pub trait SyscallAbi: Sized {
    type SyscallArgType: Copy;
    type SyscallRetType: Copy;
    type SyscallNumType: Copy;
    type ArgEncoder<'a>: SyscallEncoder<'a, Self, Self::SyscallArgType>
       where Self: 'a;
    type RetEncoder<'a>: SyscallEncoder<'a, Self, Self::SyscallRetType>
       where Self: 'a;

    // Required methods
    fn with_alloc<F, R, E>(
        &self,
        layout: Layout,
        f: F
    ) -> Result<R, SyscallError<E>>
       where E: Copy,
             F: FnOnce(Allocation) -> Result<R, SyscallError<E>>;
    unsafe fn kernel_alloc(&self, layout: Layout) -> Allocation;
    unsafe fn syscall_impl(
        &self,
        num: Self::SyscallNumType,
        args: Self::SyscallArgType
    ) -> Self::SyscallRetType;
    fn unrecoverable_encoding_failure<'a, EncodedType, Encoder, T>(
        &self,
        item: T
    )
       where EncodedType: Copy,
             Encoder: SyscallEncoder<'a, Self, EncodedType>,
             T: SyscallEncodable<'a, Self, EncodedType, Encoder>;

    // Provided methods
    fn arg_encoder(&self, alloc: Allocation) -> Self::ArgEncoder<'_> { ... }
    fn arg_decoder(&self, data: Self::SyscallArgType) -> Self::ArgEncoder<'_> { ... }
    fn ret_encoder(&self, alloc: Allocation) -> Self::RetEncoder<'_> { ... }
    fn ret_decoder(&self, data: Self::SyscallRetType) -> Self::RetEncoder<'_> { ... }
}
Expand description

Basic ABI information for a syscall system.

Required Associated Types§

source

type SyscallArgType: Copy

The type that will be passed to the syscall implementation function as the arguments.

source

type SyscallRetType: Copy

The type that will be returned by the syscall implementation.

source

type SyscallNumType: Copy

The type that will be passed to the syscall implementation function as the number.

source

type ArgEncoder<'a>: SyscallEncoder<'a, Self, Self::SyscallArgType> where Self: 'a

source

type RetEncoder<'a>: SyscallEncoder<'a, Self, Self::SyscallRetType> where Self: 'a

Required Methods§

source

fn with_alloc<F, R, E>( &self, layout: Layout, f: F ) -> Result<R, SyscallError<E>>where E: Copy, F: FnOnce(Allocation) -> Result<R, SyscallError<E>>,

Allocate some memory with the supplied layout. The allocation mechanism should issue no syscalls. The allocated memory is passed to the supplied closure.

source

unsafe fn kernel_alloc(&self, layout: Layout) -> Allocation

Allocate some memory as the kernel, for passing back to the application. This can just return a null Allocation.

Safety

The allocation must point to memory that will be valid until the application fully reads and decodes the value.

source

unsafe fn syscall_impl( &self, num: Self::SyscallNumType, args: Self::SyscallArgType ) -> Self::SyscallRetType

The raw syscall implementation. This should do little more than just assign the appropriate registers and issue the appropriate instruction to initiate the trap.

Safety
  1. The values of num and args must remain unmodified as they are transferred to the kernel.
  2. The syscall instruction must correctly take the number and arguments, and return the return value.
source

fn unrecoverable_encoding_failure<'a, EncodedType, Encoder, T>(&self, item: T)where EncodedType: Copy, Encoder: SyscallEncoder<'a, Self, EncodedType>, T: SyscallEncodable<'a, Self, EncodedType, Encoder>,

Provided Methods§

source

fn arg_encoder(&self, alloc: Allocation) -> Self::ArgEncoder<'_>

Create a new encoder for arguments.

source

fn arg_decoder(&self, data: Self::SyscallArgType) -> Self::ArgEncoder<'_>

Create a new decoder for arguments.

source

fn ret_encoder(&self, alloc: Allocation) -> Self::RetEncoder<'_>

Create a new encoder for return values.

source

fn ret_decoder(&self, data: Self::SyscallRetType) -> Self::RetEncoder<'_>

Create a new decoder for return values.

Implementors§