From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR02-AM5-obe.outbound.protection.outlook.com (EUR02-AM5-obe.outbound.protection.outlook.com [40.107.0.46]) by mx.groups.io with SMTP id smtpd.web10.1334.1590085018332032645 for ; Thu, 21 May 2020 11:16:58 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=BqfwAnnB; spf=pass (domain: arm.com, ip: 40.107.0.46, 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=Eg9J9nu4oXhIkmNUZrApLYpfcyRuFp3I8JuMHgw954A=; b=BqfwAnnBguqBK0czuNyg9gi/XZzXt6qP9O3UZ5RSh7OVB6rUAnAqU75ZlaELQP1XuW7aHtwezqyOsAIc/F98k5MB0KC0GjKk+f1xcNyRu2M979yiDSIbZYGUPwG91r2+yua548+dQEf6LczcYdWwn3t6ifcEKCPn3+Ey8twHINI= Received: from AM5PR0101CA0033.eurprd01.prod.exchangelabs.com (2603:10a6:206:16::46) by AM0PR08MB4483.eurprd08.prod.outlook.com (2603:10a6:208:145::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:16:55 +0000 Received: from AM5EUR03FT012.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:16:cafe::ec) by AM5PR0101CA0033.outlook.office365.com (2603:10a6:206:16::46) 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:16:55 +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 AM5EUR03FT012.mail.protection.outlook.com (10.152.16.161) 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:16:55 +0000 Received: ("Tessian outbound d078647f4174:v57"); Thu, 21 May 2020 18:16:55 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 602a35a3836cb428 X-CR-MTA-TID: 64aa7808 Received: from 9e8b23371560.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id BE877888-9121-4448-8F1C-36839B0A1CFB.1; Thu, 21 May 2020 18:16:50 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9e8b23371560.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 21 May 2020 18:16:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=evEgijuyeGjYL1kMqwU0kmsPhwufCxFdOGb68vCTNfOEzX7E/dHHffhmC4S5im7DPYc180rCBVJgD7Rx4a4ljMwgiLgA9xh2yyd4f3JookoY3WFHIfmeCsU6/bsq+5XryjhyMIrdQ8r2Wd9qxqzs5H12/UjltDeRTxmCapvgX8Ei03f2QWFjTM1OrFboyjlXgo1bbRfZ8lhCywguPimIensQz0st6eexQaLuLGXK2bmnDKG6MVS0LQro/ZMw9j01Hl41m/GHrMaHvw0180w7yy7mcOdFcMYv2wWGIunzdN8koSF0HjlLPYy9P0/eVFzJN9ThPKo8CLfIEsv89paOqA== 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=Eg9J9nu4oXhIkmNUZrApLYpfcyRuFp3I8JuMHgw954A=; b=Pkqn8N0TJNE2WMw0pxyYgaUASde42TiQJIyY6iNhQtuLiEFqOYYJKC4SGeppWojdhpzZ54BVIYDA4FL7hsP/6SbrWOR9w8slUJ14hOADopWyS8bV1cXGZQCf3is0SAsdJs29y//5WtT48jIAxRs/I+8s0QRB55GWmloX+37u8yZPehIgjdN33bxQ3rGhII8j22l/Yqz/P5DdtbG9hUWluHl428wcWQmJP6DdJT0JjptR5tmVFJV3LQeB1tbUMezdXKa0DMucKll/wLqUrz94iNrLUZ1m9Ard5jDTVIIYUs0J5LVpiet7g0K6Ehu9KvhWX+behjEZFQQij6ozQIauwA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=bestguesspass action=none header.from=arm.com; dkim=none (message not signed); 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=Eg9J9nu4oXhIkmNUZrApLYpfcyRuFp3I8JuMHgw954A=; b=BqfwAnnBguqBK0czuNyg9gi/XZzXt6qP9O3UZ5RSh7OVB6rUAnAqU75ZlaELQP1XuW7aHtwezqyOsAIc/F98k5MB0KC0GjKk+f1xcNyRu2M979yiDSIbZYGUPwG91r2+yua548+dQEf6LczcYdWwn3t6ifcEKCPn3+Ey8twHINI= Received: from AM5PR0602CA0003.eurprd06.prod.outlook.com (2603:10a6:203:a3::13) by AM0PR08MB5492.eurprd08.prod.outlook.com (2603:10a6:208:185::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.26; Thu, 21 May 2020 18:16:48 +0000 Received: from VE1EUR03FT060.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:a3:cafe::e) by AM5PR0602CA0003.outlook.office365.com (2603:10a6:203:a3::13) 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:16:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT060.mail.protection.outlook.com (10.152.19.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3021.23 via Frontend Transport; Thu, 21 May 2020 18:16:48 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1415.2; Thu, 21 May 2020 18:16:47 +0000 Received: from localhost.localdomain (10.57.25.130) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Thu, 21 May 2020 18:16:47 +0000 From: "Tomas Pilar (tpilar)" To: CC: Ray Ni , Zhichao Gao Subject: [PATCH v1 4/6] ShellPkg/AcpiView: Move parameter parsing Date: Thu, 21 May 2020 19:16:27 +0100 Message-ID: <20200521181629.79-5-Tomas.Pilar@arm.com> X-Mailer: git-send-email 2.24.1.windows.2 In-Reply-To: <20200521181629.79-1-Tomas.Pilar@arm.com> References: <20200521181629.79-1-Tomas.Pilar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFTY:;SFS:(4636009)(39860400002)(346002)(376002)(396003)(136003)(46966005)(36756003)(5660300002)(186003)(26005)(8936002)(6916009)(6666004)(70206006)(336012)(426003)(1076003)(2616005)(478600001)(8676002)(30864003)(70586007)(81166007)(2906002)(82310400002)(86362001)(356005)(82740400003)(4326008)(47076004)(316002)(54906003);DIR:OUT;SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: eec49768-9bf9-4641-3bcb-08d7fdb324ea X-MS-TrafficTypeDiagnostic: AM0PR08MB5492:|AM0PR08MB4483: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:3044;OLM:6430; X-Forefront-PRVS: 041032FF37 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: RP7xSqB66JgpD60FFVAma58rvZjcP5goJYJ0wFIiI2l+BSKquNJLJa2lYwvPanEZrNSONgbJDwI7lH7tXLLxlEutWKt5+0Kw+rbB12vrwxHJolSjWtT9X2bzTaLyWSYspUX//rFvCsZW2cgPoIXn9KXjMBYtbpdIahU/L/gsYU08UMcIcVBj9xjhFtM++p8iTr34z7MHSLC2g3PHbHhhZtiEr6/lk9ndWrmpOjFjR0x52IvnOhO0icUzQwQAmUEUt+vo4v/E1bnc7Nt++d8iYhrnv93SXf4k1GcWFUAOnF/Rqph2yCUy3BI1VQ7x5iogEYbxhTWREECvGia6g5W0p05t/pYxtOz6DIkZifekPUsXbQKbHZYwcnxwePr/oPkk3UPWKMj2A/8CnzpRHhHJBA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB5492 Return-Path: Tomas.Pilar@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT012.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)(39860400002)(136003)(396003)(346002)(376002)(46966005)(5660300002)(70586007)(107886003)(8936002)(70206006)(478600001)(2616005)(36756003)(316002)(4326008)(54906003)(86362001)(6916009)(26005)(6666004)(1076003)(186003)(30864003)(36906005)(47076004)(8676002)(336012)(81166007)(82310400002)(2906002)(82740400003)(426003);DIR:OUT;SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 4a606e81-4924-4398-a662-08d7fdb3208d X-Forefront-PRVS: 041032FF37 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ReH+od3zjOkvBRPM20+xXMWTNmh82p8ap/1NAWhGqIHjymFRF1t2OyKOhjGB5FBBe2yvRl9O7c89t3u68HyQEnMv5Pw9UoK5Py55XkwQ8SLXbd9F0fFzc4+W8asTLhn4uL7d1AH2jyfknRUR097z8B21yN8/R3E8GILYZoREMhmIV/kTHN0DQPrJoownAhp+DCDpsj1X6wV5MpLmGJ5XbJ3axuB/UP4CfTFMuq3OKVFT43UKDjtQCeOsmU1QUKVux1qp4oIISeWeVvebTFByF7SyM51ltBptZAQ15nydwsdiGPeq69HCytghq9oHvkC2F/zWEMYyhEnO31k6DyPTD5KGHId+QdV9RiD/Vf0uikZvs7mBJRfg9W8rJJZY/ldVtEGURIezEfNvZlq5eMWvm0+dHBMr7ZMauO1tHvtk4zosl0l0lPWeXm6HkDk+XDnFkEduysUTHrZw7D5m/5Ff/0EKpy0tJEeJNQouZlBAPUtY2688hCcgh9Mc3zwJ4j1I4kR+DRVLXW6OG6ZpHs3mwA== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2020 18:16:55.5788 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eec49768-9bf9-4641-3bcb-08d7fdb324ea 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: AM0PR08MB4483 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain 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/Shel= lPkg/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, TR= UE); - 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/Shel= lPkg/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 tab= les. + + @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/UefiShellAcpiView= CommandLib.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiVi= ewCommandLib.c index e0d5a8108552..c3942ad24e5b 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand= Lib.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand= Lib.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 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, TR= UE); + 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/UefiShellAcpiView= CommandLib.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiVi= ewCommandLib.h index c1cf7a57af7a..a3a29164004d 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand= Lib.h +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand= Lib.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 be= 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 confid= ential and may also be privileged. If you are not the intended recipient, p= lease notify the sender immediately and do not disclose the contents to any= other person, use it for any purpose, or store or copy the information in = any medium. Thank you.