feat: No more kernel page table switching upon interrupt.
[lunaix-os.git] / lunaix-os / kernel / asm / x86 / gdt.c
index 41c597e962e7b9dc02e8e37739d923bac04f3f3f..1bd1c0028a77679cbfe7a439584c3b83d7682659 100644 (file)
@@ -1,7 +1,8 @@
 #include <arch/x86/gdt.h>
+#include <arch/x86/tss.h>
 #include <stdint.h>
 
-#define GDT_ENTRY 5
+#define GDT_ENTRY 6
 
 uint64_t _gdt[GDT_ENTRY];
 uint16_t _gdt_limit = sizeof(_gdt) - 1;
@@ -12,7 +13,8 @@ void _set_gdt_entry(uint32_t index, uint32_t base, uint32_t limit, uint32_t flag
     _gdt[index] |= SEG_BASE_L(base) | SEG_LIM_L(limit);
 }
 
+extern struct x86_tss _tss;
+
 void
 _init_gdt() {
     _set_gdt_entry(0, 0, 0, 0);
@@ -20,4 +22,5 @@ _init_gdt() {
     _set_gdt_entry(2, 0, 0xfffff, SEG_R0_DATA);
     _set_gdt_entry(3, 0, 0xfffff, SEG_R3_CODE);
     _set_gdt_entry(4, 0, 0xfffff, SEG_R3_DATA);
+    _set_gdt_entry(5, &_tss, sizeof(struct x86_tss) - 1, SEG_TSS);
 }
\ No newline at end of file