Skip to main content

CpuState

Struct CpuState 

Source
#[repr(align(64))]
pub struct CpuState { tss: Tss, gdt: UncheckedCell<GlobalDescriptorTable>, gs_info: GsInfo, }
Expand description

Per-CPU state such as TSS and GDT

Fields§

§tss: Tss§gdt: UncheckedCell<GlobalDescriptorTable>§gs_info: GsInfo

Implementations§

Source§

impl CpuState

Source

pub const fn new() -> Self

Constructor; returns a CpuState with an uninitialized TSS and GDT

Source

pub unsafe fn init_tss(&'static self)

Initialize the TSS

§Safety

The caller must guarantee that this method is called exactly once before any calls to CpuState::tss are made

Source

pub unsafe fn init_gdt(&'static self) -> GdtSetupInfo

Initialize the GDT

§Safety

The caller must guarantee the following:

  • That this method has never been called before and will never be called again
  • That at the time of calling this method, no references or pointers to this data exist
  • While this method is being called, no other CPU is working with the given data
Source

pub unsafe fn init_gs_info(&'static self)

Initialize the GS Info Struct

§Safety

The caller must guarantee the following:

  • This method is called exactly once on the CPU which owns the given CpuState
  • This method is called before the first jump to userspace on the CPU which owns the given CpuState
Source

pub unsafe fn set_kernel_stack_top(&self, kernel_stack_top: VirtAddr)

Set the kernel stack top of the CPU which owns this CpuState

§Safety

The caller must guarantee the following:

  • That CpuState::init_tss has already been called
  • This method is only called on the CPU which owns this TSS
  • That no refs/ptrs from CpuState::tss are held when this is called
  • kernel_stack_top is a valid pointer to a valid, mapped kernel stack
Source

pub fn tss(&self) -> &Tss

Getter for CpuState::tss

Source

pub unsafe fn gdt(&self) -> &GlobalDescriptorTable

Getter for CpuState::gdt

§Safety

The caller must guarantee the following:

  • That this value’s init method has already been called before
  • That at this method’s entire execution time, no mutable references or pointers to this data exist or will exist
Source

pub fn gs_info(&self) -> &GsInfo

Getter for CpuState::gs_info

Auto Trait Implementations§

§

impl !Freeze for CpuState

§

impl !RefUnwindSafe for CpuState

§

impl Send for CpuState

§

impl Sync for CpuState

§

impl Unpin for CpuState

§

impl UnsafeUnpin for CpuState

§

impl UnwindSafe for CpuState

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.