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.
1911 IN PCI_CONFIG_SPACE
*ConfigSpace
,
1913 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
1917 Explain the device specific part of data in PCI configuration space.
1919 @param[in] Device Data in PCI configuration space.
1920 @param[in] Address Address used to access configuration space of this PCI device.
1921 @param[in] IoDev Handle used to access configuration space of PCI device.
1923 @retval EFI_SUCCESS The command completed successfully.
1926 PciExplainDeviceData (
1927 IN PCI_DEVICE_HEADER_TYPE_REGION
*Device
,
1929 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
1933 Explain the bridge specific part of data in PCI configuration space.
1935 @param[in] Bridge Bridge specific data region in PCI configuration space.
1936 @param[in] Address Address used to access configuration space of this PCI device.
1937 @param[in] IoDev Handle used to access configuration space of PCI device.
1939 @retval EFI_SUCCESS The command completed successfully.
1942 PciExplainBridgeData (
1943 IN PCI_BRIDGE_CONTROL_REGISTER
*Bridge
,
1945 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
1949 Explain the Base Address Register(Bar) in PCI configuration space.
1951 @param[in] Bar Points to the Base Address Register intended to interpret.
1952 @param[in] Command Points to the register Command.
1953 @param[in] Address Address used to access configuration space of this PCI device.
1954 @param[in] IoDev Handle used to access configuration space of PCI device.
1955 @param[in, out] Index The Index.
1957 @retval EFI_SUCCESS The command completed successfully.
1964 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
,
1969 Explain the cardbus specific part of data in PCI configuration space.
1971 @param[in] CardBus CardBus specific region of PCI configuration space.
1972 @param[in] Address Address used to access configuration space of this PCI device.
1973 @param[in] IoDev Handle used to access configuration space of PCI device.
1975 @retval EFI_SUCCESS The command completed successfully.
1978 PciExplainCardBusData (
1979 IN PCI_CARDBUS_CONTROL_REGISTER
*CardBus
,
1981 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
1985 Explain each meaningful bit of register Status. The definition of Status is
1986 slightly different depending on the PCI header type.
1988 @param[in] Status Points to the content of register Status.
1989 @param[in] MainStatus Indicates if this register is main status(not secondary
1991 @param[in] HeaderType Header type of this PCI device.
1993 @retval EFI_SUCCESS The command completed successfully.
1998 IN BOOLEAN MainStatus
,
1999 IN PCI_HEADER_TYPE HeaderType
2003 Explain each meaningful bit of register Command.
2005 @param[in] Command Points to the content of register Command.
2007 @retval EFI_SUCCESS The command completed successfully.
2015 Explain each meaningful bit of register Bridge Control.
2017 @param[in] BridgeControl Points to the content of register Bridge Control.
2018 @param[in] HeaderType The headertype.
2020 @retval EFI_SUCCESS The command completed successfully.
2023 PciExplainBridgeControl (
2024 IN UINT16
*BridgeControl
,
2025 IN PCI_HEADER_TYPE HeaderType
2029 Locate capability register block per capability ID.
2031 @param[in] ConfigSpace Data in PCI configuration space.
2032 @param[in] CapabilityId The capability ID.
2034 @return The offset of the register block per capability ID.
2037 LocatePciCapability (
2038 IN PCI_CONFIG_SPACE
*ConfigSpace
,
2039 IN UINT8 CapabilityId
2043 Display Pcie device structure.
2045 @param[in] PciExpressCap PCI Express capability buffer.
2046 @param[in] ExtendedConfigSpace PCI Express extended configuration space.
2047 @param[in] ExtendedCapability PCI Express extended capability ID to explain.
2050 PciExplainPciExpress (
2051 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
,
2052 IN UINT8
*ExtendedConfigSpace
,
2053 IN CONST UINT16 ExtendedCapability
2057 Print out information of the capability information.
2059 @param[in] PciExpressCap The pointer to the structure about the device.
2061 @retval EFI_SUCCESS The operation was successful.
2065 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2069 Print out information of the device capability information.
2071 @param[in] PciExpressCap The pointer to the structure about the device.
2073 @retval EFI_SUCCESS The operation was successful.
2076 ExplainPcieDeviceCap (
2077 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2081 Print out information of the device control information.
2083 @param[in] PciExpressCap The pointer to the structure about the device.
2085 @retval EFI_SUCCESS The operation was successful.
2088 ExplainPcieDeviceControl (
2089 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2093 Print out information of the device status information.
2095 @param[in] PciExpressCap The pointer to the structure about the device.
2097 @retval EFI_SUCCESS The operation was successful.
2100 ExplainPcieDeviceStatus (
2101 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2105 Print out information of the device link information.
2107 @param[in] PciExpressCap The pointer to the structure about the device.
2109 @retval EFI_SUCCESS The operation was successful.
2112 ExplainPcieLinkCap (
2113 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2117 Print out information of the device link control information.
2119 @param[in] PciExpressCap The pointer to the structure about the device.
2121 @retval EFI_SUCCESS The operation was successful.
2124 ExplainPcieLinkControl (
2125 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2129 Print out information of the device link status information.
2131 @param[in] PciExpressCap The pointer to the structure about the device.
2133 @retval EFI_SUCCESS The operation was successful.
2136 ExplainPcieLinkStatus (
2137 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2141 Print out information of the device slot information.
2143 @param[in] PciExpressCap The pointer to the structure about the device.
2145 @retval EFI_SUCCESS The operation was successful.
2148 ExplainPcieSlotCap (
2149 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2153 Print out information of the device slot control information.
2155 @param[in] PciExpressCap The pointer to the structure about the device.
2157 @retval EFI_SUCCESS The operation was successful.
2160 ExplainPcieSlotControl (
2161 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2165 Print out information of the device slot status information.
2167 @param[in] PciExpressCap The pointer to the structure about the device.
2169 @retval EFI_SUCCESS The operation was successful.
2172 ExplainPcieSlotStatus (
2173 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2177 Print out information of the device root information.
2179 @param[in] PciExpressCap The pointer to the structure about the device.
2181 @retval EFI_SUCCESS The operation was successful.
2184 ExplainPcieRootControl (
2185 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2189 Print out information of the device root capability information.
2191 @param[in] PciExpressCap The pointer to the structure about the device.
2193 @retval EFI_SUCCESS The operation was successful.
2196 ExplainPcieRootCap (
2197 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2201 Print out information of the device root status information.
2203 @param[in] PciExpressCap The pointer to the structure about the device.
2205 @retval EFI_SUCCESS The operation was successful.
2208 ExplainPcieRootStatus (
2209 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
2212 typedef EFI_STATUS (*PCIE_EXPLAIN_FUNCTION
) (IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
);
2218 } PCIE_CAPREG_FIELD_WIDTH
;
2221 PcieExplainTypeCommon
,
2222 PcieExplainTypeDevice
,
2223 PcieExplainTypeLink
,
2224 PcieExplainTypeSlot
,
2225 PcieExplainTypeRoot
,
2227 } PCIE_EXPLAIN_TYPE
;
2233 PCIE_CAPREG_FIELD_WIDTH Width
;
2234 PCIE_EXPLAIN_FUNCTION Func
;
2235 PCIE_EXPLAIN_TYPE Type
;
2236 } PCIE_EXPLAIN_STRUCT
;
2238 PCIE_EXPLAIN_STRUCT PcieExplainList
[] = {
2240 STRING_TOKEN (STR_PCIEX_CAPABILITY_CAPID
),
2244 PcieExplainTypeCommon
2247 STRING_TOKEN (STR_PCIEX_NEXTCAP_PTR
),
2251 PcieExplainTypeCommon
2254 STRING_TOKEN (STR_PCIEX_CAP_REGISTER
),
2258 PcieExplainTypeCommon
2261 STRING_TOKEN (STR_PCIEX_DEVICE_CAP
),
2264 ExplainPcieDeviceCap
,
2265 PcieExplainTypeDevice
2268 STRING_TOKEN (STR_PCIEX_DEVICE_CONTROL
),
2271 ExplainPcieDeviceControl
,
2272 PcieExplainTypeDevice
2275 STRING_TOKEN (STR_PCIEX_DEVICE_STATUS
),
2278 ExplainPcieDeviceStatus
,
2279 PcieExplainTypeDevice
2282 STRING_TOKEN (STR_PCIEX_LINK_CAPABILITIES
),
2289 STRING_TOKEN (STR_PCIEX_LINK_CONTROL
),
2292 ExplainPcieLinkControl
,
2296 STRING_TOKEN (STR_PCIEX_LINK_STATUS
),
2299 ExplainPcieLinkStatus
,
2303 STRING_TOKEN (STR_PCIEX_SLOT_CAPABILITIES
),
2310 STRING_TOKEN (STR_PCIEX_SLOT_CONTROL
),
2313 ExplainPcieSlotControl
,
2317 STRING_TOKEN (STR_PCIEX_SLOT_STATUS
),
2320 ExplainPcieSlotStatus
,
2324 STRING_TOKEN (STR_PCIEX_ROOT_CONTROL
),
2327 ExplainPcieRootControl
,
2331 STRING_TOKEN (STR_PCIEX_RSVDP
),
2338 STRING_TOKEN (STR_PCIEX_ROOT_STATUS
),
2341 ExplainPcieRootStatus
,
2347 (PCIE_CAPREG_FIELD_WIDTH
)0,
2356 PCI_CONFIG_SPACE
*mConfigSpace
= NULL
;
2357 STATIC CONST SHELL_PARAM_ITEM ParamList
[] = {
2360 {L
"-ec", TypeValue
},
2364 CHAR16
*DevicePortTypeTable
[] = {
2365 L
"PCI Express Endpoint",
2366 L
"Legacy PCI Express Endpoint",
2369 L
"Root Port of PCI Express Root Complex",
2370 L
"Upstream Port of PCI Express Switch",
2371 L
"Downstream Port of PCI Express Switch",
2372 L
"PCI Express to PCI/PCI-X Bridge",
2373 L
"PCI/PCI-X to PCI Express Bridge",
2374 L
"Root Complex Integrated Endpoint",
2375 L
"Root Complex Event Collector"
2378 CHAR16
*L0sLatencyStrTable
[] = {
2380 L
"64ns to less than 128ns",
2381 L
"128ns to less than 256ns",
2382 L
"256ns to less than 512ns",
2383 L
"512ns to less than 1us",
2384 L
"1us to less than 2us",
2389 CHAR16
*L1LatencyStrTable
[] = {
2391 L
"1us to less than 2us",
2392 L
"2us to less than 4us",
2393 L
"4us to less than 8us",
2394 L
"8us to less than 16us",
2395 L
"16us to less than 32us",
2400 CHAR16
*ASPMCtrlStrTable
[] = {
2402 L
"L0s Entry Enabled",
2403 L
"L1 Entry Enabled",
2404 L
"L0s and L1 Entry Enabled"
2407 CHAR16
*SlotPwrLmtScaleTable
[] = {
2414 CHAR16
*IndicatorTable
[] = {
2423 Function for 'pci' command.
2425 @param[in] ImageHandle Handle to the Image (NULL if Internal).
2426 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
2430 ShellCommandRunPci (
2431 IN EFI_HANDLE ImageHandle
,
2432 IN EFI_SYSTEM_TABLE
*SystemTable
2440 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
;
2442 PCI_DEVICE_INDEPENDENT_REGION PciHeader
;
2443 PCI_CONFIG_SPACE ConfigSpace
;
2447 BOOLEAN ExplainData
;
2451 UINTN HandleBufSize
;
2452 EFI_HANDLE
*HandleBuf
;
2454 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*Descriptors
;
2458 LIST_ENTRY
*Package
;
2459 CHAR16
*ProblemParam
;
2460 SHELL_STATUS ShellStatus
;
2463 UINT16 ExtendedCapability
;
2464 UINT8 PcieCapabilityPtr
;
2465 UINT8
*ExtendedConfigSpace
;
2466 UINTN ExtendedConfigSize
;
2468 ShellStatus
= SHELL_SUCCESS
;
2469 Status
= EFI_SUCCESS
;
2476 // initialize the shell lib (we must be in non-auto-init...)
2478 Status
= ShellInitialize();
2479 ASSERT_EFI_ERROR(Status
);
2481 Status
= CommandInit();
2482 ASSERT_EFI_ERROR(Status
);
2485 // parse the command line
2487 Status
= ShellCommandLineParse (ParamList
, &Package
, &ProblemParam
, TRUE
);
2488 if (EFI_ERROR(Status
)) {
2489 if (Status
== EFI_VOLUME_CORRUPTED
&& ProblemParam
!= NULL
) {
2490 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellDebug1HiiHandle
, L
"pci", ProblemParam
);
2491 FreePool(ProblemParam
);
2492 ShellStatus
= SHELL_INVALID_PARAMETER
;
2498 if (ShellCommandLineGetCount(Package
) == 2) {
2499 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_FEW
), gShellDebug1HiiHandle
, L
"pci");
2500 ShellStatus
= SHELL_INVALID_PARAMETER
;
2504 if (ShellCommandLineGetCount(Package
) > 4) {
2505 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_MANY
), gShellDebug1HiiHandle
, L
"pci");
2506 ShellStatus
= SHELL_INVALID_PARAMETER
;
2509 if (ShellCommandLineGetFlag(Package
, L
"-ec") && ShellCommandLineGetValue(Package
, L
"-ec") == NULL
) {
2510 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_NO_VALUE
), gShellDebug1HiiHandle
, L
"pci", L
"-ec");
2511 ShellStatus
= SHELL_INVALID_PARAMETER
;
2514 if (ShellCommandLineGetFlag(Package
, L
"-s") && ShellCommandLineGetValue(Package
, L
"-s") == NULL
) {
2515 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_NO_VALUE
), gShellDebug1HiiHandle
, L
"pci", L
"-s");
2516 ShellStatus
= SHELL_INVALID_PARAMETER
;
2520 // Get all instances of PciRootBridgeIo. Allocate space for 1 EFI_HANDLE and
2521 // call LibLocateHandle(), if EFI_BUFFER_TOO_SMALL is returned, allocate enough
2522 // space for handles and call it again.
2524 HandleBufSize
= sizeof (EFI_HANDLE
);
2525 HandleBuf
= (EFI_HANDLE
*) AllocateZeroPool (HandleBufSize
);
2526 if (HandleBuf
== NULL
) {
2527 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_OUT_MEM
), gShellDebug1HiiHandle
, L
"pci");
2528 ShellStatus
= SHELL_OUT_OF_RESOURCES
;
2532 Status
= gBS
->LocateHandle (
2534 &gEfiPciRootBridgeIoProtocolGuid
,
2540 if (Status
== EFI_BUFFER_TOO_SMALL
) {
2541 HandleBuf
= ReallocatePool (sizeof (EFI_HANDLE
), HandleBufSize
, HandleBuf
);
2542 if (HandleBuf
== NULL
) {
2543 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_OUT_MEM
), gShellDebug1HiiHandle
, L
"pci");
2544 ShellStatus
= SHELL_OUT_OF_RESOURCES
;
2548 Status
= gBS
->LocateHandle (
2550 &gEfiPciRootBridgeIoProtocolGuid
,
2557 if (EFI_ERROR (Status
)) {
2558 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PCIRBIO_NF
), gShellDebug1HiiHandle
, L
"pci");
2559 ShellStatus
= SHELL_NOT_FOUND
;
2563 HandleCount
= HandleBufSize
/ sizeof (EFI_HANDLE
);
2565 // Argument Count == 1(no other argument): enumerate all pci functions
2567 if (ShellCommandLineGetCount(Package
) == 1) {
2568 gST
->ConOut
->QueryMode (
2570 gST
->ConOut
->Mode
->Mode
,
2577 if ((ScreenSize
& 1) == 1) {
2584 // For each handle, which decides a segment and a bus number range,
2585 // enumerate all devices on it.
2587 for (Index
= 0; Index
< HandleCount
; Index
++) {
2588 Status
= PciGetProtocolAndResource (
2593 if (EFI_ERROR (Status
)) {
2594 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_HANDLE_CFG_ERR
), gShellDebug1HiiHandle
, L
"pci");
2595 ShellStatus
= SHELL_NOT_FOUND
;
2599 // No document say it's impossible for a RootBridgeIo protocol handle
2600 // to have more than one address space descriptors, so find out every
2601 // bus range and for each of them do device enumeration.
2604 Status
= PciGetNextBusRange (&Descriptors
, &MinBus
, &MaxBus
, &IsEnd
);
2606 if (EFI_ERROR (Status
)) {
2607 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_BUS_RANGE_ERR
), gShellDebug1HiiHandle
, L
"pci");
2608 ShellStatus
= SHELL_NOT_FOUND
;
2616 for (Bus
= MinBus
; Bus
<= MaxBus
; Bus
++) {
2618 // For each devices, enumerate all functions it contains
2620 for (Device
= 0; Device
<= PCI_MAX_DEVICE
; Device
++) {
2622 // For each function, read its configuration space and print summary
2624 for (Func
= 0; Func
<= PCI_MAX_FUNC
; Func
++) {
2625 if (ShellGetExecutionBreakFlag ()) {
2626 ShellStatus
= SHELL_ABORTED
;
2629 Address
= EFI_PCI_ADDRESS (Bus
, Device
, Func
, 0);
2639 // If VendorId = 0xffff, there does not exist a device at this
2640 // location. For each device, if there is any function on it,
2641 // there must be 1 function at Function 0. So if Func = 0, there
2642 // will be no more functions in the same device, so we can break
2643 // loop to deal with the next device.
2645 if (PciHeader
.VendorId
== 0xffff && Func
== 0) {
2649 if (PciHeader
.VendorId
!= 0xffff) {
2652 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_TITLE
), gShellDebug1HiiHandle
);
2660 sizeof (PciHeader
) / sizeof (UINT32
),
2665 -1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_P1
), gShellDebug1HiiHandle
,
2666 IoDev
->SegmentNumber
,
2672 PciPrintClassCode (PciHeader
.ClassCode
, FALSE
);
2674 -1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_P2
), gShellDebug1HiiHandle
,
2677 PciHeader
.ClassCode
[0]
2681 if (ScreenCount
>= ScreenSize
&& ScreenSize
!= 0) {
2683 // If ScreenSize == 0 we have the console redirected so don't
2689 // If this is not a multi-function device, we can leave the loop
2690 // to deal with the next device.
2692 if (Func
== 0 && ((PciHeader
.HeaderType
& HEADER_TYPE_MULTI_FUNCTION
) == 0x00)) {
2700 // If Descriptor is NULL, Configuration() returns EFI_UNSUPPRORED,
2701 // we assume the bus range is 0~PCI_MAX_BUS. After enumerated all
2702 // devices on all bus, we can leave loop.
2704 if (Descriptors
== NULL
) {
2710 Status
= EFI_SUCCESS
;
2714 ExplainData
= FALSE
;
2719 ExtendedCapability
= 0xFFFF;
2720 if (ShellCommandLineGetFlag(Package
, L
"-i")) {
2724 Temp
= ShellCommandLineGetValue(Package
, L
"-s");
2727 // Input converted to hexadecimal number.
2729 if (!EFI_ERROR (ShellConvertStringToUint64 (Temp
, &RetVal
, TRUE
, TRUE
))) {
2730 Segment
= (UINT16
) RetVal
;
2732 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV_HEX
), gShellDebug1HiiHandle
, L
"pci", Temp
);
2733 ShellStatus
= SHELL_INVALID_PARAMETER
;
2739 // The first Argument(except "-i") is assumed to be Bus number, second
2740 // to be Device number, and third to be Func number.
2742 Temp
= ShellCommandLineGetRawValue(Package
, 1);
2745 // Input converted to hexadecimal number.
2747 if (!EFI_ERROR (ShellConvertStringToUint64 (Temp
, &RetVal
, TRUE
, TRUE
))) {
2748 Bus
= (UINT16
) RetVal
;
2750 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV_HEX
), gShellDebug1HiiHandle
, L
"pci", Temp
);
2751 ShellStatus
= SHELL_INVALID_PARAMETER
;
2755 if (Bus
> PCI_MAX_BUS
) {
2756 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV
), gShellDebug1HiiHandle
, L
"pci", Temp
);
2757 ShellStatus
= SHELL_INVALID_PARAMETER
;
2761 Temp
= ShellCommandLineGetRawValue(Package
, 2);
2764 // Input converted to hexadecimal number.
2766 if (!EFI_ERROR (ShellConvertStringToUint64 (Temp
, &RetVal
, TRUE
, TRUE
))) {
2767 Device
= (UINT16
) RetVal
;
2769 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV_HEX
), gShellDebug1HiiHandle
, L
"pci", Temp
);
2770 ShellStatus
= SHELL_INVALID_PARAMETER
;
2774 if (Device
> PCI_MAX_DEVICE
){
2775 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV
), gShellDebug1HiiHandle
, L
"pci", Temp
);
2776 ShellStatus
= SHELL_INVALID_PARAMETER
;
2781 Temp
= ShellCommandLineGetRawValue(Package
, 3);
2784 // Input converted to hexadecimal number.
2786 if (!EFI_ERROR (ShellConvertStringToUint64 (Temp
, &RetVal
, TRUE
, TRUE
))) {
2787 Func
= (UINT16
) RetVal
;
2789 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV_HEX
), gShellDebug1HiiHandle
, L
"pci", Temp
);
2790 ShellStatus
= SHELL_INVALID_PARAMETER
;
2794 if (Func
> PCI_MAX_FUNC
){
2795 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV
), gShellDebug1HiiHandle
, L
"pci", Temp
);
2796 ShellStatus
= SHELL_INVALID_PARAMETER
;
2801 Temp
= ShellCommandLineGetValue (Package
, L
"-ec");
2804 // Input converted to hexadecimal number.
2806 if (!EFI_ERROR (ShellConvertStringToUint64 (Temp
, &RetVal
, TRUE
, TRUE
))) {
2807 ExtendedCapability
= (UINT16
) RetVal
;
2809 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV_HEX
), gShellDebug1HiiHandle
, L
"pci", Temp
);
2810 ShellStatus
= SHELL_INVALID_PARAMETER
;
2816 // Find the protocol interface who's in charge of current segment, and its
2817 // bus range covers the current bus
2819 Status
= PciFindProtocolInterface (
2827 if (EFI_ERROR (Status
)) {
2829 -1, -1, NULL
, STRING_TOKEN (STR_PCI_NO_FIND
), gShellDebug1HiiHandle
, L
"pci",
2833 ShellStatus
= SHELL_NOT_FOUND
;
2837 Address
= EFI_PCI_ADDRESS (Bus
, Device
, Func
, 0);
2838 Status
= IoDev
->Pci
.Read (
2842 sizeof (ConfigSpace
),
2846 if (EFI_ERROR (Status
)) {
2847 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_NO_CFG
), gShellDebug1HiiHandle
, L
"pci");
2848 ShellStatus
= SHELL_ACCESS_DENIED
;
2852 mConfigSpace
= &ConfigSpace
;
2857 STRING_TOKEN (STR_PCI_INFO
),
2858 gShellDebug1HiiHandle
,
2870 // Dump standard header of configuration space
2872 SizeOfHeader
= sizeof (ConfigSpace
.Common
) + sizeof (ConfigSpace
.NonCommon
);
2874 DumpHex (2, 0, SizeOfHeader
, &ConfigSpace
);
2875 ShellPrintEx(-1,-1, L
"\r\n");
2878 // Dump device dependent Part of configuration space
2883 sizeof (ConfigSpace
) - SizeOfHeader
,
2887 ExtendedConfigSpace
= NULL
;
2888 PcieCapabilityPtr
= LocatePciCapability (&ConfigSpace
, EFI_PCI_CAPABILITY_ID_PCIEXP
);
2889 if (PcieCapabilityPtr
!= 0) {
2890 ExtendedConfigSize
= 0x1000 - EFI_PCIE_CAPABILITY_BASE_OFFSET
;
2891 ExtendedConfigSpace
= AllocatePool (ExtendedConfigSize
);
2892 if (ExtendedConfigSpace
!= NULL
) {
2893 Status
= IoDev
->Pci
.Read (
2896 EFI_PCI_ADDRESS (Bus
, Device
, Func
, EFI_PCIE_CAPABILITY_BASE_OFFSET
),
2897 ExtendedConfigSize
/ sizeof (UINT32
),
2900 if (EFI_ERROR (Status
)) {
2901 SHELL_FREE_NON_NULL (ExtendedConfigSpace
);
2906 if ((ExtendedConfigSpace
!= NULL
) && !ShellGetExecutionBreakFlag ()) {
2908 // Print the PciEx extend space in raw bytes ( 0xFF-0xFFF)
2910 ShellPrintEx (-1, -1, L
"\r\n%HStart dumping PCIex extended configuration space (0x100 - 0xFFF).%N\r\n\r\n");
2914 EFI_PCIE_CAPABILITY_BASE_OFFSET
,
2921 // If "-i" appears in command line, interpret data in configuration space
2924 PciExplainPci (&ConfigSpace
, Address
, IoDev
);
2925 if ((PcieCapabilityPtr
!= 0) && !ShellGetExecutionBreakFlag ()) {
2926 PciExplainPciExpress (
2927 (PCI_CAPABILITY_PCIEXP
*) ((UINT8
*) &ConfigSpace
+ PcieCapabilityPtr
),
2928 ExtendedConfigSpace
,
2935 if (HandleBuf
!= NULL
) {
2936 FreePool (HandleBuf
);
2938 if (Package
!= NULL
) {
2939 ShellCommandLineFreeVarList (Package
);
2941 mConfigSpace
= NULL
;
2946 This function finds out the protocol which is in charge of the given
2947 segment, and its bus range covers the current bus number. It lookes
2948 each instances of RootBridgeIoProtocol handle, until the one meets the
2951 @param[in] HandleBuf Buffer which holds all PCI_ROOT_BRIDIGE_IO_PROTOCOL handles.
2952 @param[in] HandleCount Count of all PCI_ROOT_BRIDIGE_IO_PROTOCOL handles.
2953 @param[in] Segment Segment number of device we are dealing with.
2954 @param[in] Bus Bus number of device we are dealing with.
2955 @param[out] IoDev Handle used to access configuration space of PCI device.
2957 @retval EFI_SUCCESS The command completed successfully.
2958 @retval EFI_INVALID_PARAMETER Invalid parameter.
2962 PciFindProtocolInterface (
2963 IN EFI_HANDLE
*HandleBuf
,
2964 IN UINTN HandleCount
,
2967 OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
**IoDev
2972 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*Descriptors
;
2978 // Go through all handles, until the one meets the criteria is found
2980 for (Index
= 0; Index
< HandleCount
; Index
++) {
2981 Status
= PciGetProtocolAndResource (HandleBuf
[Index
], IoDev
, &Descriptors
);
2982 if (EFI_ERROR (Status
)) {
2986 // When Descriptors == NULL, the Configuration() is not implemented,
2987 // so we only check the Segment number
2989 if (Descriptors
== NULL
&& Segment
== (*IoDev
)->SegmentNumber
) {
2993 if ((*IoDev
)->SegmentNumber
!= Segment
) {
2998 Status
= PciGetNextBusRange (&Descriptors
, &MinBus
, &MaxBus
, &IsEnd
);
2999 if (EFI_ERROR (Status
)) {
3007 if (MinBus
<= Bus
&& MaxBus
>= Bus
) {
3013 return EFI_NOT_FOUND
;
3017 This function gets the protocol interface from the given handle, and
3018 obtains its address space descriptors.
3020 @param[in] Handle The PCI_ROOT_BRIDIGE_IO_PROTOCOL handle.
3021 @param[out] IoDev Handle used to access configuration space of PCI device.
3022 @param[out] Descriptors Points to the address space descriptors.
3024 @retval EFI_SUCCESS The command completed successfully
3027 PciGetProtocolAndResource (
3028 IN EFI_HANDLE Handle
,
3029 OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
**IoDev
,
3030 OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
**Descriptors
3036 // Get inferface from protocol
3038 Status
= gBS
->HandleProtocol (
3040 &gEfiPciRootBridgeIoProtocolGuid
,
3044 if (EFI_ERROR (Status
)) {
3048 // Call Configuration() to get address space descriptors
3050 Status
= (*IoDev
)->Configuration (*IoDev
, (VOID
**)Descriptors
);
3051 if (Status
== EFI_UNSUPPORTED
) {
3052 *Descriptors
= NULL
;
3061 This function get the next bus range of given address space descriptors.
3062 It also moves the pointer backward a node, to get prepared to be called
3065 @param[in, out] Descriptors Points to current position of a serial of address space
3067 @param[out] MinBus The lower range of bus number.
3068 @param[out] MaxBus The upper range of bus number.
3069 @param[out] IsEnd Meet end of the serial of descriptors.
3071 @retval EFI_SUCCESS The command completed successfully.
3074 PciGetNextBusRange (
3075 IN OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
**Descriptors
,
3084 // When *Descriptors is NULL, Configuration() is not implemented, so assume
3085 // range is 0~PCI_MAX_BUS
3087 if ((*Descriptors
) == NULL
) {
3089 *MaxBus
= PCI_MAX_BUS
;
3093 // *Descriptors points to one or more address space descriptors, which
3094 // ends with a end tagged descriptor. Examine each of the descriptors,
3095 // if a bus typed one is found and its bus range covers bus, this handle
3096 // is the handle we are looking for.
3099 while ((*Descriptors
)->Desc
!= ACPI_END_TAG_DESCRIPTOR
) {
3100 if ((*Descriptors
)->ResType
== ACPI_ADDRESS_SPACE_TYPE_BUS
) {
3101 *MinBus
= (UINT16
) (*Descriptors
)->AddrRangeMin
;
3102 *MaxBus
= (UINT16
) (*Descriptors
)->AddrRangeMax
;
3104 return (EFI_SUCCESS
);
3110 if ((*Descriptors
)->Desc
== ACPI_END_TAG_DESCRIPTOR
) {
3118 Explain the data in PCI configuration space. The part which is common for
3119 PCI device and bridge is interpreted in this function. It calls other
3120 functions to interpret data unique for device or bridge.
3122 @param[in] ConfigSpace Data in PCI configuration space.
3123 @param[in] Address Address used to access configuration space of this PCI device.
3124 @param[in] IoDev Handle used to access configuration space of PCI device.
3128 IN PCI_CONFIG_SPACE
*ConfigSpace
,
3130 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
3133 PCI_DEVICE_INDEPENDENT_REGION
*Common
;
3134 PCI_HEADER_TYPE HeaderType
;
3136 Common
= &(ConfigSpace
->Common
);
3138 ShellPrintEx (-1, -1, L
"\r\n");
3141 // Print Vendor Id and Device Id
3143 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_VID_DID
), gShellDebug1HiiHandle
,
3144 INDEX_OF (&(Common
->VendorId
)),
3146 INDEX_OF (&(Common
->DeviceId
)),
3151 // Print register Command
3153 PciExplainCommand (&(Common
->Command
));
3156 // Print register Status
3158 PciExplainStatus (&(Common
->Status
), TRUE
, PciUndefined
);
3161 // Print register Revision ID
3163 ShellPrintEx(-1, -1, L
"\r\n");
3164 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_RID
), gShellDebug1HiiHandle
,
3165 INDEX_OF (&(Common
->RevisionID
)),
3170 // Print register BIST
3172 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_BIST
), gShellDebug1HiiHandle
, INDEX_OF (&(Common
->BIST
)));
3173 if ((Common
->BIST
& BIT7
) != 0) {
3174 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_CAP
), gShellDebug1HiiHandle
, 0x0f & Common
->BIST
);
3176 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_CAP_NO
), gShellDebug1HiiHandle
);
3179 // Print register Cache Line Size
3181 ShellPrintHiiEx(-1, -1, NULL
,
3182 STRING_TOKEN (STR_PCI2_CACHE_LINE_SIZE
),
3183 gShellDebug1HiiHandle
,
3184 INDEX_OF (&(Common
->CacheLineSize
)),
3185 Common
->CacheLineSize
3189 // Print register Latency Timer
3191 ShellPrintHiiEx(-1, -1, NULL
,
3192 STRING_TOKEN (STR_PCI2_LATENCY_TIMER
),
3193 gShellDebug1HiiHandle
,
3194 INDEX_OF (&(Common
->LatencyTimer
)),
3195 Common
->LatencyTimer
3199 // Print register Header Type
3201 ShellPrintHiiEx(-1, -1, NULL
,
3202 STRING_TOKEN (STR_PCI2_HEADER_TYPE
),
3203 gShellDebug1HiiHandle
,
3204 INDEX_OF (&(Common
->HeaderType
)),
3208 if ((Common
->HeaderType
& BIT7
) != 0) {
3209 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MULTI_FUNCTION
), gShellDebug1HiiHandle
);
3212 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_SINGLE_FUNCTION
), gShellDebug1HiiHandle
);
3215 HeaderType
= (PCI_HEADER_TYPE
)(UINT8
) (Common
->HeaderType
& 0x7f);
3216 switch (HeaderType
) {
3218 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_PCI_DEVICE
), gShellDebug1HiiHandle
);
3222 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_P2P_BRIDGE
), gShellDebug1HiiHandle
);
3225 case PciCardBusBridge
:
3226 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_CARDBUS_BRIDGE
), gShellDebug1HiiHandle
);
3230 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RESERVED
), gShellDebug1HiiHandle
);
3231 HeaderType
= PciUndefined
;
3235 // Print register Class Code
3237 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_CLASS
), gShellDebug1HiiHandle
);
3238 PciPrintClassCode ((UINT8
*) Common
->ClassCode
, TRUE
);
3239 ShellPrintEx (-1, -1, L
"\r\n");
3243 Explain the device specific part of data in PCI configuration space.
3245 @param[in] Device Data in PCI configuration space.
3246 @param[in] Address Address used to access configuration space of this PCI device.
3247 @param[in] IoDev Handle used to access configuration space of PCI device.
3249 @retval EFI_SUCCESS The command completed successfully.
3252 PciExplainDeviceData (
3253 IN PCI_DEVICE_HEADER_TYPE_REGION
*Device
,
3255 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
3264 // Print Base Address Registers(Bar). When Bar = 0, this Bar does not
3265 // exist. If these no Bar for this function, print "none", otherwise
3266 // list detail information about this Bar.
3268 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BASE_ADDR
), gShellDebug1HiiHandle
, INDEX_OF (Device
->Bar
));
3271 BarCount
= sizeof (Device
->Bar
) / sizeof (Device
->Bar
[0]);
3272 for (Index
= 0; Index
< BarCount
; Index
++) {
3273 if (Device
->Bar
[Index
] == 0) {
3279 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_START_TYPE
), gShellDebug1HiiHandle
);
3280 ShellPrintEx (-1, -1, L
" --------------------------------------------------------------------------");
3283 Status
= PciExplainBar (
3284 &(Device
->Bar
[Index
]),
3285 &(mConfigSpace
->Common
.Command
),
3291 if (EFI_ERROR (Status
)) {
3297 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NONE
), gShellDebug1HiiHandle
);
3300 ShellPrintEx (-1, -1, L
"\r\n --------------------------------------------------------------------------");
3304 // Print register Expansion ROM Base Address
3306 if ((Device
->ExpansionRomBar
& BIT0
) == 0) {
3307 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_EXPANSION_ROM_DISABLED
), gShellDebug1HiiHandle
, INDEX_OF (&(Device
->ExpansionRomBar
)));
3310 ShellPrintHiiEx(-1, -1, NULL
,
3311 STRING_TOKEN (STR_PCI2_EXPANSION_ROM_BASE
),
3312 gShellDebug1HiiHandle
,
3313 INDEX_OF (&(Device
->ExpansionRomBar
)),
3314 Device
->ExpansionRomBar
3318 // Print register Cardbus CIS ptr
3320 ShellPrintHiiEx(-1, -1, NULL
,
3321 STRING_TOKEN (STR_PCI2_CARDBUS_CIS
),
3322 gShellDebug1HiiHandle
,
3323 INDEX_OF (&(Device
->CISPtr
)),
3328 // Print register Sub-vendor ID and subsystem ID
3330 ShellPrintHiiEx(-1, -1, NULL
,
3331 STRING_TOKEN (STR_PCI2_SUB_VENDOR_ID
),
3332 gShellDebug1HiiHandle
,
3333 INDEX_OF (&(Device
->SubsystemVendorID
)),
3334 Device
->SubsystemVendorID
3337 ShellPrintHiiEx(-1, -1, NULL
,
3338 STRING_TOKEN (STR_PCI2_SUBSYSTEM_ID
),
3339 gShellDebug1HiiHandle
,
3340 INDEX_OF (&(Device
->SubsystemID
)),
3345 // Print register Capabilities Ptr
3347 ShellPrintHiiEx(-1, -1, NULL
,
3348 STRING_TOKEN (STR_PCI2_CAPABILITIES_PTR
),
3349 gShellDebug1HiiHandle
,
3350 INDEX_OF (&(Device
->CapabilityPtr
)),
3351 Device
->CapabilityPtr
3355 // Print register Interrupt Line and interrupt pin
3357 ShellPrintHiiEx(-1, -1, NULL
,
3358 STRING_TOKEN (STR_PCI2_INTERRUPT_LINE
),
3359 gShellDebug1HiiHandle
,
3360 INDEX_OF (&(Device
->InterruptLine
)),
3361 Device
->InterruptLine
3364 ShellPrintHiiEx(-1, -1, NULL
,
3365 STRING_TOKEN (STR_PCI2_INTERRUPT_PIN
),
3366 gShellDebug1HiiHandle
,
3367 INDEX_OF (&(Device
->InterruptPin
)),
3368 Device
->InterruptPin
3372 // Print register Min_Gnt and Max_Lat
3374 ShellPrintHiiEx(-1, -1, NULL
,
3375 STRING_TOKEN (STR_PCI2_MIN_GNT
),
3376 gShellDebug1HiiHandle
,
3377 INDEX_OF (&(Device
->MinGnt
)),
3381 ShellPrintHiiEx(-1, -1, NULL
,
3382 STRING_TOKEN (STR_PCI2_MAX_LAT
),
3383 gShellDebug1HiiHandle
,
3384 INDEX_OF (&(Device
->MaxLat
)),
3392 Explain the bridge specific part of data in PCI configuration space.
3394 @param[in] Bridge Bridge specific data region in PCI configuration space.
3395 @param[in] Address Address used to access configuration space of this PCI device.
3396 @param[in] IoDev Handle used to access configuration space of PCI device.
3398 @retval EFI_SUCCESS The command completed successfully.
3401 PciExplainBridgeData (
3402 IN PCI_BRIDGE_CONTROL_REGISTER
*Bridge
,
3404 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
3414 // Print Base Address Registers. When Bar = 0, this Bar does not
3415 // exist. If these no Bar for this function, print "none", otherwise
3416 // list detail information about this Bar.
3418 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BASE_ADDRESS
), gShellDebug1HiiHandle
, INDEX_OF (&(Bridge
->Bar
)));
3421 BarCount
= sizeof (Bridge
->Bar
) / sizeof (Bridge
->Bar
[0]);
3423 for (Index
= 0; Index
< BarCount
; Index
++) {
3424 if (Bridge
->Bar
[Index
] == 0) {
3430 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_START_TYPE_2
), gShellDebug1HiiHandle
);
3431 ShellPrintEx (-1, -1, L
" --------------------------------------------------------------------------");
3434 Status
= PciExplainBar (
3435 &(Bridge
->Bar
[Index
]),
3436 &(mConfigSpace
->Common
.Command
),
3442 if (EFI_ERROR (Status
)) {
3448 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NONE
), gShellDebug1HiiHandle
);
3450 ShellPrintEx (-1, -1, L
"\r\n --------------------------------------------------------------------------");
3454 // Expansion register ROM Base Address
3456 if ((Bridge
->ExpansionRomBAR
& BIT0
) == 0) {
3457 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NO_EXPANSION_ROM
), gShellDebug1HiiHandle
, INDEX_OF (&(Bridge
->ExpansionRomBAR
)));
3460 ShellPrintHiiEx(-1, -1, NULL
,
3461 STRING_TOKEN (STR_PCI2_EXPANSION_ROM_BASE_2
),
3462 gShellDebug1HiiHandle
,
3463 INDEX_OF (&(Bridge
->ExpansionRomBAR
)),
3464 Bridge
->ExpansionRomBAR
3468 // Print Bus Numbers(Primary, Secondary, and Subordinate
3470 ShellPrintHiiEx(-1, -1, NULL
,
3471 STRING_TOKEN (STR_PCI2_BUS_NUMBERS
),
3472 gShellDebug1HiiHandle
,
3473 INDEX_OF (&(Bridge
->PrimaryBus
)),
3474 INDEX_OF (&(Bridge
->SecondaryBus
)),
3475 INDEX_OF (&(Bridge
->SubordinateBus
))
3478 ShellPrintEx (-1, -1, L
" ------------------------------------------------------\r\n");
3480 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BRIDGE
), gShellDebug1HiiHandle
, Bridge
->PrimaryBus
);
3481 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BRIDGE
), gShellDebug1HiiHandle
, Bridge
->SecondaryBus
);
3482 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BRIDGE
), gShellDebug1HiiHandle
, Bridge
->SubordinateBus
);
3485 // Print register Secondary Latency Timer
3487 ShellPrintHiiEx(-1, -1, NULL
,
3488 STRING_TOKEN (STR_PCI2_SECONDARY_TIMER
),
3489 gShellDebug1HiiHandle
,
3490 INDEX_OF (&(Bridge
->SecondaryLatencyTimer
)),
3491 Bridge
->SecondaryLatencyTimer
3495 // Print register Secondary Status
3497 PciExplainStatus (&(Bridge
->SecondaryStatus
), FALSE
, PciP2pBridge
);
3500 // Print I/O and memory ranges this bridge forwards. There are 3 resource
3501 // types: I/O, memory, and pre-fetchable memory. For each resource type,
3502 // base and limit address are listed.
3504 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RESOURCE_TYPE
), gShellDebug1HiiHandle
);
3505 ShellPrintEx (-1, -1, L
"----------------------------------------------------------------------\r\n");
3510 IoAddress32
= (Bridge
->IoBaseUpper16
<< 16 | Bridge
->IoBase
<< 8);
3511 IoAddress32
&= 0xfffff000;
3512 ShellPrintHiiEx(-1, -1, NULL
,
3513 STRING_TOKEN (STR_PCI2_TWO_VARS
),
3514 gShellDebug1HiiHandle
,
3515 INDEX_OF (&(Bridge
->IoBase
)),
3519 IoAddress32
= (Bridge
->IoLimitUpper16
<< 16 | Bridge
->IoLimit
<< 8);
3520 IoAddress32
|= 0x00000fff;
3521 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_ONE_VAR
), gShellDebug1HiiHandle
, IoAddress32
);
3524 // Memory Base & Limit
3526 ShellPrintHiiEx(-1, -1, NULL
,
3527 STRING_TOKEN (STR_PCI2_MEMORY
),
3528 gShellDebug1HiiHandle
,
3529 INDEX_OF (&(Bridge
->MemoryBase
)),
3530 (Bridge
->MemoryBase
<< 16) & 0xfff00000
3533 ShellPrintHiiEx(-1, -1, NULL
,
3534 STRING_TOKEN (STR_PCI2_ONE_VAR
),
3535 gShellDebug1HiiHandle
,
3536 (Bridge
->MemoryLimit
<< 16) | 0x000fffff
3540 // Pre-fetch-able Memory Base & Limit
3542 ShellPrintHiiEx(-1, -1, NULL
,
3543 STRING_TOKEN (STR_PCI2_PREFETCHABLE
),
3544 gShellDebug1HiiHandle
,
3545 INDEX_OF (&(Bridge
->PrefetchableMemoryBase
)),
3546 Bridge
->PrefetchableBaseUpper32
,
3547 (Bridge
->PrefetchableMemoryBase
<< 16) & 0xfff00000
3550 ShellPrintHiiEx(-1, -1, NULL
,
3551 STRING_TOKEN (STR_PCI2_TWO_VARS_2
),
3552 gShellDebug1HiiHandle
,
3553 Bridge
->PrefetchableLimitUpper32
,
3554 (Bridge
->PrefetchableMemoryLimit
<< 16) | 0x000fffff
3558 // Print register Capabilities Pointer
3560 ShellPrintHiiEx(-1, -1, NULL
,
3561 STRING_TOKEN (STR_PCI2_CAPABILITIES_PTR_2
),
3562 gShellDebug1HiiHandle
,
3563 INDEX_OF (&(Bridge
->CapabilityPtr
)),
3564 Bridge
->CapabilityPtr
3568 // Print register Bridge Control
3570 PciExplainBridgeControl (&(Bridge
->BridgeControl
), PciP2pBridge
);
3573 // Print register Interrupt Line & PIN
3575 ShellPrintHiiEx(-1, -1, NULL
,
3576 STRING_TOKEN (STR_PCI2_INTERRUPT_LINE_2
),
3577 gShellDebug1HiiHandle
,
3578 INDEX_OF (&(Bridge
->InterruptLine
)),
3579 Bridge
->InterruptLine
3582 ShellPrintHiiEx(-1, -1, NULL
,
3583 STRING_TOKEN (STR_PCI2_INTERRUPT_PIN
),
3584 gShellDebug1HiiHandle
,
3585 INDEX_OF (&(Bridge
->InterruptPin
)),
3586 Bridge
->InterruptPin
3593 Explain the Base Address Register(Bar) in PCI configuration space.
3595 @param[in] Bar Points to the Base Address Register intended to interpret.
3596 @param[in] Command Points to the register Command.
3597 @param[in] Address Address used to access configuration space of this PCI device.
3598 @param[in] IoDev Handle used to access configuration space of PCI device.
3599 @param[in, out] Index The Index.
3601 @retval EFI_SUCCESS The command completed successfully.
3608 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
,
3629 // According the bar type, list detail about this bar, for example: 32 or
3630 // 64 bits; pre-fetchable or not.
3632 if ((*Bar
& BIT0
) == 0) {
3634 // This bar is of memory type
3638 if ((*Bar
& BIT1
) == 0 && (*Bar
& BIT2
) == 0) {
3639 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BAR
), gShellDebug1HiiHandle
, *Bar
& 0xfffffff0);
3640 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MEM
), gShellDebug1HiiHandle
);
3641 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_32_BITS
), gShellDebug1HiiHandle
);
3643 } else if ((*Bar
& BIT1
) == 0 && (*Bar
& BIT2
) != 0) {
3645 CopyMem (&Bar64
, Bar
, sizeof (UINT64
));
3646 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_ONE_VAR_2
), gShellDebug1HiiHandle
, (UINT32
) RShiftU64 ((Bar64
& 0xfffffffffffffff0ULL
), 32));
3647 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_ONE_VAR_3
), gShellDebug1HiiHandle
, (UINT32
) (Bar64
& 0xfffffffffffffff0ULL
));
3648 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MEM
), gShellDebug1HiiHandle
);
3649 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_64_BITS
), gShellDebug1HiiHandle
);
3657 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BAR
), gShellDebug1HiiHandle
, *Bar
& 0xfffffff0);
3658 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MEM_2
), gShellDebug1HiiHandle
);
3661 if ((*Bar
& BIT3
) == 0) {
3662 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NO
), gShellDebug1HiiHandle
);
3665 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_YES
), gShellDebug1HiiHandle
);
3670 // This bar is of io type
3673 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_ONE_VAR_4
), gShellDebug1HiiHandle
, *Bar
& 0xfffffffc);
3674 ShellPrintEx (-1, -1, L
"I/O ");
3678 // Get BAR length(or the amount of resource this bar demands for). To get
3679 // Bar length, first we should temporarily disable I/O and memory access
3680 // of this function(by set bits in the register Command), then write all
3681 // "1"s to this bar. The bar value read back is the amount of resource
3682 // this bar demands for.
3685 // Disable io & mem access
3687 OldCommand
= *Command
;
3688 NewCommand
= (UINT16
) (OldCommand
& 0xfffc);
3689 RegAddress
= Address
| INDEX_OF (Command
);
3690 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint16
, RegAddress
, 1, &NewCommand
);
3692 RegAddress
= Address
| INDEX_OF (Bar
);
3695 // Read after write the BAR to get the size
3699 NewBar32
= 0xffffffff;
3701 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint32
, RegAddress
, 1, &NewBar32
);
3702 IoDev
->Pci
.Read (IoDev
, EfiPciWidthUint32
, RegAddress
, 1, &NewBar32
);
3703 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint32
, RegAddress
, 1, &OldBar32
);
3706 NewBar32
= NewBar32
& 0xfffffff0;
3707 NewBar32
= (~NewBar32
) + 1;
3710 NewBar32
= NewBar32
& 0xfffffffc;
3711 NewBar32
= (~NewBar32
) + 1;
3712 NewBar32
= NewBar32
& 0x0000ffff;
3717 CopyMem (&OldBar64
, Bar
, sizeof (UINT64
));
3718 NewBar64
= 0xffffffffffffffffULL
;
3720 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint32
, RegAddress
, 2, &NewBar64
);
3721 IoDev
->Pci
.Read (IoDev
, EfiPciWidthUint32
, RegAddress
, 2, &NewBar64
);
3722 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint32
, RegAddress
, 2, &OldBar64
);
3725 NewBar64
= NewBar64
& 0xfffffffffffffff0ULL
;
3726 NewBar64
= (~NewBar64
) + 1;
3729 NewBar64
= NewBar64
& 0xfffffffffffffffcULL
;
3730 NewBar64
= (~NewBar64
) + 1;
3731 NewBar64
= NewBar64
& 0x000000000000ffff;
3735 // Enable io & mem access
3737 RegAddress
= Address
| INDEX_OF (Command
);
3738 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint16
, RegAddress
, 1, &OldCommand
);
3742 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NEWBAR_32
), gShellDebug1HiiHandle
, NewBar32
);
3743 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NEWBAR_32_2
), gShellDebug1HiiHandle
, NewBar32
+ (*Bar
& 0xfffffff0) - 1);
3746 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RSHIFT
), gShellDebug1HiiHandle
, (UINT32
) RShiftU64 (NewBar64
, 32));
3747 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RSHIFT
), gShellDebug1HiiHandle
, (UINT32
) NewBar64
);
3748 ShellPrintEx (-1, -1, L
" ");
3749 ShellPrintHiiEx(-1, -1, NULL
,
3750 STRING_TOKEN (STR_PCI2_RSHIFT
),
3751 gShellDebug1HiiHandle
,
3752 (UINT32
) RShiftU64 ((NewBar64
+ (Bar64
& 0xfffffffffffffff0ULL
) - 1), 32)
3754 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RSHIFT
), gShellDebug1HiiHandle
, (UINT32
) (NewBar64
+ (Bar64
& 0xfffffffffffffff0ULL
) - 1));
3758 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NEWBAR_32_3
), gShellDebug1HiiHandle
, NewBar32
);
3759 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NEWBAR_32_4
), gShellDebug1HiiHandle
, NewBar32
+ (*Bar
& 0xfffffffc) - 1);
3766 Explain the cardbus specific part of data in PCI configuration space.
3768 @param[in] CardBus CardBus specific region of PCI configuration space.
3769 @param[in] Address Address used to access configuration space of this PCI device.
3770 @param[in] IoDev Handle used to access configuration space of PCI device.
3772 @retval EFI_SUCCESS The command completed successfully.
3775 PciExplainCardBusData (
3776 IN PCI_CARDBUS_CONTROL_REGISTER
*CardBus
,
3778 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
3782 PCI_CARDBUS_DATA
*CardBusData
;
3784 ShellPrintHiiEx(-1, -1, NULL
,
3785 STRING_TOKEN (STR_PCI2_CARDBUS_SOCKET
),
3786 gShellDebug1HiiHandle
,
3787 INDEX_OF (&(CardBus
->CardBusSocketReg
)),
3788 CardBus
->CardBusSocketReg
3792 // Print Secondary Status
3794 PciExplainStatus (&(CardBus
->SecondaryStatus
), FALSE
, PciCardBusBridge
);
3797 // Print Bus Numbers(Primary bus number, CardBus bus number, and
3798 // Subordinate bus number
3800 ShellPrintHiiEx(-1, -1, NULL
,
3801 STRING_TOKEN (STR_PCI2_BUS_NUMBERS_2
),
3802 gShellDebug1HiiHandle
,
3803 INDEX_OF (&(CardBus
->PciBusNumber
)),
3804 INDEX_OF (&(CardBus
->CardBusBusNumber
)),
3805 INDEX_OF (&(CardBus
->SubordinateBusNumber
))
3808 ShellPrintEx (-1, -1, L
" ------------------------------------------------------\r\n");
3810 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_CARDBUS
), gShellDebug1HiiHandle
, CardBus
->PciBusNumber
);
3811 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_CARDBUS_2
), gShellDebug1HiiHandle
, CardBus
->CardBusBusNumber
);
3812 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_CARDBUS_3
), gShellDebug1HiiHandle
, CardBus
->SubordinateBusNumber
);
3815 // Print CardBus Latency Timer
3817 ShellPrintHiiEx(-1, -1, NULL
,
3818 STRING_TOKEN (STR_PCI2_CARDBUS_LATENCY
),
3819 gShellDebug1HiiHandle
,
3820 INDEX_OF (&(CardBus
->CardBusLatencyTimer
)),
3821 CardBus
->CardBusLatencyTimer
3825 // Print Memory/Io ranges this cardbus bridge forwards
3827 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RESOURCE_TYPE_2
), gShellDebug1HiiHandle
);
3828 ShellPrintEx (-1, -1, L
"----------------------------------------------------------------------\r\n");
3830 ShellPrintHiiEx(-1, -1, NULL
,
3831 STRING_TOKEN (STR_PCI2_MEM_3
),
3832 gShellDebug1HiiHandle
,
3833 INDEX_OF (&(CardBus
->MemoryBase0
)),
3834 CardBus
->BridgeControl
& BIT8
? L
" Prefetchable" : L
"Non-Prefetchable",
3835 CardBus
->MemoryBase0
& 0xfffff000,
3836 CardBus
->MemoryLimit0
| 0x00000fff
3839 ShellPrintHiiEx(-1, -1, NULL
,
3840 STRING_TOKEN (STR_PCI2_MEM_3
),
3841 gShellDebug1HiiHandle
,
3842 INDEX_OF (&(CardBus
->MemoryBase1
)),
3843 CardBus
->BridgeControl
& BIT9
? L
" Prefetchable" : L
"Non-Prefetchable",
3844 CardBus
->MemoryBase1
& 0xfffff000,
3845 CardBus
->MemoryLimit1
| 0x00000fff
3848 Io32Bit
= (BOOLEAN
) (CardBus
->IoBase0
& BIT0
);
3849 ShellPrintHiiEx(-1, -1, NULL
,
3850 STRING_TOKEN (STR_PCI2_IO_2
),
3851 gShellDebug1HiiHandle
,
3852 INDEX_OF (&(CardBus
->IoBase0
)),
3853 Io32Bit
? L
" 32 bit" : L
" 16 bit",
3854 CardBus
->IoBase0
& (Io32Bit
? 0xfffffffc : 0x0000fffc),
3855 (CardBus
->IoLimit0
& (Io32Bit
? 0xffffffff : 0x0000ffff)) | 0x00000003
3858 Io32Bit
= (BOOLEAN
) (CardBus
->IoBase1
& BIT0
);
3859 ShellPrintHiiEx(-1, -1, NULL
,
3860 STRING_TOKEN (STR_PCI2_IO_2
),
3861 gShellDebug1HiiHandle
,
3862 INDEX_OF (&(CardBus
->IoBase1
)),
3863 Io32Bit
? L
" 32 bit" : L
" 16 bit",
3864 CardBus
->IoBase1
& (Io32Bit
? 0xfffffffc : 0x0000fffc),
3865 (CardBus
->IoLimit1
& (Io32Bit
? 0xffffffff : 0x0000ffff)) | 0x00000003
3869 // Print register Interrupt Line & PIN
3871 ShellPrintHiiEx(-1, -1, NULL
,
3872 STRING_TOKEN (STR_PCI2_INTERRUPT_LINE_3
),
3873 gShellDebug1HiiHandle
,
3874 INDEX_OF (&(CardBus
->InterruptLine
)),
3875 CardBus
->InterruptLine
,
3876 INDEX_OF (&(CardBus
->InterruptPin
)),
3877 CardBus
->InterruptPin
3881 // Print register Bridge Control
3883 PciExplainBridgeControl (&(CardBus
->BridgeControl
), PciCardBusBridge
);
3886 // Print some registers in data region of PCI configuration space for cardbus
3887 // bridge. Fields include: Sub VendorId, Subsystem ID, and Legacy Mode Base
3890 CardBusData
= (PCI_CARDBUS_DATA
*) ((UINT8
*) CardBus
+ sizeof (PCI_CARDBUS_CONTROL_REGISTER
));
3892 ShellPrintHiiEx(-1, -1, NULL
,
3893 STRING_TOKEN (STR_PCI2_SUB_VENDOR_ID_2
),
3894 gShellDebug1HiiHandle
,
3895 INDEX_OF (&(CardBusData
->SubVendorId
)),
3896 CardBusData
->SubVendorId
,
3897 INDEX_OF (&(CardBusData
->SubSystemId
)),
3898 CardBusData
->SubSystemId
3901 ShellPrintHiiEx(-1, -1, NULL
,
3902 STRING_TOKEN (STR_PCI2_OPTIONAL
),
3903 gShellDebug1HiiHandle
,
3904 INDEX_OF (&(CardBusData
->LegacyBase
)),
3905 CardBusData
->LegacyBase
3912 Explain each meaningful bit of register Status. The definition of Status is
3913 slightly different depending on the PCI header type.
3915 @param[in] Status Points to the content of register Status.
3916 @param[in] MainStatus Indicates if this register is main status(not secondary
3918 @param[in] HeaderType Header type of this PCI device.
3920 @retval EFI_SUCCESS The command completed successfully.
3925 IN BOOLEAN MainStatus
,
3926 IN PCI_HEADER_TYPE HeaderType
3930 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_STATUS
), gShellDebug1HiiHandle
, INDEX_OF (Status
), *Status
);
3933 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_SECONDARY_STATUS
), gShellDebug1HiiHandle
, INDEX_OF (Status
), *Status
);
3936 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NEW_CAPABILITIES
), gShellDebug1HiiHandle
, (*Status
& BIT4
) != 0);
3939 // Bit 5 is meaningless for CardBus Bridge
3941 if (HeaderType
== PciCardBusBridge
) {
3942 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_66_CAPABLE
), gShellDebug1HiiHandle
, (*Status
& BIT5
) != 0);
3945 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_66_CAPABLE_2
), gShellDebug1HiiHandle
, (*Status
& BIT5
) != 0);
3948 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_FAST_BACK
), gShellDebug1HiiHandle
, (*Status
& BIT7
) != 0);
3950 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MASTER_DATA
), gShellDebug1HiiHandle
, (*Status
& BIT8
) != 0);
3952 // Bit 9 and bit 10 together decides the DEVSEL timing
3954 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_DEVSEL_TIMING
), gShellDebug1HiiHandle
);
3955 if ((*Status
& BIT9
) == 0 && (*Status
& BIT10
) == 0) {
3956 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_FAST
), gShellDebug1HiiHandle
);
3958 } else if ((*Status
& BIT9
) != 0 && (*Status
& BIT10
) == 0) {
3959 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MEDIUM
), gShellDebug1HiiHandle
);
3961 } else if ((*Status
& BIT9
) == 0 && (*Status
& BIT10
) != 0) {
3962 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_SLOW
), gShellDebug1HiiHandle
);
3965 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RESERVED_2
), gShellDebug1HiiHandle
);
3968 ShellPrintHiiEx(-1, -1, NULL
,
3969 STRING_TOKEN (STR_PCI2_SIGNALED_TARGET
),
3970 gShellDebug1HiiHandle
,
3971 (*Status
& BIT11
) != 0
3974 ShellPrintHiiEx(-1, -1, NULL
,
3975 STRING_TOKEN (STR_PCI2_RECEIVED_TARGET
),
3976 gShellDebug1HiiHandle
,
3977 (*Status
& BIT12
) != 0
3980 ShellPrintHiiEx(-1, -1, NULL
,
3981 STRING_TOKEN (STR_PCI2_RECEIVED_MASTER
),
3982 gShellDebug1HiiHandle
,
3983 (*Status
& BIT13
) != 0
3987 ShellPrintHiiEx(-1, -1, NULL
,
3988 STRING_TOKEN (STR_PCI2_SIGNALED_ERROR
),
3989 gShellDebug1HiiHandle
,
3990 (*Status
& BIT14
) != 0
3994 ShellPrintHiiEx(-1, -1, NULL
,
3995 STRING_TOKEN (STR_PCI2_RECEIVED_ERROR
),
3996 gShellDebug1HiiHandle
,
3997 (*Status
& BIT14
) != 0
4001 ShellPrintHiiEx(-1, -1, NULL
,
4002 STRING_TOKEN (STR_PCI2_DETECTED_ERROR
),
4003 gShellDebug1HiiHandle
,
4004 (*Status
& BIT15
) != 0
4011 Explain each meaningful bit of register Command.
4013 @param[in] Command Points to the content of register Command.
4015 @retval EFI_SUCCESS The command completed successfully.
4023 // Print the binary value of register Command
4025 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_COMMAND
), gShellDebug1HiiHandle
, INDEX_OF (Command
), *Command
);
4028 // Explain register Command bit by bit
4030 ShellPrintHiiEx(-1, -1, NULL
,
4031 STRING_TOKEN (STR_PCI2_SPACE_ACCESS_DENIED
),
4032 gShellDebug1HiiHandle
,
4033 (*Command
& BIT0
) != 0
4036 ShellPrintHiiEx(-1, -1, NULL
,
4037 STRING_TOKEN (STR_PCI2_MEMORY_SPACE
),
4038 gShellDebug1HiiHandle
,
4039 (*Command
& BIT1
) != 0
4042 ShellPrintHiiEx(-1, -1, NULL
,
4043 STRING_TOKEN (STR_PCI2_BEHAVE_BUS_MASTER
),
4044 gShellDebug1HiiHandle
,
4045 (*Command
& BIT2
) != 0
4048 ShellPrintHiiEx(-1, -1, NULL
,
4049 STRING_TOKEN (STR_PCI2_MONITOR_SPECIAL_CYCLE
),
4050 gShellDebug1HiiHandle
,
4051 (*Command
& BIT3
) != 0
4054 ShellPrintHiiEx(-1, -1, NULL
,
4055 STRING_TOKEN (STR_PCI2_MEM_WRITE_INVALIDATE
),
4056 gShellDebug1HiiHandle
,
4057 (*Command
& BIT4
) != 0
4060 ShellPrintHiiEx(-1, -1, NULL
,
4061 STRING_TOKEN (STR_PCI2_PALETTE_SNOOPING
),
4062 gShellDebug1HiiHandle
,
4063 (*Command
& BIT5
) != 0
4066 ShellPrintHiiEx(-1, -1, NULL
,
4067 STRING_TOKEN (STR_PCI2_ASSERT_PERR
),
4068 gShellDebug1HiiHandle
,
4069 (*Command
& BIT6
) != 0
4072 ShellPrintHiiEx(-1, -1, NULL
,
4073 STRING_TOKEN (STR_PCI2_DO_ADDR_STEPPING
),
4074 gShellDebug1HiiHandle
,
4075 (*Command
& BIT7
) != 0
4078 ShellPrintHiiEx(-1, -1, NULL
,
4079 STRING_TOKEN (STR_PCI2_SERR_DRIVER
),
4080 gShellDebug1HiiHandle
,
4081 (*Command
& BIT8
) != 0
4084 ShellPrintHiiEx(-1, -1, NULL
,
4085 STRING_TOKEN (STR_PCI2_FAST_BACK_2
),
4086 gShellDebug1HiiHandle
,
4087 (*Command
& BIT9
) != 0
4094 Explain each meaningful bit of register Bridge Control.
4096 @param[in] BridgeControl Points to the content of register Bridge Control.
4097 @param[in] HeaderType The headertype.
4099 @retval EFI_SUCCESS The command completed successfully.
4102 PciExplainBridgeControl (
4103 IN UINT16
*BridgeControl
,
4104 IN PCI_HEADER_TYPE HeaderType
4107 ShellPrintHiiEx(-1, -1, NULL
,
4108 STRING_TOKEN (STR_PCI2_BRIDGE_CONTROL
),
4109 gShellDebug1HiiHandle
,
4110 INDEX_OF (BridgeControl
),
4114 ShellPrintHiiEx(-1, -1, NULL
,
4115 STRING_TOKEN (STR_PCI2_PARITY_ERROR
),
4116 gShellDebug1HiiHandle
,
4117 (*BridgeControl
& BIT0
) != 0
4119 ShellPrintHiiEx(-1, -1, NULL
,
4120 STRING_TOKEN (STR_PCI2_SERR_ENABLE
),
4121 gShellDebug1HiiHandle
,
4122 (*BridgeControl
& BIT1
) != 0
4124 ShellPrintHiiEx(-1, -1, NULL
,
4125 STRING_TOKEN (STR_PCI2_ISA_ENABLE
),
4126 gShellDebug1HiiHandle
,
4127 (*BridgeControl
& BIT2
) != 0
4129 ShellPrintHiiEx(-1, -1, NULL
,
4130 STRING_TOKEN (STR_PCI2_VGA_ENABLE
),
4131 gShellDebug1HiiHandle
,
4132 (*BridgeControl
& BIT3
) != 0
4134 ShellPrintHiiEx(-1, -1, NULL
,
4135 STRING_TOKEN (STR_PCI2_MASTER_ABORT
),
4136 gShellDebug1HiiHandle
,
4137 (*BridgeControl
& BIT5
) != 0
4141 // Register Bridge Control has some slight differences between P2P bridge
4142 // and Cardbus bridge from bit 6 to bit 11.
4144 if (HeaderType
== PciP2pBridge
) {
4145 ShellPrintHiiEx(-1, -1, NULL
,
4146 STRING_TOKEN (STR_PCI2_SECONDARY_BUS_RESET
),
4147 gShellDebug1HiiHandle
,
4148 (*BridgeControl
& BIT6
) != 0
4150 ShellPrintHiiEx(-1, -1, NULL
,
4151 STRING_TOKEN (STR_PCI2_FAST_ENABLE
),
4152 gShellDebug1HiiHandle
,
4153 (*BridgeControl
& BIT7
) != 0
4155 ShellPrintHiiEx(-1, -1, NULL
,
4156 STRING_TOKEN (STR_PCI2_PRIMARY_DISCARD_TIMER
),
4157 gShellDebug1HiiHandle
,
4158 (*BridgeControl
& BIT8
)!=0 ? L
"2^10" : L
"2^15"
4160 ShellPrintHiiEx(-1, -1, NULL
,
4161 STRING_TOKEN (STR_PCI2_SECONDARY_DISCARD_TIMER
),
4162 gShellDebug1HiiHandle
,
4163 (*BridgeControl
& BIT9
)!=0 ? L
"2^10" : L
"2^15"
4165 ShellPrintHiiEx(-1, -1, NULL
,
4166 STRING_TOKEN (STR_PCI2_DISCARD_TIMER_STATUS
),
4167 gShellDebug1HiiHandle
,
4168 (*BridgeControl
& BIT10
) != 0
4170 ShellPrintHiiEx(-1, -1, NULL
,
4171 STRING_TOKEN (STR_PCI2_DISCARD_TIMER_SERR
),
4172 gShellDebug1HiiHandle
,
4173 (*BridgeControl
& BIT11
) != 0
4177 ShellPrintHiiEx(-1, -1, NULL
,
4178 STRING_TOKEN (STR_PCI2_CARDBUS_RESET
),
4179 gShellDebug1HiiHandle
,
4180 (*BridgeControl
& BIT6
) != 0
4182 ShellPrintHiiEx(-1, -1, NULL
,
4183 STRING_TOKEN (STR_PCI2_IREQ_ENABLE
),
4184 gShellDebug1HiiHandle
,
4185 (*BridgeControl
& BIT7
) != 0
4187 ShellPrintHiiEx(-1, -1, NULL
,
4188 STRING_TOKEN (STR_PCI2_WRITE_POSTING_ENABLE
),
4189 gShellDebug1HiiHandle
,
4190 (*BridgeControl
& BIT10
) != 0
4198 Locate capability register block per capability ID.
4200 @param[in] ConfigSpace Data in PCI configuration space.
4201 @param[in] CapabilityId The capability ID.
4203 @return The offset of the register block per capability ID,
4204 or 0 if the register block cannot be found.
4207 LocatePciCapability (
4208 IN PCI_CONFIG_SPACE
*ConfigSpace
,
4209 IN UINT8 CapabilityId
4212 UINT8 CapabilityPtr
;
4213 EFI_PCI_CAPABILITY_HDR
*CapabilityEntry
;
4216 // To check the cpability of this device supports
4218 if ((ConfigSpace
->Common
.Status
& EFI_PCI_STATUS_CAPABILITY
) == 0) {
4222 switch ((PCI_HEADER_TYPE
)(ConfigSpace
->Common
.HeaderType
& 0x7f)) {
4224 CapabilityPtr
= ConfigSpace
->NonCommon
.Device
.CapabilityPtr
;
4227 CapabilityPtr
= ConfigSpace
->NonCommon
.Bridge
.CapabilityPtr
;
4229 case PciCardBusBridge
:
4230 CapabilityPtr
= ConfigSpace
->NonCommon
.CardBus
.Cap_Ptr
;
4236 while ((CapabilityPtr
>= 0x40) && ((CapabilityPtr
& 0x03) == 0x00)) {
4237 CapabilityEntry
= (EFI_PCI_CAPABILITY_HDR
*) ((UINT8
*) ConfigSpace
+ CapabilityPtr
);
4238 if (CapabilityEntry
->CapabilityID
== CapabilityId
) {
4239 return CapabilityPtr
;
4243 // Certain PCI device may incorrectly have capability pointing to itself,
4244 // break to avoid dead loop.
4246 if (CapabilityPtr
== CapabilityEntry
->NextItemPtr
) {
4250 CapabilityPtr
= CapabilityEntry
->NextItemPtr
;
4257 Print out information of the capability information.
4259 @param[in] PciExpressCap The pointer to the structure about the device.
4261 @retval EFI_SUCCESS The operation was successful.
4265 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4268 CHAR16
*DevicePortType
;
4270 ShellPrintEx (-1, -1,
4271 L
" Capability Version(3:0): %E0x%04x%N\r\n",
4272 PciExpressCap
->Capability
.Bits
.Version
4274 if (PciExpressCap
->Capability
.Bits
.DevicePortType
< ARRAY_SIZE (DevicePortTypeTable
)) {
4275 DevicePortType
= DevicePortTypeTable
[PciExpressCap
->Capability
.Bits
.DevicePortType
];
4277 DevicePortType
= L
"Unknown Type";
4279 ShellPrintEx (-1, -1,
4280 L
" Device/PortType(7:4): %E%s%N\r\n",
4284 // 'Slot Implemented' is only valid for:
4285 // a) Root Port of PCI Express Root Complex, or
4286 // b) Downstream Port of PCI Express Switch
4288 if (PciExpressCap
->Capability
.Bits
.DevicePortType
== PCIE_DEVICE_PORT_TYPE_ROOT_PORT
||
4289 PciExpressCap
->Capability
.Bits
.DevicePortType
== PCIE_DEVICE_PORT_TYPE_DOWNSTREAM_PORT
) {
4290 ShellPrintEx (-1, -1,
4291 L
" Slot Implemented(8): %E%d%N\r\n",
4292 PciExpressCap
->Capability
.Bits
.SlotImplemented
4295 ShellPrintEx (-1, -1,
4296 L
" Interrupt Message Number(13:9): %E0x%05x%N\r\n",
4297 PciExpressCap
->Capability
.Bits
.InterruptMessageNumber
4303 Print out information of the device capability information.
4305 @param[in] PciExpressCap The pointer to the structure about the device.
4307 @retval EFI_SUCCESS The operation was successful.
4310 ExplainPcieDeviceCap (
4311 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4314 UINT8 DevicePortType
;
4318 DevicePortType
= (UINT8
)PciExpressCap
->Capability
.Bits
.DevicePortType
;
4319 ShellPrintEx (-1, -1, L
" Max_Payload_Size Supported(2:0): ");
4320 if (PciExpressCap
->DeviceCapability
.Bits
.MaxPayloadSize
< 6) {
4321 ShellPrintEx (-1, -1, L
"%E%d bytes%N\r\n", 1 << (PciExpressCap
->DeviceCapability
.Bits
.MaxPayloadSize
+ 7));
4323 ShellPrintEx (-1, -1, L
"%EUnknown%N\r\n");
4325 ShellPrintEx (-1, -1,
4326 L
" Phantom Functions Supported(4:3): %E%d%N\r\n",
4327 PciExpressCap
->DeviceCapability
.Bits
.PhantomFunctions
4329 ShellPrintEx (-1, -1,
4330 L
" Extended Tag Field Supported(5): %E%d-bit Tag field supported%N\r\n",
4331 PciExpressCap
->DeviceCapability
.Bits
.ExtendedTagField
? 8 : 5
4334 // Endpoint L0s and L1 Acceptable Latency is only valid for Endpoint
4336 if (IS_PCIE_ENDPOINT (DevicePortType
)) {
4337 L0sLatency
= (UINT8
)PciExpressCap
->DeviceCapability
.Bits
.EndpointL0sAcceptableLatency
;
4338 L1Latency
= (UINT8
)PciExpressCap
->DeviceCapability
.Bits
.EndpointL1AcceptableLatency
;
4339 ShellPrintEx (-1, -1, L
" Endpoint L0s Acceptable Latency(8:6): ");
4340 if (L0sLatency
< 4) {
4341 ShellPrintEx (-1, -1, L
"%EMaximum of %d ns%N\r\n", 1 << (L0sLatency
+ 6));
4343 if (L0sLatency
< 7) {
4344 ShellPrintEx (-1, -1, L
"%EMaximum of %d us%N\r\n", 1 << (L0sLatency
- 3));
4346 ShellPrintEx (-1, -1, L
"%ENo limit%N\r\n");
4349 ShellPrintEx (-1, -1, L
" Endpoint L1 Acceptable Latency(11:9): ");
4350 if (L1Latency
< 7) {
4351 ShellPrintEx (-1, -1, L
"%EMaximum of %d us%N\r\n", 1 << (L1Latency
+ 1));
4353 ShellPrintEx (-1, -1, L
"%ENo limit%N\r\n");
4356 ShellPrintEx (-1, -1,
4357 L
" Role-based Error Reporting(15): %E%d%N\r\n",
4358 PciExpressCap
->DeviceCapability
.Bits
.RoleBasedErrorReporting
4361 // Only valid for Upstream Port:
4362 // a) Captured Slot Power Limit Value
4363 // b) Captured Slot Power Scale
4365 if (DevicePortType
== PCIE_DEVICE_PORT_TYPE_UPSTREAM_PORT
) {
4366 ShellPrintEx (-1, -1,
4367 L
" Captured Slot Power Limit Value(25:18): %E0x%02x%N\r\n",
4368 PciExpressCap
->DeviceCapability
.Bits
.CapturedSlotPowerLimitValue
4370 ShellPrintEx (-1, -1,
4371 L
" Captured Slot Power Limit Scale(27:26): %E%s%N\r\n",
4372 SlotPwrLmtScaleTable
[PciExpressCap
->DeviceCapability
.Bits
.CapturedSlotPowerLimitScale
]
4376 // Function Level Reset Capability is only valid for Endpoint
4378 if (IS_PCIE_ENDPOINT (DevicePortType
)) {
4379 ShellPrintEx (-1, -1,
4380 L
" Function Level Reset Capability(28): %E%d%N\r\n",
4381 PciExpressCap
->DeviceCapability
.Bits
.FunctionLevelReset
4388 Print out information of the device control information.
4390 @param[in] PciExpressCap The pointer to the structure about the device.
4392 @retval EFI_SUCCESS The operation was successful.
4395 ExplainPcieDeviceControl (
4396 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4399 ShellPrintEx (-1, -1,
4400 L
" Correctable Error Reporting Enable(0): %E%d%N\r\n",
4401 PciExpressCap
->DeviceControl
.Bits
.CorrectableError
4403 ShellPrintEx (-1, -1,
4404 L
" Non-Fatal Error Reporting Enable(1): %E%d%N\r\n",
4405 PciExpressCap
->DeviceControl
.Bits
.NonFatalError
4407 ShellPrintEx (-1, -1,
4408 L
" Fatal Error Reporting Enable(2): %E%d%N\r\n",
4409 PciExpressCap
->DeviceControl
.Bits
.FatalError
4411 ShellPrintEx (-1, -1,
4412 L
" Unsupported Request Reporting Enable(3): %E%d%N\r\n",
4413 PciExpressCap
->DeviceControl
.Bits
.UnsupportedRequest
4415 ShellPrintEx (-1, -1,
4416 L
" Enable Relaxed Ordering(4): %E%d%N\r\n",
4417 PciExpressCap
->DeviceControl
.Bits
.RelaxedOrdering
4419 ShellPrintEx (-1, -1, L
" Max_Payload_Size(7:5): ");
4420 if (PciExpressCap
->DeviceControl
.Bits
.MaxPayloadSize
< 6) {
4421 ShellPrintEx (-1, -1, L
"%E%d bytes%N\r\n", 1 << (PciExpressCap
->DeviceControl
.Bits
.MaxPayloadSize
+ 7));
4423 ShellPrintEx (-1, -1, L
"%EUnknown%N\r\n");
4425 ShellPrintEx (-1, -1,
4426 L
" Extended Tag Field Enable(8): %E%d%N\r\n",
4427 PciExpressCap
->DeviceControl
.Bits
.ExtendedTagField
4429 ShellPrintEx (-1, -1,
4430 L
" Phantom Functions Enable(9): %E%d%N\r\n",
4431 PciExpressCap
->DeviceControl
.Bits
.PhantomFunctions
4433 ShellPrintEx (-1, -1,
4434 L
" Auxiliary (AUX) Power PM Enable(10): %E%d%N\r\n",
4435 PciExpressCap
->DeviceControl
.Bits
.AuxPower
4437 ShellPrintEx (-1, -1,
4438 L
" Enable No Snoop(11): %E%d%N\r\n",
4439 PciExpressCap
->DeviceControl
.Bits
.NoSnoop
4441 ShellPrintEx (-1, -1, L
" Max_Read_Request_Size(14:12): ");
4442 if (PciExpressCap
->DeviceControl
.Bits
.MaxReadRequestSize
< 6) {
4443 ShellPrintEx (-1, -1, L
"%E%d bytes%N\r\n", 1 << (PciExpressCap
->DeviceControl
.Bits
.MaxReadRequestSize
+ 7));
4445 ShellPrintEx (-1, -1, L
"%EUnknown%N\r\n");
4448 // Read operation is only valid for PCI Express to PCI/PCI-X Bridges
4450 if (PciExpressCap
->Capability
.Bits
.DevicePortType
== PCIE_DEVICE_PORT_TYPE_PCIE_TO_PCI_BRIDGE
) {
4451 ShellPrintEx (-1, -1,
4452 L
" Bridge Configuration Retry Enable(15): %E%d%N\r\n",
4453 PciExpressCap
->DeviceControl
.Bits
.BridgeConfigurationRetryOrFunctionLevelReset
4460 Print out information of the device status information.
4462 @param[in] PciExpressCap The pointer to the structure about the device.
4464 @retval EFI_SUCCESS The operation was successful.
4467 ExplainPcieDeviceStatus (
4468 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4471 ShellPrintEx (-1, -1,
4472 L
" Correctable Error Detected(0): %E%d%N\r\n",
4473 PciExpressCap
->DeviceStatus
.Bits
.CorrectableError
4475 ShellPrintEx (-1, -1,
4476 L
" Non-Fatal Error Detected(1): %E%d%N\r\n",
4477 PciExpressCap
->DeviceStatus
.Bits
.NonFatalError
4479 ShellPrintEx (-1, -1,
4480 L
" Fatal Error Detected(2): %E%d%N\r\n",
4481 PciExpressCap
->DeviceStatus
.Bits
.FatalError
4483 ShellPrintEx (-1, -1,
4484 L
" Unsupported Request Detected(3): %E%d%N\r\n",
4485 PciExpressCap
->DeviceStatus
.Bits
.UnsupportedRequest
4487 ShellPrintEx (-1, -1,
4488 L
" AUX Power Detected(4): %E%d%N\r\n",
4489 PciExpressCap
->DeviceStatus
.Bits
.AuxPower
4491 ShellPrintEx (-1, -1,
4492 L
" Transactions Pending(5): %E%d%N\r\n",
4493 PciExpressCap
->DeviceStatus
.Bits
.TransactionsPending
4499 Print out information of the device link information.
4501 @param[in] PciExpressCap The pointer to the structure about the device.
4503 @retval EFI_SUCCESS The operation was successful.
4506 ExplainPcieLinkCap (
4507 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4510 CHAR16
*MaxLinkSpeed
;
4513 switch (PciExpressCap
->LinkCapability
.Bits
.MaxLinkSpeed
) {
4515 MaxLinkSpeed
= L
"2.5 GT/s";
4518 MaxLinkSpeed
= L
"5.0 GT/s";
4521 MaxLinkSpeed
= L
"8.0 GT/s";
4524 MaxLinkSpeed
= L
"Unknown";
4527 ShellPrintEx (-1, -1,
4528 L
" Maximum Link Speed(3:0): %E%s%N\r\n",
4531 ShellPrintEx (-1, -1,
4532 L
" Maximum Link Width(9:4): %Ex%d%N\r\n",
4533 PciExpressCap
->LinkCapability
.Bits
.MaxLinkWidth
4535 switch (PciExpressCap
->LinkCapability
.Bits
.Aspm
) {
4546 AspmValue
= L
"L0s and L1";
4549 AspmValue
= L
"Reserved";
4552 ShellPrintEx (-1, -1,
4553 L
" Active State Power Management Support(11:10): %E%s Supported%N\r\n",
4556 ShellPrintEx (-1, -1,
4557 L
" L0s Exit Latency(14:12): %E%s%N\r\n",
4558 L0sLatencyStrTable
[PciExpressCap
->LinkCapability
.Bits
.L0sExitLatency
]
4560 ShellPrintEx (-1, -1,
4561 L
" L1 Exit Latency(17:15): %E%s%N\r\n",
4562 L1LatencyStrTable
[PciExpressCap
->LinkCapability
.Bits
.L1ExitLatency
]
4564 ShellPrintEx (-1, -1,
4565 L
" Clock Power Management(18): %E%d%N\r\n",
4566 PciExpressCap
->LinkCapability
.Bits
.ClockPowerManagement
4568 ShellPrintEx (-1, -1,
4569 L
" Surprise Down Error Reporting Capable(19): %E%d%N\r\n",
4570 PciExpressCap
->LinkCapability
.Bits
.SurpriseDownError
4572 ShellPrintEx (-1, -1,
4573 L
" Data Link Layer Link Active Reporting Capable(20): %E%d%N\r\n",
4574 PciExpressCap
->LinkCapability
.Bits
.DataLinkLayerLinkActive
4576 ShellPrintEx (-1, -1,
4577 L
" Link Bandwidth Notification Capability(21): %E%d%N\r\n",
4578 PciExpressCap
->LinkCapability
.Bits
.LinkBandwidthNotification
4580 ShellPrintEx (-1, -1,
4581 L
" Port Number(31:24): %E0x%02x%N\r\n",
4582 PciExpressCap
->LinkCapability
.Bits
.PortNumber
4588 Print out information of the device link control information.
4590 @param[in] PciExpressCap The pointer to the structure about the device.
4592 @retval EFI_SUCCESS The operation was successful.
4595 ExplainPcieLinkControl (
4596 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4599 UINT8 DevicePortType
;
4601 DevicePortType
= (UINT8
)PciExpressCap
->Capability
.Bits
.DevicePortType
;
4602 ShellPrintEx (-1, -1,
4603 L
" Active State Power Management Control(1:0): %E%s%N\r\n",
4604 ASPMCtrlStrTable
[PciExpressCap
->LinkControl
.Bits
.AspmControl
]
4607 // RCB is not applicable to switches
4609 if (!IS_PCIE_SWITCH(DevicePortType
)) {
4610 ShellPrintEx (-1, -1,
4611 L
" Read Completion Boundary (RCB)(3): %E%d byte%N\r\n",
4612 1 << (PciExpressCap
->LinkControl
.Bits
.ReadCompletionBoundary
+ 6)
4616 // Link Disable is reserved on
4618 // b) PCI Express to PCI/PCI-X bridges
4619 // c) Upstream Ports of Switches
4621 if (!IS_PCIE_ENDPOINT (DevicePortType
) &&
4622 DevicePortType
!= PCIE_DEVICE_PORT_TYPE_UPSTREAM_PORT
&&
4623 DevicePortType
!= PCIE_DEVICE_PORT_TYPE_PCIE_TO_PCI_BRIDGE
) {
4624 ShellPrintEx (-1, -1,
4625 L
" Link Disable(4): %E%d%N\r\n",
4626 PciExpressCap
->LinkControl
.Bits
.LinkDisable
4629 ShellPrintEx (-1, -1,
4630 L
" Common Clock Configuration(6): %E%d%N\r\n",
4631 PciExpressCap
->LinkControl
.Bits
.CommonClockConfiguration
4633 ShellPrintEx (-1, -1,
4634 L
" Extended Synch(7): %E%d%N\r\n",
4635 PciExpressCap
->LinkControl
.Bits
.ExtendedSynch
4637 ShellPrintEx (-1, -1,
4638 L
" Enable Clock Power Management(8): %E%d%N\r\n",
4639 PciExpressCap
->LinkControl
.Bits
.ClockPowerManagement
4641 ShellPrintEx (-1, -1,
4642 L
" Hardware Autonomous Width Disable(9): %E%d%N\r\n",
4643 PciExpressCap
->LinkControl
.Bits
.HardwareAutonomousWidthDisable
4645 ShellPrintEx (-1, -1,
4646 L
" Link Bandwidth Management Interrupt Enable(10): %E%d%N\r\n",
4647 PciExpressCap
->LinkControl
.Bits
.LinkBandwidthManagementInterrupt
4649 ShellPrintEx (-1, -1,
4650 L
" Link Autonomous Bandwidth Interrupt Enable(11): %E%d%N\r\n",
4651 PciExpressCap
->LinkControl
.Bits
.LinkAutonomousBandwidthInterrupt
4657 Print out information of the device link status information.
4659 @param[in] PciExpressCap The pointer to the structure about the device.
4661 @retval EFI_SUCCESS The operation was successful.
4664 ExplainPcieLinkStatus (
4665 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4668 CHAR16
*CurLinkSpeed
;
4670 switch (PciExpressCap
->LinkStatus
.Bits
.CurrentLinkSpeed
) {
4672 CurLinkSpeed
= L
"2.5 GT/s";
4675 CurLinkSpeed
= L
"5.0 GT/s";
4678 CurLinkSpeed
= L
"8.0 GT/s";
4681 CurLinkSpeed
= L
"Reserved";
4684 ShellPrintEx (-1, -1,
4685 L
" Current Link Speed(3:0): %E%s%N\r\n",
4688 ShellPrintEx (-1, -1,
4689 L
" Negotiated Link Width(9:4): %Ex%d%N\r\n",
4690 PciExpressCap
->LinkStatus
.Bits
.NegotiatedLinkWidth
4692 ShellPrintEx (-1, -1,
4693 L
" Link Training(11): %E%d%N\r\n",
4694 PciExpressCap
->LinkStatus
.Bits
.LinkTraining
4696 ShellPrintEx (-1, -1,
4697 L
" Slot Clock Configuration(12): %E%d%N\r\n",
4698 PciExpressCap
->LinkStatus
.Bits
.SlotClockConfiguration
4700 ShellPrintEx (-1, -1,
4701 L
" Data Link Layer Link Active(13): %E%d%N\r\n",
4702 PciExpressCap
->LinkStatus
.Bits
.DataLinkLayerLinkActive
4704 ShellPrintEx (-1, -1,
4705 L
" Link Bandwidth Management Status(14): %E%d%N\r\n",
4706 PciExpressCap
->LinkStatus
.Bits
.LinkBandwidthManagement
4708 ShellPrintEx (-1, -1,
4709 L
" Link Autonomous Bandwidth Status(15): %E%d%N\r\n",
4710 PciExpressCap
->LinkStatus
.Bits
.LinkAutonomousBandwidth
4716 Print out information of the device slot information.
4718 @param[in] PciExpressCap The pointer to the structure about the device.
4720 @retval EFI_SUCCESS The operation was successful.
4723 ExplainPcieSlotCap (
4724 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4727 ShellPrintEx (-1, -1,
4728 L
" Attention Button Present(0): %E%d%N\r\n",
4729 PciExpressCap
->SlotCapability
.Bits
.AttentionButton
4731 ShellPrintEx (-1, -1,
4732 L
" Power Controller Present(1): %E%d%N\r\n",
4733 PciExpressCap
->SlotCapability
.Bits
.PowerController
4735 ShellPrintEx (-1, -1,
4736 L
" MRL Sensor Present(2): %E%d%N\r\n",
4737 PciExpressCap
->SlotCapability
.Bits
.MrlSensor
4739 ShellPrintEx (-1, -1,
4740 L
" Attention Indicator Present(3): %E%d%N\r\n",
4741 PciExpressCap
->SlotCapability
.Bits
.AttentionIndicator
4743 ShellPrintEx (-1, -1,
4744 L
" Power Indicator Present(4): %E%d%N\r\n",
4745 PciExpressCap
->SlotCapability
.Bits
.PowerIndicator
4747 ShellPrintEx (-1, -1,
4748 L
" Hot-Plug Surprise(5): %E%d%N\r\n",
4749 PciExpressCap
->SlotCapability
.Bits
.HotPlugSurprise
4751 ShellPrintEx (-1, -1,
4752 L
" Hot-Plug Capable(6): %E%d%N\r\n",
4753 PciExpressCap
->SlotCapability
.Bits
.HotPlugCapable
4755 ShellPrintEx (-1, -1,
4756 L
" Slot Power Limit Value(14:7): %E0x%02x%N\r\n",
4757 PciExpressCap
->SlotCapability
.Bits
.SlotPowerLimitValue
4759 ShellPrintEx (-1, -1,
4760 L
" Slot Power Limit Scale(16:15): %E%s%N\r\n",
4761 SlotPwrLmtScaleTable
[PciExpressCap
->SlotCapability
.Bits
.SlotPowerLimitScale
]
4763 ShellPrintEx (-1, -1,
4764 L
" Electromechanical Interlock Present(17): %E%d%N\r\n",
4765 PciExpressCap
->SlotCapability
.Bits
.ElectromechanicalInterlock
4767 ShellPrintEx (-1, -1,
4768 L
" No Command Completed Support(18): %E%d%N\r\n",
4769 PciExpressCap
->SlotCapability
.Bits
.NoCommandCompleted
4771 ShellPrintEx (-1, -1,
4772 L
" Physical Slot Number(31:19): %E%d%N\r\n",
4773 PciExpressCap
->SlotCapability
.Bits
.PhysicalSlotNumber
4780 Print out information of the device slot control information.
4782 @param[in] PciExpressCap The pointer to the structure about the device.
4784 @retval EFI_SUCCESS The operation was successful.
4787 ExplainPcieSlotControl (
4788 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4791 ShellPrintEx (-1, -1,
4792 L
" Attention Button Pressed Enable(0): %E%d%N\r\n",
4793 PciExpressCap
->SlotControl
.Bits
.AttentionButtonPressed
4795 ShellPrintEx (-1, -1,
4796 L
" Power Fault Detected Enable(1): %E%d%N\r\n",
4797 PciExpressCap
->SlotControl
.Bits
.PowerFaultDetected
4799 ShellPrintEx (-1, -1,
4800 L
" MRL Sensor Changed Enable(2): %E%d%N\r\n",
4801 PciExpressCap
->SlotControl
.Bits
.MrlSensorChanged
4803 ShellPrintEx (-1, -1,
4804 L
" Presence Detect Changed Enable(3): %E%d%N\r\n",
4805 PciExpressCap
->SlotControl
.Bits
.PresenceDetectChanged
4807 ShellPrintEx (-1, -1,
4808 L
" Command Completed Interrupt Enable(4): %E%d%N\r\n",
4809 PciExpressCap
->SlotControl
.Bits
.CommandCompletedInterrupt
4811 ShellPrintEx (-1, -1,
4812 L
" Hot-Plug Interrupt Enable(5): %E%d%N\r\n",
4813 PciExpressCap
->SlotControl
.Bits
.HotPlugInterrupt
4815 ShellPrintEx (-1, -1,
4816 L
" Attention Indicator Control(7:6): %E%s%N\r\n",
4818 PciExpressCap
->SlotControl
.Bits
.AttentionIndicator
]
4820 ShellPrintEx (-1, -1,
4821 L
" Power Indicator Control(9:8): %E%s%N\r\n",
4822 IndicatorTable
[PciExpressCap
->SlotControl
.Bits
.PowerIndicator
]
4824 ShellPrintEx (-1, -1, L
" Power Controller Control(10): %EPower ");
4826 PciExpressCap
->SlotControl
.Bits
.PowerController
) {
4827 ShellPrintEx (-1, -1, L
"Off%N\r\n");
4829 ShellPrintEx (-1, -1, L
"On%N\r\n");
4831 ShellPrintEx (-1, -1,
4832 L
" Electromechanical Interlock Control(11): %E%d%N\r\n",
4833 PciExpressCap
->SlotControl
.Bits
.ElectromechanicalInterlock
4835 ShellPrintEx (-1, -1,
4836 L
" Data Link Layer State Changed Enable(12): %E%d%N\r\n",
4837 PciExpressCap
->SlotControl
.Bits
.DataLinkLayerStateChanged
4843 Print out information of the device slot status information.
4845 @param[in] PciExpressCap The pointer to the structure about the device.
4847 @retval EFI_SUCCESS The operation was successful.
4850 ExplainPcieSlotStatus (
4851 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4854 ShellPrintEx (-1, -1,
4855 L
" Attention Button Pressed(0): %E%d%N\r\n",
4856 PciExpressCap
->SlotStatus
.Bits
.AttentionButtonPressed
4858 ShellPrintEx (-1, -1,
4859 L
" Power Fault Detected(1): %E%d%N\r\n",
4860 PciExpressCap
->SlotStatus
.Bits
.PowerFaultDetected
4862 ShellPrintEx (-1, -1,
4863 L
" MRL Sensor Changed(2): %E%d%N\r\n",
4864 PciExpressCap
->SlotStatus
.Bits
.MrlSensorChanged
4866 ShellPrintEx (-1, -1,
4867 L
" Presence Detect Changed(3): %E%d%N\r\n",
4868 PciExpressCap
->SlotStatus
.Bits
.PresenceDetectChanged
4870 ShellPrintEx (-1, -1,
4871 L
" Command Completed(4): %E%d%N\r\n",
4872 PciExpressCap
->SlotStatus
.Bits
.CommandCompleted
4874 ShellPrintEx (-1, -1, L
" MRL Sensor State(5): %EMRL ");
4876 PciExpressCap
->SlotStatus
.Bits
.MrlSensor
) {
4877 ShellPrintEx (-1, -1, L
" Opened%N\r\n");
4879 ShellPrintEx (-1, -1, L
" Closed%N\r\n");
4881 ShellPrintEx (-1, -1, L
" Presence Detect State(6): ");
4883 PciExpressCap
->SlotStatus
.Bits
.PresenceDetect
) {
4884 ShellPrintEx (-1, -1, L
"%ECard Present in slot%N\r\n");
4886 ShellPrintEx (-1, -1, L
"%ESlot Empty%N\r\n");
4888 ShellPrintEx (-1, -1, L
" Electromechanical Interlock Status(7): %EElectromechanical Interlock ");
4890 PciExpressCap
->SlotStatus
.Bits
.ElectromechanicalInterlock
) {
4891 ShellPrintEx (-1, -1, L
"Engaged%N\r\n");
4893 ShellPrintEx (-1, -1, L
"Disengaged%N\r\n");
4895 ShellPrintEx (-1, -1,
4896 L
" Data Link Layer State Changed(8): %E%d%N\r\n",
4897 PciExpressCap
->SlotStatus
.Bits
.DataLinkLayerStateChanged
4903 Print out information of the device root information.
4905 @param[in] PciExpressCap The pointer to the structure about the device.
4907 @retval EFI_SUCCESS The operation was successful.
4910 ExplainPcieRootControl (
4911 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4914 ShellPrintEx (-1, -1,
4915 L
" System Error on Correctable Error Enable(0): %E%d%N\r\n",
4916 PciExpressCap
->RootControl
.Bits
.SystemErrorOnCorrectableError
4918 ShellPrintEx (-1, -1,
4919 L
" System Error on Non-Fatal Error Enable(1): %E%d%N\r\n",
4920 PciExpressCap
->RootControl
.Bits
.SystemErrorOnNonFatalError
4922 ShellPrintEx (-1, -1,
4923 L
" System Error on Fatal Error Enable(2): %E%d%N\r\n",
4924 PciExpressCap
->RootControl
.Bits
.SystemErrorOnFatalError
4926 ShellPrintEx (-1, -1,
4927 L
" PME Interrupt Enable(3): %E%d%N\r\n",
4928 PciExpressCap
->RootControl
.Bits
.PmeInterrupt
4930 ShellPrintEx (-1, -1,
4931 L
" CRS Software Visibility Enable(4): %E%d%N\r\n",
4932 PciExpressCap
->RootControl
.Bits
.CrsSoftwareVisibility
4939 Print out information of the device root capability information.
4941 @param[in] PciExpressCap The pointer to the structure about the device.
4943 @retval EFI_SUCCESS The operation was successful.
4946 ExplainPcieRootCap (
4947 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4950 ShellPrintEx (-1, -1,
4951 L
" CRS Software Visibility(0): %E%d%N\r\n",
4952 PciExpressCap
->RootCapability
.Bits
.CrsSoftwareVisibility
4959 Print out information of the device root status information.
4961 @param[in] PciExpressCap The pointer to the structure about the device.
4963 @retval EFI_SUCCESS The operation was successful.
4966 ExplainPcieRootStatus (
4967 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
4970 ShellPrintEx (-1, -1,
4971 L
" PME Requester ID(15:0): %E0x%04x%N\r\n",
4972 PciExpressCap
->RootStatus
.Bits
.PmeRequesterId
4974 ShellPrintEx (-1, -1,
4975 L
" PME Status(16): %E%d%N\r\n",
4976 PciExpressCap
->RootStatus
.Bits
.PmeStatus
4978 ShellPrintEx (-1, -1,
4979 L
" PME Pending(17): %E%d%N\r\n",
4980 PciExpressCap
->RootStatus
.Bits
.PmePending
4986 Function to interpret and print out the link control structure
4988 @param[in] HeaderAddress The Address of this capability header.
4989 @param[in] HeadersBaseAddress The address of all the extended capability headers.
4992 PrintInterpretedExtendedCompatibilityLinkControl (
4993 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
4994 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
4997 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_INTERNAL_LINK_CONTROL
*Header
;
4998 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_INTERNAL_LINK_CONTROL
*)HeaderAddress
;
5002 STRING_TOKEN (STR_PCI_EXT_CAP_LINK_CONTROL
),
5003 gShellDebug1HiiHandle
,
5004 Header
->RootComplexLinkCapabilities
,
5005 Header
->RootComplexLinkControl
,
5006 Header
->RootComplexLinkStatus
5010 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5011 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_INTERNAL_LINK_CONTROL
),
5012 (VOID
*) (HeaderAddress
)
5014 return (EFI_SUCCESS
);
5018 Function to interpret and print out the power budgeting structure
5020 @param[in] HeaderAddress The Address of this capability header.
5021 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5024 PrintInterpretedExtendedCompatibilityPowerBudgeting (
5025 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5026 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5029 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_POWER_BUDGETING
*Header
;
5030 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_POWER_BUDGETING
*)HeaderAddress
;
5034 STRING_TOKEN (STR_PCI_EXT_CAP_POWER
),
5035 gShellDebug1HiiHandle
,
5038 Header
->PowerBudgetCapability
5042 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5043 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_POWER_BUDGETING
),
5044 (VOID
*) (HeaderAddress
)
5046 return (EFI_SUCCESS
);
5050 Function to interpret and print out the ACS structure
5052 @param[in] HeaderAddress The Address of this capability header.
5053 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5056 PrintInterpretedExtendedCompatibilityAcs (
5057 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5058 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5061 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_ACS_EXTENDED
*Header
;
5065 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_ACS_EXTENDED
*)HeaderAddress
;
5070 STRING_TOKEN (STR_PCI_EXT_CAP_ACS
),
5071 gShellDebug1HiiHandle
,
5072 Header
->AcsCapability
,
5075 if (PCI_EXPRESS_EXTENDED_CAPABILITY_ACS_EXTENDED_GET_EGRES_CONTROL(Header
)) {
5076 VectorSize
= PCI_EXPRESS_EXTENDED_CAPABILITY_ACS_EXTENDED_GET_EGRES_VECTOR_SIZE(Header
);
5077 if (VectorSize
== 0) {
5080 for (LoopCounter
= 0 ; LoopCounter
* 8 < VectorSize
; LoopCounter
++) {
5083 STRING_TOKEN (STR_PCI_EXT_CAP_ACS2
),
5084 gShellDebug1HiiHandle
,
5086 Header
->EgressControlVectorArray
[LoopCounter
]
5092 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5093 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_ACS_EXTENDED
) + (VectorSize
/ 8) - 1,
5094 (VOID
*) (HeaderAddress
)
5096 return (EFI_SUCCESS
);
5100 Function to interpret and print out the latency tolerance reporting structure
5102 @param[in] HeaderAddress The Address of this capability header.
5103 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5106 PrintInterpretedExtendedCompatibilityLatencyToleranceReporting (
5107 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5108 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5111 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_LATENCE_TOLERANCE_REPORTING
*Header
;
5112 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_LATENCE_TOLERANCE_REPORTING
*)HeaderAddress
;
5116 STRING_TOKEN (STR_PCI_EXT_CAP_LAT
),
5117 gShellDebug1HiiHandle
,
5118 Header
->MaxSnoopLatency
,
5119 Header
->MaxNoSnoopLatency
5123 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5124 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_LATENCE_TOLERANCE_REPORTING
),
5125 (VOID
*) (HeaderAddress
)
5127 return (EFI_SUCCESS
);
5131 Function to interpret and print out the serial number structure
5133 @param[in] HeaderAddress The Address of this capability header.
5134 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5137 PrintInterpretedExtendedCompatibilitySerialNumber (
5138 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5139 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5142 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_SERIAL_NUMBER
*Header
;
5143 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_SERIAL_NUMBER
*)HeaderAddress
;
5147 STRING_TOKEN (STR_PCI_EXT_CAP_SN
),
5148 gShellDebug1HiiHandle
,
5149 Header
->SerialNumber
5153 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5154 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_SERIAL_NUMBER
),
5155 (VOID
*) (HeaderAddress
)
5157 return (EFI_SUCCESS
);
5161 Function to interpret and print out the RCRB structure
5163 @param[in] HeaderAddress The Address of this capability header.
5164 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5167 PrintInterpretedExtendedCompatibilityRcrb (
5168 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5169 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5172 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_RCRB_HEADER
*Header
;
5173 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_RCRB_HEADER
*)HeaderAddress
;
5177 STRING_TOKEN (STR_PCI_EXT_CAP_RCRB
),
5178 gShellDebug1HiiHandle
,
5181 Header
->RcrbCapabilities
,
5186 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5187 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_RCRB_HEADER
),
5188 (VOID
*) (HeaderAddress
)
5190 return (EFI_SUCCESS
);
5194 Function to interpret and print out the vendor specific structure
5196 @param[in] HeaderAddress The Address of this capability header.
5197 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5200 PrintInterpretedExtendedCompatibilityVendorSpecific (
5201 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5202 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5205 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_VENDOR_SPECIFIC
*Header
;
5206 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_VENDOR_SPECIFIC
*)HeaderAddress
;
5210 STRING_TOKEN (STR_PCI_EXT_CAP_VEN
),
5211 gShellDebug1HiiHandle
,
5212 Header
->VendorSpecificHeader
5216 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5217 PCI_EXPRESS_EXTENDED_CAPABILITY_VENDOR_SPECIFIC_GET_SIZE(Header
),
5218 (VOID
*) (HeaderAddress
)
5220 return (EFI_SUCCESS
);
5224 Function to interpret and print out the Event Collector Endpoint Association structure
5226 @param[in] HeaderAddress The Address of this capability header.
5227 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5230 PrintInterpretedExtendedCompatibilityECEA (
5231 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5232 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5235 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_EVENT_COLLECTOR_ENDPOINT_ASSOCIATION
*Header
;
5236 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_EVENT_COLLECTOR_ENDPOINT_ASSOCIATION
*)HeaderAddress
;
5240 STRING_TOKEN (STR_PCI_EXT_CAP_ECEA
),
5241 gShellDebug1HiiHandle
,
5242 Header
->AssociationBitmap
5246 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5247 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_EVENT_COLLECTOR_ENDPOINT_ASSOCIATION
),
5248 (VOID
*) (HeaderAddress
)
5250 return (EFI_SUCCESS
);
5254 Function to interpret and print out the ARI structure
5256 @param[in] HeaderAddress The Address of this capability header.
5257 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5260 PrintInterpretedExtendedCompatibilityAri (
5261 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5262 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5265 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_ARI_CAPABILITY
*Header
;
5266 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_ARI_CAPABILITY
*)HeaderAddress
;
5270 STRING_TOKEN (STR_PCI_EXT_CAP_ARI
),
5271 gShellDebug1HiiHandle
,
5272 Header
->AriCapability
,
5277 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5278 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_ARI_CAPABILITY
),
5279 (VOID
*) (HeaderAddress
)
5281 return (EFI_SUCCESS
);
5285 Function to interpret and print out the DPA structure
5287 @param[in] HeaderAddress The Address of this capability header.
5288 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5291 PrintInterpretedExtendedCompatibilityDynamicPowerAllocation (
5292 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5293 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5296 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_DYNAMIC_POWER_ALLOCATION
*Header
;
5298 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_DYNAMIC_POWER_ALLOCATION
*)HeaderAddress
;
5302 STRING_TOKEN (STR_PCI_EXT_CAP_DPA
),
5303 gShellDebug1HiiHandle
,
5304 Header
->DpaCapability
,
5305 Header
->DpaLatencyIndicator
,
5309 for (LinkCount
= 0 ; LinkCount
< PCI_EXPRESS_EXTENDED_CAPABILITY_DYNAMIC_POWER_ALLOCATION_GET_SUBSTATE_MAX(Header
) + 1 ; LinkCount
++) {
5312 STRING_TOKEN (STR_PCI_EXT_CAP_DPA2
),
5313 gShellDebug1HiiHandle
,
5315 Header
->DpaPowerAllocationArray
[LinkCount
]
5320 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5321 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_DYNAMIC_POWER_ALLOCATION
) - 1 + PCI_EXPRESS_EXTENDED_CAPABILITY_DYNAMIC_POWER_ALLOCATION_GET_SUBSTATE_MAX(Header
),
5322 (VOID
*) (HeaderAddress
)
5324 return (EFI_SUCCESS
);
5328 Function to interpret and print out the link declaration structure
5330 @param[in] HeaderAddress The Address of this capability header.
5331 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5334 PrintInterpretedExtendedCompatibilityLinkDeclaration (
5335 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5336 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5339 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_LINK_DECLARATION
*Header
;
5341 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_LINK_DECLARATION
*)HeaderAddress
;
5345 STRING_TOKEN (STR_PCI_EXT_CAP_LINK_DECLAR
),
5346 gShellDebug1HiiHandle
,
5347 Header
->ElementSelfDescription
5350 for (LinkCount
= 0 ; LinkCount
< PCI_EXPRESS_EXTENDED_CAPABILITY_LINK_DECLARATION_GET_LINK_COUNT(Header
) ; LinkCount
++) {
5353 STRING_TOKEN (STR_PCI_EXT_CAP_LINK_DECLAR2
),
5354 gShellDebug1HiiHandle
,
5356 Header
->LinkEntry
[LinkCount
]
5361 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5362 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_LINK_DECLARATION
) + (PCI_EXPRESS_EXTENDED_CAPABILITY_LINK_DECLARATION_GET_LINK_COUNT(Header
)-1)*sizeof(UINT32
),
5363 (VOID
*) (HeaderAddress
)
5365 return (EFI_SUCCESS
);
5369 Function to interpret and print out the Advanced Error Reporting structure
5371 @param[in] HeaderAddress The Address of this capability header.
5372 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5375 PrintInterpretedExtendedCompatibilityAer (
5376 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5377 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5380 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_ADVANCED_ERROR_REPORTING
*Header
;
5381 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_ADVANCED_ERROR_REPORTING
*)HeaderAddress
;
5385 STRING_TOKEN (STR_PCI_EXT_CAP_AER
),
5386 gShellDebug1HiiHandle
,
5387 Header
->UncorrectableErrorStatus
,
5388 Header
->UncorrectableErrorMask
,
5389 Header
->UncorrectableErrorSeverity
,
5390 Header
->CorrectableErrorStatus
,
5391 Header
->CorrectableErrorMask
,
5392 Header
->AdvancedErrorCapabilitiesAndControl
,
5393 Header
->HeaderLog
[0],
5394 Header
->HeaderLog
[1],
5395 Header
->HeaderLog
[2],
5396 Header
->HeaderLog
[3],
5397 Header
->RootErrorCommand
,
5398 Header
->RootErrorStatus
,
5399 Header
->ErrorSourceIdentification
,
5400 Header
->CorrectableErrorSourceIdentification
,
5401 Header
->TlpPrefixLog
[0],
5402 Header
->TlpPrefixLog
[1],
5403 Header
->TlpPrefixLog
[2],
5404 Header
->TlpPrefixLog
[3]
5408 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5409 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_ADVANCED_ERROR_REPORTING
),
5410 (VOID
*) (HeaderAddress
)
5412 return (EFI_SUCCESS
);
5416 Function to interpret and print out the multicast structure
5418 @param[in] HeaderAddress The Address of this capability header.
5419 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5420 @param[in] PciExpressCapPtr The address of the PCIe capabilities structure.
5423 PrintInterpretedExtendedCompatibilityMulticast (
5424 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5425 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
,
5426 IN CONST PCI_CAPABILITY_PCIEXP
*PciExpressCapPtr
5429 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_MULTICAST
*Header
;
5430 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_MULTICAST
*)HeaderAddress
;
5434 STRING_TOKEN (STR_PCI_EXT_CAP_MULTICAST
),
5435 gShellDebug1HiiHandle
,
5436 Header
->MultiCastCapability
,
5437 Header
->MulticastControl
,
5438 Header
->McBaseAddress
,
5439 Header
->McReceiveAddress
,
5441 Header
->McBlockUntranslated
,
5442 Header
->McOverlayBar
5447 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5448 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_MULTICAST
),
5449 (VOID
*) (HeaderAddress
)
5452 return (EFI_SUCCESS
);
5456 Function to interpret and print out the virtual channel and multi virtual channel structure
5458 @param[in] HeaderAddress The Address of this capability header.
5459 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5462 PrintInterpretedExtendedCompatibilityVirtualChannel (
5463 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5464 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5467 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_VIRTUAL_CHANNEL_CAPABILITY
*Header
;
5468 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_VIRTUAL_CHANNEL_VC
*CapabilityItem
;
5470 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_VIRTUAL_CHANNEL_CAPABILITY
*)HeaderAddress
;
5474 STRING_TOKEN (STR_PCI_EXT_CAP_VC_BASE
),
5475 gShellDebug1HiiHandle
,
5476 Header
->ExtendedVcCount
,
5477 Header
->PortVcCapability1
,
5478 Header
->PortVcCapability2
,
5479 Header
->VcArbTableOffset
,
5480 Header
->PortVcControl
,
5481 Header
->PortVcStatus
5483 for (ItemCount
= 0 ; ItemCount
< Header
->ExtendedVcCount
; ItemCount
++) {
5484 CapabilityItem
= &Header
->Capability
[ItemCount
];
5487 STRING_TOKEN (STR_PCI_EXT_CAP_VC_ITEM
),
5488 gShellDebug1HiiHandle
,
5490 CapabilityItem
->VcResourceCapability
,
5491 CapabilityItem
->PortArbTableOffset
,
5492 CapabilityItem
->VcResourceControl
,
5493 CapabilityItem
->VcResourceStatus
5499 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5500 sizeof (PCI_EXPRESS_EXTENDED_CAPABILITIES_VIRTUAL_CHANNEL_CAPABILITY
)
5501 + Header
->ExtendedVcCount
* sizeof (PCI_EXPRESS_EXTENDED_CAPABILITIES_VIRTUAL_CHANNEL_VC
),
5502 (VOID
*) (HeaderAddress
)
5505 return (EFI_SUCCESS
);
5509 Function to interpret and print out the resizeable bar structure
5511 @param[in] HeaderAddress The Address of this capability header.
5512 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5515 PrintInterpretedExtendedCompatibilityResizeableBar (
5516 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5517 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5520 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_RESIZABLE_BAR
*Header
;
5522 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_RESIZABLE_BAR
*)HeaderAddress
;
5524 for (ItemCount
= 0 ; ItemCount
< (UINT32
)GET_NUMBER_RESIZABLE_BARS(Header
) ; ItemCount
++) {
5527 STRING_TOKEN (STR_PCI_EXT_CAP_RESIZE_BAR
),
5528 gShellDebug1HiiHandle
,
5530 Header
->Capability
[ItemCount
].ResizableBarCapability
,
5531 Header
->Capability
[ItemCount
].ResizableBarControl
5537 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5538 (UINT32
)GET_NUMBER_RESIZABLE_BARS(Header
) * sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_RESIZABLE_BAR_ENTRY
),
5539 (VOID
*) (HeaderAddress
)
5542 return (EFI_SUCCESS
);
5546 Function to interpret and print out the TPH structure
5548 @param[in] HeaderAddress The Address of this capability header.
5549 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5552 PrintInterpretedExtendedCompatibilityTph (
5553 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5554 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
5557 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_TPH
*Header
;
5558 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_TPH
*)HeaderAddress
;
5562 STRING_TOKEN (STR_PCI_EXT_CAP_TPH
),
5563 gShellDebug1HiiHandle
,
5564 Header
->TphRequesterCapability
,
5565 Header
->TphRequesterControl
5569 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)Header
->TphStTable
- (UINT8
*)HeadersBaseAddress
),
5570 GET_TPH_TABLE_SIZE(Header
),
5571 (VOID
*)Header
->TphStTable
5576 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5577 sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_TPH
) + GET_TPH_TABLE_SIZE(Header
) - sizeof(UINT16
),
5578 (VOID
*) (HeaderAddress
)
5581 return (EFI_SUCCESS
);
5585 Function to interpret and print out the secondary PCIe capability structure
5587 @param[in] HeaderAddress The Address of this capability header.
5588 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5589 @param[in] PciExpressCapPtr The address of the PCIe capabilities structure.
5592 PrintInterpretedExtendedCompatibilitySecondary (
5593 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5594 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
,
5595 IN CONST PCI_CAPABILITY_PCIEXP
*PciExpressCap
5598 CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_SECONDARY_PCIE
*Header
;
5599 Header
= (PCI_EXPRESS_EXTENDED_CAPABILITIES_SECONDARY_PCIE
*)HeaderAddress
;
5603 STRING_TOKEN (STR_PCI_EXT_CAP_SECONDARY
),
5604 gShellDebug1HiiHandle
,
5605 Header
->LinkControl3
.Uint32
,
5606 Header
->LaneErrorStatus
5610 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)Header
->EqualizationControl
- (UINT8
*)HeadersBaseAddress
),
5611 PciExpressCap
->LinkCapability
.Bits
.MaxLinkWidth
* sizeof (PCI_EXPRESS_REG_LANE_EQUALIZATION_CONTROL
),
5612 (VOID
*)Header
->EqualizationControl
5617 EFI_PCIE_CAPABILITY_BASE_OFFSET
+ ((UINT8
*)HeaderAddress
- (UINT8
*)HeadersBaseAddress
),
5618 sizeof (PCI_EXPRESS_EXTENDED_CAPABILITIES_SECONDARY_PCIE
) - sizeof (Header
->EqualizationControl
)
5619 + PciExpressCap
->LinkCapability
.Bits
.MaxLinkWidth
* sizeof (PCI_EXPRESS_REG_LANE_EQUALIZATION_CONTROL
),
5620 (VOID
*) (HeaderAddress
)
5623 return (EFI_SUCCESS
);
5627 Display Pcie extended capability details
5629 @param[in] HeadersBaseAddress The address of all the extended capability headers.
5630 @param[in] HeaderAddress The address of this capability header.
5631 @param[in] PciExpressCapPtr The address of the PCIe capabilities structure.
5634 PrintPciExtendedCapabilityDetails(
5635 IN CONST PCI_EXP_EXT_HDR
*HeadersBaseAddress
,
5636 IN CONST PCI_EXP_EXT_HDR
*HeaderAddress
,
5637 IN CONST PCI_CAPABILITY_PCIEXP
*PciExpressCapPtr
5640 switch (HeaderAddress
->CapabilityId
){
5641 case PCI_EXPRESS_EXTENDED_CAPABILITY_ADVANCED_ERROR_REPORTING_ID
:
5642 return PrintInterpretedExtendedCompatibilityAer(HeaderAddress
, HeadersBaseAddress
);
5643 case PCI_EXPRESS_EXTENDED_CAPABILITY_LINK_CONTROL_ID
:
5644 return PrintInterpretedExtendedCompatibilityLinkControl(HeaderAddress
, HeadersBaseAddress
);
5645 case PCI_EXPRESS_EXTENDED_CAPABILITY_LINK_DECLARATION_ID
:
5646 return PrintInterpretedExtendedCompatibilityLinkDeclaration(HeaderAddress
, HeadersBaseAddress
);
5647 case PCI_EXPRESS_EXTENDED_CAPABILITY_SERIAL_NUMBER_ID
:
5648 return PrintInterpretedExtendedCompatibilitySerialNumber(HeaderAddress
, HeadersBaseAddress
);
5649 case PCI_EXPRESS_EXTENDED_CAPABILITY_POWER_BUDGETING_ID
:
5650 return PrintInterpretedExtendedCompatibilityPowerBudgeting(HeaderAddress
, HeadersBaseAddress
);
5651 case PCI_EXPRESS_EXTENDED_CAPABILITY_ACS_EXTENDED_ID
:
5652 return PrintInterpretedExtendedCompatibilityAcs(HeaderAddress
, HeadersBaseAddress
);
5653 case PCI_EXPRESS_EXTENDED_CAPABILITY_LATENCE_TOLERANCE_REPORTING_ID
:
5654 return PrintInterpretedExtendedCompatibilityLatencyToleranceReporting(HeaderAddress
, HeadersBaseAddress
);
5655 case PCI_EXPRESS_EXTENDED_CAPABILITY_ARI_CAPABILITY_ID
:
5656 return PrintInterpretedExtendedCompatibilityAri(HeaderAddress
, HeadersBaseAddress
);
5657 case PCI_EXPRESS_EXTENDED_CAPABILITY_RCRB_HEADER_ID
:
5658 return PrintInterpretedExtendedCompatibilityRcrb(HeaderAddress
, HeadersBaseAddress
);
5659 case PCI_EXPRESS_EXTENDED_CAPABILITY_VENDOR_SPECIFIC_ID
:
5660 return PrintInterpretedExtendedCompatibilityVendorSpecific(HeaderAddress
, HeadersBaseAddress
);
5661 case PCI_EXPRESS_EXTENDED_CAPABILITY_DYNAMIC_POWER_ALLOCATION_ID
:
5662 return PrintInterpretedExtendedCompatibilityDynamicPowerAllocation(HeaderAddress
, HeadersBaseAddress
);
5663 case PCI_EXPRESS_EXTENDED_CAPABILITY_EVENT_COLLECTOR_ENDPOINT_ASSOCIATION_ID
:
5664 return PrintInterpretedExtendedCompatibilityECEA(HeaderAddress
, HeadersBaseAddress
);
5665 case PCI_EXPRESS_EXTENDED_CAPABILITY_VIRTUAL_CHANNEL_ID
:
5666 case PCI_EXPRESS_EXTENDED_CAPABILITY_MULTI_FUNCTION_VIRTUAL_CHANNEL_ID
:
5667 return PrintInterpretedExtendedCompatibilityVirtualChannel(HeaderAddress
, HeadersBaseAddress
);
5668 case PCI_EXPRESS_EXTENDED_CAPABILITY_MULTICAST_ID
:
5670 // should only be present if PCIE_CAP_DEVICEPORT_TYPE(PciExpressCapPtr->PcieCapReg) == 0100b, 0101b, or 0110b
5672 return PrintInterpretedExtendedCompatibilityMulticast(HeaderAddress
, HeadersBaseAddress
, PciExpressCapPtr
);
5673 case PCI_EXPRESS_EXTENDED_CAPABILITY_RESIZABLE_BAR_ID
:
5674 return PrintInterpretedExtendedCompatibilityResizeableBar(HeaderAddress
, HeadersBaseAddress
);
5675 case PCI_EXPRESS_EXTENDED_CAPABILITY_TPH_ID
:
5676 return PrintInterpretedExtendedCompatibilityTph(HeaderAddress
, HeadersBaseAddress
);
5677 case PCI_EXPRESS_EXTENDED_CAPABILITY_SECONDARY_PCIE_ID
:
5678 return PrintInterpretedExtendedCompatibilitySecondary(HeaderAddress
, HeadersBaseAddress
, PciExpressCapPtr
);
5680 ShellPrintEx (-1, -1,
5681 L
"Unknown PCIe extended capability ID (%04xh). No interpretation available.\r\n",
5682 HeaderAddress
->CapabilityId
5690 Display Pcie device structure.
5692 @param[in] PciExpressCap PCI Express capability buffer.
5693 @param[in] ExtendedConfigSpace PCI Express extended configuration space.
5694 @param[in] ExtendedCapability PCI Express extended capability ID to explain.
5697 PciExplainPciExpress (
5698 IN PCI_CAPABILITY_PCIEXP
*PciExpressCap
,
5699 IN UINT8
*ExtendedConfigSpace
,
5700 IN CONST UINT16 ExtendedCapability
5703 UINT8 DevicePortType
;
5707 PCI_EXP_EXT_HDR
*ExtHdr
;
5709 DevicePortType
= (UINT8
)PciExpressCap
->Capability
.Bits
.DevicePortType
;
5711 ShellPrintEx (-1, -1, L
"\r\nPci Express device capability structure:\r\n");
5713 for (Index
= 0; PcieExplainList
[Index
].Type
< PcieExplainTypeMax
; Index
++) {
5714 if (ShellGetExecutionBreakFlag()) {
5717 RegAddr
= (UINT8
*) PciExpressCap
+ PcieExplainList
[Index
].Offset
;
5718 switch (PcieExplainList
[Index
].Width
) {
5719 case FieldWidthUINT8
:
5720 RegValue
= *(UINT8
*) RegAddr
;
5722 case FieldWidthUINT16
:
5723 RegValue
= *(UINT16
*) RegAddr
;
5725 case FieldWidthUINT32
:
5726 RegValue
= *(UINT32
*) RegAddr
;
5732 ShellPrintHiiEx(-1, -1, NULL
,
5733 PcieExplainList
[Index
].Token
,
5734 gShellDebug1HiiHandle
,
5735 PcieExplainList
[Index
].Offset
,
5738 if (PcieExplainList
[Index
].Func
== NULL
) {
5741 switch (PcieExplainList
[Index
].Type
) {
5742 case PcieExplainTypeLink
:
5744 // Link registers should not be used by
5745 // a) Root Complex Integrated Endpoint
5746 // b) Root Complex Event Collector
5748 if (DevicePortType
== PCIE_DEVICE_PORT_TYPE_ROOT_COMPLEX_INTEGRATED_ENDPOINT
||
5749 DevicePortType
== PCIE_DEVICE_PORT_TYPE_ROOT_COMPLEX_EVENT_COLLECTOR
) {
5753 case PcieExplainTypeSlot
:
5755 // Slot registers are only valid for
5756 // a) Root Port of PCI Express Root Complex
5757 // b) Downstream Port of PCI Express Switch
5758 // and when SlotImplemented bit is set in PCIE cap register.
5760 if ((DevicePortType
!= PCIE_DEVICE_PORT_TYPE_ROOT_PORT
&&
5761 DevicePortType
!= PCIE_DEVICE_PORT_TYPE_DOWNSTREAM_PORT
) ||
5762 !PciExpressCap
->Capability
.Bits
.SlotImplemented
) {
5766 case PcieExplainTypeRoot
:
5768 // Root registers are only valid for
5769 // Root Port of PCI Express Root Complex
5771 if (DevicePortType
!= PCIE_DEVICE_PORT_TYPE_ROOT_PORT
) {
5778 PcieExplainList
[Index
].Func (PciExpressCap
);
5781 ExtHdr
= (PCI_EXP_EXT_HDR
*)ExtendedConfigSpace
;
5782 while (ExtHdr
->CapabilityId
!= 0 && ExtHdr
->CapabilityVersion
!= 0) {
5784 // Process this item
5786 if (ExtendedCapability
== 0xFFFF || ExtendedCapability
== ExtHdr
->CapabilityId
) {
5790 PrintPciExtendedCapabilityDetails((PCI_EXP_EXT_HDR
*)ExtendedConfigSpace
, ExtHdr
, PciExpressCap
);
5794 // Advance to the next item if it exists
5796 if (ExtHdr
->NextCapabilityOffset
!= 0) {
5797 ExtHdr
= (PCI_EXP_EXT_HDR
*)(ExtendedConfigSpace
+ ExtHdr
->NextCapabilityOffset
- EFI_PCIE_CAPABILITY_BASE_OFFSET
);