aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kernel/drivers/gdt.c9
-rw-r--r--kernel/drivers/interrupts.c3
-rw-r--r--kernel/features/proc.c4
-rw-r--r--kernel/inc/gdt.h2
4 files changed, 7 insertions, 11 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)
diff --git a/kernel/features/proc.c b/kernel/features/proc.c
index 3039231..3dd8114 100644
--- a/kernel/features/proc.c
+++ b/kernel/features/proc.c
@@ -54,7 +54,7 @@ HOT FLATTEN void scheduler(struct regs *regs)
current = idle_proc;
}
- tss_set_stack(GDT_SUPER_DATA_OFFSET, PROC(current)->stack.kernel);
+ tss_set_stack(PROC(current)->stack.kernel);
memory_switch_dir(PROC(current)->page_dir);
memcpy(regs, &PROC(current)->regs, sizeof(*regs));
@@ -369,7 +369,7 @@ NORETURN void proc_init(void)
// We'll shortly jump to usermode. Clear and protect every secret!
memory_user_hook();
- tss_set_stack(GDT_SUPER_DATA_OFFSET, init->stack.kernel);
+ tss_set_stack(init->stack.kernel);
memory_switch_dir(init->page_dir);
printf("Jumping to userspace!\n");
diff --git a/kernel/inc/gdt.h b/kernel/inc/gdt.h
index 9de0ad3..7b9c65a 100644
--- a/kernel/inc/gdt.h
+++ b/kernel/inc/gdt.h
@@ -63,6 +63,6 @@ struct tss_entry {
CONST u8 gdt_offset(u8 gate);
void gdt_install(u32 esp);
-void tss_set_stack(u32 ss, u32 esp);
+void tss_set_stack(u32 esp);
#endif