2 Main file for Pci shell Debug1 function.
4 Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
5 Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "UefiShellDebug1CommandsLib.h"
17 #include <Protocol/PciRootBridgeIo.h>
18 #include <Library/ShellLib.h>
19 #include <IndustryStandard/Pci.h>
20 #include <IndustryStandard/Acpi.h>
23 #define PCI_CLASS_STRING_LIMIT 54
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 PCIPIFClass_0101
[];
67 PCI_CLASS_ENTRY PCIPIFClass_0300
[];
68 PCI_CLASS_ENTRY PCIPIFClass_0604
[];
69 PCI_CLASS_ENTRY PCIPIFClass_0700
[];
70 PCI_CLASS_ENTRY PCIPIFClass_0701
[];
71 PCI_CLASS_ENTRY PCIPIFClass_0703
[];
72 PCI_CLASS_ENTRY PCIPIFClass_0800
[];
73 PCI_CLASS_ENTRY PCIPIFClass_0801
[];
74 PCI_CLASS_ENTRY PCIPIFClass_0802
[];
75 PCI_CLASS_ENTRY PCIPIFClass_0803
[];
76 PCI_CLASS_ENTRY PCIPIFClass_0904
[];
77 PCI_CLASS_ENTRY PCIPIFClass_0c00
[];
78 PCI_CLASS_ENTRY PCIPIFClass_0c03
[];
79 PCI_CLASS_ENTRY PCIPIFClass_0e00
[];
82 // Base class strings entries
84 PCI_CLASS_ENTRY gClassStringList
[] = {
92 L
"Mass Storage Controller",
97 L
"Network Controller",
102 L
"Display Controller",
107 L
"Multimedia Device",
112 L
"Memory Controller",
122 L
"Simple Communications Controllers",
127 L
"Base System Peripherals",
147 L
"Serial Bus Controllers",
152 L
"Wireless Controllers",
157 L
"Intelligent IO Controllers",
162 L
"Satellite Communications Controllers",
167 L
"Encryption/Decryption Controllers",
172 L
"Data Acquisition & Signal Processing Controllers",
177 L
"Device does not fit in any defined classes",
183 /* null string ends the list */NULL
188 // Subclass strings entries
190 PCI_CLASS_ENTRY PCIBlankEntry
[] = {
199 /* null string ends the list */NULL
203 PCI_CLASS_ENTRY PCISubClass_00
[] = {
206 L
"All devices other than VGA",
211 L
"VGA-compatible devices",
217 /* null string ends the list */NULL
221 PCI_CLASS_ENTRY PCISubClass_01
[] = {
234 L
"Floppy disk controller",
249 L
"Other mass storage controller",
255 /* null string ends the list */NULL
259 PCI_CLASS_ENTRY PCISubClass_02
[] = {
262 L
"Ethernet controller",
267 L
"Token ring controller",
287 L
"Other network controller",
293 /* null string ends the list */NULL
297 PCI_CLASS_ENTRY PCISubClass_03
[] = {
300 L
"VGA/8514 controller",
315 L
"Other display controller",
321 /* null string ends the list */PCIBlankEntry
325 PCI_CLASS_ENTRY PCISubClass_04
[] = {
338 L
"Computer Telephony device",
343 L
"Other multimedia device",
349 /* null string ends the list */NULL
353 PCI_CLASS_ENTRY PCISubClass_05
[] = {
356 L
"RAM memory controller",
361 L
"Flash memory controller",
366 L
"Other memory controller",
372 /* null string ends the list */NULL
376 PCI_CLASS_ENTRY PCISubClass_06
[] = {
394 L
"PCI/Micro Channel bridge",
404 L
"PCI/PCMCIA bridge",
424 L
"Other bridge type",
430 /* null string ends the list */NULL
434 PCI_CLASS_ENTRY PCISubClass_07
[] = {
437 L
"Serial controller",
447 L
"Multiport serial controller",
457 L
"Other communication device",
463 /* null string ends the list */NULL
467 PCI_CLASS_ENTRY PCISubClass_08
[] = {
490 L
"Generic PCI Hot-Plug controller",
495 L
"Other system peripheral",
501 /* null string ends the list */NULL
505 PCI_CLASS_ENTRY PCISubClass_09
[] = {
508 L
"Keyboard controller",
523 L
"Scanner controller",
528 L
"Gameport controller",
533 L
"Other input controller",
539 /* null string ends the list */NULL
543 PCI_CLASS_ENTRY PCISubClass_0a
[] = {
546 L
"Generic docking station",
551 L
"Other type of docking station",
557 /* null string ends the list */NULL
561 PCI_CLASS_ENTRY PCISubClass_0b
[] = {
605 /* null string ends the list */NULL
609 PCI_CLASS_ENTRY PCISubClass_0c
[] = {
612 L
"Firewire(IEEE 1394)",
637 L
"System Management Bus",
648 /* null string ends the list */NULL
652 PCI_CLASS_ENTRY PCISubClass_0d
[] = {
655 L
"iRDA compatible controller",
660 L
"Consumer IR controller",
670 L
"Other type of wireless controller",
676 /* null string ends the list */NULL
680 PCI_CLASS_ENTRY PCISubClass_0e
[] = {
689 /* null string ends the list */NULL
693 PCI_CLASS_ENTRY PCISubClass_0f
[] = {
717 /* null string ends the list */NULL
721 PCI_CLASS_ENTRY PCISubClass_10
[] = {
724 L
"Network & computing Encrypt/Decrypt",
729 L
"Entertainment Encrypt/Decrypt",
734 L
"Other Encrypt/Decrypt",
740 /* null string ends the list */NULL
744 PCI_CLASS_ENTRY PCISubClass_11
[] = {
752 L
"Other DAQ & SP controllers",
758 /* null string ends the list */NULL
763 // Programming Interface entries
765 PCI_CLASS_ENTRY PCIPIFClass_0101
[] = {
793 L
"OM-primary, OM-secondary",
798 L
"PI-primary, OM-secondary",
803 L
"OM/PI-primary, OM-secondary",
813 L
"OM-primary, PI-secondary",
818 L
"PI-primary, PI-secondary",
823 L
"OM/PI-primary, PI-secondary",
833 L
"OM-primary, OM/PI-secondary",
838 L
"PI-primary, OM/PI-secondary",
843 L
"OM/PI-primary, OM/PI-secondary",
853 L
"Master, OM-primary",
858 L
"Master, PI-primary",
863 L
"Master, OM/PI-primary",
868 L
"Master, OM-secondary",
873 L
"Master, OM-primary, OM-secondary",
878 L
"Master, PI-primary, OM-secondary",
883 L
"Master, OM/PI-primary, OM-secondary",
888 L
"Master, OM-secondary",
893 L
"Master, OM-primary, PI-secondary",
898 L
"Master, PI-primary, PI-secondary",
903 L
"Master, OM/PI-primary, PI-secondary",
908 L
"Master, OM-secondary",
913 L
"Master, OM-primary, OM/PI-secondary",
918 L
"Master, PI-primary, OM/PI-secondary",
923 L
"Master, OM/PI-primary, OM/PI-secondary",
929 /* null string ends the list */NULL
933 PCI_CLASS_ENTRY PCIPIFClass_0300
[] = {
947 /* null string ends the list */NULL
951 PCI_CLASS_ENTRY PCIPIFClass_0604
[] = {
959 L
"Subtractive decode",
965 /* null string ends the list */NULL
969 PCI_CLASS_ENTRY PCIPIFClass_0700
[] = {
972 L
"Generic XT-compatible",
1002 L
"16950-compatible",
1008 /* null string ends the list */NULL
1012 PCI_CLASS_ENTRY PCIPIFClass_0701
[] = {
1025 L
"ECP 1.X-compliant",
1035 L
"IEEE 1284 target (not a controller)",
1041 /* null string ends the list */NULL
1045 PCI_CLASS_ENTRY PCIPIFClass_0703
[] = {
1053 L
"Hayes-compatible 16450",
1058 L
"Hayes-compatible 16550",
1063 L
"Hayes-compatible 16650",
1068 L
"Hayes-compatible 16750",
1074 /* null string ends the list */NULL
1078 PCI_CLASS_ENTRY PCIPIFClass_0800
[] = {
1101 L
"IO(x) APIC interrupt controller",
1107 /* null string ends the list */NULL
1111 PCI_CLASS_ENTRY PCIPIFClass_0801
[] = {
1130 /* null string ends the list */NULL
1134 PCI_CLASS_ENTRY PCIPIFClass_0802
[] = {
1153 /* null string ends the list */NULL
1157 PCI_CLASS_ENTRY PCIPIFClass_0803
[] = {
1176 /* null string ends the list */NULL
1180 PCI_CLASS_ENTRY PCIPIFClass_0904
[] = {
1194 /* null string ends the list */NULL
1198 PCI_CLASS_ENTRY PCIPIFClass_0c00
[] = {
1201 L
"Universal Host Controller spec",
1206 L
"Open Host Controller spec",
1211 L
"No specific programming interface",
1216 L
"(Not Host Controller)",
1222 /* null string ends the list */NULL
1226 PCI_CLASS_ENTRY PCIPIFClass_0c03
[] = {
1234 L
"Using 1394 OpenHCI spec",
1240 /* null string ends the list */NULL
1244 PCI_CLASS_ENTRY PCIPIFClass_0e00
[] = {
1247 L
"Message FIFO at offset 40h",
1258 /* null string ends the list */NULL
1264 Generates printable Unicode strings that represent PCI device class,
1265 subclass and programmed I/F based on a value passed to the function.
1267 @param[in] ClassCode Value representing the PCI "Class Code" register read from a
1268 PCI device. The encodings are:
1269 bits 23:16 - Base Class Code
1270 bits 15:8 - Sub-Class Code
1271 bits 7:0 - Programming Interface
1272 @param[in, out] ClassStrings Pointer of PCI_CLASS_STRINGS structure, which contains
1273 printable class strings corresponding to ClassCode. The
1274 caller must not modify the strings that are pointed by
1275 the fields in ClassStrings.
1278 PciGetClassStrings (
1279 IN UINT32 ClassCode
,
1280 IN OUT PCI_CLASS_STRINGS
*ClassStrings
1285 PCI_CLASS_ENTRY
*CurrentClass
;
1288 // Assume no strings found
1290 ClassStrings
->BaseClass
= L
"UNDEFINED";
1291 ClassStrings
->SubClass
= L
"UNDEFINED";
1292 ClassStrings
->PIFClass
= L
"UNDEFINED";
1294 CurrentClass
= gClassStringList
;
1295 Code
= (UINT8
) (ClassCode
>> 16);
1299 // Go through all entries of the base class, until the entry with a matching
1300 // base class code is found. If reaches an entry with a null description
1301 // text, the last entry is met, which means no text for the base class was
1302 // found, so no more action is needed.
1304 while (Code
!= CurrentClass
[Index
].Code
) {
1305 if (NULL
== CurrentClass
[Index
].DescText
) {
1312 // A base class was found. Assign description, and check if this class has
1313 // sub-class defined. If sub-class defined, no more action is needed,
1314 // otherwise, continue to find description for the sub-class code.
1316 ClassStrings
->BaseClass
= CurrentClass
[Index
].DescText
;
1317 if (NULL
== CurrentClass
[Index
].LowerLevelClass
) {
1321 // find Subclass entry
1323 CurrentClass
= CurrentClass
[Index
].LowerLevelClass
;
1324 Code
= (UINT8
) (ClassCode
>> 8);
1328 // Go through all entries of the sub-class, until the entry with a matching
1329 // sub-class code is found. If reaches an entry with a null description
1330 // text, the last entry is met, which means no text for the sub-class was
1331 // found, so no more action is needed.
1333 while (Code
!= CurrentClass
[Index
].Code
) {
1334 if (NULL
== CurrentClass
[Index
].DescText
) {
1341 // A class was found for the sub-class code. Assign description, and check if
1342 // this sub-class has programming interface defined. If no, no more action is
1343 // needed, otherwise, continue to find description for the programming
1346 ClassStrings
->SubClass
= CurrentClass
[Index
].DescText
;
1347 if (NULL
== CurrentClass
[Index
].LowerLevelClass
) {
1351 // Find programming interface entry
1353 CurrentClass
= CurrentClass
[Index
].LowerLevelClass
;
1354 Code
= (UINT8
) ClassCode
;
1358 // Go through all entries of the I/F entries, until the entry with a
1359 // matching I/F code is found. If reaches an entry with a null description
1360 // text, the last entry is met, which means no text was found, so no more
1361 // action is needed.
1363 while (Code
!= CurrentClass
[Index
].Code
) {
1364 if (NULL
== CurrentClass
[Index
].DescText
) {
1371 // A class was found for the I/F code. Assign description, done!
1373 ClassStrings
->PIFClass
= CurrentClass
[Index
].DescText
;
1378 Print strings that represent PCI device class, subclass and programmed I/F.
1380 @param[in] ClassCodePtr Points to the memory which stores register Class Code in PCI
1382 @param[in] IncludePIF If the printed string should include the programming I/F part
1386 IN UINT8
*ClassCodePtr
,
1387 IN BOOLEAN IncludePIF
1391 PCI_CLASS_STRINGS ClassStrings
;
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 // Print base class, sub class, and programming inferface name
1407 ShellPrintEx (-1, -1, L
"%s - %s - %s",
1408 ClassStrings
.BaseClass
,
1409 ClassStrings
.SubClass
,
1410 ClassStrings
.PIFClass
1415 // Only print base class and sub class name
1417 ShellPrintEx (-1, -1, L
"%s - %s",
1418 ClassStrings
.BaseClass
,
1419 ClassStrings
.SubClass
1425 This function finds out the protocol which is in charge of the given
1426 segment, and its bus range covers the current bus number. It lookes
1427 each instances of RootBridgeIoProtocol handle, until the one meets the
1430 @param[in] HandleBuf Buffer which holds all PCI_ROOT_BRIDIGE_IO_PROTOCOL handles.
1431 @param[in] HandleCount Count of all PCI_ROOT_BRIDIGE_IO_PROTOCOL handles.
1432 @param[in] Segment Segment number of device we are dealing with.
1433 @param[in] Bus Bus number of device we are dealing with.
1434 @param[out] IoDev Handle used to access configuration space of PCI device.
1436 @retval EFI_SUCCESS The command completed successfully.
1437 @retval EFI_INVALID_PARAMETER Invalid parameter.
1441 PciFindProtocolInterface (
1442 IN EFI_HANDLE
*HandleBuf
,
1443 IN UINTN HandleCount
,
1446 OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
**IoDev
1450 This function gets the protocol interface from the given handle, and
1451 obtains its address space descriptors.
1453 @param[in] Handle The PCI_ROOT_BRIDIGE_IO_PROTOCOL handle.
1454 @param[out] IoDev Handle used to access configuration space of PCI device.
1455 @param[out] Descriptors Points to the address space descriptors.
1457 @retval EFI_SUCCESS The command completed successfully
1460 PciGetProtocolAndResource (
1461 IN EFI_HANDLE Handle
,
1462 OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
**IoDev
,
1463 OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
**Descriptors
1467 This function get the next bus range of given address space descriptors.
1468 It also moves the pointer backward a node, to get prepared to be called
1471 @param[in, out] Descriptors Points to current position of a serial of address space
1473 @param[out] MinBus The lower range of bus number.
1474 @param[out] MaxBus The upper range of bus number.
1475 @param[out] IsEnd Meet end of the serial of descriptors.
1477 @retval EFI_SUCCESS The command completed successfully.
1480 PciGetNextBusRange (
1481 IN OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
**Descriptors
,
1488 Explain the data in PCI configuration space. The part which is common for
1489 PCI device and bridge is interpreted in this function. It calls other
1490 functions to interpret data unique for device or bridge.
1492 @param[in] ConfigSpace Data in PCI configuration space.
1493 @param[in] Address Address used to access configuration space of this PCI device.
1494 @param[in] IoDev Handle used to access configuration space of PCI device.
1495 @param[in] EnhancedDump The print format for the dump data.
1497 @retval EFI_SUCCESS The command completed successfully.
1501 IN PCI_CONFIG_SPACE
*ConfigSpace
,
1503 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
,
1504 IN CONST UINT16 EnhancedDump
1508 Explain the device specific part of data in PCI configuration space.
1510 @param[in] Device Data in PCI configuration space.
1511 @param[in] Address Address used to access configuration space of this PCI device.
1512 @param[in] IoDev Handle used to access configuration space of PCI device.
1514 @retval EFI_SUCCESS The command completed successfully.
1517 PciExplainDeviceData (
1518 IN PCI_DEVICE_HEADER
*Device
,
1520 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
1524 Explain the bridge specific part of data in PCI configuration space.
1526 @param[in] Bridge Bridge specific data region in PCI configuration space.
1527 @param[in] Address Address used to access configuration space of this PCI device.
1528 @param[in] IoDev Handle used to access configuration space of PCI device.
1530 @retval EFI_SUCCESS The command completed successfully.
1533 PciExplainBridgeData (
1534 IN PCI_BRIDGE_HEADER
*Bridge
,
1536 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
1540 Explain the Base Address Register(Bar) in PCI configuration space.
1542 @param[in] Bar Points to the Base Address Register intended to interpret.
1543 @param[in] Command Points to the register Command.
1544 @param[in] Address Address used to access configuration space of this PCI device.
1545 @param[in] IoDev Handle used to access configuration space of PCI device.
1546 @param[in, out] Index The Index.
1548 @retval EFI_SUCCESS The command completed successfully.
1555 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
,
1560 Explain the cardbus specific part of data in PCI configuration space.
1562 @param[in] CardBus CardBus specific region of PCI configuration space.
1563 @param[in] Address Address used to access configuration space of this PCI device.
1564 @param[in] IoDev Handle used to access configuration space of PCI device.
1566 @retval EFI_SUCCESS The command completed successfully.
1569 PciExplainCardBusData (
1570 IN PCI_CARDBUS_HEADER
*CardBus
,
1572 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
1576 Explain each meaningful bit of register Status. The definition of Status is
1577 slightly different depending on the PCI header type.
1579 @param[in] Status Points to the content of register Status.
1580 @param[in] MainStatus Indicates if this register is main status(not secondary
1582 @param[in] HeaderType Header type of this PCI device.
1584 @retval EFI_SUCCESS The command completed successfully.
1589 IN BOOLEAN MainStatus
,
1590 IN PCI_HEADER_TYPE HeaderType
1594 Explain each meaningful bit of register Command.
1596 @param[in] Command Points to the content of register Command.
1598 @retval EFI_SUCCESS The command completed successfully.
1606 Explain each meaningful bit of register Bridge Control.
1608 @param[in] BridgeControl Points to the content of register Bridge Control.
1609 @param[in] HeaderType The headertype.
1611 @retval EFI_SUCCESS The command completed successfully.
1614 PciExplainBridgeControl (
1615 IN UINT16
*BridgeControl
,
1616 IN PCI_HEADER_TYPE HeaderType
1620 Print each capability structure.
1622 @param[in] IoDev The pointer to the deivce.
1623 @param[in] Address The address to start at.
1624 @param[in] CapPtr The offset from the address.
1625 @param[in] EnhancedDump The print format for the dump data.
1627 @retval EFI_SUCCESS The operation was successful.
1630 PciExplainCapabilityStruct (
1631 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
,
1634 IN CONST UINT16 EnhancedDump
1638 Display Pcie device structure.
1640 @param[in] IoDev The pointer to the root pci protocol.
1641 @param[in] Address The Address to start at.
1642 @param[in] CapabilityPtr The offset from the address to start.
1643 @param[in] EnhancedDump The print format for the dump data.
1645 @retval EFI_SUCCESS The command completed successfully.
1646 @retval @retval EFI_SUCCESS Pci express extend space IO is not suppoted.
1649 PciExplainPciExpress (
1650 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
,
1652 IN UINT8 CapabilityPtr
,
1653 IN CONST UINT16 EnhancedDump
1657 Print out information of the capability information.
1659 @param[in] PciExpressCap The pointer to the structure about the device.
1661 @retval EFI_SUCCESS The operation was successful.
1665 IN PCIE_CAP_STURCTURE
*PciExpressCap
1669 Print out information of the device capability information.
1671 @param[in] PciExpressCap The pointer to the structure about the device.
1673 @retval EFI_SUCCESS The operation was successful.
1676 ExplainPcieDeviceCap (
1677 IN PCIE_CAP_STURCTURE
*PciExpressCap
1681 Print out information of the device control information.
1683 @param[in] PciExpressCap The pointer to the structure about the device.
1685 @retval EFI_SUCCESS The operation was successful.
1688 ExplainPcieDeviceControl (
1689 IN PCIE_CAP_STURCTURE
*PciExpressCap
1693 Print out information of the device status information.
1695 @param[in] PciExpressCap The pointer to the structure about the device.
1697 @retval EFI_SUCCESS The operation was successful.
1700 ExplainPcieDeviceStatus (
1701 IN PCIE_CAP_STURCTURE
*PciExpressCap
1705 Print out information of the device link information.
1707 @param[in] PciExpressCap The pointer to the structure about the device.
1709 @retval EFI_SUCCESS The operation was successful.
1712 ExplainPcieLinkCap (
1713 IN PCIE_CAP_STURCTURE
*PciExpressCap
1717 Print out information of the device link control information.
1719 @param[in] PciExpressCap The pointer to the structure about the device.
1721 @retval EFI_SUCCESS The operation was successful.
1724 ExplainPcieLinkControl (
1725 IN PCIE_CAP_STURCTURE
*PciExpressCap
1729 Print out information of the device link status information.
1731 @param[in] PciExpressCap The pointer to the structure about the device.
1733 @retval EFI_SUCCESS The operation was successful.
1736 ExplainPcieLinkStatus (
1737 IN PCIE_CAP_STURCTURE
*PciExpressCap
1741 Print out information of the device slot information.
1743 @param[in] PciExpressCap The pointer to the structure about the device.
1745 @retval EFI_SUCCESS The operation was successful.
1748 ExplainPcieSlotCap (
1749 IN PCIE_CAP_STURCTURE
*PciExpressCap
1753 Print out information of the device slot control information.
1755 @param[in] PciExpressCap The pointer to the structure about the device.
1757 @retval EFI_SUCCESS The operation was successful.
1760 ExplainPcieSlotControl (
1761 IN PCIE_CAP_STURCTURE
*PciExpressCap
1765 Print out information of the device slot status information.
1767 @param[in] PciExpressCap The pointer to the structure about the device.
1769 @retval EFI_SUCCESS The operation was successful.
1772 ExplainPcieSlotStatus (
1773 IN PCIE_CAP_STURCTURE
*PciExpressCap
1777 Print out information of the device root information.
1779 @param[in] PciExpressCap The pointer to the structure about the device.
1781 @retval EFI_SUCCESS The operation was successful.
1784 ExplainPcieRootControl (
1785 IN PCIE_CAP_STURCTURE
*PciExpressCap
1789 Print out information of the device root capability information.
1791 @param[in] PciExpressCap The pointer to the structure about the device.
1793 @retval EFI_SUCCESS The operation was successful.
1796 ExplainPcieRootCap (
1797 IN PCIE_CAP_STURCTURE
*PciExpressCap
1801 Print out information of the device root status information.
1803 @param[in] PciExpressCap The pointer to the structure about the device.
1805 @retval EFI_SUCCESS The operation was successful.
1808 ExplainPcieRootStatus (
1809 IN PCIE_CAP_STURCTURE
*PciExpressCap
1812 typedef EFI_STATUS (*PCIE_EXPLAIN_FUNCTION
) (IN PCIE_CAP_STURCTURE
*PciExpressCap
);
1818 } PCIE_CAPREG_FIELD_WIDTH
;
1821 PcieExplainTypeCommon
,
1822 PcieExplainTypeDevice
,
1823 PcieExplainTypeLink
,
1824 PcieExplainTypeSlot
,
1825 PcieExplainTypeRoot
,
1827 } PCIE_EXPLAIN_TYPE
;
1833 PCIE_CAPREG_FIELD_WIDTH Width
;
1834 PCIE_EXPLAIN_FUNCTION Func
;
1835 PCIE_EXPLAIN_TYPE Type
;
1836 } PCIE_EXPLAIN_STRUCT
;
1838 PCIE_EXPLAIN_STRUCT PcieExplainList
[] = {
1840 STRING_TOKEN (STR_PCIEX_CAPABILITY_CAPID
),
1844 PcieExplainTypeCommon
1847 STRING_TOKEN (STR_PCIEX_NEXTCAP_PTR
),
1851 PcieExplainTypeCommon
1854 STRING_TOKEN (STR_PCIEX_CAP_REGISTER
),
1858 PcieExplainTypeCommon
1861 STRING_TOKEN (STR_PCIEX_DEVICE_CAP
),
1864 ExplainPcieDeviceCap
,
1865 PcieExplainTypeDevice
1868 STRING_TOKEN (STR_PCIEX_DEVICE_CONTROL
),
1871 ExplainPcieDeviceControl
,
1872 PcieExplainTypeDevice
1875 STRING_TOKEN (STR_PCIEX_DEVICE_STATUS
),
1878 ExplainPcieDeviceStatus
,
1879 PcieExplainTypeDevice
1882 STRING_TOKEN (STR_PCIEX_LINK_CAPABILITIES
),
1889 STRING_TOKEN (STR_PCIEX_LINK_CONTROL
),
1892 ExplainPcieLinkControl
,
1896 STRING_TOKEN (STR_PCIEX_LINK_STATUS
),
1899 ExplainPcieLinkStatus
,
1903 STRING_TOKEN (STR_PCIEX_SLOT_CAPABILITIES
),
1910 STRING_TOKEN (STR_PCIEX_SLOT_CONTROL
),
1913 ExplainPcieSlotControl
,
1917 STRING_TOKEN (STR_PCIEX_SLOT_STATUS
),
1920 ExplainPcieSlotStatus
,
1924 STRING_TOKEN (STR_PCIEX_ROOT_CONTROL
),
1927 ExplainPcieRootControl
,
1931 STRING_TOKEN (STR_PCIEX_RSVDP
),
1938 STRING_TOKEN (STR_PCIEX_ROOT_STATUS
),
1941 ExplainPcieRootStatus
,
1947 (PCIE_CAPREG_FIELD_WIDTH
)0,
1956 PCI_CONFIG_SPACE
*mConfigSpace
= NULL
;
1957 STATIC CONST SHELL_PARAM_ITEM ParamList
[] = {
1963 CHAR16
*DevicePortTypeTable
[] = {
1964 L
"PCI Express Endpoint",
1965 L
"Legacy PCI Express Endpoint",
1968 L
"Root Port of PCI Express Root Complex",
1969 L
"Upstream Port of PCI Express Switch",
1970 L
"Downstream Port of PCI Express Switch",
1971 L
"PCI Express to PCI/PCI-X Bridge",
1972 L
"PCI/PCI-X to PCI Express Bridge",
1973 L
"Root Complex Integrated Endpoint",
1974 L
"Root Complex Event Collector"
1977 CHAR16
*L0sLatencyStrTable
[] = {
1979 L
"64ns to less than 128ns",
1980 L
"128ns to less than 256ns",
1981 L
"256ns to less than 512ns",
1982 L
"512ns to less than 1us",
1983 L
"1us to less than 2us",
1988 CHAR16
*L1LatencyStrTable
[] = {
1990 L
"1us to less than 2us",
1991 L
"2us to less than 4us",
1992 L
"4us to less than 8us",
1993 L
"8us to less than 16us",
1994 L
"16us to less than 32us",
1999 CHAR16
*ASPMCtrlStrTable
[] = {
2001 L
"L0s Entry Enabled",
2002 L
"L1 Entry Enabled",
2003 L
"L0s and L1 Entry Enabled"
2006 CHAR16
*SlotPwrLmtScaleTable
[] = {
2013 CHAR16
*IndicatorTable
[] = {
2022 Function for 'pci' command.
2024 @param[in] ImageHandle Handle to the Image (NULL if Internal).
2025 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
2029 ShellCommandRunPci (
2030 IN EFI_HANDLE ImageHandle
,
2031 IN EFI_SYSTEM_TABLE
*SystemTable
2039 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
;
2041 PCI_COMMON_HEADER PciHeader
;
2042 PCI_CONFIG_SPACE ConfigSpace
;
2046 BOOLEAN ExplainData
;
2050 UINTN HandleBufSize
;
2051 EFI_HANDLE
*HandleBuf
;
2053 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*Descriptors
;
2057 LIST_ENTRY
*Package
;
2058 CHAR16
*ProblemParam
;
2059 SHELL_STATUS ShellStatus
;
2062 UINT16 EnhancedDump
;
2064 ShellStatus
= SHELL_SUCCESS
;
2065 Status
= EFI_SUCCESS
;
2072 // initialize the shell lib (we must be in non-auto-init...)
2074 Status
= ShellInitialize();
2075 ASSERT_EFI_ERROR(Status
);
2077 Status
= CommandInit();
2078 ASSERT_EFI_ERROR(Status
);
2081 // parse the command line
2083 Status
= ShellCommandLineParse (ParamList
, &Package
, &ProblemParam
, TRUE
);
2084 if (EFI_ERROR(Status
)) {
2085 if (Status
== EFI_VOLUME_CORRUPTED
&& ProblemParam
!= NULL
) {
2086 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellDebug1HiiHandle
, ProblemParam
);
2087 FreePool(ProblemParam
);
2088 ShellStatus
= SHELL_INVALID_PARAMETER
;
2094 if (ShellCommandLineGetCount(Package
) == 2) {
2095 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_FEW
), gShellDebug1HiiHandle
);
2096 ShellStatus
= SHELL_INVALID_PARAMETER
;
2100 if (ShellCommandLineGetCount(Package
) > 4) {
2101 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_MANY
), gShellDebug1HiiHandle
);
2102 ShellStatus
= SHELL_INVALID_PARAMETER
;
2105 if (ShellCommandLineGetFlag(Package
, L
"-s") && ShellCommandLineGetValue(Package
, L
"-s") == NULL
) {
2106 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_NO_VALUE
), gShellDebug1HiiHandle
, L
"-s");
2107 ShellStatus
= SHELL_INVALID_PARAMETER
;
2111 // Get all instances of PciRootBridgeIo. Allocate space for 1 EFI_HANDLE and
2112 // call LibLocateHandle(), if EFI_BUFFER_TOO_SMALL is returned, allocate enough
2113 // space for handles and call it again.
2115 HandleBufSize
= sizeof (EFI_HANDLE
);
2116 HandleBuf
= (EFI_HANDLE
*) AllocateZeroPool (HandleBufSize
);
2117 if (HandleBuf
== NULL
) {
2118 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_OUT_MEM
), gShellDebug1HiiHandle
);
2119 ShellStatus
= SHELL_OUT_OF_RESOURCES
;
2123 Status
= gBS
->LocateHandle (
2125 &gEfiPciRootBridgeIoProtocolGuid
,
2131 if (Status
== EFI_BUFFER_TOO_SMALL
) {
2132 HandleBuf
= ReallocatePool (sizeof (EFI_HANDLE
), HandleBufSize
, HandleBuf
);
2133 if (HandleBuf
== NULL
) {
2134 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_OUT_MEM
), gShellDebug1HiiHandle
);
2135 ShellStatus
= SHELL_OUT_OF_RESOURCES
;
2139 Status
= gBS
->LocateHandle (
2141 &gEfiPciRootBridgeIoProtocolGuid
,
2148 if (EFI_ERROR (Status
)) {
2149 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PCIRBIO_NF
), gShellDebug1HiiHandle
);
2150 ShellStatus
= SHELL_NOT_FOUND
;
2154 HandleCount
= HandleBufSize
/ sizeof (EFI_HANDLE
);
2156 // Argument Count == 1(no other argument): enumerate all pci functions
2158 if (ShellCommandLineGetCount(Package
) == 1) {
2159 gST
->ConOut
->QueryMode (
2161 gST
->ConOut
->Mode
->Mode
,
2168 if ((ScreenSize
& 1) == 1) {
2175 // For each handle, which decides a segment and a bus number range,
2176 // enumerate all devices on it.
2178 for (Index
= 0; Index
< HandleCount
; Index
++) {
2179 Status
= PciGetProtocolAndResource (
2184 if (EFI_ERROR (Status
)) {
2185 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_HANDLE_CFG_ERR
), gShellDebug1HiiHandle
, Status
);
2186 ShellStatus
= SHELL_NOT_FOUND
;
2190 // No document say it's impossible for a RootBridgeIo protocol handle
2191 // to have more than one address space descriptors, so find out every
2192 // bus range and for each of them do device enumeration.
2195 Status
= PciGetNextBusRange (&Descriptors
, &MinBus
, &MaxBus
, &IsEnd
);
2197 if (EFI_ERROR (Status
)) {
2198 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_BUS_RANGE_ERR
), gShellDebug1HiiHandle
, Status
);
2199 ShellStatus
= SHELL_NOT_FOUND
;
2207 for (Bus
= MinBus
; Bus
<= MaxBus
; Bus
++) {
2209 // For each devices, enumerate all functions it contains
2211 for (Device
= 0; Device
<= PCI_MAX_DEVICE
; Device
++) {
2213 // For each function, read its configuration space and print summary
2215 for (Func
= 0; Func
<= PCI_MAX_FUNC
; Func
++) {
2216 if (ShellGetExecutionBreakFlag ()) {
2217 ShellStatus
= SHELL_ABORTED
;
2220 Address
= CALC_EFI_PCI_ADDRESS (Bus
, Device
, Func
, 0);
2230 // If VendorId = 0xffff, there does not exist a device at this
2231 // location. For each device, if there is any function on it,
2232 // there must be 1 function at Function 0. So if Func = 0, there
2233 // will be no more functions in the same device, so we can break
2234 // loop to deal with the next device.
2236 if (PciHeader
.VendorId
== 0xffff && Func
== 0) {
2240 if (PciHeader
.VendorId
!= 0xffff) {
2243 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_TITLE
), gShellDebug1HiiHandle
);
2251 sizeof (PciHeader
) / sizeof (UINT32
),
2256 -1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_P1
), gShellDebug1HiiHandle
,
2257 IoDev
->SegmentNumber
,
2263 PciPrintClassCode (PciHeader
.ClassCode
, FALSE
);
2265 -1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_P2
), gShellDebug1HiiHandle
,
2268 PciHeader
.ClassCode
[0]
2272 if (ScreenCount
>= ScreenSize
&& ScreenSize
!= 0) {
2274 // If ScreenSize == 0 we have the console redirected so don't
2280 // If this is not a multi-function device, we can leave the loop
2281 // to deal with the next device.
2283 if (Func
== 0 && ((PciHeader
.HeaderType
& HEADER_TYPE_MULTI_FUNCTION
) == 0x00)) {
2291 // If Descriptor is NULL, Configuration() returns EFI_UNSUPPRORED,
2292 // we assume the bus range is 0~PCI_MAX_BUS. After enumerated all
2293 // devices on all bus, we can leave loop.
2295 if (Descriptors
== NULL
) {
2301 Status
= EFI_SUCCESS
;
2305 ExplainData
= FALSE
;
2310 if (ShellCommandLineGetFlag(Package
, L
"-i")) {
2314 Temp
= ShellCommandLineGetValue(Package
, L
"-s");
2317 // Input converted to hexadecimal number.
2319 if (!EFI_ERROR (ShellConvertStringToUint64 (Temp
, &RetVal
, TRUE
, TRUE
))) {
2320 Segment
= (UINT16
) RetVal
;
2322 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV_HEX
), gShellDebug1HiiHandle
);
2323 ShellStatus
= SHELL_INVALID_PARAMETER
;
2329 // The first Argument(except "-i") is assumed to be Bus number, second
2330 // to be Device number, and third to be Func number.
2332 Temp
= ShellCommandLineGetRawValue(Package
, 1);
2335 // Input converted to hexadecimal number.
2337 if (!EFI_ERROR (ShellConvertStringToUint64 (Temp
, &RetVal
, TRUE
, TRUE
))) {
2338 Bus
= (UINT16
) RetVal
;
2340 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV_HEX
), gShellDebug1HiiHandle
);
2341 ShellStatus
= SHELL_INVALID_PARAMETER
;
2345 if (Bus
> MAX_BUS_NUMBER
) {
2346 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellDebug1HiiHandle
, Temp
);
2347 ShellStatus
= SHELL_INVALID_PARAMETER
;
2351 Temp
= ShellCommandLineGetRawValue(Package
, 2);
2354 // Input converted to hexadecimal number.
2356 if (!EFI_ERROR (ShellConvertStringToUint64 (Temp
, &RetVal
, TRUE
, TRUE
))) {
2357 Device
= (UINT16
) RetVal
;
2359 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV_HEX
), gShellDebug1HiiHandle
);
2360 ShellStatus
= SHELL_INVALID_PARAMETER
;
2364 if (Device
> MAX_DEVICE_NUMBER
){
2365 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellDebug1HiiHandle
, Temp
);
2366 ShellStatus
= SHELL_INVALID_PARAMETER
;
2371 Temp
= ShellCommandLineGetRawValue(Package
, 3);
2374 // Input converted to hexadecimal number.
2376 if (!EFI_ERROR (ShellConvertStringToUint64 (Temp
, &RetVal
, TRUE
, TRUE
))) {
2377 Func
= (UINT16
) RetVal
;
2379 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV_HEX
), gShellDebug1HiiHandle
);
2380 ShellStatus
= SHELL_INVALID_PARAMETER
;
2384 if (Func
> MAX_FUNCTION_NUMBER
){
2385 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellDebug1HiiHandle
, Temp
);
2386 ShellStatus
= SHELL_INVALID_PARAMETER
;
2392 // Find the protocol interface who's in charge of current segment, and its
2393 // bus range covers the current bus
2395 Status
= PciFindProtocolInterface (
2403 if (EFI_ERROR (Status
)) {
2405 -1, -1, NULL
, STRING_TOKEN (STR_PCI_NO_FIND
), gShellDebug1HiiHandle
,
2409 ShellStatus
= SHELL_NOT_FOUND
;
2413 Address
= CALC_EFI_PCI_ADDRESS (Bus
, Device
, Func
, 0);
2414 Status
= IoDev
->Pci
.Read (
2418 sizeof (ConfigSpace
),
2422 if (EFI_ERROR (Status
)) {
2423 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_NO_CFG
), gShellDebug1HiiHandle
, Status
);
2424 ShellStatus
= SHELL_ACCESS_DENIED
;
2428 mConfigSpace
= &ConfigSpace
;
2433 STRING_TOKEN (STR_PCI_INFO
),
2434 gShellDebug1HiiHandle
,
2446 // Dump standard header of configuration space
2448 SizeOfHeader
= sizeof (ConfigSpace
.Common
) + sizeof (ConfigSpace
.NonCommon
);
2450 DumpHex (2, 0, SizeOfHeader
, &ConfigSpace
);
2451 ShellPrintEx(-1,-1, L
"\r\n");
2454 // Dump device dependent Part of configuration space
2459 sizeof (ConfigSpace
) - SizeOfHeader
,
2464 // If "-i" appears in command line, interpret data in configuration space
2468 if (ShellCommandLineGetFlag(Package
, L
"-_e")) {
2469 EnhancedDump
= 0xFFFF;
2470 Temp
= ShellCommandLineGetValue(Package
, L
"-_e");
2472 EnhancedDump
= (UINT16
) ShellHexStrToUintn (Temp
);
2475 Status
= PciExplainData (&ConfigSpace
, Address
, IoDev
, EnhancedDump
);
2479 if (HandleBuf
!= NULL
) {
2480 FreePool (HandleBuf
);
2482 if (Package
!= NULL
) {
2483 ShellCommandLineFreeVarList (Package
);
2485 mConfigSpace
= NULL
;
2490 This function finds out the protocol which is in charge of the given
2491 segment, and its bus range covers the current bus number. It lookes
2492 each instances of RootBridgeIoProtocol handle, until the one meets the
2495 @param[in] HandleBuf Buffer which holds all PCI_ROOT_BRIDIGE_IO_PROTOCOL handles.
2496 @param[in] HandleCount Count of all PCI_ROOT_BRIDIGE_IO_PROTOCOL handles.
2497 @param[in] Segment Segment number of device we are dealing with.
2498 @param[in] Bus Bus number of device we are dealing with.
2499 @param[out] IoDev Handle used to access configuration space of PCI device.
2501 @retval EFI_SUCCESS The command completed successfully.
2502 @retval EFI_INVALID_PARAMETER Invalid parameter.
2506 PciFindProtocolInterface (
2507 IN EFI_HANDLE
*HandleBuf
,
2508 IN UINTN HandleCount
,
2511 OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
**IoDev
2516 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*Descriptors
;
2522 // Go through all handles, until the one meets the criteria is found
2524 for (Index
= 0; Index
< HandleCount
; Index
++) {
2525 Status
= PciGetProtocolAndResource (HandleBuf
[Index
], IoDev
, &Descriptors
);
2526 if (EFI_ERROR (Status
)) {
2530 // When Descriptors == NULL, the Configuration() is not implemented,
2531 // so we only check the Segment number
2533 if (Descriptors
== NULL
&& Segment
== (*IoDev
)->SegmentNumber
) {
2537 if ((*IoDev
)->SegmentNumber
!= Segment
) {
2542 Status
= PciGetNextBusRange (&Descriptors
, &MinBus
, &MaxBus
, &IsEnd
);
2543 if (EFI_ERROR (Status
)) {
2551 if (MinBus
<= Bus
&& MaxBus
>= Bus
) {
2557 return EFI_NOT_FOUND
;
2561 This function gets the protocol interface from the given handle, and
2562 obtains its address space descriptors.
2564 @param[in] Handle The PCI_ROOT_BRIDIGE_IO_PROTOCOL handle.
2565 @param[out] IoDev Handle used to access configuration space of PCI device.
2566 @param[out] Descriptors Points to the address space descriptors.
2568 @retval EFI_SUCCESS The command completed successfully
2571 PciGetProtocolAndResource (
2572 IN EFI_HANDLE Handle
,
2573 OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
**IoDev
,
2574 OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
**Descriptors
2580 // Get inferface from protocol
2582 Status
= gBS
->HandleProtocol (
2584 &gEfiPciRootBridgeIoProtocolGuid
,
2588 if (EFI_ERROR (Status
)) {
2592 // Call Configuration() to get address space descriptors
2594 Status
= (*IoDev
)->Configuration (*IoDev
, (VOID
**)Descriptors
);
2595 if (Status
== EFI_UNSUPPORTED
) {
2596 *Descriptors
= NULL
;
2605 This function get the next bus range of given address space descriptors.
2606 It also moves the pointer backward a node, to get prepared to be called
2609 @param[in, out] Descriptors Points to current position of a serial of address space
2611 @param[out] MinBus The lower range of bus number.
2612 @param[out] MaxBus The upper range of bus number.
2613 @param[out] IsEnd Meet end of the serial of descriptors.
2615 @retval EFI_SUCCESS The command completed successfully.
2618 PciGetNextBusRange (
2619 IN OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
**Descriptors
,
2628 // When *Descriptors is NULL, Configuration() is not implemented, so assume
2629 // range is 0~PCI_MAX_BUS
2631 if ((*Descriptors
) == NULL
) {
2633 *MaxBus
= PCI_MAX_BUS
;
2637 // *Descriptors points to one or more address space descriptors, which
2638 // ends with a end tagged descriptor. Examine each of the descriptors,
2639 // if a bus typed one is found and its bus range covers bus, this handle
2640 // is the handle we are looking for.
2643 while ((*Descriptors
)->Desc
!= ACPI_END_TAG_DESCRIPTOR
) {
2644 if ((*Descriptors
)->ResType
== ACPI_ADDRESS_SPACE_TYPE_BUS
) {
2645 *MinBus
= (UINT16
) (*Descriptors
)->AddrRangeMin
;
2646 *MaxBus
= (UINT16
) (*Descriptors
)->AddrRangeMax
;
2648 return (EFI_SUCCESS
);
2654 if ((*Descriptors
)->Desc
== ACPI_END_TAG_DESCRIPTOR
) {
2662 Explain the data in PCI configuration space. The part which is common for
2663 PCI device and bridge is interpreted in this function. It calls other
2664 functions to interpret data unique for device or bridge.
2666 @param[in] ConfigSpace Data in PCI configuration space.
2667 @param[in] Address Address used to access configuration space of this PCI device.
2668 @param[in] IoDev Handle used to access configuration space of PCI device.
2669 @param[in] EnhancedDump The print format for the dump data.
2671 @retval EFI_SUCCESS The command completed successfully.
2675 IN PCI_CONFIG_SPACE
*ConfigSpace
,
2677 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
,
2678 IN CONST UINT16 EnhancedDump
2681 PCI_COMMON_HEADER
*Common
;
2682 PCI_HEADER_TYPE HeaderType
;
2686 Common
= &(ConfigSpace
->Common
);
2688 ShellPrintEx (-1, -1, L
"\r\n");
2691 // Print Vendor Id and Device Id
2693 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_VID_DID
), gShellDebug1HiiHandle
,
2694 INDEX_OF (&(Common
->VendorId
)),
2696 INDEX_OF (&(Common
->DeviceId
)),
2701 // Print register Command
2703 PciExplainCommand (&(Common
->Command
));
2706 // Print register Status
2708 PciExplainStatus (&(Common
->Status
), TRUE
, PciUndefined
);
2711 // Print register Revision ID
2713 ShellPrintEx(-1, -1, L
"\r\n");
2714 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_RID
), gShellDebug1HiiHandle
,
2715 INDEX_OF (&(Common
->RevisionId
)),
2720 // Print register BIST
2722 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_BIST
), gShellDebug1HiiHandle
, INDEX_OF (&(Common
->Bist
)));
2723 if ((Common
->Bist
& PCI_BIT_7
) != 0) {
2724 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_CAP
), gShellDebug1HiiHandle
, 0x0f & Common
->Bist
);
2726 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_PCI_LINE_CAP_NO
), gShellDebug1HiiHandle
);
2729 // Print register Cache Line Size
2731 ShellPrintHiiEx(-1, -1, NULL
,
2732 STRING_TOKEN (STR_PCI2_CACHE_LINE_SIZE
),
2733 gShellDebug1HiiHandle
,
2734 INDEX_OF (&(Common
->CacheLineSize
)),
2735 Common
->CacheLineSize
2739 // Print register Latency Timer
2741 ShellPrintHiiEx(-1, -1, NULL
,
2742 STRING_TOKEN (STR_PCI2_LATENCY_TIMER
),
2743 gShellDebug1HiiHandle
,
2744 INDEX_OF (&(Common
->PrimaryLatencyTimer
)),
2745 Common
->PrimaryLatencyTimer
2749 // Print register Header Type
2751 ShellPrintHiiEx(-1, -1, NULL
,
2752 STRING_TOKEN (STR_PCI2_HEADER_TYPE
),
2753 gShellDebug1HiiHandle
,
2754 INDEX_OF (&(Common
->HeaderType
)),
2758 if ((Common
->HeaderType
& PCI_BIT_7
) != 0) {
2759 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MULTI_FUNCTION
), gShellDebug1HiiHandle
);
2762 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_SINGLE_FUNCTION
), gShellDebug1HiiHandle
);
2765 HeaderType
= (PCI_HEADER_TYPE
)(UINT8
) (Common
->HeaderType
& 0x7f);
2766 switch (HeaderType
) {
2768 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_PCI_DEVICE
), gShellDebug1HiiHandle
);
2772 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_P2P_BRIDGE
), gShellDebug1HiiHandle
);
2775 case PciCardBusBridge
:
2776 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_CARDBUS_BRIDGE
), gShellDebug1HiiHandle
);
2780 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RESERVED
), gShellDebug1HiiHandle
);
2781 HeaderType
= PciUndefined
;
2785 // Print register Class Code
2787 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_CLASS
), gShellDebug1HiiHandle
);
2788 PciPrintClassCode ((UINT8
*) Common
->ClassCode
, TRUE
);
2789 ShellPrintEx (-1, -1, L
"\r\n");
2791 if (ShellGetExecutionBreakFlag()) {
2796 // Interpret remaining part of PCI configuration header depending on
2800 Status
= EFI_SUCCESS
;
2801 switch (HeaderType
) {
2803 Status
= PciExplainDeviceData (
2804 &(ConfigSpace
->NonCommon
.Device
),
2808 CapPtr
= ConfigSpace
->NonCommon
.Device
.CapabilitiesPtr
;
2812 Status
= PciExplainBridgeData (
2813 &(ConfigSpace
->NonCommon
.Bridge
),
2817 CapPtr
= ConfigSpace
->NonCommon
.Bridge
.CapabilitiesPtr
;
2820 case PciCardBusBridge
:
2821 Status
= PciExplainCardBusData (
2822 &(ConfigSpace
->NonCommon
.CardBus
),
2826 CapPtr
= ConfigSpace
->NonCommon
.CardBus
.CapabilitiesPtr
;
2833 // If Status bit4 is 1, dump or explain capability structure
2835 if ((Common
->Status
) & EFI_PCI_STATUS_CAPABILITY
) {
2836 PciExplainCapabilityStruct (IoDev
, Address
, CapPtr
, EnhancedDump
);
2843 Explain the device specific part of data in PCI configuration space.
2845 @param[in] Device Data in PCI configuration space.
2846 @param[in] Address Address used to access configuration space of this PCI device.
2847 @param[in] IoDev Handle used to access configuration space of PCI device.
2849 @retval EFI_SUCCESS The command completed successfully.
2852 PciExplainDeviceData (
2853 IN PCI_DEVICE_HEADER
*Device
,
2855 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
2864 // Print Base Address Registers(Bar). When Bar = 0, this Bar does not
2865 // exist. If these no Bar for this function, print "none", otherwise
2866 // list detail information about this Bar.
2868 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BASE_ADDR
), gShellDebug1HiiHandle
, INDEX_OF (Device
->Bar
));
2871 BarCount
= sizeof (Device
->Bar
) / sizeof (Device
->Bar
[0]);
2872 for (Index
= 0; Index
< BarCount
; Index
++) {
2873 if (Device
->Bar
[Index
] == 0) {
2879 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_START_TYPE
), gShellDebug1HiiHandle
);
2880 ShellPrintEx (-1, -1, L
" --------------------------------------------------------------------------");
2883 Status
= PciExplainBar (
2884 &(Device
->Bar
[Index
]),
2885 &(mConfigSpace
->Common
.Command
),
2891 if (EFI_ERROR (Status
)) {
2897 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NONE
), gShellDebug1HiiHandle
);
2900 ShellPrintEx (-1, -1, L
"\r\n --------------------------------------------------------------------------");
2904 // Print register Expansion ROM Base Address
2906 if ((Device
->ROMBar
& PCI_BIT_0
) == 0) {
2907 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_EXPANSION_ROM_DISABLED
), gShellDebug1HiiHandle
, INDEX_OF (&(Device
->ROMBar
)));
2910 ShellPrintHiiEx(-1, -1, NULL
,
2911 STRING_TOKEN (STR_PCI2_EXPANSION_ROM_BASE
),
2912 gShellDebug1HiiHandle
,
2913 INDEX_OF (&(Device
->ROMBar
)),
2918 // Print register Cardbus CIS ptr
2920 ShellPrintHiiEx(-1, -1, NULL
,
2921 STRING_TOKEN (STR_PCI2_CARDBUS_CIS
),
2922 gShellDebug1HiiHandle
,
2923 INDEX_OF (&(Device
->CardBusCISPtr
)),
2924 Device
->CardBusCISPtr
2928 // Print register Sub-vendor ID and subsystem ID
2930 ShellPrintHiiEx(-1, -1, NULL
,
2931 STRING_TOKEN (STR_PCI2_SUB_VENDOR_ID
),
2932 gShellDebug1HiiHandle
,
2933 INDEX_OF (&(Device
->SubVendorId
)),
2937 ShellPrintHiiEx(-1, -1, NULL
,
2938 STRING_TOKEN (STR_PCI2_SUBSYSTEM_ID
),
2939 gShellDebug1HiiHandle
,
2940 INDEX_OF (&(Device
->SubSystemId
)),
2945 // Print register Capabilities Ptr
2947 ShellPrintHiiEx(-1, -1, NULL
,
2948 STRING_TOKEN (STR_PCI2_CAPABILITIES_PTR
),
2949 gShellDebug1HiiHandle
,
2950 INDEX_OF (&(Device
->CapabilitiesPtr
)),
2951 Device
->CapabilitiesPtr
2955 // Print register Interrupt Line and interrupt pin
2957 ShellPrintHiiEx(-1, -1, NULL
,
2958 STRING_TOKEN (STR_PCI2_INTERRUPT_LINE
),
2959 gShellDebug1HiiHandle
,
2960 INDEX_OF (&(Device
->InterruptLine
)),
2961 Device
->InterruptLine
2964 ShellPrintHiiEx(-1, -1, NULL
,
2965 STRING_TOKEN (STR_PCI2_INTERRUPT_PIN
),
2966 gShellDebug1HiiHandle
,
2967 INDEX_OF (&(Device
->InterruptPin
)),
2968 Device
->InterruptPin
2972 // Print register Min_Gnt and Max_Lat
2974 ShellPrintHiiEx(-1, -1, NULL
,
2975 STRING_TOKEN (STR_PCI2_MIN_GNT
),
2976 gShellDebug1HiiHandle
,
2977 INDEX_OF (&(Device
->MinGnt
)),
2981 ShellPrintHiiEx(-1, -1, NULL
,
2982 STRING_TOKEN (STR_PCI2_MAX_LAT
),
2983 gShellDebug1HiiHandle
,
2984 INDEX_OF (&(Device
->MaxLat
)),
2992 Explain the bridge specific part of data in PCI configuration space.
2994 @param[in] Bridge Bridge specific data region in PCI configuration space.
2995 @param[in] Address Address used to access configuration space of this PCI device.
2996 @param[in] IoDev Handle used to access configuration space of PCI device.
2998 @retval EFI_SUCCESS The command completed successfully.
3001 PciExplainBridgeData (
3002 IN PCI_BRIDGE_HEADER
*Bridge
,
3004 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
3014 // Print Base Address Registers. When Bar = 0, this Bar does not
3015 // exist. If these no Bar for this function, print "none", otherwise
3016 // list detail information about this Bar.
3018 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BASE_ADDRESS
), gShellDebug1HiiHandle
, INDEX_OF (&(Bridge
->Bar
)));
3021 BarCount
= sizeof (Bridge
->Bar
) / sizeof (Bridge
->Bar
[0]);
3023 for (Index
= 0; Index
< BarCount
; Index
++) {
3024 if (Bridge
->Bar
[Index
] == 0) {
3030 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_START_TYPE_2
), gShellDebug1HiiHandle
);
3031 ShellPrintEx (-1, -1, L
" --------------------------------------------------------------------------");
3034 Status
= PciExplainBar (
3035 &(Bridge
->Bar
[Index
]),
3036 &(mConfigSpace
->Common
.Command
),
3042 if (EFI_ERROR (Status
)) {
3048 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NONE
), gShellDebug1HiiHandle
);
3050 ShellPrintEx (-1, -1, L
"\r\n --------------------------------------------------------------------------");
3054 // Expansion register ROM Base Address
3056 if ((Bridge
->ROMBar
& PCI_BIT_0
) == 0) {
3057 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NO_EXPANSION_ROM
), gShellDebug1HiiHandle
, INDEX_OF (&(Bridge
->ROMBar
)));
3060 ShellPrintHiiEx(-1, -1, NULL
,
3061 STRING_TOKEN (STR_PCI2_EXPANSION_ROM_BASE_2
),
3062 gShellDebug1HiiHandle
,
3063 INDEX_OF (&(Bridge
->ROMBar
)),
3068 // Print Bus Numbers(Primary, Secondary, and Subordinate
3070 ShellPrintHiiEx(-1, -1, NULL
,
3071 STRING_TOKEN (STR_PCI2_BUS_NUMBERS
),
3072 gShellDebug1HiiHandle
,
3073 INDEX_OF (&(Bridge
->PrimaryBus
)),
3074 INDEX_OF (&(Bridge
->SecondaryBus
)),
3075 INDEX_OF (&(Bridge
->SubordinateBus
))
3078 ShellPrintEx (-1, -1, L
" ------------------------------------------------------\r\n");
3080 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BRIDGE
), gShellDebug1HiiHandle
, Bridge
->PrimaryBus
);
3081 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BRIDGE
), gShellDebug1HiiHandle
, Bridge
->SecondaryBus
);
3082 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BRIDGE
), gShellDebug1HiiHandle
, Bridge
->SubordinateBus
);
3085 // Print register Secondary Latency Timer
3087 ShellPrintHiiEx(-1, -1, NULL
,
3088 STRING_TOKEN (STR_PCI2_SECONDARY_TIMER
),
3089 gShellDebug1HiiHandle
,
3090 INDEX_OF (&(Bridge
->SecondaryLatencyTimer
)),
3091 Bridge
->SecondaryLatencyTimer
3095 // Print register Secondary Status
3097 PciExplainStatus (&(Bridge
->SecondaryStatus
), FALSE
, PciP2pBridge
);
3100 // Print I/O and memory ranges this bridge forwards. There are 3 resource
3101 // types: I/O, memory, and pre-fetchable memory. For each resource type,
3102 // base and limit address are listed.
3104 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_RESOURCE_TYPE
), gShellDebug1HiiHandle
);
3105 ShellPrintEx (-1, -1, L
"----------------------------------------------------------------------\r\n");
3110 IoAddress32
= (Bridge
->IoBaseUpper
<< 16 | Bridge
->IoBase
<< 8);
3111 IoAddress32
&= 0xfffff000;
3112 ShellPrintHiiEx(-1, -1, NULL
,
3113 STRING_TOKEN (STR_PCI2_TWO_VARS
),
3114 gShellDebug1HiiHandle
,
3115 INDEX_OF (&(Bridge
->IoBase
)),
3119 IoAddress32
= (Bridge
->IoLimitUpper
<< 16 | Bridge
->IoLimit
<< 8);
3120 IoAddress32
|= 0x00000fff;
3121 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_ONE_VAR
), gShellDebug1HiiHandle
, IoAddress32
);
3124 // Memory Base & Limit
3126 ShellPrintHiiEx(-1, -1, NULL
,
3127 STRING_TOKEN (STR_PCI2_MEMORY
),
3128 gShellDebug1HiiHandle
,
3129 INDEX_OF (&(Bridge
->MemoryBase
)),
3130 (Bridge
->MemoryBase
<< 16) & 0xfff00000
3133 ShellPrintHiiEx(-1, -1, NULL
,
3134 STRING_TOKEN (STR_PCI2_ONE_VAR
),
3135 gShellDebug1HiiHandle
,
3136 (Bridge
->MemoryLimit
<< 16) | 0x000fffff
3140 // Pre-fetch-able Memory Base & Limit
3142 ShellPrintHiiEx(-1, -1, NULL
,
3143 STRING_TOKEN (STR_PCI2_PREFETCHABLE
),
3144 gShellDebug1HiiHandle
,
3145 INDEX_OF (&(Bridge
->PrefetchableMemBase
)),
3146 Bridge
->PrefetchableBaseUpper
,
3147 (Bridge
->PrefetchableMemBase
<< 16) & 0xfff00000
3150 ShellPrintHiiEx(-1, -1, NULL
,
3151 STRING_TOKEN (STR_PCI2_TWO_VARS_2
),
3152 gShellDebug1HiiHandle
,
3153 Bridge
->PrefetchableLimitUpper
,
3154 (Bridge
->PrefetchableMemLimit
<< 16) | 0x000fffff
3158 // Print register Capabilities Pointer
3160 ShellPrintHiiEx(-1, -1, NULL
,
3161 STRING_TOKEN (STR_PCI2_CAPABILITIES_PTR_2
),
3162 gShellDebug1HiiHandle
,
3163 INDEX_OF (&(Bridge
->CapabilitiesPtr
)),
3164 Bridge
->CapabilitiesPtr
3168 // Print register Bridge Control
3170 PciExplainBridgeControl (&(Bridge
->BridgeControl
), PciP2pBridge
);
3173 // Print register Interrupt Line & PIN
3175 ShellPrintHiiEx(-1, -1, NULL
,
3176 STRING_TOKEN (STR_PCI2_INTERRUPT_LINE_2
),
3177 gShellDebug1HiiHandle
,
3178 INDEX_OF (&(Bridge
->InterruptLine
)),
3179 Bridge
->InterruptLine
3182 ShellPrintHiiEx(-1, -1, NULL
,
3183 STRING_TOKEN (STR_PCI2_INTERRUPT_PIN
),
3184 gShellDebug1HiiHandle
,
3185 INDEX_OF (&(Bridge
->InterruptPin
)),
3186 Bridge
->InterruptPin
3193 Explain the Base Address Register(Bar) in PCI configuration space.
3195 @param[in] Bar Points to the Base Address Register intended to interpret.
3196 @param[in] Command Points to the register Command.
3197 @param[in] Address Address used to access configuration space of this PCI device.
3198 @param[in] IoDev Handle used to access configuration space of PCI device.
3199 @param[in, out] Index The Index.
3201 @retval EFI_SUCCESS The command completed successfully.
3208 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*IoDev
,
3229 // According the bar type, list detail about this bar, for example: 32 or
3230 // 64 bits; pre-fetchable or not.
3232 if ((*Bar
& PCI_BIT_0
) == 0) {
3234 // This bar is of memory type
3238 if ((*Bar
& PCI_BIT_1
) == 0 && (*Bar
& PCI_BIT_2
) == 0) {
3239 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BAR
), gShellDebug1HiiHandle
, *Bar
& 0xfffffff0);
3240 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MEM
), gShellDebug1HiiHandle
);
3241 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_32_BITS
), gShellDebug1HiiHandle
);
3243 } else if ((*Bar
& PCI_BIT_1
) == 0 && (*Bar
& PCI_BIT_2
) != 0) {
3245 CopyMem (&Bar64
, Bar
, sizeof (UINT64
));
3246 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_ONE_VAR_2
), gShellDebug1HiiHandle
, (UINT32
) RShiftU64 ((Bar64
& 0xfffffffffffffff0ULL
), 32));
3247 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_ONE_VAR_3
), gShellDebug1HiiHandle
, (UINT32
) (Bar64
& 0xfffffffffffffff0ULL
));
3248 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MEM
), gShellDebug1HiiHandle
);
3249 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_64_BITS
), gShellDebug1HiiHandle
);
3257 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_BAR
), gShellDebug1HiiHandle
, *Bar
& 0xfffffff0);
3258 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_MEM_2
), gShellDebug1HiiHandle
);
3261 if ((*Bar
& PCI_BIT_3
) == 0) {
3262 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NO
), gShellDebug1HiiHandle
);
3265 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_YES
), gShellDebug1HiiHandle
);
3270 // This bar is of io type
3273 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_ONE_VAR_4
), gShellDebug1HiiHandle
, *Bar
& 0xfffffffc);
3274 ShellPrintEx (-1, -1, L
"I/O ");
3278 // Get BAR length(or the amount of resource this bar demands for). To get
3279 // Bar length, first we should temporarily disable I/O and memory access
3280 // of this function(by set bits in the register Command), then write all
3281 // "1"s to this bar. The bar value read back is the amount of resource
3282 // this bar demands for.
3285 // Disable io & mem access
3287 OldCommand
= *Command
;
3288 NewCommand
= (UINT16
) (OldCommand
& 0xfffc);
3289 RegAddress
= Address
| INDEX_OF (Command
);
3290 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint16
, RegAddress
, 1, &NewCommand
);
3292 RegAddress
= Address
| INDEX_OF (Bar
);
3295 // Read after write the BAR to get the size
3299 NewBar32
= 0xffffffff;
3301 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint32
, RegAddress
, 1, &NewBar32
);
3302 IoDev
->Pci
.Read (IoDev
, EfiPciWidthUint32
, RegAddress
, 1, &NewBar32
);
3303 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint32
, RegAddress
, 1, &OldBar32
);
3306 NewBar32
= NewBar32
& 0xfffffff0;
3307 NewBar32
= (~NewBar32
) + 1;
3310 NewBar32
= NewBar32
& 0xfffffffc;
3311 NewBar32
= (~NewBar32
) + 1;
3312 NewBar32
= NewBar32
& 0x0000ffff;
3317 CopyMem (&OldBar64
, Bar
, sizeof (UINT64
));
3318 NewBar64
= 0xffffffffffffffffULL
;
3320 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint32
, RegAddress
, 2, &NewBar64
);
3321 IoDev
->Pci
.Read (IoDev
, EfiPciWidthUint32
, RegAddress
, 2, &NewBar64
);
3322 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint32
, RegAddress
, 2, &OldBar64
);
3325 NewBar64
= NewBar64
& 0xfffffffffffffff0ULL
;
3326 NewBar64
= (~NewBar64
) + 1;
3329 NewBar64
= NewBar64
& 0xfffffffffffffffcULL
;
3330 NewBar64
= (~NewBar64
) + 1;
3331 NewBar64
= NewBar64
& 0x000000000000ffff;
3335 // Enable io & mem access
3337 RegAddress
= Address
| INDEX_OF (Command
);
3338 IoDev
->Pci
.Write (IoDev
, EfiPciWidthUint16
, RegAddress
, 1, &OldCommand
);
3342 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NEWBAR_32
), gShellDebug1HiiHandle
, NewBar32
);
3343 ShellPrintHiiEx(-1, -1, NULL
,STRING_TOKEN (STR_PCI2_NEWBAR_32_2
), gShellDebug1HiiHandle
, NewBar32
+ (*Bar
& 0xfffffff0) - 1);