From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (EUR04-VI1-obe.outbound.protection.outlook.com [40.107.8.41]) by mx.groups.io with SMTP id smtpd.web11.21344.1593444048803696610 for ; Mon, 29 Jun 2020 08:20:49 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=DgYF95JU; spf=pass (domain: arm.com, ip: 40.107.8.41, mailfrom: tomas.pilar@arm.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zjCR12XLrDbTrz7k+SmvR/sOZ2ZE+5YWiE19xK6Rlsw=; b=DgYF95JU+SnpCO+CX1Xv3qLxlKYV5VI83v+fzImRybYgNEWNBhiy9R1FbxgibZdAymVvdvEA1sd94ngQRYvTtiWR0pGX71PZkcnIvXjOTsYAeKDTI2roWhisWk7Pqp+p7rLycocBRire9Qy/2cf4zC5Z+PwbAawHq4YQaQuScdw= Received: from AM6PR10CA0070.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:80::47) by DB7PR08MB3899.eurprd08.prod.outlook.com (2603:10a6:10:7f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.21; Mon, 29 Jun 2020 15:20:44 +0000 Received: from AM5EUR03FT039.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:80:cafe::18) by AM6PR10CA0070.outlook.office365.com (2603:10a6:209:80::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.20 via Frontend Transport; Mon, 29 Jun 2020 15:20:44 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT039.mail.protection.outlook.com (10.152.17.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.20 via Frontend Transport; Mon, 29 Jun 2020 15:20:44 +0000 Received: ("Tessian outbound cea5956745d7:v60"); Mon, 29 Jun 2020 15:20:44 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 4fa805c0cb2dc487 X-CR-MTA-TID: 64aa7808 Received: from e754df136632.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 9B150B00-F1C2-431B-85E4-2815359F3FF8.1; Mon, 29 Jun 2020 15:20:39 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e754df136632.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 29 Jun 2020 15:20:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CiHPM1ogeVS+VgELuw24W9IQM/Cl8GCRp4FfTHBoSk80xqECsVReS4uXwvQE6SPjJnH+Cs7DDJfl+84XNSYwOpsXV7hu2f40et5ScJAQNmKk/r7dw0i9TDlfro2WfzMgIf1Ab8FGOV9GKqPsUnObTyOwpkhbMc5OLjXuV4tppt5g50yFsgTC2Ye2X4zLTd8g+m3AJ+9fmu02YeUUT2G3xO2VZrlp5s2177nY1fjay1s2Usowg7ESX0TtNuFMqCYfxZB/BvUe8do8CaDuAl/umQeMMxYpMHCiUrR6i85xP8eiNOm1aiqDpMmNw62u61YwViRRUK8o43OAPfTw6jWHdA== 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=zjCR12XLrDbTrz7k+SmvR/sOZ2ZE+5YWiE19xK6Rlsw=; b=kwsgfNfaWbE2jk+IGTpABQBrVIsD1ofc26vc/AGpbNnf3fGzCCdkHDA78KM6DBD25oepm8/2xtr4HOkWG0DU9r6GXrp5GGc19OSuF3yRptsk5eA5122Wi2Zpr41/FeAptkmoYbAIThFkfgTshLWShSmd0kOSz1n7o7G/vRLk6UmaxC6JKGPy4ftqIrxgJvin+U6m+gXkzbTDbwDNcTh0P2m1lbtJOT2BuLPaI0MhjXiAzKzZsgrvZuYxNZXYNKvugtAhwJFByeFHBQoLxa4RoVfzPVZhy4FJ/3emJh4mQJsIkxm7e1vha9rEbOylnudyoLIguOqw7FHkDXSFm8gp6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=bestguesspass action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zjCR12XLrDbTrz7k+SmvR/sOZ2ZE+5YWiE19xK6Rlsw=; b=DgYF95JU+SnpCO+CX1Xv3qLxlKYV5VI83v+fzImRybYgNEWNBhiy9R1FbxgibZdAymVvdvEA1sd94ngQRYvTtiWR0pGX71PZkcnIvXjOTsYAeKDTI2roWhisWk7Pqp+p7rLycocBRire9Qy/2cf4zC5Z+PwbAawHq4YQaQuScdw= Received: from AM6P194CA0066.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:84::43) by VI1PR08MB5519.eurprd08.prod.outlook.com (2603:10a6:803:133::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.21; Mon, 29 Jun 2020 15:20:37 +0000 Received: from VE1EUR03FT064.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:84:cafe::89) by AM6P194CA0066.outlook.office365.com (2603:10a6:209:84::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.21 via Frontend Transport; Mon, 29 Jun 2020 15:20:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT064.mail.protection.outlook.com (10.152.19.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3131.20 via Frontend Transport; Mon, 29 Jun 2020 15:20:37 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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; Mon, 29 Jun 2020 15:20:28 +0000 Received: from localhost.localdomain (10.57.4.19) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Mon, 29 Jun 2020 15:20:28 +0000 From: "Tomas Pilar (tpilar)" To: CC: , , Ray Ni , "Zhichao Gao" Subject: [PATCH 6/8] ShellPkg/AcpiView: Refactor dump helpers Date: Mon, 29 Jun 2020 16:20:06 +0100 Message-ID: <20200629152008.685-7-Tomas.Pilar@arm.com> X-Mailer: git-send-email 2.24.1.windows.2 In-Reply-To: <20200629152008.685-1-Tomas.Pilar@arm.com> References: <20200629152008.685-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)(39860400002)(396003)(46966005)(426003)(2616005)(4326008)(6666004)(186003)(2906002)(1076003)(19627235002)(5660300002)(336012)(316002)(54906003)(30864003)(36756003)(26005)(70586007)(8936002)(47076004)(82740400003)(82310400002)(81166007)(70206006)(6916009)(8676002)(86362001)(478600001)(356005)(83380400001);DIR:OUT;SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 58dea857-f574-47d4-d16d-08d81c3ffe2d X-MS-TrafficTypeDiagnostic: VI1PR08MB5519:|DB7PR08MB3899: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8882;OLM:8882; X-Forefront-PRVS: 044968D9E1 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: n4Xa3PqQty1e2xGw65H3alinPKRaSj6mmMUcBxxgNYUsXRafW3UViLPyYgcqQNyuC/+5BJ6xNeQ5RGSydXePb/OKjq9Ly4XrOdY+pnlRZaZZy8YWm7ax9VEjsdC0Wta5C0k5V0/j2eq33YsKRKDZXkJuOGmA+cForq6dootdRiULh0fXMnv+X3pwY2Ywp99kHtejvPtgjiVgswiGoQvISXZJZjJZQul9qxnksKxRhNDmklz/luia1umWFdoGB8lVv0HhZIAkvF5dS9SUW+S1m/KnFXg5SO7TKfCYF+6G9NKtD0U9Ipq0CXmkFfG0VZ1dwuM0TVrrMcsFE9QsBRZWnI9DYBp12BWt3qUxc/vfC3ntbt+LCDYKVG/D7mTZX8SCSjl9m6OVvDQW+BMuMMvEPA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5519 Return-Path: Tomas.Pilar@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT039.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFTY:;SFS:(4636009)(396003)(39860400002)(376002)(346002)(136003)(46966005)(5660300002)(8676002)(2616005)(186003)(26005)(86362001)(8936002)(336012)(2906002)(81166007)(426003)(36756003)(83380400001)(36906005)(316002)(107886003)(82310400002)(54906003)(6666004)(6916009)(70206006)(1076003)(478600001)(70586007)(19627235002)(4326008)(47076004)(82740400003)(30864003);DIR:OUT;SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 4ce124ac-c9cd-4d32-708f-08d81c3ff9cd X-Forefront-PRVS: 044968D9E1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: J2FDLtMaXqO2+1JDUzAlgycv7o0/2otYjfE98BxleaFQEP9pIBgVwSaailEKHSM5//Ccqgm3A/sep6sbGDwcxQf9OAzHyT7jV2WEJGTV5ORinll/48FMP+GzwJ1GPm2StvhmPJ6IVqj81Is9v5WQ9pkyvJoprscs57bsj5mqyhWy4P0JBWLQgTxHbGKXWcrRaYOg9Rpeg6Z6/hw9/xNnnLcSW4AbEm0hYyoPrdAHbsla8wgX0ANBBAwFGOnG9PAQ+pSUjvye7qMnQMNNTlGF9FrJ6x9ebvEAqmVpLWaLh67FrYByz9ohrMb0voxUhLvXqOCWKRpRStvh0OWObeLSJIWLyLVBKUu6l+1DPasvEjT+HHIkQYlwZufwVpTCvTD6uXV/+cjyddpMxh5hNReO9w== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jun 2020 15:20:44.5039 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 58dea857-f574-47d4-d16d-08d81c3ffe2d 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: AM5EUR03FT039.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3899 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain The dump variable helper functions are refactored into a separate header file as inline functions to declutter code. 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