⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

VirtualCpu

Struct VirtualCpu 

Source
pub struct VirtualCpu {
    pub id: u8,
    pub state: VcpuState,
    pub registers: GuestRegisters,
    pub apic_id: u8,
    pub pending_ipis: Vec<IpiMessage>,
    pub is_bsp: bool,
    pub host_affinity: Option<u32>,
    pub sipi_vector: u8,
    pub vmcs_fields: BTreeMap<u32, u64>,
}
Expand description

Virtual CPU

Fields§

§id: u8

vCPU ID (0 = BSP, 1+ = APs)

§state: VcpuState

Current execution state

§registers: GuestRegisters

General-purpose registers

§apic_id: u8

LAPIC ID for this vCPU

§pending_ipis: Vec<IpiMessage>

Pending IPIs (queue)

§is_bsp: bool

Whether this is the bootstrap processor

§host_affinity: Option<u32>

Host thread affinity (which host CPU to schedule on)

§sipi_vector: u8

SIPI vector (real-mode entry = vector * 0x1000)

§vmcs_fields: BTreeMap<u32, u64>

VMCS field values for this vCPU

Implementations§

Source§

impl VirtualCpu

Source

pub fn new(id: u8, is_bsp: bool) -> Self

Source

pub fn deliver_ipi(&mut self, ipi: IpiMessage)

Deliver an IPI to this vCPU

Source

pub fn pop_ipi(&mut self) -> Option<IpiMessage>

Pop next pending IPI

Source

pub fn set_affinity(&mut self, host_cpu: u32)

Set host CPU affinity for scheduling

Source

pub fn pending_ipi_count(&self) -> usize

Source

pub fn halt(&mut self)

Halt the vCPU (from HLT instruction)

Source

pub fn pause(&mut self)

Pause the vCPU (hypervisor request)

Source

pub fn resume(&mut self)

Resume the vCPU

Source

pub fn stop(&mut self)

Stop the vCPU permanently

Auto Trait Implementations§

§

impl Freeze for VirtualCpu

§

impl RefUnwindSafe for VirtualCpu

§

impl Send for VirtualCpu

§

impl Sync for VirtualCpu

§

impl Unpin for VirtualCpu

§

impl UnwindSafe for VirtualCpu

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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.
§

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

Performs the conversion.