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 <[email protected]>
Cc: Leif Lindholm <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chandni Cherukuri <[email protected]>
---
 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

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to