From 8d2cde0a3167392bd101a89c4d4f4ead1d1adc1d Mon Sep 17 00:00:00 2001 From: Elaina Claus Date: Wed, 17 Sep 2025 17:02:08 -0400 Subject: [PATCH] added no planned fat32 error codes and added mbr/vbr reading error codes --- include/BIOS/func/ext_read.nasm | 2 +- include/error_codes.inc | 20 ++++++++++---------- src/stage2/stage2.nasm | 22 +++++++++++++--------- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/include/BIOS/func/ext_read.nasm b/include/BIOS/func/ext_read.nasm index 013e834..2d4b0b1 100644 --- a/include/BIOS/func/ext_read.nasm +++ b/include/BIOS/func/ext_read.nasm @@ -94,7 +94,7 @@ read_disk_raw: %elifdef __STEVIA_VBR ERROR VBR_ERROR_DISK_READ_ERR %else - ERROR STAGE2_MBR_DISK_READ_ERROR + ERROR STAGE2_INT13_DISK_READ_ERR %endif .endf: __CDECL16_PROC_EXIT diff --git a/include/error_codes.inc b/include/error_codes.inc index c59a7da..68f4c90 100755 --- a/include/error_codes.inc +++ b/include/error_codes.inc @@ -51,16 +51,16 @@ %define STAGE2_MM_E820_MISC_ERR 'D' %define STAGE2_MM_E820_NONSTANDARD 'E' %define STAGE2_MM_E820_NO_SMAP 'F' -%define STAGE2_MBR_DISK_READ_ERROR 'G' -%define STAGE2_FAT32_INIT_ERROR 'H' -%define STAGE2_FAT32_NO_FILE 'I' -%define STAGE2_FAT32_END_OF_CHAIN 'J' -%define STAGE2_FAT32_NCLUS_CFDIVZ 'K' -%define STAGE2_FAT32_CLS2LBA_CF 'L' -%define STAGE2_FAT32_INIT_CF 'M' -%define STAGE2_ERROR_INFOPRINTER 'N' -%define STAGE2_ERROR_RESERVED_O 'O' -%define STAGE2_ERROR_RESERVED_P 'P' +%define STAGE2_INT13_DISK_READ_ERR 'G' +%define STAGE2_FAT32_E_FMT 'H' +%define STAGE2_FAT32_E_RANGE 'I' +%define STAGE2_FAT32_E_NOSUCH 'J' +%define STAGE2_FAT32_E_ISDIR 'K' +%define STAGE2_FAT32_E_TOOLONG 'L' +%define STAGE2_FAT32_E_UNSUPPORTED 'M' +%define STAGE2_FAT32_E_UNIMPLEMENTED 'N' +%define STAGE2_ERROR_BAD_MBR 'O' +%define STAGE2_ERROR_BAD_VBR 'P' %define STAGE2_ERROR_RESERVED_Q 'Q' %define STAGE2_ERROR_RESERVED_R 'R' %define STAGE2_ERROR_RESERVED_S 'S' diff --git a/src/stage2/stage2.nasm b/src/stage2/stage2.nasm index 8168103..deb5af6 100755 --- a/src/stage2/stage2.nasm +++ b/src/stage2/stage2.nasm @@ -213,13 +213,13 @@ ReadMbrData: .check_sig: mov bx, [bp + 6] cmp word [bx + 0x1FE], 0xAA55 ; check for bytes at end - jne ReadMbrData.error - ; TODO: this needs error checking, zero checking, check the sig a bunch of stuff... + jne ReadMbrData.error_nosign + ; TODO: this needs more error checking, zero checking, check the sig a bunch of stuff... .endp: __CDECL16_PROC_EXIT ret -.error: - ERROR STEVIA_DEBUG_ERR +.error_nosign: + ERROR STAGE2_ERROR_BAD_MBR ; int read_vbr(int boot_drive, void* buf) ; read vbr on boot partition to memory (for fat bpb/ebpb) @@ -239,7 +239,7 @@ ReadVbrData: je ReadVbrData.active_found add bx, PartEntry_t_size ; next part entry's attributes loop ReadVbrData.find_active_L0 - jmp ReadVbrData.error + jmp ReadVbrData.error_noactive .active_found: movzx ax, byte [bp + 4] push ax ; drive_num (2) @@ -256,15 +256,19 @@ ReadVbrData: .check_sig: mov bx, [bp + 6] cmp word [bx + 0x1FE], 0xAA55 ; check for bytes at end - jne ReadVbrData.error + jne ReadVbrData.error_nosign .check_FAT_size: test word [bx + FAT32_bpb_t.unused2_ZERO_word], 0 ; TotSectors16 will not be set if FAT32 - jnz ReadVbrData.error + jnz ReadVbrData.error_badfatfs .endp: __CDECL16_PROC_EXIT ret -.error: - ERROR STEVIA_DEBUG_ERR +.error_noactive: + ERROR STAGE2_ERROR_BAD_VBR +.error_nosign: + ERROR STAGE2_ERROR_BAD_VBR +.error_badfatfs: + ERROR STAGE2_ERROR_BAD_VBR ; set ds and es segments back to the base of the loader %ifnmacro __TINY_DS_ES