[edk2-devel] [PATCH v1 2/2] Platform/NXP: Add OEM specific DSDT generator

Vikas Singh via groups.io vikas.singh=puresoftware.com at groups.io
Mon Jan 18 11:27:41 UTC 2021


These changes add platform specific DSDT generator
and Clk dsdt properties for LX2160ARDB.

Signed-off-by: Vikas Singh <vikas.singh at puresoftware.com>
---
 .../ConfigurationManagerDxe/ConfigurationManager.c |   9 ++
 .../ConfigurationManagerDxe/ConfigurationManager.h |   4 +-
 .../ConfigurationManagerDxe.inf                    |   1 +
 .../ConfigurationManagerPkg.dec                    |  23 ++++
 .../Include/PlatformAcpiTableGenerator.h           |  20 +++
 .../LX2160aRdbPkg/AcpiTablesInclude/Dsdt/Clk.asl   |  40 ++++++
 .../LX2160aRdbPkg/AcpiTablesInclude/Dsdt/Dsdt.asl  |  15 +++
 .../AcpiTablesInclude/PlatformAcpiDsdtLib.inf      |  39 ++++++
 .../PlatformAcpiDsdtLib/RawDsdtGenerator.c         | 146 +++++++++++++++++++++
 .../AcpiTablesInclude/PlatformAcpiLib.h            |  24 ++++
 Platform/NXP/LX2160aRdbPkg/Include/Platform.h      |   6 +
 Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dec       |   3 +
 Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc       |   1 +
 13 files changed, 330 insertions(+), 1 deletion(-)
 create mode 100644 Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerPkg.dec
 create mode 100644 Platform/NXP/ConfigurationManagerPkg/Include/PlatformAcpiTableGenerator.h
 create mode 100644 Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/Dsdt/Clk.asl
 create mode 100644 Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/Dsdt/Dsdt.asl
 create mode 100644 Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/PlatformAcpiDsdtLib.inf
 create mode 100644 Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/PlatformAcpiDsdtLib/RawDsdtGenerator.c
 create mode 100644 Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/PlatformAcpiLib.h

diff --git a/Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerDxe/ConfigurationManager.c b/Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerDxe/ConfigurationManager.c
index 8db380d..d17729e 100644
--- a/Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerDxe/ConfigurationManager.c
+++ b/Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerDxe/ConfigurationManager.c
@@ -78,6 +78,15 @@ FSL_PLATFORM_REPOSITORY_INFO FslPlatformRepositoryInfo = {
       CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdSpcr),
       NULL,
       CFG_MGR_TABLE_ID
+    },
+
+    // DSDT (OEM) Table
+    {
+      EFI_ACPI_6_2_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE,
+      0,
+      CREATE_OEM_ACPI_TABLE_GEN_ID (PlatAcpiTableIdDsdt),
+      NULL,
+      CFG_MGR_TABLE_ID
     }
 
   },
diff --git a/Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerDxe/ConfigurationManager.h b/Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerDxe/ConfigurationManager.h
index de21659..7b382e8 100644
--- a/Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerDxe/ConfigurationManager.h
+++ b/Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerDxe/ConfigurationManager.h
@@ -15,6 +15,7 @@
 #define CONFIGURATION_MANAGER_H
 
 #include <Platform.h>
+#include <PlatformAcpiTableGenerator.h>
 
 /** The configuration manager version
 */
@@ -77,7 +78,8 @@
 
 /** The number of ACPI tables to install
 */
-#define PLAT_ACPI_TABLE_COUNT   5
+#define CM_MANDATORY_ACPI_TABLES  5
+#define PLAT_ACPI_TABLE_COUNT     (CM_MANDATORY_ACPI_TABLES + OEM_ACPI_TABLES)
 
 /** A structure describing the platform configuration
     manager repository information
diff --git a/Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerDxe/ConfigurationManagerDxe.inf b/Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerDxe/ConfigurationManagerDxe.inf
index 496c8bf..7c082cb 100644
--- a/Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerDxe/ConfigurationManagerDxe.inf
+++ b/Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerDxe/ConfigurationManagerDxe.inf
@@ -31,6 +31,7 @@
   EmbeddedPkg/EmbeddedPkg.dec
   MdeModulePkg/MdeModulePkg.dec
   MdePkg/MdePkg.dec
+  Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerPkg.dec
   Silicon/NXP/NxpQoriqLs.dec
 
 [LibraryClasses]
diff --git a/Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerPkg.dec b/Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerPkg.dec
new file mode 100644
index 0000000..e4af8e4
--- /dev/null
+++ b/Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerPkg.dec
@@ -0,0 +1,23 @@
+#  ConfigurationManager.dec
+#
+#  Copyright 2020 NXP
+#  Copyright 2020 Puresoftware Ltd
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+
+[Defines]
+  PACKAGE_NAME                   = ConfigurationManagerPkg
+  PACKAGE_GUID                   = 0222b1b1-247f-404e-bdc3-baab65f2ddd3
+
+################################################################################
+#
+# Include Section - list of Include Paths that are provided by this package.
+#                   Comments are used for Keywords and Module Types.
+#
+# Supported Module Types:
+#  BASE SEC PEI_CORE PEIM DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER DXE_SAL_DRIVER UEFI_DRIVER UEFI_APPLICATION
+#
+################################################################################
+[Includes]
+  Include
diff --git a/Platform/NXP/ConfigurationManagerPkg/Include/PlatformAcpiTableGenerator.h b/Platform/NXP/ConfigurationManagerPkg/Include/PlatformAcpiTableGenerator.h
new file mode 100644
index 0000000..c1ec114
--- /dev/null
+++ b/Platform/NXP/ConfigurationManagerPkg/Include/PlatformAcpiTableGenerator.h
@@ -0,0 +1,20 @@
+/** @file
+  Acpi Table generator headers
+
+  Copyright 2020 NXP
+  Copyright 2020 Puresoftware Ltd
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef PLATFORM_ACPI_TABLE_GENERATOR_H
+#define PLATFORM_ACPI_TABLE_GENERATOR_H
+
+typedef enum PlatAcpiTableId {
+  PlatAcpiTableIdReserved = 0x0000,             ///< Reserved
+  PlatAcpiTableIdDsdt,
+  PlatAcpiTableIdMax
+} PLAT_ACPI_TABLE_ID;
+
+#endif // PLATFORM_ACPI_TABLE_GENERATOR_H
diff --git a/Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/Dsdt/Clk.asl b/Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/Dsdt/Clk.asl
new file mode 100644
index 0000000..1008476
--- /dev/null
+++ b/Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/Dsdt/Clk.asl
@@ -0,0 +1,40 @@
+/** @file
+  Differentiated System Description Table Fields (DSDT)
+
+  Copyright 2020 NXP
+  Copyright 2020 Puresoftware Ltd
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+Scope(_SB)
+{
+  Device(PCLK) {
+    Name(_HID, "NXP0017")
+    Name(CLK, 0)
+    Name(AVBL, 0)
+    OperationRegion(RCWS, SystemMemory, DCFG_BASE, DCFG_LEN)
+    Method(_REG,2) {
+      if (Arg0 == "RCWS") {
+        Store(Arg1, AVBL)
+      }
+    }
+    Field (RCWS, ByteAcc, NoLock, Preserve) {
+      offset(0x100),
+      PCFG, 2,
+      PRAT, 6,
+      offset(0x124),
+      RESV, 4,
+      SFRQ, 10
+    }
+
+    Method(_INI, 0, NotSerialized) {
+      Store(SFRQ, Local0)
+      Multiply(Local0, 500000, Local0)
+      Multiply(Local0, PRAT, Local0)
+      Divide(Local0, 6, , Local0)
+      Store(Local0, CLK)
+    }
+  }
+} // end of device PCLK
diff --git a/Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/Dsdt/Dsdt.asl b/Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/Dsdt/Dsdt.asl
new file mode 100644
index 0000000..e4f04ce
--- /dev/null
+++ b/Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/Dsdt/Dsdt.asl
@@ -0,0 +1,15 @@
+/** @file
+  Differentiated System Description Table Fields (DSDT)
+
+  Copyright 2020 NXP
+  Copyright 2020 Puresoftware Ltd.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "Platform.h"
+
+DefinitionBlock("DsdtTable.aml", "DSDT", 2, "NXP  ", "LX2160  ", EFI_ACPI_ARM_OEM_REVISION) {
+  include ("Clk.asl")
+}
diff --git a/Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/PlatformAcpiDsdtLib.inf b/Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/PlatformAcpiDsdtLib.inf
new file mode 100644
index 0000000..ac7d0b6
--- /dev/null
+++ b/Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/PlatformAcpiDsdtLib.inf
@@ -0,0 +1,39 @@
+## @file
+#  Raw Table Generator
+#
+#  Copyright 2020 NXP
+#  Copyright 2020 Puresoftware Ltd
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+  INF_VERSION    = 0x00010019
+  BASE_NAME      = PlatformAcpiDsdtLib
+  FILE_GUID      = 0b1768cf-13fa-4ecf-b640-338a636d1abb
+  VERSION_STRING = 1.0
+  MODULE_TYPE    = DXE_DRIVER
+  LIBRARY_CLASS  = NULL|DXE_DRIVER
+  CONSTRUCTOR    = AcpiDsdtLibConstructor
+  DESTRUCTOR     = AcpiDsdtLibDestructor
+
+[Sources]
+  PlatformAcpiDsdtLib/RawDsdtGenerator.c
+  Dsdt/Dsdt.asl
+
+[Packages]
+  DynamicTablesPkg/DynamicTablesPkg.dec
+  EmbeddedPkg/EmbeddedPkg.dec
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dec
+
+[LibraryClasses]
+  BaseLib
+
+[Pcd]
+
+[Protocols]
+
+[Guids]
+
diff --git a/Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/PlatformAcpiDsdtLib/RawDsdtGenerator.c b/Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/PlatformAcpiDsdtLib/RawDsdtGenerator.c
new file mode 100644
index 0000000..375598c
--- /dev/null
+++ b/Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/PlatformAcpiDsdtLib/RawDsdtGenerator.c
@@ -0,0 +1,146 @@
+/** @file
+  Raw DSDT Table Generator
+
+  Copyright 2020 NXP
+  Copyright 2020 Puresoftware Ltd.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/AcpiLib.h>
+#include <Library/DebugLib.h>
+#include <Protocol/AcpiTable.h>
+
+// Module specific include files.
+#include <AcpiTableGenerator.h>
+#include <ConfigurationManagerObject.h>
+#include <ConfigurationManagerHelper.h>
+#include <Library/TableHelperLib.h>
+#include <Protocol/ConfigurationManagerProtocol.h>
+
+#include "PlatformAcpiLib.h"
+
+/** Construct the ACPI table using the ACPI table data provided.
+
+  This function invokes the Configuration Manager protocol interface
+  to get the required hardware information for generating the ACPI
+  table.
+
+  If this function allocates any resources then they must be freed
+  in the FreeXXXXTableResources function.
+
+  @param [in]  This           Pointer to the table generator.
+  @param [in]  AcpiTableInfo  Pointer to the ACPI Table Info.
+  @param [in]  CfgMgrProtocol Pointer to the Configuration Manager
+                              Protocol Interface.
+  @param [out] Table          Pointer to the constructed ACPI Table.
+
+  @retval EFI_SUCCESS           Table generated successfully.
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+BuildRawDsdtTable (
+  IN  CONST ACPI_TABLE_GENERATOR                  * CONST This,
+  IN  CONST CM_STD_OBJ_ACPI_TABLE_INFO            * CONST AcpiTableInfo,
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  * CONST CfgMgrProtocol,
+  OUT       EFI_ACPI_DESCRIPTION_HEADER          ** CONST Table
+  )
+{
+  ASSERT (This != NULL);
+  ASSERT (AcpiTableInfo != NULL);
+  ASSERT (CfgMgrProtocol != NULL);
+  ASSERT (Table != NULL);
+  ASSERT (AcpiTableInfo->TableGeneratorId == This->GeneratorID);
+
+  if (AcpiTableInfo->AcpiTableData == NULL) {
+    // Add the dsdt aml code here, Currently NULL place holder.
+    *Table = (EFI_ACPI_DESCRIPTION_HEADER *)&dsdt_aml_code;
+  }
+
+  return EFI_SUCCESS;
+}
+
+/** This macro defines the Raw Generator revision.
+*/
+#define DSDT_GENERATOR_REVISION CREATE_REVISION (1, 0)
+
+/** The interface for the Raw Table Generator.
+*/
+STATIC
+CONST
+ACPI_TABLE_GENERATOR RawDsdtGenerator = {
+  // Generator ID
+  CREATE_OEM_ACPI_TABLE_GEN_ID (PlatAcpiTableIdDsdt),
+  // Generator Description
+  L"ACPI.OEM.RAW.DSDT.GENERATOR",
+  // ACPI Table Signature - Unused
+  0,
+  // ACPI Table Revision - Unused
+  0,
+  // Minimum ACPI Table Revision - Unused
+  0,
+  // Creator ID
+  TABLE_GENERATOR_CREATOR_ID_ARM,
+  // Creator Revision
+  DSDT_GENERATOR_REVISION,
+  // Build Table function
+  BuildRawDsdtTable,
+  // No additional resources are allocated by the generator.
+  // Hence the Free Resource function is not required.
+  NULL,
+  // Extended build function not needed
+  NULL,
+  // Extended build function not implemented by the generator.
+  // Hence extended free resource function is not required.
+  NULL
+};
+
+/** Register the Generator with the ACPI Table Factory.
+
+  @param [in]  ImageHandle  The handle to the image.
+  @param [in]  SystemTable  Pointer to the System Table.
+
+  @retval EFI_SUCCESS           The Generator is registered.
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.
+  @retval EFI_ALREADY_STARTED   The Generator for the Table ID
+                                is already registered.
+**/
+EFI_STATUS
+EFIAPI
+AcpiDsdtLibConstructor (
+  IN CONST EFI_HANDLE                ImageHandle,
+  IN       EFI_SYSTEM_TABLE  * CONST SystemTable
+  )
+{
+  EFI_STATUS  Status;
+  Status = RegisterAcpiTableGenerator (&RawDsdtGenerator);
+  DEBUG ((DEBUG_INFO, "OEM: Register DSDT Generator. Status = %r\n", Status));
+  ASSERT_EFI_ERROR (Status);
+  return Status;
+}
+
+/** Deregister the Generator from the ACPI Table Factory.
+
+  @param [in]  ImageHandle  The handle to the image.
+  @param [in]  SystemTable  Pointer to the System Table.
+
+  @retval EFI_SUCCESS           The Generator is deregistered.
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.
+  @retval EFI_NOT_FOUND         The Generator is not registered.
+**/
+EFI_STATUS
+EFIAPI
+AcpiDsdtLibDestructor (
+  IN CONST EFI_HANDLE                ImageHandle,
+  IN       EFI_SYSTEM_TABLE  * CONST SystemTable
+  )
+{
+  EFI_STATUS  Status;
+  Status = DeregisterAcpiTableGenerator (&RawDsdtGenerator);
+  DEBUG ((DEBUG_INFO, "OEM: Deregister DSDT Generator. Status = %r\n", Status));
+  ASSERT_EFI_ERROR (Status);
+  return Status;
+}
diff --git a/Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/PlatformAcpiLib.h b/Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/PlatformAcpiLib.h
new file mode 100644
index 0000000..3ab2fd0
--- /dev/null
+++ b/Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/PlatformAcpiLib.h
@@ -0,0 +1,24 @@
+/** @file
+ *  Acpi lib headers
+ *
+ *  Copyright 2020 NXP
+ *  Copyright 2020 Puresoftware Ltd
+ *
+ *  SPDX-License-Identifier: BSD-2-Clause-Patent
+ *
+**/
+
+
+#ifndef LX2160ARDB_PLATFORM_ACPI_LIB_H
+#define LX2160ARDB_PLATFORM_ACPI_LIB_H
+
+#include <PlatformAcpiTableGenerator.h>
+
+/** C array containing the compiled AML template.
+    These symbols are defined in the auto generated C file
+    containing the AML bytecode array.
+*/
+extern CHAR8  dsdt_aml_code[];
+
+#endif
+
diff --git a/Platform/NXP/LX2160aRdbPkg/Include/Platform.h b/Platform/NXP/LX2160aRdbPkg/Include/Platform.h
index e11ac37..76a41d4 100644
--- a/Platform/NXP/LX2160aRdbPkg/Include/Platform.h
+++ b/Platform/NXP/LX2160aRdbPkg/Include/Platform.h
@@ -21,6 +21,10 @@
 
 #define SVR_LX2160A             0x873600
 
+// PCLK
+#define DCFG_BASE   0x1E00000
+#define DCFG_LEN    0x1FFFF
+
 // Gic
 #define GIC_VERSION 3
 #define GICD_BASE   0x6000000
@@ -80,6 +84,8 @@
 
 // Platform specific info needed by Configuration Manager
 
+#define OEM_ACPI_TABLES   1 // OEM defined DSDT
+
 #define CFG_MGR_TABLE_ID  SIGNATURE_64 ('L','X','2','1','6','0',' ',' ')
 
 #define PLAT_PCI_SEG0_CONFIG_BASE   LX2160A_PCI_SEG0_CONFIG_BASE
diff --git a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dec b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dec
index 459440c..8f10d96 100644
--- a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dec
+++ b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dec
@@ -22,3 +22,6 @@
 ################################################################################
 [Includes.common]
   Include                        # Root include for the package
+  .
+  AcpiTablesInclude
+  Platform/NXP/ConfigurationManagerPkg/Include
diff --git a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc
index 6ba429d..9d898f2 100644
--- a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc
+++ b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc
@@ -82,6 +82,7 @@
         NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/AcpiMadtLibArm.inf
         NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/AcpiMcfgLibArm.inf
         NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/AcpiSpcrLibArm.inf
+        NULL|Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/PlatformAcpiDsdtLib.inf
     }
   !endif
 
-- 
2.7.4



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#70505): https://edk2.groups.io/g/devel/message/70505
Mute This Topic: https://groups.io/mt/79928152/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-





More information about the edk2-devel-archive mailing list