diff --git a/kkk/los_ld_elflib.h b/kkk/los_ld_elflib.h
new file mode 100644
index 0000000..2ce398c
--- /dev/null
+++ b/kkk/los_ld_elflib.h
@@ -0,0 +1,294 @@
+/* ----------------------------------------------------------------------------
+ * Copyright (c) Huawei Technologies Co., Ltd. 2013-2019. All rights reserved.
+ * Description: Dynload ElfLib HeadFile
+ * Author: Huawei LiteOS Team
+ * Create: 2013-01-01
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * --------------------------------------------------------------------------- */
+
+/**
+ * @defgroup los_dynload Dynamic loading
+ * @ingroup kernel
+ */
+
+#ifndef _LOS_LD_ELFLIB_H
+#define _LOS_LD_ELFLIB_H
+
+#include "los_typedef.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#ifdef LOSCFG_KERNEL_DYNLOAD_DYN
+#ifdef LOSCFG_DYNLOAD_DYN_FROM_FS
+/**
+ * @ingroup los_dynload
+ * Define an enum type indicates load strategy.
+ *
+ * Type of load strategy of dynamic load, ZIP means using zipped shared object, NOZIP means using normal shared object.
+ */
+enum LOAD_STRATEGY {
+ ZIP,
+ NOZIP
+};
+/*这是一个枚举类型的定义,名称为LOAD_STRATEGY。它包含两个成员:ZIP和NOZIP。*/
+/**
+ * @ingroup los_dynload
+ * Define the structure of the parameters used for dynamic.
+ *
+ * Information of specified parameters passed in during dynamic load.
+ */
+typedef struct tagDynloadParam {
+ enum LOAD_STRATEGY enLoadStrategy;
+} DYNLOAD_PARAM_S;
+/*这个结构体可以用来存储动态加载的参数信息,
+其中enLoadStrategy成员表示加载策略,可以是ZIP或者NOZIP。通过使用这个结构体,
+可以将加载策略作为参数传递给相关的函数或模块。*/
+/**
+ * @ingroup los_dynload
+ * @brief Register the dynamic parameters.
+ *
+ * @par Description:
+ * This API is used to register the dynamic load parameters.
+ * @attention
+ *
+ *
+ * @param dynloadParam [IN] dynamic load parameters to be registered.
+ *
+ * @par Dependency:
+ * - los_ld_elflib.h: the header file that contains the API declaration.
+ * @see LOS_FindSymByName | LOS_LdDestroy
+ * @since Huawei LiteOS V100R001C00
+ */
+extern VOID LOS_DynParamReg(DYNLOAD_PARAM_S *dynloadParam);
+/*通过调用LOS_DynParamReg函数并传递一个指向DYNLOAD_PARAM_S类型对象的指针,
+可以将动态加载的参数信息注册到相关的系统或模块中。*/
+/**
+ * @ingroup los_dynload
+ * @brief Load a shared object file.
+ *
+ * @par Description:
+ * This API is used to load a shared object file under a particular module file path.
+ * @attention
+ *
+ * - The parameter passed to this API should be a legal path of a shared object file.
+ *
+ *
+ * @param elfFileName [IN] Shared object file path.
+ *
+ * @retval NULL The shared object file fails to be loaded.
+ * @retval VOID* The shared object file is successfully loaded.
+ * @par Dependency:
+ * - los_ld_elflib.h: the header file that contains the API declaration.
+ * @see LOS_ModuleUnload
+ * @since Huawei LiteOS V100R001C00
+ */
+extern VOID *LOS_SoLoad(CHAR *elfFileName);
+#endif /* LOSCFG_DYNLOAD_DYN_FROM_FS */
+
+#ifdef LOSCFG_DYNLOAD_DYN_FROM_MEM
+/**
+ * @ingroup los_dynload
+ * @brief Load a shared object file from the memory.
+ *
+ * @par Description:
+ * This API is used to load a shared object file that is in memory.
+ * @attention
+ *
+ * - The shared object file does not depend on other shared objects.
+ *
+ *
+ * @param elfFileName [IN] Shared object file name.
+ * @param fileNameLen [IN] The length of shared object file name.
+ * @param elfFileBuf [IN] Shared object file buffer in memory.
+ * @param bufLen [IN] the length of shared object file buffer in memory.
+ *
+ * @retval NULL The shared object file fails to be loaded.
+ * @retval VOID* The shared object file is successfully loaded.
+ * @par Dependency:
+ * - los_ld_elflib.h: the header file that contains the API declaration.
+ * @see LOS_ModuleUnload
+ * @since Huawei LiteOS V200R003C00
+ */
+extern VOID *LOS_MemLoad(const CHAR *elfFileName, UINT32 fileNameLen,
+ const CHAR *elfFileBuf, UINT32 bufLen);
+#endif /* LOSCFG_DYNLOAD_DYN_FROM_MEM */
+#endif /* LOSCFG_KERNEL_DYNLOAD_DYN */
+/*这段代码中使用了条件编译指令#ifdef和#endif,用于在不同的编译环境下选择是否启用动态加载功能。*/
+#ifdef LOSCFG_KERNEL_DYNLOAD_REL
+/**
+ * @ingroup los_dynload
+ * @brief Load a object file.
+ *
+ * @par Description:
+ * This API is used to load a object file under a particular module file path.
+ * @attention
+ *
+ * - The parameter passed to this API should be a legal path of an object file.
+ *
+ *
+ * @param elfFileName [IN] Object file path.
+ *
+ * @retval NULL The object file fails to be loaded.
+ * @retval VOID* The object file is successfully loaded.
+ * @par Dependency:
+ * - los_ld_elflib.h: the header file that contains the API declaration.
+ * @see LOS_ModuleUnload
+ * @since Huawei LiteOS V100R001C00
+ */
+extern VOID *LOS_ObjLoad(CHAR *elfFileName);
+#endif /* LOSCFG_KERNEL_DYNLOAD_REL */
+/*如果宏定义LOSCFG_KERNEL_DYNLOAD_REL被定义,
+则表示启用了动态链接库的重定位功能,此时函数LOS_ObjLoad被声明为外部函数,
+并接受一个指向字符串类型(CHAR)的指针作为参数,返回一个VOID类型的指针。*/
+/**
+ * @ingroup los_dynload
+ * @brief Unload a module.
+ *
+ * @par Description:
+ * This API is used to unload a module with a particular module handle.
+ * @attention
+ *
+ *
+ * @param handle [IN] Module handle.
+ *
+ * @retval #LOS_NOK The module fails to be unloaded.
+ * @retval #LOS_OK The module is successfully unloaded.
+ * @par Dependency:
+ * - los_ld_elflib.h: the header file that contains the API declaration.
+ * @see LOS_ObjLoad
+ * @since Huawei LiteOS V100R001C00
+ */
+extern INT32 LOS_ModuleUnload(VOID *handle);
+/*通过调用LOS_ModuleUnload函数并传递一个动态库的句柄,
+可以卸载该动态库并释放相关资源。*/
+/**
+ * @ingroup los_dynload
+ * @brief Destroy a dynamic loader.
+ *
+ * @par Description:
+ * This API is used to destroy a dynamic linker.
+ * @attention
+ *
+ * - When dynamic loading is no longer needed, call this API to destroy the dynamic linker.
+ *
+ *
+ * @param None.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_ld_elflib.h: the header file that contains the API declaration.
+ * @see LOS_FindSymByName
+ * @since Huawei LiteOS V100R001C00
+ */
+extern VOID LOS_LdDestroy(VOID);
+/*这段代码声明了一个外部函数LOS_LdDestroy,该函数没有参数和返回值。
+
+通过调用LOS_LdDestroy函数,可以销毁动态加载器(Loader),释放相关资源*/
+/**
+ * @ingroup los_dynload
+ * @brief Search for a symbol address.
+ *
+ * @par Description:
+ * This API is used to search for the address of a symbol according to a particular module handle and symbol name.
+ * @attention
+ *
+ * - If the value of handle is NULL, Huawei LiteOS searches for symbols (including system symbols) in the global
+ * symbol table. If handle is set to a valid module handle, Huawei LiteOS searches for symbols in the module that
+ * comes with the module handle.
+ *
+ *
+ * @param handle [IN] Module handle.
+ * @param name [IN] Name of the symbol to be searched for.
+ *
+ * @retval NULL The symbol address is not found.
+ * @retval VOID* Symbol address.
+ * @par Dependency:
+ * - los_ld_elflib.h: the header file that contains the API declaration.
+ * @see LOS_LdDestroy
+ * @since Huawei LiteOS V100R001C00
+ */
+extern VOID *LOS_FindSymByName(VOID *handle, CHAR *name);
+
+/**
+ * @ingroup los_dynload
+ * @brief Add a default path.
+ *
+ * @par Description:
+ * This API is used to add a path to default paths.
+ * @attention
+ *
+ *
+ * @param path [IN] Path to be added to default paths.
+ *
+ * @retval #LOS_NOK The path is added unsuccessfully.
+ * @retval #LOS_OK The path is added successfully.
+ * @par Dependency:
+ * - los_ld_elflib.h: the header file that contains the API declaration.
+ * @see LOS_FindSymByName | LOS_LdDestroy
+ * @since Huawei LiteOS V100R001C00
+ */
+extern INT32 LOS_PathAdd(CHAR *path);
+/*通过调用LOS_PathAdd函数并传递一个路径,可以将该路径添加到动态库搜索路径中。
+在动态链接库加载时,系统会按照一定的顺序搜索动态库*/
+/**
+ * @ingroup los_dynload
+ * @brief Set the memory pool address used by dynload
+ *
+ * @par Description:
+ * This API is used to set the memory pool address used by dynload.
+ * @attention
+ *
+ * - The parameter passed to this API should be a legal memory pool address by managed with LiteOS's memory
+ * algorithm, and whose value is outside of the LiteOS system memory
+ *
+ *
+ * @param memPool [IN] the memory pool address.
+ *
+ * @retval TRUE Set successful.
+ * @retval FLASE Set failed.
+ * @par Dependency:
+ * - los_ld_elflib.h: the header file that contains the API declaration.
+ * @see LOS_ModuleUnload
+ * @since Huawei LiteOS V200R002C00
+ */
+extern BOOL LOS_DynMemPoolSet(VOID *memPool);
+/*通过调用LOS_DynMemPoolSet函数并传递一个内存池指针,
+可以设置动态内存池,用于在加载和执行动态链接库时分配内存。动态链接库可能
+需要在运行时分配内存来存储数据和执行代码,因此需要提供一个合适的内存池。*/
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#endif /* _LOS_LD_ELFLIB_H */
diff --git a/kkk/los_list.h b/kkk/los_list.h
new file mode 100644
index 0000000..3bbc961
--- /dev/null
+++ b/kkk/los_list.h
@@ -0,0 +1,545 @@
+/* ----------------------------------------------------------------------------
+ * Copyright (c) Huawei Technologies Co., Ltd. 2013-2019. All rights reserved.
+ * Description: Doubly linked list
+ * Author: Huawei LiteOS Team
+ * Create: 2013-01-01
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * --------------------------------------------------------------------------- */
+
+/**
+ * @defgroup los_list Doubly linked list
+ * @ingroup kernel
+ */
+
+#ifndef _LOS_LIST_H
+#define _LOS_LIST_H
+
+#include "los_typedef.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+/**
+ * @ingroup los_list
+ * Structure of a node in a doubly linked list.
+ */
+typedef struct LOS_DL_LIST {
+ struct LOS_DL_LIST *pstPrev; /**< Current node's pointer to the previous node */
+ struct LOS_DL_LIST *pstNext; /**< Current node's pointer to the next node */
+} LOS_DL_LIST;
+/*这种结构体通常用于实现双向链表数据结构。
+通过在每个节点中嵌入LOS_DL_LIST结构体,
+可以将多个节点连接起来形成链表。
+*/
+
+/**
+ * @ingroup los_list
+ * @brief Initialize the input node to a doubly linked list.
+ *
+ * @par Description:
+ * This API is used to initialize the input node (the first parameter list) to
+ * a doubly linked list.
+ * @attention
+ * The parameter passed in should be a legal pointer.
+ *
+ * @param list [IN] A node in a doubly linked list.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_list.h: the header file that contains the API declaration.
+ * @see LOS_DL_LIST_HEAD
+ * @since Huawei LiteOS V100R001C00
+ */
+LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListInit(LOS_DL_LIST *list)
+{
+ list->pstNext = list;
+ list->pstPrev = list;
+}
+/*这段代码定义了一个静态内联函数LOS_ListInit,
+该函数接受一个指向LOS_DL_LIST结构体的指针list作为参数,没有返回值。
+
+函数的作用是将传入的链表初始化为空,即将链表头节点的pstNext和pstPrev指
+针都指向头节点本身,表示链表中没有其他节点。*/
+/**
+ * @ingroup los_list
+ * @brief Point to the next node of the current node.
+ *
+ * @par Description:
+ * This API is used to point to the next node of the current node.
+ * @attention
+ * None.
+ *
+ * @param object [IN] Type #LOS_DL_LIST * The node in the doubly linked list.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_list.h: the header file that contains the API declaration.
+ * @see LOS_DL_LIST_LAST
+ * @since Huawei LiteOS V100R001C00
+ */
+#define LOS_DL_LIST_FIRST(object) ((object)->pstNext)
+/*这段代码定义了一个宏LOS_DL_LIST_FIRST(object),
+它接受一个指向LOS_DL_LIST结构体的指针object作为参数,
+并返回object指向的节点的下一个节点的指针,即链表中的第一个节点。
+
+这个宏的作用是方便地获取链表中的第一个节点,通过宏展开后,
+可以直接访问链表头节点的下一个节点。*/
+/**
+ * @ingroup los_list
+ * @brief Point to the previous node of the current node.
+ *
+ * @par Description:
+ * This API is used to point to the previous node of the current node.
+ * @attention
+ * None.
+ *
+ * @param object [IN] Type #LOS_DL_LIST * The node in the doubly linked list.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_list.h: the header file that contains the API declaration.
+ * @see LOS_DL_LIST_FIRST
+ * @since Huawei LiteOS V100R001C00
+ */
+#define LOS_DL_LIST_LAST(object) ((object)->pstPrev)
+/*这段代码是一个宏定义,用于获取双向链表中指定节点的前一个节点。
+在这里,传入的参数 object 是一个指向双向链表节点的指针,
+pstPrev 是该节点中指向前一个节点的指针。
+该宏的功能是返回指定节点的前一个节点的指针。*/
+/**
+ * @ingroup los_list
+ * @brief Insert a new node to a doubly linked list.
+ *
+ * @par Description:
+ * This API is used to insert a new node after the list node to a doubly linked list.
+ * @attention
+ * The parameters passed in should be legal pointers.
+ *
+ * @param list [IN] Doubly linked list which the new node will be inserted in.
+ * @param node [IN] The new node to be inserted.
+ *
+ * @retval None
+ * @par Dependency:
+ * - los_list.h: the header file that contains the API declaration.
+ * @see LOS_ListDelete | LOS_ListTailInsert | LOS_ListHeadInsert
+ * @since Huawei LiteOS V100R001C00
+ */
+LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListAdd(LOS_DL_LIST *list, LOS_DL_LIST *node)
+{
+ node->pstNext = list->pstNext;
+ node->pstPrev = list;
+ list->pstNext->pstPrev = node;
+ list->pstNext = node;
+}
+/*该函数将新节点插入到链表头部,具体步骤如下:
+
+把新节点的 next 指针指向链表头部的下一个节点。
+把新节点的 prev 指针指向链表头部。
+把原链表头部的下一个节点的 prev 指针指向新节点。
+把链表头部的 next 指针指向新节点。
+通过这些步骤,新节点就被成功地添加到了链表头部。*/
+/**
+ * @ingroup los_list
+ * @brief Insert a node to a doubly linked list.
+ *
+ * @par Description:
+ * This API is used to insert a new node before the list node to a doubly linked list.
+ * @attention
+ * The parameters passed in should be legal pointers.
+ *
+ * @param list [IN] Doubly linked list which the new node will be inserted in.
+ * @param node [IN] The new node to be inserted.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_list.h: the header file that contains the API declaration.
+ * @see LOS_ListAdd | LOS_ListHeadInsert
+ * @since Huawei LiteOS V100R001C00
+ */
+LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListTailInsert(LOS_DL_LIST *list, LOS_DL_LIST *node)
+{
+ LOS_ListAdd(list->pstPrev, node);
+}
+/*在该函数中,使用了宏定义 LOS_DL_LIST 来表示链表节点,
+使用了 STATIC INLINE 关键字来定义内联函数,以提高代码执行效率。
+函数的实现非常简单,只需调用双向链表的插入操作 LOS_ListAdd,
+将新节点添加到链表头部的前一个节点即可。*/
+/**
+ * @ingroup los_list
+ * @brief Insert a node to a doubly linked list.
+ *
+ * @par Description:
+ * This API is used to insert a new node after the list node to a doubly linked list.
+ * It is same with #LOS_ListAdd.
+ * @attention
+ * The parameters passed in should be legal pointers.
+ *
+ * @param list [IN] Doubly linked list which the new node will be inserted in.
+ * @param node [IN] The new node to be inserted.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_list.h: the header file that contains the API declaration.
+ * @see LOS_ListAdd | LOS_ListTailInsert
+ * @since Huawei LiteOS V100R001C00
+ */
+LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListHeadInsert(LOS_DL_LIST *list, LOS_DL_LIST *node)
+{
+ LOS_ListAdd(list, node);
+}
+
+/**
+ * @ingroup los_list
+ * @brief Delete a specified node from a doubly linked list.
+ *
+ * @par Description:
+ * This API is used to delete a specified node from a doubly linked list.
+ * @attention
+ * The parameter passed in should be a legal pointer.
+ *
+ * @param node [IN] Node to be deleted.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_list.h: the header file that contains the API declaration.
+ * @see LOS_ListAdd
+ * @since Huawei LiteOS V100R001C00
+ */
+LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListDelete(LOS_DL_LIST *node)
+{
+ node->pstNext->pstPrev = node->pstPrev;
+ node->pstPrev->pstNext = node->pstNext;
+ node->pstNext = NULL;
+ node->pstPrev = NULL;
+}
+/*该函数的实现非常简单,具体步骤如下:
+
+把被删除节点的 next 节点的 prev 指针指向被删除节点的 prev 节点。
+把被删除节点的 prev 节点的 next 指针指向被删除节点的 next 节点。
+清空被删除节点的 next 指针和 prev 指针。
+通过这些步骤,被指定的节点就从链表中被成功地删除了。*/
+/**
+ * @ingroup los_list
+ * @brief Identify whether a specified doubly linked list is empty or not.
+ *
+ * @par Description:
+ * This API is used to judge whether a doubly linked list is empty or not. It
+ * returns a Boolean value.
+ * @attention
+ * The parameter passed in should be a legal pointer.
+ *
+ * @param list [IN] Doubly linked list.
+ *
+ * @retval #TRUE The doubly linked list is empty.
+ * @retval #FALSE The doubly linked list is not empty.
+ * @par Dependency:
+ * - los_list.h: the header file that contains the API declaration.
+ * @since Huawei LiteOS V100R001C00
+ */
+LITE_OS_SEC_ALW_INLINE STATIC INLINE BOOL LOS_ListEmpty(LOS_DL_LIST *list)
+{
+ return (BOOL)(list->pstNext == list);
+}
+/*具体步骤如下:
+
+判断链表头部的 pstNext 指针是否等于链表头部本身。
+如果相等,返回 TRUE(表示链表为空)。
+如果不相等,返回 FALSE(表示链表不为空)。
+通过这些步骤,可以判断链表是否为空。*/
+/**
+ * @ingroup los_list
+ * @brief Obtain the offset of a structure member relative to the structure start address.
+ *
+ * @par Description:
+ * This API is used to obtain the offset of the structure member (member) relative to
+ * the start address of the structure (type). And return the offset of #UINTPTR type.
+ * @attention
+ * None.
+ *
+ * @param type [IN] Structure name.
+ * @param member [IN] The structure member name which needs to measure the offset.
+ *
+ * @retval #UINTPTR Offset of the member relative to the structure start address.
+ * @par Dependency:
+ * - los_list.h: the header file that contains the API declaration.
+ * @since Huawei LiteOS V100R001C00
+ */
+#define LOS_OFF_SET_OF(type, member) ((UINTPTR)&((type *)0)->member)
+
+/* Obsolete API, please use LOS_OFF_SET_OF instead */
+#define OFFSET_OF_FIELD(type, field) LOS_OFF_SET_OF(type, field)
+/*这些宏的作用是帮助程序员在编写代码时可以方便地获取结构体成员的偏移量。
+通常情况下,结构体成员的偏移量用于在程序中进行内存操作,
+比如根据结构体的指针和成员的偏移量,
+可以获取到该成员的地址或修改该成员的值。*/
+/**
+ * @ingroup los_list
+ * @brief Obtain the pointer to a structure that contains a doubly linked list.
+ *
+ * @par Description:
+ * This API is used to obtain the pointer to a structure that contains the doubly
+ * linked list which the first parameter item specified.
+ * @attention
+ * None.
+ *
+ * @param item [IN] Type #LOS_DL_LIST * The node of the doubly linked list.
+ * @param type [IN] Structure name.
+ * @param member [IN] The doubly linked list name in the structure.
+ *
+ * @retval The pointer to the structure that contains the doubly linked list. And
+ * the doubly linked list has the node of the first parameter item.
+ * @par Dependency:
+ * - los_list.h: the header file that contains the API declaration.
+ * @see LOS_DL_LIST_FOR_EACH_ENTRY | LOS_DL_LIST_FOR_EACH_ENTRY_SAFE
+ * @since Huawei LiteOS V100R001C00
+ */
+#define LOS_DL_LIST_ENTRY(item, type, member) \
+ ((type *)(VOID *)((CHAR *)(item) - LOS_OFF_SET_OF(type, member)))
+
+/**
+ * @ingroup los_list
+ * @brief Traverse a doubly linked list which is included in a given type structure.
+ *
+ * @par Description:
+ * This API is used to traverse a doubly linked list which is included in a given type
+ * structure. The API is a loop. The start node of the doubly linked list is the second
+ * parameter list. And in each loop, the obtained pointer to a structure that contains
+ * the list is outputted in the first parameter item.
+ * @attention
+ * None.
+ *
+ * @param item [IN/OUT] The pointer to the structure that contains the doubly linked list.
+ * @param list [IN] Type #LOS_DL_LIST * The start node of the doubly linked list to
+ * be traversed.
+ * @param type [IN] Structure name.
+ * @param member [IN] The doubly linked list name in the structure.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_list.h: the header file that contains the API declaration.
+ * @see LOS_DL_LIST_ENTRY | LOS_DL_LIST_FOR_EACH_ENTRY_SAFE | LOS_DL_LIST_FOR_EACH
+ * @since Huawei LiteOS V100R001C00
+ */
+#define LOS_DL_LIST_FOR_EACH_ENTRY(item, list, type, member) \
+ for (item = LOS_DL_LIST_ENTRY((list)->pstNext, type, member); \
+ &(item)->member != (list); \
+ item = LOS_DL_LIST_ENTRY((item)->member.pstNext, type, member))
+/*宏的实现通过 for 循环来实现链表的遍历,具体步骤如下:
+
+首先使用 LOS_DL_LIST_ENTRY 宏获取链表头部节点的指针,并将其赋值给 item 变量,从而初始化遍历的起始位置。
+接着判断条件 &(item)->member != (list),当遍历到链表末尾时,即链表头部时结束遍历,否则继续循环。
+在循环体内,执行对当前节点的操作,并使用 LOS_DL_LIST_ENTRY 宏获取下一个节点的指针,从而实现链表的顺序遍历。
+通过这些步骤,可以方便地遍历双向链表中的每个节点,并对每个节点执行相应的操作。*/
+/**
+ * @ingroup los_list
+ * @brief Traverse a doubly linked list which is included in a given type structure. And
+ * it is safe against removal of list entry.
+ *
+ * @par Description:
+ * This API is used to traverse a doubly linked list which is included in a given type
+ * structure. The API is a loop. The start node of the doubly linked list is the third
+ * parameter list. And in each loop, the obtained pointer to a structure that contains
+ * the list is outputted in the first parameter item. And the next node is outputted in
+ * the second parameter next.
+ * @attention
+ * None.
+ *
+ * @param item [IN/OUT] The pointer to the structure that contains the doubly linked list.
+ * @param next [IN/OUT] The pointer to the structure that contains the next node of the
+ * doubly linked list.
+ * @param list [IN] Type #LOS_DL_LIST * The start node of the doubly linked list to
+ * be traversed.
+ * @param type [IN] Structure name.
+ * @param member [IN] The doubly linked list name in the structure.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_list.h: the header file that contains the API declaration.
+ * @see LOS_DL_LIST_ENTRY | LOS_DL_LIST_FOR_EACH_ENTRY | LOS_DL_LIST_FOR_EACH_SAFE
+ * @since Huawei LiteOS V100R001C00
+ */
+#define LOS_DL_LIST_FOR_EACH_ENTRY_SAFE(item, next, list, type, member) \
+ for (item = LOS_DL_LIST_ENTRY((list)->pstNext, type, member), \
+ next = LOS_DL_LIST_ENTRY((item)->member.pstNext, type, member); \
+ &(item)->member != (list); \
+ item = next, next = LOS_DL_LIST_ENTRY((item)->member.pstNext, type, member))
+/*该宏的功能是按顺序遍历链表中的每个节点,并对每个节点执行指定的操作。其参数包括:
+
+item:表示当前遍历到的节点
+next:表示下一个节点的指针
+list:表示链表的头部
+type:表示链表节点所在的结构体类型
+member:表示链表节点在结构体中的成员名*/
+/**
+ * @ingroup los_list
+ * @brief Iterate over a doubly linked list of given type, and call hook for any extra procedures every time.
+ *
+ * @par Description:
+ * This API is used to iterate over a doubly linked list of given type,
+ * and call hook for any extra procedures every time.
+ * @attention
+ * None.
+ *
+ * @param item [IN/OUT] Pointer to the structure that contains the doubly linked list that is to be traversed.
+ * @param list [IN] Pointer to the doubly linked list to be traversed.
+ * @param type [IN] Structure name.
+ * @param member [IN] Member name of the doubly linked list in the structure.
+ * @param hook [IN] Hook for extra procedures which will be called every time when dev is fetched.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_list.h: the header file that contains the API declaration.
+ * @see LOS_DL_LIST_ENTRY | LOS_DL_LIST_FOR_EACH_ENTRY
+ * @since Huawei LiteOS V200R005C10
+ */
+#define LOS_DL_LIST_FOR_EACH_ENTRY_HOOK(item, list, type, member, hook) \
+ for (item = LOS_DL_LIST_ENTRY((list)->pstNext, type, member), hook; \
+ &(item)->member != (list); \
+ item = LOS_DL_LIST_ENTRY((item)->member.pstNext, type, member), hook)
+/*该宏的功能是按顺序遍历链表中的每个节点,并在每个节点遍历之前执行指定的钩子函数。其参数包括:
+
+item:表示当前遍历到的节点
+list:表示链表的头部
+type:表示链表节点所在的结构体类型
+member:表示链表节点在结构体中的成员名
+hook:表示要执行的钩子函数*/
+/**
+ * @ingroup los_list
+ * @brief Delete a specified node from a doubly linked list and reinitialize the node.
+ *
+ * @par Description:
+ * This API is used to delete a specified node (the first parameter list) from the doubly
+ * linked list. And reinitialize the deleted node to a doubly linked list.
+ *
+ * @attention
+ * The parameter passed in should be a legal pointer.
+ *
+ * @param list [IN] Node to be deleted and reinitialize to a doubly linked list.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_list.h: the header file that contains the API declaration.
+ * @see LOS_ListInit | LOS_ListDelete
+ * @since Huawei LiteOS V100R001C00
+ */
+LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListDelInit(LOS_DL_LIST *list)
+{
+ list->pstNext->pstPrev = list->pstPrev;
+ list->pstPrev->pstNext = list->pstNext;
+ LOS_ListInit(list);
+}
+/**/
+/**
+ * @ingroup los_list
+ * @brief Traverse a doubly linked list.
+ *
+ * @par Description:
+ * This API is used to traverse a doubly linked list. The API is a loop. The start node of the
+ * doubly linked list is the second parameter list. And in each loop, the obtained pointer to
+ * the next node of the doubly linked list is outputted in the first parameter item.
+ * @attention
+ * None.
+ *
+ * @param item [IN/OUT] Type #LOS_DL_LIST * The pointer to the next node in the doubly
+ * linked list.
+ * @param list [IN] Type #LOS_DL_LIST * The pointer to the node of the doubly linked
+ * list to be traversed.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_list.h: the header file that contains the API declaration.
+ * @see LOS_DL_LIST_FOR_EACH_SAFE | LOS_DL_LIST_FOR_EACH_ENTRY
+ * @since Huawei LiteOS V100R001C00
+ */
+#define LOS_DL_LIST_FOR_EACH(item, list) \
+ for (item = (list)->pstNext; \
+ (item) != (list); \
+ item = (item)->pstNext)
+/*宏的实现通过 for 循环来实现链表的遍历,具体步骤如下:
+
+在循环初始化部分,将 item 初始化为链表头部节点的下一个节点,即 (list)->pstNext。
+在循环条件中,判断条件 (item) != (list),当 item 等于链表头部时,即遍历到链表末尾时结束遍历,否则继续循环。
+在每次循环结束之后,将 item 更新为下一个节点的指针,即 (item)->pstNext。
+通过这些步骤,可以方便地遍历双向链表中的每个节点,并在循环体内对每个节点执行指定的操作。*/
+/**
+ * @ingroup los_list
+ * @brief Traverse a doubly linked list safe against removal of list entry.
+ *
+ * @par Description:
+ * This API is used to traverse a doubly linked list safe against removal of list entry. The
+ * API is a loop. The start node of the doubly linked list is the third parameter list. And
+ * in each loop, the obtained pointer to the next node of the doubly linked list is outputted
+ * in the first parameter item. And the next node of the the node specified by first parameter
+ * item is outputted in the second parameter next.
+ * @attention
+ * None.
+ *
+ * @param item [IN/OUT] Type #LOS_DL_LIST * The pointer to the next node in the doubly
+ * linked list.
+ * @param next [IN/OUT] Type #LOS_DL_LIST * The pointer to the next node of the the node
+ * specified by first parameter item.
+ * @param list [IN] Type #LOS_DL_LIST * The pointer to the node of the doubly linked
+ * list to be traversed.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_list.h: the header file that contains the API declaration.
+ * @see LOS_DL_LIST_FOR_EACH | LOS_DL_LIST_FOR_EACH_ENTRY_SAFE
+ * @since Huawei LiteOS V100R001C00
+ */
+#define LOS_DL_LIST_FOR_EACH_SAFE(item, next, list) \
+ for (item = (list)->pstNext, next = (item)->pstNext; \
+ (item) != (list); \
+ item = next, next = (item)->pstNext)
+
+/**
+ * @ingroup los_list
+ * @brief Initialize a double linked list.
+ *
+ * @par Description:
+ * This API is used to initialize the input node (the parameter list) to a double linked
+ * list. The difference with LOS_ListInit is that the parameter list is not a pointer while
+ * in LOS_ListInit it is a pointer.
+ * @attention
+ * None.
+ *
+ * @param list [IN] Type #LOS_DL_LIST A node to be initialized to a doubly linked list.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_list.h: the header file that contains the API declaration.
+ * @see LOS_ListInit
+ * @since Huawei LiteOS V100R001C00
+ */
+#define LOS_DL_LIST_HEAD(list) LOS_DL_LIST list = { &(list), &(list) }
+/*通过这个宏,可以方便地定义和初始化一个双向链表的头部节点,为链表的后续操作提供了便利。*/
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#endif /* _LOS_LIST_H */
diff --git a/kkk/los_lms.h b/kkk/los_lms.h
new file mode 100644
index 0000000..6463dc9
--- /dev/null
+++ b/kkk/los_lms.h
@@ -0,0 +1,86 @@
+/* ----------------------------------------------------------------------------
+ * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
+ * Description: Lite Memory Sanitizer HeadFile
+ * Author: Huawei LiteOS Team
+ * Create: 2020-09-01
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * --------------------------------------------------------------------------- */
+
+#ifndef _LOS_LMS_H
+#define _LOS_LMS_H
+
+#include "los_typedef.h"
+#include "securec.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#ifdef LOSCFG_KERNEL_LMS
+// Start: Kernel Address Sanitizer(KASAN) for LiteOS
+// Redefine memcpy and other memory opration functions to enable KASAN check ability for LiteOS
+// This is a debug feature and only available when LOSCFG_KERNEL_LMS is configured to Y
+#define memcpy KasanMemcpy
+#define memmove KasanMemmove
+#define strcat KasanStrcat
+#define strcpy KasanStrcpy
+
+#define memcpy_s KasanMemcpySec
+#define memmove_s KasanMemmoveSec
+#define strcat_s KasanStrcatSec
+#define strcpy_s KasanStrcpySec
+/*使用#define预处理指令来重新定义标准库函数的名称。这种技术通常用于调试或测试目的,或者提供这些函数的自定义实现。
+代码片段中,函数memcpy、memmove、strcat和strcpy被重新定义为KasanMemcpy、
+KasanMemmove、KasanStrcat和KasanStrcpy。类似地,memcpy_s、memmove_s、strcat_s和strcpy_s
+被重新定义为KasanMemcpySec、KasanMemmoveSec、KasanStrcatSec和KasanStrcpySec。*/
+// End: Kernel Address Sanitizer(KASAN) for LiteOS
+
+VOID *KasanMemcpy(VOID *__restrict dest, const VOID *__restrict src, size_t copyAmount);
+VOID *KasanMemmove(VOID *dest, const VOID *src, size_t len);
+CHAR *KasanStrcat(CHAR *s, const CHAR *append);
+CHAR *KasanStrcpy(CHAR *dest, const CHAR *src);
+/*KasanMemcpy:类似于标准库中的memcpy,用于在内存中复制一定数量的数据。可能会包含额外的内存访问检查。
+KasanMemmove:类似于标准库中的memmove,用于在内存中移动一定数量的数据。同样可能包含额外的内存访问检查。
+KasanStrcat:类似于标准库中的strcat,用于将一个字符串附加到另一个字符串的末尾。可能包含额外的内存访问检查。
+KasanStrcpy:类似于标准库中的strcpy,用于将一个字符串复制到另一个字符串。同样可能包含额外的内存访问检查。*/
+errno_t KasanMemcpySec(VOID *dest, size_t destMax, const VOID *src, size_t copyAmount);
+errno_t KasanMemmoveSec(VOID *dest, size_t destMax, const VOID *src, size_t len);
+errno_t KasanStrcatSec(CHAR *s, size_t destMax, const CHAR *append);
+errno_t KasanStrcpySec(CHAR *dest, size_t destMax, const CHAR *src);
+/*主要是用于处理字符串和内存拷贝操作。这里的 destMax 参数通常表示目标缓冲区的最大长度,以防止缓冲区溢出等安全问题。
+
+KasanMemcpySec:类似于标准库中的memcpy,用于在内存中复制一定数量的数据。增加了目标缓冲区大小的参数,以保证不会发生缓冲区溢出。
+KasanMemmoveSec:类似于标准库中的memmove,用于在内存中移动一定数量的数据。同样增加了目标缓冲区大小的参数。
+KasanStrcatSec:类似于标准库中的strcat,用于将一个字符串附加到另一个字符串的末尾。增加了目标缓冲区大小的参数,以保证不会发生缓冲区溢出。
+KasanStrcpySec:类似于标准库中的strcpy,用于将一个字符串复制到另一个字符串。同样增加了目标缓冲区大小的参数。*/
+#endif /* LOSCFG_KERNEL_LMS */
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#endif /* _LOS_LMS_H */
diff --git a/kkk/los_lockdep.h b/kkk/los_lockdep.h
new file mode 100644
index 0000000..ce768a9
--- /dev/null
+++ b/kkk/los_lockdep.h
@@ -0,0 +1,173 @@
+/* ----------------------------------------------------------------------------
+ * Copyright (c) Huawei Technologies Co., Ltd. 2018-2019. All rights reserved.
+ * Description: Lock Dependency Check.
+ * Author: Huawei LiteOS Team
+ * Create: 2018-10-18
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * --------------------------------------------------------------------------- */
+
+/**
+ * @defgroup los_lockdep lockdep
+ * @ingroup kernel
+ */
+
+#ifndef _LOS_LOCKDEP_H
+#define _LOS_LOCKDEP_H
+
+#include "los_config.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+typedef struct Spinlock SPIN_LOCK_S;
+#ifdef LOSCFG_KERNEL_SMP_LOCKDEP
+
+#define MAX_LOCK_DEPTH 16U
+
+enum LockDepErrType {
+ LOCKDEP_SUCEESS = 0,
+ LOCKDEP_ERR_DOUBLE_LOCK,
+ LOCKDEP_ERR_DEAD_LOCK,
+ LOCKDEP_ERR_UNLOCK_WITHOUT_LOCK,
+ /* overflow, needs expand */
+ LOCKDEP_ERR_OVERFLOW,
+};
+/*这是一个枚举类型 LockDepErrType,用于表示在锁依赖性检查中可能发生的不同错误类型。下面是该枚举类型定义的各个取值及其含义:
+
+LOCKDEP_SUCCESS:锁依赖性检查成功,没有发现错误。
+LOCKDEP_ERR_DOUBLE_LOCK:发现了重复加锁的错误。表示在某个线程中多次对同一把锁进行了加锁操作。
+LOCKDEP_ERR_DEAD_LOCK:发现了死锁的错误。表示在不同线程之间存在循环的锁依赖关系,导致了死锁的发生。
+LOCKDEP_ERR_UNLOCK_WITHOUT_LOCK:发现了未解锁的错误。表示在某个线程中出现了解锁操作,但该线程之前并未对对应的锁进行过加锁操作。
+LOCKDEP_ERR_OVERFLOW:溢出错误。表示枚举类型需要扩展,因为当前定义的取值已经无法满足需求。*/
+typedef struct {
+ VOID *lockPtr;
+ VOID *lockAddr;
+ UINT64 waitTime;
+ UINT64 holdTime;
+} HeldLocks;
+/*这个结构体主要用于在锁依赖性分析和调试过程中记录当前线程持有的锁的相关信息。通过记录这些信息,
+可以对锁的使用情况进行监控和分析,以便发现潜在的死锁、竞争条件等问题。
+lockPtr:表示持有的锁的指针。它是一个 VOID* 类型的指针,通常用于指向被持有的锁的内存地址。
+lockAddr:表示持有的锁的地址。它是一个 VOID* 类型的指针,通常用于指向锁对象的内存地址。
+waitTime:表示等待该锁的时间。它是一个 UINT64 类型的变量,通常表示在获取该锁之前,当前线程等待该锁的时间。
+holdTime:表示持有该锁的时间。它是一个 UINT64 类型的变量,通常表示当前线程已经持有该锁的时间。*/
+typedef struct {
+ VOID *waitLock;
+ INT32 lockDepth;
+ HeldLocks heldLocks[MAX_LOCK_DEPTH];
+} LockDep;
+/*这个结构体主要用于在锁依赖性分析和调试过程中记录当前线程的锁依赖关系。
+通过记录当前线程正在等待的锁、持有的锁的深度以及每个层次的锁的详细信息,
+可以对锁的使用情况进行监控和分析,以便发现潜在的死锁、竞争条件等问题。*/
+/**
+ * @ingroup los_lockdep
+ *
+ * @par Description:
+ * This API is used to check dead lock in spinlock.
+ * @attention
+ *
+ * - The parameter passed in should be ensured to be a legal pointer.
+ *
+ *
+ * @param lock [IN] point to a SPIN_LOCK_S.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_lockdep.h: the header file that contains the API declaration.
+ * @see
+ * @since Huawei LiteOS V200R003C00
+ */
+extern VOID OsLockDepCheckIn(const SPIN_LOCK_S *lock);
+/*函数名称为 OsLockDepCheckIn,参数类型为 const SPIN_LOCK_S* lock,返回类型为 VOID。该函数的作用是将指定
+的自旋锁 lock 添加到锁依赖性检查中,用于进行锁依赖性的分析和调试。*/
+/**
+ * @ingroup los_lockdep
+ *
+ * @par Description:
+ * This API is used to trace when a spinlock locked.
+ * @attention
+ *
+ * - The parameter passed in should be ensured to be a legal pointer.
+ *
+ *
+ * @param lock [IN] point to a SPIN_LOCK_S.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_lockdep.h: the header file that contains the API declaration.
+ * @see
+ * @since Huawei LiteOS V200R003C00
+ */
+extern VOID OsLockDepRecord(SPIN_LOCK_S *lock);
+
+/**
+ * @ingroup los_lockdep
+ *
+ * @par Description:
+ * This API is used to trace when a spinlock unlocked.
+ * @attention
+ *
+ * - The parameter passed in should be ensured to be a legal pointer.
+ *
+ *
+ * @param lock [IN] point to a SPIN_LOCK_S.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_lockdep.h: the header file that contains the API declaration.
+ * @see
+ * @since Huawei LiteOS V200R003C00
+ */
+extern VOID OsLockDepCheckOut(SPIN_LOCK_S *lock);
+/*函数名称为 OsLockDepCheckOut,参数类型为 SPIN_LOCK_S* lock,返回类型为 VOID。该函数的作用
+是从锁依赖性检查中移除指定的自旋锁 lock,用于结束对该锁的依赖性分析和调试。*/
+/**
+ * @ingroup los_lockdep
+ *
+ * @par Description:
+ * This API is used to clear lockdep record of current task.
+ * @attention
+ *
+ *
+ * @param None
+ * @retval None.
+ * @par Dependency:
+ * - los_lockdep.h: the header file that contains the API declaration.
+ * @see
+ * @since Huawei LiteOS V200R003C00
+ */
+extern VOID OsLockdepClearSpinlocks(VOID);
+
+#endif /* LOSCFG_KERNEL_SMP_LOCKDEP */
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif
+#endif /* __cplusplus */
+#endif /* _LOS_LOCKDEP_H */
diff --git a/kkk/los_lowpower.h b/kkk/los_lowpower.h
new file mode 100644
index 0000000..936b791
--- /dev/null
+++ b/kkk/los_lowpower.h
@@ -0,0 +1,381 @@
+/* ----------------------------------------------------------------------------
+ * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
+ * Description: Low-power Framework.
+ * Author: Huawei LiteOS Team
+ * Create: 2020-09-19
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * --------------------------------------------------------------------------- */
+
+/* *
+ * @defgroup los_lowpower lowpower_framework
+ * @ingroup kernel
+ */
+
+#ifndef _LOS_LOWPOWER_H
+#define _LOS_LOWPOWER_H
+
+#include "los_base.h"
+#include "los_sys.h"
+#include "los_err.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+/**
+ * @ingroup los_lowpower
+ *
+ * Intermit modes
+ */
+typedef enum LOS_INTERMIT_MODE {
+ LOS_INTERMIT_NONE = 0,
+ LOS_INTERMIT_LIGHT_SLEEP, /**< Light sleep mode */
+ LOS_INTERMIT_DEEP_SLEEP, /**< Deep sleep mode */
+ LOS_INTERMIT_STANDBY, /**< Standby mode */
+ LOS_INTERMIT_SHUTDOWN, /**< Shutdown mode */
+ LOS_INTERMIT_MAX,
+} LosIntermitMode;
+/*这是一个枚举类型 LOS_INTERMIT_MODE 的定义,包含了几个枚举常量:
+
+LOS_INTERMIT_NONE:表示没有中断模式
+LOS_INTERMIT_LIGHT_SLEEP:表示轻度睡眠模式
+LOS_INTERMIT_DEEP_SLEEP:表示深度睡眠模式
+LOS_INTERMIT_STANDBY:表示待机模式
+LOS_INTERMIT_SHUTDOWN:表示关机模式
+LOS_INTERMIT_MAX:该枚举类型的最大值,用于辅助枚举类型的范围检查*/
+/**
+ * @ingroup los_lowpower
+ *
+ * System main frequency modes
+ */
+typedef enum LOS_FREQ_MODE {
+ LOS_SYS_FREQ_SUPER = 0, /**< Super high freq */
+ LOS_SYS_FREQ_HIGH, /**< High freq */
+ LOS_SYS_FREQ_NORMAL, /**< Normal freq */
+ LOS_SYS_FREQ_LOW, /**< Low freq */
+ LOS_SYS_FREQ_MAX,
+} LosFreqMode;
+/*这是另一个枚举类型 LOS_FREQ_MODE 的定义,包含了几个枚举常量:
+
+LOS_SYS_FREQ_SUPER:表示超高频模式
+LOS_SYS_FREQ_HIGH:表示高频模式
+LOS_SYS_FREQ_NORMAL:表示正常频率模式
+LOS_SYS_FREQ_LOW:表示低频模式
+LOS_SYS_FREQ_MAX:该枚举类型的最大值,用于辅助枚举类型的范围检查*/
+typedef UINT32 (*LowpowerExternalVoterHandle)(VOID);
+
+STATIC INLINE BOOL FreqHigher(LosFreqMode freq1, LosFreqMode freq2)
+{
+ return freq1 < freq2;
+}
+
+/**
+ * @ingroup los_lowpower
+ *
+ * Define the structure of the power manager operations.
+ */
+typedef struct {
+ VOID (*process)(VOID); /**< Power manager framework entry interface */
+ VOID (*wakeupFromReset)(VOID); /**< Recovery interface used to wakeup from image */
+ VOID (*resumeFromInterrupt)(UINT32); /**< Recovery interface used to wakeup from interrupt */
+ VOID (*changeFreq)(LosFreqMode); /**< System frequency tuning interface, the param is LosFreqMode */
+ VOID (*deepSleepVoteBegin)(VOID); /**< Deep sleep vote mark interface */
+ VOID (*deepSleepVoteEnd)(VOID); /**< Deep sleep vote erase interface */
+ VOID (*deepSleepVoteDelay)(UINT32 tick); /**< Deep sleep vote delay interface, the param is the delayed ticks */
+ VOID (*registerExternalVoter)(UINT32 (*handler)(VOID)); /**< External voter registration interface */
+ UINT32 (*getDeepSleepVoteCount)(VOID); /**< Get deep sleep vote count interface */
+ UINT32 (*getSleepMode)(VOID); /**< Get sleep mode interface, the retval type is LosIntermitMode */
+ VOID (*setSleepMode)(UINT32 mode); /**< Set sleep mode interface, the param type is LosIntermitMode */
+} PowerMgrOps;
+/*这是一个结构体类型 PowerMgrOps 的定义,包含了多个函数指针成员:
+
+process:电源管理框架的入口接口
+wakeupFromReset:从镜像中唤醒的恢复接口
+resumeFromInterrupt:从中断中唤醒的恢复接口
+changeFreq:系统频率调节接口,参数为 LosFreqMode
+deepSleepVoteBegin:深度睡眠投票标记接口
+deepSleepVoteEnd:深度睡眠投票取消接口
+deepSleepVoteDelay:深度睡眠投票延迟接口,参数为延迟的时钟周期数
+registerExternalVoter:注册外部投票者接口,参数为一个函数指针,返回值为 UINT32
+getDeepSleepVoteCount:获取深度睡眠投票计数接口,返回 UINT32
+getSleepMode:获取睡眠模式接口,返回值类型为 LosIntermitMode
+setSleepMode:设置睡眠模式接口,参数类型为 UINT32,表示 LosIntermitMode*/
+/**
+ * @ingroup los_lowpower
+ * @brief System main frequency tuning.
+ *
+ * @par Description:
+ * This API is used to tune the system main frequency.
+ *
+ * @attention None.
+ *
+ * @param freq [IN] The system frequency, corresponding to LosFreqMode.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_lowpower.h: the header file that contains the API declaration.
+ * @see None.
+ * @since Huawei LiteOS V200R005C10
+ */
+extern VOID LOS_PowerMgrChangeFreq(LosFreqMode freq);
+/*这是一个外部声明(extern)的函数 LOS_PowerMgrChangeFreq,
+它接受一个 LosFreqMode 类型的参数 freq,用于改变系统的工作频率。
+根据函数名和参数类型来看,这个函数很可能是用于在系统中切换不同的工作频率模式。*/
+/**
+ * @ingroup los_lowpower
+ * @brief Vote to enter deep sleep.
+ *
+ * @par Description:
+ * This API is used to mark the deep sleep vote. Called when the current state is idle.
+ *
+ * @attention None.
+ *
+ * @param None.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_lowpower.h: the header file that contains the API declaration.
+ * @see None.
+ * @since Huawei LiteOS V200R005C10
+ */
+extern VOID LOS_PowerMgrDeepSleepVoteBegin(VOID);
+
+/**
+ * @ingroup los_lowpower
+ * @brief Erase the deep sleep vote.
+ *
+ * @par Description:
+ * This API is used to erase the deep sleep vote. Called when the current state is busy.
+ *
+ * @attention None.
+ *
+ * @param None.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_lowpower.h: the header file that contains the API declaration.
+ * @see None.
+ * @since Huawei LiteOS V200R005C10
+ */
+extern VOID LOS_PowerMgrDeepSleepVoteEnd(VOID);
+/*这是一个外部声明(extern)的函数 LOS_PowerMgrDeepSleepVoteEnd,它没有任何参数,返回类型为 VOID。根据函数名来看,
+这个函数很可能用于结束深度睡眠投票,即取消之前进行的深度睡眠投票。*/
+/**
+ * @ingroup los_lowpower
+ * @brief Sleep delay vote.
+ *
+ * @par Description:
+ * This API is used to delay sleep vote. Called when the current state busy, but can enter sleep later.
+ *
+ * @attention None.
+ *
+ * @param tick [IN] The sleeptime.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_lowpower.h: the header file that contains the API declaration.
+ * @see None.
+ * @since Huawei LiteOS V200R005C10
+ */
+extern VOID LOS_PowerMgrSleepDelay(UINT32 tick);
+/*这是一个外部声明(extern)的函数 LOS_PowerMgrSleepDelay,它接受一个 UINT32 类型的参数 tick,
+用于在系统中设置睡眠延迟,即指定一定的时钟周期数作为睡眠延迟。*/
+/**
+ * @ingroup los_lowpower
+ * @brief Register the external voter.
+ *
+ * @par Description:
+ * This API is used to register the external voter, provided for developers with special needs.
+ *
+ * @attention None.
+ *
+ * @param UINT32 (*)(VOID) [IN] The external voter.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_lowpower.h: the header file that contains the API declaration.
+ * @see None.
+ * @since Huawei LiteOS V200R005C10
+ */
+extern VOID LOS_PowerMgrRegisterExtVoter(UINT32 (*)(VOID));
+/*这是一个外部声明(extern)的函数 LOS_PowerMgrRegisterExtVoter,
+它接受一个函数指针作为参数,该函数指针指向一个不接受任何参数并返回 UINT32 类型的函数。根据函数名来看,这个函数很可能用于注册外部投票者
+,即将提供的函数指针注册为外部投票者的处理函数。*/
+/**
+ * @ingroup los_lowpower
+ * @brief Get the sleep mode.
+ *
+ * @par Description:
+ * This API is used to get sleep mode. Developers can set different corresponding modes.
+ * according to the actual scene, then perform follow-up operations.
+ *
+ * @attention None.
+ *
+ * @param None.
+ *
+ * @retval #UINT32 Sleep mode, corresponding to LosIntermitMode.
+ * @par Dependency:
+ * - los_lowpower.h: the header file that contains the API declaration.
+ * @see None.
+ * @since Huawei LiteOS V200R005C10
+ */
+extern UINT32 LOS_PowerMgrGetSleepMode(VOID);
+
+/**
+ * @ingroup los_lowpower
+ * @brief Get the deep sleep vote count.
+ *
+ * @par Description:
+ * This API is used to get the deep sleep vote count.
+ *
+ * @attention None.
+ *
+ * @param None.
+ *
+ * @retval #UINT32 Deep sleep vote count.
+ * @par Dependency:
+ * - los_lowpower.h: the header file that contains the API declaration.
+ * @see None.
+ * @since Huawei LiteOS V200R005C10
+ */
+extern UINT32 LOS_PowerMgrGetDeepSleepVoteCount(VOID);
+
+/**
+ * @ingroup los_lowpower
+ * @brief Register power manager operations.
+ *
+ *
+ * @par Description:
+ * This API is used to register power manager operations or customized power manager by developers.
+ *
+ * @attention None.
+ *
+ * @param pmOps [IN] The power manager operations.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_lowpower.h: the header file that contains the API declaration.
+ * @see None.
+ * @since Huawei LiteOS V200R005C10
+ */
+extern VOID LOS_LowpowerInit(const PowerMgrOps *pmOps);
+/*这是一个外部声明(extern)的函数 LOS_LowpowerInit,
+它接受一个 const PowerMgrOps * 类型的指针参数 pmOps,用于初始化低功耗模式下的系统。根据函数名来看,这个函数很可能是用于在系统启动时初始化与低功耗相关的操作和参数,
+以便后续能够进入低功耗状态并正确恢复系统。*/
+/**
+ * @ingroup los_lowpower
+ * @brief Define the lowpower framework process function type.
+ *
+ * @par Description:
+ * This API is used to define the lowpower framework entry function type.
+ *
+ * @attention None.
+ *
+ * @param None.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_lowpower.h: the header file that contains the API declaration.
+ * @see None.
+ * @since Huawei LiteOS V200R005C10
+ */
+typedef VOID (*LowPowerHookFn)(VOID);
+/*这是一个类型定义语句,定义了一个名为 LowPowerHookFn 的函数指针类型。
+该函数指针类型指向一个不接受任何参数并返回 VOID 的函数。
+这种类型的函数指针通常用于注册低功耗模式下的钩子函数,
+以便在进入或退出低功耗模式时执行特定的操作*/
+/**
+ * @ingroup los_lowpower
+ * @brief Register a hook to enter lowpower framework process.
+ *
+ * @par Description:
+ * This API is used to register lowpower framework entry function.
+ *
+ * @attention None.
+ *
+ * @param hook [IN] The lowpower framework hook.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_lowpower.h: the header file that contains the API declaration.
+ * @see None.
+ * @since Huawei LiteOS V200R005C10
+ */
+extern VOID LOS_LowpowerHookReg(LowPowerHookFn hook);
+/*这是一个外部声明(extern)的函数 LOS_LowpowerHookReg,
+它接受一个 LowPowerHookFn 类型的参数 hook,用于注册低功耗模式下的钩子函数。
+根据函数名来看,这个函数很可能用于在系统中注册低功耗模式下的钩子函数,
+以便在进入或退出低功耗模式时执行特定的操作。*/
+/**
+ * @ingroup los_lowpower
+ * @brief Define the lowpower framework wakup function type.
+ *
+ * @par Description:
+ * This API is used to define the lowpower framework wakup function type.
+ *
+ * @attention None.
+ *
+ * @param hwiNum [IN] The interrupt number.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_lowpower.h: the header file that contains the API declaration.
+ * @see None.
+ * @since Huawei LiteOS V200R005C10
+ */
+typedef VOID (*IntWakeupHookFn)(HWI_HANDLE_T hwiNum);
+/*这是一个类型定义语句,定义了一个名为 IntWakeupHookFn 的函数指针类型。
+该函数指针类型指向一个接受 HWI_HANDLE_T 类型参数并返回 VOID 的函数。
+这种类型的函数指针通常用于注册中断唤醒的钩子函数,以便在特定中断唤醒事件发生时执行特定的操作。
+*/
+/**
+ * @ingroup los_lowpower
+ * @brief Register a hook to wakeup from interrupt.
+ *
+ * @par Description:
+ * This API is used to register a recovery function after wakeup from interrupt
+ *
+ * @attention None.
+ *
+ * @param hook [IN] The lowpower wakeup hook.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_lowpower.h: the header file that contains the API declaration.
+ * @see None.
+ * @since Huawei LiteOS V200R005C10
+ */
+extern VOID LOS_IntWakeupHookReg(IntWakeupHookFn hook);
+/*这是一个外部声明(extern)的函数 LOS_IntWakeupHookReg,
+它接受一个 IntWakeupHookFn 类型的参数 hook,用于注册中断唤醒的钩子函数。
+根据函数名来看,这个函数很可能用于在系统中注册中断唤醒的钩子函数,
+以便在特定中断唤醒事件发生时执行特定的操作。
+*/
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+#endif /* _LOS_LOWPOWER_H */
diff --git a/kkk/los_lowpower_impl.h b/kkk/los_lowpower_impl.h
new file mode 100644
index 0000000..4a8be8d
--- /dev/null
+++ b/kkk/los_lowpower_impl.h
@@ -0,0 +1,159 @@
+/* ----------------------------------------------------------------------------
+ * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
+ * Description: Low-power Framework.
+ * Author: Huawei LiteOS Team
+ * Create: 2020-09-19
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * --------------------------------------------------------------------------- */
+
+#ifndef _LOS_LOWPOWER_IMPL_H
+#define _LOS_LOWPOWER_IMPL_H
+
+#include "los_lowpower.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+/**
+ * @ingroup los_lowpower
+ *
+ * Power manager run options
+ */
+typedef struct {
+ VOID (*changeFreq)(UINT8 freq); /**< Tune system frequency */
+ VOID (*enterLightSleep)(VOID); /**< Enter light sleep */
+ VOID (*enterDeepSleep)(VOID); /**< Enter deep sleep */
+ VOID (*setWakeUpTimer)(UINT32 timeout); /**< Set wakeup timer */
+ UINT32 (*withdrawWakeUpTimer)(VOID); /**< Withdraw wakeup timer */
+ UINT32 (*getSleepTime)(VOID); /**< Get sleep time */
+ UINT32 (*selectSleepMode)(UINT32); /**< Select sleep mode, developers can set their own mode selecetion
+ strategy */
+ UINT32 (*preConfig)(VOID); /**< Preconfig, provided for special needs before entering sleep */
+ VOID (*postConfig)(VOID); /**< Postconfig, provided for special needs after wakeup */
+ VOID (*contextSave)(VOID); /**< Context save */
+ VOID (*contextRestore)(VOID); /**< Context restore */
+ UINT32 (*getDeepSleepVoteCount)(VOID); /**< Get deep sleep vote count */
+ UINT32 (*getSleepMode)(VOID); /**< Get sleep mode */
+ VOID (*setSleepMode)(UINT32 mode); /**< Set sleep mode */
+} PowerMgrRunOps;
+/*具体来说,该结构体包含以下函数指针成员:
+
+changeFreq:调整系统频率。
+enterLightSleep:进入轻度睡眠(light sleep)模式。
+enterDeepSleep:进入深度睡眠(deep sleep)模式。
+setWakeUpTimer:设置唤醒定时器。
+withdrawWakeUpTimer:撤销唤醒定时器。
+getSleepTime:获取睡眠时间。
+selectSleepMode:选择进入睡眠模式的策略函数。
+preConfig:提供特殊需要在进入睡眠前进行的预配置。
+postConfig:提供特殊需要在唤醒后进行的后配置。
+contextSave:保存上下文。
+contextRestore:恢复上下文。
+getDeepSleepVoteCount:获取深度睡眠投票计数。
+getSleepMode:获取当前睡眠模式。
+setSleepMode:设置睡眠模式。*/
+/**
+ * @ingroup los_lowpower
+ *
+ * Power manager config, corresponding to mode selection strategies.
+ */
+typedef struct {
+ UINT32 minLightSleepTicks; /**< Min light sleep ticks */
+ UINT32 minDeepSleepTicks; /**< Min deep sleep ticks */
+ UINT32 maxDeepSleepTicks; /**< Max deep sleep ticks */
+} PowerMgrConfig;
+/*minLightSleepTicks:最小轻度睡眠(light sleep)时钟周期数。
+minDeepSleepTicks:最小深度睡眠(deep sleep)时钟周期数。
+maxDeepSleepTicks:最大深度睡眠(deep sleep)时钟周期数。
+这些成员变量可能用于配置功耗管理模块的相关参数,以控制系统进入不同级别的睡眠模式,
+并限制最小和最大的睡眠时长。具体的含义和用法需要根据上下文和使用场景来确定。*/
+/**
+ * @ingroup los_lowpower
+ *
+ * Power manager deep sleep options
+ */
+typedef struct {
+ BOOL (*couldDeepSleep)(VOID); /**< Check whether could enter deep sleep */
+ VOID (*systemWakeup)(VOID); /**< System wakup */
+ BOOL (*suspendPreConfig)(VOID); /**< Suspend preconfig, provided for special needs before entering deep sleep */
+ VOID (*suspendDevice)(VOID); /**< Supend device before entering deep sleep */
+ VOID (*rollback)(VOID); /**< Rollback if failed */
+ VOID (*resumeDevice)(VOID); /**< Resume device after wakeup from deep sleep */
+ VOID (*resumePostConfig)(VOID); /**< Resume postconfig, provided for special needs after wakeup from deep sleep */
+ VOID (*resumeCallBack)(VOID); /**< Resume callback */
+ VOID (*otherCoreResume)(VOID); /**< Other core Resume for multi-core scenes */
+ VOID (*resumeFromReset)(VOID); /**< Resume from image */
+} PowerMgrDeepSleepOps;
+/*couldDeepSleep:检查系统是否可以进入深度睡眠状态。
+systemWakeup:唤醒系统。
+suspendPreConfig:提供特殊需要在进入深度睡眠前进行的暂停预配置。
+suspendDevice:进入深度睡眠前暂停设备。
+rollback:如果进入深度睡眠失败,则回滚。
+resumeDevice:从深度睡眠状态恢复后恢复设备。
+resumePostConfig:提供特殊需要在从深度睡眠状态中恢复后进行的恢复后配置。
+resumeCallBack:恢复回调。
+otherCoreResume:多核场景下,其他核心的恢复方法。
+resumeFromReset:从映像中恢复。*/
+/**
+ * @ingroup los_lowpower
+ *
+ * Power manager parameter
+ */
+typedef struct {
+ PowerMgrRunOps runOps; /**< power manager framework running operations */
+ PowerMgrDeepSleepOps deepSleepOps; /**< power manager deep sleep operations */
+ PowerMgrConfig config; /**< power manager config */
+} PowerMgrParameter;
+/*runOps:类型为 PowerMgrRunOps 的结构体变量,用于描述系统运行状态下的功耗管理操作集合。
+deepSleepOps:类型为 PowerMgrDeepSleepOps 的结构体变量,用于描述系统进入深度睡眠状态下的功耗管理操作集合。
+config:类型为 PowerMgrConfig 的结构体变量,用于配置功耗管理模块的相关参数,控制系统进入不同级别的睡眠模式。
+通过将这些结构体变量组合到 PowerMgrParameter 结构体中,可以实现对系统运行状态和深度睡眠状态下的功耗管理操作进行统一管理和配置。*/
+/**
+ * @ingroup los_lowpower
+ * @brief Init the power manager framework.
+ *
+ * @par Description:
+ * This API is used to init the power manager framework.
+ *
+ * @attention None.
+ *
+ * @param para [IN] The power manager parameter.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_lopower_impl.h: the header file that contains the API declaration.
+ * @see None.
+ * @since Huawei LiteOS V200R005C10
+ */
+extern VOID LOS_PowerMgrInit(const PowerMgrParameter *para);
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#endif // _LOS_LOWPOWER_IMPL_H
diff --git a/kkk/los_membox.h b/kkk/los_membox.h
new file mode 100644
index 0000000..8e0d4e7
--- /dev/null
+++ b/kkk/los_membox.h
@@ -0,0 +1,308 @@
+/* ----------------------------------------------------------------------------
+ * Copyright (c) Huawei Technologies Co., Ltd. 2013-2019. All rights reserved.
+ * Description: LiteOS memory Module HeadFile
+ * Author: Huawei LiteOS Team
+ * Create: 2013-01-01
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * --------------------------------------------------------------------------- */
+
+/**
+ * @defgroup los_membox Static memory
+ * @ingroup kernel
+ */
+
+#ifndef _LOS_MEMBOX_H
+#define _LOS_MEMBOX_H
+
+#include "los_config.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+/**
+ * @ingroup los_membox
+ * @brief Align the input parameter.
+ *
+ * @par Description:
+ * The macro is used to align memAddr based on UINTPTR. memAddr is the input parameter.
+ * @attention
+ * None.
+ *
+ * @param memAddr [IN] The variable that need to be aligned. Usually memAddr is an unsigned integer
+ * or an unsigned long integer on 64-bit platporm.
+ *
+ * @retval The memAddr value after alignment.
+ * @par Dependency:
+ *
+ * - los_membox.h: the header file that contains the API declaration.
+ *
+ * @since Huawei LiteOS V100R001C00
+ */
+#define LOS_MEMBOX_ALLIGNED(memAddr) (((UINTPTR)(memAddr) + sizeof(UINTPTR) - 1) & (~(sizeof(UINTPTR) - 1)))
+
+#ifdef LOSCFG_KERNEL_MEMBOX_STATIC
+/**
+ * @ingroup los_membox
+ * Get next node in static memory pool
+ */
+#define OS_MEMBOX_NEXT(addr, blkSize) (LOS_MEMBOX_NODE *)(VOID *)((UINT8 *)(addr) + (blkSize))
+
+/**
+ * @ingroup los_membox
+ * Head size of each node in staic memory pool
+ */
+#define OS_MEMBOX_NODE_HEAD_SIZE sizeof(LOS_MEMBOX_NODE)
+ /*LOS_MEMBOX_ALLIGNED(memAddr) 宏用于对内存地址进行对齐操作。
+ 它将 memAddr 强制转换为 UINTPTR 类型,然后加上 sizeof(UINTPTR) -
+ 1,再进行按位取反操作,最后与 ~(sizeof(UINTPTR) - 1) 进行按位与运算。
+ 这样可以确保地址按照 sizeof(UINTPTR) 字节对齐。
+
+OS_MEMBOX_NEXT(addr, blkSize) 宏用于获取静态内存池中下一个节点的地址。
+它将 addr 强制转换为 UINT8* 类型,然后加上 blkSize,得到下一个节点的地址。
+
+OS_MEMBOX_NODE_HEAD_SIZE 宏定义了静态内存池中每个节点的头部大小,即 LOS_MEMBOX_NODE 的大小。
+
+这些宏在静态内存池的实现中起到了辅助作用,用于计算和管理内存节点的地址和大小。*/
+/**
+ * @ingroup los_membox
+ * @brief Obtain the size of the static memory pool.
+ *
+ * @par Description:
+ * The macro is used to obtain the size of the static memory pool according to the memory
+ * block size and number.
+ * @attention
+ * None.
+ *
+ * @param blkSize [IN] Type #UINT32 The memory block size of the static memory pool.
+ * @param blkNum [IN] Type #UINT32 The total memory block number of the static memory pool.
+ *
+ * @retval The size of the static memory pool.
+ * @par Dependency:
+ *
+ * - los_membox.h: the header file that contains the API declaration.
+ *
+ * @since Huawei LiteOS V100R001C00
+ */
+#define LOS_MEMBOX_SIZE(blkSize, blkNum) \
+ (sizeof(LOS_MEMBOX_INFO) + (LOS_MEMBOX_ALLIGNED((blkSize) + OS_MEMBOX_NODE_HEAD_SIZE) * (blkNum)))
+ /*该宏首先使用 LOS_MEMBOX_ALLIGNED 宏对 (blkSize) + OS_MEMBOX_NODE_HEAD_SIZE 进行对齐操作,确保每个内存块都按照节点大小对齐。然后将对齐后的大小乘以 blkNum,并加上 sizeof(LOS_MEMBOX_INFO),得到静态内存池的总大小。
+
+其中,sizeof(LOS_MEMBOX_INFO) 表示静态内存池的元信息(头部)大小,
+包括内存池起始地址、内存块大小、内存块数量等信息。*/
+/**
+ * @ingroup los_membox
+ * Structure of a free node in a static memory pool
+ */
+typedef struct tagMEMBOX_NODE {
+ struct tagMEMBOX_NODE *pstNext; /**< Free node's pointer to the next node in a static memory pool. */
+} LOS_MEMBOX_NODE;
+#endif
+
+/**
+ * @ingroup los_membox
+ * Static memory pool information structure
+ */
+typedef struct {
+ UINT32 uwBlkSize; /**< The memory block size of the static memory pool */
+ UINT32 uwBlkNum; /**< The total memory block number of the static memory pool */
+ UINT32 uwBlkCnt; /**< The number of allocated memory blocks in the static memory pool */
+#ifdef LOSCFG_KERNEL_MEMBOX_STATIC
+ LOS_MEMBOX_NODE stFreeList; /**< The list of free memory block node in the static memory pool. This
+ structure member is available only LOSCFG_KERNEL_MEMBOX_STATIC is
+ defined. */
+#endif
+} LOS_MEMBOX_INFO;
+
+typedef LOS_MEMBOX_INFO OS_MEMBOX_S;
+/*LOS_MEMBOX_INFO:静态内存池的元信息结构体。包含了静态内存池的起始地址、
+内存块大小、内存块数量等信息。同时还包含了 uwBlkCnt 记录已分配内存块数量的成员变量
+和 stFreeList 用于记录空闲内存块的链表(仅在 LOSCFG_KERNEL_MEMBOX_STATIC 宏定义时可用)。
+
+OS_MEMBOX_S:与 LOS_MEMBOX_INFO 结构体等价的别名。*/
+/**
+ * @ingroup los_membox
+ * @brief Initialize a static memory pool.
+ *
+ * @par Description:
+ * This API is used to initialize a static memory pool. The start address of the memory pool is specified
+ * by the first parameter. In the API, it will set the memory block size, total block number, allocated
+ * block number and the list of free memory block nodes of the static memory pool.
+ * @attention
+ * The poolSize parameter value should match the following two conditions:
+ *
+ * - Be less than or equal to the size of the memory pool specified by the pool parameter.
+ * - Be greater than the size of LOS_MEMBOX_INFO.
+ *
+ *
+ * @param pool [IN] Memory pool address.
+ * @param poolSize [IN] The total size of the static memory pool.
+ * @param blkSize [IN] The memory block size of the static memory pool.
+ *
+ * @retval #LOS_NOK The memory pool fails to be initialized.
+ * @retval #LOS_OK The memory pool is successfully initialized.
+ * @par Dependency:
+ *
+ * - los_membox.h: the header file that contains the API declaration.
+ *
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT32 LOS_MemboxInit(VOID *pool, UINT32 poolSize, UINT32 blkSize);
+/*该函数会使用提供的内存池起始地址和大小来初始化静态内存池,并指定每个内存块的大小。
+在初始化完成后,该内存池将可以被用于分配内存块。*/
+/**
+ * @ingroup los_membox
+ * @brief Request a static memory block.
+ *
+ * @par Description:
+ * This API is used to request a static memory block from the static memory pool which has been initialized.
+ * @attention
+ * The input pool parameter must be initialized via func #LOS_MemboxInit.
+ *
+ * @param pool [IN] Memory pool address.
+ *
+ * @retval #VOID* This API will return a memory block address, if the request is accepted successfully.
+ * @retval #NULL The request fails.
+ * @par Dependency:
+ *
+ * - los_membox.h: the header file that contains the API declaration.
+ *
+ * @see LOS_MemboxFree
+ * @since Huawei LiteOS V100R001C00
+ */
+extern VOID *LOS_MemboxAlloc(VOID *pool);
+
+/**
+ * @ingroup los_membox
+ * @brief Free a static memory block.
+ *
+ * @par Description:
+ * This API is used to free a static memory block to the static memory pool.
+ * @attention
+ *
+ * - The input pool parameter must be initialized via func #LOS_MemboxInit.
+ * - The input box parameter must be allocated by #LOS_MemboxAlloc.
+ *
+ *
+ * @param pool [IN] Memory pool address. The memory block need to release is requested
+ * from this memory pool.
+ * @param box [IN] The pointer to the memory block to be released.
+ *
+ * @retval #LOS_NOK This memory block fails to be freed.
+ * @retval #LOS_OK This memory block is successfully freed.
+ * @par Dependency:
+ *
+ * - los_membox.h: the header file that contains the API declaration.
+ *
+ * @see LOS_MemboxAlloc
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT32 LOS_MemboxFree(VOID *pool, VOID *box);
+/*调用该函数将会释放 box 所指向的内存块,并将其重新加入到内存池的空闲内存块链表中,以便下次分配使用。*/
+/**
+ * @ingroup los_membox
+ * @brief Clear a static memory block.
+ *
+ * @par Description:
+ * This API is used to set the memory block value to 0.
+ * @attention
+ *
+ * - The input pool parameter must be initialized via func #LOS_MemboxInit.
+ * - The input box parameter must be allocated by #LOS_MemboxAlloc.
+ *
+ *
+ * @param pool [IN] Memory pool address. The memory block need to clear is requested
+ * from this memory pool.
+ * @param box [IN] The pointer to the memory block to clear.
+ * @retval None.
+ * @par Dependency:
+ *
+ * - los_membox.h: the header file that contains the API declaration.
+ *
+ * @since Huawei LiteOS V100R001C00
+ */
+extern VOID LOS_MemboxClr(VOID *pool, VOID *box);
+/*调用该函数将会将 box 所指向的内存块的数据内容清零,使其变为初始状态。
+该函数通常用于在重新使用内存块之前清除其中的旧数据,以免对后续操作产生影响。*/
+/**
+ * @ingroup los_membox
+ * @brief show static memory pool information.
+ *
+ * @par Description:
+ * This API is used to print static memory pool information. It can print the memory pool address,
+ * the memory block size, the total block number, the list of free memory block node and the total block
+ * node list of the static memory pool.
+ * @attention
+ * The input pool parameter must be initialized via func #LOS_MemboxInit.
+ *
+ * @param pool [IN] Memory pool address.
+ *
+ * @retval None.
+ * @par Dependency:
+ *
+ * - los_membox.h: the header file that contains the API declaration.
+ *
+ * @see LOS_MemboxStatisticsGet
+ * @since Huawei LiteOS V100R001C00
+ */
+extern VOID LOS_ShowBox(VOID *pool);
+
+/**
+ * @ingroup los_membox
+ * @brief Obtain the static memory pool information.
+ *
+ * @par Description:
+ * This API is used to obtain the static memory pool information. The information includes
+ * the total memory block number, block size and the allocated block number of the static
+ * memory pool. The obtained information will be outputted in the last three parameters.
+ *
+ * @attention
+ * The first parameter boxMem of this interface is a pointer, it should be a correct value.
+ * Otherwise the system may be abnormal.
+ *
+ * @param boxMem [IN] Type #VOID* Pointer to the static memory pool.
+ * @param maxBlk [OUT] Type #UINT32* The total memory block number is outputted to this parameter.
+ * @param blkCnt [OUT] Type #UINT32* The allocated memory block number is outputted to this parameter.
+ * @param blkSize [OUT] Type #UINT32* The memory block size is outputted to this parameter.
+ *
+ * @retval #LOS_OK Obtain the static memory pool information successfully.
+ * @retval #LOS_NOK Failed to obtain the static memory pool information, check whether the
+ * parameters is NULL or not.
+ * @par Dependency:
+ * - los_memory.h: the header file that contains the API declaration.
+ * @see LOS_ShowBox
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT32 LOS_MemboxStatisticsGet(const VOID *boxMem, UINT32 *maxBlk, UINT32 *blkCnt, UINT32 *blkSize);
+/*调用该函数将会获取静态内存池的统计信息,包括最大可分配内存块数量、
+已分配内存块数量以及每个内存块的大小,并通过传入的指针参数返回给调用者。
+这些统计信息可以用于监控和调试内存池的使用情况。*/
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#endif /* _LOS_MEMBOX_H */
diff --git a/kkk/los_memory.h b/kkk/los_memory.h
new file mode 100644
index 0000000..ad3cdae
--- /dev/null
+++ b/kkk/los_memory.h
@@ -0,0 +1,853 @@
+/* ----------------------------------------------------------------------------
+ * Copyright (c) Huawei Technologies Co., Ltd. 2013-2019. All rights reserved.
+ * Description: LiteOS Mem Module HeadFile
+ * Author: Huawei LiteOS Team
+ * Create: 2013-01-01
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * --------------------------------------------------------------------------- */
+
+/**
+ * @defgroup los_memory Dynamic memory
+ * @ingroup kernel
+ */
+
+#ifndef _LOS_MEMORY_H
+#define _LOS_MEMORY_H
+
+#include "los_config.h"
+#include "los_base.h"
+#include "los_toolchain.h"
+#include "los_membox.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#ifdef LOSCFG_MEM_LEAKCHECK
+
+/**
+ * @ingroup los_memory
+ * The omit layers of function call from kernel memory interfaces such as
+ * LOS_MemAlloc/LOS_MemAllocAlign/LOS_MemRealloc/LOS_MemFree.
+ * Note that this macro is defined only when LOSCFG_MEM_LEAKCHECK is defined.
+ */
+#define LOS_OMIT_LR_CNT 2
+
+/**
+ * @ingroup los_memory
+ * The recorded layers of function call.
+ * Note that this macro is defined only when LOSCFG_MEM_LEAKCHECK is defined.
+ */
+#define LOS_RECORD_LR_CNT 3
+#endif
+
+
+#define OS_MEM_ALIGN_SIZE (sizeof(UINTPTR))
+
+/**
+ * @ingroup los_memory
+ * @brief Define the type of the customized tuning function when calling the API LOS_MemAlloc to allocate
+ * memory.
+ *
+ * @par Description:
+ * This definition is used to declare the customized tuning function when calling the API LOS_MemAlloc to
+ * allocate memory.
+ * @attention
+ * None.
+ *
+ * @param None.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_memory.h: the header file that contains the API declaration.
+ * @since Huawei LiteOS V100R001C00
+ */
+typedef VOID (*MALLOC_HOOK)(VOID);
+
+/**
+ * @ingroup los_memory
+ * Customized tuning function when calling the API LOS_MemAlloc to allocate memory.
+ */
+extern MALLOC_HOOK g_MALLOC_HOOK;
+
+/**
+ * @ingroup los_memory
+ * The start address of exception interaction dynamic memory pool address, when the exception
+ * interaction feature not support, m_aucSysMem0 equals to m_aucSysMem1.
+ */
+extern UINT8 *m_aucSysMem0;
+
+/**
+ * @ingroup los_memory
+ * The start address of system dynamic memory pool address.
+ */
+extern UINT8 *m_aucSysMem1;
+
+/**
+ * @ingroup los_memory
+ * The end address of system memory.
+ */
+extern UINTPTR g_sys_mem_addr_end;
+
+#ifdef LOSCFG_EXC_INTERACTION
+/**
+ * @ingroup los_memory
+ * The size of exception interaction memory.
+ */
+extern UINTPTR g_excInteractMemSize;
+#endif
+
+#ifdef LOSCFG_MEM_MUL_MODULE
+/**
+ * @ingroup los_memory
+ * The memory usage statistics depend on module, this is the max module number 0x20.
+ * Note that this macro is defined only when LOSCFG_MEM_MUL_MODULE is defined.
+ */
+#define MEM_MODULE_MAX 0x20
+
+/**
+ * @ingroup los_memory
+ * @brief Allocate dynamic memory.
+ *
+ * @par Description:
+ * This API is used to allocate a memory block of which the size is specified and update module mem used.
+ * @attention
+ *
+ * - The input pool parameter must be initialized via func LOS_MemInit.
+ * - The size of the input parameter size can not be greater than the memory pool size that specified at the second
+ * input parameter of LOS_MemInit.
+ * - The size of the input parameter size must be four byte-aligned.
+ * - This function is defined only when LOSCFG_MEM_MUL_MODULE is defined.
+ *
+ *
+ * @param pool [IN] Pointer to the memory pool that contains the memory block to be allocated.
+ * @param size [IN] Size of the memory block to be allocated (unit: byte).
+ * @param moduleId [IN] module ID (0~MODULE_MAX).
+ *
+ * @retval #NULL The memory fails to be allocated.
+ * @retval #VOID* The memory is successfully allocated, and the API returns the pointer to
+ * the allocated memory block.
+ * @par Dependency:
+ * - los_memory.h: the header file that contains the API declaration.
+ * @see LOS_MemMrealloc | LOS_MemMallocAlign | LOS_MemMfree
+ * @since Huawei LiteOS V100R001C00
+ */
+extern VOID *LOS_MemMalloc(VOID *pool, UINT32 size, UINT32 moduleId);
+/*pool:指向内存池起始地址的指针。
+size:要分配的内存块大小。
+moduleId:分配内存块所属的模块 ID。
+调用该函数将会在指定的内存池中分配大小为 size 的内存块,并将其地址返回给调用者。
+若内存池中无法分配足够的内存块,则返回 NULL 指针表示分配失败。
+分配的内存块所属的模块 ID 由 moduleId 参数指定,通常用于管理内存使用情况。*/
+/**
+ * @ingroup los_memory
+ * @brief Allocate aligned memory.
+ *
+ * @par Description:
+ * This API is used to allocate memory blocks of specified size and of which the starting addresses are aligned on
+ * a specified boundary and update module mem used.
+ * @attention
+ *
+ * - The input pool parameter must be initialized via func LOS_MemInit.
+ * - The size of the input parameter size can not be greater than the memory pool size that specified at the second
+ * input parameter of LOS_MemInit.
+ * - The alignment parameter value must be a power of 2 with the minimum value being 4.
+ * - This function is defined only when LOSCFG_MEM_MUL_MODULE is defined.
+ *
+ *
+ * @param pool [IN] Pointer to the memory pool that contains the memory blocks to be allocated.
+ * @param size [IN] Size of the memory to be allocated.
+ * @param boundary [IN] Boundary on which the memory is aligned.
+ * @param moduleId [IN] module ID (0~MODULE_MAX).
+ *
+ * @retval #NULL The memory fails to be allocated.
+ * @retval #VOID* The memory is successfully allocated, and the API returns the pointer to the allocated memory.
+ * @par Dependency:
+ * - los_memory.h: the header file that contains the API declaration.
+ * @see LOS_MemMalloc | LOS_MemRealloc | LOS_MemMfree
+ * @since Huawei LiteOS V100R001C00
+ */
+extern VOID *LOS_MemMallocAlign(VOID *pool, UINT32 size, UINT32 boundary, UINT32 moduleId);
+/*调用该函数将会在指定的内存池中按照指定的对齐边界(boundary)分配大小为 size 的内存块,并将其地址返回给调用者。
+对齐边界表示内存块起始地址相对于内存池起始地址的偏移量必须是 boundary 的倍数。
+若内存池中无法分配足够的对齐内存块,则返回 NULL 指针表示分配失败。
+分配的内存块所属的模块 ID 由 moduleId 参数指定,通常用于管理内存使用情况。*/
+/**
+ * @ingroup los_memory
+ * @brief Free dynamic memory.
+ *
+ * @par Description:
+ * This API is used to free specified dynamic memory that has been allocated and update module mem used.
+ * @attention
+ *
+ * - The input pool parameter must be initialized via func LOS_MemInit.
+ * - The input ptr parameter must be allocated by LOS_MemMalloc or LOS_MemMallocAlign or LOS_MemMrealloc.
+ * - This function is defined only when LOSCFG_MEM_MUL_MODULE is defined.
+ *
+ *
+ * @param pool [IN] Pointer to the memory pool that contains the dynamic memory block to be freed.
+ * @param ptr [IN] Starting address of the memory block to be freed.
+ * @param moduleId [IN] module ID (0~MODULE_MAX).
+ *
+ * @retval #LOS_NOK The memory block fails to be freed because the starting address of the memory block is
+ * invalid, or the memory overwriting occurs.
+ * @retval #LOS_OK The memory block is freed successfully.
+ * @par Dependency:
+ * - los_memory.h: the header file that contains the API declaration.
+ * @see LOS_MemMalloc | LOS_MemMrealloc | LOS_MemMallocAlign
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT32 LOS_MemMfree(VOID *pool, VOID *ptr, UINT32 moduleId);
+/*调用该函数将会释放由 ptr 指向的内存块,并将其归还给指定的内存池。同时,通过 moduleId 参数指定要释放的内存块所属的模块 ID,以便进行相关的内存管理操作。
+
+在调用该函数之前,需要确保要释放的内存块确实是之前通过 LOS_MemMalloc 或 LOS_MemMallocAlign 分配得到的,并且未被重复释放。否则可能会导致内存管理错误和程序异常行为。*/
+/**
+ * @ingroup los_memory
+ * @brief Re-allocate a memory block.
+ *
+ * @par Description:
+ * This API is used to allocate a new memory block of which the size is specified by size if the original memory
+ * block size is insufficient. The new memory block will copy the data in the original memory block of which the
+ * address is specified by ptr.The size of the new memory block determines the maximum size of data to be copied.
+ * After the new memory block is created, the original one is freed. And update module mem used.
+ * @attention
+ *
+ * - The input pool parameter must be initialized via func LOS_MemInit.
+ * - The input ptr parameter must be allocated by LOS_MemMalloc or LOS_MemMallocAlign.
+ * - The size of the input parameter size can not be greater than the memory pool size that specified at the second
+ * input parameter of LOS_MemInit.
+ * - The size of the input parameter size must be aligned as follows: 1) if the ptr is allocated by LOS_MemAlloc,
+ * it must be four byte-aligned; 2) if the ptr is allocated by LOS_MemMallocAlign, it must be aligned with the size of
+ * the input parameter boundary of LOS_MemMallocAlign.
+ * - This function is defined only when LOSCFG_MEM_MUL_MODULE is defined.
+ *
+ *
+ * @param pool [IN] Pointer to the memory pool that contains the original and new memory blocks.
+ * @param ptr [IN] Address of the original memory block.
+ * @param size [IN] Size of the new memory block.
+ * @param moduleId [IN] module ID (0~MODULE_MAX).
+ *
+ * @retval #NULL The memory fails to be re-allocated.
+ * @retval #VOID* The memory is successfully re-allocated, and the API returns the pointer to
+ * the new memory block.
+ * @par Dependency:
+ * - los_memory.h: the header file that contains the API declaration.
+ * @see LOS_MemMalloc | LOS_MemMallocAlign | LOS_MemMfree
+ * @since Huawei LiteOS V100R001C00
+ */
+extern VOID *LOS_MemMrealloc(VOID *pool, VOID *ptr, UINT32 size, UINT32 moduleId);
+
+/**
+ * @ingroup los_memory
+ * @brief get the uesed memory size of the specified module.
+ *
+ * @par Description:
+ * This API is used to get the specified module's memory consume size.
+ * @attention This function is defined only when LOSCFG_MEM_MUL_MODULE is defined.
+ *
+ * @param moduleId [IN] module ID (0~MODULE_MAX).
+ *
+ * @retval #UINT32 The size of the specified module's consumed memory.
+ * @retval #OS_NULL_INT The input module id is illegal.
+ * @par Dependency:
+ * - los_memory.h: the header file that contains the API declaration.
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT32 LOS_MemMusedGet(UINT32 moduleId);
+#endif
+
+#ifdef LOSCFG_MEM_MUL_POOL
+/**
+ * @ingroup los_memory
+ * @brief Deinitialize dynamic memory.
+ *
+ * @par Description:
+ * This API is used to deinitialize the dynamic memory of a doubly linked list.
+ * @attention This function is defined only when LOSCFG_MEM_MUL_POOL is defined.
+ *
+ * @param pool [IN] Starting address of memory.
+ *
+ * @retval #LOS_NOK The dynamic memory fails to be deinitialized.
+ * @retval #LOS_OK The dynamic memory is successfully deinitialized.
+ * @par Dependency:
+ *
+ * - los_memory.h: the header file that contains the API declaration.
+ *
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT32 LOS_MemDeInit(VOID *pool);
+
+/**
+ * @ingroup los_memory
+ * @brief Print information about all pools.
+ *
+ * @par Description:
+ * This API is used to print information about all pools.
+ *
+ * @attention This function is defined only when LOSCFG_MEM_MUL_POOL is defined.
+ *
+ * @param None.
+ *
+ * @retval #UINT32 The pool number.
+ * @par Dependency:
+ *
+ * - los_memory.h: the header file that contains the API declaration.
+ *
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT32 LOS_MemPoolList(VOID);
+#endif
+
+/**
+ * @ingroup los_memory
+ * Memory pool extern information structure
+ */
+typedef struct {
+ UINT32 uwTotalUsedSize;
+ UINT32 uwTotalFreeSize;
+ UINT32 uwMaxFreeNodeSize;
+ UINT32 uwUsedNodeNum;
+ UINT32 uwFreeNodeNum;
+#ifdef LOSCFG_MEM_TASK_STAT
+ UINT32 uwUsageWaterLine; /**< this structure member is defined only when LOSCFG_MEM_TASK_STAT is defined. */
+#endif
+} LOS_MEM_POOL_STATUS;
+/*uwTotalUsedSize:内存池中已使用的总大小(单位:字节)。
+uwTotalFreeSize:内存池中未使用的总大小(单位:字节)。
+uwMaxFreeNodeSize:内存池中最大的可用内存块大小(单位:字节)。
+uwUsedNodeNum:内存池中已使用的内存块数量。
+uwFreeNodeNum:内存池中未使用的内存块数量。
+uwUsageWaterLine(仅在 LOSCFG_MEM_TASK_STAT 定义时有效):内存池的使用水位线,表示内存池在运行过程中达到的最高使用量。
+通过使用该结构体,可以获取内存池的详细状态信息,例如已使用的总大小、未使用的总大小、可用的最大内存块大小以及相关的内存块数量。
+其中,如果定义了 LOSCFG_MEM_TASK_STAT,还可以获取内存池的使用水位线。*/
+/**
+ * @ingroup los_memory
+ * @brief Initialize dynamic memory.
+ *
+ * @par Description:
+ * This API is used to initialize the dynamic memory of a doubly linked list.
+ * @attention
+ *
+ * - The size parameter value should match the following two conditions :
+ * 1) Be less than or equal to the Memory pool size;
+ * 2) Be greater than the size of OS_MEM_MIN_POOL_SIZE.
+ * - Call this API when dynamic memory needs to be initialized during the startup of Huawei LiteOS.
+ * - The parameter input must be OS_MEM_ALIGN_SIZE byte-aligned.
+ * - The init area [pool, pool + size] should not conflict with other pools.
+ *
+ *
+ * @param pool [IN] Starting address of memory.
+ * @param size [IN] Memory size.
+ *
+ * @retval #LOS_NOK The dynamic memory fails to be initialized.
+ * @retval #LOS_OK The dynamic memory is successfully initialized.
+ * @par Dependency:
+ *
+ * - los_memory.h: the header file that contains the API declaration.
+ *
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT32 LOS_MemInit(VOID *pool, UINT32 size);
+/*调用该函数将会对指定的内存池进行初始化操作,使其具备可用于分配和管理内存块的能力。
+在初始化完成后,该内存池可以被用于动态分配和释放内存块。*/
+/**
+ * @ingroup los_memory
+ * @brief Allocate dynamic memory.
+ *
+ * @par Description:
+ * This API is used to allocate a memory block of which the size is specified.
+ * @attention
+ *
+ * - The input pool parameter must be initialized via func LOS_MemInit.
+ * - The size of the input parameter size can not be greater than the memory pool size that specified at the second
+ * input parameter of LOS_MemInit.
+ * - The size of the input parameter size must be four byte-aligned.
+ *
+ *
+ * @param pool [IN] Pointer to the memory pool that contains the memory block to be allocated.
+ * @param size [IN] Size of the memory block to be allocated (unit: byte).
+ *
+ * @retval #NULL The memory fails to be allocated.
+ * @retval #VOID* The memory is successfully allocated, and the API returns the pointer to
+ * the allocated memory block.
+ * @par Dependency:
+ * - los_memory.h: the header file that contains the API declaration.
+ * @see LOS_MemRealloc | LOS_MemAllocAlign | LOS_MemFree
+ * @since Huawei LiteOS V100R001C00
+ */
+extern VOID *LOS_MemAlloc(VOID *pool, UINT32 size);
+/*通过该函数可以动态地从内存池中获取一块指定大小的内存块,以满足程序运行时的内存需求。分配的内存块可以根据实际需要进行读写操作
+,并在不再需要时通过相应的内存释放函数进行释放和回收。*/
+/**
+ * @ingroup los_memory
+ * @brief Free dynamic memory.
+ *
+ * @par Description:
+ * This API is used to free specified dynamic memory that has been allocated.
+ * @attention
+ *
+ * - The input pool parameter must be initialized via func LOS_MemInit.
+ * - The input ptr parameter must be allocated by LOS_MemAlloc or LOS_MemAllocAlign or LOS_MemRealloc.
+ *
+ *
+ * @param pool [IN] Pointer to the memory pool that contains the dynamic memory block to be freed.
+ * @param ptr [IN] Starting address of the memory block to be freed.
+ *
+ * @retval #LOS_NOK The memory block fails to be freed because the starting address of the memory block is
+ * invalid, or the memory overwriting occurs.
+ * @retval #LOS_OK The memory block is successfully freed.
+ * @par Dependency:
+ * - los_memory.h: the header file that contains the API declaration.
+ * @see LOS_MemAlloc | LOS_MemRealloc | LOS_MemAllocAlign
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT32 LOS_MemFree(VOID *pool, VOID *ptr);
+
+/**
+ * @ingroup los_memory
+ * @brief Re-allocate a memory block.
+ *
+ * @par Description:
+ * This API is used to allocate a new memory block of which the size is specified by size if the original memory
+ * block size is insufficient. The new memory block will copy the data in the original memory block of which the
+ * address is specified by ptr. The size of the new memory block determines the maximum size of data to be copied.
+ * After the new memory block is created, the original one is freed.
+ * @attention
+ *
+ * - The input pool parameter must be initialized via func LOS_MemInit.
+ * - The input ptr parameter must be allocated by LOS_MemAlloc; if the ptr is allocated by LOS_MemAllocAlign,
+ * the alignment of the newly allocated memory address cannot be guaranteed to be consistent with the original
+ * memory address.
+ * - The input size parameter can not be greater than the memory pool size that specified at the second
+ * input parameter of LOS_MemInit.
+ * - The input size parameter must be aligned as follows: 1) if the ptr is allocated by LOS_MemAlloc,
+ * it must be four byte-aligned; 2) if the ptr is allocated by LOS_MemAllocAlign, it must be aligned with the size of
+ * the input parameter boundary of LOS_MemAllocAlign.
+ * - If the user has special requirements for address alignment, it is not recommended to use this realloc function
+ * for address allocated by LOS_MemAllocAlign. For example, on a 32-bit system, LiteOS's default address alignment
+ * is 4 bytes, and if the boundary specified in LOS_MemAllocAlign is 8 bytes, it is cannot be ensured that the
+ * reallocated address is 8 bytes aligned.
+ *
+ *
+ * @param pool [IN] Pointer to the memory pool that contains the original and new memory blocks.
+ * @param ptr [IN] Address of the original memory block.
+ * @param size [IN] Size of the new memory block.
+ *
+ * @retval #NULL The memory fails to be re-allocated.
+ * @retval #VOID* The memory is successfully re-allocated, and the API returns the pointer to the new memory block.
+ * @par Dependency:
+ * - los_memory.h: the header file that contains the API declaration.
+ * @see LOS_MemAlloc | LOS_MemAllocAlign | LOS_MemFree
+ * @since Huawei LiteOS V100R001C00
+ */
+extern VOID *LOS_MemRealloc(VOID *pool, VOID *ptr, UINT32 size);
+//通过该函数可以动态地调整已分配内存块的大小,以满足程序运行时动态变化的内存需求。
+/**
+ * @ingroup los_memory
+ * @brief Allocate aligned memory.
+ *
+ * @par Description:
+ * This API is used to allocate memory blocks of specified size and of which the starting addresses are aligned on
+ * a specified boundary.
+ * @attention
+ *
+ * - The input pool parameter must be initialized via func LOS_MemInit.
+ * - The size of the input parameter size can not be greater than the memory pool size that specified at the second
+ * input parameter of LOS_MemInit.
+ * - The alignment parameter value must be a power of 2 with the minimum value being 4.
+ *
+ *
+ * @param pool [IN] Pointer to the memory pool that contains the memory blocks to be allocated.
+ * @param size [IN] Size of the memory to be allocated.
+ * @param boundary [IN] Boundary on which the memory is aligned.
+ *
+ * @retval #NULL The memory fails to be allocated.
+ * @retval #VOID* The memory is successfully allocated, and the API returns the pointer to the allocated memory.
+ * @par Dependency:
+ * - los_memory.h: the header file that contains the API declaration.
+ * @see LOS_MemAlloc | LOS_MemRealloc | LOS_MemFree
+ * @since Huawei LiteOS V100R001C00
+ */
+extern VOID *LOS_MemAllocAlign(VOID *pool, UINT32 size, UINT32 boundary);
+/*通过该函数可以动态地从内存池中获取一块指定大小并满足对齐要求的内存块,
+以满足程序运行时的内存需求。分配的内存块可以根据实际需要进行读写操作,
+并在不再需要时通过相应的内存释放函数进行释放和回收。*/
+/**
+ * @ingroup los_memory
+ * @brief Get the size of memory pool's size.
+ *
+ * @par Description:
+ * This API is used to get the size of memory pool' total size.
+ * @attention
+ * The input pool parameter must be initialized via func LOS_MemInit.
+ *
+ * @param pool [IN] A pointer pointed to the memory pool.
+ *
+ * @retval #LOS_NOK The input parameter pool is NULL.
+ * @retval #UINT32 The size of the memory pool.
+ * @par Dependency:
+ * - los_memory.h: the header file that contains the API declaration.
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT32 LOS_MemPoolSizeGet(const VOID *pool);
+
+/**
+ * @ingroup los_memory
+ * @brief Get the size of memory totally used.
+ *
+ * @par Description:
+ * This API is used to get the size of memory totally used in memory pool.
+ * @attention
+ * The input pool parameter must be initialized via func LOS_MemInit.
+ *
+ * @param pool [IN] A pointer pointed to the memory pool.
+ *
+ * @retval #LOS_NOK The input parameter pool is NULL.
+ * @retval #UINT32 The size of the used memory pool.
+ * @par Dependency:
+ * - los_memory.h: the header file that contains the API declaration.
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT32 LOS_MemTotalUsedGet(VOID *pool);
+
+/**
+ * @ingroup los_memory
+ * @brief Get the number of free memory nodes.
+ *
+ * @par Description:
+ * This API is used to get the number of free memory nodes in memory pool.
+ * @attention
+ * The input pool parameter must be initialized via func LOS_MemInit.
+ *
+ * @param pool [IN] A pointer pointed to the memory pool.
+ *
+ * @retval #LOS_NOK The input parameter pool is NULL.
+ * @retval #UINT32 The number of free memory nodes.
+ * @par Dependency:
+ * - los_memory.h: the header file that contains the API declaration.
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT32 LOS_MemFreeBlksGet(VOID *pool);
+
+/**
+ * @ingroup los_memory
+ * @brief Get the number of used memory nodes.
+ *
+ * @par Description:
+ * This API is used to get the number of used memory nodes in memory pool.
+ * @attention
+ * The input pool parameter must be initialized via func LOS_MemInit.
+ *
+ * @param pool [IN] A pointer pointed to the memory pool.
+ *
+ * @retval #LOS_NOK The input parameter pool is NULL.
+ * @retval #UINT32 The number of used memory nodes.
+ * @par Dependency:
+ * - los_memory.h: the header file that contains the API declaration.
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT32 LOS_MemUsedBlksGet(VOID *pool);
+
+/**
+ * @ingroup los_memory
+ * @brief Get the task ID of a used memory node.
+ *
+ * @par Description:
+ * This API is used to get the task ID of a used memory node.
+ * @attention
+ *
+ * - The input ptr parameter must be allocated by LOS_MemAlloc or LOS_MemAllocAlign.
+ * - This interface only support obtain the task ID of a used memory node which is allocated from the system memory
+ * pool (OS_SYS_MEM_ADDR) at present.
+ *
+ *
+ * @param ptr [IN] A used memory node.
+ *
+ * @retval #OS_INVALID The input parameter ptr is illegal.
+ * @retval #UINT32 The task ID of used memory node ptr.
+ * @par Dependency:
+ * - los_memory.h: the header file that contains the API declaration.
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT32 LOS_MemTaskIdGet(const VOID *ptr);
+
+/**
+ * @ingroup los_memory
+ * @brief Get the address of last node.
+ *
+ * @par Description:
+ * This API is used to get the address of last node.
+ * @attention
+ *
+ * - The input pool parameter must be initialized via func LOS_MemInit.
+ * - The last node of memory pool is not the end node.
+ *
+ *
+ * @param pool [IN] A pointer pointed to the memory pool.
+ *
+ * @retval #LOS_NOK The input parameter pool is NULL.
+ * @retval #UINTPTR The pointer to the last used node.
+ * @par Dependency:
+ * - los_memory.h: the header file that contains the API declaration.
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINTPTR LOS_MemLastUsedGet(VOID *pool);
+
+/**
+ * @ingroup los_memory
+ * @brief Get the information of memory pool.
+ *
+ * @par Description:
+ * This API is used to get the information of memory pool.
+ * @attention
+ * The input pool parameter must be initialized via func LOS_MemInit.
+ *
+ * @param pool [IN] A pointer pointed to the memory pool.
+ * @param poolStatus [OUT] A pointer for storage the pool status
+ *
+ * @retval #LOS_NOK The input parameter pool is NULL or invalid.
+ * @retval #LOS_OK Get memory information successfully.
+ * @par Dependency:
+ * - los_memory.h: the header file that contains the API declaration.
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT32 LOS_MemInfoGet(VOID *pool, LOS_MEM_POOL_STATUS *poolStatus);
+/*调用该函数将会获取指定内存池的状态信息,并将其保存到指定的 LOS_MEM_POOL_STATUS 结构体中。如果获取成功,返回 LOS_OK;否则返回错误码。
+
+通过该函数可以获取当前内存池的总容量、已使用的容量、剩余的容量等信息,以便于进行内存管理和优化。*/
+/**
+ * @ingroup los_memory
+ * @brief Get the number of free node in every size.
+ *
+ * @par Description:
+ * This API is used to print the number of free node in every size.
+ * @attention
+ * The input pool parameter must be initialized via func LOS_MemInit.
+ *
+ * @param pool [IN] A pointer pointed to the memory pool.
+ *
+ * @retval #LOS_NOK The input parameter pool is NULL.
+ * @retval #LOS_OK Print the number of free node in every size successfully.
+ * @par Dependency:
+ * - los_memory.h: the header file that contains the API declaration.
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT32 LOS_MemFreeNodeShow(VOID *pool);
+
+/**
+ * @ingroup los_memory
+ * @brief Check the memory pool integrity.
+ *
+ * @par Description:
+ * This API is used to check the memory pool integrity.
+ * @attention
+ *
+ * - The input pool parameter must be initialized via func LOS_MemInit.
+ * - LOS_MemIntegrityCheck will be called by malloc function when the macro of LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK
+ * is defined in LiteOS.
+ * - LOS_MemIntegrityCheck function can be called by user anytime.
+ *
+ *
+ * @param pool [IN] A pointer to the memory pool.
+ *
+ * @retval #LOS_NOK The memory pool (pool) is impaired.
+ * @retval #LOS_OK The memory pool (pool) is integrated.
+ * @par Dependency:
+ * - los_memory.h: the header file that contains the API declaration.
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT32 LOS_MemIntegrityCheck(VOID *pool);
+
+#ifdef LOSCFG_BASE_MEM_NODE_SIZE_CHECK
+/*调用该函数将会对指定的内存池进行完整性检查,以确保内存池中分配的内存块没有损坏或越界等问题。如果检查通过,返回 LOS_OK;否则返回错误码。
+
+在代码中还有一个条件编译的宏定义 #ifdef LOSCFG_BASE_MEM_NODE_SIZE_CHECK,用于判断是否开启了基于内存节点大小的检查。如果该宏定义存在且为真,
+则执行相应的代码逻辑;否则忽略该部分代码。*/
+/**
+ * @ingroup los_memory
+ * @brief Check the size of the specified memory node.
+ *
+ * @par Description:
+ * This API is used to check the size of memory node.
+ * @attention
+ *
+ * - The input pool parameter must be initialized via func LOS_MemInit.
+ * - The input ptr parameter must be allocated by LOS_MemAlloc or LOS_MemAllocAlign.
+ * - The function will be called by function specified, such as memset or memcpy.
+ * - The feature can be enabled when you set the macro value of LOSCFG_BASE_MEM_NODE_SIZE_CHECK as YES.
+ * - You had better set memory check level as LOS_MEM_CHECK_LEVEL_DISABLE when copy bin file.
+ *
+ *
+ * @param pool [IN] A pointer pointed to the memory pool.
+ * @param ptr [IN] A pointer pointed to the source node.
+ * @param totalSize [OUT] A pointer to save total size, must point to valid memory.
+ * @param availSize [OUT] A pointer to save available size, must point to valid memory.
+ *
+ * @retval #LOS_ERRNO_MEMCHECK_DISABLED Memcheck function does not open.
+ * @retval #LOS_ERRNO_MEMCHECK_PARA_NULL The pool or ptr is NULL.
+ * @retval #LOS_ERRNO_MEMCHECK_OUTSIDE The ptr address is not in the reasonable range.
+ * @retval #LOS_ERRNO_MEMCHECK_NO_HEAD Can't find the control head node from ptr.
+ * @retval #LOS_ERRNO_MEMCHECK_WRONG_LEVEL The memory check level is illegal.
+ * @retval #LOS_OK Success to get total size and available size of the memory node (ptr).
+ * @par Dependency:
+ * - los_memory.h: the header file that contains the API declaration.
+ * @see LOS_MemCheckLevelSet | LOS_MemCheckLevelGet
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT32 LOS_MemNodeSizeCheck(VOID *pool, VOID *ptr, UINT32 *totalSize, UINT32 *availSize);
+/*调用该函数将会检查指定内存池中给定内存节点的大小,并将总大小和可用大小分别保存到指定的变量中。如果检查成功,返回 LOS_OK;否则返回错误码。
+
+使用该函数可以获得指定内存节点的总大小和可用大小信息。这对于动态管理内存节点、调试内存分配问题以及优化内存使用非常有用。*/
+/**
+ * @ingroup los_memory
+ * @brief Set the memory check level.
+ *
+ * @par Description:
+ * This API is used to set the memory check level.
+ * @attention
+ *
+ * - There are three level you can set.
+ * - The legal level are LOS_MEM_CHECK_LEVEL_LOW, LOS_MEM_CHECK_LEVEL_HIGH, LOS_MEM_CHECK_LEVEL_DISABLE.
+ *
+ *
+ * @param checkLevel [IN] The level what you want to set.
+ *
+ * @retval #LOS_ERRNO_MEMCHECK_WRONG_LEVEL The input memory check level is illegal.
+ * @retval #LOS_OK Set the memory check level successfully.
+ * @par Dependency:
+ * - los_memory.h: the header file that contains the API declaration.
+ * @see LOS_MemNodeSizeCheck | LOS_MemCheckLevelGet
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT32 LOS_MemCheckLevelSet(UINT8 checkLevel);
+
+/**
+ * @ingroup los_memory
+ * @brief Get the memory check level.
+ *
+ * @par Description:
+ * This API is used to get the current memory check level.
+ * @attention None.
+ *
+ * @param None.
+ *
+ * @retval #UINT8 The current memory check level.
+ * @par Dependency:
+ * - los_memory.h: the header file that contains the API declaration.
+ * @see LOS_MemNodeSizeCheck | LOS_MemCheckLevelSet
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT8 LOS_MemCheckLevelGet(VOID);
+#endif
+
+/**
+ * @ingroup los_memory
+ * Define a mem size check intensity
+ *
+ * Lowest mem check.
+ */
+#define LOS_MEM_CHECK_LEVEL_LOW 0
+
+/**
+ * @ingroup los_memory
+ * Define a mem size check intensity
+ *
+ * Highest mem check.
+ */
+#define LOS_MEM_CHECK_LEVEL_HIGH 1
+
+/**
+ * @ingroup los_memory
+ * Define a mem size check intensity
+ *
+ * disable mem check.
+ */
+#define LOS_MEM_CHECK_LEVEL_DISABLE 0xff
+
+/**
+ * @ingroup los_memory
+ * Define a mem size check intensity.
+ *
+ * default intensity set mem check.
+ */
+#define LOS_MEM_CHECK_LEVEL_DEFAULT LOS_MEM_CHECK_LEVEL_DISABLE
+
+/**
+ * @ingroup los_memory
+ * memcheck error code: the pointer or pool is NULL.
+ *
+ * Value: 0x02000101.
+ *
+ * Solution: don't give a NULL parameter.
+ */
+#define LOS_ERRNO_MEMCHECK_PARA_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_MEM, 0x1)
+
+/**
+ * @ingroup los_memory
+ * memcheck error code: the pointer address is not in the suitable range.
+ *
+ * Value: 0x02000102.
+ *
+ * Solution: check pointer and comfirm it is in stack.
+ */
+#define LOS_ERRNO_MEMCHECK_OUTSIDE LOS_ERRNO_OS_ERROR(LOS_MOD_MEM, 0x2)
+
+/**
+ * @ingroup los_memory
+ * memcheck error code: can't find the control node.
+ *
+ * Value: 0x02000103.
+ *
+ * Solution: check if the node which the pointer points to has been freed or not been allocated.
+ */
+#define LOS_ERRNO_MEMCHECK_NO_HEAD LOS_ERRNO_OS_ERROR(LOS_MOD_MEM, 0x3)
+
+/**
+ * @ingroup los_memory
+ * memcheck error code: the memcheck level is wrong.
+ *
+ * Value: 0x02000104.
+ *
+ * Solution: check the memcheck level by the function "LOS_MemCheckLevelGet".
+ */
+#define LOS_ERRNO_MEMCHECK_WRONG_LEVEL LOS_ERRNO_OS_ERROR(LOS_MOD_MEM, 0x4)
+
+/**
+ * @ingroup los_memory
+ * memcheck error code: memcheck function is not enable.
+ *
+ * Value: 0x02000105.
+ *
+ * Solution: enable memcheck by the function "LOS_MemCheckLevelSet".
+ */
+#define LOS_ERRNO_MEMCHECK_DISABLED LOS_ERRNO_OS_ERROR(LOS_MOD_MEM, 0x5)
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#endif /* _LOS_MEMORY_H */
diff --git a/kkk/los_mux.h b/kkk/los_mux.h
new file mode 100644
index 0000000..8ef776e
--- /dev/null
+++ b/kkk/los_mux.h
@@ -0,0 +1,319 @@
+/* ----------------------------------------------------------------------------
+ * Copyright (c) Huawei Technologies Co., Ltd. 2013-2019. All rights reserved.
+ * Description: Mutex
+ * Author: Huawei LiteOS Team
+ * Create: 2013-01-01
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * --------------------------------------------------------------------------- */
+
+/**
+ * @defgroup los_mux Mutex
+ * @ingroup kernel
+ */
+
+#ifndef _LOS_MUX_H
+#define _LOS_MUX_H
+
+#include "los_base.h"
+#include "los_sys.h"
+#include "los_list.h"
+#include "los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+/**
+ * @ingroup los_mux
+ * Mutex error code: The memory request fails.
+ *
+ * Value: 0x02001d00.
+ *
+ * Solution: Decrease the number of mutexes defined by LOSCFG_BASE_IPC_MUX_LIMIT.
+ */
+#define LOS_ERRNO_MUX_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x00)
+/*这段代码定义了一个名为 LOS_ERRNO_MUX_NO_MEMORY 的宏,用于表示互斥锁分配内存失败的错误码。
+
+LOS_ERRNO_OS_ERROR 是一个宏,用于生成具有模块和错误码的错误码值。在这里,LOS_MOD_MUX 表示错误所属的模块是互斥锁模块,
+0x00 是该错误码在该模块中的具体数值。*/
+/**
+ * @ingroup los_mux
+ * Mutex error code: The mutex is not usable.
+ *
+ * Value: 0x02001d01.
+ *
+ * Solution: Check whether the mutex ID and the mutex state are applicable for the current operation.
+ */
+#define LOS_ERRNO_MUX_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x01)
+//LOS_ERRNO_OS_ERROR 是一个宏,用于生成具有模块和错误码的错误码值。在这里,LOS_MOD_MUX 表示错误所属的模块是互斥锁模块,0x01 是该错误码在该模块中的具体数值。
+/**
+ * @ingroup los_mux
+ * Mutex error code: Null pointer.
+ *
+ * Value: 0x02001d02.
+ *
+ * Solution: Check whether the input parameter is usable.
+ */
+#define LOS_ERRNO_MUX_PTR_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x02)
+//这段代码定义了一个名为 LOS_ERRNO_MUX_PTR_NULL 的宏,用于表示互斥锁指针为空的错误码。
+//LOS_ERRNO_OS_ERROR 是一个宏,用于生成具有模块和错误码的错误码值。在这里,LOS_MOD_MUX 表示错误所属的模块是互斥锁模块,0x02 是该错误码在该模块中的具体数值。
+/**
+ * @ingroup los_mux
+ * Mutex error code: No mutex is available and the mutex request fails.
+ *
+ * Value: 0x02001d03.
+ *
+ * Solution: Increase the number of mutexes defined by LOSCFG_BASE_IPC_MUX_LIMIT.
+ */
+#define LOS_ERRNO_MUX_ALL_BUSY LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x03)
+/*这段代码定义了一个名为 LOS_ERRNO_MUX_ALL_BUSY 的宏,用于表示互斥锁已全部被占用的错误码。
+
+LOS_ERRNO_OS_ERROR 是一个宏,用于生成具有模块和错误码的错误码值。在这里,LOS_MOD_MUX 表示错误所属的模块是互斥锁模块,0x03 是该错误码在该模块中的具体数值。*/
+/**
+ * @ingroup los_mux
+ * Mutex error code: The mutex fails to be locked in non-blocking mode because it is locked by another thread.
+ *
+ * Value: 0x02001d04.
+ *
+ * Solution: Lock the mutex after it is unlocked by the thread that owns it, or set a waiting time.
+ */
+#define LOS_ERRNO_MUX_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x04)
+/*这段代码定义了一个名为 LOS_ERRNO_MUX_UNAVAILABLE 的宏,用于表示互斥锁不可用的错误码。
+
+LOS_ERRNO_OS_ERROR 是一个宏,用于生成具有模块和错误码的错误码值。在这里,LOS_MOD_MUX 表示错误所属的模块是互斥锁模块,0x04 是该错误码在该模块中的具体数值。*/
+/**
+ * @ingroup los_mux
+ * Mutex error code: The mutex is being locked during an interrupt.
+ *
+ * Value: 0x02001d05.
+ *
+ * Solution: Check whether the mutex is being locked during an interrupt.
+ */
+#define LOS_ERRNO_MUX_PEND_INTERR LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x05)
+ /*这段代码定义了一个名为 LOS_ERRNO_MUX_PEND_INTERR 的宏,用于表示互斥锁等待被阻塞时发生中断错误的错误码。
+
+LOS_ERRNO_OS_ERROR 是一个宏,用于生成具有模块和错误码的错误码值。在这里,LOS_MOD_MUX 表示错误所属的模块是互斥锁模块,0x05 是该错误码在该模块中的具体数值。*/
+/**
+ * @ingroup los_mux
+ * Mutex error code: A thread locks a mutex after waiting for the mutex to be unlocked by another thread
+ * when the task scheduling is disabled.
+ *
+ * Value: 0x02001d06.
+ *
+ * Solution: Check whether the task scheduling is disabled, or set timeout to 0, which means that the
+ * thread will not wait for the mutex to become available.
+ */
+#define LOS_ERRNO_MUX_PEND_IN_LOCK LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x06)
+/*这段代码定义了一个名为 LOS_ERRNO_MUX_PEND_IN_LOCK 的宏,用于表示在互斥锁上等待时发生死锁错误的错误码。
+
+LOS_ERRNO_OS_ERROR 是一个宏,用于生成具有模块和错误码的错误码值。在这里,LOS_MOD_MUX 表示错误所属的模块是互斥锁模块,0x06 是该错误码在该模块中的具体数值。*/
+/**
+ * @ingroup los_mux
+ * Mutex error code: The mutex locking times out.
+ *
+ * Value: 0x02001d07.
+ *
+ * Solution: Increase the waiting time or set the waiting time to LOS_WAIT_FOREVER (forever-blocking mode).
+ */
+#define LOS_ERRNO_MUX_TIMEOUT LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x07)
+//LOS_ERRNO_OS_ERROR 是一个宏,用于生成具有模块和错误码的错误码值。在这里,LOS_MOD_MUX 表示错误所属的模块是互斥锁模块,0x07 是该错误码在该模块中的具体数值。
+/**
+ * @ingroup los_mux
+ * The error code is not in use temporarily.
+ *
+ * Value: 0x02001d08
+ * @deprecated This error code is obsolete since LiteOS 5.0.0.
+ */
+#define LOS_ERRNO_MUX_OVERFLOW LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x08)
+
+/**
+ * @ingroup los_mux
+ * Mutex error code: The mutex to be deleted is being locked.
+ *
+ * Value: 0x02001d09.
+ *
+ * Solution: Delete the mutex after it is unlocked.
+ */
+#define LOS_ERRNO_MUX_PENDED LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x09)
+
+/**
+ * @ingroup los_mux
+ * The error code is not in use temporarily.
+ *
+ * Value: 0x02001d0A
+ * @deprecated This error code is obsolete since LiteOS 5.0.0.
+ */
+#define LOS_ERRNO_MUX_GET_COUNT_ERR LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x0A)
+
+/**
+ * @ingroup los_mux
+ * The error code is not in use temporarily.
+ *
+ * Value: 0x02001d0B
+ * @deprecated This error code is obsolete since LiteOS 5.0.0.
+ */
+#define LOS_ERRNO_MUX_REG_ERROR LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x0B)
+
+/**
+ * @ingroup los_mux
+ * Mutex error code: The mutex is being locked in system-level task.
+ * old usage: The mutex is being locked in software timer task(LOS_ERRNO_MUX_PEND_IN_SWTMR_TSK).
+ *
+ * Value: 0x02001d0C.
+ *
+ * Solution: Pend the mutex in a vailid task.
+ * @deprecated This error code is obsolete since LiteOS 5.0.0.
+ */
+#define LOS_ERRNO_MUX_PEND_IN_SYSTEM_TASK LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x0C)
+/*其中 LOS_ERRNO_OS_ERROR 是一个宏函数,用于生成错误码。该宏函数接受两个参数:模块号和错误码。在这里,模块号为 LOS_MOD_MUX,错误码为 0x0C。
+
+通过这个宏定义,可以方便地识别并处理在系统任务中使用互斥信号量时发生的错误情况。*/
+/**
+ * @ingroup los_mux
+ * @brief Create a mutex.
+ *
+ * @par Description:
+ * This API is used to create a mutex. A mutex handle is assigned to muxHandle when the mutex is created successfully.
+ * Return #LOS_OK when creating is successful, return specific error code otherwise.
+ * @attention
+ * The total number of mutexes is pre-configured. If there are no available mutexes, the mutex creation will fail.
+ *
+ * @param muxHandle [OUT] Handle pointer of the successfully created mutex. The value of handle should be in
+ * [0, LOSCFG_BASE_IPC_MUX_LIMIT - 1].
+ *
+ * @retval #LOS_ERRNO_MUX_PTR_NULL The muxHandle pointer is NULL.
+ * @retval #LOS_ERRNO_MUX_ALL_BUSY No available mutex.
+ * @retval #LOS_OK The mutex is successfully created.
+ * @par Dependency:
+ * - los_mux.h: the header file that contains the API declaration.
+ * @see LOS_MuxDelete
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT32 LOS_MuxCreate(UINT32 *muxHandle);
+
+/**
+ * @ingroup los_mux
+ * @brief Delete a mutex.
+ *
+ * @par Description:
+ * This API is used to delete a specified mutex. Return LOS_OK if the mutex deletion is successfully,
+ * otherwise return specific error code.
+ * @attention
+ *
+ * - The specific mutex should be created firstly.
+ * - The mutex can be deleted successfully only when there is no other tasks pend on it.
+ *
+ *
+ * @param muxHandle [IN] The mutex handle to be deleted. The value of handle should be in
+ * [0, LOSCFG_BASE_IPC_MUX_LIMIT - 1].
+ *
+ * @retval #LOS_ERRNO_MUX_INVALID Invalid handle or mutex in use.
+ * @retval #LOS_ERRNO_MUX_PENDED Tasks pended on this mutex.
+ * @retval #LOS_OK The mutex is successfully deleted.
+ * @par Dependency:
+ * - los_mux.h: the header file that contains the API declaration.
+ * @see LOS_MuxCreate
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT32 LOS_MuxDelete(UINT32 muxHandle);
+
+/**
+ * @ingroup los_mux
+ * @brief Wait to lock a mutex.
+ *
+ * @par Description:
+ * This API is used to wait for a specified period of time to lock a mutex.
+ * @attention
+ *
+ * - The specific mutex should be created firstly.
+ * - The function fails if the mutex that is waited on is already locked by another thread when the task scheduling
+ * is disabled.
+ * - Do not wait on a mutex during an interrupt.
+ * - The priority inheritance protocol is supported. If a higher-priority thread is waiting on a mutex, it changes
+ * the priority of the thread that owns the mutex to avoid priority inversion.
+ * - A recursive mutex can be locked more than once by the same thread.
+ * - Do not recommend to use this API in software timer callback.
+ *
+ *
+ * @param muxHandle [IN] The mutex handle to be waited for. The value of handle should be
+ * in [0, LOSCFG_BASE_IPC_MUX_LIMIT - 1].
+ * @param timeout [IN] Waiting time. The value range is [0, LOS_WAIT_FOREVER](unit: Tick).
+ *
+ * @retval #LOS_ERRNO_MUX_INVALID The mutex state (for example, the mutex does not exist or is not in use)
+ * is not applicable for the current operation.
+ * @retval #LOS_ERRNO_MUX_UNAVAILABLE The mutex fails to be locked because it is locked by another thread and
+ * a period of time is not set for waiting for the mutex to become available.
+ * @retval #LOS_ERRNO_MUX_PEND_INTERR The mutex is being locked during an interrupt.
+ * @retval #LOS_ERRNO_MUX_PEND_IN_LOCK The mutex is waited on when the task scheduling is disabled.
+ * @retval #LOS_ERRNO_MUX_TIMEOUT The mutex waiting times out.
+ * @retval #LOS_OK The mutex is successfully locked.
+ * @par Dependency:
+ * - los_mux.h: the header file that contains the API declaration.
+ * @see LOS_MuxCreate | LOS_MuxPost
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT32 LOS_MuxPend(UINT32 muxHandle, UINT32 timeout);
+/*参数说明:
+
+muxHandle:互斥信号量句柄,即互斥信号量创建成功后返回的值。
+timeout:等待互斥信号量的超时时间,单位为系统时钟节拍。如果设置为0,则表示永久等待。
+返回值说明:
+
+返回 LOS_OK 表示成功获取互斥信号量。
+返回错误码表示获取互斥信号量失败,可能是由于传入的参数无效或者超时等原因导致。*/
+/**
+ * @ingroup los_mux
+ * @brief Release a mutex.
+ *
+ * @par Description:
+ * This API is used to release a specified mutex.
+ * @attention
+ *
+ * - The specific mutex should be created firstly.
+ * - Do not release a mutex during an interrupt.
+ * - If a recursive mutex is locked for many times, it must be unlocked for the same times to be released.
+ *
+ *
+ * @param muxHandle [IN] The mutex handle to be released. The value of handle should be in
+ * [0, LOSCFG_BASE_IPC_MUX_LIMIT - 1].
+ *
+ * @retval #LOS_ERRNO_MUX_INVALID The mutex state (for example, the mutex does not exist or is not in use
+ * or owned by other thread) is not applicable for the current operation.
+ * @retval #LOS_ERRNO_MUX_PEND_INTERR The mutex is being released during an interrupt.
+ * @retval #LOS_OK The mutex is successfully released.
+ * @par Dependency:
+ * - los_mux.h: the header file that contains the API declaration.
+ * @see LOS_MuxCreate | LOS_MuxPend
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT32 LOS_MuxPost(UINT32 muxHandle);
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif
+#endif /* __cplusplus */
+
+#endif /* _LOS_MUX_H */
diff --git a/kkk/los_perf.h b/kkk/los_perf.h
new file mode 100644
index 0000000..b075948
--- /dev/null
+++ b/kkk/los_perf.h
@@ -0,0 +1,501 @@
+/* ----------------------------------------------------------------------------
+ * Copyright (c) Huawei Technologies Co., Ltd. 2017-2020. All rights reserved.
+ * Description: LiteOS Performance Monitor Module Implementation
+ * Author: Huawei LiteOS Team
+ * Create: 2017-01-01
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * --------------------------------------------------------------------------- */
+
+/**
+ * @defgroup los_perf Perf
+ * @ingroup kernel
+ */
+
+#ifndef _LOS_PERF_H
+#define _LOS_PERF_H
+
+#include "los_typedef.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+/**
+ * @ingroup los_perf
+ * Perf max sample filter task number.
+ */
+#define PERF_MAX_FILTER_TSKS 32
+
+/**
+ * @ingroup los_perf
+ * Perf max sample event counter's number.
+ */
+#define PERF_MAX_EVENT 7
+
+/**
+ * @ingroup los_perf
+ * Perf max backtrace depth.
+ */
+#define PERF_MAX_CALLCHAIN_DEPTH 10
+
+/**
+ * @ingroup los_perf
+ * Perf sample data buffer's water mark 1/N.
+ */
+#define PERF_BUFFER_WATERMARK_ONE_N 2
+
+/**
+ * @ingroup los_perf
+ * Perf state.
+ */
+enum PerfStatus {
+ PERF_UNINIT, /**< perf isn't inited */
+ PERF_STARTED, /**< perf is started */
+ PERF_STOPED, /**< perf is stopped */
+};
+/*枚举类型 PerfStatus 包含了三个枚举常量:
+
+PERF_UNINIT:表示性能监控未初始化的状态。
+PERF_STARTED:表示性能监控已经开始的状态。
+PERF_STOPED:表示性能监控已经停止的状态。
+通过使用这个枚举类型,可以方便地表示和判断性能监控的当前状态。*/
+/**
+ * @ingroup los_perf
+ * Define the type of the perf sample data buffer water mark hook function.
+ *
+ */
+typedef VOID (*PERF_BUF_NOTIFY_HOOK)(VOID);
+
+/**
+ * @ingroup los_perf
+ * Define the type of the perf sample data buffer flush hook function.
+ *
+ */
+typedef VOID (*PERF_BUF_FLUSH_HOOK)(VOID *addr, UINT32 size);
+
+/**
+ * @ingroup los_perf
+ * Perf error code: Bad status.
+ *
+ * Value: 0x02002000
+ *
+ * Solution: Follow the perf state machine.
+ */
+#define LOS_ERRNO_PERF_STATUS_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_PERF, 0x00)
+
+/**
+ * @ingroup los_perf
+ * Perf error code: Hardware pmu init failed.
+ *
+ * Value: 0x02002001
+ *
+ * Solution: Check the pmu hwi irq.
+ */
+#define LOS_ERRNO_PERF_HW_INIT_ERROR LOS_ERRNO_OS_ERROR(LOS_MOD_PERF, 0x01)
+
+/**
+ * @ingroup los_perf
+ * Perf error code: Hrtimer init failed for hrtimer timed pmu init.
+ *
+ * Value: 0x02002002
+ *
+ * Solution: Check the Hrtimer init.
+ */
+#define LOS_ERRNO_PERF_TIMED_INIT_ERROR LOS_ERRNO_OS_ERROR(LOS_MOD_PERF, 0x02)
+
+/**
+ * @ingroup los_perf
+ * Perf error code: Software pmu init failed.
+ *
+ * Value: 0x02002003
+ *
+ * Solution: Check the Perf software events init.
+ */
+#define LOS_ERRNO_PERF_SW_INIT_ERROR LOS_ERRNO_OS_ERROR(LOS_MOD_PERF, 0x03)
+
+/**
+ * @ingroup los_perf
+ * Perf error code: Perf buffer init failed.
+ *
+ * Value: 0x02002004
+ *
+ * Solution: Check the buffer init size.
+ */
+#define LOS_ERRNO_PERF_BUF_ERROR LOS_ERRNO_OS_ERROR(LOS_MOD_PERF, 0x04)
+
+/**
+ * @ingroup los_perf
+ * Perf error code: Perf pmu type error.
+ *
+ * Value: 0x02002005
+ *
+ * Solution: Check whether the corresponding pmu is enabled in the menuconfig.
+ */
+#define LOS_ERRNO_PERF_INVALID_PMU LOS_ERRNO_OS_ERROR(LOS_MOD_PERF, 0x05)
+
+/**
+ * @ingroup los_perf
+ * Perf error code: Perf pmu config error.
+ *
+ * Value: 0x02002006
+ *
+ * Solution: Check the config attr of event id and event period.
+ */
+#define LOS_ERRNO_PERF_PMU_CONFIG_ERROR LOS_ERRNO_OS_ERROR(LOS_MOD_PERF, 0x06)
+
+/**
+ * @ingroup los_perf
+ * Perf error code: Perf pmu config attr is null.
+ *
+ * Value: 0x02002007
+ *
+ * Solution: Check if the input params of attr is null.
+ */
+#define LOS_ERRNO_PERF_CONFIG_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_PERF, 0x07)
+
+/**
+ * @ingroup los_perf
+ * Perf types
+ */
+enum PerfEventType {
+ PERF_EVENT_TYPE_HW, /**< boards common hw events */
+ PERF_EVENT_TYPE_TIMED, /**< hrtimer timed events */
+ PERF_EVENT_TYPE_SW, /**< software trace events */
+ PERF_EVENT_TYPE_RAW, /**< boards special hw events, see enum PmuEventType in corresponding arch headfile */
+
+ PERF_EVENT_TYPE_MAX
+};
+/*枚举类型 PerfEventType 包含了四个枚举常量:
+
+PERF_EVENT_TYPE_HW:表示硬件事件类型,用于表示板载通用硬件事件。
+PERF_EVENT_TYPE_TIMED:表示定时事件类型,用于表示高精度定时器定时事件。
+PERF_EVENT_TYPE_SW:表示软件事件类型,用于表示软件跟踪事件。
+PERF_EVENT_TYPE_RAW:表示原始事件类型,用于表示特殊板载硬件事件,在对应的架构头文件中有关于枚举 PmuEventType 的定义。
+通过使用这个枚举类型,可以方便地表示和区分不同类型的性能事件,便于在代码中进行处理和管理。*/
+/**
+ * @ingroup los_perf
+ * Common hardware pmu events
+ */
+enum PmuHwId {
+ PERF_COUNT_HW_CPU_CYCLES = 0, /**< cpu cycle event */
+ PERF_COUNT_HW_INSTRUCTIONS, /**< instruction event */
+ PERF_COUNT_HW_DCACHE_REFERENCES, /**< dcache access event */
+ PERF_COUNT_HW_DCACHE_MISSES, /**< dcache miss event */
+ PERF_COUNT_HW_ICACHE_REFERENCES, /**< icache access event */
+ PERF_COUNT_HW_ICACHE_MISSES, /**< icache miss event */
+ PERF_COUNT_HW_BRANCH_INSTRUCTIONS, /**< software change of pc event */
+ PERF_COUNT_HW_BRANCH_MISSES, /**< branch miss event */
+
+ PERF_COUNT_HW_MAX,
+};
+/*枚举类型 PmuHwId 包含了多个枚举常量,每个常量代表一个具体的硬件事件:
+
+PERF_COUNT_HW_CPU_CYCLES:表示 CPU 循环周期事件。
+PERF_COUNT_HW_INSTRUCTIONS:表示指令执行事件。
+PERF_COUNT_HW_DCACHE_REFERENCES:表示数据缓存访问事件。
+PERF_COUNT_HW_DCACHE_MISSES:表示数据缓存缺失事件。
+PERF_COUNT_HW_ICACHE_REFERENCES:表示指令缓存访问事件。
+PERF_COUNT_HW_ICACHE_MISSES:表示指令缓存缺失事件。
+PERF_COUNT_HW_BRANCH_INSTRUCTIONS:表示分支指令事件。
+PERF_COUNT_HW_BRANCH_MISSES:表示分支缺失事件。
+通过使用这个枚举类型的常量,可以指定要监控的硬件事件,方便地在代码中进行配置和统计。*/
+/**
+ * @ingroup los_perf
+ * Common hrtimer timed events
+ */
+enum PmuTimedId {
+ PERF_COUNT_CPU_CLOCK = 0, /**< hrtimer timed event */
+};
+
+/**
+ * @ingroup los_perf
+ * Common software pmu events
+ */
+enum PmuSwId {
+ PERF_COUNT_SW_TASK_SWITCH = 1, /**< task switch event */
+ PERF_COUNT_SW_IRQ_RESPONSE, /**< irq response event */
+ PERF_COUNT_SW_MEM_ALLOC, /**< memory alloc event */
+ PERF_COUNT_SW_MUX_PEND, /**< mutex pend event */
+
+ PERF_COUNT_SW_MAX,
+};
+/*枚举类型 PmuSwId 包含了多个枚举常量,每个常量代表一个具体的软件事件:
+
+PERF_COUNT_SW_TASK_SWITCH:表示任务切换事件。
+PERF_COUNT_SW_IRQ_RESPONSE:表示中断响应事件。
+PERF_COUNT_SW_MEM_ALLOC:表示内存分配事件。
+PERF_COUNT_SW_MUX_PEND:表示互斥锁挂起事件。
+通过使用这个枚举类型的常量,可以指定要监控的软件事件,方便地在代码中进行配置和统计。*/
+/**
+ * @ingroup los_perf
+ * perf sample data types
+ * Config it through PerfConfigAttr->sampleType.
+ */
+enum PerfSampleType {
+ PERF_RECORD_CPU = 1U << 0, /**< record current cpuid */
+ PERF_RECORD_TID = 1U << 1, /**< record current task id */
+ PERF_RECORD_TYPE = 1U << 2, /**< record event type */
+ PERF_RECORD_PERIOD = 1U << 3, /**< record event period */
+ PERF_RECORD_TIMESTAMP = 1U << 4, /**< record timestamp */
+ PERF_RECORD_IP = 1U << 5, /**< record instruction pointer */
+ PERF_RECORD_CALLCHAIN = 1U << 6, /**< record backtrace */
+};
+/*枚举类型 PerfSampleType 包含了多个枚举常量,每个常量代表一个具体的采样数据类型:
+
+PERF_RECORD_CPU:记录当前 CPU 的 ID。
+PERF_RECORD_TID:记录当前任务的 ID。
+PERF_RECORD_TYPE:记录事件类型。
+PERF_RECORD_PERIOD:记录事件周期。
+PERF_RECORD_TIMESTAMP:记录时间戳。
+PERF_RECORD_IP:记录指令指针。
+PERF_RECORD_CALLCHAIN:记录回溯信息。
+通过使用这个枚举类型的常量,可以方便地表示和区分不同类型的性能采样数据,便于在代码中进行处理和管理。*/
+/**
+ * @ingroup los_perf
+ * perf configuration sub event information
+ *
+ * This structure is used to config specific events attributes.
+ */
+typedef struct {
+ UINT32 type; /**< enum PerfEventType */
+ struct {
+ UINT32 eventId; /**< the specific event corresponds to the PerfEventType */
+ UINT32 period; /**< event period, for every "period"th occurrence of the event a
+ sample will be recorded */
+ } events[PERF_MAX_EVENT]; /**< perf event list */
+ UINT32 eventsNr; /**< total perf event number */
+ BOOL predivided; /**< whether to prescaler (once every 64 counts),
+ which only take effect on cpu cycle hardware event */
+} PerfEventConfig;
+/*type:表示性能事件类型,是一个 UINT32 类型的值,对应于 PerfEventType 枚举。
+events:一个数组,用于存储具体的事件信息。每个元素都包含两个成员变量:
+eventId:表示特定事件的标识符,是一个 UINT32 类型的值。
+period:表示事件的周期,即每隔多少次事件发生时记录一次样本,是一个 UINT32 类型的值。
+eventsNr:表示总共的性能事件数量,是一个 UINT32 类型的值。
+predivided:表示是否进行预分频(每64个计数器进行一次),仅对CPU循环硬件事件有效。它是一个 BOOL 类型的值,用于表示是否进行预分频操作。*/
+/**
+ * @ingroup los_perf
+ * perf configuration main information
+ *
+ * This structure is used to set perf sampling attributes, including events, tasks and other information.
+ */
+typedef struct {
+ PerfEventConfig eventsCfg; /**< perf event config */
+ UINT32 taskIds[PERF_MAX_FILTER_TSKS]; /**< perf task filter list (whitelist) */
+ UINT32 taskIdsNr; /**< task numbers of task filter whiltelist,
+ if set 0 perf will sample all tasks */
+ UINT32 sampleType; /**< type of data to sample defined in PerfSampleType */
+ BOOL needSample; /**< whether to sample data */
+ BOOL taskFilterEnable; /**< whether to filter tasks */
+} PerfConfigAttr;
+
+extern VOID OsPerfHook(UINT32 event);
+
+#if defined(LOSCFG_KERNEL_PERF) && defined(LOSCFG_PERF_SW_PMU)
+#define LOS_PERF(EVENT) do { \
+ OsPerfHook(EVENT); \
+ } while (0)
+#else
+#define LOS_PERF(EVENT)
+#endif
+/*PerfConfigAttr 结构体包含以下成员变量:
+
+eventsCfg:表示性能事件的配置信息,是一个 PerfEventConfig 结构体类型的值。
+taskIds:表示任务 ID 的过滤列表,是一个 UINT32 类型的数组,最多可以存储 PERF_MAX_FILTER_TSKS 个任务 ID。
+taskIdsNr:表示任务 ID 的数量,是一个 UINT32 类型的值。
+sampleType:表示需要采样的数据类型,是一个 UINT32 类型的值,对应于 PerfSampleType 枚举。
+needSample:表示是否需要采样数据,是一个 BOOL 类型的值。
+taskFilterEnable:表示是否启用任务过滤器,是一个 BOOL 类型的值。
+OsPerfHook 函数用于处理性能事件的回调函数,接收一个 UINT32 类型的参数 event,表示触发的性能事件类型。
+
+LOS_PERF 宏定义用于触发性能事件,如果操作系统配置了 LOSCFG_KERNEL_PERF 和 LOSCFG_PERF_SW_PMU 宏,则会调用 OsPerfHook 函数,否则该宏为空操作。*/
+/**
+ * @ingroup los_perf
+ * @brief Init perf.
+ *
+ * @par Description:
+ *
+ * - Used to initialize the perf module, including initializing the PMU, allocating memory,
+ * etc.,which is called during the phase of system initialization.
+ *
+ * @attention
+ *
+ * - If buf is not null, user must ensure size is not bigger than buf's length.
+ *
+ *
+ * @param buf [IN] Pointer of sample data buffer;Use the dynamically allocated memory if the pointer is NULL.
+ * @param size [IN] Length of sample data buffer;
+ *
+ * @retval #LOS_ERRNO_PERF_STATUS_INVALID Perf in a wrong status.
+ * @retval #LOS_ERRNO_PERF_HW_INIT_ERROR Perf hardware pmu init fail.
+ * @retval #LOS_ERRNO_PERF_TIMED_INIT_ERROR Perf timed pmu init fail.
+ * @retval #LOS_ERRNO_PERF_SW_INIT_ERROR Perf software pmu init fail.
+ * @retval #LOS_ERRNO_PERF_BUF_ERROR Perf buffer init fail.
+ * @retval #LOS_OK Perf init success.
+ * @par Dependency:
+ *
+ * - los_perf.h: the header file that contains the API declaration.
+ *
+ * @since Huawei LiteOS V200R005C00
+ */
+UINT32 LOS_PerfInit(VOID *buf, UINT32 size);
+
+/**
+ * @ingroup los_perf
+ * @brief Start perf sampling.
+ *
+ * @par Description
+ * Start perf sampling.
+ * @attention
+ * None.
+ *
+ * @param sectionId [IN] Set the section id for marking this piece of data in the perf sample data buffer.
+ * @retval None.
+ * @par Dependency:
+ *
+ * - los_perf.h: the header file that contains the API declaration.
+ *
+ * @since Huawei LiteOS V200R005C00
+ */
+VOID LOS_PerfStart(UINT32 sectionId);
+
+/**
+ * @ingroup los_perf
+ * @brief Stop perf sampling.
+ *
+ * @par Description
+ * Stop perf sampling.
+ * @attention
+ * None.
+ *
+ * @param None.
+ *
+ * @retval None.
+ * @par Dependency:
+ *
+ * - los_perf.h: the header file that contains the API declaration.
+ *
+ * @since Huawei LiteOS V200R005C00
+ */
+VOID LOS_PerfStop(VOID);
+
+/**
+ * @ingroup los_perf
+ * @brief Config perf parameters.
+ *
+ * @par Description
+ * Config perf parameters before sample, for example, sample event, sample task, etc. it need to be called
+ * before LOS_PerfStart.
+ * @attention
+ * None.
+ *
+ * @param attr [IN] Address of a perf event attr struct.
+ *
+ * @retval #LOS_ERRNO_PERF_STATUS_INVALID Perf in a wrong status.
+ * @retval #LOS_ERRNO_PERF_CONFIG_NULL Attr is null.
+ * @retval #LOS_ERRNO_PERF_INVALID_PMU Config perf pmu with error type.
+ * @retval #LOS_ERRNO_PERF_PMU_CONFIG_ERROR Config perf events fail with invaild event id or event period.
+ * @retval #LOS_OK Config success.
+ * @par Dependency:
+ *
+ * - los_perf.h: the header file that contains the API declaration.
+ *
+ * @since Huawei LiteOS V200R005C00
+ */
+UINT32 LOS_PerfConfig(PerfConfigAttr *attr);
+
+/**
+ * @ingroup los_perf
+ * @brief Read data from perf sample data buffer.
+ *
+ * @par Description
+ * Because perf sample data buffer is a ringbuffer, the data may be covered after user read ringbuffer.
+ * @attention
+ * None.
+ *
+ * @param dest [IN] The destionation address.
+ * @param size [IN] Read size.
+ * @retval #UINT32 The really read bytes.
+ * @par Dependency:
+ *
+ * - los_perf.h: the header file that contains the API declaration.
+ *
+ * @since Huawei LiteOS V200R005C00
+ */
+UINT32 LOS_PerfDataRead(CHAR *dest, UINT32 size);
+
+/**
+ * @ingroup los_perf
+ * @brief Register perf sample data buffer water mark hook function.
+ *
+ * @par Description
+ *
+ * - Register perf sample data buffer water mark hook function.
+ * - The registered hook will be called when buffer reaches the water mark./li>
+ *
+ * @attention
+ * None.
+ *
+ * @param func [IN] Buffer water mark hook function.
+ *
+ * @retval None.
+ * @par Dependency:
+ *
+ * - los_perf.h: the header file that contains the API declaration.
+ *
+ * @since Huawei LiteOS V200R005C00
+ */
+VOID LOS_PerfNotifyHookReg(const PERF_BUF_NOTIFY_HOOK func);
+
+/**
+ * @ingroup los_perf
+ * @brief Register perf sample data buffer flush hook function.
+ *
+ * @par Description
+ *
+ * - Register perf sample data buffer flush hook function.
+ * - The flush hook will be called when the buffer be read or written.
+ *
+ * @attention
+ * None.
+ *
+ * @param func [IN] Buffer flush hook function.
+ *
+ * @retval None.
+ * @par Dependency:
+ *
+ * - los_perf.h: the header file that contains the API declaration.
+ *
+ * @since Huawei LiteOS V200R005C00
+ */
+VOID LOS_PerfFlushHookReg(const PERF_BUF_FLUSH_HOOK func);
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#endif /* _LOS_PERF_H */
diff --git a/kkk/los_printf.h b/kkk/los_printf.h
new file mode 100644
index 0000000..adc7ca7
--- /dev/null
+++ b/kkk/los_printf.h
@@ -0,0 +1,408 @@
+/* ----------------------------------------------------------------------------
+ * Copyright (c) Huawei Technologies Co., Ltd. 2013-2020. All rights reserved.
+ * Description: Los_printf HeadFile
+ * Author: Huawei LiteOS Team
+ * Create: 2013-01-01
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * --------------------------------------------------------------------------- */
+
+/**
+ * @defgroup los_printf Printf
+ * @ingroup kernel
+ */
+
+#ifndef _LOS_PRINTF_H
+#define _LOS_PRINTF_H
+
+#include "stdarg.h"
+#include "los_config.h"
+#include "los_typedef.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+#ifdef LOSCFG_SHELL_LK
+extern void LOS_LkPrint(int level, const char *func, int line, const char *fmt, ...);
+#endif
+/*LOS_LkPrint 函数接受以下参数:
+
+level:表示打印消息的级别,是一个整数。
+func:表示打印消息的函数名,是一个指向字符常量的指针。
+line:表示打印消息所在的行号,是一个整数。
+fmt:表示打印消息的格式字符串,是一个指向字符常量的指针。
+...:表示可变参数列表,用于根据格式字符串打印相应的消息内容。
+该函数用于在操作系统中打印消息,可以根据不同的级别和格式打印出不同的信息,用于调试或记录运行时的相关信息。函数的实现可能在其他地方定义。*/
+/**
+ * @ingroup los_printf
+ * log print level definition, LOS_EMG_LEVEL is set to 0, it means the log is emergency.
+ */
+#define LOS_EMG_LEVEL 0
+
+/**
+ * @ingroup los_printf
+ * log print level definition, LOS_COMMOM_LEVEL is set to 1, it means the log is common.
+ */
+#define LOS_COMMOM_LEVEL (LOS_EMG_LEVEL + 1)
+
+/**
+ * @ingroup los_printf
+ * log print level definition, LOS_ERR_LEVEL is set to 2, it means it is a error log.
+ */
+#define LOS_ERR_LEVEL (LOS_COMMOM_LEVEL + 1)
+
+/**
+ * @ingroup los_printf
+ * log print level definition, LOS_WARN_LEVEL is set to 3, it means it is a warning log.
+ */
+#define LOS_WARN_LEVEL (LOS_ERR_LEVEL + 1)
+
+/**
+ * @ingroup los_printf
+ * log print level definition, LOS_INFO_LEVEL is set to 4, it means the log is an information.
+ */
+#define LOS_INFO_LEVEL (LOS_WARN_LEVEL + 1)
+
+/**
+ * @ingroup los_printf
+ * log print level definition, LOS_DEBUG_LEVEL is set to 5, it means it is a debug log.
+ */
+#define LOS_DEBUG_LEVEL (LOS_INFO_LEVEL + 1)
+
+/**
+ * @ingroup los_printf
+ * The default log print level. PRINT_LEVEL is set to debug log level if
+ * LOSCFG_SHELL_LK is defined, otherwise PRINT_LEVEL is set to error log level.
+ * The default log print level means only print the log which its level value
+ * is lower than or equal to the PRINT_LEVEL.
+ */
+#ifdef LOSCFG_SHELL_LK
+#define PRINT_LEVEL LOS_DEBUG_LEVEL
+#else
+#define PRINT_LEVEL LOS_ERR_LEVEL
+#endif
+
+typedef VOID (*pf_OUTPUT)(const CHAR *fmt, ...);
+/*这段代码定义了一个名为 PRINT_LEVEL 的宏以及一个名为 pf_OUTPUT 的函数指针类型。
+
+PRINT_LEVEL 宏根据条件判断是否定义为 LOS_DEBUG_LEVEL 或者 LOS_ERR_LEVEL。
+
+如果宏 LOSCFG_SHELL_LK 被定义,则 PRINT_LEVEL 被定义为 LOS_DEBUG_LEVEL。
+否则, PRINT_LEVEL 被定义为 LOS_ERR_LEVEL。
+pf_OUTPUT 是一个函数指针类型,指向一个返回值为 VOID 的函数,
+该函数接受一个格式化字符串参数 fmt 和可变参数列表 ...。该函数指针类型可以用于声明指向相应函数的指针变量,使得函数的调用可以通过该指针进行。*/
+/**
+ * @ingroup los_printf
+ * @brief Format and print data.
+ *
+ * @par Description:
+ * Print argument(s) according to fmt.
+ *
+ * @attention
+ * None.
+ *
+ * @param fmt [IN] Type char*. It controls the ouput format as in C printf.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_printf.h: the header file that contains the API declaration.
+ * @see printf
+ * @since Huawei LiteOS V100R001C00
+ */
+extern void dprintf(const char *fmt, ...);
+
+#define diag_printf dprintf
+
+/**
+ * @ingroup los_printf
+ * @brief Format and print debug log.
+ *
+ * @par Description:
+ * Define function macros PRINT_DEBUG. The Function can print debug log according to fmt
+ * when the PRINT_LEVEL is set to LOS_DEBUG_LEVEL.
+ *
+ * @attention
+ * None.
+ *
+ * @param fmt [IN] Type: const CHAR *. It controls the ouput format as in C printf.
+ * @param args [IN] It point to the variable parameters.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_printf.h: the header file that contains the API declaration.
+ * @see dprintf
+ * @since Huawei LiteOS V100R001C00
+ */
+#ifndef PRINT_DEBUG
+#if PRINT_LEVEL < LOS_DEBUG_LEVEL
+#define PRINT_DEBUG(fmt, ...)
+#else
+#ifdef LOSCFG_SHELL_LK
+#define PRINT_DEBUG(fmt, ...) LOS_LkPrint(LOS_DEBUG_LEVEL, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__)
+#else
+#define PRINT_DEBUG(fmt, ...) do { \
+ (dprintf("[DEBUG] "), dprintf(fmt, ##__VA_ARGS__)); \
+} while (0)
+#endif
+#endif
+#endif
+/*当宏 PRINT_DEBUG 未被定义时,通过条件编译判断 PRINT_LEVEL 是否小于 LOS_DEBUG_LEVEL。如果是,则将 PRINT_DEBUG 宏定义为空操作;否则,进入下一层条件编译。
+
+当宏 LOSCFG_SHELL_LK 被定义时,PRINT_DEBUG 宏被定义为调用 LOS_LkPrint 函数,
+输出 [DEBUG] 级别的日志信息,其中第一个参数为日志级别 LOS_DEBUG_LEVEL,
+第二个参数为当前函数名 __FUNCTION__,第三个参数为当前行号 __LINE__,
+第四个参数为格式化字符串 fmt,后面的可变参数列表 ...
+用于补充格式化字符串中占位符的值。
+
+否则,PRINT_DEBUG 宏被定义为输出 [DEBUG] 级别的日志信息到控制台。*/
+/**
+ * @ingroup los_printf
+ * @brief Format and print information log.
+ *
+ * @par Description:
+ * Define function macros PRINT_INFO. The Function can print information log according to fmt
+ * when the PRINT_LEVEL is greater than or equal to LOS_INFO_LEVEL.
+ *
+ * @attention
+ * None.
+ *
+ * @param fmt [IN] Type: const CHAR *. It controls the ouput format as in C printf.
+ * @param args [IN] It point to the variable parameters.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_printf.h: the header file that contains the API declaration.
+ * @see dprintf
+ * @since Huawei LiteOS V100R001C00
+ */
+#ifndef PRINT_INFO
+#if PRINT_LEVEL < LOS_INFO_LEVEL
+#define PRINT_INFO(fmt, ...)
+#else
+#ifdef LOSCFG_SHELL_LK
+#define PRINT_INFO(fmt, ...) LOS_LkPrint(LOS_INFO_LEVEL, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__)
+#else
+#define PRINT_INFO(fmt, ...) do { \
+ (dprintf("[INFO] "), dprintf(fmt, ##__VA_ARGS__)); \
+} while (0)
+#endif
+#endif
+#endif
+/*当宏 PRINT_INFO 未被定义时,通过条件编译判断 PRINT_LEVEL 是否小于 LOS_INFO_LEVEL。
+如果是,则将 PRINT_INFO 宏定义为空操作;否则,进入下一层条件编译。
+
+当宏 LOSCFG_SHELL_LK 被定义时,PRINT_INFO 宏被定义为调用 LOS_LkPrint 函数,
+输出 [INFO] 级别的日志信息,其中第一个参数为日志级别 LOS_INFO_LEVEL,
+第二个参数为当前函数名 __FUNCTION__,第三个参数为当前行号 __LINE__,
+第四个参数为格式化字符串 fmt,后面的可变参数列表 ... 用于补充格式化字符串中占位符的值。
+
+否则,PRINT_INFO 宏被定义为输出 [INFO] 级别的日志信息到控制台。*/
+/**
+ * @ingroup los_printf
+ * @brief Format and print warning log.
+ *
+ * @par Description:
+ * Define function macros PRINT_WARN. The Function can print warning log according to fmt
+ * when the PRINT_LEVEL is greater than or equal to LOS_WARN_LEVEL.
+ *
+ * @attention
+ * None.
+ *
+ * @param fmt [IN] Type: const CHAR *. It controls the ouput format as in C printf.
+ * @param args [IN] It point to the variable parameters.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_printf.h: the header file that contains the API declaration.
+ * @see dprintf
+ * @since Huawei LiteOS V100R001C00
+ */
+#ifndef PRINT_WARN
+#if PRINT_LEVEL < LOS_WARN_LEVEL
+#define PRINT_WARN(fmt, ...)
+#else
+#ifdef LOSCFG_SHELL_LK
+#define PRINT_WARN(fmt, ...) LOS_LkPrint(LOS_WARN_LEVEL, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__)
+#else
+#define PRINT_WARN(fmt, ...) do { \
+ (dprintf("[WARN] "), dprintf(fmt, ##__VA_ARGS__)); \
+} while (0)
+#endif
+#endif
+#endif
+/*当宏 PRINT_WARN 未被定义时,通过条件编译判断 PRINT_LEVEL 是否小于 LOS_WARN_LEVEL。如果是,则将 PRINT_WARN 宏定义为空操作;否则,进入下一层条件编译。
+
+当宏 LOSCFG_SHELL_LK 被定义时,PRINT_WARN 宏被定义为调用 LOS_LkPrint 函数,
+输出 [WARN] 级别的日志信息,其中第一个参数为日志级别 LOS_WARN_LEVEL,
+第二个参数为当前函数名 __FUNCTION__,第三个参数为当前行号 __LINE__,
+第四个参数为格式化字符串 fmt,后面的可变参数列表 ... 用于补充格式化字符串中占位符的值。
+
+否则,PRINT_WARN 宏被定义为输出 [WARN] 级别的日志信息到控制台。*/
+/**
+ * @ingroup los_printf
+ * @brief Format and print error log.
+ *
+ * @par Description:
+ * Define function macros PRINT_ERR. The Function can print error log according to fmt
+ * when the PRINT_LEVEL is greater than or equal to LOS_ERR_LEVEL.
+ *
+ * @attention
+ * None.
+ *
+ * @param fmt [IN] Type: const CHAR *. It controls the ouput format as in C printf.
+ * @param args [IN] It point to the variable parameters.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_printf.h: the header file that contains the API declaration.
+ * @see dprintf
+ * @since Huawei LiteOS V100R001C00
+ */
+#ifndef PRINT_ERR
+#if PRINT_LEVEL < LOS_ERR_LEVEL
+#define PRINT_ERR(fmt, ...)
+#else
+#ifdef LOSCFG_SHELL_LK
+#define PRINT_ERR(fmt, ...) LOS_LkPrint(LOS_ERR_LEVEL, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__)
+#else
+#define PRINT_ERR(fmt, ...) do { \
+ (dprintf("[ERR] "), dprintf(fmt, ##__VA_ARGS__)); \
+} while (0)
+#endif
+#endif
+#endif
+/*当宏 PRINT_ERR 未被定义时,通过条件编译判断 PRINT_LEVEL 是否小于 LOS_ERR_LEVEL。如果是,则将 PRINT_ERR 宏定义为空操作;否则,进入下一层条件编译。
+
+当宏 LOSCFG_SHELL_LK 被定义时,PRINT_ERR 宏被定义为调用 LOS_LkPrint 函数,
+输出 [ERR] 级别的日志信息,其中第一个参数为日志级别 LOS_ERR_LEVEL
+,第二个参数为当前函数名 __FUNCTION__,第三个参数为当前行号 __LINE__,
+第四个参数为格式化字符串 fmt,后面的可变参数列表 ... 用于补充格式化字符串中占位符的值。
+
+否则,PRINT_ERR 宏被定义为输出 [ERR] 级别的日志信息到控制台。*/
+/**
+ * @ingroup los_printf
+ * @brief Format and print common log.
+ *
+ * @par Description:
+ * Define function macros PRINTK. The Function can print common log according to fmt
+ * when the PRINT_LEVEL is greater than or equal to LOS_COMMOM_LEVEL.
+ *
+ * @attention
+ * None.
+ *
+ * @param fmt [IN] Type: const CHAR *. It controls the ouput format as in C printf.
+ * @param args [IN] It point to the variable parameters.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_printf.h: the header file that contains the API declaration.
+ * @see dprintf
+ * @since Huawei LiteOS V100R001C00
+ */
+#ifndef PRINTK
+#if PRINT_LEVEL < LOS_COMMOM_LEVEL
+#define PRINTK(fmt, ...)
+#else
+#ifdef LOSCFG_SHELL_LK
+#define PRINTK(fmt, ...) LOS_LkPrint(LOS_COMMOM_LEVEL, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__)
+#else
+#define PRINTK(fmt, ...) dprintf(fmt, ##__VA_ARGS__)
+#endif
+#endif
+#endif
+/*这段代码定义了一个名为 PRINTK 的宏。
+
+当宏 PRINTK 未被定义时,通过条件编译判断 PRINT_LEVEL 是否小于 LOS_COMMOM_LEVEL。如果是,则将 PRINTK 宏定义为空操作;否则,进入下一层条件编译。
+
+当宏 LOSCFG_SHELL_LK 被定义时,PRINTK 宏被定义为调用 LOS_LkPrint 函数,
+输出 [COMM] 级别的日志信息,其中第一个参数为日志级别 LOS_COMMOM_LEVEL,
+第二个参数为当前函数名 __FUNCTION__,第三个参数为当前行号 __LINE__,
+第四个参数为格式化字符串 fmt,后面的可变参数列表 ... 用于补充格式化字符串中占位符的值。
+
+否则,PRINTK 宏被定义为输出格式化字符串到控制台。*/
+/**
+ * @ingroup los_printf
+ * @brief Format and print emergency log.
+ *
+ * @par Description:
+ * Define function macros PRINT_EMG. The Function can print emergency log according to fmt
+ * when the PRINT_LEVEL is greater than or equal to LOS_EMG_LEVEL.
+ *
+ * @attention
+ * None.
+ *
+ * @param fmt [IN] Type: const CHAR *. It controls the ouput format as in C printf.
+ * @param args [IN] It point to the variable parameters.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_printf.h: the header file that contains the API declaration.
+ * @see dprintf
+ * @since Huawei LiteOS V100R001C00
+ */
+#ifndef PRINT_EMG
+#if PRINT_LEVEL < LOS_EMG_LEVEL
+#define PRINT_EMG(fmt, ...)
+#else
+#define PRINT_EMG(fmt, ...) do { \
+ (dprintf("[EMG] "), dprintf(fmt, ##__VA_ARGS__)); \
+} while (0)
+#endif
+#endif
+/*这段代码定义了一个名为 PRINT_EMG 的宏。
+
+当宏 PRINT_EMG 未被定义时,通过条件编译判断 PRINT_LEVEL 是否小于 LOS_EMG_LEVEL。如果是,则将 PRINT_EMG 宏定义为空操作;否则,进入下一层条件编译。
+
+在 PRINT_LEVEL 大于等于 LOS_EMG_LEVEL 时,PRINT_EMG 宏被定义为输出 [EMG] 级别的日志信息到控制台。*/
+/**
+ * @ingroup los_printf
+ * @brief Format and print log.
+ *
+ * @par Description:
+ * Define function macros PRINT_RELEASE. The Function can print argument(s) according to fmt.
+ * It is same with dprintf function.
+ *
+ * @attention
+ * None.
+ *
+ * @param fmt [IN] Type: const CHAR *. It controls the ouput format as in C printf.
+ * @param args [IN] It point to the variable parameters.
+ *
+ * @retval None.
+ * @par Dependency:
+ * - los_printf.h: the header file that contains the API declaration.
+ * @see dprintf
+ * @since Huawei LiteOS V100R001C00
+ */
+#ifndef PRINT_RELEASE
+#define PRINT_RELEASE(fmt, ...) dprintf(fmt, ##__VA_ARGS__)
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#endif /* _LOS_PRINTF_H */
diff --git a/kkk/los_queue.h b/kkk/los_queue.h
new file mode 100644
index 0000000..a4ffe5e
--- /dev/null
+++ b/kkk/los_queue.h
@@ -0,0 +1,866 @@
+/* ----------------------------------------------------------------------------
+ * Copyright (c) Huawei Technologies Co., Ltd. 2013-2019. All rights reserved.
+ * Description: Queue
+ * Author: Huawei LiteOS Team
+ * Create: 2013-01-01
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * --------------------------------------------------------------------------- */
+
+/**
+ * @defgroup los_queue Queue
+ * @ingroup kernel
+ */
+
+#ifndef _LOS_QUEUE_H
+#define _LOS_QUEUE_H
+
+#include "los_base.h"
+#include "los_list.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+/**
+ * @ingroup los_queue
+ * Queue error code: The maximum number of queue resources is configured to 0.
+ *
+ * Value: 0x02000600.
+ *
+ * Solution: Configure the maximum number of queue resources to be greater than 0. If queue
+ * modules are not used, set the configuration item for the tailoring of the maximum number
+ * of queue resources to NO.
+ * @deprecated This error code is obsolete since LiteOS 5.0.0.
+ */
+#define LOS_ERRNO_QUEUE_MAXNUM_ZERO LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x00)
+/*宏的定义使用了 LOS_ERRNO_OS_ERROR 宏,并指定了参数 LOS_MOD_QUE 和 0x00。根据上下文推测,LOS_MOD_QUE 可能是表示与队列相关的模块。
+
+该宏的作用是生成一个错误码,用于表示队列的最大数量为零的错误情况。具体的错误码值可能在其他地方定义。*/
+/**
+ * @ingroup los_queue
+ * Queue error code: The queue block memory fails to be initialized.
+ *
+ * Value: 0x02000601.
+ *
+ * Solution: Allocate the queue block bigger memory partition, or decrease the maximum
+ * number of queue resources.
+ */
+#define LOS_ERRNO_QUEUE_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x01)
+/*这段代码定义了一个名为 LOS_ERRNO_QUEUE_NO_MEMORY 的宏,用于表示队列分配内存失败时的错误码。
+
+宏的定义使用了 LOS_ERRNO_OS_ERROR 宏,并指定了参数 LOS_MOD_QUE 和 0x01。根据上下文推测,LOS_MOD_QUE 可能是表示与队列相关的模块。
+
+该宏的作用是生成一个错误码,用于表示队列分配内存失败的错误情况。具体的错误码值可能在其他地方定义。*/
+/**
+ * @ingroup los_queue
+ * Queue error code: The memory for queue creation fails to be requested.
+ *
+ * Value: 0x02000602.
+ *
+ * Solution: Allocate more memory for queue creation, or decrease the queue length and
+ * the number of nodes in the queue to be created.
+ */
+#define LOS_ERRNO_QUEUE_CREATE_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x02)
+/*这段代码定义了一个名为 LOS_ERRNO_QUEUE_CREATE_NO_MEMORY 的宏,用于表示创建队列时内存分配失败的错误码。
+
+该宏使用了 LOS_ERRNO_OS_ERROR 宏,并指定了参数 LOS_MOD_QUE 和 0x02。根据上下文推测,LOS_MOD_QUE 可能是表示与队列相关的模块。
+
+因此,该宏的作用是生成一个错误码,用于表示创建队列时内存分配失败的错误情况。具体的错误码值可能在其他地方定义。*/
+/**
+ * @ingroup los_queue
+ * Queue error code: The size of the biggest message in the created queue is too big.
+ *
+ * Value: 0x02000603.
+ *
+ * Solution: Change the size of the biggest message in the created queue.
+ */
+#define LOS_ERRNO_QUEUE_SIZE_TOO_BIG LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x03)
+ /*宏的定义使用了 LOS_ERRNO_OS_ERROR 宏,并指定了参数 LOS_MOD_QUE 和 0x00。根据上下文推测,LOS_MOD_QUE 可能是表示与队列相关的模块。
+
+ 该宏的作用是生成一个错误码,用于表示队列的最大数量为零的错误情况。具体的错误码值可能在其他地方定义。*/
+
+/**
+ * @ingroup los_queue
+ * Queue error code: The upper limit of the number of created queues is exceeded.
+ *
+ * Value: 0x02000604.
+ *
+ * Solution: Increase the configured number of resources for queues.
+ */
+#define LOS_ERRNO_QUEUE_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x04)
+ /*这段代码定义了一个名为 LOS_ERRNO_QUEUE_NO_MEMORY 的宏,用于表示队列分配内存失败时的错误码。
+
+ 宏的定义使用了 LOS_ERRNO_OS_ERROR 宏,并指定了参数 LOS_MOD_QUE 和 0x01。根据上下文推测,LOS_MOD_QUE 可能是表示与队列相关的模块。
+
+ 该宏的作用是生成一个错误码,用于表示队列分配内存失败的错误情况。具体的错误码值可能在其他地方定义。*/
+
+/**
+ * @ingroup los_queue
+ * Queue error code: Invalid queue.
+ *
+ * Value: 0x02000605.
+ *
+ * Solution: Ensure that the passed-in queue ID is valid.
+ */
+#define LOS_ERRNO_QUEUE_NOT_FOUND LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x05)
+
+/**
+ * @ingroup los_queue
+ * Queue error code: The task is forbidden to be blocked on a queue when the task is locked.
+ *
+ * Value: 0x02000606.
+ *
+ * Solution: Unlock the task before using a queue.
+ */
+#define LOS_ERRNO_QUEUE_PEND_IN_LOCK LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x06)
+
+/**
+ * @ingroup los_queue
+ * Queue error code: The time set for waiting to processing the queue expires.
+ *
+ * Value: 0x02000607.
+ *
+ * Solution: Check whether the expiry time setting is appropriate.
+ */
+#define LOS_ERRNO_QUEUE_TIMEOUT LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x07)
+
+/**
+ * @ingroup los_queue
+ * Queue error code: The queue that blocks a task cannot be deleted.
+ *
+ * Value: 0x02000608.
+ *
+ * Solution: Enable the task to obtain resources rather than be blocked on the queue.
+ */
+#define LOS_ERRNO_QUEUE_IN_TSKUSE LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x08)
+
+/**
+ * @ingroup los_queue
+ * Queue error code: The queue cannot be written during an interrupt when the time for
+ * waiting to processing the queue expires.
+ *
+ * Value: 0x02000609.
+ *
+ * Solution: Set the expiry time to the never-waiting mode, or use asynchronous queues.
+ */
+#define LOS_ERRNO_QUEUE_WRITE_IN_INTERRUPT LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x09)
+
+/**
+ * @ingroup los_queue
+ * Queue error code: The queue is not created.
+ *
+ * Value: 0x0200060a.
+ *
+ * Solution: Check whether the passed-in queue handle value is valid.
+ */
+#define LOS_ERRNO_QUEUE_NOT_CREATE LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x0a)
+
+/**
+ * @ingroup los_queue
+ * Queue error code: Queue reading and writing are not synchronous.
+ *
+ * Value: 0x0200060b.
+ *
+ * Solution: Synchronize queue reading with queue writing.
+ */
+#define LOS_ERRNO_QUEUE_IN_TSKWRITE LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x0b)
+
+/**
+ * @ingroup los_queue
+ * Queue error code: Parameters passed in during queue creation are null pointers.
+ *
+ * Value: 0x0200060c.
+ *
+ * Solution: Ensure the passed-in parameters are not null pointers.
+ */
+#define LOS_ERRNO_QUEUE_CREAT_PTR_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x0c)
+
+/**
+ * @ingroup los_queue
+ * Queue error code: The queue length or message node size passed in during queue creation is 0.
+ *
+ * Value: 0x0200060d.
+ *
+ * Solution: Pass in correct queue length and message node size.
+ */
+#define LOS_ERRNO_QUEUE_PARA_ISZERO LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x0d)
+
+/**
+ * @ingroup los_queue
+ * Queue error code: The handle of the queue is invalid.
+ *
+ * Value: 0x0200060e.
+ *
+ * Solution: Check whether the passed-in queue handle value is valid.
+ */
+#define LOS_ERRNO_QUEUE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x0e)
+
+/**
+ * @ingroup los_queue
+ * Queue error code: The pointer passed in during queue reading is null.
+ *
+ * Value: 0x0200060f.
+ *
+ * Solution: Check whether the passed-in pointer is null.
+ */
+#define LOS_ERRNO_QUEUE_READ_PTR_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x0f)
+
+/**
+ * @ingroup los_queue
+ * Queue error code: The buffer size passed in during queue reading is too small or too big.
+ *
+ * Value: 0x02000610.
+ *
+ * Solution: Pass in a correct buffer size between [sizeof(CHAR*), OS_NULL_SHORT - sizeof(UINT32)].
+ */
+#define LOS_ERRNO_QUEUE_READSIZE_IS_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x10)
+
+/**
+ * @ingroup los_queue
+ * Queue error code: The pointer passed in during queue writing is null.
+ *
+ * Value: 0x02000612.
+ *
+ * Solution: Check whether the passed-in pointer is null.
+ */
+#define LOS_ERRNO_QUEUE_WRITE_PTR_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x12)
+
+/**
+ * @ingroup los_queue
+ * Queue error code: The buffer size passed in during queue writing is 0.
+ *
+ * Value: 0x02000613.
+ *
+ * Solution: Pass in a correct buffer size.
+ */
+#define LOS_ERRNO_QUEUE_WRITESIZE_ISZERO LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x13)
+
+/**
+ * @ingroup los_queue
+ * Queue error code: The buffer size passed in during queue writing is bigger than the queue size.
+ *
+ * Value: 0x02000615.
+ *
+ * Solution: Decrease the buffer size, or use a queue in which nodes are bigger.
+ */
+#define LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x15)
+
+/**
+ * @ingroup los_queue
+ * Queue error code: No free node is available during queue writing.
+ *
+ * Value: 0x02000616.
+ *
+ * Solution: Ensure that free nodes are available before queue writing.
+ */
+#define LOS_ERRNO_QUEUE_ISFULL LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x16)
+
+/**
+ * @ingroup los_queue
+ * Queue error code: The pointer passed in when the queue information is being obtained is null.
+ *
+ * Value: 0x02000617.
+ *
+ * Solution: Check whether the passed-in pointer is null.
+ */
+#define LOS_ERRNO_QUEUE_PTR_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x17)
+
+/**
+ * @ingroup los_queue
+ * Queue error code: The queue cannot be read during an interrupt
+ * when the time for waiting to processing the queue expires.
+ *
+ * Value: 0x02000618.
+ *
+ * Solution: Set the expiry time to the never-waiting mode, or use asynchronous queues.
+ */
+#define LOS_ERRNO_QUEUE_READ_IN_INTERRUPT LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x18)
+
+/**
+ * @ingroup los_queue
+ * Queue error code: The handle of the queue passed-in when the memory for the queue is being freed is invalid.
+ *
+ * Value: 0x02000619.
+ *
+ * Solution: Check whether the passed-in queue handle value is valid.
+ */
+#define LOS_ERRNO_QUEUE_MAIL_HANDLE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x19)
+
+/**
+ * @ingroup los_queue
+ * Queue error code: The pointer to the memory to be freed is null.
+ *
+ * Value: 0x0200061a.
+ *
+ * Solution: Check whether the passed-in pointer is null.
+ */
+#define LOS_ERRNO_QUEUE_MAIL_PTR_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x1a)
+
+/**
+ * @ingroup los_queue
+ * Queue error code: The memory for the queue fails to be freed.
+ *
+ * Value: 0x0200061b.
+ *
+ * Solution: Pass in correct input parameters.
+ */
+#define LOS_ERRNO_QUEUE_MAIL_FREE_ERROR LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x1b)
+
+/**
+ * @ingroup los_queue
+ * Queue error code: No resource is in the queue that is being read when the
+ * time for waiting to processing the queue expires.
+ *
+ * Value: 0x0200061d.
+ *
+ * Solution: Ensure that the queue contains messages when it is being read.
+ */
+#define LOS_ERRNO_QUEUE_ISEMPTY LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x1d)
+
+/**
+ * @ingroup los_queue
+ * Queue error code: The buffer size passed in during queue reading is smaller than the queue size.
+ *
+ * Value: 0x0200061f.
+ *
+ * Solution: Increase the buffer size, or use a queue in which nodes are smaller.
+ */
+#define LOS_ERRNO_QUEUE_READ_SIZE_TOO_SMALL LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x1f)
+
+/**
+ * @ingroup los_queue
+ * Structure of the block for queue information query
+ */
+typedef struct tagQueueInfo {
+ UINT32 uwQueueID; /**< Queue ID */
+ UINT16 usQueueLen; /**< Queue length, that is the number of node in the queue */
+ UINT16 usQueueSize; /**< Node size in the queue */
+ UINT16 usQueueHead; /**< The position of queue header node, it is an array subscript */
+ UINT16 usQueueTail; /**< The position of queue tail node, it is an array subscript */
+ UINT16 usWritableCnt; /**< Count of writable resources */
+ UINT16 usReadableCnt; /**< Count of readable resources */
+ UINT64 uwWaitReadTask; /**< Tasks waiting for reading message. It is a 64-bit unsigned
+ integer, each bit represents a task ID. Therefore, 64 tasks
+ can be represented, and the maximum task ID is 63. For example,
+ 0x0200060001002010 means there are 6 tasks whose IDs are 4,
+ 13, 24, 41, 42, and 57. */
+ UINT64 uwWaitWriteTask; /**< Tasks waiting for writing message. It is a 64-bit unsigned
+ integer same with #uwWaitReadTask, each bit represents a task ID. */
+ UINT64 uwWaitMemTask; /**< Tasks waiting for memory used by the MailBox in the CMSIS-RTOS.
+ It is a 64-bit unsigned integer same with #uwWaitReadTask,
+ each bit represents a task ID. */
+} QUEUE_INFO_S;
+
+#ifdef LOSCFG_QUEUE_STATIC_ALLOCATION
+/*这段代码定义了一个结构体 QUEUE_INFO_S,用于描述队列(Queue)的信息。
+
+成员变量解释如下:
+
+uwQueueID:队列 ID。
+usQueueLen:队列长度,即队列中节点的数量。
+usQueueSize:队列中每个节点的大小。
+usQueueHead:队列头节点的位置,是一个数组下标。
+usQueueTail:队列尾节点的位置,是一个数组下标。
+usWritableCnt:可写入的资源数。
+usReadableCnt:可读取的资源数。
+uwWaitReadTask:等待读取消息的任务。是一个 64 位的无符号整数,每个二进制位表示一个任务 ID。因此,可以表示 64 个任务,最大任务 ID 是 63。
+uwWaitWriteTask:等待写入消息的任务。同 uwWaitReadTask。
+uwWaitMemTask:等待内存的任务。同 uwWaitReadTask。
+如果宏 LOSCFG_QUEUE_STATIC_ALLOCATION 被定义,则这个结构体用于动态分配内存时不起作用。*/
+/**
+ * @ingroup los_queue
+ * @brief Create a message queue.
+ *
+ * @par Description:
+ * This API is used to create a message queue by transferring the static memory for the queue.
+ * The input parameter "queueMem" is the pointer to the static memory the API can use directly.
+ * The input parameter "memSize" is the static memory size.
+ * @attention
+ *
+ * - Threre are LOSCFG_BASE_IPC_QUEUE_LIMIT queues available, change it's value when necessory.
+ * - This function is defined only when LOSCFG_QUEUE_STATIC_ALLOCATION is defined.
+ *
+ * @param queueName [IN] Message queue name. Reserved parameter, not used for now.
+ * @param len [IN] Queue length. The value range is [1,0xffff].
+ * @param queueId [OUT] ID of the queue control structure that is successfully created.
+ * @param flags [IN] Queue mode. Reserved parameter, not used for now.
+ * @param maxMsgSize [IN] Node size. The value range is [1,0xffff-4].
+ * @param queueMem [IN] Static queue memory. The value range is [0,0xffffffff].
+ * @param memSize [IN] Queue memory size. The value range is [1,0xffff-4].
+
+ * @retval #LOS_OK The message queue is successfully created.
+ * @retval #LOS_ERRNO_QUEUE_CB_UNAVAILABLE The upper limit of the number of created queues is exceeded.
+ * @retval #LOS_ERRNO_QUEUE_CREATE_NO_MEMORY Insufficient memory for queue creation.
+ * @retval #LOS_ERRNO_QUEUE_CREAT_PTR_NULL Null pointer, queueID is NULL.
+ * @retval #LOS_ERRNO_QUEUE_PARA_ISZERO The queue length or message node size passed in during queue
+ * creation is 0.
+ * @retval #LOS_ERRNO_QUEUE_SIZE_TOO_BIG The parameter maxMsgSize is larger than 0xffff - 4.
+ * @par Dependency:
+ * - los_queue.h: the header file that contains the API declaration.
+ * @see LOS_QueueDelete | LOS_QueueCreate
+ * @since Huawei LiteOS V200R005C00
+ */
+extern UINT32 LOS_QueueCreateStatic(const CHAR *queueName,
+ UINT16 len,
+ UINT32 *queueId,
+ UINT32 flags,
+ UINT16 maxMsgSize,
+ VOID *queueMem,
+ UINT16 memSize);
+#endif
+/*该函数用于静态创建一个队列(Queue),具体参数如下:
+
+queueName:队列的名称,类型为 const CHAR*。
+len:队列的长度,即队列中节点的数量,类型为 UINT16。
+queueId:指向一个 UINT32 类型的指针,用于存储创建得到的队列 ID。
+flags:队列的标志,类型为 UINT32。
+maxMsgSize:队列中每个节点的最大消息大小,类型为 UINT16。
+queueMem:指向预分配的队列内存的指针,类型为 VOID*。
+memSize:预分配的队列内存的大小,类型为 UINT16。
+该函数的作用是在预分配的静态内存空间上创建一个队列,并返回队列的 ID*/
+/**
+ * @ingroup los_queue
+ * @brief Create a message queue.
+ *
+ * @par Description:
+ * This API is used to create a message queue. Different from LOS_QueueCreateStatic,
+ * the user does not need to transfer the queue memory. In the API, system allocated
+ * the queue memory automatically.
+ * @attention
+ * There are LOSCFG_BASE_IPC_QUEUE_LIMIT queues available, change it's value when necessary.
+ * @param queueName [IN] Message queue name. Reserved parameter, not used for now.
+ * @param len [IN] Queue length. The value range is [1,0xffff].
+ * @param queueId [OUT] ID of the queue control structure that is successfully created.
+ * @param flags [IN] Queue mode. Reserved parameter, not used for now.
+ * @param maxMsgSize [IN] Node size. The value range is [1,0xffff-4].
+ *
+ * @retval #LOS_OK The message queue is successfully created.
+ * @retval #LOS_ERRNO_QUEUE_CB_UNAVAILABLE The upper limit of the number of created queues is exceeded.
+ * @retval #LOS_ERRNO_QUEUE_CREATE_NO_MEMORY Insufficient memory for queue creation.
+ * @retval #LOS_ERRNO_QUEUE_CREAT_PTR_NULL Null pointer, queueId is NULL.
+ * @retval #LOS_ERRNO_QUEUE_PARA_ISZERO The queue length or message node size passed in during queue
+ * creation is 0.
+ * @retval #LOS_ERRNO_QUEUE_SIZE_TOO_BIG The parameter usMaxMsgSize is larger than 0xffff - 4.
+ * @par Dependency:
+ * - los_queue.h: the header file that contains the API declaration.
+ * @see LOS_QueueDelete | LOS_QueueCreateStatic
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT32 LOS_QueueCreate(const CHAR *queueName,
+ UINT16 len,
+ UINT32 *queueId,
+ UINT32 flags,
+ UINT16 maxMsgSize);
+/*该函数用于动态创建一个队列(Queue),具体参数如下:
+
+queueName:队列的名称,类型为 const CHAR*。
+len:队列的长度,即队列中节点的数量,类型为 UINT16。
+queueId:指向一个 UINT32 类型的指针,用于存储创建得到的队列 ID。
+flags:队列的标志,类型为 UINT32。
+maxMsgSize:队列中每个节点的最大消息大小,类型为 UINT16。
+该函数的作用是在运行时动态分配内存空间来创建一个队列,并返回队列的 ID。*/
+/**
+ * @ingroup los_queue
+ * @brief Read a queue.
+ *
+ * @par Description:
+ * This API is used to read data in a specified queue, and store the obtained data to the address specified
+ * by bufferAddr. The address and the size of the data to be read are defined by users.
+ * @attention
+ *
+ * - The specific queue should be created firstly.
+ * - Queue reading adopts the fist in first out (FIFO) mode. The data that is first stored in the queue is read
+ * first.
+ * - bufferAddr stores the obtained data.
+ * - Do not read or write a queue in unblocking modes such as an interrupt.
+ * - This API cannot be called before the Huawei LiteOS is initialized.
+ * - The argument timeout is a relative time.
+ * - Do not call this API in software timer callback.
+ *
+ *
+ * @param queueId [IN] Queue ID created by LOS_QueueCreate or LOS_QueueCreateStatic.
+ * The value range is [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
+ * @param bufferAddr [OUT] Starting address that stores the obtained data. The starting address must not be
+ * null.
+ * @param bufferSize [IN/OUT] Where to maintain the buffer wanted-size before read, and the real-size after read.
+ * @param timeout [IN] Expiry time. The value range is [0,LOS_WAIT_FOREVER](unit: Tick).
+ *
+ * @retval #LOS_OK The queue is successfully read.
+ * @retval #LOS_ERRNO_QUEUE_INVALID The handle of the queue that is being read is invalid.
+ * @retval #LOS_ERRNO_QUEUE_READ_PTR_NULL The pointer passed in during queue reading is null.
+ * @retval #LOS_ERRNO_QUEUE_READSIZE_IS_INVALID The buffer size passed in during queue reading is invalid.
+ * @retval #LOS_ERRNO_QUEUE_READ_IN_INTERRUPT The queue cannot be read during an interrupt when the time for
+ * waiting to processing the queue expires.
+ * @retval #LOS_ERRNO_QUEUE_NOT_CREATE The queue to be read is not created.
+ * @retval #LOS_ERRNO_QUEUE_ISEMPTY No resource is in the queue that is being read when the time for
+ * waiting to processing the queue expires.
+ * @retval #LOS_ERRNO_QUEUE_PEND_IN_LOCK The task is forbidden to be blocked on a queue when the task is
+ * locked.
+ * @retval #LOS_ERRNO_QUEUE_TIMEOUT The time set for waiting to processing the queue expires.
+ * @retval #LOS_ERRNO_QUEUE_READ_SIZE_TOO_SMALL The buffer size passed in during queue reading is less than
+ * the queue size.
+ * @par Dependency:
+ * - los_queue.h: the header file that contains the API declaration.
+ * @see LOS_QueueWriteCopy | LOS_QueueWriteHeadCopy | LOS_QueueCreate | LOS_QueueCreateStatic
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT32 LOS_QueueReadCopy(UINT32 queueId,
+ VOID *bufferAddr,
+ UINT32 *bufferSize,
+ UINT32 timeout);
+/*该函数的作用是从队列中读取数据,并将数据复制到指定的缓冲区中。如果队列中没有数据可读,则根据超时时间等待数据可读,如果在超时时间内仍然没有数据可读,则返回错误码。*/
+/**
+ * @ingroup los_queue
+ * @brief Write data into a queue.
+ *
+ * @par Description:
+ * This API is used to write the data of the size specified by bufferSize and stored at the address specified by
+ * bufferAddr into a queue.
+ * @attention
+ *
+ * - The specific queue should be created firstly.
+ * - Do not read or write a queue in unblocking modes such as interrupt.
+ * - This API cannot be called before the Huawei LiteOS is initialized.
+ * - The data to be written is of the size specified by bufferSize and is stored at the address specified by
+ * bufferAddr.
+ * - The argument timeout is a relative time.
+ * - Do not call this API in software timer callback.
+ *
+ *
+ * @param queueId [IN] Queue ID created by LOS_QueueCreate or LOS_QueueCreateStatic.
+ * The value range is [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
+ * @param bufferAddr [IN] Starting address that stores the data to be written.The starting address must
+ * not be null.
+ * @param bufferSize [IN] Passed-in buffer size. The value range is [1,USHRT_MAX - sizeof(UINT32)].
+ * @param timeout [IN] Expiry time. The value range is [0,LOS_WAIT_FOREVER](unit: Tick).
+ *
+ * @retval #LOS_OK The data is successfully written into the queue.
+ * @retval #LOS_ERRNO_QUEUE_INVALID The queue handle passed in during queue writing is invalid.
+ * @retval #LOS_ERRNO_QUEUE_WRITE_PTR_NULL The pointer passed in during queue writing is null.
+ * @retval #LOS_ERRNO_QUEUE_WRITESIZE_ISZERO The buffer size passed in during queue writing is 0.
+ * @retval #LOS_ERRNO_QUEUE_WRITE_IN_INTERRUPT The queue cannot be written during an interrupt when the time
+ * for waiting to processing the queue expires.
+ * @retval #LOS_ERRNO_QUEUE_NOT_CREATE The queue into which the data is written is not created.
+ * @retval #LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG The buffer size passed in during queue writing is bigger than
+ * the queue size.
+ * @retval #LOS_ERRNO_QUEUE_ISFULL No free node is available during queue writing.
+ * @retval #LOS_ERRNO_QUEUE_PEND_IN_LOCK The task is forbidden to be blocked on a queue when
+ * the task is locked.
+ * @retval #LOS_ERRNO_QUEUE_TIMEOUT The time set for waiting to processing the queue expires.
+ * @par Dependency:
+ * - los_queue.h: the header file that contains the API declaration.
+ * @see LOS_QueueReadCopy | LOS_QueueWriteHeadCopy | LOS_QueueCreate | LOS_QueueCreateStatic
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT32 LOS_QueueWriteCopy(UINT32 queueId,
+ VOID *bufferAddr,
+ UINT32 bufferSize,
+ UINT32 timeout);
+/*该函数用于向指定的队列中写入数据,具体参数如下:
+
+queueId:要写入数据的队列 ID,类型为 UINT32。
+bufferAddr:指向待写入数据的缓冲区地址,类型为 VOID*。
+bufferSize:待写入数据的大小,类型为 UINT32。
+timeout:写入数据的超时时间,单位为 Tick。如果设置为 0,则表示不等待,立即返回。如果设置为 LOS_WAIT_FOREVER,则表示一直等待,直到有空间可写入为止,类型为 UINT32。
+该函数的作用是向队列中写入数据,如果队列已满,则根据超时时间等待空间可写入,如果在超时时间内仍然没有空间可写入,则返回错误码。*/
+/**
+ * @ingroup los_queue
+ * @brief Read a queue.
+ *
+ * @par Description:
+ * This API is used to read the address of data in a specified queue, and store it to the address specified by
+ * bufferAddr.
+ * @attention
+ *
+ * - The specific queue should be created firstly.
+ * - Queue reading adopts the fist in first out (FIFO) mode. The data that is first stored in the queue is
+ * read first.
+ * - bufferAddr stores the obtained data address.
+ * - Do not read or write a queue in unblocking modes such as an interrupt.
+ * - This API cannot be called before the Huawei LiteOS is initialized.
+ * - The argument timeout is a relative time.
+ * - The bufferSize is not really used in LOS_QueueRead, because the interface is only used to
+ * obtain the address of data.
+ * - The buffer which the bufferAddr pointing to must be greater than or equal to 4 bytes.
+ * - Do not call this API in software timer callback.
+ *
+ *
+ * @param queueId [IN] Queue ID created by LOS_QueueCreate or LOS_QueueCreateStatic.
+ * The value range is [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
+ * @param bufferAddr [OUT] Starting address that stores the obtained data. The starting address must
+ * not be null.
+ * @param bufferSize [IN] Passed-in buffer size,The value range is
+ * [sizeof(CHAR*),OS_NULL_SHORT - sizeof(UINT32)].
+ * @param timeout [IN] Expiry time. The value range is [0,LOS_WAIT_FOREVER](unit: Tick).
+ *
+ * @retval #LOS_OK The queue is successfully read.
+ * @retval #LOS_ERRNO_QUEUE_INVALID The handle of the queue that is being read is invalid.
+ * @retval #LOS_ERRNO_QUEUE_READ_PTR_NULL The pointer passed in during queue reading is null.
+ * @retval #LOS_ERRNO_QUEUE_READSIZE_IS_INVALID The buffer size passed in during queue reading is invalid.
+ * @retval #LOS_ERRNO_QUEUE_READ_IN_INTERRUPT The queue cannot be read during an interrupt when the time for
+ * waiting to processing the queue expires.
+ * @retval #LOS_ERRNO_QUEUE_NOT_CREATE The queue to be read is not created.
+ * @retval #LOS_ERRNO_QUEUE_ISEMPTY No resource is in the queue that is being read when the time for
+ * waiting to processing the queue expires.
+ * @retval #LOS_ERRNO_QUEUE_PEND_IN_LOCK The task is forbidden to be blocked on a queue when the task is
+ * locked.
+ * @retval #LOS_ERRNO_QUEUE_TIMEOUT The time set for waiting to processing the queue expires.
+ * @par Dependency:
+ * - los_queue.h: The header file that contains the API declaration.
+ * @see LOS_QueueWrite | LOS_QueueWriteHead | LOS_QueueCreate | LOS_QueueCreateStatic
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT32 LOS_QueueRead(UINT32 queueId,
+ VOID *bufferAddr,
+ UINT32 bufferSize,
+ UINT32 timeout);
+/*该函数用于从指定的队列中读取数据,具体参数如下:
+
+queueId:要读取数据的队列 ID,类型为 UINT32。
+bufferAddr:指向存储读取数据的缓冲区地址,类型为 VOID*。
+bufferSize:指定缓冲区的大小,即期望读取的数据大小,类型为 UINT32。
+timeout:读取数据的超时时间,单位为 Tick。如果设置为 0,则表示不等待,立即返回。如果设置为 LOS_WAIT_FOREVER,则表示一直等待,直到有数据可读为止,类型为 UINT32。
+该函数的作用是从队列中读取数据并存储到指定的缓冲区中。如果队列中没有足够的数据可读,则根据超时时间等待数据可读,如果在超时时间内仍然没有足够的数据可读,则返回错误码。*/
+/**
+ * @ingroup los_queue
+ * @brief Write data into a queue.
+ *
+ * @par Description:
+ * This API is used to write the address of data specified by bufferAddr into a queue.
+ * @attention
+ *
+ * - The specific queue should be created firstly.
+ * - Do not read or write a queue in unblocking modes such as an interrupt.
+ * - This API cannot be called before the Huawei LiteOS is initialized.
+ * - The address of the data of the size specified by bufferSize and stored at the address specified by
+ * bufferAddr is to be written.
+ * - The argument timeout is a relative time.
+ * - The bufferSize is not really used in LOS_QueueWrite, because the interface is only used to write the address
+ * of data specified by bufferAddr into a queue.
+ * - Do not call this API in software timer callback.
+ *
+ *
+ * @param queueId [IN] Queue ID created by LOS_QueueCreate or LOS_QueueCreateStatic.
+ * The value range is [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
+ * @param bufferAddr [IN] Starting address that stores the data to be written. The starting address
+ * must not be null.
+ * @param bufferSize [IN] This parameter is not in use temporarily.
+ * @param timeout [IN] Expiry time. The value range is [0,LOS_WAIT_FOREVER](unit: Tick).
+ *
+ * @retval #LOS_OK The data is successfully written into the queue.
+ * @retval #LOS_ERRNO_QUEUE_INVALID The queue handle passed in during queue writing is invalid.
+ * @retval #LOS_ERRNO_QUEUE_WRITE_PTR_NULL The pointer passed in during queue writing is null.
+ * @retval #LOS_ERRNO_QUEUE_WRITESIZE_ISZERO The buffer size passed in during queue writing is 0.
+ * @retval #LOS_ERRNO_QUEUE_WRITE_IN_INTERRUPT The queue cannot be written during an interrupt when the time for
+ * waiting to processing the queue expires.
+ * @retval #LOS_ERRNO_QUEUE_NOT_CREATE The queue into which the data is written is not created.
+ * @retval #LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG The buffer size passed in during queue writing is bigger than
+ * the queue size.
+ * @retval #LOS_ERRNO_QUEUE_ISFULL No free node is available during queue writing.
+ * @retval #LOS_ERRNO_QUEUE_PEND_IN_LOCK The task is forbidden to be blocked on a queue when the task is
+ * locked.
+ * @retval #LOS_ERRNO_QUEUE_TIMEOUT The time set for waiting to processing the queue expires.
+ * @par Dependency:
+ * - los_queue.h: The header file that contains the API declaration.
+ * @see LOS_QueueRead | LOS_QueueWriteHead | LOS_QueueCreate | LOS_QueueCreateStatic
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT32 LOS_QueueWrite(UINT32 queueId,
+ VOID *bufferAddr,
+ UINT32 bufferSize,
+ UINT32 timeout);
+/*该函数用于向指定的队列中写入数据,具体参数如下:
+
+queueId:要写入数据的队列 ID,类型为 UINT32。
+bufferAddr:指向待写入数据的缓冲区地址,类型为 VOID*。
+bufferSize:待写入数据的大小,类型为 UINT32。
+timeout:写入数据的超时时间,单位为 Tick。如果设置为 0,则表示不等待,立即返回。如果设置为 LOS_WAIT_FOREVER,则表示一直等待,直到有空间可写入为止,类型为 UINT32。
+该函数的作用是向队列中写入数据,如果队列已满,则根据超时时间等待空间可写入,如果在超时时间内仍然没有空间可写入,则返回错误码。*/
+/**
+ * @ingroup los_queue
+ * @brief Write data into a queue header.
+ *
+ * @par Description:
+ * This API is used to write the data of the size specified by bufferSize and stored at the address specified by
+ * bufferAddr into a queue header.
+ * @attention
+ *
+ * - Do not read or write a queue in unblocking modes such as an interrupt.
+ * - This API cannot be called before the Huawei LiteOS is initialized.
+ * - The address of the data of the size specified by bufferSize and stored at the address specified by
+ * bufferAddr is to be written.
+ * - The argument timeout is a relative time.
+ * - LOS_QueueRead and LOS_QueueWriteHead are a set of interfaces, and the two groups of interfaces need to
+ * be used.
+ * - Do not call this API in software timer callback.
+ *
+ *
+ * @param queueId [IN] Queue ID created by LOS_QueueCreate or LOS_QueueCreateStatic.
+ * The value range is [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
+ * @param bufferAddr [OUT] Starting address that stores the data to be written. The starting address
+ * must not be null.
+ * @param bufferSize [IN] This parameter is not in use temporarily.
+ * @param timeout [IN] Expiry time. The value range is [0,LOS_WAIT_FOREVER](unit: Tick).
+ *
+ * @retval #LOS_OK The data is successfully written into the queue.
+ * @retval #LOS_ERRNO_QUEUE_INVALID The queue handle passed in during queue writing is invalid.
+ * @retval #LOS_ERRNO_QUEUE_WRITE_PTR_NULL The pointer passed in during queue writing is null.
+ * @retval #LOS_ERRNO_QUEUE_WRITESIZE_ISZERO The buffer size passed in during queue writing is 0.
+ * @retval #LOS_ERRNO_QUEUE_WRITE_IN_INTERRUPT The queue cannot be written during an interrupt when the time for
+ * waiting to processing the queue expires. waiting to processing the queue expires.
+ * @retval #LOS_ERRNO_QUEUE_NOT_CREATE The queue into which the data is written is not created.
+ * @retval #LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG The buffer size passed in during queue writing is bigger than
+ * the queue size.
+ * @retval #LOS_ERRNO_QUEUE_ISFULL No free node is available during queue writing.
+ * @retval #LOS_ERRNO_QUEUE_PEND_IN_LOCK The task is forbidden to be blocked on a queue when the task is
+ * locked.
+ * @retval #LOS_ERRNO_QUEUE_TIMEOUT The time set for waiting to processing the queue expires.
+ * @par Dependency:
+ * - los_queue.h: The header file that contains the API declaration.
+ * @see LOS_QueueWrite | LOS_QueueRead | LOS_QueueCreate | LOS_QueueCreateStatic
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT32 LOS_QueueWriteHead(UINT32 queueId,
+ VOID *bufferAddr,
+ UINT32 bufferSize,
+ UINT32 timeout);
+/*该函数用于向指定队列的队首写入数据,具体参数如下:
+
+queueId:要写入数据的队列 ID,类型为 UINT32。
+bufferAddr:指向待写入数据的缓冲区地址,类型为 VOID*。
+bufferSize:待写入数据的大小,类型为 UINT32。
+timeout:写入数据的超时时间,单位为 Tick。如果设置为 0,则表示不等待,立即返回。如果设置为 LOS_WAIT_FOREVER,则表示一直等待,直到有空间可写入为止,类型为 UINT32。
+该函数的作用是向队列的队首写入数据,如果队列已满,则根据超时时间等待空间可写入,如果在超时时间内仍然没有空间可写入,则返回错误码。写入数据到队首可能会导致队列中原本的数据被挤出。*/
+/**
+ * @ingroup los_queue
+ * @brief Write data into a queue header.
+ *
+ * @par Description:
+ * This API is used to write the data of the size specified by bufferSize and stored at the address specified by
+ * bufferAddr into a queue header.
+ * @attention
+ *
+ * - Do not read or write a queue in unblocking modes such as an interrupt.
+ * - This API cannot be called before the Huawei LiteOS is initialized.
+ * - The address of the data of the size specified by bufferSize and stored at the address specified by
+ * bufferAddr is to be written.
+ * - The argument timeout is a relative time.
+ * - LOS_QueueRead and LOS_QueueWriteHead are a set of interfaces, and the two groups of interfaces need to be
+ * used.
+ * - Do not call this API in software timer callback.
+ *
+ *
+ * @param queueId [IN] Queue ID created by LOS_QueueCreate or LOS_QueueCreateStatic.
+ * The value range is [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
+ * @param bufferAddr [OUT] Starting address that stores the data to be written.
+ * The starting address must not be null.
+ * @param bufferSize [IN] Passed-in buffer size, which must not be 0. The value range is [1,0xffffffff].
+ * @param timeout [IN] Expiry time. The value range is [0,LOS_WAIT_FOREVER](unit: Tick).
+ *
+ * @retval #LOS_OK The data is successfully written into the queue.
+ * @retval #LOS_ERRNO_QUEUE_INVALID The queue handle passed in during queue writing is invalid.
+ * @retval #LOS_ERRNO_QUEUE_WRITE_PTR_NULL The pointer passed in during queue writing is null.
+ * @retval #LOS_ERRNO_QUEUE_WRITESIZE_ISZERO The buffer size passed in during queue writing is 0.
+ * @retval #LOS_ERRNO_QUEUE_WRITE_IN_INTERRUPT The queue cannot be written during an interrupt when the time for
+ * waiting to processing the queue expires.
+ * @retval #LOS_ERRNO_QUEUE_NOT_CREATE The queue into which the data is written is not created.
+ * @retval #LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG The buffer size passed in during queue writing is bigger than
+ * the queue size.
+ * @retval #LOS_ERRNO_QUEUE_ISFULL No free node is available during queue writing.
+ * @retval #LOS_ERRNO_QUEUE_PEND_IN_LOCK The task is forbidden to be blocked on a queue when the task is
+ * locked.
+ * @retval #LOS_ERRNO_QUEUE_TIMEOUT The time set for waiting to processing the queue expires.
+ * @par Dependency:
+ * - los_queue.h: The header file that contains the API declaration.
+ * @see LOS_QueueWriteCopy | LOS_QueueReadCopy
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT32 LOS_QueueWriteHeadCopy(UINT32 queueId,
+ VOID *bufferAddr,
+ UINT32 bufferSize,
+ UINT32 timeout);
+
+/**
+ * @ingroup los_queue
+ * @brief Delete a queue.
+ *
+ * @par Description:
+ * This API is used to delete a queue.
+ * @attention
+ *
+ * - This API cannot be used to delete a queue that is not created.
+ * - A synchronous queue fails to be deleted if any tasks are blocked on it, or some queues are being read or
+ * written.
+ *
+ *
+ * @param queueId [IN] Queue ID created by LOS_QueueCreate or LOS_QueueCreateStatic.
+ * The value range is [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
+ *
+ * @retval #LOS_OK The queue is successfully deleted.
+ * @retval #LOS_NOK Failed to release the queue memory.
+ * @retval #LOS_ERRNO_QUEUE_NOT_FOUND The queue cannot be found.
+ * @retval #LOS_ERRNO_QUEUE_NOT_CREATE The queue handle passed in when the queue is being deleted is
+ * incorrect.
+ * @retval #LOS_ERRNO_QUEUE_IN_TSKUSE The queue that blocks a task cannot be deleted.
+ * @retval #LOS_ERRNO_QUEUE_IN_TSKWRITE Queue reading and writing are not synchronous.
+ * @par Dependency:
+ * - los_queue.h: the header file that contains the API declaration.
+ * @see LOS_QueueCreate | LOS_QueueCreateStatic
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT32 LOS_QueueDelete(UINT32 queueId);
+
+/**
+ * @ingroup los_queue
+ * @brief Obtain queue information.
+ *
+ * @par Description:
+ * This API is used to obtain queue information.
+ * @attention
+ * The specific queue should be created firstly before getting the queue information.
+ * @param queueId [IN] Queue ID created by LOS_QueueCreate or LOS_QueueCreateStatic.
+ * The value range is [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
+ * @param queueInfo [OUT] The queue information to be read must not be null.
+ *
+ * @retval #LOS_OK The queue information is successfully obtained.
+ * @retval #LOS_ERRNO_QUEUE_PTR_NULL The pointer to the queue information to be obtained is null.
+ * @retval #LOS_ERRNO_QUEUE_INVALID The handle of the queue that is being read is invalid.
+ * @retval #LOS_ERRNO_QUEUE_NOT_CREATE The queue in which the information to be obtained is stored is
+ * not created.
+ *
+ * @par Dependency:
+ * - los_queue.h: the header file that contains the API declaration.
+ * @see LOS_QueueCreate | LOS_QueueCreateStatic
+ * @since Huawei LiteOS V100R001C00
+ */
+extern UINT32 LOS_QueueInfoGet(UINT32 queueId, QUEUE_INFO_S *queueInfo);
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#endif /* _LOS_QUEUE_H */
diff --git a/kkk/los_ringbuf.h b/kkk/los_ringbuf.h
new file mode 100644
index 0000000..4f362af
--- /dev/null
+++ b/kkk/los_ringbuf.h
@@ -0,0 +1,206 @@
+/* ----------------------------------------------------------------------------
+ * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved.
+ * Description: Ring Buffer Public HeadFile
+ * Author: Huawei LiteOS Team
+ * Create: 2019-10-10
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * --------------------------------------------------------------------------- */
+
+/**
+ * @defgroup los_ringbuf RingBuffer
+ * @ingroup kernel
+ */
+
+#ifndef _LOS_RINGBUF_H
+#define _LOS_RINGBUF_H
+
+#include "los_typedef.h"
+#include "los_spinlock.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+/**
+ * @ingroup los_ringbuf
+ * Ringbuf Status.
+ */
+typedef enum {
+ RBUF_UNINIT, /**< Ringbuf is not inited. */
+ RBUF_INITED /**< Ringbuf is inited. */
+} RingbufStatus;
+/*这段代码定义了一个名为 RingbufStatus 的枚举类型,表示环形缓冲区的状态。
+
+该枚举类型包含两个枚举值:
+
+RBUF_UNINIT:表示环形缓冲区尚未初始化。
+RBUF_INITED:表示环形缓冲区已经初始化。
+通过使用这个枚举类型,可以方便地标识和判断环形缓冲区的状态。
+在使用环形缓冲区时,可以根据不同的状态进行相应的操作或处理。*/
+/**
+ * @ingroup los_ringbuf
+ * Ringbuf information structure.
+ *
+ */
+typedef struct {
+ UINT32 startIdx; /**< Ringbuf read index */
+ UINT32 endIdx; /**< Ringbuf write index */
+ UINT32 size; /**< Ringbuf total size */
+ UINT32 remain; /**< Ringbuf free size */
+ SPIN_LOCK_S lock; /**< Lock for read and write */
+ RingbufStatus status; /**< Ringbuf status */
+ CHAR *fifo; /**< Buf to store data */
+} Ringbuf;
+/*这段代码定义了一个名为 Ringbuf 的结构体,用于表示环形缓冲区的属性和状态。
+
+该结构体包含以下成员:
+
+startIdx:环形缓冲区的读取索引。
+endIdx:环形缓冲区的写入索引。
+size:环形缓冲区的总大小。
+remain:环形缓冲区的剩余可用空间大小。
+lock:用于读取和写入操作的自旋锁。
+status:环形缓冲区的状态,类型为 RingbufStatus 枚举类型。
+fifo:用于存储数据的缓冲区。
+通过这个结构体,可以方便地管理环形缓冲区的属性和状态,并进行相应的数据读写操作。*/
+/**
+ * @ingroup los_ringbuf
+ * @brief Init a ringbuf.
+ *
+ * @par Description:
+ * This API is used to init a ringbuf.
+ * @attention
+ * The size must not be bigger than the fifo's actual size.
+ *
+ * @param ringbuf [OUT] Ringbuf control block.
+ * @param fifo [IN] Data buf address.
+ * @param size [IN] Data buf size.
+ *
+ * @retval #LOS_NOK Init failed, check the legality of function parameters.
+ * @retval #LOS_OK Init success.
+ *
+ * @par Dependency:
+ * - los_ringbuf.h: the header file that contains the API declaration.
+ * @see LOS_RingbufInit
+ * @since Huawei LiteOS V200R005C00
+ */
+extern UINT32 LOS_RingbufInit(Ringbuf *ringbuf, CHAR *fifo, UINT32 size);
+/*该函数的作用是根据给定的参数初始化环形缓冲区对象,并分配必要的资源。通过调用这个函数,可以将一个已经定义的 Ringbuf
+结构体对象与指定的缓冲区关联起来,并设置初始状态和属性。*/
+/**
+ * @ingroup los_ringbuf
+ * @brief Reset a ringbuf.
+ *
+ * @par Description:
+ * This API is used to reset a ringbuf to the init status.
+ * @attention
+ * The specific ringbuf must be inited first.
+ *
+ * @param ringbuf [IN] Ringbuf created by LOS_RingbufInit.
+ *
+ * @retval None.
+ *
+ * @par Dependency:
+ * - los_ringbuf.h: the header file that contains the API declaration.
+ * @see LOS_RingbufReset
+ * @since Huawei LiteOS V200R005C00
+ */
+extern VOID LOS_RingbufReset(Ringbuf *ringbuf);
+
+/**
+ * @ingroup los_ringbuf
+ * @brief Write data to ringbuf.
+ *
+ * @par Description:
+ * This API is used to write data to ringbuf.
+ * @attention
+ * The specific ringbuf must be inited first.
+ *
+ * @param ringbuf [IN] The ringbuf write data to.
+ * @param buf [IN] The source buf address.
+ * @param size [IN] The source buf size.
+ *
+ * @retval #UINT32 The actual written size.
+ *
+ * @par Dependency:
+ * - los_ringbuf.h: the header file that contains the API declaration.
+ * @see LOS_RingbufWrite
+ * @since Huawei LiteOS V200R005C00
+ */
+extern UINT32 LOS_RingbufWrite(Ringbuf *ringbuf, const CHAR *buf, UINT32 size);
+/*该函数的作用是将指定大小的数据从源缓冲区写入到目标环形缓冲区中。写入操作会更新环形缓冲区的写入索引,并根据需要循环覆盖已有数据。如果环形缓冲区的空间不足以容纳全部数据,只会写入部分数据。
+
+通过调用这个函数,可以方便地将数据写入到环形缓冲区中,并实现数据的循环存储和覆盖。*/
+/**
+ * @ingroup los_ringbuf
+ * @brief Read data from ringbuf.
+ *
+ * @par Description:
+ * This API is used to get data from ringbuf.
+ * @attention
+ * The specific ringbuf must be inited first.
+ *
+ * @param ringbuf [IN] The ringbuf read data from.
+ * @param buf [OUT] The dest buf address.
+ * @param size [IN] The dest buf size.
+ *
+ * @retval #UINT32 The actual read size.
+ *
+ * @par Dependency:
+ * - los_ring.h: the header file that contains the API declaration.
+ * @see LOS_RingbufRead
+ * @since Huawei LiteOS V200R005C00
+ */
+extern UINT32 LOS_RingbufRead(Ringbuf *ringbuf, CHAR *buf, UINT32 size);
+/*该函数的作用是从指定大小的数据中读取数据,并将其存储到目标缓冲区。读取操作会更新环形缓冲区的读取索引,并根据需要循环读取已有数据。如果环形缓冲区中的数据不足以满足全部读取请求,只会读取部分数据。
+
+通过调用这个函数,可以方便地从环形缓冲区中读取数据,并实现数据的循环读取和覆盖。*/
+/**
+ * @ingroup los_ringbuf
+ * @brief Get a ringbuf's used size.
+ *
+ * @par Description:
+ * This API is used to get a ringbuf's used size.
+ * @attention
+ * The specific ringbuf must be inited first.
+ *
+ * @param ringbuf [IN] The ringbuf address
+ *
+ * @retval #UINT32 The used size of ringbuf.
+ *
+ * @par Dependency:
+ * - los_ringbuf.h: the header file that contains the API declaration.
+ * @see LOS_RingbufUsedSize
+ * @since Huawei LiteOS V200R005C00
+ */
+extern UINT32 LOS_RingbufUsedSize(Ringbuf *ringbuf);
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#endif /* _LOS_RINGBUF_H */