From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id B1E1474003A for ; Wed, 19 Jun 2024 22:07:21 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=3A7F6PbPz/zdQfqgVKfJpf/GmQA1gqOrZs61blb74zY=; 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:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20240206; t=1718834841; v=1; b=ZDyTws3jgDxuSJN4q49AwIAscccaI+Tf2BZYcZCEs39ZVd6NALcpYkHr3cDFRa9pbqz59z89 xL4idTp9hPHgtIt9Epfz1x9lSS0r3ayN6SSaQrELiW1shGt/id4bkACgqaRCvN1rkgwdCdc9pm1 xpCkGxCtes2Ht8d238UXmQuCasGghYBpXX7pqFjCCDgnTmgxb9R/OxY2c522zX83bpTs+ejap9D oQ3gzAJDdP8CvFPAwIvSx7vcPF1Y777IAoE5fCqNrwq0TVbw45UdBwSTRHq4sAHp8/w21udfQ57 XuRo9Q5Xv+qu/YqxC8aEvaeOSUf+uI10DUvvclMMr6LQw== X-Received: by 127.0.0.2 with SMTP id g7XFYY7687511xUd6Bz3y5ZL; Wed, 19 Jun 2024 15:07:20 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.34056.1718834834622036395 for ; Wed, 19 Jun 2024 15:07:14 -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 0D5E41042; Wed, 19 Jun 2024 15:07:39 -0700 (PDT) X-Received: from e126645.home (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 161453F64C; Wed, 19 Jun 2024 15:07:11 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io Cc: Pierre Gondois , AbdulLateef Attar , Girish Mahadevan , Jeff Brasen , Jeshua Smith , Leif Lindholm , Meenakshi Aggarwal , Sami Mujawar , Sunil V L , Yeo Reum Yun Subject: [edk2-devel] [staging/dynamictables-reorg PATCH 10/15] DynamicTablesPkg: FdtHwInfoParserLib: Refactor to prepare for other archs Date: Thu, 20 Jun 2024 00:06:24 +0200 Message-Id: <20240619220629.1994362-11-pierre.gondois@arm.com> In-Reply-To: <20240619220629.1994362-1-pierre.gondois@arm.com> References: <20240619220629.1994362-1-pierre.gondois@arm.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 Resent-Date: Wed, 19 Jun 2024 15:07:14 -0700 Resent-From: pierre.gondois@arm.com Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: ji8XMaVCzWjvgZkJi5dJrGe8x7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=ZDyTws3j; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io To allow other architectures to potentially re-use the serial port parser and make the code arch neutral, make the MainDispatcher() function arch specific. Other architectures can choose which parse/dispatcher are desired to be called through the configuration of the HwInfoParserTable. Suggested-by: Sunil V L Signed-off-by: Pierre Gondois --- .../Arm/ArmFdtHwInfoParser.c | 83 +++++++++++++++++++ .../FdtHwInfoParserLib/FdtHwInfoParser.c | 78 +---------------- .../FdtHwInfoParserLib/FdtHwInfoParser.h | 27 ++++++ .../FdtHwInfoParserLib/FdtHwInfoParserLib.inf | 15 ++-- 4 files changed, 121 insertions(+), 82 deletions(-) create mode 100644 DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtH= wInfoParser.c diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoPa= rser.c b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser= .c new file mode 100644 index 000000000000..403402731add --- /dev/null +++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c @@ -0,0 +1,83 @@ +/** @file=0D + Arm Flattened Device Tree parser library for KvmTool.=0D +=0D + Copyright (c) 2021, ARM Limited. All rights reserved.
=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +**/=0D +=0D +#include "FdtHwInfoParser.h"=0D +#include "Arm/BootArch/ArmBootArchParser.h"=0D +#include "Arm/GenericTimer/ArmGenericTimerParser.h"=0D +#include "Arm/Gic/ArmGicDispatcher.h"=0D +#include "Pci/ArmPciConfigSpaceParser.h"=0D +#include "Serial/ArmSerialPortParser.h"=0D +=0D +/** Ordered table of parsers/dispatchers.=0D +=0D + A parser parses a Device Tree to populate a specific CmObj type. None,=0D + one or many CmObj can be created by the parser.=0D + The created CmObj are then handed to the parser's caller through the=0D + HW_INFO_ADD_OBJECT interface.=0D + This can also be a dispatcher. I.e. a function that not parsing a=0D + Device Tree but calling other parsers.=0D +*/=0D +STATIC CONST FDT_HW_INFO_PARSER_FUNC HwInfoParserTable[] =3D {=0D + ArmBootArchInfoParser,=0D + ArmGenericTimerInfoParser,=0D + ArmGicDispatcher,=0D + ArmPciConfigInfoParser,=0D + SerialPortDispatcher=0D +};=0D +=0D +/** Main dispatcher: sequentially call the parsers/dispatchers=0D + of the HwInfoParserTable.=0D +=0D + A parser parses a Device Tree to populate a specific CmObj type. None,=0D + one or many CmObj can be created by the parser.=0D + The created CmObj are then handed to the parser's caller through the=0D + HW_INFO_ADD_OBJECT interface.=0D + This can also be a dispatcher. I.e. a function that not parsing a=0D + Device Tree but calling other parsers.=0D +=0D + @param [in] FdtParserHandle A handle to the parser instance.=0D + @param [in] FdtBranch When searching for DT node name, restrict=0D + the search to this Device Tree branch.=0D +=0D + @retval EFI_SUCCESS The function completed successfully.=0D + @retval EFI_ABORTED An error occurred.=0D + @retval EFI_INVALID_PARAMETER Invalid parameter.=0D + @retval EFI_NOT_FOUND Not found.=0D + @retval EFI_UNSUPPORTED Unsupported.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +ArchFdtHwInfoMainDispatcher (=0D + IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle,=0D + IN INT32 FdtBranch=0D + )=0D +{=0D + EFI_STATUS Status;=0D + UINT32 Index;=0D +=0D + if (fdt_check_header (FdtParserHandle->Fdt) < 0) {=0D + ASSERT (0);=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + for (Index =3D 0; Index < ARRAY_SIZE (HwInfoParserTable); Index++) {=0D + Status =3D HwInfoParserTable[Index](=0D + FdtParserHandle,=0D + FdtBranch=0D + );=0D + if (EFI_ERROR (Status) &&=0D + (Status !=3D EFI_NOT_FOUND))=0D + {=0D + // If EFI_NOT_FOUND, the parser didn't find information in the DT.=0D + // Don't trigger an error.=0D + ASSERT (0);=0D + return Status;=0D + }=0D + } // for=0D +=0D + return EFI_SUCCESS;=0D +}=0D diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParser.c = b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParser.c index 78bf9c9efae4..8e980dabe373 100644 --- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParser.c +++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParser.c @@ -6,82 +6,6 @@ **/=0D =0D #include "FdtHwInfoParser.h"=0D -#include "Arm/BootArch/ArmBootArchParser.h"=0D -#include "Arm/GenericTimer/ArmGenericTimerParser.h"=0D -#include "Arm/Gic/ArmGicDispatcher.h"=0D -#include "Pci/ArmPciConfigSpaceParser.h"=0D -#include "Serial/ArmSerialPortParser.h"=0D -=0D -/** Ordered table of parsers/dispatchers.=0D -=0D - A parser parses a Device Tree to populate a specific CmObj type. None,=0D - one or many CmObj can be created by the parser.=0D - The created CmObj are then handed to the parser's caller through the=0D - HW_INFO_ADD_OBJECT interface.=0D - This can also be a dispatcher. I.e. a function that not parsing a=0D - Device Tree but calling other parsers.=0D -*/=0D -STATIC CONST FDT_HW_INFO_PARSER_FUNC HwInfoParserTable[] =3D {=0D - ArmBootArchInfoParser,=0D - ArmGenericTimerInfoParser,=0D - ArmGicDispatcher,=0D - ArmPciConfigInfoParser,=0D - SerialPortDispatcher=0D -};=0D -=0D -/** Main dispatcher: sequentially call the parsers/dispatchers=0D - of the HwInfoParserTable.=0D -=0D - A parser parses a Device Tree to populate a specific CmObj type. None,=0D - one or many CmObj can be created by the parser.=0D - The created CmObj are then handed to the parser's caller through the=0D - HW_INFO_ADD_OBJECT interface.=0D - This can also be a dispatcher. I.e. a function that not parsing a=0D - Device Tree but calling other parsers.=0D -=0D - @param [in] FdtParserHandle A handle to the parser instance.=0D - @param [in] FdtBranch When searching for DT node name, restrict=0D - the search to this Device Tree branch.=0D -=0D - @retval EFI_SUCCESS The function completed successfully.=0D - @retval EFI_ABORTED An error occurred.=0D - @retval EFI_INVALID_PARAMETER Invalid parameter.=0D - @retval EFI_NOT_FOUND Not found.=0D - @retval EFI_UNSUPPORTED Unsupported.=0D -**/=0D -STATIC=0D -EFI_STATUS=0D -EFIAPI=0D -MainDispatcher (=0D - IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle,=0D - IN INT32 FdtBranch=0D - )=0D -{=0D - EFI_STATUS Status;=0D - UINT32 Index;=0D -=0D - if (fdt_check_header (FdtParserHandle->Fdt) < 0) {=0D - ASSERT (0);=0D - return EFI_INVALID_PARAMETER;=0D - }=0D -=0D - for (Index =3D 0; Index < ARRAY_SIZE (HwInfoParserTable); Index++) {=0D - Status =3D HwInfoParserTable[Index](=0D - FdtParserHandle,=0D - FdtBranch=0D - );=0D - if (EFI_ERROR (Status) &&=0D - (Status !=3D EFI_NOT_FOUND))=0D - {=0D - // If EFI_NOT_FOUND, the parser didn't find information in the DT.=0D - // Don't trigger an error.=0D - ASSERT (0);=0D - return Status;=0D - }=0D - } // for=0D -=0D - return EFI_SUCCESS;=0D -}=0D =0D /** Initialise the HwInfoParser.=0D =0D @@ -159,7 +83,7 @@ HwInfoParse ( }=0D =0D // Call all the parsers from the root node (-1).=0D - Status =3D MainDispatcher (=0D + Status =3D ArchFdtHwInfoMainDispatcher (=0D (FDT_HW_INFO_PARSER_HANDLE)ParserHandle,=0D -1=0D );=0D diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParser.h = b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParser.h index 8a8cf38581e0..90850b356a8c 100644 --- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParser.h +++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParser.h @@ -60,4 +60,31 @@ EFI_STATUS IN INT32 FdtBranch=0D );=0D =0D +/** Main dispatcher: sequentially call the parsers/dispatchers=0D + of the HwInfoParserTable.=0D +=0D + A parser parses a Device Tree to populate a specific CmObj type. None,=0D + one or many CmObj can be created by the parser.=0D + The created CmObj are then handed to the parser's caller through the=0D + HW_INFO_ADD_OBJECT interface.=0D + This can also be a dispatcher. I.e. a function that not parsing a=0D + Device Tree but calling other parsers.=0D +=0D + @param [in] FdtParserHandle A handle to the parser instance.=0D + @param [in] FdtBranch When searching for DT node name, restrict=0D + the search to this Device Tree branch.=0D +=0D + @retval EFI_SUCCESS The function completed successfully.=0D + @retval EFI_ABORTED An error occurred.=0D + @retval EFI_INVALID_PARAMETER Invalid parameter.=0D + @retval EFI_NOT_FOUND Not found.=0D + @retval EFI_UNSUPPORTED Unsupported.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +ArchFdtHwInfoMainDispatcher (=0D + IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle,=0D + IN INT32 FdtBranch=0D + );=0D +=0D #endif // FDT_HW_INFO_PARSER_H_=0D diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib= .inf b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf index fa768cf664df..3abc6a0fd274 100644 --- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf +++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf @@ -22,6 +22,13 @@ [Sources] FdtHwInfoParser.h=0D FdtUtility.c=0D FdtUtility.h=0D + Pci/ArmPciConfigSpaceParser.c=0D + Pci/ArmPciConfigSpaceParser.h=0D + Serial/ArmSerialPortParser.c=0D + Serial/ArmSerialPortParser.h=0D +=0D +[Sources.ARM, Sources.AARCH64]=0D + Arm/ArmFdtHwInfoParser.c=0D Arm/BootArch/ArmBootArchParser.c=0D Arm/BootArch/ArmBootArchParser.h=0D Arm/GenericTimer/ArmGenericTimerParser.c=0D @@ -38,13 +45,11 @@ [Sources] Arm/Gic/ArmGicMsiFrameParser.h=0D Arm/Gic/ArmGicRParser.c=0D Arm/Gic/ArmGicRParser.h=0D - Pci/ArmPciConfigSpaceParser.c=0D - Pci/ArmPciConfigSpaceParser.h=0D - Serial/ArmSerialPortParser.c=0D - Serial/ArmSerialPortParser.h=0D =0D -[Packages]=0D +[Packages.ARM, Packages.AARCH64]=0D ArmPkg/ArmPkg.dec=0D +=0D +[Packages]=0D DynamicTablesPkg/DynamicTablesPkg.dec=0D EmbeddedPkg/EmbeddedPkg.dec=0D MdeModulePkg/MdeModulePkg.dec=0D --=20 2.25.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#119642): https://edk2.groups.io/g/devel/message/119642 Mute This Topic: https://groups.io/mt/106770174/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-