remove shortjmp and ident from bpb

This commit is contained in:
2025-09-18 11:20:05 -04:00
parent 6c402b5c4f
commit d8a89cfd2b
3 changed files with 24 additions and 20 deletions

View File

@@ -58,16 +58,14 @@
; resulting in a value which does not fit in the Number of Sectors entry at 0x13.
struc FAT32_bpb_t
.reserved_jmpboot resb 3
.u16_BytesPerSector resw 1
.ident resb 8
.u8_SectorsPerCluster resb 1
.u16_ReservedSectors resw 1
.u8_FatCount resb 1
.u16_unused1_ZERO resb 2 ; Root entry count field, 0 on fat32
.u16_unused2_ZERO resb 2 ; total sectors size 16, 0 on fat32
.u16_RootEntryCount16 resw 1 ; Root dir entry count field, 0 on fat32
.u16_TotalSectors16 resw 1 ; total number of sectors size, 0 on fat32
.u8_MediaDesc resb 1
.u16_unused3_ZERO resb 2 ; FAT size 16, 0 on fat32
.u16_FatSize16 resw 1 ; FAT size 16, 0 on fat32
.u16_SectorsPerTrack resw 1
.u16_HeadCount resw 1
.u32_HiddenSectors resd 1
@@ -91,17 +89,17 @@ endstruc
; 8 System identifier string. Always "FAT32 ". The spec says never to trust the contents of this string for any use.
struc FAT32_ebpb_t
.u32_FATSz resb 4 ; size of *each* fat in sectors, total = FATSz * (# of FATs)
.u16_ExtFlags resb 2
.u16_FSVersion resb 2
.u32_RootDirCluster resb 4
.u16_FSInfoSector resb 2
.u16_BkBootSector resb 2
.reserved1 resb 12
.u32_FATSz resd 1 ; size of *each* fat in sectors, total = FATSz * (# of FATs)
.u16_ExtFlags resw 1
.u16_FSVersion resw 1
.u32_RootDirCluster resd 1
.u16_FSInfoSector resw 1
.u16_BkBootSector resw 1
.reserved0 resb 12
.u8_DriveNumber resb 1
.u8_NtFlags resb 1
.u8_Signature resb 1
.u32_VolumeId resb 4
.u32_VolumeId resd 1
.volume_label resb 11
.system_ident resb 8 ; Should always be 'FAT32 '
endstruc

View File

@@ -258,7 +258,7 @@ ReadVbrData:
cmp word [bx + 0x1FE], 0xAA55 ; check for bytes at end
jne ReadVbrData.error_nosign
.check_FAT_size:
test word [bx + FAT32_bpb_t.unused2_ZERO_word], 0 ; TotSectors16 will not be set if FAT32
test word [bx + FAT32_bpb_t.u16_TotalSectors16], 0 ; TotSectors16 will not be set if FAT32
jnz ReadVbrData.error_badfatfs
.endp:
__CDECL16_PROC_EXIT

View File

@@ -21,15 +21,21 @@
%define __STEVIA_VBR
section .text
__ENTRY:
phy_bpb_start:
; try to force encode a short jmp nop: i.e 0xEB 0x5A 0x90
; will jump right 0x5A (90 bytes) after the end of the ebpb
; this could also be encoded as 0xE9 0x?? 0x?? for a near jump
; if init ends up being >= 128 bytes from entry.
jmp short (init - $$)
nop
; fill BPB area with 0x00 since we skip writing this part to disk
; but we need it for the 'jmp short entry; nop' above
times 33 db 0x00
; 8 ascii bytes, "MSWIN 4.1", ""
phy_bs_ident:
times 8 db 0x00
phy_bpb_start:
times 25 db 0x00
phy_ebpb_start:
; fill eBPB area with 0x00 since we skip writing this part to disk
times 54 db 0x00
; ###############
@@ -95,7 +101,7 @@ main:
mov byte [bp - 2], dl ; boot_drive
.check_FAT_size: ; we only support a very specific setup of FAT32
mov bx, phy_bpb_start
test word [bx + FAT32_bpb_t.unused2_ZERO_word], 0 ; TotSectors16 will not be set if FAT32
test word [bx + FAT32_bpb_t.u16_TotalSectors16], 0 ; TotSectors16 will not be set if FAT32
jz main.load_stage2
ERROR VBR_ERROR_WRONG_FAT_SIZE
.load_stage2: