No description
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
fawn e252d3f0cf
Some checks failed
CI / check (push) Failing after 5s
CI / no-std (aarch64-unknown-none) (push) Failing after 6s
CI / no-std (riscv64gc-unknown-none-elf) (push) Failing after 2s
CI / no-std (x86_64-unknown-none) (push) Failing after 2s
CI / msrv (push) Failing after 2s
feat: add CI workflow for automated checks and builds
2026-09-27 11:46:19 -04:00
.github/workflows feat: add CI workflow for automated checks and builds 2026-09-27 11:46:19 -04:00
macros chore: cargo fmt 2026-09-27 11:39:59 -04:00
src chore: cargo fmt 2026-09-27 11:39:59 -04:00
tests chore: cargo fmt 2026-09-27 11:39:59 -04:00
.gitignore initial commit 2026-09-27 00:08:55 -04:00
Cargo.lock feat: add project files + proc-macro crate 2026-09-27 11:29:25 -04:00
Cargo.toml feat: add project files + proc-macro crate 2026-09-27 11:29:25 -04:00
LICENSE chore: repo hygiene, license, package metadata 2026-09-27 00:23:48 -04:00
README.md feat: add project files + proc-macro crate 2026-09-27 11:29:25 -04:00

sysabi

Define a syscall ABI once and generate both halves of it from the same source.

#[syscall::abi(
    abi = "example",
    version = 2,
    errno = Errno,
)]
pub trait Demo {
    /// Terminate the calling thread.
    #[syscall(nr = 0)]
    fn exit(code: i32) -> !;

    #[syscall(nr = 1)]
    unsafe fn write(fd: u32, buf: *const u8, len: usize) -> usize;

    #[syscall(nr = 2, since = 2)]
    fn getpid() -> u32;
}

Generated in a module named after the trait (demo or module = ...):

  • demo::ABI: an [AbiDesc] with the name + version
  • demo::nr::WRITE, ...: syscall numbers
  • demo::SYSCALLS: [SyscallDesc] per syscall

kernel feature:

  • trait Demo is rewritten into the handler trait implemented by the kernel: fn write(&self, cx: &mut Self::Context, fd: u32, buf: *const u8, len: usize) -> Result<usize, Errno>
  • demo::kernel::dispatch(&handler, &hooks, cx, nr, args) -> usize decodes a trap, runs [Hooks::filter], calls handler, runs [Hooks::on_return], encodes the result

user feature:

  • demo::user::write(fd, buf, len) -> Result<usize, Errno> and other syscalls, which trap into the kernel with the calling convention in [arch], and syscalls declared unsafe fn get unsafe stubs. The rest are safe.

Both features can be enabled simultaneously, for example in a full kernel + userspace environment.

Return values

The return type written in the definition is on success; errors are always the ABI's given Errno type. -> ! becomes Result<Infallible, Errno>, and a missing return type becomes ().

On the wire, results use Linux conventions: success values returned as-is, errors returned as -code, with codes in 1..=MAX_ERRNO.

Add to your project

To use sysabi, add it to your Cargo.toml as a dependency with a Git source:

[dependencies]
sysabi = { git = "https://github.com/s0uthview/sysabi.git" }