[Linaro-uefi,RFC,3/7] Platforms/AMD: AmdStyxHelperLib: add helper to retrieve core info array

Message ID 1462196143-21998-4-git-send-email-ard.biesheuvel@linaro.org
State New
Headers show

Commit Message

Ard Biesheuvel May 2, 2016, 1:35 p.m.
Add a helper function which retrieves the ARM_CORE_INFO array directly
from the HOB rather than going via the ARM_PROCESSOR_TABLE structure
in the configuration table array.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 Platforms/AMD/Styx/Common/AmdStyxHelperLib.h                     |  5 +++++
 Platforms/AMD/Styx/Library/AmdStyxHelperLib/AmdStyxHelperLib.c   | 21 ++++++++++++++++++++
 Platforms/AMD/Styx/Library/AmdStyxHelperLib/AmdStyxHelperLib.inf |  5 ++++-
 3 files changed, 30 insertions(+), 1 deletion(-)

Patch

diff --git a/Platforms/AMD/Styx/Common/AmdStyxHelperLib.h b/Platforms/AMD/Styx/Common/AmdStyxHelperLib.h
index 8fb6bc4b6c0d..c4598fe7d108 100644
--- a/Platforms/AMD/Styx/Common/AmdStyxHelperLib.h
+++ b/Platforms/AMD/Styx/Common/AmdStyxHelperLib.h
@@ -39,4 +39,9 @@  AmdStyxGetArmProcessorTable(
   VOID
   );
 
+ARM_CORE_INFO *
+AmdStyxGetArmCoreInfoTable (
+  OUT UINTN   *NumEntries
+  );
+
 #endif // _AMDSTYX_HELPER_LIB_H_
diff --git a/Platforms/AMD/Styx/Library/AmdStyxHelperLib/AmdStyxHelperLib.c b/Platforms/AMD/Styx/Library/AmdStyxHelperLib/AmdStyxHelperLib.c
index 8189df3cddc6..6e0ed35278e4 100644
--- a/Platforms/AMD/Styx/Library/AmdStyxHelperLib/AmdStyxHelperLib.c
+++ b/Platforms/AMD/Styx/Library/AmdStyxHelperLib/AmdStyxHelperLib.c
@@ -20,6 +20,9 @@ 
 
 #include <AmdStyxHelperLib.h>
 
+#include <PiDxe.h>
+#include <Library/HobLib.h>
+
 extern  EFI_SYSTEM_TABLE        *gST;
 
 #pragma pack(push, 1)
@@ -78,3 +81,21 @@  AmdStyxGetArmProcessorTable(
   return NULL;
 }
 
+ARM_CORE_INFO *
+AmdStyxGetArmCoreInfoTable (
+  OUT UINTN   *NumEntries
+  )
+{
+  EFI_HOB_GUID_TYPE   *Hob;
+
+  ASSERT (NumEntries != NULL);
+
+  Hob = GetFirstGuidHob (&gAmdStyxMpCoreInfoGuid);
+  if (Hob == NULL) {
+    return NULL;
+  }
+
+  *NumEntries = GET_GUID_HOB_DATA_SIZE (Hob) / sizeof (ARM_CORE_INFO);
+
+  return GET_GUID_HOB_DATA (Hob);
+}
diff --git a/Platforms/AMD/Styx/Library/AmdStyxHelperLib/AmdStyxHelperLib.inf b/Platforms/AMD/Styx/Library/AmdStyxHelperLib/AmdStyxHelperLib.inf
index 57a6ebe74724..540ecfcc6399 100644
--- a/Platforms/AMD/Styx/Library/AmdStyxHelperLib/AmdStyxHelperLib.inf
+++ b/Platforms/AMD/Styx/Library/AmdStyxHelperLib/AmdStyxHelperLib.inf
@@ -29,6 +29,9 @@ 
 [Sources.common]
   AmdStyxHelperLib.c
 
+[LibraryClasses]
+  HobLib
+
 [Packages]
   ArmPkg/ArmPkg.dec
   MdePkg/MdePkg.dec
@@ -38,4 +41,4 @@ 
 
 [Guids]
   gArmMpCoreInfoGuid
-
+  gAmdStyxMpCoreInfoGuid