]> git.proxmox.com Git - mirror_edk2.git/commitdiff
DynamicTablesPkg: Add AddSsdtAcpiHeader()
authorPierre Gondois <Pierre.Gondois@arm.com>
Fri, 8 Oct 2021 14:46:14 +0000 (15:46 +0100)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Fri, 8 Oct 2021 15:39:42 +0000 (15:39 +0000)
To fetch the Oem information from the ConfigurationManagerProtocol
and the AcpiTableInfo, and populate the SSDT ACPI header when
creating a RootNode via the AmlLib, create AddSsdtAcpiHeader().

Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
DynamicTablesPkg/Include/Library/TableHelperLib.h
DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c

index 6d362ff99a27eb5d96179b94fd73ee8f8f399269..76f9e8c25feab16bd852e18cf9aff3098bd5ab68 100644 (file)
@@ -12,6 +12,8 @@
 #ifndef TABLE_HELPER_LIB_H_\r
 #define TABLE_HELPER_LIB_H_\r
 \r
+#include <Library/AmlLib/AmlLib.h>\r
+\r
 /** The GetCgfMgrInfo function gets the CM_STD_OBJ_CONFIGURATION_MANAGER_INFO\r
     object from the Configuration Manager.\r
 \r
@@ -62,6 +64,39 @@ AddAcpiHeader (
   IN      CONST UINT32                                        Length\r
   );\r
 \r
+/** Build a RootNode containing SSDT ACPI header information using the AmlLib.\r
+\r
+  The function utilizes the ACPI table Generator and the Configuration\r
+  Manager protocol to obtain any information required for constructing the\r
+  header. It then creates a RootNode. The SSDT ACPI header is part of the\r
+  RootNode.\r
+\r
+  This is essentially a wrapper around AmlCodeGenDefinitionBlock ()\r
+  from the AmlLib.\r
+\r
+  @param [in]   CfgMgrProtocol Pointer to the Configuration Manager\r
+                               protocol interface.\r
+  @param [in]   Generator      Pointer to the ACPI table Generator.\r
+  @param [in]   AcpiTableInfo  Pointer to the ACPI table info structure.\r
+  @param [out]  RootNode       If success, contains the created RootNode.\r
+                               The SSDT ACPI header is part of the RootNode.\r
+\r
+  @retval EFI_SUCCESS           Success.\r
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.\r
+  @retval EFI_NOT_FOUND         The required object information is not found.\r
+  @retval EFI_BAD_BUFFER_SIZE   The size returned by the Configuration\r
+                                Manager is less than the Object size for the\r
+                                requested object.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+AddSsdtAcpiHeader (\r
+  IN      CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  * CONST CfgMgrProtocol,\r
+  IN      CONST ACPI_TABLE_GENERATOR                  * CONST Generator,\r
+  IN      CONST CM_STD_OBJ_ACPI_TABLE_INFO            * CONST AcpiTableInfo,\r
+      OUT       AML_ROOT_NODE_HANDLE                  *       RootNode\r
+  );\r
+\r
 /**\r
   Function prototype for testing if two arbitrary objects are equal.\r
 \r
index f98da7ffdd67c17da36a35941db04f5f6451fa5e..d92c82eac99e7dfd04f0788eafe698b48c90865f 100644 (file)
@@ -185,6 +185,93 @@ error_handler:
   return Status;\r
 }\r
 \r
+/** Build a RootNode containing SSDT ACPI header information using the AmlLib.\r
+\r
+  The function utilizes the ACPI table Generator and the Configuration\r
+  Manager protocol to obtain any information required for constructing the\r
+  header. It then creates a RootNode. The SSDT ACPI header is part of the\r
+  RootNode.\r
+\r
+  This is essentially a wrapper around AmlCodeGenDefinitionBlock ()\r
+  from the AmlLib.\r
+\r
+  @param [in]   CfgMgrProtocol Pointer to the Configuration Manager\r
+                               protocol interface.\r
+  @param [in]   Generator      Pointer to the ACPI table Generator.\r
+  @param [in]   AcpiTableInfo  Pointer to the ACPI table info structure.\r
+  @param [out]  RootNode       If success, contains the created RootNode.\r
+                               The SSDT ACPI header is part of the RootNode.\r
+\r
+  @retval EFI_SUCCESS           Success.\r
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.\r
+  @retval EFI_NOT_FOUND         The required object information is not found.\r
+  @retval EFI_BAD_BUFFER_SIZE   The size returned by the Configuration\r
+                                Manager is less than the Object size for the\r
+                                requested object.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+AddSsdtAcpiHeader (\r
+  IN      CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  * CONST CfgMgrProtocol,\r
+  IN      CONST ACPI_TABLE_GENERATOR                  * CONST Generator,\r
+  IN      CONST CM_STD_OBJ_ACPI_TABLE_INFO            * CONST AcpiTableInfo,\r
+      OUT       AML_ROOT_NODE_HANDLE                  *       RootNode\r
+  )\r
+{\r
+  EFI_STATUS                               Status;\r
+  UINT64                                   OemTableId;\r
+  UINT32                                   OemRevision;\r
+  CM_STD_OBJ_CONFIGURATION_MANAGER_INFO  * CfgMfrInfo;\r
+\r
+  ASSERT (CfgMgrProtocol != NULL);\r
+  ASSERT (Generator != NULL);\r
+  ASSERT (AcpiTableInfo != NULL);\r
+\r
+  if ((CfgMgrProtocol == NULL)  ||\r
+      (Generator == NULL)       ||\r
+      (AcpiTableInfo == NULL)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Status = GetCgfMgrInfo (CfgMgrProtocol, &CfgMfrInfo);\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((\r
+      DEBUG_ERROR,\r
+      "ERROR: Failed to get Configuration Manager info. Status = %r\n",\r
+      Status\r
+      ));\r
+    return Status;\r
+  }\r
+\r
+  if (AcpiTableInfo->OemTableId != 0) {\r
+    OemTableId = AcpiTableInfo->OemTableId;\r
+  } else {\r
+    OemTableId = SIGNATURE_32 (\r
+                   CfgMfrInfo->OemId[0],\r
+                   CfgMfrInfo->OemId[1],\r
+                   CfgMfrInfo->OemId[2],\r
+                   CfgMfrInfo->OemId[3]\r
+                   ) |\r
+                 ((UINT64)Generator->AcpiTableSignature << 32);\r
+  }\r
+\r
+  if (AcpiTableInfo->OemRevision != 0) {\r
+    OemRevision = AcpiTableInfo->OemRevision;\r
+  } else {\r
+    OemRevision = CfgMfrInfo->Revision;\r
+  }\r
+\r
+  Status = AmlCodeGenDefinitionBlock (\r
+             "SSDT",\r
+             (CONST CHAR8*)&CfgMfrInfo->OemId,\r
+             (CONST CHAR8*)&OemTableId,\r
+             OemRevision,\r
+             RootNode\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+  return Status;\r
+}\r
+\r
 /**\r
   Test and report if a duplicate entry exists in the given array of comparable\r
   elements.\r