简体   繁体   English

bios如何知道BPB的类型?

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

If I want my bootloader to boot from a usb stick, I have to include a BPB. 如果我希望我的引导加载程序从usb棒引导,我必须包含一个BPB。 The usb stick is running in floppy emulation mode. usb棒在软盘模拟模式下运行。 As seen here , there are many different BPB versions. 正如所看到这里 ,有许多不同版本的BPB。 How does the bios know what type of BPB is present? bios如何知道BPB的类型? GRUB 0.97 seem to be using yet another BPB format ? GRUB 0.97似乎正在使用另一种BPB格式?

I can pad my bootloader from offset 0xb a little, and then it will also work. 我可以从偏移量0xb稍微填充我的引导加载程序,然后它也可以工作。 Is there a standard/common size to use? 是否有标准/通用尺寸可供使用? I am not using any filesystem on my USB, just raw. 我没有在USB上使用任何文件系统,只是原始的。

I guess I need the BPB because the bios tries to update some on the values, which overwrite some of the code. 我想我需要BPB,因为bios尝试更新一些值,这会覆盖一些代码。 Since every BPB seems a little different, how can the bios know where to update what value? 由于每个BPB看起来有点不同,bios如何知道在哪里更新什么值?

Not all BIOS implementations care if you have a BPB. 如果您有BPB,并非所有BIOS实施都在关注。 The general format for the BPB with the beginning of an MBR boot sector is below: 具有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

The fields are always in the same place.. The way that the system, if it cares about the BPB, verifies it is simply by parsing it. 这些字段总是在同一个地方。系统如果关心BPB,只需解析它就可以验证它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM