cortexm::syscall

Struct SysCall

Source
pub struct SysCall<A: CortexMVariant>(/* private fields */);
Expand description

Implementation of the UserspaceKernelBoundary for the Cortex-M non-floating point architecture.

Implementations§

Source§

impl<A: CortexMVariant> SysCall<A>

Source

pub const unsafe fn new() -> SysCall<A>

Trait Implementations§

Source§

impl<A: CortexMVariant> UserspaceKernelBoundary for SysCall<A>

Source§

unsafe fn set_process_function( &self, accessible_memory_start: *const u8, app_brk: *const u8, state: &mut CortexMStoredState, callback: FunctionCall, ) -> Result<(), ()>

When the process calls svc to enter the kernel, the hardware automatically pushes an SVC frame that will be unstacked when the kernel returns to the process. In the special case of process startup, initialize_new_process sets up an empty SVC frame as if an svc had been called.

Here, we modify this stack frame such that the process resumes at the beginning of the callback function that we want the process to run. We place the originally intended return address in the link register so that when the function completes execution continues.

In effect, this converts svc into bl callback.

Source§

type StoredState = CortexMStoredState

Some architecture-specific struct containing per-process state that must be kept while the process is not running. For example, for keeping CPU registers that aren’t stored on the stack. Read more
Source§

fn initial_process_app_brk_size(&self) -> usize

Called by the kernel during process creation to inform the kernel of the minimum amount of process-accessible RAM needed by a new process. This allows for architecture-specific process layout decisions, such as stack pointer initialization. Read more
Source§

unsafe fn initialize_process( &self, accessible_memory_start: *const u8, app_brk: *const u8, state: &mut Self::StoredState, ) -> Result<(), ()>

Called by the kernel after it has memory allocated to it but before it is allowed to begin executing. Allows for architecture-specific process setup, e.g. allocating a syscall stack frame. Read more
Source§

unsafe fn set_syscall_return_value( &self, accessible_memory_start: *const u8, app_brk: *const u8, state: &mut Self::StoredState, return_value: SyscallReturn, ) -> Result<(), ()>

Set the return value the process should see when it begins executing again after the syscall. This will only be called after a process has called a syscall. Read more
Source§

unsafe fn switch_to_process( &self, accessible_memory_start: *const u8, app_brk: *const u8, state: &mut CortexMStoredState, ) -> (ContextSwitchReason, Option<*const u8>)

Context switch to a specific process. Read more
Source§

unsafe fn print_context( &self, accessible_memory_start: *const u8, app_brk: *const u8, state: &CortexMStoredState, writer: &mut dyn Write, )

Display architecture specific (e.g. CPU registers or status flags) data for a process identified by the stored state for that process. Read more
Source§

fn store_context( &self, state: &CortexMStoredState, out: &mut [u8], ) -> Result<usize, ErrorCode>

Store architecture specific (e.g. CPU registers or status flags) data for a process. On success returns the number of elements written to out.

Auto Trait Implementations§

§

impl<A> Freeze for SysCall<A>

§

impl<A> RefUnwindSafe for SysCall<A>
where A: RefUnwindSafe,

§

impl<A> Send for SysCall<A>
where A: Send,

§

impl<A> Sync for SysCall<A>
where A: Sync,

§

impl<A> Unpin for SysCall<A>
where A: Unpin,

§

impl<A> UnwindSafe for SysCall<A>
where A: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.