Merge pull request '王维轮合并' (#15) from wangweilun_branch into master

master
p2gpamesw 10 months ago
commit c9d89c67b4

Binary file not shown.

@ -58,7 +58,7 @@ typedef struct {
LOS_DL_LIST queues[NPQS]; /* one for each priority */ LOS_DL_LIST queues[NPQS]; /* one for each priority */
SPIN_LOCK_S lock; /* private spinlock */ SPIN_LOCK_S lock; /* private spinlock */
} PriQueue; } PriQueue;
/*用于实现一个具有多个优先级的队列结构,并提供了相关的数据结构和锁来支持队列操作的线程安全性*/
/* priority queue per-cpu */ /* priority queue per-cpu */
STATIC PriQueue g_priqueue[LOSCFG_KERNEL_CORE_NUM]; STATIC PriQueue g_priqueue[LOSCFG_KERNEL_CORE_NUM];
@ -68,17 +68,20 @@ STATIC INLINE UINT32 OsMpIdleMask(VOID)
{ {
return ((~g_activeCpu) & LOSCFG_KERNEL_CPU_MASK); return ((~g_activeCpu) & LOSCFG_KERNEL_CPU_MASK);
} }
/*这个函数可能用来计算当前处于空闲状态的 CPU 核心的掩码。STATIC 关键字表示该函数是静态的,只在当前文件内可见,
INLINE */
STATIC INLINE VOID OsMpSetIdle(UINT32 cpu) STATIC INLINE VOID OsMpSetIdle(UINT32 cpu)
{ {
g_activeCpu &= ~CPUID_TO_AFFI_MASK(cpu); g_activeCpu &= ~CPUID_TO_AFFI_MASK(cpu);
} }
/*这个函数可能用于将指定的 CPU 核心设置为待机状态。
g_activeCpu */
STATIC INLINE VOID OsMpSetActive(UINT32 cpu) STATIC INLINE VOID OsMpSetActive(UINT32 cpu)
{ {
g_activeCpu |= CPUID_TO_AFFI_MASK(cpu); g_activeCpu |= CPUID_TO_AFFI_MASK(cpu);
} }
/*这个函数可能用于将指定的 CPU 核心设置为活动状态。
g_activeCpu */
VOID OsPriQueueInit(VOID) VOID OsPriQueueInit(VOID)
{ {
LOS_DL_LIST *priQueues = NULL; LOS_DL_LIST *priQueues = NULL;
@ -97,7 +100,7 @@ VOID OsPriQueueInit(VOID)
} }
} }
} }
/*这段代码的作用是初始化多核系统中每个核心的优先级队列,确保每个队列都处于初始状态*/
UINT32 OsPriQueueSize(UINT32 priority) UINT32 OsPriQueueSize(UINT32 priority)
{ {
UINT32 itemCnt = 0; UINT32 itemCnt = 0;
@ -112,7 +115,7 @@ UINT32 OsPriQueueSize(UINT32 priority)
return itemCnt; return itemCnt;
} }
/*这段代码的作用是获取多核系统中某个核心指定优先级的队列中的任务数量*/
UINT32 OsPriQueueTotalSize(VOID) UINT32 OsPriQueueTotalSize(VOID)
{ {
UINT32 priority; UINT32 priority;
@ -125,7 +128,7 @@ UINT32 OsPriQueueTotalSize(VOID)
return totalSize; return totalSize;
} }
/*这段代码的作用是计算多核系统中所有优先级队列的总任务数量,以便进行系统性能监控和优化*/
UINT32 OsSchedPickCpu(LosTaskCB* task) UINT32 OsSchedPickCpu(LosTaskCB* task)
{ {
UINT32 cpuid, lastMask, cpuidMask, affinity; UINT32 cpuid, lastMask, cpuidMask, affinity;
@ -158,7 +161,7 @@ UINT32 OsSchedPickCpu(LosTaskCB* task)
return cpuid; return cpuid;
} }
/*这段代码的作用是根据任务的亲和性、空闲核心和任务上次运行的核心等信息,选择一个适合调度任务的 CPU 核心。*/
VOID OsPriQueueAdd(PriQueue *priQueue, LosTaskCB* task, QueueOps flag) VOID OsPriQueueAdd(PriQueue *priQueue, LosTaskCB* task, QueueOps flag)
{ {
LOS_DL_LIST *priQueues = NULL; LOS_DL_LIST *priQueues = NULL;
@ -179,7 +182,7 @@ VOID OsPriQueueAdd(PriQueue *priQueue, LosTaskCB* task, QueueOps flag)
LOS_ListTailInsert(&priQueues[priority], &task->pendList); LOS_ListTailInsert(&priQueues[priority], &task->pendList);
} }
} }
/*这段代码的作用是根据任务的优先级,将任务插入到对应优先级的队列中,并更新相应的位图信息。*/
/* /*
* Insert a task to the head of priority queue, only available * Insert a task to the head of priority queue, only available
* when putting running task back to the ready queue. * when putting running task back to the ready queue.
@ -189,14 +192,14 @@ VOID OsPriQueueEnqueueHead(LOS_DL_LIST *queueNode, UINT32 priority)
LosTaskCB *task = LOS_DL_LIST_ENTRY(queueNode, LosTaskCB, pendList); LosTaskCB *task = LOS_DL_LIST_ENTRY(queueNode, LosTaskCB, pendList);
OsPriQueueAdd(&g_priqueue[ArchCurrCpuid()], task, QUEUE_HEAD); OsPriQueueAdd(&g_priqueue[ArchCurrCpuid()], task, QUEUE_HEAD);
} }
/*这段代码的作用是将指定任务插入到指定优先级队列的队头,用于在将当前任务从运行态切换到就绪态时,将当前任务重新插入到相应优先级队列的队头*/
VOID OsPriQueueEnqueueTail(LOS_DL_LIST *queueNode, UINT32 priority) VOID OsPriQueueEnqueueTail(LOS_DL_LIST *queueNode, UINT32 priority)
{ {
LosTaskCB *task = LOS_DL_LIST_ENTRY(queueNode, LosTaskCB, pendList); LosTaskCB *task = LOS_DL_LIST_ENTRY(queueNode, LosTaskCB, pendList);
OsPriQueueAdd(&g_priqueue[ArchCurrCpuid()], task, QUEUE_TAIL); OsPriQueueAdd(&g_priqueue[ArchCurrCpuid()], task, QUEUE_TAIL);
} }
/*这段代码的作用是将指定任务插入到指定优先级队列的队尾,用于在将一个新的任务从就绪态加入到相应优先级队列时,将任务插入到队尾*/
/* /*
* Insert a task to the tail of priority queue. The pri-queue might be * Insert a task to the tail of priority queue. The pri-queue might be
* this or another core's. * this or another core's.
@ -215,7 +218,7 @@ VOID OsPriQueueEnqueue(LOS_DL_LIST *queueNode, UINT32 priority)
/* add the task to the cpu per-core pri-queue */ /* add the task to the cpu per-core pri-queue */
OsPriQueueAdd(&g_priqueue[cpuid], task, QUEUE_TAIL); OsPriQueueAdd(&g_priqueue[cpuid], task, QUEUE_TAIL);
} }
/*这段代码的作用是将指定任务加入到相应的优先级队列中,并根据任务的调度要求选择适当的 CPU*/
VOID OsPriQueueDequeue(LOS_DL_LIST *queueNode) VOID OsPriQueueDequeue(LOS_DL_LIST *queueNode)
{ {
LosTaskCB *task = NULL; LosTaskCB *task = NULL;
@ -234,7 +237,7 @@ VOID OsPriQueueDequeue(LOS_DL_LIST *queueNode)
(*bitmap) &= ~(PRI0_BIT >> task->priority); (*bitmap) &= ~(PRI0_BIT >> task->priority);
} }
} }
/*这段代码的作用是从优先级队列中删除指定的任务节点,并在必要时更新位图以反映每个优先级队列的状态*/
LITE_OS_SEC_TEXT_MINOR LosTaskCB *OsGetTopTask(VOID) LITE_OS_SEC_TEXT_MINOR LosTaskCB *OsGetTopTask(VOID)
{ {
LosTaskCB *newTask = NULL; LosTaskCB *newTask = NULL;
@ -262,7 +265,7 @@ LITE_OS_SEC_TEXT_MINOR LosTaskCB *OsGetTopTask(VOID)
out: out:
return newTask; return newTask;
} }
/*这段代码的作用是从当前 CPU 的优先级队列中获取具有最高优先级的任务,并将其从队列中删除。*/
VOID OsSchedResched(VOID) VOID OsSchedResched(VOID)
{ {
LosTaskCB *runTask = NULL; LosTaskCB *runTask = NULL;
@ -326,7 +329,7 @@ VOID OsSchedResched(VOID)
/* do the task context switch */ /* do the task context switch */
OsTaskSchedule(newTask, runTask); OsTaskSchedule(newTask, runTask);
} }
/*这段代码实现了两个任务之间的上下文切换,包括状态更新、占用时间计算、任务监控等一系列处理,并最终调用 OsTaskSchedule 函数切换到新的任务执行。*/
VOID OsSchedPreempt(VOID) VOID OsSchedPreempt(VOID)
{ {
LosTaskCB *runTask = NULL; LosTaskCB *runTask = NULL;
@ -357,7 +360,7 @@ VOID OsSchedPreempt(VOID)
SCHEDULER_UNLOCK(intSave); SCHEDULER_UNLOCK(intSave);
} }
/*这段代码实现了抢占式调度的功能,能够在高优先级任务到来时立即暂停正在运行的低优先级任务,提高系统的响应速度和稳定性*/
#ifdef LOSCFG_BASE_CORE_TIMESLICE #ifdef LOSCFG_BASE_CORE_TIMESLICE
LITE_OS_SEC_TEXT VOID OsTimesliceCheck(VOID) LITE_OS_SEC_TEXT VOID OsTimesliceCheck(VOID)
{ {
@ -370,7 +373,7 @@ LITE_OS_SEC_TEXT VOID OsTimesliceCheck(VOID)
} }
} }
#endif #endif
/*这段代码实现了基于时间片的轮转调度算法,通过限制每个任务的执行时间,实现了任务之间的公平调度*/
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
} }

@ -60,7 +60,7 @@ UINT32 OsPriQueueInit(VOID)
return LOS_OK; return LOS_OK;
} }
/*这段代码是用于初始化优先级队列的函数 OsPriQueueInit*/
VOID OsPriQueueEnqueueHead(LOS_DL_LIST *priqueueItem, UINT32 priority) VOID OsPriQueueEnqueueHead(LOS_DL_LIST *priqueueItem, UINT32 priority)
{ {
/* /*
@ -76,7 +76,7 @@ VOID OsPriQueueEnqueueHead(LOS_DL_LIST *priqueueItem, UINT32 priority)
LOS_ListHeadInsert(&g_priQueueList[priority], priqueueItem); LOS_ListHeadInsert(&g_priQueueList[priority], priqueueItem);
} }
/*这段代码是用于将一个节点插入到优先级队列头部的函数*/
VOID OsPriQueueEnqueue(LOS_DL_LIST *priqueueItem, UINT32 priority) VOID OsPriQueueEnqueue(LOS_DL_LIST *priqueueItem, UINT32 priority)
{ {
/* /*
@ -92,7 +92,7 @@ VOID OsPriQueueEnqueue(LOS_DL_LIST *priqueueItem, UINT32 priority)
LOS_ListTailInsert(&g_priQueueList[priority], priqueueItem); LOS_ListTailInsert(&g_priQueueList[priority], priqueueItem);
} }
/*这段代码是用于将一个节点插入到优先级队列尾部的函数*/
VOID OsPriQueueDequeue(LOS_DL_LIST *priqueueItem) VOID OsPriQueueDequeue(LOS_DL_LIST *priqueueItem)
{ {
LosTaskCB *runTask = NULL; LosTaskCB *runTask = NULL;
@ -103,7 +103,7 @@ VOID OsPriQueueDequeue(LOS_DL_LIST *priqueueItem)
g_priQueueBitmap &= ~(PRIQUEUE_PRIOR0_BIT >> runTask->priority); g_priQueueBitmap &= ~(PRIQUEUE_PRIOR0_BIT >> runTask->priority);
} }
} }
/*这个函数的作用是取出优先级队列中的队首节点,并更新相应的状态信息。*/
LOS_DL_LIST *OsPriQueueTop(VOID) LOS_DL_LIST *OsPriQueueTop(VOID)
{ {
UINT32 priority; UINT32 priority;
@ -115,7 +115,7 @@ LOS_DL_LIST *OsPriQueueTop(VOID)
return NULL; return NULL;
} }
/*这个函数的作用是获取当前优先级队列中的队首节点,并返回该节点的指针,以供后续操作使用*/
UINT32 OsPriQueueSize(UINT32 priority) UINT32 OsPriQueueSize(UINT32 priority)
{ {
UINT32 itemCnt = 0; UINT32 itemCnt = 0;
@ -140,7 +140,7 @@ UINT32 OsPriQueueSize(UINT32 priority)
return itemCnt; return itemCnt;
} }
/*这个函数的作用是计算指定优先级队列中节点的数量,可以用于监控任务在不同优先级队列中的排队情况*/
LITE_OS_SEC_TEXT_MINOR LosTaskCB *OsGetTopTask(VOID) LITE_OS_SEC_TEXT_MINOR LosTaskCB *OsGetTopTask(VOID)
{ {
UINT32 priority; UINT32 priority;
@ -170,7 +170,7 @@ LITE_OS_SEC_TEXT_MINOR LosTaskCB *OsGetTopTask(VOID)
OUT: OUT:
return newTask; return newTask;
} }
/*这个函数的作用是获取优先级最高的任务控制块,并将其从相应的优先级队列中移除,以便进行调度执行*/
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
} }

@ -103,7 +103,7 @@ VOID OsSchedResched(VOID)
/* do the task context switch */ /* do the task context switch */
OsTaskSchedule(newTask, runTask); OsTaskSchedule(newTask, runTask);
} }
/*这段代码实现了操作系统的任务调度功能,根据任务的优先级和状态来选择合适的任务进行切换,并更新任务状态及相关信息,最终实现任务的切换和调度*/
VOID OsSchedPreempt(VOID) VOID OsSchedPreempt(VOID)
{ {
LosTaskCB *runTask = NULL; LosTaskCB *runTask = NULL;
@ -134,7 +134,7 @@ VOID OsSchedPreempt(VOID)
SCHEDULER_UNLOCK(intSave); SCHEDULER_UNLOCK(intSave);
} }
/*这段代码实现了在需要进行任务抢占时,将当前任务标记为就绪状态并重新加入就绪队列,然后触发任务重新调度,以实现任务的抢占和切换。*/
#ifdef LOSCFG_BASE_CORE_TIMESLICE #ifdef LOSCFG_BASE_CORE_TIMESLICE
LITE_OS_SEC_TEXT VOID OsTimesliceCheck(VOID) LITE_OS_SEC_TEXT VOID OsTimesliceCheck(VOID)
{ {
@ -147,7 +147,7 @@ LITE_OS_SEC_TEXT VOID OsTimesliceCheck(VOID)
} }
} }
#endif #endif
/*这段代码实现了时间片轮转调度算法中的时间片检查和调度触发功能,当任务时间片用尽时,会自动触发调度,让其他可运行任务有机会获得 CPU 时间片并进行执行。*/
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
} }

@ -25,16 +25,16 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --------------------------------------------------------------------------- */ * --------------------------------------------------------------------------- */
/*该函数定义提供了运行停止功能所需的接口和参数类型,为嵌入式系统中的运行停止操作提供了基本的支持
/** /**
* @defgroup los_runstop Wakeup * @defgroup los_runstop Wakeup
* @ingroup kernel * @ingroup kernel
*/ */
#ifndef _LOS_RUNSTOP_H #ifndef _LOS_RUNSTOP_H 组的定义:该组包含了一些与运行停止有关的函数和宏定义。
#define _LOS_RUNSTOP_H #define _LOS_RUNSTOP_H
#include "los_typedef.h" #include "los_typedef.h"包含了 LOS Kernel 所需的基本类型定义。
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
@ -43,7 +43,7 @@ extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
/** /**
* @ingroup los_runstop * @ingroup los_runstop ##
* @brief Define the type of a runstop callback function. * @brief Define the type of a runstop callback function.
* *
* @par Description: * @par Description:
@ -63,7 +63,7 @@ extern "C" {
* @see None. * @see None.
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
typedef VOID (*RUNSTOP_CALLBACK_FUNC)(VOID); typedef VOID (*RUNSTOP_CALLBACK_FUNC)(VOID);/*函数指针类型RUNSTOP_CALLBACK_FUNC用于定义运行停止时的回调函数没有参数和返回值
/** /**
* @ingroup los_runstop * @ingroup los_runstop
@ -88,7 +88,10 @@ typedef VOID (*RUNSTOP_CALLBACK_FUNC)(VOID);
* @see None. * @see None.
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
typedef INT32 (*FLASH_READ_FUNC)(VOID *memAddr, size_t start, size_t size); typedef INT32 (*FLASH_READ_FUNC)(VOID *memAddr, size_t start, size_t size);/*定义了一个名为FLASH_READ_FUNC的函数指针类型用于定义一个从Flash中读取数据的函数
memAddrFlash
startFlash
sizeFlash
/** /**
* @ingroup los_runstop * @ingroup los_runstop
@ -113,7 +116,10 @@ typedef INT32 (*FLASH_READ_FUNC)(VOID *memAddr, size_t start, size_t size);
* @see None. * @see None.
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
typedef INT32 (*FLASH_WRITE_FUNC)(VOID *memAddr, size_t start, size_t size); typedef INT32 (*FLASH_WRITE_FUNC)(VOID *memAddr, size_t start, size_t size);/*定义一个用于写入flash数据的函数类
memAddrflash
startflash
sizeflash
/** /**
* @ingroup los_runstop * @ingroup los_runstop
@ -122,20 +128,17 @@ typedef INT32 (*FLASH_WRITE_FUNC)(VOID *memAddr, size_t start, size_t size);
* Information of specified parameters passed in during runstop. * Information of specified parameters passed in during runstop.
*/ */
typedef struct tagRunstopParam { typedef struct tagRunstopParam {
RUNSTOP_CALLBACK_FUNC pfIdleWakeupCallback; /* < Wake up callback function, called in idle task */ RUNSTOP_CALLBACK_FUNC pfIdleWakeupCallback; /*< 空闲任务中的唤醒回调函数 */
RUNSTOP_CALLBACK_FUNC pfWakeupCallback; /* < Wake up callback function */ RUNSTOP_CALLBACK_FUNC pfWakeupCallback; /*< 唤醒回调函数 */
RUNSTOP_CALLBACK_FUNC pfImageDoneCallback; /* < Image done callback function, called just after memory is stored */ RUNSTOP_CALLBACK_FUNC pfImageDoneCallback; /*< 内存存储完成后的回调函数 */
FLASH_READ_FUNC pfFlashReadFunc; /* < An abstract function for reading data from a certain flash */ FLASH_READ_FUNC pfFlashReadFunc; /*< 从某个闪存中读取数据的抽象函数 */
FLASH_WRITE_FUNC pfFlashWriteFunc; /* < An abstract function for writing data to a certain flash */ FLASH_WRITE_FUNC pfFlashWriteFunc; /*< 向某个闪存中写入数据的抽象函数 */
size_t uwFlashReadAlignSize; /* < Block align size when reading data from a certain flash */ size_t uwFlashReadAlignSize; /*< 从某个闪存中读取数据时的块对齐大小 */
size_t uwFlashEraseAlignSize; /* < Block align size when erasing data in a certain flash */ size_t uwFlashEraseAlignSize; /*< 擦除某个闪存中数据时的块对齐大小 */
size_t uwFlashWriteAlignSize; /* < Block align size when writing data to a certain flash */ size_t uwFlashWriteAlignSize; /*< 向某个闪存中写入数据时的块对齐大小 */
UINTPTR uwWowFlashAddr; /* < The flash starting address to which the memory is to be UINTPTR uwWowFlashAddr; /* < 存储内存的闪存起始地址,地址应与闪存写入对齐长度对齐 */
stored, the address should be flash write-alignment length UINTPTR uwImageFlashAddr; /* < 整个应用程序镜像烧录到的闪存起始地址 */
aligned */ } RUNSTOP_PARAM_S;/*是用于传递和配置运行停止功能所需的参数信息
UINTPTR uwImageFlashAddr; /* < The flash starting address where the whole application image
is burned */
} RUNSTOP_PARAM_S;
/** /**
* @ingroup los_runstop * @ingroup los_runstop
@ -159,8 +162,8 @@ typedef struct tagRunstopParam {
* @see * @see
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern VOID LOS_MakeImage(const RUNSTOP_PARAM_S *runstopParam); extern VOID LOS_MakeImage(const RUNSTOP_PARAM_S *runstopParam);/*定义了一个名为LOS_MakeImage的函数用于将内存映像存储到flash中。
runstopParamrunstop使flash
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
} }

@ -25,7 +25,7 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --------------------------------------------------------------------------- */ * --------------------------------------------------------------------------- */
/*这段代码实现了对信号量操作的基本功能,包括创建、删除、请求和释放信号量,并对可能出现的错误情况进行了定义和说明。*/
/** /**
* @defgroup los_sem Semaphore * @defgroup los_sem Semaphore
* @ingroup kernel * @ingroup kernel
@ -49,17 +49,17 @@ extern "C" {
* @ingroup los_sem * @ingroup los_sem
* Max count of counting semaphores * Max count of counting semaphores
*/ */
#define LOS_SEM_COUNT_MAX 0xFFFE #define LOS_SEM_COUNT_MAX 0xFFFE/*计数信号量的最大值*/
/** /**
* @ingroup los_sem * @ingroup los_sem
* Semaphore error code: The memory is insufficient. * Semaphore error code: The memory is insufficient.
* *
* Value: 0x02000700. * Value: 0x02000700.
* *
* Solution: Allocate more memory. * Solution: Allocate more memory.
*/ */
#define LOS_ERRNO_SEM_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_SEM, 0x00) #define LOS_ERRNO_SEM_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_SEM, 0x00)/*定义一个信号量Semaphore的错误码表示内存不足
/** /**
* @ingroup los_sem * @ingroup los_sem
@ -72,14 +72,15 @@ extern "C" {
#define LOS_ERRNO_SEM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_SEM, 0x01) #define LOS_ERRNO_SEM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_SEM, 0x01)
/** /**
* @ingroup los_sem * @ingroup los_sem
* Semaphore error code: Null pointer. * Semaphore error code: Null pointer.
* *
* Value: 0x02000702. * Value: 0x02000702.
* *
* Solution: Change the passed-in null pointer to a valid non-null pointer. * Solution: Change the passed-in null pointer to a valid non-null pointer.
*/ */
#define LOS_ERRNO_SEM_PTR_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_SEM, 0x02) #define LOS_ERRNO_SEM_PTR_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_SEM, 0x02)/*这段代码定义了一个信号量模块的错误码,表示参数无效
/** /**
* @ingroup los_sem * @ingroup los_sem
@ -87,9 +88,9 @@ extern "C" {
* *
* Value: 0x02000703. * Value: 0x02000703.
* *
* Solution: Perform corresponding operations based on the requirements in the code context. * Solution: Perform corresponding operations based on the requirements in the code context.
*/ */
#define LOS_ERRNO_SEM_ALL_BUSY LOS_ERRNO_OS_ERROR(LOS_MOD_SEM, 0x03) #define LOS_ERRNO_SEM_ALL_BUSY LOS_ERRNO_OS_ERROR(LOS_MOD_SEM, 0x03)/*定义了一个信号量模块的错误码,表示没有可用的信号量控制结构*/
/** /**
* @ingroup los_sem * @ingroup los_sem
@ -97,9 +98,9 @@ extern "C" {
* *
* Value: 0x02000704. * Value: 0x02000704.
* *
* Solution: Change the passed-in parameter value to a valid nonzero value. * Solution: Change the passed-in parameter value to a valid nonzero value.
*/ */
#define LOS_ERRNO_SEM_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_SEM, 0x04) #define LOS_ERRNO_SEM_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_SEM, 0x04)/*定义了一个信号量模块的错误码,表示指定的超时时间参数无效*/
/** /**
* @ingroup los_sem * @ingroup los_sem
@ -107,9 +108,9 @@ extern "C" {
* *
* Value: 0x02000705. * Value: 0x02000705.
* *
* Solution: Do not call the API during an interrupt. * Solution: Do not call the API during an interrupt.a:API
*/ */
#define LOS_ERRNO_SEM_PEND_INTERR LOS_ERRNO_OS_ERROR(LOS_MOD_SEM, 0x05) #define LOS_ERRNO_SEM_PEND_INTERR LOS_ERRNO_OS_ERROR(LOS_MOD_SEM, 0x05)/*定义了一个信号量模块的错误码表示在中断期间调用了该API这是被禁止的*/
/** /**
* @ingroup los_sem * @ingroup los_sem
@ -117,9 +118,9 @@ extern "C" {
* *
* Value: 0x02000706. * Value: 0x02000706.
* *
* Solution: Do not call LOS_SemPend when task scheduling is locked. * Solution: Do not call LOS_SemPend when task scheduling is locked.LOS_SemPend
*/ */
#define LOS_ERRNO_SEM_PEND_IN_LOCK LOS_ERRNO_OS_ERROR(LOS_MOD_SEM, 0x06) #define LOS_ERRNO_SEM_PEND_IN_LOCK LOS_ERRNO_OS_ERROR(LOS_MOD_SEM, 0x06)/*定义了一个信号量模块的错误码,表示由于任务调度被锁定,任务无法请求信号量*/
/** /**
* @ingroup los_sem * @ingroup los_sem
@ -127,9 +128,9 @@ extern "C" {
* *
* Value: 0x02000707. * Value: 0x02000707.
* *
* Solution: Change the passed-in parameter value to the value within the valid range. * Solution: Change the passed-in parameter value to the value within the valid range.
*/ */
#define LOS_ERRNO_SEM_TIMEOUT LOS_ERRNO_OS_ERROR(LOS_MOD_SEM, 0x07) #define LOS_ERRNO_SEM_TIMEOUT LOS_ERRNO_OS_ERROR(LOS_MOD_SEM, 0x07)/*定义了一个信号量模块的错误码,表示请求信号量超时*/
/** /**
* @ingroup los_sem * @ingroup los_sem
@ -137,9 +138,9 @@ extern "C" {
* *
* Value: 0x02000708. * Value: 0x02000708.
* *
* Solution: Perform corresponding operations based on the requirements in the code context. * Solution: Perform corresponding operations based on the requirements in the code context.
*/ */
#define LOS_ERRNO_SEM_OVERFLOW LOS_ERRNO_OS_ERROR(LOS_MOD_SEM, 0x08) #define LOS_ERRNO_SEM_OVERFLOW LOS_ERRNO_OS_ERROR(LOS_MOD_SEM, 0x08)/*定义了一个信号量模块的错误码,表示信号量释放的次数超过了允许的最大次数
/** /**
* @ingroup los_sem * @ingroup los_sem
@ -148,9 +149,9 @@ extern "C" {
* *
* Value: 0x02000709. * Value: 0x02000709.
* *
* Solution: Delete the semaphore after awaking all tasks that are waiting on the semaphore. * Solution: Delete the semaphore after awaking all tasks that are waiting on the semaphore.
*/ */
#define LOS_ERRNO_SEM_PENDED LOS_ERRNO_OS_ERROR(LOS_MOD_SEM, 0x09) #define LOS_ERRNO_SEM_PENDED LOS_ERRNO_OS_ERROR(LOS_MOD_SEM, 0x09)/*定义了一个信号量模块的错误码,表示等待信号量的任务队列不为空*/
/** /**
* @ingroup los_sem * @ingroup los_sem
@ -159,10 +160,10 @@ extern "C" {
* *
* Value: 0x0200070A. * Value: 0x0200070A.
* *
* Solution: Do not call the API in the system-level callback. * Solution: Do not call the API in the system-level callback.API
* @deprecated This error code is obsolete since LiteOS 5.0.0. * @deprecated This error code is obsolete since LiteOS 5.0.0.LiteOS 5.0.0
*/ */
#define LOS_ERRNO_SEM_PEND_IN_SYSTEM_TASK LOS_ERRNO_OS_ERROR(LOS_MOD_SEM, 0x0A) #define LOS_ERRNO_SEM_PEND_IN_SYSTEM_TASK LOS_ERRNO_OS_ERROR(LOS_MOD_SEM, 0x0A)/*定义了一个信号量模块的错误码表示在系统级回调中调用了该API这是被禁止的*/
/** /**
* @ingroup los_sem * @ingroup los_sem
@ -187,7 +188,8 @@ extern "C" {
* @see LOS_SemDelete | LOS_BinarySemCreate * @see LOS_SemDelete | LOS_BinarySemCreate
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern UINT32 LOS_SemCreate(UINT16 count, UINT32 *semHandle); extern UINT32 LOS_SemCreate(UINT16 count, UINT32 *semHandle);/*这段代码声明了一个函数LOS_SemCreate用于创建信号量。该函数根据传入的初始可用信号量数量
ID*/
/** /**
* @ingroup los_sem * @ingroup los_sem
@ -212,7 +214,7 @@ extern UINT32 LOS_SemCreate(UINT16 count, UINT32 *semHandle);
* @see LOS_SemCreate | LOS_SemDelete * @see LOS_SemCreate | LOS_SemDelete
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern UINT32 LOS_BinarySemCreate(UINT16 count, UINT32 *semHandle); extern UINT32 LOS_BinarySemCreate(UINT16 count, UINT32 *semHandle);/*声明了一个函数原型 LOS_BinarySemCreate用于创建一个二进制信号量。*/
/** /**
* @ingroup los_sem * @ingroup los_sem
@ -235,7 +237,7 @@ extern UINT32 LOS_BinarySemCreate(UINT16 count, UINT32 *semHandle);
* @see LOS_SemCreate | LOS_BinarySemCreate * @see LOS_SemCreate | LOS_BinarySemCreate
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern UINT32 LOS_SemDelete(UINT32 semHandle); extern UINT32 LOS_SemDelete(UINT32 semHandle);/*这段代码定义了一个函数LOS_SemDelete用于删除一个信号量的控制结构*/
/** /**
* @ingroup los_sem * @ingroup los_sem
@ -272,7 +274,19 @@ extern UINT32 LOS_SemDelete(UINT32 semHandle);
* @see LOS_SemPost | LOS_SemCreate | LOS_BinarySemCreate * @see LOS_SemPost | LOS_SemCreate | LOS_BinarySemCreate
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern UINT32 LOS_SemPend(UINT32 semHandle, UINT32 timeout); extern UINT32 LOS_SemPend(UINT32 semHandle, UINT32 timeout);/*该函数用于请求一个信号量
semHandleIDID
timeouttimeout0timeout0xFFFFFFFFTick
LOS_ERRNO_SEM_INVALIDsemHandle
LOS_ERRNO_SEM_UNAVAILABLE
LOS_ERRNO_SEM_PEND_INTERR [Something went wrong, please try again later.]
*/
/** /**
* @ingroup los_sem * @ingroup los_sem
@ -294,7 +308,12 @@ extern UINT32 LOS_SemPend(UINT32 semHandle, UINT32 timeout);
* @see LOS_SemPend | LOS_SemCreate | LOS_BinarySemCreate * @see LOS_SemPend | LOS_SemCreate | LOS_BinarySemCreate
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern UINT32 LOS_SemPost(UINT32 semHandle); extern UINT32 LOS_SemPost(UINT32 semHandle);/*这段代码定义了一个函数LOS_SemPost用于释放一个信号量*/
/*LOS_SemPost用于释放由semHandle指定的信号量控制结构。
LOS_ERRNO_SEM_INVALID
LOS_ERRNO_SEM_OVERFLOW
LOS_OK
LOS_SemPendLOS_SemCreateLOS_BinarySemCreate*/
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus

@ -25,7 +25,7 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --------------------------------------------------------------------------- */ * --------------------------------------------------------------------------- */
/*以上代码是关于内存管理中的slab功能的实现。Slab是一种分配固定大小的内存块的机制用于提高内存分配和释放的效率。以上代码提供了对slab内存分配器的配置和定义*/
/** /**
* @defgroup los_slab Slab * @defgroup los_slab Slab
* @ingroup kernel * @ingroup kernel
@ -46,9 +46,9 @@ extern "C" {
* @ingroup los_slab * @ingroup los_slab
* total size of each slab class. * total size of each slab class.
*/ */
#define SLAB_MEM_ALLOCATOR_SIZE 512U #define SLAB_MEM_ALLOCATOR_SIZE 512U /*宏定义SLAB_MEM_ALLOCATOR_SIZE表示每个slab class一种内存分配方式所需要的总大小为512字节*/
#define SLAB_BASIC_NEED_SIZE 0x1000 #define SLAB_BASIC_NEED_SIZE 0x1000 /*宏定义SLAB_BASIC_NEED_SIZE表示内存分配时最小需要的空间为0x1000字节即4KB。*/
/** /**
* @ingroup los_slab * @ingroup los_slab
@ -63,7 +63,14 @@ enum SlabBucketSizeType {
#define SLAB_MEM_BUCKET_SIZE_TYPE SLAB_BUCKET_SIZE_HALF_OF_HEAP #define SLAB_MEM_BUCKET_SIZE_TYPE SLAB_BUCKET_SIZE_HALF_OF_HEAP
#endif #endif
/*这段代码主要是用于配置和定义slab内存分配器中内存块大小的相关选项。*/
/*这段代码定义了一个枚举类型SlabBucketSizeType用于表示slab bucket内存块的大小类型
LOSCFG_KERNEL_MEM_SLAB_AUTO_EXPANSION_MODESlabBucketSizeType
SlabBucketSizeType
SLAB_BUCKET_SIZE_HALF_OF_HEAPslab使
SLAB_BUCKET_SIZE_QUARTER_OF_HEAPslab使
SLAB_BUCKET_SIZE_TYPE_MAX
SLAB_MEM_BUCKET_SIZE_TYPESLAB_BUCKET_SIZE_HALF_OF_HEAPslab*/
/** /**
* @ingroup los_slab * @ingroup los_slab
* @brief configure slab size. * @brief configure slab size.
@ -86,8 +93,11 @@ enum SlabBucketSizeType {
* </ul> * </ul>
* @since Huawei LiteOS V200R003C00 * @since Huawei LiteOS V200R003C00
*/ */
extern VOID LOS_SlabSizeCfg(UINT32 *cfg, UINT32 cnt); extern VOID LOS_SlabSizeCfg(UINT32 *cfg, UINT32 cnt);/*段代码是关于操作系统内存管理中的slab功能的配置函数。Slab是一种分配固定大小的内存块的机制
*/
/*该函数LOS_SlabSizeCfg用于配置slab的大小。它接受两个参数
cfgslabslab
cntslab*/
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
} }

@ -25,7 +25,7 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*---------------------------------------------------------------------------*/ *---------------------------------------------------------------------------*/
/*以上代码实现了自旋锁的基本操作,并根据多处理器系统和非多处理器系统分别进行了处理*/
/** /**
* @defgroup los_spinlock Spinlock * @defgroup los_spinlock Spinlock
* @ingroup kernel * @ingroup kernel
@ -55,13 +55,19 @@ extern "C" {
#define LOCKDEP_CHECK_OUT(lock) OsLockDepCheckOut(lock) #define LOCKDEP_CHECK_OUT(lock) OsLockDepCheckOut(lock)
#define LOCKDEP_CLEAR_LOCKS() OsLockdepClearSpinlocks() #define LOCKDEP_CLEAR_LOCKS() OsLockdepClearSpinlocks()
#define SPIN_LOCK_INITIALIZER(lockName) \ #define SPIN_LOCK_INITIALIZER(lockName) \/*这段代码看起来是定义了一个自旋锁的初始化器。不同的编译选项将定义不同的初始化器*/
{ \ { \
.rawLock = 0U, \ .rawLock = 0U, \
.cpuid = (UINT32)(-1), \ .cpuid = (UINT32)(-1), \
.owner = SPINLOCK_OWNER_INIT, \ .owner = SPINLOCK_OWNER_INIT, \
.name = #lockName, \ .name = #lockName, \
} }
/*当预定义宏为真时SPIN_LOCK_INITIALIZER宏会被展开为一个结构体初始化器其中包含了一些成员变量的初始化包括
.rawLock0;
.cpuidCPU-1;
.ownerSPINLOCK_OWNER_INIT
.name
SPIN_LOCK_INITIALIZER*/
#else #else
#define LOCKDEP_CHECK_IN(lock) #define LOCKDEP_CHECK_IN(lock)
#define LOCKDEP_RECORD(lock) #define LOCKDEP_RECORD(lock)
@ -72,7 +78,8 @@ extern "C" {
.rawLock = 0U, \ .rawLock = 0U, \
} }
#endif #endif
/*
LOCKDEP_CHECK_INLOCKDEP_RECORDLOCKDEP_CHECK_OUTLOCKDEP_CLEAR_LOCKS*/
/** /**
* @ingroup los_spinlock * @ingroup los_spinlock
* <ul> * <ul>
@ -87,8 +94,8 @@ extern "C" {
* obtained. For time-consuming operation, the mutex lock can be used instead of spinlock.</li> * obtained. For time-consuming operation, the mutex lock can be used instead of spinlock.</li>
* </ul> * </ul>
*/ */
#define SPIN_LOCK_INIT(lock) SPIN_LOCK_S lock = SPIN_LOCK_INITIALIZER(lock) #define SPIN_LOCK_INIT(lock) SPIN_LOCK_S lock = SPIN_LOCK_INITIALIZER(lock)/*这段代码定义了一个宏SPIN_LOCK_INIT用于将输入参数lock定义为自旋锁并静态地初始化自旋锁*/
/*该宏主要用于定义和初始化自旋锁,用于保护对共享资源的短时间访问。在使用自旋锁时,需要注意避免使用在耗时较长的操作上,以免影响整体系统性能*/
/** /**
* @ingroup los_spinlock * @ingroup los_spinlock
* Define the structure of spinlock. * Define the structure of spinlock.
@ -104,8 +111,13 @@ struct Spinlock {
const CHAR *name; /**< the lock owner's task name. It is defined only when const CHAR *name; /**< the lock owner's task name. It is defined only when
LOSCFG_KERNEL_SMP_LOCKDEP is defined. */ LOSCFG_KERNEL_SMP_LOCKDEP is defined. */
#endif #endif
}; };/*这段代码定义了一个名为Spinlock的结构体用于表示自旋锁的结构*/
/*结构体Spinlock包括以下成员变量
rawLocksize_t
cpuidCPUUINT32LOSCFG_KERNEL_SMP_LOCKDEP
ownerVOID*LOSCFG_KERNEL_SMP_LOCKDEP
nameconst CHAR*LOSCFG_KERNEL_SMP_LOCKDEP*/
#ifdef LOSCFG_KERNEL_SMP #ifdef LOSCFG_KERNEL_SMP
/** /**
* @ingroup los_spinlock * @ingroup los_spinlock
@ -146,7 +158,14 @@ LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_SpinLock(SPIN_LOCK_S *lock)
LOCKDEP_CHECK_IN(lock); LOCKDEP_CHECK_IN(lock);
ArchSpinLock(&lock->rawLock); ArchSpinLock(&lock->rawLock);
LOCKDEP_RECORD(lock); LOCKDEP_RECORD(lock);
} }/*这段代码实现了自旋锁的加锁操作函数名称为LOS_SpinLock。它接收一个类型为SPIN_LOCK_S*的指针参数lock表示要加锁的自旋锁。*/
/*在函数内部首先调用LOS_TaskLock函数禁用调度器以确保当前任务不会被切换出去。然后调用LOCKDEP_CHECK_IN宏和LOCKDEP_RECORD宏用于记录锁依赖关系
ArchSpinLock
LOSCFG_KERNEL_SMP_LOCKDEPLOS_SpinLockLOS_LockdepCpuTryInit
使
线线线
SMP*/
/** /**
* @ingroup los_spinlock * @ingroup los_spinlock
@ -185,7 +204,11 @@ LITE_OS_SEC_ALW_INLINE STATIC INLINE INT32 LOS_SpinTrylock(SPIN_LOCK_S *lock)
} }
return ret; return ret;
} }/*这段代码实现了自旋锁的尝试加锁操作函数名称为LOS_SpinTrylock。它接收一个类型为SPIN_LOCK_S*的指针参数lock表示要尝试加锁的自旋锁*/
/*首先调用LOS_TaskLock函数禁用调度器以确保当前任务不会被切换出去。然后调用LOCKDEP_CHECK_IN宏用于记录锁依赖关系并最终调用ArchSpinTrylock函数尝试对自旋
ArchSpinTrylockLOS_OKLOCKDEP_RECORDLOS_OK线
ArchSpinTrylockLOS_NOK*/
/** /**
* @ingroup los_spinlock * @ingroup los_spinlock
@ -215,7 +238,10 @@ LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_SpinUnlock(SPIN_LOCK_S *lock)
/* restore the scheduler flag */ /* restore the scheduler flag */
LOS_TaskUnlock(); LOS_TaskUnlock();
} }/*这段代码实现了自旋锁的解锁操作函数名称为LOS_SpinUnlock。它接收一个类型为SPIN_LOCK_S*的指针参数lock表示要解锁的自旋锁。*/
/*在函数内部首先调用LOCKDEP_CHECK_OUT宏用于检查并记录锁依赖关系并最终调用ArchSpinUnlock函数对自旋锁进行解锁操作。
LOS_TaskUnlock*/
/** /**
* @ingroup los_spinlock * @ingroup los_spinlock
@ -249,8 +275,11 @@ LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_SpinLockSave(SPIN_LOCK_S *lock, UI
{ {
*intSave = LOS_IntLock(); *intSave = LOS_IntLock();
LOS_SpinLock(lock); LOS_SpinLock(lock);
} }/*这段代码实现了自旋锁的带保存中断状态的加锁操作函数名称为LOS_SpinLockSave。它接收一个类型为SPIN_LOCK_S*的指针参数lock
UINT32*intSave*/
/*在函数内部首先调用LOS_IntLock函数禁用所有中断并将禁用前的中断状态保存到intSave指向的地址中。然后调用LOS_SpinLock函数对自旋锁进行加锁操作。
*/
/** /**
* @ingroup los_spinlock * @ingroup los_spinlock
* @brief Unlock the spinlock and restore the interrupt flag. * @brief Unlock the spinlock and restore the interrupt flag.
@ -279,8 +308,11 @@ LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_SpinUnlockRestore(SPIN_LOCK_S *loc
{ {
LOS_SpinUnlock(lock); LOS_SpinUnlock(lock);
LOS_IntRestore(intSave); LOS_IntRestore(intSave);
} }/*这段代码实现了自旋锁的解锁操作并恢复中断状态。函数名称为LOS_SpinUnlockRestore。它接收一个类型为SPIN_LOCK_S*的指针参数lock表示要解锁的自旋锁
UINT32intSave*/
/*在函数内部首先调用LOS_SpinUnlock函数对自旋锁进行解锁操作然后调用LOS_IntRestore函数恢复中断状态参数为之前保存的中断状态intSave。
LOS_SpinLockSaveintSaveLOS_SpinLockSave*/
/** /**
* @ingroup los_spinlock * @ingroup los_spinlock
* @brief Check if holding the spinlock. * @brief Check if holding the spinlock.
@ -305,8 +337,9 @@ LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_SpinUnlockRestore(SPIN_LOCK_S *loc
LITE_OS_SEC_ALW_INLINE STATIC INLINE BOOL LOS_SpinHeld(const SPIN_LOCK_S *lock) LITE_OS_SEC_ALW_INLINE STATIC INLINE BOOL LOS_SpinHeld(const SPIN_LOCK_S *lock)
{ {
return (lock->rawLock != 0); return (lock->rawLock != 0);
} }/*这段代码实现了检查自旋锁是否被持有的功能。函数名称为LOS_SpinHeld。它接收一个类型为SPIN_LOCK_S*的指针参数lock表示要检查的自旋锁*/
/*在函数内部通过判断自旋锁的rawLock成员变量是否为0来确定自旋锁是否被持有。如果rawLock不为0则表示自旋锁被持有返回TRUE否则表示自旋锁未被持有返回FALSE*/
/** /**
* @ingroup los_spinlock * @ingroup los_spinlock
* @brief Spinlock dynamic initialization. * @brief Spinlock dynamic initialization.
@ -339,8 +372,13 @@ LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_SpinInit(SPIN_LOCK_S *lock)
lock->owner = SPINLOCK_OWNER_INIT; lock->owner = SPINLOCK_OWNER_INIT;
lock->name = "spinlock"; lock->name = "spinlock";
#endif #endif
} }/*这段代码是用于动态初始化自旋锁的函数LOS_SpinInit。*/
/*函数接受一个类型为SPIN_LOCK_S*的指针参数lock表示需要初始化的自旋锁。
rawLock0LOSCFG_KERNEL_SMP_LOCKDEP
LOSCFG_KERNEL_SMP_LOCKDEPcpuid-1CPUowner
SPINLOCK_OWNER_INITname"spinlock"
LOSCFG_KERNEL_SMP_LOCKDEP*/
#else #else
/* /*
@ -385,7 +423,15 @@ LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_SpinInit(SPIN_LOCK_S *lock)
{ {
(VOID)lock; (VOID)lock;
} }
/*上述代码中,是对于非多处理器系统的处理。这些函数并不实际处理自旋锁,而是为了统一代码的编写,以方便驱动程序、供应商等进行开发。
LOS_SpinLock
LOS_SpinTrylockLOS_OK
LOS_SpinUnlock
LOS_SpinLockSaveintSave
LOS_SpinUnlockRestore使intSave
LOS_SpinHeldTRUE
LOS_SpinInit*/
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus

@ -25,7 +25,7 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --------------------------------------------------------------------------- */ * --------------------------------------------------------------------------- */
/*这段代码是关于软件定时器的管理接口,主要包括软件定时器的创建、启动、停止、删除等操作。这段代码提供了一套完整的软件定时器管理接口,方便开发人员在嵌入式系统中实现基于时间的任务调度和处理。*/
/** /**
* @defgroup los_swtmr Software timer * @defgroup los_swtmr Software timer
* @ingroup kernel * @ingroup kernel
@ -51,15 +51,15 @@ extern "C" {
* *
* Solution: Define the timeout handling function. * Solution: Define the timeout handling function.
*/ */
#define LOS_ERRNO_SWTMR_PTR_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x00) #define LOS_ERRNO_SWTMR_PTR_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x00)/**/
/*错误代码LOS_ERRNO_SWTMR_PTR_NULL表示软件定时器的超时处理函数为空。这意味着当定时器到期时没有要执行的函数*/
/** /**
* @ingroup los_swtmr * @ingroup los_swtmr
* Software timer error code: The expiration time is 0. * Software timer error code: The expiration time is 0.
* *
* Value: 0x02000301. * Value: 0x02000301.
* *
* Solution: Re-define the expiration time. * Solution: Re-define the expiration time./*要解决此错误,您需要为软件定时器定义一个超时处理函数。该函数将在定时器到期时被调用,并执行所需的操作。
*/ */
#define LOS_ERRNO_SWTMR_INTERVAL_NOT_SUITED LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x01) #define LOS_ERRNO_SWTMR_INTERVAL_NOT_SUITED LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x01)
@ -69,17 +69,17 @@ extern "C" {
* *
* Value: 0x02000302. * Value: 0x02000302.
* *
* Solution: Check the mode value. The value range is [0,3]. * Solution: Check the mode value. The value range is [0,3]./*要解决此错误您需要重新定义定时器的到期时间。确保到期时间大于0并且与您的需求相符。
*/ */
#define LOS_ERRNO_SWTMR_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x02) #define LOS_ERRNO_SWTMR_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x02)
/*错误代码LOS_ERRNO_SWTMR_INTERVAL_NOT_SUITED表示定时器的到期时间为0。这意味着定时器的到期时间设置不合适*/
/** /**
* @ingroup los_swtmr * @ingroup los_swtmr
* Software timer error code: The passed-in software timer ID is NULL. * Software timer error code: The passed-in software timer ID is NULL.
* *
* Value: 0x02000303. * Value: 0x02000303.
* *
* Solution: Define the software timer ID before passing it in. * Solution: Define the software timer ID before passing it in.IDID使ID
*/ */
#define LOS_ERRNO_SWTMR_RET_PTR_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x03) #define LOS_ERRNO_SWTMR_RET_PTR_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x03)
@ -90,20 +90,20 @@ extern "C" {
* Value: 0x02000304. * Value: 0x02000304.
* *
* Solution: Re-configure the permitted maximum number of software timers, or wait for a software timer to become * Solution: Re-configure the permitted maximum number of software timers, or wait for a software timer to become
* available. * available.
*/ */
#define LOS_ERRNO_SWTMR_MAXSIZE LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x04) #define LOS_ERRNO_SWTMR_MAXSIZE LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x04)/
/*错误代码LOS_ERRNO_SWTMR_MAXSIZE表示软件定时器的数量超过了配置的允许最大数量。*/
/** /**
* @ingroup los_swtmr * @ingroup los_swtmr
* Software timer error code: Invalid software timer ID. * Software timer error code: Invalid software timer ID.
* *
* Value: 0x02000305. * Value: 0x02000305.
* *
* Solution: Pass in a valid software timer ID. * Solution: Pass in a valid software timer ID.ID
*/ */
#define LOS_ERRNO_SWTMR_ID_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x05) #define LOS_ERRNO_SWTMR_ID_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x05)
/*错误代码LOS_ERRNO_SWTMR_ID_INVALID表示软件计时器ID无效。*/
/** /**
* @ingroup los_swtmr * @ingroup los_swtmr
* Software timer error code: The software timer is not created. * Software timer error code: The software timer is not created.
@ -113,7 +113,7 @@ extern "C" {
* Solution: Create a software timer. * Solution: Create a software timer.
*/ */
#define LOS_ERRNO_SWTMR_NOT_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x06) #define LOS_ERRNO_SWTMR_NOT_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x06)
/*错误代码LOS_ERRNO_SWTMR_NOT_CREATED表示软件计时器未创建*/
/** /**
* @ingroup los_swtmr * @ingroup los_swtmr
* Software timer error code: Insufficient memory for software timer linked list creation. * Software timer error code: Insufficient memory for software timer linked list creation.
@ -121,20 +121,21 @@ extern "C" {
* Value: 0x02000307. * Value: 0x02000307.
* *
* Solution: Allocate bigger memory partition to software timer linked list creation. * Solution: Allocate bigger memory partition to software timer linked list creation.
*
*/ */
#define LOS_ERRNO_SWTMR_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x07) #define LOS_ERRNO_SWTMR_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x07)
/*错误代码LOS_ERRNO_SWTMR_NO_MEMORY内存不足无法创建软件计时器链表*/
/** /**
* @ingroup los_swtmr * @ingroup los_swtmr
* Software timer error code: Invalid configured number of software timers. * Software timer error code: Invalid configured number of software timers.
* *
* Value: 0x02000308. * Value: 0x02000308.
* *
* Solution: Re-configure the number of software timers. * Solution: Re-configure the number of software timers.
* @deprecated This error code is obsolete since LiteOS 5.0.0. * @deprecated This error code is obsolete since LiteOS 5.0.0.
*/ */
#define LOS_ERRNO_SWTMR_MAXSIZE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x08) #define LOS_ERRNO_SWTMR_MAXSIZE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x08)
/*软件计时器错误代码:配置的软件计时器数量无效*/
/** /**
* @ingroup los_swtmr * @ingroup los_swtmr
* Software timer error code: The software timer is being used during an interrupt. * Software timer error code: The software timer is being used during an interrupt.
@ -142,60 +143,61 @@ extern "C" {
* Value: 0x02000309. * Value: 0x02000309.
* *
* Solution: Change the source code and do not use the software timer during an interrupt. * Solution: Change the source code and do not use the software timer during an interrupt.
* 使
*/ */
#define LOS_ERRNO_SWTMR_HWI_ACTIVE LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x09) #define LOS_ERRNO_SWTMR_HWI_ACTIVE LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x09)
/*软件计时器错误代码:软件计时器在中断期间使用*/
/** /**
* @ingroup los_swtmr * @ingroup los_swtmr
* Software timer error code: Insufficient memory allocated by membox. * Software timer error code: Insufficient memory allocated by membox.
* *
* Value: 0x0200030a. * Value: 0x0200030a.
* *
* Solution: Expand the memory allocated by membox. * Solution: Expand the memory allocated by membox.membox
* @deprecated This error code is obsolete since LiteOS 5.0.0. * @deprecated This error code is obsolete since LiteOS 5.0.0.
*/ */
#define LOS_ERRNO_SWTMR_HANDLER_POOL_NO_MEM LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x0a) #define LOS_ERRNO_SWTMR_HANDLER_POOL_NO_MEM LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x0a)
/*软件计时器错误代码membox分配的内存不足*/
/** /**
* @ingroup los_swtmr * @ingroup los_swtmr
* Software timer error code: The software timer queue fails to be created. * Software timer error code: The software timer queue fails to be created.
* *
* Value: 0x0200030b. * Value: 0x0200030b.
* *
* Solution: Check whether more memory can be allocated to the queue to be created. * Solution: Check whether more memory can be allocated to the queue to be created.
*/ */
#define LOS_ERRNO_SWTMR_QUEUE_CREATE_FAILED LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x0b) #define LOS_ERRNO_SWTMR_QUEUE_CREATE_FAILED LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x0b)
/*软件计时器错误代码:无法创建软件计时器队列。*/
/** /**
* @ingroup los_swtmr * @ingroup los_swtmr
* Software timer error code: The software timer task fails to be created. * Software timer error code: The software timer task fails to be created.
* *
* Value: 0x0200030c. * Value: 0x0200030c.
* *
* Solution: Check whether the memory is sufficient and re-create the task. * Solution: Check whether the memory is sufficient and re-create the task.
*/ */
#define LOS_ERRNO_SWTMR_TASK_CREATE_FAILED LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x0c) #define LOS_ERRNO_SWTMR_TASK_CREATE_FAILED LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x0c)
/*软件计时器错误代码:无法创建软件计时器任务。*/
/** /**
* @ingroup los_swtmr * @ingroup los_swtmr
* Software timer error code: The software timer is not started. * Software timer error code: The software timer is not started.
* *
* Value: 0x0200030d. * Value: 0x0200030d.
* *
* Solution: Start the software timer. * Solution: Start the software timer.
*/ */
#define LOS_ERRNO_SWTMR_NOT_STARTED LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x0d) #define LOS_ERRNO_SWTMR_NOT_STARTED LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x0d)
/*软件计时器错误代码:软件计时器未启动*/
/** /**
* @ingroup los_swtmr * @ingroup los_swtmr
* Software timer error code: Invalid software timer state. * Software timer error code: Invalid software timer state.
* *
* Value: 0x0200030e. * Value: 0x0200030e.
* *
* Solution: Check the software timer state. * Solution: Check the software timer state.
*/ */
#define LOS_ERRNO_SWTMR_STATUS_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x0e) #define LOS_ERRNO_SWTMR_STATUS_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x0e)
/*软件计时器错误代码:软件计时器状态无效*/
/** /**
* @ingroup los_swtmr * @ingroup los_swtmr
* Software timer error code: This error code is not in use temporarily. * Software timer error code: This error code is not in use temporarily.
@ -204,7 +206,7 @@ extern "C" {
* @deprecated This error code is obsolete since LiteOS 5.0.0. * @deprecated This error code is obsolete since LiteOS 5.0.0.
*/ */
#define LOS_ERRNO_SWTMR_SORTLIST_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x0f) #define LOS_ERRNO_SWTMR_SORTLIST_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x0f)
/*软件计时器错误代码:此错误代码暂时未使用*/
/** /**
* @ingroup los_swtmr * @ingroup los_swtmr
* Software timer error code: The passed-in number of remaining Ticks configured on the software timer is NULL. * Software timer error code: The passed-in number of remaining Ticks configured on the software timer is NULL.
@ -214,7 +216,7 @@ extern "C" {
* Solution: Define a variable of the number of remaining Ticks before passing in the number of remaining Ticks. * Solution: Define a variable of the number of remaining Ticks before passing in the number of remaining Ticks.
*/ */
#define LOS_ERRNO_SWTMR_TICK_PTR_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x10) #define LOS_ERRNO_SWTMR_TICK_PTR_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x10)
/*软件计时器错误代码软件计时器上配置的传入的剩余Tick数为NULL*/
/** /**
* @ingroup los_swtmr * @ingroup los_swtmr
* Software timer error code: The software sortlink fails to be created. * Software timer error code: The software sortlink fails to be created.
@ -224,7 +226,7 @@ extern "C" {
* Solution: Check whether the memory is sufficient and re-create the sortlink. * Solution: Check whether the memory is sufficient and re-create the sortlink.
*/ */
#define LOS_ERRNO_SWTMR_SORTLINK_CREATE_FAILED LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x11) #define LOS_ERRNO_SWTMR_SORTLINK_CREATE_FAILED LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x11)
/*软件计时器错误代码:无法创建软件排序链接。*/
/** /**
* @ingroup los_swtmr * @ingroup los_swtmr
* Software timer mode * Software timer mode
@ -237,7 +239,11 @@ enum enSwTmrType {
periodic software timer is enabled. The value periodic software timer is enabled. The value
is 3. This mode is not supported temporarily. */ is 3. This mode is not supported temporarily. */
}; };
/*这段代码定义了软件定时器的模式使用了一个枚举类型enSwTmrType来表示。其中包含以下几种模式
LOS_SWTMR_MODE_ONCE0
LOS_SWTMR_MODE_PERIOD1
LOS_SWTMR_MODE_NO_SELFDELETE2
LOS_SWTMR_MODE_OPP3*/
/** /**
* @ingroup los_swtmr * @ingroup los_swtmr
* @brief Define the type of a callback function that handles software timer timeout. * @brief Define the type of a callback function that handles software timer timeout.
@ -257,7 +263,7 @@ enum enSwTmrType {
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
typedef VOID (*SWTMR_PROC_FUNC)(UINTPTR arg); typedef VOID (*SWTMR_PROC_FUNC)(UINTPTR arg);
/*这段代码定义了一个回调函数类型SWTMR_PROC_FUNC用于处理软件定时器超时事件。该回调函数在软件定时器超时时被调用*/
/** /**
* @ingroup los_swtmr * @ingroup los_swtmr
* @brief Start a software timer. * @brief Start a software timer.
@ -280,6 +286,12 @@ typedef VOID (*SWTMR_PROC_FUNC)(UINTPTR arg);
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern UINT32 LOS_SwtmrStart(UINT16 swtmrId); extern UINT32 LOS_SwtmrStart(UINT16 swtmrId);
/*这段代码是一个软件定时器模块中的函数LOS_SwtmrStart的声明。它用于启动一个指定ID的软件定时器。
LOS_ERRNO_SWTMR_ID_INVALIDID
LOS_ERRNO_SWTMR_NOT_CREATED
LOS_ERRNO_SWTMR_STATUS_INVALID
LOS_OK*/
/** /**
* @ingroup los_swtmr * @ingroup los_swtmr
@ -304,7 +316,13 @@ extern UINT32 LOS_SwtmrStart(UINT16 swtmrId);
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern UINT32 LOS_SwtmrStop(UINT16 swtmrId); extern UINT32 LOS_SwtmrStop(UINT16 swtmrId);
/*这段代码是一个软件定时器模块中的函数LOS_SwtmrStop的声明。它用于停止一个指定ID的软件定时器
LOS_ERRNO_SWTMR_ID_INVALIDID
LOS_ERRNO_SWTMR_NOT_CREATED
LOS_ERRNO_SWTMR_NOT_STARTED
LOS_ERRNO_SWTMR_STATUS_INVALID
LOS_OK*/
/** /**
* @ingroup los_swtmr * @ingroup los_swtmr
* @brief Obtain the number of remaining Ticks configured on a software timer. * @brief Obtain the number of remaining Ticks configured on a software timer.
@ -331,7 +349,14 @@ extern UINT32 LOS_SwtmrStop(UINT16 swtmrId);
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern UINT32 LOS_SwtmrTimeGet(UINT16 swtmrId, UINT32 *tick); extern UINT32 LOS_SwtmrTimeGet(UINT16 swtmrId, UINT32 *tick);
/*这段代码是一个软件定时器模块中的函数LOS_SwtmrTimeGet的声明。它用于获取指定ID的软件定时器配置的剩余Ticks数
LOS_ERRNO_SWTMR_ID_INVALIDID
LOS_ERRNO_SWTMR_TICK_PTR_NULLtickNULL
LOS_ERRNO_SWTMR_NOT_CREATED
LOS_ERRNO_SWTMR_NOT_STARTED
LOS_ERRNO_SWTMR_STATUS_INVALID
LOS_OKTicks*/
/** /**
* @ingroup los_swtmr * @ingroup los_swtmr
* @brief Create a software timer. * @brief Create a software timer.
@ -367,7 +392,14 @@ extern UINT32 LOS_SwtmrTimeGet(UINT16 swtmrId, UINT32 *tick);
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern UINT32 LOS_SwtmrCreate(UINT32 interval, UINT8 mode, SWTMR_PROC_FUNC handler, UINT16 *swtmrId, UINTPTR arg); extern UINT32 LOS_SwtmrCreate(UINT32 interval, UINT8 mode, SWTMR_PROC_FUNC handler, UINT16 *swtmrId, UINTPTR arg);
/*这段代码是一个软件定时器模块中的函数LOS_SwtmrCreate的声明。它用于创建一个具有指定定时时长、超时处理函数和触发模式的软件定时器并返回一个引用该软件定时器的句柄
LOS_ERRNO_SWTMR_INTERVAL_NOT_SUITED0
LOS_ERRNO_SWTMR_MODE_INVALID
LOS_ERRNO_SWTMR_PTR_NULLNULL
LOS_ERRNO_SWTMR_RET_PTR_NULLIDNULL
LOS_ERRNO_SWTMR_MAXSIZE
LOS_OK*/
/** /**
* @ingroup los_swtmr * @ingroup los_swtmr
* @brief Delete a software timer. * @brief Delete a software timer.
@ -390,7 +422,12 @@ extern UINT32 LOS_SwtmrCreate(UINT32 interval, UINT8 mode, SWTMR_PROC_FUNC handl
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern UINT32 LOS_SwtmrDelete(UINT16 swtmrId); extern UINT32 LOS_SwtmrDelete(UINT16 swtmrId);
/*这段代码是一个软件定时器模块中的函数LOS_SwtmrDelete的声明。它用于删除一个软件定时器。
LOS_ERRNO_SWTMR_ID_INVALIDID
LOS_ERRNO_SWTMR_NOT_CREATED
LOS_ERRNO_SWTMR_STATUS_INVALID
LOS_OK*/
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
} }

@ -25,7 +25,7 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --------------------------------------------------------------------------- */ * --------------------------------------------------------------------------- */
/*这个头文件提供了系统时间模块的接口和基本定义,为系统时间的管理提供了必要的支持*/
/** /**
* @defgroup los_sys System time * @defgroup los_sys System time
* @ingroup kernel * @ingroup kernel

@ -25,7 +25,8 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --------------------------------------------------------------------------- */ * --------------------------------------------------------------------------- */
/*以上代码是LiteOS系统中定义表格的头文件其中定义了一些宏用于在汇编代码中生成指定名称和标签的全局符号用于在LiteOS系统中实现一些底层硬件操作。
section*/
#ifndef _LOS_TABLES_H #ifndef _LOS_TABLES_H
#define _LOS_TABLES_H #define _LOS_TABLES_H
@ -47,7 +48,7 @@ extern "C" {
".previous\n" \ ".previous\n" \
) )
#endif #endif
/*这段代码定义了一个宏LOS_HAL_TABLE_WOW_BEGIN用于在汇编代码中声明一个LiteOS的表格开始位置。该宏使用了一些特定的汇编指令和标签定义*/
#ifndef LOS_HAL_TABLE_WOW_END #ifndef LOS_HAL_TABLE_WOW_END
#define LOS_HAL_TABLE_WOW_END(label, name) \ #define LOS_HAL_TABLE_WOW_END(label, name) \
__asm__(".section \".liteos.table." X_STRING(name) ".wow.finish\",\"aw\"\n" \ __asm__(".section \".liteos.table." X_STRING(name) ".wow.finish\",\"aw\"\n" \
@ -58,7 +59,7 @@ extern "C" {
".previous\n" \ ".previous\n" \
) )
#endif #endif
/*。该代码定义了一个名为LOS_HAL_TABLE_WOW_END的宏该宏的作用是在汇编代码中生成一个指定名称和标签的全局符号用于在LiteOS系统中实现一些底层硬件操作。*/
#ifndef LOS_HAL_TABLE_SCATTER_BEGIN #ifndef LOS_HAL_TABLE_SCATTER_BEGIN
#define LOS_HAL_TABLE_SCATTER_BEGIN(label, name) \ #define LOS_HAL_TABLE_SCATTER_BEGIN(label, name) \
__asm__(".section \".liteos.table." X_STRING(name) ".scatter.begin\",\"aw\"\n" \ __asm__(".section \".liteos.table." X_STRING(name) ".scatter.begin\",\"aw\"\n" \
@ -69,7 +70,7 @@ extern "C" {
".previous\n" \ ".previous\n" \
) )
#endif #endif
/*这是另一段C预处理器宏定义代码。该代码定义了一个名为LOS_HAL_TABLE_SCATTER_BEGIN的宏该宏的作用是在汇编代码中生成一个指定名称和标签的全局符号用于在LiteOS系统中实现一些底层硬件操作。*/
#ifndef LOS_HAL_TABLE_SCATTER_END #ifndef LOS_HAL_TABLE_SCATTER_END
#define LOS_HAL_TABLE_SCATTER_END(label, name) \ #define LOS_HAL_TABLE_SCATTER_END(label, name) \
__asm__(".section \".liteos.table." X_STRING(name) ".scatter.finish\",\"aw\"\n" \ __asm__(".section \".liteos.table." X_STRING(name) ".scatter.finish\",\"aw\"\n" \
@ -80,7 +81,7 @@ extern "C" {
".previous\n" \ ".previous\n" \
) )
#endif #endif
/*该代码定义了一个名为LOS_HAL_TABLE_SCATTER_END的宏用于在LiteOS系统中生成汇编代码中的全局符号*/
#ifndef LOS_HAL_TABLE_BEGIN #ifndef LOS_HAL_TABLE_BEGIN
#define LOS_HAL_TABLE_BEGIN(label, name) \ #define LOS_HAL_TABLE_BEGIN(label, name) \
__asm__(".section \".liteos.table." X_STRING(name) ".begin\",\"aw\"\n" \ __asm__(".section \".liteos.table." X_STRING(name) ".begin\",\"aw\"\n" \
@ -91,7 +92,7 @@ extern "C" {
".previous\n" \ ".previous\n" \
) )
#endif #endif
/*该代码定义了一个名为LOS_HAL_TABLE_BEGIN的宏该宏的作用是在汇编代码中生成一个指定名称和标签的全局符号用于在LiteOS系统中实现一些底层硬件操作。*/
#ifndef LOS_HAL_TABLE_END #ifndef LOS_HAL_TABLE_END
#define LOS_HAL_TABLE_END(label, name) \ #define LOS_HAL_TABLE_END(label, name) \
__asm__(".section \".liteos.table." X_STRING(name) ".finish\",\"aw\"\n" \ __asm__(".section \".liteos.table." X_STRING(name) ".finish\",\"aw\"\n" \
@ -102,41 +103,41 @@ extern "C" {
".previous\n" \ ".previous\n" \
) )
#endif #endif
/*该代码定义了一个名为LOS_HAL_TABLE_END的宏用于在LiteOS系统中生成汇编代码中的全局符号*/
/* This macro must be applied to any types whose objects are to be placed in tables */ /* This macro must be applied to any types whose objects are to be placed in tables */
#ifndef LOS_HAL_TABLE_TYPE #ifndef LOS_HAL_TABLE_TYPE
#define LOS_HAL_TABLE_TYPE LOSBLD_ATTRIB_ALIGN(LOSARC_ALIGNMENT) #define LOS_HAL_TABLE_TYPE LOSBLD_ATTRIB_ALIGN(LOSARC_ALIGNMENT)
#endif #endif
/*通过这个宏的定义,可以在代码中统一设置表的类型或属性,使得系统中使用的表在对齐等方面具有统一的特性*/
#ifndef LOS_HAL_TABLE_EXTRA #ifndef LOS_HAL_TABLE_EXTRA
#define LOS_HAL_TABLE_EXTRA(name) \ #define LOS_HAL_TABLE_EXTRA(name) \
LOSBLD_ATTRIB_SECTION(".liteos.table." X_STRING(name) ".extra") LOSBLD_ATTRIB_SECTION(".liteos.table." X_STRING(name) ".extra")
#endif #endif
/*该代码定义了一个名为LOS_HAL_TABLE_EXTRA的宏用于在LiteOS系统中生成汇编代码中的节section名称*/
#ifndef LOS_HAL_TABLE_WOW_ENTRY #ifndef LOS_HAL_TABLE_WOW_ENTRY
#define LOS_HAL_TABLE_WOW_ENTRY(name) \ #define LOS_HAL_TABLE_WOW_ENTRY(name) \
LOSBLD_ATTRIB_SECTION(".liteos.table." X_STRING(name) ".wow.data") \ LOSBLD_ATTRIB_SECTION(".liteos.table." X_STRING(name) ".wow.data") \
LOSBLD_ATTRIB_USED LOSBLD_ATTRIB_USED
#endif #endif
/*这段代码定义了一个名为LOS_HAL_TABLE_WOW_ENTRY的宏用于在LiteOS系统中生成汇编代码中的节section名称并将该符号标记为被使用。*/
#ifndef LOS_HAL_TABLE_SCATTER_ENTRY #ifndef LOS_HAL_TABLE_SCATTER_ENTRY
#define LOS_HAL_TABLE_SCATTER_ENTRY(name) \ #define LOS_HAL_TABLE_SCATTER_ENTRY(name) \
LOSBLD_ATTRIB_SECTION(".liteos.table." X_STRING(name) ".scatter.data") \ LOSBLD_ATTRIB_SECTION(".liteos.table." X_STRING(name) ".scatter.data") \
LOSBLD_ATTRIB_USED LOSBLD_ATTRIB_USED
#endif #endif
/*这段代码定义了一个名为LOS_HAL_TABLE_SCATTER_ENTRY的宏用于在LiteOS系统中生成汇编代码中的节section名称并将该符号标记为被使用*/
#ifndef LOS_HAL_TABLE_ENTRY #ifndef LOS_HAL_TABLE_ENTRY
#define LOS_HAL_TABLE_ENTRY(name) \ #define LOS_HAL_TABLE_ENTRY(name) \
LOSBLD_ATTRIB_SECTION(".liteos.table." X_STRING(name) ".data") \ LOSBLD_ATTRIB_SECTION(".liteos.table." X_STRING(name) ".data") \
LOSBLD_ATTRIB_USED LOSBLD_ATTRIB_USED
#endif #endif
/*该宏的作用是定义一个通用的节section用于存储数据并确保相关符号被正确使用和链接到系统的可执行文件中*/
#ifndef LOS_HAL_TABLE_QUALIFIED_ENTRY #ifndef LOS_HAL_TABLE_QUALIFIED_ENTRY
#define LOS_HAL_TABLE_QUALIFIED_ENTRY(name, _qual) \ #define LOS_HAL_TABLE_QUALIFIED_ENTRY(name, _qual) \
LOSBLD_ATTRIB_SECTION(".liteos.table." X_STRING(name) ".data." X_STRING(_qual)) \ LOSBLD_ATTRIB_SECTION(".liteos.table." X_STRING(name) ".data." X_STRING(_qual)) \
LOSBLD_ATTRIB_USED LOSBLD_ATTRIB_USED
#endif #endif
/*该宏的作用是定义一个用于存储特定类型数据的节section并将相关符号标记为被使用以确保可执行文件中包含该数据*/
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
} }

@ -25,7 +25,7 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --------------------------------------------------------------------------- */ * --------------------------------------------------------------------------- */
/*该函数定义了一些任务错误情况以及一些关于任务处理的函数*/
/** /**
* @defgroup los_task Task * @defgroup los_task Task
* @ingroup kernel * @ingroup kernel
@ -58,7 +58,7 @@ extern "C" {
* automatically after the task is done. * automatically after the task is done.
*/ */
#define LOS_TASK_STATUS_DETACHED 0x0100U #define LOS_TASK_STATUS_DETACHED 0x0100U
/*LOS_TASK_STATUS_DETACHED是一个任务或者任务控制块状态的标志位。它表示任务处于自动删除状态。在这个状态下任务会在执行完毕后自动被删除*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: Insufficient memory for task creation. * Task error code: Insufficient memory for task creation.
@ -68,7 +68,7 @@ extern "C" {
* Solution: Allocate bigger memory partition to task creation. * Solution: Allocate bigger memory partition to task creation.
*/ */
#define LOS_ERRNO_TSK_NO_MEMORY LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x00) #define LOS_ERRNO_TSK_NO_MEMORY LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x00)
/*任务错误代码:内存不足,无法创建任务。*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: Null parameter. * Task error code: Null parameter.
@ -78,7 +78,7 @@ extern "C" {
* Solution: Check the parameter. * Solution: Check the parameter.
*/ */
#define LOS_ERRNO_TSK_PTR_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x01) #define LOS_ERRNO_TSK_PTR_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x01)
/*任务错误代码参数为Null*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: The task stack is not aligned. * Task error code: The task stack is not aligned.
@ -88,7 +88,7 @@ extern "C" {
* Solution: Align the task stack. * Solution: Align the task stack.
*/ */
#define LOS_ERRNO_TSK_STKSZ_NOT_ALIGN LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x02) #define LOS_ERRNO_TSK_STKSZ_NOT_ALIGN LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x02)
/*任务错误代码:任务堆栈未对齐*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: Incorrect task priority. * Task error code: Incorrect task priority.
@ -98,7 +98,7 @@ extern "C" {
* Solution: Re-configure the task priority by referring to the priority range. * Solution: Re-configure the task priority by referring to the priority range.
*/ */
#define LOS_ERRNO_TSK_PRIOR_ERROR LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x03) #define LOS_ERRNO_TSK_PRIOR_ERROR LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x03)
/*任务错误代码:任务优先级不正确*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: The task entrance is NULL. * Task error code: The task entrance is NULL.
@ -108,7 +108,7 @@ extern "C" {
* Solution: Define the task entrance function. * Solution: Define the task entrance function.
*/ */
#define LOS_ERRNO_TSK_ENTRY_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x04) #define LOS_ERRNO_TSK_ENTRY_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x04)
/*任务错误代码任务入口为NULL*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: The task name is NULL. * Task error code: The task name is NULL.
@ -118,7 +118,7 @@ extern "C" {
* Solution: Set the task name. * Solution: Set the task name.
*/ */
#define LOS_ERRNO_TSK_NAME_EMPTY LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x05) #define LOS_ERRNO_TSK_NAME_EMPTY LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x05)
/*任务错误代码任务名称为NULL*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: The task stack size is too small. * Task error code: The task stack size is too small.
@ -128,7 +128,7 @@ extern "C" {
* Solution: Expand the task stack. * Solution: Expand the task stack.
*/ */
#define LOS_ERRNO_TSK_STKSZ_TOO_SMALL LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x06) #define LOS_ERRNO_TSK_STKSZ_TOO_SMALL LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x06)
/*任务错误代码:任务堆栈太小*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: Invalid task ID. * Task error code: Invalid task ID.
@ -138,7 +138,7 @@ extern "C" {
* Solution: Check the task ID. * Solution: Check the task ID.
*/ */
#define LOS_ERRNO_TSK_ID_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x07) #define LOS_ERRNO_TSK_ID_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x07)
/*任务错误代码任务ID无效*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: The task is already suspended. * Task error code: The task is already suspended.
@ -148,7 +148,7 @@ extern "C" {
* Solution: Suspend the task after it is resumed. * Solution: Suspend the task after it is resumed.
*/ */
#define LOS_ERRNO_TSK_ALREADY_SUSPENDED LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x08) #define LOS_ERRNO_TSK_ALREADY_SUSPENDED LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x08)
/*任务错误代码:任务已挂起*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: The task is not suspended. * Task error code: The task is not suspended.
@ -158,7 +158,7 @@ extern "C" {
* Solution: Suspend the task. * Solution: Suspend the task.
*/ */
#define LOS_ERRNO_TSK_NOT_SUSPENDED LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x09) #define LOS_ERRNO_TSK_NOT_SUSPENDED LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x09)
/*任务错误代码:任务未挂起*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: The task is not created. * Task error code: The task is not created.
@ -168,7 +168,7 @@ extern "C" {
* Solution: Create the task. * Solution: Create the task.
*/ */
#define LOS_ERRNO_TSK_NOT_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x0a) #define LOS_ERRNO_TSK_NOT_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x0a)
/*任务错误代码:未创建任务*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: The task is locked when it is being deleted. * Task error code: The task is locked when it is being deleted.
@ -178,7 +178,7 @@ extern "C" {
* Solution: Unlock the task. * Solution: Unlock the task.
*/ */
#define LOS_ERRNO_TSK_DELETE_LOCKED LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x0b) #define LOS_ERRNO_TSK_DELETE_LOCKED LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x0b)
/*任务错误代码:删除任务时该任务被锁定*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: The task message is nonzero. * Task error code: The task message is nonzero.
@ -189,7 +189,7 @@ extern "C" {
* @deprecated This error code is obsolete since LiteOS 5.0.0. * @deprecated This error code is obsolete since LiteOS 5.0.0.
*/ */
#define LOS_ERRNO_TSK_MSG_NONZERO LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x0c) #define LOS_ERRNO_TSK_MSG_NONZERO LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x0c)
/*任务错误代码:任务消息为非零*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: The task delay occurs during an interrupt. * Task error code: The task delay occurs during an interrupt.
@ -199,7 +199,7 @@ extern "C" {
* Solution: Perform this operation after exiting from the interrupt. * Solution: Perform this operation after exiting from the interrupt.
*/ */
#define LOS_ERRNO_TSK_DELAY_IN_INT LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x0d) #define LOS_ERRNO_TSK_DELAY_IN_INT LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x0d)
/*任务错误代码:任务延迟发生在中断期间*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: The task delay occurs when the task is locked. * Task error code: The task delay occurs when the task is locked.
@ -209,7 +209,7 @@ extern "C" {
* Solution: Perform this operation after unlocking the task. * Solution: Perform this operation after unlocking the task.
*/ */
#define LOS_ERRNO_TSK_DELAY_IN_LOCK LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x0e) #define LOS_ERRNO_TSK_DELAY_IN_LOCK LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x0e)
/*任务错误代码:任务锁定时会出现任务延迟*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: The task yield occurs when the task is locked. * Task error code: The task yield occurs when the task is locked.
@ -219,7 +219,7 @@ extern "C" {
* Solution: Check the task. * Solution: Check the task.
*/ */
#define LOS_ERRNO_TSK_YIELD_IN_LOCK LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x0f) #define LOS_ERRNO_TSK_YIELD_IN_LOCK LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x0f)
/*任务错误代码:当任务被锁定时,任务将产生收益*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: Only one task or no task is available for scheduling. * Task error code: Only one task or no task is available for scheduling.
@ -229,7 +229,7 @@ extern "C" {
* Solution: Increase the number of tasks. * Solution: Increase the number of tasks.
*/ */
#define LOS_ERRNO_TSK_YIELD_NOT_ENOUGH_TASK LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x10) #define LOS_ERRNO_TSK_YIELD_NOT_ENOUGH_TASK LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x10)
/*任务错误代码:只有一个任务或没有任务可用于计划*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: No free task control block is available. * Task error code: No free task control block is available.
@ -239,7 +239,7 @@ extern "C" {
* Solution: Increase the number of task control blocks. * Solution: Increase the number of task control blocks.
*/ */
#define LOS_ERRNO_TSK_TCB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x11) #define LOS_ERRNO_TSK_TCB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x11)
/*任务错误代码:没有可用的任务控制块*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: The task hook function is not matchable. * Task error code: The task hook function is not matchable.
@ -250,7 +250,7 @@ extern "C" {
* @deprecated This error code is obsolete since LiteOS 5.0.0. * @deprecated This error code is obsolete since LiteOS 5.0.0.
*/ */
#define LOS_ERRNO_TSK_HOOK_NOT_MATCH LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x12) #define LOS_ERRNO_TSK_HOOK_NOT_MATCH LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x12)
/*任务错误代码:任务挂钩函数不匹配*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: The number of task hook functions exceeds the permitted upper limit. * Task error code: The number of task hook functions exceeds the permitted upper limit.
@ -261,7 +261,7 @@ extern "C" {
* @deprecated This error code is obsolete since LiteOS 5.0.0. * @deprecated This error code is obsolete since LiteOS 5.0.0.
*/ */
#define LOS_ERRNO_TSK_HOOK_IS_FULL LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x13) #define LOS_ERRNO_TSK_HOOK_IS_FULL LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x13)
/*任务错误代码:任务挂钩函数的数量超过了允许的上限*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: The operation is performed on the system-level task. * Task error code: The operation is performed on the system-level task.
@ -272,7 +272,8 @@ extern "C" {
* Solution: Check the task ID and do not operate the system-level task. * Solution: Check the task ID and do not operate the system-level task.
*/ */
#define LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x14) #define LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x14)
/*任务错误代码:该操作是在系统级任务上执行的。
*LOS_ERRNO_TSK_OPERATE_idle*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: The task that is being suspended is locked. * Task error code: The task that is being suspended is locked.
@ -282,7 +283,7 @@ extern "C" {
* Solution: Suspend the task after unlocking the task. * Solution: Suspend the task after unlocking the task.
*/ */
#define LOS_ERRNO_TSK_SUSPEND_LOCKED LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x15) #define LOS_ERRNO_TSK_SUSPEND_LOCKED LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x15)
/*任务错误代码:正在挂起的任务已锁定*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: The task stack fails to be freed. * Task error code: The task stack fails to be freed.
@ -293,7 +294,7 @@ extern "C" {
* @deprecated This error code is obsolete since LiteOS 5.0.0. * @deprecated This error code is obsolete since LiteOS 5.0.0.
*/ */
#define LOS_ERRNO_TSK_FREE_STACK_FAILED LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x17) #define LOS_ERRNO_TSK_FREE_STACK_FAILED LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x17)
/*任务错误代码:无法释放任务堆栈*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: The task stack area is too small. * Task error code: The task stack area is too small.
@ -304,7 +305,7 @@ extern "C" {
* @deprecated This error code is obsolete since LiteOS 5.0.0. * @deprecated This error code is obsolete since LiteOS 5.0.0.
*/ */
#define LOS_ERRNO_TSK_STKAREA_TOO_SMALL LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x18) #define LOS_ERRNO_TSK_STKAREA_TOO_SMALL LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x18)
/*任务错误代码:任务堆栈区域太小*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: The task fails to be activated. * Task error code: The task fails to be activated.
@ -315,7 +316,7 @@ extern "C" {
* @deprecated This error code is obsolete since LiteOS 5.0.0. * @deprecated This error code is obsolete since LiteOS 5.0.0.
*/ */
#define LOS_ERRNO_TSK_ACTIVE_FAILED LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x19) #define LOS_ERRNO_TSK_ACTIVE_FAILED LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x19)
/*任务错误代码:任务激活失败*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: Too many task configuration items. * Task error code: Too many task configuration items.
@ -326,7 +327,7 @@ extern "C" {
* @deprecated This error code is obsolete since LiteOS 5.0.0. * @deprecated This error code is obsolete since LiteOS 5.0.0.
*/ */
#define LOS_ERRNO_TSK_CONFIG_TOO_MANY LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x1a) #define LOS_ERRNO_TSK_CONFIG_TOO_MANY LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x1a)
/*任务错误代码:任务配置项过多*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: This error code is not in use temporarily. * Task error code: This error code is not in use temporarily.
@ -335,7 +336,7 @@ extern "C" {
* @deprecated This error code is obsolete since LiteOS 5.0.0. * @deprecated This error code is obsolete since LiteOS 5.0.0.
*/ */
#define LOS_ERRNO_TSK_CP_SAVE_AREA_NOT_ALIGN LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x1b) #define LOS_ERRNO_TSK_CP_SAVE_AREA_NOT_ALIGN LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x1b)
/*任务错误代码:此错误代码暂时未使用*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: This error code is not in use temporarily. * Task error code: This error code is not in use temporarily.
@ -344,7 +345,7 @@ extern "C" {
* @deprecated This error code is obsolete since LiteOS 5.0.0. * @deprecated This error code is obsolete since LiteOS 5.0.0.
*/ */
#define LOS_ERRNO_TSK_MSG_Q_TOO_MANY LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x1d) #define LOS_ERRNO_TSK_MSG_Q_TOO_MANY LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x1d)
/*任务错误代码:此错误代码暂时未使用*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: This error code is not in use temporarily. * Task error code: This error code is not in use temporarily.
@ -353,7 +354,7 @@ extern "C" {
* @deprecated This error code is obsolete since LiteOS 5.0.0. * @deprecated This error code is obsolete since LiteOS 5.0.0.
*/ */
#define LOS_ERRNO_TSK_CP_SAVE_AREA_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x1e) #define LOS_ERRNO_TSK_CP_SAVE_AREA_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x1e)
/*任务错误代码:此错误代码暂时未使用*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: This error code is not in use temporarily. * Task error code: This error code is not in use temporarily.
@ -362,7 +363,7 @@ extern "C" {
* @deprecated This error code is obsolete since LiteOS 5.0.0. * @deprecated This error code is obsolete since LiteOS 5.0.0.
*/ */
#define LOS_ERRNO_TSK_SELF_DELETE_ERR LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x1f) #define LOS_ERRNO_TSK_SELF_DELETE_ERR LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x1f)
/*任务错误代码:此错误代码暂时未使用*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: The task stack size is too large. * Task error code: The task stack size is too large.
@ -372,7 +373,7 @@ extern "C" {
* Solution: shrink the task stack size parameter. * Solution: shrink the task stack size parameter.
*/ */
#define LOS_ERRNO_TSK_STKSZ_TOO_LARGE LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x20) #define LOS_ERRNO_TSK_STKSZ_TOO_LARGE LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x20)
/*任务错误代码:任务堆栈大小太大*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: Suspending software timer task is not allowed. * Task error code: Suspending software timer task is not allowed.
@ -383,7 +384,7 @@ extern "C" {
* @deprecated This error code is obsolete since LiteOS 5.0.0. * @deprecated This error code is obsolete since LiteOS 5.0.0.
*/ */
#define LOS_ERRNO_TSK_SUSPEND_SWTMR_NOT_ALLOWED LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x21) #define LOS_ERRNO_TSK_SUSPEND_SWTMR_NOT_ALLOWED LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x21)
/*任务错误代码:不允许挂起软件计时器任务*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: The cpu affinity mask is incorrect. * Task error code: The cpu affinity mask is incorrect.
@ -393,7 +394,7 @@ extern "C" {
* Solution: Please set the correct cpu affinity mask. * Solution: Please set the correct cpu affinity mask.
*/ */
#define LOS_ERRNO_TSK_CPU_AFFINITY_MASK_ERR LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x23) #define LOS_ERRNO_TSK_CPU_AFFINITY_MASK_ERR LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x23)
/*任务错误代码cpu关联掩码不正确*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: Task yield in interrupt is not permited, which will result in an unexpected result. * Task error code: Task yield in interrupt is not permited, which will result in an unexpected result.
@ -403,7 +404,7 @@ extern "C" {
* Solution: Don't call LOS_TaskYield in Interrupt. * Solution: Don't call LOS_TaskYield in Interrupt.
*/ */
#define LOS_ERRNO_TSK_YIELD_IN_INT LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x24) #define LOS_ERRNO_TSK_YIELD_IN_INT LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x24)
/*任务错误代码:不允许任务在中断中让步,这将导致意外结果*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: Task sync resource (semaphore) allocated failed. * Task error code: Task sync resource (semaphore) allocated failed.
@ -413,7 +414,7 @@ extern "C" {
* Solution: Expand LOSCFG_BASE_IPC_SEM_LIMIT. * Solution: Expand LOSCFG_BASE_IPC_SEM_LIMIT.
*/ */
#define LOS_ERRNO_TSK_MP_SYNC_RESOURCE LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x25) #define LOS_ERRNO_TSK_MP_SYNC_RESOURCE LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x25)
/*任务错误代码:分配的任务同步资源(信号量)失败*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task error code: Task sync failed on operating running task across cores. * Task error code: Task sync failed on operating running task across cores.
@ -423,7 +424,7 @@ extern "C" {
* Solution: Check task delete can be handled in user's scenario. * Solution: Check task delete can be handled in user's scenario.
*/ */
#define LOS_ERRNO_TSK_MP_SYNC_FAILED LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x26) #define LOS_ERRNO_TSK_MP_SYNC_FAILED LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x26)
/*任务错误代码:在操作跨核心运行的任务时,任务同步失败*/
/** /**
* @ingroup los_task * @ingroup los_task
* Minimum stack size. * Minimum stack size.
@ -432,7 +433,8 @@ extern "C" {
* LOS_TASK_MIN_STACK_SIZE bytes, aligned on a boundary of LOSCFG_STACK_POINT_ALIGN_SIZE. * LOS_TASK_MIN_STACK_SIZE bytes, aligned on a boundary of LOSCFG_STACK_POINT_ALIGN_SIZE.
*/ */
#define LOS_TASK_MIN_STACK_SIZE (ALIGN(KERNEL_TSK_MIN_STACK_SIZE, LOSCFG_STACK_POINT_ALIGN_SIZE)) #define LOS_TASK_MIN_STACK_SIZE (ALIGN(KERNEL_TSK_MIN_STACK_SIZE, LOSCFG_STACK_POINT_ALIGN_SIZE))
/*这段代码是关于任务task的最小栈大小的定义通过这段代码可以看出LOS_TASK_MIN_STACK_SIZE的大小是根据KERNEL_TSK_MIN_STACK_SIZE和
LOSCFG_STACK_POINT_ALIGN_SIZE*/
#ifdef LOSCFG_BASE_CORE_TSK_MONITOR #ifdef LOSCFG_BASE_CORE_TSK_MONITOR
/** /**
* @ingroup los_task * @ingroup los_task
@ -494,6 +496,9 @@ typedef VOID *(*TSK_ENTRY_FUNC)(UINTPTR param1,
UINTPTR param4); UINTPTR param4);
#else #else
typedef VOID *(*TSK_ENTRY_FUNC)(VOID *param); typedef VOID *(*TSK_ENTRY_FUNC)(VOID *param);
/*这段代码中使用了条件预处理指令#ifdef它用于根据预定义的宏LOSOCFG_OBSOLETE_API是否存在来选择不同的类型定义,果LOSOCFG_OBSOLETE_API宏被定义
TSK_ENTRY_FUNCUINTPTRVOIDLOSOCFG_OBSOLETE_APITSK_ENTRY_FUNC
VOIDVOID*/
#endif #endif
/** /**
* @ingroup los_task * @ingroup los_task
@ -519,7 +524,14 @@ typedef struct tagTskInitParam {
UINT32 uwResved; /**< Task is automatically deleted if uwResved is set to #LOS_TASK_STATUS_DETACHED. UINT32 uwResved; /**< Task is automatically deleted if uwResved is set to #LOS_TASK_STATUS_DETACHED.
Task will not be deleted automatically if it is set to 0. */ Task will not be deleted automatically if it is set to 0. */
} TSK_INIT_PARAM_S; } TSK_INIT_PARAM_S;
/*这段代码定义了一个结构体类型TSK_INIT_PARAM_S用于传递任务创建时的参数信息
pfnTaskEntry
usTaskPrio
auwArgs/pArgsLOSCFG_OBSOLETE_API
uwStackSize
pcName
usCpuAffiMaskCPULOSCFG_KERNEL_SMP
uwResvedLOS_TASK_STATUS_DETACHED*/
/** /**
* @ingroup los_task * @ingroup los_task
* Task name length * Task name length
@ -551,7 +563,23 @@ typedef struct tagTskInfo {
BOOL bOvf; /**< Flag that indicates whether a task stack overflow BOOL bOvf; /**< Flag that indicates whether a task stack overflow
occurs or not */ occurs or not */
} TSK_INFO_S; } TSK_INFO_S;
/*这段代码定义了一个结构体类型TSK_INFO_S用于保存任务的信息
TSK_INFO_S
acNameLOS_TASK_NAMELEN32
uwTaskIDID
usTaskStatus
usTaskPrio
pTaskSem
pTaskMux
uwEvent
uwEventMask
uwStackSize
uwTopOfStack
uwBottomOfStack
uwSPSP
uwCurrUsed使
uwPeakUsed使
bOvf*/
#ifdef LOSCFG_TASK_STATIC_ALLOCATION #ifdef LOSCFG_TASK_STATIC_ALLOCATION
/** /**
* @ingroup los_task * @ingroup los_task
@ -601,7 +629,24 @@ typedef struct tagTskInfo {
* @since Huawei LiteOS V200R005C10 * @since Huawei LiteOS V200R005C10
*/ */
extern UINT32 LOS_TaskCreateOnlyStatic(UINT32 *taskId, TSK_INIT_PARAM_S *initParam, VOID *topStack); extern UINT32 LOS_TaskCreateOnlyStatic(UINT32 *taskId, TSK_INIT_PARAM_S *initParam, VOID *topStack);
/*该函数的作用是创建一个静态分配的任务,并将其挂起。静态分配任务的栈空间由用户自行分配和释放,需要在删除任务时及时释放栈空间。
taskId[OUT] IDUINT32
initParam[IN] TSK_INIT_PARAM_S
topStack[IN] VOID
LOS_ERRNO_TSK_ID_INVALIDIDtaskIdNULL
LOS_ERRNO_TSK_PTR_NULLinitParamNULL
LOS_ERRNO_TSK_NAME_EMPTYNULL
LOS_ERRNO_TSK_ENTRY_NULLNULL
LOS_ERRNO_TSK_PRIOR_ERROR
LOS_ERRNO_TSK_STKSZ_TOO_LARGE
LOS_ERRNO_TSK_STKSZ_TOO_SMALL
LOS_ERRNO_TSK_TCB_UNAVAILABLE
LOS_ERRNO_TSK_NO_MEMORY
LOS_OK*/
/** /**
* @ingroup los_task * @ingroup los_task
* @brief Create a task. * @brief Create a task.
@ -653,7 +698,9 @@ extern UINT32 LOS_TaskCreateOnlyStatic(UINT32 *taskId, TSK_INIT_PARAM_S *initPar
*/ */
extern UINT32 LOS_TaskCreateStatic(UINT32 *taskId, TSK_INIT_PARAM_S *initParam, VOID *topStack); extern UINT32 LOS_TaskCreateStatic(UINT32 *taskId, TSK_INIT_PARAM_S *initParam, VOID *topStack);
#endif #endif
/*这段代码是关于任务创建的函数LOS_TaskCreateStatic的声明。
.
ID*/
/** /**
* @ingroup los_task * @ingroup los_task
* @brief Create a task and suspend. * @brief Create a task and suspend.
@ -699,7 +746,9 @@ extern UINT32 LOS_TaskCreateStatic(UINT32 *taskId, TSK_INIT_PARAM_S *initParam,
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern UINT32 LOS_TaskCreateOnly(UINT32 *taskId, TSK_INIT_PARAM_S *initParam); extern UINT32 LOS_TaskCreateOnly(UINT32 *taskId, TSK_INIT_PARAM_S *initParam);
/*这段代码是关于任务创建的函数LOS_TaskCreateOnly的声明。
*/
/** /**
* @ingroup los_task * @ingroup los_task
* @brief Create a task. * @brief Create a task.
@ -745,7 +794,7 @@ extern UINT32 LOS_TaskCreateOnly(UINT32 *taskId, TSK_INIT_PARAM_S *initParam);
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern UINT32 LOS_TaskCreate(UINT32 *taskId, TSK_INIT_PARAM_S *initParam); extern UINT32 LOS_TaskCreate(UINT32 *taskId, TSK_INIT_PARAM_S *initParam);
/*该函数的功能是创建一个任务。如果在系统初始化之后创建的任务的优先级比当前任务高并且任务调度未被锁定,则将其调度运行。如果不是,则创建的任务将添加到就绪任务队列中*/
/** /**
* @ingroup los_task * @ingroup los_task
* @brief Resume a task. * @brief Resume a task.
@ -772,7 +821,9 @@ extern UINT32 LOS_TaskCreate(UINT32 *taskId, TSK_INIT_PARAM_S *initParam);
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern UINT32 LOS_TaskResume(UINT32 taskId); extern UINT32 LOS_TaskResume(UINT32 taskId);
/*这是华为LiteOS中用于恢复Resume任务的函数LOS_TaskResume的声明。
Suspended*/
/** /**
* @ingroup los_task * @ingroup los_task
* @brief Suspend a task. * @brief Suspend a task.
@ -802,7 +853,9 @@ extern UINT32 LOS_TaskResume(UINT32 taskId);
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern UINT32 LOS_TaskSuspend(UINT32 taskId); extern UINT32 LOS_TaskSuspend(UINT32 taskId);
/*这是华为LiteOS中用于挂起Suspend任务的函数LOS_TaskSuspend的声明。
*/
/** /**
* @ingroup los_task * @ingroup los_task
* @brief Delete a task. * @brief Delete a task.
@ -833,7 +886,9 @@ extern UINT32 LOS_TaskSuspend(UINT32 taskId);
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern UINT32 LOS_TaskDelete(UINT32 taskId); extern UINT32 LOS_TaskDelete(UINT32 taskId);
/*这是华为LiteOS中用于删除任务的函数LOS_TaskDelete的声明。
*/
/** /**
* @ingroup los_task * @ingroup los_task
* @brief Delay a task. * @brief Delay a task.
@ -867,7 +922,9 @@ extern UINT32 LOS_TaskDelete(UINT32 taskId);
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern UINT32 LOS_TaskDelay(UINT32 tick); extern UINT32 LOS_TaskDelay(UINT32 tick);
/*这是华为LiteOS中用于延迟Delay任务的函数LOS_TaskDelay的声明。
Ticks*/
/** /**
* @ingroup los_task * @ingroup los_task
* @brief Lock the task scheduling. * @brief Lock the task scheduling.
@ -891,7 +948,9 @@ extern UINT32 LOS_TaskDelay(UINT32 tick);
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern VOID LOS_TaskLock(VOID); extern VOID LOS_TaskLock(VOID);
/*这是华为LiteOS中用于锁定任务调度的函数LOS_TaskLock的声明。
*/
/** /**
* @ingroup los_task * @ingroup los_task
* @brief Unlock the task scheduling. * @brief Unlock the task scheduling.
@ -913,7 +972,9 @@ extern VOID LOS_TaskLock(VOID);
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern VOID LOS_TaskUnlock(VOID); extern VOID LOS_TaskUnlock(VOID);
/*这是华为LiteOS中用于解锁任务调度的函数LOS_TaskUnlock的声明。
API*/
/** /**
* @ingroup los_task * @ingroup los_task
* @brief Set a task priority. * @brief Set a task priority.
@ -946,7 +1007,9 @@ extern VOID LOS_TaskUnlock(VOID);
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern UINT32 LOS_TaskPriSet(UINT32 taskId, UINT16 taskPrio); extern UINT32 LOS_TaskPriSet(UINT32 taskId, UINT16 taskPrio);
/*这是华为LiteOS中用于设置任务优先级的函数LOS_TaskPriSet的声明。
*/
/** /**
* @ingroup los_task * @ingroup los_task
* @brief Set the priority of the current running task to a specified priority. * @brief Set the priority of the current running task to a specified priority.
@ -976,7 +1039,9 @@ extern UINT32 LOS_TaskPriSet(UINT32 taskId, UINT16 taskPrio);
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern UINT32 LOS_CurTaskPriSet(UINT16 taskPrio); extern UINT32 LOS_CurTaskPriSet(UINT16 taskPrio);
/*这是华为LiteOS中用于将当前运行任务的优先级设置为指定优先级的函数LOS_CurTaskPriSet的声明。
*/
/** /**
* @ingroup los_task * @ingroup los_task
* @brief Change the scheduling sequence of tasks with the same priority. * @brief Change the scheduling sequence of tasks with the same priority.
@ -1002,7 +1067,9 @@ extern UINT32 LOS_CurTaskPriSet(UINT16 taskPrio);
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern UINT32 LOS_TaskYield(VOID); extern UINT32 LOS_TaskYield(VOID);
/*这是华为LiteOS中用于改变具有相同优先级的任务调度顺序的函数LOS_TaskYield的声明。
*/
/** /**
* @ingroup los_task * @ingroup los_task
* @brief Obtain a task priority. * @brief Obtain a task priority.
@ -1022,7 +1089,9 @@ extern UINT32 LOS_TaskYield(VOID);
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern UINT16 LOS_TaskPriGet(UINT32 taskId); extern UINT16 LOS_TaskPriGet(UINT32 taskId);
/*这是华为LiteOS中获取指定任务优先级的函数LOS_TaskPriGet的声明。
*/
/** /**
* @ingroup los_task * @ingroup los_task
* @brief Obtain current running task ID. * @brief Obtain current running task ID.
@ -1040,7 +1109,9 @@ extern UINT16 LOS_TaskPriGet(UINT32 taskId);
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern UINT32 LOS_CurTaskIDGet(VOID); extern UINT32 LOS_CurTaskIDGet(VOID);
/*这是华为LiteOS中获取当前正在运行的任务ID的函数LOS_CurTaskIDGet的声明。
ID*/
/** /**
* @ingroup los_task * @ingroup los_task
* @brief Obtain a task information structure. * @brief Obtain a task information structure.
@ -1064,7 +1135,9 @@ extern UINT32 LOS_CurTaskIDGet(VOID);
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern UINT32 LOS_TaskInfoGet(UINT32 taskId, TSK_INFO_S *taskInfo); extern UINT32 LOS_TaskInfoGet(UINT32 taskId, TSK_INFO_S *taskInfo);
/*这是华为LiteOS中获取任务信息结构的函数LOS_TaskInfoGet的声明。
*/
/** /**
* @ingroup los_task * @ingroup los_task
* @brief Set the affinity mask of the task scheduling cpu. * @brief Set the affinity mask of the task scheduling cpu.
@ -1090,7 +1163,9 @@ extern UINT32 LOS_TaskInfoGet(UINT32 taskId, TSK_INFO_S *taskInfo);
* @since Huawei LiteOS V200R003C00 * @since Huawei LiteOS V200R003C00
*/ */
extern UINT32 LOS_TaskCpuAffiSet(UINT32 taskId, UINT16 usCpuAffiMask); extern UINT32 LOS_TaskCpuAffiSet(UINT32 taskId, UINT16 usCpuAffiMask);
/*这是华为LiteOS中设置任务调度CPU亲和性掩码的函数LOS_TaskCpuAffiSet的声明。
CPUCPU*/
/** /**
* @ingroup los_task * @ingroup los_task
* @brief Get the affinity mask of the task scheduling cpu. * @brief Get the affinity mask of the task scheduling cpu.
@ -1110,7 +1185,9 @@ extern UINT32 LOS_TaskCpuAffiSet(UINT32 taskId, UINT16 usCpuAffiMask);
* @since Huawei LiteOS V200R003C00 * @since Huawei LiteOS V200R003C00
*/ */
extern UINT16 LOS_TaskCpuAffiGet(UINT32 taskId); extern UINT16 LOS_TaskCpuAffiGet(UINT32 taskId);
/*这是华为LiteOS中获取任务调度CPU亲和性掩码的函数LOS_TaskCpuAffiGet的声明。
CPUCPU*/
/** /**
* @ingroup los_task * @ingroup los_task
* @brief Recycle task stack resource. * @brief Recycle task stack resource.
@ -1129,7 +1206,10 @@ extern UINT16 LOS_TaskCpuAffiGet(UINT32 taskId);
* @since Huawei LiteOS V200R003C00 * @since Huawei LiteOS V200R003C00
*/ */
extern VOID LOS_TaskResRecycle(VOID); extern VOID LOS_TaskResRecycle(VOID);
/*这是华为LiteOS中回收任务堆栈资源的函数LOS_TaskResRecycle的声明。
使
*/
#ifdef LOSCFG_OBSOLETE_API #ifdef LOSCFG_OBSOLETE_API
#define LOS_TASK_PARAM_INIT_ARG_0(initParam, arg) \ #define LOS_TASK_PARAM_INIT_ARG_0(initParam, arg) \
initParam.auwArgs[0] = (UINTPTR)arg initParam.auwArgs[0] = (UINTPTR)arg
@ -1138,7 +1218,7 @@ extern VOID LOS_TaskResRecycle(VOID);
#define LOS_TASK_PARAM_INIT_ARG(initParam, arg) \ #define LOS_TASK_PARAM_INIT_ARG(initParam, arg) \
initParam.pArgs = (VOID *)arg initParam.pArgs = (VOID *)arg
#endif #endif
/*这段代码是关于任务参数初始化宏的定义*/
/** /**
* @ingroup los_task * @ingroup los_task
* @brief Define the lowpower framework process function type. * @brief Define the lowpower framework process function type.
@ -1157,7 +1237,7 @@ extern VOID LOS_TaskResRecycle(VOID);
* @since Huawei LiteOS V200R005C10 * @since Huawei LiteOS V200R005C10
*/ */
typedef VOID (*LOWPOWERIDLEHOOK)(VOID); typedef VOID (*LOWPOWERIDLEHOOK)(VOID);
/*这段代码定义了一个函数指针类型LOWPOWERIDLEHOOK用于定义低功耗框架的处理函数*/
/** /**
* @ingroup los_task * @ingroup los_task
* @brief Register a hook to enter lowpower framework process. * @brief Register a hook to enter lowpower framework process.
@ -1176,7 +1256,9 @@ typedef VOID (*LOWPOWERIDLEHOOK)(VOID);
* @since Huawei LiteOS V200R005C10 * @since Huawei LiteOS V200R005C10
*/ */
extern VOID LOS_LowpowerHookReg(LOWPOWERIDLEHOOK hook); extern VOID LOS_LowpowerHookReg(LOWPOWERIDLEHOOK hook);
/*这段代码是关于注册低功耗处理函数的函数LOS_LowpowerHookReg的声明。
*/
/** /**
* @ingroup los_task * @ingroup los_task
* @brief Define the type of idle handler hook function. * @brief Define the type of idle handler hook function.
@ -1193,7 +1275,11 @@ extern VOID LOS_LowpowerHookReg(LOWPOWERIDLEHOOK hook);
* @since Huawei LiteOS V200R005C20 * @since Huawei LiteOS V200R005C20
*/ */
typedef VOID (*IDLEHANDLERHOOK)(VOID); typedef VOID (*IDLEHANDLERHOOK)(VOID);
/*这段代码定义了一个函数指针类型IDLEHANDLERHOOK用于定义空闲处理函数的类型。
VOID (*IDLEHANDLERHOOK)(VOID)
使IDLEHANDLERHOOK*/
/** /**
* @ingroup los_task * @ingroup los_task
* @brief Register the hook function for idle task. * @brief Register the hook function for idle task.
@ -1212,7 +1298,9 @@ typedef VOID (*IDLEHANDLERHOOK)(VOID);
* @since Huawei LiteOS V200R005C20 * @since Huawei LiteOS V200R005C20
*/ */
extern VOID LOS_IdleHandlerHookReg(IDLEHANDLERHOOK hook); extern VOID LOS_IdleHandlerHookReg(IDLEHANDLERHOOK hook);
/*这段代码是关于注册空闲处理函数的函数LOS_IdleHandlerHookReg的声明。
*/
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
} }

@ -25,7 +25,7 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --------------------------------------------------------------------------- */ * --------------------------------------------------------------------------- */
/*这些代码主要用于系统计时、延时和低功耗唤醒功能,提供了丰富的 Tick 相关操作接口和功能*/
/** /**
* @defgroup los_tick Tick * @defgroup los_tick Tick
* @ingroup kernel * @ingroup kernel
@ -49,37 +49,37 @@ extern "C" {
* Number of milliseconds in one second. * Number of milliseconds in one second.
*/ */
#define OS_SYS_MS_PER_SECOND 1000 #define OS_SYS_MS_PER_SECOND 1000
/*一秒钟内的毫秒数。*/
/** /**
* @ingroup los_tick * @ingroup los_tick
* Number of microseconds in one second. * Number of microseconds in one second.
*/ */
#define OS_SYS_US_PER_SECOND 1000000 #define OS_SYS_US_PER_SECOND 1000000
/*一秒钟内的微秒数*/
/** /**
* @ingroup los_tick * @ingroup los_tick
* Number of nanoseconds in one second. * Number of nanoseconds in one second.
*/ */
#define OS_SYS_NS_PER_SECOND 1000000000 #define OS_SYS_NS_PER_SECOND 1000000000
/*1秒内的纳秒数*/
/** /**
* @ingroup los_tick * @ingroup los_tick
* Number of microseconds in one milliseconds. * Number of microseconds in one milliseconds.
*/ */
#define OS_SYS_US_PER_MS 1000 #define OS_SYS_US_PER_MS 1000
/*一毫秒中的微秒数*/
/** /**
* @ingroup los_tick * @ingroup los_tick
* Number of nanoseconds in one milliseconds. * Number of nanoseconds in one milliseconds.
*/ */
#define OS_SYS_NS_PER_MS 1000000 #define OS_SYS_NS_PER_MS 1000000
/*一毫秒中的纳秒数*/
/** /**
* @ingroup los_tick * @ingroup los_tick
* Number of nanoseconds in one microsecond. * Number of nanoseconds in one microsecond.
*/ */
#define OS_SYS_NS_PER_US 1000 #define OS_SYS_NS_PER_US 1000
/*一微秒中的纳秒数*/
/** /**
* @ingroup los_tick * @ingroup los_tick
* Tick error code: The Tick configuration is incorrect. * Tick error code: The Tick configuration is incorrect.
@ -90,7 +90,7 @@ extern "C" {
* in los_config.h. * in los_config.h.
*/ */
#define LOS_ERRNO_TICK_CFG_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_TICK, 0x00) #define LOS_ERRNO_TICK_CFG_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_TICK, 0x00)
/*Tick错误代码Tick配置不正确*/
/** /**
* @ingroup los_tick * @ingroup los_tick
* Tick error code: This error code is not in use temporarily. * Tick error code: This error code is not in use temporarily.
@ -99,7 +99,7 @@ extern "C" {
* @deprecated This error code is obsolete since LiteOS 5.0.0. * @deprecated This error code is obsolete since LiteOS 5.0.0.
*/ */
#define LOS_ERRNO_TICK_NO_HWTIMER LOS_ERRNO_OS_ERROR(LOS_MOD_TICK, 0x01) #define LOS_ERRNO_TICK_NO_HWTIMER LOS_ERRNO_OS_ERROR(LOS_MOD_TICK, 0x01)
/*Tick错误代码此错误代码暂时未使用*/
/** /**
* @ingroup los_tick * @ingroup los_tick
* Tick error code: This error code is not in use temporarily. * Tick error code: This error code is not in use temporarily.
@ -108,31 +108,31 @@ extern "C" {
* @deprecated This error code is obsolete since LiteOS 5.0.0. * @deprecated This error code is obsolete since LiteOS 5.0.0.
*/ */
#define LOS_ERRNO_TICK_PER_SEC_TOO_SMALL LOS_ERRNO_OS_ERROR(LOS_MOD_TICK, 0x02) #define LOS_ERRNO_TICK_PER_SEC_TOO_SMALL LOS_ERRNO_OS_ERROR(LOS_MOD_TICK, 0x02)
/*Tick错误代码此错误代码暂时未使用。*/
/** /**
* @ingroup los_config * @ingroup los_config
* system clock * system clock
*/ */
extern UINT32 g_sysClock; extern UINT32 g_sysClock;
/*这段代码定义了一个名为g_sysClock的全局变量它表示系统时钟。没有进行定义*/
/** /**
* @ingroup los_config * @ingroup los_config
* get system clock * get system clock
*/ */
#define GET_SYS_CLOCK() (g_sysClock) #define GET_SYS_CLOCK() (g_sysClock)
/*这段代码定义了一个宏,用于获取系统时钟的值*/
/** /**
* @ingroup los_config * @ingroup los_config
* set system clock * set system clock
*/ */
#define SET_SYS_CLOCK(clock) (g_sysClock = (clock)) #define SET_SYS_CLOCK(clock) (g_sysClock = (clock))
/*这段代码定义了一个宏,用于设置系统时钟的值*/
/** /**
* @ingroup los_config * @ingroup los_config
* ticks per second * ticks per second
*/ */
extern UINT32 g_tickPerSecond; extern UINT32 g_tickPerSecond;
/*这段代码定义了一个名为g_tickPerSecond的全局变量它表示每秒钟的时钟滴答数ticks per second*/
/** /**
* @ingroup los_tick * @ingroup los_tick
* system time structure. * system time structure.
@ -146,7 +146,7 @@ typedef struct tagSysTime {
UINT8 ucSecond; /**< second, the value range is 0 - 59 */ UINT8 ucSecond; /**< second, the value range is 0 - 59 */
UINT8 ucWeek; /**< week, the value range is 0 - 6 */ UINT8 ucWeek; /**< week, the value range is 0 - 6 */
} SYS_TIME_S; } SYS_TIME_S;
/*这段代码定义了一个名为tagSysTime的结构体它表示系统时间信息。*/
/** /**
* @ingroup los_tick * @ingroup los_tick
* @brief Obtain the number of Ticks. * @brief Obtain the number of Ticks.
@ -165,7 +165,9 @@ typedef struct tagSysTime {
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern UINT64 LOS_TickCountGet(VOID); extern UINT64 LOS_TickCountGet(VOID);
/*这段代码声明了一个函数LOS_TickCountGet用于获取自系统启动以来的Tick数。
TickUINT64Tick*/
/** /**
* @ingroup los_tick * @ingroup los_tick
* @brief Obtain the number of cycles in one tick. * @brief Obtain the number of cycles in one tick.
@ -183,7 +185,9 @@ extern UINT64 LOS_TickCountGet(VOID);
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern UINT32 LOS_CyclePerTickGet(VOID); extern UINT32 LOS_CyclePerTickGet(VOID);
/*这段代码声明了一个函数LOS_CyclePerTickGet用于获取一个Tick中的周期数。
TickCPUUINT32Tick*/
/** /**
* @ingroup los_tick * @ingroup los_tick
* @brief Convert Ticks to milliseconds. * @brief Convert Ticks to milliseconds.
@ -208,7 +212,9 @@ extern UINT32 LOS_CyclePerTickGet(VOID);
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern UINT32 LOS_Tick2MS(UINT32 tick); extern UINT32 LOS_Tick2MS(UINT32 tick);
/*这段代码声明了一个函数LOS_Tick2MS用于将Ticks转换为毫秒数。
TickstickTicksUINT32*/
/** /**
* @ingroup los_tick * @ingroup los_tick
* @brief Convert milliseconds to Ticks. * @brief Convert milliseconds to Ticks.
@ -234,7 +240,9 @@ extern UINT32 LOS_Tick2MS(UINT32 tick);
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern UINT32 LOS_MS2Tick(UINT32 millisec); extern UINT32 LOS_MS2Tick(UINT32 millisec);
/*这段代码声明了一个函数LOS_MS2Tick用于将毫秒数转换为Ticks。
TicksmillisecUINT32Ticks*/
/** /**
* @ingroup los_tick * @ingroup los_tick
* @brief Obtain system cycle count. * @brief Obtain system cycle count.
@ -260,7 +268,9 @@ extern UINT32 LOS_MS2Tick(UINT32 millisec);
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern VOID LOS_GetCpuCycle(UINT32 *puwCntHi, UINT32 *puwCntLo); extern VOID LOS_GetCpuCycle(UINT32 *puwCntHi, UINT32 *puwCntLo);
/*这段代码声明了一个函数LOS_GetCpuCycle用于获取系统启动以来的CPU周期计数。
CPUpuwCntHipuwCntLoUINT32CPU3232*/
/** /**
* @ingroup los_tick * @ingroup los_tick
* @brief Obtain system time in nanoseconds. * @brief Obtain system time in nanoseconds.
@ -279,7 +289,9 @@ extern VOID LOS_GetCpuCycle(UINT32 *puwCntHi, UINT32 *puwCntLo);
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern UINT64 LOS_CurrNanosec(VOID); extern UINT64 LOS_CurrNanosec(VOID);
/*这段代码声明了一个函数LOS_CurrNanosec用于获取系统当前的纳秒级时间。
nanoseconds*/
/** /**
* @ingroup los_tick * @ingroup los_tick
* @brief spinning-delay in microsecond (us). * @brief spinning-delay in microsecond (us).
@ -299,7 +311,7 @@ extern UINT64 LOS_CurrNanosec(VOID);
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern VOID LOS_Udelay(UINT32 usecs); extern VOID LOS_Udelay(UINT32 usecs);
/*这段代码声明了一个函数LOS_Udelay用于进行微秒级的自旋延迟。*/
/** /**
* @ingroup los_tick * @ingroup los_tick
* @brief spinning-delay in millisecond (ms). * @brief spinning-delay in millisecond (ms).
@ -319,7 +331,7 @@ extern VOID LOS_Udelay(UINT32 usecs);
* @since Huawei LiteOS V100R001C00 * @since Huawei LiteOS V100R001C00
*/ */
extern VOID LOS_Mdelay(UINT32 msecs); extern VOID LOS_Mdelay(UINT32 msecs);
/*这段代码声明了一个函数LOS_Mdelay用于进行毫秒级的自旋延迟。*/
#ifdef LOSCFG_KERNEL_TICKLESS #ifdef LOSCFG_KERNEL_TICKLESS
/** /**
* @ingroup los_tick * @ingroup los_tick
@ -340,6 +352,8 @@ extern VOID LOS_Mdelay(UINT32 msecs);
*/ */
typedef VOID (*WAKEUPTICKHOOK)(UINT32 tickNum); typedef VOID (*WAKEUPTICKHOOK)(UINT32 tickNum);
/*这段代码定义了一个函数指针类型WAKEUPTICKHOOK用于定义低功耗框架的唤醒函数。
*/
/** /**
* @ingroup los_tick * @ingroup los_tick
* @brief Register a hook to wakeup from tick interrupt. * @brief Register a hook to wakeup from tick interrupt.
@ -358,6 +372,9 @@ typedef VOID (*WAKEUPTICKHOOK)(UINT32 tickNum);
* @since Huawei LiteOS V200R005C10 * @since Huawei LiteOS V200R005C10
*/ */
extern VOID LOS_IntTickWakeupHookReg(WAKEUPTICKHOOK hook); extern VOID LOS_IntTickWakeupHookReg(WAKEUPTICKHOOK hook);
/*这段代码声明了一个函数LOS_IntTickWakeupHookReg用于注册一个从tick中断唤醒后的回调函数。
LOS_IntTickWakeupHookRegtick*/
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus

@ -26,6 +26,7 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --------------------------------------------------------------------------- */ * --------------------------------------------------------------------------- */
/*这些代码主要用于开启和关闭 Tickless 模式,提供了 Tickless 相关操作接口和功能。*/
/** /**
* @defgroup los_tickless Tickless * @defgroup los_tickless Tickless
* @ingroup kernel * @ingroup kernel
@ -62,7 +63,9 @@ extern "C" {
* @since Huawei LiteOS V200R001C00 * @since Huawei LiteOS V200R001C00
*/ */
extern VOID LOS_TicklessEnable(VOID); extern VOID LOS_TicklessEnable(VOID);
/*这段代码声明了一个函数LOS_TicklessEnable用于启用tickless模式。
LOS_TicklessEnabletickless*/
/** /**
* @ingroup los_tickless * @ingroup los_tickless
* @brief disable the tickless mode. * @brief disable the tickless mode.
@ -83,7 +86,9 @@ extern VOID LOS_TicklessEnable(VOID);
* @since Huawei LiteOS V200R001C00 * @since Huawei LiteOS V200R001C00
*/ */
extern VOID LOS_TicklessDisable(VOID); extern VOID LOS_TicklessDisable(VOID);
/*这段代码声明了一个函数LOS_TicklessDisable用于禁用tickless模式。
LOS_TicklessDisabletickless*/
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
} }

@ -25,7 +25,7 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --------------------------------------------------------------------------- */ * --------------------------------------------------------------------------- */
/*这段代码提供了一些通用的宏和函数,可以帮助开发者在不同的编译环境下编写跨平台的代码,并提供了一些位操作的便利功能。*/
/** /**
* @defgroup los_toolchain * @defgroup los_toolchain
* @ingroup kernel * @ingroup kernel
@ -69,7 +69,15 @@ extern "C" {
#ifndef CLZ #ifndef CLZ
#define CLZ(value) (__clz(value)) #define CLZ(value) (__clz(value))
#endif #endif
/*这段代码是宏定义,用于在 ARM Compiler 下定义一些与编译器相关的宏和函数。
ASM __asm C
INLINE __inline
STATIC_INLINE static __inline
USED 使 GCC __attribute__((used)) 使使
WEAK 使 GCC __attribute__((weak)) weak symbol
CLZ 使 __clz
IAR Compiler */
/* for IAR Compiler */ /* for IAR Compiler */
#elif defined ( __ICCARM__ ) #elif defined ( __ICCARM__ )
@ -100,7 +108,16 @@ extern "C" {
#ifndef CTZ #ifndef CTZ
#define CTZ(value) (__UNDEFINED(value)) #define CTZ(value) (__UNDEFINED(value))
#endif #endif
/*这段代码是宏定义,用于在 IAR Compiler 下定义一些与编译器相关的宏和函数。
ASM __asm C
INLINE inline
STATIC_INLINE static inline
USED 使 IAR Compiler __root 使使
WEAK 使 IAR Compiler __weak weak symbol
CLZ 使 IAR Compiler __iar_builtin_CLZ
CTZ 使 __UNDEFINED
IAR Compiler */
/* for GNU Compiler */ /* for GNU Compiler */
#elif defined ( __GNUC__ ) #elif defined ( __GNUC__ )
@ -135,7 +152,17 @@ extern "C" {
#ifndef FFS #ifndef FFS
#define FFS(value) (__builtin_ffs(value)) #define FFS(value) (__builtin_ffs(value))
#endif #endif
/*这段代码是宏定义,用于在 GNU Compiler 下定义一些与编译器相关的宏和函数。
ASM __asm C
INLINE __inline
STATIC_INLINE static inline
USED 使 GNU Compiler __attribute__((used)) 使使
WEAK 使 GNU Compiler __attribute__((weak)) weak symbol
CLZ 使 GNU Compiler __builtin_clz
CTZ 使 GNU Compiler __builtin_ctz
FFS 使 GNU Compiler __builtin_ffs
GNU Compiler */
#else #else
#error Unknown compiler. #error Unknown compiler.
#endif #endif

@ -25,7 +25,8 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --------------------------------------------------------------------------- */ * --------------------------------------------------------------------------- */
/*这段代码是关于 Huawei LiteOS 操作系统中的跟踪Trace功能的实现包括了跟踪数据结构、跟踪事件类型、初始化、启动、停止、事件掩码
*/
/** /**
* @defgroup los_trace Trace * @defgroup los_trace Trace
* @ingroup kernel * @ingroup kernel
@ -49,25 +50,25 @@ extern "C" {
/** /**
* @ingroup los_trace * @ingroup los_trace
* Trace Control agent task's priority. * Trace Control agent task's priori00ty.
*/ */
#define LOSCFG_TRACE_TASK_PRIORITY 2 #define LOSCFG_TRACE_TASK_PRIORITY 2
#endif #endif
#define LOSCFG_TRACE_OBJ_MAX_NAME_SIZE LOS_TASK_NAMELEN #define LOSCFG_TRACE_OBJ_MAX_NAME_SIZE LOS_TASK_NAMELEN
/*这段代码是关于轨迹追踪Trace Control的配置*/
/** /**
* @ingroup los_trace * @ingroup los_trace
* Trace records the max number of objects(kernel object, like tasks). if set to 0, trace will not record any object. * Trace records the max number of objects(kernel object, like tasks). if set to 0, trace will not record any object.
*/ */
#define LOSCFG_TRACE_OBJ_MAX_NUM 0 // LOSCFG_BASE_CORE_TSK_LIMIT #define LOSCFG_TRACE_OBJ_MAX_NUM 0 // LOSCFG_BASE_CORE_TSK_LIMIT
/*这段代码是关于轨迹追踪Trace Control中记录对象数量的配置*/
/** /**
* @ingroup los_trace * @ingroup los_trace
* Trace tlv encode buffer size, the buffer is used to encode one piece raw frame to tlv message in online mode. * Trace tlv encode buffer size, the buffer is used to encode one piece raw frame to tlv message in online mode.
*/ */
#define LOSCFG_TRACE_TLV_BUF_SIZE 100 #define LOSCFG_TRACE_TLV_BUF_SIZE 100
/*这段代码是关于轨迹追踪Trace Control中tlv编码缓冲区大小的配置*/
/** /**
* @ingroup los_trace * @ingroup los_trace
* Trace error code: init trace failed. * Trace error code: init trace failed.
@ -77,7 +78,7 @@ extern "C" {
* Solution: Follow the trace State Machine. * Solution: Follow the trace State Machine.
*/ */
#define LOS_ERRNO_TRACE_ERROR_STATUS LOS_ERRNO_OS_ERROR(LOS_MOD_TRACE, 0x00) #define LOS_ERRNO_TRACE_ERROR_STATUS LOS_ERRNO_OS_ERROR(LOS_MOD_TRACE, 0x00)
/*跟踪错误代码:初始化跟踪失败*/
/** /**
* @ingroup los_trace * @ingroup los_trace
* Trace error code: Insufficient memory for trace buf init. * Trace error code: Insufficient memory for trace buf init.
@ -87,7 +88,7 @@ extern "C" {
* Solution: Expand the configured system memory or decrease the value defined by LOS_TRACE_BUFFER_SIZE. * Solution: Expand the configured system memory or decrease the value defined by LOS_TRACE_BUFFER_SIZE.
*/ */
#define LOS_ERRNO_TRACE_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_TRACE, 0x01) #define LOS_ERRNO_TRACE_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_TRACE, 0x01)
/*跟踪错误代码内存不足无法进行跟踪buf-init。*/
/** /**
* @ingroup los_trace * @ingroup los_trace
* Trace error code: Insufficient memory for trace struct. * Trace error code: Insufficient memory for trace struct.
@ -97,7 +98,7 @@ extern "C" {
* Solution: Increase trace buffer's size. * Solution: Increase trace buffer's size.
*/ */
#define LOS_ERRNO_TRACE_BUF_TOO_SMALL LOS_ERRNO_OS_ERROR(LOS_MOD_TRACE, 0x02) #define LOS_ERRNO_TRACE_BUF_TOO_SMALL LOS_ERRNO_OS_ERROR(LOS_MOD_TRACE, 0x02)
/*跟踪错误代码:跟踪结构的内存不足 */
/** /**
* @ingroup los_trace * @ingroup los_trace
* Trace state. * Trace state.
@ -108,7 +109,12 @@ enum TraceState {
TRACE_STARTED, /**< trace is started and system is tracing */ TRACE_STARTED, /**< trace is started and system is tracing */
TRACE_STOPED, /**< trace is stopped */ TRACE_STOPED, /**< trace is stopped */
}; };
/*这段代码定义了一个枚举类型 TraceState用于表示轨迹追踪Trace Control的状态。该枚举包括以下几个取值
TRACE_UNINIT
TRACE_INITED
TRACE_STARTED
TRACE_STOPED*/
/** /**
* @ingroup los_trace * @ingroup los_trace
* Trace mask is used to filter events in runtime. Each mask keep only one unique bit to 1, and user can define own * Trace mask is used to filter events in runtime. Each mask keep only one unique bit to 1, and user can define own
@ -128,7 +134,20 @@ typedef enum {
TRACE_MAX_FLAG = 0x80000000, TRACE_MAX_FLAG = 0x80000000,
TRACE_USER_DEFAULT_FLAG = 0xFFFFFFF0, TRACE_USER_DEFAULT_FLAG = 0xFFFFFFF0,
} LOS_TRACE_MASK; } LOS_TRACE_MASK;
/*这段代码定义了一个枚举类型 LOS_TRACE_MASK用于在运行时过滤事件。每个标志位都保持唯一的一位为1用户可以定义自己模块的跟踪掩码
TRACE_SYS_FLAG
TRACE_HWI_FLAG
TRACE_TASK_FLAG
TRACE_SWTMR_FLAG
TRACE_MEM_FLAG
TRACE_QUE_FLAG
TRACE_EVENT_FLAG
TRACE_SEM_FLAG
TRACE_MUX_FLAG
TRACE_MAX_FLAG
TRACE_USER_DEFAULT_FLAG*/
/** /**
* @ingroup los_trace * @ingroup los_trace
* Trace event type which indicate the exactly happend events, user can define own module's event type like * Trace event type which indicate the exactly happend events, user can define own module's event type like
@ -208,7 +227,10 @@ typedef enum {
MUX_PEND = TRACE_MUX_FLAG | 2, MUX_PEND = TRACE_MUX_FLAG | 2,
MUX_POST = TRACE_MUX_FLAG | 3, MUX_POST = TRACE_MUX_FLAG | 3,
} LOS_TRACE_TYPE; } LOS_TRACE_TYPE;
/*这段代码定义了一个枚举类型 LOS_TRACE_TYPE用于表示不同的追踪事件类型。每个事件类型都由一个唯一的标志位组成用户可以根据需要定义自己模块的事件类型。
使便
便*/
/** /**
* @ingroup los_trace * @ingroup los_trace
* struct to store the trace config information. * struct to store the trace config information.
@ -218,7 +240,7 @@ typedef struct {
UINT32 clockFreq; /**< system clock frequency */ UINT32 clockFreq; /**< system clock frequency */
UINT32 version; /**< trace version */ UINT32 version; /**< trace version */
} TraceBaseHeaderInfo; } TraceBaseHeaderInfo;
/*这段代码是一个注释和结构体的定义,用于存储跟踪配置信息。*/
/** /**
* @ingroup los_trace * @ingroup los_trace
* struct to store the event infomation * struct to store the event infomation
@ -246,7 +268,7 @@ typedef struct {
UINTPTR params[LOSCFG_TRACE_FRAME_MAX_PARAMS]; /**< event frame's params */ UINTPTR params[LOSCFG_TRACE_FRAME_MAX_PARAMS]; /**< event frame's params */
#endif #endif
} TraceEventFrame; } TraceEventFrame;
/*这段代码是一个注释和结构体的定义,用于存储事件信息*/
/** /**
* @ingroup los_trace * @ingroup los_trace
* struct to store the kernel obj information, we defined task as kernel obj in this system. * struct to store the kernel obj information, we defined task as kernel obj in this system.
@ -256,7 +278,7 @@ typedef struct {
UINT32 prio; /**< kernel obj's priority */ UINT32 prio; /**< kernel obj's priority */
CHAR name[LOSCFG_TRACE_OBJ_MAX_NAME_SIZE]; /**< kernel obj's name */ CHAR name[LOSCFG_TRACE_OBJ_MAX_NAME_SIZE]; /**< kernel obj's name */
} ObjData; } ObjData;
/*这段代码是一个注释和结构体的定义,用于存储内核对象信息*/
/** /**
* @ingroup los_trace * @ingroup los_trace
* struct to store the trace data. * struct to store the trace data.
@ -269,7 +291,7 @@ typedef struct {
UINT16 objOffset; /**< the offset of the first obj data to record beginning */ UINT16 objOffset; /**< the offset of the first obj data to record beginning */
UINT16 frameOffset; /**< the offset of the first event frame data to record beginning */ UINT16 frameOffset; /**< the offset of the first event frame data to record beginning */
} OfflineHead; } OfflineHead;
/*这段代码是一个注释和结构体的定义,用于存储跟踪数据。*/
/** /**
* @ingroup los_trace * @ingroup los_trace
* @brief Define the type of trace hardware interrupt filter hook function. * @brief Define the type of trace hardware interrupt filter hook function.
@ -293,7 +315,7 @@ typedef BOOL (*TRACE_HWI_FILTER_HOOK)(UINT32 hwiNum);
typedef VOID (*TRACE_EVENT_HOOK)(UINT32 eventType, UINTPTR identity, const UINTPTR *params, UINT16 paramCount); typedef VOID (*TRACE_EVENT_HOOK)(UINT32 eventType, UINTPTR identity, const UINTPTR *params, UINT16 paramCount);
extern TRACE_EVENT_HOOK g_traceEventHook; extern TRACE_EVENT_HOOK g_traceEventHook;
/*这段代码定义了两个函数指针类型和一个函数指针变量,这些函数指针类型和变量用于实现 Huawei LiteOS 操作系统的事件跟踪功能。*/
/** /**
* @ingroup los_trace * @ingroup los_trace
* Trace event params: * Trace event params:
@ -312,64 +334,64 @@ extern TRACE_EVENT_HOOK g_traceEventHook;
* eg. Trace only you need parmas as: * eg. Trace only you need parmas as:
* #define TASK_PRIOSET_PARAMS(taskId, taskStatus, oldPrio, newPrio) taskId * #define TASK_PRIOSET_PARAMS(taskId, taskStatus, oldPrio, newPrio) taskId
*/ */
#define TASK_SWITCH_PARAMS(taskId, oldPriority, oldTaskStatus, newPriority, newTaskStatus) \ #define TASK_SWITCH_PARAMS(taskId, oldPriority, oldTaskStatus, newPriority, newTaskStatus) \/*这段代码是一个宏定义,用于定义任务切换所需的参数集合*/
taskId, oldPriority, oldTaskStatus, newPriority, newTaskStatus taskId, oldPriority, oldTaskStatus, newPriority, newTaskStatus
#define TASK_PRIOSET_PARAMS(taskId, taskStatus, oldPrio, newPrio) taskId, taskStatus, oldPrio, newPrio #define TASK_PRIOSET_PARAMS(taskId, taskStatus, oldPrio, newPrio) taskId, taskStatus, oldPrio, newPrio/*这段代码是一个宏定义,用于定义任务优先级设置所需的参数集合*/
#define TASK_CREATE_PARAMS(taskId, taskStatus, prio) taskId, taskStatus, prio #define TASK_CREATE_PARAMS(taskId, taskStatus, prio) taskId, taskStatus, prio/*这段代码是一个宏定义,用于定义任务创建所需的参数集合*/
#define TASK_DELETE_PARAMS(taskId, taskStatus, usrStack) taskId, taskStatus, usrStack #define TASK_DELETE_PARAMS(taskId, taskStatus, usrStack) taskId, taskStatus, usrStack/*这段代码是一个宏定义,用于定义任务删除所需的参数集合*/
#define TASK_SUSPEND_PARAMS(taskId, taskStatus, runTaskId) taskId, taskStatus, runTaskId #define TASK_SUSPEND_PARAMS(taskId, taskStatus, runTaskId) taskId, taskStatus, runTaskId/*这段代码是一个宏定义,用于定义任务挂起所需的参数集合*/
#define TASK_RESUME_PARAMS(taskId, taskStatus, prio) taskId, taskStatus, prio #define TASK_RESUME_PARAMS(taskId, taskStatus, prio) taskId, taskStatus, prio/*这段代码是一个宏定义,用于定义任务恢复所需的参数集合*/
#define TASK_SIGNAL_PARAMS(taskId, signal, schedFlag) // taskId, signal, schedFlag #define TASK_SIGNAL_PARAMS(taskId, signal, schedFlag) // taskId, signal, schedFlag/*这段代码是一个宏定义,用于定义任务信号所需的参数集合
#define SWTMR_START_PARAMS(swtmrId, mode, overrun, interval, expiry) swtmrId, mode, overrun, interval, expiry #define SWTMR_START_PARAMS(swtmrId, mode, overrun, interval, expiry) swtmrId, mode, overrun, interval, expiry/*这段代码是一个宏定义,用于定义软定时器启动所需的参数集合*/
#define SWTMR_DELETE_PARAMS(swtmrId) swtmrId #define SWTMR_DELETE_PARAMS(swtmrId) swtmrId/*这段代码是一个宏定义,用于定义软定时器删除所需的参数集合*/
#define SWTMR_EXPIRED_PARAMS(swtmrId) swtmrId #define SWTMR_EXPIRED_PARAMS(swtmrId) swtmrId/*这段代码是一个宏定义,用于定义软定时器到期所需的参数集合。*/
#define SWTMR_STOP_PARAMS(swtmrId) swtmrId #define SWTMR_STOP_PARAMS(swtmrId) swtmrId/*这段代码是一个宏定义,用于定义软定时器停止所需的参数集合*/
#define SWTMR_CREATE_PARAMS(swtmrId) swtmrId #define SWTMR_CREATE_PARAMS(swtmrId) swtmrId
#define HWI_CREATE_PARAMS(hwiNum, hwiPrio, hwiMode, hwiHandler) hwiNum, hwiPrio, hwiMode, hwiHandler #define HWI_CREATE_PARAMS(hwiNum, hwiPrio, hwiMode, hwiHandler) hwiNum, hwiPrio, hwiMode, hwiHandler/*这段代码是一个宏定义,用于定义创建软定时器所需的参数集合*/
#define HWI_CREATE_SHARE_PARAMS(hwiNum, pDevId, ret) hwiNum, pDevId, ret #define HWI_CREATE_SHARE_PARAMS(hwiNum, pDevId, ret) hwiNum, pDevId, ret/*这段代码是一个宏定义,用于定义创建硬件中断所需的参数集合*/
#define HWI_DELETE_PARAMS(hwiNum) hwiNum #define HWI_DELETE_PARAMS(hwiNum) hwiNum/*这段代码是一个宏定义,用于定义中断删除所需的参数集合*/
#define HWI_DELETE_SHARE_PARAMS(hwiNum, pDevId, ret) hwiNum, pDevId, ret #define HWI_DELETE_SHARE_PARAMS(hwiNum, pDevId, ret) hwiNum, pDevId, ret/*这段代码是一个宏定义,用于定义共享中断删除所需的参数集合*/
#define HWI_RESPONSE_IN_PARAMS(hwiNum) hwiNum #define HWI_RESPONSE_IN_PARAMS(hwiNum) hwiNum/*这段代码是一个宏定义,用于定义中断响应输入参数*/
#define HWI_RESPONSE_OUT_PARAMS(hwiNum) hwiNum #define HWI_RESPONSE_OUT_PARAMS(hwiNum) hwiNum/*这段代码是一个宏定义,用于定义中断响应输出参数*/
#define HWI_ENABLE_PARAMS(hwiNum) hwiNum #define HWI_ENABLE_PARAMS(hwiNum) hwiNum/*这段代码是一个宏定义,用于定义中断使能所需的参数集合*/
#define HWI_DISABLE_PARAMS(hwiNum) hwiNum #define HWI_DISABLE_PARAMS(hwiNum) hwiNum/*这段代码是一个宏定义,用于定义中断禁用所需的参数集合*/
#define HWI_TRIGGER_PARAMS(hwiNum) hwiNum #define HWI_TRIGGER_PARAMS(hwiNum) hwiNum/*这段代码是一个宏定义,用于定义触发中断所需的参数集合*/
#define HWI_SETPRI_PARAMS(hwiNum, priority) hwiNum, priority #define HWI_SETPRI_PARAMS(hwiNum, priority) hwiNum, priority/*这段代码是一个宏定义,用于定义设置中断优先级所需的参数集合*/
#define HWI_CLEAR_PARAMS(hwiNum) hwiNum #define HWI_CLEAR_PARAMS(hwiNum) hwiNum/*这段代码是一个宏定义,用于定义清除中断所需的参数集合*/
#define HWI_SETAFFINITY_PARAMS(hwiNum, cpuMask) hwiNum, cpuMask #define HWI_SETAFFINITY_PARAMS(hwiNum, cpuMask) hwiNum, cpuMask/*这段代码是一个宏定义用于定义设置中断亲和性affinity所需的参数集合*/
#define HWI_SENDIPI_PARAMS(hwiNum, cpuMask) hwiNum, cpuMask #define HWI_SENDIPI_PARAMS(hwiNum, cpuMask) hwiNum, cpuMask/*这段代码是一个宏定义用于定义发送中断处理器间中断IPI所需的参数集合*/
#define EVENT_CREATE_PARAMS(eventCB) eventCB #define EVENT_CREATE_PARAMS(eventCB) eventCB/*这段代码是一个宏定义用于定义创建事件event所需的参数集合*/
#define EVENT_DELETE_PARAMS(eventCB, delRetCode) eventCB, delRetCode #define EVENT_DELETE_PARAMS(eventCB, delRetCode) eventCB, delRetCode/*这段代码是一个宏定义用于定义删除事件event所需的参数集合*/
#define EVENT_READ_PARAMS(eventCB, eventId, mask, mode, timeout) \ #define EVENT_READ_PARAMS(eventCB, eventId, mask, mode, timeout) \
eventCB, eventId, mask, mode, timeout eventCB, eventId, mask, mode, timeout
#define EVENT_WRITE_PARAMS(eventCB, eventId, events) eventCB, eventId, events #define EVENT_WRITE_PARAMS(eventCB, eventId, events) eventCB, eventId, events/*这段代码是一个宏定义用于定义读取事件event所需的参数集合*/
#define EVENT_CLEAR_PARAMS(eventCB, eventId, events) eventCB, eventId, events #define EVENT_CLEAR_PARAMS(eventCB, eventId, events) eventCB, eventId, events/*这段代码是一个宏定义用于定义清除事件event所需的参数集合*/
#define QUEUE_CREATE_PARAMS(queueId, queueSz, itemSz, queueAddr, memType) \ #define QUEUE_CREATE_PARAMS(queueId, queueSz, itemSz, queueAddr, memType) \/*这段代码是一个宏定义用于定义创建队列queue所需的参数*/
queueId, queueSz, itemSz, queueAddr, memType queueId, queueSz, itemSz, queueAddr, memType
#define QUEUE_DELETE_PARAMS(queueId, state, readable) queueId, state, readable #define QUEUE_DELETE_PARAMS(queueId, state, readable) queueId, state, readable/*这段代码是一个宏定义用于定义删除队列queue所需的参数集合*/
#define QUEUE_RW_PARAMS(queueId, queueSize, bufSize, operateType, readable, writeable, timeout) \ #define QUEUE_RW_PARAMS(queueId, queueSize, bufSize, operateType, readable, writeable, timeout) \/*这段代码是一个宏定义用于定义读写队列queue所需的参数集合*/
queueId, queueSize, bufSize, operateType, readable, writeable, timeout queueId, queueSize, bufSize, operateType, readable, writeable, timeout
#define SEM_CREATE_PARAMS(semId, type, count) semId, type, count #define SEM_CREATE_PARAMS(semId, type, count) semId, type, count/*这段代码是一个宏定义用于定义创建信号量semaphore所需的参数集合*/
#define SEM_DELETE_PARAMS(semId, delRetCode) semId, delRetCode #define SEM_DELETE_PARAMS(semId, delRetCode) semId, delRetCode/*这段代码是一个宏定义用于定义删除信号量semaphore所需的参数集合*/
#define SEM_PEND_PARAMS(semId, count, timeout) semId, count, timeout #define SEM_PEND_PARAMS(semId, count, timeout) semId, count, timeout/*这段代码是一个宏定义用于定义等待信号量semaphore所需的参数集合*/
#define SEM_POST_PARAMS(semId, type, count) semId, type, count #define SEM_POST_PARAMS(semId, type, count) semId, type, count/*这段代码是一个宏定义用于定义发送信号量semaphore所需的参数集合*/
#define MUX_CREATE_PARAMS(muxId) muxId #define MUX_CREATE_PARAMS(muxId) muxId/*这段代码是一个宏定义用于定义创建互斥量mutex所需的参数*/
#define MUX_DELETE_PARAMS(muxId, state, count, owner) muxId, state, count, owner #define MUX_DELETE_PARAMS(muxId, state, count, owner) muxId, state, count, owner/*这段代码是一个宏定义用于定义删除互斥量mutex所需的参数集合*/
#define MUX_PEND_PARAMS(muxId, count, owner, timeout) muxId, count, owner, timeout #define MUX_PEND_PARAMS(muxId, count, owner, timeout) muxId, count, owner, timeout/*这段代码是一个宏定义用于定义等待互斥量mutex所需的参数集合*/
#define MUX_POST_PARAMS(muxId, count, owner) muxId, count, owner #define MUX_POST_PARAMS(muxId, count, owner) muxId, count, owner/*这段代码是一个宏定义用于定义发送互斥量mutex所需的参数集合*/
#define MEM_ALLOC_PARAMS(pool, ptr, size) pool, ptr, size #define MEM_ALLOC_PARAMS(pool, ptr, size) pool, ptr, size/*这段代码是一个宏定义用于定义内存分配memory allocation所需的参数集合*/
#define MEM_ALLOC_ALIGN_PARAMS(pool, ptr, size, boundary) pool, ptr, size, boundary #define MEM_ALLOC_ALIGN_PARAMS(pool, ptr, size, boundary) pool, ptr, size, boundary/*这段代码是一个宏定义用于定义内存分配对齐alignment所需的参数集合*/
#define MEM_REALLOC_PARAMS(pool, ptr, size) pool, ptr, size #define MEM_REALLOC_PARAMS(pool, ptr, size) pool, ptr, size/*这段代码是一个宏定义用于定义重新分配内存memory reallocation所需的参数集合*/
#define MEM_FREE_PARAMS(pool, ptr) pool, ptr #define MEM_FREE_PARAMS(pool, ptr) pool, ptr/*这段代码是一个宏定义用于定义内存释放memory deallocation所需的参数集合*/
#define MEM_INFO_REQ_PARAMS(pool) pool #define MEM_INFO_REQ_PARAMS(pool) pool/*这段代码是一个宏定义用于定义获取内存信息请求memory information request所需的参数集合*/
#define MEM_INFO_PARAMS(pool, usedSize, freeSize) pool, usedSize, freeSize #define MEM_INFO_PARAMS(pool, usedSize, freeSize) pool, usedSize, freeSize/*这段代码是一个宏定义用于定义内存信息memory information所需的参数集合*/
#define SYS_ERROR_PARAMS(errno) errno #define SYS_ERROR_PARAMS(errno) errno
@ -405,7 +427,15 @@ extern TRACE_EVENT_HOOK g_traceEventHook;
#else #else
#define LOS_TRACE(TYPE, ...) LOS_PERF(TYPE) #define LOS_TRACE(TYPE, ...) LOS_PERF(TYPE)
#endif #endif
/*这段代码是一个宏定义,用于在源代码中插入跟踪代码存根,以追踪事件
LOS_PERF
_inner0
_inner1g_traceEventHook
g_traceEventHook
*/
#ifdef LOSCFG_KERNEL_TRACE #ifdef LOSCFG_KERNEL_TRACE
/** /**
@ -437,7 +467,13 @@ extern TRACE_EVENT_HOOK g_traceEventHook;
#else #else
#define LOS_TRACE_EASY(...) #define LOS_TRACE_EASY(...)
#endif #endif
/*这段代码是一个宏定义,用于在源代码中插入用户自定义的跟踪代码存根,以简单地追踪事件
_inner0
_inner1g_traceEventHook
g_traceEventHookTRACE_USER_DEFAULT_FLAG | TYPE
*/
/** /**
* @ingroup los_trace * @ingroup los_trace
* @brief Intialize the trace when the system startup. * @brief Intialize the trace when the system startup.
@ -465,7 +501,19 @@ extern TRACE_EVENT_HOOK g_traceEventHook;
* @since Huawei LiteOS V200R005C00 * @since Huawei LiteOS V200R005C00
*/ */
extern UINT32 LOS_TraceInit(VOID *buf, UINT32 size); extern UINT32 LOS_TraceInit(VOID *buf, UINT32 size);
/*这段代码定义了一个名为LOS_TraceInit的函数用于初始化系统级别的跟踪功能
TRACE_UNINITLOS_ERRNO_TRACE_ERROR_STATUS
LOS_ERRNO_TRACE_NO_MEMORY
LOS_ERRNO_TRACE_BUF_TOO_SMALL
LOS_MpCreateLOS_ERRNO_TSK_MP_SYNC_RESOURCE
LOS_ERRNO_TSK_TCB_UNAVAILABLE
TRACE_IDLE
*/
/** /**
* @ingroup los_trace * @ingroup los_trace
* @brief Start trace. * @brief Start trace.
@ -487,7 +535,7 @@ extern UINT32 LOS_TraceInit(VOID *buf, UINT32 size);
* @since Huawei LiteOS V200R005C00 * @since Huawei LiteOS V200R005C00
*/ */
extern UINT32 LOS_TraceStart(VOID); extern UINT32 LOS_TraceStart(VOID);
/*这段代码定义了一个名为LOS_TraceStart的函数用于启动跟踪功能*/
/** /**
* @ingroup los_trace * @ingroup los_trace
* @brief Stop trace sample. * @brief Stop trace sample.
@ -508,7 +556,7 @@ extern UINT32 LOS_TraceStart(VOID);
* @since Huawei LiteOS V200R005C00 * @since Huawei LiteOS V200R005C00
*/ */
extern VOID LOS_TraceStop(VOID); extern VOID LOS_TraceStop(VOID);
/*这段代码定义了一个名为LOS_TraceStop的函数用于停止跟踪采样*/
/** /**
* @ingroup los_trace * @ingroup los_trace
* @brief Clear the trace buf. * @brief Clear the trace buf.
@ -529,7 +577,7 @@ extern VOID LOS_TraceStop(VOID);
* @since Huawei LiteOS V200R005C00 * @since Huawei LiteOS V200R005C00
*/ */
extern VOID LOS_TraceReset(VOID); extern VOID LOS_TraceReset(VOID);
/*这段代码定义了一个名为LOS_TraceReset的函数用于清空跟踪缓冲区中的事件帧仅在离线模式下有效*/
/** /**
* @ingroup los_trace * @ingroup los_trace
* @brief Set trace event mask. * @brief Set trace event mask.
@ -553,7 +601,7 @@ extern VOID LOS_TraceReset(VOID);
* @since Huawei LiteOS V200R005C00 * @since Huawei LiteOS V200R005C00
*/ */
extern VOID LOS_TraceEventMaskSet(UINT32 mask); extern VOID LOS_TraceEventMaskSet(UINT32 mask);
/*这段代码定义了一个名为LOS_TraceEventMaskSet的函数用于设置跟踪事件的掩码*/
/** /**
* @ingroup los_trace * @ingroup los_trace
* @brief Offline trace buffer display. * @brief Offline trace buffer display.
@ -576,7 +624,7 @@ extern VOID LOS_TraceEventMaskSet(UINT32 mask);
* @since Huawei LiteOS V200R005C00 * @since Huawei LiteOS V200R005C00
*/ */
extern VOID LOS_TraceRecordDump(BOOL toClient); extern VOID LOS_TraceRecordDump(BOOL toClient);
/*这段代码定义了一个名为LOS_TraceRecordDump的函数用于在离线模式下显示跟踪缓冲区数据*/
/** /**
* @ingroup los_trace * @ingroup los_trace
* @brief Offline trace buffer export. * @brief Offline trace buffer export.
@ -599,7 +647,7 @@ extern VOID LOS_TraceRecordDump(BOOL toClient);
* @since Huawei LiteOS V200R005C00 * @since Huawei LiteOS V200R005C00
*/ */
extern OfflineHead *LOS_TraceRecordGet(VOID); extern OfflineHead *LOS_TraceRecordGet(VOID);
/*这段代码定义了一个名为LOS_TraceRecordGet的函数用于在离线模式下导出跟踪缓冲区数据*/
/** /**
* @ingroup los_trace * @ingroup los_trace
* @brief Hwi num fliter hook. * @brief Hwi num fliter hook.
@ -620,6 +668,7 @@ extern OfflineHead *LOS_TraceRecordGet(VOID);
* @since Huawei LiteOS V200R005C00 * @since Huawei LiteOS V200R005C00
*/ */
extern VOID LOS_TraceHwiFilterHookReg(TRACE_HWI_FILTER_HOOK hook); extern VOID LOS_TraceHwiFilterHookReg(TRACE_HWI_FILTER_HOOK hook);
/*这段代码定义了一个名为LOS_TraceHwiFilterHookReg的函数用于注册硬件中断Hwi号码过滤钩子函数*/
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
} }

@ -25,7 +25,8 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --------------------------------------------------------------------------- */ * --------------------------------------------------------------------------- */
/*代码是一个虚拟串口头文件用于定义虚拟串口的初始化、反初始化和获取串口类型等函数。在这个头文件中还定义了一个名为LOS_VIRSERIAL_CB的结构体
*/
#ifndef _VIRTUAL_SERIAL_H #ifndef _VIRTUAL_SERIAL_H
#define _VIRTUAL_SERIAL_H #define _VIRTUAL_SERIAL_H
@ -51,16 +52,20 @@ extern "C" {
#define SERIAL_TYPE_UART_DEV 1 #define SERIAL_TYPE_UART_DEV 1
#define SERIAL_TYPE_USBTTY_DEV 2 #define SERIAL_TYPE_USBTTY_DEV 2
extern INT32 virtual_serial_init(const CHAR *deviceName); extern INT32 virtual_serial_init(const CHAR *deviceName);/*这段代码声明了一个函数原型 virtual_serial_init用于初始化虚拟串口设备*/
extern INT32 virtual_serial_deinit(VOID); extern INT32 virtual_serial_deinit(VOID);/*这段代码声明了一个函数原型 virtual_serial_deinit用于反初始化虚拟串口设备*/
extern UINT32 SerialTypeGet(VOID); extern UINT32 SerialTypeGet(VOID);/*这段代码声明了一个函数原型 SerialTypeGet用于获取串口类型的函数*/
typedef struct { typedef struct {
struct file *filep; struct file *filep;
UINT32 mask; UINT32 mask;
} LOS_VIRSERIAL_CB; } LOS_VIRSERIAL_CB;
/*这段代码定义了一个结构体 LOS_VIRSERIAL_CB包含两个成员变量
filep struct file
mask UINT32
filep mask */
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus

Loading…
Cancel
Save