Talking to the kernel
The system call interface: the only way from your app into the kernel.
Preview interface
The app developer kit (SDK) is not public yet. The snippets here show the shape of the interface described in the v0.1 specification. Names, numbers and signatures can change before release. For early access, write to [email protected].
A system call is how an app asks the kernel for something. DurgX has a deliberately short list: about a dozen native calls. Linux's 300+ calls are handled outside the kernel (see Linux apps).
The calls
| Call | What it does | Can block? |
|---|---|---|
SYS_CAP_INVOKE | Use a capability: the main way to act on kernel objects. | No |
SYS_IPC_CALL | Send a quick message and wait for the reply. | Yes |
SYS_IPC_RECV | Wait for a message to arrive. | Yes |
SYS_RING_NOTIFY | Tell the kernel there is new work in a ring. | Never |
SYS_VM_MAP | Map memory into your address space. | No |
SYS_YIELD | Give up the CPU. | Reschedules |
How to make a call
| Register | Role |
|---|---|
rax | System call number on entry. Return value on exit. |
rdi, rsi, rdx, r10, r8, r9 | Arguments 1 to 6. The fourth argument is in r10, not rcx. |
rcx, r11 | Overwritten by the CPU's SYSCALL instruction. |
rdi, rsi, rdx | Treat them as overwritten after the call. |
rbx, rbp, r12 to r15, r8, r9, r10 | Preserved across the call. |
use core::arch::asm;
/// Raw DurgX system call with up to six arguments.
#[inline(always)]
pub unsafe fn syscall6(nr: u64, a0: u64, a1: u64, a2: u64, a3: u64, a4: u64, a5: u64) -> u64 {
let ret: u64;
asm!(
"syscall",
inlateout("rax") nr => ret,
inout("rdi") a0 => _,
inout("rsi") a1 => _,
inout("rdx") a2 => _,
in("r10") a3,
in("r8") a4,
in("r9") a5,
lateout("rcx") _,
lateout("r11") _,
options(nostack),
);
ret
}Errors
Failures come back as negative numbers in rax, in the same style as Linux's -errno. Unknown calls return an invalid-syscall error. Permission problems are reported as capability faults. See Permissions.
Note
Numeric call values and exact argument layouts per call are published in the SDK headers.