MdePkg/BaseFdtLib: Add FdtNodeOffsetByCompatible()

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 <nhi@os.amperecomputing.com>
This commit is contained in:
Nhi Pham 2024-08-25 12:26:28 +07:00 committed by mergify[bot]
parent 99e4c8ea93
commit 90d0ec17e7
2 changed files with 37 additions and 0 deletions

View File

@ -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_ */

View File

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