pub struct SyscallContext { /* private fields */ }Expand description
Context passed to safe syscall handlers.
Implementations§
Source§impl SyscallContext
impl SyscallContext
Sourcepub unsafe fn from_raw(machine: *mut RISCVMachine) -> Option<Self>
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.
Sourcepub fn registers(&mut self) -> Result<SyscallRegisters<'_>>
pub fn registers(&mut self) -> Result<SyscallRegisters<'_>>
Borrow the guest registers for this syscall.
Sourcepub fn memview(&mut self, src: u64, len: usize) -> Result<&[u8]>
pub fn memview(&mut self, src: u64, len: usize) -> Result<&[u8]>
View guest memory as a read-only slice.
Sourcepub fn writable_memview(&mut self, src: u64, len: usize) -> Result<&mut [u8]>
pub fn writable_memview(&mut self, src: u64, len: usize) -> Result<&mut [u8]>
View guest memory as a writable slice.
Sourcepub fn memstring(&mut self, src: u64, maxlen: usize) -> Result<&[u8]>
pub fn memstring(&mut self, src: u64, maxlen: usize) -> Result<&[u8]>
Read a guest NUL-terminated string up to maxlen bytes.
Sourcepub fn read(&mut self, src: u64, dst: &mut [u8]) -> Result<()>
pub fn read(&mut self, src: u64, dst: &mut [u8]) -> Result<()>
Copy guest memory into a host buffer.
Sourcepub fn write_pod<T: Pod>(&mut self, dst: u64, value: &T) -> Result<()>
pub fn write_pod<T: Pod>(&mut self, dst: u64, value: &T) -> Result<()>
Write a POD value into guest memory.
Sourcepub fn instruction_counter(&self) -> u64
pub fn instruction_counter(&self) -> u64
Return the current instruction counter value.
Sourcepub fn max_instruction_counter(&mut self) -> Option<&mut u64>
pub fn max_instruction_counter(&mut self) -> Option<&mut u64>
Borrow the max instruction counter, if available.
Sourcepub fn trigger_exception(&mut self, exception: u32, data: u64)
pub fn trigger_exception(&mut self, exception: u32, data: u64)
Trigger a CPU exception (only safe during a syscall).
Auto Trait Implementations§
impl Freeze for SyscallContext
impl RefUnwindSafe for SyscallContext
impl !Send for SyscallContext
impl !Sync for SyscallContext
impl Unpin for SyscallContext
impl UnwindSafe for SyscallContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more