Check available physical drives using BIOS int 13H

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
EvolSoft
Posts: 9
Joined: Mon Dec 07, 2015 3:34 am
Libera.chat IRC: evolsoft

Check available physical drives using BIOS int 13H

Post by EvolSoft »

Hi all, we've got another question about some problems with BIOS Disk I/O
Currently we wrote a simple function which converts logical drive letters (from A to Z) to the phyisical drive and then checks if it is available using BIOS int 13h function AH=04h (For A and B letters the equivalent physical drive is 00h and 01h then from letter C to letter Z the equivalent physical drive is 80H, etc...)
The function seems to work but on Bochs console there are some error logs.
Bochs Console Errors
Bochs Console Errors
So is there a better way to check BIOS available Physical Drives without seeing these errors?
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Check available physical drives using BIOS int 13H

Post by Brendan »

Hi,
EvolSoft wrote:So is there a better way to check BIOS available Physical Drives without seeing these errors?
Use "int 0x13, ah = 0x08, Get Drive Parameters" to find out how many hard drives there are, and to check the validity of each (floppy and hard) drive.


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.
User avatar
TightCoderEx
Member
Member
Posts: 90
Joined: Sun Jan 13, 2013 6:24 pm
Location: Grande Prairie AB

Re: Check available physical drives using BIOS int 13H

Post by TightCoderEx »

The equipment word bits 7 & 6 @ 0:410H will also indicate how many floppies are installed and @ 0:475H the number of fixed disks. I haven't investigated it toughly, but I believe there is more detailed information in SMBIOS also.
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: Check available physical drives using BIOS int 13H

Post by BrightLight »

To detect floppy drives, simply do this:

Code: Select all

mov ah, 8
mov dl, 0	; or 1 for the second floppy drive
int 0x13
jc NoFloppy
Do the same with hard drives, replacing 0 with 0x80. Notice that Bochs' console will show errors when the drive is not present. So if you have two hard drives, numbered 0x80 and 0x81, an error will display when you try to detect 0x82.
EDIT: I just noticed that Bochs' console log messages clearly say that the last possible hard disk is 0x87. So you can access a total of 2 floppy disks and 8 hard disks through BIOS, which is way more than enough.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
EvolSoft
Posts: 9
Joined: Mon Dec 07, 2015 3:34 am
Libera.chat IRC: evolsoft

Re: Check available physical drives using BIOS int 13H

Post by EvolSoft »

Thanks, we solved getting the number of hard disks from BIOS data area (0x40:0x75) and then we stopped the function loop when that number was reached
Post Reply