Header Type 0
General
Figure 22-1 on page 771 illustrates the format of a function's Header region (for functions other than PCI-to-PCI bridges and CardBus bridges). The registers marked in black are always mandatory. Note that although many of the configuration registers in the figure are not marked mandatory, a register may be mandatory for a particular type of device. The subsequent sections define each register and any circumstances wherein it may be mandatory.

As noted earlier, this format is defined as Header Type 0. The registers within the Header are used to identify the device, to control its functionality and to sense its status in a generic manner. The usage of the device's remaining 48 dwords of PCI-compatible configuration space is intended for device-specific registers, but, with the advent of the 2.2 PCI spec, is also used as an overflow area for some new registers defined in the PCI spec (for more information, refer to "Capabilities Pointer Register" on page 779).
Header Type 0 Registers Compatible With PCI
The Header Type 0 PCI configuration registers that are implemented and used identically in PCI and PCI Express are:
Vendor ID register. Device ID register. Revision ID register. Class Code register. Subsystem Vendor ID register. Subsystem ID register. Header Type register. BIST register. Capabilities Pointer register. CardBus CIS Pointer register. Expansion ROM Base Address register.
The sections that follow provide a description of each of these registers.
Header Type 0 Registers Incompatible With PCI
In a non-bridge PCI Express function, the definitions of the following configuration registers in the function's PCI-compatible configuration space differ from the PCI spec's definition of the respective register definitions:
The sections that follow define the implementation/usage differences of these registers. For a full description of their implementation in a PCI function, refer to the MindShare book entitled PCI System Architecture, Fourth Edition (published by Addison-Wesley). For a full description of their implementation in a PCI-X function, refer to the MindShare book entitled PCI-X System Architecture, First Edition (published by Addison-Wesley).
Registers Used to Identify Device's Driver
The OS uses some combination of the following mandatory registers to determine which driver to load for a device:
Vendor ID. Device ID. Revision ID. Class Code. SubSystem Vendor ID. SubSystem ID.
Vendor ID Register
PCI-Compatible register. Always mandatory. This 16-bit register identifies the manufacturer of the function. The value hardwired in this read-only register is assigned by a central authority (the PCI SIG) that controls issuance of the numbers. The value FFFFh is reserved and must be returned by the Host/PCI bridge when an attempt is made to perform a configuration read from a configuration register in a non-existent function. In PCI or PCI-X, the read attempt results in a Master Abort, while in PCI Express it results in the return of UR (Unsupported Request) completion status. In either case, the bridge must return a Vendor ID of FFFFh. The error status returned is not considered to be an error, but the specification says that the bridge must nonetheless set its Received Master Abort bit in its configuration Status register.
Device ID Register
PCI-Compatible register. Always mandatory. This 16-bit value is assigned by the function manufacturer and identifies the type of function. In conjunction with the Vendor ID and possibly the Revision ID, the Device ID can be used to locate a function-specific (and perhaps revision-specific) driver for the function.
Revision ID Register
PCI-Compatible register. Always mandatory. This 8-bit value is assigned by the function manufacturer and identifies the revision number of the function. If the vendor has supplied a revision-specific driver, this is handy in ensuring that the correct driver is loaded by the OS.
Class Code Register
General
PCI-Compatible register. Always mandatory. The Class Code register is pictured in Figure 22-2 on page 775. It is a 24-bit, read-only register divided into three fields: base Class, Sub Class, and Programming Interface. It identifies the basic function of the function (e.g., a mass storage controller), a more specific function sub-class (e.g., IDE mass storage controller), and, in some cases, a register-specific programming interface (such as a specific flavor of the IDE register set).
The upper byte defines the base Class of the function, the middle byte defines a sub-class within the base Class, and the lower byte defines the Programming Interface.

The currently-defined base Class codes are listed in Table 22-1 on page 775. Table 2 on page 1020 through Table 19 on page 1031 define the Subclasses within each base Class. For many Class/SubClass categories, the Programming Interface byte is hardwired to return zeros (in other words, it has no meaning). For some, such as VGA-compatible functions and IDE controllers, it does have meaning.
This register is useful when the OS is attempting to locate a function that a Class driver can work with. As an example, assume that a particular device driver has been written to work with any display adapter that is 100% XGA register set-compatible. If the OS can locate a function with a Class of 03h (see Table 22-1 on page 775) and a Sub Class of 01h (see Table 5 on page 1022), the driver will work with that function. A Class driver is more flexible than a driver that has been written to work only with a specific function from a specific vendor.
The Programming Interface Byte
For some functions (such as the XGA display adapter used as an example in the previous section) the combination of the Class Code and Sub Class Code is sufficient to fully-define its level of register set compatibility. The register set layout for some function types, however, can vary from one implementation to another. As an example, from a programming interface perspective there are a number of flavors of IDE mass storage controllers, so it's not sufficient to identify yourself as an IDE mass storage controller. The Programming Interface byte value (see Table 20 on page 1031) provides the final level of granularity that identifies the exact register set layout of the function.
Detailed Class Code Description
A detailed description of the currently-defined Classes, SubClasses, and Programming Interface Byte values can be found in Appendix D.
Table 22-1. Defined Class Codes|
00h | Function built before class codes were defined (in other words: before rev 2.0 of the PCI spec). | 01h | Mass storage controller. | 02h | Network controller. | 03h | Display controller. | 04h | Multimedia device. | 05h | Memory controller. | 06h | Bridge device. | 07h | Simple communications controllers. | 08h | Base system peripherals. | 09h | Input devices. | 0Ah | Docking stations. | 0Bh | Processors. | 0Ch | Serial bus controllers. | 0Dh | Wireless controllers. | 0Eh | Intelligent IO controllers. | 0Fh | Satellite communications controllers. | 10h | Encryption/Decryption controllers. | 11h | Data acquisition and signal processing controllers. | 12h-FEh | Reserved. | FFh | Device does not fit any of the defined class codes. |
Subsystem Vendor ID and Subsystem ID Registers
General
PCI-Compatible register. Mandatory. This register pair was added in revision 2.1 of the PCI spec and was optional. The 2.2 PCI spec and the PCI-X spec state that they are mandatory except for those functions that have a base Class of 06h (a Bridge) with a Sub Class of 00h-04h (refer to Table 8 on page 1023), or a base Class of 08h (Base System Peripherals) with a Sub Class of 00h-03h (see Table 10 on page 1026). This excludes bridges of the following types:
Host/PCI PCI-to-EISA PCI-to-ISA PCI-to-Micro Channel PCI-to-PCI
It also excludes the following generic system peripherals:
Interrupt Controller DMA Controller Programmable Timers RTC Controller
The Subsystem Vendor ID is obtained from the SIG, while the vendor supplies its own Subsystem ID (the full name of this register is really "Subsystem Device ID", but the "device" is silent). A value of zero in these registers indicates there isn't a Subsystem Vendor and Subsystem ID associated with the function.
The Problem Solved by This Register Pair
A function may reside on a card or within an embedded device. Functions designed around the same PCI/PCI-X, or PCI Express core logic (produced by a third-party) may have the same Vendor and Device IDs (if the core logic vendor hardwired their own IDs into these registers). If this is the case, the OS would have a problem identifying the correct driver to load into memory for the function.
These two mandatory registers (Subsystem Vendor ID and Subsystem ID) are used to uniquely identify the add-in card or subsystem that the function resides within. Using these two registers, the OS can distinguish the difference between cards or subsystems manufactured by different vendors but designed around the same third-party core logic. This permits the Plug-and-Play OS to locate the correct driver to load into memory.
Must Contain Valid Data When First Accessed
These two registers must contain their assigned values before the system first accesses them. If software attempts to access them before they have been initialized, the device must issue:
The values in these registers could be hardwired, loaded from a serial EEPROM, determined from hardware strapping pins, etc.
Header Type Register
PCI-Compatible register. Always mandatory. Figure 22-3 on page 778 illustrates the format of the Header Type register. Bits [6:0] of this one byte register define the format of dwords 4-through-15 of the function's configuration Header (see Figure 22-1 on page 771 and Figure 22-13 on page 803). In addition, bit seven defines the device as a single- (bit 7 = 0) or multifunction (bit 7 = 1) device. During configuration, the programmer determines if there are any other functions in this device that require configuration by testing the state of bit seven.


Currently, the only Header formats defined other than that pictured in Figure 22-1 on page 771 (Header Type Zero) are:
Header Type One (PCI-to-PCI bridge Header format; description can be found in "Header Type 1" on page 802). and Header Type Two (CardBus bridge; detail can be found in the PC Card specification and in the MindShare book entitled CardBus System Architecture (published by Addison-Wesley).
Future versions of the specification may define other formats.
BIST Register
PCI-Compatible register. Optional. This register may be implemented by both Requester and Completer functions. If a function implements a Built-In Self-Test (BIST), it must implement this register as illustrated in Figure 22-4 on page 778. Table 22-2 on page 779 describes each bit's function. If the function doesn't support a BIST, this register must return zeros when read. The function's BIST is invoked by setting bit six to one. The function resets bit six upon completion of the BIST. Configuration software must fail the function if it doesn't reset bit six within two seconds. At the conclusion of the BIST, the test result is indicated in the lower four bits of the register. A completion code of zero indicates successful completion. A non-zero value represents a function-specific error code.

The time limit of two seconds may not be sufficient time to test a very complex function or one with an extremely large buffer that needs to be tested. In that case, the remainder of the test could be completed in the initialization portion of the function's device driver when the OS loads it into memory and calls it.
Table 22-2. BIST Register Bit Assignment|
3:0 | Completion Code.
A value of zero indicates successful completion, while a non-zero result indicates a function-specific error. | 5:4 | Reserved. | 6 | Start BIST.
Writing a one into this bit starts the function's BIST. The function resets this bit automatically upon completion. Software should fail the function if the BIST does not complete within two seconds. | 7 | BIST Capable.
Should return a one if the function implements a BIST, a zero if it doesn't. |
Capabilities Pointer Register
PCI-Compatible register. Optional for a PCI function. Mandatory for a PCI-X or PCI Express function.
Configuration Header Space Not Large Enough
The 2.1 PCI spec defined the first 16 dwords of a function's PCI-compatible configuration space as its configuration Header space. It was originally intended that all of the function's PCI spec-defined configuration registers would reside within this region and that all of its function-specific configuration registers would reside within the lower 48 dwords of its PCI-compatible configuration space. Unfortunately, they ran out of space when defining new configuration registers in the 2.2 PCI spec. For this reason, the 2.2 and 2.3 PCI specs permit some spec-defined registers to be implemented in the lower 48 dwords of a function's PCI-compatible configuration space.
Discovering That Capabilities Exist
If the Capabilities List bit in the Status register (see Figure 22-5 on page 780) is set to one, the function implements the Capabilities Pointer register in byte zero of dword 13 in its PCI-compatible configuration space (see Figure 22-1 on page 771). This implies that the pointer contains the dword-aligned start address of the Capabilities List within the function's lower 48 dwords of PCI-compatible configuration space. It is a rule that the two least-significant bits must be hardwired to zero and must be ignored (i.e., masked) by software when reading the register. The upper six bits represents the upper six bits of the 8-bit, dword-aligned start address of the new registers implemented in the lower 48 dwords of the function's PCI-compatible space. The two least-significant bits are assumed to be zero.

What the Capabilities List Looks Like
The configuration location pointed to by the Capabilities Pointer register is the first entry in a linked series of one or more configuration register sets, each of which supports a feature. Each entry has the general format illustrated in Figure 22-6 on page 782. The first byte is referred to as the Capability ID (assigned by the PCI SIG) and identifies the feature associated with this register set (e.g., 2 = AGP), while the second byte either points to another feature's register set, or indicates that there are no additional register sets (with a pointer value of zero) associated with this function. In either case, the least-significant two bits must return zero. If a pointer to the next feature's register set is present in the second byte, it points to a dword within the function's lower 48 dwords of PCI-compatible configuration space (it can point either forward or backward in the function's configuration space). The respective feature's register set always immediately follows the first two bytes of the entry, and its length and format are defined by what type of feature it is. The Capabilities currently defined in the 2.3 PCI spec are those listed in Table 22-3 on page 781.

Table 22-3. Currently-Assigned Capability IDs|
00h | Reserved. | 01h | PCI Power Management Interface.
Refer to "The PM Capability Register Set" on page 585. | 02h | AGP.
Refer to "AGP Capability" on page 845. Also refer to the MindShare book entitled AGP System Architecture, Second Edition (published by Addison-Wesley). | 03h | VPD.
Refer to "Vital Product Data (VPD) Capability" on page 848. | 04h | Slot Identification.
This capability identifies a bridge that provides external expansion capabilities (i.e., an expansion chassis containing add-in card slots). Full documentation of this feature can be found in the revision 1.1 PCI-to-PCI Bridge Architecture Specification. For a detailed, Express-oriented description, refer to "Introduction To Chassis/Slot Numbering Registers" on page 859 and "Chassis and Slot Number Assignment" on page 861. | 05h | Message Signaled Interrupts.
Refer to "The MSI Capability Register Set" on page 332. | 06h | CompactPCI Hot Swap.
Refer to the chapter entitled Compact PCI and PMC in the MindShare book entitled PCI System Architecture, Fourth Edition (published by Addison-Wesley). | 07h | PCI-X device.
For a detailed description, refer to the MindShare book entitled PCI-X System Architecture (published by Addison-Wesley). | 08h | Reserved for AMD. | 09h | Vendor Specific capability register set.
The layout of the register set is vendor specific, except that the byte immediately following the "Next" pointer indicates the number of bytes in the capability structure (including the ID and Next pointer bytes). An example vendor specific usage is a function that is configured in the final manufacturing steps as either a 32-bit or 64-bit PCI agent and the Vendor Specific capability structure tells the device driver which features the device supports. | 0Ah | Debug port. | 0Bh | CompactPCI central resource control.
A full definition of this capability can be found in the PICMG 2.13 Specification (http://www.picmg.com). | 0Ch | PCI Hot-Plug.
This ID indicates that the associated device conforms to the Standard Hot-Plug Controller model. | 0Dh-0Fh | Reserved. | 10h | PCI Express Capability register set (aka PCI Express Capability Structure).
For a detailed explanation, refer to "PCI Express Capability Register Set" on page 896. | 11h-FFh | Reserved. |
CardBus CIS Pointer Register
PCI-Compatible register. Optional. This optional register is implemented by functions that share silicon between a Cardbus device and a PCI or PCI Express function. This field points to the Card Information Structure (CIS) on the CardBus card. The register is read-only and indicates that the CIS can be accessed from the indicated offset within one of the following address spaces:
Offset within the function's function-specific PCI-compatible configuration space (after dword 15d in the function's PCI-compatible configuration space). Offset from the start address indicated in one of the function's Memory Base Address Registers (see Figure 22-10 on page 796 and Figure 22-11 on page 797).


Offset within a code image in the function's expansion ROM (see "Expansion ROM Base Address Register" on page 783 and "Expansion ROMs" on page 871).
The format of the CardBus CIS Pointer register is defined in the revision 3.0 PC Card specification. A detailed description of the CIS can be found in the MindShare architecture series book entitled CardBus System Architecture (published by Addison-Wesley).
Expansion ROM Base Address Register
PCI-Compatible register. Required if a function incorporates a device ROM. Many PCI functions incorporate a device ROM (the spec refers to it as an expansion ROM) that contains a device driver for the function. The expansion ROM start memory address and size is specified in the Expansion ROM Base Address Register at configuration dword 12d in the configuration Header region. As described in the section entitled "Base Address Registers" on page 792, on power-up the system must be automatically configured so that each function's IO and memory decoders recognize mutually-exclusive address ranges. The configuration software must be able to detect how much memory space an expansion ROM requires. In addition, the system must have the capability of programming a ROM's address decoder in order to locate its ROM in a non-conflicting address range.
When the start-up configuration program detects that a function has an Expansion ROM Base Address Register implemented (by writing all ones to it and reading it back), it must then check the first two locations in the ROM for an Expansion ROM signature to determine if a ROM is actually installed (i.e., there may be an empty ROM socket). If installed, the configuration program must shadow the ROM and execute its initialization code. This process is described in "Expansion ROMs" on page 871.
The format of the expansion ROM Base Address Register is illustrated in Figure 22-7 on page 785:
A one in bit zero enables the function's ROM address decoder (assuming that the Memory Space bit in the Command register is also set to one). Bits [10:1] are reserved. Bits [31:11] are used to specify the ROM's start address (starting on an address divisible by the ROM's size).

As an example, assume that the programmer writes FFFFFFFEh to the ROM's Base Address Register (bit 0, the Expansion ROM Enable bit, is cleared so as not to enable the ROM address decoder until a start memory address has been assigned). A subsequent read from the register in the example yields FFFE0000h. This indicates the following:
Bit 0 is a zero, indicating that the ROM address decoder is currently disabled. Bits [10:1] are reserved. In the Base Address field (bits [31:11]), bit 17 is the least-significant bit that the programmer was able to set to one. It has a binary-weighted value of 128K, indicating that the ROM decoder requires 128KB of memory space be assigned to the ROM. The programmer then writes a 32-bit start address into the register to assign the ROM start address on a 128K address boundary.
The PCI 2.3 spec recommends that the designer of the Expansion ROM Base Address Register should request a memory block slightly larger than that required by the current revision ROM to be installed. This permits the installation of subsequent ROM revisions that occupy more space without requiring a redesign of the logic associated with the function's Expansion ROM Base Address Register. The spec sets a limit of 16MB as the maximum expansion ROM size.
The Memory Space bit in the Command register has precedence over the Expansion ROM Enable bit. The function's expansion ROM should respond to memory accesses only if both its Memory Space bit (in its Command register) and the Expansion ROM Enable bit (in its expansion ROM Base Address register) are both set to one.
In order to minimize the number of address decoders that a function must implement, one address decoder can be shared between the Expansion ROM Base Address Register and one of the function's Memory Base Address Registers. The two Base Address Registers must be able to hold different values at the same time, but the address decoder will not decode ROM accesses unless the Expansion ROM Enable bit is set in the Expansion ROM Base Address Register.
A more detailed description of expansion ROM detection, shadowing and usage can be found in "Expansion ROMs" on page 871.
Command Register
Differs from the PCI spec. Mandatory.
Refer to Figure 22-8 on page 785. Table 22-4 on page 786 provides a description of each bit in the Command register of a non-bridge function (i.e., one with a Type 0 Header format).

Table 22-4. Command Register|
0 | RW | IO Address Space Decoder Enable.
• Endpoints: - 0. IO decoder is disabled and IO transactions targeting this device are not recognized. - 1. IO decoder is enabled andIO transactions targeting this device are accepted.
| 1 | RW | Memory Address Space Decoder Enable.
| 2 | RW | Bus Master Enable.
Endpoints: - 0. Disables an Endpoint function from issuing memory or IO requests. Also disables the ability to generate MSI messages. - 1. Enables the Endpoint to issue memory or IO requests, including MSI messages. - Requests other than memory or IO requests are not controlled by this bit. - Default =0. - Hardwired to 0 if an Endpoint function does not generate memory or IO requests.
Root and Switch Port: - Controls the forwarding of memory or IO requests by a Switch or Root Port in the upstream direction. - 0. Memory and IO requests received at a Root Port or the downstream side of a Switch port must return an Unsupported Requests (UR) Completion. - Does not affect the forwarding of Completions in either the upstream or downstream direction. - Does not control the forwarding of requests other than memory or IO requests. - Default value of this bit is 0b.
| 3 | RO | Special Cycle Enable.
Does not apply to PCI Express and must be 0. | 4 | RO | Memory Write and Invalidate.
Does not apply to PCI Express and must be 0. | 5 | RO | VGA Palette Snoop.
Does not apply to PCI Express and must be 0. | 6 | RW | Parity Error Response.
In the Status register (see Figure 22-5 on page 780), the Master Data Parity Error bit is set by a Requester if its Parity Error Response bit is set and either of the following two conditions occurs:
If the Parity Error Response bit is cleared, the Master Data Parity Error status bit is never set.
The default value of this bit is 0. | 7 | RO | IDSEL Stepping/Wait Cycle Control.
Does not apply to PCI Express and must be 0. | 8 | RW | SERR Enable.
When set, this bit enables the non-fatal and fatal errors detected by the function to be reported to the Root Complex. The function reports such errors to the Root Complex if it is enabled to do so either through this bit or through the PCI Express specific bits in the Device Control register (see "Device Control Register" on page 905). The default value of this bit is 0. | 9 | RO | Fast Back-to-Back Enable.
Does not apply to PCI Express and must be 0. | 10 | RW | Interrupt Disable.
Controls the ability of a PCI Express function to generate INTx interrupt messages.
If the function had already transmitted any Assert_INTx emulation interrupt messages and this bit is then set, it must transmit a corresponding Deassert_INTx message for each assert message transmitted earlier.
Note that INTx emulation interrupt messages forwarded by Root and Switch Ports from devices downstream of the Root or Switch Port are not affected by this bit. The default value of this bit is 0. |
Status Register
Differs from the PCI spec. Mandatory.
Table 22-5 on page 789 provides a description of each bit in the Status register (also refer to Figure 22-9 on page 788). The bit fields with the RW1C attribute have the following characteristics:

Table 22-5. Status Register|
3 | RO | Interrupt Status.
Indicates that the function has an interrupt request outstanding (that is, the function transmitted an interrupt message earlier in time and is awaiting servicing).
Note that INTx emulation interrupts forwarded by Root and Switch Ports from devices downstream of the Root or Switch Port are not reflected in this bit. The default state of this bit is 0. Note : this bit is only associated with INTx messages, and has no meaning if the device is using Message Signaled Interrupts. | 4 | RO | Capabilities List.
Indicates the presence of one or more extended capability register sets in the lower 48 dwords of the function's PCI-compatible configuration space. Since, at a minimum, all PCI Express functions are required to implement the PCI Express capability structure, this bit must be set to 1. | 5 | RO | 66MHz-Capable.
Does not apply to PCI Express and must be 0. | 7 | RO | Fast Back-to-Back Capable.
Does not apply to PCI Express and must be 0. | 8 | RW1C | Master Data Parity Error.
The Master Data Parity Error bit is set by a Requester if the Parity Error Enable bit is set in its Command register and either of the following two conditions occurs:
If the Parity Error Enable bit is cleared, the Master Data Parity Error status bit is never set.
The default value of this bit is 0. | 10:9 | RO | DEVSEL Timing.
Does not apply to PCI Express and must be 0. | 11 | RW1C | Signaled Target Abort.
This bit is set when a function acting as a Completer terminates a request by issuing Completer Abort Completion Status to the Requester.
The default value of this bit is 0. | 12 | RW1C | Received Target Abort.
This bit is set when a Requester receives a Completion with Completer Abort Completion Status.
The default value of this bit is 0. | 13 | RW1C | Received Master Abort.
This bit is set when a Requester receives a Completion with Unsupported Request Completion Status.
The default value of this bit is 0. | 14 | RW1C | Signaled System Error.
This bit is set when a function sends an ERR_FATAL or ERR_NONFATAL message, and the SERR Enable bit in the Command register is set to one.
The default value of this bit is 0. | 15 | RW1C | Detected Parity Error.
Regardless of the state the Parity Error Enable bit in the function's Command register, this bit is set if the function receives a Poisoned TLP.
The default value of this bit is 0. |
Cache Line Size Register
Differs from the PCI spec. Optional.
This field is implemented by PCI Express devices as a read-write field for legacy compatibility purposes but has no impact on any PCI Express device functionality.
Master Latency Timer Register
Differs from the PCI spec. Optional.
This register does not apply to PCI Express and must be hardwired to 0.
Interrupt Line Register
Differs from the PCI spec. Optional.
Usage In a PCI Function
Required if a PCI function is capable of generating interrupt requests via an INTx# pin (i.e., INTA#, INTB#, INTC#, or INTD#). The PCI spec allows a function to generate interrupts either using an interrupt pin, or using MSI-capability (for more information, see "Message Signaled Interrupts" on page 331).
The read/writable Interrupt Line register is used to identify which input on the interrupt controller the function's PCI interrupt request pin (as specified in its Interrupt Pin register; see "Interrupt Pin Register" on page 792) is routed to. For example, in a PC environment the values 00h-through-0Fh in this register correspond to the IRQ0-through-IRQ15 inputs on the interrupt controller. The value 255d (FFh) indicates "unknown" or "no connection." The values from 10h-through-FEh, inclusive, are reserved. Although it doesn't state this in the PCI spec, it is the author's opinion that RST# should initialize the Interrupt Line register to a value of FFh, thereby indicating that interrupt routing has not yet been assigned to the function.
The OS or device driver can examine a device's Interrupt Line register to determine which system interrupt request line the device uses to issue requests for service (and, therefore, which entry in the interrupt table to "hook").
In a non-PC environment, the value written to this register is architecture-specific and therefore outside the scope of the specification.
Usage In a PCI Express Function
A PCI Express function may generate interrupts in the legacy PCI/PCI-X manner. As an example, when a PCI Express-to-PCI or PCI-X bridge detects the assertion or deassertion of one of its INTA#, INTB#, INTC#, or INTD# inputs on the legacy side of the bridge, it sends an INTx Assert or Deassert message upstream towards the Root Complex (specifically, to the interrupt controller within the Root Complex).
As in PCI, the Interrupt Line register communicates interrupt line routing information. The register is read/write and must be implemented by any function that contains a valid non-zero value in its Interrupt Pin configuration register (described in the next section). The OS or device driver can examine a device's Interrupt Line register to determine which system interrupt request line the device uses to issue requests for service (and, therefore, which entry in the interrupt table to "hook").
In a non-PC environment, the value written to this register is architecture-specific and therefore outside the scope of the specification.
Interrupt Pin Register
Differs from the PCI spec. Optional.
Usage In a PCI Function
Required if a PCI function is capable of generating interrupt requests via an INTx# pin. The PCI spec allows a function to generate interrupts either using an interrupt pin, or using MSI-capability (for more information, see "Two Methods of Interrupt Delivery" on page 330).
The read-only Interrupt Pin register defines which of the four PCI interrupt request pins, INTA#-through-INTD#, a PCI function is connected (i.e., bonded) to. The values 01h-through-04h correspond to PCI interrupt request pins INTA#-through-INTD#. A return value of zero indicates that the device doesn't generate interrupts. All other values (05h-FFh) are reserved.
Usage In a PCI Express Function
This read-only register identifies the legacy INTx interrupt Message (INTA, INTB, INTC, or INTD) the function transmits upstream to generate an interrupt. The values 01h-through-04h correspond to legacy INTx interrupt Messages INTA-through-INTD. A return value of zero indicates that the device doesn't generate interrupts using the legacy method. All other values (05h-FFh) are reserved. Note that, although the function may not generate interrupts via the legacy method, it may generate them via the MSI method (see "Determining if a Function Uses INTx# Pins" on page 343 for more information).
Base Address Registers
Differ from the PCI spec. Required if a function implements memory and/or IO decoders.
Introduction
Virtually all functions implement some memory, and/or a function-specific register set to control the function and sense its status. Some examples are:
A parallel port's Status, Command and Data registers could reside in IO or memory-mapped IO space. A network interface's control registers (Command/Status, etc.) could reside in IO or memory-mapped IO space. The network interface may also incorporate a RAM memory buffer that must be mapped into the system's memory space. In addition, a ROM containing the function's BIOS and interrupt service routine may be present in a function.
On power-up, the system must be automatically configured so that each function's IO and memory functions occupy mutually-exclusive address ranges. In order to accomplish this, the system must be able to detect how many memory and IO address ranges a function requires and the size of each. Obviously, the system must then be able to program the function's address decoders in order to assign non-conflicting address ranges to them.
The Base Address Registers (BARs), located in dwords 4-through-9 of the function's configuration Header space (see Figure 22-1 on page 771), are used to implement a function's programmable memory and/or IO decoders. Each register is 32-bits wide (or 64-bits wide if it's a memory decoder and its associated memory block can be located above the 4GB address boundary). Figure 22-10 on page 796, Figure 22-11 on page 797, and Figure 22-12 on page 798 illustrate the three possible formats of a Base Address Register. Bit 0 is a read-only bit and indicates whether it's a memory or an IO decoder:
If bit 0 = 0, the register is a memory address decoder. If bit 0 = 1, the register is an IO address decoder.

Decoders may be implemented in any of the Base Address Register positions. If more than one decoder is implemented, there may be holes. During configuration, the configuration software must therefore look at all six of the possible Base Address Register positions in a function's Header to determine which registers are actually implemented.
IO Space Usage
In a PC environment, IO space is densely populated and will only become more so in the future. For this reason and because some processors are only capable of performing memory transactions, the following rules related to IO space usage are defined in the PCI Express spec:
Native PCI Express Endpoint Function (as indicated by a value of 0000b in the Device/Port Type field in the function's PCI Express Capabilities Register; see Figure 22-31 on page 865). Some operating systems and/or processors may not support IO accesses (i.e., accesses using IO rather than memory addresses). This being the case, the designer of a native PCI Express function should avoid the use of IO BARs.

However, the target system that a function is designed for may use the function as one of the boot devices (i.e., the boot input device, output display device, or boot mass storage device) and may utilize a legacy device driver for the function at startup time. The legacy driver may assume that the function's device-specific register set resides in IO space. In this case, the function designer would supply an IO BAR to which the configuration software will assign an IO address range. When the OS boot has completed and the OS has loaded a native PCI Express driver for the function, however, the OS may deallocate all legacy IO address ranges previously assigned to the selected boot devices. From that point forward and for the duration of the power-up session, the native driver will utilize memory accesses to communicate with its associated function through the function's memory BARs. Legacy PCI Express Endpoint Function (as indicated by a value of 0001b in the Device/Port Type field in the function's PCI Express Capabilities Register; see Figure 22-31 on page 865). A legacy PCI Express Endpoint function consists of a legacy PCI or PCI-X function supplied with a PCI Express front end to interface it to the PCI Express fabric. As many legacy functions implemented IO BARs, IO BARs are tolerated in this type of function.
Memory Base Address Register
This section provides a detailed description of the bit fields within a Memory BAR. The section entitled "Finding Block Size and Assigning Address Range" on page 799 describes how the register is probed to determine its existence, the size of the memory associated with the decoder, and the assignment of the base address to the decoder.
Decoder Width Field
In a Memory Base Address Register, bits [2:1] define whether the decoder is 32- or 64-bits wide:
If 00b = it's a 32-bit register (see Figure 22-10 on page 796). The configuration software therefore will write a 32-bit start memory address into it specifying any address in the first 4GB of memory address space. If 10b = it's a 64-bit register (see Figure 22-11 on page 797). The configuration software therefore writes a 64-bit start memory address into it that specifies a start address in a 264 memory address space. This means that this Base Address Register consumes two consecutive dwords of the configuration Header space. The first dword is used to set the lower 32-bits of the start address and the second dword is used to specify the upper 32-bits of the start address.
Prefetchable Attribute Bit
Bit three defines the block of memory as Prefetchable or not. A block of memory space may be marked as Prefetchable only if it can guarantee that:
there are no side effects from reads (e.g., the read doesn't alter the contents of the location or alter the state of the function in some manner). It's permissible for a bridge that resides between a Requester and a memory target to prefetch read data from memory that has this characteristic. If the Requester doesn't end up asking for all of the data that the bridge read into a read-ahead buffer, the bridge must discard the data (see "Bridge Must Discard Unconsumed Prefetched Data" on page 801). The data remains unchanged in the target's memory locations. on a read, it always returns all bytes irrespective of the byte enable settings. the memory device continues to function correctly if a bridge that resides between the Requester and the memory target performs byte merging (for more information, refer to "Byte Merging" on page 801) in its posted memory write buffer when memory writes are performed within the memory target's range.
In a nutshell, regular memory is prefetchable while memory-mapped IO (or any other badly-behaved memory region) is not. The configuration software can determine that a memory target is prefetchable or not by checking the Prefetchable bit in the memory target's Base Address Register (BAR).
All memory BAR registers in PCI Express Endpoint functions with the Prefetchable bit set to one must be implemented as 64-bit memory BARs. Memory BARs that do not have the prefetchable bit set to one may be implemented as 32-bit BARs.
As an example, the address decoder for a block of memory-mapped IO ports may hardwire the Prefetchable bit to zero, while the address decoder for well-behaved memory would hardwire it to one. For performance reasons, the spec urges that, wherever possible, memory-mapped IO ranges be marked as prefetchable memory.
The configuration software checks this bit to determine a memory target's operational characteristics, assigns a memory range to its decoder (i.e., its Memory BAR), and then backtracks to all upstream bridges between the memory target and the processor and configures the bridges to treat the assigned memory range in the appropriate manner:
If it's Prefetchable memory, it's permissible for a bridge to perform read prefetching to yield better performance, and it's also permissible for the bridge to perform byte merging in its posted memory write buffer for writes performed to the memory. If it's non-Prefetchable memory, bridge read prefetching and byte merging are not allowed within the assigned region of memory space. This will not allow bridges to optimize accesses to the function, but you're assured the function will work correctly (and that's pretty important!).
Base Address Field
This field consists of bits [31:7] for a 32-bit memory decoder and bits [63:7] for a 64-bit memory decoder. It is used:
to determine the size of the memory associated with this decoder, and to assign a start (i.e., base) address to the decoder.
Programming of an example Memory Base Address Register is provided in "Finding Block Size and Assigning Address Range" on page 799.
The minimum memory range requested by a BAR is 128 bytes.
IO Base Address Register
Introduction
This section provides a detailed description of the bit fields within an IO Base Address Register. The section entitled "Finding Block Size and Assigning Address Range" on page 799 describes:
how the register is probed to determine its existence, how to determine the size of the IO register set associated with the decoder and therefore the amount of IO space that must be assigned to it, and how to assign the base address to the decoder.
IO BAR Description
Refer to Figure 22-12 on page 798. Bit zero returns a one, indicating that this is an IO, rather than a memory, decoder. Bit one is reserved and must always return zero. Bits [31:2] comprises the Base Address field and is used to:
The PCI spec requires that a device that maps its control register set into IO space must not request more than 256 locations per IO Base Address Register.
PC-Compatible IO Decoder
The upper 16-bits of the IO BAR may be hardwired to zero when a function is designed specifically for a PC-compatible, x86-based machine (because Intel x86 processors are incapable of generating IO addresses over 64KB). The function must still perform a full 32-bit decode of the IO address, however.
Legacy IO Decoders
Legacy PC-compatible devices such as VGA and IDE controllers frequently expect to be located within fixed legacy IO ranges. Such functions do not implement Base Address Registers. Instead, the configuration software identifies them as legacy functions via their respective Class Code and then enables their IO decoder(s) by setting the IO Space bit in its Command register to one.
A legacy IO function may or may not own all of the byte locations within a dword of IO space:
A legacy IO function that does own all of the bytes within the currently-addressed dword can perform its decode using the dword-aligned address supplied by A[31:2]. A legacy IO function that does not own all of the byte locations within a dword must decode the byte enables to determine if it owns the byte-specific location being addressed. It must examine the byte enables to determine if the Requester is addressing additional, higher byte locations within the target IO dword (identified via A[31:2]). If it owns all of the addressed IO ports, the function can honor the request. However, if it doesn't own them all it must issue a Completer Abort to the Requester.
Finding Block Size and Assigning Address Range
How It Works
The configuration program must probe each of a function's possible Base Address Registers to determine:
Is the Base Address Register implemented? Is it a memory or an IO address decoder? If it's a memory decoder, is it a 32- or 64-bit Base Address Register? If it's a memory decoder, is the memory associated with the register Prefetchable or non-Prefetchable? How much memory or address space does it require and with what alignment?
All of this information can be ascertained simply by writing all ones to the Base Address Register and then reading it back. A return value of zero indicates that the Base Address Register isn't implemented. Assuming that the value read is non-zero, scanning the returned value (assuming its non-zero) upwards starting at the least-significant bit of the Base Address field, the programmer determines the size of the required memory or the IO space by finding the least-significant bit that was successfully set to one. Bit zero of the register has a binary-weighted value of one, bit one a value of two, bit two a value of four, etc. The binary-weighted value of the least-significant bit set to one in the Base Address field indicates the required amount of space. This is also the first read/writable bit in the register and all of the bits above it are by definition read/writable. After discovering this information, the program then writes a base 32- or 64-bit memory address, or the base 32-bit IO address into the Base Address Register.
A Memory Example
As an example, assume that FFFFFFFFh is written to the Base Address Register at configuration dword 04d and the value read back is FFF00000h. The fact that any bits could be changed to one indicates that the Base Address Register is implemented.
Bit 0 = 0, indicating that this is a memory address decoder. Bits [2:1] = 00b, indicating that it's a 32-bit memory decoder. Bit 3 = 0, indicating that it's not Prefetchable memory. Bit 20 is the first one bit found in the Base Address field. The binary-weighted value of this bit is 1,048,576, indicating that this is an address decoder for 1MB of memory.
The programmer then writes a 32-bit base address into the register. However, only bits [31:20] are writable. The decoder accepts bits [31:20] and assumes that bits [19:0] of the assigned base address are zero. This means that the base address is divisible by 1MB, the size of the requested memory range. It is a characteristic of PCI, PCI-X, and PCI Express decoders that the assigned start address is always divisible by the size of requested range.
As an example, it is possible to program the example memory address decoder for a 1MB block of memory to start on the one, two, or three meg boundary, but it is not possible to set its start address at the 1.5, 2.3, or 3.7 meg boundary.
An IO Example
As a second example, assume that FFFFFFFFh is written to a function's Base Address Register at configuration dword address 05d and the value read back is FFFFFF01h. Bit 0 is a one, indicating that this is an IO address decoder. Scanning upwards starting at bit 2 (the least-significant bit of the Base Address field), bit 8 is the first bit that was successfully changed to one. The binary-weighted value of this bit is 256, indicating that this is an IO address decoder requesting 256 bytes of IO space.
The programmer then writes a 32-bit base IO address into the register. However, only bits [31:8] are writable. The decoder accepts bits [31:8] and assumes that bits [7:0] of the assigned base address are zero. This means that the base address is divisible by 256, the size of the requested IO range.
Smallest/Largest Decoder Sizes
Smallest/Largest Memory Decoders
The smallest memory address decoder is implemented as a Base Address Register that permits bits [31:7] to be written. Since the binary-weighted value of bit seven is 128, 128 bytes is the smallest memory block a memory decoder can be designed for.
If a 32-bit memory BAR only permits bit 31 to be written, it is requesting 2GB of memory space.
A 64-bit memory BAR could request more than 2GB of memory address space, resulting in none of the lower 32 bits in the BAR being writable. If this is the case, the programmer must also write all ones in the high dword of the BAR to determine how big a memory space the decoder requires.
Smallest/Largest IO Decoders
The smallest IO decoder would be implemented as a Base Address Register that permitted bits [31:2] to be programmed. Since the binary-weighted value of bit two is 4, 4 bytes (a dword) is the smallest IO block an IO decoder can be designed for.
The largest IO decoder would permit bits [31:8] to be written. The binary-weighted value of bit 8 is 256 and this is therefore the largest range that an IO decoder can request.
Byte Merging
A bridge may combine writes to a single dword within one entry in the posted-write buffer. This feature is recommended to improve performance and is only permitted in memory address ranges that are designated as prefetchable.
As an example, assume that a Requester performs two memory writes:
These four locations reside within the same dword. The bridge could absorb the first two-byte write into a dword buffer entry and then absorb the second two byte write into the same dword buffer entry. When the bridge performs the memory write, it can complete it as a single access. It is a violation of the spec, however, for a bridge to combine separate byte writes to the same location into a single write. As an example, assume that a Requester performs four separate memory writes to the same dword: the first writes to location zero in the dword, the second to location zero again, the third to location one and the fourth to location two. When the bridge performs the posted writes, it has to perform a single memory write transaction to write the first byte to location zero. It then performs a second memory write transaction to write to locations zero (the second byte written to it by the Requester), one and two.
Bridge Must Discard Unconsumed Prefetched Data
A bridge that has prefetched memory read data for a Requester must discard any prefetched read data that the Requester doesn't actually end up reading. The following is an example scenario that demonstrates a problem that will result if a bridge doesn't discard prefetched data that wasn't consumed:
The processor has two buffers in main memory that occupy adjacent memory regions. The memory is designated as prefetchable memory. The processor writes data into the first memory buffer and then instructs a PCI Express Requester to read and process the data. The Requester starts its memory read and the bridge between the Requester and the target memory performs read aheads from the memory because it is prefetchable, well-behaved memory. The bridge ends up prefetching past the end of the first memory buffer into the second one, but the Requester only actually reads the data from the first buffer area. The bridge does not discard the unused data that was prefetched from the second buffer. The processor writes data into the second memory buffer and then instructs a Requester (the same Requester or a different one) beyond the same bridge to read and process the data. The Requester starts its memory read at the start address of the second buffer. The bridge delivers the data that it prefetched from the beginning of the second buffer earlier. This is stale data and doesn't reflect the latest data written into the second memory buffer.
Min_Gnt/Max_Lat Registers
Differs from the PCI spec. Optional.
These registers do not apply to PCI Express. They must be read-only and hardwired to 0.
 |