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 13/20] DynamicTablesPkg: FdtHwInfoParserLib: Move ARM utilities to separate file
Date: Tue,  9 Jan 2024 21:59:37 +0530	[thread overview]
Message-ID: <20240109162944.528006-14-sunilvl@ventanamicro.com> (raw)
In-Reply-To: <20240109162944.528006-1-sunilvl@ventanamicro.com>

The SPI/PPI ranges are ARM specific and the number of entries in
"interrupt-map" property can be different across architectures. Hence,
move these utility functions to ARM specific file so that common code is
clean and other architectures can easily implement their version.

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>
---
 .../FdtHwInfoParserLib/FdtHwInfoParserLib.inf |  1 +
 .../FdtHwInfoParserLib/Arm/ArmFdtUtility.c    | 85 +++++++++++++++++++
 .../Library/FdtHwInfoParserLib/FdtUtility.c   | 71 ----------------
 3 files changed, 86 insertions(+), 71 deletions(-)
 create mode 100644 DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtUtility.c

diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf
index d3010af527c1..8e1ea100bd34 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf
@@ -28,6 +28,7 @@ [Sources]
   Serial/SerialPortParser.h
 
 [Sources.ARM, Sources.AARCH64]
+  Arm/ArmFdtUtility.c
   Arm/ArmFdtHwInfoParser.c
   Arm/BootArch/ArmBootArchParser.c
   Arm/BootArch/ArmBootArchParser.h
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtUtility.c b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtUtility.c
new file mode 100644
index 000000000000..21b1306e577d
--- /dev/null
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtUtility.c
@@ -0,0 +1,85 @@
+/** @file
+  Flattened device tree utility.
+
+  Copyright (c) 2021, ARM Limited. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+  @par Reference(s):
+  - Device tree Specification - Release v0.3
+  - linux/Documentation/devicetree/bindings/interrupt-controller/arm%2Cgic.yaml
+  - linux//Documentation/devicetree/bindings/interrupt-controller/arm%2Cgic.yaml
+**/
+
+#include <FdtHwInfoParserInclude.h>
+#include "FdtUtility.h"
+
+/** Get the interrupt Id of an interrupt described in a fdt.
+
+  Data must describe a GIC interrupt. A GIC interrupt is on at least
+  3 UINT32 cells.
+  This function DOES NOT SUPPORT extended SPI range and extended PPI range.
+
+  @param [in]  Data   Pointer to the first cell of an "interrupts" property.
+
+  @retval  The interrupt id.
+**/
+UINT32
+EFIAPI
+FdtGetInterruptId (
+  UINT32 CONST  *Data
+  )
+{
+  UINT32  IrqType;
+  UINT32  IrqId;
+
+  ASSERT (Data != NULL);
+
+  IrqType = fdt32_to_cpu (Data[IRQ_TYPE_OFFSET]);
+  IrqId   = fdt32_to_cpu (Data[IRQ_NUMBER_OFFSET]);
+
+  switch (IrqType) {
+    case DT_SPI_IRQ:
+      IrqId += SPI_OFFSET;
+      break;
+
+    case DT_PPI_IRQ:
+      IrqId += PPI_OFFSET;
+      break;
+
+    default:
+      ASSERT (0);
+      IrqId = 0;
+  }
+
+  return IrqId;
+}
+
+/** Get the ACPI interrupt flags of an interrupt described in a fdt.
+
+  Data must describe a GIC interrupt. A GIC interrupt is on at least
+  3 UINT32 cells.
+
+  PPI interrupt cpu mask on bits [15:8] are ignored.
+
+  @param [in]  Data   Pointer to the first cell of an "interrupts" property.
+
+  @retval  The interrupt flags (for ACPI).
+**/
+UINT32
+EFIAPI
+FdtGetInterruptFlags (
+  UINT32 CONST  *Data
+  )
+{
+  UINT32  IrqFlags;
+  UINT32  AcpiIrqFlags;
+
+  ASSERT (Data != NULL);
+
+  IrqFlags = fdt32_to_cpu (Data[IRQ_FLAGS_OFFSET]);
+
+  AcpiIrqFlags  = DT_IRQ_IS_EDGE_TRIGGERED (IrqFlags) ? BIT0 : 0;
+  AcpiIrqFlags |= DT_IRQ_IS_ACTIVE_LOW (IrqFlags) ? BIT1 : 0;
+
+  return AcpiIrqFlags;
+}
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.c b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.c
index 5314cf3808c2..bab228575938 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.c
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.c
@@ -13,77 +13,6 @@
 #include <FdtHwInfoParserInclude.h>
 #include "FdtUtility.h"
 
-/** Get the interrupt Id of an interrupt described in a fdt.
-
-  Data must describe a GIC interrupt. A GIC interrupt is on at least
-  3 UINT32 cells.
-  This function DOES NOT SUPPORT extended SPI range and extended PPI range.
-
-  @param [in]  Data   Pointer to the first cell of an "interrupts" property.
-
-  @retval  The interrupt id.
-**/
-UINT32
-EFIAPI
-FdtGetInterruptId (
-  UINT32 CONST  *Data
-  )
-{
-  UINT32  IrqType;
-  UINT32  IrqId;
-
-  ASSERT (Data != NULL);
-
-  IrqType = fdt32_to_cpu (Data[IRQ_TYPE_OFFSET]);
-  IrqId   = fdt32_to_cpu (Data[IRQ_NUMBER_OFFSET]);
-
-  switch (IrqType) {
-    case DT_SPI_IRQ:
-      IrqId += SPI_OFFSET;
-      break;
-
-    case DT_PPI_IRQ:
-      IrqId += PPI_OFFSET;
-      break;
-
-    default:
-      ASSERT (0);
-      IrqId = 0;
-  }
-
-  return IrqId;
-}
-
-/** Get the ACPI interrupt flags of an interrupt described in a fdt.
-
-  Data must describe a GIC interrupt. A GIC interrupt is on at least
-  3 UINT32 cells.
-
-  PPI interrupt cpu mask on bits [15:8] are ignored.
-
-  @param [in]  Data   Pointer to the first cell of an "interrupts" property.
-
-  @retval  The interrupt flags (for ACPI).
-**/
-UINT32
-EFIAPI
-FdtGetInterruptFlags (
-  UINT32 CONST  *Data
-  )
-{
-  UINT32  IrqFlags;
-  UINT32  AcpiIrqFlags;
-
-  ASSERT (Data != NULL);
-
-  IrqFlags = fdt32_to_cpu (Data[IRQ_FLAGS_OFFSET]);
-
-  AcpiIrqFlags  = DT_IRQ_IS_EDGE_TRIGGERED (IrqFlags) ? BIT0 : 0;
-  AcpiIrqFlags |= DT_IRQ_IS_ACTIVE_LOW (IrqFlags) ? BIT1 : 0;
-
-  return AcpiIrqFlags;
-}
-
 /** Check whether a node has the input name.
 
   @param [in]  Fdt          Pointer to a Flattened Device Tree.
-- 
2.34.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113475): https://edk2.groups.io/g/devel/message/113475
Mute This Topic: https://groups.io/mt/103622731/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 ` Sunil V L [this message]
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 ` [edk2-devel] [RFC PATCH v1 16/20] DynamicTablesPkg: AcpiFadtLib: Move ArmBootArch to ARM specific file Sunil V L
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-14-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