From nobody Thu Dec 26 12:09:56 2024 Delivered-To: importer@patchew.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; 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 1506059430630855.6781493963935; Thu, 21 Sep 2017 22:50:30 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 42ECD2095E4E5; Thu, 21 Sep 2017 22:47:17 -0700 (PDT) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 3089B2095E4EE for ; Thu, 21 Sep 2017 22:47:14 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP; 21 Sep 2017 22:50:21 -0700 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.7]) by fmsmga006.fm.intel.com with ESMTP; 21 Sep 2017 22:50:20 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,427,1500966000"; d="scan'208";a="154738601" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Fri, 22 Sep 2017 13:50:05 +0800 Message-Id: <20170922055014.27288-6-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.12.2.windows.2 In-Reply-To: <20170922055014.27288-1-ruiyu.ni@intel.com> References: <20170922055014.27288-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 05/14] ShellPkg/dh: Modify the dump of "ImageDevicePath" and "DevicePath" 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: Jaben Carsey , Huajing Li 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" From: Huajing Li Reviewed-by: Ruiyu Ni Cc: Jaben Carsey Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Huajing Li --- .../UefiHandleParsingLib/UefiHandleParsingLib.c | 68 +++++++++++++++---= ---- 1 file changed, 46 insertions(+), 22 deletions(-) diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c b= /ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c index d3ee068eba..1f2ca92bdd 100644 --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c @@ -848,6 +848,50 @@ ConvertDevicePathToShortText( } =20 /** + Function to dump protocol information. + + 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. + @param[in] Protocol The protocol is needed to dump. + + @retval A pointer to a string containing the information. +**/ +STATIC CHAR16* +EFIAPI +DevicePathProtocolDumpInformationEx ( + IN CONST EFI_HANDLE TheHandle, + IN CONST BOOLEAN Verbose, + IN EFI_GUID *Protocol +) +{ + EFI_DEVICE_PATH_PROTOCOL *DevPath; + CHAR16 *DevPathStr; + CHAR16 *DevPathStrTemp; + UINTN Size; + EFI_STATUS Status; + DevPathStr =3D NULL; + DevPathStrTemp =3D NULL; + Status =3D gBS->OpenProtocol(TheHandle, Protocol, (VOID**)&DevPath, gIma= geHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); + if (!EFI_ERROR(Status)) { + DevPathStr =3D ConvertDevicePathToShortText (DevPath, Verbose, 30); + if (Verbose) { + Size =3D StrSize(DevPathStr) + sizeof(CHAR16) * 2; + DevPathStrTemp =3D AllocateZeroPool (Size); + if (DevPathStrTemp !=3D NULL) { + StrnCatS (DevPathStrTemp, Size/sizeof(CHAR16), L" ", 2); + StrnCatS (DevPathStrTemp, Size/sizeof(CHAR16), DevPathStr, StrLen = (DevPathStr)); + } + FreePool (DevPathStr); + DevPathStr =3D DevPathStrTemp; + } + gBS->CloseProtocol(TheHandle, Protocol, gImageHandle, NULL); + } + return DevPathStr; +} + +/** Function to dump information about DevicePath protocol. =20 This will allocate the return buffer from boot services pool. @@ -864,17 +908,7 @@ DevicePathProtocolDumpInformation( IN CONST BOOLEAN Verbose ) { - EFI_DEVICE_PATH_PROTOCOL *DevPath; - CHAR16 *Temp; - EFI_STATUS Status; - Temp =3D NULL; - - Status =3D gBS->OpenProtocol(TheHandle, &gEfiDevicePathProtocolGuid, (VO= ID**)&DevPath, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); - if (!EFI_ERROR(Status)) { - Temp =3D ConvertDevicePathToShortText (DevPath, Verbose, 30); - gBS->CloseProtocol(TheHandle, &gEfiDevicePathProtocolGuid, gImageHandl= e, NULL); - } - return (Temp); + return DevicePathProtocolDumpInformationEx (TheHandle, Verbose, &gEfiDev= icePathProtocolGuid); } =20 /** @@ -894,17 +928,7 @@ LoadedImageDevicePathProtocolDumpInformation( IN CONST BOOLEAN Verbose ) { - EFI_DEVICE_PATH_PROTOCOL *DevPath; - CHAR16 *Temp; - EFI_STATUS Status; - Temp =3D NULL; - - Status =3D gBS->OpenProtocol(TheHandle, &gEfiLoadedImageDevicePathProtoc= olGuid, (VOID**)&DevPath, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCO= L); - if (!EFI_ERROR(Status)) { - Temp =3D ConvertDevicePathToShortText (DevPath, Verbose, 30); - gBS->CloseProtocol(TheHandle, &gEfiDevicePathProtocolGuid, gImageHandl= e, NULL); - } - return (Temp); + return DevicePathProtocolDumpInformationEx (TheHandle, Verbose, &gEfiLoa= dedImageDevicePathProtocolGuid); } =20 /** --=20 2.12.2.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel