PCI Express: Difference between revisions

Various changes (mainly to add information about "PCI Segment Groups" and clean up empty sections)
[unchecked revision][unchecked revision]
m (Reverted edits by Jackpot51 (talk) to last revision by Sortie)
(Various changes (mainly to add information about "PCI Segment Groups" and clean up empty sections))
Line 6:
The PCI Express bus connects each device directly to the CPU and other system devices through a pair of high speed unidirectional differential links (transmit and recieve, respectively). These links operate at an effective rate of 2.5 GB/s and a single device may have multiple links. A single device may have x1, x2, x4, x8, x12, x16, or x32 links and can achieve a maximum bandwidth of 80 GB/s by utilizing x32 links.
 
==Initialization==
 
==Extended Configuration Space==
Line 74 ⟶ 73:
| 11 || Discard Timer SERR# Enable: Does not apply to PCIe. Hardwired to 0.
|}
 
 
==Extended PCI Bus Numbering==
 
Older variations of PCI (e.g. "PCI Conventional") were limited to a maximum of 256 PCI bus segments. PCI Express extends this by introducing "PCI Segment Groups", where a system could (in theory) have up to 65536 PCI Segment Groups with 256 PCI bus segments per group, thereby allowing a single computer to have up to a maximum of 16777216 PCI bus segments.
 
PCI Segment Groups are numbered, and in most systems there is only one PCI Segment Group (PCI Segment Group number 0). Note that legacy PCI configuration space access mechanism #1 (which still exists for backward compatibility) has no "PCI Segment Group" field and therefore can only access the PCI configuration space for PCI Segment Group number 0. The Enhanced Configuration Mechanism must be used to access the PCI configuration space for any devices in other PCI Segment Groups.
 
 
===Enhanced Configuration Mechanism===
The enhanced configuration mechanism makes use of amemory flat memory-mapped address space range/s to access it's devicePCI configuration registersspace. Put simply, the memory address is used to determinedetermines the registersegment accessed.group, Therebus, is an area for each host controllerdevice, sofunction aand systemregister withbeing 2 PCI express host controllers uses 2 memory mapped areasaccessed. On x86 and x64 platforms, the address of each memory area is determined by the ACPI 'MCFG' table. The format of this ACPI table is:
 
{| {{wikitable}}
Line 129 ⟶ 137:
|}
 
To access a specific register within a device's PCI configuration space, you have to use the device's PCI Segment Group and bus to determine which memory mapped PCI configuration space area to use, and obtain the starting physical address and starting bus number for that memory mapped area. Once you have the correct starting physical address and starting bus number for that memory mapped area you would use the following formula to determine where the (4096-byte) area for a function's PCI configuration space is: <code>Physical_Address = MMIO_Starting_Physical_Address + ( (Bus - MMIO_Starting_Bus) << 20 | Device << 15 | Function << 12 )</code>.
After determining the MMIO base address and the total number of busses in the address space, you can read from the extended configuration address space. To access a specific register, you must use the following formula: Address = MMIO_BASE + { bus number[27:20], device number[19:15], function number[14:12], extended register number[11:8], register number[7:2], offset [1:0] }.
 
<source lang="asm">
readECS_BYTE:
mov al, [esi] ; Read uint8_t from MMIO Address [ESI] into AL
ret ; Return to the calling code
 
readECS_WORD:
mov ax, [esi] ; Read uint16_t from MMIO Address [ESI] into AX
ret ; Return to the calling code
 
readECS_DWORD:
mov eax, [esi] ; Read uint32_t from MMIO Address [ESI] into EAX
ret ; Return to the calling code
 
writeECS_BYTE:
mov [esi], al ; Write uint8_t from AL into MMIO Address [ESI]
ret ; Return to the calling code
 
writeECS_WORD:
mov [esi], ax ; Write uint16_t from AX into MMIO Address [ESI]
ret ; Return to the calling code
 
writeECS_DWORD:
mov [esi], eax ; Write uint32_t from EAX into MMIO Address [ESI]
ret ; Return to the calling code
</source>
 
==System Architecture==
 
==Transaction Layer==
 
Note that it may be a good idea to determine "physical address for this function's PCI configuration space" as part of PCI enumeration and store this physical address alongside any other information you're using to manage PCI devices and drivers (e.g. in your "device manager's" hierarchical tree of device info).
==Data Link Layer==
 
Also note that for absolute maximums (with 65536 PCI segment groups and 256 bus segments per segment group), the amount of physical address space consumed by memory mapped PCI configuration space ranges would be (up to) 16 TiB (or 2<sup>44</sup> bytes); and ACPI's "MCFG" table may (in theory) be slightly larger than 256 MiB (a 16-byte entry for each individual PCI bus within each PCI segment group plus the 36-byte table header).
==Physical Layer==
 
==Power Management==
 
==See Also==
250

edits