Struct devices::irqchip::Apic

source ·
pub struct Apic {
    id: u8,
    cycle_length: Duration,
    regs: [u8; 4096],
    mp_state: MPState,
    timer: Box<dyn TimerTrait>,
    timer_length: Option<Duration>,
    last_tick: Instant,
    sipi: Option<Vector>,
    init: bool,
    nmis: u32,
}

Fields§

§id: u8§cycle_length: Duration

Base duration for the APIC timer. A timer set with initial count = 1 and timer frequency divide = 1 runs for this long.

§regs: [u8; 4096]§mp_state: MPState§timer: Box<dyn TimerTrait>§timer_length: Option<Duration>§last_tick: Instant§sipi: Option<Vector>§init: bool§nmis: u32

Implementations§

source§

impl Apic

source

pub fn new(id: u8, timer: Box<dyn TimerTrait>) -> Self

Constructs a new APIC with local APIC ID id.

source

pub fn frequency() -> u32

Get the Apic frequency in Hz

source

pub fn id(&self) -> u8

Returns the local APIC ID.

source

pub fn get_cycle_length(&self) -> Duration

Returns the base duration for the APIC timer. A timer set with initial count = 1 and timer frequency divide = 1 runs for this long.

source

pub fn get_state(&self) -> LapicState

Returns the state of the APIC registers.

source

pub fn set_state(&mut self, state: &LapicState)

Sets the state of the APIC registers.

source

pub fn get_mp_state(&self) -> MPState

Gets the multi-processing state.

source

pub fn set_mp_state(&mut self, state: &MPState)

Sets the multi-processing state.

source

fn valid_mmio(offset: u64, data: &[u8]) -> bool

Checks that offset is 16-byte aligned and data is 4 bytes.

source

pub fn read(&self, offset: u64, data: &mut [u8])

Handles an MMIO read forwarded from the IRQ chip. Reads data from the APIC’s register at offset into data.

source

pub fn write(&mut self, offset: u64, data: &[u8]) -> Option<ApicBusMsg>

Handles an MMIO write forwarded from the IRQ chip. Writes data into the APIC’s register at offset, optionally returning a command back to the IRQ chip.

source

pub fn single_dest_fast(dest: &InterruptDestination) -> Option<u8>

If dest specifies a single destination APIC that can be determined quickly without calling match_dest on each APIC, then return the destination APIC ID, otherwise return None.

source

pub fn match_dest(&self, dest: &InterruptDestination) -> bool

Returns true if this APIC is one of the destinations of the interrupt dest.

source

pub fn get_processor_priority(&self) -> u8

Returns the processor priority register.

source

pub fn accept_irq(&mut self, i: &InterruptData)

Enqueues an interrupt to be delivered to this APIC’s vcpu.

source

fn inject_interrupt(&mut self, clear: bool) -> Option<Vector>

Returns the highest-priority vector in the IRR that has high enough priority to be serviced (i.e., its priority class is greater than the current processor priority class). If clear is true, the IRR bit for that vector is cleared and the ISR bit is set.

source

fn decode_icr(&mut self) -> Interrupt

Parses data from the Interrupt Command Register into an interrupt.

source

fn enabled(&self) -> bool

Returns true if the APIC is software-enabled, false if it’s software-disabled.

source

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

Sets or unsets the software enabled bit in the Spurious Int register.

source

pub fn get_pending_irqs(&mut self, vcpu_ready: bool) -> PendingInterrupts

Gets pending interrupts to be injected into this APIC’s vcpu. The interrupts returned are cleared from the APIC. vcpu_ready indicates if the vcpu is ready to receive fixed interrupts (i.e., if the vcpu’s interrupt window is open, IF flag is set, and the PIC hasn’t already injected an interrupt).

source

pub fn load_reset_state(&mut self)

Resets the APIC to its initial state. Used for initializing a new APIC and when the vcpu receives an INIT.

source

pub fn debug_status(&self) -> String

source

pub fn handle_timer_expiration(&mut self)

Callback to be called by a timer worker when the timer expires.

source

fn get_reg(&self, offset: usize) -> u32

Returns the first 4 bytes of the register that starts at offset.

source

fn set_reg(&mut self, offset: usize, val: u32)

Sets the first 4 bytes of the register that starts at offset to val.

source

fn reg_bit_for_vector(reg: VectorReg, vector: Vector) -> (usize, u8)

Finds the bit for vector in vector bitmap register reg. Returns (index, bitmask) where index is the index of the register byte for vector, and bitmask has one bit set for the vector bit within that byte.

source

fn set_vector_bit(&mut self, reg: VectorReg, vector: Vector)

source

fn clear_vector_bit(&mut self, reg: VectorReg, vector: Vector)

source

fn highest_bit_in_vector(&self, reg: VectorReg) -> Option<Vector>

Returns the vector of the highest bit set in reg.

source

fn matches_logical_address(&self, dest: u8) -> bool

Returns true if this apic is a possible destination for the logical address dest.

source

fn get_timer_divide_control(&self) -> u32

source

fn start_timer(&mut self)

source

fn clear_timer(&mut self)

source

fn next_timer_expiration(&self) -> Duration

Returns the duration remaining until the next timer expiration.

Trait Implementations§

source§

impl Drop for Apic

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Apic

§

impl Send for Apic

§

impl !Sync for Apic

§

impl Unpin for Apic

§

impl !UnwindSafe for Apic

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where 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 T
where 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 T
where 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V