From 7e55005dda411b5adafb985e485e3756969f6ac0 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sun, 2 May 2021 14:29:12 +0200 Subject: Some GDT improvements (attempts to fix no I/O GPF) --- kernel/inc/gdt.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'kernel/inc') diff --git a/kernel/inc/gdt.h b/kernel/inc/gdt.h index 9a9fd01..20261f3 100644 --- a/kernel/inc/gdt.h +++ b/kernel/inc/gdt.h @@ -5,10 +5,17 @@ #include -#define GDT_SUPER_CODE_OFFSET 0x08 // Super (kernel) code segment offset in GDT -#define GDT_SUPER_DATA_OFFSET 0x10 // Super (kernel) data segment offset in GDT -#define GDT_USER_CODE_OFFSET 0x1b // User code segment offset in GDT (with ring3 mask) -#define GDT_USER_DATA_OFFSET 0x23 // User data segment offset in GDT (with ring3 mask) +#define GDT_ROOT_CODE_GATE 1 +#define GDT_ROOT_DATA_GATE 2 +#define GDT_USER_CODE_GATE 3 +#define GDT_USER_DATA_GATE 4 +#define GDT_TSS_GATE 5 + +#define GDT_SUPER_CODE_OFFSET (gdt_offset(GDT_ROOT_CODE_GATE)) +#define GDT_SUPER_DATA_OFFSET (gdt_offset(GDT_ROOT_DATA_GATE)) +#define GDT_USER_CODE_OFFSET (gdt_offset(GDT_USER_CODE_GATE) | 3) +#define GDT_USER_DATA_OFFSET (gdt_offset(GDT_USER_DATA_GATE) | 3) +#define GDT_TSS_OFFSET (gdt_offset(GDT_TSS_GATE)) struct gdt_entry { u16 limit_low; @@ -54,6 +61,7 @@ struct tss_entry { u16 iomap_base; } PACKED; +u8 gdt_offset(u8 gate); void gdt_install(u32 esp); void tss_set_stack(u32 ss, u32 esp); -- cgit v1.2.3