protos: Make sure Linux and chainload protocols use the proper real mode IVT when spun up
diff --git a/.gitignore b/.gitignore
index 3f12c304..fabd02f4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+/limine-install/limine-install
/bin
/build
/toolchain
diff --git a/limine-install/limine-install b/limine-install/limine-install
deleted file mode 100755
index ba6be7cf..00000000
Binary files a/limine-install/limine-install and /dev/null differ
diff --git a/stage23/protos/chainload.c b/stage23/protos/chainload.c
index 5663f9e1..6e934d7a 100644
--- a/stage23/protos/chainload.c
+++ b/stage23/protos/chainload.c
@@ -9,12 +9,19 @@
#include <drivers/disk.h>
#include <lib/term.h>
#include <mm/mtrr.h>
+#include <sys/idt.h>
-__attribute__((section(".realmode"), used))
+__attribute__((noinline))
+__attribute__((section(".realmode")))
static void spinup(uint8_t drive) {
+ struct idtr real_mode_idt = { 0x3ff, 0x0 };
+
asm volatile (
+ "cli\n\t"
"cld\n\t"
+ "lidt [eax]\n\t"
+
"jmp 0x08:1f\n\t"
"1: .code16\n\t"
"mov ax, 0x10\n\t"
@@ -46,7 +53,7 @@ static void spinup(uint8_t drive) {
".code32\n\t"
:
- : "d" (drive)
+ : "a" (&real_mode_idt), "d" (drive)
: "memory"
);
}
diff --git a/stage23/protos/linux.c b/stage23/protos/linux.c
index a54a7672..01dff929 100644
--- a/stage23/protos/linux.c
+++ b/stage23/protos/linux.c
@@ -13,16 +13,23 @@
#include <lib/uri.h>
#include <mm/pmm.h>
#include <mm/mtrr.h>
+#include <sys/idt.h>
#define KERNEL_LOAD_ADDR ((size_t)0x100000)
#define KERNEL_HEAP_SIZE ((size_t)0x6000)
-__attribute__((section(".realmode"), used))
+__attribute__((noinline))
+__attribute__((section(".realmode")))
static void spinup(uint16_t real_mode_code_seg, uint16_t kernel_entry_seg,
uint16_t stack_pointer) {
+ struct idtr real_mode_idt = { 0x3ff, 0x0 };
+
asm volatile (
+ "cli\n\t"
"cld\n\t"
+ "lidt [eax]\n\t"
+
"jmp 0x08:1f\n\t"
"1: .code16\n\t"
"mov ax, 0x10\n\t"
@@ -53,7 +60,7 @@ static void spinup(uint16_t real_mode_code_seg, uint16_t kernel_entry_seg,
".code32\n\t"
:
- : "b" (real_mode_code_seg), "c" (kernel_entry_seg),
+ : "a" (&real_mode_idt), "b" (real_mode_code_seg), "c" (kernel_entry_seg),
"d" (stack_pointer)
: "memory"
);
