Function kernel::process::load_processes_advanced[][src]

pub fn load_processes_advanced<C: Chip>(
    kernel: &'static Kernel,
    chip: &'static C,
    app_flash: &'static [u8],
    app_memory: &mut [u8],
    procs: &'static mut [Option<&'static dyn Process>],
    fault_policy: &'static dyn ProcessFaultPolicy,
    require_kernel_version: bool,
    _capability: &dyn ProcessManagementCapability
) -> Result<(), ProcessLoadError>
Expand description

Helper function to load processes from flash into an array of active processes. This is the default template for loading processes, but a board is able to create its own load_processes() function and use that instead.

Processes are found in flash starting from the given address and iterating through Tock Binary Format (TBF) headers. Processes are given memory out of the app_memory buffer until either the memory is exhausted or the allocated number of processes are created. This buffer is a non-static slice, ensuring that this code cannot hold onto the slice past the end of this function (instead, processes store a pointer and length), which necessary for later creation of ProcessBuffers in this memory region to be sound. A reference to each process is stored in the provided procs array. How process faults are handled by the kernel must be provided and is assigned to every created process.

This function is made pub so that board files can use it, but loading processes from slices of flash an memory is fundamentally unsafe. Therefore, we require the ProcessManagementCapability to call this function.

Returns Ok(()) if process discovery went as expected. Returns a ProcessLoadError if something goes wrong during TBF parsing or process creation.