-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update README.md and documentation in general (#93)
* Update the main `README.md` file. * Add `README.md` files to some directories. * General documentation improvements.
- Loading branch information
1 parent
899726d
commit 3a01b50
Showing
11 changed files
with
234 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,52 @@ | ||
# System Call Implementations | ||
|
||
The microkernel supports the following implementations to invoke system calls. | ||
Not all implementations are available on all CPUs. On initialization, before | ||
invoking any system call, an application should look at the value of auxiliary | ||
vector number 8 (called `JINUE_AT_HOWSYSCALL`) to determine the best supported | ||
system call implementation: | ||
## Overview and Register Mapping | ||
|
||
On 32-bit x86 there are three system call implementations: one interrupt-based | ||
implementation and two that use different fast system call instructions. | ||
|
||
All three implementations use the same system call register mappings: | ||
|
||
* `arg0` maps to CPU register `eax`. | ||
* `arg1` maps to CPU register `ebx`. | ||
* `arg2` maps to CPU register `esi`. | ||
* `arg3` maps to CPU register `edi`. | ||
|
||
The microkernel uses auxiliary vector number 8 (called `JINUE_AT_HOWSYSCALL`) | ||
to inform the user space loader and initial process of the implementation it | ||
should use. (See the [Initial Process Execution | ||
Environment](../init-process.md) for detail.) | ||
|
||
The value of this auxiliary vector will be set to one of the following: | ||
|
||
* 0 for the interrupt-based implementation | ||
* 1 for the SYSCALL/SYSRET (fast AMD) implementation | ||
* 2 for the SYSENTER/SYSEXIT (fast Intel) implementation | ||
|
||
## Interrupt-Based Implementation | ||
|
||
A system call can be invoked by generating a software interrupt to interrupt | ||
vector 128 (80h). The argument registers are mapped as follow: | ||
A system call is invoked by setting the correct arguments in the system call | ||
registers and then generating a software interrupt to interrupt vector 128 | ||
(80h). | ||
|
||
* `arg0` maps to CPU register `eax`. | ||
* `arg1` maps to CPU register `ebx`. | ||
* `arg2` maps to CPU register `esi`. | ||
* `arg3` maps to CPU register `edi`. | ||
On return, the return values are set in the system call registers. | ||
|
||
## SYSCALL/SYSRET (Fast AMD) Implementation | ||
|
||
A system call can be invoked by executing the `SYSCALL` CPU instruction. | ||
A system call is invoked by setting the correct arguments in the system call | ||
registers and then executing the `SYSCALL` CPU instruction. | ||
|
||
* `arg0` maps to CPU register `eax`. | ||
* `arg1` maps to CPU register `ebx`. | ||
* `arg2` maps to CPU register `esi`. | ||
* `arg3` maps to CPU register `edi`. | ||
On return, the return values are set in the system call registers. | ||
|
||
This system call is not supported by all CPUs. | ||
This implementation is not supported by all CPUs. Only use this system call | ||
implementation if the `JINUE_AT_HOWSYSCALL` auxiliary vector is set to 1. | ||
|
||
## SYSENTER/SYSEXIT (Fast Intel) Implementation | ||
|
||
A system call can be invoked by executing the `SYSENTER` CPU instruction. | ||
A system call is invoked by setting the correct arguments in the system call | ||
registers and then executing the `SYSENTER` CPU instruction. | ||
|
||
* `arg0` maps to CPU register `eax`. | ||
* `arg1` maps to CPU register `ebx`. | ||
* `arg2` maps to CPU register `esi`. | ||
* `arg3` maps to CPU register `edi`. | ||
* The return address must be set in the `ecx` CPU register. | ||
* The user stack pointer must be set in the `ebp` CPU register. | ||
On return, the return values are set in the system call registers. | ||
|
||
This system call is not supported by all CPUs. | ||
This implementation is not supported by all CPUs. Only use this system call | ||
implementation if the `JINUE_AT_HOWSYSCALL` auxiliary vector is set to 2. |
Oops, something went wrong.