public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Chandni Cherukuri <chandni.cherukuri@arm.com>
To: edk2-devel@lists.01.org
Subject: [PATCH v3 edk2-platforms 1/6] Platform/ARM/Sgi: Adapt to changes in system-id DT node.
Date: Wed, 21 Nov 2018 18:14:52 +0530	[thread overview]
Message-ID: <1542804297-31957-2-git-send-email-chandni.cherukuri@arm.com> (raw)
In-Reply-To: <1542804297-31957-1-git-send-email-chandni.cherukuri@arm.com>

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 <ard.biesheuvel@linaro.org>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chandni Cherukuri <chandni.cherukuri@arm.com>
---
 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



  reply	other threads:[~2018-11-21 12:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-21 12:44 [PATCH v3 edk2-platforms 0/6] Platform/ARM/Sgi: Add support for Clark.Ares and Clark.Helios platforms Chandni Cherukuri
2018-11-21 12:44 ` Chandni Cherukuri [this message]
2018-11-21 12:44 ` [PATCH v3 edk2-platforms 2/6] Platform/ARM/Sgi: Refactor ACPI tables for SGI platforms Chandni Cherukuri
2018-11-21 12:44 ` [PATCH v3 edk2-platforms 3/6] Platform/ARM/Sgi: Add ACPI tables for SGI-Clark.Ares platform Chandni Cherukuri
2018-11-21 12:44 ` [PATCH v3 edk2-platforms 4/6] Platform/ARM/Sgi: Add initial support " Chandni Cherukuri
2018-11-21 12:44 ` [PATCH v3 edk2-platforms 5/6] Platform/ARM/Sgi: Add ACPI tables for SGI-Clark.Helios platform Chandni Cherukuri
2018-11-21 12:44 ` [PATCH v3 edk2-platforms 6/6] Platform/ARM/Sgi: Add initial support " Chandni Cherukuri
2018-11-29 15:13 ` [PATCH v3 edk2-platforms 0/6] Platform/ARM/Sgi: Add support for Clark.Ares and Clark.Helios platforms Leif Lindholm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1542804297-31957-2-git-send-email-chandni.cherukuri@arm.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox