Merge upstream changes from branch 'trunk' into fat32_sys_rewrite

This commit is contained in:
2024-12-19 20:09:48 -05:00
4 changed files with 102 additions and 81 deletions

View File

@@ -40,16 +40,14 @@ InitFATDriver:
sub sp, 0x6
.calc_active_part:
mov bx, [partition_offset]
mov ax, partition_table
add ax, cx
mov si, ax ; si = offset to active partition
mov ax, fat32_state
mov di, ax
mov ax, word [partition_offset]
mov eax, dword [si + PartEntry_t.lba_start]
mov dword [di + FAT32_State_t.curr_drive_lba_32], eax
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.active_drive_lba_32], eax
mov ax, fat32_bpb
mov si, ax
@@ -138,7 +136,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
@@ -245,7 +243,8 @@ NextCluster:
add eax, ecx ; fat_sector + first_fat_sector
mov dword [si + FAT32_NextClusterData_t.fat_sector], eax
.load_fat_table:
mov ax, word [boot_drive]
xor ax, ax
mov al, byte [boot_drive]
push ax
mov ax, 0x1
@@ -260,20 +259,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
; <bochs:2> 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,
@@ -317,7 +302,8 @@ ReadFATCluster:
.func:
print_string ReadFATCluster_info
mov ax, word [boot_drive]
xor ax, ax
mov al, byte [boot_drive]
push ax
mov ax, 0x1 ; count = 1