diff options
author | dzwdz | 2021-07-10 16:17:07 +0200 |
---|---|---|
committer | dzwdz | 2021-07-10 16:17:07 +0200 |
commit | 1cc98d32bf344691c73fcc7b64e2ed2755f17ede (patch) | |
tree | e79afa2f1b6d24e9fe9be6280276a6134ea099f6 /kernel/gdt.c | |
parent | 3fe1cfd4518ab8ace87d08796fe2f38d66598a1d (diff) |
update all segment registers when setting the GDT
not doing that caused interrupts to break on Bochs
Diffstat (limited to 'kernel/gdt.c')
-rw-r--r-- | kernel/gdt.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/kernel/gdt.c b/kernel/gdt.c index b76e441..b0d6320 100644 --- a/kernel/gdt.c +++ b/kernel/gdt.c @@ -43,7 +43,6 @@ static struct lgdt_arg lgdt_arg; // probably doesn't need to be global static void gdt_prepare(); static void gdt_load(); -static void gdt_check(); static void gdt_prepare() { @@ -96,23 +95,27 @@ static void gdt_prepare() { GDT[SEG_TSS].base_high = (((uint32_t) &TSS) >> 24) & 0xff; } +void change_cs(int seg); // temporary + static void gdt_load() { lgdt_arg.limit = sizeof(GDT) - 1; lgdt_arg.base = (uint32_t) &GDT; - asm("lgdt (%0)" : : "r" (&lgdt_arg) : "memory"); - - asm("ltr %%ax" : : "a" (SEG_TSS << 3 | 3) : "memory"); -} + asm("lgdt (%0)" + : : "r" (&lgdt_arg) : "memory"); + asm("ltr %%ax" + : : "a" (SEG_TSS << 3 | 3) : "memory"); -static void gdt_check() { - // note: this only checks the r0data segment, - // it's far from a comprehensive test + // update all segment registers + change_cs(SEG_r0code << 3); asm("mov %0, %%ds;" + "mov %0, %%ss;" + "mov %0, %%es;" + "mov %0, %%fs;" + "mov %0, %%gs;" : : "r" (SEG_r0data << 3) : "memory"); } void gdt_init() { gdt_prepare(); gdt_load(); - gdt_check(); } |