Page 1 of 1
Port ranges from PCI addresses
Posted: Tue Apr 13, 2010 1:49 pm
by ~
Is it possible somehow to "detect" I/O port ranges from a PCI port address, for example, determine which ranges a certain controller actually uses from base address port 0x1F0 and detect from PCI scanning that it uses 0x1F0 to 0x1F7?
How does Windows do it? Does the software driver actually tells this to Windows (which seems the most reasonable or possible)?
Can this be retrieved from the "I/O limit" and/or "Memory limit" fields, reliably, or is there some other ways?
Re: Port ranges from PCI addresses
Posted: Tue Apr 13, 2010 2:05 pm
by Gigasoft
The BAR registers tell the base address of I/O and memory ranges, and the size is determined by setting them to all ones and reading them back. Some devices (such as VGA adapters) may use other I/O port ranges that are not covered by the BARs. In this case, they are often initially disabled and the driver must enable the ranges. The driver should also report these ranges before enabling them so that two devices won't use the same port ranges.
Re: Port ranges from PCI addresses
Posted: Tue Apr 13, 2010 4:49 pm
by Combuster
In practice, you'll have to keep a list of all devices with their quirks to know what ports they do or do not respond to. You can use a heuristic based on the class code - VGA compatible controllers will respond to 3B0-3DF, IDE controllers will respond to their range. Since they are initialized upon boot, you can't prevent them from enabling such decoding. Several devices can't be taken off such ranges without disabling them entirely, and some can't or shouldn't be disabled. (Try to figure out what ports the southbridge silently uses, and how you can (not) disable that behaviour)
Short answer: the only correct method is to keep tabs on each piece of hardware on what they do without telling you. But you can get a long way with guesswork.