Compare commits
25 Commits
weekly_202
...
OpenHarmon
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
773613af16 | ||
|
|
0f0e4dfafd | ||
|
|
2a5a515f50 | ||
|
|
215a1f6dc0 | ||
|
|
093af869d5 | ||
|
|
ef8d27db07 | ||
|
|
b22234dd6a | ||
|
|
5169a23adf | ||
|
|
bc42e348d0 | ||
|
|
93cc5747a2 | ||
|
|
96b4c460e2 | ||
|
|
23f634bde5 | ||
|
|
aee17ecfa6 | ||
|
|
9b160141c4 | ||
|
|
3141961013 | ||
|
|
51a6c21315 | ||
|
|
c5a9ba4abf | ||
|
|
7fa979c67c | ||
|
|
b5e84d5516 | ||
|
|
c277e8d543 | ||
|
|
230a2f348f | ||
|
|
92e3844061 | ||
|
|
088a6d5bbd | ||
|
|
d4d6489fb9 | ||
|
|
c1b2b15a87 |
@@ -71,7 +71,7 @@ After the compilation is successful, the executable file **NUCLEO-F767.hex** i
|
||||
|
||||
## Repositories Involved<a name="section1371113476307"></a>
|
||||
|
||||
[Kernel subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/kernel.md)
|
||||
[Kernel subsystem](https://gitee.com/openharmony/docs/blob/HEAD/en/readme/kernel.md)
|
||||
|
||||
**kernel\_liteos\_m**
|
||||
|
||||
|
||||
@@ -52,11 +52,11 @@ OpenHarmony LiteOS-M内核的编译构建系统是一个基于gn和ninja的组
|
||||
|
||||
### 搭建系统基础环境
|
||||
|
||||
在搭建各个开发板环境前,需要完成OpenHarmony系统基础环境搭建。系统基础环境主要是指OpenHarmony的编译环境和开发环境,详细介绍请参考官方站点[Ubuntu编译环境准备](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-env-setup-linux.md)。开发者需要根据环境搭建文档,完成下述软件的安装:Python3.7+、gn、ninja、hb。对于LiteOS-M内核,还需要安装Make构建工具和[ARM GCC编译工具链](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads)。
|
||||
在搭建各个开发板环境前,需要完成OpenHarmony系统基础环境搭建。系统基础环境主要是指OpenHarmony的编译环境和开发环境,详细介绍请参考官方站点[Ubuntu编译环境准备](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/device-dev/quick-start/quickstart-lite-env-setup-linux.md)。开发者需要根据环境搭建文档,完成下述软件的安装:Python3.7+、gn、ninja、hb。对于LiteOS-M内核,还需要安装Make构建工具和[ARM GCC编译工具链](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads)。
|
||||
|
||||
### 获取OpenHarmony源码
|
||||
|
||||
开发者需要在Linux服务器上通过Git克隆获取OpenHarmony最新源码,详细的源码获取方式,请见[源码获取](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/sourcecode-acquire.md)。获取OpenHarmony完整仓代码后,假设克隆目录为`~/openHarmony`。
|
||||
开发者需要在Linux服务器上通过Git克隆获取OpenHarmony最新源码,详细的源码获取方式,请见[源码获取](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/device-dev/get-code/sourcecode-acquire.md)。获取OpenHarmony完整仓代码后,假设克隆目录为`~/openHarmony`。
|
||||
|
||||
### 获取示例工程源码
|
||||
|
||||
@@ -78,7 +78,7 @@ chmod +x ~/openHarmony/device/st/nucleo_f767zi/build.sh
|
||||
cp -r ~/nucleo_f767zi/vendor/st ~/openHarmony/vendor/st
|
||||
```
|
||||
|
||||
关于示例代码目录的说明,可以参考资料站点[板级目录规范](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/porting/transplant-chip-board-overview.md)。如果需要自行移植开发板,请参考[板级系统移植](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/porting/transplant-chip-board.md)。
|
||||
关于示例代码目录的说明,可以参考资料站点[板级目录规范](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/device-dev/porting/transplant-chip-board-overview.md)。如果需要自行移植开发板,请参考[板级系统移植](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/device-dev/porting/transplant-chip-board.md)。
|
||||
|
||||
### 编译运行
|
||||
|
||||
@@ -121,7 +121,7 @@ LiteOS-M内核移植的具体开发板的工程由社区开发者提供,可以
|
||||
|
||||
## 相关仓<a name="section1371113476307"></a>
|
||||
|
||||
[内核子系统](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme/%E5%86%85%E6%A0%B8%E5%AD%90%E7%B3%BB%E7%BB%9F.md)
|
||||
[内核子系统](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/readme/%E5%86%85%E6%A0%B8%E5%AD%90%E7%B3%BB%E7%BB%9F.md)
|
||||
|
||||
**kernel\_liteos\_m**
|
||||
|
||||
|
||||
@@ -6,15 +6,15 @@
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
@@ -29,18 +29,6 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**********************************************************************************
|
||||
|
||||
* Notice of Export Control Law
|
||||
===============================================
|
||||
* Huawei LiteOS may be subject to applicable export control laws and regulations, which
|
||||
* might include those applicable to Huawei LiteOS of U.S. and the country in which you
|
||||
* are located.
|
||||
* Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance
|
||||
* with such applicable export control laws and regulations.
|
||||
***********************************************************************************/
|
||||
|
||||
|
||||
#ifndef LWIP_API_SHELL_H
|
||||
#define LWIP_API_SHELL_H
|
||||
|
||||
|
||||
@@ -6,15 +6,15 @@
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
@@ -29,18 +29,6 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**********************************************************************************
|
||||
|
||||
* Notice of Export Control Law
|
||||
===============================================
|
||||
* Huawei LiteOS may be subject to applicable export control laws and regulations, which
|
||||
* might include those applicable to Huawei LiteOS of U.S. and the country in which you
|
||||
* are located.
|
||||
* Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance
|
||||
* with such applicable export control laws and regulations.
|
||||
***********************************************************************************/
|
||||
|
||||
|
||||
#define LWIP_STATIC static
|
||||
#define DHCP_STATE_OFF 0
|
||||
#define LWIP_EXT_POLL_SUPPORT 1
|
||||
|
||||
@@ -34,20 +34,23 @@
|
||||
#include "los_sched.h"
|
||||
#include "los_timer.h"
|
||||
#include "los_memory.h"
|
||||
#include "los_swtmr.h"
|
||||
|
||||
#if (LOSCFG_KERNEL_PM == 1)
|
||||
#define OS_PM_NODE_FREE 0x80000000U
|
||||
#define OS_PM_LOCK_MAX 0xFFFFU
|
||||
#define OS_PM_SYS_EARLY 1
|
||||
#define OS_PM_SYS_DEVICE_EARLY 2
|
||||
|
||||
typedef UINT32 (*Suspend)(VOID);
|
||||
typedef UINT32 (*SysSuspend)(VOID);
|
||||
typedef UINT32 (*Suspend)(UINT32 mode);
|
||||
|
||||
#if (LOSCFG_KERNEL_PM_DEBUG == 1)
|
||||
typedef struct {
|
||||
CHAR *name;
|
||||
UINT32 count;
|
||||
UINT32 swtmrID;
|
||||
LOS_DL_LIST list;
|
||||
} OsPmLockCB;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
LOS_SysSleepEnum pmMode;
|
||||
@@ -60,72 +63,77 @@ typedef struct {
|
||||
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
|
||||
UINT64 enterSleepTime;
|
||||
#endif
|
||||
#if (LOSCFG_KERNEL_PM_DEBUG == 1)
|
||||
LOS_DL_LIST lockList;
|
||||
#endif
|
||||
} LosPmCB;
|
||||
|
||||
#define PM_EVENT_LOCK_MASK 0xF
|
||||
#define PM_EVENT_LOCK_RELEASE 0x1
|
||||
STATIC EVENT_CB_S g_pmEvent;
|
||||
STATIC LosPmCB g_pmCB;
|
||||
STATIC LosPmSysctrl *g_sysctrl = NULL;
|
||||
STATIC UINT64 g_pmSleepTime;
|
||||
|
||||
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
|
||||
STATIC VOID OsPmTickTimerStart(LosPmCB *pm)
|
||||
{
|
||||
UINT32 intSave;
|
||||
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
|
||||
UINT64 currTime, sleepTime, realSleepTime;
|
||||
#endif
|
||||
LosPmTickTimer *tickTimer = pm->tickTimer;
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
/* Restore the main CPU frequency */
|
||||
sleepTime = tickTimer->timerCycleGet();
|
||||
tickTimer->timerStop();
|
||||
|
||||
realSleepTime = OS_SYS_CYCLE_TO_NS(sleepTime, tickTimer->freq);
|
||||
realSleepTime = OS_SYS_NS_TO_CYCLE(realSleepTime, OS_SYS_CLOCK);
|
||||
currTime = pm->enterSleepTime + realSleepTime;
|
||||
pm->enterSleepTime = 0;
|
||||
|
||||
OsSchedTimerBaseReset(currTime);
|
||||
OsSchedUpdateExpireTime(currTime, FALSE);
|
||||
tickTimer->tickUnlock();
|
||||
LOS_IntRestore(intSave);
|
||||
return;
|
||||
}
|
||||
|
||||
STATIC VOID OsPmTickTimerStop(LosPmCB *pm)
|
||||
{
|
||||
UINT64 sleepCycle;
|
||||
UINT64 realSleepTime = g_pmSleepTime;
|
||||
LosPmTickTimer *tickTimer = pm->tickTimer;
|
||||
|
||||
if (realSleepTime == 0) {
|
||||
if ((tickTimer == NULL) || (tickTimer->tickUnlock == NULL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
sleepCycle = OS_SYS_CYCLE_TO_NS(realSleepTime, OS_SYS_CLOCK);
|
||||
sleepCycle = OS_SYS_NS_TO_CYCLE(sleepCycle, tickTimer->freq);
|
||||
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
|
||||
if (tickTimer->timerStop != NULL) {
|
||||
/* Restore the main CPU frequency */
|
||||
sleepTime = tickTimer->timerCycleGet();
|
||||
tickTimer->timerStop();
|
||||
|
||||
/* The main CPU reduces the frequency */
|
||||
pm->enterSleepTime = OsGetCurrSysTimeCycle();
|
||||
tickTimer->tickLock();
|
||||
tickTimer->timerStart(sleepCycle);
|
||||
realSleepTime = OS_SYS_CYCLE_TO_NS(sleepTime, tickTimer->freq);
|
||||
realSleepTime = OS_SYS_NS_TO_CYCLE(realSleepTime, OS_SYS_CLOCK);
|
||||
currTime = pm->enterSleepTime + realSleepTime;
|
||||
pm->enterSleepTime = 0;
|
||||
|
||||
OsSchedTimerBaseReset(currTime);
|
||||
}
|
||||
#endif
|
||||
|
||||
tickTimer->tickUnlock();
|
||||
return;
|
||||
}
|
||||
|
||||
STATIC BOOL OsPmTickTimerStop(LosPmCB *pm)
|
||||
{
|
||||
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
|
||||
UINT64 sleepCycle;
|
||||
UINT64 realSleepTime = g_pmSleepTime;
|
||||
#endif
|
||||
LosPmTickTimer *tickTimer = pm->tickTimer;
|
||||
|
||||
if ((tickTimer == NULL) || (tickTimer->tickLock == NULL)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
|
||||
if (tickTimer->timerStart != NULL) {
|
||||
if (realSleepTime == 0) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
sleepCycle = OS_SYS_CYCLE_TO_NS(realSleepTime, OS_SYS_CLOCK);
|
||||
sleepCycle = OS_SYS_NS_TO_CYCLE(sleepCycle, tickTimer->freq);
|
||||
|
||||
/* The main CPU reduces the frequency */
|
||||
pm->enterSleepTime = OsGetCurrSysTimeCycle();
|
||||
tickTimer->tickLock();
|
||||
tickTimer->timerStart(sleepCycle);
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
STATIC VOID OsPmTickTimerResume(LosPmCB *pm)
|
||||
{
|
||||
if ((pm->sysMode == LOS_SYS_DEEP_SLEEP) && (pm->tickTimer->tickUnlock != NULL)) {
|
||||
pm->tickTimer->tickUnlock();
|
||||
} else {
|
||||
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
|
||||
/* Sys tick timer is restored from low power mode */
|
||||
if (pm->enterSleepTime != 0) {
|
||||
OsPmTickTimerStart(pm);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
tickTimer->tickLock();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
STATIC VOID OsPmCpuResume(LosPmCB *pm)
|
||||
@@ -139,9 +147,9 @@ STATIC VOID OsPmCpuResume(LosPmCB *pm)
|
||||
}
|
||||
}
|
||||
|
||||
STATIC Suspend OsPmCpuSuspend(LosPmCB *pm)
|
||||
STATIC SysSuspend OsPmCpuSuspend(LosPmCB *pm)
|
||||
{
|
||||
Suspend sysSuspend = NULL;
|
||||
SysSuspend sysSuspend = NULL;
|
||||
|
||||
/* cpu enter low power mode */
|
||||
LOS_ASSERT(pm->sysctrl != NULL);
|
||||
@@ -161,104 +169,132 @@ STATIC Suspend OsPmCpuSuspend(LosPmCB *pm)
|
||||
return sysSuspend;
|
||||
}
|
||||
|
||||
STATIC VOID OsPmTickTimerSuspend(LosPmCB *pm)
|
||||
STATIC VOID OsPmResumePrepare(LosPmCB *pm, UINT32 mode, UINT32 prepare)
|
||||
{
|
||||
if (((pm->sysMode == LOS_SYS_DEEP_SLEEP) || (pm->sysMode == LOS_SYS_SHUTDOWN)) &&
|
||||
(pm->tickTimer->tickLock != NULL)) {
|
||||
pm->tickTimer->tickLock();
|
||||
} else {
|
||||
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
|
||||
/* Sys tick timer enter low power mode */
|
||||
if (pm->tickTimer == NULL) {
|
||||
return;
|
||||
}
|
||||
if ((prepare == 0) && (pm->device->resume != NULL)) {
|
||||
pm->device->resume(mode);
|
||||
}
|
||||
|
||||
if ((pm->tickTimer->timerStart != NULL) &&
|
||||
(pm->tickTimer->timerStop != NULL) &&
|
||||
(pm->tickTimer->timerCycleGet == NULL) &&
|
||||
(pm->tickTimer->freq != 0)) {
|
||||
OsPmTickTimerStop(pm);
|
||||
}
|
||||
#endif
|
||||
if (((prepare == 0) || (prepare == OS_PM_SYS_DEVICE_EARLY)) && (pm->sysctrl->late != NULL)) {
|
||||
pm->sysctrl->late(mode);
|
||||
}
|
||||
}
|
||||
|
||||
STATIC VOID OsPmEnter(BOOL isIdle)
|
||||
STATIC UINT32 OsPmSuspendPrepare(Suspend sysSuspendEarly, Suspend deviceSuspend, UINT32 mode, UINT32 *prepare)
|
||||
{
|
||||
UINT32 ret;
|
||||
|
||||
if (sysSuspendEarly != NULL) {
|
||||
ret = sysSuspendEarly(mode);
|
||||
if (ret != LOS_OK) {
|
||||
*prepare = OS_PM_SYS_EARLY;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
if (deviceSuspend != NULL) {
|
||||
ret = deviceSuspend(mode);
|
||||
if (ret != LOS_OK) {
|
||||
*prepare = OS_PM_SYS_DEVICE_EARLY;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 OsPmSuspendCheck(LosPmCB *pm, Suspend *sysSuspendEarly, Suspend *deviceSuspend, LOS_SysSleepEnum *mode)
|
||||
{
|
||||
UINT32 intSave;
|
||||
Suspend sysSuspend = NULL;
|
||||
LosPmCB *pm = &g_pmCB;
|
||||
BOOL isTaskLock = FALSE;
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
pm->sysMode = pm->pmMode;
|
||||
if (isIdle) {
|
||||
if ((pm->sysMode != LOS_SYS_NORMAL_SLEEP) && (pm->sysMode != LOS_SYS_LIGHT_SLEEP)) {
|
||||
pm->sysMode = LOS_SYS_NORMAL_SLEEP;
|
||||
}
|
||||
} else {
|
||||
if ((pm->sysMode != LOS_SYS_DEEP_SLEEP) && (pm->sysMode != LOS_SYS_SHUTDOWN)) {
|
||||
LOS_IntRestore(intSave);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ((pm->sysMode == LOS_SYS_NORMAL_SLEEP) || (pm->sysMode == LOS_SYS_LIGHT_SLEEP)) {
|
||||
if (pm->lock > 0) {
|
||||
pm->sysMode = LOS_SYS_NORMAL_SLEEP;
|
||||
}
|
||||
} else if (pm->lock > 0) {
|
||||
if (pm->lock > 0) {
|
||||
pm->sysMode = LOS_SYS_NORMAL_SLEEP;
|
||||
LOS_IntRestore(intSave);
|
||||
return;
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
if (pm->sysMode != LOS_SYS_NORMAL_SLEEP) {
|
||||
pm->isWake = FALSE;
|
||||
pm->isWake = FALSE;
|
||||
*mode = pm->sysMode;
|
||||
*sysSuspendEarly = pm->sysctrl->early;
|
||||
*deviceSuspend = pm->device->suspend;
|
||||
LOS_IntRestore(intSave);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 OsPmSuspendSleep(LosPmCB *pm)
|
||||
{
|
||||
UINT32 ret, intSave;
|
||||
Suspend sysSuspendEarly, deviceSuspend;
|
||||
LOS_SysSleepEnum mode;
|
||||
UINT32 prepare = 0;
|
||||
BOOL tickTimerStop = FALSE;
|
||||
SysSuspend sysSuspend;
|
||||
UINT64 currTime;
|
||||
|
||||
ret = OsPmSuspendCheck(pm, &sysSuspendEarly, &deviceSuspend, &mode);
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = OsPmSuspendPrepare(sysSuspendEarly, deviceSuspend, (UINT32)mode, &prepare);
|
||||
if (ret != LOS_OK) {
|
||||
intSave = LOS_IntLock();
|
||||
LOS_TaskLock();
|
||||
isTaskLock = TRUE;
|
||||
|
||||
ret = pm->device->suspend((UINT32)pm->sysMode);
|
||||
if (ret != LOS_OK) {
|
||||
goto EXIT;
|
||||
}
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
OsPmTickTimerSuspend(pm);
|
||||
intSave = LOS_IntLock();
|
||||
LOS_TaskLock();
|
||||
if (pm->isWake || (pm->lock > 0)) {
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
tickTimerStop = OsPmTickTimerStop(pm);
|
||||
if (!tickTimerStop) {
|
||||
currTime = OsGetCurrSchedTimeCycle();
|
||||
OsSchedResetSchedResponseTime(0);
|
||||
OsSchedUpdateExpireTime(currTime, TRUE);
|
||||
}
|
||||
|
||||
sysSuspend = OsPmCpuSuspend(pm);
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
if (!isTaskLock || (isTaskLock && !pm->isWake)) {
|
||||
(VOID)sysSuspend();
|
||||
if (!pm->isWake) {
|
||||
ret = sysSuspend();
|
||||
}
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
|
||||
OsPmCpuResume(pm);
|
||||
|
||||
OsPmTickTimerResume(pm);
|
||||
|
||||
if (pm->sysMode != LOS_SYS_NORMAL_SLEEP) {
|
||||
pm->device->resume((UINT32)pm->sysMode);
|
||||
}
|
||||
|
||||
if (pm->pmMode == LOS_SYS_DEEP_SLEEP) {
|
||||
pm->pmMode = LOS_SYS_NORMAL_SLEEP;
|
||||
}
|
||||
OsPmTickTimerStart(pm);
|
||||
|
||||
EXIT:
|
||||
pm->sysMode = LOS_SYS_NORMAL_SLEEP;
|
||||
OsPmResumePrepare(pm, (UINT32)mode, prepare);
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
if (isTaskLock) {
|
||||
LOS_TaskUnlock();
|
||||
}
|
||||
return;
|
||||
LOS_TaskUnlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
STATIC VOID OsPmTask(VOID)
|
||||
STATIC VOID OsPmNormalSleep(VOID)
|
||||
{
|
||||
OsPmEnter(FALSE);
|
||||
UINT32 intSave;
|
||||
LosPmCB *pm = &g_pmCB;
|
||||
SysSuspend sysSuspend = NULL;
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
sysSuspend = OsPmCpuSuspend(pm);
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
(VOID)sysSuspend();
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
OsPmCpuResume(pm);
|
||||
LOS_IntRestore(intSave);
|
||||
}
|
||||
|
||||
STATIC UINT32 OsPmDeviceRegister(LosPmCB *pm, LosPmDevice *device)
|
||||
@@ -280,13 +316,24 @@ STATIC UINT32 OsPmTickTimerRegister(LosPmCB *pm, LosPmTickTimer *tickTimer)
|
||||
{
|
||||
UINT32 intSave;
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
if ((tickTimer->tickLock == NULL) || (tickTimer->tickUnlock == NULL)) {
|
||||
return LOS_ERRNO_PM_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (((tickTimer->timerStart == NULL) && (tickTimer->timerStop == NULL) &&
|
||||
(tickTimer->timerCycleGet == NULL) && (tickTimer->freq == 0)) ||
|
||||
((tickTimer->timerStart != NULL) && (tickTimer->timerStop != NULL) &&
|
||||
(tickTimer->timerCycleGet != NULL) && (tickTimer->freq != 0))) {
|
||||
intSave = LOS_IntLock();
|
||||
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
|
||||
pm->enterSleepTime = 0;
|
||||
pm->enterSleepTime = 0;
|
||||
#endif
|
||||
pm->tickTimer = tickTimer;
|
||||
LOS_IntRestore(intSave);
|
||||
return LOS_OK;
|
||||
pm->tickTimer = tickTimer;
|
||||
LOS_IntRestore(intSave);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
return LOS_ERRNO_PM_INVALID_PARAM;
|
||||
}
|
||||
|
||||
STATIC UINT32 OsPmSysctrlRegister(LosPmCB *pm, LosPmSysctrl *sysctrl)
|
||||
@@ -433,11 +480,8 @@ LOS_SysSleepEnum LOS_PmModeGet(VOID)
|
||||
UINT32 LOS_PmModeSet(LOS_SysSleepEnum mode)
|
||||
{
|
||||
UINT32 intSave;
|
||||
UINT32 taskID;
|
||||
UINT32 ret;
|
||||
LosPmCB *pm = &g_pmCB;
|
||||
INT32 sleepMode = (INT32)mode;
|
||||
TSK_INIT_PARAM_S taskInitParam = { 0 };
|
||||
|
||||
if ((sleepMode < 0) || (sleepMode > LOS_SYS_SHUTDOWN)) {
|
||||
return LOS_ERRNO_PM_INVALID_MODE;
|
||||
@@ -464,29 +508,9 @@ UINT32 LOS_PmModeSet(LOS_SysSleepEnum mode)
|
||||
return LOS_ERRNO_PM_HANDLER_NULL;
|
||||
}
|
||||
|
||||
if ((mode == LOS_SYS_DEEP_SLEEP) || (mode == LOS_SYS_SHUTDOWN)) {
|
||||
if ((pm->tickTimer == NULL) ||
|
||||
(pm->tickTimer->tickLock == NULL) ||
|
||||
(pm->tickTimer->tickUnlock == NULL)) {
|
||||
LOS_IntRestore(intSave);
|
||||
return LOS_ERRNO_PM_TICK_TIMER_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
pm->pmMode = mode;
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
if ((mode == LOS_SYS_DEEP_SLEEP) || (mode == LOS_SYS_SHUTDOWN)) {
|
||||
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)OsPmTask;
|
||||
taskInitParam.uwStackSize = LOSCFG_KERNEL_PM_TASK_STACKSIZE;
|
||||
taskInitParam.pcName = "pm";
|
||||
taskInitParam.usTaskPrio = LOSCFG_KERNEL_PM_TASK_PTIORITY;
|
||||
ret = LOS_TaskCreate(&taskID, &taskInitParam);
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
@@ -513,24 +537,17 @@ VOID LOS_PmLockInfoShow(VOID)
|
||||
}
|
||||
#endif
|
||||
|
||||
UINT32 LOS_PmLockRequest(const CHAR *name)
|
||||
UINT32 OsPmLockRequest(const CHAR *name, UINT32 swtmrID)
|
||||
{
|
||||
UINT32 intSave;
|
||||
UINT32 ret = LOS_ERRNO_PM_NOT_LOCK;
|
||||
LosPmCB *pm = &g_pmCB;
|
||||
#if (LOSCFG_KERNEL_PM_DEBUG == 1)
|
||||
OsPmLockCB *listNode = NULL;
|
||||
OsPmLockCB *lock = NULL;
|
||||
LOS_DL_LIST *head = &pm->lockList;
|
||||
LOS_DL_LIST *list = head->pstNext;
|
||||
|
||||
if (name == NULL) {
|
||||
return LOS_ERRNO_PM_INVALID_PARAM;
|
||||
}
|
||||
#endif
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
#if (LOSCFG_KERNEL_PM_DEBUG == 1)
|
||||
while (list != head) {
|
||||
listNode = LOS_DL_LIST_ENTRY(list, OsPmLockCB, list);
|
||||
if (strcmp(name, listNode->name) == 0) {
|
||||
@@ -549,11 +566,17 @@ UINT32 LOS_PmLockRequest(const CHAR *name)
|
||||
}
|
||||
lock->name = (CHAR *)name;
|
||||
lock->count = 1;
|
||||
lock->swtmrID = swtmrID;
|
||||
LOS_ListTailInsert(head, &lock->list);
|
||||
} else if (lock->count < OS_PM_LOCK_MAX) {
|
||||
lock->count++;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((lock->swtmrID != OS_INVALID) && (lock->count > 1)) {
|
||||
lock->count--;
|
||||
LOS_IntRestore(intSave);
|
||||
return LOS_ERRNO_PM_ALREADY_LOCK;
|
||||
}
|
||||
|
||||
if (pm->lock < OS_PM_LOCK_MAX) {
|
||||
pm->lock++;
|
||||
@@ -564,25 +587,34 @@ UINT32 LOS_PmLockRequest(const CHAR *name)
|
||||
return ret;
|
||||
}
|
||||
|
||||
UINT32 LOS_PmLockRequest(const CHAR *name)
|
||||
{
|
||||
if (name == NULL) {
|
||||
return LOS_ERRNO_PM_INVALID_PARAM;
|
||||
}
|
||||
|
||||
return OsPmLockRequest(name, OS_INVALID);
|
||||
}
|
||||
|
||||
UINT32 LOS_PmLockRelease(const CHAR *name)
|
||||
{
|
||||
UINT32 intSave;
|
||||
UINT32 ret = LOS_ERRNO_PM_NOT_LOCK;
|
||||
LosPmCB *pm = &g_pmCB;
|
||||
#if (LOSCFG_KERNEL_PM_DEBUG == 1)
|
||||
OsPmLockCB *lock = NULL;
|
||||
OsPmLockCB *listNode = NULL;
|
||||
LOS_DL_LIST *head = &pm->lockList;
|
||||
LOS_DL_LIST *list = head->pstNext;
|
||||
VOID *lockFree = NULL;
|
||||
OsPmLockCB *lockFree = NULL;
|
||||
BOOL isRelease = FALSE;
|
||||
UINT32 mode;
|
||||
|
||||
if (name == NULL) {
|
||||
return LOS_ERRNO_PM_INVALID_PARAM;
|
||||
}
|
||||
#endif
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
#if (LOSCFG_KERNEL_PM_DEBUG == 1)
|
||||
mode = (UINT32)pm->pmMode;
|
||||
while (list != head) {
|
||||
listNode = LOS_DL_LIST_ENTRY(list, OsPmLockCB, list);
|
||||
if (strcmp(name, listNode->name) == 0) {
|
||||
@@ -603,25 +635,141 @@ UINT32 LOS_PmLockRelease(const CHAR *name)
|
||||
lockFree = lock;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (pm->lock > 0) {
|
||||
pm->lock--;
|
||||
if (pm->lock == 0) {
|
||||
isRelease = TRUE;
|
||||
}
|
||||
ret = LOS_OK;
|
||||
}
|
||||
|
||||
LOS_IntRestore(intSave);
|
||||
#if (LOSCFG_KERNEL_PM_DEBUG == 1)
|
||||
(VOID)LOS_MemFree((VOID *)OS_SYS_MEM_ADDR, lockFree);
|
||||
#endif
|
||||
|
||||
if (lockFree != NULL) {
|
||||
(VOID)LOS_SwtmrDelete(lockFree->swtmrID);
|
||||
(VOID)LOS_MemFree((VOID *)OS_SYS_MEM_ADDR, lockFree);
|
||||
}
|
||||
|
||||
if (isRelease && (mode > LOS_SYS_NORMAL_SLEEP)) {
|
||||
(VOID)LOS_EventWrite(&g_pmEvent, PM_EVENT_LOCK_RELEASE);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
VOID OsPmFreezeTaskUnsafe(UINT32 taskID)
|
||||
{
|
||||
UINT64 responseTime;
|
||||
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
|
||||
|
||||
responseTime = GET_SORTLIST_VALUE(&taskCB->sortList);
|
||||
OsDeleteSortLink(&taskCB->sortList, OS_SORT_LINK_TASK);
|
||||
SET_SORTLIST_VALUE(&taskCB->sortList, responseTime);
|
||||
taskCB->taskStatus |= OS_TASK_FALG_FREEZE;
|
||||
return;
|
||||
}
|
||||
|
||||
VOID OsPmUnfreezeTaskUnsafe(UINT32 taskID)
|
||||
{
|
||||
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
|
||||
UINT64 currTime, responseTime;
|
||||
UINT32 remainTick;
|
||||
|
||||
taskCB->taskStatus &= ~OS_TASK_FALG_FREEZE;
|
||||
currTime = OsGetCurrSchedTimeCycle();
|
||||
responseTime = GET_SORTLIST_VALUE(&taskCB->sortList);
|
||||
if (responseTime > currTime) {
|
||||
remainTick = ((responseTime - currTime) + OS_CYCLE_PER_TICK - 1) / OS_CYCLE_PER_TICK;
|
||||
OsAdd2SortLink(&taskCB->sortList, currTime, remainTick, OS_SORT_LINK_TASK);
|
||||
return;
|
||||
}
|
||||
|
||||
SET_SORTLIST_VALUE(&taskCB->sortList, OS_SORT_LINK_INVALID_TIME);
|
||||
if (taskCB->taskStatus & OS_TASK_STATUS_PEND) {
|
||||
LOS_ListDelete(&taskCB->pendList);
|
||||
}
|
||||
taskCB->taskStatus &= ~(OS_TASK_STATUS_DELAY | OS_TASK_STATUS_PEND_TIME | OS_TASK_STATUS_PEND);
|
||||
return;
|
||||
}
|
||||
|
||||
STATIC VOID OsPmSwtmrHandler(UINT32 arg)
|
||||
{
|
||||
const CHAR *name = (const CHAR *)arg;
|
||||
UINT32 ret = LOS_PmLockRelease(name);
|
||||
if (ret != LOS_OK) {
|
||||
PRINT_ERR("Pm delay lock %s release faled! : 0x%x\n", name, ret);
|
||||
}
|
||||
}
|
||||
|
||||
UINT32 LOS_PmTimeLockRequest(const CHAR *name, UINT64 millisecond)
|
||||
{
|
||||
UINT32 ticks;
|
||||
UINT32 swtmrID;
|
||||
UINT32 ret;
|
||||
|
||||
if ((name == NULL) || !millisecond) {
|
||||
return LOS_ERRNO_PM_INVALID_PARAM;
|
||||
}
|
||||
|
||||
ticks = (UINT32)((millisecond + OS_MS_PER_TICK - 1) / OS_MS_PER_TICK);
|
||||
#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
|
||||
ret = LOS_SwtmrCreate(ticks, LOS_SWTMR_MODE_ONCE, OsPmSwtmrHandler, &swtmrID, (UINT32)(UINTPTR)name,
|
||||
OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE);
|
||||
#else
|
||||
ret = LOS_SwtmrCreate(ticks, LOS_SWTMR_MODE_ONCE, OsPmSwtmrHandler, &swtmrID, (UINT32)(UINTPTR)name);
|
||||
#endif
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = OsPmLockRequest(name, swtmrID);
|
||||
if (ret != LOS_OK) {
|
||||
(VOID)LOS_SwtmrDelete(swtmrID);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = LOS_SwtmrStart(swtmrID);
|
||||
if (ret != LOS_OK) {
|
||||
(VOID)LOS_PmLockRelease(name);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
UINT32 LOS_PmReadLock(VOID)
|
||||
{
|
||||
UINT32 ret = LOS_EventRead(&g_pmEvent, PM_EVENT_LOCK_MASK, LOS_WAITMODE_OR | LOS_WAITMODE_CLR, LOS_WAIT_FOREVER);
|
||||
if (ret > PM_EVENT_LOCK_MASK) {
|
||||
PRINT_ERR("%s event read failed! ERROR: 0x%x\n", ret);
|
||||
}
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
UINT32 LOS_PmSuspend(UINT32 wakeCount)
|
||||
{
|
||||
(VOID)wakeCount;
|
||||
return OsPmSuspendSleep(&g_pmCB);
|
||||
}
|
||||
|
||||
STATIC VOID OsPmSleepTimeSet(UINT64 sleepTime)
|
||||
{
|
||||
g_pmSleepTime = sleepTime;
|
||||
}
|
||||
|
||||
BOOL OsIsPmMode(VOID)
|
||||
{
|
||||
LosPmCB *pm = &g_pmCB;
|
||||
|
||||
UINT32 intSave = LOS_IntLock();
|
||||
if ((pm->sysMode != LOS_SYS_NORMAL_SLEEP) && (pm->lock == 0)) {
|
||||
LOS_IntRestore(intSave);
|
||||
return TRUE;
|
||||
}
|
||||
LOS_IntRestore(intSave);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
UINT32 OsPmInit(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
@@ -630,16 +778,15 @@ UINT32 OsPmInit(VOID)
|
||||
(VOID)memset_s(pm, sizeof(LosPmCB), 0, sizeof(LosPmCB));
|
||||
|
||||
pm->pmMode = LOS_SYS_NORMAL_SLEEP;
|
||||
#if (LOSCFG_KERNEL_PM_DEBUG == 1)
|
||||
LOS_ListInit(&pm->lockList);
|
||||
#endif
|
||||
(VOID)LOS_EventInit(&g_pmEvent);
|
||||
|
||||
ret = OsSchedRealSleepTimeSet(OsPmSleepTimeSet);
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = OsPmEnterHandlerSet(OsPmEnter);
|
||||
ret = OsPmEnterHandlerSet(OsPmNormalSleep);
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -118,6 +118,15 @@
|
||||
*/
|
||||
#define LOS_ERRNO_PM_DEVICE_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_PM, 0x09)
|
||||
|
||||
/**
|
||||
* @ingroup los_pm
|
||||
* Pm error code: The delay lock has already been activated.
|
||||
*
|
||||
* Value: 0x0200200a
|
||||
*
|
||||
*/
|
||||
#define LOS_ERRNO_PM_ALREADY_LOCK LOS_ERRNO_OS_ERROR(LOS_MOD_PM, 0x0a)
|
||||
|
||||
typedef enum {
|
||||
LOS_SYS_NORMAL_SLEEP = 0,
|
||||
LOS_SYS_LIGHT_SLEEP,
|
||||
@@ -132,8 +141,8 @@ typedef enum {
|
||||
} LOS_PmNodeType;
|
||||
|
||||
typedef struct {
|
||||
UINT32 (*suspend)(UINT32 mode);
|
||||
VOID (*resume)(UINT32 mode);
|
||||
UINT32 (*suspend)(UINT32 mode); /* The device enters low power consumption, Unlocked task scheduling. */
|
||||
VOID (*resume)(UINT32 mode); /* The device exits from low power consumption, Unlocked task scheduling. */
|
||||
} LosPmDevice;
|
||||
|
||||
typedef struct {
|
||||
@@ -146,13 +155,47 @@ typedef struct {
|
||||
} LosPmTickTimer;
|
||||
|
||||
typedef struct {
|
||||
/* Preparations before the CPU enters low power consumption.
|
||||
* All modes except normal mode are invoked.
|
||||
* Unlocked task scheduling.
|
||||
*/
|
||||
UINT32 (*early)(UINT32 mode);
|
||||
/* The system performs low-power recovery.
|
||||
* All modes except normal mode are invoked.
|
||||
* Unlocked task scheduling.
|
||||
*/
|
||||
VOID (*late)(UINT32 mode);
|
||||
/* The system enters the Normal sleep mode.
|
||||
* In normal mode, the value cannot be NULL.
|
||||
*/
|
||||
UINT32 (*normalSuspend)(VOID);
|
||||
/* The system recovers from normal sleep.
|
||||
* The value can be NULL.
|
||||
*/
|
||||
VOID (*normalResume)(VOID);
|
||||
/* The system enters the light sleep mode.
|
||||
* In light sleep mode, the value cannot be NULL.
|
||||
*/
|
||||
UINT32 (*lightSuspend)(VOID);
|
||||
/* The system recovers from light sleep.
|
||||
* The value can be NULL.
|
||||
*/
|
||||
VOID (*lightResume)(VOID);
|
||||
/* The system enters the deep sleep mode.
|
||||
* In deep sleep mode, the value cannot be NULL.
|
||||
*/
|
||||
UINT32 (*deepSuspend)(VOID);
|
||||
/* The system recovers from deep sleep.
|
||||
* The value can be NULL.
|
||||
*/
|
||||
VOID (*deepResume)(VOID);
|
||||
/* The system enters the shutdown mode.
|
||||
* In shutdown mode, the value cannot be NULL.
|
||||
*/
|
||||
UINT32 (*shutdownSuspend)(VOID);
|
||||
/* The system recovers from shutdown.
|
||||
* In shutdown mode, the value cannot be NULL.
|
||||
*/
|
||||
VOID (*shutdownResume)(VOID);
|
||||
} LosPmSysctrl;
|
||||
|
||||
@@ -174,6 +217,60 @@ typedef struct {
|
||||
*/
|
||||
UINT32 OsPmInit(VOID);
|
||||
|
||||
/**
|
||||
* @ingroup los_pm
|
||||
* @brief Whether the low power consumption condition is met.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to check whether low power consumption is met.
|
||||
*
|
||||
* @attention None.
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @retval TRUE or FALSE.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_pm.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see
|
||||
*/
|
||||
BOOL OsIsPmMode(VOID);
|
||||
|
||||
/**
|
||||
* @ingroup los_pm
|
||||
* @brief Freeze delay tasks, internal interfaces between modules.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to freeze delay tasks.
|
||||
*
|
||||
* @attention None.
|
||||
*
|
||||
* @param taskID [IN] task ID.
|
||||
*
|
||||
* @retval None.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_pm.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see OsPmUnfreezeTaskUnsafe
|
||||
*/
|
||||
VOID OsPmFreezeTaskUnsafe(UINT32 taskID);
|
||||
|
||||
/**
|
||||
* @ingroup los_pm
|
||||
* @brief Unfreeze delayed tasks, internal interface between modules.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to unfreeze delayed tasks.
|
||||
*
|
||||
* @attention None.
|
||||
*
|
||||
* @param taskID [IN] task ID.
|
||||
*
|
||||
* @retval None.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_pm.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see OsPmFreezeTaskUnsafe
|
||||
*/
|
||||
VOID OsPmUnfreezeTaskUnsafe(UINT32 taskID);
|
||||
|
||||
/**
|
||||
* @ingroup los_pm
|
||||
* @brief Register a power management node.
|
||||
@@ -285,6 +382,27 @@ UINT32 LOS_PmModeSet(LOS_SysSleepEnum mode);
|
||||
*/
|
||||
UINT32 LOS_PmLockRequest(const CHAR *name);
|
||||
|
||||
/**
|
||||
* @ingroup los_pm
|
||||
* @brief Request to obtain the lock in current mode, so that the system will not enter
|
||||
* this mode when it enters the idle task next time. After the specified interval, the
|
||||
* lock is automatically released.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to obtain the delay lock in current mode.
|
||||
*
|
||||
* @attention None.
|
||||
*
|
||||
* @param name [IN] Who requests the lock.
|
||||
* @param millisecond [IN] Specifies the time to automatically release the lock.
|
||||
*
|
||||
* @retval error code, LOS_OK means success.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_pm.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see LOS_PmLockRelease
|
||||
*/
|
||||
UINT32 LOS_PmTimeLockRequest(const CHAR *name, UINT64 millisecond);
|
||||
|
||||
/**
|
||||
* @ingroup los_pm
|
||||
* @brief Release the lock in current mode so that the next time the system enters
|
||||
@@ -304,7 +422,42 @@ UINT32 LOS_PmLockRequest(const CHAR *name);
|
||||
*/
|
||||
UINT32 LOS_PmLockRelease(const CHAR *name);
|
||||
|
||||
#if (LOSCFG_KERNEL_PM_DEBUG == 1)
|
||||
/**
|
||||
* @ingroup los_pm
|
||||
* @brief Gets the current PM lock status.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to Get the current PM lock status.
|
||||
*
|
||||
* @attention None.
|
||||
*
|
||||
* @param NA.
|
||||
*
|
||||
* @retval Number of awakening sources of the device.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_pm.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see
|
||||
*/
|
||||
UINT32 LOS_PmReadLock(VOID);
|
||||
|
||||
/**
|
||||
* @ingroup los_pm
|
||||
* @brief The system enters the low-power flow.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to enter the system into a low-power process.
|
||||
*
|
||||
* @attention None.
|
||||
*
|
||||
* @param wakeCount [IN] Number of wake sources.
|
||||
*
|
||||
* @retval error code, LOS_OK means success.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_pm.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see
|
||||
*/
|
||||
UINT32 LOS_PmSuspend(UINT32 wakeCount);
|
||||
|
||||
/**
|
||||
* @ingroup los_pm
|
||||
* @brief Output the locking information of the pm lock.
|
||||
@@ -323,4 +476,3 @@ UINT32 LOS_PmLockRelease(const CHAR *name);
|
||||
*/
|
||||
VOID LOS_PmLockInfoShow(VOID);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -39,27 +39,6 @@
|
||||
#define OS_INVALID_SEM_ID 0xFFFFFFFF
|
||||
#define OS_ALL_TASK_MASK 0xFFFFFFFF
|
||||
|
||||
LITE_OS_SEC_TEXT_MINOR UINT8 *OsShellCmdConvertTskStatus(UINT16 taskStatus)
|
||||
{
|
||||
if (taskStatus & OS_TASK_STATUS_RUNNING) {
|
||||
return (UINT8 *)"Running";
|
||||
} else if (taskStatus & OS_TASK_STATUS_READY) {
|
||||
return (UINT8 *)"Ready";
|
||||
} else {
|
||||
if (taskStatus & OS_TASK_STATUS_DELAY) {
|
||||
return (UINT8 *)"Delay";
|
||||
} else if (taskStatus & OS_TASK_STATUS_PEND_TIME) {
|
||||
return (UINT8 *)"PendTime";
|
||||
} else if (taskStatus & OS_TASK_STATUS_PEND) {
|
||||
return (UINT8 *)"Pend";
|
||||
} else if (taskStatus & OS_TASK_STATUS_SUSPEND) {
|
||||
return (UINT8 *)"Suspend";
|
||||
}
|
||||
}
|
||||
|
||||
return (UINT8 *)"Invalid";
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_MINOR STATIC VOID OsShellCmdTskInfoTitle(VOID)
|
||||
{
|
||||
PRINTK("Name TaskEntryAddr TID ");
|
||||
@@ -105,7 +84,7 @@ LITE_OS_SEC_TEXT_MINOR STATIC VOID OsShellCmdTskInfoData(const LosTaskCB *allTas
|
||||
return;
|
||||
}
|
||||
(VOID)memset_s(getUsedSizeArray, arraySize, 0, arraySize);
|
||||
OsTaskMemUsed(m_aucSysMem0, getUsedSizeArray, arraySize);
|
||||
OsTaskMemUsed(m_aucSysMem0, getUsedSizeArray, (LOSCFG_BASE_CORE_TSK_LIMIT + 1));
|
||||
#endif
|
||||
|
||||
for (loop = 0; loop < g_taskMaxNum; ++loop) {
|
||||
@@ -119,11 +98,11 @@ LITE_OS_SEC_TEXT_MINOR STATIC VOID OsShellCmdTskInfoData(const LosTaskCB *allTas
|
||||
PRINTK("%-23s%-20p0x%-5x", taskCB->taskName, taskCB->taskEntry, taskCB->taskID);
|
||||
#if (LOSCFG_TASK_MEM_USED == 1)
|
||||
PRINTK("%-11u%-13s0x%-11x 0x%-11x 0x%-8x 0x%-10x ", taskCB->priority,
|
||||
OsShellCmdConvertTskStatus(taskCB->taskStatus), getUsedSizeArray[loop], taskCB->stackSize,
|
||||
OsConvertTskStatus(taskCB->taskStatus), getUsedSizeArray[loop], taskCB->stackSize,
|
||||
taskCB->stackPointer, taskCB->topOfStack, semId);
|
||||
#else
|
||||
PRINTK("%-11u%-13s0x%-11x 0x%-8x 0x%-10x ", taskCB->priority,
|
||||
OsShellCmdConvertTskStatus(taskCB->taskStatus), taskCB->stackSize,
|
||||
OsConvertTskStatus(taskCB->taskStatus), taskCB->stackSize,
|
||||
taskCB->stackPointer, taskCB->topOfStack, semId);
|
||||
#endif
|
||||
PRINTK("\n");
|
||||
|
||||
@@ -287,7 +287,6 @@ typedef struct {
|
||||
*
|
||||
* @par Dependency:
|
||||
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
|
||||
* @since Huawei LiteOS V200R005C00
|
||||
*/
|
||||
typedef BOOL (*TRACE_HWI_FILTER_HOOK)(UINT32 hwiNum);
|
||||
|
||||
@@ -391,7 +390,6 @@ extern TRACE_EVENT_HOOK g_traceEventHook;
|
||||
*
|
||||
* @par Dependency:
|
||||
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
|
||||
* @since Huawei LiteOS V200R005C00
|
||||
*/
|
||||
#define LOS_TRACE(TYPE, IDENTITY, ...) \
|
||||
do { \
|
||||
@@ -423,7 +421,6 @@ extern TRACE_EVENT_HOOK g_traceEventHook;
|
||||
*
|
||||
* @par Dependency:
|
||||
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
|
||||
* @since Huawei LiteOS V200R005C00
|
||||
*/
|
||||
#define LOS_TRACE_EASY(TYPE, IDENTITY, ...) \
|
||||
do { \
|
||||
@@ -461,7 +458,6 @@ extern TRACE_EVENT_HOOK g_traceEventHook;
|
||||
* @par Dependency:
|
||||
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see LOS_TraceInit
|
||||
* @since Huawei LiteOS V200R005C00
|
||||
*/
|
||||
extern UINT32 LOS_TraceInit(VOID *buf, UINT32 size);
|
||||
|
||||
@@ -483,7 +479,6 @@ extern UINT32 LOS_TraceInit(VOID *buf, UINT32 size);
|
||||
* @par Dependency:
|
||||
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see LOS_TraceStart
|
||||
* @since Huawei LiteOS V200R005C00
|
||||
*/
|
||||
extern UINT32 LOS_TraceStart(VOID);
|
||||
|
||||
@@ -504,7 +499,6 @@ extern UINT32 LOS_TraceStart(VOID);
|
||||
* @par Dependency:
|
||||
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see LOS_TraceStop
|
||||
* @since Huawei LiteOS V200R005C00
|
||||
*/
|
||||
extern VOID LOS_TraceStop(VOID);
|
||||
|
||||
@@ -525,7 +519,6 @@ extern VOID LOS_TraceStop(VOID);
|
||||
* @par Dependency:
|
||||
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see LOS_TraceReset
|
||||
* @since Huawei LiteOS V200R005C00
|
||||
*/
|
||||
extern VOID LOS_TraceReset(VOID);
|
||||
|
||||
@@ -549,7 +542,6 @@ extern VOID LOS_TraceReset(VOID);
|
||||
* @par Dependency:
|
||||
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see LOS_TraceEventMaskSet
|
||||
* @since Huawei LiteOS V200R005C00
|
||||
*/
|
||||
extern VOID LOS_TraceEventMaskSet(UINT32 mask);
|
||||
|
||||
@@ -572,7 +564,6 @@ extern VOID LOS_TraceEventMaskSet(UINT32 mask);
|
||||
* @par Dependency:
|
||||
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see LOS_TraceRecordDump
|
||||
* @since Huawei LiteOS V200R005C00
|
||||
*/
|
||||
extern VOID LOS_TraceRecordDump(BOOL toClient);
|
||||
|
||||
@@ -595,7 +586,6 @@ extern VOID LOS_TraceRecordDump(BOOL toClient);
|
||||
* @par Dependency:
|
||||
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see LOS_TraceRecordGet
|
||||
* @since Huawei LiteOS V200R005C00
|
||||
*/
|
||||
extern OfflineHead *LOS_TraceRecordGet(VOID);
|
||||
|
||||
@@ -616,7 +606,6 @@ extern OfflineHead *LOS_TraceRecordGet(VOID);
|
||||
* @par Dependency:
|
||||
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see LOS_TraceHwiFilterHookReg
|
||||
* @since Huawei LiteOS V200R005C00
|
||||
*/
|
||||
extern VOID LOS_TraceHwiFilterHookReg(TRACE_HWI_FILTER_HOOK hook);
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -85,7 +85,6 @@ typedef struct {
|
||||
* @par Dependency:
|
||||
* <ul><li>trace_tlv.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see LOS_TraceDataEncode
|
||||
* @since Huawei LiteOS V200R005C00
|
||||
*/
|
||||
extern UINT32 OsTraceDataEncode(UINT8 type, const TlvTable *table, UINT8 *src, UINT8 *dest, INT32 destLen);
|
||||
|
||||
|
||||
@@ -299,7 +299,9 @@ osThreadId_t osThreadNew(osThreadFunc_t func, void *argument, const osThreadAttr
|
||||
stTskInitParam.uwStackSize = attr ? attr->stack_size : LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
stTskInitParam.pcName = (CHAR *)(attr ? attr->name : "[NULL]");
|
||||
stTskInitParam.usTaskPrio = usPriority;
|
||||
|
||||
if (attr->attr_bits == osThreadJoinable) {
|
||||
stTskInitParam.uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
}
|
||||
uwRet = LOS_TaskCreate(&uwTid, &stTskInitParam);
|
||||
|
||||
if (LOS_OK != uwRet) {
|
||||
@@ -576,6 +578,46 @@ osStatus_t osThreadResume(osThreadId_t thread_id)
|
||||
}
|
||||
|
||||
|
||||
osStatus_t osThreadDetach(osThreadId_t thread_id)
|
||||
{
|
||||
UINT32 ret;
|
||||
LosTaskCB *taskCB = (LosTaskCB *)thread_id;
|
||||
|
||||
if (thread_id == NULL) {
|
||||
return osErrorParameter;
|
||||
}
|
||||
|
||||
ret = LOS_TaskDetach(taskCB->taskID);
|
||||
if (ret == LOS_ERRNO_TSK_NOT_ALLOW_IN_INT) {
|
||||
return osErrorISR;
|
||||
} else if (ret != LOS_OK) {
|
||||
return osErrorResource;
|
||||
}
|
||||
|
||||
return osOK;
|
||||
}
|
||||
|
||||
|
||||
osStatus_t osThreadJoin(osThreadId_t thread_id)
|
||||
{
|
||||
UINT32 ret;
|
||||
LosTaskCB *taskCB = (LosTaskCB *)thread_id;
|
||||
|
||||
if (thread_id == NULL) {
|
||||
return osErrorParameter;
|
||||
}
|
||||
|
||||
ret = LOS_TaskJoin(taskCB->taskID, NULL);
|
||||
if (ret == LOS_ERRNO_TSK_NOT_ALLOW_IN_INT) {
|
||||
return osErrorISR;
|
||||
} else if (ret != LOS_OK) {
|
||||
return osErrorResource;
|
||||
}
|
||||
|
||||
return osOK;
|
||||
}
|
||||
|
||||
|
||||
osStatus_t osThreadTerminate(osThreadId_t thread_id)
|
||||
{
|
||||
UINT32 uwRet;
|
||||
@@ -1087,8 +1129,9 @@ osStatus_t osMutexDelete(osMutexId_t mutex_id)
|
||||
|
||||
osSemaphoreId_t osSemaphoreNew(uint32_t max_count, uint32_t initial_count, const osSemaphoreAttr_t *attr)
|
||||
{
|
||||
UINT32 uwRet;
|
||||
UINT32 uwRet = LOS_NOK;
|
||||
UINT32 uwSemId;
|
||||
UINT32 intSave;
|
||||
|
||||
UNUSED(attr);
|
||||
|
||||
@@ -1096,14 +1139,16 @@ osSemaphoreId_t osSemaphoreNew(uint32_t max_count, uint32_t initial_count, const
|
||||
return (osSemaphoreId_t)NULL;
|
||||
}
|
||||
|
||||
if (1 == max_count) {
|
||||
uwRet = LOS_BinarySemCreate((UINT16)initial_count, &uwSemId);
|
||||
} else {
|
||||
if (max_count > 0 && max_count <= OS_SEM_COUNTING_MAX_COUNT) {
|
||||
uwRet = LOS_SemCreate((UINT16)initial_count, &uwSemId);
|
||||
}
|
||||
|
||||
if (uwRet == LOS_OK) {
|
||||
return (osSemaphoreId_t)(GET_SEM(uwSemId));
|
||||
osSemaphoreId_t semaphore_id = (osSemaphoreId_t)(GET_SEM(uwSemId));
|
||||
intSave = LOS_IntLock();
|
||||
((LosSemCB *)semaphore_id)->maxSemCount = max_count;
|
||||
LOS_IntRestore(intSave);
|
||||
return semaphore_id;
|
||||
} else {
|
||||
return (osSemaphoreId_t)NULL;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <securec.h>
|
||||
#include <limits.h>
|
||||
#include "los_config.h"
|
||||
#include "los_task.h"
|
||||
|
||||
@@ -43,7 +44,7 @@ typedef struct {
|
||||
void *(*startRoutine)(void *);
|
||||
void *param;
|
||||
char name[PTHREAD_NAMELEN];
|
||||
}PthreadData;
|
||||
} PthreadData;
|
||||
|
||||
static void *PthreadEntry(UINT32 param)
|
||||
{
|
||||
@@ -56,34 +57,39 @@ static void *PthreadEntry(UINT32 param)
|
||||
|
||||
static inline int IsPthread(pthread_t thread)
|
||||
{
|
||||
return ((UINT32)thread <= LOSCFG_BASE_CORE_TSK_LIMIT) &&
|
||||
(OS_TCB_FROM_TID((UINT32)thread)->taskEntry == PthreadEntry);
|
||||
return ((UINT32)thread <= LOSCFG_BASE_CORE_TSK_LIMIT);
|
||||
}
|
||||
|
||||
int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
|
||||
void *(*startRoutine)(void *), void *arg)
|
||||
static int PthreadCreateAttrInit(const pthread_attr_t *attr, void *(*startRoutine)(void *), void *arg,
|
||||
TSK_INIT_PARAM_S *taskInitParam)
|
||||
{
|
||||
TSK_INIT_PARAM_S taskInitParam = {0};
|
||||
const pthread_attr_t *threadAttr = attr;
|
||||
struct sched_param schedParam = { 0 };
|
||||
PthreadData *pthreadData = NULL;
|
||||
UINT32 taskID;
|
||||
INT32 policy = 0;
|
||||
pthread_attr_t attrTmp;
|
||||
INT32 ret;
|
||||
|
||||
if ((thread == NULL) || (startRoutine == NULL)) {
|
||||
return EINVAL;
|
||||
if (!attr) {
|
||||
(VOID)pthread_attr_init(&attrTmp);
|
||||
threadAttr = &attrTmp;
|
||||
}
|
||||
|
||||
taskInitParam.usTaskPrio = LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO;
|
||||
taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
if (attr) {
|
||||
if (attr->detachstate == PTHREAD_CREATE_DETACHED) {
|
||||
return ENOTSUP;
|
||||
if (threadAttr->stackaddr_set != 0) {
|
||||
return ENOTSUP;
|
||||
}
|
||||
if (threadAttr->stacksize < PTHREAD_STACK_MIN) {
|
||||
return EINVAL;
|
||||
}
|
||||
taskInitParam->uwStackSize = threadAttr->stacksize;
|
||||
if (threadAttr->inheritsched == PTHREAD_EXPLICIT_SCHED) {
|
||||
taskInitParam->usTaskPrio = (UINT16)threadAttr->schedparam.sched_priority;
|
||||
} else {
|
||||
ret = pthread_getschedparam(pthread_self(), &policy, &schedParam);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
if (attr->stackaddr_set) {
|
||||
return ENOTSUP;
|
||||
}
|
||||
if (attr->stacksize_set) {
|
||||
taskInitParam.uwStackSize = attr->stacksize;
|
||||
}
|
||||
taskInitParam.usTaskPrio = (UINT16)attr->schedparam.sched_priority;
|
||||
taskInitParam->usTaskPrio = (UINT16)schedParam.sched_priority;
|
||||
}
|
||||
|
||||
pthreadData = (PthreadData *)malloc(sizeof(PthreadData));
|
||||
@@ -91,14 +97,35 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
pthreadData->startRoutine = startRoutine;
|
||||
pthreadData->param = arg;
|
||||
taskInitParam.pcName = pthreadData->name;
|
||||
taskInitParam.pfnTaskEntry = PthreadEntry;
|
||||
taskInitParam.uwArg = (UINT32)(UINTPTR)pthreadData;
|
||||
pthreadData->startRoutine = startRoutine;
|
||||
pthreadData->param = arg;
|
||||
taskInitParam->pcName = pthreadData->name;
|
||||
taskInitParam->pfnTaskEntry = PthreadEntry;
|
||||
taskInitParam->uwArg = (UINT32)(UINTPTR)pthreadData;
|
||||
if (threadAttr->detachstate != PTHREAD_CREATE_DETACHED) {
|
||||
taskInitParam->uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
|
||||
void *(*startRoutine)(void *), void *arg)
|
||||
{
|
||||
TSK_INIT_PARAM_S taskInitParam = { 0 };
|
||||
UINT32 taskID;
|
||||
UINT32 ret;
|
||||
|
||||
if ((thread == NULL) || (startRoutine == NULL)) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
ret = PthreadCreateAttrInit(attr, startRoutine, arg, &taskInitParam);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (LOS_TaskCreateOnly(&taskID, &taskInitParam) != LOS_OK) {
|
||||
free(pthreadData);
|
||||
free((VOID *)(UINTPTR)taskInitParam.uwArg);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
@@ -164,55 +191,62 @@ int pthread_cancel(pthread_t thread)
|
||||
|
||||
int pthread_join(pthread_t thread, void **retval)
|
||||
{
|
||||
UINT32 taskStatus;
|
||||
|
||||
if (!IsPthread(thread)) {
|
||||
UINTPTR result;
|
||||
UINT32 ret = LOS_TaskJoin((UINT32)thread, &result);
|
||||
if (ret == LOS_ERRNO_TSK_NOT_JOIN_SELF) {
|
||||
return EDEADLK;
|
||||
} else if (ret != LOS_OK) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if (retval) {
|
||||
/* retrieve thread exit code is not supported currently */
|
||||
return ENOTSUP;
|
||||
if (retval != NULL) {
|
||||
*retval = (VOID *)result;
|
||||
}
|
||||
|
||||
if (thread == pthread_self()) {
|
||||
return EDEADLK;
|
||||
}
|
||||
|
||||
while (LOS_TaskStatusGet((UINT32)thread, &taskStatus) == LOS_OK) {
|
||||
(void)LOS_TaskDelay(10); /* 10: Waiting for the end of thread execution. */
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_detach(pthread_t thread)
|
||||
{
|
||||
if (!IsPthread(thread)) {
|
||||
UINT32 ret = LOS_TaskDetach((UINT32)thread);
|
||||
if (ret == LOS_ERRNO_TSK_NOT_JOIN) {
|
||||
return ESRCH;
|
||||
} else if (ret != LOS_OK) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
return ENOSYS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void pthread_exit(void *retVal)
|
||||
{
|
||||
(void)retVal;
|
||||
LosTaskCB *tcb = OS_TCB_FROM_TID(LOS_CurTaskIDGet());
|
||||
tcb->joinRetval = (UINTPTR)retVal;
|
||||
free((PthreadData *)(UINTPTR)tcb->arg);
|
||||
(void)LOS_TaskDelete(LOS_CurTaskIDGet());
|
||||
(void)LOS_TaskDelete(tcb->taskID);
|
||||
}
|
||||
|
||||
int pthread_setname_np(pthread_t thread, const char *name)
|
||||
{
|
||||
UINT32 intSave;
|
||||
LosTaskCB *taskCB = NULL;
|
||||
char *taskName = LOS_TaskNameGet((UINT32)thread);
|
||||
if (taskName == NULL || !IsPthread(thread)) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if (strnlen(name, PTHREAD_NAMELEN) >= PTHREAD_NAMELEN) {
|
||||
return ERANGE;
|
||||
}
|
||||
(void)strcpy_s(taskName, PTHREAD_NAMELEN, name);
|
||||
|
||||
taskCB = OS_TCB_FROM_TID((UINT32)thread);
|
||||
intSave = LOS_IntLock();
|
||||
if (taskCB->taskEntry == PthreadEntry) {
|
||||
(void)strcpy_s(taskName, PTHREAD_NAMELEN, name);
|
||||
} else {
|
||||
LOS_IntRestore(intSave);
|
||||
return EINVAL;
|
||||
}
|
||||
LOS_IntRestore(intSave);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ STATIC UINT32 HalMpuEncodeSize(UINT64 size)
|
||||
if (size > SIZE_4G_BYTE) {
|
||||
return 0;
|
||||
}
|
||||
if ((size & 0x1F) != 0) { /* size sould aligned to 32 byte at least. */
|
||||
if ((size & 0x1F) != 0) { /* size should aligned to 32 byte at least. */
|
||||
return 0;
|
||||
}
|
||||
size = (size >> 2);
|
||||
|
||||
@@ -97,7 +97,7 @@ STATIC UINT32 HalMpuEncodeSize(UINT64 size)
|
||||
if (size > SIZE_4G_BYTE) {
|
||||
return 0;
|
||||
}
|
||||
if ((size & 0x1F) != 0) { /* size sould aligned to 32 byte at least. */
|
||||
if ((size & 0x1F) != 0) { /* size should aligned to 32 byte at least. */
|
||||
return 0;
|
||||
}
|
||||
size = (size >> 2);
|
||||
|
||||
@@ -35,6 +35,7 @@ static_library("arch") {
|
||||
"los_dispatch.S",
|
||||
"los_exc.S",
|
||||
"los_interrupt.c",
|
||||
"los_mpu.c",
|
||||
"los_timer.c",
|
||||
]
|
||||
|
||||
|
||||
237
kernel/arch/arm/cortex-m7/gcc/los_mpu.c
Normal file
237
kernel/arch/arm/cortex-m7/gcc/los_mpu.c
Normal file
@@ -0,0 +1,237 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "los_mpu.h"
|
||||
#include "los_config.h"
|
||||
#include "los_context.h"
|
||||
|
||||
#if (LOSCFG_MPU_ENABLE == 1)
|
||||
|
||||
#define SIZE_4G_BYTE 0x100000000
|
||||
#define MPU_MAX_REGION_NUM 8
|
||||
|
||||
STATIC UINT8 g_regionNumBeUsed[MPU_MAX_REGION_NUM] = {0};
|
||||
|
||||
typedef enum {
|
||||
MPU_AP_FORBID_USER_FORBID = 0x0, /* Privileged:No access Unprivileged:No access */
|
||||
MPU_AP_RW_USER_FORBID = 0x1, /* Privileged:Read/Write Unprivileged:No access */
|
||||
MPU_AP_RW_USER_RO = 0x2, /* Privileged:Read/Write Unprivileged:Read-only */
|
||||
MPU_AP_RW_USER_RW = 0x3, /* Privileged:Read/Write Unprivileged:Read/Write */
|
||||
MPU_AP_NA_USER_NA = 0x4, /* Privileged:UNPREDICTABLE Unprivileged:UNPREDICTABLE */
|
||||
MPU_AP_RO_USER_FORBID = 0x5, /* Privileged:Read-only Unprivileged:No access */
|
||||
MPU_AP_RO_USER_RO = 0x6, /* Privileged:Read-only Unprivileged:Read-only */
|
||||
} MpuApConfig;
|
||||
|
||||
VOID HalMpuEnable(UINT32 defaultRegionEnable)
|
||||
{
|
||||
UINT32 intSave = HalIntLock();
|
||||
MPU->CTRL = (MPU_CTRL_ENABLE_Msk | ((defaultRegionEnable << MPU_CTRL_PRIVDEFENA_Pos) & MPU_CTRL_PRIVDEFENA_Msk));
|
||||
SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk;
|
||||
__DSB();
|
||||
__ISB();
|
||||
HalIntRestore(intSave);
|
||||
}
|
||||
VOID HalMpuDisable(VOID)
|
||||
{
|
||||
UINT32 intSave = HalIntLock();
|
||||
MPU->CTRL = 0;
|
||||
__DSB();
|
||||
__ISB();
|
||||
HalIntRestore(intSave);
|
||||
}
|
||||
|
||||
STATIC VOID HalMpuRASRAddMemAttr(MPU_CFG_PARA *para, UINT32 *RASR)
|
||||
{
|
||||
BOOL cachable = 0;
|
||||
BOOL buffable = 0;
|
||||
switch (para->memType) {
|
||||
case MPU_MEM_ON_CHIP_ROM:
|
||||
case MPU_MEM_ON_CHIP_RAM:
|
||||
cachable = 1;
|
||||
buffable = 0;
|
||||
break;
|
||||
case MPU_MEM_XIP_PSRAM:
|
||||
cachable = 1;
|
||||
buffable = 1;
|
||||
break;
|
||||
case MPU_MEM_XIP_NOR_FLASH:
|
||||
cachable = 0;
|
||||
buffable = 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
(*RASR) |= ((cachable << MPU_RASR_C_Pos) | (buffable << MPU_RASR_B_Pos));
|
||||
}
|
||||
|
||||
STATIC UINT32 HalMpuEncodeSize(UINT64 size)
|
||||
{
|
||||
UINT32 encodeSize = 0;
|
||||
if (size > SIZE_4G_BYTE) {
|
||||
return 0;
|
||||
}
|
||||
if ((size & 0x1F) != 0) { /* size should aligned to 32 byte at least. */
|
||||
return 0;
|
||||
}
|
||||
size = (size >> 2);
|
||||
while (size != 0) {
|
||||
if (((size & 1) != 0) && ((size & 0xFFFFFFFE) != 0)) { /* size != 2^x (5 <= x <= 32) 128B - 4GB */
|
||||
return 0;
|
||||
}
|
||||
size = (size >> 1);
|
||||
encodeSize++;
|
||||
}
|
||||
return encodeSize;
|
||||
}
|
||||
|
||||
STATIC UINT32 HalMpuEncodeAP(MpuAccessPermission permission)
|
||||
{
|
||||
UINT32 ap;
|
||||
switch (permission) {
|
||||
case MPU_RW_BY_PRIVILEGED_ONLY:
|
||||
ap = MPU_AP_RW_USER_FORBID;
|
||||
break;
|
||||
case MPU_RW_ANY:
|
||||
ap = MPU_AP_RW_USER_RW;
|
||||
break;
|
||||
case MPU_RO_BY_PRIVILEGED_ONLY:
|
||||
ap = MPU_AP_RO_USER_FORBID;
|
||||
break;
|
||||
case MPU_RO_ANY:
|
||||
ap = MPU_AP_RO_USER_RO;
|
||||
break;
|
||||
default:
|
||||
ap = MPU_AP_RW_USER_RW;
|
||||
break;
|
||||
}
|
||||
return ap;
|
||||
}
|
||||
|
||||
STATIC UINT32 HalMpuGetRASR(UINT32 encodeSize, MPU_CFG_PARA *para)
|
||||
{
|
||||
UINT32 RASR;
|
||||
UINT32 ap;
|
||||
ap = HalMpuEncodeAP(para->permission);
|
||||
RASR = MPU_RASR_ENABLE_Msk;
|
||||
RASR |= ((encodeSize << MPU_RASR_SIZE_Pos) & MPU_RASR_SIZE_Msk);
|
||||
RASR |= ((ap << MPU_RASR_AP_Pos) & MPU_RASR_AP_Msk) | ((para->executable << MPU_RASR_XN_Pos) & MPU_RASR_XN_Msk) |
|
||||
((para->shareability << MPU_RASR_S_Pos) & MPU_RASR_S_Msk);
|
||||
HalMpuRASRAddMemAttr(para, &RASR);
|
||||
return RASR;
|
||||
}
|
||||
|
||||
UINT32 HalMpuSetRegion(UINT32 regionId, MPU_CFG_PARA *para)
|
||||
{
|
||||
UINT32 RASR;
|
||||
UINT32 RBAR;
|
||||
UINT32 RNR;
|
||||
UINT32 encodeSize;
|
||||
UINT32 intSave;
|
||||
UINT64 size;
|
||||
|
||||
if ((regionId >= MPU_MAX_REGION_NUM) || (para == NULL)) {
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
if ((MPU_TYPE_DREGION_Msk & MPU->TYPE) == 0) {
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
RNR = regionId;
|
||||
encodeSize = HalMpuEncodeSize(para->size);
|
||||
if (encodeSize == 0) {
|
||||
return LOS_NOK;
|
||||
}
|
||||
size = para->size - 1; /* size aligned after encode check */
|
||||
if ((para->baseAddr & size) != 0) { /* base addr should aligned to region size */
|
||||
return LOS_NOK;
|
||||
}
|
||||
RBAR = para->baseAddr & MPU_RBAR_ADDR_Msk;
|
||||
RASR = HalMpuGetRASR(encodeSize, para);
|
||||
intSave = HalIntLock();
|
||||
if (g_regionNumBeUsed[regionId]) {
|
||||
HalIntRestore(intSave);
|
||||
return LOS_NOK;
|
||||
}
|
||||
MPU->RNR = RNR;
|
||||
MPU->RBAR = RBAR;
|
||||
MPU->RASR = RASR;
|
||||
__DSB();
|
||||
__ISB();
|
||||
g_regionNumBeUsed[regionId] = 1; /* Set mpu region used flag */
|
||||
HalIntRestore(intSave);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
UINT32 HalMpuDisableRegion(UINT32 regionId)
|
||||
{
|
||||
volatile UINT32 type;
|
||||
UINT32 intSave;
|
||||
|
||||
if (regionId >= MPU_MAX_REGION_NUM) {
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
intSave = HalIntLock();
|
||||
if (!g_regionNumBeUsed[regionId]) {
|
||||
HalIntRestore(intSave);
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
type = MPU->TYPE;
|
||||
if ((MPU_TYPE_DREGION_Msk & type) != 0) {
|
||||
MPU->RNR = regionId;
|
||||
MPU->RASR = 0;
|
||||
__DSB();
|
||||
__ISB();
|
||||
}
|
||||
g_regionNumBeUsed[regionId] = 0; /* clear mpu region used flag */
|
||||
HalIntRestore(intSave);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
INT32 HalMpuUnusedRegionGet(VOID)
|
||||
{
|
||||
INT32 id;
|
||||
UINT32 intSave = HalIntLock();
|
||||
for (id = 0; id < MPU_MAX_REGION_NUM; id++) {
|
||||
if (!g_regionNumBeUsed[id]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
HalIntRestore(intSave);
|
||||
|
||||
if (id == MPU_MAX_REGION_NUM) {
|
||||
return -1;
|
||||
} else {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -97,7 +97,7 @@ STATIC UINT32 HalMpuEncodeSize(UINT64 size)
|
||||
if (size > SIZE_4G_BYTE) {
|
||||
return 0;
|
||||
}
|
||||
if ((size & 0x1F) != 0) { /* size sould aligned to 32 byte at least. */
|
||||
if ((size & 0x1F) != 0) { /* size should aligned to 32 byte at least. */
|
||||
return 0;
|
||||
}
|
||||
size = (size >> 2);
|
||||
|
||||
@@ -52,12 +52,17 @@ WEAK UINT32 HalTickStart(OS_TICK_HANDLER handler)
|
||||
|
||||
WEAK VOID HalSysTickReload(UINT64 nextResponseTime)
|
||||
{
|
||||
UINT64 timeMax = (UINT64)LOSCFG_BASE_CORE_TICK_RESPONSE_MAX - 1;
|
||||
UINT64 timer;
|
||||
UINT32 timerL, timerH;
|
||||
READ_UINT32(timerL, MTIMER);
|
||||
READ_UINT32(timerH, MTIMER + MTIMER_HI_OFFSET);
|
||||
timer = OS_COMBINED_64(timerH, timerL);
|
||||
timer += nextResponseTime;
|
||||
if ((timeMax - nextResponseTime) > timer) {
|
||||
timer += nextResponseTime;
|
||||
} else {
|
||||
timer = timeMax;
|
||||
}
|
||||
|
||||
HalIrqDisable(RISCV_MACH_TIMER_IRQ);
|
||||
WRITE_UINT32(0xffffffff, MTIMERCMP + MTIMER_HI_OFFSET);
|
||||
|
||||
@@ -781,6 +781,10 @@ extern UINT8 *m_aucSysMem0;
|
||||
#define LOSCFG_MPU_ENABLE 0
|
||||
#endif
|
||||
|
||||
#if (LOSCFG_EXC_HARDWARE_STACK_PROTECTION == 1) && (LOSCFG_MPU_ENABLE == 0)
|
||||
#error "if hardware stack protection is enabled, then MPU should be supported and enabled"
|
||||
#endif
|
||||
|
||||
/*=============================================================================
|
||||
shell module configuration
|
||||
=============================================================================*/
|
||||
|
||||
@@ -469,7 +469,7 @@ extern UINT32 LOS_MemIntegrityCheck(const VOID *pool);
|
||||
extern VOID LOS_MemUnlockEnable(VOID *pool);
|
||||
|
||||
extern UINT32 OsMemSystemInit(VOID);
|
||||
extern VOID OsTaskMemUsed(VOID *pool, UINT32 *outArray, UINT32 arraySize);
|
||||
extern VOID OsTaskMemUsed(VOID *pool, UINT32 *tskMemInfoBuf, UINT32 tskMemInfoCnt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
@@ -341,7 +341,7 @@ extern "C" {
|
||||
*/
|
||||
#define OS_WAIT_TASK_ARRAY_LEN ((LOSCFG_BASE_CORE_TSK_LIMIT >> 5) + 1)
|
||||
#define OS_WAIT_TASK_ID_TO_ARRAY_IDX(taskID) (taskID >> 5)
|
||||
#define OS_WAIT_TASK_ARRAY_ELEMENT_MASK ((1 << OS_WAIT_TASK_ARRAY_LEN) - 1)
|
||||
#define OS_WAIT_TASK_ARRAY_ELEMENT_MASK (31)
|
||||
|
||||
/**
|
||||
* @ingroup los_queue
|
||||
|
||||
@@ -369,8 +369,66 @@ extern "C" {
|
||||
*/
|
||||
#define LOS_ERRNO_TSK_OPERATE_SWTMR LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x22)
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Task error code: Task timeout.
|
||||
*
|
||||
* Value: 0x02000223
|
||||
*
|
||||
* Solution: Check whether the waiting time and timeout are reasonable.
|
||||
*/
|
||||
#define LOS_ERRNO_TSK_TIMEOUT LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x23)
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Task error code: This task cannot wait for other tasks to finish.
|
||||
*
|
||||
* Value: 0x02000224
|
||||
*
|
||||
* Solution: Check the task properties and whether it is waiting for other tasks to finish.
|
||||
*/
|
||||
#define LOS_ERRNO_TSK_NOT_JOIN LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x24)
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Task error code: Tasks can't join himself.
|
||||
*
|
||||
* Value: 0x02000225
|
||||
*
|
||||
* Solution: Check whether the task ID is the current running task.
|
||||
*/
|
||||
#define LOS_ERRNO_TSK_NOT_JOIN_SELF LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x25)
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Task error code: This task operation is not allowed to be performed in an interrupt.
|
||||
*
|
||||
* Value: 0x02000226
|
||||
*
|
||||
* Solution: Check whether the interface is used in interrupts.
|
||||
*/
|
||||
#define LOS_ERRNO_TSK_NOT_ALLOW_IN_INT LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x26)
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Task error code: An exited task cannot be deleted.
|
||||
*
|
||||
* Value: 0x02000227
|
||||
*
|
||||
* Solution: Check whether a Joinable task exists. If so, call LOS_TaskJoin to reclaim resources.
|
||||
*/
|
||||
#define LOS_ERRNO_TSK_ALREADY_EXIT LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x27)
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Task error code: Locked scheduling does not allow tasks to be blocked.
|
||||
*
|
||||
* Value: 0x02000228
|
||||
*
|
||||
* Solution: Check for faulty lock scheduling logic.
|
||||
*/
|
||||
#define LOS_ERRNO_TSK_SCHED_LOCKED LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x28)
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Define the type of the task entry function.
|
||||
@@ -393,17 +451,21 @@ typedef struct tagTskInitParam {
|
||||
UINT32 uwResved; /**< Reserved */
|
||||
} TSK_INIT_PARAM_S;
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Task detach attribute.
|
||||
*/
|
||||
#define LOS_TASK_ATTR_JOINABLE 0x80000000
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Task name length
|
||||
*
|
||||
*/
|
||||
#define LOS_TASK_NAMELEN 32
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Task information structure.
|
||||
*
|
||||
*/
|
||||
typedef struct tagTskInfo {
|
||||
CHAR acName[LOS_TASK_NAMELEN]; /**< Task entrance function */
|
||||
@@ -1088,6 +1150,45 @@ extern CHAR* LOS_TaskNameGet(UINT32 taskID);
|
||||
*/
|
||||
extern VOID LOS_UDelay(UINT64 microseconds);
|
||||
|
||||
/* *
|
||||
* @ingroup los_task
|
||||
* @brief: cpu delay.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to wait for the subtask to finish and reclaim the resource.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param taskID [IN] task ID.
|
||||
* @param retval [IN] Value returned when the task is complete.
|
||||
*
|
||||
* @retval: None.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_task.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see LOS_TaskDetach.
|
||||
*/
|
||||
extern UINT32 LOS_TaskJoin(UINT32 taskID, UINTPTR *retval);
|
||||
|
||||
/* *
|
||||
* @ingroup los_task
|
||||
* @brief: Modify the task attributes to detach.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to modify the attribute of the specified task to detach.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param taskID [IN] task ID.
|
||||
*
|
||||
* @retval: None.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_task.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see LOS_TaskJoin.
|
||||
*/
|
||||
extern UINT32 LOS_TaskDetach(UINT32 taskID);
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Null task ID
|
||||
@@ -1177,11 +1278,28 @@ extern VOID LOS_UDelay(UINT64 microseconds);
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Flag that indicates the task is in userspace.
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is a user task.
|
||||
* The task exits and waits for the parent thread to reclaim the resource.
|
||||
*/
|
||||
#define OS_TASK_STATUS_USERSPACE 0x8000
|
||||
#define OS_TASK_STATUS_EXIT 0x0100
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The delayed operation of this task is frozen.
|
||||
*/
|
||||
#define OS_TASK_FALG_FREEZE 0x4000
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* Task join properties, The parent thread needs to reclaim
|
||||
* the resource after the task ends.
|
||||
*/
|
||||
#define OS_TASK_FLAG_JOINABLE 0x8000
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
@@ -1346,6 +1464,8 @@ typedef struct {
|
||||
CHAR *taskName; /**< Task name */
|
||||
LOS_DL_LIST pendList;
|
||||
LOS_DL_LIST timerList;
|
||||
LOS_DL_LIST joinList;
|
||||
UINTPTR joinRetval; /**< Return value of the end of the task, If the task does not exit by itself, the ID of the task that killed the task is recorded. */
|
||||
EVENT_CB_S event;
|
||||
UINT32 eventMask; /**< Event mask */
|
||||
UINT32 eventMode; /**< Event mode */
|
||||
@@ -1622,7 +1742,7 @@ extern UINT32 OsGetAllTskInfo(VOID);
|
||||
|
||||
extern VOID *OsTskUserStackInit(VOID* stackPtr, VOID* userSP, UINT32 userStackSize);
|
||||
|
||||
extern UINT32 OsPmEnterHandlerSet(VOID (*func)(BOOL));
|
||||
extern UINT32 OsPmEnterHandlerSet(VOID (*func)(VOID));
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
@@ -34,6 +34,9 @@
|
||||
#include "los_tick.h"
|
||||
#include "los_debug.h"
|
||||
#include "los_hook.h"
|
||||
#if (LOSCFG_KERNEL_PM == 1)
|
||||
#include "los_pm.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
@@ -50,6 +53,9 @@ extern "C" {
|
||||
#error "Must specify the maximum value that tick timer counter supports!"
|
||||
#endif
|
||||
|
||||
#define OS_TASK_BLOCKED_STATUS (OS_TASK_STATUS_PEND | OS_TASK_STATUS_SUSPEND | \
|
||||
OS_TASK_STATUS_EXIT | OS_TASK_STATUS_UNUSED)
|
||||
|
||||
STATIC SchedScan g_swtmrScan = NULL;
|
||||
STATIC SortLinkAttribute *g_taskSortLinkList = NULL;
|
||||
STATIC LOS_DL_LIST g_priQueueList[OS_PRIORITY_QUEUE_NUM];
|
||||
@@ -216,6 +222,7 @@ STATIC INLINE VOID OsSchedSetNextExpireTime(UINT64 startTime, UINT32 responseID,
|
||||
|
||||
VOID OsSchedUpdateExpireTime(UINT64 startTime, BOOL timeUpdate)
|
||||
{
|
||||
BOOL isPmMode = FALSE;
|
||||
UINT64 endTime;
|
||||
LosTaskCB *runTask = g_losTask.runTask;
|
||||
|
||||
@@ -223,7 +230,10 @@ VOID OsSchedUpdateExpireTime(UINT64 startTime, BOOL timeUpdate)
|
||||
return;
|
||||
}
|
||||
|
||||
if (runTask->taskID != g_idleTaskID) {
|
||||
#if (LOSCFG_KERNEL_PM == 1)
|
||||
isPmMode = OsIsPmMode();
|
||||
#endif
|
||||
if ((runTask->taskID != g_idleTaskID) && !isPmMode) {
|
||||
INT32 timeSlice = (runTask->timeSlice <= OS_TIME_SLICE_MIN) ? OS_SCHED_TIME_SLICES : runTask->timeSlice;
|
||||
endTime = startTime + timeSlice;
|
||||
} else {
|
||||
@@ -415,7 +425,7 @@ BOOL OsSchedModifyTaskSchedParam(LosTaskCB *taskCB, UINT16 priority)
|
||||
}
|
||||
|
||||
taskCB->priority = priority;
|
||||
OsHookCall(LOS_HOOK_TYPE_TASK_PRIMODIFY, taskCB, taskCB->priority);
|
||||
OsHookCall(LOS_HOOK_TYPE_TASK_PRIMODIFY, taskCB, taskCB->priority);
|
||||
if (taskCB->taskStatus & OS_TASK_STATUS_RUNNING) {
|
||||
return TRUE;
|
||||
}
|
||||
@@ -511,7 +521,7 @@ BOOL OsSchedTaskSwitch(VOID)
|
||||
|
||||
if (runTask->taskStatus & (OS_TASK_STATUS_PEND_TIME | OS_TASK_STATUS_DELAY)) {
|
||||
OsAdd2SortLink(&runTask->sortList, runTask->startTime, runTask->waitTimes, OS_SORT_LINK_TASK);
|
||||
} else if (!(runTask->taskStatus & (OS_TASK_STATUS_PEND | OS_TASK_STATUS_SUSPEND | OS_TASK_STATUS_UNUSED))) {
|
||||
} else if (!(runTask->taskStatus & OS_TASK_BLOCKED_STATUS)) {
|
||||
OsSchedTaskEnQueue(runTask);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,9 @@
|
||||
#if (LOSCFG_BASE_CORE_CPUP == 1)
|
||||
#include "los_cpup.h"
|
||||
#endif
|
||||
#if (LOSCFG_KERNEL_PM == 1)
|
||||
#include "los_pm.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
@@ -91,6 +94,14 @@
|
||||
*/
|
||||
#define OS_TASK_STACK_TOP_OFFSET 4
|
||||
|
||||
#if (LOSCFG_EXC_HARDWARE_STACK_PROTECTION == 1)
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* @brief the size of task stack's protection area
|
||||
*/
|
||||
#define OS_TASK_STACK_PROTECT_SIZE 32
|
||||
#endif
|
||||
|
||||
LITE_OS_SEC_BSS LosTaskCB *g_taskCBArray = NULL;
|
||||
LITE_OS_SEC_BSS LosTask g_losTask;
|
||||
LITE_OS_SEC_BSS UINT16 g_losTaskLock;
|
||||
@@ -101,7 +112,7 @@ LITE_OS_SEC_DATA_INIT LOS_DL_LIST g_losFreeTask;
|
||||
LITE_OS_SEC_DATA_INIT LOS_DL_LIST g_taskRecyleList;
|
||||
LITE_OS_SEC_BSS BOOL g_taskScheduled = FALSE;
|
||||
|
||||
STATIC VOID (*PmEnter)(BOOL isIdle) = NULL;
|
||||
STATIC VOID (*PmEnter)(VOID) = NULL;
|
||||
|
||||
#if (LOSCFG_BASE_CORE_EXC_TSK_SWITCH == 1)
|
||||
TaskSwitchInfo g_taskSwitchInfo;
|
||||
@@ -120,6 +131,22 @@ STATIC_INLINE UINT32 OsCheckTaskIDValid(UINT32 taskID)
|
||||
return ret;
|
||||
}
|
||||
|
||||
STATIC VOID OsRecycleTaskResources(LosTaskCB *taskCB, UINTPTR *stackPtr)
|
||||
{
|
||||
if (!(taskCB->taskStatus & OS_TASK_STATUS_EXIT)) {
|
||||
LOS_ListAdd(&g_losFreeTask, &taskCB->pendList);
|
||||
taskCB->taskStatus = OS_TASK_STATUS_UNUSED;
|
||||
}
|
||||
if (taskCB->topOfStack != 0) {
|
||||
#if (LOSCFG_EXC_HARDWARE_STACK_PROTECTION == 1)
|
||||
*stackPtr = taskCB->topOfStack - OS_TASK_STACK_PROTECT_SIZE;
|
||||
#else
|
||||
*stackPtr = taskCB->topOfStack;
|
||||
#endif
|
||||
taskCB->topOfStack = (UINT32)NULL;
|
||||
}
|
||||
}
|
||||
|
||||
STATIC VOID OsRecyleFinishedTask(VOID)
|
||||
{
|
||||
LosTaskCB *taskCB = NULL;
|
||||
@@ -130,19 +157,17 @@ STATIC VOID OsRecyleFinishedTask(VOID)
|
||||
while (!LOS_ListEmpty(&g_taskRecyleList)) {
|
||||
taskCB = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&g_taskRecyleList));
|
||||
LOS_ListDelete(LOS_DL_LIST_FIRST(&g_taskRecyleList));
|
||||
LOS_ListAdd(&g_losFreeTask, &taskCB->pendList);
|
||||
#if (LOSCFG_EXC_HARDWARE_STACK_PROTECTION == 1)
|
||||
stackPtr = taskCB->topOfStack - OS_TASK_STACK_PROTECT_SIZE;
|
||||
#else
|
||||
stackPtr = taskCB->topOfStack;
|
||||
#endif
|
||||
stackPtr = 0;
|
||||
OsRecycleTaskResources(taskCB, &stackPtr);
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
(VOID)LOS_MemFree(OS_TASK_STACK_ADDR, (VOID *)stackPtr);
|
||||
taskCB->topOfStack = (UINT32)NULL;
|
||||
intSave = LOS_IntLock();
|
||||
}
|
||||
LOS_IntRestore(intSave);
|
||||
}
|
||||
|
||||
UINT32 OsPmEnterHandlerSet(VOID (*func)(BOOL))
|
||||
UINT32 OsPmEnterHandlerSet(VOID (*func)(VOID))
|
||||
{
|
||||
if (func == NULL) {
|
||||
return LOS_NOK;
|
||||
@@ -165,7 +190,7 @@ LITE_OS_SEC_TEXT VOID OsIdleTask(VOID)
|
||||
OsRecyleFinishedTask();
|
||||
|
||||
if (PmEnter != NULL) {
|
||||
PmEnter(TRUE);
|
||||
PmEnter();
|
||||
} else {
|
||||
(VOID)HalEnterSleep();
|
||||
}
|
||||
@@ -185,6 +210,10 @@ LITE_OS_SEC_TEXT_MINOR UINT8 *OsConvertTskStatus(UINT16 taskStatus)
|
||||
return (UINT8 *)"Running";
|
||||
} else if (taskStatus & OS_TASK_STATUS_READY) {
|
||||
return (UINT8 *)"Ready";
|
||||
} else if (taskStatus & OS_TASK_STATUS_EXIT) {
|
||||
return (UINT8 *)"Exit";
|
||||
} else if (taskStatus & OS_TASK_STATUS_SUSPEND) {
|
||||
return (UINT8 *)"Suspend";
|
||||
} else if (taskStatus & OS_TASK_STATUS_DELAY) {
|
||||
return (UINT8 *)"Delay";
|
||||
} else if (taskStatus & OS_TASK_STATUS_PEND) {
|
||||
@@ -192,8 +221,6 @@ LITE_OS_SEC_TEXT_MINOR UINT8 *OsConvertTskStatus(UINT16 taskStatus)
|
||||
return (UINT8 *)"PendTime";
|
||||
}
|
||||
return (UINT8 *)"Pend";
|
||||
} else if (taskStatus & OS_TASK_STATUS_SUSPEND) {
|
||||
return (UINT8 *)"Suspend";
|
||||
}
|
||||
|
||||
return (UINT8 *)"Impossible";
|
||||
@@ -403,7 +430,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsIdleTaskCreate(VOID)
|
||||
taskInitParam.pcName = "IdleCore000";
|
||||
taskInitParam.usTaskPrio = OS_TASK_PRIORITY_LOWEST;
|
||||
retVal = LOS_TaskCreateOnly(&g_idleTaskID, &taskInitParam);
|
||||
|
||||
if (retVal != LOS_OK) {
|
||||
return retVal;
|
||||
}
|
||||
@@ -604,8 +630,7 @@ LITE_OS_SEC_TEXT_INIT VOID OsTaskEntry(UINT32 taskID)
|
||||
UINT32 retVal;
|
||||
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
|
||||
|
||||
(VOID)taskCB->taskEntry(taskCB->arg);
|
||||
|
||||
taskCB->joinRetval = (UINTPTR)taskCB->taskEntry(taskCB->arg);
|
||||
retVal = LOS_TaskDelete(taskCB->taskID);
|
||||
if (retVal != LOS_OK) {
|
||||
PRINT_ERR("Delete Task[TID: %d] Failed!\n", taskCB->taskID);
|
||||
@@ -669,6 +694,11 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsNewTaskInit(LosTaskCB *taskCB, TSK_INIT_PARAM_S *
|
||||
taskCB->stackPointer = HalTskStackInit(taskCB->taskID, taskInitParam->uwStackSize, topOfStack);
|
||||
SET_SORTLIST_VALUE(&taskCB->sortList, OS_SORT_LINK_INVALID_TIME);
|
||||
LOS_EventInit(&(taskCB->event));
|
||||
|
||||
if (taskInitParam->uwResved & LOS_TASK_ATTR_JOINABLE) {
|
||||
taskCB->taskStatus |= OS_TASK_FLAG_JOINABLE;
|
||||
LOS_ListInit(&taskCB->joinList);
|
||||
}
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
@@ -803,6 +833,12 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskResume(UINT32 taskID)
|
||||
OS_GOTO_ERREND();
|
||||
}
|
||||
|
||||
#if (LOSCFG_KERNEL_PM == 1)
|
||||
if (tempStatus & OS_TASK_FALG_FREEZE) {
|
||||
OsPmUnfreezeTaskUnsafe(taskID);
|
||||
}
|
||||
#endif
|
||||
|
||||
taskCB->taskStatus &= (~OS_TASK_STATUS_SUSPEND);
|
||||
if (!(taskCB->taskStatus & OS_CHECK_TASK_BLOCK)) {
|
||||
OsSchedTaskEnQueue(taskCB);
|
||||
@@ -862,6 +898,12 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskSuspend(UINT32 taskID)
|
||||
OsSchedTaskDeQueue(taskCB);
|
||||
}
|
||||
|
||||
#if (LOSCFG_KERNEL_PM == 1)
|
||||
if ((tempStatus & (OS_TASK_STATUS_PEND_TIME | OS_TASK_STATUS_DELAY)) && OsIsPmMode()) {
|
||||
OsPmFreezeTaskUnsafe(taskID);
|
||||
}
|
||||
#endif
|
||||
|
||||
taskCB->taskStatus |= OS_TASK_STATUS_SUSPEND;
|
||||
OsHookCall(LOS_HOOK_TYPE_MOVEDTASKTOSUSPENDEDLIST, taskCB);
|
||||
if (taskID == g_losTask.runTask->taskID) {
|
||||
@@ -878,6 +920,124 @@ LOS_ERREND:
|
||||
return retErr;
|
||||
}
|
||||
|
||||
STATIC VOID OsTaskJoinPostUnsafe(LosTaskCB *taskCB)
|
||||
{
|
||||
LosTaskCB *resumedTask = NULL;
|
||||
|
||||
if (taskCB->taskStatus & OS_TASK_FLAG_JOINABLE) {
|
||||
if (!LOS_ListEmpty(&taskCB->joinList)) {
|
||||
resumedTask = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&(taskCB->joinList)));
|
||||
OsSchedTaskWake(resumedTask);
|
||||
}
|
||||
taskCB->taskStatus |= OS_TASK_STATUS_EXIT;
|
||||
}
|
||||
}
|
||||
|
||||
STATIC UINT32 OsTaskJoinPendUnsafe(LosTaskCB *taskCB)
|
||||
{
|
||||
if (taskCB->taskStatus & OS_TASK_STATUS_EXIT) {
|
||||
return LOS_OK;
|
||||
} else if ((taskCB->taskStatus & OS_TASK_FLAG_JOINABLE) && LOS_ListEmpty(&taskCB->joinList)) {
|
||||
OsSchedTaskWait(&taskCB->joinList, LOS_WAIT_FOREVER);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
STATIC UINT32 OsTaskSetDetachUnsafe(LosTaskCB *taskCB)
|
||||
{
|
||||
if (taskCB->taskStatus & OS_TASK_FLAG_JOINABLE) {
|
||||
if (LOS_ListEmpty(&(taskCB->joinList))) {
|
||||
LOS_ListDelete(&(taskCB->joinList));
|
||||
taskCB->taskStatus &= ~OS_TASK_FLAG_JOINABLE;
|
||||
return LOS_OK;
|
||||
}
|
||||
/* This error code has a special purpose and is not allowed to appear again on the interface */
|
||||
return LOS_ERRNO_TSK_NOT_JOIN;
|
||||
}
|
||||
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskJoin(UINT32 taskID, UINTPTR *retval)
|
||||
{
|
||||
LosTaskCB *taskCB = NULL;
|
||||
UINTPTR stackPtr = 0;
|
||||
UINT32 intSave;
|
||||
UINT32 ret;
|
||||
|
||||
ret = OsCheckTaskIDValid(taskID);
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (OS_INT_ACTIVE) {
|
||||
return LOS_ERRNO_TSK_NOT_ALLOW_IN_INT;
|
||||
}
|
||||
|
||||
if (g_losTaskLock != 0) {
|
||||
return LOS_ERRNO_TSK_SCHED_LOCKED;
|
||||
}
|
||||
|
||||
if (taskID == LOS_CurTaskIDGet()) {
|
||||
return LOS_ERRNO_TSK_NOT_JOIN_SELF;
|
||||
}
|
||||
|
||||
taskCB = OS_TCB_FROM_TID(taskID);
|
||||
intSave = LOS_IntLock();
|
||||
if (taskCB->taskStatus & OS_TASK_STATUS_UNUSED) {
|
||||
LOS_IntRestore(intSave);
|
||||
return LOS_ERRNO_TSK_NOT_CREATED;
|
||||
}
|
||||
|
||||
ret = OsTaskJoinPendUnsafe(taskCB);
|
||||
LOS_IntRestore(intSave);
|
||||
if (ret == LOS_OK) {
|
||||
LOS_Schedule();
|
||||
|
||||
if (retval != NULL) {
|
||||
*retval = taskCB->joinRetval;
|
||||
}
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
taskCB->taskStatus &= ~OS_TASK_STATUS_EXIT;
|
||||
OsRecycleTaskResources(taskCB, &stackPtr);
|
||||
LOS_IntRestore(intSave);
|
||||
(VOID)LOS_MemFree(OS_TASK_STACK_ADDR, (VOID *)stackPtr);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskDetach(UINT32 taskID)
|
||||
{
|
||||
UINT32 intSave;
|
||||
UINT32 ret;
|
||||
LosTaskCB *taskCB = NULL;
|
||||
|
||||
ret = OsCheckTaskIDValid(taskID);
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (OS_INT_ACTIVE) {
|
||||
return LOS_ERRNO_TSK_NOT_ALLOW_IN_INT;
|
||||
}
|
||||
|
||||
taskCB = OS_TCB_FROM_TID(taskID);
|
||||
intSave = LOS_IntLock();
|
||||
if (taskCB->taskStatus & OS_TASK_STATUS_UNUSED) {
|
||||
LOS_IntRestore(intSave);
|
||||
return LOS_ERRNO_TSK_NOT_CREATED;
|
||||
}
|
||||
|
||||
ret = OsTaskSetDetachUnsafe(taskCB);
|
||||
LOS_IntRestore(intSave);
|
||||
return ret;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT STATIC_INLINE VOID OsRunningTaskDelete(UINT32 taskID, LosTaskCB *taskCB)
|
||||
{
|
||||
LOS_ListTailInsert(&g_taskRecyleList, &taskCB->pendList);
|
||||
@@ -897,21 +1057,27 @@ LITE_OS_SEC_TEXT_INIT STATIC_INLINE VOID OsRunningTaskDelete(UINT32 taskID, LosT
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskDelete(UINT32 taskID)
|
||||
{
|
||||
UINT32 intSave;
|
||||
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
|
||||
UINTPTR stackPtr;
|
||||
UINTPTR stackPtr = 0;
|
||||
LosTaskCB *taskCB = NULL;
|
||||
|
||||
UINT32 ret = OsCheckTaskIDValid(taskID);
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
taskCB = OS_TCB_FROM_TID(taskID);
|
||||
intSave = LOS_IntLock();
|
||||
|
||||
if ((taskCB->taskStatus) & OS_TASK_STATUS_UNUSED) {
|
||||
if (taskCB->taskStatus & OS_TASK_STATUS_UNUSED) {
|
||||
LOS_IntRestore(intSave);
|
||||
return LOS_ERRNO_TSK_NOT_CREATED;
|
||||
}
|
||||
|
||||
if (taskCB->taskStatus & OS_TASK_STATUS_EXIT) {
|
||||
LOS_IntRestore(intSave);
|
||||
return LOS_ERRNO_TSK_ALREADY_EXIT;
|
||||
}
|
||||
|
||||
/* If the task is running and scheduler is locked then you can not delete it */
|
||||
if (((taskCB->taskStatus) & OS_TASK_STATUS_RUNNING) && (g_losTaskLock != 0)) {
|
||||
PRINT_INFO("In case of task lock, task deletion is not recommended\n");
|
||||
@@ -920,6 +1086,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskDelete(UINT32 taskID)
|
||||
|
||||
OsHookCall(LOS_HOOK_TYPE_TASK_DELETE, taskCB);
|
||||
OsSchedTaskExit(taskCB);
|
||||
OsTaskJoinPostUnsafe(taskCB);
|
||||
|
||||
LOS_EventDestroy(&(taskCB->event));
|
||||
taskCB->event.uwEventID = OS_NULL_INT;
|
||||
@@ -929,24 +1096,19 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskDelete(UINT32 taskID)
|
||||
(VOID)memset_s((VOID *)&g_cpup[taskCB->taskID], sizeof(OsCpupCB), 0, sizeof(OsCpupCB));
|
||||
#endif
|
||||
if (taskCB->taskStatus & OS_TASK_STATUS_RUNNING) {
|
||||
taskCB->taskStatus = OS_TASK_STATUS_UNUSED;
|
||||
OsRunningTaskDelete(taskID, taskCB);
|
||||
if (!(taskCB->taskStatus & OS_TASK_STATUS_EXIT)) {
|
||||
taskCB->taskStatus = OS_TASK_STATUS_UNUSED;
|
||||
OsRunningTaskDelete(taskID, taskCB);
|
||||
}
|
||||
LOS_IntRestore(intSave);
|
||||
LOS_Schedule();
|
||||
return LOS_OK;
|
||||
} else {
|
||||
taskCB->taskStatus = OS_TASK_STATUS_UNUSED;
|
||||
LOS_ListAdd(&g_losFreeTask, &taskCB->pendList);
|
||||
#if (LOSCFG_EXC_HARDWARE_STACK_PROTECTION == 1)
|
||||
stackPtr = taskCB->topOfStack - OS_TASK_STACK_PROTECT_SIZE;
|
||||
#else
|
||||
stackPtr = taskCB->topOfStack;
|
||||
#endif
|
||||
(VOID)LOS_MemFree(OS_TASK_STACK_ADDR, (VOID *)stackPtr);
|
||||
taskCB->topOfStack = (UINT32)NULL;
|
||||
}
|
||||
|
||||
taskCB->joinRetval = LOS_CurTaskIDGet();
|
||||
OsRecycleTaskResources(taskCB, &stackPtr);
|
||||
LOS_IntRestore(intSave);
|
||||
(VOID)LOS_MemFree(OS_TASK_STACK_ADDR, (VOID *)stackPtr);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -345,23 +345,23 @@ STATIC VOID OsAllMemNodeDoHandle(VOID *pool, VOID (*handle)(struct OsMemNodeHead
|
||||
STATIC VOID GetTaskMemUsedHandle(struct OsMemNodeHead *curNode, VOID *arg)
|
||||
{
|
||||
UINT32 *args = (UINT32 *)arg;
|
||||
UINT32 *outArray = (UINT32 *)(UINTPTR)*args;
|
||||
UINT32 arraySize = *(args + 1);
|
||||
UINT32 *tskMemInfoBuf = (UINT32 *)(UINTPTR)*args;
|
||||
UINT32 tskMemInfoCnt = *(args + 1);
|
||||
#ifndef LOSCFG_MEM_MUL_REGIONS
|
||||
if (OS_MEM_NODE_GET_USED_FLAG(curNode->sizeAndFlag)) {
|
||||
#else
|
||||
if (OS_MEM_NODE_GET_USED_FLAG(curNode->sizeAndFlag) && !OS_MEM_IS_GAP_NODE(curNode)) {
|
||||
#endif
|
||||
if (curNode->taskID < arraySize) {
|
||||
outArray[curNode->taskID] += OS_MEM_NODE_GET_SIZE(curNode->sizeAndFlag);
|
||||
if (curNode->taskID < tskMemInfoCnt) {
|
||||
tskMemInfoBuf[curNode->taskID] += OS_MEM_NODE_GET_SIZE(curNode->sizeAndFlag);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID OsTaskMemUsed(VOID *pool, UINT32 *outArray, UINT32 arraySize)
|
||||
VOID OsTaskMemUsed(VOID *pool, UINT32 *tskMemInfoBuf, UINT32 tskMemInfoCnt)
|
||||
{
|
||||
UINT32 args[2] = {(UINT32)(UINTPTR)outArray, arraySize};
|
||||
UINT32 args[2] = {(UINT32)(UINTPTR)tskMemInfoBuf, tskMemInfoCnt};
|
||||
OsAllMemNodeDoHandle(pool, GetTaskMemUsedHandle, (VOID *)args);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -68,6 +68,7 @@ lite_component("test") {
|
||||
"sample/kernel/sem:test_sem",
|
||||
"sample/kernel/swtmr:test_swtmr",
|
||||
"sample/kernel/task:test_task",
|
||||
"sample/kernel/power:test_pm",
|
||||
|
||||
#"sample/kernel/tickless:test_tickless",
|
||||
]
|
||||
|
||||
@@ -84,6 +84,7 @@ extern "C" {
|
||||
#define LOS_KERNEL_MEM_TEST 1
|
||||
#define LOS_KERNEL_DYNLINK_TEST 0
|
||||
#define LOS_KERNEL_TICKLESS_TEST 0
|
||||
#define LOS_KERNEL_PM_TEST 1
|
||||
|
||||
#define LITEOS_CMSIS_TEST 0
|
||||
#define LOS_CMSIS2_CORE_TASK_TEST 0
|
||||
|
||||
@@ -1,4 +1,31 @@
|
||||
# Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
static_library("test_dynlink") {
|
||||
sources = [
|
||||
|
||||
@@ -1,3 +1,31 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
GCC_PREFIX = arm-none-eabi-
|
||||
|
||||
CROSS_GCC = $(GCC_PREFIX)gcc
|
||||
|
||||
@@ -1,3 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#define OK 0
|
||||
#define NOK 1
|
||||
|
||||
|
||||
@@ -1,3 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
int test_array[100];
|
||||
|
||||
int dyn_bss_func(void)
|
||||
|
||||
@@ -1,3 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
|
||||
@@ -1,3 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
static int staticParam = 9;
|
||||
int g_param = 10;
|
||||
|
||||
|
||||
@@ -1,3 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
int g_param = 10;
|
||||
|
||||
int callee(int a, int b)
|
||||
|
||||
@@ -1,3 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
extern int undef_func(int a, int b);
|
||||
|
||||
int caller(int a, int b)
|
||||
|
||||
@@ -1,3 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
extern int g_param;
|
||||
|
||||
int caller(int a, int b)
|
||||
|
||||
@@ -1,3 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
int g_value100 = 100;
|
||||
int *g_pValue100 = &g_value100;
|
||||
static int value200 = 200;
|
||||
|
||||
@@ -1,17 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
#Copyright (c) 2020-2021 Huawei Device Co., Ltd.
|
||||
#Licensed under the Apache License, Version 2.0 (the "License");
|
||||
#you may not use this file except in compliance with the License.
|
||||
#You may obtain a copy of the License at
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
#Unless required by applicable law or agreed to in writing, software
|
||||
#distributed under the License is distributed on an "AS IS" BASIS,
|
||||
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
#See the License for the specific language governing permissions and
|
||||
#limitations under the License.
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
LOAD_FLAG=false
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ EVENT_CB_S g_pevent;
|
||||
VOID ItSuiteLosEvent()
|
||||
{
|
||||
ItLosEvent001();
|
||||
ItLosEvent003();
|
||||
ItLosEvent004();
|
||||
ItLosEvent005();
|
||||
ItLosEvent006();
|
||||
@@ -64,7 +65,6 @@ VOID ItSuiteLosEvent()
|
||||
ItLosEvent043();
|
||||
#if (LOS_KERNEL_TEST_FULL == 1)
|
||||
ItLosEvent002();
|
||||
ItLosEvent003();
|
||||
ItLosEvent011();
|
||||
ItLosEvent012();
|
||||
ItLosEvent015();
|
||||
|
||||
@@ -57,7 +57,7 @@ static UINT32 Testcase(VOID)
|
||||
task1.pcName = "EventTsk3";
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the test task.
|
||||
task1.uwResved = LOS_TASK_STATUS_DETACHED;
|
||||
task1.uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
|
||||
g_testCount = 0;
|
||||
g_pevent.uwEventID = 0;
|
||||
@@ -71,11 +71,13 @@ static UINT32 Testcase(VOID)
|
||||
|
||||
g_testCount++;
|
||||
|
||||
LOS_TaskDelay(1);
|
||||
ret = LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3.
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testTaskID01);
|
||||
LOS_TaskJoin(g_testCount, NULL);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
40
testsuits/sample/kernel/power/BUILD.gn
Normal file
40
testsuits/sample/kernel/power/BUILD.gn
Normal file
@@ -0,0 +1,40 @@
|
||||
# Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
static_library("test_pm") {
|
||||
sources = [
|
||||
"It_los_pm.c",
|
||||
"It_los_pm_001.c",
|
||||
"It_los_pm_002.c",
|
||||
"It_los_pm_003.c",
|
||||
]
|
||||
|
||||
include_dirs = [ "//kernel/liteos_m/components/power" ]
|
||||
|
||||
configs += [ "//kernel/liteos_m/testsuits:include" ]
|
||||
}
|
||||
40
testsuits/sample/kernel/power/It_los_pm.c
Normal file
40
testsuits/sample/kernel/power/It_los_pm.c
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "osTest.h"
|
||||
#include "It_los_pm.h"
|
||||
|
||||
VOID ItSuiteLosPm(VOID)
|
||||
{
|
||||
ItLosPm001();
|
||||
ItLosPm002();
|
||||
ItLosPm003();
|
||||
}
|
||||
|
||||
64
testsuits/sample/kernel/power/It_los_pm.h
Normal file
64
testsuits/sample/kernel/power/It_los_pm.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "osTest.h"
|
||||
#include "los_pm.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define SELF_DELETED 0
|
||||
#define SYS_EXIST_SWTMR 1
|
||||
|
||||
#define TEST_HWI_RUNTIME 0x100000
|
||||
#define TASK_LOOP_NUM 0x100000
|
||||
|
||||
#if (LOSCFG_BASE_CORE_SWTMR == 1)
|
||||
#define TASK_EXISTED_NUM 3
|
||||
#else
|
||||
#define TASK_EXISTED_NUM 2
|
||||
#endif
|
||||
|
||||
#define TASK_EXISTED_D_NUM TASK_EXISTED_NUM
|
||||
#define TASK_NAME_NUM 10
|
||||
#define IT_TASK_LOOP 20
|
||||
|
||||
extern VOID ItLosPm001(VOID);
|
||||
extern VOID ItLosPm002(VOID);
|
||||
extern VOID ItLosPm003(VOID);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
166
testsuits/sample/kernel/power/It_los_pm_001.c
Normal file
166
testsuits/sample/kernel/power/It_los_pm_001.c
Normal file
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "osTest.h"
|
||||
#include "It_los_pm.h"
|
||||
|
||||
static UINT32 DeviceSuspend(UINT32 mode)
|
||||
{
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
static VOID DeviceResume(UINT32 mode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static LosPmDevice g_device1 = {
|
||||
.suspend = NULL,
|
||||
.resume = NULL,
|
||||
};
|
||||
|
||||
static VOID SysResume(VOID)
|
||||
{
|
||||
}
|
||||
|
||||
static LosPmSysctrl g_sysctrl = {
|
||||
.normalSuspend = NULL,
|
||||
.normalResume = SysResume,
|
||||
};
|
||||
|
||||
static VOID TimerStart(UINT64 timer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static UINT64 GetTimerCycle(VOID)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static VOID TickLock(VOID)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static VOID TickUnlock(VOID)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static LosPmTickTimer g_tickTimer = {
|
||||
.tickLock = NULL,
|
||||
.tickUnlock = NULL,
|
||||
.timerStart = NULL,
|
||||
.timerStop = NULL,
|
||||
.timerCycleGet = NULL,
|
||||
.freq = 0,
|
||||
};
|
||||
|
||||
static UINT32 TestCase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
|
||||
ret = LOS_PmRegister(LOS_PM_TYPE_DEVICE, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_PM_INVALID_PARAM, ret);
|
||||
|
||||
ret = LOS_PmRegister(LOS_PM_TYPE_DEVICE, &g_device1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_PM_INVALID_PARAM, ret);
|
||||
|
||||
g_device1.suspend = DeviceSuspend;
|
||||
ret = LOS_PmRegister(LOS_PM_TYPE_DEVICE, &g_device1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_PM_INVALID_PARAM, ret);
|
||||
|
||||
g_device1.suspend = NULL;
|
||||
g_device1.resume = DeviceResume;
|
||||
ret = LOS_PmRegister(LOS_PM_TYPE_DEVICE, &g_device1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_PM_INVALID_PARAM, ret);
|
||||
|
||||
g_device1.suspend = DeviceSuspend;
|
||||
g_device1.resume = DeviceResume;
|
||||
ret = LOS_PmRegister(LOS_PM_TYPE_DEVICE, &g_device1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_PmRegister(LOS_PM_TYPE_TICK_TIMER, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_PM_INVALID_PARAM, ret);
|
||||
|
||||
ret = LOS_PmRegister(LOS_PM_TYPE_TICK_TIMER, &g_tickTimer);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_PM_INVALID_PARAM, ret);
|
||||
|
||||
g_tickTimer.tickLock = TickLock;
|
||||
ret = LOS_PmRegister(LOS_PM_TYPE_TICK_TIMER, &g_tickTimer);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_PM_INVALID_PARAM, ret);
|
||||
|
||||
g_tickTimer.tickLock = NULL;
|
||||
g_tickTimer.tickUnlock = TickUnlock;
|
||||
ret = LOS_PmRegister(LOS_PM_TYPE_TICK_TIMER, &g_tickTimer);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_PM_INVALID_PARAM, ret);
|
||||
|
||||
g_tickTimer.tickLock = TickLock;
|
||||
g_tickTimer.tickUnlock = TickUnlock;
|
||||
ret = LOS_PmRegister(LOS_PM_TYPE_TICK_TIMER, &g_tickTimer);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_PmUnregister(LOS_PM_TYPE_TICK_TIMER, &g_tickTimer);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
g_tickTimer.tickLock = TickLock;
|
||||
g_tickTimer.tickUnlock = TickUnlock;
|
||||
g_tickTimer.timerStart = TimerStart;
|
||||
ret = LOS_PmRegister(LOS_PM_TYPE_TICK_TIMER, &g_tickTimer);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_PM_INVALID_PARAM, ret);
|
||||
|
||||
g_tickTimer.timerStop = TickLock;
|
||||
ret = LOS_PmRegister(LOS_PM_TYPE_TICK_TIMER, &g_tickTimer);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_PM_INVALID_PARAM, ret);
|
||||
|
||||
g_tickTimer.timerCycleGet = GetTimerCycle;
|
||||
ret = LOS_PmRegister(LOS_PM_TYPE_TICK_TIMER, &g_tickTimer);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_PM_INVALID_PARAM, ret);
|
||||
|
||||
g_tickTimer.freq = 32000; /* 32000HZ */
|
||||
ret = LOS_PmRegister(LOS_PM_TYPE_TICK_TIMER, &g_tickTimer);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_PmUnregister(LOS_PM_TYPE_TICK_TIMER, &g_tickTimer);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_PmRegister(LOS_PM_TYPE_SYSCTRL, &g_sysctrl);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_PM_INVALID_PARAM, ret);
|
||||
|
||||
ret = LOS_PmUnregister(LOS_PM_TYPE_DEVICE, &g_device1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosPm001(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("ItLosPm001", TestCase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
270
testsuits/sample/kernel/power/It_los_pm_002.c
Normal file
270
testsuits/sample/kernel/power/It_los_pm_002.c
Normal file
@@ -0,0 +1,270 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "osTest.h"
|
||||
#include "It_los_pm.h"
|
||||
#include "los_timer.h"
|
||||
|
||||
#define myprintf // printf
|
||||
#define TEST_LOOP 5
|
||||
static EVENT_CB_S g_pmTestEvent;
|
||||
static UINT32 g_taskID1, g_taskID2;
|
||||
static UINT32 g_deviceCount = 0;
|
||||
static UINT32 g_sysCount = 0;
|
||||
static volatile UINT32 g_pmTestCount = 0;
|
||||
|
||||
static UINT32 DeviceSuspend(UINT32 mode)
|
||||
{
|
||||
g_deviceCount++;
|
||||
g_testCount++;
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
static VOID DeviceResume(UINT32 mode)
|
||||
{
|
||||
g_deviceCount--;
|
||||
return;
|
||||
}
|
||||
|
||||
static LosPmDevice g_device = {
|
||||
.suspend = DeviceSuspend,
|
||||
.resume = DeviceResume,
|
||||
};
|
||||
|
||||
static VOID SysResume(VOID)
|
||||
{
|
||||
if (g_sysCount != (UINT32)-1) {
|
||||
g_sysCount--;
|
||||
}
|
||||
}
|
||||
|
||||
static UINT32 SysSuspend(VOID)
|
||||
{
|
||||
g_testCount++;
|
||||
g_sysCount++;
|
||||
|
||||
if ((g_deviceCount != 1) || (g_sysCount != 1)) { /* 1: sys count */
|
||||
g_sysCount = (UINT32)-1;
|
||||
}
|
||||
|
||||
UINT64 timeout = LOS_SchedTickTimeoutNsGet();
|
||||
printf("pm timeout : %u ns -> %u ticks\n", (UINT32)timeout, (UINT32)(timeout / OS_NS_PER_TICK));
|
||||
return HalEnterSleep();
|
||||
}
|
||||
|
||||
static UINT32 SystemPmEarly(UINT32 mode)
|
||||
{
|
||||
UINT32 ret;
|
||||
|
||||
ret = LOS_TaskSuspend(g_taskID2);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_TaskSuspend(g_taskID1);
|
||||
if (ret != LOS_OK) {
|
||||
(VOID)LOS_TaskResume(g_taskID2);
|
||||
}
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
static VOID SystemPmLate(UINT32 mode)
|
||||
{
|
||||
UINT32 ret;
|
||||
LosTaskCB *taskCB = NULL;
|
||||
|
||||
ICUNIT_ASSERT_EQUAL_VOID(mode, LOS_SYS_LIGHT_SLEEP, mode);
|
||||
|
||||
ret = LOS_TaskResume(g_taskID2);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_TaskResume(g_taskID1);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
}
|
||||
|
||||
static LosPmSysctrl g_sysctrl = {
|
||||
.early = SystemPmEarly,
|
||||
.late = SystemPmLate,
|
||||
.normalSuspend = HalEnterSleep,
|
||||
.normalResume = NULL,
|
||||
.lightSuspend = SysSuspend,
|
||||
.lightResume = SysResume,
|
||||
};
|
||||
|
||||
#define TEST_FLAGS 100
|
||||
static VOID PmTestTask(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
UINT32 wakeCount;
|
||||
|
||||
while (1) {
|
||||
wakeCount = LOS_PmReadLock();
|
||||
|
||||
ret = LOS_PmSuspend(wakeCount);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
ICUNIT_GOTO_NOT_EQUAL(g_testCount, 0, g_sysCount, EXIT);
|
||||
ICUNIT_GOTO_EQUAL(g_sysCount, 0, g_sysCount, EXIT);
|
||||
|
||||
g_pmTestCount++;
|
||||
if (g_pmTestCount > TEST_LOOP) {
|
||||
break;
|
||||
}
|
||||
printf("PmTestTask loop: %u\n", g_pmTestCount);
|
||||
}
|
||||
|
||||
EXIT:
|
||||
g_pmTestCount = TEST_FLAGS;
|
||||
(VOID)LOS_EventWrite(&g_pmTestEvent, 0x1); /* 0x1: test exit evnet */
|
||||
return;
|
||||
}
|
||||
|
||||
#define TEST_TASK1_LOOP 10
|
||||
static volatile UINT32 g_testSample1Count, g_testSample2Count;
|
||||
static void TaskSampleEntry2(void)
|
||||
{
|
||||
UINT32 g_testSample2Count = TEST_FLAGS;
|
||||
|
||||
while (1) {
|
||||
if (g_testSample2Count == TEST_FLAGS) {
|
||||
g_testSample2Count = 0;
|
||||
LOS_PmLockRequest("TaskSampleEntry2");
|
||||
myprintf("%s request pm lock\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
myprintf("TaskSampleEntry2 running...count: %u\n\r", g_testSample2Count);
|
||||
LOS_TaskDelay(20); /* sleep 20 ticks */
|
||||
|
||||
if (g_testSample2Count <= TEST_TASK1_LOOP) { /* */
|
||||
g_testSample2Count++;
|
||||
}
|
||||
if (g_testSample2Count == TEST_TASK1_LOOP) {
|
||||
LOS_PmLockRelease("TaskSampleEntry2");
|
||||
myprintf("%s release pm lock\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
if (g_pmTestCount > TEST_LOOP) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
LOS_PmLockRelease("TaskSampleEntry2");
|
||||
myprintf("TaskSampleEntry2 exit\n");
|
||||
}
|
||||
|
||||
static void TaskSampleEntry1(void)
|
||||
{
|
||||
UINT32 g_testSample1Count = 0;
|
||||
|
||||
while (1) {
|
||||
if (g_testSample1Count == 0) {
|
||||
LOS_PmLockRequest("TaskSampleEntry1");
|
||||
myprintf("%s request pm lock\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
myprintf("TaskSampleEntry1 running...%u\n\r", g_testSample1Count);
|
||||
LOS_TaskDelay(50); /* sleep 50 ticks */
|
||||
|
||||
g_testSample1Count++;
|
||||
if (g_testSample1Count == TEST_TASK1_LOOP) {
|
||||
LOS_PmLockRelease("TaskSampleEntry1");
|
||||
myprintf("%s release pm lock\n", __FUNCTION__);
|
||||
} else if (g_testSample1Count == (TEST_TASK1_LOOP + 1)) { /* 1: incremental */
|
||||
g_testSample1Count = 0;
|
||||
g_testSample2Count = TEST_FLAGS;
|
||||
}
|
||||
|
||||
if (g_pmTestCount > TEST_LOOP) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
LOS_PmLockRelease("TaskSampleEntry1");
|
||||
myprintf("TaskSampleEntry1 exit\n");
|
||||
}
|
||||
|
||||
static UINT32 TestCase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
TSK_INIT_PARAM_S task1 = { 0 };
|
||||
g_sysCount = 0;
|
||||
g_deviceCount = 0;
|
||||
g_testCount = 0;
|
||||
|
||||
ret = LOS_EventInit(&g_pmTestEvent);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_PmRegister(LOS_PM_TYPE_DEVICE, &g_device);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_PmRegister(LOS_PM_TYPE_SYSCTRL, &g_sysctrl);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_PmModeSet(LOS_SYS_LIGHT_SLEEP);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
task1.pfnTaskEntry = (TSK_ENTRY_FUNC)PmTestTask;
|
||||
task1.uwStackSize = 0x2000; /* 0x2000 pm task stack size */
|
||||
task1.pcName = "pmTask";
|
||||
task1.usTaskPrio = 5; /* 5: pm task prio */
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskSampleEntry1;
|
||||
task1.uwStackSize = 0x1000; /* 0x1000 task stack size */
|
||||
task1.pcName = "TaskSampleEntry1";
|
||||
task1.usTaskPrio = 10; /* 10: task prio */
|
||||
ret = LOS_TaskCreate(&g_taskID1, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskSampleEntry2;
|
||||
task1.uwStackSize = 0x1000; /* 0x1000 task stack size */
|
||||
task1.pcName = "TaskSampleEntry2";
|
||||
task1.usTaskPrio = 12; /* 12: task prio */
|
||||
ret = LOS_TaskCreate(&g_taskID2, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
(VOID)LOS_EventRead(&g_pmTestEvent, 0xff, LOS_WAITMODE_OR | LOS_WAITMODE_CLR, LOS_WAIT_FOREVER);
|
||||
|
||||
ret = LOS_PmUnregister(LOS_PM_TYPE_DEVICE, &g_device);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_PmModeSet(LOS_SYS_NORMAL_SLEEP);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
(VOID)LOS_TaskDelete(g_taskID1);
|
||||
(VOID)LOS_TaskDelete(g_taskID2);
|
||||
(VOID)LOS_TaskDelete(g_testTaskID01);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosPm002(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("ItLosPm002", TestCase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
242
testsuits/sample/kernel/power/It_los_pm_003.c
Normal file
242
testsuits/sample/kernel/power/It_los_pm_003.c
Normal file
@@ -0,0 +1,242 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "osTest.h"
|
||||
#include "It_los_pm.h"
|
||||
#include "los_timer.h"
|
||||
|
||||
#define TEST_LOOP 5
|
||||
static EVENT_CB_S g_pmTestEvent;
|
||||
static UINT32 g_taskID1, g_taskID2;
|
||||
static UINT32 g_deviceCount = 0;
|
||||
static UINT32 g_sysCount = 0;
|
||||
static volatile UINT32 g_pmTestCount = 0;
|
||||
static UINT32 g_pmTimeLock = 0;
|
||||
|
||||
static UINT32 DeviceSuspend(UINT32 mode)
|
||||
{
|
||||
g_deviceCount++;
|
||||
g_testCount++;
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
static VOID DeviceResume(UINT32 mode)
|
||||
{
|
||||
g_deviceCount--;
|
||||
return;
|
||||
}
|
||||
|
||||
static LosPmDevice g_device = {
|
||||
.suspend = DeviceSuspend,
|
||||
.resume = DeviceResume,
|
||||
};
|
||||
|
||||
static VOID SysResume(VOID)
|
||||
{
|
||||
if (g_sysCount != (UINT32)-1) {
|
||||
g_sysCount--;
|
||||
}
|
||||
}
|
||||
|
||||
static UINT32 SysSuspend(VOID)
|
||||
{
|
||||
g_testCount++;
|
||||
g_sysCount++;
|
||||
|
||||
if ((g_deviceCount != 1) || (g_sysCount != 1)) { /* 2: device count 1: sys count */
|
||||
g_sysCount = (UINT32)-1;
|
||||
}
|
||||
|
||||
UINT64 timeout = LOS_SchedTickTimeoutNsGet();
|
||||
printf("pm timeout : %u ns -> %u ticks\n", (UINT32)timeout, (UINT32)(timeout / OS_NS_PER_TICK));
|
||||
return HalEnterSleep();
|
||||
}
|
||||
|
||||
static UINT32 SystemPmEarly(UINT32 mode)
|
||||
{
|
||||
UINT32 ret;
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(mode, LOS_SYS_LIGHT_SLEEP, mode);
|
||||
|
||||
ret = LOS_TaskSuspend(g_taskID2);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_TaskSuspend(g_taskID1);
|
||||
if (ret != LOS_OK) {
|
||||
(VOID)LOS_TaskResume(g_taskID2);
|
||||
}
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
static VOID SystemPmLate(UINT32 mode)
|
||||
{
|
||||
UINT32 ret;
|
||||
|
||||
ICUNIT_ASSERT_EQUAL_VOID(mode, LOS_SYS_LIGHT_SLEEP, mode);
|
||||
|
||||
ret = LOS_TaskResume(g_taskID2);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_TaskResume(g_taskID1);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
}
|
||||
|
||||
static LosPmSysctrl g_sysctrl = {
|
||||
.early = SystemPmEarly,
|
||||
.late = SystemPmLate,
|
||||
.normalSuspend = HalEnterSleep,
|
||||
.normalResume = NULL,
|
||||
.lightSuspend = SysSuspend,
|
||||
.lightResume = SysResume,
|
||||
};
|
||||
|
||||
#define TEST_FLAGS 100
|
||||
static VOID PmTestTask(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
UINT32 wakeCount;
|
||||
|
||||
while (1) {
|
||||
wakeCount = LOS_PmReadLock();
|
||||
|
||||
ret = LOS_PmSuspend(wakeCount);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
ICUNIT_GOTO_NOT_EQUAL(g_testCount, 0, g_sysCount, EXIT);
|
||||
ICUNIT_GOTO_EQUAL(g_sysCount, 0, g_sysCount, EXIT);
|
||||
|
||||
g_pmTimeLock = 0;
|
||||
g_pmTestCount++;
|
||||
if (g_pmTestCount > TEST_LOOP) {
|
||||
break;
|
||||
}
|
||||
printf("PmTestTask loop: %u\n", g_pmTestCount);
|
||||
}
|
||||
|
||||
EXIT:
|
||||
g_pmTestCount = TEST_FLAGS;
|
||||
(VOID)LOS_EventWrite(&g_pmTestEvent, 0x1); /* 0x1: test exit evnet */
|
||||
return;
|
||||
}
|
||||
|
||||
static void TaskSampleEntry2(void)
|
||||
{
|
||||
while (1) {
|
||||
LOS_TaskDelay(20); /* sleep 20 ticks */
|
||||
if (g_pmTestCount > TEST_LOOP) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void TaskSampleEntry1(void)
|
||||
{
|
||||
UINT32 ret;
|
||||
|
||||
while (1) {
|
||||
if (g_pmTimeLock == 0) {
|
||||
g_pmTimeLock = TEST_FLAGS;
|
||||
ret = LOS_PmTimeLockRequest("TaskSampleEntry1", 1000); /* delay 1000 ms */
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_PmTimeLockRequest("TaskSampleEntry1", 1000); /* delay 1000 ms */
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_PM_ALREADY_LOCK, ret);
|
||||
}
|
||||
|
||||
LOS_TaskDelay(50); /* sleep 50 ticks */
|
||||
|
||||
if (g_pmTestCount > TEST_LOOP) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static UINT32 TestCase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
TSK_INIT_PARAM_S task1 = { 0 };
|
||||
g_sysCount = 0;
|
||||
g_deviceCount = 0;
|
||||
g_testCount = 0;
|
||||
|
||||
ret = LOS_EventInit(&g_pmTestEvent);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_PmRegister(LOS_PM_TYPE_DEVICE, &g_device);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_PmRegister(LOS_PM_TYPE_SYSCTRL, &g_sysctrl);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_PmModeSet(LOS_SYS_LIGHT_SLEEP);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
task1.pfnTaskEntry = (TSK_ENTRY_FUNC)PmTestTask;
|
||||
task1.uwStackSize = 0x2000; /* 0x2000 pm task stack size */
|
||||
task1.pcName = "pmTask";
|
||||
task1.usTaskPrio = 5; /* 5: pm task prio */
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskSampleEntry1;
|
||||
task1.uwStackSize = 0x1000; /* 0x1000 task stack size */
|
||||
task1.pcName = "TaskSampleEntry1";
|
||||
task1.usTaskPrio = 10; /* 10: task prio */
|
||||
ret = LOS_TaskCreate(&g_taskID1, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskSampleEntry2;
|
||||
task1.uwStackSize = 0x1000; /* 0x1000 task stack size */
|
||||
task1.pcName = "TaskSampleEntry2";
|
||||
task1.usTaskPrio = 12; /* 12: task prio */
|
||||
ret = LOS_TaskCreate(&g_taskID2, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
(VOID)LOS_EventRead(&g_pmTestEvent, 0xff, LOS_WAITMODE_OR | LOS_WAITMODE_CLR, LOS_WAIT_FOREVER);
|
||||
|
||||
ret = LOS_PmUnregister(LOS_PM_TYPE_DEVICE, &g_device);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_PmModeSet(LOS_SYS_NORMAL_SLEEP);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
(VOID)LOS_TaskDelete(g_taskID1);
|
||||
(VOID)LOS_TaskDelete(g_taskID2);
|
||||
(VOID)LOS_TaskDelete(g_testTaskID01);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosPm003(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("ItLosPm003", TestCase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
@@ -144,6 +144,11 @@ static_library("test_task") {
|
||||
"It_los_task_115.c",
|
||||
"It_los_task_116.c",
|
||||
"It_los_task_117.c",
|
||||
"It_los_task_118.c",
|
||||
"It_los_task_119.c",
|
||||
"It_los_task_120.c",
|
||||
"It_los_task_121.c",
|
||||
"It_los_task_122.c",
|
||||
]
|
||||
|
||||
configs += [ "//kernel/liteos_m/testsuits:include" ]
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include "osTest.h"
|
||||
#include "It_los_task.h"
|
||||
|
||||
|
||||
VOID ItSuiteLosTask()
|
||||
{
|
||||
ItLosTask001();
|
||||
@@ -76,8 +75,11 @@ VOID ItSuiteLosTask()
|
||||
ItLosTask042();
|
||||
ItLosTask046();
|
||||
ItLosTask047();
|
||||
ItLosTask048();
|
||||
ItLosTask049();
|
||||
ItLosTask050();
|
||||
ItLosTask051();
|
||||
ItLosTask052();
|
||||
ItLosTask055();
|
||||
ItLosTask057();
|
||||
ItLosTask058();
|
||||
@@ -95,28 +97,8 @@ VOID ItSuiteLosTask()
|
||||
ItLosTask076();
|
||||
ItLosTask077();
|
||||
ItLosTask078();
|
||||
|
||||
#if (LOS_KERNEL_TEST_FULL == 1)
|
||||
ItLosTask039();
|
||||
ItLosTask040();
|
||||
ItLosTask043();
|
||||
ItLosTask048();
|
||||
ItLosTask051();
|
||||
ItLosTask052();
|
||||
ItLosTask056();
|
||||
ItLosTask063();
|
||||
ItLosTask075();
|
||||
ItLosTask079();
|
||||
ItLosTask081();
|
||||
ItLosTask082();
|
||||
ItLosTask083();
|
||||
ItLosTask085();
|
||||
ItLosTask087();
|
||||
ItLosTask088();
|
||||
ItLosTask089();
|
||||
ItLosTask090();
|
||||
ItLosTask092();
|
||||
ItLosTask093();
|
||||
ItLosTask094();
|
||||
ItLosTask095();
|
||||
ItLosTask097();
|
||||
@@ -135,6 +117,28 @@ VOID ItSuiteLosTask()
|
||||
ItLosTask112();
|
||||
ItLosTask113();
|
||||
ItLosTask115();
|
||||
ItLosTask118();
|
||||
ItLosTask119();
|
||||
ItLosTask120();
|
||||
ItLosTask121();
|
||||
ItLosTask122();
|
||||
|
||||
#if (LOS_KERNEL_TEST_FULL == 1)
|
||||
ItLosTask039();
|
||||
ItLosTask040();
|
||||
ItLosTask043();
|
||||
ItLosTask056();
|
||||
ItLosTask063();
|
||||
ItLosTask075();
|
||||
ItLosTask079();
|
||||
ItLosTask081();
|
||||
ItLosTask082();
|
||||
ItLosTask083();
|
||||
ItLosTask085();
|
||||
ItLosTask087();
|
||||
ItLosTask088();
|
||||
ItLosTask090();
|
||||
ItLosTask093();
|
||||
ItLosTask116();
|
||||
#if (LOS_KERNEL_HWI_TEST == 1)
|
||||
ItLosTask053();
|
||||
|
||||
@@ -179,6 +179,11 @@ extern VOID ItLosTask114(VOID);
|
||||
extern VOID ItLosTask115(VOID);
|
||||
extern VOID ItLosTask116(VOID);
|
||||
extern VOID ItLosTask117(VOID);
|
||||
extern VOID ItLosTask118(VOID);
|
||||
extern VOID ItLosTask119(VOID);
|
||||
extern VOID ItLosTask120(VOID);
|
||||
extern VOID ItLosTask121(VOID);
|
||||
extern VOID ItLosTask122(VOID);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
@@ -48,7 +48,6 @@ static UINT32 TestCase(VOID)
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "Tsk014A";
|
||||
task1.usTaskPrio = TASK_PRIO_TEST - 1;
|
||||
task1.uwResved = -1;
|
||||
g_testCount = 0;
|
||||
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
|
||||
@@ -58,7 +58,7 @@ static UINT32 TestCase(VOID)
|
||||
task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "Tsk048A";
|
||||
task1.uwResved = LOS_TASK_STATUS_DETACHED;
|
||||
task1.uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
if (TASK_EXISTED_D_NUM == 4) { // 4, set priority based on TASK_EXISTED_D_NUM.
|
||||
task1.usTaskPrio = 2; // 2, TASK_EXISTED_D_NUM == 4, set 2 as priority.
|
||||
} else if (TASK_EXISTED_D_NUM == 3) { // 3, set reasonable priority based on TASK_EXISTED_D_NUM.
|
||||
@@ -75,11 +75,14 @@ static UINT32 TestCase(VOID)
|
||||
task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
|
||||
task1.pcName = "Tsk048B";
|
||||
task1.usTaskPrio = LOS_TASK_PRIORITY_LOWEST - 1;
|
||||
task1.uwResved = LOS_TASK_STATUS_DETACHED;
|
||||
task1.uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
ret = LOS_TaskCreate(&g_testTaskID02, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_TaskDelay(2); // 2, set delay time
|
||||
ret = LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_TaskJoin(g_testTaskID02, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
|
||||
|
||||
@@ -50,6 +50,7 @@ static VOID TaskF01(VOID)
|
||||
task1.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
task1.pcName = "Tsk051B";
|
||||
task1.usTaskPrio = TASK_PRIO_TEST - 1;
|
||||
task1.uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
|
||||
g_testCount++;
|
||||
@@ -57,7 +58,7 @@ static VOID TaskF01(VOID)
|
||||
ret = LOS_TaskCreate(&g_testTaskID02, &task1);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ret = LOS_TaskDelay(2); // 2, set delay time
|
||||
ret = LOS_TaskJoin(g_testTaskID02, NULL);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
|
||||
@@ -76,13 +77,14 @@ static UINT32 TestCase(VOID)
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "Tsk051A";
|
||||
task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
|
||||
task1.uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
|
||||
g_testCount = 0;
|
||||
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_TaskDelay(2); // 2, set delay time
|
||||
ret = LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, Here, assert that g_testCount is equal to 3.
|
||||
|
||||
@@ -65,7 +65,7 @@ static UINT32 TestCase(VOID)
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "Tsk094A";
|
||||
task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
|
||||
task1.uwResved = 0;
|
||||
task1.uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
task1.uwArg = 0xffff;
|
||||
|
||||
g_testCount = 0;
|
||||
@@ -101,12 +101,22 @@ static UINT32 TestCase(VOID)
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3.
|
||||
|
||||
LOS_TaskDelay(10); // 10, set delay time
|
||||
ret = LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
ret = LOS_TaskJoin(g_testTaskID02, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
ret = LOS_TaskJoin(g_testTaskID03, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testTaskID01);
|
||||
LOS_TaskDelete(g_testTaskID02);
|
||||
LOS_TaskDelete(g_testTaskID03);
|
||||
LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
LOS_TaskJoin(g_testTaskID02, NULL);
|
||||
LOS_TaskJoin(g_testTaskID03, NULL);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ static UINT32 TestCase(VOID)
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "Tsk095A";
|
||||
task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
|
||||
task1.uwResved = LOS_TASK_STATUS_DETACHED;
|
||||
task1.uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
|
||||
g_testCount = 0;
|
||||
ret = LOS_TaskCreateOnly(&g_testTaskID01, &task1);
|
||||
@@ -56,7 +56,8 @@ static UINT32 TestCase(VOID)
|
||||
|
||||
LOS_TaskResume(g_testTaskID01);
|
||||
|
||||
LOS_TaskDelay(10); // 10, set delay time
|
||||
ret = LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
ret = LOS_TaskCreateOnly(&g_testTaskID01, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
@@ -66,11 +67,13 @@ static UINT32 TestCase(VOID)
|
||||
ret = LOS_TaskDelete(g_testTaskID01);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
|
||||
return LOS_OK;
|
||||
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testTaskID01);
|
||||
|
||||
LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,13 +72,14 @@ static UINT32 TestCase(VOID)
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "Tsk097A";
|
||||
task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
|
||||
task1.uwResved = LOS_TASK_STATUS_DETACHED;
|
||||
task1.uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
|
||||
g_testCount = 0;
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
LOS_TaskDelay(10); // 10, set delay time
|
||||
ret = LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
|
||||
|
||||
@@ -92,7 +93,7 @@ static UINT32 TestCase(VOID)
|
||||
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testTaskID01);
|
||||
|
||||
LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ static UINT32 TestCase(VOID)
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "Tsk098A";
|
||||
task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
|
||||
task1.uwResved = LOS_TASK_STATUS_DETACHED;
|
||||
task1.uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
|
||||
g_testCount = 0;
|
||||
|
||||
@@ -84,7 +84,8 @@ static UINT32 TestCase(VOID)
|
||||
|
||||
LOS_TaskResume(g_testTaskID01);
|
||||
|
||||
LOS_TaskDelay(10); // 10, set delay time
|
||||
ret = LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
|
||||
|
||||
@@ -98,6 +99,7 @@ static UINT32 TestCase(VOID)
|
||||
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testTaskID01);
|
||||
LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ static UINT32 TestCase(VOID)
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "Tsk100A";
|
||||
task1.usTaskPrio = TASK_PRIO_TEST - 1;
|
||||
task1.uwResved = LOS_TASK_STATUS_DETACHED;
|
||||
task1.uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
|
||||
g_testCount = 0;
|
||||
|
||||
@@ -70,7 +70,8 @@ static UINT32 TestCase(VOID)
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
|
||||
|
||||
LOS_TaskDelay(10); // 10, set delay time
|
||||
ret = LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = LOS_TaskPriGet(g_testTaskID01);
|
||||
ICUNIT_ASSERT_EQUAL(ret, (UINT16)OS_INVALID, ret);
|
||||
@@ -78,6 +79,7 @@ static UINT32 TestCase(VOID)
|
||||
return LOS_OK;
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testTaskID01);
|
||||
LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ static UINT32 TestCase(VOID)
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "Tsk101A";
|
||||
task1.usTaskPrio = TASK_PRIO_TEST - 1;
|
||||
task1.uwResved = LOS_TASK_STATUS_DETACHED;
|
||||
task1.uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
|
||||
g_testCount = 0;
|
||||
|
||||
@@ -70,7 +70,8 @@ static UINT32 TestCase(VOID)
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
|
||||
|
||||
LOS_TaskDelay(10); // 10, set delay time
|
||||
ret = LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ret = LOS_TaskPriGet(g_testTaskID01);
|
||||
ICUNIT_ASSERT_EQUAL(ret, (UINT16)OS_INVALID, ret);
|
||||
@@ -78,6 +79,7 @@ static UINT32 TestCase(VOID)
|
||||
return LOS_OK;
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testTaskID01);
|
||||
LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
@@ -86,13 +86,14 @@ static UINT32 TestCase(VOID)
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "Tsk103A";
|
||||
task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
|
||||
task1.uwResved = LOS_TASK_STATUS_DETACHED;
|
||||
task1.uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
|
||||
g_testCount = 0;
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
LOS_TaskDelay(20); // 20, set delay time
|
||||
ret = LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
|
||||
|
||||
@@ -100,7 +101,7 @@ static UINT32 TestCase(VOID)
|
||||
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testTaskID01);
|
||||
|
||||
LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -91,13 +91,14 @@ static UINT32 TestCase(VOID)
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "Tsk104A";
|
||||
task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
|
||||
task1.uwResved = LOS_TASK_STATUS_DETACHED;
|
||||
task1.uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
|
||||
g_testCount = 0;
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
LOS_TaskDelay(10); // 10, set delay time
|
||||
ret = LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
|
||||
|
||||
@@ -105,7 +106,7 @@ static UINT32 TestCase(VOID)
|
||||
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testTaskID01);
|
||||
|
||||
LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ static UINT32 TestCase(VOID)
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "Tsk105A";
|
||||
task1.usTaskPrio = TASK_PRIO_TEST - 1;
|
||||
task1.uwResved = LOS_TASK_STATUS_DETACHED;
|
||||
task1.uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
|
||||
g_testCount = 0;
|
||||
|
||||
@@ -79,7 +79,8 @@ static UINT32 TestCase(VOID)
|
||||
ret = LOS_TaskPriSet(g_testTaskID01, OS_TASK_PRIORITY_LOWEST + 1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_PRIOR_ERROR, ret);
|
||||
|
||||
LOS_TaskDelay(10); // 10, set delay time
|
||||
ret = LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
|
||||
|
||||
@@ -90,6 +91,7 @@ static UINT32 TestCase(VOID)
|
||||
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testTaskID01);
|
||||
LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -89,13 +89,14 @@ static UINT32 TestCase(VOID)
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "Tsk107A";
|
||||
task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
|
||||
task1.uwResved = LOS_TASK_STATUS_DETACHED;
|
||||
task1.uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
|
||||
g_testCount = 0;
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
LOS_TaskDelay(10); // 10, set delay time
|
||||
ret = LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3.
|
||||
|
||||
@@ -103,7 +104,7 @@ static UINT32 TestCase(VOID)
|
||||
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testTaskID01);
|
||||
|
||||
LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -92,13 +92,14 @@ static UINT32 TestCase(VOID)
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "Tsk108A";
|
||||
task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
|
||||
task1.uwResved = LOS_TASK_STATUS_DETACHED;
|
||||
task1.uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
|
||||
g_testCount = 0;
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
LOS_TaskDelay(20); // 20, set delay time
|
||||
ret = LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, Here, assert that g_testCount is equal to 4.
|
||||
|
||||
@@ -106,7 +107,7 @@ static UINT32 TestCase(VOID)
|
||||
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testTaskID01);
|
||||
|
||||
LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -88,14 +88,15 @@ static UINT32 TestCase(VOID)
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "Tsk109A";
|
||||
task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
|
||||
task1.uwResved = LOS_TASK_STATUS_DETACHED;
|
||||
task1.uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
|
||||
g_testCount = 0;
|
||||
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
LOS_TaskDelay(10); // 10, set delay time
|
||||
ret = LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3.
|
||||
|
||||
@@ -103,7 +104,7 @@ static UINT32 TestCase(VOID)
|
||||
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testTaskID01);
|
||||
|
||||
LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -94,13 +94,14 @@ static UINT32 TestCase(VOID)
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "Tsk110A";
|
||||
task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
|
||||
task1.uwResved = LOS_TASK_STATUS_DETACHED;
|
||||
task1.uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
|
||||
g_testCount = 0;
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
LOS_TaskDelay(10); // 10, set delay time
|
||||
ret = LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, Here, assert that g_testCount is equal to 4.
|
||||
|
||||
@@ -108,7 +109,7 @@ static UINT32 TestCase(VOID)
|
||||
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testTaskID01);
|
||||
|
||||
LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,10 +42,10 @@ static VOID TaskF02(VOID)
|
||||
g_testCount++;
|
||||
|
||||
// 3, modify task priority, base on testsuite task`s priority.
|
||||
ret = LOS_TaskPriSet(g_testTaskID01, TASK_PRIO_TEST - 3);
|
||||
ret = LOS_TaskPriSet(g_testTaskID01, TASK_PRIO_TEST - 1); /* 1: Priority is relatively cheap */
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); /* 1: count */
|
||||
g_testCount++;
|
||||
|
||||
return;
|
||||
@@ -70,7 +70,7 @@ static VOID TaskF01(VOID)
|
||||
ret = LOS_TaskPriGet(g_testTaskID01);
|
||||
|
||||
// 3, Assert this result is consistent with the priority that has been set.
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST - 3, ret);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST - 1, ret); /* 1: Priority is relatively cheap */
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
|
||||
g_testCount++;
|
||||
@@ -91,13 +91,14 @@ static UINT32 TestCase(VOID)
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "Tsk111A";
|
||||
task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
|
||||
task1.uwResved = LOS_TASK_STATUS_DETACHED;
|
||||
task1.uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
|
||||
g_testCount = 0;
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
LOS_TaskDelay(10); // 10, set delay time
|
||||
ret = LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3.
|
||||
|
||||
@@ -105,7 +106,7 @@ static UINT32 TestCase(VOID)
|
||||
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testTaskID01);
|
||||
|
||||
LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,9 +32,6 @@
|
||||
#include "osTest.h"
|
||||
#include "It_los_task.h"
|
||||
|
||||
|
||||
|
||||
|
||||
static VOID TaskF02(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
@@ -93,13 +90,14 @@ static UINT32 TestCase(VOID)
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "Tsk112A";
|
||||
task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
|
||||
task1.uwResved = LOS_TASK_STATUS_DETACHED;
|
||||
task1.uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
|
||||
g_testCount = 0;
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
LOS_TaskDelay(10); // 10, set delay time
|
||||
ret = LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3.
|
||||
|
||||
@@ -107,7 +105,7 @@ static UINT32 TestCase(VOID)
|
||||
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testTaskID01);
|
||||
|
||||
LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -99,13 +99,14 @@ static UINT32 TestCase(VOID)
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "Tsk113A";
|
||||
task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
|
||||
task1.uwResved = LOS_TASK_STATUS_DETACHED;
|
||||
task1.uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
|
||||
g_testCount = 0;
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
LOS_TaskDelay(10); // 10, set delay time
|
||||
ret = LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, Here, assert that g_testCount is equal to 5.
|
||||
|
||||
@@ -113,7 +114,7 @@ static UINT32 TestCase(VOID)
|
||||
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testTaskID01);
|
||||
|
||||
LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -98,13 +98,14 @@ static UINT32 TestCase(VOID)
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "Tsk078A";
|
||||
task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
|
||||
task1.uwResved = LOS_TASK_STATUS_DETACHED;
|
||||
task1.uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
|
||||
g_testCount = 0;
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
LOS_TaskDelay(10); // 10, set delay time
|
||||
ret = LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, Here, assert that g_testCount is equal to 4.
|
||||
|
||||
@@ -112,7 +113,7 @@ static UINT32 TestCase(VOID)
|
||||
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testTaskID01);
|
||||
|
||||
LOS_TaskJoin(g_testTaskID01, NULL);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
|
||||
70
testsuits/sample/kernel/task/It_los_task_118.c
Normal file
70
testsuits/sample/kernel/task/It_los_task_118.c
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "osTest.h"
|
||||
#include "It_los_task.h"
|
||||
|
||||
static VOID *TaskJoinf01(void *argument)
|
||||
{
|
||||
g_testCount++;
|
||||
|
||||
return (VOID *)9; /* 9: return val */
|
||||
}
|
||||
|
||||
static UINT32 TestCase(VOID)
|
||||
{
|
||||
UINT32 taskID;
|
||||
UINT32 ret;
|
||||
UINTPTR uwtemp = 1;
|
||||
TSK_INIT_PARAM_S osTaskInitParam = { 0 };
|
||||
|
||||
g_testCount = 0;
|
||||
|
||||
osTaskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskJoinf01;
|
||||
osTaskInitParam.uwStackSize = OS_TSK_TEST_STACK_SIZE;
|
||||
osTaskInitParam.pcName = "Join";
|
||||
osTaskInitParam.usTaskPrio = TASK_PRIO_TEST;
|
||||
osTaskInitParam.uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
|
||||
ret = LOS_TaskCreate(&taskID, &osTaskInitParam);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = LOS_TaskJoin(taskID, &uwtemp);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ICUNIT_ASSERT_EQUAL(uwtemp, 9, uwtemp); /* 8: pthread exit code */
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosTask118(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("ItLosTask118", TestCase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
|
||||
72
testsuits/sample/kernel/task/It_los_task_119.c
Normal file
72
testsuits/sample/kernel/task/It_los_task_119.c
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "osTest.h"
|
||||
#include "It_los_task.h"
|
||||
|
||||
static VOID *TaskDeatchf01(void *argument)
|
||||
{
|
||||
int ret = LOS_TaskDetach(LOS_CurTaskIDGet());
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_JOIN, ret);
|
||||
|
||||
g_testCount++;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static UINT32 TestCase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
UINT32 taskID;
|
||||
TSK_INIT_PARAM_S osTaskInitParam = { 0 };
|
||||
|
||||
g_testCount = 0;
|
||||
|
||||
osTaskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskDeatchf01;
|
||||
osTaskInitParam.uwStackSize = OS_TSK_TEST_STACK_SIZE;
|
||||
osTaskInitParam.pcName = "IT_TST_INI";
|
||||
osTaskInitParam.usTaskPrio = TASK_PRIO_TEST + 1;
|
||||
osTaskInitParam.uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
|
||||
ret = LOS_TaskCreate(&taskID, &osTaskInitParam);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = LOS_TaskJoin(taskID, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosTask119(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("ItLosTask119", TestCase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
|
||||
74
testsuits/sample/kernel/task/It_los_task_120.c
Normal file
74
testsuits/sample/kernel/task/It_los_task_120.c
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "osTest.h"
|
||||
#include "It_los_task.h"
|
||||
|
||||
static VOID *TaskDeatchf01(void *argument)
|
||||
{
|
||||
UINT32 ret = LOS_TaskDetach(LOS_CurTaskIDGet());
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
g_testCount++;
|
||||
|
||||
LOS_TaskDelay(1000); /* 1000 ticks */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static UINT32 TestCase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
UINT32 taskID;
|
||||
TSK_INIT_PARAM_S osTaskInitParam = { 0 };
|
||||
|
||||
g_testCount = 0;
|
||||
|
||||
osTaskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskDeatchf01;
|
||||
osTaskInitParam.uwStackSize = OS_TSK_TEST_STACK_SIZE;
|
||||
osTaskInitParam.pcName = "deatch";
|
||||
osTaskInitParam.usTaskPrio = TASK_PRIO_TEST - 1;
|
||||
osTaskInitParam.uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
|
||||
ret = LOS_TaskCreate(&taskID, &osTaskInitParam);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
|
||||
|
||||
ret = LOS_TaskJoin(taskID, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_NOK, ret);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosTask120(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("ItLosTask120", TestCase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
|
||||
73
testsuits/sample/kernel/task/It_los_task_121.c
Normal file
73
testsuits/sample/kernel/task/It_los_task_121.c
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "osTest.h"
|
||||
#include "It_los_task.h"
|
||||
|
||||
static VOID *TaskDeatchf01(void *argument)
|
||||
{
|
||||
UINT32 ret = LOS_TaskDetach(LOS_CurTaskIDGet());
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_NOK, ret);
|
||||
|
||||
g_testCount++;
|
||||
|
||||
LOS_TaskDelay(1000); /* 1000 ticks */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static UINT32 TestCase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
UINT32 taskID;
|
||||
TSK_INIT_PARAM_S osTaskInitParam = { 0 };
|
||||
|
||||
g_testCount = 0;
|
||||
|
||||
osTaskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskDeatchf01;
|
||||
osTaskInitParam.uwStackSize = OS_TSK_TEST_STACK_SIZE;
|
||||
osTaskInitParam.pcName = "deatch";
|
||||
osTaskInitParam.usTaskPrio = TASK_PRIO_TEST - 1;
|
||||
|
||||
ret = LOS_TaskCreate(&taskID, &osTaskInitParam);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
|
||||
|
||||
ret = LOS_TaskJoin(taskID, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_NOK, ret);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosTask121(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("ItLosTask121", TestCase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
|
||||
87
testsuits/sample/kernel/task/It_los_task_122.c
Normal file
87
testsuits/sample/kernel/task/It_los_task_122.c
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "osTest.h"
|
||||
#include "It_los_task.h"
|
||||
|
||||
static UINT32 g_joinTaskID;
|
||||
static VOID *TaskJoinf01(void *argument)
|
||||
{
|
||||
g_testCount++;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static VOID *TaskJoinf02(VOID *argument)
|
||||
{
|
||||
UINT32 ret = LOS_TaskDelete(g_joinTaskID);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static UINT32 TestCase(VOID)
|
||||
{
|
||||
UINT32 taskID;
|
||||
UINT32 ret;
|
||||
UINTPTR temp = 0;
|
||||
TSK_INIT_PARAM_S osTaskInitParam = { 0 };
|
||||
|
||||
g_testCount = 0;
|
||||
|
||||
osTaskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskJoinf01;
|
||||
osTaskInitParam.uwStackSize = OS_TSK_TEST_STACK_SIZE;
|
||||
osTaskInitParam.pcName = "Join";
|
||||
osTaskInitParam.usTaskPrio = TASK_PRIO_TEST + 1;
|
||||
osTaskInitParam.uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
|
||||
ret = LOS_TaskCreate(&g_joinTaskID, &osTaskInitParam);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
osTaskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskJoinf02;
|
||||
osTaskInitParam.uwStackSize = OS_TSK_TEST_STACK_SIZE;
|
||||
osTaskInitParam.pcName = "deatch";
|
||||
osTaskInitParam.usTaskPrio = TASK_PRIO_TEST - 1;
|
||||
|
||||
ret = LOS_TaskCreate(&taskID, &osTaskInitParam);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = LOS_TaskJoin(g_joinTaskID, &temp);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ICUNIT_ASSERT_EQUAL(temp, taskID, temp);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosTask122(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("ItLosTask122", TestCase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
|
||||
@@ -129,6 +129,10 @@ void TestKernel(void)
|
||||
#if (LOS_KERNEL_DYNLINK_TEST == 1)
|
||||
ItSuiteLosDynlink();
|
||||
#endif
|
||||
|
||||
#if (LOS_KERNEL_PM_TEST == 1)
|
||||
ItSuiteLosPm();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -180,13 +184,13 @@ VOID TestTaskEntry()
|
||||
UINT32 los_TestInit(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
TSK_INIT_PARAM_S osTaskInitParam;
|
||||
TSK_INIT_PARAM_S osTaskInitParam = { 0 };
|
||||
|
||||
osTaskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)TestTaskEntry;
|
||||
osTaskInitParam.uwStackSize = OS_TSK_TEST_STACK_SIZE;
|
||||
osTaskInitParam.pcName = "IT_TST_INI";
|
||||
osTaskInitParam.usTaskPrio = TASK_PRIO_TEST;
|
||||
osTaskInitParam.uwResved = LOS_TASK_STATUS_DETACHED;
|
||||
osTaskInitParam.uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
|
||||
ret = LOS_TaskCreate(&g_testTskHandle, &osTaskInitParam);
|
||||
if (LOS_OK != ret) {
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
#include "cmsis_os2.h"
|
||||
#include "common_test.h"
|
||||
|
||||
static UINT32 g_testCount;
|
||||
|
||||
/**
|
||||
* @tc.desc : register a test suite, this suite is used to test basic flow and interface dependency
|
||||
* @param : subsystem name is pthread
|
||||
@@ -63,13 +65,234 @@ static BOOL PthreadFuncTestSuiteTearDown(void)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static VOID *pthread_join_f01(void *argument)
|
||||
{
|
||||
g_testCount++;
|
||||
|
||||
pthread_exit((void *)8); /* 8: pthread exit code */
|
||||
return (void *)9; /* 9: return val */
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_PTHREAD_OPERATION_001
|
||||
* @tc.name : event operation for creat
|
||||
* @tc.name : event operation for join
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(PthreadFuncTestSuite, testPthread001, Function | MediumTest | Level1)
|
||||
{
|
||||
pthread_attr_t attr;
|
||||
pthread_t newTh;
|
||||
struct sched_param schedParam = { 0 };
|
||||
UINT32 ret;
|
||||
UINTPTR uwtemp = 1;
|
||||
|
||||
g_testCount = 0;
|
||||
|
||||
ret = pthread_attr_init(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_attr_setstacksize(&attr, OS_TSK_TEST_STACK_SIZE);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
schedParam.sched_priority = TASK_PRIO_TEST;
|
||||
ret = pthread_attr_setschedparam(&attr, &schedParam);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_create(&newTh, &attr, pthread_join_f01, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_join(newTh, (void **)&uwtemp);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ICUNIT_ASSERT_EQUAL(uwtemp, 8, uwtemp); /* 8: pthread exit code */
|
||||
|
||||
return LOS_OK;
|
||||
};
|
||||
|
||||
static VOID *pthread_join_f02(void *argument)
|
||||
{
|
||||
g_testCount++;
|
||||
|
||||
return (void *)9; /* 9: return val */
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_PTHREAD_OPERATION_002
|
||||
* @tc.name : event operation for join
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(PthreadFuncTestSuite, testPthread002, Function | MediumTest | Level1)
|
||||
{
|
||||
pthread_attr_t attr;
|
||||
pthread_t newTh;
|
||||
struct sched_param schedParam = { 0 };
|
||||
UINT32 ret;
|
||||
UINTPTR uwtemp = 1;
|
||||
|
||||
g_testCount = 0;
|
||||
|
||||
ret = pthread_attr_init(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_attr_setstacksize(&attr, OS_TSK_TEST_STACK_SIZE);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
schedParam.sched_priority = TASK_PRIO_TEST;
|
||||
ret = pthread_attr_setschedparam(&attr, &schedParam);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_create(&newTh, &attr, pthread_join_f02, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_join(newTh, (void **)&uwtemp);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ICUNIT_ASSERT_EQUAL(uwtemp, 9, uwtemp); /* 9: pthread exit code */
|
||||
|
||||
return LOS_OK;
|
||||
};
|
||||
|
||||
static VOID *pthread_join_f03(void *argument)
|
||||
{
|
||||
int ret = pthread_detach(pthread_self());
|
||||
ICUNIT_ASSERT_EQUAL(ret, ESRCH, ret);
|
||||
|
||||
g_testCount++;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_PTHREAD_OPERATION_003
|
||||
* @tc.name : event operation for deatch
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(PthreadFuncTestSuite, testPthread003, Function | MediumTest | Level1)
|
||||
{
|
||||
pthread_attr_t attr;
|
||||
pthread_t newTh;
|
||||
struct sched_param schedParam = { 0 };
|
||||
UINT32 ret;
|
||||
|
||||
g_testCount = 0;
|
||||
|
||||
ret = pthread_attr_init(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_attr_setstacksize(&attr, OS_TSK_TEST_STACK_SIZE);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
schedParam.sched_priority = TASK_PRIO_TEST + 1;
|
||||
ret = pthread_attr_setschedparam(&attr, &schedParam);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_create(&newTh, &attr, pthread_join_f03, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_join(newTh, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
|
||||
return LOS_OK;
|
||||
};
|
||||
|
||||
static VOID *pthread_join_f04(void *argument)
|
||||
{
|
||||
int ret = pthread_detach(pthread_self());
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
g_testCount++;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_PTHREAD_OPERATION_004
|
||||
* @tc.name : event operation for deatch
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(PthreadFuncTestSuite, testPthread004, Function | MediumTest | Level1)
|
||||
{
|
||||
pthread_attr_t attr;
|
||||
pthread_t newTh;
|
||||
struct sched_param schedParam = { 0 };
|
||||
UINT32 ret;
|
||||
|
||||
g_testCount = 0;
|
||||
|
||||
ret = pthread_attr_init(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_attr_setstacksize(&attr, OS_TSK_TEST_STACK_SIZE);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
schedParam.sched_priority = TASK_PRIO_TEST - 1;
|
||||
ret = pthread_attr_setschedparam(&attr, &schedParam);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_create(&newTh, &attr, pthread_join_f04, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
|
||||
|
||||
ret = pthread_join(newTh, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
|
||||
|
||||
return LOS_OK;
|
||||
};
|
||||
|
||||
static VOID *pthread_join_f05(void *argument)
|
||||
{
|
||||
int ret = pthread_detach(pthread_self());
|
||||
ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
|
||||
|
||||
usleep(100000); /* 100000: sleep 100 ms */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_PTHREAD_OPERATION_005
|
||||
* @tc.name : event operation for deatch
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(PthreadFuncTestSuite, testPthread005, Function | MediumTest | Level1)
|
||||
{
|
||||
pthread_attr_t attr;
|
||||
pthread_t newTh;
|
||||
struct sched_param schedParam = { 0 };
|
||||
UINT32 ret;
|
||||
|
||||
ret = pthread_attr_init(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_attr_setstacksize(&attr, OS_TSK_TEST_STACK_SIZE);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
schedParam.sched_priority = TASK_PRIO_TEST - 1;
|
||||
ret = pthread_attr_setschedparam(&attr, &schedParam);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_create(&newTh, &attr, pthread_join_f05, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_join(newTh, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
|
||||
|
||||
return LOS_OK;
|
||||
};
|
||||
|
||||
RUN_TEST_SUITE(PthreadFuncTestSuite);
|
||||
|
||||
@@ -127,7 +127,6 @@ typedef enum {
|
||||
* @par Dependency:
|
||||
* <ul><li>los_printf.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see LOS_Printf
|
||||
* @since none
|
||||
*/
|
||||
#if (LOSCFG_KERNEL_PRINTF == 1)
|
||||
extern INT32 printf(const CHAR *fmt, ...);
|
||||
|
||||
Reference in New Issue
Block a user