ArmVirtPkg,DynamicTablesPkg,EmbeddedPkg,OvmfPkg: use MdePkg BaseFdtLib

Migrate these packages to use the up-to-date BaseFdtLib instead
of the EmbeddedPkg relic that is going away.

Continuous-integration-options: PatchCheck.ignore-multi-package
Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
This commit is contained in:
Leif Lindholm 2024-09-26 19:22:06 +01:00 committed by mergify[bot]
parent 37652b830e
commit 8aad683e59
37 changed files with 252 additions and 237 deletions

View file

@ -132,7 +132,7 @@
DebugAgentTimerLib|EmbeddedPkg/Library/DebugAgentTimerLibNull/DebugAgentTimerLibNull.inf
# Flattened Device Tree (FDT) access library
FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf
FdtLib|MdePkg/Library/BaseFdtLib/BaseFdtLib.inf
# PCI Libraries
PciLib|MdePkg/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf

View file

@ -9,10 +9,10 @@
#include <PiPei.h>
#include <Base.h>
#include <libfdt.h>
#include <Library/ArmLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/FdtLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PcdLib.h>
@ -68,7 +68,7 @@ CloudHvVirtMemInfoPeiLibConstructor (
//
// Make sure we have a valid device tree blob
//
if (fdt_check_header (DeviceTreeBase) != 0) {
if (FdtCheckHeader (DeviceTreeBase) != 0) {
return EFI_NOT_FOUND;
}
@ -76,7 +76,7 @@ CloudHvVirtMemInfoPeiLibConstructor (
// Look for the lowest memory node
//
for (Prev = 0; ; Prev = Node) {
Node = fdt_next_node (DeviceTreeBase, Prev, NULL);
Node = FdtNextNode (DeviceTreeBase, Prev, NULL);
if (Node < 0) {
break;
}
@ -84,16 +84,16 @@ CloudHvVirtMemInfoPeiLibConstructor (
//
// Check for memory node
//
Type = fdt_getprop (DeviceTreeBase, Node, "device_type", &Len);
Type = FdtGetProp (DeviceTreeBase, Node, "device_type", &Len);
if ((Type != 0) && (AsciiStrnCmp (Type, "memory", Len) == 0)) {
//
// Get the 'reg' property of this node. For now, we will assume
// two 8 byte quantities for base and size, respectively.
//
RegProp = fdt_getprop (DeviceTreeBase, Node, "reg", &Len);
RegProp = FdtGetProp (DeviceTreeBase, Node, "reg", &Len);
if ((RegProp != 0) && (Len == (2 * sizeof (UINT64)))) {
CurBase = fdt64_to_cpu (ReadUnaligned64 (RegProp));
CurSize = fdt64_to_cpu (ReadUnaligned64 (RegProp + 1));
CurBase = Fdt64ToCpu (ReadUnaligned64 (RegProp));
CurSize = Fdt64ToCpu (ReadUnaligned64 (RegProp + 1));
DEBUG ((
DEBUG_INFO,

View file

@ -14,10 +14,10 @@
#include <Library/MemoryAllocationLib.h>
#include <Library/DebugLib.h>
#include <Library/FdtLib.h>
#include <Library/HobLib.h>
#include <Library/PcdLib.h>
#include <Library/PeiServicesLib.h>
#include <libfdt.h>
/** Initialise Platform HOBs
@ -39,12 +39,12 @@ PlatformPeim (
UINT64 *UartHobData;
Base = (VOID *)(UINTN)PcdGet64 (PcdDeviceTreeInitialBaseAddress);
if ((Base == NULL) || (fdt_check_header (Base) != 0)) {
if ((Base == NULL) || (FdtCheckHeader (Base) != 0)) {
ASSERT (0);
return EFI_INVALID_PARAMETER;
}
FdtSize = fdt_totalsize (Base) + PcdGet32 (PcdDeviceTreeAllocationPadding);
FdtSize = FdtTotalSize (Base) + PcdGet32 (PcdDeviceTreeAllocationPadding);
FdtPages = EFI_SIZE_TO_PAGES (FdtSize);
NewBase = AllocatePages (FdtPages);
if (NewBase == NULL) {
@ -52,7 +52,7 @@ PlatformPeim (
return EFI_OUT_OF_RESOURCES;
}
fdt_open_into (Base, NewBase, EFI_PAGES_TO_SIZE (FdtPages));
FdtOpenInto (Base, NewBase, EFI_PAGES_TO_SIZE (FdtPages));
FdtHobData = BuildGuidHob (&gFdtHobGuid, sizeof (*FdtHobData));
if (FdtHobData == NULL) {

View file

@ -12,11 +12,11 @@
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/DebugLib.h>
#include <Library/FdtLib.h>
#include <Library/HobLib.h>
#include <Library/PcdLib.h>
#include <Library/PeiServicesLib.h>
#include <Library/FdtSerialPortAddressLib.h>
#include <libfdt.h>
#include <Guid/EarlyPL011BaseAddress.h>
#include <Guid/FdtHob.h>
@ -59,13 +59,13 @@ PlatformPeim (
Base = (VOID *)(UINTN)PcdGet64 (PcdDeviceTreeInitialBaseAddress);
ASSERT (Base != NULL);
ASSERT (fdt_check_header (Base) == 0);
ASSERT (FdtCheckHeader (Base) == 0);
FdtSize = fdt_totalsize (Base) + PcdGet32 (PcdDeviceTreeAllocationPadding);
FdtSize = FdtTotalSize (Base) + PcdGet32 (PcdDeviceTreeAllocationPadding);
FdtPages = EFI_SIZE_TO_PAGES (FdtSize);
NewBase = AllocatePages (FdtPages);
ASSERT (NewBase != NULL);
fdt_open_into (Base, NewBase, EFI_PAGES_TO_SIZE (FdtPages));
FdtOpenInto (Base, NewBase, EFI_PAGES_TO_SIZE (FdtPages));
FdtHobData = BuildGuidHob (&gFdtHobGuid, sizeof *FdtHobData);
ASSERT (FdtHobData != NULL);
@ -132,7 +132,7 @@ PlatformPeim (
Parent = 0;
for (Prev = Depth = 0; ; Prev = Node) {
Node = fdt_next_node (Base, Prev, &Depth);
Node = FdtNextNode (Base, Prev, &Depth);
if (Node < 0) {
break;
}
@ -141,7 +141,7 @@ PlatformPeim (
Parent = Node;
}
Compatible = fdt_getprop (Base, Node, "compatible", &Len);
Compatible = FdtGetProp (Base, Node, "compatible", &Len);
//
// Iterate over the NULL-separated items in the compatible string
@ -152,12 +152,12 @@ PlatformPeim (
if (FeaturePcdGet (PcdTpm2SupportEnabled) &&
(AsciiStrCmp (CompItem, "tcg,tpm-tis-mmio") == 0))
{
RegProp = fdt_getprop (Base, Node, "reg", &Len);
RegProp = FdtGetProp (Base, Node, "reg", &Len);
ASSERT (Len == 8 || Len == 16);
if (Len == 8) {
TpmBase = fdt32_to_cpu (RegProp[0]);
TpmBase = Fdt32ToCpu (RegProp[0]);
} else if (Len == 16) {
TpmBase = fdt64_to_cpu (ReadUnaligned64 ((UINT64 *)RegProp));
TpmBase = Fdt64ToCpu (ReadUnaligned64 ((UINT64 *)RegProp));
}
if (Depth > 1) {
@ -168,7 +168,7 @@ PlatformPeim (
// tuple, where the child base and the size use the same number of
// cells as the 'reg' property above, and the parent base uses 2 cells
//
RangesProp = fdt_getprop (Base, Parent, "ranges", &RangesLen);
RangesProp = FdtGetProp (Base, Parent, "ranges", &RangesLen);
ASSERT (RangesProp != NULL);
//
@ -189,16 +189,16 @@ PlatformPeim (
}
if (Len == 8) {
TpmBase -= fdt32_to_cpu (RangesProp[0]);
TpmBase -= Fdt32ToCpu (RangesProp[0]);
} else {
TpmBase -= fdt64_to_cpu (ReadUnaligned64 ((UINT64 *)RangesProp));
TpmBase -= Fdt64ToCpu (ReadUnaligned64 ((UINT64 *)RangesProp));
}
//
// advance RangesProp to the parent bus address
//
RangesProp = (UINT32 *)((UINT8 *)RangesProp + Len / 2);
TpmBase += fdt64_to_cpu (ReadUnaligned64 ((UINT64 *)RangesProp));
TpmBase += Fdt64ToCpu (ReadUnaligned64 ((UINT64 *)RangesProp));
}
}

View file

@ -10,8 +10,8 @@
#include <Pi/PiMultiPhase.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/FdtLib.h>
#include <Library/HobLib.h>
#include <libfdt.h>
RETURN_STATUS
EFIAPI
@ -37,13 +37,13 @@ QemuVirtMemInfoPeiLibConstructor (
//
// Make sure we have a valid device tree blob
//
ASSERT (fdt_check_header (DeviceTreeBase) == 0);
ASSERT (FdtCheckHeader (DeviceTreeBase) == 0);
//
// Look for the lowest memory node
//
for (Prev = 0; ; Prev = Node) {
Node = fdt_next_node (DeviceTreeBase, Prev, NULL);
Node = FdtNextNode (DeviceTreeBase, Prev, NULL);
if (Node < 0) {
break;
}
@ -51,16 +51,16 @@ QemuVirtMemInfoPeiLibConstructor (
//
// Check for memory node
//
Type = fdt_getprop (DeviceTreeBase, Node, "device_type", &Len);
Type = FdtGetProp (DeviceTreeBase, Node, "device_type", &Len);
if (Type && (AsciiStrnCmp (Type, "memory", Len) == 0)) {
//
// Get the 'reg' property of this node. For now, we will assume
// two 8 byte quantities for base and size, respectively.
//
RegProp = fdt_getprop (DeviceTreeBase, Node, "reg", &Len);
RegProp = FdtGetProp (DeviceTreeBase, Node, "reg", &Len);
if ((RegProp != 0) && (Len == (2 * sizeof (UINT64)))) {
CurBase = fdt64_to_cpu (ReadUnaligned64 (RegProp));
CurSize = fdt64_to_cpu (ReadUnaligned64 (RegProp + 1));
CurBase = Fdt64ToCpu (ReadUnaligned64 (RegProp));
CurSize = Fdt64ToCpu (ReadUnaligned64 (RegProp + 1));
DEBUG ((
DEBUG_INFO,

View file

@ -39,6 +39,7 @@
[LibraryClasses]
BaseLib
BaseMemoryLib
DebugLib
FdtLib
ArmLib

View file

@ -5,7 +5,8 @@
*/
#include <Uefi.h>
#include <Include/libfdt.h>
#include <Library/BaseMemoryLib.h>
#include <Library/FdtLib.h>
BOOLEAN
FindMemnode (
@ -20,14 +21,14 @@ FindMemnode (
INT32 Length;
CONST INT32 *Prop;
if (fdt_check_header (DeviceTreeBlob) != 0) {
if (FdtCheckHeader (DeviceTreeBlob) != 0) {
return FALSE;
}
//
// Look for a node called "memory" at the lowest level of the tree
//
MemoryNode = fdt_path_offset (DeviceTreeBlob, "/memory");
MemoryNode = FdtPathOffset (DeviceTreeBlob, "/memory");
if (MemoryNode <= 0) {
return FALSE;
}
@ -39,36 +40,36 @@ FindMemnode (
AddressCells = 1;
SizeCells = 1;
Prop = fdt_getprop (DeviceTreeBlob, 0, "#address-cells", &Length);
Prop = FdtGetProp (DeviceTreeBlob, 0, "#address-cells", &Length);
if (Length == 4) {
AddressCells = fdt32_to_cpu (*Prop);
AddressCells = Fdt32ToCpu (*Prop);
}
Prop = fdt_getprop (DeviceTreeBlob, 0, "#size-cells", &Length);
Prop = FdtGetProp (DeviceTreeBlob, 0, "#size-cells", &Length);
if (Length == 4) {
SizeCells = fdt32_to_cpu (*Prop);
SizeCells = Fdt32ToCpu (*Prop);
}
//
// Now find the 'reg' property of the /memory node, and read the first
// range listed.
//
Prop = fdt_getprop (DeviceTreeBlob, MemoryNode, "reg", &Length);
Prop = FdtGetProp (DeviceTreeBlob, MemoryNode, "reg", &Length);
if (Length < (AddressCells + SizeCells) * sizeof (INT32)) {
return FALSE;
}
*SystemMemoryBase = fdt32_to_cpu (Prop[0]);
*SystemMemoryBase = Fdt32ToCpu (Prop[0]);
if (AddressCells > 1) {
*SystemMemoryBase = (*SystemMemoryBase << 32) | fdt32_to_cpu (Prop[1]);
*SystemMemoryBase = (*SystemMemoryBase << 32) | Fdt32ToCpu (Prop[1]);
}
Prop += AddressCells;
*SystemMemorySize = fdt32_to_cpu (Prop[0]);
*SystemMemorySize = Fdt32ToCpu (Prop[0]);
if (SizeCells > 1) {
*SystemMemorySize = (*SystemMemorySize << 32) | fdt32_to_cpu (Prop[1]);
*SystemMemorySize = (*SystemMemorySize << 32) | Fdt32ToCpu (Prop[1]);
}
return TRUE;
@ -80,6 +81,6 @@ CopyFdt (
IN VOID *FdtSource
)
{
fdt_pack (FdtSource);
CopyMem (FdtDest, FdtSource, fdt_totalsize (FdtSource));
FdtPack (FdtSource);
CopyMem (FdtDest, FdtSource, FdtTotalSize (FdtSource));
}

View file

@ -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;
}

View file

@ -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;

View file

@ -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;

View file

@ -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))))
{

View file

@ -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);

View file

@ -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;

View file

@ -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;
}

View file

@ -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

View file

@ -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;

View file

@ -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.

View file

@ -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;

View file

@ -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>

View file

@ -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);

View file

@ -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

View file

@ -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;
}

View file

@ -8,11 +8,11 @@
#include <Uefi.h>
#include <IndustryStandard/Acpi.h>
#include <libfdt.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/DevicePathLib.h>
#include <Library/FdtLib.h>
#include <Library/HiiLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiBootServicesTableLib.h>
@ -123,18 +123,18 @@ RemoveDtStdoutPath (
return;
}
Node = fdt_path_offset (Dtb, "/chosen");
Node = FdtPathOffset (Dtb, "/chosen");
if (Node < 0) {
return;
}
Error = fdt_delprop (Dtb, Node, "stdout-path");
Error = FdtDelProp (Dtb, Node, "stdout-path");
if (Error) {
DEBUG ((
DEBUG_INFO,
"%a: Failed to delete 'stdout-path' property: %a\n",
__func__,
fdt_strerror (Error)
FdtStrerror (Error)
));
}
}

View file

@ -9,10 +9,10 @@
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/FdtLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/HobLib.h>
#include <libfdt.h>
#include <Guid/Fdt.h>
#include <Guid/FdtHob.h>
@ -38,7 +38,7 @@ GetNodeProperty (
ASSERT (mDeviceTreeBase != NULL);
ASSERT (Prop != NULL);
*Prop = fdt_getprop (mDeviceTreeBase, Node, PropertyName, &Len);
*Prop = FdtGetProp (mDeviceTreeBase, Node, PropertyName, &Len);
if (*Prop == NULL) {
return EFI_NOT_FOUND;
}
@ -65,7 +65,7 @@ SetNodeProperty (
ASSERT (mDeviceTreeBase != NULL);
Ret = fdt_setprop (mDeviceTreeBase, Node, PropertyName, Prop, PropSize);
Ret = FdtSetProp (mDeviceTreeBase, Node, PropertyName, Prop, PropSize);
if (Ret != 0) {
return EFI_DEVICE_ERROR;
}
@ -87,7 +87,7 @@ IsNodeEnabled (
// may occur here. If the status property is present, check whether
// it is set to 'ok' or 'okay', anything else is treated as 'disabled'.
//
NodeStatus = fdt_getprop (mDeviceTreeBase, Node, "status", &Len);
NodeStatus = FdtGetProp (mDeviceTreeBase, Node, "status", &Len);
if (NodeStatus == NULL) {
return TRUE;
}
@ -121,7 +121,7 @@ FindNextCompatibleNode (
ASSERT (Node != NULL);
for (Prev = PrevNode; ; Prev = Next) {
Next = fdt_next_node (mDeviceTreeBase, Prev, NULL);
Next = FdtNextNode (mDeviceTreeBase, Prev, NULL);
if (Next < 0) {
break;
}
@ -130,7 +130,7 @@ FindNextCompatibleNode (
continue;
}
Type = fdt_getprop (mDeviceTreeBase, Next, "compatible", &Len);
Type = FdtGetProp (mDeviceTreeBase, Next, "compatible", &Len);
if (Type == NULL) {
continue;
}
@ -257,12 +257,12 @@ FindNextMemoryNodeReg (
ASSERT (Node != NULL);
for (Prev = PrevNode; ; Prev = Next) {
Next = fdt_next_node (mDeviceTreeBase, Prev, NULL);
Next = FdtNextNode (mDeviceTreeBase, Prev, NULL);
if (Next < 0) {
break;
}
DeviceType = fdt_getprop (mDeviceTreeBase, Next, "device_type", &Len);
DeviceType = FdtGetProp (mDeviceTreeBase, Next, "device_type", &Len);
if ((DeviceType == NULL) || (AsciiStrCmp (DeviceType, "memory") != 0)) {
continue;
}
@ -342,9 +342,9 @@ GetOrInsertChosenNode (
ASSERT (mDeviceTreeBase != NULL);
ASSERT (Node != NULL);
NewNode = fdt_path_offset (mDeviceTreeBase, "/chosen");
NewNode = FdtPathOffset (mDeviceTreeBase, "/chosen");
if (NewNode < 0) {
NewNode = fdt_add_subnode (mDeviceTreeBase, 0, "/chosen");
NewNode = FdtAddSubnode (mDeviceTreeBase, 0, "/chosen");
}
if (NewNode < 0) {
@ -422,7 +422,7 @@ InitializeFdtClientDxe (
DeviceTreeBase = (VOID *)(UINTN)*(UINT64 *)GET_GUID_HOB_DATA (Hob);
if (fdt_check_header (DeviceTreeBase) != 0) {
if (FdtCheckHeader (DeviceTreeBase) != 0) {
DEBUG ((
DEBUG_ERROR,
"%a: No DTB found @ 0x%p\n",

View file

@ -90,7 +90,7 @@
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
AcpiLib|EmbeddedPkg/Library/AcpiLib/AcpiLib.inf
FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf
FdtLib|MdePkg/Library/BaseFdtLib/BaseFdtLib.inf
# Shell libraries
ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf

View file

@ -7,9 +7,9 @@
**/
#include <libfdt.h>
#include <Library/AndroidBootImgLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/FdtLib.h>
#include <Library/PrintLib.h>
#include <Library/DevicePathLib.h>
#include <Library/UefiBootServicesTableLib.h>
@ -434,7 +434,7 @@ AndroidBootImgLocateFdt (
return Status;
}
Err = fdt_check_header (*FdtBase);
Err = FdtCheckHeader (*FdtBase);
if (Err != 0) {
DEBUG ((
DEBUG_ERROR,
@ -454,9 +454,9 @@ AndroidBootImgGetChosenNode (
{
INTN ChosenNode;
ChosenNode = fdt_subnode_offset ((CONST VOID *)UpdatedFdtBase, 0, "chosen");
ChosenNode = FdtSubnodeOffset ((CONST VOID *)UpdatedFdtBase, 0, "chosen");
if (ChosenNode < 0) {
ChosenNode = fdt_add_subnode ((VOID *)UpdatedFdtBase, 0, "chosen");
ChosenNode = FdtAddSubnode ((VOID *)UpdatedFdtBase, 0, "chosen");
if (ChosenNode < 0) {
DEBUG ((DEBUG_ERROR, "Fail to find fdt node chosen!\n"));
return 0;
@ -474,19 +474,19 @@ AndroidBootImgSetProperty64 (
IN UINT64 Val
)
{
INTN Err;
struct fdt_property *Property;
int Len;
INTN Err;
CONST FDT_PROPERTY *Property;
int Len;
Property = fdt_get_property_w (
Property = FdtGetPropertyW (
(VOID *)UpdatedFdtBase,
ChosenNode,
PropertyName,
&Len
);
if ((NULL == Property) && (Len == -FDT_ERR_NOTFOUND)) {
Val = cpu_to_fdt64 (Val);
Err = fdt_appendprop (
Val = CpuToFdt64 (Val);
Err = FdtAppendProp (
(VOID *)UpdatedFdtBase,
ChosenNode,
PropertyName,
@ -494,18 +494,18 @@ AndroidBootImgSetProperty64 (
sizeof (UINT64)
);
if (Err) {
DEBUG ((DEBUG_ERROR, "fdt_appendprop() fail: %a\n", fdt_strerror (Err)));
DEBUG ((DEBUG_ERROR, "FdtAppendProp() fail: %a\n", FdtStrerror (Err)));
return EFI_INVALID_PARAMETER;
}
} else if (Property != NULL) {
Err = fdt_setprop_u64 (
Err = FdtSetPropU64 (
(VOID *)UpdatedFdtBase,
ChosenNode,
PropertyName,
Val
);
if (Err) {
DEBUG ((DEBUG_ERROR, "fdt_setprop_u64() fail: %a\n", fdt_strerror (Err)));
DEBUG ((DEBUG_ERROR, "FdtSetpropU64() fail: %a\n", FdtStrerror (Err)));
return EFI_INVALID_PARAMETER;
}
} else {
@ -528,7 +528,7 @@ AndroidBootImgUpdateFdt (
EFI_STATUS Status;
EFI_PHYSICAL_ADDRESS UpdatedFdtBase, NewFdtBase;
NewFdtSize = (UINTN)fdt_totalsize (FdtBase)
NewFdtSize = (UINTN)FdtTotalSize (FdtBase)
+ FDT_ADDITIONAL_ENTRIES_SIZE;
Status = gBS->AllocatePages (
AllocateAnyPages,
@ -546,9 +546,9 @@ AndroidBootImgUpdateFdt (
}
// Load the Original FDT tree into the new region
Err = fdt_open_into (FdtBase, (VOID *)(INTN)UpdatedFdtBase, NewFdtSize);
Err = FdtOpenInto (FdtBase, (VOID *)(INTN)UpdatedFdtBase, NewFdtSize);
if (Err) {
DEBUG ((DEBUG_ERROR, "fdt_open_into(): %a\n", fdt_strerror (Err)));
DEBUG ((DEBUG_ERROR, "FdtOpenInto(): %a\n", FdtStrerror (Err)));
Status = EFI_INVALID_PARAMETER;
goto Fdt_Exit;
}

View file

@ -11,8 +11,8 @@
**/
#include <Library/BaseLib.h>
#include <Library/FdtLib.h>
#include <Library/FdtSerialPortAddressLib.h>
#include <libfdt.h>
/**
Read the "reg" property of Node in DeviceTree as a UINT64 base address.
@ -46,12 +46,12 @@ GetBaseAddress (
CONST VOID *RegProp;
INT32 PropSize;
NodeStatus = fdt_getprop (DeviceTree, Node, "status", NULL);
NodeStatus = FdtGetProp (DeviceTree, Node, "status", NULL);
if ((NodeStatus != NULL) && (AsciiStrCmp (NodeStatus, "okay") != 0)) {
return RETURN_DEVICE_ERROR;
}
RegProp = fdt_getprop (DeviceTree, Node, "reg", &PropSize);
RegProp = FdtGetProp (DeviceTree, Node, "reg", &PropSize);
if (RegProp == NULL) {
return RETURN_NOT_FOUND;
}
@ -60,7 +60,7 @@ GetBaseAddress (
return RETURN_BAD_BUFFER_SIZE;
}
*BaseAddress = fdt64_to_cpu (ReadUnaligned64 (RegProp));
*BaseAddress = Fdt64ToCpu (ReadUnaligned64 (RegProp));
return RETURN_SUCCESS;
}
@ -99,19 +99,19 @@ FdtSerialGetPorts (
{
INT32 Node;
if (fdt_check_header (DeviceTree) != 0) {
if (FdtCheckHeader (DeviceTree) != 0) {
return RETURN_INVALID_PARAMETER;
}
Ports->NumberOfPorts = 0;
Node = fdt_next_node (DeviceTree, 0, NULL);
Node = FdtNextNode (DeviceTree, 0, NULL);
while ((Node > 0) &&
(Ports->NumberOfPorts < ARRAY_SIZE (Ports->BaseAddress)))
{
CONST CHAR8 *CompatProp;
INT32 PropSize;
CompatProp = fdt_getprop (DeviceTree, Node, "compatible", &PropSize);
CompatProp = FdtGetProp (DeviceTree, Node, "compatible", &PropSize);
if (CompatProp != NULL) {
CONST CHAR8 *CompatItem;
@ -133,7 +133,7 @@ FdtSerialGetPorts (
}
}
Node = fdt_next_node (DeviceTree, Node, NULL);
Node = FdtNextNode (DeviceTree, Node, NULL);
}
return Ports->NumberOfPorts > 0 ? RETURN_SUCCESS : RETURN_NOT_FOUND;
@ -178,16 +178,16 @@ FdtSerialGetConsolePort (
INT32 ConsoleNode;
RETURN_STATUS Status;
if (fdt_check_header (DeviceTree) != 0) {
if (FdtCheckHeader (DeviceTree) != 0) {
return RETURN_INVALID_PARAMETER;
}
ChosenNode = fdt_path_offset (DeviceTree, "/chosen");
ChosenNode = FdtPathOffset (DeviceTree, "/chosen");
if (ChosenNode < 0) {
return RETURN_NOT_FOUND;
}
StdoutPathProp = fdt_getprop (
StdoutPathProp = FdtGetProp (
DeviceTree,
ChosenNode,
"stdout-path",
@ -216,7 +216,7 @@ FdtSerialGetConsolePort (
//
// StdoutPathProp starts with an absolute node path.
//
ConsoleNode = fdt_path_offset_namelen (
ConsoleNode = FdtPathOffsetNameLen (
DeviceTree,
StdoutPathProp,
(INT32)StdoutPathLength
@ -227,7 +227,7 @@ FdtSerialGetConsolePort (
//
CONST CHAR8 *ResolvedStdoutPath;
ResolvedStdoutPath = fdt_get_alias_namelen (
ResolvedStdoutPath = FdtGetAliasNameLen (
DeviceTree,
StdoutPathProp,
(INT32)StdoutPathLength
@ -236,7 +236,7 @@ FdtSerialGetConsolePort (
return RETURN_NOT_FOUND;
}
ConsoleNode = fdt_path_offset (DeviceTree, ResolvedStdoutPath);
ConsoleNode = FdtPathOffset (DeviceTree, ResolvedStdoutPath);
}
if (ConsoleNode < 0) {

View file

@ -18,7 +18,6 @@
FdtSerialPortAddressLib.c
[Packages]
EmbeddedPkg/EmbeddedPkg.dec
MdePkg/MdePkg.dec
OvmfPkg/OvmfPkg.dec

View file

@ -14,12 +14,11 @@
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/FdtLib.h>
#include <Library/IoLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/QemuFwCfgLib.h>
#include <libfdt.h>
#include "QemuFwCfgLibMmioInternal.h"
/**
@ -120,7 +119,7 @@ QemuFwCfgInitialize (
//
// Make sure we have a valid device tree blob
//
ASSERT (fdt_check_header (DeviceTreeBase) == 0);
ASSERT (FdtCheckHeader (DeviceTreeBase) == 0);
//
// Create resouce memory
@ -129,7 +128,7 @@ QemuFwCfgInitialize (
ASSERT (FwCfgResource != NULL);
for (Prev = 0; ; Prev = Node) {
Node = fdt_next_node (DeviceTreeBase, Prev, NULL);
Node = FdtNextNode (DeviceTreeBase, Prev, NULL);
if (Node < 0) {
break;
}
@ -137,7 +136,7 @@ QemuFwCfgInitialize (
//
// Check for memory node
//
Type = fdt_getprop (DeviceTreeBase, Node, "compatible", &Len);
Type = FdtGetProp (DeviceTreeBase, Node, "compatible", &Len);
if ((Type != NULL) &&
(AsciiStrnCmp (Type, "qemu,fw-cfg-mmio", Len) == 0))
{
@ -145,7 +144,7 @@ QemuFwCfgInitialize (
// Get the 'reg' property of this node. For now, we will assume
// two 8 byte quantities for base and size, respectively.
//
Reg = fdt_getprop (DeviceTreeBase, Node, "reg", &Len);
Reg = FdtGetProp (DeviceTreeBase, Node, "reg", &Len);
if ((Reg != 0) && (Len == (2 * sizeof (UINT64)))) {
FwCfgDataAddress = SwapBytes64 (Reg[0]);
FwCfgDataSize = 8;

View file

@ -33,6 +33,7 @@
BaseLib
BaseMemoryLib
DebugLib
FdtLib
HobLib
IoLib
MemoryAllocationLib

View file

@ -154,7 +154,7 @@
VariablePolicyLib | MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
VariablePolicyHelperLib | MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
SortLib | MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
FdtLib | EmbeddedPkg/Library/FdtLib/FdtLib.inf
FdtLib | MdePkg/Library/BaseFdtLib/BaseFdtLib.inf
PciSegmentLib | MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf
PciHostBridgeLib | OvmfPkg/Fdt/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf
PciHostBridgeUtilityLib | OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf

View file

@ -21,6 +21,7 @@
#include <Library/BaseMemoryLib.h>
#include <Library/CpuMmuInitLib.h>
#include <Library/DebugLib.h>
#include <Library/FdtLib.h>
#include <Library/HobLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/MpInitLib.h>
@ -29,7 +30,6 @@
#include <Library/PeiServicesLib.h>
#include <Library/PlatformHookLib.h>
#include <Library/QemuFwCfgLib.h>
#include <libfdt.h>
#include <Ppi/MasterBootMode.h>
#include <Register/LoongArch64/Cpucfg.h>
#include <Register/LoongArch64/Csr.h>
@ -176,13 +176,13 @@ GetRtcAddress (
CONST UINT64 *RegProp;
EFI_STATUS Status;
if ((Fdt == NULL) || (fdt_check_header (Fdt) != 0)) {
if ((Fdt == NULL) || (FdtCheckHeader (Fdt) != 0)) {
return EFI_INVALID_PARAMETER;
}
Status = EFI_NOT_FOUND;
for (Prev = 0; ; Prev = Node) {
Node = fdt_next_node (Fdt, Prev, NULL);
Node = FdtNextNode (Fdt, Prev, NULL);
if (Node < 0) {
break;
}
@ -190,13 +190,13 @@ GetRtcAddress (
//
// Check for memory node
//
Type = fdt_getprop (Fdt, Node, "compatible", &Len);
Type = FdtGetProp (Fdt, Node, "compatible", &Len);
if ((Type) && (AsciiStrnCmp (Type, "loongson,ls7a-rtc", Len) == 0)) {
//
// Get the 'reg' property of this node. For now, we will assume
// two 8 byte quantities for base and size, respectively.
//
RegProp = fdt_getprop (Fdt, Node, "reg", &Len);
RegProp = FdtGetProp (Fdt, Node, "reg", &Len);
if ((RegProp != 0) && (Len == (2 * sizeof (UINT64)))) {
*RtcBaseAddress = SwapBytes64 (RegProp[0]);
Status = RETURN_SUCCESS;
@ -274,11 +274,11 @@ AddFdtHob (
SaveRtcRegisterAddressHob (RtcBaseAddress);
FdtSize = fdt_totalsize (Base) + PcdGet32 (PcdDeviceTreeAllocationPadding);
FdtSize = FdtTotalSize (Base) + PcdGet32 (PcdDeviceTreeAllocationPadding);
FdtPages = EFI_SIZE_TO_PAGES (FdtSize);
NewBase = AllocatePages (FdtPages);
ASSERT (NewBase != NULL);
fdt_open_into (Base, NewBase, EFI_PAGES_TO_SIZE (FdtPages));
FdtOpenInto (Base, NewBase, EFI_PAGES_TO_SIZE (FdtPages));
FdtHobData = BuildGuidHob (&gFdtHobGuid, sizeof *FdtHobData);
ASSERT (FdtHobData != NULL);

View file

@ -43,6 +43,7 @@
BaseMemoryLib
CpuMmuInitLib
DebugLib
FdtLib
HobLib
MemoryAllocationLib
MpInitLib

View file

@ -244,7 +244,7 @@
CcExitLib|OvmfPkg/Library/CcExitLib/CcExitLib.inf
SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf
PlatformHookLib|MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatformHookLibNull.inf
FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf
FdtLib|MdePkg/Library/BaseFdtLib/BaseFdtLib.inf
VirtioMmioDeviceLib|OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceLib.inf
TdxLib|MdePkg/Library/TdxLib/TdxLib.inf
TdxMailboxLib|OvmfPkg/Library/TdxMailboxLib/TdxMailboxLibNull.inf

View file

@ -93,7 +93,7 @@
DebugAgentTimerLib|EmbeddedPkg/Library/DebugAgentTimerLibNull/DebugAgentTimerLibNull.inf
# Flattened Device Tree (FDT) access library
FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf
FdtLib|MdePkg/Library/BaseFdtLib/BaseFdtLib.inf
# PCI Libraries
PciLib|MdePkg/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf

View file

@ -22,6 +22,7 @@ Module Name:
//
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/FdtLib.h>
#include <Library/HobLib.h>
#include <Library/IoLib.h>
#include <Library/PcdLib.h>
@ -29,7 +30,6 @@ Module Name:
#include <Library/BaseRiscVSbiLib.h>
#include <Register/RiscV64/RiscVEncoding.h>
#include <Library/PrePiLib.h>
#include <libfdt.h>
#include <Guid/FdtHob.h>
VOID
@ -121,7 +121,7 @@ GetNumCells (
INT32 Len;
UINT32 Val;
Prop = fdt_getprop (Fdt, Node, Name, &Len);
Prop = FdtGetProp (Fdt, Node, Name, &Len);
if (Prop == NULL) {
return Len;
}
@ -130,7 +130,7 @@ GetNumCells (
return -FDT_ERR_BADNCELLS;
}
Val = fdt32_to_cpu (*Prop);
Val = Fdt32ToCpu (*Prop);
if (Val > FDT_MAX_NCELLS) {
return -FDT_ERR_BADNCELLS;
}
@ -163,11 +163,11 @@ AddReservedMemoryMap (
INTN NumRsv, i;
INT32 NumAddrCells, NumSizeCells;
NumRsv = fdt_num_mem_rsv (FdtPointer);
NumRsv = FdtGetNumberOfReserveMapEntries (FdtPointer);
/* Look for an existing entry and add it to the efi mem map. */
for (i = 0; i < NumRsv; i++) {
if (fdt_get_mem_rsv (FdtPointer, i, &Addr, &Size) != 0) {
if (FdtGetReserveMapEntry (FdtPointer, i, &Addr, &Size) != 0) {
continue;
}
@ -179,7 +179,7 @@ AddReservedMemoryMap (
}
/* process reserved-memory */
Node = fdt_subnode_offset (FdtPointer, 0, "reserved-memory");
Node = FdtSubnodeOffset (FdtPointer, 0, "reserved-memory");
if (Node >= 0) {
NumAddrCells = GetNumCells (FdtPointer, Node, "#address-cells");
if (NumAddrCells <= 0) {
@ -191,21 +191,21 @@ AddReservedMemoryMap (
return;
}
fdt_for_each_subnode (SubNode, FdtPointer, Node) {
RegProp = fdt_getprop (FdtPointer, SubNode, "reg", &Len);
FdtForEachSubnode (SubNode, FdtPointer, Node) {
RegProp = FdtGetProp (FdtPointer, SubNode, "reg", &Len);
if ((RegProp != 0) && (Len == ((NumAddrCells + NumSizeCells) * sizeof (INT32)))) {
Addr = fdt32_to_cpu (RegProp[0]);
Addr = Fdt32ToCpu (RegProp[0]);
if (NumAddrCells > 1) {
Addr = (Addr << 32) | fdt32_to_cpu (RegProp[1]);
Addr = (Addr << 32) | Fdt32ToCpu (RegProp[1]);
}
RegProp += NumAddrCells;
Size = fdt32_to_cpu (RegProp[0]);
Size = Fdt32ToCpu (RegProp[0]);
if (NumSizeCells > 1) {
Size = (Size << 32) | fdt32_to_cpu (RegProp[1]);
Size = (Size << 32) | Fdt32ToCpu (RegProp[1]);
}
DEBUG ((
@ -216,7 +216,7 @@ AddReservedMemoryMap (
Size
));
if (fdt_getprop (FdtPointer, SubNode, "no-map", &Len)) {
if (FdtGetProp (FdtPointer, SubNode, "no-map", &Len)) {
BuildMemoryAllocationHob (
Addr,
Size,
@ -269,20 +269,20 @@ MemoryPeimInitialization (
// Look for the lowest memory node
for (Prev = 0; ; Prev = Node) {
Node = fdt_next_node (FdtPointer, Prev, NULL);
Node = FdtNextNode (FdtPointer, Prev, NULL);
if (Node < 0) {
break;
}
// Check for memory node
Type = fdt_getprop (FdtPointer, Node, "device_type", &Len);
Type = FdtGetProp (FdtPointer, Node, "device_type", &Len);
if (Type && (AsciiStrnCmp (Type, "memory", Len) == 0)) {
// Get the 'reg' property of this node. For now, we will assume
// two 8 byte quantities for base and size, respectively.
RegProp = fdt_getprop (FdtPointer, Node, "reg", &Len);
RegProp = FdtGetProp (FdtPointer, Node, "reg", &Len);
if ((RegProp != 0) && (Len == (2 * sizeof (UINT64)))) {
CurBase = fdt64_to_cpu (ReadUnaligned64 (RegProp));
CurSize = fdt64_to_cpu (ReadUnaligned64 (RegProp + 1));
CurBase = Fdt64ToCpu (ReadUnaligned64 (RegProp));
CurSize = Fdt64ToCpu (ReadUnaligned64 (RegProp + 1));
DEBUG ((
DEBUG_INFO,

View file

@ -13,12 +13,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <PiPei.h>
#include <Library/DebugLib.h>
#include <Library/FdtLib.h>
#include <Library/HobLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/BaseRiscVSbiLib.h>
#include <Library/PcdLib.h>
#include <Include/Library/PrePiLib.h>
#include <libfdt.h>
#include <Guid/FdtHob.h>
/**
@ -67,15 +67,15 @@ PopulateIoResources (
UINT64 *Reg;
INT32 Node, LenP;
Node = fdt_node_offset_by_compatible (FdtBase, -1, Compatible);
Node = FdtNodeOffsetByCompatible (FdtBase, -1, Compatible);
while (Node != -FDT_ERR_NOTFOUND) {
Reg = (UINT64 *)fdt_getprop (FdtBase, Node, "reg", &LenP);
Reg = (UINT64 *)FdtGetProp (FdtBase, Node, "reg", &LenP);
if (Reg) {
ASSERT (LenP == (2 * sizeof (UINT64)));
AddIoMemoryBaseSizeHob (SwapBytes64 (Reg[0]), SwapBytes64 (Reg[1]));
}
Node = fdt_node_offset_by_compatible (FdtBase, Node, Compatible);
Node = FdtNodeOffsetByCompatible (FdtBase, Node, Compatible);
}
}
@ -113,12 +113,12 @@ PlatformPeimInitialization (
DEBUG ((DEBUG_INFO, "%a: Build FDT HOB - FDT at address: 0x%x \n", __func__, FdtPointer));
Base = FdtPointer;
if (fdt_check_header (Base) != 0) {
if (FdtCheckHeader (Base) != 0) {
DEBUG ((DEBUG_ERROR, "%a: Corrupted DTB\n", __func__));
return EFI_UNSUPPORTED;
}
FdtSize = fdt_totalsize (Base);
FdtSize = FdtTotalSize (Base);
FdtPages = EFI_SIZE_TO_PAGES (FdtSize);
NewBase = AllocatePages (FdtPages);
if (NewBase == NULL) {
@ -126,7 +126,7 @@ PlatformPeimInitialization (
return EFI_UNSUPPORTED;
}
fdt_open_into (Base, NewBase, EFI_PAGES_TO_SIZE (FdtPages));
FdtOpenInto (Base, NewBase, EFI_PAGES_TO_SIZE (FdtPages));
FdtHobData = BuildGuidHob (&gFdtHobGuid, sizeof *FdtHobData);
if (FdtHobData == NULL) {