From 70b5c0690e66e52169944d8f51d8413be47b17d4 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Tue, 5 Mar 2019 19:11:35 +0100 Subject: [PATCH] stuff --- Makefile | 2 +- boot/loader/loader.asm | 23 ++++++++++++++++++++++- build/obj/boot/loader.bin | Bin 12647 -> 12644 bytes 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 052f64c..49bb50e 100644 --- a/Makefile +++ b/Makefile @@ -84,7 +84,7 @@ make_disk: @echo ${CL2}[make_disk]${CL} OK${CL3} testloader: loader - @qemu-system-x86_64 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall -s -S -enable-kvm 2> qemu.log & + @qemu-system-x86_64 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -s -S -enable-kvm 2> qemu.log & @ndisasm $(OBJDIR)/boot/loader.bin -b 32 > loader_dism.asm diff --git a/boot/loader/loader.asm b/boot/loader/loader.asm index 1fb8f51..586d18e 100644 --- a/boot/loader/loader.asm +++ b/boot/loader/loader.asm @@ -86,7 +86,28 @@ main: call Is64Bits call Setup_paging - call Go64 + + ;; Registering paging + mov eax, PML4_table + mov cr3, eax ; Load PML4 to cr3 + + mov eax, cr4 + or eax, 1 << 5 + mov cr4, eax ; Enable PAE + + ;; Activate long mode + mov ecx, 0xC0000080 ; address of MSR + rdmsr ; read MSR + or eax, 1 << 8 ; LME = 1. (Long Mode Enable) + wrmsr ; write MSR + + ;; Enable paging + mov eax, cr0 + or eax, 1 << 31 ; make MSR bit 31 (PG = Paging) to 1 : + ; |1|000000000000000000000000000000 + ; | + ; `------ Paging bit + mov cr0, eax mov dword [0xb8000], 0x2f4b2f4f ret diff --git a/build/obj/boot/loader.bin b/build/obj/boot/loader.bin index 8721f45ff79db257469fd909defc93f881d3203e..182a3e209f7fadaa2e907c05e87f344e1c0f846e 100644 GIT binary patch delta 152 zcmaE!^dxCQfoKZ@1H+3H5Mc!(mKrcH?9iBOXQ(l;L)+wK=Kufy=R|ZKG-Y5=Ux?+W;dt+ delta 119 zcmaEo^gL-ofkX@g1H%g&5FrX8Y7KzI79cTktv1u^i4*UNOO*Zp|G)7k(}uO$rHqF+ z7`#ja@);N(Fl^>wlr<1z5ENi&KEb@0fl+{A2ZJJ%GuhryTmZy#Z2ZZ<#K2Jc