From 31c45051e6b6b6576f49e2e9ff71caa7ded44550 Mon Sep 17 00:00:00 2001 From: Elaina Claus Date: Sat, 12 Oct 2024 12:57:56 -0400 Subject: [PATCH] minor cleanup related to memory refactor --- src/mbr/mbr.nasm | 23 ++--------------------- src/vbr/vbr.nasm | 16 +++++++++------- 2 files changed, 11 insertions(+), 28 deletions(-) diff --git a/src/mbr/mbr.nasm b/src/mbr/mbr.nasm index cfec883..efb5e84 100755 --- a/src/mbr/mbr.nasm +++ b/src/mbr/mbr.nasm @@ -25,14 +25,11 @@ [WARNING -reloc-abs-word] ; Yes, we use absolute addresses. surpress these warnings. [map all mbr.map] %define __STEVIA_MBR - jmp short (init - $$) nop ; ############### -; ; Headers/Includes/Definitions -; ; ############### %include "util/bochs_magic.inc" @@ -43,11 +40,7 @@ nop %include "error_codes.inc" %include "partition_table.inc" -; ############### -; End Section -; ############### - -ALIGN 4, db 0x90 +ALIGN 4 init: cli ; We do not want to be interrupted @@ -69,23 +62,15 @@ init: jmp 0:main ; ############### -; ; Extra/Shared Functions -; ; ############### %include "util/kmem_func.nasm" %include "util/error_func.nasm" -; ############### -; End Section -; ############### - ; ; bp - 2 : uint8_t boot_drive ; bp - 4 : uint16_t part_offset -; - ALIGN 4, db 0x90 main: mov byte [bp - 2], dl ; BIOS passes drive number in DL @@ -158,7 +143,7 @@ main: mov si, word [bp - 4] mov dl, byte [bp - 2] - jmp 0:0x7C00 + jmp word 0x0000:0x7C00 ; ############### ; @@ -168,10 +153,6 @@ main: %include 'BIOS/func/ext_read.nasm' -; ############### -; End Section -; ############### - %assign bytes_remaining (440 - ($ - $$)) %warning MBR has bytes_remaining bytes remaining for code (MAX: 440 bytes) times ((512 - 72) - ($ - $$)) nop ; Fill the rest of sector with nop diff --git a/src/vbr/vbr.nasm b/src/vbr/vbr.nasm index 009f7ae..c68a37b 100755 --- a/src/vbr/vbr.nasm +++ b/src/vbr/vbr.nasm @@ -24,7 +24,7 @@ [WARNING -reloc-abs-word] [map all vbr.map] ; Yes, we use absolute addresses. surpress these warnings. %define __STEVIA_VBR - +section .text __ENTRY: jmp short (init - $$) nop @@ -51,11 +51,8 @@ times 54 db 0x00 %include "error_codes.inc" %include "fat32/bpb_offset_bx.inc" -; ############### -; End Section -; ############### -ALIGN 4, db 0x90 +ALIGN 4 init: cli ; We do not want to be interrupted @@ -85,6 +82,9 @@ init: ; End Section ; ############### +; +; byte boot_drive @ bp - 2 +; word part_offset @ bp - 4 ALIGN 4, db 0x90 main: mov byte [bp - 2], dl ; boot_drive @@ -101,7 +101,7 @@ main: push ax mov ax, fat32_bpb ; defined in memory.inc, destination push ax - call kmemcpy ; copy bpb to memory + call kmemcpy ; copy bpb & ebpb to memory add sp, 0x6 mov bx, fat32_bpb ; bx now points to aligned memory structure @@ -130,6 +130,8 @@ main: add sp, 0xC .check_sig: + ; BUG: this is hard coded to check @ ((0x7E0 << 4) + 0x7FFC)...i.e (STAGE2_ENTRY + (STAGE2_MAX_BYTES - 4)) + ; this should be removed or done properly mov ax, 0x7E0 mov fs, ax cmp dword [fs:0x7FFC], 0xDEADBEEF @@ -140,7 +142,7 @@ main: .sig_ok: mov si, word [bp - 4] mov dl, byte [bp - 2] - jmp 0:0x7E00 + jmp word 0x0000:0x7E00 ; ############### ; Required BIOS function(s)