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 F1C3221193767 for ; Wed, 21 Nov 2018 04:45:19 -0800 (PST) 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 5448C353C; Wed, 21 Nov 2018 04:45:19 -0800 (PST) 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 07F893F5A0; Wed, 21 Nov 2018 04:45:17 -0800 (PST) From: Chandni Cherukuri To: edk2-devel@lists.01.org Date: Wed, 21 Nov 2018 18:14:52 +0530 Message-Id: <1542804297-31957-2-git-send-email-chandni.cherukuri@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1542804297-31957-1-git-send-email-chandni.cherukuri@arm.com> References: <1542804297-31957-1-git-send-email-chandni.cherukuri@arm.com> Subject: [PATCH v3 edk2-platforms 1/6] 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: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -0000 X-List-Received-Date: Wed, 21 Nov 2018 12:45:20 -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. To adapt to this change, SGI_PLATFORM_DESCRIPTOR gets a new member named 'ConfigId' and the function GetSgiPlatformId has been renamed to GetSgiSystemId which takes the SGI_PLATFORM_DESCRIPTOR HoB as the function parameter. Cc: Ard Biesheuvel Cc: Leif Lindholm Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Chandni Cherukuri --- Platform/ARM/SgiPkg/Include/SgiPlatform.h | 1 + Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c | 14 +++--- Platform/ARM/SgiPkg/Library/SgiPlatformPei/SgiPlatformPeim.c | 50 +++++++++++++------- 3 files changed, 42 insertions(+), 23 deletions(-) diff --git a/Platform/ARM/SgiPkg/Include/SgiPlatform.h b/Platform/ARM/SgiPkg/Include/SgiPlatform.h index 1454018..b0cca4e 100644 --- a/Platform/ARM/SgiPkg/Include/SgiPlatform.h +++ b/Platform/ARM/SgiPkg/Include/SgiPlatform.h @@ -79,6 +79,7 @@ // ARM platform description data. typedef struct { UINTN PlatformId; + UINTN ConfigId; } SGI_PLATFORM_DESCRIPTOR; #endif // __SGI_PLATFORM_H__ diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c index 5ccd01d..249d0a0 100644 --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c @@ -30,21 +30,21 @@ ArmSgiPkgEntryPoint ( ) { EFI_STATUS Status; - VOID *PlatformIdHob; + VOID *SystemIdHob; SGI_PLATFORM_DESCRIPTOR *HobData; UINT32 ConfigId; UINT32 PartNum; - PlatformIdHob = GetFirstGuidHob (&gArmSgiPlatformIdDescriptorGuid); - if (PlatformIdHob == NULL) { - DEBUG ((DEBUG_ERROR, "Platform ID HOB is NULL\n")); + SystemIdHob = GetFirstGuidHob (&gArmSgiPlatformIdDescriptorGuid); + if (SystemIdHob == NULL) { + DEBUG ((DEBUG_ERROR, "System ID HOB is NULL\n")); return EFI_INVALID_PARAMETER; } - HobData = (SGI_PLATFORM_DESCRIPTOR *)GET_GUID_HOB_DATA (PlatformIdHob); + HobData = (SGI_PLATFORM_DESCRIPTOR *)GET_GUID_HOB_DATA (SystemIdHob); - PartNum = HobData->PlatformId & SGI_PART_NUM_MASK; - ConfigId = (HobData->PlatformId >> SGI_CONFIG_SHIFT) & SGI_CONFIG_MASK; + PartNum = HobData->PlatformId; + ConfigId = HobData->ConfigId; if ((PartNum == SGI575_PART_NUM) && (ConfigId == SGI575_CONF_NUM)) { Status = LocateAndInstallAcpiFromFv (&gSgi575AcpiTablesFileGuid); diff --git a/Platform/ARM/SgiPkg/Library/SgiPlatformPei/SgiPlatformPeim.c b/Platform/ARM/SgiPkg/Library/SgiPlatformPei/SgiPlatformPeim.c index 081d329..15ea571 100644 --- a/Platform/ARM/SgiPkg/Library/SgiPlatformPei/SgiPlatformPeim.c +++ b/Platform/ARM/SgiPkg/Library/SgiPlatformPei/SgiPlatformPeim.c @@ -22,19 +22,21 @@ /** - This function returns the Platform ID of the platform + This function returns the System 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 + DT from which the platform ID and config ID is obtained using FDT helper + functions - @return returns the platform ID on success else returns 0 on error + @param[out] Pointer to the SGI_PLATFORM_DESCRIPTOR HoB + @return returns EFI_SUCCESS on success and EFI_INVALID_PARAMETER on error **/ STATIC -UINT32 -GetSgiPlatformId ( - VOID +EFI_STATUS +GetSgiSystemId ( + OUT SGI_PLATFORM_DESCRIPTOR *HobData ) { CONST UINT32 *Property; @@ -48,34 +50,44 @@ GetSgiPlatformId ( if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "PeiServicesLocatePpi failed with error %r\n", Status)); - return 0; + return EFI_INVALID_PARAMETER; } HwCfgDtBlob = (VOID *)(UINTN)HwConfigInfoPpi->HwConfigDtAddr; if (fdt_check_header (HwCfgDtBlob) != 0) { DEBUG ((DEBUG_ERROR, "Invalid DTB file %p passed\n", HwCfgDtBlob)); - return 0; + return EFI_INVALID_PARAMETER; } 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; + return EFI_INVALID_PARAMETER; } Property = fdt_getprop (HwCfgDtBlob, Offset, "platform-id", NULL); if (Property == NULL) { DEBUG ((DEBUG_ERROR, "Platform Id is NULL\n")); - return 0; + return EFI_INVALID_PARAMETER; } - return fdt32_to_cpu (*Property); + HobData->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 EFI_INVALID_PARAMETER; + } + + HobData->ConfigId = fdt32_to_cpu (*Property); + + return EFI_SUCCESS; } /** - This function creates a Platform ID HOB and assigns PlatformId as the - HobData + This function creates a System ID HOB and assigns PlatformId and + ConfigId as the HobData @return asserts on error and returns EFI_INVALID_PARAMETER. On success returns EFI_SUCCESS @@ -89,21 +101,27 @@ SgiPlatformPeim ( ) { SGI_PLATFORM_DESCRIPTOR *HobData; + EFI_STATUS Status; // 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 + // Get the system 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) { + Status = GetSgiSystemId (HobData); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + return EFI_INVALID_PARAMETER; + } + + if (HobData->PlatformId == 0 || HobData->ConfigId == 0) { ASSERT (FALSE); return EFI_INVALID_PARAMETER; } -- 2.7.4