Skip to content

Commit

Permalink
MdePkg/BaseFdtLib: Add Fdt function.
Browse files Browse the repository at this point in the history
Add FdtGetName() and FdtNodeDepth() function.

Cc: Benny Lin <[email protected]>
Cc: Gua Guo <[email protected]>
Cc: Chasel Chiu <[email protected]>
Cc: James Lu <[email protected]>

Reviewed-by: Benny Lin <[email protected]>
Reviewed-by: Gua Guo <[email protected]>

Signed-off-by: BruceX Wang <[email protected]>
  • Loading branch information
IntelBrucexWang authored and mergify[bot] committed Sep 26, 2023
1 parent c70d914 commit d6b0537
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
34 changes: 34 additions & 0 deletions MdePkg/Include/Library/FdtLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,4 +398,38 @@ FdtSetProp (
IN UINT32 Length
);

/**
Returns the name of a given node.
@param[in] Fdt The pointer to FDT blob.
@param[in] NodeOffse Offset of node to check.
@param[in] Length The pointer to an integer variable (will be overwritten) or NULL.
@return The pointer to the node's name.
**/
CONST CHAR8 *
EFIAPI
FdtGetName (
IN VOID *Fdt,
IN INT32 NodeOffset,
IN UINT32 *Length
);

/**
FdtNodeDepth() finds the depth of a given node. The root node
has depth 0, its immediate subnodes depth 1 and so forth.
@param[in] Fdt The pointer to FDT blob.
@param[in] NodeOffset Offset of node to check.
@return Depth of the node at NodeOffset.
**/
INT32
EFIAPI
FdtNodeDepth (
IN CONST VOID *Fdt,
IN INT32 NodeOffset
);

#endif /* FDT_LIB_H_ */
40 changes: 40 additions & 0 deletions MdePkg/Library/BaseFdtLib/FdtLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,3 +402,43 @@ FdtSetProp (
{
return fdt_setprop (Fdt, NodeOffset, Name, Value, (int)Length);
}

/**
Returns the name of a given node.
@param[in] Fdt The pointer to FDT blob.
@param[in] NodeOffset Offset of node to check.
@param[in] Length The pointer to an integer variable (will be overwritten) or NULL.
@return The pointer to the node's name.
**/
CONST CHAR8 *
EFIAPI
FdtGetName (
IN VOID *Fdt,
IN INT32 NodeOffset,
IN UINT32 *Length
)
{
return fdt_get_name (Fdt, NodeOffset, (int *)Length);
}

/**
FdtNodeDepth() finds the depth of a given node. The root node
has depth 0, its immediate subnodes depth 1 and so forth.
@param[in] Fdt The pointer to FDT blob.
@param[in] NodeOffset Offset of node to check.
@returns Depth of the node at NodeOffset.
**/
INT32
EFIAPI
FdtNodeDepth (
IN CONST VOID *Fdt,
IN INT32 NodeOffset
)
{
return fdt_node_depth (Fdt, NodeOffset);
}

0 comments on commit d6b0537

Please sign in to comment.