From 63a1a1beea66dc34d7ccc585f107802e5a5ffc0e Mon Sep 17 00:00:00 2001 From: Elaina Claus Date: Thu, 19 Dec 2024 13:13:46 -0500 Subject: [PATCH 1/7] might have fixed some of the boot_drive issues with ext_read --- bochsrc.bxrc | 23 +++++++------ include/fat32/FAT32_SYS.inc | 13 ++++--- src/stage2/stage2.nasm | 68 +++++++++++++++++++------------------ src/vbr/vbr.nasm | 8 ++--- 4 files changed, 57 insertions(+), 55 deletions(-) diff --git a/bochsrc.bxrc b/bochsrc.bxrc index 34c323d..6bd34d5 100644 --- a/bochsrc.bxrc +++ b/bochsrc.bxrc @@ -1,20 +1,18 @@ # configuration file generated by Bochs -plugin_ctrl: voodoo=false, unmapped=true, biosdev=true, speaker=true, extfpuirq=true, parallel=true, serial=true, busmouse=false, e1000=false, es1370=false, gameport=true, ne2k=false, sb16=false, usb_uhci=false, usb_ohci=false, usb_ehci=false, usb_xhci=false +plugin_ctrl: voodoo=false, unmapped=true, biosdev=true, speaker=true, extfpuirq=true, parallel=true, serial=true, busmouse=false, e1000=false, es1370=false, gameport=true, iodebug=true, ne2k=false, sb16=false, usb_uhci=false, usb_ohci=false, usb_ehci=false, usb_xhci=false config_interface: win32config display_library: win32 memory: guest=64, host=64, block_size=128 -romimage: file="C:\Program Files\Bochs-2.8\BIOS-bochs-latest", address=0x00000000, options=none, flash_data=none +romimage: file="C:\Program Files\Bochs-2.8\BIOS-bochs-legacy", address=0x00000000, options=none, flash_data=none vgaromimage: file="C:\Program Files\Bochs-2.8\VGABIOS-lgpl-latest" boot: disk -floppy_bootsig_check: disabled=0 +floppy_bootsig_check: disabled=1 floppya: type=1_44 # no floppyb ata0: enabled=true, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14 -ata0-master: type=disk, path=".\disk.img", mode=flat, cylinders=0, heads=0, spt=0, sect_size=512, model="Stevia Disk", biosdetect=auto, translation=lba +ata0-master: type=disk, path=".\disk.img", mode=flat, cylinders=0, heads=16, spt=63, sect_size=512, model="Stevia Disk", biosdetect=auto, translation=auto ata0-slave: type=none -ata1: type=none -ata1-master: type=none -ata1-slave: type=none +ata1: enabled=false ata2: enabled=false ata3: enabled=false optromimage1: file=none @@ -29,7 +27,10 @@ pci: enabled=1, chipset=i440fx, slot1=none, slot2=none, slot3=none, slot4=none, vga: extension=vbe, update_freq=10, realtime=1, ddc=builtin cpu: count=1, ips=1000000, model=p3_katmai, reset_on_triple_fault=1, cpuid_limit_winnt=0, ignore_bad_msrs=1, mwait_is_nop=0 print_timestamps: enabled=0 -port_e9_hack: enabled=false, all_rings=false +debugger_log: - +magic_break: enabled=1 +port_e9_hack: enabled=true, all_rings=false +iodebug: all_rings=0 private_colormap: enabled=0 clock: sync=none, time0=local, rtc_sync=0 # no cmosimage @@ -43,9 +44,9 @@ keyboard: type=mf, serial_delay=150, paste_delay=100000, user_shortcut=none mouse: type=none, enabled=false, toggle=ctrl+mbutton sound: waveoutdrv=dummy, waveout=none, waveindrv=dummy, wavein=none, midioutdrv=dummy, midiout=none speaker: enabled=true, mode=sound, volume=15 -parport1: enabled=true, file=none +parport1: enabled=false parport2: enabled=false -com1: enabled=true, mode=null +com1: enabled=false com2: enabled=false com3: enabled=false -com4: enabled=false +com4: enabled=false \ No newline at end of file diff --git a/include/fat32/FAT32_SYS.inc b/include/fat32/FAT32_SYS.inc index b4f25d9..e6b8355 100644 --- a/include/fat32/FAT32_SYS.inc +++ b/include/fat32/FAT32_SYS.inc @@ -38,8 +38,7 @@ InitFATDriver: sub sp, 0x6 .calc_active_part: - mov bx, [partition_offset_ptr] - mov ax, word [ds:bx] + mov ax, word partition_offset mov dx, partition_table add dx, ax ; dx points to the partition that was booted from @@ -114,7 +113,7 @@ SearchFATDIR: add sp, 0x4 cmp eax, 0x0fff_fff7 - je SearchFATDIR.bad_cluster + ;je SearchFATDIR.bad_cluster ; TODO: Implement Bad cluster checks jb SearchFATDIR.load_next_dir_next_OK ERROR STAGE2_FAT32_END_OF_CHAIN @@ -234,8 +233,8 @@ NextCluster: add eax, ecx ; fat_sector + first_fat_sector mov dword [si + FAT32_NextClusterData_t.fat_sector], eax .load_fat_table: - mov bx, word [boot_drive_ptr] - movzx ax, byte [ds:bx] + xor ax, ax + mov al, boot_drive push ax mov ax, 0x1 @@ -306,8 +305,8 @@ ReadFATCluster: .func: print_string ReadFATCluster_INFO_cstr - mov bx, word [boot_drive_ptr] - movzx ax, byte [ds:bx] + xor ax, ax + mov al, boot_drive push ax mov ax, 0x1 ; count = 1 diff --git a/src/stage2/stage2.nasm b/src/stage2/stage2.nasm index 998073d..834958f 100755 --- a/src/stage2/stage2.nasm +++ b/src/stage2/stage2.nasm @@ -49,14 +49,18 @@ section .text begin_text: ; dl = byte boot_drive -; si = word part_offset (active partition offset) -; bx = ptr PartTable_t partition_table -; dx = ptr FAT32_bpb_t fat32_bpb +; ax = word part_offset (active partition offset) +; si = ptr PartTable_t partition_table +; di = ptr FAT32_bpb_t fat32_bpb ALIGN 4, db 0x90 init: - __BOCHS_MAGIC_DEBUG cli ; We do not want to be interrupted + mov [vbr_part_table_ptr], bx ; pointer to partition_table + mov [vbr_fat32_bpb_ptr], dx ; pointer to fat32_bpb + mov [boot_drive], dl ; copy boot_drive to globals + mov [partition_offset], ax ; copy partition_offset to globals + mov ax, __STAGE2_SEGMENT ; set all our segments to the configured segment, excep es mov ds, ax ; * mov fs, ax ; * @@ -81,7 +85,7 @@ init: mov sp, stack_top mov bp, sp - sub sp, 0x20 + sub sp, 0x10 push bp ; setup a somewhat normal stack frame, minus a ret ptr sti @@ -121,22 +125,9 @@ struc EarlyBootStruct_t .fat32_ebpb resb FAT32_ebpb_t_size endstruc -; bp - 2 : byte boot_drive -; bp - 4 : word part_offset -; bp - 6 : ptr PartTable_t partition_table -; bp - 8 : ptr FAT32_bpb_t fat32_bpb ALIGN 4, db 0x90 main: - lea ax, [bp - 2] - mov [boot_drive_ptr], ax - - lea ax, [bp - 4] - mov [partition_offset_ptr], ax ; setup pointers to boot_drive and partition offset on stack - - mov byte [bp - 2], dl ; boot_drive (probably 0x80) - mov word [bp - 4], si ; partition_offset - mov word [bp - 6], bx ; partition_table - mov word [bp - 8], dx ; fat32_bpb + __BOCHS_MAGIC_DEBUG .check_sig: mov eax, dword [STAGE2_SIG] cmp eax, 0xDEADBEEF @@ -145,20 +136,20 @@ main: .stage2_main: mov ax, PartTable_t_size push ax - mov ax, [bp - 6] ; ptr partition_table + mov ax, word [vbr_part_table_ptr] ; ptr partition_table push ax mov ax, partition_table push ax - call kmemcpy ; copy partition table data + call kmemcpy ; copy partition table data add sp, 0x6 mov ax, (FAT32_bpb_t_size + FAT32_ebpb_t_size) ; size in byte push ax - mov ax, [bp - 8] + mov ax, word [vbr_fat32_bpb_ptr] push ax - mov ax, fat32_bpb ; defined in memory.inc, destination + mov ax, fat32_bpb ; defined in memory.inc, destination push ax - call kmemcpy ; copy bpb & ebpb to memory + call kmemcpy ; copy bpb & ebpb to memory add sp, 0x6 call SetTextMode @@ -503,33 +494,44 @@ section .bss follows=.sign begin_bss: ; structures -align 16, resb 1 +align 8, resb 1 partition_table resb PartTable_t_size -align 16, resb 1 +align 8, resb 1 fat32_bpb resb FAT32_bpb_t_size fat32_ebpb resb FAT32_ebpb_t_size -align 16, resb 1 +align 8, resb 1 fat32_nc_data resb 16 -align 16, resb 1 +align 8, resb 1 lba_packet resb LBAPkt_t_size -align 16, resb 1 +align 8, resb 1 fat32_state: resb FAT32_State_t_size -align 16, resb 1 +align 8, resb 1 SteviaInfo: resd 4 ; -; locals +; globals ; -boot_drive_ptr: +align 8, resb 1 +boot_drive: + resb 1 + +align 8, resb 1 +partition_offset: resw 1 -partition_offset_ptr: + +align 8, resb 1 +vbr_fat32_bpb_ptr: + resw 1 + +align 8, resb 1 +vbr_part_table_ptr: resw 1 ; diff --git a/src/vbr/vbr.nasm b/src/vbr/vbr.nasm index 729cc1e..d204995 100755 --- a/src/vbr/vbr.nasm +++ b/src/vbr/vbr.nasm @@ -152,10 +152,10 @@ main: call read_disk_raw add sp, 0xC .enter_stage2: - mov dl, byte [bp - 2] ; boot_drive - mov si, word [bp - 4] ; part_offset - mov bx, partition_table - mov dx, fat32_bpb + mov dl, byte [bp - 2] ; byte boot_drive + mov ax, word [bp - 4] ; word part_offset + mov si, partition_table ; ptr partition_table + mov di, fat32_bpb ; ptr fat32_bpb jmp word 0x0000:STAGE2_ENTRY ; ############### From 37eb87239c029b7e5da30c6008dd612034a5e171 Mon Sep 17 00:00:00 2001 From: Elaina Claus Date: Thu, 19 Dec 2024 15:18:28 -0500 Subject: [PATCH 2/7] moved varibles passed from vbr to .data section this is to work around having to save them without .bss ready --- include/fat32/FAT32_SYS.inc | 4 +-- src/stage2/stage2.nasm | 67 ++++++++++++++++++++----------------- 2 files changed, 38 insertions(+), 33 deletions(-) diff --git a/include/fat32/FAT32_SYS.inc b/include/fat32/FAT32_SYS.inc index e6b8355..d7920a9 100644 --- a/include/fat32/FAT32_SYS.inc +++ b/include/fat32/FAT32_SYS.inc @@ -234,7 +234,7 @@ NextCluster: mov dword [si + FAT32_NextClusterData_t.fat_sector], eax .load_fat_table: xor ax, ax - mov al, boot_drive + mov al, byte [boot_drive] push ax mov ax, 0x1 @@ -306,7 +306,7 @@ ReadFATCluster: print_string ReadFATCluster_INFO_cstr xor ax, ax - mov al, boot_drive + mov al, byte [boot_drive] push ax mov ax, 0x1 ; count = 1 diff --git a/src/stage2/stage2.nasm b/src/stage2/stage2.nasm index 834958f..89e55ce 100755 --- a/src/stage2/stage2.nasm +++ b/src/stage2/stage2.nasm @@ -56,12 +56,13 @@ ALIGN 4, db 0x90 init: cli ; We do not want to be interrupted - mov [vbr_part_table_ptr], bx ; pointer to partition_table - mov [vbr_fat32_bpb_ptr], dx ; pointer to fat32_bpb + ; these 4 are stored in the .data section and are effectivly const types + mov [vbr_part_table_ptr], si ; pointer to partition_table + mov [vbr_fat32_bpb_ptr], di ; pointer to fat32_bpb mov [boot_drive], dl ; copy boot_drive to globals mov [partition_offset], ax ; copy partition_offset to globals - mov ax, __STAGE2_SEGMENT ; set all our segments to the configured segment, excep es + mov ax, __STAGE2_SEGMENT ; set all our segments to the configured segment, except es mov ds, ax ; * mov fs, ax ; * mov gs, ax ; * @@ -135,19 +136,19 @@ main: ERROR STAGE2_SIGNATURE_MISSING .stage2_main: mov ax, PartTable_t_size + push ax ; len = PartTable_t_size + mov ax, word [vbr_part_table_ptr] ; src = ptr to vbr partition_table push ax - mov ax, word [vbr_part_table_ptr] ; ptr partition_table + mov ax, partition_table ; dst push ax - mov ax, partition_table - push ax - call kmemcpy ; copy partition table data + call kmemcpy ; copy partition table data to .data section in stage2 add sp, 0x6 - mov ax, (FAT32_bpb_t_size + FAT32_ebpb_t_size) ; size in byte + mov ax, (FAT32_bpb_t_size + FAT32_ebpb_t_size) ; len push ax - mov ax, word [vbr_fat32_bpb_ptr] + mov ax, word [vbr_fat32_bpb_ptr] ; src push ax - mov ax, fat32_bpb ; defined in memory.inc, destination + mov ax, fat32_bpb ; dst push ax call kmemcpy ; copy bpb & ebpb to memory add sp, 0x6 @@ -160,14 +161,14 @@ main: call EnableA20 print_string A20_Enabled_OK_cstr - ; enter unreal mode - call EnterUnrealMode - print_string UnrealMode_OK_cstr - ; get system memory map call GetMemoryMap print_string MemoryMap_OK_cstr + ; enter unreal mode + call EnterUnrealMode + print_string UnrealMode_OK_cstr + ; FAT Driver setup call InitFATDriver print_string InitFATSYS_OK_cstr @@ -400,6 +401,26 @@ define_cstr NewLine, "" define_str BootTarget, "BOOT BIN" +; +; pre-bss init globals (generally const...but there are exceptions) +; + +align 8, db 0x00 +boot_drive: + db 0x00 + +align 8, db 0x00 +partition_offset: + dw 0x0000 + +align 8, db 0x00 +vbr_fat32_bpb_ptr: + dw 0x0000 + +align 8, db 0x00 +vbr_part_table_ptr: + dw 0x0000 + ALIGN 16 IntToHex_table: db '0123456789ABCDEF' @@ -514,25 +535,9 @@ fat32_state: align 8, resb 1 SteviaInfo: resd 4 - ; -; globals +; post-bss init globals ; -align 8, resb 1 -boot_drive: - resb 1 - -align 8, resb 1 -partition_offset: - resw 1 - -align 8, resb 1 -vbr_fat32_bpb_ptr: - resw 1 - -align 8, resb 1 -vbr_part_table_ptr: - resw 1 ; ; large continuous allocations From 56b86fe12e68646852ad436ab9c844eda7b1a72e Mon Sep 17 00:00:00 2001 From: Elaina Claus Date: Thu, 19 Dec 2024 18:59:34 -0500 Subject: [PATCH 3/7] more bug catching after changing the location of data also cleanup comment from previous bug --- include/fat32/FAT32_SYS.inc | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/include/fat32/FAT32_SYS.inc b/include/fat32/FAT32_SYS.inc index d7920a9..e50af1f 100644 --- a/include/fat32/FAT32_SYS.inc +++ b/include/fat32/FAT32_SYS.inc @@ -38,7 +38,7 @@ InitFATDriver: sub sp, 0x6 .calc_active_part: - mov ax, word partition_offset + mov ax, word [partition_offset] mov dx, partition_table add dx, ax ; dx points to the partition that was booted from @@ -249,20 +249,6 @@ NextCluster: xor ax, ax push ax - ; BUG: something about this function causes this BIOS call to come back wrong - ; somehow the drive number is being read in wrong, but I can't find evidence of it being modified or writen - ; to memory incorrectly. - ; 00007109574i[BIOS ] Booting from 0000:7c00 - ; 00007123227i[CPU0 ] [7123227] Stopped on MAGIC BREAKPOINT - ; (0) Magic breakpoint - ; Next at t=7123227 - ; (0) [0x000000000502] 0000:0502 (unk. ctxt): cli ; fa - ; c - ; 00007252963i[BIOS ] int13_diskette: unsupported AH=42 - ; 00007253071i[CPU0 ] [7253071] Stopped on MAGIC BREAKPOINT - ; (0) Magic breakpoint - ; Next at t=7253071 - ; (0) [0x00000000095c] 0000:095c (unk. ctxt): mov al, 0x47 ; b047 call read_disk_raw add sp, 0xC ; uint8_t read_stage2_raw(uint16_t buf_segment, uint16_t buf_offset, From d6e8a2a923320394da9669c5d0e9994a986bfdf3 Mon Sep 17 00:00:00 2001 From: Elaina Claus Date: Fri, 20 Dec 2024 02:07:46 +0000 Subject: [PATCH 4/7] minor cleanup and add dev enviroment files to gitignore --- .gitignore | 3 ++- include/fat32/FAT32_SYS.inc | 4 ++-- src/stage2/stage2.nasm | 22 ---------------------- 3 files changed, 4 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index 92682b7..ab2cf9a 100755 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ build/* bx_enh_dbg.ini stevia-log .vscode/ -*.map \ No newline at end of file +*.map +compose-dev.yaml diff --git a/include/fat32/FAT32_SYS.inc b/include/fat32/FAT32_SYS.inc index d9bd5ba..ce85716 100644 --- a/include/fat32/FAT32_SYS.inc +++ b/include/fat32/FAT32_SYS.inc @@ -47,7 +47,7 @@ InitFATDriver: mov bx, dx ; set bx, should point at our partition mov eax, dword [bx + PartEntry_t.lba_start] - mov dword [fat32_state + FAT32_State_t.active_drive_lba_32], eax + mov dword [fat32_state + FAT32_State_t.curr_drive_lba_32], eax mov ax, fat32_bpb mov si, ax @@ -193,7 +193,7 @@ SearchFATDIR: mov cx, 0xA ; max of 11 filename length of 11 characters ; si points to the start of the current directory entry - mov di, BootTarget_str ; current memory location (8.3 name is at offset 0) + mov di, BootTarget ; current memory location (8.3 name is at offset 0) repe cmpsb ; compare the strings pop di diff --git a/src/stage2/stage2.nasm b/src/stage2/stage2.nasm index d5d6cc6..9d0b0c9 100755 --- a/src/stage2/stage2.nasm +++ b/src/stage2/stage2.nasm @@ -169,8 +169,6 @@ main: call EnterUnrealMode print_string UnrealMode_OK_info - - ; FAT Driver setup call InitFATDriver print_string InitFATSYS_OK_info @@ -401,26 +399,6 @@ BootTarget: ; pre-bss init globals (generally const...but there are exceptions) ; -align 8, db 0x00 -boot_drive: - db 0x00 - -align 8, db 0x00 -partition_offset: - dw 0x0000 - -align 8, db 0x00 -vbr_fat32_bpb_ptr: - dw 0x0000 - -align 8, db 0x00 -vbr_part_table_ptr: - dw 0x0000 - -; -; pre-bss init globals (generally const...but there are exceptions) -; - align 8, db 0x00 boot_drive: db 0x00 From ce73226eee45bba5d8e4c88a0fa5ce89195e229e Mon Sep 17 00:00:00 2001 From: Elaina Claus Date: Thu, 19 Dec 2024 21:31:12 -0500 Subject: [PATCH 5/7] update macos build script --- scripts/create-disk.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/create-disk.sh b/scripts/create-disk.sh index b16eb71..ebc3b13 100755 --- a/scripts/create-disk.sh +++ b/scripts/create-disk.sh @@ -170,7 +170,7 @@ elif [[ "$OSTYPE" == "darwin"* ]]; then sfdisk_path="/usr/local/opt/util-linux/sbin/sfdisk" if [ -e $mbr_file ] && [ -e $vbr_file ]; then # use hdiutil to attach our empty disk image - ld_path_raw=$(hdiutil attach -readwrite -imagekey diskimage-class=CRawDiskImage -nomount -blocksize 512 -noverify disk.img) + ld_path_raw=$(hdiutil attach -readwrite -imagekey diskimage-class=CRawDiskImage -nomount -blocksize 512 -noverify /tmp/disk.img) ld=$(echo $ld_path_raw | sed s:/dev/::) ld_path="/dev/$ld" @@ -193,7 +193,7 @@ elif [[ "$OSTYPE" == "darwin"* ]]; then unset ld unset ld_path_raw - ld_path_raw=$(hdiutil attach -readwrite -imagekey diskimage-class=CRawDiskImage -nomount -blocksize 512 -noverify disk.img) + ld_path_raw=$(hdiutil attach -readwrite -imagekey diskimage-class=CRawDiskImage -nomount -blocksize 512 -noverify /tmp/disk.img) ld=$(echo $ld_path_raw | grep "FDisk_partition_scheme" | awk '{print $1}' | sed s:/dev/::) ld_path="/dev/$ld" From ddd3f35a8b4f1b8ceb539456250c84e8bcee3e71 Mon Sep 17 00:00:00 2001 From: Elaina Claus Date: Fri, 20 Dec 2024 10:10:12 -0500 Subject: [PATCH 6/7] inlined ClusterToLBA into ReadFATCluster fixed a bug where fat32_state wasn't being updated... --- include/fat32/FAT32_SYS.inc | 45 ++++++++++++++----------------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/include/fat32/FAT32_SYS.inc b/include/fat32/FAT32_SYS.inc index ce85716..c0ebc05 100644 --- a/include/fat32/FAT32_SYS.inc +++ b/include/fat32/FAT32_SYS.inc @@ -41,19 +41,17 @@ InitFATDriver: .calc_active_part: mov ax, word [partition_offset] + mov di, fat32_state mov dx, partition_table add dx, ax ; dx points to the partition that was booted from mov bx, dx ; set bx, should point at our partition mov eax, dword [bx + PartEntry_t.lba_start] - mov dword [fat32_state + FAT32_State_t.curr_drive_lba_32], eax + mov dword [di + FAT32_State_t.curr_drive_lba_32], eax - mov ax, fat32_bpb - mov si, ax - - mov ax, fat32_ebpb - mov bx, ax + mov si, fat32_bpb + mov bx, fat32_ebpb .calc_first_fat: movzx eax, word [si + FAT32_bpb_t.reserved_sectors_word] ; first fat from start of partition add eax, dword [di + FAT32_State_t.curr_drive_lba_32] ; calculate offset from start of drive @@ -275,26 +273,6 @@ NextCluster: .error_cfdivz: ERROR STAGE2_FAT32_NCLUS_CFDIVZ -; __fastcall16 uint32_t ClusterToLBA(uint32_t cluster) -; input = dword cluster in eax -ALIGN 4, db 0x90 -ClusterToLBA: - __FASTCALL16_ENTRY -.func: - sub eax, 2 - movzx edx, byte [fat32_bpb + FAT32_bpb_t.sectors_per_cluster_byte] - mul edx ; result in eax, error on carry - jc ClusterToLBA.error - add eax, dword [fat32_state + FAT32_State_t.first_data_sector_32] - jc ClusterToLBA.error - ; eax contains the LBA now -.endp: - __FASTCALL16_EXIT - ret -.error: - ERROR STAGE2_FAT32_CLS2LBA_CF - -; bp - 2 - byte boot_drive ; uint8_t ReadFATCluster(uint16_t seg, uint16_t offset, uint32_t cluster) ALIGN 4, db 0x90 ReadFATCluster: @@ -302,6 +280,9 @@ ReadFATCluster: .func: print_string ReadFATCluster_info + mov bx, fat32_bpb + mov si, fat32_ebpb + xor ax, ax mov al, byte [boot_drive] push ax @@ -309,8 +290,14 @@ ReadFATCluster: mov ax, 0x1 ; count = 1 push ax - mov eax, dword [bp + 8] - call ClusterToLBA ; __fastcall16 uint32_t ClusterToLBA(uint32_t cluster) + mov eax, dword [bp + 8] ; cluster + sub eax, 2 + movzx edx, byte [bx + FAT32_bpb_t.sectors_per_cluster_byte] + mul edx ; result in eax, error on carry + jc ReadFATCluster.error + add eax, dword [si + FAT32_State_t.first_data_sector_32] + jc ReadFATCluster.error + ; eax contains the LBA now push dword eax ; lba = ClusterToLBA(..) mov ax, word [bp + 6] ; offset @@ -326,6 +313,8 @@ ReadFATCluster: .endp: __CDECL16_EXIT ret +.error: + ERROR STAGE2_FAT32_CLS2LBA_CF %endif %define __INC_FAT32_SYS \ No newline at end of file From aa181bbae41bde38db2409e12fcc845607044555 Mon Sep 17 00:00:00 2001 From: Elaina Claus Date: Fri, 20 Dec 2024 10:22:55 -0500 Subject: [PATCH 7/7] minor edit --- include/fat32/FAT32_SYS.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fat32/FAT32_SYS.inc b/include/fat32/FAT32_SYS.inc index c0ebc05..bb18a34 100644 --- a/include/fat32/FAT32_SYS.inc +++ b/include/fat32/FAT32_SYS.inc @@ -191,7 +191,7 @@ SearchFATDIR: mov cx, 0xA ; max of 11 filename length of 11 characters ; si points to the start of the current directory entry - mov di, BootTarget ; current memory location (8.3 name is at offset 0) + mov di, BootTarget ; current memory location (8.3 name is at offset 0) repe cmpsb ; compare the strings pop di