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 E1733D8107F for ; Fri, 6 Oct 2023 16:28:35 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=dXgSXCiGv/jSr6Azf9FbQgAX9X8q/Pl7lOL94Q3HuEM=; 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: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=1696609714; v=1; b=CzSlqbycxitMjsMTOemAupmCtOdpwpDDyKFi8pAlCvnX2JkObwv5jEWxM+Z+rpdyccX6w1HC 7e88QXuB/AhmWvEoqFQPjC1lcBpoNbyT3eoeQ+48YLT09u/4+0LXi+WAfMwR8Xp3Fhv8S6DPegl eF/KRTw5KiAHg1KBZ6YB3vRY= X-Received: by 127.0.0.2 with SMTP id Q75IYY7687511xt9JddbsSTV; Fri, 06 Oct 2023 09:28:34 -0700 X-Received: from NAM11-DM6-obe.outbound.protection.outlook.com (NAM11-DM6-obe.outbound.protection.outlook.com [40.107.223.47]) by mx.groups.io with SMTP id smtpd.web10.17510.1696609713985639641 for ; Fri, 06 Oct 2023 09:28:34 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=klsWUP1YInNq6lwDToJNAYTRLVDQJ+6lQkh00OOcUvqk5s5IoXdKPXdYDZ6Qr4Eo9EqU2DWTpMMTtbGAnKDw6P2a2kj9l/C0LosCmZYd5xQBfLaInViz4a5B149W4oyzj09RcBGAHH+wxOvXUK/QkdW2Ee1Hfl1QoGoncxbTscgyu8pSp+z86lJ2yGasABD6FpWhE5M5cQmTt2FGL0iAk33cZgjoLrDmoa5XgR5auVPqtfUwhi4KaRxuTjvXYZiHG7gsli3nzkqARUxZafa6pMoVcAMgdNtQgIUErXRo/x/TUWJPLme601H8HzBD0Gj/E1Ik8WVcRdhcLKIRi+CeGw== 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=P3nNvMGIBn4xub3ruMYS87LaajrSIR2fAOkvr+fcrS0=; b=V8UeNmoAT6OWC/Gu2rzKepbxz9GBvgDA0xLL41n0sK0vnqqdwbyEih9tPJCTee/3jTbS4OyuwSiNhQTe/85tCCa86yVHmDhBfgpC/nSf9WBYAIzYjFxPqODuE1y/cRH2Z3sRcjpemrNBrRCHBc/liSR41NZLTY9y9xEF1EPumO+U6PW6KrysAkeCRF0EBd1/zQOwycfJyLiAtbzbDZkJoHa5QvnKvD+FzS8wKDUL1MChwgCpK58T3WBmSSUufufygTCW9iDuNgBLx7V+jRPbTZGd0qKdQjFefBYcHq/n6hiDvuQwUFiUxwAd7fPmh7Vj8Zak+c+/28KvSW97hccxLw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none X-Received: from MN2PR06CA0026.namprd06.prod.outlook.com (2603:10b6:208:23d::31) by DM8PR12MB5462.namprd12.prod.outlook.com (2603:10b6:8:24::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.39; Fri, 6 Oct 2023 16:28:30 +0000 X-Received: from MN1PEPF0000ECD7.namprd02.prod.outlook.com (2603:10b6:208:23d:cafe::78) by MN2PR06CA0026.outlook.office365.com (2603:10b6:208:23d::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.29 via Frontend Transport; Fri, 6 Oct 2023 16:28:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C X-Received: from mail.nvidia.com (216.228.117.161) by MN1PEPF0000ECD7.mail.protection.outlook.com (10.167.242.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.14 via Frontend Transport; Fri, 6 Oct 2023 16:28:29 +0000 X-Received: from rnnvmail203.nvidia.com (10.129.68.9) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 6 Oct 2023 09:28:14 -0700 X-Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 6 Oct 2023 09:28:13 -0700 X-Received: from localhost.localdomain (10.127.8.11) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Fri, 6 Oct 2023 09:28:13 -0700 From: "Jeshua Smith via groups.io" To: CC: , , Jeshua Smith Subject: [edk2-devel] [PATCH 1/2] DynamicTablesPkg/TableHelperLib: Fix and improve text handling Date: Fri, 6 Oct 2023 16:28:06 +0000 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-NVConfidentiality: public X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECD7:EE_|DM8PR12MB5462:EE_ X-MS-Office365-Filtering-Correlation-Id: 49e0112a-5a5e-45a7-a967-08dbc6894695 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: LsbDlAodW6Pd0z9CVT8fBsj09YpPNsAn+lBoHThqGqyxBQw7qvY7/hVWuDp6k19Y3UIyc3q+p0g1halP4exXDRDJ40pWw3zMAF8hmvga6epFT2UE2Jo+nuiFirEjsTTGjDgNO78vzIu79wxmkoN1F3cMjau/chtGMt+jKmjAQ8+VlDHHcBZMx3h1A64DBY1GBrzWXBFwlnbkr8onQQ7QCC1KFAfu6odl+0hAiLTpV0Cgqs6GeqC6Gu8oe3zp8Xn3D4dsEF0wzuOPz9kid1PQgPAPxP5dd6ZAP2Y4fJhSAZHeZ9M3EyUZ/W/oBps9Xg8KWR56jF8u6h+TVOqOrmFZRr4NcjqClkM0khnPpVP3+U1qjggSC3KSCkYZnNX8esw1Km6+c3GMD/61NmDhKeV1FrtTvqUI25+TZZMsIE72gFDs3NJ+mNQYBs/WyxoehK2jln3VI874TM2HUHpS3FLFf2AIziyygUb0u0zlCR0cg2wQqaIas/xN7C3H2/1taz5uHD9C39+A6UhVg5KX63Wo3z/5pk0MNGD43WUhgYs+DeY6WKLw8Npgrfc6794+FUdRpfeFITee3lXaScPM2JThf8eqrFFw3M/F4mgH2CS24ylEmFD66Nv4t2+eqnslN+T0pcwEpBg+4nyOtoCYgVk6UBE/68jzT/epPuCMzLOkqfUY8BN2C7GKedFCUQ3S3QfSdlY528u1DxdNevowvcF0zVdoxD8tIeIDmxJsyz5naKezD+PdxqUxIY0ISzFjJ6P2 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2023 16:28:29.8214 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 49e0112a-5a5e-45a7-a967-08dbc6894695 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MN1PEPF0000ECD7.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR12MB5462 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,jeshuas@nvidia.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: PvpybznJPaIIyx89lDNPG5N0x7686176AA= 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=CzSlqbyc; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=none; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") This fixes two bugs and adds some enhancements to the handling of characters and strings in objects being printed by the CM ObjectParser. Bug fixes: 1. PrintOemID() currently attempts to print characters with "%C", but the correct syntax is (lowercase) "%c". This bug results in "CCCCCC" being printed instead of the actual ASCII characters. 2. PrintString() is being passed a pointer to data in objects, but in some cases this data is the actual string to print and other cases it is a pointer to the string to print. This adds a PrintStringPtr function and uses the correct functions depending on the situation. Enhancements: 1. Some objects contain ASCII characters, which are currently printed as their hex values. This adds functions to print out ASCII character fields as text rather than hex, and uses those functions in several cases where the object data is defined to be ASCII. 2. The PrintOemID() function is replaced with the new identical but more generecically-named PrintChar6() function. Signed-off-by: Jeshua Smith --- .../ConfigurationManagerObjectParser.c | 176 ++++++++++++++---- 1 file changed, 143 insertions(+), 33 deletions(-) diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationMa= nagerObjectParser.c b/DynamicTablesPkg/Library/Common/TableHelperLib/Config= urationManagerObjectParser.c index 99d6032510..92df1efee8 100644 --- a/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerOb= jectParser.c +++ b/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerOb= jectParser.c @@ -14,7 +14,7 @@ STATIC VOID EFIAPI -PrintOemId ( +PrintString ( CONST CHAR8 *Format, UINT8 *Ptr ); @@ -22,7 +22,31 @@ PrintOemId ( STATIC VOID EFIAPI -PrintString ( +PrintStringPtr ( + CONST CHAR8 *Format, + UINT8 *Ptr + ); + +STATIC +VOID +EFIAPI +PrintChar4 ( + CONST CHAR8 *Format, + UINT8 *Ptr + ); + +STATIC +VOID +EFIAPI +PrintChar6 ( + CONST CHAR8 *Format, + UINT8 *Ptr + ); + +STATIC +VOID +EFIAPI +PrintChar8 ( CONST CHAR8 *Format, UINT8 *Ptr ); @@ -190,16 +214,16 @@ STATIC CONST CM_OBJ_PARSER CmArmItsGroupNodeParser[]= =3D { /** A parser for EArmObjNamedComponent. */ STATIC CONST CM_OBJ_PARSER CmArmNamedComponentNodeParser[] =3D { - { "Token", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL }, - { "IdMappingCount", 4, "0x%x", NULL }, - { "IdMappingToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL }, - { "Flags", 4, "0x%x", NULL }, - { "CacheCoherent", 4, "0x%x", NULL }, - { "AllocationHints", 1, "0x%x", NULL }, - { "MemoryAccessFlags", 1, "0x%x", NULL }, - { "AddressSizeLimit", 1, "0x%x", NULL }, - { "ObjectName", sizeof (CHAR8 *), NULL, PrintString }, - { "Identifier", 4, "0x%x", NULL }, + { "Token", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL = }, + { "IdMappingCount", 4, "0x%x", NULL = }, + { "IdMappingToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL = }, + { "Flags", 4, "0x%x", NULL = }, + { "CacheCoherent", 4, "0x%x", NULL = }, + { "AllocationHints", 1, "0x%x", NULL = }, + { "MemoryAccessFlags", 1, "0x%x", NULL = }, + { "AddressSizeLimit", 1, "0x%x", NULL = }, + { "ObjectName", sizeof (CHAR8 *), NULL, PrintStringPtr = }, + { "Identifier", 4, "0x%x", NULL = }, }; =20 /** A parser for EArmObjRootComplex. @@ -740,19 +764,19 @@ STATIC CONST CM_OBJ_PARSER_ARRAY ArmNamespaceObjectP= arser[] =3D { */ STATIC CONST CM_OBJ_PARSER StdObjCfgMgrInfoParser[] =3D { { "Revision", 4, "0x%x", NULL }, - { "OemId[6]", 6, "%C%C%C%C%C%C", PrintOemId } + { "OemId[6]", 6, "%c%c%c%c%c%c", PrintChar6 } }; =20 /** A parser for EStdObjAcpiTableList. */ STATIC CONST CM_OBJ_PARSER StdObjAcpiTableInfoParser[] =3D { - { "AcpiTableSignature", 4, "0x%x", = NULL }, - { "AcpiTableRevision", 1, "%d", = NULL }, - { "TableGeneratorId", sizeof (ACPI_TABLE_GENERATOR_ID), "0x%x", = NULL }, - { "AcpiTableData", sizeof (EFI_ACPI_DESCRIPTION_HEADER *), "0x%p", = NULL }, - { "OemTableId", 8, "0x%LLX"= , NULL }, - { "OemRevision", 4, "0x%x", = NULL }, - { "MinorRevision", 1, "0x%x", = NULL }, + { "AcpiTableSignature", 4, "%c%c%c%= c", PrintChar4 }, + { "AcpiTableRevision", 1, "%d", = NULL }, + { "TableGeneratorId", sizeof (ACPI_TABLE_GENERATOR_ID), "0x%x", = NULL }, + { "AcpiTableData", sizeof (EFI_ACPI_DESCRIPTION_HEADER *), "0x%p", = NULL }, + { "OemTableId", 8, "%c%c%c%= c%c%c%c%c", PrintChar8 }, + { "OemRevision", 4, "0x%x", = NULL }, + { "MinorRevision", 1, "0x%x", = NULL }, }; =20 /** A parser for EStdObjSmbiosTableList. @@ -773,22 +797,99 @@ STATIC CONST CM_OBJ_PARSER_ARRAY StdNamespaceObjectP= arser[] =3D { ARRAY_SIZE (StdObjSmbiosTableInfoParser) }, }; =20 -/** Print OEM Id. +/** Print string data. + + The string must be NULL terminated. + + @param [in] Format Format to print the Ptr. + @param [in] Ptr Pointer to the string. +**/ +STATIC +VOID +EFIAPI +PrintString ( + IN CONST CHAR8 *Format, + IN UINT8 *Ptr + ) +{ + if (Ptr =3D=3D NULL) { + ASSERT (0); + return; + } + + DEBUG ((DEBUG_ERROR, "%a", Ptr)); +} + +/** Print string from pointer. + + The string must be NULL terminated. + + @param [in] Format Format to print the string. + @param [in] Ptr Pointer to the string pointer. +**/ +STATIC +VOID +EFIAPI +PrintStringPtr ( + IN CONST CHAR8 *Format, + IN UINT8 *Ptr + ) +{ + UINT8 *String; + + if (Ptr =3D=3D NULL) { + ASSERT (0); + return; + } + + String =3D *(UINT8 **)Ptr; + + if (String =3D=3D NULL) { + String =3D (UINT8 *)"(NULLPTR)"; + } + + PrintString (Format, String); +} + +/** Print 4 characters. =20 @param [in] Format Format to print the Ptr. - @param [in] Ptr Pointer to the OEM Id. + @param [in] Ptr Pointer to the characters. **/ STATIC VOID EFIAPI -PrintOemId ( +PrintChar4 ( IN CONST CHAR8 *Format, IN UINT8 *Ptr ) { DEBUG (( - DEBUG_INFO, - (Format !=3D NULL) ? Format : "%C%C%C%C%C%C", + DEBUG_ERROR, + (Format !=3D NULL) ? Format : "%c%c%c%c", + Ptr[0], + Ptr[1], + Ptr[2], + Ptr[3] + )); +} + +/** Print 6 characters. + + @param [in] Format Format to print the Ptr. + @param [in] Ptr Pointer to the characters. +**/ +STATIC +VOID +EFIAPI +PrintChar6 ( + IN CONST CHAR8 *Format, + IN UINT8 *Ptr + ) +{ + DEBUG (( + DEBUG_ERROR, + (Format !=3D NULL) ? Format : "%c%c%c%c%c%c", Ptr[0], Ptr[1], Ptr[2], @@ -798,22 +899,31 @@ PrintOemId ( )); } =20 -/** Print string. - - The string must be NULL terminated. +/** Print 8 characters. =20 @param [in] Format Format to print the Ptr. - @param [in] Ptr Pointer to the string. + @param [in] Ptr Pointer to the characters. **/ STATIC VOID EFIAPI -PrintString ( - CONST CHAR8 *Format, - UINT8 *Ptr +PrintChar8 ( + IN CONST CHAR8 *Format, + IN UINT8 *Ptr ) { - DEBUG ((DEBUG_ERROR, "%a", Ptr)); + DEBUG (( + DEBUG_ERROR, + (Format !=3D NULL) ? Format : "%c%c%c%c%c%c%c%c", + Ptr[0], + Ptr[1], + Ptr[2], + Ptr[3], + Ptr[4], + Ptr[5], + Ptr[6], + Ptr[7] + )); } =20 /** Print fields of the objects. --=20 2.25.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 (#109365): https://edk2.groups.io/g/devel/message/109365 Mute This Topic: https://groups.io/mt/101801390/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-