public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Sunil V L" <sunilvl@ventanamicro.com>
To: devel@edk2.groups.io
Cc: Sunil V L <sunilvl@ventanamicro.com>,
	Ard Biesheuvel <ardb+tianocore@kernel.org>,
	Leif Lindholm <quic_llindhol@quicinc.com>,
	Pierre Gondois <pierre.gondois@arm.com>,
	Sami Mujawar <Sami.Mujawar@arm.com>
Subject: [edk2-devel] [RFC PATCH v1 16/20] DynamicTablesPkg: AcpiFadtLib: Move ArmBootArch to ARM specific file
Date: Tue,  9 Jan 2024 21:59:40 +0530	[thread overview]
Message-ID: <20240109162944.528006-17-sunilvl@ventanamicro.com> (raw)
In-Reply-To: <20240109162944.528006-1-sunilvl@ventanamicro.com>

ArmBootArch field in FADT is specific to ARM. To leverage most of the
code in FADT generator for other architectures, this needs to be moved
into ARM specific file. There may be other fields in future (ex:
IA_PC_BOOT_ARCH) that need to be created in similar way. So, instead of
adding the function only to create BootArch, make this function generic
to add all arch specific functions into FADT.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Pierre Gondois <pierre.gondois@arm.com>
Cc: Sami Mujawar <Sami.Mujawar@arm.com>
Signed-off-by: Sunil V L <sunilvl@ventanamicro.com>
---
 .../Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf   |  4 +
 .../Acpi/Common/AcpiFadtLib/FadtGenerator.h   | 32 ++++++++
 .../Common/AcpiFadtLib/ArmFadtGenerator.c     | 80 +++++++++++++++++++
 .../Acpi/Common/AcpiFadtLib/FadtGenerator.c   | 71 ++--------------
 .../Arm/BootArch/ArmBootArchParser.c          |  8 +-
 5 files changed, 125 insertions(+), 70 deletions(-)
 create mode 100644 DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/FadtGenerator.h
 create mode 100644 DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/ArmFadtGenerator.c

diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf
index c9cd850faac0..1ea47aefc3e1 100644
--- a/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/AcpiFadtLib.inf
@@ -18,6 +18,10 @@ [Defines]
 
 [Sources]
   FadtGenerator.c
+  FadtGenerator.h
+
+[Sources.ARM, Sources.AARCH64]
+  ArmFadtGenerator.c
 
 [Packages]
   MdePkg/MdePkg.dec
diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/FadtGenerator.h b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/FadtGenerator.h
new file mode 100644
index 000000000000..bb98ea4c8854
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/FadtGenerator.h
@@ -0,0 +1,32 @@
+/** @file
+
+  Copyright (c) 2017 - 2023, Arm Limited. All rights reserved.<BR>
+  Copyright (c) 2024, Ventana Micro Systems Inc. All rights reserved.<BR>
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#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.
+
+  @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
+FadtAddArchInfo (
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,
+  OUT EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE           *Fadt
+  );
+
+#endif // FADT_GENERATOR_H_
diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/ArmFadtGenerator.c b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/ArmFadtGenerator.c
new file mode 100644
index 000000000000..ca4f6958a5b9
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/ArmFadtGenerator.c
@@ -0,0 +1,80 @@
+/** @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"
+
+/** This macro expands to a function that retrieves the Boot
+    Architecture Information from the Configuration Manager.
+*/
+GET_OBJECT_LIST (
+  EObjNameSpaceArch,
+  EArchObjBootArchInfo,
+  CM_ARCH_BOOT_ARCH_INFO
+  );
+
+/** Updates the Architecture specific information in the FADT Table.
+
+  @param [in]  CfgMgrProtocol Pointer to the Configuration Manager
+                              Protocol Interface.
+  @param [out] Fadt           Pointer to the FADT table
+
+  @retval EFI_SUCCESS           Success.
+  @retval EFI_NOT_FOUND         The required object was not found.
+**/
+EFI_STATUS
+EFIAPI
+FadtAddArchInfo (
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,
+  OUT EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE           *Fadt
+  )
+{
+  EFI_STATUS              Status;
+  CM_ARCH_BOOT_ARCH_INFO  *BootArchInfo;
+
+  ASSERT (CfgMgrProtocol != NULL);
+
+  // Get the Boot Architecture flags from the Platform Configuration Manager
+  Status = GetEArchObjBootArchInfo (
+             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
+    ));
+
+  Fadt->ArmBootArch = BootArchInfo->BootArchFlags;
+
+error_handler:
+  return Status;
+}
diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/FadtGenerator.c b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/FadtGenerator.c
index 6f760532314e..60f1ad69a420 100644
--- a/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/FadtGenerator.c
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiFadtLib/FadtGenerator.c
@@ -19,14 +19,14 @@
 #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:
   - EArchObjPowerManagementProfileInfo
-  - EArchObjBootArchInfo
   - EArchObjHypervisorVendorIdentity (OPTIONAL)
 */
 
@@ -165,7 +165,7 @@ EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE  AcpiFadt = {
   // 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 +207,6 @@ GET_OBJECT_LIST (
   CM_ARCH_POWER_MANAGEMENT_PROFILE_INFO
   );
 
-/** This macro expands to a function that retrieves the Boot
-    Architecture Information from the Configuration Manager.
-*/
-GET_OBJECT_LIST (
-  EObjNameSpaceArch,
-  EArchObjBootArchInfo,
-  CM_ARCH_BOOT_ARCH_INFO
-  );
-
 /** This macro expands to a function that retrieves the Hypervisor
     Vendor ID from the Configuration Manager.
 */
@@ -287,58 +278,6 @@ FadtAddPmProfileInfo (
   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_ARCH_BOOT_ARCH_INFO  *BootArchInfo;
-
-  ASSERT (CfgMgrProtocol != NULL);
-
-  // Get the Boot Architecture flags from the Platform Configuration Manager
-  Status = GetEArchObjBootArchInfo (
-             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,8 +516,8 @@ BuildFadtTable (
     goto error_handler;
   }
 
-  // Update BootArch Info
-  Status = FadtAddBootArchInfo (CfgMgrProtocol);
+  // Update Arch specific Info
+  Status = FadtAddArchInfo (CfgMgrProtocol, &AcpiFadt);
   if (EFI_ERROR (Status)) {
     goto error_handler;
   }
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/BootArch/ArmBootArchParser.c b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/BootArch/ArmBootArchParser.c
index d0f6e257a7ac..028a659292f2 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/BootArch/ArmBootArchParser.c
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/BootArch/ArmBootArchParser.c
@@ -49,8 +49,8 @@ STATIC
 EFI_STATUS
 EFIAPI
 PsciNodeParser (
-  IN  CONST VOID                   *Fdt,
-  IN        INT32                  PsciNode,
+  IN  CONST VOID                    *Fdt,
+  IN        INT32                   PsciNode,
   IN        CM_ARCH_BOOT_ARCH_INFO  *BootArchInfo
   )
 {
@@ -115,8 +115,8 @@ ArmBootArchInfoParser (
   IN        INT32                      FdtBranch
   )
 {
-  EFI_STATUS             Status;
-  INT32                  PsciNode;
+  EFI_STATUS              Status;
+  INT32                   PsciNode;
   CM_ARCH_BOOT_ARCH_INFO  BootArchInfo;
 
   if (FdtParserHandle == NULL) {
-- 
2.34.1



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



  parent reply	other threads:[~2024-01-09 16:30 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-09 16:29 [edk2-devel] [RFC PATCH v1 00/20] DynamicTablesPkg: Prepare to add RISC-V support Sunil V L
2024-01-09 16:29 ` [edk2-devel] [RFC PATCH v1 01/20] DynamicTablesPkg: FdtHwInfoParserLib: Move ARM parsers to Arm directory Sunil V L
2024-01-09 16:29 ` [edk2-devel] [RFC PATCH v1 02/20] DynamicTablesPkg: Move common ACPI libraries from folder Sunil V L
2024-01-09 16:29 ` [edk2-devel] [RFC PATCH v1 03/20] DynamicTablesPkg: Update ACPI common libraries BASE_NAME Sunil V L
2024-01-09 16:29 ` [edk2-devel] [RFC PATCH v1 04/20] DynamicTablesPkg: Rename ArmNameSpaceObjects to ArchNameSpaceObjects Sunil V L
2024-01-09 16:29 ` [edk2-devel] [RFC PATCH v1 05/20] DynamicTablesPkg: DynamicPlatRepoLib: Rename ArmObjList as ArchObjList Sunil V L
2024-01-09 16:29 ` [edk2-devel] [RFC PATCH v1 06/20] DynamicTablesPkg: Rename EObjNameSpaceArm to EObjNameSpaceArch Sunil V L
2024-01-09 16:29 ` [edk2-devel] [RFC PATCH v1 07/20] DynamicTablesPkg: FdtHwInfoParserLib: Separate ARM specific code Sunil V L
2024-01-09 16:29 ` [edk2-devel] [RFC PATCH v1 08/20] DynamicTablesPkg: FdtHwInfoParserLib: Pci: Make it common for architectures Sunil V L
2024-01-09 16:29 ` [edk2-devel] [RFC PATCH v1 09/20] DynamicTablesPkg: FdtHwInfoParserLib: Make Serial parser arch neutral Sunil V L
2024-01-09 16:29 ` [edk2-devel] [RFC PATCH v1 10/20] DynamicTablesPkg: FdtHwInfoParserLib: Move ArmLib.h to ArmGicCParser.c Sunil V L
2024-01-09 16:29 ` [edk2-devel] [RFC PATCH v1 11/20] DynamicTablesPkg: TableHelperLib: Populate OemTableId using ConfigManager Sunil V L
2024-01-09 16:29 ` [edk2-devel] [RFC PATCH v1 12/20] DynamicTablesPkg: Add CreatorId in CM_STD_OBJ_CONFIGURATION_MANAGER_INFO Sunil V L
2024-01-09 16:29 ` [edk2-devel] [RFC PATCH v1 13/20] DynamicTablesPkg: FdtHwInfoParserLib: Move ARM utilities to separate file Sunil V L
2024-01-09 16:29 ` [edk2-devel] [RFC PATCH v1 14/20] DynamicTablesPkg/FdtHwInfoParserLib: Add function for INTC address cells Sunil V L
2024-01-09 16:29 ` [edk2-devel] [RFC PATCH v1 15/20] DynamicTablesPkg: AcpiSsdtCpuTopologyLib: Move GICC from common code Sunil V L
2024-01-09 16:29 ` Sunil V L [this message]
2024-01-09 16:29 ` [edk2-devel] [RFC PATCH v1 17/20] DynamicTablesPkg: DynamicTableManagerDxe: Refactor to allow other archs Sunil V L
2024-01-09 16:29 ` [edk2-devel] [RFC PATCH v1 18/20] DynamicTablesPkg: X86: Add interfaces to succeed CI tests Sunil V L
2024-01-09 16:29 ` [edk2-devel] [RFC PATCH v1 19/20] DynamicTablesPkg/AmlLib: Fix typo Sunil V L
2024-01-09 16:29 ` [edk2-devel] [RFC PATCH v1 20/20] DynamicTablesPkg.ci.yaml: Update exception and ignore list Sunil V L
2024-01-09 18:37 ` [edk2-devel] [RFC PATCH v1 00/20] DynamicTablesPkg: Prepare to add RISC-V support Jeshua Smith via groups.io
2024-01-10  4:20   ` Sunil V L
2024-01-10 21:56     ` Jeshua Smith via groups.io
2024-01-22 17:15       ` Sami Mujawar
2024-01-23  7:01         ` Sunil V L

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=20240109162944.528006-17-sunilvl@ventanamicro.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