summaryrefslogtreecommitdiffstats
path: root/DynamicTablesPkg
diff options
context:
space:
mode:
Diffstat (limited to 'DynamicTablesPkg')
-rw-r--r--DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c3
-rw-r--r--DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtInterrupt.c7
-rw-r--r--DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/BootArch/ArmBootArchParser.c3
-rw-r--r--DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/GenericTimer/ArmGenericTimerParser.c5
-rw-r--r--DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicCParser.c49
-rw-r--r--DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicDParser.c7
-rw-r--r--DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicDispatcher.c3
-rw-r--r--DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicItsParser.c7
-rw-r--r--DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicMsiFrameParser.c7
-rw-r--r--DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicRParser.c15
-rw-r--r--DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParser.c3
-rw-r--r--DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserInclude.h1
-rw-r--r--DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.c33
-rw-r--r--DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/PciConfigSpaceParser.c43
-rw-r--r--DynamicTablesPkg/Library/FdtHwInfoParserLib/Serial/SerialPortParser.c33
15 files changed, 116 insertions, 103 deletions
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c
index 2c9105ed10..2aa09e99ad 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtHwInfoParser.c
@@ -5,6 +5,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
+#include <Library/FdtLib.h>
#include "FdtHwInfoParser.h"
#include "Arm/BootArch/ArmBootArchParser.h"
#include "Arm/GenericTimer/ArmGenericTimerParser.h"
@@ -59,7 +60,7 @@ ArchFdtHwInfoMainDispatcher (
EFI_STATUS Status;
UINT32 Index;
- if (fdt_check_header (FdtParserHandle->Fdt) < 0) {
+ if (FdtCheckHeader (FdtParserHandle->Fdt) < 0) {
ASSERT (0);
return EFI_INVALID_PARAMETER;
}
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtInterrupt.c b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtInterrupt.c
index 71774fae71..71a396de78 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtInterrupt.c
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtInterrupt.c
@@ -10,6 +10,7 @@
- linux//Documentation/devicetree/bindings/interrupt-controller/arm%2Cgic.yaml
**/
+#include <Library/FdtLib.h>
#include <FdtHwInfoParserInclude.h>
#include "FdtUtility.h"
@@ -34,8 +35,8 @@ FdtGetInterruptId (
ASSERT (Data != NULL);
- IrqType = fdt32_to_cpu (Data[IRQ_TYPE_OFFSET]);
- IrqId = fdt32_to_cpu (Data[IRQ_NUMBER_OFFSET]);
+ IrqType = Fdt32ToCpu (Data[IRQ_TYPE_OFFSET]);
+ IrqId = Fdt32ToCpu (Data[IRQ_NUMBER_OFFSET]);
switch (IrqType) {
case DT_SPI_IRQ:
@@ -76,7 +77,7 @@ FdtGetInterruptFlags (
ASSERT (Data != NULL);
- IrqFlags = fdt32_to_cpu (Data[IRQ_FLAGS_OFFSET]);
+ IrqFlags = Fdt32ToCpu (Data[IRQ_FLAGS_OFFSET]);
AcpiIrqFlags = DT_IRQ_IS_EDGE_TRIGGERED (IrqFlags) ? BIT0 : 0;
AcpiIrqFlags |= DT_IRQ_IS_ACTIVE_LOW (IrqFlags) ? BIT1 : 0;
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/BootArch/ArmBootArchParser.c b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/BootArch/ArmBootArchParser.c
index b5c42d88fc..35f4c6dbdc 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/BootArch/ArmBootArchParser.c
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/BootArch/ArmBootArchParser.c
@@ -10,6 +10,7 @@
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
+#include <Library/FdtLib.h>
#include "FdtHwInfoParser.h"
#include "CmObjectDescUtility.h"
#include "Arm/BootArch/ArmBootArchParser.h"
@@ -69,7 +70,7 @@ PsciNodeParser (
// Default to parking protocol
BootArchInfo->BootArchFlags = 0;
- Data = fdt_getprop (Fdt, PsciNode, "method", &DataSize);
+ Data = FdtGetProp (Fdt, PsciNode, "method", &DataSize);
if ((Data == NULL) || (DataSize < 0)) {
ASSERT (0);
return EFI_ABORTED;
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/GenericTimer/ArmGenericTimerParser.c b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/GenericTimer/ArmGenericTimerParser.c
index c79ad9213a..a14ed3a98a 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/GenericTimer/ArmGenericTimerParser.c
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/GenericTimer/ArmGenericTimerParser.c
@@ -9,6 +9,7 @@
**/
#include <Library/BaseMemoryLib.h>
+#include <Library/FdtLib.h>
#include "FdtHwInfoParser.h"
#include "CmObjectDescUtility.h"
#include "Arm/GenericTimer/ArmGenericTimerParser.h"
@@ -64,7 +65,7 @@ TimerNodeParser (
return EFI_INVALID_PARAMETER;
}
- Data = fdt_getprop (Fdt, TimerNode, "always-on", &DataSize);
+ Data = FdtGetProp (Fdt, TimerNode, "always-on", &DataSize);
if ((Data == NULL) || (DataSize < 0)) {
AlwaysOnTimer = FALSE;
} else {
@@ -97,7 +98,7 @@ TimerNodeParser (
return Status;
}
- Data = fdt_getprop (Fdt, TimerNode, "interrupts", &DataSize);
+ Data = FdtGetProp (Fdt, TimerNode, "interrupts", &DataSize);
if ((Data == NULL) ||
(DataSize != (FdtMaxTimerItem * IntCells * sizeof (UINT32))))
{
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicCParser.c b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicCParser.c
index f74e5d5fef..4bbe7e0d50 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicCParser.c
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicCParser.c
@@ -12,6 +12,7 @@
**/
#include <Library/ArmLib.h>
+#include <Library/FdtLib.h>
#include "FdtHwInfoParser.h"
#include "CmObjectDescUtility.h"
#include "Arm/Gic/ArmGicCParser.h"
@@ -91,7 +92,7 @@ CpuNodeParser (
return EFI_INVALID_PARAMETER;
}
- Data = fdt_getprop (Fdt, CpuNode, "reg", &DataSize);
+ Data = FdtGetProp (Fdt, CpuNode, "reg", &DataSize);
if ((Data == NULL) ||
((DataSize != sizeof (UINT32)) &&
(DataSize != sizeof (UINT64))))
@@ -107,10 +108,10 @@ CpuNodeParser (
bits [23:0] of MPIDR_EL1.
*/
if (AddressCells == 2) {
- MpIdr = fdt64_to_cpu (*((UINT64 *)Data));
+ MpIdr = Fdt64ToCpu (*((UINT64 *)Data));
CheckAffMask |= ARM_CORE_AFF3;
} else {
- MpIdr = fdt32_to_cpu (*((UINT32 *)Data));
+ MpIdr = Fdt32ToCpu (*((UINT32 *)Data));
}
if ((MpIdr & ~CheckAffMask) != 0) {
@@ -185,7 +186,7 @@ CpusNodeParser (
return EFI_INVALID_PARAMETER;
}
- AddressCells = fdt_address_cells (Fdt, CpusNode);
+ AddressCells = FdtAddressCells (Fdt, CpusNode);
if (AddressCells < 0) {
ASSERT (0);
return EFI_ABORTED;
@@ -312,11 +313,11 @@ GicCIntcNodeParser (
// According to the DT bindings, this could be the:
// "Interrupt source of the parent interrupt controller on secondary GICs"
// but it is assumed that only one Gic is available.
- Data = fdt_getprop (Fdt, GicIntcNode, "interrupts", &DataSize);
+ Data = FdtGetProp (Fdt, GicIntcNode, "interrupts", &DataSize);
if ((Data != NULL) && (DataSize == (IntCells * sizeof (UINT32)))) {
MaintenanceInterrupt = FdtGetInterruptId ((CONST UINT32 *)Data);
Flags = DT_IRQ_IS_EDGE_TRIGGERED (
- fdt32_to_cpu (((UINT32 *)Data)[IRQ_FLAGS_OFFSET])
+ Fdt32ToCpu (((UINT32 *)Data)[IRQ_FLAGS_OFFSET])
) ?
EFI_ACPI_6_3_VGIC_MAINTENANCE_INTERRUPT_MODE_FLAGS :
0;
@@ -411,7 +412,7 @@ GicCv2IntcNodeParser (
RegSize = (AddressCells + SizeCells) * sizeof (UINT32);
- Data = fdt_getprop (Fdt, Gicv2IntcNode, "reg", &DataSize);
+ Data = FdtGetProp (Fdt, Gicv2IntcNode, "reg", &DataSize);
if ((Data == NULL) ||
(DataSize < 0) ||
((DataSize % RegSize) != 0))
@@ -456,17 +457,17 @@ GicCv2IntcNodeParser (
// Patch the relevant fields of the CM_ARM_GICC_INFO objects.
for (Index = 0; Index < GicCCmObjDesc->Count; Index++) {
if (AddressCells == 2) {
- GicCInfo[Index].PhysicalBaseAddress = fdt64_to_cpu (*(UINT64 *)GicCValue);
+ GicCInfo[Index].PhysicalBaseAddress = Fdt64ToCpu (*(UINT64 *)GicCValue);
GicCInfo[Index].GICH = (GicHValue == NULL) ? 0 :
- fdt64_to_cpu (*(UINT64 *)GicHValue);
+ Fdt64ToCpu (*(UINT64 *)GicHValue);
GicCInfo[Index].GICV = (GicVValue == NULL) ? 0 :
- fdt64_to_cpu (*(UINT64 *)GicVValue);
+ Fdt64ToCpu (*(UINT64 *)GicVValue);
} else {
- GicCInfo[Index].PhysicalBaseAddress = fdt32_to_cpu (*(UINT32 *)GicCValue);
+ GicCInfo[Index].PhysicalBaseAddress = Fdt32ToCpu (*(UINT32 *)GicCValue);
GicCInfo[Index].GICH = (GicHValue == NULL) ? 0 :
- fdt32_to_cpu (*(UINT32 *)GicHValue);
+ Fdt32ToCpu (*(UINT32 *)GicHValue);
GicCInfo[Index].GICV = (GicVValue == NULL) ? 0 :
- fdt32_to_cpu (*(UINT32 *)GicVValue);
+ Fdt32ToCpu (*(UINT32 *)GicVValue);
}
} // for
@@ -549,10 +550,10 @@ GicCv3IntcNodeParser (
}
// The "#redistributor-regions" property is optional.
- Data = fdt_getprop (Fdt, Gicv3IntcNode, "#redistributor-regions", &DataSize);
+ Data = FdtGetProp (Fdt, Gicv3IntcNode, "#redistributor-regions", &DataSize);
if ((Data != NULL) && (DataSize == sizeof (UINT32))) {
- ASSERT (fdt32_to_cpu (*(UINT32 *)Data) > 1);
- AdditionalRedistReg = fdt32_to_cpu (*(UINT32 *)Data) - 1;
+ ASSERT (Fdt32ToCpu (*(UINT32 *)Data) > 1);
+ AdditionalRedistReg = Fdt32ToCpu (*(UINT32 *)Data) - 1;
} else {
AdditionalRedistReg = 0;
}
@@ -576,7 +577,7 @@ GicCv3IntcNodeParser (
minItems: 2
maxItems: 4096
*/
- Data = fdt_getprop (Fdt, Gicv3IntcNode, "reg", &DataSize);
+ Data = FdtGetProp (Fdt, Gicv3IntcNode, "reg", &DataSize);
if ((Data == NULL) ||
(DataSize < 0) ||
((DataSize % RegSize) != 0))
@@ -644,22 +645,22 @@ GicCv3IntcNodeParser (
// GicR is discribed by the CM_ARM_GIC_REDIST_INFO object.
GicCInfo[Index].GICRBaseAddress = 0;
GicCInfo[Index].PhysicalBaseAddress = (GicCValue == NULL) ? 0 :
- fdt64_to_cpu (*(UINT64 *)GicCValue);
+ Fdt64ToCpu (*(UINT64 *)GicCValue);
GicCInfo[Index].GICH = (GicHValue == NULL) ? 0 :
- fdt64_to_cpu (*(UINT64 *)GicHValue);
+ Fdt64ToCpu (*(UINT64 *)GicHValue);
GicCInfo[Index].GICV = (GicVValue == NULL) ? 0 :
- fdt64_to_cpu (*(UINT64 *)GicVValue);
+ Fdt64ToCpu (*(UINT64 *)GicVValue);
}
} else {
for (Index = 0; Index < GicCCmObjDesc->Count; Index++) {
// GicR is discribed by the CM_ARM_GIC_REDIST_INFO object.
GicCInfo[Index].GICRBaseAddress = 0;
GicCInfo[Index].PhysicalBaseAddress = (GicCValue == NULL) ? 0 :
- fdt32_to_cpu (*(UINT32 *)GicCValue);
+ Fdt32ToCpu (*(UINT32 *)GicCValue);
GicCInfo[Index].GICH = (GicHValue == NULL) ? 0 :
- fdt32_to_cpu (*(UINT32 *)GicHValue);
+ Fdt32ToCpu (*(UINT32 *)GicHValue);
GicCInfo[Index].GICV = (GicVValue == NULL) ? 0 :
- fdt32_to_cpu (*(UINT32 *)GicVValue);
+ Fdt32ToCpu (*(UINT32 *)GicVValue);
}
}
@@ -745,7 +746,7 @@ GicCPmuNodeParser (
return Status;
}
- Data = fdt_getprop (Fdt, PmuNode, "interrupts", &DataSize);
+ Data = FdtGetProp (Fdt, PmuNode, "interrupts", &DataSize);
if ((Data == NULL) || (DataSize != (IntCells * sizeof (UINT32)))) {
// If error or not 1 interrupt.
ASSERT (Data != NULL);
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicDParser.c b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicDParser.c
index d59219f375..8788dc82a3 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicDParser.c
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicDParser.c
@@ -10,6 +10,7 @@
**/
#include <Library/BaseMemoryLib.h>
+#include <Library/FdtLib.h>
#include "CmObjectDescUtility.h"
#include "FdtHwInfoParser.h"
#include "Arm/Gic/ArmGicDispatcher.h"
@@ -64,7 +65,7 @@ GicDIntcNodeParser (
return EFI_ABORTED;
}
- Data = fdt_getprop (Fdt, GicIntcNode, "reg", &DataSize);
+ Data = FdtGetProp (Fdt, GicIntcNode, "reg", &DataSize);
if ((Data == NULL) || (DataSize < (INT32)(AddressCells * sizeof (UINT32)))) {
// If error or not enough space.
ASSERT (0);
@@ -72,9 +73,9 @@ GicDIntcNodeParser (
}
if (AddressCells == 2) {
- GicDInfo->PhysicalBaseAddress = fdt64_to_cpu (*(UINT64 *)Data);
+ GicDInfo->PhysicalBaseAddress = Fdt64ToCpu (*(UINT64 *)Data);
} else {
- GicDInfo->PhysicalBaseAddress = fdt32_to_cpu (*(UINT32 *)Data);
+ GicDInfo->PhysicalBaseAddress = Fdt32ToCpu (*(UINT32 *)Data);
}
return Status;
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicDispatcher.c b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicDispatcher.c
index ca34d24a78..d289a2e79c 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicDispatcher.c
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicDispatcher.c
@@ -9,6 +9,7 @@
- linux/Documentation/devicetree/bindings/interrupt-controller/arm,gic-v3.yaml
**/
+#include <Library/FdtLib.h>
#include "FdtHwInfoParser.h"
#include "Arm/Gic/ArmGicCParser.h"
#include "Arm/Gic/ArmGicDispatcher.h"
@@ -131,7 +132,7 @@ ArmGicDispatcher (
Fdt = FdtParserHandle->Fdt;
// The "cpus" node resides at the root of the DT. Fetch it.
- CpusNode = fdt_path_offset (Fdt, "/cpus");
+ CpusNode = FdtPathOffset (Fdt, "/cpus");
if (CpusNode < 0) {
return EFI_NOT_FOUND;
}
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicItsParser.c b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicItsParser.c
index 253c22105e..606abca5a7 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicItsParser.c
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicItsParser.c
@@ -9,6 +9,7 @@
**/
#include <Library/BaseMemoryLib.h>
+#include <Library/FdtLib.h>
#include "CmObjectDescUtility.h"
#include "FdtHwInfoParser.h"
#include "Arm/Gic/ArmGicDispatcher.h"
@@ -65,7 +66,7 @@ GicItsIntcNodeParser (
return EFI_ABORTED;
}
- Data = fdt_getprop (Fdt, GicIntcNode, "reg", &DataSize);
+ Data = FdtGetProp (Fdt, GicIntcNode, "reg", &DataSize);
if ((Data == NULL) || (DataSize < (INT32)(AddressCells * sizeof (UINT32)))) {
// If error or not enough space.
ASSERT (0);
@@ -73,9 +74,9 @@ GicItsIntcNodeParser (
}
if (AddressCells == 2) {
- GicItsInfo->PhysicalBaseAddress = fdt64_to_cpu (*(UINT64 *)Data);
+ GicItsInfo->PhysicalBaseAddress = Fdt64ToCpu (*(UINT64 *)Data);
} else {
- GicItsInfo->PhysicalBaseAddress = fdt32_to_cpu (*(UINT32 *)Data);
+ GicItsInfo->PhysicalBaseAddress = Fdt32ToCpu (*(UINT32 *)Data);
}
// Gic Its Id
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicMsiFrameParser.c b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicMsiFrameParser.c
index daadcec4e0..376fdefe51 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicMsiFrameParser.c
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicMsiFrameParser.c
@@ -10,6 +10,7 @@
**/
#include <Library/BaseMemoryLib.h>
+#include <Library/FdtLib.h>
#include "CmObjectDescUtility.h"
#include "FdtHwInfoParser.h"
#include "Arm/Gic/ArmGicDispatcher.h"
@@ -77,7 +78,7 @@ MsiFrameNodeParser (
return EFI_ABORTED;
}
- Data = fdt_getprop (Fdt, MsiFrameNode, "reg", &DataSize);
+ Data = FdtGetProp (Fdt, MsiFrameNode, "reg", &DataSize);
if ((Data == NULL) || (DataSize < (INT32)(AddressCells * sizeof (UINT32)))) {
// If error or not enough space.
ASSERT (0);
@@ -85,9 +86,9 @@ MsiFrameNodeParser (
}
if (AddressCells == 2) {
- MsiFrameInfo->PhysicalBaseAddress = fdt64_to_cpu (*(UINT64 *)Data);
+ MsiFrameInfo->PhysicalBaseAddress = Fdt64ToCpu (*(UINT64 *)Data);
} else {
- MsiFrameInfo->PhysicalBaseAddress = fdt32_to_cpu (*(UINT32 *)Data);
+ MsiFrameInfo->PhysicalBaseAddress = Fdt32ToCpu (*(UINT32 *)Data);
}
MsiFrameInfo->GicMsiFrameId = MsiFrameId;
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicRParser.c b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicRParser.c
index 1c5bc97d98..da19fd6a03 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicRParser.c
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/Gic/ArmGicRParser.c
@@ -9,6 +9,7 @@
**/
#include <Library/BaseMemoryLib.h>
+#include <Library/FdtLib.h>
#include "CmObjectDescUtility.h"
#include "FdtHwInfoParser.h"
#include "Arm/Gic/ArmGicDispatcher.h"
@@ -76,10 +77,10 @@ GicRIntcNodeParser (
// The "#redistributor-regions" property is optional.
// It indicates the number of GicR.
- Data = fdt_getprop (Fdt, GicIntcNode, "#redistributor-regions", &DataSize);
+ Data = FdtGetProp (Fdt, GicIntcNode, "#redistributor-regions", &DataSize);
if ((Data != NULL) && (DataSize == sizeof (UINT32))) {
// If available, must be on one cell.
- RedistReg = fdt32_to_cpu (*(UINT32 *)Data);
+ RedistReg = Fdt32ToCpu (*(UINT32 *)Data);
} else {
// The DT Spec says GicR is mandatory so we will
// always have one.
@@ -124,7 +125,7 @@ GicRIntcNodeParser (
}
*/
RegSize = (AddressCells + SizeCells) * sizeof (UINT32);
- Data = fdt_getprop (Fdt, GicIntcNode, "reg", &DataSize);
+ Data = FdtGetProp (Fdt, GicIntcNode, "reg", &DataSize);
if ((Data == NULL) ||
(DataSize < 0) ||
((DataSize % RegSize) != 0))
@@ -140,17 +141,17 @@ GicRIntcNodeParser (
ZeroMem (&GicRInfo, sizeof (CM_ARM_GIC_REDIST_INFO));
if (AddressCells == 2) {
- GicRInfo.DiscoveryRangeBaseAddress = fdt64_to_cpu (*(UINT64 *)Data);
+ GicRInfo.DiscoveryRangeBaseAddress = Fdt64ToCpu (*(UINT64 *)Data);
} else {
- GicRInfo.DiscoveryRangeBaseAddress = fdt32_to_cpu (*(UINT32 *)Data);
+ GicRInfo.DiscoveryRangeBaseAddress = Fdt32ToCpu (*(UINT32 *)Data);
}
Data += sizeof (UINT32) * AddressCells;
if (SizeCells == 2) {
- GicRInfo.DiscoveryRangeLength = (UINT32)fdt64_to_cpu (*(UINT64 *)Data);
+ GicRInfo.DiscoveryRangeLength = (UINT32)Fdt64ToCpu (*(UINT64 *)Data);
} else {
- GicRInfo.DiscoveryRangeLength = fdt32_to_cpu (*(UINT32 *)Data);
+ GicRInfo.DiscoveryRangeLength = Fdt32ToCpu (*(UINT32 *)Data);
}
// Add the CmObj to the Configuration Manager.
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParser.c b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParser.c
index 8e980dabe3..1bff793439 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParser.c
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParser.c
@@ -5,6 +5,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
+#include <Library/FdtLib.h>
#include "FdtHwInfoParser.h"
/** Initialise the HwInfoParser.
@@ -40,7 +41,7 @@ HwInfoParserInit (
if ((ParserHandle == NULL) ||
(HwInfoAdd == NULL) ||
(HwDataSource == NULL) ||
- (fdt_check_header (HwDataSource) < 0))
+ (FdtCheckHeader (HwDataSource) < 0))
{
ASSERT (0);
return EFI_INVALID_PARAMETER;
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserInclude.h b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserInclude.h
index 60f671eccc..80d69088c0 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserInclude.h
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserInclude.h
@@ -9,7 +9,6 @@
#define FDT_HW_INFO_PARSER_INCLUDE_H_
#include <Base.h>
-#include <libfdt.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.c b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.c
index 9d8bd3e7fb..f734fbffa7 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.c
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.c
@@ -11,6 +11,7 @@
**/
#include <Library/BaseLib.h>
+#include <Library/FdtLib.h>
#include <FdtHwInfoParserInclude.h>
#include "FdtUtility.h"
@@ -47,7 +48,7 @@ FdtNodeHasName (
Length = (UINT32)AsciiStrLen (SearchName);
// Get the address of the node name.
- NodeName = fdt_offset_ptr (Fdt, Node + FDT_TAGSIZE, Length + 1);
+ NodeName = FdtOffsetPointer (Fdt, Node + FDT_TAGSIZE, Length + 1);
if (NodeName == NULL) {
return FALSE;
}
@@ -110,13 +111,13 @@ FdtNodeIsCompatible (
CompatibleTable = ((COMPATIBILITY_INFO *)CompatInfo)->CompatTable;
// Get the "compatible" property.
- Prop = fdt_getprop (Fdt, Node, "compatible", &PropLen);
+ Prop = FdtGetProp (Fdt, Node, "compatible", &PropLen);
if ((Prop == NULL) || (PropLen < 0)) {
return FALSE;
}
for (Index = 0; Index < Count; Index++) {
- if (fdt_stringlist_contains (
+ if (FdtStringListContains (
Prop,
PropLen,
CompatibleTable[Index].CompatStr
@@ -157,7 +158,7 @@ FdtNodeHasProperty (
return FALSE;
}
- Prop = fdt_getprop (Fdt, Node, PropertyName, &Size);
+ Prop = FdtGetProp (Fdt, Node, PropertyName, &Size);
if ((Prop == NULL) || (Size < 0)) {
return FALSE;
}
@@ -218,7 +219,7 @@ FdtGetNextCondNode (
CurrNode = *Node;
do {
- CurrNode = fdt_next_node (Fdt, CurrNode, Depth);
+ CurrNode = FdtNextNode (Fdt, CurrNode, Depth);
if ((CurrNode == -FDT_ERR_NOTFOUND) ||
(*Depth < 0))
{
@@ -292,9 +293,9 @@ FdtGetNextCondNodeInBranch (
// First, check the Node is in the sub-nodes of the branch.
// This allows to find the relative depth of Node in the branch.
if (CurrNode != *Node) {
- for (CurrNode = fdt_next_node (Fdt, CurrNode, &Depth);
+ for (CurrNode = FdtNextNode (Fdt, CurrNode, &Depth);
(CurrNode >= 0) && (Depth > 0);
- CurrNode = fdt_next_node (Fdt, CurrNode, &Depth))
+ CurrNode = FdtNextNode (Fdt, CurrNode, &Depth))
{
if (CurrNode == *Node) {
// Node found.
@@ -666,18 +667,18 @@ FdtGetIntcParentNode (
while (TRUE) {
// Check whether the node has the "interrupt-controller" property.
- Prop = fdt_getprop (Fdt, Node, "interrupt-controller", &Size);
+ Prop = FdtGetProp (Fdt, Node, "interrupt-controller", &Size);
if ((Prop != NULL) && (Size >= 0)) {
// The interrupt-controller has been found.
*IntcNode = Node;
return EFI_SUCCESS;
} else {
// Check whether the node has the "interrupt-parent" property.
- PHandle = fdt_getprop (Fdt, Node, "interrupt-parent", &Size);
+ PHandle = FdtGetProp (Fdt, Node, "interrupt-parent", &Size);
if ((PHandle != NULL) && (Size == sizeof (UINT32))) {
// The phandle of the interrupt-controller has been found.
// Search the node having this phandle and return it.
- Node = fdt_node_offset_by_phandle (Fdt, fdt32_to_cpu (*PHandle));
+ Node = FdtNodeOffsetByPhandle (Fdt, Fdt32ToCpu (*PHandle));
if (Node < 0) {
ASSERT (0);
return EFI_ABORTED;
@@ -697,7 +698,7 @@ FdtGetIntcParentNode (
}
// Get the parent of the node.
- Node = fdt_parent_offset (Fdt, Node);
+ Node = FdtParentOffset (Fdt, Node);
if (Node < 0) {
// An error occurred.
ASSERT (0);
@@ -739,14 +740,14 @@ FdtGetInterruptCellsInfo (
return EFI_INVALID_PARAMETER;
}
- Data = fdt_getprop (Fdt, IntcNode, "#interrupt-cells", &Size);
+ Data = FdtGetProp (Fdt, IntcNode, "#interrupt-cells", &Size);
if ((Data == NULL) || (Size != sizeof (UINT32))) {
// If error or not on one UINT32 cell.
ASSERT (0);
return EFI_ABORTED;
}
- *IntCells = fdt32_to_cpu (*Data);
+ *IntCells = Fdt32ToCpu (*Data);
return EFI_SUCCESS;
}
@@ -788,7 +789,7 @@ FdtGetAddressInfo (
}
if (AddressCells != NULL) {
- *AddressCells = fdt_address_cells (Fdt, Node);
+ *AddressCells = FdtAddressCells (Fdt, Node);
if (*AddressCells < 0) {
ASSERT (0);
return EFI_ABORTED;
@@ -796,7 +797,7 @@ FdtGetAddressInfo (
}
if (SizeCells != NULL) {
- *SizeCells = fdt_size_cells (Fdt, Node);
+ *SizeCells = FdtSizeCells (Fdt, Node);
if (*SizeCells < 0) {
ASSERT (0);
return EFI_ABORTED;
@@ -842,7 +843,7 @@ FdtGetParentAddressInfo (
return EFI_INVALID_PARAMETER;
}
- Node = fdt_parent_offset (Fdt, Node);
+ Node = FdtParentOffset (Fdt, Node);
if (Node < 0) {
// End of the tree, or an error occurred.
ASSERT (0);
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/PciConfigSpaceParser.c b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/PciConfigSpaceParser.c
index 466538ebc8..f7b8dc98f6 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/PciConfigSpaceParser.c
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Pci/PciConfigSpaceParser.c
@@ -15,6 +15,7 @@
#include "CmObjectDescUtility.h"
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
+#include <Library/FdtLib.h>
#include "FdtHwInfoParser.h"
#include "Pci/PciConfigSpaceParser.h"
@@ -72,7 +73,7 @@ GetPciSegGroup (
return EFI_INVALID_PARAMETER;
}
- Data = fdt_getprop (Fdt, HostPciNode, "linux,pci-domain", &DataSize);
+ Data = FdtGetProp (Fdt, HostPciNode, "linux,pci-domain", &DataSize);
if ((Data == NULL) || (DataSize < 0)) {
// Did not find property, assign the DomainIds ourselves.
if (LocalSegGroup < 0) {
@@ -98,7 +99,7 @@ GetPciSegGroup (
// nodes must have it.
LocalSegGroup = -1;
- *SegGroup = fdt32_to_cpu (*(UINT32 *)Data);
+ *SegGroup = Fdt32ToCpu (*(UINT32 *)Data);
return EFI_SUCCESS;
}
@@ -134,15 +135,15 @@ PopulateBusRange (
return EFI_INVALID_PARAMETER;
}
- Data = fdt_getprop (Fdt, HostPciNode, "bus-range", &DataSize);
+ Data = FdtGetProp (Fdt, HostPciNode, "bus-range", &DataSize);
if ((Data == NULL) || (DataSize < 0)) {
// No evidence this property is mandatory. Use default values.
StartBus = 0;
EndBus = 255;
} else if (DataSize == (2 * sizeof (UINT32))) {
// If available, the property is on two integers.
- StartBus = fdt32_to_cpu (((UINT32 *)Data)[0]);
- EndBus = fdt32_to_cpu (((UINT32 *)Data)[1]);
+ StartBus = Fdt32ToCpu (((UINT32 *)Data)[0]);
+ EndBus = Fdt32ToCpu (((UINT32 *)Data)[1]);
} else {
ASSERT (0);
return EFI_ABORTED;
@@ -195,7 +196,7 @@ ParseAddressMap (
AddressMapSize = (PCI_ADDRESS_CELLS + AddressCells + PCI_SIZE_CELLS) *
sizeof (UINT32);
- Data = fdt_getprop (Fdt, HostPciNode, "ranges", &DataSize);
+ Data = FdtGetProp (Fdt, HostPciNode, "ranges", &DataSize);
if ((Data == NULL) ||
(DataSize < 0) ||
((DataSize % AddressMapSize) != 0))
@@ -219,29 +220,29 @@ ParseAddressMap (
Offset = Index * AddressMapSize;
// Pci address attributes
- PciAddressAttr = fdt32_to_cpu (*(UINT32 *)&Data[Offset]);
+ PciAddressAttr = Fdt32ToCpu (*(UINT32 *)&Data[Offset]);
PciAddressMapInfo[Index].SpaceCode = READ_PCI_SS (PciAddressAttr);
Offset += sizeof (UINT32);
// Pci address
PciAddressMapInfo[Index].PciAddress =
- fdt64_to_cpu (*(UINT64 *)&Data[Offset]);
+ Fdt64ToCpu (*(UINT64 *)&Data[Offset]);
Offset += (PCI_ADDRESS_CELLS - 1) * sizeof (UINT32);
// Cpu address
if (AddressCells == 2) {
PciAddressMapInfo[Index].CpuAddress =
- fdt64_to_cpu (*(UINT64 *)&Data[Offset]);
+ Fdt64ToCpu (*(UINT64 *)&Data[Offset]);
} else {
PciAddressMapInfo[Index].CpuAddress =
- fdt32_to_cpu (*(UINT32 *)&Data[Offset]);
+ Fdt32ToCpu (*(UINT32 *)&Data[Offset]);
}
Offset += AddressCells * sizeof (UINT32);
// Address size
PciAddressMapInfo[Index].AddressSize =
- fdt64_to_cpu (*(UINT64 *)&Data[Offset]);
+ Fdt64ToCpu (*(UINT64 *)&Data[Offset]);
Offset += PCI_SIZE_CELLS * sizeof (UINT32);
} // for
@@ -313,7 +314,7 @@ ParseIrqMap (
CM_ARCH_COMMON_PCI_INTERRUPT_MAP_INFO *PciInterruptMapInfo;
UINT32 BufferSize;
- Data = fdt_getprop (Fdt, HostPciNode, "interrupt-map", &DataSize);
+ Data = FdtGetProp (Fdt, HostPciNode, "interrupt-map", &DataSize);
if ((Data == NULL) || (DataSize <= 0)) {
DEBUG ((
DEBUG_WARN,
@@ -337,7 +338,7 @@ ParseIrqMap (
return EFI_ABORTED;
}
- IrqMapMask = fdt_getprop (
+ IrqMapMask = FdtGetProp (
Fdt,
HostPciNode,
"interrupt-map-mask",
@@ -358,8 +359,8 @@ ParseIrqMap (
return EFI_ABORTED;
}
- IntcPhandle = fdt32_to_cpu (*(UINT32 *)&Data[PHandleOffset]);
- IntcNode = fdt_node_offset_by_phandle (Fdt, IntcPhandle);
+ IntcPhandle = Fdt32ToCpu (*(UINT32 *)&Data[PHandleOffset]);
+ IntcNode = FdtNodeOffsetByPhandle (Fdt, IntcPhandle);
if (IntcNode < 0) {
ASSERT (0);
return EFI_ABORTED;
@@ -394,7 +395,7 @@ ParseIrqMap (
// We assume the same interrupt-controller is used for all the mappings.
// Check this is correct.
for (Index = 0; Index < IrqMapCount; Index++) {
- if (IntcPhandle != fdt32_to_cpu (
+ if (IntcPhandle != Fdt32ToCpu (
*(UINT32 *)&Data[(Index * IrqMapSize) + PHandleOffset]
))
{
@@ -416,7 +417,7 @@ ParseIrqMap (
Offset = Index * IrqMapSize;
// Pci address attributes
- PciAddressAttr = fdt32_to_cpu (
+ PciAddressAttr = Fdt32ToCpu (
(*(UINT32 *)&Data[Offset]) &
(*(UINT32 *)&IrqMapMask[0])
);
@@ -425,7 +426,7 @@ ParseIrqMap (
Offset += PCI_ADDRESS_CELLS * sizeof (UINT32);
// Pci irq
- PciInterruptMapInfo[Index].PciInterrupt = fdt32_to_cpu (
+ PciInterruptMapInfo[Index].PciInterrupt = Fdt32ToCpu (
(*(UINT32 *)&Data[Offset]) &
(*(UINT32 *)&IrqMapMask[3 * sizeof (UINT32)])
);
@@ -527,7 +528,7 @@ PciNodeParser (
return EFI_ABORTED;
}
- Data = fdt_getprop (Fdt, HostPciNode, "reg", &DataSize);
+ Data = FdtGetProp (Fdt, HostPciNode, "reg", &DataSize);
if ((Data == NULL) ||
(DataSize != ((AddressCells + SizeCells) * sizeof (UINT32))))
{
@@ -538,9 +539,9 @@ PciNodeParser (
// Base address
if (AddressCells == 2) {
- PciInfo->PciConfigSpaceInfo.BaseAddress = fdt64_to_cpu (*(UINT64 *)Data);
+ PciInfo->PciConfigSpaceInfo.BaseAddress = Fdt64ToCpu (*(UINT64 *)Data);
} else {
- PciInfo->PciConfigSpaceInfo.BaseAddress = fdt32_to_cpu (*(UINT32 *)Data);
+ PciInfo->PciConfigSpaceInfo.BaseAddress = Fdt32ToCpu (*(UINT32 *)Data);
}
// Address map
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Serial/SerialPortParser.c b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Serial/SerialPortParser.c
index 34659001c3..8a25d5b3f9 100644
--- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Serial/SerialPortParser.c
+++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Serial/SerialPortParser.c
@@ -14,6 +14,7 @@
#include <IndustryStandard/DebugPort2Table.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
+#include <Library/FdtLib.h>
#include "CmObjectDescUtility.h"
#include "FdtHwInfoParser.h"
@@ -129,7 +130,7 @@ SerialPortNodeParser (
return EFI_ABORTED;
}
- Data = fdt_getprop (Fdt, SerialPortNode, "reg", &DataSize);
+ Data = FdtGetProp (Fdt, SerialPortNode, "reg", &DataSize);
if ((Data == NULL) ||
(DataSize < (INT32)(sizeof (UINT32) *
GET_DT_REG_ADDRESS_OFFSET (1, AddressCells, SizeCells)) - 1))
@@ -140,17 +141,17 @@ SerialPortNodeParser (
}
if (AddressCells == 2) {
- SerialPortInfo->BaseAddress = fdt64_to_cpu (*(UINT64 *)Data);
+ SerialPortInfo->BaseAddress = Fdt64ToCpu (*(UINT64 *)Data);
} else {
- SerialPortInfo->BaseAddress = fdt32_to_cpu (*(UINT32 *)Data);
+ SerialPortInfo->BaseAddress = Fdt32ToCpu (*(UINT32 *)Data);
}
SizeValue = Data + (sizeof (UINT32) *
GET_DT_REG_SIZE_OFFSET (0, AddressCells, SizeCells));
if (SizeCells == 2) {
- SerialPortInfo->BaseAddressLength = fdt64_to_cpu (*(UINT64 *)SizeValue);
+ SerialPortInfo->BaseAddressLength = Fdt64ToCpu (*(UINT64 *)SizeValue);
} else {
- SerialPortInfo->BaseAddressLength = fdt32_to_cpu (*(UINT32 *)SizeValue);
+ SerialPortInfo->BaseAddressLength = Fdt32ToCpu (*(UINT32 *)SizeValue);
}
// Get the associated interrupt-controller.
@@ -172,7 +173,7 @@ SerialPortNodeParser (
return Status;
}
- Data = fdt_getprop (Fdt, SerialPortNode, "interrupts", &DataSize);
+ Data = FdtGetProp (Fdt, SerialPortNode, "interrupts", &DataSize);
if ((Data == NULL) || (DataSize != (IntCells * sizeof (UINT32)))) {
// If error or not 1 interrupt.
ASSERT (0);
@@ -182,20 +183,20 @@ SerialPortNodeParser (
SerialPortInfo->Interrupt = FdtGetInterruptId ((CONST UINT32 *)Data);
// Note: clock-frequency is optional for SBSA UART.
- Data = fdt_getprop (Fdt, SerialPortNode, "clock-frequency", &DataSize);
+ Data = FdtGetProp (Fdt, SerialPortNode, "clock-frequency", &DataSize);
if (Data != NULL) {
if (DataSize < sizeof (UINT32)) {
// If error or not enough space.
ASSERT (0);
return EFI_ABORTED;
- } else if (fdt_node_offset_by_phandle (Fdt, fdt32_to_cpu (*Data)) >= 0) {
+ } else if (FdtNodeOffsetByPhandle (Fdt, Fdt32ToCpu (*Data)) >= 0) {
// "clock-frequency" can be a "clocks phandle to refer to the clk used".
// This is not supported.
ASSERT (0);
return EFI_UNSUPPORTED;
}
- SerialPortInfo->Clock = fdt32_to_cpu (*(UINT32 *)Data);
+ SerialPortInfo->Clock = Fdt32ToCpu (*(UINT32 *)Data);
}
if (FdtNodeIsCompatible (Fdt, SerialPortNode, &Serial16550CompatibleInfo)) {
@@ -208,7 +209,7 @@ SerialPortNodeParser (
device. There are some systems that require 32-bit accesses to the
UART.
*/
- Data = fdt_getprop (Fdt, SerialPortNode, "reg-io-width", &DataSize);
+ Data = FdtGetProp (Fdt, SerialPortNode, "reg-io-width", &DataSize);
if (Data != NULL) {
if (DataSize < sizeof (UINT32)) {
// If error or not enough space.
@@ -216,7 +217,7 @@ SerialPortNodeParser (
return EFI_ABORTED;
}
- AccessSize = fdt32_to_cpu (*(UINT32 *)Data);
+ AccessSize = Fdt32ToCpu (*(UINT32 *)Data);
if (AccessSize > EFI_ACPI_6_3_QWORD) {
ASSERT (0);
return EFI_INVALID_PARAMETER;
@@ -281,12 +282,12 @@ GetSerialConsoleNode (
}
// The "chosen" node resides at the root of the DT. Fetch it.
- ChosenNode = fdt_path_offset (Fdt, "/chosen");
+ ChosenNode = FdtPathOffset (Fdt, "/chosen");
if (ChosenNode < 0) {
return EFI_NOT_FOUND;
}
- Prop = fdt_getprop (Fdt, ChosenNode, "stdout-path", &PropSize);
+ Prop = FdtGetProp (Fdt, ChosenNode, "stdout-path", &PropSize);
if ((Prop == NULL) || (PropSize < 0)) {
return EFI_NOT_FOUND;
}
@@ -301,17 +302,17 @@ GetSerialConsoleNode (
// Aliases cannot start with a '/', so it must be the actual path.
if (Prop[0] == '/') {
- *SerialConsoleNode = fdt_path_offset_namelen (Fdt, Prop, PathLen);
+ *SerialConsoleNode = FdtPathOffsetNameLen (Fdt, Prop, PathLen);
return EFI_SUCCESS;
}
// Lookup the alias, as this contains the actual path.
- Path = fdt_get_alias_namelen (Fdt, Prop, PathLen);
+ Path = FdtGetAliasNameLen (Fdt, Prop, PathLen);
if (Path == NULL) {
return EFI_NOT_FOUND;
}
- *SerialConsoleNode = fdt_path_offset (Fdt, Path);
+ *SerialConsoleNode = FdtPathOffset (Fdt, Path);
return EFI_SUCCESS;
}