Skip to content

Commit

Permalink
MdePkg/BaseFdtLib: Add FdtNodeOffsetByCompatible()
Browse files Browse the repository at this point in the history
This adds FdtNodeOffsetByCompatible() to support finding the offset of
the first node with a given 'compatible' value after an offset.

Signed-off-by: Nhi Pham <[email protected]>
  • Loading branch information
nhivp authored and mergify[bot] committed Aug 28, 2024
1 parent 99e4c8e commit 90d0ec1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
17 changes: 17 additions & 0 deletions MdePkg/Include/Library/FdtLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -432,4 +432,21 @@ FdtNodeDepth (
IN INT32 NodeOffset
);

/**
Find nodes with a given 'compatible' value.
@param[in] Fdt The pointer to FDT blob.
@param[in] StartOffset Only find nodes after this offset.
@param[in] Compatible The string to match against.
@retval The offset of the first node after StartOffset.
**/
INT32
EFIAPI
FdtNodeOffsetByCompatible (
IN CONST VOID *Fdt,
IN INT32 StartOffset,
IN CONST CHAR8 *Compatible
);

#endif /* FDT_LIB_H_ */
20 changes: 20 additions & 0 deletions MdePkg/Library/BaseFdtLib/FdtLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,3 +442,23 @@ FdtNodeDepth (
{
return fdt_node_depth (Fdt, NodeOffset);
}

/**
Find nodes with a given 'compatible' value.
@param[in] Fdt The pointer to FDT blob.
@param[in] StartOffset Only find nodes after this offset.
@param[in] Compatible The string to match against.
@retval The offset of the first node after StartOffset.
**/
INT32
EFIAPI
FdtNodeOffsetByCompatible (
IN CONST VOID *Fdt,
IN INT32 StartOffset,
IN CONST CHAR8 *Compatible
)
{
return fdt_node_offset_by_compatible (Fdt, StartOffset, Compatible);
}

0 comments on commit 90d0ec1

Please sign in to comment.