detecting devices? [bios development]

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
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

detecting devices? [bios development]

Post 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?
Tyler
Member
Member
Posts: 514
Joined: Tue Nov 07, 2006 7:37 am
Location: York, England

Post 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.
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Post by earlz »

so is the only way to do it chipset specific? I'm not talking right now about the plug and play stuff...
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Post 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
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.
Post Reply