From nobody Mon Feb 9 16:32:50 2026 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-