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 51AE3AC1057 for ; Thu, 7 Mar 2024 10:37:25 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=slBAXv1LedXTY18tl8QD018BCy0OvoO5X7mGoDk7obc=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:User-Agent:From:Subject:To:Cc:References:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20240206; t=1709807843; v=1; b=RXhkzIxKmZvRvoycM9Ngyx8NeE8uEWDXe+5rsTexau/1Kxc7KA00kqV4bPvxQkP/+gBSexH1 YIEwJPeFXOliXfj+4bGO+/2/qmuvm2O6Ge8tKHcin2e9qfWaon1EDvYvQWFwXlBtv/VXRi6E5ZF i4YcvHeOF5Arh2xqiu6Ra5MWMM34inbvWWgqq9FOnfF5H6mf3kCcMW8D3H8waqPZN40/zPeBICd g+s3uTQXRh8bCtbLCmyrroPZPvsU/FagLR/ajWUihF4qWeH5vIQGy8UZ/Y4jNvGVVkCXFYvKODY wQ5YGOyn7Y1ezPGKJGyRqNF2m3b1E0qtDikuvEiwgu3fw== X-Received: by 127.0.0.2 with SMTP id 6TalYY7687511xaMjvL4RnyM; Thu, 07 Mar 2024 02:37:23 -0800 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.20315.1709807843230162487 for ; Thu, 07 Mar 2024 02:37:23 -0800 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E2449C15; Thu, 7 Mar 2024 02:37:59 -0800 (PST) X-Received: from [10.34.100.133] (e126645.nice.arm.com [10.34.100.133]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2607D3F762; Thu, 7 Mar 2024 02:37:22 -0800 (PST) Message-ID: Date: Thu, 07 Mar 2024 02:37:23 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: "PierreGondois" Subject: Re: [edk2-devel] [PATCH v1 1/2] ShellPkg/Acpiview: Adds HPET parser To: Abdul Lateef Attar , devel@edk2.groups.io Cc: Abdul Lateef Attar , Zhichao Gao References: <6b83014a48c42ae90b28b2261914b437ad1a99b1.1709636501.git.AbdulLateef.Attar@amd.com> In-Reply-To: <6b83014a48c42ae90b28b2261914b437ad1a99b1.1709636501.git.AbdulLateef.Attar@amd.com> 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,pierre.gondois@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 7heMP2aLeeQjv9Q9TUH8oQjvx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=RXhkzIxK; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Hello Abdul, With the comments resolved: Reviewed-by: Pierre Gondois On 3/5/24 12:12, Abdul Lateef Attar wrote: > From: Abdul Lateef Attar >=20 > Adds HPET parse to the UefiShellAcpiViewCommandLib library. >=20 > 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= /Hpet/HpetParser.c >=20 > diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h b/= ShellPkg/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/Hp= etParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Hpet/Hpet= Parser.c > new file mode 100644 > index 0000000000..d1866f91c1 > --- /dev/null > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Hpet/HpetParse= r.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)"); Maybe IncrementErrorCount() + Print() here. > + 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, = NULL, NULL, NULL }, > + { L"OEM Attributes", 4, 4, L"0x%x", NULL, = NULL, 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 }, The description in the spec is: 'Number of Comparators in 1st Timer Bloc' (maybe the name should be shorted) > + { L"Counter max size", 1, 13, NULL, DumpCounterSiz= e, 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, DumpHpetEventTimerB= lockId, NULL, NULL, NULL }, > + { L"Event Timer Block Register", 12, 40, NULL, DumpGas, = NULL, NULL, NULL }, Even though this is close, maybe the spec definition should be used instead= : 'Base address' > + { L"Sequence number", 1, 52, L"0x%x", NULL, = NULL, NULL, NULL }, 'HPET number' > + { 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/UefiShellAcpiVi= ewCommandLib.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpi= ViewCommandLib.c > index bbac125bb9..9e15979ea2 100644 > --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewComma= ndLib.c > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewComma= ndLib.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_ADD= RESS_DESCRIPTION_TABLE_SIGNATURE, > diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiVi= ewCommandLib.inf b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAc= piViewCommandLib.inf > index a38965a4bf..3338e04379 100644 > --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewComma= ndLib.inf > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewComma= ndLib.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 -=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 (#116482): https://edk2.groups.io/g/devel/message/116482 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-