From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id D8521D811C0 for ; Tue, 9 Jan 2024 16:30:36 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=DXCILK7h3R4mk4d+bC0aq1bymiDLrdUz8Bx5AkcEZgo=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1704817835; v=1; b=GcWgz3GpQ34/2PaBx2Onhv4Txb4kfYrbx8KJe7PbfYRuPLZ1nxFa4voYWVdYwZyOhX5HPOQD QXu+2CDDgxFsgKWjsy6lekc0GREEcy0usNHSeOf/eOKJItI+ZGi+ro66CqAJt5eTVp+Wwqqx2eF qto1fI9z6/brVr8xj9ldcZNg= X-Received: by 127.0.0.2 with SMTP id Dl0qYY7687511xB5uM5FDsB6; Tue, 09 Jan 2024 08:30:35 -0800 X-Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by mx.groups.io with SMTP id smtpd.web11.21058.1704817835087053255 for ; Tue, 09 Jan 2024 08:30:35 -0800 X-Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1d3f8af8297so14243195ad.2 for ; Tue, 09 Jan 2024 08:30:35 -0800 (PST) X-Gm-Message-State: ZwCckwNjsqHnosvuwHCZkOwzx7686176AA= X-Google-Smtp-Source: AGHT+IEofGGvMbrAB2sEU/4sBHg11AgyFmdadF6z4mebx2Z3hlg/SHsZFx0r1EBqCJsuIf/tapRU5A== X-Received: by 2002:a17:902:da8c:b0:1d3:c8ff:4f6e with SMTP id j12-20020a170902da8c00b001d3c8ff4f6emr3167821plx.103.1704817833669; Tue, 09 Jan 2024 08:30:33 -0800 (PST) X-Received: from localhost.localdomain ([106.51.188.200]) by smtp.gmail.com with ESMTPSA id c12-20020a170902b68c00b001d457090851sm1983596pls.289.2024.01.09.08.30.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 08:30:33 -0800 (PST) From: "Sunil V L" To: devel@edk2.groups.io Cc: Sunil V L , Ard Biesheuvel , Leif Lindholm , Pierre Gondois , Sami Mujawar 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 Message-Id: <20240109162944.528006-14-sunilvl@ventanamicro.com> In-Reply-To: <20240109162944.528006-1-sunilvl@ventanamicro.com> References: <20240109162944.528006-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sunilvl@ventanamicro.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=GcWgz3Gp; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=none 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 Cc: Leif Lindholm Cc: Pierre Gondois Cc: Sami Mujawar Signed-off-by: Sunil V L --- .../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.
+ 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 +#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 #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] -=-=-=-=-=-=-=-=-=-=-=-