diff --git a/.gitee/ISSUE_TEMPLATE.zh-CN.md b/.gitee/ISSUE_TEMPLATE.zh-CN.md
old mode 100755
new mode 100644
diff --git a/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md b/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md
old mode 100755
new mode 100644
diff --git a/.gitignore b/.gitignore
old mode 100755
new mode 100644
diff --git a/arch_spec.md b/arch_spec.md
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/COPYRIGHT.OpenSource b/components/bounds_checking_function/COPYRIGHT.OpenSource
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/LICENSE b/components/bounds_checking_function/LICENSE
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/README.OpenSource b/components/bounds_checking_function/README.OpenSource
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/README.en.md b/components/bounds_checking_function/README.en.md
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/README.md b/components/bounds_checking_function/README.md
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/include/securec.h b/components/bounds_checking_function/include/securec.h
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/include/securectype.h b/components/bounds_checking_function/include/securectype.h
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/fscanf_s.c b/components/bounds_checking_function/src/fscanf_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/fwscanf_s.c b/components/bounds_checking_function/src/fwscanf_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/gets_s.c b/components/bounds_checking_function/src/gets_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/input.inl b/components/bounds_checking_function/src/input.inl
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/memcpy_s.c b/components/bounds_checking_function/src/memcpy_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/memmove_s.c b/components/bounds_checking_function/src/memmove_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/memset_s.c b/components/bounds_checking_function/src/memset_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/output.inl b/components/bounds_checking_function/src/output.inl
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/scanf_s.c b/components/bounds_checking_function/src/scanf_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/secinput.h b/components/bounds_checking_function/src/secinput.h
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/securecutil.c b/components/bounds_checking_function/src/securecutil.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/securecutil.h b/components/bounds_checking_function/src/securecutil.h
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/secureinput_a.c b/components/bounds_checking_function/src/secureinput_a.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/secureinput_w.c b/components/bounds_checking_function/src/secureinput_w.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/secureprintoutput.h b/components/bounds_checking_function/src/secureprintoutput.h
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/secureprintoutput_a.c b/components/bounds_checking_function/src/secureprintoutput_a.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/secureprintoutput_w.c b/components/bounds_checking_function/src/secureprintoutput_w.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/snprintf_s.c b/components/bounds_checking_function/src/snprintf_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/sprintf_s.c b/components/bounds_checking_function/src/sprintf_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/sscanf_s.c b/components/bounds_checking_function/src/sscanf_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/strcat_s.c b/components/bounds_checking_function/src/strcat_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/strcpy_s.c b/components/bounds_checking_function/src/strcpy_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/strncat_s.c b/components/bounds_checking_function/src/strncat_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/strncpy_s.c b/components/bounds_checking_function/src/strncpy_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/strtok_s.c b/components/bounds_checking_function/src/strtok_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/swprintf_s.c b/components/bounds_checking_function/src/swprintf_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/swscanf_s.c b/components/bounds_checking_function/src/swscanf_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/vfscanf_s.c b/components/bounds_checking_function/src/vfscanf_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/vfwscanf_s.c b/components/bounds_checking_function/src/vfwscanf_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/vscanf_s.c b/components/bounds_checking_function/src/vscanf_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/vsnprintf_s.c b/components/bounds_checking_function/src/vsnprintf_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/vsprintf_s.c b/components/bounds_checking_function/src/vsprintf_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/vsscanf_s.c b/components/bounds_checking_function/src/vsscanf_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/vswprintf_s.c b/components/bounds_checking_function/src/vswprintf_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/vswscanf_s.c b/components/bounds_checking_function/src/vswscanf_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/vwscanf_s.c b/components/bounds_checking_function/src/vwscanf_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/wcscat_s.c b/components/bounds_checking_function/src/wcscat_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/wcscpy_s.c b/components/bounds_checking_function/src/wcscpy_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/wcsncat_s.c b/components/bounds_checking_function/src/wcsncat_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/wcsncpy_s.c b/components/bounds_checking_function/src/wcsncpy_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/wcstok_s.c b/components/bounds_checking_function/src/wcstok_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/wmemcpy_s.c b/components/bounds_checking_function/src/wmemcpy_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/wmemmove_s.c b/components/bounds_checking_function/src/wmemmove_s.c
old mode 100755
new mode 100644
diff --git a/components/bounds_checking_function/src/wscanf_s.c b/components/bounds_checking_function/src/wscanf_s.c
old mode 100755
new mode 100644
diff --git a/components/cppsupport/los_cppsupport.c b/components/cppsupport/los_cppsupport.c
old mode 100755
new mode 100644
diff --git a/components/cppsupport/los_cppsupport.h b/components/cppsupport/los_cppsupport.h
old mode 100755
new mode 100644
diff --git a/components/cpup/los_cpup.c b/components/cpup/los_cpup.c
old mode 100755
new mode 100644
index 8a01145f..74151b22
--- a/components/cpup/los_cpup.c
+++ b/components/cpup/los_cpup.c
@@ -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
diff --git a/components/cpup/los_cpup.h b/components/cpup/los_cpup.h
old mode 100755
new mode 100644
diff --git a/kal/BUILD.gn b/kal/BUILD.gn
deleted file mode 100755
index 6fbdf621..00000000
--- a/kal/BUILD.gn
+++ /dev/null
@@ -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.
- ]
-}
diff --git a/kal/cmsis/BUILD.gn b/kal/cmsis/BUILD.gn
deleted file mode 100755
index eea54fcb..00000000
--- a/kal/cmsis/BUILD.gn
+++ /dev/null
@@ -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" ]
-}
diff --git a/kal/cmsis/cmsis_liteos.c b/kal/cmsis/cmsis_liteos.c
old mode 100755
new mode 100644
diff --git a/kal/cmsis/cmsis_liteos2.c b/kal/cmsis/cmsis_liteos2.c
old mode 100755
new mode 100644
index 6ed8b135..80bb11b3
--- a/kal/cmsis/cmsis_liteos2.c
+++ b/kal/cmsis/cmsis_liteos2.c
@@ -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;
diff --git a/kal/cmsis/cmsis_os.h b/kal/cmsis/cmsis_os.h
old mode 100755
new mode 100644
index 824e9fea..d1763533
--- a/kal/cmsis/cmsis_os.h
+++ b/kal/cmsis/cmsis_os.h
@@ -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_ */
diff --git a/kal/cmsis/cmsis_os2.h b/kal/cmsis/cmsis_os2.h
old mode 100755
new mode 100644
index d688ddf0..d4e1436b
--- a/kal/cmsis/cmsis_os2.h
+++ b/kal/cmsis/cmsis_os2.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
diff --git a/kal/cmsis/hos_cmsis_adp.h b/kal/cmsis/hos_cmsis_adp.h
old mode 100755
new mode 100644
index b576b686..ac477169
--- a/kal/cmsis/hos_cmsis_adp.h
+++ b/kal/cmsis/hos_cmsis_adp.h
@@ -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
diff --git a/kernel/src/mm/los_memstat.c b/kal/kal.c
old mode 100755
new mode 100644
similarity index 51%
rename from kernel/src/mm/los_memstat.c
rename to kal/kal.c
index e244cebd..0c41efee
--- a/kernel/src/mm/los_memstat.c
+++ b/kal/kal.c
@@ -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 */
\ No newline at end of file
diff --git a/kal/kal.h b/kal/kal.h
new file mode 100644
index 00000000..9a5605e9
--- /dev/null
+++ b/kal/kal.h
@@ -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 */
\ No newline at end of file
diff --git a/kal/kal/BUILD.gn b/kal/kal/BUILD.gn
deleted file mode 100755
index 91ae225c..00000000
--- a/kal/kal/BUILD.gn
+++ /dev/null
@@ -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" ]
-}
diff --git a/kal/kal/kal.c b/kal/kal/kal.c
deleted file mode 100755
index 5c6d5006..00000000
--- a/kal/kal/kal.c
+++ /dev/null
@@ -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;
-}
diff --git a/kal/kal/kal.h b/kal/kal/kal.h
deleted file mode 100755
index 142f2ee3..00000000
--- a/kal/kal/kal.h
+++ /dev/null
@@ -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 0 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_
-
-/* * @} */
\ No newline at end of file
diff --git a/kal/posix/BUILD.gn b/kal/posix/BUILD.gn
deleted file mode 100755
index 96a63523..00000000
--- a/kal/posix/BUILD.gn
+++ /dev/null
@@ -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" ]
-}
diff --git a/kal/posix/include/README b/kal/posix/include/README
old mode 100755
new mode 100644
diff --git a/kal/posix/include/version.h b/kal/posix/include/version.h
old mode 100755
new mode 100644
diff --git a/kal/posix/src/file.c b/kal/posix/src/file.c
old mode 100755
new mode 100644
diff --git a/kal/posix/src/pthread.c b/kal/posix/src/pthread.c
old mode 100755
new mode 100644
index 4f690fb8..f7789932
--- a/kal/posix/src/pthread.c
+++ b/kal/posix/src/pthread.c
@@ -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);
diff --git a/kal/posix/src/pthread_attr.c b/kal/posix/src/pthread_attr.c
old mode 100755
new mode 100644
diff --git a/kal/posix/src/time.c b/kal/posix/src/time.c
old mode 100755
new mode 100644
diff --git a/kal/posix/src/version.c b/kal/posix/src/version.c
old mode 100755
new mode 100644
diff --git a/kernel/arch/arm/cortex-m3/keil/cmsis/ARMCM3.h b/kernel/arch/arm/cortex-m3/keil/cmsis/ARMCM3.h
old mode 100755
new mode 100644
diff --git a/kernel/arch/arm/cortex-m3/keil/cmsis/core_cm3.h b/kernel/arch/arm/cortex-m3/keil/cmsis/core_cm3.h
old mode 100755
new mode 100644
diff --git a/kernel/arch/arm/cortex-m3/keil/cmsis/core_cmFunc.h b/kernel/arch/arm/cortex-m3/keil/cmsis/core_cmFunc.h
old mode 100755
new mode 100644
diff --git a/kernel/arch/arm/cortex-m3/keil/cmsis/core_cmInstr.h b/kernel/arch/arm/cortex-m3/keil/cmsis/core_cmInstr.h
old mode 100755
new mode 100644
diff --git a/kernel/arch/arm/cortex-m3/keil/los_arch_atomic.h b/kernel/arch/arm/cortex-m3/keil/los_arch_atomic.h
new file mode 100644
index 00000000..2e6121c3
--- /dev/null
+++ b/kernel/arch/arm/cortex-m3/keil/los_arch_atomic.h
@@ -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
+ *
The pointer v must not be NULL.
+ *
+ * @param v [IN] The variable pointer.
+ * @param val [IN] The exchange value.
+ *
+ * @retval #INT32 The previous value of the atomic variable
+ * @par Dependency:
+ * los_atomic.h: the header file that contains the API declaration.
+ * @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
+ *
+ * The pointer v must not be NULL.
+ * The value which v point to must not be INT_MIN to avoid overflow after reducing 1.
+ *
+ *
+ * @param v [IN] The addSelf variable pointer.
+ *
+ * @retval #INT32 The return value of variable auto-decrement.
+ * @par Dependency:
+ * los_atomic.h: the header file that contains the API declaration.
+ * @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
+ * The pointer v must not be NULL.
+ *
+ * @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:
+ * los_atomic.h: the header file that contains the API declaration.
+ * @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 */
+
diff --git a/kernel/arch/arm/cortex-m3/keil/los_context.h b/kernel/arch/arm/cortex-m3/keil/los_arch_context.h
old mode 100755
new mode 100644
similarity index 59%
rename from kernel/arch/arm/cortex-m3/keil/los_context.h
rename to kernel/arch/arm/cortex-m3/keil/los_arch_context.h
index d3ec0bd9..4759cb69
--- a/kernel/arch/arm/cortex-m3/keil/los_context.h
+++ b/kernel/arch/arm/cortex-m3/keil/los_arch_context.h
@@ -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:
- *
- *
- * @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:
- * los_hw.h: the header file that contains the API declaration.
- * @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:
- *
- *
- * @param None.
- *
- * @retval: None.
- * @par Dependency:
- * los_hw.h: the header file that contains the API declaration.
- * @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:
- *
- *
- * @param None.
- *
- * @retval: None.
- * @par Dependency:
- * los_hw.h: the header file that contains the API declaration.
- * @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:
+ *
+ *
+ * @param: None.
+ *
+ * @retval None.
+ *
+ * @par Dependency:
+ * los_config.h: the header file that contains the API declaration.
+ * @see None.
+ */
+extern VOID HalStartToRun(VOID);
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#endif /* _LOS_ARCH_CONTEXT_H */
+
diff --git a/kernel/arch/arm/cortex-m3/keil/los_interrupt.h b/kernel/arch/arm/cortex-m3/keil/los_arch_interrupt.h
old mode 100755
new mode 100644
similarity index 65%
rename from kernel/arch/arm/cortex-m3/keil/los_interrupt.h
rename to kernel/arch/arm/cortex-m3/keil/los_arch_interrupt.h
index a8ad5da2..6a271023
--- a/kernel/arch/arm/cortex-m3/keil/los_interrupt.h
+++ b/kernel/arch/arm/cortex-m3/keil/los_arch_interrupt.h
@@ -1,1085 +1,782 @@
-/*
- * 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_EXC_H
-#define _LOS_EXC_H
-
-#include "los_config.h"
-#include "los_compiler.h"
-
-#ifdef __cplusplus
-#if __cplusplus
-extern "C" {
-#endif /* __cpluscplus */
-#endif /* __cpluscplus */
-
-/* *
- * @ingroup los_hwi
- * Maximum number of used hardware interrupts.
- */
-#ifndef OS_HWI_MAX_NUM
-#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
-#endif
-
-/* *
- * @ingroup los_hwi
- * Highest priority of a hardware interrupt.
- */
-#ifndef OS_HWI_PRIO_HIGHEST
-#define OS_HWI_PRIO_HIGHEST 0
-#endif
-
-/* *
- * @ingroup los_hwi
- * Lowest priority of a hardware interrupt.
- */
-#ifndef OS_HWI_PRIO_LOWEST
-#define OS_HWI_PRIO_LOWEST 7
-#endif
-
-/* *
- * @ingroup los_config
- * Configuration item for interrupt with argument
- */
-#ifndef OS_HWI_WITH_ARG
-#define OS_HWI_WITH_ARG NO
-#endif
-
-/* *
- * @ingroup los_hwi
- * Define the type of a hardware interrupt number.
- */
-typedef UINT32 HWI_HANDLE_T;
-
-/* *
- * @ingroup los_hwi
- * Define the type of a hardware interrupt priority.
- */
-typedef UINT16 HWI_PRIOR_T;
-
-/* *
- * @ingroup los_hwi
- * Define the type of hardware interrupt mode configurations.
- */
-typedef UINT16 HWI_MODE_T;
-
-/* *
- * @ingroup los_hwi
- * Define the type of the parameter used for the hardware interrupt creation function. The function of this parameter varies among platforms.
- */
-typedef UINT32 HWI_ARG_T;
-
-/* *
- * @ingroup los_hwi
- * Define the type of a hardware interrupt handling function.
- */
-#if (OS_HWI_WITH_ARG == YES)
-
-typedef VOID (*HWI_PROC_FUNC)(VOID *parm);
-typedef struct {
- HWI_PROC_FUNC pfnHandler;
- VOID *pParm;
-} HWI_SLAVE_FUNC;
-
-#else
-
-typedef VOID (*HWI_PROC_FUNC)(void);
-
-#endif
-
-/* *
- * @ingroup los_hwi
- * Define the type of a hardware interrupt vector table function.
- */
-typedef VOID (**HWI_VECTOR_FUNC)(void);
-
-/* *
- * @ingroup los_hwi
- * Count of interrupts.
- */
-extern UINT32 g_vuwIntCount;
-
-/* *
- * @ingroup los_hwi
- * An interrupt is active.
- */
-#define OS_INT_ACTIVE (g_vuwIntCount > 0)
-
-/* *
- * @ingroup los_hwi
- * An interrupt is inactive.
- */
-#define OS_INT_INACTIVE (!(OS_INT_ACTIVE))
-
-/* *
- * @ingroup los_hwi
- * Count of M-Core system interrupt vector.
- */
-#define OS_SYS_VECTOR_CNT 16
-
-/* *
- * @ingroup los_hwi
- * Count of M-Core interrupt vector.
- */
-#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
-
-/* *
- * @ingroup los_hwi
- * AIRCR register priority group parameter .
- */
-#define OS_NVIC_AIRCR_PRIGROUP 7
-
-/* *
- * @ingroup los_hwi
- * Boot interrupt vector table.
- */
-extern UINT32 _BootVectors[];
-
-/* *
- * @ingroup los_hwi
- * Hardware interrupt error code: Invalid interrupt number.
- *
- * Value: 0x02000900
- *
- * Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable for a Cortex-A7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
- */
-#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
-
-/* *
- * @ingroup los_hwi
- * Hardware interrupt error code: Null hardware interrupt handling function.
- *
- * Value: 0x02000901
- *
- * Solution: Pass in a valid non-null hardware interrupt handling function.
- */
-#define OS_ERRNO_HWI_PROC_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01)
-
-/* *
- * @ingroup los_hwi
- * Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation.
- *
- * Value: 0x02000902
- *
- * Solution: Increase the configured maximum number of supported hardware interrupts.
- */
-#define OS_ERRNO_HWI_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02)
-
-/* *
- * @ingroup los_hwi
- * Hardware interrupt error code: Insufficient memory for hardware interrupt initialization.
- *
- * Value: 0x02000903
- *
- * Solution: Expand the configured memory.
- */
-#define OS_ERRNO_HWI_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03)
-
-/* *
- * @ingroup los_hwi
- * Hardware interrupt error code: The interrupt has already been created.
- *
- * Value: 0x02000904
- *
- * Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created.
- */
-#define OS_ERRNO_HWI_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04)
-
-/* *
- * @ingroup los_hwi
- * Hardware interrupt error code: Invalid interrupt priority.
- *
- * Value: 0x02000905
- *
- * Solution: Ensure that the interrupt priority is valid. The value range of the interrupt priority applicable for a Cortex-A7 platform is [0,15].
- */
-#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
-
-/* *
- * @ingroup los_hwi
- * Hardware interrupt error code: Incorrect interrupt creation mode.
- *
- * Value: 0x02000906
- *
- * Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the value can be 0 or 1.
- */
-#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
-
-/* *
- * @ingroup los_hwi
- * Hardware interrupt error code: The interrupt has already been created as a fast interrupt.
- *
- * Value: 0x02000907
- *
- * Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created.
- */
-#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
-
-/* *
- * @ingroup los_hwi
- * SysTick control and status register.
- */
-#define OS_SYSTICK_CONTROL_REG 0xE000E010
-
-/* *
- * @ingroup los_hw
- * SysTick current value register.
- */
-#define OS_SYSTICK_CURRENT_REG 0xE000E018
-
-/* *
- * @ingroup los_hwi
- * Interrupt Priority-Level Registers.
- */
-#define OS_NVIC_PRI_BASE 0xE000E400
-
-/* *
- * @ingroup los_hwi
- * Interrupt enable register for 0-31.
- */
-#define OS_NVIC_SETENA_BASE 0xE000E100
-
-/* *
- * @ingroup los_hwi
- * interrupt pending register.
- */
-#define OS_NVIC_SETPEND_BASE 0xE000E200
-
-/* *
- * @ingroup los_hwi
- * Interrupt active register.
- */
-#define OS_NVIC_INT_ACT_BASE 0xE000E300
-
-/* *
- * @ingroup los_hwi
- * Interrupt disable register for 0-31.
- */
-#define OS_NVIC_CLRENA_BASE 0xE000E180
-
-/* *
- * @ingroup los_hwi
- * Interrupt control and status register.
- */
-#define OS_NVIC_INT_CTRL 0xE000ED04
-
-/* *
- * @ingroup los_hwi
- * Vector table offset register.
- */
-#define OS_NVIC_VTOR 0xE000ED08
-
-/* *
- * @ingroup los_hwi
- * Application interrupt and reset control register
- */
-#define OS_NVIC_AIRCR 0xE000ED0C
-
-/* *
- * @ingroup los_hwi
- * System exception priority register.
- */
-#define OS_NVIC_EXCPRI_BASE 0xE000ED18
-
-/* *
- * @ingroup los_hwi
- * Interrupt No. 1 :reset.
- */
-#define OS_EXC_RESET 1
-
-/* *
- * @ingroup los_hwi
- * Interrupt No. 2 :Non-Maskable Interrupt.
- */
-#define OS_EXC_NMI 2
-
-/* *
- * @ingroup los_hwi
- * Interrupt No. 3 :(hard)fault.
- */
-#define OS_EXC_HARD_FAULT 3
-
-/* *
- * @ingroup los_hwi
- * Interrupt No. 4 :MemManage fault.
- */
-#define OS_EXC_MPU_FAULT 4
-
-/* *
- * @ingroup los_hwi
- * Interrupt No. 5 :Bus fault.
- */
-#define OS_EXC_BUS_FAULT 5
-
-/* *
- * @ingroup los_hwi
- * Interrupt No. 6 :Usage fault.
- */
-#define OS_EXC_USAGE_FAULT 6
-
-/* *
- * @ingroup los_hwi
- * Interrupt No. 11 :SVCall.
- */
-#define OS_EXC_SVC_CALL 11
-
-/* *
- * @ingroup los_hwi
- * Interrupt No. 12 :Debug monitor.
- */
-#define OS_EXC_DBG_MONITOR 12
-
-/* *
- * @ingroup los_hwi
- * Interrupt No. 14 :PendSV.
- */
-#define OS_EXC_PEND_SV 14
-
-/* *
- * @ingroup los_hwi
- * Interrupt No. 15 :SysTick.
- */
-#define OS_EXC_SYS_TICK 15
-
-/* *
- * @ingroup los_hwi
- * hardware interrupt form mapping handling function array.
- */
-extern HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT];
-
-#if (OS_HWI_WITH_ARG == YES)
-/* *
- * @ingroup los_hwi
- * hardware interrupt Slave form mapping handling function array.
- */
-extern HWI_SLAVE_FUNC g_hwiSlaveForm[OS_VECTOR_CNT];
-
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-#define OsSetVectonr(num, vector, arg) \
- do { \
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsInterrupt; \
- g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector; \
- g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT].pParm = (VOID *)arg; \
- } while(0)
-#else
-/* *
- * @ingroup los_hwi
- * hardware interrupt Slave form mapping handling function array.
- */
-extern HWI_PROC_FUNC g_hwiSlaveForm[OS_VECTOR_CNT];
-
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-#define OsSetVector(num, vector) \
- do { \
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = OsInterrupt; \
- g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT] = vector; \
- } while(0)
-#endif
-
-/* *
- * @ingroup los_hwi
- * @brief Create a hardware interrupt.
- *
- * @par Description:
- * This API is used to configure a hardware interrupt and register a hardware interrupt handling function.
- *
- * @attention
- *
- * The hardware interrupt module is usable only when the configuration item for hardware interrupt tailoring is enabled.
- * Hardware interrupt number value range: [OS_USER_HWI_MIN,OS_USER_HWI_MAX]. The value range applicable for a Cortex-A7 platform is [32,95].
- * OS_HWI_MAX_NUM specifies the maximum number of interrupts that can be created.
- * Before executing an interrupt on a platform, refer to the chip manual of the platform.
- *
- *
- * @param hwiNum [IN] Type#HWI_HANDLE_T: hardware interrupt number. The value range applicable for a Cortex-A7 platform is [32,95].
- * @param hwiPrio [IN] Type#HWI_PRIOR_T: hardware interrupt priority. Ignore this parameter temporarily.
- * @param mode [IN] Type#HWI_MODE_T: hardware interrupt mode. Ignore this parameter temporarily.
- * @param handler [IN] Type#HWI_PROC_FUNC: interrupt handler used when a hardware interrupt is triggered.
- * @param arg [IN] Type#HWI_ARG_T: input parameter of the interrupt handler used when a hardware interrupt is triggered.
- *
- * @retval #OS_ERRNO_HWI_PROC_FUNC_NULL 0x02000901: Null hardware interrupt handling function.
- * @retval #OS_ERRNO_HWI_NUM_INVALID 0x02000900: Invalid interrupt number.
- * @retval #OS_ERRNO_HWI_NO_MEMORY 0x02000903: Insufficient memory for hardware interrupt creation.
- * @retval #OS_ERRNO_HWI_ALREADY_CREATED 0x02000904: The interrupt handler being created has already been created.
- * @retval #LOS_OK 0 : The interrupt is successfully created.
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see None.
- */
-extern UINT32 LOS_HwiCreate(HWI_HANDLE_T hwiNum,
- HWI_PRIOR_T hwiPrio,
- HWI_MODE_T mode,
- HWI_PROC_FUNC handler,
- HWI_ARG_T arg);
-
-/* *
- * @ingroup los_hwi
- * @brief: Hardware interrupt entry function.
- *
- * @par Description:
- * This API is used as all hardware interrupt handling function entry.
- *
- * @attention:
- *
- *
- * @param:None.
- *
- * @retval:None.
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see None.
- */
-extern VOID OsInterrupt(VOID);
-
-/* *
- * @ingroup los_hwi
- * @brief: Get a interrupt number.
- *
- * @par Description:
- * This API is used to get the current interrupt number.
- *
- * @attention:
- *
- *
- * @param: None.
- *
- * @retval: Interrupt Indexes number.
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see None.
- */
-extern UINT32 OsIntNumGet(VOID);
-
-/* *
- * @ingroup los_hwi
- * @brief: Default vector handling function.
- *
- * @par Description:
- * This API is used to configure interrupt for null function.
- *
- * @attention:
- *
- *
- * @param:None.
- *
- * @retval:None.
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see None.
- */
-extern VOID OsHwiDefaultHandler(VOID);
-
-/* *
- * @ingroup los_hwi
- * @brief: Reset the vector table.
- *
- * @par Description:
- * This API is used to reset the vector table.
- *
- * @attention:
- *
- *
- * @param:None.
- *
- * @retval:None.
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see None.
- */
-extern VOID Reset_Handler(VOID);
-
-/* *
- * @ingroup los_hwi
- * @brief: Pended System Call.
- *
- * @par Description:
- * PendSV can be pended and is useful for an OS to pend an exception
- * so that an action can be performed after other important tasks are completed.
- *
- * @attention:
- *
- *
- * @param:None.
- *
- * @retval:None.
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see None.
- */
-extern VOID osPendSV(VOID);
-
-/* *
- * @ingroup los_hwi
- * @brief Enable all interrupts.
- *
- * @par Description:
- *
- * This API is used to enable all IRQ and FIQ interrupts in the CPSR.
- *
- * @attention
- *
- *
- * @param None.
- *
- * @retval CPSR value obtained after all interrupts are enabled.
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see LOS_IntRestore
- */
-extern UINTPTR LOS_IntUnLock(VOID);
-
-/* *
- * @ingroup los_hwi
- * @brief Disable all interrupts.
- *
- * @par Description:
- *
- * This API is used to disable all IRQ and FIQ interrupts in the CPSR.
- *
- * @attention
- *
- *
- * @param None.
- *
- * @retval CPSR value obtained before all interrupts are disabled.
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see LOS_IntRestore
- */
-extern UINTPTR LOS_IntLock(VOID);
-
-/* *
- * @ingroup los_hwi
- * @brief Restore interrupts.
- *
- * @par Description:
- *
- * This API is used to restore the CPSR value obtained before all interrupts are disabled.
- *
- * @attention
- *
- * This API can be called only after all interrupts are disabled, and the input parameter value should be the value returned by calling the all interrupt disabling API.
- *
- *
- * @param intSave [IN] CPSR value obtained before all interrupts are disabled.
- *
- * @retval None.
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see LOS_IntLock
- */
-extern VOID LOS_IntRestore(UINTPTR intSave);
-
-/* *
- * @ingroup los_hwi
- * @brief Get value from xPSR register.
- *
- * @par Description:
- *
- * This API is used to Get value from xPSR register.
- *
- * @attention
- *
- *
- * @param cntHi [IN] CpuTick High 4 byte
- * @param cntLo [IN] CpuTick Low 4 byte
- *
- * @retval None.
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see LOS_IntRestore
- */
-extern VOID LOS_GetCpuCycle(UINT32 *cntHi, UINT32 *cntLo);
-
-#if (LOSCFG_KERNEL_TICKLESS == YES)
-/**
- * @ingroup los_hwi
- * @brief reconfig systick, and clear SysTick_IRQn.
- *
- * @par Description:
- *
- * This API is used to reconfig systick, and clear SysTick_IRQn.
- *
- * @attention
- *
- *
- * @param cyclesPerTick [IN] Cycles Per Tick
- *
- * @retval None.
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see LOS_IntRestore
- */
-extern VOID LOS_SysTickReload(UINT32 cyclesPerTick);
-#endif
-
-/**
- * @ingroup los_hwi
- * @brief Get System cycle count.
- *
- * @par Description:
- *
- * This API is used to Get System cycle count.
- *
- * @attention
- *
- *
- * @param None.
- *
- * @retval: The value of the system cycle count.
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see LOS_IntRestore
- */
-extern UINT32 LOS_SysTickCurrCycleGet(VOID);
-
-extern VOID LOS_GetSystickCycle(UINT32 *puwCntHi, UINT32 *puwCntLo);
-
-/* *
- * @ingroup los_hwi
- * @brief Delete hardware interrupt.
- *
- * @par Description:
- * This API is used to delete hardware interrupt.
- *
- * @attention
- *
- * The hardware interrupt module is usable only when the configuration item for hardware interrupt tailoring is enabled.
- * Hardware interrupt number value range: [OS_USER_HWI_MIN,OS_USER_HWI_MAX]. The value range applicable for a Cortex-A7 platform is [32,95].
- * OS_HWI_MAX_NUM specifies the maximum number of interrupts that can be created.
- * Before executing an interrupt on a platform, refer to the chip manual of the platform.
- *
- *
- * @param hwiNum [IN] Type#HWI_HANDLE_T: hardware interrupt number. The value range applicable for a Cortex-A7 platform is [32,95].
- *
- * @retval #OS_ERRNO_HWI_NUM_INVALID 0x02000900: Invalid interrupt number.
- * @retval #LOS_OK 0 : The interrupt is successfully delete.
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see None.
- */
-extern UINT32 LOS_HwiDelete(HWI_HANDLE_T hwiNum);
-
-typedef enum {
- OS_SYS_NORMAL_SLEEP = 0,
- OS_SYS_DEEP_SLEEP,
-} LOS_SysSleepEnum;
-
-VOID LOS_TickLock(VOID);
-
-VOID LOS_TickUnlock(VOID);
-
-BOOL LOS_GetSysSleepFlag(VOID);
-
-VOID LOS_ClearSysSleepFlag(VOID);
-
-VOID LOS_EnterSleep(LOS_SysSleepEnum sleep);
-
-VOID LOS_SystemWakeup(UINT32 hwiIndex);
-
-#define OS_EXC_IN_INIT 0
-#define OS_EXC_IN_TASK 1
-#define OS_EXC_IN_HWI 2
-
-#define OS_EXC_MAX_BUF_LEN 25
-#define OS_EXC_MAX_NEST_DEPTH 1
-
-#define OS_NVIC_SHCSR 0xE000ED24
-#define OS_NVIC_CCR 0xE000ED14
-
-#define OS_NVIC_INT_ENABLE_SIZE 0x20
-#define OS_NVIC_INT_PRI_SIZE 0xF0
-#define OS_NVIC_EXCPRI_SIZE 0xC
-
-#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
-#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
-
-#define OS_EXC_FLAG_NO_FLOAT 0x10000000
-#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
-#define OS_EXC_FLAG_IN_HWI 0x02
-
-#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
-
-#define OS_EXC_EVENT 0x00000001
-
-/**
- *@ingroup los_exc
- * the struct of register files
- *
- * description: the register files that saved when exception triggered
- *
- * notes:the following register with prefix 'uw' correspond to the registers in the cpu data sheet.
- */
-typedef struct tagExcContext {
- //handler save
-#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;
- //auto save
- UINT32 uwSP;
- 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
-}EXC_CONTEXT_S;
-
-typedef UINT32 (*EXC_INFO_SAVE_CALLBACK)(UINT32, VOID*);
-typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
-VOID OsExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
-
-/**
- * @ingroup los_hwi
- * @brief: Exception initialization.
- *
- * @par Description:
- * This API is used to configure the exception function vector table.
- *
- * @attention:
- *
- *
- *@param uwArraySize [IN] Memory size of exception.
- *
- * @retval: None
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see None.
- */
-VOID OsExcInit(VOID);
-
-extern VOID OsExcNMI(VOID);
-extern VOID OsExcHardFault(VOID);
-extern VOID OsExcMemFault(VOID);
-extern VOID OsExcBusFault(VOID);
-extern VOID OsExcUsageFault(VOID);
-extern VOID OsExcSvcCall(VOID);
-extern UINT8 g_aucTaskArray[];
-
-extern void OsBackTrace();
-
-/**
- *@ingroup los_exc
- *@brief Kernel panic function.
- *
- *@par Description:
- *Stack function that prints kernel panics.
- *@attention After this function is called and stack information is printed, the system will fail to respond.
- *@attention The input parameter can be NULL.
- *@param fmt [IN] Type #char* : variadic argument.
- *
- *@retval #None.
- *
- *@par Dependency:
- *los_interrupt.h: the header file that contains the API declaration.
- *@see None.
-*/
-VOID LOS_Panic(const CHAR *fmt, ...);
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:总线状态寄存器入栈时发生错误
- */
-#define OS_EXC_BF_STKERR 1
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:总线状态寄存器出栈时发生错误
- */
-#define OS_EXC_BF_UNSTKERR 2
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:总线状态寄存器不精确的数据访问违例
- */
-#define OS_EXC_BF_IMPRECISERR 3
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:总线状态寄存器精确的数据访问违例
- */
-#define OS_EXC_BF_PRECISERR 4
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:总线状态寄存器取指时的访问违例
- */
-#define OS_EXC_BF_IBUSERR 5
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:存储器管理状态寄存器入栈时发生错误
- */
-#define OS_EXC_MF_MSTKERR 6
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:存储器管理状态寄存器出栈时发生错误
- */
-#define OS_EXC_MF_MUNSTKERR 7
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:存储器管理状态寄存器数据访问违例
- */
-#define OS_EXC_MF_DACCVIOL 8
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:存储器管理状态寄存器取指访问违例
- */
-#define OS_EXC_MF_IACCVIOL 9
-
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:用法错误,表示除法运算时除数为零
- */
-#define OS_EXC_UF_DIVBYZERO 10
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:用法错误,未对齐访问导致的错误
- */
-#define OS_EXC_UF_UNALIGNED 11
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:用法错误,试图执行协处理器相关指令
- */
-#define OS_EXC_UF_NOCP 12
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:用法错误,在异常返回时试图非法地加载EXC_RETURN到PC
- */
-#define OS_EXC_UF_INVPC 13
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:用法错误,试图切入ARM状态
- */
-#define OS_EXC_UF_INVSTATE 14
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:用法错误,执行的指令其编码是未定义的——解码不能
- */
-#define OS_EXC_UF_UNDEFINSTR 15
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:NMI中断
- */
-
-#define OS_EXC_CAUSE_NMI 16
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:硬fault
- */
-#define OS_EXC_CAUSE_HARDFAULT 17
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:任务处理函数退出
- */
-#define OS_EXC_CAUSE_TASK_EXIT 18
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:致命错误
- */
-#define OS_EXC_CAUSE_FATAL_ERR 19
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:调试事件导致的硬fault
- */
-#define OS_EXC_CAUSE_DEBUGEVT 20
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:取向量时发生的硬fault
- */
-#define OS_EXC_CAUSE_VECTBL 21
-
-/**
- *@ingroup los_exc
- * 异常信息结构体
- *
- * 描述:M4平台下的异常触发时保存的异常信息
- *
- */
-typedef struct tagExcInfo {
- /**< 异常发生阶段: 0表示异常发生在初始化中,1表示异常发生在任务中,2表示异常发生在中断中 */
- UINT16 phase;
- /**< 异常类型,出异常时对照上面列出的1-19号 */
- UINT16 type;
- /**< 若为精确地址访问错误表示异常发生时的错误访问地址 */
- UINT32 faultAddr;
- /**< 在中断中发生异常,表示中断号。在任务中发生异常,表示任务id,如果发生在初始化中,则为0xffffffff */
- UINT32 thrdPid;
- /**< 异常嵌套个数,目前仅支持第一次进入异常时执行注册的钩子函数 */
- UINT16 nestCnt;
- /**< 保留 */
- UINT16 reserved;
- /**< 自动压栈浮点寄存器的异常发生时刻的硬件上下文 */
- EXC_CONTEXT_S * context;
-} ExcInfo;
-
-extern UINT32 g_curNestCount;
-extern UINT32 g_vuwIntCount;
-
-static VOID OsExcSave2DDR(VOID);
-VOID OsExcInfoDisplay(ExcInfo *exc);
-
-extern UINT8 g_uwExcTbl[32];
-
-typedef enum {
- OS_EXC_TYPE_CONTEXT = 0,
- OS_EXC_TYPE_TSK = 1,
- OS_EXC_TYPE_QUE = 2,
- OS_EXC_TYPE_NVIC = 3,
- OS_EXC_TYPE_TSK_SWITCH = 4,
- OS_EXC_TYPE_MEM = 5,
- OS_EXC_TYPE_MAX = 6
-} ExcInfoType;
-
-typedef struct tagExcInfoCallBackArray {
- ExcInfoType uwType;
- UINT32 uwValid;
- EXC_INFO_SAVE_CALLBACK pFnExcInfoCb;
- VOID* pArg;
-} ExcInfoArray;
-
-
-
-#define MAX_SCENE_INFO_SIZE (8 + sizeof(ExcInfo) - 4 + sizeof(EXC_CONTEXT_S))
-#define MAX_TSK_INFO_SIZE (8 + sizeof(TSK_INFO_S) * (LOSCFG_BASE_CORE_TSK_LIMIT + 1))
-#define MAX_INT_INFO_SIZE (8 + 0x164)
-
-#if (LOSCFG_BASE_IPC_QUEUE == YES)
-#define MAX_QUEUE_INFO_SIZE (8 + sizeof(QUEUE_INFO_S) * LOSCFG_BASE_IPC_QUEUE_LIMIT)
-#else
-#define MAX_QUEUE_INFO_SIZE (0)
-#endif
-
-#if (LOSCFG_BASE_CORE_EXC_TSK_SWITCH == YES)
-#define MAX_SWITCH_INFO_SIZE (8 + (sizeof(UINT32) + sizeof(CHAR) * LOS_TASK_NAMELEN) * OS_TASK_SWITCH_INFO_COUNT)
-#else
-#define MAX_SWITCH_INFO_SIZE (0)
-#endif
-
-#if (LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK == YES)
-#define MAX_MEM_INFO_SIZE (8 + sizeof(MEM_INFO_S) * OS_SYS_MEM_NUM)
-#else
-#define MAX_MEM_INFO_SIZE (0)
-#endif
-
-#define MAX_EXC_MEM_SIZE ( 4 + MAX_SCENE_INFO_SIZE + MAX_TSK_INFO_SIZE + MAX_QUEUE_INFO_SIZE + MAX_INT_INFO_SIZE + MAX_SWITCH_INFO_SIZE + MAX_MEM_INFO_SIZE + 4)
-
-VOID OsExcRegister(ExcInfoType type, EXC_INFO_SAVE_CALLBACK func, VOID *arg);
-VOID LOS_Reboot(VOID);
-
-#ifdef __cplusplus
-#if __cplusplus
-}
-#endif /* __cpluscplus */
-#endif /* __cpluscplus */
-
-#endif /* _LOS_EXC_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_EXC_H
+#define _LOS_EXC_H
+
+#include "los_config.h"
+#include "los_compiler.h"
+#include "los_interrupt.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+/* *
+ * @ingroup los_hwi
+ * Maximum number of used hardware interrupts.
+ */
+#ifndef OS_HWI_MAX_NUM
+#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
+#endif
+
+/* *
+ * @ingroup los_hwi
+ * Highest priority of a hardware interrupt.
+ */
+#ifndef OS_HWI_PRIO_HIGHEST
+#define OS_HWI_PRIO_HIGHEST 0
+#endif
+
+/* *
+ * @ingroup los_hwi
+ * Lowest priority of a hardware interrupt.
+ */
+#ifndef OS_HWI_PRIO_LOWEST
+#define OS_HWI_PRIO_LOWEST 7
+#endif
+
+
+/* *
+ * @ingroup los_hwi
+ * Define the type of a hardware interrupt vector table function.
+ */
+typedef VOID (**HWI_VECTOR_FUNC)(void);
+
+/* *
+ * @ingroup los_hwi
+ * Count of interrupts.
+ */
+extern UINT32 g_intCount;
+
+/* *
+ * @ingroup los_hwi
+ * Count of M-Core system interrupt vector.
+ */
+#define OS_SYS_VECTOR_CNT 16
+
+/* *
+ * @ingroup los_hwi
+ * Count of M-Core interrupt vector.
+ */
+#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
+
+/* *
+ * @ingroup los_hwi
+ * AIRCR register priority group parameter .
+ */
+#define OS_NVIC_AIRCR_PRIGROUP 7
+
+/* *
+ * @ingroup los_hwi
+ * Boot interrupt vector table.
+ */
+extern UINT32 _BootVectors[];
+
+/* *
+ * @ingroup los_hwi
+ * Hardware interrupt error code: Invalid interrupt number.
+ *
+ * Value: 0x02000900
+ *
+ * Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable for a Cortex-A7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
+ */
+#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
+
+/* *
+ * @ingroup los_hwi
+ * Hardware interrupt error code: Null hardware interrupt handling function.
+ *
+ * Value: 0x02000901
+ *
+ * Solution: Pass in a valid non-null hardware interrupt handling function.
+ */
+#define OS_ERRNO_HWI_PROC_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01)
+
+/* *
+ * @ingroup los_hwi
+ * Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation.
+ *
+ * Value: 0x02000902
+ *
+ * Solution: Increase the configured maximum number of supported hardware interrupts.
+ */
+#define OS_ERRNO_HWI_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02)
+
+/* *
+ * @ingroup los_hwi
+ * Hardware interrupt error code: Insufficient memory for hardware interrupt initialization.
+ *
+ * Value: 0x02000903
+ *
+ * Solution: Expand the configured memory.
+ */
+#define OS_ERRNO_HWI_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03)
+
+/* *
+ * @ingroup los_hwi
+ * Hardware interrupt error code: The interrupt has already been created.
+ *
+ * Value: 0x02000904
+ *
+ * Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created.
+ */
+#define OS_ERRNO_HWI_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04)
+
+/* *
+ * @ingroup los_hwi
+ * Hardware interrupt error code: Invalid interrupt priority.
+ *
+ * Value: 0x02000905
+ *
+ * Solution: Ensure that the interrupt priority is valid. The value range of the interrupt priority applicable for a Cortex-A7 platform is [0,15].
+ */
+#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
+
+/* *
+ * @ingroup los_hwi
+ * Hardware interrupt error code: Incorrect interrupt creation mode.
+ *
+ * Value: 0x02000906
+ *
+ * Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the value can be 0 or 1.
+ */
+#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
+
+/* *
+ * @ingroup los_hwi
+ * Hardware interrupt error code: The interrupt has already been created as a fast interrupt.
+ *
+ * Value: 0x02000907
+ *
+ * Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created.
+ */
+#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
+
+/* *
+ * @ingroup los_hwi
+ * SysTick control and status register.
+ */
+#define OS_SYSTICK_CONTROL_REG 0xE000E010
+
+/* *
+ * @ingroup los_hw
+ * SysTick current value register.
+ */
+#define OS_SYSTICK_CURRENT_REG 0xE000E018
+
+/* *
+ * @ingroup los_hwi
+ * Interrupt Priority-Level Registers.
+ */
+#define OS_NVIC_PRI_BASE 0xE000E400
+
+/* *
+ * @ingroup los_hwi
+ * Interrupt enable register for 0-31.
+ */
+#define OS_NVIC_SETENA_BASE 0xE000E100
+
+/* *
+ * @ingroup los_hwi
+ * interrupt pending register.
+ */
+#define OS_NVIC_SETPEND_BASE 0xE000E200
+
+/* *
+ * @ingroup los_hwi
+ * Interrupt active register.
+ */
+#define OS_NVIC_INT_ACT_BASE 0xE000E300
+
+/* *
+ * @ingroup los_hwi
+ * Interrupt disable register for 0-31.
+ */
+#define OS_NVIC_CLRENA_BASE 0xE000E180
+
+/* *
+ * @ingroup los_hwi
+ * Interrupt control and status register.
+ */
+#define OS_NVIC_INT_CTRL 0xE000ED04
+
+/* *
+ * @ingroup los_hwi
+ * Vector table offset register.
+ */
+#define OS_NVIC_VTOR 0xE000ED08
+
+/* *
+ * @ingroup los_hwi
+ * Application interrupt and reset control register
+ */
+#define OS_NVIC_AIRCR 0xE000ED0C
+
+/* *
+ * @ingroup los_hwi
+ * System exception priority register.
+ */
+#define OS_NVIC_EXCPRI_BASE 0xE000ED18
+
+/* *
+ * @ingroup los_hwi
+ * Interrupt No. 1 :reset.
+ */
+#define OS_EXC_RESET 1
+
+/* *
+ * @ingroup los_hwi
+ * Interrupt No. 2 :Non-Maskable Interrupt.
+ */
+#define OS_EXC_NMI 2
+
+/* *
+ * @ingroup los_hwi
+ * Interrupt No. 3 :(hard)fault.
+ */
+#define OS_EXC_HARD_FAULT 3
+
+/* *
+ * @ingroup los_hwi
+ * Interrupt No. 4 :MemManage fault.
+ */
+#define OS_EXC_MPU_FAULT 4
+
+/* *
+ * @ingroup los_hwi
+ * Interrupt No. 5 :Bus fault.
+ */
+#define OS_EXC_BUS_FAULT 5
+
+/* *
+ * @ingroup los_hwi
+ * Interrupt No. 6 :Usage fault.
+ */
+#define OS_EXC_USAGE_FAULT 6
+
+/* *
+ * @ingroup los_hwi
+ * Interrupt No. 11 :SVCall.
+ */
+#define OS_EXC_SVC_CALL 11
+
+/* *
+ * @ingroup los_hwi
+ * Interrupt No. 12 :Debug monitor.
+ */
+#define OS_EXC_DBG_MONITOR 12
+
+/* *
+ * @ingroup los_hwi
+ * Interrupt No. 14 :PendSV.
+ */
+#define OS_EXC_PEND_SV 14
+
+/* *
+ * @ingroup los_hwi
+ * Interrupt No. 15 :SysTick.
+ */
+#define OS_EXC_SYS_TICK 15
+
+/* *
+ * @ingroup los_hwi
+ * hardware interrupt form mapping handling function array.
+ */
+extern HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT];
+
+#if (OS_HWI_WITH_ARG == 1)
+/* *
+ * @ingroup los_hwi
+ * hardware interrupt Slave form mapping handling function array.
+ */
+extern HWI_SLAVE_FUNC g_hwiSlaveForm[OS_VECTOR_CNT];
+
+/* *
+ * @ingroup los_hwi
+ * Set interrupt vector table.
+ */
+#define OsSetVectonr(num, vector, arg) \
+ do { \
+ g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt; \
+ g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector; \
+ g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT].pParm = (VOID *)arg; \
+ } while(0)
+#else
+/* *
+ * @ingroup los_hwi
+ * hardware interrupt Slave form mapping handling function array.
+ */
+extern HWI_PROC_FUNC g_hwiSlaveForm[OS_VECTOR_CNT];
+
+/* *
+ * @ingroup los_hwi
+ * Set interrupt vector table.
+ */
+#define OsSetVector(num, vector) \
+ do { \
+ g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt; \
+ g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT] = vector; \
+ } while(0)
+#endif
+
+/* *
+ * @ingroup los_hwi
+ * @brief: Hardware interrupt entry function.
+ *
+ * @par Description:
+ * This API is used as all hardware interrupt handling function entry.
+ *
+ * @attention:
+ *
+ *
+ * @param:None.
+ *
+ * @retval:None.
+ * @par Dependency:
+ * los_hwi.h: the header file that contains the API declaration.
+ * @see None.
+ */
+extern VOID HalInterrupt(VOID);
+
+/* *
+ * @ingroup los_hwi
+ * @brief: Get a interrupt number.
+ *
+ * @par Description:
+ * This API is used to get the current interrupt number.
+ *
+ * @attention:
+ *
+ *
+ * @param: None.
+ *
+ * @retval: Interrupt Indexes number.
+ * @par Dependency:
+ * los_hwi.h: the header file that contains the API declaration.
+ * @see None.
+ */
+extern UINT32 HalIntNumGet(VOID);
+
+/* *
+ * @ingroup los_hwi
+ * @brief: Default vector handling function.
+ *
+ * @par Description:
+ * This API is used to configure interrupt for null function.
+ *
+ * @attention:
+ *
+ *
+ * @param:None.
+ *
+ * @retval:None.
+ * @par Dependency:
+ * los_hwi.h: the header file that contains the API declaration.
+ * @see None.
+ */
+extern VOID HalHwiDefaultHandler(VOID);
+
+/* *
+ * @ingroup los_hwi
+ * @brief: Reset the vector table.
+ *
+ * @par Description:
+ * This API is used to reset the vector table.
+ *
+ * @attention:
+ *
+ *
+ * @param:None.
+ *
+ * @retval:None.
+ * @par Dependency:
+ * los_hwi.h: the header file that contains the API declaration.
+ * @see None.
+ */
+extern VOID Reset_Handler(VOID);
+
+/* *
+ * @ingroup los_hwi
+ * @brief: Pended System Call.
+ *
+ * @par Description:
+ * PendSV can be pended and is useful for an OS to pend an exception
+ * so that an action can be performed after other important tasks are completed.
+ *
+ * @attention:
+ *
+ *
+ * @param:None.
+ *
+ * @retval:None.
+ * @par Dependency:
+ * los_hwi.h: the header file that contains the API declaration.
+ * @see None.
+ */
+extern VOID HalPendSV(VOID);
+
+
+#define OS_EXC_IN_INIT 0
+#define OS_EXC_IN_TASK 1
+#define OS_EXC_IN_HWI 2
+
+#define OS_EXC_MAX_BUF_LEN 25
+#define OS_EXC_MAX_NEST_DEPTH 1
+
+#define OS_NVIC_SHCSR 0xE000ED24
+#define OS_NVIC_CCR 0xE000ED14
+
+#define OS_NVIC_INT_ENABLE_SIZE 0x20
+#define OS_NVIC_INT_PRI_SIZE 0xF0
+#define OS_NVIC_EXCPRI_SIZE 0xC
+
+#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
+#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
+
+#define OS_EXC_FLAG_NO_FLOAT 0x10000000
+#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
+#define OS_EXC_FLAG_IN_HWI 0x02
+
+#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
+
+#define OS_EXC_EVENT 0x00000001
+
+/**
+ *@ingroup los_exc
+ * the struct of register files
+ *
+ * description: the register files that saved when exception triggered
+ *
+ * notes:the following register with prefix 'uw' correspond to the registers in the cpu data sheet.
+ */
+typedef struct tagExcContext {
+ //handler save
+#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;
+ //auto save
+ UINT32 uwSP;
+ 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
+}EXC_CONTEXT_S;
+
+typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
+VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
+
+/**
+ * @ingroup los_hwi
+ * @brief: Exception initialization.
+ *
+ * @par Description:
+ * This API is used to configure the exception function vector table.
+ *
+ * @attention:
+ *
+ *
+ *@param uwArraySize [IN] Memory size of exception.
+ *
+ * @retval: None
+ * @par Dependency:
+ * los_hwi.h: the header file that contains the API declaration.
+ * @see None.
+ */
+VOID OsExcInit(VOID);
+
+VOID HalExcNMI(VOID);
+VOID HalExcHardFault(VOID);
+VOID HalExcMemFault(VOID);
+VOID HalExcBusFault(VOID);
+VOID HalExcUsageFault(VOID);
+VOID HalExcSvcCall(VOID);
+VOID HalHwiInit();
+
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:总线状态寄存器入栈时发生错误
+ */
+#define OS_EXC_BF_STKERR 1
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:总线状态寄存器出栈时发生错误
+ */
+#define OS_EXC_BF_UNSTKERR 2
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:总线状态寄存器不精确的数据访问违例
+ */
+#define OS_EXC_BF_IMPRECISERR 3
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:总线状态寄存器精确的数据访问违例
+ */
+#define OS_EXC_BF_PRECISERR 4
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:总线状态寄存器取指时的访问违例
+ */
+#define OS_EXC_BF_IBUSERR 5
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:存储器管理状态寄存器入栈时发生错误
+ */
+#define OS_EXC_MF_MSTKERR 6
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:存储器管理状态寄存器出栈时发生错误
+ */
+#define OS_EXC_MF_MUNSTKERR 7
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:存储器管理状态寄存器数据访问违例
+ */
+#define OS_EXC_MF_DACCVIOL 8
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:存储器管理状态寄存器取指访问违例
+ */
+#define OS_EXC_MF_IACCVIOL 9
+
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:用法错误,表示除法运算时除数为零
+ */
+#define OS_EXC_UF_DIVBYZERO 10
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:用法错误,未对齐访问导致的错误
+ */
+#define OS_EXC_UF_UNALIGNED 11
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:用法错误,试图执行协处理器相关指令
+ */
+#define OS_EXC_UF_NOCP 12
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:用法错误,在异常返回时试图非法地加载EXC_RETURN到PC
+ */
+#define OS_EXC_UF_INVPC 13
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:用法错误,试图切入ARM状态
+ */
+#define OS_EXC_UF_INVSTATE 14
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:用法错误,执行的指令其编码是未定义的——解码不能
+ */
+#define OS_EXC_UF_UNDEFINSTR 15
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:NMI中断
+ */
+
+#define OS_EXC_CAUSE_NMI 16
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:硬fault
+ */
+#define OS_EXC_CAUSE_HARDFAULT 17
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:任务处理函数退出
+ */
+#define OS_EXC_CAUSE_TASK_EXIT 18
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:致命错误
+ */
+#define OS_EXC_CAUSE_FATAL_ERR 19
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:调试事件导致的硬fault
+ */
+#define OS_EXC_CAUSE_DEBUGEVT 20
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:取向量时发生的硬fault
+ */
+#define OS_EXC_CAUSE_VECTBL 21
+
+/**
+ *@ingroup los_exc
+ * 异常信息结构体
+ *
+ * 描述:M4平台下的异常触发时保存的异常信息
+ *
+ */
+typedef struct tagExcInfo {
+ /**< 异常发生阶段: 0表示异常发生在初始化中,1表示异常发生在任务中,2表示异常发生在中断中 */
+ UINT16 phase;
+ /**< 异常类型,出异常时对照上面列出的1-19号 */
+ UINT16 type;
+ /**< 若为精确地址访问错误表示异常发生时的错误访问地址 */
+ UINT32 faultAddr;
+ /**< 在中断中发生异常,表示中断号。在任务中发生异常,表示任务id,如果发生在初始化中,则为0xffffffff */
+ UINT32 thrdPid;
+ /**< 异常嵌套个数,目前仅支持第一次进入异常时执行注册的钩子函数 */
+ UINT16 nestCnt;
+ /**< 保留 */
+ UINT16 reserved;
+ /**< 自动压栈浮点寄存器的异常发生时刻的硬件上下文 */
+ EXC_CONTEXT_S * context;
+} ExcInfo;
+
+extern UINT32 g_curNestCount;
+extern UINT32 g_intCount;
+
+static VOID OsExcSave2DDR(VOID);
+VOID OsExcInfoDisplay(ExcInfo *exc);
+
+extern UINT8 g_uwExcTbl[32];
+
+
+
+typedef struct tagExcInfoCallBackArray {
+ ExcInfoType uwType;
+ UINT32 uwValid;
+ EXC_INFO_SAVE_CALLBACK pFnExcInfoCb;
+ VOID* pArg;
+} ExcInfoArray;
+
+
+
+#define MAX_SCENE_INFO_SIZE (8 + sizeof(ExcInfo) - 4 + sizeof(EXC_CONTEXT_S))
+#define MAX_TSK_INFO_SIZE (8 + sizeof(TSK_INFO_S) * (LOSCFG_BASE_CORE_TSK_LIMIT + 1))
+#define MAX_INT_INFO_SIZE (8 + 0x164)
+
+#if (LOSCFG_BASE_IPC_QUEUE == 1)
+#define MAX_QUEUE_INFO_SIZE (8 + sizeof(QUEUE_INFO_S) * LOSCFG_BASE_IPC_QUEUE_LIMIT)
+#else
+#define MAX_QUEUE_INFO_SIZE (0)
+#endif
+
+#if (LOSCFG_BASE_CORE_EXC_TSK_SWITCH == 1)
+#define MAX_SWITCH_INFO_SIZE (8 + (sizeof(UINT32) + sizeof(CHAR) * LOS_TASK_NAMELEN) * OS_TASK_SWITCH_INFO_COUNT)
+#else
+#define MAX_SWITCH_INFO_SIZE (0)
+#endif
+
+#if (LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK == 1)
+#define MAX_MEM_INFO_SIZE (8 + sizeof(MEM_INFO_S) * OS_SYS_MEM_NUM)
+#else
+#define MAX_MEM_INFO_SIZE (0)
+#endif
+
+#define MAX_EXC_MEM_SIZE ( 4 + MAX_SCENE_INFO_SIZE + MAX_TSK_INFO_SIZE + MAX_QUEUE_INFO_SIZE + MAX_INT_INFO_SIZE + MAX_SWITCH_INFO_SIZE + MAX_MEM_INFO_SIZE + 4)
+
+
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#endif /* _LOS_EXC_H */
+
diff --git a/kernel/arch/arm/cortex-m3/keil/los_arch_timer.h b/kernel/arch/arm/cortex-m3/keil/los_arch_timer.h
new file mode 100644
index 00000000..2f38c220
--- /dev/null
+++ b/kernel/arch/arm/cortex-m3/keil/los_arch_timer.h
@@ -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 */
+
diff --git a/kernel/arch/arm/cortex-m3/keil/los_hw.c b/kernel/arch/arm/cortex-m3/keil/los_context.c
old mode 100755
new mode 100644
similarity index 80%
rename from kernel/arch/arm/cortex-m3/keil/los_hw.c
rename to kernel/arch/arm/cortex-m3/keil/los_context.c
index 365a08ad..53ca335f
--- a/kernel/arch/arm/cortex-m3/keil/los_hw.c
+++ b/kernel/arch/arm/cortex-m3/keil/los_context.c
@@ -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
diff --git a/kernel/arch/arm/cortex-m3/keil/los_dispatch.S b/kernel/arch/arm/cortex-m3/keil/los_dispatch.S
old mode 100755
new mode 100644
index 05f0391b..be6145e1
--- a/kernel/arch/arm/cortex-m3/keil/los_dispatch.S
+++ b/kernel/arch/arm/cortex-m3/keil/los_dispatch.S
@@ -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}
diff --git a/kernel/arch/arm/cortex-m3/keil/los_hw_exc.S b/kernel/arch/arm/cortex-m3/keil/los_exc.S
old mode 100755
new mode 100644
similarity index 95%
rename from kernel/arch/arm/cortex-m3/keil/los_hw_exc.S
rename to kernel/arch/arm/cortex-m3/keil/los_exc.S
index 48cc76be..65e17a52
--- a/kernel/arch/arm/cortex-m3/keil/los_hw_exc.S
+++ b/kernel/arch/arm/cortex-m3/keil/los_exc.S
@@ -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
diff --git a/kernel/arch/arm/cortex-m3/keil/los_interrupt.c b/kernel/arch/arm/cortex-m3/keil/los_interrupt.c
old mode 100755
new mode 100644
index bfc5102a..8fb0c02b
--- a/kernel/arch/arm/cortex-m3/keil/los_interrupt.c
+++ b/kernel/arch/arm/cortex-m3/keil/los_interrupt.c
@@ -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
#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;
}
diff --git a/kernel/arch/arm/cortex-m3/keil/los_vendor.s b/kernel/arch/arm/cortex-m3/keil/los_startup.s
old mode 100755
new mode 100644
similarity index 94%
rename from kernel/arch/arm/cortex-m3/keil/los_vendor.s
rename to kernel/arch/arm/cortex-m3/keil/los_startup.s
index 808924a5..876e597e
--- a/kernel/arch/arm/cortex-m3/keil/los_vendor.s
+++ b/kernel/arch/arm/cortex-m3/keil/los_startup.s
@@ -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
diff --git a/kernel/arch/arm/cortex-m3/keil/los_hw_tick.c b/kernel/arch/arm/cortex-m3/keil/los_timer.c
old mode 100755
new mode 100644
similarity index 69%
rename from kernel/arch/arm/cortex-m3/keil/los_hw_tick.c
rename to kernel/arch/arm/cortex-m3/keil/los_timer.c
index eaa5eb84..c0c85edf
--- a/kernel/arch/arm/cortex-m3/keil/los_hw_tick.c
+++ b/kernel/arch/arm/cortex-m3/keil/los_timer.c
@@ -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
}
diff --git a/kernel/arch/arm/cortex-m4/iar/los_arch_atomic.h b/kernel/arch/arm/cortex-m4/iar/los_arch_atomic.h
new file mode 100644
index 00000000..2e6121c3
--- /dev/null
+++ b/kernel/arch/arm/cortex-m4/iar/los_arch_atomic.h
@@ -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
+ * The pointer v must not be NULL.
+ *
+ * @param v [IN] The variable pointer.
+ * @param val [IN] The exchange value.
+ *
+ * @retval #INT32 The previous value of the atomic variable
+ * @par Dependency:
+ * los_atomic.h: the header file that contains the API declaration.
+ * @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
+ *
+ * The pointer v must not be NULL.
+ * The value which v point to must not be INT_MIN to avoid overflow after reducing 1.
+ *
+ *
+ * @param v [IN] The addSelf variable pointer.
+ *
+ * @retval #INT32 The return value of variable auto-decrement.
+ * @par Dependency:
+ * los_atomic.h: the header file that contains the API declaration.
+ * @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
+ * The pointer v must not be NULL.
+ *
+ * @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:
+ * los_atomic.h: the header file that contains the API declaration.
+ * @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 */
+
diff --git a/kernel/arch/arm/cortex-m4/iar/los_context.h b/kernel/arch/arm/cortex-m4/iar/los_arch_context.h
old mode 100755
new mode 100644
similarity index 59%
rename from kernel/arch/arm/cortex-m4/iar/los_context.h
rename to kernel/arch/arm/cortex-m4/iar/los_arch_context.h
index d3ec0bd9..4759cb69
--- a/kernel/arch/arm/cortex-m4/iar/los_context.h
+++ b/kernel/arch/arm/cortex-m4/iar/los_arch_context.h
@@ -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:
- *
- *
- * @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:
- * los_hw.h: the header file that contains the API declaration.
- * @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:
- *
- *
- * @param None.
- *
- * @retval: None.
- * @par Dependency:
- * los_hw.h: the header file that contains the API declaration.
- * @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:
- *
- *
- * @param None.
- *
- * @retval: None.
- * @par Dependency:
- * los_hw.h: the header file that contains the API declaration.
- * @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:
+ *
+ *
+ * @param: None.
+ *
+ * @retval None.
+ *
+ * @par Dependency:
+ * los_config.h: the header file that contains the API declaration.
+ * @see None.
+ */
+extern VOID HalStartToRun(VOID);
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#endif /* _LOS_ARCH_CONTEXT_H */
+
diff --git a/kernel/arch/arm/cortex-m4/iar/los_interrupt.h b/kernel/arch/arm/cortex-m4/iar/los_arch_interrupt.h
old mode 100755
new mode 100644
similarity index 65%
rename from kernel/arch/arm/cortex-m4/iar/los_interrupt.h
rename to kernel/arch/arm/cortex-m4/iar/los_arch_interrupt.h
index a8ad5da2..6a271023
--- a/kernel/arch/arm/cortex-m4/iar/los_interrupt.h
+++ b/kernel/arch/arm/cortex-m4/iar/los_arch_interrupt.h
@@ -1,1085 +1,782 @@
-/*
- * 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_EXC_H
-#define _LOS_EXC_H
-
-#include "los_config.h"
-#include "los_compiler.h"
-
-#ifdef __cplusplus
-#if __cplusplus
-extern "C" {
-#endif /* __cpluscplus */
-#endif /* __cpluscplus */
-
-/* *
- * @ingroup los_hwi
- * Maximum number of used hardware interrupts.
- */
-#ifndef OS_HWI_MAX_NUM
-#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
-#endif
-
-/* *
- * @ingroup los_hwi
- * Highest priority of a hardware interrupt.
- */
-#ifndef OS_HWI_PRIO_HIGHEST
-#define OS_HWI_PRIO_HIGHEST 0
-#endif
-
-/* *
- * @ingroup los_hwi
- * Lowest priority of a hardware interrupt.
- */
-#ifndef OS_HWI_PRIO_LOWEST
-#define OS_HWI_PRIO_LOWEST 7
-#endif
-
-/* *
- * @ingroup los_config
- * Configuration item for interrupt with argument
- */
-#ifndef OS_HWI_WITH_ARG
-#define OS_HWI_WITH_ARG NO
-#endif
-
-/* *
- * @ingroup los_hwi
- * Define the type of a hardware interrupt number.
- */
-typedef UINT32 HWI_HANDLE_T;
-
-/* *
- * @ingroup los_hwi
- * Define the type of a hardware interrupt priority.
- */
-typedef UINT16 HWI_PRIOR_T;
-
-/* *
- * @ingroup los_hwi
- * Define the type of hardware interrupt mode configurations.
- */
-typedef UINT16 HWI_MODE_T;
-
-/* *
- * @ingroup los_hwi
- * Define the type of the parameter used for the hardware interrupt creation function. The function of this parameter varies among platforms.
- */
-typedef UINT32 HWI_ARG_T;
-
-/* *
- * @ingroup los_hwi
- * Define the type of a hardware interrupt handling function.
- */
-#if (OS_HWI_WITH_ARG == YES)
-
-typedef VOID (*HWI_PROC_FUNC)(VOID *parm);
-typedef struct {
- HWI_PROC_FUNC pfnHandler;
- VOID *pParm;
-} HWI_SLAVE_FUNC;
-
-#else
-
-typedef VOID (*HWI_PROC_FUNC)(void);
-
-#endif
-
-/* *
- * @ingroup los_hwi
- * Define the type of a hardware interrupt vector table function.
- */
-typedef VOID (**HWI_VECTOR_FUNC)(void);
-
-/* *
- * @ingroup los_hwi
- * Count of interrupts.
- */
-extern UINT32 g_vuwIntCount;
-
-/* *
- * @ingroup los_hwi
- * An interrupt is active.
- */
-#define OS_INT_ACTIVE (g_vuwIntCount > 0)
-
-/* *
- * @ingroup los_hwi
- * An interrupt is inactive.
- */
-#define OS_INT_INACTIVE (!(OS_INT_ACTIVE))
-
-/* *
- * @ingroup los_hwi
- * Count of M-Core system interrupt vector.
- */
-#define OS_SYS_VECTOR_CNT 16
-
-/* *
- * @ingroup los_hwi
- * Count of M-Core interrupt vector.
- */
-#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
-
-/* *
- * @ingroup los_hwi
- * AIRCR register priority group parameter .
- */
-#define OS_NVIC_AIRCR_PRIGROUP 7
-
-/* *
- * @ingroup los_hwi
- * Boot interrupt vector table.
- */
-extern UINT32 _BootVectors[];
-
-/* *
- * @ingroup los_hwi
- * Hardware interrupt error code: Invalid interrupt number.
- *
- * Value: 0x02000900
- *
- * Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable for a Cortex-A7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
- */
-#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
-
-/* *
- * @ingroup los_hwi
- * Hardware interrupt error code: Null hardware interrupt handling function.
- *
- * Value: 0x02000901
- *
- * Solution: Pass in a valid non-null hardware interrupt handling function.
- */
-#define OS_ERRNO_HWI_PROC_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01)
-
-/* *
- * @ingroup los_hwi
- * Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation.
- *
- * Value: 0x02000902
- *
- * Solution: Increase the configured maximum number of supported hardware interrupts.
- */
-#define OS_ERRNO_HWI_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02)
-
-/* *
- * @ingroup los_hwi
- * Hardware interrupt error code: Insufficient memory for hardware interrupt initialization.
- *
- * Value: 0x02000903
- *
- * Solution: Expand the configured memory.
- */
-#define OS_ERRNO_HWI_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03)
-
-/* *
- * @ingroup los_hwi
- * Hardware interrupt error code: The interrupt has already been created.
- *
- * Value: 0x02000904
- *
- * Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created.
- */
-#define OS_ERRNO_HWI_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04)
-
-/* *
- * @ingroup los_hwi
- * Hardware interrupt error code: Invalid interrupt priority.
- *
- * Value: 0x02000905
- *
- * Solution: Ensure that the interrupt priority is valid. The value range of the interrupt priority applicable for a Cortex-A7 platform is [0,15].
- */
-#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
-
-/* *
- * @ingroup los_hwi
- * Hardware interrupt error code: Incorrect interrupt creation mode.
- *
- * Value: 0x02000906
- *
- * Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the value can be 0 or 1.
- */
-#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
-
-/* *
- * @ingroup los_hwi
- * Hardware interrupt error code: The interrupt has already been created as a fast interrupt.
- *
- * Value: 0x02000907
- *
- * Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created.
- */
-#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
-
-/* *
- * @ingroup los_hwi
- * SysTick control and status register.
- */
-#define OS_SYSTICK_CONTROL_REG 0xE000E010
-
-/* *
- * @ingroup los_hw
- * SysTick current value register.
- */
-#define OS_SYSTICK_CURRENT_REG 0xE000E018
-
-/* *
- * @ingroup los_hwi
- * Interrupt Priority-Level Registers.
- */
-#define OS_NVIC_PRI_BASE 0xE000E400
-
-/* *
- * @ingroup los_hwi
- * Interrupt enable register for 0-31.
- */
-#define OS_NVIC_SETENA_BASE 0xE000E100
-
-/* *
- * @ingroup los_hwi
- * interrupt pending register.
- */
-#define OS_NVIC_SETPEND_BASE 0xE000E200
-
-/* *
- * @ingroup los_hwi
- * Interrupt active register.
- */
-#define OS_NVIC_INT_ACT_BASE 0xE000E300
-
-/* *
- * @ingroup los_hwi
- * Interrupt disable register for 0-31.
- */
-#define OS_NVIC_CLRENA_BASE 0xE000E180
-
-/* *
- * @ingroup los_hwi
- * Interrupt control and status register.
- */
-#define OS_NVIC_INT_CTRL 0xE000ED04
-
-/* *
- * @ingroup los_hwi
- * Vector table offset register.
- */
-#define OS_NVIC_VTOR 0xE000ED08
-
-/* *
- * @ingroup los_hwi
- * Application interrupt and reset control register
- */
-#define OS_NVIC_AIRCR 0xE000ED0C
-
-/* *
- * @ingroup los_hwi
- * System exception priority register.
- */
-#define OS_NVIC_EXCPRI_BASE 0xE000ED18
-
-/* *
- * @ingroup los_hwi
- * Interrupt No. 1 :reset.
- */
-#define OS_EXC_RESET 1
-
-/* *
- * @ingroup los_hwi
- * Interrupt No. 2 :Non-Maskable Interrupt.
- */
-#define OS_EXC_NMI 2
-
-/* *
- * @ingroup los_hwi
- * Interrupt No. 3 :(hard)fault.
- */
-#define OS_EXC_HARD_FAULT 3
-
-/* *
- * @ingroup los_hwi
- * Interrupt No. 4 :MemManage fault.
- */
-#define OS_EXC_MPU_FAULT 4
-
-/* *
- * @ingroup los_hwi
- * Interrupt No. 5 :Bus fault.
- */
-#define OS_EXC_BUS_FAULT 5
-
-/* *
- * @ingroup los_hwi
- * Interrupt No. 6 :Usage fault.
- */
-#define OS_EXC_USAGE_FAULT 6
-
-/* *
- * @ingroup los_hwi
- * Interrupt No. 11 :SVCall.
- */
-#define OS_EXC_SVC_CALL 11
-
-/* *
- * @ingroup los_hwi
- * Interrupt No. 12 :Debug monitor.
- */
-#define OS_EXC_DBG_MONITOR 12
-
-/* *
- * @ingroup los_hwi
- * Interrupt No. 14 :PendSV.
- */
-#define OS_EXC_PEND_SV 14
-
-/* *
- * @ingroup los_hwi
- * Interrupt No. 15 :SysTick.
- */
-#define OS_EXC_SYS_TICK 15
-
-/* *
- * @ingroup los_hwi
- * hardware interrupt form mapping handling function array.
- */
-extern HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT];
-
-#if (OS_HWI_WITH_ARG == YES)
-/* *
- * @ingroup los_hwi
- * hardware interrupt Slave form mapping handling function array.
- */
-extern HWI_SLAVE_FUNC g_hwiSlaveForm[OS_VECTOR_CNT];
-
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-#define OsSetVectonr(num, vector, arg) \
- do { \
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsInterrupt; \
- g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector; \
- g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT].pParm = (VOID *)arg; \
- } while(0)
-#else
-/* *
- * @ingroup los_hwi
- * hardware interrupt Slave form mapping handling function array.
- */
-extern HWI_PROC_FUNC g_hwiSlaveForm[OS_VECTOR_CNT];
-
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-#define OsSetVector(num, vector) \
- do { \
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = OsInterrupt; \
- g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT] = vector; \
- } while(0)
-#endif
-
-/* *
- * @ingroup los_hwi
- * @brief Create a hardware interrupt.
- *
- * @par Description:
- * This API is used to configure a hardware interrupt and register a hardware interrupt handling function.
- *
- * @attention
- *
- * The hardware interrupt module is usable only when the configuration item for hardware interrupt tailoring is enabled.
- * Hardware interrupt number value range: [OS_USER_HWI_MIN,OS_USER_HWI_MAX]. The value range applicable for a Cortex-A7 platform is [32,95].
- * OS_HWI_MAX_NUM specifies the maximum number of interrupts that can be created.
- * Before executing an interrupt on a platform, refer to the chip manual of the platform.
- *
- *
- * @param hwiNum [IN] Type#HWI_HANDLE_T: hardware interrupt number. The value range applicable for a Cortex-A7 platform is [32,95].
- * @param hwiPrio [IN] Type#HWI_PRIOR_T: hardware interrupt priority. Ignore this parameter temporarily.
- * @param mode [IN] Type#HWI_MODE_T: hardware interrupt mode. Ignore this parameter temporarily.
- * @param handler [IN] Type#HWI_PROC_FUNC: interrupt handler used when a hardware interrupt is triggered.
- * @param arg [IN] Type#HWI_ARG_T: input parameter of the interrupt handler used when a hardware interrupt is triggered.
- *
- * @retval #OS_ERRNO_HWI_PROC_FUNC_NULL 0x02000901: Null hardware interrupt handling function.
- * @retval #OS_ERRNO_HWI_NUM_INVALID 0x02000900: Invalid interrupt number.
- * @retval #OS_ERRNO_HWI_NO_MEMORY 0x02000903: Insufficient memory for hardware interrupt creation.
- * @retval #OS_ERRNO_HWI_ALREADY_CREATED 0x02000904: The interrupt handler being created has already been created.
- * @retval #LOS_OK 0 : The interrupt is successfully created.
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see None.
- */
-extern UINT32 LOS_HwiCreate(HWI_HANDLE_T hwiNum,
- HWI_PRIOR_T hwiPrio,
- HWI_MODE_T mode,
- HWI_PROC_FUNC handler,
- HWI_ARG_T arg);
-
-/* *
- * @ingroup los_hwi
- * @brief: Hardware interrupt entry function.
- *
- * @par Description:
- * This API is used as all hardware interrupt handling function entry.
- *
- * @attention:
- *
- *
- * @param:None.
- *
- * @retval:None.
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see None.
- */
-extern VOID OsInterrupt(VOID);
-
-/* *
- * @ingroup los_hwi
- * @brief: Get a interrupt number.
- *
- * @par Description:
- * This API is used to get the current interrupt number.
- *
- * @attention:
- *
- *
- * @param: None.
- *
- * @retval: Interrupt Indexes number.
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see None.
- */
-extern UINT32 OsIntNumGet(VOID);
-
-/* *
- * @ingroup los_hwi
- * @brief: Default vector handling function.
- *
- * @par Description:
- * This API is used to configure interrupt for null function.
- *
- * @attention:
- *
- *
- * @param:None.
- *
- * @retval:None.
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see None.
- */
-extern VOID OsHwiDefaultHandler(VOID);
-
-/* *
- * @ingroup los_hwi
- * @brief: Reset the vector table.
- *
- * @par Description:
- * This API is used to reset the vector table.
- *
- * @attention:
- *
- *
- * @param:None.
- *
- * @retval:None.
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see None.
- */
-extern VOID Reset_Handler(VOID);
-
-/* *
- * @ingroup los_hwi
- * @brief: Pended System Call.
- *
- * @par Description:
- * PendSV can be pended and is useful for an OS to pend an exception
- * so that an action can be performed after other important tasks are completed.
- *
- * @attention:
- *
- *
- * @param:None.
- *
- * @retval:None.
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see None.
- */
-extern VOID osPendSV(VOID);
-
-/* *
- * @ingroup los_hwi
- * @brief Enable all interrupts.
- *
- * @par Description:
- *
- * This API is used to enable all IRQ and FIQ interrupts in the CPSR.
- *
- * @attention
- *
- *
- * @param None.
- *
- * @retval CPSR value obtained after all interrupts are enabled.
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see LOS_IntRestore
- */
-extern UINTPTR LOS_IntUnLock(VOID);
-
-/* *
- * @ingroup los_hwi
- * @brief Disable all interrupts.
- *
- * @par Description:
- *
- * This API is used to disable all IRQ and FIQ interrupts in the CPSR.
- *
- * @attention
- *
- *
- * @param None.
- *
- * @retval CPSR value obtained before all interrupts are disabled.
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see LOS_IntRestore
- */
-extern UINTPTR LOS_IntLock(VOID);
-
-/* *
- * @ingroup los_hwi
- * @brief Restore interrupts.
- *
- * @par Description:
- *
- * This API is used to restore the CPSR value obtained before all interrupts are disabled.
- *
- * @attention
- *
- * This API can be called only after all interrupts are disabled, and the input parameter value should be the value returned by calling the all interrupt disabling API.
- *
- *
- * @param intSave [IN] CPSR value obtained before all interrupts are disabled.
- *
- * @retval None.
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see LOS_IntLock
- */
-extern VOID LOS_IntRestore(UINTPTR intSave);
-
-/* *
- * @ingroup los_hwi
- * @brief Get value from xPSR register.
- *
- * @par Description:
- *
- * This API is used to Get value from xPSR register.
- *
- * @attention
- *
- *
- * @param cntHi [IN] CpuTick High 4 byte
- * @param cntLo [IN] CpuTick Low 4 byte
- *
- * @retval None.
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see LOS_IntRestore
- */
-extern VOID LOS_GetCpuCycle(UINT32 *cntHi, UINT32 *cntLo);
-
-#if (LOSCFG_KERNEL_TICKLESS == YES)
-/**
- * @ingroup los_hwi
- * @brief reconfig systick, and clear SysTick_IRQn.
- *
- * @par Description:
- *
- * This API is used to reconfig systick, and clear SysTick_IRQn.
- *
- * @attention
- *
- *
- * @param cyclesPerTick [IN] Cycles Per Tick
- *
- * @retval None.
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see LOS_IntRestore
- */
-extern VOID LOS_SysTickReload(UINT32 cyclesPerTick);
-#endif
-
-/**
- * @ingroup los_hwi
- * @brief Get System cycle count.
- *
- * @par Description:
- *
- * This API is used to Get System cycle count.
- *
- * @attention
- *
- *
- * @param None.
- *
- * @retval: The value of the system cycle count.
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see LOS_IntRestore
- */
-extern UINT32 LOS_SysTickCurrCycleGet(VOID);
-
-extern VOID LOS_GetSystickCycle(UINT32 *puwCntHi, UINT32 *puwCntLo);
-
-/* *
- * @ingroup los_hwi
- * @brief Delete hardware interrupt.
- *
- * @par Description:
- * This API is used to delete hardware interrupt.
- *
- * @attention
- *
- * The hardware interrupt module is usable only when the configuration item for hardware interrupt tailoring is enabled.
- * Hardware interrupt number value range: [OS_USER_HWI_MIN,OS_USER_HWI_MAX]. The value range applicable for a Cortex-A7 platform is [32,95].
- * OS_HWI_MAX_NUM specifies the maximum number of interrupts that can be created.
- * Before executing an interrupt on a platform, refer to the chip manual of the platform.
- *
- *
- * @param hwiNum [IN] Type#HWI_HANDLE_T: hardware interrupt number. The value range applicable for a Cortex-A7 platform is [32,95].
- *
- * @retval #OS_ERRNO_HWI_NUM_INVALID 0x02000900: Invalid interrupt number.
- * @retval #LOS_OK 0 : The interrupt is successfully delete.
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see None.
- */
-extern UINT32 LOS_HwiDelete(HWI_HANDLE_T hwiNum);
-
-typedef enum {
- OS_SYS_NORMAL_SLEEP = 0,
- OS_SYS_DEEP_SLEEP,
-} LOS_SysSleepEnum;
-
-VOID LOS_TickLock(VOID);
-
-VOID LOS_TickUnlock(VOID);
-
-BOOL LOS_GetSysSleepFlag(VOID);
-
-VOID LOS_ClearSysSleepFlag(VOID);
-
-VOID LOS_EnterSleep(LOS_SysSleepEnum sleep);
-
-VOID LOS_SystemWakeup(UINT32 hwiIndex);
-
-#define OS_EXC_IN_INIT 0
-#define OS_EXC_IN_TASK 1
-#define OS_EXC_IN_HWI 2
-
-#define OS_EXC_MAX_BUF_LEN 25
-#define OS_EXC_MAX_NEST_DEPTH 1
-
-#define OS_NVIC_SHCSR 0xE000ED24
-#define OS_NVIC_CCR 0xE000ED14
-
-#define OS_NVIC_INT_ENABLE_SIZE 0x20
-#define OS_NVIC_INT_PRI_SIZE 0xF0
-#define OS_NVIC_EXCPRI_SIZE 0xC
-
-#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
-#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
-
-#define OS_EXC_FLAG_NO_FLOAT 0x10000000
-#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
-#define OS_EXC_FLAG_IN_HWI 0x02
-
-#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
-
-#define OS_EXC_EVENT 0x00000001
-
-/**
- *@ingroup los_exc
- * the struct of register files
- *
- * description: the register files that saved when exception triggered
- *
- * notes:the following register with prefix 'uw' correspond to the registers in the cpu data sheet.
- */
-typedef struct tagExcContext {
- //handler save
-#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;
- //auto save
- UINT32 uwSP;
- 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
-}EXC_CONTEXT_S;
-
-typedef UINT32 (*EXC_INFO_SAVE_CALLBACK)(UINT32, VOID*);
-typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
-VOID OsExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
-
-/**
- * @ingroup los_hwi
- * @brief: Exception initialization.
- *
- * @par Description:
- * This API is used to configure the exception function vector table.
- *
- * @attention:
- *
- *
- *@param uwArraySize [IN] Memory size of exception.
- *
- * @retval: None
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see None.
- */
-VOID OsExcInit(VOID);
-
-extern VOID OsExcNMI(VOID);
-extern VOID OsExcHardFault(VOID);
-extern VOID OsExcMemFault(VOID);
-extern VOID OsExcBusFault(VOID);
-extern VOID OsExcUsageFault(VOID);
-extern VOID OsExcSvcCall(VOID);
-extern UINT8 g_aucTaskArray[];
-
-extern void OsBackTrace();
-
-/**
- *@ingroup los_exc
- *@brief Kernel panic function.
- *
- *@par Description:
- *Stack function that prints kernel panics.
- *@attention After this function is called and stack information is printed, the system will fail to respond.
- *@attention The input parameter can be NULL.
- *@param fmt [IN] Type #char* : variadic argument.
- *
- *@retval #None.
- *
- *@par Dependency:
- *los_interrupt.h: the header file that contains the API declaration.
- *@see None.
-*/
-VOID LOS_Panic(const CHAR *fmt, ...);
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:总线状态寄存器入栈时发生错误
- */
-#define OS_EXC_BF_STKERR 1
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:总线状态寄存器出栈时发生错误
- */
-#define OS_EXC_BF_UNSTKERR 2
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:总线状态寄存器不精确的数据访问违例
- */
-#define OS_EXC_BF_IMPRECISERR 3
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:总线状态寄存器精确的数据访问违例
- */
-#define OS_EXC_BF_PRECISERR 4
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:总线状态寄存器取指时的访问违例
- */
-#define OS_EXC_BF_IBUSERR 5
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:存储器管理状态寄存器入栈时发生错误
- */
-#define OS_EXC_MF_MSTKERR 6
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:存储器管理状态寄存器出栈时发生错误
- */
-#define OS_EXC_MF_MUNSTKERR 7
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:存储器管理状态寄存器数据访问违例
- */
-#define OS_EXC_MF_DACCVIOL 8
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:存储器管理状态寄存器取指访问违例
- */
-#define OS_EXC_MF_IACCVIOL 9
-
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:用法错误,表示除法运算时除数为零
- */
-#define OS_EXC_UF_DIVBYZERO 10
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:用法错误,未对齐访问导致的错误
- */
-#define OS_EXC_UF_UNALIGNED 11
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:用法错误,试图执行协处理器相关指令
- */
-#define OS_EXC_UF_NOCP 12
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:用法错误,在异常返回时试图非法地加载EXC_RETURN到PC
- */
-#define OS_EXC_UF_INVPC 13
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:用法错误,试图切入ARM状态
- */
-#define OS_EXC_UF_INVSTATE 14
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:用法错误,执行的指令其编码是未定义的——解码不能
- */
-#define OS_EXC_UF_UNDEFINSTR 15
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:NMI中断
- */
-
-#define OS_EXC_CAUSE_NMI 16
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:硬fault
- */
-#define OS_EXC_CAUSE_HARDFAULT 17
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:任务处理函数退出
- */
-#define OS_EXC_CAUSE_TASK_EXIT 18
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:致命错误
- */
-#define OS_EXC_CAUSE_FATAL_ERR 19
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:调试事件导致的硬fault
- */
-#define OS_EXC_CAUSE_DEBUGEVT 20
-
-/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:取向量时发生的硬fault
- */
-#define OS_EXC_CAUSE_VECTBL 21
-
-/**
- *@ingroup los_exc
- * 异常信息结构体
- *
- * 描述:M4平台下的异常触发时保存的异常信息
- *
- */
-typedef struct tagExcInfo {
- /**< 异常发生阶段: 0表示异常发生在初始化中,1表示异常发生在任务中,2表示异常发生在中断中 */
- UINT16 phase;
- /**< 异常类型,出异常时对照上面列出的1-19号 */
- UINT16 type;
- /**< 若为精确地址访问错误表示异常发生时的错误访问地址 */
- UINT32 faultAddr;
- /**< 在中断中发生异常,表示中断号。在任务中发生异常,表示任务id,如果发生在初始化中,则为0xffffffff */
- UINT32 thrdPid;
- /**< 异常嵌套个数,目前仅支持第一次进入异常时执行注册的钩子函数 */
- UINT16 nestCnt;
- /**< 保留 */
- UINT16 reserved;
- /**< 自动压栈浮点寄存器的异常发生时刻的硬件上下文 */
- EXC_CONTEXT_S * context;
-} ExcInfo;
-
-extern UINT32 g_curNestCount;
-extern UINT32 g_vuwIntCount;
-
-static VOID OsExcSave2DDR(VOID);
-VOID OsExcInfoDisplay(ExcInfo *exc);
-
-extern UINT8 g_uwExcTbl[32];
-
-typedef enum {
- OS_EXC_TYPE_CONTEXT = 0,
- OS_EXC_TYPE_TSK = 1,
- OS_EXC_TYPE_QUE = 2,
- OS_EXC_TYPE_NVIC = 3,
- OS_EXC_TYPE_TSK_SWITCH = 4,
- OS_EXC_TYPE_MEM = 5,
- OS_EXC_TYPE_MAX = 6
-} ExcInfoType;
-
-typedef struct tagExcInfoCallBackArray {
- ExcInfoType uwType;
- UINT32 uwValid;
- EXC_INFO_SAVE_CALLBACK pFnExcInfoCb;
- VOID* pArg;
-} ExcInfoArray;
-
-
-
-#define MAX_SCENE_INFO_SIZE (8 + sizeof(ExcInfo) - 4 + sizeof(EXC_CONTEXT_S))
-#define MAX_TSK_INFO_SIZE (8 + sizeof(TSK_INFO_S) * (LOSCFG_BASE_CORE_TSK_LIMIT + 1))
-#define MAX_INT_INFO_SIZE (8 + 0x164)
-
-#if (LOSCFG_BASE_IPC_QUEUE == YES)
-#define MAX_QUEUE_INFO_SIZE (8 + sizeof(QUEUE_INFO_S) * LOSCFG_BASE_IPC_QUEUE_LIMIT)
-#else
-#define MAX_QUEUE_INFO_SIZE (0)
-#endif
-
-#if (LOSCFG_BASE_CORE_EXC_TSK_SWITCH == YES)
-#define MAX_SWITCH_INFO_SIZE (8 + (sizeof(UINT32) + sizeof(CHAR) * LOS_TASK_NAMELEN) * OS_TASK_SWITCH_INFO_COUNT)
-#else
-#define MAX_SWITCH_INFO_SIZE (0)
-#endif
-
-#if (LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK == YES)
-#define MAX_MEM_INFO_SIZE (8 + sizeof(MEM_INFO_S) * OS_SYS_MEM_NUM)
-#else
-#define MAX_MEM_INFO_SIZE (0)
-#endif
-
-#define MAX_EXC_MEM_SIZE ( 4 + MAX_SCENE_INFO_SIZE + MAX_TSK_INFO_SIZE + MAX_QUEUE_INFO_SIZE + MAX_INT_INFO_SIZE + MAX_SWITCH_INFO_SIZE + MAX_MEM_INFO_SIZE + 4)
-
-VOID OsExcRegister(ExcInfoType type, EXC_INFO_SAVE_CALLBACK func, VOID *arg);
-VOID LOS_Reboot(VOID);
-
-#ifdef __cplusplus
-#if __cplusplus
-}
-#endif /* __cpluscplus */
-#endif /* __cpluscplus */
-
-#endif /* _LOS_EXC_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_EXC_H
+#define _LOS_EXC_H
+
+#include "los_config.h"
+#include "los_compiler.h"
+#include "los_interrupt.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+/* *
+ * @ingroup los_hwi
+ * Maximum number of used hardware interrupts.
+ */
+#ifndef OS_HWI_MAX_NUM
+#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
+#endif
+
+/* *
+ * @ingroup los_hwi
+ * Highest priority of a hardware interrupt.
+ */
+#ifndef OS_HWI_PRIO_HIGHEST
+#define OS_HWI_PRIO_HIGHEST 0
+#endif
+
+/* *
+ * @ingroup los_hwi
+ * Lowest priority of a hardware interrupt.
+ */
+#ifndef OS_HWI_PRIO_LOWEST
+#define OS_HWI_PRIO_LOWEST 7
+#endif
+
+
+/* *
+ * @ingroup los_hwi
+ * Define the type of a hardware interrupt vector table function.
+ */
+typedef VOID (**HWI_VECTOR_FUNC)(void);
+
+/* *
+ * @ingroup los_hwi
+ * Count of interrupts.
+ */
+extern UINT32 g_intCount;
+
+/* *
+ * @ingroup los_hwi
+ * Count of M-Core system interrupt vector.
+ */
+#define OS_SYS_VECTOR_CNT 16
+
+/* *
+ * @ingroup los_hwi
+ * Count of M-Core interrupt vector.
+ */
+#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
+
+/* *
+ * @ingroup los_hwi
+ * AIRCR register priority group parameter .
+ */
+#define OS_NVIC_AIRCR_PRIGROUP 7
+
+/* *
+ * @ingroup los_hwi
+ * Boot interrupt vector table.
+ */
+extern UINT32 _BootVectors[];
+
+/* *
+ * @ingroup los_hwi
+ * Hardware interrupt error code: Invalid interrupt number.
+ *
+ * Value: 0x02000900
+ *
+ * Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable for a Cortex-A7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
+ */
+#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
+
+/* *
+ * @ingroup los_hwi
+ * Hardware interrupt error code: Null hardware interrupt handling function.
+ *
+ * Value: 0x02000901
+ *
+ * Solution: Pass in a valid non-null hardware interrupt handling function.
+ */
+#define OS_ERRNO_HWI_PROC_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01)
+
+/* *
+ * @ingroup los_hwi
+ * Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation.
+ *
+ * Value: 0x02000902
+ *
+ * Solution: Increase the configured maximum number of supported hardware interrupts.
+ */
+#define OS_ERRNO_HWI_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02)
+
+/* *
+ * @ingroup los_hwi
+ * Hardware interrupt error code: Insufficient memory for hardware interrupt initialization.
+ *
+ * Value: 0x02000903
+ *
+ * Solution: Expand the configured memory.
+ */
+#define OS_ERRNO_HWI_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03)
+
+/* *
+ * @ingroup los_hwi
+ * Hardware interrupt error code: The interrupt has already been created.
+ *
+ * Value: 0x02000904
+ *
+ * Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created.
+ */
+#define OS_ERRNO_HWI_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04)
+
+/* *
+ * @ingroup los_hwi
+ * Hardware interrupt error code: Invalid interrupt priority.
+ *
+ * Value: 0x02000905
+ *
+ * Solution: Ensure that the interrupt priority is valid. The value range of the interrupt priority applicable for a Cortex-A7 platform is [0,15].
+ */
+#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
+
+/* *
+ * @ingroup los_hwi
+ * Hardware interrupt error code: Incorrect interrupt creation mode.
+ *
+ * Value: 0x02000906
+ *
+ * Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the value can be 0 or 1.
+ */
+#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
+
+/* *
+ * @ingroup los_hwi
+ * Hardware interrupt error code: The interrupt has already been created as a fast interrupt.
+ *
+ * Value: 0x02000907
+ *
+ * Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created.
+ */
+#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
+
+/* *
+ * @ingroup los_hwi
+ * SysTick control and status register.
+ */
+#define OS_SYSTICK_CONTROL_REG 0xE000E010
+
+/* *
+ * @ingroup los_hw
+ * SysTick current value register.
+ */
+#define OS_SYSTICK_CURRENT_REG 0xE000E018
+
+/* *
+ * @ingroup los_hwi
+ * Interrupt Priority-Level Registers.
+ */
+#define OS_NVIC_PRI_BASE 0xE000E400
+
+/* *
+ * @ingroup los_hwi
+ * Interrupt enable register for 0-31.
+ */
+#define OS_NVIC_SETENA_BASE 0xE000E100
+
+/* *
+ * @ingroup los_hwi
+ * interrupt pending register.
+ */
+#define OS_NVIC_SETPEND_BASE 0xE000E200
+
+/* *
+ * @ingroup los_hwi
+ * Interrupt active register.
+ */
+#define OS_NVIC_INT_ACT_BASE 0xE000E300
+
+/* *
+ * @ingroup los_hwi
+ * Interrupt disable register for 0-31.
+ */
+#define OS_NVIC_CLRENA_BASE 0xE000E180
+
+/* *
+ * @ingroup los_hwi
+ * Interrupt control and status register.
+ */
+#define OS_NVIC_INT_CTRL 0xE000ED04
+
+/* *
+ * @ingroup los_hwi
+ * Vector table offset register.
+ */
+#define OS_NVIC_VTOR 0xE000ED08
+
+/* *
+ * @ingroup los_hwi
+ * Application interrupt and reset control register
+ */
+#define OS_NVIC_AIRCR 0xE000ED0C
+
+/* *
+ * @ingroup los_hwi
+ * System exception priority register.
+ */
+#define OS_NVIC_EXCPRI_BASE 0xE000ED18
+
+/* *
+ * @ingroup los_hwi
+ * Interrupt No. 1 :reset.
+ */
+#define OS_EXC_RESET 1
+
+/* *
+ * @ingroup los_hwi
+ * Interrupt No. 2 :Non-Maskable Interrupt.
+ */
+#define OS_EXC_NMI 2
+
+/* *
+ * @ingroup los_hwi
+ * Interrupt No. 3 :(hard)fault.
+ */
+#define OS_EXC_HARD_FAULT 3
+
+/* *
+ * @ingroup los_hwi
+ * Interrupt No. 4 :MemManage fault.
+ */
+#define OS_EXC_MPU_FAULT 4
+
+/* *
+ * @ingroup los_hwi
+ * Interrupt No. 5 :Bus fault.
+ */
+#define OS_EXC_BUS_FAULT 5
+
+/* *
+ * @ingroup los_hwi
+ * Interrupt No. 6 :Usage fault.
+ */
+#define OS_EXC_USAGE_FAULT 6
+
+/* *
+ * @ingroup los_hwi
+ * Interrupt No. 11 :SVCall.
+ */
+#define OS_EXC_SVC_CALL 11
+
+/* *
+ * @ingroup los_hwi
+ * Interrupt No. 12 :Debug monitor.
+ */
+#define OS_EXC_DBG_MONITOR 12
+
+/* *
+ * @ingroup los_hwi
+ * Interrupt No. 14 :PendSV.
+ */
+#define OS_EXC_PEND_SV 14
+
+/* *
+ * @ingroup los_hwi
+ * Interrupt No. 15 :SysTick.
+ */
+#define OS_EXC_SYS_TICK 15
+
+/* *
+ * @ingroup los_hwi
+ * hardware interrupt form mapping handling function array.
+ */
+extern HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT];
+
+#if (OS_HWI_WITH_ARG == 1)
+/* *
+ * @ingroup los_hwi
+ * hardware interrupt Slave form mapping handling function array.
+ */
+extern HWI_SLAVE_FUNC g_hwiSlaveForm[OS_VECTOR_CNT];
+
+/* *
+ * @ingroup los_hwi
+ * Set interrupt vector table.
+ */
+#define OsSetVectonr(num, vector, arg) \
+ do { \
+ g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt; \
+ g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector; \
+ g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT].pParm = (VOID *)arg; \
+ } while(0)
+#else
+/* *
+ * @ingroup los_hwi
+ * hardware interrupt Slave form mapping handling function array.
+ */
+extern HWI_PROC_FUNC g_hwiSlaveForm[OS_VECTOR_CNT];
+
+/* *
+ * @ingroup los_hwi
+ * Set interrupt vector table.
+ */
+#define OsSetVector(num, vector) \
+ do { \
+ g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt; \
+ g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT] = vector; \
+ } while(0)
+#endif
+
+/* *
+ * @ingroup los_hwi
+ * @brief: Hardware interrupt entry function.
+ *
+ * @par Description:
+ * This API is used as all hardware interrupt handling function entry.
+ *
+ * @attention:
+ *
+ *
+ * @param:None.
+ *
+ * @retval:None.
+ * @par Dependency:
+ * los_hwi.h: the header file that contains the API declaration.
+ * @see None.
+ */
+extern VOID HalInterrupt(VOID);
+
+/* *
+ * @ingroup los_hwi
+ * @brief: Get a interrupt number.
+ *
+ * @par Description:
+ * This API is used to get the current interrupt number.
+ *
+ * @attention:
+ *
+ *
+ * @param: None.
+ *
+ * @retval: Interrupt Indexes number.
+ * @par Dependency:
+ * los_hwi.h: the header file that contains the API declaration.
+ * @see None.
+ */
+extern UINT32 HalIntNumGet(VOID);
+
+/* *
+ * @ingroup los_hwi
+ * @brief: Default vector handling function.
+ *
+ * @par Description:
+ * This API is used to configure interrupt for null function.
+ *
+ * @attention:
+ *
+ *
+ * @param:None.
+ *
+ * @retval:None.
+ * @par Dependency:
+ * los_hwi.h: the header file that contains the API declaration.
+ * @see None.
+ */
+extern VOID HalHwiDefaultHandler(VOID);
+
+/* *
+ * @ingroup los_hwi
+ * @brief: Reset the vector table.
+ *
+ * @par Description:
+ * This API is used to reset the vector table.
+ *
+ * @attention:
+ *
+ *
+ * @param:None.
+ *
+ * @retval:None.
+ * @par Dependency:
+ * los_hwi.h: the header file that contains the API declaration.
+ * @see None.
+ */
+extern VOID Reset_Handler(VOID);
+
+/* *
+ * @ingroup los_hwi
+ * @brief: Pended System Call.
+ *
+ * @par Description:
+ * PendSV can be pended and is useful for an OS to pend an exception
+ * so that an action can be performed after other important tasks are completed.
+ *
+ * @attention:
+ *
+ *
+ * @param:None.
+ *
+ * @retval:None.
+ * @par Dependency:
+ * los_hwi.h: the header file that contains the API declaration.
+ * @see None.
+ */
+extern VOID HalPendSV(VOID);
+
+
+#define OS_EXC_IN_INIT 0
+#define OS_EXC_IN_TASK 1
+#define OS_EXC_IN_HWI 2
+
+#define OS_EXC_MAX_BUF_LEN 25
+#define OS_EXC_MAX_NEST_DEPTH 1
+
+#define OS_NVIC_SHCSR 0xE000ED24
+#define OS_NVIC_CCR 0xE000ED14
+
+#define OS_NVIC_INT_ENABLE_SIZE 0x20
+#define OS_NVIC_INT_PRI_SIZE 0xF0
+#define OS_NVIC_EXCPRI_SIZE 0xC
+
+#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
+#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
+
+#define OS_EXC_FLAG_NO_FLOAT 0x10000000
+#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
+#define OS_EXC_FLAG_IN_HWI 0x02
+
+#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
+
+#define OS_EXC_EVENT 0x00000001
+
+/**
+ *@ingroup los_exc
+ * the struct of register files
+ *
+ * description: the register files that saved when exception triggered
+ *
+ * notes:the following register with prefix 'uw' correspond to the registers in the cpu data sheet.
+ */
+typedef struct tagExcContext {
+ //handler save
+#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;
+ //auto save
+ UINT32 uwSP;
+ 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
+}EXC_CONTEXT_S;
+
+typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
+VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
+
+/**
+ * @ingroup los_hwi
+ * @brief: Exception initialization.
+ *
+ * @par Description:
+ * This API is used to configure the exception function vector table.
+ *
+ * @attention:
+ *
+ *
+ *@param uwArraySize [IN] Memory size of exception.
+ *
+ * @retval: None
+ * @par Dependency:
+ * los_hwi.h: the header file that contains the API declaration.
+ * @see None.
+ */
+VOID OsExcInit(VOID);
+
+VOID HalExcNMI(VOID);
+VOID HalExcHardFault(VOID);
+VOID HalExcMemFault(VOID);
+VOID HalExcBusFault(VOID);
+VOID HalExcUsageFault(VOID);
+VOID HalExcSvcCall(VOID);
+VOID HalHwiInit();
+
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:总线状态寄存器入栈时发生错误
+ */
+#define OS_EXC_BF_STKERR 1
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:总线状态寄存器出栈时发生错误
+ */
+#define OS_EXC_BF_UNSTKERR 2
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:总线状态寄存器不精确的数据访问违例
+ */
+#define OS_EXC_BF_IMPRECISERR 3
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:总线状态寄存器精确的数据访问违例
+ */
+#define OS_EXC_BF_PRECISERR 4
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:总线状态寄存器取指时的访问违例
+ */
+#define OS_EXC_BF_IBUSERR 5
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:存储器管理状态寄存器入栈时发生错误
+ */
+#define OS_EXC_MF_MSTKERR 6
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:存储器管理状态寄存器出栈时发生错误
+ */
+#define OS_EXC_MF_MUNSTKERR 7
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:存储器管理状态寄存器数据访问违例
+ */
+#define OS_EXC_MF_DACCVIOL 8
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:存储器管理状态寄存器取指访问违例
+ */
+#define OS_EXC_MF_IACCVIOL 9
+
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:用法错误,表示除法运算时除数为零
+ */
+#define OS_EXC_UF_DIVBYZERO 10
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:用法错误,未对齐访问导致的错误
+ */
+#define OS_EXC_UF_UNALIGNED 11
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:用法错误,试图执行协处理器相关指令
+ */
+#define OS_EXC_UF_NOCP 12
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:用法错误,在异常返回时试图非法地加载EXC_RETURN到PC
+ */
+#define OS_EXC_UF_INVPC 13
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:用法错误,试图切入ARM状态
+ */
+#define OS_EXC_UF_INVSTATE 14
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:用法错误,执行的指令其编码是未定义的——解码不能
+ */
+#define OS_EXC_UF_UNDEFINSTR 15
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:NMI中断
+ */
+
+#define OS_EXC_CAUSE_NMI 16
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:硬fault
+ */
+#define OS_EXC_CAUSE_HARDFAULT 17
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:任务处理函数退出
+ */
+#define OS_EXC_CAUSE_TASK_EXIT 18
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:致命错误
+ */
+#define OS_EXC_CAUSE_FATAL_ERR 19
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:调试事件导致的硬fault
+ */
+#define OS_EXC_CAUSE_DEBUGEVT 20
+
+/**
+ *@ingroup los_exc
+ *Cortex-M3异常具体类型:取向量时发生的硬fault
+ */
+#define OS_EXC_CAUSE_VECTBL 21
+
+/**
+ *@ingroup los_exc
+ * 异常信息结构体
+ *
+ * 描述:M4平台下的异常触发时保存的异常信息
+ *
+ */
+typedef struct tagExcInfo {
+ /**< 异常发生阶段: 0表示异常发生在初始化中,1表示异常发生在任务中,2表示异常发生在中断中 */
+ UINT16 phase;
+ /**< 异常类型,出异常时对照上面列出的1-19号 */
+ UINT16 type;
+ /**< 若为精确地址访问错误表示异常发生时的错误访问地址 */
+ UINT32 faultAddr;
+ /**< 在中断中发生异常,表示中断号。在任务中发生异常,表示任务id,如果发生在初始化中,则为0xffffffff */
+ UINT32 thrdPid;
+ /**< 异常嵌套个数,目前仅支持第一次进入异常时执行注册的钩子函数 */
+ UINT16 nestCnt;
+ /**< 保留 */
+ UINT16 reserved;
+ /**< 自动压栈浮点寄存器的异常发生时刻的硬件上下文 */
+ EXC_CONTEXT_S * context;
+} ExcInfo;
+
+extern UINT32 g_curNestCount;
+extern UINT32 g_intCount;
+
+static VOID OsExcSave2DDR(VOID);
+VOID OsExcInfoDisplay(ExcInfo *exc);
+
+extern UINT8 g_uwExcTbl[32];
+
+
+
+typedef struct tagExcInfoCallBackArray {
+ ExcInfoType uwType;
+ UINT32 uwValid;
+ EXC_INFO_SAVE_CALLBACK pFnExcInfoCb;
+ VOID* pArg;
+} ExcInfoArray;
+
+
+
+#define MAX_SCENE_INFO_SIZE (8 + sizeof(ExcInfo) - 4 + sizeof(EXC_CONTEXT_S))
+#define MAX_TSK_INFO_SIZE (8 + sizeof(TSK_INFO_S) * (LOSCFG_BASE_CORE_TSK_LIMIT + 1))
+#define MAX_INT_INFO_SIZE (8 + 0x164)
+
+#if (LOSCFG_BASE_IPC_QUEUE == 1)
+#define MAX_QUEUE_INFO_SIZE (8 + sizeof(QUEUE_INFO_S) * LOSCFG_BASE_IPC_QUEUE_LIMIT)
+#else
+#define MAX_QUEUE_INFO_SIZE (0)
+#endif
+
+#if (LOSCFG_BASE_CORE_EXC_TSK_SWITCH == 1)
+#define MAX_SWITCH_INFO_SIZE (8 + (sizeof(UINT32) + sizeof(CHAR) * LOS_TASK_NAMELEN) * OS_TASK_SWITCH_INFO_COUNT)
+#else
+#define MAX_SWITCH_INFO_SIZE (0)
+#endif
+
+#if (LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK == 1)
+#define MAX_MEM_INFO_SIZE (8 + sizeof(MEM_INFO_S) * OS_SYS_MEM_NUM)
+#else
+#define MAX_MEM_INFO_SIZE (0)
+#endif
+
+#define MAX_EXC_MEM_SIZE ( 4 + MAX_SCENE_INFO_SIZE + MAX_TSK_INFO_SIZE + MAX_QUEUE_INFO_SIZE + MAX_INT_INFO_SIZE + MAX_SWITCH_INFO_SIZE + MAX_MEM_INFO_SIZE + 4)
+
+
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#endif /* _LOS_EXC_H */
+
diff --git a/kernel/arch/arm/cortex-m4/iar/los_arch_timer.h b/kernel/arch/arm/cortex-m4/iar/los_arch_timer.h
new file mode 100644
index 00000000..2f38c220
--- /dev/null
+++ b/kernel/arch/arm/cortex-m4/iar/los_arch_timer.h
@@ -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 */
+
diff --git a/kernel/arch/arm/cortex-m4/iar/los_hw.c b/kernel/arch/arm/cortex-m4/iar/los_context.c
old mode 100755
new mode 100644
similarity index 80%
rename from kernel/arch/arm/cortex-m4/iar/los_hw.c
rename to kernel/arch/arm/cortex-m4/iar/los_context.c
index 6eabc65c..f15654fa
--- a/kernel/arch/arm/cortex-m4/iar/los_hw.c
+++ b/kernel/arch/arm/cortex-m4/iar/los_context.c
@@ -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
diff --git a/kernel/arch/arm/cortex-m4/iar/los_dispatch.S b/kernel/arch/arm/cortex-m4/iar/los_dispatch.S
old mode 100755
new mode 100644
index 67c2e8ba..d540c75d
--- a/kernel/arch/arm/cortex-m4/iar/los_dispatch.S
+++ b/kernel/arch/arm/cortex-m4/iar/los_dispatch.S
@@ -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}
diff --git a/kernel/arch/arm/cortex-m4/iar/los_hw_exc.S b/kernel/arch/arm/cortex-m4/iar/los_exc.S
old mode 100755
new mode 100644
similarity index 92%
rename from kernel/arch/arm/cortex-m4/iar/los_hw_exc.S
rename to kernel/arch/arm/cortex-m4/iar/los_exc.S
index 80761817..cd356889
--- a/kernel/arch/arm/cortex-m4/iar/los_hw_exc.S
+++ b/kernel/arch/arm/cortex-m4/iar/los_exc.S
@@ -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
diff --git a/kernel/arch/arm/cortex-m4/iar/los_interrupt.c b/kernel/arch/arm/cortex-m4/iar/los_interrupt.c
old mode 100755
new mode 100644
index 494a2ac7..8dccb56e
--- a/kernel/arch/arm/cortex-m4/iar/los_interrupt.c
+++ b/kernel/arch/arm/cortex-m4/iar/los_interrupt.c
@@ -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
#include "los_debug.h"
#include "los_task.h"
-#if (LOSCFG_KERNEL_TICKLESS == YES)
-#include "los_tick.h"
-#endif
#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"
+#pragma data_alignment=0x100
#elif defined(__CC_ARM) || defined(__GNUC__)
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,8 @@ 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;
- }
-
- OsExcRegister(OS_EXC_TYPE_CONTEXT, (EXC_INFO_SAVE_CALLBACK)OsExcContextDump, NULL);
- OsExcRegister(OS_EXC_TYPE_NVIC, (EXC_INFO_SAVE_CALLBACK)OsExcNvicDump, NULL);
+ HalExcRegister(OS_EXC_TYPE_CONTEXT, (EXC_INFO_SAVE_CALLBACK)HalExcContextDump, NULL);
+ HalExcRegister(OS_EXC_TYPE_NVIC, (EXC_INFO_SAVE_CALLBACK)HalExcNvicDump, NULL);
return;
}
diff --git a/kernel/arch/arm/cortex-m4/iar/los_hw_tick.c b/kernel/arch/arm/cortex-m4/iar/los_timer.c
old mode 100755
new mode 100644
similarity index 69%
rename from kernel/arch/arm/cortex-m4/iar/los_hw_tick.c
rename to kernel/arch/arm/cortex-m4/iar/los_timer.c
index e3a74b98..2428c4f2
--- a/kernel/arch/arm/cortex-m4/iar/los_hw_tick.c
+++ b/kernel/arch/arm/cortex-m4/iar/los_timer.c
@@ -28,28 +28,27 @@
* 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 "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;
@@ -59,10 +58,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;
@@ -76,32 +75,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;
@@ -121,14 +102,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;
@@ -157,14 +138,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;
@@ -200,62 +181,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
}
diff --git a/kernel/arch/include/los_arch.h b/kernel/arch/include/los_arch.h
new file mode 100644
index 00000000..5794e3bd
--- /dev/null
+++ b/kernel/arch/include/los_arch.h
@@ -0,0 +1,56 @@
+/*
+ * 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_H
+#define _LOS_ARCH_H
+
+#include "los_config.h"
+#include "los_compiler.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+VOID HalArchInit();
+void HalBackTrace();
+#define LOS_BackTrace HalBackTrace
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#endif /* _LOS_ARCH_H */
+
diff --git a/kernel/arch/include/los_atomic.h b/kernel/arch/include/los_atomic.h
new file mode 100644
index 00000000..6ff27f8d
--- /dev/null
+++ b/kernel/arch/include/los_atomic.h
@@ -0,0 +1,51 @@
+/*
+ * 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 */
+
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#endif /* LOS_ATOMIC_H */
+
diff --git a/kernel/arch/include/los_context.h b/kernel/arch/include/los_context.h
new file mode 100644
index 00000000..ebb1a4c4
--- /dev/null
+++ b/kernel/arch/include/los_context.h
@@ -0,0 +1,127 @@
+/*
+ * 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
+
+#include "los_compiler.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+/* *
+ * @ingroup los_hw
+ * @brief: Task stack initialization.
+ *
+ * @par Description:
+ * This API is used to initialize the task stack.
+ *
+ * @attention:
+ *
+ *
+ * @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:
+ * los_hw.h: the header file that contains the API declaration.
+ * @see None.
+ */
+extern VOID *HalTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack);
+/**
+ * @ingroup los_hw
+ * @brief: Function to sys exit.
+ *
+ * @par Description:
+ * This API is used to sys exit.
+ *
+ * @attention:
+ *
+ *
+ * @param None.
+ *
+ * @retval: None.
+ * @par Dependency:
+ * los_hw.h: the header file that contains the API declaration.
+ * @see None.
+ */
+LITE_OS_SEC_TEXT_MINOR VOID HalSysExit(VOID);
+
+/* *
+ * @ingroup los_context
+ * @brief: Task scheduling Function.
+ *
+ * @par Description:
+ * This API is used to scheduling task.
+ *
+ * @attention:
+ *
+ *
+ * @param None.
+ *
+ * @retval: None.
+ * @par Dependency:
+ * los_context.h: the header file that contains the API declaration.
+ * @see None.
+ */
+extern VOID HalTaskSchedule(VOID);
+
+typedef VOID (*OS_TICK_HANDLER)(VOID);
+UINT32 HalStartSchedule(OS_TICK_HANDLER handler);
+
+UINTPTR HalIntLock(VOID);
+#define LOS_IntLock HalIntLock
+
+VOID HalIntRestore(UINTPTR intSave);
+#define LOS_IntRestore HalIntRestore
+
+UINTPTR HalIntUnLock(VOID);
+#define LOS_IntUnLock HalIntUnLock
+
+
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#endif /* _LOS_HW_H */
+
diff --git a/kernel/arch/include/los_interrupt.h b/kernel/arch/include/los_interrupt.h
new file mode 100644
index 00000000..ee4ef2e0
--- /dev/null
+++ b/kernel/arch/include/los_interrupt.h
@@ -0,0 +1,156 @@
+/*
+ * 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_INTERRUPT_H
+#define _LOS_INTERRUPT_H
+#include "los_config.h"
+#include "los_compiler.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+/* *
+ * @ingroup los_config
+ * Configuration item for interrupt with argument
+ */
+#ifndef OS_HWI_WITH_ARG
+#define OS_HWI_WITH_ARG 0
+#endif
+
+typedef UINT32 HWI_HANDLE_T;
+
+typedef UINT16 HWI_PRIOR_T;
+
+typedef UINT16 HWI_MODE_T;
+
+typedef UINT32 HWI_ARG_T;
+
+typedef enum {
+ OS_EXC_TYPE_CONTEXT = 0,
+ OS_EXC_TYPE_TSK = 1,
+ OS_EXC_TYPE_QUE = 2,
+ OS_EXC_TYPE_NVIC = 3,
+ OS_EXC_TYPE_TSK_SWITCH = 4,
+ OS_EXC_TYPE_MEM = 5,
+ OS_EXC_TYPE_MAX = 6
+} ExcInfoType;
+
+typedef UINT32 (*EXC_INFO_SAVE_CALLBACK)(UINT32, VOID*);
+
+#if (OS_HWI_WITH_ARG == 1)
+typedef VOID (*HWI_PROC_FUNC)(VOID *parm);
+typedef struct {
+ HWI_PROC_FUNC pfnHandler;
+ VOID *pParm;
+} HWI_SLAVE_FUNC;
+
+#else
+
+typedef VOID (*HWI_PROC_FUNC)(void);
+
+#endif
+UINT32 HalIsIntAcvive(VOID);
+#define OS_INT_ACTIVE (HalIsIntAcvive())
+#define OS_INT_INACTIVE (!(OS_INT_ACTIVE))
+
+VOID HalExcRegister(ExcInfoType type, EXC_INFO_SAVE_CALLBACK func, VOID *arg);
+/* *
+ * @ingroup los_hwi
+ * @brief Delete hardware interrupt.
+ *
+ * @par Description:
+ * This API is used to delete hardware interrupt.
+ *
+ * @attention
+ *
+ * The hardware interrupt module is usable only when the configuration item for hardware interrupt tailoring is enabled.
+ * Hardware interrupt number value range: [OS_USER_HWI_MIN,OS_USER_HWI_MAX]. The value range applicable for a Cortex-A7 platform is [32,95].
+ * OS_HWI_MAX_NUM specifies the maximum number of interrupts that can be created.
+ * Before executing an interrupt on a platform, refer to the chip manual of the platform.
+ *
+ *
+ * @param hwiNum [IN] Type#HWI_HANDLE_T: hardware interrupt number. The value range applicable for a Cortex-A7 platform is [32,95].
+ *
+ * @retval #OS_ERRNO_HWI_NUM_INVALID 0x02000900: Invalid interrupt number.
+ * @retval #LOS_OK 0 : The interrupt is successfully delete.
+ * @par Dependency:
+ * los_hwi.h: the header file that contains the API declaration.
+ * @see None.
+ */
+extern UINT32 HalHwiDelete(HWI_HANDLE_T hwiNum);
+
+/* *
+ * @ingroup los_hwi
+ * @brief Create a hardware interrupt.
+ *
+ * @par Description:
+ * This API is used to configure a hardware interrupt and register a hardware interrupt handling function.
+ *
+ * @attention
+ *
+ * The hardware interrupt module is usable only when the configuration item for hardware interrupt tailoring is enabled.
+ * Hardware interrupt number value range: [OS_USER_HWI_MIN,OS_USER_HWI_MAX]. The value range applicable for a Cortex-A7 platform is [32,95].
+ * OS_HWI_MAX_NUM specifies the maximum number of interrupts that can be created.
+ * Before executing an interrupt on a platform, refer to the chip manual of the platform.
+ *
+ *
+ * @param hwiNum [IN] Type#HWI_HANDLE_T: hardware interrupt number. The value range applicable for a Cortex-A7 platform is [32,95].
+ * @param hwiPrio [IN] Type#HWI_PRIOR_T: hardware interrupt priority. Ignore this parameter temporarily.
+ * @param mode [IN] Type#HWI_MODE_T: hardware interrupt mode. Ignore this parameter temporarily.
+ * @param handler [IN] Type#HWI_PROC_FUNC: interrupt handler used when a hardware interrupt is triggered.
+ * @param arg [IN] Type#HWI_ARG_T: input parameter of the interrupt handler used when a hardware interrupt is triggered.
+ *
+ * @retval #OS_ERRNO_HWI_PROC_FUNC_NULL 0x02000901: Null hardware interrupt handling function.
+ * @retval #OS_ERRNO_HWI_NUM_INVALID 0x02000900: Invalid interrupt number.
+ * @retval #OS_ERRNO_HWI_NO_MEMORY 0x02000903: Insufficient memory for hardware interrupt creation.
+ * @retval #OS_ERRNO_HWI_ALREADY_CREATED 0x02000904: The interrupt handler being created has already been created.
+ * @retval #LOS_OK 0 : The interrupt is successfully created.
+ * @par Dependency:
+ * los_hwi.h: the header file that contains the API declaration.
+ * @see None.
+ */
+extern UINT32 HalHwiCreate(HWI_HANDLE_T hwiNum,
+ HWI_PRIOR_T hwiPrio,
+ HWI_MODE_T mode,
+ HWI_PROC_FUNC handler,
+ HWI_ARG_T arg);
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#endif /* _LOS_INTERRUPT_H */
+
diff --git a/kernel/arch/include/los_timer.h b/kernel/arch/include/los_timer.h
new file mode 100644
index 00000000..9b6b6c3c
--- /dev/null
+++ b/kernel/arch/include/los_timer.h
@@ -0,0 +1,193 @@
+/*
+ * 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.
+ */
+#define TICK_CHECK 0x4000000
+#define CYCLE_CHECK 0xFFFFFFFFU
+#define SHIFT_32_BIT 32
+#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
+
+typedef enum {
+ OS_SYS_NORMAL_SLEEP = 0,
+ OS_SYS_DEEP_SLEEP,
+} LOS_SysSleepEnum;
+
+VOID HalTickLock(VOID);
+
+VOID HalTickUnlock(VOID);
+
+BOOL HalGetSysSleepFlag(VOID);
+
+VOID HalClearSysSleepFlag(VOID);
+
+
+VOID HalEnterSleep(LOS_SysSleepEnum sleep);
+
+
+ /**
+ * @ingroup los_timer
+ * @brief Configure Tick Interrupt Start.
+ *
+ * @par Description:
+ * This API is used to configure Tick Interrupt Start while macro LOSCFG_BASE_CORE_TICK_HW_TIME is No.
+ *
+ * @attention
+ *
+ *
+ * @param: None.
+ *
+ * @retval #LOS_OK 0:configure Tick Interrupt success.
+ * @retval #LOS_ERRNO_TICK_CFG_INVALID 0x02000400:configure Tick Interrupt failed.
+ *
+ * @par Dependency:
+ * los_config.h: the header file that contains the API declaration.
+ * @see
+ */
+
+#if (LOSCFG_KERNEL_TICKLESS == YES)
+/**
+ * @ingroup los_hwi
+ * @brief reconfig systick, and clear SysTick_IRQn.
+ *
+ * @par Description:
+ *
+ * This API is used to reconfig systick, and clear SysTick_IRQn.
+ *
+ * @attention
+ *
+ *
+ * @param cyclesPerTick [IN] Cycles Per Tick
+ *
+ * @retval None.
+ * @par Dependency:
+ * los_hwi.h: the header file that contains the API declaration.
+ * @see LOS_IntRestore
+ */
+extern VOID HalSysTickReload(UINT32 cyclesPerTick);
+#endif
+
+/**
+ * @ingroup los_hwi
+ * @brief Get System cycle count.
+ *
+ * @par Description:
+ *
+ * This API is used to Get System cycle count.
+ *
+ * @attention
+ *
+ *
+ * @param None.
+ *
+ * @retval: The value of the system cycle count.
+ * @par Dependency:
+ * los_hwi.h: the header file that contains the API declaration.
+ * @see LOS_IntRestore
+ */
+extern UINT32 HalSysTickCurrCycleGet(VOID);
+
+
+/* *
+ * @ingroup los_hwi
+ * @brief Get value from xPSR register.
+ *
+ * @par Description:
+ *
+ * This API is used to Get value from xPSR register.
+ *
+ * @attention
+ *
+ *
+ * @param cntHi [IN] CpuTick High 4 byte
+ * @param cntLo [IN] CpuTick Low 4 byte
+ *
+ * @retval None.
+ * @par Dependency:
+ * los_hwi.h: the header file that contains the API declaration.
+ * @see LOS_IntRestore
+ */
+extern VOID HalGetCpuCycle(UINT32 *cntHi, UINT32 *cntLo);
+
+
+
+extern VOID HalGetSystickCycle(UINT32 *puwCntHi, UINT32 *puwCntLo);
+
+/**
+ * @ingroup los_tickless
+ * @brief enable the tickless mode.
+ *
+ * @par Description:
+ * This API is used to enable the tickless mode. System can change from periodic clock mode to dynamic clock mode.
+ *
+ * @attention
+ *
+ *
+ * @param None.
+ *
+ * @retval None.
+ * @par Dependency:
+ * los_tickless.h: the header file that contains the API declaration.
+ * @see LOS_TicklessDisable
+ */
+extern VOID HalTicklessEnable(VOID);
+/**
+ * @ingroup los_tickless
+ * @brief disable the tickless mode.
+ *
+ * @par Description:
+ * This API is used to diable the tickless mode. System will not change from periodic clock mode to dynamic clock mode.
+ *
+ * @attention
+ *
+ *
+ * @param None.
+ *
+ * @retval None.
+ * @par Dependency:
+ * los_tickless.h: the header file that contains the API declaration.
+ * @see LOS_TicklessEnable
+ */
+extern VOID HalTicklessDisable(VOID);
diff --git a/kernel/arch/risc-v/asm/soc_common.h b/kernel/arch/risc-v/asm/soc_common.h
old mode 100755
new mode 100644
diff --git a/kernel/arch/risc-v/los_context.h b/kernel/arch/risc-v/los_arch_context.h
old mode 100755
new mode 100644
similarity index 94%
rename from kernel/arch/risc-v/los_context.h
rename to kernel/arch/risc-v/los_arch_context.h
index 7604a033..864d8a40
--- a/kernel/arch/risc-v/los_context.h
+++ b/kernel/arch/risc-v/los_arch_context.h
@@ -29,10 +29,11 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _LOS_HW_H
-#define _LOS_HW_H
+#ifndef _LOS_ARCH_CONTEXT_H
+#define _LOS_ARCH_CONTEXT_H
#include "los_compiler.h"
+#include "los_context.h"
#ifdef __cplusplus
#if __cplusplus
@@ -46,12 +47,6 @@ extern "C" {
*/
#define EMPTY_STACK 0xCACA
-/**
- * @ingroup los_hw
- * Check task schedule.
- */
-#define LOS_CHECK_SCHEDULE ((!g_losTaskLock) && (!OS_INT_ACTIVE))
-
#define TP_INIT_VALUE 0x02020202L
#define SP_INIT_VALUE 0x03030303L
#define S11_INIT_VALUE 0x04040404L
@@ -127,8 +122,14 @@ STATIC INLINE UINTPTR GetSP(VOID)
return spSave;
}
-extern VOID *OsTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack);
-extern VOID OsTaskScheduleCheck(VOID);
+STATIC INLINE UINTPTR GetFp(VOID)
+{
+ UINTPTR fpSave = 0;
+ __asm__ __volatile__("mv %0, s0" : "=r"(fpSave));
+ return fpSave;
+}
+
+extern VOID HalStartToRun(VOID);
/**
* @ingroup los_hw
diff --git a/kernel/arch/risc-v/los_arch_interrupt.h b/kernel/arch/risc-v/los_arch_interrupt.h
new file mode 100644
index 00000000..6ff6b3a9
--- /dev/null
+++ b/kernel/arch/risc-v/los_arch_interrupt.h
@@ -0,0 +1,288 @@
+/*
+ * Copyright (c) 2013-2020, 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_HWI_H
+#define _LOS_HWI_H
+
+#include "los_compiler.h"
+#include "los_config.h"
+#include "los_interrupt.h"
+#include "los_arch_context.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+/**
+ * @ingroup los_hwi
+ * Define the type of a hardware interrupt vector table function.
+ */
+typedef struct tagHwiHandleForm {
+ HWI_PROC_FUNC pfnHook;
+ VOID *uwParam;
+ UINTPTR uwreserved;
+} HWI_HANDLE_FORM_S;
+
+typedef struct {
+ UINT32 mcause;
+ UINT32 mtval;
+ UINT32 medeleg;
+ UINT32 gp;
+ TaskContext taskContext;
+} LosExcContext;
+
+typedef struct {
+ UINT16 nestCnt;
+ UINT16 type;
+ UINT32 thrID;
+ LosExcContext *context;
+} LosExcInfo;
+
+typedef UINT32 (*EXC_INFO_SAVE_CALLBACK)(UINT32, VOID*);
+
+typedef struct {
+ ExcInfoType uwType;
+ UINT32 uwValid;
+ EXC_INFO_SAVE_CALLBACK pFnExcInfoCb;
+ VOID* pArg;
+} ExcInfoArray;
+
+#define MAX_EXC_MEM_SIZE 0
+
+/**
+ * @ingroup los_hwi
+ * Highest priority of a hardware interrupt.
+ */
+#define OS_HWI_PRIO_HIGHEST 7
+
+/**
+ * @ingroup los_hwi
+ * Lowest priority of a hardware interrupt.
+ */
+#define OS_HWI_PRIO_LOWEST 1
+
+/**
+ * @ingroup los_hwi
+ * Count of HimiDeer system interrupt vector.
+ */
+#define OS_RISCV_SYS_VECTOR_CNT (RISCV_SYS_MAX_IRQ + 1)
+
+/**
+ * @ingroup los_hwi
+ * Count of HimiDeer local interrupt vector 0 - 5, enabled by CSR mie 26 -31 bit.
+ */
+#define OS_RISCV_MIE_IRQ_VECTOR_CNT 6
+
+/**
+ * @ingroup los_hwi
+ * Count of HimiDeer local interrupt vector 6 - 31, enabled by custom CSR locie0 0 - 25 bit.
+ */
+#define OS_RISCV_CUSTOM_IRQ_VECTOR_CNT RISCV_PLIC_VECTOR_CNT
+
+/**
+ * @ingroup los_hwi
+ * Count of HimiDeer local IRQ interrupt vector.
+ */
+#define OS_RISCV_LOCAL_IRQ_VECTOR_CNT (OS_RISCV_MIE_IRQ_VECTOR_CNT + OS_RISCV_SYS_VECTOR_CNT)
+
+/**
+ * @ingroup los_hwi
+ * Count of himideer interrupt vector.
+ */
+#define OS_RISCV_VECTOR_CNT (OS_RISCV_SYS_VECTOR_CNT + OS_RISCV_CUSTOM_IRQ_VECTOR_CNT)
+
+/**
+ * Maximum number of supported hardware devices that generate hardware interrupts.
+ * The maximum number of hardware devices that generate hardware interrupts supported by hi3518ev200 is 32.
+ */
+#define OS_HWI_MAX_NUM OS_RISCV_VECTOR_CNT
+
+/**
+ * Maximum interrupt number.
+ */
+#define OS_HWI_MAX ((OS_HWI_MAX_NUM) - 1)
+
+/**
+ * Minimum interrupt number.
+ */
+#define OS_HWI_MIN 0
+
+/**
+ * Maximum usable interrupt number.
+ */
+#define OS_USER_HWI_MAX OS_HWI_MAX
+
+/**
+ * Minimum usable interrupt number.
+ */
+#define OS_USER_HWI_MIN OS_HWI_MIN
+
+extern HWI_HANDLE_FORM_S g_hwiForm[OS_HWI_MAX_NUM];
+
+extern VOID HalHwiInit(VOID);
+extern UINT32 HalGetHwiFormCnt(HWI_HANDLE_T hwiNum);
+extern HWI_HANDLE_FORM_S *HalGetHwiForm(VOID);
+extern VOID HalHwiInterruptDone(HWI_HANDLE_T hwiNum);
+extern VOID HalHwiDefaultHandler(VOID *arg);
+
+extern UINT32 g_intCount;
+
+/**
+ * @ingroup los_hwi
+ * Hardware interrupt error code: Invalid interrupt number.
+ *
+ * Value: 0x02000900
+ *
+ * Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable
+ * for a risc-v platform is [0, OS_RISCV_VECTOR_CNT].
+ */
+#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
+
+/**
+ * @ingroup los_hwi
+ * Hardware interrupt error code: Null hardware interrupt handling function.
+ *
+ * Value: 0x02000901
+ *
+ * Solution: Pass in a valid non-null hardware interrupt handling function.
+ */
+#define OS_ERRNO_HWI_PROC_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01)
+
+/**
+ * @ingroup los_hwi
+ * Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation.
+ *
+ * Value: 0x02000902
+ *
+ * Solution: Increase the configured maximum number of supported hardware interrupts.
+ */
+#define OS_ERRNO_HWI_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02)
+
+/**
+ * @ingroup los_hwi
+ * Hardware interrupt error code: Insufficient memory for hardware interrupt initialization.
+ *
+ * Value: 0x02000903
+ *
+ * Solution: Expand the configured memory.
+ */
+#define OS_ERRNO_HWI_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03)
+
+/**
+ * @ingroup los_hwi
+ * Hardware interrupt error code: The interrupt has already been created.
+ *
+ * Value: 0x02000904
+ *
+ * Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created.
+ */
+#define OS_ERRNO_HWI_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04)
+
+/**
+ * @ingroup los_hwi
+ * Hardware interrupt error code: Invalid interrupt priority.
+ *
+ * Value: 0x02000905
+ *
+ * Solution: Ensure that the interrupt priority is valid.
+ */
+#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
+
+/**
+ * @ingroup los_hwi
+ * Hardware interrupt error code: Incorrect interrupt creation mode.
+ *
+ * Value: 0x02000906
+ *
+ * Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the
+ * value can be 0 or 1.
+ */
+#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
+
+/**
+ * @ingroup los_hwi
+ * Hardware interrupt error code: The interrupt has already been created as a fast interrupt.
+ *
+ * Value: 0x02000907
+ *
+ * Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created.
+ */
+#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
+
+/**
+ * @ingroup los_hwi
+ * Hardware interrupt error code: The API is called during an interrupt, which is forbidden.
+ *
+ * Value: 0x02000908
+ *
+ * * Solution: Do not call the API during an interrupt.
+ */
+#define OS_ERRNO_HWI_INTERR LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x08)
+
+/**
+ * @ingroup los_hwi
+ * Hardware interrupt error code:the hwi support SHARED error.
+ *
+ * Value: 0x02000909
+ *
+ * * Solution:check the input params hwiMode and irqParam of HalHwiCreate or HalHwiDelete whether adapt the current
+ * hwi.
+ */
+#define OS_ERRNO_HWI_SHARED_ERROR LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x09)
+
+/**
+ * @ingroup los_hwi
+ * Hardware interrupt error code:Invalid interrupt Arg when interrupt mode is IRQF_SHARED.
+ *
+ * Value: 0x0200090a
+ *
+ * * Solution:check the interrupt Arg, Arg should not be NULL and pDevId should not be NULL.
+ */
+#define OS_ERRNO_HWI_ARG_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0a)
+
+/**
+ * @ingroup los_hwi
+ * Hardware interrupt error code:The interrupt corresponded to the hwi number or devid has not been created.
+ *
+ * Value: 0x0200090b
+ *
+ * * Solution:check the hwi number or devid, make sure the hwi number or devid need to delete.
+ */
+#define OS_ERRNO_HWI_HWINUM_UNCREATE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0b)
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#endif /* _LOS_HWI_H */
diff --git a/kernel/arch/risc-v/los_arch_timer.h b/kernel/arch/risc-v/los_arch_timer.h
new file mode 100644
index 00000000..2f38c220
--- /dev/null
+++ b/kernel/arch/risc-v/los_arch_timer.h
@@ -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 */
+
diff --git a/kernel/arch/risc-v/los_hw.c b/kernel/arch/risc-v/los_context.c
old mode 100755
new mode 100644
similarity index 82%
rename from kernel/arch/risc-v/los_hw.c
rename to kernel/arch/risc-v/los_context.c
index cc574322..79e5f445
--- a/kernel/arch/risc-v/los_hw.c
+++ b/kernel/arch/risc-v/los_context.c
@@ -29,10 +29,12 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "los_context.h"
-#include "los_interrupt.h"
+#include "los_arch_context.h"
+#include "los_arch_interrupt.h"
+#include "los_arch_timer.h"
#include "los_task.h"
#include "los_memory.h"
+#include "los_timer.h"
#include "soc.h"
#ifdef __cplusplus
@@ -41,14 +43,19 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
-LITE_OS_SEC_TEXT_MINOR VOID OsTaskExit(VOID)
+LITE_OS_SEC_TEXT_INIT VOID HalArchInit(VOID)
{
- OsDisableIRQ();
+ HalHwiInit();
+}
+
+LITE_OS_SEC_TEXT_MINOR VOID HalSysExit(VOID)
+{
+ HalIntLock();
while (1) {
}
}
-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)
{
UINT32 index;
TaskContext *context = NULL;
@@ -92,13 +99,24 @@ LITE_OS_SEC_TEXT_INIT VOID *OsTskStackInit(UINT32 taskID, UINT32 stackSize, VOID
context->t2 = T2_INIT_VALUE;
context->t1 = T1_INIT_VALUE;
context->t0 = T0_INIT_VALUE;
- context->ra = (UINT32)(UINTPTR)OsTaskExit;
+ context->ra = (UINT32)(UINTPTR)HalSysExit;
return (VOID *)context;
}
-LITE_OS_SEC_TEXT VOID OsTaskScheduleCheck(VOID)
+LITE_OS_SEC_TEXT_INIT UINT32 HalStartSchedule(OS_TICK_HANDLER handler)
{
-#if (LOSCFG_BASE_CORE_TSK_MONITOR == YES)
+ UINT32 ret;
+ ret = HalTickStart(handler);
+ if (ret != LOS_OK) {
+ return ret;
+ }
+ HalStartToRun();
+ return LOS_OK; /* never return */
+}
+
+LITE_OS_SEC_TEXT VOID HalTaskScheduleCheck(VOID)
+{
+#if (LOSCFG_BASE_CORE_TSK_MONITOR == 1)
OsTaskSwitchCheck();
#endif
return;
@@ -119,6 +137,11 @@ LITE_OS_SEC_TEXT VOID dsb(VOID)
__asm__ __volatile__("fence":::"memory");
}
+VOID HalEnterSleep(LOS_SysSleepEnum sleep)
+{
+ wfi();
+}
+
#ifdef __cplusplus
#if __cplusplus
}
diff --git a/kernel/arch/risc-v/los_dispatch.S b/kernel/arch/risc-v/los_dispatch.S
old mode 100755
new mode 100644
index e7895738..b0edbadb
--- a/kernel/arch/risc-v/los_dispatch.S
+++ b/kernel/arch/risc-v/los_dispatch.S
@@ -31,15 +31,16 @@
#include "soc.h"
-.global LOS_IntLock
-.global LOS_IntUnLock
-.global LOS_IntRestore
-.global LOS_StartToRun
-.global osTaskSchedule
-.global OsDisableIRQ
-.global TaskSwitch
+.global HalEnableIRQ
+.global HalDisableIRQ
+.global HalIntLock
+.global HalIntUnLock
+.global HalIntRestore
+.global HalStartToRun
+.global HalTaskSchedule
+.global HalTaskSwitch
.extern __irq_stack_top
-.extern OsTaskScheduleCheck
+.extern HalTaskScheduleCheck
.extern printk
.equ OS_TASK_STATUS_RUNNING, 0x0010
.equ OS_TASK_STATUS_NOT_RUNNING, 0xFFEF
@@ -132,7 +133,7 @@
addi sp, sp, 32 * REGBYTES
.endm
-LOS_StartToRun:
+HalStartToRun:
// disable interrupts
csrci mstatus, RISCV_MSTATUS_MIE
@@ -143,18 +144,23 @@ LOS_StartToRun:
j SwitchNewTask
-osTaskSchedule:
+HalTaskSchedule:
+ la t0, g_intCount
+ lw t1, 0(t0)
+ bne t1, zero, 1f
+
li t0, RISCV_MSTATUS_MIE | RISCV_MSTATUS_MPIE
csrrc a1, mstatus, t0
la t0, g_losTask
lw t1, 0(t0)
lw t2, 4(t0)
- bne t1, t2, 1f
+ bne t1, t2, 2f
csrw mstatus, a1
- ret
1:
+ ret
+2:
addi sp, sp, -(32 * REGBYTES)
andi a1, a1, RISCV_MSTATUS_MIE
ori a1, a1, 0x180
@@ -164,7 +170,7 @@ osTaskSchedule:
j SaveContextAndSwitchTask
-TaskSwitch:
+HalTaskSwitch:
la t0, g_losTaskLock
lw t1, 0(t0)
bgtz t1, NotSwitch
@@ -191,7 +197,7 @@ SaveContextAndSwitchTask:
sh t2, TASK_CB_STATUS(t1)
sw sp, TASK_CB_KERNEL_SP(t1)
- call OsTaskScheduleCheck
+ call HalTaskScheduleCheck
SwitchNewTask:
// copy newTask into runTask
@@ -227,27 +233,27 @@ NotSwitch:
mret
.section .text
-OsDisableIRQ:
+HalDisableIRQ:
li t0, (RISCV_MSTATUS_MPIE | RISCV_MSTATUS_MIE) // mpie | mie
csrrc zero, mstatus, t0
ret
-OsEnableIRQ:
+HalEnableIRQ:
csrsi mstatus, RISCV_MSTATUS_MIE
ret
-LOS_IntLock:
+HalIntLock:
csrr a0, mstatus // return value
li t0, RISCV_MSTATUS_MIE // mie
csrrc zero, mstatus, t0
ret
-LOS_IntUnLock:
+HalIntUnLock:
csrr a0, mstatus // return value
li t0, RISCV_MSTATUS_MIE // mie
csrrs zero, mstatus, t0
ret
-LOS_IntRestore:
+HalIntRestore:
csrw mstatus, a0
ret
diff --git a/kernel/arch/risc-v/los_trap.S b/kernel/arch/risc-v/los_exc.S
old mode 100755
new mode 100644
similarity index 95%
rename from kernel/arch/risc-v/los_trap.S
rename to kernel/arch/risc-v/los_exc.S
index 94294b37..6f71074d
--- a/kernel/arch/risc-v/los_trap.S
+++ b/kernel/arch/risc-v/los_exc.S
@@ -29,8 +29,8 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _LOS_TRAP_S
-#define _LOS_TRAP_S
+#ifndef _LOS_EXC_S
+#define _LOS_EXC_S
#include "soc.h"
.macro PUSH_ECALL_CALLER_REG
@@ -114,11 +114,11 @@
.endm
.section .interrupt.text
-.extern OsExcEntry
+.extern HalExcEntry
.extern g_excInfo
-.global TrapEntry
+.global HalTrapEntry
.align 4
-TrapEntry:
+HalTrapEntry:
PUSH_OTHER_REG
addi sp, sp, -4 * REGBYTES
sw a0, 0 * REGBYTES(sp)
@@ -142,7 +142,7 @@ TrapEntry:
1:
addi t1, t1, 0x1
sh t1, 0(t0)
- call OsExcEntry
+ call HalExcEntry
la t0, g_excInfo
sh zero, 0(t0)
csrr sp, mscratch
@@ -156,23 +156,23 @@ TrapEntry:
.section .interrupt.text
-.extern TrapEntry
-.global TrapVector
+.extern HalTrapEntry
+.global HalTrapVector
.equ TRAP_INTERRUPT_MODE_MASK, 0x80000000
.equ TRAP_INTERRUPT_NUM_MASK, 0x7FFFFFFF
.align 4
-TrapVector:
+HalTrapVector:
PUSH_ECALL_CALLER_REG
csrr a0, mcause
li a1, TRAP_INTERRUPT_MODE_MASK
li a2, TRAP_INTERRUPT_NUM_MASK
and a1, a0, a1
and a0, a2, a0
- beqz a1, TrapEntry
+ beqz a1, HalTrapEntry
PUSH_OTHER_CALLER_REG
csrw mscratch, sp
la sp, __start_and_irq_stack_top
- jal OsHwiInterruptDone
- j TaskSwitch
+ jal HalHwiInterruptDone
+ j HalTaskSwitch
#endif /* _LOS_TRAP_S */
diff --git a/kernel/arch/risc-v/los_exc.c b/kernel/arch/risc-v/los_interrupt.c
old mode 100755
new mode 100644
similarity index 83%
rename from kernel/arch/risc-v/los_exc.c
rename to kernel/arch/risc-v/los_interrupt.c
index e0749c43..cf8f53f2
--- a/kernel/arch/risc-v/los_exc.c
+++ b/kernel/arch/risc-v/los_interrupt.c
@@ -31,7 +31,9 @@
#include
#include
-#include "los_interrupt.h"
+#include "los_arch.h"
+#include "los_arch_interrupt.h"
+#include "los_arch_context.h"
#include "los_task.h"
#include "los_debug.h"
#include "riscv_hal.h"
@@ -69,7 +71,7 @@ const CHAR g_excInformation[RISCV_EXC_TYPE_NUM][50] = {
#define FP_OFFSET 8
#define OS_MAX_BACKTRACE 15
#define FP_ALIGN(value) (((UINT32)(value) & (UINT32)(LOSCFG_STACK_POINT_ALIGN_SIZE - 1)) == 0)
-#define FP_CHECK(value) (OsBackTraceFpCheck(value) && ((UINT32)(value) != FP_INIT_VALUE) && FP_ALIGN(value))
+#define FP_CHECK(value) (HalBackTraceFpCheck(value) && ((UINT32)(value) != FP_INIT_VALUE) && FP_ALIGN(value))
LITE_OS_SEC_BSS UINT32 g_intCount = 0;
LITE_OS_SEC_BSS UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM];
@@ -77,16 +79,16 @@ LITE_OS_SEC_DATA_INIT HWI_HANDLE_FORM_S g_hwiForm[OS_HWI_MAX_NUM] = {
{ .pfnHook = NULL, .uwParam = 0 }, // 0 User software interrupt handler
{ .pfnHook = NULL, .uwParam = 0 }, // 1 Supervisor software interrupt handler
{ .pfnHook = NULL, .uwParam = 0 }, // 2 Reserved
- { .pfnHook = OsHwiDefaultHandler, .uwParam = 0 }, // 3 Machine software interrupt handler
+ { .pfnHook = HalHwiDefaultHandler, .uwParam = 0 }, // 3 Machine software interrupt handler
{ .pfnHook = NULL, .uwParam = 0 }, // 4 User timer interrupt handler
{ .pfnHook = NULL, .uwParam = 0 }, // 5 Supervisor timer interrupt handler
{ .pfnHook = NULL, .uwParam = 0 }, // 6 Reserved
- { .pfnHook = OsHwiDefaultHandler, .uwParam = 0 }, // 7 Machine timer interrupt handler
+ { .pfnHook = HalHwiDefaultHandler, .uwParam = 0 }, // 7 Machine timer interrupt handler
{ .pfnHook = NULL, .uwParam = 0 }, // 8 User external interrupt handler
{ .pfnHook = NULL, .uwParam = 0 }, // 9 Supervisor external interrupt handler
{ .pfnHook = NULL, .uwParam = 0 }, // 10 Reserved
- { .pfnHook = OsHwiDefaultHandler, .uwParam = 0 }, // 11 Machine external interrupt handler
- { .pfnHook = OsHwiDefaultHandler, .uwParam = 0 }, // 12 NMI handler
+ { .pfnHook = HalHwiDefaultHandler, .uwParam = 0 }, // 11 Machine external interrupt handler
+ { .pfnHook = HalHwiDefaultHandler, .uwParam = 0 }, // 12 NMI handler
{ .pfnHook = NULL, .uwParam = 0 }, // 13 Reserved
{ .pfnHook = NULL, .uwParam = 0 }, // 14 Reserved
{ .pfnHook = NULL, .uwParam = 0 }, // 15 Reserved
@@ -102,7 +104,7 @@ LITE_OS_SEC_DATA_INIT HWI_HANDLE_FORM_S g_hwiForm[OS_HWI_MAX_NUM] = {
{ .pfnHook = NULL, .uwParam = 0 }, // 25 Reserved
};
-LITE_OS_SEC_TEXT_INIT VOID OsHwiDefaultHandler(UINTPTR arg)
+LITE_OS_SEC_TEXT_INIT VOID HalHwiDefaultHandler(VOID *arg)
{
(VOID)arg;
PRINT_ERR("default handler\n");
@@ -110,17 +112,17 @@ LITE_OS_SEC_TEXT_INIT VOID OsHwiDefaultHandler(UINTPTR arg)
}
}
-LITE_OS_SEC_TEXT_INIT VOID OsHwiInit(VOID)
+LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
UINT32 index;
for (index = OS_RISCV_SYS_VECTOR_CNT; index < OS_HWI_MAX_NUM; index++) {
- g_hwiForm[index].pfnHook = OsHwiDefaultHandler;
+ g_hwiForm[index].pfnHook = HalHwiDefaultHandler;
g_hwiForm[index].uwParam = 0;
}
}
-typedef VOID (*HwiProcFunc)(UINTPTR);
-__attribute__((section(".interrupt.text"))) VOID OsHwiInterruptDone(HWI_HANDLE_T hwiNum)
+typedef VOID (*HwiProcFunc)(VOID *arg);
+__attribute__((section(".interrupt.text"))) VOID HalHwiInterruptDone(HWI_HANDLE_T hwiNum)
{
g_intCount++;
@@ -133,7 +135,7 @@ __attribute__((section(".interrupt.text"))) VOID OsHwiInterruptDone(HWI_HANDLE_T
g_intCount--;
}
-LITE_OS_SEC_TEXT UINT32 OsGetHwiFormCnt(HWI_HANDLE_T hwiNum)
+LITE_OS_SEC_TEXT UINT32 HalGetHwiFormCnt(HWI_HANDLE_T hwiNum)
{
if (hwiNum < OS_HWI_MAX_NUM) {
return g_hwiFormCnt[hwiNum];
@@ -142,13 +144,19 @@ LITE_OS_SEC_TEXT UINT32 OsGetHwiFormCnt(HWI_HANDLE_T hwiNum)
return LOS_NOK;
}
-LITE_OS_SEC_TEXT HWI_HANDLE_FORM_S *OsGetHwiForm(VOID)
+LITE_OS_SEC_TEXT HWI_HANDLE_FORM_S *HalGetHwiForm(VOID)
{
return g_hwiForm;
}
+
+inline UINT32 HalIsIntAcvive(VOID)
+{
+ return (g_intCount > 0);
+}
+
/*****************************************************************************
- Function : LOS_HwiCreate
+ Function : HalHwiCreate
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
@@ -158,11 +166,11 @@ LITE_OS_SEC_TEXT HWI_HANDLE_FORM_S *OsGetHwiForm(VOID)
Output : None
Return : LOS_OK on success or error code on failure
*****************************************************************************/
-LITE_OS_SEC_TEXT UINT32 LOS_HwiCreate(HWI_HANDLE_T hwiNum,
+LITE_OS_SEC_TEXT UINT32 HalHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
- HWI_IRQ_PARAM_S irqParam)
+ HWI_ARG_T irqParam)
{
UINT32 intSave;
@@ -174,7 +182,7 @@ LITE_OS_SEC_TEXT UINT32 LOS_HwiCreate(HWI_HANDLE_T hwiNum,
}
if (g_hwiForm[hwiNum].pfnHook == NULL) {
return OS_ERRNO_HWI_NUM_INVALID;
- } else if (g_hwiForm[hwiNum].pfnHook != OsHwiDefaultHandler) {
+ } else if (g_hwiForm[hwiNum].pfnHook != HalHwiDefaultHandler) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if ((hwiPrio < OS_HWI_PRIO_LOWEST) || (hwiPrio > OS_HWI_PRIO_HIGHEST)) {
@@ -183,10 +191,10 @@ LITE_OS_SEC_TEXT UINT32 LOS_HwiCreate(HWI_HANDLE_T hwiNum,
intSave = LOS_IntLock();
g_hwiForm[hwiNum].pfnHook = hwiHandler;
- g_hwiForm[hwiNum].uwParam = irqParam;
+ g_hwiForm[hwiNum].uwParam = (VOID *)irqParam;
if (hwiNum >= OS_RISCV_SYS_VECTOR_CNT) {
- OsSetLocalInterPri(hwiNum, hwiPrio);
+ HalSetLocalInterPri(hwiNum, hwiPrio);
}
LOS_IntRestore(intSave);
@@ -195,12 +203,12 @@ LITE_OS_SEC_TEXT UINT32 LOS_HwiCreate(HWI_HANDLE_T hwiNum,
}
/*****************************************************************************
- Function : LOS_HwiDelete
+ Function : HalHwiDelete
Description : Delete hardware interrupt
Input : hwiNum --- hwi num to delete
Return : LOS_OK on success or error code on failure
*****************************************************************************/
-LITE_OS_SEC_TEXT UINT32 LOS_HwiDelete(HWI_HANDLE_T hwiNum, HWI_IRQ_PARAM_S irqParam)
+LITE_OS_SEC_TEXT UINT32 HalHwiDelete(HWI_HANDLE_T hwiNum)
{
UINT32 intSave;
@@ -209,13 +217,13 @@ LITE_OS_SEC_TEXT UINT32 LOS_HwiDelete(HWI_HANDLE_T hwiNum, HWI_IRQ_PARAM_S irqPa
}
intSave = LOS_IntLock();
- g_hwiForm[hwiNum].pfnHook = OsHwiDefaultHandler;
+ g_hwiForm[hwiNum].pfnHook = HalHwiDefaultHandler;
g_hwiForm[hwiNum].uwParam = 0;
LOS_IntRestore(intSave);
return LOS_OK;
}
-LITE_OS_SEC_TEXT VOID BackTraceSub(UINT32 fp)
+STATIC VOID BackTraceSub(UINT32 fp)
{
UINT32 backFp = fp;
UINT32 tmpFp;
@@ -231,21 +239,21 @@ LITE_OS_SEC_TEXT VOID BackTraceSub(UINT32 fp)
count++;
if ((count == OS_MAX_BACKTRACE) || (backFp == tmpFp) || \
- (!OsBackTraceRaCheck(backRa))) {
+ (!HalBackTraceRaCheck(backRa))) {
break;
}
}
PRINTK("*******backtrace end*******\n");
}
-LITE_OS_SEC_TEXT VOID BackTrace(UINT32 fp)
+STATIC VOID BackTrace(UINT32 fp)
{
PRINTK("*******backtrace begin*******\n");
BackTraceSub(fp);
}
-LITE_OS_SEC_TEXT static VOID OsExcBackTrace(UINT32 fp, UINT32 ra)
+STATIC VOID ExcBackTrace(UINT32 fp, UINT32 ra)
{
UINT32 backFp;
if (FP_CHECK(fp)) {
@@ -259,54 +267,7 @@ LITE_OS_SEC_TEXT static VOID OsExcBackTrace(UINT32 fp, UINT32 ra)
}
}
-LITE_OS_SEC_TEXT VOID OsTaskBackTrace(UINT32 taskID)
-{
- LosTaskCB *taskCB = NULL;
-
- if (taskID >= g_taskMaxNum) {
- PRINT_ERR("\r\nTask PID is invalid!\n");
- return;
- }
-
- taskCB = OS_TCB_FROM_TID(taskID);
- if ((taskCB->taskStatus & OS_TASK_STATUS_UNUSED) || (taskCB->taskEntry == NULL) ||
- (taskCB->taskName == NULL)) {
- PRINT_ERR("\r\nThe task is not created!\n");
- return;
- }
-
- if (taskCB->taskStatus & OS_TASK_STATUS_RUNNING) {
- OsBackTrace();
- return;
- }
-
- PRINTK("taskName = %s\n", taskCB->taskName);
- PRINTK("taskID = 0x%x\n", taskCB->taskID);
- PRINTK("curr ra = 0x%08x\n", ((TaskContext *)(taskCB->stackPointer))->ra);
- OsExcBackTrace(((TaskContext *)(taskCB->stackPointer))->s0, ((TaskContext *)(taskCB->stackPointer))->ra);
-}
-
-LITE_OS_SEC_TEXT VOID OsBackTrace(VOID)
-{
- UINT32 fp = GetFp();
- PRINTK("taskName = %s\n", g_losTask.runTask->taskName);
- PRINTK("taskID = %u\n", g_losTask.runTask->taskID);
- PRINTK("curr fp = 0x%08x \n", fp);
- BackTrace(fp);
-}
-
-LITE_OS_SEC_TEXT VOID LOS_Panic(const CHAR *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- PRINTK(fmt, ap);
- va_end(ap);
- OsDisableIRQ();
- while (1) {
- }
-}
-
-STATIC VOID OsDisplayTaskInfo(VOID)
+STATIC VOID DisplayTaskInfo(VOID)
{
TSK_INFO_S taskInfo;
UINT32 index;
@@ -326,7 +287,7 @@ STATIC VOID OsDisplayTaskInfo(VOID)
return;
}
-LITE_OS_SEC_TEXT STATIC VOID OsExcInfoDisplayContext(const LosExcInfo *exc)
+STATIC VOID ExcInfoDisplayContext(const LosExcInfo *exc)
{
const TaskContext *taskContext = &(exc->context->taskContext);
@@ -366,10 +327,10 @@ LITE_OS_SEC_TEXT STATIC VOID OsExcInfoDisplayContext(const LosExcInfo *exc)
PRINTK("t5 = 0x%x\n", taskContext->t5);
PRINTK("t6 = 0x%x\n", taskContext->t6);
- OsExcBackTrace(taskContext->s0, taskContext->ra);
+ ExcBackTrace(taskContext->s0, taskContext->ra);
}
-LITE_OS_SEC_TEXT VOID OsExcInfoDisplay(const LosExcContext *excBufAddr)
+STATIC VOID ExcInfoDisplay(const LosExcContext *excBufAddr)
{
g_excInfo.type = excBufAddr->mcause;
g_excInfo.context = (LosExcContext *)excBufAddr;
@@ -385,31 +346,31 @@ LITE_OS_SEC_TEXT VOID OsExcInfoDisplay(const LosExcContext *excBufAddr)
PRINTK("taskName = %s\n\r", g_losTask.runTask->taskName);
PRINTK("taskID = %u\n\r", g_losTask.runTask->taskID);
PRINTK("system mem addr:0x%x\n\r", (UINTPTR)OS_SYS_MEM_ADDR);
- OsExcInfoDisplayContext(&g_excInfo);
+ ExcInfoDisplayContext(&g_excInfo);
}
-VOID OsExcEntry(const LosExcContext *excBufAddr)
+VOID HalExcEntry(const LosExcContext *excBufAddr)
{
if (g_excInfo.nestCnt > 2) {
PRINTK("hard faule!\n\r");
goto SYSTEM_DEATH;
}
- OsExcInfoDisplay(excBufAddr);
+ ExcInfoDisplay(excBufAddr);
PRINTK("----------------All Task infomation ------------\n\r");
- OsDisplayTaskInfo();
+ DisplayTaskInfo();
SYSTEM_DEATH:
while (1) {
}
}
-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]);
@@ -419,6 +380,42 @@ VOID OsExcRegister(ExcInfoType type, EXC_INFO_SAVE_CALLBACK func, VOID *arg)
excInfo->uwValid = TRUE;
}
+LITE_OS_SEC_TEXT VOID HalTaskBackTrace(UINT32 taskID)
+{
+ LosTaskCB *taskCB = NULL;
+
+ if (taskID >= g_taskMaxNum) {
+ PRINT_ERR("\r\nTask PID is invalid!\n");
+ return;
+ }
+
+ taskCB = OS_TCB_FROM_TID(taskID);
+ if ((taskCB->taskStatus & OS_TASK_STATUS_UNUSED) || (taskCB->taskEntry == NULL) ||
+ (taskCB->taskName == NULL)) {
+ PRINT_ERR("\r\nThe task is not created!\n");
+ return;
+ }
+
+ if (taskCB->taskStatus & OS_TASK_STATUS_RUNNING) {
+ HalBackTrace();
+ return;
+ }
+
+ PRINTK("taskName = %s\n", taskCB->taskName);
+ PRINTK("taskID = 0x%x\n", taskCB->taskID);
+ PRINTK("curr ra = 0x%08x\n", ((TaskContext *)(taskCB->stackPointer))->ra);
+ ExcBackTrace(((TaskContext *)(taskCB->stackPointer))->s0, ((TaskContext *)(taskCB->stackPointer))->ra);
+}
+
+LITE_OS_SEC_TEXT VOID HalBackTrace(VOID)
+{
+ UINT32 fp = GetFp();
+ PRINTK("taskName = %s\n", g_losTask.runTask->taskName);
+ PRINTK("taskID = %u\n", g_losTask.runTask->taskID);
+ PRINTK("curr fp = 0x%08x \n", fp);
+ BackTrace(fp);
+}
+
/* stack protector */
UINT32 __stack_chk_guard = 0xd00a0dff;
diff --git a/kernel/arch/risc-v/los_interrupt.h b/kernel/arch/risc-v/los_interrupt.h
deleted file mode 100755
index f572cc15..00000000
--- a/kernel/arch/risc-v/los_interrupt.h
+++ /dev/null
@@ -1,539 +0,0 @@
-/*
- * Copyright (c) 2013-2020, 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_HWI_H
-#define _LOS_HWI_H
-
-#include "los_compiler.h"
-#include "los_config.h"
-#include "los_context.h"
-
-#ifdef __cplusplus
-#if __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-#endif /* __cplusplus */
-
-/**
- * @ingroup los_hwi
- * Define the type of a hardware interrupt number.
- */
-typedef UINT32 HWI_HANDLE_T;
-
-/**
- * @ingroup los_hwi
- * Define the type of a hardware interrupt priority.
- */
-typedef UINT16 HWI_PRIOR_T;
-
-/**
- * @ingroup los_hwi
- * Define the type of hardware interrupt mode configurations.
- */
-typedef UINT16 HWI_MODE_T;
-
-/**
- * @ingroup los_hwi
- * Define the type of the parameter used for the hardware interrupt creation function.
- * The function of this parameter varies among platforms.
- */
-typedef UINT32 HWI_ARG_T;
-
-/**
- * @ingroup los_hwi
- * Define the type of a hardware interrupt handling function.
- */
-typedef VOID (*HWI_PROC_FUNC)(UINTPTR);
-
-/**
- * @ingroup los_hwi
- * Define the type of a hardware interrupt vector table function.
- */
-typedef VOID (**HWI_VECTOR_FUNC)(VOID);
-
-/*
- * These flags used only by the kernel as part of the
- * irq handling routines.
- *
- * IRQF_SHARED - allow sharing the irq among several devices
- */
-#define IRQF_SHARED 0x8000
-
-/**
- * @ingroup los_hwi
- * Define the type of a hardware interrupt vector table function.
- */
-typedef struct tagHwiHandleForm {
- HWI_PROC_FUNC pfnHook;
- HWI_ARG_T uwParam;
- UINTPTR uwreserved;
-} HWI_HANDLE_FORM_S;
-
-typedef UINTPTR HWI_IRQ_PARAM_S;
-
-typedef struct {
- UINT32 mcause;
- UINT32 mtval;
- UINT32 medeleg;
- UINT32 gp;
- TaskContext taskContext;
-} LosExcContext;
-
-typedef struct {
- UINT16 nestCnt;
- UINT16 type;
- UINT32 thrID;
- LosExcContext *context;
-} LosExcInfo;
-
-typedef enum {
- OS_EXC_TYPE_CONTEXT = 0,
- OS_EXC_TYPE_TSK = 1,
- OS_EXC_TYPE_QUE = 2,
- OS_EXC_TYPE_NVIC = 3,
- OS_EXC_TYPE_TSK_SWITCH = 4,
- OS_EXC_TYPE_MEM = 5,
- OS_EXC_TYPE_MAX = 6
-} ExcInfoType;
-
-typedef UINT32 (*EXC_INFO_SAVE_CALLBACK)(UINT32, VOID*);
-
-typedef struct {
- ExcInfoType uwType;
- UINT32 uwValid;
- EXC_INFO_SAVE_CALLBACK pFnExcInfoCb;
- VOID* pArg;
-} ExcInfoArray;
-
-#define MAX_EXC_MEM_SIZE 0
-
-/**
- * @ingroup los_hwi
- * Highest priority of a hardware interrupt.
- */
-#define OS_HWI_PRIO_HIGHEST 7
-
-/**
- * @ingroup los_hwi
- * Lowest priority of a hardware interrupt.
- */
-#define OS_HWI_PRIO_LOWEST 1
-
-/**
- * @ingroup los_hwi
- * Count of HimiDeer system interrupt vector.
- */
-#define OS_RISCV_SYS_VECTOR_CNT (RISCV_SYS_MAX_IRQ + 1)
-
-/**
- * @ingroup los_hwi
- * Count of HimiDeer local interrupt vector 0 - 5, enabled by CSR mie 26 -31 bit.
- */
-#define OS_RISCV_MIE_IRQ_VECTOR_CNT 6
-
-/**
- * @ingroup los_hwi
- * Count of HimiDeer local interrupt vector 6 - 31, enabled by custom CSR locie0 0 - 25 bit.
- */
-#define OS_RISCV_CUSTOM_IRQ_VECTOR_CNT RISCV_PLIC_VECTOR_CNT
-
-/**
- * @ingroup los_hwi
- * Count of HimiDeer local IRQ interrupt vector.
- */
-#define OS_RISCV_LOCAL_IRQ_VECTOR_CNT (OS_RISCV_MIE_IRQ_VECTOR_CNT + OS_RISCV_SYS_VECTOR_CNT)
-
-/**
- * @ingroup los_hwi
- * Count of himideer interrupt vector.
- */
-#define OS_RISCV_VECTOR_CNT (OS_RISCV_SYS_VECTOR_CNT + OS_RISCV_CUSTOM_IRQ_VECTOR_CNT)
-
-/**
- * Maximum number of supported hardware devices that generate hardware interrupts.
- * The maximum number of hardware devices that generate hardware interrupts supported by hi3518ev200 is 32.
- */
-#define OS_HWI_MAX_NUM OS_RISCV_VECTOR_CNT
-
-/**
- * Maximum interrupt number.
- */
-#define OS_HWI_MAX ((OS_HWI_MAX_NUM) - 1)
-
-/**
- * Minimum interrupt number.
- */
-#define OS_HWI_MIN 0
-
-/**
- * Maximum usable interrupt number.
- */
-#define OS_USER_HWI_MAX OS_HWI_MAX
-
-/**
- * Minimum usable interrupt number.
- */
-#define OS_USER_HWI_MIN OS_HWI_MIN
-
-extern HWI_HANDLE_FORM_S g_hwiForm[OS_HWI_MAX_NUM];
-
-extern VOID OsHwiInit(VOID);
-extern UINT32 OsGetHwiFormCnt(HWI_HANDLE_T hwiNum);
-extern HWI_HANDLE_FORM_S *OsGetHwiForm(VOID);
-extern VOID OsHwiInterruptDone(HWI_HANDLE_T hwiNum);
-extern VOID OsHwiDefaultHandler(UINTPTR arg);
-
-extern VOID BackTraceSub(UINT32 fp);
-extern VOID OsDisableIRQ(VOID);
-extern VOID OsEnableIRQ(VOID);
-
-extern VOID LOS_Panic(const CHAR *fmt, ...);
-extern VOID OsBackTrace(VOID);
-extern VOID OsTaskBackTrace(UINT32 taskID);
-extern VOID OsExcInit(VOID);
-extern VOID OsExcRegister(ExcInfoType type, EXC_INFO_SAVE_CALLBACK func, VOID *arg);
-
-STATIC INLINE UINTPTR GetFp(VOID)
-{
- UINTPTR fpSave = 0;
- __asm__ __volatile__("mv %0, s0" : "=r"(fpSave));
- return fpSave;
-}
-
-extern UINT32 g_intCount;
-
-/**
- * @ingroup los_hwi
- * An interrupt is active.
- */
-#define OS_INT_ACTIVE (g_intCount > 0)
-
-/**
- * @ingroup los_hwi
- * An interrupt is inactive.
- */
-#define OS_INT_INACTIVE (!(OS_INT_ACTIVE))
-
-/**
- * @ingroup los_hwi
- * Hardware interrupt error code: Invalid interrupt number.
- *
- * Value: 0x02000900
- *
- * Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable
- * for a risc-v platform is [0, OS_RISCV_VECTOR_CNT].
- */
-#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
-
-/**
- * @ingroup los_hwi
- * Hardware interrupt error code: Null hardware interrupt handling function.
- *
- * Value: 0x02000901
- *
- * Solution: Pass in a valid non-null hardware interrupt handling function.
- */
-#define OS_ERRNO_HWI_PROC_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01)
-
-/**
- * @ingroup los_hwi
- * Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation.
- *
- * Value: 0x02000902
- *
- * Solution: Increase the configured maximum number of supported hardware interrupts.
- */
-#define OS_ERRNO_HWI_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02)
-
-/**
- * @ingroup los_hwi
- * Hardware interrupt error code: Insufficient memory for hardware interrupt initialization.
- *
- * Value: 0x02000903
- *
- * Solution: Expand the configured memory.
- */
-#define OS_ERRNO_HWI_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03)
-
-/**
- * @ingroup los_hwi
- * Hardware interrupt error code: The interrupt has already been created.
- *
- * Value: 0x02000904
- *
- * Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created.
- */
-#define OS_ERRNO_HWI_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04)
-
-/**
- * @ingroup los_hwi
- * Hardware interrupt error code: Invalid interrupt priority.
- *
- * Value: 0x02000905
- *
- * Solution: Ensure that the interrupt priority is valid.
- */
-#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
-
-/**
- * @ingroup los_hwi
- * Hardware interrupt error code: Incorrect interrupt creation mode.
- *
- * Value: 0x02000906
- *
- * Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the
- * value can be 0 or 1.
- */
-#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
-
-/**
- * @ingroup los_hwi
- * Hardware interrupt error code: The interrupt has already been created as a fast interrupt.
- *
- * Value: 0x02000907
- *
- * Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created.
- */
-#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
-
-/**
- * @ingroup los_hwi
- * Hardware interrupt error code: The API is called during an interrupt, which is forbidden.
- *
- * Value: 0x02000908
- *
- * * Solution: Do not call the API during an interrupt.
- */
-#define OS_ERRNO_HWI_INTERR LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x08)
-
-/**
- * @ingroup los_hwi
- * Hardware interrupt error code:the hwi support SHARED error.
- *
- * Value: 0x02000909
- *
- * * Solution:check the input params hwiMode and irqParam of LOS_HwiCreate or LOS_HwiDelete whether adapt the current
- * hwi.
- */
-#define OS_ERRNO_HWI_SHARED_ERROR LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x09)
-
-/**
- * @ingroup los_hwi
- * Hardware interrupt error code:Invalid interrupt Arg when interrupt mode is IRQF_SHARED.
- *
- * Value: 0x0200090a
- *
- * * Solution:check the interrupt Arg, Arg should not be NULL and pDevId should not be NULL.
- */
-#define OS_ERRNO_HWI_ARG_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0a)
-
-/**
- * @ingroup los_hwi
- * Hardware interrupt error code:The interrupt corresponded to the hwi number or devid has not been created.
- *
- * Value: 0x0200090b
- *
- * * Solution:check the hwi number or devid, make sure the hwi number or devid need to delete.
- */
-#define OS_ERRNO_HWI_HWINUM_UNCREATE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0b)
-
-/**
- * @ingroup los_hwi
- * @brief Create a hardware interrupt.
- *
- * @par Description:
- * This API is used to configure a hardware interrupt and register a hardware interrupt handling function.
- *
- * @attention
- *
- * The hardware interrupt module is usable only when the configuration item for hardware interrupt tailoring
- * is enabled.
- * Hardware interrupt number value range: [OS_HWI_MIN,OS_HWI_MAX]. The value range applicable for a riscv
- * platform is [0, OS_HWI_MAX_NUM].
- * OS_HWI_MAX_NUM specifies the maximum number of interrupts that can be created.
- * Before executing an interrupt on a platform, refer to the chip manual of the platform.
- *
- *
- * @param hwiNum [IN] Type#HWI_HANDLE_T: hardware interrupt number. The value range applicable for a riscv
- * platform is [0, OS_HWI_MAX_NUM].
- * @param hwiPrio [IN] Type#HWI_PRIOR_T: hardware interrupt priority. Ignore this parameter temporarily.
- * @param hwiMode [IN] Type#HWI_MODE_T: hardware interrupt mode. Ignore this parameter temporarily.
- * @param hwiHandler [IN] Type#HWI_PROC_FUNC: interrupt handler used when a hardware interrupt is triggered.
- * @param irqParam [IN] Type#HWI_IRQ_PARAM_S: input parameter of the interrupt handler used when a hardware
- * interrupt is triggered.
- *
- * @retval #OS_ERRNO_HWI_PROC_FUNC_NULL 0x02000901: Null hardware interrupt handling function.
- * @retval #OS_ERRNO_HWI_NUM_INVALID 0x02000900: Invalid interrupt number.
- * @retval #OS_ERRNO_HWI_NO_MEMORY 0x02000903: Insufficient memory for hardware interrupt creation.
- * @retval #OS_ERRNO_HWI_ALREADY_CREATED 0x02000904: The interrupt handler being created has already been
- * created.
- * @retval #LOS_OK 0 : The interrupt is successfully created.
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see None.
- * @since Huawei LiteOS V200R003C00
- */
-extern UINT32 LOS_HwiCreate(HWI_HANDLE_T hwiNum,
- HWI_PRIOR_T hwiPrio,
- HWI_MODE_T hwiMode,
- HWI_PROC_FUNC hwiHandler,
- HWI_IRQ_PARAM_S irqParam);
-
-/**
- * @ingroup los_hwi
- * @brief Enable all interrupts.
- *
- * @par Description:
- *
- * This API is used to enable all IRQ and FIQ interrupts in the CPSR.
- *
- * @attention
- *
- *
- * @param None.
- *
- * @retval CPSR value obtained after all interrupts are enabled.
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see LOS_IntRestore
- * @since Huawei LiteOS V200R003C00
- */
-extern UINT32 LOS_IntUnLock(VOID);
-
-/**
- * @ingroup los_hwi
- * @brief Disable all interrupts.
- *
- * @par Description:
- *
- * This API is used to disable all IRQ and FIQ interrupts in the CPSR.
- *
- * @attention
- *
- *
- * @param None.
- *
- * @retval CPSR value obtained before all interrupts are disabled.
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see LOS_IntRestore
- * @since Huawei LiteOS V200R003C00
- */
-extern UINT32 LOS_IntLock(VOID);
-
-/**
- * @ingroup los_hwi
- * @brief Restore interrupts.
- *
- * @par Description:
- *
- * This API is used to restore the CPSR value obtained before all interrupts are disabled.
- *
- * @attention
- *
- * This API can be called only after all interrupts are disabled, and the input parameter value should be the
- * value returned by calling the all interrupt disabling API.
- *
- *
- * @param intSave [IN] CPSR value obtained before all interrupts are disabled.
- *
- * @retval None.
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see LOS_IntLock
- * @since Huawei LiteOS V200R003C00
- */
-extern VOID LOS_IntRestore(UINT32 intSave);
-
-/* *
- * @ingroup los_hwi
- * @brief Get value from xPSR register.
- *
- * @par Description:
- *
- * This API is used to Get value from xPSR register.
- *
- * @attention
- *
- *
- * @param cntHi [IN] CpuTick High 4 byte
- * @param cntLo [IN] CpuTick Low 4 byte
- *
- * @retval None.
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see LOS_IntRestore
- */
-extern VOID LOS_GetCpuCycle(UINT32 *cntHi, UINT32 *cntLo);
-
-/**
- * @ingroup los_hwi
- * @brief Delete hardware interrupt.
- *
- * @par Description:
- * This API is used to delete hardware interrupt.
- *
- * @attention
- *
- * The hardware interrupt module is usable only when the configuration item for hardware interrupt tailoring
- * is enabled.
- * Hardware interrupt number value range: [OS_HWI_MIN, OS_HWI_MAX]. The value range applicable for a riscv
- * platform is [0, OS_HWI_MAX_NUM].
- * OS_HWI_MAX_NUM specifies the maximum number of interrupts that can be created.
- * Before executing an interrupt on a platform, refer to the chip manual of the platform.
- *
- *
- * @param hwiNum [IN] Type#HWI_HANDLE_T: hardware interrupt number. The value range applicable for a riscv
- * platform is [0, OS_HWI_MAX_NUM].
- * @param irqParam [IN] Type#HWI_IRQ_PARAM_S: id of hardware interrupt which will base on when delete the hardware
- * interrupt.
- *
- * @retval #OS_ERRNO_HWI_NUM_INVALID 0x02000900: Invalid interrupt number.
- * @retval #LOS_OK 0: The interrupt is successfully delete.
- * @par Dependency:
- * los_hwi.h: the header file that contains the API declaration.
- * @see None.
- * @since Huawei LiteOS V200R003C00
- */
-extern UINT32 LOS_HwiDelete(HWI_HANDLE_T hwiNum, HWI_IRQ_PARAM_S irqParam);
-
-#ifdef __cplusplus
-#if __cplusplus
-}
-#endif /* __cplusplus */
-#endif /* __cplusplus */
-
-#endif /* _LOS_HWI_H */
diff --git a/kernel/arch/risc-v/los_hw_tick.c b/kernel/arch/risc-v/los_timer.c
old mode 100755
new mode 100644
similarity index 86%
rename from kernel/arch/risc-v/los_hw_tick.c
rename to kernel/arch/risc-v/los_timer.c
index f9a35408..6b2378fc
--- a/kernel/arch/risc-v/los_hw_tick.c
+++ b/kernel/arch/risc-v/los_timer.c
@@ -31,7 +31,7 @@
#include "los_tick.h"
#include "los_config.h"
-#include "los_interrupt.h"
+#include "los_arch_interrupt.h"
#include "riscv_hal.h"
#ifdef __cplusplus
@@ -42,28 +42,27 @@ extern "C" {
#define NS_PER_SECOND 1000000000.0
-LITE_OS_SEC_TEXT_INIT UINT32 OsTickStart(VOID)
+LITE_OS_SEC_TEXT_INIT UINT32 HalTickStart(OS_TICK_HANDLER handler)
{
g_sysClock = OS_SYS_CLOCK;
g_cyclesPerTick = g_sysClock / LOSCFG_BASE_CORE_TICK_PER_SECOND;
g_intCount = 0;
- SysClockInit(g_cyclesPerTick);
+ HalClockInit(handler, g_cyclesPerTick);
- return LOS_OK;
+ return LOS_OK; /* never return */
}
-
/* ****************************************************************************
-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)
{
- OsGetCpuCycle(cntHi, cntLo);
+ HalGetSysCpuCycle(cntHi, cntLo);
return;
}
diff --git a/kernel/include/los_config.h b/kernel/include/los_config.h
old mode 100755
new mode 100644
index 5fc03de9..91a53024
--- a/kernel/include/los_config.h
+++ b/kernel/include/los_config.h
@@ -38,6 +38,7 @@
#define _LOS_CONFIG_H
#include "target_config.h"
+#include "los_compiler.h"
#ifdef __cplusplus
#if __cplusplus
@@ -53,15 +54,7 @@ extern "C" {
* System clock (unit: HZ)
*/
#ifndef OS_SYS_CLOCK
-#define OS_SYS_CLOCK 100000000UL
-#endif
-
-/**
- * @ingroup los_config
- * timer1 clock (unit: HZ)
- */
-#ifndef OS_TIME_TIMER_CLOCK
-#define OS_TIME_TIMER_CLOCK OS_SYS_CLOCK
+ #error "OS_SYS_CLOCK is system clock rate which should be defined in target_config.h"
#endif
/**
@@ -69,7 +62,7 @@ extern "C" {
* Number of Ticks in one second
*/
#ifndef LOSCFG_BASE_CORE_TICK_PER_SECOND
-#define LOSCFG_BASE_CORE_TICK_PER_SECOND 1000UL
+#define LOSCFG_BASE_CORE_TICK_PER_SECOND (100UL)
#endif
#if defined(LOSCFG_BASE_CORE_TICK_PER_SECOND) && \
@@ -106,35 +99,10 @@ extern "C" {
#endif
#endif
-/**
- * @ingroup los_config
- * External configuration item for timer tailoring
- */
-#ifndef LOSCFG_BASE_CORE_TICK_HW_TIME1
-#define LOSCFG_BASE_CORE_TICK_HW_TIME1 YES
-#endif
-
#ifndef LOSCFG_BASE_CORE_TICK_HW_TIME
-#define LOSCFG_BASE_CORE_TICK_HW_TIME NO
+#define LOSCFG_BASE_CORE_TICK_HW_TIME 0
#endif
-/**
- * @ingroup los_config
- * Configuration liteos kernel tickless
- */
-#ifndef LOSCFG_KERNEL_TICKLESS
-#define LOSCFG_KERNEL_TICKLESS NO
-#endif
-
-/**
- * @ingroup los_config
- * External configuration item for timer interrupt number
- */
-#ifndef LOSCFG_BASE_TIMER_INT_NUM
-#define LOSCFG_BASE_TIMER_INT_NUM 15
-#endif
-
-
/* =============================================================================
Hardware interrupt module configuration
============================================================================= */
@@ -143,7 +111,7 @@ extern "C" {
* Configuration item for hardware interrupt tailoring
*/
#ifndef LOSCFG_PLATFORM_HWI
-#define LOSCFG_PLATFORM_HWI YES
+#define LOSCFG_PLATFORM_HWI 1
#endif
/**
@@ -154,7 +122,6 @@ extern "C" {
#define LOSCFG_PLATFORM_HWI_LIMIT 32
#endif
-
/* =============================================================================
Task module configuration
============================================================================= */
@@ -205,7 +172,7 @@ extern "C" {
* Configuration item for task Robin tailoring
*/
#ifndef LOSCFG_BASE_CORE_TIMESLICE
-#define LOSCFG_BASE_CORE_TIMESLICE YES
+#define LOSCFG_BASE_CORE_TIMESLICE 1
#endif
/**
@@ -221,7 +188,7 @@ extern "C" {
* Configuration item for task (stack) monitoring module tailoring
*/
#ifndef LOSCFG_BASE_CORE_TSK_MONITOR
-#define LOSCFG_BASE_CORE_TSK_MONITOR NO
+#define LOSCFG_BASE_CORE_TSK_MONITOR 0
#endif
/**
@@ -229,7 +196,7 @@ extern "C" {
* Configuration item for task perf task filter hook
*/
#ifndef LOSCFG_BASE_CORE_EXC_TSK_SWITCH
-#define LOSCFG_BASE_CORE_EXC_TSK_SWITCH NO
+#define LOSCFG_BASE_CORE_EXC_TSK_SWITCH 0
#endif
/**
@@ -253,7 +220,7 @@ extern "C" {
* Configuration item for task stack independent
*/
#ifndef LOSCFG_BASE_CORE_TASKSTACK_INDEPENDENT
-#define LOSCFG_BASE_CORE_TASKSTACK_INDEPENDENT NO
+#define LOSCFG_BASE_CORE_TASKSTACK_INDEPENDENT 0
#endif
/**
@@ -272,7 +239,7 @@ extern "C" {
* Configuration item for semaphore module tailoring
*/
#ifndef LOSCFG_BASE_IPC_SEM
-#define LOSCFG_BASE_IPC_SEM YES
+#define LOSCFG_BASE_IPC_SEM 1
#endif
/**
@@ -291,7 +258,7 @@ extern "C" {
* Configuration item for mutex module tailoring
*/
#ifndef LOSCFG_BASE_IPC_MUX
-#define LOSCFG_BASE_IPC_MUX YES
+#define LOSCFG_BASE_IPC_MUX 1
#endif
/**
@@ -310,7 +277,7 @@ extern "C" {
* Configuration item for queue module tailoring
*/
#ifndef LOSCFG_BASE_IPC_QUEUE
-#define LOSCFG_BASE_IPC_QUEUE YES
+#define LOSCFG_BASE_IPC_QUEUE 1
#endif
/**
@@ -330,7 +297,7 @@ extern "C" {
* Configuration item for software timer module tailoring
*/
#ifndef LOSCFG_BASE_CORE_SWTMR
-#define LOSCFG_BASE_CORE_SWTMR YES
+#define LOSCFG_BASE_CORE_SWTMR 1
#endif
/**
@@ -349,24 +316,18 @@ extern "C" {
#define LOSCFG_BASE_CORE_TSK_SWTMR_STACK_SIZE LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE
#endif
-/**
- * @ingroup los_config
- * Configurate item for handling software timer interrupt in task tailoring
- */
-#ifndef LOSCFG_BASE_CORE_SWTMR_TASK
-#define LOSCFG_BASE_CORE_SWTMR_TASK YES
-#endif
-
/**
* @ingroup los_config
* Configurate item for software timer align tailoring
*/
#ifndef LOSCFG_BASE_CORE_SWTMR_ALIGN
-#define LOSCFG_BASE_CORE_SWTMR_ALIGN NO
+#define LOSCFG_BASE_CORE_SWTMR_ALIGN 0
#endif
-#if((LOSCFG_BASE_CORE_SWTMR == NO) && (LOSCFG_BASE_CORE_SWTMR_ALIGN == YES))
- #error "swtmr align first need support swmtr, should make LOSCFG_BASE_CORE_SWTMR = YES"
+#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
+ #if (LOSCFG_BASE_CORE_SWTMR == 0)
+ #error "if LOSCFG_BASE_CORE_SWTMR_ALIGN is set to 1, then LOSCFG_BASE_CORE_SWTMR must alse be set to 1"
+ #endif
#endif
/**
@@ -374,7 +335,7 @@ extern "C" {
* Max number of software timers ID
*/
#ifndef OS_SWTMR_MAX_TIMERID
-#define OS_SWTMR_MAX_TIMERID ((65535 / LOSCFG_BASE_CORE_SWTMR_LIMIT) * LOSCFG_BASE_CORE_SWTMR_LIMIT)
+#define OS_SWTMR_MAX_TIMERID ((65535 / LOSCFG_BASE_CORE_SWTMR_LIMIT) * LOSCFG_BASE_CORE_SWTMR_LIMIT)
#endif
/**
@@ -390,14 +351,16 @@ extern "C" {
* Minimum divisor of software timer multiple alignment
*/
#ifndef LOS_COMMON_DIVISOR
-#define LOS_COMMON_DIVISOR 10
+#define LOS_COMMON_DIVISOR 10
#endif
-#if ((LOSCFG_BASE_IPC_QUEUE == NO) && (LOSCFG_BASE_CORE_SWTMR == YES))
-#error "queue moudle is closed, don't support swtmr"
+#if (LOSCFG_BASE_CORE_SWTMR == 1)
+ #if (LOSCFG_BASE_IPC_QUEUE == 0)
+ #error "if LOSCFG_BASE_CORE_SWTMR is set to 1, then LOSCFG_BASE_IPC_QUEUE must alse be set to 1"
+ #endif
#endif
/* =============================================================================
- Memory module configuration
+ Memory module configuration ---- to be refactored
============================================================================= */
extern UINT8 *m_aucSysMem0;
@@ -423,7 +386,6 @@ extern UINT8 *m_aucSysMem0;
*/
extern UINT32 g_sysMemAddrEnd;
-
/**
* @ingroup los_config
* Memory size
@@ -433,7 +395,7 @@ extern UINT32 g_sysMemAddrEnd;
#endif
#ifndef LOSCFG_MEMORY_BESTFIT
-#define LOSCFG_MEMORY_BESTFIT YES
+#define LOSCFG_MEMORY_BESTFIT 1
#endif
/**
@@ -441,15 +403,7 @@ extern UINT32 g_sysMemAddrEnd;
* Configuration module tailoring of more mempry pool checking
*/
#ifndef LOSCFG_MEM_MUL_POOL
-#define LOSCFG_MEM_MUL_POOL YES
-#endif
-
-/**
- * @ingroup los_config
- * Configuration module tailoring of slab memory
- */
-#ifndef LOSCFG_KERNEL_MEM_SLAB
-#define LOSCFG_KERNEL_MEM_SLAB YES
+#define LOSCFG_MEM_MUL_POOL 1
#endif
/**
@@ -457,7 +411,7 @@ extern UINT32 g_sysMemAddrEnd;
* Configuration module tailoring of mem node integrity checking
*/
#ifndef LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK
-#define LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK NO
+#define LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK 0
#endif
/**
@@ -465,7 +419,7 @@ extern UINT32 g_sysMemAddrEnd;
* Configuration module tailoring of mem node size checking
*/
#ifndef LOSCFG_BASE_MEM_NODE_SIZE_CHECK
-#define LOSCFG_BASE_MEM_NODE_SIZE_CHECK YES
+#define LOSCFG_BASE_MEM_NODE_SIZE_CHECK 0
#endif
/**
@@ -473,7 +427,7 @@ extern UINT32 g_sysMemAddrEnd;
* Configuration of memory statistics
*/
#ifndef LOSCFG_KERNEL_MEM_STATISTICS
-#define LOSCFG_KERNEL_MEM_STATISTICS NO
+#define LOSCFG_KERNEL_MEM_STATISTICS 0
#endif
/**
@@ -489,7 +443,7 @@ extern UINT32 g_sysMemAddrEnd;
* Configuration heap memory peak statistics
*/
#ifndef LOSCFG_HEAP_MEMORY_PEAK_STATISTICS
-#define LOSCFG_HEAP_MEMORY_PEAK_STATISTICS YES
+#define LOSCFG_HEAP_MEMORY_PEAK_STATISTICS 1
#endif
/**
@@ -508,7 +462,6 @@ extern UINT32 g_sysMemAddrEnd;
#define OS_SYS_NOCACHEMEM_ADDR (&g_sysNoCacheMem0[0])
#endif
-
/* =============================================================================
Exception module configuration
============================================================================= */
@@ -517,7 +470,7 @@ extern UINT32 g_sysMemAddrEnd;
* Configuration item for exception tailoring
*/
#ifndef LOSCFG_PLATFORM_EXC
-#define LOSCFG_PLATFORM_EXC NO
+#define LOSCFG_PLATFORM_EXC 0
#endif
/**
@@ -525,71 +478,9 @@ extern UINT32 g_sysMemAddrEnd;
* Configuration of hardware stack protection
*/
#ifndef LOSCFG_EXC_HRADWARE_STACK_PROTECTION
-#define LOSCFG_EXC_HRADWARE_STACK_PROTECTION NO
+#define LOSCFG_EXC_HRADWARE_STACK_PROTECTION 0
#endif
-/**
- * @ingroup los_config
- * Configuration of userspace support
- */
-#ifndef LOSCFG_KERNEL_USERSPACE
-#define LOSCFG_KERNEL_USERSPACE NO
-#endif
-
-/* =============================================================================
- MPU module configuration
-============================================================================= */
-/**
- * @ingroup los_config
- * Configuration item for MPU
- */
-#ifndef LOSCFG_BASE_CORE_MPU
-#define LOSCFG_BASE_CORE_MPU NO
-#endif
-
-/**
- * @ingroup los_config
- * MPU support number : MPU maximum number of region support(According to the cotex-m4 authority Guide)
- */
-#ifndef LOSCFG_MPU_MAX_SUPPORT
-#define LOSCFG_MPU_MAX_SUPPORT 8
-#endif
-
-/**
- * @ingroup los_config
- * MPU support address range : from LOSCFG_MPU_MIN_ADDRESS to LOSCFG_MPU_MAX_ADDRESS
- */
-#ifndef LOSCFG_MPU_MIN_ADDRESS
-#define LOSCFG_MPU_MIN_ADDRESS 0x0UL // Minimum protected address
-#endif
-
-#ifndef LOSCFG_MPU_MAX_ADDRESS
-#define LOSCFG_MPU_MAX_ADDRESS 0xFFFFFFFFUL // Maximum protected address
-#endif
-
-/* =============================================================================
- Runstop module configuration
-============================================================================= */
-/**
- * @ingroup los_config
- * Configuration item for runstop module tailoring
- */
-#ifndef LOSCFG_KERNEL_RUNSTOP
-#define LOSCFG_KERNEL_RUNSTOP NO
-#endif
-
-/* =============================================================================
- Perf module configuration
-============================================================================= */
-/**
- * @ingroup los_config
- * Configuration item for performance moniter unit
- */
-#ifndef OS_INCLUDE_PERF
-#define OS_INCLUDE_PERF NO
-#endif
-
-
/* =============================================================================
CPUP configuration
============================================================================= */
@@ -598,34 +489,9 @@ extern UINT32 g_sysMemAddrEnd;
* Configuration item for CPU usage tailoring
*/
#ifndef LOSCFG_BASE_CORE_CPUP
-#define LOSCFG_BASE_CORE_CPUP NO
+#define LOSCFG_BASE_CORE_CPUP 0
#endif
-
-/* =============================================================================
- fw Interface configuration
-============================================================================= */
-/**
- * @ingroup los_config
- * Configuration item for the monitoring of task communication
- */
-#ifndef LOSCFG_COMPAT_CMSIS_FW
-#define LOSCFG_COMPAT_CMSIS_FW NO
-#endif
-
-
-/* =============================================================================
- Shell module configuration
-============================================================================= */
-/**
- * @ingroup los_config
- * Configuration item for shell module tailoring
- */
-#ifndef OS_INCLUDE_SHELL
-#define OS_INCLUDE_SHELL NO
-#endif
-
-
/* =============================================================================
Test module configuration
============================================================================= */
@@ -650,350 +516,10 @@ extern UINT32 g_sysMemAddrEnd;
* Configuration liteos trace
*/
#ifndef LOSCFG_KERNEL_TRACE
-#define LOSCFG_KERNEL_TRACE NO
+#define LOSCFG_KERNEL_TRACE 0
#endif
-/* =============================================================================
- Declaration of Huawei LiteOS module initialization functions
-============================================================================= */
-/**
- * @ingroup los_config
- * @brief: Task init function.
- *
- * @par Description:
- * This API is used to initialize task module.
- *
- * @attention:
- *
- *
- * @param: None.
- *
- * @retval #LOS_ERRNO_TSK_NO_MEMORY 0x03000200:Insufficient memory for task creation.
- * @retval #LOS_OK 0:Task initialization success.
- *
- * @par Dependency:
- * los_config.h: the header file that contains the API declaration.
- * @see None.
- */
-extern UINT32 OsTaskInit(VOID);
-
-
-/**
- * @ingroup los_config
- * @brief: hardware interrupt init function.
- *
- * @par Description:
- * This API is used to initialize hardware interrupt module.
- *
- * @attention:
- *
- *
- * @param: None.
- *
- * @retval #LOS_OK 0:Hardware interrupt initialization success.
- *
- * @par Dependency:
- * los_config.h: the header file that contains the API declaration.
- * @see None.
- */
-extern VOID OsHwiInit(VOID);
-
-
-/**
- * @ingroup los_config
- * @brief: Semaphore init function.
- *
- * @par Description:
- * This API is used to initialize Semaphore module.
- *
- * @attention:
- *
- *
- * @param: None.
- *
- * @retval #LOS_ERRNO_SEM_NO_MEMORY 0x02000700:The memory is insufficient.
- * @retval #LOS_OK 0:Semaphore initialization success.
- *
- * @par Dependency:
- * los_config.h: the header file that contains the API declaration.
- * @see None.
- */
-extern UINT32 OsSemInit(VOID);
-
-
-/**
- * @ingroup los_config
- * @brief: Mutex init function.
- *
- * @par Description:
- * This API is used to initialize mutex module.
- *
- * @attention:
- *
- *
- * @param: None.
- *
- * @retval #LOS_ERRNO_MUX_NO_MEMORY 0x02001d00:The memory request fails.
- * @retval #LOS_OK 0:Mutex initialization success.
- *
- * @par Dependency:
- * los_config.h: the header file that contains the API declaration.
- * @see None.
- */
-extern UINT32 OsMuxInit(VOID);
-
-
-/**
- * @ingroup los_config
- * @brief: Queue init function.
- *
- * @par Description:
- * This API is used to initialize Queue module.
- *
- * @attention:
- *
- *
- * @param: None.
- *
- * @retval #LOS_ERRNO_QUEUE_MAXNUM_ZERO 0x02000600:The maximum number of queue resources is configured to 0.
- * @retval #LOS_ERRNO_QUEUE_NO_MEMORY 0x02000601:The queue block memory fails to be initialized.
- * @retval #LOS_OK 0:Queue initialization success.
- *
- * @par Dependency:
- * los_config.h: the header file that contains the API declaration.
- * @see None.
- */
-extern UINT32 OsQueueInit(VOID);
-
-
-/**
- * @ingroup los_config
- * @brief: Software Timers init function.
- *
- * @par Description:
- * This API is used to initialize Software Timers module.
- *
- * @attention:
- *
- *
- * @param: None.
- *
- * @retval #LOS_ERRNO_SWTMR_MAXSIZE_INVALID 0x02000308:Invalid configured number of software timers.
- * @retval #LOS_ERRNO_SWTMR_NO_MEMORY 0x02000307:Insufficient memory for software timer linked list creation.
- * @retval #LOS_ERRNO_SWTMR_HANDLER_POOL_NO_MEM 0x0200030a:Insufficient memory allocated by membox.
- * @retval #LOS_ERRNO_SWTMR_QUEUE_CREATE_FAILED 0x0200030b:The software timer queue fails to be created.
- * @retval #LOS_ERRNO_SWTMR_TASK_CREATE_FAILED 0x0200030c:The software timer task fails to be created.
- * @retval #LOS_OK 0:Software Timers initialization success.
- *
- * @par Dependency:
- * los_config.h: the header file that contains the API declaration.
- * @see None.
- */
-extern UINT32 OsSwtmrInit(VOID);
-
-
-/**
- * @ingroup los_config
- * @brief: Task start running function.
- *
- * @par Description:
- * This API is used to start a task.
- *
- * @attention:
- *
- *
- * @param: None.
- *
- * @retval None.
- *
- * @par Dependency:
- * los_config.h: the header file that contains the API declaration.
- * @see None.
- */
-extern VOID LOS_StartToRun(VOID);
-
-
-/**
- * @ingroup los_config
- * @brief: Test Task init function.
- *
- * @par Description:
- * This API is used to initialize Test Task.
- *
- * @attention:
- *
- *
- * @param: None.
- *
- * @retval #LOS_OK 0:App_Task initialization success.
- *
- * @par Dependency:
- * los_config.h: the header file that contains the API declaration.
- * @see None.
- */
-extern UINT32 los_TestInit(VOID);
-
-
-
-/**
- * @ingroup los_config
- * @brief: Task start function.
- *
- * @par Description:
- * This API is used to start all tasks.
- *
- * @attention:
- *
- *
- * @param: None.
- *
- * @retval None.
- *
- * @par Dependency:
- * los_config.h: the header file that contains the API declaration.
- * @see None.
- */
-extern VOID OsStart(VOID);
-
-
-/**
- * @ingroup los_config
- * @brief: Hardware init function.
- *
- * @par Description:
- * This API is used to initialize Hardware module.
- *
- * @attention:
- *
- *
- * @param: None.
- *
- * @retval None.
- *
- * @par Dependency:
- * los_config.h: the header file that contains the API declaration.
- * @see None.
- */
-extern VOID OsHwInit(VOID);
-
-
-/**
- * @ingroup los_config
- * @brief Configure Tick Interrupt Start.
- *
- * @par Description:
- * This API is used to configure Tick Interrupt Start while macro LOSCFG_BASE_CORE_TICK_HW_TIME is No.
- *
- * @attention
- *
- *
- * @param: None.
- *
- * @retval #LOS_OK 0:configure Tick Interrupt success.
- * @retval #LOS_ERRNO_TICK_CFG_INVALID 0x02000400:configure Tick Interrupt failed.
- *
- * @par Dependency:
- * los_config.h: the header file that contains the API declaration.
- * @see
- */
-extern UINT32 OsTickStart(VOID);
-
-/**
- * @ingroup los_config
- * @brief Scheduling initialization.
- *
- * @par Description:
- *
- * This API is used to initialize scheduling that is used for later task scheduling.
- *
- * @attention
- *
- *
- * @param: None.
- *
- * @retval: None.
- * @par Dependency:
- * los_config.h: the header file that contains the API declaration.
- * @see
- */
-extern VOID OsTimesliceInit(VOID);
-
-
-/**
- * @ingroup los_config
- * @brief: System memory init function.
- *
- * @par Description:
- * This API is used to initialize system memory module.
- *
- * @attention:
- *
- *
- * @param: None.
- *
- * @retval #LOS_OK 0:System memory initialization success.
- * @retval #OS_ERROR (UINT32)(-1):System memory initialization failed.
- *
- * @par Dependency:
- * los_config.h: the header file that contains the API declaration.
- * @see None.
- */
-extern LITE_OS_SEC_TEXT_INIT UINT32 OsMemSystemInit(VOID);
-
-
-/**
- * @ingroup los_config
- * @brief: Task Monitor init function.
- *
- * @par Description:
- * This API is used to initialize Task Monitor module.
- *
- * @attention:
- *
- *
- * @param: None.
- *
- * @retval #LOS_OK 0:Task Monitor initialization success.
- *
- * @par Dependency:
- * los_config.h: the header file that contains the API declaration.
- * @see None.
- */
-extern VOID OsTaskMonInit(VOID);
-
-
-/**
- * @ingroup los_config
- * @brief: CPUP init function.
- *
- * @par Description:
- * This API is used to initialize CPUP module.
- *
- * @attention:
- *
- *
- * @param: None.
- *
- * @retval #LOS_ERRNO_CPUP_NO_MEMORY 0x02001e00:The request for memory fails.
- * @retval #LOS_OK 0:CPUP initialization success.
- *
- * @par Dependency:
- * los_config.h: the header file that contains the API declaration.
- * @see None.
- */
-extern UINT32 OsCpupInit(VOID);
-
-
-extern LITE_OS_SEC_TEXT_INIT UINT32 LOS_Start(VOID);
-
-extern LITE_OS_SEC_TEXT_INIT INT32 main(VOID);
-
-
#ifdef __cplusplus
#if __cplusplus
}
diff --git a/kernel/include/los_event.h b/kernel/include/los_event.h
old mode 100755
new mode 100644
diff --git a/kernel/include/los_membox.h b/kernel/include/los_membox.h
old mode 100755
new mode 100644
index 07bb6777..1d0f537d
--- a/kernel/include/los_membox.h
+++ b/kernel/include/los_membox.h
@@ -32,7 +32,7 @@
#ifndef _LOS_MEMBOX_H
#define _LOS_MEMBOX_H
-#if (LOSCFG_PLATFORM_EXC == YES)
+#if (LOSCFG_PLATFORM_EXC == 1)
#include "los_memory.h"
#endif
@@ -44,7 +44,7 @@
* @ingroup los_membox
* Define whether to check the address validity
*/
-#if (LOSCFG_PLATFORM_EXC == YES)
+#if (LOSCFG_PLATFORM_EXC == 0)
#define LOS_MEMBOX_CHECK
extern UINT8 g_memMang[];
#endif
diff --git a/kernel/include/los_memory.h b/kernel/include/los_memory.h
old mode 100755
new mode 100644
index 10f54ad8..e6656f1b
--- a/kernel/include/los_memory.h
+++ b/kernel/include/los_memory.h
@@ -29,6 +29,11 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/**
+ * @defgroup los_memory Dynamic memory
+ * @ingroup kernel
+ */
+
#ifndef _LOS_MEMORY_H
#define _LOS_MEMORY_H
@@ -41,129 +46,259 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
-#define IS_ALIGNED(value) ((((UINT32)(value)) & ((UINT32)((value) - 1))) == 0)
-#define OS_MEM_ALIGN(value, align) (((UINT32)(UINTPTR)(value) + (UINT32)((align) - 1)) & \
- (~(UINT32)((align) - 1)))
-#define OS_MEM_ALIGN_FLAG 0x80000000
-#define OS_MEM_SET_ALIGN_FLAG(align) ((align) = ((align) | OS_MEM_ALIGN_FLAG))
-#define OS_MEM_GET_ALIGN_FLAG(align) ((align) & OS_MEM_ALIGN_FLAG)
-#define OS_MEM_GET_ALIGN_GAPSIZE(align) ((align) & (~OS_MEM_ALIGN_FLAG))
+#ifdef LOSCFG_MEM_LEAKCHECK
/**
* @ingroup los_memory
- * Memory pool information structure
+ * The omit layers of function call from call kernel memory interfaces
+ * such as LOS_MemAlloc/LOS_MemAllocAlign/LOS_MemRealloc/LOS_MemFree.
*/
-typedef struct {
- VOID *pPoolAddr; /**< Starting address of a memory pool */
- UINT32 uwPoolSize; /**< Memory pool size */
-#if defined(OS_MEM_WATERLINE) && (OS_MEM_WATERLINE == YES)
- UINT32 uwPoolWaterLine; /**< Maximum usage size in a memory pool */
- UINT32 uwPoolCurUsedSize; /**< Current usage size in a memory pool */
-#endif
-//#ifdef LOSCFG_MEM_MUL_POOL
- VOID *pNextPool;
-//#endif
-} LOS_MEM_POOL_INFO;
-
-
-
-
-typedef struct __s_LOS_MEM_STATUS {
- UINT32 totalSize;
- UINT32 usedSize;
- UINT32 freeSize;
- UINT32 allocCount;
- UINT32 freeCount;
-} LOS_MEM_STATUS;
-
-
-#define MEM_INFO_SIZE ((sizeof(MEM_INFO) * OS_SYS_MEM_NUM) + 4)
-extern UINT8 g_memMang[];
-
-enum _MEM_MANG_TYPE {
- MEM_MANG_MEMBOX,
- MEM_MANG_MEMORY,
- MEM_MANG_EMPTY,
-};
-
-enum _MEM_MANG_SOUCE {
- MEM_MANG_UNUSED,
- MEM_MANG_INIT,
- MEM_MANG_INT,
- MEM_MANG_TASK,
-};
-
-typedef struct _MEM_INFO {
- UINT32 uwType;
- UINT32 uwStartAddr;
- UINT32 uwSize;
- VOID * blkAddrArray;
-}MEM_INFO;
-
-typedef struct _SLAB_INFO {
- UINT32 item_sz;
- UINT32 item_cnt;
- UINT32 cur_usage;
-}SLAB_INFO;
-
-#define SLAB_CLASS_NUM (4U)
-typedef struct _MEM_INFO_S {
- UINT32 uwType;
- UINT32 uwStartAddr;
- UINT32 uwSize;
- UINT32 uwFree;
- UINT32 uwBlockSize;
- UINT32 uwErrorAddr;
- UINT32 uwErrorLen;
- UINT32 uwErrorOwner;
- SLAB_INFO stSlabInfo[SLAB_CLASS_NUM];
-}MEM_INFO_S;
+#define LOS_OMIT_LR_CNT 2
/**
- * @ingroup los_memboxcheck
- * @brief Get the information of the exc memory.
+ * @ingroup los_memory
+ * The recored layes of function call.
+ */
+#define LOS_RECORD_LR_CNT 3
+#endif
+
+/**
+ * @ingroup los_memory
+ * The memory Maximum memory usage statistics.
+ * @attention
+ * If running as debug mode, it will affect the performance of memory malloc and free.
+ * OS_MEM_WATERLINE=YES: open the function for Maximum memory usage statistics
+ * OS_MEM_WATERLINE=NO: close the function for Maximum memory usage statistics, it set to NO as usual
+ *
+ */
+#ifdef LOSCFG_MEM_WATERLINE
+#define OS_MEM_WATERLINE NO
+#endif
+
+#if (LOSCFG_MEM_MUL_POOL == 1)
+/**
+ * @ingroup los_memory
+ * @brief Deinitialize dynamic memory.
*
* @par Description:
*
- * This API is used to get the information of the exc memory.
- *
- * @attention
- *
- * None.
+ * This API is used to deinitialize the dynamic memory of a doubly linked list.
*
*
- * @param memNum [IN] Type #UINT32 Memory pool number.
- * @param memExcInfo [IN/OUT] Type #MEM_INFO_S * information of the exc memory.
+ * @param pool [IN] Starting address of memory.
*
- * @retval UINT32 Get information result.
+ * @retval #OS_ERROR The dynamic memory fails to be deinitialized.
+ * @retval #LOS_OK The dynamic memory is successfully deinitialized.
* @par Dependency:
*
- * los_memboxcheck.h: the header file that contains the API declaration.
+ * los_memory.h: the header file that contains the API declaration.
*
* @see None.
*/
-UINT32 LOS_MemExcInfoGet(UINT32 memNum, MEM_INFO_S *memExcInfo);
+extern UINT32 LOS_MemDeInit(VOID *pool);
-//#if (LOSCFG_MEMORY_BESTFIT == YES)
-
-
-#if (LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK == YES)
-extern UINT8 g_memMang[];
-#endif
-#if (LOSCFG_PLATFORM_EXC == YES)
-#define OS_MEM_ENABLE_ALLOC_CHECK
-#endif
-#if (LOSCFG_BASE_MEM_NODE_SIZE_CHECK == YES)
-#define OS_MEM_CHECK_DEBUG
+/**
+ * @ingroup los_memory
+ * @brief Print infomation about all pools.
+ *
+ * @par Description:
+ *
+ * This API is used to print infomation about all pools.
+ *
+ *
+ * @retval #UINT32 The pool number.
+ * @par Dependency:
+ *
+ * los_memory.h: the header file that contains the API declaration.
+ *
+ * @see None.
+ */
+extern UINT32 LOS_MemPoolList(VOID);
#endif
-#ifdef LOSCFG_MEM_MUL_POOL
-extern VOID *g_memPoolHead;
+/**
+ * @ingroup los_memory
+ * Memory pool extern information structure
+ */
+typedef struct {
+ UINT32 totalUsedSize;
+ UINT32 totalFreeSize;
+ UINT32 maxFreeNodeSize;
+ UINT32 usedNodeNum;
+ UINT32 freeNodeNum;
+#if defined(OS_MEM_WATERLINE) && (OS_MEM_WATERLINE == YES)
+ UINT32 usageWaterLine;
#endif
+} LOS_MEM_POOL_STATUS;
-typedef VOID (*MALLOC_HOOK)(VOID);
+/**
+ * @ingroup los_memory
+ * @brief Initialize dynamic memory.
+ *
+ * @par Description:
+ *
+ * This API is used to initialize the dynamic memory of a doubly linked list.
+ *
+ * @attention
+ *
+ * The size parameter value should match the following two conditions :
+ * 1) Be less than or equal to the Memory pool size;
+ * 2) Be greater than the size of OS_MEM_MIN_POOL_SIZE.
+ * Call this API when dynamic memory needs to be initialized during the startup of Huawei LiteOS.
+ * The parameter input must be four byte-aligned.
+ * The init area [pool, pool + size] should not conflict with other pools.
+ *
+ *
+ * @param pool [IN] Starting address of memory.
+ * @param size [IN] Memory size.
+ *
+ * @retval #OS_ERROR The dynamic memory fails to be initialized.
+ * @retval #LOS_OK The dynamic memory is successfully initialized.
+ * @par Dependency:
+ *
+ * los_memory.h: the header file that contains the API declaration.
+ *
+ * @see None.
+ */
+extern UINT32 LOS_MemInit(VOID *pool, UINT32 size);
-extern MALLOC_HOOK g_mallocHook;
+/**
+ * @ingroup los_memory
+ * @brief Allocate dynamic memory.
+ *
+ * @par Description:
+ *
+ * This API is used to allocate a memory block of which the size is specified.
+ *
+ * @attention
+ *
+ * The input pool parameter must be initialized via func LOS_MemInit.
+ * The size of the input parameter size can not be greater than the memory pool size that specified at the second
+ * input parameter of LOS_MemInit.
+ * The size of the input parameter size must be four byte-aligned.
+ *
+ *
+ * @param pool [IN] Pointer to the memory pool that contains the memory block to be allocated.
+ * @param size [IN] Size of the memory block to be allocated (unit: byte).
+ *
+ * @retval #NULL The memory fails to be allocated.
+ * @retval #VOID* The memory is successfully allocated with the starting address of the allocated memory block
+ * returned.
+ * @par Dependency:
+ * los_memory.h: the header file that contains the API declaration.
+ * @see LOS_MemRealloc | LOS_MemAllocAlign | LOS_MemFree
+ */
+extern VOID *LOS_MemAlloc(VOID *pool, UINT32 size);
+
+/**
+ * @ingroup los_memory
+ * @brief Free dynamic memory.
+ *
+ * @par Description:
+ * This API is used to free specified dynamic memory that has been allocated.
+ * @attention
+ *
+ * The input pool parameter must be initialized via func LOS_MemInit.
+ * The input ptr parameter must be allocated by LOS_MemAlloc or LOS_MemAllocAlign or LOS_MemRealloc.
+ *
+ *
+ * @param pool [IN] Pointer to the memory pool that contains the dynamic memory block to be freed.
+ * @param ptr [IN] Starting address of the memory block to be freed.
+ *
+ * @retval #LOS_NOK The memory block fails to be freed because the starting address of the memory block is
+ * invalid, or the memory overwriting occurs.
+ * @retval #LOS_OK The memory block is successfully freed.
+ * @par Dependency:
+ * los_memory.h: the header file that contains the API declaration.
+ * @see LOS_MemAlloc | LOS_MemRealloc | LOS_MemAllocAlign
+ */
+extern UINT32 LOS_MemFree(VOID *pool, VOID *ptr);
+
+/**
+ * @ingroup los_memory
+ * @brief Re-allocate a memory block.
+ *
+ * @par Description:
+ *
+ * This API is used to allocate a new memory block of which the size is specified by size if the original memory
+ * block size is insufficient. The new memory block will copy the data in the original memory block of which the
+ * address is specified by ptr. The size of the new memory block determines the maximum size of data to be copied.
+ * After the new memory block is created, the original one is freed.
+ *
+ * @attention
+ *
+ * The input pool parameter must be initialized via func LOS_MemInit.
+ * The input ptr parameter must be allocated by LOS_MemAlloc or LOS_MemAllocAlign.
+ * The size of the input parameter size can not be greater than the memory pool size that specified at the second
+ * input parameter of LOS_MemInit.
+ * The size of the input parameter size must be aligned as follows: 1) if the ptr is allocated by LOS_MemAlloc,
+ * it must be four byte-aligned; 2) if the ptr is allocated by LOS_MemAllocAlign, it must be aligned with the size of
+ * the input parameter boundary of LOS_MemAllocAlign.
+ *
+ *
+ * @param pool [IN] Pointer to the memory pool that contains the original and new memory blocks.
+ * @param ptr [IN] Address of the original memory block.
+ * @param size [IN] Size of the new memory block.
+ *
+ * @retval #NULL The memory fails to be re-allocated.
+ * @retval #VOID* The memory is successfully re-allocated with the starting address of the new memory block returned.
+ * @par Dependency:
+ * los_memory.h: the header file that contains the API declaration.
+ * @see LOS_MemAlloc | LOS_MemAllocAlign | LOS_MemFree
+ */
+extern VOID *LOS_MemRealloc(VOID *pool, VOID *ptr, UINT32 size);
+
+/**
+ * @ingroup los_memory
+ * @brief Allocate aligned memory.
+ *
+ * @par Description:
+ *
+ * This API is used to allocate memory blocks of specified size and of which the starting addresses are aligned on
+ * a specified boundary.
+ *
+ * @attention
+ *
+ * The input pool parameter must be initialized via func LOS_MemInit.
+ * The size of the input parameter size can not be greater than the memory pool size that specified at the second
+ * input parameter of LOS_MemInit.
+ * The alignment parameter value must be a power of 2 with the minimum value being 4.
+ *
+ *
+ * @param pool [IN] Pointer to the memory pool that contains the memory blocks to be allocated.
+ * @param size [IN] Size of the memory to be allocated.
+ * @param boundary [IN] Boundary on which the memory is aligned.
+ *
+ * @retval #NULL The memory fails to be allocated.
+ * @retval #VOID* The memory is successfully allocated with the starting address of the allocated memory returned.
+ * @par Dependency:
+ * los_memory.h: the header file that contains the API declaration.
+ * @see LOS_MemAlloc | LOS_MemRealloc | LOS_MemFree
+ */
+extern VOID *LOS_MemAllocAlign(VOID *pool, UINT32 size, UINT32 boundary);
+
+/**
+ * @ingroup los_memory
+ * @brief Get the size of memory pool's size.
+ *
+ * @par Description:
+ *
+ * This API is used to get the size of memory pool' total size.
+ *
+ * @attention
+ *
+ * The input pool parameter must be initialized via func LOS_MemInit.
+ *
+ *
+ * @param pool [IN] A pointer pointed to the memory pool.
+ *
+ * @retval #LOS_NOK The incoming parameter pool is NULL.
+ * @retval #UINT32 The size of the memory pool.
+ * @par Dependency:
+ * los_memory.h: the header file that contains the API declaration.
+ * @see None.
+ */
+extern UINT32 LOS_MemPoolSizeGet(const VOID *pool);
/**
* @ingroup los_memory
@@ -190,89 +325,41 @@ extern UINT32 LOS_MemTotalUsedGet(VOID *pool);
/**
* @ingroup los_memory
- * @brief Get the number of free memory nodes.
+ * @brief Get the infomation of memory pool.
*
* @par Description:
*
- * This API is used to get the number of free memory nodes in memory pool.
+ * This API is used to get the infomation of memory pool.
*
* @attention
*
* The input pool parameter must be initialized via func LOS_MemInit.
*
*
- * @param pool [IN] A pointer pointed to the memory pool.
+ * @param pool [IN] A pointer pointed to the memory pool.
+ * @param poolStatus [IN] A pointer for storage the pool status
*
- * @retval #LOS_NOK The incoming parameter pool is NULL.
- * @retval #UINT32 The number of free memory nodes.
+ * @retval #LOS_NOK The incoming parameter pool is NULL or invalid.
+ * @retval #LOS_OK Success to get memory infomation.
* @par Dependency:
* los_memory.h: the header file that contains the API declaration.
* @see None.
*/
-extern UINT32 LOS_MemFreeBlksGet(VOID *pool);
+extern UINT32 LOS_MemInfoGet(VOID *pool, LOS_MEM_POOL_STATUS *poolStatus);
/**
* @ingroup los_memory
- * @brief Get the number of used memory nodes.
+ * @brief Get the number of free node in every size.
*
* @par Description:
*
- * This API is used to get the number of used memory nodes in memory pool.
+ * This API is used to get the number of free node in every size.
*
* @attention
*
* The input pool parameter must be initialized via func LOS_MemInit.
*
*
- * @param pool [IN] A pointer pointed to the memory pool.
- *
- * @retval #LOS_NOK The incoming parameter pool is NULL.
- * @retval #UINT32 The number of used memory nodes.
- * @par Dependency:
- * los_memory.h: the header file that contains the API declaration.
- * @see None.
- */
-extern UINT32 LOS_MemUsedBlksGet(VOID *pool);
-
-/**
- * @ingroup los_memory
- * @brief Get the task ID of a used memory node.
- *
- * @par Description:
- *
- * This API is used to get the task ID of a used memory node.
- *
- * @attention
- *
- * The input ptr parameter must be allocated by LOS_MemAlloc or LOS_MemAllocAlign.
- * This interface only support obtain the task ID of a used memory node which is allocated from
- * the system memory pool (OS_SYS_MEM_ADDR) at present.
- *
- *
- * @param pool [IN] A used memory node.
- *
- * @retval #OS_INVALID The incoming parameter ptr is illegal.
- * @retval #UINT32 The task ID of used memory node ptr.
- * @par Dependency:
- * los_memory.h: the header file that contains the API declaration.
- * @see None.
- */
-extern UINT32 LOS_MemTaskIdGet(const VOID *pool);
-
-/**
- * @ingroup los_memory
- * @brief Get the address of last node.
- *
- * @par Description:
- *
- * This API is used to get the address of last node.
- *
- * @attention
- *
- * The input pool parameter must be initialized via func LOS_MemInit.
- * The last node of memory pool is not the end node.
- *
- *
* @param pool [IN] A pointer pointed to the memory pool.
*
* @retval #LOS_NOK The incoming parameter pool is NULL.
@@ -281,15 +368,15 @@ extern UINT32 LOS_MemTaskIdGet(const VOID *pool);
* los_memory.h: the header file that contains the API declaration.
* @see None.
*/
-extern UINT32 LOS_MemLastUsedGet(VOID *pool);
+extern UINT32 LOS_MemFreeNodeShow(VOID *pool);
/**
* @ingroup los_memory
- * @brief Check the memory pool Integrity.
+ * @brief Check the memory pool integrity.
*
* @par Description:
*
- * This API is used to check the memory pool Integrity.
+ * This API is used to check the memory pool integrity.
*
* @attention
*
@@ -307,597 +394,10 @@ extern UINT32 LOS_MemLastUsedGet(VOID *pool);
* los_memory.h: the header file that contains the API declaration.
* @see None.
*/
-extern UINT32 LOS_MemIntegrityCheck(VOID *pool);
+extern UINT32 LOS_MemIntegrityCheck(const VOID *pool);
-/**
- * @ingroup los_memory
- * Define a mem size check intensity
- *
- * Lowest mem check.
- */
-#define LOS_MEM_CHECK_LEVEL_LOW 0
-
-/**
- * @ingroup los_memory
- * Define a mem size check intensity
- *
- * Highest mem check.
- */
-#define LOS_MEM_CHECK_LEVEL_HIGH 1
-
-/**
- * @ingroup los_memory
- * Define a mem size check intensity
- *
- * disable mem check.
- */
-#define LOS_MEM_CHECK_LEVEL_DISABLE 0xff
-
-/**
- * @ingroup los_memory
- * Define a mem size check intensity
- *
- * default intensity set mem check.
- */
-#define LOS_MEM_CHECK_LEVEL_DEFAULT LOS_MEM_CHECK_LEVEL_DISABLE
-
-/**
- * @ingroup los_memory
- * @brief Check the size of memory node specified.
- *
- * @par Description:
- *
- * This API is used to check the size of memory node.
- *
- * @attention
- *
- * The input pool parameter must be initialized via func LOS_MemInit.
- * The input ptr parameter must be allocated by LOS_MemAlloc or LOS_MemAllocAlign.
- * The function will be called by function specified, such as memset or memcpy.
- * The feature can be enabled when you set the macro value of LOSCFG_BASE_MEM_NODE_SIZE_CHECK as YES.
- * You had better set memory check level as LOS_MEM_CHECK_LEVEL_DISABLE when copy bin file.
- *
- *
- * @param pool [IN] A pointer pointed to the memory pool.
- * @param ptr [IN] A pointer pointed to the source node.
- * @param totalSize [OUT] A pointer to save total size, must point to valid memory.
- * @param availSize [OUT] A pointer to save available size, must point to valid memory.
- *
- * @retval #OS_ERRNO_MEMCHECK_DISABLED Memcheck function does not open.
- * @retval #OS_ERRNO_MEMCHECK_NOT_INIT Memcheck function does not init.
- * @retval #OS_ERRNO_MEMCHECK_PARA_NULL The pool or ptr is NULL.
- * @retval #OS_ERRNO_MEMCHECK_OUTSIDE The ptr address is not in the reasonable range.
- * @retval #OS_ERRNO_MEMCHECK_NO_HEAD Can't find the control head node from ptr.
- * @retval #OS_ERRNO_MEMCHECK_WRONG_LEVEL The memory check level is illegal.
- * @retval #LOS_OK Success to get total size and available
- * size of the memory node (ptr).
- * @par Dependency:
- * los_memory.h: the header file that contains the API declaration.
- * @see LOS_MemCheckLevelSet | LOS_MemCheckLevelGet
- */
-extern UINT32 LOS_MemNodeSizeCheck(VOID *pool, VOID *ptr, UINT32 *totalSize, UINT32 *availSize);
-
-/**
- * @ingroup los_memory
- * @brief Set the memory check level.
- *
- * @par Description:
- *
- * This API is used to set the memory check level.
- *
- * @attention
- *
- * There are three level you can set.
- * The legal level are LOS_MEM_CHECK_LEVEL_LOW, LOS_MEM_CHECK_LEVEL_HIGH, LOS_MEM_CHECK_LEVEL_DISABLE.
- *
- *
- * @param level [IN] The level what you want to set.
- *
- * @retval #LOS_ERRNO_MEMCHECK_WRONG_LEVEL The memory check level what you want to set is illegal.
- * @retval #LOS_OK Success to set the memory check level.
- * @par Dependency:
- * los_memory.h: the header file that contains the API declaration.
- * @see LOS_MemNodeSizeCheck | LOS_MemCheckLevelGet
- */
-extern UINT32 LOS_MemCheckLevelSet(UINT8 level);
-
-/**
- * @ingroup los_memory
- * @brief Get the memory check level.
- *
- * @par Description:
- *
- * This API is used to get the current memory check level.
- *
- * @attention
- *
- *
- * @param None
- *
- * @retval #UINT8 The current memory check level.
- * @par Dependency:
- * los_memory.h: the header file that contains the API declaration.
- * @see LOS_MemNodeSizeCheck | LOS_MemCheckLevelSet
- */
-extern UINT8 LOS_MemCheckLevelGet(VOID);
-/**
- * @ingroup los_memory
- * @brief Get the memory pool information.
- *
- * @par Description:
- *
- * This API is used to get the current memory pool used information.
- *
- * @attention
- *
- *
- * @param pool [IN] A pointer pointed to the memory pool.
- * @param status [IN] A pointer for storage the pool status.
- *
- * @retval #LOS_OK Success to get the memory pool information.
- * @par Dependency:
- * los_memory.h: the header file that contains the API declaration.
- */
-extern UINT32 LOS_MemInfoGet(VOID *pool, LOS_MEM_STATUS *status);
-
-/**
- * @ingroup los_memory
- * @brief calculate heap information.
- *
- * @par Description:
- *
- * This API is used to calculate heap information.
- *
- * @attention
- *
- * One parameter of this interface is a pointer, it should be a correct value, otherwise,
- * the system may be abnormal.
- *
- *
- * @param pool [IN] Pointer to the memory pool that contains the memory block to be allocated.
- * @param status [OUT] Type #LOS_MEM_STATUS* Pointer to the heap status structure to be obtained.
- *
- * @retval #LOS_OK The heap status calculate success.
- * @retval #LOS_NOK The heap status calculate with some error.
- * @par Dependency:
- * los_memory.h: the header file that contains the API declaration.
- * @see LOS_MemAlloc | LOS_MemRealloc | LOS_MemFree
- */
-extern UINT32 LOS_MemStatisticsGet(VOID *pool, LOS_MEM_STATUS *status);
-
-/**
- * @ingroup los_memory
- * @brief calculate heap max free block size.
- *
- * @par Description:
- *
- * This API is used to calculate heap max free block size.
- *
- * @attention
- *
- *
- * @param pool [IN] Pointer to memory pool.
- *
- * @retval #UINT32 The max free block size.
- * @par Dependency:
- * los_memory.h: the header file that contains the API declaration.
- * @see LOS_MemAlloc | LOS_MemRealloc | LOS_MemFree
- */
-extern UINT32 LOS_MemGetMaxFreeBlkSize(VOID *pool);
-//#endif
-
-/**
- * @ingroup los_memory
- * @brief Initialize dynamic memory.
- *
- * @par Description:
- *
- * This API is used to initialize the dynamic memory of a doubly linked list.
- *
- * @attention
- *
- * The size parameter value should match the following two conditions : 1) Be less than or equal to
- * the Memory pool size; 2) Be greater than the size of OS_MEM_MIN_POOL_SIZE.
- * Call this API when dynamic memory needs to be initialized during the startup of Huawei LiteOS.
- * The parameter input must be four byte-aligned.
- * The init area [pool, pool + size] should not conflict with other pools.
- *
- *
- * @param pool [IN] Starting address of memory.
- * @param size [IN] Memory size.
- *
- * @retval #LOS_NOK The dynamic memory fails to be initialized.
- * @retval #LOS_OK The dynamic memory is successfully initialized.
- * @par Dependency:
- *
- * los_memory.h: the header file that contains the API declaration.
- *
- * @see None.
- */
-extern UINT32 LOS_MemInit(VOID *pool, UINT32 size);
-
-/**
- * @ingroup los_memory
- * @brief Allocate dynamic memory.
- *
- * @par Description:
- *
- * This API is used to allocate a memory block of which the size is specified.
- *
- * @attention
- *
- * The input pool parameter must be initialized via func LOS_MemInit.
- * The size of the input parameter size can not be greater than the memory pool size
- * that specified at the second input parameter of LOS_MemInit.
- * The size of the input parameter size must be four byte-aligned.
- *
- *
- * @param pool [IN] Pointer to the memory pool that contains the memory block to be allocated.
- * @param size [IN] Size of the memory block to be allocated (unit: byte).
- *
- * @retval #NULL The memory fails to be allocated.
- * @retval #VOID* The memory is successfully allocated with the starting address of
- * the allocated memory block returned.
- * @par Dependency:
- * los_memory.h: the header file that contains the API declaration.
- * @see LOS_MemRealloc | LOS_MemAllocAlign | LOS_MemFree
- */
-extern VOID *LOS_MemAlloc(VOID *pool, UINT32 size);
-
-/**
- * @ingroup los_memory
- * @brief Free dynamic memory.
- *
- * @par Description:
- * This API is used to free specified dynamic memory that has been allocated.
- * @attention
- *
- * The input pool parameter must be initialized via func LOS_MemInit.
- * The input mem parameter must be allocated by LOS_MemAlloc or LOS_MemAllocAlign or LOS_MemRealloc.
- *
- *
- * @param pool [IN] Pointer to the memory pool that contains the dynamic memory block to be freed.
- * @param mem [IN] Starting address of the memory block to be freed.
- *
- * @retval #LOS_NOK The memory block fails to be freed
- * @retval #LOS_OK The memory block is successfully freed.
- * @par Dependency:
- * los_memory.h: the header file that contains the API declaration.
- * @see LOS_MemAlloc | LOS_MemRealloc | LOS_MemAllocAlign
- */
-extern UINT32 LOS_MemFree(VOID *pool, VOID *mem);
-
-/**
- * @ingroup los_memory
- * @brief Re-allocate a memory block.
- *
- * @par Description:
- *
- * This API is used to allocate a new memory block of which the size is specified by size if the original
- * memory block size is insufficient. The new memory block will copy the data in the original memory block of
- * which the address is specified by ptr. The size of the new memory block determines the maximum size of data
- * to be copied. After the new memory block is created, the original one is freed.
- *
- * @attention
- *
- * The input pool parameter must be initialized via func LOS_MemInit.
- * The input ptr parameter must be allocated by LOS_MemAlloc.
- * The size of the input parameter size can not be greater than the memory pool size that specified at the
- * second input parameter of LOS_MemInit.
- * The size of the input parameter size must be aligned as follows: 1) if the ptr is allocated by LOS_MemAlloc,
- * it must be four byte-aligned; 2) if the ptr is allocated by LOS_MemAllocAlign, it must be aligned with the size
- * of the input parameter uwBoundary of LOS_MemAllocAlign.
- *
- *
- * @param pool [IN] Pointer to the memory pool that contains the original and new memory blocks.
- * @param ptr [IN] Address of the original memory block.
- * @param size [IN] Size of the new memory block.
- *
- * @retval #NULL The memory fails to be re-allocated.
- * @retval #VOID* The memory is successfully re-allocated with the starting address of the new memory block
- * returned.
- * @par Dependency:
- * los_memory.h: the header file that contains the API declaration.
- * @see LOS_MemAlloc | LOS_MemAllocAlign | LOS_MemFree
- */
-extern VOID *LOS_MemRealloc(VOID *pool, VOID *ptr, UINT32 size);
-
-/**
- * @ingroup los_memory
- * @brief Allocate aligned memory.
- *
- * @par Description:
- *
- * This API is used to allocate memory blocks of specified size and of which the starting addresses are aligned
- * on a specified boundary.
- *
- * @attention
- *
- * The input pool parameter must be initialized via func LOS_MemInit.
- * The size of the input parameter size can not be greater than the memory pool size that specified at the second
- * input parameter of LOS_MemInit.
- * The alignment parameter value must be a power of 2 with the minimum value being 4.
- *
- *
- * @param pool [IN] Pointer to the memory pool that contains the memory blocks to be allocated.
- * @param size [IN] Size of the memory to be allocated.
- * @param boundary [IN] Boundary on which the memory is aligned.
- *
- * @retval #NULL The memory fails to be allocated.
- * @retval #VOID* The memory is successfully allocated with the starting address of the allocated memory
- * returned.
- * @par Dependency:
- * los_memory.h: the header file that contains the API declaration.
- * @see LOS_MemAlloc | LOS_MemRealloc | LOS_MemFree
- */
-extern VOID *LOS_MemAllocAlign(VOID *pool, UINT32 size, UINT32 boundary);
-
-#if (LOSCFG_MEM_MUL_POOL == YES)
-/**
- * @ingroup los_memory
- * @brief Deinitialize dynamic memory.
- *
- * @par Description:
- *
- * This API is used to deinitialize the dynamic memory of a doubly linked list.
- *
- *
- * @param pool [IN] Starting address of memory.
- *
- * @retval #LOS_NOK The dynamic memory fails to be deinitialized.
- * @retval #LOS_OK The dynamic memory is successfully deinitialized.
- * @par Dependency:
- *
- * los_memory.h: the header file that contains the API declaration.
- *
- * @see None.
- */
-extern UINT32 LOS_MemDeInit(const VOID *pool);
-
-/**
- * @ingroup los_memory
- * @brief Print infomation about all pools.
- *
- * @par Description:
- *
- * This API is used to print infomation about all pools.
- *
- *
- * @retval #UINT32 The pool number.
- * @par Dependency:
- *
- * los_memory.h: the header file that contains the API declaration.
- *
- * @see None.
- */
-extern UINT32 LOS_MemPoolList(VOID);
-#endif
-
-#if (LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK == YES)
-/**
- * @ingroup los_memboxcheck
- * @brief Update the information of the memory.
- *
- * @par Description:
- *
- * This API is used to update the information of the memory.
- *
- * @attention
- *
- *
- * @param pool [IN/OUT] Type #VOID * Memory pool number.
- * @param size [IN] Type #UINT32 Memory size.
- * @param type [IN] Type #UINT32 Memory mang type.
- *
- * @retval UINT32 Updateinformation result.
- * @par Dependency:
- *
- * los_memboxcheck_pri.h: the header file that contains the API declaration.
- *
- * @see None.
- */
-UINT32 OsMemInfoUpdate(VOID *pool, UINT32 size, UINT32 type);
-#endif
-
-#define OS_MEM_ENABLE_MEM_STATISTICS
-
-/*
- * memcheck error code: the stack have not inited
- * Value: 0x02000100
- * Solution: do memcheck must after stack mem init
- */
-#define OS_ERRNO_MEMCHECK_NOT_INIT LOS_ERRNO_OS_ERROR(LOS_MOD_MEM, 0x0)
-
-/*
- * memcheck error code: the pPtr is NULL
- * Value: 0x02000101
- * Solution: don't give a NULL parameter
- */
-#define OS_ERRNO_MEMCHECK_PARA_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_MEM, 0x1)
-
-/*
- * memcheck error code: the pPtr addr not in the suit range
- * Value: 0x02000102
- * Solution: check pPtr and comfirm it included by stack
- */
-#define OS_ERRNO_MEMCHECK_OUTSIDE LOS_ERRNO_OS_ERROR(LOS_MOD_MEM, 0x2)
-
-/*
- * memcheck error code: can't find the ctrl node
- * Value: 0x02000103
- * Solution: confirm the pPtr if this node has been freed or has not been alloced
- */
-#define OS_ERRNO_MEMCHECK_NO_HEAD LOS_ERRNO_OS_ERROR(LOS_MOD_MEM, 0x3)
-
-/*
- * memcheck error code: the para level is wrong
- * Value: 0x02000104
- * Solution: checkout the memcheck level by the func "OS_GetMemCheck_Level"
- */
-#define OS_ERRNO_MEMCHECK_WRONG_LEVEL LOS_ERRNO_OS_ERROR(LOS_MOD_MEM, 0x4)
-
-/*
- * memcheck error code: memcheck func not open
- * Value: 0x02000105
- * Solution: enable memcheck by the func "OS_SetMemCheck_Level"
- */
-#define OS_ERRNO_MEMCHECK_DISABLED LOS_ERRNO_OS_ERROR(LOS_MOD_MEM, 0x5)
-
-/**
- * @ingroup los_memory
- * @brief Initialization the memory system.
- *
- * @par Description:
- *
- * This API is used to initialization the memory system.
- *
- * @attention
- *
- *
- * @param None.
- *
- * @retval UINT32 Initialization result.
- * @par Dependency:
- * los_memory_pri.h: the header file that contains the API declaration.
- * @see None.
- */
extern UINT32 OsMemSystemInit(VOID);
-/**
- * @ingroup los_memory
- * Memory linked list node structure
- */
-typedef struct tagLosMemDynNode {
- LOS_DL_LIST freeNodeInfo; /**< Free memory node */
- struct tagLosMemDynNode *preNode; /**< Pointer to the previous memory node */
- UINT32 sizeAndFlag; /**< Size and flag of the current node(the highest bit
- represents a flag, and the rest bits specify the size) */
-} LosMemDynNode;
-
-#define OS_MEM_TASKID_SET(node, ID) \
- do { \
- UINTPTR tmp = (UINTPTR)(((LosMemDynNode *)(node))->freeNodeInfo.pstNext); \
- tmp = tmp & 0xffff0000; \
- tmp |= (ID); \
- ((LosMemDynNode *)(node))->freeNodeInfo.pstNext = (LOS_DL_LIST *)(tmp); \
- } while (0)
-
-#define OS_MEM_TASKID_GET(node) ((UINT32)(UINTPTR)(((LosMemDynNode *)(node))->freeNodeInfo.pstNext) & 0xffff)
-
-#define OS_MEM_MODID_SET(node, ID) \
- do { \
- UINTPTR tmp = (UINTPTR)(((LosMemDynNode *)(node))->freeNodeInfo.pstNext); \
- tmp = tmp & 0xffff; \
- tmp |= (ID) << 16; \
- ((LosMemDynNode *)(node))->freeNodeInfo.pstNext = (LOS_DL_LIST *)(tmp); \
- } while (0)
-
-#define OS_MEM_MODID_GET(node) ((UINT32)(((LosMemDynNode *)(node))->freeNodeInfo.pstNext) >> 16)
-
-#define OS_MEM_NODE_HEAD_SIZE sizeof(LosMemDynNode)
-#define OS_MEM_MIN_POOL_SIZE (OS_DLNK_HEAD_SIZE + (2 * OS_MEM_NODE_HEAD_SIZE) + sizeof(LOS_MEM_POOL_INFO))
-#define OS_MEM_ALIGN_SIZE 4
-#define OS_MEM_NODE_USED_FLAG 0x80000000
-#define OS_MEM_NODE_ALIGNED_FLAG 0x40000000
-#define OS_MEM_NODE_ALIGN_SIZE 64
-#define OS_MEM_NODE_NUM 2
-#define OS_MEM_NODE_DATA_SIZE 4
-#define OS_MEM_NODE_COUNT_NUM 8
-#define OS_MULTI_DLNK_SIZE (OS_MAX_MULTI_DLNK_LOG2 - OS_MIN_MULTI_DLNK_LOG2)
-
-#define OS_MEM_NODE_GET_ALIGNED_FLAG(sizeAndFlag) ((sizeAndFlag) & OS_MEM_NODE_ALIGNED_FLAG)
-#define OS_MEM_NODE_SET_ALIGNED_FLAG(sizeAndFlag) ((sizeAndFlag) = ((sizeAndFlag) | OS_MEM_NODE_ALIGNED_FLAG))
-#define OS_MEM_NODE_GET_ALIGNED_GAPSIZE(sizeAndFlag) ((sizeAndFlag) & (~OS_MEM_NODE_ALIGNED_FLAG))
-#define OS_MEM_NODE_GET_USED_FLAG(sizeAndFlag) ((sizeAndFlag) & OS_MEM_NODE_USED_FLAG)
-#define OS_MEM_NODE_SET_USED_FLAG(sizeAndFlag) ((sizeAndFlag) = ((sizeAndFlag) | OS_MEM_NODE_USED_FLAG))
-#define OS_MEM_NODE_GET_SIZE(sizeAndFlag) ((sizeAndFlag) & (~OS_MEM_NODE_USED_FLAG))
-#define OS_MEM_IS_NODE_NEXT_EXIST(node, poolInfo) (((UINT32)(node) + (node)->sizeAndFlag) < \
- ((UINT32)(poolInfo) + (poolInfo)->uwPoolSize))
-#define OS_MEM_HEAD(pool, size) OS_DLNK_HEAD(OS_MEM_HEAD_ADDR(pool), size)
-#define OS_MEM_HEAD_ADDR(pool) ((VOID *)((UINT32)(UINTPTR)(pool) + sizeof(LOS_MEM_POOL_INFO)))
-#define OS_MEM_NEXT_NODE(node) ((LosMemDynNode *)((UINT8 *)(node) + \
- OS_MEM_NODE_GET_SIZE((node)->sizeAndFlag)))
-#define OS_MEM_FIRST_NODE(pool) ((LosMemDynNode *)((UINT8 *)OS_MEM_HEAD_ADDR(pool) + OS_DLNK_HEAD_SIZE))
-#define OS_MEM_END_NODE(pool, size) ((LosMemDynNode *)(((UINT8 *)(pool) + (size)) - OS_MEM_NODE_HEAD_SIZE))
-#define OS_MEM_MIDDLE_ADDR_OPEN_END(startAddr, middleAddr, endAddr) \
- (((UINT8 *)(startAddr) <= (UINT8 *)(middleAddr)) && ((UINT8 *)(middleAddr) < (UINT8 *)(endAddr)))
-#define OS_MEM_MIDDLE_ADDR(startAddr, middleAddr, endAddr) (((UINT8 *)(startAddr) <= (UINT8 *)(middleAddr)) && \
- ((UINT8 *)(middleAddr) <= (UINT8 *)(endAddr)))
-#define OS_MEM_SET_MAGIC(value) (value) = (LOS_DL_LIST *)(UINTPTR)((UINT32)(UINTPTR)(&(value)) ^ 0xffffffff)
-#define OS_MEM_MAGIC_VALID(value) ((((UINT32)(UINTPTR)(value)) ^ ((UINT32)(UINTPTR)(&(value)))) == 0xffffffff)
-
-#define OS_MAX_MULTI_DLNK_LOG2 30
-#define OS_MIN_MULTI_DLNK_LOG2 4
-#define OS_MULTI_DLNK_NUM ((OS_MAX_MULTI_DLNK_LOG2 - OS_MIN_MULTI_DLNK_LOG2) + 1)
-#define OS_DLNK_HEAD_SIZE OS_MULTI_DLNK_HEAD_SIZE
-#define OS_DLNK_INIT_HEAD OsDLnkInitMultiHead
-#define OS_DLNK_HEAD OsDLnkMultiHead
-#define OS_DLNK_NEXT_HEAD OsDLnkNextMultiHead
-#define OS_DLNK_FIRST_HEAD OsDLnkFirstMultiHead
-#define OS_MULTI_DLNK_HEAD_SIZE sizeof(LosMultipleDlinkHead)
-
-typedef struct {
- LOS_DL_LIST listHead[OS_MULTI_DLNK_NUM];
-} LosMultipleDlinkHead;
-
-STATIC_INLINE LOS_DL_LIST *OsDLnkNextMultiHead(VOID *headAddr, LOS_DL_LIST *listHead)
-{
- LosMultipleDlinkHead *head = (LosMultipleDlinkHead *)headAddr;
-
- return (&(head->listHead[OS_MULTI_DLNK_NUM - 1]) == listHead) ? NULL : (listHead + 1);
-}
-
-STATIC_INLINE LOS_DL_LIST *OsDLnkFirstMultiHead(VOID *headAddr)
-{
- return (LOS_DL_LIST *)headAddr;
-}
-
-extern VOID OsDLnkInitMultiHead(VOID *headAddr);
-extern LOS_DL_LIST *OsDLnkMultiHead(VOID *headAddr, UINT32 size);
-
-#if (LOSCFG_MEMORY_BESTFIT == YES)
-
-extern VOID OsTaskMemUsedInc(UINT32 usedSize, UINT32 taskID);
-extern VOID OsTaskMemUsedDec(UINT32 usedSize, UINT32 taskID);
-extern UINT32 OsTaskMemUsage(UINT32 taskID);
-extern VOID OsTaskMemClear(UINT32 taskID);
-
-#ifdef OS_MEM_ENABLE_MEM_STATISTICS
-#define OS_MEM_ADD_USED(usedSize, taskID) OsTaskMemUsedInc(usedSize, taskID)
-#define OS_MEM_REDUCE_USED(usedSize, taskID) OsTaskMemUsedDec(usedSize, taskID)
-#define OS_MEM_CLEAR(taskID) OsTaskMemClear(taskID)
-#else
-#define OS_MEM_ADD_USED(usedSize, taskID)
-#define OS_MEM_REDUCE_USED(usedSize, taskID)
-#define OS_MEM_CLEAR(taskID)
-#endif
-
-#else
-
-#if (LOSCFG_KERNEL_MEM_STATISTICS == YES)
-typedef struct {
- UINT32 memUsed;
- UINT32 memPeak;
-} TaskMemUsedInfo;
-
-extern VOID OsTaskMemStatInit(TaskMemUsedInfo *memStats);
-extern VOID OsTaskMemUsedInc(TaskMemUsedInfo *memStats, UINT32 usedSize, UINT32 taskID);
-extern VOID OsTaskMemUsedDec(TaskMemUsedInfo *memStats, UINT32 usedSize, UINT32 taskID);
-extern UINT32 OsTaskMemUsage(TaskMemUsedInfo *memStats, UINT32 taskID);
-extern VOID OsTaskMemClear(TaskMemUsedInfo *memStats, UINT32 taskID);
-#endif
-#endif
-
#ifdef __cplusplus
#if __cplusplus
}
diff --git a/kernel/include/los_mux.h b/kernel/include/los_mux.h
old mode 100755
new mode 100644
diff --git a/kernel/include/los_queue.h b/kernel/include/los_queue.h
old mode 100755
new mode 100644
diff --git a/kernel/include/los_sem.h b/kernel/include/los_sem.h
old mode 100755
new mode 100644
diff --git a/kernel/include/los_swtmr.h b/kernel/include/los_swtmr.h
old mode 100755
new mode 100644
index 0a029643..e38f81f6
--- a/kernel/include/los_swtmr.h
+++ b/kernel/include/los_swtmr.h
@@ -211,7 +211,7 @@ extern "C" {
*/
#define LOS_ERRNO_SWTMR_TICK_PTR_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x10)
-#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == YES)
+#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
#define OS_ERRNO_SWTMR_ROUSES_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x11)
#define OS_ERRNO_SWTMR_ALIGN_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x12)
@@ -269,7 +269,7 @@ typedef struct tagSwTmrCtrl {
struct tagSwTmrCtrl *pstNext; /* Pointer to the next software timer */
UINT8 ucState; /* Software timer state */
UINT8 ucMode; /* Software timer mode */
-#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == YES)
+#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
UINT8 ucRouses; /* wake up enable */
UINT8 ucSensitive; /* align enable */
#endif
@@ -391,7 +391,7 @@ extern UINT32 LOS_SwtmrTimeGet(UINT16 swtmrID, UINT32 *tick);
* los_swtmr.h: the header file that contains the API declaration.
* @see LOS_SwtmrDelete
*/
-#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == YES)
+#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
extern UINT32 LOS_SwtmrCreate(UINT32 interval,
UINT8 mode,
SWTMR_PROC_FUNC handler,
diff --git a/kernel/include/los_task.h b/kernel/include/los_task.h
old mode 100755
new mode 100644
index 52fe294d..28673c44
--- a/kernel/include/los_task.h
+++ b/kernel/include/los_task.h
@@ -500,6 +500,9 @@ extern VOID LOS_Msleep(UINT32 mSecs);
* @see
*/
extern UINT32 LOS_Start(VOID);
+extern VOID LOS_Reboot(VOID);
+extern VOID LOS_Panic(const CHAR *fmt, ...);
+
/**
* @ingroup los_base
@@ -1081,24 +1084,6 @@ extern UINT32 LOS_NewTaskIDGet(VOID);
*/
extern CHAR* LOS_TaskNameGet(UINT32 taskID);
-/* *
- * @ingroup los_hw
- * @brief: Task scheduling Function.
- *
- * @par Description:
- * This API is used to scheduling task.
- *
- * @attention:
- *
- *
- * @param None.
- *
- * @retval: None.
- * @par Dependency:
- * los_hw.h: the header file that contains the API declaration.
- * @see None.
- */
-extern VOID OsSchedule(VOID);
/* *
* @ingroup los_hw
@@ -1676,6 +1661,13 @@ extern LosTask g_losTask;
*/
extern UINT16 g_losTaskLock;
+/* *
+ * @ingroup los_hw
+ * Check task schedule.
+ */
+#define LOS_CHECK_SCHEDULE ((!g_losTaskLock))
+
+
/**
* @ingroup los_task
* Maximum number of tasks.
@@ -1718,12 +1710,6 @@ extern LOS_DL_LIST g_losFreeTask;
*/
extern LOS_DL_LIST g_taskRecyleList;
-/**
- * @ingroup los_task
- * @brief the block status of task
- */
-extern VOID OsTaskSchedule(VOID);
-
/**
* @ingroup los_task
* @brief Modify the priority of task.
@@ -2025,14 +2011,52 @@ extern VOID OsTimerListDelete(LosTaskCB *taskCB);
*/
extern UINT32 OsGetAllTskInfo(VOID);
-
extern VOID *OsTskUserStackInit(VOID* stackPtr, VOID* userSP, UINT32 userStackSize);
-extern VOID *OsTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack);
+/**
+ * @ingroup los_timeslice
+ * @brief Initialize time slices.
+ *
+ * @par Description:
+ *
+ * This API is used to initialize time slices that defines the cycle of time slices according to
+ LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT.
+ *
+ * @attention
+ *
+ *
+ * @param None.
+ *
+ * @retval None.
+ * @par Dependency:
+ * los_timeslice_pri.h: the header file that contains the API declaration.
+ * @see None.
+ */
+extern VOID OsTimesliceInit(VOID);
-extern VOID OsSchedule(VOID);
-
-extern VOID osTaskSchedule(VOID);
+/**
+ * @ingroup los_timeslice
+ * @brief Check time slices.
+ *
+ * @par Description:
+ *
+ * This API is used to check time slices. If the number of Ticks equals to the time for task switch, tasks are switched. Otherwise, the Tick counting continues.
+ *
+ * @attention
+ *
+ *
+ * @param None.
+ *
+ * @retval None.
+ * @par Dependency:
+ * los_timeslice_pri.h: the header file that contains the API declaration.
+ * @see None.
+ */
+extern VOID OsTimesliceCheck(VOID);
#ifdef __cplusplus
#if __cplusplus
diff --git a/kernel/include/los_tick.h b/kernel/include/los_tick.h
old mode 100755
new mode 100644
index b199cf38..36b2f50b
--- a/kernel/include/los_tick.h
+++ b/kernel/include/los_tick.h
@@ -98,44 +98,7 @@ extern "C" {
* */
extern UINT32 LOS_SysClockGet(VOID);
-/**
- * @ingroup los_tickless
- * @brief enable the tickless mode.
- *
- * @par Description:
- * This API is used to enable the tickless mode. System can change from periodic clock mode to dynamic clock mode.
- *
- * @attention
- *
- *
- * @param None.
- *
- * @retval None.
- * @par Dependency:
- * los_tickless.h: the header file that contains the API declaration.
- * @see LOS_TicklessDisable
- */
-extern VOID LOS_TicklessEnable(VOID);
-/**
- * @ingroup los_tickless
- * @brief disable the tickless mode.
- *
- * @par Description:
- * This API is used to diable the tickless mode. System will not change from periodic clock mode to dynamic clock mode.
- *
- * @attention
- *
- *
- * @param None.
- *
- * @retval None.
- * @par Dependency:
- * los_tickless.h: the header file that contains the API declaration.
- * @see LOS_TicklessEnable
- */
-extern VOID LOS_TicklessDisable(VOID);
+
/**
* @ingroup los_sys
@@ -345,77 +308,6 @@ extern UINT32 g_sysClock;
*/
extern VOID OsTickHandler(VOID);
-#if (LOSCFG_KERNEL_TICKLESS == YES)
-LITE_OS_SEC_TEXT VOID OsTickHandlerLoop(UINT32 elapseTicks);
-#endif
-
-/**
- * @ingroup los_tick
- * @brief tick modul init.
- *
- * @par Description:
- * This API is called when the system initializating.
- *
- * @attention
- *
- *
- * @param systemClock [IN] Type #UINT32 SystemClock.
- * @param tickPerSecond [IN] Type #UINT32 TickPerSecond.
- *
- * @retval None.
- * @par Dependency:
- * los_tick_pri.h: the header file that contains the API declaration.
- * @see None.
- */
-extern UINT32 OsTickInit(UINT32 systemClock, UINT32 tickPerSecond);
-
-/**
- * @ingroup los_timeslice
- * @brief Initialize time slices.
- *
- * @par Description:
- *
- * This API is used to initialize time slices that defines the cycle of time slices according to
- LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT.
- *
- * @attention
- *
- *
- * @param None.
- *
- * @retval None.
- * @par Dependency:
- * los_timeslice_pri.h: the header file that contains the API declaration.
- * @see None.
- */
-extern VOID OsTimesliceInit(VOID);
-
-/**
- * @ingroup los_timeslice
- * @brief Check time slices.
- *
- * @par Description:
- *
- * This API is used to check time slices. If the number of Ticks equals to the time for task switch, tasks are switched. Otherwise, the Tick counting continues.
- *
- * @attention
- *
- *
- * @param None.
- *
- * @retval None.
- * @par Dependency:
- * los_timeslice_pri.h: the header file that contains the API declaration.
- * @see None.
- */
-extern VOID OsTimesliceCheck(VOID);
-
/**
* @ingroup los_base
* Define the CPU Tick structure.
diff --git a/kernel/src/los_event.c b/kernel/src/los_event.c
old mode 100755
new mode 100644
diff --git a/kernel/src/los_init.c b/kernel/src/los_init.c
old mode 100755
new mode 100644
index 91e849f0..d5d145db
--- a/kernel/src/los_init.c
+++ b/kernel/src/los_init.c
@@ -30,22 +30,25 @@
*/
#include "los_config.h"
+#include "los_arch.h"
#include "los_queue.h"
#include "los_memory.h"
#include "los_mux.h"
+#include "los_sem.h"
+#include "los_debug.h"
+#include "stdarg.h"
-#if (LOSCFG_PLATFORM_EXC == YES)
+#if (LOSCFG_PLATFORM_HWI == 1)
#include "los_interrupt.h"
#endif
-#if (LOSCFG_KERNEL_TRACE == YES)
+#if (LOSCFG_KERNEL_TRACE == 1)
#include "los_debug.h"
#endif
-#if (LOSCFG_KERNEL_CPPSUPPORT == YES)
-#include "los_cppsupport.h"
+#if (LOSCFG_BASE_CORE_SWTMR == 1)
+#include "los_swtmr.h"
#endif
-#include "los_debug.h"
#ifdef __cplusplus
@@ -56,16 +59,6 @@ extern "C" {
UINT8 *m_aucSysMem0;
-#if (LOSCFG_PLATFORM_EXC == YES)
-UINT8 g_aucTaskArray[MAX_EXC_MEM_SIZE];
-#endif
-#define FPU_ENABLE ((3UL << 20) | (3UL << 22))
-
-VOID OsEnableFPU(VOID)
-{
- *(volatile UINT32 *)0xE000ED88 |= FPU_ENABLE; /* CPACR is located at address 0xE000ED88. */
-}
-
/*****************************************************************************
Function : LOS_Reboot
Description : system exception, die in here, wait for watchdog.
@@ -75,10 +68,19 @@ VOID OsEnableFPU(VOID)
*****************************************************************************/
LITE_OS_SEC_TEXT_INIT VOID LOS_Reboot(VOID)
{
- (VOID)LOS_IntLock();
- while (1) {
- }
+ HalSysExit();
}
+
+LITE_OS_SEC_TEXT_INIT VOID LOS_Panic(const CHAR *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ PRINT_ERR(fmt, ap);
+ va_end(ap);
+ HalSysExit();
+}
+
+
/*****************************************************************************
Function : OsRegister
Description : Configuring the maximum number of tasks
@@ -95,17 +97,7 @@ LITE_OS_SEC_TEXT_INIT static VOID OsRegister(VOID)
LITE_OS_SEC_TEXT_INIT UINT32 LOS_Start(VOID)
{
- UINT32 ret;
-
- ret = OsTickStart();
- if (ret != LOS_OK) {
- PRINT_ERR("OsTickStart error\n");
- return ret;
- }
-
- LOS_StartToRun();
-
- return ret;
+ return HalStartSchedule(OsTickHandler);
}
extern UINT8 g_memStart[OS_SYS_MEM_SIZE];
@@ -131,9 +123,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_KernelInit(VOID)
return ret;
}
-#if (LOSCFG_PLATFORM_HWI == YES)
- OsHwiInit();
-#endif
+ HalArchInit();
ret = OsTaskInit();
if (ret != LOS_OK) {
@@ -141,11 +131,11 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_KernelInit(VOID)
return ret;
}
-#if (LOSCFG_BASE_CORE_TSK_MONITOR == YES)
+#if (LOSCFG_BASE_CORE_TSK_MONITOR == 1)
OsTaskMonInit();
#endif
-#if (LOSCFG_BASE_CORE_CPUP == YES)
+#if (LOSCFG_BASE_CORE_CPUP == 1)
ret = OsCpupInit();
if (ret != LOS_OK) {
PRINT_ERR("OsCpupInit error\n");
@@ -153,21 +143,21 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_KernelInit(VOID)
}
#endif
-#if (LOSCFG_BASE_IPC_SEM == YES)
+#if (LOSCFG_BASE_IPC_SEM == 1)
ret = OsSemInit();
if (ret != LOS_OK) {
return ret;
}
#endif
-#if (LOSCFG_BASE_IPC_MUX == YES)
+#if (LOSCFG_BASE_IPC_MUX == 1)
ret = OsMuxInit();
if (ret != LOS_OK) {
return ret;
}
#endif
-#if (LOSCFG_BASE_IPC_QUEUE == YES)
+#if (LOSCFG_BASE_IPC_QUEUE == 1)
ret = OsQueueInit();
if (ret != LOS_OK) {
PRINT_ERR("OsQueueInit error\n");
@@ -175,7 +165,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_KernelInit(VOID)
}
#endif
-#if (LOSCFG_BASE_CORE_SWTMR == YES)
+#if (LOSCFG_BASE_CORE_SWTMR == 1)
ret = OsSwtmrInit();
if (ret != LOS_OK) {
PRINT_ERR("OsSwtmrInit error\n");
@@ -183,7 +173,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_KernelInit(VOID)
}
#endif
-#if (LOSCFG_BASE_CORE_TIMESLICE == YES)
+#if (LOSCFG_BASE_CORE_TIMESLICE == 1)
OsTimesliceInit();
#endif
@@ -192,7 +182,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_KernelInit(VOID)
return ret;
}
-#if (LOSCFG_KERNEL_TRACE == YES)
+#if (LOSCFG_KERNEL_TRACE == 1)
ret = LOS_TraceInit();
if (ret != LOS_OK) {
PRINT_ERR("LOS_TraceInit error\n");
@@ -200,10 +190,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_KernelInit(VOID)
}
#endif
-#if (LOSCFG_KERNEL_CPPSUPPORT == YES)
- extern char __init_array_start,__init_array_end;
- LOS_CppSystemInit((UINTPTR)&__init_array_start,(UINTPTR)&__init_array_end);
-#endif
#ifdef LOSCFG_TEST
//ret = los_TestInit();
//if (ret != LOS_OK) {
diff --git a/kernel/src/los_mux.c b/kernel/src/los_mux.c
old mode 100755
new mode 100644
index 71839860..b0395f98
--- a/kernel/src/los_mux.c
+++ b/kernel/src/los_mux.c
@@ -28,8 +28,10 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "los_mux.h"
+#include "los_config.h"
#include "los_interrupt.h"
+#include "los_arch.h"
+#include "los_mux.h"
#include "los_memory.h"
#include "los_debug.h"
@@ -39,7 +41,7 @@ extern "C" {
#endif
#endif /* __cplusplus */
-#if (LOSCFG_BASE_IPC_MUX == YES)
+#if (LOSCFG_BASE_IPC_MUX == 1)
LITE_OS_SEC_BSS LosMuxCB* g_allMux = NULL;
LITE_OS_SEC_DATA_INIT LOS_DL_LIST g_unusedMuxList;
@@ -168,8 +170,8 @@ STATIC_INLINE UINT32 OsMuxValidCheck(LosMuxCB *muxPended)
if (g_losTaskLock) {
PRINT_ERR("!!!LOS_ERRNO_MUX_PEND_IN_LOCK!!!\n");
-#if (LOSCFG_PLATFORM_EXC == YES)
- OsBackTrace();
+#if (LOSCFG_PLATFORM_EXC == 1)
+ LOS_BackTrace();
#endif
return LOS_ERRNO_MUX_PEND_IN_LOCK;
}
@@ -303,7 +305,7 @@ LITE_OS_SEC_TEXT UINT32 LOS_MuxPost(UINT32 muxHandle)
return LOS_OK;
}
-#endif /* (LOSCFG_BASE_IPC_MUX == YES) */
+#endif /* (LOSCFG_BASE_IPC_MUX == 1) */
#ifdef __cplusplus
#if __cplusplus
diff --git a/kernel/src/los_queue.c b/kernel/src/los_queue.c
old mode 100755
new mode 100644
index e78edaf1..97bffaf0
--- a/kernel/src/los_queue.c
+++ b/kernel/src/los_queue.c
@@ -28,12 +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_interrupt.h"
-#include "securec.h"
+#include "los_config.h"
#include "los_queue.h"
+#include "securec.h"
#include "los_membox.h"
#include "los_task.h"
-#if (LOSCFG_PLATFORM_EXC == YES)
+#include "los_memory.h"
+#if (LOSCFG_PLATFORM_EXC == 1)
#include "los_interrupt.h"
#endif
#include "los_debug.h"
@@ -45,11 +46,11 @@ extern "C" {
#endif
#endif /* __cplusplus */
-#if (LOSCFG_BASE_IPC_QUEUE == YES)
+#if (LOSCFG_BASE_IPC_QUEUE == 1)
LITE_OS_SEC_BSS LosQueueCB *g_allQueue = NULL ;
LITE_OS_SEC_BSS LOS_DL_LIST g_freeQueueList;
-#if (LOSCFG_PLATFORM_EXC == YES)
+#if (LOSCFG_PLATFORM_EXC == 1)
LITE_OS_SEC_BSS UINT32 g_excQueueMaxNum;
#endif
@@ -84,9 +85,9 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsQueueInit(VOID)
LOS_ListTailInsert(&g_freeQueueList, &queueNode->readWriteList[OS_QUEUE_WRITE]);
}
-#if (LOSCFG_PLATFORM_EXC == YES)
+#if (LOSCFG_PLATFORM_EXC == 1)
g_excQueueMaxNum = LOSCFG_BASE_IPC_QUEUE_LIMIT;
- OsExcRegister(OS_EXC_TYPE_QUE, (EXC_INFO_SAVE_CALLBACK)LOS_QueueInfoGet, &g_excQueueMaxNum);
+ HalExcRegister(OS_EXC_TYPE_QUE, (EXC_INFO_SAVE_CALLBACK)LOS_QueueInfoGet, &g_excQueueMaxNum);
#endif
return LOS_OK;
@@ -670,7 +671,7 @@ QUEUE_END:
return ret;
}
-#endif /* (LOSCFG_BASE_IPC_QUEUE == YES) */
+#endif /* (LOSCFG_BASE_IPC_QUEUE == 1) */
#ifdef __cplusplus
#if __cplusplus
diff --git a/kernel/src/los_sem.c b/kernel/src/los_sem.c
old mode 100755
new mode 100644
index 653d0108..b1eacbc3
--- a/kernel/src/los_sem.c
+++ b/kernel/src/los_sem.c
@@ -28,9 +28,11 @@
* 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_arch.h"
#include "los_sem.h"
#include "los_memory.h"
-#if (LOSCFG_PLATFORM_EXC == YES)
+#if (LOSCFG_PLATFORM_EXC == 1)
#include "los_interrupt.h"
#endif
#include "los_debug.h"
@@ -41,7 +43,7 @@ extern "C" {
#endif
#endif /* __cplusplus */
-#if (LOSCFG_BASE_IPC_SEM == YES)
+#if (LOSCFG_BASE_IPC_SEM == 1)
LITE_OS_SEC_DATA_INIT LOS_DL_LIST g_unusedSemList;
LITE_OS_SEC_BSS LosSemCB *g_allSem = NULL;
@@ -195,16 +197,16 @@ STATIC_INLINE UINT32 OsSemValidCheck(LosSemCB *semPended)
if (OS_INT_ACTIVE) {
PRINT_ERR("!!!LOS_ERRNO_SEM_PEND_INTERR!!!\n");
-#if (LOSCFG_PLATFORM_EXC == YES)
- OsBackTrace();
+#if (LOSCFG_PLATFORM_EXC == 1)
+ LOS_BackTrace();
#endif
return LOS_ERRNO_SEM_PEND_INTERR;
}
if (g_losTaskLock) {
PRINT_ERR("!!!LOS_ERRNO_SEM_PEND_IN_LOCK!!!\n");
-#if (LOSCFG_PLATFORM_EXC == YES)
- OsBackTrace();
+#if (LOSCFG_PLATFORM_EXC == 1)
+ LOS_BackTrace();
#endif
return LOS_ERRNO_SEM_PEND_IN_LOCK;
}
@@ -313,7 +315,7 @@ LITE_OS_SEC_TEXT UINT32 LOS_SemPost(UINT32 semHandle)
return LOS_OK;
}
-#endif /* (LOSCFG_BASE_IPC_SEM == YES) */
+#endif /* (LOSCFG_BASE_IPC_SEM == 1) */
#ifdef __cplusplus
#if __cplusplus
diff --git a/kernel/src/los_swtmr.c b/kernel/src/los_swtmr.c
old mode 100755
new mode 100644
index f394a1a0..f0f867fa
--- a/kernel/src/los_swtmr.c
+++ b/kernel/src/los_swtmr.c
@@ -28,6 +28,7 @@
* 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 "securec.h"
#include "los_interrupt.h"
#include "los_swtmr.h"
@@ -42,14 +43,14 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
-#if (LOSCFG_BASE_CORE_SWTMR == YES)
+#if (LOSCFG_BASE_CORE_SWTMR == 1)
LITE_OS_SEC_BSS UINT32 g_swtmrHandlerQueue; /* Software Timer timeout queue ID */
LITE_OS_SEC_BSS SWTMR_CTRL_S *g_swtmrCBArray = NULL; /* first address in Timer memory space */
LITE_OS_SEC_BSS SWTMR_CTRL_S *g_swtmrFreeList = NULL; /* Free list of Softwaer Timer */
LITE_OS_SEC_BSS SWTMR_CTRL_S *g_swtmrSortList = NULL; /* The software timer count list */
-#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == YES)
+#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
typedef struct SwtmrAlignDataStr {
UINT32 times : 24;
UINT32 : 5;
@@ -139,7 +140,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsSwtmrInit(VOID)
SWTMR_CTRL_S *swtmr = NULL;
SWTMR_CTRL_S *temp = NULL;
-#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == YES)
+#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
// Ignore the return code when matching CSEC rule 6.6(1).
(VOID)memset_s((VOID *)g_swtmrAlignID, sizeof(SwtmrAlignData) * LOSCFG_BASE_CORE_SWTMR_LIMIT,
0, sizeof(SwtmrAlignData) * LOSCFG_BASE_CORE_SWTMR_LIMIT);
@@ -180,7 +181,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsSwtmrInit(VOID)
return LOS_OK;
}
-#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == YES)
+#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
STATIC_INLINE UINT32 OsSwtmrCalcAlignCount(UINT32 interval, UINT16 timerId)
{
SWTMR_CTRL_S *cur = g_swtmrSortList;
@@ -269,7 +270,7 @@ LITE_OS_SEC_TEXT VOID OsSwtmrStart(SWTMR_CTRL_S *swtmr)
swtmr->uwCount = swtmr->uwInterval;
-#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == YES)
+#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
if ((g_swtmrAlignID[swtmr->usTimerID % LOSCFG_BASE_CORE_SWTMR_LIMIT].canAlign == 1) &&
(g_swtmrAlignID[swtmr->usTimerID % LOSCFG_BASE_CORE_SWTMR_LIMIT].isAligned == 0)) {
g_swtmrAlignID[swtmr->usTimerID % LOSCFG_BASE_CORE_SWTMR_LIMIT].isAligned = 1;
@@ -312,7 +313,7 @@ STATIC_INLINE VOID OsSwtmrDelete(SWTMR_CTRL_S *swtmr)
g_swtmrFreeList = swtmr;
swtmr->ucState = OS_SWTMR_STATUS_UNUSED;
-#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == YES)
+#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
(VOID)memset_s((VOID *)&g_swtmrAlignID[swtmr->usTimerID % LOSCFG_BASE_CORE_SWTMR_LIMIT],
sizeof(SwtmrAlignData), 0, sizeof(SwtmrAlignData));
#endif
@@ -350,7 +351,7 @@ LITE_OS_SEC_TEXT VOID OsSwtmrStop(const SWTMR_CTRL_S *swtmr)
cur->pstNext = (SWTMR_CTRL_S *)NULL;
cur->ucState = OS_SWTMR_STATUS_CREATED;
-#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == YES)
+#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
g_swtmrAlignID[swtmr->usTimerID % LOSCFG_BASE_CORE_SWTMR_LIMIT].isAligned = 0;
#endif
}
@@ -415,7 +416,7 @@ Input : None
Output : None
Return : Count of the Timer list
*****************************************************************************/
-#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == YES)
+#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
LITE_OS_SEC_TEXT UINT32 OsSwtmrGetNextTimeout(VOID)
{
SWTMR_CTRL_S *cur = NULL;
@@ -464,7 +465,7 @@ Input : **head, *swtmr
Output : **head, *swtmr
Return : None
*****************************************************************************/
-#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == YES)
+#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
VOID OsSwtimerInsert(SWTMR_CTRL_S **head, SWTMR_CTRL_S *swtmr)
{
SWTMR_CTRL_S *prev = NULL;
@@ -507,7 +508,7 @@ Input : sleepTime
Output : None
Return : None
*****************************************************************************/
-#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == YES)
+#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
LITE_OS_SEC_TEXT VOID OsSwtmrAdjust(UINT32 sleepTime)
{
SWTMR_CTRL_S *cur = NULL;
@@ -595,7 +596,7 @@ Input : interval
Output : swtmrId
Return : LOS_OK on success or error code on failure
*****************************************************************************/
-#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == YES)
+#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
LITE_OS_SEC_TEXT_INIT UINT32 LOS_SwtmrCreate(UINT32 interval,
UINT8 mode,
SWTMR_PROC_FUNC handler,
@@ -632,7 +633,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_SwtmrCreate(UINT32 interval,
return LOS_ERRNO_SWTMR_RET_PTR_NULL;
}
-#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == YES)
+#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
if ((rouses != OS_SWTMR_ROUSES_IGNORE) && (rouses != OS_SWTMR_ROUSES_ALLOW)) {
return OS_ERRNO_SWTMR_ROUSES_INVALID;
}
@@ -657,7 +658,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_SwtmrCreate(UINT32 interval,
swtmr->pstNext = (SWTMR_CTRL_S *)NULL;
swtmr->uwCount = 0;
swtmr->uwArg = arg;
-#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == YES)
+#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
swtmr->ucRouses = rouses;
swtmr->ucSensitive = sensitive;
#endif
@@ -678,7 +679,7 @@ LITE_OS_SEC_TEXT UINT32 LOS_SwtmrStart(UINT16 swtmrId)
{
SWTMR_CTRL_S *swtmr = NULL;
UINTPTR intSave;
-#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == YES)
+#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
UINT32 times;
UINT32 swtmrAlignIdIndex = 0;
#endif
@@ -696,7 +697,7 @@ LITE_OS_SEC_TEXT UINT32 LOS_SwtmrStart(UINT16 swtmrId)
return LOS_ERRNO_SWTMR_ID_INVALID;
}
-#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == YES)
+#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
if ((swtmr->ucSensitive == OS_SWTMR_ALIGN_INSENSITIVE) && (swtmr->ucMode == LOS_SWTMR_MODE_PERIOD)) {
swtmrAlignIdIndex = swtmr->usTimerID % LOSCFG_BASE_CORE_SWTMR_LIMIT;
g_swtmrAlignID[swtmrAlignIdIndex].canAlign = 1;
@@ -856,7 +857,7 @@ LITE_OS_SEC_TEXT UINT32 LOS_SwtmrDelete(UINT16 swtmrId)
return ret;
}
-#endif /* (LOSCFG_BASE_CORE_SWTMR == YES) */
+#endif /* (LOSCFG_BASE_CORE_SWTMR == 1) */
#ifdef __cplusplus
diff --git a/kernel/src/los_task.c b/kernel/src/los_task.c
old mode 100755
new mode 100644
index 53e55c38..1a370bf0
--- a/kernel/src/los_task.c
+++ b/kernel/src/los_task.c
@@ -33,21 +33,13 @@
#include "los_sem.h"
#include "los_mux.h"
#include "los_memory.h"
-#if (LOSCFG_PLATFORM_EXC == YES)
+#include "los_timer.h"
#include "los_interrupt.h"
-#endif
-#if (LOSCFG_KERNEL_TICKLESS == YES)
-#include "los_tick.h"
-#endif
-#if (LOSCFG_BASE_CORE_CPUP == YES)
+#if (LOSCFG_BASE_CORE_CPUP == 1)
#include "los_cpup.h"
#endif
+#include "los_debug.h"
-#if (LOSCFG_KERNEL_TRACE == YES)
-#include "los_debug.h"
-#endif
-//#include "los_sleep.h"
-#include "los_debug.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
@@ -119,13 +111,11 @@ LITE_OS_SEC_DATA_INIT LOS_DL_LIST g_taskRecyleList;
LITE_OS_SEC_BSS TaskSortLinkAttr g_taskSortLink;
LITE_OS_SEC_BSS BOOL g_taskScheduled = FALSE;
-#if (LOSCFG_BASE_CORE_TSK_MONITOR == YES)
-
-TSKSWITCHHOOK g_taskSwitchHook = NULL;
+#if (LOSCFG_BASE_CORE_TSK_MONITOR == 1)
TSKSWITCHHOOK g_pfnUsrTskSwitchHook = NULL;
-#endif /* LOSCFG_BASE_CORE_TSK_MONITOR == YES */
+#endif /* LOSCFG_BASE_CORE_TSK_MONITOR == 1 */
-#if (LOSCFG_BASE_CORE_EXC_TSK_SWITCH == YES)
+#if (LOSCFG_BASE_CORE_EXC_TSK_SWITCH == 1)
TaskSwitchInfo g_taskSwitchInfo;
#endif
@@ -203,30 +193,21 @@ STATIC_INLINE UINT32 OsCheckTaskIDValid(UINT32 taskID)
return ret;
}
-#if (LOSCFG_KERNEL_TICKLESS == YES)
-UINT32 OsTaskNextSwitchTimeGet(VOID)
+STATIC VOID OsRecyleFinishedTask(VOID)
{
LosTaskCB *taskCB = NULL;
- UINT32 taskSortLinkTick = 0;
- LOS_DL_LIST *listObject = NULL;
- UINT32 tempTicks = 0;
- UINT32 index;
+ UINTPTR intSave;
- for (index = 0; index < OS_TSK_SORTLINK_LEN; index++) {
- listObject = g_taskSortLink.sortLink + ((g_taskSortLink.cursor + index) % OS_TSK_SORTLINK_LEN);
- if (listObject->pstNext != listObject) {
- taskCB = LOS_DL_LIST_ENTRY((listObject)->pstNext, LosTaskCB, timerList);
- tempTicks = (index == 0) ? OS_TSK_SORTLINK_LEN : index;
- tempTicks += (UINT32)(UWROLLNUM(taskCB->idxRollNum) * OS_TSK_SORTLINK_LEN);
- if ((taskSortLinkTick == 0) || (taskSortLinkTick > tempTicks)) {
- taskSortLinkTick = tempTicks;
- }
- }
+ intSave = LOS_IntLock();
+ while (!LOS_ListEmpty(&g_taskRecyleList)) {
+ taskCB = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&g_taskRecyleList));
+ LOS_ListDelete(LOS_DL_LIST_FIRST(&g_taskRecyleList));
+ LOS_ListAdd(&g_losFreeTask, &taskCB->pendList);
+ (VOID)LOS_MemFree(OS_TASK_STACK_ADDR, (VOID *)(UINTPTR)taskCB->topOfStack);
+ taskCB->topOfStack = (UINT32)NULL;
}
-
- return taskSortLinkTick;
+ LOS_IntRestore(intSave);
}
-#endif
/*****************************************************************************
Function : OsIdleTask
@@ -238,14 +219,9 @@ UINT32 OsTaskNextSwitchTimeGet(VOID)
LITE_OS_SEC_TEXT WEAK VOID OsIdleTask(VOID)
{
while (1) {
-#if (LOSCFG_KERNEL_TICKLESS == YES)
- if (g_tickIrqFlag) {
- g_tickIrqFlag = 0;
- OsTicklessStart();
- }
-#endif
+ OsRecyleFinishedTask();
#if (LOSCFG_KERNEL_RUNSTOP == YES)
- LOS_EnterSleep(OS_SYS_NORMAL_SLEEP);
+ HalEnterSleep(OS_SYS_NORMAL_SLEEP);
#endif
}
}
@@ -445,7 +421,7 @@ UINT32 OsGetTaskWaterLine(UINT32 taskID)
return peakUsed;
}
-#if (LOSCFG_BASE_CORE_CPUP == YES)
+#if (LOSCFG_BASE_CORE_CPUP == 1)
LITE_OS_SEC_TEXT_MINOR UINT32 OsGetAllTskCpupInfo(CPUP_INFO_S **cpuLessOneSec,
CPUP_INFO_S **cpuTenSec,
CPUP_INFO_S **cpuOneSec)
@@ -498,13 +474,13 @@ LITE_OS_SEC_TEXT_MINOR VOID OsPrintAllTskInfoHeader()
{
PRINT_ERR("\r\nName TID Priority Status "
"StackSize WaterLine StackPoint TopOfStack EventMask SemID");
-#if (LOSCFG_BASE_CORE_CPUP == YES)
+#if (LOSCFG_BASE_CORE_CPUP == 1)
PRINT_ERR(" CPUUSE CPUUSE10s CPUUSE1s ");
#endif /* LOSCFG_BASE_CORE_CPUP */
PRINT_ERR("\n");
PRINT_ERR("---- --- -------- -------- ");
PRINT_ERR("--------- ---------- ---------- ---------- --------- -----");
-#if (LOSCFG_BASE_CORE_CPUP == YES)
+#if (LOSCFG_BASE_CORE_CPUP == 1)
PRINT_ERR(" ------- --------- ---------");
#endif /* LOSCFG_BASE_CORE_CPUP */
PRINT_ERR("\n");
@@ -522,13 +498,13 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OsGetAllTskInfo(VOID)
LosTaskCB *taskCB = (LosTaskCB *)NULL;
UINT32 loopNum;
UINT32 semID;
-#if (LOSCFG_BASE_CORE_CPUP == YES)
+#if (LOSCFG_BASE_CORE_CPUP == 1)
CPUP_INFO_S *cpuLessOneSec = (CPUP_INFO_S *)NULL;
CPUP_INFO_S *cpuTenSec = (CPUP_INFO_S *)NULL;
CPUP_INFO_S *cpuOneSec = (CPUP_INFO_S *)NULL;
#endif
-#if (LOSCFG_BASE_CORE_CPUP == YES)
+#if (LOSCFG_BASE_CORE_CPUP == 1)
if (OsGetAllTskCpupInfo(&cpuLessOneSec, &cpuTenSec, &cpuOneSec) != LOS_OK) {
return OS_ERROR;
}
@@ -536,7 +512,7 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OsGetAllTskInfo(VOID)
OsPrintAllTskInfoHeader();
-#if (LOSCFG_EXC_HRADWARE_STACK_PROTECTION == YES)
+#if (LOSCFG_EXC_HRADWARE_STACK_PROTECTION == 1)
UINT32 flag = osStackProtDisable();
#endif
@@ -554,7 +530,7 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OsGetAllTskInfo(VOID)
semID = (taskCB->taskSem == NULL) ? OS_NULL_SHORT : (((LosSemCB *)taskCB->taskSem)->semID);
PRINT_ERR("0x%-7x", semID);
-#if (LOSCFG_BASE_CORE_CPUP == YES)
+#if (LOSCFG_BASE_CORE_CPUP == 1)
PRINT_ERR("%2d.%-7d%2d.%-9d%2d.%-6d",
cpuLessOneSec[taskCB->taskID].uwUsage / LOS_CPUP_PRECISION_MULT,
cpuLessOneSec[taskCB->taskID].uwUsage % LOS_CPUP_PRECISION_MULT,
@@ -566,11 +542,11 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OsGetAllTskInfo(VOID)
PRINT_ERR("\n");
}
-#if (LOSCFG_EXC_HRADWARE_STACK_PROTECTION == YES)
+#if (LOSCFG_EXC_HRADWARE_STACK_PROTECTION == 1)
osStackProtRestore(flag);
#endif
-#if (LOSCFG_BASE_CORE_CPUP == YES)
+#if (LOSCFG_BASE_CORE_CPUP == 1)
(VOID)LOS_MemFree((VOID *)OS_SYS_MEM_ADDR, cpuLessOneSec);
(VOID)LOS_MemFree((VOID *)OS_SYS_MEM_ADDR, cpuTenSec);
(VOID)LOS_MemFree((VOID *)OS_SYS_MEM_ADDR, cpuOneSec);
@@ -636,8 +612,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsTaskInit(VOID)
LOS_ListInit(listObject);
}
-#if (LOSCFG_PLATFORM_EXC == YES)
- OsExcRegister((ExcInfoType)OS_EXC_TYPE_TSK, (EXC_INFO_SAVE_CALLBACK)LOS_TaskInfoGet, &g_taskMaxNum);
+#if (LOSCFG_PLATFORM_EXC == 1)
+ HalExcRegister((ExcInfoType)OS_EXC_TYPE_TSK, (EXC_INFO_SAVE_CALLBACK)LOS_TaskInfoGet, &g_taskMaxNum);
#endif
return LOS_OK;
}
@@ -724,10 +700,10 @@ LITE_OS_SEC_TEXT CHAR *LOS_CurTaskNameGet(VOID)
Output : None
Return : None
*****************************************************************************/
-#if (LOSCFG_BASE_CORE_TSK_MONITOR == YES)
+#if (LOSCFG_BASE_CORE_TSK_MONITOR == 1)
LITE_OS_SEC_TEXT VOID OsTaskSwitchCheck(VOID)
{
-#if (LOSCFG_EXC_HRADWARE_STACK_PROTECTION == NO)
+#if (LOSCFG_EXC_HRADWARE_STACK_PROTECTION == 0)
UINT32 endOfStack = g_losTask.newTask->topOfStack + g_losTask.newTask->stackSize;
if ((*(UINT32 *)(UINTPTR)(g_losTask.runTask->topOfStack)) != OS_TASK_MAGIC_WORD) {
@@ -743,7 +719,7 @@ LITE_OS_SEC_TEXT VOID OsTaskSwitchCheck(VOID)
}
#endif
-#if (LOSCFG_BASE_CORE_EXC_TSK_SWITCH == YES)
+#if (LOSCFG_BASE_CORE_EXC_TSK_SWITCH == 1)
/* record task switch info */
g_taskSwitchInfo.pid[g_taskSwitchInfo.idx] = (UINT16)(g_losTask.newTask->taskID);
@@ -764,28 +740,27 @@ LITE_OS_SEC_TEXT VOID OsTaskSwitchCheck(VOID)
g_pfnUsrTskSwitchHook();
}
-#if (LOSCFG_KERNEL_TRACE == YES)
+#if (LOSCFG_KERNEL_TRACE == 1)
LOS_Trace(LOS_TRACE_SWITCH, 0);
#endif
-#if (LOSCFG_BASE_CORE_CPUP == YES)
+#if (LOSCFG_BASE_CORE_CPUP == 1)
OsTskCycleEndStart();
#endif /* LOSCFG_BASE_CORE_CPUP */
}
LITE_OS_SEC_TEXT_MINOR VOID OsTaskMonInit(VOID)
{
-#if (LOSCFG_BASE_CORE_EXC_TSK_SWITCH == YES)
+#if (LOSCFG_BASE_CORE_EXC_TSK_SWITCH == 1)
// Ignore the return code when matching CSEC rule 6.6(4).
(VOID)memset_s(&g_taskSwitchInfo, sizeof(TaskSwitchInfo), 0, sizeof(TaskSwitchInfo));
g_taskSwitchInfo.cntInfo.maxCnt = OS_TASK_SWITCH_INFO_COUNT;
-#if (LOSCFG_PLATFORM_EXC == YES)
- OsExcRegister((ExcInfoType)OS_EXC_TYPE_TSK_SWITCH,
+#if (LOSCFG_PLATFORM_EXC == 1)
+ HalExcRegister((ExcInfoType)OS_EXC_TYPE_TSK_SWITCH,
(EXC_INFO_SAVE_CALLBACK)LOS_TaskSwitchInfoGet,
&g_taskSwitchInfo);
#endif
#endif
- g_taskSwitchHook = OsTaskSwitchCheck;
g_pfnUsrTskSwitchHook = NULL;
return;
}
@@ -855,10 +830,7 @@ LITE_OS_SEC_TEXT_INIT STATIC_INLINE UINT32 OsTaskInitParamCheck(TSK_INIT_PARAM_S
LITE_OS_SEC_TEXT_INIT UINT32 OsNewTaskInit(LosTaskCB *taskCB, TSK_INIT_PARAM_S *taskInitParam, VOID *topOfStack)
{
- VOID *stackPtr = NULL;
-
- stackPtr = OsTskStackInit(taskCB->taskID, taskInitParam->uwStackSize, topOfStack);
- taskCB->stackPointer = stackPtr;
+ taskCB->stackPointer = HalTskStackInit(taskCB->taskID, taskInitParam->uwStackSize, topOfStack);
taskCB->arg = taskInitParam->uwArg;
taskCB->topOfStack = (UINT32)(UINTPTR)topOfStack;
taskCB->stackSize = taskInitParam->uwStackSize;
@@ -871,7 +843,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsNewTaskInit(LosTaskCB *taskCB, TSK_INIT_PARAM_S *
taskCB->eventMask = 0;
taskCB->taskName = taskInitParam->pcName;
taskCB->msg = NULL;
-
return LOS_OK;
}
@@ -898,15 +869,9 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskCreateOnly(UINT32 *taskID, TSK_INIT_PARAM_S
return retVal;
}
- intSave = LOS_IntLock();
- while (!LOS_ListEmpty(&g_taskRecyleList)) {
- taskCB = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&g_taskRecyleList));
- LOS_ListDelete(LOS_DL_LIST_FIRST(&g_taskRecyleList));
- LOS_ListAdd(&g_losFreeTask, &taskCB->pendList);
- (VOID)LOS_MemFree(OS_TASK_STACK_ADDR, (VOID *)(UINTPTR)taskCB->topOfStack);
- taskCB->topOfStack = (UINT32)NULL;
- }
+ OsRecyleFinishedTask();
+ intSave = LOS_IntLock();
if (LOS_ListEmpty(&g_losFreeTask)) {
retVal = LOS_ERRNO_TSK_TCB_UNAVAILABLE;
OS_GOTO_ERREND();
@@ -939,6 +904,20 @@ LOS_ERREND:
return retVal;
}
+/* ****************************************************************************
+ Function : OsTaskSchedule
+ Description : Function to check task schedule and do real task schedule.
+ Input : None
+ Output : None
+ Return : None
+ **************************************************************************** */
+VOID OsTaskSchedule(VOID)
+{
+#if (LOSCFG_BASE_CORE_TSK_MONITOR == 1)
+ OsTaskSwitchCheck();
+#endif
+ HalTaskSchedule();
+}
/*****************************************************************************
Function : LOS_TaskCreate
@@ -963,7 +942,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskCreate(UINT32 *taskID, TSK_INIT_PARAM_S *ta
taskCB->taskStatus &= (~OS_TASK_STATUS_SUSPEND);
taskCB->taskStatus |= OS_TASK_STATUS_READY;
-#if (LOSCFG_BASE_CORE_CPUP == YES)
+#if (LOSCFG_BASE_CORE_CPUP == 1)
g_cpup[taskCB->taskID].cpupID = taskCB->taskID;
g_cpup[taskCB->taskID].status = taskCB->taskStatus;
#endif
@@ -975,7 +954,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskCreate(UINT32 *taskID, TSK_INIT_PARAM_S *ta
if (g_losTask.runTask != g_losTask.newTask) {
if (LOS_CHECK_SCHEDULE) {
LOS_IntRestore(intSave);
- OsSchedule();
+ OsTaskSchedule();
return LOS_OK;
}
}
@@ -1146,7 +1125,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskDelete(UINT32 taskID)
taskCB->taskStatus |= OS_TASK_STATUS_UNUSED;
taskCB->event.uwEventID = OS_NULL_INT;
taskCB->eventMask = 0;
-#if (LOSCFG_BASE_CORE_CPUP == YES)
+#if (LOSCFG_BASE_CORE_CPUP == 1)
// Ignore the return code when matching CSEC rule 6.6(4).
(VOID)memset_s((VOID *)&g_cpup[taskCB->taskID], sizeof(OsCpupCB), 0, sizeof(OsCpupCB));
#endif
@@ -1155,7 +1134,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskDelete(UINT32 taskID)
OsRunningTaskDelete(taskID, taskCB);
taskCB->taskStatus = OS_TASK_STATUS_UNUSED;
LOS_IntRestore(intSave);
- OsSchedule();
+ OsTaskSchedule();
return LOS_OK;
} else {
taskCB->taskStatus = OS_TASK_STATUS_UNUSED;
@@ -1412,7 +1391,7 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_TaskInfoGet(UINT32 taskID, TSK_INFO_S *taskInf
{
UINT32 intSave;
LosTaskCB *taskCB = NULL;
-#if (LOSCFG_EXC_HRADWARE_STACK_PROTECTION == YES)
+#if (LOSCFG_EXC_HRADWARE_STACK_PROTECTION == 1)
UINT32 flag;
#endif
@@ -1454,14 +1433,14 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_TaskInfoGet(UINT32 taskID, TSK_INFO_S *taskInf
OS_TASK_STACK_ADDR_ALIGN);
taskInfo->uwCurrUsed = taskInfo->uwBottomOfStack - taskInfo->uwSP;
-#if (LOSCFG_EXC_HRADWARE_STACK_PROTECTION == YES)
+#if (LOSCFG_EXC_HRADWARE_STACK_PROTECTION == 1)
flag = osStackProtDisable();
#endif
taskInfo->uwPeakUsed = OsGetTaskWaterLine(taskID);
taskInfo->bOvf = (taskInfo->uwPeakUsed == OS_NULL_INT) ? TRUE : FALSE;
-#if (LOSCFG_EXC_HRADWARE_STACK_PROTECTION == YES)
+#if (LOSCFG_EXC_HRADWARE_STACK_PROTECTION == 1)
osStackProtRestore(flag);
#endif
@@ -1498,7 +1477,7 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_TaskStatusGet(UINT32 taskID, UINT32 *taskStatu
return LOS_OK;
}
-#if (LOSCFG_BASE_CORE_EXC_TSK_SWITCH == YES)
+#if (LOSCFG_BASE_CORE_EXC_TSK_SWITCH == 1)
LITE_OS_SEC_TEXT_MINOR UINT32 LOS_TaskSwitchInfoGet(UINT32 index, UINT32 *taskSwitchInfo)
{
UINTPTR intSave;
@@ -1598,50 +1577,31 @@ LITE_OS_SEC_TEXT CHAR* LOS_TaskNameGet(UINT32 taskID)
}
/* ****************************************************************************
- Function : OsSchedule
- Description : task scheduling
- Input : None
- Output : None
- Return : None
- **************************************************************************** */
-VOID OsSchedule(VOID)
-{
- osTaskSchedule();
-}
-
-/* ****************************************************************************
- Function : LOS_Schedule
+ Function : LOS_Schedule
Description : Function to determine whether task scheduling is required.
- Input : None
- Output : None
- Return : None
+ Input : None
+ Output : None
+ Return : None
**************************************************************************** */
VOID LOS_Schedule(VOID)
{
- UINTPTR intSave;
+ UINTPTR intSave;
- intSave = LOS_IntLock();
-
- /* Find the highest task */
- g_losTask.newTask = LOS_DL_LIST_ENTRY(OsPriqueueTop(), LosTaskCB, pendList);
-
- /* In case that running is not highest then reschedule */
- if (g_losTask.runTask != g_losTask.newTask) {
- if (LOS_CHECK_SCHEDULE) {
- LOS_IntRestore(intSave);
-
- osTaskSchedule();
-
- return;
- }
- }
-
- LOS_IntRestore(intSave);
+ intSave = LOS_IntLock();
+ /* Find the highest task */
+ g_losTask.newTask = LOS_DL_LIST_ENTRY(OsPriqueueTop(), LosTaskCB, pendList);
+ /* In case that running is not highest then reschedule */
+ if (g_losTask.runTask != g_losTask.newTask) {
+ if (LOS_CHECK_SCHEDULE) {
+ LOS_IntRestore(intSave);
+ OsTaskSchedule();
+ return;
+ }
+ }
+ LOS_IntRestore(intSave);
}
-
-
-#if (LOSCFG_BASE_CORE_TIMESLICE == YES)
+#if (LOSCFG_BASE_CORE_TIMESLICE == 1)
LITE_OS_SEC_BSS OsTaskRobin g_taskTimeSlice;
/*****************************************************************************
diff --git a/kernel/src/los_tick.c b/kernel/src/los_tick.c
old mode 100755
new mode 100644
index 20188758..df5761f1
--- a/kernel/src/los_tick.c
+++ b/kernel/src/los_tick.c
@@ -30,9 +30,9 @@
*/
#include "los_tick.h"
-#include "los_config.h"
#include "los_task.h"
#include "los_swtmr.h"
+#include "los_config.h"
#ifdef __cplusplus
#if __cplusplus
@@ -46,57 +46,25 @@ LITE_OS_SEC_BSS UINT32 g_uwCyclePerSec;
LITE_OS_SEC_BSS UINT32 g_cyclesPerTick;
LITE_OS_SEC_BSS UINT32 g_sysClock;
-#if (LOSCFG_BASE_CORE_TICK_HW_TIME == YES)
+#if (LOSCFG_BASE_CORE_TICK_HW_TIME == 1)
extern VOID platform_tick_handler(VOID);
#endif
-#if (LOSCFG_KERNEL_TICKLESS == YES)
-LITE_OS_SEC_TEXT VOID OsTickHandlerLoop(UINT32 elapseTicks)
-{
- UINT32 index;
-
- for (index = 0; index < elapseTicks; index++) {
-#if (LOSCFG_BASE_CORE_TICK_HW_TIME == YES)
- platform_tick_handler();
-#endif
-
- g_ullTickCount++;
-
-#if (LOSCFG_BASE_CORE_TIMESLICE == YES)
- OsTimesliceCheck();
-#endif
- OsTaskScan(); // task timeout scan
-#if (LOSCFG_BASE_CORE_SWTMR == YES)
- (VOID)OsSwtmrScan();
-#endif
- }
-}
-
-#endif
-
LITE_OS_SEC_TEXT VOID OsTickHandler(VOID)
{
-#if (LOSCFG_KERNEL_TICKLESS == YES)
- if (g_reloadSysTickFlag) {
- LOS_SysTickReload(g_cyclesPerTick);
- g_reloadSysTickFlag = 0;
- }
- g_tickIrqFlag = g_ticklessFlag;
-#endif
-
-#if (LOSCFG_BASE_CORE_TICK_HW_TIME == YES)
+#if (LOSCFG_BASE_CORE_TICK_HW_TIME == 1)
platform_tick_handler();
#endif
g_ullTickCount++;
-#if (LOSCFG_BASE_CORE_TIMESLICE == YES)
+#if (LOSCFG_BASE_CORE_TIMESLICE == 1)
OsTimesliceCheck();
#endif
OsTaskScan(); // task timeout scan
-#if (LOSCFG_BASE_CORE_SWTMR == YES)
+#if (LOSCFG_BASE_CORE_SWTMR == 1)
(VOID)OsSwtmrScan();
#endif
}
diff --git a/kernel/src/mm/los_membox.c b/kernel/src/mm/los_membox.c
old mode 100755
new mode 100644
index 3eea3ab1..0447a3fb
--- a/kernel/src/mm/los_membox.c
+++ b/kernel/src/mm/los_membox.c
@@ -31,11 +31,12 @@
#include "securec.h"
#include "los_interrupt.h"
+#include "los_context.h"
#include "los_membox.h"
#include "los_memory.h"
#include "los_debug.h"
-#if (LOSCFG_PLATFORM_EXC == YES) || (LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK == YES)
+#if (LOSCFG_PLATFORM_EXC == 0) || (LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK == 1)
UINT8 g_memMang[MEM_INFO_SIZE];
#endif
diff --git a/kernel/src/mm/los_memcheck.c b/kernel/src/mm/los_memcheck.c
deleted file mode 100755
index 78c7b0c6..00000000
--- a/kernel/src/mm/los_memcheck.c
+++ /dev/null
@@ -1,136 +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 "los_membox.h"
-//#include "los_multipledlinkhead_pri.h"
-#ifdef __cplusplus
-#if __cplusplus
-extern "C" {
-#endif /* __cpluscplus */
-#endif /* __cpluscplus */
-
-#if LOSCFG_PLATFORM_EXC == YES
-extern UINT8 g_memMang[MEM_INFO_SIZE];
-/*****************************************************************************
- Function : LOS_MemExcInfoGet
- Description : Get the information of the exc memory
- Input : uwMemNum
- Output : pstMemExcInfo
- Return : return 0
- *****************************************************************************/
-LITE_OS_SEC_TEXT_MINOR UINT32 LOS_MemExcInfoGet(UINT32 memNum, MEM_INFO_S *memExcInfo)
-{
- UINT32 idx = 0;
- UINT32 maxBlk = 0;
- UINT32 blkCnt = 0;
- UINT32 blkSize = 0;
- MEM_INFO *memInfo = NULL;
- LosMemDynNode *pstTmpNode = (LosMemDynNode *)NULL;
- LOS_MEM_POOL_INFO *pPool = (LOS_MEM_POOL_INFO *)NULL;
- LOS_MEM_POOL_INFO *pstPoolInfo = (LOS_MEM_POOL_INFO *)NULL;
- UINT8 *pEndPool = NULL;
-
- if (memNum >= *(UINT32 *)g_memMang || memExcInfo == NULL) {
- return LOS_NOK;
- }
- memInfo = (MEM_INFO *)(VOID *)(g_memMang + sizeof(UINT32)) + memNum;
- memExcInfo->uwType = memInfo->uwType;
- memExcInfo->uwStartAddr = memInfo->uwStartAddr;
- memExcInfo->uwSize = memInfo->uwSize;
- memExcInfo->uwFree = 0;
- memExcInfo->uwBlockSize = 0;
- memExcInfo->uwErrorAddr = 0;
- memExcInfo->uwErrorLen = 0;
- memExcInfo->uwErrorOwner = 0;
-
- if (memInfo->uwType == MEM_MANG_MEMBOX) {
- (VOID)LOS_MemboxStatisticsGet((VOID *)(memInfo->uwStartAddr), &maxBlk, &blkCnt, &blkSize);
- memExcInfo->uwBlockSize = blkSize;
- memExcInfo->uwSize = maxBlk; // Block num
- memExcInfo->uwFree = maxBlk - blkCnt;
- pPool = (LOS_MEM_POOL_INFO *)m_aucSysMem0;
- pstPoolInfo = pPool;
- pEndPool = (UINT8 *)pPool + pstPoolInfo->uwPoolSize;
- while (memInfo->blkAddrArray != NULL && idx < maxBlk) {
- char *tmpPtr = ((char **)(memInfo->blkAddrArray))[idx];
- if (tmpPtr != NULL) {
- pstTmpNode = (LosMemDynNode *)(tmpPtr - OS_MEM_NODE_HEAD_SIZE);
- if (!OS_MEM_MAGIC_VALID(pstTmpNode->freeNodeInfo.pstPrev)) {
- goto errout;
- }
- }
- idx++;
- }
- } else if (memInfo->uwType == MEM_MANG_MEMORY) {
- memExcInfo->uwFree = memInfo->uwSize - LOS_MemTotalUsedGet((VOID *)(memInfo->uwStartAddr)) - OS_DLNK_HEAD_SIZE
- - LOS_MemFreeBlksGet((VOID *)(memInfo->uwStartAddr)) * OS_MEM_NODE_HEAD_SIZE - sizeof(LOS_MEM_POOL_INFO);
-
- memExcInfo->uwBlockSize = 0;
- pPool = (LOS_MEM_POOL_INFO *)memInfo->uwStartAddr;
- if (pPool == NULL) {
- return LOS_OK;
- }
- pstPoolInfo = pPool;
- pEndPool = (UINT8 *)pPool + pstPoolInfo->uwPoolSize;
-
- for (pstTmpNode = (LosMemDynNode *)OS_MEM_FIRST_NODE(pPool); pstTmpNode < (LosMemDynNode *)OS_MEM_END_NODE(pPool, pstPoolInfo->uwPoolSize);
- pstTmpNode = (LosMemDynNode *)OS_MEM_NEXT_NODE(pstTmpNode)) {
- memExcInfo->uwBlockSize++;
- if (OS_MEM_NODE_GET_USED_FLAG(pstTmpNode->sizeAndFlag)) {
- if (!OS_MEM_MAGIC_VALID(pstTmpNode->freeNodeInfo.pstPrev)) {
- goto errout;
- }
- }
- else { //is free node, check free node range
- if (!OS_MEM_MIDDLE_ADDR_OPEN_END(pPool, pstTmpNode->freeNodeInfo.pstPrev, pEndPool)) {
- goto errout;
- }
- if (!OS_MEM_MIDDLE_ADDR_OPEN_END(pPool, pstTmpNode->freeNodeInfo.pstNext, pEndPool)) {
- goto errout;
- }
- }
-
- }
- }
- return LOS_OK;
-errout:
- memExcInfo->uwErrorAddr = (UINT32)(UINTPTR)((char*)pstTmpNode + OS_MEM_NODE_HEAD_SIZE);
- memExcInfo->uwErrorLen = (UINT32)OS_MEM_NODE_GET_SIZE(pstTmpNode->sizeAndFlag) - OS_MEM_NODE_HEAD_SIZE;
- memExcInfo->uwErrorOwner = (UINT32)(UINTPTR)(pstTmpNode->freeNodeInfo.pstNext);
- return LOS_OK;
-}
-#endif
-
-#ifdef __cplusplus
-#if __cplusplus
-}
-#endif /* __cpluscplus */
-#endif /* __cpluscplus */
diff --git a/kernel/src/mm/los_memory.c b/kernel/src/mm/los_memory.c
old mode 100755
new mode 100644
index 04fc5467..cf7fad9d
--- a/kernel/src/mm/los_memory.c
+++ b/kernel/src/mm/los_memory.c
@@ -28,1797 +28,1472 @@
* 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 "los_config.h"
+#include "los_interrupt.h"
+#include "los_arch.h"
#include "los_memory.h"
#include "los_task.h"
-#include "los_interrupt.h"
#include "los_debug.h"
-#include "los_membox.h"
#ifdef LOSCFG_LIB_LIBC
#endif
-
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
-#if (LOSCFG_MEM_MUL_POOL == YES)
-VOID *g_memPoolHead = NULL;
-#endif
+/* Used to cut non-essential functions. */
+#define OS_MEM_FREE_BY_TASKID 1
+#define OS_MEM_EXPAND_ENABLE 0
+#define OS_MEM_TRACE 0
-MALLOC_HOOK g_mallocHook = (MALLOC_HOOK)(UINTPTR)NULL;
-
-#if (LOSCFG_BASE_CORE_TASKSTACK_INDEPENDENT == YES)
-__attribute__((section(".data"))) UINT32 g_sysStackAddrEnd;
-#endif
-
-UINT8 *g_sysNoCacheMem0 = (UINT8 *)NULL;
__attribute__((section(".data.init"))) UINT32 g_sysMemAddrEnd;
-#ifdef OS_MEM_CHECK_DEBUG
-static UINT8 g_checkMemLevel = (UINT8)LOS_MEM_CHECK_LEVEL_DEFAULT;
+
+#if (LOSCFG_MEM_MUL_POOL == 1)
+VOID *g_poolHead = NULL;
#endif
-#ifdef LOS_MEM_LEAK_CHECK
-MEM_CHECK_INFO g_checkInfo[CHECK_MAXCOUNT] = {0};
-int g_memCount = 0;
-int g_memPeakCount = 0;
-int g_memCheckFlag = 0;
+/* The following is the macro definition and interface implementation related to the TLSF. */
+
+/* Supposing a Second Level Index: SLI = 3. */
+#define OS_MEM_SLI 3
+/* Giving 1 free list for each small bucket: 4, 8, 12, up to 124. */
+#define OS_MEM_SMALL_BUCKET_COUNT 31
+#define OS_MEM_SMALL_BUCKET_MAX_SIZE 128
+/* Giving 2^OS_MEM_SLI free lists for each large bucket. */
+#define OS_MEM_LARGE_BUCKET_COUNT 24
+/* OS_MEM_SMALL_BUCKET_MAX_SIZE to the power of 2 is 7. */
+#define OS_MEM_LARGE_START_BUCKET 7
+
+/* The count of free list. */
+#define OS_MEM_FREE_LIST_COUNT (OS_MEM_SMALL_BUCKET_COUNT + (OS_MEM_LARGE_BUCKET_COUNT << OS_MEM_SLI))
+/* The bitmap is used to indicate whether the free list is empty, 1: not empty, 0: empty. */
+#define OS_MEM_BITMAP_WORDS ((OS_MEM_FREE_LIST_COUNT >> 5) + 1)
+
+#define OS_MEM_BITMAP_MASK 0x1FU
+
+/* Used to find the first bit of 1 in bitmap. */
+STATIC INLINE UINT16 OsMemFFS(UINT32 bitmap)
+{
+ bitmap &= ~bitmap + 1;
+ return (OS_MEM_BITMAP_MASK - CLZ(bitmap));
+}
+
+/* Used to find the last bit of 1 in bitmap. */
+STATIC INLINE UINT16 OsMemFLS(UINT32 bitmap)
+{
+ return (OS_MEM_BITMAP_MASK - CLZ(bitmap));
+}
+
+STATIC INLINE UINT32 OsMemLog2(UINT32 size)
+{
+ return (size > 0) ? OsMemFLS(size) : 0;
+}
+
+/* Get the first level: f = log2(size). */
+STATIC INLINE UINT32 OsMemFlGet(UINT32 size)
+{
+ if (size < OS_MEM_SMALL_BUCKET_MAX_SIZE) {
+ return ((size >> 2) - 1); /* 2: The small bucket setup is 4. */
+ }
+ return (OsMemLog2(size) - OS_MEM_LARGE_START_BUCKET + OS_MEM_SMALL_BUCKET_COUNT);
+}
+
+/* Get the second level: s = (size - 2^f) * 2^SLI / 2^f. */
+STATIC INLINE UINT32 OsMemSlGet(UINT32 size, UINT32 fl)
+{
+ if ((fl < OS_MEM_SMALL_BUCKET_COUNT) || (size < OS_MEM_SMALL_BUCKET_MAX_SIZE)) {
+ PRINT_ERR("fl or size is too small, fl = %u, size = %u\n", fl, size);
+ return 0;
+ }
+
+ UINT32 sl = (size << OS_MEM_SLI) >> (fl - OS_MEM_SMALL_BUCKET_COUNT + OS_MEM_LARGE_START_BUCKET);
+ return (sl - (1 << OS_MEM_SLI));
+}
+
+/* The following is the memory algorithm related macro definition and interface implementation. */
+
+struct OsMemNodeHead {
+ UINT32 magic;
+ union {
+ struct OsMemNodeHead *prev; /* The prev is used for current node points to the previous node */
+ struct OsMemNodeHead *next; /* The next is used for last node points to the expand node */
+ } ptr;
+ UINT32 sizeAndFlag;
+};
+
+struct OsMemUsedNodeHead {
+ struct OsMemNodeHead header;
+#if OS_MEM_FREE_BY_TASKID
+ UINT32 taskID;
#endif
+};
-#ifdef LOSCFG_MEM_MUL_MODULE
-UINT32 g_memInfo[MEM_MODULE_MAX + 1] = {0};
+struct OsMemFreeNodeHead {
+ struct OsMemNodeHead header;
+ struct OsMemFreeNodeHead *prev;
+ struct OsMemFreeNodeHead *next;
+};
+
+struct OsMemPoolInfo {
+ VOID *pool;
+ UINT32 totalSize;
+ UINT32 attr;
+};
+
+struct OsMemPoolHead {
+ struct OsMemPoolInfo info;
+ UINT32 freeListBitmap[OS_MEM_BITMAP_WORDS];
+ struct OsMemFreeNodeHead *freeList[OS_MEM_FREE_LIST_COUNT];
+#if (LOSCFG_MEM_MUL_POOL == 1)
+ VOID *nextPool;
#endif
+};
-#define OS_BITS_PER_BYTE 8
-STATIC_INLINE UINT32 OsLog2(UINT32 size)
+/* Spinlock for mem module, only available on SMP mode */
+#define MEM_LOCK(pool, state) ((void)(pool), (state) = LOS_IntLock())
+#define MEM_UNLOCK(pool, state) ((void)(pool), LOS_IntRestore(state))
+
+/* The memory pool support expand. */
+#define OS_MEM_POOL_EXPAND_ENABLE 0x01
+/* The memory pool ssupport no lock. */
+#define OS_MEM_POOL_LOCK_ENABLE 0x02
+
+#define OS_MEM_NODE_MAGIC 0xABCDDCBA
+#define OS_MEM_MIN_ALLOC_SIZE (sizeof(struct OsMemFreeNodeHead) - sizeof(struct OsMemUsedNodeHead))
+
+#define OS_MEM_NODE_USED_FLAG 0x80000000U
+#define OS_MEM_NODE_ALIGNED_FLAG 0x40000000U
+#define OS_MEM_NODE_LAST_FLAG 0x20000000U /* Sentinel Node */
+#define OS_MEM_NODE_ALIGNED_AND_USED_FLAG (OS_MEM_NODE_USED_FLAG | OS_MEM_NODE_ALIGNED_FLAG | OS_MEM_NODE_LAST_FLAG)
+
+#define OS_MEM_NODE_GET_ALIGNED_FLAG(sizeAndFlag) \
+ ((sizeAndFlag) & OS_MEM_NODE_ALIGNED_FLAG)
+#define OS_MEM_NODE_SET_ALIGNED_FLAG(sizeAndFlag) \
+ ((sizeAndFlag) = ((sizeAndFlag) | OS_MEM_NODE_ALIGNED_FLAG))
+#define OS_MEM_NODE_GET_ALIGNED_GAPSIZE(sizeAndFlag) \
+ ((sizeAndFlag) & ~OS_MEM_NODE_ALIGNED_FLAG)
+#define OS_MEM_NODE_GET_USED_FLAG(sizeAndFlag) \
+ ((sizeAndFlag) & OS_MEM_NODE_USED_FLAG)
+#define OS_MEM_NODE_SET_USED_FLAG(sizeAndFlag) \
+ ((sizeAndFlag) = ((sizeAndFlag) | OS_MEM_NODE_USED_FLAG))
+#define OS_MEM_NODE_GET_SIZE(sizeAndFlag) \
+ ((sizeAndFlag) & ~OS_MEM_NODE_ALIGNED_AND_USED_FLAG)
+#define OS_MEM_NODE_SET_LAST_FLAG(sizeAndFlag) \
+ ((sizeAndFlag) = ((sizeAndFlag) | OS_MEM_NODE_LAST_FLAG))
+#define OS_MEM_NODE_GET_LAST_FLAG(sizeAndFlag) \
+ ((sizeAndFlag) & OS_MEM_NODE_LAST_FLAG)
+
+#define OS_MEM_ALIGN_SIZE sizeof(UINTPTR)
+#define OS_MEM_IS_POW_TWO(value) ((((UINTPTR)(value)) & ((UINTPTR)(value) - 1)) == 0)
+#define OS_MEM_ALIGN(p, alignSize) (((UINTPTR)(p) + (alignSize) - 1) & ~((UINTPTR)((alignSize) - 1)))
+#define OS_MEM_IS_ALIGNED(a, b) (!(((UINTPTR)(a)) & (((UINTPTR)(b)) - 1)))
+#define OS_MEM_NODE_HEAD_SIZE sizeof(struct OsMemUsedNodeHead)
+#define OS_MEM_MIN_POOL_SIZE (OS_MEM_NODE_HEAD_SIZE + sizeof(struct OsMemPoolHead))
+#define OS_MEM_NEXT_NODE(node) \
+ ((struct OsMemNodeHead *)(VOID *)((UINT8 *)(node) + OS_MEM_NODE_GET_SIZE((node)->sizeAndFlag)))
+#define OS_MEM_FIRST_NODE(pool) \
+ (struct OsMemNodeHead *)((UINT8 *)(pool) + sizeof(struct OsMemPoolHead))
+#define OS_MEM_END_NODE(pool, size) \
+ (struct OsMemNodeHead *)((UINT8 *)(pool) + (size) - OS_MEM_NODE_HEAD_SIZE)
+#define OS_MEM_MIDDLE_ADDR_OPEN_END(startAddr, middleAddr, endAddr) \
+ (((UINT8 *)(startAddr) <= (UINT8 *)(middleAddr)) && ((UINT8 *)(middleAddr) < (UINT8 *)(endAddr)))
+#define OS_MEM_MIDDLE_ADDR(startAddr, middleAddr, endAddr) \
+ (((UINT8 *)(startAddr) <= (UINT8 *)(middleAddr)) && ((UINT8 *)(middleAddr) <= (UINT8 *)(endAddr)))
+#define OS_MEM_SET_MAGIC(node) ((node)->magic = OS_MEM_NODE_MAGIC)
+#define OS_MEM_MAGIC_VALID(node) ((node)->magic == OS_MEM_NODE_MAGIC)
+
+STATIC INLINE VOID OsMemFreeNodeAdd(VOID *pool, struct OsMemFreeNodeHead *node);
+STATIC INLINE UINT32 OsMemFree(struct OsMemPoolHead *pool, struct OsMemNodeHead *node);
+STATIC VOID OsMemInfoPrint(VOID *pool);
+
+#if OS_MEM_FREE_BY_TASKID
+STATIC INLINE VOID OsMemNodeSetTaskID(struct OsMemUsedNodeHead *node)
{
- return size ? ((sizeof(size) * OS_BITS_PER_BYTE) - CLZ(size) - 1) : 0;
-}
-
-LITE_OS_SEC_TEXT_INIT VOID OsDLnkInitMultiHead(VOID *headAddr)
-{
- LosMultipleDlinkHead *head = (LosMultipleDlinkHead *)headAddr;
- LOS_DL_LIST *listHead = head->listHead;
- UINT32 idx;
-
- for (idx = 0; idx < OS_MULTI_DLNK_NUM; ++idx, ++listHead) {
- LOS_ListInit(listHead);
- }
-}
-
-LITE_OS_SEC_TEXT_MINOR LOS_DL_LIST *OsDLnkMultiHead(VOID *headAddr, UINT32 size)
-{
- LosMultipleDlinkHead *head = (LosMultipleDlinkHead *)headAddr;
- UINT32 idx = OsLog2(size);
-
- if (idx > OS_MAX_MULTI_DLNK_LOG2) {
- return (LOS_DL_LIST *)NULL;
- }
-
- if (idx <= OS_MIN_MULTI_DLNK_LOG2) {
- idx = OS_MIN_MULTI_DLNK_LOG2;
- }
-
- return head->listHead + (idx - OS_MIN_MULTI_DLNK_LOG2);
-}
-
-LITE_OS_SEC_TEXT_INIT UINT32 OsMemSystemInit()
-{
- UINT32 ret;
- UINT32 memSize;
- m_aucSysMem0 = (UINT8 *)(UINTPTR)(((UINT32)(UINTPTR)m_aucSysMem0 + (OS_MEM_NODE_ALIGN_SIZE - 1)) &
- ~(OS_MEM_NODE_ALIGN_SIZE - 1));
- memSize = ((UINT32)g_sysMemAddrEnd) - OS_SYS_NOCACHEMEM_SIZE - (UINT32)(UINTPTR)m_aucSysMem0;
- ret = LOS_MemInit(m_aucSysMem0, memSize);
- PRINT_INFO("LiteOS heap memory address:0x%x,size:0x%x\n", m_aucSysMem0, memSize);
- return ret;
-}
-#if (LOSCFG_BASE_CORE_TASKSTACK_INDEPENDENT == YES)
-LITE_OS_SEC_TEXT_INIT UINT32 OsSysStackInit(UINT32 memStart)
-{
- UINT32 ret;
- UINT32 memSize;
- UINT8 *sysStackAddr = NULL;
- sysStackAddr = (UINT8 *)((memStart + (OS_MEM_NODE_ALIGN_SIZE - 1)) & ~(OS_MEM_NODE_ALIGN_SIZE - 1));
- memSize = ((UINTPTR)g_sysStackAddrEnd) - (UINTPTR)sysStackAddr;
- ret = LOS_MemInit(sysStackAddr, memSize);
- PRINT_INFO("LiteOS stack memory address:0x%x,size:0x%x\n", sysStackAddr, memSize);
- return ret;
+ node->taskID = LOS_CurTaskIDGet();
}
#endif
-#if OS_SYS_NOCACHEMEM_SIZE
-UINT32 OsNocacheMemSystemInit(VOID)
+#if OS_MEM_EXPAND_ENABLE
+STATIC INLINE struct OsMemNodeHead *OsMemLastSentinelNodeGet(const struct OsMemNodeHead *sentinelNode)
{
- UINT32 ret;
- g_sysNoCacheMem0 = (g_sysMemAddrEnd - OS_SYS_NOCACHEMEM_SIZE);
- ret = LOS_MemInit(g_sysNoCacheMem0, OS_SYS_NOCACHEMEM_SIZE);
- return ret;
-}
-#endif
+ struct OsMemNodeHead *node = NULL;
+ VOID *ptr = sentinelNode->ptr.next;
+ UINT32 size = OS_MEM_NODE_GET_SIZE(sentinelNode->sizeAndFlag);
-VOID OsMemInfoPrint(VOID *pool);
-VOID *OsMemFindNodeCtrl(VOID *headPtr);
-
-/*****************************************************************************
- Function : OsMemFindSuitableFreeBlock
- Description : find suitable free block use "best fit" algorithm
- Input : pool --- Pointer to memory pool
- allocSize --- Size of memory in bytes which note need allocate
- Output : None
- Return : NULL --- no suitable block found
- tmpNode --- pointer a suitable free block
-*****************************************************************************/
-STATIC_INLINE LosMemDynNode *OsMemFindSuitableFreeBlock(VOID *pool, UINT32 allocSize)
-{
- LOS_DL_LIST *listHead = (LOS_DL_LIST *)NULL;
-
- for (listHead = OS_MEM_HEAD(pool, allocSize); listHead != NULL;
- listHead = OS_DLNK_NEXT_HEAD(OS_MEM_HEAD_ADDR(pool), listHead)) {
- LosMemDynNode *tmpNode = (LosMemDynNode *)NULL;
- LOS_DL_LIST_FOR_EACH_ENTRY(tmpNode, listHead, LosMemDynNode, freeNodeInfo) {
- if (tmpNode->sizeAndFlag >= allocSize) {
- return tmpNode;
- }
- }
+ while ((ptr != NULL) && (size != 0)) {
+ node = OS_MEM_END_NODE(ptr, size);
+ ptr = node->ptr.next;
+ size = OS_MEM_NODE_GET_SIZE(node->sizeAndFlag);
}
- return (LosMemDynNode *)NULL;
+ return node;
}
-/*****************************************************************************
- Function : OsMemClearNode
- Description : clear a mem Node , set every member to NULL
- Input : node --- Pointer to the mem node which will be cleared up
- Output : None
- Return : None
-*****************************************************************************/
-STATIC_INLINE VOID OsMemClearNode(LosMemDynNode *node)
+STATIC INLINE BOOL OsMemSentinelNodeCheck(struct OsMemNodeHead *sentinelNode)
{
- node->freeNodeInfo.pstPrev = (LOS_DL_LIST *)NULL;
- node->freeNodeInfo.pstNext = (LOS_DL_LIST *)NULL;
- node->preNode = (LosMemDynNode *)NULL;
-}
-
-/*****************************************************************************
- Function : OsMemMergeNode
- Description : merge this node and pre node ,then clear this node info
- Input : node --- Pointer to node which will be merged
- Output : None
- Return : None
-*****************************************************************************/
-STATIC_INLINE VOID OsMemMergeNode(LosMemDynNode *node)
-{
- LosMemDynNode *nextNode = (LosMemDynNode *)NULL;
-
- node->preNode->sizeAndFlag += node->sizeAndFlag;
- nextNode = (LosMemDynNode *)((UINTPTR)node + node->sizeAndFlag);
- nextNode->preNode = node->preNode;
- OsMemClearNode(node);
-}
-
-/*****************************************************************************
- Function : OsMemSpitNode
- Description : spit new node from allocNode, and merge remainder mem if necessary
- Input : pool --- Pointer to memory pool
- allocNode --- the source node which new node be spit from to.
- After pick up it's node info, change to point the new node
- allocSize --- the size of new node
- Output : allocNode --- save new node addr
- Return : None
-*****************************************************************************/
-STATIC_INLINE VOID OsMemSpitNode(VOID *pool, LosMemDynNode *allocNode, UINT32 allocSize)
-{
- LosMemDynNode *newFreeNode = (LosMemDynNode *)NULL;
- LosMemDynNode *nextNode = (LosMemDynNode *)NULL;
- LOS_DL_LIST *listHead = (LOS_DL_LIST *)NULL;
-
- newFreeNode = (LosMemDynNode *)((UINT8 *)allocNode + allocSize);
- newFreeNode->preNode = allocNode;
- newFreeNode->sizeAndFlag = allocNode->sizeAndFlag - allocSize;
- allocNode->sizeAndFlag = allocSize;
- nextNode = OS_MEM_NEXT_NODE(newFreeNode);
- nextNode->preNode = newFreeNode;
- if (!OS_MEM_NODE_GET_USED_FLAG(nextNode->sizeAndFlag)) {
- LOS_ListDelete(&(nextNode->freeNodeInfo));
- OsMemMergeNode(nextNode);
- }
-
- listHead = OS_MEM_HEAD(pool, newFreeNode->sizeAndFlag);
- if (listHead == NULL) {
- PRINT_ERR("%s %d\n", __FUNCTION__, __LINE__);
- return;
- }
-
- LOS_ListAdd(listHead, &(newFreeNode->freeNodeInfo));
-}
-
-/*****************************************************************************
- Function : OsMemFreeNode
- Description : free the node from memory & if there are free node beside, merger them.
- at last update "listHead' which saved all free node control head
- Input : node --- the node which need be freed
- pool --- Pointer to memory pool
- Output : None
- Return : None
-*****************************************************************************/
-STATIC_INLINE VOID OsMemFreeNode(LosMemDynNode *node, VOID *pool)
-{
- LosMemDynNode *nextNode = (LosMemDynNode *)NULL;
- LOS_DL_LIST *listHead = (LOS_DL_LIST *)NULL;
-
-#if defined(OS_MEM_WATERLINE) && (OS_MEM_WATERLINE == YES)
- LOS_MEM_POOL_INFO *poolInfo = (LOS_MEM_POOL_INFO *)pool;
- poolInfo->uwPoolCurUsedSize -= OS_MEM_NODE_GET_SIZE(node->sizeAndFlag);
-#endif
- if (pool == (VOID *)OS_SYS_MEM_ADDR) {
- OS_MEM_REDUCE_USED(OS_MEM_NODE_GET_SIZE(node->sizeAndFlag), OS_MEM_TASKID_GET(node));
- }
-
- node->sizeAndFlag = OS_MEM_NODE_GET_SIZE(node->sizeAndFlag);
- if ((node->preNode != NULL) &&
- (!OS_MEM_NODE_GET_USED_FLAG(node->preNode->sizeAndFlag))) {
- LosMemDynNode *preNode = node->preNode;
- OsMemMergeNode(node);
- nextNode = OS_MEM_NEXT_NODE(preNode);
- if (!OS_MEM_NODE_GET_USED_FLAG(nextNode->sizeAndFlag)) {
- LOS_ListDelete(&(nextNode->freeNodeInfo));
- OsMemMergeNode(nextNode);
- }
-
- LOS_ListDelete(&(preNode->freeNodeInfo));
- listHead = OS_MEM_HEAD(pool, preNode->sizeAndFlag);
- if (listHead == NULL) {
- PRINT_ERR("%s %d\n", __FUNCTION__, __LINE__);
- return;
- }
-
- LOS_ListAdd(listHead, &(preNode->freeNodeInfo));
- } else {
- nextNode = OS_MEM_NEXT_NODE(node);
- if (!OS_MEM_NODE_GET_USED_FLAG(nextNode->sizeAndFlag)) {
- LOS_ListDelete(&(nextNode->freeNodeInfo));
- OsMemMergeNode(nextNode);
- }
-
- listHead = OS_MEM_HEAD(pool, node->sizeAndFlag);
- if (listHead == NULL) {
- PRINT_ERR("%s %d\n", __FUNCTION__, __LINE__);
- return;
- }
-
- LOS_ListAdd(listHead, &(node->freeNodeInfo));
- }
-}
-
-STATIC_INLINE LosMemDynNode *OsMemGetNodeFromPtr(VOID *ptr)
-{
- UINT32 gapSize;
- if (((UINT32 *)((UINTPTR)ptr - OS_MEM_NODE_DATA_SIZE)) == NULL) {
- return (LosMemDynNode *)NULL;
- }
- gapSize = *((UINT32 *)((UINTPTR)ptr - OS_MEM_NODE_DATA_SIZE));
- if (OS_MEM_NODE_GET_ALIGNED_FLAG(gapSize)) {
- gapSize = OS_MEM_NODE_GET_ALIGNED_GAPSIZE(gapSize);
- ptr = (VOID *)((UINTPTR)ptr - gapSize);
- }
- return (LosMemDynNode *)((UINTPTR)ptr - OS_MEM_NODE_HEAD_SIZE);
-}
-
-/*****************************************************************************
- Function : OsMemCheckUsedNode
- Description : check the result if pointer memory node belongs to pointer memory pool
- Input : pool --- Pointer to memory pool
- node --- the node which need be checked
- Output : None
- Return : LOS_OK or LOS_NOK
-*****************************************************************************/
-#ifdef LOS_DLNK_SAFE_CHECK
-STATIC_INLINE UINT32 OsMemCheckUsedNode(VOID *pool, LosMemDynNode *node)
-{
- LosMemDynNode *tmpNode = NULL;
- LOS_MEM_POOL_INFO *poolInfo = (LOS_MEM_POOL_INFO *)pool;
- LosMemDynNode *end = OS_MEM_END_NODE(pool, poolInfo->uwPoolSize);
-
- for (tmpNode = OS_MEM_FIRST_NODE(pool); tmpNode < end; tmpNode = OS_MEM_NEXT_NODE(tmpNode)) {
- if ((tmpNode == node) && OS_MEM_NODE_GET_USED_FLAG(tmpNode->sizeAndFlag)) {
- return LOS_OK;
- } else if (tmpNode > node) {
- return LOS_NOK;
- }
- }
-
- return LOS_NOK;
-}
-
-#elif defined(LOS_DLNK_SIMPLE_CHECK)
-STATIC_INLINE UINT32 OsMemCheckUsedNode(VOID *pool, LosMemDynNode *node)
-{
- LOS_MEM_POOL_INFO *poolInfo = (LOS_MEM_POOL_INFO *)pool;
- LosMemDynNode *startNode = OS_MEM_FIRST_NODE(pool);
- LosMemDynNode *endNode = OS_MEM_END_NODE(pool, poolInfo->uwPoolSize);
- if (!OS_MEM_MIDDLE_ADDR_OPEN_END(startNode, node, endNode)) {
- return LOS_NOK;
- }
-
- if (!OS_MEM_NODE_GET_USED_FLAG(node->sizeAndFlag)) {
- return LOS_NOK;
- }
-
- if (!OS_MEM_MAGIC_VALID(node->freeNodeInfo.pstPrev)) {
- return LOS_NOK;
- }
-
- return LOS_OK;
-}
-
-#else
-STATIC_INLINE BOOL OsMemIsNodeValid(const LosMemDynNode *node, const LosMemDynNode *startNode,
- const LosMemDynNode *endNode, const UINT8 *startPool, const UINT8 *endPool)
-{
- if (!OS_MEM_MIDDLE_ADDR(startNode, node, endNode)) {
+ if (!OS_MEM_NODE_GET_USED_FLAG(sentinelNode->sizeAndFlag)) {
return FALSE;
}
- if (OS_MEM_NODE_GET_USED_FLAG(node->sizeAndFlag)) {
- if (!OS_MEM_MAGIC_VALID(node->freeNodeInfo.pstPrev)) {
- return FALSE;
- }
- return TRUE;
- }
-
- if (!OS_MEM_MIDDLE_ADDR_OPEN_END(startPool, node->freeNodeInfo.pstPrev, endPool)) {
+ if (!OS_MEM_MAGIC_VALID(sentinelNode)) {
return FALSE;
}
return TRUE;
}
-STATIC_INLINE UINT32 OsMemCheckUsedNode(VOID *pool, LosMemDynNode *node)
+STATIC INLINE BOOL OsMemIsLastSentinelNode(struct OsMemNodeHead *sentinelNode)
{
- LOS_MEM_POOL_INFO *poolInfo = (LOS_MEM_POOL_INFO *)pool;
- LosMemDynNode *startNode = OS_MEM_FIRST_NODE(pool);
- LosMemDynNode *endNode = OS_MEM_END_NODE(pool, poolInfo->uwPoolSize);
- UINT8 *endPool = (UINT8 *)pool + poolInfo->uwPoolSize;
- const LosMemDynNode *nextNode = (const LosMemDynNode *)NULL;
- if (OsMemIsNodeValid(node, startNode, endNode, (UINT8 *)pool, endPool) != TRUE) {
- return LOS_NOK;
+ if (OsMemSentinelNodeCheck(sentinelNode) == FALSE) {
+ PRINT_ERR("%s %d, The current sentinel node is invalid\n", __FUNCTION__, __LINE__);
+ return TRUE;
}
- if (!OS_MEM_NODE_GET_USED_FLAG(node->sizeAndFlag)) {
- return LOS_NOK;
+ if ((OS_MEM_NODE_GET_SIZE(sentinelNode->sizeAndFlag) == 0) ||
+ (sentinelNode->ptr.next == NULL)) {
+ return TRUE;
}
- nextNode = OS_MEM_NEXT_NODE(node);
- if (OsMemIsNodeValid(nextNode, startNode, endNode, (UINT8 *)pool, endPool) != TRUE) {
- return LOS_NOK;
- }
-
- if (nextNode->preNode != node) {
- return LOS_NOK;
- }
-
- if (node != startNode) {
- if (OsMemIsNodeValid(node->preNode, startNode, endNode, (UINT8 *)pool, endPool) != TRUE) {
- return LOS_NOK;
- }
-
- if (OS_MEM_NEXT_NODE(node->preNode) != node) {
- return LOS_NOK;
- }
- }
-
- return LOS_OK;
+ return FALSE;
}
-#endif
-
-/*****************************************************************************
- Function : OsMemSetMagicNumAndTaskid
- Description : set magic & taskid
- Input : node --- the node which will be set magic & taskid
- Output : None
- Return : None
-*****************************************************************************/
-STATIC_INLINE VOID OsMemSetMagicNumAndTaskid(LosMemDynNode *node)
+STATIC INLINE VOID OsMemSentinelNodeSet(struct OsMemNodeHead *sentinelNode, VOID *newNode, UINT32 size)
{
- OS_MEM_SET_MAGIC(node->freeNodeInfo.pstPrev);
-
- /* In the process of dynamic memory initialization, direct use of uninitialized global variable which
- * initialized in task initialization. Need to exclude this scene, make the value of
- * node->freeNodeInfo.pstNext to 0xffffffff */
- if ((g_losTask.runTask != NULL) && OS_INT_INACTIVE) {
- OS_MEM_TASKID_SET(node, g_losTask.runTask->taskID);
- } else {
- node->freeNodeInfo.pstNext = (LOS_DL_LIST *)0xffffffff; /* If the task mode does not initialize,
- * the field is the 0xffffffff */
+ if (sentinelNode->ptr.next != NULL) {
+ sentinelNode = OsMemLastSentinelNodeGet(sentinelNode);
}
+
+ sentinelNode->sizeAndFlag = size;
+ sentinelNode->ptr.next = newNode;
+ OS_MEM_NODE_SET_USED_FLAG(sentinelNode->sizeAndFlag);
+ OS_MEM_NODE_SET_LAST_FLAG(sentinelNode->sizeAndFlag);
}
-STATIC_INLINE VOID OsMemIntegrityCheckErrout(LosMemDynNode *curNode, LosMemDynNode *prevNode)
+STATIC INLINE VOID *OsMemSentinelNodeGet(struct OsMemNodeHead *node)
{
- UINT32 taskID;
- LosTaskCB *taskCB = NULL;
-
- /* print the 4 UINT32 of the current memory node head */
- PRINTK("broken node head: 0x%x 0x%x 0x%x 0x%x\n",
- *(UINT32 *)curNode, *((UINT32 *)curNode + 1), *((UINT32 *)curNode + 2), *((UINT32 *)curNode + 3));
-
- taskID = OS_MEM_TASKID_GET(prevNode);
- do {
- if (taskID >= g_taskMaxNum) {
- LOS_Panic("Task ID %d in pre node is invalid!\n", taskID);
- break;
- }
- taskCB = OS_TCB_FROM_TID(taskID);
-
- if ((taskCB->taskStatus & OS_TASK_STATUS_UNUSED) ||
- (taskCB->taskEntry == NULL) ||
- (taskCB->taskName == NULL)) {
- LOS_Panic("\r\nTask ID %d in pre node is not created!\n", taskID);
- break;
- }
- LOS_Panic("cur node: 0x%x\n"
- "pre node: 0x%x\n"
- "pre node was allocated by task:%s\n",
- (UINTPTR)curNode, (UINTPTR)prevNode, taskCB->taskName);
- } while (0);
-}
-
-/*****************************************************************************
- Function : LOS_MemIntegrityCheck
- Description : memory pool integrity checking
- Input : pool --- Pointer to memory pool
- Output : None
- Return : LOS_OK --- memory pool integrate or LOS_NOK --- memory pool impaired
-*****************************************************************************/
-LITE_OS_SEC_TEXT_MINOR UINT32 LOS_MemIntegrityCheck(VOID *pool)
-{
- LosMemDynNode *tmpNode = (LosMemDynNode *)NULL;
- LosMemDynNode *prevNode = (LosMemDynNode *)NULL;
- LOS_MEM_POOL_INFO *poolInfo = (LOS_MEM_POOL_INFO *)pool;
- UINT8 *endPool = NULL;
- UINTPTR intSave;
-
- if (pool == NULL) {
- return LOS_NOK;
- }
-
- endPool = (UINT8 *)pool + poolInfo->uwPoolSize;
-
- intSave = LOS_IntLock();
- prevNode = OS_MEM_FIRST_NODE(pool);
- for (tmpNode = OS_MEM_FIRST_NODE(pool);
- tmpNode < OS_MEM_END_NODE(pool, poolInfo->uwPoolSize);
- tmpNode = OS_MEM_NEXT_NODE(tmpNode)) {
- if (OS_MEM_NODE_GET_USED_FLAG(tmpNode->sizeAndFlag)) {
- if (!OS_MEM_MAGIC_VALID(tmpNode->freeNodeInfo.pstPrev)) {
- PRINT_ERR("[%s], %d, memory check error!\n"
- "memory used but magic num wrong, freeNodeInfo.pstPrev(magic num):0x%x \n",
- __FUNCTION__, __LINE__, (UINT32)(UINTPTR)(tmpNode->freeNodeInfo.pstPrev));
- goto ERROUT;
- }
- } else { /* is free node, check free node range */
- if (!OS_MEM_MIDDLE_ADDR_OPEN_END(pool, tmpNode->freeNodeInfo.pstPrev, endPool)) {
- PRINT_ERR("[%s], %d, memory check error!\n"
- "freeNodeInfo.pstPrev:0x%x is out of legal mem range[0x%x, 0x%x]\n",
- __FUNCTION__, __LINE__,
- (UINT32)(UINTPTR)(tmpNode->freeNodeInfo.pstPrev), (UINTPTR)pool, (UINTPTR)endPool);
- goto ERROUT;
- }
- if (!OS_MEM_MIDDLE_ADDR_OPEN_END(pool,
- (UINT32)(UINTPTR)(tmpNode->freeNodeInfo.pstNext),
- (UINTPTR)endPool)) {
- PRINT_ERR("[%s], %d, memory check error!\n"
- "freeNodeInfo.pstNext:0x%x is out of legal mem range[0x%x, 0x%x]\n",
- __FUNCTION__, __LINE__,
- (UINT32)(UINTPTR)(tmpNode->freeNodeInfo.pstNext), (UINTPTR)pool, (UINTPTR)endPool);
- goto ERROUT;
- }
- }
-
- prevNode = tmpNode;
- }
- LOS_IntRestore(intSave);
- return LOS_OK;
-
-ERROUT:
- OsMemIntegrityCheckErrout(tmpNode, prevNode);
- LOS_IntRestore(intSave);
- return LOS_NOK;
-}
-
-/*****************************************************************************
- Function : OsMemAllocWithCheck
- Description : Allocate node from Memory pool
- Input : pool --- Pointer to memory pool
- size --- Size of memory in bytes to allocate
- Output : None
- Return : Pointer to allocated memory
-*****************************************************************************/
-STATIC_INLINE VOID *OsMemAllocWithCheck(VOID *pool, UINT32 size)
-{
- LosMemDynNode *allocNode = (LosMemDynNode *)NULL;
- UINT32 allocSize;
-#if defined(OS_MEM_WATERLINE) && (OS_MEM_WATERLINE == YES)
- LOS_MEM_POOL_INFO *poolInfo = (LOS_MEM_POOL_INFO *)pool;
-#endif
- if (g_mallocHook != NULL) {
- g_mallocHook();
- }
-
-#ifdef OS_MEM_ENABLE_ALLOC_CHECK
- if (LOS_MemIntegrityCheck(pool) != LOS_OK) {
- PRINT_ERR("Memory Pool Integrity Checking Failed!\n");
- }
-#endif
-
- allocSize = OS_MEM_ALIGN(size + OS_MEM_NODE_HEAD_SIZE, OS_MEM_ALIGN_SIZE);
- allocNode = OsMemFindSuitableFreeBlock(pool, allocSize);
- if (allocNode == NULL) {
- PRINT_ERR("--------------------------------------------------------------------------------------\n");
- OsMemInfoPrint(pool);
- PRINT_ERR("[%s] No suitable free block, require free node size: 0x%x\n", __FUNCTION__, allocSize);
- PRINT_ERR("--------------------------------------------------------------------------------------\n");
+ if (OsMemSentinelNodeCheck(node) == FALSE) {
return NULL;
}
- if ((allocSize + OS_MEM_NODE_HEAD_SIZE + OS_MEM_ALIGN_SIZE) <= allocNode->sizeAndFlag) {
- OsMemSpitNode(pool, allocNode, allocSize);
- }
- LOS_ListDelete(&(allocNode->freeNodeInfo));
- OsMemSetMagicNumAndTaskid(allocNode);
- OS_MEM_NODE_SET_USED_FLAG(allocNode->sizeAndFlag);
- if (pool == (VOID *)OS_SYS_MEM_ADDR) {
- OS_MEM_ADD_USED(OS_MEM_NODE_GET_SIZE(allocNode->sizeAndFlag), OS_MEM_TASKID_GET(allocNode));
- }
-#if defined(OS_MEM_WATERLINE) && (OS_MEM_WATERLINE == YES)
- poolInfo->uwPoolCurUsedSize += OS_MEM_NODE_GET_SIZE(allocNode->sizeAndFlag);
- if (poolInfo->uwPoolCurUsedSize > poolInfo->uwPoolWaterLine) {
- poolInfo->uwPoolWaterLine = poolInfo->uwPoolCurUsedSize;
- }
-#endif
- return (allocNode + 1);
+
+ return node->ptr.next;
}
-/*****************************************************************************
- Function : OsMemReAllocSmaller
- Description : reAlloc a smaller memory node
- Input : pool --- Pointer to memory pool
- allocSize --- the size of new node which will be alloced
- node --- the node which wille be realloced
- nodeSize --- the size of old node
- Output : node --- pointer to the new node after realloc
- Return : None
-*****************************************************************************/
-STATIC_INLINE VOID OsMemReAllocSmaller(VOID *pool, UINT32 allocSize, LosMemDynNode *node, UINT32 nodeSize)
+STATIC INLINE struct OsMemNodeHead *PreSentinelNodeGet(const VOID *pool, const struct OsMemNodeHead *node)
{
-#if defined(OS_MEM_WATERLINE) && (OS_MEM_WATERLINE == YES)
- LOS_MEM_POOL_INFO *poolInfo = (LOS_MEM_POOL_INFO *)pool;
-#endif
- if ((allocSize + OS_MEM_NODE_HEAD_SIZE + OS_MEM_ALIGN_SIZE) <= nodeSize) {
- node->sizeAndFlag = nodeSize;
- OsMemSpitNode(pool, node, allocSize);
- OS_MEM_NODE_SET_USED_FLAG(node->sizeAndFlag);
- if (pool == (VOID *)OS_SYS_MEM_ADDR) {
- OS_MEM_REDUCE_USED(nodeSize - allocSize, OS_MEM_TASKID_GET(node));
+ UINT32 nextSize;
+ struct OsMemNodeHead *nextNode = NULL;
+ struct OsMemNodeHead *sentinelNode = NULL;
+
+ sentinelNode = OS_MEM_END_NODE(pool, ((struct OsMemPoolHead *)pool)->info.totalSize);
+ while (sentinelNode != NULL) {
+ if (OsMemIsLastSentinelNode(sentinelNode)) {
+ PRINT_ERR("PreSentinelNodeGet can not find node %#x\n", node);
+ return NULL;
}
+ nextNode = OsMemSentinelNodeGet(sentinelNode);
+ if (nextNode == node) {
+ return sentinelNode;
+ }
+ nextSize = OS_MEM_NODE_GET_SIZE(sentinelNode->sizeAndFlag);
+ sentinelNode = OS_MEM_END_NODE(nextNode, nextSize);
+ }
+
+ return NULL;
+}
+
+STATIC INLINE BOOL TryShrinkPool(const VOID *pool, const struct OsMemNodeHead *node)
+{
+ struct OsMemNodeHead *mySentinel = NULL;
+ struct OsMemNodeHead *preSentinel = NULL;
+ size_t totalSize = (UINTPTR)node->ptr.prev - (UINTPTR)node;
+ size_t nodeSize = OS_MEM_NODE_GET_SIZE(node->sizeAndFlag);
+
+ if (nodeSize != totalSize) {
+ return FALSE;
+ }
+
+ preSentinel = PreSentinelNodeGet(pool, node);
+ if (preSentinel == NULL) {
+ return FALSE;
+ }
+
+ mySentinel = node->ptr.prev;
+ if (OsMemIsLastSentinelNode(mySentinel)) { /* prev node becomes sentinel node */
+ preSentinel->ptr.next = NULL;
+ OsMemSentinelNodeSet(preSentinel, NULL, 0);
+ } else {
+ preSentinel->sizeAndFlag = mySentinel->sizeAndFlag;
+ preSentinel->ptr.next = mySentinel->ptr.next;
+ }
+
+ if (OsMemLargeNodeFree(node) != LOS_OK) {
+ PRINT_ERR("TryShrinkPool free %#x failed!\n", node);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+STATIC INLINE INT32 OsMemPoolExpand(VOID *pool, UINT32 size, UINT32 intSave)
+{
+ UINT32 tryCount = MAX_SHRINK_PAGECACHE_TRY;
+ struct OsMemPoolHead *poolInfo = (struct OsMemPoolHead *)pool;
+ struct OsMemNodeHead *newNode = NULL;
+ struct OsMemNodeHead *endNode = NULL;
+
+ size = ROUNDUP(size + OS_MEM_NODE_HEAD_SIZE, PAGE_SIZE);
+ endNode = OS_MEM_END_NODE(pool, poolInfo->info.totalSize);
+
+RETRY:
+ newNode = (struct OsMemNodeHead *)LOS_PhysPagesAllocContiguous(size >> PAGE_SHIFT);
+ if (newNode == NULL) {
+ if (tryCount > 0) {
+ tryCount--;
+ MEM_UNLOCK(poolInfo, intSave);
+ OsTryShrinkMemory(size >> PAGE_SHIFT);
+ MEM_LOCK(poolInfo, intSave);
+ goto RETRY;
+ }
+
+ PRINT_ERR("OsMemPoolExpand alloc failed size = %u\n", size);
+ return -1;
+ }
+ newNode->sizeAndFlag = (size - OS_MEM_NODE_HEAD_SIZE);
+ newNode->ptr.prev = OS_MEM_END_NODE(newNode, size);
+ OsMemSentinelNodeSet(endNode, newNode, size);
+ OsMemFreeNodeAdd(pool, (struct OsMemFreeNodeHead *)newNode);
+
+ endNode = OS_MEM_END_NODE(newNode, size);
+ (VOID)memset_s(endNode, sizeof(*endNode), 0, sizeof(*endNode));
+ endNode->ptr.next = NULL;
+ endNode->magic = OS_MEM_NODE_MAGIC;
+ OsMemSentinelNodeSet(endNode, NULL, 0);
#if defined(OS_MEM_WATERLINE) && (OS_MEM_WATERLINE == YES)
- poolInfo->uwPoolCurUsedSize -= (nodeSize - allocSize);
+ poolInfo->poolCurUsedSize = sizeof(LosMemPoolInfo) + OS_MULTI_DLNK_HEAD_SIZE +
+ OS_MEM_NODE_GET_SIZE(endNode->sizeAndFlag);
+ poolInfo->poolWaterLine = poolInfo->poolCurUsedSize;
+#endif
+ return 0;
+}
+
+VOID LOS_MemExpandEnable(VOID *pool)
+{
+ if (pool == NULL) {
+ return;
+ }
+
+ ((struct OsMemPoolHead *)pool)->info.attr |= OS_MEM_POOL_EXPAND_ENABLE;
+}
+#endif
+
+STATIC INLINE UINT32 OsMemFreeListIndexGet(UINT32 size)
+{
+ UINT32 fl = OsMemFlGet(size);
+ if (fl < OS_MEM_SMALL_BUCKET_COUNT) {
+ return fl;
+ }
+
+ UINT32 sl = OsMemSlGet(size, fl);
+ return (OS_MEM_SMALL_BUCKET_COUNT + ((fl - OS_MEM_SMALL_BUCKET_COUNT) << OS_MEM_SLI) + sl);
+}
+
+STATIC INLINE struct OsMemFreeNodeHead *OsMemFindCurSuitableBlock(struct OsMemPoolHead *poolHead,
+ UINT32 index, UINT32 size)
+{
+ struct OsMemFreeNodeHead *node = NULL;
+
+ for (node = poolHead->freeList[index]; node != NULL; node = node->next) {
+ if (node->header.sizeAndFlag >= size) {
+ return node;
+ }
+ }
+
+ return NULL;
+}
+
+STATIC INLINE UINT32 OsMemNotEmptyIndexGet(struct OsMemPoolHead *poolHead, UINT32 index)
+{
+ UINT32 mask = poolHead->freeListBitmap[index >> 5]; /* 5: Divide by 32 to calculate the index of the bitmap array. */
+ mask &= ~((1 << (index & OS_MEM_BITMAP_MASK)) - 1);
+ if (mask != 0) {
+ index = OsMemFFS(mask) + (index & ~OS_MEM_BITMAP_MASK);
+ return index;
+ }
+
+ return OS_MEM_FREE_LIST_COUNT;
+}
+
+STATIC INLINE struct OsMemFreeNodeHead *OsMemFindNextSuitableBlock(VOID *pool, UINT32 size, UINT32 *outIndex)
+{
+ struct OsMemPoolHead *poolHead = (struct OsMemPoolHead *)pool;
+ UINT32 fl = OsMemFlGet(size);
+ UINT32 sl;
+ UINT32 index, tmp;
+ UINT32 curIndex = OS_MEM_FREE_LIST_COUNT;
+ UINT32 mask;
+
+ do {
+ if (fl < OS_MEM_SMALL_BUCKET_COUNT) {
+ index = fl;
+ } else {
+ sl = OsMemSlGet(size, fl);
+ curIndex = ((fl - OS_MEM_SMALL_BUCKET_COUNT) << OS_MEM_SLI) + sl + OS_MEM_SMALL_BUCKET_COUNT;
+ index = curIndex + 1;
+ }
+
+ tmp = OsMemNotEmptyIndexGet(poolHead, index);
+ if (tmp != OS_MEM_FREE_LIST_COUNT) {
+ index = tmp;
+ goto DONE;
+ }
+
+ for (index = LOS_Align(index + 1, 32); index < OS_MEM_FREE_LIST_COUNT; index += 32) {
+ mask = poolHead->freeListBitmap[index >> 5]; /* 5: Divide by 32 to calculate the index of the bitmap array. */
+ if (mask != 0) {
+ index = OsMemFFS(mask) + index;
+ goto DONE;
+ }
+ }
+ } while (0);
+
+ if (curIndex == OS_MEM_FREE_LIST_COUNT) {
+ return NULL;
+ }
+
+ *outIndex = curIndex;
+ return OsMemFindCurSuitableBlock(poolHead, curIndex, size);
+DONE:
+ *outIndex = index;
+ return poolHead->freeList[index];
+}
+
+STATIC INLINE VOID OsMemSetFreeListBit(struct OsMemPoolHead *head, UINT32 index)
+{
+ head->freeListBitmap[index >> 5] |= 1U << (index & 0x1f); /* 5: Divide by 32 to calculate the index of the bitmap array. */
+}
+
+STATIC INLINE VOID OsMemClearFreeListBit(struct OsMemPoolHead *head, UINT32 index)
+{
+ head->freeListBitmap[index >> 5] &= ~(1U << (index & 0x1f)); /* 5: Divide by 32 to calculate the index of the bitmap array. */
+}
+
+STATIC INLINE VOID OsMemListAdd(struct OsMemPoolHead *pool, UINT32 listIndex, struct OsMemFreeNodeHead *node)
+{
+ struct OsMemFreeNodeHead *firstNode = pool->freeList[listIndex];
+ if (firstNode != NULL) {
+ firstNode->prev = node;
+ }
+ node->next = firstNode;
+ pool->freeList[listIndex] = node;
+ OsMemSetFreeListBit(pool, listIndex);
+ node->header.magic = OS_MEM_NODE_MAGIC;
+}
+
+STATIC INLINE VOID OsMemListDelete(struct OsMemPoolHead *pool, UINT32 listIndex, struct OsMemFreeNodeHead *node)
+{
+ if (node == pool->freeList[listIndex]) {
+ pool->freeList[listIndex] = node->next;
+ if (node->next == NULL) {
+ OsMemClearFreeListBit(pool, listIndex);
+ }
+ } else {
+ node->prev->next = node->next;
+ if (node->next != NULL) {
+ node->next->prev = node->prev;
+ }
+ }
+ node->header.magic = OS_MEM_NODE_MAGIC;
+}
+
+STATIC INLINE VOID OsMemFreeNodeAdd(VOID *pool, struct OsMemFreeNodeHead *node)
+{
+ UINT32 index = OsMemFreeListIndexGet(node->header.sizeAndFlag);
+ if (index >= OS_MEM_FREE_LIST_COUNT) {
+ LOS_Panic("The index of free lists is error, index = %u\n", index);
+ }
+ OsMemListAdd(pool, index, node);
+}
+
+STATIC INLINE VOID OsMemFreeNodeDelete(VOID *pool, struct OsMemFreeNodeHead *node)
+{
+ UINT32 index = OsMemFreeListIndexGet(node->header.sizeAndFlag);
+ OsMemListDelete(pool, index, node);
+}
+
+STATIC INLINE struct OsMemNodeHead *OsMemFreeNodeGet(VOID *pool, UINT32 size)
+{
+ struct OsMemPoolHead *poolHead = (struct OsMemPoolHead *)pool;
+ UINT32 index;
+ struct OsMemFreeNodeHead *firstNode = OsMemFindNextSuitableBlock(pool, size, &index);
+ if (firstNode == NULL) {
+ return NULL;
+ }
+
+ OsMemListDelete(poolHead, index, firstNode);
+
+ return &firstNode->header;
+}
+
+STATIC INLINE VOID OsMemMergeNode(struct OsMemNodeHead *node)
+{
+ struct OsMemNodeHead *nextNode = NULL;
+
+ node->ptr.prev->sizeAndFlag += node->sizeAndFlag;
+ nextNode = (struct OsMemNodeHead *)((UINTPTR)node + node->sizeAndFlag);
+ if (!OS_MEM_NODE_GET_LAST_FLAG(nextNode->sizeAndFlag)) {
+ nextNode->ptr.prev = node->ptr.prev;
+ }
+}
+
+STATIC INLINE VOID OsMemSplitNode(VOID *pool, struct OsMemNodeHead *allocNode, UINT32 allocSize)
+{
+ struct OsMemFreeNodeHead *newFreeNode = NULL;
+ struct OsMemNodeHead *nextNode = NULL;
+
+ newFreeNode = (struct OsMemFreeNodeHead *)(VOID *)((UINT8 *)allocNode + allocSize);
+ newFreeNode->header.ptr.prev = allocNode;
+ newFreeNode->header.sizeAndFlag = allocNode->sizeAndFlag - allocSize;
+ allocNode->sizeAndFlag = allocSize;
+ nextNode = OS_MEM_NEXT_NODE(&newFreeNode->header);
+ if (!OS_MEM_NODE_GET_LAST_FLAG(nextNode->sizeAndFlag)) {
+ nextNode->ptr.prev = &newFreeNode->header;
+ if (!OS_MEM_NODE_GET_USED_FLAG(nextNode->sizeAndFlag)) {
+ OsMemFreeNodeDelete(pool, (struct OsMemFreeNodeHead *)nextNode);
+ OsMemMergeNode(nextNode);
+ }
+ }
+
+ OsMemFreeNodeAdd(pool, newFreeNode);
+}
+
+STATIC INLINE VOID *OsMemCreateUsedNode(VOID *addr)
+{
+ struct OsMemUsedNodeHead *node = (struct OsMemUsedNodeHead *)addr;
+
+#if OS_MEM_FREE_BY_TASKID
+ OsMemNodeSetTaskID(node);
+#endif
+
+ return node + 1;
+}
+
+STATIC UINT32 OsMemPoolInit(VOID *pool, UINT32 size)
+{
+ struct OsMemPoolHead *poolHead = (struct OsMemPoolHead *)pool;
+ struct OsMemNodeHead *newNode = NULL;
+ struct OsMemNodeHead *endNode = NULL;
+
+ (VOID)memset_s(poolHead, sizeof(struct OsMemPoolHead), 0, sizeof(struct OsMemPoolHead));
+
+ poolHead->info.pool = pool;
+ poolHead->info.totalSize = size;
+ poolHead->info.attr = OS_MEM_POOL_LOCK_ENABLE; /* default attr: lock, not expand. */
+
+ newNode = OS_MEM_FIRST_NODE(pool);
+ newNode->sizeAndFlag = (size - sizeof(struct OsMemPoolHead) - OS_MEM_NODE_HEAD_SIZE);
+ newNode->ptr.prev = NULL;
+ newNode->magic = OS_MEM_NODE_MAGIC;
+ OsMemFreeNodeAdd(pool, (struct OsMemFreeNodeHead *)newNode);
+
+ /* The last mem node */
+ endNode = OS_MEM_END_NODE(pool, size);
+ endNode->magic = OS_MEM_NODE_MAGIC;
+#if OS_MEM_EXPAND_ENABLE
+ endNode->ptr.next = NULL;
+ OsMemSentinelNodeSet(endNode, NULL, 0);
+#else
+ endNode->sizeAndFlag = 0;
+ endNode->ptr.prev = newNode;
+ OS_MEM_NODE_SET_USED_FLAG(endNode->sizeAndFlag);
+#endif
+
+ return LOS_OK;
+}
+
+#if (LOSCFG_MEM_MUL_POOL == 1)
+STATIC VOID OsMemPoolDeinit(VOID *pool)
+{
+ (VOID)memset_s(pool, sizeof(struct OsMemPoolHead), 0, sizeof(struct OsMemPoolHead));
+}
+
+STATIC UINT32 OsMemPoolAdd(VOID *pool, UINT32 size)
+{
+ VOID *nextPool = g_poolHead;
+ VOID *curPool = g_poolHead;
+ UINTPTR poolEnd;
+ while (nextPool != NULL) {
+ poolEnd = (UINTPTR)nextPool + LOS_MemPoolSizeGet(nextPool);
+ if (((pool <= nextPool) && (((UINTPTR)pool + size) > (UINTPTR)nextPool)) ||
+ (((UINTPTR)pool < poolEnd) && (((UINTPTR)pool + size) >= poolEnd))) {
+ PRINT_ERR("pool [%#x, %#x) conflict with pool [%#x, %#x)\n", (UINTPTR)pool,
+ (UINTPTR)pool + size, (UINTPTR)nextPool, (UINTPTR)nextPool + LOS_MemPoolSizeGet(nextPool));
+ return LOS_NOK;
+ }
+ curPool = nextPool;
+ nextPool = ((struct OsMemPoolHead *)nextPool)->nextPool;
+ }
+
+ if (g_poolHead == NULL) {
+ g_poolHead = pool;
+ } else {
+ ((struct OsMemPoolHead *)curPool)->nextPool = pool;
+ }
+
+ ((struct OsMemPoolHead *)pool)->nextPool = NULL;
+ return LOS_OK;
+}
+
+STATIC UINT32 OsMemPoolDelete(VOID *pool)
+{
+ UINT32 ret = LOS_NOK;
+ VOID *nextPool = NULL;
+ VOID *curPool = NULL;
+
+ do {
+ if (pool == g_poolHead) {
+ g_poolHead = ((struct OsMemPoolHead *)g_poolHead)->nextPool;
+ ret = LOS_OK;
+ break;
+ }
+
+ curPool = g_poolHead;
+ nextPool = g_poolHead;
+ while (nextPool != NULL) {
+ if (pool == nextPool) {
+ ((struct OsMemPoolHead *)curPool)->nextPool = ((struct OsMemPoolHead *)nextPool)->nextPool;
+ ret = LOS_OK;
+ break;
+ }
+ curPool = nextPool;
+ nextPool = ((struct OsMemPoolHead *)nextPool)->nextPool;
+ }
+ } while (0);
+
+ return ret;
+}
+#endif
+
+UINT32 LOS_MemInit(VOID *pool, UINT32 size)
+{
+ if ((pool == NULL) || (size <= OS_MEM_MIN_POOL_SIZE)) {
+ return OS_ERROR;
+ }
+
+ size = OS_MEM_ALIGN(size, OS_MEM_ALIGN_SIZE);
+ if (OsMemPoolInit(pool, size)) {
+ return OS_ERROR;
+ }
+
+#if (LOSCFG_MEM_MUL_POOL == 1)
+ if (OsMemPoolAdd(pool, size)) {
+ (VOID)OsMemPoolDeinit(pool);
+ return OS_ERROR;
+ }
+#endif
+
+#if OS_MEM_TRACE
+ LOS_TraceReg(LOS_TRACE_MEM_TIME, OsMemTimeTrace, LOS_TRACE_MEM_TIME_NAME, LOS_TRACE_ENABLE);
+ LOS_TraceReg(LOS_TRACE_MEM_INFO, OsMemInfoTrace, LOS_TRACE_MEM_INFO_NAME, LOS_TRACE_ENABLE);
+#endif
+
+ return LOS_OK;
+}
+
+#if (LOSCFG_MEM_MUL_POOL == 1)
+UINT32 LOS_MemDeInit(VOID *pool)
+{
+ if (pool == NULL) {
+ return OS_ERROR;
+ }
+
+ if (OsMemPoolDelete(pool)) {
+ return OS_ERROR;
+ }
+
+ OsMemPoolDeinit(pool);
+
+#if OS_MEM_TRACE
+ LOS_TraceUnreg(LOS_TRACE_MEM_TIME);
+ LOS_TraceUnreg(LOS_TRACE_MEM_INFO);
+#endif
+
+ return LOS_OK;
+}
+
+UINT32 LOS_MemPoolList(VOID)
+{
+ VOID *nextPool = g_poolHead;
+ UINT32 index = 0;
+ while (nextPool != NULL) {
+ PRINTK("pool%u :\n", index);
+ index++;
+ OsMemInfoPrint(nextPool);
+ nextPool = ((struct OsMemPoolHead *)nextPool)->nextPool;
+ }
+ return index;
+}
+#endif
+
+STATIC INLINE VOID *OsMemAlloc(struct OsMemPoolHead *pool, UINT32 size, UINT32 intSave)
+{
+ struct OsMemNodeHead *allocNode = NULL;
+ UINT32 allocSize = OS_MEM_ALIGN(size + OS_MEM_NODE_HEAD_SIZE, OS_MEM_ALIGN_SIZE);
+ if (allocSize == 0) {
+ return NULL;
+ }
+
+#if OS_MEM_EXPAND_ENABLE
+retry:
+#endif
+ allocNode = OsMemFreeNodeGet(pool, allocSize);
+ if (allocNode == NULL) {
+#if OS_MEM_EXPAND_ENABLE
+ if (pool->info.attr & OS_MEM_POOL_EXPAND_ENABLE) {
+ INT32 ret = OsMemPoolExpand(pool, allocSize, intSave);
+ if (ret == 0) {
+ goto retry;
+ }
+ }
+#endif
+ PRINT_ERR("---------------------------------------------------"
+ "--------------------------------------------------------\n");
+ MEM_UNLOCK(pool, intSave);
+ OsMemInfoPrint(pool);
+ MEM_LOCK(pool, intSave);
+ PRINT_ERR("[%s] No suitable free block, require free node size: 0x%x\n", __FUNCTION__, allocSize);
+ PRINT_ERR("----------------------------------------------------"
+ "-------------------------------------------------------\n");
+ return NULL;
+ }
+
+ if ((allocSize + OS_MEM_NODE_HEAD_SIZE + OS_MEM_MIN_ALLOC_SIZE) <= allocNode->sizeAndFlag) {
+ OsMemSplitNode(pool, allocNode, allocSize);
+ }
+
+ OS_MEM_NODE_SET_USED_FLAG(allocNode->sizeAndFlag);
+ return OsMemCreateUsedNode((VOID *)allocNode);
+}
+
+VOID *LOS_MemAlloc(VOID *pool, UINT32 size)
+{
+#if OS_MEM_TRACE
+ UINT64 start = HalClockGetCycles();
+#endif
+
+ if ((pool == NULL) || (size == 0)) {
+ return NULL;
+ }
+
+ if (size < OS_MEM_MIN_ALLOC_SIZE) {
+ size = OS_MEM_MIN_ALLOC_SIZE;
+ }
+
+ struct OsMemPoolHead *poolHead = (struct OsMemPoolHead *)pool;
+ VOID *ptr = NULL;
+ UINT32 intSave;
+
+ MEM_LOCK(poolHead, intSave);
+ do {
+ if (OS_MEM_NODE_GET_USED_FLAG(size) || OS_MEM_NODE_GET_ALIGNED_FLAG(size)) {
+ break;
+ }
+ ptr = OsMemAlloc(poolHead, size, intSave);
+ } while (0);
+ MEM_UNLOCK(poolHead, intSave);
+
+#if OS_MEM_TRACE
+ UINT64 end = HalClockGetCycles();
+ UINT32 timeUsed = MEM_TRACE_CYCLE_TO_US(end - start);
+ LOS_Trace(LOS_TRACE_MEM_TIME, (UINTPTR)pool & MEM_POOL_ADDR_MASK, MEM_TRACE_MALLOC, timeUsed);
+
+ LOS_MEM_POOL_STATUS poolStatus = {0};
+ (VOID)LOS_MemInfoGet(pool, &poolStatus);
+ UINT8 fragment = 100 - poolStatus.uwMaxFreeNodeSize * 100 / poolStatus.uwTotalFreeSize; /* 100: percent denominator. */
+ UINT8 usage = LOS_MemTotalUsedGet(pool) * 100 / LOS_MemPoolSizeGet(pool); /* 100: percent denominator. */
+ LOS_Trace(LOS_TRACE_MEM_INFO, (UINTPTR)pool & MEM_POOL_ADDR_MASK, fragment, usage, poolStatus.uwTotalFreeSize,
+ poolStatus.uwMaxFreeNodeSize, poolStatus.uwUsedNodeNum, poolStatus.uwFreeNodeNum);
+#endif
+
+ return ptr;
+}
+
+VOID *LOS_MemAllocAlign(VOID *pool, UINT32 size, UINT32 boundary)
+{
+#if OS_MEM_TRACE
+ UINT64 start = HalClockGetCycles();
+#endif
+
+ UINT32 gapSize;
+
+ if ((pool == NULL) || (size == 0) || (boundary == 0) || !OS_MEM_IS_POW_TWO(boundary) ||
+ !OS_MEM_IS_ALIGNED(boundary, sizeof(VOID *))) {
+ return NULL;
+ }
+
+ if (size < OS_MEM_MIN_ALLOC_SIZE) {
+ size = OS_MEM_MIN_ALLOC_SIZE;
+ }
+
+ /*
+ * sizeof(gapSize) bytes stores offset between alignedPtr and ptr,
+ * the ptr has been OS_MEM_ALIGN_SIZE(4 or 8) aligned, so maximum
+ * offset between alignedPtr and ptr is boundary - OS_MEM_ALIGN_SIZE
+ */
+ if ((boundary - sizeof(gapSize)) > ((UINT32)(-1) - size)) {
+ return NULL;
+ }
+
+ UINT32 useSize = (size + boundary) - sizeof(gapSize);
+ if (OS_MEM_NODE_GET_USED_FLAG(useSize) || OS_MEM_NODE_GET_ALIGNED_FLAG(useSize)) {
+ return NULL;
+ }
+
+ struct OsMemPoolHead *poolHead = (struct OsMemPoolHead *)pool;
+ UINT32 intSave;
+ VOID *ptr = NULL;
+ VOID *alignedPtr = NULL;
+
+ MEM_LOCK(poolHead, intSave);
+ do {
+ ptr = OsMemAlloc(pool, useSize, intSave);
+ alignedPtr = (VOID *)OS_MEM_ALIGN(ptr, boundary);
+ if (ptr == alignedPtr) {
+ break;
+ }
+
+ /* store gapSize in address (ptr - 4), it will be checked while free */
+ gapSize = (UINT32)((UINTPTR)alignedPtr - (UINTPTR)ptr);
+ struct OsMemUsedNodeHead *allocNode = (struct OsMemUsedNodeHead *)ptr - 1;
+ OS_MEM_NODE_SET_ALIGNED_FLAG(allocNode->header.sizeAndFlag);
+ OS_MEM_NODE_SET_ALIGNED_FLAG(gapSize);
+ *(UINT32 *)((UINTPTR)alignedPtr - sizeof(gapSize)) = gapSize;
+ ptr = alignedPtr;
+ } while (0);
+ MEM_UNLOCK(poolHead, intSave);
+
+#if OS_MEM_TRACE
+ UINT64 end = HalClockGetCycles();
+ UINT32 timeUsed = MEM_TRACE_CYCLE_TO_US(end - start);
+ LOS_Trace(LOS_TRACE_MEM_TIME, (UINTPTR)pool & MEM_POOL_ADDR_MASK, MEM_TRACE_MEMALIGN, timeUsed);
+#endif
+
+ return ptr;
+}
+
+STATIC INLINE BOOL OsMemAddrValidCheck(const struct OsMemPoolHead *pool, const VOID *addr)
+{
+ UINT32 size;
+
+ /* First node prev is NULL */
+ if (addr == NULL) {
+ return TRUE;
+ }
+
+ size = pool->info.totalSize;
+ if (OS_MEM_MIDDLE_ADDR_OPEN_END(pool + 1, addr, (UINTPTR)pool + size)) {
+ return TRUE;
+ }
+#if OS_MEM_EXPAND_ENABLE
+ struct OsMemNodeHead *node = NULL;
+ struct OsMemNodeHead *sentinel = OS_MEM_END_NODE(pool, size);
+ while (OsMemIsLastSentinelNode(sentinel) == FALSE) {
+ size = OS_MEM_NODE_GET_SIZE(sentinel->sizeAndFlag);
+ node = OsMemSentinelNodeGet(sentinel);
+ sentinel = OS_MEM_END_NODE(node, size);
+ if (OS_MEM_MIDDLE_ADDR_OPEN_END(node, addr, (UINTPTR)node + size)) {
+ return TRUE;
+ }
+ }
+#endif
+ return FALSE;
+}
+
+STATIC INLINE BOOL OsMemIsNodeValid(const struct OsMemNodeHead *node, const struct OsMemNodeHead *startNode,
+ const struct OsMemNodeHead *endNode,
+ const struct OsMemPoolHead *poolInfo)
+{
+ if (!OS_MEM_MIDDLE_ADDR(startNode, node, endNode)) {
+ return FALSE;
+ }
+
+ if (OS_MEM_NODE_GET_USED_FLAG(node->sizeAndFlag)) {
+ if (!OS_MEM_MAGIC_VALID(node)) {
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ if (!OsMemAddrValidCheck(poolInfo, node->ptr.prev)) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+STATIC UINT32 OsMemCheckUsedNode(const struct OsMemPoolHead *pool, const struct OsMemNodeHead *node)
+{
+ struct OsMemNodeHead *startNode = (struct OsMemNodeHead *)OS_MEM_FIRST_NODE(pool);
+ struct OsMemNodeHead *endNode = (struct OsMemNodeHead *)OS_MEM_END_NODE(pool, pool->info.totalSize);
+ struct OsMemNodeHead *nextNode = NULL;
+ BOOL doneFlag = FALSE;
+
+ do {
+ do {
+ if (!OsMemIsNodeValid(node, startNode, endNode, pool)) {
+ break;
+ }
+
+ if (!OS_MEM_NODE_GET_USED_FLAG(node->sizeAndFlag)) {
+ break;
+ }
+
+ nextNode = OS_MEM_NEXT_NODE(node);
+ if (!OsMemIsNodeValid(nextNode, startNode, endNode, pool)) {
+ break;
+ }
+
+ if (!OS_MEM_NODE_GET_LAST_FLAG(nextNode->sizeAndFlag)) {
+ if (nextNode->ptr.prev != node) {
+ break;
+ }
+ }
+
+ if ((node != startNode) &&
+ ((!OsMemIsNodeValid(node->ptr.prev, startNode, endNode, pool)) ||
+ (OS_MEM_NEXT_NODE(node->ptr.prev) != node))) {
+ break;
+ }
+ doneFlag = TRUE;
+ } while (0);
+
+ if (!doneFlag) {
+#if OS_MEM_EXPAND_ENABLE
+ if (OsMemIsLastSentinelNode(endNode) == FALSE) {
+ startNode = OsMemSentinelNodeGet(endNode);
+ endNode = OS_MEM_END_NODE(startNode, OS_MEM_NODE_GET_SIZE(endNode->sizeAndFlag));
+ continue;
+ }
+#endif
+ return LOS_NOK;
+ }
+ } while (!doneFlag);
+
+ return LOS_OK;
+}
+
+STATIC INLINE UINT32 OsMemFree(struct OsMemPoolHead *pool, struct OsMemNodeHead *node)
+{
+ UINT32 ret = OsMemCheckUsedNode(pool, node);
+ if (ret != LOS_OK) {
+ PRINT_ERR("OsMemFree check error!\n");
+ return ret;
+ }
+
+ node->sizeAndFlag = OS_MEM_NODE_GET_SIZE(node->sizeAndFlag);
+ struct OsMemNodeHead *preNode = node->ptr.prev; /* merage preNode */
+ if ((preNode != NULL) && !OS_MEM_NODE_GET_USED_FLAG(preNode->sizeAndFlag)) {
+ OsMemFreeNodeDelete(pool, (struct OsMemFreeNodeHead *)preNode);
+ OsMemMergeNode(node);
+ node = preNode;
+ }
+
+ struct OsMemNodeHead *nextNode = OS_MEM_NEXT_NODE(node); /* merage nextNode */
+ if ((nextNode != NULL) && !OS_MEM_NODE_GET_USED_FLAG(nextNode->sizeAndFlag)) {
+ OsMemFreeNodeDelete(pool, (struct OsMemFreeNodeHead *)nextNode);
+ OsMemMergeNode(nextNode);
+ }
+
+#if OS_MEM_EXPAND_ENABLE
+ if (pool->info.attr & OS_MEM_POOL_EXPAND_ENABLE) {
+ /* if this is a expand head node, and all unused, free it to pmm */
+ if ((node->ptr.prev != NULL) && (node->ptr.prev > node)) {
+ if (TryShrinkPool(pool, node)) {
+ return LOS_NOK;
+ }
+ }
+ }
+#endif
+ OsMemFreeNodeAdd(pool, (struct OsMemFreeNodeHead *)node);
+
+ return ret;
+}
+
+UINT32 LOS_MemFree(VOID *pool, VOID *ptr)
+{
+#if OS_MEM_TRACE
+ UINT64 start = HalClockGetCycles();
+#endif
+
+ if ((pool == NULL) || (ptr == NULL) || !OS_MEM_IS_ALIGNED(pool, sizeof(VOID *)) ||
+ !OS_MEM_IS_ALIGNED(ptr, sizeof(VOID *))) {
+ return LOS_NOK;
+ }
+
+ UINT32 ret = LOS_NOK;
+ struct OsMemPoolHead *poolHead = (struct OsMemPoolHead *)pool;
+ struct OsMemNodeHead *node = NULL;
+ UINT32 intSave;
+
+ MEM_LOCK(poolHead, intSave);
+ do {
+ UINT32 gapSize = *(UINT32 *)((UINTPTR)ptr - sizeof(UINT32));
+ if (OS_MEM_NODE_GET_ALIGNED_FLAG(gapSize) && OS_MEM_NODE_GET_USED_FLAG(gapSize)) {
+ PRINT_ERR("[%s:%d]gapSize:0x%x error\n", __FUNCTION__, __LINE__, gapSize);
+ break;
+ }
+
+ node = (struct OsMemNodeHead *)((UINTPTR)ptr - OS_MEM_NODE_HEAD_SIZE);
+
+ if (OS_MEM_NODE_GET_ALIGNED_FLAG(gapSize)) {
+ gapSize = OS_MEM_NODE_GET_ALIGNED_GAPSIZE(gapSize);
+ if ((gapSize & (OS_MEM_ALIGN_SIZE - 1)) || (gapSize > ((UINTPTR)ptr - OS_MEM_NODE_HEAD_SIZE))) {
+ PRINT_ERR("illegal gapSize: 0x%x\n", gapSize);
+ break;
+ }
+ node = (struct OsMemNodeHead *)((UINTPTR)ptr - gapSize - OS_MEM_NODE_HEAD_SIZE);
+ }
+ ret = OsMemFree(poolHead, node);
+ } while (0);
+ MEM_UNLOCK(poolHead, intSave);
+
+#if OS_MEM_TRACE
+ UINT64 end = HalClockGetCycles();
+ UINT32 timeUsed = MEM_TRACE_CYCLE_TO_US(end - start);
+ LOS_Trace(LOS_TRACE_MEM_TIME, (UINTPTR)pool & MEM_POOL_ADDR_MASK, MEM_TRACE_FREE, timeUsed);
+#endif
+
+ return ret;
+}
+
+STATIC INLINE VOID OsMemReAllocSmaller(VOID *pool, UINT32 allocSize, struct OsMemNodeHead *node, UINT32 nodeSize)
+{
+#if defined(OS_MEM_WATERLINE) && (OS_MEM_WATERLINE == YES)
+ struct OsMemPoolHead *poolInfo = (struct OsMemPoolHead *)pool;
+#endif
+ if ((allocSize + OS_MEM_NODE_HEAD_SIZE + OS_MEM_MIN_ALLOC_SIZE) <= nodeSize) {
+ OsMemSplitNode(pool, node, allocSize);
+ OS_MEM_NODE_SET_USED_FLAG(node->sizeAndFlag);
+#if defined(OS_MEM_WATERLINE) && (OS_MEM_WATERLINE == YES)
+ poolInfo->poolCurUsedSize -= nodeSize - allocSize;
#endif
}
}
-/*****************************************************************************
- Function : OsMemMergeNodeForReAllocBigger
- Description : reAlloc a Bigger memory node after merge node and nextNode
- Input : pool --- Pointer to memory pool
- allocSize --- the size of new node which will be alloced
- node --- the node which wille be realloced
- nodeSize --- the size of old node
- nextNode --- pointer next node which will be merged
- Output : node --- pointer to the new node after realloc
- Return : None
-*****************************************************************************/
-STATIC_INLINE VOID OsMemMergeNodeForReAllocBigger(VOID *pool, UINT32 allocSize,
- LosMemDynNode *node, UINT32 nodeSize, LosMemDynNode *nextNode)
+STATIC INLINE VOID OsMemMergeNodeForReAllocBigger(VOID *pool, UINT32 allocSize, struct OsMemNodeHead *node,
+ UINT32 nodeSize, struct OsMemNodeHead *nextNode)
{
#if defined(OS_MEM_WATERLINE) && (OS_MEM_WATERLINE == YES)
- LOS_MEM_POOL_INFO *poolInfo = (LOS_MEM_POOL_INFO *)pool;
+ struct OsMemPoolHead *poolInfo = (struct OsMemPoolHead *)pool;
#endif
+
node->sizeAndFlag = nodeSize;
- LOS_ListDelete(&(nextNode->freeNodeInfo));
+ OsMemFreeNodeDelete(pool, (struct OsMemFreeNodeHead *)nextNode);
OsMemMergeNode(nextNode);
- if ((allocSize + OS_MEM_NODE_HEAD_SIZE + OS_MEM_ALIGN_SIZE) <= node->sizeAndFlag) {
- OsMemSpitNode(pool, node, allocSize);
+ if ((allocSize + OS_MEM_NODE_HEAD_SIZE + OS_MEM_MIN_ALLOC_SIZE) <= node->sizeAndFlag) {
+ OsMemSplitNode(pool, node, allocSize);
}
#if defined(OS_MEM_WATERLINE) && (OS_MEM_WATERLINE == YES)
- poolInfo->uwPoolCurUsedSize += (node->sizeAndFlag - nodeSize);
- if (poolInfo->uwPoolCurUsedSize > poolInfo->uwPoolWaterLine) {
- poolInfo->uwPoolWaterLine = poolInfo->uwPoolCurUsedSize;
+ poolInfo->poolCurUsedSize += (node->sizeAndFlag - nodeSize);
+ if (poolInfo->poolCurUsedSize > poolInfo->poolWaterLine) {
+ poolInfo->poolWaterLine = poolInfo->poolCurUsedSize;
}
#endif
- if (pool == (VOID *)OS_SYS_MEM_ADDR) {
- OS_MEM_ADD_USED(node->sizeAndFlag - nodeSize, OS_MEM_TASKID_GET(node));
- }
- OS_MEM_NODE_SET_USED_FLAG(node->sizeAndFlag);
}
-STATIC_INLINE VOID *OsMemReallocMem(VOID *pool, const VOID *ptr, UINT32 size, LosMemDynNode *node)
+STATIC INLINE VOID *OsGetRealPtr(const VOID *pool, VOID *ptr)
{
- errno_t rc;
- VOID *newPtr = NULL;
- UINT32 allocSize, nodeSize;
- LosMemDynNode *nextNode = NULL;
+ VOID *realPtr = ptr;
+ UINT32 gapSize = *((UINT32 *)((UINTPTR)ptr - sizeof(UINT32)));
+
+ if (OS_MEM_NODE_GET_ALIGNED_FLAG(gapSize) && OS_MEM_NODE_GET_USED_FLAG(gapSize)) {
+ PRINT_ERR("[%s:%d]gapSize:0x%x error\n", __FUNCTION__, __LINE__, gapSize);
+ return NULL;
+ }
+ if (OS_MEM_NODE_GET_ALIGNED_FLAG(gapSize)) {
+ gapSize = OS_MEM_NODE_GET_ALIGNED_GAPSIZE(gapSize);
+ if ((gapSize & (OS_MEM_ALIGN_SIZE - 1)) ||
+ (gapSize > ((UINTPTR)ptr - OS_MEM_NODE_HEAD_SIZE - (UINTPTR)pool))) {
+ PRINT_ERR("[%s:%d]gapSize:0x%x error\n", __FUNCTION__, __LINE__, gapSize);
+ return NULL;
+ }
+ realPtr = (VOID *)((UINTPTR)ptr - (UINTPTR)gapSize);
+ }
+ return realPtr;
+}
+
+STATIC INLINE VOID *OsMemRealloc(struct OsMemPoolHead *pool, const VOID *ptr,
+ struct OsMemNodeHead *node, UINT32 size, UINT32 intSave)
+{
+ struct OsMemNodeHead *nextNode = NULL;
+ UINT32 allocSize = OS_MEM_ALIGN(size + OS_MEM_NODE_HEAD_SIZE, OS_MEM_ALIGN_SIZE);
+ UINT32 nodeSize = OS_MEM_NODE_GET_SIZE(node->sizeAndFlag);
+ VOID *tmpPtr = NULL;
- allocSize = OS_MEM_ALIGN(size + OS_MEM_NODE_HEAD_SIZE, OS_MEM_ALIGN_SIZE);
- nodeSize = OS_MEM_NODE_GET_SIZE(node->sizeAndFlag);
if (nodeSize >= allocSize) {
OsMemReAllocSmaller(pool, allocSize, node, nodeSize);
return (VOID *)ptr;
}
nextNode = OS_MEM_NEXT_NODE(node);
- if ((!OS_MEM_NODE_GET_USED_FLAG(nextNode->sizeAndFlag)) &&
+ if (!OS_MEM_NODE_GET_USED_FLAG(nextNode->sizeAndFlag) &&
((nextNode->sizeAndFlag + nodeSize) >= allocSize)) {
OsMemMergeNodeForReAllocBigger(pool, allocSize, node, nodeSize, nextNode);
return (VOID *)ptr;
}
- newPtr = OsMemAllocWithCheck(pool, size);
- if (newPtr != NULL) {
- rc = memcpy_s(newPtr, size, ptr, nodeSize - OS_MEM_NODE_HEAD_SIZE);
- if (rc != EOK) {
- PRINT_ERR("%s[%d] memcpy_s failed, error type = %d\n", __FUNCTION__, __LINE__, rc);
+ tmpPtr = OsMemAlloc(pool, size, intSave);
+ if (tmpPtr != NULL) {
+ if (memcpy_s(tmpPtr, size, ptr, (nodeSize - OS_MEM_NODE_HEAD_SIZE)) != EOK) {
+ MEM_UNLOCK(pool, intSave);
+ (VOID)LOS_MemFree((VOID *)pool, (VOID *)tmpPtr);
+ MEM_LOCK(pool, intSave);
+ return NULL;
}
- OsMemFreeNode(node, pool);
+ (VOID)OsMemFree(pool, node);
}
- return newPtr;
-
-}
-/*****************************************************************************
- Function : LOS_MemPoolSizeGet
- Description : get the memory pool's size
- Input : pool --- Pointer to memory pool
- Output : LOS_NOK & Other value --- The size of the memory pool.
- Return : the size of the memory pool
-*****************************************************************************/
-UINT32 LOS_MemPoolSizeGet(const VOID *pool)
-{
- if (pool == NULL) {
- return LOS_NOK;
- }
- return ((LOS_MEM_POOL_INFO *)pool)->uwPoolSize;
+ return tmpPtr;
}
-STATIC_INLINE UINT32 OsMemMulPoolInit(VOID *pool, UINT32 size)
+VOID *LOS_MemRealloc(VOID *pool, VOID *ptr, UINT32 size)
{
- VOID *next = g_memPoolHead;
- VOID *cur = NULL;
- UINT32 poolEnd;
-
- while (next != NULL) {
- poolEnd = (UINTPTR)next + LOS_MemPoolSizeGet(next);
- if ((((pool <= next) && ((UINTPTR)pool + size)) > (UINTPTR)next) ||
- (((UINTPTR)pool < poolEnd) && (((UINTPTR)pool + size) >= poolEnd))) {
- PRINT_ERR("pool [0x%x, 0x%x) conflict with pool [0x%x, 0x%x)\n",
- (UINT32)(UINTPTR)pool, (UINT32)(UINTPTR)pool + size,
- (UINT32)(UINTPTR)next, (UINT32)(UINTPTR)next + LOS_MemPoolSizeGet(next));
- return OS_ERROR;
- }
- cur = next;
- next = ((LOS_MEM_POOL_INFO *)next)->pNextPool;
- }
-
- if (g_memPoolHead == NULL) {
- g_memPoolHead = pool;
- } else {
- ((LOS_MEM_POOL_INFO *)cur)->pNextPool = pool;
- }
-
- ((LOS_MEM_POOL_INFO *)pool)->pNextPool = NULL;
- return LOS_OK;
-}
-/*****************************************************************************
- Function : LOS_MemInit
- Description : Initialize Dynamic Memory pool
- Input : pool --- Pointer to memory pool
- size --- Size of memory in bytes to allocate
- Output : None
- Return : LOS_OK --- Ok, OS_ERROR --- Error
-*****************************************************************************/
-LITE_OS_SEC_TEXT_INIT UINT32 LOS_MemInit(VOID *pool, UINT32 size)
-{
- LosMemDynNode *newNode = (LosMemDynNode *)NULL;
- LosMemDynNode *endNode = (LosMemDynNode *)NULL;
- LOS_MEM_POOL_INFO *poolInfo = (LOS_MEM_POOL_INFO *)NULL;
- UINTPTR intSave;
- LOS_DL_LIST *listHead = (LOS_DL_LIST *)NULL;
-#if (LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK == YES)
- UINT32 *memCount = (UINT32 *)g_memMang;
- MEM_INFO *memInfo = (MEM_INFO *)(g_memMang + sizeof(UINT32));
- UINT8 loop;
+#if OS_MEM_TRACE
+ UINT64 start = HalClockGetCycles();
#endif
- if ((pool == NULL) || (size < OS_MEM_MIN_POOL_SIZE)) {
- return OS_ERROR;
- }
-
-#if (LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK == YES)
- intSave = LOS_IntLock();
- for (loop = 0; loop < *memCount; loop++) {
- if (memInfo->uwStartAddr == (UINT32)(UINTPTR)pool) {
- (*memCount)--;
- break;
- }
- memInfo++;
- }
- if (*memCount < OS_SYS_MEM_NUM) {
- memInfo->uwType = MEM_MANG_MEMORY;
- memInfo->uwStartAddr = (UINT32)(UINTPTR)pool;
- memInfo->uwSize = size;
- (*memCount)++;
- }
- LOS_IntRestore(intSave);
-#endif
- intSave = LOS_IntLock();
-
- poolInfo = (LOS_MEM_POOL_INFO *)pool;
- poolInfo->pPoolAddr = pool;
- poolInfo->uwPoolSize = size;
- OS_DLNK_INIT_HEAD(OS_MEM_HEAD_ADDR(pool));
- newNode = OS_MEM_FIRST_NODE(pool);
- newNode->sizeAndFlag = ((size - ((UINTPTR)newNode - (UINTPTR)pool)) - OS_MEM_NODE_HEAD_SIZE);
- newNode->preNode = (LosMemDynNode *)NULL;
- listHead = OS_MEM_HEAD(pool, newNode->sizeAndFlag);
- if (listHead == NULL) {
- LOS_IntRestore(intSave);
- return OS_ERROR;
- }
-
- LOS_ListTailInsert(listHead, &(newNode->freeNodeInfo));
- endNode = (LosMemDynNode *)OS_MEM_END_NODE(pool, size);
- // Ignore the return code when matching CSEC rule 6.6(4).
- (VOID)memset_s(endNode, sizeof(*endNode), 0, sizeof(*endNode));
- endNode->preNode = newNode;
- endNode->sizeAndFlag = OS_MEM_NODE_HEAD_SIZE;
- OS_MEM_NODE_SET_USED_FLAG(endNode->sizeAndFlag);
- OsMemSetMagicNumAndTaskid(endNode);
-#if defined(OS_MEM_WATERLINE) && (OS_MEM_WATERLINE == YES)
- poolInfo->uwPoolCurUsedSize = sizeof(LOS_MEM_POOL_INFO) +
- OS_MULTI_DLNK_HEAD_SIZE + OS_MEM_NODE_GET_SIZE(endNode->sizeAndFlag);
- poolInfo->uwPoolWaterLine = poolInfo->uwPoolCurUsedSize;
-#endif
-
-#if (LOSCFG_MEM_MUL_POOL == YES)
- UINT32 ret = OsMemMulPoolInit(pool, size);
- if (ret != LOS_OK) {
- LOS_IntRestore(intSave);
- return ret;
- }
-#endif
-
- LOS_IntRestore(intSave);
-
- return LOS_OK;
-}
-
-#if (LOSCFG_MEM_MUL_POOL == YES)
-LITE_OS_SEC_TEXT_INIT UINT32 LOS_MemDeInit(const VOID *pool)
-{
- UINTPTR intSave;
- UINTPTR ret = LOS_NOK;
- VOID *next = NULL;
- VOID *cur = NULL;
-
- intSave = LOS_IntLock();
- do {
- if (pool == NULL) {
- break;
- }
-
- if (pool == g_memPoolHead) {
- g_memPoolHead = ((LOS_MEM_POOL_INFO *)g_memPoolHead)->pNextPool;
- ret = LOS_OK;
- break;
- }
-
- cur = g_memPoolHead;
- next = g_memPoolHead;
-
- while (next != NULL) {
- if (pool == next) {
- ((LOS_MEM_POOL_INFO *)cur)->pNextPool = ((LOS_MEM_POOL_INFO *)next)->pNextPool;
- ret = LOS_OK;
- break;
- }
- cur = next;
- next = ((LOS_MEM_POOL_INFO *)next)->pNextPool;
- }
- } while (0);
-
- LOS_IntRestore(intSave);
- return ret;
-}
-
-LITE_OS_SEC_TEXT_INIT UINT32 LOS_MemPoolList(VOID)
-{
- VOID *next = g_memPoolHead;
- UINT32 index = 0;
- while (next != NULL) {
- PRINTK("pool%u :\n", index);
- index++;
- OsMemInfoPrint(next);
- next = ((LOS_MEM_POOL_INFO *)next)->pNextPool;
- }
- return index;
-}
-#endif
-
-#ifdef LOS_MEM_LEAK_CHECK
-LITE_OS_SEC_TEXT VOID LOS_CheckMaxcount(VOID)
-{
- if (g_memCheckFlag == 1) {
- PRINTK("\nIt's checking the maxcount now, please waiting!\n");
- return;
- }
- PRINTK("\nthe max malloc count :%d\nplease set the CHECK_MAXCOUNT bigger than %d!\n",
- g_memPeakCount, g_memPeakCount);
-}
-
-LITE_OS_SEC_TEXT VOID LOS_MemLeakCheckStart(VOID)
-{
- UINT32 ret;
- UINTPTR intSave;
- errno_t rc;
-
- intSave = LOS_IntLock();
- rc = memset_s(g_checkInfo, CHECK_MAXCOUNT, 0, MEM_CHECK_MAX_SIZE);
- if (rc != EOK) {
- PRINT_ERR("%s[%d] memset_s failed, error type = %d\n", __FUNCTION__, __LINE__, rc);
- LOS_IntRestore(intSave);
- return;
- }
- ret = LOS_MemboxInit(g_checkInfo, MEM_CHECK_MAX_SIZE, MEM_CHECK_SIZE);
- if (ret != LOS_OK) {
- PRINT_ERR("\nLOS_MemboxInit failed!\n");
- LOS_IntRestore(intSave);
- return;
- }
- g_memCount = 0;
- g_memPeakCount = 0;
- g_memCheckFlag = 1;
- LOS_IntRestore(intSave);
-}
-
-INLINE VOID OsMemCheckinfoCreate(VOID *ptr, UINT32 size)
-{
- UINT32 fp;
- UINT32 i = 0;
- UINT32 tmpFp;
- UINT32 backLR;
- MEM_CHECK_INFO *check = NULL;
- UINTPTR intSave;
-
- fp = Get_Fp();
- intSave = LOS_IntLock();
- g_memCount++;
- if (g_memCount > g_memPeakCount) {
- g_memPeakCount = g_memCount;
- }
- LOS_IntRestore(intSave);
-
- check = (MEM_CHECK_INFO *)LOS_MemboxAlloc(g_checkInfo);
- if (check == NULL) {
- PRINTK("memboxalloc is failure:%s[%d]\r\n", __FUNCTION__, __LINE__);
- return;
- }
-
- (void)memset_s(check, sizeof(MEM_CHECK_INFO), 0, sizeof(MEM_CHECK_INFO));
- check->pPoolAddr = ptr;
- while ((fp > OS_SYS_FUNC_ADDR_START) && (fp < OS_SYS_FUNC_ADDR_END)) {
- tmpFp = fp;
- backLR = *((UINT32 *)(fp));
- fp = *((UINT32 *)(tmpFp - OS_MEM_NODE_DATA_SIZE));
- if (i > 0) {
- check->fp[i - 1] = backLR;
- }
- i++;
- if (i == (OS_MEM_NODE_DATA_SIZE + 1)) {
- break;
- }
- }
- check->flag = 1;
- check->uwAddrSize = size;
- return;
-}
-
-INLINE VOID OsMemCheckinfoDel(VOID *nodePtr)
-{
- UINT32 i;
- UINT32 ret;
- UINTPTR intSave;
- LOS_MEMBOX_INFO *boxInfo = (LOS_MEMBOX_INFO *)g_checkInfo;
- LOS_MEMBOX_NODE *node = (LOS_MEMBOX_NODE *)NULL;
-
- intSave = LOS_IntLock();
- g_memCount--;
- node = (LOS_MEMBOX_NODE *)(boxInfo + 1);
- for (i = 0; i < boxInfo->uwBlkNum; ++i, node = OS_MEMBOX_NEXT(node, boxInfo->uwBlkSize)) {
- if (*(UINT32 *)((UINTPTR)node + OS_CHECK_FLAG) != 1) {
- continue;
- }
-
- if ((UINTPTR)nodePtr == *((UINT32 *)node)) {
- ret = LOS_MemboxFree(g_checkInfo, node);
- if (ret != LOS_OK) {
- PRINTK("free membox failed!\n");
- }
- *(UINT32 *)((UINTPTR)node + OS_CHECK_FLAG) = 0;
- LOS_IntRestore(intSave);
- return;
- }
- }
- LOS_IntRestore(intSave);
-}
-
-LITE_OS_SEC_TEXT VOID LOS_MemLeakCheckEnd(VOID)
-{
- UINTPTR intSave;
-
- intSave = LOS_IntLock();
- g_memCheckFlag = 0;
- LOS_IntRestore(intSave);
-}
-
-LITE_OS_SEC_TEXT VOID LOS_MemLeakCheckShow(VOID)
-{
- UINT32 i;
- UINT32 j;
- UINTPTR intSave;
- LOS_MEMBOX_INFO *boxInfo = (LOS_MEMBOX_INFO *)g_checkInfo;
- LOS_MEMBOX_NODE *node = (LOS_MEMBOX_NODE *)NULL;
-
- intSave = LOS_IntLock();
-
- if (g_memCheckFlag == 1) {
- PRINTK("\nIt's checking mem used now, please waiting!\n");
- LOS_IntRestore(intSave);
- return;
- }
-
- PRINTK("\n\n **********************all mem used list**********************\r\n");
- PRINTK(" ID lr0 lr1 lr2 lr3 MemSize MemAddr\n");
- PRINTK("---------------------------------------------------------------------------------\n");
- node = (LOS_MEMBOX_NODE *)(boxInfo + 1);
- for (i = 0, j = 0; i < boxInfo->uwBlkNum; ++i, node = OS_MEMBOX_NEXT(node, boxInfo->uwBlkSize)) {
- if ((*(UINT32 *)((UINTPTR)node + OS_CHECK_FLAG)) == 1) {
- PRINTK(" %-3d 0x%-11x0x%-11x0x%-11x0x%-11x0x%-11x0x%-11x\n", j,
- *(UINT32 *)((UINTPTR)node + OS_CHECK_FP0), *(UINT32 *)((UINTPTR)node + OS_CHECK_FP1),
- *(UINT32 *)((UINTPTR)node + OS_CHECK_FP2), *(UINT32 *)((UINTPTR)node + OS_CHECK_FP3),
- *(UINT32 *)((UINTPTR)node + OS_ADDR_SIZE), *(UINT32 *)(UINTPTR)node);
- j++;
- }
- }
- LOS_IntRestore(intSave);
- if (j == 0) {
- PRINTK("************************no mem leak!!!************************\n");
- return;
- }
- PRINTK("---------------------------------------------------------------------------------\n");
-}
-
-#endif
-
-/*****************************************************************************
- Function : LOS_MemAlloc
- Description : Allocate node from Memory pool
- Input : pool --- Pointer to memory pool
- size --- Size of memory in bytes to allocate
- Output : None
- Return : Pointer to allocated memory node
-*****************************************************************************/
-LITE_OS_SEC_TEXT VOID *LOS_MemAlloc(VOID *pool, UINT32 size)
-{
- VOID *ptr = NULL;
- UINTPTR intSave = LOS_IntLock();
-
- do {
- if ((pool == NULL) || (size == 0)) {
- break;
- }
-
- if (OS_MEM_NODE_GET_USED_FLAG(size)) {
- break;
- }
-
- ptr = OsMemAllocWithCheck(pool, size);
-
-#ifdef LOS_MEM_LEAK_CHECK
- if (g_memCheckFlag == 1) {
- OsMemCheckinfoCreate(ptr, size);
- }
-#endif
- } while (0);
-
- LOS_IntRestore(intSave);
- return ptr;
-}
-
-/*****************************************************************************
- Function : LOS_MemAllocAlign
- Description : align size then allocate node from Memory pool
- Input : pool --- Pointer to memory pool
- size --- Size of memory in bytes to allocate
- boundary --- align form
- Output : None
- Return : Pointer to allocated memory node
-*****************************************************************************/
-LITE_OS_SEC_TEXT VOID *LOS_MemAllocAlign(VOID *pool, UINT32 size, UINT32 boundary)
-{
- UINT32 useSize;
- UINT32 gapSize;
- VOID *ptr = NULL;
- VOID *alignedPtr = NULL;
- UINTPTR intSave = LOS_IntLock();
-
- do {
- if ((pool == NULL) || (size == 0) || (boundary < sizeof(VOID *)) || !IS_ALIGNED(boundary)) {
- break;
- }
-
- useSize = size + boundary + 4; /* 4bytes stores offset between alignedPtr and ptr */
-
- if ((useSize < size) || OS_MEM_NODE_GET_USED_FLAG(useSize)) {
- break;
- }
-
- ptr = OsMemAllocWithCheck(pool, useSize);
-
- alignedPtr = (VOID *)(UINTPTR)OS_MEM_ALIGN(ptr, boundary);
-
- if (ptr == alignedPtr) {
- break;
- }
-
- gapSize = (UINTPTR)alignedPtr - (UINTPTR)ptr; /* store gapSize in address (ptr -4),
- it will be checked while free */
- OS_MEM_NODE_SET_ALIGNED_FLAG(gapSize);
- *((UINT32 *)((UINTPTR)alignedPtr - OS_MEM_NODE_DATA_SIZE)) = gapSize;
-
- ptr = alignedPtr;
-
-#ifdef LOS_MEM_LEAK_CHECK
- if (g_memCheckFlag == 1) {
- OsMemCheckinfoCreate(ptr, size);
- }
-#endif
- } while (0);
-
- LOS_IntRestore(intSave);
-
- return ptr;
-}
-
-/*****************************************************************************
- Function : LOS_MemFree
- Description : free the node from memory & if there are free node beside, merger them.
- at last update "listHead" which saved all free node control head
- Input : pool --- Pointer to memory pool
- ptr --- the node which need be freed
- Output : None
- Return : LOS_OK --- OK, LOS_NOK --- failed
-*****************************************************************************/
-LITE_OS_SEC_TEXT UINT32 LOS_MemFree(VOID *pool, VOID *ptr)
-{
- UINT32 ret = LOS_NOK;
- UINTPTR intSave = LOS_IntLock();
-#ifdef LOS_MEM_LEAK_CHECK
- VOID *p = ptr;
-#endif
- do {
- LosMemDynNode *node = (LosMemDynNode *)NULL;
-
- if ((pool == NULL) || (ptr == NULL)) {
- break;
- }
-
- node = OsMemGetNodeFromPtr(ptr);
-
- ret = OsMemCheckUsedNode(pool, node);
- if (ret == LOS_OK) {
- OsMemFreeNode(node, pool);
-#ifdef LOS_MEM_LEAK_CHECK
- if (g_memCheckFlag == 1) {
- OsMemCheckinfoDel(p);
- }
-#endif
- }
-
- } while (0);
-
- LOS_IntRestore(intSave);
- return ret;
-}
-
-/*****************************************************************************
- Function : LOS_MemRealloc
- Description : reAlloc memory node
- Input : pool --- Pointer to memory pool
- ptr --- pointer to memory node which will be realloced
- size --- the size of new node
- Output : None
- Return : Pointer to allocated memory
-*****************************************************************************/
-LITE_OS_SEC_TEXT_MINOR VOID *LOS_MemRealloc(VOID *pool, VOID *ptr, UINT32 size)
-{
- VOID *newPtr = NULL;
-
- if ((INT32)size < 0) {
+ if ((pool == NULL) || OS_MEM_NODE_GET_USED_FLAG(size) || OS_MEM_NODE_GET_ALIGNED_FLAG(size)) {
return NULL;
}
- UINTPTR intSave = LOS_IntLock();
+ if (size < OS_MEM_MIN_ALLOC_SIZE) {
+ size = OS_MEM_MIN_ALLOC_SIZE;
+ }
+ if (ptr == NULL) {
+ return LOS_MemAlloc(pool, size);
+ }
+
+ if (size == 0) {
+ (VOID)LOS_MemFree(pool, ptr);
+ return NULL;
+ }
+
+ struct OsMemPoolHead *poolHead = (struct OsMemPoolHead *)pool;
+ struct OsMemNodeHead *node = NULL;
+ VOID *newPtr = NULL;
+ UINT32 intSave;
+
+ MEM_LOCK(poolHead, intSave);
do {
- LosMemDynNode *node = (LosMemDynNode *)NULL;
- UINT32 ret;
-
- if (size == 0) {
- (VOID)LOS_MemFree((VOID *)pool, (VOID *)ptr);
- break;
- }
-
+ ptr = OsGetRealPtr(pool, ptr);
if (ptr == NULL) {
- newPtr = LOS_MemAlloc((VOID *)pool, (UINT32)size);
- if (newPtr == NULL) {
- break;
- }
- (VOID)memset_s(newPtr, (UINT32)size, 0, (UINT32)size);
break;
}
- node = OsMemGetNodeFromPtr(ptr);
-
- ret = OsMemCheckUsedNode(pool, node);
- if (ret != LOS_OK) {
+ node = (struct OsMemNodeHead *)((UINTPTR)ptr - OS_MEM_NODE_HEAD_SIZE);
+ if (OsMemCheckUsedNode(pool, node) != LOS_OK) {
break;
}
- newPtr = OsMemReallocMem(pool, ptr, size, node);
+ newPtr = OsMemRealloc(pool, ptr, node, size, intSave);
} while (0);
+ MEM_UNLOCK(poolHead, intSave);
+
+#if OS_MEM_TRACE
+ UINT64 end = HalClockGetCycles();
+ UINT32 timeUsed = MEM_TRACE_CYCLE_TO_US(end - start);
+ LOS_Trace(LOS_TRACE_MEM_TIME, (UINTPTR)pool & MEM_POOL_ADDR_MASK, MEM_TRACE_REALLOC, timeUsed);
+#endif
- LOS_IntRestore(intSave);
return newPtr;
}
-/*****************************************************************************
- Function : LOS_MemTotalUsedGet
- Description : figure the pointer memory pool for it's total mem used
- Input : pool --- Pointer to memory pool
- Output : None
- Return : the size of the pool has been used
-*****************************************************************************/
-LITE_OS_SEC_TEXT_MINOR UINT32 LOS_MemTotalUsedGet(VOID *pool)
+#if OS_MEM_FREE_BY_TASKID
+UINT32 LOS_MemFreeByTaskID(VOID *pool, UINT32 taskID)
{
- LosMemDynNode *tmpNode = (LosMemDynNode *)NULL;
- LOS_MEM_POOL_INFO *poolInfo = (LOS_MEM_POOL_INFO *)pool;
- UINT32 memUsed = 0;
- UINTPTR intSave;
+ if (pool == NULL) {
+ return OS_ERROR;
+ }
+
+ if (taskID >= LOSCFG_BASE_CORE_TSK_LIMIT) {
+ return OS_ERROR;
+ }
+
+ struct OsMemPoolHead *poolHead = (struct OsMemPoolHead *)pool;
+ struct OsMemNodeHead *tmpNode = NULL;
+ struct OsMemUsedNodeHead *node = NULL;
+ struct OsMemNodeHead *endNode = NULL;
+ UINT32 intSave;
+
+ MEM_LOCK(poolHead, intSave);
+ endNode = OS_MEM_END_NODE(pool, poolHead->info.totalSize);
+ for (tmpNode = OS_MEM_FIRST_NODE(pool); tmpNode < endNode;
+ tmpNode = OS_MEM_NEXT_NODE(tmpNode)) {
+ if (!OS_MEM_NODE_GET_USED_FLAG(tmpNode->sizeAndFlag)) {
+ continue;
+ }
+
+ node = (struct OsMemUsedNodeHead *)tmpNode;
+ if (node->taskID == taskID) {
+ OsMemFree(poolHead, &node->header);
+ }
+ }
+ MEM_UNLOCK(poolHead, intSave);
+
+ return LOS_OK;
+}
+#endif
+
+UINT32 LOS_MemPoolSizeGet(const VOID *pool)
+{
+ UINT32 count = 0;
if (pool == NULL) {
return LOS_NOK;
}
- intSave = LOS_IntLock();
+ count += ((struct OsMemPoolHead *)pool)->info.totalSize;
- for (tmpNode = OS_MEM_FIRST_NODE(pool); tmpNode <= OS_MEM_END_NODE(pool, poolInfo->uwPoolSize);
- tmpNode = OS_MEM_NEXT_NODE(tmpNode)) {
+#if OS_MEM_EXPAND_ENABLE
+ UINT32 size;
+ struct OsMemNodeHead *node = NULL;
+ struct OsMemNodeHead *sentinel = OS_MEM_END_NODE(pool, count);
+
+ while (OsMemIsLastSentinelNode(sentinel) == FALSE) {
+ size = OS_MEM_NODE_GET_SIZE(sentinel->sizeAndFlag);
+ node = OsMemSentinelNodeGet(sentinel);
+ sentinel = OS_MEM_END_NODE(node, size);
+ count += size;
+ }
+#endif
+ return count;
+}
+
+UINT32 LOS_MemTotalUsedGet(VOID *pool)
+{
+ struct OsMemNodeHead *tmpNode = NULL;
+ struct OsMemPoolHead *poolInfo = (struct OsMemPoolHead *)pool;
+ struct OsMemNodeHead *endNode = NULL;
+ UINT32 memUsed = 0;
+ UINT32 intSave;
+
+ if (pool == NULL) {
+ return LOS_NOK;
+ }
+
+ MEM_LOCK(poolInfo, intSave);
+ endNode = OS_MEM_END_NODE(pool, poolInfo->info.totalSize);
+#if OS_MEM_EXPAND_ENABLE
+ UINT32 size;
+ for (tmpNode = OS_MEM_FIRST_NODE(pool); tmpNode <= endNode;) {
+ if (tmpNode == endNode) {
+ memUsed += OS_MEM_NODE_HEAD_SIZE;
+ if (OsMemIsLastSentinelNode(endNode) == FALSE) {
+ size = OS_MEM_NODE_GET_SIZE(endNode->sizeAndFlag);
+ tmpNode = OsMemSentinelNodeGet(endNode);
+ endNode = OS_MEM_END_NODE(tmpNode, size);
+ continue;
+ } else {
+ break;
+ }
+ } else {
+ if (OS_MEM_NODE_GET_USED_FLAG(tmpNode->sizeAndFlag)) {
+ memUsed += OS_MEM_NODE_GET_SIZE(tmpNode->sizeAndFlag);
+ }
+ tmpNode = OS_MEM_NEXT_NODE(tmpNode);
+ }
+ }
+#else
+ for (tmpNode = OS_MEM_FIRST_NODE(pool); tmpNode < endNode;) {
if (OS_MEM_NODE_GET_USED_FLAG(tmpNode->sizeAndFlag)) {
memUsed += OS_MEM_NODE_GET_SIZE(tmpNode->sizeAndFlag);
}
+ tmpNode = OS_MEM_NEXT_NODE(tmpNode);
}
-
- LOS_IntRestore(intSave);
+#endif
+ MEM_UNLOCK(poolInfo, intSave);
return memUsed;
}
-/*****************************************************************************
- Function : LOS_MemUsedBlksGet
- Description : get the number of used node
- Input : pool --- Pointer to memory pool
- Output : None
- Return : the number of used node
-*****************************************************************************/
-LITE_OS_SEC_TEXT_MINOR UINT32 LOS_MemUsedBlksGet(VOID *pool)
+UINT32 LOS_MemIntegrityCheck(const VOID *pool)
{
- LosMemDynNode *tmpNode = (LosMemDynNode *)NULL;
- LOS_MEM_POOL_INFO *poolInfo = (LOS_MEM_POOL_INFO *)pool;
- UINT32 blkNums = 0;
- UINTPTR intSave;
-
- if (pool == NULL) {
- return LOS_NOK;
- }
-
- intSave = LOS_IntLock();
-
- for (tmpNode = OS_MEM_FIRST_NODE(pool); tmpNode <= OS_MEM_END_NODE(pool, poolInfo->uwPoolSize);
- tmpNode = OS_MEM_NEXT_NODE(tmpNode)) {
- if (OS_MEM_NODE_GET_USED_FLAG(tmpNode->sizeAndFlag)) {
- blkNums++;
- }
- }
-
- LOS_IntRestore(intSave);
-
- return blkNums;
-}
-
-/*****************************************************************************
- Function : LOS_MemTaskIdGet
- Description : get a memory node's taskID if pointer node is "used node"
- Input : ptr --- pointer to aim node
- Output : None
- Return : taskID --- Ok or OS_INVALID --- pointer node is illegal or free node
-*****************************************************************************/
-LITE_OS_SEC_TEXT_MINOR UINT32 LOS_MemTaskIdGet(const VOID *ptr)
-{
- LosMemDynNode *tmpNode = (LosMemDynNode *)NULL;
- LOS_MEM_POOL_INFO *poolInfo = (LOS_MEM_POOL_INFO *)OS_SYS_MEM_ADDR;
- UINTPTR intSave;
-
- if ((ptr == NULL) ||
- (ptr < (VOID *)OS_MEM_FIRST_NODE(OS_SYS_MEM_ADDR)) ||
- (ptr > (VOID *)OS_MEM_END_NODE(OS_SYS_MEM_ADDR, poolInfo->uwPoolSize))) {
- PRINT_ERR("input ptr 0x%x is out of system memory range[0x%x, 0x%x]\n",
- (UINTPTR)ptr,
- (UINTPTR)(OS_MEM_FIRST_NODE(OS_SYS_MEM_ADDR)),
- (UINTPTR)(OS_MEM_END_NODE(OS_SYS_MEM_ADDR, poolInfo->uwPoolSize)));
- return OS_INVALID;
- }
-
- intSave = LOS_IntLock();
-
- for (tmpNode = OS_MEM_FIRST_NODE(OS_SYS_MEM_ADDR);
- tmpNode <= OS_MEM_END_NODE(OS_SYS_MEM_ADDR, poolInfo->uwPoolSize); tmpNode = OS_MEM_NEXT_NODE(tmpNode)) {
- if ((UINTPTR)ptr < (UINTPTR)tmpNode) {
- if (OS_MEM_NODE_GET_USED_FLAG(tmpNode->preNode->sizeAndFlag)) {
- UINTPTR tmpValue = (UINTPTR)(tmpNode->preNode->freeNodeInfo.pstNext);
- LOS_IntRestore(intSave);
- return tmpValue;
- } else {
- LOS_IntRestore(intSave);
- PRINT_ERR("input ptr 0x%x is belong to a free mem node\n", (UINTPTR)ptr);
- return OS_INVALID;
- }
- }
- }
-
- LOS_IntRestore(intSave);
- return OS_INVALID;
-}
-
-/*****************************************************************************
- Function : LOS_MemFreeBlksGet
- Description : get the number of free node
- Input : pool --- Pointer to memory pool
- Output : None
- Return : the number of free node
-*****************************************************************************/
-LITE_OS_SEC_TEXT_MINOR UINT32 LOS_MemFreeBlksGet(VOID *pool)
-{
- LosMemDynNode *tmpNode = (LosMemDynNode *)NULL;
- LOS_MEM_POOL_INFO *poolInfo = (LOS_MEM_POOL_INFO *)pool;
- UINT32 blkNum = 0;
- UINTPTR intSave;
-
- if (pool == NULL) {
- return LOS_NOK;
- }
-
- intSave = LOS_IntLock();
-
- for (tmpNode = OS_MEM_FIRST_NODE(pool); tmpNode <= OS_MEM_END_NODE(pool, poolInfo->uwPoolSize);
- tmpNode = OS_MEM_NEXT_NODE(tmpNode)) {
- if (!OS_MEM_NODE_GET_USED_FLAG(tmpNode->sizeAndFlag)) {
- blkNum++;
- }
- }
-
- LOS_IntRestore(intSave);
-
- return blkNum;
-}
-
-/*****************************************************************************
- Function : LOS_MemLastUsedGet
- Description : get the address of last used node(except end node)
- Input : pool --- Pointer to memory pool
- Output : None
- Return : address of last node offset sizeof(LosMemDynNode), if last node is freeNode
- address of the end node, if last node is usedNode
-*****************************************************************************/
-LITE_OS_SEC_TEXT_MINOR UINT32 LOS_MemLastUsedGet(VOID *pool)
-{
- LOS_MEM_POOL_INFO *poolInfo = (LOS_MEM_POOL_INFO *)pool;
- LosMemDynNode *node = NULL;
-
- if (pool == NULL) {
- return LOS_NOK;
- }
-
- node = OS_MEM_END_NODE(pool, poolInfo->uwPoolSize)->preNode;
-
- if (OS_MEM_NODE_GET_USED_FLAG(node->sizeAndFlag)) {
- return (UINTPTR)node + OS_MEM_NODE_GET_SIZE(node->sizeAndFlag) + sizeof(LosMemDynNode);
- } else {
- return (UINTPTR)node + sizeof(LosMemDynNode);
- }
-}
-
-/*****************************************************************************
- Function : OsMemResetEndNode
- Description : reset "end node"
- Input : None
- Output : endNode --- pointer to "end node"
- Return : the number of free node
-*****************************************************************************/
-LITE_OS_SEC_TEXT_MINOR VOID OsMemResetEndNode(UINT32 preAddr)
-{
- LosMemDynNode *endNode = (LosMemDynNode *)OS_MEM_END_NODE(OS_SYS_MEM_ADDR, OS_SYS_MEM_SIZE);
- endNode->sizeAndFlag = OS_MEM_NODE_HEAD_SIZE;
- if (preAddr != (UINT32)NULL) {
- endNode->preNode = (LosMemDynNode *)(UINTPTR)(preAddr - sizeof(LosMemDynNode));
- }
- OS_MEM_NODE_SET_USED_FLAG(endNode->sizeAndFlag);
- OsMemSetMagicNumAndTaskid(endNode);
-}
-
-LITE_OS_SEC_TEXT_MINOR UINT32 LOS_MemInfoGet(VOID *pool, LOS_MEM_STATUS *status)
-{
- LOS_MEM_POOL_INFO *poolInfo = (LOS_MEM_POOL_INFO *)pool;
- LosMemDynNode *tmpNode = (LosMemDynNode *)NULL;
- UINT32 totalUsedSize = 0;
- UINT32 totalFreeSize = 0;
- UINT32 maxFreeNodeSize = 0;
- UINT32 usedNodeNum = 0;
- UINT32 freeNodeNum = 0;
- UINTPTR intSave;
-
- if ((poolInfo == NULL) || ((UINTPTR)pool != (UINTPTR)poolInfo->pPoolAddr)) {
- PRINT_ERR("wrong mem pool addr: 0x%x, line:%d\n", (UINTPTR)poolInfo, __LINE__);
- return LOS_NOK;
- }
-
- if (status == NULL) {
- PRINT_ERR("wrong status addr: 0x%x, line:%d\n", (UINTPTR)status, __LINE__);
- return LOS_NOK;
- }
-
- tmpNode = (LosMemDynNode *)OS_MEM_END_NODE(pool, poolInfo->uwPoolSize);
- tmpNode = (LosMemDynNode *)(UINTPTR)OS_MEM_ALIGN(tmpNode, OS_MEM_ALIGN_SIZE);
-
- if (!OS_MEM_MAGIC_VALID(tmpNode->freeNodeInfo.pstPrev)) {
- PRINT_ERR("wrong mem pool addr: 0x%x, line:%d\n", (UINTPTR)poolInfo, __LINE__);
- return LOS_NOK;
- }
-
- intSave = LOS_IntLock();
-
- for (tmpNode = OS_MEM_FIRST_NODE(pool); tmpNode <= OS_MEM_END_NODE(pool, poolInfo->uwPoolSize);
- tmpNode = OS_MEM_NEXT_NODE(tmpNode)) {
- if (!OS_MEM_NODE_GET_USED_FLAG(tmpNode->sizeAndFlag)) {
- ++freeNodeNum;
- totalFreeSize += OS_MEM_NODE_GET_SIZE(tmpNode->sizeAndFlag);
- if (maxFreeNodeSize < OS_MEM_NODE_GET_SIZE(tmpNode->sizeAndFlag)) {
- maxFreeNodeSize = OS_MEM_NODE_GET_SIZE(tmpNode->sizeAndFlag);
- }
- } else {
- ++usedNodeNum;
- totalUsedSize += OS_MEM_NODE_GET_SIZE(tmpNode->sizeAndFlag);
- }
- }
-
- LOS_IntRestore(intSave);
-
- status->usedSize = totalUsedSize;
- status->freeSize = totalFreeSize;
- status->totalSize = maxFreeNodeSize;
- status->allocCount = usedNodeNum;
- status->freeCount = freeNodeNum;
-#if defined(OS_MEM_WATERLINE) && (OS_MEM_WATERLINE == YES)
- status->uwUsageWaterLine = poolInfo->uwPoolWaterLine;
-#endif
return LOS_OK;
}
-LITE_OS_SEC_TEXT_MINOR VOID OsMemInfoPrint(VOID *pool)
+STATIC INLINE VOID OsMemInfoGet(struct OsMemNodeHead *node, LOS_MEM_POOL_STATUS *poolStatus)
{
- LOS_MEM_POOL_INFO *poolInfo = (LOS_MEM_POOL_INFO *)pool;
- LOS_MEM_STATUS status = {0};
+ UINT32 totalUsedSize = 0;
+ UINT32 totalFreeSize = 0;
+ UINT32 usedNodeNum = 0;
+ UINT32 freeNodeNum = 0;
+ UINT32 maxFreeSize = 0;
+ UINT32 size;
- if (LOS_NOK == LOS_MemInfoGet(pool, &status)) {
+ if (!OS_MEM_NODE_GET_USED_FLAG(node->sizeAndFlag)) {
+ size = OS_MEM_NODE_GET_SIZE(node->sizeAndFlag) - sizeof(struct OsMemFreeNodeHead);
+ ++freeNodeNum;
+ totalFreeSize += size;
+ if (maxFreeSize < size) {
+ maxFreeSize = size;
+ }
+ } else {
+ size = OS_MEM_NODE_GET_SIZE(node->sizeAndFlag) - sizeof(struct OsMemUsedNodeHead);
+ ++usedNodeNum;
+ totalUsedSize += size;
+ }
+
+ poolStatus->totalUsedSize += totalUsedSize;
+ poolStatus->totalFreeSize += totalFreeSize;
+ poolStatus->maxFreeNodeSize = poolStatus->maxFreeNodeSize > maxFreeSize ?
+ poolStatus->maxFreeNodeSize : maxFreeSize;
+ poolStatus->usedNodeNum += usedNodeNum;
+ poolStatus->freeNodeNum += freeNodeNum;
+#if defined(OS_MEM_WATERLINE) && (OS_MEM_WATERLINE == YES)
+ poolStatus->usageWaterLine = poolInfo->poolWaterLine;
+#endif
+}
+
+UINT32 LOS_MemInfoGet(VOID *pool, LOS_MEM_POOL_STATUS *poolStatus)
+{
+ struct OsMemPoolHead *poolInfo = pool;
+
+ if (poolStatus == NULL) {
+ PRINT_ERR("can't use NULL addr to save info\n");
+ return LOS_NOK;
+ }
+
+ if ((pool == NULL) || (poolInfo->info.pool != pool)) {
+ PRINT_ERR("wrong mem pool addr: %#x, line:%d\n", (UINTPTR)poolInfo, __LINE__);
+ return LOS_NOK;
+ }
+
+ struct OsMemNodeHead *tmpNode = NULL;
+ struct OsMemNodeHead *endNode = NULL;
+ UINT32 intSave;
+
+ MEM_LOCK(poolInfo, intSave);
+ endNode = OS_MEM_END_NODE(pool, poolInfo->info.totalSize);
+#if OS_MEM_EXPAND_ENABLE
+ UINT32 size;
+ for (tmpNode = OS_MEM_FIRST_NODE(pool); tmpNode <= endNode; tmpNode = OS_MEM_NEXT_NODE(tmpNode)) {
+ if (tmpNode == endNode) {
+ if (OsMemIsLastSentinelNode(endNode) == FALSE) {
+ size = OS_MEM_NODE_GET_SIZE(endNode->sizeAndFlag);
+ tmpNode = OsMemSentinelNodeGet(endNode);
+ endNode = OS_MEM_END_NODE(tmpNode, size);
+ continue;
+ } else {
+ break;
+ }
+ } else {
+ OsMemInfoGet(tmpNode, poolStatus);
+ }
+ }
+#else
+ for (tmpNode = OS_MEM_FIRST_NODE(pool); tmpNode < endNode; tmpNode = OS_MEM_NEXT_NODE(tmpNode)) {
+ OsMemInfoGet(tmpNode, poolStatus);
+ }
+#endif
+ MEM_UNLOCK(poolInfo, intSave);
+
+ return LOS_OK;
+}
+
+STATIC VOID OsMemInfoPrint(VOID *pool)
+{
+ struct OsMemPoolHead *poolInfo = (struct OsMemPoolHead *)pool;
+ LOS_MEM_POOL_STATUS status = {0};
+
+ if (LOS_MemInfoGet(pool, &status) == LOS_NOK) {
return;
}
#if defined(OS_MEM_WATERLINE) && (OS_MEM_WATERLINE == YES)
- PRINTK("pool addr pool size used size free size"
- " max free node size used node num free node num UsageWaterLine\n"
- "--------- -------- ------- --------"
- " -------------- ------------- ------------ ------------\n"
- "0x%-8x 0x%-8x 0x%-8x 0x%-8x 0x%-16x 0x%-13x 0x%-13x 0x%-13x\n",
- poolInfo->pPoolAddr, poolInfo->uwPoolSize, status.usedSize, status.freeSize,
- status.totalSize, status.allocCount, status.freeCount, status.uwUsageWaterLine);
+ PRINTK("pool addr pool size used size free size "
+ "max free node size used node num free node num UsageWaterLine\n");
+ PRINTK("--------------- -------- ------- -------- "
+ "-------------- ------------- ------------ ------------\n");
+ PRINTK("%-16#x 0x%-8x 0x%-8x 0x%-8x 0x%-16x 0x%-13x 0x%-13x 0x%-13x\n",
+ poolInfo->info.pool, LOS_MemPoolSizeGet(pool), status.totalUsedSize,
+ status.totalFreeSize, status.maxFreeNodeSize, status.usedNodeNum,
+ status.freeNodeNum, status.usageWaterLine);
#else
- PRINTK("pool addr pool size used size free size"
- " max free node size used node num free node num\n"
- "--------- -------- ------- --------"
- " -------------- ------------- ------------\n"
- "0x%-8x 0x%-8x 0x%-8x 0x%-8x 0x%-16x 0x%-13x 0x%-13x\n",
- (UINT32)(UINTPTR)(poolInfo->pPoolAddr), poolInfo->uwPoolSize, status.usedSize, status.freeSize,
- status.totalSize, status.allocCount, status.freeCount);
+ PRINTK("pool addr pool size used size free size "
+ "max free node size used node num free node num\n");
+ PRINTK("--------------- -------- ------- -------- "
+ "-------------- ------------- ------------\n");
+ PRINTK("0x%-16x 0x%-8x 0x%-8x 0x%-8x 0x%-16x 0x%-13x 0x%-13x\n",
+ (UINTPTR)poolInfo->info.pool, LOS_MemPoolSizeGet(pool), status.totalUsedSize,
+ status.totalFreeSize, status.maxFreeNodeSize, status.usedNodeNum,
+ status.freeNodeNum);
#endif
- return;
}
-LITE_OS_SEC_TEXT_MINOR UINT32 LOS_MemFreeNodeShow(VOID *pool)
+UINT32 LOS_MemFreeNodeShow(VOID *pool)
{
- LOS_DL_LIST *listHead = (LOS_DL_LIST *)NULL;
- LosMultipleDlinkHead *headAddr = (LosMultipleDlinkHead *)((UINTPTR)pool + sizeof(LOS_MEM_POOL_INFO));
- LOS_MEM_POOL_INFO *poolInfo = (LOS_MEM_POOL_INFO *)pool;
- LosMemDynNode *tmpNode = (LosMemDynNode *)NULL;
- UINT32 count, idx;
- UINT32 countNum[OS_MEM_NODE_COUNT_NUM] = {0};
- UINTPTR intSave;
- INT32 i, j;
+ struct OsMemPoolHead *poolInfo = (struct OsMemPoolHead *)pool;
- if ((poolInfo == NULL) || ((UINTPTR)pool != (UINTPTR)poolInfo->pPoolAddr)) {
- PRINT_ERR("wrong mem pool addr: 0x%x, line:%d\n", (UINTPTR)poolInfo, __LINE__);
+ if ((poolInfo == NULL) || ((UINTPTR)pool != (UINTPTR)poolInfo->info.pool)) {
+ PRINT_ERR("wrong mem pool addr: %#x, line: %d\n", (UINTPTR)poolInfo, __LINE__);
return LOS_NOK;
}
- tmpNode = (LosMemDynNode *)OS_MEM_END_NODE(pool, poolInfo->uwPoolSize);
- tmpNode = (LosMemDynNode *)(UINTPTR)OS_MEM_ALIGN(tmpNode, OS_MEM_ALIGN_SIZE);
+ struct OsMemFreeNodeHead *node = NULL;
+ UINT32 countNum[OS_MEM_FREE_LIST_COUNT] = {0};
+ UINT32 index;
+ UINT32 intSave;
- if (!OS_MEM_MAGIC_VALID(tmpNode->freeNodeInfo.pstPrev)) {
- PRINT_ERR("wrong mem pool addr: 0x%x\n, line:%d", (UINTPTR)poolInfo, __LINE__);
- return LOS_NOK;
+ MEM_LOCK(poolInfo, intSave);
+ for (index = 0; index < OS_MEM_FREE_LIST_COUNT; index++) {
+ node = poolInfo->freeList[index];
+ while (node) {
+ node = node->next;
+ countNum[index]++;
+ }
}
- PRINTK("\n ************************ left free node number**********************\n block size: ");
- intSave = LOS_IntLock();
+ MEM_UNLOCK(poolInfo, intSave);
- for (idx = 0, j = 0; idx <= (OS_MAX_MULTI_DLNK_LOG2 - OS_MIN_MULTI_DLNK_LOG2); idx++, j++) {
- for (count = 0, listHead = headAddr->listHead[idx].pstNext; listHead != &(headAddr->listHead[idx]);
- listHead = listHead->pstNext) {
- ++count;
+ PRINTK("\n ************************ left free node number**********************\n");
+ for (index = 0; index < OS_MEM_FREE_LIST_COUNT; index++) {
+ if (countNum[index] == 0) {
+ continue;
}
- PRINTK("2^%-5d", idx + OS_MEM_NODE_DATA_SIZE);
- if ((idx == 0) || ((((idx + 1) % OS_MEM_NODE_COUNT_NUM) != 0) && (idx != OS_MULTI_DLNK_SIZE))) {
- goto NEXT;
+
+ PRINTK("free index: %03u, ", index);
+ if (index < OS_MEM_SMALL_BUCKET_COUNT) {
+ PRINTK("size: [%#x], num: %u\n", (index + 1) << 2, countNum[index]); /* 2: setup is 4. */
+ } else {
+ UINT32 val = 1 << (((index - OS_MEM_SMALL_BUCKET_COUNT) >> OS_MEM_SLI) + OS_MEM_LARGE_START_BUCKET);
+ UINT32 offset = val >> OS_MEM_SLI;
+ PRINTK("size: [%#x, %#x], num: %u\n", (offset * ((index - OS_MEM_SMALL_BUCKET_COUNT) % (1 << OS_MEM_SLI))) + val,
+ ((offset * (((index - OS_MEM_SMALL_BUCKET_COUNT) % (1 << OS_MEM_SLI)) + 1)) + val - 1), countNum[index]);
}
- PRINTK("\n node number:");
- for (i = 0; i < OS_MEM_NODE_COUNT_NUM; i++) {
- PRINTK(" %-5u", countNum[i]);
- if ((i == OS_MEM_NODE_NUM) && (idx == (OS_MAX_MULTI_DLNK_LOG2 - OS_MIN_MULTI_DLNK_LOG2))) {
- break;
- }
- }
- if (idx != (OS_MAX_MULTI_DLNK_LOG2 - OS_MIN_MULTI_DLNK_LOG2)) {
- PRINTK("\n\n block size: ");
- }
-NEXT:
- j = idx % OS_MEM_NODE_COUNT_NUM;
- countNum[j] = count;
}
- LOS_IntRestore(intSave);
PRINTK("\n ********************************************************************\n\n");
return LOS_OK;
}
-#ifdef OS_MEM_CHECK_DEBUG
-
-/*****************************************************************************
- Function : LOS_MemNodeSizeCheck
- Description: get a pNode's(ptr) size ,include total size and available size
- Input : pool --- which pool doesn't your ptr belong to
- ptr --- point to source node
- Output : totalSize --- save total size
- availSize --- save availabe size
- Return : errorID or LOS_OK
-*****************************************************************************/
-LITE_OS_SEC_TEXT_MINOR UINT32 LOS_MemNodeSizeCheck(VOID *pool, VOID *ptr, UINT32 *totalSize, UINT32 *availSize)
+UINT32 OsMemSystemInit(VOID)
{
- VOID *head = NULL;
- LOS_MEM_POOL_INFO *poolInfo = (LOS_MEM_POOL_INFO *)pool;
- UINT8 *endPool = NULL;
-
- if (g_checkMemLevel == LOS_MEM_CHECK_LEVEL_DISABLE) {
- return OS_ERRNO_MEMCHECK_DISABLED;
- }
-
- if ((pool == NULL) || (ptr == NULL)) {
- return OS_ERRNO_MEMCHECK_PARA_NULL;
- }
-
- if (totalSize == NULL || availSize == NULL) {
- return OS_ERRNO_MEMCHECK_PARA_NULL;
- }
-
- endPool = (UINT8 *)pool + poolInfo->uwPoolSize;
- if (!(OS_MEM_MIDDLE_ADDR_OPEN_END(pool, (UINT8 *)ptr, endPool))) {
- return OS_ERRNO_MEMCHECK_OUTSIDE;
- }
-
- if (g_checkMemLevel == LOS_MEM_CHECK_LEVEL_HIGH) {
- head = OsMemFindNodeCtrl(ptr);
- if ((head == NULL) || ((((LosMemDynNode *)head)->sizeAndFlag & (~OS_MEM_NODE_USED_FLAG)) <
- ((UINTPTR)ptr - (UINTPTR)head))) {
- return OS_ERRNO_MEMCHECK_NO_HEAD;
- }
- *totalSize = (((LosMemDynNode *)head)->sizeAndFlag - sizeof(LosMemDynNode)) & (~OS_MEM_NODE_USED_FLAG);
- *availSize = (((LosMemDynNode *)head)->sizeAndFlag - ((UINTPTR)ptr - (UINTPTR)head)) &
- (~OS_MEM_NODE_USED_FLAG);
- return LOS_OK;
- }
- if (g_checkMemLevel == LOS_MEM_CHECK_LEVEL_LOW) {
- if (ptr != (VOID *)OS_MEM_ALIGN(ptr, OS_MEM_ALIGN_SIZE)) {
- return OS_ERRNO_MEMCHECK_NO_HEAD;
- }
- head = (VOID *)((UINTPTR)ptr - sizeof(LosMemDynNode));
- if (OS_MEM_MAGIC_VALID(((LosMemDynNode *)head)->freeNodeInfo.pstPrev)) {
- *totalSize = (((LosMemDynNode *)head)->sizeAndFlag - sizeof(LosMemDynNode)) & (~OS_MEM_NODE_USED_FLAG);
- *availSize = (((LosMemDynNode *)head)->sizeAndFlag - sizeof(LosMemDynNode)) & (~OS_MEM_NODE_USED_FLAG);
- return LOS_OK;
- } else {
- return OS_ERRNO_MEMCHECK_NO_HEAD;
- }
- }
-
- return OS_ERRNO_MEMCHECK_WRONG_LEVEL;
-}
-
-/*****************************************************************************
-Function : OsMemFindNodeCtrl
-Description : get a pool's memCtrl
-Input : headPtr --- point to source ptr
-Output : None
-Return : search forward for headPtr's memCtrl or "NULL"
-@attention : this func couldn't ensure the return memCtrl belongs to ptr
- it just find forward the most nearly one
-*******************************************************************************/
-LITE_OS_SEC_TEXT_MINOR VOID *OsMemFindNodeCtrl(VOID *headPtr)
-{
- UINT8 *head = (UINT8 *)headPtr;
-
- if (headPtr == NULL) {
- return NULL;
- }
-
- head = (UINT8 *)OS_MEM_ALIGN((VOID *)head, OS_MEM_ALIGN_SIZE);
- while (!OS_MEM_MAGIC_VALID(((LosMemDynNode *)head)->freeNodeInfo.pstPrev)) {
- head -= OS_MEM_NODE_DATA_SIZE;
- }
- return head;
-}
-
-/*****************************************************************************
- Function : LOS_MemCheckLevelSet
- Description : setting g_checkMemLevel which decide the manner of memcheck
- Input : level --- waht level want to set
- Output : None
- Return : LOS_OK --- setting succeed
- OS_ERRNO_MEMCHECK_WRONG_LEVEL --- setting failed due to illegal parameter
-*****************************************************************************/
-LITE_OS_SEC_TEXT_MINOR UINT32 LOS_MemCheckLevelSet(UINT8 level)
-{
- if (level == LOS_MEM_CHECK_LEVEL_LOW) {
- PRINTK("%s: LOS_MEM_CHECK_LEVEL_LOW \n", __FUNCTION__);
- } else if (level == LOS_MEM_CHECK_LEVEL_HIGH) {
- PRINTK("%s: LOS_MEM_CHECK_LEVEL_HIGH \n", __FUNCTION__);
- } else if (level == LOS_MEM_CHECK_LEVEL_DISABLE) {
- PRINTK("%s: LOS_MEM_CHECK_LEVEL_DISABLE \n", __FUNCTION__);
- } else {
- PRINTK("%s: wrong para, setting failed !! \n", __FUNCTION__);
- return OS_ERRNO_MEMCHECK_WRONG_LEVEL;
- }
- g_checkMemLevel = level;
- return LOS_OK;
-}
-
-LITE_OS_SEC_TEXT_MINOR UINT8 LOS_MemCheckLevelGet(VOID)
-{
- return g_checkMemLevel;
-}
-
-#endif /* OS_MEM_CHECK_DEBUG */
-
-UINT32 OsMemSysNodeCheck(VOID *dst, VOID *src, UINT32 length, UINT8 pos)
-{
-#ifdef OS_MEM_CHECK_DEBUG
UINT32 ret;
- UINT32 totalSize = 0;
- UINT32 availSize = 0;
-
- if (pos == 0) { /* if this func was called by memset */
- ret = LOS_MemNodeSizeCheck(m_aucSysMem0, dst, &totalSize, &availSize);
- if ((ret == LOS_OK) && (length > availSize)) {
- PRINT_ERR("---------------------------------------------\n");
- PRINT_ERR("memset: dst inode availSize is not enough"
- " availSize = 0x%x length = 0x%x\n",
- availSize, length);
- OsBackTrace();
- PRINT_ERR("---------------------------------------------\n");
- return LOS_NOK;
- }
- } else if (pos == 1) { /* if this func was called by memcpy */
- ret = LOS_MemNodeSizeCheck(m_aucSysMem0, dst, &totalSize, &availSize);
- if ((ret == LOS_OK) && (length > availSize)) {
- PRINT_ERR("---------------------------------------------\n");
- PRINT_ERR("memcpy: dst inode availSize is not enough availSize = 0x%x length = 0x%x\n",
- availSize, length);
- OsBackTrace();
- PRINT_ERR("---------------------------------------------\n");
- return LOS_NOK;
- }
- ret = LOS_MemNodeSizeCheck(m_aucSysMem0, src, &totalSize, &availSize);
- if ((ret == LOS_OK) && (length > availSize)) {
- PRINT_ERR("---------------------------------------------\n");
- PRINT_ERR("memcpy: src inode availSize is not enough availSize = 0x%x length = 0x%x\n",
- availSize, length);
- OsBackTrace();
- PRINT_ERR("---------------------------------------------\n");
- return LOS_NOK;
- }
- }
-#endif
- return LOS_OK;
-}
-
-#ifdef LOSCFG_MEM_MUL_MODULE
-INLINE UINT32 OsMemModCheck(UINT32 module)
-{
- if (module > MEM_MODULE_MAX) {
- PRINT_ERR("error module ID input!\n");
- return LOS_NOK;
- }
- return LOS_OK;
-}
-
-INLINE VOID *OsMemPtrToNode(VOID *ptr)
-{
- UINT32 gapSize;
- LosMemDynNode *node = NULL;
- gapSize = *((UINT32 *)((UINTPTR)ptr - OS_MEM_NODE_DATA_SIZE));
- if (OS_MEM_NODE_GET_ALIGNED_FLAG(gapSize)) {
- gapSize = OS_MEM_NODE_GET_ALIGNED_GAPSIZE(gapSize);
- ptr = (VOID *)((UINTPTR)ptr - gapSize);
- }
-
- return (VOID *)((UINTPTR)ptr - OS_MEM_NODE_HEAD_SIZE);
-}
-
-INLINE UINT32 OsMemNodeSizeGet(VOID *ptr)
-{
- LosMemDynNode *node;
- node = (LosMemDynNode *)OsMemPtrToNode(ptr);
-
- return ((node->sizeAndFlag) & (~OS_MEM_NODE_USED_FLAG));
-}
-
-VOID *LOS_MemMalloc(VOID *pool, UINT32 size, UINT32 module)
-{
- UINTPTR intSave;
- VOID *ptr = NULL;
- if (OsMemModCheck(module) == LOS_NOK) {
- return NULL;
- }
- ptr = LOS_MemAlloc(pool, size);
- if (ptr != NULL) {
- intSave = LOS_IntLock();
- g_memInfo[module] += OsMemNodeSizeGet(ptr);
- OS_MEM_MODID_SET(OsMemPtrToNode(ptr), module);
- LOS_IntRestore(intSave);
- }
- return ptr;
-}
-
-VOID *LOS_MemMallocAlign(VOID *pool, UINT32 size, UINT32 boundary, UINT32 module)
-{
- UINTPTR intSave;
- VOID *ptr = NULL;
- if (OsMemModCheck(module) == LOS_NOK) {
- return NULL;
- }
- ptr = LOS_MemAllocAlign(pool, size, boundary);
- if (ptr != NULL) {
- intSave = LOS_IntLock();
- g_memInfo[module] += OsMemNodeSizeGet(ptr);
- OS_MEM_MODID_SET(OsMemPtrToNode(ptr), module);
- LOS_IntRestore(intSave);
- }
- return ptr;
-}
-
-UINT32 LOS_MemMfree(VOID *pool, VOID *ptr, UINT32 module)
-{
- UINTPTR intSave;
- UINT32 ret;
- UINT32 size;
-
- if ((OsMemModCheck(module) == LOS_NOK) || (ptr == NULL)) {
- return LOS_NOK;
- }
-
- size = OsMemNodeSizeGet(ptr);
-
- if (module != OS_MEM_MODID_GET(OsMemPtrToNode(ptr))) {
- PRINT_ERR("node[%p] alloced in module %d, but free in module %d\n node's taskID: 0x%x\n",
- ptr, OS_MEM_MODID_GET(OsMemPtrToNode(ptr)), module, OS_MEM_TASKID_GET(OsMemPtrToNode(ptr)));
- }
-
- ret = LOS_MemFree(pool, ptr);
- if (ret == LOS_OK) {
- intSave = LOS_IntLock();
- g_memInfo[module] -= size;
- LOS_IntRestore(intSave);
- }
+ UINT32 memSize;
+ m_aucSysMem0 = (UINT8 *)(UINTPTR)(((UINT32)(UINTPTR)m_aucSysMem0 + (OS_MEM_ALIGN_SIZE - 1)) &
+ ~(OS_MEM_ALIGN_SIZE - 1));
+ memSize = ((UINT32)g_sysMemAddrEnd) - OS_SYS_NOCACHEMEM_SIZE - (UINT32)(UINTPTR)m_aucSysMem0;
+ ret = LOS_MemInit(m_aucSysMem0, memSize);
+ PRINT_INFO("LiteOS heap memory address:0x%x,size:0x%x\n", m_aucSysMem0, memSize);
return ret;
}
-VOID *LOS_MemMrealloc(VOID *pool, VOID *ptr, UINT32 size, UINT32 module)
-{
- VOID *newPtr = NULL;
- UINT32 oldSize;
- UINTPTR intSave;
-
- if (OsMemModCheck(module) == LOS_NOK) {
- return NULL;
- }
-
- if (ptr == NULL) {
- return LOS_MemMalloc(pool, size, module);
- }
-
- if (module != OS_MEM_MODID_GET(OsMemPtrToNode(ptr))) {
- PRINT_ERR("a node[%p] alloced in module %d, but realloc in module %d\n node's taskID: %d\n",
- ptr, OS_MEM_MODID_GET(OsMemPtrToNode(ptr)), module, OS_MEM_TASKID_GET(OsMemPtrToNode(ptr)));
- }
-
- if (size == 0) {
- if (LOS_MemMfree(pool, ptr, module) != LOS_OK) {
- PRINT_ERR("Mem Free Failed!\n");
- }
- return NULL;
- }
-
- oldSize = OsMemNodeSizeGet(ptr);
- newPtr = LOS_MemRealloc(pool, ptr, size);
- if (newPtr != NULL) {
- intSave = LOS_IntLock();
- g_memInfo[module] += OsMemNodeSizeGet(newPtr);
- g_memInfo[module] -= oldSize;
- OS_MEM_MODID_SET(OsMemPtrToNode(newPtr), module);
- LOS_IntRestore(intSave);
- }
- return newPtr;
-}
-
-UINT32 LOS_MemMusedGet(UINT32 module)
-{
- if (OsMemModCheck(module) == LOS_NOK) {
- return LOS_NOK;
- }
- return g_memInfo[module];
-}
-#endif
-
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
+
diff --git a/readme.md b/readme.md
old mode 100755
new mode 100644
diff --git a/targets/cortex-m3_stm32f103_simulator_keil/Driver/STM32F103/uart.c b/targets/cortex-m3_stm32f103_simulator_keil/Driver/STM32F103/uart.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m3_stm32f103_simulator_keil/main.c b/targets/cortex-m3_stm32f103_simulator_keil/main.c
old mode 100755
new mode 100644
index 9a820fd8..44d7e08d
--- a/targets/cortex-m3_stm32f103_simulator_keil/main.c
+++ b/targets/cortex-m3_stm32f103_simulator_keil/main.c
@@ -1,15 +1,21 @@
/*
- * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
- * Description: Redistribution and use in source and binary forms, with or without modification,
+ * 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.
+ * conditions and the following disclaimer.
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
- * to endorse or promote products derived from this software without specific prior written
- * permission.
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
@@ -21,16 +27,8 @@
* 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.
- * ---------------------------------------------------------------------------
- * Notice of Export Control Law
- * ===============================================
- * Huawei LiteOS may be subject to applicable export control laws and regulations, which might
- * include those applicable to Huawei LiteOS of U.S. and the country in which you are located.
- * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such
- * applicable export control laws and regulations.
*/
-
#include "los_tick.h"
#include "los_task.h"
#include "los_config.h"
@@ -49,7 +47,6 @@ UINT8 g_memStart[OS_SYS_MEM_SIZE];
VOID taskSampleEntry2(VOID)
{
- UINT32 uwRet;
while(1) {
LOS_TaskDelay(10000);
printf("taskSampleEntry2 running...\n");
@@ -59,7 +56,6 @@ VOID taskSampleEntry2(VOID)
VOID taskSampleEntry1(VOID)
{
- UINT32 uwRet;
while(1) {
LOS_TaskDelay(2000);
printf("taskSampleEntry1 running...\n");
@@ -70,20 +66,25 @@ VOID taskSampleEntry1(VOID)
UINT32 taskSample(VOID)
{
UINT32 uwRet;
- UINT32 taskID1,taskID2;
+ UINT32 taskID1,taskID2;
TSK_INIT_PARAM_S stTask1={0};
stTask1.pfnTaskEntry = (TSK_ENTRY_FUNC)taskSampleEntry1;
stTask1.uwStackSize = 0X1000;
stTask1.pcName = "taskSampleEntry1";
stTask1.usTaskPrio = 6;
uwRet = LOS_TaskCreate(&taskID1, &stTask1);
+ if (uwRet != LOS_OK) {
+ printf("create task1 failed\n");
+ }
stTask1.pfnTaskEntry = (TSK_ENTRY_FUNC)taskSampleEntry2;
stTask1.uwStackSize = 0X1000;
stTask1.pcName = "taskSampleEntry2";
stTask1.usTaskPrio = 7;
uwRet = LOS_TaskCreate(&taskID2, &stTask1);
-
+ if (uwRet != LOS_OK) {
+ printf("create task2 failed\n");
+ }
return LOS_OK;
}
@@ -118,12 +119,12 @@ LITE_OS_SEC_TEXT_INIT int main(void)
printf("\n\rhello world!!\n\r");
ret = LOS_KernelInit();
- taskSample();
+ taskSample();
if (ret == LOS_OK) {
LOS_Start();
}
- while (1) {
+ while (1) {
__asm volatile("wfi");
}
}
diff --git a/targets/cortex-m3_stm32f103_simulator_keil/project/los_demo.sct b/targets/cortex-m3_stm32f103_simulator_keil/project/los_demo.sct
old mode 100755
new mode 100644
index c9230778..2891a419
--- a/targets/cortex-m3_stm32f103_simulator_keil/project/los_demo.sct
+++ b/targets/cortex-m3_stm32f103_simulator_keil/project/los_demo.sct
@@ -4,7 +4,7 @@
LR_IROM1 0x08000000 0x00200000 { ; load region size_region
ER_IROM1 0x08000000 0x00200000 { ; load address = execution address
- LOS_vendor.o (RESET, +First)
+ los_startup.o (RESET, +First)
*(InRoot$$Sections)
* (+RO)
}
diff --git a/targets/cortex-m3_stm32f103_simulator_keil/project/los_demo.uvopt b/targets/cortex-m3_stm32f103_simulator_keil/project/los_demo.uvopt
old mode 100755
new mode 100644
index 784cad11..1c1deda6
--- a/targets/cortex-m3_stm32f103_simulator_keil/project/los_demo.uvopt
+++ b/targets/cortex-m3_stm32f103_simulator_keil/project/los_demo.uvopt
@@ -13,7 +13,6 @@
*.txt; *.h; *.inc
*.plm
*.cpp
- 0
@@ -32,7 +31,6 @@
1
1
0
- 0
1
@@ -95,6 +93,16 @@
datashts\arm\cortex_m3\r2p1\DUI0552A_CORTEX_M3_DGUG.PDF
+
+ SARMCM3.DLL
+
+ DARMSTM.DLL
+ -pSTM32F103RB
+ SARMCM3.DLL
+
+ TARMSTM.DLL
+ -pSTM32F103RB
+
1
0
@@ -113,13 +121,8 @@
0
1
1
- 1
- 1
0
0
- 1
- 0
- 0
0
@@ -182,23 +185,12 @@
- 0
- 0
- 0
-
-
-
-
-
-
-
-
liteos-m
- 1
+ 0
0
0
0
@@ -207,31 +199,11 @@
1
1
0
+ 1
+ 49223292
0
- 0
- ..\..\..\kernel\arch\arm\cortex-m3\keil\los_hw.c
- los_hw.c
- 0
- 0
-
-
- 1
- 2
- 1
- 0
- 0
- 0
- ..\..\..\kernel\arch\arm\cortex-m3\keil\los_hw_tick.c
- los_hw_tick.c
- 0
- 0
-
-
- 1
- 3
- 1
- 0
- 0
+ 0
+ 5
0
..\..\..\kernel\src\los_event.c
los_event.c
@@ -240,10 +212,14 @@
1
- 4
+ 2
1
0
+ 1
+ 49223292
0
+ 0
+ 5
0
..\..\..\kernel\src\los_init.c
los_init.c
@@ -252,10 +228,14 @@
1
- 5
+ 3
1
0
+ 1
+ 49223292
0
+ 0
+ 5
0
..\..\..\kernel\src\los_mux.c
los_mux.c
@@ -264,10 +244,14 @@
1
- 6
+ 4
1
0
+ 1
+ 49223292
0
+ 0
+ 5
0
..\..\..\kernel\src\los_queue.c
los_queue.c
@@ -276,10 +260,14 @@
1
- 7
+ 5
1
0
+ 1
+ 49223292
0
+ 0
+ 5
0
..\..\..\kernel\src\los_sem.c
los_sem.c
@@ -288,10 +276,14 @@
1
- 8
+ 6
1
0
+ 1
+ 49223292
0
+ 0
+ 5
0
..\..\..\kernel\src\los_swtmr.c
los_swtmr.c
@@ -300,10 +292,14 @@
1
- 9
+ 7
1
0
+ 1
+ 49223292
0
+ 0
+ 5
0
..\..\..\kernel\src\los_task.c
los_task.c
@@ -312,10 +308,14 @@
1
- 10
+ 8
1
0
+ 1
+ 49223292
0
+ 0
+ 5
0
..\..\..\kernel\src\los_tick.c
los_tick.c
@@ -324,10 +324,14 @@
1
- 11
+ 9
1
0
+ 1
+ 49223292
0
+ 0
+ 5
0
..\..\..\kernel\src\mm\los_membox.c
los_membox.c
@@ -336,10 +340,14 @@
1
- 12
+ 10
1
0
+ 1
+ 49223292
0
+ 0
+ 5
0
..\..\..\kernel\src\mm\los_memcheck.c
los_memcheck.c
@@ -348,10 +356,14 @@
1
- 13
+ 11
1
0
+ 1
+ 49223292
0
+ 0
+ 5
0
..\..\..\kernel\src\mm\los_memory.c
los_memory.c
@@ -360,10 +372,14 @@
1
- 14
+ 12
1
0
+ 1
+ 49223292
0
+ 0
+ 5
0
..\..\..\kernel\src\mm\los_memstat.c
los_memstat.c
@@ -372,10 +388,14 @@
1
- 15
+ 13
2
0
+ 1
+ 49223292
0
+ 0
+ 5
0
..\..\..\kernel\arch\arm\cortex-m3\keil\los_dispatch.S
los_dispatch.S
@@ -384,34 +404,14 @@
1
- 16
- 2
- 0
- 0
- 0
- ..\..\..\kernel\arch\arm\cortex-m3\keil\los_hw_exc.S
- los_hw_exc.S
- 0
- 0
-
-
- 1
- 17
- 2
- 0
- 0
- 0
- ..\..\..\kernel\arch\arm\cortex-m3\keil\los_vendor.s
- los_vendor.s
- 0
- 0
-
-
- 1
- 18
+ 14
5
0
+ 1
+ 49223292
0
+ 0
+ 5
0
..\..\..\kernel\arch\arm\cortex-m3\keil\cmsis\ARMCM3.h
ARMCM3.h
@@ -420,10 +420,14 @@
1
- 19
+ 15
5
0
+ 1
+ 49223292
0
+ 0
+ 5
0
..\..\..\kernel\arch\arm\cortex-m3\keil\cmsis\core_cm3.h
core_cm3.h
@@ -432,10 +436,14 @@
1
- 20
+ 16
5
0
+ 1
+ 49223292
0
+ 0
+ 5
0
..\..\..\kernel\arch\arm\cortex-m3\keil\cmsis\core_cmFunc.h
core_cmFunc.h
@@ -444,10 +452,14 @@
1
- 21
+ 17
5
0
+ 1
+ 49223292
0
+ 0
+ 5
0
..\..\..\kernel\arch\arm\cortex-m3\keil\cmsis\core_cmInstr.h
core_cmInstr.h
@@ -456,10 +468,14 @@
1
- 22
+ 18
1
0
+ 1
+ 49223292
0
+ 0
+ 5
0
..\..\..\components\cpup\los_cpup.c
los_cpup.c
@@ -468,10 +484,14 @@
1
- 23
+ 19
1
0
+ 1
+ 49223292
0
+ 0
+ 5
0
..\..\..\kernel\arch\arm\cortex-m3\keil\los_interrupt.c
los_interrupt.c
@@ -480,21 +500,89 @@
1
- 24
+ 20
1
0
+ 1
+ 49223292
0
+ 0
+ 5
0
..\..\..\utils\los_error.c
los_error.c
0
0
+
+ 1
+ 21
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ ..\..\..\kernel\arch\arm\cortex-m3\keil\los_context.c
+ los_context.c
+ 0
+ 0
+
+
+ 1
+ 22
+ 1
+ 0
+ 0
+ 1
+ 0
+ 206
+ 216
+ 0
+ ..\..\..\kernel\arch\arm\cortex-m3\keil\los_timer.c
+ los_timer.c
+ 0
+ 0
+
+
+ 1
+ 23
+ 2
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ ..\..\..\kernel\arch\arm\cortex-m3\keil\los_exc.S
+ los_exc.S
+ 0
+ 0
+
+
+ 1
+ 24
+ 2
+ 0
+ 0
+ 0
+ 0
+ 26
+ 45
+ 0
+ ..\..\..\kernel\arch\arm\cortex-m3\keil\los_startup.s
+ los_startup.s
+ 0
+ 0
+
main
- 1
+ 0
0
0
0
@@ -503,7 +591,11 @@
25
1
0
+ 1
+ 49223292
0
+ 0
+ 5
0
..\Driver\STM32F103\uart.c
uart.c
@@ -515,7 +607,11 @@
26
1
0
+ 1
+ 0
0
+ 113
+ 121
0
..\main.c
main.c
@@ -535,7 +631,11 @@
27
1
0
+ 1
+ 49223292
0
+ 0
+ 5
0
..\..\..\components\bounds_checking_function\src\memcpy_s.c
memcpy_s.c
@@ -547,7 +647,11 @@
28
1
0
+ 1
+ 49223292
0
+ 0
+ 5
0
..\..\..\components\bounds_checking_function\src\memmove_s.c
memmove_s.c
@@ -559,7 +663,11 @@
29
1
0
+ 1
+ 49223292
0
+ 0
+ 5
0
..\..\..\components\bounds_checking_function\src\memset_s.c
memset_s.c
@@ -571,7 +679,11 @@
30
1
0
+ 1
+ 49223292
0
+ 0
+ 5
0
..\..\..\components\bounds_checking_function\src\strcpy_s.c
strcpy_s.c
@@ -583,7 +695,11 @@
31
1
0
+ 1
+ 49223292
0
+ 0
+ 5
0
..\..\..\components\bounds_checking_function\src\strncpy_s.c
strncpy_s.c
diff --git a/targets/cortex-m3_stm32f103_simulator_keil/project/los_demo.uvproj b/targets/cortex-m3_stm32f103_simulator_keil/project/los_demo.uvproj
old mode 100755
new mode 100644
index 84044f61..e15f55d2
--- a/targets/cortex-m3_stm32f103_simulator_keil/project/los_demo.uvproj
+++ b/targets/cortex-m3_stm32f103_simulator_keil/project/los_demo.uvproj
@@ -10,7 +10,6 @@
los_demo
0x4
ARM-ADS
- 0
STM32F103RB
@@ -31,7 +30,6 @@
SFD\ST\STM32F1xx\STM32F103xx.sfr
- 0
0
@@ -73,8 +71,6 @@
0
0
- 0
- 0
0
@@ -83,8 +79,6 @@
0
0
- 0
- 0
0
@@ -103,7 +97,6 @@
3
- 1
SARMCM3.DLL
@@ -133,7 +126,6 @@
1
1
0
- 1
0
@@ -145,7 +137,6 @@
0
1
1
- 1
0
0
@@ -178,10 +169,6 @@
BIN\UL2CM3.DLL
-
-
-
- 0
@@ -222,15 +209,12 @@
0
0
0
- 0
- 0
0
0
8
1
0
0
- 0
3
3
0
@@ -363,21 +347,11 @@
0
0
0
- 0
- 0
- 0
- 1
- 1
- 1
- 1
- 0
- 0
- 0
--gnu
- ..\..\cortex-m3_stm32f103_simulator_keil;..\..\..\kernel\include;..\..\..\kernel\arch\arm\cortex-m3\keil;..\..\..\kernel\arch\arm\cortex-m3\keil\cmsis;..\..\..\kernel\src;..\..\..\components\bounds_checking_function\include;..\..\..\components\cpup;..\..\..\utils
+ ..\..\cortex-m3_stm32f103_simulator_keil;..\..\..\kernel\include;..\..\..\kernel\arch\arm\cortex-m3\keil;..\..\..\kernel\arch\arm\cortex-m3\keil\cmsis;..\..\..\kernel\src;..\..\..\components\bounds_checking_function\include;..\..\..\components\cpup;..\..\..\utils;..\..\..\kernel\arch\include
@@ -389,8 +363,6 @@
0
0
0
- 0
- 1
@@ -407,7 +379,6 @@
0
0x08000000
0x20000000
-
.\los_demo.sct
@@ -421,16 +392,6 @@
liteos-m
-
- los_hw.c
- 1
- ..\..\..\kernel\arch\arm\cortex-m3\keil\los_hw.c
-
-
- los_hw_tick.c
- 1
- ..\..\..\kernel\arch\arm\cortex-m3\keil\los_hw_tick.c
-
los_event.c
1
@@ -496,16 +457,6 @@
2
..\..\..\kernel\arch\arm\cortex-m3\keil\los_dispatch.S
-
- los_hw_exc.S
- 2
- ..\..\..\kernel\arch\arm\cortex-m3\keil\los_hw_exc.S
-
-
- los_vendor.s
- 2
- ..\..\..\kernel\arch\arm\cortex-m3\keil\los_vendor.s
-
ARMCM3.h
5
@@ -541,6 +492,26 @@
1
..\..\..\utils\los_error.c
+
+ los_context.c
+ 1
+ ..\..\..\kernel\arch\arm\cortex-m3\keil\los_context.c
+
+
+ los_timer.c
+ 1
+ ..\..\..\kernel\arch\arm\cortex-m3\keil\los_timer.c
+
+
+ los_exc.S
+ 2
+ ..\..\..\kernel\arch\arm\cortex-m3\keil\los_exc.S
+
+
+ los_startup.s
+ 2
+ ..\..\..\kernel\arch\arm\cortex-m3\keil\los_startup.s
+
@@ -592,19 +563,4 @@
-
-
-
- <Project Info>
-
-
-
-
-
- 0
- 1
-
-
-
-
diff --git a/targets/cortex-m3_stm32f103_simulator_keil/target_config.h b/targets/cortex-m3_stm32f103_simulator_keil/target_config.h
old mode 100755
new mode 100644
index 8c59f5eb..68942abb
--- a/targets/cortex-m3_stm32f103_simulator_keil/target_config.h
+++ b/targets/cortex-m3_stm32f103_simulator_keil/target_config.h
@@ -1,15 +1,21 @@
/*
- * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
- * Description: Redistribution and use in source and binary forms, with or without modification,
+ * 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.
+ * conditions and the following disclaimer.
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
- * to endorse or promote products derived from this software without specific prior written
- * permission.
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
@@ -21,13 +27,6 @@
* 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.
- * ---------------------------------------------------------------------------
- * Notice of Export Control Law
- * ===============================================
- * Huawei LiteOS may be subject to applicable export control laws and regulations, which might
- * include those applicable to Huawei LiteOS of U.S. and the country in which you are located.
- * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such
- * applicable export control laws and regulations.
*/
/**@defgroup los_config System configuration items
@@ -37,396 +36,66 @@
#ifndef _TARGET_CONFIG_H
#define _TARGET_CONFIG_H
-#include "los_compiler.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
-#define LOSCFG_CORTEX_M3
-
-//#define LOSCFG_BASE_CORE_MPU YES
-#define LOSCFG_BASE_CORE_MPU NO
-
-#define LOSCFG_BASE_CORE_CPUP YES
/*=============================================================================
System clock module configuration
=============================================================================*/
-
-/**
- * @ingroup los_config
- * System clock (unit: HZ)
- */
-#define OS_SYS_CLOCK 24000000
-
-#define configCPU_CLOCK_HZ ( OS_SYS_CLOCK )
-
-#if( configUSE_16_BIT_TICKS == 1 )
- typedef UINT16 TickType_t;
- #define portMAX_DELAY ( TickType_t ) 0xffff
-#else
- typedef UINT32 TickType_t;
- #define portMAX_DELAY ( TickType_t ) 0xffffffffUL
-
- /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do
- not need to be guarded with a critical section. */
- #define portTICK_TYPE_IS_ATOMIC 1
-#endif
-
-#define configTICK_RATE_HZ ( ( TickType_t ) 1000 )
-
-#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
-
-/**
- * @ingroup los_config
- * Number of Ticks in one second
- */
+#define OS_SYS_CLOCK 24000000
#define LOSCFG_BASE_CORE_TICK_PER_SECOND (1000UL)
-
-/**
- * @ingroup los_config
- * External configuration item for timer tailoring
- */
-#define LOSCFG_BASE_CORE_TICK_HW_TIME NO
-
-/**
- * @ingroup los_config
- * Configuration liteos kernel tickless
- */
-#define LOSCFG_KERNEL_TICKLESS NO
+#define LOSCFG_BASE_CORE_TICK_HW_TIME 0
/*=============================================================================
Hardware interrupt module configuration
=============================================================================*/
-
-/**
- * @ingroup los_config
- * Configuration item for hardware interrupt tailoring
- */
-#define LOSCFG_PLATFORM_HWI YES
-
-/**
- * @ingroup los_config
- * Maximum number of used hardware interrupts, including Tick timer interrupts.
- */
+#define LOSCFG_PLATFORM_HWI 1
#define LOSCFG_PLATFORM_HWI_LIMIT 128
-#define LOSCFG_PLATFORM_HWI_MAX_EXCEPTION_COUNT 65000
-
/*=============================================================================
Task module configuration
=============================================================================*/
-
-/**
- * @ingroup los_config
- * Default task priority
- */
-#define LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO 10
-
-/**
- * @ingroup los_config
- * Maximum supported number of tasks except the idle task rather than the number of usable tasks
- */
-#define LOSCFG_BASE_CORE_TSK_LIMIT 24 // max num task
-
-/**
- * @ingroup los_config
- * Size of the idle task stack
- */
-#define LOSCFG_BASE_CORE_TSK_IDLE_STACK_SIZE (0x500U) // IDLE task stack
-
-/**
- * @ingroup los_config
- * Default task stack size
- */
-#define LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE (0x2D0U) // default stack
-
-/**
- * @ingroup los_config
- * Minimum stack size.
- */
+#define LOSCFG_BASE_CORE_TSK_LIMIT 24
+#define LOSCFG_BASE_CORE_TSK_IDLE_STACK_SIZE (0x500U)
+#define LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE (0x2D0U)
#define LOSCFG_BASE_CORE_TSK_MIN_STACK_SIZE (0x130U)
-
-/**
- * @ingroup los_config
- * Configuration item for task Robin tailoring
- */
-#define LOSCFG_BASE_CORE_TIMESLICE YES
-
-/**
- * @ingroup los_config
- * Longest execution time of tasks with the same priorities
- */
+#define LOSCFG_BASE_CORE_TIMESLICE 1
#define LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT 10
-
-/**
- * @ingroup los_config
- * Configuration item for task (stack) monitoring module tailoring
- */
-#define LOSCFG_BASE_CORE_TSK_MONITOR YES
-
-/**
- * @ingroup los_config
- * Configuration item for task perf task filter hook
- */
-#define LOSCFG_BASE_CORE_EXC_TSK_SWITCH YES
-
-/**
- * @ingroup los_config
- * Configuration item for performance moniter unit
- */
-#define OS_INCLUDE_PERF YES
-
-/**
- * @ingroup los_config
- * Define a usable task priority.Highest task priority.
- */
-#define LOS_TASK_PRIORITY_HIGHEST 0
-
-/**
- * @ingroup los_config
- * Define a usable task priority.Lowest task priority.
- */
-#define LOS_TASK_PRIORITY_LOWEST 31
-
-
/*=============================================================================
Semaphore module configuration
=============================================================================*/
-
-/**
- * @ingroup los_config
- * Configuration item for semaphore module tailoring
- */
-#define LOSCFG_BASE_IPC_SEM YES
-
-/**
- * @ingroup los_config
- * Maximum supported number of semaphores
- */
-#define LOSCFG_BASE_IPC_SEM_LIMIT 48 // the max sem-numb
-
-
+#define LOSCFG_BASE_IPC_SEM 1
+#define LOSCFG_BASE_IPC_SEM_LIMIT 48
/*=============================================================================
Mutex module configuration
=============================================================================*/
-
-/**
- * @ingroup los_config
- * Configuration item for mutex module tailoring
- */
-#define LOSCFG_BASE_IPC_MUX YES
-
-/**
- * @ingroup los_config
- * Maximum supported number of mutexes
- */
-#define LOSCFG_BASE_IPC_MUX_LIMIT 24 // the max mutex-num
-
-
+#define LOSCFG_BASE_IPC_MUX 1
+#define LOSCFG_BASE_IPC_MUX_LIMIT 24
/*=============================================================================
Queue module configuration
=============================================================================*/
-
-/**
- * @ingroup los_config
- * Configuration item for queue module tailoring
- */
-#define LOSCFG_BASE_IPC_QUEUE YES
-
-/**
- * @ingroup los_config
- * Maximum supported number of queues rather than the number of usable queues
- */
-#define LOSCFG_BASE_IPC_QUEUE_LIMIT 24 //the max queue-numb
-
-
+#define LOSCFG_BASE_IPC_QUEUE 1
+#define LOSCFG_BASE_IPC_QUEUE_LIMIT 24
/*=============================================================================
Software timer module configuration
=============================================================================*/
-
-#if (LOSCFG_BASE_IPC_QUEUE == YES)
-/**
- * @ingroup los_config
- * Configuration item for software timer module tailoring
- */
-#define LOSCFG_BASE_CORE_SWTMR YES
-
-#define LOSCFG_BASE_CORE_TSK_SWTMR_STACK_SIZE (LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE * 4)
-
-#define LOSCFG_BASE_CORE_SWTMR_TASK YES
-
-#define LOSCFG_BASE_CORE_SWTMR_ALIGN YES
-#if(LOSCFG_BASE_CORE_SWTMR == NO && LOSCFG_BASE_CORE_SWTMR_ALIGN == YES)
- #error "swtmr align first need support swmtr, should make LOSCFG_BASE_CORE_SWTMR = YES"
-#endif
-
-/**
- * @ingroup los_config
- * Maximum supported number of software timers rather than the number of usable software timers
- */
-#define LOSCFG_BASE_CORE_SWTMR_LIMIT 48 // the max SWTMR numb
-
-/**
- * @ingroup los_config
- * Max number of software timers ID
- */
-#define OS_SWTMR_MAX_TIMERID ((65535/LOSCFG_BASE_CORE_SWTMR_LIMIT) * LOSCFG_BASE_CORE_SWTMR_LIMIT)
-
-/**
- * @ingroup los_config
- * Maximum size of a software timer queue
- */
-#define OS_SWTMR_HANDLE_QUEUE_SIZE (LOSCFG_BASE_CORE_SWTMR_LIMIT + 0)
-
-/**
- * @ingroup los_config
- * Minimum divisor of software timer multiple alignment
- */
-#define LOS_COMMON_DIVISOR 10
-#endif
-
-
+#define LOSCFG_BASE_CORE_SWTMR 1
+#define LOSCFG_BASE_CORE_SWTMR_ALIGN 1
+#define LOSCFG_BASE_CORE_SWTMR_LIMIT 48
/*=============================================================================
Memory module configuration
=============================================================================*/
-
-extern UINT8 *m_aucSysMem0;
-extern UINT32 __LOS_HEAP_ADDR_START__;
-extern UINT32 __LOS_HEAP_ADDR_END__;
-/**
- * @ingroup los_config
- * Starting address of the memory
- */
-#define OS_SYS_MEM_ADDR (VOID *)m_aucSysMem0
-/**
- * @ingroup los_config
- * Ending address of the memory
- */
-extern UINT32 g_sys_mem_addr_end;
-
-/**
- * @ingroup los_config
- * Memory size
- */
-#define OS_SYS_MEM_SIZE 0x00014000
-
-/**
- * @ingroup los_config
- * Configuration module tailoring of mem node integrity checking
- */
-#define LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK YES
-
-/**
- * @ingroup los_config
- * Configuration module tailoring of mem node size checking
- */
-#define LOSCFG_BASE_MEM_NODE_SIZE_CHECK YES
-
-#define LOSCFG_MEMORY_BESTFIT YES
-
-/**
- * @ingroup los_config
- * Configuration module tailoring of more mempry pool checking
- */
-#define LOSCFG_MEM_MUL_POOL YES
-
-/**
- * @ingroup los_config
- * Number of memory checking blocks
- */
+#define OS_SYS_MEM_SIZE 0x00013000
+#define LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK 0
+#define LOSCFG_BASE_MEM_NODE_SIZE_CHECK 1
+#define LOSCFG_MEM_MUL_POOL 1
#define OS_SYS_MEM_NUM 20
-
-/**
- * @ingroup los_config
- * Configuration module tailoring of slab memory
- */
-#define LOSCFG_KERNEL_MEM_SLAB NO
-
-
-/*=============================================================================
- fw Interface configuration
-=============================================================================*/
-
-/**
- * @ingroup los_config
- * Configuration item for the monitoring of task communication
- */
-#define LOSCFG_COMPAT_CMSIS_FW YES
-
-
-/*=============================================================================
- others
-=============================================================================*/
-
-/**
- * @ingroup los_config
- * Configuration system wake-up info to open
- */
-#define OS_SR_WAKEUP_INFO YES
-
-/**
- * @ingroup los_config
- * Configuration CMSIS_OS_VER
- */
-#define CMSIS_OS_VER 2
-
-
+#define LOSCFG_KERNEL_MEM_SLAB 0
/*=============================================================================
Exception module configuration
=============================================================================*/
-
-/**
- * @ingroup los_config
- * Configuration item for exception tailoring
- */
-#define LOSCFG_PLATFORM_EXC YES
-
-
-/*=============================================================================
- Runstop module configuration
-=============================================================================*/
-
-/**
- * @ingroup los_config
- * Configuration item for runstop module tailoring
- */
-#define LOSCFG_KERNEL_RUNSTOP NO
-
-
-
-/**
- * @ingroup los_config
- * Configuration test case to open
- */
-
-
-
-#define LOSCFG_EXCLUDE_TEST
-
-#ifndef LOSCFG_EXCLUDE_TEST
-#define LOSCFG_TEST YES
-#else
-#define LOSCFG_TEST NO
-#endif
-
-
-
-/*=============================================================================
- track configuration
-=============================================================================*/
-
-/**
- * @ingroup los_config
- * Configuration item for track
- */
-#define LOSCFG_BASE_MISC_TRACK NO
-
-/**
- * @ingroup los_config
- * Max count of track items
- */
-#define LOSCFG_BASE_MISC_TRACK_MAX_COUNT 1024
-
+#define LOSCFG_PLATFORM_EXC 1
#ifdef __cplusplus
#if __cplusplus
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Include/system_stm32f4xx.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Include/system_stm32f4xx.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f401xx.s b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f401xx.s
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f40_41xxx.s b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f40_41xxx.s
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f40xx.s b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f40xx.s
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f410xx.s b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f410xx.s
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f411xe.s b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f411xe.s
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f412xg.s b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f412xg.s
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f413_423xx.s b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f413_423xx.s
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f427_437xx.s b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f427_437xx.s
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f427x.s b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f427x.s
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f429_439xx.s b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f429_439xx.s
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f446xx.s b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f446xx.s
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f469_479xx.s b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f469_479xx.s
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/misc.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/misc.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_adc.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_adc.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_can.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_can.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_cec.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_cec.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_crc.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_crc.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_cryp.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_cryp.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dac.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dac.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dbgmcu.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dbgmcu.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dcmi.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dcmi.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dfsdm.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dfsdm.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dma.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dma.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dma2d.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dma2d.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dsi.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dsi.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_exti.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_exti.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_flash.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_flash.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_flash_ramfunc.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_flash_ramfunc.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_fmc.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_fmc.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_fmpi2c.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_fmpi2c.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_fsmc.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_fsmc.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_gpio.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_gpio.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_hash.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_hash.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_i2c.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_i2c.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_iwdg.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_iwdg.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_lptim.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_lptim.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_ltdc.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_ltdc.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_pwr.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_pwr.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_qspi.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_qspi.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_rcc.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_rcc.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_rng.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_rng.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_rtc.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_rtc.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_sai.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_sai.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_sdio.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_sdio.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_spdifrx.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_spdifrx.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_spi.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_spi.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_syscfg.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_syscfg.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_tim.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_tim.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_usart.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_usart.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_wwdg.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_wwdg.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/misc.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/misc.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_adc.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_adc.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_can.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_can.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_cec.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_cec.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_crc.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_crc.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_cryp.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_cryp.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_cryp_aes.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_cryp_aes.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_cryp_des.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_cryp_des.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_cryp_tdes.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_cryp_tdes.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dac.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dac.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dbgmcu.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dbgmcu.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dcmi.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dcmi.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dfsdm.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dfsdm.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dma.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dma.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dma2d.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dma2d.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dsi.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dsi.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_exti.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_exti.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_flash.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_flash.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_flash_ramfunc.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_flash_ramfunc.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_fmc.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_fmc.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_fmpi2c.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_fmpi2c.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_fsmc.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_fsmc.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_hash.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_hash.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_hash_md5.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_hash_md5.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_hash_sha1.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_hash_sha1.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_i2c.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_i2c.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_iwdg.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_iwdg.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_lptim.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_lptim.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_ltdc.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_ltdc.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_pwr.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_pwr.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_qspi.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_qspi.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rng.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rng.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rtc.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rtc.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_sai.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_sai.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_sdio.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_sdio.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_spdifrx.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_spdifrx.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_spi.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_spi.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_syscfg.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_syscfg.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_tim.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_tim.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_usart.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_usart.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_wwdg.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_wwdg.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Utilities/STM32_EVAL/Common/stm32_eval_legacy.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Utilities/STM32_EVAL/Common/stm32_eval_legacy.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Utilities/STM32_EVAL/STM324x9I_EVAL/stm324x9i_eval.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Utilities/STM32_EVAL/STM324x9I_EVAL/stm324x9i_eval.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Utilities/STM32_EVAL/STM324x9I_EVAL/stm324x9i_eval.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Utilities/STM32_EVAL/STM324x9I_EVAL/stm324x9i_eval.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/board/iar_stm32f429ig_fire-challenger.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/board/iar_stm32f429ig_fire-challenger.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/board/iar_stm32f429ig_fire-challenger.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/board/iar_stm32f429ig_fire-challenger.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/dprintf.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/dprintf.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/main.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/main.c
old mode 100755
new mode 100644
index a6ce45a7..97a4c60d
--- a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/main.c
+++ b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/main.c
@@ -1,15 +1,21 @@
/*
- * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
- * Description: Redistribution and use in source and binary forms, with or without modification,
+ * 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.
+ * conditions and the following disclaimer.
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
- * to endorse or promote products derived from this software without specific prior written
- * permission.
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
@@ -21,13 +27,6 @@
* 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.
- * ---------------------------------------------------------------------------
- * Notice of Export Control Law
- * ===============================================
- * Huawei LiteOS may be subject to applicable export control laws and regulations, which might
- * include those applicable to Huawei LiteOS of U.S. and the country in which you are located.
- * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such
- * applicable export control laws and regulations.
*/
#include "los_tick.h"
@@ -49,7 +48,6 @@ UINT8 g_memStart[OS_SYS_MEM_SIZE];
VOID taskSampleEntry2(VOID)
{
- UINT32 uwRet;
while(1) {
LOS_TaskDelay(10000);
printf("taskSampleEntry2 running...\n");
@@ -59,7 +57,6 @@ VOID taskSampleEntry2(VOID)
VOID taskSampleEntry1(VOID)
{
- UINT32 uwRet;
while(1) {
LOS_TaskDelay(2000);
printf("taskSampleEntry1 running...\n");
@@ -70,20 +67,25 @@ VOID taskSampleEntry1(VOID)
UINT32 taskSample(VOID)
{
UINT32 uwRet;
- UINT32 taskID1,taskID2;
+ UINT32 taskID1,taskID2;
TSK_INIT_PARAM_S stTask1={0};
stTask1.pfnTaskEntry = (TSK_ENTRY_FUNC)taskSampleEntry1;
stTask1.uwStackSize = 0X1000;
stTask1.pcName = "taskSampleEntry1";
stTask1.usTaskPrio = 6;
uwRet = LOS_TaskCreate(&taskID1, &stTask1);
+ if (uwRet != LOS_OK) {
+ printf("task1 create failed\n");
+ }
stTask1.pfnTaskEntry = (TSK_ENTRY_FUNC)taskSampleEntry2;
stTask1.uwStackSize = 0X1000;
stTask1.pcName = "taskSampleEntry2";
stTask1.usTaskPrio = 7;
uwRet = LOS_TaskCreate(&taskID2, &stTask1);
-
+ if (uwRet != LOS_OK) {
+ printf("task2 create failed\n");
+ }
return LOS_OK;
}
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/config/stm32f429xG.icf b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/config/stm32f429xG.icf
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/los_demo.dep b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/los_demo.dep
old mode 100755
new mode 100644
index 8029b198..eb10e772
--- a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/los_demo.dep
+++ b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/los_demo.dep
@@ -1,342 +1,301 @@
2
- 2019208183
+ 4111223328
Debug
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_exc.S
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_interrupt.c
- $PROJ_DIR$\..\..\..\components\cpup\los_cpup.c
- $PROJ_DIR$\..\..\..\kernel\src\los_err.c
- $PROJ_DIR$\..\..\..\components\cppsupport\los_cppsupport.c
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_dispatch.S
- $PROJ_DIR$\..\..\..\kernel\src\los_event.c
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw.c
- $PROJ_DIR$\..\..\..\kernel\src\mm\los_membox.c
- $PROJ_DIR$\..\..\..\kernel\src\los_init.c
$PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_tick.c
- $PROJ_DIR$\Debug\Obj\main.o
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_rcc.h
- $TOOLKIT_DIR$\CMSIS\Include\cmsis_compiler.h
- $PROJ_DIR$\Debug\Obj\los_membox.__cstat.et
- $PROJ_DIR$\Debug\Obj\los_memstat.__cstat.et
- $TOOLKIT_DIR$\CMSIS\Include\core_cm4.h
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_usart.h
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_wwdg.h
- $TOOLKIT_DIR$\inc\c\DLib_Config_Full.h
- $PROJ_DIR$\Debug\Obj\los_misc.__cstat.et
- $PROJ_DIR$\Debug\Obj\los_timeslice.pbi
- $PROJ_DIR$\Debug\Obj\dprintf.__cstat.et
- $PROJ_DIR$\Debug\Obj\los_exc.pbi
- $TOOLKIT_DIR$\inc\c\iccarm_builtin.h
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_pwr.h
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_crc.h
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_ltdc.h
- $PROJ_DIR$\Debug\Obj\los_cppsupport.o
- $PROJ_DIR$\Debug\Obj\los_hw_tick.pbi
- $PROJ_DIR$\Debug\Obj\los_event.__cstat.et
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_exti.h
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_flash.h
- $PROJ_DIR$\..\..\..\kernel\include\los_config.h
- $PROJ_DIR$\Debug\Obj\dprintf.o
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_rtc.h
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_syscfg.h
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_tim.h
- $PROJ_DIR$\Debug\Obj\los_cppsupport.pbi
- $PROJ_DIR$\..\..\..\utils\los_debug.h
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_dma2d.h
- $PROJ_DIR$\..\Libraries\CMSIS\Device\ST\STM32F4xx\Include\system_stm32f4xx.h
- $PROJ_DIR$\..\..\..\kernel\include\los_task.h
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_interrupt.h
- $TOOLKIT_DIR$\inc\c\DLib_Product.h
- $PROJ_DIR$\Debug\Obj\misc.o
- $PROJ_DIR$\Debug\Obj\los_init.__cstat.et
- $PROJ_DIR$\Debug\Exe\los_demo.out
- $PROJ_DIR$\Debug\Obj\los_exc.__cstat.et
- $PROJ_DIR$\..\..\..\components\cpup\los_cpup.h
- $TOOLKIT_DIR$\inc\c\stdio.h
- $PROJ_DIR$\Debug\Obj\dprintf.pbi
- $PROJ_DIR$\Debug\Obj\los_hw.__cstat.et
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_rng.h
- $PROJ_DIR$\..\board\iar_stm32f429ig_fire-challenger.h
- $PROJ_DIR$\Debug\Obj\los_cppsupport.__cstat.et
- $PROJ_DIR$\..\..\..\kernel\include\los_sem.h
- $PROJ_DIR$\Debug\Obj\los_hw_exc_iar.o
- $PROJ_DIR$\Debug\Obj\los_hw.pbi
- $PROJ_DIR$\Debug\Obj\los_dispatch_iar.o
- $TOOLKIT_DIR$\inc\c\yvals.h
- $PROJ_DIR$\config\stm32f429xG.icf
- $TOOLKIT_DIR$\inc\c\DLib_Defaults.h
- $TOOLKIT_DIR$\lib\dl7M_tlf.a
- $PROJ_DIR$\..\..\..\kernel\include\los_swtmr.h
- $PROJ_DIR$\Debug\Obj\los_hw_tick.o
- $PROJ_DIR$\Debug\Obj\main.pbi
- $PROJ_DIR$\Debug\Obj\los_memory.pbi
- $PROJ_DIR$\Debug\Obj\los_hw.o
- $PROJ_DIR$\Debug\Obj\stm32f4xx_exti.o
- $PROJ_DIR$\..\Utilities\STM32_EVAL\Common\stm32_eval_legacy.h
- $PROJ_DIR$\Debug\Obj\los_err.__cstat.et
- $TOOLKIT_DIR$\inc\c\ycheck.h
- $TOOLKIT_DIR$\inc\c\ysizet.h
- $PROJ_DIR$\Debug\Obj\misc.pbi
- $PROJ_DIR$\..\..\..\kernel\src\los_sys.c
- $PROJ_DIR$\Debug\Obj\stm32f4xx_rcc.pbi
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_interrupt.c
+ $PROJ_DIR$\..\..\..\components\cppsupport\los_cppsupport.c
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw.c
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_exc.S
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_dispatch.S
$PROJ_DIR$\Debug\Obj\los_membox.pbi
- $PROJ_DIR$\Debug\Obj\los_dispatch.o
+ $PROJ_DIR$\Debug\Obj\los_memstat.pbi
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_usart.o
+ $PROJ_DIR$\..\..\..\kernel\src\los_sys.c
+ $PROJ_DIR$\Debug\Obj\los_memcheck.__cstat.et
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_syscfg.o
$PROJ_DIR$\..\..\..\kernel\src\los_priqueue.c
- $PROJ_DIR$\Debug\Obj\los_cpup.pbi
- $PROJ_DIR$\Debug\Obj\stm32f4xx_exti.pbi
- $PROJ_DIR$\Debug\Obj\los_mux.o
- $PROJ_DIR$\Debug\Obj\los_memcheck.pbi
- $PROJ_DIR$\..\..\..\components\cppsupport\los_cppsupport.h
- $PROJ_DIR$\Debug\Obj\stm32f4xx_wwdg.pbi
+ $PROJ_DIR$\..\Libraries\CMSIS\Device\ST\STM32F4xx\Include\stm32f4xx.h
$PROJ_DIR$\Debug\Obj\stm32f4xx_syscfg.pbi
$PROJ_DIR$\Debug\Obj\stm32f4xx_wwdg.o
$PROJ_DIR$\Debug\Obj\los_memory.o
- $PROJ_DIR$\Debug\Obj\los_memcheck.__cstat.et
- $PROJ_DIR$\Debug\Obj\stm32f4xx_syscfg.o
- $PROJ_DIR$\Debug\Obj\los_memstat.pbi
- $PROJ_DIR$\..\Libraries\CMSIS\Device\ST\STM32F4xx\Include\stm32f4xx.h
- $PROJ_DIR$\Debug\Obj\stm32f4xx_usart.pbi
- $PROJ_DIR$\..\..\..\utils\los_compiler.h
$PROJ_DIR$\Debug\Obj\stm32f4xx_tim.pbi
$PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_hash.h
- $PROJ_DIR$\Debug\Obj\stm32f4xx_usart.o
- $PROJ_DIR$\Debug\Obj\stm32f4xx_tim.o
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_rcc.pbi
$PROJ_DIR$\Debug\Obj\los_hw_exc.o
- $PROJ_DIR$\Debug\Obj\los_cpup.__cstat.et
- $PROJ_DIR$\Debug\Obj\los_interrupt.o
$PROJ_DIR$\Debug\Obj\los_priqueue.o
$PROJ_DIR$\Debug\Obj\los_memory.__cstat.et
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_wwdg.pbi
$PROJ_DIR$\Debug\Obj\stm32f4xx_gpio.o
+ $PROJ_DIR$\Debug\Obj\los_cpup.__cstat.et
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_usart.pbi
$PROJ_DIR$\Debug\Obj\los_queue.pbi
+ $PROJ_DIR$\Debug\Obj\los_dispatch.o
+ $PROJ_DIR$\Debug\Obj\los_mux.o
+ $PROJ_DIR$\Debug\Obj\los_cpup.pbi
+ $PROJ_DIR$\..\..\..\components\cppsupport\los_cppsupport.h
+ $PROJ_DIR$\..\..\..\utils\los_compiler.h
+ $PROJ_DIR$\Debug\Obj\los_memcheck.pbi
+ $PROJ_DIR$\Debug\Obj\los_interrupt.o
$PROJ_DIR$\Debug\Obj\los_interrupt.pbi
- $PROJ_DIR$\Debug\Obj\los_error.pbi
- $PROJ_DIR$\Debug\Obj\los_error.o
- $PROJ_DIR$\Debug\Obj\los_queue.o
- $TOOLKIT_DIR$\inc\c\stdarg.h
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_tim.o
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_exti.pbi
+ $TOOLKIT_DIR$\lib\dl7M_tlf.a
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_exti.o
+ $PROJ_DIR$\Debug\Obj\dprintf.pbi
+ $PROJ_DIR$\..\board\iar_stm32f429ig_fire-challenger.h
+ $TOOLKIT_DIR$\inc\c\yvals.h
+ $PROJ_DIR$\Debug\Obj\misc.o
+ $PROJ_DIR$\Debug\Obj\los_init.__cstat.et
+ $TOOLKIT_DIR$\inc\c\DLib_Product.h
+ $TOOLKIT_DIR$\inc\c\DLib_Defaults.h
+ $PROJ_DIR$\..\..\..\components\cpup\los_cpup.h
+ $TOOLKIT_DIR$\inc\c\stdio.h
+ $PROJ_DIR$\..\..\..\kernel\include\los_swtmr.h
+ $PROJ_DIR$\Debug\Obj\los_cppsupport.__cstat.et
+ $PROJ_DIR$\Debug\Obj\los_hw.o
+ $PROJ_DIR$\..\Utilities\STM32_EVAL\Common\stm32_eval_legacy.h
+ $PROJ_DIR$\Debug\Obj\misc.pbi
+ $PROJ_DIR$\Debug\Obj\los_hw.pbi
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_rng.h
+ $TOOLKIT_DIR$\inc\c\ycheck.h
+ $PROJ_DIR$\Debug\Obj\los_hw_tick.o
+ $PROJ_DIR$\Debug\Obj\los_hw_exc_iar.o
+ $PROJ_DIR$\Debug\Obj\main.pbi
+ $PROJ_DIR$\config\stm32f429xG.icf
+ $PROJ_DIR$\Debug\Obj\los_dispatch_iar.o
+ $PROJ_DIR$\Debug\Obj\los_memory.pbi
+ $PROJ_DIR$\..\..\..\kernel\include\los_sem.h
+ $PROJ_DIR$\Debug\Obj\los_err.__cstat.et
+ $TOOLKIT_DIR$\inc\c\ysizet.h
+ $PROJ_DIR$\Debug\Obj\los_exc.__cstat.et
+ $PROJ_DIR$\Debug\Exe\los_demo.out
+ $PROJ_DIR$\Debug\Obj\los_hw.__cstat.et
+ $PROJ_DIR$\Debug\Obj\los_exc.pbi
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_ltdc.h
+ $PROJ_DIR$\Debug\Obj\los_cppsupport.o
+ $PROJ_DIR$\..\..\..\kernel\include\los_config.h
+ $PROJ_DIR$\Debug\Obj\dprintf.o
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_rtc.h
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_tim.h
+ $PROJ_DIR$\Debug\Obj\los_hw_tick.pbi
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_wwdg.h
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_syscfg.h
+ $PROJ_DIR$\Debug\Obj\los_membox.__cstat.et
+ $PROJ_DIR$\Debug\Obj\los_memstat.__cstat.et
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_flash.h
+ $PROJ_DIR$\Debug\Obj\los_cppsupport.pbi
+ $PROJ_DIR$\..\..\..\utils\los_debug.h
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_exti.h
+ $PROJ_DIR$\Debug\Obj\dprintf.__cstat.et
+ $PROJ_DIR$\Debug\Obj\los_event.__cstat.et
+ $PROJ_DIR$\..\Libraries\CMSIS\Device\ST\STM32F4xx\Include\system_stm32f4xx.h
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_pwr.h
+ $TOOLKIT_DIR$\inc\c\DLib_Config_Full.h
+ $PROJ_DIR$\..\..\..\kernel\include\los_task.h
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_interrupt.h
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_dma2d.h
+ $TOOLKIT_DIR$\CMSIS\Include\core_cm4.h
+ $TOOLKIT_DIR$\CMSIS\Include\cmsis_compiler.h
+ $PROJ_DIR$\Debug\Obj\los_timeslice.pbi
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_rcc.h
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_usart.h
+ $PROJ_DIR$\Debug\Obj\los_misc.__cstat.et
+ $TOOLKIT_DIR$\inc\c\iccarm_builtin.h
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_crc.h
+ $PROJ_DIR$\..\..\..\kernel\src\mm\los_membox.c
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_usart.c
+ $PROJ_DIR$\..\..\..\kernel\src\los_mux.c
+ $PROJ_DIR$\Debug\Obj\main.o
+ $PROJ_DIR$\..\..\..\components\cpup\los_cpup.c
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_wwdg.c
$PROJ_DIR$\..\..\..\utils\los_error.c
- $PROJ_DIR$\Debug\Obj\startup_stm32f429_439xx.o
- $PROJ_DIR$\Debug\Obj\los_swtmr.__cstat.et
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_gpio.h
- $TOOLKIT_DIR$\inc\c\DLib_Product_string.h
- $TOOLKIT_DIR$\lib\m7M_tls.a
- $PROJ_DIR$\..\..\..\kernel\include\los_mux.h
- $PROJ_DIR$\Debug\Obj\los_sys.pbi
- $PROJ_DIR$\..\..\..\components\bounds_checking_function\include\securectype.h
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_dispatch_iar.S
- $PROJ_DIR$\Debug\Obj\los_task.__cstat.et
- $PROJ_DIR$\Debug\Obj\los_mux.pbi
- $PROJ_DIR$\Debug\Obj\los_timeslice.__cstat.et
- $PROJ_DIR$\..\stm32f4xx_conf.h
- $PROJ_DIR$\Debug\Obj\los_queue.__cstat.et
- $PROJ_DIR$\Debug\Obj\system_stm32f4xx.__cstat.et
- $PROJ_DIR$\Debug\Obj\stm32f4xx_tim.__cstat.et
- $TOOLKIT_DIR$\inc\c\cmsis_iar.h
- $PROJ_DIR$\Debug\Obj\stm324x9i_eval.__cstat.et
- $PROJ_DIR$\Debug\Obj\los_mux.__cstat.et
- $PROJ_DIR$\Debug\Obj\stm32f4xx_gpio.__cstat.et
- $PROJ_DIR$\Debug\List\los_demo.map
- $PROJ_DIR$\Debug\Obj\stm32f4xx_syscfg.__cstat.et
- $PROJ_DIR$\Debug\Obj\system_stm32f4xx.pbi
- $PROJ_DIR$\Debug\Obj\stm32f4xx_usart.__cstat.et
- $PROJ_DIR$\Debug\Obj\los_sys.__cstat.et
- $PROJ_DIR$\Debug\Obj\misc.__cstat.et
- $PROJ_DIR$\Debug\Obj\iar_stm32f429ig_fire-challenger.pbi
+ $PROJ_DIR$\..\..\..\kernel\src\los_tick.c
+ $PROJ_DIR$\..\..\..\kernel\src\los_swtmr.c
+ $PROJ_DIR$\..\..\..\kernel\src\los_task.c
+ $PROJ_DIR$\..\board\iar_stm32f429ig_fire-challenger.c
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_exti.c
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_gpio.c
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_rcc.c
+ $PROJ_DIR$\..\..\..\kernel\src\mm\los_memcheck.c
+ $PROJ_DIR$\..\..\..\kernel\src\los_init.c
+ $PROJ_DIR$\..\..\..\kernel\src\mm\los_memstat.c
+ $PROJ_DIR$\..\..\..\kernel\src\los_queue.c
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_syscfg.c
+ $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval.c
+ $PROJ_DIR$\..\..\..\kernel\src\los_sem.c
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\misc.c
+ $PROJ_DIR$\..\Libraries\CMSIS\Device\ST\STM32F4xx\Source\Templates\iar\startup_stm32f429_439xx.s
+ $PROJ_DIR$\..\Libraries\CMSIS\Device\ST\STM32F4xx\Source\Templates\system_stm32f4xx.c
+ $PROJ_DIR$\..\dprintf.c
+ $PROJ_DIR$\..\..\..\kernel\src\los_event.c
+ $PROJ_DIR$\..\..\..\kernel\src\mm\los_memory.c
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_tim.c
+ $PROJ_DIR$\..\target_config.h
+ $PROJ_DIR$\..\..\..\kernel\src\los_err.c
+ $PROJ_DIR$\..\main.c
+ $TOOLKIT_DIR$\inc\c\stdlib.h
+ $PROJ_DIR$\..\..\..\kernel\include\los_memory.h
+ $PROJ_DIR$\..\..\..\kernel\include\los_event.h
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_sdio.h
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_adc.h
$PROJ_DIR$\Debug\Obj\los_tick.__cstat.et
$PROJ_DIR$\Debug\Obj\iar_stm32f429ig_fire-challenger.o
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_exc.c
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_adc.h
- $PROJ_DIR$\Debug\Obj\stm32f4xx_exti.__cstat.et
$PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_dbgmcu.h
$PROJ_DIR$\Debug\Obj\los_demo.pbd
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_exti.__cstat.et
$PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_can.h
$PROJ_DIR$\..\..\..\kernel\include\los_membox.h
$PROJ_DIR$\Debug\Obj\los_cpup.o
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_fmc.h
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_exc.c
$PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_spi.h
$PROJ_DIR$\Debug\Obj\main.__cstat.et
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\misc.h
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_fmc.h
- $PROJ_DIR$\..\..\..\utils\los_error.h
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_i2c.h
$PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_dma.h
- $PROJ_DIR$\..\..\..\kernel\include\los_event.h
- $TOOLKIT_DIR$\inc\c\string.h
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_sai.h
$PROJ_DIR$\..\..\..\components\bounds_checking_function\include\securec.h
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_iwdg.h
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_dac.h
$PROJ_DIR$\..\..\..\kernel\include\los_queue.h
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_dac.h
$PROJ_DIR$\..\..\..\kernel\include\los_tick.h
$PROJ_DIR$\..\..\..\utils\los_list.h
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_sai.h
+ $PROJ_DIR$\..\..\..\utils\los_error.h
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_iwdg.h
$TOOLKIT_DIR$\inc\c\stddef.h
$PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_dcmi.h
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_i2c.h
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\misc.h
+ $TOOLKIT_DIR$\inc\c\string.h
$TOOLKIT_DIR$\inc\c\errno.h
- $TOOLKIT_DIR$\inc\c\stdlib.h
- $PROJ_DIR$\..\..\..\kernel\include\los_memory.h
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_sdio.h
- $TOOLKIT_DIR$\inc\c\stdint.h
- $PROJ_DIR$\Debug\Obj\iar_stm32f429ig_fire-challenger.__cstat.et
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_cryp.h
- $TOOLKIT_DIR$\inc\c\DLib_Product_stdlib.h
- $PROJ_DIR$\Debug\Obj\stm324x9i_eval.pbi
- $PROJ_DIR$\Debug\Obj\los_misc.pbi
- $TOOLKIT_DIR$\lib\rt7M_tl.a
- $PROJ_DIR$\Debug\Obj\los_sem.__cstat.et
- $PROJ_DIR$\Debug\Obj\los_membox.o
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_syscfg.__cstat.et
+ $PROJ_DIR$\Debug\Obj\system_stm32f4xx.pbi
+ $PROJ_DIR$\Debug\Obj\misc.__cstat.et
+ $PROJ_DIR$\Debug\Obj\iar_stm32f429ig_fire-challenger.pbi
+ $PROJ_DIR$\Debug\Obj\los_queue.o
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_usart.__cstat.et
+ $PROJ_DIR$\Debug\Obj\los_mux.pbi
+ $PROJ_DIR$\Debug\Obj\los_sys.__cstat.et
+ $PROJ_DIR$\Debug\Obj\los_error.pbi
+ $TOOLKIT_DIR$\lib\m7M_tls.a
+ $PROJ_DIR$\..\..\..\kernel\include\los_mux.h
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_dispatch_iar.S
+ $PROJ_DIR$\Debug\Obj\los_task.__cstat.et
+ $PROJ_DIR$\Debug\Obj\los_sys.pbi
+ $PROJ_DIR$\Debug\Obj\system_stm32f4xx.__cstat.et
+ $PROJ_DIR$\Debug\Obj\los_queue.__cstat.et
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_tim.__cstat.et
+ $TOOLKIT_DIR$\inc\c\stdarg.h
+ $PROJ_DIR$\Debug\Obj\los_error.o
+ $PROJ_DIR$\Debug\Obj\startup_stm32f429_439xx.o
+ $PROJ_DIR$\Debug\Obj\los_timeslice.__cstat.et
+ $PROJ_DIR$\..\stm32f4xx_conf.h
+ $TOOLKIT_DIR$\inc\c\cmsis_iar.h
+ $PROJ_DIR$\Debug\Obj\stm324x9i_eval.__cstat.et
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_gpio.__cstat.et
+ $TOOLKIT_DIR$\inc\c\DLib_Product_string.h
+ $PROJ_DIR$\Debug\Obj\los_mux.__cstat.et
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_gpio.h
+ $PROJ_DIR$\..\..\..\components\bounds_checking_function\include\securectype.h
+ $PROJ_DIR$\Debug\List\los_demo.map
+ $PROJ_DIR$\Debug\Obj\los_swtmr.__cstat.et
+ $PROJ_DIR$\Debug\Obj\los_event.pbi
$PROJ_DIR$\Debug\Obj\los_sem.pbi
- $PROJ_DIR$\Debug\Obj\los_swtmr.o
+ $PROJ_DIR$\Debug\Obj\los_err.pbi
+ $PROJ_DIR$\Debug\Obj\stm324x9i_eval.pbi
+ $PROJ_DIR$\Debug\Obj\los_swtmr.pbi
+ $PROJ_DIR$\Debug\Obj\los_tick.pbi
+ $PROJ_DIR$\Debug\Obj\stm324x9i_eval.o
+ $PROJ_DIR$\Debug\Obj\iar_stm32f429ig_fire-challenger.__cstat.et
+ $PROJ_DIR$\Debug\Obj\los_sem.__cstat.et
+ $PROJ_DIR$\Debug\Obj\los_event.o
+ $PROJ_DIR$\Debug\Obj\los_err.o
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_cryp.h
+ $PROJ_DIR$\Debug\Obj\los_misc.pbi
+ $PROJ_DIR$\Debug\Obj\los_membox.o
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_rcc.o
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_exc_iar.S
+ $PROJ_DIR$\Debug\Obj\los_sys.o
+ $TOOLKIT_DIR$\inc\c\DLib_Product_stdlib.h
+ $TOOLKIT_DIR$\lib\rt7M_tl.a
$PROJ_DIR$\Debug\Obj\los_memstat.o
$PROJ_DIR$\Debug\Obj\los_tick.o
$PROJ_DIR$\Debug\Obj\los_misc.o
- $PROJ_DIR$\Debug\Obj\los_err.o
- $PROJ_DIR$\Debug\Obj\los_memcheck.o
- $PROJ_DIR$\Debug\Obj\los_event.o
- $PROJ_DIR$\Debug\Obj\stm32f4xx_wwdg.__cstat.et
- $PROJ_DIR$\Debug\Obj\stm32f4xx_rcc.o
- $PROJ_DIR$\Debug\Obj\stm32f4xx_gpio.pbi
- $PROJ_DIR$\Debug\Obj\los_swtmr.pbi
- $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval.h
$PROJ_DIR$\Debug\Obj\los_task.o
- $PROJ_DIR$\Debug\Obj\los_event.pbi
- $PROJ_DIR$\Debug\Obj\los_err.pbi
$PROJ_DIR$\Debug\Obj\los_task.pbi
- $PROJ_DIR$\Debug\Obj\los_tick.pbi
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_exc_iar.S
- $PROJ_DIR$\Debug\Obj\los_priqueue.pbi
- $PROJ_DIR$\Debug\Obj\los_sys.o
$PROJ_DIR$\Debug\Obj\los_hw_tick.__cstat.et
- $PROJ_DIR$\Debug\Obj\stm324x9i_eval.o
- $TOOLKIT_DIR$\lib\shb_l.a
- $PROJ_DIR$\Debug\Obj\los_timeslice.o
- $PROJ_DIR$\Debug\Obj\stm32f4xx_rcc.__cstat.et
- $PROJ_DIR$\Debug\Obj\los_priqueue.__cstat.et
- $PROJ_DIR$\..\..\..\kernel\src\los_tick.c
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_tim.c
- $PROJ_DIR$\..\dprintf.c
- $PROJ_DIR$\..\main.c
- $PROJ_DIR$\Debug\Obj\los_init.pbi
- $PROJ_DIR$\Debug\Obj\los_init.o
- $PROJ_DIR$\..\..\..\kernel\src\los_sem.c
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\misc.c
- $PROJ_DIR$\..\..\..\kernel\src\mm\los_memcheck.c
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_gpio.c
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_usart.c
- $PROJ_DIR$\..\..\..\kernel\src\los_mux.c
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_wwdg.c
- $PROJ_DIR$\..\Libraries\CMSIS\Device\ST\STM32F4xx\Source\Templates\system_stm32f4xx.c
- $PROJ_DIR$\..\..\..\kernel\src\los_timeslice.c
- $PROJ_DIR$\..\..\..\kernel\src\mm\los_memory.c
- $PROJ_DIR$\..\Libraries\CMSIS\Device\ST\STM32F4xx\Source\Templates\iar\startup_stm32f429_439xx.s
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_exti.c
- $PROJ_DIR$\Debug\Obj\system_stm32f4xx.o
+ $PROJ_DIR$\Debug\Obj\los_priqueue.pbi
+ $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval.h
+ $PROJ_DIR$\Debug\Obj\los_swtmr.o
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_gpio.pbi
+ $PROJ_DIR$\Debug\Obj\los_memcheck.o
+ $TOOLKIT_DIR$\inc\c\stdint.h
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_wwdg.__cstat.et
$PROJ_DIR$\..\..\..\kernel\src\los_misc.c
- $PROJ_DIR$\..\..\..\kernel\src\los_queue.c
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_rcc.c
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_syscfg.c
- $PROJ_DIR$\..\board\iar_stm32f429ig_fire-challenger.c
- $PROJ_DIR$\..\target_config.h
- $PROJ_DIR$\..\..\..\kernel\src\mm\los_memstat.c
- $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval.c
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_context.h
+ $TOOLKIT_DIR$\CMSIS\Core\Include\cmsis_compiler.h
+ $PROJ_DIR$\..\..\..\kernel\src\los_timeslice.c
+ $TOOLKIT_DIR$\CMSIS\Core\Include\cmsis_version.h
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_rcc.__cstat.et
+ $PROJ_DIR$\Debug\Obj\los_timeslice.o
+ $TOOLKIT_DIR$\lib\shb_l.a
$PROJ_DIR$\Debug\Obj\los_sem.o
- $PROJ_DIR$\..\..\..\kernel\src\los_swtmr.c
- $PROJ_DIR$\..\..\..\kernel\src\los_task.c
- $TOOLKIT_DIR$\CMSIS\Core\Include\cmsis_iccarm.h
$TOOLKIT_DIR$\CMSIS\Core\Include\core_cm4.h
$TOOLKIT_DIR$\CMSIS\Core\Include\mpu_armv7.h
- $TOOLKIT_DIR$\CMSIS\Core\Include\cmsis_compiler.h
- $TOOLKIT_DIR$\CMSIS\Core\Include\cmsis_version.h
+ $PROJ_DIR$\Debug\Obj\los_priqueue.__cstat.et
+ $PROJ_DIR$\Debug\Obj\los_init.o
+ $PROJ_DIR$\Debug\Obj\system_stm32f4xx.o
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_context.h
+ $TOOLKIT_DIR$\CMSIS\Core\Include\cmsis_iccarm.h
+ $PROJ_DIR$\Debug\Obj\los_init.pbi
- [ROOT_NODE]
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_tick.c
- ILINK
- 47 132
+ BICOMP
+ 76
-
-
-
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_exc.S
-
- AARM
- 99
+ ICCARM
+ 57
+
+
+ __cstat
+ 219
+
+
+ BICOMP
+ 225 46 185 92 96 13 99 139 161 42 241 191 78 55 156 72 235 236 136 84 157 135 97 206 152 70 91 32 89 45 129 87 230 228 56 100 149 81 160 88 74 147 75 77 18 142 159 145 155 153
+
+
+ ICCARM
+ 153 156 32 99 42 46 89 45 91 72 129 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155
+
+
$PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_interrupt.c
- ICCARM
- 101
+ BICOMP
+ 35
- BICOMP
- 106
+ ICCARM
+ 34
-
- ICCARM
- 43 33 231 94 24 60 62 19 44 92 16 171 72 13 128 41 124 142 26 144 155 31 32 114 154 160 25 12 35 170 149 36 37 17 18 151 173 96 53 146 161 166 40 152 27 158 39 42 163 153 234 156 164
-
BICOMP
- 171 155 33 60 35 152 92 94 44 239 240 154 37 146 39 24 19 124 26 32 25 149 18 96 166 158 72 110 42 231 62 41 242 241 238 142 144 31 114 160 12 170 36 17 151 173 53 161 40 27 234 43 163 156 153 164
+ 225 149 72 42 74 145 13 32 45 235 236 160 75 142 83 99 89 185 100 81 88 147 77 18 159 155 56 181 90 129 46 87 230 228 241 136 139 84 191 157 96 135 78 97 161 206 55 152 92 70 240 91 153 134 156 154
-
-
-
- $PROJ_DIR$\..\..\..\components\cpup\los_cpup.c
-
ICCARM
- 148
-
-
- BICOMP
- 80
-
-
- __cstat
- 100
-
-
-
-
- ICCARM
- 49 43 33 231 94 24 60 62 19 44 92 16 171 72 13 128 41 124 142 26 144 155 31 32 114 154 160 25 12 35 170 149 36 37 17 18 151 173 96 53 146 161 166 40 152 27 158 42 163 153 234 156 164 39
-
-
- BICOMP
- 241 37 62 154 146 92 60 72 155 35 152 42 94 231 41 242 26 32 25 149 18 96 166 158 39 43 33 24 19 44 239 171 124 240 238 142 144 31 114 160 12 170 36 17 151 173 53 161 40 27 234 49 163 156 153 164
-
-
-
-
- $PROJ_DIR$\..\..\..\kernel\src\los_err.c
-
-
- ICCARM
- 185
-
-
- BICOMP
- 195
-
-
- __cstat
- 71
-
-
-
-
- ICCARM
- 153 94 24 60 62 19 44
+ 91 72 129 32 99 42 46 89 45 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 83 90 153 156 240 134 154
@@ -344,170 +303,130 @@
$PROJ_DIR$\..\..\..\components\cppsupport\los_cppsupport.c
- ICCARM
- 28
+ BICOMP
+ 82
- BICOMP
- 38
+ ICCARM
+ 71
__cstat
- 55
+ 50
-
- ICCARM
- 84 94 24 60 62 19 44
-
BICOMP
- 44 60 94 24 62 19 84
+ 45 42 32 99 46 89 31
-
-
-
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_dispatch.S
-
-
- AARM
- 78
-
-
-
-
- $PROJ_DIR$\..\..\..\kernel\src\los_event.c
-
ICCARM
- 187
-
-
- BICOMP
- 194
-
-
- __cstat
- 30
-
-
-
-
- ICCARM
- 42 163 153 94 24 60 62 19 44 234 156 164 43 33 231 92 16 171 72 13 128 41 124 142 26 144 155 31 32 114 154 160 25 12 35 170 149 36 37 17 18 151 173 96 53 146 161 166 40 152 27 158
-
-
- BICOMP
- 149 94 158 92 231 242 32 96 153 41 26 25 18 166 234 60 62 241 72 155 154 35 37 146 152 43 163 156 24 19 44 164 33 239 171 124 240 238 142 144 31 114 160 12 170 36 17 151 173 53 161 40 27 42
+ 31 32 99 42 46 89 45
$PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw.c
+
+ BICOMP
+ 54
+
ICCARM
+ 51
+
+
+ __cstat
68
-
- BICOMP
- 58
-
-
- __cstat
- 52
-
- ICCARM
- 42 163 153 94 24 60 62 19 44 234 156 164 159 119 50 72 73 157 115 168 174 165 167
+ BICOMP
+ 99 240 32 65 42 46 89 56 150 153 134 156 45 154 192 90 181 163 48 162 132 158 189 212
- BICOMP
- 24 234 94 73 60 62 19 72 159 163 156 153 44 164 119 42 110 167 50 157 168 165 115 174
+ ICCARM
+ 90 153 156 32 99 42 46 89 45 240 134 154 150 192 48 56 65 162 189 132 212 158 163
- $PROJ_DIR$\..\..\..\kernel\src\mm\los_membox.c
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_exc.S
- ICCARM
- 179
-
-
- BICOMP
- 77
-
-
- __cstat
- 14
+ AARM
+ 20
-
-
- ICCARM
- 159 119 50 72 60 62 19 44 73 157 115 168 174 165 167 43 33 231 94 24 92 16 171 13 128 41 124 142 26 144 155 31 32 114 154 160 25 12 35 170 149 36 37 17 18 151 173 96 53 146 161 166 40 152 27 158 147 169 164 39
-
-
- BICOMP
- 72 37 169 60 174 154 146 39 115 73 94 231 171 124 155 35 152 92 33 147 110 167 239 240 26 32 25 149 18 96 166 158 43 119 50 157 168 165 62 19 44 24 41 242 241 238 142 144 31 114 160 12 170 36 17 151 173 53 161 40 27 159 164
-
-
- $PROJ_DIR$\..\..\..\kernel\src\los_init.c
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_dispatch.S
- ICCARM
- 212
+ AARM
+ 28
+
+
+
+ [ROOT_NODE]
+
+
+ ILINK
+ 67 193
+
+
+
+
+ $PROJ_DIR$\..\..\..\kernel\src\los_sys.c
+
BICOMP
+ 177
+
+
+ ICCARM
211
__cstat
- 46
+ 171
- ICCARM
- 33 231 94 24 60 62 19 44 92 16 171 72 13 128 41 124 142 26 144 155 31 32 114 154 160 25 12 35 170 149 36 37 17 18 151 173 96 53 146 161 166 40 152 27 158 162 164 169 117 42 163 153 234 156 43 39
+ BICOMP
+ 142 99 129 160 13 32 75 87 149 74 145 42 46 186 100 81 88 147 77 18 159 155 72 156 89 45 93 225 185 94 56 136 139 84 191 157 96 135 78 97 161 206 55 152 92 70 153
- BICOMP
- 62 154 92 146 241 37 60 72 155 35 152 164 156 169 43 39 231 94 41 242 26 32 25 149 18 96 166 158 153 33 162 117 24 19 44 239 171 124 240 238 142 144 31 114 160 12 170 36 17 151 173 53 161 40 27 42 163 234
+ ICCARM
+ 153 156 32 99 42 46 89 45 72 129 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_tick.c
+ $PROJ_DIR$\..\..\..\kernel\src\los_priqueue.c
- ICCARM
- 65
+ BICOMP
+ 220
- BICOMP
- 29
+ ICCARM
+ 21
__cstat
- 201
+ 237
ICCARM
- 163 153 94 24 60 62 19 44 43 33 231 92 16 171 72 13 128 41 124 142 26 144 155 31 32 114 154 160 25 12 35 170 149 36 37 17 18 151 173 96 53 146 161 166 40 152 27 158
-
-
- BICOMP
- 171 62 124 40 12 92 24 144 151 60 238 114 36 53 153 33 239 240 142 31 160 170 17 173 161 27 43 94 19 44 231 41 242 241 72 26 155 32 154 25 35 149 37 18 96 146 166 152 158 163
+ 151 154 32 99 42 46 89 45 90 153 156 240 134 72 129 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155
@@ -516,63 +435,148 @@
ILINK
- 132
+ 193
ILINK
- 61 34 140 28 148 78 185 187 68 99 65 212 101 179 186 88 182 184 82 109 235 181 193 183 11 45 112 202 69 104 189 90 98 97 87 225 203 177 116 63
+ 60 73 138 71 144 28 205 204 51 20 57 238 34 208 224 16 214 216 29 168 234 222 217 215 104 43 183 201 39 24 209 11 36 8 15 239 233 213 173 38
- $PROJ_DIR$\..\..\..\kernel\src\los_sys.c
+ $PROJ_DIR$\..\..\..\kernel\src\mm\los_membox.c
- ICCARM
- 200
+ BICOMP
+ 6
- BICOMP
- 118
+ ICCARM
+ 208
__cstat
- 136
+ 79
- ICCARM
- 163 153 94 24 60 62 19 44 33 231 92 16 171 72 13 128 41 124 142 26 144 155 31 32 114 154 160 25 12 35 170 149 36 37 17 18 151 173 96 53 146 161 166 40 152 27 158
+ BICOMP
+ 56 75 133 42 212 160 142 83 189 65 32 129 225 185 149 74 145 13 72 143 181 163 235 236 100 81 88 147 77 18 159 155 91 192 48 162 132 158 46 89 45 99 87 230 228 241 136 139 84 191 157 96 135 78 97 161 206 55 152 92 70 150 154
- BICOMP
- 146 24 231 154 92 94 37 41 155 35 152 60 62 128 26 32 25 149 18 96 166 158 33 153 19 44 16 171 124 13 72 142 144 31 114 160 12 170 36 17 151 173 53 161 40 27 163
+ ICCARM
+ 150 192 48 56 42 46 89 45 65 162 189 132 212 158 163 91 72 129 32 99 13 93 225 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 143 133 154 83
- $PROJ_DIR$\..\..\..\kernel\src\los_priqueue.c
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_usart.c
- ICCARM
- 102
+ BICOMP
+ 26
- BICOMP
- 199
+ ICCARM
+ 8
__cstat
- 206
+ 169
+
+ BICOMP
+ 160 13 142 75 225 185 46 89 149 74 145 235 236 42 45 241 99 100 81 88 147 77 18 159 155 96 87 230 228 56 136 139 84 191 157 135 78 97 161 206 55 152 92 70
+
ICCARM
- 162 164 94 24 60 62 19 44 42 163 153 234 156 33 231 92 16 171 72 13 128 41 124 142 26 144 155 31 32 114 154 160 25 12 35 170 149 36 37 17 18 151 173 96 53 146 161 166 40 152 27 158
+ 97 13 93 225 56 42 46 89 45 94 186 99 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 77 161 206 18 55 142 152 159 92 145 70 155
+
+
+
+
+ $PROJ_DIR$\..\..\..\kernel\src\los_mux.c
+
+
+ BICOMP
+ 170
+
+
+ ICCARM
+ 29
+
+
+ __cstat
+ 190
+
+
+
+
+ BICOMP
+ 32 228 75 42 160 142 13 240 46 56 149 74 145 133 156 129 87 230 100 81 88 147 77 18 159 155 91 83 90 153 134 99 89 45 154 72 235 225 185 236 241 136 139 84 191 157 96 135 78 97 161 206 55 152 92 70 174
+
+
+ ICCARM
+ 174 90 153 156 32 99 42 46 89 45 240 134 154 91 72 129 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 133 83
+
+
+
+
+ $PROJ_DIR$\..\..\..\components\cpup\los_cpup.c
+
+
+ BICOMP
+ 30
+
+
+ ICCARM
+ 144
+
+
+ __cstat
+ 25
+
+
+
+
+ BICOMP
+ 228 75 46 160 142 13 42 56 149 74 145 90 32 129 87 230 100 81 88 147 77 18 159 155 83 91 72 99 89 45 235 225 185 236 241 136 139 84 191 157 96 135 78 97 161 206 55 152 92 70 240 47 153 134 156 154
+
+
+ ICCARM
+ 47 91 72 129 32 99 42 46 89 45 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 90 153 156 240 134 154 83
+
+
+
+
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_wwdg.c
+
+
+ BICOMP
+ 23
+
+
+ ICCARM
+ 15
+
+
+ __cstat
+ 226
+
+
+
+
+ BICOMP
+ 136 13 97 228 42 157 152 56 84 135 206 70 87 230 139 191 96 78 161 55 92 235 225 185 236 46 89 45 241 99 100 149 81 160 88 74 147 75 77 18 142 159 145 155
+
+
+ ICCARM
+ 77 13 93 225 56 42 46 89 45 94 186 99 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 161 206 18 55 142 152 159 92 145 70 155
@@ -580,197 +584,31 @@
$PROJ_DIR$\..\..\..\utils\los_error.c
- ICCARM
- 108
+ BICOMP
+ 172
- BICOMP
- 107
+ ICCARM
+ 182
BICOMP
- 60 44 94 24 19 153 62
+ 42 45 32 99 89 156 46
-
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_dispatch_iar.S
-
-
- AARM
- 59
-
-
-
-
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_exc.c
-
-
- BICOMP
- 23
-
-
- __cstat
- 48
-
-
-
-
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_exc_iar.S
-
-
- AARM
- 57
-
-
-
$PROJ_DIR$\..\..\..\kernel\src\los_tick.c
-
- ICCARM
- 183
-
BICOMP
- 197
+ 200
-
- __cstat
- 139
-
-
-
ICCARM
- 163 153 94 24 60 62 19 44 33 231 92 16 171 72 13 128 41 124 142 26 144 155 31 32 114 154 160 25 12 35 170 149 36 37 17 18 151 173 96 53 146 161 166 40 152 27 158 42 234 156 164 64
-
-
- BICOMP
- 238 114 92 53 24 36 19 171 124 144 12 151 40 42 94 44 239 240 60 142 31 160 170 17 173 161 27 163 33 64 153 62 231 41 242 241 72 26 155 32 154 25 35 149 37 18 96 146 166 152 158 156 234 164
-
-
-
-
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_tim.c
-
-
- ICCARM
- 98
-
-
- BICOMP
- 95
-
-
- __cstat
- 127
-
-
-
-
- ICCARM
- 37 92 16 171 72 60 62 19 44 13 128 24 41 124 142 26 144 155 31 32 114 154 160 25 12 35 170 149 36 17 18 151 173 96 53 146 161 166 40 152 27 158
-
-
- BICOMP
- 92 142 17 241 60 160 161 72 31 170 173 27 41 242 144 114 12 36 151 53 40 239 171 124 240 62 19 44 238 24 26 155 32 154 25 35 149 37 18 96 146 166 152 158
-
-
-
-
- $PROJ_DIR$\..\dprintf.c
-
-
- ICCARM
- 34
-
-
- BICOMP
- 51
-
-
- __cstat
- 22
-
-
-
-
- ICCARM
- 50 72 60 62 19 44 73 39 94 24 17 92 16 171 13 128 41 124 142 26 144 155 31 32 114 154 160 25 12 35 170 149 36 37 18 151 173 96 53 146 161 166 40 152 27 158 192 70
-
-
- BICOMP
- 24 155 60 171 124 35 152 92 192 73 154 37 146 39 72 239 240 26 32 25 149 18 96 166 158 50 17 62 19 44 94 41 242 241 238 142 144 31 114 160 12 170 36 151 173 53 161 40 27 110 70
-
-
-
-
- $PROJ_DIR$\..\main.c
-
-
- ICCARM
- 11
-
-
- BICOMP
- 66
-
-
- __cstat
- 150
-
-
-
-
- ICCARM
- 163 153 94 24 60 62 19 44 42 234 156 164 33 231 92 16 171 72 13 128 41 124 142 26 144 155 31 32 114 154 160 25 12 35 170 149 36 37 17 18 151 173 96 53 146 161 166 40 152 27 158 43 39 54
-
-
- BICOMP
- 92 144 94 24 151 171 124 12 40 39 44 238 114 36 53 33 54 19 234 239 240 60 142 31 160 170 17 173 161 27 42 43 153 62 163 156 164 231 41 242 241 72 26 155 32 154 25 35 149 37 18 96 146 166 152 158
-
-
-
-
- $PROJ_DIR$\..\..\..\kernel\src\los_sem.c
-
-
- ICCARM
- 235
-
-
- BICOMP
- 180
-
-
- __cstat
- 178
-
-
-
-
- ICCARM
- 56 42 163 153 94 24 60 62 19 44 234 156 164 169 33 231 92 16 171 72 13 128 41 124 142 26 144 155 31 32 114 154 160 25 12 35 170 149 36 37 17 18 151 173 96 53 146 161 166 40 152 27 158 43 39
-
-
- BICOMP
- 60 170 19 27 163 171 31 173 92 43 24 239 240 142 160 17 161 156 94 44 164 33 124 238 144 114 12 36 151 53 40 169 39 42 234 153 62 231 41 242 241 72 26 155 32 154 25 35 149 37 18 96 146 166 152 158 56
-
-
-
-
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\misc.c
-
-
- ICCARM
- 45
-
-
- BICOMP
- 74
+ 215
__cstat
@@ -780,132 +618,120 @@
ICCARM
- 151 92 16 171 72 60 62 19 44 13 128 24 41 124 142 26 144 155 31 32 114 154 160 25 12 35 170 149 36 37 17 18 173 96 53 146 161 166 40 152 27 158
-
-
- BICOMP
- 40 12 92 41 144 151 242 114 36 53 241 72 60 142 31 160 170 17 173 161 27 239 171 124 240 62 19 44 238 24 26 155 32 154 25 35 149 37 18 96 146 166 152 158
+ 153 156 32 99 42 46 89 45 72 129 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 90 240 134 154 49
- $PROJ_DIR$\..\..\..\kernel\src\mm\los_memcheck.c
+ $PROJ_DIR$\..\..\..\kernel\src\los_swtmr.c
- ICCARM
- 186
+ BICOMP
+ 199
- BICOMP
- 83
+ ICCARM
+ 222
__cstat
- 89
+ 194
ICCARM
- 147 169 33 231 94 24 60 62 19 44 92 16 171 72 13 128 41 124 142 26 144 155 31 32 114 154 160 25 12 35 170 149 36 37 17 18 151 173 96 53 146 161 166 40 152 27 158 164
+ 150 192 48 56 42 46 89 45 65 162 189 132 212 158 163 91 72 129 32 99 13 93 225 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 49 90 153 156 240 134 154 133 151 83
+
+
+
+ $PROJ_DIR$\..\..\..\kernel\src\los_task.c
+
BICOMP
- 240 17 44 142 92 239 160 161 171 60 31 170 173 27 169 33 24 19 124 238 144 114 12 36 151 53 40 164 231 94 62 41 242 241 72 26 155 32 154 25 35 149 37 18 96 146 166 152 158 147
+ 218
+
+
+ ICCARM
+ 217
+
+
+ __cstat
+ 176
+
+
+
+
+ ICCARM
+ 72 129 32 99 42 46 89 45 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 150 192 48 65 162 189 132 212 158 163 63 90 153 156 240 134 154 174 133 91 47 83
+
+
+
+
+ $PROJ_DIR$\..\board\iar_stm32f429ig_fire-challenger.c
+
+
+ BICOMP
+ 167
+
+
+ ICCARM
+ 138
+
+
+ __cstat
+ 202
+
+
+
+
+ BICOMP
+ 70 135 13 56 84 206 228 42 136 157 97 152 87 230 139 191 96 78 161 55 92 52 235 225 185 236 46 89 45 241 99 100 149 81 160 88 74 147 75 77 18 142 159 145 155 221
+
+
+ ICCARM
+ 221 13 93 225 56 42 46 89 45 94 186 99 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 52
+
+
+
+
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_exti.c
+
+
+ BICOMP
+ 37
+
+
+ ICCARM
+ 39
+
+
+ __cstat
+ 141
+
+
+
+
+ BICOMP
+ 88 236 159 13 235 99 100 77 225 42 45 241 81 147 18 155 185 46 89 149 160 74 75 142 145 87 230 228 56 136 139 84 191 157 96 135 78 97 161 206 55 152 92 70
+
+
+ ICCARM
+ 84 13 93 225 56 42 46 89 45 94 186 99 87 185 136 100 139 149 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155
$PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_gpio.c
-
- ICCARM
- 104
-
BICOMP
- 190
+ 223
-
- __cstat
- 131
-
-
-
ICCARM
- 114 92 16 171 72 60 62 19 44 13 128 24 41 124 142 26 144 155 31 32 154 160 25 12 35 170 149 36 37 17 18 151 173 96 53 146 161 166 40 152 27 158
-
-
- BICOMP
- 25 240 166 92 239 24 26 18 171 60 44 238 32 149 96 158 124 62 19 155 154 35 37 146 152 12 41 242 241 72 142 144 31 114 160 170 36 17 151 173 53 161 40 27
-
-
-
-
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_usart.c
-
-
- ICCARM
- 97
-
-
- BICOMP
- 93
-
-
- __cstat
- 135
-
-
-
-
- ICCARM
- 17 92 16 171 72 60 62 19 44 13 128 24 41 124 142 26 144 155 31 32 114 154 160 25 12 35 170 149 36 37 18 151 173 96 53 146 161 166 40 152 27 158
-
-
- BICOMP
- 154 92 146 37 171 124 62 19 155 35 152 239 240 60 44 238 24 26 32 25 149 18 96 166 158 12 41 242 241 72 142 144 31 114 160 170 36 17 151 173 53 161 40 27
-
-
-
-
- $PROJ_DIR$\..\..\..\kernel\src\los_mux.c
-
-
- ICCARM
- 82
-
-
- BICOMP
- 122
-
-
- __cstat
- 130
-
-
-
-
- ICCARM
- 117 42 163 153 94 24 60 62 19 44 234 156 164 43 33 231 92 16 171 72 13 128 41 124 142 26 144 155 31 32 114 154 160 25 12 35 170 149 36 37 17 18 151 173 96 53 146 161 166 40 152 27 158 169 39
-
-
- BICOMP
- 94 241 37 60 154 146 92 234 62 72 155 35 152 169 153 231 41 242 26 32 25 149 18 96 166 158 43 39 42 163 156 24 19 44 164 33 239 171 124 240 238 142 144 31 114 160 12 170 36 17 151 173 53 161 40 27 117
-
-
-
-
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_wwdg.c
-
-
- ICCARM
- 87
-
-
- BICOMP
- 85
+ 24
__cstat
@@ -914,93 +740,247 @@
- ICCARM
- 18 92 16 171 72 60 62 19 44 13 128 24 41 124 142 26 144 155 31 32 114 154 160 25 12 35 170 149 36 37 17 151 173 96 53 146 161 166 40 152 27 158
+ BICOMP
+ 88 236 159 13 235 99 100 77 225 42 45 241 81 147 18 155 185 46 89 149 160 74 75 142 145 96 87 230 228 56 136 139 84 191 157 135 78 97 161 206 55 152 92 70
- BICOMP
- 142 92 17 241 60 160 161 72 31 170 173 27 41 242 144 114 12 36 151 53 40 239 171 124 240 62 19 44 238 24 26 155 32 154 25 35 149 37 18 96 146 166 152 158
+ ICCARM
+ 191 13 93 225 56 42 46 89 45 94 186 99 87 185 136 100 139 149 84 81 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155
- $PROJ_DIR$\..\Libraries\CMSIS\Device\ST\STM32F4xx\Source\Templates\system_stm32f4xx.c
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_rcc.c
- ICCARM
- 225
+ BICOMP
+ 19
- BICOMP
- 134
+ ICCARM
+ 209
__cstat
- 126
+ 231
+
+
+
+
+ BICOMP
+ 157 228 42 152 136 97 13 56 84 135 206 70 87 230 139 191 96 78 161 55 92 235 225 185 236 46 89 45 241 99 100 149 81 160 88 74 147 75 77 18 142 159 145 155
+
+
+ ICCARM
+ 96 13 93 225 56 42 46 89 45 94 186 99 87 185 136 100 139 149 84 81 191 160 157 88 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155
+
+
+
+
+ $PROJ_DIR$\..\..\..\kernel\src\mm\los_memcheck.c
+
+
+ BICOMP
+ 33
+
+
+ ICCARM
+ 224
+
+
+ __cstat
+ 10
ICCARM
- 92 16 171 72 60 62 19 44 13 128 24 41 124 142 26 144 155 31 32 114 154 160 25 12 35 170 149 36 37 17 18 151 173 96 53 146 161 166 40 152 27 158
-
-
- BICOMP
- 25 92 240 166 239 24 26 18 171 60 44 238 32 149 96 158 124 62 19 155 154 35 37 146 152 41 242 241 72 142 144 31 114 160 12 170 36 17 151 173 53 161 40 27
+ 143 133 72 129 32 99 42 46 89 45 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 154
- $PROJ_DIR$\..\..\..\kernel\src\los_timeslice.c
+ $PROJ_DIR$\..\..\..\kernel\src\los_init.c
- ICCARM
- 204
+ BICOMP
+ 242
- BICOMP
- 21
+ ICCARM
+ 238
__cstat
- 123
+ 44
+
+
+
+
+ BICOMP
+ 46 160 13 142 228 75 42 56 149 74 145 154 134 133 91 83 129 32 87 230 100 81 88 147 77 18 159 155 156 72 151 174 99 89 45 235 225 185 236 241 136 139 84 191 157 96 135 78 97 161 206 55 152 92 70 90 153 240
+
+
+ ICCARM
+ 72 129 32 99 42 46 89 45 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 151 154 133 174 90 153 156 240 134 91 83
+
+
+
+
+ $PROJ_DIR$\..\..\..\kernel\src\mm\los_memstat.c
+
+
+ BICOMP
+ 7
+
+
+ ICCARM
+ 214
+
+
+ __cstat
+ 80
ICCARM
- 43 33 231 94 24 60 62 19 44 92 16 171 72 13 128 41 124 142 26 144 155 31 32 114 154 160 25 12 35 170 149 36 37 17 18 151 173 96 53 146 161 166 40 152 27 158 42 163 153 234 156 164
-
-
- BICOMP
- 24 155 41 35 152 92 94 154 37 146 60 62 128 26 32 25 149 18 96 166 158 42 33 231 19 44 16 171 124 13 72 142 144 31 114 160 12 170 36 17 151 173 53 161 40 27 234 43 163 156 153 164
+ 83 32 99 42 46 89 45 91 72 129 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155
- $PROJ_DIR$\..\..\..\kernel\src\mm\los_memory.c
+ $PROJ_DIR$\..\..\..\kernel\src\los_queue.c
- ICCARM
- 88
+ BICOMP
+ 27
- BICOMP
- 67
+ ICCARM
+ 168
__cstat
- 103
+ 179
- ICCARM
- 159 119 50 72 60 62 19 44 73 157 115 168 174 165 167 169 33 231 94 24 92 16 171 13 128 41 124 142 26 144 155 31 32 114 154 160 25 12 35 170 149 36 37 17 18 151 173 96 53 146 161 166 40 152 27 158 164 42 163 153 234 156 43 39 147
+ BICOMP
+ 13 81 32 18 133 83 89 147 155 42 90 99 225 185 100 88 77 159 56 72 240 151 45 235 236 149 160 74 75 142 145 150 143 91 129 46 87 230 228 241 136 139 84 191 157 96 135 78 97 161 206 55 152 92 70 192 65 181 163 48 162 132 158 189 212 154 153 134 156
+
+ ICCARM
+ 91 72 129 32 99 42 46 89 45 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 150 192 48 65 162 189 132 212 158 163 151 154 143 133 90 153 156 240 134 83
+
+
+
+
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_syscfg.c
+
BICOMP
- 73 41 92 142 60 72 17 39 157 44 242 160 161 42 119 50 168 165 62 19 33 24 241 171 31 170 173 27 163 164 169 43 147 110 167 115 174 231 94 239 124 238 144 114 12 36 151 53 40 156 153 159 240 26 155 32 154 25 35 149 37 18 96 146 166 152 158 234
+ 14
+
+
+ ICCARM
+ 11
+
+
+ __cstat
+ 164
+
+
+
+
+ BICOMP
+ 70 135 13 56 84 206 228 42 136 157 97 152 87 230 139 191 96 78 161 55 92 235 225 185 236 46 89 45 241 99 100 149 81 160 88 74 147 75 77 18 142 159 145 155
+
+
+ ICCARM
+ 78 13 93 225 56 42 46 89 45 94 186 99 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 75 97 77 161 206 18 55 142 152 159 92 145 70 155
+
+
+
+
+ $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval.c
+
+
+ BICOMP
+ 198
+
+
+ ICCARM
+ 201
+
+
+ __cstat
+ 187
+
+
+
+
+ BICOMP
+ 96 92 87 139 161 13 230 191 78 55 149 52 228 56 42 136 84 157 135 97 206 152 70 160 235 225 185 236 46 89 45 241 99 100 81 88 74 147 75 77 18 142 159 145 155 221
+
+
+ ICCARM
+ 221 13 93 225 56 42 46 89 45 94 186 99 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 52
+
+
+
+
+ $PROJ_DIR$\..\..\..\kernel\src\los_sem.c
+
+
+ BICOMP
+ 196
+
+
+ ICCARM
+ 234
+
+
+ __cstat
+ 203
+
+
+
+
+ BICOMP
+ 42 135 89 70 153 225 84 206 13 91 99 235 236 136 157 97 152 134 32 45 154 72 185 241 139 191 96 78 161 55 92 133 83 90 240 156 46 129 87 230 228 56 100 149 81 160 88 74 147 75 77 18 142 159 145 155 63
+
+
+ ICCARM
+ 63 90 153 156 32 99 42 46 89 45 240 134 154 133 72 129 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 91 83
+
+
+
+
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\misc.c
+
+
+ BICOMP
+ 53
+
+
+ ICCARM
+ 43
+
+
+ __cstat
+ 166
+
+
+
+
+ BICOMP
+ 92 96 13 87 139 161 230 191 78 55 228 56 42 136 84 157 135 97 206 152 70 235 225 185 236 46 89 45 241 99 100 149 81 160 88 74 147 75 77 18 142 159 145 155
+
+
+ ICCARM
+ 161 13 93 225 56 42 46 89 45 94 186 99 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 206 18 55 142 152 159 92 145 70 155
@@ -1009,273 +989,273 @@
AARM
- 112
+ 183
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_exti.c
+ $PROJ_DIR$\..\Libraries\CMSIS\Device\ST\STM32F4xx\Source\Templates\system_stm32f4xx.c
- ICCARM
- 69
+ BICOMP
+ 165
- BICOMP
- 81
+ ICCARM
+ 239
__cstat
- 143
+ 178
+
+
+
+
+ BICOMP
+ 88 13 236 159 235 99 100 77 225 42 45 241 81 147 18 155 185 46 89 149 160 74 75 142 145 87 230 228 56 136 139 84 191 157 96 135 78 97 161 206 55 152 92 70
+
+
+ ICCARM
+ 13 93 225 56 42 46 89 45 94 186 99 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155
+
+
+
+
+ $PROJ_DIR$\..\dprintf.c
+
+
+ BICOMP
+ 40
+
+
+ ICCARM
+ 73
+
+
+ __cstat
+ 85
+
+
+
+
+ BICOMP
+ 99 149 42 225 185 74 145 13 221 65 160 75 142 83 56 235 236 100 81 88 147 77 18 159 155 48 97 46 89 45 32 87 230 228 241 136 139 84 191 157 96 135 78 161 206 55 152 92 70 181 52
+
+
+ ICCARM
+ 48 56 42 46 89 45 65 83 32 99 97 13 93 225 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 77 161 206 18 55 142 152 159 92 145 70 155 221 52
+
+
+
+
+ $PROJ_DIR$\..\..\..\kernel\src\los_event.c
+
+
+ BICOMP
+ 195
+
+
+ ICCARM
+ 204
+
+
+ __cstat
+ 86
+
+
+
+
+ BICOMP
+ 147 32 155 13 129 230 81 18 156 87 100 88 77 159 240 42 46 228 56 149 160 74 75 142 145 91 153 134 99 89 45 154 72 235 225 185 236 241 136 139 84 191 157 96 135 78 97 161 206 55 152 92 70 90
+
+
+ ICCARM
+ 90 153 156 32 99 42 46 89 45 240 134 154 91 72 129 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155
+
+
+
+
+ $PROJ_DIR$\..\..\..\kernel\src\mm\los_memory.c
+
+
+ BICOMP
+ 62
+
+
+ ICCARM
+ 16
+
+
+ __cstat
+ 22
+
+
+
+
+ BICOMP
+ 65 87 13 136 42 56 97 83 162 45 230 157 152 90 192 48 132 158 46 89 72 99 228 225 84 135 206 70 153 154 133 91 143 181 163 189 212 129 32 235 185 241 139 191 96 78 161 55 92 134 156 150 236 100 149 81 160 88 74 147 75 77 18 142 159 145 155 240
+
+
+ ICCARM
+ 150 192 48 56 42 46 89 45 65 162 189 132 212 158 163 133 72 129 32 99 13 93 225 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 154 90 153 156 240 134 91 83 143
+
+
+
+
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_tim.c
+
+
+ BICOMP
+ 17
+
+
+ ICCARM
+ 36
+
+
+ __cstat
+ 180
+
+
+
+
+ BICOMP
+ 13 136 97 228 42 157 152 56 84 135 206 70 87 230 139 191 96 78 161 55 92 235 225 185 236 46 89 45 241 99 100 149 81 160 88 74 147 75 77 18 142 159 145 155
+
+
+ ICCARM
+ 75 13 93 225 56 42 46 89 45 94 186 99 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 97 77 161 206 18 55 142 152 159 92 145 70 155
+
+
+
+
+ $PROJ_DIR$\..\..\..\kernel\src\los_err.c
+
+
+ BICOMP
+ 197
+
+
+ ICCARM
+ 205
+
+
+ __cstat
+ 64
ICCARM
- 31 92 16 171 72 60 62 19 44 13 128 24 41 124 142 26 144 155 32 114 154 160 25 12 35 170 149 36 37 17 18 151 173 96 53 146 161 166 40 152 27 158
-
-
- BICOMP
- 25 240 166 92 239 24 26 18 171 60 44 238 32 149 96 158 124 62 19 155 154 35 37 146 152 41 242 241 72 142 144 31 114 160 12 170 36 17 151 173 53 161 40 27
+ 156 32 99 42 46 89 45
+
+ $PROJ_DIR$\..\main.c
+
+
+ BICOMP
+ 59
+
+
+ ICCARM
+ 104
+
+
+ __cstat
+ 148
+
+
+
+
+ BICOMP
+ 13 139 32 99 161 225 185 96 92 83 45 241 191 78 55 72 41 89 240 235 236 42 136 84 157 135 97 206 152 70 90 91 156 46 153 134 154 129 87 230 228 56 100 149 81 160 88 74 147 75 77 18 142 159 145 155
+
+
+ ICCARM
+ 153 156 32 99 42 46 89 45 90 240 134 154 72 129 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 91 83 41
+
+
+
+
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_exc.c
+
+
+ BICOMP
+ 69
+
+
+ __cstat
+ 66
+
+
+
+
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_dispatch_iar.S
+
+
+ AARM
+ 61
+
+
+
+
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_exc_iar.S
+
+
+ AARM
+ 58
+
+
+
$PROJ_DIR$\..\..\..\kernel\src\los_misc.c
+
+ BICOMP
+ 207
+
ICCARM
+ 216
+
+
+ __cstat
+ 98
+
+
+
+
+ ICCARM
+ 91 72 129 32 99 42 46 89 45 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 90 153 156 240 134 154
+
+
+
+
+ $PROJ_DIR$\..\..\..\kernel\src\los_timeslice.c
+
+
+ BICOMP
+ 95
+
+
+ ICCARM
+ 232
+
+
+ __cstat
184
-
- BICOMP
- 176
-
-
- __cstat
- 20
-
-
- ICCARM
- 43 33 231 94 24 60 62 19 44 92 16 171 72 13 128 41 124 142 26 144 155 31 32 114 154 160 25 12 35 170 149 36 37 17 18 151 173 96 53 146 161 166 40 152 27 158 42 163 153 234 156 164
-
-
-
-
- $PROJ_DIR$\..\..\..\kernel\src\los_queue.c
-
-
- ICCARM
- 109
-
BICOMP
- 105
+ 99 149 87 74 145 13 32 160 75 142 42 46 186 100 81 88 147 77 18 159 155 90 72 129 89 45 93 225 185 94 56 136 139 84 191 157 96 135 78 97 161 206 55 152 92 70 240 91 153 134 156 154
-
- __cstat
- 125
-
-
-
ICCARM
- 43 33 231 94 24 60 62 19 44 92 16 171 72 13 128 41 124 142 26 144 155 31 32 114 154 160 25 12 35 170 149 36 37 17 18 151 173 96 53 146 161 166 40 152 27 158 159 119 50 73 157 115 168 174 165 167 162 164 147 169 42 163 153 234 156 39
-
-
- BICOMP
- 92 32 94 96 169 39 19 149 158 60 42 24 171 124 26 25 18 166 72 33 234 162 44 239 240 155 154 35 37 146 152 159 147 43 231 62 41 242 241 238 142 144 31 114 160 12 170 36 17 151 173 53 161 40 27 119 73 110 167 50 157 168 165 115 174 164 163 156 153
-
-
-
-
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_rcc.c
-
-
- ICCARM
- 189
-
-
- BICOMP
- 76
-
-
- __cstat
- 205
-
-
-
-
- ICCARM
- 12 92 16 171 72 60 62 19 44 13 128 24 41 124 142 26 144 155 31 32 114 154 160 25 35 170 149 36 37 17 18 151 173 96 53 146 161 166 40 152 27 158
-
-
- BICOMP
- 160 241 60 161 142 17 92 72 31 170 173 27 41 242 144 114 12 36 151 53 40 239 171 124 240 62 19 44 238 24 26 155 32 154 25 35 149 37 18 96 146 166 152 158
-
-
-
-
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_syscfg.c
-
-
- ICCARM
- 90
-
-
- BICOMP
- 86
-
-
- __cstat
- 133
-
-
-
-
- ICCARM
- 36 92 16 171 72 60 62 19 44 13 128 24 41 124 142 26 144 155 31 32 114 154 160 25 12 35 170 149 37 17 18 151 173 96 53 146 161 166 40 152 27 158
-
-
- BICOMP
- 27 170 92 72 31 173 241 60 142 160 17 161 41 242 144 114 12 36 151 53 40 239 171 124 240 62 19 44 238 24 26 155 32 154 25 35 149 37 18 96 146 166 152 158
-
-
-
-
- $PROJ_DIR$\..\board\iar_stm32f429ig_fire-challenger.c
-
-
- ICCARM
- 140
-
-
- BICOMP
- 138
-
-
- __cstat
- 172
-
-
-
-
- ICCARM
- 192 92 16 171 72 60 62 19 44 13 128 24 41 124 142 26 144 155 31 32 114 154 160 25 12 35 170 149 36 37 17 18 151 173 96 53 146 161 166 40 152 27 158 70
-
-
- BICOMP
- 27 170 92 72 31 173 241 60 142 160 17 161 41 242 144 114 12 36 151 53 40 70 239 171 124 240 62 19 44 238 24 26 155 32 154 25 35 149 37 18 96 146 166 152 158 192
-
-
-
-
- $PROJ_DIR$\..\..\..\kernel\src\mm\los_memstat.c
-
-
- ICCARM
- 182
-
-
- BICOMP
- 91
-
-
- __cstat
- 15
-
-
-
-
- ICCARM
- 39 94 24 60 62 19 44 43 33 231 92 16 171 72 13 128 41 124 142 26 144 155 31 32 114 154 160 25 12 35 170 149 36 37 17 18 151 173 96 53 146 161 166 40 152 27 158
-
-
- BICOMP
- 72 35 92 152 44 155 241 154 37 146 24 19 94 231 41 242 26 32 25 149 18 96 166 158 43 60 62 33 239 171 124 240 238 142 144 31 114 160 12 170 36 17 151 173 53 161 40 27 39
-
-
-
-
- $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval.c
-
-
- ICCARM
- 202
-
-
- BICOMP
- 175
-
-
- __cstat
- 129
-
-
-
-
- ICCARM
- 192 92 16 171 72 60 62 19 44 13 128 24 41 124 142 26 144 155 31 32 114 154 160 25 12 35 170 149 36 37 17 18 151 173 96 53 146 161 166 40 152 27 158 70
-
-
- BICOMP
- 12 40 41 144 151 92 242 114 36 53 155 70 241 72 60 142 31 160 170 17 173 161 27 154 239 171 124 240 62 19 44 238 24 26 32 25 35 149 37 18 96 146 166 152 158 192
-
-
-
-
- $PROJ_DIR$\..\..\..\kernel\src\los_swtmr.c
-
-
- ICCARM
- 181
-
-
- BICOMP
- 191
-
-
- __cstat
- 113
-
-
-
-
- ICCARM
- 159 119 50 72 60 62 19 44 73 157 115 168 174 165 167 43 33 231 94 24 92 16 171 13 128 41 124 142 26 144 155 31 32 114 154 160 25 12 35 170 149 36 37 17 18 151 173 96 53 146 161 166 40 152 27 158 64 42 163 153 234 156 164 169 162 39
-
-
- BICOMP
- 26 110 171 72 60 18 92 169 167 73 239 240 25 166 94 164 64 39 115 174 231 124 32 149 96 158 43 42 162 119 50 157 168 165 62 19 44 33 24 41 242 241 155 154 35 37 146 152 234 159 238 142 144 31 114 160 12 170 36 17 151 173 53 161 40 27 163 156 153
-
-
-
-
- $PROJ_DIR$\..\..\..\kernel\src\los_task.c
-
-
- ICCARM
- 193
-
-
- BICOMP
- 196
-
-
- __cstat
- 121
-
-
-
-
- ICCARM
- 33 231 94 24 60 62 19 44 92 16 171 72 13 128 41 124 142 26 144 155 31 32 114 154 160 25 12 35 170 149 36 37 17 18 151 173 96 53 146 161 166 40 152 27 158 159 119 50 73 157 115 168 174 165 167 56 42 163 153 234 156 164 117 169 43 49 39
-
-
- BICOMP
- 152 94 60 35 92 171 155 169 49 44 239 240 154 37 146 72 56 24 19 124 26 32 25 149 18 96 166 158 33 159 117 43 39 231 62 41 242 241 238 142 144 31 114 160 12 170 36 17 151 173 53 161 40 27 119 73 234 164 42 110 167 50 157 168 165 115 174 163 156 153
+ 91 72 129 32 99 42 46 89 45 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 90 153 156 240 134 154
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/los_demo.ewd b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/los_demo.ewd
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/los_demo.ewp b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/los_demo.ewp
old mode 100755
new mode 100644
index a07f6b3a..5b8cebca
--- a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/los_demo.ewp
+++ b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/los_demo.ewp
@@ -66,7 +66,7 @@
OGLastSavedByProductVersion
- 8.22.1.15696
+ 8.20.2.14834
GeneralEnableMisra
@@ -343,6 +343,7 @@
$PROJ_DIR$\..\Libraries\CMSIS\Device\ST\STM32F4xx\Include
$PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc
$PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar
+ $PROJ_DIR$\..\..\..\kernel\arch\include
$PROJ_DIR$\..\..\..\kernel\include
$PROJ_DIR$\..\..\..\kernel\src
$PROJ_DIR$\..
@@ -2053,21 +2054,21 @@
liteos_m
arch
+
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_context.c
+
$PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_dispatch.S
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw.c
-
-
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_exc.S
-
-
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_tick.c
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_exc.S
$PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_interrupt.c
+
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_timer.c
+
components
@@ -2093,15 +2094,9 @@
$PROJ_DIR$\..\..\..\kernel\src\mm\los_membox.c
-
- $PROJ_DIR$\..\..\..\kernel\src\mm\los_memcheck.c
-
$PROJ_DIR$\..\..\..\kernel\src\mm\los_memory.c
-
- $PROJ_DIR$\..\..\..\kernel\src\mm\los_memstat.c
-
$PROJ_DIR$\..\..\..\kernel\src\los_mux.c
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/los_demo.ewt b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/los_demo.ewt
old mode 100755
new mode 100644
index 215a0603..17f39437
--- a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/los_demo.ewt
+++ b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/los_demo.ewt
@@ -2373,21 +2373,21 @@
liteos_m
arch
+
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_context.c
+
$PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_dispatch.S
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw.c
-
-
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_exc.S
-
-
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_tick.c
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_exc.S
$PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_interrupt.c
+
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_timer.c
+
components
@@ -2413,15 +2413,9 @@
$PROJ_DIR$\..\..\..\kernel\src\mm\los_membox.c
-
- $PROJ_DIR$\..\..\..\kernel\src\mm\los_memcheck.c
-
$PROJ_DIR$\..\..\..\kernel\src\mm\los_memory.c
-
- $PROJ_DIR$\..\..\..\kernel\src\mm\los_memstat.c
-
$PROJ_DIR$\..\..\..\kernel\src\los_mux.c
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/los_demo.eww b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/los_demo.eww
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/settings/los_demo.crun b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/settings/los_demo.crun
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/settings/los_demo.dbgdt b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/settings/los_demo.dbgdt
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/settings/los_demo.dnx b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/settings/los_demo.dnx
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/settings/los_demo.wsdt b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/settings/los_demo.wsdt
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/stm32f4xx_conf.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/stm32f4xx_conf.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/stm32f4xx_it.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/stm32f4xx_it.c
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/stm32f4xx_it.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/stm32f4xx_it.h
old mode 100755
new mode 100644
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/target_config.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/target_config.h
old mode 100755
new mode 100644
index 71d27386..3e537bf0
--- a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/target_config.h
+++ b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/target_config.h
@@ -1,15 +1,21 @@
/*
- * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
- * Description: Redistribution and use in source and binary forms, with or without modification,
+ * 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.
+ * conditions and the following disclaimer.
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
- * to endorse or promote products derived from this software without specific prior written
- * permission.
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
@@ -21,13 +27,6 @@
* 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.
- * ---------------------------------------------------------------------------
- * Notice of Export Control Law
- * ===============================================
- * Huawei LiteOS may be subject to applicable export control laws and regulations, which might
- * include those applicable to Huawei LiteOS of U.S. and the country in which you are located.
- * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such
- * applicable export control laws and regulations.
*/
/**@defgroup los_config System configuration items
@@ -37,7 +36,6 @@
#ifndef _TARGET_CONFIG_H
#define _TARGET_CONFIG_H
-#include "los_compiler.h"
#include "stm32f4xx.h"
#ifdef __cplusplus
@@ -46,389 +44,60 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
-#define LOSCFG_CORTEX_M4
-
-//#define LOSCFG_BASE_CORE_MPU YES
-#define LOSCFG_BASE_CORE_MPU NO
-
-#define LOSCFG_BASE_CORE_CPUP YES
/*=============================================================================
System clock module configuration
=============================================================================*/
-
-/**
- * @ingroup los_config
- * System clock (unit: HZ)
- */
-#define OS_SYS_CLOCK 64000000
-
-#define configCPU_CLOCK_HZ ( OS_SYS_CLOCK )
-
-#if( configUSE_16_BIT_TICKS == 1 )
- typedef UINT16 TickType_t;
- #define portMAX_DELAY ( TickType_t ) 0xffff
-#else
- typedef UINT32 TickType_t;
- #define portMAX_DELAY ( TickType_t ) 0xffffffffUL
-
- /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do
- not need to be guarded with a critical section. */
- #define portTICK_TYPE_IS_ATOMIC 1
-#endif
-
-#define configTICK_RATE_HZ ( ( TickType_t ) 1000 )
-
-#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
-
-/**
- * @ingroup los_config
- * Number of Ticks in one second
- */
+#define OS_SYS_CLOCK 64000000
#define LOSCFG_BASE_CORE_TICK_PER_SECOND (1000UL)
-
-/**
- * @ingroup los_config
- * External configuration item for timer tailoring
- */
-#define LOSCFG_BASE_CORE_TICK_HW_TIME NO
-
-/**
- * @ingroup los_config
- * Configuration liteos kernel tickless
- */
-#define LOSCFG_KERNEL_TICKLESS NO
+#define LOSCFG_BASE_CORE_TICK_HW_TIME 0
/*=============================================================================
Hardware interrupt module configuration
=============================================================================*/
-
-/**
- * @ingroup los_config
- * Configuration item for hardware interrupt tailoring
- */
-#define LOSCFG_PLATFORM_HWI YES
-
-/**
- * @ingroup los_config
- * Maximum number of used hardware interrupts, including Tick timer interrupts.
- */
+#define LOSCFG_PLATFORM_HWI 1
#define LOSCFG_PLATFORM_HWI_LIMIT 128
-#define LOSCFG_PLATFORM_HWI_MAX_EXCEPTION_COUNT 65000
-
/*=============================================================================
Task module configuration
=============================================================================*/
-
-/**
- * @ingroup los_config
- * Default task priority
- */
-#define LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO 10
-
-/**
- * @ingroup los_config
- * Maximum supported number of tasks except the idle task rather than the number of usable tasks
- */
-#define LOSCFG_BASE_CORE_TSK_LIMIT 24 // max num task
-
-/**
- * @ingroup los_config
- * Size of the idle task stack
- */
-#define LOSCFG_BASE_CORE_TSK_IDLE_STACK_SIZE (0x500U) // IDLE task stack
-
-/**
- * @ingroup los_config
- * Default task stack size
- */
-#define LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE (0x2D0U) // default stack
-
-/**
- * @ingroup los_config
- * Minimum stack size.
- */
+#define LOSCFG_BASE_CORE_TSK_LIMIT 24
+#define LOSCFG_BASE_CORE_TSK_IDLE_STACK_SIZE (0x500U)
+#define LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE (0x2D0U)
#define LOSCFG_BASE_CORE_TSK_MIN_STACK_SIZE (0x130U)
-
-/**
- * @ingroup los_config
- * Configuration item for task Robin tailoring
- */
-#define LOSCFG_BASE_CORE_TIMESLICE YES
-
-/**
- * @ingroup los_config
- * Longest execution time of tasks with the same priorities
- */
+#define LOSCFG_BASE_CORE_TIMESLICE 1
#define LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT 10
-
-/**
- * @ingroup los_config
- * Configuration item for task (stack) monitoring module tailoring
- */
-#define LOSCFG_BASE_CORE_TSK_MONITOR YES
-
-/**
- * @ingroup los_config
- * Configuration item for task perf task filter hook
- */
-#define LOSCFG_BASE_CORE_EXC_TSK_SWITCH YES
-
-/**
- * @ingroup los_config
- * Configuration item for performance moniter unit
- */
-#define OS_INCLUDE_PERF YES
-
-/**
- * @ingroup los_config
- * Define a usable task priority.Highest task priority.
- */
-#define LOS_TASK_PRIORITY_HIGHEST 0
-
-/**
- * @ingroup los_config
- * Define a usable task priority.Lowest task priority.
- */
-#define LOS_TASK_PRIORITY_LOWEST 31
-
-
/*=============================================================================
Semaphore module configuration
=============================================================================*/
-
-/**
- * @ingroup los_config
- * Configuration item for semaphore module tailoring
- */
-#define LOSCFG_BASE_IPC_SEM YES
-
-/**
- * @ingroup los_config
- * Maximum supported number of semaphores
- */
-#define LOSCFG_BASE_IPC_SEM_LIMIT 48 // the max sem-numb
-
-
+#define LOSCFG_BASE_IPC_SEM 1
+#define LOSCFG_BASE_IPC_SEM_LIMIT 48
/*=============================================================================
Mutex module configuration
=============================================================================*/
-
-/**
- * @ingroup los_config
- * Configuration item for mutex module tailoring
- */
-#define LOSCFG_BASE_IPC_MUX YES
-
-/**
- * @ingroup los_config
- * Maximum supported number of mutexes
- */
-#define LOSCFG_BASE_IPC_MUX_LIMIT 24 // the max mutex-num
-
-
+#define LOSCFG_BASE_IPC_MUX 1
+#define LOSCFG_BASE_IPC_MUX_LIMIT 24
/*=============================================================================
Queue module configuration
=============================================================================*/
-
-/**
- * @ingroup los_config
- * Configuration item for queue module tailoring
- */
-#define LOSCFG_BASE_IPC_QUEUE YES
-
-/**
- * @ingroup los_config
- * Maximum supported number of queues rather than the number of usable queues
- */
-#define LOSCFG_BASE_IPC_QUEUE_LIMIT 24 //the max queue-numb
-
-
+#define LOSCFG_BASE_IPC_QUEUE 1
+#define LOSCFG_BASE_IPC_QUEUE_LIMIT 24
/*=============================================================================
Software timer module configuration
=============================================================================*/
-
-#if (LOSCFG_BASE_IPC_QUEUE == YES)
-/**
- * @ingroup los_config
- * Configuration item for software timer module tailoring
- */
-#define LOSCFG_BASE_CORE_SWTMR YES
-
-#define LOSCFG_BASE_CORE_TSK_SWTMR_STACK_SIZE (LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE * 4)
-
-#define LOSCFG_BASE_CORE_SWTMR_TASK YES
-
-#define LOSCFG_BASE_CORE_SWTMR_ALIGN YES
-#if(LOSCFG_BASE_CORE_SWTMR == NO && LOSCFG_BASE_CORE_SWTMR_ALIGN == YES)
- #error "swtmr align first need support swmtr, should make LOSCFG_BASE_CORE_SWTMR = YES"
-#endif
-
-/**
- * @ingroup los_config
- * Maximum supported number of software timers rather than the number of usable software timers
- */
-#define LOSCFG_BASE_CORE_SWTMR_LIMIT 48 // the max SWTMR numb
-
-/**
- * @ingroup los_config
- * Max number of software timers ID
- */
-#define OS_SWTMR_MAX_TIMERID ((65535/LOSCFG_BASE_CORE_SWTMR_LIMIT) * LOSCFG_BASE_CORE_SWTMR_LIMIT)
-
-/**
- * @ingroup los_config
- * Maximum size of a software timer queue
- */
-#define OS_SWTMR_HANDLE_QUEUE_SIZE (LOSCFG_BASE_CORE_SWTMR_LIMIT + 0)
-
-/**
- * @ingroup los_config
- * Minimum divisor of software timer multiple alignment
- */
-#define LOS_COMMON_DIVISOR 10
-#endif
-
-
+#define LOSCFG_BASE_CORE_SWTMR 1
+#define LOSCFG_BASE_CORE_SWTMR_ALIGN 1
+#define LOSCFG_BASE_CORE_SWTMR_LIMIT 48
/*=============================================================================
Memory module configuration
=============================================================================*/
-
-extern UINT8 *m_aucSysMem0;
-extern UINT32 __LOS_HEAP_ADDR_START__;
-extern UINT32 __LOS_HEAP_ADDR_END__;
-/**
- * @ingroup los_config
- * Starting address of the memory
- */
-#define OS_SYS_MEM_ADDR (VOID *)m_aucSysMem0
-/**
- * @ingroup los_config
- * Ending address of the memory
- */
-extern UINT32 g_sys_mem_addr_end;
-
-/**
- * @ingroup los_config
- * Memory size
- */
#define OS_SYS_MEM_SIZE 0x00013000
-
-/**
- * @ingroup los_config
- * Configuration module tailoring of mem node integrity checking
- */
-#define LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK YES
-
-/**
- * @ingroup los_config
- * Configuration module tailoring of mem node size checking
- */
-#define LOSCFG_BASE_MEM_NODE_SIZE_CHECK YES
-
-#define LOSCFG_MEMORY_BESTFIT YES
-
-/**
- * @ingroup los_config
- * Configuration module tailoring of more mempry pool checking
- */
-#define LOSCFG_MEM_MUL_POOL YES
-
-/**
- * @ingroup los_config
- * Number of memory checking blocks
- */
+#define LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK 0
+#define LOSCFG_BASE_MEM_NODE_SIZE_CHECK 1
+#define LOSCFG_MEM_MUL_POOL 1
#define OS_SYS_MEM_NUM 20
-
-/**
- * @ingroup los_config
- * Configuration module tailoring of slab memory
- */
-#define LOSCFG_KERNEL_MEM_SLAB NO
-
-
-/*=============================================================================
- fw Interface configuration
-=============================================================================*/
-
-/**
- * @ingroup los_config
- * Configuration item for the monitoring of task communication
- */
-#define LOSCFG_COMPAT_CMSIS_FW YES
-
-
-/*=============================================================================
- others
-=============================================================================*/
-
-/**
- * @ingroup los_config
- * Configuration system wake-up info to open
- */
-#define OS_SR_WAKEUP_INFO YES
-
-/**
- * @ingroup los_config
- * Configuration CMSIS_OS_VER
- */
-#define CMSIS_OS_VER 2
-
-
+#define LOSCFG_KERNEL_MEM_SLAB 0
/*=============================================================================
Exception module configuration
=============================================================================*/
-
-/**
- * @ingroup los_config
- * Configuration item for exception tailoring
- */
-#define LOSCFG_PLATFORM_EXC YES
-
-
-/*=============================================================================
- Runstop module configuration
-=============================================================================*/
-
-/**
- * @ingroup los_config
- * Configuration item for runstop module tailoring
- */
-#define LOSCFG_KERNEL_RUNSTOP NO
-
-
-
-/**
- * @ingroup los_config
- * Configuration test case to open
- */
-
-
-
-#define LOSCFG_EXCLUDE_TEST
-
-#ifndef LOSCFG_EXCLUDE_TEST
-#define LOSCFG_TEST YES
-#else
-#define LOSCFG_TEST NO
-#endif
-
-
-
-/*=============================================================================
- track configuration
-=============================================================================*/
-
-/**
- * @ingroup los_config
- * Configuration item for track
- */
-#define LOSCFG_BASE_MISC_TRACK NO
-
-/**
- * @ingroup los_config
- * Max count of track items
- */
-#define LOSCFG_BASE_MISC_TRACK_MAX_COUNT 1024
-
+#define LOSCFG_PLATFORM_EXC 1
#ifdef __cplusplus
#if __cplusplus
diff --git a/targets/riscv_sifive_fe310_gcc/target_config.h b/targets/riscv_sifive_fe310_gcc/target_config.h
new file mode 100644
index 00000000..3fbf6f32
--- /dev/null
+++ b/targets/riscv_sifive_fe310_gcc/target_config.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2013-2020, 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 _TARGETS_CONFIG_H
+#define _TARGETS_CONFIG_H
+
+#include "soc.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#define OS_SYS_CLOCK 10000000UL
+
+#define LOSCFG_BASE_CORE_TICK_PER_SECOND 1000
+
+/****************************** System clock module configuration ****************************/
+#define LOSCFG_BASE_CORE_TIMER_NUM 7
+
+/****************************** Task module configuration ********************************/
+#define LOSCFG_BASE_CORE_TSK_LIMIT 20 // max num task
+#define LOSCFG_BASE_CORE_TSK_IDLE_STACK_SIZE (0x500U) // IDLE task stack
+#define LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE (0x2D0U) // default stack
+#define LOSCFG_BASE_CORE_TSK_MIN_STACK_SIZE (0x130U)
+#define LOSCFG_BASE_CORE_TIMESLICE 1 // task-ROBIN moduel cutting switch
+#define LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT 10
+/****************************** Semaphore module configuration ******************************/
+#define LOSCFG_BASE_IPC_SEM 1
+#define LOSCFG_BASE_IPC_SEM_LIMIT 10 // the max sem-numb
+/****************************** mutex module configuration ******************************/
+#define LOSCFG_BASE_IPC_MUX 1
+#define LOSCFG_BASE_IPC_MUX_LIMIT 10 // the max mutex-num
+/****************************** Queue module configuration ********************************/
+#define LOSCFG_BASE_IPC_QUEUE 1
+#define LOSCFG_BASE_IPC_QUEUE_LIMIT 10 //the max queue-numb
+
+/****************************** Software timer module configuration **************************/
+#define LOSCFG_BASE_CORE_SWTMR 1
+#define LOSCFG_BASE_CORE_SWTMR_LIMIT 10 // the max SWTMR numb
+
+/****************************** Memory module configuration **************************/
+#define LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK 0
+#define LOSCFG_BASE_MEM_NODE_SIZE_CHECK 1
+#define LOSCFG_MEMORY_BESTFIT 1
+#define LOSCFG_PLATFORM_EXC 1
+#define OS_SYS_MEM_NUM 20
+
+#define LOSCFG_KERNEL_MEM_SLAB 0
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+
+#endif /* _TARGETS_CONFIG_H */
diff --git a/utils/los_compiler.h b/utils/los_compiler.h
old mode 100755
new mode 100644
index ef74252b..648a95c5
--- a/utils/los_compiler.h
+++ b/utils/los_compiler.h
@@ -311,16 +311,6 @@ typedef signed int INTPTR;
#define NULL ((VOID *)0)
#endif
-#ifdef YES
-#undef YES
-#endif
-#define YES 1
-
-#ifdef NO
-#undef NO
-#endif
-#define NO 0
-
#define OS_NULL_BYTE ((UINT8)0xFF)
#define OS_NULL_SHORT ((UINT16)0xFFFF)
#define OS_NULL_INT ((UINT32)0xFFFFFFFF)
diff --git a/utils/los_debug.h b/utils/los_debug.h
old mode 100755
new mode 100644
index f4a29d29..3ff3d1d6
--- a/utils/los_debug.h
+++ b/utils/los_debug.h
@@ -1,15 +1,21 @@
/*
- * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
- * Description: Redistribution and use in source and binary forms, with or without modification,
+ * 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.
+ * conditions and the following disclaimer.
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
- * to endorse or promote products derived from this software without specific prior written
- * permission.
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
@@ -21,13 +27,6 @@
* 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.
- * ---------------------------------------------------------------------------
- * Notice of Export Control Law
- * ===============================================
- * Huawei LiteOS may be subject to applicable export control laws and regulations, which might
- * include those applicable to Huawei LiteOS of U.S. and the country in which you are located.
- * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such
- * applicable export control laws and regulations.
*/
/**@defgroup los_debug
diff --git a/utils/los_error.c b/utils/los_error.c
old mode 100755
new mode 100644
diff --git a/utils/los_error.h b/utils/los_error.h
old mode 100755
new mode 100644
diff --git a/utils/los_list.h b/utils/los_list.h
old mode 100755
new mode 100644
index 6e0f989c..fbd622c0
--- a/utils/los_list.h
+++ b/utils/los_list.h
@@ -205,27 +205,6 @@ LITE_OS_SEC_ALW_INLINE STATIC_INLINE BOOL LOS_ListEmpty(LOS_DL_LIST *node)
return (BOOL)(node->pstNext == node);
}
-/**
- * @ingroup los_list
- * @brief Obtain the offset of a field to a structure address.
- *
- * @par Description:
- * This API is used to obtain the offset of a field to a structure address.
- * @attention
- *
- *
- * @param type [IN] Structure name.
- * @param field [IN] Name of the field of which the offset is to be measured.
- *
- * @retval Offset of the field to the structure address.
- * @par Dependency:
- * los_list.h: the header file that contains the API declaration.
- * @see
- */
-#define OFFSET_OF_FIELD(type, field) ((UINT32)&(((type *)0)->field))
-
/**
* @ingroup los_list
* @brief Obtain the pointer to a doubly linked list in a structure.
diff --git a/utils/los_reg.h b/utils/los_reg.h
old mode 100755
new mode 100644