public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "PierreGondois" <pierre.gondois@arm.com>
To: devel@edk2.groups.io
Cc: Pierre Gondois <pierre.gondois@arm.com>,
	AbdulLateef Attar <AbdulLateef.Attar@amd.com>,
	Girish Mahadevan <gmahadevan@nvidia.com>,
	Jeff Brasen <jbrasen@nvidia.com>,
	Jeshua Smith <jeshuas@nvidia.com>,
	Leif Lindholm <quic_llindhol@quicinc.com>,
	Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>,
	Sami Mujawar <sami.mujawar@arm.com>,
	Sunil V L <sunilvl@ventanamicro.com>,
	Yeo Reum Yun <YeoReum.Yun@arm.com>
Subject: [edk2-devel] [staging/dynamictables-reorg PATCH 03/15] DynamicTablesPkg: AcpiFadtLib: Prepare to support other archs
Date: Thu, 20 Jun 2024 00:06:17 +0200	[thread overview]
Message-ID: <20240619220629.1994362-4-pierre.gondois@arm.com> (raw)
In-Reply-To: <20240619220629.1994362-1-pierre.gondois@arm.com>

Allow other architectures to reuse the AcpiFadtLib by extracting
the Arm specific part of the table generation.

Suggested-by: Sunil V L <sunilvl@ventanamicro.com>
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
---
 .../Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf   |   7 +
 .../Common/AcpiFadtLib/Arm/ArmFadtGenerator.c | 126 ++++++++++++++++++
 .../AcpiFadtLib/Common/CommonFadtGenerator.c  |  46 +++++++
 .../Acpi/Common/AcpiFadtLib/FadtGenerator.c   |  86 ++----------
 .../Acpi/Common/AcpiFadtLib/FadtGenerator.h   |  35 +++++
 5 files changed, 224 insertions(+), 76 deletions(-)
 create mode 100644 DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/Arm/ArmFadtGenerator.c
 create mode 100644 DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/Common/CommonFadtGenerator.c
 create mode 100644 DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/FadtGenerator.h

diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf
index c9cd850faac0..be2af0cfd53a 100644
--- a/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf
@@ -18,6 +18,13 @@ [Defines]
 
 [Sources]
   FadtGenerator.c
+  FadtGenerator.h
+
+[Sources.ARM, Sources.AARCH64]
+  Arm/ArmFadtGenerator.c
+
+[Sources.IA32, Sources.X64]
+  Common/CommonFadtGenerator.c
 
 [Packages]
   MdePkg/MdePkg.dec
diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/Arm/ArmFadtGenerator.c b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/Arm/ArmFadtGenerator.c
new file mode 100644
index 000000000000..2d2afe98ab1f
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/Arm/ArmFadtGenerator.c
@@ -0,0 +1,126 @@
+/** @file
+  ARM FADT Table Helpers
+
+  Copyright (c) 2017 - 2023, Arm Limited. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+  @par Reference(s):
+  - ACPI 6.5 Specification, Aug 29, 2022
+
+**/
+
+#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 "FadtGenerator.h"
+
+/** ARM Standard FADT Generator
+
+Requirements:
+  The following Configuration Manager Object(s) are required by
+  this Generator:
+  - EArmObjBootArchInfo
+*/
+
+/** This macro expands to a function that retrieves the Boot
+    Architecture Information from the Configuration Manager.
+*/
+GET_OBJECT_LIST (
+  EObjNameSpaceArm,
+  EArmObjBootArchInfo,
+  CM_ARM_BOOT_ARCH_INFO
+  );
+
+/** This macro defines the FADT flag options for ARM Platforms.
+*/
+#define FADT_FLAGS  (EFI_ACPI_6_5_HW_REDUCED_ACPI |          \
+                     EFI_ACPI_6_5_LOW_POWER_S0_IDLE_CAPABLE)
+
+/** Updates the Architecture specific information in the FADT Table.
+
+  @param [in]  CfgMgrProtocol Pointer to the Configuration Manager
+                              Protocol Interface.
+  @param [in, out] Fadt       Pointer to the constructed ACPI Table.
+
+  @retval EFI_SUCCESS           Success.
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.
+  @retval EFI_NOT_FOUND         The required object was not found.
+  @retval EFI_BAD_BUFFER_SIZE   The size returned by the Configuration
+                                Manager is less than the Object size for the
+                                requested object.
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+ArmFadtBootArchInfoUpdate (
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,
+  IN   OUT EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE      *Fadt
+  )
+{
+  EFI_STATUS             Status;
+  CM_ARM_BOOT_ARCH_INFO  *BootArchInfo;
+
+  ASSERT (CfgMgrProtocol != NULL);
+  ASSERT (Fadt != NULL);
+
+  // Get the Boot Architecture flags from the Platform Configuration Manager
+  Status = GetEArmObjBootArchInfo (
+             CfgMgrProtocol,
+             CM_NULL_TOKEN,
+             &BootArchInfo,
+             NULL
+             );
+  if (EFI_ERROR (Status)) {
+    DEBUG ((
+      DEBUG_ERROR,
+      "ERROR: FADT: Failed to get Boot Architecture flags. Status = %r\n",
+      Status
+      ));
+    return Status;
+  }
+
+  DEBUG ((
+    DEBUG_INFO,
+    "FADT BootArchFlag = 0x%x\n",
+    BootArchInfo->BootArchFlags
+    ));
+
+  Fadt->ArmBootArch = BootArchInfo->BootArchFlags;
+
+  return Status;
+}
+
+/** Updates the Architecture specific information in the FADT Table.
+
+  @param [in]  CfgMgrProtocol Pointer to the Configuration Manager
+                              Protocol Interface.
+  @param [in, out] Fadt       Pointer to the constructed ACPI Table.
+
+  @retval EFI_SUCCESS           Success.
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.
+  @retval EFI_NOT_FOUND         The required object was not found.
+  @retval EFI_BAD_BUFFER_SIZE   The size returned by the Configuration
+                                Manager is less than the Object size for the
+                                requested object.
+**/
+EFI_STATUS
+EFIAPI
+FadtArchUpdate (
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,
+  IN   OUT EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE      *Fadt
+  )
+{
+  ASSERT (CfgMgrProtocol != NULL);
+  ASSERT (Fadt != NULL);
+
+  Fadt->Flags = FADT_FLAGS;
+
+  return ArmFadtBootArchInfoUpdate (CfgMgrProtocol, Fadt);
+}
diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/Common/CommonFadtGenerator.c b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/Common/CommonFadtGenerator.c
new file mode 100644
index 000000000000..d3e908358b7b
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/Common/CommonFadtGenerator.c
@@ -0,0 +1,46 @@
+/** @file
+  Common FADT Table Helpers
+
+  Copyright (c) 2017 - 2023, Arm Limited. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+  @par Reference(s):
+  - ACPI 6.5 Specification, Aug 29, 2022
+
+**/
+
+#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 "FadtGenerator.h"
+
+/** Updates the Architecture specific information in the FADT Table.
+
+  @param [in]  CfgMgrProtocol Pointer to the Configuration Manager
+                              Protocol Interface.
+  @param [in, out] Fadt       Pointer to the constructed ACPI Table.
+
+  @retval EFI_SUCCESS           Success.
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.
+  @retval EFI_NOT_FOUND         The required object was not found.
+  @retval EFI_BAD_BUFFER_SIZE   The size returned by the Configuration
+                                Manager is less than the Object size for the
+                                requested object.
+**/
+EFI_STATUS
+EFIAPI
+FadtArchUpdate (
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,
+  IN   OUT EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE      *Fadt
+  )
+{
+  // Nothing to do.
+  return EFI_SUCCESS;
+}
diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/FadtGenerator.c b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/FadtGenerator.c
index 470f1acfd11f..c2140ef414d2 100644
--- a/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/FadtGenerator.c
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/FadtGenerator.c
@@ -19,22 +19,17 @@
 #include <ConfigurationManagerHelper.h>
 #include <Library/TableHelperLib.h>
 #include <Protocol/ConfigurationManagerProtocol.h>
+#include "FadtGenerator.h"
 
-/** ARM standard FADT Generator
+/** Standard FADT Generator
 
 Requirements:
   The following Configuration Manager Object(s) are required by
   this Generator:
   - EArchCommonObjPowerManagementProfileInfo
-  - EArmObjBootArchInfo
   - EArchCommonObjHypervisorVendorIdentity (OPTIONAL)
 */
 
-/** This macro defines the FADT flag options for ARM Platforms.
-*/
-#define FADT_FLAGS  (EFI_ACPI_6_5_HW_REDUCED_ACPI |          \
-                     EFI_ACPI_6_5_LOW_POWER_S0_IDLE_CAPABLE)
-
 /** This macro defines the valid mask for the FADT flag option
     if HW_REDUCED_ACPI flag in the table is set.
 
@@ -159,13 +154,13 @@ EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE  AcpiFadt = {
   // UINT8      Reserved1
   0,
   // UINT32     Flags
-  FADT_FLAGS,
+  0,
   // EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE  ResetReg
   NULL_GAS,
   // UINT8      ResetValue
   0,
   // UINT16     ArmBootArch
-  EFI_ACPI_6_5_ARM_PSCI_COMPLIANT,  // {Template}: ARM Boot Architecture Flags
+  0,  // {Template}: ARM Boot Architecture Flags
   // UINT8      MinorRevision
   EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE_MINOR_REVISION, // {Template}
   // UINT64     XFirmwareCtrl
@@ -207,15 +202,6 @@ GET_OBJECT_LIST (
   CM_ARCH_COMMON_POWER_MANAGEMENT_PROFILE_INFO
   );
 
-/** This macro expands to a function that retrieves the Boot
-    Architecture Information from the Configuration Manager.
-*/
-GET_OBJECT_LIST (
-  EObjNameSpaceArm,
-  EArmObjBootArchInfo,
-  CM_ARM_BOOT_ARCH_INFO
-  );
-
 /** This macro expands to a function that retrieves the Hypervisor
     Vendor ID from the Configuration Manager.
 */
@@ -287,58 +273,6 @@ error_handler:
   return Status;
 }
 
-/** Updates the Boot Architecture information in the FADT Table.
-
-  @param [in]  CfgMgrProtocol Pointer to the Configuration Manager
-                              Protocol Interface.
-
-  @retval EFI_SUCCESS           Success.
-  @retval EFI_INVALID_PARAMETER A parameter is invalid.
-  @retval EFI_NOT_FOUND         The required object was not found.
-  @retval EFI_BAD_BUFFER_SIZE   The size returned by the Configuration
-                                Manager is less than the Object size for the
-                                requested object.
-**/
-STATIC
-EFI_STATUS
-EFIAPI
-FadtAddBootArchInfo (
-  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol
-  )
-{
-  EFI_STATUS             Status;
-  CM_ARM_BOOT_ARCH_INFO  *BootArchInfo;
-
-  ASSERT (CfgMgrProtocol != NULL);
-
-  // Get the Boot Architecture flags from the Platform Configuration Manager
-  Status = GetEArmObjBootArchInfo (
-             CfgMgrProtocol,
-             CM_NULL_TOKEN,
-             &BootArchInfo,
-             NULL
-             );
-  if (EFI_ERROR (Status)) {
-    DEBUG ((
-      DEBUG_ERROR,
-      "ERROR: FADT: Failed to get Boot Architecture flags. Status = %r\n",
-      Status
-      ));
-    goto error_handler;
-  }
-
-  DEBUG ((
-    DEBUG_INFO,
-    "FADT BootArchFlag = 0x%x\n",
-    BootArchInfo->BootArchFlags
-    ));
-
-  AcpiFadt.ArmBootArch = BootArchInfo->BootArchFlags;
-
-error_handler:
-  return Status;
-}
-
 /** Update the Hypervisor Vendor ID in the FADT Table.
 
   @param [in]  CfgMgrProtocol Pointer to the Configuration Manager
@@ -577,12 +511,6 @@ BuildFadtTable (
     goto error_handler;
   }
 
-  // Update BootArch Info
-  Status = FadtAddBootArchInfo (CfgMgrProtocol);
-  if (EFI_ERROR (Status)) {
-    goto error_handler;
-  }
-
   // Add the Hypervisor Vendor Id if present
   // Note if no hypervisor is present the zero bytes
   // will be placed in this field.
@@ -623,6 +551,12 @@ BuildFadtTable (
     }
   }
 
+  // Update Arch specific Info
+  Status = FadtArchUpdate (CfgMgrProtocol, &AcpiFadt);
+  if (EFI_ERROR (Status)) {
+    goto error_handler;
+  }
+
   *Table = (EFI_ACPI_DESCRIPTION_HEADER *)&AcpiFadt;
 error_handler:
   return Status;
diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/FadtGenerator.h b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/FadtGenerator.h
new file mode 100644
index 000000000000..08ac59e00684
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/FadtGenerator.h
@@ -0,0 +1,35 @@
+/** @file
+  FADT Table Generator
+
+  Copyright (c) 2017 - 2023, Arm Limited. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+  @par Reference(s):
+  - ACPI 6.5 Specification, Aug 29, 2022
+
+**/
+
+#ifndef FADT_GENERATOR_H_
+#define FADT_GENERATOR_H_
+
+/** Updates the Architecture specific information in the FADT Table.
+
+  @param [in]  CfgMgrProtocol Pointer to the Configuration Manager
+                              Protocol Interface.
+  @param [in, out] Fadt       Pointer to the constructed ACPI Table.
+
+  @retval EFI_SUCCESS           Success.
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.
+  @retval EFI_NOT_FOUND         The required object was not found.
+  @retval EFI_BAD_BUFFER_SIZE   The size returned by the Configuration
+                                Manager is less than the Object size for the
+                                requested object.
+**/
+EFI_STATUS
+EFIAPI
+FadtArchUpdate (
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,
+  IN   OUT EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE      *Fadt
+  );
+
+#endif // FADT_GENERATOR_H_
-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119635): https://edk2.groups.io/g/devel/message/119635
Mute This Topic: https://groups.io/mt/106770154/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



  parent reply	other threads:[~2024-06-19 22:06 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-19 22:06 [edk2-devel] [staging/dynamictables-reorg PATCH 00/15] Prepare libraries to support other archs PierreGondois
2024-06-19 22:06 ` [edk2-devel] [staging/dynamictables-reorg PATCH 01/15] DynamicTablesPkg: Acpi: Move generic libraries to common folder PierreGondois
2024-06-19 22:06 ` [edk2-devel] [staging/dynamictables-reorg PATCH 02/15] DynamicTablesPkg: Acpi: Prepare common libraries to support other archs PierreGondois
2024-06-19 22:06 ` PierreGondois [this message]
2024-06-19 22:06 ` [edk2-devel] [staging/dynamictables-reorg PATCH 04/15] DynamicTablesPkg: AcpiDbg2Lib: Prepare " PierreGondois
2024-06-19 22:06 ` [edk2-devel] [staging/dynamictables-reorg PATCH 05/15] DynamicTablesPkg: AcpiSpcrLib: " PierreGondois
2024-06-19 22:06 ` [edk2-devel] [staging/dynamictables-reorg PATCH 06/15] DynamicTablesPkg: AcpiSratLib: " PierreGondois
2024-06-19 22:06 ` [edk2-devel] [staging/dynamictables-reorg PATCH 07/15] DynamicTablesPkg: AcpiSsdtCpuTopologyLib: Avoid dependency on GICC PierreGondois
2024-06-19 22:06 ` [edk2-devel] [staging/dynamictables-reorg PATCH 08/15] DynamicTablesPkg: DynamicTableManagerDxe: Refactor PresenceArray PierreGondois
2024-06-19 22:06 ` [edk2-devel] [staging/dynamictables-reorg PATCH 09/15] DynamicTablesPkg: FdtHwInfoParserLib: Move ARM parsers to Arm directory PierreGondois
2024-06-19 22:06 ` [edk2-devel] [staging/dynamictables-reorg PATCH 10/15] DynamicTablesPkg: FdtHwInfoParserLib: Refactor to prepare for other archs PierreGondois
2024-06-19 22:06 ` [edk2-devel] [staging/dynamictables-reorg PATCH 11/15] DynamicTablesPkg: FdtHwInfoParserLib: Make Pci parser arch neutral PierreGondois
2024-06-19 22:06 ` [edk2-devel] [staging/dynamictables-reorg PATCH 12/15] DynamicTablesPkg: FdtHwInfoParserLib: Make Serial Port " PierreGondois
2024-06-19 22:06 ` [edk2-devel] [staging/dynamictables-reorg PATCH 13/15] DynamicTablesPkg: FdtHwInfoParserLib: Move ArmLib.h to ArmGicCParser.c PierreGondois
2024-06-19 22:06 ` [edk2-devel] [staging/dynamictables-reorg PATCH 14/15] DynamicTablesPkg: FdtHwInfoParserLib: Move IRQ map to arch folder PierreGondois
2024-07-03  6:20   ` Sunil V L
2024-06-19 22:06 ` [edk2-devel] [staging/dynamictables-reorg PATCH 15/15] DynamicTablesPkg: FdtHwInfoParserLib: Create wrapper to get INTC addr cells PierreGondois
2024-07-03  6:50   ` Sunil V L
2024-07-03  7:36     ` Sami Mujawar
2024-07-03  9:08 ` [edk2-devel] [staging/dynamictables-reorg PATCH 00/15] Prepare libraries to support other archs Sami Mujawar
2024-07-03  9:36   ` Sunil V L
2024-07-03  9:39     ` Sami Mujawar
2024-07-03  9:43       ` Sunil V L
2024-07-03  9:55   ` PierreGondois

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240619220629.1994362-4-pierre.gondois@arm.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox