Skip to main content

Crate nub_rt

Crate nub_rt 

Source
Expand description

Guest-side runtime support for PVM2 programs.

Provides compiler builtins (memset, memcpy, memcmp), a panic handler, and a default trap _start (so guests link without defining one themselves).

Programs that need alloc get it from bump_allocator!, which installs a resettable bump arena.

Personality-free: a program built against this crate is a plain PVM2 program. Whether the engine running it has a capability system is not its concern.

Guests declare their entry points via the #[nub_rt::endpoint(N)] attribute (from nub-rt-macro). Each annotation emits a per-endpoint trampoline that calls the user fn and halts; the kernel enters trampolines via endpoints[N].entry_pc. _start (PC=0) is never an intended entry — it traps via unimp if ever reached.

All freestanding-only symbols are gated behind cfg(target_os = "none") — on host this crate is empty. Services force-link it via use nub_rt as _;.

target_os = "none" is the freestanding-target test throughout; the guest target JSON sets it. The RISC-V-specific bits (panic handler, _start) additionally require target_arch = "riscv64", because x86_64-unknown-none is also target_os = "none" and must never see this crate’s unimp.

Modules§

alloc
A bump allocator with an explicit reset.

Macros§

bump_allocator
Install a BumpAlloc of $bytes as the program’s global allocator, and define reset_heap() beside it.

Structs§

EndpointDescriptor
Descriptor written into the .nub.endpoints ELF section by the endpoint attribute macro. nub-linker reads this section at link time and turns each record into a nub_program::ProgramBlob::endpoints entry.

Attribute Macros§

endpoint
Mark a function as endpoint N of a PVM2 program.