pub trait Syscall: Send + Sync {
// Required method
fn execute(
&self,
ctx: &mut SyscallContext<'_, '_>,
arg1: u32,
arg2: u32,
) -> Option<u32>;
// Provided method
fn num_extra_cycles(&self) -> u32 { ... }
}Required Methods§
sourcefn execute(
&self,
ctx: &mut SyscallContext<'_, '_>,
arg1: u32,
arg2: u32,
) -> Option<u32>
fn execute( &self, ctx: &mut SyscallContext<'_, '_>, arg1: u32, arg2: u32, ) -> Option<u32>
Execute the syscall and return the resulting value of register a0. arg1 and arg2 are the
values in registers X10 and X11, respectively. While not a hard requirement, the convention
is that the return value is only for system calls such as HALT. Most precompiles use arg1
and arg2 to denote the addresses of the input data, and write the result to the memory at
arg1.
Provided Methods§
sourcefn num_extra_cycles(&self) -> u32
fn num_extra_cycles(&self) -> u32
The number of extra cycles that the syscall takes to execute. Unless this syscall is complex and requires many cycles, this should be zero.