zhangxinyuan_branch
张鑫源 12 months ago
parent 99c01f46b7
commit cea066915b

@ -54,7 +54,7 @@ enum LOAD_STRATEGY {
ZIP,
NOZIP
};
/*这是一个枚举类型的定义名称为LOAD_STRATEGY。它包含两个成员ZIP和NOZIP。*/
/**
* @ingroup los_dynload
* Define the structure of the parameters used for dynamic.
@ -64,7 +64,9 @@ enum LOAD_STRATEGY {
typedef struct tagDynloadParam {
enum LOAD_STRATEGY enLoadStrategy;
} DYNLOAD_PARAM_S;
/*这个结构体可以用来存储动态加载的参数信息,
enLoadStrategyZIPNOZIP使
*/
/**
* @ingroup los_dynload
* @brief Register the dynamic parameters.
@ -84,7 +86,8 @@ typedef struct tagDynloadParam {
* @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.
@ -136,7 +139,7 @@ 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
@ -160,7 +163,9 @@ extern VOID *LOS_MemLoad(const CHAR *elfFileName, UINT32 fileNameLen,
*/
extern VOID *LOS_ObjLoad(CHAR *elfFileName);
#endif /* LOSCFG_KERNEL_DYNLOAD_REL */
/*如果宏定义LOSCFG_KERNEL_DYNLOAD_REL被定义
LOS_ObjLoad
CHARVOID*/
/**
* @ingroup los_dynload
* @brief Unload a module.
@ -182,7 +187,8 @@ extern VOID *LOS_ObjLoad(CHAR *elfFileName);
* @since Huawei LiteOS V100R001C00
*/
extern INT32 LOS_ModuleUnload(VOID *handle);
/*通过调用LOS_ModuleUnload函数并传递一个动态库的句柄
*/
/**
* @ingroup los_dynload
* @brief Destroy a dynamic loader.
@ -203,7 +209,9 @@ extern INT32 LOS_ModuleUnload(VOID *handle);
* @since Huawei LiteOS V100R001C00
*/
extern VOID LOS_LdDestroy(VOID);
/*这段代码声明了一个外部函数LOS_LdDestroy该函数没有参数和返回值。
LOS_LdDestroyLoader*/
/**
* @ingroup los_dynload
* @brief Search for a symbol address.
@ -250,7 +258,8 @@ extern VOID *LOS_FindSymByName(VOID *handle, CHAR *name);
* @since Huawei LiteOS V100R001C00
*/
extern INT32 LOS_PathAdd(CHAR *path);
/*通过调用LOS_PathAdd函数并传递一个路径可以将该路径添加到动态库搜索路径中。
*/
/**
* @ingroup los_dynload
* @brief Set the memory pool address used by dynload
@ -273,7 +282,9 @@ extern INT32 LOS_PathAdd(CHAR *path);
* @since Huawei LiteOS V200R002C00
*/
extern BOOL LOS_DynMemPoolSet(VOID *memPool);
/*通过调用LOS_DynMemPoolSet函数并传递一个内存池指针
*/
#ifdef __cplusplus
#if __cplusplus
}

@ -50,6 +50,10 @@ 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
@ -74,7 +78,11 @@ LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListInit(LOS_DL_LIST *list)
list->pstNext = list;
list->pstPrev = list;
}
/*这段代码定义了一个静态内联函数LOS_ListInit
LOS_DL_LISTlist
pstNextpstPrev
*/
/**
* @ingroup los_list
* @brief Point to the next node of the current node.
@ -93,7 +101,12 @@ LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListInit(LOS_DL_LIST *list)
* @since Huawei LiteOS V100R001C00
*/
#define LOS_DL_LIST_FIRST(object) ((object)->pstNext)
/*这段代码定义了一个宏LOS_DL_LIST_FIRST(object)
LOS_DL_LISTobject
object
便
访*/
/**
* @ingroup los_list
* @brief Point to the previous node of the current node.
@ -112,7 +125,10 @@ LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListInit(LOS_DL_LIST *list)
* @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.
@ -138,7 +154,13 @@ LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListAdd(LOS_DL_LIST *list, LOS_DL_
list->pstNext->pstPrev = node;
list->pstNext = node;
}
/*该函数将新节点插入到链表头部,具体步骤如下:
next
prev
prev
next
*/
/**
* @ingroup los_list
* @brief Insert a node to a doubly linked list.
@ -161,7 +183,10 @@ LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListTailInsert(LOS_DL_LIST *list,
{
LOS_ListAdd(list->pstPrev, node);
}
/*在该函数中,使用了宏定义 LOS_DL_LIST 来表示链表节点,
使 STATIC INLINE
LOS_ListAdd
*/
/**
* @ingroup los_list
* @brief Insert a node to a doubly linked list.
@ -210,7 +235,12 @@ LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListDelete(LOS_DL_LIST *node)
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.
@ -233,7 +263,12 @@ 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.
@ -256,7 +291,10 @@ LITE_OS_SEC_ALW_INLINE STATIC INLINE BOOL LOS_ListEmpty(LOS_DL_LIST *list)
/* 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.
@ -309,7 +347,12 @@ LITE_OS_SEC_ALW_INLINE STATIC INLINE BOOL LOS_ListEmpty(LOS_DL_LIST *list)
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
@ -343,7 +386,13 @@ LITE_OS_SEC_ALW_INLINE STATIC INLINE BOOL LOS_ListEmpty(LOS_DL_LIST *list)
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.
@ -370,7 +419,13 @@ LITE_OS_SEC_ALW_INLINE STATIC INLINE BOOL LOS_ListEmpty(LOS_DL_LIST *list)
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.
@ -396,7 +451,7 @@ LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListDelInit(LOS_DL_LIST *list)
list->pstPrev->pstNext = list->pstNext;
LOS_ListInit(list);
}
/**/
/**
* @ingroup los_list
* @brief Traverse a doubly linked list.
@ -423,7 +478,12 @@ LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListDelInit(LOS_DL_LIST *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.
@ -475,7 +535,7 @@ LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListDelInit(LOS_DL_LIST *list)
* @since Huawei LiteOS V100R001C00
*/
#define LOS_DL_LIST_HEAD(list) LOS_DL_LIST list = { &(list), &(list) }
/*通过这个宏,可以方便地定义和初始化一个双向链表的头部节点,为链表的后续操作提供了便利。*/
#ifdef __cplusplus
#if __cplusplus
}

@ -51,18 +51,30 @@ extern "C" {
#define memmove_s KasanMemmoveSec
#define strcat_s KasanStrcatSec
#define strcpy_s KasanStrcpySec
/*使用#define预处理指令来重新定义标准库函数的名称。这种技术通常用于调试或测试目的或者提供这些函数的自定义实现。
memcpymemmovestrcatstrcpyKasanMemcpy
KasanMemmoveKasanStrcatKasanStrcpymemcpy_smemmove_sstrcat_sstrcpy_s
KasanMemcpySecKasanMemmoveSecKasanStrcatSecKasanStrcpySec*/
// 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用于在内存中复制一定数量的数据。可能会包含额外的内存访问检查。
KasanMemmovememmove访
KasanStrcatstrcat访
KasanStrcpystrcpy访*/
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 参数通常表示目标缓冲区的最大长度,以防止缓冲区溢出等安全问题。
KasanMemcpySecmemcpy
KasanMemmoveSecmemmove
KasanStrcatSecstrcat
KasanStrcpySecstrcpy*/
#endif /* LOSCFG_KERNEL_LMS */
#ifdef __cplusplus

@ -55,20 +55,33 @@ enum LockDepErrType {
/* 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
*
@ -88,7 +101,8 @@ typedef struct {
* @since Huawei LiteOS V200R003C00
*/
extern VOID OsLockDepCheckIn(const SPIN_LOCK_S *lock);
/*函数名称为 OsLockDepCheckIn参数类型为 const SPIN_LOCK_S* lock返回类型为 VOID。该函数的作用是将指定
lock */
/**
* @ingroup los_lockdep
*
@ -128,7 +142,8 @@ extern VOID OsLockDepRecord(SPIN_LOCK_S *lock);
* @since Huawei LiteOS V200R003C00
*/
extern VOID OsLockDepCheckOut(SPIN_LOCK_S *lock);
/*函数名称为 OsLockDepCheckOut参数类型为 SPIN_LOCK_S* lock返回类型为 VOID。该函数的作用
lock*/
/**
* @ingroup los_lockdep
*

@ -57,7 +57,14 @@ typedef enum LOS_INTERMIT_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
*
@ -70,7 +77,13 @@ typedef enum LOS_FREQ_MODE {
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)
@ -96,7 +109,19 @@ typedef struct {
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.
@ -115,7 +140,9 @@ typedef struct {
* @since Huawei LiteOS V200R005C10
*/
extern VOID LOS_PowerMgrChangeFreq(LosFreqMode freq);
/*这是一个外部声明extern的函数 LOS_PowerMgrChangeFreq
LosFreqMode freq
*/
/**
* @ingroup los_lowpower
* @brief Vote to enter deep sleep.
@ -153,7 +180,8 @@ extern VOID LOS_PowerMgrDeepSleepVoteBegin(VOID);
* @since Huawei LiteOS V200R005C10
*/
extern VOID LOS_PowerMgrDeepSleepVoteEnd(VOID);
/*这是一个外部声明extern的函数 LOS_PowerMgrDeepSleepVoteEnd它没有任何参数返回类型为 VOID。根据函数名来看
*/
/**
* @ingroup los_lowpower
* @brief Sleep delay vote.
@ -172,7 +200,8 @@ extern VOID LOS_PowerMgrDeepSleepVoteEnd(VOID);
* @since Huawei LiteOS V200R005C10
*/
extern VOID LOS_PowerMgrSleepDelay(UINT32 tick);
/*这是一个外部声明extern的函数 LOS_PowerMgrSleepDelay它接受一个 UINT32 类型的参数 tick
*/
/**
* @ingroup los_lowpower
* @brief Register the external voter.
@ -191,7 +220,9 @@ extern VOID LOS_PowerMgrSleepDelay(UINT32 tick);
* @since Huawei LiteOS V200R005C10
*/
extern VOID LOS_PowerMgrRegisterExtVoter(UINT32 (*)(VOID));
/*这是一个外部声明extern的函数 LOS_PowerMgrRegisterExtVoter
UINT32
*/
/**
* @ingroup los_lowpower
* @brief Get the sleep mode.
@ -250,7 +281,9 @@ extern UINT32 LOS_PowerMgrGetDeepSleepVoteCount(VOID);
* @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.
@ -269,7 +302,10 @@ extern VOID LOS_LowpowerInit(const PowerMgrOps *pmOps);
* @since Huawei LiteOS V200R005C10
*/
typedef VOID (*LowPowerHookFn)(VOID);
/*这是一个类型定义语句,定义了一个名为 LowPowerHookFn 的函数指针类型。
VOID
便退*/
/**
* @ingroup los_lowpower
* @brief Register a hook to enter lowpower framework process.
@ -288,7 +324,10 @@ typedef VOID (*LowPowerHookFn)(VOID);
* @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.
@ -307,7 +346,10 @@ extern VOID LOS_LowpowerHookReg(LowPowerHookFn hook);
* @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.
@ -326,7 +368,11 @@ typedef VOID (*IntWakeupHookFn)(HWI_HANDLE_T hwiNum);
* @since Huawei LiteOS V200R005C10
*/
extern VOID LOS_IntWakeupHookReg(IntWakeupHookFn hook);
/*这是一个外部声明extern的函数 LOS_IntWakeupHookReg
IntWakeupHookFn hook
便
*/
#ifdef __cplusplus
#if __cplusplus
}

@ -59,7 +59,22 @@ typedef struct {
UINT32 (*getSleepMode)(VOID); /**< Get sleep mode */
VOID (*setSleepMode)(UINT32 mode); /**< Set sleep mode */
} PowerMgrRunOps;
/*具体来说,该结构体包含以下函数指针成员:
changeFreq
enterLightSleeplight sleep
enterDeepSleepdeep sleep
setWakeUpTimer
withdrawWakeUpTimer
getSleepTime
selectSleepMode
preConfig
postConfig
contextSave
contextRestore
getDeepSleepVoteCount
getSleepMode
setSleepMode*/
/**
* @ingroup los_lowpower
*
@ -70,7 +85,11 @@ typedef struct {
UINT32 minDeepSleepTicks; /**< Min deep sleep ticks */
UINT32 maxDeepSleepTicks; /**< Max deep sleep ticks */
} PowerMgrConfig;
/*minLightSleepTicks最小轻度睡眠light sleep时钟周期数。
minDeepSleepTicksdeep sleep
maxDeepSleepTicksdeep sleep
使*/
/**
* @ingroup los_lowpower
*
@ -88,7 +107,16 @@ typedef struct {
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
*
@ -99,7 +127,10 @@ typedef struct {
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.

@ -75,7 +75,17 @@ extern "C" {
* 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.
@ -98,7 +108,10 @@ extern "C" {
*/
#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
@ -124,7 +137,11 @@ typedef struct {
} 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.
@ -153,7 +170,8 @@ typedef LOS_MEMBOX_INFO OS_MEMBOX_S;
* @since Huawei LiteOS V100R001C00
*/
extern UINT32 LOS_MemboxInit(VOID *pool, UINT32 poolSize, UINT32 blkSize);
/*该函数会使用提供的内存池起始地址和大小来初始化静态内存池,并指定每个内存块的大小。
*/
/**
* @ingroup los_membox
* @brief Request a static memory block.
@ -202,7 +220,7 @@ extern VOID *LOS_MemboxAlloc(VOID *pool);
* @since Huawei LiteOS V100R001C00
*/
extern UINT32 LOS_MemboxFree(VOID *pool, VOID *box);
/*调用该函数将会释放 box 所指向的内存块,并将其重新加入到内存池的空闲内存块链表中,以便下次分配使用。*/
/**
* @ingroup los_membox
* @brief Clear a static memory block.
@ -226,7 +244,8 @@ extern UINT32 LOS_MemboxFree(VOID *pool, VOID *box);
* @since Huawei LiteOS V100R001C00
*/
extern VOID LOS_MemboxClr(VOID *pool, VOID *box);
/*调用该函数将会将 box 所指向的内存块的数据内容清零,使其变为初始状态。
使*/
/**
* @ingroup los_membox
* @brief show static memory pool information.
@ -277,7 +296,9 @@ extern VOID LOS_ShowBox(VOID *pool);
* @since Huawei LiteOS V100R001C00
*/
extern UINT32 LOS_MemboxStatisticsGet(const VOID *boxMem, UINT32 *maxBlk, UINT32 *blkCnt, UINT32 *blkSize);
/*调用该函数将会获取静态内存池的统计信息,包括最大可分配内存块数量、
使*/
#ifdef __cplusplus
#if __cplusplus
}

@ -155,7 +155,12 @@ extern UINTPTR g_excInteractMemSize;
* @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.
@ -185,7 +190,10 @@ extern VOID *LOS_MemMalloc(VOID *pool, UINT32 size, UINT32 moduleId);
* @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.
@ -212,7 +220,9 @@ extern VOID *LOS_MemMallocAlign(VOID *pool, UINT32 size, UINT32 boundary, UINT32
* @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.
@ -324,7 +334,14 @@ typedef struct {
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.
@ -353,7 +370,8 @@ typedef struct {
* @since Huawei LiteOS V100R001C00
*/
extern UINT32 LOS_MemInit(VOID *pool, UINT32 size);
/*调用该函数将会对指定的内存池进行初始化操作,使其具备可用于分配和管理内存块的能力。
*/
/**
* @ingroup los_memory
* @brief Allocate dynamic memory.
@ -380,7 +398,8 @@ extern UINT32 LOS_MemInit(VOID *pool, UINT32 size);
* @since Huawei LiteOS V100R001C00
*/
extern VOID *LOS_MemAlloc(VOID *pool, UINT32 size);
/*通过该函数可以动态地从内存池中获取一块指定大小的内存块,以满足程序运行时的内存需求。分配的内存块可以根据实际需要进行读写操作
*/
/**
* @ingroup los_memory
* @brief Free dynamic memory.
@ -444,7 +463,7 @@ extern UINT32 LOS_MemFree(VOID *pool, VOID *ptr);
* @since Huawei LiteOS V100R001C00
*/
extern VOID *LOS_MemRealloc(VOID *pool, VOID *ptr, UINT32 size);
//通过该函数可以动态地调整已分配内存块的大小,以满足程序运行时动态变化的内存需求。
/**
* @ingroup los_memory
* @brief Allocate aligned memory.
@ -472,7 +491,9 @@ extern VOID *LOS_MemRealloc(VOID *pool, VOID *ptr, UINT32 size);
* @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.
@ -613,7 +634,9 @@ extern UINTPTR LOS_MemLastUsedGet(VOID *pool);
* @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.
@ -658,6 +681,10 @@ extern UINT32 LOS_MemFreeNodeShow(VOID *pool);
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.
@ -690,7 +717,9 @@ extern UINT32 LOS_MemIntegrityCheck(VOID *pool);
* @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.

@ -54,7 +54,10 @@ extern "C" {
* 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.
@ -64,7 +67,7 @@ extern "C" {
* 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.
@ -74,7 +77,8 @@ extern "C" {
* 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.
@ -84,7 +88,9 @@ extern "C" {
* 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.
@ -94,7 +100,9 @@ extern "C" {
* 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.
@ -104,7 +112,9 @@ extern "C" {
* 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
@ -116,7 +126,9 @@ extern "C" {
* 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.
@ -126,7 +138,7 @@ extern "C" {
* 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.
@ -175,7 +187,9 @@ extern "C" {
* @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.
@ -261,7 +275,14 @@ extern UINT32 LOS_MuxDelete(UINT32 muxHandle);
* @since Huawei LiteOS V100R001C00
*/
extern UINT32 LOS_MuxPend(UINT32 muxHandle, UINT32 timeout);
/*参数说明:
muxHandle
timeout0
LOS_OK
*/
/**
* @ingroup los_mux
* @brief Release a mutex.

@ -75,7 +75,12 @@ enum PerfStatus {
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.
@ -182,7 +187,13 @@ enum PerfEventType {
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
@ -199,7 +210,17 @@ enum PmuHwId {
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
@ -220,7 +241,13 @@ enum PmuSwId {
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
@ -235,7 +262,16 @@ enum PerfSampleType {
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
@ -253,7 +289,12 @@ typedef struct {
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
predivided64CPU BOOL */
/**
* @ingroup los_perf
* perf configuration main information
@ -279,7 +320,17 @@ extern VOID OsPerfHook(UINT32 event);
#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.

@ -46,7 +46,14 @@ extern "C" {
#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.
@ -97,7 +104,14 @@ extern void LOS_LkPrint(int level, const char *func, int line, const char *fmt,
#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.
@ -153,7 +167,15 @@ extern void dprintf(const char *fmt, ...);
#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.
@ -187,7 +209,15 @@ extern void dprintf(const char *fmt, ...);
#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.
@ -221,7 +251,14 @@ extern void dprintf(const char *fmt, ...);
#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.
@ -255,7 +292,14 @@ extern void dprintf(const char *fmt, ...);
#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.
@ -287,7 +331,16 @@ extern void dprintf(const char *fmt, ...);
#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.
@ -317,7 +370,11 @@ extern void dprintf(const char *fmt, ...);
} 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.

@ -55,7 +55,9 @@ extern "C" {
* @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.
@ -66,7 +68,11 @@ extern "C" {
* 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 0x01LOS_MOD_QUE
*/
/**
* @ingroup los_queue
* Queue error code: The memory for queue creation fails to be requested.
@ -77,7 +83,11 @@ extern "C" {
* 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 0x02LOS_MOD_QUE
*/
/**
* @ingroup los_queue
* Queue error code: The size of the biggest message in the created queue is too big.
@ -87,6 +97,9 @@ extern "C" {
* 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
@ -97,6 +110,11 @@ extern "C" {
* 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 0x01LOS_MOD_QUE
*/
/**
* @ingroup los_queue
@ -356,6 +374,21 @@ typedef struct tagQueueInfo {
} 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.
@ -397,7 +430,16 @@ extern UINT32 LOS_QueueCreateStatic(const CHAR *queueName,
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.
@ -431,7 +473,14 @@ extern UINT32 LOS_QueueCreate(const CHAR *queueName,
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.
@ -481,7 +530,7 @@ extern UINT32 LOS_QueueReadCopy(UINT32 queueId,
VOID *bufferAddr,
UINT32 *bufferSize,
UINT32 timeout);
/*该函数的作用是从队列中读取数据,并将数据复制到指定的缓冲区中。如果队列中没有数据可读,则根据超时时间等待数据可读,如果在超时时间内仍然没有数据可读,则返回错误码。*/
/**
* @ingroup los_queue
* @brief Write data into a queue.
@ -529,7 +578,13 @@ 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.
@ -581,7 +636,13 @@ 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.
@ -630,7 +691,13 @@ 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.
@ -679,7 +746,13 @@ 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.

@ -51,7 +51,14 @@ 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.
@ -66,7 +73,18 @@ typedef struct {
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.
@ -89,7 +107,8 @@ typedef struct {
* @since Huawei LiteOS V200R005C00
*/
extern UINT32 LOS_RingbufInit(Ringbuf *ringbuf, CHAR *fifo, UINT32 size);
/*该函数的作用是根据给定的参数初始化环形缓冲区对象,并分配必要的资源。通过调用这个函数,可以将一个已经定义的 Ringbuf
*/
/**
* @ingroup los_ringbuf
* @brief Reset a ringbuf.
@ -131,7 +150,9 @@ extern VOID LOS_RingbufReset(Ringbuf *ringbuf);
* @since Huawei LiteOS V200R005C00
*/
extern UINT32 LOS_RingbufWrite(Ringbuf *ringbuf, const CHAR *buf, UINT32 size);
/*该函数的作用是将指定大小的数据从源缓冲区写入到目标环形缓冲区中。写入操作会更新环形缓冲区的写入索引,并根据需要循环覆盖已有数据。如果环形缓冲区的空间不足以容纳全部数据,只会写入部分数据。
便*/
/**
* @ingroup los_ringbuf
* @brief Read data from ringbuf.
@ -153,7 +174,9 @@ extern UINT32 LOS_RingbufWrite(Ringbuf *ringbuf, const CHAR *buf, UINT32 size);
* @since Huawei LiteOS V200R005C00
*/
extern UINT32 LOS_RingbufRead(Ringbuf *ringbuf, CHAR *buf, UINT32 size);
/*该函数的作用是从指定大小的数据中读取数据,并将其存储到目标缓冲区。读取操作会更新环形缓冲区的读取索引,并根据需要循环读取已有数据。如果环形缓冲区中的数据不足以满足全部读取请求,只会读取部分数据。
便*/
/**
* @ingroup los_ringbuf
* @brief Get a ringbuf's used size.

Loading…
Cancel
Save