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/// Check file accessibility using the real user/group IDs.
844///
845/// - `path_ptr`: pointer to the path string
846/// - `path_len`: length of the path
847/// - `mode`: accessibility check (`F_OK`=0, `R_OK`=4, `W_OK`=2, `X_OK`=1)
848///
849/// Returns `0` if the file is accessible, `-EACCES` or `-ENOENT` otherwise.
850/// Prefer `SYS_FACCESSAT` for new code : this syscall is provided for
851/// POSIX compatibility.
852pub const SYS_ACCESS: usize = 413;
853
854// ── Block 420-429: Volumes / Block Devices ──────────────────────────────────
855
856/// Read data from a block device volume.
857///
858/// - `handle`: volume capability handle
859/// - `offset`: byte offset into the volume
860/// - `buf_ptr`: buffer to receive the data
861/// - `buf_len`: number of bytes to read
862///
863/// Returns the number of bytes read.
864pub const SYS_VOLUME_READ: usize = 420;
865
866/// Write data to a block device volume.
867///
868/// - `handle`: volume capability handle
869/// - `offset`: byte offset into the volume
870/// - `buf_ptr`: pointer to the data buffer
871/// - `buf_len`: number of bytes to write
872///
873/// Returns the number of bytes written.
874pub const SYS_VOLUME_WRITE: usize = 421;
875
876/// Query information about a block device volume.
877///
878/// - `handle`: volume capability handle
879/// - `out_ptr`: pointer to a `VolumeInfo` struct (size, block size, etc.)
880///
881/// Returns `0` on success.
882pub const SYS_VOLUME_INFO: usize = 422;
883
884// ── Block 430-461: VFS Extended ─────────────────────────────────────────────
885
886/// Read directory entries from an open directory.
887///
888/// - `fd`: directory file descriptor
889/// - `buf_ptr`: buffer to receive `DirEntry` structs
890/// - `buf_len`: size of the buffer
891///
892/// Returns the number of bytes read. Returns `0` when all entries
893/// have been read (end of directory).
894pub const SYS_GETDENTS: usize = 430;
895
896/// Create a pipe pair for inter-process communication.
897///
898/// - `fds_ptr`: pointer to receive two file descriptors (read end, write end)
899///
900/// Returns `0` on success. The pipe provides unidirectional byte stream IPC.
901pub const SYS_PIPE: usize = 431;
902
903/// Duplicate a file descriptor.
904///
905/// - `old_fd`: file descriptor to duplicate
906///
907/// Returns the new file descriptor (lowest available).
908pub const SYS_DUP: usize = 432;
909
910/// Duplicate a file descriptor to a specific number.
911///
912/// - `old_fd`: file descriptor to duplicate
913/// - `new_fd`: desired new file descriptor number
914///
915/// If `new_fd` is already open, it is closed first. Returns `new_fd`.
916pub const SYS_DUP2: usize = 433;
917
918/// Change the current working directory by path.
919///
920/// - `path_ptr`: pointer to the new directory path
921/// - `path_len`: length of the path
922pub const SYS_CHDIR: usize = 440;
923
924/// Change the current working directory by file descriptor.
925///
926/// - `fd`: file descriptor of an open directory
927pub const SYS_FCHDIR: usize = 441;
928
929/// Get the current working directory.
930///
931/// - `buf_ptr`: buffer to receive the path string
932/// - `buf_len`: size of the buffer
933///
934/// Returns the number of bytes written (excluding null terminator).
935pub const SYS_GETCWD: usize = 442;
936
937/// Perform device-specific I/O control operations.
938///
939/// - `fd`: file descriptor
940/// - `cmd`: device-specific command code
941/// - `arg`: command-specific argument
942///
943/// The behavior depends entirely on the device driver.
944pub const SYS_IOCTL: usize = 443;
945
946/// Set the file mode creation mask.
947///
948/// - `mask`: new umask value (e.g., `0o022`)
949///
950/// Returns the previous umask. New files are created with
951/// `mode & ~umask`.
952pub const SYS_UMASK: usize = 444;
953
954/// Delete a file by path.
955///
956/// - `path_ptr`: pointer to the file path
957/// - `path_len`: length of the path
958pub const SYS_UNLINK: usize = 445;
959
960/// Remove an empty directory by path.
961///
962/// - `path_ptr`: pointer to the directory path
963/// - `path_len`: length of the path
964pub const SYS_RMDIR: usize = 446;
965
966/// Create a directory by path.
967///
968/// - `path_ptr`: pointer to the directory path
969/// - `path_len`: length of the path
970/// - `mode`: permission mode (e.g., `0o755`)
971pub const SYS_MKDIR: usize = 447;
972
973/// Rename or move a file.
974///
975/// - `old_ptr`: pointer to the old path
976/// - `old_len`: length of the old path
977/// - `new_ptr`: pointer to the new path
978/// - `new_len`: length of the new path
979///
980/// Atomic operation : either succeeds completely or fails.
981pub const SYS_RENAME: usize = 448;
982
983/// Create a hard link to an existing file.
984///
985/// - `old_ptr`: pointer to the existing file path
986/// - `old_len`: length of the existing path
987/// - `new_ptr`: pointer to the new link path
988/// - `new_len`: length of the new path
989pub const SYS_LINK: usize = 449;
990
991/// Create a symbolic link.
992///
993/// - `target_ptr`: pointer to the target path (what the link points to)
994/// - `target_len`: length of the target path
995/// - `link_ptr`: pointer to the link path (where the link is created)
996/// - `link_len`: length of the link path
997pub const SYS_SYMLINK: usize = 450;
998
999/// Read the target of a symbolic link.
1000///
1001/// - `path_ptr`: pointer to the symlink path
1002/// - `path_len`: length of the path
1003/// - `buf_ptr`: buffer to receive the target path
1004/// - `buf_len`: size of the buffer
1005///
1006/// Returns the number of bytes placed in the buffer.
1007pub const SYS_READLINK: usize = 451;
1008
1009/// Change file permissions by path.
1010///
1011/// - `path_ptr`: pointer to the file path
1012/// - `path_len`: length of the path
1013/// - `mode`: new permission mode (e.g., `0o644`)
1014pub const SYS_CHMOD: usize = 452;
1015
1016/// Change file permissions by file descriptor.
1017///
1018/// - `fd`: file descriptor
1019/// - `mode`: new permission mode
1020pub const SYS_FCHMOD: usize = 453;
1021
1022/// Truncate a file to a specified length by path.
1023///
1024/// - `path_ptr`: pointer to the file path
1025/// - `path_len`: length of the path
1026/// - `len`: desired file length in bytes
1027pub const SYS_TRUNCATE: usize = 454;
1028
1029/// Truncate a file to a specified length by file descriptor.
1030///
1031/// - `fd`: file descriptor
1032/// - `len`: desired file length in bytes
1033pub const SYS_FTRUNCATE: usize = 455;
1034
1035/// Read from a file descriptor at a specific offset.
1036///
1037/// - `fd`: file descriptor
1038/// - `buf_ptr`: buffer to receive the data
1039/// - `buf_len`: number of bytes to read
1040/// - `offset`: byte offset in the file
1041///
1042/// Returns the number of bytes read. The file position is not changed.
1043pub const SYS_PREAD: usize = 456;
1044
1045/// Write to a file descriptor at a specific offset.
1046///
1047/// - `fd`: file descriptor
1048/// - `buf_ptr`: pointer to the data buffer
1049/// - `buf_len`: number of bytes to write
1050/// - `offset`: byte offset in the file
1051///
1052/// Returns the number of bytes written. The file position is not changed.
1053pub const SYS_PWRITE: usize = 457;
1054
1055// ── Block 460-461: Poll / I/O Multiplexing ──────────────────────────────────
1056
1057/// Poll multiple file descriptors for events.
1058///
1059/// - `fds_ptr`: pointer to an array of `PollFd` structs
1060/// - `nfds`: number of file descriptors in the array
1061/// - `timeout_ms`: maximum wait time in milliseconds (-1 = infinite, 0 = return immediately)
1062///
1063/// Returns the number of file descriptors with events, or `0` on timeout.
1064pub const SYS_POLL: usize = 460;
1065
1066/// Poll with signal mask (ppoll).
1067///
1068/// - `fds_ptr`: pointer to an array of `PollFd` structs
1069/// - `nfds`: number of file descriptors
1070/// - `timeout_ptr`: pointer to a `Timespec` struct (0 = return immediately)
1071/// - `sigmask_ptr`: pointer to signal set to temporarily unblock during poll
1072///
1073/// Returns the number of file descriptors with events.
1074pub const SYS_PPOLL: usize = 461;
1075
1076// ── Block 462-469: *at() Syscalls (FD-Relative Path Resolution) ─────────────
1077//
1078// These syscalls resolve paths relative to a directory file descriptor
1079// instead of the process CWD. They are the POSIX-standard way to open,
1080// stat, and manipulate files safely in multi-threaded programs.
1081//
1082// Special `dirfd` values:
1083// AT_FDCWD (-100) : use the process's current working directory
1084// >= 0 : use the opened directory referenced by this fd
1085
1086/// Base directory for *at() syscalls: use the process CWD.
1087pub const AT_FDCWD: i64 = -100;
1088
1089/// Open a file relative to a directory FD.
1090///
1091/// - `dirfd`: directory file descriptor (or `AT_FDCWD`)
1092/// - `path_ptr`: pointer to the path string
1093/// - `path_len`: length of the path
1094/// - `flags`: open flags
1095///
1096/// Returns a file descriptor. If `path_ptr` is absolute, `dirfd` is ignored.
1097pub const SYS_OPENAT: usize = 462;
1098
1099/// Get file status relative to a directory FD.
1100///
1101/// - `dirfd`: directory file descriptor (or `AT_FDCWD`)
1102/// - `path_ptr`: pointer to the path string
1103/// - `path_len`: length of the path
1104/// - `stat_ptr`: pointer to a `FileStat` struct
1105/// - `flags`: flags (`AT_SYMLINK_NOFOLLOW` to not follow symlinks)
1106///
1107/// Returns `0` on success.
1108pub const SYS_FSTATAT: usize = 463;
1109
1110/// Delete a file relative to a directory FD.
1111///
1112/// - `dirfd`: directory file descriptor (or `AT_FDCWD`)
1113/// - `path_ptr`: pointer to the file path
1114/// - `path_len`: length of the path
1115/// - `flags`: flags (`AT_REMOVEDIR` to remove a directory instead of a file)
1116pub const SYS_UNLINKAT: usize = 464;
1117
1118/// Rename or move a file between two directory FDs.
1119///
1120/// - `olddirfd`: source directory FD (or `AT_FDCWD`)
1121/// - `old_ptr`: pointer to the source path
1122/// - `old_len`: length of the source path
1123/// - `newdirfd`: destination directory FD (or `AT_FDCWD`)
1124/// - `new_ptr`: pointer to the destination path
1125/// - `new_len`: length of the destination path
1126///
1127/// Source and destination can be on different mount points (atomic if same FS).
1128pub const SYS_RENAMEAT: usize = 465;
1129
1130/// Create a directory relative to a directory FD.
1131///
1132/// - `dirfd`: directory file descriptor (or `AT_FDCWD`)
1133/// - `path_ptr`: pointer to the directory path
1134/// - `path_len`: length of the path
1135/// - `mode`: permission mode (e.g., `0o755`)
1136pub const SYS_MKDIRAT: usize = 466;
1137
1138/// Read the target of a symbolic link relative to a directory FD.
1139///
1140/// - `dirfd`: directory file descriptor (or `AT_FDCWD`)
1141/// - `path_ptr`: pointer to the symlink path
1142/// - `path_len`: length of the path
1143/// - `buf_ptr`: buffer to receive the target path
1144/// - `buf_len`: size of the buffer
1145///
1146/// Returns the number of bytes placed in the buffer.
1147pub const SYS_READLINKAT: usize = 467;
1148
1149/// Check file accessibility relative to a directory FD.
1150///
1151/// - `dirfd`: directory file descriptor (or `AT_FDCWD`)
1152/// - `path_ptr`: pointer to the path string
1153/// - `path_len`: length of the path
1154/// - `mode`: accessibility check (`R_OK`=4, `W_OK`=2, `X_OK`=1, `F_OK`=0)
1155/// - `flags`: flags (currently unused, pass 0)
1156///
1157/// Returns `0` if the file is accessible, `-EACCES` or `-ENOENT` otherwise.
1158/// This is the preferred way to check file access : it avoids TOCTOU races
1159/// that `SYS_ACCESS` can have when paths are resolved relative to CWD.
1160pub const SYS_FACCESSAT: usize = 468;
1161
1162// ── Block 500-599: Time / Alarms ────────────────────────────────────────────
1163
1164/// Get the current time of a clock.
1165///
1166/// - `clock_id`: clock identifier (`CLOCK_REALTIME`, `CLOCK_MONOTONIC`, etc.)
1167/// - `tp_ptr`: pointer to a `Timespec` struct to receive the time
1168///
1169/// Returns `0` on success.
1170pub const SYS_CLOCK_GETTIME: usize = 500;
1171
1172/// Suspend execution for a specified duration.
1173///
1174/// - `req_ptr`: pointer to a `Timespec` struct (requested sleep time)
1175/// - `rem_ptr`: pointer to receive the remaining time (0 = ignore)
1176///
1177/// Returns `0` on success. The actual sleep may be shorter due to
1178/// signal delivery.
1179pub const SYS_NANOSLEEP: usize = 501;
1180
1181/// Suspend execution on a specific clock.
1182///
1183/// - `clock_id`: clock to use for the sleep
1184/// - `flags`: `TIMER_ABSTIME` (1) for absolute time, 0 for relative
1185/// - `req_ptr`: pointer to a `Timespec` struct
1186/// - `rem_ptr`: pointer to receive the remaining time (0 = ignore)
1187///
1188/// Returns `0` on success.
1189pub const SYS_CLOCK_NANOSLEEP: usize = 502;
1190
1191// ── Block 600-699: Debug / Profiling / Random / Robust List ────────────────
1192
1193/// Write a debug message to the kernel log (serial console).
1194///
1195/// - `msg_ptr`: pointer to the message string
1196/// - `msg_len`: length of the message
1197///
1198/// The message is written to the serial port and optionally to the
1199/// VGA framebuffer if debug output is enabled.
1200pub const SYS_DEBUG_LOG: usize = 600;
1201
1202/// Fill a buffer with cryptographically secure random bytes.
1203///
1204/// - `buf`: pointer to the buffer to fill
1205/// - `len`: number of random bytes to generate
1206/// - `flags`: `GRND_RANDOM` (1) for /dev/random behavior, 0 for /dev/urandom
1207///
1208/// Returns the number of bytes written. Uses RDRAND/RDSEED when available.
1209pub const SYS_GETRANDOM: usize = 601;
1210
1211/// Set the robust futex list head for the current thread.
1212///
1213/// - `head`: pointer to the first `RobustListHead` struct
1214/// - `len`: length of the list in bytes
1215///
1216/// The kernel walks this list on thread exit to wake any futex waiters.
1217pub const SYS_SET_ROBUST_LIST: usize = 610;
1218
1219/// Get the robust futex list head for a process.
1220///
1221/// - `pid`: target process ID (0 = current)
1222/// - `head_ptr`: pointer to receive the list head address
1223/// - `len_ptr`: pointer to receive the list length
1224pub const SYS_GET_ROBUST_LIST: usize = 611;
1225
1226// ── Block 700-799: Module Management (.cmod) ────────────────────────────────
1227
1228/// Load a kernel module from a CMOD binary.
1229///
1230/// - `path_ptr`: pointer to the module path string
1231/// - `path_len`: length of the path
1232///
1233/// Returns a module ID on success. The module is loaded into the kernel
1234/// address space and its init function is called.
1235pub const SYS_MODULE_LOAD: usize = 700;
1236
1237/// Unload a previously loaded kernel module.
1238///
1239/// - `module_id`: module ID from `SYS_MODULE_LOAD`
1240///
1241/// Calls the module's cleanup function, then unmaps its memory.
1242/// Returns `0` on success.
1243pub const SYS_MODULE_UNLOAD: usize = 701;
1244
1245/// Look up a symbol address in a loaded kernel module.
1246///
1247/// - `module_id`: module ID
1248/// - `name_ptr`: pointer to the null-terminated symbol name
1249/// - `name_len`: length of the symbol name
1250///
1251/// Returns the virtual address of the symbol, or `0` if not found.
1252pub const SYS_MODULE_GET_SYMBOL: usize = 702;
1253
1254/// List all loaded kernel modules.
1255///
1256/// - `out_ptr`: buffer to receive `ModuleInfo` structs
1257/// - `max_count`: maximum number of modules to return
1258///
1259/// Returns the number of modules written to the buffer.
1260pub const SYS_MODULE_QUERY: usize = 703;
1261
1262// ── Block 800-899: Silo Management ─────────────────────────────────────────
1263
1264/// Create a new silo (process isolation container).
1265///
1266/// Returns a silo ID on success. The silo starts in a stopped state
1267/// and must be configured and started with subsequent syscalls.
1268pub const SYS_SILO_CREATE: usize = 800;
1269
1270/// Configure a silo's properties.
1271///
1272/// - `silo_id`: silo to configure
1273/// - `key_ptr`: pointer to the configuration key string
1274/// - `key_len`: length of the key
1275/// - `val_ptr`: pointer to the configuration value string
1276/// - `val_len`: length of the value
1277///
1278/// Configuration keys include: `mode` (OctalMode), `mem_max`, `mem_usage_bytes`.
1279pub const SYS_SILO_CONFIG: usize = 801;
1280
1281/// Attach a kernel module to a silo.
1282///
1283/// - `silo_id`: target silo
1284/// - `module_id`: module ID from `SYS_MODULE_LOAD`
1285///
1286/// The module runs inside the silo's address space and can be started
1287/// with `SYS_SILO_START`.
1288pub const SYS_SILO_ATTACH_MODULE: usize = 802;
1289
1290/// Start a silo (begin execution of its attached module).
1291///
1292/// - `silo_id`: silo to start
1293///
1294/// The silo's module init function is called, and the silo enters
1295/// the running state.
1296pub const SYS_SILO_START: usize = 803;
1297
1298/// Stop a silo gracefully (sends SIGTERM, waits for cleanup).
1299///
1300/// - `silo_id`: silo to stop
1301///
1302/// Returns `0` on success, `-ETIMEDOUT` if the silo doesn't stop in time.
1303pub const SYS_SILO_STOP: usize = 804;
1304
1305/// Force-kill a silo immediately (SIGKILL).
1306///
1307/// - `silo_id`: silo to kill
1308///
1309/// The silo is terminated without cleanup. Use `SYS_SILO_STOP` for
1310/// graceful shutdown.
1311pub const SYS_SILO_KILL: usize = 805;
1312
1313/// Wait for the next event from a silo.
1314///
1315/// - `silo_id`: silo to monitor
1316/// - `out_ptr`: pointer to a `SiloEvent` struct to receive the event
1317///
1318/// Events include: state changes, faults, resource usage alerts.
1319/// Blocks until an event is available.
1320pub const SYS_SILO_EVENT_NEXT: usize = 806;
1321
1322/// Suspend a running silo (freeze its threads).
1323///
1324/// - `silo_id`: silo to suspend
1325pub const SYS_SILO_SUSPEND: usize = 807;
1326
1327/// Resume a suspended silo.
1328///
1329/// - `silo_id`: silo to resume
1330pub const SYS_SILO_RESUME: usize = 808;
1331
1332/// Restrict syscalls available to a silo (pledge).
1333///
1334/// - `promises_ptr`: pointer to the octal mode value string
1335/// - `promises_len`: length of the string
1336///
1337/// The new mode must be a subset of the current mode (monotonic restriction).
1338/// Once pledged, the silo cannot gain additional capabilities.
1339pub const SYS_SILO_PLEDGE: usize = 809;
1340
1341/// Restrict filesystem access for a silo (unveil).
1342///
1343/// - `path_ptr`: pointer to the path to reveal
1344/// - `path_len`: length of the path
1345/// - `perms_ptr`: pointer to the permissions string (e.g., "rwx")
1346/// - `perms_len`: length of the permissions string
1347///
1348/// Only paths that have been unveiled are accessible. Once a path is
1349/// unveiled, the silo cannot unveil additional paths (monotonic).
1350pub const SYS_SILO_UNVEIL: usize = 810;
1351
1352/// Enter sandbox mode (irreversible).
1353///
1354/// After this call, the silo cannot:
1355/// - Gain new capabilities (pledge is locked)
1356/// - Access new filesystem paths (unveil is locked)
1357/// - Execute certain privileged syscalls
1358///
1359/// This is a one-way operation : there is no way to exit sandbox mode.
1360pub const SYS_SILO_ENTER_SANDBOX: usize = 811;
1361
1362/// Rename a silo.
1363///
1364/// - `silo_id`: silo to rename
1365/// - `name_ptr`: pointer to the new name string
1366/// - `name_len`: length of the new name
1367///
1368/// The name is used for display and debugging purposes.
1369pub const SYS_SILO_RENAME: usize = 812;
1370
1371// ── Block 900: ABI Introspection ────────────────────────────────────────────
1372
1373/// Query the ABI version.
1374///
1375/// No parameters.
1376///
1377/// Returns `(major << 16) | minor`. For example, version 1.2 returns
1378/// `0x0001_0002`. Userspace can use this to check for ABI compatibility
1379/// before making syscalls.
1380pub const SYS_ABI_VERSION: usize = 900;