PCI: Difference between revisions

1,982 bytes added ,  9 years ago
Added notes for detecting PCI config space access mechanism
[unchecked revision][unchecked revision]
(Added "access mechanism #2")
(Added notes for detecting PCI config space access mechanism)
Line 1:
==The PCI Bus==
The PCI ([http://en.wikipedia.org/wiki/Conventional_PCI Peripheral Component Interconnect]) bus was defined to establish a high performance and low cost local bus that would remain through several generations of products. By combining a transparent upgrade path from 132 MB/s (32-bit at 33 MHz) to 528 MB/s (64-bit at 66 MHz) and both 5 volt and 3.3 volt signaling environments, the PCI bus meets the needs of both low end desktop systems as well as that of high-end LAN servers. The PCI bus component and add-in card interface is processor independent, enabling an efficient transition to future processors, as well as use with multiple processor architectures. The disadvantage of the PCI bus is the limited number of electrical loads it can drive. A single PCI bus can drive a maximum of 10 loads. (Remember when counting the number of loads on the bus, a connector counts as one load and the PCI device counts as another, and sometimes two.)
 
 
==Configuration Space==
Line 11 ⟶ 12:
 
Systems must provide a mechanism that allows access to the PCI configuration space, as most CPUs do not have any such mechanism. This task is usually performed by the Host to PCI Bridge (Host Bridge). Two distinct mechanisms are defined to allow the software to generate the required configuration accesses. Configuration mechanism #1 is the preferred method, while mechanism #2 is provided for backward compatibility. Only configuration mechanism #1 will be described here, as it is the only access mechanism that will be used in the future.
 
 
===Configuration Space Access Mechanism #1===
Line 73 ⟶ 75:
}
</source>
 
 
===Configuration Space Access Mechanism #2===
Line 109 ⟶ 112:
 
Note that this limits the system to 16 devices per PCI bus.
 
 
===Memory Mapped PCI Configuration Space Access===
 
PCI Express introduced a new way to access PCI configuration space, where it's simply memory mapped and no IO ports are used. This access mechanism is described in [[PCI Express]].
 
Note that systems that do provide the memory mapped access mechanism are also required to support PCI access mechanism #1 for backward compatibility.
 
 
===Detecting Configuration Space Access Mechanism/s===
 
In general there are 4 cases:
* computer doesn't support PCI (either the computer is too old, or your OS is being run at some time in the future after PCI has been superseded)
* computer supports mechanism #2
* computer supports mechanism #1 but doesn't support the memory mapped access mechanism
* computer supports both mechanism #1 and the memory mapped access mechanism
 
For BIOS systems, "int 0x1A, BX=0xB101 (PCI BIOS presence check)" will tell you if the system uses mechanism #1 or mechanism #2. If this function doesn't exist you can't be sure if the computer supports PCI or not. If it says mechanism #1 is supported you won't know if the memory mapped access mechanism is also supported or not.
 
For UEFI systems, it's extremely safe to assume that mechanism #2 is not supported; and you can test to see if the computer supports PCI or not by checking to see if the "PCI bus support" protocol exists. If PCI is supported, there's no easy way to determine if (e.g.) the computer supports mechanism #1 or not.
 
For both BIOS and UEFI systems, you can check the ACPI tables to determine if the memory mapped access mechanism is supported.
 
This leaves a few cases uncovered (e.g. where you don't know if whether mechanism #1 or #2 are supported despite trying all of the above). For these cases the only option left is manual probing. This means 2 specific tests - whether mechanism #1 is supported, and if not whether mechanism #2 is supported. Please note that manual probing has risks; in that if there is no PCI (e.g. the system only has ISA) the IO port accesses might cause undefined behaviour (especially on systems where the ISA bus ignores highest 6 bits of the IO port address, where accessing IO port 0x0CF8 is the same as accessing IO port 0x00F8).
 
 
250

edits