Is int 13 extension for usb? [solved]

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Klakap
Member
Member
Posts: 297
Joined: Sat Mar 10, 2018 10:16 am

Is int 13 extension for usb? [solved]

Post by Klakap »

Good day,

I tested that bios int 13h extension ah=42h work on emulators and my computer. But when I try to read from usb, it report error on my computer(on emulators I test my operation system as floppy disc, so I cant test reading by extension). Please, is there any way how read and write to usb on real computer by bios extension?

//EDIT: I think that bios emulate my usb like floppy because dl value after start is 0x00. Please how I can change my usb to hdd emulate or cdrom emulate?
Last edited by Klakap on Thu May 14, 2020 6:29 am, edited 1 time in total.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Is int 13 extension for usb?

Post by neon »

Hi,

The firmware emulates USB devices in SMM as a floppy or hard disk device. Some systems only support one type of emulation whereas other systems support both and may even have an option to select in BIOS Settings. That is where you would go to check what type of emulation is enabled for USB boot -- BIOS Settings.

If it is emulated as a floppy device, use the standard int 13h function 2 service. If hard disk, use int 13h function 42h. Only use the device number provided by the BIOS in DL.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
BenLunt
Member
Member
Posts: 941
Joined: Sat Nov 22, 2014 6:33 pm
Location: USA
Contact:

Re: Is int 13 extension for usb?

Post by BenLunt »

neon is correct, though may I add a little more.

Some BIOSes will read the device and see what is already there. For example, if there is a FAT BPB that describes a 1.44meg floppy, the BIOS will use that emulation. If there is a FAT BPB that describes a hard disk drive, it will use a hard disk emulation.

If it doesn't recognize the media format, it may guess. However, more times than not, it will take the fail option.

There is not a standard to what the USB emulation must do, so it is up to the BIOS manufacturer to do as they wish.

Why no standard? The BIOS (firmware) manufacturers are trying to get away from the Legacy system. Why create a standard for something that is more than 20 years old?

With numerous tests, myself and others, the findings are that to be mostly compatible, make sure the USB thumb drive is formatted with a valid FAT file system, either as a 1.44meg floppy or a "smallish" hard drive image. The 1.44meg floppy image *must not* have a MBR and the hard drive image most likely must have a MBR.

Ben
- http://www.fysnet.net/the_universal_serial_bus.htm
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: Is int 13 extension for usb?

Post by bzt »

BenLunt wrote:With numerous tests, myself and others, the findings are that to be mostly compatible, make sure the USB thumb drive is formatted with a valid FAT file system, either as a 1.44meg floppy or a "smallish" hard drive image. The 1.44meg floppy image *must not* have a MBR and the hard drive image most likely must have a MBR.
Please don't listen to this advice. Forget about floppies already! We're in the XXI. century!

Don't waste your USB storage and limit its capacity to 1.44 M. If your BIOS has a floppy emulation option, turn it off; put a partitioning table in the first sector with 55AAh magic and the INT 13 / AH=42 lba packet reading will work, guaranteed. I've never seen any hw that didn't handle that. And if by any chance your hw won't handle USB storage like that, then you should update your BIOS anyway because it must have other bugs as well.

Cheers,
bzt
Klakap
Member
Member
Posts: 297
Joined: Sat Mar 10, 2018 10:16 am

Re: Is int 13 extension for usb?

Post by Klakap »

Thank a milion for all reply! It were very useful. After remove BPB BIOS emulate usb like hard disk with number 0x80 and all work fine.
Post Reply