]> git.proxmox.com Git - mirror_edk2.git/commitdiff
DynamicTablesPkg: Arm Raw/DSDT/SSDT Generator
authorSami Mujawar <sami.mujawar@arm.com>
Sat, 15 Dec 2018 12:20:23 +0000 (12:20 +0000)
committerSami Mujawar <sami.mujawar@arm.com>
Tue, 19 Feb 2019 10:37:30 +0000 (10:37 +0000)
A Raw generator is a simple generator. This generator provides
the ability to install a binary blob (that contains ACPI table
data) as an ACPI table. The binary blob could be pre-generated
ACPI table data or it may be the pre-compiled output from an
iAsl compiler for a DSDT or SSDT table.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Alexei Fedorov <alexei.fedorov@arm.com>
DynamicTablesPkg/DynamicTables.dsc.inc
DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/AcpiRawLibArm.inf [new file with mode: 0644]
DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/RawGenerator.c [new file with mode: 0644]

index 0c47e85b88d737a914514be123e23370ee69e311..1dde21f393e9717c1d5adfbebe8dd8840da418c3 100644 (file)
@@ -15,6 +15,9 @@
 \r
 [Defines]\r
 \r
+[BuildOptions]\r
+  *_*_*_ASL_FLAGS          = -tc -li -so\r
+\r
 [LibraryClasses.common]\r
   TableHelperLib|DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf\r
 \r
   #\r
   # Dynamic Table Factory Dxe\r
   #\r
-  DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.inf\r
+  DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.inf {\r
+    <LibraryClasses>\r
+      NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/AcpiRawLibArm.inf\r
+  }\r
 \r
   #\r
   # Dynamic Tables Manager Dxe\r
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/AcpiRawLibArm.inf b/DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/AcpiRawLibArm.inf
new file mode 100644 (file)
index 0000000..213dbd1
--- /dev/null
@@ -0,0 +1,42 @@
+## @file\r
+#  Raw Table Generator\r
+#\r
+#  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.\r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution.  The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION    = 0x00010019\r
+  BASE_NAME      = AcpiRawLibArm\r
+  FILE_GUID      = 20F31568-D687-49BA-B326-CCD9D38EDE16\r
+  VERSION_STRING = 1.0\r
+  MODULE_TYPE    = DXE_DRIVER\r
+  LIBRARY_CLASS  = NULL|DXE_DRIVER\r
+  CONSTRUCTOR    = AcpiRawLibConstructor\r
+  DESTRUCTOR     = AcpiRawLibDestructor\r
+\r
+[Sources]\r
+  RawGenerator.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+  EmbeddedPkg/EmbeddedPkg.dec\r
+  DynamicTablesPkg/DynamicTablesPkg.dec\r
+\r
+[LibraryClasses]\r
+  BaseLib\r
+\r
+[Pcd]\r
+\r
+[Protocols]\r
+\r
+[Guids]\r
+\r
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/RawGenerator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/RawGenerator.c
new file mode 100644 (file)
index 0000000..ae3d3ec
--- /dev/null
@@ -0,0 +1,150 @@
+/** @file\r
+  MCFG Table Generator\r
+\r
+  Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+#include <Library/AcpiLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Protocol/AcpiTable.h>\r
+\r
+// Module specific include files.\r
+#include <AcpiTableGenerator.h>\r
+#include <ConfigurationManagerObject.h>\r
+#include <ConfigurationManagerHelper.h>\r
+#include <Library/TableHelperLib.h>\r
+#include <Protocol/ConfigurationManagerProtocol.h>\r
+\r
+/** Construct the ACPI table using the ACPI table data provided.\r
+\r
+  This function invokes the Configuration Manager protocol interface\r
+  to get the required hardware information for generating the ACPI\r
+  table.\r
+\r
+  If this function allocates any resources then they must be freed\r
+  in the FreeXXXXTableResources function.\r
+\r
+  @param [in]  This           Pointer to the table generator.\r
+  @param [in]  AcpiTableInfo  Pointer to the ACPI Table Info.\r
+  @param [in]  CfgMgrProtocol Pointer to the Configuration Manager\r
+                              Protocol Interface.\r
+  @param [out] Table          Pointer to the constructed ACPI Table.\r
+\r
+  @retval EFI_SUCCESS           Table generated successfully.\r
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.\r
+**/\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+BuildRawTable (\r
+  IN  CONST ACPI_TABLE_GENERATOR                  * CONST This,\r
+  IN  CONST CM_STD_OBJ_ACPI_TABLE_INFO            * CONST AcpiTableInfo,\r
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  * CONST CfgMgrProtocol,\r
+  OUT       EFI_ACPI_DESCRIPTION_HEADER          ** CONST Table\r
+  )\r
+{\r
+  ASSERT (This != NULL);\r
+  ASSERT (AcpiTableInfo != NULL);\r
+  ASSERT (CfgMgrProtocol != NULL);\r
+  ASSERT (Table != NULL);\r
+  ASSERT (AcpiTableInfo->TableGeneratorId == This->GeneratorID);\r
+  ASSERT (AcpiTableInfo->AcpiTableData != NULL);\r
+\r
+  if (AcpiTableInfo->AcpiTableData == NULL) {\r
+    *Table = NULL;\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  *Table = AcpiTableInfo->AcpiTableData;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/** This macro defines the Raw Generator revision.\r
+*/\r
+#define RAW_GENERATOR_REVISION CREATE_REVISION (1, 0)\r
+\r
+/** The interface for the Raw Table Generator.\r
+*/\r
+STATIC\r
+CONST\r
+ACPI_TABLE_GENERATOR RawGenerator = {\r
+  // Generator ID\r
+  CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdRaw),\r
+  // Generator Description\r
+  L"ACPI.STD.RAW.GENERATOR",\r
+  // ACPI Table Signature - Unused\r
+  0,\r
+  // ACPI Table Revision - Unused\r
+  0,\r
+  // Minimum ACPI Table Revision - Unused\r
+  0,\r
+  // Creator ID\r
+  TABLE_GENERATOR_CREATOR_ID_ARM,\r
+  // Creator Revision\r
+  RAW_GENERATOR_REVISION,\r
+  // Build Table function\r
+  BuildRawTable,\r
+  // No additional resources are allocated by the generator.\r
+  // Hence the Free Resource function is not required.\r
+  NULL,\r
+  // Extended build function not needed\r
+  NULL,\r
+  // Extended build function not implemented by the generator.\r
+  // Hence extended free resource function is not required.\r
+  NULL\r
+};\r
+\r
+/** Register the Generator with the ACPI Table Factory.\r
+\r
+  @param [in]  ImageHandle  The handle to the image.\r
+  @param [in]  SystemTable  Pointer to the System Table.\r
+\r
+  @retval EFI_SUCCESS           The Generator is registered.\r
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.\r
+  @retval EFI_ALREADY_STARTED   The Generator for the Table ID\r
+                                is already registered.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+AcpiRawLibConstructor (\r
+  IN CONST EFI_HANDLE                ImageHandle,\r
+  IN       EFI_SYSTEM_TABLE  * CONST SystemTable\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+  Status = RegisterAcpiTableGenerator (&RawGenerator);\r
+  DEBUG ((DEBUG_INFO, "RAW: Register Generator. Status = %r\n", Status));\r
+  ASSERT_EFI_ERROR (Status);\r
+  return Status;\r
+}\r
+\r
+/** Deregister the Generator from the ACPI Table Factory.\r
+\r
+  @param [in]  ImageHandle  The handle to the image.\r
+  @param [in]  SystemTable  Pointer to the System Table.\r
+\r
+  @retval EFI_SUCCESS           The Generator is deregistered.\r
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.\r
+  @retval EFI_NOT_FOUND         The Generator is not registered.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+AcpiRawLibDestructor (\r
+  IN CONST EFI_HANDLE                ImageHandle,\r
+  IN       EFI_SYSTEM_TABLE  * CONST SystemTable\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+  Status = DeregisterAcpiTableGenerator (&RawGenerator);\r
+  DEBUG ((DEBUG_INFO, "RAW: Deregister Generator. Status = %r\n", Status));\r
+  ASSERT_EFI_ERROR (Status);\r
+  return Status;\r
+}\r