From d8a43e068895fb6e858377ea9c79aaa3e920476e Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Tue, 12 Feb 2019 14:58:26 +0100 Subject: [PATCH] multiboot stuff '-' --- boot/loader/loader.asm | 46 +++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/boot/loader/loader.asm b/boot/loader/loader.asm index 6734aec..583e121 100644 --- a/boot/loader/loader.asm +++ b/boot/loader/loader.asm @@ -25,16 +25,40 @@ %define DEBUG -[BITS 16] -[ORG 0x1000] +[BITS 32] +[global _start] +[ORG 0x100000] ; Where GRUB loads us. -mov ax, cs ; correcting cs after the horrible far jump -mov ds, ax ; hm... And ds too -mov es, ax ; And es because it is jealous +%include "boot/loader/multiboot.inc" -mov [Bootdrv], dl -xor dl, dl -jmp 0x0000:main +_start: + mov ax, cs ; correcting cs after the horrible far jump + mov ds, ax ; hm... And ds too + mov es, ax ; And es because it is jealous + + mov [Bootdrv], dl + xor dl, dl + jmp 0x0000:main ;; pas sûr + +[align 4] +dd MULTIBOOT_HEADER_MAGIC +dd MULTIBOOT_HEADER_FLAGS +dd CHECKSUM +dd multiboot_header ; Header address +dd _start ; Address of code entry point +dd 00 ; (end of code) not necessary +dd 00 ; (bss) not necessary +dd MB_start ; entry address GRUB will start at + +MB_start: + mov esp, KERNEL_STACK ; Setup the stack + push 0 ; Reset EFLAGS + popf + push eax ; 2nd argument is magic number + push ebx ; 1st argument multiboot info pointer + call main + add esp, 8 ; Cleanup 8 bytes pushed as arguments + jmp Die %include "boot/loader/cpu/cpuid.asm" %include "boot/loader/io/rmterm.asm" @@ -42,6 +66,8 @@ jmp 0x0000:main main: + ;; XXX NEED TO SWITCH TO RM HERE ;; + ;; compatibility check push si mov si, Init @@ -92,10 +118,6 @@ main: push dword [VGA_HEIGHT] jmp (CODE_SELECTOR-GDT64):main32 -;; THE HOLE ----------------------------------------------------------------- ;; -ErrorNo64: - mov si, NoLongMode - call PrintB Die: cli hlt ; die nooooow