From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=217.140.106.50; helo=cam-smtp0.cambridge.arm.com; envelope-from=sami.mujawar@arm.com; receiver=edk2-devel@lists.01.org Received: from cam-smtp0.cambridge.arm.com (unknown [217.140.106.50]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 89A6F21B02822 for ; Thu, 24 Jan 2019 08:40:41 -0800 (PST) Received: from E107187.Arm.com (E107187.Arm.com [10.1.195.55]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id x0OFifCZ013695; Thu, 24 Jan 2019 15:44:45 GMT From: Sami Mujawar To: edk2-devel@lists.01.org Cc: alexei.fedorov@arm.com, leif.lindholm@linaro.org, Matteo.Carlini@arm.com, Stephanie.Hughes-Fitt@arm.com, nd@arm.com Date: Thu, 24 Jan 2019 15:44:24 +0000 Message-Id: <20190124154436.21996-11-sami.mujawar@arm.com> X-Mailer: git-send-email 2.11.0.windows.3 In-Reply-To: <20190124154436.21996-1-sami.mujawar@arm.com> References: <20190124154436.21996-1-sami.mujawar@arm.com> Subject: [PATCH v2 10/22] DynamicTablesPkg: Configuration Manager Helper X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jan 2019 16:40:41 -0000 X-List-Received-Date: Thu, 24 Jan 2019 16:40:41 -0000 X-List-Received-Date: Thu, 24 Jan 2019 16:40:41 -0000 X-List-Received-Date: Thu, 24 Jan 2019 16:40:41 -0000 X-List-Received-Date: Thu, 24 Jan 2019 16:40:41 -0000 X-List-Received-Date: Thu, 24 Jan 2019 16:40:41 -0000 X-List-Received-Date: Thu, 24 Jan 2019 16:40:41 -0000 X-List-Received-Date: Thu, 24 Jan 2019 16:40:41 -0000 This patch defines a helper macro 'GET_OBJECT_LIST()' that expands to a function that uses the configuration manager protocol to retrieve configuration manager object(s). Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Sami Mujawar --- DynamicTablesPkg/Include/ConfigurationManagerHelper.h | 132 ++++++++++++++++++++ 1 file changed, 132 insertions(+) diff --git a/DynamicTablesPkg/Include/ConfigurationManagerHelper.h b/DynamicTablesPkg/Include/ConfigurationManagerHelper.h new file mode 100644 index 0000000000000000000000000000000000000000..cf9960040908d4aeb540714c1a4cf3d720c27029 --- /dev/null +++ b/DynamicTablesPkg/Include/ConfigurationManagerHelper.h @@ -0,0 +1,132 @@ +/** @file + + Copyright (c) 2017 - 2019, ARM Limited. All rights reserved. + + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Glossary: + - Cm or CM - Configuration Manager + - Obj or OBJ - Object +**/ + +#ifndef CONFIGURATION_MANAGER_HELPER_H_ +#define CONFIGURATION_MANAGER_HELPER_H_ + +/** The GET_OBJECT_LIST macro expands to a function that is used to retrieve + an object or an object list from the Configuration Manager using the + Configuration Manager Protocol interface. + + The macro expands to a function which has the following prototype: + + STATIC + EFI_STATUS + EFIAPI + Get ( + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol, + IN CONST CM_OBJECT_TOKEN Token OPTIONAL, + OUT Type ** List, + OUT UINT32 * Count OPTIONAL + ); + + Generated function parameters: + @param [in] CfgMgrProtocol Pointer to the Configuration Manager protocol + interface. + @param [in] Token Reference token for the Object. + @param [out] List Pointer to the Object list. + @param [out] Count Count of the objects returned in the list. + + Macro Parameters: + @param [in] CmObjectNameSpace The Object Namespace + @param [in] CmObjectId Object Id. + @param [in] Type Structure used to describe the Object. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND The required object information is not found. + @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration + Manager is less than the Object size for the + requested object. +**/ +#define GET_OBJECT_LIST(CmObjectNameSpace, CmObjectId, Type) \ +STATIC \ +EFI_STATUS \ +EFIAPI \ +Get##CmObjectId ( \ + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol, \ + IN CONST CM_OBJECT_TOKEN Token OPTIONAL, \ + OUT Type ** List, \ + OUT UINT32 * CONST Count OPTIONAL \ + ) \ +{ \ + EFI_STATUS Status; \ + CM_OBJ_DESCRIPTOR CmObjectDesc; \ + UINT32 ObjCount = 0; \ + if (List == NULL) { \ + Status = EFI_INVALID_PARAMETER; \ + DEBUG (( \ + DEBUG_ERROR, \ + "ERROR: Get" #CmObjectId ": Invalid out parameter for" \ + " object list. Status = %r\n", \ + Status \ + )); \ + goto error_handler; \ + } \ + Status = CfgMgrProtocol->GetObject ( \ + CfgMgrProtocol, \ + CREATE_CM_OBJECT_ID ( \ + CmObjectNameSpace, \ + CmObjectId \ + ), \ + Token, \ + &CmObjectDesc \ + ); \ + if (EFI_ERROR (Status)) { \ + DEBUG (( \ + DEBUG_INFO, \ + "INFO: Get" #CmObjectId ": Platform does not implement " \ + #CmObjectId ". Status = %r\n", \ + Status \ + )); \ + *List = NULL; \ + goto error_handler; \ + } \ + if (CmObjectDesc.ObjectId != \ + CREATE_CM_OBJECT_ID (CmObjectNameSpace, CmObjectId)) { \ + DEBUG (( \ + DEBUG_ERROR, \ + "ERROR: Get" #CmObjectId ": " #CmObjectId \ + ": Invalid ObjectId = 0x%x\n, expected Id = 0x%x\n", \ + CmObjectDesc.ObjectId, \ + CREATE_CM_OBJECT_ID (CmObjectNameSpace, CmObjectId) \ + )); \ + ASSERT (FALSE); \ + Status = EFI_INVALID_PARAMETER; \ + goto error_handler; \ + } \ + if (CmObjectDesc.Size < (sizeof (Type) * CmObjectDesc.Count)) { \ + DEBUG (( \ + DEBUG_ERROR, \ + "ERROR: Get" #CmObjectId ": " #CmObjectId \ + ": Buffer too small, size = 0x%x\n", \ + CmObjectDesc.Size \ + )); \ + ASSERT (FALSE); \ + Status = EFI_BAD_BUFFER_SIZE; \ + goto error_handler; \ + } \ + ObjCount = CmObjectDesc.Count; \ + *List = (Type*)CmObjectDesc.Data; \ +error_handler: \ + if (Count != NULL) { \ + *Count = ObjCount; \ + } \ + return Status; \ +} + +#endif // CONFIGURATION_MANAGER_HELPER_H_ -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'