FreeNOS
|
Intel Advanced Programmable Interrupt Controller (APIC) More...
#include <IntelAPIC.h>
Public Member Functions | |
IntelAPIC () | |
Constructor. More... | |
IntelIO & | getIO () |
Get I/O object. More... | |
uint | getCounter () const |
Get timer initial counter. More... | |
virtual Timer::Result | initialize () |
Initialize the APIC. More... | |
virtual Timer::Result | wait (u32 microseconds) const |
Busy wait a number of microseconds. More... | |
Timer::Result | start (IntelPIT *pit) |
Start the timer using PIT as reference timer. More... | |
Timer::Result | start (uint initialCounter, uint hertz) |
Start the timer with initial counter. More... | |
virtual Timer::Result | start () |
(Re)start the APIC timer. More... | |
virtual Timer::Result | stop () |
Stop the APIC timer. More... | |
virtual IntController::Result | enable (uint irq) |
Enable hardware interrupt (IRQ). More... | |
virtual IntController::Result | disable (uint irq) |
Disable hardware interrupt (IRQ). More... | |
virtual IntController::Result | clear (uint irq) |
Clear hardware interrupt (IRQ). More... | |
IntController::Result | sendStartupIPI (uint cpuId, Address addr) |
Send startup Intercore-Processor-Interrupt. More... | |
IntController::Result | sendIPI (uint coreId, uint vector) |
Send Intercore-Processor-Interrupt. More... | |
Public Member Functions inherited from IntController | |
IntController () | |
Constructor. More... | |
uint | getBase () const |
Get interrupt number base offset. More... | |
virtual Result | nextPending (uint &irq) |
Retrieve the next pending interrupt (IRQ). More... | |
virtual bool | isTriggered (uint irq) |
Check if an IRQ vector is set. More... | |
virtual Result | send (const uint targetCoreId, const uint irq) |
Send an inter-processor-interrupt (IPI). More... | |
Public Member Functions inherited from Timer | |
struct Timer::Info | ALIGN (8) Info |
Timer information structure. More... | |
Timer () | |
Constructor. More... | |
Size | getInterrupt () const |
Get timer interrupt number. More... | |
Size | getFrequency () const |
Get timer frequency. More... | |
virtual Result | setFrequency (Size hertz) |
Set timer frequency. More... | |
virtual Result | getCurrent (Info *info, const Size msecOffset=0) |
Get current timer info. More... | |
virtual Result | tick () |
Process timer tick. More... | |
bool | isExpired (const Info &info) const |
Check if a timer value is expired. More... | |
Static Public Attributes | |
static const uint | IOBase = 0xfee00000 |
APIC memory mapped I/O register base offset (physical address). More... | |
static const uint | TimerVector = 48 |
APIC timer interrupt vector is fixed at 48. More... | |
Private Types | |
enum | Registers { Identifier = 0x20, Version = 0x30, TaskPriority = 0x80, ArbitrationPriority = 0x90, ProcessorPriority = 0xa0, EndOfInterrupt = 0xb0, SpuriousIntVec = 0xf0, InService = 0x100, TriggerMode = 0x180, IntRequest = 0x200, ErrorStatus = 0x280, IntCommand1 = 0x300, IntCommand2 = 0x310, Timer = 0x320, ThermalSensor = 0x330, PerfCounters = 0x340, LocalInt0 = 0x350, LocalInt1 = 0x360, Error = 0x370, InitialCount = 0x380, CurrentCount = 0x390, DivideConfig = 0x3e0 } |
Hardware registers. More... | |
enum | SpuriousIntVecFlags { APICEnable = 0x100 } |
Spurious Interrupt Vector Register flags. More... | |
enum | DivideConfigFlags { Divide16 = 3 } |
Timer Divide Configuration Register flags. More... | |
enum | TimerFlags { TimerMasked = (1 << 16), PeriodicMode = (1 << 17) } |
Timer Register flags. More... | |
Private Member Functions | |
virtual Result | start () |
Start the timer. More... | |
Private Attributes | |
IntelIO | m_io |
I/O object. More... | |
uint | m_initialCounter |
Saved initial counter value for APIC timer. More... | |
Additional Inherited Members | |
Public Types inherited from IntController | |
enum | Result { Success, InvalidIRQ, InvalidFrequency, IOError, NotFound } |
Result codes. More... | |
Public Types inherited from Timer | |
enum | Result { Success, NotFound, IOError, InvalidFrequency } |
Result codes. More... | |
Data Fields inherited from Timer | |
enum Timer::Result | ALIGN |
Protected Attributes inherited from IntController | |
uint | m_base |
Interrupt number base offset. More... | |
Protected Attributes inherited from Timer | |
Size | m_ticks |
The current timer ticks. More... | |
Size | m_frequency |
Frequency of the Timer. More... | |
Size | m_int |
Timer interrupt number. More... | |
Intel Advanced Programmable Interrupt Controller (APIC)
Definition at line 45 of file IntelAPIC.h.
|
private |
Timer Divide Configuration Register flags.
Enumerator | |
---|---|
Divide16 |
Definition at line 99 of file IntelAPIC.h.
|
private |
Hardware registers.
Definition at line 62 of file IntelAPIC.h.
|
private |
Spurious Interrupt Vector Register flags.
Enumerator | |
---|---|
APICEnable |
Definition at line 91 of file IntelAPIC.h.
|
private |
Timer Register flags.
Enumerator | |
---|---|
TimerMasked | |
PeriodicMode |
Definition at line 107 of file IntelAPIC.h.
IntelAPIC::IntelAPIC | ( | ) |
Constructor.
Definition at line 36 of file IntelAPIC.cpp.
References IOBase, Timer::m_frequency, m_initialCounter, Timer::m_int, m_io, IO::setBase(), and TimerVector.
|
virtual |
Clear hardware interrupt (IRQ).
Clearing marks the end of an interrupt service routine and causes the controller to trigger the interrupt again on the next trigger moment.
irq | Interrupt Request number to clear. |
Implements IntController.
Definition at line 189 of file IntelAPIC.cpp.
References EndOfInterrupt, m_io, IntController::Success, and IntelIO::write().
Referenced by IntelKernel::clocktick().
|
virtual |
Disable hardware interrupt (IRQ).
irq | Interrupt Request number. |
Implements IntController.
Definition at line 184 of file IntelAPIC.cpp.
References IntController::NotFound.
|
virtual |
Enable hardware interrupt (IRQ).
irq | Interrupt Request number. |
Implements IntController.
Definition at line 179 of file IntelAPIC.cpp.
References IntController::NotFound.
uint IntelAPIC::getCounter | ( | ) | const |
Get timer initial counter.
Definition at line 50 of file IntelAPIC.cpp.
References InitialCount, m_io, and IntelIO::read().
Referenced by IntelKernel::IntelKernel().
IntelIO & IntelAPIC::getIO | ( | ) |
Get I/O object.
Definition at line 45 of file IntelAPIC.cpp.
References m_io.
Referenced by IntelMP::initialize().
|
virtual |
Initialize the APIC.
Reimplemented from Timer.
Definition at line 162 of file IntelAPIC.cpp.
References APICEnable, Divide16, DivideConfig, EndOfInterrupt, InitialCount, IOBase, Timer::IOError, m_io, IO::map(), PeriodicMode, IntelIO::set(), SpuriousIntVec, IO::Success, Timer::Success, TimerVector, and IntelIO::write().
Referenced by IntelKernel::IntelKernel().
IntController::Result IntelAPIC::sendIPI | ( | uint | coreId, |
uint | vector | ||
) |
Send Intercore-Processor-Interrupt.
coreId | Core identifier to send IPI to. |
vector | Interrupt vector number of the IPI. |
Definition at line 237 of file IntelAPIC.cpp.
References APIC_DEST, APIC_DEST_ASSERT, APIC_DEST_FIELD, APIC_DEST_LEVELTRIG, IntCommand1, IntCommand2, m_io, IntelIO::read(), IntController::Success, and IntelIO::write().
Referenced by IntelCoreServer::sendIPI().
IntController::Result IntelAPIC::sendStartupIPI | ( | uint | cpuId, |
Address | addr | ||
) |
Send startup Intercore-Processor-Interrupt.
cpuId | CPU identifier to send startup IPI. |
addr | Start of execution address. |
Definition at line 195 of file IntelAPIC.cpp.
References APIC_DEST, APIC_DEST_ASSERT, APIC_DEST_DM_INIT, APIC_DEST_DM_STARTUP, APIC_DEST_FIELD, APIC_DEST_LEVELTRIG, IntCommand1, IntCommand2, m_io, IntelIO::read(), IntController::Success, wait(), and IntelIO::write().
Referenced by IntelMP::boot().
|
private |
|
virtual |
(Re)start the APIC timer.
This function only re-enables the APIC timer. APIC initialization and timer configuration must be done prior to calling this function.
Reimplemented from Timer.
Definition at line 149 of file IntelAPIC.cpp.
References m_io, PeriodicMode, Timer::Success, TimerVector, and IntelIO::write().
Referenced by start().
Timer::Result IntelAPIC::start | ( | IntelPIT * | pit | ) |
Start the timer using PIT as reference timer.
pit | PIT instance used to measure the APIC bus speed for clock calibration. |
Definition at line 55 of file IntelAPIC.cpp.
References CurrentCount, Divide16, DivideConfig, Timer::getFrequency(), InitialCount, Timer::m_frequency, m_initialCounter, m_io, NOTICE, PeriodicMode, IntelIO::read(), Timer::Success, TimerVector, IntelPIT::waitTrigger(), and IntelIO::write().
Referenced by IntelKernel::enableIRQ(), and IntelKernel::IntelKernel().
Timer::Result IntelAPIC::start | ( | uint | initialCounter, |
uint | hertz | ||
) |
Start the timer with initial counter.
initialCounter | The value of the InitialCount register. |
hertz | Hertz associated to the initial counter. |
Definition at line 137 of file IntelAPIC.cpp.
References Divide16, DivideConfig, InitialCount, Timer::m_frequency, m_initialCounter, m_io, start(), and IntelIO::write().
|
virtual |
Stop the APIC timer.
Reimplemented from Timer.
Definition at line 156 of file IntelAPIC.cpp.
References m_io, Timer::Success, TimerMasked, TimerVector, and IntelIO::write().
Referenced by IntelKernel::enableIRQ().
|
virtual |
Busy wait a number of microseconds.
microseconds | The number of microseconds to wait at minimum. |
Reimplemented from Timer.
Definition at line 93 of file IntelAPIC.cpp.
References CurrentCount, InfoTimer, InitialCount, Timer::IOError, isKernel, Timer::m_frequency, m_io, ProcessCtl(), IntelIO::read(), SELF, Timer::Success, API::Success, and WaitTimer.
Referenced by sendStartupIPI().
|
static |
APIC memory mapped I/O register base offset (physical address).
Definition at line 52 of file IntelAPIC.h.
Referenced by initialize(), IntelMP::initialize(), and IntelAPIC().
|
private |
Saved initial counter value for APIC timer.
Definition at line 237 of file IntelAPIC.h.
Referenced by IntelAPIC(), and start().
|
private |
I/O object.
Definition at line 234 of file IntelAPIC.h.
Referenced by clear(), getCounter(), getIO(), initialize(), IntelAPIC(), sendIPI(), sendStartupIPI(), start(), stop(), and wait().
|
static |
APIC timer interrupt vector is fixed at 48.
Definition at line 55 of file IntelAPIC.h.
Referenced by initialize(), IntelAPIC(), start(), and stop().