diff options
author | Marvin Borner | 2021-05-03 14:25:39 +0200 |
---|---|---|
committer | Marvin Borner | 2021-05-03 14:25:39 +0200 |
commit | c00e76f35e78329c0aa01e90a7766b457dcc4e66 (patch) | |
tree | 7d15be0a3e5abe06c28493820d1338c2e8888213 /kernel/drivers | |
parent | 975dc11bbf2edfd7f30f98c17f593058368a30c0 (diff) |
Fixed TSS
Diffstat (limited to 'kernel/drivers')
-rw-r--r-- | kernel/drivers/gdt.c | 9 | ||||
-rw-r--r-- | kernel/drivers/interrupts.c | 3 |
2 files changed, 4 insertions, 8 deletions
diff --git a/kernel/drivers/gdt.c b/kernel/drivers/gdt.c index 3e7da94..0e8086f 100644 --- a/kernel/drivers/gdt.c +++ b/kernel/drivers/gdt.c @@ -41,11 +41,10 @@ CLEAR static void gdt_set_gate(u32 num, u32 base, u32 limit, u8 access, u8 gran) gdt[num].access = access; } -// TODO: Fix GPF for in/out operations in userspace (not necessarily a TSS problem) CLEAR static void tss_write(u32 num, u16 ss0, u32 esp0) { u32 base = (u32)&tss; - u32 limit = base + sizeof(tss); + u32 limit = sizeof(tss) - 1; gdt_set_gate(num, base, limit, GDT_PRESENT | GDT_RING3 | GDT_EXECUTABLE | GDT_ACCESSED, GDT_SIZE); @@ -56,7 +55,7 @@ CLEAR static void tss_write(u32 num, u16 ss0, u32 esp0) tss.esp0 = esp0; tss.cs = GDT_SUPER_CODE_OFFSET | 3; tss.ss = tss.ds = tss.es = tss.fs = tss.gs = GDT_SUPER_DATA_OFFSET | 3; - tss.iomap_base = U16_MAX; + tss.iomap_base = sizeof(tss); } CLEAR static void tss_flush(void) @@ -69,11 +68,9 @@ CLEAR static void gdt_flush(void) __asm__ volatile("lgdt %0" ::"m"(gp) : "memory"); } -void tss_set_stack(u32 ss, u32 esp) +void tss_set_stack(u32 esp) { - assert(ss && esp); tss.esp0 = esp; - tss.ss0 = ss; } CLEAR void gdt_install(u32 esp) diff --git a/kernel/drivers/interrupts.c b/kernel/drivers/interrupts.c index 7a57a91..92971e4 100644 --- a/kernel/drivers/interrupts.c +++ b/kernel/drivers/interrupts.c @@ -15,8 +15,7 @@ * IDT */ -// TODO: Why does PROTECTED on idt only work when debug mode is disabled? File size? -static struct idt_entry idt[256] = { 0 }; +PROTECTED static struct idt_entry idt[256] = { 0 }; PROTECTED static struct idt_ptr idt_ptr = { 0 }; CLEAR void idt_set_gate(u8 num, u32 base, u16 sel, u8 flags) |