From nobody Mon Apr 29 10:40:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1506516201138429.81273532109583; Wed, 27 Sep 2017 05:43:21 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 1BFEA20945BBA; Wed, 27 Sep 2017 05:40:06 -0700 (PDT) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 891D320945BAC for ; Wed, 27 Sep 2017 05:40:04 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Sep 2017 05:43:17 -0700 Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.13]) by FMSMGA003.fm.intel.com with ESMTP; 27 Sep 2017 05:43:16 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=hao.a.wu@intel.com; receiver=edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,445,1500966000"; d="scan'208";a="904374781" From: Hao Wu To: edk2-devel@lists.01.org Date: Wed, 27 Sep 2017 20:43:12 +0800 Message-Id: <20170927124312.27228-1-hao.a.wu@intel.com> X-Mailer: git-send-email 2.12.0.windows.1 Subject: [edk2] [PATCH] ShellPkg/dh: Add the 'dh' dump support for Partition Info protocol X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hao Wu , Ruiyu Ni , Jaben Carsey MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D655 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 Cc: Jaben Carsey Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu --- .../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; } =20 +/** + 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 otherwi= se. + + @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 =3D gBS->OpenProtocol ( + TheHandle, + &gEfiPartitionInfoProtocolGuid, + (VOID**)&PartitionInfo, + gImageHandle, + NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL + ); + if (EFI_ERROR (Status)) { + return NULL; + } + + HandleParsingHiiInit (); + GetString =3D HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_PA= RTINFO_DUMP_MAIN), NULL); + if (GetString =3D=3D NULL) { + return NULL; + } + + switch (PartitionInfo->Type) { + case PARTITION_TYPE_OTHER: PartitionType =3D L"Other"; break; + case PARTITION_TYPE_MBR: PartitionType =3D L"Mbr"; break; + case PARTITION_TYPE_GPT: PartitionType =3D L"Gpt"; break; + default: return NULL; + } + + RetVal =3D CatSPrint ( + NULL, + GetString, + PartitionType, + PartitionInfo->System =3D=3D 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 depen= dant on the Nt32Pkg // @@ -2147,6 +2210,11 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringList[] =3D { {STRING_TOKEN(STR_ADAPTER_INFO), &gEfiAdapterInformationProtoco= lGuid, AdapterInformationDumpInformation}, =20 // +// UEFI 2.7 +// + {STRING_TOKEN(STR_PARTITION_INFO), &gEfiPartitionInfoProtocolGuid= , PartitionInfoProtocolDumpInformation}, + +// // PI Spec ones // {STRING_TOKEN(STR_IDE_CONT_INIT), &gEfiIdeControllerInitProtocol= Guid, 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 #include #include +#include =20 #include #include 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 =20 [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" =20 +// Partition Information +#string STR_PARTITION_INFO #language en-US "PartitionInformation" + #string STR_EFI_GLOBAL_VARIABLE #language en-US "EFIGlobalVariable" =20 // 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 Partiti= on : %s" --=20 2.12.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel