Expand description
ServiceContext - entry-point type handed to every service’s service_main.
Provides safe, named access to the capabilities the service declared in its
contract. Capability names match the contract field names exactly.
Requesting a cap not in the contract returns Err(CapNotHeld).
Modules§
- death
- How a task ended, as the kernel says it in the death notice (
name, NUL, then one of these). The kernel’stask::deathholds the same values;askasserts its copy against these. - hwclass
- Device classes a spawner can name in
SpawnRequest::hw_flags. The kernel resolves the class to what its own bus scan found - a CLASS rather than an address, because the kernel keeps a permanent physical DMA reservation per device that a respawned driver must get back. - privbits
- Bits for
SpawnRequest::privileges. A spawner may only request what it HOLDS ITSELF - the kernel checks, and refuses otherwise - so this passes authority on, it never mints it (3.1, 7.3). - supcmd
- The supervisor’s command channel wire format.
- usbdev
- A USB host’s report to the supervisor about a device it does not drive itself, so the supervisor can
start that device’s driver when it arrives and stop it when it leaves (
docs/usb-device-drivers.md).
Structs§
- Boot
Manifest - CapInfo
- One held capability, as reported by
ServiceContext::task_caps. - Datetime
- Wall-clock date/time read from the hardware RTC, fully decoded (binary,
24-hour). See
ServiceContext::datetime. - Power
Pending - The machine’s one pending power action, as the kernel holds it (InspectKernel query 28,
docs/shutdown.md). SeeServiceContext::power_pending. - Service
Context - Passed by the kernel to
service_main. Non-Copy; one per service instance. - Service
Descriptor - Spawn
Request - What a spawner tells the kernel about a task it wants started from an image IT supplies
(
SpawnImage, syscall 52). Layout must match the kernel’sSpawnRequestexactly. - Task
Stat - Snapshot of kernel task state for a single scheduler slot.
Enums§
- Acquire
Failure - Why a
reacquire_cap_detailfailed. The two real cases want OPPOSITE responses, which is the entire reason this type exists rather than abool. - Alloc
Error - Error from the AllocMem syscall (6).
- Clock
Source - Where a wall-clock reading came from. Reported alongside the time so a displayed timestamp says what it is standing on: a local hardware clock, a network correction, or nothing (§26.4 - a fallback chain is mechanism while its choice is visible, and magic when it is not).
- Deadline
Outcome - Outcome of
ServiceContext::request_with_reply_deadline_outcome, which distinguishes the two ways a deadline request fails - so a caller can self-heal a restarted peer without penalising a silent one.SendFailed: the send never left (the peer’s cap is stale or its name is currently unresolvable - it was killed and respawned, generation bumped), so reacquiring it by name and retrying will reach the fresh instance.Timeout: the peer received the request but did not reply within the deadline (a genuinely silent/absent host) - retrying only doubles the wait.request_with_reply_deadlinecollapses both toNone; use this when the difference matters. - Deadline
Outcome Into - Outcome of
ServiceContext::request_with_reply_deadline_outcome_into- the buffer-writing twin ofDeadlineOutcome. - ReqOutcome
- Outcome of an abortable request/reply (
ServiceContext::request_with_reply_abortable): the reply arrived, the user pressedq/Q/ESC to abort the wait, or the deadline expired with no reply.Timeoutalso covers a request that never left (no such peer, no reply cap, a failed send).
Constants§
- AUTHORITIES
- THE KERNEL’S FIXED AUTHORITIES, by resource id: (id, the name a contract uses, what it lets a task do).
- BOOT_
READ_ CHUNK - The most one boot-record read copies (InspectKernel query 27). Equal to the kernel’s
log::BOOT_READ_CHUNK; a reader’s buffer is exactly this size, so the kernel never writes past it. - LAYOUT_
RELEASE - The first GodspeedOS release whose program layout this one runs: the context page and
TaskStat, which changed when names grew to 128 bytes. A package built for an earlier release would read them wrongly, so the supervisor refuses to start it and says its publisher must rebuild it. - NAME_
MAX - The longest name the kernel holds - a task’s, a send-peer’s, a directory entry’s - and so the longest a
program can run under and be reached by. 128 since 2026-10-18: an installed package runs under its
publisher/name, which may be that long. It was 24 for a peer and for acquiring by name, and 32 for a task, and a 26-byte package name was then unreachable by its own clients. Growing it changed the context page’s layout, so its magic changed with it, and a package built before that is refused at start (LAYOUT_RELEASE). - SPAWN_
FLAG_ CORE_ STRICT coreis a STRICT placement, not a preference.- SPAWN_
FLAG_ HANDOVER - A live handover: start this beside the one task already running under its name, which keeps running until it
ends itself; the new one takes the name. The supervisor’s alone, since only
SpawnImagehonours it (CLAUDE.md 2.5). - SPAWN_
FLAG_ PEERS_ GRANT - Mint the child’s name-wired peer caps WITH
GRANT, so it can re-delegate them. - SPAWN_
FLAG_ REQ_ CONSOLE - SPAWN_
FLAG_ REQ_ RECV - SPAWN_
FLAG_ WATCHED - Report this task’s death to the supervisor’s death-notification endpoint and count it as a restart. The
supervisor sets it for every service it manages; the kernel keeps no list of which services those are
(
docs/audio.md, “No service names in the kernel”). - SPAWN_
PAYLOAD_ MAX - Upper bound on a spawn name payload (
name+ NUL-separated peers). Matches the kernel’s limit. - SPAWN_
REQUEST_ VERSION - 2 since
installswas added, 3 sinceprobe_modewas. A spawner built against a different kernel is refused loudly. - USB_
DISK_ ABSENT - No USB disk is attached - the opposite instruction to
USB_DISK_BUSY, and it must stay in step with the kernel’sUSB_DISK_ABSENT. BUSY means “come back, I am working”; ABSENT means “there is nothing here, and asking again cannot change that - only a hot-plug can”. A caller that retries on this waits out its entire budget against an empty socket and then reports the device as busy, which is a false statement about hardware sitting on the operator’s desk. - USB_
DISK_ BUSY - The USB-disk syscalls’ “device NAKed, re-ask” status.