From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 6F01374003C for ; Fri, 8 Mar 2024 07:22:38 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=hRzYSa1n9VCP4KjIjnT8mync95vQ/30mUgeTCIPe930=; c=relaxed/simple; d=groups.io; h=Received-SPF:From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20240206; t=1709882556; v=1; b=qji4LrDaMuvi42EaLltGq6S8e1x3IpIo+9+iKPkaGCkMqiGwXM0ROr4tQWM19BD4T/uPS1t4 TffIjzjXktAswgh+JOr1uMb/w/Gfm7j+ovs198PsiwrDxN2zyji8sGhM4ZSAy1ac9YLXf44YQSd zU22EO1IpZ2xP8VeBGw0jEAb/pMskIUmsqeR1WZRHph2R9uhTIp9QE+orIkpemAyJ2LfEz9vG1V NbXiTg7i08Z8eOVy8AIRs8acGO64SwjkHiY8SitrFsNvH3/fZgq0VZLDFjh26WOSi3I1Jb2PLWF ZHWQ0ahCW34acDekCPkToDf3Bd0WM/ZfK+CFEkUW91RAw== X-Received: by 127.0.0.2 with SMTP id Oub1YY7687511x4SUddWJsgq; Thu, 07 Mar 2024 23:22:36 -0800 X-Received: from NAM12-BN8-obe.outbound.protection.outlook.com (NAM12-BN8-obe.outbound.protection.outlook.com [40.107.237.52]) by mx.groups.io with SMTP id smtpd.web10.16407.1709882556060419276 for ; Thu, 07 Mar 2024 23:22:36 -0800 X-Received: from CH5P220CA0013.NAMP220.PROD.OUTLOOK.COM (2603:10b6:610:1ef::27) by PH8PR12MB6699.namprd12.prod.outlook.com (2603:10b6:510:1ce::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.24; Fri, 8 Mar 2024 07:22:33 +0000 X-Received: from DS3PEPF000099DA.namprd04.prod.outlook.com (2603:10b6:610:1ef:cafe::75) by CH5P220CA0013.outlook.office365.com (2603:10b6:610:1ef::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.28 via Frontend Transport; Fri, 8 Mar 2024 07:22:32 +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 (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; pr=C X-Received: from SATLEXMB03.amd.com (165.204.84.17) by DS3PEPF000099DA.mail.protection.outlook.com (10.167.17.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7362.11 via Frontend Transport; Fri, 8 Mar 2024 07:22:32 +0000 X-Received: from SATLEXMB08.amd.com (10.181.40.132) 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.2507.35; Fri, 8 Mar 2024 01:22:32 -0600 X-Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 7 Mar 2024 23:22:31 -0800 X-Received: from BLR-LAB-SFW01.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Fri, 8 Mar 2024 01:22:30 -0600 From: "Abdul Lateef Attar via groups.io" To: CC: Abdul Lateef Attar , Zhichao Gao , Pierre Gondois Subject: [edk2-devel] [PATCH v2 1/2] ShellPkg/Acpiview: Adds HPET parser Date: Thu, 07 Mar 2024 23:22:36 -0800 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DA:EE_|PH8PR12MB6699:EE_ X-MS-Office365-Filtering-Correlation-Id: 9ff38006-3aeb-40c1-9d72-08dc3f408573 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: QO5EC5rfKD3wL3GvF9a5ABndbGDtVUiedQjbatwRoSKj60+YVPsZIhLnAGLhZBvA++JYW+CLexbPq+eV8ifqw+Bc+2lwTlPg3vYuH5fV3fhy5mJU1jOWZB2SHMzUWkxVhp22fLFeYcRSI5HoF4w1TAOn4t+i8rf5cxsfWi3zusIWlMXStOFNco4sICAOTQRMDm4e7dU81e4WdP64jjSEjPV8hcq4IGNpD18j4vfI3I8GcWmFnzgIEi/5x/tlcVlXWx2y+Z+5wkIjpkoz00cnV9U8fHIiOwQNM/jQu9IKGrZWKbClsArz3/V45QcHee0ZgGU+7H+eMiX39JYgX4PECwWRzi+8XjIXSM/L9TJxUqXRNoX9ZKbhkwdvFMDRsT8cZDwiyqV1e+Of9cFcB5NGXubtryX0KRUfCT07DNaZx1r4uU9F7W9cEFgkuWsXIBxZ5TdMGD75ywvkIfpa2GnM9472uKdR93INgHVx02VMJVwx9weddpKOUbGsQ9kH9SEiyubjJ5q5V70m2dfPoPlzrKyFs95xjRCGvuL23DWvrEcqv9esXkO7eoTuA/Wn6I88M2stBFjh1Q8YAw0HObQDmtjXz5P35tM72XCRENBiuQiAHu3eGoda2jZTdOpvbrq+z7sYOmqUI1R2Ukoeu+Tev4ebN8e7y9YuCdGrtG23EZ6KDi082ZXf7GpZ582BMTJMsidXWoGd5MybTnPEmkhIpsH/mI4qEhLkQr87qPiRyQucI1hMHe030NJlCqtVNs6A X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2024 07:22:32.8233 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9ff38006-3aeb-40c1-9d72-08dc3f408573 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: DS3PEPF000099DA.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6699 Precedence: Bulk 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,AbdulLateef.Attar@amd.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: uQstsTADBbt1NwJDMDDbLA1Hx7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=qji4LrDa; dmarc=pass (policy=none) header.from=groups.io; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io From: Abdul Lateef Attar Adds HPET parse to the UefiShellAcpiViewCommandLib library. Cc: Zhichao Gao Cc: Pierre Gondois Signed-off-by: Abdul Lateef Attar Reviewed-by: Pierre Gondois --- .../UefiShellAcpiViewCommandLib/AcpiParser.h | 17 ++ .../Parsers/Hpet/HpetParser.c | 222 ++++++++++++++++++ .../UefiShellAcpiViewCommandLib.c | 1 + .../UefiShellAcpiViewCommandLib.inf | 1 + 4 files changed, 241 insertions(+) create mode 100644 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Hp= et/HpetParser.c diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h b/Sh= ellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h index 4b4397961b..ba3364f2c2 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h @@ -730,6 +730,23 @@ ParseAcpiHmat ( IN UINT8 AcpiTableRevision ); =20 +/** + This function parses the ACPI HPET table. + + @param [in] Trace If TRUE, trace the ACPI fields. + @param [in] Ptr Pointer to the start of the buffer. + @param [in] AcpiTableLength Length of the ACPI table. + @param [in] AcpiTableRevision Revision of the ACPI table. +**/ +VOID +EFIAPI +ParseAcpiHpet ( + IN BOOLEAN Trace, + IN UINT8 *Ptr, + IN UINT32 AcpiTableLength, + IN UINT8 AcpiTableRevision + ); + /** This function parses the ACPI IORT table. When trace is enabled this function parses the IORT table and diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Hpet/Hpet= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Hpet/HpetPa= rser.c new file mode 100644 index 0000000000..1b4c38f2af --- /dev/null +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Hpet/HpetParser.= c @@ -0,0 +1,222 @@ +/** @file + HPET table parser + + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Reference(s): + - HPET spec, version 1.0a +**/ + +#include +#include "AcpiParser.h" + +STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; + +/** + This function prints HPET page protection flags. + 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 +DumpHpetPageProtectionFlag ( + IN CONST CHAR16 *Format OPTIONAL, + IN UINT8 *Ptr + ) +{ + if (Format !=3D NULL) { + Print (Format, *(UINT8 *)Ptr); + return; + } + + Print (L"0x%X ", *(UINT8 *)Ptr); + switch (*Ptr) { + case 0: + Print (L"(no guarantee for page protection)"); + break; + case 1: + Print (L"(4K page protection)"); + break; + case 2: + Print (L"(64K page protection)"); + break; + default: + IncrementErrorCount (); + Print (L"(OEM Reserved)"); + break; + } + + return; +} + +/** + An ACPI_PARSER array describing the ACPI HPET flags. +**/ +STATIC CONST ACPI_PARSER DumpHpetFlagParser[] =3D { + { L"Page Protection Flag", 4, 0, NULL, DumpHpetPageProtectionFlag, NU= LL, NULL, NULL }, + { L"OEM Attributes", 4, 4, L"0x%x", NULL, NU= LL, NULL, NULL } +}; + +/** + This function prints HPET 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 +DumpHpetFlag ( + IN CONST CHAR16 *Format OPTIONAL, + IN UINT8 *Ptr + ) +{ + if (Format !=3D NULL) { + Print (Format, *(UINT8 *)Ptr); + return; + } + + Print (L"0x%X\n", *(UINT8 *)Ptr); + ParseAcpiBitFields ( + TRUE, + 2, + NULL, + Ptr, + 4, + PARSER_PARAMS (DumpHpetFlagParser) + ); +} + +/** + This function prints HPET Counter size 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 +DumpCounterSize ( + IN CONST CHAR16 *Format OPTIONAL, + IN UINT8 *Ptr + ) +{ + if (Format !=3D NULL) { + Print (Format, *(UINT32 *)Ptr); + return; + } + + Print (L"0x%X ", *(UINT32 *)Ptr); + if (*Ptr =3D=3D 0) { + Print (L"(Max 32-bit counter size)"); + } else { + Print (L"(Max 64-bit counter size)"); + } +} + +/** + This function validates the flags. + + @param [in] Ptr Pointer to the start of the field data. + @param [in] Context Pointer to context specific information e.g. this + could be a pointer to the ACPI table header. +**/ +STATIC +VOID +EFIAPI +ValidateHpetRevId ( + IN UINT8 *Ptr, + IN VOID *Context + ) +{ + if ((*(UINT8 *)Ptr) =3D=3D 0) { + IncrementErrorCount (); + Print ( + L"\nERROR: HPET Hardware Rev ID must be set." + ); + } +} + +/** + An ACPI_PARSER array describing the ACPI HPET Event Timer Block ID. +**/ +STATIC CONST ACPI_PARSER HpetEventTimerBlockIdFlagParser[] =3D { + { L"Hardware Rev ID", 8, 0, L"0x%x", NULL, = NULL, ValidateHpetRevId, NULL }, + { L"Comparators in 1st Timer Block", 5, 8, L"0x%x", NULL, = NULL, NULL, NULL }, + { L"Counter max size", 1, 13, NULL, DumpCounterSize,= NULL, NULL, NULL }, + { L"Reserved", 1, 14, L"%d", NULL, = NULL, NULL, NULL }, + { L"LegacyReplacement IRQ Routing", 1, 15, L"%d", NULL, = NULL, NULL, NULL }, + { L"PCI Vendor ID of 1st Timer Block", 16, 16, L"0x%x", NULL, = NULL, NULL, NULL } +}; + +/** + This function prints Hardware ID of HPET Event timer block. + 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 +DumpHpetEventTimerBlockId ( + 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 (HpetEventTimerBlockIdFlagParser) + ); +} + +/** + An ACPI_PARSER array describing the ACPI HPET Table. +**/ +STATIC CONST ACPI_PARSER HpetParser[] =3D { + PARSE_ACPI_HEADER (&AcpiHdrInfo), + { L"Event Timer Block ID", 4, 36, NULL, DumpHpetEventTimerBlo= ckId, NULL, NULL, NULL }, + { L"Base Address", 12, 40, NULL, DumpGas, = NULL, NULL, NULL }, + { L"HPET Number", 1, 52, L"0x%x", NULL, = NULL, NULL, NULL }, + { L"Minimum Clock Ticks", 2, 53, L"0x%x", NULL, = NULL, NULL, NULL }, + { L"Page Protection and OEM Attributes",1, 55, NULL, DumpHpetFlag, = NULL, NULL, NULL } +}; + +/** + This function parses the ACPI HPET table. + + @param [in] Trace If TRUE, trace the ACPI fields. + @param [in] Ptr Pointer to the start of the buffer. + @param [in] AcpiTableLength Length of the ACPI table. + @param [in] AcpiTableRevision Revision of the ACPI table. +**/ +VOID +EFIAPI +ParseAcpiHpet ( + IN BOOLEAN Trace, + IN UINT8 *Ptr, + IN UINT32 AcpiTableLength, + IN UINT8 AcpiTableRevision + ) +{ + ParseAcpi ( + Trace, + 0, + "HPET", + Ptr, + AcpiTableLength, + PARSER_PARAMS (HpetParser) + ); +} diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiView= CommandLib.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiVi= ewCommandLib.c index bbac125bb9..9e15979ea2 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand= Lib.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand= Lib.c @@ -59,6 +59,7 @@ ACPI_TABLE_PARSER ParserList[] =3D { { EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, = ParseAcpiFadt }, { EFI_ACPI_6_4_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE, = ParseAcpiGtdt }, { EFI_ACPI_6_4_HETEROGENEOUS_MEMORY_ATTRIBUTE_TABLE_SIGNATURE, = ParseAcpiHmat }, + { EFI_ACPI_6_5_HIGH_PRECISION_EVENT_TIMER_TABLE_SIGNATURE, = ParseAcpiHpet }, { EFI_ACPI_6_2_IO_REMAPPING_TABLE_SIGNATURE, = ParseAcpiIort }, { EFI_ACPI_6_2_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE, = ParseAcpiMadt }, { EFI_ACPI_6_2_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRES= S_DESCRIPTION_TABLE_SIGNATURE, diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiView= CommandLib.inf b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpi= ViewCommandLib.inf index a38965a4bf..3338e04379 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand= Lib.inf +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand= Lib.inf @@ -38,6 +38,7 @@ Parsers/Fadt/FadtParser.c Parsers/Gtdt/GtdtParser.c Parsers/Hmat/HmatParser.c + Parsers/Hpet/HpetParser.c Parsers/Iort/IortParser.c Parsers/Madt/MadtParser.c Parsers/Madt/MadtParser.h --=20 2.34.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 (#116489): https://edk2.groups.io/g/devel/message/116489 Mute This Topic: https://groups.io/mt/104804848/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-