[][src]Struct kernel::process::Process

pub struct Process<'a, C: 'static + Chip> {
    app_idx: usize,
    kernel: &'static Kernel,
    chip: &'static C,
    memory: &'static mut [u8],
    kernel_memory_break: Cell<*const u8>,
    original_kernel_memory_break: *const u8,
    app_break: Cell<*const u8>,
    original_app_break: *const u8,
    allow_high_water_mark: Cell<*const u8>,
    current_stack_pointer: Cell<*const u8>,
    original_stack_pointer: *const u8,
    flash: &'static [u8],
    header: TbfHeader,
    stored_state: Cell<<<C as Chip>::UserspaceKernelBoundary as UserspaceKernelBoundary>::StoredState>,
    state: Cell<State>,
    fault_response: FaultResponse,
    mpu_config: MapCell<<<C as Chip>::MPU as MPU>::MpuConfig>,
    mpu_regions: [Cell<Option<Region>>; 6],
    tasks: MapCell<RingBuffer<'a, Task>>,
    process_name: &'static str,
    debug: MapCell<ProcessDebug>,
}

Fields

app_idx: usize

Index of the process in the process table.

Corresponds to AppId

kernel: &'static Kernel

Pointer to the main Kernel struct.

chip: &'static C

Pointer to the struct that defines the actual chip the kernel is running on. This is used because processes have subtle hardware-based differences. Specifically, the actual syscall interface and how processes are switched to is architecture-specific, and how memory must be allocated for memory protection units is also hardware-specific.

memory: &'static mut [u8]

Application memory layout:

    ╒════════ ← memory[memory.len()]
 ╔═ │ Grant
    │   ↓
 D  │ ──────  ← kernel_memory_break
 Y  │
 N  │ ──────  ← app_break               ═╗
 A  │                                    ║
 M  │   ↑                                  A
    │  Heap                              P C
 ╠═ │ ──────  ← app_heap_start           R C
    │  Data                              O E
 F  │ ──────  ← data_start_pointer       C S
 I  │ Stack                              E S
 X  │   ↓                                S I
 E  │                                    S B
 D  │ ──────  ← current_stack_pointer      L
    │                                    ║ E
 ╚═ ╘════════ ← memory[0]               ═╝

The process's memory.

kernel_memory_break: Cell<*const u8>

Pointer to the end of the allocated (and MPU protected) grant region.

original_kernel_memory_break: *const u8

Copy of where the kernel memory break is when the app is first started. This is handy if the app is restarted so we know where to reset the kernel_memory break to without having to recalculate it.

app_break: Cell<*const u8>

Pointer to the end of process RAM that has been sbrk'd to the process.

original_app_break: *const u8allow_high_water_mark: Cell<*const u8>

Pointer to high water mark for process buffers shared through allow

current_stack_pointer: Cell<*const u8>

Saved when the app switches to the kernel.

original_stack_pointer: *const u8flash: &'static [u8]

Process flash segment. This is the region of nonvolatile flash that the process occupies.

header: TbfHeader

Collection of pointers to the TBF header in flash.

stored_state: Cell<<<C as Chip>::UserspaceKernelBoundary as UserspaceKernelBoundary>::StoredState>

State saved on behalf of the process each time the app switches to the kernel.

state: Cell<State>

Whether the scheduler can schedule this app.

fault_response: FaultResponse

How to deal with Faults occurring in the process

mpu_config: MapCell<<<C as Chip>::MPU as MPU>::MpuConfig>

Configuration data for the MPU

mpu_regions: [Cell<Option<Region>>; 6]

MPU regions are saved as a pointer-size pair.

tasks: MapCell<RingBuffer<'a, Task>>

Essentially a list of callbacks that want to call functions in the process.

process_name: &'static str

Name of the app.

debug: MapCell<ProcessDebug>

Values kept so that we can print useful debug messages when apps fault.

Methods

impl<'a, C: 'static + Chip> Process<'a, C>[src]

pub(crate) unsafe fn create(
    kernel: &'static Kernel,
    chip: &'static C,
    app_flash_address: *const u8,
    remaining_app_memory: *mut u8,
    remaining_app_memory_size: usize,
    fault_response: FaultResponse,
    index: usize
) -> (Option<&'static dyn ProcessType>, usize, usize)
[src]

fn sp(&self) -> *const usize[src]

fn in_app_owned_memory(&self, buf_start_addr: *const u8, size: usize) -> bool[src]

Checks if the buffer represented by the passed in base pointer and size are within the memory bounds currently exposed to the processes (i.e. ending at app_break. If this method returns true, the buffer is guaranteed to be accessible to the process and to not overlap with the grant region.

unsafe fn grant_ptrs_reset(&self)[src]

Reset all grant_ptrs to NULL.

fn debug_set_max_stack_depth(&self)[src]

Trait Implementations

impl<'a, C: Chip> ProcessType for Process<'a, C>[src]

Auto Trait Implementations

impl<'a, C> Unpin for Process<'a, C> where
    <C as Chip>::MPU: MPU,
    <<C as Chip>::MPU as MPU>::MpuConfig: Unpin,
    <<C as Chip>::UserspaceKernelBoundary as UserspaceKernelBoundary>::StoredState: Unpin,
    <C as Chip>::UserspaceKernelBoundary: UserspaceKernelBoundary

impl<'a, C> !Send for Process<'a, C>

impl<'a, C> !Sync for Process<'a, C>

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]