From d173f81cd6c91a80f46fd1f34922a9155adebcdf Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Wed, 13 Apr 2022 12:14:36 +0200 Subject: [PATCH] Minor refactor --- bootloader/bios/memory.asm | 40 ++++++++++++++++++++------------------ bootloader/bootloader.asm | 14 ++++++------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/bootloader/bios/memory.asm b/bootloader/bios/memory.asm index 4f41588..0d96434 100644 --- a/bootloader/bios/memory.asm +++ b/bootloader/bios/memory.asm @@ -1,19 +1,19 @@ ; SRs to find memory size and leave it as a "note" for the kernel -mmap_probe: ; literally just test the memory boundaries - push eax - push ebx - push edx - push ebp - - mov ebp, esi - add esi, 0x00000ff - and esi, ~0x00000ff -mmap_probe_addr: - -mmap_probe_done: - -mmap_e820: +; mmap_probe: ; literally just test the memory boundaries +; push eax +; push ebx +; push edx +; push ebp +; +; mov ebp, esi +; add esi, 0x00000ff +; and esi, ~0x00000ff +; mmap_probe_addr: +; +; mmap_probe_done: + +e820: mov di, 0x8004 mov ebx, 0 ; Must be 0 mov bp, 0 ; entry count @@ -27,15 +27,17 @@ mmap_e820: int 0x15 ; Do the interupt ; carry flag = (un)supported function - jc mmap_e820_fail ; Try probing instead + jc e820_fail ; Try probing instead cmp eax, edx ; eax should be = 'SMAP' - jne mmap_e820_fail ; if not then fail + jne e820_fail ; if not then fail + + test ebx, ebx ; no entries + je e820_fail + - test ebx, ebx - je mmap_e820_fail -mmap_e820_fail: +e820_fail: stc ret diff --git a/bootloader/bootloader.asm b/bootloader/bootloader.asm index 91112b7..35a05c3 100644 --- a/bootloader/bootloader.asm +++ b/bootloader/bootloader.asm @@ -35,15 +35,15 @@ ; Switching to PM [bits 16] pm_preinit: - call mmap_e820 ; Map the physical memory - - cli ; Switch interupts + ; Do stats before mode switch + call e820 ; Map the physical memory + ; PM prep stuff + cli ; Switch interupts lgdt [gdt_descriptor] ; Tell the CPU about the GDT - - mov eax, cr0 ; Set first bit of the CR0 register - or eax, 0x1 ; to 1 - mov cr0, eax ; Update the control register + mov eax, cr0 ; Set first bit of the CR0 register + or eax, 0x1 ; to 1 + mov cr0, eax ; Update the control register ; Initialize PM jmp GDT_CODE_SEG:pm_init