Struct kernel::process::ProcessStandard
source · [−]pub struct ProcessStandard<'a, C: 'static + Chip> { /* private fields */ }
Expand description
A type for userspace processes in Tock.
Trait Implementations
sourceimpl<C: Chip> Process for ProcessStandard<'_, C>
impl<C: Chip> Process for ProcessStandard<'_, C>
sourcefn enqueue_task(&self, task: Task) -> Result<(), ErrorCode>
fn enqueue_task(&self, task: Task) -> Result<(), ErrorCode>
Queue a Task
for the process. This will be added to a per-process
buffer and executed by the scheduler. Task
s are some function the app
should run, for example a upcall or an IPC call. Read more
sourcefn remove_pending_upcalls(&self, upcall_id: UpcallId)
fn remove_pending_upcalls(&self, upcall_id: UpcallId)
Remove all scheduled upcalls for a given upcall id from the task queue. Read more
sourcefn get_state(&self) -> State
fn get_state(&self) -> State
Returns the current state the process is in. Common states are “running” or “yielded”. Read more
sourcefn set_yielded_state(&self)
fn set_yielded_state(&self)
Move this process from the running state to the yielded state. Read more
sourcefn stop(&self)
fn stop(&self)
Move this process from running or yielded state into the stopped state. Read more
sourcefn set_fault_state(&self)
fn set_fault_state(&self)
Put this process in the fault state. This will trigger the
FaultResponse
for this process to occur. Read more
sourcefn try_restart(&self, completion_code: Option<u32>)
fn try_restart(&self, completion_code: Option<u32>)
Terminates and attempts to restart the process. The process and current application always terminate. The kernel may, based on its own policy, restart the application using the same process, reuse the process for another application, or simply terminate the process and application. Read more
sourcefn terminate(&self, completion_code: Option<u32>)
fn terminate(&self, completion_code: Option<u32>)
Stop and clear a process’s state, putting it into the Terminated
state. Read more
sourcefn get_restart_count(&self) -> usize
fn get_restart_count(&self) -> usize
Returns how many times this process has been restarted.
sourcefn has_tasks(&self) -> bool
fn has_tasks(&self) -> bool
Return if there are any Tasks (upcalls/IPC requests) enqueued for the process. Read more
sourcefn dequeue_task(&self) -> Option<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. Read more
sourcefn pending_tasks(&self) -> usize
fn pending_tasks(&self) -> usize
Returns the number of pending tasks. If 0 then dequeue_task()
will
return None
when called. Read more
sourcefn get_command_permissions(
&self,
driver_num: usize,
offset: usize
) -> CommandPermissions
fn get_command_permissions(
&self,
driver_num: usize,
offset: usize
) -> CommandPermissions
Return the permissions for this process for a given driver_num
. Read more
sourcefn get_storage_permissions(&self) -> Option<StoragePermissions>
fn get_storage_permissions(&self) -> Option<StoragePermissions>
Get the storage permissions for the process. Read more
sourcefn number_writeable_flash_regions(&self) -> usize
fn number_writeable_flash_regions(&self) -> usize
How many writeable flash regions defined in the TBF header for this process. Read more
sourcefn get_writeable_flash_region(&self, region_index: usize) -> (u32, u32)
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. Read more
sourcefn update_stack_start_pointer(&self, stack_pointer: *const u8)
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. Read more
sourcefn update_heap_start_pointer(&self, heap_pointer: *const u8)
fn update_heap_start_pointer(&self, heap_pointer: *const u8)
Debug function to update the kernel on where the process heap starts. Also optional. Read more
sourcefn add_mpu_region(
&self,
unallocated_memory_start: *const u8,
unallocated_memory_size: usize,
min_region_size: usize
) -> Option<Region>
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. Read more
sourcefn remove_mpu_region(&self, region: Region) -> Result<(), ErrorCode>
fn remove_mpu_region(&self, region: Region) -> Result<(), ErrorCode>
Removes an MPU region from the process that has been previouly added with
add_mpu_region
. Read more
sourcefn sbrk(&self, increment: isize) -> Result<*const u8, Error>
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. Read more
sourcefn brk(&self, new_break: *const u8) -> Result<*const u8, Error>
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. Read more
sourcefn build_readwrite_process_buffer(
&self,
buf_start_addr: *mut u8,
size: usize
) -> Result<ReadWriteProcessBuffer, ErrorCode>
fn build_readwrite_process_buffer(
&self,
buf_start_addr: *mut u8,
size: usize
) -> Result<ReadWriteProcessBuffer, ErrorCode>
Creates a ReadWriteProcessBuffer
from the given offset and size in
process memory. Read more
sourcefn build_readonly_process_buffer(
&self,
buf_start_addr: *const u8,
size: usize
) -> Result<ReadOnlyProcessBuffer, ErrorCode>
fn build_readonly_process_buffer(
&self,
buf_start_addr: *const u8,
size: usize
) -> Result<ReadOnlyProcessBuffer, ErrorCode>
Creates a ReadOnlyProcessBuffer
from the given offset and size in
process memory. Read more
sourceunsafe fn set_byte(&self, addr: *mut u8, value: u8) -> bool
unsafe fn set_byte(&self, addr: *mut u8, value: u8) -> bool
Set a single byte within the process address space at addr
to value
.
Return true if addr
is within the RAM bounds currently exposed to the
process (thereby writable by the process itself) and the value was set,
false otherwise. Read more
sourcefn grant_is_allocated(&self, grant_num: usize) -> Option<bool>
fn grant_is_allocated(&self, grant_num: usize) -> Option<bool>
Check if a given grant for this process has been allocated. Read more
sourcefn allocate_grant(
&self,
grant_num: usize,
driver_num: usize,
size: usize,
align: usize
) -> bool
fn allocate_grant(
&self,
grant_num: usize,
driver_num: usize,
size: usize,
align: usize
) -> bool
Allocate memory from the grant region and store the reference in the proper grant pointer index. Read more
sourcefn allocate_custom_grant(
&self,
size: usize,
align: usize
) -> Option<(ProcessCustomGrantIdentifer, NonNull<u8>)>
fn allocate_custom_grant(
&self,
size: usize,
align: usize
) -> Option<(ProcessCustomGrantIdentifer, NonNull<u8>)>
Allocate memory from the grant region that is size
bytes long and
aligned to align
bytes. This is used for creating custom grants which
are not recorded in the grant pointer array, but are useful for capsules
which need additional process-specific dynamically allocated memory. Read more
sourcefn enter_grant(&self, grant_num: usize) -> Result<NonNull<u8>, Error>
fn enter_grant(&self, grant_num: usize) -> Result<NonNull<u8>, Error>
Enter the grant based on grant_num
for this process. Read more
sourcefn enter_custom_grant(
&self,
identifier: ProcessCustomGrantIdentifer
) -> Result<*mut u8, Error>
fn enter_custom_grant(
&self,
identifier: ProcessCustomGrantIdentifer
) -> Result<*mut u8, Error>
Enter a custom grant based on the identifier
. Read more
sourceunsafe fn leave_grant(&self, grant_num: usize)
unsafe fn leave_grant(&self, grant_num: usize)
Opposite of enter_grant()
. Used to signal that the grant is no longer
entered. Read more
sourcefn grant_allocated_count(&self) -> Option<usize>
fn grant_allocated_count(&self) -> Option<usize>
Return the count of the number of allocated grant pointers if the
process is active. This does not count custom grants. This is used
to determine if a new grant has been allocated after a call to
SyscallDriver::allocate_grant()
. Read more
sourcefn lookup_grant_from_driver_num(
&self,
driver_num: usize
) -> Result<usize, Error>
fn lookup_grant_from_driver_num(
&self,
driver_num: usize
) -> Result<usize, Error>
Get the grant number (grant_num) associated with a given driver number if there is a grant associated with that driver_num. Read more
sourcefn is_valid_upcall_function_pointer(&self, upcall_fn: NonNull<()>) -> bool
fn is_valid_upcall_function_pointer(&self, upcall_fn: NonNull<()>) -> bool
Verify that an Upcall function pointer is within process-accessible memory. Read more
sourcefn get_process_name(&self) -> &'static str
fn get_process_name(&self) -> &'static str
Get the name of the process. Used for IPC.
sourcefn get_completion_code(&self) -> Option<Option<u32>>
fn get_completion_code(&self) -> Option<Option<u32>>
Get the completion code if the process has previously terminated. Read more
sourcefn set_syscall_return_value(&self, return_value: SyscallReturn)
fn set_syscall_return_value(&self, return_value: SyscallReturn)
Set the return value the process should see when it begins executing again after the syscall. Read more
sourcefn set_process_function(&self, callback: FunctionCall)
fn set_process_function(&self, callback: FunctionCall)
Set the function that is to be executed when the process is resumed. Read more
sourcefn switch_to(&self) -> Option<ContextSwitchReason>
fn switch_to(&self) -> Option<ContextSwitchReason>
Context switch to a specific process. Read more
sourcefn debug_syscall_count(&self) -> usize
fn debug_syscall_count(&self) -> usize
Returns how many syscalls this app has called.
sourcefn debug_dropped_upcall_count(&self) -> usize
fn debug_dropped_upcall_count(&self) -> usize
Returns how many upcalls for this process have been dropped.
sourcefn debug_timeslice_expiration_count(&self) -> usize
fn debug_timeslice_expiration_count(&self) -> usize
Returns how many times this process has exceeded its timeslice.
sourcefn debug_timeslice_expired(&self)
fn debug_timeslice_expired(&self)
Increment the number of times the process has exceeded its timeslice.
sourcefn debug_syscall_called(&self, last_syscall: Syscall)
fn debug_syscall_called(&self, last_syscall: Syscall)
Increment the number of times the process called a syscall and record the last syscall that was called. Read more
sourcefn debug_syscall_last(&self) -> Option<Syscall>
fn debug_syscall_last(&self) -> Option<Syscall>
Return the last syscall the process called. Returns None
if the
process has not called any syscalls or the information is unknown. Read more
sourcefn get_addresses(&self) -> ProcessAddresses
fn get_addresses(&self) -> ProcessAddresses
Return process state information related to the location in memory of various process data structures. Read more
sourcefn get_sizes(&self) -> ProcessSizes
fn get_sizes(&self) -> ProcessSizes
Return process state information related to the size in memory of various process data structures. Read more
sourcefn print_full_process(&self, writer: &mut dyn Write)
fn print_full_process(&self, writer: &mut dyn Write)
Print out the full state of the process: its memory map, its context, and the state of the memory protection unit (MPU). Read more
Auto Trait Implementations
impl<'a, C> !RefUnwindSafe for ProcessStandard<'a, C>
impl<'a, C> !Send for ProcessStandard<'a, C>
impl<'a, C> !Sync for ProcessStandard<'a, C>
impl<'a, C> Unpin for ProcessStandard<'a, C> where
<<C as Chip>::MPU as MPU>::MpuConfig: Unpin,
<<C as Chip>::UserspaceKernelBoundary as UserspaceKernelBoundary>::StoredState: Unpin,
impl<'a, C> !UnwindSafe for ProcessStandard<'a, C>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more