pub struct LocalApic { /* private fields */ }
Expand description
This structure represents a single Local APIC in the system; there is one per CPU.
Implementations§
source§impl LocalApic
impl LocalApic
sourcepub fn init(
page_table: &mut PageTable,
processor_id: u32,
expected_apic_id: Option<u32>,
should_be_bsp: bool,
nmi_lint: u8,
nmi_flags: u16
) -> Result<(), LapicInitError>
pub fn init( page_table: &mut PageTable, processor_id: u32, expected_apic_id: Option<u32>, should_be_bsp: bool, nmi_lint: u8, nmi_flags: u16 ) -> Result<(), LapicInitError>
Creates and initializes a new LocalApic
for the current CPU core
and adds it to the global set of initialized local APICs.
Arguments
page_table
: the page table used to map the APIC MMIO registers (only used for xapic, not x2apic).processor_id
: the processor ID specified in the ACPIMadt
table. This value is currently unused in Theseus.expected_apic_id
: the expected APIC ID as specified in the ACPIMadt
table.- If
Some
, the APIC’s own ID (given byLocalApic::read_apic_id()
) must match this value, otherwise an error will be returned. - If
None
, the local APIC will determine its own ID value, and no check is performed.
- If
should_be_bsp
: whether or not this CPU is expected to be the BSP.- If
true
, this CPU must be the BSP (bootstrap processor). - If
false
, this CPU must not be the BSP – it must be an AP. - An error is returned if the above checks fail.
- If
nmi_lint
: the local interrupt pin used for NMI. Must be0
or1
.nmi_flags
: the flags used to configure the local NMI interrupt.
Important Usage Note
This MUST be invoked from each CPU itself when it is booting up, i.e., the BSP cannot invoke this for other APs.
sourcepub fn processor_id(&self) -> u32
pub fn processor_id(&self) -> u32
Returns the “processor ID” of this local APIC, which is currently unused.
This value comes from the MADT
ACPI table entry that was used
to boot up this CPU core.
sourcepub fn is_bootstrap_cpu(&self) -> bool
pub fn is_bootstrap_cpu(&self) -> bool
Returns true
if this CPU core was the BootStrap Processor (BSP),
i.e., the first CPU to boot and run the OS code.
There is only one BSP per system.
sourcepub fn enable_lvt_timer(&mut self, enable: bool)
pub fn enable_lvt_timer(&mut self, enable: bool)
Enable (unmask) or disable (mask) the LVT timer interrupt on this lapic.
sourcepub fn apic_id(&self) -> ApicId
pub fn apic_id(&self) -> ApicId
Returns the ID of this Local APIC (fast).
Unlike LocalApic::read_apic_id()
, this does not read any hardware registers.
sourcepub fn read_apic_id(&self) -> ApicId
pub fn read_apic_id(&self) -> ApicId
Reads the hardware-provided ID of this Local APIC from its registers (slow).
The semantics of this are defined in section 10.4.6 of the Intel SDM.
sourcepub fn clear_error(&mut self)
pub fn clear_error(&mut self)
Clears/resets this lapic’s error register.
sourcepub fn send_ipi(&mut self, irq: u8, destination: LapicIpiDestination)
pub fn send_ipi(&mut self, irq: u8, destination: LapicIpiDestination)
Send an IPI to the cores specified by the given destination
sourcepub fn send_nmi_ipi(&mut self, destination: LapicIpiDestination)
pub fn send_nmi_ipi(&mut self, destination: LapicIpiDestination)
Send a NMI IPI to the cores specified by the given destination
sourcepub fn eoi(&mut self)
pub fn eoi(&mut self)
Send an End Of Interrupt (EOI) signal to this local APIC, which indicates that the calling interrupt handler has finished handling the current interrupt.
sourcepub fn set_nmi(&mut self, lint: LvtLint, flags: u16)
pub fn set_nmi(&mut self, lint: LvtLint, flags: u16)
Set the NonMaskableInterrupt redirect for this LocalApic.
Argument lint
can be either 0 or 1, since each local APIC has two LVT LINTs
(Local Vector Table Local INTerrupts)
sourcepub fn get_isr(&self) -> [u32; 8]
pub fn get_isr(&self) -> [u32; 8]
Returns the values of the 8 in-service registers for this APIC, which is a series of bitmasks that shows which interrupt lines are currently being serviced.
sourcepub fn get_irr(&self) -> [u32; 8]
pub fn get_irr(&self) -> [u32; 8]
Returns the values of the 8 request registers for this APIC, which is a series of bitmasks that shows which interrupt lines are currently raised, but not yet being serviced.
sourcepub fn clear_pmi_mask(&mut self)
pub fn clear_pmi_mask(&mut self)
Clears the interrupt mask bit in the apic performance monitor register.