summaryrefslogtreecommitdiffstats
path: root/MdePkg
diff options
context:
space:
mode:
authorNhi Pham <nhi@os.amperecomputing.com>2024-08-25 12:26:28 +0700
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-08-28 08:59:22 +0000
commit90d0ec17e7074905de347ccf2accdd6b8e8ee968 (patch)
tree21e14b388a3a37e99b7197a28329643e84dec659 /MdePkg
parent99e4c8ea93fa0e98bc1bdb968e9d5bb42ff5d39c (diff)
downloadedk2-90d0ec17e7074905de347ccf2accdd6b8e8ee968.tar.gz
edk2-90d0ec17e7074905de347ccf2accdd6b8e8ee968.tar.bz2
edk2-90d0ec17e7074905de347ccf2accdd6b8e8ee968.zip
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>
Diffstat (limited to 'MdePkg')
-rw-r--r--MdePkg/Include/Library/FdtLib.h17
-rw-r--r--MdePkg/Library/BaseFdtLib/FdtLib.c20
2 files changed, 37 insertions, 0 deletions
diff --git a/MdePkg/Include/Library/FdtLib.h b/MdePkg/Include/Library/FdtLib.h
index 65d74609cd..89aa1e00f9 100644
--- a/MdePkg/Include/Library/FdtLib.h
+++ b/MdePkg/Include/Library/FdtLib.h
@@ -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_ */
diff --git a/MdePkg/Library/BaseFdtLib/FdtLib.c b/MdePkg/Library/BaseFdtLib/FdtLib.c
index c9514af673..9b1ceac551 100644
--- a/MdePkg/Library/BaseFdtLib/FdtLib.c
+++ b/MdePkg/Library/BaseFdtLib/FdtLib.c
@@ -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);
+}