From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (EUR01-VE1-obe.outbound.protection.outlook.com [40.107.14.42]) by mx.groups.io with SMTP id smtpd.web12.1964.1594748776738797137 for ; Tue, 14 Jul 2020 10:46:17 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=XSUYnHUK; spf=pass (domain: arm.com, ip: 40.107.14.42, 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=X0GoVxGGwvtXAkSaNskAvI+uRMSnnEPHpKriUDML7M0=; b=XSUYnHUK4OwRGozfOgKODQ5UTqQg8mFwpIu4+WzcgmYp3fE3NVRSpqx6v0sq7QDUBQ9uDsQVufwS/fW6fGG5OyehqETuCUTmggc5TOXvNXCkJfXmcNQ1qanuOs2QxqlfnNm932Oc2phw1lf4+O+V8EbsgmFpR/92WEWNnd1s138= Received: from AM6PR05CA0023.eurprd05.prod.outlook.com (2603:10a6:20b:2e::36) by DBBPR08MB4506.eurprd08.prod.outlook.com (2603:10a6:10:d0::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.23; Tue, 14 Jul 2020 17:46:11 +0000 Received: from AM5EUR03FT059.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:2e:cafe::58) by AM6PR05CA0023.outlook.office365.com (2603:10a6:20b:2e::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Tue, 14 Jul 2020 17:46:11 +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 AM5EUR03FT059.mail.protection.outlook.com (10.152.17.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Tue, 14 Jul 2020 17:46:11 +0000 Received: ("Tessian outbound 7de93d801f24:v62"); Tue, 14 Jul 2020 17:46:11 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: c1cd05599f0a3724 X-CR-MTA-TID: 64aa7808 Received: from d9ab9c04b973.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 3517DC92-9782-4410-84D7-92435A5D7402.1; Tue, 14 Jul 2020 17:46:05 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d9ab9c04b973.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 14 Jul 2020 17:46:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DUg3FkXVTGOawolB810k+KI0tkbn9ea3GAMZkOdrmyxtQ6NJCnqKuwPmsxkFnbKq0fSt1COiwgItj+UVwIJGG7B2Hfdxcg8o4ut3GiYHK3Vx6wQAUszr9uCAOvD0SCNmYT+9mrMmRgdj97uGeCWaZXe2erUr5a+UhMc1arOG8TSWlalpxknCVCf9yg7xyA1SkRnH8I8CGLLlNTWJPZ+xXYNf9ckUe7V07HWiq+hVWWD4Epy1dpSBnNkt6RwpAINwu7vXTaLKnoN0ZkieFj8g4CMSjxRbC8O/kJ/3YhQHaqwUfj9aDYfmcILv3KJ1jgOAycYRAeUbdRx+CU+svsOP8w== 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=X0GoVxGGwvtXAkSaNskAvI+uRMSnnEPHpKriUDML7M0=; b=NEJ3iwbWVLtWhHbrq4xLuaJMe1VHB9UCbkWhirSWO0tVUsDD9T86aKp88+4Ra0ESCwi14IC5WfdHLeu/fdCFlmzQaimQ0c3cbtQzm039XMm4ReUmI8ic2hrmwMlZwWv+pyQb92au+rLIy+s0OJUnJGZt6m6XtvLieBNyZZJRNr7eOMzXJ/2IYSVQLHKqgVckWSUjUfFjUc6HcFJDGUEDXpKn24OjP/d5l1EjWML6eCGxI2EN28dgHDqTXSsY5hWPFnz1L7mZfw3Rt5RxVrGR2htXEAUKzDMJ6uUmkuo+0UPcPzySsIj1dM/kkB55qemyAtuepLWbO4jQ3QQLAMDFRw== 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=X0GoVxGGwvtXAkSaNskAvI+uRMSnnEPHpKriUDML7M0=; b=XSUYnHUK4OwRGozfOgKODQ5UTqQg8mFwpIu4+WzcgmYp3fE3NVRSpqx6v0sq7QDUBQ9uDsQVufwS/fW6fGG5OyehqETuCUTmggc5TOXvNXCkJfXmcNQ1qanuOs2QxqlfnNm932Oc2phw1lf4+O+V8EbsgmFpR/92WEWNnd1s138= Received: from MRXP264CA0019.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:15::31) by HE1PR08MB2921.eurprd08.prod.outlook.com (2603:10a6:7:30::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20; Tue, 14 Jul 2020 17:46:03 +0000 Received: from VE1EUR03FT009.eop-EUR03.prod.protection.outlook.com (2603:10a6:500:15:cafe::c) by MRXP264CA0019.outlook.office365.com (2603:10a6:500:15::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.22 via Frontend Transport; Tue, 14 Jul 2020 17:46:03 +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 VE1EUR03FT009.mail.protection.outlook.com (10.152.18.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3174.21 via Frontend Transport; Tue, 14 Jul 2020 17:46:03 +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; Tue, 14 Jul 2020 17:46:00 +0000 Received: from localhost.localdomain (10.57.32.194) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Tue, 14 Jul 2020 17:46:00 +0000 From: "Tomas Pilar (tpilar)" To: CC: , , Ray Ni , "Zhichao Gao" Subject: [PATCH v3 1/8] ShellPkg/AcpiView: Extract configuration struct Date: Tue, 14 Jul 2020 18:45:39 +0100 Message-ID: <20200714174546.560-2-Tomas.Pilar@arm.com> X-Mailer: git-send-email 2.24.1.windows.2 In-Reply-To: <20200714174546.560-1-Tomas.Pilar@arm.com> References: <20200714174546.560-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)(46966005)(356005)(81166007)(82310400002)(70586007)(36756003)(83380400001)(8676002)(1076003)(70206006)(2906002)(30864003)(8936002)(5660300002)(54906003)(4326008)(6916009)(186003)(86362001)(47076004)(2616005)(426003)(336012)(6666004)(498600001)(26005);DIR:OUT;SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a4cc7767-b595-4849-1b38-08d8281dcbcf X-MS-TrafficTypeDiagnostic: HE1PR08MB2921:|DBBPR08MB4506: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:1824;OLM:1824; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: /cfc48Q7jPunKSOtuJ91LT2SrKkndm2WmRwcwoKeR+5+FmGnTLBpQAG6zsH2bUpLXBLPZATm4rvF4AmfpWNoL7ezXoVrgBtv3HZyvbppUIhprm9lW9m1D7BKqoQr026UIdp7fTO416jAtR4G5Zh40tIa5pXnbSLRulR7E9SMGxjfQ31uDUS1bRc6W3N+qBDbVB6iaUdZUhDTh7usfLlNAskmHcxgO948qUK0E3aZXrpxV1PXsPeLSzbsy2Jeq1+QAPv7AGx8lG+iJV366Q3EAYJhentTjKv4IuljwJ4vsay5YUBfMROWamnn4A6cmE8HBfaYCvzcDIq6ov9PreTGnv7AGmPplsOT7xd1Cf3bl1eo7rmXp885afOh/X7Bwq0tV4jmrQnMIdaSGWM8OLWucg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR08MB2921 Return-Path: Tomas.Pilar@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT059.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)(136003)(39860400002)(376002)(396003)(346002)(46966005)(83380400001)(82310400002)(30864003)(47076004)(5660300002)(316002)(36906005)(6666004)(70206006)(70586007)(1076003)(186003)(54906003)(36756003)(81166007)(8936002)(107886003)(8676002)(478600001)(4326008)(336012)(426003)(86362001)(2906002)(82740400003)(6916009)(26005)(2616005);DIR:OUT;SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 1cf42480-ebce-4edd-497d-08d8281dc72e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UfNojWl5DAm1wKUvZj2qaypIWs1WuLZz/rTo/kybvXnObTIeB6UDrZEOAnisKhNFh4x2L0gHNZBI3QnlDEUYxMk6GnBUs5knQTQO5fMbcUqRxju63MtrX0nBAYUDFiMqSH5V9mvxj2vku4964B3H8AOlL/iACQi9Pr2YO1N8Wz/shUu+/Q6NzSpDZezd0vu5D8rDof+c2iRQpfQcf50MSPuRx3JL7mhTdyCu/EpSje7fjfg+sHuidYsuI0djpAV6AEzeeXtgPqIGw48Im+zSfWng92xKLqDfQUd//UUYwGT3JnIr3BZJ7sj9kSzyhDEQOJmbdByMxDl7QvuJxN3WbFLjyIR679UpYIBkh+Fw1BLjmtsauognbUrnlcKJKrXs55lTTeWM9s8nvzGq26qsjQ== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2020 17:46:11.0665 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a4cc7767-b595-4849-1b38-08d8281dcbcf 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-AuthSource: AM5EUR03FT059.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4506 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain Remove accessor method bloat by creating a configuration struct that is linked using an extern symbol in the config header file. Directly reference the config struct for all read and write accesses in the entire module. Rationalise the remaining methods in the config header and source. Cc: Ray Ni Cc: Zhichao Gao Signed-off-by: Tomas Pilar --- .../UefiShellAcpiViewCommandLib/AcpiParser.c | 18 +- .../AcpiTableParser.c | 4 +- .../UefiShellAcpiViewCommandLib/AcpiView.c | 67 +++---- .../AcpiViewConfig.c | 180 ++---------------- .../AcpiViewConfig.h | 138 ++------------ .../UefiShellAcpiViewCommandLib.c | 18 +- 6 files changed, 70 insertions(+), 355 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c b/Sh= ellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c index 02f6d771c7e1..3a029b01cc20 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c @@ -137,7 +137,7 @@ VerifyChecksum ( if (Log) { OriginalAttribute =3D gST->ConOut->Mode->Attribute; if (Checksum =3D=3D 0) { - if (GetColourHighlighting ()) { + if (mConfig.ColourHighlighting) { gST->ConOut->SetAttribute ( gST->ConOut, EFI_TEXT_ATTR (EFI_GREEN, @@ -147,7 +147,7 @@ VerifyChecksum ( Print (L"Table Checksum : OK\n\n"); } else { IncrementErrorCount (); - if (GetColourHighlighting ()) { + if (mConfig.ColourHighlighting) { gST->ConOut->SetAttribute ( gST->ConOut, EFI_TEXT_ATTR (EFI_RED, @@ -156,7 +156,7 @@ VerifyChecksum ( } Print (L"Table Checksum : FAILED (0x%X)\n\n", Checksum); } - if (GetColourHighlighting ()) { + if (mConfig.ColourHighlighting) { gST->ConOut->SetAttribute (gST->ConOut, OriginalAttribute); } } @@ -507,7 +507,6 @@ ParseAcpi ( { UINT32 Index; UINT32 Offset; - BOOLEAN HighLight; UINTN OriginalAttribute; =20 // @@ -520,9 +519,8 @@ ParseAcpi ( gIndent +=3D Indent; =20 if (Trace && (AsciiName !=3D NULL)){ - HighLight =3D GetColourHighlighting (); =20 - if (HighLight) { + if (mConfig.ColourHighlighting) { OriginalAttribute =3D gST->ConOut->Mode->Attribute; gST->ConOut->SetAttribute ( gST->ConOut, @@ -537,7 +535,7 @@ ParseAcpi ( (OUTPUT_FIELD_COLUMN_WIDTH - gIndent), AsciiName ); - if (HighLight) { + if (mConfig.ColourHighlighting) { gST->ConOut->SetAttribute (gST->ConOut, OriginalAttribute); } } @@ -555,8 +553,7 @@ ParseAcpi ( continue; } =20 - if (GetConsistencyChecking () && - (Offset !=3D Parser[Index].Offset)) { + if (mConfig.ConsistencyCheck && (Offset !=3D Parser[Index].Offset)) { IncrementErrorCount (); Print ( L"\nERROR: %a: Offset Mismatch for %s\n" @@ -599,8 +596,7 @@ ParseAcpi ( =20 // Validating only makes sense if we are tracing // the parsed table entries, to report by table name. - if (GetConsistencyChecking () && - (Parser[Index].FieldValidator !=3D NULL)) { + if (mConfig.ConsistencyCheck && (Parser[Index].FieldValidator !=3D= NULL)) { Parser[Index].FieldValidator (Ptr, Parser[Index].Context); } } diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c= b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c index 4b618f131eac..526cb8cb7cad 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c @@ -222,13 +222,13 @@ ProcessAcpiTable ( return; } =20 - if (GetConsistencyChecking ()) { + if (mConfig.ConsistencyCheck) { VerifyChecksum (TRUE, Ptr, *AcpiTableLength); } } =20 #if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) - if (GetMandatoryTableValidate ()) { + if (mConfig.MandatoryTableValidate) { ArmSbbrIncrementTableCount (*AcpiTableSignature); } #endif diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c b/Shel= lPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c index 9a5b013fb234..d0a0edc45f3b 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c @@ -48,15 +48,12 @@ DumpAcpiTableToFile ( { CHAR16 FileNameBuffer[MAX_FILE_NAME_LEN]; UINTN TransferBytes; - SELECTED_ACPI_TABLE *SelectedTable; - - GetSelectedAcpiTable (&SelectedTable); =20 UnicodeSPrint ( FileNameBuffer, sizeof (FileNameBuffer), L".\\%s%04d.bin", - SelectedTable->Name, + mSelectedAcpiTable.Name, mBinTableCount++ ); =20 @@ -82,11 +79,9 @@ ProcessTableReportOptions ( IN CONST UINT32 Length ) { - UINTN OriginalAttribute; - UINT8 *SignaturePtr; - BOOLEAN Log; - BOOLEAN HighLight; - SELECTED_ACPI_TABLE *SelectedTable; + UINTN OriginalAttribute; + UINT8 *SignaturePtr; + BOOLEAN Log; =20 // // set local variables to suppress incorrect compiler/analyzer warnings @@ -94,22 +89,20 @@ ProcessTableReportOptions ( OriginalAttribute =3D 0; SignaturePtr =3D (UINT8*)(UINTN)&Signature; Log =3D FALSE; - HighLight =3D GetColourHighlighting (); - GetSelectedAcpiTable (&SelectedTable); =20 - switch (GetReportOption ()) { + switch (mConfig.ReportType) { case ReportAll: Log =3D TRUE; break; case ReportSelected: - if (Signature =3D=3D SelectedTable->Type) { + if (Signature =3D=3D mSelectedAcpiTable.Type) { Log =3D TRUE; - SelectedTable->Found =3D TRUE; + mSelectedAcpiTable.Found =3D TRUE; } break; case ReportTableList: if (mTableCount =3D=3D 0) { - if (HighLight) { + if (mConfig.ColourHighlighting) { OriginalAttribute =3D gST->ConOut->Mode->Attribute; gST->ConOut->SetAttribute ( gST->ConOut, @@ -118,7 +111,7 @@ ProcessTableReportOptions ( ); } Print (L"\nInstalled Table(s):\n"); - if (HighLight) { + if (mConfig.ColourHighlighting) { gST->ConOut->SetAttribute (gST->ConOut, OriginalAttribute); } } @@ -132,8 +125,8 @@ ProcessTableReportOptions ( ); break; case ReportDumpBinFile: - if (Signature =3D=3D SelectedTable->Type) { - SelectedTable->Found =3D TRUE; + if (Signature =3D=3D mSelectedAcpiTable.Type) { + mSelectedAcpiTable.Found =3D TRUE; DumpAcpiTableToFile (TablePtr, Length); } break; @@ -144,7 +137,7 @@ ProcessTableReportOptions ( } // switch =20 if (Log) { - if (HighLight) { + if (mConfig.ColourHighlighting) { OriginalAttribute =3D gST->ConOut->Mode->Attribute; gST->ConOut->SetAttribute ( gST->ConOut, @@ -159,7 +152,7 @@ ProcessTableReportOptions ( SignaturePtr[2], SignaturePtr[3] ); - if (HighLight) { + if (mConfig.ColourHighlighting) { gST->ConOut->SetAttribute (gST->ConOut, OriginalAttribute); } } @@ -191,18 +184,12 @@ AcpiView ( BOOLEAN FoundAcpiTable; UINTN OriginalAttribute; UINTN PrintAttribute; - EREPORT_OPTION ReportOption; UINT8* RsdpPtr; UINT32 RsdpLength; UINT8 RsdpRevision; PARSE_ACPI_TABLE_PROC RsdpParserProc; BOOLEAN Trace; - SELECTED_ACPI_TABLE *SelectedTable; =20 - // - // set local variables to suppress incorrect compiler/analyzer warnings - // - EfiConfigurationTable =3D NULL; OriginalAttribute =3D 0; =20 // Reset Table counts @@ -213,9 +200,6 @@ AcpiView ( ResetErrorCount (); ResetWarningCount (); =20 - // Retrieve the user selection of ACPI table to process - GetSelectedAcpiTable (&SelectedTable); - // Search the table for an entry that matches the ACPI Table Guid FoundAcpiTable =3D FALSE; for (Index =3D 0; Index < SystemTable->NumberOfTableEntries; Index++) { @@ -241,7 +225,7 @@ AcpiView ( } =20 #if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) - if (GetMandatoryTableValidate ()) { + if (mConfig.MandatoryTableValidate) { ArmSbbrResetTableCounts (); } #endif @@ -275,24 +259,23 @@ AcpiView ( } =20 #if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) - if (GetMandatoryTableValidate ()) { - ArmSbbrReqsValidate ((ARM_SBBR_VERSION)GetMandatoryTableSpec ()); + if (mConfig.MandatoryTableValidate) { + ArmSbbrReqsValidate ((ARM_SBBR_VERSION) mConfig.MandatoryTableSpec); } #endif =20 - ReportOption =3D GetReportOption (); - if (ReportTableList !=3D ReportOption) { - if (((ReportSelected =3D=3D ReportOption) || - (ReportDumpBinFile =3D=3D ReportOption)) && - (!SelectedTable->Found)) { + if (ReportTableList !=3D mConfig.ReportType) { + if (((ReportSelected =3D=3D mConfig.ReportType) || + (ReportDumpBinFile =3D=3D mConfig.ReportType)) && + (!mSelectedAcpiTable.Found)) { Print (L"\nRequested ACPI Table not found.\n"); - } else if (GetConsistencyChecking () && - (ReportDumpBinFile !=3D ReportOption)) { + } else if (mConfig.ConsistencyCheck && + (ReportDumpBinFile !=3D mConfig.ReportType)) { OriginalAttribute =3D gST->ConOut->Mode->Attribute; =20 Print (L"\nTable Statistics:\n"); =20 - if (GetColourHighlighting ()) { + if (mConfig.ColourHighlighting) { PrintAttribute =3D (GetErrorCount () > 0) ? EFI_TEXT_ATTR ( EFI_RED, @@ -303,7 +286,7 @@ AcpiView ( } Print (L"\t%d Error(s)\n", GetErrorCount ()); =20 - if (GetColourHighlighting ()) { + if (mConfig.ColourHighlighting) { PrintAttribute =3D (GetWarningCount () > 0) ? EFI_TEXT_ATTR ( EFI_RED, @@ -315,7 +298,7 @@ AcpiView ( } Print (L"\t%d Warning(s)\n", GetWarningCount ()); =20 - if (GetColourHighlighting ()) { + if (mConfig.ColourHighlighting) { gST->ConOut->SetAttribute (gST->ConOut, OriginalAttribute); } } diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.c = b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.c index 759a915928c7..a0a392085355 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.c @@ -10,12 +10,8 @@ =20 #include "AcpiViewConfig.h" =20 -// Report variables -STATIC BOOLEAN mConsistencyCheck; -STATIC BOOLEAN mColourHighlighting; -STATIC EREPORT_OPTION mReportType; -STATIC BOOLEAN mMandatoryTableValidate; -STATIC UINTN mMandatoryTableSpec; +// Main configuration structure +ACPI_VIEW_CONFIG mConfig; =20 // User selection of which ACPI table should be checked SELECTED_ACPI_TABLE mSelectedAcpiTable; @@ -25,17 +21,21 @@ SELECTED_ACPI_TABLE mSelectedAcpiTable; **/ VOID EFIAPI -AcpiConfigSetDefaults ( +AcpiViewConfigSetDefaults ( VOID ) { - mReportType =3D ReportAll; + // Generic defaults + mConfig.ReportType =3D ReportAll; + mConfig.ConsistencyCheck =3D TRUE; + mConfig.MandatoryTableValidate =3D FALSE; + mConfig.MandatoryTableSpec =3D 0; + mConfig.ColourHighlighting =3D FALSE; + + // Unselect acpi table mSelectedAcpiTable.Type =3D 0; mSelectedAcpiTable.Name =3D NULL; mSelectedAcpiTable.Found =3D FALSE; - mConsistencyCheck =3D TRUE; - mMandatoryTableValidate =3D FALSE; - mMandatoryTableSpec =3D 0; } =20 /** @@ -79,7 +79,7 @@ ConvertStrToAcpiSignature ( **/ VOID EFIAPI -SelectAcpiTable ( +AcpiViewConfigSelectTable ( IN CONST CHAR16 *TableName ) { @@ -88,159 +88,3 @@ SelectAcpiTable ( mSelectedAcpiTable.Name =3D TableName; mSelectedAcpiTable.Type =3D ConvertStrToAcpiSignature (mSelectedAcpiTabl= e.Name); } - -/** - This function returns the selected ACPI table. - - @param [out] SelectedAcpiTable Pointer that will contain the returned st= ruct. -**/ -VOID -EFIAPI -GetSelectedAcpiTable ( - OUT SELECTED_ACPI_TABLE **SelectedAcpiTable - ) -{ - *SelectedAcpiTable =3D &mSelectedAcpiTable; -} - -/** - This function returns the colour highlighting status. - - @retval TRUE Colour highlighting is enabled. -**/ -BOOLEAN -EFIAPI -GetColourHighlighting ( - VOID - ) -{ - return mColourHighlighting; -} - -/** - This function sets the colour highlighting status. - - @param [in] Highlight The highlight status. -**/ -VOID -EFIAPI -SetColourHighlighting ( - BOOLEAN Highlight - ) -{ - mColourHighlighting =3D Highlight; -} - -/** - This function returns the consistency checking status. - - @retval TRUE Consistency checking is enabled. -**/ -BOOLEAN -EFIAPI -GetConsistencyChecking ( - VOID - ) -{ - return mConsistencyCheck; -} - -/** - This function sets the consistency checking status. - - @param [in] ConsistencyChecking The consistency checking status. -**/ -VOID -EFIAPI -SetConsistencyChecking ( - BOOLEAN ConsistencyChecking - ) -{ - mConsistencyCheck =3D ConsistencyChecking; -} - -/** - This function returns the report options. - - @return The current report option. -**/ -EREPORT_OPTION -EFIAPI -GetReportOption ( - VOID - ) -{ - return mReportType; -} - -/** - This function sets the report options. - - @param [in] ReportType The report option to set. -**/ -VOID -EFIAPI -SetReportOption ( - EREPORT_OPTION ReportType - ) -{ - mReportType =3D ReportType; -} - -/** - This function returns the ACPI table requirements validation flag. - - @retval TRUE Check for mandatory table presence should be performed. -**/ -BOOLEAN -EFIAPI -GetMandatoryTableValidate ( - VOID - ) -{ - return mMandatoryTableValidate; -} - -/** - This function sets the ACPI table requirements validation flag. - - @param [in] Validate Enable/Disable ACPI table requirements validation. -**/ -VOID -EFIAPI -SetMandatoryTableValidate ( - BOOLEAN Validate - ) -{ - mMandatoryTableValidate =3D Validate; -} - -/** - This function returns the identifier of specification to validate ACPI t= able - requirements against. - - @return ID of specification listing mandatory tables. -**/ -UINTN -EFIAPI -GetMandatoryTableSpec ( - VOID - ) -{ - return mMandatoryTableSpec; -} - -/** - This function sets the identifier of specification to validate ACPI tabl= e - requirements against. - - @param [in] Spec ID of specification listing mandatory tables. -**/ -VOID -EFIAPI -SetMandatoryTableSpec ( - UINTN Spec - ) -{ - mMandatoryTableSpec =3D Spec; -} diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h = b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h index 2db4a65415d8..1883145d04a4 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h @@ -8,96 +8,6 @@ #ifndef ACPI_VIEW_CONFIG_H_ #define ACPI_VIEW_CONFIG_H_ =20 -/** - This function returns the colour highlighting status. - - @retval TRUE Colour highlighting is enabled. -**/ -BOOLEAN -EFIAPI -GetColourHighlighting ( - VOID - ); - -/** - This function sets the colour highlighting status. - - @param [in] Highlight The highlight status. -**/ -VOID -EFIAPI -SetColourHighlighting ( - BOOLEAN Highlight - ); - -/** - This function returns the consistency checking status. - - @retval TRUE Consistency checking is enabled. -**/ -BOOLEAN -EFIAPI -GetConsistencyChecking ( - VOID - ); - -/** - This function sets the consistency checking status. - - @param [in] ConsistencyChecking The consistency checking status. -**/ -VOID -EFIAPI -SetConsistencyChecking ( - BOOLEAN ConsistencyChecking - ); - -/** - This function returns the ACPI table requirements validation flag. - - @retval TRUE Check for mandatory table presence should be performed. -**/ -BOOLEAN -EFIAPI -GetMandatoryTableValidate ( - VOID - ); - -/** - This function sets the ACPI table requirements validation flag. - - @param [in] Validate Enable/Disable ACPI table requirements validation. -**/ -VOID -EFIAPI -SetMandatoryTableValidate ( - BOOLEAN Validate - ); - -/** - This function returns the identifier of specification to validate ACPI t= able - requirements against. - - @return ID of specification listing mandatory tables. -**/ -UINTN -EFIAPI -GetMandatoryTableSpec ( - VOID - ); - -/** - This function sets the identifier of specification to validate ACPI tabl= e - requirements against. - - @param [in] Spec ID of specification listing mandatory tables. -**/ -VOID -EFIAPI -SetMandatoryTableSpec ( - UINTN Spec - ); - /** The EREPORT_OPTION enum describes ACPI table Reporting options. **/ @@ -109,28 +19,6 @@ typedef enum { ReportMax, } EREPORT_OPTION; =20 -/** - This function returns the report options. - - @return The current report option. -**/ -EREPORT_OPTION -EFIAPI -GetReportOption ( - VOID - ); - -/** - This function sets the report options. - - @param [in] ReportType The report option to set. -**/ -VOID -EFIAPI -SetReportOption ( - EREPORT_OPTION ReportType - ); - /** A structure holding the user selection detailing which ACPI table is to be examined by the AcpiView code. @@ -142,15 +30,15 @@ typedef struct { } SELECTED_ACPI_TABLE; =20 /** - This function returns the selected ACPI table. - - @param [out] SelectedAcpiTable Pointer that will contain the returned st= ruct. + Configuration struct for the acpiview command. **/ -VOID -EFIAPI -GetSelectedAcpiTable ( - OUT SELECTED_ACPI_TABLE** SelectedAcpiTable - ); +typedef struct { + BOOLEAN ConsistencyCheck; ///< Enable consistency chec= ks when processing tables + BOOLEAN ColourHighlighting; ///< Enable UEFI shell colou= r codes in output + EREPORT_OPTION ReportType; ///< Type of report to creat= e + BOOLEAN MandatoryTableValidate; ///< Validate presence of ma= ndatory tables + UINTN MandatoryTableSpec; ///< Specification of which = tables are mandatory +} ACPI_VIEW_CONFIG; =20 /** This function selects an ACPI table in current context. @@ -161,8 +49,8 @@ GetSelectedAcpiTable ( **/ VOID EFIAPI -SelectAcpiTable ( - CONST CHAR16* TableName +AcpiViewConfigSelectTable ( + CONST CHAR16 *TableName ); =20 /** @@ -170,8 +58,12 @@ SelectAcpiTable ( **/ VOID EFIAPI -AcpiConfigSetDefaults ( +AcpiViewConfigSetDefaults ( VOID ); =20 +extern ACPI_VIEW_CONFIG mConfig; +extern SELECTED_ACPI_TABLE mSelectedAcpiTable; + #endif // ACPI_VIEW_CONFIG_H_ + diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiView= CommandLib.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiVi= ewCommandLib.c index d2f26ff89f12..9613c16f5703 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand= Lib.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand= Lib.c @@ -197,7 +197,7 @@ ShellCommandRunAcpiView ( CONST CHAR16* SelectedTableName; =20 // Set configuration defaults - AcpiConfigSetDefaults (); + AcpiViewConfigSetDefaults (); =20 ShellStatus =3D SHELL_SUCCESS; Package =3D NULL; @@ -290,31 +290,31 @@ ShellCommandRunAcpiView ( ShellStatus =3D SHELL_INVALID_PARAMETER; } else { // Turn on colour highlighting if requested - SetColourHighlighting (ShellCommandLineGetFlag (Package, L"-h")); + mConfig.ColourHighlighting =3D ShellCommandLineGetFlag (Package, L"-= h"); =20 // Surpress consistency checking if requested - SetConsistencyChecking (!ShellCommandLineGetFlag (Package, L"-q")); + mConfig.ConsistencyCheck =3D !ShellCommandLineGetFlag (Package, L"-q= "); =20 // Evaluate the parameters for mandatory ACPI table presence checks - SetMandatoryTableValidate (ShellCommandLineGetFlag (Package, L"-r"))= ; + mConfig.MandatoryTableValidate =3D ShellCommandLineGetFlag (Package,= L"-r"); MandatoryTableSpecStr =3D ShellCommandLineGetValue (Package, L"-r"); =20 if (MandatoryTableSpecStr !=3D NULL) { - SetMandatoryTableSpec (ShellHexStrToUintn (MandatoryTableSpecStr))= ; + mConfig.MandatoryTableSpec =3D ShellHexStrToUintn (MandatoryTableS= pecStr); } =20 if (ShellCommandLineGetFlag (Package, L"-l")) { - SetReportOption (ReportTableList); + mConfig.ReportType =3D ReportTableList; } else { SelectedTableName =3D ShellCommandLineGetValue (Package, L"-s"); if (SelectedTableName !=3D NULL) { - SelectAcpiTable (SelectedTableName); - SetReportOption (ReportSelected); + AcpiViewConfigSelectTable (SelectedTableName); + mConfig.ReportType =3D ReportSelected; =20 if (ShellCommandLineGetFlag (Package, L"-d")) { // Create a temporary file to check if the media is writable. CHAR16 FileNameBuffer[MAX_FILE_NAME_LEN]; - SetReportOption (ReportDumpBinFile); + mConfig.ReportType =3D ReportDumpBinFile; =20 UnicodeSPrint ( FileNameBuffer, --=20 2.24.1.windows.2