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");
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++)
#define APIC_DEST_DM_STARTUP
#define APIC_DEST_LEVELTRIG
#define APIC_DEST_DM_INIT
void setBase(const Address base)
Set memory I/O base offset.
Result map(Address phys, Size size=4096, Memory::Access access=Memory::Readable|Memory::Writable|Memory::User)
Map I/O address space.
Interrupt controller interface.
virtual IntController::Result enable(uint irq)
Enable hardware interrupt (IRQ).
virtual Timer::Result initialize()
Initialize the APIC.
virtual IntController::Result disable(uint irq)
Disable hardware interrupt (IRQ).
virtual Timer::Result wait(u32 microseconds) const
Busy wait a number of microseconds.
virtual Timer::Result stop()
Stop the APIC timer.
uint m_initialCounter
Saved initial counter value for APIC timer.
virtual Timer::Result start()
(Re)start the APIC timer.
IntController::Result sendStartupIPI(uint cpuId, Address addr)
Send startup Intercore-Processor-Interrupt.
IntController::Result sendIPI(uint coreId, uint vector)
Send Intercore-Processor-Interrupt.
IntelIO & getIO()
Get I/O object.
static const uint IOBase
APIC memory mapped I/O register base offset (physical address).
static const uint TimerVector
APIC timer interrupt vector is fixed at 48.
virtual IntController::Result clear(uint irq)
Clear hardware interrupt (IRQ).
uint getCounter() const
Get timer initial counter.
void set(Address addr, u32 data)
Set bits in memory mapped register.
void write(const Address addr, const u32 data)
Write memory mapped register.
u32 read(const Address addr) const
Read memory mapped register.
Intel 8254 Programmable Interrupt Timer (PIT).
Result waitTrigger()
Busy wait for one trigger period.
Represents a configurable timer device.
Size getFrequency() const
Get timer frequency.
Size m_int
Timer interrupt number.
Size m_frequency
Frequency of the Timer.
API::Result ProcessCtl(const ProcessID proc, const ProcessOperation op, const Address addr=0, const Address output=0)
Prototype for user applications.
C uint isKernel
Non-zero if this executable is linked as the kernel.
unsigned int u32
Unsigned 32-bit number.
unsigned long Address
A memory address.
#define NOTICE(msg)
Output a notice message.
unsigned long ulong
Unsigned long number.
unsigned int uint
Unsigned integer number.
unsigned int Size
Any sane size indicator cannot go negative.
Timer information structure.