From nobody Fri Apr 19 20:52:49 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.108 as permitted sender) smtp.mailfrom=bounce+27952+83910+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1637576488764203.27902502929544; Mon, 22 Nov 2021 02:21:28 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 2MADYY1788612xSSgycJ0NQm; Mon, 22 Nov 2021 02:21:28 -0800 X-Received: from NAM11-DM6-obe.outbound.protection.outlook.com (NAM11-DM6-obe.outbound.protection.outlook.com [40.107.223.80]) by mx.groups.io with SMTP id smtpd.web10.4744.1637576487334504991 for ; Mon, 22 Nov 2021 02:21:27 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YMACEA1xosEmA4byRGfWGoiBYMwvNyz3fsY3PLePpGkRF3KH9eN1u5ypUPF3A+4C8EGcOvOCT7Kug7J4zQ1K1uxFlEmwpyAyfCiREbTrmC0x3hftGvi2SheACjU/Mso1TNG747oIytbeZUA+CQv4ooBN06AKgySnttJSMJsaiNgxGNJFWrkR4bBMrfapZ4PHj+lqFxTek9s/e4HUQ4tb1Ccz7v6GRKXLYn0WWgcr6O2bJb1LvzDIR0ToZmsHPbC18UibDH6Zc9qTlpzHADL/OM3tccsF+GkHJATJYPB2m2cMEm5dy45g9hPPWCAwMzPeARrKq4FOfUbFupnBN7uWiw== 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=Etl55HmlEeelMFmS+PCr9EGRBw6J0sEmPmcrV6CZ9kM=; b=Aoo+4i2ZCJUjeodtw8Bm+Yk5uFalkd1gmuM8Nv7w3iF1UUAIUv6oBdzD6O/S4kJJMBBsVCIfeqJsTWb6LsReHmbcK4c4bB71x1j1Jv0AdXv9rgLkhaTKCkzAldZOGq+r1su0PwxSUleinZV7NXWnZSZwCthn2PbkZFpq3dsLHdbOIdZ5DYZ4sqvnJRtoMsSpU7Gpf04MvJkZYSNAPCHyVQK7svlyd67YEkCm9jy7609nW7wFSD+WjR74JlWUytxy4OFnw08latUHVcpIcV94xShK+H5IXp4B5E4vO897pmDEd8xu9C3Ca0gOlUVRQKkkiNrQIuKK0gwc2uiHiVJ+Aw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none X-Received: from BN9PR03CA0789.namprd03.prod.outlook.com (2603:10b6:408:13f::14) by MW3PR12MB4489.namprd12.prod.outlook.com (2603:10b6:303:5e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.22; Mon, 22 Nov 2021 10:21:23 +0000 X-Received: from BN8NAM11FT015.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13f:cafe::a8) by BN9PR03CA0789.outlook.office365.com (2603:10b6:408:13f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19 via Frontend Transport; Mon, 22 Nov 2021 10:21:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+83910+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; X-Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT015.mail.protection.outlook.com (10.13.176.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4713.20 via Frontend Transport; Mon, 22 Nov 2021 10:21:23 +0000 X-Received: from SATLEXMB07.amd.com (10.181.41.45) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Mon, 22 Nov 2021 04:21:22 -0600 X-Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Mon, 22 Nov 2021 02:21:22 -0800 X-Received: from BLR-LAB-SFW01.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Mon, 22 Nov 2021 04:21:21 -0600 From: "Abdul Lateef Attar via groups.io" To: CC: Ray Ni , Zhichao Gao , "Sami Mujawar" Subject: [edk2-devel] [PATCH v3 1/2] ShellPkg/AcpiView: Adds ACPI_PARSER bitfield parser Date: Mon, 22 Nov 2021 15:51:15 +0530 Message-ID: <20211122102116.22635-2-abdattar@amd.com> In-Reply-To: <20211122102116.22635-1-abdattar@amd.com> References: <20211122102116.22635-1-abdattar@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5e9eee1f-8632-4727-c0d4-08d9ada1d564 X-MS-TrafficTypeDiagnostic: MW3PR12MB4489: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: K14IvDE/5AhREPK73a6vui0ZBqhjv9U4kDqMJ5xkMNJbN7gBIxCfPZofjJmqLARQsuPHLTG3RSWHChHSF2D0UxfVjBR5qR2fTnvXeElXXLGmoGcx2WMa2HfFwQmHaEzd22jGNNVOTGP2luIxVwrD9gTKPZxhdltTQGJwgBECUN6Q8okse5YEwQ7NwvX86jrxB3HdcZFA/9cjM/SnZfSDdctIAD+rGrzpGZzxqBXzneyO7acpoyueixG5ye5qFv/jKk2hza24p7diguKePVi5DEse9w+PjHPPPj7wHFjw6P/PBXPBN6EANtQXv2DMuPIFQpMMHV2Z742tSAKE1J997C71Dtzpd4+iA52ZAMFhhzKfjcYyCQ2rO7i4Slep+21g//Ig1oKQeeF6xcxJ/giI6q8R3dg+DSFXt9kU5hRVFiJZKHMFRo3B3NuVJh2ZxBIFxpm6iz5BaQouchjvIWT1lypbhy9g7D/J8kDeaynD0CphqjGLA8Z6Pv7m2la2pzpEs84qjF9vHEXpT0NgYa/QP1CMbaWmmHOmE1AjPbMljUgFmp7bEn+wauDxMSGdo3Im429ePGWXf/hxSlQh7oM/W1qmViJ8xkMBDQwatQX5gHq2p48jyqrZ7IyJGJpMX/jF05wagISQWA13TpXc3nQj0HHDBs19KMkgrLjEsAps00nkUUsQPxIiEpU9leFiD9+ODw/y3ygjl0jfA3ipAmGWITRj+dYkK8DfDuIKIw+Nu38= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Nov 2021 10:21:23.0675 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5e9eee1f-8632-4727-c0d4-08d9ada1d564 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT015.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4489 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: 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,abdattar@amd.com X-Gm-Message-State: 30k16q9SSrCOnrQv4vgy3xpOx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1637576488; bh=2xP2coKZA2JAu8CHXpboZ28ewZpf0aDDzF3cMOUpy+g=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=TbuMghKQBzQULpG3pinCsoI4xh/xGpSPiejxSIg+9o12PC06090oBRD2mUizwrjvlg/ dB5E8TMiPY2UWg1dCTp17hCo0aivIXJTkLrUftD5bHzZZOjfFDlCXgzP1Sb5Sgry3XK/Y ONTp1hUk00YWNoqtV274HOjcIkiq8Wgn+cY= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1637576489821100005 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Sami Mujawar --- ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h | 45 +++++ ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c | 177 ++++++++++= ++++++++++ 2 files changed, 222 insertions(+) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h b/Sh= ellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h index 5e34a70c8bae..d64eec533fab 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h @@ -2,6 +2,7 @@ Header file for ACPI parser =20 Copyright (c) 2016 - 2020, Arm Limited. All rights reserved. + Copyright (c) 2021, AMD Incorporated. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent **/ =20 @@ -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. =20 @@ -265,10 +271,12 @@ typedef struct AcpiParser { =20 /// The length of the field. /// (Byte Length column from ACPI table spec) + /// Length(in bits) of the bitfield if used with ParseAcpiBitFields(). UINT32 Length; =20 /// 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; =20 /// Optional Print() style format string for tracing the data. If not @@ -365,6 +373,43 @@ ParseAcpi ( IN UINT32 ParserItems ); =20 +/** + 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 spec= ific + field values. The ItemPtr member of the ACPI_PARSER structure (where use= d) + 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. =20 diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c b/Sh= ellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c index 74056e72c359..d89c68ba3905 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c @@ -2,12 +2,14 @@ ACPI parser =20 Copyright (c) 2016 - 2021, Arm Limited. All rights reserved. + Copyright (c) 2021, AMD Incorporated. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent **/ =20 #include #include #include +#include #include "AcpiParser.h" #include "AcpiView.h" #include "AcpiViewConfig.h" @@ -738,3 +740,178 @@ ParseAcpiHeader ( =20 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 spec= ific + field values. The ItemPtr member of the ACPI_PARSER structure (where use= d) + 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 lim= it.\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].Contex= t); + } + 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; +} --=20 2.25.1 -=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 (#83910): https://edk2.groups.io/g/devel/message/83910 Mute This Topic: https://groups.io/mt/87232140/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 Apr 19 20:52:49 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.108 as permitted sender) smtp.mailfrom=bounce+27952+83911+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1637576491719924.3659140922509; Mon, 22 Nov 2021 02:21:31 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id bB3GYY1788612xOkzJbxLuNW; Mon, 22 Nov 2021 02:21:31 -0800 X-Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.53]) by mx.groups.io with SMTP id smtpd.web10.4745.1637576489994566955 for ; Mon, 22 Nov 2021 02:21:30 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HcfXdk0bFSSjDIC0eCjSs3hC+QaQmffRAlymWCD5MeU0JzMBJZviG9Jcz8aFTzAFqUeb76YW2u4CYA94L4uAQ6f46SSKL0alka3BCnyh3Llupk1+2M9fPB2JA0VbFYucN9kJl0Kd1nYJzUienUUkSMALcrrBUMaXGvpl0DY2vgpf/ppaW1yziyHIhyH0EghBw13YsLurjjmHTm8z4JKn9l3PLEj403gtN+FFNX/e088hqb55uwsp5kGmQyF1yehlXlrx+XK2iF2c8KuG8Mg24zFHAq1NVXv83ABYbbZ0NYaqOgiAPGfqReRdfQ/jkcHk7QMPRFwoMmni7g5N0UOZgg== 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=ndVM+l2sHe6MkIOwjhjqhS9T/zcGqiqpHwLminwWS5M=; b=Ew/TnuPMtIE1PPsGGSBOtDYvOu8AbzO0F+dvkXlsA3XVEL8XA5+H6Jcy27nN4c5/mbESz8+IArzuB2GyJuqab77PpW7aKyi1LUyQqKxqK99b5uIUGz6kcQDc5yh+BxUjlyRJQ0hPsuHdpI+SSArR4Zf6pWlRt1EgVKCChrtkqTQeCdjm8zGMFKBYuuQkDchp4KOX/CA2NHAs718l7HySWOMsll6EYqTqda2IStpTzqWylmXcUELPdYODlCpdO/xYnmKSwiFtX6ezvRVMoxFiPZwZywZL7CBEJtjHP4v79Zu6zG4j22E6Fk4MXd/fAJKUWSgUO4GnRAV2ONePLH5tpw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none X-Received: from DS7PR03CA0314.namprd03.prod.outlook.com (2603:10b6:8:2b::26) by DM6PR12MB4714.namprd12.prod.outlook.com (2603:10b6:5:30::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.22; Mon, 22 Nov 2021 10:21:27 +0000 X-Received: from DM6NAM11FT013.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2b:cafe::62) by DS7PR03CA0314.outlook.office365.com (2603:10b6:8:2b::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19 via Frontend Transport; Mon, 22 Nov 2021 10:21:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+83911+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; X-Received: from SATLEXMB03.amd.com (165.204.84.17) by DM6NAM11FT013.mail.protection.outlook.com (10.13.173.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4713.20 via Frontend Transport; Mon, 22 Nov 2021 10:21:27 +0000 X-Received: from SATLEXMB07.amd.com (10.181.41.45) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Mon, 22 Nov 2021 04:21:24 -0600 X-Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Mon, 22 Nov 2021 02:21:24 -0800 X-Received: from BLR-LAB-SFW01.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Mon, 22 Nov 2021 04:21:22 -0600 From: "Abdul Lateef Attar via groups.io" To: CC: Ray Ni , Zhichao Gao , "Sami Mujawar" Subject: [edk2-devel] [PATCH v3 2/2] ShellPkg/AcpiView: PrintFormatter for FADT Flags field Date: Mon, 22 Nov 2021 15:51:16 +0530 Message-ID: <20211122102116.22635-3-abdattar@amd.com> In-Reply-To: <20211122102116.22635-1-abdattar@amd.com> References: <20211122102116.22635-1-abdattar@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d5c9b110-6ca3-4415-19b5-08d9ada1d81c X-MS-TrafficTypeDiagnostic: DM6PR12MB4714: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: UvskpJb+S/MxgyM/IXSyXEMgUjNa4nxYiMut91rITBDSsEXDdA0f6wO0Xl1RdHI3URpDURqLvWeoZPZXTNY53hOjo+shl4HUiElS8WK7caOZ7ccX1vjbJq8d5iiwqavAJC2ylNdA1SSPAe4UDT0HnGMIQKw+QYeP7nHBMxSzeUqiGbtNA8xs/FO1bvkDcejjzKhFHO9mKeVXQbrbm2jz64I/CK3WDPHZblpRb9TttbEsX2pMDGBQdOhcaNJDsNwq2qGT/f9Pb83xYIpleU9LOsI72Uv1bF6D8MIOwy2VbhZXsRLJOgN3hbTF+H/x6sdgpi07YcjqLFcuTUkI2gQ2BwGCuylyeiM0fpP4q03Ox8yZWL0DHeRrOic6oclxcXjWLqbKMY6FETL4ETkzGpHRF+rANMoDcW8iBg1xxuV9ydZQeoiacZ1jeBsch0zGI+Z6t/akPC9xCSFO+hmO8Vr2fom3GntI4ZWd1AnVC6aiM7hbf19B3q7tE6qUKI2GbUjA05VbOsHLSVMWZkkHLXhZpt+vqzQZjS1AZmzLnDT+81MPbmZVSA5oKDX6lcy0m11tZekBNa/6DMghQ9pwAynG+dhBy7yy/AhUqBA1eH8hPkzhVGZ1QoZ77fWaW/nHIREpdja0mDs+xNyU4OrgdWgUHR0bGN95vWrXoUodVLjyn5TX6lDx7qoBAiGEmyxlIBHCz4+BAVAeN8J27MZ5qyG2xPGglBKxqHUyMgEHjKcyjRM= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Nov 2021 10:21:27.5826 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d5c9b110-6ca3-4415-19b5-08d9ada1d81c X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT013.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4714 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: 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,abdattar@amd.com X-Gm-Message-State: ahcj9IcECaWlwgKVuK7gQHHAx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1637576491; bh=IFf4MleXRdbXWm/n/LapE7To+1ovxtbv5wTLgm3NW9M=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=hi/CFoj6On6mZMWIl9uTAsVRjEyF/vxG7axluzvvX3NFai6xiYu01kZ498z6TIBDK93 DcNvQUPZahGwZ2Vu65Z2NrWFgsfMCrlCNWj1s9GJDYywxR9wSdKGkOGt496umijJAJM1z HGLVm1xAJJQ+kErp5pSRqubU7KOSaBEOvX0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1637576492508100002 Content-Type: text/plain; charset="utf-8" Adds PrintFormatter function to the FADT flags field. Prints indivisual flag name along with flag value. Cc: Ray Ni Cc: Zhichao Gao Cc: Sami Mujawar Signed-off-by: Abdul Lateef Attar Reviewed-by: Sami Mujawar --- ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c | 5= 9 +++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/Fadt= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtPa= rser.c index d86718bab67d..3b59864d2c7e 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c @@ -2,6 +2,7 @@ FADT table parser =20 Copyright (c) 2016 - 2020, ARM Limited. All rights reserved. + Copyright (c) 2021, AMD Incorporated. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent =20 @par Reference(s): @@ -127,6 +128,62 @@ ValidateFlags ( #endif } =20 +STATIC CONST ACPI_PARSER FadtFlagParser [] =3D { + {L"WBINVD", 1, 0, L"%d", NULL, NULL, NULL, NULL}, + {L"WBINVD_FLUSH", 1, 1, L"%d", NULL, NULL, NULL, NULL}, + {L"PROC_C1", 1, 2, L"%d", NULL, NULL, NULL, NULL}, + {L"P_LVL2_UP", 1, 3, L"%d", NULL, NULL, NULL, NULL}, + {L"PWR_BUTTON", 1, 4, L"%d", NULL, NULL, NULL, NULL}, + {L"SLP_BUTTON", 1, 5, L"%d", NULL, NULL, NULL, NULL}, + {L"FIX_RTC", 1, 6, L"%d", NULL, NULL, NULL, NULL}, + {L"RTC_S4", 1, 7, L"%d", NULL, NULL, NULL, NULL}, + {L"TMR_VAL_EXT", 1, 8, L"%d", NULL, NULL, NULL, NULL}, + {L"DCK_CAP", 1, 9, L"%d", NULL, NULL, NULL, NULL}, + {L"RESET_REG_SUP", 1, 10, L"%d", NULL, NULL, NULL, NULL}, + {L"SEALED_CASE", 1, 11, L"%d", NULL, NULL, NULL, NULL}, + {L"HEADLESS", 1, 12, L"%d", NULL, NULL, NULL, NULL}, + {L"CPU_SW_SLP", 1, 13, L"%d", NULL, NULL, NULL, NULL}, + {L"PCI_EXP_WAK", 1, 14, L"%d", NULL, NULL, NULL, NULL}, + {L"USE_PLATFORM_CLOCK", 1, 15, L"%d", NULL, NULL, NULL, NULL}, + {L"S4_RTC_STS_VALID", 1, 16, L"%d", NULL, NULL, NULL, NULL}, + {L"REMOTE_POWER_ON_CAPABLE", 1, 17, L"%d", NULL, NULL, NULL, NULL}, + {L"FORCE_APIC_CLUSTER_MODEL", 1, 18, L"%d", NULL, NULL, NULL, NULL}, + {L"FORCE_APIC_PHYSICAL_DESTINATION_MODE", 1, 19, L"%d", NULL, NULL, NULL= , NULL}, + {L"HW_REDUCED_ACPI", 1, 20, L"%d", NULL, NULL, NULL, NULL}, + {L"LOW_POWER_S0_IDLE_CAPABLE", 1, 21, L"%d", NULL, NULL, NULL, NULL}, + {L"Reserved", 10, 22, L"%d", NULL, NULL, NULL, NULL} +}; + +/** + This function traces FADT Flags fields. + 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 +DumpFadtFlags ( + IN CONST CHAR16* Format OPTIONAL, + IN UINT8* Ptr + ) +{ + if (Format !=3D NULL) { + Print (Format, *(UINT32*)Ptr); + return; + } + + Print (L"0x%X\n", *(UINT32*)Ptr); + ParseAcpiBitFields ( + TRUE, + 2, + NULL, + Ptr, + 4, + PARSER_PARAMS (FadtFlagParser) + ); +} + /** An ACPI_PARSER array describing the ACPI FADT Table. **/ @@ -170,7 +227,7 @@ STATIC CONST ACPI_PARSER FadtParser[] =3D { {L"CENTURY", 1, 108, L"0x%x", NULL, NULL, NULL, NULL}, {L"IAPC_BOOT_ARCH", 2, 109, L"0x%x", NULL, NULL, NULL, NULL}, {L"Reserved", 1, 111, L"0x%x", NULL, NULL, NULL, NULL}, - {L"Flags", 4, 112, L"0x%x", NULL, (VOID**)&Flags, ValidateFlags, NULL}, + {L"Flags", 4, 112, NULL, DumpFadtFlags, (VOID**)&Flags, ValidateFlags, N= ULL}, {L"RESET_REG", 12, 116, NULL, DumpGas, NULL, NULL, NULL}, {L"RESET_VALUE", 1, 128, L"0x%x", NULL, NULL, NULL, NULL}, {L"ARM_BOOT_ARCH", 2, 129, L"0x%x", NULL, NULL, NULL, NULL}, --=20 2.25.1 -=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 (#83911): https://edk2.groups.io/g/devel/message/83911 Mute This Topic: https://groups.io/mt/87232141/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-