From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (EUR01-HE1-obe.outbound.protection.outlook.com [40.107.13.82]) by mx.groups.io with SMTP id smtpd.web08.6317.1636122459166672023 for ; Fri, 05 Nov 2021 07:27:40 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=0cE1Slrl; spf=pass (domain: arm.com, ip: 40.107.13.82, mailfrom: sami.mujawar@arm.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6LNAz20JHuq2lWyk2QpZO6QHuKwyFQPZIF6GCGQwl3w=; b=0cE1SlrlRRDQSZ/LuA7k4klxOrQ5z8gM16TRO1aRC6DRc42VkNNJQSk2BBo3u+GqJ/BfLaTDLcxRwH+L78WbfvOQd+oIKeHJi4lLPy/uZ06bKsz9EdlylRUsBJn1AhDVGDTTDeXYCf4gDm201cKLHDaI/Z4FO1W2zKX5MiGs8n4= Received: from AS9PR06CA0020.eurprd06.prod.outlook.com (2603:10a6:20b:462::24) by AM8PR08MB6626.eurprd08.prod.outlook.com (2603:10a6:20b:367::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15; Fri, 5 Nov 2021 14:27:34 +0000 Received: from VE1EUR03FT023.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:462:cafe::a8) by AS9PR06CA0020.outlook.office365.com (2603:10a6:20b:462::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Fri, 5 Nov 2021 14:27:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT023.mail.protection.outlook.com (10.152.18.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.14 via Frontend Transport; Fri, 5 Nov 2021 14:27:34 +0000 Received: ("Tessian outbound d49ee2bec50d:v108"); Fri, 05 Nov 2021 14:27:34 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 3ec3d55e972d6f78 X-CR-MTA-TID: 64aa7808 Received: from ed24d7973b3e.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id A377A775-3D97-4A7D-B26E-1CF874182B23.1; Fri, 05 Nov 2021 14:27:22 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ed24d7973b3e.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 05 Nov 2021 14:27:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GWGTtUILdak9M9dV+Mqm7Dw0qAC5pMNRsLWJJRi8gTH89asYJnMXWHSMIrYeAh2ECmxT5uUVdPOdFq+nIlHLAkmzXCv3oGnugjlJbfCuuCyim6wyoaM0s3wBrRbJzwR54d8YmpiK6elZPp4gX2XZPKFq2Nzom8RlePYfBtp9utj+DSQvRGIHADDijBSLJxL7d8HFHbmSfeLgEuWm46J5G38URrLX8j2lcY1HBzGexMNvOmo5chcBi7LnwyOPUj9BBmq7zHvPe23Dxj3EtbPHxNmT0AxnaxOpU/qjoBWFVvH7FKIKduU26Z4XqWH1YUjQuKHhIHnJMBoQw0p4e+J18w== 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=6LNAz20JHuq2lWyk2QpZO6QHuKwyFQPZIF6GCGQwl3w=; b=QROl2Mu0uWHbrQBK60H8MUMnmEhMa2eHgUYWc/stzcAdkHeM0ACwwxzMN1ps1QrIk3o9hwboxoOufHV/Gvzw+M6UtblJLTI5uquDxuSZFQhrUMNDT+uWCxBwLcp/klzv6Am9lzO950z7R/4484bV6c9t8abih85Tl1w2q0esAm8g7hKhjxWZzwDQnOYOtW3dbeuAsFsrUSiw702jAkehd07dx/nc8AXV/PAeTupFFEfbMRLZwPgqu7flFXrLbxPkRKJLo4Vc6LnbnxbDJTFIUu3B4Lp/GuFCkkFiu2bfqw9ePWWVKaFxqgfeR9LTN1xxc4UNaR7iewiS+SxE6pHLgA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6LNAz20JHuq2lWyk2QpZO6QHuKwyFQPZIF6GCGQwl3w=; b=0cE1SlrlRRDQSZ/LuA7k4klxOrQ5z8gM16TRO1aRC6DRc42VkNNJQSk2BBo3u+GqJ/BfLaTDLcxRwH+L78WbfvOQd+oIKeHJi4lLPy/uZ06bKsz9EdlylRUsBJn1AhDVGDTTDeXYCf4gDm201cKLHDaI/Z4FO1W2zKX5MiGs8n4= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AS8PR08MB6806.eurprd08.prod.outlook.com (2603:10a6:20b:39b::12) by AM6PR08MB4721.eurprd08.prod.outlook.com (2603:10a6:20b:c7::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11; Fri, 5 Nov 2021 14:27:20 +0000 Received: from AS8PR08MB6806.eurprd08.prod.outlook.com ([fe80::54b5:239d:9896:ee65]) by AS8PR08MB6806.eurprd08.prod.outlook.com ([fe80::54b5:239d:9896:ee65%4]) with mapi id 15.20.4669.010; Fri, 5 Nov 2021 14:27:20 +0000 Subject: Re: [PATCH v1 02/14] DynamicTablesPkg: FdtHwInfoParser: CM Object descriptor helper To: Pierre.Gondois@arm.com, devel@edk2.groups.io, Alexei Fedorov Cc: Akanksha Jain , Alexandru Elisei , nd References: <20210623123828.23693-1-Pierre.Gondois@arm.com> <20210623123828.23693-3-Pierre.Gondois@arm.com> From: "Sami Mujawar" Message-ID: Date: Fri, 5 Nov 2021 14:27:25 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.0.1 In-Reply-To: <20210623123828.23693-3-Pierre.Gondois@arm.com> X-ClientProxiedBy: LO4P123CA0412.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:189::21) To AS8PR08MB6806.eurprd08.prod.outlook.com (2603:10a6:20b:39b::12) MIME-Version: 1.0 Received: from [10.1.196.43] (217.140.106.52) by LO4P123CA0412.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:189::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Fri, 5 Nov 2021 14:27:20 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9fa769f9-89e6-4ce1-3c58-08d9a06868e3 X-MS-TrafficTypeDiagnostic: AM6PR08MB4721:|AM8PR08MB6626: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:7691;OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: l4NNDXwxk2BJ2BBD+juIJ1571bSUEq2hydE+dOp2DzT/d/ovVv0D33aMEqLQJ0rUev4HJtF5Cjdmo6+xrhUrWS4asTlsi+2MpBbrahgxc/IDcmaQKGn5sXgl292YPjwXp0JEIeofelZ+hJ+lrFTLo/ZMU0oaikFsFFGhaqJxSajjz5aUct/eVvVfaa968vePruDFbcFkuz6oTcV4JWBd4XYEPXLGhT5469bE1rxjUCAZGBhzIJD1AvtjgXVg+O4jPtz9SIEQSA3KwlOY3uJT4kFwVWYKKQhcDNYFSgdPZ6uiIPyVwjhkmcj7bD7+/M9ilTjyIaGMlAuSuhinjiyEHPTj3PTX7SkKD0XrKzgeOmDXci7ZcpyWaE20PoR77ngUfNLzij+8NiWSkiGYPwSfnrAj3ekJgOfJdZBqVf5kpJSYdEI7jPy3c2kT5/JpFSNhpYxumtj2XjHCX4ih7PHr7D4+EQ+vgIPt/ASMNGOPSU/OH6nvW36mGd07nUuZMoHYmijnuWMIDAe5SHTFSbS1gBfUaNij/O3cL17aJKrUJC5CDOenPsW/RxblsBFz4RZDxQtqv3YuPS4gEnEXyEJzPgh3PsTOcyocW+DyaBHYV/k7bb1QF8pmTQOHDcm5YXL7hJ0BTgWe+KEbSXuba5s5pgHIIF8m05+10gKTtco57qbWdfDcxAcAx/h/bin0ir7D56VKLfQIiVvBLDMagdzQIC23oM1uEkHbpCKy7lVkQyyQqgyok5URNlwgy4UwYWjfEBMNA1uk8utT/2gr4xbQ6Q== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR08MB6806.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(6029001)(4636009)(366004)(37006003)(53546011)(54906003)(33964004)(31686004)(8936002)(86362001)(316002)(6862004)(26005)(5660300002)(6486002)(44832011)(16576012)(8676002)(4326008)(2906002)(6636002)(508600001)(38100700002)(83380400001)(956004)(2616005)(186003)(38350700002)(66476007)(66556008)(30864003)(66946007)(52116002)(36756003)(31696002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4721 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Return-Path: Sami.Mujawar@arm.com X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT023.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 0ee33afe-e9b7-4e76-8bd3-08d9a0686070 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2c+CTQHw1pKHAzzLywOMFioRiF3spG227EAH/xHLuBMPMN9FN8cAErwI1xc1zyNvh+4Ryt2+B37YuBN6NreMBqiRGIZ/actrhHohzHBbj105OAO0J3OqMtFqRH48a9ag+moVL3FX01FLk2ov8OeXHGAiw2PkTyOc3Sezy23IqW/5C4GXyER24Gdb/pN/7girykYMRdvoYK0gk1PcSUhny8Wj/ekNuLF2zJ4hc8Mg3/Tg44t0QP4vj10XNkRkAs80a8gTB90gNISeYKwc4ZPOOpLPn/OvJ8jbbF5qS0dx/PMmrpsGpl9leTz/ce+NHRzCyOA5heA1TJ8s6gQJJ8F4G6zR1UT2Ze3gnW2qr2yLyrEsMc7FUq5/iX8006u5qmyBgCzVGwyjBT227y8sosxRc2Mw4AV1+hiFWuNGWH55S1dAKh0c5gXk+4UIgvmqL592o2aj9s+fUqcdZDUGuRoj/wCjNTorVVmlgkqUC7AgD4kmaNGOl6JnlRt9E3ePSBGDQpGneMY+NrvScZHuUBES7JxVdyJyTsxp/ODqboYmk7Um9w55hc2FZndZo0MVFmHDHhoaUpF8zwnRIQ/J+3t+MzpxzHGoVwvowcCTLFIykbAaINRuEis/xk/2r3A/Dmbdodvn4WJETxc3nE2XcAqwWPGv6nHyP/3XYY1HCIq+R9u425St83wNmeF9UGYrP3GfBKz9emQ+QfLqmlKBCu1pkp/5iGknBxypv5jqQxlmpQ0= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(6029001)(4636009)(36840700001)(46966006)(44832011)(8676002)(54906003)(508600001)(356005)(70206006)(5660300002)(6862004)(36860700001)(316002)(37006003)(16576012)(956004)(31686004)(81166007)(6486002)(83380400001)(2616005)(336012)(31696002)(47076005)(70586007)(33964004)(6636002)(4326008)(2906002)(8936002)(36756003)(26005)(186003)(53546011)(30864003)(82310400003)(86362001)(43740500002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2021 14:27:34.4952 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9fa769f9-89e6-4ce1-3c58-08d9a06868e3 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT023.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB6626 Content-Type: multipart/alternative; boundary="------------09A0839E5CD9ECAE54B6E6E4" Content-Language: en-GB --------------09A0839E5CD9ECAE54B6E6E4 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Hi Pierre, Thank you for this patch. Please find my feedback inline marked [SAMI]. Regards, Sami Mujawar On 23/06/2021 01:38 PM, Pierre.Gondois@arm.com wrote: > From: Pierre Gondois > > FdtHwInfoParserLib is an instance of the HwInfoParser. The > FdtHwInfoParser parses a platform Device Tree and populates > the Platform Information repository with Configuration > Manager objects that describe the platform hardware. > These Configuration Manager objects are encapsulated in > Configuration Manager Object Descriptors. > > Therefore, add helper functions to create and free the > Configuration Manager Object descriptors. > > Signed-off-by: Pierre Gondois > Signed-off-by: Sami Mujawar > --- > .../FdtHwInfoParserLib/CmObjectDescUtility.c | 305 ++++++++++++++++++ > .../FdtHwInfoParserLib/CmObjectDescUtility.h | 131 ++++++++ > 2 files changed, 436 insertions(+) > create mode 100644 DynamicTablesPkg/Library/FdtHwInfoParserLib/CmObjectDescUtility.c > create mode 100644 DynamicTablesPkg/Library/FdtHwInfoParserLib/CmObjectDescUtility.h > > diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/CmObjectDescUtility.c b/DynamicTablesPkg/Library/FdtHwInfoParserLib/CmObjectDescUtility.c > new file mode 100644 > index 000000000000..e471217504fe > --- /dev/null > +++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/CmObjectDescUtility.c > @@ -0,0 +1,305 @@ > +/** @file > + Configuration manager Object Descriptor Utility. > + > + Copyright (c) 2021, ARM Limited. All rights reserved.
> + SPDX-License-Identifier: BSD-2-Clause-Patent > +**/ > + > +#include > +#include > + > +#include "CmObjectDescUtility.h" > + > +/** Create a CM_OBJ_DESCRIPTOR. > + > + @param [in] ObjectId CM_OBJECT_ID of the node. > + @param [in] Count Number of CmObj stored in the > + data field. > + @param [in] Data Pointer to one or more CmObj objects. > + The content of this Data buffer is copied. > + @param [in] Size Size of the Data buffer. > + @param [out] NewCmObjDesc The created CM_OBJ_DESCRIPTOR. > + > + @retval EFI_SUCCESS The function completed successfully. > + @retval EFI_INVALID_PARAMETER Invalid parameter. > + @retval EFI_OUT_OF_RESOURCES An allocation has failed. > +**/ > +EFI_STATUS > +EFIAPI > +CreateCmObjDesc ( > + IN CM_OBJECT_ID ObjectId, > + IN UINT32 Count, > + IN VOID * Data, > + IN UINT32 Size, > + OUT CM_OBJ_DESCRIPTOR ** NewCmObjDesc > + ) > +{ > + CM_OBJ_DESCRIPTOR * CmObjDesc; > + VOID * DataBuffer; > + > + if ((Count == 0) || > + (Data == NULL) || > + (Size == 0) || > + (NewCmObjDesc == NULL)) { > + ASSERT (0); > + return EFI_INVALID_PARAMETER; > + } > + > + CmObjDesc = AllocateZeroPool (sizeof (CM_OBJ_DESCRIPTOR)); > + if (CmObjDesc == NULL) { > + ASSERT (0); > + return EFI_OUT_OF_RESOURCES; > + } > + > + DataBuffer = AllocateCopyPool (Size, Data); > + if (DataBuffer == NULL) { > + ASSERT (0); > + return EFI_OUT_OF_RESOURCES; [SAMI] CmObjDescmust be freed here otherwise there would be a memory leak. > + } > + > + CmObjDesc->ObjectId = ObjectId; > + CmObjDesc->Count = Count; > + CmObjDesc->Data = DataBuffer; > + CmObjDesc->Size = Size; > + > + *NewCmObjDesc = CmObjDesc; > + > + return EFI_SUCCESS; > +} > + > +/** Free resources allocated for the CM_OBJ_DESCRIPTOR. > + > + @param [in] CmObjDesc Pointer to the CM_OBJ_DESCRIPTOR. > + > + @retval EFI_SUCCESS The function completed successfully. > + @retval EFI_INVALID_PARAMETER Invalid parameter. > +**/ > +EFI_STATUS > +EFIAPI > +FreeCmObjDesc ( > + IN CM_OBJ_DESCRIPTOR * CmObjDesc > + ) > +{ > + if (CmObjDesc == NULL) { > + ASSERT (0); > + return EFI_INVALID_PARAMETER; > + } > + > + if (CmObjDesc->Data != NULL) { > + FreePool (CmObjDesc->Data); > + } > + > + FreePool (CmObjDesc); > + return EFI_SUCCESS; > +} > + > +/** Add a single CmObj to the Configuration Manager. > + > + @param [in] FdtParserHandle A handle to the parser instance. > + @param [in] ObjectId CmObj ObjectId. > + @param [in] Data CmObj Data. > + @param [in] Size CmObj Size. > + @param [out] Token If provided and success, > + token generated for this CmObj. > + > + @retval EFI_SUCCESS The function completed successfully. > + @retval EFI_INVALID_PARAMETER Invalid parameter. > +**/ > +EFI_STATUS > +EFIAPI > +AddSingleCmObj ( > + IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, > + IN CM_OBJECT_ID ObjectId, > + IN VOID *Data, > + IN UINT32 Size, > + OUT CM_OBJECT_TOKEN *Token OPTIONAL > + ) > +{ > + EFI_STATUS Status; > + CM_OBJ_DESCRIPTOR CmObjDesc; > + > + if ((FdtParserHandle == NULL) || > + (FdtParserHandle->HwInfoAdd == NULL) || > + (Data == NULL) || > + (Size == 0)) { > + ASSERT (0); > + return EFI_INVALID_PARAMETER; > + } > + > + CmObjDesc.ObjectId = ObjectId; > + CmObjDesc.Count = 1; > + CmObjDesc.Data = Data; > + CmObjDesc.Size = Size; > + > + // Add the CmObj. > + // Don't ask for a token. > + Status = FdtParserHandle->HwInfoAdd ( > + FdtParserHandle, > + FdtParserHandle->Context, > + &CmObjDesc, > + Token > + ); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + } [SAMI] I thinkASSERT_EFI_ERROR() can be used here. > + return Status; > +} > + > +/** Add multiple CmObj to the Configuration Manager. > + > + @param [in] FdtParserHandle A handle to the parser instance. > + @param [in] CmObjDesc CmObjDesc containing multiple CmObj > + to add. > + @param [in] TokenCount If provided, count of entries in the > + TokenTable. > + @param [out] TokenTable If provided and success, > + token generated for these CmObj. > + Address of an array of CM_OBJECT_TOKEN > + with the same number of elements as the > + CmObjDesc. > + > + @retval EFI_SUCCESS The function completed successfully. > + @retval EFI_INVALID_PARAMETER Invalid parameter. > +**/ > +EFI_STATUS > +EFIAPI > +AddMultipleCmObj ( > + IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, > + IN CONST CM_OBJ_DESCRIPTOR *CmObjDesc, > + IN UINT32 TokenCount, OPTIONAL > + OUT CM_OBJECT_TOKEN *TokenTable OPTIONAL > + ) > +{ > + EFI_STATUS Status; > + UINT32 Index; > + UINT32 Count; > + VOID * Data; > + UINT32 Size; > + CM_OBJ_DESCRIPTOR SingleCmObjDesc; > + > + if ((FdtParserHandle == NULL) || > + (FdtParserHandle->HwInfoAdd == NULL) || > + (CmObjDesc == NULL) || > + (CmObjDesc->Count == 0) || > + (CmObjDesc->Data == NULL) || > + (CmObjDesc->Size == 0)){ > + ASSERT (0); > + return EFI_INVALID_PARAMETER; > + } > + > + Count = CmObjDesc->Count; > + Data = CmObjDesc->Data; > + Size = CmObjDesc->Size / Count; > + > + SingleCmObjDesc.ObjectId = CmObjDesc->ObjectId; > + SingleCmObjDesc.Count = 1; > + SingleCmObjDesc.Size = Size; > + > + for (Index = 0; Index < Count; Index++) { > + SingleCmObjDesc.Data = Data + Index * Size; [SAMI] Data needs to be typecasted to UINT8 for the pointer arithmetic to work. Also, enclose Index * Size in parenthesis. > + // Add the CmObj. > + Status = FdtParserHandle->HwInfoAdd ( > + FdtParserHandle, > + FdtParserHandle->Context, > + &SingleCmObjDesc, > + (TokenTable != NULL) ? > + &TokenTable[Index] : > + NULL > + ); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + return Status; > + } > + } // for > + > + return Status; > +} > + > +/** Add multiple CmObj to the Configuration Manager. > + > + Get one token referencing a EArmObjCmRef CmObj itself referencing > + the input CmObj. In the table below, RefToken is returned. > + > + Token referencing an Array of tokens Array of CmObj > + array of EArmObjCmRef referencing each from the input: > + CmObj: CmObj from the input: > + > + RefToken ---> CmObjToken[0] ---> CmObj[0] > + CmObjToken[1] ---> CmObj[1] > + CmObjToken[2] ---> CmObj[2] > + > + @param [in] FdtParserHandle A handle to the parser instance. > + @param [in] CmObjDesc CmObjDesc containing multiple CmObj > + to add. > + @param [out] Token If success, token referencing an array > + of EArmObjCmRef CmObj, themselves > + referencing the input CmObjs. > + > + @retval EFI_SUCCESS The function completed successfully. > + @retval EFI_INVALID_PARAMETER Invalid parameter. > + @retval EFI_OUT_OF_RESOURCES An allocation has failed. > +**/ > +EFI_STATUS > +EFIAPI > +AddMultipleCmObjWithCmObjRef ( > + IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, > + IN CM_OBJ_DESCRIPTOR * CmObjDesc, > + OUT CM_OBJECT_TOKEN * Token > + ) > +{ > + EFI_STATUS Status; > + CM_OBJ_DESCRIPTOR CmObjRef; > + CM_OBJECT_TOKEN *TokenTable; > + INT32 TokenTableSize; > + > + if ((FdtParserHandle == NULL) || > + (FdtParserHandle->HwInfoAdd == NULL) || > + (CmObjDesc == NULL) || > + (CmObjDesc->Count == 0) || > + (CmObjDesc->Data == NULL) || > + (CmObjDesc->Size == 0) || > + (Token == NULL)) { > + ASSERT (0); > + return EFI_INVALID_PARAMETER; > + } > + > + // Allocate a buffer to store the tokens. > + TokenTableSize = CmObjDesc->Count * sizeof (CM_OBJECT_TOKEN); > + TokenTable = AllocateZeroPool (TokenTableSize); > + if (TokenTable == NULL) { > + ASSERT (0); > + return EFI_OUT_OF_RESOURCES; > + } > + > + // Add the input CmObjs. > + Status = AddMultipleCmObj ( > + FdtParserHandle, > + CmObjDesc, > + CmObjDesc->Count, > + TokenTable > + ); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + goto exit_handler; > + } > + > + CmObjRef.ObjectId = CREATE_CM_ARM_OBJECT_ID (EArmObjCmRef); > + CmObjRef.Data = TokenTable; > + CmObjRef.Count = CmObjDesc->Count; > + CmObjRef.Size = TokenTableSize; > + > + // Add the array of EArmObjCmRef CmObjs. > + Status = FdtParserHandle->HwInfoAdd ( > + FdtParserHandle, > + FdtParserHandle->Context, > + &CmObjRef, > + Token > + ); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + } [SAMI] I thinkASSERT_EFI_ERROR() can be used here. > + > +exit_handler: > + FreePool (TokenTable); > + return Status; > +} > diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/CmObjectDescUtility.h b/DynamicTablesPkg/Library/FdtHwInfoParserLib/CmObjectDescUtility.h > new file mode 100644 > index 000000000000..34439c716fb3 > --- /dev/null > +++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/CmObjectDescUtility.h > @@ -0,0 +1,131 @@ > +/** @file > + Configuration manager Object Descriptor Utility. > + > + Copyright (c) 2021, ARM Limited. All rights reserved.
> + SPDX-License-Identifier: BSD-2-Clause-Patent > +**/ > + > +#ifndef CM_OBJECT_DESC_UTILITY_H_ > +#define CM_OBJECT_DESC_UTILITY_H_ > + > +#include > + > +#include "FdtHwInfoParser.h" > + > +/** Create a CM_OBJ_DESCRIPTOR. > + > + @param [in] ObjectId CM_OBJECT_ID of the node. > + @param [in] Count Number of CmObj stored in the > + data field. > + @param [in] Data Pointer to one or more CmObj objects. > + The content of this Data buffer is copied. > + @param [in] Size Size of the Data buffer. > + @param [out] NewCmObjDesc The created CM_OBJ_DESCRIPTOR. > + > + @retval EFI_SUCCESS The function completed successfully. > + @retval EFI_INVALID_PARAMETER Invalid parameter. > + @retval EFI_OUT_OF_RESOURCES An allocation has failed. > +**/ > +EFI_STATUS > +EFIAPI > +CreateCmObjDesc ( > + IN CM_OBJECT_ID ObjectId, > + IN UINT32 Count, > + IN VOID * Data, > + IN UINT32 Size, > + OUT CM_OBJ_DESCRIPTOR ** NewCmObjDesc > + ); > + > +/** Free resources allocated for the CM_OBJ_DESCRIPTOR. > + > + @param [in] CmObjDesc Pointer to the CM_OBJ_DESCRIPTOR. > + > + @retval EFI_SUCCESS The function completed successfully. > + @retval EFI_INVALID_PARAMETER Invalid parameter. > +**/ > +EFI_STATUS > +EFIAPI > +FreeCmObjDesc ( > + IN CM_OBJ_DESCRIPTOR * CmObjDesc > + ); > + > +/** Add a single CmObj to the Configuration Manager. > + > + @param [in] FdtParserHandle A handle to the parser instance. > + @param [in] ObjectId CmObj ObjectId. > + @param [in] Data CmObj Data. > + @param [in] Size CmObj Size. > + @param [out] Token If provided and success, > + token generated for this CmObj. > + > + @retval EFI_SUCCESS The function completed successfully. > + @retval EFI_INVALID_PARAMETER Invalid parameter. > +**/ > +EFI_STATUS > +EFIAPI > +AddSingleCmObj ( > + IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, > + IN CM_OBJECT_ID ObjectId, > + IN VOID *Data, > + IN UINT32 Size, > + OUT CM_OBJECT_TOKEN *Token OPTIONAL > + ); > + > +/** Add multiple CmObj to the Configuration Manager. > + > + @param [in] FdtParserHandle A handle to the parser instance. > + @param [in] CmObjDesc CmObjDesc containing multiple CmObj > + to add. > + @param [in] TokenCount If provided, count of entries in the > + TokenTable. > + @param [out] TokenTable If provided and success, > + token generated for these CmObj. > + Address of an array of CM_OBJECT_TOKEN > + with the same number of elements as the > + CmObjDesc. > + > + @retval EFI_SUCCESS The function completed successfully. > + @retval EFI_INVALID_PARAMETER Invalid parameter. > +**/ > +EFI_STATUS > +EFIAPI > +AddMultipleCmObj ( > + IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, > + IN CONST CM_OBJ_DESCRIPTOR *CmObjDesc, > + IN UINT32 TokenCount, OPTIONAL > + OUT CM_OBJECT_TOKEN *TokenTable OPTIONAL > + ); > + > +/** Add multiple CmObj to the Configuration Manager. > + > + Get one token referencing a EArmObjCmRef CmObj itself referencing > + the input CmObj. In the table below, RefToken is returned. > + > + Token referencing an Array of tokens Array of CmObj > + array of EArmObjCmRef referencing each from the input: > + CmObj: CmObj from the input: > + > + RefToken ---> CmObjToken[0] ---> CmObj[0] > + CmObjToken[1] ---> CmObj[1] > + CmObjToken[2] ---> CmObj[2] > + > + @param [in] FdtParserHandle A handle to the parser instance. > + @param [in] CmObjDesc CmObjDesc containing multiple CmObj > + to add. > + @param [out] Token If success, token referencing an array > + of EArmObjCmRef CmObj, themselves > + referencing the input CmObjs. > + > + @retval EFI_SUCCESS The function completed successfully. > + @retval EFI_INVALID_PARAMETER Invalid parameter. > + @retval EFI_OUT_OF_RESOURCES An allocation has failed. > +**/ > +EFI_STATUS > +EFIAPI > +AddMultipleCmObjWithCmObjRef ( > + IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, > + IN CM_OBJ_DESCRIPTOR * CmObjDesc, > + OUT CM_OBJECT_TOKEN * Token > + ); > + > +#endif // CM_OBJECT_DESC_UTILITY_H_ --------------09A0839E5CD9ECAE54B6E6E4 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit

Hi Pierre,

Thank you for this patch.

Please find my feedback inline marked [SAMI].

Regards,

Sami Mujawar

On 23/06/2021 01:38 PM, Pierre.Gondois@arm.com wrote:
From: Pierre Gondois <Pierre.Gondois@arm.com>

FdtHwInfoParserLib is an instance of the HwInfoParser. The
FdtHwInfoParser parses a platform Device Tree and populates
the Platform Information repository with Configuration
Manager objects that describe the platform hardware.
These Configuration Manager objects are encapsulated in
Configuration Manager Object Descriptors.

Therefore, add helper functions to create and free the
Configuration Manager Object descriptors.

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
---
 .../FdtHwInfoParserLib/CmObjectDescUtility.c  | 305 ++++++++++++++++++
 .../FdtHwInfoParserLib/CmObjectDescUtility.h  | 131 ++++++++
 2 files changed, 436 insertions(+)
 create mode 100644 DynamicTablesPkg/Library/FdtHwInfoParserLib/CmObjectDescUtility.c
 create mode 100644 DynamicTablesPkg/Library/FdtHwInfoParserLib/CmObjectDescUtility.h

diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/CmObjectDescUtility.c b/DynamicTablesPkg/Library/FdtHwInfoParserLib/CmObjectDescUtility.c
new file mode 100644
index 000000000000..e471217504fe
--- /dev/null
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/CmObjectDescUtility.c
@@ -0,0 +1,305 @@
+/** @file
+  Configuration manager Object Descriptor Utility.
+
+  Copyright (c) 2021, ARM Limited. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <FdtHwInfoParserInclude.h>
+#include <ConfigurationManagerObject.h>
+
+#include "CmObjectDescUtility.h"
+
+/** Create a CM_OBJ_DESCRIPTOR.
+
+  @param [in]  ObjectId       CM_OBJECT_ID of the node.
+  @param [in]  Count          Number of CmObj stored in the
+                              data field.
+  @param [in]  Data           Pointer to one or more CmObj objects.
+                              The content of this Data buffer is copied.
+  @param [in]  Size           Size of the Data buffer.
+  @param [out] NewCmObjDesc   The created CM_OBJ_DESCRIPTOR.
+
+  @retval EFI_SUCCESS             The function completed successfully.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+  @retval EFI_OUT_OF_RESOURCES    An allocation has failed.
+**/
+EFI_STATUS
+EFIAPI
+CreateCmObjDesc (
+  IN  CM_OBJECT_ID          ObjectId,
+  IN  UINT32                Count,
+  IN  VOID                * Data,
+  IN  UINT32                Size,
+  OUT CM_OBJ_DESCRIPTOR  ** NewCmObjDesc
+  )
+{
+  CM_OBJ_DESCRIPTOR   * CmObjDesc;
+  VOID                * DataBuffer;
+
+  if ((Count == 0)      ||
+      (Data == NULL)    ||
+      (Size == 0)       ||
+      (NewCmObjDesc == NULL)) {
+    ASSERT (0);
+    return EFI_INVALID_PARAMETER;
+  }
+
+  CmObjDesc = AllocateZeroPool (sizeof (CM_OBJ_DESCRIPTOR));
+  if (CmObjDesc == NULL) {
+    ASSERT (0);
+    return EFI_OUT_OF_RESOURCES;
+  }
+
+  DataBuffer = AllocateCopyPool (Size, Data);
+  if (DataBuffer == NULL) {
+    ASSERT (0);
+    return EFI_OUT_OF_RESOURCES;
[SAMI] CmObjDescmust be freed here otherwise there would be a memory leak.
+  }
+
+  CmObjDesc->ObjectId = ObjectId;
+  CmObjDesc->Count = Count;
+  CmObjDesc->Data = DataBuffer;
+  CmObjDesc->Size = Size;
+
+  *NewCmObjDesc = CmObjDesc;
+
+  return EFI_SUCCESS;
+}
+
+/** Free resources allocated for the CM_OBJ_DESCRIPTOR.
+
+  @param [in] CmObjDesc           Pointer to the CM_OBJ_DESCRIPTOR.
+
+  @retval EFI_SUCCESS             The function completed successfully.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+**/
+EFI_STATUS
+EFIAPI
+FreeCmObjDesc (
+  IN CM_OBJ_DESCRIPTOR  * CmObjDesc
+  )
+{
+  if (CmObjDesc == NULL) {
+    ASSERT (0);
+    return EFI_INVALID_PARAMETER;
+  }
+
+  if (CmObjDesc->Data != NULL) {
+    FreePool (CmObjDesc->Data);
+  }
+
+  FreePool (CmObjDesc);
+  return EFI_SUCCESS;
+}
+
+/** Add a single CmObj to the Configuration Manager.
+
+  @param  [in]  FdtParserHandle   A handle to the parser instance.
+  @param  [in]  ObjectId          CmObj ObjectId.
+  @param  [in]  Data              CmObj Data.
+  @param  [in]  Size              CmObj Size.
+  @param  [out] Token             If provided and success,
+                                  token generated for this CmObj.
+
+  @retval EFI_SUCCESS             The function completed successfully.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+**/
+EFI_STATUS
+EFIAPI
+AddSingleCmObj (
+  IN  CONST FDT_HW_INFO_PARSER_HANDLE   FdtParserHandle,
+  IN        CM_OBJECT_ID                ObjectId,
+  IN        VOID                        *Data,
+  IN        UINT32                      Size,
+  OUT       CM_OBJECT_TOKEN             *Token    OPTIONAL
+  )
+{
+  EFI_STATUS          Status;
+  CM_OBJ_DESCRIPTOR   CmObjDesc;
+
+  if ((FdtParserHandle == NULL)             ||
+      (FdtParserHandle->HwInfoAdd == NULL)  ||
+      (Data == NULL)                        ||
+      (Size == 0)) {
+    ASSERT (0);
+    return EFI_INVALID_PARAMETER;
+  }
+
+  CmObjDesc.ObjectId = ObjectId;
+  CmObjDesc.Count = 1;
+  CmObjDesc.Data = Data;
+  CmObjDesc.Size = Size;
+
+  // Add the CmObj.
+  // Don't ask for a token.
+  Status = FdtParserHandle->HwInfoAdd (
+                              FdtParserHandle,
+                              FdtParserHandle->Context,
+                              &CmObjDesc,
+                              Token
+                              );
+  if (EFI_ERROR (Status)) {
+    ASSERT (0);
+  }
[SAMI] I think ASSERT_EFI_ERROR() can be used here.
+  return Status;
+}
+
+/** Add multiple CmObj to the Configuration Manager.
+
+  @param  [in]  FdtParserHandle   A handle to the parser instance.
+  @param  [in]  CmObjDesc         CmObjDesc containing multiple CmObj
+                                  to add.
+  @param  [in]  TokenCount        If provided, count of entries in the
+                                  TokenTable.
+  @param  [out] TokenTable        If provided and success,
+                                  token generated for these CmObj.
+                                  Address of an array of CM_OBJECT_TOKEN
+                                  with the same number of elements as the
+                                  CmObjDesc.
+
+  @retval EFI_SUCCESS             The function completed successfully.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+**/
+EFI_STATUS
+EFIAPI
+AddMultipleCmObj (
+  IN  CONST FDT_HW_INFO_PARSER_HANDLE   FdtParserHandle,
+  IN  CONST CM_OBJ_DESCRIPTOR           *CmObjDesc,
+  IN        UINT32                      TokenCount,   OPTIONAL
+  OUT       CM_OBJECT_TOKEN             *TokenTable   OPTIONAL
+  )
+{
+  EFI_STATUS          Status;
+  UINT32              Index;
+  UINT32              Count;
+  VOID              * Data;
+  UINT32              Size;
+  CM_OBJ_DESCRIPTOR   SingleCmObjDesc;
+
+  if ((FdtParserHandle == NULL)             ||
+      (FdtParserHandle->HwInfoAdd == NULL)  ||
+      (CmObjDesc == NULL)                   ||
+      (CmObjDesc->Count == 0)               ||
+      (CmObjDesc->Data == NULL)             ||
+      (CmObjDesc->Size == 0)){
+    ASSERT (0);
+    return EFI_INVALID_PARAMETER;
+  }
+
+  Count = CmObjDesc->Count;
+  Data = CmObjDesc->Data;
+  Size = CmObjDesc->Size / Count;
+
+  SingleCmObjDesc.ObjectId = CmObjDesc->ObjectId;
+  SingleCmObjDesc.Count = 1;
+  SingleCmObjDesc.Size = Size;
+
+  for (Index = 0; Index < Count; Index++) {
+    SingleCmObjDesc.Data = Data + Index * Size;
[SAMI] Data needs to be typecasted to UINT8 for the pointer arithmetic to work. Also, enclose Index * Size in parenthesis.
+    // Add the CmObj.
+    Status = FdtParserHandle->HwInfoAdd (
+                                FdtParserHandle,
+                                FdtParserHandle->Context,
+                                &SingleCmObjDesc,
+                                (TokenTable != NULL) ?
+                                  &TokenTable[Index] :
+                                  NULL
+                                );
+    if (EFI_ERROR (Status)) {
+      ASSERT (0);
+      return Status;
+    }
+  } // for
+
+  return Status;
+}
+
+/** Add multiple CmObj to the Configuration Manager.
+
+  Get one token referencing a EArmObjCmRef CmObj itself referencing
+  the input CmObj. In the table below, RefToken is returned.
+
+  Token referencing an      Array of tokens             Array of CmObj
+  array of EArmObjCmRef     referencing each            from the input:
+  CmObj:                    CmObj from the input:
+
+  RefToken         --->     CmObjToken[0]        --->   CmObj[0]
+                            CmObjToken[1]        --->   CmObj[1]
+                            CmObjToken[2]        --->   CmObj[2]
+
+  @param  [in]  FdtParserHandle   A handle to the parser instance.
+  @param  [in]  CmObjDesc         CmObjDesc containing multiple CmObj
+                                  to add.
+  @param  [out] Token             If success, token referencing an array
+                                  of EArmObjCmRef CmObj, themselves
+                                  referencing the input CmObjs.
+
+  @retval EFI_SUCCESS             The function completed successfully.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+  @retval EFI_OUT_OF_RESOURCES    An allocation has failed.
+**/
+EFI_STATUS
+EFIAPI
+AddMultipleCmObjWithCmObjRef (
+  IN  CONST FDT_HW_INFO_PARSER_HANDLE     FdtParserHandle,
+  IN  CM_OBJ_DESCRIPTOR                 * CmObjDesc,
+  OUT CM_OBJECT_TOKEN                   * Token
+  )
+{
+  EFI_STATUS          Status;
+  CM_OBJ_DESCRIPTOR   CmObjRef;
+  CM_OBJECT_TOKEN    *TokenTable;
+  INT32               TokenTableSize;
+
+  if ((FdtParserHandle == NULL)             ||
+      (FdtParserHandle->HwInfoAdd == NULL)  ||
+      (CmObjDesc == NULL)                   ||
+      (CmObjDesc->Count == 0)               ||
+      (CmObjDesc->Data == NULL)             ||
+      (CmObjDesc->Size == 0)                ||
+      (Token == NULL)) {
+    ASSERT (0);
+    return EFI_INVALID_PARAMETER;
+  }
+
+  // Allocate a buffer to store the tokens.
+  TokenTableSize = CmObjDesc->Count * sizeof (CM_OBJECT_TOKEN);
+  TokenTable = AllocateZeroPool (TokenTableSize);
+  if (TokenTable == NULL) {
+    ASSERT (0);
+    return EFI_OUT_OF_RESOURCES;
+  }
+
+  // Add the input CmObjs.
+  Status = AddMultipleCmObj (
+             FdtParserHandle,
+             CmObjDesc,
+             CmObjDesc->Count,
+             TokenTable
+             );
+  if (EFI_ERROR (Status)) {
+    ASSERT (0);
+    goto exit_handler;
+  }
+
+  CmObjRef.ObjectId = CREATE_CM_ARM_OBJECT_ID (EArmObjCmRef);
+  CmObjRef.Data = TokenTable;
+  CmObjRef.Count = CmObjDesc->Count;
+  CmObjRef.Size = TokenTableSize;
+
+  // Add the array of EArmObjCmRef CmObjs.
+  Status = FdtParserHandle->HwInfoAdd (
+                              FdtParserHandle,
+                              FdtParserHandle->Context,
+                              &CmObjRef,
+                              Token
+                              );
+  if (EFI_ERROR (Status)) {
+    ASSERT (0);
+  }
[SAMI] I think ASSERT_EFI_ERROR() can be used here.
+
+exit_handler:
+  FreePool (TokenTable);
+  return Status;
+}
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/CmObjectDescUtility.h b/DynamicTablesPkg/Library/FdtHwInfoParserLib/CmObjectDescUtility.h
new file mode 100644
index 000000000000..34439c716fb3
--- /dev/null
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/CmObjectDescUtility.h
@@ -0,0 +1,131 @@
+/** @file
+  Configuration manager Object Descriptor Utility.
+
+  Copyright (c) 2021, ARM Limited. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef CM_OBJECT_DESC_UTILITY_H_
+#define CM_OBJECT_DESC_UTILITY_H_
+
+#include <ConfigurationManagerObject.h>
+
+#include "FdtHwInfoParser.h"
+
+/** Create a CM_OBJ_DESCRIPTOR.
+
+  @param [in]  ObjectId       CM_OBJECT_ID of the node.
+  @param [in]  Count          Number of CmObj stored in the
+                              data field.
+  @param [in]  Data           Pointer to one or more CmObj objects.
+                              The content of this Data buffer is copied.
+  @param [in]  Size           Size of the Data buffer.
+  @param [out] NewCmObjDesc   The created CM_OBJ_DESCRIPTOR.
+
+  @retval EFI_SUCCESS             The function completed successfully.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+  @retval EFI_OUT_OF_RESOURCES    An allocation has failed.
+**/
+EFI_STATUS
+EFIAPI
+CreateCmObjDesc (
+  IN  CM_OBJECT_ID          ObjectId,
+  IN  UINT32                Count,
+  IN  VOID                * Data,
+  IN  UINT32                Size,
+  OUT CM_OBJ_DESCRIPTOR  ** NewCmObjDesc
+  );
+
+/** Free resources allocated for the CM_OBJ_DESCRIPTOR.
+
+  @param [in] CmObjDesc           Pointer to the CM_OBJ_DESCRIPTOR.
+
+  @retval EFI_SUCCESS             The function completed successfully.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+**/
+EFI_STATUS
+EFIAPI
+FreeCmObjDesc (
+  IN CM_OBJ_DESCRIPTOR  * CmObjDesc
+  );
+
+/** Add a single CmObj to the Configuration Manager.
+
+  @param  [in]  FdtParserHandle   A handle to the parser instance.
+  @param  [in]  ObjectId          CmObj ObjectId.
+  @param  [in]  Data              CmObj Data.
+  @param  [in]  Size              CmObj Size.
+  @param  [out] Token             If provided and success,
+                                  token generated for this CmObj.
+
+  @retval EFI_SUCCESS             The function completed successfully.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+**/
+EFI_STATUS
+EFIAPI
+AddSingleCmObj (
+  IN  CONST FDT_HW_INFO_PARSER_HANDLE   FdtParserHandle,
+  IN        CM_OBJECT_ID                ObjectId,
+  IN        VOID                        *Data,
+  IN        UINT32                      Size,
+  OUT       CM_OBJECT_TOKEN             *Token    OPTIONAL
+  );
+
+/** Add multiple CmObj to the Configuration Manager.
+
+  @param  [in]  FdtParserHandle   A handle to the parser instance.
+  @param  [in]  CmObjDesc         CmObjDesc containing multiple CmObj
+                                  to add.
+  @param  [in]  TokenCount        If provided, count of entries in the
+                                  TokenTable.
+  @param  [out] TokenTable        If provided and success,
+                                  token generated for these CmObj.
+                                  Address of an array of CM_OBJECT_TOKEN
+                                  with the same number of elements as the
+                                  CmObjDesc.
+
+  @retval EFI_SUCCESS             The function completed successfully.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+**/
+EFI_STATUS
+EFIAPI
+AddMultipleCmObj (
+  IN  CONST FDT_HW_INFO_PARSER_HANDLE   FdtParserHandle,
+  IN  CONST CM_OBJ_DESCRIPTOR           *CmObjDesc,
+  IN        UINT32                      TokenCount,   OPTIONAL
+  OUT       CM_OBJECT_TOKEN             *TokenTable   OPTIONAL
+  );
+
+/** Add multiple CmObj to the Configuration Manager.
+
+  Get one token referencing a EArmObjCmRef CmObj itself referencing
+  the input CmObj. In the table below, RefToken is returned.
+
+  Token referencing an      Array of tokens             Array of CmObj
+  array of EArmObjCmRef     referencing each            from the input:
+  CmObj:                    CmObj from the input:
+
+  RefToken         --->     CmObjToken[0]        --->   CmObj[0]
+                            CmObjToken[1]        --->   CmObj[1]
+                            CmObjToken[2]        --->   CmObj[2]
+
+  @param  [in]  FdtParserHandle   A handle to the parser instance.
+  @param  [in]  CmObjDesc         CmObjDesc containing multiple CmObj
+                                  to add.
+  @param  [out] Token             If success, token referencing an array
+                                  of EArmObjCmRef CmObj, themselves
+                                  referencing the input CmObjs.
+
+  @retval EFI_SUCCESS             The function completed successfully.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+  @retval EFI_OUT_OF_RESOURCES    An allocation has failed.
+**/
+EFI_STATUS
+EFIAPI
+AddMultipleCmObjWithCmObjRef (
+  IN  CONST FDT_HW_INFO_PARSER_HANDLE     FdtParserHandle,
+  IN  CM_OBJ_DESCRIPTOR                 * CmObjDesc,
+  OUT CM_OBJECT_TOKEN                   * Token
+  );
+
+#endif // CM_OBJECT_DESC_UTILITY_H_

--------------09A0839E5CD9ECAE54B6E6E4--