2 Header file for Pci shell Debug1 function.
4 Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef _EFI_SHELL_PCI_H_
16 #define _EFI_SHELL_PCI_H_
25 #define HEADER_TYPE_MULTI_FUNCTION 0x80
27 #define MAX_BUS_NUMBER 255
28 #define MAX_DEVICE_NUMBER 31
29 #define MAX_FUNCTION_NUMBER 7
31 #define EFI_PCI_CAPABILITY_ID_PCIEXP 0x10
32 #define EFI_PCI_CAPABILITY_ID_PCIX 0x07
34 #define CALC_EFI_PCI_ADDRESS(Bus, Dev, Func, Reg) \
35 ((UINT64) ((((UINTN) Bus) << 24) + (((UINTN) Dev) << 16) + (((UINTN) Func) << 8) + ((UINTN) Reg)))
37 #define CALC_EFI_PCIEX_ADDRESS(Bus, Dev, Func, ExReg) ( \
38 (UINT64) ((((UINTN) Bus) << 24) + (((UINTN) Dev) << 16) + (((UINTN) Func) << 8) + (LShiftU64 ((UINT64) ExReg, 32))) \
41 #define INDEX_OF(Field) ((UINT8 *) (Field) - (UINT8 *) mConfigSpace)
43 #define PCI_BIT_0 0x00000001
44 #define PCI_BIT_1 0x00000002
45 #define PCI_BIT_2 0x00000004
46 #define PCI_BIT_3 0x00000008
47 #define PCI_BIT_4 0x00000010
48 #define PCI_BIT_5 0x00000020
49 #define PCI_BIT_6 0x00000040
50 #define PCI_BIT_7 0x00000080
51 #define PCI_BIT_8 0x00000100
52 #define PCI_BIT_9 0x00000200
53 #define PCI_BIT_10 0x00000400
54 #define PCI_BIT_11 0x00000800
55 #define PCI_BIT_12 0x00001000
56 #define PCI_BIT_13 0x00002000
57 #define PCI_BIT_14 0x00004000
58 #define PCI_BIT_15 0x00008000
61 // PCIE device/port types
63 #define PCIE_PCIE_ENDPOINT 0
64 #define PCIE_LEGACY_PCIE_ENDPOINT 1
65 #define PCIE_ROOT_COMPLEX_ROOT_PORT 4
66 #define PCIE_SWITCH_UPSTREAM_PORT 5
67 #define PCIE_SWITCH_DOWNSTREAM_PORT 6
68 #define PCIE_PCIE_TO_PCIX_BRIDGE 7
69 #define PCIE_PCIX_TO_PCIE_BRIDGE 8
70 #define PCIE_ROOT_COMPLEX_INTEGRATED_PORT 9
71 #define PCIE_ROOT_COMPLEX_EVENT_COLLECTOR 10
72 #define PCIE_DEVICE_PORT_TYPE_MAX 11
74 #define IS_PCIE_ENDPOINT(DevicePortType) \
75 ((DevicePortType) == PCIE_PCIE_ENDPOINT || \
76 (DevicePortType) == PCIE_LEGACY_PCIE_ENDPOINT || \
77 (DevicePortType) == PCIE_ROOT_COMPLEX_INTEGRATED_PORT)
79 #define IS_PCIE_SWITCH(DevicePortType) \
80 ((DevicePortType == PCIE_SWITCH_UPSTREAM_PORT) || \
81 (DevicePortType == PCIE_SWITCH_DOWNSTREAM_PORT))
84 // Capabilities Register
86 #define PCIE_CAP_VERSION(PcieCapReg) \
88 #define PCIE_CAP_DEVICEPORT_TYPE(PcieCapReg) \
89 (((PcieCapReg) >> 4) & 0x0f)
90 #define PCIE_CAP_SLOT_IMPLEMENTED(PcieCapReg) \
91 (((PcieCapReg) >> 8) & 0x1)
92 #define PCIE_CAP_INT_MSG_NUM(PcieCapReg) \
93 (((PcieCapReg) >> 9) & 0x1f)
95 // Device Capabilities Register
97 #define PCIE_CAP_MAX_PAYLOAD(PcieDeviceCap) \
98 ((PcieDeviceCap) & 0x7)
99 #define PCIE_CAP_PHANTOM_FUNC(PcieDeviceCap) \
100 (((PcieDeviceCap) >> 3) & 0x3)
101 #define PCIE_CAP_EXTENDED_TAG(PcieDeviceCap) \
102 (((PcieDeviceCap) >> 5) & 0x1)
103 #define PCIE_CAP_L0SLATENCY(PcieDeviceCap) \
104 (((PcieDeviceCap) >> 6) & 0x7)
105 #define PCIE_CAP_L1LATENCY(PcieDeviceCap) \
106 (((PcieDeviceCap) >> 9) & 0x7)
107 #define PCIE_CAP_ERR_REPORTING(PcieDeviceCap) \
108 (((PcieDeviceCap) >> 15) & 0x1)
109 #define PCIE_CAP_SLOT_POWER_VALUE(PcieDeviceCap) \
110 (((PcieDeviceCap) >> 18) & 0x0ff)
111 #define PCIE_CAP_SLOT_POWER_SCALE(PcieDeviceCap) \
112 (((PcieDeviceCap) >> 26) & 0x3)
113 #define PCIE_CAP_FUNC_LEVEL_RESET(PcieDeviceCap) \
114 (((PcieDeviceCap) >> 28) & 0x1)
116 // Device Control Register
118 #define PCIE_CAP_COR_ERR_REPORTING_ENABLE(PcieDeviceControl) \
119 ((PcieDeviceControl) & 0x1)
120 #define PCIE_CAP_NONFAT_ERR_REPORTING_ENABLE(PcieDeviceControl) \
121 (((PcieDeviceControl) >> 1) & 0x1)
122 #define PCIE_CAP_FATAL_ERR_REPORTING_ENABLE(PcieDeviceControl) \
123 (((PcieDeviceControl) >> 2) & 0x1)
124 #define PCIE_CAP_UNSUP_REQ_REPORTING_ENABLE(PcieDeviceControl) \
125 (((PcieDeviceControl) >> 3) & 0x1)
126 #define PCIE_CAP_RELAXED_ORDERING_ENABLE(PcieDeviceControl) \
127 (((PcieDeviceControl) >> 4) & 0x1)
128 #define PCIE_CAP_MAX_PAYLOAD_SIZE(PcieDeviceControl) \
129 (((PcieDeviceControl) >> 5) & 0x7)
130 #define PCIE_CAP_EXTENDED_TAG_ENABLE(PcieDeviceControl) \
131 (((PcieDeviceControl) >> 8) & 0x1)
132 #define PCIE_CAP_PHANTOM_FUNC_ENABLE(PcieDeviceControl) \
133 (((PcieDeviceControl) >> 9) & 0x1)
134 #define PCIE_CAP_AUX_PM_ENABLE(PcieDeviceControl) \
135 (((PcieDeviceControl) >> 10) & 0x1)
136 #define PCIE_CAP_NO_SNOOP_ENABLE(PcieDeviceControl) \
137 (((PcieDeviceControl) >> 11) & 0x1)
138 #define PCIE_CAP_MAX_READ_REQ_SIZE(PcieDeviceControl) \
139 (((PcieDeviceControl) >> 12) & 0x7)
140 #define PCIE_CAP_BRG_CONF_RETRY(PcieDeviceControl) \
141 (((PcieDeviceControl) >> 15) & 0x1)
143 // Device Status Register
145 #define PCIE_CAP_COR_ERR_DETECTED(PcieDeviceStatus) \
146 ((PcieDeviceStatus) & 0x1)
147 #define PCIE_CAP_NONFAT_ERR_DETECTED(PcieDeviceStatus) \
148 (((PcieDeviceStatus) >> 1) & 0x1)
149 #define PCIE_CAP_FATAL_ERR_DETECTED(PcieDeviceStatus) \
150 (((PcieDeviceStatus) >> 2) & 0x1)
151 #define PCIE_CAP_UNSUP_REQ_DETECTED(PcieDeviceStatus) \
152 (((PcieDeviceStatus) >> 3) & 0x1)
153 #define PCIE_CAP_AUX_POWER_DETECTED(PcieDeviceStatus) \
154 (((PcieDeviceStatus) >> 4) & 0x1)
155 #define PCIE_CAP_TRANSACTION_PENDING(PcieDeviceStatus) \
156 (((PcieDeviceStatus) >> 5) & 0x1)
158 // Link Capabilities Register
160 #define PCIE_CAP_SUP_LINK_SPEEDS(PcieLinkCap) \
161 ((PcieLinkCap) & 0x0f)
162 #define PCIE_CAP_MAX_LINK_WIDTH(PcieLinkCap) \
163 (((PcieLinkCap) >> 4) & 0x3f)
164 #define PCIE_CAP_ASPM_SUPPORT(PcieLinkCap) \
165 (((PcieLinkCap) >> 10) & 0x3)
166 #define PCIE_CAP_L0S_LATENCY(PcieLinkCap) \
167 (((PcieLinkCap) >> 12) & 0x7)
168 #define PCIE_CAP_L1_LATENCY(PcieLinkCap) \
169 (((PcieLinkCap) >> 15) & 0x7)
170 #define PCIE_CAP_CLOCK_PM(PcieLinkCap) \
171 (((PcieLinkCap) >> 18) & 0x1)
172 #define PCIE_CAP_SUP_DOWN_ERR_REPORTING(PcieLinkCap) \
173 (((PcieLinkCap) >> 19) & 0x1)
174 #define PCIE_CAP_LINK_ACTIVE_REPORTING(PcieLinkCap) \
175 (((PcieLinkCap) >> 20) & 0x1)
176 #define PCIE_CAP_LINK_BWD_NOTIF_CAP(PcieLinkCap) \
177 (((PcieLinkCap) >> 21) & 0x1)
178 #define PCIE_CAP_PORT_NUMBER(PcieLinkCap) \
179 (((PcieLinkCap) >> 24) & 0x0ff)
181 // Link Control Register
183 #define PCIE_CAP_ASPM_CONTROL(PcieLinkControl) \
184 ((PcieLinkControl) & 0x3)
185 #define PCIE_CAP_RCB(PcieLinkControl) \
186 (((PcieLinkControl) >> 3) & 0x1)
187 #define PCIE_CAP_LINK_DISABLE(PcieLinkControl) \
188 (((PcieLinkControl) >> 4) & 0x1)
189 #define PCIE_CAP_COMMON_CLK_CONF(PcieLinkControl) \
190 (((PcieLinkControl) >> 6) & 0x1)
191 #define PCIE_CAP_EXT_SYNC(PcieLinkControl) \
192 (((PcieLinkControl) >> 7) & 0x1)
193 #define PCIE_CAP_CLK_PWR_MNG(PcieLinkControl) \
194 (((PcieLinkControl) >> 8) & 0x1)
195 #define PCIE_CAP_HW_AUTO_WIDTH_DISABLE(PcieLinkControl) \
196 (((PcieLinkControl) >> 9) & 0x1)
197 #define PCIE_CAP_LINK_BDW_MNG_INT_EN(PcieLinkControl) \
198 (((PcieLinkControl) >> 10) & 0x1)
199 #define PCIE_CAP_LINK_AUTO_BDW_INT_EN(PcieLinkControl) \
200 (((PcieLinkControl) >> 11) & 0x1)
202 // Link Status Register
204 #define PCIE_CAP_CUR_LINK_SPEED(PcieLinkStatus) \
205 ((PcieLinkStatus) & 0x0f)
206 #define PCIE_CAP_NEGO_LINK_WIDTH(PcieLinkStatus) \
207 (((PcieLinkStatus) >> 4) & 0x3f)
208 #define PCIE_CAP_LINK_TRAINING(PcieLinkStatus) \
209 (((PcieLinkStatus) >> 11) & 0x1)
210 #define PCIE_CAP_SLOT_CLK_CONF(PcieLinkStatus) \
211 (((PcieLinkStatus) >> 12) & 0x1)
212 #define PCIE_CAP_DATA_LINK_ACTIVE(PcieLinkStatus) \
213 (((PcieLinkStatus) >> 13) & 0x1)
214 #define PCIE_CAP_LINK_BDW_MNG_STAT(PcieLinkStatus) \
215 (((PcieLinkStatus) >> 14) & 0x1)
216 #define PCIE_CAP_LINK_AUTO_BDW_STAT(PcieLinkStatus) \
217 (((PcieLinkStatus) >> 15) & 0x1)
219 // Slot Capabilities Register
221 #define PCIE_CAP_ATT_BUT_PRESENT(PcieSlotCap) \
222 ((PcieSlotCap) & 0x1)
223 #define PCIE_CAP_PWR_CTRLLER_PRESENT(PcieSlotCap) \
224 (((PcieSlotCap) >> 1) & 0x1)
225 #define PCIE_CAP_MRL_SENSOR_PRESENT(PcieSlotCap) \
226 (((PcieSlotCap) >> 2) & 0x1)
227 #define PCIE_CAP_ATT_IND_PRESENT(PcieSlotCap) \
228 (((PcieSlotCap) >> 3) & 0x1)
229 #define PCIE_CAP_PWD_IND_PRESENT(PcieSlotCap) \
230 (((PcieSlotCap) >> 4) & 0x1)
231 #define PCIE_CAP_HOTPLUG_SUPPRISE(PcieSlotCap) \
232 (((PcieSlotCap) >> 5) & 0x1)
233 #define PCIE_CAP_HOTPLUG_CAPABLE(PcieSlotCap) \
234 (((PcieSlotCap) >> 6) & 0x1)
235 #define PCIE_CAP_SLOT_PWR_LIMIT_VALUE(PcieSlotCap) \
236 (((PcieSlotCap) >> 7) & 0x0ff)
237 #define PCIE_CAP_SLOT_PWR_LIMIT_SCALE(PcieSlotCap) \
238 (((PcieSlotCap) >> 15) & 0x3)
239 #define PCIE_CAP_ELEC_INTERLOCK_PRESENT(PcieSlotCap) \
240 (((PcieSlotCap) >> 17) & 0x1)
241 #define PCIE_CAP_NO_COMM_COMPLETED_SUP(PcieSlotCap) \
242 (((PcieSlotCap) >> 18) & 0x1)
243 #define PCIE_CAP_PHY_SLOT_NUM(PcieSlotCap) \
244 (((PcieSlotCap) >> 19) & 0x1fff)
246 // Slot Control Register
248 #define PCIE_CAP_ATT_BUT_ENABLE(PcieSlotControl) \
249 ((PcieSlotControl) & 0x1)
250 #define PCIE_CAP_PWR_FLT_DETECT_ENABLE(PcieSlotControl) \
251 (((PcieSlotControl) >> 1) & 0x1)
252 #define PCIE_CAP_MRL_SENSOR_CHANGE_ENABLE(PcieSlotControl) \
253 (((PcieSlotControl) >> 2) & 0x1)
254 #define PCIE_CAP_PRES_DETECT_CHANGE_ENABLE(PcieSlotControl) \
255 (((PcieSlotControl) >> 3) & 0x1)
256 #define PCIE_CAP_COMM_CMPL_INT_ENABLE(PcieSlotControl) \
257 (((PcieSlotControl) >> 4) & 0x1)
258 #define PCIE_CAP_HOTPLUG_INT_ENABLE(PcieSlotControl) \
259 (((PcieSlotControl) >> 5) & 0x1)
260 #define PCIE_CAP_ATT_IND_CTRL(PcieSlotControl) \
261 (((PcieSlotControl) >> 6) & 0x3)
262 #define PCIE_CAP_PWR_IND_CTRL(PcieSlotControl) \
263 (((PcieSlotControl) >> 8) & 0x3)
264 #define PCIE_CAP_PWR_CTRLLER_CTRL(PcieSlotControl) \
265 (((PcieSlotControl) >> 10) & 0x1)
266 #define PCIE_CAP_ELEC_INTERLOCK_CTRL(PcieSlotControl) \
267 (((PcieSlotControl) >> 11) & 0x1)
268 #define PCIE_CAP_DLINK_STAT_CHANGE_ENABLE(PcieSlotControl) \
269 (((PcieSlotControl) >> 12) & 0x1)
271 // Slot Status Register
273 #define PCIE_CAP_ATT_BUT_PRESSED(PcieSlotStatus) \
274 ((PcieSlotStatus) & 0x1)
275 #define PCIE_CAP_PWR_FLT_DETECTED(PcieSlotStatus) \
276 (((PcieSlotStatus) >> 1) & 0x1)
277 #define PCIE_CAP_MRL_SENSOR_CHANGED(PcieSlotStatus) \
278 (((PcieSlotStatus) >> 2) & 0x1)
279 #define PCIE_CAP_PRES_DETECT_CHANGED(PcieSlotStatus) \
280 (((PcieSlotStatus) >> 3) & 0x1)
281 #define PCIE_CAP_COMM_COMPLETED(PcieSlotStatus) \
282 (((PcieSlotStatus) >> 4) & 0x1)
283 #define PCIE_CAP_MRL_SENSOR_STATE(PcieSlotStatus) \
284 (((PcieSlotStatus) >> 5) & 0x1)
285 #define PCIE_CAP_PRES_DETECT_STATE(PcieSlotStatus) \
286 (((PcieSlotStatus) >> 6) & 0x1)
287 #define PCIE_CAP_ELEC_INTERLOCK_STATE(PcieSlotStatus) \
288 (((PcieSlotStatus) >> 7) & 0x1)
289 #define PCIE_CAP_DLINK_STAT_CHANGED(PcieSlotStatus) \
290 (((PcieSlotStatus) >> 8) & 0x1)
292 // Root Control Register
294 #define PCIE_CAP_SYSERR_ON_CORERR_EN(PcieRootControl) \
295 ((PcieRootControl) & 0x1)
296 #define PCIE_CAP_SYSERR_ON_NONFATERR_EN(PcieRootControl) \
297 (((PcieRootControl) >> 1) & 0x1)
298 #define PCIE_CAP_SYSERR_ON_FATERR_EN(PcieRootControl) \
299 (((PcieRootControl) >> 2) & 0x1)
300 #define PCIE_CAP_PME_INT_ENABLE(PcieRootControl) \
301 (((PcieRootControl) >> 3) & 0x1)
302 #define PCIE_CAP_CRS_SW_VIS_ENABLE(PcieRootControl) \
303 (((PcieRootControl) >> 4) & 0x1)
305 // Root Capabilities Register
307 #define PCIE_CAP_CRS_SW_VIS(PcieRootCap) \
308 ((PcieRootCap) & 0x1)
310 // Root Status Register
312 #define PCIE_CAP_PME_REQ_ID(PcieRootStatus) \
313 ((PcieRootStatus) & 0x0ffff)
314 #define PCIE_CAP_PME_STATUS(PcieRootStatus) \
315 (((PcieRootStatus) >> 16) & 0x1)
316 #define PCIE_CAP_PME_PENDING(PcieRootStatus) \
317 (((PcieRootStatus) >> 17) & 0x1)
321 // Common part of the PCI configuration space header for devices, P2P bridges,
322 // and cardbus bridges
335 UINT8 PrimaryLatencyTimer
;
342 // PCI configuration space header for devices(after the common part)
345 UINT32 Bar
[6]; // Base Address Registers
346 UINT32 CardBusCISPtr
; // CardBus CIS Pointer
347 UINT16 SubVendorId
; // Subsystem Vendor ID
348 UINT16 SubSystemId
; // Subsystem ID
349 UINT32 ROMBar
; // Expansion ROM Base Address
350 UINT8 CapabilitiesPtr
; // Capabilities Pointer
355 UINT8 InterruptLine
; // Interrupt Line
356 UINT8 InterruptPin
; // Interrupt Pin
357 UINT8 MinGnt
; // Min_Gnt
358 UINT8 MaxLat
; // Max_Lat
362 // PCI configuration space header for pci-to-pci bridges(after the common part)
365 UINT32 Bar
[2]; // Base Address Registers
366 UINT8 PrimaryBus
; // Primary Bus Number
367 UINT8 SecondaryBus
; // Secondary Bus Number
368 UINT8 SubordinateBus
; // Subordinate Bus Number
369 UINT8 SecondaryLatencyTimer
; // Secondary Latency Timer
370 UINT8 IoBase
; // I/O Base
371 UINT8 IoLimit
; // I/O Limit
372 UINT16 SecondaryStatus
; // Secondary Status
373 UINT16 MemoryBase
; // Memory Base
374 UINT16 MemoryLimit
; // Memory Limit
375 UINT16 PrefetchableMemBase
; // Pre-fetchable Memory Base
376 UINT16 PrefetchableMemLimit
; // Pre-fetchable Memory Limit
377 UINT32 PrefetchableBaseUpper
; // Pre-fetchable Base Upper 32 bits
378 UINT32 PrefetchableLimitUpper
; // Pre-fetchable Limit Upper 32 bits
379 UINT16 IoBaseUpper
; // I/O Base Upper 16 bits
380 UINT16 IoLimitUpper
; // I/O Limit Upper 16 bits
381 UINT8 CapabilitiesPtr
; // Capabilities Pointer
384 UINT32 ROMBar
; // Expansion ROM Base Address
385 UINT8 InterruptLine
; // Interrupt Line
386 UINT8 InterruptPin
; // Interrupt Pin
387 UINT16 BridgeControl
; // Bridge Control
391 // PCI configuration space header for cardbus bridges(after the common part)
394 UINT32 CardBusSocketReg
; // Cardus Socket/ExCA Base
397 UINT8 CapabilitiesPtr
; // 14h in pci-cardbus bridge.
399 UINT16 SecondaryStatus
; // Secondary Status
400 UINT8 PciBusNumber
; // PCI Bus Number
401 UINT8 CardBusBusNumber
; // CardBus Bus Number
402 UINT8 SubordinateBusNumber
; // Subordinate Bus Number
403 UINT8 CardBusLatencyTimer
; // CardBus Latency Timer
404 UINT32 MemoryBase0
; // Memory Base Register 0
405 UINT32 MemoryLimit0
; // Memory Limit Register 0
409 UINT32 IoLimit0
; // I/O Base Register 0
410 UINT32 IoBase1
; // I/O Limit Register 0
413 UINT8 InterruptLine
; // Interrupt Line
414 UINT8 InterruptPin
; // Interrupt Pin
415 UINT16 BridgeControl
; // Bridge Control
416 } PCI_CARDBUS_HEADER
;
419 // Data region after PCI configuration header(for cardbus bridge)
422 UINT16 SubVendorId
; // Subsystem Vendor ID
423 UINT16 SubSystemId
; // Subsystem ID
424 UINT32 LegacyBase
; // Optional 16-Bit PC Card Legacy
431 PCI_DEVICE_HEADER Device
;
432 PCI_BRIDGE_HEADER Bridge
;
433 PCI_CARDBUS_HEADER CardBus
;
437 PCI_COMMON_HEADER Common
;
438 NON_COMMON_UNION NonCommon
;
446 UINT32 PcieDeviceCap
;
447 UINT16 DeviceControl
;
458 } PCIE_CAP_STURCTURE
;