From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=217.140.101.70; helo=foss.arm.com; envelope-from=chandni.cherukuri@arm.com; receiver=edk2-devel@lists.01.org Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by ml01.01.org (Postfix) with ESMTP id 9005121188C53 for ; Fri, 2 Nov 2018 09:37:30 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EA94AA78; Fri, 2 Nov 2018 09:37:29 -0700 (PDT) Received: from usa.arm.com (a73437-lin.blr.arm.com [10.162.0.155]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A0B6E3F718; Fri, 2 Nov 2018 09:37:28 -0700 (PDT) From: Chandni Cherukuri To: edk2-devel@lists.01.org Date: Fri, 2 Nov 2018 22:06:49 +0530 Message-Id: <1541176613-2539-2-git-send-email-chandni.cherukuri@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541176613-2539-1-git-send-email-chandni.cherukuri@arm.com> References: <1541176613-2539-1-git-send-email-chandni.cherukuri@arm.com> Subject: [PATCH edk2-platforms 1/5] Platform/ARM/Sgi: Adapt to changes in system-id DT node. 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: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 X-List-Received-Date: Fri, 02 Nov 2018 16:37:30 -0000 The 'system-id' node of HW_CONFIG device tree has been updated to have a new property 'config-id' to hold the platform configuration value. Prior to this, configuration ID value was represented by the the upper four bits of the 'platform ID' property value but it now has a seperate property of its own in the 'system-id' node. So adapt to these changes in the 'system-id' node. Change-Id: Ia15e31df50f2f43746231e5c4352035a13510bba Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Chandni Cherukuri --- Platform/ARM/SgiPkg/Library/SgiPlatformPei/SgiPlatformPeim.c | 241 +++++++++++--------- 1 file changed, 129 insertions(+), 112 deletions(-) diff --git a/Platform/ARM/SgiPkg/Library/SgiPlatformPei/SgiPlatformPeim.c b/Platform/ARM/SgiPkg/Library/SgiPlatformPei/SgiPlatformPeim.c index 081d329..ba980e0 100644 --- a/Platform/ARM/SgiPkg/Library/SgiPlatformPei/SgiPlatformPeim.c +++ b/Platform/ARM/SgiPkg/Library/SgiPlatformPei/SgiPlatformPeim.c @@ -1,112 +1,129 @@ -/** @file -* -* Copyright (c) 2018, 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. -* -**/ - -#include -#include -#include -#include -#include -#include -#include - -/** - - This function returns the Platform ID of the platform - - This functions locates the HwConfig PPI and gets the base address of HW CONFIG - DT from which the platform ID is obtained using FDT helper functions - - @return returns the platform ID on success else returns 0 on error - -**/ - -STATIC -UINT32 -GetSgiPlatformId ( - VOID -) -{ - CONST UINT32 *Property; - INT32 Offset; - CONST VOID *HwCfgDtBlob; - SGI_HW_CONFIG_INFO_PPI *HwConfigInfoPpi; - EFI_STATUS Status; - - Status = PeiServicesLocatePpi (&gHwConfigDtInfoPpiGuid, 0, NULL, - (VOID**)&HwConfigInfoPpi); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, - "PeiServicesLocatePpi failed with error %r\n", Status)); - return 0; - } - - HwCfgDtBlob = (VOID *)(UINTN)HwConfigInfoPpi->HwConfigDtAddr; - if (fdt_check_header (HwCfgDtBlob) != 0) { - DEBUG ((DEBUG_ERROR, "Invalid DTB file %p passed\n", HwCfgDtBlob)); - return 0; - } - - Offset = fdt_subnode_offset (HwCfgDtBlob, 0, "system-id"); - if (Offset == -FDT_ERR_NOTFOUND) { - DEBUG ((DEBUG_ERROR, "Invalid DTB : system-id node not found\n")); - return 0; - } - - Property = fdt_getprop (HwCfgDtBlob, Offset, "platform-id", NULL); - if (Property == NULL) { - DEBUG ((DEBUG_ERROR, "Platform Id is NULL\n")); - return 0; - } - - return fdt32_to_cpu (*Property); -} - -/** - - This function creates a Platform ID HOB and assigns PlatformId as the - HobData - - @return asserts on error and returns EFI_INVALID_PARAMETER. On success - returns EFI_SUCCESS - -**/ -EFI_STATUS -EFIAPI -SgiPlatformPeim ( - IN EFI_PEI_FILE_HANDLE FileHandle, - IN CONST EFI_PEI_SERVICES **PeiServices -) -{ - SGI_PLATFORM_DESCRIPTOR *HobData; - - // Create platform descriptor HOB - HobData = (SGI_PLATFORM_DESCRIPTOR *)BuildGuidHob ( - &gArmSgiPlatformIdDescriptorGuid, - sizeof (SGI_PLATFORM_DESCRIPTOR)); - - // Get the platform id from the platform specific hw_config device tree - if (HobData == NULL) { - DEBUG ((DEBUG_ERROR, "Platform HOB is NULL\n")); - ASSERT (FALSE); - return EFI_OUT_OF_RESOURCES; - } - - HobData->PlatformId = GetSgiPlatformId (); - if (HobData->PlatformId == 0) { - ASSERT (FALSE); - return EFI_INVALID_PARAMETER; - } - - return EFI_SUCCESS; -} +/** @file +* +* Copyright (c) 2018, 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. +* +**/ + +#include +#include +#include +#include +#include +#include +#include + +/** + + This function returns the Platform ID of the platform + + This functions locates the HwConfig PPI and gets the base address of HW CONFIG + DT from which the platform ID is obtained using FDT helper functions + + @return returns the platform ID on success else returns 0 on error + +**/ + +STATIC +UINT32 +GetSgiPlatformId ( + VOID +) +{ + CONST UINT32 *Property; + INT32 Offset; + CONST VOID *HwCfgDtBlob; + SGI_HW_CONFIG_INFO_PPI *HwConfigInfoPpi; + EFI_STATUS Status; + UINT32 PlatformId; + UINT32 ConfigId; + + Status = PeiServicesLocatePpi (&gHwConfigDtInfoPpiGuid, 0, NULL, + (VOID**)&HwConfigInfoPpi); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, + "PeiServicesLocatePpi failed with error %r\n", Status)); + return 0; + } + + HwCfgDtBlob = (VOID *)(UINTN)HwConfigInfoPpi->HwConfigDtAddr; + if (fdt_check_header (HwCfgDtBlob) != 0) { + DEBUG ((DEBUG_ERROR, "Invalid DTB file %p passed\n", HwCfgDtBlob)); + return 0; + } + + Offset = fdt_subnode_offset (HwCfgDtBlob, 0, "system-id"); + if (Offset == -FDT_ERR_NOTFOUND) { + DEBUG ((DEBUG_ERROR, "Invalid DTB : system-id node not found\n")); + return 0; + } + + Property = fdt_getprop (HwCfgDtBlob, Offset, "platform-id", NULL); + if (Property == NULL) { + DEBUG ((DEBUG_ERROR, "Platform Id is NULL\n")); + return 0; + } + + PlatformId = fdt32_to_cpu (*Property); + + Property = fdt_getprop (HwCfgDtBlob, Offset, "config-id", NULL); + if (Property == NULL) { + DEBUG ((DEBUG_ERROR, "Config Id is NULL\n")); + return 0; + } + + ConfigId = fdt32_to_cpu (*Property); + + // Concatenate the value of config ID into the platform ID value with + // config ID occupying the upper 4 bits of platform ID. + ConfigId = ConfigId & SGI_CONFIG_MASK; + PlatformId = PlatformId | (ConfigId << SGI_CONFIG_SHIFT); + + return PlatformId; +} + +/** + + This function creates a Platform ID HOB and assigns PlatformId as the + HobData + + @return asserts on error and returns EFI_INVALID_PARAMETER. On success + returns EFI_SUCCESS + +**/ +EFI_STATUS +EFIAPI +SgiPlatformPeim ( + IN EFI_PEI_FILE_HANDLE FileHandle, + IN CONST EFI_PEI_SERVICES **PeiServices +) +{ + SGI_PLATFORM_DESCRIPTOR *HobData; + + // Create platform descriptor HOB + HobData = (SGI_PLATFORM_DESCRIPTOR *)BuildGuidHob ( + &gArmSgiPlatformIdDescriptorGuid, + sizeof (SGI_PLATFORM_DESCRIPTOR)); + + // Get the platform id from the platform specific hw_config device tree + if (HobData == NULL) { + DEBUG ((DEBUG_ERROR, "Platform HOB is NULL\n")); + ASSERT (FALSE); + return EFI_OUT_OF_RESOURCES; + } + + HobData->PlatformId = GetSgiPlatformId (); + if (HobData->PlatformId == 0) { + ASSERT (FALSE); + return EFI_INVALID_PARAMETER; + } + + return EFI_SUCCESS; +} -- 2.7.4