Trait syscall_encode::abi::SyscallAbi
source · 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§
sourcetype SyscallArgType: Copy
type SyscallArgType: Copy
The type that will be passed to the syscall implementation function as the arguments.
sourcetype SyscallRetType: Copy
type SyscallRetType: Copy
The type that will be returned by the syscall implementation.
sourcetype SyscallNumType: Copy
type SyscallNumType: Copy
The type that will be passed to the syscall implementation function as the number.
type ArgEncoder<'a>: SyscallEncoder<'a, Self, Self::SyscallArgType> where Self: 'a
type RetEncoder<'a>: SyscallEncoder<'a, Self, Self::SyscallRetType> where Self: 'a
Required Methods§
sourcefn with_alloc<F, R, E>(
&self,
layout: Layout,
f: F
) -> Result<R, SyscallError<E>>where
E: Copy,
F: FnOnce(Allocation) -> Result<R, SyscallError<E>>,
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.
sourceunsafe fn kernel_alloc(&self, layout: Layout) -> Allocation
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.
sourceunsafe fn syscall_impl(
&self,
num: Self::SyscallNumType,
args: Self::SyscallArgType
) -> Self::SyscallRetType
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
- The values of num and args must remain unmodified as they are transferred to the kernel.
- The syscall instruction must correctly take the number and arguments, and return the return value.
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§
sourcefn arg_encoder(&self, alloc: Allocation) -> Self::ArgEncoder<'_>
fn arg_encoder(&self, alloc: Allocation) -> Self::ArgEncoder<'_>
Create a new encoder for arguments.
sourcefn arg_decoder(&self, data: Self::SyscallArgType) -> Self::ArgEncoder<'_>
fn arg_decoder(&self, data: Self::SyscallArgType) -> Self::ArgEncoder<'_>
Create a new decoder for arguments.
sourcefn ret_encoder(&self, alloc: Allocation) -> Self::RetEncoder<'_>
fn ret_encoder(&self, alloc: Allocation) -> Self::RetEncoder<'_>
Create a new encoder for return values.
sourcefn ret_decoder(&self, data: Self::SyscallRetType) -> Self::RetEncoder<'_>
fn ret_decoder(&self, data: Self::SyscallRetType) -> Self::RetEncoder<'_>
Create a new decoder for return values.