WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
los_task.h
浏览该文件的文档.
1/* ----------------------------------------------------------------------------
2 * Copyright (c) Huawei Technologies Co., Ltd. 2013-2022. All rights reserved.
3 * Description: LiteOS Task Module Implementation HeadFile
4 * Author: Huawei LiteOS Team
5 * Create: 2013-01-01
6 * Redistribution and use in source and binary forms, with or without modification,
7 * are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice, this list of
9 * conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
14 * to endorse or promote products derived from this software without specific prior written
15 * permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 * --------------------------------------------------------------------------- */
28
34#ifndef _LOS_TASK_H
35#define _LOS_TASK_H
36
37#include "los_base.h"
38#include "los_list.h"
39#include "los_sys.h"
40#include "los_tick.h"
41#include "los_event.h"
42#include "los_memory.h"
43#include "los_err.h"
44#include "arch/task.h"
45
46#ifdef __cplusplus
47extern "C" {
48#endif /* __cplusplus */
49
50#define CPUID_TO_AFFI_MASK(cpuid) (0x1u << (cpuid))
51
56#define LOS_TASK_PRIORITY_HIGHEST 0
57
62#define LOS_TASK_PRIORITY_LOWEST 31
63
78
87#define LOS_ERRNO_TSK_NO_MEMORY LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x00)
88
97#define LOS_ERRNO_TSK_PTR_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x01)
98
107#define LOS_ERRNO_TSK_STKSZ_NOT_ALIGN LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x02)
108
117#define LOS_ERRNO_TSK_PRIOR_ERROR LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x03)
118
127#define LOS_ERRNO_TSK_ENTRY_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x04)
128
137#define LOS_ERRNO_TSK_NAME_EMPTY LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x05)
138
147#define LOS_ERRNO_TSK_STKSZ_TOO_SMALL LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x06)
148
157#define LOS_ERRNO_TSK_ID_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x07)
158
167#define LOS_ERRNO_TSK_ALREADY_SUSPENDED LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x08)
168
177#define LOS_ERRNO_TSK_NOT_SUSPENDED LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x09)
178
187#define LOS_ERRNO_TSK_NOT_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x0a)
188
197#define LOS_ERRNO_TSK_DELETE_LOCKED LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x0b)
198
208#define LOS_ERRNO_TSK_MSG_NONZERO LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x0c)
209
218#define LOS_ERRNO_TSK_DELAY_IN_INT LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x0d)
219
228#define LOS_ERRNO_TSK_DELAY_IN_LOCK LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x0e)
229
238#define LOS_ERRNO_TSK_YIELD_IN_LOCK LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x0f)
239
248#define LOS_ERRNO_TSK_YIELD_NOT_ENOUGH_TASK LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x10)
249
258#define LOS_ERRNO_TSK_TCB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x11)
259
269#define LOS_ERRNO_TSK_HOOK_NOT_MATCH LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x12)
270
280#define LOS_ERRNO_TSK_HOOK_IS_FULL LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x13)
281
291#define LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x14)
292
301#define LOS_ERRNO_TSK_SUSPEND_LOCKED LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x15)
302
312#define LOS_ERRNO_TSK_FREE_STACK_FAILED LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x17)
313
323#define LOS_ERRNO_TSK_STKAREA_TOO_SMALL LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x18)
324
334#define LOS_ERRNO_TSK_ACTIVE_FAILED LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x19)
335
345#define LOS_ERRNO_TSK_CONFIG_TOO_MANY LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x1a)
346
354#define LOS_ERRNO_TSK_CP_SAVE_AREA_NOT_ALIGN LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x1b)
355
363#define LOS_ERRNO_TSK_MSG_Q_TOO_MANY LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x1d)
364
372#define LOS_ERRNO_TSK_CP_SAVE_AREA_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x1e)
373
381#define LOS_ERRNO_TSK_SELF_DELETE_ERR LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x1f)
382
391#define LOS_ERRNO_TSK_STKSZ_TOO_LARGE LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x20)
392
402#define LOS_ERRNO_TSK_SUSPEND_SWTMR_NOT_ALLOWED LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x21)
403
412#define LOS_ERRNO_TSK_CPU_AFFINITY_MASK_ERR LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x23)
413
422#define LOS_ERRNO_TSK_YIELD_IN_INT LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x24)
423
432#define LOS_ERRNO_TSK_MP_SYNC_RESOURCE LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x25)
433
442#define LOS_ERRNO_TSK_MP_SYNC_FAILED LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x26)
443
452#define LOS_ERRNO_TSK_ALLOC_SECURE_INT LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x27)
453
462#define LOS_ERRNO_TSK_SECURE_ALREADY_ALLOC LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x28)
463
472#define LOS_ERRNO_TSK_ALLOC_SECURE_FAILED LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x29)
473
482#define LOS_ERRNO_TSK_FREE_SECURE_FAILED LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x2a)
483
492#define LOS_ERRNO_TSK_NOT_ALLOW_IN_INT LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x2b)
493
502#define LOS_ERRNO_TSK_SCHED_LOCKED LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x2c)
503
512#define LOS_ERRNO_TSK_ALREADY_JOIN LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x2d)
513
522#define LOS_ERRNO_TSK_IS_DETACHED LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x2e)
523
532#define LOS_ERRNO_TSK_NOT_JOIN_SELF LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x2f)
533
542#define LOS_ERRNO_TSK_IS_ZOMBIE LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x30)
543
551#define LOS_TASK_MIN_STACK_SIZE (LOS_Align(KERNEL_TSK_MIN_STACK_SIZE, LOSCFG_STACK_POINT_ALIGN_SIZE))
552
553#ifdef LOSCFG_BASE_CORE_TSK_MONITOR
570typedef VOID (*TSKSWITCHHOOK)(UINT32 oldTaskId, UINT32 newTaskId);
571
586extern VOID LOS_TaskSwitchHookReg(TSKSWITCHHOOK hook);
587#endif
588
608#ifdef LOSCFG_OBSOLETE_API
609typedef VOID *(*TSK_ENTRY_FUNC)(UINTPTR param1,
610 UINTPTR param2,
611 UINTPTR param3,
612 UINTPTR param4);
613#else
614typedef VOID *(*TSK_ENTRY_FUNC)(VOID *param);
615#endif
622typedef struct tagTskInitParam {
625#ifdef LOSCFG_OBSOLETE_API
626 UINTPTR auwArgs[4];
629#else
631#endif
634#ifdef LOSCFG_KERNEL_SMP
635 UINT16 usCpuAffiMask;
636#endif
648
654#define LOS_TASK_NAMELEN 32
655
680
681#ifdef LOSCFG_TASK_STACK_STATIC_ALLOCATION
731extern UINT32 LOS_TaskCreateOnlyStatic(UINT32 *taskId, TSK_INIT_PARAM_S *initParam, VOID *topStack);
732
784extern UINT32 LOS_TaskCreateStatic(UINT32 *taskId, TSK_INIT_PARAM_S *initParam, VOID *topStack);
785#endif
786
787#ifdef LOSCFG_TASK_STACK_DYNAMIC_ALLOCATION
835extern UINT32 LOS_TaskCreateOnly(UINT32 *taskId, TSK_INIT_PARAM_S *initParam);
836
883extern UINT32 LOS_TaskCreate(UINT32 *taskId, TSK_INIT_PARAM_S *initParam);
884#endif
885
913
944
976
1010
1033
1058
1082
1108
1142extern UINT32 LOS_TaskPriSet(UINT32 taskId, UINT16 taskPrio);
1143
1173
1199
1219
1237
1260extern UINT32 LOS_TaskInfoGet(UINT32 taskId, TSK_INFO_S *taskInfo);
1261
1287extern UINT32 LOS_TaskCpuAffiSet(UINT32 taskId, UINT16 usCpuAffiMask);
1288
1308
1327
1328#ifdef LOSCFG_OBSOLETE_API
1329 #define LOS_TASK_PARAM_INIT_ARG_0(initParam, arg) \
1330 (initParam.auwArgs[0] = (UINTPTR)(arg))
1331 #define LOS_TASK_PARAM_INIT_ARG(initParam, arg) LOS_TASK_PARAM_INIT_ARG_0(initParam, arg)
1332#else
1333 #define LOS_TASK_PARAM_INIT_ARG(initParam, arg) \
1334 (initParam.pArgs = (VOID *)(arg))
1335#endif
1336
1355
1374
1391
1410
1411#ifdef LOSCFG_TRUSTZONE
1436extern UINT32 LOS_TaskAllocSecureContext(UINT32 taskId, UINT32 size);
1437
1438#endif
1439
1461
1485extern UINT32 LOS_TaskJoin(UINT32 taskId, UINTPTR *retval);
1486
1487#ifdef __cplusplus
1488}
1489#endif /* __cplusplus */
1490
1491#endif /* _LOS_TASK_H */
TaskAttrBits
Definition los_task.h:68
UINT32 LOS_TaskResume(UINT32 taskId)
Resume a task.
UINT32 LOS_TaskSuspend(UINT32 taskId)
Suspend a task.
UINT16 LOS_TaskPriGet(UINT32 taskId)
Obtain a task priority.
void LOS_TaskResRecycle(void)
Recycle task stack resource.
UINT32 LOS_CurTaskPriSet(UINT16 taskPrio)
Set the priority of the current running task to a specified priority.
UINT32 LOS_TaskPriSet(UINT32 taskId, UINT16 taskPrio)
Set a task priority.
UINT32 LOS_TaskInfoGet(UINT32 taskId, TSK_INFO_S *taskInfo)
Obtain a task information structure.
UINT16 LOS_TaskCpuAffiGet(UINT32 taskId)
Get the affinity mask of the task scheduling cpu.
UINT32 LOS_TaskCpuAffiSet(UINT32 taskId, UINT16 usCpuAffiMask)
Set the affinity mask of the task scheduling cpu.
struct tagTskInitParam TSK_INIT_PARAM_S
BOOL LOS_TaskIsScheduled(void)
To check if the current running core is scheduled.
void *(* TSK_ENTRY_FUNC)(void *param)
Define the type of a task entrance function.
Definition los_task.h:614
UINT32 LOS_TaskDelay(UINT32 tick)
Delay a task.
UINT32 LOS_CurTaskIDGet(void)
Obtain current running task ID.
void(* IDLEHANDLERHOOK)(void)
Define the type of idle handler hook function.
Definition los_task.h:1390
UINT32 LOS_TaskDelete(UINT32 taskId)
Delete a task.
struct tagTskInfo TSK_INFO_S
UINT32 LOS_TaskJoin(UINT32 taskId, UINTPTR *retval)
Join with a terminated thread.
UINT32 LOS_TaskDetach(UINT32 taskId)
Modify the task attributes to detach.
void LOS_TaskUnlockNoSched(void)
Unlock the task scheduling and no scheduling is generated.
void LOS_LowpowerHookReg(LOWPOWERIDLEHOOK hook)
Register a hook to enter lowpower framework process.
void(* LOWPOWERIDLEHOOK)(void)
Define the lowpower framework process function type.
Definition los_task.h:1354
void LOS_IdleHandlerHookReg(IDLEHANDLERHOOK hook)
Register the hook function for idle task.
void LOS_TaskUnlock(void)
Unlock the task scheduling.
UINT32 LOS_TaskYield(void)
Change the scheduling sequence of tasks with the same priority.
void LOS_TaskLock(void)
Lock the task scheduling.
#define LOS_TASK_NAMELEN
Definition los_task.h:654
@ LOS_TASK_STATUS_JOINABLE
Definition los_task.h:71
@ LOS_TASK_STATUS_DETACHED
Definition los_task.h:74
@ LOS_TASK_OS_ALLOC_SECURE
Definition los_task.h:69
unsigned short UINT16
Definition los_typedef.h:51
#define VOID
Definition los_typedef.h:88
unsigned int UINTPTR
Definition los_typedef.h:74
unsigned int UINT32
Definition los_typedef.h:52
char CHAR
Definition los_typedef.h:58
size_t BOOL
Definition los_typedef.h:83
Definition los_event.h:164
Definition los_task.h:661
UINT16 usTaskPrio
Definition los_task.h:666
void * pTaskSem
Definition los_task.h:667
EVENT_CB_S uwEvent
Definition los_task.h:669
void * pTaskMux
Definition los_task.h:668
UINT16 usTaskStatus
Definition los_task.h:665
UINT32 uwStackSize
Definition los_task.h:671
UINTPTR uwBottomOfStack
Definition los_task.h:673
UINT32 uwPeakUsed
Definition los_task.h:676
UINT32 uwTaskID
Definition los_task.h:664
UINTPTR uwSP
Definition los_task.h:674
UINT32 uwCurrUsed
Definition los_task.h:675
BOOL bOvf
Definition los_task.h:677
CHAR acName[32]
Definition los_task.h:662
UINTPTR uwTopOfStack
Definition los_task.h:672
UINT32 uwEventMask
Definition los_task.h:670
Definition los_task.h:622
UINT16 usTaskPrio
Definition los_task.h:624
UINT32 uwStackSize
Definition los_task.h:632
CHAR * pcName
Definition los_task.h:633
TSK_ENTRY_FUNC pfnTaskEntry
Definition los_task.h:623
UINT32 uwResved
Definition los_task.h:637
void * pArgs
Definition los_task.h:630