]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c
ShellPkg: Fix pci command to parse seg, bus, dev, and func arguments as hex
[mirror_edk2.git] / ShellPkg / Library / UefiShellDebug1CommandsLib / Pci.c
index cd739d05f2afdfb47ba071b5195a8ad40d70a643..d20093902cb7892293cc5bccaad3d2787c9584b3 100644 (file)
@@ -1,6 +1,7 @@
 /** @file\r
   Main file for Pci shell Debug1 function.\r
 \r
+  Copyright (c) 2013 Hewlett-Packard Development Company, L.P.\r
   Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -1388,7 +1389,6 @@ PciPrintClassCode (
 {\r
   UINT32            ClassCode;\r
   PCI_CLASS_STRINGS ClassStrings;\r
-  CHAR16            OutputString[PCI_CLASS_STRING_LIMIT + 1];\r
 \r
   ClassCode = 0;\r
   ClassCode |= ClassCodePtr[0];\r
@@ -1402,9 +1402,9 @@ PciPrintClassCode (
 \r
   if (IncludePIF) {\r
     //\r
-    // Only print base class and sub class name\r
+    // Print base class, sub class, and programming inferface name\r
     //\r
-    ShellPrintEx(-1,-1, L"%s - %s - %s",\r
+    ShellPrintEx (-1, -1, L"%s - %s - %s",\r
       ClassStrings.BaseClass,\r
       ClassStrings.SubClass,\r
       ClassStrings.PIFClass\r
@@ -1412,18 +1412,12 @@ PciPrintClassCode (
 \r
   } else {\r
     //\r
-    // Print base class, sub class, and programming inferface name\r
+    // Only print base class and sub class name\r
     //\r
-    UnicodeSPrint (\r
-      OutputString,\r
-      PCI_CLASS_STRING_LIMIT * sizeof (CHAR16),\r
-      L"%s - %s",\r
+    ShellPrintEx (-1, -1, L"%s - %s",\r
       ClassStrings.BaseClass,\r
       ClassStrings.SubClass\r
-     );\r
-\r
-    OutputString[PCI_CLASS_STRING_LIMIT] = 0;\r
-    ShellPrintEx(-1,-1, L"%s", OutputString);\r
+    );\r
   }\r
 }\r
 \r
@@ -2055,6 +2049,7 @@ ShellCommandRunPci (
   CHAR16                            *ProblemParam;\r
   SHELL_STATUS                      ShellStatus;\r
   CONST CHAR16                      *Temp;\r
+  UINT64                            RetVal;\r
 \r
   ShellStatus         = SHELL_SUCCESS;\r
   Status              = EFI_SUCCESS;\r
@@ -2308,7 +2303,16 @@ ShellCommandRunPci (
 \r
     Temp = ShellCommandLineGetValue(Package, L"-s");\r
     if (Temp != NULL) {\r
-      Segment = (UINT16) ShellStrToUintn (Temp);\r
+      //\r
+      // Input converted to hexadecimal number.\r
+      //\r
+      if (!EFI_ERROR (ShellConvertStringToUint64 (Temp, &RetVal, TRUE, TRUE))) {\r
+        Segment = (UINT16) RetVal;\r
+      } else {\r
+        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV_HEX), gShellDebug1HiiHandle);\r
+        ShellStatus = SHELL_INVALID_PARAMETER;\r
+        goto Done;\r
+      }\r
     }\r
 \r
     //\r
@@ -2317,7 +2321,17 @@ ShellCommandRunPci (
     //\r
     Temp = ShellCommandLineGetRawValue(Package, 1);\r
     if (Temp != NULL) {\r
-      Bus = (UINT16)ShellStrToUintn(Temp);\r
+      //\r
+      // Input converted to hexadecimal number.\r
+      //\r
+      if (!EFI_ERROR (ShellConvertStringToUint64 (Temp, &RetVal, TRUE, TRUE))) {\r
+        Bus = (UINT16) RetVal;\r
+      } else {\r
+        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV_HEX), gShellDebug1HiiHandle);\r
+        ShellStatus = SHELL_INVALID_PARAMETER;\r
+        goto Done;\r
+      }\r
+\r
       if (Bus > MAX_BUS_NUMBER) {\r
         ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp);\r
         ShellStatus = SHELL_INVALID_PARAMETER;\r
@@ -2326,7 +2340,17 @@ ShellCommandRunPci (
     }\r
     Temp = ShellCommandLineGetRawValue(Package, 2);\r
     if (Temp != NULL) {\r
-      Device = (UINT16) ShellStrToUintn(Temp);\r
+      //\r
+      // Input converted to hexadecimal number.\r
+      //\r
+      if (!EFI_ERROR (ShellConvertStringToUint64 (Temp, &RetVal, TRUE, TRUE))) {\r
+        Device = (UINT16) RetVal;\r
+      } else {\r
+        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV_HEX), gShellDebug1HiiHandle);\r
+        ShellStatus = SHELL_INVALID_PARAMETER;\r
+        goto Done;\r
+      }\r
+\r
       if (Device > MAX_DEVICE_NUMBER){\r
         ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp);\r
         ShellStatus = SHELL_INVALID_PARAMETER;\r
@@ -2336,7 +2360,17 @@ ShellCommandRunPci (
 \r
     Temp = ShellCommandLineGetRawValue(Package, 3);\r
     if (Temp != NULL) {\r
-      Func = (UINT16) ShellStrToUintn(Temp);\r
+      //\r
+      // Input converted to hexadecimal number.\r
+      //\r
+      if (!EFI_ERROR (ShellConvertStringToUint64 (Temp, &RetVal, TRUE, TRUE))) {\r
+        Func = (UINT16) RetVal;\r
+      } else {\r
+        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV_HEX), gShellDebug1HiiHandle);\r
+        ShellStatus = SHELL_INVALID_PARAMETER;\r
+        goto Done;\r
+      }\r
+\r
       if (Func > MAX_FUNCTION_NUMBER){\r
         ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp);\r
         ShellStatus = SHELL_INVALID_PARAMETER;\r
@@ -2359,7 +2393,6 @@ ShellCommandRunPci (
     if (EFI_ERROR (Status)) {\r
       ShellPrintHiiEx(\r
         -1, -1, NULL, STRING_TOKEN (STR_PCI_NO_FIND), gShellDebug1HiiHandle,\r
-        gShellDebug1HiiHandle,\r
         Segment,\r
         Bus\r
        );\r
@@ -2632,7 +2665,7 @@ PciExplainData (
 \r
   Common = &(ConfigSpace->Common);\r
 \r
-  Print (L"\n");\r
+  ShellPrintEx (-1, -1, L"\r\n");\r
 \r
   //\r
   // Print Vendor Id and Device Id\r
@@ -2733,7 +2766,7 @@ PciExplainData (
   //\r
   ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_CLASS), gShellDebug1HiiHandle);\r
   PciPrintClassCode ((UINT8 *) Common->ClassCode, TRUE);\r
-  Print (L"\n");\r
+  ShellPrintEx (-1, -1, L"\r\n");\r
 \r
   if (ShellGetExecutionBreakFlag()) {\r
     return EFI_SUCCESS;\r
@@ -2824,7 +2857,7 @@ PciExplainDeviceData (
     if (!BarExist) {\r
       BarExist = TRUE;\r
       ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_START_TYPE), gShellDebug1HiiHandle);\r
-      Print (L"  --------------------------------------------------------------------------");\r
+      ShellPrintEx (-1, -1, L"  --------------------------------------------------------------------------");\r
     }\r
 \r
     Status = PciExplainBar (\r
@@ -2844,7 +2877,7 @@ PciExplainDeviceData (
     ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_NONE), gShellDebug1HiiHandle);\r
 \r
   } else {\r
-    Print (L"\n  --------------------------------------------------------------------------");\r
+    ShellPrintEx (-1, -1, L"\r\n  --------------------------------------------------------------------------");\r
   }\r
 \r
   //\r
@@ -2975,7 +3008,7 @@ PciExplainBridgeData (
     if (!BarExist) {\r
       BarExist = TRUE;\r
       ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_START_TYPE_2), gShellDebug1HiiHandle);\r
-      Print (L"  --------------------------------------------------------------------------");\r
+      ShellPrintEx (-1, -1, L"  --------------------------------------------------------------------------");\r
     }\r
 \r
     Status = PciExplainBar (\r
@@ -2994,7 +3027,7 @@ PciExplainBridgeData (
   if (!BarExist) {\r
     ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_NONE), gShellDebug1HiiHandle);\r
   } else {\r
-    Print (L"\n  --------------------------------------------------------------------------");\r
+    ShellPrintEx (-1, -1, L"\r\n  --------------------------------------------------------------------------");\r
   }\r
 \r
   //\r
@@ -3022,7 +3055,7 @@ PciExplainBridgeData (
     INDEX_OF (&(Bridge->SubordinateBus))\r
    );\r
 \r
-  Print (L"               ------------------------------------------------------\n");\r
+  ShellPrintEx (-1, -1, L"               ------------------------------------------------------\r\n");\r
 \r
   ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_BRIDGE), gShellDebug1HiiHandle, Bridge->PrimaryBus);\r
   ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_BRIDGE), gShellDebug1HiiHandle, Bridge->SecondaryBus);\r
@@ -3049,7 +3082,7 @@ PciExplainBridgeData (
   // base and limit address are listed.\r
   //\r
   ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_RESOURCE_TYPE), gShellDebug1HiiHandle);\r
-  Print (L"----------------------------------------------------------------------\n");\r
+  ShellPrintEx (-1, -1, L"----------------------------------------------------------------------\r\n");\r
 \r
   //\r
   // IO Base & Limit\r
@@ -3218,7 +3251,7 @@ PciExplainBar (
     //\r
     IsMem = FALSE;\r
     ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_ONE_VAR_4), gShellDebug1HiiHandle, *Bar & 0xfffffffc);\r
-    Print (L"I/O                               ");\r
+    ShellPrintEx (-1, -1, L"I/O                               ");\r
   }\r
 \r
   //\r
@@ -3292,7 +3325,7 @@ PciExplainBar (
     } else {\r
       ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_RSHIFT), gShellDebug1HiiHandle, (UINT32) RShiftU64 (NewBar64, 32));\r
       ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_RSHIFT), gShellDebug1HiiHandle, (UINT32) NewBar64);\r
-      Print (L"  ");\r
+      ShellPrintEx (-1, -1, L"  ");\r
       ShellPrintHiiEx(-1, -1, NULL,\r
         STRING_TOKEN (STR_PCI2_RSHIFT),\r
         gShellDebug1HiiHandle,\r
@@ -3352,7 +3385,7 @@ PciExplainCardBusData (
     INDEX_OF (&(CardBus->SubordinateBusNumber))\r
    );\r
 \r
-  Print (L"               ------------------------------------------------------\n");\r
+  ShellPrintEx (-1, -1, L"               ------------------------------------------------------\r\n");\r
 \r
   ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_CARDBUS), gShellDebug1HiiHandle, CardBus->PciBusNumber);\r
   ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_CARDBUS_2), gShellDebug1HiiHandle, CardBus->CardBusBusNumber);\r
@@ -3372,7 +3405,7 @@ PciExplainCardBusData (
   // Print Memory/Io ranges this cardbus bridge forwards\r
   //\r
   ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_RESOURCE_TYPE_2), gShellDebug1HiiHandle);\r
-  Print (L"----------------------------------------------------------------------\n");\r
+  ShellPrintEx (-1, -1, L"----------------------------------------------------------------------\r\n");\r
 \r
   ShellPrintHiiEx(-1, -1, NULL,\r
     STRING_TOKEN (STR_PCI2_MEM_3),\r
@@ -3805,8 +3838,8 @@ ExplainPcieCapReg (
   CHAR16 *DevicePortType;\r
 \r
   PcieCapReg = PciExpressCap->PcieCapReg;\r
-  Print (\r
-    L"  Capability Version(3:0):          %E0x%04x%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Capability Version(3:0):          %E0x%04x%N\r\n",\r
     PCIE_CAP_VERSION (PcieCapReg)\r
    );\r
   if ((UINT8) PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg) < PCIE_DEVICE_PORT_TYPE_MAX) {\r
@@ -3814,8 +3847,8 @@ ExplainPcieCapReg (
   } else {\r
     DevicePortType = L"Unknown Type";\r
   }\r
-  Print (\r
-    L"  Device/PortType(7:4):             %E%s%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Device/PortType(7:4):             %E%s%N\r\n",\r
     DevicePortType\r
    );\r
   //\r
@@ -3825,13 +3858,13 @@ ExplainPcieCapReg (
   //\r
   if (PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg) == PCIE_ROOT_COMPLEX_ROOT_PORT ||\r
       PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg) == PCIE_SWITCH_DOWNSTREAM_PORT) {\r
-    Print (\r
-      L"  Slot Implemented(8):              %E%d%N\n",\r
+    ShellPrintEx (-1, -1,\r
+      L"  Slot Implemented(8):              %E%d%N\r\n",\r
       PCIE_CAP_SLOT_IMPLEMENTED (PcieCapReg)\r
      );\r
   }\r
-  Print (\r
-    L"  Interrupt Message Number(13:9):   %E0x%05x%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Interrupt Message Number(13:9):   %E0x%05x%N\r\n",\r
     PCIE_CAP_INT_MSG_NUM (PcieCapReg)\r
    );\r
   return EFI_SUCCESS;\r
@@ -3858,18 +3891,18 @@ ExplainPcieDeviceCap (
   PcieCapReg     = PciExpressCap->PcieCapReg;\r
   PcieDeviceCap  = PciExpressCap->PcieDeviceCap;\r
   DevicePortType = (UINT8) PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg);\r
-  Print (L"  Max_Payload_Size Supported(2:0):          ");\r
+  ShellPrintEx (-1, -1, L"  Max_Payload_Size Supported(2:0):          ");\r
   if (PCIE_CAP_MAX_PAYLOAD (PcieDeviceCap) < 6) {\r
-    Print (L"%E%d bytes%N\n", 1 << (PCIE_CAP_MAX_PAYLOAD (PcieDeviceCap) + 7));\r
+    ShellPrintEx (-1, -1, L"%E%d bytes%N\r\n", 1 << (PCIE_CAP_MAX_PAYLOAD (PcieDeviceCap) + 7));\r
   } else {\r
-    Print (L"%EUnknown%N\n");\r
+    ShellPrintEx (-1, -1, L"%EUnknown%N\r\n");\r
   }\r
-  Print (\r
-    L"  Phantom Functions Supported(4:3):         %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Phantom Functions Supported(4:3):         %E%d%N\r\n",\r
     PCIE_CAP_PHANTOM_FUNC (PcieDeviceCap)\r
    );\r
-  Print (\r
-    L"  Extended Tag Field Supported(5):          %E%d-bit Tag field supported%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Extended Tag Field Supported(5):          %E%d-bit Tag field supported%N\r\n",\r
     PCIE_CAP_EXTENDED_TAG (PcieDeviceCap) ? 8 : 5\r
    );\r
   //\r
@@ -3878,25 +3911,25 @@ ExplainPcieDeviceCap (
   if (IS_PCIE_ENDPOINT (DevicePortType)) {\r
     L0sLatency = (UINT8) PCIE_CAP_L0SLATENCY (PcieDeviceCap);\r
     L1Latency  = (UINT8) PCIE_CAP_L1LATENCY (PcieDeviceCap);\r
-    Print (L"  Endpoint L0s Acceptable Latency(8:6):     ");\r
+    ShellPrintEx (-1, -1, L"  Endpoint L0s Acceptable Latency(8:6):     ");\r
     if (L0sLatency < 4) {\r
-      Print (L"%EMaximum of %d ns%N\n", 1 << (L0sLatency + 6));\r
+      ShellPrintEx (-1, -1, L"%EMaximum of %d ns%N\r\n", 1 << (L0sLatency + 6));\r
     } else {\r
       if (L0sLatency < 7) {\r
-        Print (L"%EMaximum of %d us%N\n", 1 << (L0sLatency - 3));\r
+        ShellPrintEx (-1, -1, L"%EMaximum of %d us%N\r\n", 1 << (L0sLatency - 3));\r
       } else {\r
-        Print (L"%ENo limit%N\n");\r
+        ShellPrintEx (-1, -1, L"%ENo limit%N\r\n");\r
       }\r
     }\r
-    Print (L"  Endpoint L1 Acceptable Latency(11:9):     ");\r
+    ShellPrintEx (-1, -1, L"  Endpoint L1 Acceptable Latency(11:9):     ");\r
     if (L1Latency < 7) {\r
-      Print (L"%EMaximum of %d us%N\n", 1 << (L1Latency + 1));\r
+      ShellPrintEx (-1, -1, L"%EMaximum of %d us%N\r\n", 1 << (L1Latency + 1));\r
     } else {\r
-      Print (L"%ENo limit%N\n");\r
+      ShellPrintEx (-1, -1, L"%ENo limit%N\r\n");\r
     }\r
   }\r
-  Print (\r
-    L"  Role-based Error Reporting(15):           %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Role-based Error Reporting(15):           %E%d%N\r\n",\r
     PCIE_CAP_ERR_REPORTING (PcieDeviceCap)\r
    );\r
   //\r
@@ -3905,12 +3938,12 @@ ExplainPcieDeviceCap (
   // b) Captured Slot Power Scale\r
   //\r
   if (DevicePortType == PCIE_SWITCH_UPSTREAM_PORT) {\r
-    Print (\r
-      L"  Captured Slot Power Limit Value(25:18):   %E0x%02x%N\n",\r
+    ShellPrintEx (-1, -1,\r
+      L"  Captured Slot Power Limit Value(25:18):   %E0x%02x%N\r\n",\r
       PCIE_CAP_SLOT_POWER_VALUE (PcieDeviceCap)\r
      );\r
-    Print (\r
-      L"  Captured Slot Power Limit Scale(27:26):   %E%s%N\n",\r
+    ShellPrintEx (-1, -1,\r
+      L"  Captured Slot Power Limit Scale(27:26):   %E%s%N\r\n",\r
       SlotPwrLmtScaleTable[PCIE_CAP_SLOT_POWER_SCALE (PcieDeviceCap)]\r
      );\r
   }\r
@@ -3918,8 +3951,8 @@ ExplainPcieDeviceCap (
   // Function Level Reset Capability is only valid for Endpoint\r
   //\r
   if (IS_PCIE_ENDPOINT (DevicePortType)) {\r
-    Print (\r
-      L"  Function Level Reset Capability(28):      %E%d%N\n",\r
+    ShellPrintEx (-1, -1,\r
+      L"  Function Level Reset Capability(28):      %E%d%N\r\n",\r
       PCIE_CAP_FUNC_LEVEL_RESET (PcieDeviceCap)\r
      );\r
   }\r
@@ -3943,60 +3976,60 @@ ExplainPcieDeviceControl (
 \r
   PcieCapReg        = PciExpressCap->PcieCapReg;\r
   PcieDeviceControl = PciExpressCap->DeviceControl;\r
-  Print (\r
-    L"  Correctable Error Reporting Enable(0):    %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Correctable Error Reporting Enable(0):    %E%d%N\r\n",\r
     PCIE_CAP_COR_ERR_REPORTING_ENABLE (PcieDeviceControl)\r
    );\r
-  Print (\r
-    L"  Non-Fatal Error Reporting Enable(1):      %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Non-Fatal Error Reporting Enable(1):      %E%d%N\r\n",\r
     PCIE_CAP_NONFAT_ERR_REPORTING_ENABLE (PcieDeviceControl)\r
    );\r
-  Print (\r
-    L"  Fatal Error Reporting Enable(2):          %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Fatal Error Reporting Enable(2):          %E%d%N\r\n",\r
     PCIE_CAP_FATAL_ERR_REPORTING_ENABLE (PcieDeviceControl)\r
    );\r
-  Print (\r
-    L"  Unsupported Request Reporting Enable(3):  %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Unsupported Request Reporting Enable(3):  %E%d%N\r\n",\r
     PCIE_CAP_UNSUP_REQ_REPORTING_ENABLE (PcieDeviceControl)\r
    );\r
-  Print (\r
-    L"  Enable Relaxed Ordering(4):               %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Enable Relaxed Ordering(4):               %E%d%N\r\n",\r
     PCIE_CAP_RELAXED_ORDERING_ENABLE (PcieDeviceControl)\r
    );\r
-  Print (L"  Max_Payload_Size(7:5):                    ");\r
+  ShellPrintEx (-1, -1, L"  Max_Payload_Size(7:5):                    ");\r
   if (PCIE_CAP_MAX_PAYLOAD_SIZE (PcieDeviceControl) < 6) {\r
-    Print (L"%E%d bytes%N\n", 1 << (PCIE_CAP_MAX_PAYLOAD_SIZE (PcieDeviceControl) + 7));\r
+    ShellPrintEx (-1, -1, L"%E%d bytes%N\r\n", 1 << (PCIE_CAP_MAX_PAYLOAD_SIZE (PcieDeviceControl) + 7));\r
   } else {\r
-    Print (L"%EUnknown%N\n");\r
+    ShellPrintEx (-1, -1, L"%EUnknown%N\r\n");\r
   }\r
-  Print (\r
-    L"  Extended Tag Field Enable(8):             %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Extended Tag Field Enable(8):             %E%d%N\r\n",\r
     PCIE_CAP_EXTENDED_TAG_ENABLE (PcieDeviceControl)\r
    );\r
-  Print (\r
-    L"  Phantom Functions Enable(9):              %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Phantom Functions Enable(9):              %E%d%N\r\n",\r
     PCIE_CAP_PHANTOM_FUNC_ENABLE (PcieDeviceControl)\r
    );\r
-  Print (\r
-    L"  Auxiliary (AUX) Power PM Enable(10):      %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Auxiliary (AUX) Power PM Enable(10):      %E%d%N\r\n",\r
     PCIE_CAP_AUX_PM_ENABLE (PcieDeviceControl)\r
    );\r
-  Print (\r
-    L"  Enable No Snoop(11):                      %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Enable No Snoop(11):                      %E%d%N\r\n",\r
     PCIE_CAP_NO_SNOOP_ENABLE (PcieDeviceControl)\r
    );\r
-  Print (L"  Max_Read_Request_Size(14:12):             ");\r
+  ShellPrintEx (-1, -1, L"  Max_Read_Request_Size(14:12):             ");\r
   if (PCIE_CAP_MAX_READ_REQ_SIZE (PcieDeviceControl) < 6) {\r
-    Print (L"%E%d bytes%N\n", 1 << (PCIE_CAP_MAX_READ_REQ_SIZE (PcieDeviceControl) + 7));\r
+    ShellPrintEx (-1, -1, L"%E%d bytes%N\r\n", 1 << (PCIE_CAP_MAX_READ_REQ_SIZE (PcieDeviceControl) + 7));\r
   } else {\r
-    Print (L"%EUnknown%N\n");\r
+    ShellPrintEx (-1, -1, L"%EUnknown%N\r\n");\r
   }\r
   //\r
   // Read operation is only valid for PCI Express to PCI/PCI-X Bridges\r
   //\r
   if (PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg) == PCIE_PCIE_TO_PCIX_BRIDGE) {\r
-    Print (\r
-      L"  Bridge Configuration Retry Enable(15):  %E%d%N\n",\r
+    ShellPrintEx (-1, -1,\r
+      L"  Bridge Configuration Retry Enable(15):  %E%d%N\r\n",\r
       PCIE_CAP_BRG_CONF_RETRY (PcieDeviceControl)\r
      );\r
   }\r
@@ -4018,28 +4051,28 @@ ExplainPcieDeviceStatus (
   UINT16 PcieDeviceStatus;\r
 \r
   PcieDeviceStatus = PciExpressCap->DeviceStatus;\r
-  Print (\r
-    L"  Correctable Error Detected(0):            %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Correctable Error Detected(0):            %E%d%N\r\n",\r
     PCIE_CAP_COR_ERR_DETECTED (PcieDeviceStatus)\r
    );\r
-  Print (\r
-    L"  Non-Fatal Error Detected(1):              %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Non-Fatal Error Detected(1):              %E%d%N\r\n",\r
     PCIE_CAP_NONFAT_ERR_DETECTED (PcieDeviceStatus)\r
    );\r
-  Print (\r
-    L"  Fatal Error Detected(2):                  %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Fatal Error Detected(2):                  %E%d%N\r\n",\r
     PCIE_CAP_FATAL_ERR_DETECTED (PcieDeviceStatus)\r
    );\r
-  Print (\r
-    L"  Unsupported Request Detected(3):          %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Unsupported Request Detected(3):          %E%d%N\r\n",\r
     PCIE_CAP_UNSUP_REQ_DETECTED (PcieDeviceStatus)\r
    );\r
-  Print (\r
-    L"  AUX Power Detected(4):                    %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  AUX Power Detected(4):                    %E%d%N\r\n",\r
     PCIE_CAP_AUX_POWER_DETECTED (PcieDeviceStatus)\r
    );\r
-  Print (\r
-    L"  Transactions Pending(5):                  %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Transactions Pending(5):                  %E%d%N\r\n",\r
     PCIE_CAP_TRANSACTION_PENDING (PcieDeviceStatus)\r
    );\r
   return EFI_SUCCESS;\r
@@ -4058,32 +4091,41 @@ ExplainPcieLinkCap (
   )\r
 {\r
   UINT32 PcieLinkCap;\r
-  CHAR16 *SupLinkSpeeds;\r
+  CHAR16 *MaxLinkSpeed;\r
   CHAR16 *AspmValue;\r
 \r
   PcieLinkCap = PciExpressCap->LinkCap;\r
-  switch (PCIE_CAP_SUP_LINK_SPEEDS (PcieLinkCap)) {\r
+  switch (PCIE_CAP_MAX_LINK_SPEED (PcieLinkCap)) {\r
     case 1:\r
-      SupLinkSpeeds = L"2.5 GT/s";\r
+      MaxLinkSpeed = L"2.5 GT/s";\r
       break;\r
     case 2:\r
-      SupLinkSpeeds = L"5.0 GT/s and 2.5 GT/s";\r
+      MaxLinkSpeed = L"5.0 GT/s";\r
+      break;\r
+    case 3:\r
+      MaxLinkSpeed = L"8.0 GT/s";\r
       break;\r
     default:\r
-      SupLinkSpeeds = L"Unknown";\r
+      MaxLinkSpeed = L"Unknown";\r
       break;\r
   }\r
-  Print (\r
-    L"  Supported Link Speeds(3:0):                         %E%s supported%N\n",\r
-    SupLinkSpeeds\r
+  ShellPrintEx (-1, -1,\r
+    L"  Maximum Link Speed(3:0):                            %E%s%N\r\n",\r
+    MaxLinkSpeed\r
    );\r
-  Print (\r
-    L"  Maximum Link Width(9:4):                            %Ex%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Maximum Link Width(9:4):                            %Ex%d%N\r\n",\r
     PCIE_CAP_MAX_LINK_WIDTH (PcieLinkCap)\r
    );\r
   switch (PCIE_CAP_ASPM_SUPPORT (PcieLinkCap)) {\r
+    case 0:\r
+      AspmValue = L"Not";\r
+      break;\r
     case 1:\r
-      AspmValue = L"L0s Entry";\r
+      AspmValue = L"L0s";\r
+      break;\r
+    case 2:\r
+      AspmValue = L"L1";\r
       break;\r
     case 3:\r
       AspmValue = L"L0s and L1";\r
@@ -4092,36 +4134,36 @@ ExplainPcieLinkCap (
       AspmValue = L"Reserved";\r
       break;\r
   }\r
-  Print (\r
-    L"  Active State Power Management Support(11:10):       %E%s Supported%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Active State Power Management Support(11:10):       %E%s Supported%N\r\n",\r
     AspmValue\r
    );\r
-  Print (\r
-    L"  L0s Exit Latency(14:12):                            %E%s%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  L0s Exit Latency(14:12):                            %E%s%N\r\n",\r
     L0sLatencyStrTable[PCIE_CAP_L0S_LATENCY (PcieLinkCap)]\r
    );\r
-  Print (\r
-    L"  L1 Exit Latency(17:15):                             %E%s%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  L1 Exit Latency(17:15):                             %E%s%N\r\n",\r
     L1LatencyStrTable[PCIE_CAP_L0S_LATENCY (PcieLinkCap)]\r
    );\r
-  Print (\r
-    L"  Clock Power Management(18):                         %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Clock Power Management(18):                         %E%d%N\r\n",\r
     PCIE_CAP_CLOCK_PM (PcieLinkCap)\r
    );\r
-  Print (\r
-    L"  Surprise Down Error Reporting Capable(19):          %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Surprise Down Error Reporting Capable(19):          %E%d%N\r\n",\r
     PCIE_CAP_SUP_DOWN_ERR_REPORTING (PcieLinkCap)\r
    );\r
-  Print (\r
-    L"  Data Link Layer Link Active Reporting Capable(20):  %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Data Link Layer Link Active Reporting Capable(20):  %E%d%N\r\n",\r
     PCIE_CAP_LINK_ACTIVE_REPORTING (PcieLinkCap)\r
    );\r
-  Print (\r
-    L"  Link Bandwidth Notification Capability(21):         %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Link Bandwidth Notification Capability(21):         %E%d%N\r\n",\r
     PCIE_CAP_LINK_BWD_NOTIF_CAP (PcieLinkCap)\r
    );\r
-  Print (\r
-    L"  Port Number(31:24):                                 %E0x%02x%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Port Number(31:24):                                 %E0x%02x%N\r\n",\r
     PCIE_CAP_PORT_NUMBER (PcieLinkCap)\r
    );\r
   return EFI_SUCCESS;\r
@@ -4144,16 +4186,16 @@ ExplainPcieLinkControl (
 \r
   PcieLinkControl = PciExpressCap->LinkControl;\r
   DevicePortType  = (UINT8) PCIE_CAP_DEVICEPORT_TYPE (PciExpressCap->PcieCapReg);\r
-  Print (\r
-    L"  Active State Power Management Control(1:0):         %E%s%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Active State Power Management Control(1:0):         %E%s%N\r\n",\r
     ASPMCtrlStrTable[PCIE_CAP_ASPM_CONTROL (PcieLinkControl)]\r
    );\r
   //\r
   // RCB is not applicable to switches\r
   //\r
   if (!IS_PCIE_SWITCH(DevicePortType)) {\r
-    Print (\r
-      L"  Read Completion Boundary (RCB)(3):                  %E%d byte%N\n",\r
+    ShellPrintEx (-1, -1,\r
+      L"  Read Completion Boundary (RCB)(3):                  %E%d byte%N\r\n",\r
       1 << (PCIE_CAP_RCB (PcieLinkControl) + 6)\r
      );\r
   }\r
@@ -4166,33 +4208,33 @@ ExplainPcieLinkControl (
   if (!IS_PCIE_ENDPOINT (DevicePortType) &&\r
       DevicePortType != PCIE_SWITCH_UPSTREAM_PORT &&\r
       DevicePortType != PCIE_PCIE_TO_PCIX_BRIDGE) {\r
-    Print (\r
-      L"  Link Disable(4):                                    %E%d%N\n",\r
+    ShellPrintEx (-1, -1,\r
+      L"  Link Disable(4):                                    %E%d%N\r\n",\r
       PCIE_CAP_LINK_DISABLE (PcieLinkControl)\r
      );\r
   }\r
-  Print (\r
-    L"  Common Clock Configuration(6):                      %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Common Clock Configuration(6):                      %E%d%N\r\n",\r
     PCIE_CAP_COMMON_CLK_CONF (PcieLinkControl)\r
    );\r
-  Print (\r
-    L"  Extended Synch(7):                                  %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Extended Synch(7):                                  %E%d%N\r\n",\r
     PCIE_CAP_EXT_SYNC (PcieLinkControl)\r
    );\r
-  Print (\r
-    L"  Enable Clock Power Management(8):                   %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Enable Clock Power Management(8):                   %E%d%N\r\n",\r
     PCIE_CAP_CLK_PWR_MNG (PcieLinkControl)\r
    );\r
-  Print (\r
-    L"  Hardware Autonomous Width Disable(9):               %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Hardware Autonomous Width Disable(9):               %E%d%N\r\n",\r
     PCIE_CAP_HW_AUTO_WIDTH_DISABLE (PcieLinkControl)\r
    );\r
-  Print (\r
-    L"  Link Bandwidth Management Interrupt Enable(10):     %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Link Bandwidth Management Interrupt Enable(10):     %E%d%N\r\n",\r
     PCIE_CAP_LINK_BDW_MNG_INT_EN (PcieLinkControl)\r
    );\r
-  Print (\r
-    L"  Link Autonomous Bandwidth Interrupt Enable(11):     %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Link Autonomous Bandwidth Interrupt Enable(11):     %E%d%N\r\n",\r
     PCIE_CAP_LINK_AUTO_BDW_INT_EN (PcieLinkControl)\r
    );\r
   return EFI_SUCCESS;\r
@@ -4211,46 +4253,49 @@ ExplainPcieLinkStatus (
   )\r
 {\r
   UINT16 PcieLinkStatus;\r
-  CHAR16 *SupLinkSpeeds;\r
+  CHAR16 *CurLinkSpeed;\r
 \r
   PcieLinkStatus = PciExpressCap->LinkStatus;\r
   switch (PCIE_CAP_CUR_LINK_SPEED (PcieLinkStatus)) {\r
     case 1:\r
-      SupLinkSpeeds = L"2.5 GT/s";\r
+      CurLinkSpeed = L"2.5 GT/s";\r
       break;\r
     case 2:\r
-      SupLinkSpeeds = L"5.0 GT/s";\r
+      CurLinkSpeed = L"5.0 GT/s";\r
+      break;\r
+    case 3:\r
+      CurLinkSpeed = L"8.0 GT/s";\r
       break;\r
     default:\r
-      SupLinkSpeeds = L"Reserved";\r
+      CurLinkSpeed = L"Reserved";\r
       break;\r
   }\r
-  Print (\r
-    L"  Current Link Speed(3:0):                            %E%s%N\n",\r
-    SupLinkSpeeds\r
+  ShellPrintEx (-1, -1,\r
+    L"  Current Link Speed(3:0):                            %E%s%N\r\n",\r
+    CurLinkSpeed\r
    );\r
-  Print (\r
-    L"  Negotiated Link Width(9:4):                         %Ex%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Negotiated Link Width(9:4):                         %Ex%d%N\r\n",\r
     PCIE_CAP_NEGO_LINK_WIDTH (PcieLinkStatus)\r
    );\r
-  Print (\r
-    L"  Link Training(11):                                  %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Link Training(11):                                  %E%d%N\r\n",\r
     PCIE_CAP_LINK_TRAINING (PcieLinkStatus)\r
    );\r
-  Print (\r
-    L"  Slot Clock Configuration(12):                       %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Slot Clock Configuration(12):                       %E%d%N\r\n",\r
     PCIE_CAP_SLOT_CLK_CONF (PcieLinkStatus)\r
    );\r
-  Print (\r
-    L"  Data Link Layer Link Active(13):                    %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Data Link Layer Link Active(13):                    %E%d%N\r\n",\r
     PCIE_CAP_DATA_LINK_ACTIVE (PcieLinkStatus)\r
    );\r
-  Print (\r
-    L"  Link Bandwidth Management Status(14):               %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Link Bandwidth Management Status(14):               %E%d%N\r\n",\r
     PCIE_CAP_LINK_BDW_MNG_STAT (PcieLinkStatus)\r
    );\r
-  Print (\r
-    L"  Link Autonomous Bandwidth Status(15):               %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Link Autonomous Bandwidth Status(15):               %E%d%N\r\n",\r
     PCIE_CAP_LINK_AUTO_BDW_STAT (PcieLinkStatus)\r
    );\r
   return EFI_SUCCESS;\r
@@ -4272,52 +4317,52 @@ ExplainPcieSlotCap (
 \r
   PcieSlotCap = PciExpressCap->SlotCap;\r
 \r
-  Print (\r
-    L"  Attention Button Present(0):                        %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Attention Button Present(0):                        %E%d%N\r\n",\r
     PCIE_CAP_ATT_BUT_PRESENT (PcieSlotCap)\r
    );\r
-  Print (\r
-    L"  Power Controller Present(1):                        %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Power Controller Present(1):                        %E%d%N\r\n",\r
     PCIE_CAP_PWR_CTRLLER_PRESENT (PcieSlotCap)\r
    );\r
-  Print (\r
-    L"  MRL Sensor Present(2):                              %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  MRL Sensor Present(2):                              %E%d%N\r\n",\r
     PCIE_CAP_MRL_SENSOR_PRESENT (PcieSlotCap)\r
    );\r
-  Print (\r
-    L"  Attention Indicator Present(3):                     %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Attention Indicator Present(3):                     %E%d%N\r\n",\r
     PCIE_CAP_ATT_IND_PRESENT (PcieSlotCap)\r
    );\r
-  Print (\r
-    L"  Power Indicator Present(4):                         %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Power Indicator Present(4):                         %E%d%N\r\n",\r
     PCIE_CAP_PWD_IND_PRESENT (PcieSlotCap)\r
    );\r
-  Print (\r
-    L"  Hot-Plug Surprise(5):                               %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Hot-Plug Surprise(5):                               %E%d%N\r\n",\r
     PCIE_CAP_HOTPLUG_SUPPRISE (PcieSlotCap)\r
    );\r
-  Print (\r
-    L"  Hot-Plug Capable(6):                                %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Hot-Plug Capable(6):                                %E%d%N\r\n",\r
     PCIE_CAP_HOTPLUG_CAPABLE (PcieSlotCap)\r
    );\r
-  Print (\r
-    L"  Slot Power Limit Value(14:7):                       %E0x%02x%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Slot Power Limit Value(14:7):                       %E0x%02x%N\r\n",\r
     PCIE_CAP_SLOT_PWR_LIMIT_VALUE (PcieSlotCap)\r
    );\r
-  Print (\r
-    L"  Slot Power Limit Scale(16:15):                      %E%s%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Slot Power Limit Scale(16:15):                      %E%s%N\r\n",\r
     SlotPwrLmtScaleTable[PCIE_CAP_SLOT_PWR_LIMIT_SCALE (PcieSlotCap)]\r
    );\r
-  Print (\r
-    L"  Electromechanical Interlock Present(17):            %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Electromechanical Interlock Present(17):            %E%d%N\r\n",\r
     PCIE_CAP_ELEC_INTERLOCK_PRESENT (PcieSlotCap)\r
    );\r
-  Print (\r
-    L"  No Command Completed Support(18):                   %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  No Command Completed Support(18):                   %E%d%N\r\n",\r
     PCIE_CAP_NO_COMM_COMPLETED_SUP (PcieSlotCap)\r
    );\r
-  Print (\r
-    L"  Physical Slot Number(31:19):                        %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Physical Slot Number(31:19):                        %E%d%N\r\n",\r
     PCIE_CAP_PHY_SLOT_NUM (PcieSlotCap)\r
    );\r
 \r
@@ -4339,50 +4384,50 @@ ExplainPcieSlotControl (
   UINT16 PcieSlotControl;\r
 \r
   PcieSlotControl = PciExpressCap->SlotControl;\r
-  Print (\r
-    L"  Attention Button Pressed Enable(0):                 %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Attention Button Pressed Enable(0):                 %E%d%N\r\n",\r
     PCIE_CAP_ATT_BUT_ENABLE (PcieSlotControl)\r
    );\r
-  Print (\r
-    L"  Power Fault Detected Enable(1):                     %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Power Fault Detected Enable(1):                     %E%d%N\r\n",\r
     PCIE_CAP_PWR_FLT_DETECT_ENABLE (PcieSlotControl)\r
    );\r
-  Print (\r
-    L"  MRL Sensor Changed Enable(2):                       %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  MRL Sensor Changed Enable(2):                       %E%d%N\r\n",\r
     PCIE_CAP_MRL_SENSOR_CHANGE_ENABLE (PcieSlotControl)\r
    );\r
-  Print (\r
-    L"  Presence Detect Changed Enable(3):                  %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Presence Detect Changed Enable(3):                  %E%d%N\r\n",\r
     PCIE_CAP_PRES_DETECT_CHANGE_ENABLE (PcieSlotControl)\r
    );\r
-  Print (\r
-    L"  Command Completed Interrupt Enable(4):              %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Command Completed Interrupt Enable(4):              %E%d%N\r\n",\r
     PCIE_CAP_COMM_CMPL_INT_ENABLE (PcieSlotControl)\r
    );\r
-  Print (\r
-    L"  Hot-Plug Interrupt Enable(5):                       %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Hot-Plug Interrupt Enable(5):                       %E%d%N\r\n",\r
     PCIE_CAP_HOTPLUG_INT_ENABLE (PcieSlotControl)\r
    );\r
-  Print (\r
-    L"  Attention Indicator Control(7:6):                   %E%s%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Attention Indicator Control(7:6):                   %E%s%N\r\n",\r
     IndicatorTable[PCIE_CAP_ATT_IND_CTRL (PcieSlotControl)]\r
    );\r
-  Print (\r
-    L"  Power Indicator Control(9:8):                       %E%s%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Power Indicator Control(9:8):                       %E%s%N\r\n",\r
     IndicatorTable[PCIE_CAP_PWR_IND_CTRL (PcieSlotControl)]\r
    );\r
-  Print (L"  Power Controller Control(10):                       %EPower ");\r
+  ShellPrintEx (-1, -1, L"  Power Controller Control(10):                       %EPower ");\r
   if (PCIE_CAP_PWR_CTRLLER_CTRL (PcieSlotControl)) {\r
-    Print (L"Off%N\n");\r
+    ShellPrintEx (-1, -1, L"Off%N\r\n");\r
   } else {\r
-    Print (L"On%N\n");\r
+    ShellPrintEx (-1, -1, L"On%N\r\n");\r
   }\r
-  Print (\r
-    L"  Electromechanical Interlock Control(11):            %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Electromechanical Interlock Control(11):            %E%d%N\r\n",\r
     PCIE_CAP_ELEC_INTERLOCK_CTRL (PcieSlotControl)\r
    );\r
-  Print (\r
-    L"  Data Link Layer State Changed Enable(12):           %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Data Link Layer State Changed Enable(12):           %E%d%N\r\n",\r
     PCIE_CAP_DLINK_STAT_CHANGE_ENABLE (PcieSlotControl)\r
    );\r
   return EFI_SUCCESS;\r
@@ -4404,46 +4449,46 @@ ExplainPcieSlotStatus (
 \r
   PcieSlotStatus = PciExpressCap->SlotStatus;\r
 \r
-  Print (\r
-    L"  Attention Button Pressed(0):           %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Attention Button Pressed(0):           %E%d%N\r\n",\r
     PCIE_CAP_ATT_BUT_PRESSED (PcieSlotStatus)\r
    );\r
-  Print (\r
-    L"  Power Fault Detected(1):               %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Power Fault Detected(1):               %E%d%N\r\n",\r
     PCIE_CAP_PWR_FLT_DETECTED (PcieSlotStatus)\r
    );\r
-  Print (\r
-    L"  MRL Sensor Changed(2):                 %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  MRL Sensor Changed(2):                 %E%d%N\r\n",\r
     PCIE_CAP_MRL_SENSOR_CHANGED (PcieSlotStatus)\r
    );\r
-  Print (\r
-    L"  Presence Detect Changed(3):            %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Presence Detect Changed(3):            %E%d%N\r\n",\r
     PCIE_CAP_PRES_DETECT_CHANGED (PcieSlotStatus)\r
    );\r
-  Print (\r
-    L"  Command Completed(4):                  %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Command Completed(4):                  %E%d%N\r\n",\r
     PCIE_CAP_COMM_COMPLETED (PcieSlotStatus)\r
    );\r
-  Print (L"  MRL Sensor State(5):                   %EMRL ");\r
+  ShellPrintEx (-1, -1, L"  MRL Sensor State(5):                   %EMRL ");\r
   if (PCIE_CAP_MRL_SENSOR_STATE (PcieSlotStatus)) {\r
-    Print (L" Opened%N\n");\r
+    ShellPrintEx (-1, -1, L" Opened%N\r\n");\r
   } else {\r
-    Print (L" Closed%N\n");\r
+    ShellPrintEx (-1, -1, L" Closed%N\r\n");\r
   }\r
-  Print (L"  Presence Detect State(6):              ");\r
+  ShellPrintEx (-1, -1, L"  Presence Detect State(6):              ");\r
   if (PCIE_CAP_PRES_DETECT_STATE (PcieSlotStatus)) {\r
-    Print (L"%ECard Present in slot%N\n");\r
+    ShellPrintEx (-1, -1, L"%ECard Present in slot%N\r\n");\r
   } else {\r
-    Print (L"%ESlot Empty%N\n");\r
+    ShellPrintEx (-1, -1, L"%ESlot Empty%N\r\n");\r
   }\r
-  Print (L"  Electromechanical Interlock Status(7): %EElectromechanical Interlock ");\r
+  ShellPrintEx (-1, -1, L"  Electromechanical Interlock Status(7): %EElectromechanical Interlock ");\r
   if (PCIE_CAP_ELEC_INTERLOCK_STATE (PcieSlotStatus)) {\r
-    Print (L"Engaged%N\n");\r
+    ShellPrintEx (-1, -1, L"Engaged%N\r\n");\r
   } else {\r
-    Print (L"Disengaged%N\n");\r
+    ShellPrintEx (-1, -1, L"Disengaged%N\r\n");\r
   }\r
-  Print (\r
-    L"  Data Link Layer State Changed(8):      %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  Data Link Layer State Changed(8):      %E%d%N\r\n",\r
     PCIE_CAP_DLINK_STAT_CHANGED (PcieSlotStatus)\r
    );\r
   return EFI_SUCCESS;\r
@@ -4465,24 +4510,24 @@ ExplainPcieRootControl (
 \r
   PcieRootControl = PciExpressCap->RootControl;\r
 \r
-  Print (\r
-    L"  System Error on Correctable Error Enable(0):  %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  System Error on Correctable Error Enable(0):  %E%d%N\r\n",\r
     PCIE_CAP_SYSERR_ON_CORERR_EN (PcieRootControl)\r
    );\r
-  Print (\r
-    L"  System Error on Non-Fatal Error Enable(1):    %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  System Error on Non-Fatal Error Enable(1):    %E%d%N\r\n",\r
     PCIE_CAP_SYSERR_ON_NONFATERR_EN (PcieRootControl)\r
    );\r
-  Print (\r
-    L"  System Error on Fatal Error Enable(2):        %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  System Error on Fatal Error Enable(2):        %E%d%N\r\n",\r
     PCIE_CAP_SYSERR_ON_FATERR_EN (PcieRootControl)\r
    );\r
-  Print (\r
-    L"  PME Interrupt Enable(3):                      %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  PME Interrupt Enable(3):                      %E%d%N\r\n",\r
     PCIE_CAP_PME_INT_ENABLE (PcieRootControl)\r
    );\r
-  Print (\r
-    L"  CRS Software Visibility Enable(4):            %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  CRS Software Visibility Enable(4):            %E%d%N\r\n",\r
     PCIE_CAP_CRS_SW_VIS_ENABLE (PcieRootControl)\r
    );\r
 \r
@@ -4505,8 +4550,8 @@ ExplainPcieRootCap (
 \r
   PcieRootCap = PciExpressCap->RsvdP;\r
 \r
-  Print (\r
-    L"  CRS Software Visibility(0):                   %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  CRS Software Visibility(0):                   %E%d%N\r\n",\r
     PCIE_CAP_CRS_SW_VIS (PcieRootCap)\r
    );\r
 \r
@@ -4529,16 +4574,16 @@ ExplainPcieRootStatus (
 \r
   PcieRootStatus = PciExpressCap->RootStatus;\r
 \r
-  Print (\r
-    L"  PME Requester ID(15:0):                       %E0x%04x%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  PME Requester ID(15:0):                       %E0x%04x%N\r\n",\r
     PCIE_CAP_PME_REQ_ID (PcieRootStatus)\r
    );\r
-  Print (\r
-    L"  PME Status(16):                               %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  PME Status(16):                               %E%d%N\r\n",\r
     PCIE_CAP_PME_STATUS (PcieRootStatus)\r
    );\r
-  Print (\r
-    L"  PME Pending(17):                              %E%d%N\n",\r
+  ShellPrintEx (-1, -1,\r
+    L"  PME Pending(17):                              %E%d%N\r\n",\r
     PCIE_CAP_PME_PENDING (PcieRootStatus)\r
    );\r
   return EFI_SUCCESS;\r
@@ -4584,7 +4629,7 @@ PciExplainPciExpress (
 \r
   DevicePortType = (UINT8) PCIE_CAP_DEVICEPORT_TYPE (PciExpressCap.PcieCapReg);\r
 \r
-  Print (L"\nPci Express device capability structure:\n");\r
+  ShellPrintEx (-1, -1, L"\r\nPci Express device capability structure:\r\n");\r
 \r
   for (Index = 0; PcieExplainList[Index].Type < PcieExplainTypeMax; Index++) {\r
     if (ShellGetExecutionBreakFlag()) {\r
@@ -4682,7 +4727,7 @@ PciExplainPciExpress (
   //\r
   // Start outputing PciEx extend space( 0xFF-0xFFF)\r
   //\r
-  Print (L"\n%HStart dumping PCIex extended configuration space (0x100 - 0xFFF).%N\n\n");\r
+  ShellPrintEx (-1, -1, L"\r\n%HStart dumping PCIex extended configuration space (0x100 - 0xFFF).%N\r\n\r\n");\r
 \r
   if (ExRegBuffer != NULL) {\r
     DumpHex (\r