Skip to content

Commit 74a65f6

Browse files
antkleinmergify[bot]
authored andcommitted
MdePkg/BaseFdtLib: Implement new libfdt wrappers
Add support for the define FdtForEachPropertyOffset and FdtFindMaxPhandle() wrappers. Signed-off-by: Antaeus Kleinert-Strand <[email protected]>
1 parent defbd14 commit 74a65f6

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

MdePkg/Include/Library/FdtLib.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,11 @@ typedef struct {
202202
#define FdtSetPropEmpty(Fdt, NodeOffset, Name) \
203203
FdtSetProp ((Fdt), (NodeOffset), (Name), NULL, 0)
204204

205+
#define FdtForEachPropertyOffset(Property, Fdt, Node) \
206+
for (Property = FdtFirstPropertyOffset(Fdt, Node); \
207+
Property >= 0; \
208+
Property = FdtNextPropertyOffset(Fdt, Property))
209+
205210
/**
206211
Convert UINT16 data of the FDT blob to little-endian
207212
@@ -971,6 +976,22 @@ FdtGetPhandle (
971976
IN INT32 NodeOffset
972977
);
973978

979+
/**
980+
Find and return the highest phandle in a tree. The value returned in Phandle
981+
is only valid if the function returns success.
982+
983+
@param[in] Fdt The pointer to FDT blob.
984+
@param[out] Phandle The return location for the highest Phandle value found in the tree
985+
986+
@return 0 on success or a negative error code on failure
987+
**/
988+
INT32
989+
EFIAPI
990+
FdtFindMaxPhandle (
991+
IN CONST VOID *Fdt,
992+
OUT UINT32 *Phandle
993+
);
994+
974995
/**
975996
Applies a DT overlay on a base DT.
976997

MdePkg/Library/BaseFdtLib/FdtLib.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,25 @@ FdtGetPhandle (
918918
return fdt_get_phandle (Fdt, NodeOffset);
919919
}
920920

921+
/**
922+
Find and return the highest phandle in a tree. The value returned in Phandle
923+
is only valid if the function returns success.
924+
925+
@param[in] Fdt The pointer to FDT blob.
926+
@param[out] Phandle The return location for the highest Phandle value found in the tree
927+
928+
@return 0 on success or a negative error code on failure
929+
**/
930+
INT32
931+
EFIAPI
932+
FdtFindMaxPhandle (
933+
IN CONST VOID *Fdt,
934+
OUT UINT32 *Phandle
935+
)
936+
{
937+
return fdt_find_max_phandle (Fdt, Phandle);
938+
}
939+
921940
/**
922941
Applies a DT overlay on a base DT.
923942

0 commit comments

Comments
 (0)