|
PatchworkOS
|
Global Descriptor Table. More...
Data Structures | |
| struct | gdt_desc_t |
| GDT descriptor structure. More... | |
| struct | gdt_segment_t |
| A single GDT segment descriptor. More... | |
| struct | gdt_long_system_segment_t |
| A long mode system segment descriptor, used for TSS and LDT. More... | |
| struct | gdt_t |
| The actual GDT structure. More... | |
Functions | |
| void | gdt_load_descriptor (gdt_desc_t *descriptor) |
| Loads a GDT descriptor. | |
| void | gdt_init (void) |
| Initialize the GDT. | |
| void | gdt_cpu_load (void) |
| Load the GDT on the current CPU. | |
| void | gdt_cpu_tss_load (tss_t *tss) |
Load a TSS into the GDT and load it using the ltr instruction on the current CPU. | |
Global Descriptor Table.
The global descriptor table is a legacy feature from the days of 32-bit x86 and older. Most of its features are unused, but is still required in 64-bit mode to specify the current privilage level and to load the TSS.
| enum gdt_access_t |
Access byte.
| enum gdt_flags_t |
Flags byte.
| enum gdt_ring_t |
Segment selectors.
These values are stored in the segment registers (CS, DS, ES, FS, GS, SS) to tell the CPU which segment of the GDT to use.
| void gdt_cpu_load | ( | void | ) |
Load the GDT on the current CPU.
This will load the GDT using the lgdt instruction and then reload all segment registers to use the new GDT.
Must be called after gdt_init().
Definition at line 55 of file gdt.c.
References gdt_load_descriptor(), gdt_desc_t::offset, and gdt_desc_t::size.
Referenced by cpu_init().
| void gdt_cpu_tss_load | ( | tss_t * | tss | ) |
Load a TSS into the GDT and load it using the ltr instruction on the current CPU.
Note that the actual TTS descriptor in the GDT can be shared between CPUs, as its only used while loading the TSS, after that its just useless.
| tss | The TSS to load. |
Definition at line 63 of file gdt.c.
References GDT_ACCESS_ACCESSED, GDT_ACCESS_PRESENT, GDT_ACCESS_RING0, GDT_ACCESS_SYSTEM, GDT_ACCESS_TYPE_TSS_AVAILABLE, GDT_FLAGS_NONE, gdt_long_system_segment(), and tss_load().
Referenced by cpu_init().
| void gdt_init | ( | void | ) |
Initialize the GDT.
This will setup the GDT structure in memory, but will not load it. Loading is done in gdt_cpu_load().
Definition at line 35 of file gdt.c.
References GDT_ACCESS_ACCESSED, GDT_ACCESS_DATA_CODE, GDT_ACCESS_EXEC, GDT_ACCESS_PRESENT, GDT_ACCESS_READ_WRITE, GDT_ACCESS_RING0, GDT_ACCESS_RING3, GDT_ACCESS_SYSTEM, GDT_ACCESS_TYPE_TSS_AVAILABLE, GDT_FLAGS_4KB, GDT_FLAGS_LONG_MODE, GDT_FLAGS_NONE, gdt_long_system_segment(), and gdt_segment().
Referenced by init_early().
|
extern |
Loads a GDT descriptor.
Dont use this directly use gdt_cpu_load() instead.
| descriptor | The GDT descriptor to load. |
Referenced by gdt_cpu_load().