如何在BIOS下用U盘进行低级IO(相对于软盘)?

发布于 2024-07-13 19:57:58 字数 673 浏览 13 评论 0原文

我最近一直在研究一些旨在与软盘驱动器一起使用的引导程序代码。 我的目标是修改程序,使其使用我的 USB 闪存驱动器。 现在我明白了 INT 13H 函数是如何与软盘设备一起使用的,但我想我的问题是,与 USB 驱动器的通信有何不同?

例如,下面是软盘代码的片段(GNU 汇编器):

    movb    $0x00,%dl       /* select 1st floppy */

    /* later */

    movw    sec,%cx     /* get sector number */
    movw    head,%dx    /* get head number */

    movw    $0x0201,%ax /* read 1 sector */
    int $0x13

现在我读到将 0x80 移动到 %dl 将选择 BIOS 中的第一个 HDD。 在我的特定 BIOS 中,我可以更改驱动器顺序,其中包括 USB 驱动器。 我非常确定这与 BIOS 相关,但我认为 BIOS 中列出的顺序可以对应于我移入 %dl 的值。 我需要追踪一些文档...

我真的不熟悉使用块设备,有人可以给我指出一个开始学习更多信息的好地方吗?

谢谢!

I have recently been studying some bootstrap code which was intended for use with a floppy drive. My goal is to modify the program so that it uses my USB flash drive. Now I see how the INT 13H function has been used with the floppy device, but I guess my question is, how will communicating with the USB drive differ?

For example, here is a snippet of the floppy code (GNU assembler):

    movb    $0x00,%dl       /* select 1st floppy */

    /* later */

    movw    sec,%cx     /* get sector number */
    movw    head,%dx    /* get head number */

    movw    $0x0201,%ax /* read 1 sector */
    int $0x13

Now I have read that moving 0x80 into %dl will select the first HDD in the BIOS. In my particular bios I can change the drive order, which would include a USB drive. I am quite sure this is becoming BIOS dependant, but I was thinking that the order listed in the BIOS could correspond to the value I move into %dl. I need to track down some documentation...

I am really unfamiliar with working with block devices as it is, can someone point me to a good place to start learning more?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

寻找一个思念的角度 2024-07-20 19:57:58

简单的答案是,如果 BIOS 可以从 USB 闪存驱动器启动,则可以使用与软盘/硬盘驱动器访问相同的 BIOS 功能。

令人高兴的答案是,一种简单的技术允许相同的引导扇区代码访问 USB 闪存驱动器上的软盘映像,无论它是通过软盘模拟还是硬盘驱动器模拟启动。 如果 dl=80h(硬盘模拟)

获取驱动器参数
int 13h, ah=8
返回:
ch=最大扇区数(与每磁道的扇区数相同)
dh=最大头数(只需加1即可得到头数)

此返回信息描述了模拟设备的几何结构(如果 dl=0 则为标准软盘几何结构 - 每磁道 18 个扇区和 2 个磁头)。 这可用于计算以下所需的气缸盖扇区信息:

读取扇区
int 13h,ah=2

写入扇区
int 13h,ah=3

请参阅 Ralf Brown 的中断列表 - int 13h

请参阅我的帖子:USB 启动秘密

The simple answer is that if the BIOS can boot from the USB flash drive the same BIOS functions for floppy disk / hard drive access can be used.

The happy answer is that a simple technique allows the same boot sector code to access a floppy disk image on a USB flash drive whether it was booted with floppy disk emulation or hard drive emulation. If dl=80h (hard drive emulation)

GET DRIVE PARAMETERS
int 13h, ah=8
Return:
ch=maximum sector number (same as number of sectors per track)
dh=maximum head number (just add 1 to get number of heads)

This returned information describes the geometry of the emulated device (if dl=0 then it's standard floppy disk geometry - 18 sectors per track and 2 heads). This can be used to calculate the required Cylinder Head Sector information required for:

READ SECTOR(S)
int 13h, ah=2

and

WRITE SECTOR(S)
int 13h, ah=3

See Ralf Brown's Interrupt List - int 13h

See my post here: USB Booting Secrets

抱猫软卧 2024-07-20 19:57:58

如果 BIOS 将 USB 设备“视为”硬盘驱动器,它将为其分配一个编号。 第一个硬盘驱动器分配的编号从 0x80 开始,第二个硬盘驱动器从 0x81 开始,依此类推。因此,根据安装的硬盘数量,您的 USB 驱动器将位于 0x81 或更大。 此外,如果您更改 BIOS 中的顺序,USB 驱动器编号也会更改以反映这一点。

If the BIOS "sees" the USB device as a hard drive it will assign a number to it. The assigned number starts at 0x80 for the first hard drive, 0x81 for the second, etc. So depending how many hdds are installed your USB drive will be at 0x81 or greater. Also if you change the order in BIOS the USB drive number will change to reflect this.

醉生梦死 2024-07-20 19:57:58

仅当 BIOS 支持时,闪存驱动器才可用。 如果是的话,它可能已经让你从它启动了。 其中大部分是通过仿真完成的,因此启动闪存驱动器的调用可能是相同的。

我已经从拇指驱动器中转储了引导块,并找到了软盘和硬盘驱动器格式。

也许您应该尝试使用一堆数字来访问驱动器,然后看看哪些数字可以回答。

我认为谷歌是你的朋友。 从“INT 13H”开始。 并提出更多问题。

The flash drive is only available if the BIOS supports it. And if it does, it would probably let you boot from it already. Most of this is done by emulation, so the calls to boot the flash drive are probably the same.

I've dumped out the boot blocks from my thumb drives, and have found both floppy and hard drive formats.

Maybe you should just try a bunch of numbers for accessing the drives and see which ones answer.

I think Google is your friend here. Start with "INT 13H". And ask more questions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文