[][src]Struct kernel::sched::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

work: Cell<usize>

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

processes: &'static [Option<&'static dyn ProcessType>]

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

grant_counter: Cell<usize>

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.

grants_finalized: Cell<bool>

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]

pub fn new(processes: &'static [Option<&'static dyn ProcessType>]) -> Kernel[src]

pub(crate) fn increment_work(&self)[src]

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

pub(crate) fn decrement_work(&self)[src]

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

fn processes_blocked(&self) -> bool[src]

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

pub(crate) fn process_map_or<F, R>(
    &self,
    default: R,
    process_index: usize,
    closure: F
) -> R where
    F: FnOnce(&dyn ProcessType) -> R, 
[src]

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.

pub(crate) fn process_each<F>(&self, closure: F) where
    F: Fn(&dyn ProcessType), 
[src]

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

pub fn process_each_capability<F>(
    &'static self,
    _capability: &dyn ProcessManagementCapability,
    closure: F
) where
    F: Fn(usize, &dyn ProcessType), 
[src]

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.

pub(crate) fn process_until<F>(&self, closure: F) -> ReturnCode where
    F: Fn(&dyn ProcessType) -> ReturnCode
[src]

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.

pub(crate) fn number_of_process_slots(&self) -> usize[src]

Return how many processes this board supports.

pub fn create_grant<T: Default>(
    &'static self,
    _capability: &dyn MemoryAllocationCapability
) -> Grant<T>
[src]

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.

pub(crate) fn get_grant_count_and_finalize(&self) -> usize[src]

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.

pub fn hardfault_all_apps<C: ProcessManagementCapability>(&self, _c: &C)[src]

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.

pub fn kernel_loop<P: Platform, C: Chip>(
    &'static self,
    platform: &P,
    chip: &C,
    ipc: Option<&IPC>,
    _capability: &dyn MainLoopCapability
)
[src]

Main loop.

unsafe fn do_process<P: Platform, C: Chip>(
    &self,
    platform: &P,
    chip: &C,
    process: &dyn ProcessType,
    ipc: Option<&IPC>
)
[src]

Auto Trait Implementations

impl Unpin for Kernel

impl !Send for Kernel

impl !Sync for Kernel

Blanket Implementations

impl<T> From<T> for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

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

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

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