mirror of
https://gitlab.os-k.eu/os-k-team/os-k.git
synced 2023-08-25 14:03:10 +02:00
46 lines
1.3 KiB
Markdown
46 lines
1.3 KiB
Markdown
# OS on Kaleid Documentation
|
|
## System calls in Kaleid kernel
|
|
|
|
Copyright © 2018-2021 The OS/K Team
|
|
|
|
| ![FDL Logo](https://www.os-k.eu/FDLLOGO.png) | Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License|
|
|
|-------|-----------------------|
|
|
|
|
### System call ABI
|
|
|
|
System calls take arguments and return values from/by classical System V ABI
|
|
registers
|
|
|
|
#### Arguments
|
|
|
|
rdi : system call code
|
|
rsi : first argument
|
|
rdx : second argument
|
|
r10 : third argument
|
|
|
|
#### Return value
|
|
|
|
rax : an error_t value
|
|
|
|
### System call vector
|
|
|
|
In OS/K, system calls are triggered by an userspace program using a software
|
|
interrupt vector 0x80.
|
|
In assembly language that means using `int 0x80`
|
|
|
|
That vector is directly registered in the IDT : it *does not* use the ISR
|
|
inscription function (`error_t KeRegisterISR(void (*isr)(ISRFrame_t *regs), uchar
|
|
isrNo)`), thus a device driver can't replace the syscall handler.
|
|
|
|
#### Pre-handler
|
|
|
|
When int 0x80 is triggered, following the IDT, the pre-handler `syscallPreHandler`
|
|
takes control. The role of that pre-handler is mainly context-switching related
|
|
before the actual system call takes place.
|
|
|
|
#### Syscall handler
|
|
|
|
`error_t _KeSyscallHandler(ulong code, ISRFrame_t *regs)` is called by the
|
|
pre-handler and actually get parameters
|
|
|