|
| enum | {
} |
| | Known fixed indexes inside the GDT. More...
|
| |
|
| void | gdt_init (void) |
| | Initialize the GDTR and GDT. More...
|
| |
| void | gdt_load_segment (gdt_descriptor, u16 index) |
| | Load a segment descriptor into the Global Descriptor Table. More...
|
| |
|
void | gdt_log (void) |
| | Print the content of the GDT and GDTR.
|
| |
|
void | gdt_set_esp0 (u32) |
| | Modify the kernel stack pointer inside the current TSS.
|
| |
Global Descriptor Table
The GDT is responsible for segmenting the physical address space into different parts with different level of security each.
The segments can contain either code or data.
Each "segment" can then be accessed using a selector. These selectors are the ones stored inside the segement registers (cs, ds ..) When addressing a linear address (~physical), the processor infact dereferences an offset inside the related segment's address range.
- Warning
- This is a x86 structure only
- See also
- https://wiki.osdev.org/Global_Descriptor_Table
◆ anonymous enum
| Enumerator |
|---|
| GDT_ENTRY_KERNEL_CODE | Required NULL segment.
|
| GDT_ENTRY_KERNEL_DATA | Kernel code segment.
|
| GDT_ENTRY_USER_CODE | Kernel data segment.
|
| GDT_ENTRY_USER_DATA | User code segment.
|
| GDT_ENTRY_TSS | User data segment.
|
◆ gdt_init()
- Load the GDT's base address int GDTR
- Setup the NULL segment at offset 0
- Add our global segment descriptors (ring 0)
◆ gdt_load_segment()
- Parameters
-
| segment | The segment's content |
| index | The segment's index within the GDT. |