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 BBFF2941DCA for ; Mon, 2 Oct 2023 17:16:31 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=67dfaluPZaVwRhjThEr5WJtOU0k4Rn1Kt0SCp3UaEzE=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1696266990; v=1; b=QENpnUrYDFfWNFBkdL73awqQSZgXncPAxoWIg2rX6epSIesgq7QMA2ApKnbqgoS7G/Xr6zKI Sggs5Qw3lzBpwxiUke2KziT1JJfl2vfxqgubz38FIcVJ/xZKz8FXkQgtEGbOl+p272dao8dHNRw Ankxvg0pQ53ib36a4oyK48Vk= X-Received: by 127.0.0.2 with SMTP id SWncYY7687511xWpGKk7qbtj; Mon, 02 Oct 2023 10:16:30 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.88133.1696266989769485342 for ; Mon, 02 Oct 2023 10:16:29 -0700 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 E3427C15; Mon, 2 Oct 2023 10:17:07 -0700 (PDT) X-Received: from usa.arm.com (iss-desktop03.cambridge.arm.com [10.1.196.33]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 92A3C3F59C; Mon, 2 Oct 2023 10:16:28 -0700 (PDT) From: "Rohit Mathew" To: devel@edk2.groups.io Cc: Rohit Mathew , James Morse , Sami Mujawar , Thomas Abraham , Zhichao Gao Subject: [edk2-devel] [PATCH v5 3/6] ShellPkg/AcpiView: Update print-formatter prototype Date: Mon, 2 Oct 2023 18:16:23 +0100 Message-Id: <20231002171623.901196-1-Rohit.Mathew@arm.com> MIME-Version: 1.0 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,rohit.mathew@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: ZeoSIkb9yEQEflf5W8uxCH9Ox7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=QENpnUrY; 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 As of now, the print-formatter implemented by the FNPTR_PRINT_FORMATTER function pointer takes two parameters, the format string and the pointer to the field. For cases where the print-formatter has to have access to the length of the field, there is no clean way to currently do it. In order to resolve this, update the print-formatter's prototype to take the length of the field as a third parameter. This change should improve the overall robustness and flexibility of AcpiView. Signed-off-by: Rohit Mathew Cc: James Morse Cc: Sami Mujawar Cc: Thomas Abraham Cc: Zhichao Gao --- ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c |= 28 ++++++++++++++------ ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h |= 27 ++++++++++++++----- ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Aest/AestParser.c |= 4 ++- ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Erst/ErstParser.c |= 8 ++++-- ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c |= 4 ++- ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Hmat/HmatParser.c |= 4 ++- ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c |= 4 ++- ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c |= 12 ++++++--- 8 files changed, 67 insertions(+), 24 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c b/= ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c index 6823ba60cf..e0ad78250a 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c @@ -319,12 +319,14 @@ DumpUint64 ( =20 @param [in] Format Optional format string for tracing the data. @param [in] Ptr Pointer to the start of the buffer. + @param [in] Length Length of the field. **/ VOID EFIAPI Dump3Chars ( IN CONST CHAR16 *Format OPTIONAL, - IN UINT8 *Ptr + IN UINT8 *Ptr, + IN UINT32 Length ) { Print ( @@ -343,12 +345,14 @@ Dump3Chars ( =20 @param [in] Format Optional format string for tracing the data. @param [in] Ptr Pointer to the start of the buffer. + @param [in] Length Length of the field. **/ VOID EFIAPI Dump4Chars ( IN CONST CHAR16 *Format OPTIONAL, - IN UINT8 *Ptr + IN UINT8 *Ptr, + IN UINT32 Length ) { Print ( @@ -368,12 +372,14 @@ Dump4Chars ( =20 @param [in] Format Optional format string for tracing the data. @param [in] Ptr Pointer to the start of the buffer. + @param [in] Length Length of the field. **/ VOID EFIAPI Dump6Chars ( IN CONST CHAR16 *Format OPTIONAL, - IN UINT8 *Ptr + IN UINT8 *Ptr, + IN UINT32 Length ) { Print ( @@ -395,12 +401,14 @@ Dump6Chars ( =20 @param [in] Format Optional format string for tracing the data. @param [in] Ptr Pointer to the start of the buffer. + @param [in] Length Length of the field. **/ VOID EFIAPI Dump8Chars ( IN CONST CHAR16 *Format OPTIONAL, - IN UINT8 *Ptr + IN UINT8 *Ptr, + IN UINT32 Length ) { Print ( @@ -424,12 +432,14 @@ Dump8Chars ( =20 @param [in] Format Optional format string for tracing the data. @param [in] Ptr Pointer to the start of the buffer. + @param [in] Length Length of the field. **/ VOID EFIAPI Dump12Chars ( IN CONST CHAR16 *Format OPTIONAL, - IN UINT8 *Ptr + IN UINT8 *Ptr, + IN UINT32 Length ) { Print ( @@ -587,7 +597,7 @@ ParseAcpi ( // the Format for printing PrintFieldName (2, Parser[Index].NameStr); if (Parser[Index].PrintFormatter !=3D NULL) { - Parser[Index].PrintFormatter (Parser[Index].Format, Ptr); + Parser[Index].PrintFormatter (Parser[Index].Format, Ptr, Parser[= Index].Length); } else if (Parser[Index].Format !=3D NULL) { switch (Parser[Index].Length) { case 1: @@ -681,12 +691,14 @@ DumpGasStruct ( =20 @param [in] Format Optional format string for tracing the data. @param [in] Ptr Pointer to the start of the buffer. + @param [in] Length Length of the field. **/ VOID EFIAPI DumpGas ( IN CONST CHAR16 *Format OPTIONAL, - IN UINT8 *Ptr + IN UINT8 *Ptr, + IN UINT32 Length ) { DumpGasStruct (Ptr, 2, sizeof (EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE)= ); @@ -892,7 +904,7 @@ ParseAcpiBitFields ( // the Format for printing PrintFieldName (2, Parser[Index].NameStr); if (Parser[Index].PrintFormatter !=3D NULL) { - Parser[Index].PrintFormatter (Parser[Index].Format, (UINT8 *)&Da= ta); + Parser[Index].PrintFormatter (Parser[Index].Format, (UINT8 *)&Da= ta, Parser[Index].Length); } else if (Parser[Index].Format !=3D NULL) { // convert bit length to byte length switch ((Parser[Index].Length + 7) >> 3) { diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h b/= ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h index 6d8b44d94a..e760467a9d 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h @@ -130,12 +130,14 @@ DumpUint64 ( =20 @param [in] Format Optional format string for tracing the data. @param [in] Ptr Pointer to the start of the buffer. + @param [in] Length Length of the field. **/ VOID EFIAPI Dump3Chars ( IN CONST CHAR16 *Format OPTIONAL, - IN UINT8 *Ptr + IN UINT8 *Ptr, + IN UINT32 Length ); =20 /** @@ -146,12 +148,14 @@ Dump3Chars ( =20 @param [in] Format Optional format string for tracing the data. @param [in] Ptr Pointer to the start of the buffer. + @param [in] Length Length of the field. **/ VOID EFIAPI Dump4Chars ( IN CONST CHAR16 *Format OPTIONAL, - IN UINT8 *Ptr + IN UINT8 *Ptr, + IN UINT32 Length ); =20 /** @@ -162,12 +166,14 @@ Dump4Chars ( =20 @param [in] Format Optional format string for tracing the data. @param [in] Ptr Pointer to the start of the buffer. + @param [in] Length Length of the field. **/ VOID EFIAPI Dump6Chars ( IN CONST CHAR16 *Format OPTIONAL, - IN UINT8 *Ptr + IN UINT8 *Ptr, + IN UINT32 Length ); =20 /** @@ -178,12 +184,14 @@ Dump6Chars ( =20 @param [in] Format Optional format string for tracing the data. @param [in] Ptr Pointer to the start of the buffer. + @param [in] Length Length of the field. **/ VOID EFIAPI Dump8Chars ( IN CONST CHAR16 *Format OPTIONAL, - IN UINT8 *Ptr + IN UINT8 *Ptr, + IN UINT32 Length ); =20 /** @@ -194,12 +202,14 @@ Dump8Chars ( =20 @param [in] Format Optional format string for tracing the data. @param [in] Ptr Pointer to the start of the buffer. + @param [in] Length Length of the field. **/ VOID EFIAPI Dump12Chars ( IN CONST CHAR16 *Format OPTIONAL, - IN UINT8 *Ptr + IN UINT8 *Ptr, + IN UINT32 Length ); =20 /** @@ -227,8 +237,9 @@ PrintFieldName ( @param [in] Format Format string for tracing the data as specified by the 'Format' member of ACPI_PARSER. @param [in] Ptr Pointer to the start of the buffer. + @param [in] Length Length of the field. **/ -typedef VOID (EFIAPI *FNPTR_PRINT_FORMATTER)(CONST CHAR16 *Format, UINT8= *Ptr); +typedef VOID (EFIAPI *FNPTR_PRINT_FORMATTER)(CONST CHAR16 *Format, UINT8= *Ptr, UINT32 Length); =20 /** This function pointer is the template for validating an ACPI table fie= ld. @@ -469,12 +480,14 @@ DumpGasStruct ( =20 @param [in] Format Optional format string for tracing the data. @param [in] Ptr Pointer to the start of the buffer. + @param [in] Length Length of the field. **/ VOID EFIAPI DumpGas ( IN CONST CHAR16 *Format OPTIONAL, - IN UINT8 *Ptr + IN UINT8 *Ptr, + IN UINT32 Length ); =20 /** diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Aest/Ae= stParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Aest/Ae= stParser.c index a37927b107..799b32cb2b 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Aest/AestParse= r.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Aest/AestParse= r.c @@ -157,12 +157,14 @@ ValidateInterruptFlags ( =20 @param [in] Format Optional format string for tracing the data. @param [in] Ptr Pointer to the start of the buffer. + @param [in] Length Length of the field. **/ VOID EFIAPI DumpVendorSpecificData ( IN CONST CHAR16 *Format OPTIONAL, - IN UINT8 *Ptr + IN UINT8 *Ptr, + IN UINT32 Length ) { Print ( diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Erst/Er= stParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Erst/Er= stParser.c index f9f08732ca..78bca0c248 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Erst/ErstParse= r.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Erst/ErstParse= r.c @@ -171,13 +171,15 @@ FormatByte ( =20 @param [in] Format Optional format string for tracing the data. @param [in] Ptr Pointer to the Action byte. + @param [in] Length Length of the field. **/ STATIC VOID EFIAPI DumpErstAction ( IN CONST CHAR16 *Format OPTIONAL, - IN UINT8 *Ptr + IN UINT8 *Ptr, + IN UINT32 Length ) { FormatByte (ErstActionTable, *Ptr, ARRAY_SIZE (ErstActionTable)); @@ -188,13 +190,15 @@ DumpErstAction ( =20 @param [in] Format Optional format string for tracing the data. @param [in] Ptr Pointer to the Instruction byte. + @param [in] Length Length of the field. **/ STATIC VOID EFIAPI DumpErstInstruction ( IN CONST CHAR16 *Format OPTIONAL, - IN UINT8 *Ptr + IN UINT8 *Ptr, + IN UINT32 Length ) { FormatByte (ErstInstructionTable, *Ptr, ARRAY_SIZE (ErstInstructionTab= le)); diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/Fa= dtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/Fa= dtParser.c index f03b99ebde..2d6f10119d 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParse= r.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParse= r.c @@ -169,12 +169,14 @@ STATIC CONST ACPI_PARSER FadtFlagParser[] =3D { =20 @param [in] Format Optional format string for tracing the data. @param [in] Ptr Pointer to the start of the buffer. + @param [in] Length Length of the field. **/ VOID EFIAPI DumpFadtFlags ( IN CONST CHAR16 *Format OPTIONAL, - IN UINT8 *Ptr + IN UINT8 *Ptr, + IN UINT32 Length ) { if (Format !=3D NULL) { diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Hmat/Hm= atParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Hmat/Hm= atParser.c index de8e9cf01f..0660c626dc 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Hmat/HmatParse= r.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Hmat/HmatParse= r.c @@ -111,13 +111,15 @@ ValidateCacheAttributes ( =20 @param [in] Format Optional format string for tracing the data. @param [in] Ptr Pointer to the start of the buffer. + @param [in] Length Length of the field. **/ STATIC VOID EFIAPI DumpCacheAttributes ( IN CONST CHAR16 *Format OPTIONAL, - IN UINT8 *Ptr + IN UINT8 *Ptr, + IN UINT32 Length ) { EFI_ACPI_6_4_HMAT_STRUCTURE_MEMORY_SIDE_CACHE_INFO_CACHE_ATTRIBUTES * diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/Ma= dtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/Ma= dtParser.c index 3633329bea..f3dba486d7 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParse= r.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParse= r.c @@ -223,12 +223,14 @@ STATIC CONST ACPI_PARSER LocalApicFlags[] =3D { =20 @param [in] Format Optional format string for tracing the data. @param [in] Ptr Pointer to the start of the buffer. + @param [in] Length Length of the field. **/ VOID EFIAPI DumpLocalApicBitFlags ( IN CONST CHAR16 *Format OPTIONAL, - IN UINT8 *Ptr + IN UINT8 *Ptr, + IN UINT32 Length ) { if (Format !=3D NULL) { diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/Sr= atParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/Sr= atParser.c index 76534ccee3..c923a350d9 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParse= r.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParse= r.c @@ -81,13 +81,15 @@ ValidateSratDeviceHandleType ( =20 @param [in] Format Format string for tracing the data. @param [in] Ptr Pointer to the start of the buffer. + @param [in] Length Length of the field. **/ STATIC VOID EFIAPI DumpSratPciBdfNumber ( IN CONST CHAR16 *Format, - IN UINT8 *Ptr + IN UINT8 *Ptr, + IN UINT32 Length ) { CHAR16 Buffer[OUTPUT_FIELD_COLUMN_WIDTH]; @@ -169,13 +171,15 @@ STATIC CONST ACPI_PARSER SratDeviceHandlePciParser= [] =3D { =20 @param [in] Format Format string for tracing the data. @param [in] Ptr Pointer to the start of the buffer. + @param [in] Length Length of the field. **/ STATIC VOID EFIAPI DumpSratDeviceHandle ( IN CONST CHAR16 *Format, - IN UINT8 *Ptr + IN UINT8 *Ptr, + IN UINT32 Length ) { if (SratDeviceHandleType =3D=3D NULL) { @@ -212,13 +216,15 @@ DumpSratDeviceHandle ( =20 @param [in] Format Format string for tracing the data. @param [in] Ptr Pointer to the start of the buffer. + @param [in] Length Length of the field. **/ STATIC VOID EFIAPI DumpSratApicProximity ( IN CONST CHAR16 *Format, - IN UINT8 *Ptr + IN UINT8 *Ptr, + IN UINT32 Length ) { UINT32 ProximityDomain; --=20 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109261): https://edk2.groups.io/g/devel/message/109261 Mute This Topic: https://groups.io/mt/101716941/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-