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 373FBD81195 for ; Tue, 9 Jan 2024 16:30:19 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=UKFifUet5QP7j/8tu0iD5wuK44Q0kabK3O6BIvx845Q=; 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=1704817817; v=1; b=hZEZhxiRAcheW5LPBC8jTi9T8s/rRgP5c9GebiWzWdEwFyAMR15C1CER4UuwvBLyEt/Qh+ox 31sh4F0ffZYuo24Nfn8dJih60vJcxErgodi6SsR9CLHa06Idc3Ayf4p1fyOleKjFaBoD6RJ6IVf 3SlNVDIoszirhYvfsqO/kw20= X-Received: by 127.0.0.2 with SMTP id tYsZYY7687511xTyeS8FZXqd; Tue, 09 Jan 2024 08:30:17 -0800 X-Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by mx.groups.io with SMTP id smtpd.web10.21255.1704817817402729380 for ; Tue, 09 Jan 2024 08:30:17 -0800 X-Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1d4ba539f6cso28746495ad.3 for ; Tue, 09 Jan 2024 08:30:17 -0800 (PST) X-Gm-Message-State: VTD3FZCN64btSDN2NeZfAjYux7686176AA= X-Google-Smtp-Source: AGHT+IFJWEazj3bi1q8sD1A2jazPs9c8ic2gFMWUD7SqODzoMWJhhTthm8LW/Ti55xej31Of3iyX0g== X-Received: by 2002:a17:902:d2c4:b0:1d4:e20f:f2c2 with SMTP id n4-20020a170902d2c400b001d4e20ff2c2mr6367155plc.96.1704817816553; Tue, 09 Jan 2024 08:30:16 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 08:30:16 -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 07/20] DynamicTablesPkg: FdtHwInfoParserLib: Separate ARM specific code Date: Tue, 9 Jan 2024 21:59:31 +0530 Message-Id: <20240109162944.528006-8-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=hZEZhxiR; 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 HwInfoParserTable is an architecture specific structure. Hence, move it and the MainDispatcher function to ARCH specific file. Update INF file. Cc: Ard Biesheuvel Cc: Leif Lindholm Cc: Pierre Gondois Cc: Sami Mujawar Signed-off-by: Sunil V L --- .../FdtHwInfoParserLib/FdtHwInfoParserLib.inf | 15 ++-- .../FdtHwInfoParserLib/FdtHwInfoParser.h | 27 ++++++ .../Arm/ArmFdtHwInfoParser.c | 83 +++++++++++++++++++ .../FdtHwInfoParserLib/FdtHwInfoParser.c | 78 +---------------- 4 files changed, 121 insertions(+), 82 deletions(-) create mode 100644 DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c 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 FdtUtility.c FdtUtility.h + Pci/ArmPciConfigSpaceParser.c + Pci/ArmPciConfigSpaceParser.h + Serial/ArmSerialPortParser.c + Serial/ArmSerialPortParser.h + +[Sources.ARM, Sources.AARCH64] + Arm/ArmFdtHwInfoParser.c Arm/BootArch/ArmBootArchParser.c Arm/BootArch/ArmBootArchParser.h Arm/GenericTimer/ArmGenericTimerParser.c @@ -38,13 +45,11 @@ [Sources] Arm/Gic/ArmGicMsiFrameParser.h Arm/Gic/ArmGicRParser.c Arm/Gic/ArmGicRParser.h - Pci/ArmPciConfigSpaceParser.c - Pci/ArmPciConfigSpaceParser.h - Serial/ArmSerialPortParser.c - Serial/ArmSerialPortParser.h -[Packages] +[Packages.ARM, Packages.AARCH64] ArmPkg/ArmPkg.dec + +[Packages] DynamicTablesPkg/DynamicTablesPkg.dec EmbeddedPkg/EmbeddedPkg.dec MdeModulePkg/MdeModulePkg.dec diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParser.h b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParser.h index 8a8cf38581e0..f8766236c492 100644 --- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParser.h +++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParser.h @@ -60,4 +60,31 @@ EFI_STATUS IN INT32 FdtBranch ); +/** Main dispatcher: sequentially call the parsers/dispatchers + of the HwInfoParserTable. + + 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 +FdtHwInfoMainDispatcher ( + IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, + IN INT32 FdtBranch + ); + #endif // FDT_HW_INFO_PARSER_H_ diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c new file mode 100644 index 000000000000..4b1f5eeea423 --- /dev/null +++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c @@ -0,0 +1,83 @@ +/** @file + Flattened Device Tree parser library for KvmTool. + + Copyright (c) 2021, ARM Limited. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include "FdtHwInfoParser.h" +#include "Arm/BootArch/ArmBootArchParser.h" +#include "Arm/GenericTimer/ArmGenericTimerParser.h" +#include "Arm/Gic/ArmGicDispatcher.h" +#include "Pci/ArmPciConfigSpaceParser.h" +#include "Serial/ArmSerialPortParser.h" + +/** Ordered table of parsers/dispatchers. + + 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. +*/ +STATIC CONST FDT_HW_INFO_PARSER_FUNC HwInfoParserTable[] = { + ArmBootArchInfoParser, + ArmGenericTimerInfoParser, + ArmGicDispatcher, + ArmPciConfigInfoParser, + SerialPortDispatcher +}; + +/** Main dispatcher: sequentially call the parsers/dispatchers + of the HwInfoParserTable. + + 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 +FdtHwInfoMainDispatcher ( + IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, + IN INT32 FdtBranch + ) +{ + EFI_STATUS Status; + UINT32 Index; + + if (fdt_check_header (FdtParserHandle->Fdt) < 0) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + for (Index = 0; Index < ARRAY_SIZE (HwInfoParserTable); Index++) { + Status = HwInfoParserTable[Index]( + FdtParserHandle, + FdtBranch + ); + if (EFI_ERROR (Status) && + (Status != EFI_NOT_FOUND)) + { + // If EFI_NOT_FOUND, the parser didn't find information in the DT. + // Don't trigger an error. + ASSERT (0); + return Status; + } + } // for + + return EFI_SUCCESS; +} diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParser.c b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParser.c index 78bf9c9efae4..ae5c8eae6a6f 100644 --- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParser.c +++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParser.c @@ -6,82 +6,6 @@ **/ #include "FdtHwInfoParser.h" -#include "Arm/BootArch/ArmBootArchParser.h" -#include "Arm/GenericTimer/ArmGenericTimerParser.h" -#include "Arm/Gic/ArmGicDispatcher.h" -#include "Pci/ArmPciConfigSpaceParser.h" -#include "Serial/ArmSerialPortParser.h" - -/** Ordered table of parsers/dispatchers. - - 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. -*/ -STATIC CONST FDT_HW_INFO_PARSER_FUNC HwInfoParserTable[] = { - ArmBootArchInfoParser, - ArmGenericTimerInfoParser, - ArmGicDispatcher, - ArmPciConfigInfoParser, - SerialPortDispatcher -}; - -/** Main dispatcher: sequentially call the parsers/dispatchers - of the HwInfoParserTable. - - 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. -**/ -STATIC -EFI_STATUS -EFIAPI -MainDispatcher ( - IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, - IN INT32 FdtBranch - ) -{ - EFI_STATUS Status; - UINT32 Index; - - if (fdt_check_header (FdtParserHandle->Fdt) < 0) { - ASSERT (0); - return EFI_INVALID_PARAMETER; - } - - for (Index = 0; Index < ARRAY_SIZE (HwInfoParserTable); Index++) { - Status = HwInfoParserTable[Index]( - FdtParserHandle, - FdtBranch - ); - if (EFI_ERROR (Status) && - (Status != EFI_NOT_FOUND)) - { - // If EFI_NOT_FOUND, the parser didn't find information in the DT. - // Don't trigger an error. - ASSERT (0); - return Status; - } - } // for - - return EFI_SUCCESS; -} /** Initialise the HwInfoParser. @@ -159,7 +83,7 @@ HwInfoParse ( } // Call all the parsers from the root node (-1). - Status = MainDispatcher ( + Status = FdtHwInfoMainDispatcher ( (FDT_HW_INFO_PARSER_HANDLE)ParserHandle, -1 ); -- 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#113469): https://edk2.groups.io/g/devel/message/113469 Mute This Topic: https://groups.io/mt/103622718/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-