System calls #
Helios supports a small number of system calls, which are documented in their respective pages — consult the site navigation on the left. Helios is a non-preemptable kernel, so a given CPU will not context-switch while executing a syscall or interrupt. The system uses one kernel stack per CPU.
System call ABI #
The Application Binary Interface (ABI) for syscalls varies depending on architecture. Each architecture has a minimum of one register to identify the syscall number to execute, and one return register. Additional registers may be used for passing arguments or returning values. Any arguments which do not fit into the available registers are stored in the IPC buffer (TODO: link).
Each system call has two return values: a status value and an additional value. The status value is zero if no error occured, or non-zero if an error occured. The additional value provides additional information (if useful for that syscall) in the case of success, or additional details about the error in the case of an error. Additional error information may be placed into the IPC buffer if necessary.
x86_64 #
Incoming parameters:
- %rax: system call number
- %rdi: 1st argument
- %rsi: 2nd argument
- %rdx: 3rd argument
- %rcx: 4th argument
- %r8: 5th argument
- %r9: 6th argument
Return values:
- %rax: 1st return value; status code
- %rdx: 2nd return value; additional info
%r10, %r11, and %rcx are destroyed.
Data types:
- uintptr: 64-bit address, virtual or physical
- size: 64-bit unsigned integer
- caddr: 32-bit unsigned integer, capability address
Error handling #
The first return register is used to provide the result of a syscall. The error codes and their meanings are as follows:
Number | Name | Description |
---|---|---|
0 | NONE |
No error occured; the operation completed successfully. |
1 | NOMEM |
Insufficient resources are available. |
2 | INVALID_CADDR |
A provided address exceeded the range of a cspace. |
3 | INVALID_CSLOT |
A provided capability slot was not valid, for instance because it is not empty. |
4 | INVALID_CTYPE |
A provided capability has a type which is not compatible with the requested operation. |
5 | INVALID_PARAM |
An invalid parameter or combination of parameters was provided. |
6 | INVALID_CAP |
An invalid capability or combination of parameters was provided. |
7 | UNSUPPORTED |
The requested operation is not supported by this kernel version. |
8 | MISSING_TABLE |
A page table required to complete a virtual memory mapping is not present. |
9 | ALREADY_MAPPED |
The user attempted to map the same page or page table capability twice. |
10 | INVALID_ASID |
A virtual memory operation was attempted on a vspace capabillity without a valid ASID. |
11 | ACCESS |
The user does not possess the necessary permissions to complete the requested operation. |
12 | OBJECT_DESTROYED |
The subject of an operation was destroyed while it was being performed. |
13 | WOULD_BLOCK |
Non-blocking operation was requested, but is not available. |
The documentation for each syscall or capability invocation clarifies the meaning of each status code as it relates to the requested operation.