diff options
author | Danny Holman <dholman@gymli.org> | 2023-11-26 18:20:12 -0600 |
---|---|---|
committer | Danny Holman <dholman@gymli.org> | 2023-11-26 18:20:12 -0600 |
commit | 5be734b1ad07f531e4b8af88644ef8dd7e03baf7 (patch) | |
tree | 9aabe2a16d6c49bdb05e31be9204c4b950c5f078 | |
parent | f63f92582552af06d8ad7bc4ccd235e51ad651b7 (diff) |
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 <dholman@gymli.org>
-rw-r--r-- | arch/i386/boot/gdt.c | 7 |
1 files changed, 5 insertions, 2 deletions
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(); |