From 450a001c09d9df15b483b152e8cbd13095e87d57 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Tue, 1 Oct 2024 16:01:00 +0100 Subject: MdePkg: export additional Property functions from BaseFdtLib - FdtSetPropU64 - FdtAppendProp - FdtDelProp Signed-off-by: Leif Lindholm --- MdePkg/Include/Library/FdtLib.h | 62 +++++++++++++++++++++++++++++++ MdePkg/Library/BaseFdtLib/FdtLib.c | 75 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 137 insertions(+) (limited to 'MdePkg') 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 @@ -588,6 +588,68 @@ FdtSetProperty ( IN UINT32 Length ); +/** + 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. 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 @@ -482,6 +482,81 @@ FdtSetProperty ( return fdt_setprop (Fdt, NodeOffset, Name, Value, (int)Length); } +/** + 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. -- cgit v1.2.3