2 Main file for Pci shell Debug1 function.
4 Copyright (c) 2005 - 2017, 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 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include "UefiShellDebug1CommandsLib.h"
18 #include <Protocol/PciRootBridgeIo.h>
19 #include <Library/ShellLib.h>
20 #include <IndustryStandard/Pci.h>
21 #include <IndustryStandard/Acpi.h>
25 // Printable strings for Pci class code
28 CHAR16
*BaseClass
; // Pointer to the PCI base class string
29 CHAR16
*SubClass
; // Pointer to the PCI sub class string
30 CHAR16
*PIFClass
; // Pointer to the PCI programming interface string
34 // a structure holding a single entry, which also points to its lower level
37 typedef struct PCI_CLASS_ENTRY_TAG
{
38 UINT8 Code
; // Class, subclass or I/F code
39 CHAR16
*DescText
; // Description string
40 struct PCI_CLASS_ENTRY_TAG
*LowerLevelClass
; // Subclass or I/F if any
44 // Declarations of entries which contain printable strings for class codes
45 // in PCI configuration space
47 PCI_CLASS_ENTRY PCIBlankEntry
[];
48 PCI_CLASS_ENTRY PCISubClass_00
[];
49 PCI_CLASS_ENTRY PCISubClass_01
[];
50 PCI_CLASS_ENTRY PCISubClass_02
[];
51 PCI_CLASS_ENTRY PCISubClass_03
[];
52 PCI_CLASS_ENTRY PCISubClass_04
[];
53 PCI_CLASS_ENTRY PCISubClass_05
[];
54 PCI_CLASS_ENTRY PCISubClass_06
[];
55 PCI_CLASS_ENTRY PCISubClass_07
[];
56 PCI_CLASS_ENTRY PCISubClass_08
[];
57 PCI_CLASS_ENTRY PCISubClass_09
[];
58 PCI_CLASS_ENTRY PCISubClass_0a
[];
59 PCI_CLASS_ENTRY PCISubClass_0b
[];
60 PCI_CLASS_ENTRY PCISubClass_0c
[];
61 PCI_CLASS_ENTRY PCISubClass_0d
[];
62 PCI_CLASS_ENTRY PCISubClass_0e
[];
63 PCI_CLASS_ENTRY PCISubClass_0f
[];
64 PCI_CLASS_ENTRY PCISubClass_10
[];
65 PCI_CLASS_ENTRY PCISubClass_11
[];
66 PCI_CLASS_ENTRY PCISubClass_12
[];
67 PCI_CLASS_ENTRY PCISubClass_13
[];
68 PCI_CLASS_ENTRY PCIPIFClass_0100
[];
69 PCI_CLASS_ENTRY PCIPIFClass_0101
[];
70 PCI_CLASS_ENTRY PCIPIFClass_0105
[];
71 PCI_CLASS_ENTRY PCIPIFClass_0106
[];
72 PCI_CLASS_ENTRY PCIPIFClass_0107
[];
73 PCI_CLASS_ENTRY PCIPIFClass_0108
[];
74 PCI_CLASS_ENTRY PCIPIFClass_0109
[];
75 PCI_CLASS_ENTRY PCIPIFClass_0300
[];
76 PCI_CLASS_ENTRY PCIPIFClass_0604
[];
77 PCI_CLASS_ENTRY PCIPIFClass_0609
[];
78 PCI_CLASS_ENTRY PCIPIFClass_060b
[];
79 PCI_CLASS_ENTRY PCIPIFClass_0700
[];
80 PCI_CLASS_ENTRY PCIPIFClass_0701
[];
81 PCI_CLASS_ENTRY PCIPIFClass_0703
[];
82 PCI_CLASS_ENTRY PCIPIFClass_0800
[];
83 PCI_CLASS_ENTRY PCIPIFClass_0801
[];
84 PCI_CLASS_ENTRY PCIPIFClass_0802
[];
85 PCI_CLASS_ENTRY PCIPIFClass_0803
[];
86 PCI_CLASS_ENTRY PCIPIFClass_0904
[];
87 PCI_CLASS_ENTRY PCIPIFClass_0c00
[];
88 PCI_CLASS_ENTRY PCIPIFClass_0c03
[];
89 PCI_CLASS_ENTRY PCIPIFClass_0c07
[];
90 PCI_CLASS_ENTRY PCIPIFClass_0d01
[];
91 PCI_CLASS_ENTRY PCIPIFClass_0e00
[];
94 // Base class strings entries
96 PCI_CLASS_ENTRY gClassStringList
[] = {
104 L
"Mass Storage Controller",
109 L
"Network Controller",
114 L
"Display Controller",
119 L
"Multimedia Device",
124 L
"Memory Controller",
134 L
"Simple Communications Controllers",
139 L
"Base System Peripherals",
159 L
"Serial Bus Controllers",
164 L
"Wireless Controllers",
169 L
"Intelligent IO Controllers",
174 L
"Satellite Communications Controllers",
179 L
"Encryption/Decryption Controllers",
184 L
"Data Acquisition & Signal Processing Controllers",
189 L
"Processing Accelerators",
194 L
"Non-Essential Instrumentation",
199 L
"Device does not fit in any defined classes",
205 /* null string ends the list */NULL
210 // Subclass strings entries
212 PCI_CLASS_ENTRY PCIBlankEntry
[] = {
221 /* null string ends the list */NULL
225 PCI_CLASS_ENTRY PCISubClass_00
[] = {
228 L
"All devices other than VGA",
233 L
"VGA-compatible devices",
239 /* null string ends the list */NULL
243 PCI_CLASS_ENTRY PCISubClass_01
[] = {
256 L
"Floppy disk controller",
271 L
"ATA controller with ADMA interface",
276 L
"Serial ATA controller",
281 L
"Serial Attached SCSI (SAS) controller ",
286 L
"Non-volatile memory subsystem",
291 L
"Universal Flash Storage (UFS) controller ",
296 L
"Other mass storage controller",
302 /* null string ends the list */NULL
306 PCI_CLASS_ENTRY PCISubClass_02
[] = {
309 L
"Ethernet controller",
314 L
"Token ring controller",
334 L
"WorldFip controller",
339 L
"PICMG 2.14 Multi Computing",
344 L
"InfiniBand controller",
349 L
"Other network controller",
355 /* null string ends the list */NULL
359 PCI_CLASS_ENTRY PCISubClass_03
[] = {
362 L
"VGA/8514 controller",
377 L
"Other display controller",
383 /* null string ends the list */PCIBlankEntry
387 PCI_CLASS_ENTRY PCISubClass_04
[] = {
400 L
"Computer Telephony device",
405 L
"Mixed mode device",
410 L
"Other multimedia device",
416 /* null string ends the list */NULL
420 PCI_CLASS_ENTRY PCISubClass_05
[] = {
423 L
"RAM memory controller",
428 L
"Flash memory controller",
433 L
"Other memory controller",
439 /* null string ends the list */NULL
443 PCI_CLASS_ENTRY PCISubClass_06
[] = {
461 L
"PCI/Micro Channel bridge",
471 L
"PCI/PCMCIA bridge",
491 L
"Semi-transparent PCI-to-PCI bridge",
496 L
"InfiniBand-to-PCI host bridge",
501 L
"Advanced Switching to PCI host bridge",
506 L
"Other bridge type",
512 /* null string ends the list */NULL
516 PCI_CLASS_ENTRY PCISubClass_07
[] = {
519 L
"Serial controller",
529 L
"Multiport serial controller",
539 L
"GPIB (IEEE 488.1/2) controller",
549 L
"Other communication device",
555 /* null string ends the list */NULL
559 PCI_CLASS_ENTRY PCISubClass_08
[] = {
582 L
"Generic PCI Hot-Plug controller",
587 L
"SD Host controller",
597 L
"Root Complex Event Collector",
602 L
"Other system peripheral",
608 /* null string ends the list */NULL
612 PCI_CLASS_ENTRY PCISubClass_09
[] = {
615 L
"Keyboard controller",
630 L
"Scanner controller",
635 L
"Gameport controller",
640 L
"Other input controller",
646 /* null string ends the list */NULL
650 PCI_CLASS_ENTRY PCISubClass_0a
[] = {
653 L
"Generic docking station",
658 L
"Other type of docking station",
664 /* null string ends the list */NULL
668 PCI_CLASS_ENTRY PCISubClass_0b
[] = {
712 /* null string ends the list */NULL
716 PCI_CLASS_ENTRY PCISubClass_0c
[] = {
744 L
"System Management Bus",
759 L
"SERCOS Interface Standard (IEC 61491)",
775 /* null string ends the list */NULL
779 PCI_CLASS_ENTRY PCISubClass_0d
[] = {
782 L
"iRDA compatible controller",
807 L
"Ethernet (802.11a - 5 GHz)",
812 L
"Ethernet (802.11b - 2.4 GHz)",
817 L
"Other type of wireless controller",
823 /* null string ends the list */NULL
827 PCI_CLASS_ENTRY PCISubClass_0e
[] = {
836 /* null string ends the list */NULL
840 PCI_CLASS_ENTRY PCISubClass_0f
[] = {
863 L
"Other satellite communication controller",
869 /* null string ends the list */NULL
873 PCI_CLASS_ENTRY PCISubClass_10
[] = {
876 L
"Network & computing Encrypt/Decrypt",
881 L
"Entertainment Encrypt/Decrypt",
886 L
"Other Encrypt/Decrypt",
892 /* null string ends the list */NULL
896 PCI_CLASS_ENTRY PCISubClass_11
[] = {
904 L
"Performance Counters",
909 L
"Communications synchronization plus time and frequency test/measurement ",
919 L
"Other DAQ & SP controllers",
925 /* null string ends the list */NULL
929 PCI_CLASS_ENTRY PCISubClass_12
[] = {
932 L
"Processing Accelerator",
938 /* null string ends the list */NULL
942 PCI_CLASS_ENTRY PCISubClass_13
[] = {
945 L
"Non-Essential Instrumentation Function",
951 /* null string ends the list */NULL
956 // Programming Interface entries
958 PCI_CLASS_ENTRY PCIPIFClass_0100
[] = {
966 L
"SCSI storage device SOP using PQI",
971 L
"SCSI controller SOP using PQI",
976 L
"SCSI storage device and controller SOP using PQI",
981 L
"SCSI storage device SOP using NVMe",
987 /* null string ends the list */NULL
991 PCI_CLASS_ENTRY PCIPIFClass_0101
[] = {
1019 L
"OM-primary, OM-secondary",
1024 L
"PI-primary, OM-secondary",
1029 L
"OM/PI-primary, OM-secondary",
1039 L
"OM-primary, PI-secondary",
1044 L
"PI-primary, PI-secondary",
1049 L
"OM/PI-primary, PI-secondary",
1059 L
"OM-primary, OM/PI-secondary",
1064 L
"PI-primary, OM/PI-secondary",
1069 L
"OM/PI-primary, OM/PI-secondary",
1079 L
"Master, OM-primary",
1084 L
"Master, PI-primary",
1089 L
"Master, OM/PI-primary",
1094 L
"Master, OM-secondary",
1099 L
"Master, OM-primary, OM-secondary",
1104 L
"Master, PI-primary, OM-secondary",
1109 L
"Master, OM/PI-primary, OM-secondary",
1114 L
"Master, OM-secondary",
1119 L
"Master, OM-primary, PI-secondary",
1124 L
"Master, PI-primary, PI-secondary",
1129 L
"Master, OM/PI-primary, PI-secondary",
1134 L
"Master, OM-secondary",
1139 L
"Master, OM-primary, OM/PI-secondary",
1144 L
"Master, PI-primary, OM/PI-secondary",
1149 L
"Master, OM/PI-primary, OM/PI-secondary",
1155 /* null string ends the list */NULL
1159 PCI_CLASS_ENTRY PCIPIFClass_0105
[] = {
1167 L
"Continuous operation",
1173 /* null string ends the list */NULL
1177 PCI_CLASS_ENTRY PCIPIFClass_0106
[] = {
1190 L
"Serial Storage Bus",
1196 /* null string ends the list */NULL
1200 PCI_CLASS_ENTRY PCIPIFClass_0107
[] = {
1214 /* null string ends the list */NULL
1218 PCI_CLASS_ENTRY PCIPIFClass_0108
[] = {
1237 /* null string ends the list */NULL
1241 PCI_CLASS_ENTRY PCIPIFClass_0109
[] = {
1255 /* null string ends the list */NULL
1259 PCI_CLASS_ENTRY PCIPIFClass_0300
[] = {
1273 /* null string ends the list */NULL
1277 PCI_CLASS_ENTRY PCIPIFClass_0604
[] = {
1285 L
"Subtractive decode",
1291 /* null string ends the list */NULL
1295 PCI_CLASS_ENTRY PCIPIFClass_0609
[] = {
1298 L
"Primary PCI bus side facing the system host processor",
1303 L
"Secondary PCI bus side facing the system host processor",
1309 /* null string ends the list */NULL
1313 PCI_CLASS_ENTRY PCIPIFClass_060b
[] = {
1321 L
"ASI-SIG Defined Portal",
1327 /* null string ends the list */NULL
1331 PCI_CLASS_ENTRY PCIPIFClass_0700
[] = {
1334 L
"Generic XT-compatible",
1339 L
"16450-compatible",
1344 L
"16550-compatible",
1349 L
"16650-compatible",
1354 L
"16750-compatible",
1359 L
"16850-compatible",
1364 L
"16950-compatible",
1370 /* null string ends the list */NULL
1374 PCI_CLASS_ENTRY PCIPIFClass_0701
[] = {
1387 L
"ECP 1.X-compliant",
1397 L
"IEEE 1284 target (not a controller)",
1403 /* null string ends the list */NULL
1407 PCI_CLASS_ENTRY PCIPIFClass_0703
[] = {
1415 L
"Hayes-compatible 16450",
1420 L
"Hayes-compatible 16550",
1425 L
"Hayes-compatible 16650",
1430 L
"Hayes-compatible 16750",
1436 /* null string ends the list */NULL
1440 PCI_CLASS_ENTRY PCIPIFClass_0800
[] = {
1463 L
"IO(x) APIC interrupt controller",
1469 /* null string ends the list */NULL
1473 PCI_CLASS_ENTRY PCIPIFClass_0801
[] = {
1492 /* null string ends the list */NULL
1496 PCI_CLASS_ENTRY PCIPIFClass_0802
[] = {
1515 /* null string ends the list */NULL
1519 PCI_CLASS_ENTRY PCIPIFClass_0803
[] = {
1538 /* null string ends the list */NULL
1542 PCI_CLASS_ENTRY PCIPIFClass_0904
[] = {
1556 /* null string ends the list */NULL
1560 PCI_CLASS_ENTRY PCIPIFClass_0c00
[] = {
1568 L
"Using 1394 OpenHCI spec",
1574 /* null string ends the list */NULL
1578 PCI_CLASS_ENTRY PCIPIFClass_0c03
[] = {
1601 L
"No specific programming interface",
1606 L
"(Not Host Controller)",
1612 /* null string ends the list */NULL
1616 PCI_CLASS_ENTRY PCIPIFClass_0c07
[] = {
1624 L
"Keyboard Controller Style",
1635 /* null string ends the list */NULL
1639 PCI_CLASS_ENTRY PCIPIFClass_0d01
[] = {
1642 L
"Consumer IR controller",
1647 L
"UWB Radio controller",
1653 /* null string ends the list */NULL
1657 PCI_CLASS_ENTRY PCIPIFClass_0e00
[] = {
1660 L
"Message FIFO at offset 40h",
1671 /* null string ends the list */NULL
1677 Generates printable Unicode strings that represent PCI device class,
1678 subclass and programmed I/F based on a value passed to the function.
1680 @param[in] ClassCode Value representing the PCI "Class Code" register read from a
1681 PCI device. The encodings are:
1682 bits 23:16 - Base Class Code
1683 bits 15:8 - Sub-Class Code
1684 bits 7:0 - Programming Interface
1685 @param[in, out] ClassStrings Pointer of PCI_CLASS_STRINGS structure, which contains
1686 printable class strings corresponding to ClassCode. The
1687 caller must not modify the strings that are pointed by
1688 the fields in ClassStrings.
1691 PciGetClassStrings (
1692 IN UINT32 ClassCode
,
1693 IN OUT PCI_CLASS_STRINGS
*ClassStrings
1698 PCI_CLASS_ENTRY
*CurrentClass
;
1701 // Assume no strings found
1703 ClassStrings
->BaseClass
= L
"UNDEFINED";
1704 ClassStrings
->SubClass
= L
"UNDEFINED";
1705 ClassStrings
->PIFClass
= L
"UNDEFINED";
1707 CurrentClass
= gClassStringList
;
1708 Code
= (UINT8
) (ClassCode
>> 16);
1712 // Go through all entries of the base class, until the entry with a matching
1713 // base class code is found. If reaches an entry with a null description
1714 // text, the last entry is met, which means no text for the base class was
1715 // found, so no more action is needed.
1717 while (Code
!= CurrentClass
[Index
].Code
) {
1718 if (NULL
== CurrentClass
[Index
].DescText
) {
1725 // A base class was found. Assign description, and check if this class has
1726 // sub-class defined. If sub-class defined, no more action is needed,
1727 // otherwise, continue to find description for the sub-class code.
1729 ClassStrings
->BaseClass
= CurrentClass
[Index
].DescText
;
1730 if (NULL
== CurrentClass
[Index
].LowerLevelClass
) {
1734 // find Subclass entry
1736 CurrentClass
= CurrentClass
[Index
].LowerLevelClass
;
1737 Code
= (UINT8
) (ClassCode
>> 8);
1741 // Go through all entries of the sub-class, until the entry with a matching
1742 // sub-class code is found. If reaches an entry with a null description
1743 // text, the last entry is met, which means no text for the sub-class was
1744 // found, so no more action is needed.
1746 while (Code
!= CurrentClass
[Index
].Code
) {
1747 if (NULL
== CurrentClass
[Index
].DescText
) {
1754 // A class was found for the sub-class code. Assign description, and check if
1755 // this sub-class has programming interface defined. If no, no more action is
1756 // needed, otherwise, continue to find description for the programming
1759 ClassStrings
->SubClass
= CurrentClass
[Index
].DescText
;
1760 if (NULL
== CurrentClass
[Index
].LowerLevelClass
) {
1764 // Find programming interface entry
1766 CurrentClass
= CurrentClass
[Index
].LowerLevelClass
;
1767 Code
= (UINT8
) ClassCode
;
1771 // Go through all entries of the I/F entries, until the entry with a
1772 // matching I/F code is found. If reaches an entry with a null description
1773 // text, the last entry is met, which means no text was found, so no more
1774 // action is needed.
1776 while (Code
!= CurrentClass
[Index
].Code
) {
1777 if (NULL
== CurrentClass
[Index
].DescText
) {
1784 // A class was found for the I/F code. Assign description, done!
1786 ClassStrings
->PIFClass
= CurrentClass
[Index
].DescText
;
1791 Print strings that represent PCI device class, subclass and programmed I/F.
1793 @param[in] ClassCodePtr Points to the memory which stores register Class Code in PCI
1794 configuration space.
1795 @param[in] IncludePIF If the printed string should include the programming I/F part
1799 IN UINT8
*ClassCodePtr
,
1800 IN BOOLEAN IncludePIF
1804 PCI_CLASS_STRINGS ClassStrings
;
1807 ClassCode
|= (UINT32
)ClassCodePtr
[0];
1808 ClassCode
|= (UINT32
)(ClassCodePtr
[1] << 8);
1809 ClassCode
|= (UINT32
)(ClassCodePtr
[2] << 16);
1812 // Get name from class code
1814 PciGetClassStrings (ClassCode
, &ClassStrings
);
1818 // Print base class, sub class, and programming inferface name
1820 ShellPrintEx (-1, -1, L
"%s - %s - %s",
1821 ClassStrings
.BaseClass
,
1822 ClassStrings
.SubClass
,
1823 ClassStrings
.PIFClass
1828 // Only print base class and sub class name
1830 ShellPrintEx (-1, -1, L
"%s - %s",
1831 ClassStrings
.BaseClass
,
1832 ClassStrings
.SubClass
1838 This function finds out the protocol which is in charge of the given
1839 segment, and its bus range covers the current bus number. It lookes
1840 each instances of RootBridgeIoProtocol handle, until the one meets the
1843 @param[in] HandleBuf Buffer which holds all PCI_ROOT_BRIDIGE_IO_PROTOCOL handles.
1844 @param[in] HandleCount Count of all PCI_ROOT_BRIDIGE_IO_PROTOCOL handles.
1845 @param[in] Segment Segment number of device we are dealing with.
1846 @param[in] Bus Bus number of device we are dealing with.
1847 @param[out] IoDev Handle used to access configuration space of PCI device.
1849 @retval EFI_SUCCESS The command completed successfully.
1850 @retval EFI_INVALID_PARAMETER Invalid parameter.
1854 PciFindProtocolInterface (
1855 IN EFI_HANDLE
*HandleBuf
,
1856 IN UINTN HandleCount
,
1859 OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
**IoDev
1863 This function gets the protocol interface from the given handle, and
1864 obtains its address space descriptors.
1866 @param[in] Handle The PCI_ROOT_BRIDIGE_IO_PROTOCOL handle.
1867 @param[out] IoDev Handle used to access configuration space of PCI device.
1868 @param[out] Descriptors Points to the address space descriptors.
1870 @retval EFI_SUCCESS The command completed successfully
1873 PciGetProtocolAndResource (
1874 IN EFI_HANDLE Handle
,
1875 OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
**IoDev
,
1876 OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
**Descriptors
1880 This function get the next bus range of given address space descriptors.
1881 It also moves the pointer backward a node, to get prepared to be called
1884 @param[in, out] Descriptors Points to current position of a serial of address space
1886 @param[out] MinBus The lower range of bus number.
1887 @param[out] MaxBus The upper range of bus number.
1888 @param[out] IsEnd Meet end of the serial of descriptors.
1890 @retval EFI_SUCCESS The command completed successfully.
1893 PciGetNextBusRange (
1894 IN OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
**Descriptors
,
1901 Explain the data in PCI configuration space. The part which is common for
1902 PCI device and bridge is interpreted in this function. It calls other
1903 functions to interpret data unique for device or bridge.
1905 @param[in] ConfigSpace Data in PCI configuration space.
1906 @param[in] Address Address used to access configuration space of this PCI device.
1907 @param[in] IoDev Handle used to access configuration space of PCI device.
1908 @param[in] EnhancedDump The print format for the dump data.
1910 @retval EFI_SUCCESS The command completed successfully.
1914 IN PCI_CONFIG_SPACE
*ConfigSpace
,
1916 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
,
1917 IN CONST UINT16 EnhancedDump
1921 Explain the device specific part of data in PCI configuration space.
1923 @param[in] Device Data in PCI configuration space.
1924 @param[in] Address Address used to access configuration space of this PCI device.
1925 @param[in] IoDev Handle used to access configuration space of PCI device.
1927 @retval EFI_SUCCESS The command completed successfully.
1930 PciExplainDeviceData (
1931 IN PCI_DEVICE_HEADER_TYPE_REGION
*Device
,
1933 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
1937 Explain the bridge specific part of data in PCI configuration space.
1939 @param[in] Bridge Bridge specific data region in PCI configuration space.
1940 @param[in] Address Address used to access configuration space of this PCI device.
1941 @param[in] IoDev Handle used to access configuration space of PCI device.
1943 @retval EFI_SUCCESS The command completed successfully.
1946 PciExplainBridgeData (
1947 IN PCI_BRIDGE_CONTROL_REGISTER
*Bridge
,
1949 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
1953 Explain the Base Address Register(Bar) in PCI configuration space.
1955 @param[in] Bar Points to the Base Address Register intended to interpret.
1956 @param[in] Command Points to the register Command.
1957 @param[in] Address Address used to access configuration space of this PCI device.
1958 @param[in] IoDev Handle used to access configuration space of PCI device.
1959 @param[in, out] Index The Index.
1961 @retval EFI_SUCCESS The command completed successfully.
1968 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
,
1973 Explain the cardbus specific part of data in PCI configuration space.
1975 @param[in] CardBus CardBus specific region of PCI configuration space.
1976 @param[in] Address Address used to access configuration space of this PCI device.
1977 @param[in] IoDev Handle used to access configuration space of PCI device.
1979 @retval EFI_SUCCESS The command completed successfully.
1982 PciExplainCardBusData (
1983 IN PCI_CARDBUS_CONTROL_REGISTER
*CardBus
,
1985 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
1989 Explain each meaningful bit of register Status. The definition of Status is
1990 slightly different depending on the PCI header type.
1992 @param[in] Status Points to the content of register Status.
1993 @param[in] MainStatus Indicates if this register is main status(not secondary
1995 @param[in] HeaderType Header type of this PCI device.
1997 @retval EFI_SUCCESS The command completed successfully.
2002 IN BOOLEAN MainStatus
,
2003 IN PCI_HEADER_TYPE HeaderType
2007 Explain each meaningful bit of register Command.
2009 @param[in] Command Points to the content of register Command.
2011 @retval EFI_SUCCESS The command completed successfully.
2019 Explain each meaningful bit of register Bridge Control.
2021 @param[in] BridgeControl Points to the content of register Bridge Control.
2022 @param[in] HeaderType The headertype.
2024 @retval EFI_SUCCESS The command completed successfully.
2027 PciExplainBridgeControl (
2028 IN UINT16
*BridgeControl
,
2029 IN PCI_HEADER_TYPE HeaderType
2033 Print each capability structure.
2035 @param[in] IoDev The pointer to the deivce.
2036 @param[in] Address The address to start at.
2037 @param[in] CapPtr The offset from the address.
2038 @param[in] EnhancedDump The print format for the dump data.
2040 @retval EFI_SUCCESS The operation was successful.
2043 PciExplainCapabilityStruct (
2044 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
,
2047 IN CONST UINT16 EnhancedDump
2051 Display Pcie device structure.
2053 @param[in] IoDev The pointer to the root pci protocol.
2054 @param[in] Address The Address to start at.
2055 @param[in] CapabilityPtr The offset from the address to start.
2056 @param[in] EnhancedDump The print format for the dump data.
2058 @retval EFI_SUCCESS The command completed successfully.
2059 @retval @retval EFI_SUCCESS Pci express extend space IO is not suppoted.
2062 PciExplainPciExpress (
2063 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
,
2065 IN UINT8 CapabilityPtr
,
2066 IN CONST UINT16 EnhancedDump
2070 Print out information of the capability information.
2072 @param[in] PciExpressCap The pointer to the structure about the device.
2074 @retval EFI_SUCCESS The operation was successful.
2078 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2082 Print out information of the device capability information.
2084 @param[in] PciExpressCap The pointer to the structure about the device.
2086 @retval EFI_SUCCESS The operation was successful.
2089 ExplainPcieDeviceCap (
2090 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2094 Print out information of the device control information.
2096 @param[in] PciExpressCap The pointer to the structure about the device.
2098 @retval EFI_SUCCESS The operation was successful.
2101 ExplainPcieDeviceControl (
2102 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2106 Print out information of the device status information.
2108 @param[in] PciExpressCap The pointer to the structure about the device.
2110 @retval EFI_SUCCESS The operation was successful.
2113 ExplainPcieDeviceStatus (
2114 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2118 Print out information of the device link information.
2120 @param[in] PciExpressCap The pointer to the structure about the device.
2122 @retval EFI_SUCCESS The operation was successful.
2125 ExplainPcieLinkCap (
2126 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2130 Print out information of the device link control information.
2132 @param[in] PciExpressCap The pointer to the structure about the device.
2134 @retval EFI_SUCCESS The operation was successful.
2137 ExplainPcieLinkControl (
2138 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2142 Print out information of the device link status information.
2144 @param[in] PciExpressCap The pointer to the structure about the device.
2146 @retval EFI_SUCCESS The operation was successful.
2149 ExplainPcieLinkStatus (
2150 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2154 Print out information of the device slot information.
2156 @param[in] PciExpressCap The pointer to the structure about the device.
2158 @retval EFI_SUCCESS The operation was successful.
2161 ExplainPcieSlotCap (
2162 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2166 Print out information of the device slot control information.
2168 @param[in] PciExpressCap The pointer to the structure about the device.
2170 @retval EFI_SUCCESS The operation was successful.
2173 ExplainPcieSlotControl (
2174 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2178 Print out information of the device slot status information.
2180 @param[in] PciExpressCap The pointer to the structure about the device.
2182 @retval EFI_SUCCESS The operation was successful.
2185 ExplainPcieSlotStatus (
2186 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2190 Print out information of the device root information.
2192 @param[in] PciExpressCap The pointer to the structure about the device.
2194 @retval EFI_SUCCESS The operation was successful.
2197 ExplainPcieRootControl (
2198 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2202 Print out information of the device root capability information.
2204 @param[in] PciExpressCap The pointer to the structure about the device.
2206 @retval EFI_SUCCESS The operation was successful.
2209 ExplainPcieRootCap (
2210 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2214 Print out information of the device root status information.
2216 @param[in] PciExpressCap The pointer to the structure about the device.
2218 @retval EFI_SUCCESS The operation was successful.
2221 ExplainPcieRootStatus (
2222 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2225 typedef EFI_STATUS (*PCIE_EXPLAIN_FUNCTION
) (IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
);
2231 } PCIE_CAPREG_FIELD_WIDTH
;
2234 PcieExplainTypeCommon
,
2235 PcieExplainTypeDevice
,
2236 PcieExplainTypeLink
,
2237 PcieExplainTypeSlot
,
2238 PcieExplainTypeRoot
,
2240 } PCIE_EXPLAIN_TYPE
;
2246 PCIE_CAPREG_FIELD_WIDTH Width
;
2247 PCIE_EXPLAIN_FUNCTION Func
;
2248 PCIE_EXPLAIN_TYPE Type
;
2249 } PCIE_EXPLAIN_STRUCT
;
2251 PCIE_EXPLAIN_STRUCT PcieExplainList
[] = {
2253 STRING_TOKEN (STR_PCIEX_CAPABILITY_CAPID
),
2257 PcieExplainTypeCommon
2260 STRING_TOKEN (STR_PCIEX_NEXTCAP_PTR
),
2264 PcieExplainTypeCommon
2267 STRING_TOKEN (STR_PCIEX_CAP_REGISTER
),
2271 PcieExplainTypeCommon
2274 STRING_TOKEN (STR_PCIEX_DEVICE_CAP
),
2277 ExplainPcieDeviceCap
,
2278 PcieExplainTypeDevice
2281 STRING_TOKEN (STR_PCIEX_DEVICE_CONTROL
),
2284 ExplainPcieDeviceControl
,
2285 PcieExplainTypeDevice
2288 STRING_TOKEN (STR_PCIEX_DEVICE_STATUS
),
2291 ExplainPcieDeviceStatus
,
2292 PcieExplainTypeDevice
2295 STRING_TOKEN (STR_PCIEX_LINK_CAPABILITIES
),
2302 STRING_TOKEN (STR_PCIEX_LINK_CONTROL
),
2305 ExplainPcieLinkControl
,
2309 STRING_TOKEN (STR_PCIEX_LINK_STATUS
),
2312 ExplainPcieLinkStatus
,
2316 STRING_TOKEN (STR_PCIEX_SLOT_CAPABILITIES
),
2323 STRING_TOKEN (STR_PCIEX_SLOT_CONTROL
),
2326 ExplainPcieSlotControl
,
2330 STRING_TOKEN (STR_PCIEX_SLOT_STATUS
),
2333 ExplainPcieSlotStatus
,
2337 STRING_TOKEN (STR_PCIEX_ROOT_CONTROL
),
2340 ExplainPcieRootControl
,
2344 STRING_TOKEN (STR_PCIEX_RSVDP
),
2351 STRING_TOKEN (STR_PCIEX_ROOT_STATUS
),
2354 ExplainPcieRootStatus
,
2360 (PCIE_CAPREG_FIELD_WIDTH
)0,
2369 PCI_CONFIG_SPACE
*mConfigSpace
= NULL
;
2370 STATIC CONST SHELL_PARAM_ITEM ParamList
[] = {
2373 {L
"-ec", TypeValue
},
2377 CHAR16
*DevicePortTypeTable
[] = {
2378 L
"PCI Express Endpoint",
2379 L
"Legacy PCI Express Endpoint",
2382 L
"Root Port of PCI Express Root Complex",
2383 L
"Upstream Port of PCI Express Switch",
2384 L
"Downstream Port of PCI Express Switch",
2385 L
"PCI Express to PCI/PCI-X Bridge",
2386 L
"PCI/PCI-X to PCI Express Bridge",
2387 L
"Root Complex Integrated Endpoint",
2388 L
"Root Complex Event Collector"
2391 CHAR16
*L0sLatencyStrTable
[] = {
2393 L
"64ns to less than 128ns",
2394 L
"128ns to less than 256ns",
2395 L
"256ns to less than 512ns",
2396 L
"512ns to less than 1us",
2397 L
"1us to less than 2us",
2402 CHAR16
*L1LatencyStrTable
[] = {
2404 L
"1us to less than 2us",
2405 L
"2us to less than 4us",
2406 L
"4us to less than 8us",
2407 L
"8us to less than 16us",
2408 L
"16us to less than 32us",
2413 CHAR16
*ASPMCtrlStrTable
[] = {
2415 L
"L0s Entry Enabled",
2416 L
"L1 Entry Enabled",
2417 L
"L0s and L1 Entry Enabled"
2420 CHAR16
*SlotPwrLmtScaleTable
[] = {
2427 CHAR16
*IndicatorTable
[] = {
2436 Function for 'pci' command.
2438 @param[in] ImageHandle Handle to the Image (NULL if Internal).
2439 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
2443 ShellCommandRunPci (
2444 IN EFI_HANDLE ImageHandle
,
2445 IN EFI_SYSTEM_TABLE
*SystemTable
2453 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
;
2455 PCI_DEVICE_INDEPENDENT_REGION PciHeader
;
2456 PCI_CONFIG_SPACE ConfigSpace
;
2460 BOOLEAN ExplainData
;
2464 UINTN HandleBufSize
;
2465 EFI_HANDLE
*HandleBuf
;
2467 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*Descriptors
;
2471 LIST_ENTRY
*Package
;
2472 CHAR16
*ProblemParam
;
2473 SHELL_STATUS ShellStatus
;
2476 UINT16 EnhancedDump
;
2478 ShellStatus
= SHELL_SUCCESS
;
2479 Status
= EFI_SUCCESS
;
2486 // initialize the shell lib (we must be in non-auto-init...)
2488 Status
= ShellInitialize();
2489 ASSERT_EFI_ERROR(Status
);
2491 Status
= CommandInit();
2492 ASSERT_EFI_ERROR(Status
);
2495 // parse the command line
2497 Status
= ShellCommandLineParse (ParamList
, &Package
, &ProblemParam
, TRUE
);
2498 if (EFI_ERROR(Status
)) {
2499 if (Status
== EFI_VOLUME_CORRUPTED
&& ProblemParam
!= NULL
) {
2500 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellDebug1HiiHandle
, L
"pci", ProblemParam
);
2501 FreePool(ProblemParam
);
2502 ShellStatus
= SHELL_INVALID_PARAMETER
;
2508 if (ShellCommandLineGetCount(Package
) == 2) {
2509 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_FEW
), gShellDebug1HiiHandle
, L
"pci");
2510 ShellStatus
= SHELL_INVALID_PARAMETER
;
2514 if (ShellCommandLineGetCount(Package
) > 4) {
2515 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_MANY
), gShellDebug1HiiHandle
, L
"pci");
2516 ShellStatus
= SHELL_INVALID_PARAMETER
;
2519 if (ShellCommandLineGetFlag(Package
, L
"-ec") && ShellCommandLineGetValue(Package
, L
"-ec") == NULL
) {
2520 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_NO_VALUE
), gShellDebug1HiiHandle
, L
"pci", L
"-ec");
2521 ShellStatus
= SHELL_INVALID_PARAMETER
;
2524 if (ShellCommandLineGetFlag(Package
, L
"-s") && ShellCommandLineGetValue(Package
, L
"-s") == NULL
) {
2525 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_NO_VALUE
), gShellDebug1HiiHandle
, L
"pci", L
"-s");
2526 ShellStatus
= SHELL_INVALID_PARAMETER
;
2530 // Get all instances of PciRootBridgeIo. Allocate space for 1 EFI_HANDLE and
2531 // call LibLocateHandle(), if EFI_BUFFER_TOO_SMALL is returned, allocate enough
2532 // space for handles and call it again.
2534 HandleBufSize
= sizeof (EFI_HANDLE
);
2535 HandleBuf
= (EFI_HANDLE
*) AllocateZeroPool (HandleBufSize
);
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
,
2550 if (Status
== EFI_BUFFER_TOO_SMALL
) {
2551 HandleBuf
= ReallocatePool (sizeof (EFI_HANDLE
), HandleBufSize
, HandleBuf
);
2552 if (HandleBuf
== NULL
) {
2553 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_OUT_MEM
), gShellDebug1HiiHandle
, L
"pci");
2554 ShellStatus
= SHELL_OUT_OF_RESOURCES
;
2558 Status
= gBS
->LocateHandle (
2560 &gEfiPciRootBridgeIoProtocolGuid
,
2567 if (EFI_ERROR (Status
)) {
2568 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PCIRBIO_NF
), gShellDebug1HiiHandle
, L
"pci");
2569 ShellStatus
= SHELL_NOT_FOUND
;
2573 HandleCount
= HandleBufSize
/ sizeof (EFI_HANDLE
);
2575 // Argument Count == 1(no other argument): enumerate all pci functions
2577 if (ShellCommandLineGetCount(Package
) == 1) {
2578 gST
->ConOut
->QueryMode (
2580 gST
->ConOut
->Mode
->Mode
,
2587 if ((ScreenSize
& 1) == 1) {
2594 // For each handle, which decides a segment and a bus number range,
2595 // enumerate all devices on it.
2597 for (Index
= 0; Index
< HandleCount
; Index
++) {
2598 Status
= PciGetProtocolAndResource (
2603 if (EFI_ERROR (Status
)) {
2604 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_HANDLE_CFG_ERR
), gShellDebug1HiiHandle
, L
"pci");
2605 ShellStatus
= SHELL_NOT_FOUND
;
2609 // No document say it's impossible for a RootBridgeIo protocol handle
2610 // to have more than one address space descriptors, so find out every
2611 // bus range and for each of them do device enumeration.
2614 Status
= PciGetNextBusRange (&Descriptors
, &MinBus
, &MaxBus
, &IsEnd
);
2616 if (EFI_ERROR (Status
)) {
2617 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_BUS_RANGE_ERR
), gShellDebug1HiiHandle
, L
"pci");
2618 ShellStatus
= SHELL_NOT_FOUND
;
2626 for (Bus
= MinBus
; Bus
<= MaxBus
; Bus
++) {
2628 // For each devices, enumerate all functions it contains
2630 for (Device
= 0; Device
<= PCI_MAX_DEVICE
; Device
++) {
2632 // For each function, read its configuration space and print summary
2634 for (Func
= 0; Func
<= PCI_MAX_FUNC
; Func
++) {
2635 if (ShellGetExecutionBreakFlag ()) {
2636 ShellStatus
= SHELL_ABORTED
;
2639 Address
= EFI_PCI_ADDRESS (Bus
, Device
, Func
, 0);
2649 // If VendorId = 0xffff, there does not exist a device at this
2650 // location. For each device, if there is any function on it,
2651 // there must be 1 function at Function 0. So if Func = 0, there
2652 // will be no more functions in the same device, so we can break
2653 // loop to deal with the next device.
2655 if (PciHeader
.VendorId
== 0xffff && Func
== 0) {
2659 if (PciHeader
.VendorId
!= 0xffff) {
2662 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_TITLE
), gShellDebug1HiiHandle
);
2670 sizeof (PciHeader
) / sizeof (UINT32
),
2675 -1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_P1
), gShellDebug1HiiHandle
,
2676 IoDev
->SegmentNumber
,
2682 PciPrintClassCode (PciHeader
.ClassCode
, FALSE
);
2684 -1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_P2
), gShellDebug1HiiHandle
,
2687 PciHeader
.ClassCode
[0]
2691 if (ScreenCount
>= ScreenSize
&& ScreenSize
!= 0) {
2693 // If ScreenSize == 0 we have the console redirected so don't
2699 // If this is not a multi-function device, we can leave the loop
2700 // to deal with the next device.
2702 if (Func
== 0 && ((PciHeader
.HeaderType
& HEADER_TYPE_MULTI_FUNCTION
) == 0x00)) {
2710 // If Descriptor is NULL, Configuration() returns EFI_UNSUPPRORED,
2711 // we assume the bus range is 0~PCI_MAX_BUS. After enumerated all
2712 // devices on all bus, we can leave loop.
2714 if (Descriptors
== NULL
) {
2720 Status
= EFI_SUCCESS
;
2724 ExplainData
= FALSE
;
2729 if (ShellCommandLineGetFlag(Package
, L
"-i")) {
2733 Temp
= ShellCommandLineGetValue(Package
, L
"-s");
2736 // Input converted to hexadecimal number.
2738 if (!EFI_ERROR (ShellConvertStringToUint64 (Temp
, &RetVal
, TRUE
, TRUE
))) {
2739 Segment
= (UINT16
) RetVal
;
2741 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV_HEX
), gShellDebug1HiiHandle
, L
"pci", Temp
);
2742 ShellStatus
= SHELL_INVALID_PARAMETER
;
2748 // The first Argument(except "-i") is assumed to be Bus number, second
2749 // to be Device number, and third to be Func number.
2751 Temp
= ShellCommandLineGetRawValue(Package
, 1);
2754 // Input converted to hexadecimal number.
2756 if (!EFI_ERROR (ShellConvertStringToUint64 (Temp
, &RetVal
, TRUE
, TRUE
))) {
2757 Bus
= (UINT16
) RetVal
;
2759 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV_HEX
), gShellDebug1HiiHandle
, L
"pci", Temp
);
2760 ShellStatus
= SHELL_INVALID_PARAMETER
;
2764 if (Bus
> PCI_MAX_BUS
) {
2765 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV
), gShellDebug1HiiHandle
, L
"pci", Temp
);
2766 ShellStatus
= SHELL_INVALID_PARAMETER
;
2770 Temp
= ShellCommandLineGetRawValue(Package
, 2);
2773 // Input converted to hexadecimal number.
2775 if (!EFI_ERROR (ShellConvertStringToUint64 (Temp
, &RetVal
, TRUE
, TRUE
))) {
2776 Device
= (UINT16
) RetVal
;
2778 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV_HEX
), gShellDebug1HiiHandle
, L
"pci", Temp
);
2779 ShellStatus
= SHELL_INVALID_PARAMETER
;
2783 if (Device
> PCI_MAX_DEVICE
){
2784 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV
), gShellDebug1HiiHandle
, L
"pci", Temp
);
2785 ShellStatus
= SHELL_INVALID_PARAMETER
;
2790 Temp
= ShellCommandLineGetRawValue(Package
, 3);
2793 // Input converted to hexadecimal number.
2795 if (!EFI_ERROR (ShellConvertStringToUint64 (Temp
, &RetVal
, TRUE
, TRUE
))) {
2796 Func
= (UINT16
) RetVal
;
2798 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV_HEX
), gShellDebug1HiiHandle
, L
"pci", Temp
);
2799 ShellStatus
= SHELL_INVALID_PARAMETER
;
2803 if (Func
> PCI_MAX_FUNC
){
2804 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV
), gShellDebug1HiiHandle
, L
"pci", Temp
);
2805 ShellStatus
= SHELL_INVALID_PARAMETER
;
2811 // Find the protocol interface who's in charge of current segment, and its
2812 // bus range covers the current bus
2814 Status
= PciFindProtocolInterface (
2822 if (EFI_ERROR (Status
)) {
2824 -1, -1, NULL
, STRING_TOKEN (STR_PCI_NO_FIND
), gShellDebug1HiiHandle
, L
"pci",
2828 ShellStatus
= SHELL_NOT_FOUND
;
2832 Address
= EFI_PCI_ADDRESS (Bus
, Device
, Func
, 0);
2833 Status
= IoDev
->Pci
.Read (
2837 sizeof (ConfigSpace
),
2841 if (EFI_ERROR (Status
)) {
2842 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_NO_CFG
), gShellDebug1HiiHandle
, L
"pci");
2843 ShellStatus
= SHELL_ACCESS_DENIED
;
2847 mConfigSpace
= &ConfigSpace
;
2852 STRING_TOKEN (STR_PCI_INFO
),
2853 gShellDebug1HiiHandle
,
2865 // Dump standard header of configuration space
2867 SizeOfHeader
= sizeof (ConfigSpace
.Common
) + sizeof (ConfigSpace
.NonCommon
);
2869 DumpHex (2, 0, SizeOfHeader
, &ConfigSpace
);
2870 ShellPrintEx(-1,-1, L
"\r\n");
2873 // Dump device dependent Part of configuration space
2878 sizeof (ConfigSpace
) - SizeOfHeader
,
2883 // If "-i" appears in command line, interpret data in configuration space
2886 EnhancedDump
= 0xFFFF;
2887 if (ShellCommandLineGetFlag(Package
, L
"-ec")) {
2888 Temp
= ShellCommandLineGetValue(Package
, L
"-ec");
2889 ASSERT (Temp
!= NULL
);
2890 EnhancedDump
= (UINT16
) ShellHexStrToUintn (Temp
);
2892 Status
= PciExplainData (&ConfigSpace
, Address
, IoDev
, EnhancedDump
);
2896 if (HandleBuf
!= NULL
) {
2897 FreePool (HandleBuf
);
2899 if (Package
!= NULL
) {
2900 ShellCommandLineFreeVarList (Package
);
2902 mConfigSpace
= NULL
;
2907 This function finds out the protocol which is in charge of the given
2908 segment, and its bus range covers the current bus number. It lookes
2909 each instances of RootBridgeIoProtocol handle, until the one meets the
2912 @param[in] HandleBuf Buffer which holds all PCI_ROOT_BRIDIGE_IO_PROTOCOL handles.
2913 @param[in] HandleCount Count of all PCI_ROOT_BRIDIGE_IO_PROTOCOL handles.
2914 @param[in] Segment Segment number of device we are dealing with.
2915 @param[in] Bus Bus number of device we are dealing with.
2916 @param[out] IoDev Handle used to access configuration space of PCI device.
2918 @retval EFI_SUCCESS The command completed successfully.
2919 @retval EFI_INVALID_PARAMETER Invalid parameter.
2923 PciFindProtocolInterface (
2924 IN EFI_HANDLE
*HandleBuf
,
2925 IN UINTN HandleCount
,
2928 OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
**IoDev
2933 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*Descriptors
;
2939 // Go through all handles, until the one meets the criteria is found
2941 for (Index
= 0; Index
< HandleCount
; Index
++) {
2942 Status
= PciGetProtocolAndResource (HandleBuf
[Index
], IoDev
, &Descriptors
);
2943 if (EFI_ERROR (Status
)) {
2947 // When Descriptors == NULL, the Configuration() is not implemented,
2948 // so we only check the Segment number
2950 if (Descriptors
== NULL
&& Segment
== (*IoDev
)->SegmentNumber
) {
2954 if ((*IoDev
)->SegmentNumber
!= Segment
) {
2959 Status
= PciGetNextBusRange (&Descriptors
, &MinBus
, &MaxBus
, &IsEnd
);
2960 if (EFI_ERROR (Status
)) {
2968 if (MinBus
<= Bus
&& MaxBus
>= Bus
) {
2974 return EFI_NOT_FOUND
;
2978 This function gets the protocol interface from the given handle, and
2979 obtains its address space descriptors.
2981 @param[in] Handle The PCI_ROOT_BRIDIGE_IO_PROTOCOL handle.
2982 @param[out] IoDev Handle used to access configuration space of PCI device.
2983 @param[out] Descriptors Points to the address space descriptors.
2985 @retval EFI_SUCCESS The command completed successfully
2988 PciGetProtocolAndResource (
2989 IN EFI_HANDLE Handle
,
2990 OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
**IoDev
,
2991 OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
**Descriptors
2997 // Get inferface from protocol
2999 Status
= gBS
->HandleProtocol (
3001 &gEfiPciRootBridgeIoProtocolGuid
,
3005 if (EFI_ERROR (Status
)) {
3009 // Call Configuration() to get address space descriptors
3011 Status
= (*IoDev
)->Configuration (*IoDev
, (VOID
**)Descriptors
);
3012 if (Status
== EFI_UNSUPPORTED
) {
3013 *Descriptors
= NULL
;
3022 This function get the next bus range of given address space descriptors.
3023 It also moves the pointer backward a node, to get prepared to be called
3026 @param[in, out] Descriptors Points to current position of a serial of address space
3028 @param[out] MinBus The lower range of bus number.
3029 @param[out] MaxBus The upper range of bus number.
3030 @param[out] IsEnd Meet end of the serial of descriptors.
3032 @retval EFI_SUCCESS The command completed successfully.
3035 PciGetNextBusRange (
3036 IN OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
**Descriptors
,
3045 // When *Descriptors is NULL, Configuration() is not implemented, so assume
3046 // range is 0~PCI_MAX_BUS
3048 if ((*Descriptors
) == NULL
) {
3050 *MaxBus
= PCI_MAX_BUS
;
3054 // *Descriptors points to one or more address space descriptors, which
3055 // ends with a end tagged descriptor. Examine each of the descriptors,
3056 // if a bus typed one is found and its bus range covers bus, this handle
3057 // is the handle we are looking for.
3060 while ((*Descriptors
)->Desc
!= ACPI_END_TAG_DESCRIPTOR
) {
3061 if ((*Descriptors
)->ResType
== ACPI_ADDRESS_SPACE_TYPE_BUS
) {
3062 *MinBus
= (UINT16
) (*Descriptors
)->AddrRangeMin
;
3063 *MaxBus
= (UINT16
) (*Descriptors
)->AddrRangeMax
;
3065 return (EFI_SUCCESS
);
3071 if ((*Descriptors
)->Desc
== ACPI_END_TAG_DESCRIPTOR
) {
3079 Explain the data in PCI configuration space. The part which is common for
3080 PCI device and bridge is interpreted in this function. It calls other
3081 functions to interpret data unique for device or bridge.
3083 @param[in] ConfigSpace Data in PCI configuration space.
3084 @param[in] Address Address used to access configuration space of this PCI device.
3085 @param[in] IoDev Handle used to access configuration space of PCI device.
3086 @param[in] EnhancedDump The print format for the dump data.
3088 @retval EFI_SUCCESS The command completed successfully.
3092 IN PCI_CONFIG_SPACE
*ConfigSpace
,
3094 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
,
3095 IN CONST UINT16 EnhancedDump
3098 PCI_DEVICE_INDEPENDENT_REGION
*Common
;
3099 PCI_HEADER_TYPE HeaderType
;
3103 Common
= &(ConfigSpace
->Common
);
3105 ShellPrintEx (-1, -1, L
"\r\n");
3108 // Print Vendor Id and Device Id
3110 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_VID_DID
), gShellDebug1HiiHandle
,
3111 INDEX_OF (&(Common
->VendorId
)),
3113 INDEX_OF (&(Common
->DeviceId
)),
3118 // Print register Command
3120 PciExplainCommand (&(Common
->Command
));
3123 // Print register Status
3125 PciExplainStatus (&(Common
->Status
), TRUE
, PciUndefined
);
3128 // Print register Revision ID
3130 ShellPrintEx(-1, -1, L
"\r\n");
3131 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_RID
), gShellDebug1HiiHandle
,
3132 INDEX_OF (&(Common
->RevisionID
)),
3137 // Print register BIST
3139 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_BIST
), gShellDebug1HiiHandle
, INDEX_OF (&(Common
->BIST
)));
3140 if ((Common
->BIST
& BIT7
) != 0) {
3141 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_CAP
), gShellDebug1HiiHandle
, 0x0f & Common
->BIST
);
3143 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_CAP_NO
), gShellDebug1HiiHandle
);
3146 // Print register Cache Line Size
3148 ShellPrintHiiEx(-1, -1, NULL
,
3149 STRING_TOKEN (STR_PCI2_CACHE_LINE_SIZE
),
3150 gShellDebug1HiiHandle
,
3151 INDEX_OF (&(Common
->CacheLineSize
)),
3152 Common
->CacheLineSize
3156 // Print register Latency Timer
3158 ShellPrintHiiEx(-1, -1, NULL
,
3159 STRING_TOKEN (STR_PCI2_LATENCY_TIMER
),
3160 gShellDebug1HiiHandle
,
3161 INDEX_OF (&(Common
->LatencyTimer
)),
3162 Common
->LatencyTimer
3166 // Print register Header Type
3168 ShellPrintHiiEx(-1, -1, NULL
,
3169 STRING_TOKEN (STR_PCI2_HEADER_TYPE
),
3170 gShellDebug1HiiHandle
,
3171 INDEX_OF (&(Common
->HeaderType
)),
3175 if ((Common
->HeaderType
& BIT7
) != 0) {
3176 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MULTI_FUNCTION
), gShellDebug1HiiHandle
);
3179 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_SINGLE_FUNCTION
), gShellDebug1HiiHandle
);
3182 HeaderType
= (PCI_HEADER_TYPE
)(UINT8
) (Common
->HeaderType
& 0x7f);
3183 switch (HeaderType
) {
3185 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_PCI_DEVICE
), gShellDebug1HiiHandle
);
3189 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_P2P_BRIDGE
), gShellDebug1HiiHandle
);
3192 case PciCardBusBridge
:
3193 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_CARDBUS_BRIDGE
), gShellDebug1HiiHandle
);
3197 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RESERVED
), gShellDebug1HiiHandle
);
3198 HeaderType
= PciUndefined
;
3202 // Print register Class Code
3204 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_CLASS
), gShellDebug1HiiHandle
);
3205 PciPrintClassCode ((UINT8
*) Common
->ClassCode
, TRUE
);
3206 ShellPrintEx (-1, -1, L
"\r\n");
3208 if (ShellGetExecutionBreakFlag()) {
3213 // Interpret remaining part of PCI configuration header depending on
3217 Status
= EFI_SUCCESS
;
3218 switch (HeaderType
) {
3220 Status
= PciExplainDeviceData (
3221 &(ConfigSpace
->NonCommon
.Device
),
3225 CapPtr
= ConfigSpace
->NonCommon
.Device
.CapabilityPtr
;
3229 Status
= PciExplainBridgeData (
3230 &(ConfigSpace
->NonCommon
.Bridge
),
3234 CapPtr
= ConfigSpace
->NonCommon
.Bridge
.CapabilityPtr
;
3237 case PciCardBusBridge
:
3238 Status
= PciExplainCardBusData (
3239 &(ConfigSpace
->NonCommon
.CardBus
),
3243 CapPtr
= ConfigSpace
->NonCommon
.CardBus
.Cap_Ptr
;
3250 // If Status bit4 is 1, dump or explain capability structure
3252 if ((Common
->Status
) & EFI_PCI_STATUS_CAPABILITY
) {
3253 PciExplainCapabilityStruct (IoDev
, Address
, CapPtr
, EnhancedDump
);
3260 Explain the device specific part of data in PCI configuration space.
3262 @param[in] Device Data in PCI configuration space.
3263 @param[in] Address Address used to access configuration space of this PCI device.
3264 @param[in] IoDev Handle used to access configuration space of PCI device.
3266 @retval EFI_SUCCESS The command completed successfully.
3269 PciExplainDeviceData (
3270 IN PCI_DEVICE_HEADER_TYPE_REGION
*Device
,
3272 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
3281 // Print Base Address Registers(Bar). When Bar = 0, this Bar does not
3282 // exist. If these no Bar for this function, print "none", otherwise
3283 // list detail information about this Bar.
3285 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BASE_ADDR
), gShellDebug1HiiHandle
, INDEX_OF (Device
->Bar
));
3288 BarCount
= sizeof (Device
->Bar
) / sizeof (Device
->Bar
[0]);
3289 for (Index
= 0; Index
< BarCount
; Index
++) {
3290 if (Device
->Bar
[Index
] == 0) {
3296 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_START_TYPE
), gShellDebug1HiiHandle
);
3297 ShellPrintEx (-1, -1, L
" --------------------------------------------------------------------------");
3300 Status
= PciExplainBar (
3301 &(Device
->Bar
[Index
]),
3302 &(mConfigSpace
->Common
.Command
),
3308 if (EFI_ERROR (Status
)) {
3314 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NONE
), gShellDebug1HiiHandle
);
3317 ShellPrintEx (-1, -1, L
"\r\n --------------------------------------------------------------------------");
3321 // Print register Expansion ROM Base Address
3323 if ((Device
->ExpansionRomBar
& BIT0
) == 0) {
3324 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_EXPANSION_ROM_DISABLED
), gShellDebug1HiiHandle
, INDEX_OF (&(Device
->ExpansionRomBar
)));
3327 ShellPrintHiiEx(-1, -1, NULL
,
3328 STRING_TOKEN (STR_PCI2_EXPANSION_ROM_BASE
),
3329 gShellDebug1HiiHandle
,
3330 INDEX_OF (&(Device
->ExpansionRomBar
)),
3331 Device
->ExpansionRomBar
3335 // Print register Cardbus CIS ptr
3337 ShellPrintHiiEx(-1, -1, NULL
,
3338 STRING_TOKEN (STR_PCI2_CARDBUS_CIS
),
3339 gShellDebug1HiiHandle
,
3340 INDEX_OF (&(Device
->CISPtr
)),
3345 // Print register Sub-vendor ID and subsystem ID
3347 ShellPrintHiiEx(-1, -1, NULL
,
3348 STRING_TOKEN (STR_PCI2_SUB_VENDOR_ID
),
3349 gShellDebug1HiiHandle
,
3350 INDEX_OF (&(Device
->SubsystemVendorID
)),
3351 Device
->SubsystemVendorID
3354 ShellPrintHiiEx(-1, -1, NULL
,
3355 STRING_TOKEN (STR_PCI2_SUBSYSTEM_ID
),
3356 gShellDebug1HiiHandle
,
3357 INDEX_OF (&(Device
->SubsystemID
)),
3362 // Print register Capabilities Ptr
3364 ShellPrintHiiEx(-1, -1, NULL
,
3365 STRING_TOKEN (STR_PCI2_CAPABILITIES_PTR
),
3366 gShellDebug1HiiHandle
,
3367 INDEX_OF (&(Device
->CapabilityPtr
)),
3368 Device
->CapabilityPtr
3372 // Print register Interrupt Line and interrupt pin
3374 ShellPrintHiiEx(-1, -1, NULL
,
3375 STRING_TOKEN (STR_PCI2_INTERRUPT_LINE
),
3376 gShellDebug1HiiHandle
,
3377 INDEX_OF (&(Device
->InterruptLine
)),
3378 Device
->InterruptLine
3381 ShellPrintHiiEx(-1, -1, NULL
,
3382 STRING_TOKEN (STR_PCI2_INTERRUPT_PIN
),
3383 gShellDebug1HiiHandle
,
3384 INDEX_OF (&(Device
->InterruptPin
)),
3385 Device
->InterruptPin
3389 // Print register Min_Gnt and Max_Lat
3391 ShellPrintHiiEx(-1, -1, NULL
,
3392 STRING_TOKEN (STR_PCI2_MIN_GNT
),
3393 gShellDebug1HiiHandle
,
3394 INDEX_OF (&(Device
->MinGnt
)),
3398 ShellPrintHiiEx(-1, -1, NULL
,
3399 STRING_TOKEN (STR_PCI2_MAX_LAT
),
3400 gShellDebug1HiiHandle
,
3401 INDEX_OF (&(Device
->MaxLat
)),
3409 Explain the bridge specific part of data in PCI configuration space.
3411 @param[in] Bridge Bridge specific data region in PCI configuration space.
3412 @param[in] Address Address used to access configuration space of this PCI device.
3413 @param[in] IoDev Handle used to access configuration space of PCI device.
3415 @retval EFI_SUCCESS The command completed successfully.
3418 PciExplainBridgeData (
3419 IN PCI_BRIDGE_CONTROL_REGISTER
*Bridge
,
3421 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
3431 // Print Base Address Registers. When Bar = 0, this Bar does not
3432 // exist. If these no Bar for this function, print "none", otherwise
3433 // list detail information about this Bar.
3435 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BASE_ADDRESS
), gShellDebug1HiiHandle
, INDEX_OF (&(Bridge
->Bar
)));
3438 BarCount
= sizeof (Bridge
->Bar
) / sizeof (Bridge
->Bar
[0]);
3440 for (Index
= 0; Index
< BarCount
; Index
++) {
3441 if (Bridge
->Bar
[Index
] == 0) {
3447 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_START_TYPE_2
), gShellDebug1HiiHandle
);
3448 ShellPrintEx (-1, -1, L
" --------------------------------------------------------------------------");
3451 Status
= PciExplainBar (
3452 &(Bridge
->Bar
[Index
]),
3453 &(mConfigSpace
->Common
.Command
),
3459 if (EFI_ERROR (Status
)) {
3465 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NONE
), gShellDebug1HiiHandle
);
3467 ShellPrintEx (-1, -1, L
"\r\n --------------------------------------------------------------------------");
3471 // Expansion register ROM Base Address
3473 if ((Bridge
->ExpansionRomBAR
& BIT0
) == 0) {
3474 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NO_EXPANSION_ROM
), gShellDebug1HiiHandle
, INDEX_OF (&(Bridge
->ExpansionRomBAR
)));
3477 ShellPrintHiiEx(-1, -1, NULL
,
3478 STRING_TOKEN (STR_PCI2_EXPANSION_ROM_BASE_2
),
3479 gShellDebug1HiiHandle
,
3480 INDEX_OF (&(Bridge
->ExpansionRomBAR
)),
3481 Bridge
->ExpansionRomBAR
3485 // Print Bus Numbers(Primary, Secondary, and Subordinate
3487 ShellPrintHiiEx(-1, -1, NULL
,
3488 STRING_TOKEN (STR_PCI2_BUS_NUMBERS
),
3489 gShellDebug1HiiHandle
,
3490 INDEX_OF (&(Bridge
->PrimaryBus
)),
3491 INDEX_OF (&(Bridge
->SecondaryBus
)),
3492 INDEX_OF (&(Bridge
->SubordinateBus
))
3495 ShellPrintEx (-1, -1, L
" ------------------------------------------------------\r\n");
3497 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BRIDGE
), gShellDebug1HiiHandle
, Bridge
->PrimaryBus
);
3498 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BRIDGE
), gShellDebug1HiiHandle
, Bridge
->SecondaryBus
);
3499 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BRIDGE
), gShellDebug1HiiHandle
, Bridge
->SubordinateBus
);
3502 // Print register Secondary Latency Timer
3504 ShellPrintHiiEx(-1, -1, NULL
,
3505 STRING_TOKEN (STR_PCI2_SECONDARY_TIMER
),
3506 gShellDebug1HiiHandle
,
3507 INDEX_OF (&(Bridge
->SecondaryLatencyTimer
)),
3508 Bridge
->SecondaryLatencyTimer
3512 // Print register Secondary Status
3514 PciExplainStatus (&(Bridge
->SecondaryStatus
), FALSE
, PciP2pBridge
);
3517 // Print I/O and memory ranges this bridge forwards. There are 3 resource
3518 // types: I/O, memory, and pre-fetchable memory. For each resource type,
3519 // base and limit address are listed.
3521 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RESOURCE_TYPE
), gShellDebug1HiiHandle
);
3522 ShellPrintEx (-1, -1, L
"----------------------------------------------------------------------\r\n");
3527 IoAddress32
= (Bridge
->IoBaseUpper16
<< 16 | Bridge
->IoBase
<< 8);
3528 IoAddress32
&= 0xfffff000;
3529 ShellPrintHiiEx(-1, -1, NULL
,
3530 STRING_TOKEN (STR_PCI2_TWO_VARS
),
3531 gShellDebug1HiiHandle
,
3532 INDEX_OF (&(Bridge
->IoBase
)),
3536 IoAddress32
= (Bridge
->IoLimitUpper16
<< 16 | Bridge
->IoLimit
<< 8);
3537 IoAddress32
|= 0x00000fff;
3538 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_ONE_VAR
), gShellDebug1HiiHandle
, IoAddress32
);
3541 // Memory Base & Limit
3543 ShellPrintHiiEx(-1, -1, NULL
,
3544 STRING_TOKEN (STR_PCI2_MEMORY
),
3545 gShellDebug1HiiHandle
,
3546 INDEX_OF (&(Bridge
->MemoryBase
)),
3547 (Bridge
->MemoryBase
<< 16) & 0xfff00000
3550 ShellPrintHiiEx(-1, -1, NULL
,
3551 STRING_TOKEN (STR_PCI2_ONE_VAR
),
3552 gShellDebug1HiiHandle
,
3553 (Bridge
->MemoryLimit
<< 16) | 0x000fffff
3557 // Pre-fetch-able Memory Base & Limit
3559 ShellPrintHiiEx(-1, -1, NULL
,
3560 STRING_TOKEN (STR_PCI2_PREFETCHABLE
),
3561 gShellDebug1HiiHandle
,
3562 INDEX_OF (&(Bridge
->PrefetchableMemoryBase
)),
3563 Bridge
->PrefetchableBaseUpper32
,
3564 (Bridge
->PrefetchableMemoryBase
<< 16) & 0xfff00000
3567 ShellPrintHiiEx(-1, -1, NULL
,
3568 STRING_TOKEN (STR_PCI2_TWO_VARS_2
),
3569 gShellDebug1HiiHandle
,
3570 Bridge
->PrefetchableLimitUpper32
,
3571 (Bridge
->PrefetchableMemoryLimit
<< 16) | 0x000fffff
3575 // Print register Capabilities Pointer
3577 ShellPrintHiiEx(-1, -1, NULL
,
3578 STRING_TOKEN (STR_PCI2_CAPABILITIES_PTR_2
),
3579 gShellDebug1HiiHandle
,
3580 INDEX_OF (&(Bridge
->CapabilityPtr
)),
3581 Bridge
->CapabilityPtr
3585 // Print register Bridge Control
3587 PciExplainBridgeControl (&(Bridge
->BridgeControl
), PciP2pBridge
);
3590 // Print register Interrupt Line & PIN
3592 ShellPrintHiiEx(-1, -1, NULL
,
3593 STRING_TOKEN (STR_PCI2_INTERRUPT_LINE_2
),
3594 gShellDebug1HiiHandle
,
3595 INDEX_OF (&(Bridge
->InterruptLine
)),
3596 Bridge
->InterruptLine
3599 ShellPrintHiiEx(-1, -1, NULL
,
3600 STRING_TOKEN (STR_PCI2_INTERRUPT_PIN
),
3601 gShellDebug1HiiHandle
,
3602 INDEX_OF (&(Bridge
->InterruptPin
)),
3603 Bridge
->InterruptPin
3610 Explain the Base Address Register(Bar) in PCI configuration space.
3612 @param[in] Bar Points to the Base Address Register intended to interpret.
3613 @param[in] Command Points to the register Command.
3614 @param[in] Address Address used to access configuration space of this PCI device.
3615 @param[in] IoDev Handle used to access configuration space of PCI device.
3616 @param[in, out] Index The Index.
3618 @retval EFI_SUCCESS The command completed successfully.
3625 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
,
3646 // According the bar type, list detail about this bar, for example: 32 or
3647 // 64 bits; pre-fetchable or not.
3649 if ((*Bar
& BIT0
) == 0) {
3651 // This bar is of memory type
3655 if ((*Bar
& BIT1
) == 0 && (*Bar
& BIT2
) == 0) {
3656 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BAR
), gShellDebug1HiiHandle
, *Bar
& 0xfffffff0);
3657 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MEM
), gShellDebug1HiiHandle
);
3658 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_32_BITS
), gShellDebug1HiiHandle
);
3660 } else if ((*Bar
& BIT1
) == 0 && (*Bar
& BIT2
) != 0) {
3662 CopyMem (&Bar64
, Bar
, sizeof (UINT64
));
3663 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_ONE_VAR_2
), gShellDebug1HiiHandle
, (UINT32
) RShiftU64 ((Bar64
& 0xfffffffffffffff0ULL
), 32));
3664 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_ONE_VAR_3
), gShellDebug1HiiHandle
, (UINT32
) (Bar64
& 0xfffffffffffffff0ULL
));
3665 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MEM
), gShellDebug1HiiHandle
);
3666 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_64_BITS
), gShellDebug1HiiHandle
);
3674 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BAR
), gShellDebug1HiiHandle
, *Bar
& 0xfffffff0);
3675 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MEM_2
), gShellDebug1HiiHandle
);
3678 if ((*Bar
& BIT3
) == 0) {
3679 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NO
), gShellDebug1HiiHandle
);
3682 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_YES
), gShellDebug1HiiHandle
);
3687 // This bar is of io type
3690 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_ONE_VAR_4
), gShellDebug1HiiHandle
, *Bar
& 0xfffffffc);
3691 ShellPrintEx (-1, -1, L
"I/O ");
3695 // Get BAR length(or the amount of resource this bar demands for). To get
3696 // Bar length, first we should temporarily disable I/O and memory access
3697 // of this function(by set bits in the register Command), then write all
3698 // "1"s to this bar. The bar value read back is the amount of resource
3699 // this bar demands for.
3702 // Disable io & mem access
3704 OldCommand
= *Command
;
3705 NewCommand
= (UINT16
) (OldCommand
& 0xfffc);
3706 RegAddress
= Address
| INDEX_OF (Command
);
3707 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint16
, RegAddress
, 1, &NewCommand
);
3709 RegAddress
= Address
| INDEX_OF (Bar
);
3712 // Read after write the BAR to get the size
3716 NewBar32
= 0xffffffff;
3718 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint32
, RegAddress
, 1, &NewBar32
);
3719 IoDev
->Pci
.Read (IoDev
, EfiPciWidthUint32
, RegAddress
, 1, &NewBar32
);
3720 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint32
, RegAddress
, 1, &OldBar32
);
3723 NewBar32
= NewBar32
& 0xfffffff0;
3724 NewBar32
= (~NewBar32
) + 1;
3727 NewBar32
= NewBar32
& 0xfffffffc;
3728 NewBar32
= (~NewBar32
) + 1;
3729 NewBar32
= NewBar32
& 0x0000ffff;
3734 CopyMem (&OldBar64
, Bar
, sizeof (UINT64
));
3735 NewBar64
= 0xffffffffffffffffULL
;
3737 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint32
, RegAddress
, 2, &NewBar64
);
3738 IoDev
->Pci
.Read (IoDev
, EfiPciWidthUint32
, RegAddress
, 2, &NewBar64
);
3739 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint32
, RegAddress
, 2, &OldBar64
);
3742 NewBar64
= NewBar64
& 0xfffffffffffffff0ULL
;
3743 NewBar64
= (~NewBar64
) + 1;
3746 NewBar64
= NewBar64
& 0xfffffffffffffffcULL
;
3747 NewBar64
= (~NewBar64
) + 1;
3748 NewBar64
= NewBar64
& 0x000000000000ffff;
3752 // Enable io & mem access
3754 RegAddress
= Address
| INDEX_OF (Command
);
3755 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint16
, RegAddress
, 1, &OldCommand
);
3759 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NEWBAR_32
), gShellDebug1HiiHandle
, NewBar32
);
3760 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NEWBAR_32_2
), gShellDebug1HiiHandle
, NewBar32
+ (*Bar
& 0xfffffff0) - 1);
3763 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RSHIFT
), gShellDebug1HiiHandle
, (UINT32
) RShiftU64 (NewBar64
, 32));
3764 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RSHIFT
), gShellDebug1HiiHandle
, (UINT32
) NewBar64
);
3765 ShellPrintEx (-1, -1, L
" ");
3766 ShellPrintHiiEx(-1, -1, NULL
,
3767 STRING_TOKEN (STR_PCI2_RSHIFT
),
3768 gShellDebug1HiiHandle
,
3769 (UINT32
) RShiftU64 ((NewBar64
+ (Bar64
& 0xfffffffffffffff0ULL
) - 1), 32)
3771 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RSHIFT
), gShellDebug1HiiHandle
, (UINT32
) (NewBar64
+ (Bar64
& 0xfffffffffffffff0ULL
) - 1));
3775 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NEWBAR_32_3
), gShellDebug1HiiHandle
, NewBar32
);
3776 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NEWBAR_32_4
), gShellDebug1HiiHandle
, NewBar32
+ (*Bar
& 0xfffffffc) - 1);
3783 Explain the cardbus specific part of data in PCI configuration space.
3785 @param[in] CardBus CardBus specific region of PCI configuration space.
3786 @param[in] Address Address used to access configuration space of this PCI device.
3787 @param[in] IoDev Handle used to access configuration space of PCI device.
3789 @retval EFI_SUCCESS The command completed successfully.
3792 PciExplainCardBusData (
3793 IN PCI_CARDBUS_CONTROL_REGISTER
*CardBus
,
3795 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
3799 PCI_CARDBUS_DATA
*CardBusData
;
3801 ShellPrintHiiEx(-1, -1, NULL
,
3802 STRING_TOKEN (STR_PCI2_CARDBUS_SOCKET
),
3803 gShellDebug1HiiHandle
,
3804 INDEX_OF (&(CardBus
->CardBusSocketReg
)),
3805 CardBus
->CardBusSocketReg
3809 // Print Secondary Status
3811 PciExplainStatus (&(CardBus
->SecondaryStatus
), FALSE
, PciCardBusBridge
);
3814 // Print Bus Numbers(Primary bus number, CardBus bus number, and
3815 // Subordinate bus number
3817 ShellPrintHiiEx(-1, -1, NULL
,
3818 STRING_TOKEN (STR_PCI2_BUS_NUMBERS_2
),
3819 gShellDebug1HiiHandle
,
3820 INDEX_OF (&(CardBus
->PciBusNumber
)),
3821 INDEX_OF (&(CardBus
->CardBusBusNumber
)),
3822 INDEX_OF (&(CardBus
->SubordinateBusNumber
))
3825 ShellPrintEx (-1, -1, L
" ------------------------------------------------------\r\n");
3827 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_CARDBUS
), gShellDebug1HiiHandle
, CardBus
->PciBusNumber
);
3828 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_CARDBUS_2
), gShellDebug1HiiHandle
, CardBus
->CardBusBusNumber
);
3829 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_CARDBUS_3
), gShellDebug1HiiHandle
, CardBus
->SubordinateBusNumber
);
3832 // Print CardBus Latency Timer
3834 ShellPrintHiiEx(-1, -1, NULL
,
3835 STRING_TOKEN (STR_PCI2_CARDBUS_LATENCY
),
3836 gShellDebug1HiiHandle
,
3837 INDEX_OF (&(CardBus
->CardBusLatencyTimer
)),
3838 CardBus
->CardBusLatencyTimer
3842 // Print Memory/Io ranges this cardbus bridge forwards
3844 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RESOURCE_TYPE_2
), gShellDebug1HiiHandle
);
3845 ShellPrintEx (-1, -1, L
"----------------------------------------------------------------------\r\n");
3847 ShellPrintHiiEx(-1, -1, NULL
,
3848 STRING_TOKEN (STR_PCI2_MEM_3
),
3849 gShellDebug1HiiHandle
,
3850 INDEX_OF (&(CardBus
->MemoryBase0
)),
3851 CardBus
->BridgeControl
& BIT8
? L
" Prefetchable" : L
"Non-Prefetchable",
3852 CardBus
->MemoryBase0
& 0xfffff000,
3853 CardBus
->MemoryLimit0
| 0x00000fff
3856 ShellPrintHiiEx(-1, -1, NULL
,
3857 STRING_TOKEN (STR_PCI2_MEM_3
),
3858 gShellDebug1HiiHandle
,
3859 INDEX_OF (&(CardBus
->MemoryBase1
)),
3860 CardBus
->BridgeControl
& BIT9
? L
" Prefetchable" : L
"Non-Prefetchable",
3861 CardBus
->MemoryBase1
& 0xfffff000,
3862 CardBus
->MemoryLimit1
| 0x00000fff
3865 Io32Bit
= (BOOLEAN
) (CardBus
->IoBase0
& BIT0
);
3866 ShellPrintHiiEx(-1, -1, NULL
,
3867 STRING_TOKEN (STR_PCI2_IO_2
),
3868 gShellDebug1HiiHandle
,
3869 INDEX_OF (&(CardBus
->IoBase0
)),
3870 Io32Bit
? L
" 32 bit" : L
" 16 bit",
3871 CardBus
->IoBase0
& (Io32Bit
? 0xfffffffc : 0x0000fffc),
3872 (CardBus
->IoLimit0
& (Io32Bit
? 0xffffffff : 0x0000ffff)) | 0x00000003
3875 Io32Bit
= (BOOLEAN
) (CardBus
->IoBase1
& BIT0
);
3876 ShellPrintHiiEx(-1, -1, NULL
,
3877 STRING_TOKEN (STR_PCI2_IO_2
),
3878 gShellDebug1HiiHandle
,
3879 INDEX_OF (&(CardBus
->IoBase1
)),
3880 Io32Bit
? L
" 32 bit" : L
" 16 bit",
3881 CardBus
->IoBase1
& (Io32Bit
? 0xfffffffc : 0x0000fffc),
3882 (CardBus
->IoLimit1
& (Io32Bit
? 0xffffffff : 0x0000ffff)) | 0x00000003
3886 // Print register Interrupt Line & PIN
3888 ShellPrintHiiEx(-1, -1, NULL
,
3889 STRING_TOKEN (STR_PCI2_INTERRUPT_LINE_3
),
3890 gShellDebug1HiiHandle
,
3891 INDEX_OF (&(CardBus
->InterruptLine
)),
3892 CardBus
->InterruptLine
,
3893 INDEX_OF (&(CardBus
->InterruptPin
)),
3894 CardBus
->InterruptPin
3898 // Print register Bridge Control
3900 PciExplainBridgeControl (&(CardBus
->BridgeControl
), PciCardBusBridge
);
3903 // Print some registers in data region of PCI configuration space for cardbus
3904 // bridge. Fields include: Sub VendorId, Subsystem ID, and Legacy Mode Base
3907 CardBusData
= (PCI_CARDBUS_DATA
*) ((UINT8
*) CardBus
+ sizeof (PCI_CARDBUS_CONTROL_REGISTER
));
3909 ShellPrintHiiEx(-1, -1, NULL
,
3910 STRING_TOKEN (STR_PCI2_SUB_VENDOR_ID_2
),
3911 gShellDebug1HiiHandle
,
3912 INDEX_OF (&(CardBusData
->SubVendorId
)),
3913 CardBusData
->SubVendorId
,
3914 INDEX_OF (&(CardBusData
->SubSystemId
)),
3915 CardBusData
->SubSystemId
3918 ShellPrintHiiEx(-1, -1, NULL
,
3919 STRING_TOKEN (STR_PCI2_OPTIONAL
),
3920 gShellDebug1HiiHandle
,
3921 INDEX_OF (&(CardBusData
->LegacyBase
)),
3922 CardBusData
->LegacyBase
3929 Explain each meaningful bit of register Status. The definition of Status is
3930 slightly different depending on the PCI header type.
3932 @param[in] Status Points to the content of register Status.
3933 @param[in] MainStatus Indicates if this register is main status(not secondary
3935 @param[in] HeaderType Header type of this PCI device.
3937 @retval EFI_SUCCESS The command completed successfully.
3942 IN BOOLEAN MainStatus
,
3943 IN PCI_HEADER_TYPE HeaderType
3947 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_STATUS
), gShellDebug1HiiHandle
, INDEX_OF (Status
), *Status
);
3950 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_SECONDARY_STATUS
), gShellDebug1HiiHandle
, INDEX_OF (Status
), *Status
);
3953 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NEW_CAPABILITIES
), gShellDebug1HiiHandle
, (*Status
& BIT4
) != 0);
3956 // Bit 5 is meaningless for CardBus Bridge
3958 if (HeaderType
== PciCardBusBridge
) {
3959 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_66_CAPABLE
), gShellDebug1HiiHandle
, (*Status
& BIT5
) != 0);
3962 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_66_CAPABLE_2
), gShellDebug1HiiHandle
, (*Status
& BIT5
) != 0);
3965 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_FAST_BACK
), gShellDebug1HiiHandle
, (*Status
& BIT7
) != 0);
3967 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MASTER_DATA
), gShellDebug1HiiHandle
, (*Status
& BIT8
) != 0);
3969 // Bit 9 and bit 10 together decides the DEVSEL timing
3971 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_DEVSEL_TIMING
), gShellDebug1HiiHandle
);
3972 if ((*Status
& BIT9
) == 0 && (*Status
& BIT10
) == 0) {
3973 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_FAST
), gShellDebug1HiiHandle
);
3975 } else if ((*Status
& BIT9
) != 0 && (*Status
& BIT10
) == 0) {
3976 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MEDIUM
), gShellDebug1HiiHandle
);
3978 } else if ((*Status
& BIT9
) == 0 && (*Status
& BIT10
) != 0) {
3979 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_SLOW
), gShellDebug1HiiHandle
);
3982 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RESERVED_2
), gShellDebug1HiiHandle
);
3985 ShellPrintHiiEx(-1, -1, NULL
,
3986 STRING_TOKEN (STR_PCI2_SIGNALED_TARGET
),
3987 gShellDebug1HiiHandle
,
3988 (*Status
& BIT11
) != 0
3991 ShellPrintHiiEx(-1, -1, NULL
,
3992 STRING_TOKEN (STR_PCI2_RECEIVED_TARGET
),
3993 gShellDebug1HiiHandle
,
3994 (*Status
& BIT12
) != 0
3997 ShellPrintHiiEx(-1, -1, NULL
,
3998 STRING_TOKEN (STR_PCI2_RECEIVED_MASTER
),
3999 gShellDebug1HiiHandle
,
4000 (*Status
& BIT13
) != 0
4004 ShellPrintHiiEx(-1, -1, NULL
,
4005 STRING_TOKEN (STR_PCI2_SIGNALED_ERROR
),
4006 gShellDebug1HiiHandle
,
4007 (*Status
& BIT14
) != 0
4011 ShellPrintHiiEx(-1, -1, NULL
,
4012 STRING_TOKEN (STR_PCI2_RECEIVED_ERROR
),
4013 gShellDebug1HiiHandle
,
4014 (*Status
& BIT14
) != 0
4018 ShellPrintHiiEx(-1, -1, NULL
,
4019 STRING_TOKEN (STR_PCI2_DETECTED_ERROR
),
4020 gShellDebug1HiiHandle
,
4021 (*Status
& BIT15
) != 0
4028 Explain each meaningful bit of register Command.
4030 @param[in] Command Points to the content of register Command.
4032 @retval EFI_SUCCESS The command completed successfully.
4040 // Print the binary value of register Command
4042 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_COMMAND
), gShellDebug1HiiHandle
, INDEX_OF (Command
), *Command
);
4045 // Explain register Command bit by bit
4047 ShellPrintHiiEx(-1, -1, NULL
,
4048 STRING_TOKEN (STR_PCI2_SPACE_ACCESS_DENIED
),
4049 gShellDebug1HiiHandle
,
4050 (*Command
& BIT0
) != 0
4053 ShellPrintHiiEx(-1, -1, NULL
,
4054 STRING_TOKEN (STR_PCI2_MEMORY_SPACE
),
4055 gShellDebug1HiiHandle
,
4056 (*Command
& BIT1
) != 0
4059 ShellPrintHiiEx(-1, -1, NULL
,
4060 STRING_TOKEN (STR_PCI2_BEHAVE_BUS_MASTER
),
4061 gShellDebug1HiiHandle
,
4062 (*Command
& BIT2
) != 0
4065 ShellPrintHiiEx(-1, -1, NULL
,
4066 STRING_TOKEN (STR_PCI2_MONITOR_SPECIAL_CYCLE
),
4067 gShellDebug1HiiHandle
,
4068 (*Command
& BIT3
) != 0
4071 ShellPrintHiiEx(-1, -1, NULL
,
4072 STRING_TOKEN (STR_PCI2_MEM_WRITE_INVALIDATE
),
4073 gShellDebug1HiiHandle
,
4074 (*Command
& BIT4
) != 0
4077 ShellPrintHiiEx(-1, -1, NULL
,
4078 STRING_TOKEN (STR_PCI2_PALETTE_SNOOPING
),
4079 gShellDebug1HiiHandle
,
4080 (*Command
& BIT5
) != 0
4083 ShellPrintHiiEx(-1, -1, NULL
,
4084 STRING_TOKEN (STR_PCI2_ASSERT_PERR
),
4085 gShellDebug1HiiHandle
,
4086 (*Command
& BIT6
) != 0
4089 ShellPrintHiiEx(-1, -1, NULL
,
4090 STRING_TOKEN (STR_PCI2_DO_ADDR_STEPPING
),
4091 gShellDebug1HiiHandle
,
4092 (*Command
& BIT7
) != 0
4095 ShellPrintHiiEx(-1, -1, NULL
,
4096 STRING_TOKEN (STR_PCI2_SERR_DRIVER
),
4097 gShellDebug1HiiHandle
,
4098 (*Command
& BIT8
) != 0
4101 ShellPrintHiiEx(-1, -1, NULL
,
4102 STRING_TOKEN (STR_PCI2_FAST_BACK_2
),
4103 gShellDebug1HiiHandle
,
4104 (*Command
& BIT9
) != 0
4111 Explain each meaningful bit of register Bridge Control.
4113 @param[in] BridgeControl Points to the content of register Bridge Control.
4114 @param[in] HeaderType The headertype.
4116 @retval EFI_SUCCESS The command completed successfully.
4119 PciExplainBridgeControl (
4120 IN UINT16
*BridgeControl
,
4121 IN PCI_HEADER_TYPE HeaderType
4124 ShellPrintHiiEx(-1, -1, NULL
,
4125 STRING_TOKEN (STR_PCI2_BRIDGE_CONTROL
),
4126 gShellDebug1HiiHandle
,
4127 INDEX_OF (BridgeControl
),
4131 ShellPrintHiiEx(-1, -1, NULL
,
4132 STRING_TOKEN (STR_PCI2_PARITY_ERROR
),
4133 gShellDebug1HiiHandle
,
4134 (*BridgeControl
& BIT0
) != 0
4136 ShellPrintHiiEx(-1, -1, NULL
,
4137 STRING_TOKEN (STR_PCI2_SERR_ENABLE
),
4138 gShellDebug1HiiHandle
,
4139 (*BridgeControl
& BIT1
) != 0
4141 ShellPrintHiiEx(-1, -1, NULL
,
4142 STRING_TOKEN (STR_PCI2_ISA_ENABLE
),
4143 gShellDebug1HiiHandle
,
4144 (*BridgeControl
& BIT2
) != 0
4146 ShellPrintHiiEx(-1, -1, NULL
,
4147 STRING_TOKEN (STR_PCI2_VGA_ENABLE
),
4148 gShellDebug1HiiHandle
,
4149 (*BridgeControl
& BIT3
) != 0
4151 ShellPrintHiiEx(-1, -1, NULL
,
4152 STRING_TOKEN (STR_PCI2_MASTER_ABORT
),
4153 gShellDebug1HiiHandle
,
4154 (*BridgeControl
& BIT5
) != 0
4158 // Register Bridge Control has some slight differences between P2P bridge
4159 // and Cardbus bridge from bit 6 to bit 11.
4161 if (HeaderType
== PciP2pBridge
) {
4162 ShellPrintHiiEx(-1, -1, NULL
,
4163 STRING_TOKEN (STR_PCI2_SECONDARY_BUS_RESET
),
4164 gShellDebug1HiiHandle
,
4165 (*BridgeControl
& BIT6
) != 0
4167 ShellPrintHiiEx(-1, -1, NULL
,
4168 STRING_TOKEN (STR_PCI2_FAST_ENABLE
),
4169 gShellDebug1HiiHandle
,
4170 (*BridgeControl
& BIT7
) != 0
4172 ShellPrintHiiEx(-1, -1, NULL
,
4173 STRING_TOKEN (STR_PCI2_PRIMARY_DISCARD_TIMER
),
4174 gShellDebug1HiiHandle
,
4175 (*BridgeControl
& BIT8
)!=0 ? L
"2^10" : L
"2^15"
4177 ShellPrintHiiEx(-1, -1, NULL
,
4178 STRING_TOKEN (STR_PCI2_SECONDARY_DISCARD_TIMER
),
4179 gShellDebug1HiiHandle
,
4180 (*BridgeControl
& BIT9
)!=0 ? L
"2^10" : L
"2^15"
4182 ShellPrintHiiEx(-1, -1, NULL
,
4183 STRING_TOKEN (STR_PCI2_DISCARD_TIMER_STATUS
),
4184 gShellDebug1HiiHandle
,
4185 (*BridgeControl
& BIT10
) != 0
4187 ShellPrintHiiEx(-1, -1, NULL
,
4188 STRING_TOKEN (STR_PCI2_DISCARD_TIMER_SERR
),
4189 gShellDebug1HiiHandle
,
4190 (*BridgeControl
& BIT11
) != 0
4194 ShellPrintHiiEx(-1, -1, NULL
,
4195 STRING_TOKEN (STR_PCI2_CARDBUS_RESET
),
4196 gShellDebug1HiiHandle
,
4197 (*BridgeControl
& BIT6
) != 0
4199 ShellPrintHiiEx(-1, -1, NULL
,
4200 STRING_TOKEN (STR_PCI2_IREQ_ENABLE
),
4201 gShellDebug1HiiHandle
,
4202 (*BridgeControl
& BIT7
) != 0
4204 ShellPrintHiiEx(-1, -1, NULL
,
4205 STRING_TOKEN (STR_PCI2_WRITE_POSTING_ENABLE
),
4206 gShellDebug1HiiHandle
,
4207 (*BridgeControl
& BIT10
) != 0
4215 Print each capability structure.
4217 @param[in] IoDev The pointer to the deivce.
4218 @param[in] Address The address to start at.
4219 @param[in] CapPtr The offset from the address.
4220 @param[in] EnhancedDump The print format for the dump data.
4222 @retval EFI_SUCCESS The operation was successful.
4225 PciExplainCapabilityStruct (
4226 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
,
4229 IN CONST UINT16 EnhancedDump
4232 UINT8 CapabilityPtr
;
4233 UINT16 CapabilityEntry
;
4237 CapabilityPtr
= CapPtr
;
4240 // Go through the Capability list
4242 while ((CapabilityPtr
>= 0x40) && ((CapabilityPtr
& 0x03) == 0x00)) {
4243 RegAddress
= Address
+ CapabilityPtr
;
4244 IoDev
->Pci
.Read (IoDev
, EfiPciWidthUint16
, RegAddress
, 1, &CapabilityEntry
);
4246 CapabilityID
= (UINT8
) CapabilityEntry
;
4249 // Explain PciExpress data
4251 if (EFI_PCI_CAPABILITY_ID_PCIEXP
== CapabilityID
) {
4252 PciExplainPciExpress (IoDev
, Address
, CapabilityPtr
, EnhancedDump
);
4256 // Explain other capabilities here
4258 CapabilityPtr
= (UINT8
) (CapabilityEntry
>> 8);
4265 Print out information of the capability information.
4267 @param[in] PciExpressCap The pointer to the structure about the device.
4269 @retval EFI_SUCCESS The operation was successful.
4273 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4276 CHAR16
*DevicePortType
;
4278 ShellPrintEx (-1, -1,
4279 L
" Capability Version(3:0): %E0x%04x%N\r\n",
4280 PciExpressCap
->Capability
.Bits
.Version
4282 if (PciExpressCap
->Capability
.Bits
.DevicePortType
< ARRAY_SIZE (DevicePortTypeTable
)) {
4283 DevicePortType
= DevicePortTypeTable
[PciExpressCap
->Capability
.Bits
.DevicePortType
];
4285 DevicePortType
= L
"Unknown Type";
4287 ShellPrintEx (-1, -1,
4288 L
" Device/PortType(7:4): %E%s%N\r\n",
4292 // 'Slot Implemented' is only valid for:
4293 // a) Root Port of PCI Express Root Complex, or
4294 // b) Downstream Port of PCI Express Switch
4296 if (PciExpressCap
->Capability
.Bits
.DevicePortType
== PCIE_DEVICE_PORT_TYPE_ROOT_PORT
||
4297 PciExpressCap
->Capability
.Bits
.DevicePortType
== PCIE_DEVICE_PORT_TYPE_DOWNSTREAM_PORT
) {
4298 ShellPrintEx (-1, -1,
4299 L
" Slot Implemented(8): %E%d%N\r\n",
4300 PciExpressCap
->Capability
.Bits
.SlotImplemented
4303 ShellPrintEx (-1, -1,
4304 L
" Interrupt Message Number(13:9): %E0x%05x%N\r\n",
4305 PciExpressCap
->Capability
.Bits
.InterruptMessageNumber
4311 Print out information of the device capability information.
4313 @param[in] PciExpressCap The pointer to the structure about the device.
4315 @retval EFI_SUCCESS The operation was successful.
4318 ExplainPcieDeviceCap (
4319 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4322 UINT8 DevicePortType
;
4326 DevicePortType
= (UINT8
)PciExpressCap
->Capability
.Bits
.DevicePortType
;
4327 ShellPrintEx (-1, -1, L
" Max_Payload_Size Supported(2:0): ");
4328 if (PciExpressCap
->DeviceCapability
.Bits
.MaxPayloadSize
< 6) {
4329 ShellPrintEx (-1, -1, L
"%E%d bytes%N\r\n", 1 << (PciExpressCap
->DeviceCapability
.Bits
.MaxPayloadSize
+ 7));
4331 ShellPrintEx (-1, -1, L
"%EUnknown%N\r\n");
4333 ShellPrintEx (-1, -1,
4334 L
" Phantom Functions Supported(4:3): %E%d%N\r\n",
4335 PciExpressCap
->DeviceCapability
.Bits
.PhantomFunctions
4337 ShellPrintEx (-1, -1,
4338 L
" Extended Tag Field Supported(5): %E%d-bit Tag field supported%N\r\n",
4339 PciExpressCap
->DeviceCapability
.Bits
.ExtendedTagField
? 8 : 5
4342 // Endpoint L0s and L1 Acceptable Latency is only valid for Endpoint
4344 if (IS_PCIE_ENDPOINT (DevicePortType
)) {
4345 L0sLatency
= (UINT8
)PciExpressCap
->DeviceCapability
.Bits
.EndpointL0sAcceptableLatency
;
4346 L1Latency
= (UINT8
)PciExpressCap
->DeviceCapability
.Bits
.EndpointL1AcceptableLatency
;
4347 ShellPrintEx (-1, -1, L
" Endpoint L0s Acceptable Latency(8:6): ");
4348 if (L0sLatency
< 4) {
4349 ShellPrintEx (-1, -1, L
"%EMaximum of %d ns%N\r\n", 1 << (L0sLatency
+ 6));
4351 if (L0sLatency
< 7) {
4352 ShellPrintEx (-1, -1, L
"%EMaximum of %d us%N\r\n", 1 << (L0sLatency
- 3));
4354 ShellPrintEx (-1, -1, L
"%ENo limit%N\r\n");
4357 ShellPrintEx (-1, -1, L
" Endpoint L1 Acceptable Latency(11:9): ");
4358 if (L1Latency
< 7) {
4359 ShellPrintEx (-1, -1, L
"%EMaximum of %d us%N\r\n", 1 << (L1Latency
+ 1));
4361 ShellPrintEx (-1, -1, L
"%ENo limit%N\r\n");
4364 ShellPrintEx (-1, -1,
4365 L
" Role-based Error Reporting(15): %E%d%N\r\n",
4366 PciExpressCap
->DeviceCapability
.Bits
.RoleBasedErrorReporting
4369 // Only valid for Upstream Port:
4370 // a) Captured Slot Power Limit Value
4371 // b) Captured Slot Power Scale
4373 if (DevicePortType
== PCIE_DEVICE_PORT_TYPE_UPSTREAM_PORT
) {
4374 ShellPrintEx (-1, -1,
4375 L
" Captured Slot Power Limit Value(25:18): %E0x%02x%N\r\n",
4376 PciExpressCap
->DeviceCapability
.Bits
.CapturedSlotPowerLimitValue
4378 ShellPrintEx (-1, -1,
4379 L
" Captured Slot Power Limit Scale(27:26): %E%s%N\r\n",
4380 SlotPwrLmtScaleTable
[PciExpressCap
->DeviceCapability
.Bits
.CapturedSlotPowerLimitScale
]
4384 // Function Level Reset Capability is only valid for Endpoint
4386 if (IS_PCIE_ENDPOINT (DevicePortType
)) {
4387 ShellPrintEx (-1, -1,
4388 L
" Function Level Reset Capability(28): %E%d%N\r\n",
4389 PciExpressCap
->DeviceCapability
.Bits
.FunctionLevelReset
4396 Print out information of the device control information.
4398 @param[in] PciExpressCap The pointer to the structure about the device.
4400 @retval EFI_SUCCESS The operation was successful.
4403 ExplainPcieDeviceControl (
4404 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4407 ShellPrintEx (-1, -1,
4408 L
" Correctable Error Reporting Enable(0): %E%d%N\r\n",
4409 PciExpressCap
->DeviceControl
.Bits
.CorrectableError
4411 ShellPrintEx (-1, -1,
4412 L
" Non-Fatal Error Reporting Enable(1): %E%d%N\r\n",
4413 PciExpressCap
->DeviceControl
.Bits
.NonFatalError
4415 ShellPrintEx (-1, -1,
4416 L
" Fatal Error Reporting Enable(2): %E%d%N\r\n",
4417 PciExpressCap
->DeviceControl
.Bits
.FatalError
4419 ShellPrintEx (-1, -1,
4420 L
" Unsupported Request Reporting Enable(3): %E%d%N\r\n",
4421 PciExpressCap
->DeviceControl
.Bits
.UnsupportedRequest
4423 ShellPrintEx (-1, -1,
4424 L
" Enable Relaxed Ordering(4): %E%d%N\r\n",
4425 PciExpressCap
->DeviceControl
.Bits
.RelaxedOrdering
4427 ShellPrintEx (-1, -1, L
" Max_Payload_Size(7:5): ");
4428 if (PciExpressCap
->DeviceControl
.Bits
.MaxPayloadSize
< 6) {
4429 ShellPrintEx (-1, -1, L
"%E%d bytes%N\r\n", 1 << (PciExpressCap
->DeviceControl
.Bits
.MaxPayloadSize
+ 7));
4431 ShellPrintEx (-1, -1, L
"%EUnknown%N\r\n");
4433 ShellPrintEx (-1, -1,
4434 L
" Extended Tag Field Enable(8): %E%d%N\r\n",
4435 PciExpressCap
->DeviceControl
.Bits
.ExtendedTagField
4437 ShellPrintEx (-1, -1,
4438 L
" Phantom Functions Enable(9): %E%d%N\r\n",
4439 PciExpressCap
->DeviceControl
.Bits
.PhantomFunctions
4441 ShellPrintEx (-1, -1,
4442 L
" Auxiliary (AUX) Power PM Enable(10): %E%d%N\r\n",
4443 PciExpressCap
->DeviceControl
.Bits
.AuxPower
4445 ShellPrintEx (-1, -1,
4446 L
" Enable No Snoop(11): %E%d%N\r\n",
4447 PciExpressCap
->DeviceControl
.Bits
.NoSnoop
4449 ShellPrintEx (-1, -1, L
" Max_Read_Request_Size(14:12): ");
4450 if (PciExpressCap
->DeviceControl
.Bits
.MaxReadRequestSize
< 6) {
4451 ShellPrintEx (-1, -1, L
"%E%d bytes%N\r\n", 1 << (PciExpressCap
->DeviceControl
.Bits
.MaxReadRequestSize
+ 7));
4453 ShellPrintEx (-1, -1, L
"%EUnknown%N\r\n");
4456 // Read operation is only valid for PCI Express to PCI/PCI-X Bridges
4458 if (PciExpressCap
->Capability
.Bits
.DevicePortType
== PCIE_DEVICE_PORT_TYPE_PCIE_TO_PCI_BRIDGE
) {
4459 ShellPrintEx (-1, -1,
4460 L
" Bridge Configuration Retry Enable(15): %E%d%N\r\n",
4461 PciExpressCap
->DeviceControl
.Bits
.BridgeConfigurationRetryOrFunctionLevelReset
4468 Print out information of the device status information.
4470 @param[in] PciExpressCap The pointer to the structure about the device.
4472 @retval EFI_SUCCESS The operation was successful.
4475 ExplainPcieDeviceStatus (
4476 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4479 ShellPrintEx (-1, -1,
4480 L
" Correctable Error Detected(0): %E%d%N\r\n",
4481 PciExpressCap
->DeviceStatus
.Bits
.CorrectableError
4483 ShellPrintEx (-1, -1,
4484 L
" Non-Fatal Error Detected(1): %E%d%N\r\n",
4485 PciExpressCap
->DeviceStatus
.Bits
.NonFatalError
4487 ShellPrintEx (-1, -1,
4488 L
" Fatal Error Detected(2): %E%d%N\r\n",
4489 PciExpressCap
->DeviceStatus
.Bits
.FatalError
4491 ShellPrintEx (-1, -1,
4492 L
" Unsupported Request Detected(3): %E%d%N\r\n",
4493 PciExpressCap
->DeviceStatus
.Bits
.UnsupportedRequest
4495 ShellPrintEx (-1, -1,
4496 L
" AUX Power Detected(4): %E%d%N\r\n",
4497 PciExpressCap
->DeviceStatus
.Bits
.AuxPower
4499 ShellPrintEx (-1, -1,
4500 L
" Transactions Pending(5): %E%d%N\r\n",
4501 PciExpressCap
->DeviceStatus
.Bits
.TransactionsPending
4507 Print out information of the device link information.
4509 @param[in] PciExpressCap The pointer to the structure about the device.
4511 @retval EFI_SUCCESS The operation was successful.
4514 ExplainPcieLinkCap (
4515 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4518 CHAR16
*MaxLinkSpeed
;
4521 switch (PciExpressCap
->LinkCapability
.Bits
.MaxLinkSpeed
) {
4523 MaxLinkSpeed
= L
"2.5 GT/s";
4526 MaxLinkSpeed
= L
"5.0 GT/s";
4529 MaxLinkSpeed
= L
"8.0 GT/s";
4532 MaxLinkSpeed
= L
"Unknown";
4535 ShellPrintEx (-1, -1,
4536 L
" Maximum Link Speed(3:0): %E%s%N\r\n",
4539 ShellPrintEx (-1, -1,
4540 L
" Maximum Link Width(9:4): %Ex%d%N\r\n",
4541 PciExpressCap
->LinkCapability
.Bits
.MaxLinkWidth
4543 switch (PciExpressCap
->LinkCapability
.Bits
.Aspm
) {
4554 AspmValue
= L
"L0s and L1";
4557 AspmValue
= L
"Reserved";
4560 ShellPrintEx (-1, -1,
4561 L
" Active State Power Management Support(11:10): %E%s Supported%N\r\n",
4564 ShellPrintEx (-1, -1,
4565 L
" L0s Exit Latency(14:12): %E%s%N\r\n",
4566 L0sLatencyStrTable
[PciExpressCap
->LinkCapability
.Bits
.L0sExitLatency
]
4568 ShellPrintEx (-1, -1,
4569 L
" L1 Exit Latency(17:15): %E%s%N\r\n",
4570 L1LatencyStrTable
[PciExpressCap
->LinkCapability
.Bits
.L1ExitLatency
]
4572 ShellPrintEx (-1, -1,
4573 L
" Clock Power Management(18): %E%d%N\r\n",
4574 PciExpressCap
->LinkCapability
.Bits
.ClockPowerManagement
4576 ShellPrintEx (-1, -1,
4577 L
" Surprise Down Error Reporting Capable(19): %E%d%N\r\n",
4578 PciExpressCap
->LinkCapability
.Bits
.SurpriseDownError
4580 ShellPrintEx (-1, -1,
4581 L
" Data Link Layer Link Active Reporting Capable(20): %E%d%N\r\n",
4582 PciExpressCap
->LinkCapability
.Bits
.DataLinkLayerLinkActive
4584 ShellPrintEx (-1, -1,
4585 L
" Link Bandwidth Notification Capability(21): %E%d%N\r\n",
4586 PciExpressCap
->LinkCapability
.Bits
.LinkBandwidthNotification
4588 ShellPrintEx (-1, -1,
4589 L
" Port Number(31:24): %E0x%02x%N\r\n",
4590 PciExpressCap
->LinkCapability
.Bits
.PortNumber
4596 Print out information of the device link control information.
4598 @param[in] PciExpressCap The pointer to the structure about the device.
4600 @retval EFI_SUCCESS The operation was successful.
4603 ExplainPcieLinkControl (
4604 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4607 UINT8 DevicePortType
;
4609 DevicePortType
= (UINT8
)PciExpressCap
->Capability
.Bits
.DevicePortType
;
4610 ShellPrintEx (-1, -1,
4611 L
" Active State Power Management Control(1:0): %E%s%N\r\n",
4612 ASPMCtrlStrTable
[PciExpressCap
->LinkControl
.Bits
.AspmControl
]
4615 // RCB is not applicable to switches
4617 if (!IS_PCIE_SWITCH(DevicePortType
)) {
4618 ShellPrintEx (-1, -1,
4619 L
" Read Completion Boundary (RCB)(3): %E%d byte%N\r\n",
4620 1 << (PciExpressCap
->LinkControl
.Bits
.ReadCompletionBoundary
+ 6)
4624 // Link Disable is reserved on
4626 // b) PCI Express to PCI/PCI-X bridges
4627 // c) Upstream Ports of Switches
4629 if (!IS_PCIE_ENDPOINT (DevicePortType
) &&
4630 DevicePortType
!= PCIE_DEVICE_PORT_TYPE_UPSTREAM_PORT
&&
4631 DevicePortType
!= PCIE_DEVICE_PORT_TYPE_PCIE_TO_PCI_BRIDGE
) {
4632 ShellPrintEx (-1, -1,
4633 L
" Link Disable(4): %E%d%N\r\n",
4634 PciExpressCap
->LinkControl
.Bits
.LinkDisable
4637 ShellPrintEx (-1, -1,
4638 L
" Common Clock Configuration(6): %E%d%N\r\n",
4639 PciExpressCap
->LinkControl
.Bits
.CommonClockConfiguration
4641 ShellPrintEx (-1, -1,
4642 L
" Extended Synch(7): %E%d%N\r\n",
4643 PciExpressCap
->LinkControl
.Bits
.ExtendedSynch
4645 ShellPrintEx (-1, -1,
4646 L
" Enable Clock Power Management(8): %E%d%N\r\n",
4647 PciExpressCap
->LinkControl
.Bits
.ClockPowerManagement
4649 ShellPrintEx (-1, -1,
4650 L
" Hardware Autonomous Width Disable(9): %E%d%N\r\n",
4651 PciExpressCap
->LinkControl
.Bits
.HardwareAutonomousWidthDisable
4653 ShellPrintEx (-1, -1,
4654 L
" Link Bandwidth Management Interrupt Enable(10): %E%d%N\r\n",
4655 PciExpressCap
->LinkControl
.Bits
.LinkBandwidthManagementInterrupt
4657 ShellPrintEx (-1, -1,
4658 L
" Link Autonomous Bandwidth Interrupt Enable(11): %E%d%N\r\n",
4659 PciExpressCap
->LinkControl
.Bits
.LinkAutonomousBandwidthInterrupt
4665 Print out information of the device link status information.
4667 @param[in] PciExpressCap The pointer to the structure about the device.
4669 @retval EFI_SUCCESS The operation was successful.
4672 ExplainPcieLinkStatus (
4673 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4676 CHAR16
*CurLinkSpeed
;
4678 switch (PciExpressCap
->LinkStatus
.Bits
.CurrentLinkSpeed
) {
4680 CurLinkSpeed
= L
"2.5 GT/s";
4683 CurLinkSpeed
= L
"5.0 GT/s";
4686 CurLinkSpeed
= L
"8.0 GT/s";
4689 CurLinkSpeed
= L
"Reserved";
4692 ShellPrintEx (-1, -1,
4693 L
" Current Link Speed(3:0): %E%s%N\r\n",
4696 ShellPrintEx (-1, -1,
4697 L
" Negotiated Link Width(9:4): %Ex%d%N\r\n",
4698 PciExpressCap
->LinkStatus
.Bits
.NegotiatedLinkWidth
4700 ShellPrintEx (-1, -1,
4701 L
" Link Training(11): %E%d%N\r\n",
4702 PciExpressCap
->LinkStatus
.Bits
.LinkTraining
4704 ShellPrintEx (-1, -1,
4705 L
" Slot Clock Configuration(12): %E%d%N\r\n",
4706 PciExpressCap
->LinkStatus
.Bits
.SlotClockConfiguration
4708 ShellPrintEx (-1, -1,
4709 L
" Data Link Layer Link Active(13): %E%d%N\r\n",
4710 PciExpressCap
->LinkStatus
.Bits
.DataLinkLayerLinkActive
4712 ShellPrintEx (-1, -1,
4713 L
" Link Bandwidth Management Status(14): %E%d%N\r\n",
4714 PciExpressCap
->LinkStatus
.Bits
.LinkBandwidthManagement
4716 ShellPrintEx (-1, -1,
4717 L
" Link Autonomous Bandwidth Status(15): %E%d%N\r\n",
4718 PciExpressCap
->LinkStatus
.Bits
.LinkAutonomousBandwidth
4724 Print out information of the device slot information.
4726 @param[in] PciExpressCap The pointer to the structure about the device.
4728 @retval EFI_SUCCESS The operation was successful.
4731 ExplainPcieSlotCap (
4732 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4735 ShellPrintEx (-1, -1,
4736 L
" Attention Button Present(0): %E%d%N\r\n",
4737 PciExpressCap
->SlotCapability
.Bits
.AttentionButton
4739 ShellPrintEx (-1, -1,
4740 L
" Power Controller Present(1): %E%d%N\r\n",
4741 PciExpressCap
->SlotCapability
.Bits
.PowerController
4743 ShellPrintEx (-1, -1,
4744 L
" MRL Sensor Present(2): %E%d%N\r\n",
4745 PciExpressCap
->SlotCapability
.Bits
.MrlSensor
4747 ShellPrintEx (-1, -1,
4748 L
" Attention Indicator Present(3): %E%d%N\r\n",
4749 PciExpressCap
->SlotCapability
.Bits
.AttentionIndicator
4751 ShellPrintEx (-1, -1,
4752 L
" Power Indicator Present(4): %E%d%N\r\n",
4753 PciExpressCap
->SlotCapability
.Bits
.PowerIndicator
4755 ShellPrintEx (-1, -1,
4756 L
" Hot-Plug Surprise(5): %E%d%N\r\n",
4757 PciExpressCap
->SlotCapability
.Bits
.HotPlugSurprise
4759 ShellPrintEx (-1, -1,
4760 L
" Hot-Plug Capable(6): %E%d%N\r\n",
4761 PciExpressCap
->SlotCapability
.Bits
.HotPlugCapable
4763 ShellPrintEx (-1, -1,
4764 L
" Slot Power Limit Value(14:7): %E0x%02x%N\r\n",
4765 PciExpressCap
->SlotCapability
.Bits
.SlotPowerLimitValue
4767 ShellPrintEx (-1, -1,
4768 L
" Slot Power Limit Scale(16:15): %E%s%N\r\n",
4769 SlotPwrLmtScaleTable
[PciExpressCap
->SlotCapability
.Bits
.SlotPowerLimitScale
]
4771 ShellPrintEx (-1, -1,
4772 L
" Electromechanical Interlock Present(17): %E%d%N\r\n",
4773 PciExpressCap
->SlotCapability
.Bits
.ElectromechanicalInterlock
4775 ShellPrintEx (-1, -1,
4776 L
" No Command Completed Support(18): %E%d%N\r\n",
4777 PciExpressCap
->SlotCapability
.Bits
.NoCommandCompleted
4779 ShellPrintEx (-1, -1,
4780 L
" Physical Slot Number(31:19): %E%d%N\r\n",
4781 PciExpressCap
->SlotCapability
.Bits
.PhysicalSlotNumber
4788 Print out information of the device slot control information.
4790 @param[in] PciExpressCap The pointer to the structure about the device.
4792 @retval EFI_SUCCESS The operation was successful.
4795 ExplainPcieSlotControl (
4796 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4799 ShellPrintEx (-1, -1,
4800 L
" Attention Button Pressed Enable(0): %E%d%N\r\n",
4801 PciExpressCap
->SlotControl
.Bits
.AttentionButtonPressed
4803 ShellPrintEx (-1, -1,
4804 L
" Power Fault Detected Enable(1): %E%d%N\r\n",
4805 PciExpressCap
->SlotControl
.Bits
.PowerFaultDetected
4807 ShellPrintEx (-1, -1,
4808 L
" MRL Sensor Changed Enable(2): %E%d%N\r\n",
4809 PciExpressCap
->SlotControl
.Bits
.MrlSensorChanged
4811 ShellPrintEx (-1, -1,
4812 L
" Presence Detect Changed Enable(3): %E%d%N\r\n",
4813 PciExpressCap
->SlotControl
.Bits
.PresenceDetectChanged
4815 ShellPrintEx (-1, -1,
4816 L
" Command Completed Interrupt Enable(4): %E%d%N\r\n",
4817 PciExpressCap
->SlotControl
.Bits
.CommandCompletedInterrupt
4819 ShellPrintEx (-1, -1,
4820 L
" Hot-Plug Interrupt Enable(5): %E%d%N\r\n",
4821 PciExpressCap
->SlotControl
.Bits
.HotPlugInterrupt
4823 ShellPrintEx (-1, -1,
4824 L
" Attention Indicator Control(7:6): %E%s%N\r\n",
4826 PciExpressCap
->SlotControl
.Bits
.AttentionIndicator
]
4828 ShellPrintEx (-1, -1,
4829 L
" Power Indicator Control(9:8): %E%s%N\r\n",
4830 IndicatorTable
[PciExpressCap
->SlotControl
.Bits
.PowerIndicator
]
4832 ShellPrintEx (-1, -1, L
" Power Controller Control(10): %EPower ");
4834 PciExpressCap
->SlotControl
.Bits
.PowerController
) {
4835 ShellPrintEx (-1, -1, L
"Off%N\r\n");
4837 ShellPrintEx (-1, -1, L
"On%N\r\n");
4839 ShellPrintEx (-1, -1,
4840 L
" Electromechanical Interlock Control(11): %E%d%N\r\n",
4841 PciExpressCap
->SlotControl
.Bits
.ElectromechanicalInterlock
4843 ShellPrintEx (-1, -1,
4844 L
" Data Link Layer State Changed Enable(12): %E%d%N\r\n",
4845 PciExpressCap
->SlotControl
.Bits
.DataLinkLayerStateChanged
4851 Print out information of the device slot status information.
4853 @param[in] PciExpressCap The pointer to the structure about the device.
4855 @retval EFI_SUCCESS The operation was successful.
4858 ExplainPcieSlotStatus (
4859 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4862 ShellPrintEx (-1, -1,
4863 L
" Attention Button Pressed(0): %E%d%N\r\n",
4864 PciExpressCap
->SlotStatus
.Bits
.AttentionButtonPressed
4866 ShellPrintEx (-1, -1,
4867 L
" Power Fault Detected(1): %E%d%N\r\n",
4868 PciExpressCap
->SlotStatus
.Bits
.PowerFaultDetected
4870 ShellPrintEx (-1, -1,
4871 L
" MRL Sensor Changed(2): %E%d%N\r\n",
4872 PciExpressCap
->SlotStatus
.Bits
.MrlSensorChanged
4874 ShellPrintEx (-1, -1,
4875 L
" Presence Detect Changed(3): %E%d%N\r\n",
4876 PciExpressCap
->SlotStatus
.Bits
.PresenceDetectChanged
4878 ShellPrintEx (-1, -1,
4879 L
" Command Completed(4): %E%d%N\r\n",
4880 PciExpressCap
->SlotStatus
.Bits
.CommandCompleted
4882 ShellPrintEx (-1, -1, L
" MRL Sensor State(5): %EMRL ");
4884 PciExpressCap
->SlotStatus
.Bits
.MrlSensor
) {
4885 ShellPrintEx (-1, -1, L
" Opened%N\r\n");
4887 ShellPrintEx (-1, -1, L
" Closed%N\r\n");
4889 ShellPrintEx (-1, -1, L
" Presence Detect State(6): ");
4891 PciExpressCap
->SlotStatus
.Bits
.PresenceDetect
) {
4892 ShellPrintEx (-1, -1, L
"%ECard Present in slot%N\r\n");
4894 ShellPrintEx (-1, -1, L
"%ESlot Empty%N\r\n");
4896 ShellPrintEx (-1, -1, L
" Electromechanical Interlock Status(7): %EElectromechanical Interlock ");
4898 PciExpressCap
->SlotStatus
.Bits
.ElectromechanicalInterlock
) {
4899 ShellPrintEx (-1, -1, L
"Engaged%N\r\n");
4901 ShellPrintEx (-1, -1, L
"Disengaged%N\r\n");
4903 ShellPrintEx (-1, -1,
4904 L
" Data Link Layer State Changed(8): %E%d%N\r\n",
4905 PciExpressCap
->SlotStatus
.Bits
.DataLinkLayerStateChanged
4911 Print out information of the device root information.
4913 @param[in] PciExpressCap The pointer to the structure about the device.
4915 @retval EFI_SUCCESS The operation was successful.
4918 ExplainPcieRootControl (
4919 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4922 ShellPrintEx (-1, -1,
4923 L
" System Error on Correctable Error Enable(0): %E%d%N\r\n",
4924 PciExpressCap
->RootControl
.Bits
.SystemErrorOnCorrectableError
4926 ShellPrintEx (-1, -1,
4927 L
" System Error on Non-Fatal Error Enable(1): %E%d%N\r\n",
4928 PciExpressCap
->RootControl
.Bits
.SystemErrorOnNonFatalError
4930 ShellPrintEx (-1, -1,
4931 L
" System Error on Fatal Error Enable(2): %E%d%N\r\n",
4932 PciExpressCap
->RootControl
.Bits
.SystemErrorOnFatalError
4934 ShellPrintEx (-1, -1,
4935 L
" PME Interrupt Enable(3): %E%d%N\r\n",
4936 PciExpressCap
->RootControl
.Bits
.PmeInterrupt
4938 ShellPrintEx (-1, -1,
4939 L
" CRS Software Visibility Enable(4): %E%d%N\r\n",
4940 PciExpressCap
->RootControl
.Bits
.CrsSoftwareVisibility
4947 Print out information of the device root capability information.
4949 @param[in] PciExpressCap The pointer to the structure about the device.
4951 @retval EFI_SUCCESS The operation was successful.
4954 ExplainPcieRootCap (
4955 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4958 ShellPrintEx (-1, -1,
4959 L
" CRS Software Visibility(0): %E%d%N\r\n",
4960 PciExpressCap
->RootCapability
.Bits
.CrsSoftwareVisibility
4967 Print out information of the device root status information.
4969 @param[in] PciExpressCap The pointer to the structure about the device.
4971 @retval EFI_SUCCESS The operation was successful.
4974 ExplainPcieRootStatus (
4975 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4978 ShellPrintEx (-1, -1,
4979 L
" PME Requester ID(15:0): %E0x%04x%N\r\n",
4980 PciExpressCap
->RootStatus
.Bits
.PmeRequesterId
4982 ShellPrintEx (-1, -1,
4983 L
" PME Status(16): %E%d%N\r\n",
4984 PciExpressCap
->RootStatus
.Bits
.PmeStatus
4986 ShellPrintEx (-1, -1,
4987 L
" PME Pending(17): %E%d%N\r\n",
4988 PciExpressCap
->RootStatus
.Bits
.PmePending
4994 Function to interpret and print out the link control structure
4996 @param[in] HeaderAddress The Address of this capability header.
4997 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5000 PrintInterpretedExtendedCompatibilityLinkControl (
5001 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5002 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5005 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_INTERNAL_LINK_CONTROL
*Header
;
5006 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_INTERNAL_LINK_CONTROL
*)HeaderAddress
;
5010 STRING_TOKEN (STR_PCI_EXT_CAP_LINK_CONTROL
),
5011 gShellDebug1HiiHandle
,
5012 Header
->RootComplexLinkCapabilities
,
5013 Header
->RootComplexLinkControl
,
5014 Header
->RootComplexLinkStatus
5018 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5019 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_INTERNAL_LINK_CONTROL
),
5020 (VOID
*) (HeaderAddress
)
5022 return (EFI_SUCCESS
);
5026 Function to interpret and print out the power budgeting structure
5028 @param[in] HeaderAddress The Address of this capability header.
5029 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5032 PrintInterpretedExtendedCompatibilityPowerBudgeting (
5033 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5034 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5037 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_POWER_BUDGETING
*Header
;
5038 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_POWER_BUDGETING
*)HeaderAddress
;
5042 STRING_TOKEN (STR_PCI_EXT_CAP_POWER
),
5043 gShellDebug1HiiHandle
,
5046 Header
->PowerBudgetCapability
5050 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5051 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_POWER_BUDGETING
),
5052 (VOID
*) (HeaderAddress
)
5054 return (EFI_SUCCESS
);
5058 Function to interpret and print out the ACS structure
5060 @param[in] HeaderAddress The Address of this capability header.
5061 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5064 PrintInterpretedExtendedCompatibilityAcs (
5065 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5066 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5069 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_ACS_EXTENDED
*Header
;
5073 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_ACS_EXTENDED
*)HeaderAddress
;
5078 STRING_TOKEN (STR_PCI_EXT_CAP_ACS
),
5079 gShellDebug1HiiHandle
,
5080 Header
->AcsCapability
,
5083 if (PCI_EXPRESS_EXTENDED_CAPABILITY_ACS_EXTENDED_GET_EGRES_CONTROL(Header
)) {
5084 VectorSize
= PCI_EXPRESS_EXTENDED_CAPABILITY_ACS_EXTENDED_GET_EGRES_VECTOR_SIZE(Header
);
5085 if (VectorSize
== 0) {
5088 for (LoopCounter
= 0 ; LoopCounter
* 8 < VectorSize
; LoopCounter
++) {
5091 STRING_TOKEN (STR_PCI_EXT_CAP_ACS2
),
5092 gShellDebug1HiiHandle
,
5094 Header
->EgressControlVectorArray
[LoopCounter
]
5100 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5101 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_ACS_EXTENDED
) + (VectorSize
/ 8) - 1,
5102 (VOID
*) (HeaderAddress
)
5104 return (EFI_SUCCESS
);
5108 Function to interpret and print out the latency tolerance reporting structure
5110 @param[in] HeaderAddress The Address of this capability header.
5111 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5114 PrintInterpretedExtendedCompatibilityLatencyToleranceReporting (
5115 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5116 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5119 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_LATENCE_TOLERANCE_REPORTING
*Header
;
5120 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_LATENCE_TOLERANCE_REPORTING
*)HeaderAddress
;
5124 STRING_TOKEN (STR_PCI_EXT_CAP_LAT
),
5125 gShellDebug1HiiHandle
,
5126 Header
->MaxSnoopLatency
,
5127 Header
->MaxNoSnoopLatency
5131 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5132 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_LATENCE_TOLERANCE_REPORTING
),
5133 (VOID
*) (HeaderAddress
)
5135 return (EFI_SUCCESS
);
5139 Function to interpret and print out the serial number structure
5141 @param[in] HeaderAddress The Address of this capability header.
5142 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5145 PrintInterpretedExtendedCompatibilitySerialNumber (
5146 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5147 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5150 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_SERIAL_NUMBER
*Header
;
5151 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_SERIAL_NUMBER
*)HeaderAddress
;
5155 STRING_TOKEN (STR_PCI_EXT_CAP_SN
),
5156 gShellDebug1HiiHandle
,
5157 Header
->SerialNumber
5161 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5162 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_SERIAL_NUMBER
),
5163 (VOID
*) (HeaderAddress
)
5165 return (EFI_SUCCESS
);
5169 Function to interpret and print out the RCRB structure
5171 @param[in] HeaderAddress The Address of this capability header.
5172 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5175 PrintInterpretedExtendedCompatibilityRcrb (
5176 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5177 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5180 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_RCRB_HEADER
*Header
;
5181 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_RCRB_HEADER
*)HeaderAddress
;
5185 STRING_TOKEN (STR_PCI_EXT_CAP_RCRB
),
5186 gShellDebug1HiiHandle
,
5189 Header
->RcrbCapabilities
,
5194 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5195 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_RCRB_HEADER
),
5196 (VOID
*) (HeaderAddress
)
5198 return (EFI_SUCCESS
);
5202 Function to interpret and print out the vendor specific structure
5204 @param[in] HeaderAddress The Address of this capability header.
5205 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5208 PrintInterpretedExtendedCompatibilityVendorSpecific (
5209 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5210 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5213 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_VENDOR_SPECIFIC
*Header
;
5214 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_VENDOR_SPECIFIC
*)HeaderAddress
;
5218 STRING_TOKEN (STR_PCI_EXT_CAP_VEN
),
5219 gShellDebug1HiiHandle
,
5220 Header
->VendorSpecificHeader
5224 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5225 PCI_EXPRESS_EXTENDED_CAPABILITY_VENDOR_SPECIFIC_GET_SIZE(Header
),
5226 (VOID
*) (HeaderAddress
)
5228 return (EFI_SUCCESS
);
5232 Function to interpret and print out the Event Collector Endpoint Association structure
5234 @param[in] HeaderAddress The Address of this capability header.
5235 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5238 PrintInterpretedExtendedCompatibilityECEA (
5239 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5240 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5243 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_EVENT_COLLECTOR_ENDPOINT_ASSOCIATION
*Header
;
5244 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_EVENT_COLLECTOR_ENDPOINT_ASSOCIATION
*)HeaderAddress
;
5248 STRING_TOKEN (STR_PCI_EXT_CAP_ECEA
),
5249 gShellDebug1HiiHandle
,
5250 Header
->AssociationBitmap
5254 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5255 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_EVENT_COLLECTOR_ENDPOINT_ASSOCIATION
),
5256 (VOID
*) (HeaderAddress
)
5258 return (EFI_SUCCESS
);
5262 Function to interpret and print out the ARI structure
5264 @param[in] HeaderAddress The Address of this capability header.
5265 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5268 PrintInterpretedExtendedCompatibilityAri (
5269 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5270 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5273 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_ARI_CAPABILITY
*Header
;
5274 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_ARI_CAPABILITY
*)HeaderAddress
;
5278 STRING_TOKEN (STR_PCI_EXT_CAP_ARI
),
5279 gShellDebug1HiiHandle
,
5280 Header
->AriCapability
,
5285 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5286 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_ARI_CAPABILITY
),
5287 (VOID
*) (HeaderAddress
)
5289 return (EFI_SUCCESS
);
5293 Function to interpret and print out the DPA structure
5295 @param[in] HeaderAddress The Address of this capability header.
5296 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5299 PrintInterpretedExtendedCompatibilityDynamicPowerAllocation (
5300 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5301 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5304 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_DYNAMIC_POWER_ALLOCATION
*Header
;
5306 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_DYNAMIC_POWER_ALLOCATION
*)HeaderAddress
;
5310 STRING_TOKEN (STR_PCI_EXT_CAP_DPA
),
5311 gShellDebug1HiiHandle
,
5312 Header
->DpaCapability
,
5313 Header
->DpaLatencyIndicator
,
5317 for (LinkCount
= 0 ; LinkCount
< PCI_EXPRESS_EXTENDED_CAPABILITY_DYNAMIC_POWER_ALLOCATION_GET_SUBSTATE_MAX(Header
) + 1 ; LinkCount
++) {
5320 STRING_TOKEN (STR_PCI_EXT_CAP_DPA2
),
5321 gShellDebug1HiiHandle
,
5323 Header
->DpaPowerAllocationArray
[LinkCount
]
5328 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5329 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_DYNAMIC_POWER_ALLOCATION
) - 1 + PCI_EXPRESS_EXTENDED_CAPABILITY_DYNAMIC_POWER_ALLOCATION_GET_SUBSTATE_MAX(Header
),
5330 (VOID
*) (HeaderAddress
)
5332 return (EFI_SUCCESS
);
5336 Function to interpret and print out the link declaration structure
5338 @param[in] HeaderAddress The Address of this capability header.
5339 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5342 PrintInterpretedExtendedCompatibilityLinkDeclaration (
5343 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5344 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5347 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_LINK_DECLARATION
*Header
;
5349 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_LINK_DECLARATION
*)HeaderAddress
;
5353 STRING_TOKEN (STR_PCI_EXT_CAP_LINK_DECLAR
),
5354 gShellDebug1HiiHandle
,
5355 Header
->ElementSelfDescription
5358 for (LinkCount
= 0 ; LinkCount
< PCI_EXPRESS_EXTENDED_CAPABILITY_LINK_DECLARATION_GET_LINK_COUNT(Header
) ; LinkCount
++) {
5361 STRING_TOKEN (STR_PCI_EXT_CAP_LINK_DECLAR2
),
5362 gShellDebug1HiiHandle
,
5364 Header
->LinkEntry
[LinkCount
]
5369 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5370 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_LINK_DECLARATION
) + (PCI_EXPRESS_EXTENDED_CAPABILITY_LINK_DECLARATION_GET_LINK_COUNT(Header
)-1)*sizeof(UINT32
),
5371 (VOID
*) (HeaderAddress
)
5373 return (EFI_SUCCESS
);
5377 Function to interpret and print out the Advanced Error Reporting structure
5379 @param[in] HeaderAddress The Address of this capability header.
5380 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5383 PrintInterpretedExtendedCompatibilityAer (
5384 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5385 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5388 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_ADVANCED_ERROR_REPORTING
*Header
;
5389 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_ADVANCED_ERROR_REPORTING
*)HeaderAddress
;
5393 STRING_TOKEN (STR_PCI_EXT_CAP_AER
),
5394 gShellDebug1HiiHandle
,
5395 Header
->UncorrectableErrorStatus
,
5396 Header
->UncorrectableErrorMask
,
5397 Header
->UncorrectableErrorSeverity
,
5398 Header
->CorrectableErrorStatus
,
5399 Header
->CorrectableErrorMask
,
5400 Header
->AdvancedErrorCapabilitiesAndControl
,
5401 Header
->HeaderLog
[0],
5402 Header
->HeaderLog
[1],
5403 Header
->HeaderLog
[2],
5404 Header
->HeaderLog
[3],
5405 Header
->RootErrorCommand
,
5406 Header
->RootErrorStatus
,
5407 Header
->ErrorSourceIdentification
,
5408 Header
->CorrectableErrorSourceIdentification
,
5409 Header
->TlpPrefixLog
[0],
5410 Header
->TlpPrefixLog
[1],
5411 Header
->TlpPrefixLog
[2],
5412 Header
->TlpPrefixLog
[3]
5416 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5417 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_ADVANCED_ERROR_REPORTING
),
5418 (VOID
*) (HeaderAddress
)
5420 return (EFI_SUCCESS
);
5424 Function to interpret and print out the multicast structure
5426 @param[in] HeaderAddress The Address of this capability header.
5427 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5428 @param[in] PciExpressCapPtr The address of the PCIe capabilities structure.
5431 PrintInterpretedExtendedCompatibilityMulticast (
5432 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5433 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
,
5434 IN CONST PCI_CAPABILITY_PCIEXP
*PciExpressCapPtr
5437 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_MULTICAST
*Header
;
5438 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_MULTICAST
*)HeaderAddress
;
5442 STRING_TOKEN (STR_PCI_EXT_CAP_MULTICAST
),
5443 gShellDebug1HiiHandle
,
5444 Header
->MultiCastCapability
,
5445 Header
->MulticastControl
,
5446 Header
->McBaseAddress
,
5447 Header
->McReceiveAddress
,
5449 Header
->McBlockUntranslated
,
5450 Header
->McOverlayBar
5455 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5456 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_MULTICAST
),
5457 (VOID
*) (HeaderAddress
)
5460 return (EFI_SUCCESS
);
5464 Function to interpret and print out the virtual channel and multi virtual channel structure
5466 @param[in] HeaderAddress The Address of this capability header.
5467 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5470 PrintInterpretedExtendedCompatibilityVirtualChannel (
5471 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5472 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5475 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_VIRTUAL_CHANNEL_CAPABILITY
*Header
;
5476 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_VIRTUAL_CHANNEL_VC
*CapabilityItem
;
5478 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_VIRTUAL_CHANNEL_CAPABILITY
*)HeaderAddress
;
5482 STRING_TOKEN (STR_PCI_EXT_CAP_VC_BASE
),
5483 gShellDebug1HiiHandle
,
5484 Header
->ExtendedVcCount
,
5485 Header
->PortVcCapability1
,
5486 Header
->PortVcCapability2
,
5487 Header
->VcArbTableOffset
,
5488 Header
->PortVcControl
,
5489 Header
->PortVcStatus
5491 for (ItemCount
= 0 ; ItemCount
< Header
->ExtendedVcCount
; ItemCount
++) {
5492 CapabilityItem
= &Header
->Capability
[ItemCount
];
5495 STRING_TOKEN (STR_PCI_EXT_CAP_VC_ITEM
),
5496 gShellDebug1HiiHandle
,
5498 CapabilityItem
->VcResourceCapability
,
5499 CapabilityItem
->PortArbTableOffset
,
5500 CapabilityItem
->VcResourceControl
,
5501 CapabilityItem
->VcResourceStatus
5507 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5508 sizeof (PCI_EXPRESS_EXTENDED_CAPABILITIES_VIRTUAL_CHANNEL_CAPABILITY
)
5509 + Header
->ExtendedVcCount
* sizeof (PCI_EXPRESS_EXTENDED_CAPABILITIES_VIRTUAL_CHANNEL_VC
),
5510 (VOID
*) (HeaderAddress
)
5513 return (EFI_SUCCESS
);
5517 Function to interpret and print out the resizeable bar structure
5519 @param[in] HeaderAddress The Address of this capability header.
5520 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5523 PrintInterpretedExtendedCompatibilityResizeableBar (
5524 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5525 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5528 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_RESIZABLE_BAR
*Header
;
5530 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_RESIZABLE_BAR
*)HeaderAddress
;
5532 for (ItemCount
= 0 ; ItemCount
< (UINT32
)GET_NUMBER_RESIZABLE_BARS(Header
) ; ItemCount
++) {
5535 STRING_TOKEN (STR_PCI_EXT_CAP_RESIZE_BAR
),
5536 gShellDebug1HiiHandle
,
5538 Header
->Capability
[ItemCount
].ResizableBarCapability
,
5539 Header
->Capability
[ItemCount
].ResizableBarControl
5545 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5546 (UINT32
)GET_NUMBER_RESIZABLE_BARS(Header
) * sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_RESIZABLE_BAR_ENTRY
),
5547 (VOID
*) (HeaderAddress
)
5550 return (EFI_SUCCESS
);
5554 Function to interpret and print out the TPH structure
5556 @param[in] HeaderAddress The Address of this capability header.
5557 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5560 PrintInterpretedExtendedCompatibilityTph (
5561 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5562 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5565 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_TPH
*Header
;
5566 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_TPH
*)HeaderAddress
;
5570 STRING_TOKEN (STR_PCI_EXT_CAP_TPH
),
5571 gShellDebug1HiiHandle
,
5572 Header
->TphRequesterCapability
,
5573 Header
->TphRequesterControl
5577 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)Header
->TphStTable
- (UINT8
*)HeadersBaseAddress
),
5578 GET_TPH_TABLE_SIZE(Header
),
5579 (VOID
*)Header
->TphStTable
5584 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5585 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_TPH
) + GET_TPH_TABLE_SIZE(Header
) - sizeof(UINT16
),
5586 (VOID
*) (HeaderAddress
)
5589 return (EFI_SUCCESS
);
5593 Function to interpret and print out the secondary PCIe capability structure
5595 @param[in] HeaderAddress The Address of this capability header.
5596 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5597 @param[in] PciExpressCapPtr The address of the PCIe capabilities structure.
5600 PrintInterpretedExtendedCompatibilitySecondary (
5601 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5602 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
,
5603 IN CONST PCI_CAPABILITY_PCIEXP
*PciExpressCap
5606 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_SECONDARY_PCIE
*Header
;
5607 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_SECONDARY_PCIE
*)HeaderAddress
;
5611 STRING_TOKEN (STR_PCI_EXT_CAP_SECONDARY
),
5612 gShellDebug1HiiHandle
,
5613 Header
->LinkControl3
.Uint32
,
5614 Header
->LaneErrorStatus
5618 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)Header
->EqualizationControl
- (UINT8
*)HeadersBaseAddress
),
5619 PciExpressCap
->LinkCapability
.Bits
.MaxLinkWidth
* sizeof (PCI_EXPRESS_REG_LANE_EQUALIZATION_CONTROL
),
5620 (VOID
*)Header
->EqualizationControl
5625 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5626 sizeof (PCI_EXPRESS_EXTENDED_CAPABILITIES_SECONDARY_PCIE
) - sizeof (Header
->EqualizationControl
)
5627 + PciExpressCap
->LinkCapability
.Bits
.MaxLinkWidth
* sizeof (PCI_EXPRESS_REG_LANE_EQUALIZATION_CONTROL
),
5628 (VOID
*) (HeaderAddress
)
5631 return (EFI_SUCCESS
);
5635 Display Pcie extended capability details
5637 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5638 @param[in] HeaderAddress The address of this capability header.
5639 @param[in] PciExpressCapPtr The address of the PCIe capabilities structure.
5642 PrintPciExtendedCapabilityDetails(
5643 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
,
5644 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5645 IN CONST PCI_CAPABILITY_PCIEXP
*PciExpressCapPtr
5648 switch (HeaderAddress
->CapabilityId
){
5649 case PCI_EXPRESS_EXTENDED_CAPABILITY_ADVANCED_ERROR_REPORTING_ID
:
5650 return PrintInterpretedExtendedCompatibilityAer(HeaderAddress
, HeadersBaseAddress
);
5651 case PCI_EXPRESS_EXTENDED_CAPABILITY_LINK_CONTROL_ID
:
5652 return PrintInterpretedExtendedCompatibilityLinkControl(HeaderAddress
, HeadersBaseAddress
);
5653 case PCI_EXPRESS_EXTENDED_CAPABILITY_LINK_DECLARATION_ID
:
5654 return PrintInterpretedExtendedCompatibilityLinkDeclaration(HeaderAddress
, HeadersBaseAddress
);
5655 case PCI_EXPRESS_EXTENDED_CAPABILITY_SERIAL_NUMBER_ID
:
5656 return PrintInterpretedExtendedCompatibilitySerialNumber(HeaderAddress
, HeadersBaseAddress
);
5657 case PCI_EXPRESS_EXTENDED_CAPABILITY_POWER_BUDGETING_ID
:
5658 return PrintInterpretedExtendedCompatibilityPowerBudgeting(HeaderAddress
, HeadersBaseAddress
);
5659 case PCI_EXPRESS_EXTENDED_CAPABILITY_ACS_EXTENDED_ID
:
5660 return PrintInterpretedExtendedCompatibilityAcs(HeaderAddress
, HeadersBaseAddress
);
5661 case PCI_EXPRESS_EXTENDED_CAPABILITY_LATENCE_TOLERANCE_REPORTING_ID
:
5662 return PrintInterpretedExtendedCompatibilityLatencyToleranceReporting(HeaderAddress
, HeadersBaseAddress
);
5663 case PCI_EXPRESS_EXTENDED_CAPABILITY_ARI_CAPABILITY_ID
:
5664 return PrintInterpretedExtendedCompatibilityAri(HeaderAddress
, HeadersBaseAddress
);
5665 case PCI_EXPRESS_EXTENDED_CAPABILITY_RCRB_HEADER_ID
:
5666 return PrintInterpretedExtendedCompatibilityRcrb(HeaderAddress
, HeadersBaseAddress
);
5667 case PCI_EXPRESS_EXTENDED_CAPABILITY_VENDOR_SPECIFIC_ID
:
5668 return PrintInterpretedExtendedCompatibilityVendorSpecific(HeaderAddress
, HeadersBaseAddress
);
5669 case PCI_EXPRESS_EXTENDED_CAPABILITY_DYNAMIC_POWER_ALLOCATION_ID
:
5670 return PrintInterpretedExtendedCompatibilityDynamicPowerAllocation(HeaderAddress
, HeadersBaseAddress
);
5671 case PCI_EXPRESS_EXTENDED_CAPABILITY_EVENT_COLLECTOR_ENDPOINT_ASSOCIATION_ID
:
5672 return PrintInterpretedExtendedCompatibilityECEA(HeaderAddress
, HeadersBaseAddress
);
5673 case PCI_EXPRESS_EXTENDED_CAPABILITY_VIRTUAL_CHANNEL_ID
:
5674 case PCI_EXPRESS_EXTENDED_CAPABILITY_MULTI_FUNCTION_VIRTUAL_CHANNEL_ID
:
5675 return PrintInterpretedExtendedCompatibilityVirtualChannel(HeaderAddress
, HeadersBaseAddress
);
5676 case PCI_EXPRESS_EXTENDED_CAPABILITY_MULTICAST_ID
:
5678 // should only be present if PCIE_CAP_DEVICEPORT_TYPE(PciExpressCapPtr->PcieCapReg) == 0100b, 0101b, or 0110b
5680 return PrintInterpretedExtendedCompatibilityMulticast(HeaderAddress
, HeadersBaseAddress
, PciExpressCapPtr
);
5681 case PCI_EXPRESS_EXTENDED_CAPABILITY_RESIZABLE_BAR_ID
:
5682 return PrintInterpretedExtendedCompatibilityResizeableBar(HeaderAddress
, HeadersBaseAddress
);
5683 case PCI_EXPRESS_EXTENDED_CAPABILITY_TPH_ID
:
5684 return PrintInterpretedExtendedCompatibilityTph(HeaderAddress
, HeadersBaseAddress
);
5685 case PCI_EXPRESS_EXTENDED_CAPABILITY_SECONDARY_PCIE_ID
:
5686 return PrintInterpretedExtendedCompatibilitySecondary(HeaderAddress
, HeadersBaseAddress
, PciExpressCapPtr
);
5688 ShellPrintEx (-1, -1,
5689 L
"Unknown PCIe extended capability ID (%04xh). No interpretation available.\r\n",
5690 HeaderAddress
->CapabilityId
5698 Display Pcie device structure.
5700 @param[in] IoDev The pointer to the root pci protocol.
5701 @param[in] Address The Address to start at.
5702 @param[in] CapabilityPtr The offset from the address to start.
5703 @param[in] EnhancedDump The print format for the dump data.
5707 PciExplainPciExpress (
5708 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
,
5710 IN UINT8 CapabilityPtr
,
5711 IN CONST UINT16 EnhancedDump
5714 PCI_CAPABILITY_PCIEXP PciExpressCap
;
5716 UINT64 CapRegAddress
;
5721 UINTN ExtendRegSize
;
5722 UINT64 Pciex_Address
;
5723 UINT8 DevicePortType
;
5727 PCI_EXP_EXT_HDR
*ExtHdr
;
5729 CapRegAddress
= Address
+ CapabilityPtr
;
5734 sizeof (PciExpressCap
) / sizeof (UINT32
),
5738 DevicePortType
= (UINT8
)PciExpressCap
.Capability
.Bits
.DevicePortType
;
5740 ShellPrintEx (-1, -1, L
"\r\nPci Express device capability structure:\r\n");
5742 for (Index
= 0; PcieExplainList
[Index
].Type
< PcieExplainTypeMax
; Index
++) {
5743 if (ShellGetExecutionBreakFlag()) {
5746 RegAddr
= ((UINT8
*) &PciExpressCap
) + PcieExplainList
[Index
].Offset
;
5747 switch (PcieExplainList
[Index
].Width
) {
5748 case FieldWidthUINT8
:
5749 RegValue
= *(UINT8
*) RegAddr
;
5751 case FieldWidthUINT16
:
5752 RegValue
= *(UINT16
*) RegAddr
;
5754 case FieldWidthUINT32
:
5755 RegValue
= *(UINT32
*) RegAddr
;
5761 ShellPrintHiiEx(-1, -1, NULL
,
5762 PcieExplainList
[Index
].Token
,
5763 gShellDebug1HiiHandle
,
5764 PcieExplainList
[Index
].Offset
,
5767 if (PcieExplainList
[Index
].Func
== NULL
) {
5770 switch (PcieExplainList
[Index
].Type
) {
5771 case PcieExplainTypeLink
:
5773 // Link registers should not be used by
5774 // a) Root Complex Integrated Endpoint
5775 // b) Root Complex Event Collector
5777 if (DevicePortType
== PCIE_DEVICE_PORT_TYPE_ROOT_COMPLEX_INTEGRATED_ENDPOINT
||
5778 DevicePortType
== PCIE_DEVICE_PORT_TYPE_ROOT_COMPLEX_EVENT_COLLECTOR
) {
5782 case PcieExplainTypeSlot
:
5784 // Slot registers are only valid for
5785 // a) Root Port of PCI Express Root Complex
5786 // b) Downstream Port of PCI Express Switch
5787 // and when SlotImplemented bit is set in PCIE cap register.
5789 if ((DevicePortType
!= PCIE_DEVICE_PORT_TYPE_ROOT_PORT
&&
5790 DevicePortType
!= PCIE_DEVICE_PORT_TYPE_DOWNSTREAM_PORT
) ||
5791 !PciExpressCap
.Capability
.Bits
.SlotImplemented
) {
5795 case PcieExplainTypeRoot
:
5797 // Root registers are only valid for
5798 // Root Port of PCI Express Root Complex
5800 if (DevicePortType
!= PCIE_DEVICE_PORT_TYPE_ROOT_PORT
) {
5807 PcieExplainList
[Index
].Func (&PciExpressCap
);
5810 Bus
= (UINT8
) (RShiftU64 (Address
, 24));
5811 Dev
= (UINT8
) (RShiftU64 (Address
, 16));
5812 Func
= (UINT8
) (RShiftU64 (Address
, 8));
5814 Pciex_Address
= EFI_PCI_ADDRESS (Bus
, Dev
, Func
, EFI_PCIE_CAPABILITY_BASE_OFFSET
);
5816 ExtendRegSize
= 0x1000 - EFI_PCIE_CAPABILITY_BASE_OFFSET
;
5818 ExRegBuffer
= (UINT8
*) AllocateZeroPool (ExtendRegSize
);
5821 // PciRootBridgeIo protocol should support pci express extend space IO
5822 // (Begins at offset EFI_PCIE_CAPABILITY_BASE_OFFSET)
5824 Status
= IoDev
->Pci
.Read (
5828 (ExtendRegSize
) / sizeof (UINT32
),
5829 (VOID
*) (ExRegBuffer
)
5831 if (EFI_ERROR (Status
) || ExRegBuffer
== NULL
) {
5832 SHELL_FREE_NON_NULL(ExRegBuffer
);
5833 return EFI_UNSUPPORTED
;
5836 ExtHdr
= (PCI_EXP_EXT_HDR
*)ExRegBuffer
;
5837 while (ExtHdr
->CapabilityId
!= 0 && ExtHdr
->CapabilityVersion
!= 0) {
5839 // Process this item
5841 if (EnhancedDump
== 0xFFFF || EnhancedDump
== ExtHdr
->CapabilityId
) {
5845 PrintPciExtendedCapabilityDetails((PCI_EXP_EXT_HDR
*)ExRegBuffer
, ExtHdr
, &PciExpressCap
);
5849 // Advance to the next item if it exists
5851 if (ExtHdr
->NextCapabilityOffset
!= 0) {
5852 ExtHdr
= (PCI_EXP_EXT_HDR
*)((UINT8
*)ExRegBuffer
+ ExtHdr
->NextCapabilityOffset
- EFI_PCIE_CAPABILITY_BASE_OFFSET
);
5857 SHELL_FREE_NON_NULL(ExRegBuffer
);