From nobody Tue Feb 10 06:26:26 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+76979+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+76979+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1624451937; cv=none; d=zohomail.com; s=zohoarc; b=FgLu0ksEYBreQ59jJ/UsRq/Rsie4EW9sr/DoVkPqi0xLrLzV8A0v86J3ZRUeqv6LV8CyFmSjy5vTR+zpI69l6MiHc23Uj+sunFEOERC9uFesXpTTS1Zwxx4TLx1xF+qlCbDnnse4Vbbqkgg0Jg06M8cEG6v7zZEpOostYu3Vvtw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624451937; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=O3HJcO9wpCQtjD0QUVBW7YYNSU9d4pclYwQcXlpg9jA=; b=OPCbmo9mj5mHflvVzmIwMLGZKiRgCMr4aQ/SC5DF5M11ox8vbJ5VXUz2zl90KdzAkP6Iz2FZsI2/3V7GBgZqMVsCB8mSi2ExJdzGxwUUovdVCWtGKzppiF5r2aLo9OiuMzFQpJWhh9RwMXfLnK2UG/u6PziNxxuHvYBr33C8rVk= 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+76979+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 162445193752478.55044108146308; Wed, 23 Jun 2021 05:38:57 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id WzaGYY1788612x2ugOyhGeK2; Wed, 23 Jun 2021 05:38:56 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web08.6817.1624451934474215829 for ; Wed, 23 Jun 2021 05:38:54 -0700 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 E323D1063; Wed, 23 Jun 2021 05:38:53 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.78.245]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 782003F718; Wed, 23 Jun 2021 05:38:52 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei Fedorov Cc: Akanksha Jain , Alexandru Elisei Subject: [edk2-devel] [PATCH v1 12/14] DynamicTablesPkg: FdtHwInfoParser: Add GIC dispatcher Date: Wed, 23 Jun 2021 13:38:26 +0100 Message-Id: <20210623123828.23693-13-Pierre.Gondois@arm.com> In-Reply-To: <20210623123828.23693-1-Pierre.Gondois@arm.com> References: <20210623123828.23693-1-Pierre.Gondois@arm.com> 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: m0EAvq0AI9yqReGHJaHTGqtzx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1624451936; bh=dxYF5kWWZMRS+nv+vUib5pq06bJbOOnTjsAMt9BCsII=; h=Cc:Date:From:Reply-To:Subject:To; b=i93dcDUxIV+wg30oz0ZzPXtuGgazn6c1jtLxnSbZzil6zJziQuzxpHZFNyAu2VkLcj9 3K897h0M1AaATbweW0gSIWU0wMqAsdgi1HKPStfEsZHBkvyQil1n5zwyJYKae87Q0btKN uXpRWky9iH9VdTArykFCfekiU7CmTjYNJCo= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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 Signed-off-by: Sami Mujawar --- .../FdtHwInfoParserLib/Gic/ArmGicDispatcher.c | 212 ++++++++++++++++++ .../FdtHwInfoParserLib/Gic/ArmGicDispatcher.h | 72 ++++++ 2 files changed, 284 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..3e5d7fb0cba6 --- /dev/null +++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Gic/ArmGicDispatcher.c @@ -0,0 +1,212 @@ +/** @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..a0671cea8a67 --- /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.17.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 (#76979): https://edk2.groups.io/g/devel/message/76979 Mute This Topic: https://groups.io/mt/83736647/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-