First commit, Vystem v0.1
This commit is contained in:
13
docs/shelter/cpu/asmint.md
Normal file
13
docs/shelter/cpu/asmint.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# ASM instructions
|
||||
|
||||
## Introduction
|
||||
|
||||
While the Shelter kernel is made in C, somes basic CPU functions require using ASM instructions. For that, we define wrappers that can be used anywhere in the kernel. These wrappers are defined inside the header file `shelter/lib/include/cpu/asm.h` which act as the only place in the entire kernel where the `__asm__` should be used. The subsystem prefix is `sh_asm_`.
|
||||
|
||||
## Overview
|
||||
|
||||
Here is a list of all the wrappers available. They are all defined as `static inline` function:
|
||||
- `inb`: take a `sh_uint16` in input for specifying the port and return the inputed byte
|
||||
- `outb`: take a `sh_uint16` for specifying the port and a `sh_uint8` for specifying the byte to output
|
||||
- `rdtsc`: take no arguments and return the current TSC as a `sh_uint64`
|
||||
- `invlpg`: take a `void *` as an address and return nothing
|
||||
11
docs/shelter/cpu/cpuabstract.md
Normal file
11
docs/shelter/cpu/cpuabstract.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# CPU Abstraction
|
||||
|
||||
## Introduction
|
||||
|
||||
This component of the Shelter kernel allow for basic CPU functions abstractions, like ASM instruction, serial output and TSC utilities.
|
||||
|
||||
## Summary
|
||||
|
||||
1) [ASM instructions](asmint.md)
|
||||
2) [Serial outputing API](serial.md)
|
||||
3) [TSC API](tsc.md)
|
||||
12
docs/shelter/cpu/serial.md
Normal file
12
docs/shelter/cpu/serial.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# Serial outputing API
|
||||
|
||||
## Introduction
|
||||
|
||||
Shelter provide an abstraction around the serial port for outputing on it. This should act as the central point for outputing on the serial. The API is defined in `shelter/lib/include/cpu/serial.h` and implemented in `shelter/lib/src/cpu/serial.c`. This API obey the `serial_port_disabled` killswitch defined in kernel boot configuration. The subsystem prefix is `sh_serial_`.
|
||||
|
||||
## Overview
|
||||
|
||||
The API define the following elements:
|
||||
- `sh_serial_load_serial_port_setting`: should be used only once at the start of the boot process to load the serial port setting using the argument `is_disabled` which is a `sh_bool`
|
||||
- `sh_serial_send_byte`: safely (wait for previous byte to finish being send) send a byte to the serial port
|
||||
The default and only serial port available is COM1.
|
||||
20
docs/shelter/cpu/tsc.md
Normal file
20
docs/shelter/cpu/tsc.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# TSC API
|
||||
|
||||
## Introduction
|
||||
|
||||
In order to be able to measure and approximate time as soon as the kernel start the boot process, the TSC API is implemented in a volontary minimal way. The TSC API is defined inside `shelter/lib/include/cpu/tsc.h` and implemented inside `shelter/lib/src/cpu/tsc.c`. The API prefix is `sh_tsc_`.
|
||||
|
||||
## Overview
|
||||
|
||||
The TSC API being intented for measuring time during the boot process, the provided features are extremely basic. In order for any TSC value to start at 0, we define two concept:
|
||||
- `kernel_init_tsc`: a TSC value initialized at the very start of the kernel boot process
|
||||
- `kernel_current_tsc`: a TSC value which is the result of `kernel_init_tsc` substracted to the value returned by `sh_asm_rdtsc()`
|
||||
|
||||
## API content
|
||||
|
||||
The API define the following elements:
|
||||
- `sh_tsc_TSC_VALUE`: a value of the TSC register, which is a wrapper of a `sh_uint64`
|
||||
- `sh_tsc_read_value()`: an inline function reading the TSC register using `sh_asm_rdtsc()`, return a `sh_tsc_TSC_VALUE`
|
||||
- `sh_tsc_init_tsc()`: a function initializing `kernel_init_tsc`. This function should only be called once as soon as the kernel start. Return a `SH_STATUS`
|
||||
- `sh_tsc_get_kernel_init_tsc()`: return `kernel_init_tsc` under a `sh_tsc_TSC_VALUE`
|
||||
- `sh_tsc_get_kernel_current_tsc()`: return the result of `sh_asm_rdtsc()` less `kernel_init_tsc`, under a `sh_tsc_TSC_VALUE`
|
||||
Reference in New Issue
Block a user