2 Main file for Pci shell Debug1 function.
4 Copyright (c) 2005 - 2019, Intel Corporation. All rights reserved.<BR>
5 (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
6 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
7 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include "UefiShellDebug1CommandsLib.h"
12 #include <Protocol/PciRootBridgeIo.h>
13 #include <Library/ShellLib.h>
14 #include <IndustryStandard/Pci.h>
15 #include <IndustryStandard/Acpi.h>
19 // Printable strings for Pci class code
22 CHAR16
*BaseClass
; // Pointer to the PCI base class string
23 CHAR16
*SubClass
; // Pointer to the PCI sub class string
24 CHAR16
*PIFClass
; // Pointer to the PCI programming interface string
28 // a structure holding a single entry, which also points to its lower level
31 typedef struct PCI_CLASS_ENTRY_TAG
{
32 UINT8 Code
; // Class, subclass or I/F code
33 CHAR16
*DescText
; // Description string
34 struct PCI_CLASS_ENTRY_TAG
*LowerLevelClass
; // Subclass or I/F if any
38 // Declarations of entries which contain printable strings for class codes
39 // in PCI configuration space
41 PCI_CLASS_ENTRY PCIBlankEntry
[];
42 PCI_CLASS_ENTRY PCISubClass_00
[];
43 PCI_CLASS_ENTRY PCISubClass_01
[];
44 PCI_CLASS_ENTRY PCISubClass_02
[];
45 PCI_CLASS_ENTRY PCISubClass_03
[];
46 PCI_CLASS_ENTRY PCISubClass_04
[];
47 PCI_CLASS_ENTRY PCISubClass_05
[];
48 PCI_CLASS_ENTRY PCISubClass_06
[];
49 PCI_CLASS_ENTRY PCISubClass_07
[];
50 PCI_CLASS_ENTRY PCISubClass_08
[];
51 PCI_CLASS_ENTRY PCISubClass_09
[];
52 PCI_CLASS_ENTRY PCISubClass_0a
[];
53 PCI_CLASS_ENTRY PCISubClass_0b
[];
54 PCI_CLASS_ENTRY PCISubClass_0c
[];
55 PCI_CLASS_ENTRY PCISubClass_0d
[];
56 PCI_CLASS_ENTRY PCISubClass_0e
[];
57 PCI_CLASS_ENTRY PCISubClass_0f
[];
58 PCI_CLASS_ENTRY PCISubClass_10
[];
59 PCI_CLASS_ENTRY PCISubClass_11
[];
60 PCI_CLASS_ENTRY PCISubClass_12
[];
61 PCI_CLASS_ENTRY PCISubClass_13
[];
62 PCI_CLASS_ENTRY PCIPIFClass_0100
[];
63 PCI_CLASS_ENTRY PCIPIFClass_0101
[];
64 PCI_CLASS_ENTRY PCIPIFClass_0105
[];
65 PCI_CLASS_ENTRY PCIPIFClass_0106
[];
66 PCI_CLASS_ENTRY PCIPIFClass_0107
[];
67 PCI_CLASS_ENTRY PCIPIFClass_0108
[];
68 PCI_CLASS_ENTRY PCIPIFClass_0109
[];
69 PCI_CLASS_ENTRY PCIPIFClass_0300
[];
70 PCI_CLASS_ENTRY PCIPIFClass_0604
[];
71 PCI_CLASS_ENTRY PCIPIFClass_0609
[];
72 PCI_CLASS_ENTRY PCIPIFClass_060b
[];
73 PCI_CLASS_ENTRY PCIPIFClass_0700
[];
74 PCI_CLASS_ENTRY PCIPIFClass_0701
[];
75 PCI_CLASS_ENTRY PCIPIFClass_0703
[];
76 PCI_CLASS_ENTRY PCIPIFClass_0800
[];
77 PCI_CLASS_ENTRY PCIPIFClass_0801
[];
78 PCI_CLASS_ENTRY PCIPIFClass_0802
[];
79 PCI_CLASS_ENTRY PCIPIFClass_0803
[];
80 PCI_CLASS_ENTRY PCIPIFClass_0904
[];
81 PCI_CLASS_ENTRY PCIPIFClass_0c00
[];
82 PCI_CLASS_ENTRY PCIPIFClass_0c03
[];
83 PCI_CLASS_ENTRY PCIPIFClass_0c07
[];
84 PCI_CLASS_ENTRY PCIPIFClass_0d01
[];
85 PCI_CLASS_ENTRY PCIPIFClass_0e00
[];
88 // Base class strings entries
90 PCI_CLASS_ENTRY gClassStringList
[] = {
98 L
"Mass Storage Controller",
103 L
"Network Controller",
108 L
"Display Controller",
113 L
"Multimedia Device",
118 L
"Memory Controller",
128 L
"Simple Communications Controllers",
133 L
"Base System Peripherals",
153 L
"Serial Bus Controllers",
158 L
"Wireless Controllers",
163 L
"Intelligent IO Controllers",
168 L
"Satellite Communications Controllers",
173 L
"Encryption/Decryption Controllers",
178 L
"Data Acquisition & Signal Processing Controllers",
183 L
"Processing Accelerators",
188 L
"Non-Essential Instrumentation",
193 L
"Device does not fit in any defined classes",
199 /* null string ends the list */NULL
204 // Subclass strings entries
206 PCI_CLASS_ENTRY PCIBlankEntry
[] = {
215 /* null string ends the list */NULL
219 PCI_CLASS_ENTRY PCISubClass_00
[] = {
222 L
"All devices other than VGA",
227 L
"VGA-compatible devices",
233 /* null string ends the list */NULL
237 PCI_CLASS_ENTRY PCISubClass_01
[] = {
250 L
"Floppy disk controller",
265 L
"ATA controller with ADMA interface",
270 L
"Serial ATA controller",
275 L
"Serial Attached SCSI (SAS) controller ",
280 L
"Non-volatile memory subsystem",
285 L
"Universal Flash Storage (UFS) controller ",
290 L
"Other mass storage controller",
296 /* null string ends the list */NULL
300 PCI_CLASS_ENTRY PCISubClass_02
[] = {
303 L
"Ethernet controller",
308 L
"Token ring controller",
328 L
"WorldFip controller",
333 L
"PICMG 2.14 Multi Computing",
338 L
"InfiniBand controller",
343 L
"Other network controller",
349 /* null string ends the list */NULL
353 PCI_CLASS_ENTRY PCISubClass_03
[] = {
356 L
"VGA/8514 controller",
371 L
"Other display controller",
377 /* null string ends the list */PCIBlankEntry
381 PCI_CLASS_ENTRY PCISubClass_04
[] = {
394 L
"Computer Telephony device",
399 L
"Mixed mode device",
404 L
"Other multimedia device",
410 /* null string ends the list */NULL
414 PCI_CLASS_ENTRY PCISubClass_05
[] = {
417 L
"RAM memory controller",
422 L
"Flash memory controller",
427 L
"Other memory controller",
433 /* null string ends the list */NULL
437 PCI_CLASS_ENTRY PCISubClass_06
[] = {
455 L
"PCI/Micro Channel bridge",
465 L
"PCI/PCMCIA bridge",
485 L
"Semi-transparent PCI-to-PCI bridge",
490 L
"InfiniBand-to-PCI host bridge",
495 L
"Advanced Switching to PCI host bridge",
500 L
"Other bridge type",
506 /* null string ends the list */NULL
510 PCI_CLASS_ENTRY PCISubClass_07
[] = {
513 L
"Serial controller",
523 L
"Multiport serial controller",
533 L
"GPIB (IEEE 488.1/2) controller",
543 L
"Other communication device",
549 /* null string ends the list */NULL
553 PCI_CLASS_ENTRY PCISubClass_08
[] = {
576 L
"Generic PCI Hot-Plug controller",
581 L
"SD Host controller",
591 L
"Root Complex Event Collector",
596 L
"Other system peripheral",
602 /* null string ends the list */NULL
606 PCI_CLASS_ENTRY PCISubClass_09
[] = {
609 L
"Keyboard controller",
624 L
"Scanner controller",
629 L
"Gameport controller",
634 L
"Other input controller",
640 /* null string ends the list */NULL
644 PCI_CLASS_ENTRY PCISubClass_0a
[] = {
647 L
"Generic docking station",
652 L
"Other type of docking station",
658 /* null string ends the list */NULL
662 PCI_CLASS_ENTRY PCISubClass_0b
[] = {
706 /* null string ends the list */NULL
710 PCI_CLASS_ENTRY PCISubClass_0c
[] = {
738 L
"System Management Bus",
753 L
"SERCOS Interface Standard (IEC 61491)",
769 /* null string ends the list */NULL
773 PCI_CLASS_ENTRY PCISubClass_0d
[] = {
776 L
"iRDA compatible controller",
801 L
"Ethernet (802.11a - 5 GHz)",
806 L
"Ethernet (802.11b - 2.4 GHz)",
811 L
"Other type of wireless controller",
817 /* null string ends the list */NULL
821 PCI_CLASS_ENTRY PCISubClass_0e
[] = {
830 /* null string ends the list */NULL
834 PCI_CLASS_ENTRY PCISubClass_0f
[] = {
857 L
"Other satellite communication controller",
863 /* null string ends the list */NULL
867 PCI_CLASS_ENTRY PCISubClass_10
[] = {
870 L
"Network & computing Encrypt/Decrypt",
875 L
"Entertainment Encrypt/Decrypt",
880 L
"Other Encrypt/Decrypt",
886 /* null string ends the list */NULL
890 PCI_CLASS_ENTRY PCISubClass_11
[] = {
898 L
"Performance Counters",
903 L
"Communications synchronization plus time and frequency test/measurement ",
913 L
"Other DAQ & SP controllers",
919 /* null string ends the list */NULL
923 PCI_CLASS_ENTRY PCISubClass_12
[] = {
926 L
"Processing Accelerator",
932 /* null string ends the list */NULL
936 PCI_CLASS_ENTRY PCISubClass_13
[] = {
939 L
"Non-Essential Instrumentation Function",
945 /* null string ends the list */NULL
950 // Programming Interface entries
952 PCI_CLASS_ENTRY PCIPIFClass_0100
[] = {
960 L
"SCSI storage device SOP using PQI",
965 L
"SCSI controller SOP using PQI",
970 L
"SCSI storage device and controller SOP using PQI",
975 L
"SCSI storage device SOP using NVMe",
981 /* null string ends the list */NULL
985 PCI_CLASS_ENTRY PCIPIFClass_0101
[] = {
1013 L
"OM-primary, OM-secondary",
1018 L
"PI-primary, OM-secondary",
1023 L
"OM/PI-primary, OM-secondary",
1033 L
"OM-primary, PI-secondary",
1038 L
"PI-primary, PI-secondary",
1043 L
"OM/PI-primary, PI-secondary",
1053 L
"OM-primary, OM/PI-secondary",
1058 L
"PI-primary, OM/PI-secondary",
1063 L
"OM/PI-primary, OM/PI-secondary",
1073 L
"Master, OM-primary",
1078 L
"Master, PI-primary",
1083 L
"Master, OM/PI-primary",
1088 L
"Master, OM-secondary",
1093 L
"Master, OM-primary, OM-secondary",
1098 L
"Master, PI-primary, OM-secondary",
1103 L
"Master, OM/PI-primary, OM-secondary",
1108 L
"Master, OM-secondary",
1113 L
"Master, OM-primary, PI-secondary",
1118 L
"Master, PI-primary, PI-secondary",
1123 L
"Master, OM/PI-primary, PI-secondary",
1128 L
"Master, OM-secondary",
1133 L
"Master, OM-primary, OM/PI-secondary",
1138 L
"Master, PI-primary, OM/PI-secondary",
1143 L
"Master, OM/PI-primary, OM/PI-secondary",
1149 /* null string ends the list */NULL
1153 PCI_CLASS_ENTRY PCIPIFClass_0105
[] = {
1161 L
"Continuous operation",
1167 /* null string ends the list */NULL
1171 PCI_CLASS_ENTRY PCIPIFClass_0106
[] = {
1184 L
"Serial Storage Bus",
1190 /* null string ends the list */NULL
1194 PCI_CLASS_ENTRY PCIPIFClass_0107
[] = {
1208 /* null string ends the list */NULL
1212 PCI_CLASS_ENTRY PCIPIFClass_0108
[] = {
1231 /* null string ends the list */NULL
1235 PCI_CLASS_ENTRY PCIPIFClass_0109
[] = {
1249 /* null string ends the list */NULL
1253 PCI_CLASS_ENTRY PCIPIFClass_0300
[] = {
1267 /* null string ends the list */NULL
1271 PCI_CLASS_ENTRY PCIPIFClass_0604
[] = {
1279 L
"Subtractive decode",
1285 /* null string ends the list */NULL
1289 PCI_CLASS_ENTRY PCIPIFClass_0609
[] = {
1292 L
"Primary PCI bus side facing the system host processor",
1297 L
"Secondary PCI bus side facing the system host processor",
1303 /* null string ends the list */NULL
1307 PCI_CLASS_ENTRY PCIPIFClass_060b
[] = {
1315 L
"ASI-SIG Defined Portal",
1321 /* null string ends the list */NULL
1325 PCI_CLASS_ENTRY PCIPIFClass_0700
[] = {
1328 L
"Generic XT-compatible",
1333 L
"16450-compatible",
1338 L
"16550-compatible",
1343 L
"16650-compatible",
1348 L
"16750-compatible",
1353 L
"16850-compatible",
1358 L
"16950-compatible",
1364 /* null string ends the list */NULL
1368 PCI_CLASS_ENTRY PCIPIFClass_0701
[] = {
1381 L
"ECP 1.X-compliant",
1391 L
"IEEE 1284 target (not a controller)",
1397 /* null string ends the list */NULL
1401 PCI_CLASS_ENTRY PCIPIFClass_0703
[] = {
1409 L
"Hayes-compatible 16450",
1414 L
"Hayes-compatible 16550",
1419 L
"Hayes-compatible 16650",
1424 L
"Hayes-compatible 16750",
1430 /* null string ends the list */NULL
1434 PCI_CLASS_ENTRY PCIPIFClass_0800
[] = {
1457 L
"IO(x) APIC interrupt controller",
1463 /* null string ends the list */NULL
1467 PCI_CLASS_ENTRY PCIPIFClass_0801
[] = {
1486 /* null string ends the list */NULL
1490 PCI_CLASS_ENTRY PCIPIFClass_0802
[] = {
1509 /* null string ends the list */NULL
1513 PCI_CLASS_ENTRY PCIPIFClass_0803
[] = {
1532 /* null string ends the list */NULL
1536 PCI_CLASS_ENTRY PCIPIFClass_0904
[] = {
1550 /* null string ends the list */NULL
1554 PCI_CLASS_ENTRY PCIPIFClass_0c00
[] = {
1562 L
"Using 1394 OpenHCI spec",
1568 /* null string ends the list */NULL
1572 PCI_CLASS_ENTRY PCIPIFClass_0c03
[] = {
1595 L
"No specific programming interface",
1600 L
"(Not Host Controller)",
1606 /* null string ends the list */NULL
1610 PCI_CLASS_ENTRY PCIPIFClass_0c07
[] = {
1618 L
"Keyboard Controller Style",
1629 /* null string ends the list */NULL
1633 PCI_CLASS_ENTRY PCIPIFClass_0d01
[] = {
1636 L
"Consumer IR controller",
1641 L
"UWB Radio controller",
1647 /* null string ends the list */NULL
1651 PCI_CLASS_ENTRY PCIPIFClass_0e00
[] = {
1654 L
"Message FIFO at offset 40h",
1665 /* null string ends the list */NULL
1671 Generates printable Unicode strings that represent PCI device class,
1672 subclass and programmed I/F based on a value passed to the function.
1674 @param[in] ClassCode Value representing the PCI "Class Code" register read from a
1675 PCI device. The encodings are:
1676 bits 23:16 - Base Class Code
1677 bits 15:8 - Sub-Class Code
1678 bits 7:0 - Programming Interface
1679 @param[in, out] ClassStrings Pointer of PCI_CLASS_STRINGS structure, which contains
1680 printable class strings corresponding to ClassCode. The
1681 caller must not modify the strings that are pointed by
1682 the fields in ClassStrings.
1685 PciGetClassStrings (
1686 IN UINT32 ClassCode
,
1687 IN OUT PCI_CLASS_STRINGS
*ClassStrings
1692 PCI_CLASS_ENTRY
*CurrentClass
;
1695 // Assume no strings found
1697 ClassStrings
->BaseClass
= L
"UNDEFINED";
1698 ClassStrings
->SubClass
= L
"UNDEFINED";
1699 ClassStrings
->PIFClass
= L
"UNDEFINED";
1701 CurrentClass
= gClassStringList
;
1702 Code
= (UINT8
) (ClassCode
>> 16);
1706 // Go through all entries of the base class, until the entry with a matching
1707 // base class code is found. If reaches an entry with a null description
1708 // text, the last entry is met, which means no text for the base class was
1709 // found, so no more action is needed.
1711 while (Code
!= CurrentClass
[Index
].Code
) {
1712 if (NULL
== CurrentClass
[Index
].DescText
) {
1719 // A base class was found. Assign description, and check if this class has
1720 // sub-class defined. If sub-class defined, no more action is needed,
1721 // otherwise, continue to find description for the sub-class code.
1723 ClassStrings
->BaseClass
= CurrentClass
[Index
].DescText
;
1724 if (NULL
== CurrentClass
[Index
].LowerLevelClass
) {
1728 // find Subclass entry
1730 CurrentClass
= CurrentClass
[Index
].LowerLevelClass
;
1731 Code
= (UINT8
) (ClassCode
>> 8);
1735 // Go through all entries of the sub-class, until the entry with a matching
1736 // sub-class code is found. If reaches an entry with a null description
1737 // text, the last entry is met, which means no text for the sub-class was
1738 // found, so no more action is needed.
1740 while (Code
!= CurrentClass
[Index
].Code
) {
1741 if (NULL
== CurrentClass
[Index
].DescText
) {
1748 // A class was found for the sub-class code. Assign description, and check if
1749 // this sub-class has programming interface defined. If no, no more action is
1750 // needed, otherwise, continue to find description for the programming
1753 ClassStrings
->SubClass
= CurrentClass
[Index
].DescText
;
1754 if (NULL
== CurrentClass
[Index
].LowerLevelClass
) {
1758 // Find programming interface entry
1760 CurrentClass
= CurrentClass
[Index
].LowerLevelClass
;
1761 Code
= (UINT8
) ClassCode
;
1765 // Go through all entries of the I/F entries, until the entry with a
1766 // matching I/F code is found. If reaches an entry with a null description
1767 // text, the last entry is met, which means no text was found, so no more
1768 // action is needed.
1770 while (Code
!= CurrentClass
[Index
].Code
) {
1771 if (NULL
== CurrentClass
[Index
].DescText
) {
1778 // A class was found for the I/F code. Assign description, done!
1780 ClassStrings
->PIFClass
= CurrentClass
[Index
].DescText
;
1785 Print strings that represent PCI device class, subclass and programmed I/F.
1787 @param[in] ClassCodePtr Points to the memory which stores register Class Code in PCI
1788 configuration space.
1789 @param[in] IncludePIF If the printed string should include the programming I/F part
1793 IN UINT8
*ClassCodePtr
,
1794 IN BOOLEAN IncludePIF
1798 PCI_CLASS_STRINGS ClassStrings
;
1801 ClassCode
|= (UINT32
)ClassCodePtr
[0];
1802 ClassCode
|= (UINT32
)(ClassCodePtr
[1] << 8);
1803 ClassCode
|= (UINT32
)(ClassCodePtr
[2] << 16);
1806 // Get name from class code
1808 PciGetClassStrings (ClassCode
, &ClassStrings
);
1812 // Print base class, sub class, and programming inferface name
1814 ShellPrintEx (-1, -1, L
"%s - %s - %s",
1815 ClassStrings
.BaseClass
,
1816 ClassStrings
.SubClass
,
1817 ClassStrings
.PIFClass
1822 // Only print base class and sub class name
1824 ShellPrintEx (-1, -1, L
"%s - %s",
1825 ClassStrings
.BaseClass
,
1826 ClassStrings
.SubClass
1832 This function finds out the protocol which is in charge of the given
1833 segment, and its bus range covers the current bus number. It lookes
1834 each instances of RootBridgeIoProtocol handle, until the one meets the
1837 @param[in] HandleBuf Buffer which holds all PCI_ROOT_BRIDIGE_IO_PROTOCOL handles.
1838 @param[in] HandleCount Count of all PCI_ROOT_BRIDIGE_IO_PROTOCOL handles.
1839 @param[in] Segment Segment number of device we are dealing with.
1840 @param[in] Bus Bus number of device we are dealing with.
1841 @param[out] IoDev Handle used to access configuration space of PCI device.
1843 @retval EFI_SUCCESS The command completed successfully.
1844 @retval EFI_INVALID_PARAMETER Invalid parameter.
1848 PciFindProtocolInterface (
1849 IN EFI_HANDLE
*HandleBuf
,
1850 IN UINTN HandleCount
,
1853 OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
**IoDev
1857 This function gets the protocol interface from the given handle, and
1858 obtains its address space descriptors.
1860 @param[in] Handle The PCI_ROOT_BRIDIGE_IO_PROTOCOL handle.
1861 @param[out] IoDev Handle used to access configuration space of PCI device.
1862 @param[out] Descriptors Points to the address space descriptors.
1864 @retval EFI_SUCCESS The command completed successfully
1867 PciGetProtocolAndResource (
1868 IN EFI_HANDLE Handle
,
1869 OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
**IoDev
,
1870 OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
**Descriptors
1874 This function get the next bus range of given address space descriptors.
1875 It also moves the pointer backward a node, to get prepared to be called
1878 @param[in, out] Descriptors Points to current position of a serial of address space
1880 @param[out] MinBus The lower range of bus number.
1881 @param[out] MaxBus The upper range of bus number.
1882 @param[out] IsEnd Meet end of the serial of descriptors.
1884 @retval EFI_SUCCESS The command completed successfully.
1887 PciGetNextBusRange (
1888 IN OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
**Descriptors
,
1895 Explain the data in PCI configuration space. The part which is common for
1896 PCI device and bridge is interpreted in this function. It calls other
1897 functions to interpret data unique for device or bridge.
1899 @param[in] ConfigSpace Data in PCI configuration space.
1900 @param[in] Address Address used to access configuration space of this PCI device.
1901 @param[in] IoDev Handle used to access configuration space of PCI device.
1905 IN PCI_CONFIG_SPACE
*ConfigSpace
,
1907 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
1911 Explain the device specific part of data in PCI configuration space.
1913 @param[in] Device Data in PCI configuration space.
1914 @param[in] Address Address used to access configuration space of this PCI device.
1915 @param[in] IoDev Handle used to access configuration space of PCI device.
1917 @retval EFI_SUCCESS The command completed successfully.
1920 PciExplainDeviceData (
1921 IN PCI_DEVICE_HEADER_TYPE_REGION
*Device
,
1923 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
1927 Explain the bridge specific part of data in PCI configuration space.
1929 @param[in] Bridge Bridge specific data region in PCI configuration space.
1930 @param[in] Address Address used to access configuration space of this PCI device.
1931 @param[in] IoDev Handle used to access configuration space of PCI device.
1933 @retval EFI_SUCCESS The command completed successfully.
1936 PciExplainBridgeData (
1937 IN PCI_BRIDGE_CONTROL_REGISTER
*Bridge
,
1939 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
1943 Explain the Base Address Register(Bar) in PCI configuration space.
1945 @param[in] Bar Points to the Base Address Register intended to interpret.
1946 @param[in] Command Points to the register Command.
1947 @param[in] Address Address used to access configuration space of this PCI device.
1948 @param[in] IoDev Handle used to access configuration space of PCI device.
1949 @param[in, out] Index The Index.
1951 @retval EFI_SUCCESS The command completed successfully.
1958 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
,
1963 Explain the cardbus specific part of data in PCI configuration space.
1965 @param[in] CardBus CardBus specific region of PCI configuration space.
1966 @param[in] Address Address used to access configuration space of this PCI device.
1967 @param[in] IoDev Handle used to access configuration space of PCI device.
1969 @retval EFI_SUCCESS The command completed successfully.
1972 PciExplainCardBusData (
1973 IN PCI_CARDBUS_CONTROL_REGISTER
*CardBus
,
1975 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
1979 Explain each meaningful bit of register Status. The definition of Status is
1980 slightly different depending on the PCI header type.
1982 @param[in] Status Points to the content of register Status.
1983 @param[in] MainStatus Indicates if this register is main status(not secondary
1985 @param[in] HeaderType Header type of this PCI device.
1987 @retval EFI_SUCCESS The command completed successfully.
1992 IN BOOLEAN MainStatus
,
1993 IN PCI_HEADER_TYPE HeaderType
1997 Explain each meaningful bit of register Command.
1999 @param[in] Command Points to the content of register Command.
2001 @retval EFI_SUCCESS The command completed successfully.
2009 Explain each meaningful bit of register Bridge Control.
2011 @param[in] BridgeControl Points to the content of register Bridge Control.
2012 @param[in] HeaderType The headertype.
2014 @retval EFI_SUCCESS The command completed successfully.
2017 PciExplainBridgeControl (
2018 IN UINT16
*BridgeControl
,
2019 IN PCI_HEADER_TYPE HeaderType
2023 Locate capability register block per capability ID.
2025 @param[in] ConfigSpace Data in PCI configuration space.
2026 @param[in] CapabilityId The capability ID.
2028 @return The offset of the register block per capability ID.
2031 LocatePciCapability (
2032 IN PCI_CONFIG_SPACE
*ConfigSpace
,
2033 IN UINT8 CapabilityId
2037 Display Pcie device structure.
2039 @param[in] PciExpressCap PCI Express capability buffer.
2040 @param[in] ExtendedConfigSpace PCI Express extended configuration space.
2041 @param[in] ExtendedCapability PCI Express extended capability ID to explain.
2044 PciExplainPciExpress (
2045 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
,
2046 IN UINT8
*ExtendedConfigSpace
,
2047 IN CONST UINT16 ExtendedCapability
2051 Print out information of the capability information.
2053 @param[in] PciExpressCap The pointer to the structure about the device.
2055 @retval EFI_SUCCESS The operation was successful.
2059 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2063 Print out information of the device capability information.
2065 @param[in] PciExpressCap The pointer to the structure about the device.
2067 @retval EFI_SUCCESS The operation was successful.
2070 ExplainPcieDeviceCap (
2071 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2075 Print out information of the device control information.
2077 @param[in] PciExpressCap The pointer to the structure about the device.
2079 @retval EFI_SUCCESS The operation was successful.
2082 ExplainPcieDeviceControl (
2083 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2087 Print out information of the device status information.
2089 @param[in] PciExpressCap The pointer to the structure about the device.
2091 @retval EFI_SUCCESS The operation was successful.
2094 ExplainPcieDeviceStatus (
2095 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2099 Print out information of the device link information.
2101 @param[in] PciExpressCap The pointer to the structure about the device.
2103 @retval EFI_SUCCESS The operation was successful.
2106 ExplainPcieLinkCap (
2107 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2111 Print out information of the device link control information.
2113 @param[in] PciExpressCap The pointer to the structure about the device.
2115 @retval EFI_SUCCESS The operation was successful.
2118 ExplainPcieLinkControl (
2119 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2123 Print out information of the device link status information.
2125 @param[in] PciExpressCap The pointer to the structure about the device.
2127 @retval EFI_SUCCESS The operation was successful.
2130 ExplainPcieLinkStatus (
2131 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2135 Print out information of the device slot information.
2137 @param[in] PciExpressCap The pointer to the structure about the device.
2139 @retval EFI_SUCCESS The operation was successful.
2142 ExplainPcieSlotCap (
2143 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2147 Print out information of the device slot control information.
2149 @param[in] PciExpressCap The pointer to the structure about the device.
2151 @retval EFI_SUCCESS The operation was successful.
2154 ExplainPcieSlotControl (
2155 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2159 Print out information of the device slot status information.
2161 @param[in] PciExpressCap The pointer to the structure about the device.
2163 @retval EFI_SUCCESS The operation was successful.
2166 ExplainPcieSlotStatus (
2167 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2171 Print out information of the device root information.
2173 @param[in] PciExpressCap The pointer to the structure about the device.
2175 @retval EFI_SUCCESS The operation was successful.
2178 ExplainPcieRootControl (
2179 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2183 Print out information of the device root capability information.
2185 @param[in] PciExpressCap The pointer to the structure about the device.
2187 @retval EFI_SUCCESS The operation was successful.
2190 ExplainPcieRootCap (
2191 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2195 Print out information of the device root status information.
2197 @param[in] PciExpressCap The pointer to the structure about the device.
2199 @retval EFI_SUCCESS The operation was successful.
2202 ExplainPcieRootStatus (
2203 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2206 typedef EFI_STATUS (*PCIE_EXPLAIN_FUNCTION
) (IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
);
2212 } PCIE_CAPREG_FIELD_WIDTH
;
2215 PcieExplainTypeCommon
,
2216 PcieExplainTypeDevice
,
2217 PcieExplainTypeLink
,
2218 PcieExplainTypeSlot
,
2219 PcieExplainTypeRoot
,
2221 } PCIE_EXPLAIN_TYPE
;
2227 PCIE_CAPREG_FIELD_WIDTH Width
;
2228 PCIE_EXPLAIN_FUNCTION Func
;
2229 PCIE_EXPLAIN_TYPE Type
;
2230 } PCIE_EXPLAIN_STRUCT
;
2232 PCIE_EXPLAIN_STRUCT PcieExplainList
[] = {
2234 STRING_TOKEN (STR_PCIEX_CAPABILITY_CAPID
),
2238 PcieExplainTypeCommon
2241 STRING_TOKEN (STR_PCIEX_NEXTCAP_PTR
),
2245 PcieExplainTypeCommon
2248 STRING_TOKEN (STR_PCIEX_CAP_REGISTER
),
2252 PcieExplainTypeCommon
2255 STRING_TOKEN (STR_PCIEX_DEVICE_CAP
),
2258 ExplainPcieDeviceCap
,
2259 PcieExplainTypeDevice
2262 STRING_TOKEN (STR_PCIEX_DEVICE_CONTROL
),
2265 ExplainPcieDeviceControl
,
2266 PcieExplainTypeDevice
2269 STRING_TOKEN (STR_PCIEX_DEVICE_STATUS
),
2272 ExplainPcieDeviceStatus
,
2273 PcieExplainTypeDevice
2276 STRING_TOKEN (STR_PCIEX_LINK_CAPABILITIES
),
2283 STRING_TOKEN (STR_PCIEX_LINK_CONTROL
),
2286 ExplainPcieLinkControl
,
2290 STRING_TOKEN (STR_PCIEX_LINK_STATUS
),
2293 ExplainPcieLinkStatus
,
2297 STRING_TOKEN (STR_PCIEX_SLOT_CAPABILITIES
),
2304 STRING_TOKEN (STR_PCIEX_SLOT_CONTROL
),
2307 ExplainPcieSlotControl
,
2311 STRING_TOKEN (STR_PCIEX_SLOT_STATUS
),
2314 ExplainPcieSlotStatus
,
2318 STRING_TOKEN (STR_PCIEX_ROOT_CONTROL
),
2321 ExplainPcieRootControl
,
2325 STRING_TOKEN (STR_PCIEX_RSVDP
),
2332 STRING_TOKEN (STR_PCIEX_ROOT_STATUS
),
2335 ExplainPcieRootStatus
,
2341 (PCIE_CAPREG_FIELD_WIDTH
)0,
2350 PCI_CONFIG_SPACE
*mConfigSpace
= NULL
;
2351 STATIC CONST SHELL_PARAM_ITEM ParamList
[] = {
2354 {L
"-ec", TypeValue
},
2358 CHAR16
*DevicePortTypeTable
[] = {
2359 L
"PCI Express Endpoint",
2360 L
"Legacy PCI Express Endpoint",
2363 L
"Root Port of PCI Express Root Complex",
2364 L
"Upstream Port of PCI Express Switch",
2365 L
"Downstream Port of PCI Express Switch",
2366 L
"PCI Express to PCI/PCI-X Bridge",
2367 L
"PCI/PCI-X to PCI Express Bridge",
2368 L
"Root Complex Integrated Endpoint",
2369 L
"Root Complex Event Collector"
2372 CHAR16
*L0sLatencyStrTable
[] = {
2374 L
"64ns to less than 128ns",
2375 L
"128ns to less than 256ns",
2376 L
"256ns to less than 512ns",
2377 L
"512ns to less than 1us",
2378 L
"1us to less than 2us",
2383 CHAR16
*L1LatencyStrTable
[] = {
2385 L
"1us to less than 2us",
2386 L
"2us to less than 4us",
2387 L
"4us to less than 8us",
2388 L
"8us to less than 16us",
2389 L
"16us to less than 32us",
2394 CHAR16
*ASPMCtrlStrTable
[] = {
2396 L
"L0s Entry Enabled",
2397 L
"L1 Entry Enabled",
2398 L
"L0s and L1 Entry Enabled"
2401 CHAR16
*SlotPwrLmtScaleTable
[] = {
2408 CHAR16
*IndicatorTable
[] = {
2417 Function for 'pci' command.
2419 @param[in] ImageHandle Handle to the Image (NULL if Internal).
2420 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
2424 ShellCommandRunPci (
2425 IN EFI_HANDLE ImageHandle
,
2426 IN EFI_SYSTEM_TABLE
*SystemTable
2434 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
;
2436 PCI_DEVICE_INDEPENDENT_REGION PciHeader
;
2437 PCI_CONFIG_SPACE ConfigSpace
;
2441 BOOLEAN ExplainData
;
2445 UINTN HandleBufSize
;
2446 EFI_HANDLE
*HandleBuf
;
2448 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*Descriptors
;
2452 LIST_ENTRY
*Package
;
2453 CHAR16
*ProblemParam
;
2454 SHELL_STATUS ShellStatus
;
2457 UINT16 ExtendedCapability
;
2458 UINT8 PcieCapabilityPtr
;
2459 UINT8
*ExtendedConfigSpace
;
2460 UINTN ExtendedConfigSize
;
2462 ShellStatus
= SHELL_SUCCESS
;
2463 Status
= EFI_SUCCESS
;
2470 // initialize the shell lib (we must be in non-auto-init...)
2472 Status
= ShellInitialize();
2473 ASSERT_EFI_ERROR(Status
);
2475 Status
= CommandInit();
2476 ASSERT_EFI_ERROR(Status
);
2479 // parse the command line
2481 Status
= ShellCommandLineParse (ParamList
, &Package
, &ProblemParam
, TRUE
);
2482 if (EFI_ERROR(Status
)) {
2483 if (Status
== EFI_VOLUME_CORRUPTED
&& ProblemParam
!= NULL
) {
2484 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellDebug1HiiHandle
, L
"pci", ProblemParam
);
2485 FreePool(ProblemParam
);
2486 ShellStatus
= SHELL_INVALID_PARAMETER
;
2492 if (ShellCommandLineGetCount(Package
) == 2) {
2493 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_FEW
), gShellDebug1HiiHandle
, L
"pci");
2494 ShellStatus
= SHELL_INVALID_PARAMETER
;
2498 if (ShellCommandLineGetCount(Package
) > 4) {
2499 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_MANY
), gShellDebug1HiiHandle
, L
"pci");
2500 ShellStatus
= SHELL_INVALID_PARAMETER
;
2503 if (ShellCommandLineGetFlag(Package
, L
"-ec") && ShellCommandLineGetValue(Package
, L
"-ec") == NULL
) {
2504 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_NO_VALUE
), gShellDebug1HiiHandle
, L
"pci", L
"-ec");
2505 ShellStatus
= SHELL_INVALID_PARAMETER
;
2508 if (ShellCommandLineGetFlag(Package
, L
"-s") && ShellCommandLineGetValue(Package
, L
"-s") == NULL
) {
2509 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_NO_VALUE
), gShellDebug1HiiHandle
, L
"pci", L
"-s");
2510 ShellStatus
= SHELL_INVALID_PARAMETER
;
2514 // Get all instances of PciRootBridgeIo. Allocate space for 1 EFI_HANDLE and
2515 // call LibLocateHandle(), if EFI_BUFFER_TOO_SMALL is returned, allocate enough
2516 // space for handles and call it again.
2518 HandleBufSize
= sizeof (EFI_HANDLE
);
2519 HandleBuf
= (EFI_HANDLE
*) AllocateZeroPool (HandleBufSize
);
2520 if (HandleBuf
== NULL
) {
2521 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_OUT_MEM
), gShellDebug1HiiHandle
, L
"pci");
2522 ShellStatus
= SHELL_OUT_OF_RESOURCES
;
2526 Status
= gBS
->LocateHandle (
2528 &gEfiPciRootBridgeIoProtocolGuid
,
2534 if (Status
== EFI_BUFFER_TOO_SMALL
) {
2535 HandleBuf
= ReallocatePool (sizeof (EFI_HANDLE
), HandleBufSize
, HandleBuf
);
2536 if (HandleBuf
== NULL
) {
2537 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_OUT_MEM
), gShellDebug1HiiHandle
, L
"pci");
2538 ShellStatus
= SHELL_OUT_OF_RESOURCES
;
2542 Status
= gBS
->LocateHandle (
2544 &gEfiPciRootBridgeIoProtocolGuid
,
2551 if (EFI_ERROR (Status
)) {
2552 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PCIRBIO_NF
), gShellDebug1HiiHandle
, L
"pci");
2553 ShellStatus
= SHELL_NOT_FOUND
;
2557 HandleCount
= HandleBufSize
/ sizeof (EFI_HANDLE
);
2559 // Argument Count == 1(no other argument): enumerate all pci functions
2561 if (ShellCommandLineGetCount(Package
) == 1) {
2562 gST
->ConOut
->QueryMode (
2564 gST
->ConOut
->Mode
->Mode
,
2571 if ((ScreenSize
& 1) == 1) {
2578 // For each handle, which decides a segment and a bus number range,
2579 // enumerate all devices on it.
2581 for (Index
= 0; Index
< HandleCount
; Index
++) {
2582 Status
= PciGetProtocolAndResource (
2587 if (EFI_ERROR (Status
)) {
2588 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_HANDLE_CFG_ERR
), gShellDebug1HiiHandle
, L
"pci");
2589 ShellStatus
= SHELL_NOT_FOUND
;
2593 // No document say it's impossible for a RootBridgeIo protocol handle
2594 // to have more than one address space descriptors, so find out every
2595 // bus range and for each of them do device enumeration.
2598 Status
= PciGetNextBusRange (&Descriptors
, &MinBus
, &MaxBus
, &IsEnd
);
2600 if (EFI_ERROR (Status
)) {
2601 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_BUS_RANGE_ERR
), gShellDebug1HiiHandle
, L
"pci");
2602 ShellStatus
= SHELL_NOT_FOUND
;
2610 for (Bus
= MinBus
; Bus
<= MaxBus
; Bus
++) {
2612 // For each devices, enumerate all functions it contains
2614 for (Device
= 0; Device
<= PCI_MAX_DEVICE
; Device
++) {
2616 // For each function, read its configuration space and print summary
2618 for (Func
= 0; Func
<= PCI_MAX_FUNC
; Func
++) {
2619 if (ShellGetExecutionBreakFlag ()) {
2620 ShellStatus
= SHELL_ABORTED
;
2623 Address
= EFI_PCI_ADDRESS (Bus
, Device
, Func
, 0);
2633 // If VendorId = 0xffff, there does not exist a device at this
2634 // location. For each device, if there is any function on it,
2635 // there must be 1 function at Function 0. So if Func = 0, there
2636 // will be no more functions in the same device, so we can break
2637 // loop to deal with the next device.
2639 if (PciHeader
.VendorId
== 0xffff && Func
== 0) {
2643 if (PciHeader
.VendorId
!= 0xffff) {
2646 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_TITLE
), gShellDebug1HiiHandle
);
2654 sizeof (PciHeader
) / sizeof (UINT32
),
2659 -1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_P1
), gShellDebug1HiiHandle
,
2660 IoDev
->SegmentNumber
,
2666 PciPrintClassCode (PciHeader
.ClassCode
, FALSE
);
2668 -1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_P2
), gShellDebug1HiiHandle
,
2671 PciHeader
.ClassCode
[0]
2675 if (ScreenCount
>= ScreenSize
&& ScreenSize
!= 0) {
2677 // If ScreenSize == 0 we have the console redirected so don't
2683 // If this is not a multi-function device, we can leave the loop
2684 // to deal with the next device.
2686 if (Func
== 0 && ((PciHeader
.HeaderType
& HEADER_TYPE_MULTI_FUNCTION
) == 0x00)) {
2694 // If Descriptor is NULL, Configuration() returns EFI_UNSUPPRORED,
2695 // we assume the bus range is 0~PCI_MAX_BUS. After enumerated all
2696 // devices on all bus, we can leave loop.
2698 if (Descriptors
== NULL
) {
2704 Status
= EFI_SUCCESS
;
2708 ExplainData
= FALSE
;
2713 ExtendedCapability
= 0xFFFF;
2714 if (ShellCommandLineGetFlag(Package
, L
"-i")) {
2718 Temp
= ShellCommandLineGetValue(Package
, L
"-s");
2721 // Input converted to hexadecimal number.
2723 if (!EFI_ERROR (ShellConvertStringToUint64 (Temp
, &RetVal
, TRUE
, TRUE
))) {
2724 Segment
= (UINT16
) RetVal
;
2726 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV_HEX
), gShellDebug1HiiHandle
, L
"pci", Temp
);
2727 ShellStatus
= SHELL_INVALID_PARAMETER
;
2733 // The first Argument(except "-i") is assumed to be Bus number, second
2734 // to be Device number, and third to be Func number.
2736 Temp
= ShellCommandLineGetRawValue(Package
, 1);
2739 // Input converted to hexadecimal number.
2741 if (!EFI_ERROR (ShellConvertStringToUint64 (Temp
, &RetVal
, TRUE
, TRUE
))) {
2742 Bus
= (UINT16
) RetVal
;
2744 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV_HEX
), gShellDebug1HiiHandle
, L
"pci", Temp
);
2745 ShellStatus
= SHELL_INVALID_PARAMETER
;
2749 if (Bus
> PCI_MAX_BUS
) {
2750 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV
), gShellDebug1HiiHandle
, L
"pci", Temp
);
2751 ShellStatus
= SHELL_INVALID_PARAMETER
;
2755 Temp
= ShellCommandLineGetRawValue(Package
, 2);
2758 // Input converted to hexadecimal number.
2760 if (!EFI_ERROR (ShellConvertStringToUint64 (Temp
, &RetVal
, TRUE
, TRUE
))) {
2761 Device
= (UINT16
) RetVal
;
2763 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV_HEX
), gShellDebug1HiiHandle
, L
"pci", Temp
);
2764 ShellStatus
= SHELL_INVALID_PARAMETER
;
2768 if (Device
> PCI_MAX_DEVICE
){
2769 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV
), gShellDebug1HiiHandle
, L
"pci", Temp
);
2770 ShellStatus
= SHELL_INVALID_PARAMETER
;
2775 Temp
= ShellCommandLineGetRawValue(Package
, 3);
2778 // Input converted to hexadecimal number.
2780 if (!EFI_ERROR (ShellConvertStringToUint64 (Temp
, &RetVal
, TRUE
, TRUE
))) {
2781 Func
= (UINT16
) RetVal
;
2783 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV_HEX
), gShellDebug1HiiHandle
, L
"pci", Temp
);
2784 ShellStatus
= SHELL_INVALID_PARAMETER
;
2788 if (Func
> PCI_MAX_FUNC
){
2789 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV
), gShellDebug1HiiHandle
, L
"pci", Temp
);
2790 ShellStatus
= SHELL_INVALID_PARAMETER
;
2795 Temp
= ShellCommandLineGetValue (Package
, L
"-ec");
2798 // Input converted to hexadecimal number.
2800 if (!EFI_ERROR (ShellConvertStringToUint64 (Temp
, &RetVal
, TRUE
, TRUE
))) {
2801 ExtendedCapability
= (UINT16
) RetVal
;
2803 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV_HEX
), gShellDebug1HiiHandle
, L
"pci", Temp
);
2804 ShellStatus
= SHELL_INVALID_PARAMETER
;
2810 // Find the protocol interface who's in charge of current segment, and its
2811 // bus range covers the current bus
2813 Status
= PciFindProtocolInterface (
2821 if (EFI_ERROR (Status
)) {
2823 -1, -1, NULL
, STRING_TOKEN (STR_PCI_NO_FIND
), gShellDebug1HiiHandle
, L
"pci",
2827 ShellStatus
= SHELL_NOT_FOUND
;
2831 Address
= EFI_PCI_ADDRESS (Bus
, Device
, Func
, 0);
2832 Status
= IoDev
->Pci
.Read (
2836 sizeof (ConfigSpace
),
2840 if (EFI_ERROR (Status
)) {
2841 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_NO_CFG
), gShellDebug1HiiHandle
, L
"pci");
2842 ShellStatus
= SHELL_ACCESS_DENIED
;
2846 mConfigSpace
= &ConfigSpace
;
2851 STRING_TOKEN (STR_PCI_INFO
),
2852 gShellDebug1HiiHandle
,
2864 // Dump standard header of configuration space
2866 SizeOfHeader
= sizeof (ConfigSpace
.Common
) + sizeof (ConfigSpace
.NonCommon
);
2868 DumpHex (2, 0, SizeOfHeader
, &ConfigSpace
);
2869 ShellPrintEx(-1,-1, L
"\r\n");
2872 // Dump device dependent Part of configuration space
2877 sizeof (ConfigSpace
) - SizeOfHeader
,
2881 ExtendedConfigSpace
= NULL
;
2882 ExtendedConfigSize
= 0;
2883 PcieCapabilityPtr
= LocatePciCapability (&ConfigSpace
, EFI_PCI_CAPABILITY_ID_PCIEXP
);
2884 if (PcieCapabilityPtr
!= 0) {
2885 ExtendedConfigSize
= 0x1000 - EFI_PCIE_CAPABILITY_BASE_OFFSET
;
2886 ExtendedConfigSpace
= AllocatePool (ExtendedConfigSize
);
2887 if (ExtendedConfigSpace
!= NULL
) {
2888 Status
= IoDev
->Pci
.Read (
2891 EFI_PCI_ADDRESS (Bus
, Device
, Func
, EFI_PCIE_CAPABILITY_BASE_OFFSET
),
2892 ExtendedConfigSize
/ sizeof (UINT32
),
2895 if (EFI_ERROR (Status
)) {
2896 SHELL_FREE_NON_NULL (ExtendedConfigSpace
);
2901 if ((ExtendedConfigSpace
!= NULL
) && !ShellGetExecutionBreakFlag ()) {
2903 // Print the PciEx extend space in raw bytes ( 0xFF-0xFFF)
2905 ShellPrintEx (-1, -1, L
"\r\n%HStart dumping PCIex extended configuration space (0x100 - 0xFFF).%N\r\n\r\n");
2909 EFI_PCIE_CAPABILITY_BASE_OFFSET
,
2916 // If "-i" appears in command line, interpret data in configuration space
2919 PciExplainPci (&ConfigSpace
, Address
, IoDev
);
2920 if ((ExtendedConfigSpace
!= NULL
) && !ShellGetExecutionBreakFlag ()) {
2921 PciExplainPciExpress (
2922 (PCI_CAPABILITY_PCIEXP
*) ((UINT8
*) &ConfigSpace
+ PcieCapabilityPtr
),
2923 ExtendedConfigSpace
,
2930 if (HandleBuf
!= NULL
) {
2931 FreePool (HandleBuf
);
2933 if (Package
!= NULL
) {
2934 ShellCommandLineFreeVarList (Package
);
2936 mConfigSpace
= NULL
;
2941 This function finds out the protocol which is in charge of the given
2942 segment, and its bus range covers the current bus number. It lookes
2943 each instances of RootBridgeIoProtocol handle, until the one meets the
2946 @param[in] HandleBuf Buffer which holds all PCI_ROOT_BRIDIGE_IO_PROTOCOL handles.
2947 @param[in] HandleCount Count of all PCI_ROOT_BRIDIGE_IO_PROTOCOL handles.
2948 @param[in] Segment Segment number of device we are dealing with.
2949 @param[in] Bus Bus number of device we are dealing with.
2950 @param[out] IoDev Handle used to access configuration space of PCI device.
2952 @retval EFI_SUCCESS The command completed successfully.
2953 @retval EFI_INVALID_PARAMETER Invalid parameter.
2957 PciFindProtocolInterface (
2958 IN EFI_HANDLE
*HandleBuf
,
2959 IN UINTN HandleCount
,
2962 OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
**IoDev
2967 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*Descriptors
;
2973 // Go through all handles, until the one meets the criteria is found
2975 for (Index
= 0; Index
< HandleCount
; Index
++) {
2976 Status
= PciGetProtocolAndResource (HandleBuf
[Index
], IoDev
, &Descriptors
);
2977 if (EFI_ERROR (Status
)) {
2981 // When Descriptors == NULL, the Configuration() is not implemented,
2982 // so we only check the Segment number
2984 if (Descriptors
== NULL
&& Segment
== (*IoDev
)->SegmentNumber
) {
2988 if ((*IoDev
)->SegmentNumber
!= Segment
) {
2993 Status
= PciGetNextBusRange (&Descriptors
, &MinBus
, &MaxBus
, &IsEnd
);
2994 if (EFI_ERROR (Status
)) {
3002 if (MinBus
<= Bus
&& MaxBus
>= Bus
) {
3008 return EFI_NOT_FOUND
;
3012 This function gets the protocol interface from the given handle, and
3013 obtains its address space descriptors.
3015 @param[in] Handle The PCI_ROOT_BRIDIGE_IO_PROTOCOL handle.
3016 @param[out] IoDev Handle used to access configuration space of PCI device.
3017 @param[out] Descriptors Points to the address space descriptors.
3019 @retval EFI_SUCCESS The command completed successfully
3022 PciGetProtocolAndResource (
3023 IN EFI_HANDLE Handle
,
3024 OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
**IoDev
,
3025 OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
**Descriptors
3031 // Get inferface from protocol
3033 Status
= gBS
->HandleProtocol (
3035 &gEfiPciRootBridgeIoProtocolGuid
,
3039 if (EFI_ERROR (Status
)) {
3043 // Call Configuration() to get address space descriptors
3045 Status
= (*IoDev
)->Configuration (*IoDev
, (VOID
**)Descriptors
);
3046 if (Status
== EFI_UNSUPPORTED
) {
3047 *Descriptors
= NULL
;
3056 This function get the next bus range of given address space descriptors.
3057 It also moves the pointer backward a node, to get prepared to be called
3060 @param[in, out] Descriptors Points to current position of a serial of address space
3062 @param[out] MinBus The lower range of bus number.
3063 @param[out] MaxBus The upper range of bus number.
3064 @param[out] IsEnd Meet end of the serial of descriptors.
3066 @retval EFI_SUCCESS The command completed successfully.
3069 PciGetNextBusRange (
3070 IN OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
**Descriptors
,
3079 // When *Descriptors is NULL, Configuration() is not implemented, so assume
3080 // range is 0~PCI_MAX_BUS
3082 if ((*Descriptors
) == NULL
) {
3084 *MaxBus
= PCI_MAX_BUS
;
3088 // *Descriptors points to one or more address space descriptors, which
3089 // ends with a end tagged descriptor. Examine each of the descriptors,
3090 // if a bus typed one is found and its bus range covers bus, this handle
3091 // is the handle we are looking for.
3094 while ((*Descriptors
)->Desc
!= ACPI_END_TAG_DESCRIPTOR
) {
3095 if ((*Descriptors
)->ResType
== ACPI_ADDRESS_SPACE_TYPE_BUS
) {
3096 *MinBus
= (UINT16
) (*Descriptors
)->AddrRangeMin
;
3097 *MaxBus
= (UINT16
) (*Descriptors
)->AddrRangeMax
;
3099 return (EFI_SUCCESS
);
3105 if ((*Descriptors
)->Desc
== ACPI_END_TAG_DESCRIPTOR
) {
3113 Explain the data in PCI configuration space. The part which is common for
3114 PCI device and bridge is interpreted in this function. It calls other
3115 functions to interpret data unique for device or bridge.
3117 @param[in] ConfigSpace Data in PCI configuration space.
3118 @param[in] Address Address used to access configuration space of this PCI device.
3119 @param[in] IoDev Handle used to access configuration space of PCI device.
3123 IN PCI_CONFIG_SPACE
*ConfigSpace
,
3125 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
3128 PCI_DEVICE_INDEPENDENT_REGION
*Common
;
3129 PCI_HEADER_TYPE HeaderType
;
3131 Common
= &(ConfigSpace
->Common
);
3133 ShellPrintEx (-1, -1, L
"\r\n");
3136 // Print Vendor Id and Device Id
3138 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_VID_DID
), gShellDebug1HiiHandle
,
3139 INDEX_OF (&(Common
->VendorId
)),
3141 INDEX_OF (&(Common
->DeviceId
)),
3146 // Print register Command
3148 PciExplainCommand (&(Common
->Command
));
3151 // Print register Status
3153 PciExplainStatus (&(Common
->Status
), TRUE
, PciUndefined
);
3156 // Print register Revision ID
3158 ShellPrintEx(-1, -1, L
"\r\n");
3159 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_RID
), gShellDebug1HiiHandle
,
3160 INDEX_OF (&(Common
->RevisionID
)),
3165 // Print register BIST
3167 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_BIST
), gShellDebug1HiiHandle
, INDEX_OF (&(Common
->BIST
)));
3168 if ((Common
->BIST
& BIT7
) != 0) {
3169 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_CAP
), gShellDebug1HiiHandle
, 0x0f & Common
->BIST
);
3171 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_CAP_NO
), gShellDebug1HiiHandle
);
3174 // Print register Cache Line Size
3176 ShellPrintHiiEx(-1, -1, NULL
,
3177 STRING_TOKEN (STR_PCI2_CACHE_LINE_SIZE
),
3178 gShellDebug1HiiHandle
,
3179 INDEX_OF (&(Common
->CacheLineSize
)),
3180 Common
->CacheLineSize
3184 // Print register Latency Timer
3186 ShellPrintHiiEx(-1, -1, NULL
,
3187 STRING_TOKEN (STR_PCI2_LATENCY_TIMER
),
3188 gShellDebug1HiiHandle
,
3189 INDEX_OF (&(Common
->LatencyTimer
)),
3190 Common
->LatencyTimer
3194 // Print register Header Type
3196 ShellPrintHiiEx(-1, -1, NULL
,
3197 STRING_TOKEN (STR_PCI2_HEADER_TYPE
),
3198 gShellDebug1HiiHandle
,
3199 INDEX_OF (&(Common
->HeaderType
)),
3203 if ((Common
->HeaderType
& BIT7
) != 0) {
3204 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MULTI_FUNCTION
), gShellDebug1HiiHandle
);
3207 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_SINGLE_FUNCTION
), gShellDebug1HiiHandle
);
3210 HeaderType
= (PCI_HEADER_TYPE
)(UINT8
) (Common
->HeaderType
& 0x7f);
3211 switch (HeaderType
) {
3213 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_PCI_DEVICE
), gShellDebug1HiiHandle
);
3217 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_P2P_BRIDGE
), gShellDebug1HiiHandle
);
3220 case PciCardBusBridge
:
3221 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_CARDBUS_BRIDGE
), gShellDebug1HiiHandle
);
3225 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RESERVED
), gShellDebug1HiiHandle
);
3226 HeaderType
= PciUndefined
;
3230 // Print register Class Code
3232 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_CLASS
), gShellDebug1HiiHandle
);
3233 PciPrintClassCode ((UINT8
*) Common
->ClassCode
, TRUE
);
3234 ShellPrintEx (-1, -1, L
"\r\n");
3238 Explain the device specific part of data in PCI configuration space.
3240 @param[in] Device Data in PCI configuration space.
3241 @param[in] Address Address used to access configuration space of this PCI device.
3242 @param[in] IoDev Handle used to access configuration space of PCI device.
3244 @retval EFI_SUCCESS The command completed successfully.
3247 PciExplainDeviceData (
3248 IN PCI_DEVICE_HEADER_TYPE_REGION
*Device
,
3250 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
3259 // Print Base Address Registers(Bar). When Bar = 0, this Bar does not
3260 // exist. If these no Bar for this function, print "none", otherwise
3261 // list detail information about this Bar.
3263 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BASE_ADDR
), gShellDebug1HiiHandle
, INDEX_OF (Device
->Bar
));
3266 BarCount
= sizeof (Device
->Bar
) / sizeof (Device
->Bar
[0]);
3267 for (Index
= 0; Index
< BarCount
; Index
++) {
3268 if (Device
->Bar
[Index
] == 0) {
3274 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_START_TYPE
), gShellDebug1HiiHandle
);
3275 ShellPrintEx (-1, -1, L
" --------------------------------------------------------------------------");
3278 Status
= PciExplainBar (
3279 &(Device
->Bar
[Index
]),
3280 &(mConfigSpace
->Common
.Command
),
3286 if (EFI_ERROR (Status
)) {
3292 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NONE
), gShellDebug1HiiHandle
);
3295 ShellPrintEx (-1, -1, L
"\r\n --------------------------------------------------------------------------");
3299 // Print register Expansion ROM Base Address
3301 if ((Device
->ExpansionRomBar
& BIT0
) == 0) {
3302 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_EXPANSION_ROM_DISABLED
), gShellDebug1HiiHandle
, INDEX_OF (&(Device
->ExpansionRomBar
)));
3305 ShellPrintHiiEx(-1, -1, NULL
,
3306 STRING_TOKEN (STR_PCI2_EXPANSION_ROM_BASE
),
3307 gShellDebug1HiiHandle
,
3308 INDEX_OF (&(Device
->ExpansionRomBar
)),
3309 Device
->ExpansionRomBar
3313 // Print register Cardbus CIS ptr
3315 ShellPrintHiiEx(-1, -1, NULL
,
3316 STRING_TOKEN (STR_PCI2_CARDBUS_CIS
),
3317 gShellDebug1HiiHandle
,
3318 INDEX_OF (&(Device
->CISPtr
)),
3323 // Print register Sub-vendor ID and subsystem ID
3325 ShellPrintHiiEx(-1, -1, NULL
,
3326 STRING_TOKEN (STR_PCI2_SUB_VENDOR_ID
),
3327 gShellDebug1HiiHandle
,
3328 INDEX_OF (&(Device
->SubsystemVendorID
)),
3329 Device
->SubsystemVendorID
3332 ShellPrintHiiEx(-1, -1, NULL
,
3333 STRING_TOKEN (STR_PCI2_SUBSYSTEM_ID
),
3334 gShellDebug1HiiHandle
,
3335 INDEX_OF (&(Device
->SubsystemID
)),
3340 // Print register Capabilities Ptr
3342 ShellPrintHiiEx(-1, -1, NULL
,
3343 STRING_TOKEN (STR_PCI2_CAPABILITIES_PTR
),
3344 gShellDebug1HiiHandle
,
3345 INDEX_OF (&(Device
->CapabilityPtr
)),
3346 Device
->CapabilityPtr
3350 // Print register Interrupt Line and interrupt pin
3352 ShellPrintHiiEx(-1, -1, NULL
,
3353 STRING_TOKEN (STR_PCI2_INTERRUPT_LINE
),
3354 gShellDebug1HiiHandle
,
3355 INDEX_OF (&(Device
->InterruptLine
)),
3356 Device
->InterruptLine
3359 ShellPrintHiiEx(-1, -1, NULL
,
3360 STRING_TOKEN (STR_PCI2_INTERRUPT_PIN
),
3361 gShellDebug1HiiHandle
,
3362 INDEX_OF (&(Device
->InterruptPin
)),
3363 Device
->InterruptPin
3367 // Print register Min_Gnt and Max_Lat
3369 ShellPrintHiiEx(-1, -1, NULL
,
3370 STRING_TOKEN (STR_PCI2_MIN_GNT
),
3371 gShellDebug1HiiHandle
,
3372 INDEX_OF (&(Device
->MinGnt
)),
3376 ShellPrintHiiEx(-1, -1, NULL
,
3377 STRING_TOKEN (STR_PCI2_MAX_LAT
),
3378 gShellDebug1HiiHandle
,
3379 INDEX_OF (&(Device
->MaxLat
)),
3387 Explain the bridge specific part of data in PCI configuration space.
3389 @param[in] Bridge Bridge specific data region in PCI configuration space.
3390 @param[in] Address Address used to access configuration space of this PCI device.
3391 @param[in] IoDev Handle used to access configuration space of PCI device.
3393 @retval EFI_SUCCESS The command completed successfully.
3396 PciExplainBridgeData (
3397 IN PCI_BRIDGE_CONTROL_REGISTER
*Bridge
,
3399 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
3409 // Print Base Address Registers. When Bar = 0, this Bar does not
3410 // exist. If these no Bar for this function, print "none", otherwise
3411 // list detail information about this Bar.
3413 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BASE_ADDRESS
), gShellDebug1HiiHandle
, INDEX_OF (&(Bridge
->Bar
)));
3416 BarCount
= sizeof (Bridge
->Bar
) / sizeof (Bridge
->Bar
[0]);
3418 for (Index
= 0; Index
< BarCount
; Index
++) {
3419 if (Bridge
->Bar
[Index
] == 0) {
3425 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_START_TYPE_2
), gShellDebug1HiiHandle
);
3426 ShellPrintEx (-1, -1, L
" --------------------------------------------------------------------------");
3429 Status
= PciExplainBar (
3430 &(Bridge
->Bar
[Index
]),
3431 &(mConfigSpace
->Common
.Command
),
3437 if (EFI_ERROR (Status
)) {
3443 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NONE
), gShellDebug1HiiHandle
);
3445 ShellPrintEx (-1, -1, L
"\r\n --------------------------------------------------------------------------");
3449 // Expansion register ROM Base Address
3451 if ((Bridge
->ExpansionRomBAR
& BIT0
) == 0) {
3452 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NO_EXPANSION_ROM
), gShellDebug1HiiHandle
, INDEX_OF (&(Bridge
->ExpansionRomBAR
)));
3455 ShellPrintHiiEx(-1, -1, NULL
,
3456 STRING_TOKEN (STR_PCI2_EXPANSION_ROM_BASE_2
),
3457 gShellDebug1HiiHandle
,
3458 INDEX_OF (&(Bridge
->ExpansionRomBAR
)),
3459 Bridge
->ExpansionRomBAR
3463 // Print Bus Numbers(Primary, Secondary, and Subordinate
3465 ShellPrintHiiEx(-1, -1, NULL
,
3466 STRING_TOKEN (STR_PCI2_BUS_NUMBERS
),
3467 gShellDebug1HiiHandle
,
3468 INDEX_OF (&(Bridge
->PrimaryBus
)),
3469 INDEX_OF (&(Bridge
->SecondaryBus
)),
3470 INDEX_OF (&(Bridge
->SubordinateBus
))
3473 ShellPrintEx (-1, -1, L
" ------------------------------------------------------\r\n");
3475 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BRIDGE
), gShellDebug1HiiHandle
, Bridge
->PrimaryBus
);
3476 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BRIDGE
), gShellDebug1HiiHandle
, Bridge
->SecondaryBus
);
3477 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BRIDGE
), gShellDebug1HiiHandle
, Bridge
->SubordinateBus
);
3480 // Print register Secondary Latency Timer
3482 ShellPrintHiiEx(-1, -1, NULL
,
3483 STRING_TOKEN (STR_PCI2_SECONDARY_TIMER
),
3484 gShellDebug1HiiHandle
,
3485 INDEX_OF (&(Bridge
->SecondaryLatencyTimer
)),
3486 Bridge
->SecondaryLatencyTimer
3490 // Print register Secondary Status
3492 PciExplainStatus (&(Bridge
->SecondaryStatus
), FALSE
, PciP2pBridge
);
3495 // Print I/O and memory ranges this bridge forwards. There are 3 resource
3496 // types: I/O, memory, and pre-fetchable memory. For each resource type,
3497 // base and limit address are listed.
3499 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RESOURCE_TYPE
), gShellDebug1HiiHandle
);
3500 ShellPrintEx (-1, -1, L
"----------------------------------------------------------------------\r\n");
3505 IoAddress32
= (Bridge
->IoBaseUpper16
<< 16 | Bridge
->IoBase
<< 8);
3506 IoAddress32
&= 0xfffff000;
3507 ShellPrintHiiEx(-1, -1, NULL
,
3508 STRING_TOKEN (STR_PCI2_TWO_VARS
),
3509 gShellDebug1HiiHandle
,
3510 INDEX_OF (&(Bridge
->IoBase
)),
3514 IoAddress32
= (Bridge
->IoLimitUpper16
<< 16 | Bridge
->IoLimit
<< 8);
3515 IoAddress32
|= 0x00000fff;
3516 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_ONE_VAR
), gShellDebug1HiiHandle
, IoAddress32
);
3519 // Memory Base & Limit
3521 ShellPrintHiiEx(-1, -1, NULL
,
3522 STRING_TOKEN (STR_PCI2_MEMORY
),
3523 gShellDebug1HiiHandle
,
3524 INDEX_OF (&(Bridge
->MemoryBase
)),
3525 (Bridge
->MemoryBase
<< 16) & 0xfff00000
3528 ShellPrintHiiEx(-1, -1, NULL
,
3529 STRING_TOKEN (STR_PCI2_ONE_VAR
),
3530 gShellDebug1HiiHandle
,
3531 (Bridge
->MemoryLimit
<< 16) | 0x000fffff
3535 // Pre-fetch-able Memory Base & Limit
3537 ShellPrintHiiEx(-1, -1, NULL
,
3538 STRING_TOKEN (STR_PCI2_PREFETCHABLE
),
3539 gShellDebug1HiiHandle
,
3540 INDEX_OF (&(Bridge
->PrefetchableMemoryBase
)),
3541 Bridge
->PrefetchableBaseUpper32
,
3542 (Bridge
->PrefetchableMemoryBase
<< 16) & 0xfff00000
3545 ShellPrintHiiEx(-1, -1, NULL
,
3546 STRING_TOKEN (STR_PCI2_TWO_VARS_2
),
3547 gShellDebug1HiiHandle
,
3548 Bridge
->PrefetchableLimitUpper32
,
3549 (Bridge
->PrefetchableMemoryLimit
<< 16) | 0x000fffff
3553 // Print register Capabilities Pointer
3555 ShellPrintHiiEx(-1, -1, NULL
,
3556 STRING_TOKEN (STR_PCI2_CAPABILITIES_PTR_2
),
3557 gShellDebug1HiiHandle
,
3558 INDEX_OF (&(Bridge
->CapabilityPtr
)),
3559 Bridge
->CapabilityPtr
3563 // Print register Bridge Control
3565 PciExplainBridgeControl (&(Bridge
->BridgeControl
), PciP2pBridge
);
3568 // Print register Interrupt Line & PIN
3570 ShellPrintHiiEx(-1, -1, NULL
,
3571 STRING_TOKEN (STR_PCI2_INTERRUPT_LINE_2
),
3572 gShellDebug1HiiHandle
,
3573 INDEX_OF (&(Bridge
->InterruptLine
)),
3574 Bridge
->InterruptLine
3577 ShellPrintHiiEx(-1, -1, NULL
,
3578 STRING_TOKEN (STR_PCI2_INTERRUPT_PIN
),
3579 gShellDebug1HiiHandle
,
3580 INDEX_OF (&(Bridge
->InterruptPin
)),
3581 Bridge
->InterruptPin
3588 Explain the Base Address Register(Bar) in PCI configuration space.
3590 @param[in] Bar Points to the Base Address Register intended to interpret.
3591 @param[in] Command Points to the register Command.
3592 @param[in] Address Address used to access configuration space of this PCI device.
3593 @param[in] IoDev Handle used to access configuration space of PCI device.
3594 @param[in, out] Index The Index.
3596 @retval EFI_SUCCESS The command completed successfully.
3603 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
,
3624 // According the bar type, list detail about this bar, for example: 32 or
3625 // 64 bits; pre-fetchable or not.
3627 if ((*Bar
& BIT0
) == 0) {
3629 // This bar is of memory type
3633 if ((*Bar
& BIT1
) == 0 && (*Bar
& BIT2
) == 0) {
3634 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BAR
), gShellDebug1HiiHandle
, *Bar
& 0xfffffff0);
3635 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MEM
), gShellDebug1HiiHandle
);
3636 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_32_BITS
), gShellDebug1HiiHandle
);
3638 } else if ((*Bar
& BIT1
) == 0 && (*Bar
& BIT2
) != 0) {
3640 CopyMem (&Bar64
, Bar
, sizeof (UINT64
));
3641 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_ONE_VAR_2
), gShellDebug1HiiHandle
, (UINT32
) RShiftU64 ((Bar64
& 0xfffffffffffffff0ULL
), 32));
3642 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_ONE_VAR_3
), gShellDebug1HiiHandle
, (UINT32
) (Bar64
& 0xfffffffffffffff0ULL
));
3643 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MEM
), gShellDebug1HiiHandle
);
3644 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_64_BITS
), gShellDebug1HiiHandle
);
3652 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BAR
), gShellDebug1HiiHandle
, *Bar
& 0xfffffff0);
3653 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MEM_2
), gShellDebug1HiiHandle
);
3656 if ((*Bar
& BIT3
) == 0) {
3657 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NO
), gShellDebug1HiiHandle
);
3660 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_YES
), gShellDebug1HiiHandle
);
3665 // This bar is of io type
3668 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_ONE_VAR_4
), gShellDebug1HiiHandle
, *Bar
& 0xfffffffc);
3669 ShellPrintEx (-1, -1, L
"I/O ");
3673 // Get BAR length(or the amount of resource this bar demands for). To get
3674 // Bar length, first we should temporarily disable I/O and memory access
3675 // of this function(by set bits in the register Command), then write all
3676 // "1"s to this bar. The bar value read back is the amount of resource
3677 // this bar demands for.
3680 // Disable io & mem access
3682 OldCommand
= *Command
;
3683 NewCommand
= (UINT16
) (OldCommand
& 0xfffc);
3684 RegAddress
= Address
| INDEX_OF (Command
);
3685 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint16
, RegAddress
, 1, &NewCommand
);
3687 RegAddress
= Address
| INDEX_OF (Bar
);
3690 // Read after write the BAR to get the size
3694 NewBar32
= 0xffffffff;
3696 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint32
, RegAddress
, 1, &NewBar32
);
3697 IoDev
->Pci
.Read (IoDev
, EfiPciWidthUint32
, RegAddress
, 1, &NewBar32
);
3698 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint32
, RegAddress
, 1, &OldBar32
);
3701 NewBar32
= NewBar32
& 0xfffffff0;
3702 NewBar32
= (~NewBar32
) + 1;
3705 NewBar32
= NewBar32
& 0xfffffffc;
3706 NewBar32
= (~NewBar32
) + 1;
3707 NewBar32
= NewBar32
& 0x0000ffff;
3712 CopyMem (&OldBar64
, Bar
, sizeof (UINT64
));
3713 NewBar64
= 0xffffffffffffffffULL
;
3715 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint32
, RegAddress
, 2, &NewBar64
);
3716 IoDev
->Pci
.Read (IoDev
, EfiPciWidthUint32
, RegAddress
, 2, &NewBar64
);
3717 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint32
, RegAddress
, 2, &OldBar64
);
3720 NewBar64
= NewBar64
& 0xfffffffffffffff0ULL
;
3721 NewBar64
= (~NewBar64
) + 1;
3724 NewBar64
= NewBar64
& 0xfffffffffffffffcULL
;
3725 NewBar64
= (~NewBar64
) + 1;
3726 NewBar64
= NewBar64
& 0x000000000000ffff;
3730 // Enable io & mem access
3732 RegAddress
= Address
| INDEX_OF (Command
);
3733 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint16
, RegAddress
, 1, &OldCommand
);
3737 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NEWBAR_32
), gShellDebug1HiiHandle
, NewBar32
);
3738 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NEWBAR_32_2
), gShellDebug1HiiHandle
, NewBar32
+ (*Bar
& 0xfffffff0) - 1);
3741 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RSHIFT
), gShellDebug1HiiHandle
, (UINT32
) RShiftU64 (NewBar64
, 32));
3742 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RSHIFT
), gShellDebug1HiiHandle
, (UINT32
) NewBar64
);
3743 ShellPrintEx (-1, -1, L
" ");
3744 ShellPrintHiiEx(-1, -1, NULL
,
3745 STRING_TOKEN (STR_PCI2_RSHIFT
),
3746 gShellDebug1HiiHandle
,
3747 (UINT32
) RShiftU64 ((NewBar64
+ (Bar64
& 0xfffffffffffffff0ULL
) - 1), 32)
3749 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RSHIFT
), gShellDebug1HiiHandle
, (UINT32
) (NewBar64
+ (Bar64
& 0xfffffffffffffff0ULL
) - 1));
3753 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NEWBAR_32_3
), gShellDebug1HiiHandle
, NewBar32
);
3754 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NEWBAR_32_4
), gShellDebug1HiiHandle
, NewBar32
+ (*Bar
& 0xfffffffc) - 1);
3761 Explain the cardbus specific part of data in PCI configuration space.
3763 @param[in] CardBus CardBus specific region of PCI configuration space.
3764 @param[in] Address Address used to access configuration space of this PCI device.
3765 @param[in] IoDev Handle used to access configuration space of PCI device.
3767 @retval EFI_SUCCESS The command completed successfully.
3770 PciExplainCardBusData (
3771 IN PCI_CARDBUS_CONTROL_REGISTER
*CardBus
,
3773 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
3777 PCI_CARDBUS_DATA
*CardBusData
;
3779 ShellPrintHiiEx(-1, -1, NULL
,
3780 STRING_TOKEN (STR_PCI2_CARDBUS_SOCKET
),
3781 gShellDebug1HiiHandle
,
3782 INDEX_OF (&(CardBus
->CardBusSocketReg
)),
3783 CardBus
->CardBusSocketReg
3787 // Print Secondary Status
3789 PciExplainStatus (&(CardBus
->SecondaryStatus
), FALSE
, PciCardBusBridge
);
3792 // Print Bus Numbers(Primary bus number, CardBus bus number, and
3793 // Subordinate bus number
3795 ShellPrintHiiEx(-1, -1, NULL
,
3796 STRING_TOKEN (STR_PCI2_BUS_NUMBERS_2
),
3797 gShellDebug1HiiHandle
,
3798 INDEX_OF (&(CardBus
->PciBusNumber
)),
3799 INDEX_OF (&(CardBus
->CardBusBusNumber
)),
3800 INDEX_OF (&(CardBus
->SubordinateBusNumber
))
3803 ShellPrintEx (-1, -1, L
" ------------------------------------------------------\r\n");
3805 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_CARDBUS
), gShellDebug1HiiHandle
, CardBus
->PciBusNumber
);
3806 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_CARDBUS_2
), gShellDebug1HiiHandle
, CardBus
->CardBusBusNumber
);
3807 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_CARDBUS_3
), gShellDebug1HiiHandle
, CardBus
->SubordinateBusNumber
);
3810 // Print CardBus Latency Timer
3812 ShellPrintHiiEx(-1, -1, NULL
,
3813 STRING_TOKEN (STR_PCI2_CARDBUS_LATENCY
),
3814 gShellDebug1HiiHandle
,
3815 INDEX_OF (&(CardBus
->CardBusLatencyTimer
)),
3816 CardBus
->CardBusLatencyTimer
3820 // Print Memory/Io ranges this cardbus bridge forwards
3822 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RESOURCE_TYPE_2
), gShellDebug1HiiHandle
);
3823 ShellPrintEx (-1, -1, L
"----------------------------------------------------------------------\r\n");
3825 ShellPrintHiiEx(-1, -1, NULL
,
3826 STRING_TOKEN (STR_PCI2_MEM_3
),
3827 gShellDebug1HiiHandle
,
3828 INDEX_OF (&(CardBus
->MemoryBase0
)),
3829 CardBus
->BridgeControl
& BIT8
? L
" Prefetchable" : L
"Non-Prefetchable",
3830 CardBus
->MemoryBase0
& 0xfffff000,
3831 CardBus
->MemoryLimit0
| 0x00000fff
3834 ShellPrintHiiEx(-1, -1, NULL
,
3835 STRING_TOKEN (STR_PCI2_MEM_3
),
3836 gShellDebug1HiiHandle
,
3837 INDEX_OF (&(CardBus
->MemoryBase1
)),
3838 CardBus
->BridgeControl
& BIT9
? L
" Prefetchable" : L
"Non-Prefetchable",
3839 CardBus
->MemoryBase1
& 0xfffff000,
3840 CardBus
->MemoryLimit1
| 0x00000fff
3843 Io32Bit
= (BOOLEAN
) (CardBus
->IoBase0
& BIT0
);
3844 ShellPrintHiiEx(-1, -1, NULL
,
3845 STRING_TOKEN (STR_PCI2_IO_2
),
3846 gShellDebug1HiiHandle
,
3847 INDEX_OF (&(CardBus
->IoBase0
)),
3848 Io32Bit
? L
" 32 bit" : L
" 16 bit",
3849 CardBus
->IoBase0
& (Io32Bit
? 0xfffffffc : 0x0000fffc),
3850 (CardBus
->IoLimit0
& (Io32Bit
? 0xffffffff : 0x0000ffff)) | 0x00000003
3853 Io32Bit
= (BOOLEAN
) (CardBus
->IoBase1
& BIT0
);
3854 ShellPrintHiiEx(-1, -1, NULL
,
3855 STRING_TOKEN (STR_PCI2_IO_2
),
3856 gShellDebug1HiiHandle
,
3857 INDEX_OF (&(CardBus
->IoBase1
)),
3858 Io32Bit
? L
" 32 bit" : L
" 16 bit",
3859 CardBus
->IoBase1
& (Io32Bit
? 0xfffffffc : 0x0000fffc),
3860 (CardBus
->IoLimit1
& (Io32Bit
? 0xffffffff : 0x0000ffff)) | 0x00000003
3864 // Print register Interrupt Line & PIN
3866 ShellPrintHiiEx(-1, -1, NULL
,
3867 STRING_TOKEN (STR_PCI2_INTERRUPT_LINE_3
),
3868 gShellDebug1HiiHandle
,
3869 INDEX_OF (&(CardBus
->InterruptLine
)),
3870 CardBus
->InterruptLine
,
3871 INDEX_OF (&(CardBus
->InterruptPin
)),
3872 CardBus
->InterruptPin
3876 // Print register Bridge Control
3878 PciExplainBridgeControl (&(CardBus
->BridgeControl
), PciCardBusBridge
);
3881 // Print some registers in data region of PCI configuration space for cardbus
3882 // bridge. Fields include: Sub VendorId, Subsystem ID, and Legacy Mode Base
3885 CardBusData
= (PCI_CARDBUS_DATA
*) ((UINT8
*) CardBus
+ sizeof (PCI_CARDBUS_CONTROL_REGISTER
));
3887 ShellPrintHiiEx(-1, -1, NULL
,
3888 STRING_TOKEN (STR_PCI2_SUB_VENDOR_ID_2
),
3889 gShellDebug1HiiHandle
,
3890 INDEX_OF (&(CardBusData
->SubVendorId
)),
3891 CardBusData
->SubVendorId
,
3892 INDEX_OF (&(CardBusData
->SubSystemId
)),
3893 CardBusData
->SubSystemId
3896 ShellPrintHiiEx(-1, -1, NULL
,
3897 STRING_TOKEN (STR_PCI2_OPTIONAL
),
3898 gShellDebug1HiiHandle
,
3899 INDEX_OF (&(CardBusData
->LegacyBase
)),
3900 CardBusData
->LegacyBase
3907 Explain each meaningful bit of register Status. The definition of Status is
3908 slightly different depending on the PCI header type.
3910 @param[in] Status Points to the content of register Status.
3911 @param[in] MainStatus Indicates if this register is main status(not secondary
3913 @param[in] HeaderType Header type of this PCI device.
3915 @retval EFI_SUCCESS The command completed successfully.
3920 IN BOOLEAN MainStatus
,
3921 IN PCI_HEADER_TYPE HeaderType
3925 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_STATUS
), gShellDebug1HiiHandle
, INDEX_OF (Status
), *Status
);
3928 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_SECONDARY_STATUS
), gShellDebug1HiiHandle
, INDEX_OF (Status
), *Status
);
3931 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NEW_CAPABILITIES
), gShellDebug1HiiHandle
, (*Status
& BIT4
) != 0);
3934 // Bit 5 is meaningless for CardBus Bridge
3936 if (HeaderType
== PciCardBusBridge
) {
3937 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_66_CAPABLE
), gShellDebug1HiiHandle
, (*Status
& BIT5
) != 0);
3940 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_66_CAPABLE_2
), gShellDebug1HiiHandle
, (*Status
& BIT5
) != 0);
3943 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_FAST_BACK
), gShellDebug1HiiHandle
, (*Status
& BIT7
) != 0);
3945 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MASTER_DATA
), gShellDebug1HiiHandle
, (*Status
& BIT8
) != 0);
3947 // Bit 9 and bit 10 together decides the DEVSEL timing
3949 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_DEVSEL_TIMING
), gShellDebug1HiiHandle
);
3950 if ((*Status
& BIT9
) == 0 && (*Status
& BIT10
) == 0) {
3951 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_FAST
), gShellDebug1HiiHandle
);
3953 } else if ((*Status
& BIT9
) != 0 && (*Status
& BIT10
) == 0) {
3954 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MEDIUM
), gShellDebug1HiiHandle
);
3956 } else if ((*Status
& BIT9
) == 0 && (*Status
& BIT10
) != 0) {
3957 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_SLOW
), gShellDebug1HiiHandle
);
3960 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RESERVED_2
), gShellDebug1HiiHandle
);
3963 ShellPrintHiiEx(-1, -1, NULL
,
3964 STRING_TOKEN (STR_PCI2_SIGNALED_TARGET
),
3965 gShellDebug1HiiHandle
,
3966 (*Status
& BIT11
) != 0
3969 ShellPrintHiiEx(-1, -1, NULL
,
3970 STRING_TOKEN (STR_PCI2_RECEIVED_TARGET
),
3971 gShellDebug1HiiHandle
,
3972 (*Status
& BIT12
) != 0
3975 ShellPrintHiiEx(-1, -1, NULL
,
3976 STRING_TOKEN (STR_PCI2_RECEIVED_MASTER
),
3977 gShellDebug1HiiHandle
,
3978 (*Status
& BIT13
) != 0
3982 ShellPrintHiiEx(-1, -1, NULL
,
3983 STRING_TOKEN (STR_PCI2_SIGNALED_ERROR
),
3984 gShellDebug1HiiHandle
,
3985 (*Status
& BIT14
) != 0
3989 ShellPrintHiiEx(-1, -1, NULL
,
3990 STRING_TOKEN (STR_PCI2_RECEIVED_ERROR
),
3991 gShellDebug1HiiHandle
,
3992 (*Status
& BIT14
) != 0
3996 ShellPrintHiiEx(-1, -1, NULL
,
3997 STRING_TOKEN (STR_PCI2_DETECTED_ERROR
),
3998 gShellDebug1HiiHandle
,
3999 (*Status
& BIT15
) != 0
4006 Explain each meaningful bit of register Command.
4008 @param[in] Command Points to the content of register Command.
4010 @retval EFI_SUCCESS The command completed successfully.
4018 // Print the binary value of register Command
4020 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_COMMAND
), gShellDebug1HiiHandle
, INDEX_OF (Command
), *Command
);
4023 // Explain register Command bit by bit
4025 ShellPrintHiiEx(-1, -1, NULL
,
4026 STRING_TOKEN (STR_PCI2_SPACE_ACCESS_DENIED
),
4027 gShellDebug1HiiHandle
,
4028 (*Command
& BIT0
) != 0
4031 ShellPrintHiiEx(-1, -1, NULL
,
4032 STRING_TOKEN (STR_PCI2_MEMORY_SPACE
),
4033 gShellDebug1HiiHandle
,
4034 (*Command
& BIT1
) != 0
4037 ShellPrintHiiEx(-1, -1, NULL
,
4038 STRING_TOKEN (STR_PCI2_BEHAVE_BUS_MASTER
),
4039 gShellDebug1HiiHandle
,
4040 (*Command
& BIT2
) != 0
4043 ShellPrintHiiEx(-1, -1, NULL
,
4044 STRING_TOKEN (STR_PCI2_MONITOR_SPECIAL_CYCLE
),
4045 gShellDebug1HiiHandle
,
4046 (*Command
& BIT3
) != 0
4049 ShellPrintHiiEx(-1, -1, NULL
,
4050 STRING_TOKEN (STR_PCI2_MEM_WRITE_INVALIDATE
),
4051 gShellDebug1HiiHandle
,
4052 (*Command
& BIT4
) != 0
4055 ShellPrintHiiEx(-1, -1, NULL
,
4056 STRING_TOKEN (STR_PCI2_PALETTE_SNOOPING
),
4057 gShellDebug1HiiHandle
,
4058 (*Command
& BIT5
) != 0
4061 ShellPrintHiiEx(-1, -1, NULL
,
4062 STRING_TOKEN (STR_PCI2_ASSERT_PERR
),
4063 gShellDebug1HiiHandle
,
4064 (*Command
& BIT6
) != 0
4067 ShellPrintHiiEx(-1, -1, NULL
,
4068 STRING_TOKEN (STR_PCI2_DO_ADDR_STEPPING
),
4069 gShellDebug1HiiHandle
,
4070 (*Command
& BIT7
) != 0
4073 ShellPrintHiiEx(-1, -1, NULL
,
4074 STRING_TOKEN (STR_PCI2_SERR_DRIVER
),
4075 gShellDebug1HiiHandle
,
4076 (*Command
& BIT8
) != 0
4079 ShellPrintHiiEx(-1, -1, NULL
,
4080 STRING_TOKEN (STR_PCI2_FAST_BACK_2
),
4081 gShellDebug1HiiHandle
,
4082 (*Command
& BIT9
) != 0
4089 Explain each meaningful bit of register Bridge Control.
4091 @param[in] BridgeControl Points to the content of register Bridge Control.
4092 @param[in] HeaderType The headertype.
4094 @retval EFI_SUCCESS The command completed successfully.
4097 PciExplainBridgeControl (
4098 IN UINT16
*BridgeControl
,
4099 IN PCI_HEADER_TYPE HeaderType
4102 ShellPrintHiiEx(-1, -1, NULL
,
4103 STRING_TOKEN (STR_PCI2_BRIDGE_CONTROL
),
4104 gShellDebug1HiiHandle
,
4105 INDEX_OF (BridgeControl
),
4109 ShellPrintHiiEx(-1, -1, NULL
,
4110 STRING_TOKEN (STR_PCI2_PARITY_ERROR
),
4111 gShellDebug1HiiHandle
,
4112 (*BridgeControl
& BIT0
) != 0
4114 ShellPrintHiiEx(-1, -1, NULL
,
4115 STRING_TOKEN (STR_PCI2_SERR_ENABLE
),
4116 gShellDebug1HiiHandle
,
4117 (*BridgeControl
& BIT1
) != 0
4119 ShellPrintHiiEx(-1, -1, NULL
,
4120 STRING_TOKEN (STR_PCI2_ISA_ENABLE
),
4121 gShellDebug1HiiHandle
,
4122 (*BridgeControl
& BIT2
) != 0
4124 ShellPrintHiiEx(-1, -1, NULL
,
4125 STRING_TOKEN (STR_PCI2_VGA_ENABLE
),
4126 gShellDebug1HiiHandle
,
4127 (*BridgeControl
& BIT3
) != 0
4129 ShellPrintHiiEx(-1, -1, NULL
,
4130 STRING_TOKEN (STR_PCI2_MASTER_ABORT
),
4131 gShellDebug1HiiHandle
,
4132 (*BridgeControl
& BIT5
) != 0
4136 // Register Bridge Control has some slight differences between P2P bridge
4137 // and Cardbus bridge from bit 6 to bit 11.
4139 if (HeaderType
== PciP2pBridge
) {
4140 ShellPrintHiiEx(-1, -1, NULL
,
4141 STRING_TOKEN (STR_PCI2_SECONDARY_BUS_RESET
),
4142 gShellDebug1HiiHandle
,
4143 (*BridgeControl
& BIT6
) != 0
4145 ShellPrintHiiEx(-1, -1, NULL
,
4146 STRING_TOKEN (STR_PCI2_FAST_ENABLE
),
4147 gShellDebug1HiiHandle
,
4148 (*BridgeControl
& BIT7
) != 0
4150 ShellPrintHiiEx(-1, -1, NULL
,
4151 STRING_TOKEN (STR_PCI2_PRIMARY_DISCARD_TIMER
),
4152 gShellDebug1HiiHandle
,
4153 (*BridgeControl
& BIT8
)!=0 ? L
"2^10" : L
"2^15"
4155 ShellPrintHiiEx(-1, -1, NULL
,
4156 STRING_TOKEN (STR_PCI2_SECONDARY_DISCARD_TIMER
),
4157 gShellDebug1HiiHandle
,
4158 (*BridgeControl
& BIT9
)!=0 ? L
"2^10" : L
"2^15"
4160 ShellPrintHiiEx(-1, -1, NULL
,
4161 STRING_TOKEN (STR_PCI2_DISCARD_TIMER_STATUS
),
4162 gShellDebug1HiiHandle
,
4163 (*BridgeControl
& BIT10
) != 0
4165 ShellPrintHiiEx(-1, -1, NULL
,
4166 STRING_TOKEN (STR_PCI2_DISCARD_TIMER_SERR
),
4167 gShellDebug1HiiHandle
,
4168 (*BridgeControl
& BIT11
) != 0
4172 ShellPrintHiiEx(-1, -1, NULL
,
4173 STRING_TOKEN (STR_PCI2_CARDBUS_RESET
),
4174 gShellDebug1HiiHandle
,
4175 (*BridgeControl
& BIT6
) != 0
4177 ShellPrintHiiEx(-1, -1, NULL
,
4178 STRING_TOKEN (STR_PCI2_IREQ_ENABLE
),
4179 gShellDebug1HiiHandle
,
4180 (*BridgeControl
& BIT7
) != 0
4182 ShellPrintHiiEx(-1, -1, NULL
,
4183 STRING_TOKEN (STR_PCI2_WRITE_POSTING_ENABLE
),
4184 gShellDebug1HiiHandle
,
4185 (*BridgeControl
& BIT10
) != 0
4193 Locate capability register block per capability ID.
4195 @param[in] ConfigSpace Data in PCI configuration space.
4196 @param[in] CapabilityId The capability ID.
4198 @return The offset of the register block per capability ID,
4199 or 0 if the register block cannot be found.
4202 LocatePciCapability (
4203 IN PCI_CONFIG_SPACE
*ConfigSpace
,
4204 IN UINT8 CapabilityId
4207 UINT8 CapabilityPtr
;
4208 EFI_PCI_CAPABILITY_HDR
*CapabilityEntry
;
4211 // To check the cpability of this device supports
4213 if ((ConfigSpace
->Common
.Status
& EFI_PCI_STATUS_CAPABILITY
) == 0) {
4217 switch ((PCI_HEADER_TYPE
)(ConfigSpace
->Common
.HeaderType
& 0x7f)) {
4219 CapabilityPtr
= ConfigSpace
->NonCommon
.Device
.CapabilityPtr
;
4222 CapabilityPtr
= ConfigSpace
->NonCommon
.Bridge
.CapabilityPtr
;
4224 case PciCardBusBridge
:
4225 CapabilityPtr
= ConfigSpace
->NonCommon
.CardBus
.Cap_Ptr
;
4231 while ((CapabilityPtr
>= 0x40) && ((CapabilityPtr
& 0x03) == 0x00)) {
4232 CapabilityEntry
= (EFI_PCI_CAPABILITY_HDR
*) ((UINT8
*) ConfigSpace
+ CapabilityPtr
);
4233 if (CapabilityEntry
->CapabilityID
== CapabilityId
) {
4234 return CapabilityPtr
;
4238 // Certain PCI device may incorrectly have capability pointing to itself,
4239 // break to avoid dead loop.
4241 if (CapabilityPtr
== CapabilityEntry
->NextItemPtr
) {
4245 CapabilityPtr
= CapabilityEntry
->NextItemPtr
;
4252 Print out information of the capability information.
4254 @param[in] PciExpressCap The pointer to the structure about the device.
4256 @retval EFI_SUCCESS The operation was successful.
4260 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4263 CHAR16
*DevicePortType
;
4265 ShellPrintEx (-1, -1,
4266 L
" Capability Version(3:0): %E0x%04x%N\r\n",
4267 PciExpressCap
->Capability
.Bits
.Version
4269 if (PciExpressCap
->Capability
.Bits
.DevicePortType
< ARRAY_SIZE (DevicePortTypeTable
)) {
4270 DevicePortType
= DevicePortTypeTable
[PciExpressCap
->Capability
.Bits
.DevicePortType
];
4272 DevicePortType
= L
"Unknown Type";
4274 ShellPrintEx (-1, -1,
4275 L
" Device/PortType(7:4): %E%s%N\r\n",
4279 // 'Slot Implemented' is only valid for:
4280 // a) Root Port of PCI Express Root Complex, or
4281 // b) Downstream Port of PCI Express Switch
4283 if (PciExpressCap
->Capability
.Bits
.DevicePortType
== PCIE_DEVICE_PORT_TYPE_ROOT_PORT
||
4284 PciExpressCap
->Capability
.Bits
.DevicePortType
== PCIE_DEVICE_PORT_TYPE_DOWNSTREAM_PORT
) {
4285 ShellPrintEx (-1, -1,
4286 L
" Slot Implemented(8): %E%d%N\r\n",
4287 PciExpressCap
->Capability
.Bits
.SlotImplemented
4290 ShellPrintEx (-1, -1,
4291 L
" Interrupt Message Number(13:9): %E0x%05x%N\r\n",
4292 PciExpressCap
->Capability
.Bits
.InterruptMessageNumber
4298 Print out information of the device capability information.
4300 @param[in] PciExpressCap The pointer to the structure about the device.
4302 @retval EFI_SUCCESS The operation was successful.
4305 ExplainPcieDeviceCap (
4306 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4309 UINT8 DevicePortType
;
4313 DevicePortType
= (UINT8
)PciExpressCap
->Capability
.Bits
.DevicePortType
;
4314 ShellPrintEx (-1, -1, L
" Max_Payload_Size Supported(2:0): ");
4315 if (PciExpressCap
->DeviceCapability
.Bits
.MaxPayloadSize
< 6) {
4316 ShellPrintEx (-1, -1, L
"%E%d bytes%N\r\n", 1 << (PciExpressCap
->DeviceCapability
.Bits
.MaxPayloadSize
+ 7));
4318 ShellPrintEx (-1, -1, L
"%EUnknown%N\r\n");
4320 ShellPrintEx (-1, -1,
4321 L
" Phantom Functions Supported(4:3): %E%d%N\r\n",
4322 PciExpressCap
->DeviceCapability
.Bits
.PhantomFunctions
4324 ShellPrintEx (-1, -1,
4325 L
" Extended Tag Field Supported(5): %E%d-bit Tag field supported%N\r\n",
4326 PciExpressCap
->DeviceCapability
.Bits
.ExtendedTagField
? 8 : 5
4329 // Endpoint L0s and L1 Acceptable Latency is only valid for Endpoint
4331 if (IS_PCIE_ENDPOINT (DevicePortType
)) {
4332 L0sLatency
= (UINT8
)PciExpressCap
->DeviceCapability
.Bits
.EndpointL0sAcceptableLatency
;
4333 L1Latency
= (UINT8
)PciExpressCap
->DeviceCapability
.Bits
.EndpointL1AcceptableLatency
;
4334 ShellPrintEx (-1, -1, L
" Endpoint L0s Acceptable Latency(8:6): ");
4335 if (L0sLatency
< 4) {
4336 ShellPrintEx (-1, -1, L
"%EMaximum of %d ns%N\r\n", 1 << (L0sLatency
+ 6));
4338 if (L0sLatency
< 7) {
4339 ShellPrintEx (-1, -1, L
"%EMaximum of %d us%N\r\n", 1 << (L0sLatency
- 3));
4341 ShellPrintEx (-1, -1, L
"%ENo limit%N\r\n");
4344 ShellPrintEx (-1, -1, L
" Endpoint L1 Acceptable Latency(11:9): ");
4345 if (L1Latency
< 7) {
4346 ShellPrintEx (-1, -1, L
"%EMaximum of %d us%N\r\n", 1 << (L1Latency
+ 1));
4348 ShellPrintEx (-1, -1, L
"%ENo limit%N\r\n");
4351 ShellPrintEx (-1, -1,
4352 L
" Role-based Error Reporting(15): %E%d%N\r\n",
4353 PciExpressCap
->DeviceCapability
.Bits
.RoleBasedErrorReporting
4356 // Only valid for Upstream Port:
4357 // a) Captured Slot Power Limit Value
4358 // b) Captured Slot Power Scale
4360 if (DevicePortType
== PCIE_DEVICE_PORT_TYPE_UPSTREAM_PORT
) {
4361 ShellPrintEx (-1, -1,
4362 L
" Captured Slot Power Limit Value(25:18): %E0x%02x%N\r\n",
4363 PciExpressCap
->DeviceCapability
.Bits
.CapturedSlotPowerLimitValue
4365 ShellPrintEx (-1, -1,
4366 L
" Captured Slot Power Limit Scale(27:26): %E%s%N\r\n",
4367 SlotPwrLmtScaleTable
[PciExpressCap
->DeviceCapability
.Bits
.CapturedSlotPowerLimitScale
]
4371 // Function Level Reset Capability is only valid for Endpoint
4373 if (IS_PCIE_ENDPOINT (DevicePortType
)) {
4374 ShellPrintEx (-1, -1,
4375 L
" Function Level Reset Capability(28): %E%d%N\r\n",
4376 PciExpressCap
->DeviceCapability
.Bits
.FunctionLevelReset
4383 Print out information of the device control information.
4385 @param[in] PciExpressCap The pointer to the structure about the device.
4387 @retval EFI_SUCCESS The operation was successful.
4390 ExplainPcieDeviceControl (
4391 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4394 ShellPrintEx (-1, -1,
4395 L
" Correctable Error Reporting Enable(0): %E%d%N\r\n",
4396 PciExpressCap
->DeviceControl
.Bits
.CorrectableError
4398 ShellPrintEx (-1, -1,
4399 L
" Non-Fatal Error Reporting Enable(1): %E%d%N\r\n",
4400 PciExpressCap
->DeviceControl
.Bits
.NonFatalError
4402 ShellPrintEx (-1, -1,
4403 L
" Fatal Error Reporting Enable(2): %E%d%N\r\n",
4404 PciExpressCap
->DeviceControl
.Bits
.FatalError
4406 ShellPrintEx (-1, -1,
4407 L
" Unsupported Request Reporting Enable(3): %E%d%N\r\n",
4408 PciExpressCap
->DeviceControl
.Bits
.UnsupportedRequest
4410 ShellPrintEx (-1, -1,
4411 L
" Enable Relaxed Ordering(4): %E%d%N\r\n",
4412 PciExpressCap
->DeviceControl
.Bits
.RelaxedOrdering
4414 ShellPrintEx (-1, -1, L
" Max_Payload_Size(7:5): ");
4415 if (PciExpressCap
->DeviceControl
.Bits
.MaxPayloadSize
< 6) {
4416 ShellPrintEx (-1, -1, L
"%E%d bytes%N\r\n", 1 << (PciExpressCap
->DeviceControl
.Bits
.MaxPayloadSize
+ 7));
4418 ShellPrintEx (-1, -1, L
"%EUnknown%N\r\n");
4420 ShellPrintEx (-1, -1,
4421 L
" Extended Tag Field Enable(8): %E%d%N\r\n",
4422 PciExpressCap
->DeviceControl
.Bits
.ExtendedTagField
4424 ShellPrintEx (-1, -1,
4425 L
" Phantom Functions Enable(9): %E%d%N\r\n",
4426 PciExpressCap
->DeviceControl
.Bits
.PhantomFunctions
4428 ShellPrintEx (-1, -1,
4429 L
" Auxiliary (AUX) Power PM Enable(10): %E%d%N\r\n",
4430 PciExpressCap
->DeviceControl
.Bits
.AuxPower
4432 ShellPrintEx (-1, -1,
4433 L
" Enable No Snoop(11): %E%d%N\r\n",
4434 PciExpressCap
->DeviceControl
.Bits
.NoSnoop
4436 ShellPrintEx (-1, -1, L
" Max_Read_Request_Size(14:12): ");
4437 if (PciExpressCap
->DeviceControl
.Bits
.MaxReadRequestSize
< 6) {
4438 ShellPrintEx (-1, -1, L
"%E%d bytes%N\r\n", 1 << (PciExpressCap
->DeviceControl
.Bits
.MaxReadRequestSize
+ 7));
4440 ShellPrintEx (-1, -1, L
"%EUnknown%N\r\n");
4443 // Read operation is only valid for PCI Express to PCI/PCI-X Bridges
4445 if (PciExpressCap
->Capability
.Bits
.DevicePortType
== PCIE_DEVICE_PORT_TYPE_PCIE_TO_PCI_BRIDGE
) {
4446 ShellPrintEx (-1, -1,
4447 L
" Bridge Configuration Retry Enable(15): %E%d%N\r\n",
4448 PciExpressCap
->DeviceControl
.Bits
.BridgeConfigurationRetryOrFunctionLevelReset
4455 Print out information of the device status information.
4457 @param[in] PciExpressCap The pointer to the structure about the device.
4459 @retval EFI_SUCCESS The operation was successful.
4462 ExplainPcieDeviceStatus (
4463 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4466 ShellPrintEx (-1, -1,
4467 L
" Correctable Error Detected(0): %E%d%N\r\n",
4468 PciExpressCap
->DeviceStatus
.Bits
.CorrectableError
4470 ShellPrintEx (-1, -1,
4471 L
" Non-Fatal Error Detected(1): %E%d%N\r\n",
4472 PciExpressCap
->DeviceStatus
.Bits
.NonFatalError
4474 ShellPrintEx (-1, -1,
4475 L
" Fatal Error Detected(2): %E%d%N\r\n",
4476 PciExpressCap
->DeviceStatus
.Bits
.FatalError
4478 ShellPrintEx (-1, -1,
4479 L
" Unsupported Request Detected(3): %E%d%N\r\n",
4480 PciExpressCap
->DeviceStatus
.Bits
.UnsupportedRequest
4482 ShellPrintEx (-1, -1,
4483 L
" AUX Power Detected(4): %E%d%N\r\n",
4484 PciExpressCap
->DeviceStatus
.Bits
.AuxPower
4486 ShellPrintEx (-1, -1,
4487 L
" Transactions Pending(5): %E%d%N\r\n",
4488 PciExpressCap
->DeviceStatus
.Bits
.TransactionsPending
4494 Print out information of the device link information.
4496 @param[in] PciExpressCap The pointer to the structure about the device.
4498 @retval EFI_SUCCESS The operation was successful.
4501 ExplainPcieLinkCap (
4502 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4505 CHAR16
*MaxLinkSpeed
;
4508 switch (PciExpressCap
->LinkCapability
.Bits
.MaxLinkSpeed
) {
4510 MaxLinkSpeed
= L
"2.5 GT/s";
4513 MaxLinkSpeed
= L
"5.0 GT/s";
4516 MaxLinkSpeed
= L
"8.0 GT/s";
4519 MaxLinkSpeed
= L
"16.0 GT/s";
4522 MaxLinkSpeed
= L
"32.0 GT/s";
4525 MaxLinkSpeed
= L
"Reserved";
4528 ShellPrintEx (-1, -1,
4529 L
" Maximum Link Speed(3:0): %E%s%N\r\n",
4532 ShellPrintEx (-1, -1,
4533 L
" Maximum Link Width(9:4): %Ex%d%N\r\n",
4534 PciExpressCap
->LinkCapability
.Bits
.MaxLinkWidth
4536 switch (PciExpressCap
->LinkCapability
.Bits
.Aspm
) {
4547 AspmValue
= L
"L0s and L1";
4550 AspmValue
= L
"Reserved";
4553 ShellPrintEx (-1, -1,
4554 L
" Active State Power Management Support(11:10): %E%s Supported%N\r\n",
4557 ShellPrintEx (-1, -1,
4558 L
" L0s Exit Latency(14:12): %E%s%N\r\n",
4559 L0sLatencyStrTable
[PciExpressCap
->LinkCapability
.Bits
.L0sExitLatency
]
4561 ShellPrintEx (-1, -1,
4562 L
" L1 Exit Latency(17:15): %E%s%N\r\n",
4563 L1LatencyStrTable
[PciExpressCap
->LinkCapability
.Bits
.L1ExitLatency
]
4565 ShellPrintEx (-1, -1,
4566 L
" Clock Power Management(18): %E%d%N\r\n",
4567 PciExpressCap
->LinkCapability
.Bits
.ClockPowerManagement
4569 ShellPrintEx (-1, -1,
4570 L
" Surprise Down Error Reporting Capable(19): %E%d%N\r\n",
4571 PciExpressCap
->LinkCapability
.Bits
.SurpriseDownError
4573 ShellPrintEx (-1, -1,
4574 L
" Data Link Layer Link Active Reporting Capable(20): %E%d%N\r\n",
4575 PciExpressCap
->LinkCapability
.Bits
.DataLinkLayerLinkActive
4577 ShellPrintEx (-1, -1,
4578 L
" Link Bandwidth Notification Capability(21): %E%d%N\r\n",
4579 PciExpressCap
->LinkCapability
.Bits
.LinkBandwidthNotification
4581 ShellPrintEx (-1, -1,
4582 L
" Port Number(31:24): %E0x%02x%N\r\n",
4583 PciExpressCap
->LinkCapability
.Bits
.PortNumber
4589 Print out information of the device link control information.
4591 @param[in] PciExpressCap The pointer to the structure about the device.
4593 @retval EFI_SUCCESS The operation was successful.
4596 ExplainPcieLinkControl (
4597 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4600 UINT8 DevicePortType
;
4602 DevicePortType
= (UINT8
)PciExpressCap
->Capability
.Bits
.DevicePortType
;
4603 ShellPrintEx (-1, -1,
4604 L
" Active State Power Management Control(1:0): %E%s%N\r\n",
4605 ASPMCtrlStrTable
[PciExpressCap
->LinkControl
.Bits
.AspmControl
]
4608 // RCB is not applicable to switches
4610 if (!IS_PCIE_SWITCH(DevicePortType
)) {
4611 ShellPrintEx (-1, -1,
4612 L
" Read Completion Boundary (RCB)(3): %E%d byte%N\r\n",
4613 1 << (PciExpressCap
->LinkControl
.Bits
.ReadCompletionBoundary
+ 6)
4617 // Link Disable is reserved on
4619 // b) PCI Express to PCI/PCI-X bridges
4620 // c) Upstream Ports of Switches
4622 if (!IS_PCIE_ENDPOINT (DevicePortType
) &&
4623 DevicePortType
!= PCIE_DEVICE_PORT_TYPE_UPSTREAM_PORT
&&
4624 DevicePortType
!= PCIE_DEVICE_PORT_TYPE_PCIE_TO_PCI_BRIDGE
) {
4625 ShellPrintEx (-1, -1,
4626 L
" Link Disable(4): %E%d%N\r\n",
4627 PciExpressCap
->LinkControl
.Bits
.LinkDisable
4630 ShellPrintEx (-1, -1,
4631 L
" Common Clock Configuration(6): %E%d%N\r\n",
4632 PciExpressCap
->LinkControl
.Bits
.CommonClockConfiguration
4634 ShellPrintEx (-1, -1,
4635 L
" Extended Synch(7): %E%d%N\r\n",
4636 PciExpressCap
->LinkControl
.Bits
.ExtendedSynch
4638 ShellPrintEx (-1, -1,
4639 L
" Enable Clock Power Management(8): %E%d%N\r\n",
4640 PciExpressCap
->LinkControl
.Bits
.ClockPowerManagement
4642 ShellPrintEx (-1, -1,
4643 L
" Hardware Autonomous Width Disable(9): %E%d%N\r\n",
4644 PciExpressCap
->LinkControl
.Bits
.HardwareAutonomousWidthDisable
4646 ShellPrintEx (-1, -1,
4647 L
" Link Bandwidth Management Interrupt Enable(10): %E%d%N\r\n",
4648 PciExpressCap
->LinkControl
.Bits
.LinkBandwidthManagementInterrupt
4650 ShellPrintEx (-1, -1,
4651 L
" Link Autonomous Bandwidth Interrupt Enable(11): %E%d%N\r\n",
4652 PciExpressCap
->LinkControl
.Bits
.LinkAutonomousBandwidthInterrupt
4658 Print out information of the device link status information.
4660 @param[in] PciExpressCap The pointer to the structure about the device.
4662 @retval EFI_SUCCESS The operation was successful.
4665 ExplainPcieLinkStatus (
4666 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4669 CHAR16
*CurLinkSpeed
;
4671 switch (PciExpressCap
->LinkStatus
.Bits
.CurrentLinkSpeed
) {
4673 CurLinkSpeed
= L
"2.5 GT/s";
4676 CurLinkSpeed
= L
"5.0 GT/s";
4679 CurLinkSpeed
= L
"8.0 GT/s";
4682 CurLinkSpeed
= L
"16.0 GT/s";
4685 CurLinkSpeed
= L
"32.0 GT/s";
4688 CurLinkSpeed
= L
"Reserved";
4691 ShellPrintEx (-1, -1,
4692 L
" Current Link Speed(3:0): %E%s%N\r\n",
4695 ShellPrintEx (-1, -1,
4696 L
" Negotiated Link Width(9:4): %Ex%d%N\r\n",
4697 PciExpressCap
->LinkStatus
.Bits
.NegotiatedLinkWidth
4699 ShellPrintEx (-1, -1,
4700 L
" Link Training(11): %E%d%N\r\n",
4701 PciExpressCap
->LinkStatus
.Bits
.LinkTraining
4703 ShellPrintEx (-1, -1,
4704 L
" Slot Clock Configuration(12): %E%d%N\r\n",
4705 PciExpressCap
->LinkStatus
.Bits
.SlotClockConfiguration
4707 ShellPrintEx (-1, -1,
4708 L
" Data Link Layer Link Active(13): %E%d%N\r\n",
4709 PciExpressCap
->LinkStatus
.Bits
.DataLinkLayerLinkActive
4711 ShellPrintEx (-1, -1,
4712 L
" Link Bandwidth Management Status(14): %E%d%N\r\n",
4713 PciExpressCap
->LinkStatus
.Bits
.LinkBandwidthManagement
4715 ShellPrintEx (-1, -1,
4716 L
" Link Autonomous Bandwidth Status(15): %E%d%N\r\n",
4717 PciExpressCap
->LinkStatus
.Bits
.LinkAutonomousBandwidth
4723 Print out information of the device slot information.
4725 @param[in] PciExpressCap The pointer to the structure about the device.
4727 @retval EFI_SUCCESS The operation was successful.
4730 ExplainPcieSlotCap (
4731 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4734 ShellPrintEx (-1, -1,
4735 L
" Attention Button Present(0): %E%d%N\r\n",
4736 PciExpressCap
->SlotCapability
.Bits
.AttentionButton
4738 ShellPrintEx (-1, -1,
4739 L
" Power Controller Present(1): %E%d%N\r\n",
4740 PciExpressCap
->SlotCapability
.Bits
.PowerController
4742 ShellPrintEx (-1, -1,
4743 L
" MRL Sensor Present(2): %E%d%N\r\n",
4744 PciExpressCap
->SlotCapability
.Bits
.MrlSensor
4746 ShellPrintEx (-1, -1,
4747 L
" Attention Indicator Present(3): %E%d%N\r\n",
4748 PciExpressCap
->SlotCapability
.Bits
.AttentionIndicator
4750 ShellPrintEx (-1, -1,
4751 L
" Power Indicator Present(4): %E%d%N\r\n",
4752 PciExpressCap
->SlotCapability
.Bits
.PowerIndicator
4754 ShellPrintEx (-1, -1,
4755 L
" Hot-Plug Surprise(5): %E%d%N\r\n",
4756 PciExpressCap
->SlotCapability
.Bits
.HotPlugSurprise
4758 ShellPrintEx (-1, -1,
4759 L
" Hot-Plug Capable(6): %E%d%N\r\n",
4760 PciExpressCap
->SlotCapability
.Bits
.HotPlugCapable
4762 ShellPrintEx (-1, -1,
4763 L
" Slot Power Limit Value(14:7): %E0x%02x%N\r\n",
4764 PciExpressCap
->SlotCapability
.Bits
.SlotPowerLimitValue
4766 ShellPrintEx (-1, -1,
4767 L
" Slot Power Limit Scale(16:15): %E%s%N\r\n",
4768 SlotPwrLmtScaleTable
[PciExpressCap
->SlotCapability
.Bits
.SlotPowerLimitScale
]
4770 ShellPrintEx (-1, -1,
4771 L
" Electromechanical Interlock Present(17): %E%d%N\r\n",
4772 PciExpressCap
->SlotCapability
.Bits
.ElectromechanicalInterlock
4774 ShellPrintEx (-1, -1,
4775 L
" No Command Completed Support(18): %E%d%N\r\n",
4776 PciExpressCap
->SlotCapability
.Bits
.NoCommandCompleted
4778 ShellPrintEx (-1, -1,
4779 L
" Physical Slot Number(31:19): %E%d%N\r\n",
4780 PciExpressCap
->SlotCapability
.Bits
.PhysicalSlotNumber
4787 Print out information of the device slot control information.
4789 @param[in] PciExpressCap The pointer to the structure about the device.
4791 @retval EFI_SUCCESS The operation was successful.
4794 ExplainPcieSlotControl (
4795 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4798 ShellPrintEx (-1, -1,
4799 L
" Attention Button Pressed Enable(0): %E%d%N\r\n",
4800 PciExpressCap
->SlotControl
.Bits
.AttentionButtonPressed
4802 ShellPrintEx (-1, -1,
4803 L
" Power Fault Detected Enable(1): %E%d%N\r\n",
4804 PciExpressCap
->SlotControl
.Bits
.PowerFaultDetected
4806 ShellPrintEx (-1, -1,
4807 L
" MRL Sensor Changed Enable(2): %E%d%N\r\n",
4808 PciExpressCap
->SlotControl
.Bits
.MrlSensorChanged
4810 ShellPrintEx (-1, -1,
4811 L
" Presence Detect Changed Enable(3): %E%d%N\r\n",
4812 PciExpressCap
->SlotControl
.Bits
.PresenceDetectChanged
4814 ShellPrintEx (-1, -1,
4815 L
" Command Completed Interrupt Enable(4): %E%d%N\r\n",
4816 PciExpressCap
->SlotControl
.Bits
.CommandCompletedInterrupt
4818 ShellPrintEx (-1, -1,
4819 L
" Hot-Plug Interrupt Enable(5): %E%d%N\r\n",
4820 PciExpressCap
->SlotControl
.Bits
.HotPlugInterrupt
4822 ShellPrintEx (-1, -1,
4823 L
" Attention Indicator Control(7:6): %E%s%N\r\n",
4825 PciExpressCap
->SlotControl
.Bits
.AttentionIndicator
]
4827 ShellPrintEx (-1, -1,
4828 L
" Power Indicator Control(9:8): %E%s%N\r\n",
4829 IndicatorTable
[PciExpressCap
->SlotControl
.Bits
.PowerIndicator
]
4831 ShellPrintEx (-1, -1, L
" Power Controller Control(10): %EPower ");
4833 PciExpressCap
->SlotControl
.Bits
.PowerController
) {
4834 ShellPrintEx (-1, -1, L
"Off%N\r\n");
4836 ShellPrintEx (-1, -1, L
"On%N\r\n");
4838 ShellPrintEx (-1, -1,
4839 L
" Electromechanical Interlock Control(11): %E%d%N\r\n",
4840 PciExpressCap
->SlotControl
.Bits
.ElectromechanicalInterlock
4842 ShellPrintEx (-1, -1,
4843 L
" Data Link Layer State Changed Enable(12): %E%d%N\r\n",
4844 PciExpressCap
->SlotControl
.Bits
.DataLinkLayerStateChanged
4850 Print out information of the device slot status information.
4852 @param[in] PciExpressCap The pointer to the structure about the device.
4854 @retval EFI_SUCCESS The operation was successful.
4857 ExplainPcieSlotStatus (
4858 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4861 ShellPrintEx (-1, -1,
4862 L
" Attention Button Pressed(0): %E%d%N\r\n",
4863 PciExpressCap
->SlotStatus
.Bits
.AttentionButtonPressed
4865 ShellPrintEx (-1, -1,
4866 L
" Power Fault Detected(1): %E%d%N\r\n",
4867 PciExpressCap
->SlotStatus
.Bits
.PowerFaultDetected
4869 ShellPrintEx (-1, -1,
4870 L
" MRL Sensor Changed(2): %E%d%N\r\n",
4871 PciExpressCap
->SlotStatus
.Bits
.MrlSensorChanged
4873 ShellPrintEx (-1, -1,
4874 L
" Presence Detect Changed(3): %E%d%N\r\n",
4875 PciExpressCap
->SlotStatus
.Bits
.PresenceDetectChanged
4877 ShellPrintEx (-1, -1,
4878 L
" Command Completed(4): %E%d%N\r\n",
4879 PciExpressCap
->SlotStatus
.Bits
.CommandCompleted
4881 ShellPrintEx (-1, -1, L
" MRL Sensor State(5): %EMRL ");
4883 PciExpressCap
->SlotStatus
.Bits
.MrlSensor
) {
4884 ShellPrintEx (-1, -1, L
" Opened%N\r\n");
4886 ShellPrintEx (-1, -1, L
" Closed%N\r\n");
4888 ShellPrintEx (-1, -1, L
" Presence Detect State(6): ");
4890 PciExpressCap
->SlotStatus
.Bits
.PresenceDetect
) {
4891 ShellPrintEx (-1, -1, L
"%ECard Present in slot%N\r\n");
4893 ShellPrintEx (-1, -1, L
"%ESlot Empty%N\r\n");
4895 ShellPrintEx (-1, -1, L
" Electromechanical Interlock Status(7): %EElectromechanical Interlock ");
4897 PciExpressCap
->SlotStatus
.Bits
.ElectromechanicalInterlock
) {
4898 ShellPrintEx (-1, -1, L
"Engaged%N\r\n");
4900 ShellPrintEx (-1, -1, L
"Disengaged%N\r\n");
4902 ShellPrintEx (-1, -1,
4903 L
" Data Link Layer State Changed(8): %E%d%N\r\n",
4904 PciExpressCap
->SlotStatus
.Bits
.DataLinkLayerStateChanged
4910 Print out information of the device root information.
4912 @param[in] PciExpressCap The pointer to the structure about the device.
4914 @retval EFI_SUCCESS The operation was successful.
4917 ExplainPcieRootControl (
4918 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4921 ShellPrintEx (-1, -1,
4922 L
" System Error on Correctable Error Enable(0): %E%d%N\r\n",
4923 PciExpressCap
->RootControl
.Bits
.SystemErrorOnCorrectableError
4925 ShellPrintEx (-1, -1,
4926 L
" System Error on Non-Fatal Error Enable(1): %E%d%N\r\n",
4927 PciExpressCap
->RootControl
.Bits
.SystemErrorOnNonFatalError
4929 ShellPrintEx (-1, -1,
4930 L
" System Error on Fatal Error Enable(2): %E%d%N\r\n",
4931 PciExpressCap
->RootControl
.Bits
.SystemErrorOnFatalError
4933 ShellPrintEx (-1, -1,
4934 L
" PME Interrupt Enable(3): %E%d%N\r\n",
4935 PciExpressCap
->RootControl
.Bits
.PmeInterrupt
4937 ShellPrintEx (-1, -1,
4938 L
" CRS Software Visibility Enable(4): %E%d%N\r\n",
4939 PciExpressCap
->RootControl
.Bits
.CrsSoftwareVisibility
4946 Print out information of the device root capability information.
4948 @param[in] PciExpressCap The pointer to the structure about the device.
4950 @retval EFI_SUCCESS The operation was successful.
4953 ExplainPcieRootCap (
4954 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4957 ShellPrintEx (-1, -1,
4958 L
" CRS Software Visibility(0): %E%d%N\r\n",
4959 PciExpressCap
->RootCapability
.Bits
.CrsSoftwareVisibility
4966 Print out information of the device root status information.
4968 @param[in] PciExpressCap The pointer to the structure about the device.
4970 @retval EFI_SUCCESS The operation was successful.
4973 ExplainPcieRootStatus (
4974 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4977 ShellPrintEx (-1, -1,
4978 L
" PME Requester ID(15:0): %E0x%04x%N\r\n",
4979 PciExpressCap
->RootStatus
.Bits
.PmeRequesterId
4981 ShellPrintEx (-1, -1,
4982 L
" PME Status(16): %E%d%N\r\n",
4983 PciExpressCap
->RootStatus
.Bits
.PmeStatus
4985 ShellPrintEx (-1, -1,
4986 L
" PME Pending(17): %E%d%N\r\n",
4987 PciExpressCap
->RootStatus
.Bits
.PmePending
4993 Function to interpret and print out the link control structure
4995 @param[in] HeaderAddress The Address of this capability header.
4996 @param[in] HeadersBaseAddress The address of all the extended capability headers.
4999 PrintInterpretedExtendedCompatibilityLinkControl (
5000 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5001 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5004 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_INTERNAL_LINK_CONTROL
*Header
;
5005 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_INTERNAL_LINK_CONTROL
*)HeaderAddress
;
5009 STRING_TOKEN (STR_PCI_EXT_CAP_LINK_CONTROL
),
5010 gShellDebug1HiiHandle
,
5011 Header
->RootComplexLinkCapabilities
,
5012 Header
->RootComplexLinkControl
,
5013 Header
->RootComplexLinkStatus
5017 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5018 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_INTERNAL_LINK_CONTROL
),
5019 (VOID
*) (HeaderAddress
)
5021 return (EFI_SUCCESS
);
5025 Function to interpret and print out the power budgeting structure
5027 @param[in] HeaderAddress The Address of this capability header.
5028 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5031 PrintInterpretedExtendedCompatibilityPowerBudgeting (
5032 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5033 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5036 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_POWER_BUDGETING
*Header
;
5037 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_POWER_BUDGETING
*)HeaderAddress
;
5041 STRING_TOKEN (STR_PCI_EXT_CAP_POWER
),
5042 gShellDebug1HiiHandle
,
5045 Header
->PowerBudgetCapability
5049 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5050 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_POWER_BUDGETING
),
5051 (VOID
*) (HeaderAddress
)
5053 return (EFI_SUCCESS
);
5057 Function to interpret and print out the ACS structure
5059 @param[in] HeaderAddress The Address of this capability header.
5060 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5063 PrintInterpretedExtendedCompatibilityAcs (
5064 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5065 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5068 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_ACS_EXTENDED
*Header
;
5072 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_ACS_EXTENDED
*)HeaderAddress
;
5077 STRING_TOKEN (STR_PCI_EXT_CAP_ACS
),
5078 gShellDebug1HiiHandle
,
5079 Header
->AcsCapability
,
5082 if (PCI_EXPRESS_EXTENDED_CAPABILITY_ACS_EXTENDED_GET_EGRES_CONTROL(Header
)) {
5083 VectorSize
= PCI_EXPRESS_EXTENDED_CAPABILITY_ACS_EXTENDED_GET_EGRES_VECTOR_SIZE(Header
);
5084 if (VectorSize
== 0) {
5087 for (LoopCounter
= 0 ; LoopCounter
* 8 < VectorSize
; LoopCounter
++) {
5090 STRING_TOKEN (STR_PCI_EXT_CAP_ACS2
),
5091 gShellDebug1HiiHandle
,
5093 Header
->EgressControlVectorArray
[LoopCounter
]
5099 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5100 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_ACS_EXTENDED
) + (VectorSize
/ 8) - 1,
5101 (VOID
*) (HeaderAddress
)
5103 return (EFI_SUCCESS
);
5107 Function to interpret and print out the latency tolerance reporting structure
5109 @param[in] HeaderAddress The Address of this capability header.
5110 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5113 PrintInterpretedExtendedCompatibilityLatencyToleranceReporting (
5114 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5115 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5118 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_LATENCE_TOLERANCE_REPORTING
*Header
;
5119 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_LATENCE_TOLERANCE_REPORTING
*)HeaderAddress
;
5123 STRING_TOKEN (STR_PCI_EXT_CAP_LAT
),
5124 gShellDebug1HiiHandle
,
5125 Header
->MaxSnoopLatency
,
5126 Header
->MaxNoSnoopLatency
5130 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5131 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_LATENCE_TOLERANCE_REPORTING
),
5132 (VOID
*) (HeaderAddress
)
5134 return (EFI_SUCCESS
);
5138 Function to interpret and print out the serial number structure
5140 @param[in] HeaderAddress The Address of this capability header.
5141 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5144 PrintInterpretedExtendedCompatibilitySerialNumber (
5145 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5146 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5149 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_SERIAL_NUMBER
*Header
;
5150 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_SERIAL_NUMBER
*)HeaderAddress
;
5154 STRING_TOKEN (STR_PCI_EXT_CAP_SN
),
5155 gShellDebug1HiiHandle
,
5156 Header
->SerialNumber
5160 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5161 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_SERIAL_NUMBER
),
5162 (VOID
*) (HeaderAddress
)
5164 return (EFI_SUCCESS
);
5168 Function to interpret and print out the RCRB structure
5170 @param[in] HeaderAddress The Address of this capability header.
5171 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5174 PrintInterpretedExtendedCompatibilityRcrb (
5175 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5176 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5179 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_RCRB_HEADER
*Header
;
5180 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_RCRB_HEADER
*)HeaderAddress
;
5184 STRING_TOKEN (STR_PCI_EXT_CAP_RCRB
),
5185 gShellDebug1HiiHandle
,
5188 Header
->RcrbCapabilities
,
5193 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5194 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_RCRB_HEADER
),
5195 (VOID
*) (HeaderAddress
)
5197 return (EFI_SUCCESS
);
5201 Function to interpret and print out the vendor specific structure
5203 @param[in] HeaderAddress The Address of this capability header.
5204 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5207 PrintInterpretedExtendedCompatibilityVendorSpecific (
5208 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5209 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5212 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_VENDOR_SPECIFIC
*Header
;
5213 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_VENDOR_SPECIFIC
*)HeaderAddress
;
5217 STRING_TOKEN (STR_PCI_EXT_CAP_VEN
),
5218 gShellDebug1HiiHandle
,
5219 Header
->VendorSpecificHeader
5223 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5224 PCI_EXPRESS_EXTENDED_CAPABILITY_VENDOR_SPECIFIC_GET_SIZE(Header
),
5225 (VOID
*) (HeaderAddress
)
5227 return (EFI_SUCCESS
);
5231 Function to interpret and print out the Event Collector Endpoint Association structure
5233 @param[in] HeaderAddress The Address of this capability header.
5234 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5237 PrintInterpretedExtendedCompatibilityECEA (
5238 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5239 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5242 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_EVENT_COLLECTOR_ENDPOINT_ASSOCIATION
*Header
;
5243 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_EVENT_COLLECTOR_ENDPOINT_ASSOCIATION
*)HeaderAddress
;
5247 STRING_TOKEN (STR_PCI_EXT_CAP_ECEA
),
5248 gShellDebug1HiiHandle
,
5249 Header
->AssociationBitmap
5253 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5254 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_EVENT_COLLECTOR_ENDPOINT_ASSOCIATION
),
5255 (VOID
*) (HeaderAddress
)
5257 return (EFI_SUCCESS
);
5261 Function to interpret and print out the ARI structure
5263 @param[in] HeaderAddress The Address of this capability header.
5264 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5267 PrintInterpretedExtendedCompatibilityAri (
5268 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5269 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5272 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_ARI_CAPABILITY
*Header
;
5273 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_ARI_CAPABILITY
*)HeaderAddress
;
5277 STRING_TOKEN (STR_PCI_EXT_CAP_ARI
),
5278 gShellDebug1HiiHandle
,
5279 Header
->AriCapability
,
5284 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5285 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_ARI_CAPABILITY
),
5286 (VOID
*) (HeaderAddress
)
5288 return (EFI_SUCCESS
);
5292 Function to interpret and print out the DPA structure
5294 @param[in] HeaderAddress The Address of this capability header.
5295 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5298 PrintInterpretedExtendedCompatibilityDynamicPowerAllocation (
5299 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5300 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5303 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_DYNAMIC_POWER_ALLOCATION
*Header
;
5305 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_DYNAMIC_POWER_ALLOCATION
*)HeaderAddress
;
5309 STRING_TOKEN (STR_PCI_EXT_CAP_DPA
),
5310 gShellDebug1HiiHandle
,
5311 Header
->DpaCapability
,
5312 Header
->DpaLatencyIndicator
,
5316 for (LinkCount
= 0 ; LinkCount
< PCI_EXPRESS_EXTENDED_CAPABILITY_DYNAMIC_POWER_ALLOCATION_GET_SUBSTATE_MAX(Header
) + 1 ; LinkCount
++) {
5319 STRING_TOKEN (STR_PCI_EXT_CAP_DPA2
),
5320 gShellDebug1HiiHandle
,
5322 Header
->DpaPowerAllocationArray
[LinkCount
]
5327 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5328 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_DYNAMIC_POWER_ALLOCATION
) - 1 + PCI_EXPRESS_EXTENDED_CAPABILITY_DYNAMIC_POWER_ALLOCATION_GET_SUBSTATE_MAX(Header
),
5329 (VOID
*) (HeaderAddress
)
5331 return (EFI_SUCCESS
);
5335 Function to interpret and print out the link declaration structure
5337 @param[in] HeaderAddress The Address of this capability header.
5338 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5341 PrintInterpretedExtendedCompatibilityLinkDeclaration (
5342 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5343 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5346 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_LINK_DECLARATION
*Header
;
5348 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_LINK_DECLARATION
*)HeaderAddress
;
5352 STRING_TOKEN (STR_PCI_EXT_CAP_LINK_DECLAR
),
5353 gShellDebug1HiiHandle
,
5354 Header
->ElementSelfDescription
5357 for (LinkCount
= 0 ; LinkCount
< PCI_EXPRESS_EXTENDED_CAPABILITY_LINK_DECLARATION_GET_LINK_COUNT(Header
) ; LinkCount
++) {
5360 STRING_TOKEN (STR_PCI_EXT_CAP_LINK_DECLAR2
),
5361 gShellDebug1HiiHandle
,
5363 Header
->LinkEntry
[LinkCount
]
5368 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5369 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_LINK_DECLARATION
) + (PCI_EXPRESS_EXTENDED_CAPABILITY_LINK_DECLARATION_GET_LINK_COUNT(Header
)-1)*sizeof(UINT32
),
5370 (VOID
*) (HeaderAddress
)
5372 return (EFI_SUCCESS
);
5376 Function to interpret and print out the Advanced Error Reporting structure
5378 @param[in] HeaderAddress The Address of this capability header.
5379 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5382 PrintInterpretedExtendedCompatibilityAer (
5383 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5384 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5387 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_ADVANCED_ERROR_REPORTING
*Header
;
5388 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_ADVANCED_ERROR_REPORTING
*)HeaderAddress
;
5392 STRING_TOKEN (STR_PCI_EXT_CAP_AER
),
5393 gShellDebug1HiiHandle
,
5394 Header
->UncorrectableErrorStatus
,
5395 Header
->UncorrectableErrorMask
,
5396 Header
->UncorrectableErrorSeverity
,
5397 Header
->CorrectableErrorStatus
,
5398 Header
->CorrectableErrorMask
,
5399 Header
->AdvancedErrorCapabilitiesAndControl
,
5400 Header
->HeaderLog
[0],
5401 Header
->HeaderLog
[1],
5402 Header
->HeaderLog
[2],
5403 Header
->HeaderLog
[3],
5404 Header
->RootErrorCommand
,
5405 Header
->RootErrorStatus
,
5406 Header
->ErrorSourceIdentification
,
5407 Header
->CorrectableErrorSourceIdentification
,
5408 Header
->TlpPrefixLog
[0],
5409 Header
->TlpPrefixLog
[1],
5410 Header
->TlpPrefixLog
[2],
5411 Header
->TlpPrefixLog
[3]
5415 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5416 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_ADVANCED_ERROR_REPORTING
),
5417 (VOID
*) (HeaderAddress
)
5419 return (EFI_SUCCESS
);
5423 Function to interpret and print out the multicast structure
5425 @param[in] HeaderAddress The Address of this capability header.
5426 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5427 @param[in] PciExpressCapPtr The address of the PCIe capabilities structure.
5430 PrintInterpretedExtendedCompatibilityMulticast (
5431 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5432 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
,
5433 IN CONST PCI_CAPABILITY_PCIEXP
*PciExpressCapPtr
5436 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_MULTICAST
*Header
;
5437 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_MULTICAST
*)HeaderAddress
;
5441 STRING_TOKEN (STR_PCI_EXT_CAP_MULTICAST
),
5442 gShellDebug1HiiHandle
,
5443 Header
->MultiCastCapability
,
5444 Header
->MulticastControl
,
5445 Header
->McBaseAddress
,
5446 Header
->McReceiveAddress
,
5448 Header
->McBlockUntranslated
,
5449 Header
->McOverlayBar
5454 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5455 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_MULTICAST
),
5456 (VOID
*) (HeaderAddress
)
5459 return (EFI_SUCCESS
);
5463 Function to interpret and print out the virtual channel and multi virtual channel structure
5465 @param[in] HeaderAddress The Address of this capability header.
5466 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5469 PrintInterpretedExtendedCompatibilityVirtualChannel (
5470 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5471 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5474 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_VIRTUAL_CHANNEL_CAPABILITY
*Header
;
5475 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_VIRTUAL_CHANNEL_VC
*CapabilityItem
;
5477 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_VIRTUAL_CHANNEL_CAPABILITY
*)HeaderAddress
;
5481 STRING_TOKEN (STR_PCI_EXT_CAP_VC_BASE
),
5482 gShellDebug1HiiHandle
,
5483 Header
->ExtendedVcCount
,
5484 Header
->PortVcCapability1
,
5485 Header
->PortVcCapability2
,
5486 Header
->VcArbTableOffset
,
5487 Header
->PortVcControl
,
5488 Header
->PortVcStatus
5490 for (ItemCount
= 0 ; ItemCount
< Header
->ExtendedVcCount
; ItemCount
++) {
5491 CapabilityItem
= &Header
->Capability
[ItemCount
];
5494 STRING_TOKEN (STR_PCI_EXT_CAP_VC_ITEM
),
5495 gShellDebug1HiiHandle
,
5497 CapabilityItem
->VcResourceCapability
,
5498 CapabilityItem
->PortArbTableOffset
,
5499 CapabilityItem
->VcResourceControl
,
5500 CapabilityItem
->VcResourceStatus
5506 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5507 sizeof (PCI_EXPRESS_EXTENDED_CAPABILITIES_VIRTUAL_CHANNEL_CAPABILITY
)
5508 + Header
->ExtendedVcCount
* sizeof (PCI_EXPRESS_EXTENDED_CAPABILITIES_VIRTUAL_CHANNEL_VC
),
5509 (VOID
*) (HeaderAddress
)
5512 return (EFI_SUCCESS
);
5516 Function to interpret and print out the resizeable bar structure
5518 @param[in] HeaderAddress The Address of this capability header.
5519 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5522 PrintInterpretedExtendedCompatibilityResizeableBar (
5523 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5524 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5527 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_RESIZABLE_BAR
*Header
;
5529 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_RESIZABLE_BAR
*)HeaderAddress
;
5531 for (ItemCount
= 0 ; ItemCount
< (UINT32
)GET_NUMBER_RESIZABLE_BARS(Header
) ; ItemCount
++) {
5534 STRING_TOKEN (STR_PCI_EXT_CAP_RESIZE_BAR
),
5535 gShellDebug1HiiHandle
,
5537 Header
->Capability
[ItemCount
].ResizableBarCapability
,
5538 Header
->Capability
[ItemCount
].ResizableBarControl
5544 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5545 (UINT32
)GET_NUMBER_RESIZABLE_BARS(Header
) * sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_RESIZABLE_BAR_ENTRY
),
5546 (VOID
*) (HeaderAddress
)
5549 return (EFI_SUCCESS
);
5553 Function to interpret and print out the TPH structure
5555 @param[in] HeaderAddress The Address of this capability header.
5556 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5559 PrintInterpretedExtendedCompatibilityTph (
5560 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5561 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5564 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_TPH
*Header
;
5565 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_TPH
*)HeaderAddress
;
5569 STRING_TOKEN (STR_PCI_EXT_CAP_TPH
),
5570 gShellDebug1HiiHandle
,
5571 Header
->TphRequesterCapability
,
5572 Header
->TphRequesterControl
5576 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)Header
->TphStTable
- (UINT8
*)HeadersBaseAddress
),
5577 GET_TPH_TABLE_SIZE(Header
),
5578 (VOID
*)Header
->TphStTable
5583 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5584 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_TPH
) + GET_TPH_TABLE_SIZE(Header
) - sizeof(UINT16
),
5585 (VOID
*) (HeaderAddress
)
5588 return (EFI_SUCCESS
);
5592 Function to interpret and print out the secondary PCIe capability structure
5594 @param[in] HeaderAddress The Address of this capability header.
5595 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5596 @param[in] PciExpressCapPtr The address of the PCIe capabilities structure.
5599 PrintInterpretedExtendedCompatibilitySecondary (
5600 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5601 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
,
5602 IN CONST PCI_CAPABILITY_PCIEXP
*PciExpressCap
5605 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_SECONDARY_PCIE
*Header
;
5606 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_SECONDARY_PCIE
*)HeaderAddress
;
5610 STRING_TOKEN (STR_PCI_EXT_CAP_SECONDARY
),
5611 gShellDebug1HiiHandle
,
5612 Header
->LinkControl3
.Uint32
,
5613 Header
->LaneErrorStatus
5617 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)Header
->EqualizationControl
- (UINT8
*)HeadersBaseAddress
),
5618 PciExpressCap
->LinkCapability
.Bits
.MaxLinkWidth
* sizeof (PCI_EXPRESS_REG_LANE_EQUALIZATION_CONTROL
),
5619 (VOID
*)Header
->EqualizationControl
5624 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5625 sizeof (PCI_EXPRESS_EXTENDED_CAPABILITIES_SECONDARY_PCIE
) - sizeof (Header
->EqualizationControl
)
5626 + PciExpressCap
->LinkCapability
.Bits
.MaxLinkWidth
* sizeof (PCI_EXPRESS_REG_LANE_EQUALIZATION_CONTROL
),
5627 (VOID
*) (HeaderAddress
)
5630 return (EFI_SUCCESS
);
5634 Display Pcie extended capability details
5636 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5637 @param[in] HeaderAddress The address of this capability header.
5638 @param[in] PciExpressCapPtr The address of the PCIe capabilities structure.
5641 PrintPciExtendedCapabilityDetails(
5642 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
,
5643 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5644 IN CONST PCI_CAPABILITY_PCIEXP
*PciExpressCapPtr
5647 switch (HeaderAddress
->CapabilityId
){
5648 case PCI_EXPRESS_EXTENDED_CAPABILITY_ADVANCED_ERROR_REPORTING_ID
:
5649 return PrintInterpretedExtendedCompatibilityAer(HeaderAddress
, HeadersBaseAddress
);
5650 case PCI_EXPRESS_EXTENDED_CAPABILITY_LINK_CONTROL_ID
:
5651 return PrintInterpretedExtendedCompatibilityLinkControl(HeaderAddress
, HeadersBaseAddress
);
5652 case PCI_EXPRESS_EXTENDED_CAPABILITY_LINK_DECLARATION_ID
:
5653 return PrintInterpretedExtendedCompatibilityLinkDeclaration(HeaderAddress
, HeadersBaseAddress
);
5654 case PCI_EXPRESS_EXTENDED_CAPABILITY_SERIAL_NUMBER_ID
:
5655 return PrintInterpretedExtendedCompatibilitySerialNumber(HeaderAddress
, HeadersBaseAddress
);
5656 case PCI_EXPRESS_EXTENDED_CAPABILITY_POWER_BUDGETING_ID
:
5657 return PrintInterpretedExtendedCompatibilityPowerBudgeting(HeaderAddress
, HeadersBaseAddress
);
5658 case PCI_EXPRESS_EXTENDED_CAPABILITY_ACS_EXTENDED_ID
:
5659 return PrintInterpretedExtendedCompatibilityAcs(HeaderAddress
, HeadersBaseAddress
);
5660 case PCI_EXPRESS_EXTENDED_CAPABILITY_LATENCE_TOLERANCE_REPORTING_ID
:
5661 return PrintInterpretedExtendedCompatibilityLatencyToleranceReporting(HeaderAddress
, HeadersBaseAddress
);
5662 case PCI_EXPRESS_EXTENDED_CAPABILITY_ARI_CAPABILITY_ID
:
5663 return PrintInterpretedExtendedCompatibilityAri(HeaderAddress
, HeadersBaseAddress
);
5664 case PCI_EXPRESS_EXTENDED_CAPABILITY_RCRB_HEADER_ID
:
5665 return PrintInterpretedExtendedCompatibilityRcrb(HeaderAddress
, HeadersBaseAddress
);
5666 case PCI_EXPRESS_EXTENDED_CAPABILITY_VENDOR_SPECIFIC_ID
:
5667 return PrintInterpretedExtendedCompatibilityVendorSpecific(HeaderAddress
, HeadersBaseAddress
);
5668 case PCI_EXPRESS_EXTENDED_CAPABILITY_DYNAMIC_POWER_ALLOCATION_ID
:
5669 return PrintInterpretedExtendedCompatibilityDynamicPowerAllocation(HeaderAddress
, HeadersBaseAddress
);
5670 case PCI_EXPRESS_EXTENDED_CAPABILITY_EVENT_COLLECTOR_ENDPOINT_ASSOCIATION_ID
:
5671 return PrintInterpretedExtendedCompatibilityECEA(HeaderAddress
, HeadersBaseAddress
);
5672 case PCI_EXPRESS_EXTENDED_CAPABILITY_VIRTUAL_CHANNEL_ID
:
5673 case PCI_EXPRESS_EXTENDED_CAPABILITY_MULTI_FUNCTION_VIRTUAL_CHANNEL_ID
:
5674 return PrintInterpretedExtendedCompatibilityVirtualChannel(HeaderAddress
, HeadersBaseAddress
);
5675 case PCI_EXPRESS_EXTENDED_CAPABILITY_MULTICAST_ID
:
5677 // should only be present if PCIE_CAP_DEVICEPORT_TYPE(PciExpressCapPtr->PcieCapReg) == 0100b, 0101b, or 0110b
5679 return PrintInterpretedExtendedCompatibilityMulticast(HeaderAddress
, HeadersBaseAddress
, PciExpressCapPtr
);
5680 case PCI_EXPRESS_EXTENDED_CAPABILITY_RESIZABLE_BAR_ID
:
5681 return PrintInterpretedExtendedCompatibilityResizeableBar(HeaderAddress
, HeadersBaseAddress
);
5682 case PCI_EXPRESS_EXTENDED_CAPABILITY_TPH_ID
:
5683 return PrintInterpretedExtendedCompatibilityTph(HeaderAddress
, HeadersBaseAddress
);
5684 case PCI_EXPRESS_EXTENDED_CAPABILITY_SECONDARY_PCIE_ID
:
5685 return PrintInterpretedExtendedCompatibilitySecondary(HeaderAddress
, HeadersBaseAddress
, PciExpressCapPtr
);
5687 ShellPrintEx (-1, -1,
5688 L
"Unknown PCIe extended capability ID (%04xh). No interpretation available.\r\n",
5689 HeaderAddress
->CapabilityId
5697 Display Pcie device structure.
5699 @param[in] PciExpressCap PCI Express capability buffer.
5700 @param[in] ExtendedConfigSpace PCI Express extended configuration space.
5701 @param[in] ExtendedCapability PCI Express extended capability ID to explain.
5704 PciExplainPciExpress (
5705 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
,
5706 IN UINT8
*ExtendedConfigSpace
,
5707 IN CONST UINT16 ExtendedCapability
5710 UINT8 DevicePortType
;
5714 PCI_EXP_EXT_HDR
*ExtHdr
;
5716 DevicePortType
= (UINT8
)PciExpressCap
->Capability
.Bits
.DevicePortType
;
5718 ShellPrintEx (-1, -1, L
"\r\nPci Express device capability structure:\r\n");
5720 for (Index
= 0; PcieExplainList
[Index
].Type
< PcieExplainTypeMax
; Index
++) {
5721 if (ShellGetExecutionBreakFlag()) {
5724 RegAddr
= (UINT8
*) PciExpressCap
+ PcieExplainList
[Index
].Offset
;
5725 switch (PcieExplainList
[Index
].Width
) {
5726 case FieldWidthUINT8
:
5727 RegValue
= *(UINT8
*) RegAddr
;
5729 case FieldWidthUINT16
:
5730 RegValue
= *(UINT16
*) RegAddr
;
5732 case FieldWidthUINT32
:
5733 RegValue
= *(UINT32
*) RegAddr
;
5739 ShellPrintHiiEx(-1, -1, NULL
,
5740 PcieExplainList
[Index
].Token
,
5741 gShellDebug1HiiHandle
,
5742 PcieExplainList
[Index
].Offset
,
5745 if (PcieExplainList
[Index
].Func
== NULL
) {
5748 switch (PcieExplainList
[Index
].Type
) {
5749 case PcieExplainTypeLink
:
5751 // Link registers should not be used by
5752 // a) Root Complex Integrated Endpoint
5753 // b) Root Complex Event Collector
5755 if (DevicePortType
== PCIE_DEVICE_PORT_TYPE_ROOT_COMPLEX_INTEGRATED_ENDPOINT
||
5756 DevicePortType
== PCIE_DEVICE_PORT_TYPE_ROOT_COMPLEX_EVENT_COLLECTOR
) {
5760 case PcieExplainTypeSlot
:
5762 // Slot registers are only valid for
5763 // a) Root Port of PCI Express Root Complex
5764 // b) Downstream Port of PCI Express Switch
5765 // and when SlotImplemented bit is set in PCIE cap register.
5767 if ((DevicePortType
!= PCIE_DEVICE_PORT_TYPE_ROOT_PORT
&&
5768 DevicePortType
!= PCIE_DEVICE_PORT_TYPE_DOWNSTREAM_PORT
) ||
5769 !PciExpressCap
->Capability
.Bits
.SlotImplemented
) {
5773 case PcieExplainTypeRoot
:
5775 // Root registers are only valid for
5776 // Root Port of PCI Express Root Complex
5778 if (DevicePortType
!= PCIE_DEVICE_PORT_TYPE_ROOT_PORT
) {
5785 PcieExplainList
[Index
].Func (PciExpressCap
);
5788 ExtHdr
= (PCI_EXP_EXT_HDR
*)ExtendedConfigSpace
;
5789 while (ExtHdr
->CapabilityId
!= 0 && ExtHdr
->CapabilityVersion
!= 0) {
5791 // Process this item
5793 if (ExtendedCapability
== 0xFFFF || ExtendedCapability
== ExtHdr
->CapabilityId
) {
5797 PrintPciExtendedCapabilityDetails((PCI_EXP_EXT_HDR
*)ExtendedConfigSpace
, ExtHdr
, PciExpressCap
);
5801 // Advance to the next item if it exists
5803 if (ExtHdr
->NextCapabilityOffset
!= 0) {
5804 ExtHdr
= (PCI_EXP_EXT_HDR
*)(ExtendedConfigSpace
+ ExtHdr
->NextCapabilityOffset
- EFI_PCIE_CAPABILITY_BASE_OFFSET
);