From 703a5fc067b7889a2aa39242113ff9a26297932f Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Tue, 5 Mar 2019 20:40:34 +0100 Subject: [PATCH] LONG MODE MULTIBOOT WORKS gsp! --- boot/loader/loader.asm | 1 + boot/loader/mem/management.inc | 7 +++++++ boot/loader/mem/structures.inc | 4 ++-- build/obj/boot/loader.bin | Bin 12649 -> 20612 bytes 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/boot/loader/loader.asm b/boot/loader/loader.asm index 09b565b..2040668 100644 --- a/boot/loader/loader.asm +++ b/boot/loader/loader.asm @@ -108,6 +108,7 @@ lnext: %include "boot/loader/mem/structures.inc" lnext2: call Setup_paging + call Go64 jmp lnext3 %include "boot/loader/mem/management.inc" diff --git a/boot/loader/mem/management.inc b/boot/loader/mem/management.inc index 3634666..48ff4cc 100644 --- a/boot/loader/mem/management.inc +++ b/boot/loader/mem/management.inc @@ -57,6 +57,8 @@ Setup_paging: ; Enable long mode and paging ; ; ---------------------------------------------------------------------------- ; Go64: + pusha + ;; Registering paging mov eax, PML4_table mov cr3, eax ; Load PML4 to cr3 @@ -78,5 +80,10 @@ Go64: ; | ; `------ Paging bit mov cr0, eax + jmp .end + nop + nop +.end: + popa ret diff --git a/boot/loader/mem/structures.inc b/boot/loader/mem/structures.inc index 31e98b4..4947b9d 100644 --- a/boot/loader/mem/structures.inc +++ b/boot/loader/mem/structures.inc @@ -26,7 +26,7 @@ [BITS 32] ;; GDT WITH DOC -ALIGN 4 +ALIGN 4096 GDT64: NULL_SELECTOR: ;; null selector within 64 bits dw GDT_LENGTH ; limit of GDT @@ -104,7 +104,7 @@ GDT64: GDT_LENGTH: ;; EMPTY PAGE TABLES (identity of the first 1GiB) -ALIGN 4 +ALIGN 4096 PML4_table: resb 4096 PDP_table: diff --git a/build/obj/boot/loader.bin b/build/obj/boot/loader.bin index faf31098a145ef011cb83636a3ffd826bcb67367..1b1f11896fe51199cc124b80b5c4c94d9415d1f8 100644 GIT binary patch literal 20612 zcmeI)&ntvM7{Kvo7ZGinQ~G>c|EUn^aoJiIm|rsyzk7s@8>p`XMQ8xyxFXI*H2556_NDOL1&Ys zNPKM}FAAeD*f(rMJA`Qmw->$+%>LWhj`Q~pIuvqn??phj&PS>O8A zb`6}ozqn7AS$oqXx>r;6BhQ7=a~#KRFwlJpraF|;VL2NlgQ>orY1Xdji+Q)VJ5xIC zPmZ3b?9NP92EruY=hmZp-5@&A?lJF+lxYYcfB*srAb1#1Tyk7(d2RR7h0vy%IjUGsBx+JGI>6__9khO)rb0QkSsE}8)I*a op*6YN{ETO8Eu-rSCRcOma(S-aC>iMYj`!BT05voAUH||9 delta 140 zcmZo!$oMj8!YNfH0|tf(6Fx9pU;u&t|AEA;^ALJcKa{_IGo!+PeGdkP7fe9u*XcVx z2naAVpI~16fkA*_#|H%{2Pn7`WXKK%1_g%i4|$t`>`s=mAbH2epA0~~rB4p;_`opP UCqSL&@Nrg#25ts_eQ*840IWnXGXMYp