From 7abe0539f9ca3e9bbb50a9b13d4f57701fa5df1e Mon Sep 17 00:00:00 2001 From: Eric-Paul Ickhorn Date: Wed, 7 Aug 2024 10:06:18 +0200 Subject: [PATCH] Make finishing touches before UEFI addition As legacy BIOS isn't as straightforward to develop using a modern system, modern emulators/VMs and virtual machine firmware, it was decided to start work on an UEFI version of the Nightloader. This commit leaves the not-yet boot-capable, but as far as it's there already assembling and working legacy BIOS code behind for later work on this edition. --- i386/loader/src-asm/drivers/manager.asm | 1 - i386/loader/src-asm/entry.asm | 14 +++++--------- i386/loader/src-asm/memory/gdt.asm | 2 +- i386/loader/src-asm/utility/memory.asm | 13 ++++++------- i386/run.bash | 2 +- 5 files changed, 13 insertions(+), 19 deletions(-) diff --git a/i386/loader/src-asm/drivers/manager.asm b/i386/loader/src-asm/drivers/manager.asm index f28956c..400b650 100644 --- a/i386/loader/src-asm/drivers/manager.asm +++ b/i386/loader/src-asm/drivers/manager.asm @@ -73,4 +73,3 @@ setup_drivers: ret %include "drivers/pci/driver.asm" -%include "drivers/acpi/driver.asm" diff --git a/i386/loader/src-asm/entry.asm b/i386/loader/src-asm/entry.asm index 6001da1..d47d83d 100755 --- a/i386/loader/src-asm/entry.asm +++ b/i386/loader/src-asm/entry.asm @@ -18,7 +18,7 @@ stage_2_setup_entry: cli mov ah, 0x00 - mov al, 0x03 ;0x13 + mov al, 0x03 ; 0x13 for graphics, 0x03 for text. int 0x10 .check_a20: @@ -51,19 +51,15 @@ stage_2_setup_entry: %include "memory/a20.asm" %include "memory/gdt.asm" - - bits 32 -stage2_true_entry: - push ebp - mov ebp, esp - call setup_drivers - mov esp, ebp - pop ebp +stage2_protected_entry: cli hlt +.buffer: + dd 0 + %include "utility/math.asm" %include "utility/memory.asm" %include "utility/display.asm" diff --git a/i386/loader/src-asm/memory/gdt.asm b/i386/loader/src-asm/memory/gdt.asm index 7d1cfcb..3cf15f5 100755 --- a/i386/loader/src-asm/memory/gdt.asm +++ b/i386/loader/src-asm/memory/gdt.asm @@ -286,7 +286,7 @@ bits 32 mov ebx, [esi + (64 - 8)] mov eax, [esi + (64 - 4)] - jmp dword stage2_true_entry + jmp dword stage2_protected_entry align 16 .gdtr: diff --git a/i386/loader/src-asm/utility/memory.asm b/i386/loader/src-asm/utility/memory.asm index b3c03c3..cb5afa9 100755 --- a/i386/loader/src-asm/utility/memory.asm +++ b/i386/loader/src-asm/utility/memory.asm @@ -65,32 +65,31 @@ mem_equal: mov [esi + (32 - 16)], edi .body: - mov edx, [ebp - 4] ; Block 1 - mov edi, [ebp - 8] ; Block 2 xor eax, eax ; Current Byte Offset -.body.compare_loop: - +.comparison_loop: + mov edx, [ebp - 4] ; Block 1 mov ebx, edx add ebx, eax mov dl, [ebx] + mov edi, [ebp - 8] ; Block 2 mov ebx, edi add ebx, eax mov dh, [ebx] inc eax cmp dl, dh - je .body.compare_loop.condition + je .length_condition ; On NOT equal xor eax, eax jmp .epilog -.body.compare_loop.condition: +.length_condition: inc eax cmp eax, [ebp - 12] - jb .body.compare_loop + jb .comparison_loop mov eax, 1 .epilog: diff --git a/i386/run.bash b/i386/run.bash index 82f3e2b..449e0c7 100755 --- a/i386/run.bash +++ b/i386/run.bash @@ -1,3 +1,3 @@ #!/usr/bin/env bash -qemu-system-i386 nightloader.bin -qmp unix:qmp.socket,server,nowait +qemu-system-x86_64 -m 512M -enable-kvm -d guest_errors nightloader.bin -qmp unix:qmp.socket,server,nowait