Skip to main content

strat9_abi/
syscall.rs

1//! Syscall number definitions for Strat9 OS.
2//!
3//! Each syscall is identified by a unique `usize` constant. Syscalls are
4//! invoked via the `syscall` instruction on x86_64. Arguments are passed in
5//! registers (RDI, RSI, RDX, R8, R9, R10); the return value is in RAX.
6//!
7//! **ABI convention**: Success returns a non-negative value. Errors return a
8//! negative errno value (two's complement). Userspace checks
9//! `if result > 0xFFFF_F000 { errno = !result + 1; }`.
10
11// ── Block 0-99: Capability / Handle Management ──────────────────────────────
12
13/// No-op syscall. Used for benchmarking syscall overhead.
14pub const SYS_NULL: usize = 0;
15
16/// Duplicate a capability handle.
17///
18/// Returns a new handle pointing to the same underlying resource.
19/// The new handle has its own lifetime and must be closed independently.
20pub const SYS_HANDLE_DUPLICATE: usize = 1;
21
22/// Close a capability handle.
23///
24/// After this call, the handle is invalid. If this was the last reference
25/// to the underlying resource, the resource is destroyed.
26pub const SYS_HANDLE_CLOSE: usize = 2;
27
28/// Wait on a capability handle until it becomes ready or the timeout expires.
29///
30/// - `handle`: capability handle to wait on
31/// - `timeout_ns`: maximum wait time in nanoseconds (0 = infinite)
32///
33/// Returns `0` on success, `-ETIMEDOUT` if the timeout expired.
34pub const SYS_HANDLE_WAIT: usize = 3;
35
36/// Grant a capability handle to another process.
37///
38/// - `handle`: capability to grant
39/// - `target_pid`: PID of the target process
40///
41/// The target process receives a new handle to the same resource.
42/// Returns `0` on success, `-EPERM` if the caller lacks grant permission.
43pub const SYS_HANDLE_GRANT: usize = 4;
44
45/// Revoke a capability handle.
46///
47/// All holders of this handle (including the caller and any granted
48/// recipients) lose access. The underlying resource may be destroyed
49/// if no other references exist.
50pub const SYS_HANDLE_REVOKE: usize = 5;
51
52/// Query information about a capability handle.
53///
54/// - `handle`: capability to query
55/// - `out_ptr`: pointer to a `HandleInfo` struct that receives the result
56///
57/// Returns `0` on success, `-EBADF` if the handle is invalid.
58pub const SYS_HANDLE_INFO: usize = 6;
59
60// ── Block 100-199: Memory Management ────────────────────────────────────────
61
62/// Map a memory region into the process address space.
63///
64/// - `addr`: desired virtual address (0 = kernel chooses)
65/// - `len`: length in bytes (rounded up to page boundary)
66/// - `prot`: protection flags (`PROT_READ | PROT_WRITE | PROT_EXEC`)
67/// - `flags`: mapping flags (`MAP_SHARED`, `MAP_PRIVATE`, `MAP_ANONYMOUS`, etc.)
68/// - `fd`: file descriptor for file-backed mappings (-1 for anonymous)
69/// - `offset`: offset into the file (must be page-aligned)
70///
71/// Returns the mapped virtual address on success, or a negative errno.
72pub const SYS_MMAP: usize = 100;
73
74/// Unmap a memory region.
75///
76/// - `addr`: virtual address of the mapping (must be page-aligned)
77/// - `len`: length in bytes (rounded up to page boundary)
78///
79/// After this call, the region is no longer accessible. Any dirty pages
80/// are written back if the mapping was shared.
81pub const SYS_MUNMAP: usize = 101;
82
83/// Set or query the program break (data segment end).
84///
85/// - `addr`: new break address (0 = query current break)
86///
87/// Returns the current break address. If `addr` is non-zero, the break
88/// is moved to `addr` (may allocate or free pages).
89pub const SYS_BRK: usize = 102;
90
91/// Remap a memory region to a new address or size.
92///
93/// - `old_addr`: current virtual address
94/// - `old_len`: current length in bytes
95/// - `new_len`: desired new length in bytes
96/// - `flags`: `MREMAP_MAYMOVE` (1) to allow relocation
97/// - `new_addr`: desired new address (only with `MREMAP_MAYMOVE`)
98///
99/// Returns the new virtual address.
100pub const SYS_MREMAP: usize = 103;
101
102/// Change memory protection flags on a mapped region.
103///
104/// - `addr`: start address (must be page-aligned)
105/// - `len`: length in bytes (rounded up to page boundary)
106/// - `prot`: new protection flags (`PROT_READ`, `PROT_WRITE`, `PROT_EXEC`)
107///
108/// Returns `0` on success. Common errors: `-EACCES` (trying to make
109/// a mapping executable that wasn't created with PROT_EXEC).
110pub const SYS_MPROTECT: usize = 104;
111
112/// Export a memory region as a shareable handle.
113///
114/// - `addr`: start address of the region
115/// - `len`: length in bytes
116///
117/// Returns a capability handle that can be granted to another process.
118/// The other process can then map it with `SYS_MEM_REGION_MAP`.
119pub const SYS_MEM_REGION_EXPORT: usize = 105;
120
121/// Map an exported memory region into the current address space.
122///
123/// - `region_handle`: capability handle from `SYS_MEM_REGION_EXPORT`
124/// - `addr`: desired virtual address (0 = kernel chooses)
125/// - `len`: length in bytes
126///
127/// Returns the mapped virtual address.
128pub const SYS_MEM_REGION_MAP: usize = 106;
129
130/// Query metadata about an exported memory region.
131///
132/// - `region_handle`: capability handle from `SYS_MEM_REGION_EXPORT`
133/// - `out_ptr`: pointer to a `MemRegionInfo` struct
134///
135/// Returns `0` on success.
136pub const SYS_MEM_REGION_INFO: usize = 107;
137
138// ── Block 200-219: IPC ─────────────────────────────────────────────────────
139
140/// Create a new IPC port.
141///
142/// Returns a capability handle for the port. The port is owned by the
143/// calling process and can receive messages from other processes that
144/// hold a handle to it.
145pub const SYS_IPC_CREATE_PORT: usize = 200;
146
147/// Send a message to an IPC port.
148///
149/// - `port_handle`: capability handle of the target port
150/// - `msg_ptr`: pointer to the message data
151/// - `msg_len`: length of the message in bytes
152///
153/// Blocks if the port's message queue is full.
154pub const SYS_IPC_SEND: usize = 201;
155
156/// Receive a message from an IPC port.
157///
158/// - `port_handle`: capability handle of the port
159/// - `buf_ptr`: buffer to receive the message
160/// - `buf_len`: size of the buffer
161///
162/// Blocks until a message is available. Returns the number of bytes received.
163pub const SYS_IPC_RECV: usize = 202;
164
165/// Synchronous RPC: send a message and wait for a reply.
166///
167/// - `port_handle`: capability handle of the target port
168/// - `msg_ptr`: pointer to the request message
169/// - `msg_len`: length of the request
170///
171/// Blocks until the server replies. Returns the number of bytes in the reply.
172/// Equivalent to `SYS_IPC_SEND` + `SYS_IPC_RECV` with automatic reply routing.
173pub const SYS_IPC_CALL: usize = 203;
174
175/// Reply to the current IPC call.
176///
177/// - `msg_ptr`: pointer to the reply message
178/// - `msg_len`: length of the reply
179///
180/// Must be called from within an `IPC_CALL` handler. Wakes the waiting caller.
181pub const SYS_IPC_REPLY: usize = 204;
182
183/// Bind a port as a listener in the IPC namespace.
184///
185/// - `port_handle`: capability handle of the port
186///
187/// After binding, other processes can connect to this port by name.
188pub const SYS_IPC_BIND_PORT: usize = 205;
189
190/// Unbind a listening port from the IPC namespace.
191///
192/// - `port_handle`: capability handle of the port
193///
194/// The port continues to exist but is no longer discoverable by name.
195pub const SYS_IPC_UNBIND_PORT: usize = 206;
196
197/// Non-blocking receive from an IPC port.
198///
199/// - `port_handle`: capability handle of the port
200/// - `buf_ptr`: buffer to receive the message
201/// - `buf_len`: size of the buffer
202///
203/// Returns the number of bytes received, or `0` if no message is available
204/// (does not block). Returns `-EAGAIN` if the port is empty.
205pub const SYS_IPC_TRY_RECV: usize = 207;
206
207/// Connect to a bound IPC port by name.
208///
209/// - `port_handle`: capability handle (used for authentication/permissions)
210///
211/// Returns a new handle to the connected port, or `-ENOENT` if not found.
212pub const SYS_IPC_CONNECT: usize = 208;
213
214/// Create a shared ring buffer for zero-copy IPC.
215///
216/// - `size_log2`: log2 of the ring size in bytes (e.g., 12 = 4096 bytes)
217///
218/// Returns a capability handle for the ring. The ring can be mapped into
219/// another process's address space with `SYS_IPC_RING_MAP`.
220pub const SYS_IPC_RING_CREATE: usize = 210;
221
222/// Map a shared ring buffer into the current address space.
223///
224/// - `ring_handle`: capability handle from `SYS_IPC_RING_CREATE`
225/// - `addr`: desired virtual address (0 = kernel chooses)
226///
227/// Returns the mapped virtual address.
228pub const SYS_IPC_RING_MAP: usize = 211;
229
230// ── Block 220-224: Typed Channels (MPMC) ───────────────────────────────────
231
232/// Create a typed MPMC channel.
233///
234/// - `capacity`: maximum number of messages the channel can hold
235///
236/// Returns a capability handle for the channel. Both endpoints (sender
237/// and receiver) share the same handle; the channel is symmetric.
238pub const SYS_CHAN_CREATE: usize = 220;
239
240/// Send a message through a typed channel (blocks if full).
241///
242/// - `handle`: channel handle
243/// - `msg_ptr`: pointer to the message data
244///
245/// Blocks until space is available in the channel buffer.
246pub const SYS_CHAN_SEND: usize = 221;
247
248/// Receive a message from a typed channel (blocks if empty).
249///
250/// - `handle`: channel handle
251/// - `msg_ptr`: buffer to receive the message
252///
253/// Blocks until a message is available.
254pub const SYS_CHAN_RECV: usize = 222;
255
256/// Non-blocking receive from a typed channel.
257///
258/// - `handle`: channel handle
259/// - `msg_ptr`: buffer to receive the message
260///
261/// Returns `1` if a message was received, `0` if the channel is empty.
262pub const SYS_CHAN_TRY_RECV: usize = 223;
263
264/// Close a typed channel handle.
265///
266/// - `handle`: channel handle
267///
268/// If this was the last handle, the channel is destroyed and all
269/// pending senders/receivers receive `EPIPE`.
270pub const SYS_CHAN_CLOSE: usize = 224;
271
272// ── Block 230-234: Semaphores ───────────────────────────────────────────────
273
274/// Create a POSIX counting semaphore.
275///
276/// - `initial_value`: initial count of the semaphore
277///
278/// Returns a capability handle for the semaphore.
279pub const SYS_SEM_CREATE: usize = 230;
280
281/// Decrement (wait on) a semaphore. Blocks if the count is zero.
282///
283/// - `handle`: semaphore handle
284pub const SYS_SEM_WAIT: usize = 231;
285
286/// Non-blocking decrement (trywait) on a semaphore.
287///
288/// - `handle`: semaphore handle
289///
290/// Returns `1` if the semaphore was decremented, `0` if it would block.
291pub const SYS_SEM_TRYWAIT: usize = 232;
292
293/// Increment (post) a semaphore, waking a waiter if any.
294///
295/// - `handle`: semaphore handle
296pub const SYS_SEM_POST: usize = 233;
297
298/// Close a semaphore handle.
299///
300/// - `handle`: semaphore handle
301pub const SYS_SEM_CLOSE: usize = 234;
302
303// ── Block 240-249: PCI ──────────────────────────────────────────────────────
304
305/// Enumerate PCI devices matching specified criteria.
306///
307/// - `criteria_ptr`: pointer to a `PciProbeCriteria` struct (class, subclass, vendor/device ID)
308/// - `out_ptr`: buffer to receive `PciDevice` structs
309/// - `max_count`: maximum number of devices to return
310///
311/// Returns the number of matching devices found.
312pub const SYS_PCI_ENUM: usize = 240;
313
314/// Read a PCI configuration space register.
315///
316/// - `addr_ptr`: pointer to a `PciAddress` struct (bus/device/function)
317/// - `offset`: register offset within config space
318/// - `width`: access width in bytes (1, 2, or 4)
319///
320/// Returns the register value.
321pub const SYS_PCI_CFG_READ: usize = 241;
322
323/// Write a PCI configuration space register.
324///
325/// - `addr_ptr`: pointer to a `PciAddress` struct
326/// - `offset`: register offset within config space
327/// - `width`: access width in bytes (1, 2, or 4)
328/// - `value`: value to write
329pub const SYS_PCI_CFG_WRITE: usize = 242;
330
331// ── Block 250-254: Async I/O ────────────────────────────────────────────────
332
333/// Set up async event notification on a file descriptor.
334///
335/// - `handle`: file descriptor to monitor
336/// - `event_mask`: bitmask of events to watch (`POLLIN`, `POLLOUT`, etc.)
337///
338/// Returns an async context handle for use with `SYS_ASYNC_ENTER`.
339pub const SYS_ASYNC_SETUP: usize = 250;
340
341/// Enter async wait on a previously set up context.
342///
343/// - `ctx`: async context handle from `SYS_ASYNC_SETUP`
344///
345/// Yields the current thread until one of the monitored events fires.
346/// The event type is returned in RAX.
347pub const SYS_ASYNC_ENTER: usize = 251;
348
349/// Cancel a pending async wait.
350///
351/// - `ctx`: async context handle
352///
353/// Wakes the thread immediately with `-ECANCELED` as the result.
354pub const SYS_ASYNC_CANCEL: usize = 252;
355
356/// Map a shared ring buffer to an async context for event delivery.
357///
358/// - `ctx`: async context handle
359/// - `ring_handle`: capability handle of a shared ring buffer
360///
361/// Events are delivered as messages in the ring buffer instead of
362/// waking the thread directly.
363pub const SYS_ASYNC_MAP: usize = 253;
364
365/// Destroy an async context and release its resources.
366///
367/// - `ctx`: async context handle
368pub const SYS_ASYNC_DESTROY: usize = 254;
369
370// ── Block 260-269: IPC Transport Layer ──────────────────────────────────────
371
372/// Create an IPC transport between two silos.
373///
374/// - `dst_silo`: destination silo ID
375/// - `config_flags`: transport configuration (level, ring capacity, etc.)
376///
377/// Returns a transport capability handle. The transport level is selected
378/// automatically based on the silo tiers (TypeSafe / LockFree / MMU).
379pub const SYS_TRANSPORT_CREATE: usize = 260;
380
381/// Send a message through an IPC transport.
382///
383/// - `transport_handle`: transport capability from `SYS_TRANSPORT_CREATE`
384/// - `buf_ptr`: pointer to the message data
385/// - `buf_len`: length of the message
386///
387/// Dispatches to the appropriate transport (N1/N2/N3) automatically.
388pub const SYS_TRANSPORT_SEND: usize = 261;
389
390/// Receive a message from an IPC transport.
391///
392/// - `transport_handle`: transport capability
393/// - `buf_ptr`: buffer to receive the message
394/// - `buf_len`: size of the buffer
395///
396/// Returns the number of bytes received.
397pub const SYS_TRANSPORT_RECV: usize = 262;
398
399/// Close an IPC transport and release its resources.
400///
401/// - `transport_handle`: transport capability
402///
403/// All pending messages are discarded. Both endpoints are invalidated.
404pub const SYS_TRANSPORT_CLOSE: usize = 263;
405
406/// Query information about an IPC transport.
407///
408/// - `transport_handle`: transport capability
409/// - `out_ptr`: pointer to a `TransportInfo` struct
410///
411/// Returns the transport level, capacity, and performance statistics.
412pub const SYS_TRANSPORT_INFO: usize = 264;
413
414// ── Block 300-399: Process / Thread Management ──────────────────────────────
415
416/// Terminate the current process with an exit code.
417///
418/// - `exit_code`: process exit status
419///
420/// This syscall never returns. All threads in the process are terminated.
421pub const SYS_PROC_EXIT: usize = 300;
422
423/// Yield the CPU to the scheduler.
424///
425/// The current thread is placed at the back of the run queue and another
426/// thread is scheduled. Returns `0` when the thread is rescheduled.
427pub const SYS_PROC_YIELD: usize = 301;
428
429/// Fork the current process (copy-on-write).
430///
431/// - `frame`: pointer to the `SyscallFrame` to restore in the child
432///
433/// Returns `0` in the child process, and the child PID in the parent.
434/// The child gets a copy of the parent's address space (COW).
435pub const SYS_PROC_FORK: usize = 302;
436
437/// Sleep on a futex word. Blocks if `*addr == val`.
438///
439/// - `addr`: futex word address
440/// - `val`: expected value
441/// - `timeout_ns`: timeout in nanoseconds (0 = infinite)
442///
443/// Returns `0` on wakeup, `-EAGAIN` if value mismatch, `-ETIMEDOUT` on timeout.
444pub const SYS_FUTEX_WAIT: usize = 303;
445
446/// Wake up to N waiters blocked on a futex word.
447///
448/// - `addr`: futex word address
449/// - `max_wake`: maximum number of waiters to wake
450///
451/// Returns the number of waiters actually woken.
452pub const SYS_FUTEX_WAKE: usize = 304;
453
454/// Wake waiters on `addr` and requeue remaining waiters to `addr2`.
455///
456/// - `addr`: source futex word
457/// - `max_wake`: maximum waiters to wake
458/// - `addr2`: destination futex word for requeue
459/// - `max_requeue`: maximum waiters to requeue
460///
461/// Returns the number of waiters woken.
462pub const SYS_FUTEX_REQUEUE: usize = 305;
463
464/// Conditional requeue: only requeue if `*addr == cmp_val`.
465///
466/// - `addr`: source futex word
467/// - `max_wake`: maximum waiters to wake
468/// - `addr2`: destination futex word for requeue
469/// - `max_requeue`: maximum waiters to requeue
470/// - `cmp_val`: expected value at `addr`
471///
472/// Returns the number of waiters woken.
473pub const SYS_FUTEX_CMP_REQUEUE: usize = 306;
474
475/// Atomic operation on `addr2` + wake waiters on `addr`.
476///
477/// - `addr`: source futex word to wake from
478/// - `max_wake`: maximum waiters to wake
479/// - `addr2`: target futex word for atomic operation
480/// - `max_requeue`: maximum waiters to requeue
481/// - `wake_op`: encoded atomic operation (op, cmp_op, cmp_val, shift)
482///
483/// Returns the number of waiters woken.
484pub const SYS_FUTEX_WAKE_OP: usize = 307;
485
486/// Get the current process ID (PID).
487///
488/// Returns the PID of the calling process.
489pub const SYS_PROC_GETPID: usize = 308;
490
491/// Get the parent process ID (PPID).
492///
493/// Returns the PID of the parent process, or 0 if the parent has exited.
494pub const SYS_PROC_GETPPID: usize = 309;
495
496/// Wait for a specific child process to change state.
497///
498/// - `pid`: child PID to wait for (-1 = any child)
499/// - `status_ptr`: pointer to receive exit status
500/// - `options`: `WNOHANG`, `WUNTRACED`, `WCONTINUED` flags
501///
502/// Returns the child PID, or `-ECHILD` if no children exist.
503pub const SYS_PROC_WAITPID: usize = 310;
504
505/// Get the current process ID (alias for `SYS_PROC_GETPID`).
506pub const SYS_GETPID: usize = 311;
507
508/// Get the current thread ID (TID).
509///
510/// Returns the TID of the calling thread. TIDs are unique per-thread.
511pub const SYS_GETTID: usize = 312;
512
513/// Get the parent process ID (alias for `SYS_PROC_GETPPID`).
514pub const SYS_GETPPID: usize = SYS_PROC_GETPPID;
515
516/// Wait for any child process to change state.
517///
518/// Returns the PID of the terminated child, or `-ECHILD` if no children.
519pub const SYS_PROC_WAIT: usize = 314;
520
521/// Execute a new program, replacing the current process image.
522///
523/// - `path_ptr`: pointer to the null-terminated path string
524/// - `path_len`: length of the path string
525/// - `argv_ptr`: pointer to the argument array
526/// - `envp_ptr`: pointer to the environment array
527///
528/// This syscall never returns on success. The current process image is
529/// replaced with the new ELF binary.
530pub const SYS_PROC_EXECVE: usize = 315;
531
532/// File control operations (fcntl).
533///
534/// - `fd`: file descriptor
535/// - `cmd`: command (`F_DUPFD`, `F_GETFD`, `F_SETFD`, `F_GETFL`, `F_SETFL`)
536/// - `arg`: command-specific argument
537///
538/// Returns a command-dependent value.
539pub const SYS_FCNTL: usize = 316;
540
541/// Set the process group ID of a process.
542///
543/// - `pid`: target process ID (0 = current process)
544/// - `pgid`: desired process group ID
545pub const SYS_SETPGID: usize = 317;
546
547/// Get the process group ID of a process.
548///
549/// - `pid`: target process ID (0 = current process)
550///
551/// Returns the process group ID.
552pub const SYS_GETPGID: usize = 318;
553
554/// Create a new session and set the process group ID.
555///
556/// Returns the new session ID. The calling process becomes the session
557/// leader with a new process group.
558pub const SYS_SETSID: usize = 319;
559
560// ── Block 320-353: Signal Handling ──────────────────────────────────────────
561
562/// Send a signal to a process.
563///
564/// - `pid`: target process ID (negative = send to process group)
565/// - `signum`: signal number (1-31)
566///
567/// Returns `0` on success, `-ESRCH` if process not found.
568pub const SYS_KILL: usize = 320;
569
570/// Get or set the signal mask of the current thread.
571///
572/// - `how`: `SIG_BLOCK` (0), `SIG_UNBLOCK` (1), or `SIG_SETMASK` (2)
573/// - `set_ptr`: pointer to signal set to apply
574/// - `oldset_ptr`: pointer to receive the previous signal set (0 = ignore)
575pub const SYS_SIGPROCMASK: usize = 321;
576
577/// Set the action for a signal.
578///
579/// - `signum`: signal number
580/// - `act_ptr`: pointer to `Sigaction` struct (handler, flags, mask)
581/// - `oact_ptr`: pointer to receive the previous action (0 = ignore)
582pub const SYS_SIGACTION: usize = 322;
583
584/// Set the alternate signal stack for the current thread.
585///
586/// - `ss_ptr`: pointer to `Stack` struct (base, size, flags)
587/// - `old_ss_ptr`: pointer to receive the previous stack (0 = ignore)
588pub const SYS_SIGALTSTACK: usize = 323;
589
590/// Get the set of pending signals for the current thread.
591///
592/// - `set_ptr`: pointer to receive the signal set
593pub const SYS_SIGPENDING: usize = 324;
594
595/// Suspend the current thread until a signal is delivered.
596///
597/// - `mask_ptr`: pointer to signal set to temporarily unblock
598///
599/// This syscall does not return normally; it returns when a signal handler runs.
600pub const SYS_SIGSUSPEND: usize = 325;
601
602/// Suspend the current thread until a specific signal is delivered.
603///
604/// - `set_ptr`: pointer to signal set to wait for
605/// - `info_ptr`: pointer to receive signal info
606/// - `timeout_ptr`: pointer to timeout (0 = infinite)
607///
608/// Returns the signal number that was delivered.
609pub const SYS_SIGTIMEDWAIT: usize = 326;
610
611/// Queue a signal with associated data to a process.
612///
613/// - `pid`: target process ID
614/// - `signum`: signal number
615/// - `sigval_ptr`: pointer to `Sigval` union (integer or pointer)
616///
617/// Unlike `SYS_KILL`, this delivers the signal asynchronously with data.
618pub const SYS_SIGQUEUE: usize = 327;
619
620/// Send a signal to all processes in a process group.
621///
622/// - `pgrp`: process group ID
623/// - `signum`: signal number
624pub const SYS_KILLPG: usize = 328;
625
626/// Get the current value of an interval timer.
627///
628/// - `which`: timer type (`ITIMER_REAL`, `ITIMER_VIRTUAL`, `ITIMER_PROF`)
629/// - `out_ptr`: pointer to receive the `itimerval` struct
630pub const SYS_GETITIMER: usize = 329;
631
632/// Set an interval timer.
633///
634/// - `which`: timer type
635/// - `in_ptr`: pointer to `itimerval` struct (interval + initial value)
636/// - `out_ptr`: pointer to receive the previous value (0 = ignore)
637pub const SYS_SETITIMER: usize = 330;
638
639/// Get the current process group ID.
640///
641/// Returns the process group ID of the calling process.
642pub const SYS_GETPGRP: usize = 331;
643
644/// Get the session ID of a process.
645///
646/// - `pid`: target process ID (0 = current process)
647///
648/// Returns the session ID.
649pub const SYS_GETSID: usize = 332;
650
651/// Set the clear-on-exit TID address for the current thread.
652///
653/// - `tidptr`: pointer to the TID variable (for `CLONE_CHILD_CLEARTID`)
654///
655/// When the thread exits, the kernel clears the memory at `tidptr` and
656/// wakes any futex waiters on that address.
657pub const SYS_SET_TID_ADDRESS: usize = 333;
658
659/// Exit all threads in the current process.
660///
661/// - `exit_code`: process exit status
662///
663/// This is the multi-threaded equivalent of `SYS_PROC_EXIT`. All threads
664/// are terminated, not just the calling thread.
665pub const SYS_EXIT_GROUP: usize = 334;
666
667/// Get the real user ID of the calling process.
668pub const SYS_GETUID: usize = 335;
669
670/// Get the effective user ID of the calling process.
671pub const SYS_GETEUID: usize = 336;
672
673/// Get the real group ID of the calling process.
674pub const SYS_GETGID: usize = 337;
675
676/// Get the effective group ID of the calling process.
677pub const SYS_GETEGID: usize = 338;
678
679/// Set the real user ID of the calling process.
680///
681/// - `uid`: new real user ID
682///
683/// Requires root privileges. Also sets the effective UID.
684pub const SYS_SETUID: usize = 339;
685
686/// Set the real group ID of the calling process.
687///
688/// - `gid`: new real group ID
689///
690/// Requires root privileges. Also sets the effective GID.
691pub const SYS_SETGID: usize = 340;
692
693/// Create a new thread within the current process.
694///
695/// - `entry`: thread entry point address
696/// - `stack`: thread stack base address
697/// - `arg`: argument passed to the thread entry point
698///
699/// Returns the new thread ID (TID).
700pub const SYS_THREAD_CREATE: usize = 341;
701
702/// Wait for a thread to exit.
703///
704/// - `tid`: thread ID to wait for
705/// - `status_ptr`: pointer to receive the exit status (0 = ignore)
706///
707/// Blocks until the thread terminates.
708pub const SYS_THREAD_JOIN: usize = 342;
709
710/// Terminate the current thread.
711///
712/// - `status`: thread exit status
713///
714/// This syscall never returns. Only the calling thread is terminated;
715/// other threads in the process continue running.
716pub const SYS_THREAD_EXIT: usize = 343;
717
718/// Get system identification information.
719///
720/// - `uts_ptr`: pointer to a `Utsname` struct that receives:
721///   - `sysname`: OS name ("Strat9")
722///   - `nodename`: hostname
723///   - `release`: kernel version
724///   - `version`: build timestamp
725///   - `machine`: architecture ("x86_64")
726///
727/// Returns `0` on success.
728pub const SYS_UNAME: usize = 344;
729
730/// Architecture-specific process control.
731///
732/// - `code`: operation code (`ARCH_SET_FS` = 0x1001, `ARCH_GET_FS` = 0x1002)
733/// - `addr`: address value (for set operations)
734///
735/// Used primarily to set the FS base for thread-local storage.
736pub const SYS_ARCH_PRCTL: usize = 350;
737
738/// Send a signal to a specific thread.
739///
740/// - `tgid`: thread group ID (process ID)
741/// - `tid`: target thread ID
742/// - `signum`: signal number
743///
744/// Unlike `SYS_KILL`, this targets a specific thread within a process.
745pub const SYS_TGKILL: usize = 352;
746
747/// Return from a signal handler.
748///
749/// Restores the signal mask and registers from the signal frame on the
750/// user stack. This syscall is invoked implicitly by the kernel when
751/// returning from a signal handler trampoline.
752pub const SYS_RT_SIGRETURN: usize = 353;
753
754// ── Block 400-499: Filesystem / VFS ─────────────────────────────────────────
755
756/// Open a file by path.
757///
758/// - `path_ptr`: pointer to the null-terminated path string
759/// - `path_len`: length of the path
760/// - `flags`: open flags (`O_RDONLY`, `O_WRONLY`, `O_RDWR`, `O_CREAT`, etc.)
761///
762/// Returns a file descriptor on success.
763pub const SYS_OPEN: usize = 403;
764
765/// Write data to a file descriptor.
766///
767/// - `fd`: file descriptor
768/// - `buf_ptr`: pointer to the data buffer
769/// - `buf_len`: number of bytes to write
770///
771/// Returns the number of bytes actually written.
772pub const SYS_WRITE: usize = 404;
773
774/// Read data from a file descriptor.
775///
776/// - `fd`: file descriptor
777/// - `buf_ptr`: buffer to receive the data
778/// - `buf_len`: maximum number of bytes to read
779///
780/// Returns the number of bytes actually read (0 = end of file).
781pub const SYS_READ: usize = 405;
782
783/// Close a file descriptor.
784///
785/// - `fd`: file descriptor to close
786///
787/// After this call, the file descriptor is invalid.
788pub const SYS_CLOSE: usize = 406;
789
790/// Set the file position of a file descriptor.
791///
792/// - `fd`: file descriptor
793/// - `offset`: new position offset
794/// - `whence`: `SEEK_SET` (0), `SEEK_CUR` (1), or `SEEK_END` (2)
795///
796/// Returns the new file position.
797pub const SYS_LSEEK: usize = 407;
798
799/// Get file status information by file descriptor.
800///
801/// - `fd`: file descriptor
802/// - `stat_ptr`: pointer to a `FileStat` struct to receive the result
803///
804/// Returns `0` on success.
805pub const SYS_FSTAT: usize = 408;
806
807/// Get file status information by path.
808///
809/// - `path_ptr`: pointer to the path string
810/// - `path_len`: length of the path
811/// - `stat_ptr`: pointer to a `FileStat` struct
812///
813/// Returns `0` on success.
814pub const SYS_STAT: usize = 409;
815
816// ── Block 410-419: Network ──────────────────────────────────────────────────
817
818/// Receive a network packet.
819///
820/// - `buf_ptr`: buffer to receive the packet data
821/// - `buf_len`: size of the buffer
822///
823/// Returns the number of bytes received. The packet includes all headers
824/// (Ethernet, IP, TCP/UDP).
825pub const SYS_NET_RECV: usize = 410;
826
827/// Send a network packet.
828///
829/// - `buf_ptr`: pointer to the packet data (including all headers)
830/// - `buf_len`: length of the packet
831///
832/// Returns the number of bytes sent.
833pub const SYS_NET_SEND: usize = 411;
834
835/// Query network interface information.
836///
837/// - `info_type`: information type (IP address, MAC, link status, etc.)
838/// - `buf_ptr`: buffer to receive the information
839///
840/// Returns `0` on success.
841pub const SYS_NET_INFO: usize = 412;
842
843/// Register the calling task as the strate-net networking silo.
844///
845/// Called once by strate-net during startup.  The NIC IRQ handler uses
846/// this registration to wake the networking task when packets arrive.
847///
848/// Returns `0` on success.
849pub const SYS_NET_REGISTER: usize = 414;
850
851/// Check file accessibility using the real user/group IDs.
852///
853/// - `path_ptr`: pointer to the path string
854/// - `path_len`: length of the path
855/// - `mode`: accessibility check (`F_OK`=0, `R_OK`=4, `W_OK`=2, `X_OK`=1)
856///
857/// Returns `0` if the file is accessible, `-EACCES` or `-ENOENT` otherwise.
858/// Prefer `SYS_FACCESSAT` for new code : this syscall is provided for
859/// POSIX compatibility.
860pub const SYS_ACCESS: usize = 413;
861
862// ── Block 420-429: Volumes / Block Devices ──────────────────────────────────
863
864/// Read data from a block device volume.
865///
866/// - `handle`: volume capability handle
867/// - `offset`: byte offset into the volume
868/// - `buf_ptr`: buffer to receive the data
869/// - `buf_len`: number of bytes to read
870///
871/// Returns the number of bytes read.
872pub const SYS_VOLUME_READ: usize = 420;
873
874/// Write data to a block device volume.
875///
876/// - `handle`: volume capability handle
877/// - `offset`: byte offset into the volume
878/// - `buf_ptr`: pointer to the data buffer
879/// - `buf_len`: number of bytes to write
880///
881/// Returns the number of bytes written.
882pub const SYS_VOLUME_WRITE: usize = 421;
883
884/// Query information about a block device volume.
885///
886/// - `handle`: volume capability handle
887/// - `out_ptr`: pointer to a `VolumeInfo` struct (size, block size, etc.)
888///
889/// Returns `0` on success.
890pub const SYS_VOLUME_INFO: usize = 422;
891
892// ── Block 430-461: VFS Extended ─────────────────────────────────────────────
893
894/// Read directory entries from an open directory.
895///
896/// - `fd`: directory file descriptor
897/// - `buf_ptr`: buffer to receive `DirEntry` structs
898/// - `buf_len`: size of the buffer
899///
900/// Returns the number of bytes read. Returns `0` when all entries
901/// have been read (end of directory).
902pub const SYS_GETDENTS: usize = 430;
903
904/// Create a pipe pair for inter-process communication.
905///
906/// - `fds_ptr`: pointer to receive two file descriptors (read end, write end)
907///
908/// Returns `0` on success. The pipe provides unidirectional byte stream IPC.
909pub const SYS_PIPE: usize = 431;
910
911/// Duplicate a file descriptor.
912///
913/// - `old_fd`: file descriptor to duplicate
914///
915/// Returns the new file descriptor (lowest available).
916pub const SYS_DUP: usize = 432;
917
918/// Duplicate a file descriptor to a specific number.
919///
920/// - `old_fd`: file descriptor to duplicate
921/// - `new_fd`: desired new file descriptor number
922///
923/// If `new_fd` is already open, it is closed first. Returns `new_fd`.
924pub const SYS_DUP2: usize = 433;
925
926/// Change the current working directory by path.
927///
928/// - `path_ptr`: pointer to the new directory path
929/// - `path_len`: length of the path
930pub const SYS_CHDIR: usize = 440;
931
932/// Change the current working directory by file descriptor.
933///
934/// - `fd`: file descriptor of an open directory
935pub const SYS_FCHDIR: usize = 441;
936
937/// Get the current working directory.
938///
939/// - `buf_ptr`: buffer to receive the path string
940/// - `buf_len`: size of the buffer
941///
942/// Returns the number of bytes written (excluding null terminator).
943pub const SYS_GETCWD: usize = 442;
944
945/// Perform device-specific I/O control operations.
946///
947/// - `fd`: file descriptor
948/// - `cmd`: device-specific command code
949/// - `arg`: command-specific argument
950///
951/// The behavior depends entirely on the device driver.
952pub const SYS_IOCTL: usize = 443;
953
954/// Set the file mode creation mask.
955///
956/// - `mask`: new umask value (e.g., `0o022`)
957///
958/// Returns the previous umask. New files are created with
959/// `mode & ~umask`.
960pub const SYS_UMASK: usize = 444;
961
962/// Delete a file by path.
963///
964/// - `path_ptr`: pointer to the file path
965/// - `path_len`: length of the path
966pub const SYS_UNLINK: usize = 445;
967
968/// Remove an empty directory by path.
969///
970/// - `path_ptr`: pointer to the directory path
971/// - `path_len`: length of the path
972pub const SYS_RMDIR: usize = 446;
973
974/// Create a directory by path.
975///
976/// - `path_ptr`: pointer to the directory path
977/// - `path_len`: length of the path
978/// - `mode`: permission mode (e.g., `0o755`)
979pub const SYS_MKDIR: usize = 447;
980
981/// Rename or move a file.
982///
983/// - `old_ptr`: pointer to the old path
984/// - `old_len`: length of the old path
985/// - `new_ptr`: pointer to the new path
986/// - `new_len`: length of the new path
987///
988/// Atomic operation : either succeeds completely or fails.
989pub const SYS_RENAME: usize = 448;
990
991/// Create a hard link to an existing file.
992///
993/// - `old_ptr`: pointer to the existing file path
994/// - `old_len`: length of the existing path
995/// - `new_ptr`: pointer to the new link path
996/// - `new_len`: length of the new path
997pub const SYS_LINK: usize = 449;
998
999/// Create a symbolic link.
1000///
1001/// - `target_ptr`: pointer to the target path (what the link points to)
1002/// - `target_len`: length of the target path
1003/// - `link_ptr`: pointer to the link path (where the link is created)
1004/// - `link_len`: length of the link path
1005pub const SYS_SYMLINK: usize = 450;
1006
1007/// Read the target of a symbolic link.
1008///
1009/// - `path_ptr`: pointer to the symlink path
1010/// - `path_len`: length of the path
1011/// - `buf_ptr`: buffer to receive the target path
1012/// - `buf_len`: size of the buffer
1013///
1014/// Returns the number of bytes placed in the buffer.
1015pub const SYS_READLINK: usize = 451;
1016
1017/// Change file permissions by path.
1018///
1019/// - `path_ptr`: pointer to the file path
1020/// - `path_len`: length of the path
1021/// - `mode`: new permission mode (e.g., `0o644`)
1022pub const SYS_CHMOD: usize = 452;
1023
1024/// Change file permissions by file descriptor.
1025///
1026/// - `fd`: file descriptor
1027/// - `mode`: new permission mode
1028pub const SYS_FCHMOD: usize = 453;
1029
1030/// Truncate a file to a specified length by path.
1031///
1032/// - `path_ptr`: pointer to the file path
1033/// - `path_len`: length of the path
1034/// - `len`: desired file length in bytes
1035pub const SYS_TRUNCATE: usize = 454;
1036
1037/// Truncate a file to a specified length by file descriptor.
1038///
1039/// - `fd`: file descriptor
1040/// - `len`: desired file length in bytes
1041pub const SYS_FTRUNCATE: usize = 455;
1042
1043/// Read from a file descriptor at a specific offset.
1044///
1045/// - `fd`: file descriptor
1046/// - `buf_ptr`: buffer to receive the data
1047/// - `buf_len`: number of bytes to read
1048/// - `offset`: byte offset in the file
1049///
1050/// Returns the number of bytes read. The file position is not changed.
1051pub const SYS_PREAD: usize = 456;
1052
1053/// Write to a file descriptor at a specific offset.
1054///
1055/// - `fd`: file descriptor
1056/// - `buf_ptr`: pointer to the data buffer
1057/// - `buf_len`: number of bytes to write
1058/// - `offset`: byte offset in the file
1059///
1060/// Returns the number of bytes written. The file position is not changed.
1061pub const SYS_PWRITE: usize = 457;
1062
1063/// Synchronize a file's in-core state with storage.
1064///
1065/// - `fd`: file descriptor
1066pub const SYS_FSYNC: usize = 458;
1067
1068/// Synchronize file data (not metadata) with storage.
1069///
1070/// - `fd`: file descriptor
1071pub const SYS_FDATASYNC: usize = 459;
1072
1073// ── Block 460-461: Poll / I/O Multiplexing ──────────────────────────────────
1074
1075/// Poll multiple file descriptors for events.
1076///
1077/// - `fds_ptr`: pointer to an array of `PollFd` structs
1078/// - `nfds`: number of file descriptors in the array
1079/// - `timeout_ms`: maximum wait time in milliseconds (-1 = infinite, 0 = return immediately)
1080///
1081/// Returns the number of file descriptors with events, or `0` on timeout.
1082pub const SYS_POLL: usize = 460;
1083
1084/// Poll with signal mask (ppoll).
1085///
1086/// - `fds_ptr`: pointer to an array of `PollFd` structs
1087/// - `nfds`: number of file descriptors
1088/// - `timeout_ptr`: pointer to a `Timespec` struct (0 = return immediately)
1089/// - `sigmask_ptr`: pointer to signal set to temporarily unblock during poll
1090///
1091/// Returns the number of file descriptors with events.
1092pub const SYS_PPOLL: usize = 461;
1093
1094// ── Block 462-469: *at() Syscalls (FD-Relative Path Resolution) ─────────────
1095//
1096// These syscalls resolve paths relative to a directory file descriptor
1097// instead of the process CWD. They are the POSIX-standard way to open,
1098// stat, and manipulate files safely in multi-threaded programs.
1099//
1100// Special `dirfd` values:
1101//   AT_FDCWD (-100) : use the process's current working directory
1102//   >= 0            : use the opened directory referenced by this fd
1103
1104/// Base directory for *at() syscalls: use the process CWD.
1105pub const AT_FDCWD: i64 = -100;
1106
1107/// Open a file relative to a directory FD.
1108///
1109/// - `dirfd`: directory file descriptor (or `AT_FDCWD`)
1110/// - `path_ptr`: pointer to the path string
1111/// - `path_len`: length of the path
1112/// - `flags`: open flags
1113///
1114/// Returns a file descriptor. If `path_ptr` is absolute, `dirfd` is ignored.
1115pub const SYS_OPENAT: usize = 462;
1116
1117/// Get file status relative to a directory FD.
1118///
1119/// - `dirfd`: directory file descriptor (or `AT_FDCWD`)
1120/// - `path_ptr`: pointer to the path string
1121/// - `path_len`: length of the path
1122/// - `stat_ptr`: pointer to a `FileStat` struct
1123/// - `flags`: flags (`AT_SYMLINK_NOFOLLOW` to not follow symlinks)
1124///
1125/// Returns `0` on success.
1126pub const SYS_FSTATAT: usize = 463;
1127
1128/// Delete a file relative to a directory FD.
1129///
1130/// - `dirfd`: directory file descriptor (or `AT_FDCWD`)
1131/// - `path_ptr`: pointer to the file path
1132/// - `path_len`: length of the path
1133/// - `flags`: flags (`AT_REMOVEDIR` to remove a directory instead of a file)
1134pub const SYS_UNLINKAT: usize = 464;
1135
1136/// Rename or move a file between two directory FDs.
1137///
1138/// - `olddirfd`: source directory FD (or `AT_FDCWD`)
1139/// - `old_ptr`: pointer to the source path
1140/// - `old_len`: length of the source path
1141/// - `newdirfd`: destination directory FD (or `AT_FDCWD`)
1142/// - `new_ptr`: pointer to the destination path
1143/// - `new_len`: length of the destination path
1144///
1145/// Source and destination can be on different mount points (atomic if same FS).
1146pub const SYS_RENAMEAT: usize = 465;
1147
1148/// Create a directory relative to a directory FD.
1149///
1150/// - `dirfd`: directory file descriptor (or `AT_FDCWD`)
1151/// - `path_ptr`: pointer to the directory path
1152/// - `path_len`: length of the path
1153/// - `mode`: permission mode (e.g., `0o755`)
1154pub const SYS_MKDIRAT: usize = 466;
1155
1156/// Read the target of a symbolic link relative to a directory FD.
1157///
1158/// - `dirfd`: directory file descriptor (or `AT_FDCWD`)
1159/// - `path_ptr`: pointer to the symlink path
1160/// - `path_len`: length of the path
1161/// - `buf_ptr`: buffer to receive the target path
1162/// - `buf_len`: size of the buffer
1163///
1164/// Returns the number of bytes placed in the buffer.
1165pub const SYS_READLINKAT: usize = 467;
1166
1167/// Check file accessibility relative to a directory FD.
1168///
1169/// - `dirfd`: directory file descriptor (or `AT_FDCWD`)
1170/// - `path_ptr`: pointer to the path string
1171/// - `path_len`: length of the path
1172/// - `mode`: accessibility check (`R_OK`=4, `W_OK`=2, `X_OK`=1, `F_OK`=0)
1173/// - `flags`: flags (currently unused, pass 0)
1174///
1175/// Returns `0` if the file is accessible, `-EACCES` or `-ENOENT` otherwise.
1176/// This is the preferred way to check file access : it avoids TOCTOU races
1177/// that `SYS_ACCESS` can have when paths are resolved relative to CWD.
1178pub const SYS_FACCESSAT: usize = 468;
1179
1180// ── Block 500-599: Time / Alarms ────────────────────────────────────────────
1181
1182/// Get the current time of a clock.
1183///
1184/// - `clock_id`: clock identifier (`CLOCK_REALTIME`, `CLOCK_MONOTONIC`, etc.)
1185/// - `tp_ptr`: pointer to a `Timespec` struct to receive the time
1186///
1187/// Returns `0` on success.
1188pub const SYS_CLOCK_GETTIME: usize = 500;
1189
1190/// Suspend execution for a specified duration.
1191///
1192/// - `req_ptr`: pointer to a `Timespec` struct (requested sleep time)
1193/// - `rem_ptr`: pointer to receive the remaining time (0 = ignore)
1194///
1195/// Returns `0` on success. The actual sleep may be shorter due to
1196/// signal delivery.
1197pub const SYS_NANOSLEEP: usize = 501;
1198
1199/// Suspend execution on a specific clock.
1200///
1201/// - `clock_id`: clock to use for the sleep
1202/// - `flags`: `TIMER_ABSTIME` (1) for absolute time, 0 for relative
1203/// - `req_ptr`: pointer to a `Timespec` struct
1204/// - `rem_ptr`: pointer to receive the remaining time (0 = ignore)
1205///
1206/// Returns `0` on success.
1207pub const SYS_CLOCK_NANOSLEEP: usize = 502;
1208
1209// ── Block 600-699: Debug / Profiling / Random / Robust List ────────────────
1210
1211/// Write a debug message to the kernel log (serial console).
1212///
1213/// - `msg_ptr`: pointer to the message string
1214/// - `msg_len`: length of the message
1215///
1216/// The message is written to the serial port and optionally to the
1217/// VGA framebuffer if debug output is enabled.
1218pub const SYS_DEBUG_LOG: usize = 600;
1219
1220/// Fill a buffer with cryptographically secure random bytes.
1221///
1222/// - `buf`: pointer to the buffer to fill
1223/// - `len`: number of random bytes to generate
1224/// - `flags`: `GRND_RANDOM` (1) for /dev/random behavior, 0 for /dev/urandom
1225///
1226/// Returns the number of bytes written. Uses RDRAND/RDSEED when available.
1227pub const SYS_GETRANDOM: usize = 601;
1228
1229/// Set the robust futex list head for the current thread.
1230///
1231/// - `head`: pointer to the first `RobustListHead` struct
1232/// - `len`: length of the list in bytes
1233///
1234/// The kernel walks this list on thread exit to wake any futex waiters.
1235pub const SYS_SET_ROBUST_LIST: usize = 610;
1236
1237/// Get the robust futex list head for a process.
1238///
1239/// - `pid`: target process ID (0 = current)
1240/// - `head_ptr`: pointer to receive the list head address
1241/// - `len_ptr`: pointer to receive the list length
1242pub const SYS_GET_ROBUST_LIST: usize = 611;
1243
1244// ── Block 700-799: Module Management (.cmod) ────────────────────────────────
1245
1246/// Load a kernel module from a CMOD binary.
1247///
1248/// - `path_ptr`: pointer to the module path string
1249/// - `path_len`: length of the path
1250///
1251/// Returns a module ID on success. The module is loaded into the kernel
1252/// address space and its init function is called.
1253pub const SYS_MODULE_LOAD: usize = 700;
1254
1255/// Unload a previously loaded kernel module.
1256///
1257/// - `module_id`: module ID from `SYS_MODULE_LOAD`
1258///
1259/// Calls the module's cleanup function, then unmaps its memory.
1260/// Returns `0` on success.
1261pub const SYS_MODULE_UNLOAD: usize = 701;
1262
1263/// Look up a symbol address in a loaded kernel module.
1264///
1265/// - `module_id`: module ID
1266/// - `name_ptr`: pointer to the null-terminated symbol name
1267/// - `name_len`: length of the symbol name
1268///
1269/// Returns the virtual address of the symbol, or `0` if not found.
1270pub const SYS_MODULE_GET_SYMBOL: usize = 702;
1271
1272/// List all loaded kernel modules.
1273///
1274/// - `out_ptr`: buffer to receive `ModuleInfo` structs
1275/// - `max_count`: maximum number of modules to return
1276///
1277/// Returns the number of modules written to the buffer.
1278pub const SYS_MODULE_QUERY: usize = 703;
1279
1280// ── Block 800-899: Silo Management ─────────────────────────────────────────
1281
1282/// Create a new silo (process isolation container).
1283///
1284/// Returns a silo ID on success. The silo starts in a stopped state
1285/// and must be configured and started with subsequent syscalls.
1286pub const SYS_SILO_CREATE: usize = 800;
1287
1288/// Configure a silo's properties.
1289///
1290/// - `silo_id`: silo to configure
1291/// - `key_ptr`: pointer to the configuration key string
1292/// - `key_len`: length of the key
1293/// - `val_ptr`: pointer to the configuration value string
1294/// - `val_len`: length of the value
1295///
1296/// Configuration keys include: `mode` (OctalMode), `mem_max`, `mem_usage_bytes`.
1297pub const SYS_SILO_CONFIG: usize = 801;
1298
1299/// Attach a kernel module to a silo.
1300///
1301/// - `silo_id`: target silo
1302/// - `module_id`: module ID from `SYS_MODULE_LOAD`
1303///
1304/// The module runs inside the silo's address space and can be started
1305/// with `SYS_SILO_START`.
1306pub const SYS_SILO_ATTACH_MODULE: usize = 802;
1307
1308/// Start a silo (begin execution of its attached module).
1309///
1310/// - `silo_id`: silo to start
1311///
1312/// The silo's module init function is called, and the silo enters
1313/// the running state.
1314pub const SYS_SILO_START: usize = 803;
1315
1316/// Stop a silo gracefully (sends SIGTERM, waits for cleanup).
1317///
1318/// - `silo_id`: silo to stop
1319///
1320/// Returns `0` on success, `-ETIMEDOUT` if the silo doesn't stop in time.
1321pub const SYS_SILO_STOP: usize = 804;
1322
1323/// Force-kill a silo immediately (SIGKILL).
1324///
1325/// - `silo_id`: silo to kill
1326///
1327/// The silo is terminated without cleanup. Use `SYS_SILO_STOP` for
1328/// graceful shutdown.
1329pub const SYS_SILO_KILL: usize = 805;
1330
1331/// Wait for the next event from a silo.
1332///
1333/// - `silo_id`: silo to monitor
1334/// - `out_ptr`: pointer to a `SiloEvent` struct to receive the event
1335///
1336/// Events include: state changes, faults, resource usage alerts.
1337/// Blocks until an event is available.
1338pub const SYS_SILO_EVENT_NEXT: usize = 806;
1339
1340/// Suspend a running silo (freeze its threads).
1341///
1342/// - `silo_id`: silo to suspend
1343pub const SYS_SILO_SUSPEND: usize = 807;
1344
1345/// Resume a suspended silo.
1346///
1347/// - `silo_id`: silo to resume
1348pub const SYS_SILO_RESUME: usize = 808;
1349
1350/// Restrict syscalls available to a silo (pledge).
1351///
1352/// - `promises_ptr`: pointer to the octal mode value string
1353/// - `promises_len`: length of the string
1354///
1355/// The new mode must be a subset of the current mode (monotonic restriction).
1356/// Once pledged, the silo cannot gain additional capabilities.
1357pub const SYS_SILO_PLEDGE: usize = 809;
1358
1359/// Restrict filesystem access for a silo (unveil).
1360///
1361/// - `path_ptr`: pointer to the path to reveal
1362/// - `path_len`: length of the path
1363/// - `perms_ptr`: pointer to the permissions string (e.g., "rwx")
1364/// - `perms_len`: length of the permissions string
1365///
1366/// Only paths that have been unveiled are accessible. Once a path is
1367/// unveiled, the silo cannot unveil additional paths (monotonic).
1368pub const SYS_SILO_UNVEIL: usize = 810;
1369
1370/// Enter sandbox mode (irreversible).
1371///
1372/// After this call, the silo cannot:
1373/// - Gain new capabilities (pledge is locked)
1374/// - Access new filesystem paths (unveil is locked)
1375/// - Execute certain privileged syscalls
1376///
1377/// This is a one-way operation : there is no way to exit sandbox mode.
1378pub const SYS_SILO_ENTER_SANDBOX: usize = 811;
1379
1380/// Rename a silo.
1381///
1382/// - `silo_id`: silo to rename
1383/// - `name_ptr`: pointer to the new name string
1384/// - `name_len`: length of the new name
1385///
1386/// The name is used for display and debugging purposes.
1387pub const SYS_SILO_RENAME: usize = 812;
1388
1389// ── Block 900: ABI Introspection ────────────────────────────────────────────
1390
1391/// Query the ABI version.
1392///
1393/// No parameters.
1394///
1395/// Returns `(major << 16) | minor`. For example, version 1.2 returns
1396/// `0x0001_0002`. Userspace can use this to check for ABI compatibility
1397/// before making syscalls.
1398pub const SYS_ABI_VERSION: usize = 900;