Device Detection

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
PlayOS

Device Detection

Post by PlayOS »

Hi,

Does anyone know how to detect what devices are installed on a system, I know that you can detect up to two floppy disks using CMOS with the following code:

mov al, 0x10
out 0x70, al
cli
in al, 0x71
sti

format of al after this is done

High Nibble = Drive 0
Low Nibble = Drive 1

0000 = No Drive Present
0001 = 5.25" 360KB Drive
0010 = 5.25" 1.2MB Drive
0011 = 3.5" 720KB Drive
0100 = 3.5" 1.44MB Drive
0101 = 3.5" 2.88MB Drive
0110 = 3.5" 2.88MB Drive

Interrupts must be disabled (so I am told) to read this register. Does anyone know of other devices that are detectable through the CMOS or any other place.

Thanks.

PS: Bochs does not handle this properly, it will not crash but it does not return the true value, I had to reset the system and boot with my floppy and it worked properly.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Device Detection

Post by Pype.Clicker »

Curufir

Re:Device Detection

Post by Curufir »

I use this function to detect floppies and it works just fine under Bochs 1.4.1, I don't disable interrupts before using it though.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Device Detection

Post by Pype.Clicker »

doing cli - in - sti has little sense, anyway: anything can happen between out & in (i suppose the idea was to defend the code against some CMOS update by the timer interrupt)

if something is useful, it would be cli - out - in - sti
Warmaster199

Re:Device Detection

Post by Warmaster199 »

If you are wanting to detect installed devices, I suggest you look into the BIOS32 and ISAPnP Specifications. These bus extensions provide a way of detecting installed devices such as sound cards, mice, different keyboards, video cards, etc... Check out http://www.nondot.org/sabre/os
Post Reply