Page 1 of 1

Device Detection

Posted: Wed Sep 04, 2002 2:07 am
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.

Re:Device Detection

Posted: Wed Sep 04, 2002 2:44 am
by Pype.Clicker

Re:Device Detection

Posted: Wed Sep 04, 2002 9:03 am
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.

Re:Device Detection

Posted: Wed Sep 04, 2002 9:19 am
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

Re:Device Detection

Posted: Wed Sep 04, 2002 4:13 pm
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