Go to the documentation of this file.
21 #include <FreeNOS/System.h>
25 #pragma clang optimize off
26 #pragma GCC push_options
27 #pragma GCC optimize ("O0")
29 #define APIC_DEST(x) ((x) << 24)
30 #define APIC_DEST_FIELD 0x00000
31 #define APIC_DEST_LEVELTRIG 0x08000
32 #define APIC_DEST_ASSERT 0x04000
33 #define APIC_DEST_DM_INIT 0x00500
34 #define APIC_DEST_DM_STARTUP 0x00600
57 u32 t1, t2, loops = 20;
73 for (
uint i = 0; i < loops; i++)
87 NOTICE(
"Detected " << busFreq / 1000000 <<
"."
88 << busFreq % 1000000 <<
" Mhz APIC bus");
108 u32 msecPerTick = 1000.0 / info.frequency;
109 u32 msecToWait = microseconds / 1000;
110 info.ticks += (msecToWait / msecPerTick) + 1;
123 while (waited < microseconds)
128 waited += (t1 - t2) * usecPerTick;
215 for (
Size i = 0; i < 2; i++)
Size getFrequency() const
Get timer frequency.
Intel 8254 Programmable Interrupt Timer (PIT).
Interrupt controller interface.
#define APIC_DEST_DM_STARTUP
Size m_int
Timer interrupt number.
uint getCounter() const
Get timer initial counter.
unsigned long ulong
Unsigned long number.
#define NOTICE(msg)
Output a notice message.
virtual IntController::Result clear(uint irq)
Clear hardware interrupt (IRQ).
void set(Address addr, u32 data)
Set bits in memory mapped register.
Result map(Address phys, Size size=4096, Memory::Access access=Memory::Readable|Memory::Writable|Memory::User)
Map I/O address space.
virtual Timer::Result stop()
Stop the APIC timer.
C uint isKernel
Non-zero if this executable is linked as the kernel.
IntController::Result sendIPI(uint coreId, uint vector)
Send Intercore-Processor-Interrupt.
virtual Timer::Result start()
(Re)start the APIC timer.
virtual IntController::Result disable(uint irq)
Disable hardware interrupt (IRQ).
unsigned long Address
A memory address.
static const uint IOBase
APIC memory mapped I/O register base offset (physical address).
API::Result ProcessCtl(const ProcessID proc, const ProcessOperation op, const Address addr=0, const Address output=0)
Prototype for user applications.
Timer information structure.
Represents a configurable timer device.
Size m_frequency
Frequency of the Timer.
unsigned int uint
Unsigned integer number.
u32 read(const Address addr) const
Read memory mapped register.
void setBase(const Address base)
Set memory I/O base offset.
virtual IntController::Result enable(uint irq)
Enable hardware interrupt (IRQ).
unsigned int u32
Unsigned 32-bit number.
unsigned int Size
Any sane size indicator cannot go negative.
virtual Timer::Result wait(u32 microseconds) const
Busy wait a number of microseconds.
#define APIC_DEST_LEVELTRIG
#define APIC_DEST_DM_INIT
Result waitTrigger()
Busy wait for one trigger period.
void write(const Address addr, const u32 data)
Write memory mapped register.
IntController::Result sendStartupIPI(uint cpuId, Address addr)
Send startup Intercore-Processor-Interrupt.
virtual Timer::Result initialize()
Initialize the APIC.
IntelIO & getIO()
Get I/O object.
uint m_initialCounter
Saved initial counter value for APIC timer.
static const uint TimerVector
APIC timer interrupt vector is fixed at 48.