2 Main file for Pci shell Debug1 function.
4 Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
5 Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "UefiShellDebug1CommandsLib.h"
17 #include <Protocol/PciRootBridgeIo.h>
18 #include <Library/ShellLib.h>
19 #include <IndustryStandard/Pci.h>
20 #include <IndustryStandard/Acpi.h>
23 #define PCI_CLASS_STRING_LIMIT 54
25 // Printable strings for Pci class code
28 CHAR16
*BaseClass
; // Pointer to the PCI base class string
29 CHAR16
*SubClass
; // Pointer to the PCI sub class string
30 CHAR16
*PIFClass
; // Pointer to the PCI programming interface string
34 // a structure holding a single entry, which also points to its lower level
37 typedef struct PCI_CLASS_ENTRY_TAG
{
38 UINT8 Code
; // Class, subclass or I/F code
39 CHAR16
*DescText
; // Description string
40 struct PCI_CLASS_ENTRY_TAG
*LowerLevelClass
; // Subclass or I/F if any
44 // Declarations of entries which contain printable strings for class codes
45 // in PCI configuration space
47 PCI_CLASS_ENTRY PCIBlankEntry
[];
48 PCI_CLASS_ENTRY PCISubClass_00
[];
49 PCI_CLASS_ENTRY PCISubClass_01
[];
50 PCI_CLASS_ENTRY PCISubClass_02
[];
51 PCI_CLASS_ENTRY PCISubClass_03
[];
52 PCI_CLASS_ENTRY PCISubClass_04
[];
53 PCI_CLASS_ENTRY PCISubClass_05
[];
54 PCI_CLASS_ENTRY PCISubClass_06
[];
55 PCI_CLASS_ENTRY PCISubClass_07
[];
56 PCI_CLASS_ENTRY PCISubClass_08
[];
57 PCI_CLASS_ENTRY PCISubClass_09
[];
58 PCI_CLASS_ENTRY PCISubClass_0a
[];
59 PCI_CLASS_ENTRY PCISubClass_0b
[];
60 PCI_CLASS_ENTRY PCISubClass_0c
[];
61 PCI_CLASS_ENTRY PCISubClass_0d
[];
62 PCI_CLASS_ENTRY PCISubClass_0e
[];
63 PCI_CLASS_ENTRY PCISubClass_0f
[];
64 PCI_CLASS_ENTRY PCISubClass_10
[];
65 PCI_CLASS_ENTRY PCISubClass_11
[];
66 PCI_CLASS_ENTRY PCIPIFClass_0101
[];
67 PCI_CLASS_ENTRY PCIPIFClass_0300
[];
68 PCI_CLASS_ENTRY PCIPIFClass_0604
[];
69 PCI_CLASS_ENTRY PCIPIFClass_0700
[];
70 PCI_CLASS_ENTRY PCIPIFClass_0701
[];
71 PCI_CLASS_ENTRY PCIPIFClass_0703
[];
72 PCI_CLASS_ENTRY PCIPIFClass_0800
[];
73 PCI_CLASS_ENTRY PCIPIFClass_0801
[];
74 PCI_CLASS_ENTRY PCIPIFClass_0802
[];
75 PCI_CLASS_ENTRY PCIPIFClass_0803
[];
76 PCI_CLASS_ENTRY PCIPIFClass_0904
[];
77 PCI_CLASS_ENTRY PCIPIFClass_0c00
[];
78 PCI_CLASS_ENTRY PCIPIFClass_0c03
[];
79 PCI_CLASS_ENTRY PCIPIFClass_0e00
[];
82 // Base class strings entries
84 PCI_CLASS_ENTRY gClassStringList
[] = {
92 L
"Mass Storage Controller",
97 L
"Network Controller",
102 L
"Display Controller",
107 L
"Multimedia Device",
112 L
"Memory Controller",
122 L
"Simple Communications Controllers",
127 L
"Base System Peripherals",
147 L
"Serial Bus Controllers",
152 L
"Wireless Controllers",
157 L
"Intelligent IO Controllers",
162 L
"Satellite Communications Controllers",
167 L
"Encryption/Decryption Controllers",
172 L
"Data Acquisition & Signal Processing Controllers",
177 L
"Device does not fit in any defined classes",
183 /* null string ends the list */NULL
188 // Subclass strings entries
190 PCI_CLASS_ENTRY PCIBlankEntry
[] = {
199 /* null string ends the list */NULL
203 PCI_CLASS_ENTRY PCISubClass_00
[] = {
206 L
"All devices other than VGA",
211 L
"VGA-compatible devices",
217 /* null string ends the list */NULL
221 PCI_CLASS_ENTRY PCISubClass_01
[] = {
234 L
"Floppy disk controller",
249 L
"Other mass storage controller",
255 /* null string ends the list */NULL
259 PCI_CLASS_ENTRY PCISubClass_02
[] = {
262 L
"Ethernet controller",
267 L
"Token ring controller",
287 L
"Other network controller",
293 /* null string ends the list */NULL
297 PCI_CLASS_ENTRY PCISubClass_03
[] = {
300 L
"VGA/8514 controller",
315 L
"Other display controller",
321 /* null string ends the list */PCIBlankEntry
325 PCI_CLASS_ENTRY PCISubClass_04
[] = {
338 L
"Computer Telephony device",
343 L
"Other multimedia device",
349 /* null string ends the list */NULL
353 PCI_CLASS_ENTRY PCISubClass_05
[] = {
356 L
"RAM memory controller",
361 L
"Flash memory controller",
366 L
"Other memory controller",
372 /* null string ends the list */NULL
376 PCI_CLASS_ENTRY PCISubClass_06
[] = {
394 L
"PCI/Micro Channel bridge",
404 L
"PCI/PCMCIA bridge",
424 L
"Other bridge type",
430 /* null string ends the list */NULL
434 PCI_CLASS_ENTRY PCISubClass_07
[] = {
437 L
"Serial controller",
447 L
"Multiport serial controller",
457 L
"Other communication device",
463 /* null string ends the list */NULL
467 PCI_CLASS_ENTRY PCISubClass_08
[] = {
490 L
"Generic PCI Hot-Plug controller",
495 L
"Other system peripheral",
501 /* null string ends the list */NULL
505 PCI_CLASS_ENTRY PCISubClass_09
[] = {
508 L
"Keyboard controller",
523 L
"Scanner controller",
528 L
"Gameport controller",
533 L
"Other input controller",
539 /* null string ends the list */NULL
543 PCI_CLASS_ENTRY PCISubClass_0a
[] = {
546 L
"Generic docking station",
551 L
"Other type of docking station",
557 /* null string ends the list */NULL
561 PCI_CLASS_ENTRY PCISubClass_0b
[] = {
605 /* null string ends the list */NULL
609 PCI_CLASS_ENTRY PCISubClass_0c
[] = {
612 L
"Firewire(IEEE 1394)",
637 L
"System Management Bus",
648 /* null string ends the list */NULL
652 PCI_CLASS_ENTRY PCISubClass_0d
[] = {
655 L
"iRDA compatible controller",
660 L
"Consumer IR controller",
670 L
"Other type of wireless controller",
676 /* null string ends the list */NULL
680 PCI_CLASS_ENTRY PCISubClass_0e
[] = {
689 /* null string ends the list */NULL
693 PCI_CLASS_ENTRY PCISubClass_0f
[] = {
717 /* null string ends the list */NULL
721 PCI_CLASS_ENTRY PCISubClass_10
[] = {
724 L
"Network & computing Encrypt/Decrypt",
729 L
"Entertainment Encrypt/Decrypt",
734 L
"Other Encrypt/Decrypt",
740 /* null string ends the list */NULL
744 PCI_CLASS_ENTRY PCISubClass_11
[] = {
752 L
"Other DAQ & SP controllers",
758 /* null string ends the list */NULL
763 // Programming Interface entries
765 PCI_CLASS_ENTRY PCIPIFClass_0101
[] = {
793 L
"OM-primary, OM-secondary",
798 L
"PI-primary, OM-secondary",
803 L
"OM/PI-primary, OM-secondary",
813 L
"OM-primary, PI-secondary",
818 L
"PI-primary, PI-secondary",
823 L
"OM/PI-primary, PI-secondary",
833 L
"OM-primary, OM/PI-secondary",
838 L
"PI-primary, OM/PI-secondary",
843 L
"OM/PI-primary, OM/PI-secondary",
853 L
"Master, OM-primary",
858 L
"Master, PI-primary",
863 L
"Master, OM/PI-primary",
868 L
"Master, OM-secondary",
873 L
"Master, OM-primary, OM-secondary",
878 L
"Master, PI-primary, OM-secondary",
883 L
"Master, OM/PI-primary, OM-secondary",
888 L
"Master, OM-secondary",
893 L
"Master, OM-primary, PI-secondary",
898 L
"Master, PI-primary, PI-secondary",
903 L
"Master, OM/PI-primary, PI-secondary",
908 L
"Master, OM-secondary",
913 L
"Master, OM-primary, OM/PI-secondary",
918 L
"Master, PI-primary, OM/PI-secondary",
923 L
"Master, OM/PI-primary, OM/PI-secondary",
929 /* null string ends the list */NULL
933 PCI_CLASS_ENTRY PCIPIFClass_0300
[] = {
947 /* null string ends the list */NULL
951 PCI_CLASS_ENTRY PCIPIFClass_0604
[] = {
959 L
"Subtractive decode",
965 /* null string ends the list */NULL
969 PCI_CLASS_ENTRY PCIPIFClass_0700
[] = {
972 L
"Generic XT-compatible",
1002 L
"16950-compatible",
1008 /* null string ends the list */NULL
1012 PCI_CLASS_ENTRY PCIPIFClass_0701
[] = {
1025 L
"ECP 1.X-compliant",
1035 L
"IEEE 1284 target (not a controller)",
1041 /* null string ends the list */NULL
1045 PCI_CLASS_ENTRY PCIPIFClass_0703
[] = {
1053 L
"Hayes-compatible 16450",
1058 L
"Hayes-compatible 16550",
1063 L
"Hayes-compatible 16650",
1068 L
"Hayes-compatible 16750",
1074 /* null string ends the list */NULL
1078 PCI_CLASS_ENTRY PCIPIFClass_0800
[] = {
1101 L
"IO(x) APIC interrupt controller",
1107 /* null string ends the list */NULL
1111 PCI_CLASS_ENTRY PCIPIFClass_0801
[] = {
1130 /* null string ends the list */NULL
1134 PCI_CLASS_ENTRY PCIPIFClass_0802
[] = {
1153 /* null string ends the list */NULL
1157 PCI_CLASS_ENTRY PCIPIFClass_0803
[] = {
1176 /* null string ends the list */NULL
1180 PCI_CLASS_ENTRY PCIPIFClass_0904
[] = {
1194 /* null string ends the list */NULL
1198 PCI_CLASS_ENTRY PCIPIFClass_0c00
[] = {
1201 L
"Universal Host Controller spec",
1206 L
"Open Host Controller spec",
1211 L
"No specific programming interface",
1216 L
"(Not Host Controller)",
1222 /* null string ends the list */NULL
1226 PCI_CLASS_ENTRY PCIPIFClass_0c03
[] = {
1234 L
"Using 1394 OpenHCI spec",
1240 /* null string ends the list */NULL
1244 PCI_CLASS_ENTRY PCIPIFClass_0e00
[] = {
1247 L
"Message FIFO at offset 40h",
1258 /* null string ends the list */NULL
1264 Generates printable Unicode strings that represent PCI device class,
1265 subclass and programmed I/F based on a value passed to the function.
1267 @param[in] ClassCode Value representing the PCI "Class Code" register read from a
1268 PCI device. The encodings are:
1269 bits 23:16 - Base Class Code
1270 bits 15:8 - Sub-Class Code
1271 bits 7:0 - Programming Interface
1272 @param[in, out] ClassStrings Pointer of PCI_CLASS_STRINGS structure, which contains
1273 printable class strings corresponding to ClassCode. The
1274 caller must not modify the strings that are pointed by
1275 the fields in ClassStrings.
1278 PciGetClassStrings (
1279 IN UINT32 ClassCode
,
1280 IN OUT PCI_CLASS_STRINGS
*ClassStrings
1285 PCI_CLASS_ENTRY
*CurrentClass
;
1288 // Assume no strings found
1290 ClassStrings
->BaseClass
= L
"UNDEFINED";
1291 ClassStrings
->SubClass
= L
"UNDEFINED";
1292 ClassStrings
->PIFClass
= L
"UNDEFINED";
1294 CurrentClass
= gClassStringList
;
1295 Code
= (UINT8
) (ClassCode
>> 16);
1299 // Go through all entries of the base class, until the entry with a matching
1300 // base class code is found. If reaches an entry with a null description
1301 // text, the last entry is met, which means no text for the base class was
1302 // found, so no more action is needed.
1304 while (Code
!= CurrentClass
[Index
].Code
) {
1305 if (NULL
== CurrentClass
[Index
].DescText
) {
1312 // A base class was found. Assign description, and check if this class has
1313 // sub-class defined. If sub-class defined, no more action is needed,
1314 // otherwise, continue to find description for the sub-class code.
1316 ClassStrings
->BaseClass
= CurrentClass
[Index
].DescText
;
1317 if (NULL
== CurrentClass
[Index
].LowerLevelClass
) {
1321 // find Subclass entry
1323 CurrentClass
= CurrentClass
[Index
].LowerLevelClass
;
1324 Code
= (UINT8
) (ClassCode
>> 8);
1328 // Go through all entries of the sub-class, until the entry with a matching
1329 // sub-class code is found. If reaches an entry with a null description
1330 // text, the last entry is met, which means no text for the sub-class was
1331 // found, so no more action is needed.
1333 while (Code
!= CurrentClass
[Index
].Code
) {
1334 if (NULL
== CurrentClass
[Index
].DescText
) {
1341 // A class was found for the sub-class code. Assign description, and check if
1342 // this sub-class has programming interface defined. If no, no more action is
1343 // needed, otherwise, continue to find description for the programming
1346 ClassStrings
->SubClass
= CurrentClass
[Index
].DescText
;
1347 if (NULL
== CurrentClass
[Index
].LowerLevelClass
) {
1351 // Find programming interface entry
1353 CurrentClass
= CurrentClass
[Index
].LowerLevelClass
;
1354 Code
= (UINT8
) ClassCode
;
1358 // Go through all entries of the I/F entries, until the entry with a
1359 // matching I/F code is found. If reaches an entry with a null description
1360 // text, the last entry is met, which means no text was found, so no more
1361 // action is needed.
1363 while (Code
!= CurrentClass
[Index
].Code
) {
1364 if (NULL
== CurrentClass
[Index
].DescText
) {
1371 // A class was found for the I/F code. Assign description, done!
1373 ClassStrings
->PIFClass
= CurrentClass
[Index
].DescText
;
1378 Print strings that represent PCI device class, subclass and programmed I/F.
1380 @param[in] ClassCodePtr Points to the memory which stores register Class Code in PCI
1382 @param[in] IncludePIF If the printed string should include the programming I/F part
1386 IN UINT8
*ClassCodePtr
,
1387 IN BOOLEAN IncludePIF
1391 PCI_CLASS_STRINGS ClassStrings
;
1394 ClassCode
|= ClassCodePtr
[0];
1395 ClassCode
|= (ClassCodePtr
[1] << 8);
1396 ClassCode
|= (ClassCodePtr
[2] << 16);
1399 // Get name from class code
1401 PciGetClassStrings (ClassCode
, &ClassStrings
);
1405 // Print base class, sub class, and programming inferface name
1407 ShellPrintEx (-1, -1, L
"%s - %s - %s",
1408 ClassStrings
.BaseClass
,
1409 ClassStrings
.SubClass
,
1410 ClassStrings
.PIFClass
1415 // Only print base class and sub class name
1417 ShellPrintEx (-1, -1, L
"%s - %s",
1418 ClassStrings
.BaseClass
,
1419 ClassStrings
.SubClass
1425 This function finds out the protocol which is in charge of the given
1426 segment, and its bus range covers the current bus number. It lookes
1427 each instances of RootBridgeIoProtocol handle, until the one meets the
1430 @param[in] HandleBuf Buffer which holds all PCI_ROOT_BRIDIGE_IO_PROTOCOL handles.
1431 @param[in] HandleCount Count of all PCI_ROOT_BRIDIGE_IO_PROTOCOL handles.
1432 @param[in] Segment Segment number of device we are dealing with.
1433 @param[in] Bus Bus number of device we are dealing with.
1434 @param[out] IoDev Handle used to access configuration space of PCI device.
1436 @retval EFI_SUCCESS The command completed successfully.
1437 @retval EFI_INVALID_PARAMETER Invalid parameter.
1441 PciFindProtocolInterface (
1442 IN EFI_HANDLE
*HandleBuf
,
1443 IN UINTN HandleCount
,
1446 OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
**IoDev
1450 This function gets the protocol interface from the given handle, and
1451 obtains its address space descriptors.
1453 @param[in] Handle The PCI_ROOT_BRIDIGE_IO_PROTOCOL handle.
1454 @param[out] IoDev Handle used to access configuration space of PCI device.
1455 @param[out] Descriptors Points to the address space descriptors.
1457 @retval EFI_SUCCESS The command completed successfully
1460 PciGetProtocolAndResource (
1461 IN EFI_HANDLE Handle
,
1462 OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
**IoDev
,
1463 OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
**Descriptors
1467 This function get the next bus range of given address space descriptors.
1468 It also moves the pointer backward a node, to get prepared to be called
1471 @param[in, out] Descriptors Points to current position of a serial of address space
1473 @param[out] MinBus The lower range of bus number.
1474 @param[out] MaxBus The upper range of bus number.
1475 @param[out] IsEnd Meet end of the serial of descriptors.
1477 @retval EFI_SUCCESS The command completed successfully.
1480 PciGetNextBusRange (
1481 IN OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
**Descriptors
,
1488 Explain the data in PCI configuration space. The part which is common for
1489 PCI device and bridge is interpreted in this function. It calls other
1490 functions to interpret data unique for device or bridge.
1492 @param[in] ConfigSpace Data in PCI configuration space.
1493 @param[in] Address Address used to access configuration space of this PCI device.
1494 @param[in] IoDev Handle used to access configuration space of PCI device.
1496 @retval EFI_SUCCESS The command completed successfully.
1500 IN PCI_CONFIG_SPACE
*ConfigSpace
,
1502 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
1506 Explain the device specific part of data in PCI configuration space.
1508 @param[in] Device Data in PCI configuration space.
1509 @param[in] Address Address used to access configuration space of this PCI device.
1510 @param[in] IoDev Handle used to access configuration space of PCI device.
1512 @retval EFI_SUCCESS The command completed successfully.
1515 PciExplainDeviceData (
1516 IN PCI_DEVICE_HEADER
*Device
,
1518 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
1522 Explain the bridge specific part of data in PCI configuration space.
1524 @param[in] Bridge Bridge specific data region in PCI configuration space.
1525 @param[in] Address Address used to access configuration space of this PCI device.
1526 @param[in] IoDev Handle used to access configuration space of PCI device.
1528 @retval EFI_SUCCESS The command completed successfully.
1531 PciExplainBridgeData (
1532 IN PCI_BRIDGE_HEADER
*Bridge
,
1534 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
1538 Explain the Base Address Register(Bar) in PCI configuration space.
1540 @param[in] Bar Points to the Base Address Register intended to interpret.
1541 @param[in] Command Points to the register Command.
1542 @param[in] Address Address used to access configuration space of this PCI device.
1543 @param[in] IoDev Handle used to access configuration space of PCI device.
1544 @param[in, out] Index The Index.
1546 @retval EFI_SUCCESS The command completed successfully.
1553 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
,
1558 Explain the cardbus specific part of data in PCI configuration space.
1560 @param[in] CardBus CardBus specific region of PCI configuration space.
1561 @param[in] Address Address used to access configuration space of this PCI device.
1562 @param[in] IoDev Handle used to access configuration space of PCI device.
1564 @retval EFI_SUCCESS The command completed successfully.
1567 PciExplainCardBusData (
1568 IN PCI_CARDBUS_HEADER
*CardBus
,
1570 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
1574 Explain each meaningful bit of register Status. The definition of Status is
1575 slightly different depending on the PCI header type.
1577 @param[in] Status Points to the content of register Status.
1578 @param[in] MainStatus Indicates if this register is main status(not secondary
1580 @param[in] HeaderType Header type of this PCI device.
1582 @retval EFI_SUCCESS The command completed successfully.
1587 IN BOOLEAN MainStatus
,
1588 IN PCI_HEADER_TYPE HeaderType
1592 Explain each meaningful bit of register Command.
1594 @param[in] Command Points to the content of register Command.
1596 @retval EFI_SUCCESS The command completed successfully.
1604 Explain each meaningful bit of register Bridge Control.
1606 @param[in] BridgeControl Points to the content of register Bridge Control.
1607 @param[in] HeaderType The headertype.
1609 @retval EFI_SUCCESS The command completed successfully.
1612 PciExplainBridgeControl (
1613 IN UINT16
*BridgeControl
,
1614 IN PCI_HEADER_TYPE HeaderType
1618 Print each capability structure.
1620 @param[in] IoDev The pointer to the deivce.
1621 @param[in] Address The address to start at.
1622 @param[in] CapPtr The offset from the address.
1624 @retval EFI_SUCCESS The operation was successful.
1627 PciExplainCapabilityStruct (
1628 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
,
1634 Display Pcie device structure.
1636 @param[in] IoDev The pointer to the root pci protocol.
1637 @param[in] Address The Address to start at.
1638 @param[in] CapabilityPtr The offset from the address to start.
1641 PciExplainPciExpress (
1642 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
,
1644 IN UINT8 CapabilityPtr
1648 Print out information of the capability information.
1650 @param[in] PciExpressCap The pointer to the structure about the device.
1652 @retval EFI_SUCCESS The operation was successful.
1656 IN PCIE_CAP_STURCTURE
*PciExpressCap
1660 Print out information of the device capability information.
1662 @param[in] PciExpressCap The pointer to the structure about the device.
1664 @retval EFI_SUCCESS The operation was successful.
1667 ExplainPcieDeviceCap (
1668 IN PCIE_CAP_STURCTURE
*PciExpressCap
1672 Print out information of the device control information.
1674 @param[in] PciExpressCap The pointer to the structure about the device.
1676 @retval EFI_SUCCESS The operation was successful.
1679 ExplainPcieDeviceControl (
1680 IN PCIE_CAP_STURCTURE
*PciExpressCap
1684 Print out information of the device status information.
1686 @param[in] PciExpressCap The pointer to the structure about the device.
1688 @retval EFI_SUCCESS The operation was successful.
1691 ExplainPcieDeviceStatus (
1692 IN PCIE_CAP_STURCTURE
*PciExpressCap
1696 Print out information of the device link information.
1698 @param[in] PciExpressCap The pointer to the structure about the device.
1700 @retval EFI_SUCCESS The operation was successful.
1703 ExplainPcieLinkCap (
1704 IN PCIE_CAP_STURCTURE
*PciExpressCap
1708 Print out information of the device link control information.
1710 @param[in] PciExpressCap The pointer to the structure about the device.
1712 @retval EFI_SUCCESS The operation was successful.
1715 ExplainPcieLinkControl (
1716 IN PCIE_CAP_STURCTURE
*PciExpressCap
1720 Print out information of the device link status information.
1722 @param[in] PciExpressCap The pointer to the structure about the device.
1724 @retval EFI_SUCCESS The operation was successful.
1727 ExplainPcieLinkStatus (
1728 IN PCIE_CAP_STURCTURE
*PciExpressCap
1732 Print out information of the device slot information.
1734 @param[in] PciExpressCap The pointer to the structure about the device.
1736 @retval EFI_SUCCESS The operation was successful.
1739 ExplainPcieSlotCap (
1740 IN PCIE_CAP_STURCTURE
*PciExpressCap
1744 Print out information of the device slot control information.
1746 @param[in] PciExpressCap The pointer to the structure about the device.
1748 @retval EFI_SUCCESS The operation was successful.
1751 ExplainPcieSlotControl (
1752 IN PCIE_CAP_STURCTURE
*PciExpressCap
1756 Print out information of the device slot status information.
1758 @param[in] PciExpressCap The pointer to the structure about the device.
1760 @retval EFI_SUCCESS The operation was successful.
1763 ExplainPcieSlotStatus (
1764 IN PCIE_CAP_STURCTURE
*PciExpressCap
1768 Print out information of the device root information.
1770 @param[in] PciExpressCap The pointer to the structure about the device.
1772 @retval EFI_SUCCESS The operation was successful.
1775 ExplainPcieRootControl (
1776 IN PCIE_CAP_STURCTURE
*PciExpressCap
1780 Print out information of the device root capability information.
1782 @param[in] PciExpressCap The pointer to the structure about the device.
1784 @retval EFI_SUCCESS The operation was successful.
1787 ExplainPcieRootCap (
1788 IN PCIE_CAP_STURCTURE
*PciExpressCap
1792 Print out information of the device root status information.
1794 @param[in] PciExpressCap The pointer to the structure about the device.
1796 @retval EFI_SUCCESS The operation was successful.
1799 ExplainPcieRootStatus (
1800 IN PCIE_CAP_STURCTURE
*PciExpressCap
1803 typedef EFI_STATUS (*PCIE_EXPLAIN_FUNCTION
) (IN PCIE_CAP_STURCTURE
*PciExpressCap
);
1809 } PCIE_CAPREG_FIELD_WIDTH
;
1812 PcieExplainTypeCommon
,
1813 PcieExplainTypeDevice
,
1814 PcieExplainTypeLink
,
1815 PcieExplainTypeSlot
,
1816 PcieExplainTypeRoot
,
1818 } PCIE_EXPLAIN_TYPE
;
1824 PCIE_CAPREG_FIELD_WIDTH Width
;
1825 PCIE_EXPLAIN_FUNCTION Func
;
1826 PCIE_EXPLAIN_TYPE Type
;
1827 } PCIE_EXPLAIN_STRUCT
;
1829 PCIE_EXPLAIN_STRUCT PcieExplainList
[] = {
1831 STRING_TOKEN (STR_PCIEX_CAPABILITY_CAPID
),
1835 PcieExplainTypeCommon
1838 STRING_TOKEN (STR_PCIEX_NEXTCAP_PTR
),
1842 PcieExplainTypeCommon
1845 STRING_TOKEN (STR_PCIEX_CAP_REGISTER
),
1849 PcieExplainTypeCommon
1852 STRING_TOKEN (STR_PCIEX_DEVICE_CAP
),
1855 ExplainPcieDeviceCap
,
1856 PcieExplainTypeDevice
1859 STRING_TOKEN (STR_PCIEX_DEVICE_CONTROL
),
1862 ExplainPcieDeviceControl
,
1863 PcieExplainTypeDevice
1866 STRING_TOKEN (STR_PCIEX_DEVICE_STATUS
),
1869 ExplainPcieDeviceStatus
,
1870 PcieExplainTypeDevice
1873 STRING_TOKEN (STR_PCIEX_LINK_CAPABILITIES
),
1880 STRING_TOKEN (STR_PCIEX_LINK_CONTROL
),
1883 ExplainPcieLinkControl
,
1887 STRING_TOKEN (STR_PCIEX_LINK_STATUS
),
1890 ExplainPcieLinkStatus
,
1894 STRING_TOKEN (STR_PCIEX_SLOT_CAPABILITIES
),
1901 STRING_TOKEN (STR_PCIEX_SLOT_CONTROL
),
1904 ExplainPcieSlotControl
,
1908 STRING_TOKEN (STR_PCIEX_SLOT_STATUS
),
1911 ExplainPcieSlotStatus
,
1915 STRING_TOKEN (STR_PCIEX_ROOT_CONTROL
),
1918 ExplainPcieRootControl
,
1922 STRING_TOKEN (STR_PCIEX_RSVDP
),
1929 STRING_TOKEN (STR_PCIEX_ROOT_STATUS
),
1932 ExplainPcieRootStatus
,
1938 (PCIE_CAPREG_FIELD_WIDTH
)0,
1947 PCI_CONFIG_SPACE
*mConfigSpace
= NULL
;
1948 STATIC CONST SHELL_PARAM_ITEM ParamList
[] = {
1954 CHAR16
*DevicePortTypeTable
[] = {
1955 L
"PCI Express Endpoint",
1956 L
"Legacy PCI Express Endpoint",
1959 L
"Root Port of PCI Express Root Complex",
1960 L
"Upstream Port of PCI Express Switch",
1961 L
"Downstream Port of PCI Express Switch",
1962 L
"PCI Express to PCI/PCI-X Bridge",
1963 L
"PCI/PCI-X to PCI Express Bridge",
1964 L
"Root Complex Integrated Endpoint",
1965 L
"Root Complex Event Collector"
1968 CHAR16
*L0sLatencyStrTable
[] = {
1970 L
"64ns to less than 128ns",
1971 L
"128ns to less than 256ns",
1972 L
"256ns to less than 512ns",
1973 L
"512ns to less than 1us",
1974 L
"1us to less than 2us",
1979 CHAR16
*L1LatencyStrTable
[] = {
1981 L
"1us to less than 2us",
1982 L
"2us to less than 4us",
1983 L
"4us to less than 8us",
1984 L
"8us to less than 16us",
1985 L
"16us to less than 32us",
1990 CHAR16
*ASPMCtrlStrTable
[] = {
1992 L
"L0s Entry Enabled",
1993 L
"L1 Entry Enabled",
1994 L
"L0s and L1 Entry Enabled"
1997 CHAR16
*SlotPwrLmtScaleTable
[] = {
2004 CHAR16
*IndicatorTable
[] = {
2013 Function for 'pci' command.
2015 @param[in] ImageHandle Handle to the Image (NULL if Internal).
2016 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
2020 ShellCommandRunPci (
2021 IN EFI_HANDLE ImageHandle
,
2022 IN EFI_SYSTEM_TABLE
*SystemTable
2030 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
;
2032 PCI_COMMON_HEADER PciHeader
;
2033 PCI_CONFIG_SPACE ConfigSpace
;
2037 BOOLEAN ExplainData
;
2041 UINTN HandleBufSize
;
2042 EFI_HANDLE
*HandleBuf
;
2044 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*Descriptors
;
2048 LIST_ENTRY
*Package
;
2049 CHAR16
*ProblemParam
;
2050 SHELL_STATUS ShellStatus
;
2053 ShellStatus
= SHELL_SUCCESS
;
2054 Status
= EFI_SUCCESS
;
2061 // initialize the shell lib (we must be in non-auto-init...)
2063 Status
= ShellInitialize();
2064 ASSERT_EFI_ERROR(Status
);
2066 Status
= CommandInit();
2067 ASSERT_EFI_ERROR(Status
);
2070 // parse the command line
2072 Status
= ShellCommandLineParse (ParamList
, &Package
, &ProblemParam
, TRUE
);
2073 if (EFI_ERROR(Status
)) {
2074 if (Status
== EFI_VOLUME_CORRUPTED
&& ProblemParam
!= NULL
) {
2075 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellDebug1HiiHandle
, ProblemParam
);
2076 FreePool(ProblemParam
);
2077 ShellStatus
= SHELL_INVALID_PARAMETER
;
2083 if (ShellCommandLineGetCount(Package
) == 2) {
2084 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_FEW
), gShellDebug1HiiHandle
);
2085 ShellStatus
= SHELL_INVALID_PARAMETER
;
2089 if (ShellCommandLineGetCount(Package
) > 4) {
2090 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_MANY
), gShellDebug1HiiHandle
);
2091 ShellStatus
= SHELL_INVALID_PARAMETER
;
2094 if (ShellCommandLineGetFlag(Package
, L
"-s") && ShellCommandLineGetValue(Package
, L
"-s") == NULL
) {
2095 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_NO_VALUE
), gShellDebug1HiiHandle
, L
"-s");
2096 ShellStatus
= SHELL_INVALID_PARAMETER
;
2100 // Get all instances of PciRootBridgeIo. Allocate space for 1 EFI_HANDLE and
2101 // call LibLocateHandle(), if EFI_BUFFER_TOO_SMALL is returned, allocate enough
2102 // space for handles and call it again.
2104 HandleBufSize
= sizeof (EFI_HANDLE
);
2105 HandleBuf
= (EFI_HANDLE
*) AllocateZeroPool (HandleBufSize
);
2106 if (HandleBuf
== NULL
) {
2107 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_OUT_MEM
), gShellDebug1HiiHandle
);
2108 ShellStatus
= SHELL_OUT_OF_RESOURCES
;
2112 Status
= gBS
->LocateHandle (
2114 &gEfiPciRootBridgeIoProtocolGuid
,
2120 if (Status
== EFI_BUFFER_TOO_SMALL
) {
2121 HandleBuf
= ReallocatePool (sizeof (EFI_HANDLE
), HandleBufSize
, HandleBuf
);
2122 if (HandleBuf
== NULL
) {
2123 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_OUT_MEM
), gShellDebug1HiiHandle
);
2124 ShellStatus
= SHELL_OUT_OF_RESOURCES
;
2128 Status
= gBS
->LocateHandle (
2130 &gEfiPciRootBridgeIoProtocolGuid
,
2137 if (EFI_ERROR (Status
)) {
2138 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PCIRBIO_NF
), gShellDebug1HiiHandle
);
2139 ShellStatus
= SHELL_NOT_FOUND
;
2143 HandleCount
= HandleBufSize
/ sizeof (EFI_HANDLE
);
2145 // Argument Count == 1(no other argument): enumerate all pci functions
2147 if (ShellCommandLineGetCount(Package
) == 1) {
2148 gST
->ConOut
->QueryMode (
2150 gST
->ConOut
->Mode
->Mode
,
2157 if ((ScreenSize
& 1) == 1) {
2164 // For each handle, which decides a segment and a bus number range,
2165 // enumerate all devices on it.
2167 for (Index
= 0; Index
< HandleCount
; Index
++) {
2168 Status
= PciGetProtocolAndResource (
2173 if (EFI_ERROR (Status
)) {
2174 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_HANDLE_CFG_ERR
), gShellDebug1HiiHandle
, Status
);
2175 ShellStatus
= SHELL_NOT_FOUND
;
2179 // No document say it's impossible for a RootBridgeIo protocol handle
2180 // to have more than one address space descriptors, so find out every
2181 // bus range and for each of them do device enumeration.
2184 Status
= PciGetNextBusRange (&Descriptors
, &MinBus
, &MaxBus
, &IsEnd
);
2186 if (EFI_ERROR (Status
)) {
2187 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_BUS_RANGE_ERR
), gShellDebug1HiiHandle
, Status
);
2188 ShellStatus
= SHELL_NOT_FOUND
;
2196 for (Bus
= MinBus
; Bus
<= MaxBus
; Bus
++) {
2198 // For each devices, enumerate all functions it contains
2200 for (Device
= 0; Device
<= PCI_MAX_DEVICE
; Device
++) {
2202 // For each function, read its configuration space and print summary
2204 for (Func
= 0; Func
<= PCI_MAX_FUNC
; Func
++) {
2205 if (ShellGetExecutionBreakFlag ()) {
2206 ShellStatus
= SHELL_ABORTED
;
2209 Address
= CALC_EFI_PCI_ADDRESS (Bus
, Device
, Func
, 0);
2219 // If VendorId = 0xffff, there does not exist a device at this
2220 // location. For each device, if there is any function on it,
2221 // there must be 1 function at Function 0. So if Func = 0, there
2222 // will be no more functions in the same device, so we can break
2223 // loop to deal with the next device.
2225 if (PciHeader
.VendorId
== 0xffff && Func
== 0) {
2229 if (PciHeader
.VendorId
!= 0xffff) {
2232 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_TITLE
), gShellDebug1HiiHandle
);
2240 sizeof (PciHeader
) / sizeof (UINT32
),
2245 -1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_P1
), gShellDebug1HiiHandle
,
2246 IoDev
->SegmentNumber
,
2252 PciPrintClassCode (PciHeader
.ClassCode
, FALSE
);
2254 -1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_P2
), gShellDebug1HiiHandle
,
2257 PciHeader
.ClassCode
[0]
2261 if (ScreenCount
>= ScreenSize
&& ScreenSize
!= 0) {
2263 // If ScreenSize == 0 we have the console redirected so don't
2269 // If this is not a multi-function device, we can leave the loop
2270 // to deal with the next device.
2272 if (Func
== 0 && ((PciHeader
.HeaderType
& HEADER_TYPE_MULTI_FUNCTION
) == 0x00)) {
2280 // If Descriptor is NULL, Configuration() returns EFI_UNSUPPRORED,
2281 // we assume the bus range is 0~PCI_MAX_BUS. After enumerated all
2282 // devices on all bus, we can leave loop.
2284 if (Descriptors
== NULL
) {
2290 Status
= EFI_SUCCESS
;
2294 ExplainData
= FALSE
;
2299 if (ShellCommandLineGetFlag(Package
, L
"-i")) {
2303 Temp
= ShellCommandLineGetValue(Package
, L
"-s");
2305 Segment
= (UINT16
) ShellStrToUintn (Temp
);
2309 // The first Argument(except "-i") is assumed to be Bus number, second
2310 // to be Device number, and third to be Func number.
2312 Temp
= ShellCommandLineGetRawValue(Package
, 1);
2314 Bus
= (UINT16
)ShellStrToUintn(Temp
);
2315 if (Bus
> MAX_BUS_NUMBER
) {
2316 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellDebug1HiiHandle
, Temp
);
2317 ShellStatus
= SHELL_INVALID_PARAMETER
;
2321 Temp
= ShellCommandLineGetRawValue(Package
, 2);
2323 Device
= (UINT16
) ShellStrToUintn(Temp
);
2324 if (Device
> MAX_DEVICE_NUMBER
){
2325 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellDebug1HiiHandle
, Temp
);
2326 ShellStatus
= SHELL_INVALID_PARAMETER
;
2331 Temp
= ShellCommandLineGetRawValue(Package
, 3);
2333 Func
= (UINT16
) ShellStrToUintn(Temp
);
2334 if (Func
> MAX_FUNCTION_NUMBER
){
2335 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellDebug1HiiHandle
, Temp
);
2336 ShellStatus
= SHELL_INVALID_PARAMETER
;
2342 // Find the protocol interface who's in charge of current segment, and its
2343 // bus range covers the current bus
2345 Status
= PciFindProtocolInterface (
2353 if (EFI_ERROR (Status
)) {
2355 -1, -1, NULL
, STRING_TOKEN (STR_PCI_NO_FIND
), gShellDebug1HiiHandle
,
2359 ShellStatus
= SHELL_NOT_FOUND
;
2363 Address
= CALC_EFI_PCI_ADDRESS (Bus
, Device
, Func
, 0);
2364 Status
= IoDev
->Pci
.Read (
2368 sizeof (ConfigSpace
),
2372 if (EFI_ERROR (Status
)) {
2373 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_NO_CFG
), gShellDebug1HiiHandle
, Status
);
2374 ShellStatus
= SHELL_ACCESS_DENIED
;
2378 mConfigSpace
= &ConfigSpace
;
2383 STRING_TOKEN (STR_PCI_INFO
),
2384 gShellDebug1HiiHandle
,
2396 // Dump standard header of configuration space
2398 SizeOfHeader
= sizeof (ConfigSpace
.Common
) + sizeof (ConfigSpace
.NonCommon
);
2400 DumpHex (2, 0, SizeOfHeader
, &ConfigSpace
);
2401 ShellPrintEx(-1,-1, L
"\r\n");
2404 // Dump device dependent Part of configuration space
2409 sizeof (ConfigSpace
) - SizeOfHeader
,
2414 // If "-i" appears in command line, interpret data in configuration space
2417 Status
= PciExplainData (&ConfigSpace
, Address
, IoDev
);
2421 if (HandleBuf
!= NULL
) {
2422 FreePool (HandleBuf
);
2424 if (Package
!= NULL
) {
2425 ShellCommandLineFreeVarList (Package
);
2427 mConfigSpace
= NULL
;
2432 This function finds out the protocol which is in charge of the given
2433 segment, and its bus range covers the current bus number. It lookes
2434 each instances of RootBridgeIoProtocol handle, until the one meets the
2437 @param[in] HandleBuf Buffer which holds all PCI_ROOT_BRIDIGE_IO_PROTOCOL handles.
2438 @param[in] HandleCount Count of all PCI_ROOT_BRIDIGE_IO_PROTOCOL handles.
2439 @param[in] Segment Segment number of device we are dealing with.
2440 @param[in] Bus Bus number of device we are dealing with.
2441 @param[out] IoDev Handle used to access configuration space of PCI device.
2443 @retval EFI_SUCCESS The command completed successfully.
2444 @retval EFI_INVALID_PARAMETER Invalid parameter.
2448 PciFindProtocolInterface (
2449 IN EFI_HANDLE
*HandleBuf
,
2450 IN UINTN HandleCount
,
2453 OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
**IoDev
2458 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*Descriptors
;
2464 // Go through all handles, until the one meets the criteria is found
2466 for (Index
= 0; Index
< HandleCount
; Index
++) {
2467 Status
= PciGetProtocolAndResource (HandleBuf
[Index
], IoDev
, &Descriptors
);
2468 if (EFI_ERROR (Status
)) {
2472 // When Descriptors == NULL, the Configuration() is not implemented,
2473 // so we only check the Segment number
2475 if (Descriptors
== NULL
&& Segment
== (*IoDev
)->SegmentNumber
) {
2479 if ((*IoDev
)->SegmentNumber
!= Segment
) {
2484 Status
= PciGetNextBusRange (&Descriptors
, &MinBus
, &MaxBus
, &IsEnd
);
2485 if (EFI_ERROR (Status
)) {
2493 if (MinBus
<= Bus
&& MaxBus
>= Bus
) {
2499 return EFI_NOT_FOUND
;
2503 This function gets the protocol interface from the given handle, and
2504 obtains its address space descriptors.
2506 @param[in] Handle The PCI_ROOT_BRIDIGE_IO_PROTOCOL handle.
2507 @param[out] IoDev Handle used to access configuration space of PCI device.
2508 @param[out] Descriptors Points to the address space descriptors.
2510 @retval EFI_SUCCESS The command completed successfully
2513 PciGetProtocolAndResource (
2514 IN EFI_HANDLE Handle
,
2515 OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
**IoDev
,
2516 OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
**Descriptors
2522 // Get inferface from protocol
2524 Status
= gBS
->HandleProtocol (
2526 &gEfiPciRootBridgeIoProtocolGuid
,
2530 if (EFI_ERROR (Status
)) {
2534 // Call Configuration() to get address space descriptors
2536 Status
= (*IoDev
)->Configuration (*IoDev
, (VOID
**)Descriptors
);
2537 if (Status
== EFI_UNSUPPORTED
) {
2538 *Descriptors
= NULL
;
2547 This function get the next bus range of given address space descriptors.
2548 It also moves the pointer backward a node, to get prepared to be called
2551 @param[in, out] Descriptors Points to current position of a serial of address space
2553 @param[out] MinBus The lower range of bus number.
2554 @param[out] MaxBus The upper range of bus number.
2555 @param[out] IsEnd Meet end of the serial of descriptors.
2557 @retval EFI_SUCCESS The command completed successfully.
2560 PciGetNextBusRange (
2561 IN OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
**Descriptors
,
2570 // When *Descriptors is NULL, Configuration() is not implemented, so assume
2571 // range is 0~PCI_MAX_BUS
2573 if ((*Descriptors
) == NULL
) {
2575 *MaxBus
= PCI_MAX_BUS
;
2579 // *Descriptors points to one or more address space descriptors, which
2580 // ends with a end tagged descriptor. Examine each of the descriptors,
2581 // if a bus typed one is found and its bus range covers bus, this handle
2582 // is the handle we are looking for.
2585 while ((*Descriptors
)->Desc
!= ACPI_END_TAG_DESCRIPTOR
) {
2586 if ((*Descriptors
)->ResType
== ACPI_ADDRESS_SPACE_TYPE_BUS
) {
2587 *MinBus
= (UINT16
) (*Descriptors
)->AddrRangeMin
;
2588 *MaxBus
= (UINT16
) (*Descriptors
)->AddrRangeMax
;
2590 return (EFI_SUCCESS
);
2596 if ((*Descriptors
)->Desc
== ACPI_END_TAG_DESCRIPTOR
) {
2604 Explain the data in PCI configuration space. The part which is common for
2605 PCI device and bridge is interpreted in this function. It calls other
2606 functions to interpret data unique for device or bridge.
2608 @param[in] ConfigSpace Data in PCI configuration space.
2609 @param[in] Address Address used to access configuration space of this PCI device.
2610 @param[in] IoDev Handle used to access configuration space of PCI device.
2612 @retval EFI_SUCCESS The command completed successfully.
2616 IN PCI_CONFIG_SPACE
*ConfigSpace
,
2618 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
2621 PCI_COMMON_HEADER
*Common
;
2622 PCI_HEADER_TYPE HeaderType
;
2626 Common
= &(ConfigSpace
->Common
);
2628 ShellPrintEx (-1, -1, L
"\r\n");
2631 // Print Vendor Id and Device Id
2633 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_VID_DID
), gShellDebug1HiiHandle
,
2634 INDEX_OF (&(Common
->VendorId
)),
2636 INDEX_OF (&(Common
->DeviceId
)),
2641 // Print register Command
2643 PciExplainCommand (&(Common
->Command
));
2646 // Print register Status
2648 PciExplainStatus (&(Common
->Status
), TRUE
, PciUndefined
);
2651 // Print register Revision ID
2653 ShellPrintEx(-1, -1, L
"\r\n");
2654 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_RID
), gShellDebug1HiiHandle
,
2655 INDEX_OF (&(Common
->RevisionId
)),
2660 // Print register BIST
2662 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_BIST
), gShellDebug1HiiHandle
, INDEX_OF (&(Common
->Bist
)));
2663 if ((Common
->Bist
& PCI_BIT_7
) != 0) {
2664 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_CAP
), gShellDebug1HiiHandle
, 0x0f & Common
->Bist
);
2666 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_CAP_NO
), gShellDebug1HiiHandle
);
2669 // Print register Cache Line Size
2671 ShellPrintHiiEx(-1, -1, NULL
,
2672 STRING_TOKEN (STR_PCI2_CACHE_LINE_SIZE
),
2673 gShellDebug1HiiHandle
,
2674 INDEX_OF (&(Common
->CacheLineSize
)),
2675 Common
->CacheLineSize
2679 // Print register Latency Timer
2681 ShellPrintHiiEx(-1, -1, NULL
,
2682 STRING_TOKEN (STR_PCI2_LATENCY_TIMER
),
2683 gShellDebug1HiiHandle
,
2684 INDEX_OF (&(Common
->PrimaryLatencyTimer
)),
2685 Common
->PrimaryLatencyTimer
2689 // Print register Header Type
2691 ShellPrintHiiEx(-1, -1, NULL
,
2692 STRING_TOKEN (STR_PCI2_HEADER_TYPE
),
2693 gShellDebug1HiiHandle
,
2694 INDEX_OF (&(Common
->HeaderType
)),
2698 if ((Common
->HeaderType
& PCI_BIT_7
) != 0) {
2699 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MULTI_FUNCTION
), gShellDebug1HiiHandle
);
2702 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_SINGLE_FUNCTION
), gShellDebug1HiiHandle
);
2705 HeaderType
= (PCI_HEADER_TYPE
)(UINT8
) (Common
->HeaderType
& 0x7f);
2706 switch (HeaderType
) {
2708 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_PCI_DEVICE
), gShellDebug1HiiHandle
);
2712 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_P2P_BRIDGE
), gShellDebug1HiiHandle
);
2715 case PciCardBusBridge
:
2716 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_CARDBUS_BRIDGE
), gShellDebug1HiiHandle
);
2720 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RESERVED
), gShellDebug1HiiHandle
);
2721 HeaderType
= PciUndefined
;
2725 // Print register Class Code
2727 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_CLASS
), gShellDebug1HiiHandle
);
2728 PciPrintClassCode ((UINT8
*) Common
->ClassCode
, TRUE
);
2729 ShellPrintEx (-1, -1, L
"\r\n");
2731 if (ShellGetExecutionBreakFlag()) {
2736 // Interpret remaining part of PCI configuration header depending on
2740 Status
= EFI_SUCCESS
;
2741 switch (HeaderType
) {
2743 Status
= PciExplainDeviceData (
2744 &(ConfigSpace
->NonCommon
.Device
),
2748 CapPtr
= ConfigSpace
->NonCommon
.Device
.CapabilitiesPtr
;
2752 Status
= PciExplainBridgeData (
2753 &(ConfigSpace
->NonCommon
.Bridge
),
2757 CapPtr
= ConfigSpace
->NonCommon
.Bridge
.CapabilitiesPtr
;
2760 case PciCardBusBridge
:
2761 Status
= PciExplainCardBusData (
2762 &(ConfigSpace
->NonCommon
.CardBus
),
2766 CapPtr
= ConfigSpace
->NonCommon
.CardBus
.CapabilitiesPtr
;
2773 // If Status bit4 is 1, dump or explain capability structure
2775 if ((Common
->Status
) & EFI_PCI_STATUS_CAPABILITY
) {
2776 PciExplainCapabilityStruct (IoDev
, Address
, CapPtr
);
2783 Explain the device specific part of data in PCI configuration space.
2785 @param[in] Device Data in PCI configuration space.
2786 @param[in] Address Address used to access configuration space of this PCI device.
2787 @param[in] IoDev Handle used to access configuration space of PCI device.
2789 @retval EFI_SUCCESS The command completed successfully.
2792 PciExplainDeviceData (
2793 IN PCI_DEVICE_HEADER
*Device
,
2795 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
2804 // Print Base Address Registers(Bar). When Bar = 0, this Bar does not
2805 // exist. If these no Bar for this function, print "none", otherwise
2806 // list detail information about this Bar.
2808 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BASE_ADDR
), gShellDebug1HiiHandle
, INDEX_OF (Device
->Bar
));
2811 BarCount
= sizeof (Device
->Bar
) / sizeof (Device
->Bar
[0]);
2812 for (Index
= 0; Index
< BarCount
; Index
++) {
2813 if (Device
->Bar
[Index
] == 0) {
2819 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_START_TYPE
), gShellDebug1HiiHandle
);
2820 ShellPrintEx (-1, -1, L
" --------------------------------------------------------------------------");
2823 Status
= PciExplainBar (
2824 &(Device
->Bar
[Index
]),
2825 &(mConfigSpace
->Common
.Command
),
2831 if (EFI_ERROR (Status
)) {
2837 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NONE
), gShellDebug1HiiHandle
);
2840 ShellPrintEx (-1, -1, L
"\r\n --------------------------------------------------------------------------");
2844 // Print register Expansion ROM Base Address
2846 if ((Device
->ROMBar
& PCI_BIT_0
) == 0) {
2847 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_EXPANSION_ROM_DISABLED
), gShellDebug1HiiHandle
, INDEX_OF (&(Device
->ROMBar
)));
2850 ShellPrintHiiEx(-1, -1, NULL
,
2851 STRING_TOKEN (STR_PCI2_EXPANSION_ROM_BASE
),
2852 gShellDebug1HiiHandle
,
2853 INDEX_OF (&(Device
->ROMBar
)),
2858 // Print register Cardbus CIS ptr
2860 ShellPrintHiiEx(-1, -1, NULL
,
2861 STRING_TOKEN (STR_PCI2_CARDBUS_CIS
),
2862 gShellDebug1HiiHandle
,
2863 INDEX_OF (&(Device
->CardBusCISPtr
)),
2864 Device
->CardBusCISPtr
2868 // Print register Sub-vendor ID and subsystem ID
2870 ShellPrintHiiEx(-1, -1, NULL
,
2871 STRING_TOKEN (STR_PCI2_SUB_VENDOR_ID
),
2872 gShellDebug1HiiHandle
,
2873 INDEX_OF (&(Device
->SubVendorId
)),
2877 ShellPrintHiiEx(-1, -1, NULL
,
2878 STRING_TOKEN (STR_PCI2_SUBSYSTEM_ID
),
2879 gShellDebug1HiiHandle
,
2880 INDEX_OF (&(Device
->SubSystemId
)),
2885 // Print register Capabilities Ptr
2887 ShellPrintHiiEx(-1, -1, NULL
,
2888 STRING_TOKEN (STR_PCI2_CAPABILITIES_PTR
),
2889 gShellDebug1HiiHandle
,
2890 INDEX_OF (&(Device
->CapabilitiesPtr
)),
2891 Device
->CapabilitiesPtr
2895 // Print register Interrupt Line and interrupt pin
2897 ShellPrintHiiEx(-1, -1, NULL
,
2898 STRING_TOKEN (STR_PCI2_INTERRUPT_LINE
),
2899 gShellDebug1HiiHandle
,
2900 INDEX_OF (&(Device
->InterruptLine
)),
2901 Device
->InterruptLine
2904 ShellPrintHiiEx(-1, -1, NULL
,
2905 STRING_TOKEN (STR_PCI2_INTERRUPT_PIN
),
2906 gShellDebug1HiiHandle
,
2907 INDEX_OF (&(Device
->InterruptPin
)),
2908 Device
->InterruptPin
2912 // Print register Min_Gnt and Max_Lat
2914 ShellPrintHiiEx(-1, -1, NULL
,
2915 STRING_TOKEN (STR_PCI2_MIN_GNT
),
2916 gShellDebug1HiiHandle
,
2917 INDEX_OF (&(Device
->MinGnt
)),
2921 ShellPrintHiiEx(-1, -1, NULL
,
2922 STRING_TOKEN (STR_PCI2_MAX_LAT
),
2923 gShellDebug1HiiHandle
,
2924 INDEX_OF (&(Device
->MaxLat
)),
2932 Explain the bridge specific part of data in PCI configuration space.
2934 @param[in] Bridge Bridge specific data region in PCI configuration space.
2935 @param[in] Address Address used to access configuration space of this PCI device.
2936 @param[in] IoDev Handle used to access configuration space of PCI device.
2938 @retval EFI_SUCCESS The command completed successfully.
2941 PciExplainBridgeData (
2942 IN PCI_BRIDGE_HEADER
*Bridge
,
2944 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
2954 // Print Base Address Registers. When Bar = 0, this Bar does not
2955 // exist. If these no Bar for this function, print "none", otherwise
2956 // list detail information about this Bar.
2958 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BASE_ADDRESS
), gShellDebug1HiiHandle
, INDEX_OF (&(Bridge
->Bar
)));
2961 BarCount
= sizeof (Bridge
->Bar
) / sizeof (Bridge
->Bar
[0]);
2963 for (Index
= 0; Index
< BarCount
; Index
++) {
2964 if (Bridge
->Bar
[Index
] == 0) {
2970 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_START_TYPE_2
), gShellDebug1HiiHandle
);
2971 ShellPrintEx (-1, -1, L
" --------------------------------------------------------------------------");
2974 Status
= PciExplainBar (
2975 &(Bridge
->Bar
[Index
]),
2976 &(mConfigSpace
->Common
.Command
),
2982 if (EFI_ERROR (Status
)) {
2988 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NONE
), gShellDebug1HiiHandle
);
2990 ShellPrintEx (-1, -1, L
"\r\n --------------------------------------------------------------------------");
2994 // Expansion register ROM Base Address
2996 if ((Bridge
->ROMBar
& PCI_BIT_0
) == 0) {
2997 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NO_EXPANSION_ROM
), gShellDebug1HiiHandle
, INDEX_OF (&(Bridge
->ROMBar
)));
3000 ShellPrintHiiEx(-1, -1, NULL
,
3001 STRING_TOKEN (STR_PCI2_EXPANSION_ROM_BASE_2
),
3002 gShellDebug1HiiHandle
,
3003 INDEX_OF (&(Bridge
->ROMBar
)),
3008 // Print Bus Numbers(Primary, Secondary, and Subordinate
3010 ShellPrintHiiEx(-1, -1, NULL
,
3011 STRING_TOKEN (STR_PCI2_BUS_NUMBERS
),
3012 gShellDebug1HiiHandle
,
3013 INDEX_OF (&(Bridge
->PrimaryBus
)),
3014 INDEX_OF (&(Bridge
->SecondaryBus
)),
3015 INDEX_OF (&(Bridge
->SubordinateBus
))
3018 ShellPrintEx (-1, -1, L
" ------------------------------------------------------\r\n");
3020 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BRIDGE
), gShellDebug1HiiHandle
, Bridge
->PrimaryBus
);
3021 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BRIDGE
), gShellDebug1HiiHandle
, Bridge
->SecondaryBus
);
3022 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BRIDGE
), gShellDebug1HiiHandle
, Bridge
->SubordinateBus
);
3025 // Print register Secondary Latency Timer
3027 ShellPrintHiiEx(-1, -1, NULL
,
3028 STRING_TOKEN (STR_PCI2_SECONDARY_TIMER
),
3029 gShellDebug1HiiHandle
,
3030 INDEX_OF (&(Bridge
->SecondaryLatencyTimer
)),
3031 Bridge
->SecondaryLatencyTimer
3035 // Print register Secondary Status
3037 PciExplainStatus (&(Bridge
->SecondaryStatus
), FALSE
, PciP2pBridge
);
3040 // Print I/O and memory ranges this bridge forwards. There are 3 resource
3041 // types: I/O, memory, and pre-fetchable memory. For each resource type,
3042 // base and limit address are listed.
3044 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RESOURCE_TYPE
), gShellDebug1HiiHandle
);
3045 ShellPrintEx (-1, -1, L
"----------------------------------------------------------------------\r\n");
3050 IoAddress32
= (Bridge
->IoBaseUpper
<< 16 | Bridge
->IoBase
<< 8);
3051 IoAddress32
&= 0xfffff000;
3052 ShellPrintHiiEx(-1, -1, NULL
,
3053 STRING_TOKEN (STR_PCI2_TWO_VARS
),
3054 gShellDebug1HiiHandle
,
3055 INDEX_OF (&(Bridge
->IoBase
)),
3059 IoAddress32
= (Bridge
->IoLimitUpper
<< 16 | Bridge
->IoLimit
<< 8);
3060 IoAddress32
|= 0x00000fff;
3061 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_ONE_VAR
), gShellDebug1HiiHandle
, IoAddress32
);
3064 // Memory Base & Limit
3066 ShellPrintHiiEx(-1, -1, NULL
,
3067 STRING_TOKEN (STR_PCI2_MEMORY
),
3068 gShellDebug1HiiHandle
,
3069 INDEX_OF (&(Bridge
->MemoryBase
)),
3070 (Bridge
->MemoryBase
<< 16) & 0xfff00000
3073 ShellPrintHiiEx(-1, -1, NULL
,
3074 STRING_TOKEN (STR_PCI2_ONE_VAR
),
3075 gShellDebug1HiiHandle
,
3076 (Bridge
->MemoryLimit
<< 16) | 0x000fffff
3080 // Pre-fetch-able Memory Base & Limit
3082 ShellPrintHiiEx(-1, -1, NULL
,
3083 STRING_TOKEN (STR_PCI2_PREFETCHABLE
),
3084 gShellDebug1HiiHandle
,
3085 INDEX_OF (&(Bridge
->PrefetchableMemBase
)),
3086 Bridge
->PrefetchableBaseUpper
,
3087 (Bridge
->PrefetchableMemBase
<< 16) & 0xfff00000
3090 ShellPrintHiiEx(-1, -1, NULL
,
3091 STRING_TOKEN (STR_PCI2_TWO_VARS_2
),
3092 gShellDebug1HiiHandle
,
3093 Bridge
->PrefetchableLimitUpper
,
3094 (Bridge
->PrefetchableMemLimit
<< 16) | 0x000fffff
3098 // Print register Capabilities Pointer
3100 ShellPrintHiiEx(-1, -1, NULL
,
3101 STRING_TOKEN (STR_PCI2_CAPABILITIES_PTR_2
),
3102 gShellDebug1HiiHandle
,
3103 INDEX_OF (&(Bridge
->CapabilitiesPtr
)),
3104 Bridge
->CapabilitiesPtr
3108 // Print register Bridge Control
3110 PciExplainBridgeControl (&(Bridge
->BridgeControl
), PciP2pBridge
);
3113 // Print register Interrupt Line & PIN
3115 ShellPrintHiiEx(-1, -1, NULL
,
3116 STRING_TOKEN (STR_PCI2_INTERRUPT_LINE_2
),
3117 gShellDebug1HiiHandle
,
3118 INDEX_OF (&(Bridge
->InterruptLine
)),
3119 Bridge
->InterruptLine
3122 ShellPrintHiiEx(-1, -1, NULL
,
3123 STRING_TOKEN (STR_PCI2_INTERRUPT_PIN
),
3124 gShellDebug1HiiHandle
,
3125 INDEX_OF (&(Bridge
->InterruptPin
)),
3126 Bridge
->InterruptPin
3133 Explain the Base Address Register(Bar) in PCI configuration space.
3135 @param[in] Bar Points to the Base Address Register intended to interpret.
3136 @param[in] Command Points to the register Command.
3137 @param[in] Address Address used to access configuration space of this PCI device.
3138 @param[in] IoDev Handle used to access configuration space of PCI device.
3139 @param[in, out] Index The Index.
3141 @retval EFI_SUCCESS The command completed successfully.
3148 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
,
3169 // According the bar type, list detail about this bar, for example: 32 or
3170 // 64 bits; pre-fetchable or not.
3172 if ((*Bar
& PCI_BIT_0
) == 0) {
3174 // This bar is of memory type
3178 if ((*Bar
& PCI_BIT_1
) == 0 && (*Bar
& PCI_BIT_2
) == 0) {
3179 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BAR
), gShellDebug1HiiHandle
, *Bar
& 0xfffffff0);
3180 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MEM
), gShellDebug1HiiHandle
);
3181 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_32_BITS
), gShellDebug1HiiHandle
);
3183 } else if ((*Bar
& PCI_BIT_1
) == 0 && (*Bar
& PCI_BIT_2
) != 0) {
3185 CopyMem (&Bar64
, Bar
, sizeof (UINT64
));
3186 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_ONE_VAR_2
), gShellDebug1HiiHandle
, (UINT32
) RShiftU64 ((Bar64
& 0xfffffffffffffff0ULL
), 32));
3187 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_ONE_VAR_3
), gShellDebug1HiiHandle
, (UINT32
) (Bar64
& 0xfffffffffffffff0ULL
));
3188 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MEM
), gShellDebug1HiiHandle
);
3189 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_64_BITS
), gShellDebug1HiiHandle
);
3197 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BAR
), gShellDebug1HiiHandle
, *Bar
& 0xfffffff0);
3198 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MEM_2
), gShellDebug1HiiHandle
);
3201 if ((*Bar
& PCI_BIT_3
) == 0) {
3202 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NO
), gShellDebug1HiiHandle
);
3205 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_YES
), gShellDebug1HiiHandle
);
3210 // This bar is of io type
3213 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_ONE_VAR_4
), gShellDebug1HiiHandle
, *Bar
& 0xfffffffc);
3214 ShellPrintEx (-1, -1, L
"I/O ");
3218 // Get BAR length(or the amount of resource this bar demands for). To get
3219 // Bar length, first we should temporarily disable I/O and memory access
3220 // of this function(by set bits in the register Command), then write all
3221 // "1"s to this bar. The bar value read back is the amount of resource
3222 // this bar demands for.
3225 // Disable io & mem access
3227 OldCommand
= *Command
;
3228 NewCommand
= (UINT16
) (OldCommand
& 0xfffc);
3229 RegAddress
= Address
| INDEX_OF (Command
);
3230 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint16
, RegAddress
, 1, &NewCommand
);
3232 RegAddress
= Address
| INDEX_OF (Bar
);
3235 // Read after write the BAR to get the size
3239 NewBar32
= 0xffffffff;
3241 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint32
, RegAddress
, 1, &NewBar32
);
3242 IoDev
->Pci
.Read (IoDev
, EfiPciWidthUint32
, RegAddress
, 1, &NewBar32
);
3243 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint32
, RegAddress
, 1, &OldBar32
);
3246 NewBar32
= NewBar32
& 0xfffffff0;
3247 NewBar32
= (~NewBar32
) + 1;
3250 NewBar32
= NewBar32
& 0xfffffffc;
3251 NewBar32
= (~NewBar32
) + 1;
3252 NewBar32
= NewBar32
& 0x0000ffff;
3257 CopyMem (&OldBar64
, Bar
, sizeof (UINT64
));
3258 NewBar64
= 0xffffffffffffffffULL
;
3260 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint32
, RegAddress
, 2, &NewBar64
);
3261 IoDev
->Pci
.Read (IoDev
, EfiPciWidthUint32
, RegAddress
, 2, &NewBar64
);
3262 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint32
, RegAddress
, 2, &OldBar64
);
3265 NewBar64
= NewBar64
& 0xfffffffffffffff0ULL
;
3266 NewBar64
= (~NewBar64
) + 1;
3269 NewBar64
= NewBar64
& 0xfffffffffffffffcULL
;
3270 NewBar64
= (~NewBar64
) + 1;
3271 NewBar64
= NewBar64
& 0x000000000000ffff;
3275 // Enable io & mem access
3277 RegAddress
= Address
| INDEX_OF (Command
);
3278 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint16
, RegAddress
, 1, &OldCommand
);
3282 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NEWBAR_32
), gShellDebug1HiiHandle
, NewBar32
);
3283 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NEWBAR_32_2
), gShellDebug1HiiHandle
, NewBar32
+ (*Bar
& 0xfffffff0) - 1);
3286 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RSHIFT
), gShellDebug1HiiHandle
, (UINT32
) RShiftU64 (NewBar64
, 32));
3287 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RSHIFT
), gShellDebug1HiiHandle
, (UINT32
) NewBar64
);
3288 ShellPrintEx (-1, -1, L
" ");
3289 ShellPrintHiiEx(-1, -1, NULL
,
3290 STRING_TOKEN (STR_PCI2_RSHIFT
),
3291 gShellDebug1HiiHandle
,
3292 (UINT32
) RShiftU64 ((NewBar64
+ (Bar64
& 0xfffffffffffffff0ULL
) - 1), 32)
3294 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RSHIFT
), gShellDebug1HiiHandle
, (UINT32
) (NewBar64
+ (Bar64
& 0xfffffffffffffff0ULL
) - 1));
3298 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NEWBAR_32_3
), gShellDebug1HiiHandle
, NewBar32
);
3299 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NEWBAR_32_4
), gShellDebug1HiiHandle
, NewBar32
+ (*Bar
& 0xfffffffc) - 1);
3306 Explain the cardbus specific part of data in PCI configuration space.
3308 @param[in] CardBus CardBus specific region of PCI configuration space.
3309 @param[in] Address Address used to access configuration space of this PCI device.
3310 @param[in] IoDev Handle used to access configuration space of PCI device.
3312 @retval EFI_SUCCESS The command completed successfully.
3315 PciExplainCardBusData (
3316 IN PCI_CARDBUS_HEADER
*CardBus
,
3318 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
3322 PCI_CARDBUS_DATA
*CardBusData
;
3324 ShellPrintHiiEx(-1, -1, NULL
,
3325 STRING_TOKEN (STR_PCI2_CARDBUS_SOCKET
),
3326 gShellDebug1HiiHandle
,
3327 INDEX_OF (&(CardBus
->CardBusSocketReg
)),
3328 CardBus
->CardBusSocketReg
3332 // Print Secondary Status
3334 PciExplainStatus (&(CardBus
->SecondaryStatus
), FALSE
, PciCardBusBridge
);
3337 // Print Bus Numbers(Primary bus number, CardBus bus number, and
3338 // Subordinate bus number
3340 ShellPrintHiiEx(-1, -1, NULL
,
3341 STRING_TOKEN (STR_PCI2_BUS_NUMBERS_2
),
3342 gShellDebug1HiiHandle
,
3343 INDEX_OF (&(CardBus
->PciBusNumber
)),
3344 INDEX_OF (&(CardBus
->CardBusBusNumber
)),
3345 INDEX_OF (&(CardBus
->SubordinateBusNumber
))
3348 ShellPrintEx (-1, -1, L
" ------------------------------------------------------\r\n");
3350 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_CARDBUS
), gShellDebug1HiiHandle
, CardBus
->PciBusNumber
);
3351 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_CARDBUS_2
), gShellDebug1HiiHandle
, CardBus
->CardBusBusNumber
);
3352 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_CARDBUS_3
), gShellDebug1HiiHandle
, CardBus
->SubordinateBusNumber
);
3355 // Print CardBus Latency Timer
3357 ShellPrintHiiEx(-1, -1, NULL
,
3358 STRING_TOKEN (STR_PCI2_CARDBUS_LATENCY
),
3359 gShellDebug1HiiHandle
,
3360 INDEX_OF (&(CardBus
->CardBusLatencyTimer
)),
3361 CardBus
->CardBusLatencyTimer
3365 // Print Memory/Io ranges this cardbus bridge forwards
3367 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RESOURCE_TYPE_2
), gShellDebug1HiiHandle
);
3368 ShellPrintEx (-1, -1, L
"----------------------------------------------------------------------\r\n");
3370 ShellPrintHiiEx(-1, -1, NULL
,
3371 STRING_TOKEN (STR_PCI2_MEM_3
),
3372 gShellDebug1HiiHandle
,
3373 INDEX_OF (&(CardBus
->MemoryBase0
)),
3374 CardBus
->BridgeControl
& PCI_BIT_8
? L
" Prefetchable" : L
"Non-Prefetchable",
3375 CardBus
->MemoryBase0
& 0xfffff000,
3376 CardBus
->MemoryLimit0
| 0x00000fff
3379 ShellPrintHiiEx(-1, -1, NULL
,
3380 STRING_TOKEN (STR_PCI2_MEM_3
),
3381 gShellDebug1HiiHandle
,
3382 INDEX_OF (&(CardBus
->MemoryBase1
)),
3383 CardBus
->BridgeControl
& PCI_BIT_9
? L
" Prefetchable" : L
"Non-Prefetchable",
3384 CardBus
->MemoryBase1
& 0xfffff000,
3385 CardBus
->MemoryLimit1
| 0x00000fff
3388 Io32Bit
= (BOOLEAN
) (CardBus
->IoBase0
& PCI_BIT_0
);
3389 ShellPrintHiiEx(-1, -1, NULL
,
3390 STRING_TOKEN (STR_PCI2_IO_2
),
3391 gShellDebug1HiiHandle
,
3392 INDEX_OF (&(CardBus
->IoBase0
)),
3393 Io32Bit
? L
" 32 bit" : L
" 16 bit",
3394 CardBus
->IoBase0
& (Io32Bit
? 0xfffffffc : 0x0000fffc),
3395 (CardBus
->IoLimit0
& (Io32Bit
? 0xffffffff : 0x0000ffff)) | 0x00000003
3398 Io32Bit
= (BOOLEAN
) (CardBus
->IoBase1
& PCI_BIT_0
);
3399 ShellPrintHiiEx(-1, -1, NULL
,
3400 STRING_TOKEN (STR_PCI2_IO_2
),
3401 gShellDebug1HiiHandle
,
3402 INDEX_OF (&(CardBus
->IoBase1
)),
3403 Io32Bit
? L
" 32 bit" : L
" 16 bit",
3404 CardBus
->IoBase1
& (Io32Bit
? 0xfffffffc : 0x0000fffc),
3405 (CardBus
->IoLimit1
& (Io32Bit
? 0xffffffff : 0x0000ffff)) | 0x00000003
3409 // Print register Interrupt Line & PIN
3411 ShellPrintHiiEx(-1, -1, NULL
,
3412 STRING_TOKEN (STR_PCI2_INTERRUPT_LINE_3
),
3413 gShellDebug1HiiHandle
,
3414 INDEX_OF (&(CardBus
->InterruptLine
)),
3415 CardBus
->InterruptLine
,
3416 INDEX_OF (&(CardBus
->InterruptPin
)),
3417 CardBus
->InterruptPin
3421 // Print register Bridge Control
3423 PciExplainBridgeControl (&(CardBus
->BridgeControl
), PciCardBusBridge
);
3426 // Print some registers in data region of PCI configuration space for cardbus
3427 // bridge. Fields include: Sub VendorId, Subsystem ID, and Legacy Mode Base
3430 CardBusData
= (PCI_CARDBUS_DATA
*) ((UINT8
*) CardBus
+ sizeof (PCI_CARDBUS_HEADER
));
3432 ShellPrintHiiEx(-1, -1, NULL
,
3433 STRING_TOKEN (STR_PCI2_SUB_VENDOR_ID_2
),
3434 gShellDebug1HiiHandle
,
3435 INDEX_OF (&(CardBusData
->SubVendorId
)),
3436 CardBusData
->SubVendorId
,
3437 INDEX_OF (&(CardBusData
->SubSystemId
)),
3438 CardBusData
->SubSystemId
3441 ShellPrintHiiEx(-1, -1, NULL
,
3442 STRING_TOKEN (STR_PCI2_OPTIONAL
),
3443 gShellDebug1HiiHandle
,
3444 INDEX_OF (&(CardBusData
->LegacyBase
)),
3445 CardBusData
->LegacyBase
3452 Explain each meaningful bit of register Status. The definition of Status is
3453 slightly different depending on the PCI header type.
3455 @param[in] Status Points to the content of register Status.
3456 @param[in] MainStatus Indicates if this register is main status(not secondary
3458 @param[in] HeaderType Header type of this PCI device.
3460 @retval EFI_SUCCESS The command completed successfully.
3465 IN BOOLEAN MainStatus
,
3466 IN PCI_HEADER_TYPE HeaderType
3470 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_STATUS
), gShellDebug1HiiHandle
, INDEX_OF (Status
), *Status
);
3473 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_SECONDARY_STATUS
), gShellDebug1HiiHandle
, INDEX_OF (Status
), *Status
);
3476 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NEW_CAPABILITIES
), gShellDebug1HiiHandle
, (*Status
& PCI_BIT_4
) != 0);
3479 // Bit 5 is meaningless for CardBus Bridge
3481 if (HeaderType
== PciCardBusBridge
) {
3482 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_66_CAPABLE
), gShellDebug1HiiHandle
, (*Status
& PCI_BIT_5
) != 0);
3485 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_66_CAPABLE_2
), gShellDebug1HiiHandle
, (*Status
& PCI_BIT_5
) != 0);
3488 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_FAST_BACK
), gShellDebug1HiiHandle
, (*Status
& PCI_BIT_7
) != 0);
3490 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MASTER_DATA
), gShellDebug1HiiHandle
, (*Status
& PCI_BIT_8
) != 0);
3492 // Bit 9 and bit 10 together decides the DEVSEL timing
3494 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_DEVSEL_TIMING
), gShellDebug1HiiHandle
);
3495 if ((*Status
& PCI_BIT_9
) == 0 && (*Status
& PCI_BIT_10
) == 0) {
3496 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_FAST
), gShellDebug1HiiHandle
);
3498 } else if ((*Status
& PCI_BIT_9
) != 0 && (*Status
& PCI_BIT_10
) == 0) {
3499 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MEDIUM
), gShellDebug1HiiHandle
);
3501 } else if ((*Status
& PCI_BIT_9
) == 0 && (*Status
& PCI_BIT_10
) != 0) {
3502 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_SLOW
), gShellDebug1HiiHandle
);
3505 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RESERVED_2
), gShellDebug1HiiHandle
);
3508 ShellPrintHiiEx(-1, -1, NULL
,
3509 STRING_TOKEN (STR_PCI2_SIGNALED_TARGET
),
3510 gShellDebug1HiiHandle
,
3511 (*Status
& PCI_BIT_11
) != 0
3514 ShellPrintHiiEx(-1, -1, NULL
,
3515 STRING_TOKEN (STR_PCI2_RECEIVED_TARGET
),
3516 gShellDebug1HiiHandle
,
3517 (*Status
& PCI_BIT_12
) != 0
3520 ShellPrintHiiEx(-1, -1, NULL
,
3521 STRING_TOKEN (STR_PCI2_RECEIVED_MASTER
),
3522 gShellDebug1HiiHandle
,
3523 (*Status
& PCI_BIT_13
) != 0
3527 ShellPrintHiiEx(-1, -1, NULL
,
3528 STRING_TOKEN (STR_PCI2_SIGNALED_ERROR
),
3529 gShellDebug1HiiHandle
,
3530 (*Status
& PCI_BIT_14
) != 0
3534 ShellPrintHiiEx(-1, -1, NULL
,
3535 STRING_TOKEN (STR_PCI2_RECEIVED_ERROR
),
3536 gShellDebug1HiiHandle
,
3537 (*Status
& PCI_BIT_14
) != 0
3541 ShellPrintHiiEx(-1, -1, NULL
,
3542 STRING_TOKEN (STR_PCI2_DETECTED_ERROR
),
3543 gShellDebug1HiiHandle
,
3544 (*Status
& PCI_BIT_15
) != 0
3551 Explain each meaningful bit of register Command.
3553 @param[in] Command Points to the content of register Command.
3555 @retval EFI_SUCCESS The command completed successfully.
3563 // Print the binary value of register Command
3565 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_COMMAND
), gShellDebug1HiiHandle
, INDEX_OF (Command
), *Command
);
3568 // Explain register Command bit by bit
3570 ShellPrintHiiEx(-1, -1, NULL
,
3571 STRING_TOKEN (STR_PCI2_SPACE_ACCESS_DENIED
),
3572 gShellDebug1HiiHandle
,
3573 (*Command
& PCI_BIT_0
) != 0
3576 ShellPrintHiiEx(-1, -1, NULL
,
3577 STRING_TOKEN (STR_PCI2_MEMORY_SPACE
),
3578 gShellDebug1HiiHandle
,
3579 (*Command
& PCI_BIT_1
) != 0
3582 ShellPrintHiiEx(-1, -1, NULL
,
3583 STRING_TOKEN (STR_PCI2_BEHAVE_BUS_MASTER
),
3584 gShellDebug1HiiHandle
,
3585 (*Command
& PCI_BIT_2
) != 0
3588 ShellPrintHiiEx(-1, -1, NULL
,
3589 STRING_TOKEN (STR_PCI2_MONITOR_SPECIAL_CYCLE
),
3590 gShellDebug1HiiHandle
,
3591 (*Command
& PCI_BIT_3
) != 0
3594 ShellPrintHiiEx(-1, -1, NULL
,
3595 STRING_TOKEN (STR_PCI2_MEM_WRITE_INVALIDATE
),
3596 gShellDebug1HiiHandle
,
3597 (*Command
& PCI_BIT_4
) != 0
3600 ShellPrintHiiEx(-1, -1, NULL
,
3601 STRING_TOKEN (STR_PCI2_PALETTE_SNOOPING
),
3602 gShellDebug1HiiHandle
,
3603 (*Command
& PCI_BIT_5
) != 0
3606 ShellPrintHiiEx(-1, -1, NULL
,
3607 STRING_TOKEN (STR_PCI2_ASSERT_PERR
),
3608 gShellDebug1HiiHandle
,
3609 (*Command
& PCI_BIT_6
) != 0
3612 ShellPrintHiiEx(-1, -1, NULL
,
3613 STRING_TOKEN (STR_PCI2_DO_ADDR_STEPPING
),
3614 gShellDebug1HiiHandle
,
3615 (*Command
& PCI_BIT_7
) != 0
3618 ShellPrintHiiEx(-1, -1, NULL
,
3619 STRING_TOKEN (STR_PCI2_SERR_DRIVER
),
3620 gShellDebug1HiiHandle
,
3621 (*Command
& PCI_BIT_8
) != 0
3624 ShellPrintHiiEx(-1, -1, NULL
,
3625 STRING_TOKEN (STR_PCI2_FAST_BACK_2
),
3626 gShellDebug1HiiHandle
,
3627 (*Command
& PCI_BIT_9
) != 0
3634 Explain each meaningful bit of register Bridge Control.
3636 @param[in] BridgeControl Points to the content of register Bridge Control.
3637 @param[in] HeaderType The headertype.
3639 @retval EFI_SUCCESS The command completed successfully.
3642 PciExplainBridgeControl (
3643 IN UINT16
*BridgeControl
,
3644 IN PCI_HEADER_TYPE HeaderType
3647 ShellPrintHiiEx(-1, -1, NULL
,
3648 STRING_TOKEN (STR_PCI2_BRIDGE_CONTROL
),
3649 gShellDebug1HiiHandle
,
3650 INDEX_OF (BridgeControl
),
3654 ShellPrintHiiEx(-1, -1, NULL
,
3655 STRING_TOKEN (STR_PCI2_PARITY_ERROR
),
3656 gShellDebug1HiiHandle
,
3657 (*BridgeControl
& PCI_BIT_0
) != 0
3659 ShellPrintHiiEx(-1, -1, NULL
,
3660 STRING_TOKEN (STR_PCI2_SERR_ENABLE
),
3661 gShellDebug1HiiHandle
,
3662 (*BridgeControl
& PCI_BIT_1
) != 0
3664 ShellPrintHiiEx(-1, -1, NULL
,
3665 STRING_TOKEN (STR_PCI2_ISA_ENABLE
),
3666 gShellDebug1HiiHandle
,
3667 (*BridgeControl
& PCI_BIT_2
) != 0
3669 ShellPrintHiiEx(-1, -1, NULL
,
3670 STRING_TOKEN (STR_PCI2_VGA_ENABLE
),
3671 gShellDebug1HiiHandle
,
3672 (*BridgeControl
& PCI_BIT_3
) != 0
3674 ShellPrintHiiEx(-1, -1, NULL
,
3675 STRING_TOKEN (STR_PCI2_MASTER_ABORT
),
3676 gShellDebug1HiiHandle
,
3677 (*BridgeControl
& PCI_BIT_5
) != 0
3681 // Register Bridge Control has some slight differences between P2P bridge
3682 // and Cardbus bridge from bit 6 to bit 11.
3684 if (HeaderType
== PciP2pBridge
) {
3685 ShellPrintHiiEx(-1, -1, NULL
,
3686 STRING_TOKEN (STR_PCI2_SECONDARY_BUS_RESET
),
3687 gShellDebug1HiiHandle
,
3688 (*BridgeControl
& PCI_BIT_6
) != 0
3690 ShellPrintHiiEx(-1, -1, NULL
,
3691 STRING_TOKEN (STR_PCI2_FAST_ENABLE
),
3692 gShellDebug1HiiHandle
,
3693 (*BridgeControl
& PCI_BIT_7
) != 0
3695 ShellPrintHiiEx(-1, -1, NULL
,
3696 STRING_TOKEN (STR_PCI2_PRIMARY_DISCARD_TIMER
),
3697 gShellDebug1HiiHandle
,
3698 (*BridgeControl
& PCI_BIT_8
)!=0 ? L
"2^10" : L
"2^15"
3700 ShellPrintHiiEx(-1, -1, NULL
,
3701 STRING_TOKEN (STR_PCI2_SECONDARY_DISCARD_TIMER
),
3702 gShellDebug1HiiHandle
,
3703 (*BridgeControl
& PCI_BIT_9
)!=0 ? L
"2^10" : L
"2^15"
3705 ShellPrintHiiEx(-1, -1, NULL
,
3706 STRING_TOKEN (STR_PCI2_DISCARD_TIMER_STATUS
),
3707 gShellDebug1HiiHandle
,
3708 (*BridgeControl
& PCI_BIT_10
) != 0
3710 ShellPrintHiiEx(-1, -1, NULL
,
3711 STRING_TOKEN (STR_PCI2_DISCARD_TIMER_SERR
),
3712 gShellDebug1HiiHandle
,
3713 (*BridgeControl
& PCI_BIT_11
) != 0
3717 ShellPrintHiiEx(-1, -1, NULL
,
3718 STRING_TOKEN (STR_PCI2_CARDBUS_RESET
),
3719 gShellDebug1HiiHandle
,
3720 (*BridgeControl
& PCI_BIT_6
) != 0
3722 ShellPrintHiiEx(-1, -1, NULL
,
3723 STRING_TOKEN (STR_PCI2_IREQ_ENABLE
),
3724 gShellDebug1HiiHandle
,
3725 (*BridgeControl
& PCI_BIT_7
) != 0
3727 ShellPrintHiiEx(-1, -1, NULL
,
3728 STRING_TOKEN (STR_PCI2_WRITE_POSTING_ENABLE
),
3729 gShellDebug1HiiHandle
,
3730 (*BridgeControl
& PCI_BIT_10
) != 0
3738 Print each capability structure.
3740 @param[in] IoDev The pointer to the deivce.
3741 @param[in] Address The address to start at.
3742 @param[in] CapPtr The offset from the address.
3744 @retval EFI_SUCCESS The operation was successful.
3747 PciExplainCapabilityStruct (
3748 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
,
3753 UINT8 CapabilityPtr
;
3754 UINT16 CapabilityEntry
;
3758 CapabilityPtr
= CapPtr
;
3761 // Go through the Capability list
3763 while ((CapabilityPtr
>= 0x40) && ((CapabilityPtr
& 0x03) == 0x00)) {
3764 RegAddress
= Address
+ CapabilityPtr
;
3765 IoDev
->Pci
.Read (IoDev
, EfiPciWidthUint16
, RegAddress
, 1, &CapabilityEntry
);
3767 CapabilityID
= (UINT8
) CapabilityEntry
;
3770 // Explain PciExpress data
3772 if (EFI_PCI_CAPABILITY_ID_PCIEXP
== CapabilityID
) {
3773 PciExplainPciExpress (IoDev
, Address
, CapabilityPtr
);
3777 // Explain other capabilities here
3779 CapabilityPtr
= (UINT8
) (CapabilityEntry
>> 8);
3786 Print out information of the capability information.
3788 @param[in] PciExpressCap The pointer to the structure about the device.
3790 @retval EFI_SUCCESS The operation was successful.
3794 IN PCIE_CAP_STURCTURE
*PciExpressCap
3798 CHAR16
*DevicePortType
;
3800 PcieCapReg
= PciExpressCap
->PcieCapReg
;
3801 ShellPrintEx (-1, -1,
3802 L
" Capability Version(3:0): %E0x%04x%N\r\n",
3803 PCIE_CAP_VERSION (PcieCapReg
)
3805 if ((UINT8
) PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg
) < PCIE_DEVICE_PORT_TYPE_MAX
) {
3806 DevicePortType
= DevicePortTypeTable
[PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg
)];
3808 DevicePortType
= L
"Unknown Type";
3810 ShellPrintEx (-1, -1,
3811 L
" Device/PortType(7:4): %E%s%N\r\n",
3815 // 'Slot Implemented' is only valid for:
3816 // a) Root Port of PCI Express Root Complex, or
3817 // b) Downstream Port of PCI Express Switch
3819 if (PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg
) == PCIE_ROOT_COMPLEX_ROOT_PORT
||
3820 PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg
) == PCIE_SWITCH_DOWNSTREAM_PORT
) {
3821 ShellPrintEx (-1, -1,
3822 L
" Slot Implemented(8): %E%d%N\r\n",
3823 PCIE_CAP_SLOT_IMPLEMENTED (PcieCapReg
)
3826 ShellPrintEx (-1, -1,
3827 L
" Interrupt Message Number(13:9): %E0x%05x%N\r\n",
3828 PCIE_CAP_INT_MSG_NUM (PcieCapReg
)
3834 Print out information of the device capability information.
3836 @param[in] PciExpressCap The pointer to the structure about the device.
3838 @retval EFI_SUCCESS The operation was successful.
3841 ExplainPcieDeviceCap (
3842 IN PCIE_CAP_STURCTURE
*PciExpressCap
3846 UINT32 PcieDeviceCap
;
3847 UINT8 DevicePortType
;
3851 PcieCapReg
= PciExpressCap
->PcieCapReg
;
3852 PcieDeviceCap
= PciExpressCap
->PcieDeviceCap
;
3853 DevicePortType
= (UINT8
) PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg
);
3854 ShellPrintEx (-1, -1, L
" Max_Payload_Size Supported(2:0): ");
3855 if (PCIE_CAP_MAX_PAYLOAD (PcieDeviceCap
) < 6) {
3856 ShellPrintEx (-1, -1, L
"%E%d bytes%N\r\n", 1 << (PCIE_CAP_MAX_PAYLOAD (PcieDeviceCap
) + 7));
3858 ShellPrintEx (-1, -1, L
"%EUnknown%N\r\n");
3860 ShellPrintEx (-1, -1,
3861 L
" Phantom Functions Supported(4:3): %E%d%N\r\n",
3862 PCIE_CAP_PHANTOM_FUNC (PcieDeviceCap
)
3864 ShellPrintEx (-1, -1,
3865 L
" Extended Tag Field Supported(5): %E%d-bit Tag field supported%N\r\n",
3866 PCIE_CAP_EXTENDED_TAG (PcieDeviceCap
) ? 8 : 5
3869 // Endpoint L0s and L1 Acceptable Latency is only valid for Endpoint
3871 if (IS_PCIE_ENDPOINT (DevicePortType
)) {
3872 L0sLatency
= (UINT8
) PCIE_CAP_L0SLATENCY (PcieDeviceCap
);
3873 L1Latency
= (UINT8
) PCIE_CAP_L1LATENCY (PcieDeviceCap
);
3874 ShellPrintEx (-1, -1, L
" Endpoint L0s Acceptable Latency(8:6): ");
3875 if (L0sLatency
< 4) {
3876 ShellPrintEx (-1, -1, L
"%EMaximum of %d ns%N\r\n", 1 << (L0sLatency
+ 6));
3878 if (L0sLatency
< 7) {
3879 ShellPrintEx (-1, -1, L
"%EMaximum of %d us%N\r\n", 1 << (L0sLatency
- 3));
3881 ShellPrintEx (-1, -1, L
"%ENo limit%N\r\n");
3884 ShellPrintEx (-1, -1, L
" Endpoint L1 Acceptable Latency(11:9): ");
3885 if (L1Latency
< 7) {
3886 ShellPrintEx (-1, -1, L
"%EMaximum of %d us%N\r\n", 1 << (L1Latency
+ 1));
3888 ShellPrintEx (-1, -1, L
"%ENo limit%N\r\n");
3891 ShellPrintEx (-1, -1,
3892 L
" Role-based Error Reporting(15): %E%d%N\r\n",
3893 PCIE_CAP_ERR_REPORTING (PcieDeviceCap
)
3896 // Only valid for Upstream Port:
3897 // a) Captured Slot Power Limit Value
3898 // b) Captured Slot Power Scale
3900 if (DevicePortType
== PCIE_SWITCH_UPSTREAM_PORT
) {
3901 ShellPrintEx (-1, -1,
3902 L
" Captured Slot Power Limit Value(25:18): %E0x%02x%N\r\n",
3903 PCIE_CAP_SLOT_POWER_VALUE (PcieDeviceCap
)
3905 ShellPrintEx (-1, -1,
3906 L
" Captured Slot Power Limit Scale(27:26): %E%s%N\r\n",
3907 SlotPwrLmtScaleTable
[PCIE_CAP_SLOT_POWER_SCALE (PcieDeviceCap
)]
3911 // Function Level Reset Capability is only valid for Endpoint
3913 if (IS_PCIE_ENDPOINT (DevicePortType
)) {
3914 ShellPrintEx (-1, -1,
3915 L
" Function Level Reset Capability(28): %E%d%N\r\n",
3916 PCIE_CAP_FUNC_LEVEL_RESET (PcieDeviceCap
)
3923 Print out information of the device control information.
3925 @param[in] PciExpressCap The pointer to the structure about the device.
3927 @retval EFI_SUCCESS The operation was successful.
3930 ExplainPcieDeviceControl (
3931 IN PCIE_CAP_STURCTURE
*PciExpressCap
3935 UINT16 PcieDeviceControl
;
3937 PcieCapReg
= PciExpressCap
->PcieCapReg
;
3938 PcieDeviceControl
= PciExpressCap
->DeviceControl
;
3939 ShellPrintEx (-1, -1,
3940 L
" Correctable Error Reporting Enable(0): %E%d%N\r\n",
3941 PCIE_CAP_COR_ERR_REPORTING_ENABLE (PcieDeviceControl
)
3943 ShellPrintEx (-1, -1,
3944 L
" Non-Fatal Error Reporting Enable(1): %E%d%N\r\n",
3945 PCIE_CAP_NONFAT_ERR_REPORTING_ENABLE (PcieDeviceControl
)
3947 ShellPrintEx (-1, -1,
3948 L
" Fatal Error Reporting Enable(2): %E%d%N\r\n",
3949 PCIE_CAP_FATAL_ERR_REPORTING_ENABLE (PcieDeviceControl
)
3951 ShellPrintEx (-1, -1,
3952 L
" Unsupported Request Reporting Enable(3): %E%d%N\r\n",
3953 PCIE_CAP_UNSUP_REQ_REPORTING_ENABLE (PcieDeviceControl
)
3955 ShellPrintEx (-1, -1,
3956 L
" Enable Relaxed Ordering(4): %E%d%N\r\n",
3957 PCIE_CAP_RELAXED_ORDERING_ENABLE (PcieDeviceControl
)
3959 ShellPrintEx (-1, -1, L
" Max_Payload_Size(7:5): ");
3960 if (PCIE_CAP_MAX_PAYLOAD_SIZE (PcieDeviceControl
) < 6) {
3961 ShellPrintEx (-1, -1, L
"%E%d bytes%N\r\n", 1 << (PCIE_CAP_MAX_PAYLOAD_SIZE (PcieDeviceControl
) + 7));
3963 ShellPrintEx (-1, -1, L
"%EUnknown%N\r\n");
3965 ShellPrintEx (-1, -1,
3966 L
" Extended Tag Field Enable(8): %E%d%N\r\n",
3967 PCIE_CAP_EXTENDED_TAG_ENABLE (PcieDeviceControl
)
3969 ShellPrintEx (-1, -1,
3970 L
" Phantom Functions Enable(9): %E%d%N\r\n",
3971 PCIE_CAP_PHANTOM_FUNC_ENABLE (PcieDeviceControl
)
3973 ShellPrintEx (-1, -1,
3974 L
" Auxiliary (AUX) Power PM Enable(10): %E%d%N\r\n",
3975 PCIE_CAP_AUX_PM_ENABLE (PcieDeviceControl
)
3977 ShellPrintEx (-1, -1,
3978 L
" Enable No Snoop(11): %E%d%N\r\n",
3979 PCIE_CAP_NO_SNOOP_ENABLE (PcieDeviceControl
)
3981 ShellPrintEx (-1, -1, L
" Max_Read_Request_Size(14:12): ");
3982 if (PCIE_CAP_MAX_READ_REQ_SIZE (PcieDeviceControl
) < 6) {
3983 ShellPrintEx (-1, -1, L
"%E%d bytes%N\r\n", 1 << (PCIE_CAP_MAX_READ_REQ_SIZE (PcieDeviceControl
) + 7));
3985 ShellPrintEx (-1, -1, L
"%EUnknown%N\r\n");
3988 // Read operation is only valid for PCI Express to PCI/PCI-X Bridges
3990 if (PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg
) == PCIE_PCIE_TO_PCIX_BRIDGE
) {
3991 ShellPrintEx (-1, -1,
3992 L
" Bridge Configuration Retry Enable(15): %E%d%N\r\n",
3993 PCIE_CAP_BRG_CONF_RETRY (PcieDeviceControl
)
4000 Print out information of the device status information.
4002 @param[in] PciExpressCap The pointer to the structure about the device.
4004 @retval EFI_SUCCESS The operation was successful.
4007 ExplainPcieDeviceStatus (
4008 IN PCIE_CAP_STURCTURE
*PciExpressCap
4011 UINT16 PcieDeviceStatus
;
4013 PcieDeviceStatus
= PciExpressCap
->DeviceStatus
;
4014 ShellPrintEx (-1, -1,
4015 L
" Correctable Error Detected(0): %E%d%N\r\n",
4016 PCIE_CAP_COR_ERR_DETECTED (PcieDeviceStatus
)
4018 ShellPrintEx (-1, -1,
4019 L
" Non-Fatal Error Detected(1): %E%d%N\r\n",
4020 PCIE_CAP_NONFAT_ERR_DETECTED (PcieDeviceStatus
)
4022 ShellPrintEx (-1, -1,
4023 L
" Fatal Error Detected(2): %E%d%N\r\n",
4024 PCIE_CAP_FATAL_ERR_DETECTED (PcieDeviceStatus
)
4026 ShellPrintEx (-1, -1,
4027 L
" Unsupported Request Detected(3): %E%d%N\r\n",
4028 PCIE_CAP_UNSUP_REQ_DETECTED (PcieDeviceStatus
)
4030 ShellPrintEx (-1, -1,
4031 L
" AUX Power Detected(4): %E%d%N\r\n",
4032 PCIE_CAP_AUX_POWER_DETECTED (PcieDeviceStatus
)
4034 ShellPrintEx (-1, -1,
4035 L
" Transactions Pending(5): %E%d%N\r\n",
4036 PCIE_CAP_TRANSACTION_PENDING (PcieDeviceStatus
)
4042 Print out information of the device link information.
4044 @param[in] PciExpressCap The pointer to the structure about the device.
4046 @retval EFI_SUCCESS The operation was successful.
4049 ExplainPcieLinkCap (
4050 IN PCIE_CAP_STURCTURE
*PciExpressCap
4054 CHAR16
*SupLinkSpeeds
;
4057 PcieLinkCap
= PciExpressCap
->LinkCap
;
4058 switch (PCIE_CAP_SUP_LINK_SPEEDS (PcieLinkCap
)) {
4060 SupLinkSpeeds
= L
"2.5 GT/s";
4063 SupLinkSpeeds
= L
"5.0 GT/s and 2.5 GT/s";
4066 SupLinkSpeeds
= L
"Unknown";
4069 ShellPrintEx (-1, -1,
4070 L
" Supported Link Speeds(3:0): %E%s supported%N\r\n",
4073 ShellPrintEx (-1, -1,
4074 L
" Maximum Link Width(9:4): %Ex%d%N\r\n",
4075 PCIE_CAP_MAX_LINK_WIDTH (PcieLinkCap
)
4077 switch (PCIE_CAP_ASPM_SUPPORT (PcieLinkCap
)) {
4079 AspmValue
= L
"L0s Entry";
4082 AspmValue
= L
"L0s and L1";
4085 AspmValue
= L
"Reserved";
4088 ShellPrintEx (-1, -1,
4089 L
" Active State Power Management Support(11:10): %E%s Supported%N\r\n",
4092 ShellPrintEx (-1, -1,
4093 L
" L0s Exit Latency(14:12): %E%s%N\r\n",
4094 L0sLatencyStrTable
[PCIE_CAP_L0S_LATENCY (PcieLinkCap
)]
4096 ShellPrintEx (-1, -1,
4097 L
" L1 Exit Latency(17:15): %E%s%N\r\n",
4098 L1LatencyStrTable
[PCIE_CAP_L0S_LATENCY (PcieLinkCap
)]
4100 ShellPrintEx (-1, -1,
4101 L
" Clock Power Management(18): %E%d%N\r\n",
4102 PCIE_CAP_CLOCK_PM (PcieLinkCap
)
4104 ShellPrintEx (-1, -1,
4105 L
" Surprise Down Error Reporting Capable(19): %E%d%N\r\n",
4106 PCIE_CAP_SUP_DOWN_ERR_REPORTING (PcieLinkCap
)
4108 ShellPrintEx (-1, -1,
4109 L
" Data Link Layer Link Active Reporting Capable(20): %E%d%N\r\n",
4110 PCIE_CAP_LINK_ACTIVE_REPORTING (PcieLinkCap
)
4112 ShellPrintEx (-1, -1,
4113 L
" Link Bandwidth Notification Capability(21): %E%d%N\r\n",
4114 PCIE_CAP_LINK_BWD_NOTIF_CAP (PcieLinkCap
)
4116 ShellPrintEx (-1, -1,
4117 L
" Port Number(31:24): %E0x%02x%N\r\n",
4118 PCIE_CAP_PORT_NUMBER (PcieLinkCap
)
4124 Print out information of the device link control information.
4126 @param[in] PciExpressCap The pointer to the structure about the device.
4128 @retval EFI_SUCCESS The operation was successful.
4131 ExplainPcieLinkControl (
4132 IN PCIE_CAP_STURCTURE
*PciExpressCap
4135 UINT16 PcieLinkControl
;
4136 UINT8 DevicePortType
;
4138 PcieLinkControl
= PciExpressCap
->LinkControl
;
4139 DevicePortType
= (UINT8
) PCIE_CAP_DEVICEPORT_TYPE (PciExpressCap
->PcieCapReg
);
4140 ShellPrintEx (-1, -1,
4141 L
" Active State Power Management Control(1:0): %E%s%N\r\n",
4142 ASPMCtrlStrTable
[PCIE_CAP_ASPM_CONTROL (PcieLinkControl
)]
4145 // RCB is not applicable to switches
4147 if (!IS_PCIE_SWITCH(DevicePortType
)) {
4148 ShellPrintEx (-1, -1,
4149 L
" Read Completion Boundary (RCB)(3): %E%d byte%N\r\n",
4150 1 << (PCIE_CAP_RCB (PcieLinkControl
) + 6)
4154 // Link Disable is reserved on
4156 // b) PCI Express to PCI/PCI-X bridges
4157 // c) Upstream Ports of Switches
4159 if (!IS_PCIE_ENDPOINT (DevicePortType
) &&
4160 DevicePortType
!= PCIE_SWITCH_UPSTREAM_PORT
&&
4161 DevicePortType
!= PCIE_PCIE_TO_PCIX_BRIDGE
) {
4162 ShellPrintEx (-1, -1,
4163 L
" Link Disable(4): %E%d%N\r\n",
4164 PCIE_CAP_LINK_DISABLE (PcieLinkControl
)
4167 ShellPrintEx (-1, -1,
4168 L
" Common Clock Configuration(6): %E%d%N\r\n",
4169 PCIE_CAP_COMMON_CLK_CONF (PcieLinkControl
)
4171 ShellPrintEx (-1, -1,
4172 L
" Extended Synch(7): %E%d%N\r\n",
4173 PCIE_CAP_EXT_SYNC (PcieLinkControl
)
4175 ShellPrintEx (-1, -1,
4176 L
" Enable Clock Power Management(8): %E%d%N\r\n",
4177 PCIE_CAP_CLK_PWR_MNG (PcieLinkControl
)
4179 ShellPrintEx (-1, -1,
4180 L
" Hardware Autonomous Width Disable(9): %E%d%N\r\n",
4181 PCIE_CAP_HW_AUTO_WIDTH_DISABLE (PcieLinkControl
)
4183 ShellPrintEx (-1, -1,
4184 L
" Link Bandwidth Management Interrupt Enable(10): %E%d%N\r\n",
4185 PCIE_CAP_LINK_BDW_MNG_INT_EN (PcieLinkControl
)
4187 ShellPrintEx (-1, -1,
4188 L
" Link Autonomous Bandwidth Interrupt Enable(11): %E%d%N\r\n",
4189 PCIE_CAP_LINK_AUTO_BDW_INT_EN (PcieLinkControl
)
4195 Print out information of the device link status information.
4197 @param[in] PciExpressCap The pointer to the structure about the device.
4199 @retval EFI_SUCCESS The operation was successful.
4202 ExplainPcieLinkStatus (
4203 IN PCIE_CAP_STURCTURE
*PciExpressCap
4206 UINT16 PcieLinkStatus
;
4207 CHAR16
*SupLinkSpeeds
;
4209 PcieLinkStatus
= PciExpressCap
->LinkStatus
;
4210 switch (PCIE_CAP_CUR_LINK_SPEED (PcieLinkStatus
)) {
4212 SupLinkSpeeds
= L
"2.5 GT/s";
4215 SupLinkSpeeds
= L
"5.0 GT/s";
4218 SupLinkSpeeds
= L
"Reserved";
4221 ShellPrintEx (-1, -1,
4222 L
" Current Link Speed(3:0): %E%s%N\r\n",
4225 ShellPrintEx (-1, -1,
4226 L
" Negotiated Link Width(9:4): %Ex%d%N\r\n",
4227 PCIE_CAP_NEGO_LINK_WIDTH (PcieLinkStatus
)
4229 ShellPrintEx (-1, -1,
4230 L
" Link Training(11): %E%d%N\r\n",
4231 PCIE_CAP_LINK_TRAINING (PcieLinkStatus
)
4233 ShellPrintEx (-1, -1,
4234 L
" Slot Clock Configuration(12): %E%d%N\r\n",
4235 PCIE_CAP_SLOT_CLK_CONF (PcieLinkStatus
)
4237 ShellPrintEx (-1, -1,
4238 L
" Data Link Layer Link Active(13): %E%d%N\r\n",
4239 PCIE_CAP_DATA_LINK_ACTIVE (PcieLinkStatus
)
4241 ShellPrintEx (-1, -1,
4242 L
" Link Bandwidth Management Status(14): %E%d%N\r\n",
4243 PCIE_CAP_LINK_BDW_MNG_STAT (PcieLinkStatus
)
4245 ShellPrintEx (-1, -1,
4246 L
" Link Autonomous Bandwidth Status(15): %E%d%N\r\n",
4247 PCIE_CAP_LINK_AUTO_BDW_STAT (PcieLinkStatus
)
4253 Print out information of the device slot information.
4255 @param[in] PciExpressCap The pointer to the structure about the device.
4257 @retval EFI_SUCCESS The operation was successful.
4260 ExplainPcieSlotCap (
4261 IN PCIE_CAP_STURCTURE
*PciExpressCap
4266 PcieSlotCap
= PciExpressCap
->SlotCap
;
4268 ShellPrintEx (-1, -1,
4269 L
" Attention Button Present(0): %E%d%N\r\n",
4270 PCIE_CAP_ATT_BUT_PRESENT (PcieSlotCap
)
4272 ShellPrintEx (-1, -1,
4273 L
" Power Controller Present(1): %E%d%N\r\n",
4274 PCIE_CAP_PWR_CTRLLER_PRESENT (PcieSlotCap
)
4276 ShellPrintEx (-1, -1,
4277 L
" MRL Sensor Present(2): %E%d%N\r\n",
4278 PCIE_CAP_MRL_SENSOR_PRESENT (PcieSlotCap
)
4280 ShellPrintEx (-1, -1,
4281 L
" Attention Indicator Present(3): %E%d%N\r\n",
4282 PCIE_CAP_ATT_IND_PRESENT (PcieSlotCap
)
4284 ShellPrintEx (-1, -1,
4285 L
" Power Indicator Present(4): %E%d%N\r\n",
4286 PCIE_CAP_PWD_IND_PRESENT (PcieSlotCap
)
4288 ShellPrintEx (-1, -1,
4289 L
" Hot-Plug Surprise(5): %E%d%N\r\n",
4290 PCIE_CAP_HOTPLUG_SUPPRISE (PcieSlotCap
)
4292 ShellPrintEx (-1, -1,
4293 L
" Hot-Plug Capable(6): %E%d%N\r\n",
4294 PCIE_CAP_HOTPLUG_CAPABLE (PcieSlotCap
)
4296 ShellPrintEx (-1, -1,
4297 L
" Slot Power Limit Value(14:7): %E0x%02x%N\r\n",
4298 PCIE_CAP_SLOT_PWR_LIMIT_VALUE (PcieSlotCap
)
4300 ShellPrintEx (-1, -1,
4301 L
" Slot Power Limit Scale(16:15): %E%s%N\r\n",
4302 SlotPwrLmtScaleTable
[PCIE_CAP_SLOT_PWR_LIMIT_SCALE (PcieSlotCap
)]
4304 ShellPrintEx (-1, -1,
4305 L
" Electromechanical Interlock Present(17): %E%d%N\r\n",
4306 PCIE_CAP_ELEC_INTERLOCK_PRESENT (PcieSlotCap
)
4308 ShellPrintEx (-1, -1,
4309 L
" No Command Completed Support(18): %E%d%N\r\n",
4310 PCIE_CAP_NO_COMM_COMPLETED_SUP (PcieSlotCap
)
4312 ShellPrintEx (-1, -1,
4313 L
" Physical Slot Number(31:19): %E%d%N\r\n",
4314 PCIE_CAP_PHY_SLOT_NUM (PcieSlotCap
)
4321 Print out information of the device slot control information.
4323 @param[in] PciExpressCap The pointer to the structure about the device.
4325 @retval EFI_SUCCESS The operation was successful.
4328 ExplainPcieSlotControl (
4329 IN PCIE_CAP_STURCTURE
*PciExpressCap
4332 UINT16 PcieSlotControl
;
4334 PcieSlotControl
= PciExpressCap
->SlotControl
;
4335 ShellPrintEx (-1, -1,
4336 L
" Attention Button Pressed Enable(0): %E%d%N\r\n",
4337 PCIE_CAP_ATT_BUT_ENABLE (PcieSlotControl
)
4339 ShellPrintEx (-1, -1,
4340 L
" Power Fault Detected Enable(1): %E%d%N\r\n",
4341 PCIE_CAP_PWR_FLT_DETECT_ENABLE (PcieSlotControl
)
4343 ShellPrintEx (-1, -1,
4344 L
" MRL Sensor Changed Enable(2): %E%d%N\r\n",
4345 PCIE_CAP_MRL_SENSOR_CHANGE_ENABLE (PcieSlotControl
)
4347 ShellPrintEx (-1, -1,
4348 L
" Presence Detect Changed Enable(3): %E%d%N\r\n",
4349 PCIE_CAP_PRES_DETECT_CHANGE_ENABLE (PcieSlotControl
)
4351 ShellPrintEx (-1, -1,
4352 L
" Command Completed Interrupt Enable(4): %E%d%N\r\n",
4353 PCIE_CAP_COMM_CMPL_INT_ENABLE (PcieSlotControl
)
4355 ShellPrintEx (-1, -1,
4356 L
" Hot-Plug Interrupt Enable(5): %E%d%N\r\n",
4357 PCIE_CAP_HOTPLUG_INT_ENABLE (PcieSlotControl
)
4359 ShellPrintEx (-1, -1,
4360 L
" Attention Indicator Control(7:6): %E%s%N\r\n",
4361 IndicatorTable
[PCIE_CAP_ATT_IND_CTRL (PcieSlotControl
)]
4363 ShellPrintEx (-1, -1,
4364 L
" Power Indicator Control(9:8): %E%s%N\r\n",
4365 IndicatorTable
[PCIE_CAP_PWR_IND_CTRL (PcieSlotControl
)]
4367 ShellPrintEx (-1, -1, L
" Power Controller Control(10): %EPower ");
4368 if (PCIE_CAP_PWR_CTRLLER_CTRL (PcieSlotControl
)) {
4369 ShellPrintEx (-1, -1, L
"Off%N\r\n");
4371 ShellPrintEx (-1, -1, L
"On%N\r\n");
4373 ShellPrintEx (-1, -1,
4374 L
" Electromechanical Interlock Control(11): %E%d%N\r\n",
4375 PCIE_CAP_ELEC_INTERLOCK_CTRL (PcieSlotControl
)
4377 ShellPrintEx (-1, -1,
4378 L
" Data Link Layer State Changed Enable(12): %E%d%N\r\n",
4379 PCIE_CAP_DLINK_STAT_CHANGE_ENABLE (PcieSlotControl
)
4385 Print out information of the device slot status information.
4387 @param[in] PciExpressCap The pointer to the structure about the device.
4389 @retval EFI_SUCCESS The operation was successful.
4392 ExplainPcieSlotStatus (
4393 IN PCIE_CAP_STURCTURE
*PciExpressCap
4396 UINT16 PcieSlotStatus
;
4398 PcieSlotStatus
= PciExpressCap
->SlotStatus
;
4400 ShellPrintEx (-1, -1,
4401 L
" Attention Button Pressed(0): %E%d%N\r\n",
4402 PCIE_CAP_ATT_BUT_PRESSED (PcieSlotStatus
)
4404 ShellPrintEx (-1, -1,
4405 L
" Power Fault Detected(1): %E%d%N\r\n",
4406 PCIE_CAP_PWR_FLT_DETECTED (PcieSlotStatus
)
4408 ShellPrintEx (-1, -1,
4409 L
" MRL Sensor Changed(2): %E%d%N\r\n",
4410 PCIE_CAP_MRL_SENSOR_CHANGED (PcieSlotStatus
)
4412 ShellPrintEx (-1, -1,
4413 L
" Presence Detect Changed(3): %E%d%N\r\n",
4414 PCIE_CAP_PRES_DETECT_CHANGED (PcieSlotStatus
)
4416 ShellPrintEx (-1, -1,
4417 L
" Command Completed(4): %E%d%N\r\n",
4418 PCIE_CAP_COMM_COMPLETED (PcieSlotStatus
)
4420 ShellPrintEx (-1, -1, L
" MRL Sensor State(5): %EMRL ");
4421 if (PCIE_CAP_MRL_SENSOR_STATE (PcieSlotStatus
)) {
4422 ShellPrintEx (-1, -1, L
" Opened%N\r\n");
4424 ShellPrintEx (-1, -1, L
" Closed%N\r\n");
4426 ShellPrintEx (-1, -1, L
" Presence Detect State(6): ");
4427 if (PCIE_CAP_PRES_DETECT_STATE (PcieSlotStatus
)) {
4428 ShellPrintEx (-1, -1, L
"%ECard Present in slot%N\r\n");
4430 ShellPrintEx (-1, -1, L
"%ESlot Empty%N\r\n");
4432 ShellPrintEx (-1, -1, L
" Electromechanical Interlock Status(7): %EElectromechanical Interlock ");
4433 if (PCIE_CAP_ELEC_INTERLOCK_STATE (PcieSlotStatus
)) {
4434 ShellPrintEx (-1, -1, L
"Engaged%N\r\n");
4436 ShellPrintEx (-1, -1, L
"Disengaged%N\r\n");
4438 ShellPrintEx (-1, -1,
4439 L
" Data Link Layer State Changed(8): %E%d%N\r\n",
4440 PCIE_CAP_DLINK_STAT_CHANGED (PcieSlotStatus
)
4446 Print out information of the device root information.
4448 @param[in] PciExpressCap The pointer to the structure about the device.
4450 @retval EFI_SUCCESS The operation was successful.
4453 ExplainPcieRootControl (
4454 IN PCIE_CAP_STURCTURE
*PciExpressCap
4457 UINT16 PcieRootControl
;
4459 PcieRootControl
= PciExpressCap
->RootControl
;
4461 ShellPrintEx (-1, -1,
4462 L
" System Error on Correctable Error Enable(0): %E%d%N\r\n",
4463 PCIE_CAP_SYSERR_ON_CORERR_EN (PcieRootControl
)
4465 ShellPrintEx (-1, -1,
4466 L
" System Error on Non-Fatal Error Enable(1): %E%d%N\r\n",
4467 PCIE_CAP_SYSERR_ON_NONFATERR_EN (PcieRootControl
)
4469 ShellPrintEx (-1, -1,
4470 L
" System Error on Fatal Error Enable(2): %E%d%N\r\n",
4471 PCIE_CAP_SYSERR_ON_FATERR_EN (PcieRootControl
)
4473 ShellPrintEx (-1, -1,
4474 L
" PME Interrupt Enable(3): %E%d%N\r\n",
4475 PCIE_CAP_PME_INT_ENABLE (PcieRootControl
)
4477 ShellPrintEx (-1, -1,
4478 L
" CRS Software Visibility Enable(4): %E%d%N\r\n",
4479 PCIE_CAP_CRS_SW_VIS_ENABLE (PcieRootControl
)
4486 Print out information of the device root capability information.
4488 @param[in] PciExpressCap The pointer to the structure about the device.
4490 @retval EFI_SUCCESS The operation was successful.
4493 ExplainPcieRootCap (
4494 IN PCIE_CAP_STURCTURE
*PciExpressCap
4499 PcieRootCap
= PciExpressCap
->RsvdP
;
4501 ShellPrintEx (-1, -1,
4502 L
" CRS Software Visibility(0): %E%d%N\r\n",
4503 PCIE_CAP_CRS_SW_VIS (PcieRootCap
)
4510 Print out information of the device root status information.
4512 @param[in] PciExpressCap The pointer to the structure about the device.
4514 @retval EFI_SUCCESS The operation was successful.
4517 ExplainPcieRootStatus (
4518 IN PCIE_CAP_STURCTURE
*PciExpressCap
4521 UINT32 PcieRootStatus
;
4523 PcieRootStatus
= PciExpressCap
->RootStatus
;
4525 ShellPrintEx (-1, -1,
4526 L
" PME Requester ID(15:0): %E0x%04x%N\r\n",
4527 PCIE_CAP_PME_REQ_ID (PcieRootStatus
)
4529 ShellPrintEx (-1, -1,
4530 L
" PME Status(16): %E%d%N\r\n",
4531 PCIE_CAP_PME_STATUS (PcieRootStatus
)
4533 ShellPrintEx (-1, -1,
4534 L
" PME Pending(17): %E%d%N\r\n",
4535 PCIE_CAP_PME_PENDING (PcieRootStatus
)
4541 Display Pcie device structure.
4543 @param[in] IoDev The pointer to the root pci protocol.
4544 @param[in] Address The Address to start at.
4545 @param[in] CapabilityPtr The offset from the address to start.
4548 PciExplainPciExpress (
4549 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
,
4551 IN UINT8 CapabilityPtr
4555 PCIE_CAP_STURCTURE PciExpressCap
;
4557 UINT64 CapRegAddress
;
4562 UINTN ExtendRegSize
;
4563 UINT64 Pciex_Address
;
4564 UINT8 DevicePortType
;
4569 CapRegAddress
= Address
+ CapabilityPtr
;
4574 sizeof (PciExpressCap
) / sizeof (UINT32
),
4578 DevicePortType
= (UINT8
) PCIE_CAP_DEVICEPORT_TYPE (PciExpressCap
.PcieCapReg
);
4580 ShellPrintEx (-1, -1, L
"\r\nPci Express device capability structure:\r\n");
4582 for (Index
= 0; PcieExplainList
[Index
].Type
< PcieExplainTypeMax
; Index
++) {
4583 if (ShellGetExecutionBreakFlag()) {
4586 RegAddr
= ((UINT8
*) &PciExpressCap
) + PcieExplainList
[Index
].Offset
;
4587 switch (PcieExplainList
[Index
].Width
) {
4588 case FieldWidthUINT8
:
4589 RegValue
= *(UINT8
*) RegAddr
;
4591 case FieldWidthUINT16
:
4592 RegValue
= *(UINT16
*) RegAddr
;
4594 case FieldWidthUINT32
:
4595 RegValue
= *(UINT32
*) RegAddr
;
4601 ShellPrintHiiEx(-1, -1, NULL
,
4602 PcieExplainList
[Index
].Token
,
4603 gShellDebug1HiiHandle
,
4604 PcieExplainList
[Index
].Offset
,
4607 if (PcieExplainList
[Index
].Func
== NULL
) {
4610 switch (PcieExplainList
[Index
].Type
) {
4611 case PcieExplainTypeLink
:
4613 // Link registers should not be used by
4614 // a) Root Complex Integrated Endpoint
4615 // b) Root Complex Event Collector
4617 if (DevicePortType
== PCIE_ROOT_COMPLEX_INTEGRATED_PORT
||
4618 DevicePortType
== PCIE_ROOT_COMPLEX_EVENT_COLLECTOR
) {
4622 case PcieExplainTypeSlot
:
4624 // Slot registers are only valid for
4625 // a) Root Port of PCI Express Root Complex
4626 // b) Downstream Port of PCI Express Switch
4627 // and when SlotImplemented bit is set in PCIE cap register.
4629 if ((DevicePortType
!= PCIE_ROOT_COMPLEX_ROOT_PORT
&&
4630 DevicePortType
!= PCIE_SWITCH_DOWNSTREAM_PORT
) ||
4631 !PCIE_CAP_SLOT_IMPLEMENTED (PciExpressCap
.PcieCapReg
)) {
4635 case PcieExplainTypeRoot
:
4637 // Root registers are only valid for
4638 // Root Port of PCI Express Root Complex
4640 if (DevicePortType
!= PCIE_ROOT_COMPLEX_ROOT_PORT
) {
4647 PcieExplainList
[Index
].Func (&PciExpressCap
);
4650 Bus
= (UINT8
) (RShiftU64 (Address
, 24));
4651 Dev
= (UINT8
) (RShiftU64 (Address
, 16));
4652 Func
= (UINT8
) (RShiftU64 (Address
, 8));
4654 Pciex_Address
= CALC_EFI_PCIEX_ADDRESS (Bus
, Dev
, Func
, 0x100);
4656 ExtendRegSize
= 0x1000 - 0x100;
4658 ExRegBuffer
= (UINT8
*) AllocateZeroPool (ExtendRegSize
);
4661 // PciRootBridgeIo protocol should support pci express extend space IO
4662 // (Begins at offset 0x100)
4664 Status
= IoDev
->Pci
.Read (
4668 (ExtendRegSize
) / sizeof (UINT32
),
4669 (VOID
*) (ExRegBuffer
)
4671 if (EFI_ERROR (Status
)) {
4672 FreePool ((VOID
*) ExRegBuffer
);
4673 return EFI_UNSUPPORTED
;
4676 // Start outputing PciEx extend space( 0xFF-0xFFF)
4678 ShellPrintEx (-1, -1, L
"\r\n%HStart dumping PCIex extended configuration space (0x100 - 0xFFF).%N\r\n\r\n");
4680 if (ExRegBuffer
!= NULL
) {
4685 (VOID
*) (ExRegBuffer
)
4688 FreePool ((VOID
*) ExRegBuffer
);