pub struct AppLoader<S: DynamicBinaryStore + 'static, L: DynamicProcessLoad + 'static> { /* private fields */ }
Implementations§
Source§impl<S: DynamicBinaryStore + 'static, L: DynamicProcessLoad + 'static> AppLoader<S, L>
impl<S: DynamicBinaryStore + 'static, L: DynamicProcessLoad + 'static> AppLoader<S, L>
pub fn new( grant: Grant<App, UpcallCount<{ upcall::COUNT }>, AllowRoCount<{ ro_allow::COUNT }>, AllowRwCount<0>>, storage_driver: &'static S, load_driver: &'static L, buffer: &'static mut [u8], ) -> AppLoader<S, L>
Trait Implementations§
Source§impl<S: DynamicBinaryStore + 'static, L: DynamicProcessLoad + 'static> DynamicBinaryStoreClient for AppLoader<S, L>
impl<S: DynamicBinaryStore + 'static, L: DynamicProcessLoad + 'static> DynamicBinaryStoreClient for AppLoader<S, L>
Source§fn setup_done(&self, result: Result<(), ErrorCode>)
fn setup_done(&self, result: Result<(), ErrorCode>)
Let the requesting app know we are done setting up for the new app
Source§fn write_done(
&self,
result: Result<(), ErrorCode>,
buffer: &'static mut [u8],
length: usize,
)
fn write_done( &self, result: Result<(), ErrorCode>, buffer: &'static mut [u8], length: usize, )
Let the app know we are done writing the block of data
Source§impl<S: DynamicBinaryStore + 'static, L: DynamicProcessLoad + 'static> DynamicProcessLoadClient for AppLoader<S, L>
impl<S: DynamicBinaryStore + 'static, L: DynamicProcessLoad + 'static> DynamicProcessLoadClient for AppLoader<S, L>
Source§fn load_done(&self, result: Result<(), ProcessLoadError>)
fn load_done(&self, result: Result<(), ProcessLoadError>)
Let the requesting app know we are done loading the new process
Error Type Mapping.
This method converts ProcessLoadError
to ErrorCode
so it can be
passed to userspace.
Currently,
- ProcessLoadError::NotEnoughMemory <==> ErrorCode::NOMEM
- ProcessLoadError::MpuInvalidFlashLength <==> ErrorCode::INVAL
- ProcessLoadError::InternalError <==> ErrorCode::OFF
- All other ProcessLoadError types <==> ErrorCode::FAIL
Source§impl<S: DynamicBinaryStore + 'static, L: DynamicProcessLoad + 'static> SyscallDriver for AppLoader<S, L>
impl<S: DynamicBinaryStore + 'static, L: DynamicProcessLoad + 'static> SyscallDriver for AppLoader<S, L>
Provide an interface for userland.
Source§fn command(
&self,
command_num: usize,
arg1: usize,
arg2: usize,
processid: ProcessId,
) -> CommandReturn
fn command( &self, command_num: usize, arg1: usize, arg2: usize, processid: ProcessId, ) -> CommandReturn
Command interface.
The driver returns ErrorCode::BUSY if:
- The kernel has already dedicated this driver to another process.
- The kernel is busy executing another command for this process.
Currently, this capsule is not virtualized and can only be used by one application at a time.
Commands are selected by the lowest 8 bits of the first argument.
§command_num
0
: Return Ok(()) if this driver is included on the platform.1
: Request kernel to setup for loading app.- Returns appsize if the kernel has available space
- Returns ErrorCode::FAIL if the kernel is unable to allocate space for the new app
2
: Request kernel to write app data to the nonvolatile_storage- Returns Ok(()) when write is successful
- Returns ErrorCode::INVAL when the app is violating bounds
- Returns ErrorCode::FAIL when the write fails
3
: Signal to the kernel that the writing is done.- Returns Ok(()) if the kernel successfully verified it and
set the stage for
load()
. - Returns ErrorCode::FAIL if: a. The kernel needs to write a leading padding app but is unable to. b. The command is called during setup or load phases.
4
: Request kernel to load app.- Returns Ok(()) when the process is successfully loaded
- Returns ErrorCode::FAIL if: a. The kernel is unable to create a process object for the application
5
: Request kernel to abort setup/write operation.- Returns Ok(()) when the operation is cancelled successfully
- Returns ErrorCode::BUSY when the abort fails (due to padding app being unable to be written, so try again)
- Returns ErrorCode::FAIL if the driver is not dedicated to this process
The driver returns ErrorCode::INVAL if any operation is called before the
preceeding operation was invoked. For example, write()
cannot be called before
setup()
, and load()
cannot be called before write()
(for this implementation).
Source§fn allocate_grant(&self, processid: ProcessId) -> Result<(), Error>
fn allocate_grant(&self, processid: ProcessId) -> Result<(), Error>
Source§fn allow_userspace_readable(
&self,
app: ProcessId,
which: usize,
slice: ReadWriteProcessBuffer,
) -> Result<ReadWriteProcessBuffer, (ReadWriteProcessBuffer, ErrorCode)>
fn allow_userspace_readable( &self, app: ProcessId, which: usize, slice: ReadWriteProcessBuffer, ) -> Result<ReadWriteProcessBuffer, (ReadWriteProcessBuffer, ErrorCode)>
UserspaceReadableProcessBuffer
) to the kernel that the kernel can
either read or write. The kernel calls this method only after it checks
that the entire buffer is within memory the process can both read and
write. Read more