Syscalls
Description
System calls provide a way to execute kernel routines from userland, so they can get ressources like memory, I/O accesses… Their implementation always consists in two parts:
- kernel-side syscall handling
- user-side syscall wrapping (syscall user API)
A unique syscall gate, 0x80, is used for all the syscalls. The dispatch is done in the kernel through a table depending on a identifier. The syscall identifier is passed as a parameter. The parameter passing method is Linux-like (registers).
Syscalls parameters are given in %ebx through %edx, %eax is the syscall number.
Recommended methodology
- Ensure that the event manager is working properly
- Write the syscall dispatch table management functions:
- allocate/clean the dispatch table
- add a handler to the table depending on the syscall identifier
- Implement the syscall wrapper as a classic interrupts wrapper which:
- fetches syscall parameters before they are corrupted by the wrapper execution
- executes the handler depending on the syscall identifier
- Write the syscall initialization procedure:
- initialize the syscall dispatch table
- register every syscall
- add the syscall gate to the IDT
- Write a fake syscall for testing purposes:
- print the syscall identifier when executing
int 0x80
- print the syscall identifier when executing
- Fill the syscall dispatch table with the developed syscalls.
Notes
Syscall ids are defined in include/k/kstd.h
. You must follow those values!