[][src]Struct kernel::Kernel

pub struct Kernel {
    work: Cell<usize>,
    processes: &'static [Option<&'static dyn ProcessType>],
    grant_counter: Cell<usize>,
    grants_finalized: Cell<bool>,
}

Main object for the kernel. Each board will need to create one.

Fields

How many "to-do" items exist at any given time. These include outstanding callbacks and processes in the Running state.

This holds a pointer to the static array of Process pointers.

How many grant regions have been setup. This is incremented on every call to create_grant(). We need to explicitly track this so that when processes are created they can allocated pointers for each grant.

Flag to mark that grants have been finalized. This means that the kernel cannot support creating new grants because processes have already been created and the data structures for grants have already been established.

Methods

impl Kernel
[src]

Something was scheduled for a process, so there is more work to do.

Something finished for a process, so we decrement how much work there is to do.

Helper function for determining if we should service processes or go to sleep.

Run a closure on a specific process if it exists. If the process does not exist (i.e. it is None in the processes array) then default will be returned. Otherwise the closure will executed and passed a reference to the process.

Run a closure on every valid process. This will iterate the array of processes and call the closure on every process that exists.

Run a closure on every valid process. This will iterate the array of processes and call the closure on every process that exists. Ths method is available outside the kernel crate but requires a ProcessManagementCapability to use.

Run a closure on every process, but only continue if the closure returns FAIL. That is, if the closure returns any other return code than FAIL, that value will be returned from this function and the iteration of the array of processes will stop.

Return how many processes this board supports.

Create a new grant. This is used in board initialization to setup grants that capsules use to interact with processes.

Grants must only be created before processes are initialized. Processes use the number of grants that have been allocated to correctly initialize the process's memory with a pointer for each grant. If a grant is created after processes are initialized this will panic.

Calling this function is restricted to only certain users, and to enforce this calling this function requires the MemoryAllocationCapability capability.

Returns the number of grants that have been setup in the system and marks the grants as "finalized". This means that no more grants can be created because data structures have been setup based on the number of grants when this function is called.

In practice, this is called when processes are created, and the process memory is setup based on the number of current grants.

Cause all apps to fault.

This will call set_fault_state() on each app, causing the app to enter the state as if it had crashed (for example with an MPU violation). If the process is configured to be restarted it will be.

Only callers with the ProcessManagementCapability can call this function. This restricts general capsules from being able to call this function, since capsules should not be able to arbitrarily restart all apps.

Main loop.

Auto Trait Implementations

impl !Send for Kernel

impl !Sync for Kernel

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]