BIOS 参数块和磁盘格式化
我自己编写了一个简单的引导加载程序。首先,我有初始的典型 3 行代码,
bits 16
org 0x7c00
jmp main
后面是 FAT 12 和 1.44MB 软盘的 BIOS 参数块,直到偏移字节 0x003D。为了简单起见,假设主引导加载程序正在打印“Hello World”。
当我使用它复制引导加载程序时,
PARTCOPY 0 200 -f0 0
它会使我的磁盘丢失格式,从而在 Windows 上触发“磁盘未格式化”消息。
另一方面,如果我使用
PARTCOPY 0 3 -f0 0
PARTCOPY 3E 1C2 -f0 3E ; Do not copy BIOS Parameter Block
Windows 复制引导加载程序,则不会抱怨格式问题。
有了这些不同的结果,我想知道 BPB 如何影响格式和/或分区表。我提到分区表,因为我得到一个建议,我需要分区表来解决复制引导扇区后“磁盘未格式化”的问题。
任何帮助或评论将不胜感激。
真挚地,
I have written a simple bootloader of my own. I, first, have initial typical 3 lines of code
bits 16
org 0x7c00
jmp main
followed by BIOS Parameter Block for FAT 12 and for 1.44MB Floppy disk, up to offset byte 0x003D. Let's say the main bootloader is printing "Hello World" for simplicity.
When I copy my bootloader using
PARTCOPY 0 200 -f0 0
it makes my disk to lose its format, triggering "Disk not formatted" message on Windows.
On the other hand, if I copy my bootloader using
PARTCOPY 0 3 -f0 0
PARTCOPY 3E 1C2 -f0 3E ; Do not copy BIOS Parameter Block
Windows does not complain about the formatting.
With these different results, I would like to know how BPB affects the formatting and/or Partition Table. I mentioned Partition Table, because I got an advice that I need to have the Partition Table to resolve the "Disk not formatted" problem after copying the boot sector.
Any help or comment would be appreciated.
Sincerely,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Windows 对引导扇区执行大量检查,并且对它认为有效的引导扇区有点过于挑剔。如果您保留 FAT12 格式软盘的前 62 (0x3E) 字节并且不损坏 FAT,Windows 就不会抱怨。它不关心偏移量 0x3E 到 0x1FD 处的字节数。您也可以更改
OEM名称
和卷标名称
条目。其余的,保持原样即可。您的代码可以使用 BPB 中的值从 FAT 读取文件。Windows performs a number of checks on boot sectors and is a little too picky in what it considers a valid boot sector. If you preserve the first 62 (0x3E) bytes of a FAT12 formatted floppy and don't corrupt the FAT, Windows won't complain. It doesn't care about what's in bytes at offsets 0x3E through 0x1FD. You can change the
OEM name
andvolume label name
entries too. The rest, just keep it as-is. Your code may use the values in the BPB to read a file from the FAT.听起来您可能缺少主引导记录,这应该放置在第一个物理扇区中设备的并将由 BIOS 执行,它应该将控制权转移到您的引导加载程序。虽然公平地说,如果您将引导加载程序放在 FAT 分区中,您可能可以保留通过格式化驱动器创建的 MBR,并将代码直接复制到活动 FAT 分区的位置,而不是直接复制到文件的开头。驾驶。
Microsoft 在 此处 还对 FAT 设备上的启动过程进行了很好的解释,这可能会有所帮助。
It sounds like you might be missing a Master Boot Record, this should be placed in the first physical sector of the device and will be executed by the bios, it should transfer control to your boot loader. Although to be fair if you are putting your boot loader in a FAT partition you can probably just leave the MBR that would be created by formating the drive and copy your code directly into the location for active FAT partition rather than directly onto the start of the drive.
Microsoft also have a good explaination of the boot process on a FAT device here, which might help.