From nobody Tue Feb 10 13:17:23 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+84597+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+84597+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1639042351; cv=none; d=zohomail.com; s=zohoarc; b=KtgqoXP04qJFZLTpyD95xLZeuKh1YStpuJI+pLR+GZzyH4SZT0URjnSj52TX1QyB7lNjiKG/pGCIYj5wW1z3KSCZZTlgQO/RB7lDid05j97Rzt2uJK7FJUUzpAkC1trtCbMC7zphcIwy+aet6fwO9IcVa9Tl8d8OkbQXh6WfcrE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639042351; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=LN0tofsO8Wh8HdiJdjiZBFKejGlQoTrjOJHkGbXEVRw=; b=EjrN0vTAGl47CLScb0+LEOOAiGSuREnh6QVEZwb7Dm2hYmGGfCcsiFly6bsUOjJZWu03jdt+B0PLe59vkcy9/M3Feq3qQTDTuCRuVHkUHfb5T1MIIcItUQqGmoRoXCI/9x9BSQrD9r7/eeESptpXv8K1xyvznDXVYOj528YNWQE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+84597+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1639042351266780.9847628953145; Thu, 9 Dec 2021 01:32:31 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id jL2nYY1788612xM8l8MFNaEe; Thu, 09 Dec 2021 01:32:30 -0800 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web09.9537.1639042350272353351 for ; Thu, 09 Dec 2021 01:32:30 -0800 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E72D011FB; Thu, 9 Dec 2021 01:32:29 -0800 (PST) X-Received: from e126645.nice.arm.com (unknown [10.34.129.54]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 19EAB3F73B; Thu, 9 Dec 2021 01:32:28 -0800 (PST) From: "PierreGondois" To: devel@edk2.groups.io Cc: Sami Mujawar , Alexei Fedorov Subject: [edk2-devel] [PATCH v4 12/15] DynamicTablesPkg: FdtHwInfoParser: Add GIC dispatcher Date: Thu, 9 Dec 2021 10:32:05 +0100 Message-Id: <20211209093208.1249257-13-Pierre.Gondois@arm.com> In-Reply-To: <20211209093208.1249257-1-Pierre.Gondois@arm.com> References: <20211209093208.1249257-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,pierre.gondois@arm.com X-Gm-Message-State: KXuG4B7YQXtPPaXUIFT5a51dx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1639042350; bh=M+7ON00iu9i+rvhd7tXacM0ysFQP41I84XIkj0185y0=; h=Cc:Date:From:Reply-To:Subject:To; b=GI0Y5l359j94Y0SFxjLXlPxsmDe9gEKAUGgdTuGhKSmpAvGBk4J14iMfUzdFfwDdjtF T977mw0YG8unxuiE5eo10/Q8Ikf0UGu+qjdVkrFUfvDgpDWu3TYhVLLGAGzCshQX+f/ui ik0xbSW+sa+HfEPIzDoyqn2wEn2Nacp9tDc= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1639042351661100005 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois The GIC Dispatcher is the top-level component that is responsible for invoking the respective parsers for GICC, GICD, GIC MSI Frame, GIC ITS and the GICR. Signed-off-by: Pierre Gondois --- .../FdtHwInfoParserLib/Gic/ArmGicDispatcher.c | 218 ++++++++++++++++++ .../FdtHwInfoParserLib/Gic/ArmGicDispatcher.h | 72 ++++++ 2 files changed, 290 insertions(+) create mode 100644 DynamicTablesPkg/Library/FdtHwInfoParserLib/Gic/ArmGicD= ispatcher.c create mode 100644 DynamicTablesPkg/Library/FdtHwInfoParserLib/Gic/ArmGicD= ispatcher.h diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Gic/ArmGicDispatch= er.c b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Gic/ArmGicDispatcher.c new file mode 100644 index 000000000000..831f0d5b7365 --- /dev/null +++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Gic/ArmGicDispatcher.c @@ -0,0 +1,218 @@ +/** @file + Arm Gic dispatcher. + + Copyright (c) 2021, ARM Limited. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Reference(s): + - linux/Documentation/devicetree/bindings/interrupt-controller/arm,gic.y= aml + - linux/Documentation/devicetree/bindings/interrupt-controller/arm,gic-v= 3.yaml +**/ + +#include "FdtHwInfoParser.h" +#include "Gic/ArmGicCParser.h" +#include "Gic/ArmGicDispatcher.h" +#include "Gic/ArmGicDParser.h" +#include "Gic/ArmGicItsParser.h" +#include "Gic/ArmGicMsiFrameParser.h" +#include "Gic/ArmGicRParser.h" + +/** List of "compatible" property values for GicV2 interrupt nodes. + + Any other "compatible" value is not supported by this module. +*/ +STATIC CONST COMPATIBILITY_STR GicV2CompatibleStr[] =3D { + { "arm,cortex-a15-gic" } +}; + +/** COMPATIBILITY_INFO structure for the GICv2. +*/ +CONST COMPATIBILITY_INFO GicV2CompatibleInfo =3D { + ARRAY_SIZE (GicV2CompatibleStr), + GicV2CompatibleStr +}; + +/** List of "compatible" property values for GicV3 interrupt nodes. + + Any other "compatible" value is not supported by this module. +*/ +STATIC CONST COMPATIBILITY_STR GicV3CompatibleStr[] =3D { + { "arm,gic-v3" } +}; + +/** COMPATIBILITY_INFO structure for the GICv3. +*/ +CONST COMPATIBILITY_INFO GicV3CompatibleInfo =3D { + ARRAY_SIZE (GicV3CompatibleStr), + GicV3CompatibleStr +}; + +/** Get the Gic version of am interrupt-controller node. + + @param [in] Fdt Pointer to a Flattened Device Tree (Fdt). + @param [in] IntcNode Interrupt-controller node. + @param [out] GicVersion If success, contains the Gic version of the + interrupt-controller node. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_UNSUPPORTED Unsupported. +**/ +EFI_STATUS +EFIAPI +GetGicVersion ( + IN CONST VOID *Fdt, + IN INT32 IntcNode, + OUT UINT32 *GicVersion + ) +{ + if ((Fdt =3D=3D NULL) || + (GicVersion =3D=3D NULL)) + { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + if (FdtNodeIsCompatible (Fdt, IntcNode, &GicV2CompatibleInfo)) { + *GicVersion =3D 2; + } else if (FdtNodeIsCompatible (Fdt, IntcNode, &GicV3CompatibleInfo)) { + *GicVersion =3D 3; + } else { + // Unsupported Gic version. + ASSERT (0); + return EFI_UNSUPPORTED; + } + + return EFI_SUCCESS; +} + +/** Gic dispatcher. + + This disptacher populates the following structures: + - CM_ARM_GICC_INFO + - CM_ARM_GICD_INFO + - CM_ARM_GIC_MSI_FRAME_INFO + + A parser parses a Device Tree to populate a specific CmObj type. None, + one or many CmObj can be created by the parser. + The created CmObj are then handed to the parser's caller through the + HW_INFO_ADD_OBJECT interface. + This can also be a dispatcher. I.e. a function that not parsing a + Device Tree but calling other parsers. + + @param [in] FdtParserHandle A handle to the parser instance. + @param [in] FdtBranch When searching for DT node name, restrict + the search to this Device Tree branch. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_ABORTED An error occurred. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_NOT_FOUND Not found. + @retval EFI_UNSUPPORTED Unsupported. +**/ +EFI_STATUS +EFIAPI +ArmGicDispatcher ( + IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, + IN INT32 FdtBranch + ) +{ + EFI_STATUS Status; + INT32 CpusNode; + INT32 IntcNode; + UINT32 GicVersion; + VOID *Fdt; + + if (FdtParserHandle =3D=3D NULL) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + Fdt =3D FdtParserHandle->Fdt; + + // The "cpus" node resides at the the root of the DT. Fetch it. + CpusNode =3D fdt_path_offset (Fdt, "/cpus"); + if (CpusNode < 0) { + return EFI_NOT_FOUND; + } + + // Get the interrupt-controller node associated to the "cpus" node. + Status =3D FdtGetIntcParentNode (Fdt, CpusNode, &IntcNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + if (Status =3D=3D EFI_NOT_FOUND) { + // Should have found the node. + Status =3D EFI_ABORTED; + } + + return Status; + } + + Status =3D GetGicVersion (Fdt, IntcNode, &GicVersion); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + // Parse the GicC information. + Status =3D ArmGicCInfoParser (FdtParserHandle, CpusNode); + if (EFI_ERROR (Status)) { + // Don't try to parse GicD and GicMsiFrame information + // if no GicC information is found. Return. + ASSERT (Status =3D=3D EFI_NOT_FOUND); + return Status; + } + + // Parse the GicD information of the "cpus" interrupt-controller node. + Status =3D ArmGicDInfoParser (FdtParserHandle, IntcNode); + if (EFI_ERROR (Status)) { + // EFI_NOT_FOUND is not tolerated at this point. + ASSERT (0); + return Status; + } + + switch (GicVersion) { + case 4: + case 3: + { + // Parse the GicR information of the interrupt-controller node. + Status =3D ArmGicRInfoParser (FdtParserHandle, IntcNode); + if (EFI_ERROR (Status)) { + // EFI_NOT_FOUND is not tolerated at this point. + ASSERT (0); + return Status; + } + + // Parse the GicIts information of the interrupt-controller node. + Status =3D ArmGicItsInfoParser (FdtParserHandle, IntcNode); + if (EFI_ERROR (Status) && + (Status !=3D EFI_NOT_FOUND)) + { + ASSERT (0); + return Status; + } + + break; + } + case 2: + { + // Parse the GicMsiFrame information. + Status =3D ArmGicMsiFrameInfoParser (FdtParserHandle, IntcNode); + if (EFI_ERROR (Status) && + (Status !=3D EFI_NOT_FOUND)) + { + ASSERT (0); + return Status; + } + + break; + } + default: + { + ASSERT (0); + return EFI_UNSUPPORTED; + } + } + + return EFI_SUCCESS; +} diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Gic/ArmGicDispatch= er.h b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Gic/ArmGicDispatcher.h new file mode 100644 index 000000000000..aa942f7d1f49 --- /dev/null +++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Gic/ArmGicDispatcher.h @@ -0,0 +1,72 @@ +/** @file + Arm Gic dispatcher. + + Copyright (c) 2021, ARM Limited. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Reference(s): + - linux/Documentation/devicetree/bindings/interrupt-controller/arm,gic.y= aml + - linux/Documentation/devicetree/bindings/interrupt-controller/arm,gic-v= 3.yaml +**/ + +#ifndef ARM_GIC_DISPATCHER_H_ +#define ARM_GIC_DISPATCHER_H_ + +#include +#include "FdtUtility.h" + +/** COMPATIBILITY_INFO structure for the GICv2. +*/ +extern CONST COMPATIBILITY_INFO GicV2CompatibleInfo; + +/** Get the Gic version of the interrupt-controller node. + + @param [in] Fdt Pointer to a Flattened Device Tree (Fdt). + @param [in] IntcNode Interrupt-controller node. + @param [out] GicVersion If success, contains the Gic version of the + interrupt-controller node. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_UNSUPPORTED Unsupported. +**/ +EFI_STATUS +EFIAPI +GetGicVersion ( + IN CONST VOID *Fdt, + IN INT32 IntcNode, + OUT UINT32 *GicVersion + ); + +/** Gic dispatcher. + + This disptacher populates the following structures: + - CM_ARM_GICC_INFO + - CM_ARM_GICD_INFO + - CM_ARM_GIC_MSI_FRAME_INFO + + A parser parses a Device Tree to populate a specific CmObj type. None, + one or many CmObj can be created by the parser. + The created CmObj are then handed to the parser's caller through the + HW_INFO_ADD_OBJECT interface. + This can also be a dispatcher. I.e. a function that not parsing a + Device Tree but calling other parsers. + + @param [in] FdtParserHandle A handle to the parser instance. + @param [in] FdtBranch When searching for DT node name, restrict + the search to this Device Tree branch. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_ABORTED An error occurred. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_NOT_FOUND Not found. + @retval EFI_UNSUPPORTED Unsupported. +**/ +EFI_STATUS +EFIAPI +ArmGicDispatcher ( + IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, + IN INT32 FdtBranch + ); + +#endif // ARM_GIC_DISPATCHER_H_ --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#84597): https://edk2.groups.io/g/devel/message/84597 Mute This Topic: https://groups.io/mt/87608916/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-