From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web11.12190.1591929661600266445 for ; Thu, 11 Jun 2020 19:41:01 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=XfXOqdGV; spf=pass (domain: intel.com, ip: 134.134.136.126, mailfrom: zhichao.gao@intel.com) IronPort-SDR: 1/O4lLOeVAEMgvNJdMoPvSmxuxW7QmDBpQpxM/oj1QDuWWbQ1aPSUpUdHM2lBVXPazLHR7lxqC zttFAR0iXNRg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2020 19:41:01 -0700 IronPort-SDR: kqWV0Xqh/lB+yTqqfa7H2r21jWOCT1PontoQLtnimrMB6JwwmRjDLwZfSB2BOQqGlyA2H4738g x5PjBFV2OPWg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,501,1583222400"; d="scan'208";a="271778774" Received: from orsmsx102.amr.corp.intel.com ([10.22.225.129]) by orsmga003.jf.intel.com with ESMTP; 11 Jun 2020 19:41:01 -0700 Received: from orsmsx112.amr.corp.intel.com (10.22.240.13) by ORSMSX102.amr.corp.intel.com (10.22.225.129) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 11 Jun 2020 19:41:00 -0700 Received: from ORSEDG002.ED.cps.intel.com (10.7.248.5) by ORSMSX112.amr.corp.intel.com (10.22.240.13) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 11 Jun 2020 19:41:00 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.104) by edgegateway.intel.com (134.134.137.101) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 11 Jun 2020 19:41:00 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nfFoeuslwLxOsO55L5dzrdlcFUI3dYaVPWwEqQTzkBHgBqMPF7/gMy0G2vIwSRS+0t/AfPdeyzyHwiM0DrKVnmGgHA6CyloTcU+fUOvkahgFsck97KBwj32HfQE366yBgui9/lszy3eEKBarjpuABhG8e4RQ+rcsxQTvWtis1IrI8yzL7gmeJJViiKC9hXxSR42oz9I6+OWFTht/taCFKhWjriIwkLgcENFenifFf/egouNefPKGqg5jaJLsELEhJGcU7z9U+XX6KDdMOHoo7v76zl/mDQXxY6x+aiGN8XLqIVJlnDLtI4sWqB5a8fOpbU1QshWGiuCjaRtrndb+RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kIQ2C7MG2SIhgkXYJaOKQQQGwNYD5qxNBm0qa9UyQRY=; b=kY1AAvGBmppGmrrA/WQ7qFVgzRkNyexSqB29LOAgsS6bqnUfwSyXplVQEVlqd1f/YPiDJ+TK+/WqpT8Jd5qdsXngQivkKBXplvo5MiFaZW4BpdUQFO6XazjT2/GzIRZYcsWnfUfCp+crBFT5qWjOS7LMH/iE47lpPAXGK9MS+cgpvkGWKtaFHT6Ns+EEtsl8XHpZD0IduZDEpWYrNSK7aIRJ7PlyJJIg2kVULE8rJhbHQ5VM9i98oQC+hj83eoOsxSNHUfcSz44a85vOjkAvFTv7un1reBETzKSRtozqLmyFi7MZBE6YcYQobBriLxibMsMjGMrwFycQFAM9A1UisA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kIQ2C7MG2SIhgkXYJaOKQQQGwNYD5qxNBm0qa9UyQRY=; b=XfXOqdGVxamMOLwGJONy9bVvQRGaayDRR95mzWEepfT1Nxn7IsoHReiJj0xHSNgcTDxESMry3vrXBTE/Qs7cco6WWCu3DSH2Xrsf4Iiq3ap4svyROcPC5u53+d+GeUpL7xZpg8yvO09wOi95wgJQmQSGvoqh6U0cbFiqrHWFpq8= Received: from DM6PR11MB4425.namprd11.prod.outlook.com (2603:10b6:5:1d9::31) by DM6PR11MB4753.namprd11.prod.outlook.com (2603:10b6:5:2ac::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.20; Fri, 12 Jun 2020 02:40:58 +0000 Received: from DM6PR11MB4425.namprd11.prod.outlook.com ([fe80::ad34:e1fc:2e7b:d124]) by DM6PR11MB4425.namprd11.prod.outlook.com ([fe80::ad34:e1fc:2e7b:d124%3]) with mapi id 15.20.3088.023; Fri, 12 Jun 2020 02:40:58 +0000 From: "Gao, Zhichao" To: "devel@edk2.groups.io" , "Tomas.Pilar@arm.com" CC: "nd@arm.com" , "Ni, Ray" Subject: Re: [edk2-devel] [PATCH v2 4/6] ShellPkg/AcpiView: Move parameter parsing Thread-Topic: [edk2-devel] [PATCH v2 4/6] ShellPkg/AcpiView: Move parameter parsing Thread-Index: AQHWL6AIyZDZKEQznUuuThLMlV7A46jUStPg Date: Fri, 12 Jun 2020 02:40:58 +0000 Message-ID: References: <20200521184421.2222-1-Tomas.Pilar@arm.com> <20200521184421.2222-5-Tomas.Pilar@arm.com> In-Reply-To: <20200521184421.2222-5-Tomas.Pilar@arm.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.2.0.6 authentication-results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.102.204.38] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: d724a0cd-23b2-4904-a841-08d80e7a09f6 x-ms-traffictypediagnostic: DM6PR11MB4753: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1247; x-forefront-prvs: 0432A04947 x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: jrIaW4XyLkA++QlqxcclsScMMIdU5WnwKVk0LTISr0L+eab9hfcSR52dvLEFA4vGpO+NK26ZSLgS14xYnYSkteK6S7PbQIjhB7adVNfcaUzctqjaHJVBkR1Pe7ZeYElq00jekEB5zx+CeCBtQZXuMILMKGKe4ISmcqQE4SWwKMKS9d3Vy9vJMn2l6pvvxQSA0dywg8Ydt58pd2bUWyqo+2+lVSk0DIwNcmI8x3HDWjYPXeFjXuR/TQEGiENMekM+uwR4fTzoltkGjcCyKD5fPZM/f+N6TMb4vMsRuzlespxROPoH/dOAgsvG9PSZDI4g7aTq88S8xwYlPgfxKlaNKNbDtcpieMe7nK8GIcwcUxs7ar2rxtSeguOUsqpr5zRyhd30ChXfdxr41dLBl2r0Lg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR11MB4425.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(346002)(136003)(366004)(39860400002)(376002)(396003)(52536014)(5660300002)(71200400001)(966005)(86362001)(66446008)(66946007)(64756008)(83380400001)(2906002)(76116006)(8676002)(8936002)(66556008)(66476007)(478600001)(30864003)(110136005)(107886003)(6506007)(55016002)(53546011)(9686003)(316002)(4326008)(186003)(33656002)(7696005)(54906003)(26005)(579004);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: nXUHdopwqw51SMLLLddHeq9yEOZGlvRStrAG1Of/3MmpVUh99JMwJz8QISCDuu8/5S94YZ1Gv4DPptK17I/TaNr9OYcrMxxer2TYfpzWVer16KChziz6o3EfDdT1FHNm+Z4LfnnVufkHOE8Y9Ztp1eDU856mgSIDCbhk3qa5n4mtgtUIMIm+qS+63AP6G0aS5OdkcDG1tlhlCJRFx2Hfm1tJxLSrb+3OvuEm5x89XnOmIDUZCvbF7PbT4X6MDbXDzU/h8CL54a/fJtslPPTj4CzubgiVcZTMnZ6hVS9dDeO+WhQwiFbiWiSEMkZ8Z03sfRq8d3er0Hk0DlEl2IfnWfh5voREcMXHWCKqqOT715XXg9EKFbvZMzgjJ0u5Kw6v+gTgzMHK35ptMqjIhp3wNeTphmqE8/A2Nvcp98dfm1v3C0lWYmQlm9q1nbGRABBIeIWJUNTJ30zCDId1QFrPeKbSt2Fxe5Gwbfghl1yMA9nCglxyCfdqIVmvtq3fufB1 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: d724a0cd-23b2-4904-a841-08d80e7a09f6 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Jun 2020 02:40:58.6715 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: LXj7mCt1xH+E7tHVs1pYZIADPVS8AK4Nw3mSSafWW0HDrchbl/unUI4D5GhNCQJcgSzQ8kczYDEgOHQ3wceOfw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB4753 Return-Path: zhichao.gao@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Zhichao Gao Thanks, Zhichao > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Tomas Pil= ar > (tpilar) > Sent: Friday, May 22, 2020 2:44 AM > To: devel@edk2.groups.io > Cc: nd@arm.com; Ni, Ray ; Gao, Zhichao > > Subject: [edk2-devel] [PATCH v2 4/6] ShellPkg/AcpiView: Move parameter p= arsing >=20 > Parsing command line parameters is done in the shell command wrapper. Th= is > declutters the core code and improves modular design. >=20 > Cc: Ray Ni > Cc: Zhichao Gao > Signed-off-by: Tomas Pilar > --- > ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c = | 205 ------ > ----------------------------------------------------------- > ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h = | 18 > +++++- >=20 > ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib= .c > | 218 > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > ++++- >=20 > ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib= . > h | 10 +++- > 4 files changed, 240 insertions(+), 211 deletions(-) >=20 > diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c > index c9654e52c434..a3160ed6f0a2 100644 > --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c > @@ -32,19 +32,6 @@ EFI_HII_HANDLE gShellAcpiViewHiiHandle =3D NULL; > STATIC UINT32 mTableCount; > STATIC UINT32 mBinTableCount; >=20 > -/** > - An array of acpiview command line parameters. > -**/ > -STATIC CONST SHELL_PARAM_ITEM ParamList[] =3D { > - {L"-q", TypeFlag}, > - {L"-d", TypeFlag}, > - {L"-h", TypeFlag}, > - {L"-l", TypeFlag}, > - {L"-s", TypeValue}, > - {L"-r", TypeValue}, > - {NULL, TypeMax} > -}; > - > /** > This function dumps the ACPI table to a file. >=20 > @@ -228,7 +215,6 @@ ProcessTableReportOptions ( > Returns EFI_UNSUPPORTED if the RSDP version is less than 2. > Returns EFI_SUCCESS if successful. > **/ > -STATIC > EFI_STATUS > EFIAPI > AcpiView ( > @@ -372,194 +358,3 @@ AcpiView ( > } > return EFI_SUCCESS; > } > - > -/** > - Function for 'acpiview' command. > - > - @param[in] ImageHandle Handle to the Image (NULL if Internal). > - @param[in] SystemTable Pointer to the System Table (NULL if Internal= ). > -**/ > -SHELL_STATUS > -EFIAPI > -ShellCommandRunAcpiView ( > - IN EFI_HANDLE ImageHandle, > - IN EFI_SYSTEM_TABLE* SystemTable > - ) > -{ > - EFI_STATUS Status; > - SHELL_STATUS ShellStatus; > - LIST_ENTRY* Package; > - CHAR16* ProblemParam; > - SHELL_FILE_HANDLE TmpDumpFileHandle; > - CONST CHAR16* MandatoryTableSpecStr; > - CONST CHAR16 *SelectedTableName; > - > - // Set configuration defaults > - AcpiConfigSetDefaults (); > - > - ShellStatus =3D SHELL_SUCCESS; > - Package =3D NULL; > - TmpDumpFileHandle =3D NULL; > - > - Status =3D ShellCommandLineParse (ParamList, &Package, &ProblemParam, > TRUE); > - if (EFI_ERROR (Status)) { > - if (Status =3D=3D EFI_VOLUME_CORRUPTED && ProblemParam !=3D NULL) { > - ShellPrintHiiEx ( > - -1, > - -1, > - NULL, > - STRING_TOKEN (STR_GEN_PROBLEM), > - gShellAcpiViewHiiHandle, > - L"acpiview", > - ProblemParam > - ); > - FreePool (ProblemParam); > - } else { > - Print (L"acpiview: Error processing input parameter(s)\n"); > - } > - ShellStatus =3D SHELL_INVALID_PARAMETER; > - } else { > - if (ShellCommandLineGetCount (Package) > 1) { > - ShellPrintHiiEx ( > - -1, > - -1, > - NULL, > - STRING_TOKEN (STR_GEN_TOO_MANY), > - gShellAcpiViewHiiHandle, > - L"acpiview" > - ); > - ShellStatus =3D SHELL_INVALID_PARAMETER; > - } else if (ShellCommandLineGetFlag (Package, L"-?")) { > - ShellPrintHiiEx ( > - -1, > - -1, > - NULL, > - STRING_TOKEN (STR_GET_HELP_ACPIVIEW), > - gShellAcpiViewHiiHandle, > - L"acpiview" > - ); > - } else if (ShellCommandLineGetFlag (Package, L"-s") && > - ShellCommandLineGetValue (Package, L"-s") =3D=3D NULL) { > - ShellPrintHiiEx ( > - -1, > - -1, > - NULL, > - STRING_TOKEN (STR_GEN_NO_VALUE), > - gShellAcpiViewHiiHandle, > - L"acpiview", > - L"-s" > - ); > - ShellStatus =3D SHELL_INVALID_PARAMETER; > - } else if (ShellCommandLineGetFlag (Package, L"-r") && > - ShellCommandLineGetValue (Package, L"-r") =3D=3D NULL) { > - ShellPrintHiiEx ( > - -1, > - -1, > - NULL, > - STRING_TOKEN (STR_GEN_NO_VALUE), > - gShellAcpiViewHiiHandle, > - L"acpiview", > - L"-r" > - ); > - ShellStatus =3D SHELL_INVALID_PARAMETER; > - } else if ((ShellCommandLineGetFlag (Package, L"-s") && > - ShellCommandLineGetFlag (Package, L"-l"))) { > - ShellPrintHiiEx ( > - -1, > - -1, > - NULL, > - STRING_TOKEN (STR_GEN_TOO_MANY), > - gShellAcpiViewHiiHandle, > - L"acpiview" > - ); > - ShellStatus =3D SHELL_INVALID_PARAMETER; > - } else if (ShellCommandLineGetFlag (Package, L"-d") && > - !ShellCommandLineGetFlag (Package, L"-s")) { > - ShellPrintHiiEx ( > - -1, > - -1, > - NULL, > - STRING_TOKEN (STR_GEN_MISSING_OPTION), > - gShellAcpiViewHiiHandle, > - L"acpiview", > - L"-s", > - L"-d" > - ); > - ShellStatus =3D SHELL_INVALID_PARAMETER; > - } else { > - // Turn on colour highlighting if requested > - SetColourHighlighting (ShellCommandLineGetFlag (Package, L"-h")); > - > - // Surpress consistency checking if requested > - SetConsistencyChecking (!ShellCommandLineGetFlag (Package, L"-q")= ); > - > - // Evaluate the parameters for mandatory ACPI table presence chec= ks > - SetMandatoryTableValidate (ShellCommandLineGetFlag (Package, L"-r= ")); > - MandatoryTableSpecStr =3D ShellCommandLineGetValue (Package, L"-r= "); > - > - if (MandatoryTableSpecStr !=3D NULL) { > - SetMandatoryTableSpec (ShellHexStrToUintn (MandatoryTableSpecSt= r)); > - } > - > - if (ShellCommandLineGetFlag (Package, L"-l")) { > - SetReportOption (ReportTableList); > - } else { > - SelectedTableName =3D ShellCommandLineGetValue (Package, L"-s")= ; > - if (SelectedTableName !=3D NULL) { > - SelectAcpiTable (SelectedTableName); > - SetReportOption (ReportSelected); > - > - if (ShellCommandLineGetFlag (Package, L"-d")) { > - // Create a temporary file to check if the media is writabl= e. > - CHAR16 FileNameBuffer[MAX_FILE_NAME_LEN]; > - SetReportOption (ReportDumpBinFile); > - > - UnicodeSPrint ( > - FileNameBuffer, > - sizeof (FileNameBuffer), > - L".\\%s%04d.tmp", > - SelectedTableName, > - mBinTableCount > - ); > - > - Status =3D ShellOpenFileByName ( > - FileNameBuffer, > - &TmpDumpFileHandle, > - EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | > - EFI_FILE_MODE_CREATE, > - 0 > - ); > - > - if (EFI_ERROR (Status)) { > - ShellStatus =3D SHELL_INVALID_PARAMETER; > - TmpDumpFileHandle =3D NULL; > - ShellPrintHiiEx ( > - -1, > - -1, > - NULL, > - STRING_TOKEN (STR_GEN_READONLY_MEDIA), > - gShellAcpiViewHiiHandle, > - L"acpiview" > - ); > - goto Done; > - } > - // Delete Temporary file. > - ShellDeleteFile (&TmpDumpFileHandle); > - } // -d > - } // -s > - } > - > - // Parse ACPI Table information > - Status =3D AcpiView (SystemTable); > - if (EFI_ERROR (Status)) { > - ShellStatus =3D SHELL_NOT_FOUND; > - } > - } > - } > - > -Done: > - if (Package !=3D NULL) { > - ShellCommandLineFreeVarList (Package); > - } > - return ShellStatus; > -} > diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h > index 92d64a88814d..d5b95f5ee707 100644 > --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h > @@ -64,7 +64,7 @@ GetWarningCount ( >=20 > @param [in] Signature The ACPI table Signature. > @param [in] TablePtr Pointer to the ACPI table data. > - @param [in] Length The length fo the ACPI table. > + @param [in] Length The length of the ACPI table. >=20 > @retval Returns TRUE if the ACPI table should be traced. > **/ > @@ -75,4 +75,20 @@ ProcessTableReportOptions ( > IN CONST UINT32 Length > ); >=20 > +/** > + This function iterates the configuration table entries in the > + system table, retrieves the RSDP pointer and starts parsing the ACPI = tables. > + > + @param [in] SystemTable Pointer to the EFI system table. > + > + @retval EFI_NOT_FOUND The RSDP pointer was not found. > + @retval EFI_UNSUPPORTED The RSDP version was less than 2. > + @retval EFI_SUCCESS The command was successful. > +**/ > +EFI_STATUS > +EFIAPI > +AcpiView ( > + IN EFI_SYSTEM_TABLE* SystemTable > + ); > + > #endif // ACPIVIEW_H_ > diff --git > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandL= i > b.c > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandL= i > b.c > index e0d5a8108552..c3942ad24e5b 100644 > --- > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandL= i > b.c > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewComm > +++ andLib.c > @@ -1,24 +1,44 @@ > /** @file > Main file for 'acpiview' Shell command function. >=20 > - Copyright (c) 2016 - 2019, ARM Limited. All rights reserved.
> + Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
> SPDX-License-Identifier: BSD-2-Clause-Patent **/ >=20 > #include > #include > + > +#include > #include > +#include #include > #include > -#include > +#include > #include > +#include > #include > + > #include "AcpiParser.h" > #include "AcpiTableParser.h" > #include "AcpiView.h" > +#include "AcpiViewConfig.h" > #include "UefiShellAcpiViewCommandLib.h" >=20 > CONST CHAR16 gShellAcpiViewFileName[] =3D L"ShellCommand"; >=20 > +/** > + An array of acpiview command line parameters. > +**/ > +STATIC CONST SHELL_PARAM_ITEM ParamList[] =3D { > + {L"-q", TypeFlag}, > + {L"-d", TypeFlag}, > + {L"-h", TypeFlag}, > + {L"-l", TypeFlag}, > + {L"-s", TypeValue}, > + {L"-r", TypeValue}, > + {NULL, TypeMax} > +}; > + > /** > A list of available table parsers. > */ > @@ -92,6 +112,200 @@ ShellCommandGetManFileNameAcpiView ( > return gShellAcpiViewFileName; > } >=20 > +/** > + Function for 'acpiview' command. > + > + @param[in] ImageHandle Handle to the Image (NULL if internal). > + @param[in] SystemTable Pointer to the System Table (NULL if internal= ). > + > + @retval SHELL_INVALID_PARAMETER The command line invocation could not > be parsed > + @retval SHELL_NOT_FOUND The command failed > + @retval SHELL_SUCCESS The command was successful > +**/ > +SHELL_STATUS > +EFIAPI > +ShellCommandRunAcpiView ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE* SystemTable > + ) > +{ > + EFI_STATUS Status; > + SHELL_STATUS ShellStatus; > + LIST_ENTRY* Package; > + CHAR16* ProblemParam; > + SHELL_FILE_HANDLE TmpDumpFileHandle; > + CONST CHAR16* MandatoryTableSpecStr; > + CONST CHAR16* SelectedTableName; > + > + // Set configuration defaults > + AcpiConfigSetDefaults (); > + > + ShellStatus =3D SHELL_SUCCESS; > + Package =3D NULL; > + TmpDumpFileHandle =3D NULL; > + > + Status =3D ShellCommandLineParse (ParamList, &Package, &ProblemParam, > + TRUE); if (EFI_ERROR (Status)) { > + if (Status =3D=3D EFI_VOLUME_CORRUPTED && ProblemParam !=3D NULL) { > + ShellPrintHiiEx ( > + -1, > + -1, > + NULL, > + STRING_TOKEN (STR_GEN_PROBLEM), > + gShellAcpiViewHiiHandle, > + L"acpiview", > + ProblemParam > + ); > + FreePool (ProblemParam); > + } else { > + Print (L"acpiview: Error processing input parameter(s)\n"); > + } > + ShellStatus =3D SHELL_INVALID_PARAMETER; } else { > + if (ShellCommandLineGetCount (Package) > 1) { > + ShellPrintHiiEx ( > + -1, > + -1, > + NULL, > + STRING_TOKEN (STR_GEN_TOO_MANY), > + gShellAcpiViewHiiHandle, > + L"acpiview" > + ); > + ShellStatus =3D SHELL_INVALID_PARAMETER; > + } else if (ShellCommandLineGetFlag (Package, L"-?")) { > + ShellPrintHiiEx ( > + -1, > + -1, > + NULL, > + STRING_TOKEN (STR_GET_HELP_ACPIVIEW), > + gShellAcpiViewHiiHandle, > + L"acpiview" > + ); > + } else if (ShellCommandLineGetFlag (Package, L"-s") && > + ShellCommandLineGetValue (Package, L"-s") =3D=3D NULL) { > + ShellPrintHiiEx ( > + -1, > + -1, > + NULL, > + STRING_TOKEN (STR_GEN_NO_VALUE), > + gShellAcpiViewHiiHandle, > + L"acpiview", > + L"-s" > + ); > + ShellStatus =3D SHELL_INVALID_PARAMETER; > + } else if (ShellCommandLineGetFlag (Package, L"-r") && > + ShellCommandLineGetValue (Package, L"-r") =3D=3D NULL) { > + ShellPrintHiiEx ( > + -1, > + -1, > + NULL, > + STRING_TOKEN (STR_GEN_NO_VALUE), > + gShellAcpiViewHiiHandle, > + L"acpiview", > + L"-r" > + ); > + ShellStatus =3D SHELL_INVALID_PARAMETER; > + } else if ((ShellCommandLineGetFlag (Package, L"-s") && > + ShellCommandLineGetFlag (Package, L"-l"))) { > + ShellPrintHiiEx ( > + -1, > + -1, > + NULL, > + STRING_TOKEN (STR_GEN_TOO_MANY), > + gShellAcpiViewHiiHandle, > + L"acpiview" > + ); > + ShellStatus =3D SHELL_INVALID_PARAMETER; > + } else if (ShellCommandLineGetFlag (Package, L"-d") && > + !ShellCommandLineGetFlag (Package, L"-s")) { > + ShellPrintHiiEx ( > + -1, > + -1, > + NULL, > + STRING_TOKEN (STR_GEN_MISSING_OPTION), > + gShellAcpiViewHiiHandle, > + L"acpiview", > + L"-s", > + L"-d" > + ); > + ShellStatus =3D SHELL_INVALID_PARAMETER; > + } else { > + // Turn on colour highlighting if requested > + SetColourHighlighting (ShellCommandLineGetFlag (Package, L"-h")); > + > + // Surpress consistency checking if requested > + SetConsistencyChecking (!ShellCommandLineGetFlag (Package, > + L"-q")); > + > + // Evaluate the parameters for mandatory ACPI table presence chec= ks > + SetMandatoryTableValidate (ShellCommandLineGetFlag (Package, L"-r= ")); > + MandatoryTableSpecStr =3D ShellCommandLineGetValue (Package, > + L"-r"); > + > + if (MandatoryTableSpecStr !=3D NULL) { > + SetMandatoryTableSpec (ShellHexStrToUintn (MandatoryTableSpecSt= r)); > + } > + > + if (ShellCommandLineGetFlag (Package, L"-l")) { > + SetReportOption (ReportTableList); > + } else { > + SelectedTableName =3D ShellCommandLineGetValue (Package, L"-s")= ; > + if (SelectedTableName !=3D NULL) { > + SelectAcpiTable (SelectedTableName); > + SetReportOption (ReportSelected); > + > + if (ShellCommandLineGetFlag (Package, L"-d")) { > + // Create a temporary file to check if the media is writabl= e. > + CHAR16 FileNameBuffer[MAX_FILE_NAME_LEN]; > + SetReportOption (ReportDumpBinFile); > + > + UnicodeSPrint ( > + FileNameBuffer, > + sizeof (FileNameBuffer), > + L".\\%s0000.tmp", > + SelectedTableName > + ); > + > + Status =3D ShellOpenFileByName ( > + FileNameBuffer, > + &TmpDumpFileHandle, > + EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | > + EFI_FILE_MODE_CREATE, > + 0 > + ); > + > + if (EFI_ERROR (Status)) { > + ShellStatus =3D SHELL_INVALID_PARAMETER; > + TmpDumpFileHandle =3D NULL; > + ShellPrintHiiEx ( > + -1, > + -1, > + NULL, > + STRING_TOKEN (STR_GEN_READONLY_MEDIA), > + gShellAcpiViewHiiHandle, > + L"acpiview" > + ); > + goto Done; > + } > + // Delete Temporary file. > + ShellDeleteFile (&TmpDumpFileHandle); > + } // -d > + } // -s > + } > + > + // Parse ACPI Table information > + Status =3D AcpiView (SystemTable); > + if (EFI_ERROR (Status)) { > + ShellStatus =3D SHELL_NOT_FOUND; > + } > + } > + } > + > +Done: > + if (Package !=3D NULL) { > + ShellCommandLineFreeVarList (Package); > + } > + return ShellStatus; > +} > + > /** > Constructor for the Shell AcpiView Command library. >=20 > diff --git > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandL= i > b.h > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandL= i > b.h > index c1cf7a57af7a..a3a29164004d 100644 > --- > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandL= i > b.h > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewComm > +++ andLib.h > @@ -1,7 +1,7 @@ > /** @file > Header file for 'acpiview' Shell command functions. >=20 > - Copyright (c) 2016 - 2017, ARM Limited. All rights reserved.
> + Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
> SPDX-License-Identifier: BSD-2-Clause-Patent **/ >=20 > @@ -13,8 +13,12 @@ extern EFI_HII_HANDLE gShellAcpiViewHiiHandle; > /** > Function for 'acpiview' command. >=20 > - @param[in] ImageHandle Handle to the Image (NULL if Internal). > - @param[in] SystemTable Pointer to the System Table (NULL if Internal= ). > + @param[in] ImageHandle Handle to the Image (NULL if internal). > + @param[in] SystemTable Pointer to the System Table (NULL if internal= ). > + > + @retval SHELL_INVALID_PARAMETER The command line invocation could not > be parsed > + @retval SHELL_NOT_FOUND The command failed > + @retval SHELL_SUCCESS The command was successful > **/ > SHELL_STATUS > EFIAPI > -- > 2.24.1.windows.2 >=20 >=20 >=20 >=20