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
impl Kernel
sourcepub unsafe fn new(settings: KernelSettings) -> Result<Box<Self>, &'static str>
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.
pub(crate) fn inner(&'static self) -> &'static KernelInner
pub fn timer(&'static self) -> &'static Timer
pub fn tick(&'static self) -> Tick
sourcepub fn set_global_timer(&'static self) -> Result<(), AlreadyInitialized>
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?
pub fn initialize<F>(
&'static self,
fut: F,
) -> Result<JoinHandle<F::Output>, &'static str>where
F: Future + 'static,
pub async fn spawn<F>(&'static self, fut: F) -> JoinHandle<F::Output>where
F: Future + 'static,
pub fn spawn_allocated<F>(
&'static self,
task: <BoxStorage as Storage<LocalScheduler, F>>::StoredTask,
) -> JoinHandle<F::Output>where
F: Future + 'static,
sourcepub fn initialize_default_services(
&'static self,
settings: KernelServiceSettings,
)
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:
daemons::sermux::loopback
, which serves a loopback service on a configured loopback portdaemons::sermux::hello
, which sends periodic “hello world” pings to a configured serial mux port- If the “serial-trace” feature flag is enabled, the
serial_trace::SerialSubscriber
worker task, which sendstracing
events over the serial port.
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.