Struct Base

Source
#[repr(C)]
struct Base { config: *const Config, arch: *const ArchConfig, cpu: usize, thread: *const Thread, uma: *const Uma, pmgr: *const ProcMgr, }
Expand description

Implementation of pcpu structure.

Access to this structure must be done by atomic reading or writing its field directly. It is not safe to have a temporary a pointer or reference to this struct or its field because the CPU might get interrupted, which mean it is possible for the next instruction to get executed on a different CPU if the interrupt cause the CPU to switch the task.

The activation of this struct is a minimum requirements for a new CPU to call most of the other functions. The new CPU should call run_with_context() as soon as possible. We don’t make the functions that require this context as unsafe nor make it check for the context because it will be (almost) all of it. So we impose this requirement on a function that setup a CPU instead.

Beware for any type that implement Drop because it may access the CPU context. For maximum safety the CPU setup function must not cause any value of the kernel type to drop before context is activated. It is safe to drop values of Rust core type (e.g. String) only on a main CPU because the only kernel functions it can call into is either stage 1 allocator or panic handler, both of them does not require a CPU context.

Fields§

§config: *const Config§arch: *const ArchConfig§cpu: usize§thread: *const Thread§uma: *const Uma§pmgr: *const ProcMgr

Trait Implementations§

Source§

impl Drop for Base

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Base

§

impl !RefUnwindSafe for Base

§

impl !Send for Base

§

impl !Sync for Base

§

impl Unpin for Base

§

impl !UnwindSafe for Base

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
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>,

Source§

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>,

Source§

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.