FreeNOS
Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes
IntelAPIC Class Reference

Intel Advanced Programmable Interrupt Controller (APIC) More...

#include <IntelAPIC.h>

Inheritance diagram for IntelAPIC:
IntController Timer

Public Member Functions

 IntelAPIC ()
 Constructor. More...
 
IntelIOgetIO ()
 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...
 

Detailed Description

Intel Advanced Programmable Interrupt Controller (APIC)

Definition at line 45 of file IntelAPIC.h.

Member Enumeration Documentation

◆ DivideConfigFlags

Timer Divide Configuration Register flags.

Enumerator
Divide16 

Definition at line 99 of file IntelAPIC.h.

◆ Registers

enum IntelAPIC::Registers
private

Hardware registers.

Enumerator
Identifier 
Version 
TaskPriority 
ArbitrationPriority 
ProcessorPriority 
EndOfInterrupt 
SpuriousIntVec 
InService 
TriggerMode 
IntRequest 
ErrorStatus 
IntCommand1 
IntCommand2 
Timer 
ThermalSensor 
PerfCounters 
LocalInt0 
LocalInt1 
Error 
InitialCount 
CurrentCount 
DivideConfig 

Definition at line 62 of file IntelAPIC.h.

◆ SpuriousIntVecFlags

Spurious Interrupt Vector Register flags.

Enumerator
APICEnable 

Definition at line 91 of file IntelAPIC.h.

◆ TimerFlags

enum IntelAPIC::TimerFlags
private

Timer Register flags.

Enumerator
TimerMasked 
PeriodicMode 

Definition at line 107 of file IntelAPIC.h.

Constructor & Destructor Documentation

◆ IntelAPIC()

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.

Member Function Documentation

◆ clear()

IntController::Result IntelAPIC::clear ( uint  irq)
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.

Parameters
irqInterrupt Request number to clear.
Returns
Result code.

Implements IntController.

Definition at line 189 of file IntelAPIC.cpp.

References EndOfInterrupt, m_io, IntController::Success, and IntelIO::write().

Referenced by IntelKernel::clocktick().

◆ disable()

IntController::Result IntelAPIC::disable ( uint  irq)
virtual

Disable hardware interrupt (IRQ).

Parameters
irqInterrupt Request number.
Returns
Result code.

Implements IntController.

Definition at line 184 of file IntelAPIC.cpp.

References IntController::NotFound.

◆ enable()

IntController::Result IntelAPIC::enable ( uint  irq)
virtual

Enable hardware interrupt (IRQ).

Parameters
irqInterrupt Request number.
Returns
Result code.

Implements IntController.

Definition at line 179 of file IntelAPIC.cpp.

References IntController::NotFound.

◆ getCounter()

uint IntelAPIC::getCounter ( ) const

Get timer initial counter.

Returns
Initial timer counter.

Definition at line 50 of file IntelAPIC.cpp.

References InitialCount, m_io, and IntelIO::read().

Referenced by IntelKernel::IntelKernel().

◆ getIO()

IntelIO & IntelAPIC::getIO ( )

Get I/O object.

Returns
I/O object reference.

Definition at line 45 of file IntelAPIC.cpp.

References m_io.

Referenced by IntelMP::initialize().

◆ initialize()

Timer::Result IntelAPIC::initialize ( )
virtual

Initialize the APIC.

Returns
Result code.

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().

◆ sendIPI()

IntController::Result IntelAPIC::sendIPI ( uint  coreId,
uint  vector 
)

Send Intercore-Processor-Interrupt.

Parameters
coreIdCore identifier to send IPI to.
vectorInterrupt vector number of the IPI.
Returns
Result code.

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().

◆ sendStartupIPI()

IntController::Result IntelAPIC::sendStartupIPI ( uint  cpuId,
Address  addr 
)

Send startup Intercore-Processor-Interrupt.

Parameters
cpuIdCPU identifier to send startup IPI.
addrStart of execution address.
Returns
Result code.

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().

◆ start() [1/4]

Timer::Result Timer::start
private

Start the timer.

This function lets the timer run. The timer will generate interrupts on the configured frequency.

Returns
Result code.

Definition at line 64 of file Timer.cpp.

◆ start() [2/4]

Timer::Result IntelAPIC::start ( )
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.

Returns
Result code

Reimplemented from Timer.

Definition at line 149 of file IntelAPIC.cpp.

References m_io, PeriodicMode, Timer::Success, TimerVector, and IntelIO::write().

Referenced by start().

◆ start() [3/4]

Timer::Result IntelAPIC::start ( IntelPIT pit)

Start the timer using PIT as reference timer.

Parameters
pitPIT instance used to measure the APIC bus speed for clock calibration.
Returns
Result code.

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().

◆ start() [4/4]

Timer::Result IntelAPIC::start ( uint  initialCounter,
uint  hertz 
)

Start the timer with initial counter.

Parameters
initialCounterThe value of the InitialCount register.
hertzHertz associated to the initial counter.
Returns
Result code.

Definition at line 137 of file IntelAPIC.cpp.

References Divide16, DivideConfig, InitialCount, Timer::m_frequency, m_initialCounter, m_io, start(), and IntelIO::write().

◆ stop()

Timer::Result IntelAPIC::stop ( )
virtual

Stop the APIC timer.

Returns
Result code

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().

◆ wait()

Timer::Result IntelAPIC::wait ( u32  microseconds) const
virtual

Busy wait a number of microseconds.

Parameters
microsecondsThe number of microseconds to wait at minimum.
Returns
Result code.

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().

Field Documentation

◆ IOBase

const uint IntelAPIC::IOBase = 0xfee00000
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().

◆ m_initialCounter

uint IntelAPIC::m_initialCounter
private

Saved initial counter value for APIC timer.

Definition at line 237 of file IntelAPIC.h.

Referenced by IntelAPIC(), and start().

◆ m_io

IntelIO IntelAPIC::m_io
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().

◆ TimerVector

const uint IntelAPIC::TimerVector = 48
static

APIC timer interrupt vector is fixed at 48.

Definition at line 55 of file IntelAPIC.h.

Referenced by initialize(), IntelAPIC(), start(), and stop().


The documentation for this class was generated from the following files: