diff --git a/MdePkg/Include/Library/FdtLib.h b/MdePkg/Include/Library/FdtLib.h index ad34e0bc17..7347d84ff8 100644 --- a/MdePkg/Include/Library/FdtLib.h +++ b/MdePkg/Include/Library/FdtLib.h @@ -12,6 +12,8 @@ Refer to FDT specification: https://www.devicetree.org/specifications/ Copyright (c) 2023, Intel Corporation. All rights reserved.
+ Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -560,6 +562,49 @@ FdtStringListContains ( IN CONST CHAR8 *String ); +/** + Returns the number of strings in the given property. + + @param[in] Fdt The pointer to FDT blob. + @param[in] NodeOffset The offset to the node which contains the property. + @param[in] Property Name of the property containing the string list. + + @return The number of strings in the property, or a negative error code + on failure. Returns -FDT_ERR_BADVALUE if the property value is + not a valid NUL-terminated string list. + +**/ +INT32 +EFIAPI +FdtStringListCount ( + IN CONST VOID *Fdt, + IN INT32 NodeOffset, + IN CONST CHAR8 *Property + ); + +/** + Searches for a string in a string list property and returns its index. + + @param[in] Fdt The pointer to FDT blob. + @param[in] NodeOffset The offset to the node which contains the property. + @param[in] Property The name of the property to search. + @param[in] String String to find within the list. + + @return The index of the string in the string list (>=0) on success, + -FDT_ERR_NOTFOUND if the string is not found, + -FDT_ERR_BADVALUE if the property is not a valid NUL-terminated + string list, or another negative error code on failure. + +**/ +INT32 +EFIAPI +FdtStringListSearch ( + IN CONST VOID *Fdt, + IN INT32 NodeOffset, + IN CONST CHAR8 *Property, + IN CONST CHAR8 *String + ); + /** Returns a property with the given name from the given node. diff --git a/MdePkg/Library/BaseFdtLib/FdtLib.c b/MdePkg/Library/BaseFdtLib/FdtLib.c index d9b423b872..fd9c3bcfe0 100644 --- a/MdePkg/Library/BaseFdtLib/FdtLib.c +++ b/MdePkg/Library/BaseFdtLib/FdtLib.c @@ -2,6 +2,8 @@ Flattened Device Tree Library. Copyright (c) 2023, Intel Corporation. All rights reserved.
+ Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -429,6 +431,55 @@ FdtStringListContains ( return fdt_stringlist_contains (StringList, ListLength, String); } +/** + Returns the number of strings in the given property. + + @param[in] Fdt The pointer to FDT blob. + @param[in] NodeOffset The offset to the given node. + @param[in] Property Name of the property containing the string list. + + @return The number of strings in the property, or a negative error code + on failure. Returns -FDT_ERR_BADVALUE if the property value is + not a valid NUL-terminated string list. + +**/ +INT32 +EFIAPI +FdtStringListCount ( + IN CONST VOID *Fdt, + IN INT32 NodeOffset, + IN CONST CHAR8 *Property + ) +{ + return fdt_stringlist_count (Fdt, NodeOffset, Property); +} + +/** + Searches for a string in a string list property and returns its index. + + @param[in] Fdt The pointer to FDT blob. + @param[in] NodeOffset The offset to the given node. + @param[in] Property The name of the property to search. + @param[in] String String to find within the list. + + @return The index of the string in the string list (>=0) on success, + -FDT_ERR_NOTFOUND if the string is not found, + -FDT_ERR_BADVALUE if the property is not a valid NUL-terminated + string list, or another negative error code on failure. + +**/ +INT32 +EFIAPI +FdtStringListSearch ( + IN CONST VOID *Fdt, + IN INT32 NodeOffset, + IN CONST CHAR8 *Property, + IN CONST CHAR8 *String + ) +{ + return fdt_stringlist_search (Fdt, NodeOffset, Property, String); +} + /** Returns a property with the given name from the given node.