From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id 434C4941DD0 for ; Mon, 8 Jul 2024 21:39:30 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=4SqyhJdbRWzajsBXSCdeQWeyAIi0oiYBAMwp7n+UHrU=; 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:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20240206; t=1720474770; v=1; b=yoday0fiA5fA3YB+bXmEMNrpUrx2RJXq8kjdV5g66wtY/Ly+gMbCwTbob1iFa2tDaNSPk7fq zQ1pnrjN/34RRYIa1+/wif9QkchNaufL7Fqd2rye+sZr/TojJMT6dEILW5+6LvQOiyOiDKDTvW8 wiIEPDUtX/L9V+obrz7CVBCIeyfT7U2ux1HHvfS2w0kfGyR/nZ9kTN6KsQCQirw7d8x69aPTO1i lzK5ls33M8dD5JrZfl/MZuj3OfhOmVnVSGEZ8qrPCzFEQPzLzELaBJyHUHKcXXSwXMWBVYAMkK/ HrjWRqQ0/rwi1RUlRlYSNSXN4ABqCy+mRczGTl2aMX2uw== X-Received: by 127.0.0.2 with SMTP id 9PSOYY7687511xrRtGcWCjy6; Mon, 08 Jul 2024 14:39:28 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.5750.1720474767480838514 for ; Mon, 08 Jul 2024 14:39:28 -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 818B2139F; Mon, 8 Jul 2024 14:39:51 -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 A00073F641; Mon, 8 Jul 2024 14:39:25 -0700 (PDT) From: "Rohit Mathew" To: devel@edk2.groups.io Cc: James Morse , Sami Mujawar , Thomas Abraham , Zhichao Gao Subject: [edk2-devel] [PATCH V6 3/6] ShellPkg/AcpiView: Update print-formatter prototype Date: Mon, 8 Jul 2024 22:39:22 +0100 Message-Id: <20240708213922.41493-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 Resent-Date: Mon, 08 Jul 2024 14:39:28 -0700 Resent-From: rohit.mathew@arm.com Reply-To: devel@edk2.groups.io,rohit.mathew@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: tWuJZF5njsjCVNt2PDRHInpjx7686176AA= 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=yoday0fi; 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 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io From: Rohit Mathew 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 Reviewed-by: Sami Mujawar --- 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/Hpet/HpetParser.c |= 12 ++++++--- ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c |= 4 ++- ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c |= 12 ++++++--- ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Wsmt/WsmtParser.c |= 3 ++- 10 files changed, 77 insertions(+), 29 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c b/= ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c index 2e3afbac9d..beb58c72a9 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: @@ -685,12 +695,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)= ); @@ -896,7 +908,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 188d3556ee..2b7b847e22 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. @@ -473,12 +484,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 83f9b292b0..af70c41826 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 2b19e3e1c0..e237e0e04e 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 c9eac9c18e..d89fcb13a4 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 ce69a600e7..8f48927da7 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/Hpet/Hp= etParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Hpet/Hp= etParser.c index 9975af53fd..c8ccdd4785 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Hpet/HpetParse= r.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Hpet/HpetParse= r.c @@ -25,7 +25,8 @@ VOID EFIAPI DumpHpetPageProtectionFlag ( IN CONST CHAR16 *Format OPTIONAL, - IN UINT8 *Ptr + IN UINT8 *Ptr, + IN UINT32 Length ) { if (Format !=3D NULL) { @@ -72,7 +73,8 @@ VOID EFIAPI DumpHpetFlag ( IN CONST CHAR16 *Format OPTIONAL, - IN UINT8 *Ptr + IN UINT8 *Ptr, + IN UINT32 Length ) { if (Format !=3D NULL) { @@ -102,7 +104,8 @@ VOID EFIAPI DumpCounterSize ( IN CONST CHAR16 *Format OPTIONAL, - IN UINT8 *Ptr + IN UINT8 *Ptr, + IN UINT32 Length ) { if (Format !=3D NULL) { @@ -166,7 +169,8 @@ VOID EFIAPI DumpHpetEventTimerBlockId ( 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/Madt/Ma= dtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/Ma= dtParser.c index 10afe8ce60..b21e3fa5cf 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParse= r.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParse= r.c @@ -269,12 +269,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 d9831023ce..7bae94c076 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; diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Wsmt/Ws= mtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Wsmt/Ws= mtParser.c index 96c2706c73..4433c047a4 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Wsmt/WsmtParse= r.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Wsmt/WsmtParse= r.c @@ -97,7 +97,8 @@ VOID EFIAPI DumpWsmtProtectionFlag ( IN CONST CHAR16 *Format OPTIONAL, - IN UINT8 *Ptr + IN UINT8 *Ptr, + IN UINT32 Length ) { if (Format !=3D NULL) { --=20 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#119819): https://edk2.groups.io/g/devel/message/119819 Mute This Topic: https://groups.io/mt/107112185/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-