parent
b295e8e28f
commit
1405111aa9
|
@ -30,6 +30,8 @@
|
|||
*/
|
||||
|
||||
#include "los_cpup.h"
|
||||
#include "securec.h"
|
||||
#include "los_memory.h"
|
||||
#include "los_debug.h"
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
@ -37,7 +39,7 @@ extern "C" {
|
|||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#if (LOSCFG_BASE_CORE_CPUP == YES)
|
||||
#if (LOSCFG_BASE_CORE_CPUP == 1)
|
||||
|
||||
/**
|
||||
* @ingroup los_cpup
|
||||
|
|
11
kal/BUILD.gn
11
kal/BUILD.gn
|
@ -1,11 +0,0 @@
|
|||
# Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
|
||||
import("//build/lite/config/component/lite_component.gni")
|
||||
|
||||
lite_component("kal") {
|
||||
features = [
|
||||
"cmsis",
|
||||
"posix",
|
||||
|
||||
#"kal", # kal is not supported now.
|
||||
]
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
# Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
|
||||
import("//build/lite/config/component/lite_component.gni")
|
||||
|
||||
static_library("cmsis") {
|
||||
sources = [ "cmsis_liteos.c" ]
|
||||
|
||||
include_dirs = [
|
||||
"//kernel/liteos_m/kal",
|
||||
"//third_party/bounds_checking_function/include",
|
||||
]
|
||||
|
||||
defines = [ "LITEOS_WIFI_IOT_VERSION" ]
|
||||
|
||||
cflags = [ "-Wno-error" ]
|
||||
}
|
|
@ -30,24 +30,21 @@
|
|||
*/
|
||||
|
||||
#include "cmsis_os.h"
|
||||
#include "los_typedef.h"
|
||||
#include "los_printf.h"
|
||||
|
||||
#include "los_event.h"
|
||||
#include "los_membox.h"
|
||||
#include "los_memory.h"
|
||||
#include "los_hwi.h"
|
||||
#include "los_interrupt.h"
|
||||
#include "los_mux.h"
|
||||
#include "los_queue.h"
|
||||
#include "los_sem.h"
|
||||
#include "los_swtmr.h"
|
||||
#include "los_task.h"
|
||||
#include "kal.h"
|
||||
#include "los_debug.h"
|
||||
|
||||
#include "los_mux_pri.h"
|
||||
#include "los_queue_pri.h"
|
||||
#include "los_sem_pri.h"
|
||||
#include "los_swtmr_pri.h"
|
||||
#include "los_sys_pri.h"
|
||||
#include "los_task_pri.h"
|
||||
#include "los_tick_pri.h"
|
||||
#include "string.h"
|
||||
#include "securec.h"
|
||||
//#include "system_config.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
|
@ -74,7 +71,7 @@ const osVersion_t g_stLosVersion = { 001, 001 };
|
|||
((UINT32)LITEOS_VERSION_BUILD * 1UL))
|
||||
|
||||
#define KERNEL_ID "HUAWEI-LiteOS"
|
||||
#define UNUSED(var) do { (void)var; } while(0)
|
||||
#define UNUSED(var) do { (void)var; } while (0)
|
||||
|
||||
// ==== Kernel Management Functions ====
|
||||
uint32_t osTaskStackWaterMarkGet(UINT32 taskID);
|
||||
|
@ -659,7 +656,7 @@ uint32_t osThreadGetCount(void)
|
|||
|
||||
|
||||
// ==== Generic Wait Functions ====
|
||||
WEAK UINT32 LOS_HalDelay(UINT32 ticks)
|
||||
WEAK UINT32 HalDelay(UINT32 ticks)
|
||||
{
|
||||
UNUSED(ticks);
|
||||
return LOS_ERRNO_TSK_DELAY_IN_INT;
|
||||
|
@ -668,12 +665,12 @@ WEAK UINT32 LOS_HalDelay(UINT32 ticks)
|
|||
|
||||
osStatus_t osDelay(uint32_t ticks)
|
||||
{
|
||||
UINT32 uwRet = 0;
|
||||
UINT32 uwRet;
|
||||
if (ticks == 0) {
|
||||
return osOK;
|
||||
}
|
||||
if (osKernelGetState() != osKernelRunning) {
|
||||
uwRet = LOS_HalDelay(ticks);
|
||||
uwRet = HalDelay(ticks);
|
||||
} else {
|
||||
uwRet = LOS_TaskDelay(ticks);
|
||||
}
|
||||
|
@ -706,41 +703,14 @@ osStatus_t osDelayUntil(uint32_t ticks)
|
|||
}
|
||||
|
||||
// ==== Timer Management Functions ====
|
||||
#if (LOSCFG_BASE_CORE_SWTMR == YES)
|
||||
#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == YES)
|
||||
#if 0
|
||||
osTimerId_t osTimerExtNew(osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr,
|
||||
os_timer_rouses_type ucRouses, os_timer_align_type ucSensitive)
|
||||
{
|
||||
UNUSED(attr);
|
||||
UINT16 usSwTmrID;
|
||||
UINT8 mode;
|
||||
|
||||
if ((OS_INT_ACTIVE) || (NULL == func) || ((osTimerOnce != type) && (osTimerPeriodic != type))) {
|
||||
return (osTimerId_t)NULL;
|
||||
}
|
||||
|
||||
if (osTimerOnce == type) {
|
||||
mode = LOS_SWTMR_MODE_NO_SELFDELETE;
|
||||
} else {
|
||||
mode = LOS_SWTMR_MODE_PERIOD;
|
||||
}
|
||||
if (LOS_OK != LOS_SwtmrCreate(1, mode, (SWTMR_PROC_FUNC)func, &usSwTmrID, (UINT32)(UINTPTR)argument, ucRouses, ucSensitive)) {
|
||||
return (osTimerId_t)NULL;
|
||||
}
|
||||
|
||||
return (osTimerId_t)OS_SWT_FROM_SID(usSwTmrID);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#if 1
|
||||
#if (LOSCFG_BASE_CORE_SWTMR == 1)
|
||||
osTimerId_t osTimerNew(osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr)
|
||||
{
|
||||
UNUSED(attr);
|
||||
UINT16 usSwTmrID;
|
||||
UINT8 mode;
|
||||
|
||||
if ((OS_INT_ACTIVE) || (NULL == func) || ((osTimerOnce != type) && (osTimerPeriodic != type))) {
|
||||
if ((NULL == func) || ((osTimerOnce != type) && (osTimerPeriodic != type))) {
|
||||
return (osTimerId_t)NULL;
|
||||
}
|
||||
|
||||
|
@ -749,7 +719,7 @@ osTimerId_t osTimerNew(osTimerFunc_t func, osTimerType_t type, void *argument, c
|
|||
} else {
|
||||
mode = LOS_SWTMR_MODE_PERIOD;
|
||||
}
|
||||
#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == YES)
|
||||
#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
|
||||
if (LOS_OK != LOS_SwtmrCreate(1, mode, (SWTMR_PROC_FUNC)func, &usSwTmrID, (UINT32)(UINTPTR)argument,
|
||||
osTimerRousesAllow, osTimerAlignIgnore)) {
|
||||
return (osTimerId_t)NULL;
|
||||
|
@ -762,7 +732,7 @@ osTimerId_t osTimerNew(osTimerFunc_t func, osTimerType_t type, void *argument, c
|
|||
|
||||
return (osTimerId_t)OS_SWT_FROM_SID(usSwTmrID);
|
||||
}
|
||||
#endif
|
||||
|
||||
osStatus_t osTimerStart(osTimerId_t timer_id, uint32_t ticks)
|
||||
{
|
||||
UINT32 uwRet;
|
||||
|
@ -772,9 +742,11 @@ osStatus_t osTimerStart(osTimerId_t timer_id, uint32_t ticks)
|
|||
return osErrorParameter;
|
||||
}
|
||||
|
||||
UINTPTR intSave = LOS_IntLock();
|
||||
pstSwtmr = (SWTMR_CTRL_S *)timer_id;
|
||||
pstSwtmr->uwInterval = ticks;
|
||||
uwRet = LOS_SwtmrStart(pstSwtmr->usTimerID);
|
||||
LOS_IntRestore(intSave);
|
||||
if (LOS_OK == uwRet) {
|
||||
return osOK;
|
||||
} else if (LOS_ERRNO_SWTMR_ID_INVALID == uwRet) {
|
||||
|
@ -797,10 +769,6 @@ osStatus_t osTimerStop(osTimerId_t timer_id)
|
|||
UINT32 uwRet;
|
||||
SWTMR_CTRL_S *pstSwtmr = (SWTMR_CTRL_S *)timer_id;
|
||||
|
||||
if (OS_INT_ACTIVE) {
|
||||
return osErrorISR;
|
||||
}
|
||||
|
||||
if (NULL == pstSwtmr) {
|
||||
return osErrorParameter;
|
||||
}
|
||||
|
@ -818,7 +786,7 @@ osStatus_t osTimerStop(osTimerId_t timer_id)
|
|||
|
||||
uint32_t osTimerIsRunning(osTimerId_t timer_id)
|
||||
{
|
||||
if ((OS_INT_ACTIVE) || (NULL == timer_id)) {
|
||||
if (NULL == timer_id) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -831,10 +799,6 @@ osStatus_t osTimerDelete(osTimerId_t timer_id)
|
|||
UINT32 uwRet;
|
||||
SWTMR_CTRL_S *pstSwtmr = (SWTMR_CTRL_S *)timer_id;
|
||||
|
||||
if (OS_INT_ACTIVE) {
|
||||
return osErrorISR;
|
||||
}
|
||||
|
||||
if (NULL == pstSwtmr) {
|
||||
return osErrorParameter;
|
||||
}
|
||||
|
@ -1014,7 +978,7 @@ osStatus_t osEventFlagsDelete(osEventFlagsId_t ef_id)
|
|||
}
|
||||
|
||||
// ==== Mutex Management Functions ====
|
||||
#if (LOSCFG_BASE_IPC_MUX == YES)
|
||||
#if (LOSCFG_BASE_IPC_MUX == 1)
|
||||
osMutexId_t osMutexNew(const osMutexAttr_t *attr)
|
||||
{
|
||||
UINT32 uwRet;
|
||||
|
@ -1122,7 +1086,7 @@ osStatus_t osMutexDelete(osMutexId_t mutex_id)
|
|||
#endif
|
||||
|
||||
// ==== Semaphore Management Functions ====
|
||||
#if (LOSCFG_BASE_IPC_SEM == YES)
|
||||
#if (LOSCFG_BASE_IPC_SEM == 1)
|
||||
|
||||
osSemaphoreId_t osSemaphoreNew(uint32_t max_count, uint32_t initial_count, const osSemaphoreAttr_t *attr)
|
||||
{
|
||||
|
@ -1241,7 +1205,7 @@ osStatus_t osSemaphoreDelete(osSemaphoreId_t semaphore_id)
|
|||
|
||||
|
||||
// ==== Message Queue Management Functions ====
|
||||
#if (LOSCFG_BASE_IPC_QUEUE == YES)
|
||||
#if (LOSCFG_BASE_IPC_QUEUE == 1)
|
||||
osMessageQueueId_t osMessageQueueNew(uint32_t msg_count, uint32_t msg_size, const osMessageQueueAttr_t *attr)
|
||||
{
|
||||
UINT32 uwQueueID;
|
||||
|
|
|
@ -29,6 +29,9 @@
|
|||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef CMSIS_OS_H_
|
||||
#define CMSIS_OS_H_
|
||||
|
||||
#include "los_config.h"
|
||||
|
||||
#if (CMSIS_OS_VER == 1)
|
||||
|
@ -37,3 +40,4 @@
|
|||
#include "cmsis_os2.h"
|
||||
#endif
|
||||
|
||||
#endif /* CMSIS_OS_H_ */
|
||||
|
|
|
@ -656,8 +656,8 @@ uint32_t osKernelGetSysTimerFreq (void);
|
|||
/**
|
||||
* @brief Creates an active thread.
|
||||
*
|
||||
* The priority ranges from 9 to 38. Select a proper priority as required.
|
||||
* The maximum of tasks is LOSCFG_BASE_CORE_TSK_LIMIT(LOSCFG_BASE_CORE_TSK_LIMIT is defined in the traget_config.h).
|
||||
* The task priority ranges from 9 (highest priority) to 38 (lowest priority). {@code LOSCFG_BASE_CORE_TSK_LIMIT} declared in target_config.h specifies the
|
||||
maximum number of tasks running in this system.
|
||||
* @param func Indicates the entry of the thread callback function.
|
||||
* @param argument Indicates the pointer to the argument passed to the thread.
|
||||
* @param attr Indicates the thread attributes.
|
||||
|
@ -956,7 +956,7 @@ uint32_t osEventFlagsGet (osEventFlagsId_t ef_id);
|
|||
/**
|
||||
* @brief Waits for event flags to trigger.
|
||||
*
|
||||
* When the specified flag of the event is set, the function returns immediately. Otherwise, the thread is blocked.
|
||||
* This function is blocked if the specified event flags are not set via {@code flags}.
|
||||
* @param ef_id Indicates the event flags ID, which is obtained using osEventFlagsNew.
|
||||
* @param flags Indicates the event flags to trigger.
|
||||
* @param options Indicates the configuration of the event flags to trigger.
|
||||
|
@ -1054,7 +1054,7 @@ const char *osSemaphoreGetName (osSemaphoreId_t semaphore_id);
|
|||
* @brief Acquires a token of a semaphore object.
|
||||
*
|
||||
* @param semaphore_id Indicates the semaphore ID, which is obtained using osSemaphoreNew.
|
||||
* @param timeout Indicates the timeout duration. This parameter is the number of ticks.
|
||||
* @param timeout Indicates the timeout duration, in ticks.
|
||||
* @return Returns the CMSIS-RTOS running result.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#define HOS_CMSIS_ADP_H
|
||||
|
||||
#include "cmsis_os.h"
|
||||
#include "ohos_types.h"
|
||||
#include "los_compiler.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
@ -43,8 +43,8 @@ extern "C" {
|
|||
|
||||
typedef struct {
|
||||
osSemaphoreAttr_t attr;
|
||||
uint32 maxCount;
|
||||
uint32 initialCount;
|
||||
UINT32 maxCount;
|
||||
UINT32 initialCount;
|
||||
} SemaphoreEx;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -29,65 +29,43 @@
|
|||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "los_debug.h"
|
||||
#include "los_interrupt.h"
|
||||
#include "kal.h"
|
||||
#include "los_swtmr.h"
|
||||
|
||||
typedef struct {
|
||||
UINT32 memUsed;
|
||||
} TskMemUsedInfo;
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
LITE_OS_SEC_BSS_MINOR TskMemUsedInfo g_tskMemUsedInfo[LOSCFG_BASE_CORE_TSK_LIMIT + 1];
|
||||
|
||||
LITE_OS_SEC_TEXT_MINOR VOID OsTaskMemUsedInc(UINT32 usedSize, UINT32 taskID)
|
||||
#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
|
||||
osTimerId_t osTimerExtNew(osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr,
|
||||
osTimerRouses_t ucRouses, osTimerAlign_t ucSensitive)
|
||||
{
|
||||
if (taskID > LOSCFG_BASE_CORE_TSK_LIMIT) {
|
||||
return;
|
||||
UNUSED(attr);
|
||||
UINT16 usSwTmrID;
|
||||
UINT8 mode;
|
||||
|
||||
if ((OS_INT_ACTIVE) || (NULL == func) || ((osTimerOnce != type) && (osTimerPeriodic != type))) {
|
||||
return (osTimerId_t)NULL;
|
||||
}
|
||||
|
||||
if (OS_INT_ACTIVE) {
|
||||
return;
|
||||
if (osTimerOnce == type) {
|
||||
mode = LOS_SWTMR_MODE_NO_SELFDELETE;
|
||||
} else {
|
||||
mode = LOS_SWTMR_MODE_PERIOD;
|
||||
}
|
||||
g_tskMemUsedInfo[taskID].memUsed += usedSize;
|
||||
if (LOS_OK != LOS_SwtmrCreate(1, mode, (SWTMR_PROC_FUNC)func, &usSwTmrID,
|
||||
(UINT32)(UINTPTR)argument, ucRouses, ucSensitive)) {
|
||||
return (osTimerId_t)NULL;
|
||||
}
|
||||
|
||||
return (osTimerId_t)OS_SWT_FROM_SID(usSwTmrID);
|
||||
}
|
||||
#endif
|
||||
|
||||
LITE_OS_SEC_TEXT_MINOR VOID OsTaskMemUsedDec(UINT32 usedSize, UINT32 taskID)
|
||||
{
|
||||
if (taskID > LOSCFG_BASE_CORE_TSK_LIMIT) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (OS_INT_ACTIVE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_tskMemUsedInfo[taskID].memUsed < usedSize) {
|
||||
PRINT_INFO("mem used of current task '%s':0x%x, decrease size:0x%x\n",
|
||||
g_losTask.runTask->taskName, g_tskMemUsedInfo[taskID].memUsed, usedSize);
|
||||
return;
|
||||
}
|
||||
|
||||
g_tskMemUsedInfo[taskID].memUsed -= usedSize;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_MINOR UINT32 OsTaskMemUsage(UINT32 taskId)
|
||||
{
|
||||
if ((UINT32)taskId > LOSCFG_BASE_CORE_TSK_LIMIT) {
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
return g_tskMemUsedInfo[(UINT32)taskId].memUsed;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_MINOR VOID OsTaskMemClear(UINT32 taskID)
|
||||
{
|
||||
if (taskID > LOSCFG_BASE_CORE_TSK_LIMIT) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_tskMemUsedInfo[taskID].memUsed != 0) {
|
||||
PRINT_INFO("mem used of task '%s' is:0x%x, not zero when task being deleted\n",
|
||||
g_losTask.runTask->taskName, g_tskMemUsedInfo[taskID].memUsed);
|
||||
}
|
||||
g_tskMemUsedInfo[taskID].memUsed = 0;
|
||||
return;
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, 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.
|
||||
*/
|
||||
|
||||
#ifndef _KAL_H
|
||||
#define _KAL_H
|
||||
|
||||
#include "cmsis_os2.h"
|
||||
#include "los_compiler.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
|
||||
/**
|
||||
* @brief Enumerates timer permissions.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
typedef enum {
|
||||
/** The timer is not allowed to wake up the RTOS. */
|
||||
osTimerRousesIgnore = 0,
|
||||
/** The timer is allowed to wake up the RTOS. */
|
||||
osTimerRousesAllow = 1
|
||||
} osTimerRouses_t;
|
||||
|
||||
/**
|
||||
* @brief Enumerates timer alignment modes.
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
/** The timer ignores alignment. */
|
||||
osTimerAlignIgnore = 0,
|
||||
/** The timer allows alignment. */
|
||||
osTimerAlignAllow = 1
|
||||
} osTimerAlign_t;
|
||||
|
||||
osTimerId_t osTimerExtNew (osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr,
|
||||
osTimerRouses_t ucRouses, osTimerAlign_t ucSensitive);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
#endif /* _KAL_H */
|
|
@ -1,15 +0,0 @@
|
|||
# Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
|
||||
import("//build/lite/config/component/lite_component.gni")
|
||||
|
||||
static_library("kal") {
|
||||
sources = [ "kal.c" ]
|
||||
|
||||
include_dirs = [
|
||||
"//kernel/liteos_m/kal",
|
||||
"//third_party/bounds_checking_function/include",
|
||||
]
|
||||
|
||||
defines = [ "LITEOS_WIFI_IOT_VERSION" ]
|
||||
|
||||
cflags = [ "-Werror" ]
|
||||
}
|
220
kal/kal/kal.c
220
kal/kal/kal.c
|
@ -1,220 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, 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 "securec.h"
|
||||
#include "hi_mem.h"
|
||||
#include "los_task.h"
|
||||
#include "los_swtmr.h"
|
||||
#include "los_swtmr_pri.h"
|
||||
#include "los_hwi.h"
|
||||
#include "kal.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define NULL 0L
|
||||
#else
|
||||
#ifndef NULL
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
#endif
|
||||
#define MS_PER_SECOND 1000
|
||||
|
||||
unsigned int KalThreadGetInfo(unsigned int threadId, ThreadInfo *info)
|
||||
{
|
||||
unsigned int ret;
|
||||
if (info == NULL) {
|
||||
return -1;
|
||||
}
|
||||
(void)memset_s(info, sizeof(ThreadInfo), 0, sizeof(ThreadInfo));
|
||||
TSK_INFO_S *losTaskInfo = (TSK_INFO_S *)malloc(sizeof(TSK_INFO_S));
|
||||
if (losTaskInfo == NULL) {
|
||||
return -1;
|
||||
}
|
||||
(void)memset_s(losTaskInfo, sizeof(TSK_INFO_S), 0, sizeof(TSK_INFO_S));
|
||||
ret = LOS_TaskInfoGet(threadId, losTaskInfo);
|
||||
if (ret == LOS_OK) {
|
||||
info->id = losTaskInfo->uwTaskID;
|
||||
info->status = losTaskInfo->usTaskStatus;
|
||||
info->priority = losTaskInfo->usTaskPrio;
|
||||
info->taskSem = losTaskInfo->pTaskSem;
|
||||
info->taskMutex = losTaskInfo->pTaskMux;
|
||||
info->eventMask = losTaskInfo->uwEventMask;
|
||||
info->stackSize = losTaskInfo->uwStackSize;
|
||||
info->topOfStack = losTaskInfo->uwTopOfStack;
|
||||
info->bottomOfStack = losTaskInfo->uwBottomOfStack;
|
||||
info->mstatus = losTaskInfo->mstatus;
|
||||
info->mepc = losTaskInfo->mepc;
|
||||
info->tp = losTaskInfo->tp;
|
||||
info->ra = losTaskInfo->ra;
|
||||
info->sp = losTaskInfo->uwSP;
|
||||
info->currUsed = losTaskInfo->uwCurrUsed;
|
||||
info->peakUsed = losTaskInfo->uwPeakUsed;
|
||||
info->overflowFlag = losTaskInfo->bOvf;
|
||||
ret = memcpy_s(info->name, sizeof(info->name), losTaskInfo->acName, sizeof(info->name) - 1);
|
||||
}
|
||||
free(losTaskInfo);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void KalDelayUs(unsigned int us)
|
||||
{
|
||||
unsigned int ticks;
|
||||
if (us == 0) {
|
||||
return;
|
||||
}
|
||||
ticks = LOS_MS2Tick(us / MS_PER_SECOND);
|
||||
(void)LOS_TaskDelay(ticks);
|
||||
}
|
||||
|
||||
KalTimerId KalTimerCreate(KalTimerProc func, KalTimerType type, void *arg, unsigned int ticks)
|
||||
{
|
||||
UINT16 swtmrId;
|
||||
UINT8 mode;
|
||||
if ((OS_INT_ACTIVE) || (NULL == func) || ((KAL_TIMER_ONCE != type) && (KAL_TIMER_PERIODIC != type))) {
|
||||
return (KalTimerId)NULL;
|
||||
}
|
||||
if (KAL_TIMER_ONCE == type) {
|
||||
mode = LOS_SWTMR_MODE_NO_SELFDELETE;
|
||||
} else {
|
||||
mode = LOS_SWTMR_MODE_PERIOD;
|
||||
}
|
||||
#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == YES)
|
||||
if (LOS_OK != LOS_SwtmrCreate(ticks, mode, (SWTMR_PROC_FUNC)func, &swtmrId, (UINT32)(UINTPTR)arg,
|
||||
osTimerRousesAllow, osTimerAlignIgnore)) {
|
||||
return (KalTimerId)NULL;
|
||||
}
|
||||
#else
|
||||
if (LOS_OK != LOS_SwtmrCreate(ticks, mode, (SWTMR_PROC_FUNC)func, &swtmrId, (UINT32)(UINTPTR)arg)) {
|
||||
return (KalTimerId)NULL;
|
||||
}
|
||||
#endif
|
||||
return (KalTimerId)OS_SWT_FROM_SID(swtmrId);
|
||||
}
|
||||
KalErrCode KalTransRetCode(unsigned int ret)
|
||||
{
|
||||
if (LOS_OK == ret) {
|
||||
return KAL_OK;
|
||||
} else if (LOS_ERRNO_SWTMR_ID_INVALID == ret) {
|
||||
return KAL_ERR_PARA;
|
||||
} else {
|
||||
return KAL_ERR_INNER;
|
||||
}
|
||||
}
|
||||
KalErrCode KalTimerStart(KalTimerId timerId)
|
||||
{
|
||||
UINT32 ret;
|
||||
SWTMR_CTRL_S *swtmr = NULL;
|
||||
if (NULL == timerId) {
|
||||
return KAL_ERR_PARA;
|
||||
}
|
||||
swtmr = (SWTMR_CTRL_S *)timerId;
|
||||
|
||||
ret = LOS_SwtmrStart(swtmr->usTimerID);
|
||||
return KalTransRetCode(ret);
|
||||
}
|
||||
// support change while not running.
|
||||
KalErrCode KalTimerChange(KalTimerId timerId, unsigned int ticks)
|
||||
{
|
||||
SWTMR_CTRL_S *swtmr = NULL;
|
||||
if ((0 == ticks) || (NULL == timerId)) {
|
||||
return KAL_ERR_PARA;
|
||||
}
|
||||
swtmr = (SWTMR_CTRL_S *)timerId;
|
||||
if (OS_SWTMR_STATUS_TICKING == swtmr->ucState) {
|
||||
return KAL_ERR_TIMER_STATE;
|
||||
}
|
||||
swtmr->uwInterval = ticks;
|
||||
return KAL_OK;
|
||||
}
|
||||
KalErrCode KalTimerStop(KalTimerId timerId)
|
||||
{
|
||||
UINT32 ret;
|
||||
SWTMR_CTRL_S *swtmr = NULL;
|
||||
if (NULL == timerId) {
|
||||
return KAL_ERR_PARA;
|
||||
}
|
||||
swtmr = (SWTMR_CTRL_S *)timerId;
|
||||
ret = LOS_SwtmrStop(swtmr->usTimerID);
|
||||
return KalTransRetCode(ret);
|
||||
}
|
||||
|
||||
KalErrCode KalTimerDelete(KalTimerId timerId)
|
||||
{
|
||||
UINT32 ret;
|
||||
SWTMR_CTRL_S *swtmr = NULL;
|
||||
if (NULL == timerId) {
|
||||
return KAL_ERR_PARA;
|
||||
}
|
||||
swtmr = (SWTMR_CTRL_S *)timerId;
|
||||
ret = LOS_SwtmrDelete(swtmr->usTimerID);
|
||||
return KalTransRetCode(ret);
|
||||
}
|
||||
unsigned int KalTimerIsRunning(KalTimerId timerId)
|
||||
{
|
||||
if ((OS_INT_ACTIVE) || (NULL == timerId)) {
|
||||
return 0;
|
||||
}
|
||||
return (OS_SWTMR_STATUS_TICKING == ((SWTMR_CTRL_S *)timerId)->ucState);
|
||||
}
|
||||
|
||||
unsigned int KalTickToMs(unsigned int ticks)
|
||||
{
|
||||
return LOS_Tick2MS(ticks);
|
||||
}
|
||||
unsigned int KalMsToTick(unsigned int millisec)
|
||||
{
|
||||
return LOS_MS2Tick(millisec);
|
||||
}
|
||||
|
||||
KalErrCode KalGetMemInfo(MemInfo *pmemInfo)
|
||||
{
|
||||
hi_mdm_mem_info hiMemInfo;
|
||||
hi_u32 hiRet;
|
||||
if (NULL == pmemInfo) {
|
||||
return KAL_ERR_PARA;
|
||||
}
|
||||
hiRet = hi_mem_get_sys_info(&hiMemInfo);
|
||||
if (hiRet != 0) {
|
||||
return KAL_ERR_INNER;
|
||||
}
|
||||
pmemInfo->total = hiMemInfo.total;
|
||||
pmemInfo->used = hiMemInfo.used;
|
||||
pmemInfo->free = hiMemInfo.free;
|
||||
pmemInfo->freeNodeNum = hiMemInfo.free_node_num;
|
||||
pmemInfo->usedNodeNum = hiMemInfo.used_node_num;
|
||||
pmemInfo->maxFreeNodeSize = hiMemInfo.max_free_node_size;
|
||||
pmemInfo->mallocFailCount = hiMemInfo.malloc_fail_count;
|
||||
pmemInfo->peekSize = hiMemInfo.peek_size;
|
||||
pmemInfo->totalLmp = hiMemInfo.total_lmp;
|
||||
pmemInfo->usedLmp = hiMemInfo.used_lmp;
|
||||
pmemInfo->freeLmp = hiMemInfo.free_lmp;
|
||||
return KAL_OK;
|
||||
}
|
182
kal/kal/kal.h
182
kal/kal/kal.h
|
@ -1,182 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup KAL
|
||||
* @{
|
||||
*
|
||||
* @brief Defines the kernel adaptation layer (KAL), which provides compatible interfaces across L0 and L1 systems.
|
||||
*
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
#ifndef KAL_H_
|
||||
#define KAL_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Indicates the maximum length of a thread name.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
#define KAL_TASK_NAME_LEN 32
|
||||
|
||||
typedef void (*KalTimerProc)(void *arg);
|
||||
typedef void *KalTimerId;
|
||||
|
||||
typedef enum {
|
||||
KAL_TIMER_ONCE = 0, // /< One-shot timer.
|
||||
KAL_TIMER_PERIODIC = 1 // /< Repeating timer.
|
||||
} KalTimerType;
|
||||
|
||||
typedef enum {
|
||||
KAL_OK = 0,
|
||||
KAL_ERR_PARA = 1,
|
||||
KAL_ERR_INNER = 2,
|
||||
KAL_ERR_TIMER_STATE = 0x100,
|
||||
} KalErrCode;
|
||||
|
||||
/**
|
||||
* @brief Describes a thread.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
typedef struct {
|
||||
/** Thread name */
|
||||
char name[KAL_TASK_NAME_LEN];
|
||||
/** Thread ID */
|
||||
unsigned int id;
|
||||
/** Thread status */
|
||||
unsigned short status;
|
||||
/** Thread priority */
|
||||
unsigned short priority;
|
||||
/** Thread semaphore */
|
||||
void *taskSem;
|
||||
/** Thread mutex */
|
||||
void *taskMutex;
|
||||
/** Thread event */
|
||||
unsigned int eventStru[3];
|
||||
/** Thread event mask */
|
||||
unsigned int eventMask;
|
||||
/** Thread stack size */
|
||||
unsigned int stackSize;
|
||||
/** Thread stack top */
|
||||
unsigned int topOfStack;
|
||||
/** Thread stack bottom */
|
||||
unsigned int bottomOfStack;
|
||||
/** Thread current mstatus */
|
||||
unsigned int mstatus;
|
||||
/** Thread current mepc */
|
||||
unsigned int mepc;
|
||||
/** Thread current tp */
|
||||
unsigned int tp;
|
||||
/** Thread current ra */
|
||||
unsigned int ra;
|
||||
/** Thread stack pointer */
|
||||
unsigned int sp;
|
||||
/** Current stack space usage */
|
||||
unsigned int currUsed;
|
||||
/** Peak stack space usage */
|
||||
unsigned int peakUsed;
|
||||
/** Thread stack overflow flag */
|
||||
unsigned int overflowFlag;
|
||||
} ThreadInfo;
|
||||
|
||||
typedef struct {
|
||||
/**< Total space of the memory pool. */
|
||||
unsigned int total;
|
||||
/**< Used space of the memory pool. */
|
||||
unsigned int used;
|
||||
/**< Free space of the memory pool. */
|
||||
unsigned int free;
|
||||
/**< Number of free nodes in the memory pool. */
|
||||
unsigned int freeNodeNum;
|
||||
/**< Number of used nodes in the memory pool. */
|
||||
unsigned int usedNodeNum;
|
||||
/**< Maximum size of the node in the free space of the memory pool. */
|
||||
unsigned int maxFreeNodeSize;
|
||||
/**< Number of memory application failures. */
|
||||
unsigned int mallocFailCount;
|
||||
/**< Peak memory usage of the memory pool. */
|
||||
unsigned int peekSize;
|
||||
/**< Total space of the little memory pool. */
|
||||
unsigned int totalLmp;
|
||||
/**< Used space of the little memory pool. */
|
||||
unsigned int usedLmp;
|
||||
/**< Free space of the little memory pool. */
|
||||
unsigned int freeLmp;
|
||||
} MemInfo;
|
||||
|
||||
/**
|
||||
* @brief Obtains thread information.
|
||||
*
|
||||
* @param threadId Indicates the thread ID.
|
||||
* @param info Indicates the pointer to the buffer for storing the obtained thread information.
|
||||
* @return Returns <b>0</b> if the thread information is obtained; returns a negative value otherwise.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
unsigned int KalThreadGetInfo(unsigned int threadId, ThreadInfo *info);
|
||||
|
||||
/**
|
||||
* @brief Delays a thread.
|
||||
*
|
||||
* The delay unit is microsecond. The actual delay precision can reach only the tick level.
|
||||
*
|
||||
* @param us Indicates the number of microseconds to delay. The actual delay precision is one tick.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
void KalDelayUs(unsigned int us);
|
||||
KalTimerId KalTimerCreate(KalTimerProc func, KalTimerType type, void *arg, unsigned int ticks);
|
||||
KalErrCode KalTimerStart(KalTimerId timerId);
|
||||
KalErrCode KalTimerChange(KalTimerId timerId, unsigned int ticks);
|
||||
KalErrCode KalTimerStop(KalTimerId timerId);
|
||||
KalErrCode KalTimerDelete(KalTimerId timerId);
|
||||
unsigned int KalTimerIsRunning(KalTimerId timerId);
|
||||
unsigned int KalTickToMs(unsigned int ticks);
|
||||
unsigned int KalMsToTick(unsigned int millisec);
|
||||
KalErrCode KalGetMemInfo(MemInfo *pmemInfo);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // KAL_H_
|
||||
|
||||
/* * @} */
|
|
@ -1,20 +0,0 @@
|
|||
# Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
|
||||
import("//build/lite/config/component/lite_component.gni")
|
||||
|
||||
static_library("posix") {
|
||||
sources = [
|
||||
"src/file.c",
|
||||
"src/pthread.c",
|
||||
"src/pthread_attr.c",
|
||||
"src/time.c",
|
||||
"src/version.c",
|
||||
]
|
||||
|
||||
include_dirs = [ "include" ]
|
||||
defines = [
|
||||
"LIBC_VERSION_NUM=0x00010000",
|
||||
"LIBC_VERSION_STR=\"1.0.0-liteos_m\"",
|
||||
]
|
||||
|
||||
cflags = [ "-Werror" ]
|
||||
}
|
|
@ -72,15 +72,19 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
|
|||
return EINVAL;
|
||||
}
|
||||
|
||||
taskInitParam.usTaskPrio = LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO;
|
||||
taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
if (attr) {
|
||||
if (attr->detachstate == PTHREAD_CREATE_DETACHED) {
|
||||
return ENOTSUP;
|
||||
}
|
||||
if (attr->stackaddr_set) {
|
||||
return ENOTSUP;
|
||||
}
|
||||
if (attr->stacksize_set) {
|
||||
taskInitParam.uwStackSize = attr->stacksize;
|
||||
}
|
||||
taskInitParam.usTaskPrio = (UINT16)attr->schedparam.sched_priority;
|
||||
taskInitParam.uwStackSize = attr->stacksize;
|
||||
} else {
|
||||
taskInitParam.usTaskPrio = LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO;
|
||||
taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
}
|
||||
|
||||
taskInitParam.pcName = malloc(PTHREAD_NAMELEN);
|
||||
|
|
|
@ -0,0 +1,161 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, 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.
|
||||
*/
|
||||
|
||||
#ifndef LOS_ATOMIC_H
|
||||
#define LOS_ATOMIC_H
|
||||
|
||||
#include "los_compiler.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/**
|
||||
* @ingroup los_atomic
|
||||
* @brief Atomic exchange for 32-bit variable.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to implement the atomic exchange for 32-bit variable and return the previous value of the atomic variable.
|
||||
* @attention
|
||||
* <ul>The pointer v must not be NULL.</ul>
|
||||
*
|
||||
* @param v [IN] The variable pointer.
|
||||
* @param val [IN] The exchange value.
|
||||
*
|
||||
* @retval #INT32 The previous value of the atomic variable
|
||||
* @par Dependency:
|
||||
* <ul><li>los_atomic.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see
|
||||
* @since Huawei LiteOS V100R001C00
|
||||
*/
|
||||
STATIC INLINE INT32 HalAtomicXchg32bits(volatile INT32 *v, INT32 val)
|
||||
{
|
||||
INT32 prevVal = 0;
|
||||
UINT32 status = 0;
|
||||
|
||||
do {
|
||||
__asm__ __volatile__("ldrex %0, [%3]\n"
|
||||
"strex %1, %4, [%3]"
|
||||
: "=&r"(prevVal), "=&r"(status), "+m"(*v)
|
||||
: "r"(v), "r"(val)
|
||||
: "cc");
|
||||
} while (__builtin_expect(status != 0, 0));
|
||||
|
||||
return prevVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup los_atomic
|
||||
* @brief Atomic auto-decrement.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to implementating the atomic auto-decrement and return the result of auto-decrement.
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>The pointer v must not be NULL.</li>
|
||||
* <li>The value which v point to must not be INT_MIN to avoid overflow after reducing 1.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param v [IN] The addSelf variable pointer.
|
||||
*
|
||||
* @retval #INT32 The return value of variable auto-decrement.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_atomic.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see
|
||||
* @since Huawei LiteOS V100R001C00
|
||||
*/
|
||||
STATIC INLINE INT32 HalAtomicDecRet(volatile INT32 *v)
|
||||
{
|
||||
INT32 val = 0;
|
||||
UINT32 status = 0;
|
||||
|
||||
do {
|
||||
__asm__ __volatile__("ldrex %0, [%3]\n"
|
||||
"sub %0, %0, #1\n"
|
||||
"strex %1, %0, [%3]"
|
||||
: "=&r"(val), "=&r"(status), "+m"(*v)
|
||||
: "r"(v)
|
||||
: "cc");
|
||||
} while (__builtin_expect(status != 0, 0));
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup los_atomic
|
||||
* @brief Atomic exchange for 32-bit variable with compare.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to implement the atomic exchange for 32-bit variable, if the value of variable is equal to oldVal.
|
||||
* @attention
|
||||
* <ul>The pointer v must not be NULL.</ul>
|
||||
*
|
||||
* @param v [IN] The variable pointer.
|
||||
* @param val [IN] The new value.
|
||||
* @param oldVal [IN] The old value.
|
||||
*
|
||||
* @retval TRUE The previous value of the atomic variable is not equal to oldVal.
|
||||
* @retval FALSE The previous value of the atomic variable is equal to oldVal.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_atomic.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see
|
||||
* @since Huawei LiteOS V100R001C00
|
||||
*/
|
||||
STATIC INLINE BOOL HalAtomicCmpXchg32bits(volatile INT32 *v, INT32 val, INT32 oldVal)
|
||||
{
|
||||
INT32 prevVal = 0;
|
||||
UINT32 status = 0;
|
||||
|
||||
do {
|
||||
__asm__ __volatile__("1: ldrex %0, %2\n"
|
||||
" mov %1, #0\n"
|
||||
" cmp %0, %3\n"
|
||||
" bne 2f\n"
|
||||
" strex %1, %4, %2\n"
|
||||
"2:"
|
||||
: "=&r"(prevVal), "=&r"(status), "+Q"(*v)
|
||||
: "r"(oldVal), "r"(val)
|
||||
: "cc");
|
||||
} while (__builtin_expect(status != 0, 0));
|
||||
|
||||
return prevVal != oldVal;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* LOS_ATOMIC_H */
|
||||
|
325
kernel/arch/arm/cortex-m3/keil/los_context.h → kernel/arch/arm/cortex-m3/keil/los_arch_context.h
Executable file → Normal file
325
kernel/arch/arm/cortex-m3/keil/los_context.h → kernel/arch/arm/cortex-m3/keil/los_arch_context.h
Executable file → Normal file
|
@ -1,194 +1,131 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup los_hw hardware
|
||||
* @ingroup kernel
|
||||
*/
|
||||
|
||||
#ifndef _LOS_HW_H
|
||||
#define _LOS_HW_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* *
|
||||
* @ingroup los_hw
|
||||
* The initialization value of stack space.
|
||||
*/
|
||||
#define EMPTY_STACK 0xCACA
|
||||
|
||||
/* *
|
||||
* @ingroup los_hw
|
||||
* Trigger a task.
|
||||
*/
|
||||
#define OsTaskTrap() __asm(" TRAP #31")
|
||||
|
||||
/* *
|
||||
* @ingroup los_hw
|
||||
* Check task schedule.
|
||||
*/
|
||||
#define LOS_CHECK_SCHEDULE ((!g_losTaskLock))
|
||||
|
||||
/* *
|
||||
* @ingroup los_hw
|
||||
* Define the type of a task context control block.
|
||||
*/
|
||||
typedef struct tagTskContext {
|
||||
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
||||
UINT32 S16;
|
||||
UINT32 S17;
|
||||
UINT32 S18;
|
||||
UINT32 S19;
|
||||
UINT32 S20;
|
||||
UINT32 S21;
|
||||
UINT32 S22;
|
||||
UINT32 S23;
|
||||
UINT32 S24;
|
||||
UINT32 S25;
|
||||
UINT32 S26;
|
||||
UINT32 S27;
|
||||
UINT32 S28;
|
||||
UINT32 S29;
|
||||
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;
|
||||
UINT32 uwR3;
|
||||
UINT32 uwR12;
|
||||
UINT32 uwLR;
|
||||
UINT32 uwPC;
|
||||
UINT32 uwxPSR;
|
||||
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
||||
UINT32 S0;
|
||||
UINT32 S1;
|
||||
UINT32 S2;
|
||||
UINT32 S3;
|
||||
UINT32 S4;
|
||||
UINT32 S5;
|
||||
UINT32 S6;
|
||||
UINT32 S7;
|
||||
UINT32 S8;
|
||||
UINT32 S9;
|
||||
UINT32 S10;
|
||||
UINT32 S11;
|
||||
UINT32 S12;
|
||||
UINT32 S13;
|
||||
UINT32 S14;
|
||||
UINT32 S15;
|
||||
UINT32 FPSCR;
|
||||
UINT32 NO_NAME;
|
||||
#endif
|
||||
} TaskContext;
|
||||
|
||||
/* *
|
||||
* @ingroup los_hw
|
||||
* @brief: Task stack initialization.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to initialize the task stack.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param taskID [IN] Type#UINT32: TaskID.
|
||||
* @param stackSize [IN] Type#UINT32: Total size of the stack.
|
||||
* @param topStack [IN] Type#VOID *: Top of task's stack.
|
||||
*
|
||||
* @retval: context Type#TaskContext *.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_hw.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
extern VOID *OsTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack);
|
||||
|
||||
/**
|
||||
* @ingroup los_hw
|
||||
* @brief: Function to task exit.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to exit task.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @retval: None.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_hw.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
LITE_OS_SEC_TEXT_MINOR VOID OsTaskExit(VOID);
|
||||
|
||||
/* *
|
||||
* @ingroup los_hw
|
||||
* @brief: The M3 wait interrupt instruction.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to make CPU enter to power-save mode.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @retval: None.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_hw.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
extern VOID OsEnterSleep(VOID);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _LOS_HW_H */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, 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.
|
||||
*/
|
||||
|
||||
#ifndef _LOS_ARCH_CONTEXT_H
|
||||
#define _LOS_ARCH_CONTEXT_H
|
||||
|
||||
#include "los_config.h"
|
||||
#include "los_compiler.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
typedef struct tagTskContext {
|
||||
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
||||
UINT32 S16;
|
||||
UINT32 S17;
|
||||
UINT32 S18;
|
||||
UINT32 S19;
|
||||
UINT32 S20;
|
||||
UINT32 S21;
|
||||
UINT32 S22;
|
||||
UINT32 S23;
|
||||
UINT32 S24;
|
||||
UINT32 S25;
|
||||
UINT32 S26;
|
||||
UINT32 S27;
|
||||
UINT32 S28;
|
||||
UINT32 S29;
|
||||
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;
|
||||
UINT32 uwR3;
|
||||
UINT32 uwR12;
|
||||
UINT32 uwLR;
|
||||
UINT32 uwPC;
|
||||
UINT32 uwxPSR;
|
||||
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
||||
UINT32 S0;
|
||||
UINT32 S1;
|
||||
UINT32 S2;
|
||||
UINT32 S3;
|
||||
UINT32 S4;
|
||||
UINT32 S5;
|
||||
UINT32 S6;
|
||||
UINT32 S7;
|
||||
UINT32 S8;
|
||||
UINT32 S9;
|
||||
UINT32 S10;
|
||||
UINT32 S11;
|
||||
UINT32 S12;
|
||||
UINT32 S13;
|
||||
UINT32 S14;
|
||||
UINT32 S15;
|
||||
UINT32 FPSCR;
|
||||
UINT32 NO_NAME;
|
||||
#endif
|
||||
} TaskContext;
|
||||
|
||||
/**
|
||||
* @ingroup los_config
|
||||
* @brief: Task start running function.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to start a task.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param: None.
|
||||
*
|
||||
* @retval None.
|
||||
*
|
||||
* @par Dependency:
|
||||
* <ul><li>los_config.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
extern VOID HalStartToRun(VOID);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
#endif /* _LOS_ARCH_CONTEXT_H */
|
||||
|
1867
kernel/arch/arm/cortex-m3/keil/los_interrupt.h → kernel/arch/arm/cortex-m3/keil/los_arch_interrupt.h
Executable file → Normal file
1867
kernel/arch/arm/cortex-m3/keil/los_interrupt.h → kernel/arch/arm/cortex-m3/keil/los_arch_interrupt.h
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, 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.
|
||||
*/
|
||||
|
||||
#ifndef _LOS_ARCH_TIMER_H
|
||||
#define _LOS_ARCH_TIMER_H
|
||||
|
||||
#include "los_config.h"
|
||||
#include "los_compiler.h"
|
||||
#include "los_context.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
UINT32 HalTickStart(OS_TICK_HANDLER handler);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
#endif /* _LOS_ARCH_TIMER_H */
|
||||
|
47
kernel/arch/arm/cortex-m3/keil/los_hw.c → kernel/arch/arm/cortex-m3/keil/los_context.c
Executable file → Normal file
47
kernel/arch/arm/cortex-m3/keil/los_hw.c → kernel/arch/arm/cortex-m3/keil/los_context.c
Executable file → Normal file
|
@ -28,9 +28,13 @@
|
|||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "los_config.h"
|
||||
#include "los_task.h"
|
||||
#include "securec.h"
|
||||
#include "los_interrupt.h"
|
||||
#include "los_arch_context.h"
|
||||
#include "los_arch_interrupt.h"
|
||||
#include "los_arch_timer.h"
|
||||
#include "ARMCM3.h"
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
@ -39,20 +43,32 @@ extern "C" {
|
|||
#endif /* __cplusplus */
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : OsTaskExit
|
||||
Description : Task exit function
|
||||
Function : HalArchInit
|
||||
Description : arch init function
|
||||
Input : None
|
||||
Output : None
|
||||
Return : None
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR VOID OsTaskExit(VOID)
|
||||
LITE_OS_SEC_TEXT_INIT VOID HalArchInit()
|
||||
{
|
||||
HalHwiInit();
|
||||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : HalSysExit
|
||||
Description : exit function
|
||||
Input : None
|
||||
Output : None
|
||||
Return : None
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR VOID HalSysExit(VOID)
|
||||
{
|
||||
LOS_IntLock();
|
||||
for(;;);
|
||||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : OsTskStackInit
|
||||
Function : HalTskStackInit
|
||||
Description : Task stack initialization function
|
||||
Input : taskID --- TaskID
|
||||
stackSize --- Total size of the stack
|
||||
|
@ -60,7 +76,7 @@ LITE_OS_SEC_TEXT_MINOR VOID OsTaskExit(VOID)
|
|||
Output : None
|
||||
Return : Context pointer
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_INIT VOID *OsTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
|
||||
LITE_OS_SEC_TEXT_INIT VOID *HalTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
|
||||
{
|
||||
TaskContext *context = NULL;
|
||||
errno_t result;
|
||||
|
@ -126,18 +142,27 @@ LITE_OS_SEC_TEXT_INIT VOID *OsTskStackInit(UINT32 taskID, UINT32 stackSize, VOID
|
|||
context->uwR2 = 0x02020202L;
|
||||
context->uwR3 = 0x03030303L;
|
||||
context->uwR12 = 0x12121212L;
|
||||
context->uwLR = (UINT32)(UINTPTR)OsTaskExit;
|
||||
context->uwLR = (UINT32)(UINTPTR)HalSysExit;
|
||||
context->uwPC = (UINT32)(UINTPTR)OsTaskEntry;
|
||||
context->uwxPSR = 0x01000000L;
|
||||
|
||||
return (VOID *)context;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT VOID OsEnterSleep(VOID)
|
||||
void HalBackTrace()
|
||||
{
|
||||
__DSB();
|
||||
__WFI();
|
||||
__ISB();
|
||||
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 HalStartSchedule(OS_TICK_HANDLER handler)
|
||||
{
|
||||
UINT32 ret;
|
||||
ret = HalTickStart(handler);
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
HalStartToRun();
|
||||
return LOS_OK; /* never return */
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
|
@ -31,15 +31,14 @@
|
|||
|
||||
PRESERVE8
|
||||
|
||||
EXPORT LOS_IntLock
|
||||
EXPORT LOS_IntUnLock
|
||||
EXPORT LOS_IntRestore
|
||||
EXPORT LOS_StartToRun
|
||||
EXPORT osTaskSchedule
|
||||
EXPORT osPendSV
|
||||
EXPORT HalIntLock
|
||||
EXPORT HalIntUnLock
|
||||
EXPORT HalIntRestore
|
||||
EXPORT HalStartToRun
|
||||
EXPORT HalTaskSchedule
|
||||
EXPORT HalPendSV
|
||||
|
||||
IMPORT g_losTask
|
||||
IMPORT g_taskSwitchHook
|
||||
IMPORT g_taskScheduled
|
||||
|
||||
OS_NVIC_INT_CTRL EQU 0xE000ED04
|
||||
|
@ -52,7 +51,7 @@ OS_TASK_STATUS_RUNNING EQU 0x0010
|
|||
THUMB
|
||||
REQUIRE8
|
||||
|
||||
LOS_StartToRun
|
||||
HalStartToRun
|
||||
LDR R4, =OS_NVIC_SYSPRI2
|
||||
LDR R5, =OS_NVIC_PENDSV_PRI
|
||||
STR R5, [R4]
|
||||
|
@ -94,38 +93,31 @@ LOS_StartToRun
|
|||
BX R6
|
||||
|
||||
|
||||
LOS_IntLock
|
||||
HalIntLock
|
||||
MRS R0, PRIMASK
|
||||
CPSID I
|
||||
BX LR
|
||||
|
||||
LOS_IntUnLock
|
||||
HalIntUnLock
|
||||
MRS R0, PRIMASK
|
||||
CPSIE I
|
||||
BX LR
|
||||
|
||||
LOS_IntRestore
|
||||
HalIntRestore
|
||||
MSR PRIMASK, R0
|
||||
BX LR
|
||||
|
||||
osTaskSchedule
|
||||
HalTaskSchedule
|
||||
LDR R0, =OS_NVIC_INT_CTRL
|
||||
LDR R1, =OS_NVIC_PENDSVSET
|
||||
STR R1, [R0]
|
||||
BX LR
|
||||
|
||||
osPendSV
|
||||
HalPendSV
|
||||
MRS R12, PRIMASK
|
||||
CPSID I
|
||||
|
||||
LDR R2, =g_taskSwitchHook
|
||||
LDR R2, [R2]
|
||||
CBZ R2, TaskSwitch
|
||||
PUSH {R12, LR}
|
||||
BLX R2
|
||||
POP {R12, LR}
|
||||
|
||||
TaskSwitch
|
||||
HalTaskSwitch
|
||||
MRS R0, PSP
|
||||
|
||||
STMFD R0!, {R4-R12}
|
||||
|
|
30
kernel/arch/arm/cortex-m3/keil/los_hw_exc.S → kernel/arch/arm/cortex-m3/keil/los_exc.S
Executable file → Normal file
30
kernel/arch/arm/cortex-m3/keil/los_hw_exc.S → kernel/arch/arm/cortex-m3/keil/los_exc.S
Executable file → Normal file
|
@ -33,16 +33,14 @@
|
|||
AREA |.text|, CODE, READONLY
|
||||
THUMB
|
||||
|
||||
EXPORT OsExcNMI
|
||||
EXPORT OsExcHardFault
|
||||
EXPORT OsExcMemFault
|
||||
EXPORT OsExcBusFault
|
||||
EXPORT OsExcUsageFault
|
||||
EXPORT OsExcSvcCall
|
||||
EXPORT HalExcNMI
|
||||
EXPORT HalExcHardFault
|
||||
EXPORT HalExcMemFault
|
||||
EXPORT HalExcBusFault
|
||||
EXPORT HalExcUsageFault
|
||||
EXPORT HalExcSvcCall
|
||||
|
||||
IMPORT OsExcHandleEntry
|
||||
;IMPORT g_vuwLosFlag
|
||||
;IMPORT g_curNestCount
|
||||
IMPORT HalExcHandleEntry
|
||||
IMPORT g_uwExcTbl
|
||||
IMPORT g_taskScheduled
|
||||
|
||||
|
@ -66,12 +64,12 @@ OS_NVIC_ACT_BASE EQU 0xE000E300
|
|||
OS_NVIC_SHCSRS EQU 0xE000ED24
|
||||
OS_NVIC_SHCSR_MASK EQU 0xC00
|
||||
|
||||
OsExcNMI
|
||||
HalExcNMI
|
||||
MOV R0, #OS_EXC_CAUSE_NMI
|
||||
MOV R1, #0
|
||||
B osExcDispatch
|
||||
|
||||
OsExcHardFault
|
||||
HalExcHardFault
|
||||
MOV R0, #OS_EXC_CAUSE_HARDFAULT
|
||||
LDR R2, =OS_NVIC_HFSR
|
||||
LDR R2, [R2]
|
||||
|
@ -122,7 +120,7 @@ osHFExcCommonBMU
|
|||
ORR R0, R0 ,R12
|
||||
B osExcDispatch
|
||||
|
||||
OsExcSvcCall
|
||||
HalExcSvcCall
|
||||
TST LR, #0x4
|
||||
ITE EQ
|
||||
MRSEQ R0, MSP
|
||||
|
@ -132,7 +130,7 @@ OsExcSvcCall
|
|||
MOV R1, #0
|
||||
B osExcDispatch
|
||||
|
||||
OsExcBusFault
|
||||
HalExcBusFault
|
||||
LDR R0, =OS_NVIC_FSR
|
||||
LDR R0, [R0]
|
||||
|
||||
|
@ -149,7 +147,7 @@ _ExcBusNoADDR
|
|||
MOV R12,#0
|
||||
B osExcCommonBMU
|
||||
|
||||
OsExcMemFault
|
||||
HalExcMemFault
|
||||
LDR R0, =OS_NVIC_FSR
|
||||
LDR R0, [R0]
|
||||
|
||||
|
@ -166,7 +164,7 @@ _ExcMemNoADDR
|
|||
MOV R12,#0
|
||||
B osExcCommonBMU
|
||||
|
||||
OsExcUsageFault
|
||||
HalExcUsageFault
|
||||
LDR R0, =OS_NVIC_FSR
|
||||
LDR R0, [R0]
|
||||
|
||||
|
@ -281,7 +279,7 @@ _handleEntry
|
|||
MOV R3, R13 ; R13:the 4th param
|
||||
CPSID I
|
||||
CPSID F
|
||||
B OsExcHandleEntry
|
||||
B HalExcHandleEntry
|
||||
|
||||
NOP
|
||||
END
|
|
@ -29,12 +29,11 @@
|
|||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "los_interrupt.h"
|
||||
#include "los_context.h"
|
||||
#include "los_arch_interrupt.h"
|
||||
#include <stdarg.h>
|
||||
#include "los_debug.h"
|
||||
#include "los_task.h"
|
||||
#if (LOSCFG_KERNEL_TICKLESS == YES)
|
||||
#include "los_tick.h"
|
||||
#endif
|
||||
#include "ARMCM3.h"
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
@ -43,99 +42,79 @@ extern "C" {
|
|||
#endif /* __cplusplus */
|
||||
|
||||
/*lint -save -e40 -e522 -e533*/
|
||||
__weak VOID SysTickHandler(VOID)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UINT32 g_vuwIntCount = 0;
|
||||
UINT32 g_intCount = 0;
|
||||
/*lint -restore*/
|
||||
#ifdef __ICCARM__
|
||||
#pragma location = ".data.vector"
|
||||
#elif defined(__CC_ARM) || defined(__GNUC__)
|
||||
#pragma data_alignment=0x100
|
||||
LITE_OS_SEC_VEC
|
||||
#endif
|
||||
HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {
|
||||
(HWI_PROC_FUNC)0, // [0] Top of Stack
|
||||
(HWI_PROC_FUNC)Reset_Handler, // [1] reset
|
||||
(HWI_PROC_FUNC)OsHwiDefaultHandler, // [2] NMI Handler
|
||||
(HWI_PROC_FUNC)OsHwiDefaultHandler, // [3] Hard Fault Handler
|
||||
(HWI_PROC_FUNC)OsHwiDefaultHandler, // [4] MPU Fault Handler
|
||||
(HWI_PROC_FUNC)OsHwiDefaultHandler, // [5] Bus Fault Handler
|
||||
(HWI_PROC_FUNC)OsHwiDefaultHandler, // [6] Usage Fault Handler
|
||||
(HWI_PROC_FUNC)0, // [7] Reserved
|
||||
(HWI_PROC_FUNC)0, // [8] Reserved
|
||||
(HWI_PROC_FUNC)0, // [9] Reserved
|
||||
(HWI_PROC_FUNC)0, // [10] Reserved
|
||||
(HWI_PROC_FUNC)OsHwiDefaultHandler, // [11] SVCall Handler
|
||||
(HWI_PROC_FUNC)OsHwiDefaultHandler, // [12] Debug Monitor Handler
|
||||
(HWI_PROC_FUNC)0, // [13] Reserved
|
||||
(HWI_PROC_FUNC)osPendSV, // [14] PendSV Handler
|
||||
(HWI_PROC_FUNC)SysTickHandler, // [15] SysTick Handler
|
||||
};
|
||||
HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
|
||||
|
||||
|
||||
#if (OS_HWI_WITH_ARG == YES)
|
||||
#if (OS_HWI_WITH_ARG == 1)
|
||||
HWI_SLAVE_FUNC g_hwiSlaveForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
|
||||
#else
|
||||
HWI_PROC_FUNC g_hwiSlaveForm[OS_VECTOR_CNT] = {0};
|
||||
#endif
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : OsIntNumGet
|
||||
Function : HalIntNumGet
|
||||
Description : Get a interrupt number
|
||||
Input : None
|
||||
Output : None
|
||||
Return : Interrupt Indexes number
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR UINT32 OsIntNumGet(VOID)
|
||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
||||
{
|
||||
return __get_IPSR();
|
||||
}
|
||||
|
||||
inline UINT32 HalIsIntAcvive(VOID)
|
||||
{
|
||||
return (g_intCount > 0);
|
||||
}
|
||||
/* ****************************************************************************
|
||||
Function : OsHwiDefaultHandler
|
||||
Function : HalHwiDefaultHandler
|
||||
Description : default handler of the hardware interrupt
|
||||
Input : None
|
||||
Output : None
|
||||
Return : None
|
||||
**************************************************************************** */
|
||||
/*lint -e529*/
|
||||
LITE_OS_SEC_TEXT_MINOR VOID OsHwiDefaultHandler(VOID)
|
||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||
{
|
||||
UINT32 irqNum = OsIntNumGet();
|
||||
UINT32 irqNum = HalIntNumGet();
|
||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : OsInterrupt
|
||||
Function : HalInterrupt
|
||||
Description : Hardware interrupt entry function
|
||||
Input : None
|
||||
Output : None
|
||||
Return : None
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT VOID OsInterrupt(VOID)
|
||||
LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
||||
{
|
||||
UINT32 hwiIndex;
|
||||
UINT32 intSave;
|
||||
|
||||
#if (LOSCFG_KERNEL_RUNSTOP == YES)
|
||||
#if (LOSCFG_KERNEL_RUNSTOP == 1)
|
||||
SCB->SCR &= (UINT32) ~((UINT32)SCB_SCR_SLEEPDEEP_Msk);
|
||||
#endif
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
|
||||
g_vuwIntCount++;
|
||||
g_intCount++;
|
||||
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
hwiIndex = OsIntNumGet();
|
||||
#if (LOSCFG_KERNEL_TICKLESS == YES)
|
||||
osUpdateKernelTickCount(hwiIndex);
|
||||
#endif
|
||||
hwiIndex = HalIntNumGet();
|
||||
|
||||
#if (OS_HWI_WITH_ARG == YES)
|
||||
#if (OS_HWI_WITH_ARG == 1)
|
||||
if (g_hwiSlaveForm[hwiIndex].pfnHandler != 0) {
|
||||
g_hwiSlaveForm[hwiIndex].pfnHandler((VOID *)g_hwiSlaveForm[hwiIndex].pParm);
|
||||
}
|
||||
|
@ -145,12 +124,12 @@ LITE_OS_SEC_TEXT VOID OsInterrupt(VOID)
|
|||
}
|
||||
#endif
|
||||
intSave = LOS_IntLock();
|
||||
g_vuwIntCount--;
|
||||
g_intCount--;
|
||||
LOS_IntRestore(intSave);
|
||||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : LOS_HwiCreate
|
||||
Function : HalHwiCreate
|
||||
Description : create hardware interrupt
|
||||
Input : hwiNum --- hwi num to create
|
||||
hwiPrio --- priority of the hwi
|
||||
|
@ -160,7 +139,7 @@ LITE_OS_SEC_TEXT VOID OsInterrupt(VOID)
|
|||
Output : None
|
||||
Return : LOS_OK on success or error code on failure
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 LOS_HwiCreate(HWI_HANDLE_T hwiNum,
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 HalHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
HWI_PRIOR_T hwiPrio,
|
||||
HWI_MODE_T mode,
|
||||
HWI_PROC_FUNC handler,
|
||||
|
@ -176,7 +155,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_HwiCreate(HWI_HANDLE_T hwiNum,
|
|||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)OsHwiDefaultHandler) {
|
||||
if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
|
||||
return OS_ERRNO_HWI_ALREADY_CREATED;
|
||||
}
|
||||
|
||||
|
@ -185,7 +164,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_HwiCreate(HWI_HANDLE_T hwiNum,
|
|||
}
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
#if (OS_HWI_WITH_ARG == YES)
|
||||
#if (OS_HWI_WITH_ARG == 1)
|
||||
OsSetVector(hwiNum, handler, arg);
|
||||
#else
|
||||
OsSetVector(hwiNum, handler);
|
||||
|
@ -199,13 +178,13 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_HwiCreate(HWI_HANDLE_T hwiNum,
|
|||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : LOS_HwiDelete
|
||||
Function : HalHwiDelete
|
||||
Description : Delete hardware interrupt
|
||||
Input : hwiNum --- hwi num to delete
|
||||
Output : None
|
||||
Return : LOS_OK on success or error code on failure
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 LOS_HwiDelete(HWI_HANDLE_T hwiNum)
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 HalHwiDelete(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
UINT32 intSave;
|
||||
|
||||
|
@ -217,7 +196,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_HwiDelete(HWI_HANDLE_T hwiNum)
|
|||
|
||||
intSave = LOS_IntLock();
|
||||
|
||||
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsHwiDefaultHandler;
|
||||
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
|
@ -235,9 +214,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_HwiDelete(HWI_HANDLE_T hwiNum)
|
|||
|
||||
static ExcInfoArray g_excArray[OS_EXC_TYPE_MAX];
|
||||
|
||||
UINT32 g_curNestCount = 0;
|
||||
static ExcInfo g_excInfo;
|
||||
static EVENT_CB_S g_excEvent;
|
||||
static 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,
|
||||
|
@ -246,19 +223,10 @@ UINT8 g_uwExcTbl[FAULT_STATUS_REG_BIT] = {
|
|||
0, 0, 0, OS_EXC_MF_MSTKERR, OS_EXC_MF_MUNSTKERR, 0, OS_EXC_MF_DACCVIOL, OS_EXC_MF_IACCVIOL
|
||||
};
|
||||
|
||||
__attribute__((noinline)) VOID LOS_Panic(const CHAR *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap,fmt);
|
||||
PRINT_ERR(fmt, ap);
|
||||
va_end(ap);
|
||||
asm volatile ("swi 0");
|
||||
}
|
||||
|
||||
UINT32 OsExcNvicDump(UINT32 index, UINT32 *excContent)
|
||||
UINT32 HalExcNvicDump(UINT32 index, UINT32 *excContent)
|
||||
{
|
||||
UINT32 *base = NULL;
|
||||
UINT32 len = 0,i,j;
|
||||
UINT32 len = 0, i, j;
|
||||
#define OS_NR_NVIC_EXC_DUMP_Types 7
|
||||
UINT32 rgNvicBases[OS_NR_NVIC_EXC_DUMP_Types] = {OS_NVIC_SETENA_BASE, OS_NVIC_SETPEND_BASE,
|
||||
OS_NVIC_INT_ACT_BASE, OS_NVIC_PRI_BASE, OS_NVIC_EXCPRI_BASE, OS_NVIC_SHCSR, OS_NVIC_INT_CTRL};
|
||||
|
@ -286,9 +254,10 @@ UINT32 OsExcNvicDump(UINT32 index, UINT32 *excContent)
|
|||
}
|
||||
PRINTK("\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT32 OsExcContextDump(UINT32 index, UINT32 *excContent)
|
||||
UINT32 HalExcContextDump(UINT32 index, UINT32 *excContent)
|
||||
{
|
||||
(VOID)index;
|
||||
(VOID)excContent;
|
||||
|
@ -315,9 +284,10 @@ UINT32 OsExcContextDump(UINT32 index, UINT32 *excContent)
|
|||
PRINTK("LR = 0x%x\n", g_excInfo.context->uwLR);
|
||||
PRINTK("PC = 0x%x\n", g_excInfo.context->uwPC);
|
||||
PRINTK("xPSR = 0x%x\n", g_excInfo.context->uwxPSR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
VOID OsDumpMsg(VOID)
|
||||
VOID HalDumpMsg(VOID)
|
||||
{
|
||||
UINT32 index = 0;
|
||||
for (index = 0; index < (OS_EXC_TYPE_MAX - 1); index++) {
|
||||
|
@ -328,21 +298,11 @@ VOID OsDumpMsg(VOID)
|
|||
}
|
||||
}
|
||||
|
||||
VOID OsExcNotify(VOID)
|
||||
{
|
||||
UINT32 ret = LOS_EventWrite(&g_excEvent, OS_EXC_EVENT);
|
||||
if (ret != LOS_OK) {
|
||||
PRINT_ERR("event notify failed\n");
|
||||
}
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT VOID OsExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid,
|
||||
EXC_CONTEXT_S *excBufAddr)
|
||||
LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr)
|
||||
{
|
||||
UINT16 tmpFlag = (excType >> 16) & OS_NULL_SHORT;
|
||||
g_curNestCount++;
|
||||
g_vuwIntCount++;
|
||||
g_excInfo.nestCnt = g_curNestCount;
|
||||
g_intCount++;
|
||||
g_excInfo.nestCnt++;
|
||||
|
||||
g_excInfo.type = excType & OS_NULL_SHORT;
|
||||
|
||||
|
@ -351,7 +311,6 @@ LITE_OS_SEC_TEXT_INIT VOID OsExcHandleEntry(UINT32 excType, UINT32 faultAddr, UI
|
|||
} else {
|
||||
g_excInfo.faultAddr = OS_EXC_IMPRECISE_ACCESS_ADDR;
|
||||
}
|
||||
|
||||
if (g_losTask.runTask != NULL) {
|
||||
if (tmpFlag & OS_EXC_FLAG_IN_HWI) {
|
||||
g_excInfo.phase = OS_EXC_IN_HWI;
|
||||
|
@ -364,25 +323,20 @@ LITE_OS_SEC_TEXT_INIT VOID OsExcHandleEntry(UINT32 excType, UINT32 faultAddr, UI
|
|||
g_excInfo.phase = OS_EXC_IN_INIT;
|
||||
g_excInfo.thrdPid = OS_NULL_INT;
|
||||
}
|
||||
|
||||
if (excType & OS_EXC_FLAG_NO_FLOAT) {
|
||||
g_excInfo.context = (EXC_CONTEXT_S *)((CHAR *)excBufAddr - LOS_OFF_SET_OF(EXC_CONTEXT_S, uwR4));
|
||||
} else {
|
||||
g_excInfo.context = excBufAddr;
|
||||
}
|
||||
|
||||
OsDumpMsg();
|
||||
|
||||
OsExcNotify();
|
||||
|
||||
LOS_Reboot();
|
||||
HalDumpMsg();
|
||||
HalSysExit();
|
||||
}
|
||||
|
||||
VOID OsExcRegister(ExcInfoType type, EXC_INFO_SAVE_CALLBACK func, VOID *arg)
|
||||
VOID HalExcRegister(ExcInfoType type, EXC_INFO_SAVE_CALLBACK func, VOID *arg)
|
||||
{
|
||||
ExcInfoArray *excInfo = NULL;
|
||||
if ((type >= OS_EXC_TYPE_MAX) || (func == NULL)) {
|
||||
PRINT_ERR("OsExcRegister ERROR!\n");
|
||||
PRINT_ERR("HalExcRegister ERROR!\n");
|
||||
return;
|
||||
}
|
||||
excInfo = &(g_excArray[type]);
|
||||
|
@ -392,33 +346,29 @@ VOID OsExcRegister(ExcInfoType type, EXC_INFO_SAVE_CALLBACK func, VOID *arg)
|
|||
excInfo->uwValid = TRUE;
|
||||
}
|
||||
|
||||
void OsBackTrace()
|
||||
{
|
||||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : OsHwiInit
|
||||
Function : HalHwiInit
|
||||
Description : initialization of the hardware interrupt
|
||||
Input : None
|
||||
Output : None
|
||||
Return : None
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_INIT VOID OsHwiInit()
|
||||
LITE_OS_SEC_TEXT_INIT VOID HalHwiInit()
|
||||
{
|
||||
UINT32 index;
|
||||
UINT32 ret;
|
||||
|
||||
for (index = OS_SYS_VECTOR_CNT; index < OS_VECTOR_CNT; index++) {
|
||||
g_hwiForm[index] = (HWI_PROC_FUNC)OsHwiDefaultHandler;
|
||||
g_hwiForm[0] = 0; /* [0] Top of Stack */
|
||||
g_hwiForm[1] = Reset_Handler; /* [1] reset */
|
||||
for (index = 2; index < OS_VECTOR_CNT; index++) {
|
||||
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||
}
|
||||
|
||||
/* Exception handler register */
|
||||
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = OsExcHardFault;
|
||||
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = OsExcNMI;
|
||||
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = OsExcMemFault;
|
||||
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = OsExcBusFault;
|
||||
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = OsExcUsageFault;
|
||||
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = OsExcSvcCall;
|
||||
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI;
|
||||
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault;
|
||||
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault;
|
||||
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault;
|
||||
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault;
|
||||
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalExcSvcCall;
|
||||
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV;
|
||||
|
||||
/* Interrupt vector table location */
|
||||
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
|
||||
|
@ -431,15 +381,9 @@ LITE_OS_SEC_TEXT_INIT VOID OsHwiInit()
|
|||
/* Enable DIV 0 and unaligned exception */
|
||||
*(volatile UINT32 *)OS_NVIC_CCR |= DIV0FAULT;
|
||||
|
||||
/* Init Exception Event */
|
||||
ret = LOS_EventInit(&g_excEvent);
|
||||
if (ret != LOS_OK) {
|
||||
PRINT_ERR("[EXC]init excepiton event failed!\n");
|
||||
return;
|
||||
}
|
||||
HalExcRegister(OS_EXC_TYPE_CONTEXT, (EXC_INFO_SAVE_CALLBACK)HalExcContextDump, NULL);
|
||||
HalExcRegister(OS_EXC_TYPE_NVIC, (EXC_INFO_SAVE_CALLBACK)HalExcNvicDump, NULL);
|
||||
|
||||
OsExcRegister(OS_EXC_TYPE_CONTEXT, (EXC_INFO_SAVE_CALLBACK)OsExcContextDump, NULL);
|
||||
OsExcRegister(OS_EXC_TYPE_NVIC, (EXC_INFO_SAVE_CALLBACK)OsExcNvicDump, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
6
kernel/arch/arm/cortex-m3/keil/los_vendor.s → kernel/arch/arm/cortex-m3/keil/los_startup.s
Executable file → Normal file
6
kernel/arch/arm/cortex-m3/keil/los_vendor.s → kernel/arch/arm/cortex-m3/keil/los_startup.s
Executable file → Normal file
|
@ -29,7 +29,7 @@
|
|||
THUMB
|
||||
|
||||
IMPORT ||Image$$ARM_LIB_STACKHEAP$$ZI$$Limit||
|
||||
IMPORT OsHwiDefaultHandler
|
||||
IMPORT HalHwiDefaultHandler
|
||||
|
||||
EXPORT _BootVectors
|
||||
EXPORT Reset_Handler
|
||||
|
@ -37,8 +37,8 @@
|
|||
_BootVectors
|
||||
DCD ||Image$$ARM_LIB_STACKHEAP$$ZI$$Limit||
|
||||
DCD Reset_Handler
|
||||
DCD OsHwiDefaultHandler
|
||||
DCD OsHwiDefaultHandler
|
||||
DCD HalHwiDefaultHandler
|
||||
DCD HalHwiDefaultHandler
|
||||
|
||||
|
||||
Reset_Handler
|
94
kernel/arch/arm/cortex-m3/keil/los_hw_tick.c → kernel/arch/arm/cortex-m3/keil/los_timer.c
Executable file → Normal file
94
kernel/arch/arm/cortex-m3/keil/los_hw_tick.c → kernel/arch/arm/cortex-m3/keil/los_timer.c
Executable file → Normal file
|
@ -28,29 +28,28 @@
|
|||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "los_config.h"
|
||||
#include "los_tick.h"
|
||||
#include "los_interrupt.h"
|
||||
#include "los_arch_interrupt.h"
|
||||
#include "ARMCM3.h"
|
||||
#include "los_timer.h"
|
||||
#include "los_context.h"
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
#define TICK_CHECK 0x4000000
|
||||
#define CYCLE_CHECK 0xFFFFFFFFU
|
||||
#define SHIFT_32_BIT 32
|
||||
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : OsTickStart
|
||||
Function : HalTickStart
|
||||
Description : Configure Tick Interrupt Start
|
||||
Input : none
|
||||
output : none
|
||||
return : LOS_OK - Success , or LOS_ERRNO_TICK_CFG_INVALID - failed
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 OsTickStart(VOID)
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 HalTickStart(OS_TICK_HANDLER *handler)
|
||||
{
|
||||
UINT32 ret;
|
||||
|
||||
|
@ -60,10 +59,10 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsTickStart(VOID)
|
|||
return LOS_ERRNO_TICK_CFG_INVALID;
|
||||
}
|
||||
|
||||
#if (OS_HWI_WITH_ARG == YES)
|
||||
OsSetVector(SysTick_IRQn, (HWI_PROC_FUNC)OsTickHandler, NULL);
|
||||
#if (OS_HWI_WITH_ARG == 1)
|
||||
OsSetVector(SysTick_IRQn, (HWI_PROC_FUNC)handler, NULL);
|
||||
#else
|
||||
OsSetVector(SysTick_IRQn, OsTickHandler);
|
||||
OsSetVector(SysTick_IRQn, (HWI_PROC_FUNC)handler);
|
||||
#endif
|
||||
|
||||
g_cyclesPerTick = OS_SYS_CLOCK / LOSCFG_BASE_CORE_TICK_PER_SECOND;
|
||||
|
@ -77,32 +76,14 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsTickStart(VOID)
|
|||
return LOS_OK;
|
||||
}
|
||||
|
||||
#if (LOSCFG_KERNEL_TICKLESS == YES)
|
||||
/* ****************************************************************************
|
||||
Function : LOS_SysTickReload
|
||||
Description : reconfig systick, and clear SysTick_IRQn
|
||||
Input : cyclesPerTick --- cycles Per Tick
|
||||
output : none
|
||||
return : none
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR VOID LOS_SysTickReload(UINT32 cyclesPerTick)
|
||||
{
|
||||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||
SysTick->LOAD = (UINT32)(cyclesPerTick - 1UL); /* set reload register */
|
||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : LOS_SysTickCurrCycleGet
|
||||
Function : HalSysTickCurrCycleGet
|
||||
Description : Get System cycle count
|
||||
Input : none
|
||||
output : none
|
||||
return : hwCycle --- the system cycle count
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR UINT32 LOS_SysTickCurrCycleGet(VOID)
|
||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalSysTickCurrCycleGet(VOID)
|
||||
{
|
||||
UINT32 hwCycle;
|
||||
UINTPTR intSave;
|
||||
|
@ -122,14 +103,14 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_SysTickCurrCycleGet(VOID)
|
|||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : LOS_GetCpuCycle
|
||||
Function : HalGetCpuCycle
|
||||
Description : Get System cycle count
|
||||
Input : none
|
||||
output : cntHi --- CpuTick High 4 byte
|
||||
cntLo --- CpuTick Low 4 byte
|
||||
return : none
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR VOID LOS_GetCpuCycle(UINT32 *cntHi, UINT32 *cntLo)
|
||||
LITE_OS_SEC_TEXT_MINOR VOID HalGetCpuCycle(UINT32 *cntHi, UINT32 *cntLo)
|
||||
{
|
||||
UINT64 swTick;
|
||||
UINT64 cycle;
|
||||
|
@ -158,14 +139,14 @@ LITE_OS_SEC_TEXT_MINOR VOID LOS_GetCpuCycle(UINT32 *cntHi, UINT32 *cntLo)
|
|||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : LOS_GetSystickCycle
|
||||
Function : HalGetSystickCycle
|
||||
Description : Get Sys tick cycle count
|
||||
Input : none
|
||||
output : cntHi --- SysTick count High 4 byte
|
||||
cntLo --- SysTick count Low 4 byte
|
||||
return : none
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR VOID LOS_GetSystickCycle(UINT32 *cntHi, UINT32 *cntLo)
|
||||
LITE_OS_SEC_TEXT_MINOR VOID HalGetSystickCycle(UINT32 *cntHi, UINT32 *cntLo)
|
||||
{
|
||||
UINT64 swTick;
|
||||
UINT64 cycle;
|
||||
|
@ -201,62 +182,49 @@ LITE_OS_SEC_TEXT_MINOR VOID LOS_GetSystickCycle(UINT32 *cntHi, UINT32 *cntLo)
|
|||
return;
|
||||
}
|
||||
|
||||
#define MAX_HOUR 24
|
||||
#define MAX_MINUTES 60
|
||||
#define MAX_SECONDS 60
|
||||
#define MILSEC 1000
|
||||
#define RTC_WAKEUPCLOCK_RTCCLK 32768
|
||||
#define RTC_WAKEUPCLOCK_RTCCLK_DIV 16
|
||||
#define RTC_CALIBRATE_SLEEP_TIME 8
|
||||
#define MACHINE_CYCLE_DEALAY_TIMES 4000
|
||||
|
||||
static BOOL g_sysSleepFlag = FALSE;
|
||||
|
||||
VOID LOS_TickLock(VOID)
|
||||
VOID HalTickLock(VOID)
|
||||
{
|
||||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
}
|
||||
|
||||
VOID LOS_TickUnlock(VOID)
|
||||
VOID HalTickUnlock(VOID)
|
||||
{
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||
}
|
||||
|
||||
BOOL LOS_GetSysSleepFlag(VOID)
|
||||
BOOL HalGetSysSleepFlag(VOID)
|
||||
{
|
||||
return g_sysSleepFlag;
|
||||
}
|
||||
|
||||
VOID LOS_ClearSysSleepFlag(VOID)
|
||||
VOID HalClearSysSleepFlag(VOID)
|
||||
{
|
||||
g_sysSleepFlag = FALSE;
|
||||
}
|
||||
|
||||
VOID LOS_EnterSleep(LOS_SysSleepEnum sleep)
|
||||
VOID HalEnterSleep(LOS_SysSleepEnum sleep)
|
||||
{
|
||||
__DSB();
|
||||
__WFI();
|
||||
__ISB();
|
||||
}
|
||||
|
||||
VOID LOS_SystemWakeup(UINT32 hwiIndex)
|
||||
{
|
||||
}
|
||||
//extern unsigned int SystemCoreClock;
|
||||
void LOS_HalDelay(UINT32 ticks)
|
||||
void HalDelay(UINT32 ticks)
|
||||
{
|
||||
UINT32 delayTimes;
|
||||
#if 0
|
||||
/* there are 4 machine cycle in loop */
|
||||
if ((ticks * (SystemCoreClock / MACHINE_CYCLE_DEALAY_TIMES)) >= 0xffffffff) {
|
||||
delayTimes = 0xffffffff;
|
||||
} else {
|
||||
delayTimes = ticks * (SystemCoreClock / MACHINE_CYCLE_DEALAY_TIMES);
|
||||
}
|
||||
|
||||
while (delayTimes) {
|
||||
delayTimes = delayTimes - 1;
|
||||
}
|
||||
UINT32 delayTimes;
|
||||
/* there are 4 machine cycle in loop */
|
||||
if ((ticks * (SystemCoreClock / MACHINE_CYCLE_DEALAY_TIMES)) >= 0xffffffff) {
|
||||
delayTimes = 0xffffffff;
|
||||
} else {
|
||||
delayTimes = ticks * (SystemCoreClock / MACHINE_CYCLE_DEALAY_TIMES);
|
||||
}
|
||||
while (delayTimes) {
|
||||
delayTimes = delayTimes - 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
@ -0,0 +1,161 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, 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.
|
||||
*/
|
||||
|
||||
#ifndef LOS_ATOMIC_H
|
||||
#define LOS_ATOMIC_H
|
||||
|
||||
#include "los_compiler.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/**
|
||||
* @ingroup los_atomic
|
||||
* @brief Atomic exchange for 32-bit variable.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to implement the atomic exchange for 32-bit variable and return the previous value of the atomic variable.
|
||||
* @attention
|
||||
* <ul>The pointer v must not be NULL.</ul>
|
||||
*
|
||||
* @param v [IN] The variable pointer.
|
||||
* @param val [IN] The exchange value.
|
||||
*
|
||||
* @retval #INT32 The previous value of the atomic variable
|
||||
* @par Dependency:
|
||||
* <ul><li>los_atomic.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see
|
||||
* @since Huawei LiteOS V100R001C00
|
||||
*/
|
||||
STATIC INLINE INT32 HalAtomicXchg32bits(volatile INT32 *v, INT32 val)
|
||||
{
|
||||
INT32 prevVal = 0;
|
||||
UINT32 status = 0;
|
||||
|
||||
do {
|
||||
__asm__ __volatile__("ldrex %0, [%3]\n"
|
||||
"strex %1, %4, [%3]"
|
||||
: "=&r"(prevVal), "=&r"(status), "+m"(*v)
|
||||
: "r"(v), "r"(val)
|
||||
: "cc");
|
||||
} while (__builtin_expect(status != 0, 0));
|
||||
|
||||
return prevVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup los_atomic
|
||||
* @brief Atomic auto-decrement.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to implementating the atomic auto-decrement and return the result of auto-decrement.
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>The pointer v must not be NULL.</li>
|
||||
* <li>The value which v point to must not be INT_MIN to avoid overflow after reducing 1.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param v [IN] The addSelf variable pointer.
|
||||
*
|
||||
* @retval #INT32 The return value of variable auto-decrement.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_atomic.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see
|
||||
* @since Huawei LiteOS V100R001C00
|
||||
*/
|
||||
STATIC INLINE INT32 HalAtomicDecRet(volatile INT32 *v)
|
||||
{
|
||||
INT32 val = 0;
|
||||
UINT32 status = 0;
|
||||
|
||||
do {
|
||||
__asm__ __volatile__("ldrex %0, [%3]\n"
|
||||
"sub %0, %0, #1\n"
|
||||
"strex %1, %0, [%3]"
|
||||
: "=&r"(val), "=&r"(status), "+m"(*v)
|
||||
: "r"(v)
|
||||
: "cc");
|
||||
} while (__builtin_expect(status != 0, 0));
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup los_atomic
|
||||
* @brief Atomic exchange for 32-bit variable with compare.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to implement the atomic exchange for 32-bit variable, if the value of variable is equal to oldVal.
|
||||
* @attention
|
||||
* <ul>The pointer v must not be NULL.</ul>
|
||||
*
|
||||
* @param v [IN] The variable pointer.
|
||||
* @param val [IN] The new value.
|
||||
* @param oldVal [IN] The old value.
|
||||
*
|
||||
* @retval TRUE The previous value of the atomic variable is not equal to oldVal.
|
||||
* @retval FALSE The previous value of the atomic variable is equal to oldVal.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_atomic.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see
|
||||
* @since Huawei LiteOS V100R001C00
|
||||
*/
|
||||
STATIC INLINE BOOL HalAtomicCmpXchg32bits(volatile INT32 *v, INT32 val, INT32 oldVal)
|
||||
{
|
||||
INT32 prevVal = 0;
|
||||
UINT32 status = 0;
|
||||
|
||||
do {
|
||||
__asm__ __volatile__("1: ldrex %0, %2\n"
|
||||
" mov %1, #0\n"
|
||||
" cmp %0, %3\n"
|
||||
" bne 2f\n"
|
||||
" strex %1, %4, %2\n"
|
||||
"2:"
|
||||
: "=&r"(prevVal), "=&r"(status), "+Q"(*v)
|
||||
: "r"(oldVal), "r"(val)
|
||||
: "cc");
|
||||
} while (__builtin_expect(status != 0, 0));
|
||||
|
||||
return prevVal != oldVal;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* LOS_ATOMIC_H */
|
||||
|
325
kernel/arch/arm/cortex-m4/iar/los_context.h → kernel/arch/arm/cortex-m4/iar/los_arch_context.h
Executable file → Normal file
325
kernel/arch/arm/cortex-m4/iar/los_context.h → kernel/arch/arm/cortex-m4/iar/los_arch_context.h
Executable file → Normal file
|
@ -1,194 +1,131 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup los_hw hardware
|
||||
* @ingroup kernel
|
||||
*/
|
||||
|
||||
#ifndef _LOS_HW_H
|
||||
#define _LOS_HW_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* *
|
||||
* @ingroup los_hw
|
||||
* The initialization value of stack space.
|
||||
*/
|
||||
#define EMPTY_STACK 0xCACA
|
||||
|
||||
/* *
|
||||
* @ingroup los_hw
|
||||
* Trigger a task.
|
||||
*/
|
||||
#define OsTaskTrap() __asm(" TRAP #31")
|
||||
|
||||
/* *
|
||||
* @ingroup los_hw
|
||||
* Check task schedule.
|
||||
*/
|
||||
#define LOS_CHECK_SCHEDULE ((!g_losTaskLock))
|
||||
|
||||
/* *
|
||||
* @ingroup los_hw
|
||||
* Define the type of a task context control block.
|
||||
*/
|
||||
typedef struct tagTskContext {
|
||||
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
||||
UINT32 S16;
|
||||
UINT32 S17;
|
||||
UINT32 S18;
|
||||
UINT32 S19;
|
||||
UINT32 S20;
|
||||
UINT32 S21;
|
||||
UINT32 S22;
|
||||
UINT32 S23;
|
||||
UINT32 S24;
|
||||
UINT32 S25;
|
||||
UINT32 S26;
|
||||
UINT32 S27;
|
||||
UINT32 S28;
|
||||
UINT32 S29;
|
||||
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;
|
||||
UINT32 uwR3;
|
||||
UINT32 uwR12;
|
||||
UINT32 uwLR;
|
||||
UINT32 uwPC;
|
||||
UINT32 uwxPSR;
|
||||
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
||||
UINT32 S0;
|
||||
UINT32 S1;
|
||||
UINT32 S2;
|
||||
UINT32 S3;
|
||||
UINT32 S4;
|
||||
UINT32 S5;
|
||||
UINT32 S6;
|
||||
UINT32 S7;
|
||||
UINT32 S8;
|
||||
UINT32 S9;
|
||||
UINT32 S10;
|
||||
UINT32 S11;
|
||||
UINT32 S12;
|
||||
UINT32 S13;
|
||||
UINT32 S14;
|
||||
UINT32 S15;
|
||||
UINT32 FPSCR;
|
||||
UINT32 NO_NAME;
|
||||
#endif
|
||||
} TaskContext;
|
||||
|
||||
/* *
|
||||
* @ingroup los_hw
|
||||
* @brief: Task stack initialization.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to initialize the task stack.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param taskID [IN] Type#UINT32: TaskID.
|
||||
* @param stackSize [IN] Type#UINT32: Total size of the stack.
|
||||
* @param topStack [IN] Type#VOID *: Top of task's stack.
|
||||
*
|
||||
* @retval: context Type#TaskContext *.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_hw.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
extern VOID *OsTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack);
|
||||
|
||||
/**
|
||||
* @ingroup los_hw
|
||||
* @brief: Function to task exit.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to exit task.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @retval: None.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_hw.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
LITE_OS_SEC_TEXT_MINOR VOID OsTaskExit(VOID);
|
||||
|
||||
/* *
|
||||
* @ingroup los_hw
|
||||
* @brief: The M3 wait interrupt instruction.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to make CPU enter to power-save mode.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @retval: None.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_hw.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
extern VOID OsEnterSleep(VOID);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _LOS_HW_H */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, 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.
|
||||
*/
|
||||
|
||||
#ifndef _LOS_ARCH_CONTEXT_H
|
||||
#define _LOS_ARCH_CONTEXT_H
|
||||
|
||||
#include "los_config.h"
|
||||
#include "los_compiler.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
typedef struct tagTskContext {
|
||||
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
||||
UINT32 S16;
|
||||
UINT32 S17;
|
||||
UINT32 S18;
|
||||
UINT32 S19;
|
||||
UINT32 S20;
|
||||
UINT32 S21;
|
||||
UINT32 S22;
|
||||
UINT32 S23;
|
||||
UINT32 S24;
|
||||
UINT32 S25;
|
||||
UINT32 S26;
|
||||
UINT32 S27;
|
||||
UINT32 S28;
|
||||
UINT32 S29;
|
||||
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;
|
||||
UINT32 uwR3;
|
||||
UINT32 uwR12;
|
||||
UINT32 uwLR;
|
||||
UINT32 uwPC;
|
||||
UINT32 uwxPSR;
|
||||
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
||||
UINT32 S0;
|
||||
UINT32 S1;
|
||||
UINT32 S2;
|
||||
UINT32 S3;
|
||||
UINT32 S4;
|
||||
UINT32 S5;
|
||||
UINT32 S6;
|
||||
UINT32 S7;
|
||||
UINT32 S8;
|
||||
UINT32 S9;
|
||||
UINT32 S10;
|
||||
UINT32 S11;
|
||||
UINT32 S12;
|
||||
UINT32 S13;
|
||||
UINT32 S14;
|
||||
UINT32 S15;
|
||||
UINT32 FPSCR;
|
||||
UINT32 NO_NAME;
|
||||
#endif
|
||||
} TaskContext;
|
||||
|
||||
/**
|
||||
* @ingroup los_config
|
||||
* @brief: Task start running function.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to start a task.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param: None.
|
||||
*
|
||||
* @retval None.
|
||||
*
|
||||
* @par Dependency:
|
||||
* <ul><li>los_config.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
extern VOID HalStartToRun(VOID);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
#endif /* _LOS_ARCH_CONTEXT_H */
|
||||
|
1867
kernel/arch/arm/cortex-m4/iar/los_interrupt.h → kernel/arch/arm/cortex-m4/iar/los_arch_interrupt.h
Executable file → Normal file
1867
kernel/arch/arm/cortex-m4/iar/los_interrupt.h → kernel/arch/arm/cortex-m4/iar/los_arch_interrupt.h
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, 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.
|
||||
*/
|
||||
|
||||
#ifndef _LOS_ARCH_TIMER_H
|
||||
#define _LOS_ARCH_TIMER_H
|
||||
|
||||
#include "los_config.h"
|
||||
#include "los_compiler.h"
|
||||
#include "los_context.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
UINT32 HalTickStart(OS_TICK_HANDLER handler);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
#endif /* _LOS_ARCH_TIMER_H */
|
||||
|
46
kernel/arch/arm/cortex-m4/iar/los_hw.c → kernel/arch/arm/cortex-m4/iar/los_context.c
Executable file → Normal file
46
kernel/arch/arm/cortex-m4/iar/los_hw.c → kernel/arch/arm/cortex-m4/iar/los_context.c
Executable file → Normal file
|
@ -28,9 +28,14 @@
|
|||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "los_config.h"
|
||||
#include "los_task.h"
|
||||
#include "securec.h"
|
||||
#include "los_interrupt.h"
|
||||
#include "los_arch_context.h"
|
||||
#include "los_arch_interrupt.h"
|
||||
#include "los_arch_timer.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
|
@ -38,20 +43,32 @@ extern "C" {
|
|||
#endif /* __cplusplus */
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : OsTaskExit
|
||||
Function : HalArchInit
|
||||
Description : arch init function
|
||||
Input : None
|
||||
Output : None
|
||||
Return : None
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_INIT VOID HalArchInit()
|
||||
{
|
||||
HalHwiInit();
|
||||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : HalSysExit
|
||||
Description : Task exit function
|
||||
Input : None
|
||||
Output : None
|
||||
Return : None
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR VOID OsTaskExit(VOID)
|
||||
LITE_OS_SEC_TEXT_MINOR VOID HalSysExit(VOID)
|
||||
{
|
||||
LOS_IntLock();
|
||||
for(;;);
|
||||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : OsTskStackInit
|
||||
Function : HalTskStackInit
|
||||
Description : Task stack initialization function
|
||||
Input : taskID --- TaskID
|
||||
stackSize --- Total size of the stack
|
||||
|
@ -59,7 +76,7 @@ LITE_OS_SEC_TEXT_MINOR VOID OsTaskExit(VOID)
|
|||
Output : None
|
||||
Return : Context pointer
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_INIT VOID *OsTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
|
||||
LITE_OS_SEC_TEXT_INIT VOID *HalTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
|
||||
{
|
||||
TaskContext *context = NULL;
|
||||
errno_t result;
|
||||
|
@ -125,18 +142,27 @@ LITE_OS_SEC_TEXT_INIT VOID *OsTskStackInit(UINT32 taskID, UINT32 stackSize, VOID
|
|||
context->uwR2 = 0x02020202L;
|
||||
context->uwR3 = 0x03030303L;
|
||||
context->uwR12 = 0x12121212L;
|
||||
context->uwLR = (UINT32)(UINTPTR)OsTaskExit;
|
||||
context->uwLR = (UINT32)(UINTPTR)HalSysExit;
|
||||
context->uwPC = (UINT32)(UINTPTR)OsTaskEntry;
|
||||
context->uwxPSR = 0x01000000L;
|
||||
|
||||
return (VOID *)context;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT VOID OsEnterSleep(VOID)
|
||||
void HalBackTrace()
|
||||
{
|
||||
__DSB();
|
||||
__WFI();
|
||||
__ISB();
|
||||
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 HalStartSchedule(OS_TICK_HANDLER handler)
|
||||
{
|
||||
UINT32 ret;
|
||||
ret = HalTickStart(handler);
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
HalStartToRun();
|
||||
return LOS_OK; /* never return */
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
|
@ -31,15 +31,14 @@
|
|||
|
||||
PRESERVE8
|
||||
|
||||
EXPORT LOS_IntLock
|
||||
EXPORT LOS_IntUnLock
|
||||
EXPORT LOS_IntRestore
|
||||
EXPORT LOS_StartToRun
|
||||
EXPORT osTaskSchedule
|
||||
EXPORT osPendSV
|
||||
EXPORT HalIntLock
|
||||
EXPORT HalIntUnLock
|
||||
EXPORT HalIntRestore
|
||||
EXPORT HalStartToRun
|
||||
EXPORT HalTaskSchedule
|
||||
EXPORT HalPendSV
|
||||
|
||||
IMPORT g_losTask
|
||||
IMPORT g_taskSwitchHook
|
||||
IMPORT g_taskScheduled
|
||||
|
||||
OS_NVIC_INT_CTRL EQU 0xE000ED04
|
||||
|
@ -52,7 +51,7 @@ OS_TASK_STATUS_RUNNING EQU 0x0010
|
|||
THUMB
|
||||
REQUIRE8
|
||||
|
||||
LOS_StartToRun
|
||||
HalStartToRun
|
||||
LDR R4, =OS_NVIC_SYSPRI2
|
||||
LDR R5, =OS_NVIC_PENDSV_PRI
|
||||
STR R5, [R4]
|
||||
|
@ -93,38 +92,31 @@ LOS_StartToRun
|
|||
BX R6
|
||||
|
||||
|
||||
LOS_IntLock
|
||||
HalIntLock
|
||||
MRS R0, PRIMASK
|
||||
CPSID I
|
||||
BX LR
|
||||
|
||||
LOS_IntUnLock
|
||||
HalIntUnLock
|
||||
MRS R0, PRIMASK
|
||||
CPSIE I
|
||||
BX LR
|
||||
|
||||
LOS_IntRestore
|
||||
HalIntRestore
|
||||
MSR PRIMASK, R0
|
||||
BX LR
|
||||
|
||||
osTaskSchedule
|
||||
HalTaskSchedule
|
||||
LDR R0, =OS_NVIC_INT_CTRL
|
||||
LDR R1, =OS_NVIC_PENDSVSET
|
||||
STR R1, [R0]
|
||||
BX LR
|
||||
|
||||
osPendSV
|
||||
HalPendSV
|
||||
MRS R12, PRIMASK
|
||||
CPSID I
|
||||
|
||||
LDR R2, =g_taskSwitchHook
|
||||
LDR R2, [R2]
|
||||
CBZ R2, TaskSwitch
|
||||
PUSH {R12, LR}
|
||||
BLX R2
|
||||
POP {R12, LR}
|
||||
|
||||
TaskSwitch
|
||||
HalTaskSwitch
|
||||
MRS R0, PSP
|
||||
|
||||
STMFD R0!, {R4-R12}
|
||||
|
|
30
kernel/arch/arm/cortex-m4/iar/los_hw_exc.S → kernel/arch/arm/cortex-m4/iar/los_exc.S
Executable file → Normal file
30
kernel/arch/arm/cortex-m4/iar/los_hw_exc.S → kernel/arch/arm/cortex-m4/iar/los_exc.S
Executable file → Normal file
|
@ -33,16 +33,14 @@
|
|||
SECTION .text:CODE(2)
|
||||
THUMB
|
||||
|
||||
EXPORT OsExcNMI
|
||||
EXPORT OsExcHardFault
|
||||
EXPORT OsExcMemFault
|
||||
EXPORT OsExcBusFault
|
||||
EXPORT OsExcUsageFault
|
||||
EXPORT OsExcSvcCall
|
||||
EXPORT HalExcNMI
|
||||
EXPORT HalExcHardFault
|
||||
EXPORT HalExcMemFault
|
||||
EXPORT HalExcBusFault
|
||||
EXPORT HalExcUsageFault
|
||||
EXPORT HalExcSvcCall
|
||||
|
||||
IMPORT OsExcHandleEntry
|
||||
IMPORT g_vuwLosFlag
|
||||
IMPORT g_uwCurNestCount
|
||||
IMPORT HalExcHandleEntry
|
||||
IMPORT g_uwExcTbl
|
||||
IMPORT g_taskScheduled
|
||||
|
||||
|
@ -66,12 +64,12 @@ OS_NVIC_ACT_BASE EQU 0xE000E300
|
|||
OS_NVIC_SHCSRS EQU 0xE000ED24
|
||||
OS_NVIC_SHCSR_MASK EQU 0xC00
|
||||
|
||||
OsExcNMI
|
||||
HalExcNMI
|
||||
MOV R0, #OS_EXC_CAUSE_NMI
|
||||
MOV R1, #0
|
||||
B osExcDispatch
|
||||
|
||||
OsExcHardFault
|
||||
HalExcHardFault
|
||||
MOV R0, #OS_EXC_CAUSE_HARDFAULT
|
||||
LDR R2, =OS_NVIC_HFSR
|
||||
LDR R2, [R2]
|
||||
|
@ -122,7 +120,7 @@ osHFExcCommonBMU
|
|||
ORR R0, R0 ,R12
|
||||
B osExcDispatch
|
||||
|
||||
OsExcSvcCall
|
||||
HalExcSvcCall
|
||||
TST LR, #0x4
|
||||
ITE EQ
|
||||
MRSEQ R0, MSP
|
||||
|
@ -132,7 +130,7 @@ OsExcSvcCall
|
|||
MOV R1, #0
|
||||
B osExcDispatch
|
||||
|
||||
OsExcBusFault
|
||||
HalExcBusFault
|
||||
LDR R0, =OS_NVIC_FSR
|
||||
LDR R0, [R0]
|
||||
|
||||
|
@ -149,7 +147,7 @@ _ExcBusNoADDR
|
|||
MOV R12,#0
|
||||
B osExcCommonBMU
|
||||
|
||||
OsExcMemFault
|
||||
HalExcMemFault
|
||||
LDR R0, =OS_NVIC_FSR
|
||||
LDR R0, [R0]
|
||||
|
||||
|
@ -166,7 +164,7 @@ _ExcMemNoADDR
|
|||
MOV R12,#0
|
||||
B osExcCommonBMU
|
||||
|
||||
OsExcUsageFault
|
||||
HalExcUsageFault
|
||||
LDR R0, =OS_NVIC_FSR
|
||||
LDR R0, [R0]
|
||||
|
||||
|
@ -281,7 +279,7 @@ _handleEntry
|
|||
MOV R3, R13 ; R13:the 4th param
|
||||
CPSID I
|
||||
CPSID F
|
||||
B OsExcHandleEntry
|
||||
B HalExcHandleEntry
|
||||
|
||||
NOP
|
||||
END
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue