27 } __attribute__((packed))
gdtr_t;
36 } __attribute__((packed)) bits;
59 gdtr_t gdtr = {.base = (uint32_t)
gdt, .limit =
sizeof(
gdt) - 1};
60 asm volatile(
"lgdt %0" : :
"m" (gdtr));
73 print(
"GDT init ... ");
105 return (uint16_t) selector.
word;
#define GDT_RING3_DATA_SEG
user data segment index
uint8_t dpl
Descriptor privilege level.
uint8_t dc
direction / conforming
the GDTR register pointing to the GDT
uint8_t dt
descriptor type
#define GDT_ENTRIES
number of entries in the GDT
void gdt_init()
Initializes the GDT.
void tss_init(gdt_entry_t *gdt)
Initializes the TSS.
#define GDT_RING3_CODE_SEG
user code segment index
#define GDT_RING0_DATA_SEG
kernel data segment index
uint8_t base24_31
where the segment begins (byte 4)
uint16_t dpl
DPL needed to access this memory segment.
struct gdt_selector_t::@9 bits
bit field
uint32_t base0_23
where the segment begins (byte 1-3)
uint16_t gdt_get_selector(size_t entry)
Returns a selector ready to be loaded in a segment register.
uint32_t base
where the GDT is located
uint8_t reserved
always 0 (long mode & available)
void tss_load()
Loads the TSS into the TR register.
void gdt_flush()
Loads the kernel code and data segments into the segment registers.
static void gdt_load()
Loads the GDT into the GDTR register.
uint8_t rw
read / write allowed
uint16_t word
useful for casting
uint8_t limit16_19
maximum offset allowed (last nibble)
static idt_entry_t idt[IDT_ENTRIES]
The IDT itself.
static gdt_entry_t gdt[GDT_ENTRIES]
The GDT itself. It is located inside the kernel.
void gdt_init_entry(size_t entry, uint32_t base, uint32_t limit)
Sets basic parameters of a GDT entry.
uint16_t limit
number of entries in the GDT
uint16_t limit0_15
maximum offset allowed (byte 1-2)
#define GDT_RING0_CODE_SEG
kernel code segment index