SyscallContext

Struct SyscallContext 

Source
pub struct SyscallContext { /* private fields */ }
Expand description

Context passed to safe syscall handlers.

Implementations§

Source§

impl SyscallContext

Source

pub unsafe fn from_raw(machine: *mut RISCVMachine) -> Option<Self>

Create a syscall context from a raw machine pointer.

§Safety

The pointer must be a valid RISCVMachine from libriscv and only used for the duration of the syscall callback.

Source

pub fn registers(&mut self) -> Result<SyscallRegisters<'_>>

Borrow the guest registers for this syscall.

Source

pub fn memview(&mut self, src: u64, len: usize) -> Result<&[u8]>

View guest memory as a read-only slice.

Source

pub fn writable_memview(&mut self, src: u64, len: usize) -> Result<&mut [u8]>

View guest memory as a writable slice.

Source

pub fn memstring(&mut self, src: u64, maxlen: usize) -> Result<&[u8]>

Read a guest NUL-terminated string up to maxlen bytes.

Source

pub fn read(&mut self, src: u64, dst: &mut [u8]) -> Result<()>

Copy guest memory into a host buffer.

Source

pub fn write(&mut self, dst: u64, data: &[u8]) -> Result<()>

Copy host data into guest memory.

Source

pub fn read_pod<T: Pod>(&mut self, src: u64) -> Result<T>

Read a POD value from guest memory.

Source

pub fn write_pod<T: Pod>(&mut self, dst: u64, value: &T) -> Result<()>

Write a POD value into guest memory.

Source

pub fn stop(&mut self)

Stop execution at the next opportunity.

Source

pub fn instruction_counter(&self) -> u64

Return the current instruction counter value.

Source

pub fn max_instruction_counter(&mut self) -> Option<&mut u64>

Borrow the max instruction counter, if available.

Source

pub fn trigger_exception(&mut self, exception: u32, data: u64)

Trigger a CPU exception (only safe during a syscall).

Source

pub fn opaque(&self) -> *mut c_void

Return the opaque userdata pointer.

Auto Trait Implementations§

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.