static gdt_long_system_segment_t gdt_long_system_segment(gdt_access_t access, gdt_flags_t flags, uint64_t base, uint32_t limit)
static gdt_segment_t gdt_segment(gdt_access_t access, gdt_flags_t flags)
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.
void gdt_init(void)
Initialize the GDT.
void gdt_load_descriptor(gdt_desc_t *descriptor)
Loads a GDT descriptor.
void gdt_cpu_load(void)
Load the GDT on the current CPU.
@ GDT_FLAGS_4KB
If set, the limit is in 4KiB blocks. If clear, the limit is in bytes.
@ GDT_FLAGS_NONE
No flags set.
@ GDT_FLAGS_LONG_MODE
If set, its a 64-bit code segment.
@ GDT_ACCESS_RING0
Descriptor Privilege Level 0 (kernel).
@ GDT_ACCESS_ACCESSED
Will be set to 1 when accessed, but its best to set it to 1 manually.
@ GDT_ACCESS_EXEC
If set, the segment is a code segment. If clear, its a data segment.
@ GDT_ACCESS_SYSTEM
Is a system segment.
@ GDT_ACCESS_READ_WRITE
If set on a code segment, its readable. If set on a data segment, its writable.
@ GDT_ACCESS_PRESENT
Must be 1 for all valid segments.
@ GDT_ACCESS_DATA_CODE
Is a data or code segment.
@ GDT_ACCESS_RING3
Descriptor Privilege Level 3 (user).
@ GDT_ACCESS_TYPE_TSS_AVAILABLE
Available 64-bit Task State Segment. Only used if the SYSTEM bit is 0.
void tss_load(void)
Load the TSS.
#define ALIGNED(alignment)
GCC aligned attribute.
#define PAGE_SIZE
Memory page size.
GDT descriptor structure.
uint64_t offset
Address of the GDT.
uint16_t size
Size of the GDT - 1.
A long mode system segment descriptor, used for TSS and LDT.
uint8_t flagsAndLimitHigh
A single GDT segment descriptor.
uint8_t flagsAndLimitHigh
The actual GDT structure.
Task State Segment structure.