1.3 KiB
OS on Kaleid Documentation
System calls in Kaleid kernel
Copyright © 2018-2021 The OS/K Team
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