SyscallAbi

Struct SyscallAbi 

Source
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: usize

The system call number that identifies the requested system service.

§arg1: usize

First argument for the system call.

§arg2: usize

Second argument for the system call.

§arg3: usize

Third argument for the system call.

§arg4: usize

Fourth argument for the system call.

§arg5: usize

Fifth argument for the system call.

§arg6: usize

Sixth argument for the system call.

§regs: &'a mut Registers

A 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>

Source

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 the Registers structure 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.

Source

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: A Result indicating either the success value (Ok(value)) or the error type (Err(KernelError)).

Auto Trait Implementations§

§

impl<'a> Freeze for SyscallAbi<'a>

§

impl<'a> RefUnwindSafe for SyscallAbi<'a>

§

impl<'a> Send for SyscallAbi<'a>

§

impl<'a> Sync for SyscallAbi<'a>

§

impl<'a> Unpin for SyscallAbi<'a>

§

impl<'a> !UnwindSafe for SyscallAbi<'a>

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.