]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg/dh: Modify the dump of PciIo protocol
authorHuajing Li <huajing.li@intel.com>
Thu, 21 Sep 2017 08:26:48 +0000 (16:26 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Mon, 25 Sep 2017 00:32:19 +0000 (08:32 +0800)
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Huajing Li <huajing.li@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni

index 1c62415e8630f60d7756b9be0b5554b50e3366d5..e5b4bea8f69e83a9ee1f844eaa6dc7eddcb0d1f7 100644 (file)
@@ -16,6 +16,7 @@
 \r
 #include "UefiHandleParsingLib.h"\r
 #include "IndustryStandard/Acpi10.h"\r
+#include "IndustryStandard/Pci.h"\r
 #include <PiDxe.h>\r
 #include <Protocol/FirmwareVolume2.h>\r
 \r
@@ -1159,6 +1160,90 @@ DebugSupportProtocolDumpInformation (
   return RetVal;\r
 }\r
 \r
+/**\r
+  Function to dump information about PciIoProtocol.\r
+\r
+  This will allocate the return buffer from boot services pool.\r
+\r
+  @param[in] TheHandle      The handle that has PciRootBridgeIo installed.\r
+  @param[in] Verbose        TRUE for additional information, FALSE otherwise.\r
+\r
+  @retval A poitner to a string containing the information.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+PciIoProtocolDumpInformation (\r
+  IN CONST EFI_HANDLE TheHandle,\r
+  IN CONST BOOLEAN    Verbose\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EFI_PCI_IO_PROTOCOL     *PciIo;\r
+  PCI_TYPE00              Pci;\r
+  UINTN                   Segment;\r
+  UINTN                   Bus;\r
+  UINTN                   Device;\r
+  UINTN                   Function;\r
+  UINTN                   Index;\r
+  CHAR16                  *GetString;\r
+  CHAR16                  *TempRetVal;\r
+  CHAR16                  *RetVal;\r
+\r
+  if (!Verbose) {\r
+    return (NULL);\r
+  }\r
+  RetVal = NULL;\r
+  GetString   = NULL;\r
+  TempRetVal  = NULL;\r
+  Status = gBS->OpenProtocol (\r
+                  TheHandle,\r
+                  &gEfiPciIoProtocolGuid,\r
+                  (VOID**)&PciIo,\r
+                  gImageHandle,\r
+                  NULL,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+\r
+  if (EFI_ERROR(Status)) {\r
+    return NULL;\r
+  }\r
+  PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0, sizeof (Pci), &Pci);\r
+  PciIo->GetLocation (PciIo, &Segment, &Bus, &Device, &Function);\r
+  HandleParsingHiiInit ();\r
+  GetString = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIIO_DUMP_MAIN), NULL);\r
+  if (GetString == NULL) {\r
+    return NULL;\r
+  }\r
+  RetVal = CatSPrint (\r
+            NULL,\r
+            GetString,\r
+            Segment,\r
+            Bus,\r
+            Device,\r
+            Function,\r
+            PciIo->RomSize,\r
+            PciIo->RomImage,\r
+            Pci.Hdr.VendorId,\r
+            Pci.Hdr.DeviceId,\r
+            Pci.Hdr.ClassCode[0],\r
+            Pci.Hdr.ClassCode[1],\r
+            Pci.Hdr.ClassCode[2]\r
+            );\r
+  for (Index = 0; Index < sizeof (Pci); Index ++) {\r
+    if ((Index % 0x10) == 0) {\r
+      TempRetVal = CatSPrint (RetVal, L"\r\n       %02x", *((UINT8 *) (&Pci) + Index));\r
+    } else {\r
+      TempRetVal = CatSPrint (RetVal, L"%02x", *((UINT8 *) (&Pci) + Index));\r
+    }\r
+    FreePool (RetVal);\r
+    RetVal = TempRetVal;\r
+    TempRetVal = NULL;\r
+  }\r
+\r
+  FreePool(GetString);\r
+  return RetVal;\r
+}\r
+\r
 /**\r
   Function to dump information about EfiAdapterInformation Protocol.\r
 \r
@@ -1874,7 +1959,7 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = {
   {STRING_TOKEN(STR_UC),                    &gEfiUnicodeCollationProtocolGuid,                NULL},\r
   {STRING_TOKEN(STR_UC2),                   &gEfiUnicodeCollation2ProtocolGuid,               NULL},\r
   {STRING_TOKEN(STR_PCIRB_IO),              &gEfiPciRootBridgeIoProtocolGuid,                 PciRootBridgeIoDumpInformation},\r
-  {STRING_TOKEN(STR_PCI_IO),                &gEfiPciIoProtocolGuid,                           NULL},\r
+  {STRING_TOKEN(STR_PCI_IO),                &gEfiPciIoProtocolGuid,                           PciIoProtocolDumpInformation},\r
   {STRING_TOKEN(STR_SCSI_PT),               &gEfiScsiPassThruProtocolGuid,                    NULL},\r
   {STRING_TOKEN(STR_SCSI_IO),               &gEfiScsiIoProtocolGuid,                          NULL},\r
   {STRING_TOKEN(STR_SCSI_PT_EXT),           &gEfiExtScsiPassThruProtocolGuid,                 NULL},\r
index 4b0c67b42a6d48f17c1fcb36aaa63f72fed4cc27..59409d9ca02886c9c69bae11bdd3af33d26891b5 100644 (file)
 #string STR_PCIRB_DUMP_IO         #language en-US "      IO  : "\r
 #string STR_PCIRB_DUMP_TITLE      #language en-US "      Type  Flag  Base              Limit             Gran\r\n"\r
                                                   "      ====  ====  ================  ================  ====\r\n"\r
-\r
+#string STR_PCIIO_DUMP_MAIN       #language en-US "     Segment #.....: %02x\r\n"\r
+                                                  "     Bus #.........: %02x\r\n"\r
+                                                  "     Device #......: %02x\r\n"\r
+                                                  "     Function #....: %02x\r\n"\r
+                                                  "     ROM Size......: %lx\r\n"\r
+                                                  "     ROM Location..: %08x\r\n"\r
+                                                  "     Vendor ID.....: %04x\r\n"\r
+                                                  "     Device ID.....: %04x\r\n"\r
+                                                  "     Class Code....: %02x %02x %02x\r\n"\r
+                                                  "     Configuration Header :"\r
 \r
 \r
 #string STR_LI_DUMP_NAME          #language en-US "     Name..........: %%H%s%%N\r\n"\r