2 Main file for Pci shell Debug1 function.
4 Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "UefiShellDebug1CommandsLib.h"
16 #include <Protocol/PciRootBridgeIo.h>
17 #include <Library/ShellLib.h>
18 #include <IndustryStandard/Pci.h>
19 #include <IndustryStandard/Acpi.h>
22 #define PCI_CLASS_STRING_LIMIT 54
24 // Printable strings for Pci class code
27 CHAR16
*BaseClass
; // Pointer to the PCI base class string
28 CHAR16
*SubClass
; // Pointer to the PCI sub class string
29 CHAR16
*PIFClass
; // Pointer to the PCI programming interface string
33 // a structure holding a single entry, which also points to its lower level
36 typedef struct PCI_CLASS_ENTRY_TAG
{
37 UINT8 Code
; // Class, subclass or I/F code
38 CHAR16
*DescText
; // Description string
39 struct PCI_CLASS_ENTRY_TAG
*LowerLevelClass
; // Subclass or I/F if any
43 // Declarations of entries which contain printable strings for class codes
44 // in PCI configuration space
46 PCI_CLASS_ENTRY PCIBlankEntry
[];
47 PCI_CLASS_ENTRY PCISubClass_00
[];
48 PCI_CLASS_ENTRY PCISubClass_01
[];
49 PCI_CLASS_ENTRY PCISubClass_02
[];
50 PCI_CLASS_ENTRY PCISubClass_03
[];
51 PCI_CLASS_ENTRY PCISubClass_04
[];
52 PCI_CLASS_ENTRY PCISubClass_05
[];
53 PCI_CLASS_ENTRY PCISubClass_06
[];
54 PCI_CLASS_ENTRY PCISubClass_07
[];
55 PCI_CLASS_ENTRY PCISubClass_08
[];
56 PCI_CLASS_ENTRY PCISubClass_09
[];
57 PCI_CLASS_ENTRY PCISubClass_0a
[];
58 PCI_CLASS_ENTRY PCISubClass_0b
[];
59 PCI_CLASS_ENTRY PCISubClass_0c
[];
60 PCI_CLASS_ENTRY PCISubClass_0d
[];
61 PCI_CLASS_ENTRY PCISubClass_0e
[];
62 PCI_CLASS_ENTRY PCISubClass_0f
[];
63 PCI_CLASS_ENTRY PCISubClass_10
[];
64 PCI_CLASS_ENTRY PCISubClass_11
[];
65 PCI_CLASS_ENTRY PCIPIFClass_0101
[];
66 PCI_CLASS_ENTRY PCIPIFClass_0300
[];
67 PCI_CLASS_ENTRY PCIPIFClass_0604
[];
68 PCI_CLASS_ENTRY PCIPIFClass_0700
[];
69 PCI_CLASS_ENTRY PCIPIFClass_0701
[];
70 PCI_CLASS_ENTRY PCIPIFClass_0703
[];
71 PCI_CLASS_ENTRY PCIPIFClass_0800
[];
72 PCI_CLASS_ENTRY PCIPIFClass_0801
[];
73 PCI_CLASS_ENTRY PCIPIFClass_0802
[];
74 PCI_CLASS_ENTRY PCIPIFClass_0803
[];
75 PCI_CLASS_ENTRY PCIPIFClass_0904
[];
76 PCI_CLASS_ENTRY PCIPIFClass_0c00
[];
77 PCI_CLASS_ENTRY PCIPIFClass_0c03
[];
78 PCI_CLASS_ENTRY PCIPIFClass_0e00
[];
81 // Base class strings entries
83 PCI_CLASS_ENTRY gClassStringList
[] = {
91 L
"Mass Storage Controller",
96 L
"Network Controller",
101 L
"Display Controller",
106 L
"Multimedia Device",
111 L
"Memory Controller",
121 L
"Simple Communications Controllers",
126 L
"Base System Peripherals",
146 L
"Serial Bus Controllers",
151 L
"Wireless Controllers",
156 L
"Intelligent IO Controllers",
161 L
"Satellite Communications Controllers",
166 L
"Encryption/Decryption Controllers",
171 L
"Data Acquisition & Signal Processing Controllers",
176 L
"Device does not fit in any defined classes",
182 /* null string ends the list */NULL
187 // Subclass strings entries
189 PCI_CLASS_ENTRY PCIBlankEntry
[] = {
198 /* null string ends the list */NULL
202 PCI_CLASS_ENTRY PCISubClass_00
[] = {
205 L
"All devices other than VGA",
210 L
"VGA-compatible devices",
216 /* null string ends the list */NULL
220 PCI_CLASS_ENTRY PCISubClass_01
[] = {
233 L
"Floppy disk controller",
248 L
"Other mass storage controller",
254 /* null string ends the list */NULL
258 PCI_CLASS_ENTRY PCISubClass_02
[] = {
261 L
"Ethernet controller",
266 L
"Token ring controller",
286 L
"Other network controller",
292 /* null string ends the list */NULL
296 PCI_CLASS_ENTRY PCISubClass_03
[] = {
299 L
"VGA/8514 controller",
314 L
"Other display controller",
320 /* null string ends the list */PCIBlankEntry
324 PCI_CLASS_ENTRY PCISubClass_04
[] = {
337 L
"Computer Telephony device",
342 L
"Other multimedia device",
348 /* null string ends the list */NULL
352 PCI_CLASS_ENTRY PCISubClass_05
[] = {
355 L
"RAM memory controller",
360 L
"Flash memory controller",
365 L
"Other memory controller",
371 /* null string ends the list */NULL
375 PCI_CLASS_ENTRY PCISubClass_06
[] = {
393 L
"PCI/Micro Channel bridge",
403 L
"PCI/PCMCIA bridge",
423 L
"Other bridge type",
429 /* null string ends the list */NULL
433 PCI_CLASS_ENTRY PCISubClass_07
[] = {
436 L
"Serial controller",
446 L
"Multiport serial controller",
456 L
"Other communication device",
462 /* null string ends the list */NULL
466 PCI_CLASS_ENTRY PCISubClass_08
[] = {
489 L
"Generic PCI Hot-Plug controller",
494 L
"Other system peripheral",
500 /* null string ends the list */NULL
504 PCI_CLASS_ENTRY PCISubClass_09
[] = {
507 L
"Keyboard controller",
522 L
"Scanner controller",
527 L
"Gameport controller",
532 L
"Other input controller",
538 /* null string ends the list */NULL
542 PCI_CLASS_ENTRY PCISubClass_0a
[] = {
545 L
"Generic docking station",
550 L
"Other type of docking station",
556 /* null string ends the list */NULL
560 PCI_CLASS_ENTRY PCISubClass_0b
[] = {
604 /* null string ends the list */NULL
608 PCI_CLASS_ENTRY PCISubClass_0c
[] = {
611 L
"Firewire(IEEE 1394)",
636 L
"System Management Bus",
647 /* null string ends the list */NULL
651 PCI_CLASS_ENTRY PCISubClass_0d
[] = {
654 L
"iRDA compatible controller",
659 L
"Consumer IR controller",
669 L
"Other type of wireless controller",
675 /* null string ends the list */NULL
679 PCI_CLASS_ENTRY PCISubClass_0e
[] = {
688 /* null string ends the list */NULL
692 PCI_CLASS_ENTRY PCISubClass_0f
[] = {
716 /* null string ends the list */NULL
720 PCI_CLASS_ENTRY PCISubClass_10
[] = {
723 L
"Network & computing Encrypt/Decrypt",
728 L
"Entertainment Encrypt/Decrypt",
733 L
"Other Encrypt/Decrypt",
739 /* null string ends the list */NULL
743 PCI_CLASS_ENTRY PCISubClass_11
[] = {
751 L
"Other DAQ & SP controllers",
757 /* null string ends the list */NULL
762 // Programming Interface entries
764 PCI_CLASS_ENTRY PCIPIFClass_0101
[] = {
792 L
"OM-primary, OM-secondary",
797 L
"PI-primary, OM-secondary",
802 L
"OM/PI-primary, OM-secondary",
812 L
"OM-primary, PI-secondary",
817 L
"PI-primary, PI-secondary",
822 L
"OM/PI-primary, PI-secondary",
832 L
"OM-primary, OM/PI-secondary",
837 L
"PI-primary, OM/PI-secondary",
842 L
"OM/PI-primary, OM/PI-secondary",
852 L
"Master, OM-primary",
857 L
"Master, PI-primary",
862 L
"Master, OM/PI-primary",
867 L
"Master, OM-secondary",
872 L
"Master, OM-primary, OM-secondary",
877 L
"Master, PI-primary, OM-secondary",
882 L
"Master, OM/PI-primary, OM-secondary",
887 L
"Master, OM-secondary",
892 L
"Master, OM-primary, PI-secondary",
897 L
"Master, PI-primary, PI-secondary",
902 L
"Master, OM/PI-primary, PI-secondary",
907 L
"Master, OM-secondary",
912 L
"Master, OM-primary, OM/PI-secondary",
917 L
"Master, PI-primary, OM/PI-secondary",
922 L
"Master, OM/PI-primary, OM/PI-secondary",
928 /* null string ends the list */NULL
932 PCI_CLASS_ENTRY PCIPIFClass_0300
[] = {
946 /* null string ends the list */NULL
950 PCI_CLASS_ENTRY PCIPIFClass_0604
[] = {
958 L
"Subtractive decode",
964 /* null string ends the list */NULL
968 PCI_CLASS_ENTRY PCIPIFClass_0700
[] = {
971 L
"Generic XT-compatible",
1001 L
"16950-compatible",
1007 /* null string ends the list */NULL
1011 PCI_CLASS_ENTRY PCIPIFClass_0701
[] = {
1024 L
"ECP 1.X-compliant",
1034 L
"IEEE 1284 target (not a controller)",
1040 /* null string ends the list */NULL
1044 PCI_CLASS_ENTRY PCIPIFClass_0703
[] = {
1052 L
"Hayes-compatible 16450",
1057 L
"Hayes-compatible 16550",
1062 L
"Hayes-compatible 16650",
1067 L
"Hayes-compatible 16750",
1073 /* null string ends the list */NULL
1077 PCI_CLASS_ENTRY PCIPIFClass_0800
[] = {
1100 L
"IO(x) APIC interrupt controller",
1106 /* null string ends the list */NULL
1110 PCI_CLASS_ENTRY PCIPIFClass_0801
[] = {
1129 /* null string ends the list */NULL
1133 PCI_CLASS_ENTRY PCIPIFClass_0802
[] = {
1152 /* null string ends the list */NULL
1156 PCI_CLASS_ENTRY PCIPIFClass_0803
[] = {
1175 /* null string ends the list */NULL
1179 PCI_CLASS_ENTRY PCIPIFClass_0904
[] = {
1193 /* null string ends the list */NULL
1197 PCI_CLASS_ENTRY PCIPIFClass_0c00
[] = {
1200 L
"Universal Host Controller spec",
1205 L
"Open Host Controller spec",
1210 L
"No specific programming interface",
1215 L
"(Not Host Controller)",
1221 /* null string ends the list */NULL
1225 PCI_CLASS_ENTRY PCIPIFClass_0c03
[] = {
1233 L
"Using 1394 OpenHCI spec",
1239 /* null string ends the list */NULL
1243 PCI_CLASS_ENTRY PCIPIFClass_0e00
[] = {
1246 L
"Message FIFO at offset 40h",
1257 /* null string ends the list */NULL
1261 #define EFI_HEX_DISP_SIZE 32
1271 Routine Description:
1273 Add page break feature to the DumpHex
1276 Indent - The indent space
1280 DataSize - The data size
1286 TRUE - The dump is broke
1287 FALSE - The dump is completed
1294 DispSize
= EFI_HEX_DISP_SIZE
;
1295 DispData
= (UINT8
*) UserData
;
1297 while (DataSize
!=0) {
1298 if (ShellGetExecutionBreakFlag ()) {
1302 if (DataSize
> EFI_HEX_DISP_SIZE
) {
1303 DataSize
-= EFI_HEX_DISP_SIZE
;
1305 DispSize
= DataSize
;
1309 DumpHex (Indent
, Offset
+ DispData
- (UINT8
*) UserData
, DispSize
, DispData
);
1310 DispData
+= DispSize
;
1320 PciGetClassStrings (
1321 IN UINT32 ClassCode
,
1322 IN OUT PCI_CLASS_STRINGS
*ClassStrings
1325 Routine Description:
1327 Generates printable Unicode strings that represent PCI device class,
1328 subclass and programmed I/F based on a value passed to the function.
1332 ClassCode Value representing the PCI "Class Code" register read from a
1333 PCI device. The encodings are:
1334 bits 23:16 - Base Class Code
1335 bits 15:8 - Sub-Class Code
1336 bits 7:0 - Programming Interface
1337 ClassStrings Pointer of PCI_CLASS_STRINGS structure, which contains
1338 printable class strings corresponding to ClassCode. The
1339 caller must not modify the strings that are pointed by
1340 the fields in ClassStrings.
1348 PCI_CLASS_ENTRY
*CurrentClass
;
1351 // Assume no strings found
1353 ClassStrings
->BaseClass
= L
"UNDEFINED";
1354 ClassStrings
->SubClass
= L
"UNDEFINED";
1355 ClassStrings
->PIFClass
= L
"UNDEFINED";
1357 CurrentClass
= gClassStringList
;
1358 Code
= (UINT8
) (ClassCode
>> 16);
1362 // Go through all entries of the base class, until the entry with a matching
1363 // base class code is found. If reaches an entry with a null description
1364 // text, the last entry is met, which means no text for the base class was
1365 // found, so no more action is needed.
1367 while (Code
!= CurrentClass
[Index
].Code
) {
1368 if (NULL
== CurrentClass
[Index
].DescText
) {
1375 // A base class was found. Assign description, and check if this class has
1376 // sub-class defined. If sub-class defined, no more action is needed,
1377 // otherwise, continue to find description for the sub-class code.
1379 ClassStrings
->BaseClass
= CurrentClass
[Index
].DescText
;
1380 if (NULL
== CurrentClass
[Index
].LowerLevelClass
) {
1384 // find Subclass entry
1386 CurrentClass
= CurrentClass
[Index
].LowerLevelClass
;
1387 Code
= (UINT8
) (ClassCode
>> 8);
1391 // Go through all entries of the sub-class, until the entry with a matching
1392 // sub-class code is found. If reaches an entry with a null description
1393 // text, the last entry is met, which means no text for the sub-class was
1394 // found, so no more action is needed.
1396 while (Code
!= CurrentClass
[Index
].Code
) {
1397 if (NULL
== CurrentClass
[Index
].DescText
) {
1404 // A class was found for the sub-class code. Assign description, and check if
1405 // this sub-class has programming interface defined. If no, no more action is
1406 // needed, otherwise, continue to find description for the programming
1409 ClassStrings
->SubClass
= CurrentClass
[Index
].DescText
;
1410 if (NULL
== CurrentClass
[Index
].LowerLevelClass
) {
1414 // Find programming interface entry
1416 CurrentClass
= CurrentClass
[Index
].LowerLevelClass
;
1417 Code
= (UINT8
) ClassCode
;
1421 // Go through all entries of the I/F entries, until the entry with a
1422 // matching I/F code is found. If reaches an entry with a null description
1423 // text, the last entry is met, which means no text was found, so no more
1424 // action is needed.
1426 while (Code
!= CurrentClass
[Index
].Code
) {
1427 if (NULL
== CurrentClass
[Index
].DescText
) {
1434 // A class was found for the I/F code. Assign description, done!
1436 ClassStrings
->PIFClass
= CurrentClass
[Index
].DescText
;
1442 IN UINT8
*ClassCodePtr
,
1443 IN BOOLEAN IncludePIF
1446 Routine Description:
1448 Print strings that represent PCI device class, subclass and programmed I/F
1452 ClassCodePtr Points to the memory which stores register Class Code in PCI
1454 IncludePIF If the printed string should include the programming I/F part
1461 PCI_CLASS_STRINGS ClassStrings
;
1462 CHAR16 OutputString
[PCI_CLASS_STRING_LIMIT
+ 1];
1465 ClassCode
|= ClassCodePtr
[0];
1466 ClassCode
|= (ClassCodePtr
[1] << 8);
1467 ClassCode
|= (ClassCodePtr
[2] << 16);
1470 // Get name from class code
1472 PciGetClassStrings (ClassCode
, &ClassStrings
);
1476 // Only print base class and sub class name
1478 ShellPrintEx(-1,-1, L
"%s - %s - %s",
1479 ClassStrings
.BaseClass
,
1480 ClassStrings
.SubClass
,
1481 ClassStrings
.PIFClass
1486 // Print base class, sub class, and programming inferface name
1490 PCI_CLASS_STRING_LIMIT
* sizeof (CHAR16
),
1492 ClassStrings
.BaseClass
,
1493 ClassStrings
.SubClass
1496 OutputString
[PCI_CLASS_STRING_LIMIT
] = 0;
1497 ShellPrintEx(-1,-1, L
"%s", OutputString
);
1503 IN EFI_HANDLE ImageHandle
,
1504 IN EFI_SYSTEM_TABLE
*SystemTable
1508 PciFindProtocolInterface (
1509 IN EFI_HANDLE
*HandleBuf
,
1510 IN UINTN HandleCount
,
1513 OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
**IoDev
1517 PciGetProtocolAndResource (
1518 IN EFI_HANDLE Handle
,
1519 OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
**IoDev
,
1520 OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
**Descriptors
1524 PciGetNextBusRange (
1525 IN OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
**Descriptors
,
1533 IN PCI_CONFIG_SPACE
*ConfigSpace
,
1535 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
1539 PciExplainDeviceData (
1540 IN PCI_DEVICE_HEADER
*Device
,
1542 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
1546 PciExplainBridgeData (
1547 IN PCI_BRIDGE_HEADER
*Bridge
,
1549 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
1557 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
,
1562 PciExplainCardBusData (
1563 IN PCI_CARDBUS_HEADER
*CardBus
,
1565 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
1571 IN BOOLEAN MainStatus
,
1572 IN PCI_HEADER_TYPE HeaderType
1581 PciExplainBridgeControl (
1582 IN UINT16
*BridgeControl
,
1583 IN PCI_HEADER_TYPE HeaderType
1587 PciExplainCapabilityStruct (
1588 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
,
1594 PciExplainPciExpress (
1595 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
,
1597 IN UINT8 CapabilityPtr
1602 IN PCIE_CAP_STURCTURE
*PciExpressCap
1606 ExplainPcieDeviceCap (
1607 IN PCIE_CAP_STURCTURE
*PciExpressCap
1611 ExplainPcieDeviceControl (
1612 IN PCIE_CAP_STURCTURE
*PciExpressCap
1616 ExplainPcieDeviceStatus (
1617 IN PCIE_CAP_STURCTURE
*PciExpressCap
1621 ExplainPcieLinkCap (
1622 IN PCIE_CAP_STURCTURE
*PciExpressCap
1626 ExplainPcieLinkControl (
1627 IN PCIE_CAP_STURCTURE
*PciExpressCap
1631 ExplainPcieLinkStatus (
1632 IN PCIE_CAP_STURCTURE
*PciExpressCap
1636 ExplainPcieSlotCap (
1637 IN PCIE_CAP_STURCTURE
*PciExpressCap
1641 ExplainPcieSlotControl (
1642 IN PCIE_CAP_STURCTURE
*PciExpressCap
1646 ExplainPcieSlotStatus (
1647 IN PCIE_CAP_STURCTURE
*PciExpressCap
1651 ExplainPcieRootControl (
1652 IN PCIE_CAP_STURCTURE
*PciExpressCap
1656 ExplainPcieRootCap (
1657 IN PCIE_CAP_STURCTURE
*PciExpressCap
1661 ExplainPcieRootStatus (
1662 IN PCIE_CAP_STURCTURE
*PciExpressCap
1665 typedef EFI_STATUS (*PCIE_EXPLAIN_FUNCTION
) (IN PCIE_CAP_STURCTURE
*PciExpressCap
);
1671 } PCIE_CAPREG_FIELD_WIDTH
;
1674 PcieExplainTypeCommon
,
1675 PcieExplainTypeDevice
,
1676 PcieExplainTypeLink
,
1677 PcieExplainTypeSlot
,
1678 PcieExplainTypeRoot
,
1680 } PCIE_EXPLAIN_TYPE
;
1686 PCIE_CAPREG_FIELD_WIDTH Width
;
1687 PCIE_EXPLAIN_FUNCTION Func
;
1688 PCIE_EXPLAIN_TYPE Type
;
1689 } PCIE_EXPLAIN_STRUCT
;
1691 PCIE_EXPLAIN_STRUCT PcieExplainList
[] = {
1693 STRING_TOKEN (STR_PCIEX_CAPABILITY_CAPID
),
1697 PcieExplainTypeCommon
1700 STRING_TOKEN (STR_PCIEX_NEXTCAP_PTR
),
1704 PcieExplainTypeCommon
1707 STRING_TOKEN (STR_PCIEX_CAP_REGISTER
),
1711 PcieExplainTypeCommon
1714 STRING_TOKEN (STR_PCIEX_DEVICE_CAP
),
1717 ExplainPcieDeviceCap
,
1718 PcieExplainTypeDevice
1721 STRING_TOKEN (STR_PCIEX_DEVICE_CONTROL
),
1724 ExplainPcieDeviceControl
,
1725 PcieExplainTypeDevice
1728 STRING_TOKEN (STR_PCIEX_DEVICE_STATUS
),
1731 ExplainPcieDeviceStatus
,
1732 PcieExplainTypeDevice
1735 STRING_TOKEN (STR_PCIEX_LINK_CAPABILITIES
),
1742 STRING_TOKEN (STR_PCIEX_LINK_CONTROL
),
1745 ExplainPcieLinkControl
,
1749 STRING_TOKEN (STR_PCIEX_LINK_STATUS
),
1752 ExplainPcieLinkStatus
,
1756 STRING_TOKEN (STR_PCIEX_SLOT_CAPABILITIES
),
1763 STRING_TOKEN (STR_PCIEX_SLOT_CONTROL
),
1766 ExplainPcieSlotControl
,
1770 STRING_TOKEN (STR_PCIEX_SLOT_STATUS
),
1773 ExplainPcieSlotStatus
,
1777 STRING_TOKEN (STR_PCIEX_ROOT_CONTROL
),
1780 ExplainPcieRootControl
,
1784 STRING_TOKEN (STR_PCIEX_RSVDP
),
1791 STRING_TOKEN (STR_PCIEX_ROOT_STATUS
),
1794 ExplainPcieRootStatus
,
1800 (PCIE_CAPREG_FIELD_WIDTH
)0,
1809 PCI_CONFIG_SPACE
*mConfigSpace
= NULL
;
1810 STATIC CONST SHELL_PARAM_ITEM ParamList
[] = {
1816 CHAR16
*DevicePortTypeTable
[] = {
1817 L
"PCI Express Endpoint",
1818 L
"Legacy PCI Express Endpoint",
1821 L
"Root Port of PCI Express Root Complex",
1822 L
"Upstream Port of PCI Express Switch",
1823 L
"Downstream Port of PCI Express Switch",
1824 L
"PCI Express to PCI/PCI-X Bridge",
1825 L
"PCI/PCI-X to PCI Express Bridge",
1826 L
"Root Complex Integrated Endpoint",
1827 L
"Root Complex Event Collector"
1830 CHAR16
*L0sLatencyStrTable
[] = {
1832 L
"64ns to less than 128ns",
1833 L
"128ns to less than 256ns",
1834 L
"256ns to less than 512ns",
1835 L
"512ns to less than 1us",
1836 L
"1us to less than 2us",
1841 CHAR16
*L1LatencyStrTable
[] = {
1843 L
"1us to less than 2us",
1844 L
"2us to less than 4us",
1845 L
"4us to less than 8us",
1846 L
"8us to less than 16us",
1847 L
"16us to less than 32us",
1852 CHAR16
*ASPMCtrlStrTable
[] = {
1854 L
"L0s Entry Enabled",
1855 L
"L1 Entry Enabled",
1856 L
"L0s and L1 Entry Enabled"
1859 CHAR16
*SlotPwrLmtScaleTable
[] = {
1866 CHAR16
*IndicatorTable
[] = {
1876 ShellCommandRunPci (
1877 IN EFI_HANDLE ImageHandle
,
1878 IN EFI_SYSTEM_TABLE
*SystemTable
1886 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
;
1888 PCI_COMMON_HEADER PciHeader
;
1889 PCI_CONFIG_SPACE ConfigSpace
;
1893 BOOLEAN ExplainData
;
1897 UINTN HandleBufSize
;
1898 EFI_HANDLE
*HandleBuf
;
1900 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*Descriptors
;
1904 LIST_ENTRY
*Package
;
1905 CHAR16
*ProblemParam
;
1906 SHELL_STATUS ShellStatus
;
1910 ShellStatus
= SHELL_SUCCESS
;
1911 Status
= EFI_SUCCESS
;
1919 // initialize the shell lib (we must be in non-auto-init...)
1921 Status
= ShellInitialize();
1922 ASSERT_EFI_ERROR(Status
);
1924 Status
= CommandInit();
1925 ASSERT_EFI_ERROR(Status
);
1928 // parse the command line
1930 Status
= ShellCommandLineParse (ParamList
, &Package
, &ProblemParam
, TRUE
);
1931 if (EFI_ERROR(Status
)) {
1932 if (Status
== EFI_VOLUME_CORRUPTED
&& ProblemParam
!= NULL
) {
1933 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellDebug1HiiHandle
, ProblemParam
);
1934 FreePool(ProblemParam
);
1935 ShellStatus
= SHELL_INVALID_PARAMETER
;
1943 // Get all instances of PciRootBridgeIo. Allocate space for 1 EFI_HANDLE and
1944 // call LibLocateHandle(), if EFI_BUFFER_TOO_SMALL is returned, allocate enough
1945 // space for handles and call it again.
1947 HandleBufSize
= sizeof (EFI_HANDLE
);
1948 HandleBuf
= (EFI_HANDLE
*) AllocatePool (HandleBufSize
);
1949 if (HandleBuf
== NULL
) {
1950 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_OUT_MEM
), gShellDebug1HiiHandle
);
1951 ShellStatus
= SHELL_OUT_OF_RESOURCES
;
1955 Status
= gBS
->LocateHandle (
1957 &gEfiPciRootBridgeIoProtocolGuid
,
1963 if (Status
== EFI_BUFFER_TOO_SMALL
) {
1964 HandleBuf
= ReallocatePool (sizeof (EFI_HANDLE
), HandleBufSize
, HandleBuf
);
1965 if (HandleBuf
== NULL
) {
1966 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_OUT_MEM
), gShellDebug1HiiHandle
);
1967 ShellStatus
= SHELL_OUT_OF_RESOURCES
;
1971 Status
= gBS
->LocateHandle (
1973 &gEfiPciRootBridgeIoProtocolGuid
,
1980 if (EFI_ERROR (Status
)) {
1981 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PCIRBIO_NF
), gShellDebug1HiiHandle
);
1982 ShellStatus
= SHELL_NOT_FOUND
;
1986 HandleCount
= HandleBufSize
/ sizeof (EFI_HANDLE
);
1988 // Argument Count == 1(no other argument): enumerate all pci functions
1990 if (ShellCommandLineGetCount(Package
) == 0) {
1991 gST
->ConOut
->QueryMode (
1993 gST
->ConOut
->Mode
->Mode
,
2000 if ((ScreenSize
& 1) == 1) {
2007 // For each handle, which decides a segment and a bus number range,
2008 // enumerate all devices on it.
2010 for (Index
= 0; Index
< HandleCount
; Index
++) {
2011 Status
= PciGetProtocolAndResource (
2016 if (EFI_ERROR (Status
)) {
2017 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_HANDLE_CFG_ERR
), gShellDebug1HiiHandle
, Status
);
2018 ShellStatus
= SHELL_NOT_FOUND
;
2022 // No document say it's impossible for a RootBridgeIo protocol handle
2023 // to have more than one address space descriptors, so find out every
2024 // bus range and for each of them do device enumeration.
2027 Status
= PciGetNextBusRange (&Descriptors
, &MinBus
, &MaxBus
, &IsEnd
);
2029 if (EFI_ERROR (Status
)) {
2030 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_BUS_RANGE_ERR
), gShellDebug1HiiHandle
, Status
);
2031 ShellStatus
= SHELL_NOT_FOUND
;
2039 for (Bus
= MinBus
; Bus
<= MaxBus
; Bus
++) {
2041 // For each devices, enumerate all functions it contains
2043 for (Device
= 0; Device
<= PCI_MAX_DEVICE
; Device
++) {
2045 // For each function, read its configuration space and print summary
2047 for (Func
= 0; Func
<= PCI_MAX_FUNC
; Func
++) {
2048 if (ShellGetExecutionBreakFlag ()) {
2049 ShellStatus
= SHELL_ABORTED
;
2052 Address
= CALC_EFI_PCI_ADDRESS (Bus
, Device
, Func
, 0);
2062 // If VendorId = 0xffff, there does not exist a device at this
2063 // location. For each device, if there is any function on it,
2064 // there must be 1 function at Function 0. So if Func = 0, there
2065 // will be no more functions in the same device, so we can break
2066 // loop to deal with the next device.
2068 if (PciHeader
.VendorId
== 0xffff && Func
== 0) {
2072 if (PciHeader
.VendorId
!= 0xffff) {
2075 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_TITLE
), gShellDebug1HiiHandle
);
2083 sizeof (PciHeader
) / sizeof (UINT32
),
2088 -1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_P1
), gShellDebug1HiiHandle
,
2089 IoDev
->SegmentNumber
,
2095 PciPrintClassCode (PciHeader
.ClassCode
, FALSE
);
2097 -1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_P2
), gShellDebug1HiiHandle
,
2100 PciHeader
.ClassCode
[0]
2104 if (ScreenCount
>= ScreenSize
&& ScreenSize
!= 0) {
2106 // If ScreenSize == 0 we have the console redirected so don't
2112 // If this is not a multi-function device, we can leave the loop
2113 // to deal with the next device.
2115 if (Func
== 0 && ((PciHeader
.HeaderType
& HEADER_TYPE_MULTI_FUNCTION
) == 0x00)) {
2123 // If Descriptor is NULL, Configuration() returns EFI_UNSUPPRORED,
2124 // we assume the bus range is 0~PCI_MAX_BUS. After enumerated all
2125 // devices on all bus, we can leave loop.
2127 if (Descriptors
== NULL
) {
2133 Status
= EFI_SUCCESS
;
2137 if (ShellCommandLineGetCount(Package
) == 1) {
2138 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_FEW
), gShellDebug1HiiHandle
);
2139 ShellStatus
= SHELL_INVALID_PARAMETER
;
2143 // Arg count >= 3, dump binary of specified function, interpret if necessary
2145 if (ShellCommandLineGetCount(Package
) > 3) {
2146 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_MANY
), gShellDebug1HiiHandle
);
2147 ShellStatus
= SHELL_INVALID_PARAMETER
;
2151 ExplainData
= FALSE
;
2156 if (ShellCommandLineGetFlag(Package
, L
"-i")) {
2160 Temp
= ShellCommandLineGetValue(Package
, L
"-s");
2162 Segment
= (UINT16
) StrHexToUintn (Temp
);
2166 // The first Argument(except "-i") is assumed to be Bus number, second
2167 // to be Device number, and third to be Func number.
2169 Temp
= ShellCommandLineGetRawValue(Package
, 1);
2171 Bus
= (UINT16
)StrHexToUintn(Temp
);
2172 if (Bus
> MAX_BUS_NUMBER
) {
2173 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellDebug1HiiHandle
, Temp
);
2174 ShellStatus
= SHELL_INVALID_PARAMETER
;
2178 Temp
= ShellCommandLineGetRawValue(Package
, 2);
2180 Device
= (UINT16
) StrHexToUintn(Temp
);
2181 if (Device
> MAX_DEVICE_NUMBER
){
2182 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellDebug1HiiHandle
, Temp
);
2183 ShellStatus
= SHELL_INVALID_PARAMETER
;
2188 Temp
= ShellCommandLineGetRawValue(Package
, 3);
2190 Func
= (UINT16
) StrHexToUintn(Temp
);
2191 if (Func
> MAX_FUNCTION_NUMBER
){
2192 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellDebug1HiiHandle
, Temp
);
2193 ShellStatus
= SHELL_INVALID_PARAMETER
;
2199 // Find the protocol interface who's in charge of current segment, and its
2200 // bus range covers the current bus
2202 Status
= PciFindProtocolInterface (
2210 if (EFI_ERROR (Status
)) {
2212 -1, -1, NULL
, STRING_TOKEN (STR_PCI_NO_FIND
), gShellDebug1HiiHandle
,
2213 gShellDebug1HiiHandle
,
2217 ShellStatus
= SHELL_NOT_FOUND
;
2221 Address
= CALC_EFI_PCI_ADDRESS (Bus
, Device
, Func
, 0);
2222 Status
= IoDev
->Pci
.Read (
2226 sizeof (ConfigSpace
),
2230 if (EFI_ERROR (Status
)) {
2231 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_NO_CFG
), gShellDebug1HiiHandle
, Status
);
2232 ShellStatus
= SHELL_ACCESS_DENIED
;
2236 mConfigSpace
= &ConfigSpace
;
2241 STRING_TOKEN (STR_PCI_INFO
),
2242 gShellDebug1HiiHandle
,
2254 // Dump standard header of configuration space
2256 SizeOfHeader
= sizeof (ConfigSpace
.Common
) + sizeof (ConfigSpace
.NonCommon
);
2258 PrivateDumpHex (2, 0, SizeOfHeader
, &ConfigSpace
);
2259 ShellPrintEx(-1,-1, L
"\r\n");
2262 // Dump device dependent Part of configuration space
2267 sizeof (ConfigSpace
) - SizeOfHeader
,
2272 // If "-i" appears in command line, interpret data in configuration space
2275 Status
= PciExplainData (&ConfigSpace
, Address
, IoDev
);
2279 if (HandleBuf
!= NULL
) {
2280 FreePool (HandleBuf
);
2282 if (Package
!= NULL
) {
2283 ShellCommandLineFreeVarList (Package
);
2285 mConfigSpace
= NULL
;
2290 PciFindProtocolInterface (
2291 IN EFI_HANDLE
*HandleBuf
,
2292 IN UINTN HandleCount
,
2295 OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
**IoDev
2299 Routine Description:
2301 This function finds out the protocol which is in charge of the given
2302 segment, and its bus range covers the current bus number. It lookes
2303 each instances of RootBridgeIoProtocol handle, until the one meets the
2308 HandleBuf Buffer which holds all PCI_ROOT_BRIDIGE_IO_PROTOCOL handles
2309 HandleCount Count of all PCI_ROOT_BRIDIGE_IO_PROTOCOL handles
2310 Segment Segment number of device we are dealing with
2311 Bus Bus number of device we are dealing with
2312 IoDev Handle used to access configuration space of PCI device
2316 EFI_SUCCESS - The command completed successfully
2317 EFI_INVALID_PARAMETER - Invalid parameter
2323 BOOLEAN FoundInterface
;
2324 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*Descriptors
;
2329 FoundInterface
= FALSE
;
2331 // Go through all handles, until the one meets the criteria is found
2333 for (Index
= 0; Index
< HandleCount
; Index
++) {
2334 Status
= PciGetProtocolAndResource (HandleBuf
[Index
], IoDev
, &Descriptors
);
2335 if (EFI_ERROR (Status
)) {
2339 // When Descriptors == NULL, the Configuration() is not implemented,
2340 // so we only check the Segment number
2342 if (Descriptors
== NULL
&& Segment
== (*IoDev
)->SegmentNumber
) {
2346 if ((*IoDev
)->SegmentNumber
!= Segment
) {
2351 Status
= PciGetNextBusRange (&Descriptors
, &MinBus
, &MaxBus
, &IsEnd
);
2352 if (EFI_ERROR (Status
)) {
2360 if (MinBus
<= Bus
&& MaxBus
>= Bus
) {
2361 FoundInterface
= TRUE
;
2367 if (FoundInterface
) {
2370 return EFI_INVALID_PARAMETER
;
2375 PciGetProtocolAndResource (
2376 IN EFI_HANDLE Handle
,
2377 OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
**IoDev
,
2378 OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
**Descriptors
2382 Routine Description:
2384 This function gets the protocol interface from the given handle, and
2385 obtains its address space descriptors.
2389 Handle The PCI_ROOT_BRIDIGE_IO_PROTOCOL handle
2390 IoDev Handle used to access configuration space of PCI device
2391 Descriptors Points to the address space descriptors
2395 EFI_SUCCESS The command completed successfully
2402 // Get inferface from protocol
2404 Status
= gBS
->HandleProtocol (
2406 &gEfiPciRootBridgeIoProtocolGuid
,
2410 if (EFI_ERROR (Status
)) {
2414 // Call Configuration() to get address space descriptors
2416 Status
= (*IoDev
)->Configuration (*IoDev
, (VOID
**)Descriptors
);
2417 if (Status
== EFI_UNSUPPORTED
) {
2418 *Descriptors
= NULL
;
2427 PciGetNextBusRange (
2428 IN OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
**Descriptors
,
2435 Routine Description:
2437 This function get the next bus range of given address space descriptors.
2438 It also moves the pointer backward a node, to get prepared to be called
2443 Descriptors points to current position of a serial of address space
2445 MinBus The lower range of bus number
2446 ManBus The upper range of bus number
2447 IsEnd Meet end of the serial of descriptors
2451 EFI_SUCCESS The command completed successfully
2458 // When *Descriptors is NULL, Configuration() is not implemented, so assume
2459 // range is 0~PCI_MAX_BUS
2461 if ((*Descriptors
) == NULL
) {
2463 *MaxBus
= PCI_MAX_BUS
;
2467 // *Descriptors points to one or more address space descriptors, which
2468 // ends with a end tagged descriptor. Examine each of the descriptors,
2469 // if a bus typed one is found and its bus range covers bus, this handle
2470 // is the handle we are looking for.
2472 if ((*Descriptors
)->Desc
== ACPI_END_TAG_DESCRIPTOR
) {
2476 while ((*Descriptors
)->Desc
!= ACPI_END_TAG_DESCRIPTOR
) {
2477 if ((*Descriptors
)->ResType
== ACPI_ADDRESS_SPACE_TYPE_BUS
) {
2478 *MinBus
= (UINT16
) (*Descriptors
)->AddrRangeMin
;
2479 *MaxBus
= (UINT16
) (*Descriptors
)->AddrRangeMax
;
2492 IN PCI_CONFIG_SPACE
*ConfigSpace
,
2494 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
2498 Routine Description:
2500 Explain the data in PCI configuration space. The part which is common for
2501 PCI device and bridge is interpreted in this function. It calls other
2502 functions to interpret data unique for device or bridge.
2506 ConfigSpace Data in PCI configuration space
2507 Address Address used to access configuration space of this PCI device
2508 IoDev Handle used to access configuration space of PCI device
2512 EFI_SUCCESS The command completed successfully
2516 PCI_COMMON_HEADER
*Common
;
2517 PCI_HEADER_TYPE HeaderType
;
2521 Common
= &(ConfigSpace
->Common
);
2526 // Print Vendor Id and Device Id
2528 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_VID_DID
), gShellDebug1HiiHandle
,
2529 INDEX_OF (&(Common
->VendorId
)),
2531 INDEX_OF (&(Common
->DeviceId
)),
2536 // Print register Command
2538 PciExplainCommand (&(Common
->Command
));
2541 // Print register Status
2543 PciExplainStatus (&(Common
->Status
), TRUE
, PciUndefined
);
2546 // Print register Revision ID
2548 ShellPrintEx(-1, -1, L
"/r/n");
2549 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_RID
), gShellDebug1HiiHandle
,
2550 INDEX_OF (&(Common
->RevisionId
)),
2555 // Print register BIST
2557 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_BIST
), gShellDebug1HiiHandle
, INDEX_OF (&(Common
->BIST
)));
2558 if ((Common
->BIST
& PCI_BIT_7
) != 0) {
2559 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_CAP
), gShellDebug1HiiHandle
, 0x0f & Common
->BIST
);
2561 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_CAP_NO
), gShellDebug1HiiHandle
);
2564 // Print register Cache Line Size
2566 ShellPrintHiiEx(-1, -1, NULL
,
2567 STRING_TOKEN (STR_PCI2_CACHE_LINE_SIZE
),
2568 gShellDebug1HiiHandle
,
2569 INDEX_OF (&(Common
->CacheLineSize
)),
2570 Common
->CacheLineSize
2574 // Print register Latency Timer
2576 ShellPrintHiiEx(-1, -1, NULL
,
2577 STRING_TOKEN (STR_PCI2_LATENCY_TIMER
),
2578 gShellDebug1HiiHandle
,
2579 INDEX_OF (&(Common
->PrimaryLatencyTimer
)),
2580 Common
->PrimaryLatencyTimer
2584 // Print register Header Type
2586 ShellPrintHiiEx(-1, -1, NULL
,
2587 STRING_TOKEN (STR_PCI2_HEADER_TYPE
),
2588 gShellDebug1HiiHandle
,
2589 INDEX_OF (&(Common
->HeaderType
)),
2593 if ((Common
->HeaderType
& PCI_BIT_7
) != 0) {
2594 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MULTI_FUNCTION
), gShellDebug1HiiHandle
);
2597 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_SINGLE_FUNCTION
), gShellDebug1HiiHandle
);
2600 HeaderType
= (PCI_HEADER_TYPE
)(UINT8
) (Common
->HeaderType
& 0x7f);
2601 switch (HeaderType
) {
2603 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_PCI_DEVICE
), gShellDebug1HiiHandle
);
2607 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_P2P_BRIDGE
), gShellDebug1HiiHandle
);
2610 case PciCardBusBridge
:
2611 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_CARDBUS_BRIDGE
), gShellDebug1HiiHandle
);
2615 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RESERVED
), gShellDebug1HiiHandle
);
2616 HeaderType
= PciUndefined
;
2620 // Print register Class Code
2622 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_CLASS
), gShellDebug1HiiHandle
);
2623 PciPrintClassCode ((UINT8
*) Common
->ClassCode
, TRUE
);
2626 if (ShellGetExecutionBreakFlag()) {
2631 // Interpret remaining part of PCI configuration header depending on
2635 Status
= EFI_SUCCESS
;
2636 switch (HeaderType
) {
2638 Status
= PciExplainDeviceData (
2639 &(ConfigSpace
->NonCommon
.Device
),
2643 CapPtr
= ConfigSpace
->NonCommon
.Device
.CapabilitiesPtr
;
2647 Status
= PciExplainBridgeData (
2648 &(ConfigSpace
->NonCommon
.Bridge
),
2652 CapPtr
= ConfigSpace
->NonCommon
.Bridge
.CapabilitiesPtr
;
2655 case PciCardBusBridge
:
2656 Status
= PciExplainCardBusData (
2657 &(ConfigSpace
->NonCommon
.CardBus
),
2661 CapPtr
= ConfigSpace
->NonCommon
.CardBus
.CapabilitiesPtr
;
2665 // If Status bit4 is 1, dump or explain capability structure
2667 if ((Common
->Status
) & EFI_PCI_STATUS_CAPABILITY
) {
2668 PciExplainCapabilityStruct (IoDev
, Address
, CapPtr
);
2675 PciExplainDeviceData (
2676 IN PCI_DEVICE_HEADER
*Device
,
2678 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
2682 Routine Description:
2684 Explain the device specific part of data in PCI configuration space.
2688 Device Data in PCI configuration space
2689 Address Address used to access configuration space of this PCI device
2690 IoDev Handle used to access configuration space of PCI device
2694 EFI_SUCCESS The command completed successfully
2704 // Print Base Address Registers(Bar). When Bar = 0, this Bar does not
2705 // exist. If these no Bar for this function, print "none", otherwise
2706 // list detail information about this Bar.
2708 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BASE_ADDR
), gShellDebug1HiiHandle
, INDEX_OF (Device
->Bar
));
2711 BarCount
= sizeof (Device
->Bar
) / sizeof (Device
->Bar
[0]);
2712 for (Index
= 0; Index
< BarCount
; Index
++) {
2713 if (Device
->Bar
[Index
] == 0) {
2719 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_START_TYPE
), gShellDebug1HiiHandle
);
2720 Print (L
" --------------------------------------------------------------------------");
2723 Status
= PciExplainBar (
2724 &(Device
->Bar
[Index
]),
2725 &(mConfigSpace
->Common
.Command
),
2731 if (EFI_ERROR (Status
)) {
2737 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NONE
), gShellDebug1HiiHandle
);
2740 Print (L
"\n --------------------------------------------------------------------------");
2744 // Print register Expansion ROM Base Address
2746 if ((Device
->ROMBar
& PCI_BIT_0
) == 0) {
2747 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_EXPANSION_ROM_DISABLED
), gShellDebug1HiiHandle
, INDEX_OF (&(Device
->ROMBar
)));
2750 ShellPrintHiiEx(-1, -1, NULL
,
2751 STRING_TOKEN (STR_PCI2_EXPANSION_ROM_BASE
),
2752 gShellDebug1HiiHandle
,
2753 INDEX_OF (&(Device
->ROMBar
)),
2758 // Print register Cardbus CIS ptr
2760 ShellPrintHiiEx(-1, -1, NULL
,
2761 STRING_TOKEN (STR_PCI2_CARDBUS_CIS
),
2762 gShellDebug1HiiHandle
,
2763 INDEX_OF (&(Device
->CardBusCISPtr
)),
2764 Device
->CardBusCISPtr
2768 // Print register Sub-vendor ID and subsystem ID
2770 ShellPrintHiiEx(-1, -1, NULL
,
2771 STRING_TOKEN (STR_PCI2_SUB_VENDOR_ID
),
2772 gShellDebug1HiiHandle
,
2773 INDEX_OF (&(Device
->SubVendorId
)),
2777 ShellPrintHiiEx(-1, -1, NULL
,
2778 STRING_TOKEN (STR_PCI2_SUBSYSTEM_ID
),
2779 gShellDebug1HiiHandle
,
2780 INDEX_OF (&(Device
->SubSystemId
)),
2785 // Print register Capabilities Ptr
2787 ShellPrintHiiEx(-1, -1, NULL
,
2788 STRING_TOKEN (STR_PCI2_CAPABILITIES_PTR
),
2789 gShellDebug1HiiHandle
,
2790 INDEX_OF (&(Device
->CapabilitiesPtr
)),
2791 Device
->CapabilitiesPtr
2795 // Print register Interrupt Line and interrupt pin
2797 ShellPrintHiiEx(-1, -1, NULL
,
2798 STRING_TOKEN (STR_PCI2_INTERRUPT_LINE
),
2799 gShellDebug1HiiHandle
,
2800 INDEX_OF (&(Device
->InterruptLine
)),
2801 Device
->InterruptLine
2804 ShellPrintHiiEx(-1, -1, NULL
,
2805 STRING_TOKEN (STR_PCI2_INTERRUPT_PIN
),
2806 gShellDebug1HiiHandle
,
2807 INDEX_OF (&(Device
->InterruptPin
)),
2808 Device
->InterruptPin
2812 // Print register Min_Gnt and Max_Lat
2814 ShellPrintHiiEx(-1, -1, NULL
,
2815 STRING_TOKEN (STR_PCI2_MIN_GNT
),
2816 gShellDebug1HiiHandle
,
2817 INDEX_OF (&(Device
->MinGnt
)),
2821 ShellPrintHiiEx(-1, -1, NULL
,
2822 STRING_TOKEN (STR_PCI2_MAX_LAT
),
2823 gShellDebug1HiiHandle
,
2824 INDEX_OF (&(Device
->MaxLat
)),
2832 PciExplainBridgeData (
2833 IN PCI_BRIDGE_HEADER
*Bridge
,
2835 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
2839 Routine Description:
2841 Explain the bridge specific part of data in PCI configuration space.
2845 Bridge Bridge specific data region in PCI configuration space
2846 Address Address used to access configuration space of this PCI device
2847 IoDev Handle used to access configuration space of PCI device
2851 EFI_SUCCESS The command completed successfully
2862 // Print Base Address Registers. When Bar = 0, this Bar does not
2863 // exist. If these no Bar for this function, print "none", otherwise
2864 // list detail information about this Bar.
2866 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BASE_ADDRESS
), gShellDebug1HiiHandle
, INDEX_OF (&(Bridge
->Bar
)));
2869 BarCount
= sizeof (Bridge
->Bar
) / sizeof (Bridge
->Bar
[0]);
2871 for (Index
= 0; Index
< BarCount
; Index
++) {
2872 if (Bridge
->Bar
[Index
] == 0) {
2878 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_START_TYPE_2
), gShellDebug1HiiHandle
);
2879 Print (L
" --------------------------------------------------------------------------");
2882 Status
= PciExplainBar (
2883 &(Bridge
->Bar
[Index
]),
2884 &(mConfigSpace
->Common
.Command
),
2890 if (EFI_ERROR (Status
)) {
2896 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NONE
), gShellDebug1HiiHandle
);
2898 Print (L
"\n --------------------------------------------------------------------------");
2902 // Expansion register ROM Base Address
2904 if ((Bridge
->ROMBar
& PCI_BIT_0
) == 0) {
2905 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NO_EXPANSION_ROM
), gShellDebug1HiiHandle
, INDEX_OF (&(Bridge
->ROMBar
)));
2908 ShellPrintHiiEx(-1, -1, NULL
,
2909 STRING_TOKEN (STR_PCI2_EXPANSION_ROM_BASE_2
),
2910 gShellDebug1HiiHandle
,
2911 INDEX_OF (&(Bridge
->ROMBar
)),
2916 // Print Bus Numbers(Primary, Secondary, and Subordinate
2918 ShellPrintHiiEx(-1, -1, NULL
,
2919 STRING_TOKEN (STR_PCI2_BUS_NUMBERS
),
2920 gShellDebug1HiiHandle
,
2921 INDEX_OF (&(Bridge
->PrimaryBus
)),
2922 INDEX_OF (&(Bridge
->SecondaryBus
)),
2923 INDEX_OF (&(Bridge
->SubordinateBus
))
2926 Print (L
" ------------------------------------------------------\n");
2928 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BRIDGE
), gShellDebug1HiiHandle
, Bridge
->PrimaryBus
);
2929 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BRIDGE
), gShellDebug1HiiHandle
, Bridge
->SecondaryBus
);
2930 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BRIDGE
), gShellDebug1HiiHandle
, Bridge
->SubordinateBus
);
2933 // Print register Secondary Latency Timer
2935 ShellPrintHiiEx(-1, -1, NULL
,
2936 STRING_TOKEN (STR_PCI2_SECONDARY_TIMER
),
2937 gShellDebug1HiiHandle
,
2938 INDEX_OF (&(Bridge
->SecondaryLatencyTimer
)),
2939 Bridge
->SecondaryLatencyTimer
2943 // Print register Secondary Status
2945 PciExplainStatus (&(Bridge
->SecondaryStatus
), FALSE
, PciP2pBridge
);
2948 // Print I/O and memory ranges this bridge forwards. There are 3 resource
2949 // types: I/O, memory, and pre-fetchable memory. For each resource type,
2950 // base and limit address are listed.
2952 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RESOURCE_TYPE
), gShellDebug1HiiHandle
);
2953 Print (L
"----------------------------------------------------------------------\n");
2958 IoAddress32
= (Bridge
->IoBaseUpper
<< 16 | Bridge
->IoBase
<< 8);
2959 IoAddress32
&= 0xfffff000;
2960 ShellPrintHiiEx(-1, -1, NULL
,
2961 STRING_TOKEN (STR_PCI2_TWO_VARS
),
2962 gShellDebug1HiiHandle
,
2963 INDEX_OF (&(Bridge
->IoBase
)),
2967 IoAddress32
= (Bridge
->IoLimitUpper
<< 16 | Bridge
->IoLimit
<< 8);
2968 IoAddress32
|= 0x00000fff;
2969 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_ONE_VAR
), gShellDebug1HiiHandle
, IoAddress32
);
2972 // Memory Base & Limit
2974 ShellPrintHiiEx(-1, -1, NULL
,
2975 STRING_TOKEN (STR_PCI2_MEMORY
),
2976 gShellDebug1HiiHandle
,
2977 INDEX_OF (&(Bridge
->MemoryBase
)),
2978 (Bridge
->MemoryBase
<< 16) & 0xfff00000
2981 ShellPrintHiiEx(-1, -1, NULL
,
2982 STRING_TOKEN (STR_PCI2_ONE_VAR
),
2983 gShellDebug1HiiHandle
,
2984 (Bridge
->MemoryLimit
<< 16) | 0x000fffff
2988 // Pre-fetch-able Memory Base & Limit
2990 ShellPrintHiiEx(-1, -1, NULL
,
2991 STRING_TOKEN (STR_PCI2_PREFETCHABLE
),
2992 gShellDebug1HiiHandle
,
2993 INDEX_OF (&(Bridge
->PrefetchableMemBase
)),
2994 Bridge
->PrefetchableBaseUpper
,
2995 (Bridge
->PrefetchableMemBase
<< 16) & 0xfff00000
2998 ShellPrintHiiEx(-1, -1, NULL
,
2999 STRING_TOKEN (STR_PCI2_TWO_VARS_2
),
3000 gShellDebug1HiiHandle
,
3001 Bridge
->PrefetchableLimitUpper
,
3002 (Bridge
->PrefetchableMemLimit
<< 16) | 0x000fffff
3006 // Print register Capabilities Pointer
3008 ShellPrintHiiEx(-1, -1, NULL
,
3009 STRING_TOKEN (STR_PCI2_CAPABILITIES_PTR_2
),
3010 gShellDebug1HiiHandle
,
3011 INDEX_OF (&(Bridge
->CapabilitiesPtr
)),
3012 Bridge
->CapabilitiesPtr
3016 // Print register Bridge Control
3018 PciExplainBridgeControl (&(Bridge
->BridgeControl
), PciP2pBridge
);
3021 // Print register Interrupt Line & PIN
3023 ShellPrintHiiEx(-1, -1, NULL
,
3024 STRING_TOKEN (STR_PCI2_INTERRUPT_LINE_2
),
3025 gShellDebug1HiiHandle
,
3026 INDEX_OF (&(Bridge
->InterruptLine
)),
3027 Bridge
->InterruptLine
3030 ShellPrintHiiEx(-1, -1, NULL
,
3031 STRING_TOKEN (STR_PCI2_INTERRUPT_PIN
),
3032 gShellDebug1HiiHandle
,
3033 INDEX_OF (&(Bridge
->InterruptPin
)),
3034 Bridge
->InterruptPin
3045 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
,
3050 Routine Description:
3052 Explain the Base Address Register(Bar) in PCI configuration space.
3056 Bar Points to the Base Address Register intended to interpret
3057 Command Points to the register Command
3058 Address Address used to access configuration space of this PCI device
3059 IoDev Handle used to access configuration space of PCI device
3064 EFI_SUCCESS The command completed successfully
3085 // According the bar type, list detail about this bar, for example: 32 or
3086 // 64 bits; pre-fetchable or not.
3088 if ((*Bar
& PCI_BIT_0
) == 0) {
3090 // This bar is of memory type
3094 if ((*Bar
& PCI_BIT_1
) == 0 && (*Bar
& PCI_BIT_2
) == 0) {
3095 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BAR
), gShellDebug1HiiHandle
, *Bar
& 0xfffffff0);
3096 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MEM
), gShellDebug1HiiHandle
);
3097 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_32_BITS
), gShellDebug1HiiHandle
);
3099 } else if ((*Bar
& PCI_BIT_1
) == 0 && (*Bar
& PCI_BIT_2
) != 0) {
3101 CopyMem (&Bar64
, Bar
, sizeof (UINT64
));
3102 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_ONE_VAR_2
), gShellDebug1HiiHandle
, RShiftU64 ((Bar64
& 0xfffffffffffffff0), 32));
3103 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_ONE_VAR_3
), gShellDebug1HiiHandle
, (UINT32
) (Bar64
& 0xfffffffffffffff0));
3104 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MEM
), gShellDebug1HiiHandle
);
3105 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_64_BITS
), gShellDebug1HiiHandle
);
3113 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BAR
), gShellDebug1HiiHandle
, *Bar
& 0xfffffff0);
3114 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MEM_2
), gShellDebug1HiiHandle
);
3117 if ((*Bar
& PCI_BIT_3
) == 0) {
3118 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NO
), gShellDebug1HiiHandle
);
3121 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_YES
), gShellDebug1HiiHandle
);
3126 // This bar is of io type
3129 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_ONE_VAR_4
), gShellDebug1HiiHandle
, *Bar
& 0xfffffffc);
3134 // Get BAR length(or the amount of resource this bar demands for). To get
3135 // Bar length, first we should temporarily disable I/O and memory access
3136 // of this function(by set bits in the register Command), then write all
3137 // "1"s to this bar. The bar value read back is the amount of resource
3138 // this bar demands for.
3141 // Disable io & mem access
3143 OldCommand
= *Command
;
3144 NewCommand
= (UINT16
) (OldCommand
& 0xfffc);
3145 RegAddress
= Address
| INDEX_OF (Command
);
3146 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint16
, RegAddress
, 1, &NewCommand
);
3148 RegAddress
= Address
| INDEX_OF (Bar
);
3151 // Read after write the BAR to get the size
3155 NewBar32
= 0xffffffff;
3157 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint32
, RegAddress
, 1, &NewBar32
);
3158 IoDev
->Pci
.Read (IoDev
, EfiPciWidthUint32
, RegAddress
, 1, &NewBar32
);
3159 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint32
, RegAddress
, 1, &OldBar32
);
3162 NewBar32
= NewBar32
& 0xfffffff0;
3163 NewBar32
= (~NewBar32
) + 1;
3166 NewBar32
= NewBar32
& 0xfffffffc;
3167 NewBar32
= (~NewBar32
) + 1;
3168 NewBar32
= NewBar32
& 0x0000ffff;
3173 CopyMem (&OldBar64
, Bar
, sizeof (UINT64
));
3174 NewBar64
= 0xffffffffffffffff;
3176 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint32
, RegAddress
, 2, &NewBar64
);
3177 IoDev
->Pci
.Read (IoDev
, EfiPciWidthUint32
, RegAddress
, 2, &NewBar64
);
3178 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint32
, RegAddress
, 2, &OldBar64
);
3181 NewBar64
= NewBar64
& 0xfffffffffffffff0;
3182 NewBar64
= (~NewBar64
) + 1;
3185 NewBar64
= NewBar64
& 0xfffffffffffffffc;
3186 NewBar64
= (~NewBar64
) + 1;
3187 NewBar64
= NewBar64
& 0x000000000000ffff;
3191 // Enable io & mem access
3193 RegAddress
= Address
| INDEX_OF (Command
);
3194 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint16
, RegAddress
, 1, &OldCommand
);
3198 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NEWBAR_32
), gShellDebug1HiiHandle
, NewBar32
);
3199 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NEWBAR_32_2
), gShellDebug1HiiHandle
, NewBar32
+ (*Bar
& 0xfffffff0) - 1);
3202 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RSHIFT
), gShellDebug1HiiHandle
, RShiftU64 (NewBar64
, 32));
3203 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RSHIFT
), gShellDebug1HiiHandle
, (UINT32
) NewBar64
);
3205 ShellPrintHiiEx(-1, -1, NULL
,
3206 STRING_TOKEN (STR_PCI2_RSHIFT
),
3207 gShellDebug1HiiHandle
,
3208 RShiftU64 ((NewBar64
+ (Bar64
& 0xfffffffffffffff0) - 1), 32)
3210 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RSHIFT
), gShellDebug1HiiHandle
, (UINT32
) (NewBar64
+ (Bar64
& 0xfffffffffffffff0) - 1));
3214 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NEWBAR_32_3
), gShellDebug1HiiHandle
, NewBar32
);
3215 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NEWBAR_32_4
), gShellDebug1HiiHandle
, NewBar32
+ (*Bar
& 0xfffffffc) - 1);
3222 PciExplainCardBusData (
3223 IN PCI_CARDBUS_HEADER
*CardBus
,
3225 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
3229 Routine Description:
3231 Explain the cardbus specific part of data in PCI configuration space.
3235 CardBus CardBus specific region of PCI configuration space
3236 Address Address used to access configuration space of this PCI device
3237 IoDev Handle used to access configuration space of PCI device
3241 EFI_SUCCESS The command completed successfully
3246 PCI_CARDBUS_DATA
*CardBusData
;
3248 ShellPrintHiiEx(-1, -1, NULL
,
3249 STRING_TOKEN (STR_PCI2_CARDBUS_SOCKET
),
3250 gShellDebug1HiiHandle
,
3251 INDEX_OF (&(CardBus
->CardBusSocketReg
)),
3252 CardBus
->CardBusSocketReg
3256 // Print Secondary Status
3258 PciExplainStatus (&(CardBus
->SecondaryStatus
), FALSE
, PciCardBusBridge
);
3261 // Print Bus Numbers(Primary bus number, CardBus bus number, and
3262 // Subordinate bus number
3264 ShellPrintHiiEx(-1, -1, NULL
,
3265 STRING_TOKEN (STR_PCI2_BUS_NUMBERS_2
),
3266 gShellDebug1HiiHandle
,
3267 INDEX_OF (&(CardBus
->PciBusNumber
)),
3268 INDEX_OF (&(CardBus
->CardBusBusNumber
)),
3269 INDEX_OF (&(CardBus
->SubordinateBusNumber
))
3272 Print (L
" ------------------------------------------------------\n");
3274 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_CARDBUS
), gShellDebug1HiiHandle
, CardBus
->PciBusNumber
);
3275 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_CARDBUS_2
), gShellDebug1HiiHandle
, CardBus
->CardBusBusNumber
);
3276 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_CARDBUS_3
), gShellDebug1HiiHandle
, CardBus
->SubordinateBusNumber
);
3279 // Print CardBus Latency Timer
3281 ShellPrintHiiEx(-1, -1, NULL
,
3282 STRING_TOKEN (STR_PCI2_CARDBUS_LATENCY
),
3283 gShellDebug1HiiHandle
,
3284 INDEX_OF (&(CardBus
->CardBusLatencyTimer
)),
3285 CardBus
->CardBusLatencyTimer
3289 // Print Memory/Io ranges this cardbus bridge forwards
3291 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RESOURCE_TYPE_2
), gShellDebug1HiiHandle
);
3292 Print (L
"----------------------------------------------------------------------\n");
3294 ShellPrintHiiEx(-1, -1, NULL
,
3295 STRING_TOKEN (STR_PCI2_MEM_3
),
3296 gShellDebug1HiiHandle
,
3297 INDEX_OF (&(CardBus
->MemoryBase0
)),
3298 CardBus
->BridgeControl
& PCI_BIT_8
? L
" Prefetchable" : L
"Non-Prefetchable",
3299 CardBus
->MemoryBase0
& 0xfffff000,
3300 CardBus
->MemoryLimit0
| 0x00000fff
3303 ShellPrintHiiEx(-1, -1, NULL
,
3304 STRING_TOKEN (STR_PCI2_MEM_3
),
3305 gShellDebug1HiiHandle
,
3306 INDEX_OF (&(CardBus
->MemoryBase1
)),
3307 CardBus
->BridgeControl
& PCI_BIT_9
? L
" Prefetchable" : L
"Non-Prefetchable",
3308 CardBus
->MemoryBase1
& 0xfffff000,
3309 CardBus
->MemoryLimit1
| 0x00000fff
3312 Io32Bit
= (BOOLEAN
) (CardBus
->IoBase0
& PCI_BIT_0
);
3313 ShellPrintHiiEx(-1, -1, NULL
,
3314 STRING_TOKEN (STR_PCI2_IO_2
),
3315 gShellDebug1HiiHandle
,
3316 INDEX_OF (&(CardBus
->IoBase0
)),
3317 Io32Bit
? L
" 32 bit" : L
" 16 bit",
3318 CardBus
->IoBase0
& (Io32Bit
? 0xfffffffc : 0x0000fffc),
3319 CardBus
->IoLimit0
& (Io32Bit
? 0xffffffff : 0x0000ffff) | 0x00000003
3322 Io32Bit
= (BOOLEAN
) (CardBus
->IoBase1
& PCI_BIT_0
);
3323 ShellPrintHiiEx(-1, -1, NULL
,
3324 STRING_TOKEN (STR_PCI2_IO_2
),
3325 gShellDebug1HiiHandle
,
3326 INDEX_OF (&(CardBus
->IoBase1
)),
3327 Io32Bit
? L
" 32 bit" : L
" 16 bit",
3328 CardBus
->IoBase1
& (Io32Bit
? 0xfffffffc : 0x0000fffc),
3329 CardBus
->IoLimit1
& (Io32Bit
? 0xffffffff : 0x0000ffff) | 0x00000003
3333 // Print register Interrupt Line & PIN
3335 ShellPrintHiiEx(-1, -1, NULL
,
3336 STRING_TOKEN (STR_PCI2_INTERRUPT_LINE_3
),
3337 gShellDebug1HiiHandle
,
3338 INDEX_OF (&(CardBus
->InterruptLine
)),
3339 CardBus
->InterruptLine
,
3340 INDEX_OF (&(CardBus
->InterruptPin
)),
3341 CardBus
->InterruptPin
3345 // Print register Bridge Control
3347 PciExplainBridgeControl (&(CardBus
->BridgeControl
), PciCardBusBridge
);
3350 // Print some registers in data region of PCI configuration space for cardbus
3351 // bridge. Fields include: Sub VendorId, Subsystem ID, and Legacy Mode Base
3354 CardBusData
= (PCI_CARDBUS_DATA
*) ((UINT8
*) CardBus
+ sizeof (PCI_CARDBUS_HEADER
));
3356 ShellPrintHiiEx(-1, -1, NULL
,
3357 STRING_TOKEN (STR_PCI2_SUB_VENDOR_ID_2
),
3358 gShellDebug1HiiHandle
,
3359 INDEX_OF (&(CardBusData
->SubVendorId
)),
3360 CardBusData
->SubVendorId
,
3361 INDEX_OF (&(CardBusData
->SubSystemId
)),
3362 CardBusData
->SubSystemId
3365 ShellPrintHiiEx(-1, -1, NULL
,
3366 STRING_TOKEN (STR_PCI2_OPTIONAL
),
3367 gShellDebug1HiiHandle
,
3368 INDEX_OF (&(CardBusData
->LegacyBase
)),
3369 CardBusData
->LegacyBase
3378 IN BOOLEAN MainStatus
,
3379 IN PCI_HEADER_TYPE HeaderType
3383 Routine Description:
3385 Explain each meaningful bit of register Status. The definition of Status is
3386 slightly different depending on the PCI header type.
3390 Status Points to the content of register Status
3391 MainStatus Indicates if this register is main status(not secondary
3393 HeaderType Header type of this PCI device
3397 EFI_SUCCESS The command completed successfully
3402 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_STATUS
), gShellDebug1HiiHandle
, INDEX_OF (Status
), *Status
);
3405 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_SECONDARY_STATUS
), gShellDebug1HiiHandle
, INDEX_OF (Status
), *Status
);
3408 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NEW_CAPABILITIES
), gShellDebug1HiiHandle
, (*Status
& PCI_BIT_4
) != 0);
3411 // Bit 5 is meaningless for CardBus Bridge
3413 if (HeaderType
== PciCardBusBridge
) {
3414 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_66_CAPABLE
), gShellDebug1HiiHandle
, (*Status
& PCI_BIT_5
) != 0);
3417 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_66_CAPABLE_2
), gShellDebug1HiiHandle
, (*Status
& PCI_BIT_5
) != 0);
3420 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_FAST_BACK
), gShellDebug1HiiHandle
, (*Status
& PCI_BIT_7
) != 0);
3422 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MASTER_DATA
), gShellDebug1HiiHandle
, (*Status
& PCI_BIT_8
) != 0);
3424 // Bit 9 and bit 10 together decides the DEVSEL timing
3426 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_DEVSEL_TIMING
), gShellDebug1HiiHandle
);
3427 if ((*Status
& PCI_BIT_9
) == 0 && (*Status
& PCI_BIT_10
) == 0) {
3428 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_FAST
), gShellDebug1HiiHandle
);
3430 } else if ((*Status
& PCI_BIT_9
) != 0 && (*Status
& PCI_BIT_10
) == 0) {
3431 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MEDIUM
), gShellDebug1HiiHandle
);
3433 } else if ((*Status
& PCI_BIT_9
) == 0 && (*Status
& PCI_BIT_10
) != 0) {
3434 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_SLOW
), gShellDebug1HiiHandle
);
3437 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RESERVED_2
), gShellDebug1HiiHandle
);
3440 ShellPrintHiiEx(-1, -1, NULL
,
3441 STRING_TOKEN (STR_PCI2_SIGNALED_TARGET
),
3442 gShellDebug1HiiHandle
,
3443 (*Status
& PCI_BIT_11
) != 0
3446 ShellPrintHiiEx(-1, -1, NULL
,
3447 STRING_TOKEN (STR_PCI2_RECEIVED_TARGET
),
3448 gShellDebug1HiiHandle
,
3449 (*Status
& PCI_BIT_12
) != 0
3452 ShellPrintHiiEx(-1, -1, NULL
,
3453 STRING_TOKEN (STR_PCI2_RECEIVED_MASTER
),
3454 gShellDebug1HiiHandle
,
3455 (*Status
& PCI_BIT_13
) != 0
3459 ShellPrintHiiEx(-1, -1, NULL
,
3460 STRING_TOKEN (STR_PCI2_SIGNALED_ERROR
),
3461 gShellDebug1HiiHandle
,
3462 (*Status
& PCI_BIT_14
) != 0
3466 ShellPrintHiiEx(-1, -1, NULL
,
3467 STRING_TOKEN (STR_PCI2_RECEIVED_ERROR
),
3468 gShellDebug1HiiHandle
,
3469 (*Status
& PCI_BIT_14
) != 0
3473 ShellPrintHiiEx(-1, -1, NULL
,
3474 STRING_TOKEN (STR_PCI2_DETECTED_ERROR
),
3475 gShellDebug1HiiHandle
,
3476 (*Status
& PCI_BIT_15
) != 0
3488 Routine Description:
3490 Explain each meaningful bit of register Command.
3494 Command Points to the content of register Command
3498 EFI_SUCCESS The command completed successfully
3503 // Print the binary value of register Command
3505 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_COMMAND
), gShellDebug1HiiHandle
, INDEX_OF (Command
), *Command
);
3508 // Explain register Command bit by bit
3510 ShellPrintHiiEx(-1, -1, NULL
,
3511 STRING_TOKEN (STR_PCI2_SPACE_ACCESS_DENIED
),
3512 gShellDebug1HiiHandle
,
3513 (*Command
& PCI_BIT_0
) != 0
3516 ShellPrintHiiEx(-1, -1, NULL
,
3517 STRING_TOKEN (STR_PCI2_MEMORY_SPACE
),
3518 gShellDebug1HiiHandle
,
3519 (*Command
& PCI_BIT_1
) != 0
3522 ShellPrintHiiEx(-1, -1, NULL
,
3523 STRING_TOKEN (STR_PCI2_BEHAVE_BUS_MASTER
),
3524 gShellDebug1HiiHandle
,
3525 (*Command
& PCI_BIT_2
) != 0
3528 ShellPrintHiiEx(-1, -1, NULL
,
3529 STRING_TOKEN (STR_PCI2_MONITOR_SPECIAL_CYCLE
),
3530 gShellDebug1HiiHandle
,
3531 (*Command
& PCI_BIT_3
) != 0
3534 ShellPrintHiiEx(-1, -1, NULL
,
3535 STRING_TOKEN (STR_PCI2_MEM_WRITE_INVALIDATE
),
3536 gShellDebug1HiiHandle
,
3537 (*Command
& PCI_BIT_4
) != 0
3540 ShellPrintHiiEx(-1, -1, NULL
,
3541 STRING_TOKEN (STR_PCI2_PALETTE_SNOOPING
),
3542 gShellDebug1HiiHandle
,
3543 (*Command
& PCI_BIT_5
) != 0
3546 ShellPrintHiiEx(-1, -1, NULL
,
3547 STRING_TOKEN (STR_PCI2_ASSERT_PERR
),
3548 gShellDebug1HiiHandle
,
3549 (*Command
& PCI_BIT_6
) != 0
3552 ShellPrintHiiEx(-1, -1, NULL
,
3553 STRING_TOKEN (STR_PCI2_DO_ADDR_STEPPING
),
3554 gShellDebug1HiiHandle
,
3555 (*Command
& PCI_BIT_7
) != 0
3558 ShellPrintHiiEx(-1, -1, NULL
,
3559 STRING_TOKEN (STR_PCI2_SERR_DRIVER
),
3560 gShellDebug1HiiHandle
,
3561 (*Command
& PCI_BIT_8
) != 0
3564 ShellPrintHiiEx(-1, -1, NULL
,
3565 STRING_TOKEN (STR_PCI2_FAST_BACK_2
),
3566 gShellDebug1HiiHandle
,
3567 (*Command
& PCI_BIT_9
) != 0
3574 PciExplainBridgeControl (
3575 IN UINT16
*BridgeControl
,
3576 IN PCI_HEADER_TYPE HeaderType
3580 Routine Description:
3582 Explain each meaningful bit of register Bridge Control.
3586 BridgeControl Points to the content of register Bridge Control
3587 HeaderType The headertype
3591 EFI_SUCCESS The command completed successfully
3595 ShellPrintHiiEx(-1, -1, NULL
,
3596 STRING_TOKEN (STR_PCI2_BRIDGE_CONTROL
),
3597 gShellDebug1HiiHandle
,
3598 INDEX_OF (BridgeControl
),
3602 ShellPrintHiiEx(-1, -1, NULL
,
3603 STRING_TOKEN (STR_PCI2_PARITY_ERROR
),
3604 gShellDebug1HiiHandle
,
3605 (*BridgeControl
& PCI_BIT_0
) != 0
3607 ShellPrintHiiEx(-1, -1, NULL
,
3608 STRING_TOKEN (STR_PCI2_SERR_ENABLE
),
3609 gShellDebug1HiiHandle
,
3610 (*BridgeControl
& PCI_BIT_1
) != 0
3612 ShellPrintHiiEx(-1, -1, NULL
,
3613 STRING_TOKEN (STR_PCI2_ISA_ENABLE
),
3614 gShellDebug1HiiHandle
,
3615 (*BridgeControl
& PCI_BIT_2
) != 0
3617 ShellPrintHiiEx(-1, -1, NULL
,
3618 STRING_TOKEN (STR_PCI2_VGA_ENABLE
),
3619 gShellDebug1HiiHandle
,
3620 (*BridgeControl
& PCI_BIT_3
) != 0
3622 ShellPrintHiiEx(-1, -1, NULL
,
3623 STRING_TOKEN (STR_PCI2_MASTER_ABORT
),
3624 gShellDebug1HiiHandle
,
3625 (*BridgeControl
& PCI_BIT_5
) != 0
3629 // Register Bridge Control has some slight differences between P2P bridge
3630 // and Cardbus bridge from bit 6 to bit 11.
3632 if (HeaderType
== PciP2pBridge
) {
3633 ShellPrintHiiEx(-1, -1, NULL
,
3634 STRING_TOKEN (STR_PCI2_SECONDARY_BUS_RESET
),
3635 gShellDebug1HiiHandle
,
3636 (*BridgeControl
& PCI_BIT_6
) != 0
3638 ShellPrintHiiEx(-1, -1, NULL
,
3639 STRING_TOKEN (STR_PCI2_FAST_ENABLE
),
3640 gShellDebug1HiiHandle
,
3641 (*BridgeControl
& PCI_BIT_7
) != 0
3643 ShellPrintHiiEx(-1, -1, NULL
,
3644 STRING_TOKEN (STR_PCI2_PRIMARY_DISCARD_TIMER
),
3645 gShellDebug1HiiHandle
,
3646 (*BridgeControl
& PCI_BIT_8
)!=0 ? L
"2^10" : L
"2^15"
3648 ShellPrintHiiEx(-1, -1, NULL
,
3649 STRING_TOKEN (STR_PCI2_SECONDARY_DISCARD_TIMER
),
3650 gShellDebug1HiiHandle
,
3651 (*BridgeControl
& PCI_BIT_9
)!=0 ? L
"2^10" : L
"2^15"
3653 ShellPrintHiiEx(-1, -1, NULL
,
3654 STRING_TOKEN (STR_PCI2_DISCARD_TIMER_STATUS
),
3655 gShellDebug1HiiHandle
,
3656 (*BridgeControl
& PCI_BIT_10
) != 0
3658 ShellPrintHiiEx(-1, -1, NULL
,
3659 STRING_TOKEN (STR_PCI2_DISCARD_TIMER_SERR
),
3660 gShellDebug1HiiHandle
,
3661 (*BridgeControl
& PCI_BIT_11
) != 0
3665 ShellPrintHiiEx(-1, -1, NULL
,
3666 STRING_TOKEN (STR_PCI2_CARDBUS_RESET
),
3667 gShellDebug1HiiHandle
,
3668 (*BridgeControl
& PCI_BIT_6
) != 0
3670 ShellPrintHiiEx(-1, -1, NULL
,
3671 STRING_TOKEN (STR_PCI2_IREQ_ENABLE
),
3672 gShellDebug1HiiHandle
,
3673 (*BridgeControl
& PCI_BIT_7
) != 0
3675 ShellPrintHiiEx(-1, -1, NULL
,
3676 STRING_TOKEN (STR_PCI2_WRITE_POSTING_ENABLE
),
3677 gShellDebug1HiiHandle
,
3678 (*BridgeControl
& PCI_BIT_10
) != 0
3686 PciExplainCapabilityStruct (
3687 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
,
3692 UINT8 CapabilityPtr
;
3693 UINT16 CapabilityEntry
;
3697 CapabilityPtr
= CapPtr
;
3700 // Go through the Capability list
3702 while ((CapabilityPtr
>= 0x40) && ((CapabilityPtr
& 0x03) == 0x00)) {
3703 RegAddress
= Address
+ CapabilityPtr
;
3704 IoDev
->Pci
.Read (IoDev
, EfiPciWidthUint16
, RegAddress
, 1, &CapabilityEntry
);
3706 CapabilityID
= (UINT8
) CapabilityEntry
;
3709 // Explain PciExpress data
3711 if (EFI_PCI_CAPABILITY_ID_PCIEXP
== CapabilityID
) {
3712 PciExplainPciExpress (IoDev
, Address
, CapabilityPtr
);
3716 // Explain other capabilities here
3718 CapabilityPtr
= (UINT8
) (CapabilityEntry
>> 8);
3726 IN PCIE_CAP_STURCTURE
*PciExpressCap
3730 CHAR16
*DevicePortType
;
3732 PcieCapReg
= PciExpressCap
->PcieCapReg
;
3734 L
" Capability Version(3:0): %E0x%04x%N\n",
3735 PCIE_CAP_VERSION (PcieCapReg
)
3737 if ((UINT8
) PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg
) < PCIE_DEVICE_PORT_TYPE_MAX
) {
3738 DevicePortType
= DevicePortTypeTable
[PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg
)];
3740 DevicePortType
= L
"Unknown Type";
3743 L
" Device/PortType(7:4): %E%s%N\n",
3747 // 'Slot Implemented' is only valid for:
3748 // a) Root Port of PCI Express Root Complex, or
3749 // b) Downstream Port of PCI Express Switch
3751 if (PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg
) == PCIE_ROOT_COMPLEX_ROOT_PORT
||
3752 PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg
) == PCIE_SWITCH_DOWNSTREAM_PORT
) {
3754 L
" Slot Implemented(8): %E%d%N\n",
3755 PCIE_CAP_SLOT_IMPLEMENTED (PcieCapReg
)
3759 L
" Interrupt Message Number(13:9): %E0x%05x%N\n",
3760 PCIE_CAP_INT_MSG_NUM (PcieCapReg
)
3766 ExplainPcieDeviceCap (
3767 IN PCIE_CAP_STURCTURE
*PciExpressCap
3771 UINT32 PcieDeviceCap
;
3772 UINT8 DevicePortType
;
3776 PcieCapReg
= PciExpressCap
->PcieCapReg
;
3777 PcieDeviceCap
= PciExpressCap
->PcieDeviceCap
;
3778 DevicePortType
= (UINT8
) PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg
);
3779 Print (L
" Max_Payload_Size Supported(2:0): ");
3780 if (PCIE_CAP_MAX_PAYLOAD (PcieDeviceCap
) < 6) {
3781 Print (L
"%E%d bytes%N\n", 1 << (PCIE_CAP_MAX_PAYLOAD (PcieDeviceCap
) + 7));
3783 Print (L
"%EUnknown%N\n");
3786 L
" Phantom Functions Supported(4:3): %E%d%N\n",
3787 PCIE_CAP_PHANTOM_FUNC (PcieDeviceCap
)
3790 L
" Extended Tag Field Supported(5): %E%d-bit Tag field supported%N\n",
3791 PCIE_CAP_EXTENDED_TAG (PcieDeviceCap
) ? 8 : 5
3794 // Endpoint L0s and L1 Acceptable Latency is only valid for Endpoint
3796 if (IS_PCIE_ENDPOINT (DevicePortType
)) {
3797 L0sLatency
= (UINT8
) PCIE_CAP_L0sLatency (PcieDeviceCap
);
3798 L1Latency
= (UINT8
) PCIE_CAP_L1Latency (PcieDeviceCap
);
3799 Print (L
" Endpoint L0s Acceptable Latency(8:6): ");
3800 if (L0sLatency
< 4) {
3801 Print (L
"%EMaximum of %d ns%N\n", 1 << (L0sLatency
+ 6));
3803 if (L0sLatency
< 7) {
3804 Print (L
"%EMaximum of %d us%N\n", 1 << (L0sLatency
- 3));
3806 Print (L
"%ENo limit%N\n");
3809 Print (L
" Endpoint L1 Acceptable Latency(11:9): ");
3810 if (L1Latency
< 7) {
3811 Print (L
"%EMaximum of %d us%N\n", 1 << (L1Latency
+ 1));
3813 Print (L
"%ENo limit%N\n");
3817 L
" Role-based Error Reporting(15): %E%d%N\n",
3818 PCIE_CAP_ERR_REPORTING (PcieDeviceCap
)
3821 // Only valid for Upstream Port:
3822 // a) Captured Slot Power Limit Value
3823 // b) Captured Slot Power Scale
3825 if (DevicePortType
== PCIE_SWITCH_UPSTREAM_PORT
) {
3827 L
" Captured Slot Power Limit Value(25:18): %E0x%02x%N\n",
3828 PCIE_CAP_SLOT_POWER_VALUE (PcieDeviceCap
)
3831 L
" Captured Slot Power Limit Scale(27:26): %E%s%N\n",
3832 SlotPwrLmtScaleTable
[PCIE_CAP_SLOT_POWER_SCALE (PcieDeviceCap
)]
3836 // Function Level Reset Capability is only valid for Endpoint
3838 if (IS_PCIE_ENDPOINT (DevicePortType
)) {
3840 L
" Function Level Reset Capability(28): %E%d%N\n",
3841 PCIE_CAP_FUNC_LEVEL_RESET (PcieDeviceCap
)
3848 ExplainPcieDeviceControl (
3849 IN PCIE_CAP_STURCTURE
*PciExpressCap
3853 UINT16 PcieDeviceControl
;
3855 PcieCapReg
= PciExpressCap
->PcieCapReg
;
3856 PcieDeviceControl
= PciExpressCap
->DeviceControl
;
3858 L
" Correctable Error Reporting Enable(0): %E%d%N\n",
3859 PCIE_CAP_COR_ERR_REPORTING_ENABLE (PcieDeviceControl
)
3862 L
" Non-Fatal Error Reporting Enable(1): %E%d%N\n",
3863 PCIE_CAP_NONFAT_ERR_REPORTING_ENABLE (PcieDeviceControl
)
3866 L
" Fatal Error Reporting Enable(2): %E%d%N\n",
3867 PCIE_CAP_FATAL_ERR_REPORTING_ENABLE (PcieDeviceControl
)
3870 L
" Unsupported Request Reporting Enable(3): %E%d%N\n",
3871 PCIE_CAP_UNSUP_REQ_REPORTING_ENABLE (PcieDeviceControl
)
3874 L
" Enable Relaxed Ordering(4): %E%d%N\n",
3875 PCIE_CAP_RELAXED_ORDERING_ENABLE (PcieDeviceControl
)
3877 Print (L
" Max_Payload_Size(7:5): ");
3878 if (PCIE_CAP_MAX_PAYLOAD_SIZE (PcieDeviceControl
) < 6) {
3879 Print (L
"%E%d bytes%N\n", 1 << (PCIE_CAP_MAX_PAYLOAD_SIZE (PcieDeviceControl
) + 7));
3881 Print (L
"%EUnknown%N\n");
3884 L
" Extended Tag Field Enable(8): %E%d%N\n",
3885 PCIE_CAP_EXTENDED_TAG_ENABLE (PcieDeviceControl
)
3888 L
" Phantom Functions Enable(9): %E%d%N\n",
3889 PCIE_CAP_PHANTOM_FUNC_ENABLE (PcieDeviceControl
)
3892 L
" Auxiliary (AUX) Power PM Enable(10): %E%d%N\n",
3893 PCIE_CAP_AUX_PM_ENABLE (PcieDeviceControl
)
3896 L
" Enable No Snoop(11): %E%d%N\n",
3897 PCIE_CAP_NO_SNOOP_ENABLE (PcieDeviceControl
)
3899 Print (L
" Max_Read_Request_Size(14:12): ");
3900 if (PCIE_CAP_MAX_READ_REQ_SIZE (PcieDeviceControl
) < 6) {
3901 Print (L
"%E%d bytes%N\n", 1 << (PCIE_CAP_MAX_READ_REQ_SIZE (PcieDeviceControl
) + 7));
3903 Print (L
"%EUnknown%N\n");
3906 // Read operation is only valid for PCI Express to PCI/PCI-X Bridges
3908 if (PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg
) == PCIE_PCIE_TO_PCIX_BRIDGE
) {
3910 L
" Bridge Configuration Retry Enable(15): %E%d%N\n",
3911 PCIE_CAP_BRG_CONF_RETRY (PcieDeviceControl
)
3918 ExplainPcieDeviceStatus (
3919 IN PCIE_CAP_STURCTURE
*PciExpressCap
3922 UINT16 PcieDeviceStatus
;
3924 PcieDeviceStatus
= PciExpressCap
->DeviceStatus
;
3926 L
" Correctable Error Detected(0): %E%d%N\n",
3927 PCIE_CAP_COR_ERR_DETECTED (PcieDeviceStatus
)
3930 L
" Non-Fatal Error Detected(1): %E%d%N\n",
3931 PCIE_CAP_NONFAT_ERR_DETECTED (PcieDeviceStatus
)
3934 L
" Fatal Error Detected(2): %E%d%N\n",
3935 PCIE_CAP_FATAL_ERR_DETECTED (PcieDeviceStatus
)
3938 L
" Unsupported Request Detected(3): %E%d%N\n",
3939 PCIE_CAP_UNSUP_REQ_DETECTED (PcieDeviceStatus
)
3942 L
" AUX Power Detected(4): %E%d%N\n",
3943 PCIE_CAP_AUX_POWER_DETECTED (PcieDeviceStatus
)
3946 L
" Transactions Pending(5): %E%d%N\n",
3947 PCIE_CAP_TRANSACTION_PENDING (PcieDeviceStatus
)
3953 ExplainPcieLinkCap (
3954 IN PCIE_CAP_STURCTURE
*PciExpressCap
3958 CHAR16
*SupLinkSpeeds
;
3961 PcieLinkCap
= PciExpressCap
->LinkCap
;
3962 switch (PCIE_CAP_SUP_LINK_SPEEDS (PcieLinkCap
)) {
3964 SupLinkSpeeds
= L
"2.5 GT/s";
3967 SupLinkSpeeds
= L
"5.0 GT/s and 2.5 GT/s";
3970 SupLinkSpeeds
= L
"Unknown";
3974 L
" Supported Link Speeds(3:0): %E%s supported%N\n",
3978 L
" Maximum Link Width(9:4): %Ex%d%N\n",
3979 PCIE_CAP_MAX_LINK_WIDTH (PcieLinkCap
)
3981 switch (PCIE_CAP_ASPM_SUPPORT (PcieLinkCap
)) {
3983 ASPM
= L
"L0s Entry";
3986 ASPM
= L
"L0s and L1";
3993 L
" Active State Power Management Support(11:10): %E%s Supported%N\n",
3997 L
" L0s Exit Latency(14:12): %E%s%N\n",
3998 L0sLatencyStrTable
[PCIE_CAP_L0s_LATENCY (PcieLinkCap
)]
4001 L
" L1 Exit Latency(17:15): %E%s%N\n",
4002 L1LatencyStrTable
[PCIE_CAP_L0s_LATENCY (PcieLinkCap
)]
4005 L
" Clock Power Management(18): %E%d%N\n",
4006 PCIE_CAP_CLOCK_PM (PcieLinkCap
)
4009 L
" Surprise Down Error Reporting Capable(19): %E%d%N\n",
4010 PCIE_CAP_SUP_DOWN_ERR_REPORTING (PcieLinkCap
)
4013 L
" Data Link Layer Link Active Reporting Capable(20): %E%d%N\n",
4014 PCIE_CAP_LINK_ACTIVE_REPORTING (PcieLinkCap
)
4017 L
" Link Bandwidth Notification Capability(21): %E%d%N\n",
4018 PCIE_CAP_LINK_BWD_NOTIF_CAP (PcieLinkCap
)
4021 L
" Port Number(31:24): %E0x%02x%N\n",
4022 PCIE_CAP_PORT_NUMBER (PcieLinkCap
)
4028 ExplainPcieLinkControl (
4029 IN PCIE_CAP_STURCTURE
*PciExpressCap
4032 UINT16 PcieLinkControl
;
4033 UINT8 DevicePortType
;
4035 PcieLinkControl
= PciExpressCap
->LinkControl
;
4036 DevicePortType
= (UINT8
) PCIE_CAP_DEVICEPORT_TYPE (PciExpressCap
->PcieCapReg
);
4038 L
" Active State Power Management Control(1:0): %E%s%N\n",
4039 ASPMCtrlStrTable
[PCIE_CAP_ASPM_CONTROL (PcieLinkControl
)]
4042 // RCB is not applicable to switches
4044 if (!IS_PCIE_SWITCH(DevicePortType
)) {
4046 L
" Read Completion Boundary (RCB)(3): %E%d byte%N\n",
4047 1 << (PCIE_CAP_RCB (PcieLinkControl
) + 6)
4051 // Link Disable is reserved on
4053 // b) PCI Express to PCI/PCI-X bridges
4054 // c) Upstream Ports of Switches
4056 if (!IS_PCIE_ENDPOINT (DevicePortType
) &&
4057 DevicePortType
!= PCIE_SWITCH_UPSTREAM_PORT
&&
4058 DevicePortType
!= PCIE_PCIE_TO_PCIX_BRIDGE
) {
4060 L
" Link Disable(4): %E%d%N\n",
4061 PCIE_CAP_LINK_DISABLE (PcieLinkControl
)
4065 L
" Common Clock Configuration(6): %E%d%N\n",
4066 PCIE_CAP_COMMON_CLK_CONF (PcieLinkControl
)
4069 L
" Extended Synch(7): %E%d%N\n",
4070 PCIE_CAP_EXT_SYNC (PcieLinkControl
)
4073 L
" Enable Clock Power Management(8): %E%d%N\n",
4074 PCIE_CAP_CLK_PWR_MNG (PcieLinkControl
)
4077 L
" Hardware Autonomous Width Disable(9): %E%d%N\n",
4078 PCIE_CAP_HW_AUTO_WIDTH_DISABLE (PcieLinkControl
)
4081 L
" Link Bandwidth Management Interrupt Enable(10): %E%d%N\n",
4082 PCIE_CAP_LINK_BDW_MNG_INT_EN (PcieLinkControl
)
4085 L
" Link Autonomous Bandwidth Interrupt Enable(11): %E%d%N\n",
4086 PCIE_CAP_LINK_AUTO_BDW_INT_EN (PcieLinkControl
)
4092 ExplainPcieLinkStatus (
4093 IN PCIE_CAP_STURCTURE
*PciExpressCap
4096 UINT16 PcieLinkStatus
;
4097 CHAR16
*SupLinkSpeeds
;
4099 PcieLinkStatus
= PciExpressCap
->LinkStatus
;
4100 switch (PCIE_CAP_CUR_LINK_SPEED (PcieLinkStatus
)) {
4102 SupLinkSpeeds
= L
"2.5 GT/s";
4105 SupLinkSpeeds
= L
"5.0 GT/s";
4108 SupLinkSpeeds
= L
"Reserved";
4112 L
" Current Link Speed(3:0): %E%s%N\n",
4116 L
" Negotiated Link Width(9:4): %Ex%d%N\n",
4117 PCIE_CAP_NEGO_LINK_WIDTH (PcieLinkStatus
)
4120 L
" Link Training(11): %E%d%N\n",
4121 PCIE_CAP_LINK_TRAINING (PcieLinkStatus
)
4124 L
" Slot Clock Configuration(12): %E%d%N\n",
4125 PCIE_CAP_SLOT_CLK_CONF (PcieLinkStatus
)
4128 L
" Data Link Layer Link Active(13): %E%d%N\n",
4129 PCIE_CAP_DATA_LINK_ACTIVE (PcieLinkStatus
)
4132 L
" Link Bandwidth Management Status(14): %E%d%N\n",
4133 PCIE_CAP_LINK_BDW_MNG_STAT (PcieLinkStatus
)
4136 L
" Link Autonomous Bandwidth Status(15): %E%d%N\n",
4137 PCIE_CAP_LINK_AUTO_BDW_STAT (PcieLinkStatus
)
4143 ExplainPcieSlotCap (
4144 IN PCIE_CAP_STURCTURE
*PciExpressCap
4149 PcieSlotCap
= PciExpressCap
->SlotCap
;
4152 L
" Attention Button Present(0): %E%d%N\n",
4153 PCIE_CAP_ATT_BUT_PRESENT (PcieSlotCap
)
4156 L
" Power Controller Present(1): %E%d%N\n",
4157 PCIE_CAP_PWR_CTRLLER_PRESENT (PcieSlotCap
)
4160 L
" MRL Sensor Present(2): %E%d%N\n",
4161 PCIE_CAP_MRL_SENSOR_PRESENT (PcieSlotCap
)
4164 L
" Attention Indicator Present(3): %E%d%N\n",
4165 PCIE_CAP_ATT_IND_PRESENT (PcieSlotCap
)
4168 L
" Power Indicator Present(4): %E%d%N\n",
4169 PCIE_CAP_PWD_IND_PRESENT (PcieSlotCap
)
4172 L
" Hot-Plug Surprise(5): %E%d%N\n",
4173 PCIE_CAP_HOTPLUG_SUPPRISE (PcieSlotCap
)
4176 L
" Hot-Plug Capable(6): %E%d%N\n",
4177 PCIE_CAP_HOTPLUG_CAPABLE (PcieSlotCap
)
4180 L
" Slot Power Limit Value(14:7): %E0x%02x%N\n",
4181 PCIE_CAP_SLOT_PWR_LIMIT_VALUE (PcieSlotCap
)
4184 L
" Slot Power Limit Scale(16:15): %E%s%N\n",
4185 SlotPwrLmtScaleTable
[PCIE_CAP_SLOT_PWR_LIMIT_SCALE (PcieSlotCap
)]
4188 L
" Electromechanical Interlock Present(17): %E%d%N\n",
4189 PCIE_CAP_ELEC_INTERLOCK_PRESENT (PcieSlotCap
)
4192 L
" No Command Completed Support(18): %E%d%N\n",
4193 PCIE_CAP_NO_COMM_COMPLETED_SUP (PcieSlotCap
)
4196 L
" Physical Slot Number(31:19): %E%d%N\n",
4197 PCIE_CAP_PHY_SLOT_NUM (PcieSlotCap
)
4204 ExplainPcieSlotControl (
4205 IN PCIE_CAP_STURCTURE
*PciExpressCap
4208 UINT16 PcieSlotControl
;
4210 PcieSlotControl
= PciExpressCap
->SlotControl
;
4212 L
" Attention Button Pressed Enable(0): %E%d%N\n",
4213 PCIE_CAP_ATT_BUT_ENABLE (PcieSlotControl
)
4216 L
" Power Fault Detected Enable(1): %E%d%N\n",
4217 PCIE_CAP_PWR_FLT_DETECT_ENABLE (PcieSlotControl
)
4220 L
" MRL Sensor Changed Enable(2): %E%d%N\n",
4221 PCIE_CAP_MRL_SENSOR_CHANGE_ENABLE (PcieSlotControl
)
4224 L
" Presence Detect Changed Enable(3): %E%d%N\n",
4225 PCIE_CAP_PRES_DETECT_CHANGE_ENABLE (PcieSlotControl
)
4228 L
" Command Completed Interrupt Enable(4): %E%d%N\n",
4229 PCIE_CAP_COMM_CMPL_INT_ENABLE (PcieSlotControl
)
4232 L
" Hot-Plug Interrupt Enable(5): %E%d%N\n",
4233 PCIE_CAP_HOTPLUG_INT_ENABLE (PcieSlotControl
)
4236 L
" Attention Indicator Control(7:6): %E%s%N\n",
4237 IndicatorTable
[PCIE_CAP_ATT_IND_CTRL (PcieSlotControl
)]
4240 L
" Power Indicator Control(9:8): %E%s%N\n",
4241 IndicatorTable
[PCIE_CAP_PWR_IND_CTRL (PcieSlotControl
)]
4243 Print (L
" Power Controller Control(10): %EPower ");
4244 if (PCIE_CAP_PWR_CTRLLER_CTRL (PcieSlotControl
)) {
4250 L
" Electromechanical Interlock Control(11): %E%d%N\n",
4251 PCIE_CAP_ELEC_INTERLOCK_CTRL (PcieSlotControl
)
4254 L
" Data Link Layer State Changed Enable(12): %E%d%N\n",
4255 PCIE_CAP_DLINK_STAT_CHANGE_ENABLE (PcieSlotControl
)
4261 ExplainPcieSlotStatus (
4262 IN PCIE_CAP_STURCTURE
*PciExpressCap
4265 UINT16 PcieSlotStatus
;
4267 PcieSlotStatus
= PciExpressCap
->SlotStatus
;
4270 L
" Attention Button Pressed(0): %E%d%N\n",
4271 PCIE_CAP_ATT_BUT_PRESSED (PcieSlotStatus
)
4274 L
" Power Fault Detected(1): %E%d%N\n",
4275 PCIE_CAP_PWR_FLT_DETECTED (PcieSlotStatus
)
4278 L
" MRL Sensor Changed(2): %E%d%N\n",
4279 PCIE_CAP_MRL_SENSOR_CHANGED (PcieSlotStatus
)
4282 L
" Presence Detect Changed(3): %E%d%N\n",
4283 PCIE_CAP_PRES_DETECT_CHANGED (PcieSlotStatus
)
4286 L
" Command Completed(4): %E%d%N\n",
4287 PCIE_CAP_COMM_COMPLETED (PcieSlotStatus
)
4289 Print (L
" MRL Sensor State(5): %EMRL ");
4290 if (PCIE_CAP_MRL_SENSOR_STATE (PcieSlotStatus
)) {
4291 Print (L
" Opened%N\n");
4293 Print (L
" Closed%N\n");
4295 Print (L
" Presence Detect State(6): ");
4296 if (PCIE_CAP_PRES_DETECT_STATE (PcieSlotStatus
)) {
4297 Print (L
"%ECard Present in slot%N\n");
4299 Print (L
"%ESlot Empty%N\n");
4301 Print (L
" Electromechanical Interlock Status(7): %EElectromechanical Interlock ");
4302 if (PCIE_CAP_ELEC_INTERLOCK_STATE (PcieSlotStatus
)) {
4303 Print (L
"Engaged%N\n");
4305 Print (L
"Disengaged%N\n");
4308 L
" Data Link Layer State Changed(8): %E%d%N\n",
4309 PCIE_CAP_DLINK_STAT_CHANGED (PcieSlotStatus
)
4315 ExplainPcieRootControl (
4316 IN PCIE_CAP_STURCTURE
*PciExpressCap
4319 UINT16 PcieRootControl
;
4321 PcieRootControl
= PciExpressCap
->RootControl
;
4324 L
" System Error on Correctable Error Enable(0): %E%d%N\n",
4325 PCIE_CAP_SYSERR_ON_CORERR_EN (PcieRootControl
)
4328 L
" System Error on Non-Fatal Error Enable(1): %E%d%N\n",
4329 PCIE_CAP_SYSERR_ON_NONFATERR_EN (PcieRootControl
)
4332 L
" System Error on Fatal Error Enable(2): %E%d%N\n",
4333 PCIE_CAP_SYSERR_ON_FATERR_EN (PcieRootControl
)
4336 L
" PME Interrupt Enable(3): %E%d%N\n",
4337 PCIE_CAP_PME_INT_ENABLE (PcieRootControl
)
4340 L
" CRS Software Visibility Enable(4): %E%d%N\n",
4341 PCIE_CAP_CRS_SW_VIS_ENABLE (PcieRootControl
)
4348 ExplainPcieRootCap (
4349 IN PCIE_CAP_STURCTURE
*PciExpressCap
4354 PcieRootCap
= PciExpressCap
->RsvdP
;
4357 L
" CRS Software Visibility(0): %E%d%N\n",
4358 PCIE_CAP_CRS_SW_VIS (PcieRootCap
)
4365 ExplainPcieRootStatus (
4366 IN PCIE_CAP_STURCTURE
*PciExpressCap
4369 UINT32 PcieRootStatus
;
4371 PcieRootStatus
= PciExpressCap
->RootStatus
;
4374 L
" PME Requester ID(15:0): %E0x%04x%N\n",
4375 PCIE_CAP_PME_REQ_ID (PcieRootStatus
)
4378 L
" PME Status(16): %E%d%N\n",
4379 PCIE_CAP_PME_STATUS (PcieRootStatus
)
4382 L
" PME Pending(17): %E%d%N\n",
4383 PCIE_CAP_PME_PENDING (PcieRootStatus
)
4389 PciExplainPciExpress (
4390 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
,
4392 IN UINT8 CapabilityPtr
4396 PCIE_CAP_STURCTURE PciExpressCap
;
4398 UINT64 CapRegAddress
;
4403 UINTN ExtendRegSize
;
4404 UINT64 Pciex_Address
;
4405 UINT8 DevicePortType
;
4410 CapRegAddress
= Address
+ CapabilityPtr
;
4415 sizeof (PciExpressCap
) / sizeof (UINT32
),
4419 DevicePortType
= (UINT8
) PCIE_CAP_DEVICEPORT_TYPE (PciExpressCap
.PcieCapReg
);
4421 Print (L
"\nPci Express device capability structure:\n");
4423 for (Index
= 0; PcieExplainList
[Index
].Type
< PcieExplainTypeMax
; Index
++) {
4424 if (ShellGetExecutionBreakFlag()) {
4427 RegAddr
= ((UINT8
*) &PciExpressCap
) + PcieExplainList
[Index
].Offset
;
4428 switch (PcieExplainList
[Index
].Width
) {
4429 case FieldWidthUINT8
:
4430 RegValue
= *(UINT8
*) RegAddr
;
4432 case FieldWidthUINT16
:
4433 RegValue
= *(UINT16
*) RegAddr
;
4435 case FieldWidthUINT32
:
4436 RegValue
= *(UINT32
*) RegAddr
;
4442 ShellPrintHiiEx(-1, -1, NULL
,
4443 PcieExplainList
[Index
].Token
,
4444 gShellDebug1HiiHandle
,
4445 PcieExplainList
[Index
].Offset
,
4448 if (PcieExplainList
[Index
].Func
== NULL
) {
4451 switch (PcieExplainList
[Index
].Type
) {
4452 case PcieExplainTypeLink
:
4454 // Link registers should not be used by
4455 // a) Root Complex Integrated Endpoint
4456 // b) Root Complex Event Collector
4458 if (DevicePortType
== PCIE_ROOT_COMPLEX_INTEGRATED_PORT
||
4459 DevicePortType
== PCIE_ROOT_COMPLEX_EVENT_COLLECTOR
) {
4463 case PcieExplainTypeSlot
:
4465 // Slot registers are only valid for
4466 // a) Root Port of PCI Express Root Complex
4467 // b) Downstream Port of PCI Express Switch
4468 // and when SlotImplemented bit is set in PCIE cap register.
4470 if ((DevicePortType
!= PCIE_ROOT_COMPLEX_ROOT_PORT
&&
4471 DevicePortType
!= PCIE_SWITCH_DOWNSTREAM_PORT
) ||
4472 !PCIE_CAP_SLOT_IMPLEMENTED (PciExpressCap
.PcieCapReg
)) {
4476 case PcieExplainTypeRoot
:
4478 // Root registers are only valid for
4479 // Root Port of PCI Express Root Complex
4481 if (DevicePortType
!= PCIE_ROOT_COMPLEX_ROOT_PORT
) {
4488 PcieExplainList
[Index
].Func (&PciExpressCap
);
4491 Bus
= (UINT8
) (RShiftU64 (Address
, 24));
4492 Dev
= (UINT8
) (RShiftU64 (Address
, 16));
4493 Func
= (UINT8
) (RShiftU64 (Address
, 8));
4495 Pciex_Address
= CALC_EFI_PCIEX_ADDRESS (Bus
, Dev
, Func
, 0x100);
4497 ExtendRegSize
= 0x1000 - 0x100;
4499 ExRegBuffer
= (UINT8
*) AllocatePool (ExtendRegSize
);
4502 // PciRootBridgeIo protocol should support pci express extend space IO
4503 // (Begins at offset 0x100)
4505 Status
= IoDev
->Pci
.Read (
4509 (ExtendRegSize
) / sizeof (UINT32
),
4510 (VOID
*) (ExRegBuffer
)
4512 if (EFI_ERROR (Status
)) {
4513 FreePool ((VOID
*) ExRegBuffer
);
4514 return EFI_UNSUPPORTED
;
4517 // Start outputing PciEx extend space( 0xFF-0xFFF)
4519 Print (L
"\n%HStart dumping PCIex extended configuration space (0x100 - 0xFFF).%N\n\n");
4525 (VOID
*) (ExRegBuffer
)
4528 FreePool ((VOID
*) ExRegBuffer
);