summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeif Lindholm <quic_llindhol@quicinc.com>2024-10-01 18:01:00 +0300
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-10-02 05:58:31 +0300
commit450a001c09d9df15b483b152e8cbd13095e87d57 (patch)
tree33d308518fa91f0c8090705f4822c37826f72531
parent5bad56093534d943e4fa6e00a068dbe20c39ef81 (diff)
downloadedk2-450a001c09d9df15b483b152e8cbd13095e87d57.tar.xz
MdePkg: export additional Property functions from BaseFdtLib
- FdtSetPropU64 - FdtAppendProp - FdtDelProp Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com>
-rw-r--r--MdePkg/Include/Library/FdtLib.h62
-rw-r--r--MdePkg/Library/BaseFdtLib/FdtLib.c75
2 files changed, 137 insertions, 0 deletions
diff --git a/MdePkg/Include/Library/FdtLib.h b/MdePkg/Include/Library/FdtLib.h
index e4471fc2ab..1a36f58ebe 100644
--- a/MdePkg/Include/Library/FdtLib.h
+++ b/MdePkg/Include/Library/FdtLib.h
@@ -589,6 +589,68 @@ FdtSetProperty (
);
/**
+ Set a property to a 64-bit integer.
+
+ @param[in] Fdt The pointer to FDT blob.
+ @param[in] NodeOffset The offset to the node offset which want to add in.
+ @param[in] Name The name to name the property.
+ @param[in] Value The value (big-endian) to the property value.
+
+ @return Zero for successfully, otherwise failed.
+
+ **/
+INT32
+EFIAPI
+FdtSetPropU64 (
+ IN VOID *Fdt,
+ IN INT32 NodeOffset,
+ IN CONST CHAR8 *Name,
+ IN UINT64 Value
+ );
+
+/**
+ Append or create a property in the given node.
+
+ @param[in] Fdt The pointer to FDT blob.
+ @param[in] NodeOffset The offset to the node offset which want to add in.
+ @param[in] Name The name to name the property.
+ @param[in] Value The value (big-endian) to the property value.
+ @param[in] Length The length to the size of the property.
+
+ @return Zero for successfully, otherwise failed.
+
+ **/
+INT32
+EFIAPI
+FdtAppendProp (
+ IN VOID *Fdt,
+ IN INT32 NodeOffset,
+ IN CONST CHAR8 *Name,
+ IN CONST VOID *Value,
+ IN UINT32 Length
+ );
+
+/**
+ Delete a property.
+
+ This function will delete data from the blob, and will therefore
+ change the offsets of some existing nodes.
+
+ @param[in][out] Fdt Pointer to the device tree blob.
+ @param[in] NodeOffset Offset of the node whose property to nop.
+ @param[in] Name Name of the property to nop.
+
+ @return Zero for successfully, otherwise failed.
+
+**/
+INT32
+FdtDelProp (
+ IN OUT VOID *Fdt,
+ IN INT32 NodeOffset,
+ IN CONST CHAR8 *Name
+ );
+
+/**
Returns the name of a given node.
@param[in] Fdt The pointer to FDT blob.
diff --git a/MdePkg/Library/BaseFdtLib/FdtLib.c b/MdePkg/Library/BaseFdtLib/FdtLib.c
index 530549ba75..960984842d 100644
--- a/MdePkg/Library/BaseFdtLib/FdtLib.c
+++ b/MdePkg/Library/BaseFdtLib/FdtLib.c
@@ -483,6 +483,81 @@ FdtSetProperty (
}
/**
+ Set a property to a 64-bit integer.
+
+ @param[in] Fdt The pointer to FDT blob.
+ @param[in] NodeOffset The offset to the node offset which want to add in.
+ @param[in] Name The name to name the property.
+ @param[in] Value The value (big-endian) to the property value.
+
+ @return Zero for successfully, otherwise failed.
+
+ **/
+INT32
+EFIAPI
+FdtSetPropU64 (
+ IN VOID *Fdt,
+ IN INT32 NodeOffset,
+ IN CONST CHAR8 *Name,
+ IN UINT64 Value
+ )
+{
+ UINT64 Tmp;
+
+ Tmp = cpu_to_fdt64 (Value);
+
+ return fdt_setprop (Fdt, NodeOffset, Name, &Tmp, sizeof (Tmp));
+}
+
+/**
+ Append or create a property in the given node.
+
+ @param[in] Fdt The pointer to FDT blob.
+ @param[in] NodeOffset The offset to the node offset which want to add in.
+ @param[in] Name The name to name the property.
+ @param[in] Value The value (big-endian) to the property value.
+ @param[in] Length The length to the size of the property.
+
+ @return Zero for successfully, otherwise failed.
+
+ **/
+INT32
+EFIAPI
+FdtAppendProp (
+ IN VOID *Fdt,
+ IN INT32 NodeOffset,
+ IN CONST CHAR8 *Name,
+ IN CONST VOID *Value,
+ IN UINT32 Length
+ )
+{
+ return fdt_appendprop (Fdt, NodeOffset, Name, Value, (int)Length);
+}
+
+/**
+ Delete a property.
+
+ This function will delete data from the blob, and will therefore
+ change the offsets of some existing nodes.
+
+ @param[in][out] Fdt Pointer to the device tree blob.
+ @param[in] NodeOffset Offset of the node whose property to nop.
+ @param[in] Name Name of the property to nop.
+
+ @return Zero for successfully, otherwise failed.
+
+**/
+INT32
+FdtDelProp (
+ IN OUT VOID *Fdt,
+ IN INT32 NodeOffset,
+ IN CONST CHAR8 *Name
+ )
+{
+ return fdt_delprop (Fdt, NodeOffset, Name);
+}
+
+/**
Returns the name of a given node.
@param[in] Fdt The pointer to FDT blob.