bios 如何知道存在哪种类型的 BPB?

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

如果我想让我的引导加载程序从 U 盘引导,我必须包含一个 BPB。 U 盘在软盘仿真模式下是 运行。正如所见 here, there are many different BPB versions. How does the bios know what type of BPB is present? GRUB 0.97 seem to be using yet another BPB 格式?

我可以从偏移量 0xb 填充我的引导加载程序一点,然后它也会工作。 是否有 standard/common 尺寸可供使用?我没有在我的 USB 上使用任何文件系统,只是原始文件系统。

我想我需要 BPB,因为 bios 试图更新一些值,这会覆盖一些代码。由于每个 BPB 看起来都有点不同,bios 怎么知道在哪里更新什么值?

并非所有 BIOS 实现都关心您是否有 BPB。以 MBR 引导扇区开头的 BPB 的一般格式如下:

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

字段总是在同一个地方。如果系统关心 BPB,验证它的方式就是简单地解析它。