Trait SyscallContext

Source
pub trait SyscallContext {
    // Required methods
    fn peek_register(&mut self, idx: usize) -> Result<u32>;
    fn peek_u32(&mut self, addr: ByteAddr) -> Result<u32>;
    fn peek_u8(&mut self, addr: ByteAddr) -> Result<u8>;
    fn peek_region(&mut self, addr: ByteAddr, size: usize) -> Result<Vec<u8>>;
    fn peek_page(&mut self, page_idx: u32) -> Result<Vec<u8>>;
    fn get_cycle(&self) -> u64;
    fn get_pc(&self) -> u32;
}
Expand description

Access to memory and machine state for syscalls.

Required Methods§

Source

fn peek_register(&mut self, idx: usize) -> Result<u32>

Loads the value of the given register, e.g. REG_A0.

Source

fn peek_u32(&mut self, addr: ByteAddr) -> Result<u32>

Loads an individual word from memory.

Source

fn peek_u8(&mut self, addr: ByteAddr) -> Result<u8>

Loads an individual byte from memory.

Source

fn peek_region(&mut self, addr: ByteAddr, size: usize) -> Result<Vec<u8>>

Loads bytes from the given region of memory.

A region may span multiple pages.

Source

fn peek_page(&mut self, page_idx: u32) -> Result<Vec<u8>>

Load a page from memory at the specified page index.

This is used by sys_fork in order to build a copy-on-write page cache to inherit pages from the parent process.

Source

fn get_cycle(&self) -> u64

Returns the current cycle count.

Source

fn get_pc(&self) -> u32

Returns the current program counter.

Implementors§

Source§

impl<S: Syscall> SyscallContext for Executor<'_, '_, S>