From 8f0a20faa06dd89d04ea5af91addb142cc06a495 Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Sun, 20 Mar 2022 16:09:08 +0100 Subject: [PATCH] 0xe820 stuff (WIP) --- bootloader/bios/memory.asm | 51 +++++++++++++++++++++++--------------- bootloader/bootloader.asm | 2 +- bootloader/equ/bios.asm | 3 --- 3 files changed, 32 insertions(+), 24 deletions(-) diff --git a/bootloader/bios/memory.asm b/bootloader/bios/memory.asm index b6a2efb..fe2cb6a 100644 --- a/bootloader/bios/memory.asm +++ b/bootloader/bios/memory.asm @@ -1,25 +1,36 @@ ; SRs to find memory size and leave it as a "note" for the kernel -; Descriptor Table for address ranges -map_phys_mem_init: - mov ebx, 0 -map_phys_mem: - mov eax, 0xE820 ; Function code - ; Tell the CPU about the descriptors location (ES:DI) - ;mov es, addr_rng_dt_start - ;mov di, - mov ecx, ADDR_RNG_DT_SIZE - mov edx, 'SMAP' ; Signature - int BIOS_PMEM_INT - ret +mmap_e820: + mov di, 0x8004 + mov ebx, 0 ; Must be 0 + mov bp, 0 ; entry count + + mov eax, 0xe820 ; function reg + mov edx, 'SMAP' + + mov [es:di + 20], dword 1 ; fill + mov ecx, 24 ; ask for 24 bytes + int 0x15 ; Do the interupt + + ; carry flag = (un)supported function + jc short mmap_fail -addr_rng_dt_start: - addr_rng_low: dd 0 - addr_rng_high: dd 0 - addr_rng_len_low: dd 0 - addr_rng_len_high: dd 0 - addr_rng_type: dd 0 -addr_rng_dt_end: + ; TODO more error stuff + cmp eax, edx + jne short mmap_fail + + test ebx, ebx + je short mmap_fail + +mmap_fail: + stc + ret +e820_dt_start: + e820_low: dd 0 + e820_high: dd 0 + e820_len_low: dd 0 + e820_len_high: dd 0 + e820_type: dd 0 +e820_dt_end: -ADDR_RNG_DT_SIZE equ addr_rng_dt_end - addr_rng_dt_start diff --git a/bootloader/bootloader.asm b/bootloader/bootloader.asm index 7f4d456..e602ce6 100644 --- a/bootloader/bootloader.asm +++ b/bootloader/bootloader.asm @@ -5,7 +5,7 @@ mov [BOOT_DRIVE], dl ; Move the stack pointer somewhere safe - mov bp, 0x9000 ; move it to 0x8000 + mov bp, 0x9000 ; move it to 0x9000 mov sp, bp ; Load kernel into memory diff --git a/bootloader/equ/bios.asm b/bootloader/equ/bios.asm index d8352a9..7b24bdc 100644 --- a/bootloader/equ/bios.asm +++ b/bootloader/equ/bios.asm @@ -6,6 +6,3 @@ BIOS_TTY_MODE equ 0x0e BIOS_DISK_INT equ 0x13 BIOS_DISK_READ equ 0x02 -; Physical Memory -BIOS_PMEM_INT equ 0x15 -