From 5be734b1ad07f531e4b8af88644ef8dd7e03baf7 Mon Sep 17 00:00:00 2001 From: Danny Holman Date: Sun, 26 Nov 2023 18:20:12 -0600 Subject: arch: i386: gdt.c: init the TSS before loading it Perform some initialization routines on the TSS structure before loading its address. Signed-off-by: Danny Holman --- arch/i386/boot/gdt.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'arch') diff --git a/arch/i386/boot/gdt.c b/arch/i386/boot/gdt.c index 3972e53..f84c767 100644 --- a/arch/i386/boot/gdt.c +++ b/arch/i386/boot/gdt.c @@ -63,7 +63,7 @@ void gdt_set_gate(int num, uint32_t base, uint32_t limit, uint8_t access, uint8_ void write_tss(int num, uint16_t ss0, uint16_t esp0) { uint32_t base = (uint32_t)&tss_entry; - uint32_t limit = base + sizeof(tss_entry); + uint32_t limit = base + sizeof(struct tss_entry); gdt_set_gate(num, base, limit, 0xE9, 0x00); memset(&tss_entry, 0x0, sizeof(tss_entry)); @@ -88,7 +88,10 @@ void gdt_install(void) { gdt_set_gate(2, 0, 0xFFFFFFFF, 0x92, 0xCF); gdt_set_gate(3, 0, 0xFFFFFFFF, 0xFA, 0xCF); gdt_set_gate(4, 0, 0xFFFFFFFF, 0xF2, 0xCF); - write_tss(5, 0x10, 0x0); + + uint32_t esp; + __asm__ volatile("movl %%esp, %0" : "=r"(esp)); + write_tss(5, 0x10, esp); flush_gdt(); flush_tss(); -- cgit v1.2.3