]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg/dh: Add the 'dh' dump support for Partition Info protocol
authorHao Wu <hao.a.wu@intel.com>
Wed, 27 Sep 2017 11:15:24 +0000 (19:15 +0800)
committerHao Wu <hao.a.wu@intel.com>
Fri, 29 Sep 2017 01:39:35 +0000 (09:39 +0800)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=655

V2 change:
Put some strings into the UNI file for localization.

The dump information will include:
a. The type of the partition (Mbr, Gpt or Other);
b. Whether the partition is an EFI System Partition.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h
ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni

index 489decfaf80bcbe2903ebc5ec609dccb9ddcb72f..15103160d9b0d2f96312eb9a01e6889413895cf7 100644 (file)
@@ -1933,6 +1933,87 @@ ERROR_EXIT:
   return NULL;\r
 }\r
 \r
+/**\r
+  Function to dump information about Partition Information protocol.\r
+\r
+  This will allocate the return buffer from boot services pool.\r
+\r
+  @param[in] TheHandle      The handle that has the protocol installed.\r
+  @param[in] Verbose        TRUE for additional information, FALSE otherwise.\r
+\r
+  @retval A pointer to a string containing the information.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+PartitionInfoProtocolDumpInformation (\r
+  IN CONST EFI_HANDLE TheHandle,\r
+  IN CONST BOOLEAN    Verbose\r
+  )\r
+{\r
+  EFI_STATUS                      Status;\r
+  EFI_PARTITION_INFO_PROTOCOL     *PartitionInfo;\r
+  CHAR16                          *PartitionType;\r
+  CHAR16                          *EfiSystemPartition;\r
+  CHAR16                          *RetVal;\r
+\r
+  if (!Verbose) {\r
+    return NULL;\r
+  }\r
+\r
+  Status = gBS->OpenProtocol (\r
+                TheHandle,\r
+                &gEfiPartitionInfoProtocolGuid,\r
+                (VOID**)&PartitionInfo,\r
+                gImageHandle,\r
+                NULL,\r
+                EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                );\r
+  if (EFI_ERROR (Status)) {\r
+    return NULL;\r
+  }\r
+\r
+  HandleParsingHiiInit ();\r
+\r
+  switch (PartitionInfo->Type) {\r
+  case PARTITION_TYPE_OTHER:\r
+    PartitionType = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_PARTINFO_DUMP_TYPE_OTHER), NULL);\r
+    break;\r
+  case PARTITION_TYPE_MBR:\r
+    PartitionType = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_PARTINFO_DUMP_TYPE_MBR), NULL);\r
+    break;\r
+  case PARTITION_TYPE_GPT:\r
+    PartitionType = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_PARTINFO_DUMP_TYPE_GPT), NULL);\r
+    break;\r
+  default:\r
+    PartitionType = NULL;\r
+    break;\r
+  }\r
+  if (PartitionType == NULL) {\r
+    return NULL;\r
+  }\r
+\r
+  if (PartitionInfo->System == 1) {\r
+    EfiSystemPartition = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_PARTINFO_DUMP_EFI_SYS_PART), NULL);\r
+  } else {\r
+    EfiSystemPartition = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_PARTINFO_DUMP_NOT_EFI_SYS_PART), NULL);\r
+  }\r
+  if (EfiSystemPartition == NULL) {\r
+    SHELL_FREE_NON_NULL (PartitionType);\r
+    return NULL;\r
+  }\r
+\r
+  RetVal = CatSPrint (\r
+             NULL,\r
+             L"%s\r\n%s",\r
+             PartitionType,\r
+             EfiSystemPartition\r
+             );\r
+\r
+  SHELL_FREE_NON_NULL (EfiSystemPartition);\r
+  SHELL_FREE_NON_NULL (PartitionType);\r
+  return RetVal;\r
+}\r
+\r
 //\r
 // Put the information on the NT32 protocol GUIDs here so we are not dependant on the Nt32Pkg\r
 //\r
@@ -2174,7 +2255,7 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = {
   {STRING_TOKEN(STR_UFS_DEV_CONFIG),        &gEfiUfsDeviceConfigProtocolGuid,                  NULL},\r
   {STRING_TOKEN(STR_HTTP_BOOT_CALL),        &gEfiHttpBootCallbackProtocolGuid,                 NULL},\r
   {STRING_TOKEN(STR_RESET_NOTI),            &gEfiResetNotificationProtocolGuid,                NULL},\r
-  {STRING_TOKEN(STR_PARTITION_INFO),        &gEfiPartitionInfoProtocolGuid,                    NULL},\r
+  {STRING_TOKEN(STR_PARTITION_INFO),        &gEfiPartitionInfoProtocolGuid,                    PartitionInfoProtocolDumpInformation},\r
   {STRING_TOKEN(STR_HII_POPUP),             &gEfiHiiPopupProtocolGuid,                         NULL},\r
 \r
 //\r
index cf849658aa1870c956759b942d98d5041269636d..68bb00c620056f691d1d64472f9a07d4f7161032 100644 (file)
 #include <Protocol/AdapterInformation.h>\r
 #include <Protocol/ShellDynamicCommand.h>\r
 #include <Protocol/DiskInfo.h>\r
+#include <Protocol/PartitionInfo.h>\r
 \r
 #include <Library/HandleParsingLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
index d5e0c79f3f491c126e0764bef5b598a15d060568..9076a54159bed295c66b873c2f0063683e4e6335 100644 (file)
                                                                         "    AttributesSetting           : %%H%s%%N\r\n"\r
                                                                         "    Compatibilities             : %%H0x%L016x%%N\r\n"\r
                                                                         "    LowestSupportedImageVersion : %%H0x%08x%%N\r\n"\r
+\r
+#string STR_PARTINFO_DUMP_TYPE_OTHER        #language en-US "  Partition Type       : Other"\r
+#string STR_PARTINFO_DUMP_TYPE_MBR          #language en-US "  Partition Type       : MBR"\r
+#string STR_PARTINFO_DUMP_TYPE_GPT          #language en-US "  Partition Type       : GPT"\r
+#string STR_PARTINFO_DUMP_EFI_SYS_PART      #language en-US "  EFI System Partition : Yes"\r
+#string STR_PARTINFO_DUMP_NOT_EFI_SYS_PART  #language en-US "  EFI System Partition : No"\r