From 40a0dbdd18fe6303a71113e7e9c49f45042e692b Mon Sep 17 00:00:00 2001 From: Pierre Gondois Date: Mon, 10 Jun 2024 14:00:00 +0200 Subject: [PATCH] DynamicTablesPkg: FdtHwInfoParserLib: Create wrapper to get INTC addr cells Parent interrupt controller's address cells is arch specific. So, create a wrapper function which can be implemented differently for different archs. Move current implementation to ARM specific file. Suggested-by: Sunil V L Signed-off-by: Pierre Gondois Reviewed-by: Sami Mujawar Reviewed-by: Sunil V L --- .../AcpiSsdtPcieLib/SsdtPcieGenerator.c | 2 +- .../FdtHwInfoParserLib/Arm/ArmFdtInterrupt.c | 33 +++++++++++++++++++ .../Library/FdtHwInfoParserLib/FdtUtility.h | 30 +++++++++++++++++ .../Pci/PciConfigSpaceParser.c | 2 +- 4 files changed, 65 insertions(+), 2 deletions(-) diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtPcieLib/SsdtPcieGenerator.c b/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtPcieLib/SsdtPcieGenerator.c index 2b488016e5..5b6d551562 100644 --- a/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtPcieLib/SsdtPcieGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtPcieLib/SsdtPcieGenerator.c @@ -974,7 +974,7 @@ BuildSsdtPciTableEx ( EFI_STATUS Status; CM_ARCH_COMMON_PCI_CONFIG_SPACE_INFO *PciInfo; UINT32 PciCount; - UINTN Index; + UINT32 Index; EFI_ACPI_DESCRIPTION_HEADER **TableList; ACPI_PCI_GENERATOR *Generator; UINT32 Uid; diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtInterrupt.c b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtInterrupt.c index 21b1306e57..71774fae71 100644 --- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtInterrupt.c +++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtInterrupt.c @@ -83,3 +83,36 @@ FdtGetInterruptFlags ( return AcpiIrqFlags; } + +/** For relevant architectures, get the "#address-cells" and/or "#size-cells" + property of the node. + + According to the Device Tree specification, s2.3.5 "#address-cells and + #size-cells": + "If missing, a client program should assume a default value of 2 for + #address-cells, and a value of 1 for #size-cells." + + @param [in] Fdt Pointer to a Flattened Device Tree. + @param [in] Node Offset of the node having to get the + "#address-cells" and "#size-cells" + properties from. + @param [out] AddressCells If success, number of address-cells. + If the property is not available, + default value is 2. + @param [out] SizeCells If success, number of size-cells. + If the property is not available, + default value is 1. + + @retval EFI_INVALID_PARAMETER Invalid parameter. +**/ +EFI_STATUS +EFIAPI +FdtGetIntcAddressCells ( + IN CONST VOID *Fdt, + IN INT32 Node, + OUT INT32 *AddressCells, OPTIONAL + OUT INT32 *SizeCells OPTIONAL + ) +{ + return FdtGetAddressInfo (Fdt, Node, AddressCells, SizeCells); +} diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.h b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.h index 3f5d131d9a..2d7048753b 100644 --- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.h +++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.h @@ -455,4 +455,34 @@ FdtGetParentAddressInfo ( OUT INT32 *SizeCells OPTIONAL ); +/** For relevant architectures, get the "#address-cells" and/or "#size-cells" + property of the node. + + According to the Device Tree specification, s2.3.5 "#address-cells and + #size-cells": + "If missing, a client program should assume a default value of 2 for + #address-cells, and a value of 1 for #size-cells." + + @param [in] Fdt Pointer to a Flattened Device Tree. + @param [in] Node Offset of the node having to get the + "#address-cells" and "#size-cells" + properties from. + @param [out] AddressCells If success, number of address-cells. + If the property is not available, + default value is 2. + @param [out] SizeCells If success, number of size-cells. + If the property is not available, + default value is 1. + + @retval EFI_INVALID_PARAMETER Invalid parameter. +**/ +EFI_STATUS +EFIAPI +FdtGetIntcAddressCells ( + IN CONST VOID *Fdt, + IN INT32 Node, + OUT INT32 *AddressCells, OPTIONAL + OUT INT32 *SizeCells OPTIONAL + ); + #endif // FDT_UTILITY_H_ diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/PciConfigSpaceParser.c b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/PciConfigSpaceParser.c index 76f9efdf64..7f536c0ac6 100644 --- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/PciConfigSpaceParser.c +++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/PciConfigSpaceParser.c @@ -365,7 +365,7 @@ ParseIrqMap ( } // Get the "address-cells" property of the IntcNode. - Status = FdtGetAddressInfo (Fdt, IntcNode, &IntcAddressCells, NULL); + Status = FdtGetIntcAddressCells (Fdt, IntcNode, &IntcAddressCells, NULL); if (EFI_ERROR (Status)) { ASSERT (0); return Status;