From: "PierreGondois" <pierre.gondois@arm.com>
To: devel@edk2.groups.io
Cc: Pierre Gondois <pierre.gondois@arm.com>,
AbdulLateef Attar <AbdulLateef.Attar@amd.com>,
Girish Mahadevan <gmahadevan@nvidia.com>,
Jeff Brasen <jbrasen@nvidia.com>,
Jeshua Smith <jeshuas@nvidia.com>,
Leif Lindholm <quic_llindhol@quicinc.com>,
Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>,
Sami Mujawar <sami.mujawar@arm.com>,
Sunil V L <sunilvl@ventanamicro.com>,
Yeo Reum Yun <YeoReum.Yun@arm.com>
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 [thread overview]
Message-ID: <20240619220629.1994362-11-pierre.gondois@arm.com> (raw)
In-Reply-To: <20240619220629.1994362-1-pierre.gondois@arm.com>
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 <sunilvl@ventanamicro.com>
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
---
.../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/ArmFdtHwInfoParser.c
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.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
+ Arm Flattened Device Tree parser library for KvmTool.
+
+ Copyright (c) 2021, ARM Limited. All rights reserved.<BR>
+ 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
+ArchFdtHwInfoMainDispatcher (
+ 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..8e980dabe373 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 = ArchFdtHwInfoMainDispatcher (
(FDT_HW_INFO_PARSER_HANDLE)ParserHandle,
-1
);
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
);
+/** 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
+ArchFdtHwInfoMainDispatcher (
+ IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle,
+ IN INT32 FdtBranch
+ );
+
#endif // FDT_HW_INFO_PARSER_H_
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
--
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]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2024-06-19 22:07 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-19 22:06 [edk2-devel] [staging/dynamictables-reorg PATCH 00/15] Prepare libraries to support other archs PierreGondois
2024-06-19 22:06 ` [edk2-devel] [staging/dynamictables-reorg PATCH 01/15] DynamicTablesPkg: Acpi: Move generic libraries to common folder PierreGondois
2024-06-19 22:06 ` [edk2-devel] [staging/dynamictables-reorg PATCH 02/15] DynamicTablesPkg: Acpi: Prepare common libraries to support other archs PierreGondois
2024-06-19 22:06 ` [edk2-devel] [staging/dynamictables-reorg PATCH 03/15] DynamicTablesPkg: AcpiFadtLib: Prepare " PierreGondois
2024-06-19 22:06 ` [edk2-devel] [staging/dynamictables-reorg PATCH 04/15] DynamicTablesPkg: AcpiDbg2Lib: " PierreGondois
2024-06-19 22:06 ` [edk2-devel] [staging/dynamictables-reorg PATCH 05/15] DynamicTablesPkg: AcpiSpcrLib: " PierreGondois
2024-06-19 22:06 ` [edk2-devel] [staging/dynamictables-reorg PATCH 06/15] DynamicTablesPkg: AcpiSratLib: " PierreGondois
2024-06-19 22:06 ` [edk2-devel] [staging/dynamictables-reorg PATCH 07/15] DynamicTablesPkg: AcpiSsdtCpuTopologyLib: Avoid dependency on GICC PierreGondois
2024-06-19 22:06 ` [edk2-devel] [staging/dynamictables-reorg PATCH 08/15] DynamicTablesPkg: DynamicTableManagerDxe: Refactor PresenceArray PierreGondois
2024-06-19 22:06 ` [edk2-devel] [staging/dynamictables-reorg PATCH 09/15] DynamicTablesPkg: FdtHwInfoParserLib: Move ARM parsers to Arm directory PierreGondois
2024-06-19 22:06 ` PierreGondois [this message]
2024-06-19 22:06 ` [edk2-devel] [staging/dynamictables-reorg PATCH 11/15] DynamicTablesPkg: FdtHwInfoParserLib: Make Pci parser arch neutral PierreGondois
2024-06-19 22:06 ` [edk2-devel] [staging/dynamictables-reorg PATCH 12/15] DynamicTablesPkg: FdtHwInfoParserLib: Make Serial Port " PierreGondois
2024-06-19 22:06 ` [edk2-devel] [staging/dynamictables-reorg PATCH 13/15] DynamicTablesPkg: FdtHwInfoParserLib: Move ArmLib.h to ArmGicCParser.c PierreGondois
2024-06-19 22:06 ` [edk2-devel] [staging/dynamictables-reorg PATCH 14/15] DynamicTablesPkg: FdtHwInfoParserLib: Move IRQ map to arch folder PierreGondois
2024-07-03 6:20 ` Sunil V L
2024-06-19 22:06 ` [edk2-devel] [staging/dynamictables-reorg PATCH 15/15] DynamicTablesPkg: FdtHwInfoParserLib: Create wrapper to get INTC addr cells PierreGondois
2024-07-03 6:50 ` Sunil V L
2024-07-03 7:36 ` Sami Mujawar
2024-07-03 9:08 ` [edk2-devel] [staging/dynamictables-reorg PATCH 00/15] Prepare libraries to support other archs Sami Mujawar
2024-07-03 9:36 ` Sunil V L
2024-07-03 9:39 ` Sami Mujawar
2024-07-03 9:43 ` Sunil V L
2024-07-03 9:55 ` PierreGondois
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240619220629.1994362-11-pierre.gondois@arm.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox