Struct kernel::Kernel

source ·
pub struct Kernel {
    pub(crate) inner: KernelInner,
    pub(crate) registry: Registry,
}

Fields§

§inner: KernelInner

Items that do not require a lock to access, and must only be accessed with shared refs

§registry: Registry

The run-time driver registry.

Implementations§

source§

impl Kernel

source

pub unsafe fn new(settings: KernelSettings) -> Result<Box<Self>, &'static str>

Create a new kernel with the given settings.

The allocator MUST be initialized if required, and be ready to allocate data.

source

pub(crate) fn inner(&'static self) -> &'static KernelInner

source

pub fn timer(&'static self) -> &'static Timer

source

pub fn tick(&'static self) -> Tick

source

pub fn set_global_timer(&'static self) -> Result<(), AlreadyInitialized>

Initialize the kernel’s maitake timer as the global default timer.

This allows the use of sleep and timeout free functions. TODO(eliza): can the kernel just “do this” once it becomes active? Or, have a “kernel.init()” or something that does this and other global inits?

source

pub fn initialize<F>( &'static self, fut: F ) -> Result<JoinHandle<F::Output>, &'static str>where F: Future + 'static,

source

pub async fn spawn<F>(&'static self, fut: F) -> JoinHandle<F::Output>where F: Future + 'static,

source

pub fn registry(&self) -> &Registry

Immutably borrow the kernel’s Registry.

source

pub fn spawn_allocated<F>( &'static self, task: <BoxStorage as Storage<LocalScheduler, F>>::StoredTask ) -> JoinHandle<F::Output>where F: Future + 'static,

source

pub fn sleep(&'static self, duration: Duration) -> Sleep<'static>

Returns a Sleep future that sleeps for the specified Duration.

source

pub fn timeout<F: Future>( &'static self, duration: Duration, f: F ) -> Timeout<'static, F>

Returns a Timeout future that cancels F if the specified Duration has elapsed before it completes.

source

pub fn initialize_default_services( &'static self, settings: KernelServiceSettings )

Initialize the default set of cross-platform kernel services that are spawned on all hardware platforms.

Calling this method is not mandatory for a hardware platform implementation. The platform implementation may manually spawn these services individually, or choose not to spawn them at all. However, this method is provided to ensure that a consistent set of cross-platform services are initialized on all hardware platforms if they are desired.

Services spawned by this method include:

  • The KeyboardMuxService, which multiplexes keyboard input from multiple keyboards to tasks that depend on keyboard input,
  • The SerialMuxService, which multiplexes serial I/O to virtual serial ports
  • The SpawnulatorService, which is responsible for spawning new Forth tasks

In addition, this method will initialize the following non-service daemons:

If the kernel’s maitake::time::Timer has not been set as the global timer, this method will also ensure that the global timer is set as the default.

Trait Implementations§

Auto Trait Implementations§

§

impl !RefUnwindSafe for Kernel

§

impl !Send for Kernel

§

impl Unpin for Kernel

§

impl !UnwindSafe for Kernel

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> Az for T

source§

fn az<Dst>(self) -> Dstwhere T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dstwhere Src: Cast<Dst>,

source§

fn cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> CheckedAs for T

source§

fn checked_as<Dst>(self) -> Option<Dst>where T: CheckedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere Src: CheckedCast<Dst>,

source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> OverflowingAs for T

source§

fn overflowing_as<Dst>(self) -> (Dst, bool)where T: OverflowingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere Src: OverflowingCast<Dst>,

source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
source§

impl<T> SaturatingAs for T

source§

fn saturating_as<Dst>(self) -> Dstwhere T: SaturatingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere Src: SaturatingCast<Dst>,

source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
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.
source§

impl<T> UnwrappedAs for T

source§

fn unwrapped_as<Dst>(self) -> Dstwhere T: UnwrappedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere Src: UnwrappedCast<Dst>,

source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> WrappingAs for T

source§

fn wrapping_as<Dst>(self) -> Dstwhere T: WrappingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere Src: WrappingCast<Dst>,

source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.