Page 1 of 1
detecting devices? [bios development]
Posted: Sun Apr 08, 2007 9:02 am
by earlz
I am making my own bios for my emulator. I have hit a bit of a snag, I don't know how you would know if a device exists..
note that the hardware on my emulator is NOT fixed, sometimes a fdd might exist and sometimes it wont!
like, well how would I detect if there is an FDD, would I just read the appropriate ports to try to get the appropriate output, or is this dangerous?
and how do you get the base address of the ports?
Posted: Sun Apr 08, 2007 9:08 am
by Tyler
Depends on your virtual chipset, and whether or not you have virtual PCI. I guess technically you can do it any way you like, as it is all imaginary ports, but i advise getting the Floppy Controller data sheet.
Posted: Sun Apr 08, 2007 9:10 am
by earlz
so is the only way to do it chipset specific? I'm not talking right now about the plug and play stuff...
Posted: Sun Apr 08, 2007 10:44 am
by Brendan
Hi,
hckr83 wrote:so is the only way to do it chipset specific? I'm not talking right now about the plug and play stuff...
For floppies there's there floppy drive controller (FDC) and the devices attached to it (e.g. the disk drives - FDDs).
For the controller you could assume one (or 2) is present, do some sort of manual probing (see if the "identify" command works perhaps), or for PCI systems check the vendor ID and device ID of the "PCI to LPC bridge".
For floppies you can do manual probing (e.g. see if the device responds to a "recalibrate" command). For real computers the user has to tell the BIOS which floppy devices are present (via. the inbuilt BIOS setup utility) - the BIOS setup utility stores this information in the CMOS and uses it each time it boots. This means that you can also cheat - for e.g. make the emulator set values in the CMOS for the BIOS to use during boot. This is what Bochs does.
BTW the FDCs and FDDs predate Plug and Play - they completely suck for autodetection as they weren't designed for it to begin with, and manufacturers haven't bothered extending these devices since. There is an exception to this - the BIOS includes descriptions of FDCs in the ACPI AML code (which makes things much worse for people developing BIOS code, rather than actually helping).
Cheers,
Brendan