Finding Storage Devices
- Masterkiller
- Member
- Posts: 153
- Joined: Sat May 05, 2007 6:20 pm
Finding Storage Devices
Is there a way that BIOS could give me information what storage devices are installed at boot time in the computer. The idea is to get all possible devices from where user can load files. It is 100% suer that there is boot device from where operationg system has started, but in my case it is a CD-ROM so it is read-only (or possible writing could damage CD ). It is not effective to assume that you HDD is on IDE drive and try IDE controller. I still can test one by one controllers to find where device, but what if you motherboard don't have an IDE controller and I test it? So is there a wayto find all storage devices installed with BIOS and if it is possible, what controller to use to access to the device?
Well, there's the CMOS - theres a tutorial on how to use it to detect floppy drives on osdever.net - http://www.osdever.net/tutorials/detect ... drives.php
Hope it helped,
t6q4
Hope it helped,
t6q4
Last edited by t6q4 on Fri Nov 07, 2008 1:48 pm, edited 1 time in total.
Re: Finding Storage Devices
A few things to do. On bootup, the bios will give you which device it booted from in dx. 0x80 is first hd, 0x81 is second hd, 0x01 is first floppy, etc. I don't know if there is a function to check installed devices without a driver, but you can use the info from DX with int 13h to load the OS from the boot device, which has drivers to determine other storage devices. This method works fine for just about anything. And of course, your boot code on your floppy disk will have code to read a floppy, while your boot code on a hdd will have code to read a hdd, etc. I don't do my device detection until after my OS is loaded (well, in the process of loading), even though my OS can boot from just about any boot media (including USB devives if supported by bios).Masterkiller wrote:Is there a way that BIOS could give me information what storage devices are installed at boot time in the computer. The idea is to get all possible devices from where user can load files. It is 100% suer that there is boot device from where operationg system has started, but in my case it is a CD-ROM so it is read-only (or possible writing could damage CD ). It is not effective to assume that you HDD is on IDE drive and try IDE controller. I still can test one by one controllers to find where device, but what if you motherboard don't have an IDE controller and I test it? So is there a wayto find all storage devices installed with BIOS and if it is possible, what controller to use to access to the device?
Re: Finding Storage Devices
0x00 = first floppyReady4Dis wrote: A few things to do. On bootup, the bios will give you which device it booted from in dx. 0x80 is first hd, 0x81 is second hd, 0x01 is first floppy, etc.
0x01 = second floppy
- Masterkiller
- Member
- Posts: 153
- Joined: Sat May 05, 2007 6:20 pm
Thanks a lot! There is a lot of useful information in CMOS I can use (and now I can display a clock on a screen )t6q4 wrote:Well, there's the CMOS - theres a tutorial on how to use it to detect floppy drives on osdever.net - http://www.osdever.net/tutorials/detect ... drives.php
That is a good point, but what if the OS still has no drivers loaded Well that was the point. I always could load drivers from CD (from where OS boots) but the idea is to know what drivers to load. IDE? SCSI? USB? Where you are planing to read/write when the system goes into protected mode and there is no BIOS?Ready4Dis wrote:...to load the OS from the boot device, which has drivers to determine other storage devices...
Last edited by Masterkiller on Wed Jul 15, 2009 3:51 pm, edited 1 time in total.
You can use the PCI bus to enumerate all devices present. It will present you with a list of all devices, including the storage ones.Masterkiller wrote:the idea is to know what drivers to load. IDE? SCSI? USB? Where you are planing to read/write when the system goes into protected mode and there is no BIOS?
JAL
Hi,
Once you have detected all devices, you'll have no way to map between PCI devices and BIOS device numbers (except guessing). For example, the BIOS may tell you that your boot loader was started from device "0x00", which could be the first floppy, or could be the second floppy (with the "swap floppy drives" BIOS option enabled), or a CD-ROM, or a USB flash device, or a USB floppy drive, or some strange netboot/RAMdisk arrangement, or....
If it helps, I just use the BIOS (and the BIOS's drive numbers) to load everything I'll need into RAM while the BIOS is still usable; so that once I'm in protected mode I can "load" stuff from RAM instead of caring what the boot device was.
Cheers,
Brendan
You can scan the PCI bus and enumerate all PCI devices (which doesn't include ISA devices, like floppy).jal wrote:You can use the PCI bus to enumerate all devices present. It will present you with a list of all devices, including the storage ones.Masterkiller wrote:the idea is to know what drivers to load. IDE? SCSI? USB? Where you are planing to read/write when the system goes into protected mode and there is no BIOS?
Once you have detected all devices, you'll have no way to map between PCI devices and BIOS device numbers (except guessing). For example, the BIOS may tell you that your boot loader was started from device "0x00", which could be the first floppy, or could be the second floppy (with the "swap floppy drives" BIOS option enabled), or a CD-ROM, or a USB flash device, or a USB floppy drive, or some strange netboot/RAMdisk arrangement, or....
If it helps, I just use the BIOS (and the BIOS's drive numbers) to load everything I'll need into RAM while the BIOS is still usable; so that once I'm in protected mode I can "load" stuff from RAM instead of caring what the boot device was.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Hi,
In the "Enhanced Disk Drive Specification", see section 5.8.1 (Interface Path) and section 5.8.2 (device path). They describe 2 of the fields in the data structure returned by a "Get drive parameters" function. It should be possible to use this (if supported) to correctly identify the actual device the BIOS used to load your boot loader from; including things like (where appropriate) the base I/O port, bus, device, function, interface type, master/slave, logical unit number, GUID, WWN, etc.
It's late at night here, so I'm printing the "Enhanced Disk Drive Specification" so I can actually read it properly tommorrow - I can't remember reading this specification before (not sure if this means I've never read any of it, or if I read parts of it ages ago and forgot)...
Cheers,
Brendan
My apologies - I think I'm wrong!Brendan wrote:Once you have detected all devices, you'll have no way to map between PCI devices and BIOS device numbers (except guessing). For example, the BIOS may tell you that your boot loader was started from device "0x00", which could be the first floppy, or could be the second floppy (with the "swap floppy drives" BIOS option enabled), or a CD-ROM, or a USB flash device, or a USB floppy drive, or some strange netboot/RAMdisk arrangement, or....
In the "Enhanced Disk Drive Specification", see section 5.8.1 (Interface Path) and section 5.8.2 (device path). They describe 2 of the fields in the data structure returned by a "Get drive parameters" function. It should be possible to use this (if supported) to correctly identify the actual device the BIOS used to load your boot loader from; including things like (where appropriate) the base I/O port, bus, device, function, interface type, master/slave, logical unit number, GUID, WWN, etc.
It's late at night here, so I'm printing the "Enhanced Disk Drive Specification" so I can actually read it properly tommorrow - I can't remember reading this specification before (not sure if this means I've never read any of it, or if I read parts of it ages ago and forgot)...
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re: Finding Storage Devices
oops, that was a typo, you are correct.Dex wrote:0x00 = first floppyReady4Dis wrote: A few things to do. On bootup, the bios will give you which device it booted from in dx. 0x80 is first hd, 0x81 is second hd, 0x01 is first floppy, etc.
0x01 = second floppy
- Masterkiller
- Member
- Posts: 153
- Joined: Sat May 05, 2007 6:20 pm
Well, it seems that the BIOS comes in action again. So Ah=48h/INT 13h Get Drive Parametes BIOS extension (I'm absolutely sure that there will such function, because booting from CD requires these extension) check for the pointer to Enchanced Drive Parameters Structure. First word is the I/O address, second word is control address of the ports, so I don't have to know actually what interface use the "misterious" storage device, I just read/write to those ports. I am unsure about thatBrendan wrote:In the "Enhanced Disk Drive Specification", see section 5.8.1 (Interface Path) and section 5.8.2 (device path). They describe 2 of the fields in the data structure returned by a "Get drive parameters" function. It should be possible to use this (if supported) to correctly identify the actual device the BIOS used to load your boot loader from; including things like (where appropriate) the base I/O port, bus, device, function, interface type, master/slave, logical unit number, GUID, WWN, etc.
According to the Ralf Brawn Interrupt Table site there is version 3.0 that also displays ASCIZ name of interface type, but it seems my computer don't support it, neither is supported by MSVPC or Bochs.