Crate syscall_encode

source ·
Expand description

Syscall Encode

Type-safe Automatic syscall encoding support.

The goal of this crate is to supply mechanisms for OS kernels and ABI libraries to define:

  1. Exact syscall ABI semantics, including how arguments are encoded and sent between kernel and userspace: abi::SyscallAbi.
  2. A method for enabling a type to be encoded into what can be sent via a syscall instruction (according to the defined ABI): api::SyscallEncodable.
  3. A method for defining such an encodable type as an API endpoint that allows userspace to easily perform syscalls using a type as arguments api::SyscallApi.
  4. A derive macro that derives the encodable trait SyscallEncodable.
  5. A trait that provides much lower overhead than the normal encoding, but may be harder to use and more limited api::SyscallFastApi.
  6. A way to encode pointers to other userland data structures that the kernel can verify before derefencing.

More documentation coming…

Pointers and References

You cannot encode a pointer or reference directly. Instead, you can use the UserPointer type, which will encode a reference that is safe to pass to the kernel.

#[derive(syscall_macros::SyscallEncodable, Debug, Clone, Eq, PartialEq, PartialOrd)]
struct Bar<'a> { x: &'a u32 }

Modules

Macros

  • Define the entire syscall table based on types that implement SyscallApi and SyscallFastApi. Also acts as the match statement for that table, and so takes in the syscall number and args for the syscall we are handling. For example:

Derive Macros