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 7DAA99415D7 for ; Tue, 5 Mar 2024 11:12:47 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=7oppY3ur8tyQ1KHcDsIZetCYKZoPvwPnLEBVzo5wmZg=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Received-SPF:From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Received-SPF: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=20140610; t=1709637166; v=1; b=pvhmjaCf5mT7q2SqbEVr4cbIn9vpRw/l2UqA7A4hFc+hPF/7XvNkyn8VPEe0ir2IrdLzlVmB d59K+JdsoLl04M0bFTydI2YsitY4Zz5uVx7Uvks/TnCCfypIn7FHozhhP+KD+Yziv3oiLs/y27w BicKSsEOaZ0Qb3DmC0ZpnDXE= X-Received: by 127.0.0.2 with SMTP id Lw5MYY7687511x02fbUSJhLv; Tue, 05 Mar 2024 03:12:46 -0800 X-Received: from NAM02-SN1-obe.outbound.protection.outlook.com (NAM02-SN1-obe.outbound.protection.outlook.com [40.107.96.64]) by mx.groups.io with SMTP id smtpd.web10.19926.1709637165587874364 for ; Tue, 05 Mar 2024 03:12:45 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lY/BRvEVCAvXnm5O1zbY5NyGp7jijyntAbSY4QDd7fSHrzLxD+3vjXlneeWd8glqM/hv+MUP7RRugxgmFgmSfl/rJwv9BKIeJK2hd0fEEbAQZGWxxgKlQ4+xwndzz6Lh4Dz/gVlPBtkvmnxveK47yVW5FPMtid5+GjV4J65L0PN4un56qfwrXqO2VsK56iv9P9fC+o0c7H/UqLahef4ba3niQv9BqDqqK+p1/oBaugH7QrEMN9RLZPFtICAs0CPTVsMl58BtKqo6Dg/r99EJXAovkAJjUrsvT6EoXPDqSnCqyGcgpcBHVhrLUxcbLS/LKmNItvSPoxywS4n8mMSyRQ== 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=YZOinvkDGmNlEVZEIprHPVGVhn83DE06xu5/ymqTfgk=; b=dxZHXLK0P5i1Om+kOqQ/fdsi2SguIj/oIMprf9K+O8nLSvaNdz2Vv9k2lnl9AE8E3J5aQOBwmUF6PImEDID6PJEyL7OSm2ChP9MUkaPE5mC8yCXGBfAE1HST81NaVQ1bvwaOCO90N37CZlwQt/qnVeEKpYBnJQLtxuOJ66ydEUuq0gTkndaxi4I5+/gNMzdIfqr9F2ZVBkbWoXaoNj03TArlKLlOezp8QGBVqUp5O9fD2ic80bgbVXi8U+PWQ6YVUjt+2tpp62znACtAZW0S5/qZM2/d3n79yEy5hk0PocUV9R5HGerGh19IDatm2xsry3zVHAfc+mVLpa7LIi919Q== 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 (0) X-Received: from BN0PR04CA0174.namprd04.prod.outlook.com (2603:10b6:408:eb::29) by PH0PR12MB7960.namprd12.prod.outlook.com (2603:10b6:510:287::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.38; Tue, 5 Mar 2024 11:12:41 +0000 X-Received: from BN3PEPF0000B073.namprd04.prod.outlook.com (2603:10b6:408:eb:cafe::7a) by BN0PR04CA0174.outlook.office365.com (2603:10b6:408:eb::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.39 via Frontend Transport; Tue, 5 Mar 2024 11:12:36 +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=SATLEXMB04.amd.com; pr=C X-Received: from SATLEXMB04.amd.com (165.204.84.17) by BN3PEPF0000B073.mail.protection.outlook.com (10.167.243.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7362.11 via Frontend Transport; Tue, 5 Mar 2024 11:12:36 +0000 X-Received: from SATLEXMB03.amd.com (10.181.40.144) 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.2507.35; Tue, 5 Mar 2024 05:12:35 -0600 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; Tue, 5 Mar 2024 05:12:33 -0600 From: "Abdul Lateef Attar via groups.io" To: CC: Abdul Lateef Attar , Zhichao Gao , Pierre Gondois Subject: [edk2-devel] [PATCH v1 1/2] ShellPkg/Acpiview: Adds HPET parser Date: Tue, 5 Mar 2024 16:42:27 +0530 Message-ID: <6b83014a48c42ae90b28b2261914b437ad1a99b1.1709636501.git.AbdulLateef.Attar@amd.com> In-Reply-To: References: MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: abdattar@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B073:EE_|PH0PR12MB7960:EE_ X-MS-Office365-Filtering-Correlation-Id: 86b7fc77-a689-478c-cc20-08dc3d0529c8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: mdrWcGBhnpYIGWLqAwvaJFAofan0rdSyy0eBc4tpg6mtUH0Xx57FLVIC9ope07LQK+V1PI5ZXE0PQknQJh67Kw/Sqz2dNfjeRRQ0h3Nik9z3DQYK7redTmTqL1mW/ozFcsBH0WkbsmiVBNt/uViSxMlsFXmSRDQ6bYtXAK5hFlg38FfWR+bUt08kQAsuZa0WUZdGTmTPngqtDcd2eZ8aai9qGzrW7XwU+T0Sy9Oe8AmzTlLY9eFdPZTG9vvZBXKF3KP41EIGnCk5k8eXFWxeFai0s3XENJne+dbEiM/F4j5AHh0A/wJYITkxBN0RtdsPpDjgnd4Vvq1z6jGQUfKvcRCbA9SplW+DKu6bnovEHlCSZmGHC+C1c94J96qC97h+G2byAdpqKeJYkcySCuJko9R4+ztaZ4HK3vOtygkmfV2Dp7FmbUIzAaRxsPwXPA4k7OQanVRNWkpSHSJ5nlKh+whYehfpfVnlx4qTIw65jeAjqw17JVYkRt3C0+Q7Wgu3dbjO9AkRAg52dXbWpkxIFP3XoCpN/vgFQJ94q3FXP+LB/GYq0IoODip+xK5v2ULULRDt1i6GICXiZLRBLEEE3hKWN32oAiokCHyJb00BsntQVI9lMhNwowsln+pEU3Q1azfkYZVc2j0RoxIvWemYBYIDvTWORk1zfgV4IT5tSfSar2k2mPMSi0rREhuKWrDG5IRI2s9hoWQo9Uht4XKRzwNVSBxsVQ3pO0xGxXou2BVmpxC4D4YpPRX6GRCCJKs3 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2024 11:12:36.4455 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 86b7fc77-a689-478c-cc20-08dc3d0529c8 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: BN3PEPF0000B073.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7960 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: WLi07v9gqymcqPoJp3zBqOb3x7686176AA= 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=20140610 header.b=pvhmjaCf; 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 --- .../UefiShellAcpiViewCommandLib/AcpiParser.h | 17 ++ .../Parsers/Hpet/HpetParser.c | 221 ++++++++++++++++++ .../UefiShellAcpiViewCommandLib.c | 1 + .../UefiShellAcpiViewCommandLib.inf | 1 + 4 files changed, 240 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..d1866f91c1 --- /dev/null +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Hpet/HpetParser.= c @@ -0,0 +1,221 @@ +/** @file + HPET table parser + + Copyright (C) 2023 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: + 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"Timer count (minus one)", 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"Event Timer Block Register", 12, 40, NULL, DumpGas, = NULL, NULL, NULL }, + { L"Sequence number", 1, 52, L"0x%x", NULL, = NULL, NULL, NULL }, + { L"Minimum Clock Ticks", 2, 53, L"0x%x", NULL, = NULL, NULL, NULL }, + { L"Flag", 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 (#116365): https://edk2.groups.io/g/devel/message/116365 Mute This Topic: https://groups.io/mt/104742259/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-