From nobody Fri May 3 03:13:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62379+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1594549965526647.1125423512096; Sun, 12 Jul 2020 03:32:45 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id YNJjYY1788612xAmcgBPrlEm; Sun, 12 Jul 2020 03:32:45 -0700 X-Received: from EUR05-DB8-obe.outbound.protection.outlook.com (EUR05-DB8-obe.outbound.protection.outlook.com [40.107.20.61]) by mx.groups.io with SMTP id smtpd.web12.6631.1594549962932168784 for ; Sun, 12 Jul 2020 03:32:43 -0700 X-Received: from DB6PR0802CA0041.eurprd08.prod.outlook.com (2603:10a6:4:a3::27) by DB7PR08MB2953.eurprd08.prod.outlook.com (2603:10a6:5:1b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21; Sun, 12 Jul 2020 10:32:39 +0000 X-Received: from DB5EUR03FT015.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:a3:cafe::50) by DB6PR0802CA0041.outlook.office365.com (2603:10a6:4:a3::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20 via Frontend Transport; Sun, 12 Jul 2020 10:32:38 +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 (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+62379+1787277+3901457@groups.io; helo=web01.groups.io; 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; X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT015.mail.protection.outlook.com (10.152.20.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Sun, 12 Jul 2020 10:32:38 +0000 X-Received: ("Tessian outbound 1dc58800d5dd:v62"); Sun, 12 Jul 2020 10:32:38 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 2c9328c0044a748a X-CR-MTA-TID: 64aa7808 X-Received: from 26ad25260613.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 8009DD9F-7379-487D-81C2-AE0119665844.1; Sun, 12 Jul 2020 10:32:33 +0000 X-Received: from EUR03-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 26ad25260613.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Sun, 12 Jul 2020 10:32:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CaHA4MXydCLKEDdY8rWmSHogyjibJMkhHssROg9jPGk0PEk/B3S3/qd/LcCDS0e9IJ4C/XRBJWzQwo2u3URB1Kd6HJ427a6ZyNv16XywghXLwXrY9+bc5WZc7+Jbq69rHiMNPVAZ+VnJNw/NLni7SbqsTo6jXtM/sJ4qazKKy4q1UDyUrXASu3a0z0YdV5deifRZWpLsqNq/TokFHtzvU1rVkE/fnGQGHBQh1SF+7GkJIOGUMVZmLEs2y20wAbEclFDPGIb+4O4R3acbvxo1plOHpO2dX14olZCtye5VsoPeN7aCl7laT5A8jOABqBmcTQz4RhadNHJv7Qg7Dhnlhg== 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=ywAJ8bj+6HdyWpQGXU0uAExr6WBwUtOtZBtsHtHSU7Y=; b=ZpTqVynhhJQFSShaGuRlRE4OZ/oLqOtEgtHpeoPdApXSm/Tr+m/QdATBGzk1+GJNU+HvRzEmKt3p+PSezW0o0j2M+zHTn3y9pGX7yLxaMFUB4PAkg5YhYjLdAQsSJKSPQKkkIol+E7n/zPuNTCPCeZ/wI/rHS4A4N2DHwSihXxy4L0moiMxwfFU+DuKGKOaSvRylXIHwuXYLN34H2AWKM9KERdJa+WHRwDYf/SUjze3mMjJJw25VDuZzoYWhE4zJeeNaV1a2zOy5a/lEbpHoXNMXjVmk19qGHe6J/QKqUk4BGy4Up0AoBnIVBasHtv6vLFJUd6g2qxPGKcvZbRTrnw== 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 X-Received: from MR2P264CA0003.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:1::15) by AM6PR08MB3143.eurprd08.prod.outlook.com (2603:10a6:209:45::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21; Sun, 12 Jul 2020 10:32:30 +0000 X-Received: from VE1EUR03FT020.eop-EUR03.prod.protection.outlook.com (2603:10a6:500:1:cafe::19) by MR2P264CA0003.outlook.office365.com (2603:10a6:500:1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20 via Frontend Transport; Sun, 12 Jul 2020 10:32:30 +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; X-Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT020.mail.protection.outlook.com (10.152.18.242) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3174.21 via Frontend Transport; Sun, 12 Jul 2020 10:32:30 +0000 X-Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1415.2; Sun, 12 Jul 2020 10:32:29 +0000 X-Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1779.2; Sun, 12 Jul 2020 10:32:28 +0000 X-Received: from localhost.localdomain (10.57.55.192) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Sun, 12 Jul 2020 10:32:28 +0000 From: "Tomas Pilar (tpilar)" To: CC: , , Ray Ni , "Zhichao Gao" Subject: [edk2-devel] [PATCH v2 1/8] ShellPkg/AcpiView: Extract configuration struct Date: Sun, 12 Jul 2020 11:32:08 +0100 Message-ID: <20200712103215.855-2-Tomas.Pilar@arm.com> In-Reply-To: <20200712103215.855-1-Tomas.Pilar@arm.com> References: <20200712103215.855-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)(396003)(136003)(39850400004)(346002)(376002)(46966005)(5660300002)(83380400001)(36756003)(70206006)(70586007)(1076003)(30864003)(6916009)(478600001)(316002)(47076004)(336012)(82740400003)(54906003)(2616005)(8676002)(2906002)(8936002)(426003)(356005)(4326008)(186003)(82310400002)(6666004)(86362001)(26005)(81166007);DIR:OUT;SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f22ef083-c7f1-43b9-2c91-08d8264ee64e X-MS-TrafficTypeDiagnostic: AM6PR08MB3143:|DB7PR08MB2953: 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: 2j8LWmK28mD1xtQ/XMY2o+kbLM8GcDHhVwBSs80VvjJhQ2AtFqhob17jR2YpNmxjtFfWVXviaMGg6mDM6tGWUam7Bj1XUoORgulWi1rMe7efHcF9CVZ0/EnZ3VnqUbdWPA85VDk3tn/zgcpQBrGIG1Xsph5awlkofiyy/m/kxIY1pvFjSVxdugDYdji22a+tDtekB0m5rzNPq2VkEGidHo1SbWIvv7qMhDn1ZukSYBerABJmPb/v5ylXLslmxu28sJJOoB3msmW7asS6vxnRAPqnVLY7UTkVY6giBoIilNRN+ns9OPmTWpZBIQnyCWknU/YN0OP1EusYARaeJ7Aptb/LNTYzTQyHuamMV6hwVpPXQ22nsX+Rw26q5KevyROTkdQwB6ZfWlXSqchNmjC9Sg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3143 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT015.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: a1cc8a1a-1be5-4581-efaa-08d8264ee157 X-Microsoft-Antispam-Message-Info: FqoUV7uhkAUVeyQjLDrvPne1KbbMJw4GhShU6iJlJ7Rf2fu9lG6FRQZSbjHmWdoKHjbdHoUK0f9cCAOJpGyJkoPZvU5IGJ6n+PtemrA+y6dfot5+yT2zQ2L3fEykrn+12NRuib6cyE1yF8hKmvsSNhUznnyjTHPrW0O+gf+n2aJCAOlZDIfeZIta5Dr5jD3vun2R23KTATM6RdNyQSQrOVRHE3rGEz7tkciUDY5Px/5/v0qVqoA0fg3bL1+RG5yND60/QKfNxDtGfmvHXAkJqPiDpWXrFHeDeTD8UwEJQ5uMTPtfOq9jtvLG/TCF+52rZvpuys8D9LAEEQFFjFBULrGMSVGK+HXjXX29tmRXEXtjQKdn+lmUzmKu3KlCWOLr5N2VrgLu7oxOCSd7UjkMIw== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2020 10:32:38.6032 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f22ef083-c7f1-43b9-2c91-08d8264ee64e 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: DB5EUR03FT015.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB2953 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,Tomas.Pilar@arm.com X-Gm-Message-State: KGQILn2kkMbSyDcBnGRdEKIMx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1594549965; bh=Q3OKhCOapPX9R5zzuEvf4kMbFa2LiSCv46tTs/w7WIo=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=UIm8OayaFUDZbrO8uMrKuPsfAkh8BPLst5lP7cAZA60UfceoCcoGQKvx1WxYuzHdkqs G7kfsTb54n3lEp6V3e1WoFhN/3HESy6f4F/BO+5QEf8IbBJW9p/ZXShoNHdm0DtfLOa6P XVbpv/j3nEuGzQWd7lNFJYV4rAsAv1WN5Mw= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" 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. Change-Id: Id19058caf875c5502f5a21ecec2db8b77361cb08 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 table - 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 table - 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 create + 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 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#62379): https://edk2.groups.io/g/devel/message/62379 Mute This Topic: https://groups.io/mt/75454452/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri May 3 03:13:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62375+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 159454996684627.317200009659587; Sun, 12 Jul 2020 03:32:46 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id wWnCYY1788612xQX8IScdxbp; Sun, 12 Jul 2020 03:32:46 -0700 X-Received: from EUR04-HE1-obe.outbound.protection.outlook.com (EUR04-HE1-obe.outbound.protection.outlook.com [40.107.7.84]) by mx.groups.io with SMTP id smtpd.web12.6627.1594549961909766441 for ; Sun, 12 Jul 2020 03:32:43 -0700 X-Received: from AM6P192CA0065.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:82::42) by VI1PR0801MB1696.eurprd08.prod.outlook.com (2603:10a6:800:51::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20; Sun, 12 Jul 2020 10:32:39 +0000 X-Received: from VE1EUR03FT049.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:82:cafe::8c) by AM6P192CA0065.outlook.office365.com (2603:10a6:209:82::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Sun, 12 Jul 2020 10:32:38 +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 (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+62375+1787277+3901457@groups.io; helo=web01.groups.io; 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; X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT049.mail.protection.outlook.com (10.152.19.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Sun, 12 Jul 2020 10:32:38 +0000 X-Received: ("Tessian outbound 1c27ecaec3d6:v62"); Sun, 12 Jul 2020 10:32:38 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: f4ccd03dcdca4435 X-CR-MTA-TID: 64aa7808 X-Received: from f8230f27f8be.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id B254D1C4-269B-4B20-8E98-9F1F910E1465.1; Sun, 12 Jul 2020 10:32:33 +0000 X-Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f8230f27f8be.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Sun, 12 Jul 2020 10:32:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H0s+IzbxvgER21zBCtDcbSzlWzTVNmdYS4ORDKyLU3rOW5zTXMrbLKdBGgeOzIklUnumV57CnO+6pu6gPxoz+G3Xbv3n5ORbOEJNDNeUtCHEA0s+1NiobV5NI5Kls0g+rytJGFZWOWlcX+PGrD8d5N1cnZSaI95JUzcwYDgmCFNyFl6Z2cJXzckA52SFutmaVU4/e5V4aQpUmJilZKYpjgDfg2SUcwcTb5IVf1c7g0RCfSTIVQQOaQ29HIKNelocT3dBWDmrcvZwlgkyJu71PXFAy5EHYD76ugbPXkRQVvadtFjijmyGN7GKVunxdPCgr+KFeDa8ivhjHYPEpnMkgg== 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=A7PliNOrj9qgZNh+9jyMkscQaSHchAilra5ny3f7Cjw=; b=ag8PW6Eu+oTrAixzq9IS5mBFuRSNxPwfx/sOSKAzAF48kBYas6TxMtmEeNpoCVSYfrflbFa7zCipCExKzZGv6vj3rdtsb8YdPWKQtMzVCyn7k81500S8qMXJ1/2ZAFG0mJ2Qy5LW6CZ7i39zylLYSWNOrGvH8+8ZGw2M50AOMohIrS/qOVAsgkE7Vc6l7jW7Gh05sCtoiw/BAZEcCSp4eSI/yDiWaueE+IWRqgWqzWHJNxRty2ZwM9gNVTWem+pTpaTgabeT/HrcajE26PK3UPMUvJMyum8W56R6QD8SlnaETVDk+ZrGANyjDkLAfJ4gwd8s1OykCjaWn7sweUcBkQ== 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 X-Received: from DBBPR09CA0015.eurprd09.prod.outlook.com (2603:10a6:10:c0::27) by DB8PR08MB5340.eurprd08.prod.outlook.com (2603:10a6:10:11c::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.22; Sun, 12 Jul 2020 10:32:30 +0000 X-Received: from DB5EUR03FT008.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:c0:cafe::ee) by DBBPR09CA0015.outlook.office365.com (2603:10a6:10:c0::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Sun, 12 Jul 2020 10:32:29 +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; X-Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT008.mail.protection.outlook.com (10.152.20.98) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3174.21 via Frontend Transport; Sun, 12 Jul 2020 10:32:29 +0000 X-Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1415.2; Sun, 12 Jul 2020 10:32:29 +0000 X-Received: from localhost.localdomain (10.57.55.192) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Sun, 12 Jul 2020 10:32:28 +0000 From: "Tomas Pilar (tpilar)" To: CC: , , Ray Ni , "Zhichao Gao" Subject: [edk2-devel] [PATCH v2 2/8] ShellPkg/AcpiView: Declutter error counters Date: Sun, 12 Jul 2020 11:32:09 +0100 Message-ID: <20200712103215.855-3-Tomas.Pilar@arm.com> In-Reply-To: <20200712103215.855-1-Tomas.Pilar@arm.com> References: <20200712103215.855-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)(396003)(346002)(136003)(39850400004)(376002)(46966005)(4326008)(426003)(2906002)(81166007)(70206006)(356005)(186003)(70586007)(82310400002)(82740400003)(54906003)(26005)(47076004)(1076003)(36756003)(336012)(478600001)(86362001)(8936002)(83380400001)(5660300002)(6666004)(6916009)(8676002)(316002)(2616005);DIR:OUT;SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fc3080f9-2886-4d5f-77ea-08d8264ee655 X-MS-TrafficTypeDiagnostic: DB8PR08MB5340:|VI1PR0801MB1696: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:107;OLM:107; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: TH14gQm0V/j6apZAs99x+WqJ29+roZvlywoIEF7kM5aYSLVUbsUNm/6Hb/1z9qKDNExoNqIX3D4KJDgN5mwYWfnTioKRape6ubP6KnfhHN2MuxkmkOputnUpAQOfR0GBXlIVdzmf79qkgrcHJ/q5ZuhfJ741eJ/rkQoZ2KM8pyF63x8bKgLw5pLSpxATzpVEtpbFUiJLkjpG0E8B0f1Y7ulfirlsliYuGLiDyIn9gp3ya7e3u5Vb1CRaXI2zH3FWAnauZ/0Dg70nskOSTllOarOM9xy8OycmHTKmU3iOka6UvgPby96UWWxGAKxwz2WiyfGd9jLF7uIR3lrw9RIs1BDV41KtoUwYmbCg39+vpCKeVoK3kphQ+gZ7hzzeZ2ltCbo++JQ95wL00b2uyirhYg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5340 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT049.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 07fc4d4c-d771-48ed-2b95-08d8264ee11a X-Microsoft-Antispam-Message-Info: 1ZfxSSDu5Jplrn/cb3Gyp0ZkXBMGv9YGOA1BoslNfv/YyvEKVOo5fycIP/oCGTPxMenxYiEx4UA4kOzqlbGhC4oGp7xm8QyOq5IhMCwj6EKQaRTnbsHOi4qDubckLKtrxXNqyoM7kZM/Z0dXAaHq9DQuB/jGL2h4os8OZU+VtmhIGSCthXcExLtlwYS9uODmKlEDidjUBGqgpq8fcQfjU8PnzUMdMpeH//iy8svOuyB9Rb9fn3/mVjb7Vffx+N/u8L6AhQDHTWWOsouSyYWVMW5lxO+sV5zSgLBg1MaNf2sdYnMYHNaB8RRL5vczsWPb+sFwBpQ4uJixjMZArL1gDAHgws6H/IMc0JZ6gYnL38chyXnXhA/lpLv4XJTl2++p90Wfb7rJXAGG1nP8YySnYg== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2020 10:32:38.5111 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fc3080f9-2886-4d5f-77ea-08d8264ee655 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: VE1EUR03FT049.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1696 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,Tomas.Pilar@arm.com X-Gm-Message-State: YQOpFqkSwcNwTDUt6TFHvtq3x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1594549966; bh=6CVaS/7YK8V7n+3fRo/r10Ux4t8cT7vl94yY5azgC1Q=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=eYFAeqT1xdbRNnzObobEucQGl/JSd/ykkkjzOiPCnVdUFjRfhJtrKr6Fe1GqWiNuwkN pwLpDqtQkg9JHpZpTX4GQu6eJFGZlWSbHV9IW5Uof52lqNIjUCoOUUVasHLnUQrPthCWa LaRDU1a+P2m0LaciI4c+BZiJkrfk2TWZ23g= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Remove superfluous accessor methods for error and warning counters. Change-Id: I23df0aa10cfc757f37d83dee7ecce8a188a3ad1c Cc: Ray Ni Cc: Zhichao Gao Signed-off-by: Tomas Pilar --- .../UefiShellAcpiViewCommandLib/AcpiParser.c | 54 ++----------------- .../UefiShellAcpiViewCommandLib/AcpiParser.h | 4 ++ .../UefiShellAcpiViewCommandLib/AcpiView.c | 12 ++--- .../UefiShellAcpiViewCommandLib/AcpiView.h | 36 ------------- 4 files changed, 14 insertions(+), 92 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c b/Sh= ellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c index 3a029b01cc20..7017fa93efae 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c @@ -13,8 +13,10 @@ #include "AcpiViewConfig.h" =20 STATIC UINT32 gIndent; -STATIC UINT32 mTableErrorCount; -STATIC UINT32 mTableWarningCount; + +// Publicly accessible error and warning counters. +UINT32 mTableErrorCount; +UINT32 mTableWarningCount; =20 STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; =20 @@ -25,54 +27,6 @@ STATIC CONST ACPI_PARSER AcpiHeaderParser[] =3D { PARSE_ACPI_HEADER (&AcpiHdrInfo) }; =20 -/** - This function resets the ACPI table error counter to Zero. -**/ -VOID -ResetErrorCount ( - VOID - ) -{ - mTableErrorCount =3D 0; -} - -/** - This function returns the ACPI table error count. - - @retval Returns the count of errors detected in the ACPI tables. -**/ -UINT32 -GetErrorCount ( - VOID - ) -{ - return mTableErrorCount; -} - -/** - This function resets the ACPI table warning counter to Zero. -**/ -VOID -ResetWarningCount ( - VOID - ) -{ - mTableWarningCount =3D 0; -} - -/** - This function returns the ACPI table warning count. - - @retval Returns the count of warning detected in the ACPI tables. -**/ -UINT32 -GetWarningCount ( - VOID - ) -{ - return mTableWarningCount; -} - /** This function increments the ACPI table error counter. **/ diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h b/Sh= ellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h index f81ccac7e118..84eae61c8889 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h @@ -16,6 +16,10 @@ /// that allows us to process the log options. #define RSDP_TABLE_INFO SIGNATURE_32('R', 'S', 'D', 'P') =20 +// Publicly accessible error and warning counters. +extern UINT32 mTableErrorCount; +extern UINT32 mTableWarningCount; + /** This function increments the ACPI table error counter. **/ diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c b/Shel= lPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c index d0a0edc45f3b..16f498b8c328 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c @@ -197,8 +197,8 @@ AcpiView ( mBinTableCount =3D 0; =20 // Reset The error/warning counters - ResetErrorCount (); - ResetWarningCount (); + mTableErrorCount =3D 0; + mTableWarningCount =3D 0; =20 // Search the table for an entry that matches the ACPI Table Guid FoundAcpiTable =3D FALSE; @@ -276,7 +276,7 @@ AcpiView ( Print (L"\nTable Statistics:\n"); =20 if (mConfig.ColourHighlighting) { - PrintAttribute =3D (GetErrorCount () > 0) ? + PrintAttribute =3D ((mTableErrorCount) > 0) ? EFI_TEXT_ATTR ( EFI_RED, ((OriginalAttribute&(BIT4|BIT5|BIT6))>>4) @@ -284,10 +284,10 @@ AcpiView ( OriginalAttribute; gST->ConOut->SetAttribute (gST->ConOut, PrintAttribute); } - Print (L"\t%d Error(s)\n", GetErrorCount ()); + Print (L"\t%d Error(s)\n", mTableErrorCount); =20 if (mConfig.ColourHighlighting) { - PrintAttribute =3D (GetWarningCount () > 0) ? + PrintAttribute =3D (mTableWarningCount > 0) ? EFI_TEXT_ATTR ( EFI_RED, ((OriginalAttribute&(BIT4|BIT5|BIT6))>>4) @@ -296,7 +296,7 @@ AcpiView ( =20 gST->ConOut->SetAttribute (gST->ConOut, PrintAttribute); } - Print (L"\t%d Warning(s)\n", GetWarningCount ()); + Print (L"\t%d Warning(s)\n", mTableWarningCount); =20 if (mConfig.ColourHighlighting) { gST->ConOut->SetAttribute (gST->ConOut, OriginalAttribute); diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h b/Shel= lPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h index d5b95f5ee707..6fefe98a4463 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h @@ -23,42 +23,6 @@ **/ #define RSDP_LENGTH_OFFSET 20 =20 -/** - This function resets the ACPI table error counter to Zero. -**/ -VOID -ResetErrorCount ( - VOID - ); - -/** - This function returns the ACPI table error count. - - @retval Returns the count of errors detected in the ACPI tables. -**/ -UINT32 -GetErrorCount ( - VOID - ); - -/** - This function resets the ACPI table warning counter to Zero. -**/ -VOID -ResetWarningCount ( - VOID - ); - -/** - This function returns the ACPI table warning count. - - @retval Returns the count of warning detected in the ACPI tables. -**/ -UINT32 -GetWarningCount ( - VOID - ); - /** This function processes the table reporting options for the ACPI table. =20 --=20 2.24.1.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#62375): https://edk2.groups.io/g/devel/message/62375 Mute This Topic: https://groups.io/mt/75454448/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri May 3 03:13:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62376+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1594549964919931.9861581614483; Sun, 12 Jul 2020 03:32:44 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id qVcGYY1788612x1OQvl1mvTw; Sun, 12 Jul 2020 03:32:44 -0700 X-Received: from EUR02-HE1-obe.outbound.protection.outlook.com (EUR02-HE1-obe.outbound.protection.outlook.com [40.107.1.58]) by mx.groups.io with SMTP id smtpd.web12.6629.1594549962161781531 for ; Sun, 12 Jul 2020 03:32:43 -0700 X-Received: from AM5PR1001CA0035.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:206:2::48) by AM6PR08MB3431.eurprd08.prod.outlook.com (2603:10a6:20b:44::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.22; Sun, 12 Jul 2020 10:32:38 +0000 X-Received: from VE1EUR03FT055.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:2:cafe::8) by AM5PR1001CA0035.outlook.office365.com (2603:10a6:206:2::48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Sun, 12 Jul 2020 10:32:38 +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 (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+62376+1787277+3901457@groups.io; helo=web01.groups.io; 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; X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT055.mail.protection.outlook.com (10.152.19.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Sun, 12 Jul 2020 10:32:38 +0000 X-Received: ("Tessian outbound c83312565ef4:v62"); Sun, 12 Jul 2020 10:32:38 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d063476b027dd864 X-CR-MTA-TID: 64aa7808 X-Received: from f8230f27f8be.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 53EFF420-441D-4EA8-BA75-9C7601405DC0.1; Sun, 12 Jul 2020 10:32:32 +0000 X-Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f8230f27f8be.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Sun, 12 Jul 2020 10:32:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OH8Zubf/RIJI3FPoe2M/Rf440Ncej4n8RTOiNM6OSDrD+dT8tQ3iVbt0XFnPJvv9Ce7iAk7OZk28uyS6ykPu4I3JDc2KSanTmWYUm720eLGCrRGnEHCwW19Mkwq1Btgxpu1mp5TAqRjGqiiyIsppXWaFOCOaG/Zs3IjIgsIG8dzI5KfWQ32HPi8AElQycw/NHript8YW/qWmeuJwMjHoEoBwc7PGFjDtrgkFJ0WmEGWhLgpk5U7ChEHPFvBgePZQzlLOqGpQvzTXExYQJE4C2rvBa0xfCc3Snmx5L/1Ea8dN31QJcoBQSZX7FU50gGQs2xFDdNWcp4xWVvFY7m8xig== 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=CVZaJZyDb6rXNt8V26wT6Jrf/x1e1l2RtrYW7A6f1fQ=; b=oWv1cYyYbpSAV/RfKvP4moQ7bQl0et3sfL0xULAgXbLOT+waV9Dx3RO7ol4wjnGl+nNTDPaaiSvnxA/lgKHGasAd7zwZIk59RTgDawZj1XeuVH5QNFwJdf+HMZfsznbL35CvvSuVGRY2bOZZDEctqb6PnWmZzxUVKN7xJAxWZNH01gMgxGzRN4HVlsPafpxAJ5W+DADzGXHMmK+PI+SJX8aJPLcwbhJVgm59puacmLJZv5d1TzY0RItiAOE5r0eg+62tuDOUjpaGtf8vsNCZtY0njPCncrLZqCtrH/pTvqJqz3tu0Ku45spRkmxskDOBB7lQSH5cEnAQk2cxa9Oy2g== 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 X-Received: from DBBPR09CA0015.eurprd09.prod.outlook.com (2603:10a6:10:c0::27) by DB8PR08MB5340.eurprd08.prod.outlook.com (2603:10a6:10:11c::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.22; Sun, 12 Jul 2020 10:32:30 +0000 X-Received: from DB5EUR03FT008.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:c0:cafe::ee) by DBBPR09CA0015.outlook.office365.com (2603:10a6:10:c0::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Sun, 12 Jul 2020 10:32:30 +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; X-Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT008.mail.protection.outlook.com (10.152.20.98) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3174.21 via Frontend Transport; Sun, 12 Jul 2020 10:32:30 +0000 X-Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1415.2; Sun, 12 Jul 2020 10:32:30 +0000 X-Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1779.2; Sun, 12 Jul 2020 10:32:29 +0000 X-Received: from localhost.localdomain (10.57.55.192) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Sun, 12 Jul 2020 10:32:29 +0000 From: "Tomas Pilar (tpilar)" To: CC: , , Ray Ni , "Zhichao Gao" Subject: [edk2-devel] [PATCH v2 3/8] ShellPkg/AcpiView: Modify error message Date: Sun, 12 Jul 2020 11:32:10 +0100 Message-ID: <20200712103215.855-4-Tomas.Pilar@arm.com> In-Reply-To: <20200712103215.855-1-Tomas.Pilar@arm.com> References: <20200712103215.855-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)(396003)(346002)(136003)(39850400004)(376002)(46966005)(4326008)(426003)(2906002)(81166007)(70206006)(356005)(186003)(70586007)(82310400002)(82740400003)(54906003)(26005)(47076004)(1076003)(36756003)(336012)(15650500001)(478600001)(86362001)(8936002)(83380400001)(5660300002)(6666004)(6916009)(8676002)(316002)(2616005);DIR:OUT;SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f5fd59de-2a26-4f05-f4aa-08d8264ee63f X-MS-TrafficTypeDiagnostic: DB8PR08MB5340:|AM6PR08MB3431: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:6430;OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: zpe1KnuPBAfPqQNL81Anx6hhnpUigucvP91lrL7BajdiRSVxVBvMv4tjqr/VDBp83GGa6W9PhD0UXWGrm3DNY0VrFkoXaPFXIeCY85XD0cHSbYw2Y2XKXDoJ6ah7U0aL1M0m7CPf/LdHy4xlmnxombkB9ZTxULCb8pc5iG742wnQhEflC6+FF3LxIz5inCK0ytAZH22o6R8mR7OoK5E1ofcdwDJLZvD08M9CY/jUsc4MpTZcRwoLbnGaGeOPR8SL3+tuB62BXUbXYpfs9nj3XaoT1DAVxPwBepzD1bXSkvklVzgQNhkoV43Sun86SqNsWHSR+3MVCk/JxUDW0994bwpj/fH1FcWcZpngqP1ffHjDATbI1NkVzfjXNKRnLjuSfNeMoahZKJ41RHRX70HvaA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5340 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT055.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: b1f7de2c-8f3e-4165-a518-08d8264ee179 X-Microsoft-Antispam-Message-Info: YnY/tg3slRJLpnItpQv/j/Yri9ODQxU39CJzhjHfy1ZYxcNrKcBMbTzZPcyrCWIhD9PuatsNw+PPdM96WfBWB2+Jy2aLseirmChVVAFdnGPParxoWNLbPLQQypSRafxyWfjEGPnQdzQ6VxQhDB2uSEE6jPauva8hrbDo0XfYkzmX9rSPqmvPha/n9wF6gZV9W/dRVtVVm1SBYpdoaxKakBFCpzatDK7HBaUmJZywSfmtJuwuMS0WHeMjYcS6M5Y/e5FmXtB13yzjLPgJmSKI+lqZ/zVAtpMmN3rbJF2hclrwiw9aJOnhZ815qUJM6OzZfZ863n+edqCQyKwoStO8CGMHpGAYl+guEcBGoGWRN7JHU7Affv1YHRDB/qf/cccgpP74u/OBNFk23t1kQo2A9g== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2020 10:32:38.3703 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f5fd59de-2a26-4f05-f4aa-08d8264ee63f 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: VE1EUR03FT055.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3431 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,Tomas.Pilar@arm.com X-Gm-Message-State: pfuIRijaBw3nkqiBbIhiz55Lx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1594549964; bh=n6GhFRWwMtcZ5yZXRz2xdml2GmqPxDMeZHhzYqGK25Q=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=ArfCz7ugqiqZSJjM2L9d35/6EOR67MguhMG80VzNCeCWPK9jg9EAWi608/9KFOqGpfg 7Gpx+/Lf7HcOC41g0rjG+J7aDORwLGZm2HWPoWADQO+a2UaXwrz4GBTacoJAtNyULD+Xk DPo5dyJuiKZdh57v7T2C9XekAzu8oVvgGYM= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Modify the DumpFile error message to be more in line with the rest of the error messages in the same file. Change-Id: I8f074178154e13db06a67f2158448fc625ee4216 Cc: Ray Ni Cc: Zhichao Gao Signed-off-by: Tomas Pilar --- .../UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiView= CommandLib.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiVi= ewCommandLib.c index 9613c16f5703..11e97afabc52 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand= Lib.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand= Lib.c @@ -147,10 +147,8 @@ ShellDumpBufferToFile ( ); =20 if (EFI_ERROR (Status)) { - Print (L"ERROR: Failed to write binary file.\n"); + Print (L"acpiview: Failed to write binary file.\n"); TransferBytes =3D 0; - } else { - Print (L"DONE.\n"); } =20 ShellCloseFile (&DumpFileHandle); --=20 2.24.1.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#62376): https://edk2.groups.io/g/devel/message/62376 Mute This Topic: https://groups.io/mt/75454449/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri May 3 03:13:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62377+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 15945499673431011.4447206271519; Sun, 12 Jul 2020 03:32:47 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id uhV5YY1788612xWQxGE2u0j9; Sun, 12 Jul 2020 03:32:47 -0700 X-Received: from EUR04-VI1-obe.outbound.protection.outlook.com (EUR04-VI1-obe.outbound.protection.outlook.com [40.107.8.74]) by mx.groups.io with SMTP id smtpd.web10.6637.1594549962714862758 for ; Sun, 12 Jul 2020 03:32:43 -0700 X-Received: from DB6PR0802CA0026.eurprd08.prod.outlook.com (2603:10a6:4:a3::12) by DBBPR08MB4917.eurprd08.prod.outlook.com (2603:10a6:10:f1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.22; Sun, 12 Jul 2020 10:32:39 +0000 X-Received: from DB5EUR03FT015.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:a3:cafe::17) by DB6PR0802CA0026.outlook.office365.com (2603:10a6:4:a3::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Sun, 12 Jul 2020 10:32:39 +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 (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+62377+1787277+3901457@groups.io; helo=web01.groups.io; 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; X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT015.mail.protection.outlook.com (10.152.20.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Sun, 12 Jul 2020 10:32:39 +0000 X-Received: ("Tessian outbound 1dc58800d5dd:v62"); Sun, 12 Jul 2020 10:32:39 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: da62a33b9ec669c4 X-CR-MTA-TID: 64aa7808 X-Received: from e4fecd5eed28.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 6632697E-52C2-4ACE-B2A9-4DD8A830E9EB.1; Sun, 12 Jul 2020 10:32:34 +0000 X-Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e4fecd5eed28.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Sun, 12 Jul 2020 10:32:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dPZhgfkjawsCzOCk+q+Z5zOdaaTHhwcaymoinbog9KkZ/lg5jRq2iWTGfBRdZrXHOSlmRw+hQaq4jIvp3/D5MF2t9zvKu8QAcd3jS6UAmnf6z/9elzFPrfTBjUDoJVz9H52mojZVAF5vZbKQ4b6kDP5uph1lTXTFqm+Rotc9GGFxz/ReRSm7HZHd2BfMJZ76hzbcKJ0f8E+PzoQ45PmTNvvtewWXD33jkX9vzBYcBpNp4QO7krVg6t71x9ybpFSEIfpfUojebV2KFnGCDfUEaws8F0L3H88ljCHFuWWQMmj5mrpJjKgdQ4zdKUAkoYHz4ISUbfAeQX+Ssm4m4MUSBA== 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=xNYP0HilM/I4bv+QK5HOX2eVGAGv7Z6pE+kfBHMAfLU=; b=G/QkHRZkL5/qVgGPB1x+sBsUk6e02Q/jCV9nJMsLOS1OBmE8NRq+tbu9or1IMXwEtaxbNZ2J4X2CJjcSusaKErykBzxB0LypjU+TtXlydftOLAA0+GERrdRSkDTgzr5/O6aPNvF0D1vLvJw70agZ34NH80veSOGiBQZ+/25TsZTVzG5xSYBfqjajlovhqc723auxG0PfeubB5Kjl8GECP4o5aYgVeLtoYm0q35AvnqFwHQY5Xjrk7EV7z+Tq/omIRe0jbO82PiN6CbDEzFkOuhjU/6k5ogbR0S4yXTXdZlMcW6Uas0pBY//o0sO0/7nmJj0QSaY9ZnLbas7uaGgdIw== 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 X-Received: from DBBPR09CA0018.eurprd09.prod.outlook.com (2603:10a6:10:c0::30) by AM6PR08MB4214.eurprd08.prod.outlook.com (2603:10a6:20b:8d::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20; Sun, 12 Jul 2020 10:32:31 +0000 X-Received: from DB5EUR03FT008.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:c0:cafe::25) by DBBPR09CA0018.outlook.office365.com (2603:10a6:10:c0::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Sun, 12 Jul 2020 10:32:30 +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; X-Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT008.mail.protection.outlook.com (10.152.20.98) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3174.21 via Frontend Transport; Sun, 12 Jul 2020 10:32:30 +0000 X-Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1415.2; Sun, 12 Jul 2020 10:32:30 +0000 X-Received: from localhost.localdomain (10.57.55.192) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Sun, 12 Jul 2020 10:32:29 +0000 From: "Tomas Pilar (tpilar)" To: CC: , , Ray Ni , "Zhichao Gao" Subject: [edk2-devel] [PATCH v2 4/8] ShellPkg/AcpiView: Create a logging facility Date: Sun, 12 Jul 2020 11:32:11 +0100 Message-ID: <20200712103215.855-5-Tomas.Pilar@arm.com> In-Reply-To: <20200712103215.855-1-Tomas.Pilar@arm.com> References: <20200712103215.855-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)(136003)(346002)(376002)(396003)(39850400004)(46966005)(356005)(5660300002)(36756003)(82310400002)(6666004)(83380400001)(54906003)(6916009)(86362001)(81166007)(316002)(478600001)(30864003)(186003)(4326008)(1076003)(2906002)(26005)(82740400003)(8676002)(2616005)(70586007)(70206006)(47076004)(19627235002)(426003)(336012)(8936002)(403724002);DIR:OUT;SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6ea61644-ad44-49da-704c-08d8264ee6ce X-MS-TrafficTypeDiagnostic: AM6PR08MB4214:|DBBPR08MB4917: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:10000;OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: LA/7rSkYZrHJJYca9Cp+F4uJN795ZIy1jAdOivxJkwZ0AFX6XNb92ci0/r/vLKKfMwChfLr28ZlfEM1j0Gms99ue2TuLhGSmxdxJwcDhz7ftfLIT/aYLmpwo7dWox487kT3z3X1+Fz5YHYtUoroyfT+DN5WvXPeqvLKMIHrNLKbZ/g4E8eItr0jK5DwIErWfUJCZii3GK/NG9Wu/j8hi+FCya7eZhPL7dZMsvdophyTKyrZDhh7ChGWHlH+QDzdSQG2a2e1yZii97lT5DzSui17Jy+bhDuoHhmH7hZGDR14eGPnq3E09Mk37QjEowJoTYeJRohpmrb5MtfZ6NffoYuW7rdaJOohXtwGJM9YH9+E2nR8qt8qrAm9AqxdohScJbftPw6Ftp4ONj6LoCvyD0x56WmibYSqXQFqrm83l72A= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4214 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT015.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: bad553c2-66fc-4bab-d1b1-08d8264ee1bd X-Microsoft-Antispam-Message-Info: LSuqbnUwF+WGbzex6LGkZhmiUN07XZGdjznPuhL/GMSrIzIRSjH8IuAjETued7RVF5sfbAegS1UtzBD1PsS5CVScTnp9S7QM7upbzG7R0P/Zw8noihdq6HsTi/1dfI6IeFpkknAwZ4AS9qq8iwJLXB//3MVtlFg5PqqK5Yk3CvUKHwE9uH61/gsOSyp8+ca7tVqlvXrXSSO3WRL4aTDHoOf9Cpj6pygrBp0OTC2mkSy4tVejJxcFHrI9D9fyU1S08f7x1xq4Hs/++vV7PsrRra42a6J/vdqfntQm4RKYRzOYSmvwNcFpflCbk/hy9X1e3Nb6f58A/1YbMmb271mvWRtz7J+b3jxpZmAYODMgOIe6vrXNQjgetXTEueTZYUxzGOy/us96g264bW+zAKxcmiA4JiY+0M4whzmGvv9XACc= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2020 10:32:39.4438 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6ea61644-ad44-49da-704c-08d8264ee6ce 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: DB5EUR03FT015.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4917 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,Tomas.Pilar@arm.com X-Gm-Message-State: hLsRjS3N6dzYPIbrdpWfYA5rx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1594549967; bh=6Pj/nsuTaOWaLr1hUqVZNAeWHdjyDd0EwTWxdBME/kQ=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=Vfmf/z2gGQ+ecl7PFOXQdrHgo4uBKoaGOAOLcdE8X/x3ibVDAFWMzaStIXJp6tcbvsH jBdh7f05HugDEQiVPfvZjNH6YZ8w2E0Vbsgu3V2XH7Ad1F/sjNPbet4mbCsea2vO6iCbj 9epeCSBeZoSagxv55nAaitfqYMW9aFIdV6Q= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Extract error and warning logging into separate methods. Fold highlighting and other output properties into the logging methods. Change-Id: I46bba2afc6fe8d7bc0c92ec7054f2af2d2254441 Cc: Ray Ni Cc: Zhichao Gao Signed-off-by: Tomas Pilar --- .../UefiShellAcpiViewCommandLib/AcpiParser.c | 5 +- .../UefiShellAcpiViewCommandLib/AcpiViewLog.c | 338 ++++++++++++++++++ .../UefiShellAcpiViewCommandLib/AcpiViewLog.h | 192 ++++++++++ .../UefiShellAcpiViewCommandLib.inf | 2 + 4 files changed, 533 insertions(+), 4 deletions(-) create mode 100644 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewLo= g.c create mode 100644 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewLo= g.h diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c b/Sh= ellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c index 7017fa93efae..b88594cf3865 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c @@ -11,13 +11,10 @@ #include "AcpiParser.h" #include "AcpiView.h" #include "AcpiViewConfig.h" +#include "AcpiViewLog.h" =20 STATIC UINT32 gIndent; =20 -// Publicly accessible error and warning counters. -UINT32 mTableErrorCount; -UINT32 mTableWarningCount; - STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; =20 /** diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewLog.c b/S= hellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewLog.c new file mode 100644 index 000000000000..7ec276ac7528 --- /dev/null +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewLog.c @@ -0,0 +1,338 @@ +/** @file + 'acpiview' logging and output facility + + Copyright (c) 2020, ARM Limited. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include "AcpiViewLog.h" +#include "AcpiViewConfig.h" +#include "AcpiParser.h" +#include +#include + +static CHAR16 mOutputBuffer [MAX_OUTPUT_SIZE] =3D { 0 }; + +// String descriptions of error types +static const CHAR16* mErrorTypeDesc [ACPI_ERROR_MAX] =3D { + L"Not an error", ///< ACPI_ERROR_NONE + L"Generic", ///< ACPI_ERROR_GENERIC + L"Checksum", ///< ACPI_ERROR_CSUM + L"Parsing", ///< ACPI_ERROR_PARSE + L"Length", ///< ACPI_ERROR_LENGTH + L"Value", ///< ACPI_ERROR_VALUE + L"Cross-check", ///< ACPI_ERROR_CROSS +}; + +// Publicly accessible error and warning counters. +UINT32 mTableErrorCount; +UINT32 mTableWarningCount; + +/** + Change the attributes of the standard output console + to change the colour of the text according to the given + severity of a log message. + + @param[in] Severity The severity of the log message that is bei= ng + annotated with changed colour text. + @param[in] OriginalAttribute The current attributes of ConOut that will + be modified. +**/ +static +VOID +EFIAPI +ApplyColor ( + IN ACPI_LOG_SEVERITY Severity, + IN UINTN OriginalAttribute + ) +{ + if (!mConfig.ColourHighlighting) { + return; + } + + // Strip the foreground colour + UINTN NewAttribute =3D OriginalAttribute & 0xF0; + + // Add specific foreground colour based on severity + switch (Severity) { + case ACPI_DEBUG: + NewAttribute |=3D EFI_DARKGRAY; + break; + case ACPI_HIGHLIGHT: + NewAttribute |=3D EFI_LIGHTBLUE; + break; + case ACPI_GOOD: + NewAttribute |=3D EFI_GREEN; + break; + case ACPI_ITEM: + case ACPI_WARN: + NewAttribute |=3D EFI_YELLOW; + break; + case ACPI_BAD: + case ACPI_ERROR: + case ACPI_FATAL: + NewAttribute |=3D EFI_RED; + break; + case ACPI_INFO: + default: + NewAttribute |=3D OriginalAttribute; + break; + } + + gST->ConOut->SetAttribute (gST->ConOut, NewAttribute); +} + +/** + Restore ConOut text attributes. + + @param[in] OriginalAttribute The attribute set that will be restored. +**/ +static +VOID +EFIAPI +RestoreColor( + IN UINTN OriginalAttribute + ) +{ + gST->ConOut->SetAttribute (gST->ConOut, OriginalAttribute); +} + +/** + Formats and prints an ascii string to screen. + + @param[in] Format String that will be formatted and printed. + @param[in] Marker The marker for variable parameters to be formatted. +**/ +static +VOID +EFIAPI +AcpiViewVSOutput ( + IN const CHAR16 *Format, + IN VA_LIST Marker + ) +{ + UnicodeVSPrint (mOutputBuffer, sizeof(mOutputBuffer), Format, Marker); + gST->ConOut->OutputString (gST->ConOut, mOutputBuffer); +} + +/** + Formats and prints and ascii string to screen. + + @param[in] Format String that will be formatted and printed. + @param[in] ... A variable number of parameters that will be formatted. +**/ +VOID +EFIAPI +AcpiViewOutput ( + IN const CHAR16 *Format, + IN ... + ) +{ + VA_LIST Marker; + VA_START (Marker, Format); + + AcpiViewVSOutput (Format, Marker); + + VA_END (Marker); +} + + +/** + Prints the base file name given a full file path. + + @param[in] FullName Fully qualified file path +**/ +VOID +EFIAPI +PrintFileName ( + IN const CHAR8* FullName + ) +{ + const CHAR8* Cursor; + UINTN Size; + + Cursor =3D FullName; + Size =3D 0; + + // Find the end point of the string. + while (*Cursor && Cursor < FullName + MAX_OUTPUT_SIZE) + Cursor++; + + // Find the rightmost path separator. + while (*Cursor !=3D '\\' && *Cursor !=3D '/' && Cursor > FullName) { + Cursor--; + Size++; + } + + // Print base file name. + AcpiViewOutput (L"%.*a", Size - 1, Cursor + 1); +} + +/** + AcpiView output and logging function. Will log the event to + configured output (currently screen) and annotate with colour + and extra metadata. + + @param[in] FileName The full filename of the source file where this + event occured. + @param[in] FunctionName The name of the function where this event occur= ed. + @param[in] LineNumber The line number in the source code where this e= vent + occured. + @param[in] Severity The severity of the event that occured. + @param[in] Format The format of the string describing the event. + @param[in] ... The variable number of parameters that will for= mat the + string supplied in Format. +**/ +VOID +EFIAPI +AcpiViewLog ( + IN const CHAR8 *FileName, + IN const CHAR8 *FunctionName, + IN UINTN LineNumber, + IN ACPI_ERROR_TYPE Error, + IN ACPI_LOG_SEVERITY Severity, + IN const CHAR16 *Format, + ... + ) +{ + VA_LIST Marker; + UINTN OriginalAttribute; + + OriginalAttribute =3D gST->ConOut->Mode->Attribute; + ApplyColor (Severity, OriginalAttribute); + VA_START (Marker, Format); + + switch (Severity) { + case ACPI_FATAL: + AcpiViewOutput (L"FATAL "); + break; + case ACPI_ERROR: + AcpiViewOutput (L"ERROR[%s] ", mErrorTypeDesc[Error]); + mTableErrorCount++; + break; + case ACPI_WARN: + AcpiViewOutput (L"WARN "); + mTableWarningCount++; + break; + default: + break; + } + + if (Severity >=3D ACPI_WARN) { + AcpiViewOutput (L"("); + PrintFileName (FileName); + AcpiViewOutput (L":%d) ", LineNumber); + } + + AcpiViewVSOutput (Format, Marker); + AcpiViewOutput (L"\n"); + + VA_END (Marker); + RestoreColor (OriginalAttribute); +} + +/** + Check that a buffer has not been overrun by a member. Can be invoked + using the BufferOverrun macro that fills in local source metadata + (first three parameters) for logging purposes. + + @param[in] FileName Source file where this invocation is made + @param[in] FunctionName Name of the local symbol + @param[in] LineNumber Source line number of the local call + @param[in] ItemDescription User friendly name for the member being check= ed + @param[in] Position Memory address of the member + @param[in] Length Length of the member + @param[in] Buffer Memory address of the buffer where member res= ides + @param[in] BufferSize Size of the buffer where member resides + + @retval TRUE Buffer was overrun + @retval FALSE Buffer is safe +**/ +BOOLEAN +EFIAPI +MemberIntegrityInternal ( + IN const CHAR8 *FileName, + IN const CHAR8 *FunctionName, + IN UINTN LineNumber, + IN const CHAR8 *ItemDescription, + IN UINTN Offset, + IN UINTN Length, + IN VOID *Buffer, + IN UINTN BufferSize + ) +{ + if (Length =3D=3D 0) { + AcpiViewLog ( + FileName, + FunctionName, + LineNumber, + ACPI_ERROR_LENGTH, + ACPI_ERROR, + L"%a at %p in buffer %p+%x has zero size!", + ItemDescription, + (UINT8 *)Buffer + Offset, + Buffer, + BufferSize); + return TRUE; + } + + if (Offset + Length > BufferSize) { + AcpiViewLog ( + FileName, + FunctionName, + LineNumber, + ACPI_ERROR_LENGTH, + ACPI_ERROR, + L"%a %p+%x overruns buffer %p+%x", + ItemDescription, + (UINT8 *) Buffer + Offset, + Length, + Buffer, + BufferSize); + } + + return (Offset + Length > BufferSize); +} + +/** + Checks that a boolean constraint evaluates correctly. Can be invoked + using the CheckConstraint macro that fills in the source code metadata. + + @param[in] FileName Source file where this invocation is made + @param[in] FunctionName Name of the local symbol + @param[in] LineNumber Source line number of the local call + @param[in] ConstraintText The Source code of the constraint + @param[in] Specification The specification that imposes the constraint + @param[in] Constraint The actual constraint + @ + + @retval TRUE Constraint is violated + @retval FALSE Constraint is not violated +**/ +BOOLEAN +EFIAPI +CheckConstraintInternal ( + IN const CHAR8 *FileName, + IN const CHAR8 *FunctionName, + IN UINTN LineNumber, + IN const CHAR8 *ConstraintText, + IN const CHAR16 *Specification, + IN BOOLEAN Constraint, + IN ACPI_LOG_SEVERITY Severity +) +{ + if (!Constraint) { + AcpiViewLog ( + FileName, + FunctionName, + LineNumber, + Severity =3D=3D ACPI_ERROR ? ACPI_ERROR_VALUE : ACPI_ERROR_NONE, + Severity, + L"(%a) Constraint was violated: %a", + Specification, + ConstraintText); + } + + // Return TRUE if constraint was violated + return !Constraint; +} diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewLog.h b/S= hellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewLog.h new file mode 100644 index 000000000000..ce276ef7add2 --- /dev/null +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewLog.h @@ -0,0 +1,192 @@ +/** @file + Header file for 'acpiview' logging and output facility + + Copyright (c) 2020, ARM Limited. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef ACPI_VIEW_LOG_H_ +#define ACPI_VIEW_LOG_H_ + +/** + Categories of errors that can be logged by AcpiView. +*/ +typedef enum { + ACPI_ERROR_NONE, ///< Not an error + ACPI_ERROR_GENERIC, ///< An unspecified error + ACPI_ERROR_CSUM, ///< A checksum was invalid + ACPI_ERROR_PARSE, ///< Failed to parse item + ACPI_ERROR_LENGTH, ///< Size of a thing is incorrect + ACPI_ERROR_VALUE, ///< The value of a field was incorrect + ACPI_ERROR_CROSS, ///< A constraint on multiple items was violated + ACPI_ERROR_MAX +} ACPI_ERROR_TYPE; + +/** + Different severities of events that can be logged. +*/ +typedef enum { + ACPI_DEBUG, ///< Will not be shown unless specified on command line + ACPI_INFO, ///< Standard output + ACPI_GOOD, ///< Unspecified good outcome, green colour + ACPI_BAD, ///< Unspecified bad outcome, red colour + ACPI_ITEM, ///< Used when describing multiple items + ACPI_HIGHLIGHT, ///< A new context or section has been entered + ACPI_WARN, ///< An unusual event happened + ACPI_ERROR, ///< Acpi table is not conformant + ACPI_FATAL ///< This will abort program execution. +} ACPI_LOG_SEVERITY; + +// Publicly accessible error and warning counters. +extern UINT32 mTableErrorCount; +extern UINT32 mTableWarningCount; + +/** + AcpiView output and logging function. Will log the event to + configured output (currently screen) and annotate with colour + and extra metadata. + + @param[in] FileName The full filename of the source file where this + event occured. + @param[in] FunctionName The name of the function where this event occur= ed. + @param[in] LineNumber The line number in the source code where this e= vent + occured. + @param[in] Severity The severity of the event that occured. + @param[in] Error The type of the erorr reported. May be ACPI_ERR= OR_NONE if the event + is not an error. + @param[in] Format The format of the string describing the event. + @param[in] ... The variable number of parameters that will for= mat the + string supplied in Format. +**/ +VOID +EFIAPI +AcpiViewLog ( + IN const CHAR8 *FileName, + IN const CHAR8 *FunctionName, + IN UINTN LineNumber, + IN ACPI_ERROR_TYPE Error, + IN ACPI_LOG_SEVERITY Severity, + IN const CHAR16 *Format, + ... + ); + +/** + Formats and prints and ascii string to screen. + + @param[in] Format String that will be formatted and printed. + @param[in] ... A variable number of parameters that will be formatted. +**/ +VOID +EFIAPI +AcpiViewOutput ( + IN const CHAR16 *Format, + IN ... + ); + +/** + Check that a buffer has not been overrun by a member. Can be invoked + using the BufferOverrun macro that fills in local source metadata + (first three parameters) for logging purposes. + + @param[in] FileName Source file where this invocation is made + @param[in] FunctionName Name of the local symbol + @param[in] LineNumber Source line number of the local call + @param[in] ItemDescription User friendly name for the member being check= ed + @param[in] Position Memory address of the member + @param[in] Length Length of the member + @param[in] Buffer Memory address of the buffer where member res= ides + @param[in] BufferSize Size of the buffer where member resides + + @retval TRUE Buffer was overrun + @retval FALSE Buffer is safe +**/ +BOOLEAN +EFIAPI +MemberIntegrityInternal ( + IN const CHAR8 *FileName, + IN const CHAR8 *FunctionName, + IN UINTN LineNumber, + IN const CHAR8 *ItemDescription, + IN UINTN Offset, + IN UINTN Length, + IN VOID *Buffer, + IN UINTN BufferSize + ); + +// Determine if a member located at Offset into a Buffer lies entirely +// within the BufferSize given the member size is Length +// Evaluates to TRUE and logs error if buffer is overrun or if Length is z= ero +#define AssertMemberIntegrity(Offset, Length, Buffer, BufferSize) \ + MemberIntegrityInternal (__FILE__, __func__, __LINE__, #Length, Offset, = Length, Buffer, BufferSize) + + +/** + Checks that a boolean constraint evaluates correctly. Can be invoked + using the CheckConstraint macro that fills in the source code metadata. + + @param[in] FileName Source file where this invocation is made + @param[in] FunctionName Name of the local symbol + @param[in] LineNumber Source line number of the local call + @param[in] ConstraintText The Source code of the constraint + @param[in] Specification The specification that imposes the constraint + @param[in] Constraint The actual constraint + @ + + @retval TRUE Constraint is violated + @retval FALSE Constraint is not violated +**/ +BOOLEAN +EFIAPI +CheckConstraintInternal ( + IN const CHAR8 *FileName, + IN const CHAR8 *FunctionName, + IN UINTN LineNumber, + IN const CHAR8 *ConstraintText, + IN const CHAR16 *Specification, + IN BOOLEAN Constraint, + IN ACPI_LOG_SEVERITY Severity + ); + +// Evaluates to TRUE and logs error if a constraint is violated +// Constraint internally cast to BOOLEAN using !!(Constraint) +#define AssertConstraint(Specification, Constraint) \ + CheckConstraintInternal ( \ + __FILE__, \ + __func__, \ + __LINE__, \ + #Constraint, \ + Specification, \ + !!(Constraint), \ + ACPI_ERROR) + +// Evaluates to TRUE and logs error if a constraint is violated +// Constraint internally cast to BOOLEAN using !!(Constraint) +#define WarnConstraint(Specification, Constraint) \ + CheckConstraintInternal ( \ + __FILE__, \ + __func__, \ + __LINE__, \ + #Constraint, \ + Specification, \ + !!(Constraint), \ + ACPI_WARN) + + +// Maximum string size that can be printed +#define MAX_OUTPUT_SIZE 256 + +#define _AcpiLog(...) AcpiViewLog(__FILE__, __func__, __LINE__, __VA_ARGS_= _) + +// Generic Loging macro, needs severity and formatted string +#define AcpiLog(Severity, ...) _AcpiLog(ACPI_ERROR_NONE, Severity, __VA_AR= GS__) + +// Log undecorated text, needs formatted string +#define AcpiInfo(...) _AcpiLog(ACPI_ERROR_NONE, ACPI_INFO, __VA_ARGS__) + +// Log error and increment counter, needs error type and formatted string +#define AcpiError(Error, ...) _AcpiLog(Error, ACPI_ERROR, __VA_ARGS__) + +// Log a FATAL error, needs formatted string +#define AcpiFatal(...) _AcpiLog(ACPI_ERROR_GENERIC, ACPI_FATAL, __VA_ARGS_= _) + +#endif // ACPI_VIEW_LOG_H_ diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiView= CommandLib.inf b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpi= ViewCommandLib.inf index 91459f9ec632..e0586cbccec2 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand= Lib.inf +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand= Lib.inf @@ -27,6 +27,8 @@ [Sources.common] AcpiView.h AcpiViewConfig.c AcpiViewConfig.h + AcpiViewLog.h + AcpiViewLog.c Parsers/Bgrt/BgrtParser.c Parsers/Dbg2/Dbg2Parser.c Parsers/Dsdt/DsdtParser.c --=20 2.24.1.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#62377): https://edk2.groups.io/g/devel/message/62377 Mute This Topic: https://groups.io/mt/75454450/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri May 3 03:13:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62378+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1594549965508326.6984300800078; Sun, 12 Jul 2020 03:32:45 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id mcnHYY1788612xZBTd6PJZg6; Sun, 12 Jul 2020 03:32:45 -0700 X-Received: from EUR04-HE1-obe.outbound.protection.outlook.com (EUR04-HE1-obe.outbound.protection.outlook.com [40.107.7.43]) by mx.groups.io with SMTP id smtpd.web11.6719.1594549962701135095 for ; Sun, 12 Jul 2020 03:32:43 -0700 X-Received: from AM5PR0301CA0018.eurprd03.prod.outlook.com (2603:10a6:206:14::31) by VI1PR08MB3997.eurprd08.prod.outlook.com (2603:10a6:803:e0::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.23; Sun, 12 Jul 2020 10:32:40 +0000 X-Received: from VE1EUR03FT029.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:14:cafe::76) by AM5PR0301CA0018.outlook.office365.com (2603:10a6:206:14::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; Sun, 12 Jul 2020 10:32:39 +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 (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+62378+1787277+3901457@groups.io; helo=web01.groups.io; 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; X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT029.mail.protection.outlook.com (10.152.18.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Sun, 12 Jul 2020 10:32:39 +0000 X-Received: ("Tessian outbound 1c27ecaec3d6:v62"); Sun, 12 Jul 2020 10:32:39 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: a1c66840ed2abc08 X-CR-MTA-TID: 64aa7808 X-Received: from 6c53b941d868.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D77674A7-43F3-4A0C-95F3-3E41EA5F7BB7.1; Sun, 12 Jul 2020 10:32:33 +0000 X-Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 6c53b941d868.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Sun, 12 Jul 2020 10:32:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nR+Zr+gsMXlVA4uPFzn0vxJDYhVBquboxS9hyJ+roZAJZQ1S/sRb1uIfiJdI9y3yHb2mN9ZC6rSDchrfwP/BHxYFi9xUHkiuWuve8e1bHe2ZCUtziEmj3d4y0N7KepsPgyi/GnK1K2pSpLPXhcUHoptf0VRBcoEqKVArtRkNU5ImAG1CTISdOHH/LssRZc/ltjN1E7h2q3stGpWrN4bmU6e4wkIXgspfcLEfa6V4ayUzGxtmaweCcZjH7/lXuG+3lKfiS+oeybnaOCEtQzGxzALG2uRlifCmShc/I7BH3+x2e54AlDSYyqo+Op6OQtS26YqBv7W8UmRxctlJqzvFrA== 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=rV828EaDUM5a6gz3XppPz1jX36YJXWSjhL+7i+wZ+pg=; b=Vro+Baso1/2h6QWmqM010tDu9mQvTXu2o8FGj4kMASN9xvwi2S2jtlhAsDZYIypVjV5B/PsDVb2bKEKtqsG5YjxQjTWWpwaKJiGlrQ7FgaggPhhaR6tgshAeXJd43oKlwit8rcqHiq3/tCLz/BFZCMfedXvVTxioAf5D6yHn5qSX3IvtjCtyDczumsYDgrMPRas0S4ryHTqRoqRSmCs2mfCW9kdjP9+vPOjXGIsnl4dBBukFTTW9BcUmpykDZYoUTAOu0I1RMG6xyzurm1/hndMjkO0Dej7i5dMbm1a8VRU8ltMp0BOp7kVUwjkM/Uf3vt3B1cMtU6pPeoZ+VpiEYg== 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 X-Received: from AM6P192CA0052.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:82::29) by VI1PR08MB3200.eurprd08.prod.outlook.com (2603:10a6:803:47::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.22; Sun, 12 Jul 2020 10:32:32 +0000 X-Received: from VE1EUR03FT049.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:82:cafe::80) by AM6P192CA0052.outlook.office365.com (2603:10a6:209:82::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Sun, 12 Jul 2020 10:32:32 +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; X-Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT049.mail.protection.outlook.com (10.152.19.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3174.21 via Frontend Transport; Sun, 12 Jul 2020 10:32:31 +0000 X-Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1415.2; Sun, 12 Jul 2020 10:32:31 +0000 X-Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1779.2; Sun, 12 Jul 2020 10:32:30 +0000 X-Received: from localhost.localdomain (10.57.55.192) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Sun, 12 Jul 2020 10:32:30 +0000 From: "Tomas Pilar (tpilar)" To: CC: , , Ray Ni , "Zhichao Gao" Subject: [edk2-devel] [PATCH v2 5/8] ShellPkg/AcpiView: Refactor PrintFieldName Date: Sun, 12 Jul 2020 11:32:12 +0100 Message-ID: <20200712103215.855-6-Tomas.Pilar@arm.com> In-Reply-To: <20200712103215.855-1-Tomas.Pilar@arm.com> References: <20200712103215.855-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)(396003)(39850400004)(376002)(346002)(136003)(46966005)(6916009)(1076003)(2616005)(81166007)(70206006)(83380400001)(54906003)(26005)(36756003)(426003)(47076004)(70586007)(336012)(4326008)(478600001)(316002)(8676002)(82310400002)(8936002)(356005)(6666004)(86362001)(186003)(2906002)(19627235002)(82740400003)(5660300002);DIR:OUT;SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4199c0d4-56e1-47b2-5ecc-08d8264ee6f5 X-MS-TrafficTypeDiagnostic: VI1PR08MB3200:|VI1PR08MB3997: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:6108;OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: hu7dZE1HhXn7zJ6uI+j6+fvrRyldNM68tdeBlr4V7QOyEiSiAvykwcKitULtmkZWsgWLgloc5tSGSZ4FQ1O4MUciG4obbKIvzpWZsCtJOS2U9fDNnWYe3/PZqxFSlb2mW0vD8+p1rLGCbdOxFvrdNuPvQKrRnwhnZf4WtmmBYBcbWYx1vZDxh+gHiBTFswPt2xbBc91AbqHEWTGaQAzdq0hAqj94lkfNEpDToqFMcghHQNvrcT3CPdCAAflbeFBTVFNDqoVus2Ejt6SVH93Umn26Ad89DdDyPH/TSHOZpoHKWqsvsNF5NYLkQA7yQCucPY9hDT4fkmvJ1Uxe21zlCaxt2KeugTGQlEEhciI0dQTO4R+NwDWAhzrFbctsLceFVX7xMHU0kqHGSn6aE3tOIA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3200 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT029.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: ed1d6756-46f2-47d6-258a-08d8264ee269 X-Microsoft-Antispam-Message-Info: SJRzEB3RQI3IIsKYBDyiMspMV0P3FOqMquF56gCEis+psJrQZErwTTIYIDr5h9B5GFnz6vrojFdD3TLojHm1P6w3XmAaXmEtO6K/z60cUT93fG5vew4QQrxR3qijE+fthXq97mRjHw0gR2NqnkFqXtU7MXxwGSaPz+wd7OsdAXvx6W2vkP7PRnTXaENGYv6B4kxk+W1W6OpWChJu6Gua1rmRHCtp6HrRHaXwv4T60dusrpxVOlJugIJgBJqb5k8obAew0/YBWWv+KVmc0eqyWWoj+6/n1wDmEgGoWJ1SWAPKJKzSQ0j2Gv0DJEgEOJOxLXalIoBVtNac+mi8jXFqqMsbWJWnj0H9gqptrhueOONyjHfFxiTVuq2xLNNzREebO+eXUOAeM52rYJ5ONQ3oiA== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2020 10:32:39.5950 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4199c0d4-56e1-47b2-5ecc-08d8264ee6f5 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: VE1EUR03FT029.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3997 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,Tomas.Pilar@arm.com X-Gm-Message-State: zcyX1nNmhEYbG035B95FjpcMx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1594549965; bh=kIjMYOIlpyDkZMJD6gMHRCu5QmhQoq8M/0TS0Bp+XOg=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=eoRMFvm1nNKmihPhohvgzz5hdg7M9FKq8Exqk7uQLG4fA8946M+bfNgQZ3JVoc0maQP 4/cUtjTtBrewQA3Mm1UgmqYIG75hfS+T254gf8ImMAuHOPZSl+jyo3I+2aarjaP1/JPsD aC8n3ho8PTn/KcT/G/nSG7ZKKT+0aVJbJww= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" The AcpiView core method is refactored to take format and parameters rather than a fully formatted string. This allows for far more flexible parser writing. Change-Id: I02c30939f2c5ad98da7174303ae241839d2c8eba Cc: Ray Ni Cc: Zhichao Gao Signed-off-by: Tomas Pilar --- .../UefiShellAcpiViewCommandLib/AcpiParser.c | 30 --------------- .../UefiShellAcpiViewCommandLib/AcpiParser.h | 19 ---------- .../UefiShellAcpiViewCommandLib/AcpiViewLog.c | 38 +++++++++++++++++++ .../UefiShellAcpiViewCommandLib/AcpiViewLog.h | 21 ++++++++++ .../Parsers/Dbg2/Dbg2Parser.c | 1 + .../Parsers/Fadt/FadtParser.c | 1 + .../Parsers/Iort/IortParser.c | 1 + .../Parsers/Pptt/PpttParser.c | 1 + .../Parsers/Slit/SlitParser.c | 1 + .../Parsers/Srat/SratParser.c | 1 + .../Parsers/Xsdt/XsdtParser.c | 1 + 11 files changed, 66 insertions(+), 49 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c b/Sh= ellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c index b88594cf3865..54d87e2768e1 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c @@ -13,8 +13,6 @@ #include "AcpiViewConfig.h" #include "AcpiViewLog.h" =20 -STATIC UINT32 gIndent; - STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; =20 /** @@ -390,34 +388,6 @@ Dump12Chars ( ); } =20 -/** - This function indents and prints the ACPI table Field Name. - - @param [in] Indent Number of spaces to add to the global table inde= nt. - The global table indent is 0 by default; however - this value is updated on entry to the ParseAcpi() - by adding the indent value provided to ParseAcpi= () - and restored back on exit. - Therefore the total indent in the output is - dependent on from where this function is called. - @param [in] FieldName Pointer to the Field Name. -**/ -VOID -EFIAPI -PrintFieldName ( - IN UINT32 Indent, - IN CONST CHAR16* FieldName -) -{ - Print ( - L"%*a%-*s : ", - gIndent + Indent, - "", - (OUTPUT_FIELD_COLUMN_WIDTH - gIndent - Indent), - FieldName - ); -} - /** This function is used to parse an ACPI table buffer. =20 diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h b/Sh= ellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h index 84eae61c8889..eb0c74eef144 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h @@ -204,25 +204,6 @@ Dump12Chars ( IN UINT8* Ptr ); =20 -/** - This function indents and prints the ACPI table Field Name. - - @param [in] Indent Number of spaces to add to the global table - indent. The global table indent is 0 by default; - however this value is updated on entry to the - ParseAcpi() by adding the indent value provided = to - ParseAcpi() and restored back on exit. Therefore - the total indent in the output is dependent on f= rom - where this function is called. - @param [in] FieldName Pointer to the Field Name. -**/ -VOID -EFIAPI -PrintFieldName ( - IN UINT32 Indent, - IN CONST CHAR16* FieldName - ); - /** This function pointer is the template for customizing the trace output =20 diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewLog.c b/S= hellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewLog.c index 7ec276ac7528..18bbf67eef0a 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewLog.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewLog.c @@ -27,6 +27,7 @@ static const CHAR16* mErrorTypeDesc [ACPI_ERROR_MAX] =3D { // Publicly accessible error and warning counters. UINT32 mTableErrorCount; UINT32 mTableWarningCount; +UINT32 gIndent; =20 /** Change the attributes of the standard output console @@ -336,3 +337,40 @@ CheckConstraintInternal ( // Return TRUE if constraint was violated return !Constraint; } + +/** + This function indents and prints the ACPI table Field Name. + + @param [in] Indent Number of spaces to add to the global table inde= nt. + The global table indent is 0 by default; however + this value is updated on entry to the ParseAcpi() + by adding the indent value provided to ParseAcpi= () + and restored back on exit. + Therefore the total indent in the output is + dependent on from where this function is called. + @param [in] FieldName Pointer to the format string for field name. + @param [in] ... Variable List parameters to format. +**/ +VOID +EFIAPI +PrintFieldName ( + IN UINT32 Indent, + IN CONST CHAR16* FieldNameFormat, + ... + ) +{ + VA_LIST Marker; + CHAR16 Buffer[64]; + + VA_START(Marker, FieldNameFormat); + UnicodeVSPrint(Buffer, sizeof(Buffer), FieldNameFormat, Marker); + VA_END(Marker); + + AcpiViewOutput ( + L"%*a%-*s : ", + gIndent + Indent, + "", + (OUTPUT_FIELD_COLUMN_WIDTH - gIndent - Indent), + Buffer + ); +} diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewLog.h b/S= hellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewLog.h index ce276ef7add2..0077646ca253 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewLog.h +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewLog.h @@ -40,6 +40,7 @@ typedef enum { // Publicly accessible error and warning counters. extern UINT32 mTableErrorCount; extern UINT32 mTableWarningCount; +extern UINT32 gIndent; =20 /** AcpiView output and logging function. Will log the event to @@ -171,6 +172,26 @@ CheckConstraintInternal ( !!(Constraint), \ ACPI_WARN) =20 +/** + This function indents and prints the ACPI table Field Name. + + @param [in] Indent Number of spaces to add to the global table inde= nt. + The global table indent is 0 by default; however + this value is updated on entry to the ParseAcpi() + by adding the indent value provided to ParseAcpi= () + and restored back on exit. + Therefore the total indent in the output is + dependent on from where this function is called. + @param [in] FieldName Pointer to the format string for field name. + @param [in] ... Variable List parameters to format. +**/ +VOID +EFIAPI +PrintFieldName ( + IN UINT32 Indent, + IN CONST CHAR16* FieldNameFormat, + ... + ); =20 // Maximum string size that can be printed #define MAX_OUTPUT_SIZE 256 diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Pa= rser.c index 9df111ecaa7d..dd69ed6992ba 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c @@ -12,6 +12,7 @@ #include #include "AcpiParser.h" #include "AcpiTableParser.h" +#include "AcpiViewLog.h" =20 // Local variables pointing to the table fields STATIC CONST UINT32* OffsetDbgDeviceInfo; diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/Fadt= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtPa= rser.c index d86718bab67d..4734864dfdcf 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c @@ -13,6 +13,7 @@ #include "AcpiParser.h" #include "AcpiTableParser.h" #include "AcpiView.h" +#include "AcpiViewLog.h" =20 // Local variables STATIC CONST UINT32* DsdtAddress; diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/Iort= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortPa= rser.c index f7447947b230..356f355939aa 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c @@ -14,6 +14,7 @@ #include "AcpiParser.h" #include "AcpiTableParser.h" #include "AcpiViewConfig.h" +#include "AcpiViewLog.h" =20 // Local variables STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/Pptt= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttPa= rser.c index acd2b81bb325..97a5203efb5f 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c @@ -15,6 +15,7 @@ #include "AcpiView.h" #include "AcpiViewConfig.h" #include "PpttParser.h" +#include "AcpiViewLog.h" =20 // Local variables STATIC CONST UINT8* ProcessorTopologyStructureType; diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/Slit= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitPa= rser.c index e4625ee8b139..cedfc8a71849 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c @@ -13,6 +13,7 @@ #include #include "AcpiParser.h" #include "AcpiTableParser.h" +#include "AcpiViewLog.h" =20 // Local Variables STATIC CONST UINT64* SlitSystemLocalityCount; diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/Srat= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratPa= rser.c index b9b67820b89f..568a0400bf07 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c @@ -14,6 +14,7 @@ #include "AcpiParser.h" #include "AcpiTableParser.h" #include "AcpiViewConfig.h" +#include "AcpiViewLog.h" =20 // Local Variables STATIC CONST UINT8* SratRAType; diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/Xsdt= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtPa= rser.c index e39061f8e261..771c4f322b8e 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c @@ -13,6 +13,7 @@ #include #include "AcpiParser.h" #include "AcpiTableParser.h" +#include "AcpiViewLog.h" =20 // Local variables STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; --=20 2.24.1.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#62378): https://edk2.groups.io/g/devel/message/62378 Mute This Topic: https://groups.io/mt/75454451/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri May 3 03:13:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62380+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1594549967679280.4733871856621; Sun, 12 Jul 2020 03:32:47 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id D9U0YY1788612xIG6PKJeY5u; Sun, 12 Jul 2020 03:32:47 -0700 X-Received: from EUR03-VE1-obe.outbound.protection.outlook.com (EUR03-VE1-obe.outbound.protection.outlook.com [40.107.5.46]) by mx.groups.io with SMTP id smtpd.web12.6632.1594549963666503919 for ; Sun, 12 Jul 2020 03:32:44 -0700 X-Received: from AM7PR03CA0006.eurprd03.prod.outlook.com (2603:10a6:20b:130::16) by DBBPR08MB4888.eurprd08.prod.outlook.com (2603:10a6:10:db::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.24; Sun, 12 Jul 2020 10:32:40 +0000 X-Received: from VE1EUR03FT034.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:130:cafe::33) by AM7PR03CA0006.outlook.office365.com (2603:10a6:20b:130::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.22 via Frontend Transport; Sun, 12 Jul 2020 10:32:40 +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 (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+62380+1787277+3901457@groups.io; helo=web01.groups.io; 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; X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT034.mail.protection.outlook.com (10.152.18.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Sun, 12 Jul 2020 10:32:39 +0000 X-Received: ("Tessian outbound 8f45de5545d6:v62"); Sun, 12 Jul 2020 10:32:39 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 20417495e7850dd3 X-CR-MTA-TID: 64aa7808 X-Received: from 68f9f0ecada4.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id EE4DCBC6-5F2E-45FE-9549-8F5D5BC89281.1; Sun, 12 Jul 2020 10:32:33 +0000 X-Received: from EUR03-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 68f9f0ecada4.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Sun, 12 Jul 2020 10:32:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nVSftrAI41vDxB3wG+zYt9Wi7p2A819gnvTaYFkgpGyjoLkX2QWYKlo3hJip7qKreDeOBsG5Unsa6KOPvfgqLjaFNEYWJgfEUNmTnKYC0Q8ugJtlLIZfrn4xBXv6tVgxvT7A9YZXRO0oZOXDehHD9yO7lVBGAyZW5amyY9DoA2oKhO5BaWWPvL7BHVdNc92ebdAWd5wcPEQNKAtL//Mj9E/iOGdG5XQTzB9+0CTCQNA2//7439Cu7EmyPxPJ1/fieNBHEGR3H9Z6FxftSEfvinuhzkCEZx2hyxJcoAdCU+RNlQiaZR1610s7XDkXxCAdaQpwoIx2DDJTV67gdsw/sg== 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=3LAjI6qZmPsUxor/fw0+9xc+l4Mds6cakX3ILO0QiOk=; b=fIhmrQ3HnWRDV/p+Rqj8uYtSyidO/KcbKA/9lUdnxfWoQj55K5fx/SoKQSmXhYmXKwMsZmrs4oaZsT6axeU09CgARQBrAJK0lr7vDYtWqItn0WUOXHkrEtp7ByWfJW2C6DLect7OVrPnuFqd73Q4LSNmlff5Ig/vfohecbRjFlr5QAkln7jBW0K7o3dMYLBVVhgcTF9xCwR+PVo5GS5t1wpUCPhWg52RUFpxn6Qe2nPxcxtJ6k9b/vKYWRo5BEmVDj0m4L6nfZXcC5heECJszm0Cz4vm73KCBuhIy7YNF6BhbwDuU5wwI/9A5Xh83ExjxmaRCP5j3E055gOZS7vu7g== 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 X-Received: from DBBPR09CA0015.eurprd09.prod.outlook.com (2603:10a6:10:c0::27) by AM6PR08MB4565.eurprd08.prod.outlook.com (2603:10a6:20b:af::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21; Sun, 12 Jul 2020 10:32:31 +0000 X-Received: from DB5EUR03FT008.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:c0:cafe::99) by DBBPR09CA0015.outlook.office365.com (2603:10a6:10:c0::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Sun, 12 Jul 2020 10:32:31 +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; X-Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT008.mail.protection.outlook.com (10.152.20.98) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3174.21 via Frontend Transport; Sun, 12 Jul 2020 10:32:31 +0000 X-Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1415.2; Sun, 12 Jul 2020 10:32:31 +0000 X-Received: from localhost.localdomain (10.57.55.192) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Sun, 12 Jul 2020 10:32:30 +0000 From: "Tomas Pilar (tpilar)" To: CC: , , Ray Ni , "Zhichao Gao" Subject: [edk2-devel] [PATCH v2 6/8] ShellPkg/AcpiView: Refactor dump helpers Date: Sun, 12 Jul 2020 11:32:13 +0100 Message-ID: <20200712103215.855-7-Tomas.Pilar@arm.com> In-Reply-To: <20200712103215.855-1-Tomas.Pilar@arm.com> References: <20200712103215.855-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)(376002)(39850400004)(346002)(396003)(136003)(46966005)(356005)(81166007)(4326008)(54906003)(82740400003)(6916009)(83380400001)(316002)(5660300002)(36756003)(47076004)(6666004)(30864003)(336012)(2906002)(82310400002)(70206006)(70586007)(8676002)(8936002)(1076003)(86362001)(19627235002)(478600001)(186003)(2616005)(26005)(426003);DIR:OUT;SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c8dd0f1b-5a51-4a73-1ca9-08d8264ee71c X-MS-TrafficTypeDiagnostic: AM6PR08MB4565:|DBBPR08MB4888: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8882;OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 0w+6EhaWC+7dXDidIO/NXeAtp5LAmMS4v3xCAV8xhVHDwoCB4N+RRNRZFAgewltsXi6xwDsMokJ5RxVvT0YqqaC6eh3x3DkhwHLnqd4SDy1vTmmfj3ONQRSqOaJbcjdkmOErr/kwwF42kuBwD30Sna81l5PFlLjkxMyEtD3Fi9ZbeWf5BoqB+GCCmKvwwn/He654gKw9WFDa9b92N9ItqnIpYWu7UjYXsNgpOl4KWHlnWC7Gc9aKvjiOHHqAeuozmdxu1Gw3CbBZY4qf2XIPHhgHDXr8AgfEa3hAAB/rlnDcrbnD4ay3gbAhqT4+PxnDMy2ghEJX1ZJJ1X2b6juCaXfSOezQ1Ok2S76zMVf+mzga6fVW9tp/JoIgmr8mv7j9mKehDsW71hOmy0x3Dbb8fQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4565 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT034.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 6508953c-bf1e-40bd-044d-08d8264ee23d X-Microsoft-Antispam-Message-Info: uCkJsTWhkLMARVCe+unKBHk0cjOVuSEY7pUehI7DS085DHZQwLWowMmCsBQ8YFwmKWznk8towmxvrE4wK7vj/JAUBEfQtFT4DoiYl7zdEcPQof/4X0SM8XzFXKFNJWHfkrT/Uvatah9l6bWikVWVjqbms9rxdEGpZAmRfRoKYLGy1sADeNCpj1rXCqT/TBodVPI5Yb8siFNYoRZ2V1m+pAyxkQrmhQ8DimDYWRTcta5cwoZCubE+72v1+4X3Lx4gN9YvnEZ2n13pOWJq5Muar8zB3c4BZCr0vC1IA9uRrh340PQ9g149HUuOZ3u8K3p8VJDudqJpz2yQ4CqszrkTcDd4taZir3bOj2zfGpjNm6UGz0ZZS8NOS5Av+s+on8Es7q4ENFAC/FvrXLMoU2hVBA== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2020 10:32:39.8149 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c8dd0f1b-5a51-4a73-1ca9-08d8264ee71c 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: VE1EUR03FT034.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4888 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,Tomas.Pilar@arm.com X-Gm-Message-State: OsBFSUvVJSXHvfhLWnWi5nUWx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1594549967; bh=itxIJvbRSpFZ0OtrYifsNAejrJmDibB7XNkUrYniTK4=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=pydQQIJKvkXzXo1j1krA/zD/OzjVBAGmm37r3oTkMw6WK6uviPCrrIRvcdYp95K5uJ8 ssxDCD+/vmi48g6xbElpyGeA+dVggNOINk8y9lXNvBlyynOMyJzlXcM79BBKoNR1uHHbW tEkbHaN5uluhsZvTV80+LSe3vWklzA8VGwg= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" The dump variable helper functions are refactored into a separate header file as inline functions to declutter code. Change-Id: I9c43c9ce1e9809813949b4f45b1b19b6265e18c4 Cc: Ray Ni Cc: Zhichao Gao Signed-off-by: Tomas Pilar --- .../UefiShellAcpiViewCommandLib/AcpiParser.c | 212 --------------- .../UefiShellAcpiViewCommandLib/AcpiParser.h | 134 +--------- .../FieldFormatHelper.h | 244 ++++++++++++++++++ .../UefiShellAcpiViewCommandLib.inf | 1 + 4 files changed, 247 insertions(+), 344 deletions(-) create mode 100644 ShellPkg/Library/UefiShellAcpiViewCommandLib/FieldForma= tHelper.h diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c b/Sh= ellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c index 54d87e2768e1..65108e25ff96 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c @@ -176,218 +176,6 @@ DumpRaw ( Print (L" %a\n\n", AsciiBuffer); } =20 -/** - This function traces 1 byte of data as specified in the format string. - - @param [in] Format The format string for tracing the data. - @param [in] Ptr Pointer to the start of the buffer. -**/ -VOID -EFIAPI -DumpUint8 ( - IN CONST CHAR16* Format, - IN UINT8* Ptr - ) -{ - Print (Format, *Ptr); -} - -/** - This function traces 2 bytes of data as specified in the format string. - - @param [in] Format The format string for tracing the data. - @param [in] Ptr Pointer to the start of the buffer. -**/ -VOID -EFIAPI -DumpUint16 ( - IN CONST CHAR16* Format, - IN UINT8* Ptr - ) -{ - Print (Format, *(UINT16*)Ptr); -} - -/** - This function traces 4 bytes of data as specified in the format string. - - @param [in] Format The format string for tracing the data. - @param [in] Ptr Pointer to the start of the buffer. -**/ -VOID -EFIAPI -DumpUint32 ( - IN CONST CHAR16* Format, - IN UINT8* Ptr - ) -{ - Print (Format, *(UINT32*)Ptr); -} - -/** - This function traces 8 bytes of data as specified by the format string. - - @param [in] Format The format string for tracing the data. - @param [in] Ptr Pointer to the start of the buffer. -**/ -VOID -EFIAPI -DumpUint64 ( - IN CONST CHAR16* Format, - IN UINT8* Ptr - ) -{ - // Some fields are not aligned and this causes alignment faults - // on ARM platforms if the compiler generates LDRD instructions. - // Perform word access so that LDRD instructions are not generated. - UINT64 Val; - - Val =3D *(UINT32*)(Ptr + sizeof (UINT32)); - - Val =3D LShiftU64(Val,32); - Val |=3D (UINT64)*(UINT32*)Ptr; - - Print (Format, Val); -} - -/** - This function traces 3 characters which can be optionally - formated using the format string if specified. - - If no format string is specified the Format must be NULL. - - @param [in] Format Optional format string for tracing the data. - @param [in] Ptr Pointer to the start of the buffer. -**/ -VOID -EFIAPI -Dump3Chars ( - IN CONST CHAR16* Format OPTIONAL, - IN UINT8* Ptr - ) -{ - Print ( - (Format !=3D NULL) ? Format : L"%c%c%c", - Ptr[0], - Ptr[1], - Ptr[2] - ); -} - -/** - This function traces 4 characters which can be optionally - formated using the format string if specified. - - If no format string is specified the Format must be NULL. - - @param [in] Format Optional format string for tracing the data. - @param [in] Ptr Pointer to the start of the buffer. -**/ -VOID -EFIAPI -Dump4Chars ( - IN CONST CHAR16* Format OPTIONAL, - IN UINT8* Ptr - ) -{ - Print ( - (Format !=3D NULL) ? Format : L"%c%c%c%c", - Ptr[0], - Ptr[1], - Ptr[2], - Ptr[3] - ); -} - -/** - This function traces 6 characters which can be optionally - formated using the format string if specified. - - If no format string is specified the Format must be NULL. - - @param [in] Format Optional format string for tracing the data. - @param [in] Ptr Pointer to the start of the buffer. -**/ -VOID -EFIAPI -Dump6Chars ( - IN CONST CHAR16* Format OPTIONAL, - IN UINT8* Ptr - ) -{ - Print ( - (Format !=3D NULL) ? Format : L"%c%c%c%c%c%c", - Ptr[0], - Ptr[1], - Ptr[2], - Ptr[3], - Ptr[4], - Ptr[5] - ); -} - -/** - This function traces 8 characters which can be optionally - formated using the format string if specified. - - If no format string is specified the Format must be NULL. - - @param [in] Format Optional format string for tracing the data. - @param [in] Ptr Pointer to the start of the buffer. -**/ -VOID -EFIAPI -Dump8Chars ( - IN CONST CHAR16* Format OPTIONAL, - IN UINT8* Ptr - ) -{ - Print ( - (Format !=3D NULL) ? Format : L"%c%c%c%c%c%c%c%c", - Ptr[0], - Ptr[1], - Ptr[2], - Ptr[3], - Ptr[4], - Ptr[5], - Ptr[6], - Ptr[7] - ); -} - -/** - This function traces 12 characters which can be optionally - formated using the format string if specified. - - If no format string is specified the Format must be NULL. - - @param [in] Format Optional format string for tracing the data. - @param [in] Ptr Pointer to the start of the buffer. -**/ -VOID -EFIAPI -Dump12Chars ( - IN CONST CHAR16* Format OPTIONAL, - IN UINT8* Ptr - ) -{ - Print ( - (Format !=3D NULL) ? Format : L"%c%c%c%c%c%c%c%c%c%c%c%c", - Ptr[0], - Ptr[1], - Ptr[2], - Ptr[3], - Ptr[4], - Ptr[5], - Ptr[6], - Ptr[7], - Ptr[8], - Ptr[9], - Ptr[10], - Ptr[11] - ); -} - /** This function is used to parse an ACPI table buffer. =20 diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h b/Sh= ellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h index eb0c74eef144..54ce44132055 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h @@ -8,6 +8,8 @@ #ifndef ACPIPARSER_H_ #define ACPIPARSER_H_ =20 +#include "FieldFormatHelper.h" + #define OUTPUT_FIELD_COLUMN_WIDTH 36 =20 /// The RSDP table signature is "RSD PTR " (8 bytes) @@ -72,138 +74,6 @@ DumpRaw ( IN UINT32 Length ); =20 -/** - This function traces 1 byte of datum as specified in the format string. - - @param [in] Format The format string for tracing the data. - @param [in] Ptr Pointer to the start of the buffer. -**/ -VOID -EFIAPI -DumpUint8 ( - IN CONST CHAR16* Format, - IN UINT8* Ptr - ); - -/** - This function traces 2 bytes of data as specified in the format string. - - @param [in] Format The format string for tracing the data. - @param [in] Ptr Pointer to the start of the buffer. -**/ -VOID -EFIAPI -DumpUint16 ( - IN CONST CHAR16* Format, - IN UINT8* Ptr - ); - -/** - This function traces 4 bytes of data as specified in the format string. - - @param [in] Format The format string for tracing the data. - @param [in] Ptr Pointer to the start of the buffer. -**/ -VOID -EFIAPI -DumpUint32 ( - IN CONST CHAR16* Format, - IN UINT8* Ptr - ); - -/** - This function traces 8 bytes of data as specified by the format string. - - @param [in] Format The format string for tracing the data. - @param [in] Ptr Pointer to the start of the buffer. -**/ -VOID -EFIAPI -DumpUint64 ( - IN CONST CHAR16* Format, - IN UINT8* Ptr - ); - -/** - This function traces 3 characters which can be optionally - formated using the format string if specified. - - If no format string is specified the Format must be NULL. - - @param [in] Format Optional format string for tracing the data. - @param [in] Ptr Pointer to the start of the buffer. -**/ -VOID -EFIAPI -Dump3Chars ( - IN CONST CHAR16* Format OPTIONAL, - IN UINT8* Ptr - ); - -/** - This function traces 4 characters which can be optionally - formated using the format string if specified. - - If no format string is specified the Format must be NULL. - - @param [in] Format Optional format string for tracing the data. - @param [in] Ptr Pointer to the start of the buffer. -**/ -VOID -EFIAPI -Dump4Chars ( - IN CONST CHAR16* Format OPTIONAL, - IN UINT8* Ptr - ); - -/** - This function traces 6 characters which can be optionally - formated using the format string if specified. - - If no format string is specified the Format must be NULL. - - @param [in] Format Optional format string for tracing the data. - @param [in] Ptr Pointer to the start of the buffer. -**/ -VOID -EFIAPI -Dump6Chars ( - IN CONST CHAR16* Format OPTIONAL, - IN UINT8* Ptr - ); - -/** - This function traces 8 characters which can be optionally - formated using the format string if specified. - - If no format string is specified the Format must be NULL. - - @param [in] Format Optional format string for tracing the data. - @param [in] Ptr Pointer to the start of the buffer. -**/ -VOID -EFIAPI -Dump8Chars ( - IN CONST CHAR16* Format OPTIONAL, - IN UINT8* Ptr - ); - -/** - This function traces 12 characters which can be optionally - formated using the format string if specified. - - If no format string is specified the Format must be NULL. - - @param [in] Format Optional format string for tracing the data. - @param [in] Ptr Pointer to the start of the buffer. -**/ -VOID -EFIAPI -Dump12Chars ( - IN CONST CHAR16* Format OPTIONAL, - IN UINT8* Ptr - ); - /** This function pointer is the template for customizing the trace output =20 diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/FieldFormatHelper= .h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/FieldFormatHelper.h new file mode 100644 index 000000000000..25c70652806c --- /dev/null +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/FieldFormatHelper.h @@ -0,0 +1,244 @@ +/** @file + Formatting functions used in parser definitions + + Copyright (c) 2020, ARM Limited. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef FIELD_FORMAT_HELPER_H_ +#define FIELD_FORMAT_HELPER_H_ + +#include +#include + +/** + This function traces 1 byte of data as specified in the format string. + + @param [in] Format The format string for tracing the data. + @param [in] Ptr Pointer to the start of the buffer. +**/ +static +inline +VOID +EFIAPI +DumpUint8 ( + IN CONST CHAR16* Format, + IN UINT8* Ptr + ) +{ + Print (Format, *Ptr); +} + +/** + This function traces 2 bytes of data as specified in the format string. + + @param [in] Format The format string for tracing the data. + @param [in] Ptr Pointer to the start of the buffer. +**/ +static +inline +VOID +EFIAPI +DumpUint16 ( + IN CONST CHAR16* Format, + IN UINT8* Ptr + ) +{ + Print (Format, *(UINT16*)Ptr); +} + +/** + This function traces 4 bytes of data as specified in the format string. + + @param [in] Format The format string for tracing the data. + @param [in] Ptr Pointer to the start of the buffer. +**/ +static +inline +VOID +EFIAPI +DumpUint32 ( + IN CONST CHAR16* Format, + IN UINT8* Ptr + ) +{ + Print (Format, *(UINT32*)Ptr); +} + +/** + This function traces 8 bytes of data as specified by the format string. + + @param [in] Format The format string for tracing the data. + @param [in] Ptr Pointer to the start of the buffer. +**/ +static +inline +VOID +EFIAPI +DumpUint64 ( + IN CONST CHAR16* Format, + IN UINT8* Ptr + ) +{ + // Some fields are not aligned and this causes alignment faults + // on ARM platforms if the compiler generates LDRD instructions. + // Perform word access so that LDRD instructions are not generated. + UINT64 Val; + + Val =3D *(UINT32*)(Ptr + sizeof (UINT32)); + + Val =3D LShiftU64(Val,32); + Val |=3D (UINT64)*(UINT32*)Ptr; + + Print (Format, Val); +} + +/** + This function traces 3 characters which can be optionally + formated using the format string if specified. + + If no format string is specified the Format must be NULL. + + @param [in] Format Optional format string for tracing the data. + @param [in] Ptr Pointer to the start of the buffer. +**/ +static +inline +VOID +EFIAPI +Dump3Chars ( + IN CONST CHAR16* Format OPTIONAL, + IN UINT8* Ptr + ) +{ + Print ( + (Format !=3D NULL) ? Format : (CONST CHAR16*) L"%c%c%c", + Ptr[0], + Ptr[1], + Ptr[2] + ); +} + +/** + This function traces 4 characters which can be optionally + formated using the format string if specified. + + If no format string is specified the Format must be NULL. + + @param [in] Format Optional format string for tracing the data. + @param [in] Ptr Pointer to the start of the buffer. +**/ +static +inline +VOID +EFIAPI +Dump4Chars ( + IN CONST CHAR16* Format OPTIONAL, + IN UINT8* Ptr + ) +{ + Print ( + (Format !=3D NULL) ? Format : (CONST CHAR16*) L"%c%c%c%c", + Ptr[0], + Ptr[1], + Ptr[2], + Ptr[3] + ); +} + +/** + This function traces 6 characters which can be optionally + formated using the format string if specified. + + If no format string is specified the Format must be NULL. + + @param [in] Format Optional format string for tracing the data. + @param [in] Ptr Pointer to the start of the buffer. +**/ +static +inline +VOID +EFIAPI +Dump6Chars ( + IN CONST CHAR16* Format OPTIONAL, + IN UINT8* Ptr + ) +{ + Print ( + (Format !=3D NULL) ? Format : (CONST CHAR16*) L"%c%c%c%c%c%c", + Ptr[0], + Ptr[1], + Ptr[2], + Ptr[3], + Ptr[4], + Ptr[5] + ); +} + +/** + This function traces 8 characters which can be optionally + formated using the format string if specified. + + If no format string is specified the Format must be NULL. + + @param [in] Format Optional format string for tracing the data. + @param [in] Ptr Pointer to the start of the buffer. +**/ +static +inline +VOID +EFIAPI +Dump8Chars ( + IN CONST CHAR16* Format OPTIONAL, + IN UINT8* Ptr + ) +{ + Print ( + (Format !=3D NULL) ? Format : (CONST CHAR16*) L"%c%c%c%c%c%c%c%c", + Ptr[0], + Ptr[1], + Ptr[2], + Ptr[3], + Ptr[4], + Ptr[5], + Ptr[6], + Ptr[7] + ); +} + +/** + This function traces 12 characters which can be optionally + formated using the format string if specified. + + If no format string is specified the Format must be NULL. + + @param [in] Format Optional format string for tracing the data. + @param [in] Ptr Pointer to the start of the buffer. +**/ +static +inline +VOID +EFIAPI +Dump12Chars ( + IN CONST CHAR16* Format OPTIONAL, + IN UINT8* Ptr + ) +{ + Print ( + (Format !=3D NULL) ? Format : (CONST CHAR16*) L"%c%c%c%c%c%c%c%c%c%c%c= %c", + Ptr[0], + Ptr[1], + Ptr[2], + Ptr[3], + Ptr[4], + Ptr[5], + Ptr[6], + Ptr[7], + Ptr[8], + Ptr[9], + Ptr[10], + Ptr[11] + ); +} + +#endif diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiView= CommandLib.inf b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpi= ViewCommandLib.inf index e0586cbccec2..271d09a940ee 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand= Lib.inf +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand= Lib.inf @@ -29,6 +29,7 @@ [Sources.common] AcpiViewConfig.h AcpiViewLog.h AcpiViewLog.c + FieldFormatHelper.h Parsers/Bgrt/BgrtParser.c Parsers/Dbg2/Dbg2Parser.c Parsers/Dsdt/DsdtParser.c --=20 2.24.1.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#62380): https://edk2.groups.io/g/devel/message/62380 Mute This Topic: https://groups.io/mt/75454453/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri May 3 03:13:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62381+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1594549968113909.940623551551; Sun, 12 Jul 2020 03:32:48 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id boGGYY1788612xklliWFSr3Y; Sun, 12 Jul 2020 03:32:47 -0700 X-Received: from EUR04-DB3-obe.outbound.protection.outlook.com (EUR04-DB3-obe.outbound.protection.outlook.com [40.107.6.84]) by mx.groups.io with SMTP id smtpd.web12.6633.1594549964410827501 for ; Sun, 12 Jul 2020 03:32:44 -0700 X-Received: from DB6P192CA0019.EURP192.PROD.OUTLOOK.COM (2603:10a6:4:b8::29) by HE1PR0802MB2523.eurprd08.prod.outlook.com (2603:10a6:3:e1::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21; Sun, 12 Jul 2020 10:32:40 +0000 X-Received: from DB5EUR03FT040.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:b8:cafe::c7) by DB6P192CA0019.outlook.office365.com (2603:10a6:4:b8::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Sun, 12 Jul 2020 10:32:40 +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 (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+62381+1787277+3901457@groups.io; helo=web01.groups.io; 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; X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT040.mail.protection.outlook.com (10.152.20.243) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Sun, 12 Jul 2020 10:32:40 +0000 X-Received: ("Tessian outbound c83312565ef4:v62"); Sun, 12 Jul 2020 10:32:39 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 9ba502b1da5edcde X-CR-MTA-TID: 64aa7808 X-Received: from c35da852b146.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 9E93F678-9FB1-41D0-A24D-09434B3F18D5.1; Sun, 12 Jul 2020 10:32:34 +0000 X-Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id c35da852b146.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Sun, 12 Jul 2020 10:32:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gtcp3hPSLxV8ETVIrG/dFKv3QtAizkGnHBSojzaTN4hl6t/IbnwgKBJchrVBQUQrOomjOrcj6cG3EwBbIdYwkD0Xn8q0fzv+hjO4VlUfcprSeKjGaVRmpmwn8Ss9IMw5VcmCp3v8/aqtPx+5/ilbkYWCMhDrBgRM3LDU240TmEMtNBwLdtME8EAaEVGvzp+K7L0CdKYxLdgfSMgICjLaB5NXC4ofY6vdZcDPn+4v3N29ddLGm/1gwcSeTAmRdQCxGb/DSh8USn8WlWsccC8UAZ3FRKn9KcYujUOjMw8lTmOJnzYgcRHEA+3/9dqBNJ7SUkgjTD1hhkC6l2UnhrEyFw== 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=derZx6RdIfGESDqqjpghqy33LgEeWG27KK3UY64z6HE=; b=aOJ1+aaxvnV9z7srVuZ8UWXNr4u4tM25qBsTOvS/SMQQ0RdqQ4ElTaLaYTculIVvHlRPijEaAp1W9yj0V4v+QzoLqKpOMx6fx61L4MNvKsVx/K0V3a5FINTpSnsURh2FWYUFE1xHD5kstzBbRaVUC2dJfXaH5/sW1neBAxLAlzAGRTe502I0pxWXlRUAr6co07wwNVih7sQJ5rDgEB0PV2fGdeYu1JqvdxzkOe79jq7nBV1CG/KNqInY1NbjBNR1N4W+taz3+xkakpDNdwxexCOaTrcdNozHkzfaZRI9/3YNQHt9qe5mI7Va94/+2DDyl91C10gfnt6AinIfle6fdQ== 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 X-Received: from DBBPR09CA0012.eurprd09.prod.outlook.com (2603:10a6:10:c0::24) by AM6PR08MB4470.eurprd08.prod.outlook.com (2603:10a6:20b:b5::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.22; Sun, 12 Jul 2020 10:32:32 +0000 X-Received: from DB5EUR03FT008.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:c0:cafe::51) by DBBPR09CA0012.outlook.office365.com (2603:10a6:10:c0::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Sun, 12 Jul 2020 10:32:32 +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; X-Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT008.mail.protection.outlook.com (10.152.20.98) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3174.21 via Frontend Transport; Sun, 12 Jul 2020 10:32:32 +0000 X-Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1415.2; Sun, 12 Jul 2020 10:32:32 +0000 X-Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1779.2; Sun, 12 Jul 2020 10:32:31 +0000 X-Received: from localhost.localdomain (10.57.55.192) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Sun, 12 Jul 2020 10:32:31 +0000 From: "Tomas Pilar (tpilar)" To: CC: , , Ray Ni , "Zhichao Gao" Subject: [edk2-devel] [PATCH v2 7/8] ShellPkg/AcpiView: Refactor AcpiView Date: Sun, 12 Jul 2020 11:32:14 +0100 Message-ID: <20200712103215.855-8-Tomas.Pilar@arm.com> In-Reply-To: <20200712103215.855-1-Tomas.Pilar@arm.com> References: <20200712103215.855-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)(396003)(39850400004)(136003)(376002)(346002)(46966005)(82740400003)(8936002)(30864003)(47076004)(5660300002)(336012)(6666004)(1076003)(54906003)(478600001)(356005)(86362001)(81166007)(8676002)(82310400002)(4326008)(83380400001)(2906002)(6916009)(26005)(316002)(70206006)(70586007)(2616005)(36756003)(426003)(186003);DIR:OUT;SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 09368e37-8bbd-4f72-2123-08d8264ee72b X-MS-TrafficTypeDiagnostic: AM6PR08MB4470:|HE1PR0802MB2523: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8273;OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: xcIPRMxyHrUPzt+whFDXr/Wmpp4vlnKB+4ElCsKiBumBeWCNOQNmKGNKCZEnTodW4hpvZM2ajqTszQO66hFs4cSFYWSsr+lTXB52Ipz7eAGXnP9LgR1MzwXZyhyZABWZ1a8aFE5wpa/kva6NspaF8Ev7HZllgTj759aguos0ZnJIQ8s0P3s+gJyzSiKIgxu7OBlXtr4tXxFKVl6IvOQ4b05Ol2Qt9Zb1de466aZBK9D8uVkIdHcyZCnb60Gl3siRIm4DO3GFwThBaYRhByN8T4OQEGGdfmoGnYxQPQNMinQytcu4c6aWP7u0l4eWihUQhDISR2EOltkBh/NHH0y37g615BqsPL9fJVezBo1er5lr2SX9QIubDTFE0ny7AcK/YXh8gG8f1M/LxlRIB8ZFhA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4470 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT040.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 9cdd18d6-2ea0-456e-0f0a-08d8264ee2ce X-Microsoft-Antispam-Message-Info: yzjBGf8o75n97MoVkq9Zfu/VdFZWlazTad7CIQSHnmW4jBGXESURbpSaFJnPfSYS5KB4091OLXr2FnLzLhoerAtwIL3k6sqSb1MyhDDGR1shlRPYYm6hNu/J9gI4HlN/wv+klhHrcAeTNIiCIxEJSnemu5daG1toseNIVuGizRpwGPy05HIMWZG9MYaDlpp/QlTFpJkqV6SRnoj0EL5X5Ea7O+jeZe5VKHG2/+MBv3kSHJPk+rQgwRu82F6qnglkMV0ISlSEWzOspmHdJ1RdP5f2QmQCE5vHVlTUValY70GroHMgRGOmEI/bQ3iwTmgZOPWLy87LPg7LTpAsImYqSgtVu1cM49J9zCr63VreKP5W9L35Zs0gbU5aMbt7Ek9u6SbM46mnG2Almlavkoo4Ng== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2020 10:32:40.0413 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 09368e37-8bbd-4f72-2123-08d8264ee72b 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: DB5EUR03FT040.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0802MB2523 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,Tomas.Pilar@arm.com X-Gm-Message-State: IOUvcIwh6IKbfgBFqFqDTzuTx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1594549967; bh=hK59ndObxTC9UfyqHw7yzjjtLE9SaInjhXQCyZGgWck=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=MAbToNka7Kkf5k0BwKFk8zXHjajmvNtjiYer6qBHHP+M67trJma902hvyYOgRPeQVw2 ML/ToAONiMqG/Akczx9MUXOvfPLxnJ6mSSX8l0K4ffCDC5HBnIE1tGrAKo4R9reTOt0WH GdwFUCI2g+NH7LhoH/L2aS08Ta19mscyw+Y= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Refactor logging using the AcpiViewLog facility. Trim some of the source to more elegant state. Change-Id: I98b2c49b155e8c8b91aaf9bbd2ab21ebad5b36f0 Cc: Ray Ni Cc: Zhichao Gao Signed-off-by: Tomas Pilar --- .../UefiShellAcpiViewCommandLib/AcpiParser.c | 225 ++++++++---------- .../UefiShellAcpiViewCommandLib/AcpiParser.h | 6 +- .../AcpiTableParser.c | 52 ++-- .../AcpiTableParser.h | 2 +- .../UefiShellAcpiViewCommandLib/AcpiView.c | 187 +++++---------- .../FieldFormatHelper.h | 106 +-------- 6 files changed, 188 insertions(+), 390 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c b/Sh= ellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c index 65108e25ff96..16b8d1f80bc2 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c @@ -8,6 +8,9 @@ #include #include #include +#include +#include +#include #include "AcpiParser.h" #include "AcpiView.h" #include "AcpiViewConfig.h" @@ -46,6 +49,7 @@ IncrementWarningCount ( mTableWarningCount++; } =20 + /** This function verifies the ACPI table checksum. =20 @@ -69,12 +73,7 @@ VerifyChecksum ( { UINTN ByteCount; UINT8 Checksum; - UINTN OriginalAttribute; =20 - // - // set local variables to suppress incorrect compiler/analyzer warnings - // - OriginalAttribute =3D 0; ByteCount =3D 0; Checksum =3D 0; =20 @@ -84,29 +83,10 @@ VerifyChecksum ( } =20 if (Log) { - OriginalAttribute =3D gST->ConOut->Mode->Attribute; if (Checksum =3D=3D 0) { - if (mConfig.ColourHighlighting) { - gST->ConOut->SetAttribute ( - gST->ConOut, - EFI_TEXT_ATTR (EFI_GREEN, - ((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)) - ); - } - Print (L"Table Checksum : OK\n\n"); + AcpiLog (ACPI_GOOD, L"Table Checksum : OK\n"); } else { - IncrementErrorCount (); - if (mConfig.ColourHighlighting) { - gST->ConOut->SetAttribute ( - gST->ConOut, - EFI_TEXT_ATTR (EFI_RED, - ((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)) - ); - } - Print (L"Table Checksum : FAILED (0x%X)\n\n", Checksum); - } - if (mConfig.ColourHighlighting) { - gST->ConOut->SetAttribute (gST->ConOut, OriginalAttribute); + AcpiError (ACPI_ERROR_CSUM, L"Table Checksum (0x%X !=3D 0)\n", Check= sum); } } =20 @@ -127,53 +107,101 @@ DumpRaw ( ) { UINTN ByteCount; - UINTN PartLineChars; - UINTN AsciiBufferIndex; CHAR8 AsciiBuffer[17]; + CHAR8 HexBuffer[128]; + CHAR8 *HexCursor; =20 ByteCount =3D 0; - AsciiBufferIndex =3D 0; =20 - Print (L"Address : 0x%p\n", Ptr); - Print (L"Length : %d\n", Length); + AcpiInfo (L"Address : 0x%p", Ptr); + AcpiInfo (L"Length : %d\n", Length); =20 while (ByteCount < Length) { - if ((ByteCount & 0x0F) =3D=3D 0) { - AsciiBuffer[AsciiBufferIndex] =3D '\0'; - Print (L" %a\n%08X : ", AsciiBuffer, ByteCount); - AsciiBufferIndex =3D 0; - } else if ((ByteCount & 0x07) =3D=3D 0) { - Print (L"- "); + + // Reset ascii and hex strings + if (ByteCount % 16 =3D=3D 0) { + HexCursor =3D HexBuffer; + ZeroMem (AsciiBuffer, sizeof(AsciiBuffer)); + ZeroMem (HexBuffer, sizeof(HexBuffer)); + } else if (ByteCount % 8 =3D=3D 0) { + HexCursor +=3D AsciiSPrint (HexCursor, sizeof(HexBuffer), "- "); } =20 + // Add hex couplet to hex buffer + HexCursor +=3D AsciiSPrint (HexCursor, sizeof(HexBuffer), "%02X ", *Pt= r); + + // Add ascii letter to the ascii buffer + AsciiBuffer[ByteCount & 0xF] =3D '.'; if ((*Ptr >=3D ' ') && (*Ptr < 0x7F)) { - AsciiBuffer[AsciiBufferIndex++] =3D *Ptr; - } else { - AsciiBuffer[AsciiBufferIndex++] =3D '.'; + AsciiBuffer[ByteCount & 0xF] =3D *Ptr; } =20 - Print (L"%02X ", *Ptr++); + // Print line with fixed width hex part + if (ByteCount % 16 =3D=3D 15) { + AcpiInfo (L"%08X : %-.*a %a", ByteCount + 1, 46, HexBuffer, AsciiBuf= fer); + } =20 ByteCount++; + Ptr++; } =20 - // Justify the final line using spaces before printing - // the ASCII data. - PartLineChars =3D (Length & 0x0F); - if (PartLineChars !=3D 0) { - PartLineChars =3D 48 - (PartLineChars * 3); - if ((Length & 0x0F) <=3D 8) { - PartLineChars +=3D 2; - } - while (PartLineChars > 0) { - Print (L" "); - PartLineChars--; + // Print the last line + if (ByteCount % 16 !=3D 15) { + AcpiInfo ( + L"%08X : %-*a %.*a", + (ByteCount + 16) & ~0xF, + 46, + HexBuffer, + ByteCount & 0xF, + AsciiBuffer); } +} + +/** + Prints an arbitrary variable to screen using a given parser. + Also calls the internal validator if it exists. + + @param[in] Parser The parser to use to print to screen + @param[in] Prt Pointer to variable that should be printed +**/ +STATIC +VOID +EFIAPI +DumpAndValidate( + IN CONST ACPI_PARSER* Parser, + IN VOID* Ptr + ) +{ + // if there is a Formatter function let the function handle + // the printing else if a Format is specified in the table use + // the Format for printing + PrintFieldName (2, Parser->NameStr); + if (Parser->PrintFormatter !=3D NULL) { + Parser->PrintFormatter(Parser->Format, Ptr); + } else if (Parser->Format !=3D NULL) { + switch (Parser->Length) { + case 1: + AcpiInfo (Parser->Format, *(UINT8 *)Ptr); + break; + case 2: + AcpiInfo (Parser->Format, ReadUnaligned16 ((CONST UINT16 *)Ptr)); + break; + case 4: + AcpiInfo (Parser->Format, ReadUnaligned32 ((CONST UINT32 *)Ptr)); + break; + case 8: + AcpiInfo (Parser->Format, ReadUnaligned64 ((CONST UINT64 *)Ptr)); + break; + default: + AcpiLog (ACPI_BAD, L""); + } // switch } =20 - // Print ASCII data for the final line. - AsciiBuffer[AsciiBufferIndex] =3D '\0'; - Print (L" %a\n\n", AsciiBuffer); + // Validating only makes sense if we are tracing + // the parsed table entries, to report by table name. + if (mConfig.ConsistencyCheck && (Parser->FieldValidator !=3D NULL)) { + Parser->FieldValidator(Ptr, Parser->Context); + } } =20 /** @@ -216,39 +244,25 @@ ParseAcpi ( { UINT32 Index; UINT32 Offset; - UINTN OriginalAttribute; =20 - // - // set local variables to suppress incorrect compiler/analyzer warnings - // - OriginalAttribute =3D 0; - Offset =3D 0; + if (Length =3D=3D 0) { + AcpiLog ( + ACPI_WARN, + L"Will not parse zero-length buffer <%a>=3D%p", + AsciiName ? AsciiName : "Unknown Item", + Ptr); + return 0; + } =20 // Increment the Indent gIndent +=3D Indent; =20 if (Trace && (AsciiName !=3D NULL)){ - - if (mConfig.ColourHighlighting) { - OriginalAttribute =3D gST->ConOut->Mode->Attribute; - gST->ConOut->SetAttribute ( - gST->ConOut, - EFI_TEXT_ATTR(EFI_YELLOW, - ((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)) - ); - } - Print ( - L"%*a%-*a :\n", - gIndent, - "", - (OUTPUT_FIELD_COLUMN_WIDTH - gIndent), - AsciiName - ); - if (mConfig.ColourHighlighting) { - gST->ConOut->SetAttribute (gST->ConOut, OriginalAttribute); - } + AcpiLog ( + ACPI_ITEM, L"%*.a%a", gIndent, "", AsciiName); } =20 + Offset =3D 0; for (Index =3D 0; Index < ParserItems; Index++) { if ((Offset + Parser[Index].Length) > Length) { =20 @@ -263,10 +277,8 @@ ParseAcpi ( } =20 if (mConfig.ConsistencyCheck && (Offset !=3D Parser[Index].Offset)) { - IncrementErrorCount (); - Print ( - L"\nERROR: %a: Offset Mismatch for %s\n" - L"CurrentOffset =3D %d FieldOffset =3D %d\n", + AcpiError (ACPI_ERROR_PARSE, + L"%a: Offset Mismatch for %s (%d !=3D %d)", AsciiName, Parser[Index].NameStr, Offset, @@ -275,48 +287,13 @@ ParseAcpi ( } =20 if (Trace) { - // if there is a Formatter function let the function handle - // the printing else if a Format is specified in the table use - // the Format for printing - PrintFieldName (2, Parser[Index].NameStr); - if (Parser[Index].PrintFormatter !=3D NULL) { - Parser[Index].PrintFormatter (Parser[Index].Format, Ptr); - } else if (Parser[Index].Format !=3D NULL) { - switch (Parser[Index].Length) { - case 1: - DumpUint8 (Parser[Index].Format, Ptr); - break; - case 2: - DumpUint16 (Parser[Index].Format, Ptr); - break; - case 4: - DumpUint32 (Parser[Index].Format, Ptr); - break; - case 8: - DumpUint64 (Parser[Index].Format, Ptr); - break; - default: - Print ( - L"\nERROR: %a: CANNOT PARSE THIS FIELD, Field Length =3D %d\= n", - AsciiName, - Parser[Index].Length - ); - } // switch - - // Validating only makes sense if we are tracing - // the parsed table entries, to report by table name. - if (mConfig.ConsistencyCheck && (Parser[Index].FieldValidator !=3D= NULL)) { - Parser[Index].FieldValidator (Ptr, Parser[Index].Context); - } - } - Print (L"\n"); - } // if (Trace) + DumpAndValidate (&Parser[Index], &Ptr[Offset]); + } =20 if (Parser[Index].ItemPtr !=3D NULL) { - *Parser[Index].ItemPtr =3D (VOID*)Ptr; + *Parser[Index].ItemPtr =3D Ptr + Offset; } =20 - Ptr +=3D Parser[Index].Length; Offset +=3D Parser[Index].Length; } // for =20 @@ -355,7 +332,7 @@ DumpGasStruct ( IN UINT32 Length ) { - Print (L"\n"); + AcpiInfo(L""); return ParseAcpi ( TRUE, Indent, @@ -421,7 +398,7 @@ DumpAcpiHeader ( UINT32 EFIAPI ParseAcpiHeader ( - IN UINT8* Ptr, + IN VOID* Ptr, OUT CONST UINT32** Signature, OUT CONST UINT32** Length, OUT CONST UINT8** Revision diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h b/Sh= ellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h index 54ce44132055..bd3cdb774fb5 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h @@ -18,10 +18,6 @@ /// that allows us to process the log options. #define RSDP_TABLE_INFO SIGNATURE_32('R', 'S', 'D', 'P') =20 -// Publicly accessible error and warning counters. -extern UINT32 mTableErrorCount; -extern UINT32 mTableWarningCount; - /** This function increments the ACPI table error counter. **/ @@ -310,7 +306,7 @@ DumpAcpiHeader ( UINT32 EFIAPI ParseAcpiHeader ( - IN UINT8* Ptr, + IN VOID* Ptr, OUT CONST UINT32** Signature, OUT CONST UINT32** Length, OUT CONST UINT8** Revision diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c= b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c index 526cb8cb7cad..49acb3d03da1 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c @@ -18,6 +18,7 @@ #include "AcpiTableParser.h" #include "AcpiView.h" #include "AcpiViewConfig.h" +#include "AcpiViewLog.h" =20 #if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) #include "Arm/SbbrValidator.h" @@ -179,61 +180,43 @@ GetParser ( VOID EFIAPI ProcessAcpiTable ( - IN UINT8* Ptr + IN VOID* Ptr ) { EFI_STATUS Status; BOOLEAN Trace; - CONST UINT32* AcpiTableSignature; - CONST UINT32* AcpiTableLength; - CONST UINT8* AcpiTableRevision; - CONST UINT8* SignaturePtr; + CONST UINT32* Signature; + CONST UINT32* Length; + CONST UINT8* Revision; PARSE_ACPI_TABLE_PROC ParserProc; =20 - ParseAcpiHeader ( - Ptr, - &AcpiTableSignature, - &AcpiTableLength, - &AcpiTableRevision - ); + ParseAcpiHeader (Ptr, &Signature, &Length, &Revision); =20 - Trace =3D ProcessTableReportOptions ( - *AcpiTableSignature, - Ptr, - *AcpiTableLength - ); + Trace =3D ProcessTableReportOptions (*Signature, Ptr, *Length); =20 if (Trace) { - DumpRaw (Ptr, *AcpiTableLength); + DumpRaw (Ptr, *Length); =20 // Do not process the ACPI table any further if the table length read // is invalid. The ACPI table should at least contain the table header. - if (*AcpiTableLength < sizeof (EFI_ACPI_DESCRIPTION_HEADER)) { - SignaturePtr =3D (CONST UINT8*)AcpiTableSignature; - IncrementErrorCount (); - Print ( - L"ERROR: Invalid %c%c%c%c table length. Length =3D %d\n", - SignaturePtr[0], - SignaturePtr[1], - SignaturePtr[2], - SignaturePtr[3], - *AcpiTableLength - ); + if (*Length < sizeof (EFI_ACPI_DESCRIPTION_HEADER)) { + AcpiError ( + ACPI_ERROR_LENGTH, L"Table %4a invalid length %d", Signature, *Len= gth); return; } =20 if (mConfig.ConsistencyCheck) { - VerifyChecksum (TRUE, Ptr, *AcpiTableLength); + VerifyChecksum (TRUE, Ptr, *Length); } } =20 #if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) if (mConfig.MandatoryTableValidate) { - ArmSbbrIncrementTableCount (*AcpiTableSignature); + ArmSbbrIncrementTableCount (*Signature); } #endif =20 - Status =3D GetParser (*AcpiTableSignature, &ParserProc); + Status =3D GetParser (*Signature, &ParserProc); if (EFI_ERROR (Status)) { // No registered parser found, do default handling. if (Trace) { @@ -242,10 +225,5 @@ ProcessAcpiTable ( return; } =20 - ParserProc ( - Trace, - Ptr, - *AcpiTableLength, - *AcpiTableRevision - ); + ParserProc (Trace, Ptr, *Length, *Revision); } diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h= b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h index 4f92596b90a6..e2afeda2379c 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h @@ -101,7 +101,7 @@ DeregisterParser ( VOID EFIAPI ProcessAcpiTable ( - IN UINT8* Ptr + IN VOID* Ptr ); =20 /** diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c b/Shel= lPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c index 16f498b8c328..a34af68f7c23 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c @@ -10,6 +10,8 @@ - Arm Server Base Boot Requirements 1.2, September 2019 **/ =20 +#include + #include #include #include @@ -22,6 +24,7 @@ #include "AcpiTableParser.h" #include "AcpiView.h" #include "AcpiViewConfig.h" +#include "AcpiViewLog.h" =20 #if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) #include "Arm/SbbrValidator.h" @@ -57,7 +60,7 @@ DumpAcpiTableToFile ( mBinTableCount++ ); =20 - Print (L"Dumping ACPI table to : %s ... ", FileNameBuffer); + AcpiInfo (L"Dumping ACPI table to : %s ... ", FileNameBuffer); =20 TransferBytes =3D ShellDumpBufferToFile (FileNameBuffer, Ptr, Length); return (Length =3D=3D TransferBytes); @@ -79,15 +82,7 @@ ProcessTableReportOptions ( IN CONST UINT32 Length ) { - UINTN OriginalAttribute; - UINT8 *SignaturePtr; BOOLEAN Log; - - // - // set local variables to suppress incorrect compiler/analyzer warnings - // - OriginalAttribute =3D 0; - SignaturePtr =3D (UINT8*)(UINTN)&Signature; Log =3D FALSE; =20 switch (mConfig.ReportType) { @@ -102,27 +97,9 @@ ProcessTableReportOptions ( break; case ReportTableList: if (mTableCount =3D=3D 0) { - if (mConfig.ColourHighlighting) { - OriginalAttribute =3D gST->ConOut->Mode->Attribute; - gST->ConOut->SetAttribute ( - gST->ConOut, - EFI_TEXT_ATTR(EFI_CYAN, - ((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)) - ); - } - Print (L"\nInstalled Table(s):\n"); - if (mConfig.ColourHighlighting) { - gST->ConOut->SetAttribute (gST->ConOut, OriginalAttribute); - } + AcpiLog (ACPI_HIGHLIGHT, L"\nInstalled Table(s):"); } - Print ( - L"\t%4d. %c%c%c%c\n", - ++mTableCount, - SignaturePtr[0], - SignaturePtr[1], - SignaturePtr[2], - SignaturePtr[3] - ); + AcpiInfo (L"\t%4d. %.*a", ++mTableCount, 4, &Signature); break; case ReportDumpBinFile: if (Signature =3D=3D mSelectedAcpiTable.Type) { @@ -137,31 +114,16 @@ ProcessTableReportOptions ( } // switch =20 if (Log) { - if (mConfig.ColourHighlighting) { - OriginalAttribute =3D gST->ConOut->Mode->Attribute; - gST->ConOut->SetAttribute ( - gST->ConOut, - EFI_TEXT_ATTR(EFI_LIGHTBLUE, - ((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)) - ); - } - Print ( - L"\n\n --------------- %c%c%c%c Table --------------- \n\n", - SignaturePtr[0], - SignaturePtr[1], - SignaturePtr[2], - SignaturePtr[3] - ); - if (mConfig.ColourHighlighting) { - gST->ConOut->SetAttribute (gST->ConOut, OriginalAttribute); - } + AcpiLog ( + ACPI_HIGHLIGHT, + L"\n --------------- %.*a Table --------------- \n", + 4, + &Signature); } =20 return Log; } =20 - - /** This function iterates the configuration table entries in the system table, retrieves the RSDP pointer and starts parsing the ACPI tab= les. @@ -181,17 +143,12 @@ AcpiView ( EFI_STATUS Status; UINTN Index; EFI_CONFIGURATION_TABLE* EfiConfigurationTable; - BOOLEAN FoundAcpiTable; - UINTN OriginalAttribute; - UINTN PrintAttribute; UINT8* RsdpPtr; UINT32 RsdpLength; UINT8 RsdpRevision; PARSE_ACPI_TABLE_PROC RsdpParserProc; BOOLEAN Trace; =20 - OriginalAttribute =3D 0; - // Reset Table counts mTableCount =3D 0; mBinTableCount =3D 0; @@ -201,107 +158,77 @@ AcpiView ( mTableWarningCount =3D 0; =20 // Search the table for an entry that matches the ACPI Table Guid - FoundAcpiTable =3D FALSE; + EfiConfigurationTable =3D NULL; for (Index =3D 0; Index < SystemTable->NumberOfTableEntries; Index++) { if (CompareGuid (&gEfiAcpiTableGuid, &(SystemTable->ConfigurationTable[Index].VendorGuid))) { EfiConfigurationTable =3D &SystemTable->ConfigurationTable[Index]; - FoundAcpiTable =3D TRUE; break; } } =20 - if (FoundAcpiTable) { - RsdpPtr =3D (UINT8*)EfiConfigurationTable->VendorTable; + if (!EfiConfigurationTable) { + AcpiFatal (L"No ACPI Table Guid in System Configuration Table."); + return EFI_NOT_FOUND; + } =20 - // The RSDP revision is 1 byte starting at offset 15 - RsdpRevision =3D *(RsdpPtr + RSDP_REVISION_OFFSET); + RsdpPtr =3D (UINT8 *)EfiConfigurationTable->VendorTable; =20 - if (RsdpRevision < 2) { - Print ( - L"ERROR: RSDP version less than 2 is not supported.\n" - ); - return EFI_UNSUPPORTED; - } + // The RSDP revision is 1 byte starting at offset 15 + RsdpRevision =3D *(RsdpPtr + RSDP_REVISION_OFFSET); =20 -#if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) - if (mConfig.MandatoryTableValidate) { - ArmSbbrResetTableCounts (); - } -#endif + if (RsdpRevision < 2) { + AcpiFatal (L"RSDP version less than 2 is not supported."); + return EFI_UNSUPPORTED; + } =20 - // The RSDP length is 4 bytes starting at offset 20 - RsdpLength =3D *(UINT32*)(RsdpPtr + RSDP_LENGTH_OFFSET); +#if defined(MDE_CPU_ARM) || defined(MDE_CPU_AARCH64) + if (mConfig.MandatoryTableValidate) { + ArmSbbrResetTableCounts(); + } +#endif =20 - Trace =3D ProcessTableReportOptions (RSDP_TABLE_INFO, RsdpPtr, RsdpLen= gth); + // The RSDP length is 4 bytes starting at offset 20 + RsdpLength =3D *(UINT32 *)(RsdpPtr + RSDP_LENGTH_OFFSET); =20 - Status =3D GetParser (RSDP_TABLE_INFO, &RsdpParserProc); - if (EFI_ERROR (Status)) { - Print ( - L"ERROR: No registered parser found for RSDP.\n" - ); - return Status; - } + Trace =3D ProcessTableReportOptions(RSDP_TABLE_INFO, RsdpPtr, RsdpLength= ); =20 - RsdpParserProc ( - Trace, - RsdpPtr, - RsdpLength, - RsdpRevision - ); - - } else { - IncrementErrorCount (); - Print ( - L"ERROR: Failed to find ACPI Table Guid in System Configuration Tabl= e.\n" - ); - return EFI_NOT_FOUND; + Status =3D GetParser(RSDP_TABLE_INFO, &RsdpParserProc); + if (EFI_ERROR(Status)) { + AcpiFatal (L"No registered parser found for RSDP."); + return Status; } =20 + RsdpParserProc(Trace, RsdpPtr, RsdpLength, RsdpRevision); + #if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) if (mConfig.MandatoryTableValidate) { ArmSbbrReqsValidate ((ARM_SBBR_VERSION) mConfig.MandatoryTableSpec); } #endif =20 - 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 (mConfig.ConsistencyCheck && - (ReportDumpBinFile !=3D mConfig.ReportType)) { - OriginalAttribute =3D gST->ConOut->Mode->Attribute; - - Print (L"\nTable Statistics:\n"); - - if (mConfig.ColourHighlighting) { - PrintAttribute =3D ((mTableErrorCount) > 0) ? - EFI_TEXT_ATTR ( - EFI_RED, - ((OriginalAttribute&(BIT4|BIT5|BIT6))>>4) - ) : - OriginalAttribute; - gST->ConOut->SetAttribute (gST->ConOut, PrintAttribute); - } - Print (L"\t%d Error(s)\n", mTableErrorCount); - - if (mConfig.ColourHighlighting) { - PrintAttribute =3D (mTableWarningCount > 0) ? - EFI_TEXT_ATTR ( - EFI_RED, - ((OriginalAttribute&(BIT4|BIT5|BIT6))>>4) - ) : - OriginalAttribute; - - gST->ConOut->SetAttribute (gST->ConOut, PrintAttribute); - } - Print (L"\t%d Warning(s)\n", mTableWarningCount); + if (mConfig.ReportType =3D=3D ReportSelected || + mConfig.ReportType =3D=3D ReportDumpBinFile) { + if (!mSelectedAcpiTable.Found) { + AcpiFatal (L"Requested ACPI Table not found."); + return EFI_SUCCESS; + } + } =20 - if (mConfig.ColourHighlighting) { - gST->ConOut->SetAttribute (gST->ConOut, OriginalAttribute); - } + if (mConfig.ConsistencyCheck) { + if (mConfig.ReportType =3D=3D ReportSelected || + mConfig.ReportType =3D=3D ReportAll) { + AcpiInfo (L"Table Statistics:"); + AcpiLog ( + mTableErrorCount ? ACPI_BAD : ACPI_GOOD, + L"\t%d Error(s)", + mTableErrorCount); + AcpiLog ( + mTableWarningCount ? ACPI_BAD : ACPI_GOOD, + L"\t%d Warning(s)\n", + mTableWarningCount); } } + return EFI_SUCCESS; } diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/FieldFormatHelper= .h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/FieldFormatHelper.h index 25c70652806c..b0072b68844c 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/FieldFormatHelper.h +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/FieldFormatHelper.h @@ -8,90 +8,10 @@ #ifndef FIELD_FORMAT_HELPER_H_ #define FIELD_FORMAT_HELPER_H_ =20 -#include -#include - -/** - This function traces 1 byte of data as specified in the format string. - - @param [in] Format The format string for tracing the data. - @param [in] Ptr Pointer to the start of the buffer. -**/ -static -inline -VOID -EFIAPI -DumpUint8 ( - IN CONST CHAR16* Format, - IN UINT8* Ptr - ) -{ - Print (Format, *Ptr); -} - -/** - This function traces 2 bytes of data as specified in the format string. - - @param [in] Format The format string for tracing the data. - @param [in] Ptr Pointer to the start of the buffer. -**/ -static -inline -VOID -EFIAPI -DumpUint16 ( - IN CONST CHAR16* Format, - IN UINT8* Ptr - ) -{ - Print (Format, *(UINT16*)Ptr); -} - -/** - This function traces 4 bytes of data as specified in the format string. - - @param [in] Format The format string for tracing the data. - @param [in] Ptr Pointer to the start of the buffer. -**/ -static -inline -VOID -EFIAPI -DumpUint32 ( - IN CONST CHAR16* Format, - IN UINT8* Ptr - ) -{ - Print (Format, *(UINT32*)Ptr); -} - -/** - This function traces 8 bytes of data as specified by the format string. +#define INLINE inline =20 - @param [in] Format The format string for tracing the data. - @param [in] Ptr Pointer to the start of the buffer. -**/ -static -inline -VOID -EFIAPI -DumpUint64 ( - IN CONST CHAR16* Format, - IN UINT8* Ptr - ) -{ - // Some fields are not aligned and this causes alignment faults - // on ARM platforms if the compiler generates LDRD instructions. - // Perform word access so that LDRD instructions are not generated. - UINT64 Val; - - Val =3D *(UINT32*)(Ptr + sizeof (UINT32)); - - Val =3D LShiftU64(Val,32); - Val |=3D (UINT64)*(UINT32*)Ptr; - - Print (Format, Val); -} +#include +#include "AcpiViewLog.h" =20 /** This function traces 3 characters which can be optionally @@ -111,8 +31,8 @@ Dump3Chars ( IN UINT8* Ptr ) { - Print ( - (Format !=3D NULL) ? Format : (CONST CHAR16*) L"%c%c%c", + AcpiInfo ( + (Format !=3D NULL) ? Format : L"%c%c%c", Ptr[0], Ptr[1], Ptr[2] @@ -137,8 +57,8 @@ Dump4Chars ( IN UINT8* Ptr ) { - Print ( - (Format !=3D NULL) ? Format : (CONST CHAR16*) L"%c%c%c%c", + AcpiInfo( + (Format !=3D NULL) ? Format : L"%c%c%c%c", Ptr[0], Ptr[1], Ptr[2], @@ -164,8 +84,8 @@ Dump6Chars ( IN UINT8* Ptr ) { - Print ( - (Format !=3D NULL) ? Format : (CONST CHAR16*) L"%c%c%c%c%c%c", + AcpiInfo( + (Format !=3D NULL) ? Format : L"%c%c%c%c%c%c", Ptr[0], Ptr[1], Ptr[2], @@ -193,8 +113,8 @@ Dump8Chars ( IN UINT8* Ptr ) { - Print ( - (Format !=3D NULL) ? Format : (CONST CHAR16*) L"%c%c%c%c%c%c%c%c", + AcpiInfo( + (Format !=3D NULL) ? Format : L"%c%c%c%c%c%c%c%c", Ptr[0], Ptr[1], Ptr[2], @@ -224,8 +144,8 @@ Dump12Chars ( IN UINT8* Ptr ) { - Print ( - (Format !=3D NULL) ? Format : (CONST CHAR16*) L"%c%c%c%c%c%c%c%c%c%c%c= %c", + AcpiInfo( + (Format !=3D NULL) ? Format : L"%c%c%c%c%c%c%c%c%c%c%c%c", Ptr[0], Ptr[1], Ptr[2], --=20 2.24.1.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#62381): https://edk2.groups.io/g/devel/message/62381 Mute This Topic: https://groups.io/mt/75454454/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri May 3 03:13:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62382+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1594549968692779.3357724035144; Sun, 12 Jul 2020 03:32:48 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id TR9cYY1788612xzyETZxO7ZL; Sun, 12 Jul 2020 03:32:48 -0700 X-Received: from EUR04-HE1-obe.outbound.protection.outlook.com (EUR04-HE1-obe.outbound.protection.outlook.com [40.107.7.52]) by mx.groups.io with SMTP id smtpd.web10.6638.1594549966921827238 for ; Sun, 12 Jul 2020 03:32:47 -0700 X-Received: from MR2P264CA0003.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:1::15) by AM5PR0801MB1745.eurprd08.prod.outlook.com (2603:10a6:203:3a::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.24; Sun, 12 Jul 2020 10:32:42 +0000 X-Received: from VE1EUR03FT020.eop-EUR03.prod.protection.outlook.com (2603:10a6:500:1:cafe::47) by MR2P264CA0003.outlook.office365.com (2603:10a6:500:1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20 via Frontend Transport; Sun, 12 Jul 2020 10:32:42 +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 (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+62382+1787277+3901457@groups.io; helo=web01.groups.io; 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; X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT020.mail.protection.outlook.com (10.152.18.242) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Sun, 12 Jul 2020 10:32:42 +0000 X-Received: ("Tessian outbound 1dc58800d5dd:v62"); Sun, 12 Jul 2020 10:32:41 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 7dffad7301a56769 X-CR-MTA-TID: 64aa7808 X-Received: from 0485141b5a04.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 21750FC6-4395-4AB8-BC6D-4FB03A818E33.1; Sun, 12 Jul 2020 10:32:36 +0000 X-Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 0485141b5a04.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Sun, 12 Jul 2020 10:32:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VlZmmozbJnRGBSD1ljrEfjqZHCergHaxeC5pTWrOCqy67OApxunOJE9SiPUd8UvdG8fJDT4Gc4t+tvWMBGtI+W7l2jZuOwmt4Rymc9whVY2ayOSNu7xmsLg4ukHsM9t9/wddw9q1YbHlY5hAGI10LzW88tSb9cub5Qy4P3+R3b1evUidGb1B2UGcmMOloS/yi6kSu/lzDmP4AXCt76td7HZ9V7y/MHeISV2Lt+OPpzLAhlR1QGdriRynkKOMiPBRh1vpk9khaFeeYouTKHjJEQ/rcQNr9kOoG8cZ+eG03kQ2ftaB8PWLnfdvzA0qxqijXeAOQE2nPhe+hk7hOWiVyQ== 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=Yk/kgkggUjBcxBoUTpE8hdeJJcbmBejhBmZNw/FJ0Ro=; b=LSfOeXR+w/+5FUwqrf/d6GL/6e6TEmgBsQwkdm94bfUVVVxo1Bpzqm+qPPOdq7wEPDT2kMbUspwKhz/G0W8Y+D5Ew++htUvI6sVpT7v+Jrhb7fAUOu9KgP5J6XlpQgOqLsrvKhV9S1IsBytDTtkqi1mQaEsEXR8sYEdaPRGKlrMRM2y/vYkhNVc/wLqMlOjruaHX7q4XHqJJ6sVLGZe2DT/tMP1n/TiEOaXz7/BFHmfkQoEql+Id4zY9fkZnfIqAxOq/ZLPNZ6LRhIknh4PafNGRvDhDjqPgsUxi6v29h1LDuHdGndJKFJgkwwgPBDSq1pwBAeg4rq2OWf//n8sM3w== 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 X-Received: from DBBPR09CA0012.eurprd09.prod.outlook.com (2603:10a6:10:c0::24) by DB7PR08MB3372.eurprd08.prod.outlook.com (2603:10a6:10:4f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.22; Sun, 12 Jul 2020 10:32:33 +0000 X-Received: from DB5EUR03FT008.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:c0:cafe::51) by DBBPR09CA0012.outlook.office365.com (2603:10a6:10:c0::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Sun, 12 Jul 2020 10:32:33 +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; X-Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT008.mail.protection.outlook.com (10.152.20.98) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3174.21 via Frontend Transport; Sun, 12 Jul 2020 10:32:33 +0000 X-Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1415.2; Sun, 12 Jul 2020 10:32:32 +0000 X-Received: from localhost.localdomain (10.57.55.192) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Sun, 12 Jul 2020 10:32:31 +0000 From: "Tomas Pilar (tpilar)" To: CC: , , Ray Ni , "Zhichao Gao" Subject: [edk2-devel] [PATCH v2 8/8] ShellPkg/AcpiView: Refactor table parsers Date: Sun, 12 Jul 2020 11:32:15 +0100 Message-ID: <20200712103215.855-9-Tomas.Pilar@arm.com> In-Reply-To: <20200712103215.855-1-Tomas.Pilar@arm.com> References: <20200712103215.855-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)(346002)(396003)(376002)(136003)(39850400004)(46966005)(70206006)(70586007)(316002)(6916009)(26005)(2906002)(36756003)(426003)(186003)(19627235002)(2616005)(336012)(6666004)(47076004)(82740400003)(8936002)(5660300002)(30864003)(8676002)(86362001)(81166007)(82310400002)(4326008)(83380400001)(478600001)(54906003)(1076003)(356005)(579004)(559001);DIR:OUT;SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 911ceaa2-add5-4d21-f83b-08d8264ee86b X-MS-TrafficTypeDiagnostic: DB7PR08MB3372:|AM5PR0801MB1745: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8882;OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: ML2wVozpdwiSe7ScSbcGf9Z6sfVwZvSwwS9eZ91VkcNFEnMiSvSw1+M6ZqmbnbTDoxlqB0GcDe9lRi1LaAmNFcv8VeGeo/4o9T4z0bm2y8+Ju0DzuvFfvYp9gkwnAuwnOjHFWW0RVwx7Cqj5gvfwMgpxrd2RCmsI3AJwYbwLqudZAUWTHV7glFYe+hZtmKpKHk8lZHFi1CQD4q6CMI/L2F5XlQ9Pgjo37VtvjD7/ilN1GFT4VrhQrzmEwhcih8V208eUh9ORthUAVapJhwzylYyQqAVfnOEG9Gib2PILf4C1dI8yV1ctZ62TSb8s86BZ9G50H2xQt8ASaPR4cqSG7J2TC+auZmSiyhJd66v2s6qEeVBGdw7YL0zwpzVyzAZKb2K9q7Cfq+eIkGSST49sjA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3372 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT020.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 80a32c6b-4d23-4b72-c620-08d8264ee31a X-Microsoft-Antispam-Message-Info: FRJLFOL4OGKl62N7/7JtVzu9X+VbN5QhfZcMaZz0D+h09HYjcm3zDRTu5CxB/xjtbmcJNe8gMHEGPAaRmSRUwTjaiwnltcmicLvyBJvLQhQljKJWM/rwY2m2/DvTmrKGgIlRKxxDHSEK1upNRmn7+eTKtDeIas4JfCloVl0I61gAqDdEtIhFvauqNF5W89dgIn4IwTc01U+QjLcTcLBonIf5N1SniyV7ZU0Io66WTQQdveyTQXn7fhc28PFQFEvDq92em6tinR1HecYaTkxaiqIlJwJyW2MHDPspV3rMvvFEXGbtg7YREmbvaT+0oLQCP1nwamsi4yg8cGTvK+1mPX/OZXEBVje59H8ep8IkwSL3d/L/qRUnsJgcwCNUqiPGGqJyipXPvwKrjxZrjbzQyA== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2020 10:32:42.0180 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 911ceaa2-add5-4d21-f83b-08d8264ee86b 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: VE1EUR03FT020.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1745 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,Tomas.Pilar@arm.com X-Gm-Message-State: 1kRUxIsUp1uqlPLxPAsuGRNLx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1594549968; bh=jfcu4KdMt/LWkOQ4UmLmg5ST1OMOH3hC86dJIv0fkoY=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=XTtxix8mYqyw4rPXR7vrUczwCA/mxcOnnwqqBTMRzvnOQLBJz4F+S/LrR0hHVc9YxKn v3VuCgFpdJqFyBa3FMiAb7OWENlE4+roFmUafuBjym87En1yDa7kmikjKKG9qWF9wkRIE hgPURSIBQq8b3Ausu2TSH8vLrC2jIvw6xyE= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" The tests for checking specific constraints and checking for buffer overflows have been simplified to use a standard set of templates defined in the logging facility. This regularises some of the error handling and makes it easier to write more tests like this in the future. Change-Id: Ica35c9ca1d9ef155927a4be3f16418f6755be8e6 Cc: Ray Ni Cc: Zhichao Gao Signed-off-by: Tomas Pilar --- .../UefiShellAcpiViewCommandLib/AcpiParser.c | 25 -- .../UefiShellAcpiViewCommandLib/AcpiParser.h | 18 -- .../Arm/SbbrValidator.c | 65 +++--- .../Parsers/Dbg2/Dbg2Parser.c | 118 +++------- .../Parsers/Fadt/FadtParser.c | 54 ++--- .../Parsers/Gtdt/GtdtParser.c | 80 ++----- .../Parsers/Iort/IortParser.c | 213 +++++++----------- .../Parsers/Madt/MadtParser.c | 101 +++------ .../Parsers/Mcfg/McfgParser.c | 11 +- .../Parsers/Pptt/PpttParser.c | 165 ++++---------- .../Parsers/Rsdp/RsdpParser.c | 38 +--- .../Parsers/Slit/SlitParser.c | 124 ++++------ .../Parsers/Spcr/SpcrParser.c | 23 +- .../Parsers/Srat/SratParser.c | 188 +++++----------- .../Parsers/Xsdt/XsdtParser.c | 96 ++------ 15 files changed, 398 insertions(+), 921 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c b/Sh= ellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c index 16b8d1f80bc2..1c8664910515 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c @@ -25,31 +25,6 @@ STATIC CONST ACPI_PARSER AcpiHeaderParser[] =3D { PARSE_ACPI_HEADER (&AcpiHdrInfo) }; =20 -/** - This function increments the ACPI table error counter. -**/ -VOID -EFIAPI -IncrementErrorCount ( - VOID - ) -{ - mTableErrorCount++; -} - -/** - This function increments the ACPI table warning counter. -**/ -VOID -EFIAPI -IncrementWarningCount ( - VOID - ) -{ - mTableWarningCount++; -} - - /** This function verifies the ACPI table checksum. =20 diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h b/Sh= ellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h index bd3cdb774fb5..cdae433fef3b 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h @@ -18,24 +18,6 @@ /// that allows us to process the log options. #define RSDP_TABLE_INFO SIGNATURE_32('R', 'S', 'D', 'P') =20 -/** - This function increments the ACPI table error counter. -**/ -VOID -EFIAPI -IncrementErrorCount ( - VOID - ); - -/** - This function increments the ACPI table warning counter. -**/ -VOID -EFIAPI -IncrementWarningCount ( - VOID - ); - /** This function verifies the ACPI table checksum. =20 diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator= .c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.c index d3284417fa5f..ba80a5ab3b40 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.c @@ -18,15 +18,16 @@ #include #include #include "AcpiParser.h" +#include "AcpiViewLog.h" #include "Arm/SbbrValidator.h" =20 /** SBBR specification version strings **/ -STATIC CONST CHAR8* ArmSbbrVersions[ArmSbbrVersionMax] =3D { - "1.0", // ArmSbbrVersion_1_0 - "1.1", // ArmSbbrVersion_1_1 - "1.2" // ArmSbbrVersion_1_2 +STATIC CONST CHAR16* ArmSbbrVersions[ArmSbbrVersionMax] =3D { + L"SBBR-v1.0", // ArmSbbrVersion_1_0 + L"SBBR-v1.1", // ArmSbbrVersion_1_1 + L"SBBR-v1.2" // ArmSbbrVersion_1_2 }; =20 /** @@ -96,6 +97,16 @@ STATIC ACPI_TABLE_COUNTER ArmSbbrTableCounts[] =3D { {EFI_ACPI_6_3_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_STRUCTURE_SIGNATURE, 0} }; =20 +STATIC_ASSERT ( + ARRAY_SIZE (ArmSbbr10Mandatory) <=3D ARRAY_SIZE (ArmSbbrTableCounts), + "Incompatible mandatory array tables"); +STATIC_ASSERT ( + ARRAY_SIZE (ArmSbbr11Mandatory) <=3D ARRAY_SIZE (ArmSbbrTableCounts), + "Incompatible mandatory array tables"); +STATIC_ASSERT ( + ARRAY_SIZE (ArmSbbr12Mandatory) <=3D ARRAY_SIZE (ArmSbbrTableCounts), + "Incompatible mandatory array tables"); + /** Reset the platform ACPI table instance count for all SBBR-mandatory tabl= es. **/ @@ -160,7 +171,6 @@ ArmSbbrReqsValidate ( UINT32 Table; UINT32 Index; UINT32 MandatoryTable; - CONST UINT8* SignaturePtr; BOOLEAN IsArmSbbrViolated; =20 if (Version >=3D ArmSbbrVersionMax) { @@ -172,51 +182,30 @@ ArmSbbrReqsValidate ( // Go through the list of mandatory tables for the input SBBR version for (Table =3D 0; Table < ArmSbbrReqs[Version].TableCount; Table++) { MandatoryTable =3D ArmSbbrReqs[Version].Tables[Table]; - SignaturePtr =3D (CONST UINT8*)(UINTN)&MandatoryTable; =20 // Locate the instance count for the table with the given signature - Index =3D 0; - while ((Index < ARRAY_SIZE (ArmSbbrTableCounts)) && - (ArmSbbrTableCounts[Index].Signature !=3D MandatoryTable)) { - Index++; - } - - if (Index >=3D ARRAY_SIZE (ArmSbbrTableCounts)) { - IncrementErrorCount (); - Print ( - L"\nERROR: SBBR v%a: Mandatory %c%c%c%c table's instance count not= " \ - L"found\n", - ArmSbbrVersions[Version], - SignaturePtr[0], - SignaturePtr[1], - SignaturePtr[2], - SignaturePtr[3] - ); - return EFI_UNSUPPORTED; + for (Index =3D 0; Index < ARRAY_SIZE (ArmSbbrTableCounts); Index++) { + if (ArmSbbrTableCounts[Index].Signature =3D=3D MandatoryTable) { + break; + } } =20 if (ArmSbbrTableCounts[Index].Count =3D=3D 0) { IsArmSbbrViolated =3D TRUE; - IncrementErrorCount (); - Print ( - L"\nERROR: SBBR v%a: Mandatory %c%c%c%c table is missing", + AcpiError ( + ACPI_ERROR_CROSS, + L"(%a) Mandatory %4a table is missing", ArmSbbrVersions[Version], - SignaturePtr[0], - SignaturePtr[1], - SignaturePtr[2], - SignaturePtr[3] - ); + MandatoryTable); } } =20 if (!IsArmSbbrViolated) { - Print ( - L"\nINFO: SBBR v%a: All mandatory ACPI tables are installed", - ArmSbbrVersions[Version] - ); + AcpiLog ( + ACPI_GOOD, + L"(%a): Mandatory ACPI tables present", + ArmSbbrVersions[Version]); } =20 - Print (L"\n"); - return IsArmSbbrViolated ? EFI_NOT_FOUND : EFI_SUCCESS; } diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Pa= rser.c index dd69ed6992ba..933ad92312e1 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c @@ -10,6 +10,7 @@ =20 #include #include +#include #include "AcpiParser.h" #include "AcpiTableParser.h" #include "AcpiViewLog.h" @@ -42,17 +43,10 @@ ValidateNameSpaceStrLen ( IN VOID* Context ) { - UINT16 NameSpaceStrLen; + UINT16 NameSpaceStrLen =3D *(UINT16 *) Ptr; =20 - NameSpaceStrLen =3D *(UINT16*)Ptr; - - if (NameSpaceStrLen < 2) { - IncrementErrorCount (); - Print ( - L"\nERROR: NamespaceString Length =3D %d. If no Namespace device exi= sts, " \ - L"NamespaceString[] must contain a period '.'", - NameSpaceStrLen - ); + if (AssertConstraint (L"ACPI", NameSpaceStrLen > 1)) { + AcpiInfo (L"With no namespace, NamespaceString[] must be a period '.'"= ); } } =20 @@ -133,76 +127,51 @@ DumpDbgDeviceInfo ( (OEMDataOffset =3D=3D NULL) || (BaseAddrRegOffset =3D=3D NULL) || (AddrSizeOffset =3D=3D NULL)) { - IncrementErrorCount (); - Print ( - L"ERROR: Insufficient Debug Device Information Structure length. " \ - L"Length =3D %d.\n", - Length - ); + AcpiError (ACPI_ERROR_PARSE, L"Failed to parse DbgDevInfo Structure"); return; } =20 // GAS - Index =3D 0; Offset =3D *BaseAddrRegOffset; - while ((Index++ < *GasCount) && - (Offset < Length)) { - PrintFieldName (4, L"BaseAddressRegister"); - Offset +=3D (UINT16)DumpGasStruct ( - Ptr + Offset, - 4, - Length - Offset - ); + for (Index =3D 0; Index < *GasCount; Index++) { + if (AssertMemberIntegrity (Offset, 1, Ptr, Length)) { + break; + } + + PrintFieldName (4, L"BaseAddressRegister[%d]", Index); + Offset +=3D (UINT16)DumpGasStruct (Ptr + Offset, 4, Length - Offset); } =20 // Make sure the array of address sizes corresponding to each GAS fit in= the // Debug Device Information structure - if ((*AddrSizeOffset + (*GasCount * sizeof (UINT32))) > Length) { - IncrementErrorCount (); - Print ( - L"ERROR: Invalid GAS count. GasCount =3D %d. RemainingBufferLength = =3D %d. " \ - L"Parsing of the Debug Device Information structure aborted.\n", - *GasCount, - Length - *AddrSizeOffset - ); + if (AssertMemberIntegrity ( + *AddrSizeOffset, *GasCount * sizeof (UINT32), Ptr, Length)) { return; } =20 // Address Size Index =3D 0; Offset =3D *AddrSizeOffset; - while ((Index++ < *GasCount) && - (Offset < Length)) { - PrintFieldName (4, L"Address Size"); - Print (L"0x%x\n", *((UINT32*)(Ptr + Offset))); + for (Index =3D 0; Index < *GasCount; Index++) { + if (AssertMemberIntegrity (Offset, 1, Ptr, Length)) { + break; + } + PrintFieldName (4, L"Address Size[%d]", Index); + AcpiInfo (L"0x%x", ReadUnaligned32 ((CONST UINT32 *)(Ptr + Offset))); Offset +=3D sizeof (UINT32); } =20 // NameSpace String - Index =3D 0; - Offset =3D *NameSpaceStringOffset; PrintFieldName (4, L"NameSpace String"); - while ((Index++ < *NameSpaceStringLength) && - (Offset < Length)) { - Print (L"%c", *(Ptr + Offset)); - Offset++; + if (!AssertMemberIntegrity ( + *NameSpaceStringOffset, *NameSpaceStringLength, Ptr, Length)) { + AcpiInfo (L"%-.*a", *NameSpaceStringLength - 1, Ptr + *NameSpaceString= Offset); } - Print (L"\n"); =20 // OEM Data if (*OEMDataOffset !=3D 0) { - Index =3D 0; - Offset =3D *OEMDataOffset; - PrintFieldName (4, L"OEM Data"); - while ((Index++ < *OEMDataLength) && - (Offset < Length)) { - Print (L"%x ", *(Ptr + Offset)); - if ((Index & 7) =3D=3D 0) { - Print (L"\n%-*s ", OUTPUT_FIELD_COLUMN_WIDTH, L""); - } - Offset++; - } - Print (L"\n"); + AcpiInfo (L"OEM Data"); + DumpRaw (Ptr + *OEMDataOffset, *OEMDataLength); } } =20 @@ -245,13 +214,8 @@ ParseAcpiDbg2 ( =20 // Check if the values used to control the parsing logic have been // successfully read. - if ((OffsetDbgDeviceInfo =3D=3D NULL) || - (NumberDbgDeviceInfo =3D=3D NULL)) { - IncrementErrorCount (); - Print ( - L"ERROR: Insufficient table length. AcpiTableLength =3D %d\n", - AcpiTableLength - ); + if ((OffsetDbgDeviceInfo =3D=3D NULL) || (NumberDbgDeviceInfo =3D=3D NUL= L)) { + AcpiError (ACPI_ERROR_PARSE, L"Failed to parse DbgDevInfo array"); return; } =20 @@ -259,7 +223,6 @@ ParseAcpiDbg2 ( Index =3D 0; =20 while (Index++ < *NumberDbgDeviceInfo) { - // Parse the Debug Device Information Structure header to obtain Length ParseAcpi ( FALSE, @@ -273,31 +236,20 @@ ParseAcpiDbg2 ( // Check if the values used to control the parsing logic have been // successfully read. if (DbgDevInfoLen =3D=3D NULL) { - IncrementErrorCount (); - Print ( - L"ERROR: Insufficient remaining table buffer length to read the " \ - L"Debug Device Information structure's 'Length' field. " \ - L"RemainingTableBufferLength =3D %d.\n", - AcpiTableLength - Offset - ); + AcpiError (ACPI_ERROR_PARSE, L"Failed to parse DbgDevInfoLen"); return; } =20 // Validate Debug Device Information Structure length - if ((*DbgDevInfoLen =3D=3D 0) || - ((Offset + (*DbgDevInfoLen)) > AcpiTableLength)) { - IncrementErrorCount (); - Print ( - L"ERROR: Invalid Debug Device Information Structure length. " \ - L"Length =3D %d. Offset =3D %d. AcpiTableLength =3D %d.\n", - *DbgDevInfoLen, - Offset, - AcpiTableLength - ); + if (AssertConstraint (L"ACPI", *DbgDevInfoLen > 0)) { + return; + } + + if (AssertMemberIntegrity (Offset, *DbgDevInfoLen, Ptr, AcpiTableLengt= h)) { return; } =20 - DumpDbgDeviceInfo (Ptr + Offset, (*DbgDevInfoLen)); - Offset +=3D (*DbgDevInfoLen); + DumpDbgDeviceInfo (Ptr + Offset, *DbgDevInfoLen); + Offset +=3D *DbgDevInfoLen; } } diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/Fadt= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtPa= rser.c index 4734864dfdcf..473495651370 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c @@ -69,12 +69,10 @@ ValidateFirmwareCtrl ( ) { #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) - if (*(UINT32*)Ptr !=3D 0) { - IncrementErrorCount (); - Print ( - L"\nERROR: Firmware Control must be zero for ARM platforms." - ); - } + UINT32 FirmwareControl; + + FirmwareControl =3D *(UINT32 *) Ptr; + AssertConstraint (L"ARM", FirmwareControl =3D=3D 0); #endif } =20 @@ -94,12 +92,10 @@ ValidateXFirmwareCtrl ( ) { #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) - if (*(UINT64*)Ptr !=3D 0) { - IncrementErrorCount (); - Print ( - L"\nERROR: X Firmware Control must be zero for ARM platforms." - ); - } + UINT32 XFirmwareControl; + + XFirmwareControl =3D *(UINT32 *) Ptr; + AssertConstraint (L"ARM", XFirmwareControl =3D=3D 0); #endif } =20 @@ -119,12 +115,10 @@ ValidateFlags ( ) { #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) - if (((*(UINT32*)Ptr) & HW_REDUCED_ACPI) =3D=3D 0) { - IncrementErrorCount (); - Print ( - L"\nERROR: HW_REDUCED_ACPI flag must be set for ARM platforms." - ); - } + UINT32 Flags; + + Flags =3D *(UINT32 *) Ptr; + AssertConstraint (L"ARM", Flags & HW_REDUCED_ACPI); #endif } =20 @@ -232,15 +226,13 @@ ParseAcpiFadt ( =20 if (Trace) { if (FadtMinorRevision !=3D NULL) { - Print (L"\nSummary:\n"); + AcpiInfo (L"Summary:"); PrintFieldName (2, L"FADT Version"); - Print (L"%d.%d\n", *AcpiHdrInfo.Revision, *FadtMinorRevision); + AcpiInfo (L"%d.%d", *AcpiHdrInfo.Revision, *FadtMinorRevision); } =20 - if (*GetAcpiXsdtHeaderInfo ()->OemTableId !=3D *AcpiHdrInfo.OemTableId= ) { - IncrementErrorCount (); - Print (L"ERROR: OEM Table Id does not match with RSDT/XSDT.\n"); - } + AssertConstraint ( + L"ACPI", *GetAcpiXsdtHeaderInfo ()->OemTableId =3D=3D *AcpiHdrInfo.O= emTableId); } =20 // If X_FIRMWARE_CTRL is not zero then use X_FIRMWARE_CTRL and ignore @@ -257,9 +249,9 @@ ParseAcpiFadt ( if ((Trace) && (Flags !=3D NULL) && ((*Flags & EFI_ACPI_6_3_HW_REDUCED_ACPI) !=3D EFI_ACPI_6_3_HW_REDU= CED_ACPI)) { - IncrementErrorCount (); - Print (L"ERROR: No FACS table found, " - L"both X_FIRMWARE_CTRL and FIRMWARE_CTRL are zero.\n"); + AcpiError ( + ACPI_ERROR_CROSS, + L"No FACS table found, X_FIRMWARE_CTRL and FIRMWARE_CTRL are zero"= ); } } =20 @@ -283,9 +275,7 @@ ParseAcpiFadt ( =20 Status =3D GetParser (FacsSignature, &FacsParserProc); if (EFI_ERROR (Status)) { - Print ( - L"ERROR: No registered parser found for FACS.\n" - ); + AcpiFatal (L"No registered parser found for FACS"); return; } =20 @@ -309,8 +299,8 @@ ParseAcpiFadt ( // The DSDT Table is mandatory for ARM systems // as the CPU information MUST be presented in // the DSDT. - IncrementErrorCount (); - Print (L"ERROR: Both X_DSDT and DSDT are invalid.\n"); + AcpiError ( + ACPI_ERROR_CROSS, L"(ARM) One of X_DSDT or DSDT must be valid!"); } #endif return; diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/Gtdt= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtPa= rser.c index d02fc4929d6f..3716a801cf6a 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c @@ -13,6 +13,7 @@ #include "AcpiParser.h" #include "AcpiTableParser.h" #include "AcpiViewConfig.h" +#include "AcpiViewLog.h" =20 // "The number of GT Block Timers must be less than or equal to 8" #define GT_BLOCK_TIMER_COUNT_MAX 8 @@ -44,15 +45,7 @@ ValidateGtBlockTimerCount ( UINT32 BlockTimerCount; =20 BlockTimerCount =3D *(UINT32*)Ptr; - - if (BlockTimerCount > GT_BLOCK_TIMER_COUNT_MAX) { - IncrementErrorCount (); - Print ( - L"\nERROR: Timer Count =3D %d. Max Timer Count is %d.", - BlockTimerCount, - GT_BLOCK_TIMER_COUNT_MAX - ); - } + AssertConstraint (L"ACPI", BlockTimerCount < GT_BLOCK_TIMER_COUNT_MAX); } =20 /** @@ -70,18 +63,10 @@ ValidateGtFrameNumber ( IN VOID* Context ) { - UINT8 FrameNumber; + UINT8 GTFrameNumber; =20 - FrameNumber =3D *(UINT8*)Ptr; - - if (FrameNumber >=3D GT_BLOCK_TIMER_COUNT_MAX) { - IncrementErrorCount (); - Print ( - L"\nERROR: GT Frame Number =3D %d. GT Frame Number must be in range = 0-%d.", - FrameNumber, - GT_BLOCK_TIMER_COUNT_MAX - 1 - ); - } + GTFrameNumber =3D *Ptr; + AssertConstraint (L"ACPI", GTFrameNumber < GT_BLOCK_TIMER_COUNT_MAX); } =20 /** @@ -194,11 +179,7 @@ DumpGTBlock ( // successfully read. if ((GtBlockTimerCount =3D=3D NULL) || (GtBlockTimerOffset =3D=3D NULL)) { - IncrementErrorCount (); - Print ( - L"ERROR: Insufficient GT Block Structure length. Length =3D %d.\n", - Length - ); + AcpiError (ACPI_ERROR_PARSE, L"Failed to parse GT Block Structure"); return; } =20 @@ -270,7 +251,6 @@ ParseAcpiGtdt ( { UINT32 Index; UINT32 Offset; - UINT8* TimerPtr; =20 if (!Trace) { return; @@ -287,17 +267,11 @@ ParseAcpiGtdt ( =20 // Check if the values used to control the parsing logic have been // successfully read. - if ((GtdtPlatformTimerCount =3D=3D NULL) || - (GtdtPlatformTimerOffset =3D=3D NULL)) { - IncrementErrorCount (); - Print ( - L"ERROR: Insufficient table length. AcpiTableLength =3D %d.\n", - AcpiTableLength - ); + if ((GtdtPlatformTimerCount =3D=3D NULL) || (GtdtPlatformTimerOffset =3D= =3D NULL)) { + AcpiError (ACPI_ERROR_PARSE, L"Corrupt Platform Timer Table"); return; } =20 - TimerPtr =3D Ptr + *GtdtPlatformTimerOffset; Offset =3D *GtdtPlatformTimerOffset; Index =3D 0; =20 @@ -310,55 +284,35 @@ ParseAcpiGtdt ( FALSE, 0, NULL, - TimerPtr, + Ptr + Offset, AcpiTableLength - Offset, PARSER_PARAMS (GtPlatformTimerHeaderParser) ); =20 // Check if the values used to control the parsing logic have been // successfully read. - if ((PlatformTimerType =3D=3D NULL) || - (PlatformTimerLength =3D=3D NULL)) { - IncrementErrorCount (); - Print ( - L"ERROR: Insufficient remaining table buffer length to read the " \ - L"Platform Timer Structure header. Length =3D %d.\n", - AcpiTableLength - Offset - ); + if ((PlatformTimerType =3D=3D NULL) || (PlatformTimerLength =3D=3D NUL= L)) { + AcpiError (ACPI_ERROR_PARSE, L"Corrupt Platform Timer Structure"); return; } =20 // Validate Platform Timer Structure length - if ((*PlatformTimerLength =3D=3D 0) || - ((Offset + (*PlatformTimerLength)) > AcpiTableLength)) { - IncrementErrorCount (); - Print ( - L"ERROR: Invalid Platform Timer Structure length. " \ - L"Length =3D %d. Offset =3D %d. AcpiTableLength =3D %d.\n", - *PlatformTimerLength, - Offset, - AcpiTableLength - ); + if (AssertMemberIntegrity(Offset, *PlatformTimerLength, Ptr, AcpiTable= Length)) { return; } =20 switch (*PlatformTimerType) { case EFI_ACPI_6_3_GTDT_GT_BLOCK: - DumpGTBlock (TimerPtr, *PlatformTimerLength); + DumpGTBlock (Ptr + Offset, *PlatformTimerLength); break; case EFI_ACPI_6_3_GTDT_SBSA_GENERIC_WATCHDOG: - DumpWatchdogTimer (TimerPtr, *PlatformTimerLength); + DumpWatchdogTimer (Ptr + Offset, *PlatformTimerLength); break; default: - IncrementErrorCount (); - Print ( - L"ERROR: Invalid Platform Timer Type =3D %d\n", - *PlatformTimerType - ); - break; - } // switch + AcpiError ( + ACPI_ERROR_VALUE, L"Platform Timer Type %d", *PlatformTimerType); + } =20 - TimerPtr +=3D *PlatformTimerLength; Offset +=3D *PlatformTimerLength; } // while } diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/Iort= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortPa= rser.c index 356f355939aa..f7e9aa775301 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "AcpiParser.h" #include "AcpiTableParser.h" #include "AcpiViewConfig.h" @@ -49,10 +50,10 @@ ValidateItsIdMappingCount ( IN VOID* Context ) { - if (*(UINT32*)Ptr !=3D 0) { - IncrementErrorCount (); - Print (L"\nERROR: IORT ID Mapping count must be zero."); - } + UINT32 ItsNodeIdMapping; + + ItsNodeIdMapping =3D *(UINT32 *) Ptr; + AssertConstraint (L"ACPI", ItsNodeIdMapping =3D=3D 0); } =20 /** @@ -71,10 +72,10 @@ ValidatePmcgIdMappingCount ( IN VOID* Context ) { - if (*(UINT32*)Ptr > 1) { - IncrementErrorCount (); - Print (L"\nERROR: IORT ID Mapping count must not be greater than 1."); - } + UINT32 PmcgNodeIdMapping; + + PmcgNodeIdMapping =3D *(UINT32 *) Ptr; + AssertConstraint (L"ACPI", PmcgNodeIdMapping <=3D 1); } =20 /** @@ -92,10 +93,10 @@ ValidateItsIdArrayReference ( IN VOID* Context ) { - if (*(UINT32*)Ptr !=3D 0) { - IncrementErrorCount (); - Print (L"\nERROR: IORT ID Mapping offset must be zero."); - } + UINT32 ItsNodeMappingArrayOffset; + + ItsNodeMappingArrayOffset =3D *(UINT32 *) Ptr; + AssertConstraint (L"ACPI", ItsNodeMappingArrayOffset =3D=3D 0); } =20 /** @@ -268,28 +269,21 @@ DumpIortNodeIdMappings ( { UINT32 Index; UINT32 Offset; - CHAR8 Buffer[40]; // Used for AsciiName param of ParseAcpi =20 - Index =3D 0; Offset =3D 0; + for (Index =3D 0; Index < MappingCount; Index++) { + if (AssertMemberIntegrity(Offset, 1, Ptr, Length)) { + return; + } =20 - while ((Index < MappingCount) && - (Offset < Length)) { - AsciiSPrint ( - Buffer, - sizeof (Buffer), - "ID Mapping [%d]", - Index - ); + AcpiLog (ACPI_ITEM, L" ID Mapping[%d] (+0x%x)", Index, Offset); Offset +=3D ParseAcpi ( - TRUE, - 4, - Buffer, - Ptr + Offset, - Length - Offset, - PARSER_PARAMS (IortNodeIdMappingParser) - ); - Index++; + TRUE, + 4, + NULL, + Ptr + Offset, + Length - Offset, + PARSER_PARAMS (IortNodeIdMappingParser)); } } =20 @@ -313,7 +307,6 @@ DumpIortNodeSmmuV1V2 ( { UINT32 Index; UINT32 Offset; - CHAR8 Buffer[50]; // Used for AsciiName param of ParseAcpi =20 ParseAcpi ( TRUE, @@ -330,56 +323,41 @@ DumpIortNodeSmmuV1V2 ( (InterruptContextOffset =3D=3D NULL) || (PmuInterruptCount =3D=3D NULL) || (PmuInterruptOffset =3D=3D NULL)) { - IncrementErrorCount (); - Print ( - L"ERROR: Insufficient SMMUv1/2 node length. Length =3D %d\n", - Length - ); + AcpiError (ACPI_ERROR_PARSE, L"Failed to parse the SMMUv1/2 node"); return; } =20 Offset =3D *InterruptContextOffset; - Index =3D 0; + for (Index =3D 0; Index < *InterruptContextCount; Index++) { + if (AssertMemberIntegrity(Offset, 1, Ptr, Length)) { + break; + } =20 - while ((Index < *InterruptContextCount) && - (Offset < Length)) { - AsciiSPrint ( - Buffer, - sizeof (Buffer), - "Context Interrupts Array [%d]", - Index - ); + AcpiLog ( + ACPI_ITEM, L" Context Interrupts Array[%d] (+0x%x)", Index, Offse= t); Offset +=3D ParseAcpi ( - TRUE, - 4, - Buffer, - Ptr + Offset, - Length - Offset, - PARSER_PARAMS (InterruptArrayParser) - ); - Index++; + TRUE, + 4, + NULL, + Ptr + Offset, + Length - Offset, + PARSER_PARAMS (InterruptArrayParser)); } =20 Offset =3D *PmuInterruptOffset; - Index =3D 0; + for(Index =3D 0; Index < *PmuInterruptCount; Index++) { + if (AssertMemberIntegrity(Offset, 1, Ptr, Length)){ + break; + } =20 - while ((Index < *PmuInterruptCount) && - (Offset < Length)) { - AsciiSPrint ( - Buffer, - sizeof (Buffer), - "PMU Interrupts Array [%d]", - Index - ); + AcpiLog (ACPI_ITEM, L" PMU Interrupts Array[%d] (+0x%x)", Index, Of= fset); Offset +=3D ParseAcpi ( - TRUE, - 4, - Buffer, - Ptr + Offset, - Length - Offset, - PARSER_PARAMS (InterruptArrayParser) - ); - Index++; + TRUE, + 4, + NULL, + Ptr + Offset, + Length - Offset, + PARSER_PARAMS (InterruptArrayParser)); } =20 DumpIortNodeIdMappings ( @@ -438,7 +416,6 @@ DumpIortNodeIts ( { UINT32 Offset; UINT32 Index; - CHAR8 Buffer[80]; // Used for AsciiName param of ParseAcpi =20 Offset =3D ParseAcpi ( TRUE, @@ -452,32 +429,26 @@ DumpIortNodeIts ( // Check if the values used to control the parsing logic have been // successfully read. if (ItsCount =3D=3D NULL) { - IncrementErrorCount (); - Print ( - L"ERROR: Insufficient ITS group length. Length =3D %d.\n", - Length - ); + AcpiError (ACPI_ERROR_PARSE, L"Failed to parse ITS node"); return; } =20 Index =3D 0; =20 - while ((Index < *ItsCount) && - (Offset < Length)) { - AsciiSPrint ( - Buffer, - sizeof (Buffer), - "GIC ITS Identifier Array [%d]", - Index - ); + for (Index =3D 0; Index < *ItsCount; Index++) { + if (AssertMemberIntegrity(Offset, 1, Ptr, Length)) { + return; + } + + AcpiLog ( + ACPI_ITEM, L" GIC ITS Identifier Array[%d] (+0x%x)", Index, Offse= t); Offset +=3D ParseAcpi ( - TRUE, - 4, - Buffer, - Ptr + Offset, - Length - Offset, - PARSER_PARAMS (ItsIdParser) - ); + TRUE, + 4, + NULL, + Ptr + Offset, + Length - Offset, + PARSER_PARAMS (ItsIdParser)); Index++; } =20 @@ -516,13 +487,10 @@ DumpIortNodeNamedComponent ( =20 // Estimate the Device Name length PrintFieldName (2, L"Device Object Name"); - - while ((*(Ptr + Offset) !=3D 0) && - (Offset < Length)) { - Print (L"%c", *(Ptr + Offset)); - Offset++; - } - Print (L"\n"); + AcpiInfo ( + L"%.*a", + AsciiStrnLenS ((CONST CHAR8 *)Ptr + Offset, Length - Offset), + Ptr + Offset); =20 DumpIortNodeIdMappings ( Ptr + MappingOffset, @@ -629,7 +597,6 @@ ParseAcpiIort ( { UINT32 Offset; UINT32 Index; - UINT8* NodePtr; =20 if (!Trace) { return; @@ -648,16 +615,11 @@ ParseAcpiIort ( // successfully read. if ((IortNodeCount =3D=3D NULL) || (IortNodeOffset =3D=3D NULL)) { - IncrementErrorCount (); - Print ( - L"ERROR: Insufficient table length. AcpiTableLength =3D %d.\n", - AcpiTableLength - ); + AcpiError (ACPI_ERROR_PARSE, L"Failed to parse IORT Node."); return; } =20 Offset =3D *IortNodeOffset; - NodePtr =3D Ptr + Offset; Index =3D 0; =20 // Parse the specified number of IORT nodes or the IORT table buffer len= gth. @@ -669,7 +631,7 @@ ParseAcpiIort ( FALSE, 0, "IORT Node Header", - NodePtr, + Ptr + Offset, AcpiTableLength - Offset, PARSER_PARAMS (IortNodeHeaderParser) ); @@ -680,42 +642,28 @@ ParseAcpiIort ( (IortNodeLength =3D=3D NULL) || (IortIdMappingCount =3D=3D NULL) || (IortIdMappingOffset =3D=3D NULL)) { - IncrementErrorCount (); - Print ( - L"ERROR: Insufficient remaining table buffer length to read the " \ - L"IORT node header. Length =3D %d.\n", - AcpiTableLength - Offset - ); + AcpiError (ACPI_ERROR_PARSE, L"Failed ot parse the IORT node header"= ); return; } =20 - // Validate IORT Node length - if ((*IortNodeLength =3D=3D 0) || - ((Offset + (*IortNodeLength)) > AcpiTableLength)) { - IncrementErrorCount (); - Print ( - L"ERROR: Invalid IORT Node length. " \ - L"Length =3D %d. Offset =3D %d. AcpiTableLength =3D %d.\n", - *IortNodeLength, - Offset, - AcpiTableLength - ); + // Protect against buffer overrun + if (AssertMemberIntegrity (Offset, *IortNodeLength, Ptr, AcpiTableLeng= th)) { return; } =20 PrintFieldName (2, L"* Node Offset *"); - Print (L"0x%x\n", Offset); + AcpiInfo (L"0x%x", Offset); =20 switch (*IortNodeType) { case EFI_ACPI_IORT_TYPE_ITS_GROUP: DumpIortNodeIts ( - NodePtr, + Ptr + Offset, *IortNodeLength ); break; case EFI_ACPI_IORT_TYPE_NAMED_COMP: DumpIortNodeNamedComponent ( - NodePtr, + Ptr + Offset, *IortNodeLength, *IortIdMappingCount, *IortIdMappingOffset @@ -723,7 +671,7 @@ ParseAcpiIort ( break; case EFI_ACPI_IORT_TYPE_ROOT_COMPLEX: DumpIortNodeRootComplex ( - NodePtr, + Ptr + Offset, *IortNodeLength, *IortIdMappingCount, *IortIdMappingOffset @@ -731,7 +679,7 @@ ParseAcpiIort ( break; case EFI_ACPI_IORT_TYPE_SMMUv1v2: DumpIortNodeSmmuV1V2 ( - NodePtr, + Ptr + Offset, *IortNodeLength, *IortIdMappingCount, *IortIdMappingOffset @@ -739,7 +687,7 @@ ParseAcpiIort ( break; case EFI_ACPI_IORT_TYPE_SMMUv3: DumpIortNodeSmmuV3 ( - NodePtr, + Ptr + Offset, *IortNodeLength, *IortIdMappingCount, *IortIdMappingOffset @@ -747,7 +695,7 @@ ParseAcpiIort ( break; case EFI_ACPI_IORT_TYPE_PMCG: DumpIortNodePmcg ( - NodePtr, + Ptr + Offset, *IortNodeLength, *IortIdMappingCount, *IortIdMappingOffset @@ -755,11 +703,10 @@ ParseAcpiIort ( break; =20 default: - IncrementErrorCount (); - Print (L"ERROR: Unsupported IORT Node type =3D %d\n", *IortNodeTyp= e); + AcpiError ( + ACPI_ERROR_VALUE, L"Unsupported IORT Node type =3D %d", *IortNod= eType); } // switch =20 - NodePtr +=3D (*IortNodeLength); Offset +=3D (*IortNodeLength); } // while } diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/Madt= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtPa= rser.c index 15aa2392b60c..69c1c6d752cb 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c @@ -17,6 +17,7 @@ #include "AcpiTableParser.h" #include "AcpiViewConfig.h" #include "MadtParser.h" +#include "AcpiViewLog.h" =20 // Local Variables STATIC CONST UINT8* MadtInterruptControllerType; @@ -38,12 +39,10 @@ ValidateGICDSystemVectorBase ( IN VOID* Context ) { - if (*(UINT32*)Ptr !=3D 0) { - IncrementErrorCount (); - Print ( - L"\nERROR: System Vector Base must be zero." - ); - } + UINT32 GicdSystemVectorBase; + + GicdSystemVectorBase =3D *(UINT32 *) Ptr; + AssertConstraint (L"ACPI", GicdSystemVectorBase =3D=3D 0); } =20 /** @@ -63,36 +62,20 @@ ValidateSpeOverflowInterrupt ( { UINT16 SpeOverflowInterrupt; =20 - SpeOverflowInterrupt =3D *(UINT16*)Ptr; + SpeOverflowInterrupt =3D *(UINT16 *) Ptr; =20 // SPE not supported by this processor if (SpeOverflowInterrupt =3D=3D 0) { return; } =20 - if ((SpeOverflowInterrupt < ARM_PPI_ID_MIN) || - ((SpeOverflowInterrupt > ARM_PPI_ID_MAX) && - (SpeOverflowInterrupt < ARM_PPI_ID_EXTENDED_MIN)) || - (SpeOverflowInterrupt > ARM_PPI_ID_EXTENDED_MAX)) { - IncrementErrorCount (); - Print ( - L"\nERROR: SPE Overflow Interrupt ID of %d is not in the allowed PPI= ID " - L"ranges of %d-%d or %d-%d (for GICv3.1 or later).", - SpeOverflowInterrupt, - ARM_PPI_ID_MIN, - ARM_PPI_ID_MAX, - ARM_PPI_ID_EXTENDED_MIN, - ARM_PPI_ID_EXTENDED_MAX - ); - } else if (SpeOverflowInterrupt !=3D ARM_PPI_ID_PMBIRQ) { - IncrementWarningCount(); - Print ( - L"\nWARNING: SPE Overflow Interrupt ID of %d is not compliant with S= BSA " - L"Level 3 PPI ID assignment: %d.", - SpeOverflowInterrupt, - ARM_PPI_ID_PMBIRQ - ); - } + AssertConstraint (L"ACPI", SpeOverflowInterrupt > ARM_PPI_ID_MIN); + AssertConstraint ( + L"ACPI", + (SpeOverflowInterrupt < ARM_PPI_ID_MAX) || + (SpeOverflowInterrupt > ARM_PPI_ID_EXTENDED_MIN)); + AssertConstraint (L"ACPI", SpeOverflowInterrupt < ARM_PPI_ID_EXTENDED_MA= X); + WarnConstraint (L"SBSA", SpeOverflowInterrupt =3D=3D ARM_PPI_ID_PMBIRQ); } =20 /** @@ -231,7 +214,6 @@ ParseAcpiMadt ( ) { UINT32 Offset; - UINT8* InterruptContollerPtr; UINT32 GICDCount; =20 GICDCount =3D 0; @@ -248,7 +230,6 @@ ParseAcpiMadt ( AcpiTableLength, PARSER_PARAMS (MadtParser) ); - InterruptContollerPtr =3D Ptr + Offset; =20 while (Offset < AcpiTableLength) { // Parse Interrupt Controller Structure to obtain Length. @@ -256,7 +237,7 @@ ParseAcpiMadt ( FALSE, 0, NULL, - InterruptContollerPtr, + Ptr + Offset, AcpiTableLength - Offset, PARSER_PARAMS (MadtInterruptControllerHeaderParser) ); @@ -265,26 +246,14 @@ ParseAcpiMadt ( // successfully read. if ((MadtInterruptControllerType =3D=3D NULL) || (MadtInterruptControllerLength =3D=3D NULL)) { - IncrementErrorCount (); - Print ( - L"ERROR: Insufficient remaining table buffer length to read the " \ - L"Interrupt Controller Structure header. Length =3D %d.\n", - AcpiTableLength - Offset - ); + AcpiError ( + ACPI_ERROR_PARSE, + L"Failed to read the Interrupt Controller Structure header"); return; } =20 - // Validate Interrupt Controller Structure length - if ((*MadtInterruptControllerLength =3D=3D 0) || - ((Offset + (*MadtInterruptControllerLength)) > AcpiTableLength)) { - IncrementErrorCount (); - Print ( - L"ERROR: Invalid Interrupt Controller Structure length. " \ - L"Length =3D %d. Offset =3D %d. AcpiTableLength =3D %d.\n", - *MadtInterruptControllerLength, - Offset, - AcpiTableLength - ); + if (AssertMemberIntegrity ( + Offset, *MadtInterruptControllerLength, Ptr, AcpiTableLength)) { return; } =20 @@ -294,7 +263,7 @@ ParseAcpiMadt ( TRUE, 2, "GICC", - InterruptContollerPtr, + Ptr + Offset, *MadtInterruptControllerLength, PARSER_PARAMS (GicCParser) ); @@ -303,18 +272,16 @@ ParseAcpiMadt ( =20 case EFI_ACPI_6_3_GICD: { if (++GICDCount > 1) { - IncrementErrorCount (); - Print ( - L"ERROR: Only one GICD must be present," - L" GICDCount =3D %d\n", - GICDCount - ); + AcpiError ( + ACPI_ERROR_CROSS, + L"Only one GICD must be present (now %d)", + GICDCount); } ParseAcpi ( TRUE, 2, "GICD", - InterruptContollerPtr, + Ptr + Offset, *MadtInterruptControllerLength, PARSER_PARAMS (GicDParser) ); @@ -326,7 +293,7 @@ ParseAcpiMadt ( TRUE, 2, "GIC MSI Frame", - InterruptContollerPtr, + Ptr + Offset, *MadtInterruptControllerLength, PARSER_PARAMS (GicMSIFrameParser) ); @@ -338,7 +305,7 @@ ParseAcpiMadt ( TRUE, 2, "GICR", - InterruptContollerPtr, + Ptr + Offset, *MadtInterruptControllerLength, PARSER_PARAMS (GicRParser) ); @@ -350,7 +317,7 @@ ParseAcpiMadt ( TRUE, 2, "GIC ITS", - InterruptContollerPtr, + Ptr + Offset, *MadtInterruptControllerLength, PARSER_PARAMS (GicITSParser) ); @@ -358,17 +325,13 @@ ParseAcpiMadt ( } =20 default: { - IncrementErrorCount (); - Print ( - L"ERROR: Unknown Interrupt Controller Structure," - L" Type =3D %d, Length =3D %d\n", - *MadtInterruptControllerType, - *MadtInterruptControllerLength - ); + AcpiError ( + ACPI_ERROR_VALUE, + L"Interrupt Controller Structure Type =3D %d", + *MadtInterruptControllerType); } } // switch =20 - InterruptContollerPtr +=3D *MadtInterruptControllerLength; Offset +=3D *MadtInterruptControllerLength; } // while } diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Mcfg/Mcfg= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Mcfg/McfgPa= rser.c index 9da4d60e8497..7a7eaa374acf 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Mcfg/McfgParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Mcfg/McfgParser.c @@ -12,6 +12,7 @@ #include #include "AcpiParser.h" #include "AcpiTableParser.h" +#include "AcpiViewLog.h" =20 // Local variables STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; @@ -57,8 +58,6 @@ ParseAcpiMcfg ( ) { UINT32 Offset; - UINT32 PciCfgOffset; - UINT8* PciCfgSpacePtr; =20 if (!Trace) { return; @@ -73,18 +72,14 @@ ParseAcpiMcfg ( PARSER_PARAMS (McfgParser) ); =20 - PciCfgSpacePtr =3D Ptr + Offset; - while (Offset < AcpiTableLength) { - PciCfgOffset =3D ParseAcpi ( + Offset +=3D ParseAcpi ( TRUE, 2, "PCI Configuration Space", - PciCfgSpacePtr, + Ptr + Offset, (AcpiTableLength - Offset), PARSER_PARAMS (PciCfgSpaceBaseAddrParser) ); - PciCfgSpacePtr +=3D PciCfgOffset; - Offset +=3D PciCfgOffset; } } diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/Pptt= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttPa= rser.c index 97a5203efb5f..719c9dce9d4f 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c @@ -14,6 +14,7 @@ #include "AcpiParser.h" #include "AcpiView.h" #include "AcpiViewConfig.h" +#include "AcpiViewLog.h" #include "PpttParser.h" #include "AcpiViewLog.h" =20 @@ -39,38 +40,21 @@ ValidateCacheNumberOfSets ( IN VOID* Context ) { - UINT32 NumberOfSets; - NumberOfSets =3D *(UINT32*)Ptr; + UINT32 CacheNumberOfSets; =20 - if (NumberOfSets =3D=3D 0) { - IncrementErrorCount (); - Print (L"\nERROR: Cache number of sets must be greater than 0"); - return; - } + CacheNumberOfSets =3D *(UINT32*) Ptr; + AssertConstraint (L"ACPI", CacheNumberOfSets !=3D 0); =20 #if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) - if (NumberOfSets > PPTT_ARM_CCIDX_CACHE_NUMBER_OF_SETS_MAX) { - IncrementErrorCount (); - Print ( - L"\nERROR: When ARMv8.3-CCIDX is implemented the maximum cache numbe= r of " - L"sets must be less than or equal to %d", - PPTT_ARM_CCIDX_CACHE_NUMBER_OF_SETS_MAX - ); + if (AssertConstraint ( + L"ARMv8.3-CCIDX", + CacheNumberOfSets < PPTT_ARM_CCIDX_CACHE_NUMBER_OF_SETS_MAX)) { return; } =20 - if (NumberOfSets > PPTT_ARM_CACHE_NUMBER_OF_SETS_MAX) { - IncrementWarningCount (); - Print ( - L"\nWARNING: Without ARMv8.3-CCIDX, the maximum cache number of sets= " - L"must be less than or equal to %d. Ignore this message if " - L"ARMv8.3-CCIDX is implemented", - PPTT_ARM_CACHE_NUMBER_OF_SETS_MAX - ); - return; - } + WarnConstraint ( + L"No-ARMv8.3-CCIDX", CacheNumberOfSets < PPTT_ARM_CACHE_NUMBER_OF_SETS= _MAX); #endif - } =20 /** @@ -89,14 +73,10 @@ ValidateCacheAssociativity ( IN VOID* Context ) { - UINT8 Associativity; - Associativity =3D *(UINT8*)Ptr; + UINT8 CacheAssociativity; =20 - if (Associativity =3D=3D 0) { - IncrementErrorCount (); - Print (L"\nERROR: Cache associativity must be greater than 0"); - return; - } + CacheAssociativity =3D *Ptr; + AssertConstraint (L"ACPI", CacheAssociativity !=3D 0); } =20 /** @@ -120,25 +100,15 @@ ValidateCacheLineSize ( // LineSize, bits [2:0] // (Log2(Number of bytes in cache line)) - 4. =20 - UINT16 LineSize; - LineSize =3D *(UINT16*)Ptr; - - if ((LineSize < PPTT_ARM_CACHE_LINE_SIZE_MIN) || - (LineSize > PPTT_ARM_CACHE_LINE_SIZE_MAX)) { - IncrementErrorCount (); - Print ( - L"\nERROR: The cache line size must be between %d and %d bytes" - L" on ARM Platforms.", - PPTT_ARM_CACHE_LINE_SIZE_MIN, - PPTT_ARM_CACHE_LINE_SIZE_MAX - ); - return; - } + UINT16 CacheLineSize; =20 - if ((LineSize & (LineSize - 1)) !=3D 0) { - IncrementErrorCount (); - Print (L"\nERROR: The cache line size is not a power of 2."); - } + CacheLineSize =3D *(UINT16 *) Ptr; + AssertConstraint ( + L"ARM", + (CacheLineSize >=3D PPTT_ARM_CACHE_LINE_SIZE_MIN && + CacheLineSize <=3D PPTT_ARM_CACHE_LINE_SIZE_MAX)); + + AssertConstraint (L"ARM", BitFieldCountOnes32 (CacheLineSize, 0, 15) =3D= =3D 1); #endif } =20 @@ -161,16 +131,9 @@ ValidateCacheAttributes ( // Version 6.2 Errata A, September 2017 // Table 5-153: Cache Type Structure UINT8 Attributes; - Attributes =3D *(UINT8*)Ptr; =20 - if ((Attributes & 0xE0) !=3D 0) { - IncrementErrorCount (); - Print ( - L"\nERROR: Attributes bits [7:5] are reserved and must be zero.", - Attributes - ); - return; - } + Attributes =3D *(UINT8 *) Ptr; + AssertConstraint (L"ACPI", BitFieldCountOnes32 (Attributes, 5, 7) =3D=3D= 0); } =20 /** @@ -255,7 +218,6 @@ DumpProcessorHierarchyNodeStructure ( { UINT32 Offset; UINT32 Index; - CHAR16 Buffer[OUTPUT_FIELD_COLUMN_WIDTH]; =20 Offset =3D ParseAcpi ( TRUE, @@ -268,48 +230,22 @@ DumpProcessorHierarchyNodeStructure ( =20 // Check if the values used to control the parsing logic have been // successfully read. - if (NumberOfPrivateResources =3D=3D NULL) { - IncrementErrorCount (); - Print ( - L"ERROR: Insufficient Processor Hierarchy Node length. Length =3D %d= .\n", - Length - ); - return; - } - - // Make sure the Private Resource array lies inside this structure - if (Offset + (*NumberOfPrivateResources * sizeof (UINT32)) > Length) { - IncrementErrorCount (); - Print ( - L"ERROR: Invalid Number of Private Resources. " \ - L"PrivateResourceCount =3D %d. RemainingBufferLength =3D %d. " \ - L"Parsing of this structure aborted.\n", - *NumberOfPrivateResources, - Length - Offset - ); + if(NumberOfPrivateResources =3D=3D NULL) { + AcpiError (ACPI_ERROR_PARSE, L"Failed to parse processor hierarchy"); return; } =20 - Index =3D 0; - // Parse the specified number of private resource references or the Proc= essor // Hierarchy Node length. Whichever is minimum. - while (Index < *NumberOfPrivateResources) { - UnicodeSPrint ( - Buffer, - sizeof (Buffer), - L"Private resources [%d]", - Index - ); + for (Index =3D 0; Index < *NumberOfPrivateResources; Index++) { + if (AssertMemberIntegrity (Offset, sizeof (UINT32), Ptr, Length)) { + return; + } =20 - PrintFieldName (4, Buffer); - Print ( - L"0x%x\n", - *((UINT32*)(Ptr + Offset)) - ); + PrintFieldName (4, L"Private resources [%d]", Index); + AcpiInfo (L"0x%x", *(UINT32 *) (Ptr + Offset)); =20 Offset +=3D sizeof (UINT32); - Index++; } } =20 @@ -386,7 +322,6 @@ ParseAcpiPptt ( ) { UINT32 Offset; - UINT8* ProcessorTopologyStructurePtr; =20 if (!Trace) { return; @@ -401,15 +336,13 @@ ParseAcpiPptt ( PARSER_PARAMS (PpttParser) ); =20 - ProcessorTopologyStructurePtr =3D Ptr + Offset; - while (Offset < AcpiTableLength) { // Parse Processor Hierarchy Node Structure to obtain Type and Length. ParseAcpi ( FALSE, 0, NULL, - ProcessorTopologyStructurePtr, + Ptr + Offset, AcpiTableLength - Offset, PARSER_PARAMS (ProcessorTopologyStructureHeaderParser) ); @@ -418,62 +351,42 @@ ParseAcpiPptt ( // successfully read. if ((ProcessorTopologyStructureType =3D=3D NULL) || (ProcessorTopologyStructureLength =3D=3D NULL)) { - IncrementErrorCount (); - Print ( - L"ERROR: Insufficient remaining table buffer length to read the " \ - L"processor topology structure header. Length =3D %d.\n", - AcpiTableLength - Offset - ); + AcpiError (ACPI_ERROR_PARSE, L"Failed to parse processor topology"); return; } =20 // Validate Processor Topology Structure length - if ((*ProcessorTopologyStructureLength =3D=3D 0) || - ((Offset + (*ProcessorTopologyStructureLength)) > AcpiTableLength)= ) { - IncrementErrorCount (); - Print ( - L"ERROR: Invalid Processor Topology Structure length. " \ - L"Length =3D %d. Offset =3D %d. AcpiTableLength =3D %d.\n", - *ProcessorTopologyStructureLength, - Offset, - AcpiTableLength - ); + if (AssertMemberIntegrity ( + Offset, *ProcessorTopologyStructureLength, Ptr, AcpiTableLength)= ) { return; } =20 PrintFieldName (2, L"* Structure Offset *"); - Print (L"0x%x\n", Offset); + AcpiInfo (L"0x%x", Offset); =20 switch (*ProcessorTopologyStructureType) { case EFI_ACPI_6_2_PPTT_TYPE_PROCESSOR: DumpProcessorHierarchyNodeStructure ( - ProcessorTopologyStructurePtr, + Ptr + Offset, *ProcessorTopologyStructureLength ); break; case EFI_ACPI_6_2_PPTT_TYPE_CACHE: DumpCacheTypeStructure ( - ProcessorTopologyStructurePtr, + Ptr + Offset, *ProcessorTopologyStructureLength ); break; case EFI_ACPI_6_2_PPTT_TYPE_ID: DumpIDStructure ( - ProcessorTopologyStructurePtr, + Ptr + Offset, *ProcessorTopologyStructureLength ); break; default: - IncrementErrorCount (); - Print ( - L"ERROR: Unknown processor topology structure:" - L" Type =3D %d, Length =3D %d\n", - *ProcessorTopologyStructureType, - *ProcessorTopologyStructureLength - ); + AcpiError (ACPI_ERROR_VALUE, L"Unknown processor topology structur= e"); } =20 - ProcessorTopologyStructurePtr +=3D *ProcessorTopologyStructureLength; Offset +=3D *ProcessorTopologyStructureLength; } // while } diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/Rsdp= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpPa= rser.c index f4a8732a7db7..16dbab118795 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c @@ -11,6 +11,7 @@ #include #include "AcpiParser.h" #include "AcpiTableParser.h" +#include "AcpiViewLog.h" =20 // Local Variables STATIC CONST UINT64* XsdtAddress; @@ -38,15 +39,8 @@ ValidateRsdtAddress ( // XsdtAddresss MUST be a valid, non-null, 64-bit value. UINT32 RsdtAddr; =20 - RsdtAddr =3D *(UINT32*)Ptr; - - if (RsdtAddr !=3D 0) { - IncrementErrorCount (); - Print ( - L"\nERROR: Rsdt Address =3D 0x%p. This must be NULL on ARM Platforms= .", - RsdtAddr - ); - } + RsdtAddr =3D *(UINT32 *) Ptr; + AssertConstraint (L"ARM", RsdtAddr =3D=3D 0); #endif } =20 @@ -73,15 +67,8 @@ ValidateXsdtAddress ( // XsdtAddresss MUST be a valid, non-null, 64-bit value. UINT64 XsdtAddr; =20 - XsdtAddr =3D *(UINT64*)Ptr; - - if (XsdtAddr =3D=3D 0) { - IncrementErrorCount (); - Print ( - L"\nERROR: Xsdt Address =3D 0x%p. This must not be NULL on ARM Platf= orms.", - XsdtAddr - ); - } + XsdtAddr =3D *(UINT64 *) Ptr; + AssertConstraint (L"ARM", XsdtAddr !=3D 0); #endif } =20 @@ -141,12 +128,7 @@ ParseAcpiRsdp ( // Check if the values used to control the parsing logic have been // successfully read. if (XsdtAddress =3D=3D NULL) { - IncrementErrorCount (); - Print ( - L"ERROR: Insufficient table length. AcpiTableLength =3D %d." \ - L"RSDP parsing aborted.\n", - AcpiTableLength - ); + AcpiError (ACPI_ERROR_PARSE, L"Failed to parse the RSDP table"); return; } =20 @@ -154,11 +136,11 @@ ParseAcpiRsdp ( // and does not parse the RSDT table. Platforms provide the // RSDT to enable compatibility with ACPI 1.0 operating systems. // Therefore the RSDT should not be used on ARM platforms. - if ((*XsdtAddress) =3D=3D 0) { - IncrementErrorCount (); - Print (L"ERROR: XSDT Pointer is not set. RSDP parsing aborted.\n"); + if (*XsdtAddress =3D=3D 0) { + AcpiError ( + ACPI_ERROR_VALUE, L"XSDT Pointer is not set. RSDP parsing aborted."); return; } =20 - ProcessAcpiTable ((UINT8*)(UINTN)(*XsdtAddress)); + ProcessAcpiTable ((VOID *)(UINTN) *XsdtAddress); } diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/Slit= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitPa= rser.c index cedfc8a71849..5f3207f5827c 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c @@ -29,9 +29,11 @@ STATIC CONST ACPI_PARSER SlitParser[] =3D { }; =20 /** - Macro to get the value of a System Locality + Macro to get the value of a System Locality, simple + 2D variable size array item retrieval **/ -#define SLIT_ELEMENT(Ptr, i, j) *(Ptr + (i * LocalityCount) + j) +#define SLIT_ELEMENT(ArrayPtr, RowSize, Row, Column) \ + *((ArrayPtr) + ((Row) * (RowSize)) + (Column)) =20 /** This function parses the ACPI SLIT table. @@ -58,11 +60,11 @@ ParseAcpiSlit ( ) { UINT32 Offset; - UINT32 Count; - UINT32 Index; + UINT32 Index1; + UINT32 Index2; UINT32 LocalityCount; - UINT8* LocalityPtr; - CHAR16 Buffer[80]; // Used for AsciiName param of ParseAcpi + CHAR16 Buffer[256]; + UINTN StrLen; =20 if (!Trace) { return; @@ -80,11 +82,7 @@ ParseAcpiSlit ( // Check if the values used to control the parsing logic have been // successfully read. if (SlitSystemLocalityCount =3D=3D NULL) { - IncrementErrorCount (); - Print ( - L"ERROR: Insufficient table length. AcpiTableLength =3D %d.\n", - AcpiTableLength - ); + AcpiError (ACPI_ERROR_PARSE, L"Failed to parse the SLIT table"); return; } =20 @@ -100,89 +98,65 @@ ParseAcpiSlit ( =3D 65535 =3D MAX_UINT16 */ - if (*SlitSystemLocalityCount > MAX_UINT16) { - IncrementErrorCount (); - Print ( - L"ERROR: The Number of System Localities provided can't be represent= ed " \ - L"in the SLIT table. SlitSystemLocalityCount =3D %ld. " \ - L"MaxLocalityCountAllowed =3D %d.\n", - *SlitSystemLocalityCount, - MAX_UINT16 - ); + if (AssertConstraint (L"ACPI", *SlitSystemLocalityCount <=3D MAX_UINT16)= ) { return; } =20 - LocalityCount =3D (UINT32)*SlitSystemLocalityCount; + LocalityCount =3D (UINT32) *SlitSystemLocalityCount; =20 // Make sure system localities fit in the table buffer provided - if (Offset + (LocalityCount * LocalityCount) > AcpiTableLength) { - IncrementErrorCount (); - Print ( - L"ERROR: Invalid Number of System Localities. " \ - L"SlitSystemLocalityCount =3D %ld. AcpiTableLength =3D %d.\n", - *SlitSystemLocalityCount, - AcpiTableLength - ); + if (AssertMemberIntegrity ( + Offset, (LocalityCount * LocalityCount), Ptr, AcpiTableLength)) { return; } =20 - LocalityPtr =3D Ptr + Offset; - // We only print the Localities if the count is less than 16 // If the locality count is more than 16 then refer to the // raw data dump. if (LocalityCount < 16) { - UnicodeSPrint ( - Buffer, - sizeof (Buffer), - L"Entry[0x%lx][0x%lx]", - LocalityCount, - LocalityCount - ); - PrintFieldName (0, Buffer); - Print (L"\n"); - Print (L" "); - for (Index =3D 0; Index < LocalityCount; Index++) { - Print (L" (%3d) ", Index); + PrintFieldName (0, L"Entry[0x%lx][0x%lx]", LocalityCount, LocalityCoun= t); + AcpiInfo (L""); + UnicodeSPrint (Buffer, sizeof (Buffer), L" "); + for (Index1 =3D 0; Index1 < LocalityCount; Index1++) { + StrLen =3D StrnLenS (Buffer, sizeof (Buffer)); + UnicodeSPrint ( + Buffer + StrLen, sizeof (Buffer) - StrLen, L" (%3d) ", Index1); } - Print (L"\n"); - for (Count =3D 0; Count< LocalityCount; Count++) { - Print (L" (%3d) ", Count); - for (Index =3D 0; Index < LocalityCount; Index++) { - Print (L" %3d ", SLIT_ELEMENT (LocalityPtr, Count, Index)); + AcpiInfo (L"%s", Buffer); + + for (Index1 =3D 0; Index1 < LocalityCount; Index1++) { + UnicodeSPrint (Buffer, sizeof (Buffer), L" (%3d) ", Index1); + for (Index2 =3D 0; Index2 < LocalityCount; Index2++) { + StrLen =3D StrnLenS (Buffer, sizeof (Buffer)); + UnicodeSPrint ( + Buffer + StrLen, + sizeof (Buffer) - StrLen, + L" %3d ", + SLIT_ELEMENT(Ptr + Offset, LocalityCount, Index1, Index2)); } - Print (L"\n"); + AcpiInfo (L"%s", Buffer); } } =20 // Validate - for (Count =3D 0; Count < LocalityCount; Count++) { - for (Index =3D 0; Index < LocalityCount; Index++) { - // Element[x][x] must be equal to 10 - if ((Count =3D=3D Index) && (SLIT_ELEMENT (LocalityPtr, Count,Index)= !=3D 10)) { - IncrementErrorCount (); - Print ( - L"ERROR: Diagonal Element[0x%lx][0x%lx] (%3d)." - L" Normalized Value is not 10\n", - Count, - Index, - SLIT_ELEMENT (LocalityPtr, Count, Index) - ); - } + for (Index1 =3D 0; Index1 < LocalityCount; Index1++) { + // Element[x][x] must be equal to 10 + if (SLIT_ELEMENT(Ptr + Offset, LocalityCount, Index1, Index1) !=3D 10)= { + AcpiError ( + ACPI_ERROR_VALUE, L"SLIT Element[%d][%d] !=3D 10", Index1, Index1); + } + for (Index2 =3D 0; Index2 < Index1; Index2++) { // Element[i][j] must be equal to Element[j][i] - if (SLIT_ELEMENT (LocalityPtr, Count, Index) !=3D - SLIT_ELEMENT (LocalityPtr, Index, Count)) { - IncrementErrorCount (); - Print ( - L"ERROR: Relative distances for Element[0x%lx][0x%lx] (%3d) and = \n" - L"Element[0x%lx][0x%lx] (%3d) do not match.\n", - Count, - Index, - SLIT_ELEMENT (LocalityPtr, Count, Index), - Index, - Count, - SLIT_ELEMENT (LocalityPtr, Index, Count) - ); + if ( + SLIT_ELEMENT(Ptr + Offset, LocalityCount, Index1, Index2) !=3D + SLIT_ELEMENT(Ptr + Offset, LocalityCount, Index2, Index1)) { + AcpiError ( + ACPI_ERROR_VALUE, + L"SLIT Element[%d][%d] !=3D SLIT Element[%d][%d]", + Index1, + Index2, + Index2, + Index1); } } } diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Spcr/Spcr= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Spcr/SpcrPa= rser.c index 3b06b05dee8c..fa611d4b37c2 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Spcr/SpcrParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Spcr/SpcrParser.c @@ -14,6 +14,7 @@ #include #include "AcpiParser.h" #include "AcpiTableParser.h" +#include "AcpiViewLog.h" =20 // Local variables STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; @@ -37,15 +38,10 @@ ValidateInterruptType ( UINT8 InterruptType; =20 InterruptType =3D *Ptr; - - if (InterruptType !=3D - EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERRUPT_TYPE_GIC)= { - IncrementErrorCount (); - Print ( - L"\nERROR: InterruptType =3D %d. This must be 8 on ARM Platforms", - InterruptType - ); - } + AssertConstraint ( + L"ARM", + InterruptType =3D=3D + EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERRUPT_TYPE_GIC); #endif } =20 @@ -68,14 +64,7 @@ ValidateIrq ( UINT8 Irq; =20 Irq =3D *Ptr; - - if (Irq !=3D 0) { - IncrementErrorCount (); - Print ( - L"\nERROR: Irq =3D %d. This must be zero on ARM Platforms\n", - Irq - ); - } + AssertConstraint (L"ARM", Irq =3D=3D 0); #endif } =20 diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/Srat= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratPa= rser.c index 568a0400bf07..1954b18298b9 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c @@ -37,10 +37,10 @@ ValidateSratReserved ( IN VOID* Context ) { - if (*(UINT32*)Ptr !=3D 1) { - IncrementErrorCount (); - Print (L"\nERROR: Reserved should be 1 for backward compatibility.\n"); - } + UINT32 Reserved; + + Reserved =3D *(UINT32 *) Ptr; + AssertConstraint (L"Backwards-Compatibility", Reserved =3D=3D 1); } =20 /** @@ -59,18 +59,10 @@ ValidateSratDeviceHandleType ( IN VOID* Context ) { - UINT8 DeviceHandleType; + UINT8 DeviceHandleType; =20 DeviceHandleType =3D *Ptr; - - if (DeviceHandleType > EFI_ACPI_6_3_PCI_DEVICE_HANDLE) { - IncrementErrorCount (); - Print ( - L"\nERROR: Invalid Device Handle Type: %d. Must be between 0 and %d.= ", - DeviceHandleType, - EFI_ACPI_6_3_PCI_DEVICE_HANDLE - ); - } + AssertConstraint (L"ACPI", DeviceHandleType < EFI_ACPI_6_3_PCI_DEVICE_HA= NDLE); } =20 /** @@ -87,9 +79,9 @@ DumpSratPciBdfNumber ( IN UINT8* Ptr ) { - CHAR16 Buffer[OUTPUT_FIELD_COLUMN_WIDTH]; - - Print (L"\n"); + UINT16 Bus; + UINT16 Device; + UINT16 Function; =20 /* The PCI BDF Number subfields are printed in the order specified in the= ACPI @@ -102,43 +94,13 @@ DumpSratPciBdfNumber ( +-----+------+------+ */ =20 + Bus =3D BitFieldRead16(*(UINT16 *) Ptr, 0, 7); + Device =3D BitFieldRead16(*(UINT16 *) Ptr, 8, 10); + Function =3D BitFieldRead16(*(UINT16 *) Ptr, 11, 15); + // Print PCI Bus Number (Bits 7:0 of Byte 2) - UnicodeSPrint ( - Buffer, - sizeof (Buffer), - L"PCI Bus Number" - ); - PrintFieldName (4, Buffer); - Print ( - L"0x%x\n", - *Ptr - ); - - Ptr++; - - // Print PCI Device Number (Bits 7:3 of Byte 3) - UnicodeSPrint ( - Buffer, - sizeof (Buffer), - L"PCI Device Number" - ); - PrintFieldName (4, Buffer); - Print ( - L"0x%x\n", - (*Ptr & (BIT7 | BIT6 | BIT5 | BIT4 | BIT3)) >> 3 - ); - - // PCI Function Number (Bits 2:0 of Byte 3) - UnicodeSPrint ( - Buffer, - sizeof (Buffer), - L"PCI Function Number" - ); - PrintFieldName (4, Buffer); - Print ( - L"0x%x\n", - *Ptr & (BIT2 | BIT1 | BIT0) - ); + PrintFieldName (4, L"PCI Bus:Device.Function"); + AcpiInfo (L"%4X:%2X.%d", Bus, Device, Function); } =20 /** @@ -176,8 +138,7 @@ DumpSratDeviceHandle ( ) { if (SratDeviceHandleType =3D=3D NULL) { - IncrementErrorCount (); - Print (L"\nERROR: Device Handle Type read incorrectly.\n"); + AcpiError (ACPI_ERROR_PARSE, L"Failed to parse Device Handle"); return; } =20 @@ -222,7 +183,7 @@ DumpSratApicProximity ( =20 ProximityDomain =3D Ptr[0] | (Ptr[1] << 8) | (Ptr[2] << 16); =20 - Print (Format, ProximityDomain); + AcpiInfo ((CHAR16 *)Format, ProximityDomain); } =20 /** @@ -360,7 +321,6 @@ ParseAcpiSrat ( ) { UINT32 Offset; - UINT8* ResourcePtr; UINT32 GicCAffinityIndex; UINT32 GicITSAffinityIndex; UINT32 GenericInitiatorAffinityIndex; @@ -389,155 +349,113 @@ ParseAcpiSrat ( PARSER_PARAMS (SratParser) ); =20 - ResourcePtr =3D Ptr + Offset; - while (Offset < AcpiTableLength) { ParseAcpi ( FALSE, 0, NULL, - ResourcePtr, + Ptr + Offset, AcpiTableLength - Offset, PARSER_PARAMS (SratResourceAllocationParser) ); =20 // Check if the values used to control the parsing logic have been // successfully read. - if ((SratRAType =3D=3D NULL) || - (SratRALength =3D=3D NULL)) { - IncrementErrorCount (); - Print ( - L"ERROR: Insufficient remaining table buffer length to read the " \ - L"Static Resource Allocation structure header. Length =3D %d.\n", - AcpiTableLength - Offset - ); + if ((SratRAType =3D=3D NULL) || (SratRALength =3D=3D NULL)) { + AcpiError (ACPI_ERROR_PARSE, L"Failed to parse SRAT header"); return; } =20 // Validate Static Resource Allocation Structure length - if ((*SratRALength =3D=3D 0) || - ((Offset + (*SratRALength)) > AcpiTableLength)) { - IncrementErrorCount (); - Print ( - L"ERROR: Invalid Static Resource Allocation Structure length. " \ - L"Length =3D %d. Offset =3D %d. AcpiTableLength =3D %d.\n", - *SratRALength, - Offset, - AcpiTableLength - ); + if (AssertMemberIntegrity(Offset, *SratRALength, Ptr, AcpiTableLength)= ) { return; } =20 switch (*SratRAType) { case EFI_ACPI_6_3_GICC_AFFINITY: - AsciiSPrint ( - Buffer, - sizeof (Buffer), - "GICC Affinity Structure [%d]", - GicCAffinityIndex++ - ); + AcpiLog ( + ACPI_ITEM, L"GICC Affinity Structure [%d]", GicCAffinityIndex++); ParseAcpi ( TRUE, 2, Buffer, - ResourcePtr, + Ptr + Offset, *SratRALength, - PARSER_PARAMS (SratGicCAffinityParser) - ); + PARSER_PARAMS (SratGicCAffinityParser)); break; =20 case EFI_ACPI_6_3_GIC_ITS_AFFINITY: - AsciiSPrint ( - Buffer, - sizeof (Buffer), - "GIC ITS Affinity Structure [%d]", - GicITSAffinityIndex++ - ); + AcpiLog ( + ACPI_ITEM, L"GIC ITS Affinity Structure [%d]", GicITSAffinityInd= ex++); ParseAcpi ( TRUE, 2, Buffer, - ResourcePtr, + Ptr + Offset, *SratRALength, - PARSER_PARAMS (SratGicITSAffinityParser) - ); + PARSER_PARAMS (SratGicITSAffinityParser)); break; =20 case EFI_ACPI_6_3_GENERIC_INITIATOR_AFFINITY: - AsciiSPrint ( - Buffer, - sizeof (Buffer), - "Generic Initiator Affinity Structure [%d]", - GenericInitiatorAffinityIndex++ - ); + AcpiLog ( + ACPI_ITEM, + L"Generic Initiator Affinity Structure [%d]", + GenericInitiatorAffinityIndex++); ParseAcpi ( TRUE, 2, Buffer, - ResourcePtr, + Ptr + Offset, *SratRALength, - PARSER_PARAMS (SratGenericInitiatorAffinityParser) - ); + PARSER_PARAMS (SratGenericInitiatorAffinityParser)); break; =20 case EFI_ACPI_6_3_MEMORY_AFFINITY: - AsciiSPrint ( - Buffer, - sizeof (Buffer), - "Memory Affinity Structure [%d]", - MemoryAffinityIndex++ - ); + AcpiLog ( + ACPI_ITEM, L"Memory Affinity Structure [%d]", MemoryAffinityInde= x++); ParseAcpi ( TRUE, 2, Buffer, - ResourcePtr, + Ptr + Offset, *SratRALength, - PARSER_PARAMS (SratMemAffinityParser) - ); + PARSER_PARAMS (SratMemAffinityParser)); break; =20 case EFI_ACPI_6_3_PROCESSOR_LOCAL_APIC_SAPIC_AFFINITY: - AsciiSPrint ( - Buffer, - sizeof (Buffer), - "APIC/SAPIC Affinity Structure [%d]", - ApicSapicAffinityIndex++ - ); + AcpiLog ( + ACPI_ITEM, + L"APIC/SAPIC Affinity Structure [%d]", + ApicSapicAffinityIndex++); ParseAcpi ( TRUE, 2, Buffer, - ResourcePtr, + Ptr + Offset, *SratRALength, - PARSER_PARAMS (SratApciSapicAffinityParser) - ); + PARSER_PARAMS (SratApciSapicAffinityParser)); break; =20 case EFI_ACPI_6_3_PROCESSOR_LOCAL_X2APIC_AFFINITY: - AsciiSPrint ( - Buffer, - sizeof (Buffer), - "X2APIC Affinity Structure [%d]", - X2ApicAffinityIndex++ - ); + AcpiLog ( + ACPI_ITEM, L"X2APIC Affinity Structure [%d]", X2ApicAffinityInde= x++); ParseAcpi ( TRUE, 2, Buffer, - ResourcePtr, + Ptr + Offset, *SratRALength, - PARSER_PARAMS (SratX2ApciAffinityParser) - ); + PARSER_PARAMS (SratX2ApciAffinityParser)); break; =20 default: - IncrementErrorCount (); - Print (L"ERROR: Unknown SRAT Affinity type =3D 0x%x\n", *SratRATyp= e); + AcpiError ( + ACPI_ERROR_VALUE, + L"Unknown SRAT Affinity type =3D 0x%x\n", + *SratRAType); break; } =20 - ResourcePtr +=3D (*SratRALength); Offset +=3D (*SratRALength); } } diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/Xsdt= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtPa= rser.c index 771c4f322b8e..77031183782d 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c @@ -29,9 +29,7 @@ STATIC CONST ACPI_PARSER XsdtParser[] =3D { **/ CONST ACPI_DESCRIPTION_HEADER_INFO * EFIAPI -GetAcpiXsdtHeaderInfo ( - VOID -) +GetAcpiXsdtHeaderInfo (VOID) { return &AcpiHdrInfo; } @@ -55,87 +53,43 @@ ParseAcpiXsdt ( IN UINT8 AcpiTableRevision ) { - UINT32 Offset; UINT32 TableOffset; - UINT64* TablePointer; + UINT64** TablePointer; UINTN EntryIndex; - CHAR16 Buffer[32]; =20 - Offset =3D ParseAcpi ( - Trace, - 0, - "XSDT", - Ptr, - AcpiTableLength, - PARSER_PARAMS (XsdtParser) - ); - - TableOffset =3D Offset; + TableOffset =3D ParseAcpi ( + Trace, 0, "XSDT", Ptr, AcpiTableLength, PARSER_PARAMS (XsdtParser)); =20 + EntryIndex =3D 0; if (Trace) { - EntryIndex =3D 0; - TablePointer =3D (UINT64*)(Ptr + TableOffset); - while (Offset < AcpiTableLength) { + for (TablePointer =3D (UINT64 **)(Ptr + TableOffset); + (UINT8 *) TablePointer < Ptr + AcpiTableLength; + TablePointer++) { + CONST UINT32* Signature; CONST UINT32* Length; CONST UINT8* Revision; =20 - if ((UINT64*)(UINTN)(*TablePointer) !=3D NULL) { - UINT8* SignaturePtr; - - ParseAcpiHeader ( - (UINT8*)(UINTN)(*TablePointer), - &Signature, - &Length, - &Revision - ); - - SignaturePtr =3D (UINT8*)Signature; - - UnicodeSPrint ( - Buffer, - sizeof (Buffer), - L"Entry[%d] - %c%c%c%c", - EntryIndex++, - SignaturePtr[0], - SignaturePtr[1], - SignaturePtr[2], - SignaturePtr[3] - ); + if (*TablePointer !=3D NULL) { + ParseAcpiHeader (*TablePointer, &Signature, &Length, &Revision); + PrintFieldName (2, L"Entry[%d] - %.4a", EntryIndex++, Signature); + AcpiInfo (L"0x%lx", *TablePointer); } else { - UnicodeSPrint ( - Buffer, - sizeof (Buffer), - L"Entry[%d]", - EntryIndex++ - ); - } - - PrintFieldName (2, Buffer); - Print (L"0x%lx\n", *TablePointer); - - // Validate the table pointers are not NULL - if ((UINT64*)(UINTN)(*TablePointer) =3D=3D NULL) { - IncrementErrorCount (); - Print ( - L"ERROR: Invalid table entry at 0x%lx, table address is 0x%lx\n", - TablePointer, - *TablePointer - ); + PrintFieldName (2, L"Entry[%d]", EntryIndex++); + AcpiInfo (L"NULL"); + AcpiError (ACPI_ERROR_VALUE, L"Invalid table entry"); } - Offset +=3D sizeof (UINT64); - TablePointer++; - } // while + } } =20 // Process the tables - Offset =3D TableOffset; - TablePointer =3D (UINT64*)(Ptr + TableOffset); - while (Offset < AcpiTableLength) { - if ((UINT64*)(UINTN)(*TablePointer) !=3D NULL) { - ProcessAcpiTable ((UINT8*)(UINTN)(*TablePointer)); + for (TablePointer =3D (UINT64 **)(Ptr + TableOffset); + (UINT8 *) TablePointer < Ptr + AcpiTableLength; + TablePointer++) { + + if (*TablePointer !=3D NULL) { + ProcessAcpiTable (*TablePointer); } - Offset +=3D sizeof (UINT64); - TablePointer++; - } // while + + } } --=20 2.24.1.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#62382): https://edk2.groups.io/g/devel/message/62382 Mute This Topic: https://groups.io/mt/75454456/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-