aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/gdt
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/gdt')
-rw-r--r--src/kernel/gdt/gdt.asm12
-rw-r--r--src/kernel/gdt/gdt.c21
-rw-r--r--src/kernel/gdt/gdt.h4
3 files changed, 15 insertions, 22 deletions
diff --git a/src/kernel/gdt/gdt.asm b/src/kernel/gdt/gdt.asm
index 6cb2b7d..51ce444 100644
--- a/src/kernel/gdt/gdt.asm
+++ b/src/kernel/gdt/gdt.asm
@@ -9,12 +9,6 @@ gdt_flush:
mov fs, ax
mov gs, ax
mov ss, ax
- jmp 0x08:flush2 ; Code segment offset
-flush2:
- ret ; Returns to C code
-
-global tss_flush
-tss_flush:
- mov ax, 0x2B
- ltr ax
- ret \ No newline at end of file
+ jmp 0x08:flush ; Code segment offset
+flush:
+ ret ; Returns to C code \ No newline at end of file
diff --git a/src/kernel/gdt/gdt.c b/src/kernel/gdt/gdt.c
index 70d5b7f..94ce06b 100644
--- a/src/kernel/gdt/gdt.c
+++ b/src/kernel/gdt/gdt.c
@@ -2,7 +2,7 @@
#include <kernel/gdt/gdt.h>
#include <kernel/system.h>
#include <kernel/lib/lib.h>
-#include <kernel/io/io.h>
+#include <mlibc/stdlib/liballoc.h>
struct gdt_entry {
unsigned short limit_low;
@@ -55,8 +55,6 @@ struct tss_entry_struct tss_entry;
extern void gdt_flush();
-extern void tss_flush();
-
void gdt_set_gate(int32_t num, uint32_t base, uint32_t limit, uint8_t access, uint8_t gran)
{
// Set descriptor base address
@@ -95,32 +93,31 @@ void gdt_install()
gdt_set_gate(4, 0, 0xFFFFFFFF, 0xF2, 0xCF);
// Write TSS
- tss_write(5, 0x10, 0x0);
+ tss_write(5, 0x10);
// Remove old GDT and install the new changes!
gdt_flush();
- tss_flush();
vga_log("Installed Global Descriptor Table", 1);
}
-void tss_write(int32_t num, uint16_t ss0, uint32_t esp0)
+void tss_write(int32_t num, uint16_t ss0)
{
uint32_t base = (uint32_t) &tss_entry;
- uint32_t limit = base + sizeof(tss_entry);
+ uint32_t limit = base + sizeof(struct tss_entry_struct);
gdt_set_gate(num, base, limit, 0xE9, 0x00);
memset(&tss_entry, 0, sizeof(tss_entry));
tss_entry.ss0 = ss0;
- tss_entry.esp0 = esp0;
-
+ tss_entry.iomap_base = sizeof(struct tss_entry_struct);
tss_entry.cs = 0x0b;
tss_entry.ss = tss_entry.ds = tss_entry.es = tss_entry.fs = tss_entry.gs = 0x13;
}
-void set_kernel_stack(uint32_t stack)
+void tss_flush(void)
{
- tss_entry.esp0 = stack;
-}
+ tss_entry.esp0 = 4096 + (uint32_t) kmalloc(4096);
+ asm volatile ("ltr %%ax": : "a" (0x2A));
+} \ No newline at end of file
diff --git a/src/kernel/gdt/gdt.h b/src/kernel/gdt/gdt.h
index 0fffc20..da36445 100644
--- a/src/kernel/gdt/gdt.h
+++ b/src/kernel/gdt/gdt.h
@@ -6,6 +6,8 @@
*/
void gdt_install();
-void tss_write(int32_t num, uint16_t ss0, uint32_t esp0);
+void tss_write(int32_t num, uint16_t ss0);
+
+void tss_flush();
#endif