From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (EUR04-HE1-obe.outbound.protection.outlook.com [40.107.7.54]) by mx.groups.io with SMTP id smtpd.web12.8859.1611322191088250385 for ; Fri, 22 Jan 2021 05:29:51 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=k8SmK8zM; spf=pass (domain: arm.com, ip: 40.107.7.54, 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=Nh9B1IaxcqNEqkUFsMLRAZCifOo+w8sFLdd3DOSiKG4=; b=k8SmK8zM03U8BFcZ2V0ycJb1cLSUsoje253K9LvHHnO3HDZ1xVslE6Fx1urvsVgN85u5QiKw8b7hDUS4HKkjEAMzp2b9YL+r1oTh0nW64vNyi7yB4Vz6JiJXKJOOGISxndnye95COr1g2D/SW3Z+ZDb8RyEkaIkcAik8SYo+S/Q= Received: from AM0PR10CA0118.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:e6::35) by PR3PR08MB5739.eurprd08.prod.outlook.com (2603:10a6:102:8e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.13; Fri, 22 Jan 2021 13:29:48 +0000 Received: from AM5EUR03FT047.eop-EUR03.prod.protection.outlook.com (2603:10a6:208:e6:cafe::2c) by AM0PR10CA0118.outlook.office365.com (2603:10a6:208:e6::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.12 via Frontend Transport; Fri, 22 Jan 2021 13:29:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; 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 AM5EUR03FT047.mail.protection.outlook.com (10.152.16.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11 via Frontend Transport; Fri, 22 Jan 2021 13:29:47 +0000 Received: ("Tessian outbound e989e14f9207:v71"); Fri, 22 Jan 2021 13:29:47 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 4d6aef7e354eb282 X-CR-MTA-TID: 64aa7808 Received: from 8893f11aa350.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 9B22D093-4F12-4DF6-B99B-33D650192B47.1; Fri, 22 Jan 2021 13:29:41 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 8893f11aa350.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 22 Jan 2021 13:29:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jbS/nffjaXPLUY768iAO7EwR5ip7/7KNRgVUvJ6utIBHIWxmyQeBsrYfvOoliF7kDVQsRV2pjtQEhcusDDwZ/G4pVOBuLci99tWcT4+1txinBN+M3vBP5t7Ak3dfjuxwZKhig2JfeHaZSW3S/0UFSvMoY4jlMYGCQufoKdpPM6TG8UnTa2Xtw15KX0GXVA+hPw0NdeER10xxGWjpuw24hYjs3VmezHeFB6HlP4Bea8SdPG9zGgjFxclZk7/bAPaP2cgsFutLpPEGqyY+IV3xr2xoUsGC9y7ej2AS3VomX7p9ExSRhC+8C4YftHK/+6e3BNvbyTv2+adqtnjOnsJVMg== 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-SenderADCheck; bh=Nh9B1IaxcqNEqkUFsMLRAZCifOo+w8sFLdd3DOSiKG4=; b=TybuOa4Mi7OKNSzF2Y3CZMnG6/x5dhPBVOanxQWT4peT6V/S10mssSzncQ7J7ep5NJKt7HnvTYCQGJSfCg+6aCq1Dz1AahQAiZE1LoC0P2MoY59j/O9NcsiHb498N4BK08u7Nd64/E281G/jKhuDwB33TSm4OZSEHDTOdAuH9fsCpAv6k51rEuD4IG1r8/cXtiVRcFlNTNP5CXmwJ8QQ/YTBx9ozK8YOvKdA7TnNrTwneGnCo7V18d1WfnkzMxljkWlhwxZB1ESY/nknq7xgUxcKzFGSJQ6/FrQ0LeZF7x4hH+2N1upb5Fc9l4uOYF0wo83gGS6RUCIONLc6GEGLrg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); 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=Nh9B1IaxcqNEqkUFsMLRAZCifOo+w8sFLdd3DOSiKG4=; b=k8SmK8zM03U8BFcZ2V0ycJb1cLSUsoje253K9LvHHnO3HDZ1xVslE6Fx1urvsVgN85u5QiKw8b7hDUS4HKkjEAMzp2b9YL+r1oTh0nW64vNyi7yB4Vz6JiJXKJOOGISxndnye95COr1g2D/SW3Z+ZDb8RyEkaIkcAik8SYo+S/Q= Received: from DB6PR0202CA0014.eurprd02.prod.outlook.com (2603:10a6:4:29::24) by AM8PR08MB5618.eurprd08.prod.outlook.com (2603:10a6:20b:1d7::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.13; Fri, 22 Jan 2021 13:29:40 +0000 Received: from DB5EUR03FT005.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:29:cafe::c1) by DB6PR0202CA0014.outlook.office365.com (2603:10a6:4:29::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.12 via Frontend Transport; Fri, 22 Jan 2021 13:29:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT005.mail.protection.outlook.com (10.152.20.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3784.11 via Frontend Transport; Fri, 22 Jan 2021 13:29:40 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2044.4; Fri, 22 Jan 2021 13:29:38 +0000 Received: from E107187.Arm.com (10.57.3.168) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2044.4 via Frontend Transport; Fri, 22 Jan 2021 13:29:37 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , Subject: [PATCH edk2-platforms v1 2/6] Platform/ARM: Juno: Remove usage of function macros Date: Fri, 22 Jan 2021 13:29:31 +0000 Message-ID: <20210122132935.22484-3-sami.mujawar@arm.com> X-Mailer: git-send-email 2.11.0.windows.3 In-Reply-To: <20210122132935.22484-1-sami.mujawar@arm.com> References: <20210122132935.22484-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c40324a5-0151-4b5d-90de-08d8bed9c9c3 X-MS-TrafficTypeDiagnostic: AM8PR08MB5618:|PR3PR08MB5739: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:2201;OLM:2201; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: Z9hXJdyVyxvK/1CsrDht1TQQUD5fJQWOsN6ZPcmBCMbyOpBCqbjWXoCjDAqoEXPwON711pSfeEXyV72e69OWw4LmmdoJKwTWUyE+ekBR05jURUaiiikCj4isL4p8C7NJ9fl0jkRnNtHOg1p+ioYfYdqSgyxebhhDuOdVT9D+u7hPvSW64jgegKqAr8vmKDnOQrbVLp3e8xKqvxJ+XT+lFBS5bL+dYcPIHJdvBd7ZO+IfxWiw8+TeHgXZyNbOup7+WgiDZOB2bnHb84qXFJImdowqhh6aavQZTzWO1JhQDTeCqzMoBCsq/1Ct2JsRkM+JPnYujrIsWDXASjxpkOJLfEynQo3fIdcRTPRHsiy5ZZk6heFwbLeGEnEIDDsU1SIFwr6rs9rD252qhzMft33pvvbJyqrr6dk0swev+4z4BLJXrkXDYz//BvWgvA82j581Xg+4vRpBhngGWgsxe5H9UAAfb2m6jhdeQdJh/8Il2DtdiuprlhdtLnfZVz8ZRnJMdNOvx9UxM2Iw55zLN6LJWy4zHESEz2beh0CiQwOiMIFJsUhsYnp7USLYWuSW5e2X X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(346002)(39840400004)(396003)(376002)(136003)(46966006)(30864003)(86362001)(2906002)(8936002)(6666004)(5660300002)(47076005)(82310400003)(356005)(316002)(966005)(36756003)(1076003)(83380400001)(81166007)(44832011)(4326008)(426003)(336012)(478600001)(2616005)(26005)(6916009)(70206006)(54906003)(70586007)(8676002)(186003)(7696005)(36610700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB5618 Return-Path: Sami.Mujawar@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT047.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: d3eb3854-f00e-493f-4338-08d8bed9c565 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1fx33FH1CRXbr9wG+1LKWba5JbWviVRoP1s0yuEOSdYz6vDmLmrhZvVSDWvwga/dEd9ayzsIAkBK6SxCn6EoTd1OWvdKTQMBzu3RXkprSiyXB0oRS38mopXO0frFBqSSwBwZK3fqIDAqjGTfWZaeF5PB8Is9sKe9mSTRsfC4WVLXP5itSfj7tWGn6zFH1apn0LdRnwJvfVHpHLs3FK3ElOeruvcksoLGLSaDh86iO86CjTdWZuGNok5bJMnNiAoFMjYEKiqO+ES/uzg4RoGBTSXAiaOdQ6+Ioou0zSemxXLMaN1024SAIgTRUW7EQF6P010sZTwaWsPFkjQ4IkgtHR4wGI1VXTIY1o2rbZdZf3NrAB7FJ3LMbdZlFJzHDIeOV3wz90NoiKjyMID2XJoq8ascytuLFCwnNpmiS4sGzxDDgPpk8RSWWFKXNXyKcsNx3oRogmimpxBVDpwV3KC9MunlDzKnGgQ4J7VNGaq/p7YhmebxxdLUQrL+EETQ7osb8I0vJJfEjMwlbP9LLWyq0VaLgEtmiUf+fvu2ZvPN6SY= 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:(4636009)(39840400004)(346002)(376002)(136003)(396003)(46966006)(478600001)(4326008)(336012)(966005)(70586007)(83380400001)(6666004)(81166007)(7696005)(6916009)(70206006)(426003)(86362001)(47076005)(2616005)(2906002)(36756003)(54906003)(44832011)(5660300002)(8676002)(26005)(82310400003)(30864003)(186003)(1076003)(8936002)(316002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2021 13:29:47.4403 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c40324a5-0151-4b5d-90de-08d8bed9c9c3 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: AM5EUR03FT047.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR08MB5739 Content-Type: text/plain The Configuration Manager code for Juno uses function macros to prepare and return CM objects. However, according to section 5.5.2.1 of the edk2 coding standard, use of functional macros is not allowed. See https://edk2-docs.gitbook.io/edk-ii-c-coding-standards-specification/ 5_source_files/55_preprocessor_directives#5-5-2-1-functional-macros-are- generally-discouraged Therefore, replace the function macros with static helper functions. Signed-off-by: Sami Mujawar --- Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c | 448 ++++++++++++++------ Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.h | 104 +---- 2 files changed, 336 insertions(+), 216 deletions(-) diff --git a/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c b/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c index 913cffc9b994319065b5292b0d28970a0a0d8320..8d92a8a666af4c5555343a929cb2d5063e54ffd5 100644 --- a/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c +++ b/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c @@ -1,7 +1,7 @@ /** @file Configuration Manager Dxe - Copyright (c) 2017 - 2020, Arm Limited. All rights reserved.
+ Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent @@ -559,6 +559,149 @@ EDKII_PLATFORM_REPOSITORY_INFO ArmJunoPlatformRepositoryInfo = { } }; +/** A helper function for returning the Configuration Manager Objects. + + @param [in] CmObjectId The Configuration Manager Object ID. + @param [in] Object Pointer to the Object(s). + @param [in] ObjectSize Total size of the Object(s). + @param [in] ObjectCount Number of Objects. + @param [in, out] CmObjectDesc Pointer to the Configuration Manager Object + descriptor describing the requested Object. + + @retval EFI_SUCCESS Success. +**/ +STATIC +EFI_STATUS +EFIAPI +HandleCmObject ( + IN CONST CM_OBJECT_ID CmObjectId, + IN VOID * Object, + IN CONST UINTN ObjectSize, + IN CONST UINTN ObjectCount, + IN OUT CM_OBJ_DESCRIPTOR * CONST CmObjectDesc + ) +{ + CmObjectDesc->ObjectId = CmObjectId; + CmObjectDesc->Size = ObjectSize; + CmObjectDesc->Data = (VOID*)Object; + CmObjectDesc->Count = ObjectCount; + DEBUG (( + DEBUG_INFO, + "INFO: CmObjectId = %x, Ptr = 0x%p, Size = %d, Count = %d\n", + CmObjectId, + CmObjectDesc->Data, + CmObjectDesc->Size, + CmObjectDesc->Count + )); + return EFI_SUCCESS; +} + +/** A helper function for returning the Configuration Manager Objects that + match the token. + + @param [in] This Pointer to the Configuration Manager Protocol. + @param [in] CmObjectId The Configuration Manager Object ID. + @param [in] Object Pointer to the Object(s). + @param [in] ObjectSize Total size of the Object(s). + @param [in] ObjectCount Number of Objects. + @param [in] Token A token identifying the object. + @param [in] HandlerProc A handler function to search the object + referenced by the token. + @param [in, out] CmObjectDesc Pointer to the Configuration Manager Object + descriptor describing the requested Object. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND The required object information is not found. +**/ +STATIC +EFI_STATUS +EFIAPI +HandleCmObjectRefByToken ( + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST This, + IN CONST CM_OBJECT_ID CmObjectId, + IN VOID * Object, + IN CONST UINTN ObjectSize, + IN CONST UINTN ObjectCount, + IN CONST CM_OBJECT_TOKEN Token, + IN CONST CM_OBJECT_HANDLER_PROC HandlerProc, + IN OUT CM_OBJ_DESCRIPTOR * CONST CmObjectDesc + ) +{ + EFI_STATUS Status; + CmObjectDesc->ObjectId = CmObjectId; + if (Token == CM_NULL_TOKEN) { + CmObjectDesc->Size = ObjectSize; + CmObjectDesc->Data = (VOID*)Object; + CmObjectDesc->Count = ObjectCount; + Status = EFI_SUCCESS; + } else { + Status = HandlerProc (This, CmObjectId, Token, CmObjectDesc); + } + + DEBUG (( + DEBUG_INFO, + "INFO: Token = 0x%p, CmObjectId = %x, Ptr = 0x%p, Size = %d, Count = %d\n", + (VOID*)Token, + CmObjectId, + CmObjectDesc->Data, + CmObjectDesc->Size, + CmObjectDesc->Count + )); + return Status; +} + +/** A helper function for returning Configuration Manager Object(s) referenced + by token when the entire platform repository is in scope and the + CM_NULL_TOKEN value is not allowed. + + @param [in] This Pointer to the Configuration Manager Protocol. + @param [in] CmObjectId The Configuration Manager Object ID. + @param [in] Token A token identifying the object. + @param [in] HandlerProc A handler function to search the object(s) + referenced by the token. + @param [in, out] CmObjectDesc Pointer to the Configuration Manager Object + descriptor describing the requested Object. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND The required object information is not found. +**/ +STATIC +EFI_STATUS +EFIAPI +HandleCmObjectSearchPlatformRepo ( + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST This, + IN CONST CM_OBJECT_ID CmObjectId, + IN CONST CM_OBJECT_TOKEN Token, + IN CONST CM_OBJECT_HANDLER_PROC HandlerProc, + IN OUT CM_OBJ_DESCRIPTOR * CONST CmObjectDesc + ) +{ + EFI_STATUS Status; + CmObjectDesc->ObjectId = CmObjectId; + if (Token == CM_NULL_TOKEN) { + DEBUG (( + DEBUG_ERROR, + "ERROR: CM_NULL_TOKEN value is not allowed when searching" + " the entire platform repository.\n" + )); + return EFI_INVALID_PARAMETER; + } + + Status = HandlerProc (This, CmObjectId, Token, CmObjectDesc); + DEBUG (( + DEBUG_INFO, + "INFO: Token = 0x%p, CmObjectId = %x, Ptr = 0x%p, Size = %d, Count = %d\n", + CmObjectId, + (VOID*)Token, + CmObjectDesc->Data, + CmObjectDesc->Size, + CmObjectDesc->Count + )); + return Status; +} + /** Initialize the platform configuration repository. @param [in] This Pointer to the Configuration Manager Protocol. @@ -760,46 +903,42 @@ GetStandardNameSpaceObject ( EDKII_PLATFORM_REPOSITORY_INFO * PlatformRepo; UINT32 TableCount; - Status = EFI_SUCCESS; if ((This == NULL) || (CmObject == NULL)) { ASSERT (This != NULL); ASSERT (CmObject != NULL); return EFI_INVALID_PARAMETER; } + + Status = EFI_NOT_FOUND; PlatformRepo = This->PlatRepoInfo; switch (GET_CM_OBJECT_ID (CmObjectId)) { - HANDLE_CM_OBJECT ( - EStdObjCfgMgrInfo, - CmObjectId, - PlatformRepo->CmInfo, - 1 - ); + case EStdObjCfgMgrInfo: + Status = HandleCmObject ( + CmObjectId, + &PlatformRepo->CmInfo, + sizeof (PlatformRepo->CmInfo), + 1, + CmObject + ); + break; case EStdObjAcpiTableList: - CmObject->ObjectId = CmObjectId; - TableCount = sizeof (PlatformRepo->CmAcpiTableList) / - sizeof (PlatformRepo->CmAcpiTableList[0]); - if (PlatformRepo->JunoRevision != JUNO_REVISION_R0) { - CmObject->Size = sizeof (PlatformRepo->CmAcpiTableList); - CmObject->Count = TableCount; - } else { + TableCount = ARRAY_SIZE (PlatformRepo->CmAcpiTableList); + if (PlatformRepo->JunoRevision == JUNO_REVISION_R0) { /* The last 2 tables in the ACPI table list enable PCIe support. - Reduce the CmObject size so that the PCIe specific ACPI + Reduce the TableCount so that the PCIe specific ACPI tables are not installed on Juno R0 */ - CmObject->Size = sizeof (PlatformRepo->CmAcpiTableList[0]) * - (TableCount - 2); - CmObject->Count = TableCount - 2; + TableCount -= 2; } - CmObject->Data = (VOID*)&PlatformRepo->CmAcpiTableList; - DEBUG (( - DEBUG_INFO, - "EStdObjAcpiTableList: Ptr = 0x%p. Size = %d, Count = %d\n", - CmObject->Data, - CmObject->Size, - CmObject->Count - )); + Status = HandleCmObject ( + CmObjectId, + PlatformRepo->CmAcpiTableList, + (sizeof (PlatformRepo->CmAcpiTableList[0]) * TableCount), + TableCount, + CmObject + ); break; default: { @@ -842,120 +981,171 @@ GetArmNameSpaceObject ( EFI_STATUS Status; EDKII_PLATFORM_REPOSITORY_INFO * PlatformRepo; - Status = EFI_SUCCESS; if ((This == NULL) || (CmObject == NULL)) { ASSERT (This != NULL); ASSERT (CmObject != NULL); return EFI_INVALID_PARAMETER; } + + Status = EFI_NOT_FOUND; PlatformRepo = This->PlatRepoInfo; switch (GET_CM_OBJECT_ID (CmObjectId)) { - HANDLE_CM_OBJECT ( - EArmObjBootArchInfo, - CmObjectId, - PlatformRepo->BootArchInfo, - 1 - ); - HANDLE_CM_OBJECT ( - EArmObjPowerManagementProfileInfo, - CmObjectId, - PlatformRepo->PmProfileInfo, - 1 - ); - HANDLE_CM_OBJECT ( - EArmObjGenericTimerInfo, - CmObjectId, - PlatformRepo->GenericTimerInfo, - 1 - ); - HANDLE_CM_OBJECT ( - EArmObjPlatformGenericWatchdogInfo, - CmObjectId, - PlatformRepo->Watchdog, - 1 - ); - HANDLE_CM_OBJECT ( - EArmObjPlatformGTBlockInfo, - CmObjectId, - PlatformRepo->GTBlockInfo, - (sizeof (PlatformRepo->GTBlockInfo) / - sizeof (PlatformRepo->GTBlockInfo[0])) - ); - HANDLE_CM_OBJECT_REF_BY_TOKEN ( - EArmObjGTBlockTimerFrameInfo, - CmObjectId, - PlatformRepo->GTBlock0TimerInfo, - (sizeof (PlatformRepo->GTBlock0TimerInfo) / - sizeof (PlatformRepo->GTBlock0TimerInfo[0])), - Token, - GetGTBlockTimerFrameInfo - ); - HANDLE_CM_OBJECT_REF_BY_TOKEN ( - EArmObjGicCInfo, - CmObjectId, - PlatformRepo->GicCInfo, - ARRAY_SIZE (PlatformRepo->GicCInfo), - Token, - GetGicCInfo - ); - HANDLE_CM_OBJECT ( - EArmObjGicDInfo, - CmObjectId, - PlatformRepo->GicDInfo, - 1 - ); - HANDLE_CM_OBJECT ( - EArmObjSerialConsolePortInfo, - CmObjectId, - PlatformRepo->SpcrSerialPort, - 1 - ); + case EArmObjBootArchInfo: + Status = HandleCmObject ( + CmObjectId, + &PlatformRepo->BootArchInfo, + sizeof (PlatformRepo->BootArchInfo), + 1, + CmObject + ); + break; + case EArmObjPowerManagementProfileInfo: + Status = HandleCmObject ( + CmObjectId, + &PlatformRepo->PmProfileInfo, + sizeof (PlatformRepo->PmProfileInfo), + 1, + CmObject + ); + break; - HANDLE_CM_OBJECT ( - EArmObjSerialDebugPortInfo, - CmObjectId, - PlatformRepo->DbgSerialPort, - 1 - ); - HANDLE_CM_OBJECT ( - EArmObjGicMsiFrameInfo, - CmObjectId, - PlatformRepo->GicMsiFrameInfo, - 1 - ); - HANDLE_CM_OBJECT ( - EArmObjProcHierarchyInfo, - CmObjectId, - PlatformRepo->ProcHierarchyInfo, - ARRAY_SIZE (PlatformRepo->ProcHierarchyInfo) - ); - HANDLE_CM_OBJECT ( - EArmObjCacheInfo, - CmObjectId, - PlatformRepo->CacheInfo, - ARRAY_SIZE (PlatformRepo->CacheInfo) - ); - HANDLE_CM_OBJECT_SEARCH_PLAT_REPO ( - EArmObjCmRef, - CmObjectId, - Token, - GetCmObjRefs - ); + case EArmObjGenericTimerInfo: + Status = HandleCmObject ( + CmObjectId, + &PlatformRepo->GenericTimerInfo, + sizeof (PlatformRepo->GenericTimerInfo), + 1, + CmObject + ); + break; + + case EArmObjPlatformGenericWatchdogInfo: + Status = HandleCmObject ( + CmObjectId, + &PlatformRepo->Watchdog, + sizeof (PlatformRepo->Watchdog), + 1, + CmObject + ); + break; + + case EArmObjPlatformGTBlockInfo: + Status = HandleCmObject ( + CmObjectId, + PlatformRepo->GTBlockInfo, + sizeof (PlatformRepo->GTBlockInfo), + ARRAY_SIZE (PlatformRepo->GTBlockInfo), + CmObject + ); + break; + + case EArmObjGTBlockTimerFrameInfo: + Status = HandleCmObjectRefByToken ( + This, + CmObjectId, + PlatformRepo->GTBlock0TimerInfo, + sizeof (PlatformRepo->GTBlock0TimerInfo), + ARRAY_SIZE (PlatformRepo->GTBlock0TimerInfo), + Token, + GetGTBlockTimerFrameInfo, + CmObject + ); + break; + + case EArmObjGicCInfo: + Status = HandleCmObjectRefByToken ( + This, + CmObjectId, + PlatformRepo->GicCInfo, + sizeof (PlatformRepo->GicCInfo), + ARRAY_SIZE (PlatformRepo->GicCInfo), + Token, + GetGicCInfo, + CmObject + ); + break; + + case EArmObjGicDInfo: + Status = HandleCmObject ( + CmObjectId, + &PlatformRepo->GicDInfo, + sizeof (PlatformRepo->GicDInfo), + 1, + CmObject + ); + break; + case EArmObjSerialConsolePortInfo: + Status = HandleCmObject ( + CmObjectId, + &PlatformRepo->SpcrSerialPort, + sizeof (PlatformRepo->SpcrSerialPort), + 1, + CmObject + ); + break; + + case EArmObjSerialDebugPortInfo: + Status = HandleCmObject ( + CmObjectId, + &PlatformRepo->DbgSerialPort, + sizeof (PlatformRepo->DbgSerialPort), + 1, + CmObject + ); + break; + case EArmObjGicMsiFrameInfo: + Status = HandleCmObject ( + CmObjectId, + &PlatformRepo->GicMsiFrameInfo, + sizeof (PlatformRepo->GicMsiFrameInfo), + 1, + CmObject + ); + break; + + case EArmObjProcHierarchyInfo: + Status = HandleCmObject ( + CmObjectId, + PlatformRepo->ProcHierarchyInfo, + sizeof (PlatformRepo->ProcHierarchyInfo), + ARRAY_SIZE (PlatformRepo->ProcHierarchyInfo), + CmObject + ); + break; + + case EArmObjCacheInfo: + Status = HandleCmObject ( + CmObjectId, + PlatformRepo->CacheInfo, + sizeof (PlatformRepo->CacheInfo), + ARRAY_SIZE (PlatformRepo->CacheInfo), + CmObject + ); + break; + + case EArmObjCmRef: + Status = HandleCmObjectSearchPlatformRepo ( + This, + CmObjectId, + Token, + GetCmObjRefs, + CmObject + ); + break; case EArmObjPciConfigSpaceInfo: if (PlatformRepo->JunoRevision != JUNO_REVISION_R0) { - CmObject->ObjectId = CmObjectId; - CmObject->Size = sizeof (PlatformRepo->PciConfigInfo); - CmObject->Count = 1; - CmObject->Data = (VOID*)&PlatformRepo->PciConfigInfo; - DEBUG (( - DEBUG_INFO, - "EArmObjPciConfigSpaceInfo: Ptr = 0x%p, Size = %d, Count = %d\n", - CmObject->Data, - CmObject->Size, - CmObject->Count - )); + Status = HandleCmObject ( + CmObjectId, + &PlatformRepo->PciConfigInfo, + sizeof (PlatformRepo->PciConfigInfo), + 1, + CmObject + ); + } else { + // No PCIe on Juno R0. + Status = EFI_NOT_FOUND; } break; diff --git a/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.h b/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.h index 2073ae4902e540de869612353bfaf0ebacaea50d..f382c7f967420c4fa8f272f3fee5c8f191999b23 100644 --- a/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.h +++ b/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.h @@ -1,6 +1,6 @@ /** @file - Copyright (c) 2017 - 2020, Arm Limited. All rights reserved.
+ Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent @@ -91,94 +91,24 @@ extern CHAR8 ssdtuart_aml_code[]; (WritePolicy << 4) \ ) -/** A helper macro for returning configuration manager objects -*/ -#define HANDLE_CM_OBJECT(ObjId, CmObjectId, Object, ObjectCount) \ - case ObjId: { \ - CmObject->ObjectId = CmObjectId; \ - CmObject->Size = sizeof (Object); \ - CmObject->Data = (VOID*)&Object; \ - CmObject->Count = ObjectCount; \ - DEBUG (( \ - DEBUG_INFO, \ - #CmObjectId ": Ptr = 0x%p, Size = %d, Count = %d\n", \ - CmObject->Data, \ - CmObject->Size, \ - CmObject->Count \ - )); \ - break; \ - } +/** A function that prepares Configuration Manager Objects for returning. -/** A helper macro for returning configuration manager objects - referenced by token -*/ -#define HANDLE_CM_OBJECT_REF_BY_TOKEN( \ - ObjId, \ - CmObjectId, \ - Object, \ - ObjectCount, \ - Token, \ - HandlerProc \ - ) \ - case ObjId: { \ - CmObject->ObjectId = CmObjectId; \ - if (Token == CM_NULL_TOKEN) { \ - CmObject->Size = sizeof (Object); \ - CmObject->Data = (VOID*)&Object; \ - CmObject->Count = ObjectCount; \ - DEBUG (( \ - DEBUG_INFO, \ - #CmObjectId ": Ptr = 0x%p, Size = %d, Count = %d\n", \ - CmObject->Data, \ - CmObject->Size, \ - CmObject->Count \ - )); \ - } else { \ - Status = HandlerProc (This, CmObjectId, Token, CmObject); \ - DEBUG (( \ - DEBUG_INFO, \ - #CmObjectId ": Token = 0x%p, Ptr = 0x%p, Size = %d, Count = %d\n", \ - (VOID*)Token, \ - CmObject->Data, \ - CmObject->Size, \ - CmObject->Count \ - )); \ - } \ - break; \ - } + @param [in] This Pointer to the Configuration Manager Protocol. + @param [in] CmObjectId The Configuration Manager Object ID. + @param [in] Token A token for identifying the object. + @param [out] CmObject Pointer to the Configuration Manager Object + descriptor describing the requested Object. -/** A helper macro for returning configuration manager objects referenced - by token when the entire platform repository is in scope and the - CM_NULL_TOKEN value is not allowed. -*/ -#define HANDLE_CM_OBJECT_SEARCH_PLAT_REPO( \ - ObjId, \ - CmObjectId, \ - Token, \ - HandlerProc \ - ) \ - case ObjId: { \ - CmObject->ObjectId = CmObjectId; \ - if (Token == CM_NULL_TOKEN) { \ - Status = EFI_INVALID_PARAMETER; \ - DEBUG (( \ - DEBUG_ERROR, \ - #ObjId ": CM_NULL_TOKEN value is not allowed when searching" \ - " the entire platform repository.\n" \ - )); \ - } else { \ - Status = HandlerProc (This, CmObjectId, Token, CmObject); \ - DEBUG (( \ - DEBUG_INFO, \ - #ObjId ": Token = 0x%p, Ptr = 0x%p, Size = %d, Count = %d\n", \ - (VOID*)Token, \ - CmObject->Data, \ - CmObject->Size, \ - CmObject->Count \ - )); \ - } \ - break; \ - } + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND The required object information is not found. +**/ +typedef EFI_STATUS (*CM_OBJECT_HANDLER_PROC) ( + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST This, + IN CONST CM_OBJECT_ID CmObjectId, + IN CONST CM_OBJECT_TOKEN Token, + IN OUT CM_OBJ_DESCRIPTOR * CONST CmObject + ); /** The number of CPUs */ -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'