[][src]Trait kernel::process::ProcessType

pub trait ProcessType {
    fn appid(&self) -> AppId;
fn enqueue_task(&self, task: Task) -> bool;
fn dequeue_task(&self) -> Option<Task>;
fn remove_pending_callbacks(&self, callback_id: CallbackId);
fn get_state(&self) -> State;
fn set_yielded_state(&self);
fn stop(&self);
fn resume(&self);
fn set_fault_state(&self);
fn get_process_name(&self) -> &'static str;
fn brk(&self, new_break: *const u8) -> Result<*const u8, Error>;
fn sbrk(&self, increment: isize) -> Result<*const u8, Error>;
fn mem_start(&self) -> *const u8;
fn mem_end(&self) -> *const u8;
fn flash_start(&self) -> *const u8;
fn flash_end(&self) -> *const u8;
fn kernel_memory_break(&self) -> *const u8;
fn number_writeable_flash_regions(&self) -> usize;
fn get_writeable_flash_region(&self, region_index: usize) -> (u32, u32);
fn update_stack_start_pointer(&self, stack_pointer: *const u8);
fn update_heap_start_pointer(&self, heap_pointer: *const u8);
fn allow(
        &self,
        buf_start_addr: *const u8,
        size: usize
    ) -> Result<Option<AppSlice<Shared, u8>>, ReturnCode>;
fn flash_non_protected_start(&self) -> *const u8;
fn setup_mpu(&self);
fn add_mpu_region(
        &self,
        unallocated_memory_start: *const u8,
        unallocated_memory_size: usize,
        min_region_size: usize
    ) -> Option<Region>;
unsafe fn alloc(&self, size: usize, align: usize) -> Option<&mut [u8]>;
unsafe fn free(&self, _: *mut u8);
unsafe fn grant_ptr(&self, grant_num: usize) -> *mut *mut u8;
unsafe fn set_syscall_return_value(&self, return_value: isize);
unsafe fn set_process_function(&self, callback: FunctionCall);
unsafe fn switch_to(&self) -> Option<ContextSwitchReason>;
unsafe fn fault_fmt(&self, writer: &mut dyn Write);
unsafe fn process_detail_fmt(&self, writer: &mut dyn Write);
fn debug_syscall_count(&self) -> usize;
fn debug_dropped_callback_count(&self) -> usize;
fn debug_restart_count(&self) -> usize;
fn debug_timeslice_expiration_count(&self) -> usize;
fn debug_timeslice_expired(&self); }

This trait is implemented by process structs.

Required methods

fn appid(&self) -> AppId

Returns the process's identifier

fn enqueue_task(&self, task: Task) -> bool

Queue a Task for the process. This will be added to a per-process buffer and executed by the scheduler. Tasks are some function the app should run, for example a callback or an IPC call.

This function returns true if the Task was successfully enqueued, and false otherwise. This is represented as a simple bool because this is passed to the capsule that tried to schedule the Task.

fn dequeue_task(&self) -> Option<Task>

Remove the scheduled operation from the front of the queue and return it to be handled by the scheduler.

If there are no Tasks in the queue for this process this will return None.

fn remove_pending_callbacks(&self, callback_id: CallbackId)

Remove all scheduled callbacks for a given callback id from the task queue.

fn get_state(&self) -> State

Returns the current state the process is in. Common states are "running" or "yielded".

fn set_yielded_state(&self)

Move this process from the running state to the yielded state.

fn stop(&self)

Move this process from running or yielded state into the stopped state

fn resume(&self)

Move this stopped process back into its original state

fn set_fault_state(&self)

Put this process in the fault state. This will trigger the FaultResponse for this process to occur.

fn get_process_name(&self) -> &'static str

Get the name of the process. Used for IPC.

fn brk(&self, new_break: *const u8) -> Result<*const u8, Error>

Change the location of the program break and reallocate the MPU region covering program memory.

fn sbrk(&self, increment: isize) -> Result<*const u8, Error>

Change the location of the program break, reallocate the MPU region covering program memory, and return the previous break address.

fn mem_start(&self) -> *const u8

The start address of allocated RAM for this process.

fn mem_end(&self) -> *const u8

The first address after the end of the allocated RAM for this process.

fn flash_start(&self) -> *const u8

The start address of the flash region allocated for this process.

fn flash_end(&self) -> *const u8

The first address after the end of the flash region allocated for this process.

fn kernel_memory_break(&self) -> *const u8

The lowest address of the grant region for the process.

fn number_writeable_flash_regions(&self) -> usize

How many writeable flash regions defined in the TBF header for this process.

fn get_writeable_flash_region(&self, region_index: usize) -> (u32, u32)

Get the offset from the beginning of flash and the size of the defined writeable flash region.

fn update_stack_start_pointer(&self, stack_pointer: *const u8)

Debug function to update the kernel on where the stack starts for this process. Processes are not required to call this through the memop system call, but it aids in debugging the process.

fn update_heap_start_pointer(&self, heap_pointer: *const u8)

Debug function to update the kernel on where the process heap starts. Also optional.

fn allow(
    &self,
    buf_start_addr: *const u8,
    size: usize
) -> Result<Option<AppSlice<Shared, u8>>, ReturnCode>

Creates an AppSlice from the given offset and size in process memory.

Returns

If the buffer is null (a zero-valued offset), return None, signaling the capsule to delete the entry. If the buffer is within the process's accessible memory, returns an AppSlice wrapping that buffer. Otherwise, returns an error ReturnCode.

fn flash_non_protected_start(&self) -> *const u8

Get the first address of process's flash that isn't protected by the kernel. The protected range of flash contains the TBF header and potentially other state the kernel is storing on behalf of the process, and cannot be edited by the process.

fn setup_mpu(&self)

Configure the MPU to use the process's allocated regions.

fn add_mpu_region(
    &self,
    unallocated_memory_start: *const u8,
    unallocated_memory_size: usize,
    min_region_size: usize
) -> Option<Region>

Allocate a new MPU region for the process that is at least min_region_size bytes and lies within the specified stretch of unallocated memory.

unsafe fn alloc(&self, size: usize, align: usize) -> Option<&mut [u8]>

Create new memory in the grant region, and check that the MPU region covering program memory does not extend past the kernel memory break.

unsafe fn free(&self, _: *mut u8)

unsafe fn grant_ptr(&self, grant_num: usize) -> *mut *mut u8

Get a pointer to the grant pointer for this grant number.

unsafe fn set_syscall_return_value(&self, return_value: isize)

Set the return value the process should see when it begins executing again after the syscall.

unsafe fn set_process_function(&self, callback: FunctionCall)

Set the function that is to be executed when the process is resumed.

unsafe fn switch_to(&self) -> Option<ContextSwitchReason>

Context switch to a specific process.

unsafe fn fault_fmt(&self, writer: &mut dyn Write)

unsafe fn process_detail_fmt(&self, writer: &mut dyn Write)

fn debug_syscall_count(&self) -> usize

Returns how many syscalls this app has called.

fn debug_dropped_callback_count(&self) -> usize

Returns how many callbacks for this process have been dropped.

fn debug_restart_count(&self) -> usize

Returns how many times this process has been restarted.

fn debug_timeslice_expiration_count(&self) -> usize

Returns how many times this process has exceeded its timeslice.

fn debug_timeslice_expired(&self)

Loading content...

Implementors

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

Loading content...