BenLunt wrote:
mikegonta wrote:
BenLunt wrote:
My conclusion is that if you wish to have (most) all machines boot your USB device, have a first sector that contains a BPB and a Partition Table with code within this first sector to parse and boot one of the Partition Table Entries.
Or use a self referencing partition table entry which requires no code since it points to itself (LBA 0).
Which is perfectly fine, though now you have a BPB and a Partition Table in the way of the file system. Some file systems, FAT for example, won't care and require the BPB anyway. Other file systems will not like a BPB and/or Partition Table within the first sector.
There doesn't seem to any booting requirement for a
BPB for non FAT file systems and generally assumed that partitioned media has
the best chance.
BenLunt wrote:
Ext2 for example, leaves you with only two sectors for your boot code. Two sectors is really tight, let alone having to leave room for the BPB and Partition Table.
A simple rearrangement of
your ext2_hd.asm costs only
5 extra bytes (out of the 25 spare bytes that you have) to implement
a self referencing
MBR.
Code:
; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
; These data items must be in the first sector already loaded by the BIOS
diskerrorS db 13,10,'Error reading disk/non-system disk'
db 13,10,'Press a key',0
; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
; Pad out to fill 512 bytes, including self referencing MBR and final word 0xAA55
%PRINT (510-64-$) ; 20 byte(s) free in this area
; mbr is located here
org (200h-66)
boot_data ; st S_BOOT_DATA ; booted data to pass to loader.sys
db 80h ; status
db 0,0,0 ; chs of first active sector
db 83h ; EXT2 partition type
db 0,0,0 ; chs of last absolute sector (initialize if required)
dd 0 ; volume LBA
dd VOLUME_SIZE ; requires initialization
dup 12,0 ; don't care
dd 0 ; required
dup 12,0 ; don't care
dd 0 ; required
dup 12,0 ; don't care
dd 0 ; required
loadname db 'loader.sys',0
db 0
dd 0 ; required
dw 0AA55h