-
-
Notifications
You must be signed in to change notification settings - Fork 5
Syscalls
kazah-png edited this page Jul 6, 2026
·
9 revisions
Ring-3 → ring-0 interface via syscall/sysret (x86_64 fast syscall).
See also: Userspace, Security, Process Management, Architecture
| Register | Purpose |
|---|---|
| RAX | Syscall number |
| RDI | arg0 |
| RSI | arg1 |
| RDX | arg2 |
| R10 | arg3 |
| R8 | arg4 |
| R9 | arg5 |
| Return | RAX |
| # | Name | Description |
|---|---|---|
| 0 | exit(code) |
Exit process, wake parent |
| 1 | write(fd, buf, len) |
Write to fd |
| 2 | print(msg) |
Debug print (legacy) |
| 3 | open(path, flags) |
Open file |
| 4 | read(fd, buf, len) |
Read from fd |
| 5 | close(fd) |
Close fd |
| 6 | getpid() |
Return PID |
| 7 | sbrk(inc) |
Extend heap |
| 8 | fsize(fd) |
File size |
| 9 | exec(path) |
Spawn + wait |
| 10 | fork() |
COW-clone calling process; child returns 0, parent returns child PID |
| 11 | waitpid(pid, *status) |
Reap a child from ring 3; returns PID on reaped, -2 (EAGAIN) if running, -1 if no child |
-
Pointer validation:
user_ptr_okrejects kernel addresses. See Security. - Opaque fds: Small integers mapped to VFS handles (kernel pointers never exposed)
- copy_from_user/copy_to_user: Walks user page tables safely
- Interrupt masking: Syscalls run with IF=0
NyxOS v6.4.363 · GPL v2 · GitHub · uselessalter on Discord · nyxos@inbox.lv
NyxOS Wiki
Getting started
Kernel
Storage & network
Graphics & apps
Userspace
HOWTO
- HOWTO-Add-a-system-call
- HOWTO-Write-a-userspace-program
- HOWTO-Add-a-shell-command
- HOWTO-Add-a-GUI-application
Reference
- Syscall-Reference
- Command-Reference
- Hardware-Reference
- Format-Reference
- Kernel-Data-Structures
- Source-Tree-Reference
Project