public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-platforms PATCH v2 1/1] Platform/ARM: Juno: Add support for PPTT dynamic generation
@ 2019-06-18  9:24 Krzysztof Koch
  2019-06-18 18:16 ` Leif Lindholm
  0 siblings, 1 reply; 2+ messages in thread
From: Krzysztof Koch @ 2019-06-18  9:24 UTC (permalink / raw)
  To: devel
  Cc: Ard Biesheuvel, Leif Lindholm, Michael D Kinney, Sami.Mujawar,
	Matteo.Carlini, Stephanie.Hughes-Fitt, nd

Update the Platform Respository for the Juno platform
to include support for generation of the Processor Properties
Topology Table (PPTT) using the Dynamic Tables Framework.

The Platform Repository now also describes the cache and
processor topology in Juno (all revisions).

Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>
---

Changes can be seen at: https://github.com/KrzysztofKoch1/edk2-platforms/tree/392_dynamic_pptt_juno_v2

Notes:
    v2:
    - use ARRAY_SIZE macro from Base.h to compute array size [Leif]
    v1:
    - add support for dynamic generation of PPTT [Krzysztof]

 Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c | 438 +++++++++++++++++++-
 Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.h | 136 +++++-
 2 files changed, 569 insertions(+), 5 deletions(-)

diff --git a/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c b/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
index 78b906ddb8bbd35c32b4be98b1ee8bd973b6b818..d52cc2982334ded1c3bf2f5e8f570378d8fb0ae1 100644
--- a/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
+++ b/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
@@ -96,7 +96,13 @@ EDKII_PLATFORM_REPOSITORY_INFO ArmJunoPlatformRepositoryInfo = {
       CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdSsdt),
       (EFI_ACPI_DESCRIPTION_HEADER*)ssdtuart_aml_code
     },
-
+    // PPTT Table
+    {
+      EFI_ACPI_6_3_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_STRUCTURE_SIGNATURE,
+      EFI_ACPI_6_3_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_REVISION,
+      CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdPptt),
+      NULL
+    },
     /* PCI MCFG Table
        PCIe is only available on Juno R1 and R2.
        Add the PCI table entries at the end of the table so that
@@ -261,6 +267,301 @@ EDKII_PLATFORM_REPOSITORY_INFO ArmJunoPlatformRepositoryInfo = {
     127,
     // SPI Base used by this frame.
     224
+  },
+
+  // Processor Hierarchy Nodes
+  {
+    // Package
+    {
+      // CM_OBJECT_TOKEN  Token
+      REFERENCE_TOKEN (ProcHierarchyInfo[0]),
+      // UINT32  Flags
+      PROC_NODE_FLAGS (
+        EFI_ACPI_6_3_PPTT_PACKAGE_PHYSICAL,
+        EFI_ACPI_6_3_PPTT_PROCESSOR_ID_INVALID,
+        EFI_ACPI_6_3_PPTT_PROCESSOR_IS_NOT_THREAD,
+        EFI_ACPI_6_3_PPTT_NODE_IS_NOT_LEAF,
+        EFI_ACPI_6_3_PPTT_IMPLEMENTATION_NOT_IDENTICAL
+      ),
+      // CM_OBJECT_TOKEN  ParentToken
+      CM_NULL_TOKEN,
+      // CM_OBJECT_TOKEN  GicCToken
+      CM_NULL_TOKEN,
+      // UINT32  NoOfPrivateResources
+      0,
+      // CM_OBJECT_TOKEN  PrivateResourcesArrayToken
+      CM_NULL_TOKEN
+    },
+    // 'big' cluster
+    {
+      // CM_OBJECT_TOKEN  Token
+      REFERENCE_TOKEN (ProcHierarchyInfo[1]),
+      // UINT32  Flags
+      PROC_NODE_FLAGS (
+        EFI_ACPI_6_3_PPTT_PACKAGE_NOT_PHYSICAL,
+        EFI_ACPI_6_3_PPTT_PROCESSOR_ID_INVALID,
+        EFI_ACPI_6_3_PPTT_PROCESSOR_IS_NOT_THREAD,
+        EFI_ACPI_6_3_PPTT_NODE_IS_NOT_LEAF,
+        EFI_ACPI_6_3_PPTT_IMPLEMENTATION_IDENTICAL
+      ),
+      // CM_OBJECT_TOKEN  ParentToken
+      REFERENCE_TOKEN (ProcHierarchyInfo[0]), // -> Package
+      // CM_OBJECT_TOKEN  GicCToken
+      CM_NULL_TOKEN,
+      // UINT32  NoOfPrivateResources
+      BIG_CLUSTER_RESOURCE_COUNT,
+      // CM_OBJECT_TOKEN  PrivateResourcesArrayToken
+      REFERENCE_TOKEN (BigClusterResources)
+    },
+    // 'LITTLE' cluster
+    {
+      // CM_OBJECT_TOKEN  Token
+      REFERENCE_TOKEN (ProcHierarchyInfo[2]),
+      // UINT32  Flags
+      PROC_NODE_FLAGS (
+        EFI_ACPI_6_3_PPTT_PACKAGE_NOT_PHYSICAL,
+        EFI_ACPI_6_3_PPTT_PROCESSOR_ID_INVALID,
+        EFI_ACPI_6_3_PPTT_PROCESSOR_IS_NOT_THREAD,
+        EFI_ACPI_6_3_PPTT_NODE_IS_NOT_LEAF,
+        EFI_ACPI_6_3_PPTT_IMPLEMENTATION_IDENTICAL
+      ),
+      // CM_OBJECT_TOKEN  ParentToken
+      REFERENCE_TOKEN (ProcHierarchyInfo[0]), // -> Package
+      // CM_OBJECT_TOKEN  GicCToken
+      CM_NULL_TOKEN,
+      // UINT32  NoOfPrivateResources
+      LITTLE_CLUSTER_RESOURCE_COUNT,
+      // CM_OBJECT_TOKEN  PrivateResourcesArrayToken
+      REFERENCE_TOKEN (LittleClusterResources)
+    },
+    // Two 'big' cores
+    {
+      // CM_OBJECT_TOKEN  Token
+      REFERENCE_TOKEN (ProcHierarchyInfo[3]),
+      // UINT32  Flags
+      PROC_NODE_FLAGS (
+        EFI_ACPI_6_3_PPTT_PACKAGE_NOT_PHYSICAL,
+        EFI_ACPI_6_3_PPTT_PROCESSOR_ID_VALID,
+        EFI_ACPI_6_3_PPTT_PROCESSOR_IS_NOT_THREAD,
+        EFI_ACPI_6_3_PPTT_NODE_IS_LEAF,
+        EFI_ACPI_6_3_PPTT_IMPLEMENTATION_NOT_IDENTICAL
+      ),
+      // CM_OBJECT_TOKEN  ParentToken
+      REFERENCE_TOKEN (ProcHierarchyInfo[1]), // -> 'big' cluster
+      // CM_OBJECT_TOKEN  GicCToken
+      REFERENCE_TOKEN (GicCInfo[0]),
+      // UINT32  NoOfPrivateResources
+      BIG_CORE_RESOURCE_COUNT,
+      // CM_OBJECT_TOKEN  PrivateResourcesArrayToken
+      REFERENCE_TOKEN (BigCoreResources)
+    },
+    {
+      // CM_OBJECT_TOKEN  Token
+      REFERENCE_TOKEN (ProcHierarchyInfo[4]),
+      // UINT32  Flags
+      PROC_NODE_FLAGS (
+        EFI_ACPI_6_3_PPTT_PACKAGE_NOT_PHYSICAL,
+        EFI_ACPI_6_3_PPTT_PROCESSOR_ID_VALID,
+        EFI_ACPI_6_3_PPTT_PROCESSOR_IS_NOT_THREAD,
+        EFI_ACPI_6_3_PPTT_NODE_IS_LEAF,
+        EFI_ACPI_6_3_PPTT_IMPLEMENTATION_NOT_IDENTICAL
+      ),
+      // CM_OBJECT_TOKEN  ParentToken
+      REFERENCE_TOKEN (ProcHierarchyInfo[1]), // -> 'big' cluster
+      // CM_OBJECT_TOKEN  GicCToken
+      REFERENCE_TOKEN (GicCInfo[1]),
+      // UINT32  NoOfPrivateResources
+      BIG_CORE_RESOURCE_COUNT,
+      // CM_OBJECT_TOKEN  PrivateResourcesArrayToken
+      REFERENCE_TOKEN (BigCoreResources)
+    },
+    // Four 'LITTLE' cores
+    {
+      // CM_OBJECT_TOKEN  Token
+      REFERENCE_TOKEN (ProcHierarchyInfo[5]),
+      // UINT32  Flags
+      PROC_NODE_FLAGS (
+        EFI_ACPI_6_3_PPTT_PACKAGE_NOT_PHYSICAL,
+        EFI_ACPI_6_3_PPTT_PROCESSOR_ID_VALID,
+        EFI_ACPI_6_3_PPTT_PROCESSOR_IS_NOT_THREAD,
+        EFI_ACPI_6_3_PPTT_NODE_IS_LEAF,
+        EFI_ACPI_6_3_PPTT_IMPLEMENTATION_NOT_IDENTICAL
+      ),
+      // CM_OBJECT_TOKEN  ParentToken
+      REFERENCE_TOKEN (ProcHierarchyInfo[2]), // -> 'LITTLE' cluster
+      // CM_OBJECT_TOKEN  GicCToken
+      REFERENCE_TOKEN (GicCInfo[2]),
+      // UINT32  NoOfPrivateResources
+      LITTLE_CORE_RESOURCE_COUNT,
+      // CM_OBJECT_TOKEN  PrivateResourcesArrayToken
+      REFERENCE_TOKEN (LittleCoreResources)
+    },
+    {
+      // CM_OBJECT_TOKEN  Token
+      REFERENCE_TOKEN (ProcHierarchyInfo[6]),
+      // UINT32  Flags
+      PROC_NODE_FLAGS (
+        EFI_ACPI_6_3_PPTT_PACKAGE_NOT_PHYSICAL,
+        EFI_ACPI_6_3_PPTT_PROCESSOR_ID_VALID,
+        EFI_ACPI_6_3_PPTT_PROCESSOR_IS_NOT_THREAD,
+        EFI_ACPI_6_3_PPTT_NODE_IS_LEAF,
+        EFI_ACPI_6_3_PPTT_IMPLEMENTATION_NOT_IDENTICAL
+      ),
+      // CM_OBJECT_TOKEN  ParentToken
+      REFERENCE_TOKEN (ProcHierarchyInfo[2]), // -> 'LITTLE' cluster
+      // CM_OBJECT_TOKEN  GicCToken
+      REFERENCE_TOKEN (GicCInfo[3]),
+      // UINT32  NoOfPrivateResources
+      LITTLE_CORE_RESOURCE_COUNT,
+      // CM_OBJECT_TOKEN  PrivateResourcesArrayToken
+      REFERENCE_TOKEN (LittleCoreResources)
+    },
+    {
+      // CM_OBJECT_TOKEN  Token
+      REFERENCE_TOKEN (ProcHierarchyInfo[7]),
+      // UINT32  Flags
+      PROC_NODE_FLAGS (
+        EFI_ACPI_6_3_PPTT_PACKAGE_NOT_PHYSICAL,
+        EFI_ACPI_6_3_PPTT_PROCESSOR_ID_VALID,
+        EFI_ACPI_6_3_PPTT_PROCESSOR_IS_NOT_THREAD,
+        EFI_ACPI_6_3_PPTT_NODE_IS_LEAF,
+        EFI_ACPI_6_3_PPTT_IMPLEMENTATION_NOT_IDENTICAL
+      ),
+      // CM_OBJECT_TOKEN  ParentToken
+      REFERENCE_TOKEN (ProcHierarchyInfo[2]), // -> 'LITTLE' cluster
+      // CM_OBJECT_TOKEN  GicCToken
+      REFERENCE_TOKEN (GicCInfo[4]),
+      // UINT32  NoOfPrivateResources
+      LITTLE_CORE_RESOURCE_COUNT,
+      // CM_OBJECT_TOKEN  PrivateResourcesArrayToken
+      REFERENCE_TOKEN (LittleCoreResources)
+    },
+    {
+      // CM_OBJECT_TOKEN  Token
+      REFERENCE_TOKEN (ProcHierarchyInfo[8]),
+      // UINT32  Flags
+      PROC_NODE_FLAGS (
+        EFI_ACPI_6_3_PPTT_PACKAGE_NOT_PHYSICAL,
+        EFI_ACPI_6_3_PPTT_PROCESSOR_ID_VALID,
+        EFI_ACPI_6_3_PPTT_PROCESSOR_IS_NOT_THREAD,
+        EFI_ACPI_6_3_PPTT_NODE_IS_LEAF,
+        EFI_ACPI_6_3_PPTT_IMPLEMENTATION_NOT_IDENTICAL
+      ),
+      // CM_OBJECT_TOKEN  ParentToken
+      REFERENCE_TOKEN (ProcHierarchyInfo[2]), // -> 'LITTLE' cluster
+      // CM_OBJECT_TOKEN  GicCToken
+      REFERENCE_TOKEN (GicCInfo[5]),
+      // UINT32  NoOfPrivateResources
+      LITTLE_CORE_RESOURCE_COUNT,
+      // CM_OBJECT_TOKEN  PrivateResourcesArrayToken
+      REFERENCE_TOKEN (LittleCoreResources)
+    }
+  },
+
+  // Cache information
+  {
+    // 'big' cluster's L2 cache
+    {
+      REFERENCE_TOKEN (CacheInfo[0]),  // CM_OBJECT_TOKEN  Token
+      CM_NULL_TOKEN,                   // CM_OBJECT_TOKEN  NextLevelOfCacheToken
+      0x200000,                        // UINT32  Size
+      2048,                            // UINT32  NumberOfSets
+      16,                              // UINT32  Associativity
+      CACHE_ATTRIBUTES (               // UINT8   Attributes
+        EFI_ACPI_6_3_CACHE_ATTRIBUTES_ALLOCATION_READ_WRITE,
+        EFI_ACPI_6_3_CACHE_ATTRIBUTES_CACHE_TYPE_UNIFIED,
+        EFI_ACPI_6_3_CACHE_ATTRIBUTES_WRITE_POLICY_WRITE_BACK
+      ),
+      64                               // UINT16  LineSize
+    },
+    // 'big' core's L1 instruction cache
+    {
+      REFERENCE_TOKEN (CacheInfo[1]),  // CM_OBJECT_TOKEN  Token
+      CM_NULL_TOKEN,                   // CM_OBJECT_TOKEN  NextLevelOfCacheToken
+      0xc000,                          // UINT32  Size
+      256,                             // UINT32  NumberOfSets
+      3,                               // UINT32  Associativity
+      CACHE_ATTRIBUTES (               // UINT8   Attributes
+        EFI_ACPI_6_3_CACHE_ATTRIBUTES_ALLOCATION_READ,
+        EFI_ACPI_6_3_CACHE_ATTRIBUTES_CACHE_TYPE_INSTRUCTION,
+        EFI_ACPI_6_3_CACHE_ATTRIBUTES_WRITE_POLICY_WRITE_BACK
+      ),
+      64                               // UINT16  LineSize
+    },
+    // 'big' core's L1 data cache
+    {
+      REFERENCE_TOKEN (CacheInfo[2]),  // CM_OBJECT_TOKEN  Token
+      CM_NULL_TOKEN,                   // CM_OBJECT_TOKEN  NextLevelOfCacheToken
+      0x8000,                          // UINT32  Size
+      256,                             // UINT32  NumberOfSets
+      2,                               // UINT32  Associativity
+      CACHE_ATTRIBUTES (               // UINT8   Attributes
+        EFI_ACPI_6_3_CACHE_ATTRIBUTES_ALLOCATION_READ_WRITE,
+        EFI_ACPI_6_3_CACHE_ATTRIBUTES_CACHE_TYPE_DATA,
+        EFI_ACPI_6_3_CACHE_ATTRIBUTES_WRITE_POLICY_WRITE_BACK
+      ),
+      64                               // UINT16  LineSize
+    },
+    // 'LITTLE' cluster's L2 cache
+    {
+      REFERENCE_TOKEN (CacheInfo[3]),  // CM_OBJECT_TOKEN  Token
+      CM_NULL_TOKEN,                   // CM_OBJECT_TOKEN  NextLevelOfCacheToken
+      0x100000,                        // UINT32  Size
+      1024,                            // UINT32  NumberOfSets
+      16,                              // UINT32  Associativity
+      CACHE_ATTRIBUTES (               // UINT8   Attributes
+        EFI_ACPI_6_3_CACHE_ATTRIBUTES_ALLOCATION_READ_WRITE,
+        EFI_ACPI_6_3_CACHE_ATTRIBUTES_CACHE_TYPE_UNIFIED,
+        EFI_ACPI_6_3_CACHE_ATTRIBUTES_WRITE_POLICY_WRITE_BACK
+      ),
+      64                               // UINT16  LineSize
+    },
+    // 'LITTLE' core's L1 instruction cache
+    {
+      REFERENCE_TOKEN (CacheInfo[4]),  // CM_OBJECT_TOKEN  Token
+      CM_NULL_TOKEN,                   // CM_OBJECT_TOKEN  NextLevelOfCacheToken
+      0x8000,                          // UINT32  Size
+      256,                             // UINT32  NumberOfSets
+      2,                               // UINT32  Associativity
+      CACHE_ATTRIBUTES (               // UINT8   Attributes
+        EFI_ACPI_6_3_CACHE_ATTRIBUTES_ALLOCATION_READ,
+        EFI_ACPI_6_3_CACHE_ATTRIBUTES_CACHE_TYPE_INSTRUCTION,
+        EFI_ACPI_6_3_CACHE_ATTRIBUTES_WRITE_POLICY_WRITE_BACK
+      ),
+      64                               // UINT16  LineSize
+    },
+    // 'LITTLE' core's L1 data cache
+    {
+      REFERENCE_TOKEN (CacheInfo[5]),  // CM_OBJECT_TOKEN  Token
+      CM_NULL_TOKEN,                   // CM_OBJECT_TOKEN  NextLevelOfCacheToken
+      0x8000,                          // UINT32  Size
+      128,                             // UINT32  NumberOfSets
+      4,                               // UINT32  Associativity
+      CACHE_ATTRIBUTES (               // UINT8   Attributes
+        EFI_ACPI_6_3_CACHE_ATTRIBUTES_ALLOCATION_READ_WRITE,
+        EFI_ACPI_6_3_CACHE_ATTRIBUTES_CACHE_TYPE_DATA,
+        EFI_ACPI_6_3_CACHE_ATTRIBUTES_WRITE_POLICY_WRITE_BACK
+      ),
+      64                               // UINT16  LineSize
+    }
+  },
+  // Resources private to the 'big' cluster (shared among cores)
+  {
+    { REFERENCE_TOKEN (CacheInfo[0]) }  // -> 'big' cluster's L2 cache
+  },
+  // Resources private to each individual 'big' core instance
+  {
+    { REFERENCE_TOKEN (CacheInfo[1]) }, // -> 'big' core's L1 I-cache
+    { REFERENCE_TOKEN (CacheInfo[2]) }  // -> 'big' core's L1 D-cache
+  },
+  // Resources private to the 'LITTLE' cluster (shared among cores)
+  {
+    { REFERENCE_TOKEN (CacheInfo[3]) }  // -> 'LITTLE' cluster's L2 cache
+  },
+  // Resources private to each individual 'LITTLE' core instance
+  {
+    { REFERENCE_TOKEN (CacheInfo[4]) }, // -> 'LITTLE' core's L1 I-cache
+    { REFERENCE_TOKEN (CacheInfo[5]) }  // -> 'LITTLE' core's L1 D-cache
   }
 };
 
@@ -329,6 +630,116 @@ GetGTBlockTimerFrameInfo (
   return EFI_SUCCESS;
 }
 
+/** Return GIC CPU Interface Info.
+
+  @param [in]      This           Pointer to the Configuration Manager Protocol.
+  @param [in]      CmObjectId     The Object ID of the CM object requested
+  @param [in]      SearchToken    A unique token for identifying the requested
+                                  CM_ARM_GICC_INFO object.
+  @param [in, out] CmObject       Pointer to the Configuration Manager Object
+                                  descriptor describing the requested Object.
+
+  @retval EFI_SUCCESS             Success.
+  @retval EFI_INVALID_PARAMETER   A parameter is invalid.
+  @retval EFI_NOT_FOUND           The required object information is not found.
+**/
+EFI_STATUS
+EFIAPI
+GetGicCInfo (
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  * CONST This,
+  IN  CONST CM_OBJECT_ID                                  CmObjectId,
+  IN  CONST CM_OBJECT_TOKEN                               SearchToken,
+  IN  OUT   CM_OBJ_DESCRIPTOR                     * CONST CmObject
+  )
+{
+  EDKII_PLATFORM_REPOSITORY_INFO  * PlatformRepo;
+  UINT32                            TotalObjCount;
+  UINT32                            ObjIndex;
+
+  if ((This == NULL) || (CmObject == NULL)) {
+    ASSERT (This != NULL);
+    ASSERT (CmObject != NULL);
+    return EFI_INVALID_PARAMETER;
+  }
+
+  PlatformRepo = This->PlatRepoInfo;
+
+  TotalObjCount = ARRAY_SIZE (PlatformRepo->GicCInfo);
+
+  for (ObjIndex = 0; ObjIndex < TotalObjCount; ObjIndex++) {
+    if (SearchToken == (CM_OBJECT_TOKEN)&PlatformRepo->GicCInfo[ObjIndex]) {
+      CmObject->ObjectId = CmObjectId;
+      CmObject->Size = sizeof (PlatformRepo->GicCInfo[ObjIndex]);
+      CmObject->Data = (VOID*)&PlatformRepo->GicCInfo[ObjIndex];
+      CmObject->Count = 1;
+      return EFI_SUCCESS;
+    }
+  }
+
+  return EFI_NOT_FOUND;
+}
+
+/** Return a list of Configuration Manager object references pointed to by the
+    given input token.
+
+  @param [in]      This           Pointer to the Configuration Manager Protocol.
+  @param [in]      CmObjectId     The Object ID of the CM object requested
+  @param [in]      SearchToken    A unique token for identifying the requested
+                                  CM_ARM_OBJ_REF list.
+  @param [in, out] CmObject       Pointer to the Configuration Manager Object
+                                  descriptor describing the requested Object.
+
+  @retval EFI_SUCCESS             Success.
+  @retval EFI_INVALID_PARAMETER   A parameter is invalid.
+  @retval EFI_NOT_FOUND           The required object information is not found.
+**/
+EFI_STATUS
+EFIAPI
+GetCmObjRefs (
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  * CONST This,
+  IN  CONST CM_OBJECT_ID                                  CmObjectId,
+  IN  CONST CM_OBJECT_TOKEN                               SearchToken,
+  IN  OUT   CM_OBJ_DESCRIPTOR                     * CONST CmObject
+  )
+{
+  EDKII_PLATFORM_REPOSITORY_INFO  * PlatformRepo;
+
+  if ((This == NULL) || (CmObject == NULL)) {
+    ASSERT (This != NULL);
+    ASSERT (CmObject != NULL);
+    return EFI_INVALID_PARAMETER;
+  }
+
+  PlatformRepo = This->PlatRepoInfo;
+
+  if (SearchToken == (CM_OBJECT_TOKEN)&PlatformRepo->BigClusterResources) {
+    CmObject->Size = sizeof (PlatformRepo->BigClusterResources);
+    CmObject->Data = (VOID*)&PlatformRepo->BigClusterResources;
+    CmObject->Count = ARRAY_SIZE (PlatformRepo->BigClusterResources);
+    return EFI_SUCCESS;
+  }
+  if (SearchToken == (CM_OBJECT_TOKEN)&PlatformRepo->BigCoreResources) {
+    CmObject->Size = sizeof (PlatformRepo->BigCoreResources);
+    CmObject->Data = (VOID*)&PlatformRepo->BigCoreResources;
+    CmObject->Count = ARRAY_SIZE (PlatformRepo->BigCoreResources);
+    return EFI_SUCCESS;
+  }
+  if (SearchToken == (CM_OBJECT_TOKEN)&PlatformRepo->LittleClusterResources) {
+    CmObject->Size = sizeof (PlatformRepo->LittleClusterResources);
+    CmObject->Data = (VOID*)&PlatformRepo->LittleClusterResources;
+    CmObject->Count = ARRAY_SIZE (PlatformRepo->LittleClusterResources);
+    return EFI_SUCCESS;
+  }
+  if (SearchToken == (CM_OBJECT_TOKEN)&PlatformRepo->LittleCoreResources) {
+    CmObject->Size = sizeof (PlatformRepo->LittleCoreResources);
+    CmObject->Data = (VOID*)&PlatformRepo->LittleCoreResources;
+    CmObject->Count = ARRAY_SIZE (PlatformRepo->LittleCoreResources);
+    return EFI_SUCCESS;
+  }
+
+  return EFI_NOT_FOUND;
+}
+
 /** Return a standard namespace object.
 
   @param [in]      This        Pointer to the Configuration Manager Protocol.
@@ -486,12 +897,13 @@ GetArmNameSpaceObject (
       Token,
       GetGTBlockTimerFrameInfo
       );
-    HANDLE_CM_OBJECT (
+    HANDLE_CM_OBJECT_REF_BY_TOKEN (
       EArmObjGicCInfo,
       CmObjectId,
       PlatformRepo->GicCInfo,
-      (sizeof (PlatformRepo->GicCInfo) /
-         sizeof (PlatformRepo->GicCInfo[0]))
+      ARRAY_SIZE (PlatformRepo->GicCInfo),
+      Token,
+      GetGicCInfo
       );
     HANDLE_CM_OBJECT (
       EArmObjGicDInfo,
@@ -518,6 +930,24 @@ GetArmNameSpaceObject (
       PlatformRepo->GicMsiFrameInfo,
       1
       );
+    HANDLE_CM_OBJECT (
+      EArmObjProcHierarchyInfo,
+      CmObjectId,
+      PlatformRepo->ProcHierarchyInfo,
+      ARRAY_SIZE (PlatformRepo->ProcHierarchyInfo)
+      );
+    HANDLE_CM_OBJECT (
+      EArmObjCacheInfo,
+      CmObjectId,
+      PlatformRepo->CacheInfo,
+      ARRAY_SIZE (PlatformRepo->CacheInfo)
+      );
+    HANDLE_CM_OBJECT_SEARCH_PLAT_REPO (
+      EArmObjCmRef,
+      CmObjectId,
+      Token,
+      GetCmObjRefs
+      );
 
     case EArmObjPciConfigSpaceInfo:
       if (PlatformRepo->JunoRevision != JUNO_REVISION_R0) {
diff --git a/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.h b/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.h
index 060817430fe75fdf79196f8a9d31561028fb0f50..7fdf663fc6d2ad80da26ff1f1635c858d5be4e93 100644
--- a/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.h
+++ b/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.h
@@ -20,6 +20,12 @@
 */
 #define CFG_MGR_OEM_ID    { 'A', 'R', 'M', 'L', 'T', 'D' }
 
+/** A helper macro for mapping a reference token
+*/
+#define REFERENCE_TOKEN(Field)                                           \
+  (CM_OBJECT_TOKEN)((UINT8*)&ArmJunoPlatformRepositoryInfo +             \
+    OFFSET_OF (EDKII_PLATFORM_REPOSITORY_INFO, Field))
+
 /** A helper macro for populating the GIC CPU information
 */
 #define GICC_ENTRY(                                                      \
@@ -46,6 +52,36 @@
     EnergyEfficiency          /* UINT8   ProcessorPowerEfficiencyClass*/ \
     }
 
+/** A helper macro for populating the Processor Hierarchy Node flags
+*/
+#define PROC_NODE_FLAGS(                                                \
+          PhysicalPackage,                                              \
+          AcpiProcessorIdValid,                                         \
+          ProcessorIsThread,                                            \
+          NodeIsLeaf,                                                   \
+          IdenticalImplementation                                       \
+          )                                                             \
+  (                                                                     \
+    PhysicalPackage |                                                   \
+    (AcpiProcessorIdValid << 1) |                                       \
+    (ProcessorIsThread << 2) |                                          \
+    (NodeIsLeaf << 3) |                                                 \
+    (IdenticalImplementation << 4)                                      \
+  )
+
+/** A helper macro for populating the Cache Type Structure's attributes
+*/
+#define CACHE_ATTRIBUTES(                                               \
+          AllocationType,                                               \
+          CacheType,                                                    \
+          WritePolicy                                                   \
+          )                                                             \
+  (                                                                     \
+    AllocationType |                                                    \
+    (CacheType << 2) |                                                  \
+    (WritePolicy << 4)                                                  \
+  )
+
 /** A helper macro for returning configuration manager objects
 */
 #define HANDLE_CM_OBJECT(ObjId, CmObjectId, Object, ObjectCount)      \
@@ -102,13 +138,46 @@
     break;                                                                  \
   }
 
+/** A helper macro for returning configuration manager objects referenced
+    by token when the entire platform repository is in scope and the
+    CM_NULL_TOKEN value is not allowed.
+*/
+#define HANDLE_CM_OBJECT_SEARCH_PLAT_REPO(                                  \
+          ObjId,                                                            \
+          CmObjectId,                                                       \
+          Token,                                                            \
+          HandlerProc                                                       \
+          )                                                                 \
+  case ObjId: {                                                             \
+    CmObject->ObjectId = CmObjectId;                                        \
+    if (Token == CM_NULL_TOKEN) {                                           \
+      Status = EFI_INVALID_PARAMETER;                                       \
+      DEBUG ((                                                              \
+        DEBUG_ERROR,                                                        \
+        #ObjId ": CM_NULL_TOKEN value is not allowed when searching"        \
+        " the entire platform repository.\n"                                \
+        ));                                                                 \
+    } else {                                                                \
+      Status = HandlerProc (This, CmObjectId, Token, CmObject);             \
+      DEBUG ((                                                              \
+        DEBUG_INFO,                                                         \
+        #ObjId ": Token = 0x%p, Ptr = 0x%p, Size = %d, Count = %d\n",       \
+        (VOID*)Token,                                                       \
+        CmObject->Data,                                                     \
+        CmObject->Size,                                                     \
+        CmObject->Count                                                     \
+        ));                                                                 \
+    }                                                                       \
+    break;                                                                  \
+  }
+
 /** The number of CPUs
 */
 #define PLAT_CPU_COUNT          6
 
 /** The number of ACPI tables to install
 */
-#define PLAT_ACPI_TABLE_COUNT   10
+#define PLAT_ACPI_TABLE_COUNT   11
 
 /** The number of platform generic timer blocks
 */
@@ -118,6 +187,53 @@
 */
 #define PLAT_GTFRAME_COUNT          2
 
+/** For all Juno revisions, the cache and processor topology is identical.
+
+  Terms 'big' and 'LITTLE' are used in favour of A72, A57 or A53 to take into
+  account that Juno r2 uses Cortex-A72 as 'big' cores, whereas Juno r0 and r1
+  have Cortex-A57 as 'big' cores.
+*/
+
+/** The number of Processor Hierarchy Nodes
+    - one package node
+    - two cluster nodes ('big' + 'LITTLE')
+    - two 'big' cores
+    - four 'LITTLE' cores
+*/
+#define PLAT_PROC_HIERARCHY_NODE_COUNT  9
+
+/** The number of unique cache structures:
+    - 'big' core L1 instruction cache
+    - 'big' core L1 data cache
+    - 'big' core L2 cache
+    - 'LITTLE' core L1 instruction cache
+    - 'LITTLE' core L1 data cache
+    - 'LITTLE' core L2 cache
+*/
+#define PLAT_CACHE_COUNT                6
+
+/** The number of resources private to the entire 'big' cluster
+    - L2 cache
+*/
+#define BIG_CLUSTER_RESOURCE_COUNT  1
+
+/** The number of resources private to 'big' core instance
+    - L1 data cache
+    - L1 instruction cache
+*/
+#define BIG_CORE_RESOURCE_COUNT  2
+
+/** The number of resources private to the entire 'LITTLE' cluster
+    - L2 cache
+*/
+#define LITTLE_CLUSTER_RESOURCE_COUNT  1
+
+/** The number of resources private to each 'LITTLE' core instance
+    - L1 data cache
+    - L1 instruction cache
+*/
+#define LITTLE_CORE_RESOURCE_COUNT  2
+
 /** A structure describing the platform configuration
     manager repository information
 */
@@ -166,6 +282,24 @@ typedef struct PlatformRepositoryInfo {
   /// GIC MSI Frame information
   CM_ARM_GIC_MSI_FRAME_INFO             GicMsiFrameInfo;
 
+  // Processor topology information
+  CM_ARM_PROC_HIERARCHY_INFO            ProcHierarchyInfo[PLAT_PROC_HIERARCHY_NODE_COUNT];
+
+  // Cache information
+  CM_ARM_CACHE_INFO                     CacheInfo[PLAT_CACHE_COUNT];
+
+  // 'big' cluster private resources
+  CM_ARM_OBJ_REF                        BigClusterResources[BIG_CLUSTER_RESOURCE_COUNT];
+
+  // 'big' core private resources
+  CM_ARM_OBJ_REF                        BigCoreResources[BIG_CORE_RESOURCE_COUNT];
+
+  // 'LITTLE' cluster private resources
+  CM_ARM_OBJ_REF                        LittleClusterResources[LITTLE_CLUSTER_RESOURCE_COUNT];
+
+  // 'LITTLE' core private resources
+  CM_ARM_OBJ_REF                        LittleCoreResources[LITTLE_CORE_RESOURCE_COUNT];
+
   /// Juno Board Revision
   UINT32                                JunoRevision;
 } EDKII_PLATFORM_REPOSITORY_INFO;
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [edk2-platforms PATCH v2 1/1] Platform/ARM: Juno: Add support for PPTT dynamic generation
  2019-06-18  9:24 [edk2-platforms PATCH v2 1/1] Platform/ARM: Juno: Add support for PPTT dynamic generation Krzysztof Koch
@ 2019-06-18 18:16 ` Leif Lindholm
  0 siblings, 0 replies; 2+ messages in thread
From: Leif Lindholm @ 2019-06-18 18:16 UTC (permalink / raw)
  To: Krzysztof Koch
  Cc: devel, Ard Biesheuvel, Michael D Kinney, Sami.Mujawar,
	Matteo.Carlini, Stephanie.Hughes-Fitt, nd

On Tue, Jun 18, 2019 at 10:24:53AM +0100, Krzysztof Koch wrote:
> Update the Platform Respository for the Juno platform
> to include support for generation of the Processor Properties
> Topology Table (PPTT) using the Dynamic Tables Framework.
> 
> The Platform Repository now also describes the cache and
> processor topology in Juno (all revisions).
> 
> Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>

Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Pushed as 2ff8f1bf36.

> ---
> 
> Changes can be seen at: https://github.com/KrzysztofKoch1/edk2-platforms/tree/392_dynamic_pptt_juno_v2
> 
> Notes:
>     v2:
>     - use ARRAY_SIZE macro from Base.h to compute array size [Leif]
>     v1:
>     - add support for dynamic generation of PPTT [Krzysztof]
> 
>  Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c | 438 +++++++++++++++++++-
>  Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.h | 136 +++++-
>  2 files changed, 569 insertions(+), 5 deletions(-)
> 
> diff --git a/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c b/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
> index 78b906ddb8bbd35c32b4be98b1ee8bd973b6b818..d52cc2982334ded1c3bf2f5e8f570378d8fb0ae1 100644
> --- a/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
> +++ b/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
> @@ -96,7 +96,13 @@ EDKII_PLATFORM_REPOSITORY_INFO ArmJunoPlatformRepositoryInfo = {
>        CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdSsdt),
>        (EFI_ACPI_DESCRIPTION_HEADER*)ssdtuart_aml_code
>      },
> -
> +    // PPTT Table
> +    {
> +      EFI_ACPI_6_3_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_STRUCTURE_SIGNATURE,
> +      EFI_ACPI_6_3_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_REVISION,
> +      CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdPptt),
> +      NULL
> +    },
>      /* PCI MCFG Table
>         PCIe is only available on Juno R1 and R2.
>         Add the PCI table entries at the end of the table so that
> @@ -261,6 +267,301 @@ EDKII_PLATFORM_REPOSITORY_INFO ArmJunoPlatformRepositoryInfo = {
>      127,
>      // SPI Base used by this frame.
>      224
> +  },
> +
> +  // Processor Hierarchy Nodes
> +  {
> +    // Package
> +    {
> +      // CM_OBJECT_TOKEN  Token
> +      REFERENCE_TOKEN (ProcHierarchyInfo[0]),
> +      // UINT32  Flags
> +      PROC_NODE_FLAGS (
> +        EFI_ACPI_6_3_PPTT_PACKAGE_PHYSICAL,
> +        EFI_ACPI_6_3_PPTT_PROCESSOR_ID_INVALID,
> +        EFI_ACPI_6_3_PPTT_PROCESSOR_IS_NOT_THREAD,
> +        EFI_ACPI_6_3_PPTT_NODE_IS_NOT_LEAF,
> +        EFI_ACPI_6_3_PPTT_IMPLEMENTATION_NOT_IDENTICAL
> +      ),
> +      // CM_OBJECT_TOKEN  ParentToken
> +      CM_NULL_TOKEN,
> +      // CM_OBJECT_TOKEN  GicCToken
> +      CM_NULL_TOKEN,
> +      // UINT32  NoOfPrivateResources
> +      0,
> +      // CM_OBJECT_TOKEN  PrivateResourcesArrayToken
> +      CM_NULL_TOKEN
> +    },
> +    // 'big' cluster
> +    {
> +      // CM_OBJECT_TOKEN  Token
> +      REFERENCE_TOKEN (ProcHierarchyInfo[1]),
> +      // UINT32  Flags
> +      PROC_NODE_FLAGS (
> +        EFI_ACPI_6_3_PPTT_PACKAGE_NOT_PHYSICAL,
> +        EFI_ACPI_6_3_PPTT_PROCESSOR_ID_INVALID,
> +        EFI_ACPI_6_3_PPTT_PROCESSOR_IS_NOT_THREAD,
> +        EFI_ACPI_6_3_PPTT_NODE_IS_NOT_LEAF,
> +        EFI_ACPI_6_3_PPTT_IMPLEMENTATION_IDENTICAL
> +      ),
> +      // CM_OBJECT_TOKEN  ParentToken
> +      REFERENCE_TOKEN (ProcHierarchyInfo[0]), // -> Package
> +      // CM_OBJECT_TOKEN  GicCToken
> +      CM_NULL_TOKEN,
> +      // UINT32  NoOfPrivateResources
> +      BIG_CLUSTER_RESOURCE_COUNT,
> +      // CM_OBJECT_TOKEN  PrivateResourcesArrayToken
> +      REFERENCE_TOKEN (BigClusterResources)
> +    },
> +    // 'LITTLE' cluster
> +    {
> +      // CM_OBJECT_TOKEN  Token
> +      REFERENCE_TOKEN (ProcHierarchyInfo[2]),
> +      // UINT32  Flags
> +      PROC_NODE_FLAGS (
> +        EFI_ACPI_6_3_PPTT_PACKAGE_NOT_PHYSICAL,
> +        EFI_ACPI_6_3_PPTT_PROCESSOR_ID_INVALID,
> +        EFI_ACPI_6_3_PPTT_PROCESSOR_IS_NOT_THREAD,
> +        EFI_ACPI_6_3_PPTT_NODE_IS_NOT_LEAF,
> +        EFI_ACPI_6_3_PPTT_IMPLEMENTATION_IDENTICAL
> +      ),
> +      // CM_OBJECT_TOKEN  ParentToken
> +      REFERENCE_TOKEN (ProcHierarchyInfo[0]), // -> Package
> +      // CM_OBJECT_TOKEN  GicCToken
> +      CM_NULL_TOKEN,
> +      // UINT32  NoOfPrivateResources
> +      LITTLE_CLUSTER_RESOURCE_COUNT,
> +      // CM_OBJECT_TOKEN  PrivateResourcesArrayToken
> +      REFERENCE_TOKEN (LittleClusterResources)
> +    },
> +    // Two 'big' cores
> +    {
> +      // CM_OBJECT_TOKEN  Token
> +      REFERENCE_TOKEN (ProcHierarchyInfo[3]),
> +      // UINT32  Flags
> +      PROC_NODE_FLAGS (
> +        EFI_ACPI_6_3_PPTT_PACKAGE_NOT_PHYSICAL,
> +        EFI_ACPI_6_3_PPTT_PROCESSOR_ID_VALID,
> +        EFI_ACPI_6_3_PPTT_PROCESSOR_IS_NOT_THREAD,
> +        EFI_ACPI_6_3_PPTT_NODE_IS_LEAF,
> +        EFI_ACPI_6_3_PPTT_IMPLEMENTATION_NOT_IDENTICAL
> +      ),
> +      // CM_OBJECT_TOKEN  ParentToken
> +      REFERENCE_TOKEN (ProcHierarchyInfo[1]), // -> 'big' cluster
> +      // CM_OBJECT_TOKEN  GicCToken
> +      REFERENCE_TOKEN (GicCInfo[0]),
> +      // UINT32  NoOfPrivateResources
> +      BIG_CORE_RESOURCE_COUNT,
> +      // CM_OBJECT_TOKEN  PrivateResourcesArrayToken
> +      REFERENCE_TOKEN (BigCoreResources)
> +    },
> +    {
> +      // CM_OBJECT_TOKEN  Token
> +      REFERENCE_TOKEN (ProcHierarchyInfo[4]),
> +      // UINT32  Flags
> +      PROC_NODE_FLAGS (
> +        EFI_ACPI_6_3_PPTT_PACKAGE_NOT_PHYSICAL,
> +        EFI_ACPI_6_3_PPTT_PROCESSOR_ID_VALID,
> +        EFI_ACPI_6_3_PPTT_PROCESSOR_IS_NOT_THREAD,
> +        EFI_ACPI_6_3_PPTT_NODE_IS_LEAF,
> +        EFI_ACPI_6_3_PPTT_IMPLEMENTATION_NOT_IDENTICAL
> +      ),
> +      // CM_OBJECT_TOKEN  ParentToken
> +      REFERENCE_TOKEN (ProcHierarchyInfo[1]), // -> 'big' cluster
> +      // CM_OBJECT_TOKEN  GicCToken
> +      REFERENCE_TOKEN (GicCInfo[1]),
> +      // UINT32  NoOfPrivateResources
> +      BIG_CORE_RESOURCE_COUNT,
> +      // CM_OBJECT_TOKEN  PrivateResourcesArrayToken
> +      REFERENCE_TOKEN (BigCoreResources)
> +    },
> +    // Four 'LITTLE' cores
> +    {
> +      // CM_OBJECT_TOKEN  Token
> +      REFERENCE_TOKEN (ProcHierarchyInfo[5]),
> +      // UINT32  Flags
> +      PROC_NODE_FLAGS (
> +        EFI_ACPI_6_3_PPTT_PACKAGE_NOT_PHYSICAL,
> +        EFI_ACPI_6_3_PPTT_PROCESSOR_ID_VALID,
> +        EFI_ACPI_6_3_PPTT_PROCESSOR_IS_NOT_THREAD,
> +        EFI_ACPI_6_3_PPTT_NODE_IS_LEAF,
> +        EFI_ACPI_6_3_PPTT_IMPLEMENTATION_NOT_IDENTICAL
> +      ),
> +      // CM_OBJECT_TOKEN  ParentToken
> +      REFERENCE_TOKEN (ProcHierarchyInfo[2]), // -> 'LITTLE' cluster
> +      // CM_OBJECT_TOKEN  GicCToken
> +      REFERENCE_TOKEN (GicCInfo[2]),
> +      // UINT32  NoOfPrivateResources
> +      LITTLE_CORE_RESOURCE_COUNT,
> +      // CM_OBJECT_TOKEN  PrivateResourcesArrayToken
> +      REFERENCE_TOKEN (LittleCoreResources)
> +    },
> +    {
> +      // CM_OBJECT_TOKEN  Token
> +      REFERENCE_TOKEN (ProcHierarchyInfo[6]),
> +      // UINT32  Flags
> +      PROC_NODE_FLAGS (
> +        EFI_ACPI_6_3_PPTT_PACKAGE_NOT_PHYSICAL,
> +        EFI_ACPI_6_3_PPTT_PROCESSOR_ID_VALID,
> +        EFI_ACPI_6_3_PPTT_PROCESSOR_IS_NOT_THREAD,
> +        EFI_ACPI_6_3_PPTT_NODE_IS_LEAF,
> +        EFI_ACPI_6_3_PPTT_IMPLEMENTATION_NOT_IDENTICAL
> +      ),
> +      // CM_OBJECT_TOKEN  ParentToken
> +      REFERENCE_TOKEN (ProcHierarchyInfo[2]), // -> 'LITTLE' cluster
> +      // CM_OBJECT_TOKEN  GicCToken
> +      REFERENCE_TOKEN (GicCInfo[3]),
> +      // UINT32  NoOfPrivateResources
> +      LITTLE_CORE_RESOURCE_COUNT,
> +      // CM_OBJECT_TOKEN  PrivateResourcesArrayToken
> +      REFERENCE_TOKEN (LittleCoreResources)
> +    },
> +    {
> +      // CM_OBJECT_TOKEN  Token
> +      REFERENCE_TOKEN (ProcHierarchyInfo[7]),
> +      // UINT32  Flags
> +      PROC_NODE_FLAGS (
> +        EFI_ACPI_6_3_PPTT_PACKAGE_NOT_PHYSICAL,
> +        EFI_ACPI_6_3_PPTT_PROCESSOR_ID_VALID,
> +        EFI_ACPI_6_3_PPTT_PROCESSOR_IS_NOT_THREAD,
> +        EFI_ACPI_6_3_PPTT_NODE_IS_LEAF,
> +        EFI_ACPI_6_3_PPTT_IMPLEMENTATION_NOT_IDENTICAL
> +      ),
> +      // CM_OBJECT_TOKEN  ParentToken
> +      REFERENCE_TOKEN (ProcHierarchyInfo[2]), // -> 'LITTLE' cluster
> +      // CM_OBJECT_TOKEN  GicCToken
> +      REFERENCE_TOKEN (GicCInfo[4]),
> +      // UINT32  NoOfPrivateResources
> +      LITTLE_CORE_RESOURCE_COUNT,
> +      // CM_OBJECT_TOKEN  PrivateResourcesArrayToken
> +      REFERENCE_TOKEN (LittleCoreResources)
> +    },
> +    {
> +      // CM_OBJECT_TOKEN  Token
> +      REFERENCE_TOKEN (ProcHierarchyInfo[8]),
> +      // UINT32  Flags
> +      PROC_NODE_FLAGS (
> +        EFI_ACPI_6_3_PPTT_PACKAGE_NOT_PHYSICAL,
> +        EFI_ACPI_6_3_PPTT_PROCESSOR_ID_VALID,
> +        EFI_ACPI_6_3_PPTT_PROCESSOR_IS_NOT_THREAD,
> +        EFI_ACPI_6_3_PPTT_NODE_IS_LEAF,
> +        EFI_ACPI_6_3_PPTT_IMPLEMENTATION_NOT_IDENTICAL
> +      ),
> +      // CM_OBJECT_TOKEN  ParentToken
> +      REFERENCE_TOKEN (ProcHierarchyInfo[2]), // -> 'LITTLE' cluster
> +      // CM_OBJECT_TOKEN  GicCToken
> +      REFERENCE_TOKEN (GicCInfo[5]),
> +      // UINT32  NoOfPrivateResources
> +      LITTLE_CORE_RESOURCE_COUNT,
> +      // CM_OBJECT_TOKEN  PrivateResourcesArrayToken
> +      REFERENCE_TOKEN (LittleCoreResources)
> +    }
> +  },
> +
> +  // Cache information
> +  {
> +    // 'big' cluster's L2 cache
> +    {
> +      REFERENCE_TOKEN (CacheInfo[0]),  // CM_OBJECT_TOKEN  Token
> +      CM_NULL_TOKEN,                   // CM_OBJECT_TOKEN  NextLevelOfCacheToken
> +      0x200000,                        // UINT32  Size
> +      2048,                            // UINT32  NumberOfSets
> +      16,                              // UINT32  Associativity
> +      CACHE_ATTRIBUTES (               // UINT8   Attributes
> +        EFI_ACPI_6_3_CACHE_ATTRIBUTES_ALLOCATION_READ_WRITE,
> +        EFI_ACPI_6_3_CACHE_ATTRIBUTES_CACHE_TYPE_UNIFIED,
> +        EFI_ACPI_6_3_CACHE_ATTRIBUTES_WRITE_POLICY_WRITE_BACK
> +      ),
> +      64                               // UINT16  LineSize
> +    },
> +    // 'big' core's L1 instruction cache
> +    {
> +      REFERENCE_TOKEN (CacheInfo[1]),  // CM_OBJECT_TOKEN  Token
> +      CM_NULL_TOKEN,                   // CM_OBJECT_TOKEN  NextLevelOfCacheToken
> +      0xc000,                          // UINT32  Size
> +      256,                             // UINT32  NumberOfSets
> +      3,                               // UINT32  Associativity
> +      CACHE_ATTRIBUTES (               // UINT8   Attributes
> +        EFI_ACPI_6_3_CACHE_ATTRIBUTES_ALLOCATION_READ,
> +        EFI_ACPI_6_3_CACHE_ATTRIBUTES_CACHE_TYPE_INSTRUCTION,
> +        EFI_ACPI_6_3_CACHE_ATTRIBUTES_WRITE_POLICY_WRITE_BACK
> +      ),
> +      64                               // UINT16  LineSize
> +    },
> +    // 'big' core's L1 data cache
> +    {
> +      REFERENCE_TOKEN (CacheInfo[2]),  // CM_OBJECT_TOKEN  Token
> +      CM_NULL_TOKEN,                   // CM_OBJECT_TOKEN  NextLevelOfCacheToken
> +      0x8000,                          // UINT32  Size
> +      256,                             // UINT32  NumberOfSets
> +      2,                               // UINT32  Associativity
> +      CACHE_ATTRIBUTES (               // UINT8   Attributes
> +        EFI_ACPI_6_3_CACHE_ATTRIBUTES_ALLOCATION_READ_WRITE,
> +        EFI_ACPI_6_3_CACHE_ATTRIBUTES_CACHE_TYPE_DATA,
> +        EFI_ACPI_6_3_CACHE_ATTRIBUTES_WRITE_POLICY_WRITE_BACK
> +      ),
> +      64                               // UINT16  LineSize
> +    },
> +    // 'LITTLE' cluster's L2 cache
> +    {
> +      REFERENCE_TOKEN (CacheInfo[3]),  // CM_OBJECT_TOKEN  Token
> +      CM_NULL_TOKEN,                   // CM_OBJECT_TOKEN  NextLevelOfCacheToken
> +      0x100000,                        // UINT32  Size
> +      1024,                            // UINT32  NumberOfSets
> +      16,                              // UINT32  Associativity
> +      CACHE_ATTRIBUTES (               // UINT8   Attributes
> +        EFI_ACPI_6_3_CACHE_ATTRIBUTES_ALLOCATION_READ_WRITE,
> +        EFI_ACPI_6_3_CACHE_ATTRIBUTES_CACHE_TYPE_UNIFIED,
> +        EFI_ACPI_6_3_CACHE_ATTRIBUTES_WRITE_POLICY_WRITE_BACK
> +      ),
> +      64                               // UINT16  LineSize
> +    },
> +    // 'LITTLE' core's L1 instruction cache
> +    {
> +      REFERENCE_TOKEN (CacheInfo[4]),  // CM_OBJECT_TOKEN  Token
> +      CM_NULL_TOKEN,                   // CM_OBJECT_TOKEN  NextLevelOfCacheToken
> +      0x8000,                          // UINT32  Size
> +      256,                             // UINT32  NumberOfSets
> +      2,                               // UINT32  Associativity
> +      CACHE_ATTRIBUTES (               // UINT8   Attributes
> +        EFI_ACPI_6_3_CACHE_ATTRIBUTES_ALLOCATION_READ,
> +        EFI_ACPI_6_3_CACHE_ATTRIBUTES_CACHE_TYPE_INSTRUCTION,
> +        EFI_ACPI_6_3_CACHE_ATTRIBUTES_WRITE_POLICY_WRITE_BACK
> +      ),
> +      64                               // UINT16  LineSize
> +    },
> +    // 'LITTLE' core's L1 data cache
> +    {
> +      REFERENCE_TOKEN (CacheInfo[5]),  // CM_OBJECT_TOKEN  Token
> +      CM_NULL_TOKEN,                   // CM_OBJECT_TOKEN  NextLevelOfCacheToken
> +      0x8000,                          // UINT32  Size
> +      128,                             // UINT32  NumberOfSets
> +      4,                               // UINT32  Associativity
> +      CACHE_ATTRIBUTES (               // UINT8   Attributes
> +        EFI_ACPI_6_3_CACHE_ATTRIBUTES_ALLOCATION_READ_WRITE,
> +        EFI_ACPI_6_3_CACHE_ATTRIBUTES_CACHE_TYPE_DATA,
> +        EFI_ACPI_6_3_CACHE_ATTRIBUTES_WRITE_POLICY_WRITE_BACK
> +      ),
> +      64                               // UINT16  LineSize
> +    }
> +  },
> +  // Resources private to the 'big' cluster (shared among cores)
> +  {
> +    { REFERENCE_TOKEN (CacheInfo[0]) }  // -> 'big' cluster's L2 cache
> +  },
> +  // Resources private to each individual 'big' core instance
> +  {
> +    { REFERENCE_TOKEN (CacheInfo[1]) }, // -> 'big' core's L1 I-cache
> +    { REFERENCE_TOKEN (CacheInfo[2]) }  // -> 'big' core's L1 D-cache
> +  },
> +  // Resources private to the 'LITTLE' cluster (shared among cores)
> +  {
> +    { REFERENCE_TOKEN (CacheInfo[3]) }  // -> 'LITTLE' cluster's L2 cache
> +  },
> +  // Resources private to each individual 'LITTLE' core instance
> +  {
> +    { REFERENCE_TOKEN (CacheInfo[4]) }, // -> 'LITTLE' core's L1 I-cache
> +    { REFERENCE_TOKEN (CacheInfo[5]) }  // -> 'LITTLE' core's L1 D-cache
>    }
>  };
>  
> @@ -329,6 +630,116 @@ GetGTBlockTimerFrameInfo (
>    return EFI_SUCCESS;
>  }
>  
> +/** Return GIC CPU Interface Info.
> +
> +  @param [in]      This           Pointer to the Configuration Manager Protocol.
> +  @param [in]      CmObjectId     The Object ID of the CM object requested
> +  @param [in]      SearchToken    A unique token for identifying the requested
> +                                  CM_ARM_GICC_INFO object.
> +  @param [in, out] CmObject       Pointer to the Configuration Manager Object
> +                                  descriptor describing the requested Object.
> +
> +  @retval EFI_SUCCESS             Success.
> +  @retval EFI_INVALID_PARAMETER   A parameter is invalid.
> +  @retval EFI_NOT_FOUND           The required object information is not found.
> +**/
> +EFI_STATUS
> +EFIAPI
> +GetGicCInfo (
> +  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  * CONST This,
> +  IN  CONST CM_OBJECT_ID                                  CmObjectId,
> +  IN  CONST CM_OBJECT_TOKEN                               SearchToken,
> +  IN  OUT   CM_OBJ_DESCRIPTOR                     * CONST CmObject
> +  )
> +{
> +  EDKII_PLATFORM_REPOSITORY_INFO  * PlatformRepo;
> +  UINT32                            TotalObjCount;
> +  UINT32                            ObjIndex;
> +
> +  if ((This == NULL) || (CmObject == NULL)) {
> +    ASSERT (This != NULL);
> +    ASSERT (CmObject != NULL);
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  PlatformRepo = This->PlatRepoInfo;
> +
> +  TotalObjCount = ARRAY_SIZE (PlatformRepo->GicCInfo);
> +
> +  for (ObjIndex = 0; ObjIndex < TotalObjCount; ObjIndex++) {
> +    if (SearchToken == (CM_OBJECT_TOKEN)&PlatformRepo->GicCInfo[ObjIndex]) {
> +      CmObject->ObjectId = CmObjectId;
> +      CmObject->Size = sizeof (PlatformRepo->GicCInfo[ObjIndex]);
> +      CmObject->Data = (VOID*)&PlatformRepo->GicCInfo[ObjIndex];
> +      CmObject->Count = 1;
> +      return EFI_SUCCESS;
> +    }
> +  }
> +
> +  return EFI_NOT_FOUND;
> +}
> +
> +/** Return a list of Configuration Manager object references pointed to by the
> +    given input token.
> +
> +  @param [in]      This           Pointer to the Configuration Manager Protocol.
> +  @param [in]      CmObjectId     The Object ID of the CM object requested
> +  @param [in]      SearchToken    A unique token for identifying the requested
> +                                  CM_ARM_OBJ_REF list.
> +  @param [in, out] CmObject       Pointer to the Configuration Manager Object
> +                                  descriptor describing the requested Object.
> +
> +  @retval EFI_SUCCESS             Success.
> +  @retval EFI_INVALID_PARAMETER   A parameter is invalid.
> +  @retval EFI_NOT_FOUND           The required object information is not found.
> +**/
> +EFI_STATUS
> +EFIAPI
> +GetCmObjRefs (
> +  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  * CONST This,
> +  IN  CONST CM_OBJECT_ID                                  CmObjectId,
> +  IN  CONST CM_OBJECT_TOKEN                               SearchToken,
> +  IN  OUT   CM_OBJ_DESCRIPTOR                     * CONST CmObject
> +  )
> +{
> +  EDKII_PLATFORM_REPOSITORY_INFO  * PlatformRepo;
> +
> +  if ((This == NULL) || (CmObject == NULL)) {
> +    ASSERT (This != NULL);
> +    ASSERT (CmObject != NULL);
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  PlatformRepo = This->PlatRepoInfo;
> +
> +  if (SearchToken == (CM_OBJECT_TOKEN)&PlatformRepo->BigClusterResources) {
> +    CmObject->Size = sizeof (PlatformRepo->BigClusterResources);
> +    CmObject->Data = (VOID*)&PlatformRepo->BigClusterResources;
> +    CmObject->Count = ARRAY_SIZE (PlatformRepo->BigClusterResources);
> +    return EFI_SUCCESS;
> +  }
> +  if (SearchToken == (CM_OBJECT_TOKEN)&PlatformRepo->BigCoreResources) {
> +    CmObject->Size = sizeof (PlatformRepo->BigCoreResources);
> +    CmObject->Data = (VOID*)&PlatformRepo->BigCoreResources;
> +    CmObject->Count = ARRAY_SIZE (PlatformRepo->BigCoreResources);
> +    return EFI_SUCCESS;
> +  }
> +  if (SearchToken == (CM_OBJECT_TOKEN)&PlatformRepo->LittleClusterResources) {
> +    CmObject->Size = sizeof (PlatformRepo->LittleClusterResources);
> +    CmObject->Data = (VOID*)&PlatformRepo->LittleClusterResources;
> +    CmObject->Count = ARRAY_SIZE (PlatformRepo->LittleClusterResources);
> +    return EFI_SUCCESS;
> +  }
> +  if (SearchToken == (CM_OBJECT_TOKEN)&PlatformRepo->LittleCoreResources) {
> +    CmObject->Size = sizeof (PlatformRepo->LittleCoreResources);
> +    CmObject->Data = (VOID*)&PlatformRepo->LittleCoreResources;
> +    CmObject->Count = ARRAY_SIZE (PlatformRepo->LittleCoreResources);
> +    return EFI_SUCCESS;
> +  }
> +
> +  return EFI_NOT_FOUND;
> +}
> +
>  /** Return a standard namespace object.
>  
>    @param [in]      This        Pointer to the Configuration Manager Protocol.
> @@ -486,12 +897,13 @@ GetArmNameSpaceObject (
>        Token,
>        GetGTBlockTimerFrameInfo
>        );
> -    HANDLE_CM_OBJECT (
> +    HANDLE_CM_OBJECT_REF_BY_TOKEN (
>        EArmObjGicCInfo,
>        CmObjectId,
>        PlatformRepo->GicCInfo,
> -      (sizeof (PlatformRepo->GicCInfo) /
> -         sizeof (PlatformRepo->GicCInfo[0]))
> +      ARRAY_SIZE (PlatformRepo->GicCInfo),
> +      Token,
> +      GetGicCInfo
>        );
>      HANDLE_CM_OBJECT (
>        EArmObjGicDInfo,
> @@ -518,6 +930,24 @@ GetArmNameSpaceObject (
>        PlatformRepo->GicMsiFrameInfo,
>        1
>        );
> +    HANDLE_CM_OBJECT (
> +      EArmObjProcHierarchyInfo,
> +      CmObjectId,
> +      PlatformRepo->ProcHierarchyInfo,
> +      ARRAY_SIZE (PlatformRepo->ProcHierarchyInfo)
> +      );
> +    HANDLE_CM_OBJECT (
> +      EArmObjCacheInfo,
> +      CmObjectId,
> +      PlatformRepo->CacheInfo,
> +      ARRAY_SIZE (PlatformRepo->CacheInfo)
> +      );
> +    HANDLE_CM_OBJECT_SEARCH_PLAT_REPO (
> +      EArmObjCmRef,
> +      CmObjectId,
> +      Token,
> +      GetCmObjRefs
> +      );
>  
>      case EArmObjPciConfigSpaceInfo:
>        if (PlatformRepo->JunoRevision != JUNO_REVISION_R0) {
> diff --git a/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.h b/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.h
> index 060817430fe75fdf79196f8a9d31561028fb0f50..7fdf663fc6d2ad80da26ff1f1635c858d5be4e93 100644
> --- a/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.h
> +++ b/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.h
> @@ -20,6 +20,12 @@
>  */
>  #define CFG_MGR_OEM_ID    { 'A', 'R', 'M', 'L', 'T', 'D' }
>  
> +/** A helper macro for mapping a reference token
> +*/
> +#define REFERENCE_TOKEN(Field)                                           \
> +  (CM_OBJECT_TOKEN)((UINT8*)&ArmJunoPlatformRepositoryInfo +             \
> +    OFFSET_OF (EDKII_PLATFORM_REPOSITORY_INFO, Field))
> +
>  /** A helper macro for populating the GIC CPU information
>  */
>  #define GICC_ENTRY(                                                      \
> @@ -46,6 +52,36 @@
>      EnergyEfficiency          /* UINT8   ProcessorPowerEfficiencyClass*/ \
>      }
>  
> +/** A helper macro for populating the Processor Hierarchy Node flags
> +*/
> +#define PROC_NODE_FLAGS(                                                \
> +          PhysicalPackage,                                              \
> +          AcpiProcessorIdValid,                                         \
> +          ProcessorIsThread,                                            \
> +          NodeIsLeaf,                                                   \
> +          IdenticalImplementation                                       \
> +          )                                                             \
> +  (                                                                     \
> +    PhysicalPackage |                                                   \
> +    (AcpiProcessorIdValid << 1) |                                       \
> +    (ProcessorIsThread << 2) |                                          \
> +    (NodeIsLeaf << 3) |                                                 \
> +    (IdenticalImplementation << 4)                                      \
> +  )
> +
> +/** A helper macro for populating the Cache Type Structure's attributes
> +*/
> +#define CACHE_ATTRIBUTES(                                               \
> +          AllocationType,                                               \
> +          CacheType,                                                    \
> +          WritePolicy                                                   \
> +          )                                                             \
> +  (                                                                     \
> +    AllocationType |                                                    \
> +    (CacheType << 2) |                                                  \
> +    (WritePolicy << 4)                                                  \
> +  )
> +
>  /** A helper macro for returning configuration manager objects
>  */
>  #define HANDLE_CM_OBJECT(ObjId, CmObjectId, Object, ObjectCount)      \
> @@ -102,13 +138,46 @@
>      break;                                                                  \
>    }
>  
> +/** A helper macro for returning configuration manager objects referenced
> +    by token when the entire platform repository is in scope and the
> +    CM_NULL_TOKEN value is not allowed.
> +*/
> +#define HANDLE_CM_OBJECT_SEARCH_PLAT_REPO(                                  \
> +          ObjId,                                                            \
> +          CmObjectId,                                                       \
> +          Token,                                                            \
> +          HandlerProc                                                       \
> +          )                                                                 \
> +  case ObjId: {                                                             \
> +    CmObject->ObjectId = CmObjectId;                                        \
> +    if (Token == CM_NULL_TOKEN) {                                           \
> +      Status = EFI_INVALID_PARAMETER;                                       \
> +      DEBUG ((                                                              \
> +        DEBUG_ERROR,                                                        \
> +        #ObjId ": CM_NULL_TOKEN value is not allowed when searching"        \
> +        " the entire platform repository.\n"                                \
> +        ));                                                                 \
> +    } else {                                                                \
> +      Status = HandlerProc (This, CmObjectId, Token, CmObject);             \
> +      DEBUG ((                                                              \
> +        DEBUG_INFO,                                                         \
> +        #ObjId ": Token = 0x%p, Ptr = 0x%p, Size = %d, Count = %d\n",       \
> +        (VOID*)Token,                                                       \
> +        CmObject->Data,                                                     \
> +        CmObject->Size,                                                     \
> +        CmObject->Count                                                     \
> +        ));                                                                 \
> +    }                                                                       \
> +    break;                                                                  \
> +  }
> +
>  /** The number of CPUs
>  */
>  #define PLAT_CPU_COUNT          6
>  
>  /** The number of ACPI tables to install
>  */
> -#define PLAT_ACPI_TABLE_COUNT   10
> +#define PLAT_ACPI_TABLE_COUNT   11
>  
>  /** The number of platform generic timer blocks
>  */
> @@ -118,6 +187,53 @@
>  */
>  #define PLAT_GTFRAME_COUNT          2
>  
> +/** For all Juno revisions, the cache and processor topology is identical.
> +
> +  Terms 'big' and 'LITTLE' are used in favour of A72, A57 or A53 to take into
> +  account that Juno r2 uses Cortex-A72 as 'big' cores, whereas Juno r0 and r1
> +  have Cortex-A57 as 'big' cores.
> +*/
> +
> +/** The number of Processor Hierarchy Nodes
> +    - one package node
> +    - two cluster nodes ('big' + 'LITTLE')
> +    - two 'big' cores
> +    - four 'LITTLE' cores
> +*/
> +#define PLAT_PROC_HIERARCHY_NODE_COUNT  9
> +
> +/** The number of unique cache structures:
> +    - 'big' core L1 instruction cache
> +    - 'big' core L1 data cache
> +    - 'big' core L2 cache
> +    - 'LITTLE' core L1 instruction cache
> +    - 'LITTLE' core L1 data cache
> +    - 'LITTLE' core L2 cache
> +*/
> +#define PLAT_CACHE_COUNT                6
> +
> +/** The number of resources private to the entire 'big' cluster
> +    - L2 cache
> +*/
> +#define BIG_CLUSTER_RESOURCE_COUNT  1
> +
> +/** The number of resources private to 'big' core instance
> +    - L1 data cache
> +    - L1 instruction cache
> +*/
> +#define BIG_CORE_RESOURCE_COUNT  2
> +
> +/** The number of resources private to the entire 'LITTLE' cluster
> +    - L2 cache
> +*/
> +#define LITTLE_CLUSTER_RESOURCE_COUNT  1
> +
> +/** The number of resources private to each 'LITTLE' core instance
> +    - L1 data cache
> +    - L1 instruction cache
> +*/
> +#define LITTLE_CORE_RESOURCE_COUNT  2
> +
>  /** A structure describing the platform configuration
>      manager repository information
>  */
> @@ -166,6 +282,24 @@ typedef struct PlatformRepositoryInfo {
>    /// GIC MSI Frame information
>    CM_ARM_GIC_MSI_FRAME_INFO             GicMsiFrameInfo;
>  
> +  // Processor topology information
> +  CM_ARM_PROC_HIERARCHY_INFO            ProcHierarchyInfo[PLAT_PROC_HIERARCHY_NODE_COUNT];
> +
> +  // Cache information
> +  CM_ARM_CACHE_INFO                     CacheInfo[PLAT_CACHE_COUNT];
> +
> +  // 'big' cluster private resources
> +  CM_ARM_OBJ_REF                        BigClusterResources[BIG_CLUSTER_RESOURCE_COUNT];
> +
> +  // 'big' core private resources
> +  CM_ARM_OBJ_REF                        BigCoreResources[BIG_CORE_RESOURCE_COUNT];
> +
> +  // 'LITTLE' cluster private resources
> +  CM_ARM_OBJ_REF                        LittleClusterResources[LITTLE_CLUSTER_RESOURCE_COUNT];
> +
> +  // 'LITTLE' core private resources
> +  CM_ARM_OBJ_REF                        LittleCoreResources[LITTLE_CORE_RESOURCE_COUNT];
> +
>    /// Juno Board Revision
>    UINT32                                JunoRevision;
>  } EDKII_PLATFORM_REPOSITORY_INFO;
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
> 
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-06-18 18:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-18  9:24 [edk2-platforms PATCH v2 1/1] Platform/ARM: Juno: Add support for PPTT dynamic generation Krzysztof Koch
2019-06-18 18:16 ` Leif Lindholm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox