Function kernel::process_loading::load_processes_from_flash

source ยท
fn load_processes_from_flash<C: Chip>(
    kernel: &'static Kernel,
    chip: &'static C,
    app_flash: &'static [u8],
    app_memory: &'static mut [u8],
    procs: &mut &'static mut [Option<&'static dyn Process>],
    fault_policy: &'static dyn ProcessFaultPolicy,
) -> 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.

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