* [PATCH] ShellPkg/dh: Add the 'dh' dump support for Partition Info protocol
@ 2017-09-27 12:43 Hao Wu
2017-09-27 14:08 ` Carsey, Jaben
0 siblings, 1 reply; 2+ messages in thread
From: Hao Wu @ 2017-09-27 12:43 UTC (permalink / raw)
To: edk2-devel; +Cc: Hao Wu, Ruiyu Ni, Jaben Carsey
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=655
The dump information will include:
a. The type of the partition (Mbr, Gpt or Other);
b. Whether the partition is an EFI System Partition.
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
.../UefiHandleParsingLib/UefiHandleParsingLib.c | 68 ++++++++++++++++++++++
.../UefiHandleParsingLib/UefiHandleParsingLib.h | 1 +
.../UefiHandleParsingLib/UefiHandleParsingLib.inf | 1 +
.../UefiHandleParsingLib/UefiHandleParsingLib.uni | 6 ++
4 files changed, 76 insertions(+)
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
index d12466c7b0..1a56a699ba 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
@@ -1933,6 +1933,69 @@ 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 *GetString;
+ CHAR16 *RetVal;
+ CONST CHAR16 *PartitionType;
+
+ 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 ();
+ GetString = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_PARTINFO_DUMP_MAIN), NULL);
+ if (GetString == NULL) {
+ return NULL;
+ }
+
+ switch (PartitionInfo->Type) {
+ case PARTITION_TYPE_OTHER: PartitionType = L"Other"; break;
+ case PARTITION_TYPE_MBR: PartitionType = L"Mbr"; break;
+ case PARTITION_TYPE_GPT: PartitionType = L"Gpt"; break;
+ default: return NULL;
+ }
+
+ RetVal = CatSPrint (
+ NULL,
+ GetString,
+ PartitionType,
+ PartitionInfo->System == 1 ? L"Yes" : L"No"
+ );
+
+ SHELL_FREE_NON_NULL (GetString);
+ return RetVal;
+}
+
//
// Put the information on the NT32 protocol GUIDs here so we are not dependant on the Nt32Pkg
//
@@ -2147,6 +2210,11 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = {
{STRING_TOKEN(STR_ADAPTER_INFO), &gEfiAdapterInformationProtocolGuid, AdapterInformationDumpInformation},
//
+// UEFI 2.7
+//
+ {STRING_TOKEN(STR_PARTITION_INFO), &gEfiPartitionInfoProtocolGuid, PartitionInfoProtocolDumpInformation},
+
+//
// PI Spec ones
//
{STRING_TOKEN(STR_IDE_CONT_INIT), &gEfiIdeControllerInitProtocolGuid, NULL},
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h
index cf849658aa..68bb00c620 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.inf b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
index 4c1c3d3846..ee1b85552b 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
@@ -292,6 +292,7 @@
gEfiHttpProtocolGuid ## UNDEFINED
gEfiHttpUtilitiesProtocolGuid ## UNDEFINED
gEfiRestProtocolGuid ## UNDEFINED
+ gEfiPartitionInfoProtocolGuid ## CONSUMES
[Guids]
gEfiFileInfoGuid ## UNDEFINED
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni
index f49ca94623..1f2cc4a6f9 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni
@@ -152,6 +152,9 @@
#string STR_SHELL #language en-US "Shell"
#string STR_SHELL_DYNAMIC #language en-US "ShellDynamicCommand"
+// Partition Information
+#string STR_PARTITION_INFO #language en-US "PartitionInformation"
+
#string STR_EFI_GLOBAL_VARIABLE #language en-US "EFIGlobalVariable"
// NT32 emulation
@@ -478,3 +481,6 @@
" AttributesSetting : %%H%s%%N\r\n"
" Compatibilities : %%H0x%L016x%%N\r\n"
" LowestSupportedImageVersion : %%H0x%08x%%N\r\n"
+
+#string STR_PARTINFO_DUMP_MAIN #language en-US " Partition Type : %s\r\n"
+ " EFI System Partition : %s"
--
2.12.0.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ShellPkg/dh: Add the 'dh' dump support for Partition Info protocol
2017-09-27 12:43 [PATCH] ShellPkg/dh: Add the 'dh' dump support for Partition Info protocol Hao Wu
@ 2017-09-27 14:08 ` Carsey, Jaben
0 siblings, 0 replies; 2+ messages in thread
From: Carsey, Jaben @ 2017-09-27 14:08 UTC (permalink / raw)
To: Wu, Hao A, edk2-devel@lists.01.org; +Cc: Ni, Ruiyu
> -----Original Message-----
> From: Wu, Hao A
> Sent: Wednesday, September 27, 2017 5:43 AM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A <hao.a.wu@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>;
> Carsey, Jaben <jaben.carsey@intel.com>
> Subject: [PATCH] ShellPkg/dh: Add the 'dh' dump support for Partition Info
> protocol
> Importance: High
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=655
>
> The dump information will include:
> a. The type of the partition (Mbr, Gpt or Other);
> b. Whether the partition is an EFI System Partition.
>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Jaben Carsey <jaben.carsey@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Hao Wu <hao.a.wu@intel.com>
> ---
> .../UefiHandleParsingLib/UefiHandleParsingLib.c | 68
> ++++++++++++++++++++++
> .../UefiHandleParsingLib/UefiHandleParsingLib.h | 1 +
> .../UefiHandleParsingLib/UefiHandleParsingLib.inf | 1 +
> .../UefiHandleParsingLib/UefiHandleParsingLib.uni | 6 ++
> 4 files changed, 76 insertions(+)
>
> diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
> b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
> index d12466c7b0..1a56a699ba 100644
> --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
> +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
> @@ -1933,6 +1933,69 @@ 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 *GetString;
> + CHAR16 *RetVal;
> + CONST CHAR16 *PartitionType;
> +
> + 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 ();
> + GetString = HiiGetString (mHandleParsingHiiHandle,
> STRING_TOKEN(STR_PARTINFO_DUMP_MAIN), NULL);
> + if (GetString == NULL) {
> + return NULL;
> + }
> +
> + switch (PartitionInfo->Type) {
> + case PARTITION_TYPE_OTHER: PartitionType = L"Other"; break;
> + case PARTITION_TYPE_MBR: PartitionType = L"Mbr"; break;
> + case PARTITION_TYPE_GPT: PartitionType = L"Gpt"; break;
> + default: return NULL;
> + }
> +
> + RetVal = CatSPrint (
> + NULL,
> + GetString,
> + PartitionType,
> + PartitionInfo->System == 1 ? L"Yes" : L"No"
> + );
This section needs to use proper localization. The strings should be from UNI files, not hard coded here.
> +
> + SHELL_FREE_NON_NULL (GetString);
> + return RetVal;
> +}
> +
> //
> // Put the information on the NT32 protocol GUIDs here so we are not
> dependant on the Nt32Pkg
> //
> @@ -2147,6 +2210,11 @@ STATIC CONST GUID_INFO_BLOCK
> mGuidStringList[] = {
> {STRING_TOKEN(STR_ADAPTER_INFO),
> &gEfiAdapterInformationProtocolGuid,
> AdapterInformationDumpInformation},
>
> //
> +// UEFI 2.7
> +//
> + {STRING_TOKEN(STR_PARTITION_INFO),
> &gEfiPartitionInfoProtocolGuid,
> PartitionInfoProtocolDumpInformation},
> +
> +//
> // PI Spec ones
> //
> {STRING_TOKEN(STR_IDE_CONT_INIT),
> &gEfiIdeControllerInitProtocolGuid, NULL},
> diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h
> b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h
> index cf849658aa..68bb00c620 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.inf
> b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
> index 4c1c3d3846..ee1b85552b 100644
> --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
> +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
> @@ -292,6 +292,7 @@
> gEfiHttpProtocolGuid ## UNDEFINED
> gEfiHttpUtilitiesProtocolGuid ## UNDEFINED
> gEfiRestProtocolGuid ## UNDEFINED
> + gEfiPartitionInfoProtocolGuid ## CONSUMES
>
> [Guids]
> gEfiFileInfoGuid ## UNDEFINED
> diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni
> b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni
> index f49ca94623..1f2cc4a6f9 100644
> --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni
> +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni
> @@ -152,6 +152,9 @@
> #string STR_SHELL #language en-US "Shell"
> #string STR_SHELL_DYNAMIC #language en-US
> "ShellDynamicCommand"
>
> +// Partition Information
> +#string STR_PARTITION_INFO #language en-US "PartitionInformation"
> +
> #string STR_EFI_GLOBAL_VARIABLE #language en-US "EFIGlobalVariable"
>
> // NT32 emulation
> @@ -478,3 +481,6 @@
> " AttributesSetting :
> %%H%s%%N\r\n"
> " Compatibilities :
> %%H0x%L016x%%N\r\n"
> " LowestSupportedImageVersion :
> %%H0x%08x%%N\r\n"
> +
> +#string STR_PARTINFO_DUMP_MAIN #language en-US " Partition Type
> : %s\r\n"
> + " EFI System Partition : %s"
> --
> 2.12.0.windows.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-09-27 14:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-27 12:43 [PATCH] ShellPkg/dh: Add the 'dh' dump support for Partition Info protocol Hao Wu
2017-09-27 14:08 ` Carsey, Jaben
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox