From: David Devecsery Date: Mon, 18 May 2020 15:59:06 +0000 (-0400) Subject: Added very minimal e820 support to the bootblock, had to omit frame pointers to compile X-Git-Url: https://git.devinivas.org/?a=commitdiff_plain;h=2e953b3fb1a90c0e18955d9ede241b3036b096db;p=cs3210-lab1.git Added very minimal e820 support to the bootblock, had to omit frame pointers to compile --- diff --git a/bootblock/CMakeLists.txt b/bootblock/CMakeLists.txt index 5e0f66c..b25db5c 100644 --- a/bootblock/CMakeLists.txt +++ b/bootblock/CMakeLists.txt @@ -6,12 +6,15 @@ set(bootblock_SOURCES # NOTE: bootasm.S must go first in this list, to ensure its placed at 0x7c00 # in the bootloader dump bootasm.S + e820.S bootmain.c) add_library(bootblockobjs OBJECT ${bootblock_SOURCES}) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static -fno-builtin -fno-pic -nostdinc -m32") +# NOTE: I'm omitting frame pointers, which will screw hard with debugging, +# but it should be fine for the boot block? +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static -fno-builtin -fno-pic -fomit-frame-pointer -nostdinc -m32") set(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m elf_i386") diff --git a/bootblock/e820.S b/bootblock/e820.S new file mode 100644 index 0000000..03eb0ba --- /dev/null +++ b/bootblock/e820.S @@ -0,0 +1,48 @@ +.code16 # Assemble for 16-bit mode + +magic: + .long 0x0534d4150 + +e820: + .long 0xe820 + +# Only 16 bit. +dest_addr: + .word 0x0 + + +# The desetination adder (where the data will be stored) is passed in eax +.globl do_e820 +do_e820: + mov %ax, (dest_addr) + add $4, %ax + mov %ax, %di + xor %ebx, %ebx + xor %bp, %bp + mov (magic), %edx + +.e820lp: + mov (e820), %eax + movl $1, %es:20(%di) + mov $24, %ecx + int $0x15 + jc .e820f + mov (magic), %edx + + cmp %edx, %eax + jne .e820f + test %ebx, %ebx + je .e820f + jcxz .skipent + cmp $20, %cl + inc %bp + add $24, %di +.skipent: + test %ebx, %ebx + jne .e820lp +.e820f: + xor %eax, %eax + mov (dest_addr), %ax + mov %bp, (%eax) + ret +