2
Main file for Pci shell Debug1 function.
4
Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
5
This program and the accompanying materials
6
are licensed and made available under the terms and conditions of the BSD License
7
which accompanies this distribution. The full text of the license may be found at
8
http://opensource.org/licenses/bsd-license.php
10
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
#include "UefiShellDebug1CommandsLib.h"
16
#include <Protocol/PciRootBridgeIo.h>
17
#include <Library/ShellLib.h>
18
#include <IndustryStandard/Pci.h>
19
#include <IndustryStandard/Acpi.h>
22
#define PCI_CLASS_STRING_LIMIT 54
24
// Printable strings for Pci class code
27
CHAR16 *BaseClass; // Pointer to the PCI base class string
28
CHAR16 *SubClass; // Pointer to the PCI sub class string
29
CHAR16 *PIFClass; // Pointer to the PCI programming interface string
33
// a structure holding a single entry, which also points to its lower level
36
typedef struct PCI_CLASS_ENTRY_TAG {
37
UINT8 Code; // Class, subclass or I/F code
38
CHAR16 *DescText; // Description string
39
struct PCI_CLASS_ENTRY_TAG *LowerLevelClass; // Subclass or I/F if any
43
// Declarations of entries which contain printable strings for class codes
44
// in PCI configuration space
46
PCI_CLASS_ENTRY PCIBlankEntry[];
47
PCI_CLASS_ENTRY PCISubClass_00[];
48
PCI_CLASS_ENTRY PCISubClass_01[];
49
PCI_CLASS_ENTRY PCISubClass_02[];
50
PCI_CLASS_ENTRY PCISubClass_03[];
51
PCI_CLASS_ENTRY PCISubClass_04[];
52
PCI_CLASS_ENTRY PCISubClass_05[];
53
PCI_CLASS_ENTRY PCISubClass_06[];
54
PCI_CLASS_ENTRY PCISubClass_07[];
55
PCI_CLASS_ENTRY PCISubClass_08[];
56
PCI_CLASS_ENTRY PCISubClass_09[];
57
PCI_CLASS_ENTRY PCISubClass_0a[];
58
PCI_CLASS_ENTRY PCISubClass_0b[];
59
PCI_CLASS_ENTRY PCISubClass_0c[];
60
PCI_CLASS_ENTRY PCISubClass_0d[];
61
PCI_CLASS_ENTRY PCISubClass_0e[];
62
PCI_CLASS_ENTRY PCISubClass_0f[];
63
PCI_CLASS_ENTRY PCISubClass_10[];
64
PCI_CLASS_ENTRY PCISubClass_11[];
65
PCI_CLASS_ENTRY PCIPIFClass_0101[];
66
PCI_CLASS_ENTRY PCIPIFClass_0300[];
67
PCI_CLASS_ENTRY PCIPIFClass_0604[];
68
PCI_CLASS_ENTRY PCIPIFClass_0700[];
69
PCI_CLASS_ENTRY PCIPIFClass_0701[];
70
PCI_CLASS_ENTRY PCIPIFClass_0703[];
71
PCI_CLASS_ENTRY PCIPIFClass_0800[];
72
PCI_CLASS_ENTRY PCIPIFClass_0801[];
73
PCI_CLASS_ENTRY PCIPIFClass_0802[];
74
PCI_CLASS_ENTRY PCIPIFClass_0803[];
75
PCI_CLASS_ENTRY PCIPIFClass_0904[];
76
PCI_CLASS_ENTRY PCIPIFClass_0c00[];
77
PCI_CLASS_ENTRY PCIPIFClass_0c03[];
78
PCI_CLASS_ENTRY PCIPIFClass_0e00[];
81
// Base class strings entries
83
PCI_CLASS_ENTRY gClassStringList[] = {
91
L"Mass Storage Controller",
96
L"Network Controller",
101
L"Display Controller",
106
L"Multimedia Device",
111
L"Memory Controller",
121
L"Simple Communications Controllers",
126
L"Base System Peripherals",
146
L"Serial Bus Controllers",
151
L"Wireless Controllers",
156
L"Intelligent IO Controllers",
161
L"Satellite Communications Controllers",
166
L"Encryption/Decryption Controllers",
171
L"Data Acquisition & Signal Processing Controllers",
176
L"Device does not fit in any defined classes",
182
/* null string ends the list */NULL
187
// Subclass strings entries
189
PCI_CLASS_ENTRY PCIBlankEntry[] = {
198
/* null string ends the list */NULL
202
PCI_CLASS_ENTRY PCISubClass_00[] = {
205
L"All devices other than VGA",
210
L"VGA-compatible devices",
216
/* null string ends the list */NULL
220
PCI_CLASS_ENTRY PCISubClass_01[] = {
233
L"Floppy disk controller",
248
L"Other mass storage controller",
254
/* null string ends the list */NULL
258
PCI_CLASS_ENTRY PCISubClass_02[] = {
261
L"Ethernet controller",
266
L"Token ring controller",
286
L"Other network controller",
292
/* null string ends the list */NULL
296
PCI_CLASS_ENTRY PCISubClass_03[] = {
299
L"VGA/8514 controller",
314
L"Other display controller",
320
/* null string ends the list */PCIBlankEntry
324
PCI_CLASS_ENTRY PCISubClass_04[] = {
337
L"Computer Telephony device",
342
L"Other multimedia device",
348
/* null string ends the list */NULL
352
PCI_CLASS_ENTRY PCISubClass_05[] = {
355
L"RAM memory controller",
360
L"Flash memory controller",
365
L"Other memory controller",
371
/* null string ends the list */NULL
375
PCI_CLASS_ENTRY PCISubClass_06[] = {
393
L"PCI/Micro Channel bridge",
403
L"PCI/PCMCIA bridge",
423
L"Other bridge type",
429
/* null string ends the list */NULL
433
PCI_CLASS_ENTRY PCISubClass_07[] = {
436
L"Serial controller",
446
L"Multiport serial controller",
456
L"Other communication device",
462
/* null string ends the list */NULL
466
PCI_CLASS_ENTRY PCISubClass_08[] = {
489
L"Generic PCI Hot-Plug controller",
494
L"Other system peripheral",
500
/* null string ends the list */NULL
504
PCI_CLASS_ENTRY PCISubClass_09[] = {
507
L"Keyboard controller",
522
L"Scanner controller",
527
L"Gameport controller",
532
L"Other input controller",
538
/* null string ends the list */NULL
542
PCI_CLASS_ENTRY PCISubClass_0a[] = {
545
L"Generic docking station",
550
L"Other type of docking station",
556
/* null string ends the list */NULL
560
PCI_CLASS_ENTRY PCISubClass_0b[] = {
604
/* null string ends the list */NULL
608
PCI_CLASS_ENTRY PCISubClass_0c[] = {
611
L"Firewire(IEEE 1394)",
636
L"System Management Bus",
647
/* null string ends the list */NULL
651
PCI_CLASS_ENTRY PCISubClass_0d[] = {
654
L"iRDA compatible controller",
659
L"Consumer IR controller",
669
L"Other type of wireless controller",
675
/* null string ends the list */NULL
679
PCI_CLASS_ENTRY PCISubClass_0e[] = {
688
/* null string ends the list */NULL
692
PCI_CLASS_ENTRY PCISubClass_0f[] = {
716
/* null string ends the list */NULL
720
PCI_CLASS_ENTRY PCISubClass_10[] = {
723
L"Network & computing Encrypt/Decrypt",
728
L"Entertainment Encrypt/Decrypt",
733
L"Other Encrypt/Decrypt",
739
/* null string ends the list */NULL
743
PCI_CLASS_ENTRY PCISubClass_11[] = {
751
L"Other DAQ & SP controllers",
757
/* null string ends the list */NULL
762
// Programming Interface entries
764
PCI_CLASS_ENTRY PCIPIFClass_0101[] = {
792
L"OM-primary, OM-secondary",
797
L"PI-primary, OM-secondary",
802
L"OM/PI-primary, OM-secondary",
812
L"OM-primary, PI-secondary",
817
L"PI-primary, PI-secondary",
822
L"OM/PI-primary, PI-secondary",
832
L"OM-primary, OM/PI-secondary",
837
L"PI-primary, OM/PI-secondary",
842
L"OM/PI-primary, OM/PI-secondary",
852
L"Master, OM-primary",
857
L"Master, PI-primary",
862
L"Master, OM/PI-primary",
867
L"Master, OM-secondary",
872
L"Master, OM-primary, OM-secondary",
877
L"Master, PI-primary, OM-secondary",
882
L"Master, OM/PI-primary, OM-secondary",
887
L"Master, OM-secondary",
892
L"Master, OM-primary, PI-secondary",
897
L"Master, PI-primary, PI-secondary",
902
L"Master, OM/PI-primary, PI-secondary",
907
L"Master, OM-secondary",
912
L"Master, OM-primary, OM/PI-secondary",
917
L"Master, PI-primary, OM/PI-secondary",
922
L"Master, OM/PI-primary, OM/PI-secondary",
928
/* null string ends the list */NULL
932
PCI_CLASS_ENTRY PCIPIFClass_0300[] = {
946
/* null string ends the list */NULL
950
PCI_CLASS_ENTRY PCIPIFClass_0604[] = {
958
L"Subtractive decode",
964
/* null string ends the list */NULL
968
PCI_CLASS_ENTRY PCIPIFClass_0700[] = {
971
L"Generic XT-compatible",
1001
L"16950-compatible",
1007
/* null string ends the list */NULL
1011
PCI_CLASS_ENTRY PCIPIFClass_0701[] = {
1024
L"ECP 1.X-compliant",
1034
L"IEEE 1284 target (not a controller)",
1040
/* null string ends the list */NULL
1044
PCI_CLASS_ENTRY PCIPIFClass_0703[] = {
1052
L"Hayes-compatible 16450",
1057
L"Hayes-compatible 16550",
1062
L"Hayes-compatible 16650",
1067
L"Hayes-compatible 16750",
1073
/* null string ends the list */NULL
1077
PCI_CLASS_ENTRY PCIPIFClass_0800[] = {
1100
L"IO(x) APIC interrupt controller",
1106
/* null string ends the list */NULL
1110
PCI_CLASS_ENTRY PCIPIFClass_0801[] = {
1129
/* null string ends the list */NULL
1133
PCI_CLASS_ENTRY PCIPIFClass_0802[] = {
1152
/* null string ends the list */NULL
1156
PCI_CLASS_ENTRY PCIPIFClass_0803[] = {
1175
/* null string ends the list */NULL
1179
PCI_CLASS_ENTRY PCIPIFClass_0904[] = {
1193
/* null string ends the list */NULL
1197
PCI_CLASS_ENTRY PCIPIFClass_0c00[] = {
1200
L"Universal Host Controller spec",
1205
L"Open Host Controller spec",
1210
L"No specific programming interface",
1215
L"(Not Host Controller)",
1221
/* null string ends the list */NULL
1225
PCI_CLASS_ENTRY PCIPIFClass_0c03[] = {
1233
L"Using 1394 OpenHCI spec",
1239
/* null string ends the list */NULL
1243
PCI_CLASS_ENTRY PCIPIFClass_0e00[] = {
1246
L"Message FIFO at offset 40h",
1257
/* null string ends the list */NULL
1263
Generates printable Unicode strings that represent PCI device class,
1264
subclass and programmed I/F based on a value passed to the function.
1266
@param[in] ClassCode Value representing the PCI "Class Code" register read from a
1267
PCI device. The encodings are:
1268
bits 23:16 - Base Class Code
1269
bits 15:8 - Sub-Class Code
1270
bits 7:0 - Programming Interface
1271
@param[in, out] ClassStrings Pointer of PCI_CLASS_STRINGS structure, which contains
1272
printable class strings corresponding to ClassCode. The
1273
caller must not modify the strings that are pointed by
1274
the fields in ClassStrings.
1277
PciGetClassStrings (
1278
IN UINT32 ClassCode,
1279
IN OUT PCI_CLASS_STRINGS *ClassStrings
1284
PCI_CLASS_ENTRY *CurrentClass;
1287
// Assume no strings found
1289
ClassStrings->BaseClass = L"UNDEFINED";
1290
ClassStrings->SubClass = L"UNDEFINED";
1291
ClassStrings->PIFClass = L"UNDEFINED";
1293
CurrentClass = gClassStringList;
1294
Code = (UINT8) (ClassCode >> 16);
1298
// Go through all entries of the base class, until the entry with a matching
1299
// base class code is found. If reaches an entry with a null description
1300
// text, the last entry is met, which means no text for the base class was
1301
// found, so no more action is needed.
1303
while (Code != CurrentClass[Index].Code) {
1304
if (NULL == CurrentClass[Index].DescText) {
1311
// A base class was found. Assign description, and check if this class has
1312
// sub-class defined. If sub-class defined, no more action is needed,
1313
// otherwise, continue to find description for the sub-class code.
1315
ClassStrings->BaseClass = CurrentClass[Index].DescText;
1316
if (NULL == CurrentClass[Index].LowerLevelClass) {
1320
// find Subclass entry
1322
CurrentClass = CurrentClass[Index].LowerLevelClass;
1323
Code = (UINT8) (ClassCode >> 8);
1327
// Go through all entries of the sub-class, until the entry with a matching
1328
// sub-class code is found. If reaches an entry with a null description
1329
// text, the last entry is met, which means no text for the sub-class was
1330
// found, so no more action is needed.
1332
while (Code != CurrentClass[Index].Code) {
1333
if (NULL == CurrentClass[Index].DescText) {
1340
// A class was found for the sub-class code. Assign description, and check if
1341
// this sub-class has programming interface defined. If no, no more action is
1342
// needed, otherwise, continue to find description for the programming
1345
ClassStrings->SubClass = CurrentClass[Index].DescText;
1346
if (NULL == CurrentClass[Index].LowerLevelClass) {
1350
// Find programming interface entry
1352
CurrentClass = CurrentClass[Index].LowerLevelClass;
1353
Code = (UINT8) ClassCode;
1357
// Go through all entries of the I/F entries, until the entry with a
1358
// matching I/F code is found. If reaches an entry with a null description
1359
// text, the last entry is met, which means no text was found, so no more
1360
// action is needed.
1362
while (Code != CurrentClass[Index].Code) {
1363
if (NULL == CurrentClass[Index].DescText) {
1370
// A class was found for the I/F code. Assign description, done!
1372
ClassStrings->PIFClass = CurrentClass[Index].DescText;
1377
Print strings that represent PCI device class, subclass and programmed I/F.
1379
@param[in] ClassCodePtr Points to the memory which stores register Class Code in PCI
1381
@param[in] IncludePIF If the printed string should include the programming I/F part
1385
IN UINT8 *ClassCodePtr,
1386
IN BOOLEAN IncludePIF
1390
PCI_CLASS_STRINGS ClassStrings;
1391
CHAR16 OutputString[PCI_CLASS_STRING_LIMIT + 1];
1394
ClassCode |= ClassCodePtr[0];
1395
ClassCode |= (ClassCodePtr[1] << 8);
1396
ClassCode |= (ClassCodePtr[2] << 16);
1399
// Get name from class code
1401
PciGetClassStrings (ClassCode, &ClassStrings);
1405
// Only print base class and sub class name
1407
ShellPrintEx(-1,-1, L"%s - %s - %s",
1408
ClassStrings.BaseClass,
1409
ClassStrings.SubClass,
1410
ClassStrings.PIFClass
1415
// Print base class, sub class, and programming inferface name
1419
PCI_CLASS_STRING_LIMIT * sizeof (CHAR16),
1421
ClassStrings.BaseClass,
1422
ClassStrings.SubClass
1425
OutputString[PCI_CLASS_STRING_LIMIT] = 0;
1426
ShellPrintEx(-1,-1, L"%s", OutputString);
1431
This function finds out the protocol which is in charge of the given
1432
segment, and its bus range covers the current bus number. It lookes
1433
each instances of RootBridgeIoProtocol handle, until the one meets the
1436
@param[in] HandleBuf Buffer which holds all PCI_ROOT_BRIDIGE_IO_PROTOCOL handles.
1437
@param[in] HandleCount Count of all PCI_ROOT_BRIDIGE_IO_PROTOCOL handles.
1438
@param[in] Segment Segment number of device we are dealing with.
1439
@param[in] Bus Bus number of device we are dealing with.
1440
@param[out] IoDev Handle used to access configuration space of PCI device.
1442
@retval EFI_SUCCESS The command completed successfully.
1443
@retval EFI_INVALID_PARAMETER Invalid parameter.
1447
PciFindProtocolInterface (
1448
IN EFI_HANDLE *HandleBuf,
1449
IN UINTN HandleCount,
1452
OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL **IoDev
1456
This function gets the protocol interface from the given handle, and
1457
obtains its address space descriptors.
1459
@param[in] Handle The PCI_ROOT_BRIDIGE_IO_PROTOCOL handle.
1460
@param[out] IoDev Handle used to access configuration space of PCI device.
1461
@param[out] Descriptors Points to the address space descriptors.
1463
@retval EFI_SUCCESS The command completed successfully
1466
PciGetProtocolAndResource (
1467
IN EFI_HANDLE Handle,
1468
OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL **IoDev,
1469
OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR **Descriptors
1473
This function get the next bus range of given address space descriptors.
1474
It also moves the pointer backward a node, to get prepared to be called
1477
@param[in, out] Descriptors Points to current position of a serial of address space
1479
@param[out] MinBus The lower range of bus number.
1480
@param[out] MaxBus The upper range of bus number.
1481
@param[out] IsEnd Meet end of the serial of descriptors.
1483
@retval EFI_SUCCESS The command completed successfully.
1486
PciGetNextBusRange (
1487
IN OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR **Descriptors,
1494
Explain the data in PCI configuration space. The part which is common for
1495
PCI device and bridge is interpreted in this function. It calls other
1496
functions to interpret data unique for device or bridge.
1498
@param[in] ConfigSpace Data in PCI configuration space.
1499
@param[in] Address Address used to access configuration space of this PCI device.
1500
@param[in] IoDev Handle used to access configuration space of PCI device.
1502
@retval EFI_SUCCESS The command completed successfully.
1506
IN PCI_CONFIG_SPACE *ConfigSpace,
1508
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev
1512
Explain the device specific part of data in PCI configuration space.
1514
@param[in] Device Data in PCI configuration space.
1515
@param[in] Address Address used to access configuration space of this PCI device.
1516
@param[in] IoDev Handle used to access configuration space of PCI device.
1518
@retval EFI_SUCCESS The command completed successfully.
1521
PciExplainDeviceData (
1522
IN PCI_DEVICE_HEADER *Device,
1524
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev
1528
Explain the bridge specific part of data in PCI configuration space.
1530
@param[in] Bridge Bridge specific data region in PCI configuration space.
1531
@param[in] Address Address used to access configuration space of this PCI device.
1532
@param[in] IoDev Handle used to access configuration space of PCI device.
1534
@retval EFI_SUCCESS The command completed successfully.
1537
PciExplainBridgeData (
1538
IN PCI_BRIDGE_HEADER *Bridge,
1540
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev
1544
Explain the Base Address Register(Bar) in PCI configuration space.
1546
@param[in] Bar Points to the Base Address Register intended to interpret.
1547
@param[in] Command Points to the register Command.
1548
@param[in] Address Address used to access configuration space of this PCI device.
1549
@param[in] IoDev Handle used to access configuration space of PCI device.
1550
@param[in, out] Index The Index.
1552
@retval EFI_SUCCESS The command completed successfully.
1559
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev,
1564
Explain the cardbus specific part of data in PCI configuration space.
1566
@param[in] CardBus CardBus specific region of PCI configuration space.
1567
@param[in] Address Address used to access configuration space of this PCI device.
1568
@param[in] IoDev Handle used to access configuration space of PCI device.
1570
@retval EFI_SUCCESS The command completed successfully.
1573
PciExplainCardBusData (
1574
IN PCI_CARDBUS_HEADER *CardBus,
1576
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev
1580
Explain each meaningful bit of register Status. The definition of Status is
1581
slightly different depending on the PCI header type.
1583
@param[in] Status Points to the content of register Status.
1584
@param[in] MainStatus Indicates if this register is main status(not secondary
1586
@param[in] HeaderType Header type of this PCI device.
1588
@retval EFI_SUCCESS The command completed successfully.
1593
IN BOOLEAN MainStatus,
1594
IN PCI_HEADER_TYPE HeaderType
1598
Explain each meaningful bit of register Command.
1600
@param[in] Command Points to the content of register Command.
1602
@retval EFI_SUCCESS The command completed successfully.
1610
Explain each meaningful bit of register Bridge Control.
1612
@param[in] BridgeControl Points to the content of register Bridge Control.
1613
@param[in] HeaderType The headertype.
1615
@retval EFI_SUCCESS The command completed successfully.
1618
PciExplainBridgeControl (
1619
IN UINT16 *BridgeControl,
1620
IN PCI_HEADER_TYPE HeaderType
1624
Print each capability structure.
1626
@param[in] IoDev The pointer to the deivce.
1627
@param[in] Address The address to start at.
1628
@param[in] CapPtr The offset from the address.
1630
@retval EFI_SUCCESS The operation was successful.
1633
PciExplainCapabilityStruct (
1634
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev,
1640
Display Pcie device structure.
1642
@param[in] IoDev The pointer to the root pci protocol.
1643
@param[in] Address The Address to start at.
1644
@param[in] CapabilityPtr The offset from the address to start.
1647
PciExplainPciExpress (
1648
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev,
1650
IN UINT8 CapabilityPtr
1654
Print out information of the capability information.
1656
@param[in] PciExpressCap The pointer to the structure about the device.
1658
@retval EFI_SUCCESS The operation was successful.
1662
IN PCIE_CAP_STURCTURE *PciExpressCap
1666
Print out information of the device capability information.
1668
@param[in] PciExpressCap The pointer to the structure about the device.
1670
@retval EFI_SUCCESS The operation was successful.
1673
ExplainPcieDeviceCap (
1674
IN PCIE_CAP_STURCTURE *PciExpressCap
1678
Print out information of the device control information.
1680
@param[in] PciExpressCap The pointer to the structure about the device.
1682
@retval EFI_SUCCESS The operation was successful.
1685
ExplainPcieDeviceControl (
1686
IN PCIE_CAP_STURCTURE *PciExpressCap
1690
Print out information of the device status information.
1692
@param[in] PciExpressCap The pointer to the structure about the device.
1694
@retval EFI_SUCCESS The operation was successful.
1697
ExplainPcieDeviceStatus (
1698
IN PCIE_CAP_STURCTURE *PciExpressCap
1702
Print out information of the device link information.
1704
@param[in] PciExpressCap The pointer to the structure about the device.
1706
@retval EFI_SUCCESS The operation was successful.
1709
ExplainPcieLinkCap (
1710
IN PCIE_CAP_STURCTURE *PciExpressCap
1714
Print out information of the device link control information.
1716
@param[in] PciExpressCap The pointer to the structure about the device.
1718
@retval EFI_SUCCESS The operation was successful.
1721
ExplainPcieLinkControl (
1722
IN PCIE_CAP_STURCTURE *PciExpressCap
1726
Print out information of the device link status information.
1728
@param[in] PciExpressCap The pointer to the structure about the device.
1730
@retval EFI_SUCCESS The operation was successful.
1733
ExplainPcieLinkStatus (
1734
IN PCIE_CAP_STURCTURE *PciExpressCap
1738
Print out information of the device slot information.
1740
@param[in] PciExpressCap The pointer to the structure about the device.
1742
@retval EFI_SUCCESS The operation was successful.
1745
ExplainPcieSlotCap (
1746
IN PCIE_CAP_STURCTURE *PciExpressCap
1750
Print out information of the device slot control information.
1752
@param[in] PciExpressCap The pointer to the structure about the device.
1754
@retval EFI_SUCCESS The operation was successful.
1757
ExplainPcieSlotControl (
1758
IN PCIE_CAP_STURCTURE *PciExpressCap
1762
Print out information of the device slot status information.
1764
@param[in] PciExpressCap The pointer to the structure about the device.
1766
@retval EFI_SUCCESS The operation was successful.
1769
ExplainPcieSlotStatus (
1770
IN PCIE_CAP_STURCTURE *PciExpressCap
1774
Print out information of the device root information.
1776
@param[in] PciExpressCap The pointer to the structure about the device.
1778
@retval EFI_SUCCESS The operation was successful.
1781
ExplainPcieRootControl (
1782
IN PCIE_CAP_STURCTURE *PciExpressCap
1786
Print out information of the device root capability information.
1788
@param[in] PciExpressCap The pointer to the structure about the device.
1790
@retval EFI_SUCCESS The operation was successful.
1793
ExplainPcieRootCap (
1794
IN PCIE_CAP_STURCTURE *PciExpressCap
1798
Print out information of the device root status information.
1800
@param[in] PciExpressCap The pointer to the structure about the device.
1802
@retval EFI_SUCCESS The operation was successful.
1805
ExplainPcieRootStatus (
1806
IN PCIE_CAP_STURCTURE *PciExpressCap
1809
typedef EFI_STATUS (*PCIE_EXPLAIN_FUNCTION) (IN PCIE_CAP_STURCTURE *PciExpressCap);
1815
} PCIE_CAPREG_FIELD_WIDTH;
1818
PcieExplainTypeCommon,
1819
PcieExplainTypeDevice,
1820
PcieExplainTypeLink,
1821
PcieExplainTypeSlot,
1822
PcieExplainTypeRoot,
1824
} PCIE_EXPLAIN_TYPE;
1830
PCIE_CAPREG_FIELD_WIDTH Width;
1831
PCIE_EXPLAIN_FUNCTION Func;
1832
PCIE_EXPLAIN_TYPE Type;
1833
} PCIE_EXPLAIN_STRUCT;
1835
PCIE_EXPLAIN_STRUCT PcieExplainList[] = {
1837
STRING_TOKEN (STR_PCIEX_CAPABILITY_CAPID),
1841
PcieExplainTypeCommon
1844
STRING_TOKEN (STR_PCIEX_NEXTCAP_PTR),
1848
PcieExplainTypeCommon
1851
STRING_TOKEN (STR_PCIEX_CAP_REGISTER),
1855
PcieExplainTypeCommon
1858
STRING_TOKEN (STR_PCIEX_DEVICE_CAP),
1861
ExplainPcieDeviceCap,
1862
PcieExplainTypeDevice
1865
STRING_TOKEN (STR_PCIEX_DEVICE_CONTROL),
1868
ExplainPcieDeviceControl,
1869
PcieExplainTypeDevice
1872
STRING_TOKEN (STR_PCIEX_DEVICE_STATUS),
1875
ExplainPcieDeviceStatus,
1876
PcieExplainTypeDevice
1879
STRING_TOKEN (STR_PCIEX_LINK_CAPABILITIES),
1886
STRING_TOKEN (STR_PCIEX_LINK_CONTROL),
1889
ExplainPcieLinkControl,
1893
STRING_TOKEN (STR_PCIEX_LINK_STATUS),
1896
ExplainPcieLinkStatus,
1900
STRING_TOKEN (STR_PCIEX_SLOT_CAPABILITIES),
1907
STRING_TOKEN (STR_PCIEX_SLOT_CONTROL),
1910
ExplainPcieSlotControl,
1914
STRING_TOKEN (STR_PCIEX_SLOT_STATUS),
1917
ExplainPcieSlotStatus,
1921
STRING_TOKEN (STR_PCIEX_ROOT_CONTROL),
1924
ExplainPcieRootControl,
1928
STRING_TOKEN (STR_PCIEX_RSVDP),
1935
STRING_TOKEN (STR_PCIEX_ROOT_STATUS),
1938
ExplainPcieRootStatus,
1944
(PCIE_CAPREG_FIELD_WIDTH)0,
1953
PCI_CONFIG_SPACE *mConfigSpace = NULL;
1954
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
1960
CHAR16 *DevicePortTypeTable[] = {
1961
L"PCI Express Endpoint",
1962
L"Legacy PCI Express Endpoint",
1965
L"Root Port of PCI Express Root Complex",
1966
L"Upstream Port of PCI Express Switch",
1967
L"Downstream Port of PCI Express Switch",
1968
L"PCI Express to PCI/PCI-X Bridge",
1969
L"PCI/PCI-X to PCI Express Bridge",
1970
L"Root Complex Integrated Endpoint",
1971
L"Root Complex Event Collector"
1974
CHAR16 *L0sLatencyStrTable[] = {
1976
L"64ns to less than 128ns",
1977
L"128ns to less than 256ns",
1978
L"256ns to less than 512ns",
1979
L"512ns to less than 1us",
1980
L"1us to less than 2us",
1985
CHAR16 *L1LatencyStrTable[] = {
1987
L"1us to less than 2us",
1988
L"2us to less than 4us",
1989
L"4us to less than 8us",
1990
L"8us to less than 16us",
1991
L"16us to less than 32us",
1996
CHAR16 *ASPMCtrlStrTable[] = {
1998
L"L0s Entry Enabled",
1999
L"L1 Entry Enabled",
2000
L"L0s and L1 Entry Enabled"
2003
CHAR16 *SlotPwrLmtScaleTable[] = {
2010
CHAR16 *IndicatorTable[] = {
2019
Function for 'pci' command.
2021
@param[in] ImageHandle Handle to the Image (NULL if Internal).
2022
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
2026
ShellCommandRunPci (
2027
IN EFI_HANDLE ImageHandle,
2028
IN EFI_SYSTEM_TABLE *SystemTable
2036
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev;
2038
PCI_COMMON_HEADER PciHeader;
2039
PCI_CONFIG_SPACE ConfigSpace;
2043
BOOLEAN ExplainData;
2047
UINTN HandleBufSize;
2048
EFI_HANDLE *HandleBuf;
2050
EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptors;
2054
LIST_ENTRY *Package;
2055
CHAR16 *ProblemParam;
2056
SHELL_STATUS ShellStatus;
2060
ShellStatus = SHELL_SUCCESS;
2061
Status = EFI_SUCCESS;
2069
// initialize the shell lib (we must be in non-auto-init...)
2071
Status = ShellInitialize();
2072
ASSERT_EFI_ERROR(Status);
2074
Status = CommandInit();
2075
ASSERT_EFI_ERROR(Status);
2078
// parse the command line
2080
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
2081
if (EFI_ERROR(Status)) {
2082
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
2083
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, ProblemParam);
2084
FreePool(ProblemParam);
2085
ShellStatus = SHELL_INVALID_PARAMETER;
2091
if (ShellCommandLineGetCount(Package) == 2) {
2092
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle);
2093
ShellStatus = SHELL_INVALID_PARAMETER;
2097
if (ShellCommandLineGetCount(Package) > 4) {
2098
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle);
2099
ShellStatus = SHELL_INVALID_PARAMETER;
2102
if (ShellCommandLineGetFlag(Package, L"-s") && ShellCommandLineGetValue(Package, L"-s") == NULL) {
2103
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"-s");
2104
ShellStatus = SHELL_INVALID_PARAMETER;
2108
// Get all instances of PciRootBridgeIo. Allocate space for 1 EFI_HANDLE and
2109
// call LibLocateHandle(), if EFI_BUFFER_TOO_SMALL is returned, allocate enough
2110
// space for handles and call it again.
2112
HandleBufSize = sizeof (EFI_HANDLE);
2113
HandleBuf = (EFI_HANDLE *) AllocateZeroPool (HandleBufSize);
2114
if (HandleBuf == NULL) {
2115
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellDebug1HiiHandle);
2116
ShellStatus = SHELL_OUT_OF_RESOURCES;
2120
Status = gBS->LocateHandle (
2122
&gEfiPciRootBridgeIoProtocolGuid,
2128
if (Status == EFI_BUFFER_TOO_SMALL) {
2129
HandleBuf = ReallocatePool (sizeof (EFI_HANDLE), HandleBufSize, HandleBuf);
2130
if (HandleBuf == NULL) {
2131
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellDebug1HiiHandle);
2132
ShellStatus = SHELL_OUT_OF_RESOURCES;
2136
Status = gBS->LocateHandle (
2138
&gEfiPciRootBridgeIoProtocolGuid,
2145
if (EFI_ERROR (Status)) {
2146
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PCIRBIO_NF), gShellDebug1HiiHandle);
2147
ShellStatus = SHELL_NOT_FOUND;
2151
HandleCount = HandleBufSize / sizeof (EFI_HANDLE);
2153
// Argument Count == 1(no other argument): enumerate all pci functions
2155
if (ShellCommandLineGetCount(Package) == 1) {
2156
gST->ConOut->QueryMode (
2158
gST->ConOut->Mode->Mode,
2165
if ((ScreenSize & 1) == 1) {
2172
// For each handle, which decides a segment and a bus number range,
2173
// enumerate all devices on it.
2175
for (Index = 0; Index < HandleCount; Index++) {
2176
Status = PciGetProtocolAndResource (
2181
if (EFI_ERROR (Status)) {
2182
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_PCI_HANDLE_CFG_ERR), gShellDebug1HiiHandle, Status);
2183
ShellStatus = SHELL_NOT_FOUND;
2187
// No document say it's impossible for a RootBridgeIo protocol handle
2188
// to have more than one address space descriptors, so find out every
2189
// bus range and for each of them do device enumeration.
2192
Status = PciGetNextBusRange (&Descriptors, &MinBus, &MaxBus, &IsEnd);
2194
if (EFI_ERROR (Status)) {
2195
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_PCI_BUS_RANGE_ERR), gShellDebug1HiiHandle, Status);
2196
ShellStatus = SHELL_NOT_FOUND;
2204
for (Bus = MinBus; Bus <= MaxBus; Bus++) {
2206
// For each devices, enumerate all functions it contains
2208
for (Device = 0; Device <= PCI_MAX_DEVICE; Device++) {
2210
// For each function, read its configuration space and print summary
2212
for (Func = 0; Func <= PCI_MAX_FUNC; Func++) {
2213
if (ShellGetExecutionBreakFlag ()) {
2214
ShellStatus = SHELL_ABORTED;
2217
Address = CALC_EFI_PCI_ADDRESS (Bus, Device, Func, 0);
2227
// If VendorId = 0xffff, there does not exist a device at this
2228
// location. For each device, if there is any function on it,
2229
// there must be 1 function at Function 0. So if Func = 0, there
2230
// will be no more functions in the same device, so we can break
2231
// loop to deal with the next device.
2233
if (PciHeader.VendorId == 0xffff && Func == 0) {
2237
if (PciHeader.VendorId != 0xffff) {
2240
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_PCI_TITLE), gShellDebug1HiiHandle);
2248
sizeof (PciHeader) / sizeof (UINT32),
2253
-1, -1, NULL, STRING_TOKEN (STR_PCI_LINE_P1), gShellDebug1HiiHandle,
2254
IoDev->SegmentNumber,
2260
PciPrintClassCode (PciHeader.ClassCode, FALSE);
2262
-1, -1, NULL, STRING_TOKEN (STR_PCI_LINE_P2), gShellDebug1HiiHandle,
2265
PciHeader.ClassCode[0]
2269
if (ScreenCount >= ScreenSize && ScreenSize != 0) {
2271
// If ScreenSize == 0 we have the console redirected so don't
2277
// If this is not a multi-function device, we can leave the loop
2278
// to deal with the next device.
2280
if (Func == 0 && ((PciHeader.HeaderType & HEADER_TYPE_MULTI_FUNCTION) == 0x00)) {
2288
// If Descriptor is NULL, Configuration() returns EFI_UNSUPPRORED,
2289
// we assume the bus range is 0~PCI_MAX_BUS. After enumerated all
2290
// devices on all bus, we can leave loop.
2292
if (Descriptors == NULL) {
2298
Status = EFI_SUCCESS;
2302
ExplainData = FALSE;
2307
if (ShellCommandLineGetFlag(Package, L"-i")) {
2311
Temp = ShellCommandLineGetValue(Package, L"-s");
2313
Segment = (UINT16) ShellStrToUintn (Temp);
2317
// The first Argument(except "-i") is assumed to be Bus number, second
2318
// to be Device number, and third to be Func number.
2320
Temp = ShellCommandLineGetRawValue(Package, 1);
2322
Bus = (UINT16)ShellStrToUintn(Temp);
2323
if (Bus > MAX_BUS_NUMBER) {
2324
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp);
2325
ShellStatus = SHELL_INVALID_PARAMETER;
2329
Temp = ShellCommandLineGetRawValue(Package, 2);
2331
Device = (UINT16) ShellStrToUintn(Temp);
2332
if (Device > MAX_DEVICE_NUMBER){
2333
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp);
2334
ShellStatus = SHELL_INVALID_PARAMETER;
2339
Temp = ShellCommandLineGetRawValue(Package, 3);
2341
Func = (UINT16) ShellStrToUintn(Temp);
2342
if (Func > MAX_FUNCTION_NUMBER){
2343
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp);
2344
ShellStatus = SHELL_INVALID_PARAMETER;
2350
// Find the protocol interface who's in charge of current segment, and its
2351
// bus range covers the current bus
2353
Status = PciFindProtocolInterface (
2361
if (EFI_ERROR (Status)) {
2363
-1, -1, NULL, STRING_TOKEN (STR_PCI_NO_FIND), gShellDebug1HiiHandle,
2364
gShellDebug1HiiHandle,
2368
ShellStatus = SHELL_NOT_FOUND;
2372
Address = CALC_EFI_PCI_ADDRESS (Bus, Device, Func, 0);
2373
Status = IoDev->Pci.Read (
2377
sizeof (ConfigSpace),
2381
if (EFI_ERROR (Status)) {
2382
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_PCI_NO_CFG), gShellDebug1HiiHandle, Status);
2383
ShellStatus = SHELL_ACCESS_DENIED;
2387
mConfigSpace = &ConfigSpace;
2392
STRING_TOKEN (STR_PCI_INFO),
2393
gShellDebug1HiiHandle,
2405
// Dump standard header of configuration space
2407
SizeOfHeader = sizeof (ConfigSpace.Common) + sizeof (ConfigSpace.NonCommon);
2409
DumpHex (2, 0, SizeOfHeader, &ConfigSpace);
2410
ShellPrintEx(-1,-1, L"\r\n");
2413
// Dump device dependent Part of configuration space
2418
sizeof (ConfigSpace) - SizeOfHeader,
2423
// If "-i" appears in command line, interpret data in configuration space
2426
Status = PciExplainData (&ConfigSpace, Address, IoDev);
2430
if (HandleBuf != NULL) {
2431
FreePool (HandleBuf);
2433
if (Package != NULL) {
2434
ShellCommandLineFreeVarList (Package);
2436
mConfigSpace = NULL;
2441
This function finds out the protocol which is in charge of the given
2442
segment, and its bus range covers the current bus number. It lookes
2443
each instances of RootBridgeIoProtocol handle, until the one meets the
2446
@param[in] HandleBuf Buffer which holds all PCI_ROOT_BRIDIGE_IO_PROTOCOL handles.
2447
@param[in] HandleCount Count of all PCI_ROOT_BRIDIGE_IO_PROTOCOL handles.
2448
@param[in] Segment Segment number of device we are dealing with.
2449
@param[in] Bus Bus number of device we are dealing with.
2450
@param[out] IoDev Handle used to access configuration space of PCI device.
2452
@retval EFI_SUCCESS The command completed successfully.
2453
@retval EFI_INVALID_PARAMETER Invalid parameter.
2457
PciFindProtocolInterface (
2458
IN EFI_HANDLE *HandleBuf,
2459
IN UINTN HandleCount,
2462
OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL **IoDev
2467
EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptors;
2473
// Go through all handles, until the one meets the criteria is found
2475
for (Index = 0; Index < HandleCount; Index++) {
2476
Status = PciGetProtocolAndResource (HandleBuf[Index], IoDev, &Descriptors);
2477
if (EFI_ERROR (Status)) {
2481
// When Descriptors == NULL, the Configuration() is not implemented,
2482
// so we only check the Segment number
2484
if (Descriptors == NULL && Segment == (*IoDev)->SegmentNumber) {
2488
if ((*IoDev)->SegmentNumber != Segment) {
2493
Status = PciGetNextBusRange (&Descriptors, &MinBus, &MaxBus, &IsEnd);
2494
if (EFI_ERROR (Status)) {
2502
if (MinBus <= Bus && MaxBus >= Bus) {
2508
return EFI_NOT_FOUND;
2512
This function gets the protocol interface from the given handle, and
2513
obtains its address space descriptors.
2515
@param[in] Handle The PCI_ROOT_BRIDIGE_IO_PROTOCOL handle.
2516
@param[out] IoDev Handle used to access configuration space of PCI device.
2517
@param[out] Descriptors Points to the address space descriptors.
2519
@retval EFI_SUCCESS The command completed successfully
2522
PciGetProtocolAndResource (
2523
IN EFI_HANDLE Handle,
2524
OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL **IoDev,
2525
OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR **Descriptors
2531
// Get inferface from protocol
2533
Status = gBS->HandleProtocol (
2535
&gEfiPciRootBridgeIoProtocolGuid,
2539
if (EFI_ERROR (Status)) {
2543
// Call Configuration() to get address space descriptors
2545
Status = (*IoDev)->Configuration (*IoDev, (VOID**)Descriptors);
2546
if (Status == EFI_UNSUPPORTED) {
2547
*Descriptors = NULL;
2556
This function get the next bus range of given address space descriptors.
2557
It also moves the pointer backward a node, to get prepared to be called
2560
@param[in, out] Descriptors Points to current position of a serial of address space
2562
@param[out] MinBus The lower range of bus number.
2563
@param[out] MaxBus The upper range of bus number.
2564
@param[out] IsEnd Meet end of the serial of descriptors.
2566
@retval EFI_SUCCESS The command completed successfully.
2569
PciGetNextBusRange (
2570
IN OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR **Descriptors,
2579
// When *Descriptors is NULL, Configuration() is not implemented, so assume
2580
// range is 0~PCI_MAX_BUS
2582
if ((*Descriptors) == NULL) {
2584
*MaxBus = PCI_MAX_BUS;
2588
// *Descriptors points to one or more address space descriptors, which
2589
// ends with a end tagged descriptor. Examine each of the descriptors,
2590
// if a bus typed one is found and its bus range covers bus, this handle
2591
// is the handle we are looking for.
2594
while ((*Descriptors)->Desc != ACPI_END_TAG_DESCRIPTOR) {
2595
if ((*Descriptors)->ResType == ACPI_ADDRESS_SPACE_TYPE_BUS) {
2596
*MinBus = (UINT16) (*Descriptors)->AddrRangeMin;
2597
*MaxBus = (UINT16) (*Descriptors)->AddrRangeMax;
2599
return (EFI_SUCCESS);
2605
if ((*Descriptors)->Desc == ACPI_END_TAG_DESCRIPTOR) {
2613
Explain the data in PCI configuration space. The part which is common for
2614
PCI device and bridge is interpreted in this function. It calls other
2615
functions to interpret data unique for device or bridge.
2617
@param[in] ConfigSpace Data in PCI configuration space.
2618
@param[in] Address Address used to access configuration space of this PCI device.
2619
@param[in] IoDev Handle used to access configuration space of PCI device.
2621
@retval EFI_SUCCESS The command completed successfully.
2625
IN PCI_CONFIG_SPACE *ConfigSpace,
2627
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev
2630
PCI_COMMON_HEADER *Common;
2631
PCI_HEADER_TYPE HeaderType;
2635
Common = &(ConfigSpace->Common);
2640
// Print Vendor Id and Device Id
2642
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_PCI_LINE_VID_DID), gShellDebug1HiiHandle,
2643
INDEX_OF (&(Common->VendorId)),
2645
INDEX_OF (&(Common->DeviceId)),
2650
// Print register Command
2652
PciExplainCommand (&(Common->Command));
2655
// Print register Status
2657
PciExplainStatus (&(Common->Status), TRUE, PciUndefined);
2660
// Print register Revision ID
2662
ShellPrintEx(-1, -1, L"/r/n");
2663
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_PCI_LINE_RID), gShellDebug1HiiHandle,
2664
INDEX_OF (&(Common->RevisionId)),
2669
// Print register BIST
2671
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_PCI_LINE_BIST), gShellDebug1HiiHandle, INDEX_OF (&(Common->Bist)));
2672
if ((Common->Bist & PCI_BIT_7) != 0) {
2673
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_PCI_LINE_CAP), gShellDebug1HiiHandle, 0x0f & Common->Bist);
2675
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_PCI_LINE_CAP_NO), gShellDebug1HiiHandle);
2678
// Print register Cache Line Size
2680
ShellPrintHiiEx(-1, -1, NULL,
2681
STRING_TOKEN (STR_PCI2_CACHE_LINE_SIZE),
2682
gShellDebug1HiiHandle,
2683
INDEX_OF (&(Common->CacheLineSize)),
2684
Common->CacheLineSize
2688
// Print register Latency Timer
2690
ShellPrintHiiEx(-1, -1, NULL,
2691
STRING_TOKEN (STR_PCI2_LATENCY_TIMER),
2692
gShellDebug1HiiHandle,
2693
INDEX_OF (&(Common->PrimaryLatencyTimer)),
2694
Common->PrimaryLatencyTimer
2698
// Print register Header Type
2700
ShellPrintHiiEx(-1, -1, NULL,
2701
STRING_TOKEN (STR_PCI2_HEADER_TYPE),
2702
gShellDebug1HiiHandle,
2703
INDEX_OF (&(Common->HeaderType)),
2707
if ((Common->HeaderType & PCI_BIT_7) != 0) {
2708
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_MULTI_FUNCTION), gShellDebug1HiiHandle);
2711
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_SINGLE_FUNCTION), gShellDebug1HiiHandle);
2714
HeaderType = (PCI_HEADER_TYPE)(UINT8) (Common->HeaderType & 0x7f);
2715
switch (HeaderType) {
2717
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_PCI_DEVICE), gShellDebug1HiiHandle);
2721
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_P2P_BRIDGE), gShellDebug1HiiHandle);
2724
case PciCardBusBridge:
2725
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_CARDBUS_BRIDGE), gShellDebug1HiiHandle);
2729
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_RESERVED), gShellDebug1HiiHandle);
2730
HeaderType = PciUndefined;
2734
// Print register Class Code
2736
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_CLASS), gShellDebug1HiiHandle);
2737
PciPrintClassCode ((UINT8 *) Common->ClassCode, TRUE);
2740
if (ShellGetExecutionBreakFlag()) {
2745
// Interpret remaining part of PCI configuration header depending on
2749
Status = EFI_SUCCESS;
2750
switch (HeaderType) {
2752
Status = PciExplainDeviceData (
2753
&(ConfigSpace->NonCommon.Device),
2757
CapPtr = ConfigSpace->NonCommon.Device.CapabilitiesPtr;
2761
Status = PciExplainBridgeData (
2762
&(ConfigSpace->NonCommon.Bridge),
2766
CapPtr = ConfigSpace->NonCommon.Bridge.CapabilitiesPtr;
2769
case PciCardBusBridge:
2770
Status = PciExplainCardBusData (
2771
&(ConfigSpace->NonCommon.CardBus),
2775
CapPtr = ConfigSpace->NonCommon.CardBus.CapabilitiesPtr;
2782
// If Status bit4 is 1, dump or explain capability structure
2784
if ((Common->Status) & EFI_PCI_STATUS_CAPABILITY) {
2785
PciExplainCapabilityStruct (IoDev, Address, CapPtr);
2792
Explain the device specific part of data in PCI configuration space.
2794
@param[in] Device Data in PCI configuration space.
2795
@param[in] Address Address used to access configuration space of this PCI device.
2796
@param[in] IoDev Handle used to access configuration space of PCI device.
2798
@retval EFI_SUCCESS The command completed successfully.
2801
PciExplainDeviceData (
2802
IN PCI_DEVICE_HEADER *Device,
2804
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev
2813
// Print Base Address Registers(Bar). When Bar = 0, this Bar does not
2814
// exist. If these no Bar for this function, print "none", otherwise
2815
// list detail information about this Bar.
2817
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_BASE_ADDR), gShellDebug1HiiHandle, INDEX_OF (Device->Bar));
2820
BarCount = sizeof (Device->Bar) / sizeof (Device->Bar[0]);
2821
for (Index = 0; Index < BarCount; Index++) {
2822
if (Device->Bar[Index] == 0) {
2828
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_START_TYPE), gShellDebug1HiiHandle);
2829
Print (L" --------------------------------------------------------------------------");
2832
Status = PciExplainBar (
2833
&(Device->Bar[Index]),
2834
&(mConfigSpace->Common.Command),
2840
if (EFI_ERROR (Status)) {
2846
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_NONE), gShellDebug1HiiHandle);
2849
Print (L"\n --------------------------------------------------------------------------");
2853
// Print register Expansion ROM Base Address
2855
if ((Device->ROMBar & PCI_BIT_0) == 0) {
2856
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_EXPANSION_ROM_DISABLED), gShellDebug1HiiHandle, INDEX_OF (&(Device->ROMBar)));
2859
ShellPrintHiiEx(-1, -1, NULL,
2860
STRING_TOKEN (STR_PCI2_EXPANSION_ROM_BASE),
2861
gShellDebug1HiiHandle,
2862
INDEX_OF (&(Device->ROMBar)),
2867
// Print register Cardbus CIS ptr
2869
ShellPrintHiiEx(-1, -1, NULL,
2870
STRING_TOKEN (STR_PCI2_CARDBUS_CIS),
2871
gShellDebug1HiiHandle,
2872
INDEX_OF (&(Device->CardBusCISPtr)),
2873
Device->CardBusCISPtr
2877
// Print register Sub-vendor ID and subsystem ID
2879
ShellPrintHiiEx(-1, -1, NULL,
2880
STRING_TOKEN (STR_PCI2_SUB_VENDOR_ID),
2881
gShellDebug1HiiHandle,
2882
INDEX_OF (&(Device->SubVendorId)),
2886
ShellPrintHiiEx(-1, -1, NULL,
2887
STRING_TOKEN (STR_PCI2_SUBSYSTEM_ID),
2888
gShellDebug1HiiHandle,
2889
INDEX_OF (&(Device->SubSystemId)),
2894
// Print register Capabilities Ptr
2896
ShellPrintHiiEx(-1, -1, NULL,
2897
STRING_TOKEN (STR_PCI2_CAPABILITIES_PTR),
2898
gShellDebug1HiiHandle,
2899
INDEX_OF (&(Device->CapabilitiesPtr)),
2900
Device->CapabilitiesPtr
2904
// Print register Interrupt Line and interrupt pin
2906
ShellPrintHiiEx(-1, -1, NULL,
2907
STRING_TOKEN (STR_PCI2_INTERRUPT_LINE),
2908
gShellDebug1HiiHandle,
2909
INDEX_OF (&(Device->InterruptLine)),
2910
Device->InterruptLine
2913
ShellPrintHiiEx(-1, -1, NULL,
2914
STRING_TOKEN (STR_PCI2_INTERRUPT_PIN),
2915
gShellDebug1HiiHandle,
2916
INDEX_OF (&(Device->InterruptPin)),
2917
Device->InterruptPin
2921
// Print register Min_Gnt and Max_Lat
2923
ShellPrintHiiEx(-1, -1, NULL,
2924
STRING_TOKEN (STR_PCI2_MIN_GNT),
2925
gShellDebug1HiiHandle,
2926
INDEX_OF (&(Device->MinGnt)),
2930
ShellPrintHiiEx(-1, -1, NULL,
2931
STRING_TOKEN (STR_PCI2_MAX_LAT),
2932
gShellDebug1HiiHandle,
2933
INDEX_OF (&(Device->MaxLat)),
2941
Explain the bridge specific part of data in PCI configuration space.
2943
@param[in] Bridge Bridge specific data region in PCI configuration space.
2944
@param[in] Address Address used to access configuration space of this PCI device.
2945
@param[in] IoDev Handle used to access configuration space of PCI device.
2947
@retval EFI_SUCCESS The command completed successfully.
2950
PciExplainBridgeData (
2951
IN PCI_BRIDGE_HEADER *Bridge,
2953
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev
2963
// Print Base Address Registers. When Bar = 0, this Bar does not
2964
// exist. If these no Bar for this function, print "none", otherwise
2965
// list detail information about this Bar.
2967
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_BASE_ADDRESS), gShellDebug1HiiHandle, INDEX_OF (&(Bridge->Bar)));
2970
BarCount = sizeof (Bridge->Bar) / sizeof (Bridge->Bar[0]);
2972
for (Index = 0; Index < BarCount; Index++) {
2973
if (Bridge->Bar[Index] == 0) {
2979
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_START_TYPE_2), gShellDebug1HiiHandle);
2980
Print (L" --------------------------------------------------------------------------");
2983
Status = PciExplainBar (
2984
&(Bridge->Bar[Index]),
2985
&(mConfigSpace->Common.Command),
2991
if (EFI_ERROR (Status)) {
2997
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_NONE), gShellDebug1HiiHandle);
2999
Print (L"\n --------------------------------------------------------------------------");
3003
// Expansion register ROM Base Address
3005
if ((Bridge->ROMBar & PCI_BIT_0) == 0) {
3006
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_NO_EXPANSION_ROM), gShellDebug1HiiHandle, INDEX_OF (&(Bridge->ROMBar)));
3009
ShellPrintHiiEx(-1, -1, NULL,
3010
STRING_TOKEN (STR_PCI2_EXPANSION_ROM_BASE_2),
3011
gShellDebug1HiiHandle,
3012
INDEX_OF (&(Bridge->ROMBar)),
3017
// Print Bus Numbers(Primary, Secondary, and Subordinate
3019
ShellPrintHiiEx(-1, -1, NULL,
3020
STRING_TOKEN (STR_PCI2_BUS_NUMBERS),
3021
gShellDebug1HiiHandle,
3022
INDEX_OF (&(Bridge->PrimaryBus)),
3023
INDEX_OF (&(Bridge->SecondaryBus)),
3024
INDEX_OF (&(Bridge->SubordinateBus))
3027
Print (L" ------------------------------------------------------\n");
3029
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_BRIDGE), gShellDebug1HiiHandle, Bridge->PrimaryBus);
3030
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_BRIDGE), gShellDebug1HiiHandle, Bridge->SecondaryBus);
3031
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_BRIDGE), gShellDebug1HiiHandle, Bridge->SubordinateBus);
3034
// Print register Secondary Latency Timer
3036
ShellPrintHiiEx(-1, -1, NULL,
3037
STRING_TOKEN (STR_PCI2_SECONDARY_TIMER),
3038
gShellDebug1HiiHandle,
3039
INDEX_OF (&(Bridge->SecondaryLatencyTimer)),
3040
Bridge->SecondaryLatencyTimer
3044
// Print register Secondary Status
3046
PciExplainStatus (&(Bridge->SecondaryStatus), FALSE, PciP2pBridge);
3049
// Print I/O and memory ranges this bridge forwards. There are 3 resource
3050
// types: I/O, memory, and pre-fetchable memory. For each resource type,
3051
// base and limit address are listed.
3053
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_RESOURCE_TYPE), gShellDebug1HiiHandle);
3054
Print (L"----------------------------------------------------------------------\n");
3059
IoAddress32 = (Bridge->IoBaseUpper << 16 | Bridge->IoBase << 8);
3060
IoAddress32 &= 0xfffff000;
3061
ShellPrintHiiEx(-1, -1, NULL,
3062
STRING_TOKEN (STR_PCI2_TWO_VARS),
3063
gShellDebug1HiiHandle,
3064
INDEX_OF (&(Bridge->IoBase)),
3068
IoAddress32 = (Bridge->IoLimitUpper << 16 | Bridge->IoLimit << 8);
3069
IoAddress32 |= 0x00000fff;
3070
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_ONE_VAR), gShellDebug1HiiHandle, IoAddress32);
3073
// Memory Base & Limit
3075
ShellPrintHiiEx(-1, -1, NULL,
3076
STRING_TOKEN (STR_PCI2_MEMORY),
3077
gShellDebug1HiiHandle,
3078
INDEX_OF (&(Bridge->MemoryBase)),
3079
(Bridge->MemoryBase << 16) & 0xfff00000
3082
ShellPrintHiiEx(-1, -1, NULL,
3083
STRING_TOKEN (STR_PCI2_ONE_VAR),
3084
gShellDebug1HiiHandle,
3085
(Bridge->MemoryLimit << 16) | 0x000fffff
3089
// Pre-fetch-able Memory Base & Limit
3091
ShellPrintHiiEx(-1, -1, NULL,
3092
STRING_TOKEN (STR_PCI2_PREFETCHABLE),
3093
gShellDebug1HiiHandle,
3094
INDEX_OF (&(Bridge->PrefetchableMemBase)),
3095
Bridge->PrefetchableBaseUpper,
3096
(Bridge->PrefetchableMemBase << 16) & 0xfff00000
3099
ShellPrintHiiEx(-1, -1, NULL,
3100
STRING_TOKEN (STR_PCI2_TWO_VARS_2),
3101
gShellDebug1HiiHandle,
3102
Bridge->PrefetchableLimitUpper,
3103
(Bridge->PrefetchableMemLimit << 16) | 0x000fffff
3107
// Print register Capabilities Pointer
3109
ShellPrintHiiEx(-1, -1, NULL,
3110
STRING_TOKEN (STR_PCI2_CAPABILITIES_PTR_2),
3111
gShellDebug1HiiHandle,
3112
INDEX_OF (&(Bridge->CapabilitiesPtr)),
3113
Bridge->CapabilitiesPtr
3117
// Print register Bridge Control
3119
PciExplainBridgeControl (&(Bridge->BridgeControl), PciP2pBridge);
3122
// Print register Interrupt Line & PIN
3124
ShellPrintHiiEx(-1, -1, NULL,
3125
STRING_TOKEN (STR_PCI2_INTERRUPT_LINE_2),
3126
gShellDebug1HiiHandle,
3127
INDEX_OF (&(Bridge->InterruptLine)),
3128
Bridge->InterruptLine
3131
ShellPrintHiiEx(-1, -1, NULL,
3132
STRING_TOKEN (STR_PCI2_INTERRUPT_PIN),
3133
gShellDebug1HiiHandle,
3134
INDEX_OF (&(Bridge->InterruptPin)),
3135
Bridge->InterruptPin
3142
Explain the Base Address Register(Bar) in PCI configuration space.
3144
@param[in] Bar Points to the Base Address Register intended to interpret.
3145
@param[in] Command Points to the register Command.
3146
@param[in] Address Address used to access configuration space of this PCI device.
3147
@param[in] IoDev Handle used to access configuration space of PCI device.
3148
@param[in, out] Index The Index.
3150
@retval EFI_SUCCESS The command completed successfully.
3157
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev,
3178
// According the bar type, list detail about this bar, for example: 32 or
3179
// 64 bits; pre-fetchable or not.
3181
if ((*Bar & PCI_BIT_0) == 0) {
3183
// This bar is of memory type
3187
if ((*Bar & PCI_BIT_1) == 0 && (*Bar & PCI_BIT_2) == 0) {
3188
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_BAR), gShellDebug1HiiHandle, *Bar & 0xfffffff0);
3189
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_MEM), gShellDebug1HiiHandle);
3190
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_32_BITS), gShellDebug1HiiHandle);
3192
} else if ((*Bar & PCI_BIT_1) == 0 && (*Bar & PCI_BIT_2) != 0) {
3194
CopyMem (&Bar64, Bar, sizeof (UINT64));
3195
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_ONE_VAR_2), gShellDebug1HiiHandle, (UINT32) RShiftU64 ((Bar64 & 0xfffffffffffffff0ULL), 32));
3196
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_ONE_VAR_3), gShellDebug1HiiHandle, (UINT32) (Bar64 & 0xfffffffffffffff0ULL));
3197
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_MEM), gShellDebug1HiiHandle);
3198
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_64_BITS), gShellDebug1HiiHandle);
3206
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_BAR), gShellDebug1HiiHandle, *Bar & 0xfffffff0);
3207
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_MEM_2), gShellDebug1HiiHandle);
3210
if ((*Bar & PCI_BIT_3) == 0) {
3211
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_NO), gShellDebug1HiiHandle);
3214
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_YES), gShellDebug1HiiHandle);
3219
// This bar is of io type
3222
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_ONE_VAR_4), gShellDebug1HiiHandle, *Bar & 0xfffffffc);
3227
// Get BAR length(or the amount of resource this bar demands for). To get
3228
// Bar length, first we should temporarily disable I/O and memory access
3229
// of this function(by set bits in the register Command), then write all
3230
// "1"s to this bar. The bar value read back is the amount of resource
3231
// this bar demands for.
3234
// Disable io & mem access
3236
OldCommand = *Command;
3237
NewCommand = (UINT16) (OldCommand & 0xfffc);
3238
RegAddress = Address | INDEX_OF (Command);
3239
IoDev->Pci.Write (IoDev, EfiPciWidthUint16, RegAddress, 1, &NewCommand);
3241
RegAddress = Address | INDEX_OF (Bar);
3244
// Read after write the BAR to get the size
3248
NewBar32 = 0xffffffff;
3250
IoDev->Pci.Write (IoDev, EfiPciWidthUint32, RegAddress, 1, &NewBar32);
3251
IoDev->Pci.Read (IoDev, EfiPciWidthUint32, RegAddress, 1, &NewBar32);
3252
IoDev->Pci.Write (IoDev, EfiPciWidthUint32, RegAddress, 1, &OldBar32);
3255
NewBar32 = NewBar32 & 0xfffffff0;
3256
NewBar32 = (~NewBar32) + 1;
3259
NewBar32 = NewBar32 & 0xfffffffc;
3260
NewBar32 = (~NewBar32) + 1;
3261
NewBar32 = NewBar32 & 0x0000ffff;
3266
CopyMem (&OldBar64, Bar, sizeof (UINT64));
3267
NewBar64 = 0xffffffffffffffffULL;
3269
IoDev->Pci.Write (IoDev, EfiPciWidthUint32, RegAddress, 2, &NewBar64);
3270
IoDev->Pci.Read (IoDev, EfiPciWidthUint32, RegAddress, 2, &NewBar64);
3271
IoDev->Pci.Write (IoDev, EfiPciWidthUint32, RegAddress, 2, &OldBar64);
3274
NewBar64 = NewBar64 & 0xfffffffffffffff0ULL;
3275
NewBar64 = (~NewBar64) + 1;
3278
NewBar64 = NewBar64 & 0xfffffffffffffffcULL;
3279
NewBar64 = (~NewBar64) + 1;
3280
NewBar64 = NewBar64 & 0x000000000000ffff;
3284
// Enable io & mem access
3286
RegAddress = Address | INDEX_OF (Command);
3287
IoDev->Pci.Write (IoDev, EfiPciWidthUint16, RegAddress, 1, &OldCommand);
3291
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_NEWBAR_32), gShellDebug1HiiHandle, NewBar32);
3292
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_NEWBAR_32_2), gShellDebug1HiiHandle, NewBar32 + (*Bar & 0xfffffff0) - 1);
3295
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_RSHIFT), gShellDebug1HiiHandle, (UINT32) RShiftU64 (NewBar64, 32));
3296
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_RSHIFT), gShellDebug1HiiHandle, (UINT32) NewBar64);
3298
ShellPrintHiiEx(-1, -1, NULL,
3299
STRING_TOKEN (STR_PCI2_RSHIFT),
3300
gShellDebug1HiiHandle,
3301
(UINT32) RShiftU64 ((NewBar64 + (Bar64 & 0xfffffffffffffff0ULL) - 1), 32)
3303
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_RSHIFT), gShellDebug1HiiHandle, (UINT32) (NewBar64 + (Bar64 & 0xfffffffffffffff0ULL) - 1));
3307
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_NEWBAR_32_3), gShellDebug1HiiHandle, NewBar32);
3308
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_NEWBAR_32_4), gShellDebug1HiiHandle, NewBar32 + (*Bar & 0xfffffffc) - 1);
3315
Explain the cardbus specific part of data in PCI configuration space.
3317
@param[in] CardBus CardBus specific region of PCI configuration space.
3318
@param[in] Address Address used to access configuration space of this PCI device.
3319
@param[in] IoDev Handle used to access configuration space of PCI device.
3321
@retval EFI_SUCCESS The command completed successfully.
3324
PciExplainCardBusData (
3325
IN PCI_CARDBUS_HEADER *CardBus,
3327
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev
3331
PCI_CARDBUS_DATA *CardBusData;
3333
ShellPrintHiiEx(-1, -1, NULL,
3334
STRING_TOKEN (STR_PCI2_CARDBUS_SOCKET),
3335
gShellDebug1HiiHandle,
3336
INDEX_OF (&(CardBus->CardBusSocketReg)),
3337
CardBus->CardBusSocketReg
3341
// Print Secondary Status
3343
PciExplainStatus (&(CardBus->SecondaryStatus), FALSE, PciCardBusBridge);
3346
// Print Bus Numbers(Primary bus number, CardBus bus number, and
3347
// Subordinate bus number
3349
ShellPrintHiiEx(-1, -1, NULL,
3350
STRING_TOKEN (STR_PCI2_BUS_NUMBERS_2),
3351
gShellDebug1HiiHandle,
3352
INDEX_OF (&(CardBus->PciBusNumber)),
3353
INDEX_OF (&(CardBus->CardBusBusNumber)),
3354
INDEX_OF (&(CardBus->SubordinateBusNumber))
3357
Print (L" ------------------------------------------------------\n");
3359
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_CARDBUS), gShellDebug1HiiHandle, CardBus->PciBusNumber);
3360
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_CARDBUS_2), gShellDebug1HiiHandle, CardBus->CardBusBusNumber);
3361
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_CARDBUS_3), gShellDebug1HiiHandle, CardBus->SubordinateBusNumber);
3364
// Print CardBus Latency Timer
3366
ShellPrintHiiEx(-1, -1, NULL,
3367
STRING_TOKEN (STR_PCI2_CARDBUS_LATENCY),
3368
gShellDebug1HiiHandle,
3369
INDEX_OF (&(CardBus->CardBusLatencyTimer)),
3370
CardBus->CardBusLatencyTimer
3374
// Print Memory/Io ranges this cardbus bridge forwards
3376
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_RESOURCE_TYPE_2), gShellDebug1HiiHandle);
3377
Print (L"----------------------------------------------------------------------\n");
3379
ShellPrintHiiEx(-1, -1, NULL,
3380
STRING_TOKEN (STR_PCI2_MEM_3),
3381
gShellDebug1HiiHandle,
3382
INDEX_OF (&(CardBus->MemoryBase0)),
3383
CardBus->BridgeControl & PCI_BIT_8 ? L" Prefetchable" : L"Non-Prefetchable",
3384
CardBus->MemoryBase0 & 0xfffff000,
3385
CardBus->MemoryLimit0 | 0x00000fff
3388
ShellPrintHiiEx(-1, -1, NULL,
3389
STRING_TOKEN (STR_PCI2_MEM_3),
3390
gShellDebug1HiiHandle,
3391
INDEX_OF (&(CardBus->MemoryBase1)),
3392
CardBus->BridgeControl & PCI_BIT_9 ? L" Prefetchable" : L"Non-Prefetchable",
3393
CardBus->MemoryBase1 & 0xfffff000,
3394
CardBus->MemoryLimit1 | 0x00000fff
3397
Io32Bit = (BOOLEAN) (CardBus->IoBase0 & PCI_BIT_0);
3398
ShellPrintHiiEx(-1, -1, NULL,
3399
STRING_TOKEN (STR_PCI2_IO_2),
3400
gShellDebug1HiiHandle,
3401
INDEX_OF (&(CardBus->IoBase0)),
3402
Io32Bit ? L" 32 bit" : L" 16 bit",
3403
CardBus->IoBase0 & (Io32Bit ? 0xfffffffc : 0x0000fffc),
3404
(CardBus->IoLimit0 & (Io32Bit ? 0xffffffff : 0x0000ffff)) | 0x00000003
3407
Io32Bit = (BOOLEAN) (CardBus->IoBase1 & PCI_BIT_0);
3408
ShellPrintHiiEx(-1, -1, NULL,
3409
STRING_TOKEN (STR_PCI2_IO_2),
3410
gShellDebug1HiiHandle,
3411
INDEX_OF (&(CardBus->IoBase1)),
3412
Io32Bit ? L" 32 bit" : L" 16 bit",
3413
CardBus->IoBase1 & (Io32Bit ? 0xfffffffc : 0x0000fffc),
3414
(CardBus->IoLimit1 & (Io32Bit ? 0xffffffff : 0x0000ffff)) | 0x00000003
3418
// Print register Interrupt Line & PIN
3420
ShellPrintHiiEx(-1, -1, NULL,
3421
STRING_TOKEN (STR_PCI2_INTERRUPT_LINE_3),
3422
gShellDebug1HiiHandle,
3423
INDEX_OF (&(CardBus->InterruptLine)),
3424
CardBus->InterruptLine,
3425
INDEX_OF (&(CardBus->InterruptPin)),
3426
CardBus->InterruptPin
3430
// Print register Bridge Control
3432
PciExplainBridgeControl (&(CardBus->BridgeControl), PciCardBusBridge);
3435
// Print some registers in data region of PCI configuration space for cardbus
3436
// bridge. Fields include: Sub VendorId, Subsystem ID, and Legacy Mode Base
3439
CardBusData = (PCI_CARDBUS_DATA *) ((UINT8 *) CardBus + sizeof (PCI_CARDBUS_HEADER));
3441
ShellPrintHiiEx(-1, -1, NULL,
3442
STRING_TOKEN (STR_PCI2_SUB_VENDOR_ID_2),
3443
gShellDebug1HiiHandle,
3444
INDEX_OF (&(CardBusData->SubVendorId)),
3445
CardBusData->SubVendorId,
3446
INDEX_OF (&(CardBusData->SubSystemId)),
3447
CardBusData->SubSystemId
3450
ShellPrintHiiEx(-1, -1, NULL,
3451
STRING_TOKEN (STR_PCI2_OPTIONAL),
3452
gShellDebug1HiiHandle,
3453
INDEX_OF (&(CardBusData->LegacyBase)),
3454
CardBusData->LegacyBase
3461
Explain each meaningful bit of register Status. The definition of Status is
3462
slightly different depending on the PCI header type.
3464
@param[in] Status Points to the content of register Status.
3465
@param[in] MainStatus Indicates if this register is main status(not secondary
3467
@param[in] HeaderType Header type of this PCI device.
3469
@retval EFI_SUCCESS The command completed successfully.
3474
IN BOOLEAN MainStatus,
3475
IN PCI_HEADER_TYPE HeaderType
3479
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_STATUS), gShellDebug1HiiHandle, INDEX_OF (Status), *Status);
3482
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_SECONDARY_STATUS), gShellDebug1HiiHandle, INDEX_OF (Status), *Status);
3485
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_NEW_CAPABILITIES), gShellDebug1HiiHandle, (*Status & PCI_BIT_4) != 0);
3488
// Bit 5 is meaningless for CardBus Bridge
3490
if (HeaderType == PciCardBusBridge) {
3491
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_66_CAPABLE), gShellDebug1HiiHandle, (*Status & PCI_BIT_5) != 0);
3494
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_66_CAPABLE_2), gShellDebug1HiiHandle, (*Status & PCI_BIT_5) != 0);
3497
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_FAST_BACK), gShellDebug1HiiHandle, (*Status & PCI_BIT_7) != 0);
3499
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_MASTER_DATA), gShellDebug1HiiHandle, (*Status & PCI_BIT_8) != 0);
3501
// Bit 9 and bit 10 together decides the DEVSEL timing
3503
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_DEVSEL_TIMING), gShellDebug1HiiHandle);
3504
if ((*Status & PCI_BIT_9) == 0 && (*Status & PCI_BIT_10) == 0) {
3505
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_FAST), gShellDebug1HiiHandle);
3507
} else if ((*Status & PCI_BIT_9) != 0 && (*Status & PCI_BIT_10) == 0) {
3508
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_MEDIUM), gShellDebug1HiiHandle);
3510
} else if ((*Status & PCI_BIT_9) == 0 && (*Status & PCI_BIT_10) != 0) {
3511
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_SLOW), gShellDebug1HiiHandle);
3514
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_RESERVED_2), gShellDebug1HiiHandle);
3517
ShellPrintHiiEx(-1, -1, NULL,
3518
STRING_TOKEN (STR_PCI2_SIGNALED_TARGET),
3519
gShellDebug1HiiHandle,
3520
(*Status & PCI_BIT_11) != 0
3523
ShellPrintHiiEx(-1, -1, NULL,
3524
STRING_TOKEN (STR_PCI2_RECEIVED_TARGET),
3525
gShellDebug1HiiHandle,
3526
(*Status & PCI_BIT_12) != 0
3529
ShellPrintHiiEx(-1, -1, NULL,
3530
STRING_TOKEN (STR_PCI2_RECEIVED_MASTER),
3531
gShellDebug1HiiHandle,
3532
(*Status & PCI_BIT_13) != 0
3536
ShellPrintHiiEx(-1, -1, NULL,
3537
STRING_TOKEN (STR_PCI2_SIGNALED_ERROR),
3538
gShellDebug1HiiHandle,
3539
(*Status & PCI_BIT_14) != 0
3543
ShellPrintHiiEx(-1, -1, NULL,
3544
STRING_TOKEN (STR_PCI2_RECEIVED_ERROR),
3545
gShellDebug1HiiHandle,
3546
(*Status & PCI_BIT_14) != 0
3550
ShellPrintHiiEx(-1, -1, NULL,
3551
STRING_TOKEN (STR_PCI2_DETECTED_ERROR),
3552
gShellDebug1HiiHandle,
3553
(*Status & PCI_BIT_15) != 0
3560
Explain each meaningful bit of register Command.
3562
@param[in] Command Points to the content of register Command.
3564
@retval EFI_SUCCESS The command completed successfully.
3572
// Print the binary value of register Command
3574
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_COMMAND), gShellDebug1HiiHandle, INDEX_OF (Command), *Command);
3577
// Explain register Command bit by bit
3579
ShellPrintHiiEx(-1, -1, NULL,
3580
STRING_TOKEN (STR_PCI2_SPACE_ACCESS_DENIED),
3581
gShellDebug1HiiHandle,
3582
(*Command & PCI_BIT_0) != 0
3585
ShellPrintHiiEx(-1, -1, NULL,
3586
STRING_TOKEN (STR_PCI2_MEMORY_SPACE),
3587
gShellDebug1HiiHandle,
3588
(*Command & PCI_BIT_1) != 0
3591
ShellPrintHiiEx(-1, -1, NULL,
3592
STRING_TOKEN (STR_PCI2_BEHAVE_BUS_MASTER),
3593
gShellDebug1HiiHandle,
3594
(*Command & PCI_BIT_2) != 0
3597
ShellPrintHiiEx(-1, -1, NULL,
3598
STRING_TOKEN (STR_PCI2_MONITOR_SPECIAL_CYCLE),
3599
gShellDebug1HiiHandle,
3600
(*Command & PCI_BIT_3) != 0
3603
ShellPrintHiiEx(-1, -1, NULL,
3604
STRING_TOKEN (STR_PCI2_MEM_WRITE_INVALIDATE),
3605
gShellDebug1HiiHandle,
3606
(*Command & PCI_BIT_4) != 0
3609
ShellPrintHiiEx(-1, -1, NULL,
3610
STRING_TOKEN (STR_PCI2_PALETTE_SNOOPING),
3611
gShellDebug1HiiHandle,
3612
(*Command & PCI_BIT_5) != 0
3615
ShellPrintHiiEx(-1, -1, NULL,
3616
STRING_TOKEN (STR_PCI2_ASSERT_PERR),
3617
gShellDebug1HiiHandle,
3618
(*Command & PCI_BIT_6) != 0
3621
ShellPrintHiiEx(-1, -1, NULL,
3622
STRING_TOKEN (STR_PCI2_DO_ADDR_STEPPING),
3623
gShellDebug1HiiHandle,
3624
(*Command & PCI_BIT_7) != 0
3627
ShellPrintHiiEx(-1, -1, NULL,
3628
STRING_TOKEN (STR_PCI2_SERR_DRIVER),
3629
gShellDebug1HiiHandle,
3630
(*Command & PCI_BIT_8) != 0
3633
ShellPrintHiiEx(-1, -1, NULL,
3634
STRING_TOKEN (STR_PCI2_FAST_BACK_2),
3635
gShellDebug1HiiHandle,
3636
(*Command & PCI_BIT_9) != 0
3643
Explain each meaningful bit of register Bridge Control.
3645
@param[in] BridgeControl Points to the content of register Bridge Control.
3646
@param[in] HeaderType The headertype.
3648
@retval EFI_SUCCESS The command completed successfully.
3651
PciExplainBridgeControl (
3652
IN UINT16 *BridgeControl,
3653
IN PCI_HEADER_TYPE HeaderType
3656
ShellPrintHiiEx(-1, -1, NULL,
3657
STRING_TOKEN (STR_PCI2_BRIDGE_CONTROL),
3658
gShellDebug1HiiHandle,
3659
INDEX_OF (BridgeControl),
3663
ShellPrintHiiEx(-1, -1, NULL,
3664
STRING_TOKEN (STR_PCI2_PARITY_ERROR),
3665
gShellDebug1HiiHandle,
3666
(*BridgeControl & PCI_BIT_0) != 0
3668
ShellPrintHiiEx(-1, -1, NULL,
3669
STRING_TOKEN (STR_PCI2_SERR_ENABLE),
3670
gShellDebug1HiiHandle,
3671
(*BridgeControl & PCI_BIT_1) != 0
3673
ShellPrintHiiEx(-1, -1, NULL,
3674
STRING_TOKEN (STR_PCI2_ISA_ENABLE),
3675
gShellDebug1HiiHandle,
3676
(*BridgeControl & PCI_BIT_2) != 0
3678
ShellPrintHiiEx(-1, -1, NULL,
3679
STRING_TOKEN (STR_PCI2_VGA_ENABLE),
3680
gShellDebug1HiiHandle,
3681
(*BridgeControl & PCI_BIT_3) != 0
3683
ShellPrintHiiEx(-1, -1, NULL,
3684
STRING_TOKEN (STR_PCI2_MASTER_ABORT),
3685
gShellDebug1HiiHandle,
3686
(*BridgeControl & PCI_BIT_5) != 0
3690
// Register Bridge Control has some slight differences between P2P bridge
3691
// and Cardbus bridge from bit 6 to bit 11.
3693
if (HeaderType == PciP2pBridge) {
3694
ShellPrintHiiEx(-1, -1, NULL,
3695
STRING_TOKEN (STR_PCI2_SECONDARY_BUS_RESET),
3696
gShellDebug1HiiHandle,
3697
(*BridgeControl & PCI_BIT_6) != 0
3699
ShellPrintHiiEx(-1, -1, NULL,
3700
STRING_TOKEN (STR_PCI2_FAST_ENABLE),
3701
gShellDebug1HiiHandle,
3702
(*BridgeControl & PCI_BIT_7) != 0
3704
ShellPrintHiiEx(-1, -1, NULL,
3705
STRING_TOKEN (STR_PCI2_PRIMARY_DISCARD_TIMER),
3706
gShellDebug1HiiHandle,
3707
(*BridgeControl & PCI_BIT_8)!=0 ? L"2^10" : L"2^15"
3709
ShellPrintHiiEx(-1, -1, NULL,
3710
STRING_TOKEN (STR_PCI2_SECONDARY_DISCARD_TIMER),
3711
gShellDebug1HiiHandle,
3712
(*BridgeControl & PCI_BIT_9)!=0 ? L"2^10" : L"2^15"
3714
ShellPrintHiiEx(-1, -1, NULL,
3715
STRING_TOKEN (STR_PCI2_DISCARD_TIMER_STATUS),
3716
gShellDebug1HiiHandle,
3717
(*BridgeControl & PCI_BIT_10) != 0
3719
ShellPrintHiiEx(-1, -1, NULL,
3720
STRING_TOKEN (STR_PCI2_DISCARD_TIMER_SERR),
3721
gShellDebug1HiiHandle,
3722
(*BridgeControl & PCI_BIT_11) != 0
3726
ShellPrintHiiEx(-1, -1, NULL,
3727
STRING_TOKEN (STR_PCI2_CARDBUS_RESET),
3728
gShellDebug1HiiHandle,
3729
(*BridgeControl & PCI_BIT_6) != 0
3731
ShellPrintHiiEx(-1, -1, NULL,
3732
STRING_TOKEN (STR_PCI2_IREQ_ENABLE),
3733
gShellDebug1HiiHandle,
3734
(*BridgeControl & PCI_BIT_7) != 0
3736
ShellPrintHiiEx(-1, -1, NULL,
3737
STRING_TOKEN (STR_PCI2_WRITE_POSTING_ENABLE),
3738
gShellDebug1HiiHandle,
3739
(*BridgeControl & PCI_BIT_10) != 0
3747
Print each capability structure.
3749
@param[in] IoDev The pointer to the deivce.
3750
@param[in] Address The address to start at.
3751
@param[in] CapPtr The offset from the address.
3753
@retval EFI_SUCCESS The operation was successful.
3756
PciExplainCapabilityStruct (
3757
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev,
3762
UINT8 CapabilityPtr;
3763
UINT16 CapabilityEntry;
3767
CapabilityPtr = CapPtr;
3770
// Go through the Capability list
3772
while ((CapabilityPtr >= 0x40) && ((CapabilityPtr & 0x03) == 0x00)) {
3773
RegAddress = Address + CapabilityPtr;
3774
IoDev->Pci.Read (IoDev, EfiPciWidthUint16, RegAddress, 1, &CapabilityEntry);
3776
CapabilityID = (UINT8) CapabilityEntry;
3779
// Explain PciExpress data
3781
if (EFI_PCI_CAPABILITY_ID_PCIEXP == CapabilityID) {
3782
PciExplainPciExpress (IoDev, Address, CapabilityPtr);
3786
// Explain other capabilities here
3788
CapabilityPtr = (UINT8) (CapabilityEntry >> 8);
3795
Print out information of the capability information.
3797
@param[in] PciExpressCap The pointer to the structure about the device.
3799
@retval EFI_SUCCESS The operation was successful.
3803
IN PCIE_CAP_STURCTURE *PciExpressCap
3807
CHAR16 *DevicePortType;
3809
PcieCapReg = PciExpressCap->PcieCapReg;
3811
L" Capability Version(3:0): %E0x%04x%N\n",
3812
PCIE_CAP_VERSION (PcieCapReg)
3814
if ((UINT8) PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg) < PCIE_DEVICE_PORT_TYPE_MAX) {
3815
DevicePortType = DevicePortTypeTable[PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg)];
3817
DevicePortType = L"Unknown Type";
3820
L" Device/PortType(7:4): %E%s%N\n",
3824
// 'Slot Implemented' is only valid for:
3825
// a) Root Port of PCI Express Root Complex, or
3826
// b) Downstream Port of PCI Express Switch
3828
if (PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg) == PCIE_ROOT_COMPLEX_ROOT_PORT ||
3829
PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg) == PCIE_SWITCH_DOWNSTREAM_PORT) {
3831
L" Slot Implemented(8): %E%d%N\n",
3832
PCIE_CAP_SLOT_IMPLEMENTED (PcieCapReg)
3836
L" Interrupt Message Number(13:9): %E0x%05x%N\n",
3837
PCIE_CAP_INT_MSG_NUM (PcieCapReg)
3843
Print out information of the device capability information.
3845
@param[in] PciExpressCap The pointer to the structure about the device.
3847
@retval EFI_SUCCESS The operation was successful.
3850
ExplainPcieDeviceCap (
3851
IN PCIE_CAP_STURCTURE *PciExpressCap
3855
UINT32 PcieDeviceCap;
3856
UINT8 DevicePortType;
3860
PcieCapReg = PciExpressCap->PcieCapReg;
3861
PcieDeviceCap = PciExpressCap->PcieDeviceCap;
3862
DevicePortType = (UINT8) PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg);
3863
Print (L" Max_Payload_Size Supported(2:0): ");
3864
if (PCIE_CAP_MAX_PAYLOAD (PcieDeviceCap) < 6) {
3865
Print (L"%E%d bytes%N\n", 1 << (PCIE_CAP_MAX_PAYLOAD (PcieDeviceCap) + 7));
3867
Print (L"%EUnknown%N\n");
3870
L" Phantom Functions Supported(4:3): %E%d%N\n",
3871
PCIE_CAP_PHANTOM_FUNC (PcieDeviceCap)
3874
L" Extended Tag Field Supported(5): %E%d-bit Tag field supported%N\n",
3875
PCIE_CAP_EXTENDED_TAG (PcieDeviceCap) ? 8 : 5
3878
// Endpoint L0s and L1 Acceptable Latency is only valid for Endpoint
3880
if (IS_PCIE_ENDPOINT (DevicePortType)) {
3881
L0sLatency = (UINT8) PCIE_CAP_L0SLATENCY (PcieDeviceCap);
3882
L1Latency = (UINT8) PCIE_CAP_L1LATENCY (PcieDeviceCap);
3883
Print (L" Endpoint L0s Acceptable Latency(8:6): ");
3884
if (L0sLatency < 4) {
3885
Print (L"%EMaximum of %d ns%N\n", 1 << (L0sLatency + 6));
3887
if (L0sLatency < 7) {
3888
Print (L"%EMaximum of %d us%N\n", 1 << (L0sLatency - 3));
3890
Print (L"%ENo limit%N\n");
3893
Print (L" Endpoint L1 Acceptable Latency(11:9): ");
3894
if (L1Latency < 7) {
3895
Print (L"%EMaximum of %d us%N\n", 1 << (L1Latency + 1));
3897
Print (L"%ENo limit%N\n");
3901
L" Role-based Error Reporting(15): %E%d%N\n",
3902
PCIE_CAP_ERR_REPORTING (PcieDeviceCap)
3905
// Only valid for Upstream Port:
3906
// a) Captured Slot Power Limit Value
3907
// b) Captured Slot Power Scale
3909
if (DevicePortType == PCIE_SWITCH_UPSTREAM_PORT) {
3911
L" Captured Slot Power Limit Value(25:18): %E0x%02x%N\n",
3912
PCIE_CAP_SLOT_POWER_VALUE (PcieDeviceCap)
3915
L" Captured Slot Power Limit Scale(27:26): %E%s%N\n",
3916
SlotPwrLmtScaleTable[PCIE_CAP_SLOT_POWER_SCALE (PcieDeviceCap)]
3920
// Function Level Reset Capability is only valid for Endpoint
3922
if (IS_PCIE_ENDPOINT (DevicePortType)) {
3924
L" Function Level Reset Capability(28): %E%d%N\n",
3925
PCIE_CAP_FUNC_LEVEL_RESET (PcieDeviceCap)
3932
Print out information of the device control information.
3934
@param[in] PciExpressCap The pointer to the structure about the device.
3936
@retval EFI_SUCCESS The operation was successful.
3939
ExplainPcieDeviceControl (
3940
IN PCIE_CAP_STURCTURE *PciExpressCap
3944
UINT16 PcieDeviceControl;
3946
PcieCapReg = PciExpressCap->PcieCapReg;
3947
PcieDeviceControl = PciExpressCap->DeviceControl;
3949
L" Correctable Error Reporting Enable(0): %E%d%N\n",
3950
PCIE_CAP_COR_ERR_REPORTING_ENABLE (PcieDeviceControl)
3953
L" Non-Fatal Error Reporting Enable(1): %E%d%N\n",
3954
PCIE_CAP_NONFAT_ERR_REPORTING_ENABLE (PcieDeviceControl)
3957
L" Fatal Error Reporting Enable(2): %E%d%N\n",
3958
PCIE_CAP_FATAL_ERR_REPORTING_ENABLE (PcieDeviceControl)
3961
L" Unsupported Request Reporting Enable(3): %E%d%N\n",
3962
PCIE_CAP_UNSUP_REQ_REPORTING_ENABLE (PcieDeviceControl)
3965
L" Enable Relaxed Ordering(4): %E%d%N\n",
3966
PCIE_CAP_RELAXED_ORDERING_ENABLE (PcieDeviceControl)
3968
Print (L" Max_Payload_Size(7:5): ");
3969
if (PCIE_CAP_MAX_PAYLOAD_SIZE (PcieDeviceControl) < 6) {
3970
Print (L"%E%d bytes%N\n", 1 << (PCIE_CAP_MAX_PAYLOAD_SIZE (PcieDeviceControl) + 7));
3972
Print (L"%EUnknown%N\n");
3975
L" Extended Tag Field Enable(8): %E%d%N\n",
3976
PCIE_CAP_EXTENDED_TAG_ENABLE (PcieDeviceControl)
3979
L" Phantom Functions Enable(9): %E%d%N\n",
3980
PCIE_CAP_PHANTOM_FUNC_ENABLE (PcieDeviceControl)
3983
L" Auxiliary (AUX) Power PM Enable(10): %E%d%N\n",
3984
PCIE_CAP_AUX_PM_ENABLE (PcieDeviceControl)
3987
L" Enable No Snoop(11): %E%d%N\n",
3988
PCIE_CAP_NO_SNOOP_ENABLE (PcieDeviceControl)
3990
Print (L" Max_Read_Request_Size(14:12): ");
3991
if (PCIE_CAP_MAX_READ_REQ_SIZE (PcieDeviceControl) < 6) {
3992
Print (L"%E%d bytes%N\n", 1 << (PCIE_CAP_MAX_READ_REQ_SIZE (PcieDeviceControl) + 7));
3994
Print (L"%EUnknown%N\n");
3997
// Read operation is only valid for PCI Express to PCI/PCI-X Bridges
3999
if (PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg) == PCIE_PCIE_TO_PCIX_BRIDGE) {
4001
L" Bridge Configuration Retry Enable(15): %E%d%N\n",
4002
PCIE_CAP_BRG_CONF_RETRY (PcieDeviceControl)
4009
Print out information of the device status information.
4011
@param[in] PciExpressCap The pointer to the structure about the device.
4013
@retval EFI_SUCCESS The operation was successful.
4016
ExplainPcieDeviceStatus (
4017
IN PCIE_CAP_STURCTURE *PciExpressCap
4020
UINT16 PcieDeviceStatus;
4022
PcieDeviceStatus = PciExpressCap->DeviceStatus;
4024
L" Correctable Error Detected(0): %E%d%N\n",
4025
PCIE_CAP_COR_ERR_DETECTED (PcieDeviceStatus)
4028
L" Non-Fatal Error Detected(1): %E%d%N\n",
4029
PCIE_CAP_NONFAT_ERR_DETECTED (PcieDeviceStatus)
4032
L" Fatal Error Detected(2): %E%d%N\n",
4033
PCIE_CAP_FATAL_ERR_DETECTED (PcieDeviceStatus)
4036
L" Unsupported Request Detected(3): %E%d%N\n",
4037
PCIE_CAP_UNSUP_REQ_DETECTED (PcieDeviceStatus)
4040
L" AUX Power Detected(4): %E%d%N\n",
4041
PCIE_CAP_AUX_POWER_DETECTED (PcieDeviceStatus)
4044
L" Transactions Pending(5): %E%d%N\n",
4045
PCIE_CAP_TRANSACTION_PENDING (PcieDeviceStatus)
4051
Print out information of the device link information.
4053
@param[in] PciExpressCap The pointer to the structure about the device.
4055
@retval EFI_SUCCESS The operation was successful.
4058
ExplainPcieLinkCap (
4059
IN PCIE_CAP_STURCTURE *PciExpressCap
4063
CHAR16 *SupLinkSpeeds;
4066
PcieLinkCap = PciExpressCap->LinkCap;
4067
switch (PCIE_CAP_SUP_LINK_SPEEDS (PcieLinkCap)) {
4069
SupLinkSpeeds = L"2.5 GT/s";
4072
SupLinkSpeeds = L"5.0 GT/s and 2.5 GT/s";
4075
SupLinkSpeeds = L"Unknown";
4079
L" Supported Link Speeds(3:0): %E%s supported%N\n",
4083
L" Maximum Link Width(9:4): %Ex%d%N\n",
4084
PCIE_CAP_MAX_LINK_WIDTH (PcieLinkCap)
4086
switch (PCIE_CAP_ASPM_SUPPORT (PcieLinkCap)) {
4088
AspmValue = L"L0s Entry";
4091
AspmValue = L"L0s and L1";
4094
AspmValue = L"Reserved";
4098
L" Active State Power Management Support(11:10): %E%s Supported%N\n",
4102
L" L0s Exit Latency(14:12): %E%s%N\n",
4103
L0sLatencyStrTable[PCIE_CAP_L0S_LATENCY (PcieLinkCap)]
4106
L" L1 Exit Latency(17:15): %E%s%N\n",
4107
L1LatencyStrTable[PCIE_CAP_L0S_LATENCY (PcieLinkCap)]
4110
L" Clock Power Management(18): %E%d%N\n",
4111
PCIE_CAP_CLOCK_PM (PcieLinkCap)
4114
L" Surprise Down Error Reporting Capable(19): %E%d%N\n",
4115
PCIE_CAP_SUP_DOWN_ERR_REPORTING (PcieLinkCap)
4118
L" Data Link Layer Link Active Reporting Capable(20): %E%d%N\n",
4119
PCIE_CAP_LINK_ACTIVE_REPORTING (PcieLinkCap)
4122
L" Link Bandwidth Notification Capability(21): %E%d%N\n",
4123
PCIE_CAP_LINK_BWD_NOTIF_CAP (PcieLinkCap)
4126
L" Port Number(31:24): %E0x%02x%N\n",
4127
PCIE_CAP_PORT_NUMBER (PcieLinkCap)
4133
Print out information of the device link control information.
4135
@param[in] PciExpressCap The pointer to the structure about the device.
4137
@retval EFI_SUCCESS The operation was successful.
4140
ExplainPcieLinkControl (
4141
IN PCIE_CAP_STURCTURE *PciExpressCap
4144
UINT16 PcieLinkControl;
4145
UINT8 DevicePortType;
4147
PcieLinkControl = PciExpressCap->LinkControl;
4148
DevicePortType = (UINT8) PCIE_CAP_DEVICEPORT_TYPE (PciExpressCap->PcieCapReg);
4150
L" Active State Power Management Control(1:0): %E%s%N\n",
4151
ASPMCtrlStrTable[PCIE_CAP_ASPM_CONTROL (PcieLinkControl)]
4154
// RCB is not applicable to switches
4156
if (!IS_PCIE_SWITCH(DevicePortType)) {
4158
L" Read Completion Boundary (RCB)(3): %E%d byte%N\n",
4159
1 << (PCIE_CAP_RCB (PcieLinkControl) + 6)
4163
// Link Disable is reserved on
4165
// b) PCI Express to PCI/PCI-X bridges
4166
// c) Upstream Ports of Switches
4168
if (!IS_PCIE_ENDPOINT (DevicePortType) &&
4169
DevicePortType != PCIE_SWITCH_UPSTREAM_PORT &&
4170
DevicePortType != PCIE_PCIE_TO_PCIX_BRIDGE) {
4172
L" Link Disable(4): %E%d%N\n",
4173
PCIE_CAP_LINK_DISABLE (PcieLinkControl)
4177
L" Common Clock Configuration(6): %E%d%N\n",
4178
PCIE_CAP_COMMON_CLK_CONF (PcieLinkControl)
4181
L" Extended Synch(7): %E%d%N\n",
4182
PCIE_CAP_EXT_SYNC (PcieLinkControl)
4185
L" Enable Clock Power Management(8): %E%d%N\n",
4186
PCIE_CAP_CLK_PWR_MNG (PcieLinkControl)
4189
L" Hardware Autonomous Width Disable(9): %E%d%N\n",
4190
PCIE_CAP_HW_AUTO_WIDTH_DISABLE (PcieLinkControl)
4193
L" Link Bandwidth Management Interrupt Enable(10): %E%d%N\n",
4194
PCIE_CAP_LINK_BDW_MNG_INT_EN (PcieLinkControl)
4197
L" Link Autonomous Bandwidth Interrupt Enable(11): %E%d%N\n",
4198
PCIE_CAP_LINK_AUTO_BDW_INT_EN (PcieLinkControl)
4204
Print out information of the device link status information.
4206
@param[in] PciExpressCap The pointer to the structure about the device.
4208
@retval EFI_SUCCESS The operation was successful.
4211
ExplainPcieLinkStatus (
4212
IN PCIE_CAP_STURCTURE *PciExpressCap
4215
UINT16 PcieLinkStatus;
4216
CHAR16 *SupLinkSpeeds;
4218
PcieLinkStatus = PciExpressCap->LinkStatus;
4219
switch (PCIE_CAP_CUR_LINK_SPEED (PcieLinkStatus)) {
4221
SupLinkSpeeds = L"2.5 GT/s";
4224
SupLinkSpeeds = L"5.0 GT/s";
4227
SupLinkSpeeds = L"Reserved";
4231
L" Current Link Speed(3:0): %E%s%N\n",
4235
L" Negotiated Link Width(9:4): %Ex%d%N\n",
4236
PCIE_CAP_NEGO_LINK_WIDTH (PcieLinkStatus)
4239
L" Link Training(11): %E%d%N\n",
4240
PCIE_CAP_LINK_TRAINING (PcieLinkStatus)
4243
L" Slot Clock Configuration(12): %E%d%N\n",
4244
PCIE_CAP_SLOT_CLK_CONF (PcieLinkStatus)
4247
L" Data Link Layer Link Active(13): %E%d%N\n",
4248
PCIE_CAP_DATA_LINK_ACTIVE (PcieLinkStatus)
4251
L" Link Bandwidth Management Status(14): %E%d%N\n",
4252
PCIE_CAP_LINK_BDW_MNG_STAT (PcieLinkStatus)
4255
L" Link Autonomous Bandwidth Status(15): %E%d%N\n",
4256
PCIE_CAP_LINK_AUTO_BDW_STAT (PcieLinkStatus)
4262
Print out information of the device slot information.
4264
@param[in] PciExpressCap The pointer to the structure about the device.
4266
@retval EFI_SUCCESS The operation was successful.
4269
ExplainPcieSlotCap (
4270
IN PCIE_CAP_STURCTURE *PciExpressCap
4275
PcieSlotCap = PciExpressCap->SlotCap;
4278
L" Attention Button Present(0): %E%d%N\n",
4279
PCIE_CAP_ATT_BUT_PRESENT (PcieSlotCap)
4282
L" Power Controller Present(1): %E%d%N\n",
4283
PCIE_CAP_PWR_CTRLLER_PRESENT (PcieSlotCap)
4286
L" MRL Sensor Present(2): %E%d%N\n",
4287
PCIE_CAP_MRL_SENSOR_PRESENT (PcieSlotCap)
4290
L" Attention Indicator Present(3): %E%d%N\n",
4291
PCIE_CAP_ATT_IND_PRESENT (PcieSlotCap)
4294
L" Power Indicator Present(4): %E%d%N\n",
4295
PCIE_CAP_PWD_IND_PRESENT (PcieSlotCap)
4298
L" Hot-Plug Surprise(5): %E%d%N\n",
4299
PCIE_CAP_HOTPLUG_SUPPRISE (PcieSlotCap)
4302
L" Hot-Plug Capable(6): %E%d%N\n",
4303
PCIE_CAP_HOTPLUG_CAPABLE (PcieSlotCap)
4306
L" Slot Power Limit Value(14:7): %E0x%02x%N\n",
4307
PCIE_CAP_SLOT_PWR_LIMIT_VALUE (PcieSlotCap)
4310
L" Slot Power Limit Scale(16:15): %E%s%N\n",
4311
SlotPwrLmtScaleTable[PCIE_CAP_SLOT_PWR_LIMIT_SCALE (PcieSlotCap)]
4314
L" Electromechanical Interlock Present(17): %E%d%N\n",
4315
PCIE_CAP_ELEC_INTERLOCK_PRESENT (PcieSlotCap)
4318
L" No Command Completed Support(18): %E%d%N\n",
4319
PCIE_CAP_NO_COMM_COMPLETED_SUP (PcieSlotCap)
4322
L" Physical Slot Number(31:19): %E%d%N\n",
4323
PCIE_CAP_PHY_SLOT_NUM (PcieSlotCap)
4330
Print out information of the device slot control information.
4332
@param[in] PciExpressCap The pointer to the structure about the device.
4334
@retval EFI_SUCCESS The operation was successful.
4337
ExplainPcieSlotControl (
4338
IN PCIE_CAP_STURCTURE *PciExpressCap
4341
UINT16 PcieSlotControl;
4343
PcieSlotControl = PciExpressCap->SlotControl;
4345
L" Attention Button Pressed Enable(0): %E%d%N\n",
4346
PCIE_CAP_ATT_BUT_ENABLE (PcieSlotControl)
4349
L" Power Fault Detected Enable(1): %E%d%N\n",
4350
PCIE_CAP_PWR_FLT_DETECT_ENABLE (PcieSlotControl)
4353
L" MRL Sensor Changed Enable(2): %E%d%N\n",
4354
PCIE_CAP_MRL_SENSOR_CHANGE_ENABLE (PcieSlotControl)
4357
L" Presence Detect Changed Enable(3): %E%d%N\n",
4358
PCIE_CAP_PRES_DETECT_CHANGE_ENABLE (PcieSlotControl)
4361
L" Command Completed Interrupt Enable(4): %E%d%N\n",
4362
PCIE_CAP_COMM_CMPL_INT_ENABLE (PcieSlotControl)
4365
L" Hot-Plug Interrupt Enable(5): %E%d%N\n",
4366
PCIE_CAP_HOTPLUG_INT_ENABLE (PcieSlotControl)
4369
L" Attention Indicator Control(7:6): %E%s%N\n",
4370
IndicatorTable[PCIE_CAP_ATT_IND_CTRL (PcieSlotControl)]
4373
L" Power Indicator Control(9:8): %E%s%N\n",
4374
IndicatorTable[PCIE_CAP_PWR_IND_CTRL (PcieSlotControl)]
4376
Print (L" Power Controller Control(10): %EPower ");
4377
if (PCIE_CAP_PWR_CTRLLER_CTRL (PcieSlotControl)) {
4383
L" Electromechanical Interlock Control(11): %E%d%N\n",
4384
PCIE_CAP_ELEC_INTERLOCK_CTRL (PcieSlotControl)
4387
L" Data Link Layer State Changed Enable(12): %E%d%N\n",
4388
PCIE_CAP_DLINK_STAT_CHANGE_ENABLE (PcieSlotControl)
4394
Print out information of the device slot status information.
4396
@param[in] PciExpressCap The pointer to the structure about the device.
4398
@retval EFI_SUCCESS The operation was successful.
4401
ExplainPcieSlotStatus (
4402
IN PCIE_CAP_STURCTURE *PciExpressCap
4405
UINT16 PcieSlotStatus;
4407
PcieSlotStatus = PciExpressCap->SlotStatus;
4410
L" Attention Button Pressed(0): %E%d%N\n",
4411
PCIE_CAP_ATT_BUT_PRESSED (PcieSlotStatus)
4414
L" Power Fault Detected(1): %E%d%N\n",
4415
PCIE_CAP_PWR_FLT_DETECTED (PcieSlotStatus)
4418
L" MRL Sensor Changed(2): %E%d%N\n",
4419
PCIE_CAP_MRL_SENSOR_CHANGED (PcieSlotStatus)
4422
L" Presence Detect Changed(3): %E%d%N\n",
4423
PCIE_CAP_PRES_DETECT_CHANGED (PcieSlotStatus)
4426
L" Command Completed(4): %E%d%N\n",
4427
PCIE_CAP_COMM_COMPLETED (PcieSlotStatus)
4429
Print (L" MRL Sensor State(5): %EMRL ");
4430
if (PCIE_CAP_MRL_SENSOR_STATE (PcieSlotStatus)) {
4431
Print (L" Opened%N\n");
4433
Print (L" Closed%N\n");
4435
Print (L" Presence Detect State(6): ");
4436
if (PCIE_CAP_PRES_DETECT_STATE (PcieSlotStatus)) {
4437
Print (L"%ECard Present in slot%N\n");
4439
Print (L"%ESlot Empty%N\n");
4441
Print (L" Electromechanical Interlock Status(7): %EElectromechanical Interlock ");
4442
if (PCIE_CAP_ELEC_INTERLOCK_STATE (PcieSlotStatus)) {
4443
Print (L"Engaged%N\n");
4445
Print (L"Disengaged%N\n");
4448
L" Data Link Layer State Changed(8): %E%d%N\n",
4449
PCIE_CAP_DLINK_STAT_CHANGED (PcieSlotStatus)
4455
Print out information of the device root information.
4457
@param[in] PciExpressCap The pointer to the structure about the device.
4459
@retval EFI_SUCCESS The operation was successful.
4462
ExplainPcieRootControl (
4463
IN PCIE_CAP_STURCTURE *PciExpressCap
4466
UINT16 PcieRootControl;
4468
PcieRootControl = PciExpressCap->RootControl;
4471
L" System Error on Correctable Error Enable(0): %E%d%N\n",
4472
PCIE_CAP_SYSERR_ON_CORERR_EN (PcieRootControl)
4475
L" System Error on Non-Fatal Error Enable(1): %E%d%N\n",
4476
PCIE_CAP_SYSERR_ON_NONFATERR_EN (PcieRootControl)
4479
L" System Error on Fatal Error Enable(2): %E%d%N\n",
4480
PCIE_CAP_SYSERR_ON_FATERR_EN (PcieRootControl)
4483
L" PME Interrupt Enable(3): %E%d%N\n",
4484
PCIE_CAP_PME_INT_ENABLE (PcieRootControl)
4487
L" CRS Software Visibility Enable(4): %E%d%N\n",
4488
PCIE_CAP_CRS_SW_VIS_ENABLE (PcieRootControl)
4495
Print out information of the device root capability information.
4497
@param[in] PciExpressCap The pointer to the structure about the device.
4499
@retval EFI_SUCCESS The operation was successful.
4502
ExplainPcieRootCap (
4503
IN PCIE_CAP_STURCTURE *PciExpressCap
4508
PcieRootCap = PciExpressCap->RsvdP;
4511
L" CRS Software Visibility(0): %E%d%N\n",
4512
PCIE_CAP_CRS_SW_VIS (PcieRootCap)
4519
Print out information of the device root status information.
4521
@param[in] PciExpressCap The pointer to the structure about the device.
4523
@retval EFI_SUCCESS The operation was successful.
4526
ExplainPcieRootStatus (
4527
IN PCIE_CAP_STURCTURE *PciExpressCap
4530
UINT32 PcieRootStatus;
4532
PcieRootStatus = PciExpressCap->RootStatus;
4535
L" PME Requester ID(15:0): %E0x%04x%N\n",
4536
PCIE_CAP_PME_REQ_ID (PcieRootStatus)
4539
L" PME Status(16): %E%d%N\n",
4540
PCIE_CAP_PME_STATUS (PcieRootStatus)
4543
L" PME Pending(17): %E%d%N\n",
4544
PCIE_CAP_PME_PENDING (PcieRootStatus)
4550
Display Pcie device structure.
4552
@param[in] IoDev The pointer to the root pci protocol.
4553
@param[in] Address The Address to start at.
4554
@param[in] CapabilityPtr The offset from the address to start.
4557
PciExplainPciExpress (
4558
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev,
4560
IN UINT8 CapabilityPtr
4564
PCIE_CAP_STURCTURE PciExpressCap;
4566
UINT64 CapRegAddress;
4571
UINTN ExtendRegSize;
4572
UINT64 Pciex_Address;
4573
UINT8 DevicePortType;
4578
CapRegAddress = Address + CapabilityPtr;
4583
sizeof (PciExpressCap) / sizeof (UINT32),
4587
DevicePortType = (UINT8) PCIE_CAP_DEVICEPORT_TYPE (PciExpressCap.PcieCapReg);
4589
Print (L"\nPci Express device capability structure:\n");
4591
for (Index = 0; PcieExplainList[Index].Type < PcieExplainTypeMax; Index++) {
4592
if (ShellGetExecutionBreakFlag()) {
4595
RegAddr = ((UINT8 *) &PciExpressCap) + PcieExplainList[Index].Offset;
4596
switch (PcieExplainList[Index].Width) {
4597
case FieldWidthUINT8:
4598
RegValue = *(UINT8 *) RegAddr;
4600
case FieldWidthUINT16:
4601
RegValue = *(UINT16 *) RegAddr;
4603
case FieldWidthUINT32:
4604
RegValue = *(UINT32 *) RegAddr;
4610
ShellPrintHiiEx(-1, -1, NULL,
4611
PcieExplainList[Index].Token,
4612
gShellDebug1HiiHandle,
4613
PcieExplainList[Index].Offset,
4616
if (PcieExplainList[Index].Func == NULL) {
4619
switch (PcieExplainList[Index].Type) {
4620
case PcieExplainTypeLink:
4622
// Link registers should not be used by
4623
// a) Root Complex Integrated Endpoint
4624
// b) Root Complex Event Collector
4626
if (DevicePortType == PCIE_ROOT_COMPLEX_INTEGRATED_PORT ||
4627
DevicePortType == PCIE_ROOT_COMPLEX_EVENT_COLLECTOR) {
4631
case PcieExplainTypeSlot:
4633
// Slot registers are only valid for
4634
// a) Root Port of PCI Express Root Complex
4635
// b) Downstream Port of PCI Express Switch
4636
// and when SlotImplemented bit is set in PCIE cap register.
4638
if ((DevicePortType != PCIE_ROOT_COMPLEX_ROOT_PORT &&
4639
DevicePortType != PCIE_SWITCH_DOWNSTREAM_PORT) ||
4640
!PCIE_CAP_SLOT_IMPLEMENTED (PciExpressCap.PcieCapReg)) {
4644
case PcieExplainTypeRoot:
4646
// Root registers are only valid for
4647
// Root Port of PCI Express Root Complex
4649
if (DevicePortType != PCIE_ROOT_COMPLEX_ROOT_PORT) {
4656
PcieExplainList[Index].Func (&PciExpressCap);
4659
Bus = (UINT8) (RShiftU64 (Address, 24));
4660
Dev = (UINT8) (RShiftU64 (Address, 16));
4661
Func = (UINT8) (RShiftU64 (Address, 8));
4663
Pciex_Address = CALC_EFI_PCIEX_ADDRESS (Bus, Dev, Func, 0x100);
4665
ExtendRegSize = 0x1000 - 0x100;
4667
ExRegBuffer = (UINT8 *) AllocateZeroPool (ExtendRegSize);
4670
// PciRootBridgeIo protocol should support pci express extend space IO
4671
// (Begins at offset 0x100)
4673
Status = IoDev->Pci.Read (
4677
(ExtendRegSize) / sizeof (UINT32),
4678
(VOID *) (ExRegBuffer)
4680
if (EFI_ERROR (Status)) {
4681
FreePool ((VOID *) ExRegBuffer);
4682
return EFI_UNSUPPORTED;
4685
// Start outputing PciEx extend space( 0xFF-0xFFF)
4687
Print (L"\n%HStart dumping PCIex extended configuration space (0x100 - 0xFFF).%N\n\n");
4689
if (ExRegBuffer != NULL) {
4694
(VOID *) (ExRegBuffer)
4697
FreePool ((VOID *) ExRegBuffer);