pub struct SyscallAbi<'a> {
pub sysno: usize,
pub arg1: usize,
pub arg2: usize,
pub arg3: usize,
pub arg4: usize,
pub arg5: usize,
pub arg6: usize,
pub regs: &'a mut Registers,
}Expand description
A struct representing the system call ABI (Application Binary Interface).
This struct provides a way to access and manipulate the system call’s
arguments and return values in the context of the system call handler. It
stores the system call number and up to six arguments that are passed to the
kernel during a system call, as well as a mutable reference to the CPU
registers (Registers) which hold the current state of the system call.
The SyscallAbi struct abstracts away the management of system call
parameters and return values, making it easier to implement and handle
system calls in the kernel.
Fields§
§sysno: usizeThe system call number that identifies the requested system service.
arg1: usizeFirst argument for the system call.
arg2: usizeSecond argument for the system call.
arg3: usizeThird argument for the system call.
arg4: usizeFourth argument for the system call.
arg5: usizeFifth argument for the system call.
arg6: usizeSixth argument for the system call.
regs: &'a mut RegistersA mutable reference to the Registers structure, which holds the
state of the CPU registers. It is used to manipulate the system
call return value and access any state needed for the call.
Implementations§
Source§impl<'a> SyscallAbi<'a>
impl<'a> SyscallAbi<'a>
Sourcepub fn from_registers(regs: &'a mut Registers) -> Self
pub fn from_registers(regs: &'a mut Registers) -> Self
Constructs a SyscallAbi instance from the provided registers.
This function extracts the system call number and arguments from the
Registers struct and initializes a new SyscallAbi struct.
§Parameters
regs: A mutable reference to theRegistersstructure that contains the current state of the CPU registers.
§Returns
Returns an instance of SyscallAbi populated with the system call
number and arguments extracted from the provided registers.
Sourcepub fn set_return_value(self, return_val: Result<usize, KernelError>)
pub fn set_return_value(self, return_val: Result<usize, KernelError>)
Sets the return value for the system call.
This function modifies the %rax register to indicate the result of the
system call. If the system call was successful, it sets %rax to the
returned value. If the system call encountered an error, it sets %rax
to the corresponding error code with the KernelError::into_usize
enum.
§Parameters
return_val: AResultindicating either the success value (Ok(value)) or the error type (Err(KernelError)).