How to perform low-level IO with a USB flash drive under the BIOS (compared to a floppy)?

一曲冷凌霜 提交于 2019-12-03 15:25:43

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

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!