How does the bios know what type of BPB is present?

If I want my bootloader to boot from a USB drive, I have to enable BPB. The USB drive is in floppy disk emulation mode. As you can see here , there are many versions of BPB. How does the bios know what type of BPB is present? Does GRUB 0.97 seem to use another BPB format?

I can load my bootloader a bit at offset 0xb and then it will work as well. Is there a standard / overall size? I do not use any file system on my USB device, just raw.

I think I need BPB because bios is trying to update some values ​​that overwrite some of the code. Since each BPB seems a little different, how can the bios know where to update the value?

+5
source share
1 answer

Not all BIOS versions care if you have BPB. The general format for BPBs with the start of the MBR boot sector is below:

bits 16 org 0 ; BIOS will load the MBR to this location. bootStart: jmp _start nop osType db 'MSDOS6.0' bpb bps dw 512 spc db 8 rs dw 1 fats db 2 re dw 512 ss dw 0 media db 0xf8 spfat dw 0xc900 spt dw 0x3f00 heads dw 0x1000 hidden dw 0x3f00, 0 ls dw 0x5142,0x0600 pdn db 0x80 cheads db 0 sig db 0x29 serialno dw 0xce13, 0x4630 label db 'NO NAME' fattype db "FAT32" _start: ; set up the registers mov ax, 0x07c0 mov ds, ax mov fs, ax mov gs, ax mov ax, 0x0700 mov es, ax 

Fields are always in the same place. The way the system, if it cares about BPB, checks this simply by parsing it.

+2
source

Source: https://habr.com/ru/post/1264030/


All Articles