protos: Make sure Linux and chainload protocols use the proper real mode IVT when spun up

This commit is contained in:
mintsuki 2021-03-17 19:12:31 +01:00
parent 17c184ca25
commit 2e12cc0a40
4 changed files with 19 additions and 4 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
/limine-install/limine-install
/bin
/build
/toolchain

Binary file not shown.

View File

@ -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"
);
}

View File

@ -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"
);