From nobody Fri Dec 27 01:32:11 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 15022649874831004.2956033282742; Wed, 9 Aug 2017 00:49:47 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 418E221E1DB41; Wed, 9 Aug 2017 00:47:26 -0700 (PDT) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 5AF1921E1DADE for ; Wed, 9 Aug 2017 00:47:24 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Aug 2017 00:49:42 -0700 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.2]) by fmsmga004.fm.intel.com with ESMTP; 09 Aug 2017 00:49:37 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,346,1498546800"; d="scan'208";a="297694991" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Wed, 9 Aug 2017 15:49:34 +0800 Message-Id: <20170809074935.230172-2-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.12.2.windows.2 In-Reply-To: <20170809074935.230172-1-ruiyu.ni@intel.com> References: <20170809074935.230172-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 1/2] ShellPkg/driver: Show Image Name in non-SFO mode 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: 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 Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Huajing Li Reviewed-by: Ruiyu Ni --- .../Library/UefiShellDriver1CommandsLib/Drivers.c | 99 ++++++++++++++++++= +++- .../UefiShellDriver1CommandsLib.h | 4 + .../UefiShellDriver1CommandsLib.uni | 2 +- 3 files changed, 100 insertions(+), 5 deletions(-) diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Drivers.c b/Shell= Pkg/Library/UefiShellDriver1CommandsLib/Drivers.c index ffdef04352..f3c1476872 100644 --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Drivers.c +++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/Drivers.c @@ -2,7 +2,7 @@ Main file for Drivers shell Driver1 function. =20 (C) Copyright 2012-2015 Hewlett-Packard Development Company, L.P.
- Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.
+ Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -161,6 +161,92 @@ ReturnDriverVersion( } =20 /** + Get image name from Image Handle. + + @param[in] Handle Image Handle + + @return A pointer to the image name as a string. +**/ +CHAR16 * +GetImageNameFromHandle ( + IN CONST EFI_HANDLE Handle + ) +{ + EFI_STATUS Status; + EFI_DRIVER_BINDING_PROTOCOL *DriverBinding; + EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; + EFI_DEVICE_PATH_PROTOCOL *DevPathNode; + EFI_GUID *NameGuid; + CHAR16 *ImageName; + UINTN BufferSize; + UINT32 AuthenticationStatus; + EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv2; + + LoadedImage =3D NULL; + DriverBinding =3D NULL; + ImageName =3D NULL; + + Status =3D gBS->OpenProtocol ( + Handle, + &gEfiDriverBindingProtocolGuid, + (VOID **) &DriverBinding, + NULL, + NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL + ); + if (EFI_ERROR (Status)) { + return NULL; + } + Status =3D gBS->OpenProtocol ( + DriverBinding->ImageHandle, + &gEfiLoadedImageProtocolGuid, + (VOID**)&LoadedImage, + gImageHandle, + NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL + ); + if (!EFI_ERROR (Status)) { + DevPathNode =3D LoadedImage->FilePath; + if (DevPathNode =3D=3D NULL) { + return NULL; + } + while (!IsDevicePathEnd (DevPathNode)) { + NameGuid =3D EfiGetNameGuidFromFwVolDevicePathNode ((MEDIA_FW_VOL_FI= LEPATH_DEVICE_PATH *)DevPathNode); + if (NameGuid !=3D NULL) { + Status =3D gBS->HandleProtocol ( + LoadedImage->DeviceHandle, + &gEfiFirmwareVolume2ProtocolGuid, + &Fv2 + ); + if (!EFI_ERROR (Status)) { + Status =3D Fv2->ReadSection ( + Fv2, + NameGuid, + EFI_SECTION_USER_INTERFACE, + 0, + (VOID **)&ImageName, + &BufferSize, + &AuthenticationStatus + ); + if (!EFI_ERROR (Status)) { + break; + } + ImageName =3D NULL; + } + } + // + // Next device path node + // + DevPathNode =3D NextDevicePathNode (DevPathNode); + } + if (ImageName =3D=3D NULL) { + ImageName =3D ConvertDevicePathToText (LoadedImage->FilePath, TRUE, = TRUE); + } + } + return ImageName; +} + +/** Function for 'drivers' command. =20 @param[in] ImageHandle Handle to the Image (NULL if Internal). @@ -186,6 +272,7 @@ ShellCommandRunDrivers ( CHAR16 *Temp2; CONST CHAR16 *FullDriverName; CHAR16 *TruncatedDriverName; + CHAR16 *ImageName; CHAR16 *FormatString; UINT32 DriverVersion; BOOLEAN DriverConfig; @@ -274,6 +361,7 @@ ShellCommandRunDrivers ( DriverConfig =3D ReturnDriverConfig(*HandleWalker); DriverDiag =3D ReturnDriverDiag (*HandleWalker); FullDriverName =3D GetStringNameFromHandle(*HandleWalker, Language= ); + ImageName =3D GetImageNameFromHandle (*HandleWalker); =20 TruncatedDriverName =3D NULL; if (!SfoFlag && (FullDriverName !=3D NULL)) { @@ -293,15 +381,18 @@ ShellCommandRunDrivers ( DeviceCount, ChildCount, SfoFlag?FullDriverName:TruncatedDriverName, - Temp2=3D=3DNULL?L"":Temp2 - ); + SfoFlag ? (Temp2 =3D=3D NULL ? L"" : Temp2) : (ImageName =3D=3D = NULL ? L"" : ImageName) + ); if (TruncatedDriverName !=3D NULL) { FreePool (TruncatedDriverName); } if (Temp2 !=3D NULL) { FreePool(Temp2); } - =20 + if (ImageName !=3D NULL) { + FreePool (ImageName); + } + if (ShellGetExecutionBreakFlag ()) { ShellStatus =3D SHELL_ABORTED; break; diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1C= ommandsLib.h b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver= 1CommandsLib.h index b061243af7..fa51677aa2 100644 --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1Commands= Lib.h +++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1Commands= Lib.h @@ -24,6 +24,10 @@ =20 #include =20 +#include +#include +#include + #include #include #include diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1C= ommandsLib.uni b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriv= er1CommandsLib.uni index 7a3e61e5fc..5ca548d9f6 100644 --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1Commands= Lib.uni +++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1Commands= Lib.uni @@ -93,7 +93,7 @@ " T D\r\n" " Y C I\r\n" " P F A\r\n" -"DRV VERSION E G G #D #C DRIVER NAME IMAGE PATH= \r\n" +"DRV VERSION E G G #D #C DRIVER NAME IMAGE NAME= \r\n" "=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D =3D =3D =3D =3D=3D=3D =3D=3D=3D =3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D\r\n" #string STR_DRIVERS_ITEM_LINE #language en-US "%H%3x%N %08x %1c %1c %1= c %3d %3d %-35s %s\r\n" #string STR_DRIVERS_ITEM_LINE_SFO #language en-US "DriversInfo,"%x","%x","= %c","%c","%c","%d","%d","%s","%s"\r\n" --=20 2.12.2.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Fri Dec 27 01:32:11 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 150226498955275.63500246862134; Wed, 9 Aug 2017 00:49:49 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 7895921E1DB45; Wed, 9 Aug 2017 00:47:26 -0700 (PDT) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 85C0521E11D94 for ; Wed, 9 Aug 2017 00:47:24 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Aug 2017 00:49:42 -0700 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.2]) by fmsmga004.fm.intel.com with ESMTP; 09 Aug 2017 00:49:38 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,346,1498546800"; d="scan'208";a="297694993" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Wed, 9 Aug 2017 15:49:35 +0800 Message-Id: <20170809074935.230172-3-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.12.2.windows.2 In-Reply-To: <20170809074935.230172-1-ruiyu.ni@intel.com> References: <20170809074935.230172-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 2/2] ShellPkg/driver: Show "-" in non-SFO mode 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: 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 The patch shows "X"/"-" instead of "Y"/"N" in column "CFG" and "DIAG". The patch shows "-" instead of "0" in column "#D" and "#C". Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Huajing Li Reviewed-by: Ruiyu Ni --- .../Library/UefiShellDriver1CommandsLib/Drivers.c | 49 +++++++++++++++---= ---- .../UefiShellDriver1CommandsLib.uni | 12 +++--- 2 files changed, 41 insertions(+), 20 deletions(-) diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Drivers.c b/Shell= Pkg/Library/UefiShellDriver1CommandsLib/Drivers.c index f3c1476872..4d876bb108 100644 --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Drivers.c +++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/Drivers.c @@ -269,6 +269,8 @@ ShellCommandRunDrivers ( EFI_HANDLE *HandleWalker; UINTN ChildCount; UINTN DeviceCount; + CHAR16 ChildCountStr[3]; + CHAR16 DeviceCountStr[3]; CHAR16 *Temp2; CONST CHAR16 *FullDriverName; CHAR16 *TruncatedDriverName; @@ -363,26 +365,45 @@ ShellCommandRunDrivers ( FullDriverName =3D GetStringNameFromHandle(*HandleWalker, Language= ); ImageName =3D GetImageNameFromHandle (*HandleWalker); =20 + UnicodeValueToStringS (ChildCountStr, sizeof (ChildCountStr), 0,= ChildCount, 0); + UnicodeValueToStringS (DeviceCountStr, sizeof (DeviceCountStr), 0,= DeviceCount, 0); TruncatedDriverName =3D NULL; if (!SfoFlag && (FullDriverName !=3D NULL)) { TruncatedDriverName =3D AllocateZeroPool ((MAX_LEN_DRIVER_NAME += 1) * sizeof (CHAR16)); StrnCpyS (TruncatedDriverName, MAX_LEN_DRIVER_NAME + 1, FullDriv= erName, MAX_LEN_DRIVER_NAME); } =20 - ShellPrintEx( - -1, - -1, - FormatString, - ConvertHandleToHandleIndex(*HandleWalker), - DriverVersion, - ChildCount > 0?L'B':(DeviceCount > 0?L'D':L'?'), - DriverConfig?L'Y':L'N', - DriverDiag?L'Y':L'N', - DeviceCount, - ChildCount, - SfoFlag?FullDriverName:TruncatedDriverName, - SfoFlag ? (Temp2 =3D=3D NULL ? L"" : Temp2) : (ImageName =3D=3D = NULL ? L"" : ImageName) - ); + if (!SfoFlag) { + ShellPrintEx ( + -1, + -1, + FormatString, + ConvertHandleToHandleIndex (*HandleWalker), + DriverVersion, + ChildCount > 0 ? L'B' : (DeviceCount > 0 ? L'D' : L'?'), + DriverConfig ? L'X' : L'-', + DriverDiag ? L'X' : L'-', + DeviceCount > 0 ? DeviceCountStr : L"-", + ChildCount > 0 ? ChildCountStr : L"-", + TruncatedDriverName, + ImageName =3D=3D NULL ? L"" : ImageName + ); + } else { + ShellPrintEx ( + -1, + -1, + FormatString, + ConvertHandleToHandleIndex (*HandleWalker), + DriverVersion, + ChildCount > 0 ? L'B' : (DeviceCount > 0 ? L'D' : L'?'), + DriverConfig ? L'Y' : L'N', + DriverDiag ? L'Y' : L'N', + DeviceCount, + ChildCount, + FullDriverName, + Temp2 =3D=3D NULL ? L"" : Temp2 + ); + } if (TruncatedDriverName !=3D NULL) { FreePool (TruncatedDriverName); } diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1C= ommandsLib.uni b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriv= er1CommandsLib.uni index 5ca548d9f6..05101f3782 100644 --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1Commands= Lib.uni +++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1Commands= Lib.uni @@ -90,12 +90,12 @@ #string STR_DEVICES_ITEM_LINE_SFO #language en-US "DevicesInfo,"%x","%c","= %c","%c","%d","%d","%d","%s"\r\n" =20 #string STR_DRIVERS_HEADER_LINES #language en-US "%N" -" T D\r\n" -" Y C I\r\n" -" P F A\r\n" -"DRV VERSION E G G #D #C DRIVER NAME IMAGE NAME= \r\n" -"=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D =3D =3D =3D =3D=3D=3D =3D=3D=3D =3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D\r\n" -#string STR_DRIVERS_ITEM_LINE #language en-US "%H%3x%N %08x %1c %1c %1= c %3d %3d %-35s %s\r\n" +"%H T D%N\r\n" +"%HD Y C I%N\r\n" +"%HR P F A%N\r\n" +"%HV VERSION E G G #D #C DRIVER NAME IMAGE NAME%= N\r\n" +"=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D =3D =3D =3D =3D=3D =3D=3D =3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D\r\n" +#string STR_DRIVERS_ITEM_LINE #language en-US "%H%2x%N %08x %1c %1c %1= c %2s %2s %-35s %s\r\n" #string STR_DRIVERS_ITEM_LINE_SFO #language en-US "DriversInfo,"%x","%x","= %c","%c","%c","%d","%d","%s","%s"\r\n" =20 #string STR_DH_OUTPUT_DECODE #language en-US "%s: %g\r\n" --=20 2.12.2.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel