Struct apic::LocalApic

source ·
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

source

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 ACPI Madt table. This value is currently unused in Theseus.
  • expected_apic_id: the expected APIC ID as specified in the ACPI Madt table.
    • If Some, the APIC’s own ID (given by LocalApic::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.
  • 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.
  • nmi_lint: the local interrupt pin used for NMI. Must be 0 or 1.
  • 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.

source

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.

source

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.

source

pub fn enable_lvt_timer(&mut self, enable: bool)

Enable (unmask) or disable (mask) the LVT timer interrupt on this lapic.

source

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.

source

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.

source

pub fn version(&self) -> u32

Returns the version of this lapic.

source

pub fn error(&self) -> u32

Returns the value of this lapic’s error register.

source

pub fn clear_error(&mut self)

Clears/resets this lapic’s error register.

source

pub fn icr(&self) -> u64

Reads the current value of this lapic’s Interrupt Control Register.

source

pub fn set_icr(&mut self, value: u64)

Writes value to this lapic’s Interrupt Control Register.

source

pub fn send_ipi(&mut self, irq: u8, destination: LapicIpiDestination)

Send an IPI to the cores specified by the given destination

source

pub fn send_nmi_ipi(&mut self, destination: LapicIpiDestination)

Send a NMI IPI to the cores specified by the given destination

source

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.

source

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)

source

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.

source

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.

source

pub fn clear_pmi_mask(&mut self)

Clears the interrupt mask bit in the apic performance monitor register.

Trait Implementations§

source§

impl Debug for LocalApic

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for LocalApic

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.