From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (NAM10-BN7-obe.outbound.protection.outlook.com [40.107.92.43]) by mx.groups.io with SMTP id smtpd.web08.1987.1642563602757513071 for ; Tue, 18 Jan 2022 19:40:03 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=zlQ5CT5c; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.92.43, mailfrom: abdullateef.attar@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CTNS8A+5P7b5iAPA7GYMif/G20yReAcQI4GSYbnUFF7H61ZnHM+VszqfxhXmgMj9rjoubg92R4tRbtcmmIfurEqNrIrngdHhkyMtS1xO4Kv50VcgLB9whGBG4aKS4ZFlLtvPW/P406jy2ufwfI5Kylpcuq2o5ETW6m8xCmJztfKdF3iL4mg8UVgjCk0Ux4Cpw2XZFvWHjJJ4zTN+x7OTs6AEvT0ADODvQgf25/5je1pS+cjHCYGTAxh5gLqac0Yj0lviIFsjT269p3z1avNsbJ3XxDgyNDXiWX81BGkh1mIvoIhrJu38fPzO4gzYveKtRWn3Ngmh+8m6tQZTHp7mDA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=so8nJdDu3Y6FSPcwuygbzeloqSW9xwxS0afgrqEVllQ=; b=OksnEcuUoMg0AI2SP79yhPOpyBjKTaHiGKkW2Stfxt9Fv+QPnIo24fFeHngnZKDD/+nfi7WdzQvyl3Ra+pZ8MebmLcnlv2APOMKfqWaSfH25N9JHRhuQVxDopnLCsBpKcFCdgwC9hEg3L8NCTkBg1hfV/UzFoInbNqp81lH3xELJndvbGvk1lYXNVLRuo5qav2yNM+In5KLgOKjxRDyNW+9TapddVJJasxBauXbSmwNTZkxRWAzdLyVdonOU7lskDhiCjhuLOdBAju+RnX5F1cvNDkd4x6Kn8yZ3DZcFo7gVjy/wfx82bmnTnMDRUORWe90uSgpTSmEAJCU772iwxA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=so8nJdDu3Y6FSPcwuygbzeloqSW9xwxS0afgrqEVllQ=; b=zlQ5CT5cx4pHgOuFN1nCfXfnkYtMA3UugDfcJsBFuGljXNvlElmGwSNKlmWmz3m01yg7/xI4m/bZFB7M9mcgq2/R9cYS1fUu0Z0jAXdtfjq4wq03LQL4T5I6gJmzp9tUBwOkhRcvAMfRbJmGRGTk59t7k3S3E0ovi7jHTLSCe+0= Received: from CH0PR12MB5219.namprd12.prod.outlook.com (2603:10b6:610:d2::13) by MW2PR12MB2571.namprd12.prod.outlook.com (2603:10b6:907:10::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7; Wed, 19 Jan 2022 03:39:59 +0000 Received: from CH0PR12MB5219.namprd12.prod.outlook.com ([fe80::1994:216c:67df:ca3b]) by CH0PR12MB5219.namprd12.prod.outlook.com ([fe80::1994:216c:67df:ca3b%7]) with mapi id 15.20.4888.014; Wed, 19 Jan 2022 03:39:59 +0000 From: "Attar, AbdulLateef (Abdul Lateef)" To: "devel@edk2.groups.io" CC: Ray Ni , Zhichao Gao , Sami Mujawar Subject: Re: [edk2-devel] [PATCH v4 1/2] ShellPkg/AcpiView: Adds ACPI_PARSER bitfield parser Thread-Topic: [edk2-devel] [PATCH v4 1/2] ShellPkg/AcpiView: Adds ACPI_PARSER bitfield parser Thread-Index: AQHX9Ob5QqSAwOlMVUOdbX7DHSAhTqxW+vjwgBLnLrA= Date: Wed, 19 Jan 2022 03:39:59 +0000 Message-ID: References: <20211219144437.3721-1-abdattar@amd.com> <16C22F2D003754C4.24651@groups.io> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_88914ebd-7e6c-4e12-a031-a9906be2db14_ActionId=100da70a-d292-4aa9-aac2-083f13339fde;MSIP_Label_88914ebd-7e6c-4e12-a031-a9906be2db14_ContentBits=0;MSIP_Label_88914ebd-7e6c-4e12-a031-a9906be2db14_Enabled=true;MSIP_Label_88914ebd-7e6c-4e12-a031-a9906be2db14_Method=Standard;MSIP_Label_88914ebd-7e6c-4e12-a031-a9906be2db14_Name=AMD Official Use Only-AIP 2.0;MSIP_Label_88914ebd-7e6c-4e12-a031-a9906be2db14_SetDate=2022-01-07T02:58:02Z;MSIP_Label_88914ebd-7e6c-4e12-a031-a9906be2db14_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 5a9ba829-cd56-4ca5-1f52-08d9dafd5e94 x-ms-traffictypediagnostic: MW2PR12MB2571:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: oUnIH5WN2cUh9XXNBvlbYfS25B2jyMNaCYDpYhmQfR48AZHYoFlqgoJ/prKC/OWfcSp8cV8LBxy3FlXS2ixCaBFKGmWUJd3xniPRFrzy2oyeaFdJszZHw0o3AgvxtBpTVtVPAkFAOaPcM0CNEleleCOfgyA+t011SAjazB+qLdLE9NOAAfjxHGjW+1oZsBzYOsGQgfkLW0iYzYUvPRxrbnzdc3KzJgpFTVgao7ph/2xDdB/zMG1MVQZavAjL5uqKA+Lb2+0AKLnr7h6vY8VYD+v8Xk/F84/f1dG/blxXCToXJPPEjaCIo0UrKIqgYr3yZKCsL0fZMgMDsYkJmS5+wcMNP1GiXqkpfBQP545VDlL0OwFBpNv0JuxoGFkSCiQbwyrB9qYILoAmluPGZOG3oKrpl9dyQ/uUzWfsGya8bMjuhVjKpjKJ7GBMae95wUCbUP3h509deqtRks8HWzYA6jdrDVrh9g3UcfEn8bf4N8zaqw55YhsQEcvAWr4Tq/aBCFiXF9TEaOtdRGpJPNAtVvu+/M4q4z9Hbg9huyrLTf7Zl7aIyeiRIyYRfzrOUk/CrhazgzxwRgzPgUOfxGVQbIdGtkgZaiWzjkTf2Z6BMecpj9oA/18h9396ydNA93S36abeflJzovuMa0l5GVEe1Ksu3yk0L38SIsnmxXleYfoMCq8d6DxhGhXtCBkqaCo7pCU5ClFmnTdeRaTf4EhhqoQHPhK9WRIMLEgnmXJ73vplK6amStecf87bl9Tg0yyTeMH5wNM5cq21ch30Eu0Rekzbc/eTkAuUAFRFmgNxHnE= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH0PR12MB5219.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(966005)(6916009)(45080400002)(86362001)(26005)(508600001)(83380400001)(66946007)(53546011)(186003)(30864003)(71200400001)(66556008)(66446008)(66476007)(64756008)(76116006)(5660300002)(6506007)(54906003)(52536014)(122000001)(38100700002)(38070700005)(9686003)(8936002)(33656002)(8676002)(2906002)(4326008)(316002)(7696005)(55016003);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?lMxX1KUdB9xA01sTcqHAvvgR2w3WMcgYo0EorSZBgnXPLZ8i9OhRcTs3ekeC?= =?us-ascii?Q?mVvL+kXaJMehIu/P3OkkJeJ4+omZa8ZizE/mZf7Ua62ao3i8GjXhocUYlo5P?= =?us-ascii?Q?WlCdWEsVE9FbMOYlQ2y5VoTq9JnuMpRuhQqSvrklqA2ADIhXBFBnsuuWYeEt?= =?us-ascii?Q?NgnYJTVqKKUGIwcEGATWlrk8GAybXPT4sPoe9Wpi9aXLQCufwPqZB+ABZqfj?= =?us-ascii?Q?8LTirLsZ5nuhHqdcF8tIqQBX1pey4BBdnmjFfGlx+kEJ1KMPMKTVnLIokT+K?= =?us-ascii?Q?ME7VkUsmJFw4XOJb9a9MkrBf5QD2UDlkZV4NQUG7ztuJ5fEZXkqbiIn23yAf?= =?us-ascii?Q?dxi7OOrXRhiZ2hxN1B9IqBsPRYhcMh0ps64CWIvnvYNzLneiuSb9s9MDkzBE?= =?us-ascii?Q?de+MUGbi9ivQANCUQlgbBW4p5Efc90Rl01cYXA345DMfIKisLPOYb/Z9iJ9B?= =?us-ascii?Q?/hD8Q01113MYOWGKH9POb+Rdsysz2ry+q5qs7YvDFuvSd2C6c16eplDkU+ba?= =?us-ascii?Q?0XxdkchVUMVR0tl05ntR5ZWfY8t+Ua80WsbWxSE6lBRRSe/UitN529c71Vsx?= =?us-ascii?Q?3+pUd7PNOIQO0e5E1lQQOIv6sH3NPaPA9wqKR7Uc37OGwf9DxULW+kMmmlte?= =?us-ascii?Q?td5iIE8r3U/zw76oQP6Lm80qLa0C1G2frJztb5tB7IjbzthGxHGLNSpSBdjb?= =?us-ascii?Q?mrZJ1cAXaNTWGaDvst9iNG7P/W8Dsbrbh5l+x9ZLCkjQKlZrsyU/xfVyqsKe?= =?us-ascii?Q?LMZSd400m+tJrVpq+SnXsUmZWy8HiwLZeu9/2JFncmQo8xo2mtYfYDwzAJuf?= =?us-ascii?Q?9/afdCWkPUGzAzsadOu3iJkvovdtRp1P3fkFeUtaIqisEK8kRwn1bebIN2x/?= =?us-ascii?Q?a4tl6zLnKJjskTsBB0Ty7dAKjxVGM5kzrFhC2kttm3bVeUW9RLdy4Y9+A1A4?= =?us-ascii?Q?cXVY2O2XolDcU6V2cxayRdSZ6YTNWwgxlASW632n6EG2qH2paxDovuiU60Fr?= =?us-ascii?Q?+TU19Seh364cPeTZjU7VCh4Bjh3N9wWIsk6O4GOFAzsVmNONFNrMDhtUcxJQ?= =?us-ascii?Q?6fEX7kBp6jC4ngszR5KweQazVWYEfcav+xCFhjt+2SUJgVPGNBRBb5+GUPGp?= =?us-ascii?Q?w0kwnf49bEVKg8KXIHkSDHfOlOcLU0ODayBTMD7WTBv1lSLNn2nThmBLJHtR?= =?us-ascii?Q?EJH4zFPEFzD4Tu98rfI0EBTq+pUk+GZZVk6uRozkergVTLTMtoW95Ju7XZPj?= =?us-ascii?Q?Gdi3E1YGIBn95bbUe7RZV2NhVP8q/fiRHKod7e3VyYA7jElewHWUgGVXos0J?= =?us-ascii?Q?ugf1edFSJPvQRnPkhpMYJtoARyAz1vdAeVT+NFfYlMkt2JC9gh27pPeo+69n?= =?us-ascii?Q?kwN6pUQBVOAT6enAqZFwmEtVePQYeQ3+Wj/L1Fgx6LUml1HteC6OLTxGIVck?= =?us-ascii?Q?Zkc+VqF/I+1sTKDhKi+20MxAbNjctlpjDoXXwhGnMX+H6RgmjZAFBUg0WN+o?= =?us-ascii?Q?MR1kYCpHS2RmUZhqlcprJbuVuxxo9ss9BA/Lr3az7EwdwpD2BzyB6HjqWUU7?= =?us-ascii?Q?lnMOk/xGIR+oUejTeueWAn9EJkOim4joTtNO9Zt9njG9jlDg+Mj2Mz2HiTi6?= =?us-ascii?Q?923y+W9k0Dsf3FpOAIIwx8s=3D?= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CH0PR12MB5219.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5a9ba829-cd56-4ca5-1f52-08d9dafd5e94 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jan 2022 03:39:59.6489 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 5dEzOQJSfiZKXzvXLmIf/YFAn0ZSp2knx76oCBgu/4fSecV3v8SclicS2sEdb6jY1TB4aR5aw878S5CR5WiLVQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR12MB2571 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable [AMD Official Use Only] Hi Zhichao Gao, Ray Ni, Could you please review the below patches and merge the changes? Thanks AbduL -----Original Message----- From: Attar, AbdulLateef (Abdul Lateef) Sent: 07 January 2022 08:29 To: devel@edk2.groups.io; Attar, AbdulLateef (Abdul Lateef) Cc: Ray Ni ; Zhichao Gao ; Sami Mu= jawar Subject: RE: [edk2-devel] [PATCH v4 1/2] ShellPkg/AcpiView: Adds ACPI_PARSE= R bitfield parser Gentle reminder...please review and merge the changeset. -----Original Message----- From: devel@edk2.groups.io On Behalf Of Abdul Lateef= Attar via groups.io Sent: 19 December 2021 20:15 To: devel@edk2.groups.io Cc: Ray Ni ; Zhichao Gao ; Sami Mu= jawar Subject: [edk2-devel] [PATCH v4 1/2] ShellPkg/AcpiView: Adds ACPI_PARSER bi= tfield parser [CAUTION: External Email] Adds ParseAcpiBitFields() which is based on ParseAcpi() and capable of parsing the bit fields. Supports parsing of UINT8, UINT16, UINT32 and UINT64 byte data. Cc: Ray Ni Cc: Zhichao Gao Cc: Sami Mujawar Signed-off-by: Abdul Lateef Attar --- ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h | 45 +++++ She= llPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c | 185 ++++++++++++++= ++++++ 2 files changed, 230 insertions(+) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h b/Sh= ellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h index 5c916a4720b8..83266e8ec2d3 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h @@ -2,6 +2,7 @@ Header file for ACPI parser Copyright (c) 2016 - 2020, Arm Limited. All rights reserved. + Copyright (c) 2021, AMD Incorporated. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -251,6 +252,11 @@ typedef VOID (EFIAPI *FNPTR_FIELD_VALIDATOR)(UINT8 *Pt= r, VOID *Context); the field data. If the field is more complex and requires additional processing for formatting and representation a print formatter function can be specified in 'PrintFormatter'. + + ParseAcpiBitFields() uses AcpiParser structure to parse the bit fields. + It considers Length as a number of bits that need to be parsed. + Also, the Offset field will be considered as starting offset of the bitf= ield. + The PrintFormatter function may choose to use the format string specified by 'Format' or use its own internal format string. @@ -264,10 +270,12 @@ typedef struct AcpiParser { /// The length of the field. /// (Byte Length column from ACPI table spec) + /// Length(in bits) of the bitfield if used with ParseAcpiBitFields(). UINT32 Length; /// The offset of the field from the start of the table. /// (Byte Offset column from ACPI table spec) + /// The Bit offset of the field if used with ParseAcpiBitFields(). UINT32 Offset; /// Optional Print() style format string for tracing the data. If not @@ -364,6 +372,43 @@ ParseAcpi ( IN UINT32 ParserItems ); +/** + This function is used to parse an ACPI table bitfield buffer. + + The ACPI table buffer is parsed using the ACPI table parser + information + specified by a pointer to an array of ACPI_PARSER elements. This + parser + function iterates through each item on the ACPI_PARSER array and logs th= e ACPI table bitfields. + + This function can optionally be used to parse ACPI tables and fetch + specific + field values. The ItemPtr member of the ACPI_PARSER structure (where + used) + is updated by this parser function to point to the selected field + data + (e.g. useful for variable length nested fields). + + @param [in] Trace Trace the ACPI fields TRUE else only parse the + table. + @param [in] Indent Number of spaces to indent the output. + @param [in] AsciiName Optional pointer to an ASCII string that descri= bes + the table being parsed. + @param [in] Ptr Pointer to the start of the buffer. + @param [in] Length Length of the buffer pointed by Ptr. + @param [in] Parser Pointer to an array of ACPI_PARSER structure th= at + describes the table being parsed. + @param [in] ParserItems Number of items in the ACPI_PARSER array. + + @retval Number of bits parsed. +**/ +UINT32 +EFIAPI +ParseAcpiBitFields ( + IN BOOLEAN Trace, + IN UINT32 Indent, + IN CONST CHAR8 *AsciiName OPTIONAL, + IN UINT8 *Ptr, + IN UINT32 Length, + IN CONST ACPI_PARSER *Parser, + IN UINT32 ParserItems + ); + /** This is a helper macro to pass parameters to the Parser functions. diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c b/Sh= ellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c index cb193a5ea449..94ee26f42ab9 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c @@ -2,12 +2,14 @@ ACPI parser Copyright (c) 2016 - 2021, Arm Limited. All rights reserved. + Copyright (c) 2021, AMD Incorporated. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent **/ #include #include #include +#include #include "AcpiParser.h" #include "AcpiView.h" #include "AcpiViewConfig.h" @@ -752,3 +754,186 @@ ParseAcpiHeader ( return BytesParsed; } + +/** + This function is used to parse an ACPI table bitfield buffer. + + The ACPI table buffer is parsed using the ACPI table parser + information + specified by a pointer to an array of ACPI_PARSER elements. This + parser + function iterates through each item on the ACPI_PARSER array and logs th= e ACPI table bitfields. + + This function can optionally be used to parse ACPI tables and fetch + specific + field values. The ItemPtr member of the ACPI_PARSER structure (where + used) + is updated by this parser function to point to the selected field + data + (e.g. useful for variable length nested fields). + + @param [in] Trace Trace the ACPI fields TRUE else only parse the + table. + @param [in] Indent Number of spaces to indent the output. + @param [in] AsciiName Optional pointer to an ASCII string that descri= bes + the table being parsed. + @param [in] Ptr Pointer to the start of the buffer. + @param [in] Length Length in bytes of the buffer pointed by Ptr. + @param [in] Parser Pointer to an array of ACPI_PARSER structure th= at + describes the table being parsed. + @param [in] ParserItems Number of items in the ACPI_PARSER array. + + @retval Number of bits parsed. +**/ +UINT32 +EFIAPI +ParseAcpiBitFields ( + IN BOOLEAN Trace, + IN UINT32 Indent, + IN CONST CHAR8 *AsciiName OPTIONAL, + IN UINT8 *Ptr, + IN UINT32 Length, + IN CONST ACPI_PARSER *Parser, + IN UINT32 ParserItems + ) +{ + UINT32 Index; + UINT32 Offset; + BOOLEAN HighLight; + UINTN OriginalAttribute; + + UINT64 Data; + UINT64 BitsData; + + if ((Length =3D=3D 0) || (Length > 8)) { + IncrementErrorCount (); + Print ( + L"\nERROR: Bitfield Length(%d) is zero or exceeding the 64 bit + limit.\n", + Length + ); + return 0; + } + + // + // set local variables to suppress incorrect compiler/analyzer + warnings + // + OriginalAttribute =3D 0; + Offset =3D 0; + + // Increment the Indent + gIndent +=3D Indent; + + CopyMem ((VOID *)&BitsData, (VOID *)Ptr, Length); + if (Trace && (AsciiName !=3D NULL)) { + HighLight =3D GetColourHighlighting (); + + if (HighLight) { + 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 (HighLight) { + gST->ConOut->SetAttribute (gST->ConOut, OriginalAttribute); + } + } + + for (Index =3D 0; Index < ParserItems; Index++) { + if ((Offset + Parser[Index].Length) > (Length * 8)) { + // For fields outside the buffer length provided, reset any + pointers + // which were supposed to be updated by this function call + if (Parser[Index].ItemPtr !=3D NULL) { + *Parser[Index].ItemPtr =3D NULL; + } + + // We don't parse past the end of the max length specified + continue; + } + + if (Parser[Index].Length =3D=3D 0) { + // don't parse the bitfield whose length is zero + continue; + } + + if (GetConsistencyChecking () && + (Offset !=3D Parser[Index].Offset)) + { + IncrementErrorCount (); + Print ( + L"\nERROR: %a: Offset Mismatch for %s\n" + L"CurrentOffset =3D %d FieldOffset =3D %d\n", + AsciiName, + Parser[Index].NameStr, + Offset, + Parser[Index].Offset + ); + } + + // extract Bitfield data for the current item + Data =3D (BitsData >> Parser[Index].Offset) & ~(~0ULL << + Parser[Index].Length); + + 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, (UINT8 + *)&Data); + } else if (Parser[Index].Format !=3D NULL) { + // convert bit length to byte length + switch ((Parser[Index].Length + 7) >> 3) { + // print the data depends on byte size + case 1: + DumpUint8 (Parser[Index].Format, (UINT8 *)&Data); + break; + case 2: + DumpUint16 (Parser[Index].Format, (UINT8 *)&Data); + break; + case 3: + case 4: + DumpUint32 (Parser[Index].Format, (UINT8 *)&Data); + break; + case 5: + case 6: + case 7: + case 8: + DumpUint64 (Parser[Index].Format, (UINT8 *)&Data); + 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 (GetConsistencyChecking () && + (Parser[Index].FieldValidator !=3D NULL)) + { + Parser[Index].FieldValidator ((UINT8 *)&Data, + Parser[Index].Context); + } + + Print (L"\n"); + } // if (Trace) + + if (Parser[Index].ItemPtr !=3D NULL) { + *Parser[Index].ItemPtr =3D (VOID *)(UINT8 *)&Data; + } + + Offset +=3D Parser[Index].Length; + } // for + + // Decrement the Indent + gIndent -=3D Indent; + return Offset; +} -- 2.25.1