PCI Express: Difference between revisions

From OSDev.wiki
Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content added Content deleted
m (Added "In Progress" notice, adjusted the page description, added layout for what needs to/will be added.)
(Added a section on the Configuration Space Changes from PCI -- Not Completed.)
Line 1: Line 1:
The PCI Express bus is a high performance, general purpose I/O interconnect bus, and was designed for a range of computing platforms. One of the key improvements of PCI Express, over the [[PCI|PCI Local Bus]], is that it now uses a serial interface (compared to the parallel interface used by PCI). This improvement can be compared to the similiar serialization of the ATA interface.
The PCI Express bus is a backwards compatible, high performance, general purpose I/O interconnect bus, and was designed for a range of computing platforms. One of the key improvements of PCI Express, over the [[PCI|PCI Local Bus]], is that it now uses a serial interface (compared to the parallel interface used by PCI). This improvement can be compared to the similiar serialization of the ATA interface.


{{In Progress}}
{{In Progress}}
Line 9: Line 9:


==Extended Configuration Space==
==Extended Configuration Space==
The PCI Express bus extends the [[PCI#Configuration Space|Configuration Space]] from 256 bytes to 4096 bytes. This extended configuration space *cannot* be accessed using the legacy PCI method (through ports 0xCF8 and 0xCFC). Instead, an enhanced configuration mechanism is provided.
The PCI Express bus extends the [[PCI#Configuration Space|Configuration Space]] from 256 bytes to 4096 bytes. This extended configuration space *cannot* be accessed using the legacy PCI method (through ports 0xCF8 and 0xCFC). Instead, an [[#Enhanced Configuration Mechanism]] is provided.
===Changes from the PCI Configuration Space===
{| {{wikitable}}
|-
! Header Type !! Register (Offset) !! Bit Location !! Difference
|-
| rowspan="11" | All Headers
| rowspan="5" | Command Register (0x04)
| 3 || Special Cycle Enable: Does not apply to PCIe. Hardwired to 0.
|-
| 4 || Memory Write and Invalidate: Does not apply to PCIe. Hardwired to 0.
|-
| 5 || VGA Palette Snoop: Does not apply to PCIe. Hardwired to 0.
|-
| 7 || IDSEL Stepping/Wait Cycle Control: Does not apply to PCIe. Hardwired to 0.
|-
| 9 || Fast Back-to-Back Transactions Enable: Does not apply to PCIe. Hardwired to 0.
|-
| rowspan="4" | Status Register (0x06)
| 4 || Capabilities List: All PCIe devices are required to implement the capability structure. Hardwired to 1.
|-
| 5 || 66 MHz Capable: Does not apply to PCIe. Hardwired to 0.
|-
| 6 || Fast Back-to-Back Transactions Capable: Does not apply to PCIe. Hardwired to 0.
|-
| 10:9 || DEVSEL Timing: Does not apply to PCIe. Hardwired to 0.
|-
| Cache Line Size Register (0x0C) || All Bits || Implemented for legacy purposes only.
|-
| Master Latency Timer Register (0x0D) || All Bits || Does not apply to PCIe. Hardwired to 0.
|-
| rowspan="2" | Type 0
| Base Address Registers (0x10:0x24) || All Bits || PCIe Endpoint devices must set the BAR's prefetchable bit while the range does not contain memory with read side-effects or where the memory does not tolerate write merging. 64-Bit Addressing MUST be supported by non legacy Endpoint devices. The minimum memory address range requested by a BAR 128-bytes.
|-
| Min_Gnt/Max_Lat Registers (0x3E:0x3F) || All Bits || Does not apply to PCIe. Hardwired to 0.
|-
| rowspan="13" | Type 1
| Base Address Registers (0x10:0x24) || All Bits || PCIe Endpoint devices must set the BAR's prefetchable bit while the range does not contain memory with read side-effects or where the memory does not tolerate write merging. 64-Bit Addressing MUST be supported by non legacy Endpoint devices. The minimum memory address range requested by a BAR 128-bytes.
|-
| Primary Bus Number (0x18) || All Bits || Implemented for legacy purposes only.
|-
| Secondary Latency Timer (0x1B) || All Bits || Does not apply to PCIe. Hardwired to 0.
|-
| rowspan="3" | Secondary Status Register (0x1E)
| 5 || 66 MHz Capable: Does not apply to PCIe. Hardwired to 0.
|-
| 7 || Fast Back-to-Back Transactions Capable: Does not apply to PCIe. Hardwired to 0.
|-
| 10:9 || DEVSEL Timing: Does not apply to PCIe. Hardwired to 0.
|-
| Prefetchable Memory Base/Limit (0x24) || All Bits || Must indicate support for 64-bit addresses.
|-
| rowspan="6" | Bridge Control Register (0x3E)
| 5 || Master Abort Mode: Does not apply to PCIe. Hardwired to 0.
|-
| 7 || Fast Back-to-Back Transactions Enable: Does not apply to PCIe. Hardwired to 0.
|-
| 8 || Primary Discard Timer: Does not apply to PCIe. Hardwired to 0.
|-
| 9 || Secondary Discard Timer: Does not apply to PCIe. Hardwired to 0.
|-
| 10 || Discard Timer Status: Does not apply to PCIe. Hardwired to 0.
|-
| 11 || Discard Timer SERR# Enable: Does not apply to PCIe. Hardwired to 0.
|}
===Enhanced Configuration Mechanism===
===Enhanced Configuration Mechanism===
The enhanced configuration mechanism makes use of a flat memory-mapped address space to access it's device configuration registers. Put simply, the memory address is used to determine the register accessed. On the x86 and x64 platforms, the memory range's base address can be determined by reading Model Specific Register 0xC0010058 and masking all but bits 31:20 or bits 47:20, respectively. Note that if all but bits 5:2 are masked you can determine the number of busses in the MMIO configuration space. 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[28:20], device number[19:15], function number[14:12], extended register number[11:8], register number[7:2], offset [1:0] }.
The enhanced configuration mechanism makes use of a flat memory-mapped address space to access it's device configuration registers. Put simply, the memory address is used to determine the register accessed. On the x86 and x64 platforms, the memory range's base address can be determined by reading Model Specific Register 0xC0010058 and masking all but bits 31:20 or bits 47:20, respectively. Note that if all but bits 5:2 are masked you can determine the number of busses in the MMIO configuration space. 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[28:20], device number[19:15], function number[14:12], extended register number[11:8], register number[7:2], offset [1:0] }.

Revision as of 22:14, 9 April 2010

The PCI Express bus is a backwards compatible, high performance, general purpose I/O interconnect bus, and was designed for a range of computing platforms. One of the key improvements of PCI Express, over the PCI Local Bus, is that it now uses a serial interface (compared to the parallel interface used by PCI). This improvement can be compared to the similiar serialization of the ATA interface.

This page is a work in progress.
This page may thus be incomplete. Its content may be changed in the near future.

PCI Express Link

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

The PCI Express bus extends the Configuration Space from 256 bytes to 4096 bytes. This extended configuration space *cannot* be accessed using the legacy PCI method (through ports 0xCF8 and 0xCFC). Instead, an #Enhanced Configuration Mechanism is provided.

Changes from the PCI Configuration Space

Header Type Register (Offset) Bit Location Difference
All Headers Command Register (0x04) 3 Special Cycle Enable: Does not apply to PCIe. Hardwired to 0.
4 Memory Write and Invalidate: Does not apply to PCIe. Hardwired to 0.
5 VGA Palette Snoop: Does not apply to PCIe. Hardwired to 0.
7 IDSEL Stepping/Wait Cycle Control: Does not apply to PCIe. Hardwired to 0.
9 Fast Back-to-Back Transactions Enable: Does not apply to PCIe. Hardwired to 0.
Status Register (0x06) 4 Capabilities List: All PCIe devices are required to implement the capability structure. Hardwired to 1.
5 66 MHz Capable: Does not apply to PCIe. Hardwired to 0.
6 Fast Back-to-Back Transactions Capable: Does not apply to PCIe. Hardwired to 0.
10:9 DEVSEL Timing: Does not apply to PCIe. Hardwired to 0.
Cache Line Size Register (0x0C) All Bits Implemented for legacy purposes only.
Master Latency Timer Register (0x0D) All Bits Does not apply to PCIe. Hardwired to 0.
Type 0 Base Address Registers (0x10:0x24) All Bits PCIe Endpoint devices must set the BAR's prefetchable bit while the range does not contain memory with read side-effects or where the memory does not tolerate write merging. 64-Bit Addressing MUST be supported by non legacy Endpoint devices. The minimum memory address range requested by a BAR 128-bytes.
Min_Gnt/Max_Lat Registers (0x3E:0x3F) All Bits Does not apply to PCIe. Hardwired to 0.
Type 1 Base Address Registers (0x10:0x24) All Bits PCIe Endpoint devices must set the BAR's prefetchable bit while the range does not contain memory with read side-effects or where the memory does not tolerate write merging. 64-Bit Addressing MUST be supported by non legacy Endpoint devices. The minimum memory address range requested by a BAR 128-bytes.
Primary Bus Number (0x18) All Bits Implemented for legacy purposes only.
Secondary Latency Timer (0x1B) All Bits Does not apply to PCIe. Hardwired to 0.
Secondary Status Register (0x1E) 5 66 MHz Capable: Does not apply to PCIe. Hardwired to 0.
7 Fast Back-to-Back Transactions Capable: Does not apply to PCIe. Hardwired to 0.
10:9 DEVSEL Timing: Does not apply to PCIe. Hardwired to 0.
Prefetchable Memory Base/Limit (0x24) All Bits Must indicate support for 64-bit addresses.
Bridge Control Register (0x3E) 5 Master Abort Mode: Does not apply to PCIe. Hardwired to 0.
7 Fast Back-to-Back Transactions Enable: Does not apply to PCIe. Hardwired to 0.
8 Primary Discard Timer: Does not apply to PCIe. Hardwired to 0.
9 Secondary Discard Timer: Does not apply to PCIe. Hardwired to 0.
10 Discard Timer Status: Does not apply to PCIe. Hardwired to 0.
11 Discard Timer SERR# Enable: Does not apply to PCIe. Hardwired to 0.

Enhanced Configuration Mechanism

The enhanced configuration mechanism makes use of a flat memory-mapped address space to access it's device configuration registers. Put simply, the memory address is used to determine the register accessed. On the x86 and x64 platforms, the memory range's base address can be determined by reading Model Specific Register 0xC0010058 and masking all but bits 31:20 or bits 47:20, respectively. Note that if all but bits 5:2 are masked you can determine the number of busses in the MMIO configuration space. 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[28:20], device number[19:15], function number[14:12], extended register number[11:8], register number[7:2], offset [1:0] }.

getPCIBusRange:
    mov ecx, 0xC0010058    ; Set ECX to the register we need to read
    rdmsr                  ; Read the MMIO Configuratio Base Address Register
    and al, 0x3C           ; Mask everything but the bus range (bits 5:2)
    shr al, 2              ; Adjust to the proper value
    mov ah, 1              ; set AH to 1
    shl ah, al             ; AH <<= AL
    movzx eax, ah          ; Save the number of buses into EAX
    ret                    ; Return to the calling code

getMMIOBase:
    mov ecx, 0xC0010058    ; Set ECX to the register we need to read
    rdmsr                  ; Read the MMIO Configuratio Base Address Register
    xor ax, ax             ; Mask everythin but the base address (bits 47:20)
    ret                    ; Return to the calling code

readECS_BYTE:
    mov al, [esi]          ; Read byte from MMIO Address [ESI] into AL
    ret                    ; Return to the calling code

readECS_WORD:
    mov ax, [esi]          ; Read word from MMIO Address [ESI] into AX
    ret                    ; Return to the calling code

readECS_DWORD:
    mov eax, [esi]         ; Read dword from MMIO Address [ESI] into EAX
    ret                    ; Return to the calling code

writeECS_BYTE:
    mov [esi], al          ; Write byte from AL into MMIO Address [ESI]
    ret                    ; Return to the calling code

writeECS_WORD:
    mov [esi], ax          ; Write word from AX into MMIO Address [ESI]
    ret                    ; Return to the calling code

writeECS_DWORD:
    mov [esi], eax         ; Write dword from EAX into MMIO Address [ESI]
    ret                    ; Return to the calling code

System Architecture

Transaction Layer

Data Link Layer

Physical Layer

Power Management

See Also

References

  • PCI Express Base Specification, revision 1.1, PCI Special Interest Group, March 28, 2005

External Links