23 : 16, : 32, : 32, : 32, : 32, : 32, : 32, : 32, : 32, : 32, : 32, : 32,
25 : 32, : 32, : 32, : 32, : 32, : 32, : 32, : 32, : 32, : 32, : 32, : 16,
27 } __attribute__((packed))
tss_t;
38 gdt[5].ac = 1; gdt[5].rw = 0; gdt[5].dc = 0; gdt[5].ex = 1; gdt[5].dt = 0;
39 gdt[5].dpl = 3; gdt[5].pr = 1; gdt[5].sz = 1; gdt[5].gr = 0;
56 asm volatile(
"ltr %0" : :
"a" (tss_selector));
static tss_t tss
the TSS, for software multitasking we only need one
void tss_set_stack(uint32_t stack_pointer)
Sets the TSS's kernel stack which is used to handle interrupts.
void tss_init(gdt_entry_t *gdt)
Initializes the TSS.
#define GDT_RING0_DATA_SEG
kernel data segment index
uint32_t esp0
the stack pointer to load when entering the kernel
uint16_t gdt_get_selector(size_t entry)
Returns a selector ready to be loaded in a segment register.
void tss_load()
Loads the TSS into the TR register.
#define GDT_TASK_STATE_SEG
task state segment index
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.