From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from FRA01-MR2-obe.outbound.protection.outlook.com (FRA01-MR2-obe.outbound.protection.outlook.com [40.107.9.73]) by mx.groups.io with SMTP id smtpd.web10.1473.1590085396908267706 for ; Thu, 21 May 2020 11:23:17 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=gWt0+Si9; spf=pass (domain: arm.com, ip: 40.107.9.73, mailfrom: tomas.pilar@arm.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=V9i+8ctHeAlse4SSGM0agQYHf/nepAr8wNnhZF+abwo=; b=gWt0+Si9DmRasmSRhApEZH7laf6Y7ebRTaO0W2ok+rsfu23A8sb8yQE+gAl7qA8pGYnuePAZFEZV/f6KujsVc2f7sYa0TIu5qt5seOa/efYB20jaXbjihALy7tXANklrXbzWEhok1gXBtr8Z+YWpzpZLX1FELRwU5tPMRCCQOqM= Received: from AM5PR0602CA0022.eurprd06.prod.outlook.com (2603:10a6:203:a3::32) by PR2PR08MB4780.eurprd08.prod.outlook.com (2603:10a6:101:1a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.27; Thu, 21 May 2020 18:23:13 +0000 Received: from AM5EUR03FT064.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:a3:cafe::a7) by AM5PR0602CA0022.outlook.office365.com (2603:10a6:203:a3::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.24 via Frontend Transport; Thu, 21 May 2020 18:23:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT064.mail.protection.outlook.com (10.152.17.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.23 via Frontend Transport; Thu, 21 May 2020 18:23:12 +0000 Received: ("Tessian outbound cff7dd4de28a:v57"); Thu, 21 May 2020 18:23:12 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 285d16f683e91102 X-CR-MTA-TID: 64aa7808 Received: from 1ccb6facc0da.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 69AD01A9-B7EF-4FC7-9323-21751B24E785.1; Thu, 21 May 2020 18:23:07 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 1ccb6facc0da.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 21 May 2020 18:23:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aDw2CRzd2GBcBXENhFEeNzw54TIPfNiHXXLdY9c3HvtXvhNzfEQlv6ajZBwteaD464IwyK/OE2367Ahokqbf0LnfkjmN4X/fGZDRa7d/Mucsm9ISVuJw2OoV0d5ybUkB2WIBcbJKfhdesbtc8+Dt59W3K2dOSPOYY3e2VuRlpbjWLjfSehkQdJuJoSPxpSWkiALZ6NNE22Prg0AngDscM59AqGK2BBN+VtuFz/VLpDl4PJHaT152XXUg5YybOyH5S352Gr3+OBKWgKSnPSQsLEC7CQMcZRYPBPLHuiDpjF8qJx8aRhoL6sulRC/ZWIe8yN7e9vVHdPHWLH7yjIUEtQ== 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=V9i+8ctHeAlse4SSGM0agQYHf/nepAr8wNnhZF+abwo=; b=kNIITPqBurflPcoJm9eSYwFPZ6Jb8Un32U02tLFw9AbPTOv5uOJdMBWTvK/WIMBvNxlowB+GZcqqPQ7XtEW/b3FD697g39mUZwIG6TA4bm2JcKiVkCAFw1LjE7cLYVUlMf/VV/yzYy/fKGEG16bSwEqpXlgOfmttEei2b4d0Ar61ZZ/33Vr3+XWHYFd8qrgQDK4wHRwE3qGGUWPXARKRoohZb+7eLKmIwQy/9b+7hrRO8UhU/YCPNjn0/rCavtZvygb+ehXI+r5vNz2OcCIeECEdvDPX7WYvSvVmGckC++0P87kXH30OkRS6nFFoZYaY77pOFw9wcHlu4RSSyEZd0w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=V9i+8ctHeAlse4SSGM0agQYHf/nepAr8wNnhZF+abwo=; b=gWt0+Si9DmRasmSRhApEZH7laf6Y7ebRTaO0W2ok+rsfu23A8sb8yQE+gAl7qA8pGYnuePAZFEZV/f6KujsVc2f7sYa0TIu5qt5seOa/efYB20jaXbjihALy7tXANklrXbzWEhok1gXBtr8Z+YWpzpZLX1FELRwU5tPMRCCQOqM= Received: from AM5PR0801MB1844.eurprd08.prod.outlook.com (2603:10a6:203:39::22) by AM5PR0801MB1939.eurprd08.prod.outlook.com (2603:10a6:203:4c::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.23; Thu, 21 May 2020 18:23:06 +0000 Received: from AM5PR0801MB1844.eurprd08.prod.outlook.com ([fe80::ed78:8b3c:523d:d153]) by AM5PR0801MB1844.eurprd08.prod.outlook.com ([fe80::ed78:8b3c:523d:d153%6]) with mapi id 15.20.3000.034; Thu, 21 May 2020 18:23:06 +0000 From: "Tomas Pilar (tpilar)" To: "devel@edk2.groups.io" , Tomas Pilar Subject: Re: [edk2-devel] [PATCH v1 4/6] ShellPkg/AcpiView: Move parameter parsing Thread-Topic: [edk2-devel] [PATCH v1 4/6] ShellPkg/AcpiView: Move parameter parsing Thread-Index: AQHWL5xDs8HV0GqSs0iwulP1E+0yHqiy2jzw Date: Thu, 21 May 2020 18:23:06 +0000 Message-ID: References: <20200521181629.79-1-Tomas.Pilar@arm.com> <20200521181629.79-5-Tomas.Pilar@arm.com> In-Reply-To: <20200521181629.79-5-Tomas.Pilar@arm.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Authentication-Results-Original: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=arm.com; x-originating-ip: [81.111.29.163] x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: ecd7106d-c847-4ee0-99e4-08d7fdb405d5 x-ms-traffictypediagnostic: AM5PR0801MB1939:|PR2PR08MB4780: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:6108;OLM:6108; x-forefront-prvs: 041032FF37 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: WGCDOPqHnBz49if6ZJMJBFFkjMXxLDir//zcq3bM1jaOT9B0QbyhikF0GPGOyuCFb3s6RzGhNV69sovlP8FazcwhDw8hNxvr2r51CQF6YHityvi2pJ5JsWrjp3+aJYILdsbcN4MsRePX/a8sgQMJInHHAObYOAW+86XVtCYM8uA42oPlp2YoVxayJiyoKVd+EalMCZQivlsTXuwV4nL4Ky2eYF2MxK76BzawK9U0TccZT6mBqE7YUfLBVtNzy4A3UhY2kJG+MkcF8kzVNUrew0EegUhVsbrEeSGe9BqDN2HT2Jo19gPM8tjMRisEK7pVveJS277aNYTPySn3TYY3bPXMKQJ+npsOZMUM18dBnSuEyJ09fgaopuiYfZMOdUvBCtPhkXIuF+PEjyrr0Ojs/w== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM5PR0801MB1844.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(396003)(39860400002)(346002)(136003)(366004)(376002)(478600001)(7696005)(55016002)(966005)(53546011)(26005)(64756008)(30864003)(66556008)(9686003)(186003)(6506007)(33656002)(86362001)(8676002)(66476007)(316002)(66946007)(66446008)(76116006)(71200400001)(52536014)(110136005)(2906002)(5660300002)(8936002)(579004);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata: tS+RWqpRu8j1+82FyHJRYYHq1CK3fCbmc6AoU+g5lIpvoSWMWKcgM31uvNqoHfoT+rCyWQz4zImYsCF2aR5H/GXb01Om12BM14WpyC8ShbwE5m+JU9dlXCJmrIX5m4ZxzoAdtH1qM6sKeGhF63B6y0YEffAot2hytOTFy1orUt6nnLkylM8hB0vtF5D0rOnaS1QEDBzY5b62y+RF19hH8ip04Ec4U9jONxV9BimsV1NzEd1CSctaOQOYTq7v83K4kTfTc7d9DUIO1Tlt9LNgclddUKa5cOyGxNz8dWLF0ZT9GvnFobZbM1bVUK2rj8NkC9r/yWkAlyxlH8ljdgWbbYSb+fEqnkz31XVuwCSjCaSNvhIVVrJQgA/P/Xbm1Syfi9muo5d0/+QexvKhLCYIYX6ZgOXK5+WDyD9t95zzVPg2Pwl3SZApwxA2g+fO63Xu24ZDDRyhJi3C1KFDeMBrC2EDOwIXla5/IMA8/2Xfiqg= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1939 Original-Authentication-Results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=arm.com; Return-Path: Tomas.Pilar@arm.com X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT064.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFTY:;SFS:(4636009)(376002)(39860400002)(346002)(136003)(396003)(46966005)(86362001)(55016002)(9686003)(478600001)(36906005)(47076004)(316002)(966005)(70206006)(52536014)(7696005)(110136005)(186003)(82740400003)(30864003)(53546011)(8676002)(8936002)(6506007)(70586007)(5660300002)(336012)(33656002)(82310400002)(81166007)(356005)(2906002)(26005);DIR:OUT;SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: d42bfd02-1861-436d-1be2-08d7fdb401b9 X-Forefront-PRVS: 041032FF37 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: junTqiEnZcj1KjRMDtYwKpidhP0lKvDkpjhfHQmOqo63aeurYx2CHcTaGGa3t4yKj5etTQEzONt2XZQhIhqadu1FCFlZGJxr6tUSXekLxlnPUiYZKkcpfvSSeP1Sb24BOl2R2+jI+yjZgOQ3Nvs8C9CBm17oAnE1TFsibNkcxDRDcnCLm4JYsj9AlRYAhW7NB36n/iXrj3oYXHQ0+NKjJttJIdrlE4GP0JwOQdIrTkCbPk1xiZ7CDMQY0/t5GQGe9c1wglLz0Ayso5wu3a9OLYrqa27Ths9VygsqXiVC3+Y/QWpoVMYiHAYGxm1h3/gk8A2FLZZXG/kqDrBSOiEVFxy5KFEob1pcxJQiKqvFBFQqPgAPJ+saLpw5pC3xP290WfUMd62wG9uAzBdkl7hONBUuLnStmlukUVUIf/5Cp7rBPKNmRjORlRx2HaPWQe8IZzsC4ECyyN31Pej1RvZSnvJtSzgMSwwYk4uBtGQhG8Oa80v8KbkzJ15pJ2YxEgQL7hLJOBNyzN/9i3eUQmt3HFXeJZG2ZHI6k/ESgDUI6JWixC79Q6TU05Gm/PRsjMEgOoDKlNKw9PjfmKycp486xQ== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2020 18:23:12.9290 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ecd7106d-c847-4ee0-99e4-08d7fdb405d5 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR2PR08MB4780 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Well, it looks like the settings for send-email don't Just Work (tm), I'll = clean up the series and resubmit. Apologies for spamming the list. Tom -----Original Message----- From: devel@edk2.groups.io On Behalf Of Tomas Pilar= (tpilar) via groups.io Sent: 21 May 2020 19:16 To: devel@edk2.groups.io Cc: Ray Ni ; Zhichao Gao Subject: [edk2-devel] [PATCH v1 4/6] ShellPkg/AcpiView: Move parameter par= sing Parsing command line parameters is done in the shell command wrapper. This declutters the core code and improves modular design. Cc: Ray Ni Cc: Zhichao Gao Signed-off-by: Tomas Pilar --- ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c = | 205 ----------------------------------------------------------------- ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h = | 18 +++++- ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.= c | 218 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= ++- ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.= h | 10 +++- 4 files changed, 240 insertions(+), 211 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c b/She= llPkg/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; -/** - 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. @@ -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, T= RUE); - 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 checks - SetMandatoryTableValidate (ShellCommandLineGetFlag (Package, L"-r")= ); - MandatoryTableSpecStr =3D ShellCommandLineGetValue (Package, L"-r")= ; - - if (MandatoryTableSpecStr !=3D NULL) { - SetMandatoryTableSpec (ShellHexStrToUintn (MandatoryTableSpecStr)= ); - } - - 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 writable. - 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/She= llPkg/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 ( @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. @retval Returns TRUE if the ACPI table should be traced. **/ @@ -75,4 +75,20 @@ ProcessTableReportOptions ( IN CONST UINT32 Length ); +/** + This function iterates the configuration table entries in the + system table, retrieves the RSDP pointer and starts parsing the ACPI ta= bles. + + @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/UefiShellAcpiVie= wCommandLib.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiV= iewCommandLib.c index e0d5a8108552..c3942ad24e5b 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewComman= dLib.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewComman= dLib.c @@ -1,24 +1,44 @@ /** @file Main file for 'acpiview' Shell command function. - 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 **/ #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" CONST CHAR16 gShellAcpiViewFileName[] =3D L"ShellCommand"; +/** + 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; } +/** + 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 b= e 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, T= RUE); + 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 checks + SetMandatoryTableValidate (ShellCommandLineGetFlag (Package, L"-r")= ); + MandatoryTableSpecStr =3D ShellCommandLineGetValue (Package, L"-r")= ; + + if (MandatoryTableSpecStr !=3D NULL) { + SetMandatoryTableSpec (ShellHexStrToUintn (MandatoryTableSpecStr)= ); + } + + 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 writable. + 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. diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiVie= wCommandLib.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiV= iewCommandLib.h index c1cf7a57af7a..a3a29164004d 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewComman= dLib.h +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewComman= dLib.h @@ -1,7 +1,7 @@ /** @file Header file for 'acpiview' Shell command functions. - 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 **/ @@ -13,8 +13,12 @@ extern EFI_HII_HANDLE gShellAcpiViewHiiHandle; /** 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). + @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 b= e parsed + @retval SHELL_NOT_FOUND The command failed + @retval SHELL_SUCCESS The command was successful **/ SHELL_STATUS EFIAPI -- 2.24.1.windows.2 IMPORTANT NOTICE: The contents of this email and any attachments are confi= dential and may also be privileged. If you are not the intended recipient, = please notify the sender immediately and do not disclose the contents to an= y other person, use it for any purpose, or store or copy the information in= any medium. Thank you. IMPORTANT NOTICE: The contents of this email and any attachments are confi= dential and may also be privileged. If you are not the intended recipient, = please notify the sender immediately and do not disclose the contents to an= y other person, use it for any purpose, or store or copy the information in= any medium. Thank you.