docs: documented GDT changes

This commit is contained in:
antifallobst 2023-03-05 15:57:56 +01:00
parent e078840aef
commit 990a74798c
1 changed files with 37 additions and 1 deletions

View File

@ -1068,8 +1068,44 @@ OSDev Wiki: [Global Descriptor Table](https://wiki.osdev.org/GDT)
- **Null** - **Null**
- **Kernel Code** - Readable - **Kernel Code** - Readable
- **Kernel Data** - Readable + Writable - **Kernel Data** - Readable + Writable
- **User Null**
- **User Code** - Readable
- **User Data** - Readable + Writable
NoxOS uses the GDT loaded by limine, because in 64 bit mode a GDT is only needed for backwards compatability. #### `gdt_descriptor_T` - struct [packed]
| Name | Type | Description |
|--------|----------|-----------------------------------------------------|
| size | uint16_t | The tables size in bytes (-1) |
| offset | uint64_t | The virtual address, where the table lies in memory |
#### `gdt_entry_T` - struct [packed]
| Name | Type | Description |
|--------------|----------|--------------------------------------------------------------|
| limit0 | uint16_t | Can be ignored in long mode |
| base0 | uint16_t | Can be ignored in long mode |
| base1 | uint8_t | Can be ignored in long mode |
| access | uint8_t | Specifies permissions (details in osdev wiki) |
| limit1_flags | uint8_t | The first 4 bits can be ignored and the last 4 specify flags |
| base2 | uint8_t | Can be ignored in long mode |
#### `gdt_T` - struct [packed / page aligned]
| Name | Type | Description |
|-------------|-------------|------------------------------------------|
| null | gdt_entry_T | The entry for `GDT_SELECTOR_NULL` |
| kernel_code | gdt_entry_T | The entry for `GDT_SELECTOR_KERNEL_CODE` |
| kernel_data | gdt_entry_T | The entry for `GDT_SELECTOR_KERNEL_DATA` |
| user_null | gdt_entry_T | The entry for `GDT_SELECTOR_USER_NULL` |
| user_code | gdt_entry_T | The entry for `GDT_SELECTOR_USER_CODE` |
| user_data | gdt_entry_T | The entry for `GDT_SELECTOR_USER_DATA` |
#### `g_default_gdt` - global variable
The systems GDT.
#### `gdt_init` - function (void)
Populates and loads `g_default_gdt`.
This will also set all the data segment registers to 0x10 (Kernel Data) and `cs` to 0x08 (Kernel Code).
### interrupts.h ### interrupts.h
This header contains all the stuff, needed to init and handle Interrupts. This header contains all the stuff, needed to init and handle Interrupts.