diff options
author | Hao Wu <hao.a.wu@intel.com> | 2017-09-27 19:15:24 +0800 |
---|---|---|
committer | Hao Wu <hao.a.wu@intel.com> | 2017-09-29 09:39:35 +0800 |
commit | 770f3f6144b47b7b52f2fb6b3f7f532630f2fc32 (patch) | |
tree | 78aa1a01788a18f2b8147d33c981f930c5f6a910 | |
parent | de15f8b6eff892be8872f14fa000e425e82f9cff (diff) | |
download | edk2-770f3f6144b47b7b52f2fb6b3f7f532630f2fc32.zip edk2-770f3f6144b47b7b52f2fb6b3f7f532630f2fc32.tar.gz edk2-770f3f6144b47b7b52f2fb6b3f7f532630f2fc32.tar.bz2 |
ShellPkg/dh: Add the 'dh' dump support for Partition Info protocol
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>
3 files changed, 89 insertions, 1 deletions
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c index 489decf..1510316 100644 --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c @@ -1933,6 +1933,87 @@ ERROR_EXIT: return NULL;
}
+/**
+ Function to dump information about Partition Information protocol.
+
+ This will allocate the return buffer from boot services pool.
+
+ @param[in] TheHandle The handle that has the protocol installed.
+ @param[in] Verbose TRUE for additional information, FALSE otherwise.
+
+ @retval A pointer to a string containing the information.
+**/
+CHAR16*
+EFIAPI
+PartitionInfoProtocolDumpInformation (
+ IN CONST EFI_HANDLE TheHandle,
+ IN CONST BOOLEAN Verbose
+ )
+{
+ EFI_STATUS Status;
+ EFI_PARTITION_INFO_PROTOCOL *PartitionInfo;
+ CHAR16 *PartitionType;
+ CHAR16 *EfiSystemPartition;
+ CHAR16 *RetVal;
+
+ if (!Verbose) {
+ return NULL;
+ }
+
+ Status = gBS->OpenProtocol (
+ TheHandle,
+ &gEfiPartitionInfoProtocolGuid,
+ (VOID**)&PartitionInfo,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ if (EFI_ERROR (Status)) {
+ return NULL;
+ }
+
+ HandleParsingHiiInit ();
+
+ switch (PartitionInfo->Type) {
+ case PARTITION_TYPE_OTHER:
+ PartitionType = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_PARTINFO_DUMP_TYPE_OTHER), NULL);
+ break;
+ case PARTITION_TYPE_MBR:
+ PartitionType = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_PARTINFO_DUMP_TYPE_MBR), NULL);
+ break;
+ case PARTITION_TYPE_GPT:
+ PartitionType = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_PARTINFO_DUMP_TYPE_GPT), NULL);
+ break;
+ default:
+ PartitionType = NULL;
+ break;
+ }
+ if (PartitionType == NULL) {
+ return NULL;
+ }
+
+ if (PartitionInfo->System == 1) {
+ EfiSystemPartition = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_PARTINFO_DUMP_EFI_SYS_PART), NULL);
+ } else {
+ EfiSystemPartition = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_PARTINFO_DUMP_NOT_EFI_SYS_PART), NULL);
+ }
+ if (EfiSystemPartition == NULL) {
+ SHELL_FREE_NON_NULL (PartitionType);
+ return NULL;
+ }
+
+ RetVal = CatSPrint (
+ NULL,
+ L"%s\r\n%s",
+ PartitionType,
+ EfiSystemPartition
+ );
+
+ SHELL_FREE_NON_NULL (EfiSystemPartition);
+ SHELL_FREE_NON_NULL (PartitionType);
+ return RetVal;
+}
+
//
// Put the information on the NT32 protocol GUIDs here so we are not dependant on the Nt32Pkg
//
@@ -2174,7 +2255,7 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = { {STRING_TOKEN(STR_UFS_DEV_CONFIG), &gEfiUfsDeviceConfigProtocolGuid, NULL},
{STRING_TOKEN(STR_HTTP_BOOT_CALL), &gEfiHttpBootCallbackProtocolGuid, NULL},
{STRING_TOKEN(STR_RESET_NOTI), &gEfiResetNotificationProtocolGuid, NULL},
- {STRING_TOKEN(STR_PARTITION_INFO), &gEfiPartitionInfoProtocolGuid, NULL},
+ {STRING_TOKEN(STR_PARTITION_INFO), &gEfiPartitionInfoProtocolGuid, PartitionInfoProtocolDumpInformation},
{STRING_TOKEN(STR_HII_POPUP), &gEfiHiiPopupProtocolGuid, NULL},
//
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h index cf84965..68bb00c 100644 --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h @@ -138,6 +138,7 @@ #include <Protocol/AdapterInformation.h>
#include <Protocol/ShellDynamicCommand.h>
#include <Protocol/DiskInfo.h>
+#include <Protocol/PartitionInfo.h>
#include <Library/HandleParsingLib.h>
#include <Library/UefiBootServicesTableLib.h>
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni index d5e0c79..9076a54 100644 --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni @@ -522,3 +522,9 @@ " AttributesSetting : %%H%s%%N\r\n"
" Compatibilities : %%H0x%L016x%%N\r\n"
" LowestSupportedImageVersion : %%H0x%08x%%N\r\n"
+
+#string STR_PARTINFO_DUMP_TYPE_OTHER #language en-US " Partition Type : Other"
+#string STR_PARTINFO_DUMP_TYPE_MBR #language en-US " Partition Type : MBR"
+#string STR_PARTINFO_DUMP_TYPE_GPT #language en-US " Partition Type : GPT"
+#string STR_PARTINFO_DUMP_EFI_SYS_PART #language en-US " EFI System Partition : Yes"
+#string STR_PARTINFO_DUMP_NOT_EFI_SYS_PART #language en-US " EFI System Partition : No"
|