Compare commits
23 Commits
weekly_202
...
weekly_202
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
76366bc358 | ||
|
|
11e7f0f5e2 | ||
|
|
35971d660e | ||
|
|
289ad2c57d | ||
|
|
e20444cda6 | ||
|
|
b9830c61f5 | ||
|
|
cee9714a90 | ||
|
|
ffd228cd8d | ||
|
|
5af4c2e213 | ||
|
|
b423d9f7bb | ||
|
|
fb11ab181e | ||
|
|
c811efbf37 | ||
|
|
9bc9f3aa53 | ||
|
|
db7d641c22 | ||
|
|
a68323683d | ||
|
|
59e9c6ed73 | ||
|
|
d1d412255c | ||
|
|
b534083056 | ||
|
|
968c00f049 | ||
|
|
df0ed8d219 | ||
|
|
4b607fd074 | ||
|
|
8b586fb2bf | ||
|
|
d986648e9c |
@@ -173,11 +173,13 @@ LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||
|
||||
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
||||
{
|
||||
(VOID)arg;
|
||||
return;
|
||||
}
|
||||
|
||||
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
||||
{
|
||||
(VOID)arg;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -243,6 +245,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
HWI_PROC_FUNC handler,
|
||||
HWI_ARG_T arg)
|
||||
{
|
||||
(VOID)mode;
|
||||
UINT32 intSave;
|
||||
|
||||
if (handler == NULL) {
|
||||
@@ -261,6 +264,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||
OsSetVector(hwiNum, handler, arg);
|
||||
#else
|
||||
(VOID)arg;
|
||||
OsSetVector(hwiNum, handler);
|
||||
#endif
|
||||
HwiUnmask(hwiNum);
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
#define OS_TIMER_READ_VAL_ADDR (OS_TIMER_REG_BASE + 20)
|
||||
|
||||
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
|
||||
STATIC VOID SysTickReload(UINT64 nextResponseTime);
|
||||
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period);
|
||||
STATIC VOID SysTickLock(VOID);
|
||||
STATIC VOID SysTickUnlock(VOID);
|
||||
@@ -60,6 +60,7 @@ STATIC VOID SysTickUnlock(VOID);
|
||||
STATIC ArchTickTimer g_archTickTimer = {
|
||||
.freq = 0,
|
||||
.irqNum = OS_TIMER_IRQ_NUM,
|
||||
.periodMax = LOSCFG_BASE_CORE_TICK_RESPONSE_MAX,
|
||||
.init = SysTickStart,
|
||||
.getCycle = SysTickCycleGet,
|
||||
.reload = SysTickReload,
|
||||
@@ -107,12 +108,17 @@ STATIC VOID SysTickClockIrqClear(VOID)
|
||||
} while (status & mask);
|
||||
}
|
||||
|
||||
STATIC VOID SysTickReload(UINT64 nextResponseTime)
|
||||
STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
||||
{
|
||||
if (nextResponseTime > g_archTickTimer.periodMax) {
|
||||
nextResponseTime = g_archTickTimer.periodMax;
|
||||
}
|
||||
|
||||
SysTickLock();
|
||||
WRITE_UINT32(nextResponseTime, OS_TIMER_PERIOD_REG_ADDR);
|
||||
WRITE_UINT32((UINT32)nextResponseTime, OS_TIMER_PERIOD_REG_ADDR);
|
||||
SysTickClockIrqClear();
|
||||
SysTickUnlock();
|
||||
return nextResponseTime;
|
||||
}
|
||||
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
||||
|
||||
@@ -208,11 +208,13 @@ LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||
|
||||
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
||||
{
|
||||
(VOID)arg;
|
||||
return;
|
||||
}
|
||||
|
||||
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
||||
{
|
||||
(VOID)arg;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -278,6 +280,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
HWI_PROC_FUNC handler,
|
||||
HWI_ARG_T arg)
|
||||
{
|
||||
(VOID)mode;
|
||||
UINT32 intSave;
|
||||
|
||||
if (handler == NULL) {
|
||||
@@ -300,6 +303,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||
OsSetVector(hwiNum, handler, arg);
|
||||
#else
|
||||
(VOID)arg;
|
||||
OsSetVector(hwiNum, handler);
|
||||
#endif
|
||||
HwiUnmask((IRQn_Type)hwiNum);
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#include "los_debug.h"
|
||||
|
||||
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
|
||||
STATIC VOID SysTickReload(UINT64 nextResponseTime);
|
||||
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period);
|
||||
STATIC VOID SysTickLock(VOID);
|
||||
STATIC VOID SysTickUnlock(VOID);
|
||||
@@ -45,6 +45,7 @@ STATIC VOID SysTickUnlock(VOID);
|
||||
STATIC ArchTickTimer g_archTickTimer = {
|
||||
.freq = 0,
|
||||
.irqNum = SysTick_IRQn,
|
||||
.periodMax = LOSCFG_BASE_CORE_TICK_RESPONSE_MAX,
|
||||
.init = SysTickStart,
|
||||
.getCycle = SysTickCycleGet,
|
||||
.reload = SysTickReload,
|
||||
@@ -76,13 +77,19 @@ STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC VOID SysTickReload(UINT64 nextResponseTime)
|
||||
STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
||||
{
|
||||
if (nextResponseTime > g_archTickTimer.periodMax) {
|
||||
nextResponseTime = g_archTickTimer.periodMax;
|
||||
}
|
||||
|
||||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||
|
||||
return nextResponseTime;
|
||||
}
|
||||
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
||||
|
||||
@@ -199,11 +199,13 @@ LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||
|
||||
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
||||
{
|
||||
(VOID)arg;
|
||||
return;
|
||||
}
|
||||
|
||||
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
||||
{
|
||||
(VOID)arg;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -269,6 +271,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
HWI_PROC_FUNC handler,
|
||||
HWI_ARG_T arg)
|
||||
{
|
||||
(VOID)mode;
|
||||
UINT32 intSave;
|
||||
|
||||
if (handler == NULL) {
|
||||
@@ -291,6 +294,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||
OsSetVector(hwiNum, handler, arg);
|
||||
#else
|
||||
(VOID)arg;
|
||||
OsSetVector(hwiNum, handler);
|
||||
#endif
|
||||
HwiUnmask((IRQn_Type)hwiNum);
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "los_debug.h"
|
||||
|
||||
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
|
||||
STATIC VOID SysTickReload(UINT64 nextResponseTime);
|
||||
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period);
|
||||
STATIC VOID SysTickLock(VOID);
|
||||
STATIC VOID SysTickUnlock(VOID);
|
||||
@@ -44,6 +44,7 @@ STATIC VOID SysTickUnlock(VOID);
|
||||
STATIC ArchTickTimer g_archTickTimer = {
|
||||
.freq = 0,
|
||||
.irqNum = SysTick_IRQn,
|
||||
.periodMax = LOSCFG_BASE_CORE_TICK_RESPONSE_MAX,
|
||||
.init = SysTickStart,
|
||||
.getCycle = SysTickCycleGet,
|
||||
.reload = SysTickReload,
|
||||
@@ -75,13 +76,18 @@ STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC VOID SysTickReload(UINT64 nextResponseTime)
|
||||
STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
||||
{
|
||||
if (nextResponseTime > g_archTickTimer.periodMax) {
|
||||
nextResponseTime = g_archTickTimer.periodMax;
|
||||
}
|
||||
|
||||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||
return nextResponseTime;
|
||||
}
|
||||
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
||||
|
||||
@@ -199,11 +199,13 @@ LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||
|
||||
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
||||
{
|
||||
(VOID)arg;
|
||||
return;
|
||||
}
|
||||
|
||||
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
||||
{
|
||||
(VOID)arg;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -269,6 +271,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
HWI_PROC_FUNC handler,
|
||||
HWI_ARG_T arg)
|
||||
{
|
||||
(VOID)mode;
|
||||
UINT32 intSave;
|
||||
|
||||
if (handler == NULL) {
|
||||
@@ -291,6 +294,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||
OsSetVector(hwiNum, handler, arg);
|
||||
#else
|
||||
(VOID)arg;
|
||||
OsSetVector(hwiNum, handler);
|
||||
#endif
|
||||
HwiUnmask((IRQn_Type)hwiNum);
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "los_arch_interrupt.h"
|
||||
|
||||
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
|
||||
STATIC VOID SysTickReload(UINT64 nextResponseTime);
|
||||
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period);
|
||||
STATIC VOID SysTickLock(VOID);
|
||||
STATIC VOID SysTickUnlock(VOID);
|
||||
@@ -43,6 +43,7 @@ STATIC VOID SysTickUnlock(VOID);
|
||||
STATIC ArchTickTimer g_archTickTimer = {
|
||||
.freq = 0,
|
||||
.irqNum = SysTick_IRQn,
|
||||
.periodMax = LOSCFG_BASE_CORE_TICK_RESPONSE_MAX,
|
||||
.init = SysTickStart,
|
||||
.getCycle = SysTickCycleGet,
|
||||
.reload = SysTickReload,
|
||||
@@ -74,13 +75,18 @@ STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC VOID SysTickReload(UINT64 nextResponseTime)
|
||||
STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
||||
{
|
||||
if (nextResponseTime > g_archTickTimer.periodMax) {
|
||||
nextResponseTime = g_archTickTimer.periodMax;
|
||||
}
|
||||
|
||||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||
return nextResponseTime;
|
||||
}
|
||||
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
||||
|
||||
@@ -205,11 +205,13 @@ LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||
|
||||
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
||||
{
|
||||
(VOID)arg;
|
||||
return;
|
||||
}
|
||||
|
||||
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
||||
{
|
||||
(VOID)arg;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -277,6 +279,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
HWI_PROC_FUNC handler,
|
||||
HWI_ARG_T arg)
|
||||
{
|
||||
(VOID)mode;
|
||||
UINTPTR intSave;
|
||||
|
||||
if (handler == NULL) {
|
||||
@@ -299,6 +302,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||
OsSetVector(hwiNum, handler, arg);
|
||||
#else
|
||||
(VOID)arg;
|
||||
OsSetVector(hwiNum, handler);
|
||||
#endif
|
||||
HwiUnmask((IRQn_Type)hwiNum);
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "los_debug.h"
|
||||
|
||||
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
|
||||
STATIC VOID SysTickReload(UINT64 nextResponseTime);
|
||||
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period);
|
||||
STATIC VOID SysTickLock(VOID);
|
||||
STATIC VOID SysTickUnlock(VOID);
|
||||
@@ -44,6 +44,7 @@ STATIC VOID SysTickUnlock(VOID);
|
||||
STATIC ArchTickTimer g_archTickTimer = {
|
||||
.freq = 0,
|
||||
.irqNum = SysTick_IRQn,
|
||||
.periodMax = LOSCFG_BASE_CORE_TICK_RESPONSE_MAX,
|
||||
.init = SysTickStart,
|
||||
.getCycle = SysTickCycleGet,
|
||||
.reload = SysTickReload,
|
||||
@@ -75,13 +76,17 @@ STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC VOID SysTickReload(UINT64 nextResponseTime)
|
||||
STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
||||
{
|
||||
if (nextResponseTime > g_archTickTimer.periodMax) {
|
||||
nextResponseTime = g_archTickTimer.periodMax;
|
||||
}
|
||||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||
return nextResponseTime;
|
||||
}
|
||||
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
||||
|
||||
@@ -205,11 +205,13 @@ LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||
|
||||
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
||||
{
|
||||
(VOID)arg;
|
||||
return;
|
||||
}
|
||||
|
||||
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
||||
{
|
||||
(VOID)arg;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -277,6 +279,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
HWI_PROC_FUNC handler,
|
||||
HWI_ARG_T arg)
|
||||
{
|
||||
(VOID)mode;
|
||||
UINTPTR intSave;
|
||||
|
||||
if (handler == NULL) {
|
||||
@@ -299,6 +302,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||
OsSetVector(hwiNum, handler, arg);
|
||||
#else
|
||||
(VOID)arg;
|
||||
OsSetVector(hwiNum, handler);
|
||||
#endif
|
||||
HwiUnmask((IRQn_Type)hwiNum);
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "los_debug.h"
|
||||
|
||||
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
|
||||
STATIC VOID SysTickReload(UINT64 nextResponseTime);
|
||||
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period);
|
||||
STATIC VOID SysTickLock(VOID);
|
||||
STATIC VOID SysTickUnlock(VOID);
|
||||
@@ -44,6 +44,7 @@ STATIC VOID SysTickUnlock(VOID);
|
||||
STATIC ArchTickTimer g_archTickTimer = {
|
||||
.freq = 0,
|
||||
.irqNum = SysTick_IRQn,
|
||||
.periodMax = LOSCFG_BASE_CORE_TICK_RESPONSE_MAX,
|
||||
.init = SysTickStart,
|
||||
.getCycle = SysTickCycleGet,
|
||||
.reload = SysTickReload,
|
||||
@@ -75,13 +76,18 @@ STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC VOID SysTickReload(UINT64 nextResponseTime)
|
||||
STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
||||
{
|
||||
if (nextResponseTime > g_archTickTimer.periodMax) {
|
||||
nextResponseTime = g_archTickTimer.periodMax;
|
||||
}
|
||||
|
||||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||
return nextResponseTime;
|
||||
}
|
||||
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
||||
|
||||
@@ -203,11 +203,13 @@ LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||
|
||||
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
||||
{
|
||||
(VOID)arg;
|
||||
return;
|
||||
}
|
||||
|
||||
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
||||
{
|
||||
(VOID)arg;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -273,6 +275,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
HWI_PROC_FUNC handler,
|
||||
HWI_ARG_T arg)
|
||||
{
|
||||
(VOID)mode;
|
||||
UINT32 intSave;
|
||||
|
||||
if (handler == NULL) {
|
||||
@@ -295,6 +298,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||
OsSetVector(hwiNum, handler, arg);
|
||||
#else
|
||||
(VOID)arg;
|
||||
OsSetVector(hwiNum, handler);
|
||||
#endif
|
||||
HwiUnmask((IRQn_Type)hwiNum);
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "los_debug.h"
|
||||
|
||||
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
|
||||
STATIC VOID SysTickReload(UINT64 nextResponseTime);
|
||||
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period);
|
||||
STATIC VOID SysTickLock(VOID);
|
||||
STATIC VOID SysTickUnlock(VOID);
|
||||
@@ -44,6 +44,7 @@ STATIC VOID SysTickUnlock(VOID);
|
||||
STATIC ArchTickTimer g_archTickTimer = {
|
||||
.freq = 0,
|
||||
.irqNum = SysTick_IRQn,
|
||||
.periodMax = LOSCFG_BASE_CORE_TICK_RESPONSE_MAX,
|
||||
.init = SysTickStart,
|
||||
.getCycle = SysTickCycleGet,
|
||||
.reload = SysTickReload,
|
||||
@@ -75,13 +76,17 @@ STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC VOID SysTickReload(UINT64 nextResponseTime)
|
||||
STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
||||
{
|
||||
if (nextResponseTime > g_archTickTimer.periodMax) {
|
||||
nextResponseTime = g_archTickTimer.periodMax;
|
||||
}
|
||||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||
return nextResponseTime;
|
||||
}
|
||||
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
||||
|
||||
@@ -209,11 +209,13 @@ LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||
|
||||
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
||||
{
|
||||
(VOID)arg;
|
||||
return;
|
||||
}
|
||||
|
||||
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
||||
{
|
||||
(VOID)arg;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -279,6 +281,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
HWI_PROC_FUNC handler,
|
||||
HWI_ARG_T arg)
|
||||
{
|
||||
(VOID)mode;
|
||||
UINT32 intSave;
|
||||
|
||||
if (handler == NULL) {
|
||||
@@ -301,6 +304,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||
OsSetVector(hwiNum, handler, arg);
|
||||
#else
|
||||
(VOID)arg;
|
||||
OsSetVector(hwiNum, handler);
|
||||
#endif
|
||||
HwiUnmask((IRQn_Type)hwiNum);
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "los_debug.h"
|
||||
|
||||
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
|
||||
STATIC VOID SysTickReload(UINT64 nextResponseTime);
|
||||
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period);
|
||||
STATIC VOID SysTickLock(VOID);
|
||||
STATIC VOID SysTickUnlock(VOID);
|
||||
@@ -44,6 +44,7 @@ STATIC VOID SysTickUnlock(VOID);
|
||||
STATIC ArchTickTimer g_archTickTimer = {
|
||||
.freq = 0,
|
||||
.irqNum = SysTick_IRQn,
|
||||
.periodMax = LOSCFG_BASE_CORE_TICK_RESPONSE_MAX,
|
||||
.init = SysTickStart,
|
||||
.getCycle = SysTickCycleGet,
|
||||
.reload = SysTickReload,
|
||||
@@ -75,13 +76,17 @@ STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC VOID SysTickReload(UINT64 nextResponseTime)
|
||||
STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
||||
{
|
||||
if (nextResponseTime > g_archTickTimer.periodMax) {
|
||||
nextResponseTime = g_archTickTimer.periodMax;
|
||||
}
|
||||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||
return nextResponseTime;
|
||||
}
|
||||
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
||||
|
||||
@@ -41,6 +41,17 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct TagTskContext {
|
||||
UINT32 uwPspLim;
|
||||
UINT32 uwExcLR;
|
||||
UINT32 uwR4;
|
||||
UINT32 uwR5;
|
||||
UINT32 uwR6;
|
||||
UINT32 uwR7;
|
||||
UINT32 uwR8;
|
||||
UINT32 uwR9;
|
||||
UINT32 uwR10;
|
||||
UINT32 uwR11;
|
||||
UINT32 uwPriMask;
|
||||
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
||||
UINT32 S16;
|
||||
@@ -60,15 +71,6 @@ typedef struct TagTskContext {
|
||||
UINT32 S30;
|
||||
UINT32 S31;
|
||||
#endif
|
||||
UINT32 uwR4;
|
||||
UINT32 uwR5;
|
||||
UINT32 uwR6;
|
||||
UINT32 uwR7;
|
||||
UINT32 uwR8;
|
||||
UINT32 uwR9;
|
||||
UINT32 uwR10;
|
||||
UINT32 uwR11;
|
||||
UINT32 uwPriMask;
|
||||
UINT32 uwR0;
|
||||
UINT32 uwR1;
|
||||
UINT32 uwR2;
|
||||
|
||||
@@ -505,133 +505,150 @@ VOID HalExcUsageFault(VOID);
|
||||
VOID HalSVCHandler(VOID);
|
||||
VOID HalHwiInit(VOID);
|
||||
|
||||
/**
|
||||
* @ingroup los_exc
|
||||
* Cortex-M exception types: Record whether a precise BusFault occurred during floating-point lazy state preservation.
|
||||
*/
|
||||
#define OS_EXC_BF_LSPERR 1
|
||||
|
||||
/**
|
||||
* @ingroup los_exc
|
||||
* Cortex-M exception types: An error occurred while the bus status register was being pushed.
|
||||
*/
|
||||
#define OS_EXC_BF_STKERR 1
|
||||
#define OS_EXC_BF_STKERR 2
|
||||
|
||||
/**
|
||||
* @ingroup los_exc
|
||||
* Cortex-M exception types: An error occurred while the bus status register was out of the stack.
|
||||
*/
|
||||
#define OS_EXC_BF_UNSTKERR 2
|
||||
#define OS_EXC_BF_UNSTKERR 3
|
||||
|
||||
/**
|
||||
* @ingroup los_exc
|
||||
* Cortex-M exception types: Bus status register imprecise data access violation.
|
||||
*/
|
||||
#define OS_EXC_BF_IMPRECISERR 3
|
||||
#define OS_EXC_BF_IMPRECISERR 4
|
||||
|
||||
/**
|
||||
* @ingroup los_exc
|
||||
* Cortex-M exception types: Bus status register exact data access violation.
|
||||
*/
|
||||
#define OS_EXC_BF_PRECISERR 4
|
||||
#define OS_EXC_BF_PRECISERR 5
|
||||
|
||||
/**
|
||||
* @ingroup los_exc
|
||||
* Cortex-M exception types: Bus status register access violation while pointing.
|
||||
*/
|
||||
#define OS_EXC_BF_IBUSERR 5
|
||||
#define OS_EXC_BF_IBUSERR 6
|
||||
|
||||
/**
|
||||
* @ingroup los_exc
|
||||
* Cortex-M exception types: Record whether a MemManage fault occurred during floating-point lazy state preservation.
|
||||
*/
|
||||
#define OS_EXC_MF_MLSPERR 7
|
||||
|
||||
/**
|
||||
* @ingroup los_exc
|
||||
* Cortex-M exception types: An error occurred while the memory management status register was being pushed.
|
||||
*/
|
||||
#define OS_EXC_MF_MSTKERR 6
|
||||
#define OS_EXC_MF_MSTKERR 8
|
||||
|
||||
/**
|
||||
* @ingroup los_exc
|
||||
* Cortex-M exception types: An error occurred while the memory management status register was out of the stack.
|
||||
*/
|
||||
#define OS_EXC_MF_MUNSTKERR 7
|
||||
#define OS_EXC_MF_MUNSTKERR 9
|
||||
|
||||
/**
|
||||
* @ingroup los_exc
|
||||
* Cortex-M exception types: Memory management status register data access violation.
|
||||
*/
|
||||
#define OS_EXC_MF_DACCVIOL 8
|
||||
#define OS_EXC_MF_DACCVIOL 10
|
||||
|
||||
/**
|
||||
* @ingroup los_exc
|
||||
* Cortex-M exception types: Memory management status register access violation.
|
||||
*/
|
||||
#define OS_EXC_MF_IACCVIOL 9
|
||||
|
||||
#define OS_EXC_MF_IACCVIOL 11
|
||||
|
||||
/**
|
||||
* @ingroup los_exc
|
||||
* Cortex-M exception types: Incorrect usage indicating that the divisor is zero during the division operation.
|
||||
*/
|
||||
#define OS_EXC_UF_DIVBYZERO 10
|
||||
#define OS_EXC_UF_DIVBYZERO 12
|
||||
|
||||
/**
|
||||
* @ingroup los_exc
|
||||
* Cortex-M exception types: Usage error, error caused by unaligned access.
|
||||
*/
|
||||
#define OS_EXC_UF_UNALIGNED 11
|
||||
#define OS_EXC_UF_UNALIGNED 13
|
||||
|
||||
/**
|
||||
* @ingroup los_exc
|
||||
* Cortex-M exception types: Sticky flag indicating whether a stack overflow error has occurred.
|
||||
*/
|
||||
#define OS_EXC_UF_STKOF 14
|
||||
|
||||
/**
|
||||
* @ingroup los_exc
|
||||
* Cortex-M exception types: Incorrect usage attempting to execute coprocessor related instruction.
|
||||
*/
|
||||
#define OS_EXC_UF_NOCP 12
|
||||
#define OS_EXC_UF_NOCP 15
|
||||
|
||||
/**
|
||||
* @ingroup los_exc
|
||||
* Cortex-M exception types: Usage error attempting to load EXC_RETURN to PC illegally on exception return.
|
||||
*/
|
||||
#define OS_EXC_UF_INVPC 13
|
||||
#define OS_EXC_UF_INVPC 16
|
||||
|
||||
/**
|
||||
* @ingroup los_exc
|
||||
* Cortex-M exception types: Incorrect usage, attempting to cut to ARM state.
|
||||
*/
|
||||
#define OS_EXC_UF_INVSTATE 14
|
||||
#define OS_EXC_UF_INVSTATE 17
|
||||
|
||||
/**
|
||||
* @ingroup los_exc
|
||||
* Cortex-M exception types: Incorrect usage. Executed instruction whose code is undefined.
|
||||
*/
|
||||
#define OS_EXC_UF_UNDEFINSTR 15
|
||||
#define OS_EXC_UF_UNDEFINSTR 18
|
||||
|
||||
/**
|
||||
* @ingroup los_exc
|
||||
* Cortex-M exception types: NMI
|
||||
*/
|
||||
|
||||
#define OS_EXC_CAUSE_NMI 16
|
||||
#define OS_EXC_CAUSE_NMI 19
|
||||
|
||||
/**
|
||||
* @ingroup los_exc
|
||||
* Cortex-M exception types: hard fault
|
||||
*/
|
||||
#define OS_EXC_CAUSE_HARDFAULT 17
|
||||
#define OS_EXC_CAUSE_HARDFAULT 20
|
||||
|
||||
/**
|
||||
* @ingroup los_exc
|
||||
* Cortex-M exception types: The task handler exits.
|
||||
*/
|
||||
#define OS_EXC_CAUSE_TASK_EXIT 18
|
||||
#define OS_EXC_CAUSE_TASK_EXIT 21
|
||||
|
||||
/**
|
||||
* @ingroup los_exc
|
||||
* Cortex-M exception types: A fatal error.
|
||||
*/
|
||||
#define OS_EXC_CAUSE_FATAL_ERR 19
|
||||
#define OS_EXC_CAUSE_FATAL_ERR 22
|
||||
|
||||
/**
|
||||
* @ingroup los_exc
|
||||
* Cortex-M exception types: Hard Fault caused by a debug event.
|
||||
*/
|
||||
#define OS_EXC_CAUSE_DEBUGEVT 20
|
||||
#define OS_EXC_CAUSE_DEBUGEVT 23
|
||||
|
||||
/**
|
||||
* @ingroup los_exc
|
||||
* Cortex-M exception types: A hard fault that occurs when a quantity is oriented.
|
||||
*/
|
||||
#define OS_EXC_CAUSE_VECTBL 21
|
||||
#define OS_EXC_CAUSE_VECTBL 24
|
||||
|
||||
/**
|
||||
* @ingroup los_exc
|
||||
|
||||
@@ -112,8 +112,11 @@ LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VO
|
||||
context->S15 = 0xAA00000F;
|
||||
context->FPSCR = 0x00000000;
|
||||
context->NO_NAME = 0xAA000011;
|
||||
context->uwExcLR = 0xFFFFFFEDL;
|
||||
#else
|
||||
context->uwExcLR = 0xFFFFFFFDL;
|
||||
#endif
|
||||
|
||||
context->uwPspLim = (UINT32)topStack;
|
||||
context->uwR4 = 0x04040404L;
|
||||
context->uwR5 = 0x05050505L;
|
||||
context->uwR6 = 0x06060606L;
|
||||
|
||||
@@ -33,13 +33,10 @@
|
||||
.fpu vfpv3-d16-fp16
|
||||
.thumb
|
||||
|
||||
.equ OS_FPU_CPACR, 0xE000ED88
|
||||
.equ OS_FPU_CPACR_ENABLE, 0x00F00000
|
||||
.equ OS_NVIC_INT_CTRL, 0xE000ED04
|
||||
.equ OS_NVIC_SYSPRI3, 0xE000ED20
|
||||
.equ OS_NVIC_PENDSV_PRI, 0xF0F00000
|
||||
.equ OS_NVIC_PENDSVSET, 0x10000000
|
||||
.equ OS_TASK_STATUS_RUNNING, 0x0010
|
||||
|
||||
.section .text
|
||||
.thumb
|
||||
@@ -70,13 +67,12 @@ HalStartToRun:
|
||||
ldr r0, [r1, #4]
|
||||
ldr r12, [r0]
|
||||
|
||||
ldr.w r1, =OS_FPU_CPACR
|
||||
ldr r1, [r1]
|
||||
and r1, r1, #OS_FPU_CPACR_ENABLE
|
||||
cmp r1, #OS_FPU_CPACR_ENABLE
|
||||
ldr r2, [r12, #4]
|
||||
tst r2, #0x10
|
||||
it ne
|
||||
bne __DisabledFPU
|
||||
|
||||
add r12, r12, #100
|
||||
add r12, r12, #108
|
||||
ldmfd r12!, {r0-r7}
|
||||
add r12, r12, #72
|
||||
msr psp, r12
|
||||
@@ -88,7 +84,7 @@ HalStartToRun:
|
||||
bx r6
|
||||
|
||||
__DisabledFPU:
|
||||
add r12, r12, #36
|
||||
add r12, r12, #44
|
||||
|
||||
ldmfd r12!, {r0-r7}
|
||||
msr psp, r12
|
||||
@@ -165,38 +161,31 @@ HalTaskSwitch:
|
||||
bx lr
|
||||
|
||||
TaskContextSwitch:
|
||||
mov lr, r0
|
||||
mrs r0, psp
|
||||
stmfd r0!, {r4-r12}
|
||||
mov lr, r0
|
||||
mrs r0, psp
|
||||
tst lr, #0x10
|
||||
it eq
|
||||
vstmdbeq r0!, {d8-d15}
|
||||
mrs r2, psplim
|
||||
mov r3, lr
|
||||
stmfd r0!, {r2-r12}
|
||||
|
||||
ldr.w r3, =OS_FPU_CPACR
|
||||
ldr r3, [r3]
|
||||
and r3, r3, #OS_FPU_CPACR_ENABLE
|
||||
cmp r3, #OS_FPU_CPACR_ENABLE
|
||||
bne __DisabledFPU1
|
||||
vstmdb r0!, {d8-d15}
|
||||
ldr r5, =g_losTask
|
||||
ldr r6, [r5]
|
||||
str r0, [r6]
|
||||
|
||||
__DisabledFPU1:
|
||||
ldr r5, =g_losTask
|
||||
ldr r6, [r5]
|
||||
str r0, [r6]
|
||||
|
||||
ldr r0, [r5, #4]
|
||||
str r0, [r5]
|
||||
ldr r1, [r0]
|
||||
ldr r0, [r5, #4]
|
||||
str r0, [r5]
|
||||
ldr r1, [r0]
|
||||
|
||||
SignalContextRestore:
|
||||
ldr.w r3, =OS_FPU_CPACR
|
||||
ldr r3, [r3]
|
||||
and r3, r3, #OS_FPU_CPACR_ENABLE
|
||||
cmp r3, #OS_FPU_CPACR_ENABLE
|
||||
bne __DisabledFPU2
|
||||
VLDMIA r1!, {d8-d15}
|
||||
ldmfd r1!, {r2-r12}
|
||||
msr psplim, r2
|
||||
tst r3, #0x10
|
||||
it eq
|
||||
vldmiaeq r1!, {d8-d15}
|
||||
msr psp, r1
|
||||
msr PRIMASK, r12
|
||||
|
||||
__DisabledFPU2:
|
||||
ldmfd r1!, {r4-r12}
|
||||
msr psp, r1
|
||||
msr PRIMASK, r12
|
||||
|
||||
bx lr
|
||||
bx lr
|
||||
.fnend
|
||||
|
||||
@@ -46,23 +46,23 @@
|
||||
.extern g_taskScheduled
|
||||
|
||||
.equ OS_FLG_BGD_ACTIVE, 0x0002
|
||||
.equ OS_EXC_CAUSE_NMI, 16
|
||||
.equ OS_EXC_CAUSE_HARDFAULT, 17
|
||||
.equ OS_EXC_CAUSE_NMI, 19
|
||||
.equ OS_EXC_CAUSE_HARDFAULT, 20
|
||||
|
||||
.equ HF_DEBUGEVT, 20
|
||||
.equ HF_VECTBL, 21
|
||||
.equ HF_DEBUGEVT, 23
|
||||
.equ HF_VECTBL, 24
|
||||
|
||||
.equ FLAG_ADDR_VALID, 0x10000
|
||||
.equ FLAG_HWI_ACTIVE, 0x20000
|
||||
.equ FLAG_NO_FLOAT, 0x10000000
|
||||
|
||||
.equ OS_NVIC_FSR , 0xE000ED28 //include BusFault/MemFault/UsageFault State Register
|
||||
.equ OS_NVIC_HFSR , 0xE000ED2C //HardFault State Register
|
||||
.equ OS_NVIC_BFAR , 0xE000ED38
|
||||
.equ OS_NVIC_MMAR , 0xE000ED34
|
||||
.equ OS_NVIC_ACT_BASE , 0xE000E300
|
||||
.equ OS_NVIC_SHCSRS , 0xE000ED24
|
||||
.equ OS_NVIC_SHCSR_MASK , 0xC00
|
||||
.equ OS_NVIC_FSR, 0xE000ED28 //include BusFault/MemFault/UsageFault State Register
|
||||
.equ OS_NVIC_HFSR, 0xE000ED2C //HardFault State Register
|
||||
.equ OS_NVIC_BFAR, 0xE000ED38
|
||||
.equ OS_NVIC_MMAR, 0xE000ED34
|
||||
.equ OS_NVIC_ACT_BASE, 0xE000E300
|
||||
.equ OS_NVIC_SHCSRS, 0xE000ED24
|
||||
.equ OS_NVIC_SHCSR_MASK, 0xC00
|
||||
|
||||
.type HalExcNMI, %function
|
||||
.global HalExcNMI
|
||||
@@ -71,7 +71,7 @@ HalExcNMI:
|
||||
.cantunwind
|
||||
MOV R0, #OS_EXC_CAUSE_NMI
|
||||
MOV R1, #0
|
||||
B osExcDispatch
|
||||
B osExcDispatch
|
||||
.fnend
|
||||
|
||||
.type HalExcHardFault, %function
|
||||
@@ -88,7 +88,7 @@ HalExcHardFault:
|
||||
TST R2, #0x80000000
|
||||
BNE osExcDispatch // DEBUGEVT
|
||||
|
||||
AND R0, R0 , #0x000000FF
|
||||
AND R0, R0, #0x000000FF
|
||||
MOV R1, #HF_VECTBL
|
||||
ORR R0, R0, R1, LSL #0x8
|
||||
TST R2, #0x00000002
|
||||
@@ -106,7 +106,7 @@ HalExcHardFault:
|
||||
TST R2, #0x80 // MMARVALID
|
||||
BNE _HFMemFault // MemFault
|
||||
|
||||
MOV R12,#0
|
||||
MOV R12, #0
|
||||
B osHFExcCommonBMU
|
||||
.fnend
|
||||
|
||||
@@ -141,7 +141,7 @@ osHFExcCommonBMU:
|
||||
ADD R3, R3, R2
|
||||
LDRB R2, [R3]
|
||||
ORR R0, R0, R2, LSL #0x8
|
||||
ORR R0, R0 ,R12
|
||||
ORR R0, R0, R12
|
||||
B osExcDispatch
|
||||
.fnend
|
||||
|
||||
@@ -183,7 +183,7 @@ HalExcBusFault:
|
||||
_ExcBusNoADDR:
|
||||
.fnstart
|
||||
.cantunwind
|
||||
MOV R12,#0
|
||||
MOV R12, #0
|
||||
B osExcCommonBMU
|
||||
.fnend
|
||||
|
||||
@@ -210,7 +210,7 @@ HalExcMemFault:
|
||||
_ExcMemNoADDR:
|
||||
.fnstart
|
||||
.cantunwind
|
||||
MOV R12,#0
|
||||
MOV R12, #0
|
||||
B osExcCommonBMU
|
||||
.fnend
|
||||
|
||||
@@ -222,7 +222,7 @@ HalExcUsageFault:
|
||||
LDR R0, =OS_NVIC_FSR
|
||||
LDR R0, [R0]
|
||||
|
||||
MOVW R1, #0x030F
|
||||
MOVW R1, #0x031F
|
||||
LSL R1, R1, #16
|
||||
AND R0, R0, R1
|
||||
MOV R12, #0
|
||||
@@ -248,7 +248,7 @@ osExcDispatch:
|
||||
.fnstart
|
||||
.cantunwind
|
||||
LDR R2, =OS_NVIC_ACT_BASE
|
||||
MOV R12, #8 // R12 is hwi check loop counter
|
||||
MOV R12, #16 // R12 is hwi check loop counter
|
||||
.fnend
|
||||
|
||||
.type _hwiActiveCheck, %function
|
||||
@@ -277,8 +277,8 @@ _ExcInMSP:
|
||||
BNE _NoFloatInMsp
|
||||
ADD R3, R13, #104
|
||||
PUSH {R3}
|
||||
MRS R12, PRIMASK // store message-->exc: disable int?
|
||||
PUSH {R4-R12} // store message-->exc: {R4-R12}
|
||||
MRS R12, PRIMASK // store message-->exc: disable int?
|
||||
PUSH {R4-R12} // store message-->exc: {R4-R12}
|
||||
VPUSH {D8-D15}
|
||||
B _handleEntry
|
||||
.fnend
|
||||
@@ -291,8 +291,8 @@ _NoFloatInMsp:
|
||||
ADD R3, R13, #32
|
||||
PUSH {R3} // save IRQ SP // store message-->exc: MSP(R13)
|
||||
|
||||
MRS R12, PRIMASK // store message-->exc: disable int?
|
||||
PUSH {R4-R12} // store message-->exc: {R4-R12}
|
||||
MRS R12, PRIMASK // store message-->exc: disable int?
|
||||
PUSH {R4-R12} // store message-->exc: {R4-R12}
|
||||
ORR R0, R0, #FLAG_NO_FLOAT
|
||||
B _handleEntry
|
||||
.fnend
|
||||
@@ -308,42 +308,42 @@ _hwiActiveCheckNext:
|
||||
|
||||
/*NMI interrupt excption*/
|
||||
LDR R2, =OS_NVIC_SHCSRS
|
||||
LDRH R2,[R2]
|
||||
LDR R3,=OS_NVIC_SHCSR_MASK
|
||||
AND R2, R2,R3
|
||||
CMP R2,#0
|
||||
LDRH R2, [R2]
|
||||
LDR R3, =OS_NVIC_SHCSR_MASK
|
||||
AND R2, R2, R3
|
||||
CMP R2, #0
|
||||
BNE _ExcInMSP
|
||||
// exc occured in Task or Init or exc
|
||||
// reserved for register info from task stack
|
||||
|
||||
LDR R2, =g_taskScheduled
|
||||
LDR R2, [R2]
|
||||
TST R2, #1 // OS_FLG_BGD_ACTIVE
|
||||
BEQ _ExcInMSP // if exc occured in Init then branch
|
||||
LDR R2, =g_taskScheduled
|
||||
LDR R2, [R2]
|
||||
TST R2, #1 // OS_FLG_BGD_ACTIVE
|
||||
BEQ _ExcInMSP // if exc occured in Init then branch
|
||||
|
||||
|
||||
CMP LR, #0xFFFFFFED //auto push floating registers
|
||||
CMP LR, #0xFFFFFFED //auto push floating registers
|
||||
BNE _NoFloatInPsp
|
||||
|
||||
// exc occured in Task
|
||||
MOV R2, R13
|
||||
SUB R13, #96 // add 8 Bytes reg(for STMFD)
|
||||
MOV R2, R13
|
||||
SUB R13, #96 // add 8 Bytes reg(for STMFD)
|
||||
|
||||
MRS R3, PSP
|
||||
MRS R3, PSP
|
||||
ADD R12, R3, #104
|
||||
PUSH {R12} // save task SP
|
||||
PUSH {R12} // save task SP
|
||||
|
||||
MRS R12, PRIMASK
|
||||
PUSH {R4-R12}
|
||||
PUSH {R4-R12}
|
||||
VPUSH {D8-D15}
|
||||
|
||||
// copy auto saved task register
|
||||
|
||||
LDMFD R3!, {R4-R11} // R4-R11 store PSP reg(auto push when exc in task)
|
||||
LDMFD R3!, {R4-R11} // R4-R11 store PSP reg(auto push when exc in task)
|
||||
VLDMIA R3!, {D8-D15}
|
||||
VSTMDB R2!, {D8-D15}
|
||||
STMFD R2!, {R4-R11}
|
||||
B _handleEntry
|
||||
STMFD R2!, {R4-R11}
|
||||
B _handleEntry
|
||||
.fnend
|
||||
|
||||
.type _NoFloatInPsp, %function
|
||||
@@ -351,15 +351,15 @@ _hwiActiveCheckNext:
|
||||
_NoFloatInPsp:
|
||||
.fnstart
|
||||
.cantunwind
|
||||
MOV R2, R13 // no auto push floating registers
|
||||
MOV R2, R13 // no auto push floating registers
|
||||
SUB R13, #32 // add 8 Bytes reg(for STMFD)
|
||||
|
||||
MRS R3, PSP
|
||||
MRS R3, PSP
|
||||
ADD R12, R3, #32
|
||||
PUSH {R12} // save task SP
|
||||
|
||||
MRS R12, PRIMASK
|
||||
PUSH {R4-R12}
|
||||
PUSH {R4-R12}
|
||||
|
||||
LDMFD R3, {R4-R11} // R4-R11 store PSP reg(auto push when exc in task)
|
||||
STMFD R2!, {R4-R11}
|
||||
@@ -371,10 +371,10 @@ _NoFloatInPsp:
|
||||
_handleEntry:
|
||||
.fnstart
|
||||
.cantunwind
|
||||
MOV R3, R13 // R13:the 4th param
|
||||
MOV R3, R13 // R13:the 4th param
|
||||
CPSID I
|
||||
CPSID F
|
||||
B HalExcHandleEntry
|
||||
B HalExcHandleEntry
|
||||
|
||||
NOP
|
||||
.fnend
|
||||
|
||||
@@ -203,11 +203,13 @@ LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||
|
||||
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
||||
{
|
||||
(VOID)arg;
|
||||
return;
|
||||
}
|
||||
|
||||
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
||||
{
|
||||
(VOID)arg;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -273,6 +275,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
HWI_PROC_FUNC handler,
|
||||
HWI_ARG_T arg)
|
||||
{
|
||||
(VOID)mode;
|
||||
UINT32 intSave;
|
||||
|
||||
if (handler == NULL) {
|
||||
@@ -295,6 +298,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||
OsSetVector(hwiNum, handler, arg);
|
||||
#else
|
||||
(VOID)arg;
|
||||
OsSetVector(hwiNum, handler);
|
||||
#endif
|
||||
HwiUnmask((IRQn_Type)hwiNum);
|
||||
@@ -342,10 +346,14 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum)
|
||||
ExcInfo g_excInfo = {0};
|
||||
|
||||
UINT8 g_uwExcTbl[FAULT_STATUS_REG_BIT] = {
|
||||
0, 0, 0, 0, 0, 0, OS_EXC_UF_DIVBYZERO, OS_EXC_UF_UNALIGNED,
|
||||
0, 0, 0, 0, OS_EXC_UF_NOCP, OS_EXC_UF_INVPC, OS_EXC_UF_INVSTATE, OS_EXC_UF_UNDEFINSTR,
|
||||
0, 0, 0, OS_EXC_BF_STKERR, OS_EXC_BF_UNSTKERR, OS_EXC_BF_IMPRECISERR, OS_EXC_BF_PRECISERR, OS_EXC_BF_IBUSERR,
|
||||
0, 0, 0, OS_EXC_MF_MSTKERR, OS_EXC_MF_MUNSTKERR, 0, OS_EXC_MF_DACCVIOL, OS_EXC_MF_IACCVIOL
|
||||
0, 0, 0, 0,
|
||||
0, 0, OS_EXC_UF_DIVBYZERO, OS_EXC_UF_UNALIGNED,
|
||||
0, 0, 0, OS_EXC_UF_STKOF,
|
||||
OS_EXC_UF_NOCP, OS_EXC_UF_INVPC, OS_EXC_UF_INVSTATE, OS_EXC_UF_UNDEFINSTR,
|
||||
0, 0, OS_EXC_BF_LSPERR, OS_EXC_BF_STKERR,
|
||||
OS_EXC_BF_UNSTKERR, OS_EXC_BF_IMPRECISERR, OS_EXC_BF_PRECISERR, OS_EXC_BF_IBUSERR,
|
||||
0, 0, OS_EXC_MF_MLSPERR, OS_EXC_MF_MSTKERR,
|
||||
OS_EXC_MF_MUNSTKERR, 0, OS_EXC_MF_DACCVIOL, OS_EXC_MF_IACCVIOL
|
||||
};
|
||||
|
||||
#if (LOSCFG_KERNEL_PRINTF != 0)
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "los_debug.h"
|
||||
|
||||
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
|
||||
STATIC VOID SysTickReload(UINT64 nextResponseTime);
|
||||
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period);
|
||||
STATIC VOID SysTickLock(VOID);
|
||||
STATIC VOID SysTickUnlock(VOID);
|
||||
@@ -43,6 +43,7 @@ STATIC VOID SysTickUnlock(VOID);
|
||||
STATIC ArchTickTimer g_archTickTimer = {
|
||||
.freq = 0,
|
||||
.irqNum = SysTick_IRQn,
|
||||
.periodMax = LOSCFG_BASE_CORE_TICK_RESPONSE_MAX,
|
||||
.init = SysTickStart,
|
||||
.getCycle = SysTickCycleGet,
|
||||
.reload = SysTickReload,
|
||||
@@ -74,13 +75,18 @@ STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC VOID SysTickReload(UINT64 nextResponseTime)
|
||||
STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
||||
{
|
||||
if (nextResponseTime > g_archTickTimer.periodMax) {
|
||||
nextResponseTime = g_archTickTimer.periodMax;
|
||||
}
|
||||
|
||||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||
return nextResponseTime;
|
||||
}
|
||||
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
||||
|
||||
@@ -198,11 +198,13 @@ LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||
|
||||
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
||||
{
|
||||
(VOID)arg;
|
||||
return;
|
||||
}
|
||||
|
||||
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
||||
{
|
||||
(VOID)arg;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -268,6 +270,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
HWI_PROC_FUNC handler,
|
||||
HWI_ARG_T arg)
|
||||
{
|
||||
(VOID)mode;
|
||||
UINT32 intSave;
|
||||
|
||||
if (handler == NULL) {
|
||||
@@ -290,6 +293,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||
OsSetVector(hwiNum, handler, arg);
|
||||
#else
|
||||
(VOID)arg;
|
||||
OsSetVector(hwiNum, handler);
|
||||
#endif
|
||||
HwiUnmask((IRQn_Type)hwiNum);
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "los_debug.h"
|
||||
|
||||
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
|
||||
STATIC VOID SysTickReload(UINT64 nextResponseTime);
|
||||
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period);
|
||||
STATIC VOID SysTickLock(VOID);
|
||||
STATIC VOID SysTickUnlock(VOID);
|
||||
@@ -44,6 +44,7 @@ STATIC VOID SysTickUnlock(VOID);
|
||||
STATIC ArchTickTimer g_archTickTimer = {
|
||||
.freq = 0,
|
||||
.irqNum = SysTick_IRQn,
|
||||
.periodMax = LOSCFG_BASE_CORE_TICK_RESPONSE_MAX,
|
||||
.init = SysTickStart,
|
||||
.getCycle = SysTickCycleGet,
|
||||
.reload = SysTickReload,
|
||||
@@ -75,13 +76,17 @@ STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC VOID SysTickReload(UINT64 nextResponseTime)
|
||||
STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
||||
{
|
||||
if (nextResponseTime > g_archTickTimer.periodMax) {
|
||||
nextResponseTime = g_archTickTimer.periodMax;
|
||||
}
|
||||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||
return nextResponseTime;
|
||||
}
|
||||
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
||||
|
||||
@@ -205,11 +205,13 @@ LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||
|
||||
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
||||
{
|
||||
(VOID)arg;
|
||||
return;
|
||||
}
|
||||
|
||||
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
||||
{
|
||||
(VOID)arg;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -275,6 +277,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
HWI_PROC_FUNC handler,
|
||||
HWI_ARG_T arg)
|
||||
{
|
||||
(VOID)mode;
|
||||
UINT32 intSave;
|
||||
|
||||
if (handler == NULL) {
|
||||
@@ -297,6 +300,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||
OsSetVector(hwiNum, handler, arg);
|
||||
#else
|
||||
(VOID)arg;
|
||||
OsSetVector(hwiNum, handler);
|
||||
#endif
|
||||
HwiUnmask((IRQn_Type)hwiNum);
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "los_debug.h"
|
||||
|
||||
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
|
||||
STATIC VOID SysTickReload(UINT64 nextResponseTime);
|
||||
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period);
|
||||
STATIC VOID SysTickLock(VOID);
|
||||
STATIC VOID SysTickUnlock(VOID);
|
||||
@@ -44,6 +44,7 @@ STATIC VOID SysTickUnlock(VOID);
|
||||
STATIC ArchTickTimer g_archTickTimer = {
|
||||
.freq = 0,
|
||||
.irqNum = SysTick_IRQn,
|
||||
.periodMax = LOSCFG_BASE_CORE_TICK_RESPONSE_MAX,
|
||||
.init = SysTickStart,
|
||||
.getCycle = SysTickCycleGet,
|
||||
.reload = SysTickReload,
|
||||
@@ -75,13 +76,17 @@ STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC VOID SysTickReload(UINT64 nextResponseTime)
|
||||
STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
||||
{
|
||||
if (nextResponseTime > g_archTickTimer.periodMax) {
|
||||
nextResponseTime = g_archTickTimer.periodMax;
|
||||
}
|
||||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||
return nextResponseTime;
|
||||
}
|
||||
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
||||
|
||||
@@ -256,7 +256,7 @@ VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
|
||||
**************************************************************************** */
|
||||
STATIC UINT32 HwiNumGet(VOID)
|
||||
{
|
||||
return HalGetPsr();
|
||||
return (HalGetPsr() >> PSR_VEC_OFFSET) & MASK_8_BITS;
|
||||
}
|
||||
|
||||
HwiControllerOps g_archHwiOps = {
|
||||
@@ -283,18 +283,19 @@ inline UINT32 ArchIsIntActive(VOID)
|
||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||
{
|
||||
UINT32 irqNum = HwiNumGet();
|
||||
irqNum = (irqNum >> PSR_VEC_OFFSET) & MASK_8_BITS;
|
||||
PRINT_ERR("%s irqnum:%x\n", __FUNCTION__, irqNum);
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
||||
{
|
||||
(VOID)arg;
|
||||
return;
|
||||
}
|
||||
|
||||
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
||||
{
|
||||
(VOID)arg;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -315,7 +316,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
hwiIndex = HwiNumGet();
|
||||
hwiIndex = (hwiIndex >> PSR_VEC_OFFSET) & MASK_8_BITS;
|
||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||
|
||||
HalPreInterruptHandler(hwiIndex);
|
||||
@@ -356,6 +356,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
HWI_PROC_FUNC handler,
|
||||
HWI_ARG_T arg)
|
||||
{
|
||||
(VOID)mode;
|
||||
UINT32 intSave;
|
||||
|
||||
if (handler == NULL) {
|
||||
@@ -377,6 +378,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||
OsSetVector(hwiNum, handler, arg);
|
||||
#else
|
||||
(VOID)arg;
|
||||
OsSetVector(hwiNum, handler);
|
||||
#endif
|
||||
HwiUnmask(hwiNum);
|
||||
|
||||
@@ -53,7 +53,7 @@ typedef struct {
|
||||
#define TIM_INT_NUM 1
|
||||
|
||||
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
|
||||
STATIC VOID SysTickReload(UINT64 nextResponseTime);
|
||||
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period);
|
||||
STATIC VOID SysTickLock(VOID);
|
||||
STATIC VOID SysTickUnlock(VOID);
|
||||
@@ -61,6 +61,7 @@ STATIC VOID SysTickUnlock(VOID);
|
||||
STATIC ArchTickTimer g_archTickTimer = {
|
||||
.freq = 0,
|
||||
.irqNum = TIM_INT_NUM,
|
||||
.periodMax = LOSCFG_BASE_CORE_TICK_RESPONSE_MAX,
|
||||
.init = SysTickStart,
|
||||
.getCycle = SysTickCycleGet,
|
||||
.reload = SysTickReload,
|
||||
@@ -98,12 +99,16 @@ STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC VOID SysTickReload(UINT64 nextResponseTime)
|
||||
STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
||||
{
|
||||
if (nextResponseTime > g_archTickTimer.periodMax) {
|
||||
nextResponseTime = g_archTickTimer.periodMax;
|
||||
}
|
||||
SysTick->CTRL &= ~CORETIM_ENABLE;
|
||||
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||
SysTick->CTRL |= CORETIM_ENABLE;
|
||||
return nextResponseTime;
|
||||
}
|
||||
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
||||
|
||||
@@ -80,6 +80,7 @@ UINT32 ArchIsIntActive(VOID);
|
||||
#define LOS_HwiDisable ArchIntDisable
|
||||
#define LOS_HwiClear ArchIntClear
|
||||
#define LOS_HwiSetPriority ArchIntSetPriority
|
||||
#define LOS_HwiCurIrqNum ArchIntCurIrqNum
|
||||
|
||||
UINT32 ArchIntLock(VOID);
|
||||
#define LOS_IntLock ArchIntLock
|
||||
@@ -193,6 +194,14 @@ STATIC INLINE UINT32 ArchIntSetPriority(HWI_HANDLE_T hwiNum, HWI_PRIOR_T priorit
|
||||
return g_archHwiOps.setIrqPriority(hwiNum, priority);
|
||||
}
|
||||
|
||||
STATIC INLINE UINT32 ArchIntCurIrqNum(VOID)
|
||||
{
|
||||
if (g_archHwiOps.getCurIrqNum == NULL) {
|
||||
return LOS_NOK;
|
||||
}
|
||||
return g_archHwiOps.getCurIrqNum();
|
||||
}
|
||||
|
||||
STATIC INLINE HwiControllerOps *ArchIntOpsGet(VOID)
|
||||
{
|
||||
return &g_archHwiOps;
|
||||
|
||||
@@ -56,9 +56,10 @@ extern "C" {
|
||||
typedef struct {
|
||||
UINT32 freq;
|
||||
INT32 irqNum;
|
||||
UINT64 periodMax;
|
||||
UINT32 (*init)(HWI_PROC_FUNC tickHandler);
|
||||
UINT64 (*getCycle)(UINT32 *period);
|
||||
VOID (*reload)(UINT64 time);
|
||||
UINT64 (*reload)(UINT64 time);
|
||||
VOID (*lock)(VOID);
|
||||
VOID (*unlock)(VOID);
|
||||
HWI_PROC_FUNC tickHandler;
|
||||
|
||||
@@ -47,7 +47,7 @@ STATIC HWI_PROC_FUNC g_sysTickHandler = (HWI_PROC_FUNC)NULL;
|
||||
extern UINT32 g_intCount;
|
||||
|
||||
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
|
||||
STATIC VOID SysTickReload(UINT64 nextResponseTime);
|
||||
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period);
|
||||
STATIC VOID SysTickLock(VOID);
|
||||
STATIC VOID SysTickUnlock(VOID);
|
||||
@@ -55,6 +55,7 @@ STATIC VOID SysTickUnlock(VOID);
|
||||
STATIC ArchTickTimer g_archTickTimer = {
|
||||
.freq = 0,
|
||||
.irqNum = SysTimer_IRQn,
|
||||
.periodMax = LOSCFG_BASE_CORE_TICK_RESPONSE_MAX,
|
||||
.init = SysTickStart,
|
||||
.getCycle = SysTickCycleGet,
|
||||
.reload = SysTickReload,
|
||||
@@ -95,9 +96,10 @@ void ArchTickSysTickHandler(void)
|
||||
}
|
||||
}
|
||||
|
||||
STATIC VOID SysTickReload(UINT64 nextResponseTime)
|
||||
STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
||||
{
|
||||
SysTick_Reload(nextResponseTime);
|
||||
return nextResponseTime;
|
||||
}
|
||||
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include "los_debug.h"
|
||||
|
||||
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
|
||||
STATIC VOID SysTickReload(UINT64 nextResponseTime);
|
||||
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period);
|
||||
STATIC VOID SysTickLock(VOID);
|
||||
STATIC VOID SysTickUnlock(VOID);
|
||||
@@ -47,6 +47,7 @@ STATIC VOID SysTickUnlock(VOID);
|
||||
STATIC ArchTickTimer g_archTickTimer = {
|
||||
.freq = 0,
|
||||
.irqNum = RISCV_MACH_TIMER_IRQ,
|
||||
.periodMax = LOSCFG_BASE_CORE_TICK_RESPONSE_MAX,
|
||||
.init = SysTickStart,
|
||||
.getCycle = SysTickCycleGet,
|
||||
.reload = SysTickReload,
|
||||
@@ -75,7 +76,7 @@ STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC VOID SysTickReload(UINT64 nextResponseTime)
|
||||
STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
||||
{
|
||||
UINT64 timeMax = (UINT64)LOSCFG_BASE_CORE_TICK_RESPONSE_MAX - 1;
|
||||
UINT64 timer;
|
||||
@@ -94,6 +95,7 @@ STATIC VOID SysTickReload(UINT64 nextResponseTime)
|
||||
WRITE_UINT32((UINT32)timer, MTIMERCMP);
|
||||
WRITE_UINT32((UINT32)(timer >> SHIFT_32_BIT), MTIMERCMP + MTIMER_HI_OFFSET);
|
||||
HalIrqEnable(RISCV_MACH_TIMER_IRQ);
|
||||
return nextResponseTime;
|
||||
}
|
||||
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
||||
|
||||
@@ -256,11 +256,13 @@ VOID HalHwiDefaultHandler(VOID)
|
||||
|
||||
WEAK VOID HalPreInterruptHandler(UINT32 arg)
|
||||
{
|
||||
(VOID)arg;
|
||||
return;
|
||||
}
|
||||
|
||||
WEAK VOID HalAftInterruptHandler(UINT32 arg)
|
||||
{
|
||||
(VOID)arg;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -324,6 +326,7 @@ UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
HWI_PROC_FUNC handler,
|
||||
HWI_ARG_T arg)
|
||||
{
|
||||
(VOID)mode;
|
||||
UINT32 intSave;
|
||||
|
||||
if (handler == NULL) {
|
||||
@@ -346,6 +349,7 @@ UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||
OsSetVector(hwiNum, handler, arg);
|
||||
#else
|
||||
(VOID)arg;
|
||||
OsSetVector(hwiNum, handler);
|
||||
#endif
|
||||
HwiUnmask(hwiNum);
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#include "los_debug.h"
|
||||
|
||||
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
|
||||
STATIC VOID SysTickReload(UINT64 nextResponseTime);
|
||||
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period);
|
||||
STATIC VOID SysTickLock(VOID);
|
||||
STATIC VOID SysTickUnlock(VOID);
|
||||
@@ -45,6 +45,7 @@ STATIC VOID SysTickUnlock(VOID);
|
||||
STATIC ArchTickTimer g_archTickTimer = {
|
||||
.freq = 0,
|
||||
.irqNum = OS_TICK_INT_NUM,
|
||||
.periodMax = LOSCFG_BASE_CORE_TICK_RESPONSE_MAX,
|
||||
.init = SysTickStart,
|
||||
.getCycle = SysTickCycleGet,
|
||||
.reload = SysTickReload,
|
||||
@@ -77,12 +78,17 @@ STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC VOID SysTickReload(UINT64 nextResponseTime)
|
||||
STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
||||
{
|
||||
UINT32 timerL;
|
||||
if (nextResponseTime > g_archTickTimer.periodMax) {
|
||||
nextResponseTime = g_archTickTimer.periodMax;
|
||||
}
|
||||
|
||||
timerL = GetCcount();
|
||||
timerL += nextResponseTime;
|
||||
SetCcompare(timerL);
|
||||
return nextResponseTime;
|
||||
}
|
||||
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
||||
|
||||
@@ -42,4 +42,9 @@ config LFS_MAX_MOUNT_SIZE
|
||||
help
|
||||
This is a global maximum number of mount points.
|
||||
|
||||
config LFS_MAX_OPEN_FILES
|
||||
int "Maximum number of open files"
|
||||
default 100
|
||||
help
|
||||
This is a global maximum number of open files.
|
||||
endif # FS_LITTLEFS
|
||||
|
||||
@@ -38,7 +38,7 @@ lfs_t g_lfs;
|
||||
FileDirInfo g_lfsDir[LFS_MAX_OPEN_DIRS] = {0};
|
||||
|
||||
struct FileOpInfo g_fsOp[LOSCFG_LFS_MAX_MOUNT_SIZE] = {0};
|
||||
static LittleFsHandleStruct g_handle[LITTLE_FS_MAX_OPEN_FILES] = {0};
|
||||
static LittleFsHandleStruct g_handle[LOSCFG_LFS_MAX_OPEN_FILES] = {0};
|
||||
struct dirent g_nameValue;
|
||||
static pthread_mutex_t g_FslocalMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static const char *g_littlefsMntName[LOSCFG_LFS_MAX_MOUNT_SIZE] = {"/a"};
|
||||
@@ -46,7 +46,7 @@ static const char *g_littlefsMntName[LOSCFG_LFS_MAX_MOUNT_SIZE] = {"/a"};
|
||||
LittleFsHandleStruct *LfsAllocFd(const char *fileName, int *fd)
|
||||
{
|
||||
pthread_mutex_lock(&g_FslocalMutex);
|
||||
for (int i = 0; i < LITTLE_FS_MAX_OPEN_FILES; i++) {
|
||||
for (int i = 0; i < LOSCFG_LFS_MAX_OPEN_FILES; i++) {
|
||||
if (g_handle[i].useFlag == 0) {
|
||||
*fd = i;
|
||||
g_handle[i].useFlag = 1;
|
||||
@@ -78,7 +78,7 @@ static void LfsFreeFd(int fd)
|
||||
BOOL CheckFileIsOpen(const char *fileName)
|
||||
{
|
||||
pthread_mutex_lock(&g_FslocalMutex);
|
||||
for (int i = 0; i < LITTLE_FS_MAX_OPEN_FILES; i++) {
|
||||
for (int i = 0; i < LOSCFG_LFS_MAX_OPEN_FILES; i++) {
|
||||
if (g_handle[i].useFlag == 1) {
|
||||
if (strcmp(g_handle[i].pathName, fileName) == 0) {
|
||||
pthread_mutex_unlock(&g_FslocalMutex);
|
||||
@@ -92,7 +92,7 @@ BOOL CheckFileIsOpen(const char *fileName)
|
||||
|
||||
static BOOL LfsFdIsValid(int fd)
|
||||
{
|
||||
if (fd >= LITTLE_FS_MAX_OPEN_FILES || fd < 0) {
|
||||
if (fd >= LOSCFG_LFS_MAX_OPEN_FILES || fd < 0) {
|
||||
return FALSE;
|
||||
}
|
||||
if (g_handle[fd].lfsHandle == NULL) {
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#ifndef _LFS_CONF_H
|
||||
#define _LFS_CONF_H
|
||||
|
||||
#define LITTLE_FS_MAX_OPEN_FILES 100
|
||||
#define LITTLE_FS_STANDARD_NAME_LENGTH 50
|
||||
#define LITTLE_FS_MAX_NAME_LEN 255
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@
|
||||
|
||||
#ifdef LOSCFG_FS_LITTLEFS
|
||||
#include "lfs_conf.h"
|
||||
#define __LFS_NFILE LITTLE_FS_MAX_OPEN_FILES
|
||||
#define __LFS_NFILE LOSCFG_LFS_MAX_OPEN_FILES
|
||||
#else
|
||||
#define __LFS_NFILE 0
|
||||
#endif
|
||||
|
||||
@@ -31,8 +31,11 @@
|
||||
|
||||
#include "los_pm.h"
|
||||
#include "securec.h"
|
||||
#include "los_sched.h"
|
||||
#include "los_timer.h"
|
||||
#include "los_task.h"
|
||||
#include "los_tick.h"
|
||||
#include "los_event.h"
|
||||
#include "los_sched.h"
|
||||
#include "los_memory.h"
|
||||
#include "los_swtmr.h"
|
||||
|
||||
@@ -70,7 +73,6 @@ typedef struct {
|
||||
STATIC EVENT_CB_S g_pmEvent;
|
||||
STATIC LosPmCB g_pmCB;
|
||||
STATIC LosPmSysctrl g_sysctrl;
|
||||
STATIC UINT64 g_pmSleepTime;
|
||||
|
||||
STATIC VOID OsPmSysctrlInit(VOID)
|
||||
{
|
||||
@@ -122,7 +124,7 @@ STATIC BOOL OsPmTickTimerStop(LosPmCB *pm)
|
||||
{
|
||||
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
|
||||
UINT64 sleepCycle;
|
||||
UINT64 realSleepTime = g_pmSleepTime;
|
||||
UINT64 realSleepTime = OsSchedGetNextExpireTime(OsGetCurrSchedTimeCycle());
|
||||
#endif
|
||||
LosPmTickTimer *tickTimer = pm->tickTimer;
|
||||
|
||||
@@ -239,7 +241,6 @@ STATIC UINT32 OsPmSuspendSleep(LosPmCB *pm)
|
||||
LOS_SysSleepEnum mode;
|
||||
UINT32 prepare = 0;
|
||||
BOOL tickTimerStop = FALSE;
|
||||
UINT64 currTime;
|
||||
|
||||
ret = OsPmSuspendCheck(pm, &sysSuspendEarly, &deviceSuspend, &mode);
|
||||
if (ret != LOS_OK) {
|
||||
@@ -261,9 +262,8 @@ STATIC UINT32 OsPmSuspendSleep(LosPmCB *pm)
|
||||
|
||||
tickTimerStop = OsPmTickTimerStop(pm);
|
||||
if (!tickTimerStop) {
|
||||
currTime = OsGetCurrSchedTimeCycle();
|
||||
OsSchedResetSchedResponseTime(0);
|
||||
OsSchedUpdateExpireTime(currTime);
|
||||
OsSchedUpdateExpireTime();
|
||||
}
|
||||
|
||||
OsPmCpuSuspend(pm);
|
||||
@@ -723,11 +723,6 @@ UINT32 LOS_PmSuspend(UINT32 wakeCount)
|
||||
return OsPmSuspendSleep(&g_pmCB);
|
||||
}
|
||||
|
||||
STATIC VOID OsPmSleepTimeSet(UINT64 sleepTime)
|
||||
{
|
||||
g_pmSleepTime = sleepTime;
|
||||
}
|
||||
|
||||
BOOL OsIsPmMode(VOID)
|
||||
{
|
||||
LosPmCB *pm = &g_pmCB;
|
||||
@@ -752,11 +747,6 @@ UINT32 OsPmInit(VOID)
|
||||
LOS_ListInit(&pm->lockList);
|
||||
(VOID)LOS_EventInit(&g_pmEvent);
|
||||
|
||||
ret = OsSchedRealSleepTimeSet(OsPmSleepTimeSet);
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = OsPmEnterHandlerSet(OsPmNormalSleep);
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
|
||||
7
components/shell/src/base/shmsg.c
Executable file → Normal file
7
components/shell/src/base/shmsg.c
Executable file → Normal file
@@ -212,10 +212,15 @@ VOID ShellTaskEntry(VOID)
|
||||
(VOID)LOS_EventRead(&g_shellInputEvent, 0x1, LOS_WAITMODE_AND | LOS_WAITMODE_CLR, LOS_WAIT_FOREVER);
|
||||
while ((*ptr = (UINT8)UartGetc()) != 0 && *ptr != 13) {
|
||||
if (*ptr == '\x03') { /* ctrl + c */
|
||||
PRINTK("^C\n\rOHOS # ", *ptr);
|
||||
PRINTK("^C\n\rOHOS # ");
|
||||
ptr = buf;
|
||||
break;
|
||||
}
|
||||
if (*ptr == '\b' && ptr != buf) { /* support backspace */
|
||||
PRINTK("\b \b");
|
||||
ptr--;
|
||||
break;
|
||||
}
|
||||
if (!VISIABLE_CHAR(*ptr)) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "securec.h"
|
||||
#include "los_config.h"
|
||||
#include "los_memory.h"
|
||||
@@ -39,7 +40,7 @@ void *calloc(size_t nitems, size_t size)
|
||||
size_t real_size;
|
||||
void *ptr = NULL;
|
||||
|
||||
if (nitems == 0 || size == 0) {
|
||||
if ((nitems == 0) || (size == 0) || (nitems > (UINT32_MAX / size))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@ kernel_module(module_name) {
|
||||
"porting/src/network/ntohl.c",
|
||||
"porting/src/network/ntohs.c",
|
||||
"porting/src/other_adapt.c",
|
||||
"porting/src/pthread.c",
|
||||
"porting/src/time.c",
|
||||
]
|
||||
configs += [ "$LITEOSTOPDIR:warn_config" ]
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
#undef _PTHREAD_ONCE_INIT
|
||||
|
||||
#undef PTHREAD_STACK_MIN
|
||||
#undef PTHREAD_MUTEX_DEFAULT
|
||||
|
||||
#include "los_config.h"
|
||||
#define PTHREAD_STACK_MIN LOSCFG_BASE_CORE_TSK_MIN_STACK_SIZE
|
||||
@@ -76,17 +77,18 @@ typedef struct {
|
||||
} pthread_attr_t;
|
||||
|
||||
#include "los_list.h"
|
||||
typedef struct { unsigned int magic; unsigned int handle; } pthread_mutex_t;
|
||||
|
||||
typedef struct { unsigned type; } pthread_mutexattr_t;
|
||||
typedef struct { unsigned int magic; unsigned int handle; pthread_mutexattr_t stAttr;} pthread_mutex_t;
|
||||
|
||||
#define _MUX_MAGIC 0xEBCFDEA0
|
||||
#define _MUX_INVALID_HANDLE 0xEEEEEEEF
|
||||
#define PTHREAD_MUTEX_DEFAULT 0
|
||||
|
||||
#define _PTHREAD_MUTEX_INITIALIZER { _MUX_MAGIC, _MUX_INVALID_HANDLE }
|
||||
#define PTHREAD_MUTEXATTR_INITIALIZER { PTHREAD_MUTEX_RECURSIVE }
|
||||
#define _PTHREAD_MUTEX_INITIALIZER { _MUX_MAGIC, _MUX_INVALID_HANDLE, PTHREAD_MUTEXATTR_INITIALIZER }
|
||||
|
||||
#ifdef _GNU_SOURCE
|
||||
#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP { _MUX_MAGIC, _MUX_INVALID_HANDLE }
|
||||
#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP { _MUX_MAGIC, _MUX_INVALID_HANDLE, PTHREAD_MUTEXATTR_INITIALIZER }
|
||||
#endif
|
||||
|
||||
#include "los_event.h"
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
#define _POSIX_TIMEOUTS
|
||||
#define _POSIX_THREAD_PRIORITY_SCHEDULING
|
||||
#define _UNIX98_THREAD_MUTEX_ATTRIBUTES
|
||||
#define _POSIX_THREAD_PROCESS_SHARED
|
||||
|
||||
#include_next <sys/features.h>
|
||||
|
||||
|
||||
@@ -312,7 +312,7 @@ OUT:
|
||||
|
||||
int mq_close(mqd_t personal)
|
||||
{
|
||||
INT32 ret = 0;
|
||||
INT32 ret = -1;
|
||||
struct mqarray *mqueueCB = NULL;
|
||||
struct mqpersonal *privateMqPersonal = NULL;
|
||||
struct mqpersonal *tmp = NULL;
|
||||
@@ -425,7 +425,7 @@ int OsMqSetAttr(mqd_t personal, const struct mq_attr *mqSetAttr, struct mq_attr
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mq_getsetattr(mqd_t mqd, const struct mq_attr *new, struct mq_attr *old)
|
||||
static int MqGetSetAttr(mqd_t mqd, const struct mq_attr *new, struct mq_attr *old)
|
||||
{
|
||||
if (new == NULL) {
|
||||
return OsMqGetAttr(mqd, old);
|
||||
@@ -439,7 +439,7 @@ int mq_getattr(mqd_t mqd, struct mq_attr *attr)
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
return mq_getsetattr(mqd, 0, attr);
|
||||
return MqGetSetAttr(mqd, NULL, attr);
|
||||
}
|
||||
|
||||
int mq_setattr(mqd_t mqd, const struct mq_attr *new, struct mq_attr *old)
|
||||
@@ -452,7 +452,7 @@ int mq_setattr(mqd_t mqd, const struct mq_attr *new, struct mq_attr *old)
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
return mq_getsetattr(mqd, new, old);
|
||||
return MqGetSetAttr(mqd, new, old);
|
||||
}
|
||||
|
||||
int mq_unlink(const char *mqName)
|
||||
@@ -472,7 +472,9 @@ int mq_unlink(const char *mqName)
|
||||
}
|
||||
|
||||
if (mqueueCB->mq_personal != NULL) {
|
||||
errno = EINTR;
|
||||
mqueueCB->unlinkflag = TRUE;
|
||||
goto ERROUT_UNLOCK;
|
||||
} else {
|
||||
ret = DoMqueueDelete(mqueueCB);
|
||||
}
|
||||
|
||||
@@ -35,14 +35,17 @@
|
||||
#include <unistd.h>
|
||||
#include <securec.h>
|
||||
#include <limits.h>
|
||||
#include <stdbool.h>
|
||||
#include "los_config.h"
|
||||
#include "los_task.h"
|
||||
#include "los_debug.h"
|
||||
|
||||
#define PTHREAD_DEFAULT_NAME "pthread"
|
||||
#define PTHREAD_DEFAULT_NAME_LEN 8
|
||||
#define PTHREAD_NAMELEN 16
|
||||
#define PTHREAD_KEY_UNUSED 0
|
||||
#define PTHREAD_KEY_USED 1
|
||||
#define PTHREAD_TASK_INVAILD 0
|
||||
|
||||
typedef void (*PthreadKeyDtor)(void *);
|
||||
typedef struct {
|
||||
@@ -59,6 +62,9 @@ typedef struct {
|
||||
char name[PTHREAD_NAMELEN];
|
||||
uintptr_t *key;
|
||||
LOS_DL_LIST threadList;
|
||||
unsigned char cancelState;
|
||||
unsigned char cancelType;
|
||||
unsigned char canceled;
|
||||
} PthreadData;
|
||||
|
||||
static void PthreadExitKeyDtor(PthreadData *pthreadData);
|
||||
@@ -69,12 +75,21 @@ static void *PthreadEntry(UINT32 param)
|
||||
void *(*startRoutine)(void *) = pthreadData->startRoutine;
|
||||
void *ret = startRoutine(pthreadData->param);
|
||||
pthread_exit(ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline int IsPthread(pthread_t thread)
|
||||
static inline bool IsPthread(pthread_t thread)
|
||||
{
|
||||
return ((UINT32)thread <= LOSCFG_BASE_CORE_TSK_LIMIT);
|
||||
LosTaskCB *tcb = NULL;
|
||||
if ((UINT32)thread >= LOSCFG_BASE_CORE_TSK_LIMIT) {
|
||||
return false;
|
||||
}
|
||||
tcb = OS_TCB_FROM_TID((UINT32)thread);
|
||||
if ((UINTPTR)tcb->taskEntry != (UINTPTR)PthreadEntry) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static int PthreadCreateAttrInit(const pthread_attr_t *attr, void *(*startRoutine)(void *), void *arg,
|
||||
@@ -121,6 +136,9 @@ static int PthreadCreateAttrInit(const pthread_attr_t *attr, void *(*startRoutin
|
||||
return error;
|
||||
}
|
||||
|
||||
pthreadData->cancelState = PTHREAD_CANCEL_ENABLE;
|
||||
pthreadData->cancelType = PTHREAD_CANCEL_DEFERRED;
|
||||
pthreadData->canceled = 0;
|
||||
pthreadData->startRoutine = startRoutine;
|
||||
pthreadData->param = arg;
|
||||
pthreadData->key = NULL;
|
||||
@@ -130,6 +148,29 @@ static int PthreadCreateAttrInit(const pthread_attr_t *attr, void *(*startRoutin
|
||||
if (threadAttr->detachstate != PTHREAD_CREATE_DETACHED) {
|
||||
taskInitParam->uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int CheckForCancel(void)
|
||||
{
|
||||
UINT32 intSave;
|
||||
LosTaskCB *tcb = NULL;
|
||||
|
||||
pthread_t thread = pthread_self();
|
||||
if (!IsPthread(thread)) {
|
||||
PRINT_ERR("[%s:%d] This task %d is not a posix thread!!!\n", __FUNCTION__, __LINE__, thread);
|
||||
return 0;
|
||||
}
|
||||
|
||||
tcb = OS_TCB_FROM_TID((UINT32)thread);
|
||||
intSave = LOS_IntLock();
|
||||
PthreadData *pthreadData = (PthreadData *)(UINTPTR)tcb->arg;
|
||||
if ((pthreadData->canceled) && (pthreadData->cancelState == PTHREAD_CANCEL_ENABLE)) {
|
||||
LOS_IntRestore(intSave);
|
||||
return 1;
|
||||
}
|
||||
LOS_IntRestore(intSave);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -167,13 +208,19 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
|
||||
(void)LOS_TaskResume(taskID);
|
||||
|
||||
*thread = (pthread_t)taskID;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param *param)
|
||||
{
|
||||
if (!IsPthread(thread)) {
|
||||
PRINT_ERR("[%s:%d] This task %d is not a posix thread!!!\n", __FUNCTION__, __LINE__, thread);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if ((param == NULL) || (param->sched_priority < OS_TASK_PRIORITY_HIGHEST) ||
|
||||
(param->sched_priority >= OS_TASK_PRIORITY_LOWEST) || !IsPthread(thread)) {
|
||||
(param->sched_priority >= OS_TASK_PRIORITY_LOWEST)) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
@@ -189,11 +236,127 @@ int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_setschedprio(pthread_t thread, int prio)
|
||||
{
|
||||
if (!IsPthread(thread)) {
|
||||
PRINT_ERR("[%s:%d] This task %d is not a posix thread!!!\n", __FUNCTION__, __LINE__, thread);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if (LOS_TaskPriSet((UINT32)thread, (UINT16)prio) != LOS_OK) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_once(pthread_once_t *onceControl, void (*initRoutine)(void))
|
||||
{
|
||||
UINT32 intSave;
|
||||
pthread_once_t old;
|
||||
|
||||
pthread_t thread = pthread_self();
|
||||
if (!IsPthread(thread)) {
|
||||
PRINT_ERR("[%s:%d] This task %d is not a posix thread!!!\n", __FUNCTION__, __LINE__, thread);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if ((onceControl == NULL) || (initRoutine == NULL)) {
|
||||
return EINVAL;
|
||||
}
|
||||
intSave = LOS_IntLock();
|
||||
old = *onceControl;
|
||||
*onceControl = 1;
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
if (!old) {
|
||||
initRoutine();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_equal(pthread_t thread1, pthread_t thread2)
|
||||
{
|
||||
return (int)(thread1 == thread2);
|
||||
}
|
||||
|
||||
int pthread_setcancelstate(int state, int *oldState)
|
||||
{
|
||||
UINT32 intSave;
|
||||
LosTaskCB *tcb = NULL;
|
||||
PthreadData *pthreadData = NULL;
|
||||
pthread_t thread = pthread_self();
|
||||
if (!IsPthread(thread)) {
|
||||
PRINT_ERR("[%s:%d] This task %d is not a posix thread!!!\n", __FUNCTION__, __LINE__, thread);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if ((state != PTHREAD_CANCEL_ENABLE) && (state != PTHREAD_CANCEL_DISABLE)) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
tcb = OS_TCB_FROM_TID((UINT32)thread);
|
||||
intSave = LOS_IntLock();
|
||||
pthreadData = (PthreadData *)(UINTPTR)tcb->arg;
|
||||
if (pthreadData == NULL) {
|
||||
LOS_IntRestore(intSave);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if (oldState != NULL) {
|
||||
*oldState = pthreadData->cancelState;
|
||||
}
|
||||
pthreadData->cancelState = (UINT8)state;
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_setcanceltype(int type, int *oldType)
|
||||
{
|
||||
UINT32 intSave;
|
||||
LosTaskCB *tcb = NULL;
|
||||
PthreadData *pthreadData = NULL;
|
||||
|
||||
pthread_t thread = pthread_self();
|
||||
if (!IsPthread(thread)) {
|
||||
PRINT_ERR("[%s:%d] This task %d is not a posix thread!!!\n", __FUNCTION__, __LINE__, thread);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if ((type != PTHREAD_CANCEL_ASYNCHRONOUS) && (type != PTHREAD_CANCEL_DEFERRED)) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
tcb = OS_TCB_FROM_TID((UINT32)thread);
|
||||
intSave = LOS_IntLock();
|
||||
pthreadData = (PthreadData *)(UINTPTR)tcb->arg;
|
||||
if (pthreadData == NULL) {
|
||||
LOS_IntRestore(intSave);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if (oldType != NULL) {
|
||||
*oldType = pthreadData->cancelType;
|
||||
}
|
||||
|
||||
pthreadData->cancelType = (UINT8)type;
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_getschedparam(pthread_t thread, int *policy, struct sched_param *param)
|
||||
{
|
||||
UINT32 prio;
|
||||
|
||||
if ((policy == NULL) || (param == NULL) || !IsPthread(thread)) {
|
||||
if (!IsPthread(thread)) {
|
||||
PRINT_ERR("[%s:%d] This task %d is not a posix thread!!!\n", __FUNCTION__, __LINE__, thread);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if ((policy == NULL) || (param == NULL)) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
@@ -204,6 +367,7 @@ int pthread_getschedparam(pthread_t thread, int *policy, struct sched_param *par
|
||||
|
||||
*policy = SCHED_RR;
|
||||
param->sched_priority = prio;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -212,21 +376,87 @@ pthread_t pthread_self(void)
|
||||
return (pthread_t)LOS_CurTaskIDGet();
|
||||
}
|
||||
|
||||
STATIC UINT32 DoPthreadCancel(LosTaskCB *task)
|
||||
{
|
||||
UINT32 ret = LOS_OK;
|
||||
PthreadData *pthreadData = NULL;
|
||||
|
||||
LOS_TaskLock();
|
||||
pthreadData = (PthreadData *)(UINTPTR)task->arg;
|
||||
pthreadData->canceled = 0;
|
||||
if ((task->taskStatus == PTHREAD_TASK_INVAILD) || (LOS_TaskSuspend(task->taskID) != LOS_OK)) {
|
||||
ret = LOS_NOK;
|
||||
goto OUT;
|
||||
}
|
||||
free((VOID *)(UINTPTR)task->arg);
|
||||
task->arg = (UINT32)(UINTPTR)NULL;
|
||||
(void)LOS_TaskDelete(task->taskID);
|
||||
|
||||
OUT:
|
||||
LOS_TaskUnlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
int pthread_cancel(pthread_t thread)
|
||||
{
|
||||
UINT32 intSave;
|
||||
LosTaskCB *tcb = NULL;
|
||||
PthreadData *pthreadData = NULL;
|
||||
if (!IsPthread(thread)) {
|
||||
PRINT_ERR("[%s:%d] This task %d is not a posix thread!!!\n", __FUNCTION__, __LINE__, thread);
|
||||
return EINVAL;
|
||||
}
|
||||
intSave = LOS_IntLock();
|
||||
tcb = OS_TCB_FROM_TID((UINT32)thread);
|
||||
pthreadData = (PthreadData *)(UINTPTR)tcb->arg;
|
||||
pthreadData->canceled = 1;
|
||||
if ((pthreadData->cancelState == PTHREAD_CANCEL_ENABLE) &&
|
||||
(pthreadData->cancelType == PTHREAD_CANCEL_ASYNCHRONOUS)) {
|
||||
/*
|
||||
* If the thread has cancellation enabled, and it is in
|
||||
* asynchronous mode, suspend it and set corresponding thread's status.
|
||||
* We also release the thread out of any current wait to make it wake up.
|
||||
*/
|
||||
if (DoPthreadCancel(tcb) == LOS_NOK) {
|
||||
LOS_IntRestore(intSave);
|
||||
return ESRCH;
|
||||
}
|
||||
}
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
return ENOSYS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void pthread_testcancel(void)
|
||||
{
|
||||
if (CheckForCancel()) {
|
||||
/*
|
||||
* If we have cancellation enabled, and there is a cancellation
|
||||
* pending, then go ahead and do the deed.
|
||||
* Exit now with special retVal. pthread_exit() calls the
|
||||
* cancellation handlers implicitly.
|
||||
*/
|
||||
pthread_exit((void *)PTHREAD_CANCELED);
|
||||
}
|
||||
}
|
||||
|
||||
int pthread_join(pthread_t thread, void **retval)
|
||||
{
|
||||
UINTPTR result;
|
||||
UINT32 ret = LOS_TaskJoin((UINT32)thread, &result);
|
||||
UINT32 ret;
|
||||
if (!IsPthread(thread)) {
|
||||
PRINT_ERR("[%s:%d] This task %d is not a posix thread!!!\n", __FUNCTION__, __LINE__, thread);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
ret = LOS_TaskJoin((UINT32)thread, &result);
|
||||
if (ret == LOS_ERRNO_TSK_NOT_JOIN_SELF) {
|
||||
return EDEADLK;
|
||||
} else if ((ret == LOS_ERRNO_TSK_NOT_CREATED) ||
|
||||
(ret == LOS_ERRNO_TSK_OPERATE_IDLE) ||
|
||||
(ret == LOS_ERRNO_TSK_ID_INVALID) ||
|
||||
(ret == LOS_ERRNO_TSK_SUSPEND_SWTMR_NOT_ALLOWED)) {
|
||||
return ESRCH;
|
||||
} else if (ret != LOS_OK) {
|
||||
return EINVAL;
|
||||
}
|
||||
@@ -234,12 +464,19 @@ int pthread_join(pthread_t thread, void **retval)
|
||||
if (retval != NULL) {
|
||||
*retval = (VOID *)result;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_detach(pthread_t thread)
|
||||
{
|
||||
UINT32 ret = LOS_TaskDetach((UINT32)thread);
|
||||
UINT32 ret;
|
||||
if (!IsPthread(thread)) {
|
||||
PRINT_ERR("[%s:%d] This task %d is not a posix thread!!!\n", __FUNCTION__, __LINE__, thread);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
ret = LOS_TaskDetach((UINT32)thread);
|
||||
if (ret == LOS_ERRNO_TSK_NOT_JOIN) {
|
||||
return ESRCH;
|
||||
} else if (ret != LOS_OK) {
|
||||
@@ -253,9 +490,18 @@ void pthread_exit(void *retVal)
|
||||
{
|
||||
UINT32 intSave;
|
||||
|
||||
LosTaskCB *tcb = OS_TCB_FROM_TID(LOS_CurTaskIDGet());
|
||||
pthread_t thread = pthread_self();
|
||||
if (!IsPthread(thread)) {
|
||||
PRINT_ERR("[%s:%d] This task %d is not a posix thread!!!\n", __FUNCTION__, __LINE__, thread);
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
LosTaskCB *tcb = OS_TCB_FROM_TID((UINT32)thread);
|
||||
tcb->joinRetval = (UINTPTR)retVal;
|
||||
PthreadData *pthreadData = (PthreadData *)(UINTPTR)tcb->arg;
|
||||
if (pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL) != 0) {
|
||||
PRINT_ERR("%s: %d failed\n", __FUNCTION__, __LINE__);
|
||||
}
|
||||
|
||||
if (pthreadData->key != NULL) {
|
||||
PthreadExitKeyDtor(pthreadData);
|
||||
@@ -267,6 +513,7 @@ void pthread_exit(void *retVal)
|
||||
LOS_IntRestore(intSave);
|
||||
free(pthreadData);
|
||||
(void)LOS_TaskDelete(tcb->taskID);
|
||||
EXIT:
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
@@ -275,8 +522,15 @@ 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)) {
|
||||
char *taskName = NULL;
|
||||
|
||||
if (!IsPthread(thread)) {
|
||||
PRINT_ERR("[%s:%d] This task %d is not a posix thread!!!\n", __FUNCTION__, __LINE__, thread);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
taskName = LOS_TaskNameGet((UINT32)thread);
|
||||
if (taskName == NULL) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
@@ -298,15 +552,22 @@ int pthread_setname_np(pthread_t thread, const char *name)
|
||||
return EINVAL;
|
||||
}
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_getname_np(pthread_t thread, char *buf, size_t buflen)
|
||||
{
|
||||
int ret;
|
||||
const char *name = NULL;
|
||||
|
||||
const char *name = LOS_TaskNameGet((UINT32)thread);
|
||||
if (name == NULL || !IsPthread(thread)) {
|
||||
if (!IsPthread(thread)) {
|
||||
PRINT_ERR("[%s:%d] This task %d is not a posix thread!!!\n", __FUNCTION__, __LINE__, thread);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
name = LOS_TaskNameGet((UINT32)thread);
|
||||
if (name == NULL) {
|
||||
return EINVAL;
|
||||
}
|
||||
if (buflen > strlen(name)) {
|
||||
@@ -315,6 +576,7 @@ int pthread_getname_np(pthread_t thread, char *buf, size_t buflen)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return ERANGE;
|
||||
}
|
||||
|
||||
@@ -349,6 +611,12 @@ int pthread_key_create(pthread_key_t *k, void (*dtor)(void *))
|
||||
unsigned int count = 0;
|
||||
PthreadKey *keys = NULL;
|
||||
|
||||
pthread_t thread = pthread_self();
|
||||
if (!IsPthread(thread)) {
|
||||
PRINT_ERR("[%s:%d] This task %d is not a posix thread!!!\n", __FUNCTION__, __LINE__, thread);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if (k == NULL) {
|
||||
return EINVAL;
|
||||
}
|
||||
@@ -373,6 +641,7 @@ int pthread_key_create(pthread_key_t *k, void (*dtor)(void *))
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
*k = count;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -380,6 +649,12 @@ int pthread_key_delete(pthread_key_t k)
|
||||
{
|
||||
unsigned int intSave;
|
||||
|
||||
pthread_t thread = pthread_self();
|
||||
if (!IsPthread(thread)) {
|
||||
PRINT_ERR("[%s:%d] This task %d is not a posix thread!!!\n", __FUNCTION__, __LINE__, thread);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if (k >= PTHREAD_KEYS_MAX) {
|
||||
return EINVAL;
|
||||
}
|
||||
@@ -406,20 +681,22 @@ int pthread_key_delete(pthread_key_t k)
|
||||
g_pthreadKeyData[k].flag = PTHREAD_KEY_UNUSED;
|
||||
g_pthreadkeyCount--;
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_setspecific(pthread_key_t k, const void *x)
|
||||
{
|
||||
pthread_t self = pthread_self();
|
||||
unsigned int intSave;
|
||||
uintptr_t *key = NULL;
|
||||
|
||||
if (k >= PTHREAD_KEYS_MAX) {
|
||||
pthread_t self = pthread_self();
|
||||
if (!IsPthread(self)) {
|
||||
PRINT_ERR("[%s:%d] This task %d is not a posix thread!!!\n", __FUNCTION__, __LINE__, self);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if (!IsPthread(self)) {
|
||||
if (k >= PTHREAD_KEYS_MAX) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
@@ -446,6 +723,7 @@ int pthread_setspecific(pthread_key_t k, const void *x)
|
||||
|
||||
pthreadData->key[k] = (uintptr_t)x;
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -454,12 +732,12 @@ void *pthread_getspecific(pthread_key_t k)
|
||||
unsigned int intSave;
|
||||
void *key = NULL;
|
||||
pthread_t self = pthread_self();
|
||||
|
||||
if (k >= PTHREAD_KEYS_MAX) {
|
||||
if (!IsPthread(self)) {
|
||||
PRINT_ERR("[%s:%d] This task %d is not a posix thread!!!\n", __FUNCTION__, __LINE__, self);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!IsPthread(self)) {
|
||||
if (k >= PTHREAD_KEYS_MAX) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -473,6 +751,7 @@ void *pthread_getspecific(pthread_key_t k)
|
||||
|
||||
key = (void *)pthreadData->key[k];
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,10 +29,12 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include <errno.h>
|
||||
#include <securec.h>
|
||||
#include <limits.h>
|
||||
#include "pthread.h"
|
||||
#include "los_config.h"
|
||||
#include "los_debug.h"
|
||||
|
||||
int pthread_attr_init(pthread_attr_t *attr)
|
||||
{
|
||||
@@ -44,7 +46,7 @@ int pthread_attr_init(pthread_attr_t *attr)
|
||||
attr->schedpolicy = SCHED_RR;
|
||||
attr->schedparam.sched_priority = LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO;
|
||||
attr->inheritsched = PTHREAD_INHERIT_SCHED;
|
||||
attr->scope = PTHREAD_SCOPE_PROCESS;
|
||||
attr->scope = PTHREAD_SCOPE_SYSTEM;
|
||||
attr->stackaddr_set = 0;
|
||||
attr->stackaddr = NULL;
|
||||
attr->stacksize_set = 1;
|
||||
@@ -59,7 +61,8 @@ int pthread_attr_destroy(pthread_attr_t *attr)
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
/* Nothing to do here... */
|
||||
(void)memset_s(attr, sizeof(pthread_attr_t), 0, sizeof(pthread_attr_t));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -90,12 +93,12 @@ int pthread_attr_setscope(pthread_attr_t *attr, int scope)
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if (scope == PTHREAD_SCOPE_PROCESS) {
|
||||
if (scope == PTHREAD_SCOPE_SYSTEM) {
|
||||
attr->scope = (unsigned int)scope;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (scope == PTHREAD_SCOPE_SYSTEM) {
|
||||
if (scope == PTHREAD_SCOPE_PROCESS) {
|
||||
return ENOTSUP;
|
||||
}
|
||||
|
||||
@@ -220,6 +223,28 @@ int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stackSize)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_attr_setstack(pthread_attr_t *attr, void *stackAddr, size_t stackSize)
|
||||
{
|
||||
(void)attr;
|
||||
(void)stackAddr;
|
||||
(void)stackSize;
|
||||
PRINT_ERR("%s: Don't support the pthread stack func currently!\n", __FUNCTION__);
|
||||
errno = ENOSYS;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int pthread_attr_getstack(const pthread_attr_t *attr, void **stackAddr, size_t *stackSize)
|
||||
{
|
||||
(void)attr;
|
||||
(void)stackAddr;
|
||||
(void)stackSize;
|
||||
PRINT_ERR("%s: Don't support the pthread stack func currently!\n", __FUNCTION__);
|
||||
errno = ENOSYS;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stackSize)
|
||||
{
|
||||
/* Reject attempts to get a stack size when one has not been set. */
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "time_internal.h"
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
#include <stdlib.h>
|
||||
@@ -37,9 +36,11 @@
|
||||
#include <securec.h>
|
||||
#include "los_config.h"
|
||||
#include "los_task.h"
|
||||
#include <los_swtmr.h>
|
||||
#include "los_swtmr.h"
|
||||
#include "time_internal.h"
|
||||
#include "los_atomic.h"
|
||||
#include "los_event.h"
|
||||
#include "los_mux.h"
|
||||
|
||||
typedef struct {
|
||||
volatile INT32 *realValue;
|
||||
@@ -54,6 +55,31 @@ typedef struct {
|
||||
#define COND_FLAGS_MASK 0x0003U
|
||||
#define COND_COUNTER_MASK (~COND_FLAGS_MASK)
|
||||
|
||||
int pthread_condattr_getpshared(const pthread_condattr_t *attr, int *shared)
|
||||
{
|
||||
if ((attr == NULL) || (shared == NULL)) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
*shared = PTHREAD_PROCESS_PRIVATE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_condattr_setpshared(pthread_condattr_t *attr, int shared)
|
||||
{
|
||||
(VOID)attr;
|
||||
if ((shared != PTHREAD_PROCESS_PRIVATE) && (shared != PTHREAD_PROCESS_SHARED)) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if (shared != PTHREAD_PROCESS_PRIVATE) {
|
||||
return ENOSYS;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_condattr_destroy(pthread_condattr_t *attr)
|
||||
{
|
||||
if (attr == NULL) {
|
||||
@@ -61,6 +87,19 @@ int pthread_condattr_destroy(pthread_condattr_t *attr)
|
||||
}
|
||||
|
||||
(VOID)memset_s(attr, sizeof(pthread_condattr_t), 0, sizeof(pthread_condattr_t));
|
||||
attr->clock = INT32_MAX;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_condattr_getclock(const pthread_condattr_t *attr, clockid_t *clock)
|
||||
{
|
||||
if ((attr == NULL) || (clock == NULL)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
*clock = attr->clock;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -71,6 +110,7 @@ int pthread_condattr_init(pthread_condattr_t *attr)
|
||||
}
|
||||
|
||||
attr->clock = CLOCK_REALTIME;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -86,6 +126,7 @@ int pthread_condattr_setclock(pthread_condattr_t *attr, clockid_t clk)
|
||||
}
|
||||
|
||||
attr->clock = clk;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -95,6 +136,7 @@ STATIC INLINE INT32 CondInitCheck(const pthread_cond_t *cond)
|
||||
(cond->event.stEventList.pstNext == NULL)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -149,6 +191,7 @@ int pthread_cond_destroy(pthread_cond_t *cond)
|
||||
}
|
||||
free(cond->mutex);
|
||||
cond->mutex = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -222,6 +265,7 @@ STATIC INT32 ProcessReturnVal(pthread_cond_t *cond, INT32 val)
|
||||
ret = EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -230,15 +274,17 @@ int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
|
||||
{
|
||||
INT32 ret;
|
||||
UINT64 absTicks;
|
||||
const UINT32 nsPerTick = OS_SYS_NS_PER_SECOND / LOSCFG_BASE_CORE_TICK_PER_SECOND;
|
||||
struct timespec tp;
|
||||
UINT64 nseconds;
|
||||
UINT64 currTime;
|
||||
|
||||
if ((cond == NULL) || (mutex == NULL) || (ts == NULL)) {
|
||||
LosMuxCB *muxPosted = NULL;
|
||||
pthread_testcancel();
|
||||
if ((cond == NULL) || (mutex == NULL) || (ts == NULL) || (mutex->magic != _MUX_MAGIC)) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
muxPosted = GET_MUX(mutex->handle);
|
||||
if ((mutex->stAttr.type == PTHREAD_MUTEX_ERRORCHECK) && (g_losTask.runTask != muxPosted->owner)) {
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
if (CondInitCheck(cond)) {
|
||||
ret = pthread_cond_init(cond, NULL);
|
||||
if (ret != 0) {
|
||||
@@ -250,17 +296,11 @@ int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
|
||||
cond->count++;
|
||||
(VOID)pthread_mutex_unlock(cond->mutex);
|
||||
|
||||
if (!ValidTimeSpec(ts)) {
|
||||
return EINVAL;
|
||||
ret = OsGetTickTimeFromNow(ts, cond->clock, &absTicks);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
clock_gettime(cond->clock, &tp);
|
||||
currTime = (UINT64)tp.tv_sec * OS_SYS_NS_PER_SECOND + tp.tv_nsec;
|
||||
nseconds = (UINT64)ts->tv_sec * OS_SYS_NS_PER_SECOND + ts->tv_nsec;
|
||||
if (currTime >= nseconds) {
|
||||
return ETIMEDOUT;
|
||||
}
|
||||
absTicks = ((nseconds - currTime) + nsPerTick - 1) / nsPerTick + 1;
|
||||
if (absTicks >= UINT32_MAX) {
|
||||
return EINVAL;
|
||||
}
|
||||
@@ -277,6 +317,8 @@ int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
|
||||
}
|
||||
|
||||
ret = ProcessReturnVal(cond, ret);
|
||||
pthread_testcancel();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,8 +35,12 @@
|
||||
#include "los_compiler.h"
|
||||
#include "los_mux.h"
|
||||
#include "errno.h"
|
||||
#include "los_mux.h"
|
||||
#include "los_debug.h"
|
||||
#include "los_hook.h"
|
||||
#include "los_sched.h"
|
||||
|
||||
|
||||
#define MUTEXATTR_TYPE_MASK 0x0FU
|
||||
#define OS_SYS_NS_PER_MSECOND 1000000
|
||||
#define OS_SYS_NS_PER_SECOND 1000000000
|
||||
|
||||
@@ -45,7 +49,7 @@ static inline int MapError(UINT32 err)
|
||||
switch (err) {
|
||||
case LOS_OK:
|
||||
return 0;
|
||||
case LOS_ERRNO_MUX_PEND_INTERR:
|
||||
case LOS_ERRNO_MUX_IN_INTERR:
|
||||
return EPERM;
|
||||
case LOS_ERRNO_MUX_PEND_IN_LOCK:
|
||||
return EDEADLK;
|
||||
@@ -68,7 +72,28 @@ int pthread_mutexattr_init(pthread_mutexattr_t *mutexAttr)
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
mutexAttr->type = PTHREAD_MUTEX_RECURSIVE;
|
||||
mutexAttr->type = PTHREAD_MUTEX_DEFAULT;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *outType)
|
||||
{
|
||||
INT32 type;
|
||||
|
||||
if ((attr == NULL) || (outType == NULL)) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
type = (INT32)(attr->type & MUTEXATTR_TYPE_MASK);
|
||||
if ((type != PTHREAD_MUTEX_NORMAL) &&
|
||||
(type != PTHREAD_MUTEX_RECURSIVE) &&
|
||||
(type != PTHREAD_MUTEX_ERRORCHECK)) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
*outType = type;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -83,12 +108,8 @@ int pthread_mutexattr_settype(pthread_mutexattr_t *mutexAttr, int type)
|
||||
((unsigned)type != PTHREAD_MUTEX_ERRORCHECK)) {
|
||||
return EINVAL;
|
||||
}
|
||||
mutexAttr->type = (UINT8)((mutexAttr->type & ~MUTEXATTR_TYPE_MASK) | (UINT32)type);
|
||||
|
||||
if ((unsigned)type != PTHREAD_MUTEX_RECURSIVE) {
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
mutexAttr->type = PTHREAD_MUTEX_RECURSIVE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -99,17 +120,25 @@ int pthread_mutexattr_destroy(pthread_mutexattr_t *mutexAttr)
|
||||
}
|
||||
|
||||
(VOID)memset_s(mutexAttr, sizeof(pthread_mutexattr_t), 0, sizeof(pthread_mutexattr_t));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Initialize mutex. If mutexAttr is NULL, use default attributes. */
|
||||
int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexAttr)
|
||||
{
|
||||
pthread_mutexattr_t useAttr;
|
||||
UINT32 muxHandle;
|
||||
UINT32 ret;
|
||||
|
||||
if ((mutexAttr != NULL) && (mutexAttr->type != PTHREAD_MUTEX_RECURSIVE)) {
|
||||
return EOPNOTSUPP;
|
||||
if (mutex == NULL) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if (mutexAttr == NULL) {
|
||||
(VOID)pthread_mutexattr_init(&useAttr);
|
||||
} else {
|
||||
useAttr = *mutexAttr;
|
||||
}
|
||||
|
||||
ret = LOS_MuxCreate(&muxHandle);
|
||||
@@ -117,6 +146,7 @@ int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexA
|
||||
return MapError(ret);
|
||||
}
|
||||
|
||||
mutex->stAttr = useAttr;
|
||||
mutex->magic = _MUX_MAGIC;
|
||||
mutex->handle = muxHandle;
|
||||
|
||||
@@ -126,7 +156,7 @@ int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexA
|
||||
int pthread_mutex_destroy(pthread_mutex_t *mutex)
|
||||
{
|
||||
UINT32 ret;
|
||||
if (mutex->magic != _MUX_MAGIC) {
|
||||
if ((mutex == NULL) || (mutex->magic != _MUX_MAGIC)) {
|
||||
return EINVAL;
|
||||
}
|
||||
ret = LOS_MuxDelete(mutex->handle);
|
||||
@@ -135,16 +165,172 @@ int pthread_mutex_destroy(pthread_mutex_t *mutex)
|
||||
}
|
||||
mutex->handle = _MUX_INVALID_HANDLE;
|
||||
mutex->magic = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
STATIC UINT32 CheckMutexAttr(const pthread_mutexattr_t *attr)
|
||||
{
|
||||
if ((attr->type != PTHREAD_MUTEX_NORMAL) &&
|
||||
(attr->type != PTHREAD_MUTEX_RECURSIVE) &&
|
||||
(attr->type != PTHREAD_MUTEX_ERRORCHECK)) {
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 MuxPreCheck(const pthread_mutex_t *mutex, const LosTaskCB *runTask)
|
||||
{
|
||||
if ((mutex == NULL) || (mutex->magic != _MUX_MAGIC) ||
|
||||
((mutex->handle != _MUX_INVALID_HANDLE) && (mutex->handle >= (UINT32)LOSCFG_BASE_IPC_MUX_LIMIT))) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if (OS_INT_ACTIVE) {
|
||||
return EPERM;
|
||||
}
|
||||
/* DO NOT recommend to use blocking API in system tasks */
|
||||
if ((runTask != NULL) && (runTask->taskStatus & OS_TASK_FLAG_SYSTEM_TASK)) {
|
||||
PRINT_DEBUG("Warning: DO NOT recommend to use %s in system tasks.\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
if (CheckMutexAttr(&mutex->stAttr) != LOS_OK) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
STATIC UINT32 MuxPendForPosix(pthread_mutex_t *mutex, UINT32 timeout)
|
||||
{
|
||||
UINT32 intSave;
|
||||
LosMuxCB *muxPended = NULL;
|
||||
UINT32 retErr;
|
||||
LosTaskCB *runningTask = NULL;
|
||||
UINT32 muxHandle = mutex->handle;
|
||||
|
||||
muxPended = GET_MUX(muxHandle);
|
||||
intSave = LOS_IntLock();
|
||||
|
||||
if (muxPended->muxStat == OS_MUX_UNUSED) {
|
||||
LOS_IntRestore(intSave);
|
||||
OS_RETURN_ERROR(LOS_ERRNO_MUX_INVALID);
|
||||
}
|
||||
|
||||
runningTask = (LosTaskCB *)g_losTask.runTask;
|
||||
if (muxPended->muxCount == 0) {
|
||||
muxPended->muxCount++;
|
||||
muxPended->owner = runningTask;
|
||||
muxPended->priority = runningTask->priority;
|
||||
LOS_IntRestore(intSave);
|
||||
OsHookCall(LOS_HOOK_TYPE_MUX_PEND, muxPended, timeout);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
if ((muxPended->owner == runningTask) && (mutex->stAttr.type == PTHREAD_MUTEX_RECURSIVE)) {
|
||||
muxPended->muxCount++;
|
||||
LOS_IntRestore(intSave);
|
||||
OsHookCall(LOS_HOOK_TYPE_MUX_PEND, muxPended, timeout);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
if (!timeout) {
|
||||
LOS_IntRestore(intSave);
|
||||
OS_RETURN_ERROR(LOS_ERRNO_MUX_UNAVAILABLE);
|
||||
}
|
||||
|
||||
runningTask->taskMux = (VOID *)muxPended;
|
||||
|
||||
if (muxPended->owner->priority > runningTask->priority) {
|
||||
(VOID)OsSchedModifyTaskSchedParam(muxPended->owner, runningTask->priority);
|
||||
}
|
||||
|
||||
OsSchedTaskWait(&muxPended->muxList, timeout);
|
||||
|
||||
LOS_IntRestore(intSave);
|
||||
OsHookCall(LOS_HOOK_TYPE_MUX_PEND, muxPended, timeout);
|
||||
LOS_Schedule();
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
if (runningTask->taskStatus & OS_TASK_STATUS_TIMEOUT) {
|
||||
runningTask->taskStatus &= (~OS_TASK_STATUS_TIMEOUT);
|
||||
retErr = LOS_ERRNO_MUX_TIMEOUT;
|
||||
LOS_IntRestore(intSave);
|
||||
OS_RETURN_ERROR(retErr);
|
||||
}
|
||||
|
||||
LOS_IntRestore(intSave);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 MuxPostForPosix(pthread_mutex_t *mutex)
|
||||
{
|
||||
UINT32 intSave;
|
||||
LosMuxCB *muxPosted = NULL;
|
||||
LosTaskCB *resumedTask = NULL;
|
||||
LosTaskCB *runningTask = NULL;
|
||||
UINT32 muxHandle = mutex->handle;
|
||||
|
||||
muxPosted = GET_MUX(muxHandle);
|
||||
intSave = LOS_IntLock();
|
||||
|
||||
if (muxPosted->muxStat == OS_MUX_UNUSED) {
|
||||
LOS_IntRestore(intSave);
|
||||
OS_RETURN_ERROR(LOS_ERRNO_MUX_INVALID);
|
||||
}
|
||||
|
||||
runningTask = (LosTaskCB *)g_losTask.runTask;
|
||||
if ((muxPosted->muxCount == 0) || (muxPosted->owner != runningTask)) {
|
||||
LOS_IntRestore(intSave);
|
||||
OS_RETURN_ERROR(LOS_ERRNO_MUX_INVALID);
|
||||
}
|
||||
|
||||
if ((--(muxPosted->muxCount) != 0) && (mutex->stAttr.type == PTHREAD_MUTEX_RECURSIVE)) {
|
||||
LOS_IntRestore(intSave);
|
||||
OsHookCall(LOS_HOOK_TYPE_MUX_POST, muxPosted);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
if ((muxPosted->owner->priority) != muxPosted->priority) {
|
||||
(VOID)OsSchedModifyTaskSchedParam(muxPosted->owner, muxPosted->priority);
|
||||
}
|
||||
|
||||
if (!LOS_ListEmpty(&muxPosted->muxList)) {
|
||||
resumedTask = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&(muxPosted->muxList)));
|
||||
|
||||
muxPosted->muxCount = 1;
|
||||
muxPosted->owner = resumedTask;
|
||||
muxPosted->priority = resumedTask->priority;
|
||||
resumedTask->taskMux = NULL;
|
||||
|
||||
OsSchedTaskWake(resumedTask);
|
||||
|
||||
LOS_IntRestore(intSave);
|
||||
OsHookCall(LOS_HOOK_TYPE_MUX_POST, muxPosted);
|
||||
LOS_Schedule();
|
||||
} else {
|
||||
muxPosted->owner = NULL;
|
||||
LOS_IntRestore(intSave);
|
||||
}
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *absTimeout)
|
||||
{
|
||||
UINT32 ret;
|
||||
UINT32 timeout;
|
||||
UINT64 timeoutNs;
|
||||
struct timespec curTime = {0};
|
||||
if ((mutex->magic != _MUX_MAGIC) || (absTimeout->tv_nsec < 0) || (absTimeout->tv_nsec >= OS_SYS_NS_PER_SECOND)) {
|
||||
LosMuxCB *muxPended = NULL;
|
||||
|
||||
ret = MuxPreCheck(mutex, OS_TCB_FROM_TID(LOS_CurTaskIDGet()));
|
||||
if (ret != 0) {
|
||||
return (INT32)ret;
|
||||
}
|
||||
|
||||
if ((absTimeout == NULL) || (absTimeout->tv_nsec < 0) || (absTimeout->tv_nsec >= OS_SYS_NS_PER_SECOND)) {
|
||||
return EINVAL;
|
||||
}
|
||||
if (mutex->handle == _MUX_INVALID_HANDLE) {
|
||||
@@ -152,6 +338,13 @@ int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *absTi
|
||||
if (ret != LOS_OK) {
|
||||
return MapError(ret);
|
||||
}
|
||||
} else {
|
||||
muxPended = GET_MUX(mutex->handle);
|
||||
if ((mutex->stAttr.type == PTHREAD_MUTEX_ERRORCHECK) &&
|
||||
(muxPended->muxCount != 0) &&
|
||||
(muxPended->owner == OS_TCB_FROM_TID(LOS_CurTaskIDGet()))) {
|
||||
return EDEADLK;
|
||||
}
|
||||
}
|
||||
ret = clock_gettime(CLOCK_REALTIME, &curTime);
|
||||
if (ret != LOS_OK) {
|
||||
@@ -162,7 +355,8 @@ int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *absTi
|
||||
return ETIMEDOUT;
|
||||
}
|
||||
timeout = (timeoutNs + (OS_SYS_NS_PER_MSECOND - 1)) / OS_SYS_NS_PER_MSECOND;
|
||||
ret = LOS_MuxPend(mutex->handle, timeout);
|
||||
ret = MuxPendForPosix(mutex, timeout);
|
||||
|
||||
return MapError(ret);
|
||||
}
|
||||
|
||||
@@ -170,42 +364,72 @@ int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *absTi
|
||||
int pthread_mutex_lock(pthread_mutex_t *mutex)
|
||||
{
|
||||
UINT32 ret;
|
||||
if (mutex->magic != _MUX_MAGIC) {
|
||||
return EINVAL;
|
||||
LosMuxCB *muxPended = NULL;
|
||||
LosTaskCB *runTask = OS_TCB_FROM_TID(LOS_CurTaskIDGet());
|
||||
|
||||
ret = MuxPreCheck(mutex, runTask);
|
||||
if (ret != 0) {
|
||||
return (INT32)ret;
|
||||
}
|
||||
|
||||
if (mutex->handle == _MUX_INVALID_HANDLE) {
|
||||
ret = LOS_MuxCreate(&mutex->handle);
|
||||
if (ret != LOS_OK) {
|
||||
return MapError(ret);
|
||||
}
|
||||
} else {
|
||||
muxPended = GET_MUX(mutex->handle);
|
||||
if ((mutex->stAttr.type == PTHREAD_MUTEX_ERRORCHECK) &&
|
||||
(muxPended->muxCount != 0) &&
|
||||
(muxPended->owner == runTask)) {
|
||||
return EDEADLK;
|
||||
}
|
||||
}
|
||||
ret = LOS_MuxPend(mutex->handle, LOS_WAIT_FOREVER);
|
||||
ret = MuxPendForPosix(mutex, LOS_WAIT_FOREVER);
|
||||
|
||||
return MapError(ret);
|
||||
}
|
||||
|
||||
int pthread_mutex_trylock(pthread_mutex_t *mutex)
|
||||
{
|
||||
UINT32 ret;
|
||||
if (mutex->magic != _MUX_MAGIC) {
|
||||
return EINVAL;
|
||||
LosMuxCB *muxPended = NULL;
|
||||
|
||||
ret = MuxPreCheck(mutex, OS_TCB_FROM_TID(LOS_CurTaskIDGet()));
|
||||
if (ret != 0) {
|
||||
return (INT32)ret;
|
||||
}
|
||||
|
||||
if (mutex->handle == _MUX_INVALID_HANDLE) {
|
||||
ret = LOS_MuxCreate(&mutex->handle);
|
||||
if (ret != LOS_OK) {
|
||||
return MapError(ret);
|
||||
}
|
||||
} else {
|
||||
muxPended = GET_MUX(mutex->handle);
|
||||
if ((mutex->stAttr.type != PTHREAD_MUTEX_RECURSIVE) && (muxPended->muxCount != 0)) {
|
||||
return EBUSY;
|
||||
}
|
||||
}
|
||||
ret = LOS_MuxPend(mutex->handle, 0);
|
||||
ret = MuxPendForPosix(mutex, 0);
|
||||
|
||||
return MapError(ret);
|
||||
}
|
||||
|
||||
int pthread_mutex_unlock(pthread_mutex_t *mutex)
|
||||
{
|
||||
UINT32 ret;
|
||||
if (mutex->magic != _MUX_MAGIC) {
|
||||
ret = MuxPreCheck(mutex, OS_TCB_FROM_TID(LOS_CurTaskIDGet()));
|
||||
if (ret != 0) {
|
||||
return (INT32)ret;
|
||||
}
|
||||
|
||||
if (mutex->handle == _MUX_INVALID_HANDLE) {
|
||||
return EINVAL;
|
||||
}
|
||||
ret = LOS_MuxPost(mutex->handle);
|
||||
|
||||
ret = MuxPostForPosix(mutex);
|
||||
|
||||
return MapError(ret);
|
||||
}
|
||||
|
||||
|
||||
@@ -102,6 +102,7 @@ int sem_destroy(sem_t *sem)
|
||||
errno = MapError(ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -119,6 +120,7 @@ int sem_wait(sem_t *sem)
|
||||
errno = MapError(ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -140,38 +142,37 @@ int sem_post(sem_t *sem)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static long long GetTickTimeFromNow(const struct timespec *absTimeSpec)
|
||||
int sem_trywait(sem_t *sem)
|
||||
{
|
||||
struct timespec tsNow = { 0 };
|
||||
long long ns;
|
||||
long long tick;
|
||||
UINT32 ret;
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &tsNow);
|
||||
ns = (absTimeSpec->tv_sec - tsNow.tv_sec) * OS_SYS_NS_PER_SECOND + (absTimeSpec->tv_nsec - tsNow.tv_nsec);
|
||||
if ((sem == NULL) || (sem->s_magic != _SEM_MAGIC)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Round up for ticks */
|
||||
tick = (ns * LOSCFG_BASE_CORE_TICK_PER_SECOND + (OS_SYS_NS_PER_SECOND - 1)) / OS_SYS_NS_PER_SECOND;
|
||||
return tick;
|
||||
ret = LOS_SemPend((UINT32)sem->s_handle, LOS_NO_WAIT);
|
||||
if (ret != LOS_OK) {
|
||||
errno = MapError(ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sem_timedwait(sem_t *sem, const struct timespec *timeout)
|
||||
{
|
||||
UINT32 ret;
|
||||
long long tickCnt;
|
||||
UINT64 tickCnt;
|
||||
|
||||
if ((sem == NULL) || (sem->s_magic != (int)_SEM_MAGIC)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!ValidTimeSpec(timeout)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
tickCnt = GetTickTimeFromNow(timeout);
|
||||
if (tickCnt < 0) {
|
||||
errno = ETIMEDOUT;
|
||||
ret = OsGetTickTimeFromNow(timeout, CLOCK_REALTIME, &tickCnt);
|
||||
if (ret != 0) {
|
||||
errno = (INT32)ret;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -192,7 +193,7 @@ int sem_getvalue(sem_t *sem, int *currVal)
|
||||
{
|
||||
UINT32 ret;
|
||||
|
||||
if ((sem == NULL) || (currVal == NULL)) {
|
||||
if ((sem == NULL) || (sem->s_magic != _SEM_MAGIC)|| (currVal == NULL)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,9 @@
|
||||
#include "los_tick.h"
|
||||
#include "los_context.h"
|
||||
#include "los_interrupt.h"
|
||||
#include "sys/times.h"
|
||||
|
||||
#define DELAYTIMER_MAX 0x7FFFFFFFF
|
||||
|
||||
/* accumulative time delta from discontinuous modify */
|
||||
STATIC struct timespec g_accDeltaFromSet;
|
||||
@@ -96,7 +99,7 @@ int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
|
||||
}
|
||||
|
||||
/* sleep in interrupt context or in task sched lock state */
|
||||
errno = EPERM;
|
||||
errno = EINTR;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -105,12 +108,12 @@ int timer_create(clockid_t clockID, struct sigevent *restrict evp, timer_t *rest
|
||||
UINT32 ret;
|
||||
UINT32 swtmrID;
|
||||
|
||||
if (!timerID || (clockID != CLOCK_REALTIME)) {
|
||||
if (!timerID || (clockID != CLOCK_REALTIME) || !evp) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!evp || evp->sigev_notify != SIGEV_THREAD || evp->sigev_notify_attributes) {
|
||||
if ((evp->sigev_notify != SIGEV_THREAD) || evp->sigev_notify_attributes) {
|
||||
errno = ENOTSUP;
|
||||
return -1;
|
||||
}
|
||||
@@ -152,7 +155,7 @@ int timer_settime(timer_t timerID, int flags,
|
||||
|
||||
if (flags != 0) {
|
||||
/* flags not supported currently */
|
||||
errno = ENOSYS;
|
||||
errno = ENOTSUP;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -190,6 +193,7 @@ int timer_settime(timer_t timerID, int flags,
|
||||
swtmr->ucMode = (interval ? LOS_SWTMR_MODE_PERIOD : LOS_SWTMR_MODE_NO_SELFDELETE);
|
||||
swtmr->uwInterval = (interval ? interval : expiry);
|
||||
|
||||
swtmr->ucOverrun = 0;
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
if ((value->it_value.tv_sec == 0) && (value->it_value.tv_nsec == 0)) {
|
||||
@@ -229,7 +233,9 @@ int timer_gettime(timer_t timerID, struct itimerspec *value)
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ret == LOS_ERRNO_SWTMR_NOT_STARTED) {
|
||||
tick = 0;
|
||||
}
|
||||
OsTick2TimeSpec(&value->it_value, tick);
|
||||
OsTick2TimeSpec(&value->it_interval, (swtmr->ucMode == LOS_SWTMR_MODE_ONCE) ? 0 : swtmr->uwInterval);
|
||||
return 0;
|
||||
@@ -237,10 +243,13 @@ int timer_gettime(timer_t timerID, struct itimerspec *value)
|
||||
|
||||
int timer_getoverrun(timer_t timerID)
|
||||
{
|
||||
(void)timerID;
|
||||
SWTMR_CTRL_S *swtmr = NULL;
|
||||
swtmr = OS_SWT_FROM_SID((UINT32)(UINTPTR)timerID);
|
||||
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
if ((swtmr->ucOverrun) >= (UINT8)DELAYTIMER_MAX) {
|
||||
return (INT32)DELAYTIMER_MAX;
|
||||
}
|
||||
return (int)swtmr->ucOverrun;
|
||||
}
|
||||
|
||||
STATIC VOID OsGetHwTime(struct timespec *hwTime)
|
||||
@@ -696,3 +705,17 @@ unsigned sleep(unsigned seconds)
|
||||
specTime.tv_nsec = (long)(nanoseconds % OS_SYS_NS_PER_SECOND);
|
||||
return nanosleep(&specTime, NULL);
|
||||
}
|
||||
|
||||
clock_t times(struct tms *tms)
|
||||
{
|
||||
clock_t clockTick = (clock_t)LOS_TickCountGet();
|
||||
|
||||
if (tms != NULL) {
|
||||
tms->tms_cstime = clockTick;
|
||||
tms->tms_cutime = clockTick;
|
||||
tms->tms_stime = clockTick;
|
||||
tms->tms_utime = clockTick;
|
||||
}
|
||||
return clockTick;
|
||||
}
|
||||
|
||||
|
||||
@@ -111,5 +111,27 @@ STATIC INLINE VOID OsTick2TimeSpec(struct timespec *tp, UINT32 tick)
|
||||
tp->tv_sec = (time_t)(ns / OS_SYS_NS_PER_SECOND);
|
||||
tp->tv_nsec = (long)(ns % OS_SYS_NS_PER_SECOND);
|
||||
}
|
||||
|
||||
STATIC INLINE INT32 OsGetTickTimeFromNow(const struct timespec *ts, clockid_t clockId, UINT64 *absTicks)
|
||||
{
|
||||
struct timespec tp;
|
||||
UINT64 nseconds;
|
||||
UINT64 currTime;
|
||||
const UINT32 nsPerTick = OS_SYS_NS_PER_SECOND / LOSCFG_BASE_CORE_TICK_PER_SECOND;
|
||||
|
||||
if (!ValidTimeSpec(ts)) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
clock_gettime(clockId, &tp);
|
||||
currTime = (UINT64)tp.tv_sec * OS_SYS_NS_PER_SECOND + tp.tv_nsec;
|
||||
nseconds = (UINT64)ts->tv_sec * OS_SYS_NS_PER_SECOND + ts->tv_nsec;
|
||||
if (currTime >= nseconds) {
|
||||
return ETIMEDOUT;
|
||||
}
|
||||
*absTicks = ((nseconds - currTime) + nsPerTick - 1) / nsPerTick + 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ extern "C" {
|
||||
*
|
||||
* Solution: Check whether the mutex is being locked during an interrupt.
|
||||
*/
|
||||
#define LOS_ERRNO_MUX_PEND_INTERR LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x05)
|
||||
#define LOS_ERRNO_MUX_IN_INTERR LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x05)
|
||||
|
||||
/**
|
||||
* @ingroup los_mux
|
||||
@@ -256,7 +256,7 @@ extern UINT32 LOS_MuxDelete(UINT32 muxHandle);
|
||||
* is not applicable for the current operation.
|
||||
* @retval #LOS_ERRNO_MUX_UNAVAILABLE The mutex fails to be locked because it is locked by another thread and
|
||||
* a period of time is not set for waiting for the mutex to become available.
|
||||
* @retval #LOS_ERRNO_MUX_PEND_INTERR The mutex is being locked during an interrupt.
|
||||
* @retval #LOS_ERRNO_MUX_IN_INTERR The mutex is being locked during an interrupt.
|
||||
* @retval #LOS_ERRNO_MUX_PEND_IN_LOCK The mutex is waited on when the task scheduling is disabled.
|
||||
* @retval #LOS_ERRNO_MUX_TIMEOUT The mutex waiting times out.
|
||||
* @retval #LOS_OK The mutex is successfully locked.
|
||||
@@ -284,7 +284,7 @@ extern UINT32 LOS_MuxPend(UINT32 muxHandle, UINT32 timeout);
|
||||
*
|
||||
* @retval #LOS_ERRNO_MUX_INVALID The mutex state (for example, the mutex does not exist or is not in use
|
||||
* or owned by other thread) is not applicable for the current operation.
|
||||
* @retval #LOS_ERRNO_MUX_PEND_INTERR The mutex is being released during an interrupt.
|
||||
* @retval #LOS_ERRNO_MUX_IN_INTERR The mutex is being released during an interrupt.
|
||||
* @retval #LOS_OK The mutex is successfully released.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_mux.h: the header file that contains the API declaration.</li></ul>
|
||||
|
||||
@@ -333,7 +333,17 @@ extern "C" {
|
||||
|
||||
/**
|
||||
* @ingroup los_queue
|
||||
* In struct QUEUE_INFO_S, the length of each waitReadTask/waitWriteTask/waitMemTask array depends on the value
|
||||
* Queue error code: The buffer size passed in during queue readding or writting is bigger than the biggest size.
|
||||
*
|
||||
* Value: 0x02000620
|
||||
*
|
||||
* Solution: Decrease the buffer size.
|
||||
*/
|
||||
#define LOS_ERRNO_QUEUE_BUFFER_SIZE_TOO_BIG LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x20)
|
||||
|
||||
/**
|
||||
* @ingroup los_queue
|
||||
* In struct QueueInfo, the length of each waitReadTask/waitWriteTask/waitMemTask array depends on the value
|
||||
* LOSCFG_BASE_CORE_TSK_LIMIT. The type of each array element is UINT32, which means that each element could mark 32(=2^5) tasks.
|
||||
* OS_WAIT_TASK_ARRAY_LEN is used to calculate the array length.
|
||||
* OS_WAIT_TASK_ID_TO_ARRAY_IDX is used to transfer task ID to array index.
|
||||
@@ -387,7 +397,7 @@ typedef struct tagQueueInfo {
|
||||
* <ul><li>los_queue.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see LOS_QueueDelete
|
||||
*/
|
||||
extern UINT32 LOS_QueueCreate(CHAR *queueName,
|
||||
extern UINT32 LOS_QueueCreate(const CHAR *queueName,
|
||||
UINT16 len,
|
||||
UINT32 *queueID,
|
||||
UINT32 flags,
|
||||
|
||||
@@ -43,21 +43,20 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define OS_SCHED_MINI_PERIOD (g_sysClock / LOSCFG_BASE_CORE_TICK_PER_SECOND_MINI)
|
||||
#define OS_TICK_RESPONSE_PRECISION (UINT32)((OS_SCHED_MINI_PERIOD * 75) / 100)
|
||||
#define OS_SCHED_MAX_RESPONSE_TIME (UINT64)(((UINT64)-1) - 1U)
|
||||
|
||||
extern UINT32 g_taskScheduled;
|
||||
typedef BOOL (*SchedScan)(VOID);
|
||||
|
||||
extern UINT64 g_sysSchedStartTime;
|
||||
|
||||
VOID OsSchedResetSchedResponseTime(UINT64 responseTime);
|
||||
|
||||
VOID OsSchedSetIdleTaskSchedParam(LosTaskCB *idleTask);
|
||||
|
||||
UINT32 OsSchedSwtmrScanRegister(SchedScan func);
|
||||
|
||||
VOID OsSchedUpdateExpireTime(UINT64 startTime);
|
||||
VOID OsSchedUpdateExpireTime(VOID);
|
||||
|
||||
UINT64 OsSchedGetNextExpireTime(UINT64 startTime);
|
||||
|
||||
VOID OsSchedTaskDeQueue(LosTaskCB *taskCB);
|
||||
|
||||
@@ -89,15 +88,9 @@ BOOL OsSchedTaskSwitch(VOID);
|
||||
|
||||
LosTaskCB *OsGetTopTask(VOID);
|
||||
|
||||
UINT32 OsSchedRealSleepTimeSet(VOID (*func)(UINT64));
|
||||
|
||||
STATIC INLINE UINT64 OsGetCurrSchedTimeCycle(VOID)
|
||||
{
|
||||
if (g_sysSchedStartTime != OS_64BIT_MAX) {
|
||||
return (LOS_SysCycleGet() - g_sysSchedStartTime);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return LOS_SysCycleGet();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -55,10 +55,15 @@ typedef struct {
|
||||
LOS_DL_LIST sortLink;
|
||||
} SortLinkAttribute;
|
||||
|
||||
extern SortLinkAttribute g_taskSortLink;
|
||||
extern SortLinkAttribute g_swtmrSortLink;
|
||||
|
||||
#define OS_SORT_LINK_INVALID_TIME ((UINT64)-1)
|
||||
#define SET_SORTLIST_VALUE(sortList, value) (((SortLinkList *)(sortList))->responseTime = (value))
|
||||
#define GET_SORTLIST_VALUE(sortList) (((SortLinkList *)(sortList))->responseTime)
|
||||
|
||||
#define OS_SORT_LINK_UINT64_MAX ((UINT64)-1)
|
||||
|
||||
STATIC INLINE UINT64 OsSortLinkGetRemainTime(UINT64 currTime, const SortLinkList *targetSortList)
|
||||
{
|
||||
if (currTime >= targetSortList->responseTime) {
|
||||
@@ -67,14 +72,42 @@ STATIC INLINE UINT64 OsSortLinkGetRemainTime(UINT64 currTime, const SortLinkList
|
||||
return (targetSortList->responseTime - currTime);
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsDeleteNodeSortLink(SortLinkList *sortList)
|
||||
{
|
||||
LOS_ListDelete(&sortList->sortLinkNode);
|
||||
SET_SORTLIST_VALUE(sortList, OS_SORT_LINK_INVALID_TIME);
|
||||
}
|
||||
|
||||
STATIC INLINE UINT64 GetSortLinkNextExpireTime(SortLinkAttribute *sortHeader, UINT64 startTime, UINT32 tickPrecision)
|
||||
{
|
||||
LOS_DL_LIST *head = &sortHeader->sortLink;
|
||||
LOS_DL_LIST *list = head->pstNext;
|
||||
|
||||
if (LOS_ListEmpty(head)) {
|
||||
return OS_SORT_LINK_UINT64_MAX - tickPrecision;
|
||||
}
|
||||
|
||||
SortLinkList *listSorted = LOS_DL_LIST_ENTRY(list, SortLinkList, sortLinkNode);
|
||||
if (listSorted->responseTime <= (startTime + tickPrecision)) {
|
||||
return (startTime + tickPrecision);
|
||||
}
|
||||
|
||||
return listSorted->responseTime;
|
||||
}
|
||||
|
||||
STATIC INLINE UINT64 OsGetNextExpireTime(UINT64 startTime, UINT32 tickPrecision)
|
||||
{
|
||||
UINT64 taskExpireTime = GetSortLinkNextExpireTime(&g_taskSortLink, startTime, tickPrecision);
|
||||
UINT64 swtmrExpireTime = GetSortLinkNextExpireTime(&g_swtmrSortLink, startTime, tickPrecision);
|
||||
return (taskExpireTime < swtmrExpireTime) ? taskExpireTime : swtmrExpireTime;
|
||||
}
|
||||
|
||||
SortLinkAttribute *OsGetSortLinkAttribute(SortLinkType type);
|
||||
UINT64 OsGetNextExpireTime(UINT64 startTime);
|
||||
UINT32 OsSortLinkInit(SortLinkAttribute *sortLinkHeader);
|
||||
VOID OsDeleteNodeSortLink(SortLinkList *sortList);
|
||||
VOID OsAdd2SortLink(SortLinkList *node, UINT64 startTime, UINT32 waitTicks, SortLinkType type);
|
||||
VOID OsDeleteSortLink(SortLinkList *node);
|
||||
UINT32 OsSortLinkGetTargetExpireTime(UINT64 currTime, const SortLinkList *targetSortList);
|
||||
UINT32 OsSortLinkGetNextExpireTime(const SortLinkAttribute *sortLinkHeader);
|
||||
UINT64 OsSortLinkGetTargetExpireTime(UINT64 currTime, const SortLinkList *targetSortList);
|
||||
UINT64 OsSortLinkGetNextExpireTime(const SortLinkAttribute *sortLinkHeader);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
@@ -271,6 +271,7 @@ typedef struct tagSwTmrCtrl {
|
||||
struct tagSwTmrCtrl *pstNext; /* Pointer to the next software timer */
|
||||
UINT8 ucState; /* Software timer state */
|
||||
UINT8 ucMode; /* Software timer mode */
|
||||
UINT8 ucOverrun; /* Times that a software timer repeats timing */
|
||||
#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
|
||||
UINT8 ucRouses; /* wake up enable */
|
||||
UINT8 ucSensitive; /* align enable */
|
||||
@@ -499,27 +500,7 @@ extern UINT32 OsSwtmrInit(VOID);
|
||||
*/
|
||||
extern UINT32 OsSwtmrGetNextTimeout(VOID);
|
||||
|
||||
/**
|
||||
* @ingroup los_swtmr
|
||||
* @brief Adjust software timer list.
|
||||
*
|
||||
* @par Description:
|
||||
* <ul>
|
||||
* <li>This API is used to adjust software timer list.</li>
|
||||
* </ul>
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>None.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param sleepTime [IN] UINT32 Sleep time.
|
||||
*
|
||||
* @retval UINT32 Sleep time.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_swtmr.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
extern VOID OsSwtmrAdjust(UINT32 sleepTime);
|
||||
extern VOID OsSwtmrResponseTimeReset(UINT64 startTime);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
@@ -1142,25 +1142,6 @@ extern UINT32 LOS_NewTaskIDGet(VOID);
|
||||
*/
|
||||
extern CHAR* LOS_TaskNameGet(UINT32 taskID);
|
||||
|
||||
/* *
|
||||
* @ingroup los_task
|
||||
* @brief: cpu delay.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to cpu delay, no task switching.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param UINT64 [IN] delay times, microseconds.
|
||||
*
|
||||
* @retval: None.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_task.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
extern VOID LOS_UDelay(UINT64 microseconds);
|
||||
|
||||
/* *
|
||||
* @ingroup los_task
|
||||
* @brief: cpu delay.
|
||||
@@ -1779,6 +1760,8 @@ STATIC INLINE LosTaskCB *OsCurrTaskGet(VOID)
|
||||
return g_losTask.runTask;
|
||||
}
|
||||
|
||||
extern VOID LOS_TaskResRecycle(VOID);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
||||
@@ -137,6 +137,8 @@ extern UINT32 g_sysClock;
|
||||
|
||||
#define OS_SYS_NS_PER_SECOND 1000000000
|
||||
|
||||
#define OS_SYS_NS_PER_MS 1000000
|
||||
|
||||
#define OS_SYS_NS_PER_US 1000
|
||||
|
||||
#define OS_CYCLE_PER_TICK (g_sysClock / LOSCFG_BASE_CORE_TICK_PER_SECOND)
|
||||
@@ -249,7 +251,7 @@ typedef struct TagSysTime {
|
||||
UINT8 ucWeek; /**< value 0 - 6 */
|
||||
} SYS_TIME_S;
|
||||
|
||||
VOID OsTickTimerReload(UINT64 responseTime);
|
||||
UINT64 OsTickTimerReload(UINT64 period);
|
||||
|
||||
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
|
||||
VOID OsTickTimerBaseReset(UINT64 currTime);
|
||||
@@ -257,6 +259,8 @@ VOID OsTickTimerBaseReset(UINT64 currTime);
|
||||
|
||||
UINT32 OsTickTimerInit(VOID);
|
||||
|
||||
VOID OsTickSysTimerStartTimeSet(UINT64 currTime);
|
||||
|
||||
/**
|
||||
* @ingroup los_tick
|
||||
* @brief Obtain the number of Ticks.
|
||||
@@ -357,6 +361,63 @@ extern UINT32 LOS_MS2Tick(UINT32 millisec);
|
||||
*/
|
||||
extern UINT32 LOS_TickTimerRegister(const ArchTickTimer *timer, const HWI_PROC_FUNC tickHandler);
|
||||
|
||||
/* *
|
||||
* @ingroup los_task
|
||||
* @brief: cpu delay.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to cpu delay, no task switching.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param UINT64 [IN] delay times, microseconds.
|
||||
*
|
||||
* @retval: None.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_task.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
extern VOID LOS_UDelay(UINT64 microseconds);
|
||||
|
||||
/* *
|
||||
* @ingroup los_task
|
||||
* @brief: cpu delay.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to cpu delay, no task switching.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param UINT32 [IN] delay times, millisecond.
|
||||
*
|
||||
* @retval: None.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_task.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
extern VOID LOS_MDelay(UINT32 millisec);
|
||||
|
||||
/* *
|
||||
* @ingroup los_task
|
||||
* @brief: cpu nanosecond get.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to get the current number of nanoseconds.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param none.
|
||||
*
|
||||
* @retval: None.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_task.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
extern UINT64 LOS_CurrNanosec(VOID);
|
||||
|
||||
/**
|
||||
* @ingroup los_tick
|
||||
* @brief Handle the system tick timeout.
|
||||
@@ -405,6 +466,8 @@ typedef struct TagCpuTick {
|
||||
*/
|
||||
#define OS_SYS_US_PER_SECOND 1000000
|
||||
|
||||
#define OS_SYS_US_PER_MS 1000
|
||||
|
||||
/**
|
||||
* @ingroup los_tick
|
||||
* The maximum length of name.
|
||||
|
||||
@@ -165,7 +165,7 @@ STATIC_INLINE UINT32 OsMuxValidCheck(LosMuxCB *muxPended)
|
||||
}
|
||||
|
||||
if (OS_INT_ACTIVE) {
|
||||
return LOS_ERRNO_MUX_PEND_INTERR;
|
||||
return LOS_ERRNO_MUX_IN_INTERR;
|
||||
}
|
||||
|
||||
if (g_losTaskLock) {
|
||||
@@ -279,6 +279,11 @@ LITE_OS_SEC_TEXT UINT32 LOS_MuxPost(UINT32 muxHandle)
|
||||
OS_RETURN_ERROR(LOS_ERRNO_MUX_INVALID);
|
||||
}
|
||||
|
||||
if (OS_INT_ACTIVE) {
|
||||
LOS_IntRestore(intSave);
|
||||
OS_RETURN_ERROR(LOS_ERRNO_MUX_IN_INTERR);
|
||||
}
|
||||
|
||||
runningTask = (LosTaskCB *)g_losTask.runTask;
|
||||
if ((muxPosted->muxCount == 0) || (muxPosted->owner != runningTask)) {
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
@@ -90,7 +90,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsQueueInit(VOID)
|
||||
Output : queueID --- Queue ID
|
||||
Return : LOS_OK on success or error code on failure
|
||||
*****************************************************************************/
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 LOS_QueueCreate(CHAR *queueName,
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 LOS_QueueCreate(const CHAR *queueName,
|
||||
UINT16 len,
|
||||
UINT32 *queueID,
|
||||
UINT32 flags,
|
||||
@@ -234,9 +234,9 @@ static INLINE VOID OsQueueBufferOperate(LosQueueCB *queueCB, UINT32 operateType,
|
||||
|
||||
if (OS_QUEUE_IS_POINT(operateType)) {
|
||||
if (OS_QUEUE_IS_READ(operateType)) {
|
||||
*(UINT32 *)bufferAddr = *(UINT32 *)(VOID *)queueNode;
|
||||
*(UINTPTR *)bufferAddr = *(UINTPTR *)(VOID *)queueNode;
|
||||
} else {
|
||||
*(UINT32 *)(VOID *)queueNode = *(UINT32 *)bufferAddr; // change to pp when calling OsQueueOperate
|
||||
*(UINTPTR *)(VOID *)queueNode = *(UINTPTR *)bufferAddr;
|
||||
}
|
||||
} else {
|
||||
if (OS_QUEUE_IS_READ(operateType)) {
|
||||
@@ -271,6 +271,10 @@ static INLINE UINT32 OsQueueOperateParamCheck(const LosQueueCB *queueCB, UINT32
|
||||
return LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG;
|
||||
}
|
||||
|
||||
if (*bufferSize >= SECUREC_MEM_MAX_LEN) {
|
||||
return LOS_ERRNO_QUEUE_BUFFER_SIZE_TOO_BIG;
|
||||
}
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "los_sched.h"
|
||||
#include "los_task.h"
|
||||
#include "los_tick.h"
|
||||
#include "los_swtmr.h"
|
||||
#include "los_debug.h"
|
||||
#include "los_hook.h"
|
||||
#if (LOSCFG_KERNEL_PM == 1)
|
||||
@@ -49,6 +50,7 @@ extern "C" {
|
||||
#define OS_SCHED_TIME_SLICES ((LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT * OS_SYS_NS_PER_US) / OS_NS_PER_CYCLE)
|
||||
#define OS_TIME_SLICE_MIN (INT32)((50 * OS_SYS_NS_PER_US) / OS_NS_PER_CYCLE) /* 50us */
|
||||
#define OS_TICK_RESPONSE_TIME_MAX LOSCFG_BASE_CORE_TICK_RESPONSE_MAX
|
||||
#define OS_TICK_RESPONSE_PRECISION (UINT32)((OS_SCHED_MINI_PERIOD * 75) / 100)
|
||||
#if (LOSCFG_BASE_CORE_TICK_RESPONSE_MAX == 0)
|
||||
#error "Must specify the maximum value that tick timer counter supports!"
|
||||
#endif
|
||||
@@ -63,25 +65,7 @@ STATIC UINT32 g_queueBitmap;
|
||||
|
||||
STATIC UINT32 g_schedResponseID = 0;
|
||||
STATIC UINT16 g_tickIntLock = 0;
|
||||
STATIC UINT64 g_tickStartTime = 0;
|
||||
STATIC UINT64 g_schedResponseTime = OS_SCHED_MAX_RESPONSE_TIME;
|
||||
STATIC VOID (*SchedRealSleepTimeSet)(UINT64) = NULL;
|
||||
UINT64 g_sysSchedStartTime = OS_64BIT_MAX;
|
||||
|
||||
STATIC VOID OsSchedSetStartTime(UINT64 currCycle)
|
||||
{
|
||||
g_sysSchedStartTime = currCycle;
|
||||
}
|
||||
|
||||
UINT32 OsSchedRealSleepTimeSet(VOID (*func)(UINT64))
|
||||
{
|
||||
if (func == NULL) {
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
SchedRealSleepTimeSet = func;
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID OsSchedResetSchedResponseTime(UINT64 responseTime)
|
||||
{
|
||||
@@ -101,27 +85,21 @@ STATIC INLINE VOID OsTimeSliceUpdate(LosTaskCB *taskCB, UINT64 currTime)
|
||||
taskCB->startTime = currTime;
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsSchedTickReload(UINT64 nextResponseTime, UINT32 responseID, BOOL isTimeSlice)
|
||||
STATIC INLINE VOID OsSchedSetNextExpireTime(UINT32 responseID, UINT64 taskEndTime)
|
||||
{
|
||||
UINT64 currTime, nextExpireTime;
|
||||
UINT32 usedTime;
|
||||
UINT64 nextResponseTime = 0;
|
||||
BOOL isTimeSlice = FALSE;
|
||||
|
||||
currTime = OsGetCurrSchedTimeCycle();
|
||||
if (g_tickStartTime != 0) {
|
||||
usedTime = currTime - g_tickStartTime;
|
||||
g_tickStartTime = 0;
|
||||
} else {
|
||||
usedTime = 0;
|
||||
UINT64 currTime = OsGetCurrSchedTimeCycle();
|
||||
UINT64 nextExpireTime = OsGetNextExpireTime(currTime, OS_TICK_RESPONSE_PRECISION);
|
||||
/* The response time of the task time slice is aligned to the next response time in the delay queue */
|
||||
if ((nextExpireTime > taskEndTime) && ((nextExpireTime - taskEndTime) > OS_SCHED_MINI_PERIOD)) {
|
||||
nextExpireTime = taskEndTime;
|
||||
isTimeSlice = TRUE;
|
||||
}
|
||||
|
||||
if ((nextResponseTime > usedTime) && ((nextResponseTime - usedTime) > OS_TICK_RESPONSE_PRECISION)) {
|
||||
nextResponseTime -= usedTime;
|
||||
} else {
|
||||
nextResponseTime = OS_TICK_RESPONSE_PRECISION;
|
||||
}
|
||||
|
||||
nextExpireTime = currTime + nextResponseTime;
|
||||
if (nextExpireTime >= g_schedResponseTime) {
|
||||
if ((g_schedResponseTime <= nextExpireTime) ||
|
||||
((g_schedResponseTime - nextExpireTime) < OS_TICK_RESPONSE_PRECISION)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -131,46 +109,15 @@ STATIC INLINE VOID OsSchedTickReload(UINT64 nextResponseTime, UINT32 responseID,
|
||||
} else {
|
||||
g_schedResponseID = OS_INVALID;
|
||||
}
|
||||
g_schedResponseTime = nextExpireTime;
|
||||
OsTickTimerReload(nextResponseTime);
|
||||
|
||||
nextResponseTime = nextExpireTime - currTime;
|
||||
if (nextResponseTime < OS_TICK_RESPONSE_PRECISION) {
|
||||
nextResponseTime = OS_TICK_RESPONSE_PRECISION;
|
||||
}
|
||||
g_schedResponseTime = currTime + OsTickTimerReload(nextResponseTime);
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsSchedSetNextExpireTime(UINT64 startTime, UINT32 responseID, UINT64 taskEndTime)
|
||||
{
|
||||
UINT64 nextExpireTime;
|
||||
UINT64 nextResponseTime = 0;
|
||||
BOOL isTimeSlice = FALSE;
|
||||
|
||||
nextExpireTime = OsGetNextExpireTime(startTime);
|
||||
/* The response time of the task time slice is aligned to the next response time in the delay queue */
|
||||
if ((nextExpireTime > taskEndTime) && ((nextExpireTime - taskEndTime) > OS_SCHED_MINI_PERIOD)) {
|
||||
nextExpireTime = taskEndTime;
|
||||
isTimeSlice = TRUE;
|
||||
}
|
||||
|
||||
if ((g_schedResponseTime > nextExpireTime) &&
|
||||
((g_schedResponseTime - nextExpireTime) >= OS_TICK_RESPONSE_PRECISION)) {
|
||||
nextResponseTime = nextExpireTime - startTime;
|
||||
if (nextResponseTime > OS_TICK_RESPONSE_TIME_MAX) {
|
||||
if (SchedRealSleepTimeSet != NULL) {
|
||||
SchedRealSleepTimeSet(nextResponseTime);
|
||||
}
|
||||
nextResponseTime = OS_TICK_RESPONSE_TIME_MAX;
|
||||
}
|
||||
|
||||
if (SchedRealSleepTimeSet != NULL) {
|
||||
SchedRealSleepTimeSet(0);
|
||||
}
|
||||
} else {
|
||||
/* There is no point earlier than the current expiration date */
|
||||
g_tickStartTime = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
OsSchedTickReload(nextResponseTime, responseID, isTimeSlice);
|
||||
}
|
||||
|
||||
VOID OsSchedUpdateExpireTime(UINT64 startTime)
|
||||
VOID OsSchedUpdateExpireTime(VOID)
|
||||
{
|
||||
UINT64 endTime;
|
||||
BOOL isPmMode = FALSE;
|
||||
@@ -185,11 +132,11 @@ VOID OsSchedUpdateExpireTime(UINT64 startTime)
|
||||
#endif
|
||||
if ((runTask->taskID != g_idleTaskID) && !isPmMode) {
|
||||
INT32 timeSlice = (runTask->timeSlice <= OS_TIME_SLICE_MIN) ? OS_SCHED_TIME_SLICES : runTask->timeSlice;
|
||||
endTime = startTime + timeSlice;
|
||||
endTime = runTask->startTime + timeSlice;
|
||||
} else {
|
||||
endTime = OS_SCHED_MAX_RESPONSE_TIME - OS_TICK_RESPONSE_PRECISION;
|
||||
}
|
||||
OsSchedSetNextExpireTime(startTime, runTask->taskID, endTime);
|
||||
OsSchedSetNextExpireTime(runTask->taskID, endTime);
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsSchedPriQueueEnHead(LOS_DL_LIST *priqueueItem, UINT32 priority)
|
||||
@@ -468,6 +415,11 @@ UINT32 OsTaskNextSwitchTimeGet(VOID)
|
||||
return ticks;
|
||||
}
|
||||
|
||||
UINT64 OsSchedGetNextExpireTime(UINT64 startTime)
|
||||
{
|
||||
return OsGetNextExpireTime(startTime, OS_TICK_RESPONSE_PRECISION);
|
||||
}
|
||||
|
||||
UINT32 OsSchedInit(VOID)
|
||||
{
|
||||
UINT16 pri;
|
||||
@@ -503,6 +455,8 @@ LosTaskCB *OsGetTopTask(VOID)
|
||||
|
||||
VOID OsSchedStart(VOID)
|
||||
{
|
||||
PRINTK("Entering scheduler\n");
|
||||
|
||||
(VOID)LOS_IntLock();
|
||||
LosTaskCB *newTask = OsGetTopTask();
|
||||
|
||||
@@ -510,18 +464,19 @@ VOID OsSchedStart(VOID)
|
||||
g_losTask.newTask = newTask;
|
||||
g_losTask.runTask = g_losTask.newTask;
|
||||
|
||||
/* Initialize the schedule timeline and enable scheduling */
|
||||
g_taskScheduled = TRUE;
|
||||
OsSchedSetStartTime(LOS_SysCycleGet());
|
||||
|
||||
newTask->startTime = OsGetCurrSchedTimeCycle();
|
||||
OsSchedTaskDeQueue(newTask);
|
||||
|
||||
OsTickSysTimerStartTimeSet(newTask->startTime);
|
||||
|
||||
OsSwtmrResponseTimeReset(newTask->startTime);
|
||||
|
||||
/* Initialize the schedule timeline and enable scheduling */
|
||||
g_taskScheduled = TRUE;
|
||||
|
||||
g_schedResponseTime = OS_SCHED_MAX_RESPONSE_TIME;
|
||||
g_schedResponseID = OS_INVALID;
|
||||
OsSchedSetNextExpireTime(newTask->startTime, newTask->taskID, newTask->startTime + newTask->timeSlice);
|
||||
|
||||
PRINTK("Entering scheduler\n");
|
||||
OsSchedSetNextExpireTime(newTask->taskID, newTask->startTime + newTask->timeSlice);
|
||||
}
|
||||
|
||||
BOOL OsSchedTaskSwitch(VOID)
|
||||
@@ -563,7 +518,7 @@ BOOL OsSchedTaskSwitch(VOID)
|
||||
if (g_schedResponseID == runTask->taskID) {
|
||||
g_schedResponseTime = OS_SCHED_MAX_RESPONSE_TIME;
|
||||
}
|
||||
OsSchedSetNextExpireTime(newTask->startTime, newTask->taskID, endTime);
|
||||
OsSchedSetNextExpireTime(newTask->taskID, endTime);
|
||||
|
||||
return isTaskSwitch;
|
||||
}
|
||||
@@ -595,7 +550,7 @@ VOID LOS_SchedTickHandler(VOID)
|
||||
}
|
||||
|
||||
UINT32 intSave = LOS_IntLock();
|
||||
g_tickStartTime = OsGetCurrSchedTimeCycle();
|
||||
UINT64 tickStartTime = OsGetCurrSchedTimeCycle();
|
||||
if (g_schedResponseID == OS_INVALID) {
|
||||
g_tickIntLock++;
|
||||
if (g_swtmrScan != NULL) {
|
||||
@@ -606,14 +561,14 @@ VOID LOS_SchedTickHandler(VOID)
|
||||
g_tickIntLock--;
|
||||
}
|
||||
|
||||
OsTimeSliceUpdate(g_losTask.runTask, g_tickStartTime);
|
||||
OsTimeSliceUpdate(g_losTask.runTask, tickStartTime);
|
||||
g_losTask.runTask->startTime = OsGetCurrSchedTimeCycle();
|
||||
|
||||
g_schedResponseTime = OS_SCHED_MAX_RESPONSE_TIME;
|
||||
if (LOS_CHECK_SCHEDULE) {
|
||||
ArchTaskSchedule();
|
||||
} else {
|
||||
OsSchedUpdateExpireTime(g_losTask.runTask->startTime);
|
||||
OsSchedUpdateExpireTime();
|
||||
}
|
||||
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
@@ -39,8 +39,8 @@ extern "C" {
|
||||
#endif
|
||||
#endif /* __cplusplus */
|
||||
|
||||
STATIC SortLinkAttribute g_taskSortLink;
|
||||
STATIC SortLinkAttribute g_swtmrSortLink;
|
||||
SortLinkAttribute g_taskSortLink;
|
||||
SortLinkAttribute g_swtmrSortLink;
|
||||
|
||||
UINT32 OsSortLinkInit(SortLinkAttribute *sortLinkHeader)
|
||||
{
|
||||
@@ -78,29 +78,6 @@ STATIC INLINE VOID OsAddNode2SortLink(SortLinkAttribute *sortLinkHeader, SortLin
|
||||
} while (1);
|
||||
}
|
||||
|
||||
VOID OsDeleteNodeSortLink(SortLinkList *sortList)
|
||||
{
|
||||
LOS_ListDelete(&sortList->sortLinkNode);
|
||||
SET_SORTLIST_VALUE(sortList, OS_SORT_LINK_INVALID_TIME);
|
||||
}
|
||||
|
||||
STATIC INLINE UINT64 OsGetSortLinkNextExpireTime(SortLinkAttribute *sortHeader, UINT64 startTime)
|
||||
{
|
||||
LOS_DL_LIST *head = &sortHeader->sortLink;
|
||||
LOS_DL_LIST *list = head->pstNext;
|
||||
|
||||
if (LOS_ListEmpty(head)) {
|
||||
return OS_SCHED_MAX_RESPONSE_TIME - OS_TICK_RESPONSE_PRECISION;
|
||||
}
|
||||
|
||||
SortLinkList *listSorted = LOS_DL_LIST_ENTRY(list, SortLinkList, sortLinkNode);
|
||||
if (listSorted->responseTime <= (startTime + OS_TICK_RESPONSE_PRECISION)) {
|
||||
return startTime + OS_TICK_RESPONSE_PRECISION;
|
||||
}
|
||||
|
||||
return listSorted->responseTime;
|
||||
}
|
||||
|
||||
VOID OsAdd2SortLink(SortLinkList *node, UINT64 startTime, UINT32 waitTicks, SortLinkType type)
|
||||
{
|
||||
UINT32 intSave;
|
||||
@@ -144,30 +121,16 @@ SortLinkAttribute *OsGetSortLinkAttribute(SortLinkType type)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
UINT64 OsGetNextExpireTime(UINT64 startTime)
|
||||
{
|
||||
UINT32 intSave;
|
||||
SortLinkAttribute *taskHeader = &g_taskSortLink;
|
||||
SortLinkAttribute *swtmrHeader = &g_swtmrSortLink;
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
UINT64 taskExpirTime = OsGetSortLinkNextExpireTime(taskHeader, startTime);
|
||||
UINT64 swtmrExpirTime = OsGetSortLinkNextExpireTime(swtmrHeader, startTime);
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
return (taskExpirTime < swtmrExpirTime) ? taskExpirTime : swtmrExpirTime;
|
||||
}
|
||||
|
||||
UINT32 OsSortLinkGetTargetExpireTime(UINT64 currTime, const SortLinkList *targetSortList)
|
||||
UINT64 OsSortLinkGetTargetExpireTime(UINT64 currTime, const SortLinkList *targetSortList)
|
||||
{
|
||||
if (currTime >= targetSortList->responseTime) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (UINT32)(((targetSortList->responseTime - currTime) * LOSCFG_BASE_CORE_TICK_PER_SECOND) / g_sysClock);
|
||||
return (targetSortList->responseTime - currTime);
|
||||
}
|
||||
|
||||
UINT32 OsSortLinkGetNextExpireTime(const SortLinkAttribute *sortLinkHeader)
|
||||
UINT64 OsSortLinkGetNextExpireTime(const SortLinkAttribute *sortLinkHeader)
|
||||
{
|
||||
LOS_DL_LIST *head = (LOS_DL_LIST *)&sortLinkHeader->sortLink;
|
||||
|
||||
|
||||
@@ -238,7 +238,7 @@ LITE_OS_SEC_TEXT VOID OsSwtmrStart(UINT64 currTime, SWTMR_CTRL_S *swtmr)
|
||||
}
|
||||
#endif
|
||||
OsAdd2SortLink(&swtmr->stSortList, swtmr->startTime, swtmr->uwInterval, OS_SORT_LINK_SWTMR);
|
||||
OsSchedUpdateExpireTime(currTime);
|
||||
OsSchedUpdateExpireTime();
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
@@ -273,7 +273,8 @@ LITE_OS_SEC_TEXT VOID OsSwtmrStop(SWTMR_CTRL_S *swtmr)
|
||||
OsDeleteSortLink(&swtmr->stSortList);
|
||||
swtmr->ucState = OS_SWTMR_STATUS_CREATED;
|
||||
|
||||
OsSchedUpdateExpireTime(OsGetCurrSchedTimeCycle());
|
||||
swtmr->ucOverrun = 0;
|
||||
OsSchedUpdateExpireTime();
|
||||
#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
|
||||
g_swtmrAlignID[swtmr->usTimerID % LOSCFG_BASE_CORE_SWTMR_LIMIT].isAligned = 0;
|
||||
#endif
|
||||
@@ -289,6 +290,7 @@ STATIC VOID OsSwtmrTimeoutHandle(UINT64 currTime, SWTMR_CTRL_S *swtmr)
|
||||
|
||||
(VOID)LOS_QueueWriteCopy(g_swtmrHandlerQueue, &swtmrHandler, sizeof(SwtmrHandlerItem), LOS_NO_WAIT);
|
||||
if (swtmr->ucMode == LOS_SWTMR_MODE_PERIOD) {
|
||||
swtmr->ucOverrun++;
|
||||
OsSwtmrStart(currTime, swtmr);
|
||||
} else if (swtmr->ucMode == LOS_SWTMR_MODE_NO_SELFDELETE) {
|
||||
swtmr->ucState = OS_SWTMR_STATUS_CREATED;
|
||||
@@ -325,6 +327,24 @@ STATIC BOOL OsSwtmrScan(VOID)
|
||||
return needSchedule;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT VOID OsSwtmrResponseTimeReset(UINT64 startTime)
|
||||
{
|
||||
LOS_DL_LIST *listHead = &g_swtmrSortLinkList->sortLink;
|
||||
LOS_DL_LIST *listNext = listHead->pstNext;
|
||||
|
||||
while (listNext != listHead) {
|
||||
SortLinkList *sortList = LOS_DL_LIST_ENTRY(listNext, SortLinkList, sortLinkNode);
|
||||
SWTMR_CTRL_S *swtmr = LOS_DL_LIST_ENTRY(sortList, SWTMR_CTRL_S, stSortList);
|
||||
OsDeleteNodeSortLink(sortList);
|
||||
#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
|
||||
g_swtmrAlignID[swtmr->usTimerID % LOSCFG_BASE_CORE_SWTMR_LIMIT].isAligned = 0;
|
||||
#endif
|
||||
swtmr->startTime = startTime;
|
||||
OsSwtmrStart(startTime, swtmr);
|
||||
listNext = listNext->pstNext;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
Function : OsSwtmrGetNextTimeout
|
||||
Description : Get next timeout
|
||||
@@ -335,14 +355,23 @@ Return : Count of the Timer list
|
||||
LITE_OS_SEC_TEXT UINT32 OsSwtmrGetNextTimeout(VOID)
|
||||
{
|
||||
UINT32 intSave = LOS_IntLock();
|
||||
UINT32 ticks = OsSortLinkGetNextExpireTime(g_swtmrSortLinkList);
|
||||
UINT64 time = OsSortLinkGetNextExpireTime(g_swtmrSortLinkList);
|
||||
LOS_IntRestore(intSave);
|
||||
return ticks;
|
||||
time = time / OS_CYCLE_PER_TICK;
|
||||
if (time > OS_NULL_INT) {
|
||||
time = OS_NULL_INT;
|
||||
}
|
||||
return time;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT UINT32 OsSwtmrTimeGet(const SWTMR_CTRL_S *swtmr)
|
||||
{
|
||||
return OsSortLinkGetTargetExpireTime(OsGetCurrSchedTimeCycle(), &swtmr->stSortList);
|
||||
UINT64 time = OsSortLinkGetTargetExpireTime(OsGetCurrSchedTimeCycle(), &swtmr->stSortList);
|
||||
time = time / OS_CYCLE_PER_TICK;
|
||||
if (time > OS_NULL_INT) {
|
||||
time = OS_NULL_INT;
|
||||
}
|
||||
return (UINT32)time;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
@@ -492,6 +521,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_SwtmrCreate(UINT32 interval,
|
||||
swtmr->ucSensitive = sensitive;
|
||||
#endif
|
||||
swtmr->ucState = OS_SWTMR_STATUS_CREATED;
|
||||
swtmr->ucOverrun = 0;
|
||||
*swtmrId = swtmr->usTimerID;
|
||||
SET_SORTLIST_VALUE(&swtmr->stSortList, OS_SORT_LINK_INVALID_TIME);
|
||||
OsHookCall(LOS_HOOK_TYPE_SWTMR_CREATE, swtmr);
|
||||
|
||||
@@ -1486,19 +1486,7 @@ LITE_OS_SEC_TEXT_MINOR VOID LOS_Msleep(UINT32 mSecs)
|
||||
(VOID)LOS_TaskDelay(interval);
|
||||
}
|
||||
|
||||
VOID LOS_UDelay(UINT64 microseconds)
|
||||
VOID LOS_TaskResRecycle(VOID)
|
||||
{
|
||||
UINT64 endTime;
|
||||
|
||||
if (microseconds == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
endTime = (microseconds / OS_SYS_US_PER_SECOND) * g_sysClock +
|
||||
(microseconds % OS_SYS_US_PER_SECOND) * g_sysClock / OS_SYS_US_PER_SECOND;
|
||||
endTime = LOS_SysCycleGet() + endTime;
|
||||
while (LOS_SysCycleGet() < endTime) {
|
||||
}
|
||||
|
||||
return;
|
||||
OsRecyleFinishedTask();
|
||||
}
|
||||
|
||||
@@ -36,13 +36,15 @@
|
||||
#include "los_swtmr.h"
|
||||
#include "los_sched.h"
|
||||
#include "los_debug.h"
|
||||
#include "stdint.h"
|
||||
|
||||
LITE_OS_SEC_BSS STATIC ArchTickTimer *g_sysTickTimer = NULL;
|
||||
LITE_OS_SEC_BSS UINT32 g_ticksPerSec;
|
||||
LITE_OS_SEC_BSS UINT32 g_uwCyclePerSec;
|
||||
LITE_OS_SEC_BSS UINT32 g_cyclesPerTick;
|
||||
LITE_OS_SEC_BSS UINT32 g_sysClock;
|
||||
LITE_OS_SEC_BSS BOOL g_sysTimerIsInit = FALSE;
|
||||
LITE_OS_SEC_BSS STATIC BOOL g_sysTimerIsInit = FALSE;
|
||||
LITE_OS_SEC_BSS STATIC UINT64 g_tickTimerStartTime;
|
||||
|
||||
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
|
||||
STATIC UINT64 g_tickTimerBase;
|
||||
@@ -72,12 +74,12 @@ LITE_OS_SEC_TEXT VOID OsTickHandler(VOID)
|
||||
LOS_SchedTickHandler();
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT VOID OsTickTimerReload(UINT64 responseTime)
|
||||
LITE_OS_SEC_TEXT UINT64 OsTickTimerReload(UINT64 period)
|
||||
{
|
||||
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
|
||||
g_tickTimerBase = LOS_SysCycleGet();
|
||||
#endif
|
||||
g_sysTickTimer->reload(responseTime);
|
||||
return g_sysTickTimer->reload(period);
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT UINT64 LOS_SysCycleGet(VOID)
|
||||
@@ -120,6 +122,10 @@ STATIC UINT32 TickTimerCheck(const ArchTickTimer *tick)
|
||||
return LOS_ERRNO_TICK_CFG_INVALID;
|
||||
}
|
||||
|
||||
if (tick->periodMax == 0) {
|
||||
return LOS_ERRNO_TICK_CFG_INVALID;
|
||||
}
|
||||
|
||||
if ((tick->init == NULL) || (tick->reload == NULL) ||
|
||||
(tick->lock == NULL) || (tick->unlock == NULL) ||
|
||||
(tick->getCycle == NULL)) {
|
||||
@@ -172,6 +178,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsTickTimerInit(VOID)
|
||||
g_sysTimerIsInit = TRUE;
|
||||
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
@@ -223,6 +230,11 @@ LITE_OS_SEC_TEXT UINT32 LOS_TickTimerRegister(const ArchTickTimer *timer, const
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_MINOR VOID OsTickSysTimerStartTimeSet(UINT64 currTime)
|
||||
{
|
||||
g_tickTimerStartTime = currTime;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
Function : LOS_TickCountGet
|
||||
Description : get current tick
|
||||
@@ -232,7 +244,7 @@ Return : current tick
|
||||
*****************************************************************************/
|
||||
LITE_OS_SEC_TEXT_MINOR UINT64 LOS_TickCountGet(VOID)
|
||||
{
|
||||
return LOS_SysCycleGet() / OS_CYCLE_PER_TICK;
|
||||
return (LOS_SysCycleGet() - g_tickTimerStartTime) / OS_CYCLE_PER_TICK;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
@@ -336,3 +348,58 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsCpuTick2US(CpuTick *cpuTick, UINT32 *usHi, UINT32
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
Function : LOS_MS2Tick
|
||||
Description : get current nanoseconds
|
||||
Input : None
|
||||
Output : None
|
||||
Return : nanoseconds
|
||||
*****************************************************************************/
|
||||
UINT64 LOS_CurrNanosec(VOID)
|
||||
{
|
||||
UINT64 nanos;
|
||||
nanos = LOS_SysCycleGet() * (OS_SYS_NS_PER_SECOND / OS_SYS_NS_PER_MS) / (g_sysClock / OS_SYS_NS_PER_MS);
|
||||
return nanos;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
Function : LOS_UDelay
|
||||
Description : cpu delay function
|
||||
Input : microseconds ---------- microseconds
|
||||
Output : None
|
||||
Return : None
|
||||
*****************************************************************************/
|
||||
VOID LOS_UDelay(UINT64 microseconds)
|
||||
{
|
||||
UINT64 endTime;
|
||||
|
||||
if (microseconds == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
endTime = (microseconds / OS_SYS_US_PER_SECOND) * g_sysClock +
|
||||
(microseconds % OS_SYS_US_PER_SECOND) * g_sysClock / OS_SYS_US_PER_SECOND;
|
||||
endTime = LOS_SysCycleGet() + endTime;
|
||||
while (LOS_SysCycleGet() < endTime) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
Function : LOS_MDelay
|
||||
Description : cpu delay function
|
||||
Input : millisec ---------- milliseconds
|
||||
Output : None
|
||||
Return : None
|
||||
*****************************************************************************/
|
||||
VOID LOS_MDelay(UINT32 millisec)
|
||||
{
|
||||
UINT32 delayUs = (UINT32_MAX / OS_SYS_US_PER_MS) * OS_SYS_US_PER_MS;
|
||||
while (millisec > UINT32_MAX / OS_SYS_US_PER_MS) {
|
||||
LOS_UDelay(delayUs);
|
||||
millisec -= (UINT32_MAX / OS_SYS_US_PER_MS);
|
||||
}
|
||||
LOS_UDelay(millisec * OS_SYS_US_PER_MS);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1037,24 +1037,24 @@ STATIC UINT32 OsMemPoolDelete(VOID *pool)
|
||||
UINT32 LOS_MemInit(VOID *pool, UINT32 size)
|
||||
{
|
||||
if ((pool == NULL) || (size <= OS_MEM_MIN_POOL_SIZE)) {
|
||||
return OS_ERROR;
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
if (((UINTPTR)pool & (OS_MEM_ALIGN_SIZE - 1)) || \
|
||||
(size & (OS_MEM_ALIGN_SIZE - 1))) {
|
||||
PRINT_ERR("LiteOS heap memory address or size configured not aligned:address:0x%x,size:0x%x, alignsize:%d\n", \
|
||||
(UINTPTR)pool, size, OS_MEM_ALIGN_SIZE);
|
||||
return OS_ERROR;
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
if (OsMemPoolInit(pool, size)) {
|
||||
return OS_ERROR;
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
#if (LOSCFG_MEM_MUL_POOL == 1)
|
||||
if (OsMemPoolAdd(pool, size)) {
|
||||
(VOID)OsMemPoolDeinit(pool);
|
||||
return OS_ERROR;
|
||||
return LOS_NOK;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1067,11 +1067,11 @@ UINT32 LOS_MemInit(VOID *pool, UINT32 size)
|
||||
UINT32 LOS_MemDeInit(VOID *pool)
|
||||
{
|
||||
if (pool == NULL) {
|
||||
return OS_ERROR;
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
if (OsMemPoolDelete(pool)) {
|
||||
return OS_ERROR;
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
OsMemPoolDeinit(pool);
|
||||
@@ -1593,11 +1593,11 @@ UINT32 LOS_MemFreeByTaskID(VOID *pool, UINT32 taskID)
|
||||
{
|
||||
UINT32 args[2] = { taskID, (UINT32)(UINTPTR)pool };
|
||||
if (pool == NULL) {
|
||||
return OS_ERROR;
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
if (taskID >= LOSCFG_BASE_CORE_TSK_LIMIT) {
|
||||
return OS_ERROR;
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
OsAllMemNodeDoHandle(pool, MemNodeFreeByTaskIDHandle, (VOID *)args);
|
||||
|
||||
@@ -64,6 +64,11 @@ static_library("test_hwi") {
|
||||
"it_los_hwi_032.c",
|
||||
"it_los_hwi_033.c",
|
||||
"it_los_hwi_034.c",
|
||||
"it_los_hwi_036.c",
|
||||
"it_los_hwi_037.c",
|
||||
"it_los_hwi_038.c",
|
||||
"it_los_hwi_039.c",
|
||||
"it_los_hwi_040.c",
|
||||
"llt_los_hwi_035.c",
|
||||
]
|
||||
|
||||
|
||||
@@ -57,6 +57,11 @@ VOID ItSuiteLosHwi()
|
||||
ItLosHwi030();
|
||||
ItLosHwi031();
|
||||
ItLosHwi034();
|
||||
ItLosHwi036();
|
||||
ItLosHwi037();
|
||||
ItLosHwi038();
|
||||
ItLosHwi039();
|
||||
ItLosHwi040();
|
||||
#if (LOS_KERNEL_MULTI_HWI_TEST == 1)
|
||||
ItLosHwi003();
|
||||
ItLosHwi005();
|
||||
|
||||
@@ -73,6 +73,12 @@ extern VOID ItLosHwi030(VOID);
|
||||
extern VOID ItLosHwi031(VOID);
|
||||
extern VOID ItLosHwi034(VOID);
|
||||
extern VOID LltLosHwi035(VOID);
|
||||
extern VOID ItLosHwi036(VOID);
|
||||
extern VOID ItLosHwi037(VOID);
|
||||
extern VOID ItLosHwi038(VOID);
|
||||
extern VOID ItLosHwi039(VOID);
|
||||
extern VOID ItLosHwi040(VOID);
|
||||
|
||||
|
||||
#if (LOS_KERNEL_MULTI_HWI_TEST == 1)
|
||||
extern VOID ItLosHwi003(VOID);
|
||||
|
||||
75
testsuites/sample/kernel/hwi/it_los_hwi_036.c
Normal file
75
testsuites/sample/kernel/hwi/it_los_hwi_036.c
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2022 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_hwi.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 intSave;
|
||||
UINT32 deltaTicks;
|
||||
UINT64 timeRecordNS;
|
||||
UINT64 timeUpdateNS;
|
||||
UINT64 delayMs = 10; // delay 10 MS
|
||||
UINT32 deltaMs;
|
||||
UINT64 delayTicks;
|
||||
UINT32 loop = 10; // loop 10 time
|
||||
delayTicks = delayMs * LOSCFG_BASE_CORE_TICK_PER_SECOND / OS_SYS_MS_PER_SECOND;
|
||||
|
||||
for (int i = 0; i <= loop; i++, delayTicks++) {
|
||||
timeRecordNS = LOS_CurrNanosec();
|
||||
LOS_TaskDelay(delayTicks);
|
||||
timeUpdateNS = LOS_CurrNanosec();
|
||||
deltaTicks = ((timeUpdateNS - timeRecordNS) * LOSCFG_BASE_CORE_TICK_PER_SECOND / OS_SYS_NS_PER_SECOND);
|
||||
|
||||
if (deltaTicks >= (delayTicks - 1) && deltaTicks <= (delayTicks + 1)) {
|
||||
continue;
|
||||
} else {
|
||||
ICUNIT_ASSERT_EQUAL(deltaTicks, delayTicks, deltaTicks);
|
||||
}
|
||||
}
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
for (int i = 1; i <= loop; i++) {
|
||||
timeRecordNS = LOS_CurrNanosec();
|
||||
LOS_MDelay(i);
|
||||
timeUpdateNS = LOS_CurrNanosec();
|
||||
deltaMs = (timeUpdateNS - timeRecordNS) / OS_SYS_NS_PER_MS;
|
||||
ICUNIT_ASSERT_EQUAL(deltaMs, i, deltaMs);
|
||||
}
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosHwi036(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("ItLosHwi036", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL3, TEST_PRESSURE);
|
||||
}
|
||||
94
kal/libc/newlib/porting/src/pthread.c → testsuites/sample/kernel/hwi/it_los_hwi_037.c
Executable file → Normal file
94
kal/libc/newlib/porting/src/pthread.c → testsuites/sample/kernel/hwi/it_los_hwi_037.c
Executable file → Normal file
@@ -1,36 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2022 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 <pthread.h>
|
||||
|
||||
int pthread_equal(pthread_t __t1, pthread_t __t2)
|
||||
{
|
||||
return (int)(__t1 == __t2);
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2022-2022 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_hwi.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 intSave;
|
||||
UINT64 timeRecordNS;
|
||||
UINT64 timeUpdateNS;
|
||||
UINT32 deltaMs;
|
||||
UINT32 loop = 10; // loop 10 time
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
for (int i = 1; i <= loop; i++) {
|
||||
timeRecordNS = LOS_CurrNanosec();
|
||||
LOS_MDelay(i);
|
||||
timeUpdateNS = LOS_CurrNanosec();
|
||||
deltaMs = (timeUpdateNS - timeRecordNS) / OS_SYS_NS_PER_MS;
|
||||
ICUNIT_ASSERT_EQUAL(deltaMs, i, deltaMs);
|
||||
}
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosHwi037(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("ItLosHwi037", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL3, TEST_PRESSURE);
|
||||
}
|
||||
60
testsuites/sample/kernel/hwi/it_los_hwi_038.c
Normal file
60
testsuites/sample/kernel/hwi/it_los_hwi_038.c
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2022 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_hwi.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 deltaTicks;
|
||||
UINT64 timeRecordNS;
|
||||
UINT64 timeUpdateNS;
|
||||
UINT64 tickRecord;
|
||||
UINT64 tickUpdate;
|
||||
UINT32 loop = 10; // loop 10 time.
|
||||
|
||||
timeRecordNS = LOS_CurrNanosec();
|
||||
tickRecord = LOS_TickCountGet();
|
||||
LOS_TaskDelay(1);
|
||||
for (int i = 1; i <= loop; i++) {
|
||||
LOS_MDelay(i * 10); // i * 10, Set delay time.
|
||||
timeUpdateNS = LOS_CurrNanosec();
|
||||
tickUpdate = LOS_TickCountGet();
|
||||
deltaTicks = (UINT32)((timeUpdateNS - timeRecordNS) * LOSCFG_BASE_CORE_TICK_PER_SECOND / OS_SYS_NS_PER_SECOND);
|
||||
ICUNIT_ASSERT_WITHIN_EQUAL(deltaTicks, tickUpdate - tickRecord - 1, tickUpdate - tickRecord + 1, deltaTicks);
|
||||
}
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosHwi038(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("ItLosHwi038", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL3, TEST_PRESSURE);
|
||||
}
|
||||
72
testsuites/sample/kernel/hwi/it_los_hwi_039.c
Executable file
72
testsuites/sample/kernel/hwi/it_los_hwi_039.c
Executable file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2022 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_hwi.h"
|
||||
|
||||
static VOID HwiF01(VOID)
|
||||
{
|
||||
TestHwiClear(HWI_NUM_TEST);
|
||||
g_testCount++;
|
||||
|
||||
EXIT:
|
||||
return;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
HWI_PRIOR_T hwiPrio = 2;
|
||||
HWI_MODE_T mode = 0;
|
||||
HWI_ARG_T arg = 0;
|
||||
|
||||
g_testCount = 0;
|
||||
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, arg);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
LOS_HwiDisable(HWI_NUM_TEST);
|
||||
TestHwiTrigger(HWI_NUM_TEST);
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT); // Compare wiht the expected value 0.
|
||||
|
||||
LOS_HwiEnable(HWI_NUM_TEST);
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); // Compare wiht the expected value 1.
|
||||
|
||||
TestHwiDelete(HWI_NUM_TEST);
|
||||
|
||||
return LOS_OK;
|
||||
|
||||
EXIT:
|
||||
TestHwiDelete(HWI_NUM_TEST);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosHwi039(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("ItLosHwi039", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL3, TEST_PRESSURE);
|
||||
}
|
||||
168
testsuites/sample/kernel/hwi/it_los_hwi_040.c
Executable file
168
testsuites/sample/kernel/hwi/it_los_hwi_040.c
Executable file
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2022 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_hwi.h"
|
||||
|
||||
static UINT32 TesttriggerIrq(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
g_testCount++;
|
||||
printf("This is TesttriggerIrq\n");
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
static UINT32 TestclearIrq(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
g_testCount++;
|
||||
printf("This is TestclearIrq\n");
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
static UINT32 TestenableIrq(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
g_testCount++;
|
||||
printf("This is TestenableIrq\n");
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
static UINT32 TestdisableIrq(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
g_testCount++;
|
||||
printf("This is TestdisableIrq\n");
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
static UINT32 TestsetIrqPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
||||
{
|
||||
g_testCount++;
|
||||
printf("This is TestsetIrqPriority\n");
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
static UINT32 TestgetCurIrqNum(VOID)
|
||||
{
|
||||
g_testCount++;
|
||||
printf("This is TestgetCurIrqNum\n");
|
||||
return HWI_NUM_TEST;
|
||||
}
|
||||
|
||||
static VOID HwiF01(VOID)
|
||||
{
|
||||
TestHwiClear(HWI_NUM_TEST);
|
||||
g_testCount++;
|
||||
return;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret = LOS_OK;
|
||||
UINT32 irqNum = 0;
|
||||
HWI_PRIOR_T hwiPrio = 2; // 2, Set hwi priority.
|
||||
HWI_MODE_T mode = 0;
|
||||
HWI_ARG_T arg = 0;
|
||||
HwiControllerOps *ops = NULL;
|
||||
HwiControllerOps *opsBac = (HwiControllerOps *)malloc(sizeof(HwiControllerOps));
|
||||
if (opsBac == NULL) {
|
||||
ret = LOS_NOK;
|
||||
}
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
(VOID)memset_s(opsBac, sizeof(HwiControllerOps), 0, sizeof(HwiControllerOps));
|
||||
|
||||
g_testCount = 0;
|
||||
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, arg);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_HwiTrigger(LOSCFG_PLATFORM_HWI_LIMIT + 1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, OS_ERRNO_HWI_NUM_INVALID, ret);
|
||||
ret = LOS_HwiEnable(LOSCFG_PLATFORM_HWI_LIMIT + 1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, OS_ERRNO_HWI_NUM_INVALID, ret);
|
||||
ret = LOS_HwiDisable(LOSCFG_PLATFORM_HWI_LIMIT + 1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, OS_ERRNO_HWI_NUM_INVALID, ret);
|
||||
ret = LOS_HwiClear(LOSCFG_PLATFORM_HWI_LIMIT + 1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, OS_ERRNO_HWI_NUM_INVALID, ret);
|
||||
hwiPrio = 3; // 3, Set hwi priority.
|
||||
ret = LOS_HwiSetPriority(LOSCFG_PLATFORM_HWI_LIMIT + 1, hwiPrio);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ops = LOS_HwiOpsGet();
|
||||
(VOID)memcpy_s(opsBac, sizeof(HwiControllerOps), ops, sizeof(HwiControllerOps));
|
||||
ops->triggerIrq = TesttriggerIrq;
|
||||
ops->enableIrq = TestenableIrq;
|
||||
ops->disableIrq = TestdisableIrq;
|
||||
ops->setIrqPriority = TestsetIrqPriority;
|
||||
ops->getCurIrqNum = TestgetCurIrqNum;
|
||||
ops->clearIrq = TestclearIrq;
|
||||
|
||||
LOS_HwiTrigger(HWI_NUM_TEST);
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); // Compare wiht the expected value 1.
|
||||
LOS_HwiEnable(HWI_NUM_TEST);
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // Compare wiht the expected value 2.
|
||||
LOS_HwiDisable(HWI_NUM_TEST);
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // Compare wiht the expected value 3.
|
||||
LOS_HwiClear(HWI_NUM_TEST);
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // Compare wiht the expected value 4.
|
||||
LOS_HwiSetPriority(HWI_NUM_TEST, 3); // 3, Set hwi priority.
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // Compare wiht the expected value 5.
|
||||
irqNum = LOS_HwiCurIrqNum();
|
||||
ICUNIT_ASSERT_EQUAL(irqNum, HWI_NUM_TEST, irqNum);
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 6, g_testCount, EXIT); // Compare wiht the expected value 6.
|
||||
|
||||
ops->triggerIrq = opsBac->triggerIrq;
|
||||
ops->enableIrq = opsBac->enableIrq;
|
||||
ops->disableIrq = opsBac->disableIrq;
|
||||
ops->setIrqPriority = opsBac->setIrqPriority;
|
||||
ops->getCurIrqNum = opsBac->getCurIrqNum;
|
||||
ops->clearIrq = opsBac->clearIrq;
|
||||
|
||||
free(opsBac);
|
||||
ret = LOS_HwiDisable(HWI_NUM_TEST);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
LOS_HwiTrigger(HWI_NUM_TEST);
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 6, g_testCount, EXIT); // Compare wiht the expected value 6.
|
||||
ret = LOS_HwiEnable(HWI_NUM_TEST);
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 7, g_testCount, EXIT); // Compare wiht the expected value 7.
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
LOS_HwiTrigger(HWI_NUM_TEST);
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 8, g_testCount, EXIT); // Compare wiht the expected value 8.
|
||||
|
||||
TestHwiDelete(HWI_NUM_TEST);
|
||||
return LOS_OK;
|
||||
|
||||
EXIT:
|
||||
TestHwiDelete(HWI_NUM_TEST);
|
||||
free(opsBac);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosHwi040(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("ItLosHwi040", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL3, TEST_PRESSURE);
|
||||
}
|
||||
@@ -38,10 +38,10 @@ static UINT32 TestCase(VOID)
|
||||
UINT32 ret;
|
||||
|
||||
ret = LOS_MemInit(NULL, TEST_MEM_SIZE);
|
||||
ICUNIT_ASSERT_EQUAL(ret, OS_ERROR, ret);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_NOK, ret);
|
||||
|
||||
ret = LOS_MemInit(g_memPool, MIN_MEM_POOL_SIZE - 1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, OS_ERROR, ret);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_NOK, ret);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
@@ -43,14 +43,14 @@ static VOID HwiF01(void)
|
||||
|
||||
ret = LOS_MuxPend(g_mutexTest, 0);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_PEND_INTERR, ret);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_IN_INTERR, ret);
|
||||
|
||||
ret = LOS_MuxPend(g_mutexTest, LOS_WAIT_FOREVER);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_PEND_INTERR, ret);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_IN_INTERR, ret);
|
||||
|
||||
ret = LOS_MuxPost(g_mutexTest);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_INVALID, ret);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_IN_INTERR, ret);
|
||||
|
||||
ret = LOS_MuxDelete(g_mutexTest);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
|
||||
@@ -40,7 +40,7 @@ static VOID HwiF01(void)
|
||||
TestHwiClear(HWI_NUM_TEST);
|
||||
|
||||
ret = LOS_MuxPost(g_mutexTest);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_IN_INTERR, ret);
|
||||
|
||||
g_testCount++;
|
||||
}
|
||||
@@ -65,7 +65,7 @@ static UINT32 Testcase(VOID)
|
||||
ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount); // 1, Here, assert that g_testCount is equal to 1.
|
||||
|
||||
ret = LOS_MuxPost(g_mutexTest);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_MUX_INVALID, ret);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_MuxDelete(g_mutexTest);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
@@ -40,7 +40,7 @@ static VOID HwiF01(void)
|
||||
TestHwiClear(HWI_NUM_TEST);
|
||||
|
||||
ret = LOS_MuxPost(g_mutexTest);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_IN_INTERR, ret);
|
||||
|
||||
g_testCount++;
|
||||
}
|
||||
@@ -64,7 +64,7 @@ static UINT32 Testcase(VOID)
|
||||
ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount); // 1, Here, assert that g_testCount is equal to 1.
|
||||
|
||||
ret = LOS_MuxPost(g_mutexTest);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_MUX_INVALID, ret);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_MuxDelete(g_mutexTest);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
@@ -46,15 +46,15 @@ static VOID Func01(void)
|
||||
|
||||
TestHwiDelete(HWI_NUM_TEST);
|
||||
} else if (g_testCount == 3) { // 3, Here, The current possible value of the variable.
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_PEND_INTERR, ret);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_IN_INTERR, ret);
|
||||
}
|
||||
|
||||
ret = LOS_MuxPost(g_mutexTest);
|
||||
|
||||
if (g_testCount == 3) { // 3, Here, The current possible value of the variable.
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_IN_INTERR, ret);
|
||||
} else if (g_testCount == 4) { // 4, Here, The current possible value of the variable.
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_INVALID, ret);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
}
|
||||
|
||||
g_testCount++;
|
||||
@@ -64,7 +64,7 @@ static VOID HwiF01(void)
|
||||
{
|
||||
TestHwiClear(HWI_NUM_TEST);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
|
||||
|
||||
g_testCount++;
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ static VOID HwiF02(void)
|
||||
g_testCount++;
|
||||
|
||||
ret = LOS_MuxPost(g_mutexTest);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_INVALID, ret);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_IN_INTERR, ret);
|
||||
}
|
||||
|
||||
static VOID HwiF01(void)
|
||||
@@ -57,7 +57,7 @@ static VOID HwiF01(void)
|
||||
g_testCount++;
|
||||
|
||||
ret = LOS_MuxPend(g_mutexTest, LOS_WAIT_FOREVER);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_PEND_INTERR, ret);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_IN_INTERR, ret);
|
||||
|
||||
ret = LOS_HwiCreate(HWI_NUM_TEST0, 1, 0, (HWI_PROC_FUNC)HwiF02, 0);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
|
||||
@@ -45,10 +45,10 @@ static UINT32 Testcase(VOID)
|
||||
ret = LOS_QueueCreate(NULL, QUEUE_BASE_NUM, &queueID[index], 0, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
}
|
||||
ret = LOS_QueueWrite(LOSCFG_BASE_IPC_QUEUE_LIMIT - 1, &buff1, QUEUE_BASE_MSGSIZE, 0);
|
||||
ret = LOS_QueueWrite(queueID[limit - 1], &buff1, QUEUE_BASE_MSGSIZE, 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ret = LOS_QueueRead(LOSCFG_BASE_IPC_QUEUE_LIMIT - 1, &buff2, QUEUE_BASE_MSGSIZE, 0);
|
||||
ret = LOS_QueueRead(queueID[limit - 1], &buff2, QUEUE_BASE_MSGSIZE, 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &queueID[index], 0, QUEUE_BASE_MSGSIZE);
|
||||
|
||||
@@ -46,11 +46,11 @@ static UINT32 Testcase(VOID)
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
}
|
||||
// 2, is test for LOSCFG_BASE_IPC_QUEUE_LIMIT - 2
|
||||
ret = LOS_QueueWrite(LOSCFG_BASE_IPC_QUEUE_LIMIT - 2, &buff1, QUEUE_BASE_MSGSIZE, 0);
|
||||
ret = LOS_QueueWrite(queueID[limit - 1], &buff1, QUEUE_BASE_MSGSIZE, 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
// 2, is test for LOSCFG_BASE_IPC_QUEUE_LIMIT - 2
|
||||
ret = LOS_QueueRead(LOSCFG_BASE_IPC_QUEUE_LIMIT - 2, &buff2, QUEUE_BASE_MSGSIZE, 0);
|
||||
ret = LOS_QueueRead(queueID[limit - 1], &buff2, QUEUE_BASE_MSGSIZE, 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
EXIT:
|
||||
|
||||
@@ -45,8 +45,7 @@ static UINT32 Testcase(VOID)
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ret = LOS_QueueRead(g_testQueueID01, &buff2, 0xffffffff, 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
ICUNIT_GOTO_EQUAL(*((char *)(intptr_t)buff2 + 7), buff1[7], *((char *)(intptr_t)buff2 + 7), EXIT); // 7, QUEUE_BASE_MSGSIZE - 1
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_BUFFER_SIZE_TOO_BIG, ret, EXIT);
|
||||
|
||||
ret = LOS_QueueDelete(g_testQueueID01);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
@@ -45,8 +45,7 @@ static UINT32 Testcase(VOID)
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ret = LOS_QueueRead(g_testQueueID01, &buff2, (0xffffffff - 1), 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
ICUNIT_GOTO_EQUAL(*((char *)(intptr_t)buff2 + 7), buff1[7], *((char *)(intptr_t)buff2 + 7), EXIT); // 7, Verify that the data is correct
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_BUFFER_SIZE_TOO_BIG, ret, EXIT);
|
||||
|
||||
ret = LOS_QueueDelete(g_testQueueID01);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
@@ -46,10 +46,10 @@ static UINT32 Testcase(VOID)
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
}
|
||||
|
||||
ret = LOS_QueueWriteHead(LOSCFG_BASE_IPC_QUEUE_LIMIT - 1, &buff1, QUEUE_BASE_MSGSIZE, 0);
|
||||
ret = LOS_QueueWriteHead(queueID[limit - 1], &buff1, QUEUE_BASE_MSGSIZE, 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ret = LOS_QueueRead(LOSCFG_BASE_IPC_QUEUE_LIMIT - 1, &buff2, QUEUE_BASE_MSGSIZE, 0);
|
||||
ret = LOS_QueueRead(queueID[limit - 1], &buff2, QUEUE_BASE_MSGSIZE, 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &queueID[index], 0, QUEUE_BASE_MSGSIZE);
|
||||
|
||||
@@ -46,10 +46,10 @@ static UINT32 Testcase(VOID)
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
}
|
||||
|
||||
ret = LOS_QueueWriteHead(LOSCFG_BASE_IPC_QUEUE_LIMIT - 1, &buff1, QUEUE_BASE_MSGSIZE, 0);
|
||||
ret = LOS_QueueWriteHead(queueID[limit - 1], &buff1, QUEUE_BASE_MSGSIZE, 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ret = LOS_QueueRead(LOSCFG_BASE_IPC_QUEUE_LIMIT - 1, &buff2, QUEUE_BASE_MSGSIZE, 0);
|
||||
ret = LOS_QueueRead(queueID[limit - 1], &buff2, QUEUE_BASE_MSGSIZE, 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
EXIT:
|
||||
|
||||
@@ -107,6 +107,8 @@ static_library("test_swtmr") {
|
||||
"It_los_swtmr_077.c",
|
||||
"It_los_swtmr_078.c",
|
||||
"It_los_swtmr_079.c",
|
||||
"It_los_swtmr_080.c",
|
||||
"It_los_swtmr_081.c",
|
||||
"It_los_swtmr_Align_001.c",
|
||||
"It_los_swtmr_Align_002.c",
|
||||
"It_los_swtmr_Align_003.c",
|
||||
|
||||
@@ -114,6 +114,8 @@ VOID ItSuiteLosSwtmr(void)
|
||||
ItLosSwtmr077();
|
||||
ItLosSwtmr078();
|
||||
ItLosSwtmr079();
|
||||
ItLosSwtmr080();
|
||||
ItLosSwtmr081();
|
||||
#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
|
||||
ItLosSwtmrAlign005();
|
||||
ItLosSwtmrAlign006();
|
||||
|
||||
@@ -148,6 +148,8 @@ extern VOID ItLosSwtmr076(VOID);
|
||||
extern VOID ItLosSwtmr077(VOID);
|
||||
extern VOID ItLosSwtmr078(VOID);
|
||||
extern VOID ItLosSwtmr079(VOID);
|
||||
extern VOID ItLosSwtmr080(VOID);
|
||||
extern VOID ItLosSwtmr081(VOID);
|
||||
|
||||
extern VOID ItLosSwtmrAlign001(VOID);
|
||||
extern VOID ItLosSwtmrAlign002(VOID);
|
||||
|
||||
@@ -72,8 +72,8 @@ static UINT32 Testcase(VOID)
|
||||
|
||||
ret = LOS_SwtmrTimeGet(swTmrID, &tick);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
// 2 - 1, Here, assert that uwTick is equal to this .
|
||||
ICUNIT_GOTO_EQUAL(tick, 2 - 1, tick, EXIT);
|
||||
// 1, Here, assert that uwTick is equal to this .
|
||||
ICUNIT_GOTO_EQUAL(tick, 1, tick, EXIT);
|
||||
|
||||
// 2, Here, assert that g_testCount is equal to this .
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT);
|
||||
|
||||
87
testsuites/sample/kernel/swtmr/It_los_swtmr_080.c
Normal file
87
testsuites/sample/kernel/swtmr/It_los_swtmr_080.c
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* 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 "osTest.h"
|
||||
#include "It_los_swtmr.h"
|
||||
|
||||
static UINT32 g_testCount1 = 0;
|
||||
static VOID Case1(UINT32 arg)
|
||||
{
|
||||
g_testCount1++;
|
||||
return;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
g_testCount1 = 0;
|
||||
UINT64 tickRecord;
|
||||
UINT64 tickUpdate;
|
||||
UINT64 delayTicks;
|
||||
const UINT64 delayMs = 10; // delay 10 MS
|
||||
|
||||
// 4, Timeout interval of a periodic software timer.
|
||||
ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_PERIOD, Case1, &g_swtmrId1, 0xffff
|
||||
#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
|
||||
, OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE
|
||||
#endif
|
||||
);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_SwtmrStart(g_swtmrId1);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
tickRecord = LOS_TickCountGet();
|
||||
LOS_MDelay(delayMs);
|
||||
tickUpdate = LOS_TickCountGet();
|
||||
|
||||
// 0, Here, assert that g_testCount is equal to this.
|
||||
ICUNIT_ASSERT_EQUAL(g_testCount1, 0, g_testCount);
|
||||
|
||||
delayTicks = delayMs * LOSCFG_BASE_CORE_TICK_PER_SECOND / OS_SYS_MS_PER_SECOND;
|
||||
ICUNIT_ASSERT_WITHIN_EQUAL(delayTicks, tickUpdate - tickRecord - 1, tickUpdate - tickRecord + 1, delayTicks);
|
||||
|
||||
// 10, set task delay time.
|
||||
LOS_TaskDelay(10);
|
||||
|
||||
// 2, Here, assert that g_testCount is equal to this.
|
||||
ICUNIT_ASSERT_EQUAL(g_testCount1, 2, g_testCount);
|
||||
|
||||
EXIT:
|
||||
LOS_SwtmrDelete(g_swtmrId1);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosSwtmr080() // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("ItLosSwtmr080", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
|
||||
84
testsuites/sample/kernel/swtmr/It_los_swtmr_081.c
Normal file
84
testsuites/sample/kernel/swtmr/It_los_swtmr_081.c
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* 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 "osTest.h"
|
||||
#include "It_los_swtmr.h"
|
||||
|
||||
static UINT32 g_testCount1 = 0;
|
||||
static UINT64 g_timeRecordNS = 0;
|
||||
static UINT64 g_timeUpdateNS = 0;
|
||||
|
||||
#define SWTMR_PERIODIC 4
|
||||
|
||||
static VOID Case1(UINT32 arg)
|
||||
{
|
||||
g_testCount1++;
|
||||
g_timeUpdateNS = LOS_CurrNanosec();
|
||||
return;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
g_testCount1 = 0;
|
||||
UINT64 tickRecord;
|
||||
UINT64 tickUpdate;
|
||||
UINT64 deltaTicks;
|
||||
|
||||
// 4, Timeout interval of a periodic software timer.
|
||||
ret = LOS_SwtmrCreate(SWTMR_PERIODIC, LOS_SWTMR_MODE_ONCE, Case1, &g_swtmrId1, 0xffff
|
||||
#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
|
||||
, OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE
|
||||
#endif
|
||||
);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
g_timeRecordNS = LOS_CurrNanosec();
|
||||
|
||||
ret = LOS_SwtmrStart(g_swtmrId1);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
// 10, SSet task delay time.
|
||||
LOS_TaskDelay(10);
|
||||
|
||||
deltaTicks = (g_timeUpdateNS - g_timeRecordNS) * LOSCFG_BASE_CORE_TICK_PER_SECOND / OS_SYS_NS_PER_SECOND;
|
||||
ICUNIT_ASSERT_EQUAL(deltaTicks, SWTMR_PERIODIC, deltaTicks);
|
||||
|
||||
EXIT:
|
||||
LOS_SwtmrDelete(g_swtmrId1);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosSwtmr081() // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("ItLosSwtmr081", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
|
||||
@@ -150,6 +150,11 @@ static_library("test_task") {
|
||||
"It_los_task_121.c",
|
||||
"It_los_task_122.c",
|
||||
"It_los_task_123.c",
|
||||
"It_los_task_124.c",
|
||||
"It_los_task_125.c",
|
||||
"It_los_task_126.c",
|
||||
"It_los_task_127.c",
|
||||
"It_los_task_128.c",
|
||||
]
|
||||
|
||||
configs += [ "//kernel/liteos_m/testsuites:include" ]
|
||||
|
||||
@@ -123,7 +123,11 @@ VOID ItSuiteLosTask()
|
||||
ItLosTask121();
|
||||
ItLosTask122();
|
||||
ItLosTask123();
|
||||
|
||||
ItLosTask124();
|
||||
ItLosTask125();
|
||||
ItLosTask126();
|
||||
ItLosTask127();
|
||||
ItLosTask128();
|
||||
#if (LOS_KERNEL_TEST_FULL == 1)
|
||||
ItLosTask039();
|
||||
ItLosTask040();
|
||||
|
||||
@@ -178,6 +178,11 @@ extern VOID ItLosTask120(VOID);
|
||||
extern VOID ItLosTask121(VOID);
|
||||
extern VOID ItLosTask122(VOID);
|
||||
extern VOID ItLosTask123(VOID);
|
||||
extern VOID ItLosTask124(VOID);
|
||||
extern VOID ItLosTask125(VOID);
|
||||
extern VOID ItLosTask126(VOID);
|
||||
extern VOID ItLosTask127(VOID);
|
||||
extern VOID ItLosTask128(VOID);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
90
testsuites/sample/kernel/task/It_los_task_124.c
Normal file
90
testsuites/sample/kernel/task/It_los_task_124.c
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* 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 "osTest.h"
|
||||
#include "It_los_task.h"
|
||||
|
||||
static UINT32 GetfreeMemSize(void *pool)
|
||||
{
|
||||
return LOS_MemPoolSizeGet(pool) - LOS_MemTotalUsedGet(pool);
|
||||
}
|
||||
|
||||
static VOID TaskF01(UINT32 arg)
|
||||
{
|
||||
g_testCount++;
|
||||
return;
|
||||
}
|
||||
|
||||
static UINT32 TestCase(VOID)
|
||||
{
|
||||
UINT32 freeMem;
|
||||
UINT32 freeMem1;
|
||||
UINT32 freeMem2;
|
||||
UINT32 freeMem3;
|
||||
UINT32 freeMem4;
|
||||
UINT32 ret;
|
||||
|
||||
TSK_INIT_PARAM_S task1 = { 0 };
|
||||
task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "Tsk124A";
|
||||
task1.usTaskPrio = 8; // 8, set task priortiy value.
|
||||
g_testCount = 0;
|
||||
|
||||
freeMem = GetfreeMemSize(m_aucSysMem0);
|
||||
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
|
||||
|
||||
freeMem1 = GetfreeMemSize(m_aucSysMem0);
|
||||
|
||||
LOS_TaskDelete(g_testTaskID01);
|
||||
|
||||
freeMem2 = GetfreeMemSize(m_aucSysMem0);
|
||||
ICUNIT_ASSERT_EQUAL(freeMem2, freeMem1, freeMem2);
|
||||
|
||||
LOS_TaskResRecycle();
|
||||
freeMem3 = GetfreeMemSize(m_aucSysMem0);
|
||||
ICUNIT_ASSERT_EQUAL(freeMem3, freeMem, freeMem3);
|
||||
|
||||
LOS_TaskDelay(10); // 10, task delay times.
|
||||
|
||||
freeMem4 = GetfreeMemSize(m_aucSysMem0);
|
||||
ICUNIT_ASSERT_EQUAL(freeMem4, freeMem, freeMem4);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosTask124(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("ItLosTask124", TestCase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
92
testsuites/sample/kernel/task/It_los_task_125.c
Normal file
92
testsuites/sample/kernel/task/It_los_task_125.c
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* 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 "osTest.h"
|
||||
#include "It_los_task.h"
|
||||
|
||||
static UINT32 GetfreeMemSize(void *pool)
|
||||
{
|
||||
return LOS_MemPoolSizeGet(pool) - LOS_MemTotalUsedGet(pool);
|
||||
}
|
||||
|
||||
static VOID TaskF01(UINT32 arg)
|
||||
{
|
||||
g_testCount++;
|
||||
return;
|
||||
}
|
||||
|
||||
static UINT32 TestCase(VOID)
|
||||
{
|
||||
UINT32 freeMem;
|
||||
UINT32 freeMem1;
|
||||
UINT32 freeMem2;
|
||||
UINT32 freeMem3;
|
||||
UINT32 freeMem4;
|
||||
UINT32 ret;
|
||||
|
||||
TSK_INIT_PARAM_S task1 = { 0 };
|
||||
task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "Tsk125A";
|
||||
task1.usTaskPrio = 8; // 8, set task priortiy value.
|
||||
g_testCount = 0;
|
||||
|
||||
freeMem = GetfreeMemSize(m_aucSysMem0);
|
||||
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
|
||||
|
||||
freeMem1 = GetfreeMemSize(m_aucSysMem0);
|
||||
|
||||
LOS_TaskDelete(g_testTaskID01);
|
||||
|
||||
freeMem2 = GetfreeMemSize(m_aucSysMem0);
|
||||
ICUNIT_ASSERT_EQUAL(freeMem2, freeMem1, freeMem2);
|
||||
|
||||
LOS_TaskDelay(10); // 10, task delay times.
|
||||
|
||||
freeMem3 = GetfreeMemSize(m_aucSysMem0);
|
||||
ICUNIT_ASSERT_EQUAL(freeMem3, freeMem, freeMem3);
|
||||
|
||||
LOS_TaskResRecycle();
|
||||
freeMem4 = GetfreeMemSize(m_aucSysMem0);
|
||||
ICUNIT_ASSERT_EQUAL(freeMem4, freeMem, freeMem4);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosTask125(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("ItLosTask125", TestCase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
|
||||
87
testsuites/sample/kernel/task/It_los_task_126.c
Normal file
87
testsuites/sample/kernel/task/It_los_task_126.c
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* 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 "osTest.h"
|
||||
#include "It_los_task.h"
|
||||
|
||||
static UINT32 GetfreeMemSize(void *pool)
|
||||
{
|
||||
return LOS_MemPoolSizeGet(pool) - LOS_MemTotalUsedGet(pool);
|
||||
}
|
||||
|
||||
static VOID TaskF01(UINT32 arg)
|
||||
{
|
||||
g_testCount++;
|
||||
return;
|
||||
}
|
||||
|
||||
static UINT32 TestCase(VOID)
|
||||
{
|
||||
UINT32 freeMem;
|
||||
UINT32 freeMem1;
|
||||
UINT32 freeMem2;
|
||||
UINT32 freeMem3;
|
||||
UINT32 freeMem4;
|
||||
UINT32 ret;
|
||||
|
||||
TSK_INIT_PARAM_S task1 = { 0 };
|
||||
task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "Tsk016A";
|
||||
task1.usTaskPrio = 8; // 8, set task priortiy value.
|
||||
g_testCount = 0;
|
||||
|
||||
freeMem = GetfreeMemSize(m_aucSysMem0);
|
||||
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
|
||||
|
||||
freeMem1 = GetfreeMemSize(m_aucSysMem0);
|
||||
|
||||
LOS_TaskDelay(10); // 10, task delay times.
|
||||
|
||||
freeMem2 = GetfreeMemSize(m_aucSysMem0);
|
||||
ICUNIT_ASSERT_EQUAL(freeMem2, freeMem, freeMem2);
|
||||
|
||||
LOS_TaskResRecycle();
|
||||
freeMem3 = GetfreeMemSize(m_aucSysMem0);
|
||||
ICUNIT_ASSERT_EQUAL(freeMem3, freeMem, freeMem3);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosTask126(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("ItLosTask126", TestCase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user