From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (EUR01-HE1-obe.outbound.protection.outlook.com [40.107.13.41]) by mx.groups.io with SMTP id smtpd.web10.12484.1645199381606094367 for ; Fri, 18 Feb 2022 07:49:42 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=gWg5W82e; spf=pass (domain: arm.com, ip: 40.107.13.41, mailfrom: sami.mujawar@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=8bFp/oKzcCsT5FelRqDYKUGN3HsNJ97Hz7xgrWj/bC4=; b=gWg5W82e/2x5nH1gP9QP2E0obzmXbcsjm59j3yrPAVrhZyxHB3QRRa2KQEV3sFiyQKqpA99KzJkwWG6y00x+voZ936r9sFqYERrCdf4zZ4Tb/xc0Hqli6PrY7L5emd9HbSADNj7dW8UYhlw/TLjh0MGKGpQigCFkDRCUEOySBU0= Received: from DB8P191CA0017.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:130::27) by AM5PR0801MB2049.eurprd08.prod.outlook.com (2603:10a6:203:42::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.17; Fri, 18 Feb 2022 15:49:38 +0000 Received: from DB5EUR03FT051.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:130:cafe::50) by DB8P191CA0017.outlook.office365.com (2603:10a6:10:130::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.14 via Frontend Transport; Fri, 18 Feb 2022 15:49:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass 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 DB5EUR03FT051.mail.protection.outlook.com (10.152.21.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.20 via Frontend Transport; Fri, 18 Feb 2022 15:49:37 +0000 Received: ("Tessian outbound 741ca6c82739:v113"); Fri, 18 Feb 2022 15:49:37 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: eefd44a3aa7edead X-CR-MTA-TID: 64aa7808 Received: from 261f380dd49f.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id FAB94369-5A96-4D79-A298-52C2D90CB688.1; Fri, 18 Feb 2022 15:49:29 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 261f380dd49f.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 18 Feb 2022 15:49:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h6bWRyVCYFT0RZrXZJWTTNtXx/iAsn+Mbmc8E55hDh/z2WMR0yF4ygtYPAVBNDgSWcCqezAACZAb4S+bW1pKJNfVMTcHaeXFPxNPo1JmFFu6I5s7T2eI7GgtFf/YLj9u1Xf2MjoLwO4oFsXywLO1iIHUX9hHtHLzgg2NNDVpKvm5ZtKDw0i5b8JhByyJ7o5VHfV3abyWwNgVvNIqYc8xnVgQfM1QhbWaaYbZ2W0zor/dKD7XZCgshr7NWvoD/nCdsvbhfQfkG9epcRaM9ouXlh4e3erF/Kmu+bFEFTLuxll2yTBh5i0o3lrBymstdZr0Z5lLaZIloCMZq0LkUs7uPQ== 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=8bFp/oKzcCsT5FelRqDYKUGN3HsNJ97Hz7xgrWj/bC4=; b=jmuVp9okTfYyB7VsfP4NpXQs/En8qjS1WPnJ3ZzK6YjYxfo4K1RqBbkTAfWPX4cq2LDIHNLUmDCt51eT09QfUtkBwAPhvo5i+TBpSCEyU+eYbPBAmUF7vRVgQXDpNwRaSeI58BoxPVjfyR935t/OUjoNiEMzBlphFRF5G06qRfD3RCBJMad9LlK/Pei3kOLKRoPj+DyNYdzMugfDL3rqGRnmw59t6XhanluHnm4oN+gSlYPGOK4bhL00qCwQO+vh7fQ4ERERwn9efZZNLJzrvm6W9rwFZJAGMdvem32rA91UDUwshOGUUh6jHI1nDg6DSmvLdgI/tglF/RZ3YqPUpQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=8bFp/oKzcCsT5FelRqDYKUGN3HsNJ97Hz7xgrWj/bC4=; b=gWg5W82e/2x5nH1gP9QP2E0obzmXbcsjm59j3yrPAVrhZyxHB3QRRa2KQEV3sFiyQKqpA99KzJkwWG6y00x+voZ936r9sFqYERrCdf4zZ4Tb/xc0Hqli6PrY7L5emd9HbSADNj7dW8UYhlw/TLjh0MGKGpQigCFkDRCUEOySBU0= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AS8PR08MB6806.eurprd08.prod.outlook.com (2603:10a6:20b:39b::12) by DB6PR0801MB1768.eurprd08.prod.outlook.com (2603:10a6:4:3b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Fri, 18 Feb 2022 15:49:18 +0000 Received: from AS8PR08MB6806.eurprd08.prod.outlook.com ([fe80::34b6:4579:9e43:6b95]) by AS8PR08MB6806.eurprd08.prod.outlook.com ([fe80::34b6:4579:9e43:6b95%7]) with mapi id 15.20.4975.019; Fri, 18 Feb 2022 15:49:18 +0000 Subject: Re: [PATCH v5 1/2] ShellPkg/AcpiView: Adds ACPI_PARSER bitfield parser To: Abdul Lateef Attar , devel@edk2.groups.io Cc: Ray Ni , Zhichao Gao , nd References: <20220216111355.9801-1-abdattar@amd.com> <20220216111355.9801-2-abdattar@amd.com> From: "Sami Mujawar" Message-ID: <937a10f1-f379-a878-3cee-7df8d2b9e5d4@arm.com> Date: Fri, 18 Feb 2022 15:49:17 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.0.1 In-Reply-To: <20220216111355.9801-2-abdattar@amd.com> X-ClientProxiedBy: LO3P123CA0009.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:ba::14) To AS8PR08MB6806.eurprd08.prod.outlook.com (2603:10a6:20b:39b::12) MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 8867d1b3-8806-4aa3-a839-08d9f2f644b5 X-MS-TrafficTypeDiagnostic: DB6PR0801MB1768:EE_|DB5EUR03FT051:EE_|AM5PR0801MB2049:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:9508;OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: PWQVHEN5emhDX/NVHV0gI+E/fpucVRMQktz5PMQUht4/b1VRk/f1QNPcFd/D466WB+y9UiHBN9lmIzfS6R4eAUgwK2rWcJLVTGpnR1/zr70uKi/PGtxskhs4Zerg2LOFc7/KqKzvDkdXGAFeenrmUQNam4wegT75z6U3Hj9cXyQe3xRqSJfvwr0RhUu4c1ayCQDZwuTfPfjFEGu64uyfHgug2LUjyc1UyPMbY+g3RknUWQEDQGk3JddJ2M11ONxuX1lZjcUxM2FUaJlbc3YTNONmnZNOFmoWzJiR5ut7boacSfPxxQmg+w5wKrf2ATboqZPKMez+QINAVXaVDKmaG9p2wApIAqayRtbQsVztqaCXlLnJg5i0Z/vAg3k/pByvGXeb9mugjA5mSlmZBIkq6BJf9udyuU6bEQpQIeXydH0bACwzw8aiaI75N5A844JDkWA0g3omsuHax+XBeW507o4pHUVCQk8dQVE5ABYc+uq2fMWdxridquEmakgK0Uy777Z2B2flbiPVDCFLJMsXXHpVG+yjEc86v7yPQ5ELaIzd+fK4E4mD7s1cqQS88nUX2UGhYOb6kzSkceuwYLHmLpygx47urROB1SplaVcj2BL6DWde+SYsxaaT8oPy/6YzIq7C99f0/2C55kXx5WiAdTKecgLeGz4XfZYWGGm2E26bdHGd8QVhmy2NGtNEYRhFWslsPzY84KXdy4Nb19rUmBAZxAGqXrtbodgHHaDDCRj/C+W05L/StSBKnx6wKYS221E8bmbQT1cL+EIqwuSOgCmulcXR6nSEj190MOqr0wetKNZjQXW4lxg04s3BikE1zc6Vqi5orDqdVVBeZJx06w== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR08MB6806.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(966005)(6486002)(186003)(508600001)(44832011)(30864003)(83380400001)(26005)(4326008)(6512007)(8676002)(8936002)(6506007)(2616005)(66556008)(66946007)(66476007)(31686004)(316002)(54906003)(86362001)(5660300002)(36756003)(31696002)(2906002)(53546011)(52116002)(38100700002)(38350700002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB1768 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Return-Path: Sami.Mujawar@arm.com X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT051.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 1b34bb59-6519-4c03-cee7-08d9f2f638bb X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: InrObh5Q8yzZETMgdYAkTH6hkexl4w43EiJAgusBctKLt8KAMh+4tgFjIWd8iwU4wFhI3Or5/LAwSawtSl1f8uay3VHBPZ3PXM5D/jsYIh7tHVIMYel6nM5s4Guv98X69RvupxIG+OPoGyFstf5rU2+G2A5Q/TJcCNLObAFUzq2rH7ZAWlBgS45RItpXsnEc/XPBARqm/aIY4Pnbk8FQTR6JY6JQzhGhCf78PhlMIp16Yje7E+/kSquiLOJeXiyS7En9wK7kUkV3QCudOUjl+vYXc8zEWXyDGCg17/C5h4hkL6YkRamc3QRgeT/9+drOrsTQfb4BzigSlIoDfehq1hOqg7CQNUJVMww3gYOhnHF1FJ/vrMqIQdXgdC1rkaTJ10Z6QkNQMTYLoRp6q/euAdS7rlTZZftYOnSBbrbH883JWqUJQQKE3sYKq/Bs8WCGqR0k397Gbe3LOjw1cXsLVYgUCC7iXEvLLSZrTEX6cd/TKhZJpRAiRPLN3GsZQ+LJ6PumHI2MQGacoCwZRRFJPVAvOAUCiSmUQyizCOMtCHlIuvr6hE9tIHsoQGUv5sWGQFNnJkG0SC3CdynDqbyGhVt27hCMFKglATCwYgYSkTyuMMTsCPFu1oU0UCgi4DCzgvhRhstoDnpHLX7ExaLOPofo+zcXhd3f/duYATkm6Yph5Rds0KCRd88xaEAxi5Nv/XZcJPpxDgUE1Yee74V0r1tzQzL7lGMu3cXtJk6FvIhqBVUJsEZoNwLCoO6ySxmGcMn9ruwHNNc3nJYVFpt0/+z8/MHaDty80YsX9O5I6MA= 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;SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(30864003)(508600001)(2906002)(966005)(6486002)(5660300002)(70206006)(26005)(70586007)(8936002)(186003)(82310400004)(31686004)(36756003)(336012)(44832011)(86362001)(8676002)(4326008)(40460700003)(2616005)(316002)(81166007)(356005)(47076005)(36860700001)(83380400001)(53546011)(6512007)(54906003)(6506007)(31696002)(43740500002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2022 15:49:37.8268 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8867d1b3-8806-4aa3-a839-08d9f2f644b5 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: DB5EUR03FT051.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB2049 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-GB Hi Abdul, Thank you for this patch. Reviewed-by: Sami Mujawar Regards, Sami Mujawar On 16/02/2022 11:13 AM, Abdul Lateef Attar wrote: > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3839 > > 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 | 48 +++++ > ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c | 188 ++++++++++++++++++++ > 2 files changed, 236 insertions(+) > > diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h > index 5c916a4720b8..db8c88f6dfa4 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) 2022, AMD Incorporated. All rights reserved. > > SPDX-License-Identifier: BSD-2-Clause-Patent > > **/ > > > > @@ -251,6 +252,11 @@ typedef VOID (EFIAPI *FNPTR_FIELD_VALIDATOR)(UINT8 *Ptr, 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 bitfield. > > + > > 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 > > @@ -285,6 +293,7 @@ typedef struct AcpiParser { > /// a pointer to the field data. This value is set after the FieldValidator > > /// has been called and therefore should not be used by the FieldValidator. > > /// If unused this must be set to NULL. > > + /// ItemPtr is not supported with ParseAcpiBitFields(). > > VOID **ItemPtr; > > > > /// Optional pointer to a field validator function. > > @@ -364,6 +373,45 @@ 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 the 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). > > + > > + ItemPtr member of ACPI_PARSER is not supported with this function. > > + > > + @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 describes > > + 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 that > > + 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/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c > index cb193a5ea449..fcc56c189d65 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) 2022, 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,189 @@ 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 the 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). > > + > > + ItemPtr member of ACPI_PARSER is not supported with this function. > > + > > + @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 describes > > + 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 that > > + 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 == 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 = 0; > > + Offset = 0; > > + > > + // Increment the Indent > > + gIndent += Indent; > > + > > + CopyMem ((VOID *)&BitsData, (VOID *)Ptr, Length); > > + if (Trace && (AsciiName != NULL)) { > > + HighLight = GetColourHighlighting (); > > + > > + if (HighLight) { > > + OriginalAttribute = 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 = 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 != NULL) { > > + *Parser[Index].ItemPtr = NULL; > > + } > > + > > + // We don't parse past the end of the max length specified > > + continue; > > + } > > + > > + if (Parser[Index].Length == 0) { > > + IncrementErrorCount (); > > + // don't parse the bitfield whose length is zero > > + Print ( > > + L"\nERROR: %a: Cannot parse this field, Field Length = %d\n", > > + Parser[Index].Length > > + ); > > + continue; > > + } > > + > > + if (GetConsistencyChecking () && > > + (Offset != Parser[Index].Offset)) > > + { > > + IncrementErrorCount (); > > + Print ( > > + L"\nERROR: %a: Offset Mismatch for %s\n" > > + L"CurrentOffset = %d FieldOffset = %d\n", > > + AsciiName, > > + Parser[Index].NameStr, > > + Offset, > > + Parser[Index].Offset > > + ); > > + } > > + > > + // extract Bitfield data for the current item > > + Data = (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 != NULL) { > > + Parser[Index].PrintFormatter (Parser[Index].Format, (UINT8 *)&Data); > > + } else if (Parser[Index].Format != 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 = %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 != NULL)) > > + { > > + Parser[Index].FieldValidator ((UINT8 *)&Data, Parser[Index].Context); > > + } > > + > > + Print (L"\n"); > > + } // if (Trace) > > + > > + Offset += Parser[Index].Length; > > + } // for > > + > > + // Decrement the Indent > > + gIndent -= Indent; > > + return Offset; > > +} >