The XenevaOS Service Call Interface (SCI) provides a controlled gateway for user-space applications to request services from the kernel. Service calls act as the bridge between user mode and kernel mode, we can also call it as Kernel IPC calls. Service calls allows application to perform privileged operations such as file access, memory management, process control, and network communication. In XenevaOS, all user applications interact with the kernel through a well-defined set of system calls that follow a consistent calling convention and interface layout.
System calls in XenevaOS are invoked using the syscall instruction (on x86_64) or svc #0 (on ARM64).
The system call number is placed in the R12 register, and arguments are passed through registers R13,R14,R15,RDI and the stack. Upon completion, the return value is stored in RAX register.
For ARM64, the system call number is placed in X16 register, and arguments are passed through registers X0, X1, X2, X3, X4,X5 registers. Upon completion, the return value is stored in X6 register.
Example (x86_64):
ExitProcess:
mov r12, 5
mov r13, 0
mov r14, 0
mov r15, 0
mov rdi, 0
syscall
ret
Example (ARM64):
ProcessSleep:
mov x16, 23
svc #0
mov x0, x6
ret
The Kernel maintains a service call dispatch table, which maps each Kernel handler function to each respective system call number.
| Service Number | Symbol Name | Description |
|---|---|---|
| 0 | null_call |
Does nothing, returns 0 |
| 1 | SeTextOut/UARTDebugOut |
Uses Kernel serial console output to print user space messages |
| 2 | PauseThread |
Put currently running thread to block queue |
| 3 | GetThreadID |
Returns currently running thread ID |
| 4 | GetProcessID |
Returns current running process ID |
| 5 | ProcessExit |
Terminate and deallocate all resources of current running process |
| 6 | ProcessWaitForTermination |
Put the currently running process into wait queue untill desired process terminates. Desired process ID is taken as argument by current process |
| 7 | CreateProcess |
Create a new process slot in Kernel |
| 8 | ProcessLoadExec |
Loads an executable to provided process slot |
| 9 | CreateSharedMem |
Create a shared memory segment into current process slot |
| 10 | ObtainSharedMem |
Maps and return a pointer to shared memory address which mapped to the physical addresses of provided shared memory segment |
| 11 | UnmapSharedMem |
Unmap a shared memory from current process, Shared memory segment is not freed unless it is detached from all attached processes |
| 12 | OpenFile |
Open a file on Kernel and return its file descriptor allocated on the current process slot |