From nobody Sat Nov 2 14:29:18 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.zoho.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 1486715028070353.64471807909365; Fri, 10 Feb 2017 00:23:48 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 7E88582020; Fri, 10 Feb 2017 00:23:46 -0800 (PST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 C058981F5F for ; Fri, 10 Feb 2017 00:23:45 -0800 (PST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP; 10 Feb 2017 00:23:43 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.25]) by fmsmga004.fm.intel.com with ESMTP; 10 Feb 2017 00:23:44 -0800 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,140,1484035200"; d="scan'208";a="223619285" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Fri, 10 Feb 2017 16:23:35 +0800 Message-Id: <20170210082335.91020-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.9.0.windows.1 Subject: [edk2] [PATCH] ShellPkg/pci: Report error when invalid value is specified for "-ec" X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 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" Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni Cc: Jaben Carsey Reviewed-by: Jaben Carsey --- ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c | 21 +++++++++++++++--= ---- .../UefiShellDebug1CommandsLib.uni | 2 +- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c b/ShellPkg/L= ibrary/UefiShellDebug1CommandsLib/Pci.c index fb7561f..37f15d6 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c @@ -2726,6 +2726,7 @@ ShellCommandRunPci ( Bus =3D 0; Device =3D 0; Func =3D 0; + EnhancedDump =3D 0xFFFF; if (ShellCommandLineGetFlag(Package, L"-i")) { ExplainData =3D TRUE; } @@ -2807,6 +2808,20 @@ ShellCommandRunPci ( } } =20 + Temp =3D ShellCommandLineGetValue (Package, L"-ec"); + if (Temp !=3D NULL) { + // + // Input converted to hexadecimal number. + // + if (!EFI_ERROR (ShellConvertStringToUint64 (Temp, &RetVal, TRUE, TRU= E))) { + EnhancedDump =3D (UINT16) RetVal; + } else { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV_HEX= ), gShellDebug1HiiHandle, L"pci", Temp); =20 + ShellStatus =3D SHELL_INVALID_PARAMETER; + goto Done; + } + } + // // Find the protocol interface who's in charge of current segment, and= its // bus range covers the current bus @@ -2883,12 +2898,6 @@ ShellCommandRunPci ( // If "-i" appears in command line, interpret data in configuration sp= ace // if (ExplainData) { - EnhancedDump =3D 0xFFFF; - if (ShellCommandLineGetFlag(Package, L"-ec")) { - Temp =3D ShellCommandLineGetValue(Package, L"-ec"); - ASSERT (Temp !=3D NULL); - EnhancedDump =3D (UINT16) ShellHexStrToUintn (Temp); - } Status =3D PciExplainData (&ConfigSpace, Address, IoDev, EnhancedDum= p); } } diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Com= mandsLib.uni b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1C= ommandsLib.uni index 8ea4215..7c0ca98 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLi= b.uni +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLi= b.uni @@ -39,7 +39,7 @@ #string STR_GEN_PCIRBIO_NF #language en-US "%H%s%N: Protocol - PciR= ootBridgeIo not found.\r\n" #string STR_GEN_PCIRBIO_ER #language en-US "%H%s%N: Problem accessi= ng the data using Protocol - PciRootBridgeIo\r\n" #string STR_GEN_PARAM_INV #language en-US "%H%s%N: Invalid argumen= t - '%H%s%N'\r\n" -#string STR_GEN_PARAM_INV_HEX #language en-US "%H%s%N: Invalid paramet= er - '%H%s%N:'. Must be hexadecimal.\r\n" +#string STR_GEN_PARAM_INV_HEX #language en-US "%H%s%N: Invalid paramet= er - '%H%s%N'. Must be hexadecimal.\r\n" #string STR_GEN_PARAM_CONFLICT #language en-US "%H%s%N: Flags conflict = with - '%H%s%N' and '%H%s%N'\r\n" #string STR_GEN_OUT_MEM #language en-US "%H%s%N: Memory allocati= on was not successful.\r\n" #string STR_GEN_MAP_PROTOCOL #language en-US "%H%s%N: Mapped device '= %B%s%N' does not have protocol %B%s%N\r\n" --=20 2.9.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel