From 72c4acf01e452746a42803094b7eaf22cee52e92 Mon Sep 17 00:00:00 2001 From: likailong Date: Wed, 2 Dec 2020 19:40:34 +0800 Subject: [PATCH] Description: liteos-m refactoring Reviewed-by: wangmihu, zhushengle --- arch_spec.md | 52 + components/cmsis/2.0/cmsis_os2.h | 1 - components/cppsupport/los_cppsupport.h | 2 +- components/cpup/los_cpup.c | 40 +- components/cpup/los_cpup.h | 178 +- components/cpup/los_cpup_pri.h | 111 - kal/BUILD.gn | 27 +- kal/cmsis/BUILD.gn | 15 + kal/{ => cmsis}/cmsis_liteos.c | 0 kal/{ => cmsis}/cmsis_liteos2.c | 0 kal/{ => cmsis}/cmsis_os.h | 0 kal/{ => cmsis}/cmsis_os2.h | 222 +- kal/{ => cmsis}/hos_cmsis_adp.h | 2 +- kal/kal/BUILD.gn | 15 + kal/{ => kal}/kal.c | 0 kal/{ => kal}/kal.h | 0 kal/posix/BUILD.gn | 20 + kal/posix/include/README | 12 + .../posix/include/version.h | 99 +- kernel/src/los_misc.c => kal/posix/src/file.c | 157 +- kal/posix/src/pthread.c | 237 ++ kal/posix/src/pthread_attr.c | 233 ++ kal/posix/src/time.c | 254 ++ .../posix/src/version.c | 104 +- kernel/arch/arm/cortex-m3/keil/cmsis/ARMCM3.h | 276 ++ .../arch/arm/cortex-m3/keil/cmsis/core_cm3.h | 1623 +++++++++ .../arm/cortex-m3/keil/cmsis/core_cmFunc.h | 636 ++++ .../arm/cortex-m3/keil/cmsis/core_cmInstr.h | 688 ++++ .../los_hw.h => cortex-m3/keil/los_context.h} | 1 - kernel/arch/arm/cortex-m3/keil/los_dispatch.S | 163 + kernel/arch/arm/cortex-m3/keil/los_hw.c | 149 + kernel/arch/arm/cortex-m3/keil/los_hw_exc.S | 287 ++ kernel/arch/arm/cortex-m3/keil/los_hw_tick.c | 267 ++ .../arch/arm/cortex-m3/keil/los_interrupt.c | 450 +++ .../keil/los_interrupt.h} | 1824 ++++++---- kernel/arch/arm/cortex-m3/keil/los_vendor.s | 54 + kernel/arch/arm/cortex-m4/iar/los_context.h | 194 ++ .../{los_dispatch_iar.S => los_dispatch.S} | 0 kernel/arch/arm/cortex-m4/iar/los_exc.c | 363 -- kernel/arch/arm/cortex-m4/iar/los_exc.h | 265 -- kernel/arch/arm/cortex-m4/iar/los_exc_pri.h | 98 - kernel/arch/arm/cortex-m4/iar/los_hw.c | 4 +- .../iar/{los_hw_exc_iar.S => los_hw_exc.S} | 0 kernel/arch/arm/cortex-m4/iar/los_hw_tick.c | 13 +- .../iar/{los_hwi.c => los_interrupt.c} | 263 +- kernel/arch/arm/cortex-m4/iar/los_interrupt.h | 1085 ++++++ .../{rvm32/include => }/asm/soc_common.h | 0 kernel/arch/risc-v/include/los_exc.h | 60 - kernel/arch/risc-v/include/los_hw.h | 123 - .../include/los_hw_pri.h => los_context.h} | 83 +- .../risc-v/{rvm32/src => }/los_dispatch.S | 0 kernel/arch/risc-v/{rvm32/src => }/los_exc.c | 170 +- kernel/arch/risc-v/{rvm32/src => }/los_hw.c | 7 +- .../arch/risc-v/{rvm32/src => }/los_hw_tick.c | 14 +- .../{include/los_hwi.h => los_interrupt.h} | 157 +- kernel/arch/risc-v/{rvm32/src => }/los_trap.S | 0 .../arch/risc-v/rvm32/include/los_exc_pri.h | 67 - .../arch/risc-v/rvm32/include/los_hwi_pri.h | 135 - kernel/arch/risc-v/rvm32/src/los_hwi.c | 191 -- kernel/base/mem/common/los_slab.c | 390 --- kernel/base/mem/common/los_slabmem.c | 307 -- kernel/include/los_base.h | 261 -- kernel/include/los_builddef.h | 205 -- kernel/include/los_compiler.h | 143 - kernel/include/los_config.h | 3 +- kernel/include/los_cpup.h | 308 -- kernel/include/los_errno.h | 115 - kernel/include/los_event.h | 4 +- kernel/include/los_heap.h | 232 -- kernel/include/los_membox.h | 17 +- kernel/include/los_memcheck.h | 116 - kernel/include/los_memory.h | 333 +- kernel/include/los_mux.h | 63 +- kernel/include/los_printf.h | 135 - kernel/include/los_queue.h | 186 +- kernel/include/los_sem.h | 88 +- kernel/include/los_slab.h | 66 - kernel/include/los_swtmr.h | 115 +- kernel/include/los_sys.h | 212 -- kernel/include/los_tables.h | 128 - kernel/include/los_task.h | 1008 +++++- kernel/include/los_tick.h | 462 ++- kernel/include/los_tickless.h | 91 - kernel/include/los_typedef.h | 121 - kernel/src/los_base_pri.h | 63 - kernel/src/los_err_pri.h | 132 - kernel/src/los_event.c | 11 +- kernel/src/los_event_pri.h | 52 - kernel/src/los_heap_pri.h | 159 - kernel/src/los_init.c | 23 +- kernel/src/los_membox_pri.h | 65 - kernel/src/los_memcheck_pri.h | 75 - kernel/src/los_memory_pri.h | 179 - kernel/src/los_memstat_pri.h | 82 - kernel/src/los_multipledlinkhead_pri.h | 79 - kernel/src/los_mux.c | 14 +- kernel/src/los_mux_pri.h | 110 - kernel/src/los_priqueue.c | 113 - kernel/src/los_priqueue_pri.h | 171 - kernel/src/los_queue.c | 15 +- kernel/src/los_queue_pri.h | 234 -- kernel/src/los_sem.c | 13 +- kernel/src/los_sem_pri.h | 134 - kernel/src/los_slab_pri.h | 687 ---- kernel/src/los_sr.h | 87 - kernel/src/los_swtmr.c | 26 +- kernel/src/los_swtmr_pri.h | 163 - kernel/src/los_sys.c | 159 - kernel/src/los_sys_pri.h | 183 - kernel/src/los_task.c | 150 +- kernel/src/los_task_pri.h | 711 ---- kernel/src/los_tick.c | 128 +- kernel/src/los_tick_pri.h | 126 - kernel/src/los_timeslice.c | 91 - kernel/src/los_timeslice_pri.h | 99 - kernel/src/mm/los_membox.c | 15 +- kernel/src/mm/los_memcheck.c | 6 +- kernel/src/mm/los_memory.c | 64 +- kernel/src/mm/los_memstat.c | 7 +- kernel/src/mm/los_multipledlinkhead.c | 66 - .../Driver/STM32F103/uart.c | 409 +++ .../cortex-m3_stm32f103_simulator_keil/main.c | 135 + .../project/los_demo.sct | 24 + .../project/los_demo.uvopt | 727 ++++ .../project/los_demo.uvproj | 571 ++++ .../target_config.h | 438 +++ .../dprintf.c | 2 +- .../main.c | 240 +- .../project/los_demo.dep | 2995 ++++------------- .../project/los_demo.ewd | 8 +- .../project/los_demo.ewp | 30 +- .../project/los_demo.ewt | 26 +- .../project/settings/los_demo.dbgdt | 970 +----- .../project/settings/los_demo.dnx | 37 +- .../project/settings/los_demo.wsdt | 148 +- .../target_config.h | 3 +- .../Liteos.ld | 0 .../Makefile | 14 +- .../board.ld.S | 0 .../compiler_dir.sh | 0 .../driver/mtimer.c | 6 +- .../driver/mtimer.h | 2 +- .../driver/plic.c | 5 +- .../driver/plic.h | 2 +- .../driver/uart.c | 2 +- .../driver/uart.h | 3 +- .../include/asm/soc.h | 0 .../include/riscv_hal.h | 2 +- .../libc/dprintf.c | 2 +- .../los_start.S | 0 .../main.c | 5 +- .../qemu_sifive_run.sh | 0 .../riscv_hal.c | 2 +- .../target_config.h | 5 + utils/los_compiler.h | 402 +++ .../include/los_trace.h => utils/los_debug.h | 131 +- kernel/src/los_err.c => utils/los_error.c | 2 +- kernel/include/los_err.h => utils/los_error.h | 154 +- {kernel/include => utils}/los_list.h | 2 +- utils/los_reg.h | 117 + 160 files changed, 15478 insertions(+), 13235 deletions(-) create mode 100755 arch_spec.md delete mode 120000 components/cmsis/2.0/cmsis_os2.h delete mode 100755 components/cpup/los_cpup_pri.h create mode 100755 kal/cmsis/BUILD.gn rename kal/{ => cmsis}/cmsis_liteos.c (100%) rename kal/{ => cmsis}/cmsis_liteos2.c (100%) rename kal/{ => cmsis}/cmsis_os.h (100%) rename kal/{ => cmsis}/cmsis_os2.h (93%) rename kal/{ => cmsis}/hos_cmsis_adp.h (98%) create mode 100755 kal/kal/BUILD.gn rename kal/{ => kal}/kal.c (100%) rename kal/{ => kal}/kal.h (100%) create mode 100755 kal/posix/BUILD.gn create mode 100755 kal/posix/include/README rename kernel/arch/risc-v/rvm32/include/los_hw_tick_pri.h => kal/posix/include/version.h (81%) mode change 100644 => 100755 rename kernel/src/los_misc.c => kal/posix/src/file.c (55%) create mode 100755 kal/posix/src/pthread.c create mode 100755 kal/posix/src/pthread_attr.c create mode 100755 kal/posix/src/time.c rename kernel/src/los_printf_pri.h => kal/posix/src/version.c (77%) create mode 100755 kernel/arch/arm/cortex-m3/keil/cmsis/ARMCM3.h create mode 100755 kernel/arch/arm/cortex-m3/keil/cmsis/core_cm3.h create mode 100755 kernel/arch/arm/cortex-m3/keil/cmsis/core_cmFunc.h create mode 100755 kernel/arch/arm/cortex-m3/keil/cmsis/core_cmInstr.h rename kernel/arch/arm/{cortex-m4/iar/los_hw.h => cortex-m3/keil/los_context.h} (95%) create mode 100755 kernel/arch/arm/cortex-m3/keil/los_dispatch.S create mode 100755 kernel/arch/arm/cortex-m3/keil/los_hw.c create mode 100755 kernel/arch/arm/cortex-m3/keil/los_hw_exc.S create mode 100755 kernel/arch/arm/cortex-m3/keil/los_hw_tick.c create mode 100755 kernel/arch/arm/cortex-m3/keil/los_interrupt.c rename kernel/arch/arm/{cortex-m4/iar/los_hwi.h => cortex-m3/keil/los_interrupt.h} (67%) create mode 100755 kernel/arch/arm/cortex-m3/keil/los_vendor.s create mode 100755 kernel/arch/arm/cortex-m4/iar/los_context.h rename kernel/arch/arm/cortex-m4/iar/{los_dispatch_iar.S => los_dispatch.S} (100%) delete mode 100755 kernel/arch/arm/cortex-m4/iar/los_exc.c delete mode 100755 kernel/arch/arm/cortex-m4/iar/los_exc.h delete mode 100755 kernel/arch/arm/cortex-m4/iar/los_exc_pri.h rename kernel/arch/arm/cortex-m4/iar/{los_hw_exc_iar.S => los_hw_exc.S} (100%) rename kernel/arch/arm/cortex-m4/iar/{los_hwi.c => los_interrupt.c} (52%) create mode 100755 kernel/arch/arm/cortex-m4/iar/los_interrupt.h rename kernel/arch/risc-v/{rvm32/include => }/asm/soc_common.h (100%) mode change 100644 => 100755 delete mode 100644 kernel/arch/risc-v/include/los_exc.h delete mode 100644 kernel/arch/risc-v/include/los_hw.h rename kernel/arch/risc-v/{rvm32/include/los_hw_pri.h => los_context.h} (70%) mode change 100644 => 100755 rename kernel/arch/risc-v/{rvm32/src => }/los_dispatch.S (100%) mode change 100644 => 100755 rename kernel/arch/risc-v/{rvm32/src => }/los_exc.c (61%) mode change 100644 => 100755 rename kernel/arch/risc-v/{rvm32/src => }/los_hw.c (97%) mode change 100644 => 100755 rename kernel/arch/risc-v/{rvm32/src => }/los_hw_tick.c (81%) mode change 100644 => 100755 rename kernel/arch/risc-v/{include/los_hwi.h => los_interrupt.h} (74%) mode change 100644 => 100755 rename kernel/arch/risc-v/{rvm32/src => }/los_trap.S (100%) delete mode 100644 kernel/arch/risc-v/rvm32/include/los_exc_pri.h delete mode 100644 kernel/arch/risc-v/rvm32/include/los_hwi_pri.h delete mode 100644 kernel/arch/risc-v/rvm32/src/los_hwi.c delete mode 100755 kernel/base/mem/common/los_slab.c delete mode 100755 kernel/base/mem/common/los_slabmem.c delete mode 100755 kernel/include/los_base.h delete mode 100755 kernel/include/los_builddef.h delete mode 100755 kernel/include/los_compiler.h delete mode 100755 kernel/include/los_cpup.h delete mode 100755 kernel/include/los_errno.h delete mode 100755 kernel/include/los_heap.h delete mode 100755 kernel/include/los_memcheck.h delete mode 100755 kernel/include/los_printf.h delete mode 100755 kernel/include/los_slab.h delete mode 100755 kernel/include/los_sys.h delete mode 100755 kernel/include/los_tables.h delete mode 100755 kernel/include/los_tickless.h delete mode 100755 kernel/include/los_typedef.h delete mode 100755 kernel/src/los_base_pri.h delete mode 100755 kernel/src/los_err_pri.h delete mode 100755 kernel/src/los_event_pri.h delete mode 100755 kernel/src/los_heap_pri.h delete mode 100755 kernel/src/los_membox_pri.h delete mode 100755 kernel/src/los_memcheck_pri.h delete mode 100755 kernel/src/los_memory_pri.h delete mode 100755 kernel/src/los_memstat_pri.h delete mode 100755 kernel/src/los_multipledlinkhead_pri.h delete mode 100755 kernel/src/los_mux_pri.h delete mode 100755 kernel/src/los_priqueue.c delete mode 100755 kernel/src/los_priqueue_pri.h delete mode 100755 kernel/src/los_queue_pri.h delete mode 100755 kernel/src/los_sem_pri.h delete mode 100755 kernel/src/los_slab_pri.h delete mode 100755 kernel/src/los_sr.h delete mode 100755 kernel/src/los_swtmr_pri.h delete mode 100755 kernel/src/los_sys.c delete mode 100755 kernel/src/los_sys_pri.h delete mode 100755 kernel/src/los_task_pri.h delete mode 100755 kernel/src/los_tick_pri.h delete mode 100755 kernel/src/los_timeslice.c delete mode 100755 kernel/src/los_timeslice_pri.h delete mode 100755 kernel/src/mm/los_multipledlinkhead.c create mode 100755 targets/cortex-m3_stm32f103_simulator_keil/Driver/STM32F103/uart.c create mode 100755 targets/cortex-m3_stm32f103_simulator_keil/main.c create mode 100755 targets/cortex-m3_stm32f103_simulator_keil/project/los_demo.sct create mode 100755 targets/cortex-m3_stm32f103_simulator_keil/project/los_demo.uvopt create mode 100755 targets/cortex-m3_stm32f103_simulator_keil/project/los_demo.uvproj create mode 100755 targets/cortex-m3_stm32f103_simulator_keil/target_config.h rename targets/{riscv_sifive_fe310 => riscv_sifive_fe310_gcc}/Liteos.ld (100%) mode change 100644 => 100755 rename targets/{riscv_sifive_fe310 => riscv_sifive_fe310_gcc}/Makefile (90%) mode change 100644 => 100755 rename targets/{riscv_sifive_fe310 => riscv_sifive_fe310_gcc}/board.ld.S (100%) mode change 100644 => 100755 rename targets/{riscv_sifive_fe310 => riscv_sifive_fe310_gcc}/compiler_dir.sh (100%) rename targets/{riscv_sifive_fe310 => riscv_sifive_fe310_gcc}/driver/mtimer.c (97%) mode change 100644 => 100755 rename targets/{riscv_sifive_fe310 => riscv_sifive_fe310_gcc}/driver/mtimer.h (98%) mode change 100644 => 100755 rename targets/{riscv_sifive_fe310 => riscv_sifive_fe310_gcc}/driver/plic.c (98%) mode change 100644 => 100755 rename targets/{riscv_sifive_fe310 => riscv_sifive_fe310_gcc}/driver/plic.h (98%) mode change 100644 => 100755 rename targets/{riscv_sifive_fe310 => riscv_sifive_fe310_gcc}/driver/uart.c (99%) mode change 100644 => 100755 rename targets/{riscv_sifive_fe310 => riscv_sifive_fe310_gcc}/driver/uart.h (98%) mode change 100644 => 100755 rename targets/{riscv_sifive_fe310 => riscv_sifive_fe310_gcc}/include/asm/soc.h (100%) mode change 100644 => 100755 rename targets/{riscv_sifive_fe310 => riscv_sifive_fe310_gcc}/include/riscv_hal.h (98%) mode change 100644 => 100755 rename targets/{riscv_sifive_fe310 => riscv_sifive_fe310_gcc}/libc/dprintf.c (97%) mode change 100644 => 100755 rename targets/{riscv_sifive_fe310 => riscv_sifive_fe310_gcc}/los_start.S (100%) mode change 100644 => 100755 rename targets/{riscv_sifive_fe310 => riscv_sifive_fe310_gcc}/main.c (94%) mode change 100644 => 100755 rename targets/{riscv_sifive_fe310 => riscv_sifive_fe310_gcc}/qemu_sifive_run.sh (100%) rename targets/{riscv_sifive_fe310 => riscv_sifive_fe310_gcc}/riscv_hal.c (99%) mode change 100644 => 100755 rename targets/{riscv_sifive_fe310 => riscv_sifive_fe310_gcc}/target_config.h (97%) mode change 100644 => 100755 create mode 100755 utils/los_compiler.h rename kernel/include/los_trace.h => utils/los_debug.h (67%) rename kernel/src/los_err.c => utils/los_error.c (96%) rename kernel/include/los_err.h => utils/los_error.h (56%) rename {kernel/include => utils}/los_list.h (96%) create mode 100755 utils/los_reg.h diff --git a/arch_spec.md b/arch_spec.md new file mode 100755 index 00000000..231a5662 --- /dev/null +++ b/arch_spec.md @@ -0,0 +1,52 @@ +`` +. +├── components --- 可选组件,可裁剪,依赖kernel +│   ├── cppsupport --- C++支持 +│   └── cpup --- CPUP功能 +├── kal --- 内核抽象层 +│   ├── cmsis --- cmsis标准支持 +│   └── posix --- posix标准支持 +├── kernel --- 内核最小功能集支持 +│   ├── arch --- 硬件架构相关 +│   │   ├── arm --- arm32架构 +│   │   │   └── cortex-m4 --- cortex-m4架构 +│   │   │   └── iar --- +│   │   │   ├── los_atomic.h +│   │   │   ├── los_context.h +│   │   │   ├── los_interrupt.h +│   │   │   └── los_mpu.h +│   │   └── include +│   │   ├── los_arch_atomic.h --- 定义通用arch的原子操作 +│   │   ├── los_arch_context.h --- 定义通用arch的上下文切换 +│   │   ├── los_arch.h --- 定义通用arch初始化 +│   │   └── los_arch_interrupt.h --- 定义通用arch中断 +│   ├── include +│   │   ├── los_config.h --- 功能开关和配置参数 +│   │   ├── los_event.h --- 事件 +│   │   ├── los_liteos.h --- liteos最小功能集对外提供的头文件 +│   │   ├── los_memory.h --- 堆内存管理 +│   │   ├── los_mutex.h --- 互斥锁 +│   │   ├── los_queue.h --- 队列 +│   │   ├── los_scheduler.h --- 调度算法 +│   │   ├── los_sem.h --- 信号量 +│   │   ├── los_task.h --- 任务 +│   │   └── los_timer.h --- 定时器 +│   └── src +├── targets +│   └── targets +│   └── cortex-m4_stm32f429ig_fire-challenger_iar +│   ├── board +│   ├── dprintf.c +│   ├── Libraries +│   ├── main.c +│   ├── project +│   ├── target_config.h --- 板级配置功能开关和配置参数 +│   └── Utilities +└── utils + ├── include + │   ├── los_compiler.h --- 编译工具配置,类型定义 + │   ├── los_debug.h --- debug,printf相关 + │   ├── los_error.h --- 错误定义 + │   └── los_list.h + └── src +``` diff --git a/components/cmsis/2.0/cmsis_os2.h b/components/cmsis/2.0/cmsis_os2.h deleted file mode 120000 index 3c97517f..00000000 --- a/components/cmsis/2.0/cmsis_os2.h +++ /dev/null @@ -1 +0,0 @@ -../../../../../third_party/cmsis/CMSIS/RTOS2/Include/cmsis_os2.h \ No newline at end of file diff --git a/components/cppsupport/los_cppsupport.h b/components/cppsupport/los_cppsupport.h index 54f917fc..b1229a7e 100755 --- a/components/cppsupport/los_cppsupport.h +++ b/components/cppsupport/los_cppsupport.h @@ -37,7 +37,7 @@ #ifndef _LOS_CPPSUPPORT_H #define _LOS_CPPSUPPORT_H -#include "los_typedef.h" +#include "los_compiler.h" #ifdef __cplusplus #if __cplusplus diff --git a/components/cpup/los_cpup.c b/components/cpup/los_cpup.c index 71a66f62..8a01145f 100755 --- a/components/cpup/los_cpup.c +++ b/components/cpup/los_cpup.c @@ -29,12 +29,8 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "string.h" -#include "securec.h" -#include "los_cpup_pri.h" -#include "los_task_pri.h" -#include "los_memory_pri.h" - +#include "los_cpup.h" +#include "los_debug.h" #ifdef __cplusplus #if __cplusplus extern "C" { @@ -55,12 +51,23 @@ extern "C" { */ #define OS_THREAD_TYPE_HWI 1 +#define OS_CPUP_RECORD_PERIOD (g_sysClock) + LITE_OS_SEC_BSS UINT16 g_cpupInitFlg = 0; LITE_OS_SEC_BSS OsCpupCB *g_cpup = NULL; LITE_OS_SEC_BSS UINT64 g_lastRecordTime; LITE_OS_SEC_BSS UINT16 g_hisPos; /* taskID; g_cpup[taskID].cpupID = taskID; - g_cpup[taskID].startTime = OsGetCpuCycle(); + g_cpup[taskID].startTime = OsGetCurrentCyclesCount(); return; } @@ -139,7 +133,7 @@ LITE_OS_SEC_TEXT_MINOR VOID OsTskCycleEnd(VOID) return; } - cpuCycle = OsGetCpuCycle(); + cpuCycle = OsGetCurrentCyclesCount(); if (cpuCycle < g_cpup[taskID].startTime) { cpuCycle += g_cyclesPerTick; @@ -167,7 +161,7 @@ LITE_OS_SEC_TEXT_MINOR VOID OsTskCycleEndStart(VOID) } taskID = g_losTask.runTask->taskID; - cpuCycle = OsGetCpuCycle(); + cpuCycle = OsGetCurrentCyclesCount(); if (g_cpup[taskID].startTime != 0) { if (cpuCycle < g_cpup[taskID].startTime) { diff --git a/components/cpup/los_cpup.h b/components/cpup/los_cpup.h index 27826b89..16dc9d84 100755 --- a/components/cpup/los_cpup.h +++ b/components/cpup/los_cpup.h @@ -37,9 +37,7 @@ #ifndef _LOS_CPUP_H #define _LOS_CPUP_H -#include "los_hwi.h" -#include "los_base.h" -#include "los_sys.h" +#include "los_interrupt.h" #include "los_task.h" #ifdef __cplusplus @@ -123,181 +121,65 @@ extern "C" { /** * @ingroup los_cpup - * Count the CPU usage structures of all tasks. + * Number of historical running time records */ -typedef struct tagCpupInfo { - UINT16 usStatus; /**< save the cur task status */ - UINT32 uwUsage; /**< Usage. The value range is [0,1000]. */ -} CPUP_INFO_S; - -/** - * @ingroup los_monitor - * Type of the CPU usage query. - */ -typedef enum { - SYS_CPU_USAGE = 0, /* system cpu occupancy rate */ - TASK_CPU_USAGE, /* task cpu occupancy rate */ -} CPUP_TYPE_E; - -/** - * @ingroup los_monitor - * Mode of the CPU usage query. - */ -typedef enum { - CPUP_IN_10S = 0, /* cpu occupancy rate in 10s */ - CPUP_IN_1S, /* cpu occupancy rate in 1s */ - CPUP_LESS_THAN_1S, /* cpu occupancy rate less than 1s, if the input mode is none of them, it will be this. */ -} CPUP_MODE_E; +#define OS_CPUP_HISTORY_RECORD_NUM 10 /** * @ingroup los_cpup - * @brief Obtain the current CPU usage. + * Count the CPU usage structures of a task. + */ +typedef struct { + UINT32 cpupID; /**< Task ID */ + UINT16 status; /**< Task status */ + UINT64 allTime; /**< Total running time */ + UINT64 startTime; /**< Time before a task is invoked */ + UINT64 historyTime[OS_CPUP_HISTORY_RECORD_NUM]; /**< Historical running time */ +} OsCpupCB; + +extern OsCpupCB *g_cpup; + +/** + * @ingroup los_cpup + * @brief Initialization cpup. * * @par Description: - * This API is used to obtain the current CPU usage. + * This API is used to initialization cpup. * @attention * * * @param None. * - * @retval #OS_ERRNO_CPUP_NO_INIT 0x02001e02: The CPU usage is not initialized. - * @retval #cpup [0,100], current CPU usage, of which the precision is adjustable. + * @retval UINT32 Initialization result. * @par Dependency: * - * @see LOS_SysCpuUsage + * @see None. */ -extern UINT32 LOS_SysCpuUsage(VOID); +extern UINT32 OsCpupInit(VOID); /** * @ingroup los_cpup - * @brief Obtain the historical CPU usage. + * @brief Start task to get cycles count in current task ending. * * @par Description: - * This API is used to obtain the historical CPU usage. + * This API is used to start task to get cycles count in current task ending. * @attention * * - * @param mode [IN] UINT16. Task mode. The parameter value 0 indicates that the CPU usage within 10s will be - * obtained, and the parameter value 1 indicates that the CPU usage in the former 1s will be obtained. Other values - * indicate that the CPU usage in the period that is less than 1s will be obtained. + * @param None. * - * @retval #OS_ERRNO_CPUP_NO_INIT 0x02001e02: The CPU usage is not initialized. - * @retval #cpup [0,100], historical CPU usage, of which the precision is adjustable. + * @retval None. * @par Dependency: * - * @see LOS_HistoryTaskCpuUsage + * @see None. */ -extern UINT32 LOS_HistorySysCpuUsage(UINT16 mode); +extern VOID OsTskCycleEndStart(VOID); -/** - * @ingroup los_cpup - * @brief Obtain the CPU usage of a specified task. - * - * @par Description: - * This API is used to obtain the CPU usage of a task specified by a passed-in task ID. - * @attention - * - * - * @param taskID [IN] UINT32. Task ID. - * - * @retval #OS_ERRNO_CPUP_NO_INIT 0x02001e02: The CPU usage is not initialized. - * @retval #OS_ERRNO_CPUP_TSK_ID_INVALID 0x02001e05: The target task ID is invalid. - * @retval #OS_ERRNO_CPUP_THREAD_NO_CREATED 0x02001e04: The target thread is not created. - * @retval #cpup [0,100], CPU usage of the specified task. - * @par Dependency: - * - * @see LOS_HistoryTaskCpuUsage - */ -extern UINT32 LOS_TaskCpuUsage(UINT32 taskID); -/** - * @ingroup los_cpup - * @brief Obtain the historical CPU usage of a specified task. - * - * @par Description: - * This API is used to obtain the historical CPU usage of a task specified by a passed-in task ID. - * @attention - * - * - * @param taskID [IN] UINT32. Task ID. - * @param mode [IN] UINT16. Task mode. The parameter value 0 indicates that the CPU usage within 10s - * will be obtained, and the parameter value 1 indicates that the CPU usage in the former 1s will be obtained. - * Other values indicate that the CPU usage in the period that is less than 1s will be obtained. - * - * @retval #OS_ERRNO_CPUP_NO_INIT 0x02001e02: The CPU usage is not initialized. - * @retval #OS_ERRNO_CPUP_TSK_ID_INVALID 0x02001e05: The target task ID is invalid. - * @retval #OS_ERRNO_CPUP_THREAD_NO_CREATED 0x02001e04: The target thread is not created. - * @retval #cpup [0,100], CPU usage of the specified task. - * @par Dependency: - * - * @see LOS_HistorySysCpuUsage - */ -extern UINT32 LOS_HistoryTaskCpuUsage(UINT32 taskID, UINT16 mode); - -/** - * @ingroup los_cpup - * @brief Obtain the CPU usage of all tasks. - * - * @par Description: - * This API is used to obtain the CPU usage of all tasks according to maximum number of threads. - * @attention - * - * - * @param cpupInfo [OUT]Type. CPUP_INFO_S* Pointer to the task CPUP information structure to be obtained. - * @param mode [IN] UINT16. Task mode. The parameter value 0 indicates that the CPU usage within 10s - * will be obtained, and the parameter value 1 indicates that the CPU usage in the former 1s will be obtained. - * Other values indicate that the CPU usage in the period that is less than 1s will be obtained. - * - * @retval #OS_ERRNO_CPUP_NO_INIT 0x02001e02: The CPU usage is not initialized. - * @retval #OS_ERRNO_CPUP_TASK_PTR_NULL 0x02001e01: The input parameter pointer is NULL. - * @retval #LOS_OK 0x00000000: The CPU usage of all tasks is successfully obtained. - * @par Dependency: - * - * @see LOS_SysCpuUsage - */ -extern UINT32 LOS_AllTaskCpuUsage(CPUP_INFO_S *cpupInfo, UINT16 mode); - -/** - * @ingroup los_monitor - * @brief Obtain CPU usage history of certain task. - * - * @par Description: - * This API is used to obtain CPU usage history of certain task. - * @attention - * - * - * @param type [IN] cpup type, SYS_CPU_USAGE and TASK_CPU_USAGE - * @param mode [IN] mode,CPUP_IN_10S = usage in 10s,CPUP_IN_1S = usage in last 1s, - * CPUP_LESS_THAN_1S = less than 1s, if the inpuit mode is none of them, it will be as CPUP_LESS_THAN_1S. - * @param taskID [IN] task ID, Only in SYS_CPU_USAGE type, taskID is invalid - * - * @retval #OS_ERROR -1:CPU usage info obtain failed. - * @retval #LOS_OK 0:CPU usage info is successfully obtained. - * @par Dependency: - * - * @see LOS_CpupUsageMonitor - */ -extern UINT32 LOS_CpupUsageMonitor(CPUP_TYPE_E type, CPUP_MODE_E mode, UINT32 taskID); #ifdef __cplusplus #if __cplusplus diff --git a/components/cpup/los_cpup_pri.h b/components/cpup/los_cpup_pri.h deleted file mode 100755 index b25afe42..00000000 --- a/components/cpup/los_cpup_pri.h +++ /dev/null @@ -1,111 +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. - */ - -#ifndef _LOS_CPUP_PRI_H -#define _LOS_CPUP_PRI_H - -#include "los_cpup.h" -#include "los_tick_pri.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - - -/** - * @ingroup los_cpup - * Number of historical running time records - */ -#define OS_CPUP_HISTORY_RECORD_NUM 10 - -/** - * @ingroup los_cpup - * Count the CPU usage structures of a task. - */ -typedef struct { - UINT32 cpupID; /**< Task ID */ - UINT16 status; /**< Task status */ - UINT64 allTime; /**< Total running time */ - UINT64 startTime; /**< Time before a task is invoked */ - UINT64 historyTime[OS_CPUP_HISTORY_RECORD_NUM]; /**< Historical running time */ -} OsCpupCB; - -extern OsCpupCB *g_cpup; - -/** - * @ingroup los_cpup - * @brief Initialization cpup. - * - * @par Description: - * This API is used to initialization cpup. - * @attention - * - * - * @param None. - * - * @retval UINT32 Initialization result. - * @par Dependency: - * - * @see None. - */ -extern UINT32 OsCpupInit(VOID); - -/** - * @ingroup los_cpup - * @brief Start task to get cycles count in current task ending. - * - * @par Description: - * This API is used to start task to get cycles count in current task ending. - * @attention - * - * - * @param None. - * - * @retval None. - * @par Dependency: - * - * @see None. - */ -extern VOID OsTskCycleEndStart(VOID); - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_CPUP_PRI_H */ diff --git a/kal/BUILD.gn b/kal/BUILD.gn index 2ce702ec..6fbdf621 100755 --- a/kal/BUILD.gn +++ b/kal/BUILD.gn @@ -1,28 +1,11 @@ # Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. import("//build/lite/config/component/lite_component.gni") -static_library("kal") { - sources = [ "kal.c" ] +lite_component("kal") { + features = [ + "cmsis", + "posix", - include_dirs = [ - "//kernel/liteos_m/kal", - "//third_party/bounds_checking_function/include", + #"kal", # kal is not supported now. ] - - defines = [ "LITEOS_WIFI_IOT_VERSION" ] - - cflags = [ "-Werror" ] -} - -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/BUILD.gn b/kal/cmsis/BUILD.gn new file mode 100755 index 00000000..eea54fcb --- /dev/null +++ b/kal/cmsis/BUILD.gn @@ -0,0 +1,15 @@ +# 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_liteos.c b/kal/cmsis/cmsis_liteos.c similarity index 100% rename from kal/cmsis_liteos.c rename to kal/cmsis/cmsis_liteos.c diff --git a/kal/cmsis_liteos2.c b/kal/cmsis/cmsis_liteos2.c similarity index 100% rename from kal/cmsis_liteos2.c rename to kal/cmsis/cmsis_liteos2.c diff --git a/kal/cmsis_os.h b/kal/cmsis/cmsis_os.h similarity index 100% rename from kal/cmsis_os.h rename to kal/cmsis/cmsis_os.h diff --git a/kal/cmsis_os2.h b/kal/cmsis/cmsis_os2.h similarity index 93% rename from kal/cmsis_os2.h rename to kal/cmsis/cmsis_os2.h index b3857cda..d688ddf0 100755 --- a/kal/cmsis_os2.h +++ b/kal/cmsis/cmsis_os2.h @@ -511,17 +511,17 @@ typedef struct { /** Size of the memory for the semaphore control block */ uint32_t cb_size; } osSemaphoreAttr_t; - + typedef struct { const char *name; uint32_t attr_bits; - void *cb_mem; + void *cb_mem; uint32_t cb_size; - void *mp_mem; + void *mp_mem; uint32_t mp_size; } osMemoryPoolAttr_t; - + /** * @brief Describes message queue attributes. * @@ -542,10 +542,10 @@ typedef struct { /** Size of the memory for storing data in the message queue */ uint32_t mq_size; } osMessageQueueAttr_t; - - + + // ==== Kernel Management Functions ==== - + /** * @brief Initializes the RTOS kernel. * @@ -554,7 +554,7 @@ typedef struct { * @version 1.0 */ osStatus_t osKernelInitialize (void); - + /** * @brief Obtains the system version and name. * @@ -566,7 +566,7 @@ osStatus_t osKernelInitialize (void); * @version 1.0 */ osStatus_t osKernelGetInfo (osVersion_t *version, char *id_buf, uint32_t id_size); - + /** * @brief Obtains the kernel state. * @@ -575,7 +575,7 @@ osStatus_t osKernelGetInfo (osVersion_t *version, char *id_buf, uint32_t id_size * @version 1.0 */ osKernelState_t osKernelGetState (void); - + /** * @brief Starts the kernel. * @@ -584,7 +584,7 @@ osKernelState_t osKernelGetState (void); * @version 1.0 */ osStatus_t osKernelStart (void); - + /** * @brief Locks the kernel. * @@ -593,7 +593,7 @@ osStatus_t osKernelStart (void); * @version 1.0 */ int32_t osKernelLock (void); - + /** * @brief Unlocks the kernel. * @@ -602,7 +602,7 @@ int32_t osKernelLock (void); * @version 1.0 */ int32_t osKernelUnlock (void); - + /** * @brief Restores the previous lock state of the kernel. * @@ -612,15 +612,15 @@ int32_t osKernelUnlock (void); * @version 1.0 */ int32_t osKernelRestoreLock (int32_t lock); - + uint32_t osKernelSuspend (void); - + void osKernelResume (uint32_t sleep_ticks); /// Get the RTOS kernel tick count. /// \return RTOS kernel current tick count. uint32_t osKernelGetTickCount (void); - + /** @@ -631,7 +631,7 @@ uint32_t osKernelGetTickCount (void); * @version 1.0 */ uint32_t osKernelGetTickFreq (void); - + /** * @brief Obtains the kernel system timer. * @@ -640,7 +640,7 @@ uint32_t osKernelGetTickFreq (void); * @version 1.0 */ uint32_t osKernelGetSysTimerCount (void); - + /** * @brief Obtains the frequency of the system timer. * @@ -649,13 +649,15 @@ uint32_t osKernelGetSysTimerCount (void); * @version 1.0 */ uint32_t osKernelGetSysTimerFreq (void); - - + + // ==== Thread Management Functions ==== - + /** * @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). * @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. @@ -664,7 +666,7 @@ uint32_t osKernelGetSysTimerFreq (void); * @version 1.0 */ osThreadId_t osThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr); - + /** * @brief Obtains the name of a thread. * @@ -674,7 +676,7 @@ osThreadId_t osThreadNew (osThreadFunc_t func, void *argument, const osThreadAtt * @version 1.0 */ const char *osThreadGetName (osThreadId_t thread_id); - + /** * @brief Obtains the ID of the currently running thread. * @@ -683,7 +685,7 @@ const char *osThreadGetName (osThreadId_t thread_id); * @version 1.0 */ osThreadId_t osThreadGetId (void); - + /** * @brief Obtains the state of a thread. @@ -694,7 +696,7 @@ osThreadId_t osThreadGetId (void); * @version 1.0 */ osThreadState_t osThreadGetState (osThreadId_t thread_id); - + /** * @brief Obtains the stack size of a thread. * @@ -704,7 +706,7 @@ osThreadState_t osThreadGetState (osThreadId_t thread_id); * @version 1.0 */ uint32_t osThreadGetStackSize (osThreadId_t thread_id); - + /** * @brief Obtains the size of the available stack space for a thread based on the stack watermark. * @@ -714,7 +716,7 @@ uint32_t osThreadGetStackSize (osThreadId_t thread_id); * @version 1.0 */ uint32_t osThreadGetStackSpace (osThreadId_t thread_id); - + /** * @brief Changes the priority of a thread. * @@ -735,7 +737,7 @@ osStatus_t osThreadSetPriority (osThreadId_t thread_id, osPriority_t priority); * @version 1.0 */ osPriority_t osThreadGetPriority (osThreadId_t thread_id); - + /** * @brief Sets the currently running thread to the ready state. * @@ -744,7 +746,7 @@ osPriority_t osThreadGetPriority (osThreadId_t thread_id); * @version 1.0 */ osStatus_t osThreadYield (void); - + /** * @brief Suspends a thread. * @@ -754,7 +756,7 @@ osStatus_t osThreadYield (void); * @version 1.0 */ osStatus_t osThreadSuspend (osThreadId_t thread_id); - + /** * @brief Resumes a thread from the suspended state. * @@ -764,13 +766,13 @@ osStatus_t osThreadSuspend (osThreadId_t thread_id); * @version 1.0 */ osStatus_t osThreadResume (osThreadId_t thread_id); - + osStatus_t osThreadDetach (osThreadId_t thread_id); - + osStatus_t osThreadJoin (osThreadId_t thread_id); - + void osThreadExit (void); - + /** * @brief Terminates a thread. * @@ -780,7 +782,7 @@ void osThreadExit (void); * @version 1.0 */ osStatus_t osThreadTerminate (osThreadId_t thread_id); - + /** * @brief Obtains the number of active threads. * @@ -789,23 +791,23 @@ osStatus_t osThreadTerminate (osThreadId_t thread_id); * @version 1.0 */ uint32_t osThreadGetCount (void); - + uint32_t osThreadEnumerate (osThreadId_t *thread_array, uint32_t array_items); - - + + // ==== Thread Flags Functions ==== - + uint32_t osThreadFlagsSet (osThreadId_t thread_id, uint32_t flags); - + uint32_t osThreadFlagsClear (uint32_t flags); - + uint32_t osThreadFlagsGet (void); - + uint32_t osThreadFlagsWait (uint32_t flags, uint32_t options, uint32_t timeout); - - + + // ==== Generic Wait Functions ==== - + /** * @brief Waits for a period of time. * @@ -815,23 +817,26 @@ uint32_t osThreadFlagsWait (uint32_t flags, uint32_t options, uint32_t timeout); * @version 1.0 */ osStatus_t osDelay (uint32_t ticks); - + /** * @brief Waits until a specified time arrives. * +* This function handles the overflow of the system timer. Note that the maximum value of this parameter is (2^31 - 1) ticks. * @param ticks Indicates the number of ticks converted from the absolute time. * @return Returns the CMSIS-RTOS running result. * @since 1.0 * @version 1.0 */ osStatus_t osDelayUntil (uint32_t ticks); - - + + // ==== Timer Management Functions ==== - + /** * @brief Creates and initializes a timer. * +* This function creates a timer associated with the arguments callback function. The timer stays in the stopped state until OSTimerStart is used to start the timer. +* The timer precision is 1000 / LOSCFG_BASE_CORE_TICK_PER_SECOND ms(LOSCFG_BASE_CORE_TICK_PER_SECOND is defined in the traget_config.h). * @param func Indicates the entry of the timer callback function. * @param type Indicates the timer type. * @param argument Indicates the pointer to the argument used in timer callback. @@ -841,7 +846,7 @@ osStatus_t osDelayUntil (uint32_t ticks); * @version 1.0 */ osTimerId_t osTimerNew (osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr); - + /** * @brief Obtains the timer name. * @@ -851,7 +856,7 @@ osTimerId_t osTimerNew (osTimerFunc_t func, osTimerType_t type, void *argument, * @version 1.0 */ const char *osTimerGetName (osTimerId_t timer_id); - + /** * @brief Starts or restarts a timer. * @@ -862,7 +867,7 @@ const char *osTimerGetName (osTimerId_t timer_id); * @version 1.0 */ osStatus_t osTimerStart (osTimerId_t timer_id, uint32_t ticks); - + /** * @brief Stops a timer. * @@ -872,7 +877,7 @@ osStatus_t osTimerStart (osTimerId_t timer_id, uint32_t ticks); * @version 1.0 */ osStatus_t osTimerStop (osTimerId_t timer_id); - + /** * @brief Checks whether a timer is running. * @@ -882,7 +887,7 @@ osStatus_t osTimerStop (osTimerId_t timer_id); * @version 1.0 */ uint32_t osTimerIsRunning (osTimerId_t timer_id); - + /** * @brief Deletes a timer. * @@ -892,10 +897,10 @@ uint32_t osTimerIsRunning (osTimerId_t timer_id); * @version 1.0 */ osStatus_t osTimerDelete (osTimerId_t timer_id); - - + + // ==== Event Flags Management Functions ==== - + /** * @brief Creates and initializes an event flags object. * @@ -905,7 +910,7 @@ osStatus_t osTimerDelete (osTimerId_t timer_id); * @version 1.0 */ osEventFlagsId_t osEventFlagsNew (const osEventFlagsAttr_t *attr); - + /** * @brief Obtains the name of an event flags object. * @@ -915,7 +920,7 @@ osEventFlagsId_t osEventFlagsNew (const osEventFlagsAttr_t *attr); * @version 1.0 */ const char *osEventFlagsGetName (osEventFlagsId_t ef_id); - + /** * @brief Sets event flags. * @@ -926,7 +931,7 @@ const char *osEventFlagsGetName (osEventFlagsId_t ef_id); * @version 1.0 */ uint32_t osEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags); - + /** * @brief Clears event flags. * @@ -937,7 +942,7 @@ uint32_t osEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags); * @version 1.0 */ uint32_t osEventFlagsClear (osEventFlagsId_t ef_id, uint32_t flags); - + /** * @brief Obtains event flags. * @@ -947,10 +952,11 @@ uint32_t osEventFlagsClear (osEventFlagsId_t ef_id, uint32_t flags); * @version 1.0 */ 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. * @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. @@ -960,7 +966,7 @@ uint32_t osEventFlagsGet (osEventFlagsId_t ef_id); * @version 1.0 */ uint32_t osEventFlagsWait (osEventFlagsId_t ef_id, uint32_t flags, uint32_t options, uint32_t timeout); - + /** * @brief Deletes an event flags object. * @@ -970,10 +976,10 @@ uint32_t osEventFlagsWait (osEventFlagsId_t ef_id, uint32_t flags, uint32_t opti * @version 1.0 */ osStatus_t osEventFlagsDelete (osEventFlagsId_t ef_id); - - + + // ==== Mutex Management Functions ==== - + /** * @brief Creates and initializes a mutex. * @@ -983,9 +989,9 @@ osStatus_t osEventFlagsDelete (osEventFlagsId_t ef_id); * @version 1.0 */ osMutexId_t osMutexNew (const osMutexAttr_t *attr); - + const char *osMutexGetName (osMutexId_t mutex_id); - + /** * @brief Obtains a mutex. * @@ -996,7 +1002,7 @@ const char *osMutexGetName (osMutexId_t mutex_id); * @version 1.0 */ osStatus_t osMutexAcquire (osMutexId_t mutex_id, uint32_t timeout); - + /** * @brief Releases a mutex. * @@ -1006,7 +1012,7 @@ osStatus_t osMutexAcquire (osMutexId_t mutex_id, uint32_t timeout); * @version 1.0 */ osStatus_t osMutexRelease (osMutexId_t mutex_id); - + /** * @brief Obtains the thread ID of the currently acquired mutex. * @@ -1016,7 +1022,7 @@ osStatus_t osMutexRelease (osMutexId_t mutex_id); * @version 1.0 */ osThreadId_t osMutexGetOwner (osMutexId_t mutex_id); - + /** * @brief Deletes a mutex. * @@ -1026,10 +1032,10 @@ osThreadId_t osMutexGetOwner (osMutexId_t mutex_id); * @version 1.0 */ osStatus_t osMutexDelete (osMutexId_t mutex_id); - - + + // ==== Semaphore Management Functions ==== - + /** * @brief Creates and initializes a semaphore object. * @@ -1041,20 +1047,20 @@ osStatus_t osMutexDelete (osMutexId_t mutex_id); * @version 1.0 */ osSemaphoreId_t osSemaphoreNew (uint32_t max_count, uint32_t initial_count, const osSemaphoreAttr_t *attr); - + 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. +* @param timeout Indicates the timeout duration. This parameter is the number of ticks. * @return Returns the CMSIS-RTOS running result. * @since 1.0 * @version 1.0 */ osStatus_t osSemaphoreAcquire (osSemaphoreId_t semaphore_id, uint32_t timeout); - + /** * @brief Releases a token of a semaphore object. * @@ -1064,7 +1070,7 @@ osStatus_t osSemaphoreAcquire (osSemaphoreId_t semaphore_id, uint32_t timeout); * @version 1.0 */ osStatus_t osSemaphoreRelease (osSemaphoreId_t semaphore_id); - + /** * @brief Obtains the number of available tokens of a semaphore object. * @@ -1074,7 +1080,7 @@ osStatus_t osSemaphoreRelease (osSemaphoreId_t semaphore_id); * @version 1.0 */ uint32_t osSemaphoreGetCount (osSemaphoreId_t semaphore_id); - + /** * @brief Deletes a semaphore object. * @@ -1084,31 +1090,31 @@ uint32_t osSemaphoreGetCount (osSemaphoreId_t semaphore_id); * @version 1.0 */ osStatus_t osSemaphoreDelete (osSemaphoreId_t semaphore_id); - - + + // ==== Memory Pool Management Functions ==== - + osMemoryPoolId_t osMemoryPoolNew (uint32_t block_count, uint32_t block_size, const osMemoryPoolAttr_t *attr); - + const char *osMemoryPoolGetName (osMemoryPoolId_t mp_id); - + void *osMemoryPoolAlloc (osMemoryPoolId_t mp_id, uint32_t timeout); - + osStatus_t osMemoryPoolFree (osMemoryPoolId_t mp_id, void *block); - + uint32_t osMemoryPoolGetCapacity (osMemoryPoolId_t mp_id); - + uint32_t osMemoryPoolGetBlockSize (osMemoryPoolId_t mp_id); - + uint32_t osMemoryPoolGetCount (osMemoryPoolId_t mp_id); - + uint32_t osMemoryPoolGetSpace (osMemoryPoolId_t mp_id); - + osStatus_t osMemoryPoolDelete (osMemoryPoolId_t mp_id); - - + + // ==== Message Queue Management Functions ==== - + /** * @brief Creates and initializes a message queue. * @@ -1120,35 +1126,35 @@ osStatus_t osMemoryPoolDelete (osMemoryPoolId_t mp_id); * @version 1.0 */ osMessageQueueId_t osMessageQueueNew (uint32_t msg_count, uint32_t msg_size, const osMessageQueueAttr_t *attr); - + const char *osMessageQueueGetName (osMessageQueueId_t mq_id); - + /** * @brief Places a message in a message queue. * * @param mq_id Indicates the message queue ID, which is obtained using osMessageQueueNew. * @param msg_ptr Indicates the pointer to the buffer for storing the message to be placed in the message queue. -* @param msg_prio Indicates the priority of the message to be placed in the message queue. +* @param msg_prio Indicates the priority of the message to be placed in the message queue. This parameter is not used. * @param timeout Indicates the timeout duration. * @return Returns the CMSIS-RTOS running result. * @since 1.0 * @version 1.0 */ osStatus_t osMessageQueuePut (osMessageQueueId_t mq_id, const void *msg_ptr, uint8_t msg_prio, uint32_t timeout); - + /** * @brief Obtains a message in a message queue. * * @param mq_id Indicates the message queue ID, which is obtained using osMessageQueueNew. * @param msg_ptr Indicates the pointer to the buffer for storing the message to be retrieved from the message queue. -* @param msg_prio Indicates the pointer to the buffer for storing the priority of the message to be retrieved from the message queue. This parameter can be set to NULL. +* @param msg_prio Indicates the pointer to the buffer for storing the priority of the message to be retrieved from the message queue. This parameter is not used. * @param timeout Indicates the timeout duration. * @return Returns the CMSIS-RTOS running result. * @since 1.0 * @version 1.0 */ osStatus_t osMessageQueueGet (osMessageQueueId_t mq_id, void *msg_ptr, uint8_t *msg_prio, uint32_t timeout); - + /** * @brief Obtains the maximum number of messages that can be placed in a message queue. * @@ -1158,7 +1164,7 @@ osStatus_t osMessageQueueGet (osMessageQueueId_t mq_id, void *msg_ptr, uint8_t * * @version 1.0 */ uint32_t osMessageQueueGetCapacity (osMessageQueueId_t mq_id); - + /** * @brief Obtains the maximum size of messages that can be placed in a message queue. * @@ -1168,7 +1174,7 @@ uint32_t osMessageQueueGetCapacity (osMessageQueueId_t mq_id); * @version 1.0 */ uint32_t osMessageQueueGetMsgSize (osMessageQueueId_t mq_id); - + /** * @brief Obtains the number of queued messages in a message queue. * @@ -1178,7 +1184,7 @@ uint32_t osMessageQueueGetMsgSize (osMessageQueueId_t mq_id); * @version 1.0 */ uint32_t osMessageQueueGetCount (osMessageQueueId_t mq_id); - + /** * @brief Obtains the number of available slots for messages in a message queue. * @@ -1188,9 +1194,9 @@ uint32_t osMessageQueueGetCount (osMessageQueueId_t mq_id); * @version 1.0 */ uint32_t osMessageQueueGetSpace (osMessageQueueId_t mq_id); - + osStatus_t osMessageQueueReset (osMessageQueueId_t mq_id); - + /** * @brief Deletes a message queue. * @@ -1200,10 +1206,10 @@ osStatus_t osMessageQueueReset (osMessageQueueId_t mq_id); * @version 1.0 */ osStatus_t osMessageQueueDelete (osMessageQueueId_t mq_id); - - + + #ifdef __cplusplus } #endif - + #endif // CMSIS_OS2_H_ diff --git a/kal/hos_cmsis_adp.h b/kal/cmsis/hos_cmsis_adp.h similarity index 98% rename from kal/hos_cmsis_adp.h rename to kal/cmsis/hos_cmsis_adp.h index ccbb109b..b576b686 100755 --- a/kal/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 "hos_types.h" +#include "ohos_types.h" #ifdef __cplusplus #if __cplusplus diff --git a/kal/kal/BUILD.gn b/kal/kal/BUILD.gn new file mode 100755 index 00000000..91ae225c --- /dev/null +++ b/kal/kal/BUILD.gn @@ -0,0 +1,15 @@ +# 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.c b/kal/kal/kal.c similarity index 100% rename from kal/kal.c rename to kal/kal/kal.c diff --git a/kal/kal.h b/kal/kal/kal.h similarity index 100% rename from kal/kal.h rename to kal/kal/kal.h diff --git a/kal/posix/BUILD.gn b/kal/posix/BUILD.gn new file mode 100755 index 00000000..96a63523 --- /dev/null +++ b/kal/posix/BUILD.gn @@ -0,0 +1,20 @@ +# 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 new file mode 100755 index 00000000..49d4d90b --- /dev/null +++ b/kal/posix/include/README @@ -0,0 +1,12 @@ +Root directory "//" refers to "/vendor/hisi/hi3861/hi3861". +We use header files from musl ("//platform/os/Huawei_LiteOS/components/lib/libc/musl/include"). + +Some posix apis are already defined in different places: +errno is defined in //build/libs/libc_base.o +malloc and free are defined in //build/libs/libc_base.o +pthread_mutex_* are defined in //build/libs/hi3861/release/no_mesh/liblitekernel_flash.a +semaphore is defined in //build/libs/hi3861/release/no_mesh/liblitekernel_flash.a +usleep is defined in //build/libs/hi3861/release/no_mesh/liblitekernel_flash.a +clock_* are defined in //build/libs/liblitekernel_base.o +printf is defined in //build/libs/liblitekernel_base.o +fcntl and socket apis are defined in //build/libs/liblwip.a diff --git a/kernel/arch/risc-v/rvm32/include/los_hw_tick_pri.h b/kal/posix/include/version.h old mode 100644 new mode 100755 similarity index 81% rename from kernel/arch/risc-v/rvm32/include/los_hw_tick_pri.h rename to kal/posix/include/version.h index a0f4f89c..0394ff96 --- a/kernel/arch/risc-v/rvm32/include/los_hw_tick_pri.h +++ b/kal/posix/include/version.h @@ -1,53 +1,46 @@ -/* - * 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_HW_TICK_PRI_H -#define _LOS_HW_TICK_PRI_H - -#include "los_typedef.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#define TICK_INTERRUPT_PRI 0x1 - -extern UINT32 g_cyclesPerTick; - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_HW_TICK_PRI_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 VERSION_H_ +#define VERSION_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +const char *libc_get_version_string(void); +int libc_get_version(void); + +#ifdef __cplusplus +} +#endif + +#endif // VERSION_H_ diff --git a/kernel/src/los_misc.c b/kal/posix/src/file.c similarity index 55% rename from kernel/src/los_misc.c rename to kal/posix/src/file.c index 8e53ac5d..fc604a94 100755 --- a/kernel/src/los_misc.c +++ b/kal/posix/src/file.c @@ -1,64 +1,93 @@ -/* - * 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_base_pri.h" -#include "los_sys_pri.h" -#include "los_task_pri.h" -#include "los_hwi.h" - -LITE_OS_SEC_TEXT UINT32 LOS_Align(UINT32 addr, UINT32 boundary) -{ - if ((addr + (boundary - 1)) > addr) { - return (addr + (boundary - 1)) & ~(boundary - 1); - } else { - return addr & ~(boundary - 1); - } -} - -LITE_OS_SEC_TEXT_MINOR VOID LOS_Msleep(UINT32 mSecs) -{ - UINT32 interval; - - if (OS_INT_ACTIVE) { - return; - } - - if (mSecs == 0) { - interval = 0; - } else { - interval = LOS_MS2Tick(mSecs); - if (interval == 0) { - interval = 1; - } - } - - (VOID)LOS_TaskDelay(interval); -} +/* + * 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 +#include +#include +#include +#include "lwip/sockets.h" +#include "hks_client.h" + +#define RANDOM_DEV_FD LWIP_CONFIG_NUM_SOCKETS +#define RANDOM_DEV_PATH "/dev/random" + +int open(const char *file, int oflag, ...) +{ + if (strcmp(file, RANDOM_DEV_PATH) == 0) { + if (oflag != O_RDONLY) { + errno = EINVAL; + return -1; + } + return RANDOM_DEV_FD; + } + errno = ENOENT; + return -1; +} + +int close(int fd) +{ + if (fd == RANDOM_DEV_FD) { + return 0; + } + return closesocket(fd); +} + +ssize_t read(int fd, void *buf, size_t nbytes) +{ + if (fd == RANDOM_DEV_FD) { + if (nbytes == 0) { + return 0; + } + if (buf == NULL) { + errno = EINVAL; + return -1; + } + if (nbytes > 1024) { + nbytes = 1024; /* hks_generate_random: random_size must <= 1024 */ + } + struct hks_blob key = {HKS_BLOB_TYPE_RAW, (uint8_t *)buf, nbytes}; + if (hks_generate_random(&key) != 0) { + errno = EIO; + return -1; + } + return (ssize_t)nbytes; + } + return recv(fd, buf, nbytes, 0); +} + +ssize_t write(int fd, const void *buf, size_t nbytes) +{ + if (fd == RANDOM_DEV_FD) { + errno = EBADF; /* "/dev/random" is readonly */ + return -1; + } + return send(fd, buf, nbytes, 0); +} diff --git a/kal/posix/src/pthread.c b/kal/posix/src/pthread.c new file mode 100755 index 00000000..4f690fb8 --- /dev/null +++ b/kal/posix/src/pthread.c @@ -0,0 +1,237 @@ +/* + * 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 +#include +#include +#include +#include "los_task.h" +#include "los_task_pri.h" + +#define PTHREAD_NAMELEN 16 + +/* this is just an assertion: LOS_TASK_ARG_NUM >= 4 */ +typedef char NULNAM[-!((LOS_TASK_ARG_NUM * 4) >= PTHREAD_NAMELEN)]; + +static void *_pthread_entry(UINT32 param1, UINT32 param2, UINT32 param3, UINT32 param4) +{ + void *(*startRoutine)(void *) = (void *)(UINTPTR)param1; + void *param = (void *)(UINTPTR)param2; + (void)param3; + (void)param4; + int ret; + + LosTaskCB *tcb = OS_TCB_FROM_TID(LOS_CurTaskIDGet()); + char *tmp = tcb->taskName; + tcb->taskName = (char *)tcb->args; /* args are reused as task name */ + ret = strcpy_s(tcb->taskName, PTHREAD_NAMELEN, tmp); + if (ret != 0) { + free(tmp); + return NULL; + } + free(tmp); + + return startRoutine(param); +} + +int pthread_create(pthread_t *thread, const pthread_attr_t *attr, + void *(*startRoutine)(void *), void *arg) +{ + TSK_INIT_PARAM_S taskInitParam = {0}; + UINT32 taskID; + + if ((thread == NULL) || (startRoutine == NULL)) { + return EINVAL; + } + + if (attr) { + if (attr->detachstate == PTHREAD_CREATE_DETACHED) { + return ENOTSUP; + } + 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); + if (taskInitParam.pcName == NULL) { + return ENOMEM; + } + + taskInitParam.pfnTaskEntry = _pthread_entry; + taskInitParam.auwArgs[0] = (UINT32)(UINTPTR)startRoutine; + taskInitParam.auwArgs[1] = (UINT32)(UINTPTR)arg; + + if (LOS_TaskCreate(&taskID, &taskInitParam) != LOS_OK) { + free(taskInitParam.pcName); + return EINVAL; + } + + /* set pthread default name */ + (void)sprintf_s(taskInitParam.pcName, PTHREAD_NAMELEN, "pthread%u", taskID); + + *thread = (pthread_t)taskID; + return ENOERR; +} + +int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param *param) +{ + if ((param == NULL) || (param->sched_priority > OS_TASK_PRIORITY_LOWEST)) { + return EINVAL; + } + + /* Only support SCHED_RR policy now */ + if (policy != SCHED_RR) { + return ENOTSUP; + } + + if (LOS_TaskPriSet((UINT32)thread, (UINT16)param->sched_priority) != LOS_OK) { + return EINVAL; + } + + return ENOERR; +} + +int pthread_getschedparam(pthread_t thread, int *policy, struct sched_param *param) +{ + UINT32 prio; + + if ((policy == NULL) || (param == NULL)) { + return EINVAL; + } + + prio = LOS_TaskPriGet((UINT32)thread); + if (prio == OS_INVALID) { + return EINVAL; + } + + *policy = SCHED_RR; + param->sched_priority = prio; + return ENOERR; +} + +pthread_t pthread_self(void) +{ + return (pthread_t)LOS_CurTaskIDGet(); +} + +int pthread_cancel(pthread_t thread) +{ + (void)thread; + return ENOSYS; +} + +static void *void_task(UINT32 param1, UINT32 param2, UINT32 param3, UINT32 param4) +{ + (void)param1; + (void)param2; + (void)param3; + (void)param4; + return 0; +} + +static void cleanup_task_resource(void) +{ + TSK_INIT_PARAM_S taskInitParam = {0}; + UINT32 taskID; + + taskInitParam.pcName = "void"; + taskInitParam.pfnTaskEntry = void_task; + taskInitParam.usTaskPrio = LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO; + taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_MIN_STACK_SIZE; + + (void)LOS_TaskCreate(&taskID, &taskInitParam); +} + +int pthread_join(pthread_t thread, void **retval) +{ + UINT32 taskStatus; + + if (retval) { + /* retrieve thread exit code is not supported currently */ + return ENOTSUP; + } + + if (thread == pthread_self()) { + return EDEADLK; + } + + while (LOS_TaskStatusGet((UINT32)thread, &taskStatus) == LOS_OK) { + usleep(10000); + } + + cleanup_task_resource(); + return 0; +} + +int pthread_detach(pthread_t thread) +{ + (void)thread; + return ENOSYS; +} + +void pthread_exit(void *retVal) +{ + (void)retVal; + (void)LOS_TaskDelete(LOS_CurTaskIDGet()); +} + +int pthread_setname_np(pthread_t thread, const char *name) +{ + char *taskName = LOS_TaskNameGet((UINT32)thread); + if (taskName == NULL) { + return EINVAL; + } + if (strnlen(name, PTHREAD_NAMELEN) >= PTHREAD_NAMELEN) { + return ERANGE; + } + (void)strcpy_s(taskName, PTHREAD_NAMELEN, name); + return 0; +} + +int pthread_getname_np(pthread_t thread, char *buf, size_t buflen) +{ + int ret; + + const char *name = LOS_TaskNameGet((UINT32)thread); + if (name == NULL) { + return EINVAL; + } + if (buflen > strlen(name)) { + ret = strcpy_s(buf, buflen, name); + if (ret == 0) { + return 0; + } + } + return ERANGE; +} diff --git a/kal/posix/src/pthread_attr.c b/kal/posix/src/pthread_attr.c new file mode 100755 index 00000000..7ba709c1 --- /dev/null +++ b/kal/posix/src/pthread_attr.c @@ -0,0 +1,233 @@ +/* + * 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 +#include + +#define PTHREAD_STACK_MIN LOSCFG_BASE_CORE_TSK_MIN_STACK_SIZE + + +int pthread_attr_init(pthread_attr_t *attr) +{ + if (attr == NULL) { + return EINVAL; + } + + attr->detachstate = PTHREAD_CREATE_JOINABLE; + attr->schedpolicy = SCHED_RR; + attr->schedparam.sched_priority = LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO; + attr->inheritsched = PTHREAD_INHERIT_SCHED; + attr->scope = PTHREAD_SCOPE_PROCESS; + attr->stackaddr_set = 0; + attr->stackaddr = NULL; + attr->stacksize_set = 1; + attr->stacksize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE; + + return ENOERR; +} + +int pthread_attr_destroy(pthread_attr_t *attr) +{ + if (attr == NULL) { + return EINVAL; + } + + /* Nothing to do here... */ + return ENOERR; +} + +int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachState) +{ + if ((attr != NULL) && ((detachState == PTHREAD_CREATE_JOINABLE) || (detachState == PTHREAD_CREATE_DETACHED))) { + attr->detachstate = (UINT32)detachState; + return ENOERR; + } + + return EINVAL; +} + +int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachState) +{ + if ((attr == NULL) || (detachState == NULL)) { + return EINVAL; + } + + *detachState = (int)attr->detachstate; + + return ENOERR; +} + +int pthread_attr_setscope(pthread_attr_t *attr, int scope) +{ + if (attr == NULL) { + return EINVAL; + } + + if (scope == PTHREAD_SCOPE_PROCESS) { + attr->scope = (unsigned int)scope; + return ENOERR; + } + + if (scope == PTHREAD_SCOPE_SYSTEM) { + return ENOTSUP; + } + + return EINVAL; +} + +int pthread_attr_getscope(const pthread_attr_t *attr, int *scope) +{ + if ((attr == NULL) || (scope == NULL)) { + return EINVAL; + } + + *scope = (int)attr->scope; + + return ENOERR; +} + +int pthread_attr_setinheritsched(pthread_attr_t *attr, int inherit) +{ + if ((attr != NULL) && ((inherit == PTHREAD_INHERIT_SCHED) || (inherit == PTHREAD_EXPLICIT_SCHED))) { + attr->inheritsched = (UINT32)inherit; + return ENOERR; + } + + return EINVAL; +} + +int pthread_attr_getinheritsched(const pthread_attr_t *attr, int *inherit) +{ + if ((attr == NULL) || (inherit == NULL)) { + return EINVAL; + } + + *inherit = (int)attr->inheritsched; + + return ENOERR; +} + +int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy) +{ + if ((attr != NULL) && (policy == SCHED_RR)) { + attr->schedpolicy = SCHED_RR; + return ENOERR; + } + + return EINVAL; +} + +int pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy) +{ + if ((attr == NULL) || (policy == NULL)) { + return EINVAL; + } + + *policy = (int)attr->schedpolicy; + + return ENOERR; +} + +int pthread_attr_setschedparam(pthread_attr_t *attr, const struct sched_param *param) +{ + if ((attr == NULL) || (param == NULL)) { + return EINVAL; + } else if ((param->sched_priority < 0) || (param->sched_priority > OS_TASK_PRIORITY_LOWEST)) { + return ENOTSUP; + } + + attr->schedparam = *param; + + return ENOERR; +} + +int pthread_attr_getschedparam(const pthread_attr_t *attr, struct sched_param *param) +{ + if ((attr == NULL) || (param == NULL)) { + return EINVAL; + } + + *param = attr->schedparam; + + return ENOERR; +} + +/* + * Set starting address of stack. Whether this is at the start or end of + * the memory block allocated for the stack depends on whether the stack + * grows up or down. + */ +int pthread_attr_setstackaddr(pthread_attr_t *attr, void *stackAddr) +{ + if (attr == NULL) { + return EINVAL; + } + + attr->stackaddr_set = 1; + attr->stackaddr = stackAddr; + + return ENOERR; +} + +int pthread_attr_getstackaddr(const pthread_attr_t *attr, void **stackAddr) +{ + if (((attr != NULL) && (stackAddr != NULL)) && attr->stackaddr_set) { + *stackAddr = attr->stackaddr; + return ENOERR; + } + + return EINVAL; /* Stack address not set, return EINVAL. */ +} + +int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stackSize) +{ + /* Reject inadequate stack sizes */ + if ((attr == NULL) || (stackSize < PTHREAD_STACK_MIN)) { + return EINVAL; + } + + attr->stacksize_set = 1; + attr->stacksize = stackSize; + + return ENOERR; +} + +int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stackSize) +{ + /* Reject attempts to get a stack size when one has not been set. */ + if ((attr == NULL) || (stackSize == NULL) || (!attr->stacksize_set)) { + return EINVAL; + } + + *stackSize = attr->stacksize; + + return ENOERR; +} diff --git a/kal/posix/src/time.c b/kal/posix/src/time.c new file mode 100755 index 00000000..dcdb598d --- /dev/null +++ b/kal/posix/src/time.c @@ -0,0 +1,254 @@ +/* + * 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 +#include +#include +#include +#include +#include + +#ifndef STATIC +#define STATIC static +#endif + +#define OS_SYS_NS_PER_US 1000 +#define OS_SYS_NS_PER_SECOND 1000000000 +#define OS_SYS_US_PER_SECOND 1000000 +#define OS_SYS_MS_PER_SECOND 1000 + +STATIC INLINE BOOL ValidTimerID(UINT16 swtmrID) +{ + /* check timer id */ + return (swtmrID < LOSCFG_BASE_CORE_SWTMR_LIMIT); +} + +/* internal functions */ +STATIC INLINE BOOL ValidTimeSpec(const struct timespec *tp) +{ + /* Fail a NULL pointer */ + if (tp == NULL) { + return FALSE; + } + + /* Fail illegal nanosecond values */ + if ((tp->tv_nsec < 0) || (tp->tv_nsec >= OS_SYS_NS_PER_SECOND) || (tp->tv_sec < 0)) { + return FALSE; + } + + return TRUE; +} + +STATIC INLINE UINT32 OsTimeSpec2Tick(const struct timespec *tp) +{ + UINT64 tick, ns; + + ns = (UINT64)tp->tv_sec * OS_SYS_NS_PER_SECOND + tp->tv_nsec; + /* Round up for ticks */ + tick = (ns * LOSCFG_BASE_CORE_TICK_PER_SECOND + (OS_SYS_NS_PER_SECOND - 1)) / OS_SYS_NS_PER_SECOND; + if (tick > LOS_WAIT_FOREVER) { + tick = LOS_WAIT_FOREVER; + } + return (UINT32)tick; +} + +STATIC INLINE VOID OsTick2TimeSpec(struct timespec *tp, UINT32 tick) +{ + UINT64 ns = ((UINT64)tick * OS_SYS_NS_PER_SECOND) / LOSCFG_BASE_CORE_TICK_PER_SECOND; + tp->tv_sec = (time_t)(ns / OS_SYS_NS_PER_SECOND); + tp->tv_nsec = (long)(ns % OS_SYS_NS_PER_SECOND); +} + +int nanosleep(const struct timespec *req, struct timespec *rem) +{ + UINT64 us = (UINT64)req->tv_sec * OS_SYS_US_PER_SECOND + (req->tv_nsec + OS_SYS_NS_PER_US - 1) / OS_SYS_NS_PER_US; + if (us > 0xFFFFFFFFU) { + errno = EINVAL; + return -1; + } + if (usleep(us) == 0) { + if (rem) { + rem->tv_sec = rem->tv_nsec = 0; + } + return 0; + } + return -1; +} + +int timer_create(clockid_t clockID, struct sigevent *restrict evp, timer_t *restrict timerID) +{ + UINT32 ret; + UINT16 swtmrID; + + if (!timerID || (clockID != CLOCK_REALTIME)) { + errno = EINVAL; + return -1; + } + + if (!evp || evp->sigev_notify != SIGEV_THREAD || evp->sigev_notify_attributes) { + errno = ENOTSUP; + return -1; + } + + ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)evp->sigev_notify_function, + &swtmrID, (UINT32)(UINTPTR)evp->sigev_value.sival_ptr); + if (ret != LOS_OK) { + errno = (ret == LOS_ERRNO_SWTMR_MAXSIZE) ? EAGAIN : EINVAL; + return -1; + } + + *timerID = (timer_t)(UINTPTR)swtmrID; + return 0; +} + +int timer_delete(timer_t timerID) +{ + UINT16 swtmrID = (UINT16)(UINTPTR)timerID; + + if (!ValidTimerID(swtmrID)) { + errno = EINVAL; + return -1; + } + + if (LOS_SwtmrDelete(swtmrID) != LOS_OK) { + errno = EINVAL; + return -1; + } + + return 0; +} + +int timer_settime(timer_t timerID, int flags, + const struct itimerspec *restrict value, + struct itimerspec *restrict oldValue) +{ + UINT16 swtmrID = (UINT16)(UINTPTR)timerID; + SWTMR_CTRL_S *swtmr = NULL; + UINT32 interval, expiry, ret; + + if (flags != 0) { + /* flags not supported currently */ + errno = ENOSYS; + return -1; + } + + if (value == NULL || !ValidTimerID(swtmrID)) { + errno = EINVAL; + return -1; + } + + if (!ValidTimeSpec(&value->it_value) || !ValidTimeSpec(&value->it_interval)) { + errno = EINVAL; + return -1; + } + + expiry = OsTimeSpec2Tick(&value->it_value); + interval = OsTimeSpec2Tick(&value->it_interval); + + /* if specified interval, it must be same with expiry due to the limitation of liteos-m */ + if (interval && interval != expiry) { + errno = ENOTSUP; + return -1; + } + + if (oldValue) { + (VOID)timer_gettime(timerID, oldValue); + } + + ret = LOS_SwtmrStop(swtmrID); + if ((ret != LOS_OK) && (ret != LOS_ERRNO_SWTMR_NOT_STARTED)) { + errno = EINVAL; + return -1; + } + + swtmr = OS_SWT_FROM_SID(swtmrID); + ret = LOS_SwtmrModify(swtmrID, expiry, (interval ? LOS_SWTMR_MODE_PERIOD : LOS_SWTMR_MODE_NO_SELFDELETE), + swtmr->pfnHandler, swtmr->uwArg); + if (ret != LOS_OK) { + errno = EINVAL; + return -1; + } + + if ((value->it_value.tv_sec == 0) && (value->it_value.tv_nsec == 0)) { + /* + * 1) when expiry is 0, means timer should be stopped. + * 2) If timer is ticking, stopping timer is already done before. + * 3) If timer is created but not ticking, return 0 as well. + */ + return 0; + } + + if (LOS_SwtmrStart(swtmr->usTimerID) != LOS_OK) { + errno = EINVAL; + return -1; + } + + return 0; +} + +int timer_gettime(timer_t timerID, struct itimerspec *value) +{ + UINT32 tick = 0; + SWTMR_CTRL_S *swtmr = NULL; + UINT16 swtmrID = (UINT16)(UINTPTR)timerID; + UINT32 ret; + + if ((value == NULL) || !ValidTimerID(swtmrID)) { + errno = EINVAL; + return -1; + } + + swtmr = OS_SWT_FROM_SID(swtmrID); + + /* get expire time */ + ret = LOS_SwtmrTimeGet(swtmr->usTimerID, &tick); + if ((ret != LOS_OK) && (ret != LOS_ERRNO_SWTMR_NOT_STARTED)) { + errno = EINVAL; + return -1; + } + + OsTick2TimeSpec(&value->it_value, tick); + OsTick2TimeSpec(&value->it_interval, (swtmr->ucMode == LOS_SWTMR_MODE_ONCE) ? 0 : swtmr->uwInterval); + return 0; +} + +int timer_getoverrun(timer_t timerID) +{ + UINT16 swtmrID = (UINT16)(UINTPTR)timerID; + + if (!ValidTimerID(swtmrID)) { + errno = EINVAL; + return -1; + } + + errno = ENOSYS; + return -1; +} diff --git a/kernel/src/los_printf_pri.h b/kal/posix/src/version.c similarity index 77% rename from kernel/src/los_printf_pri.h rename to kal/posix/src/version.c index e0406522..a701d930 100755 --- a/kernel/src/los_printf_pri.h +++ b/kal/posix/src/version.c @@ -1,54 +1,50 @@ -/* - * 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_PRINTF_PRI_H -#define _LOS_PRINTF_PRI_H - -#include "los_printf.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - - -VOID _dprintf(const CHAR *fmt, va_list ap); -INT32 __dprintf(const CHAR *fmt, va_list ap, VOID (*uart_fputc)(UINT32 n, VOID *cookie), CHAR *cookie); - - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_PRINTF_PRI_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. + */ + +#include + +/** + * get libc version string. + * @return libc version string. the format is ..[-[-]] + */ +const char *libc_get_version_string(void) +{ + return LIBC_VERSION_STR; +} + +/** + * get libc version code. + * @return libc version code. the format is 0x00XXYYZZ, XX is major version, YY is minor version and ZZ is patch version + */ +int libc_get_version(void) +{ + return LIBC_VERSION_NUM; +} diff --git a/kernel/arch/arm/cortex-m3/keil/cmsis/ARMCM3.h b/kernel/arch/arm/cortex-m3/keil/cmsis/ARMCM3.h new file mode 100755 index 00000000..0619c8fe --- /dev/null +++ b/kernel/arch/arm/cortex-m3/keil/cmsis/ARMCM3.h @@ -0,0 +1,276 @@ +/**************************************************************************//** + * @file ARMCM3.h + * @brief CMSIS Core Peripheral Access Layer Header File for + * ARMCM3 Device Series + * @version V1.08 + * @date 23. November 2012 + * + * @note + * + ******************************************************************************/ +/* Copyright (c) 2011 - 2012 ARM LIMITED + + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - 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. + - Neither the name of ARM 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 COPYRIGHT HOLDERS AND 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 ARMCM3_H +#define ARMCM3_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* ------------------------- Interrupt Number Definition ------------------------ */ + +typedef enum IRQn +{ +/* ------------------- Cortex-M3 Processor Exceptions Numbers ------------------- */ + NonMaskableInt_IRQn = -14, /*!< 2 Non Maskable Interrupt */ + HardFault_IRQn = -13, /*!< 3 HardFault Interrupt */ + MemoryManagement_IRQn = -12, /*!< 4 Memory Management Interrupt */ + BusFault_IRQn = -11, /*!< 5 Bus Fault Interrupt */ + UsageFault_IRQn = -10, /*!< 6 Usage Fault Interrupt */ + SVCall_IRQn = -5, /*!< 11 SV Call Interrupt */ + DebugMonitor_IRQn = -4, /*!< 12 Debug Monitor Interrupt */ + PendSV_IRQn = -2, /*!< 14 Pend SV Interrupt */ + SysTick_IRQn = -1, /*!< 15 System Tick Interrupt */ + +/* ---------------------- ARMCM3 Specific Interrupt Numbers --------------------- */ + WDT_IRQn = 0, /*!< Watchdog Timer Interrupt */ + RTC_IRQn = 1, /*!< Real Time Clock Interrupt */ + TIM0_IRQn = 2, /*!< Timer0 / Timer1 Interrupt */ + TIM2_IRQn = 3, /*!< Timer2 / Timer3 Interrupt */ + MCIA_IRQn = 4, /*!< MCIa Interrupt */ + MCIB_IRQn = 5, /*!< MCIb Interrupt */ + UART0_IRQn = 6, /*!< UART0 Interrupt */ + UART1_IRQn = 7, /*!< UART1 Interrupt */ + UART2_IRQn = 8, /*!< UART2 Interrupt */ + UART4_IRQn = 9, /*!< UART4 Interrupt */ + AACI_IRQn = 10, /*!< AACI / AC97 Interrupt */ + CLCD_IRQn = 11, /*!< CLCD Combined Interrupt */ + ENET_IRQn = 12, /*!< Ethernet Interrupt */ + USBDC_IRQn = 13, /*!< USB Device Interrupt */ + USBHC_IRQn = 14, /*!< USB Host Controller Interrupt */ + CHLCD_IRQn = 15, /*!< Character LCD Interrupt */ + FLEXRAY_IRQn = 16, /*!< Flexray Interrupt */ + CAN_IRQn = 17, /*!< CAN Interrupt */ + LIN_IRQn = 18, /*!< LIN Interrupt */ + I2C_IRQn = 19, /*!< I2C ADC/DAC Interrupt */ + CPU_CLCD_IRQn = 28, /*!< CPU CLCD Combined Interrupt */ + UART3_IRQn = 30, /*!< UART3 Interrupt */ + SPI_IRQn = 31, /*!< SPI Touchscreen Interrupt */ +} IRQn_Type; + + +/* ================================================================================ */ +/* ================ Processor and Core Peripheral Section ================ */ +/* ================================================================================ */ + +/* -------- Configuration of the Cortex-M4 Processor and Core Peripherals ------- */ +#define __CM3_REV 0x0201 /*!< Core revision r2p1 */ +#define __MPU_PRESENT 1 /*!< MPU present or not */ +#define __NVIC_PRIO_BITS 3 /*!< Number of Bits used for Priority Levels */ +#define __Vendor_SysTickConfig 0 /*!< Set to 1 if different SysTick Config is used */ + +#include /* Processor and core peripherals */ + + +/* ================================================================================ */ +/* ================ Device Specific Peripheral Section ================ */ +/* ================================================================================ */ + +/* ------------------- Start of section using anonymous unions ------------------ */ +#if defined(__CC_ARM) + #pragma push + #pragma anon_unions +#elif defined(__ICCARM__) + #pragma language=extended +#elif defined(__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined(__TMS470__) +/* anonymous unions are enabled by default */ +#elif defined(__TASKING__) + #pragma warning 586 +#else + #warning Not supported compiler type +#endif + + + +/* ================================================================================ */ +/* ================ CPU FPGA System (CPU_SYS) ================ */ +/* ================================================================================ */ +typedef struct +{ + __I uint32_t ID; /* Offset: 0x000 (R/ ) Board and FPGA Identifier */ + __IO uint32_t MEMCFG; /* Offset: 0x004 (R/W) Remap and Alias Memory Control */ + __I uint32_t SW; /* Offset: 0x008 (R/ ) Switch States */ + __IO uint32_t LED; /* Offset: 0x00C (R/W) LED Output States */ + __I uint32_t TS; /* Offset: 0x010 (R/ ) Touchscreen Register */ + __IO uint32_t CTRL1; /* Offset: 0x014 (R/W) Misc Control Functions */ + uint32_t RESERVED0[2]; + __IO uint32_t CLKCFG; /* Offset: 0x020 (R/W) System Clock Configuration */ + __IO uint32_t WSCFG; /* Offset: 0x024 (R/W) Flash Waitstate Configuration */ + __IO uint32_t CPUCFG; /* Offset: 0x028 (R/W) Processor Configuration */ + uint32_t RESERVED1[3]; + __IO uint32_t BASE; /* Offset: 0x038 (R/W) ROM Table base Address */ + __IO uint32_t ID2; /* Offset: 0x03C (R/W) Secondary Identification Register */ +} ARM_CPU_SYS_TypeDef; + + +/* ================================================================================ */ +/* ================ DUT FPGA System (DUT_SYS) ================ */ +/* ================================================================================ */ +typedef struct +{ + __I uint32_t ID; /* Offset: 0x000 (R/ ) Board and FPGA Identifier */ + __IO uint32_t PERCFG; /* Offset: 0x004 (R/W) Peripheral Control Signals */ + __I uint32_t SW; /* Offset: 0x008 (R/ ) Switch States */ + __IO uint32_t LED; /* Offset: 0x00C (R/W) LED Output States */ + __IO uint32_t SEG7; /* Offset: 0x010 (R/W) 7-segment LED Output States */ + __I uint32_t CNT25MHz; /* Offset: 0x014 (R/ ) Freerunning counter incrementing at 25MHz */ + __I uint32_t CNT100Hz; /* Offset: 0x018 (R/ ) Freerunning counter incrementing at 100Hz */ +} ARM_DUT_SYS_TypeDef; + + +/* ================================================================================ */ +/* ================ Timer (TIM) ================ */ +/* ================================================================================ */ +typedef struct +{ + __IO uint32_t Timer1Load; /* Offset: 0x000 (R/W) Timer 1 Load */ + __I uint32_t Timer1Value; /* Offset: 0x004 (R/ ) Timer 1 Counter Current Value */ + __IO uint32_t Timer1Control; /* Offset: 0x008 (R/W) Timer 1 Control */ + __O uint32_t Timer1IntClr; /* Offset: 0x00C ( /W) Timer 1 Interrupt Clear */ + __I uint32_t Timer1RIS; /* Offset: 0x010 (R/ ) Timer 1 Raw Interrupt Status */ + __I uint32_t Timer1MIS; /* Offset: 0x014 (R/ ) Timer 1 Masked Interrupt Status */ + __IO uint32_t Timer1BGLoad; /* Offset: 0x018 (R/W) Background Load Register */ + uint32_t RESERVED0[1]; + __IO uint32_t Timer2Load; /* Offset: 0x020 (R/W) Timer 2 Load */ + __I uint32_t Timer2Value; /* Offset: 0x024 (R/ ) Timer 2 Counter Current Value */ + __IO uint32_t Timer2Control; /* Offset: 0x028 (R/W) Timer 2 Control */ + __O uint32_t Timer2IntClr; /* Offset: 0x02C ( /W) Timer 2 Interrupt Clear */ + __I uint32_t Timer2RIS; /* Offset: 0x030 (R/ ) Timer 2 Raw Interrupt Status */ + __I uint32_t Timer2MIS; /* Offset: 0x034 (R/ ) Timer 2 Masked Interrupt Status */ + __IO uint32_t Timer2BGLoad; /* Offset: 0x038 (R/W) Background Load Register */ +} ARM_TIM_TypeDef; + + +/* ================================================================================ */ +/* ============== Universal Asyncronous Receiver / Transmitter (UART) ============= */ +/* ================================================================================ */ +typedef struct +{ + __IO uint32_t DR; /* Offset: 0x000 (R/W) Data */ + union { + __I uint32_t RSR; /* Offset: 0x000 (R/ ) Receive Status */ + __O uint32_t ECR; /* Offset: 0x000 ( /W) Error Clear */ + }; + uint32_t RESERVED0[4]; + __IO uint32_t FR; /* Offset: 0x018 (R/W) Flags */ + uint32_t RESERVED1[1]; + __IO uint32_t ILPR; /* Offset: 0x020 (R/W) IrDA Low-power Counter */ + __IO uint32_t IBRD; /* Offset: 0x024 (R/W) Interger Baud Rate */ + __IO uint32_t FBRD; /* Offset: 0x028 (R/W) Fractional Baud Rate */ + __IO uint32_t LCR_H; /* Offset: 0x02C (R/W) Line Control */ + __IO uint32_t CR; /* Offset: 0x030 (R/W) Control */ + __IO uint32_t IFLS; /* Offset: 0x034 (R/W) Interrupt FIFO Level Select */ + __IO uint32_t IMSC; /* Offset: 0x038 (R/W) Interrupt Mask Set / Clear */ + __IO uint32_t RIS; /* Offset: 0x03C (R/W) Raw Interrupt Status */ + __IO uint32_t MIS; /* Offset: 0x040 (R/W) Masked Interrupt Status */ + __O uint32_t ICR; /* Offset: 0x044 ( /W) Interrupt Clear */ + __IO uint32_t DMACR; /* Offset: 0x048 (R/W) DMA Control */ +} ARM_UART_TypeDef; + + +/* -------------------- End of section using anonymous unions ------------------- */ +#if defined(__CC_ARM) + #pragma pop +#elif defined(__ICCARM__) + /* leave anonymous unions enabled */ +#elif defined(__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined(__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined(__TASKING__) + #pragma warning restore +#else + #warning Not supported compiler type +#endif + + + + +/* ================================================================================ */ +/* ================ Peripheral memory map ================ */ +/* ================================================================================ */ +/* -------------------------- CPU FPGA memory map ------------------------------- */ +#define ARM_FLASH_BASE (0x00000000UL) +#define ARM_RAM_BASE (0x20000000UL) +#define ARM_RAM_FPGA_BASE (0x1EFF0000UL) +#define ARM_CPU_CFG_BASE (0xDFFF0000UL) + +#define ARM_CPU_SYS_BASE (ARM_CPU_CFG_BASE + 0x00000) +#define ARM_UART3_BASE (ARM_CPU_CFG_BASE + 0x05000) + +/* -------------------------- DUT FPGA memory map ------------------------------- */ +#define ARM_APB_BASE (0x40000000UL) +#define ARM_AHB_BASE (0x4FF00000UL) +#define ARM_DMC_BASE (0x60000000UL) +#define ARM_SMC_BASE (0xA0000000UL) + +#define ARM_TIM0_BASE (ARM_APB_BASE + 0x02000) +#define ARM_TIM2_BASE (ARM_APB_BASE + 0x03000) +#define ARM_DUT_SYS_BASE (ARM_APB_BASE + 0x04000) +#define ARM_UART0_BASE (ARM_APB_BASE + 0x06000) +#define ARM_UART1_BASE (ARM_APB_BASE + 0x07000) +#define ARM_UART2_BASE (ARM_APB_BASE + 0x08000) +#define ARM_UART4_BASE (ARM_APB_BASE + 0x09000) + + +/* ================================================================================ */ +/* ================ Peripheral declaration ================ */ +/* ================================================================================ */ +/* -------------------------- CPU FPGA Peripherals ------------------------------ */ +#define ARM_CPU_SYS ((ARM_CPU_SYS_TypeDef *) ARM_CPU_SYS_BASE) +#define ARM_UART3 (( ARM_UART_TypeDef *) ARM_UART3_BASE) + +/* -------------------------- DUT FPGA Peripherals ------------------------------ */ +#define ARM_DUT_SYS ((ARM_DUT_SYS_TypeDef *) ARM_DUT_SYS_BASE) +#define ARM_TIM0 (( ARM_TIM_TypeDef *) ARM_TIM0_BASE) +#define ARM_TIM2 (( ARM_TIM_TypeDef *) ARM_TIM2_BASE) +#define ARM_UART0 (( ARM_UART_TypeDef *) ARM_UART0_BASE) +#define ARM_UART1 (( ARM_UART_TypeDef *) ARM_UART1_BASE) +#define ARM_UART2 (( ARM_UART_TypeDef *) ARM_UART2_BASE) +#define ARM_UART4 (( ARM_UART_TypeDef *) ARM_UART4_BASE) + + +#ifdef __cplusplus +} +#endif + +#endif /* ARMCM3_H */ diff --git a/kernel/arch/arm/cortex-m3/keil/cmsis/core_cm3.h b/kernel/arch/arm/cortex-m3/keil/cmsis/core_cm3.h new file mode 100755 index 00000000..805e0d1f --- /dev/null +++ b/kernel/arch/arm/cortex-m3/keil/cmsis/core_cm3.h @@ -0,0 +1,1623 @@ +/**************************************************************************//** + * @file core_cm3.h + * @brief CMSIS Cortex-M3 Core Peripheral Access Layer Header File + * @version V3.20 + * @date 25. February 2013 + * + * @note + * + ******************************************************************************/ +/* Copyright (c) 2009 - 2013 ARM LIMITED + + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - 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. + - Neither the name of ARM 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 COPYRIGHT HOLDERS AND 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. + ---------------------------------------------------------------------------*/ + + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#endif +#include +#ifdef __cplusplus + extern "C" { +#endif + +#ifndef __CORE_CM3_H_GENERIC +#define __CORE_CM3_H_GENERIC + +/** \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** \ingroup Cortex_M3 + @{ + */ + +/* CMSIS CM3 definitions */ +#define __CM3_CMSIS_VERSION_MAIN (0x03) /*!< [31:16] CMSIS HAL main version */ +#define __CM3_CMSIS_VERSION_SUB (0x20) /*!< [15:0] CMSIS HAL sub version */ +#define __CM3_CMSIS_VERSION ((__CM3_CMSIS_VERSION_MAIN << 16) | \ + __CM3_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */ + +#define __CORTEX_M (0x03) /*!< Cortex-M Core */ + + +#if defined ( __CC_ARM ) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline + +#elif defined ( __ICCARM__ ) + #define __ASM __asm /*!< asm keyword for IAR Compiler */ + #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ + #define __STATIC_INLINE static inline + +#elif defined ( __TMS470__ ) + #define __ASM __asm /*!< asm keyword for TI CCS Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __GNUC__ ) + #define __ASM __asm /*!< asm keyword for GNU Compiler */ + #define __INLINE inline /*!< inline keyword for GNU Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __TASKING__ ) + #define __ASM __asm /*!< asm keyword for TASKING Compiler */ + #define __INLINE inline /*!< inline keyword for TASKING Compiler */ + #define __STATIC_INLINE static inline + +#endif + +/** __FPU_USED indicates whether an FPU is used or not. This core does not support an FPU at all +*/ +#define __FPU_USED 0 + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TMS470__ ) + #if defined __TI__VFP_SUPPORT____ + #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif +#endif + +#include /* Core Instruction Access */ +#include /* Core Function Access */ + +#endif /* __CORE_CM3_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM3_H_DEPENDANT +#define __CORE_CM3_H_DEPENDANT + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM3_REV + #define __CM3_REV 0x0200 + #warning "__CM3_REV not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0 + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 4 + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0 + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/*@} end of group Cortex_M3 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + ******************************************************************************/ +/** \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { +#if (__CORTEX_M != 0x04) + uint32_t _reserved0:27; /*!< bit: 0..26 Reserved */ +#else + uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ +#endif + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + + +/** \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + + +/** \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ +#if (__CORTEX_M != 0x04) + uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */ +#else + uint32_t _reserved0:7; /*!< bit: 9..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */ +#endif + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + + +/** \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t FPCA:1; /*!< bit: 2 FP extension active flag */ + uint32_t _reserved0:29; /*!< bit: 3..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/*@} end of group CMSIS_CORE */ + + +/** \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IO uint32_t ISER[8]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[24]; + __IO uint32_t ICER[8]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[24]; + __IO uint32_t ISPR[8]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[24]; + __IO uint32_t ICPR[8]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[24]; + __IO uint32_t IABR[8]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[56]; + __IO uint8_t IP[240]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED5[644]; + __O uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0 /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL << NVIC_STIR_INTID_Pos) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __I uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IO uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IO uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IO uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IO uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IO uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IO uint8_t SHP[12]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IO uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IO uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IO uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IO uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IO uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IO uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IO uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __I uint32_t PFR[2]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __I uint32_t DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __I uint32_t ADR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __I uint32_t MMFR[4]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __I uint32_t ISAR[5]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + uint32_t RESERVED0[5]; + __IO uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24 /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20 /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16 /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4 /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0 /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL << SCB_CPUID_REVISION_Pos) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31 /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28 /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27 /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26 /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25 /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23 /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22 /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12 /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11 /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0 /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL << SCB_ICSR_VECTACTIVE_Pos) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#if (__CM3_REV < 0x0201) /* core r2p1 */ +#define SCB_VTOR_TBLBASE_Pos 29 /*!< SCB VTOR: TBLBASE Position */ +#define SCB_VTOR_TBLBASE_Msk (1UL << SCB_VTOR_TBLBASE_Pos) /*!< SCB VTOR: TBLBASE Mask */ + +#define SCB_VTOR_TBLOFF_Pos 7 /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x3FFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ +#else +#define SCB_VTOR_TBLOFF_Pos 7 /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ +#endif + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16 /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16 /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15 /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8 /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2 /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1 /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +#define SCB_AIRCR_VECTRESET_Pos 0 /*!< SCB AIRCR: VECTRESET Position */ +#define SCB_AIRCR_VECTRESET_Msk (1UL << SCB_AIRCR_VECTRESET_Pos) /*!< SCB AIRCR: VECTRESET Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4 /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2 /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1 /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9 /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8 /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4 /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3 /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1 /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +#define SCB_CCR_NONBASETHRDENA_Pos 0 /*!< SCB CCR: NONBASETHRDENA Position */ +#define SCB_CCR_NONBASETHRDENA_Msk (1UL << SCB_CCR_NONBASETHRDENA_Pos) /*!< SCB CCR: NONBASETHRDENA Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_USGFAULTENA_Pos 18 /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17 /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16 /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15 /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14 /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13 /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12 /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11 /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10 /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8 /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7 /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3 /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1 /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0 /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL << SCB_SHCSR_MEMFAULTACT_Pos) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Registers Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16 /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8 /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0 /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL << SCB_CFSR_MEMFAULTSR_Pos) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* SCB Hard Fault Status Registers Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31 /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30 /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1 /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_EXTERNAL_Pos 4 /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3 /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2 /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1 /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0 /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL << SCB_DFSR_HALTED_Pos) /*!< SCB DFSR: HALTED Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1]; + __I uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ +#if ((defined __CM3_REV) && (__CM3_REV >= 0x200)) + __IO uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ +#else + uint32_t RESERVED1[1]; +#endif +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0 /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL << SCnSCB_ICTR_INTLINESNUM_Pos) /*!< ICTR: INTLINESNUM Mask */ + +/* Auxiliary Control Register Definitions */ + +#define SCnSCB_ACTLR_DISFOLD_Pos 2 /*!< ACTLR: DISFOLD Position */ +#define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */ + +#define SCnSCB_ACTLR_DISDEFWBUF_Pos 1 /*!< ACTLR: DISDEFWBUF Position */ +#define SCnSCB_ACTLR_DISDEFWBUF_Msk (1UL << SCnSCB_ACTLR_DISDEFWBUF_Pos) /*!< ACTLR: DISDEFWBUF Mask */ + +#define SCnSCB_ACTLR_DISMCYCINT_Pos 0 /*!< ACTLR: DISMCYCINT Position */ +#define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL << SCnSCB_ACTLR_DISMCYCINT_Pos) /*!< ACTLR: DISMCYCINT Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IO uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IO uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IO uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __I uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16 /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2 /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1 /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0 /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL << SysTick_CTRL_ENABLE_Pos) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0 /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL << SysTick_LOAD_RELOAD_Pos) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0 /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL << SysTick_VAL_CURRENT_Pos) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31 /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30 /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0 /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL << SysTick_VAL_CURRENT_Pos) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __O union + { + __O uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __O uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __O uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864]; + __IO uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15]; + __IO uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15]; + __IO uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[29]; + __O uint32_t IWR; /*!< Offset: 0xEF8 ( /W) ITM Integration Write Register */ + __I uint32_t IRR; /*!< Offset: 0xEFC (R/ ) ITM Integration Read Register */ + __IO uint32_t IMCR; /*!< Offset: 0xF00 (R/W) ITM Integration Mode Control Register */ + uint32_t RESERVED4[43]; + __O uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __I uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[6]; + __I uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __I uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __I uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __I uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __I uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __I uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __I uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __I uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __I uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __I uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __I uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __I uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0 /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFUL << ITM_TPR_PRIVMASK_Pos) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23 /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TraceBusID_Pos 16 /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TraceBusID_Msk (0x7FUL << ITM_TCR_TraceBusID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10 /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPrescale_Pos 8 /*!< ITM TCR: TSPrescale Position */ +#define ITM_TCR_TSPrescale_Msk (3UL << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */ + +#define ITM_TCR_SWOENA_Pos 4 /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3 /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2 /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1 /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0 /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL << ITM_TCR_ITMENA_Pos) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Integration Write Register Definitions */ +#define ITM_IWR_ATVALIDM_Pos 0 /*!< ITM IWR: ATVALIDM Position */ +#define ITM_IWR_ATVALIDM_Msk (1UL << ITM_IWR_ATVALIDM_Pos) /*!< ITM IWR: ATVALIDM Mask */ + +/* ITM Integration Read Register Definitions */ +#define ITM_IRR_ATREADYM_Pos 0 /*!< ITM IRR: ATREADYM Position */ +#define ITM_IRR_ATREADYM_Msk (1UL << ITM_IRR_ATREADYM_Pos) /*!< ITM IRR: ATREADYM Mask */ + +/* ITM Integration Mode Control Register Definitions */ +#define ITM_IMCR_INTEGRATION_Pos 0 /*!< ITM IMCR: INTEGRATION Position */ +#define ITM_IMCR_INTEGRATION_Msk (1UL << ITM_IMCR_INTEGRATION_Pos) /*!< ITM IMCR: INTEGRATION Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2 /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1 /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0 /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL << ITM_LSR_Present_Pos) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IO uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IO uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IO uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IO uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IO uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IO uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IO uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __I uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IO uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + __IO uint32_t MASK0; /*!< Offset: 0x024 (R/W) Mask Register 0 */ + __IO uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED0[1]; + __IO uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + __IO uint32_t MASK1; /*!< Offset: 0x034 (R/W) Mask Register 1 */ + __IO uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED1[1]; + __IO uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + __IO uint32_t MASK2; /*!< Offset: 0x044 (R/W) Mask Register 2 */ + __IO uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED2[1]; + __IO uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + __IO uint32_t MASK3; /*!< Offset: 0x054 (R/W) Mask Register 3 */ + __IO uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28 /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27 /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26 /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25 /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24 /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22 /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21 /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20 /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19 /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18 /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17 /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16 /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12 /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10 /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9 /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5 /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1 /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0 /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL << DWT_CTRL_CYCCNTENA_Pos) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0 /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL << DWT_CPICNT_CPICNT_Pos) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0 /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL << DWT_EXCCNT_EXCCNT_Pos) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0 /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL << DWT_SLEEPCNT_SLEEPCNT_Pos) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0 /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL << DWT_LSUCNT_LSUCNT_Pos) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0 /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL << DWT_FOLDCNT_FOLDCNT_Pos) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Mask Register Definitions */ +#define DWT_MASK_MASK_Pos 0 /*!< DWT MASK: MASK Position */ +#define DWT_MASK_MASK_Msk (0x1FUL << DWT_MASK_MASK_Pos) /*!< DWT MASK: MASK Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_MATCHED_Pos 24 /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVADDR1_Pos 16 /*!< DWT FUNCTION: DATAVADDR1 Position */ +#define DWT_FUNCTION_DATAVADDR1_Msk (0xFUL << DWT_FUNCTION_DATAVADDR1_Pos) /*!< DWT FUNCTION: DATAVADDR1 Mask */ + +#define DWT_FUNCTION_DATAVADDR0_Pos 12 /*!< DWT FUNCTION: DATAVADDR0 Position */ +#define DWT_FUNCTION_DATAVADDR0_Msk (0xFUL << DWT_FUNCTION_DATAVADDR0_Pos) /*!< DWT FUNCTION: DATAVADDR0 Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10 /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_LNK1ENA_Pos 9 /*!< DWT FUNCTION: LNK1ENA Position */ +#define DWT_FUNCTION_LNK1ENA_Msk (0x1UL << DWT_FUNCTION_LNK1ENA_Pos) /*!< DWT FUNCTION: LNK1ENA Mask */ + +#define DWT_FUNCTION_DATAVMATCH_Pos 8 /*!< DWT FUNCTION: DATAVMATCH Position */ +#define DWT_FUNCTION_DATAVMATCH_Msk (0x1UL << DWT_FUNCTION_DATAVMATCH_Pos) /*!< DWT FUNCTION: DATAVMATCH Mask */ + +#define DWT_FUNCTION_CYCMATCH_Pos 7 /*!< DWT FUNCTION: CYCMATCH Position */ +#define DWT_FUNCTION_CYCMATCH_Msk (0x1UL << DWT_FUNCTION_CYCMATCH_Pos) /*!< DWT FUNCTION: CYCMATCH Mask */ + +#define DWT_FUNCTION_EMITRANGE_Pos 5 /*!< DWT FUNCTION: EMITRANGE Position */ +#define DWT_FUNCTION_EMITRANGE_Msk (0x1UL << DWT_FUNCTION_EMITRANGE_Pos) /*!< DWT FUNCTION: EMITRANGE Mask */ + +#define DWT_FUNCTION_FUNCTION_Pos 0 /*!< DWT FUNCTION: FUNCTION Position */ +#define DWT_FUNCTION_FUNCTION_Msk (0xFUL << DWT_FUNCTION_FUNCTION_Pos) /*!< DWT FUNCTION: FUNCTION Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IO uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ + __IO uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ + uint32_t RESERVED0[2]; + __IO uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55]; + __IO uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131]; + __I uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IO uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __I uint32_t FSCR; /*!< Offset: 0x308 (R/ ) Formatter Synchronization Counter Register */ + uint32_t RESERVED3[759]; + __I uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER */ + __I uint32_t FIFO0; /*!< Offset: 0xEEC (R/ ) Integration ETM Data */ + __I uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/ ) ITATBCTR2 */ + uint32_t RESERVED4[1]; + __I uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) ITATBCTR0 */ + __I uint32_t FIFO1; /*!< Offset: 0xEFC (R/ ) Integration ITM Data */ + __IO uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ + uint32_t RESERVED5[39]; + __IO uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ + __IO uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ + uint32_t RESERVED7[8]; + __I uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) TPIU_DEVID */ + __I uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) TPIU_DEVTYPE */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_PRESCALER_Pos 0 /*!< TPI ACPR: PRESCALER Position */ +#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL << TPI_ACPR_PRESCALER_Pos) /*!< TPI ACPR: PRESCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0 /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL << TPI_SPPR_TXMODE_Pos) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3 /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2 /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1 /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0 /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL << TPI_FFSR_FlInProg_Pos) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8 /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_EnFCont_Pos 1 /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI TRIGGER Register Definitions */ +#define TPI_TRIGGER_TRIGGER_Pos 0 /*!< TPI TRIGGER: TRIGGER Position */ +#define TPI_TRIGGER_TRIGGER_Msk (0x1UL << TPI_TRIGGER_TRIGGER_Pos) /*!< TPI TRIGGER: TRIGGER Mask */ + +/* TPI Integration ETM Data Register Definitions (FIFO0) */ +#define TPI_FIFO0_ITM_ATVALID_Pos 29 /*!< TPI FIFO0: ITM_ATVALID Position */ +#define TPI_FIFO0_ITM_ATVALID_Msk (0x3UL << TPI_FIFO0_ITM_ATVALID_Pos) /*!< TPI FIFO0: ITM_ATVALID Mask */ + +#define TPI_FIFO0_ITM_bytecount_Pos 27 /*!< TPI FIFO0: ITM_bytecount Position */ +#define TPI_FIFO0_ITM_bytecount_Msk (0x3UL << TPI_FIFO0_ITM_bytecount_Pos) /*!< TPI FIFO0: ITM_bytecount Mask */ + +#define TPI_FIFO0_ETM_ATVALID_Pos 26 /*!< TPI FIFO0: ETM_ATVALID Position */ +#define TPI_FIFO0_ETM_ATVALID_Msk (0x3UL << TPI_FIFO0_ETM_ATVALID_Pos) /*!< TPI FIFO0: ETM_ATVALID Mask */ + +#define TPI_FIFO0_ETM_bytecount_Pos 24 /*!< TPI FIFO0: ETM_bytecount Position */ +#define TPI_FIFO0_ETM_bytecount_Msk (0x3UL << TPI_FIFO0_ETM_bytecount_Pos) /*!< TPI FIFO0: ETM_bytecount Mask */ + +#define TPI_FIFO0_ETM2_Pos 16 /*!< TPI FIFO0: ETM2 Position */ +#define TPI_FIFO0_ETM2_Msk (0xFFUL << TPI_FIFO0_ETM2_Pos) /*!< TPI FIFO0: ETM2 Mask */ + +#define TPI_FIFO0_ETM1_Pos 8 /*!< TPI FIFO0: ETM1 Position */ +#define TPI_FIFO0_ETM1_Msk (0xFFUL << TPI_FIFO0_ETM1_Pos) /*!< TPI FIFO0: ETM1 Mask */ + +#define TPI_FIFO0_ETM0_Pos 0 /*!< TPI FIFO0: ETM0 Position */ +#define TPI_FIFO0_ETM0_Msk (0xFFUL << TPI_FIFO0_ETM0_Pos) /*!< TPI FIFO0: ETM0 Mask */ + +/* TPI ITATBCTR2 Register Definitions */ +#define TPI_ITATBCTR2_ATREADY_Pos 0 /*!< TPI ITATBCTR2: ATREADY Position */ +#define TPI_ITATBCTR2_ATREADY_Msk (0x1UL << TPI_ITATBCTR2_ATREADY_Pos) /*!< TPI ITATBCTR2: ATREADY Mask */ + +/* TPI Integration ITM Data Register Definitions (FIFO1) */ +#define TPI_FIFO1_ITM_ATVALID_Pos 29 /*!< TPI FIFO1: ITM_ATVALID Position */ +#define TPI_FIFO1_ITM_ATVALID_Msk (0x3UL << TPI_FIFO1_ITM_ATVALID_Pos) /*!< TPI FIFO1: ITM_ATVALID Mask */ + +#define TPI_FIFO1_ITM_bytecount_Pos 27 /*!< TPI FIFO1: ITM_bytecount Position */ +#define TPI_FIFO1_ITM_bytecount_Msk (0x3UL << TPI_FIFO1_ITM_bytecount_Pos) /*!< TPI FIFO1: ITM_bytecount Mask */ + +#define TPI_FIFO1_ETM_ATVALID_Pos 26 /*!< TPI FIFO1: ETM_ATVALID Position */ +#define TPI_FIFO1_ETM_ATVALID_Msk (0x3UL << TPI_FIFO1_ETM_ATVALID_Pos) /*!< TPI FIFO1: ETM_ATVALID Mask */ + +#define TPI_FIFO1_ETM_bytecount_Pos 24 /*!< TPI FIFO1: ETM_bytecount Position */ +#define TPI_FIFO1_ETM_bytecount_Msk (0x3UL << TPI_FIFO1_ETM_bytecount_Pos) /*!< TPI FIFO1: ETM_bytecount Mask */ + +#define TPI_FIFO1_ITM2_Pos 16 /*!< TPI FIFO1: ITM2 Position */ +#define TPI_FIFO1_ITM2_Msk (0xFFUL << TPI_FIFO1_ITM2_Pos) /*!< TPI FIFO1: ITM2 Mask */ + +#define TPI_FIFO1_ITM1_Pos 8 /*!< TPI FIFO1: ITM1 Position */ +#define TPI_FIFO1_ITM1_Msk (0xFFUL << TPI_FIFO1_ITM1_Pos) /*!< TPI FIFO1: ITM1 Mask */ + +#define TPI_FIFO1_ITM0_Pos 0 /*!< TPI FIFO1: ITM0 Position */ +#define TPI_FIFO1_ITM0_Msk (0xFFUL << TPI_FIFO1_ITM0_Pos) /*!< TPI FIFO1: ITM0 Mask */ + +/* TPI ITATBCTR0 Register Definitions */ +#define TPI_ITATBCTR0_ATREADY_Pos 0 /*!< TPI ITATBCTR0: ATREADY Position */ +#define TPI_ITATBCTR0_ATREADY_Msk (0x1UL << TPI_ITATBCTR0_ATREADY_Pos) /*!< TPI ITATBCTR0: ATREADY Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0 /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x1UL << TPI_ITCTRL_Mode_Pos) /*!< TPI ITCTRL: Mode Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11 /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10 /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9 /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_MinBufSz_Pos 6 /*!< TPI DEVID: MinBufSz Position */ +#define TPI_DEVID_MinBufSz_Msk (0x7UL << TPI_DEVID_MinBufSz_Pos) /*!< TPI DEVID: MinBufSz Mask */ + +#define TPI_DEVID_AsynClkIn_Pos 5 /*!< TPI DEVID: AsynClkIn Position */ +#define TPI_DEVID_AsynClkIn_Msk (0x1UL << TPI_DEVID_AsynClkIn_Pos) /*!< TPI DEVID: AsynClkIn Mask */ + +#define TPI_DEVID_NrTraceInput_Pos 0 /*!< TPI DEVID: NrTraceInput Position */ +#define TPI_DEVID_NrTraceInput_Msk (0x1FUL << TPI_DEVID_NrTraceInput_Pos) /*!< TPI DEVID: NrTraceInput Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 0 /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL << TPI_DEVTYPE_SubType_Pos) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 4 /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if (__MPU_PRESENT == 1) +/** \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __I uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IO uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IO uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ + __IO uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IO uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ + __IO uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Alias 1 Region Base Address Register */ + __IO uint32_t RASR_A1; /*!< Offset: 0x018 (R/W) MPU Alias 1 Region Attribute and Size Register */ + __IO uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Alias 2 Region Base Address Register */ + __IO uint32_t RASR_A2; /*!< Offset: 0x020 (R/W) MPU Alias 2 Region Attribute and Size Register */ + __IO uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Alias 3 Region Base Address Register */ + __IO uint32_t RASR_A3; /*!< Offset: 0x028 (R/W) MPU Alias 3 Region Attribute and Size Register */ +} MPU_Type; + +/* MPU Type Register */ +#define MPU_TYPE_IREGION_Pos 16 /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8 /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0 /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL << MPU_TYPE_SEPARATE_Pos) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register */ +#define MPU_CTRL_PRIVDEFENA_Pos 2 /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1 /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0 /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL << MPU_CTRL_ENABLE_Pos) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register */ +#define MPU_RNR_REGION_Pos 0 /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL << MPU_RNR_REGION_Pos) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register */ +#define MPU_RBAR_ADDR_Pos 5 /*!< MPU RBAR: ADDR Position */ +#define MPU_RBAR_ADDR_Msk (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ + +#define MPU_RBAR_VALID_Pos 4 /*!< MPU RBAR: VALID Position */ +#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ + +#define MPU_RBAR_REGION_Pos 0 /*!< MPU RBAR: REGION Position */ +#define MPU_RBAR_REGION_Msk (0xFUL << MPU_RBAR_REGION_Pos) /*!< MPU RBAR: REGION Mask */ + +/* MPU Region Attribute and Size Register */ +#define MPU_RASR_ATTRS_Pos 16 /*!< MPU RASR: MPU Region Attribute field Position */ +#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ + +#define MPU_RASR_XN_Pos 28 /*!< MPU RASR: ATTRS.XN Position */ +#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ + +#define MPU_RASR_AP_Pos 24 /*!< MPU RASR: ATTRS.AP Position */ +#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ + +#define MPU_RASR_TEX_Pos 19 /*!< MPU RASR: ATTRS.TEX Position */ +#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ + +#define MPU_RASR_S_Pos 18 /*!< MPU RASR: ATTRS.S Position */ +#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ + +#define MPU_RASR_C_Pos 17 /*!< MPU RASR: ATTRS.C Position */ +#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ + +#define MPU_RASR_B_Pos 16 /*!< MPU RASR: ATTRS.B Position */ +#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ + +#define MPU_RASR_SRD_Pos 8 /*!< MPU RASR: Sub-Region Disable Position */ +#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ + +#define MPU_RASR_SIZE_Pos 1 /*!< MPU RASR: Region Size Field Position */ +#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ + +#define MPU_RASR_ENABLE_Pos 0 /*!< MPU RASR: Region enable bit Position */ +#define MPU_RASR_ENABLE_Msk (1UL << MPU_RASR_ENABLE_Pos) /*!< MPU RASR: Region enable bit Disable Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +/** \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** \brief Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IO uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __O uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IO uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IO uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16 /*!< CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25 /*!< CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24 /*!< CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19 /*!< CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18 /*!< CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17 /*!< CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16 /*!< CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5 /*!< CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3 /*!< CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2 /*!< CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1 /*!< CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0 /*!< CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL << CoreDebug_DHCSR_C_DEBUGEN_Pos) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register */ +#define CoreDebug_DCRSR_REGWnR_Pos 16 /*!< CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0 /*!< CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL << CoreDebug_DCRSR_REGSEL_Pos) /*!< CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register */ +#define CoreDebug_DEMCR_TRCENA_Pos 24 /*!< CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19 /*!< CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18 /*!< CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17 /*!< CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16 /*!< CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10 /*!< CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9 /*!< CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8 /*!< CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7 /*!< CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6 /*!< CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5 /*!< CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4 /*!< CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0 /*!< CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL << CoreDebug_DEMCR_VC_CORERESET_Pos) /*!< CoreDebug DEMCR: VC_CORERESET Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Cortex-M3 Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ +#define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ +#define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ +#define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ +#define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ +#define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ +#define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ +#define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ + +#if (__MPU_PRESENT == 1) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ +#endif + +/*@} */ + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +/** \brief Set Priority Grouping + + The function sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FA << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << 8)); /* Insert write key and priorty group */ + SCB->AIRCR = reg_value; +} + + +/** \brief Get Priority Grouping + + The function reads the priority grouping field from the NVIC Interrupt Controller. + + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t NVIC_GetPriorityGrouping(void) +{ + return ((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos); /* read priority grouping field */ +} +/** \brief Enable External Interrupt + + The function enables a device-specific interrupt in the NVIC interrupt controller. + + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn) +{ + NVIC->ISER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* enable interrupt */ +} + + +/** \brief Disable External Interrupt + + The function disables a device-specific interrupt in the NVIC interrupt controller. + + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn) +{ + NVIC->ICER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* disable interrupt */ +} + + +/** \brief Get Pending Interrupt + + The function reads the pending register in the NVIC and returns the pending bit + for the specified interrupt. + + \param [in] IRQn Interrupt number. + + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + */ +__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + return((uint32_t) ((NVIC->ISPR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0)); /* Return 1 if pending else 0 */ +} + + +/** \brief Set Pending Interrupt + + The function sets the pending bit of an external interrupt. + + \param [in] IRQn Interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + NVIC->ISPR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* set interrupt pending */ +} + + +/** \brief Clear Pending Interrupt + + The function clears the pending bit of an external interrupt. + + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + NVIC->ICPR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* Clear pending interrupt */ +} + + +/** \brief Get Active Interrupt + + The function reads the active register in NVIC and returns the active bit. + + \param [in] IRQn Interrupt number. + + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + */ +__STATIC_INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn) +{ + return((uint32_t)((NVIC->IABR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0)); /* Return 1 if active else 0 */ +} + + +/** \brief Set Interrupt Priority + + The function sets the priority of an interrupt. + + \note The priority cannot be set for every core interrupt. + + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + */ +__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if(IRQn < 0) { + SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff); } /* set Priority for Cortex-M System Interrupts */ + else { + NVIC->IP[(uint32_t)(IRQn)] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff); } /* set Priority for device specific Interrupts */ +} + + +/** \brief Get Interrupt Priority + + The function reads the priority of an interrupt. The interrupt + number can be positive to specify an external (device specific) + interrupt, or negative to specify an internal (core) interrupt. + + + \param [in] IRQn Interrupt number. + \return Interrupt Priority. Value is aligned automatically to the implemented + priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn) +{ + + if(IRQn < 0) { + return((uint32_t)(SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] >> (8 - __NVIC_PRIO_BITS))); } /* get priority for Cortex-M system interrupts */ + else { + return((uint32_t)(NVIC->IP[(uint32_t)(IRQn)] >> (8 - __NVIC_PRIO_BITS))); } /* get priority for device specific interrupts */ +} + + +/** \brief Encode Priority + + The function encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the samllest possible priority group is set. + + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & 0x07); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7 - PriorityGroupTmp) > __NVIC_PRIO_BITS) ? __NVIC_PRIO_BITS : 7 - PriorityGroupTmp; + SubPriorityBits = ((PriorityGroupTmp + __NVIC_PRIO_BITS) < 7) ? 0 : PriorityGroupTmp - 7 + __NVIC_PRIO_BITS; + + return ( + ((PreemptPriority & ((1 << (PreemptPriorityBits)) - 1)) << SubPriorityBits) | + ((SubPriority & ((1 << (SubPriorityBits )) - 1))) + ); +} + + +/** \brief Decode Priority + + The function decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the samllest possible priority group is set. + + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* pPreemptPriority, uint32_t* pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & 0x07); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7 - PriorityGroupTmp) > __NVIC_PRIO_BITS) ? __NVIC_PRIO_BITS : 7 - PriorityGroupTmp; + SubPriorityBits = ((PriorityGroupTmp + __NVIC_PRIO_BITS) < 7) ? 0 : PriorityGroupTmp - 7 + __NVIC_PRIO_BITS; + + *pPreemptPriority = (Priority >> SubPriorityBits) & ((1 << (PreemptPriorityBits)) - 1); + *pSubPriority = (Priority ) & ((1 << (SubPriorityBits )) - 1); +} + + +/** \brief System Reset + + The function initiates a system reset request to reset the MCU. + */ +__STATIC_INLINE void NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = ((0x5FA << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + while(1); /* wait until reset */ +} + +/*@} end of CMSIS_Core_NVICFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if (__Vendor_SysTickConfig == 0) + +/** \brief System Tick Configuration + + The function initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + + \param [in] ticks Number of ticks between two interrupts. + + \return 0 Function succeeded. + \return 1 Function failed. + + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1) > SysTick_LOAD_RELOAD_Msk) return (1); /* Reload value impossible */ + + SysTick->LOAD = ticks - 1; /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY 0x5AA55AA5 /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** \brief ITM Send Character + + The function transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + + \param [in] ch Character to transmit. + + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if ((ITM->TCR & ITM_TCR_ITMENA_Msk) && /* ITM enabled */ + (ITM->TER & (1UL << 0) ) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0].u32 == 0); + ITM->PORT[0].u8 = (uint8_t) ch; + } + return (ch); +} + + +/** \brief ITM Receive Character + + The function inputs a character via the external variable \ref ITM_RxBuffer. + + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) { + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** \brief ITM Check Character + + The function checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) { + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) { + return (0); /* no character available */ + } else { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + +#endif /* __CORE_CM3_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ + +#ifdef __cplusplus +} +#endif diff --git a/kernel/arch/arm/cortex-m3/keil/cmsis/core_cmFunc.h b/kernel/arch/arm/cortex-m3/keil/cmsis/core_cmFunc.h new file mode 100755 index 00000000..a626772f --- /dev/null +++ b/kernel/arch/arm/cortex-m3/keil/cmsis/core_cmFunc.h @@ -0,0 +1,636 @@ +/**************************************************************************//** + * @file core_cmFunc.h + * @brief CMSIS Cortex-M Core Function Access Header File + * @version V3.20 + * @date 25. February 2013 + * + * @note + * + ******************************************************************************/ +/* Copyright (c) 2009 - 2013 ARM LIMITED + + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - 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. + - Neither the name of ARM 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 COPYRIGHT HOLDERS AND 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 __CORE_CMFUNC_H +#define __CORE_CMFUNC_H +#include + +/* ########################### Core Function Access ########################### */ +/** \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions + @{ + */ + +#if defined ( __CC_ARM ) /*------------------RealView Compiler -----------------*/ +/* ARM armcc specific functions */ + +#if (__ARMCC_VERSION < 400677) + #error "Please use ARM Compiler Toolchain V4.0.677 or later!" +#endif + +/* intrinsic void __enable_irq(); */ +/* intrinsic void __disable_irq(); */ + +/** \brief Get Control Register + + This function returns the content of the Control Register. + + \return Control Register value + */ +__STATIC_INLINE uint32_t __get_CONTROL(void) +{ + register uint32_t __regControl __ASM("control"); + return(__regControl); +} + + +/** \brief Set Control Register + + This function writes the given value to the Control Register. + + \param [in] control Control Register value to set + */ +__STATIC_INLINE void __set_CONTROL(uint32_t control) +{ + register uint32_t __regControl __ASM("control"); + __regControl = control; +} + + +/** \brief Get IPSR Register + + This function returns the content of the IPSR Register. + + \return IPSR Register value + */ +__STATIC_INLINE uint32_t __get_IPSR(void) +{ + register uint32_t __regIPSR __ASM("ipsr"); + return(__regIPSR); +} + + +/** \brief Get APSR Register + + This function returns the content of the APSR Register. + + \return APSR Register value + */ +__STATIC_INLINE uint32_t __get_APSR(void) +{ + register uint32_t __regAPSR __ASM("apsr"); + return(__regAPSR); +} + + +/** \brief Get xPSR Register + + This function returns the content of the xPSR Register. + + \return xPSR Register value + */ +__STATIC_INLINE uint32_t __get_xPSR(void) +{ + register uint32_t __regXPSR __ASM("xpsr"); + return(__regXPSR); +} + + +/** \brief Get Process Stack Pointer + + This function returns the current value of the Process Stack Pointer (PSP). + + \return PSP Register value + */ +__STATIC_INLINE uint32_t __get_PSP(void) +{ + register uint32_t __regProcessStackPointer __ASM("psp"); + return(__regProcessStackPointer); +} + + +/** \brief Set Process Stack Pointer + + This function assigns the given value to the Process Stack Pointer (PSP). + + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_INLINE void __set_PSP(uint32_t topOfProcStack) +{ + register uint32_t __regProcessStackPointer __ASM("psp"); + __regProcessStackPointer = topOfProcStack; +} + + +/** \brief Get Main Stack Pointer + + This function returns the current value of the Main Stack Pointer (MSP). + + \return MSP Register value + */ +__STATIC_INLINE uint32_t __get_MSP(void) +{ + register uint32_t __regMainStackPointer __ASM("msp"); + return(__regMainStackPointer); +} + + +/** \brief Set Main Stack Pointer + + This function assigns the given value to the Main Stack Pointer (MSP). + + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_INLINE void __set_MSP(uint32_t topOfMainStack) +{ + register uint32_t __regMainStackPointer __ASM("msp"); + __regMainStackPointer = topOfMainStack; +} + + +/** \brief Get Priority Mask + + This function returns the current state of the priority mask bit from the Priority Mask Register. + + \return Priority Mask value + */ +__STATIC_INLINE uint32_t __get_PRIMASK(void) +{ + register uint32_t __regPriMask __ASM("primask"); + return(__regPriMask); +} + + +/** \brief Set Priority Mask + + This function assigns the given value to the Priority Mask Register. + + \param [in] priMask Priority Mask + */ +__STATIC_INLINE void __set_PRIMASK(uint32_t priMask) +{ + register uint32_t __regPriMask __ASM("primask"); + __regPriMask = (priMask); +} + + +#if (__CORTEX_M >= 0x03) + +/** \brief Enable FIQ + + This function enables FIQ interrupts by clearing the F-bit in the CPSR. + Can only be executed in Privileged modes. + */ +#define __enable_fault_irq __enable_fiq + + +/** \brief Disable FIQ + + This function disables FIQ interrupts by setting the F-bit in the CPSR. + Can only be executed in Privileged modes. + */ +#define __disable_fault_irq __disable_fiq + + +/** \brief Get Base Priority + + This function returns the current value of the Base Priority register. + + \return Base Priority register value + */ +__STATIC_INLINE uint32_t __get_BASEPRI(void) +{ + register uint32_t __regBasePri __ASM("basepri"); + return(__regBasePri); +} + + +/** \brief Set Base Priority + + This function assigns the given value to the Base Priority register. + + \param [in] basePri Base Priority value to set + */ +__STATIC_INLINE void __set_BASEPRI(uint32_t basePri) +{ + register uint32_t __regBasePri __ASM("basepri"); + __regBasePri = (basePri & 0xff); +} + + +/** \brief Get Fault Mask + + This function returns the current value of the Fault Mask register. + + \return Fault Mask register value + */ +__STATIC_INLINE uint32_t __get_FAULTMASK(void) +{ + register uint32_t __regFaultMask __ASM("faultmask"); + return(__regFaultMask); +} + + +/** \brief Set Fault Mask + + This function assigns the given value to the Fault Mask register. + + \param [in] faultMask Fault Mask value to set + */ +__STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask) +{ + register uint32_t __regFaultMask __ASM("faultmask"); + __regFaultMask = (faultMask & (uint32_t)1); +} + +#endif /* (__CORTEX_M >= 0x03) */ + + +#if (__CORTEX_M == 0x04) + +/** \brief Get FPSCR + + This function returns the current value of the Floating Point Status/Control register. + + \return Floating Point Status/Control register value + */ +__STATIC_INLINE uint32_t __get_FPSCR(void) +{ +#if (__FPU_PRESENT == 1) && (__FPU_USED == 1) + register uint32_t __regfpscr __ASM("fpscr"); + return(__regfpscr); +#else + return(0); +#endif +} + + +/** \brief Set FPSCR + + This function assigns the given value to the Floating Point Status/Control register. + + \param [in] fpscr Floating Point Status/Control value to set + */ +__STATIC_INLINE void __set_FPSCR(uint32_t fpscr) +{ +#if (__FPU_PRESENT == 1) && (__FPU_USED == 1) + register uint32_t __regfpscr __ASM("fpscr"); + __regfpscr = (fpscr); +#endif +} + +#endif /* (__CORTEX_M == 0x04) */ + + +#elif defined ( __ICCARM__ ) /*------------------ ICC Compiler -------------------*/ +/* IAR iccarm specific functions */ + +#include + + +#elif defined ( __TMS470__ ) /*---------------- TI CCS Compiler ------------------*/ +/* TI CCS specific functions */ + +#include + + +#elif defined ( __GNUC__ ) /*------------------ GNU Compiler ---------------------*/ +/* GNU gcc specific functions */ + +/** \brief Enable IRQ Interrupts + + This function enables IRQ interrupts by clearing the I-bit in the CPSR. + Can only be executed in Privileged modes. + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_irq(void) +{ + __ASM volatile ("cpsie i" : : : "memory"); +} + + +/** \brief Disable IRQ Interrupts + + This function disables IRQ interrupts by setting the I-bit in the CPSR. + Can only be executed in Privileged modes. + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_irq(void) +{ + __ASM volatile ("cpsid i" : : : "memory"); +} + + +/** \brief Get Control Register + + This function returns the content of the Control Register. + + \return Control Register value + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_CONTROL(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control" : "=r" (result) ); + return(result); +} + + +/** \brief Set Control Register + + This function writes the given value to the Control Register. + + \param [in] control Control Register value to set + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_CONTROL(uint32_t control) +{ + __ASM volatile ("MSR control, %0" : : "r" (control) : "memory"); +} + + +/** \brief Get IPSR Register + + This function returns the content of the IPSR Register. + + \return IPSR Register value + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_IPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, ipsr" : "=r" (result) ); + return(result); +} + + +/** \brief Get APSR Register + + This function returns the content of the APSR Register. + + \return APSR Register value + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_APSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, apsr" : "=r" (result) ); + return(result); +} + + +/** \brief Get xPSR Register + + This function returns the content of the xPSR Register. + + \return xPSR Register value + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_xPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, xpsr" : "=r" (result) ); + return(result); +} + + +/** \brief Get Process Stack Pointer + + This function returns the current value of the Process Stack Pointer (PSP). + + \return PSP Register value + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PSP(void) +{ + register uint32_t result; + + __ASM volatile ("MRS %0, psp\n" : "=r" (result) ); + return(result); +} + + +/** \brief Set Process Stack Pointer + + This function assigns the given value to the Process Stack Pointer (PSP). + + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp, %0\n" : : "r" (topOfProcStack) : "sp"); +} + + +/** \brief Get Main Stack Pointer + + This function returns the current value of the Main Stack Pointer (MSP). + + \return MSP Register value + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_MSP(void) +{ + register uint32_t result; + + __ASM volatile ("MRS %0, msp\n" : "=r" (result) ); + return(result); +} + + +/** \brief Set Main Stack Pointer + + This function assigns the given value to the Main Stack Pointer (MSP). + + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp, %0\n" : : "r" (topOfMainStack) : "sp"); +} + + +/** \brief Get Priority Mask + + This function returns the current state of the priority mask bit from the Priority Mask Register. + + \return Priority Mask value + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PRIMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask" : "=r" (result) ); + return(result); +} + + +/** \brief Set Priority Mask + + This function assigns the given value to the Priority Mask Register. + + \param [in] priMask Priority Mask + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PRIMASK(uint32_t priMask) +{ + __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory"); +} + + +#if (__CORTEX_M >= 0x03) + +/** \brief Enable FIQ + + This function enables FIQ interrupts by clearing the F-bit in the CPSR. + Can only be executed in Privileged modes. + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_fault_irq(void) +{ + __ASM volatile ("cpsie f" : : : "memory"); +} + + +/** \brief Disable FIQ + + This function disables FIQ interrupts by setting the F-bit in the CPSR. + Can only be executed in Privileged modes. + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_fault_irq(void) +{ + __ASM volatile ("cpsid f" : : : "memory"); +} + + +/** \brief Get Base Priority + + This function returns the current value of the Base Priority register. + + \return Base Priority register value + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_BASEPRI(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri_max" : "=r" (result) ); + return(result); +} + + +/** \brief Set Base Priority + + This function assigns the given value to the Base Priority register. + + \param [in] basePri Base Priority value to set + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_BASEPRI(uint32_t value) +{ + __ASM volatile ("MSR basepri, %0" : : "r" (value) : "memory"); +} + + +/** \brief Get Fault Mask + + This function returns the current value of the Fault Mask register. + + \return Fault Mask register value + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FAULTMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); + return(result); +} + + +/** \brief Set Fault Mask + + This function assigns the given value to the Fault Mask register. + + \param [in] faultMask Fault Mask value to set + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory"); +} + +#endif /* (__CORTEX_M >= 0x03) */ + + +#if (__CORTEX_M == 0x04) + +/** \brief Get FPSCR + + This function returns the current value of the Floating Point Status/Control register. + + \return Floating Point Status/Control register value + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FPSCR(void) +{ +#if (__FPU_PRESENT == 1) && (__FPU_USED == 1) + uint32_t result; + + /* Empty asm statement works as a scheduling barrier */ + __ASM volatile (""); + __ASM volatile ("VMRS %0, fpscr" : "=r" (result) ); + __ASM volatile (""); + return(result); +#else + return(0); +#endif +} + + +/** \brief Set FPSCR + + This function assigns the given value to the Floating Point Status/Control register. + + \param [in] fpscr Floating Point Status/Control value to set + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr) +{ +#if (__FPU_PRESENT == 1) && (__FPU_USED == 1) + /* Empty asm statement works as a scheduling barrier */ + __ASM volatile (""); + __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc"); + __ASM volatile (""); +#endif +} + +#endif /* (__CORTEX_M == 0x04) */ + + +#elif defined ( __TASKING__ ) /*------------------ TASKING Compiler --------------*/ +/* TASKING carm specific functions */ + +/* + * The CMSIS functions have been implemented as intrinsics in the compiler. + * Please use "carm -?i" to get an up to date list of all instrinsics, + * Including the CMSIS ones. + */ + +#endif + +/*@} end of CMSIS_Core_RegAccFunctions */ + + +#endif /* __CORE_CMFUNC_H */ diff --git a/kernel/arch/arm/cortex-m3/keil/cmsis/core_cmInstr.h b/kernel/arch/arm/cortex-m3/keil/cmsis/core_cmInstr.h new file mode 100755 index 00000000..6c9e546f --- /dev/null +++ b/kernel/arch/arm/cortex-m3/keil/cmsis/core_cmInstr.h @@ -0,0 +1,688 @@ +/**************************************************************************//** + * @file core_cmInstr.h + * @brief CMSIS Cortex-M Core Instruction Access Header File + * @version V3.20 + * @date 05. March 2013 + * + * @note + * + ******************************************************************************/ +/* Copyright (c) 2009 - 2013 ARM LIMITED + + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - 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. + - Neither the name of ARM 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 COPYRIGHT HOLDERS AND 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 __CORE_CMINSTR_H +#define __CORE_CMINSTR_H + +#include +/* ########################## Core Instruction Access ######################### */ +/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface + Access to dedicated instructions + @{ +*/ + +#if defined ( __CC_ARM ) /*------------------RealView Compiler -----------------*/ +/* ARM armcc specific functions */ + +#if (__ARMCC_VERSION < 400677) + #error "Please use ARM Compiler Toolchain V4.0.677 or later!" +#endif + + +/** \brief No Operation + + No Operation does nothing. This instruction can be used for code alignment purposes. + */ +#define __NOP __nop + + +/** \brief Wait For Interrupt + + Wait For Interrupt is a hint instruction that suspends execution + until one of a number of events occurs. + */ +#define __WFI __wfi + + +/** \brief Wait For Event + + Wait For Event is a hint instruction that permits the processor to enter + a low-power state until one of a number of events occurs. + */ +#define __WFE __wfe + + +/** \brief Send Event + + Send Event is a hint instruction. It causes an event to be signaled to the CPU. + */ +#define __SEV __sev + + +/** \brief Instruction Synchronization Barrier + + Instruction Synchronization Barrier flushes the pipeline in the processor, + so that all instructions following the ISB are fetched from cache or + memory, after the instruction has been completed. + */ +#define __ISB() __isb(0xF) + + +/** \brief Data Synchronization Barrier + + This function acts as a special kind of Data Memory Barrier. + It completes when all explicit memory accesses before this instruction complete. + */ +#define __DSB() __dsb(0xF) + + +/** \brief Data Memory Barrier + + This function ensures the apparent order of the explicit memory operations before + and after the instruction, without ensuring their completion. + */ +#define __DMB() __dmb(0xF) + + +/** \brief Reverse byte order (32 bit) + + This function reverses the byte order in integer value. + + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV __rev + + +/** \brief Reverse byte order (16 bit) + + This function reverses the byte order in two unsigned short values. + + \param [in] value Value to reverse + \return Reversed value + */ +#ifndef __NO_EMBEDDED_ASM +__attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t value) +{ + rev16 r0, r0 + bx lr +} +#endif + +/** \brief Reverse byte order in signed short value + + This function reverses the byte order in a signed short value with sign extension to integer. + + \param [in] value Value to reverse + \return Reversed value + */ +#ifndef __NO_EMBEDDED_ASM +__attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int32_t __REVSH(int32_t value) +{ + revsh r0, r0 + bx lr +} +#endif + + +/** \brief Rotate Right in unsigned value (32 bit) + + This function Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. + + \param [in] value Value to rotate + \param [in] value Number of Bits to rotate + \return Rotated value + */ +#define __ROR __ror + + +/** \brief Breakpoint + + This function causes the processor to enter Debug state. + Debug tools can use this to investigate system state when the instruction at a particular address is reached. + + \param [in] value is ignored by the processor. + If required, a debugger can use it to store additional information about the breakpoint. + */ +#define __BKPT(value) __breakpoint(value) + + +#if (__CORTEX_M >= 0x03) + +/** \brief Reverse bit order of value + + This function reverses the bit order of the given value. + + \param [in] value Value to reverse + \return Reversed value + */ +#define __RBIT __rbit + + +/** \brief LDR Exclusive (8 bit) + + This function performs a exclusive LDR command for 8 bit value. + + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#define __LDREXB(ptr) ((uint8_t ) __ldrex(ptr)) + + +/** \brief LDR Exclusive (16 bit) + + This function performs a exclusive LDR command for 16 bit values. + + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#define __LDREXH(ptr) ((uint16_t) __ldrex(ptr)) + + +/** \brief LDR Exclusive (32 bit) + + This function performs a exclusive LDR command for 32 bit values. + + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#define __LDREXW(ptr) ((uint32_t ) __ldrex(ptr)) + + +/** \brief STR Exclusive (8 bit) + + This function performs a exclusive STR command for 8 bit values. + + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXB(value, ptr) __strex(value, ptr) + + +/** \brief STR Exclusive (16 bit) + + This function performs a exclusive STR command for 16 bit values. + + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXH(value, ptr) __strex(value, ptr) + + +/** \brief STR Exclusive (32 bit) + + This function performs a exclusive STR command for 32 bit values. + + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXW(value, ptr) __strex(value, ptr) + + +/** \brief Remove the exclusive lock + + This function removes the exclusive lock which is created by LDREX. + + */ +#define __CLREX __clrex + + +/** \brief Signed Saturate + + This function saturates a signed value. + + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +#define __SSAT __ssat + + +/** \brief Unsigned Saturate + + This function saturates an unsigned value. + + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +#define __USAT __usat + + +/** \brief Count leading zeros + + This function counts the number of leading zeros of a data value. + + \param [in] value Value to count the leading zeros + \return number of leading zeros in value + */ +#define __CLZ __clz + +#endif /* (__CORTEX_M >= 0x03) */ + + + +#elif defined ( __ICCARM__ ) /*------------------ ICC Compiler -------------------*/ +/* IAR iccarm specific functions */ + +#include + + +#elif defined ( __TMS470__ ) /*---------------- TI CCS Compiler ------------------*/ +/* TI CCS specific functions */ + +#include + + +#elif defined ( __GNUC__ ) /*------------------ GNU Compiler ---------------------*/ +/* GNU gcc specific functions */ + +/* Define macros for porting to both thumb1 and thumb2. + * For thumb1, use low register (r0-r7), specified by constrant "l" + * Otherwise, use general registers, specified by constrant "r" */ +#if defined (__thumb__) && !defined (__thumb2__) +#define __CMSIS_GCC_OUT_REG(r) "=l" (r) +#define __CMSIS_GCC_USE_REG(r) "l" (r) +#else +#define __CMSIS_GCC_OUT_REG(r) "=r" (r) +#define __CMSIS_GCC_USE_REG(r) "r" (r) +#endif + +/** \brief No Operation + + No Operation does nothing. This instruction can be used for code alignment purposes. + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __NOP(void) +{ + __ASM volatile ("nop"); +} + + +/** \brief Wait For Interrupt + + Wait For Interrupt is a hint instruction that suspends execution + until one of a number of events occurs. + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __WFI(void) +{ + __ASM volatile ("wfi"); +} + + +/** \brief Wait For Event + + Wait For Event is a hint instruction that permits the processor to enter + a low-power state until one of a number of events occurs. + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __WFE(void) +{ + __ASM volatile ("wfe"); +} + + +/** \brief Send Event + + Send Event is a hint instruction. It causes an event to be signaled to the CPU. + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __SEV(void) +{ + __ASM volatile ("sev"); +} + + +/** \brief Instruction Synchronization Barrier + + Instruction Synchronization Barrier flushes the pipeline in the processor, + so that all instructions following the ISB are fetched from cache or + memory, after the instruction has been completed. + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __ISB(void) +{ + __ASM volatile ("isb"); +} + + +/** \brief Data Synchronization Barrier + + This function acts as a special kind of Data Memory Barrier. + It completes when all explicit memory accesses before this instruction complete. + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __DSB(void) +{ + __ASM volatile ("dsb"); +} + + +/** \brief Data Memory Barrier + + This function ensures the apparent order of the explicit memory operations before + and after the instruction, without ensuring their completion. + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __DMB(void) +{ + __ASM volatile ("dmb"); +} + + +/** \brief Reverse byte order (32 bit) + + This function reverses the byte order in integer value. + + \param [in] value Value to reverse + \return Reversed value + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __REV(uint32_t value) +{ +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) + return __builtin_bswap32(value); +#else + uint32_t result; + + __ASM volatile ("rev %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return(result); +#endif +} + + +/** \brief Reverse byte order (16 bit) + + This function reverses the byte order in two unsigned short values. + + \param [in] value Value to reverse + \return Reversed value + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __REV16(uint32_t value) +{ + uint32_t result; + + __ASM volatile ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return(result); +} + + +/** \brief Reverse byte order in signed short value + + This function reverses the byte order in a signed short value with sign extension to integer. + + \param [in] value Value to reverse + \return Reversed value + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE int32_t __REVSH(int32_t value) +{ +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + return (short)__builtin_bswap16(value); +#else + uint32_t result; + + __ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return(result); +#endif +} + + +/** \brief Rotate Right in unsigned value (32 bit) + + This function Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. + + \param [in] value Value to rotate + \param [in] value Number of Bits to rotate + \return Rotated value + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint32_t op2) +{ + return (op1 >> op2) | (op1 << (32 - op2)); +} + + +/** \brief Breakpoint + + This function causes the processor to enter Debug state. + Debug tools can use this to investigate system state when the instruction at a particular address is reached. + + \param [in] value is ignored by the processor. + If required, a debugger can use it to store additional information about the breakpoint. + */ +#define __BKPT(value) __ASM volatile ("bkpt "#value) + + +#if (__CORTEX_M >= 0x03) + +/** \brief Reverse bit order of value + + This function reverses the bit order of the given value. + + \param [in] value Value to reverse + \return Reversed value + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __RBIT(uint32_t value) +{ + uint32_t result; + + __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) ); + return(result); +} + + +/** \brief LDR Exclusive (8 bit) + + This function performs a exclusive LDR command for 8 bit value. + + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint8_t __LDREXB(volatile uint8_t *addr) +{ + uint32_t result; + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + __ASM volatile ("ldrexb %0, %1" : "=r" (result) : "Q" (*addr) ); +#else + /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not + accepted by assembler. So has to use following less efficient pattern. + */ + __ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); +#endif + return(result); +} + + +/** \brief LDR Exclusive (16 bit) + + This function performs a exclusive LDR command for 16 bit values. + + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint16_t __LDREXH(volatile uint16_t *addr) +{ + uint32_t result; + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + __ASM volatile ("ldrexh %0, %1" : "=r" (result) : "Q" (*addr) ); +#else + /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not + accepted by assembler. So has to use following less efficient pattern. + */ + __ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); +#endif + return(result); +} + + +/** \brief LDR Exclusive (32 bit) + + This function performs a exclusive LDR command for 32 bit values. + + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __LDREXW(volatile uint32_t *addr) +{ + uint32_t result; + + __ASM volatile ("ldrex %0, %1" : "=r" (result) : "Q" (*addr) ); + return(result); +} + + +/** \brief STR Exclusive (8 bit) + + This function performs a exclusive STR command for 8 bit values. + + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __STREXB(uint8_t value, volatile uint8_t *addr) +{ + uint32_t result; + + __ASM volatile ("strexb %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) ); + return(result); +} + + +/** \brief STR Exclusive (16 bit) + + This function performs a exclusive STR command for 16 bit values. + + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __STREXH(uint16_t value, volatile uint16_t *addr) +{ + uint32_t result; + + __ASM volatile ("strexh %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) ); + return(result); +} + + +/** \brief STR Exclusive (32 bit) + + This function performs a exclusive STR command for 32 bit values. + + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __STREXW(uint32_t value, volatile uint32_t *addr) +{ + uint32_t result; + + __ASM volatile ("strex %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) ); + return(result); +} + + +/** \brief Remove the exclusive lock + + This function removes the exclusive lock which is created by LDREX. + + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __CLREX(void) +{ + __ASM volatile ("clrex" ::: "memory"); +} + + +/** \brief Signed Saturate + + This function saturates a signed value. + + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +#define __SSAT(ARG1,ARG2) \ +({ \ + uint32_t __RES, __ARG1 = (ARG1); \ + __ASM ("ssat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ + __RES; \ + }) + + +/** \brief Unsigned Saturate + + This function saturates an unsigned value. + + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +#define __USAT(ARG1,ARG2) \ +({ \ + uint32_t __RES, __ARG1 = (ARG1); \ + __ASM ("usat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ + __RES; \ + }) + + +/** \brief Count leading zeros + + This function counts the number of leading zeros of a data value. + + \param [in] value Value to count the leading zeros + \return number of leading zeros in value + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint8_t __CLZ(uint32_t value) +{ + uint32_t result; + + __ASM volatile ("clz %0, %1" : "=r" (result) : "r" (value) ); + return(result); +} + +#endif /* (__CORTEX_M >= 0x03) */ + + + + +#elif defined ( __TASKING__ ) /*------------------ TASKING Compiler --------------*/ +/* TASKING carm specific functions */ + +/* + * The CMSIS functions have been implemented as intrinsics in the compiler. + * Please use "carm -?i" to get an up to date list of all intrinsics, + * Including the CMSIS ones. + */ + +#endif + +/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ + +#endif /* __CORE_CMINSTR_H */ diff --git a/kernel/arch/arm/cortex-m4/iar/los_hw.h b/kernel/arch/arm/cortex-m3/keil/los_context.h similarity index 95% rename from kernel/arch/arm/cortex-m4/iar/los_hw.h rename to kernel/arch/arm/cortex-m3/keil/los_context.h index 1ee808dc..d3ec0bd9 100755 --- a/kernel/arch/arm/cortex-m4/iar/los_hw.h +++ b/kernel/arch/arm/cortex-m3/keil/los_context.h @@ -37,7 +37,6 @@ #ifndef _LOS_HW_H #define _LOS_HW_H -#include "los_base.h" #ifdef __cplusplus #if __cplusplus extern "C" { diff --git a/kernel/arch/arm/cortex-m3/keil/los_dispatch.S b/kernel/arch/arm/cortex-m3/keil/los_dispatch.S new file mode 100755 index 00000000..05f0391b --- /dev/null +++ b/kernel/arch/arm/cortex-m3/keil/los_dispatch.S @@ -0,0 +1,163 @@ +; +; 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. +; + + PRESERVE8 + + EXPORT LOS_IntLock + EXPORT LOS_IntUnLock + EXPORT LOS_IntRestore + EXPORT LOS_StartToRun + EXPORT osTaskSchedule + EXPORT osPendSV + + IMPORT g_losTask + IMPORT g_taskSwitchHook + IMPORT g_taskScheduled + +OS_NVIC_INT_CTRL EQU 0xE000ED04 +OS_NVIC_SYSPRI2 EQU 0xE000ED20 +OS_NVIC_PENDSV_PRI EQU 0xF0F00000 +OS_NVIC_PENDSVSET EQU 0x10000000 +OS_TASK_STATUS_RUNNING EQU 0x0010 + + AREA |.text|, CODE, READONLY + THUMB + REQUIRE8 + +LOS_StartToRun + LDR R4, =OS_NVIC_SYSPRI2 + LDR R5, =OS_NVIC_PENDSV_PRI + STR R5, [R4] + + LDR R0, =g_taskScheduled + MOV R1, #1 + STR R1, [R0] + + MOV R0, #2 + MSR CONTROL, R0 + + + LDR R0, =g_losTask + LDR R2, [R0, #4] + LDR R0, =g_losTask + STR R2, [R0] + + LDR R3, =g_losTask + LDR R0, [R3] + LDRH R7, [R0 , #4] + MOV R8, #OS_TASK_STATUS_RUNNING + ORR R7, R7, R8 + STRH R7, [R0 , #4] + + LDR R12, [R0] + ;ADD R12, R12, #100 + ADD R12, R12, #36 + + LDMFD R12!, {R0-R7} + ;ADD R12, R12, #72 + MSR PSP, R12 + ;VPUSH S0; + ;VPOP S0; + + MOV LR, R5 + ;MSR xPSR, R7 + + CPSIE I + BX R6 + + +LOS_IntLock + MRS R0, PRIMASK + CPSID I + BX LR + +LOS_IntUnLock + MRS R0, PRIMASK + CPSIE I + BX LR + +LOS_IntRestore + MSR PRIMASK, R0 + BX LR + +osTaskSchedule + LDR R0, =OS_NVIC_INT_CTRL + LDR R1, =OS_NVIC_PENDSVSET + STR R1, [R0] + BX LR + +osPendSV + MRS R12, PRIMASK + CPSID I + + LDR R2, =g_taskSwitchHook + LDR R2, [R2] + CBZ R2, TaskSwitch + PUSH {R12, LR} + BLX R2 + POP {R12, LR} + +TaskSwitch + MRS R0, PSP + + STMFD R0!, {R4-R12} + ;VSTMDB R0!, {D8-D15} + + LDR R5, =g_losTask + LDR R6, [R5] + STR R0, [R6] + + + LDRH R7, [R6 , #4] + MOV R8,#OS_TASK_STATUS_RUNNING + BIC R7, R7, R8 + STRH R7, [R6 , #4] + + + LDR R0, =g_losTask + LDR R0, [R0, #4] + STR R0, [R5] + + + LDRH R7, [R0 , #4] + MOV R8, #OS_TASK_STATUS_RUNNING + ORR R7, R7, R8 + STRH R7, [R0 , #4] + + LDR R1, [R0] + ;VLDMIA R1!, {D8-D15} + LDMFD R1!, {R4-R12} + MSR PSP, R1 + + MSR PRIMASK, R12 + BX LR + + END diff --git a/kernel/arch/arm/cortex-m3/keil/los_hw.c b/kernel/arch/arm/cortex-m3/keil/los_hw.c new file mode 100755 index 00000000..365a08ad --- /dev/null +++ b/kernel/arch/arm/cortex-m3/keil/los_hw.c @@ -0,0 +1,149 @@ +/* + * 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_task.h" +#include "securec.h" +#include "ARMCM3.h" +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +/* **************************************************************************** + Function : OsTaskExit + Description : Task exit function + Input : None + Output : None + Return : None + **************************************************************************** */ +LITE_OS_SEC_TEXT_MINOR VOID OsTaskExit(VOID) +{ + LOS_IntLock(); + for(;;); +} + +/* **************************************************************************** + Function : OsTskStackInit + Description : Task stack initialization function + Input : taskID --- TaskID + stackSize --- Total size of the stack + topStack --- Top of task's stack + Output : None + Return : Context pointer + **************************************************************************** */ +LITE_OS_SEC_TEXT_INIT VOID *OsTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack) +{ + TaskContext *context = NULL; + errno_t result; + + /* initialize the task stack, write magic num to stack top */ + result = memset_s(topStack, stackSize, (INT32)(OS_TASK_STACK_INIT & 0xFF), stackSize); + if (result != EOK) { + printf("memset_s is failed:%s[%d]\r\n", __FUNCTION__, __LINE__); + } + *((UINT32 *)(topStack)) = OS_TASK_MAGIC_WORD; + + context = (TaskContext *)(((UINTPTR)topStack + stackSize) - sizeof(TaskContext)); + +#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined(__FPU_USED) && (__FPU_USED == 1U))) + context->S16 = 0xAA000010; + context->S17 = 0xAA000011; + context->S18 = 0xAA000012; + context->S19 = 0xAA000013; + context->S20 = 0xAA000014; + context->S21 = 0xAA000015; + context->S22 = 0xAA000016; + context->S23 = 0xAA000017; + context->S24 = 0xAA000018; + context->S25 = 0xAA000019; + context->S26 = 0xAA00001A; + context->S27 = 0xAA00001B; + context->S28 = 0xAA00001C; + context->S29 = 0xAA00001D; + context->S30 = 0xAA00001E; + context->S31 = 0xAA00001F; + context->S0 = 0xAA000000; + context->S1 = 0xAA000001; + context->S2 = 0xAA000002; + context->S3 = 0xAA000003; + context->S4 = 0xAA000004; + context->S5 = 0xAA000005; + context->S6 = 0xAA000006; + context->S7 = 0xAA000007; + context->S8 = 0xAA000008; + context->S9 = 0xAA000009; + context->S10 = 0xAA00000A; + context->S11 = 0xAA00000B; + context->S12 = 0xAA00000C; + context->S13 = 0xAA00000D; + context->S14 = 0xAA00000E; + context->S15 = 0xAA00000F; + context->FPSCR = 0x00000000; + context->NO_NAME = 0xAA000011; +#endif + + context->uwR4 = 0x04040404L; + context->uwR5 = 0x05050505L; + context->uwR6 = 0x06060606L; + context->uwR7 = 0x07070707L; + context->uwR8 = 0x08080808L; + context->uwR9 = 0x09090909L; + context->uwR10 = 0x10101010L; + context->uwR11 = 0x11111111L; + context->uwPriMask = 0; + context->uwR0 = taskID; + context->uwR1 = 0x01010101L; + context->uwR2 = 0x02020202L; + context->uwR3 = 0x03030303L; + context->uwR12 = 0x12121212L; + context->uwLR = (UINT32)(UINTPTR)OsTaskExit; + context->uwPC = (UINT32)(UINTPTR)OsTaskEntry; + context->uwxPSR = 0x01000000L; + + return (VOID *)context; +} + +LITE_OS_SEC_TEXT_INIT VOID OsEnterSleep(VOID) +{ + __DSB(); + __WFI(); + __ISB(); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cplusplus */ +#endif /* __cplusplus */ + + diff --git a/kernel/arch/arm/cortex-m3/keil/los_hw_exc.S b/kernel/arch/arm/cortex-m3/keil/los_hw_exc.S new file mode 100755 index 00000000..48cc76be --- /dev/null +++ b/kernel/arch/arm/cortex-m3/keil/los_hw_exc.S @@ -0,0 +1,287 @@ +; +; 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. +; + + PRESERVE8 + AREA |.text|, CODE, READONLY + THUMB + + EXPORT OsExcNMI + EXPORT OsExcHardFault + EXPORT OsExcMemFault + EXPORT OsExcBusFault + EXPORT OsExcUsageFault + EXPORT OsExcSvcCall + + IMPORT OsExcHandleEntry + ;IMPORT g_vuwLosFlag + ;IMPORT g_curNestCount + IMPORT g_uwExcTbl + IMPORT g_taskScheduled + +OS_FLG_BGD_ACTIVE EQU 0x0002 + +OS_EXC_CAUSE_NMI EQU 16 +OS_EXC_CAUSE_HARDFAULT EQU 17 + +HF_DEBUGEVT EQU 20 +HF_VECTBL EQU 21 + +FLAG_ADDR_VALID EQU 0x10000 +FLAG_HWI_ACTIVE EQU 0x20000 +FLAG_NO_FLOAT EQU 0x10000000 + +OS_NVIC_FSR EQU 0xE000ED28 ;include BusFault/MemFault/UsageFault State Regeister +OS_NVIC_HFSR EQU 0xE000ED2C ;HardFault State Regeister +OS_NVIC_BFAR EQU 0xE000ED38 +OS_NVIC_MMAR EQU 0xE000ED34 +OS_NVIC_ACT_BASE EQU 0xE000E300 +OS_NVIC_SHCSRS EQU 0xE000ED24 +OS_NVIC_SHCSR_MASK EQU 0xC00 + +OsExcNMI + MOV R0, #OS_EXC_CAUSE_NMI + MOV R1, #0 + B osExcDispatch + +OsExcHardFault + MOV R0, #OS_EXC_CAUSE_HARDFAULT + LDR R2, =OS_NVIC_HFSR + LDR R2, [R2] + + MOV R1, #HF_DEBUGEVT + ORR R0, R0, R1, LSL #0x8 + TST R2, #0x80000000 + BNE osExcDispatch ; DEBUGEVT + + AND R0, R0 , #0x000000FF + MOV R1, #HF_VECTBL + ORR R0, R0, R1, LSL #0x8 + TST R2, #0x00000002 + BNE osExcDispatch ; VECTBL + + ;if not DEBUGEVT and VECTBL then is FORCED + AND R0, R0, #0x000000FF + + LDR R2, =OS_NVIC_FSR + LDR R2, [R2] + + TST R2, #0x8000 ; BFARVALID + BNE _HFBusFault ; BusFault + + TST R2, #0x80 ; MMARVALID + BNE _HFMemFault ; MemFault + + MOV R12,#0 + B osHFExcCommonBMU + +_HFBusFault + LDR R1, =OS_NVIC_BFAR + LDR R1, [R1] + MOV R12, #FLAG_ADDR_VALID + B osHFExcCommonBMU + +_HFMemFault + LDR R1, =OS_NVIC_MMAR + LDR R1, [R1] + MOV R12, #FLAG_ADDR_VALID + +osHFExcCommonBMU + CLZ R2, R2 + LDR R3, =g_uwExcTbl + ADD R3, R3, R2 + LDRB R2, [R3] + ORR R0, R0, R2, LSL #0x8 + ORR R0, R0 ,R12 + B osExcDispatch + +OsExcSvcCall + TST LR, #0x4 + ITE EQ + MRSEQ R0, MSP + MRSNE R0, PSP + LDR R1, [R0,#24] + LDRB R0, [R1,#-2] + MOV R1, #0 + B osExcDispatch + +OsExcBusFault + LDR R0, =OS_NVIC_FSR + LDR R0, [R0] + + TST R0, #0x8000 ; BFARVALID + BEQ _ExcBusNoADDR + LDR R1, =OS_NVIC_BFAR + LDR R1, [R1] + MOV R12, #FLAG_ADDR_VALID + AND R0, R0, #0x1F00 + + B osExcCommonBMU + +_ExcBusNoADDR + MOV R12,#0 + B osExcCommonBMU + +OsExcMemFault + LDR R0, =OS_NVIC_FSR + LDR R0, [R0] + + TST R0, #0x80 ; MMARVALID + BEQ _ExcMemNoADDR + LDR R1, =OS_NVIC_MMAR + LDR R1, [R1] + MOV R12, #FLAG_ADDR_VALID + AND R0, R0, #0x1B + + B osExcCommonBMU + +_ExcMemNoADDR + MOV R12,#0 + B osExcCommonBMU + +OsExcUsageFault + LDR R0, =OS_NVIC_FSR + LDR R0, [R0] + + MOV R1, #0x030F + LSL R1, R1, #16 + AND R0, R0, R1 + MOV R12, #0 + +osExcCommonBMU + CLZ R0, R0 + LDR R3, =g_uwExcTbl + ADD R3, R3, R0 + LDRB R0, [R3] + ORR R0, R0, R12 + +; R0 -- EXCCAUSE(bit 16 is 1 if EXCADDR valid), R1 -- EXCADDR +osExcDispatch + LDR R2, =OS_NVIC_ACT_BASE + MOV R12, #8 ; R12 is hwi check loop counter + +_hwiActiveCheck + LDR R3, [R2] ; R3 store active hwi register when exc + CMP R3, #0 + BEQ _hwiActiveCheckNext + + ; exc occured in IRQ + ORR R0, R0, #FLAG_HWI_ACTIVE + RBIT R2, R3 + CLZ R2, R2 + AND R12, R12, #1 + ADD R2, R2, R12, LSL #5 ; calculate R2 (hwi number) as uwPid + +_ExcInMSP + CMP LR, #0XFFFFFFED + BNE _NoFloatInMsp + ADD R3, R13, #104 + PUSH {R3} + MRS R12, PRIMASK ; store message-->exc: disable int? + PUSH {R4-R12} ; store message-->exc: {R4-R12} + ;VPUSH {D8-D15} + B _handleEntry + +_NoFloatInMsp + ADD R3, R13, #32 + PUSH {R3} ; save IRQ SP ; store message-->exc: MSP(R13) + + MRS R12, PRIMASK ; store message-->exc: disable int? + PUSH {R4-R12} ; store message-->exc: {R4-R12} + ORR R0, R0, #FLAG_NO_FLOAT + B _handleEntry + +_hwiActiveCheckNext + ADD R2, R2, #4 ; next NVIC ACT ADDR + SUBS R12, R12, #1 + BNE _hwiActiveCheck + + ;/*NMI interrupt excption*/ + LDR R2, =OS_NVIC_SHCSRS + LDRH R2,[R2] + LDR R3,=OS_NVIC_SHCSR_MASK + AND R2, R2,R3 + CMP R2,#0 + BNE _ExcInMSP + ; exc occured in Task or Init or exc + ; reserved for register info from task stack + + LDR R2, =g_taskScheduled + LDR R2, [R2] + TST R2, #1 ; OS_FLG_BGD_ACTIVE + BEQ _ExcInMSP ; if exc occured in Init then branch + + + CMP LR, #0xFFFFFFED ;auto push floating registers + BNE _NoFloatInPsp + + ; exc occured in Task + MOV R2, R13 + SUB R13, #96 ; add 8 Bytes reg(for STMFD) + + MRS R3, PSP + ADD R12, R3, #104 + PUSH {R12} ; save task SP + + MRS R12, PRIMASK + PUSH {R4-R12} + ;VPUSH {D8-D15} + + ; copy auto saved task register + + LDMFD R3!, {R4-R11} ; R4-R11 store PSP reg(auto push when exc in task) + ;VLDMIA R3!, {D8-D15} + ;VSTMDB R2!, {D8-D15} + STMFD R2!, {R4-R11} + B _handleEntry + +_NoFloatInPsp + MOV R2, R13 ;no auto push floating registers + SUB R13, #32 ; add 8 Bytes reg(for STMFD) + + MRS R3, PSP + ADD R12, R3, #32 + PUSH {R12} ; save task SP + + MRS R12, PRIMASK + PUSH {R4-R12} + + LDMFD R3, {R4-R11} ; R4-R11 store PSP reg(auto push when exc in task) + STMFD R2!, {R4-R11} + ORR R0, R0, #FLAG_NO_FLOAT + +_handleEntry + MOV R3, R13 ; R13:the 4th param + CPSID I + CPSID F + B OsExcHandleEntry + + NOP + END diff --git a/kernel/arch/arm/cortex-m3/keil/los_hw_tick.c b/kernel/arch/arm/cortex-m3/keil/los_hw_tick.c new file mode 100755 index 00000000..eaa5eb84 --- /dev/null +++ b/kernel/arch/arm/cortex-m3/keil/los_hw_tick.c @@ -0,0 +1,267 @@ +/* + * 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_tick.h" +#include "los_interrupt.h" +#include "ARMCM3.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 +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) +{ + UINT32 ret; + + if ((OS_SYS_CLOCK == 0) || + (LOSCFG_BASE_CORE_TICK_PER_SECOND == 0) || + (LOSCFG_BASE_CORE_TICK_PER_SECOND > OS_SYS_CLOCK)) { + return LOS_ERRNO_TICK_CFG_INVALID; + } + +#if (OS_HWI_WITH_ARG == YES) + OsSetVector(SysTick_IRQn, (HWI_PROC_FUNC)OsTickHandler, NULL); +#else + OsSetVector(SysTick_IRQn, OsTickHandler); +#endif + + g_cyclesPerTick = OS_SYS_CLOCK / LOSCFG_BASE_CORE_TICK_PER_SECOND; + g_ullTickCount = 0; + + ret = SysTick_Config(g_cyclesPerTick); + if (ret == 1) { + return LOS_ERRNO_TICK_PER_SEC_TOO_SMALL; + } + + 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 +Description : Get System cycle count +Input : none +output : none +return : hwCycle --- the system cycle count +**************************************************************************** */ +LITE_OS_SEC_TEXT_MINOR UINT32 LOS_SysTickCurrCycleGet(VOID) +{ + UINT32 hwCycle; + UINTPTR intSave; + + intSave = LOS_IntLock(); + hwCycle = SysTick->VAL; + + /* tick has come, but may interrupt environment, not counting the Tick interrupt response, to do +1 */ + if ((SCB->ICSR & TICK_CHECK) != 0) { + hwCycle = SysTick->VAL; + hwCycle += g_cyclesPerTick; + } + + LOS_IntRestore(intSave); + + return hwCycle; +} + +/* **************************************************************************** +Function : LOS_GetCpuCycle +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) +{ + UINT64 swTick; + UINT64 cycle; + UINT32 hwCycle; + UINTPTR intSave; + + intSave = LOS_IntLock(); + + swTick = g_ullTickCount; + hwCycle = SysTick->VAL; + + /* tick has come, but may interrupt environment, not counting the Tick interrupt response, to do +1 */ + if ((SCB->ICSR & TICK_CHECK) != 0) { + hwCycle = SysTick->VAL; + swTick++; + } + + cycle = (((swTick) * g_cyclesPerTick) + (g_cyclesPerTick - hwCycle)); + + *cntHi = cycle >> SHIFT_32_BIT; + *cntLo = cycle & CYCLE_CHECK; + + LOS_IntRestore(intSave); + + return; +} + +/* **************************************************************************** +Function : LOS_GetSystickCycle +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) +{ + UINT64 swTick; + UINT64 cycle; + UINT32 hwCycle; + UINTPTR intSave; + UINT32 systickLoad; + UINT32 systickCur; + + intSave = LOS_IntLock(); + + swTick = g_ullTickCount; + + systickLoad = SysTick->LOAD; + systickCur = SysTick->VAL; + if (systickLoad < systickCur) { + LOS_IntRestore(intSave); + return; + } + hwCycle = systickLoad - systickCur; + + /* tick has come, but may interrupt environment, not counting the Tick interrupt response, to do +1 */ + if ((SCB->ICSR & TICK_CHECK) != 0) { + hwCycle = systickLoad - systickCur; + swTick++; + } + + cycle = hwCycle + swTick * systickLoad; + *cntHi = cycle >> SHIFT_32_BIT; + *cntLo = cycle & CYCLE_CHECK; + + LOS_IntRestore(intSave); + + 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) +{ + SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk; +} + +VOID LOS_TickUnlock(VOID) +{ + SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk; +} + +BOOL LOS_GetSysSleepFlag(VOID) +{ + return g_sysSleepFlag; +} + +VOID LOS_ClearSysSleepFlag(VOID) +{ + g_sysSleepFlag = FALSE; +} + +VOID LOS_EnterSleep(LOS_SysSleepEnum sleep) +{ + __DSB(); + __WFI(); + __ISB(); +} + +VOID LOS_SystemWakeup(UINT32 hwiIndex) +{ +} +//extern unsigned int SystemCoreClock; +void LOS_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; + } +#endif +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/kernel/arch/arm/cortex-m3/keil/los_interrupt.c b/kernel/arch/arm/cortex-m3/keil/los_interrupt.c new file mode 100755 index 00000000..bfc5102a --- /dev/null +++ b/kernel/arch/arm/cortex-m3/keil/los_interrupt.c @@ -0,0 +1,450 @@ +/* + * 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_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 +extern "C" { +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +/*lint -save -e40 -e522 -e533*/ +__weak VOID SysTickHandler(VOID) +{ + return; +} + +UINT32 g_vuwIntCount = 0; +/*lint -restore*/ +#ifdef __ICCARM__ +#pragma location = ".data.vector" +#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 +}; + + +#if (OS_HWI_WITH_ARG == YES) +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 + Description : Get a interrupt number + Input : None + Output : None + Return : Interrupt Indexes number + **************************************************************************** */ +LITE_OS_SEC_TEXT_MINOR UINT32 OsIntNumGet(VOID) +{ + return __get_IPSR(); +} + +/* **************************************************************************** + Function : OsHwiDefaultHandler + Description : default handler of the hardware interrupt + Input : None + Output : None + Return : None + **************************************************************************** */ +/*lint -e529*/ +LITE_OS_SEC_TEXT_MINOR VOID OsHwiDefaultHandler(VOID) +{ + UINT32 irqNum = OsIntNumGet(); + PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum); + while (1) {} +} + +/* **************************************************************************** + Function : OsInterrupt + Description : Hardware interrupt entry function + Input : None + Output : None + Return : None + **************************************************************************** */ +LITE_OS_SEC_TEXT VOID OsInterrupt(VOID) +{ + UINT32 hwiIndex; + UINT32 intSave; + +#if (LOSCFG_KERNEL_RUNSTOP == YES) + SCB->SCR &= (UINT32) ~((UINT32)SCB_SCR_SLEEPDEEP_Msk); +#endif + + intSave = LOS_IntLock(); + + g_vuwIntCount++; + + LOS_IntRestore(intSave); + + hwiIndex = OsIntNumGet(); +#if (LOSCFG_KERNEL_TICKLESS == YES) + osUpdateKernelTickCount(hwiIndex); +#endif + +#if (OS_HWI_WITH_ARG == YES) + if (g_hwiSlaveForm[hwiIndex].pfnHandler != 0) { + g_hwiSlaveForm[hwiIndex].pfnHandler((VOID *)g_hwiSlaveForm[hwiIndex].pParm); + } +#else + if (g_hwiSlaveForm[hwiIndex] != 0) { + g_hwiSlaveForm[hwiIndex](); + } +#endif + intSave = LOS_IntLock(); + g_vuwIntCount--; + LOS_IntRestore(intSave); +} + +/* **************************************************************************** + Function : LOS_HwiCreate + Description : create hardware interrupt + Input : hwiNum --- hwi num to create + hwiPrio --- priority of the hwi + mode --- unused + handler --- hwi handler + arg --- param of the hwi handler + Output : None + Return : LOS_OK on success or error code on failure + **************************************************************************** */ +LITE_OS_SEC_TEXT_INIT UINT32 LOS_HwiCreate(HWI_HANDLE_T hwiNum, + HWI_PRIOR_T hwiPrio, + HWI_MODE_T mode, + HWI_PROC_FUNC handler, + HWI_ARG_T arg) +{ + UINTPTR intSave; + + if (handler == NULL) { + return OS_ERRNO_HWI_PROC_FUNC_NULL; + } + + if (hwiNum >= OS_HWI_MAX_NUM) { + return OS_ERRNO_HWI_NUM_INVALID; + } + + if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)OsHwiDefaultHandler) { + return OS_ERRNO_HWI_ALREADY_CREATED; + } + + if (hwiPrio > OS_HWI_PRIO_LOWEST) { + return OS_ERRNO_HWI_PRIO_INVALID; + } + + intSave = LOS_IntLock(); +#if (OS_HWI_WITH_ARG == YES) + OsSetVector(hwiNum, handler, arg); +#else + OsSetVector(hwiNum, handler); +#endif + NVIC_EnableIRQ((IRQn_Type)hwiNum); + NVIC_SetPriority((IRQn_Type)hwiNum, hwiPrio); + + LOS_IntRestore(intSave); + + return LOS_OK; +} + +/* **************************************************************************** + Function : LOS_HwiDelete + 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) +{ + UINT32 intSave; + + if (hwiNum >= OS_HWI_MAX_NUM) { + return OS_ERRNO_HWI_NUM_INVALID; + } + + NVIC_DisableIRQ((IRQn_Type)hwiNum); + + intSave = LOS_IntLock(); + + g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsHwiDefaultHandler; + + LOS_IntRestore(intSave); + + return LOS_OK; +} + +#define OS_NVIC_INT_CTRL_SIZE 4 +#define OS_NVIC_SHCSR_SIZE 4 +#define FAULT_STATUS_REG_BIT 32 +#define USGFAULT (1 << 18) +#define BUSFAULT (1 << 17) +#define MEMFAULT (1 << 16) +#define DIV0FAULT (1 << 4) +#define HARDFAULT_IRQN (-13) + +static ExcInfoArray g_excArray[OS_EXC_TYPE_MAX]; + +UINT32 g_curNestCount = 0; +static ExcInfo g_excInfo; +static EVENT_CB_S g_excEvent; + +UINT8 g_uwExcTbl[FAULT_STATUS_REG_BIT] = { + 0, 0, 0, 0, 0, 0, OS_EXC_UF_DIVBYZERO, OS_EXC_UF_UNALIGNED, + 0, 0, 0, 0, OS_EXC_UF_NOCP, OS_EXC_UF_INVPC, OS_EXC_UF_INVSTATE, OS_EXC_UF_UNDEFINSTR, + 0, 0, 0, OS_EXC_BF_STKERR, OS_EXC_BF_UNSTKERR, OS_EXC_BF_IMPRECISERR, OS_EXC_BF_PRECISERR, OS_EXC_BF_IBUSERR, + 0, 0, 0, OS_EXC_MF_MSTKERR, OS_EXC_MF_MUNSTKERR, 0, OS_EXC_MF_DACCVIOL, OS_EXC_MF_IACCVIOL +}; + +__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 *base = NULL; + 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}; + UINT32 rgNvicLens[OS_NR_NVIC_EXC_DUMP_Types] = {OS_NVIC_INT_ENABLE_SIZE, OS_NVIC_INT_PEND_SIZE, + OS_NVIC_INT_ACT_SIZE, OS_NVIC_INT_PRI_SIZE, OS_NVIC_EXCPRI_SIZE, OS_NVIC_SHCSR_SIZE, OS_NVIC_INT_CTRL_SIZE}; + char strRgEnable[] = "enable"; + char strRgPending[] = "pending"; + char strRgActive[] = "active"; + char strRgPriority[] = "priority"; + char strRgException[] = "exception"; + char strRgShcsr[] = "shcsr"; + char strRgIntCtrl[] = "control"; + char *strRgs[] = {strRgEnable, strRgPending, strRgActive, strRgPriority, strRgException, strRgShcsr, strRgIntCtrl}; + (VOID)index; + (VOID)excContent; + + PRINTK("OS exception NVIC dump: \n"); + for (i = 0; i < OS_NR_NVIC_EXC_DUMP_Types; i++) { + base = (UINT32 *)rgNvicBases[i]; + len = rgNvicLens[i]; + PRINTK("interrupt %s register, base address: 0x%x, size: 0x%x\n", strRgs[i], base, len); + len = (len >> 2); + for (j = 0; j < len; j++) { + PRINTK("0x%x ", *(base + j)); + } + PRINTK("\n"); + } +} + +UINT32 OsExcContextDump(UINT32 index, UINT32 *excContent) +{ + (VOID)index; + (VOID)excContent; + PRINTK("OS exception context dump:\n"); + PRINTK("Phase = 0x%x\n", g_excInfo.phase); + PRINTK("Type = 0x%x\n", g_excInfo.type); + PRINTK("FaultAddr = 0x%x\n", g_excInfo.faultAddr); + PRINTK("ThrdPid = 0x%x\n", g_excInfo.thrdPid); + PRINTK("R0 = 0x%x\n", g_excInfo.context->uwR0); + PRINTK("R1 = 0x%x\n", g_excInfo.context->uwR1); + PRINTK("R2 = 0x%x\n", g_excInfo.context->uwR2); + PRINTK("R3 = 0x%x\n", g_excInfo.context->uwR3); + PRINTK("R4 = 0x%x\n", g_excInfo.context->uwR4); + PRINTK("R5 = 0x%x\n", g_excInfo.context->uwR5); + PRINTK("R6 = 0x%x\n", g_excInfo.context->uwR6); + PRINTK("R7 = 0x%x\n", g_excInfo.context->uwR7); + PRINTK("R8 = 0x%x\n", g_excInfo.context->uwR8); + PRINTK("R9 = 0x%x\n", g_excInfo.context->uwR9); + PRINTK("R10 = 0x%x\n", g_excInfo.context->uwR10); + PRINTK("R11 = 0x%x\n", g_excInfo.context->uwR11); + PRINTK("R12 = 0x%x\n", g_excInfo.context->uwR12); + PRINTK("PriMask = 0x%x\n", g_excInfo.context->uwPriMask); + PRINTK("SP = 0x%x\n", g_excInfo.context->uwSP); + 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); +} + +VOID OsDumpMsg(VOID) +{ + UINT32 index = 0; + for (index = 0; index < (OS_EXC_TYPE_MAX - 1); index++) { + if (g_excArray[index].uwValid == FALSE) { + continue; + } + g_excArray[index].pFnExcInfoCb(index, g_excArray[index].pArg); + } +} + +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) +{ + UINT16 tmpFlag = (excType >> 16) & OS_NULL_SHORT; + g_curNestCount++; + g_vuwIntCount++; + g_excInfo.nestCnt = g_curNestCount; + + g_excInfo.type = excType & OS_NULL_SHORT; + + if (tmpFlag & OS_EXC_FLAG_FAULTADDR_VALID) { + g_excInfo.faultAddr = faultAddr; + } 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; + g_excInfo.thrdPid = pid; + } else { + g_excInfo.phase = OS_EXC_IN_TASK; + g_excInfo.thrdPid = g_losTask.runTask->taskID; + } + } else { + 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(); +} + +VOID OsExcRegister(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"); + return; + } + excInfo = &(g_excArray[type]); + excInfo->uwType = type; + excInfo->pFnExcInfoCb = func; + excInfo->pArg = arg; + excInfo->uwValid = TRUE; +} + +void OsBackTrace() +{ +} + +/* **************************************************************************** + Function : OsHwiInit + Description : initialization of the hardware interrupt + Input : None + Output : None + Return : None + **************************************************************************** */ +LITE_OS_SEC_TEXT_INIT VOID OsHwiInit() +{ + UINT32 index; + UINT32 ret; + + for (index = OS_SYS_VECTOR_CNT; index < OS_VECTOR_CNT; index++) { + g_hwiForm[index] = (HWI_PROC_FUNC)OsHwiDefaultHandler; + } + + /* 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; + + /* Interrupt vector table location */ + SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm; +#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */ + NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP); +#endif + + /* Enable USGFAULT, BUSFAULT, MEMFAULT */ + *(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT); + /* 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); + return; +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cplusplus */ +#endif /* __cplusplus */ diff --git a/kernel/arch/arm/cortex-m4/iar/los_hwi.h b/kernel/arch/arm/cortex-m3/keil/los_interrupt.h similarity index 67% rename from kernel/arch/arm/cortex-m4/iar/los_hwi.h rename to kernel/arch/arm/cortex-m3/keil/los_interrupt.h index c874ded4..a8ad5da2 100755 --- a/kernel/arch/arm/cortex-m4/iar/los_hwi.h +++ b/kernel/arch/arm/cortex-m3/keil/los_interrupt.h @@ -1,739 +1,1085 @@ -/* - * 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_hwi Hardware interrupt - * @ingroup kernel - */ -#ifndef _LOS_HWI_H -#define _LOS_HWI_H - -#include "los_base.h" -#include "los_sys.h" -#include "los_config.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -/* * - * @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: - *
  • None.
- * - * @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: - *
  • None.
- * - * @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: - *
  • None.
- * - * @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: - *
  • None.
- * - * @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: - *
  • None.
- * - * @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 - *
    - *
  • None.
  • - *
- * - * @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 - *
    - *
  • None.
  • - *
- * - * @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 - *
    - *
  • None.
  • - *
- * - * @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 - *
    - *
  • None.
  • - *
- * - * @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 - *
    - *
  • None.
  • - *
- * - * @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 VOID LOS_GetCpuCycle(UINT32 *puwCntHi, UINT32 *puwCntLo); -extern VOID LOS_GetSystickCycle(UINT32 *puwCntHi, UINT32 *puwCntLo); - -extern UINT32 LOS_SysTickCurrCycleGet(VOID); - -/* * - * @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); - - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_HWI_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" + +#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: + *
  • None.
+ * + * @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: + *
  • None.
+ * + * @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: + *
  • None.
+ * + * @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: + *
  • None.
+ * + * @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: + *
  • None.
+ * + * @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 + *
    + *
  • None.
  • + *
+ * + * @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 + *
    + *
  • None.
  • + *
+ * + * @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 + *
    + *
  • None.
  • + *
+ * + * @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 + *
    + *
  • None.
  • + *
+ * + * @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 + *
    + *
  • None.
  • + *
+ * + * @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: + *
  • None.
+ * + *@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 */ + diff --git a/kernel/arch/arm/cortex-m3/keil/los_vendor.s b/kernel/arch/arm/cortex-m3/keil/los_vendor.s new file mode 100755 index 00000000..808924a5 --- /dev/null +++ b/kernel/arch/arm/cortex-m3/keil/los_vendor.s @@ -0,0 +1,54 @@ +;/*---------------------------------------------------------------------------- +;* Huawei - LiteOS +;*---------------------------------------------------------------------------- +;* Name: LOS_VENDOR.S +;* Purpose: Thread scheduler +;* Rev.: V1.0.0 +;*---------------------------------------------------------------------------- +;* + +;* Copyright (c) 2014, Huawei Technologies Co., Ltd. +;* All rights reserved. +;* Permission to use, copy, modify, and distribute this software for any +;* purpose with or without fee is hereby granted, provided that the above +;* copyright notice and this permission notice appear in all copies. + +;*THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +;*WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +;*MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +;*ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +;*WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +;*ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +;*OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +;*---------------------------------------------------------------------------*/ + + + PRESERVE8 + + AREA RESET, CODE, READONLY + THUMB + + IMPORT ||Image$$ARM_LIB_STACKHEAP$$ZI$$Limit|| + IMPORT OsHwiDefaultHandler + + EXPORT _BootVectors + EXPORT Reset_Handler + +_BootVectors + DCD ||Image$$ARM_LIB_STACKHEAP$$ZI$$Limit|| + DCD Reset_Handler + DCD OsHwiDefaultHandler + DCD OsHwiDefaultHandler + + +Reset_Handler + CPSID I + + IMPORT LOS_HardBootInit + BL LOS_HardBootInit + IMPORT __main + LDR R0, =__main + BX R0 + + ALIGN + END diff --git a/kernel/arch/arm/cortex-m4/iar/los_context.h b/kernel/arch/arm/cortex-m4/iar/los_context.h new file mode 100755 index 00000000..d3ec0bd9 --- /dev/null +++ b/kernel/arch/arm/cortex-m4/iar/los_context.h @@ -0,0 +1,194 @@ +/* + * 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: + *
  • None.
+ * + * @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: + *
  • None.
+ * + * @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: + *
  • None.
+ * + * @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 */ + diff --git a/kernel/arch/arm/cortex-m4/iar/los_dispatch_iar.S b/kernel/arch/arm/cortex-m4/iar/los_dispatch.S similarity index 100% rename from kernel/arch/arm/cortex-m4/iar/los_dispatch_iar.S rename to kernel/arch/arm/cortex-m4/iar/los_dispatch.S diff --git a/kernel/arch/arm/cortex-m4/iar/los_exc.c b/kernel/arch/arm/cortex-m4/iar/los_exc.c deleted file mode 100755 index 977340c6..00000000 --- a/kernel/arch/arm/cortex-m4/iar/los_exc.c +++ /dev/null @@ -1,363 +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 -#include "los_exc_pri.h" -#include "los_memcheck_pri.h" -#ifdef LOSCFG_LIB_LIBC -#include "string.h" -#endif -#include "securec.h" -#include "los_printf.h" -#include "los_config.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#define EXC_INT_STATUS_LEN OS_NVIC_INT_ENABLE_SIZE + OS_NVIC_INT_PEND_SIZE + OS_NVIC_INT_ACT_SIZE + \ - OS_NVIC_INT_PRI_SIZE + OS_NVIC_EXCPRI_SIZE + OS_NVIC_SHCSR_SIZE + OS_NVIC_INT_CTRL_SIZE -#define TASK_ARRAY_INIT_VALUE 0xff -#define FAULT_STATUS_REG_BIT 32 -#define OS_NVIC_INT_CTRL_SIZE 4 -#define OS_NVIC_SHCSR_SIZE 4 -#define USGFAULT (1 << 18) -#define BUSFAULT (1 << 17) -#define MEMFAULT (1 << 16) -#define DIV0FAULT (1 << 4) -#define CORE_TYPE_CORTEX_M4 2 -#define HARDFAULT_IRQN (-13) -static VOID *g_excContent; -UINT32 g_curNestCount = 0; -ExcInfo g_excInfo; - -__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"); -} - -UINT8 g_uwExcTbl[FAULT_STATUS_REG_BIT] = { - 0, 0, 0, 0, 0, 0, OS_EXC_UF_DIVBYZERO, OS_EXC_UF_UNALIGNED, - 0, 0, 0, 0, OS_EXC_UF_NOCP, OS_EXC_UF_INVPC, OS_EXC_UF_INVSTATE, OS_EXC_UF_UNDEFINSTR, - 0, 0, 0, OS_EXC_BF_STKERR, OS_EXC_BF_UNSTKERR, OS_EXC_BF_IMPRECISERR, OS_EXC_BF_PRECISERR, OS_EXC_BF_IBUSERR, - 0, 0, 0, OS_EXC_MF_MSTKERR, OS_EXC_MF_MUNSTKERR, 0, OS_EXC_MF_DACCVIOL, OS_EXC_MF_IACCVIOL -}; -UINT32 g_excArraySize = 0; -ExcInfoArray g_excArray[OS_EXC_TYPE_MAX - 1]; - -UINT32 g_LR_regs = 0; -UINT32 g_PC_regs = 0; - -LITE_OS_SEC_TEXT_INIT VOID OsExcInfoDisplay(ExcInfo *exc) -{ - PRINT_INFO("Phase = 0x%x\n", exc->phase); - PRINT_INFO("Type = 0x%x\n", exc->type); - PRINT_INFO("FaultAddr = 0x%x\n", exc->faultAddr); - PRINT_INFO("ThrdPid = 0x%x\n", exc->thrdPid); - PRINT_INFO("R0 = 0x%x\n", exc->context->uwR0); - PRINT_INFO("R1 = 0x%x\n", exc->context->uwR1); - PRINT_INFO("R2 = 0x%x\n", exc->context->uwR2); - PRINT_INFO("R3 = 0x%x\n", exc->context->uwR3); - PRINT_INFO("R4 = 0x%x\n", exc->context->uwR4); - PRINT_INFO("R5 = 0x%x\n", exc->context->uwR5); - PRINT_INFO("R6 = 0x%x\n", exc->context->uwR6); - PRINT_INFO("R7 = 0x%x\n", exc->context->uwR7); - PRINT_INFO("R8 = 0x%x\n", exc->context->uwR8); - PRINT_INFO("R9 = 0x%x\n", exc->context->uwR9); - PRINT_INFO("R10 = 0x%x\n", exc->context->uwR10); - PRINT_INFO("R11 = 0x%x\n", exc->context->uwR11); - PRINT_INFO("R12 = 0x%x\n", exc->context->uwR12); - PRINT_INFO("PriMask = 0x%x\n", exc->context->uwPriMask); - PRINT_INFO("SP = 0x%x\n", exc->context->uwSP); - PRINT_INFO("LR = 0x%x\n", exc->context->uwLR); - PRINT_INFO("PC = 0x%x\n", exc->context->uwPC); - PRINT_INFO("xPSR = 0x%x\n", exc->context->uwxPSR); - - g_LR_regs = exc->context->uwLR; - g_PC_regs = exc->context->uwPC; -} - -LITE_OS_SEC_TEXT_INIT VOID OsExcHandleEntry(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_excInfo.type = excType & OS_NULL_SHORT; - g_excContent = (UINT32 *)g_aucTaskArray; - - if (tmpFlag & OS_EXC_FLAG_FAULTADDR_VALID) { - g_excInfo.faultAddr = faultAddr; - } 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; - g_excInfo.thrdPid = pid; - } else { - g_excInfo.phase = OS_EXC_IN_TASK; - g_excInfo.thrdPid = g_losTask.runTask->taskID; - } - } else { - 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; - } - - OsExcSave2DDR(); - - OsExcInfoDisplay(&g_excInfo); - - LOS_Reboot(); -} -static VOID OsExcSaveIntStatus() -{ - UINT32 ret; - UINT32 failCnt = 0; - *((UINT32 *)g_excContent) = OS_EXC_TYPE_NVIC; - g_excContent = (UINT8 *)g_excContent + sizeof(UINT32); - - *((UINT32 *)g_excContent) = EXC_INT_STATUS_LEN; - g_excContent = (UINT8 *)g_excContent + sizeof(UINT32); - - ret = memcpy_s(g_excContent, MAX_EXC_MEM_SIZE, (const VOID *)OS_NVIC_SETENA_BASE, OS_NVIC_INT_ENABLE_SIZE); - g_excContent = (UINT8 *)g_excContent + OS_NVIC_INT_ENABLE_SIZE; - failCnt += (ret == EOK) ? 0 : 1; - - ret = memcpy_s(g_excContent, MAX_EXC_MEM_SIZE, (const VOID *)OS_NVIC_SETPEND_BASE, OS_NVIC_INT_PEND_SIZE); - g_excContent = (UINT8 *)g_excContent + OS_NVIC_INT_PEND_SIZE; - failCnt += (ret == EOK) ? 0 : 1; - - ret = memcpy_s(g_excContent, MAX_EXC_MEM_SIZE, (const VOID *)OS_NVIC_INT_ACT_BASE, OS_NVIC_INT_ACT_SIZE); - g_excContent = (UINT8 *)g_excContent + OS_NVIC_INT_ACT_SIZE; - failCnt += (ret == EOK) ? 0 : 1; - - ret = memcpy_s(g_excContent, MAX_EXC_MEM_SIZE, (const VOID *)OS_NVIC_PRI_BASE, OS_NVIC_INT_PRI_SIZE); - g_excContent = (UINT8 *)g_excContent + OS_NVIC_INT_PRI_SIZE; - failCnt += (ret == EOK) ? 0 : 1; - - ret = memcpy_s(g_excContent, MAX_EXC_MEM_SIZE, (const VOID *)OS_NVIC_EXCPRI_BASE, OS_NVIC_EXCPRI_SIZE); - g_excContent = (UINT8 *)g_excContent + OS_NVIC_EXCPRI_SIZE; - failCnt += (ret == EOK) ? 0 : 1; - - ret = memcpy_s(g_excContent, MAX_EXC_MEM_SIZE, (const VOID *)OS_NVIC_SHCSR, OS_NVIC_SHCSR_SIZE); - g_excContent = (UINT8 *)g_excContent + sizeof(UINT32); - failCnt += (ret == EOK) ? 0 : 1; - - ret = memcpy_s(g_excContent, MAX_EXC_MEM_SIZE, (const VOID *)OS_NVIC_INT_CTRL, OS_NVIC_INT_CTRL_SIZE); - g_excContent = (UINT8 *)g_excContent + sizeof(UINT32); - failCnt += (ret == EOK) ? 0 : 1; - - if (failCnt != 0) { - PRINT_ERR("OsExcSaveIntStatus copy register info failed, cnt:%d\n", failCnt); - } - - return; -} - -VOID OsExcRegister(ExcInfoType type, EXC_INFO_SAVE_CALLBACK func, VOID *arg) -{ - ExcInfoArray *excInfo = NULL; - if ((type == 0) || (type >= OS_EXC_TYPE_MAX) || (func == NULL)) { - PRINT_ERR("OsExcRegister ERROR!\n"); - return; - } - excInfo = &(g_excArray[type - 1]); - excInfo->uwType = type; - excInfo->pFnExcInfoCb = func; - excInfo->pArg = arg; - excInfo->uwValid = TRUE; -} - -static VOID OsExcSaveSysInfo(ExcInfoType type, EXC_INFO_SAVE_CALLBACK func, UINT32 loop, UINT32 length, UINT32 index) -{ - UINT32 ret; - UINT32 buffer[OS_EXC_MAX_BUF_LEN]; - - *((UINT32 *)g_excContent) = type; - g_excContent = (UINT8 *)g_excContent + sizeof(UINT32); - *((UINT32 *)g_excContent) = length * (loop - index); - g_excContent = (UINT8 *)g_excContent + sizeof(UINT32); - - for (; index < loop; index++) { - (VOID)memset_s(buffer, sizeof(UINT32) * OS_EXC_MAX_BUF_LEN, 0, sizeof(UINT32) * OS_EXC_MAX_BUF_LEN); - ret = func(index, (VOID *)buffer); - if (ret == LOS_OK) { - if (memcpy_s(g_excContent, MAX_EXC_MEM_SIZE, (VOID *)buffer, length) != EOK) { - PRINT_ERR("OsExcSaveSysInfo copy buffer failed\n"); - return; - } - g_excContent = (UINT8 *)g_excContent + length; - } else { - g_excContent = (UINT8 *)g_excContent + length; - } - } -} - -static VOID OsExcSaveInfo(ExcInfoType type, EXC_INFO_SAVE_CALLBACK func, VOID *arg) -{ - UINT32 length; - UINT32 index; - UINT32 loop; - UINT32 taskSwitchCount = 0; - TaskSwitchInfo *taskSwitchInfo = NULL; - - if (arg == NULL) { - return; - } - - switch (type) { - case OS_EXC_TYPE_TSK: /* save task info */ - length = sizeof(TSK_INFO_S); - loop = *(UINT32 *)arg; - index = 0; - break; - - case OS_EXC_TYPE_QUE: /* save queue info */ - length = sizeof(QUEUE_INFO_S); - loop = *(UINT32 *)arg + 1; - index = 1; - break; - - case OS_EXC_TYPE_NVIC: - (VOID)func(0, 0); - goto END; - - case OS_EXC_TYPE_TSK_SWITCH: /* save task switch info */ - // not necessary, just for macro int library - taskSwitchInfo = arg; - taskSwitchCount = taskSwitchInfo->cntInfo.maxCnt; - length = sizeof(UINT32) + sizeof(CHAR) * LOS_TASK_NAMELEN; - if (taskSwitchInfo->cntInfo.isFull) { - index = taskSwitchInfo->idx; - loop = index + taskSwitchCount; - } else { - index = 0; - loop = taskSwitchInfo->idx; - } - break; - - case OS_EXC_TYPE_MEM: /* save mem info */ - length = sizeof(MEM_INFO_S); - loop = *(UINT32 *)arg; - index = 0; - break; - - default: - goto END; - } - OsExcSaveSysInfo(type, (EXC_INFO_SAVE_CALLBACK)func, loop, length, index); -END: - return; -} - -static VOID OsExcSave2DDR(VOID) -{ - UINT32 index = 0; - UINT32 ret; - UINT32 failCnt = 0; - - ret = memset_s(g_aucTaskArray, MAX_EXC_MEM_SIZE, TASK_ARRAY_INIT_VALUE, g_excArraySize); - if (ret != EOK) { - PRINT_ERR("memset failed\n"); - return; - } - - /* define core type */ - *((UINT32 *)g_excContent) = CORE_TYPE_CORTEX_M4; // 1 is cortex-M3, 2 is cortex-M4 - g_excContent = (UINT8 *)g_excContent + sizeof(UINT32); - - /* save exception info */ - *((UINT32 *)g_excContent) = OS_EXC_TYPE_CONTEXT; - g_excContent = (UINT8 *)g_excContent + sizeof(UINT32); - *((UINT32 *)g_excContent) = sizeof(ExcInfo) - sizeof(UINT32) + sizeof(EXC_CONTEXT_S); - - g_excContent = (UINT8 *)g_excContent + sizeof(UINT32); - ret = memcpy_s((VOID *)g_excContent, MAX_EXC_MEM_SIZE, (VOID *)&g_excInfo, sizeof(ExcInfo) - sizeof(UINT32)); - g_excContent = (UINT8 *)g_excContent + sizeof(ExcInfo) - sizeof(UINT32); - failCnt += (ret == EOK) ? 0 : 1; - - ret = memcpy_s((VOID *)g_excContent, MAX_EXC_MEM_SIZE, g_excInfo.context, sizeof(EXC_CONTEXT_S)); - g_excContent = (UINT8 *)g_excContent + sizeof(EXC_CONTEXT_S); - failCnt += (ret == EOK) ? 0 : 1; - - if (failCnt != 0) { - PRINT_ERR("OsExcSave2DDR copy exc info failed, cnt:%d\n", failCnt); - } - - for (index = 0; index < (OS_EXC_TYPE_MAX - 1); index++) { - if (g_excArray[index].uwValid == FALSE) { - continue; - } - OsExcSaveInfo(g_excArray[index].uwType, g_excArray[index].pFnExcInfoCb, g_excArray[index].pArg); - } - *((UINT32 *)g_excContent) = OS_EXC_TYPE_MAX; - g_excContent = (UINT8 *)g_excContent + sizeof(UINT32); - return; -} - -LITE_OS_SEC_TEXT_INIT VOID OsExcInit(UINT32 arraySize) -{ - 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; - /* Enable USGFAULT, BUSFAULT, MEMFAULT */ - *(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT); - /* Enable DIV 0 and unaligned exception */ - - *(volatile UINT32 *)OS_NVIC_CCR |= DIV0FAULT; - g_excArraySize = arraySize; - - OsExcRegister(OS_EXC_TYPE_NVIC, (EXC_INFO_SAVE_CALLBACK)OsExcSaveIntStatus, NULL); -} - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ diff --git a/kernel/arch/arm/cortex-m4/iar/los_exc.h b/kernel/arch/arm/cortex-m4/iar/los_exc.h deleted file mode 100755 index 1f529721..00000000 --- a/kernel/arch/arm/cortex-m4/iar/los_exc.h +++ /dev/null @@ -1,265 +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. - */ - -#ifndef _LOS_EXC_H -#define _LOS_EXC_H - -#include "los_sys.h" -#include "los_config.h" -#include "los_base.h" -#include "los_task_pri.h" -#include "los_queue.h" -#include "los_memcheck.h" -#include "los_sys_pri.h" -#ifdef LOSCFG_LIB_LIBC -#include "string.h" -#endif - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cpluscplus */ -#endif /* __cpluscplus */ - -#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 - -/** - *@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: - *
  • None.
- * - *@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(UINT32 uwArraySize); - -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[]; - -inline 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_exc.h: the header file that contains the API declaration. - *@see None. -*/ -VOID LOS_Panic(const CHAR *fmt, ...); - -#define OS_EXC_BF_STKERR 1 - -#define OS_EXC_BF_UNSTKERR 2 - -#define OS_EXC_BF_IMPRECISERR 3 - -#define OS_EXC_BF_PRECISERR 4 - -#define OS_EXC_BF_IBUSERR 5 - -#define OS_EXC_MF_MSTKERR 6 - -#define OS_EXC_MF_MUNSTKERR 7 - -#define OS_EXC_MF_DACCVIOL 8 - -#define OS_EXC_MF_IACCVIOL 9 - -#define OS_EXC_UF_DIVBYZERO 10 - -#define OS_EXC_UF_UNALIGNED 11 - -#define OS_EXC_UF_NOCP 12 - -#define OS_EXC_UF_INVPC 13 - -#define OS_EXC_UF_INVSTATE 14 - -#define OS_EXC_UF_UNDEFINSTR 15 - -#define OS_EXC_CAUSE_NMI 16 - -#define OS_EXC_CAUSE_HARDFAULT 17 - -#define OS_EXC_CAUSE_TASK_EXIT 18 - -#define OS_EXC_CAUSE_FATAL_ERR 19 - -#define OS_EXC_CAUSE_DEBUGEVT 20 - -#define OS_EXC_CAUSE_VECTBL 21 - -typedef struct tagExcInfo { - UINT16 phase; - UINT16 type; - UINT32 faultAddr; - 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 TaskSwitchInfo g_taskSwitchInfo; -extern UINT8 g_uwExcTbl[32]; - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cpluscplus */ -#endif /* __cpluscplus */ - -#endif /* _LOS_EXC_H */ - diff --git a/kernel/arch/arm/cortex-m4/iar/los_exc_pri.h b/kernel/arch/arm/cortex-m4/iar/los_exc_pri.h deleted file mode 100755 index f1b20d6f..00000000 --- a/kernel/arch/arm/cortex-m4/iar/los_exc_pri.h +++ /dev/null @@ -1,98 +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. - */ - -#ifndef _LOS_EXC_PRI_H -#define _LOS_EXC_PRI_H - -#include "los_exc.h" -#include "los_sys_pri.h" -#ifdef LOSCFG_LIB_LIBC -#include "string.h" -#endif - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -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 /* __cplusplus */ -#endif /* __cplusplus */ - -#endif diff --git a/kernel/arch/arm/cortex-m4/iar/los_hw.c b/kernel/arch/arm/cortex-m4/iar/los_hw.c index 3cda4f36..6eabc65c 100755 --- a/kernel/arch/arm/cortex-m4/iar/los_hw.c +++ b/kernel/arch/arm/cortex-m4/iar/los_hw.c @@ -29,10 +29,8 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "los_task_pri.h" -#include "los_hw.h" +#include "los_task.h" #include "securec.h" - #ifdef __cplusplus #if __cplusplus extern "C" { diff --git a/kernel/arch/arm/cortex-m4/iar/los_hw_exc_iar.S b/kernel/arch/arm/cortex-m4/iar/los_hw_exc.S similarity index 100% rename from kernel/arch/arm/cortex-m4/iar/los_hw_exc_iar.S rename to kernel/arch/arm/cortex-m4/iar/los_hw_exc.S diff --git a/kernel/arch/arm/cortex-m4/iar/los_hw_tick.c b/kernel/arch/arm/cortex-m4/iar/los_hw_tick.c index 6646fa6c..e3a74b98 100755 --- a/kernel/arch/arm/cortex-m4/iar/los_hw_tick.c +++ b/kernel/arch/arm/cortex-m4/iar/los_hw_tick.c @@ -29,12 +29,8 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "los_tick_pri.h" -#include "los_base.h" -#include "los_task_pri.h" -#include "los_swtmr.h" -#include "los_hwi.h" - +#include "los_tick.h" +#include "los_interrupt.h" #ifdef __cplusplus #if __cplusplus extern "C" { @@ -245,11 +241,11 @@ VOID LOS_EnterSleep(LOS_SysSleepEnum sleep) VOID LOS_SystemWakeup(UINT32 hwiIndex) { } -extern unsigned int SystemCoreClock; +//extern unsigned int SystemCoreClock; void LOS_HalDelay(UINT32 ticks) { UINT32 delayTimes; - +#if 0 /* there are 4 machine cycle in loop */ if ((ticks * (SystemCoreClock / MACHINE_CYCLE_DEALAY_TIMES)) >= 0xffffffff) { delayTimes = 0xffffffff; @@ -260,6 +256,7 @@ void LOS_HalDelay(UINT32 ticks) while (delayTimes) { delayTimes = delayTimes - 1; } +#endif } #ifdef __cplusplus diff --git a/kernel/arch/arm/cortex-m4/iar/los_hwi.c b/kernel/arch/arm/cortex-m4/iar/los_interrupt.c similarity index 52% rename from kernel/arch/arm/cortex-m4/iar/los_hwi.c rename to kernel/arch/arm/cortex-m4/iar/los_interrupt.c index 764f194f..494a2ac7 100755 --- a/kernel/arch/arm/cortex-m4/iar/los_hwi.c +++ b/kernel/arch/arm/cortex-m4/iar/los_interrupt.c @@ -28,15 +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_hwi.h" -#include "los_sr.h" -#include "los_printf.h" - - +#include "los_interrupt.h" +#include +#include "los_debug.h" +#include "los_task.h" #if (LOSCFG_KERNEL_TICKLESS == YES) -#include "los_tickless_pri.h" +#include "los_tick.h" #endif + #ifdef __cplusplus #if __cplusplus extern "C" { @@ -48,7 +47,6 @@ __weak VOID SysTickHandler(VOID) { return; } - UINT32 g_vuwIntCount = 0; /*lint -restore*/ #ifdef __ICCARM__ @@ -56,7 +54,6 @@ UINT32 g_vuwIntCount = 0; #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 @@ -75,6 +72,9 @@ HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = { (HWI_PROC_FUNC)osPendSV, // [14] PendSV Handler (HWI_PROC_FUNC)SysTickHandler, // [15] SysTick Handler }; + + + #if (OS_HWI_WITH_ARG == YES) HWI_SLAVE_FUNC g_hwiSlaveForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }}; #else @@ -149,29 +149,6 @@ LITE_OS_SEC_TEXT VOID OsInterrupt(VOID) LOS_IntRestore(intSave); } -/* **************************************************************************** - Function : OsHwiInit - Description : initialization of the hardware interrupt - Input : None - Output : None - Return : None - **************************************************************************** */ -LITE_OS_SEC_TEXT_INIT VOID OsHwiInit() -{ - UINT32 index; - - for (index = OS_SYS_VECTOR_CNT; index < OS_VECTOR_CNT; index++) { - g_hwiForm[index] = (HWI_PROC_FUNC)OsHwiDefaultHandler; - } - - /* Interrupt vector table location */ - SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm; -#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */ - NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP); -#endif - - return; -} /* **************************************************************************** Function : LOS_HwiCreate Description : create hardware interrupt @@ -247,10 +224,228 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_HwiDelete(HWI_HANDLE_T hwiNum) return LOS_OK; } +#define OS_NVIC_INT_CTRL_SIZE 4 +#define OS_NVIC_SHCSR_SIZE 4 +#define FAULT_STATUS_REG_BIT 32 +#define USGFAULT (1 << 18) +#define BUSFAULT (1 << 17) +#define MEMFAULT (1 << 16) +#define DIV0FAULT (1 << 4) +#define HARDFAULT_IRQN (-13) + +static ExcInfoArray g_excArray[OS_EXC_TYPE_MAX]; + +UINT32 g_curNestCount = 0; +static ExcInfo g_excInfo; +static EVENT_CB_S g_excEvent; + +UINT8 g_uwExcTbl[FAULT_STATUS_REG_BIT] = { + 0, 0, 0, 0, 0, 0, OS_EXC_UF_DIVBYZERO, OS_EXC_UF_UNALIGNED, + 0, 0, 0, 0, OS_EXC_UF_NOCP, OS_EXC_UF_INVPC, OS_EXC_UF_INVSTATE, OS_EXC_UF_UNDEFINSTR, + 0, 0, 0, OS_EXC_BF_STKERR, OS_EXC_BF_UNSTKERR, OS_EXC_BF_IMPRECISERR, OS_EXC_BF_PRECISERR, OS_EXC_BF_IBUSERR, + 0, 0, 0, OS_EXC_MF_MSTKERR, OS_EXC_MF_MUNSTKERR, 0, OS_EXC_MF_DACCVIOL, OS_EXC_MF_IACCVIOL +}; + +__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 *base = NULL; + 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}; + UINT32 rgNvicLens[OS_NR_NVIC_EXC_DUMP_Types] = {OS_NVIC_INT_ENABLE_SIZE, OS_NVIC_INT_PEND_SIZE, + OS_NVIC_INT_ACT_SIZE, OS_NVIC_INT_PRI_SIZE, OS_NVIC_EXCPRI_SIZE, OS_NVIC_SHCSR_SIZE, OS_NVIC_INT_CTRL_SIZE}; + char strRgEnable[] = "enable"; + char strRgPending[] = "pending"; + char strRgActive[] = "active"; + char strRgPriority[] = "priority"; + char strRgException[] = "exception"; + char strRgShcsr[] = "shcsr"; + char strRgIntCtrl[] = "control"; + char *strRgs[] = {strRgEnable, strRgPending, strRgActive, strRgPriority, strRgException, strRgShcsr, strRgIntCtrl}; + (VOID)index; + (VOID)excContent; + + PRINTK("OS exception NVIC dump: \n"); + for (i = 0; i < OS_NR_NVIC_EXC_DUMP_Types; i++) { + base = (UINT32 *)rgNvicBases[i]; + len = rgNvicLens[i]; + PRINTK("interrupt %s register, base address: 0x%x, size: 0x%x\n", strRgs[i], base, len); + len = (len >> 2); + for (j = 0; j < len; j++) { + PRINTK("0x%x ", *(base + j)); + } + PRINTK("\n"); + } +} + +UINT32 OsExcContextDump(UINT32 index, UINT32 *excContent) +{ + (VOID)index; + (VOID)excContent; + PRINTK("OS exception context dump:\n"); + PRINTK("Phase = 0x%x\n", g_excInfo.phase); + PRINTK("Type = 0x%x\n", g_excInfo.type); + PRINTK("FaultAddr = 0x%x\n", g_excInfo.faultAddr); + PRINTK("ThrdPid = 0x%x\n", g_excInfo.thrdPid); + PRINTK("R0 = 0x%x\n", g_excInfo.context->uwR0); + PRINTK("R1 = 0x%x\n", g_excInfo.context->uwR1); + PRINTK("R2 = 0x%x\n", g_excInfo.context->uwR2); + PRINTK("R3 = 0x%x\n", g_excInfo.context->uwR3); + PRINTK("R4 = 0x%x\n", g_excInfo.context->uwR4); + PRINTK("R5 = 0x%x\n", g_excInfo.context->uwR5); + PRINTK("R6 = 0x%x\n", g_excInfo.context->uwR6); + PRINTK("R7 = 0x%x\n", g_excInfo.context->uwR7); + PRINTK("R8 = 0x%x\n", g_excInfo.context->uwR8); + PRINTK("R9 = 0x%x\n", g_excInfo.context->uwR9); + PRINTK("R10 = 0x%x\n", g_excInfo.context->uwR10); + PRINTK("R11 = 0x%x\n", g_excInfo.context->uwR11); + PRINTK("R12 = 0x%x\n", g_excInfo.context->uwR12); + PRINTK("PriMask = 0x%x\n", g_excInfo.context->uwPriMask); + PRINTK("SP = 0x%x\n", g_excInfo.context->uwSP); + 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); +} + +VOID OsDumpMsg(VOID) +{ + UINT32 index = 0; + for (index = 0; index < (OS_EXC_TYPE_MAX - 1); index++) { + if (g_excArray[index].uwValid == FALSE) { + continue; + } + g_excArray[index].pFnExcInfoCb(index, g_excArray[index].pArg); + } +} + +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) +{ + UINT16 tmpFlag = (excType >> 16) & OS_NULL_SHORT; + g_curNestCount++; + g_vuwIntCount++; + g_excInfo.nestCnt = g_curNestCount; + + g_excInfo.type = excType & OS_NULL_SHORT; + + if (tmpFlag & OS_EXC_FLAG_FAULTADDR_VALID) { + g_excInfo.faultAddr = faultAddr; + } 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; + g_excInfo.thrdPid = pid; + } else { + g_excInfo.phase = OS_EXC_IN_TASK; + g_excInfo.thrdPid = g_losTask.runTask->taskID; + } + } else { + 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(); +} + +VOID OsExcRegister(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"); + return; + } + excInfo = &(g_excArray[type]); + excInfo->uwType = type; + excInfo->pFnExcInfoCb = func; + excInfo->pArg = arg; + excInfo->uwValid = TRUE; +} + +void OsBackTrace() +{ +} + +/* **************************************************************************** + Function : OsHwiInit + Description : initialization of the hardware interrupt + Input : None + Output : None + Return : None + **************************************************************************** */ +LITE_OS_SEC_TEXT_INIT VOID OsHwiInit() +{ + UINT32 index; + UINT32 ret; + + for (index = OS_SYS_VECTOR_CNT; index < OS_VECTOR_CNT; index++) { + g_hwiForm[index] = (HWI_PROC_FUNC)OsHwiDefaultHandler; + } + + /* 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; + + /* Interrupt vector table location */ + SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm; +#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */ + NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP); +#endif + + /* Enable USGFAULT, BUSFAULT, MEMFAULT */ + *(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT); + /* 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); + + return; +} + #ifdef __cplusplus #if __cplusplus } #endif /* __cplusplus */ #endif /* __cplusplus */ - - diff --git a/kernel/arch/arm/cortex-m4/iar/los_interrupt.h b/kernel/arch/arm/cortex-m4/iar/los_interrupt.h new file mode 100755 index 00000000..a8ad5da2 --- /dev/null +++ b/kernel/arch/arm/cortex-m4/iar/los_interrupt.h @@ -0,0 +1,1085 @@ +/* + * 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: + *
  • None.
+ * + * @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: + *
  • None.
+ * + * @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: + *
  • None.
+ * + * @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: + *
  • None.
+ * + * @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: + *
  • None.
+ * + * @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 + *
    + *
  • None.
  • + *
+ * + * @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 + *
    + *
  • None.
  • + *
+ * + * @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 + *
    + *
  • None.
  • + *
+ * + * @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 + *
    + *
  • None.
  • + *
+ * + * @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 + *
    + *
  • None.
  • + *
+ * + * @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: + *
  • None.
+ * + *@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 */ + diff --git a/kernel/arch/risc-v/rvm32/include/asm/soc_common.h b/kernel/arch/risc-v/asm/soc_common.h old mode 100644 new mode 100755 similarity index 100% rename from kernel/arch/risc-v/rvm32/include/asm/soc_common.h rename to kernel/arch/risc-v/asm/soc_common.h diff --git a/kernel/arch/risc-v/include/los_exc.h b/kernel/arch/risc-v/include/los_exc.h deleted file mode 100644 index 05c6932e..00000000 --- a/kernel/arch/risc-v/include/los_exc.h +++ /dev/null @@ -1,60 +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_EXC_H -#define _LOS_EXC_H - -#include "los_hw.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif -#endif /* __cplusplus */ - -extern VOID LOS_Panic(const CHAR *fmt, ...); -extern VOID OsBackTrace(VOID); -extern VOID OsTaskBackTrace(UINT32 taskID); - -STATIC INLINE UINTPTR GetFp(VOID) -{ - UINTPTR fpSave = 0; - __asm__ __volatile__("mv %0, s0" : "=r"(fpSave)); - return fpSave; -} - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif diff --git a/kernel/arch/risc-v/include/los_hw.h b/kernel/arch/risc-v/include/los_hw.h deleted file mode 100644 index 68864d52..00000000 --- a/kernel/arch/risc-v/include/los_hw.h +++ /dev/null @@ -1,123 +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_HW_H -#define _LOS_HW_H - -#include "los_typedef.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 - * Check task schedule. - */ -#define LOS_CHECK_SCHEDULE ((!g_losTaskLock) && (!OS_INT_ACTIVE)) - -/** - * @ingroup los_hw - * @brief Wait for interrupt. - * - * @par Description: - *
    - *
  • This API is used to suspend execution until interrupt or a debug request occurs.
  • - *
- * @attention None. - * - * @param None. - * - * @retval: None. - * - * @par Dependency: - * los_hw.h: the header file that contains the API declaration. - * @see None. - * @since Huawei LiteOS V200R002C00 - */ -extern VOID wfi(VOID); - -/** - * @ingroup los_hw - * @brief: mem fence function. - * - * @par Description: - * This API is used to fence for memory. - * - * @attention: - *
  • None.
- * - * @param: None. - * - * @retval:None. - * @par Dependency: - *
  • los_hw.h: the header file that contains the API declaration.
- * @see None. - * @since Huawei LiteOS V200R002C00 - */ -extern VOID mb(VOID); - -/** - * @ingroup los_hw - * @brief: mem fence function. - * - * @par Description: - * This API is same as mb, it just for adaptation. - * - * @attention: - *
  • None.
- * - * @param: None. - * - * @retval:None. - * @par Dependency: - *
  • los_hw.h: the header file that contains the API declaration.
- * @see None. - * @since Huawei LiteOS V200R002C00 - */ -extern VOID dsb(VOID); - -extern VOID LOS_GetCpuCycle(UINT32 *cntHi, UINT32 *cntLo); -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_HW_H */ diff --git a/kernel/arch/risc-v/rvm32/include/los_hw_pri.h b/kernel/arch/risc-v/los_context.h old mode 100644 new mode 100755 similarity index 70% rename from kernel/arch/risc-v/rvm32/include/los_hw_pri.h rename to kernel/arch/risc-v/los_context.h index a4b75c5f..7604a033 --- a/kernel/arch/risc-v/rvm32/include/los_hw_pri.h +++ b/kernel/arch/risc-v/los_context.h @@ -29,10 +29,10 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _LOS_HW_PRI_H -#define _LOS_HW_PRI_H +#ifndef _LOS_HW_H +#define _LOS_HW_H -#include "los_hw.h" +#include "los_compiler.h" #ifdef __cplusplus #if __cplusplus @@ -40,6 +40,18 @@ extern "C" { #endif /* __cplusplus */ #endif /* __cplusplus */ +/** + * @ingroup los_hw + * The initialization value of stack space. + */ +#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 @@ -117,8 +129,67 @@ STATIC INLINE UINTPTR GetSP(VOID) extern VOID *OsTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack); extern VOID OsTaskScheduleCheck(VOID); -extern VOID OsDisableIRQ(VOID); -extern VOID OsEnableIRQ(VOID); + +/** + * @ingroup los_hw + * @brief Wait for interrupt. + * + * @par Description: + *
    + *
  • This API is used to suspend execution until interrupt or a debug request occurs.
  • + *
+ * @attention None. + * + * @param None. + * + * @retval: None. + * + * @par Dependency: + * los_hw.h: the header file that contains the API declaration. + * @see None. + * @since Huawei LiteOS V200R002C00 + */ +extern VOID wfi(VOID); + +/** + * @ingroup los_hw + * @brief: mem fence function. + * + * @par Description: + * This API is used to fence for memory. + * + * @attention: + *
  • None.
+ * + * @param: None. + * + * @retval:None. + * @par Dependency: + *
  • los_hw.h: the header file that contains the API declaration.
+ * @see None. + * @since Huawei LiteOS V200R002C00 + */ +extern VOID mb(VOID); + +/** + * @ingroup los_hw + * @brief: mem fence function. + * + * @par Description: + * This API is same as mb, it just for adaptation. + * + * @attention: + *
  • None.
+ * + * @param: None. + * + * @retval:None. + * @par Dependency: + *
  • los_hw.h: the header file that contains the API declaration.
+ * @see None. + * @since Huawei LiteOS V200R002C00 + */ +extern VOID dsb(VOID); #ifdef __cplusplus #if __cplusplus @@ -126,4 +197,4 @@ extern VOID OsEnableIRQ(VOID); #endif /* __cplusplus */ #endif /* __cplusplus */ -#endif /* _LOS_HW_PRI_H */ +#endif /* _LOS_HW_H */ diff --git a/kernel/arch/risc-v/rvm32/src/los_dispatch.S b/kernel/arch/risc-v/los_dispatch.S old mode 100644 new mode 100755 similarity index 100% rename from kernel/arch/risc-v/rvm32/src/los_dispatch.S rename to kernel/arch/risc-v/los_dispatch.S diff --git a/kernel/arch/risc-v/rvm32/src/los_exc.c b/kernel/arch/risc-v/los_exc.c old mode 100644 new mode 100755 similarity index 61% rename from kernel/arch/risc-v/rvm32/src/los_exc.c rename to kernel/arch/risc-v/los_exc.c index 769c65eb..23a7ec18 --- a/kernel/arch/risc-v/rvm32/src/los_exc.c +++ b/kernel/arch/risc-v/los_exc.c @@ -29,10 +29,11 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "los_exc.h" -#include "los_exc_pri.h" -#include "los_task_pri.h" -#include "los_printf_pri.h" +#include +#include +#include "los_interrupt.h" +#include "los_task.h" +#include "los_debug.h" #include "riscv_hal.h" #ifdef __cplusplus @@ -41,8 +42,9 @@ extern "C" { #endif /* __cplusplus */ #endif /* __cplusplus */ -LosExcInfo g_excInfo; +static ExcInfoArray g_excArray[OS_EXC_TYPE_MAX]; +LosExcInfo g_excInfo; #define RISCV_EXC_TYPE_NUM 16 const CHAR g_excInformation[RISCV_EXC_TYPE_NUM][50] = { { "Instruction address misaligned!" }, @@ -69,6 +71,150 @@ const CHAR g_excInformation[RISCV_EXC_TYPE_NUM][50] = { #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)) +LITE_OS_SEC_BSS UINT32 g_intCount = 0; +LITE_OS_SEC_BSS UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM]; +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 = 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 = 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 = NULL, .uwParam = 0 }, // 13 Reserved + { .pfnHook = NULL, .uwParam = 0 }, // 14 Reserved + { .pfnHook = NULL, .uwParam = 0 }, // 15 Reserved + { .pfnHook = NULL, .uwParam = 0 }, // 16 Reserved + { .pfnHook = NULL, .uwParam = 0 }, // 17 Reserved + { .pfnHook = NULL, .uwParam = 0 }, // 18 Reserved + { .pfnHook = NULL, .uwParam = 0 }, // 19 Reserved + { .pfnHook = NULL, .uwParam = 0 }, // 20 Reserved + { .pfnHook = NULL, .uwParam = 0 }, // 21 Reserved + { .pfnHook = NULL, .uwParam = 0 }, // 22 Reserved + { .pfnHook = NULL, .uwParam = 0 }, // 23 Reserved + { .pfnHook = NULL, .uwParam = 0 }, // 24 Reserved + { .pfnHook = NULL, .uwParam = 0 }, // 25 Reserved +}; + +LITE_OS_SEC_TEXT_INIT VOID OsHwiDefaultHandler(UINTPTR arg) +{ + (VOID)arg; + PRINT_ERR("default handler\n"); + while (1) { + } +} + +LITE_OS_SEC_TEXT_INIT VOID OsHwiInit(VOID) +{ + UINT32 index; + for (index = OS_RISCV_SYS_VECTOR_CNT; index < OS_HWI_MAX_NUM; index++) { + g_hwiForm[index].pfnHook = OsHwiDefaultHandler; + g_hwiForm[index].uwParam = 0; + } +} + +typedef VOID (*HwiProcFunc)(UINTPTR); +LITE_OS_SEC_TEXT_INIT VOID OsHwiInterruptDone(HWI_HANDLE_T hwiNum) +{ + g_intCount++; + + HWI_HANDLE_FORM_S *hwiForm = &g_hwiForm[hwiNum]; + HwiProcFunc func = (HwiProcFunc)(hwiForm->pfnHook); + func(hwiForm->uwParam); + + ++g_hwiFormCnt[hwiNum]; + + g_intCount--; +} + +LITE_OS_SEC_TEXT UINT32 OsGetHwiFormCnt(HWI_HANDLE_T hwiNum) +{ + if (hwiNum < OS_HWI_MAX_NUM) { + return g_hwiFormCnt[hwiNum]; + } + + return LOS_NOK; +} + +LITE_OS_SEC_TEXT HWI_HANDLE_FORM_S *OsGetHwiForm(VOID) +{ + return g_hwiForm; +} + +/***************************************************************************** + Function : LOS_HwiCreate + Description : create hardware interrupt + Input : hwiNum --- hwi num to create + hwiPrio --- priority of the hwi + hwiMode --- hwi interrupt mode + hwiHandler --- hwi handler + irqParam --- param of the hwi handler + Output : None + Return : LOS_OK on success or error code on failure + *****************************************************************************/ +LITE_OS_SEC_TEXT UINT32 LOS_HwiCreate(HWI_HANDLE_T hwiNum, + HWI_PRIOR_T hwiPrio, + HWI_MODE_T hwiMode, + HWI_PROC_FUNC hwiHandler, + HWI_IRQ_PARAM_S irqParam) +{ + UINT32 intSave; + + if (hwiHandler == NULL) { + return OS_ERRNO_HWI_PROC_FUNC_NULL; + } + if (hwiNum >= OS_HWI_MAX_NUM) { + return OS_ERRNO_HWI_NUM_INVALID; + } + if (g_hwiForm[hwiNum].pfnHook == NULL) { + return OS_ERRNO_HWI_NUM_INVALID; + } else if (g_hwiForm[hwiNum].pfnHook != OsHwiDefaultHandler) { + return OS_ERRNO_HWI_NUM_INVALID; + } + if ((hwiPrio < OS_HWI_PRIO_LOWEST) || (hwiPrio > OS_HWI_PRIO_HIGHEST)) { + return OS_ERRNO_HWI_PRIO_INVALID; + } + + intSave = LOS_IntLock(); + g_hwiForm[hwiNum].pfnHook = hwiHandler; + g_hwiForm[hwiNum].uwParam = irqParam; + + if (hwiNum >= OS_RISCV_SYS_VECTOR_CNT) { + OsSetLocalInterPri(hwiNum, hwiPrio); + } + + LOS_IntRestore(intSave); + + return LOS_OK; +} + +/***************************************************************************** + Function : LOS_HwiDelete + 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) +{ + UINT32 intSave; + + if (hwiNum >= OS_HWI_MAX_NUM) { + return OS_ERRNO_HWI_NUM_INVALID; + } + + intSave = LOS_IntLock(); + g_hwiForm[hwiNum].pfnHook = OsHwiDefaultHandler; + g_hwiForm[hwiNum].uwParam = 0; + LOS_IntRestore(intSave); + return LOS_OK; +} + LITE_OS_SEC_TEXT VOID BackTraceSub(UINT32 fp) { UINT32 backFp = fp; @@ -259,6 +405,20 @@ SYSTEM_DEATH: } } +VOID OsExcRegister(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"); + return; + } + excInfo = &(g_excArray[type]); + excInfo->uwType = type; + excInfo->pFnExcInfoCb = func; + excInfo->pArg = arg; + excInfo->uwValid = TRUE; +} + /* stack protector */ UINT32 __stack_chk_guard = 0xd00a0dff; diff --git a/kernel/arch/risc-v/rvm32/src/los_hw.c b/kernel/arch/risc-v/los_hw.c old mode 100644 new mode 100755 similarity index 97% rename from kernel/arch/risc-v/rvm32/src/los_hw.c rename to kernel/arch/risc-v/los_hw.c index b43db88b..cc574322 --- a/kernel/arch/risc-v/rvm32/src/los_hw.c +++ b/kernel/arch/risc-v/los_hw.c @@ -29,11 +29,10 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "los_hw.h" -#include "los_hw_pri.h" -#include "los_task_pri.h" +#include "los_context.h" +#include "los_interrupt.h" +#include "los_task.h" #include "los_memory.h" -#include "los_priqueue_pri.h" #include "soc.h" #ifdef __cplusplus diff --git a/kernel/arch/risc-v/rvm32/src/los_hw_tick.c b/kernel/arch/risc-v/los_hw_tick.c old mode 100644 new mode 100755 similarity index 81% rename from kernel/arch/risc-v/rvm32/src/los_hw_tick.c rename to kernel/arch/risc-v/los_hw_tick.c index f4ff7b8e..f9a35408 --- a/kernel/arch/risc-v/rvm32/src/los_hw_tick.c +++ b/kernel/arch/risc-v/los_hw_tick.c @@ -29,9 +29,9 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "los_hw_tick_pri.h" -#include "los_hwi.h" -#include "los_tick_pri.h" +#include "los_tick.h" +#include "los_config.h" +#include "los_interrupt.h" #include "riscv_hal.h" #ifdef __cplusplus @@ -53,6 +53,14 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsTickStart(VOID) return LOS_OK; } +/* **************************************************************************** +Function : LOS_GetCpuCycle +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) { OsGetCpuCycle(cntHi, cntLo); diff --git a/kernel/arch/risc-v/include/los_hwi.h b/kernel/arch/risc-v/los_interrupt.h old mode 100644 new mode 100755 similarity index 74% rename from kernel/arch/risc-v/include/los_hwi.h rename to kernel/arch/risc-v/los_interrupt.h index 824b4cfd..f572cc15 --- a/kernel/arch/risc-v/include/los_hwi.h +++ b/kernel/arch/risc-v/los_interrupt.h @@ -31,8 +31,9 @@ #ifndef _LOS_HWI_H #define _LOS_HWI_H -#include "securec.h" -#include "los_printf.h" +#include "los_compiler.h" +#include "los_config.h" +#include "los_context.h" #ifdef __cplusplus #if __cplusplus @@ -97,6 +98,135 @@ typedef struct tagHwiHandleForm { 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; /** @@ -346,6 +476,29 @@ extern UINT32 LOS_IntLock(VOID); */ 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 + *
    + *
  • None.
  • + *
+ * + * @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. diff --git a/kernel/arch/risc-v/rvm32/src/los_trap.S b/kernel/arch/risc-v/los_trap.S similarity index 100% rename from kernel/arch/risc-v/rvm32/src/los_trap.S rename to kernel/arch/risc-v/los_trap.S diff --git a/kernel/arch/risc-v/rvm32/include/los_exc_pri.h b/kernel/arch/risc-v/rvm32/include/los_exc_pri.h deleted file mode 100644 index 190cae2a..00000000 --- a/kernel/arch/risc-v/rvm32/include/los_exc_pri.h +++ /dev/null @@ -1,67 +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_EXC_PRI_H -#define _LOS_EXC_PRI_H - -#include "los_typedef.h" -#include "los_hw_pri.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -extern VOID BackTraceSub(UINT32 fp); - -typedef struct { - UINT32 mcause; - UINT32 mtval; - UINT32 medeleg; - UINT32 gp; - TaskContext taskContext; -} LosExcContext; - -typedef struct { - UINT16 nestCnt; - UINT16 type; - UINT32 thrID; - LosExcContext *context; -} LosExcInfo; - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_EXC_PRI_H */ diff --git a/kernel/arch/risc-v/rvm32/include/los_hwi_pri.h b/kernel/arch/risc-v/rvm32/include/los_hwi_pri.h deleted file mode 100644 index e6209ad3..00000000 --- a/kernel/arch/risc-v/rvm32/include/los_hwi_pri.h +++ /dev/null @@ -1,135 +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_PRI_H -#define _LOS_HWI_PRI_H - -#include "soc.h" -#include "los_hwi.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -/** - * @ingroup los_hwi - * The hwi form does not contain exceptions for cortex-A - */ -#define OS_HWI_FORM_EXC_NUM 0 -#if OS_HWI_FORM_EXC_NUM != 0 -#error "OS_HWI_FORM_EXC_NUM must be zero" -#endif - -/** - * @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); - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_HWI_PRI_H */ diff --git a/kernel/arch/risc-v/rvm32/src/los_hwi.c b/kernel/arch/risc-v/rvm32/src/los_hwi.c deleted file mode 100644 index 4d801d42..00000000 --- a/kernel/arch/risc-v/rvm32/src/los_hwi.c +++ /dev/null @@ -1,191 +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. - */ - -#include "los_base.h" -#include "los_hwi_pri.h" -#include "riscv_hal.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -LITE_OS_SEC_BSS UINT32 g_intCount = 0; -LITE_OS_SEC_BSS UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM]; - -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 = 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 = 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 = NULL, .uwParam = 0 }, // 13 Reserved - { .pfnHook = NULL, .uwParam = 0 }, // 14 Reserved - { .pfnHook = NULL, .uwParam = 0 }, // 15 Reserved - { .pfnHook = NULL, .uwParam = 0 }, // 16 Reserved - { .pfnHook = NULL, .uwParam = 0 }, // 17 Reserved - { .pfnHook = NULL, .uwParam = 0 }, // 18 Reserved - { .pfnHook = NULL, .uwParam = 0 }, // 19 Reserved - { .pfnHook = NULL, .uwParam = 0 }, // 20 Reserved - { .pfnHook = NULL, .uwParam = 0 }, // 21 Reserved - { .pfnHook = NULL, .uwParam = 0 }, // 22 Reserved - { .pfnHook = NULL, .uwParam = 0 }, // 23 Reserved - { .pfnHook = NULL, .uwParam = 0 }, // 24 Reserved - { .pfnHook = NULL, .uwParam = 0 }, // 25 Reserved -}; - -LITE_OS_SEC_TEXT_INIT VOID OsHwiDefaultHandler(UINTPTR arg) -{ - (VOID)arg; - PRINT_ERR("default handler\n"); - while (1) { - } -} - -LITE_OS_SEC_TEXT_INIT VOID OsHwiInit(VOID) -{ - UINT32 index; - for (index = OS_RISCV_SYS_VECTOR_CNT; index < OS_HWI_MAX_NUM; index++) { - g_hwiForm[index].pfnHook = OsHwiDefaultHandler; - g_hwiForm[index].uwParam = 0; - } -} - -typedef VOID (*HwiProcFunc)(UINTPTR); -LITE_OS_SEC_TEXT_INIT VOID OsHwiInterruptDone(HWI_HANDLE_T hwiNum) -{ - g_intCount++; - - HWI_HANDLE_FORM_S *hwiForm = &g_hwiForm[hwiNum]; - HwiProcFunc func = (HwiProcFunc)(hwiForm->pfnHook); - func(hwiForm->uwParam); - - ++g_hwiFormCnt[hwiNum]; - - g_intCount--; -} - -LITE_OS_SEC_TEXT UINT32 OsGetHwiFormCnt(HWI_HANDLE_T hwiNum) -{ - if (hwiNum < OS_HWI_MAX_NUM) { - return g_hwiFormCnt[hwiNum]; - } - - return LOS_NOK; -} - -LITE_OS_SEC_TEXT HWI_HANDLE_FORM_S *OsGetHwiForm(VOID) -{ - return g_hwiForm; -} - -/***************************************************************************** - Function : LOS_HwiCreate - Description : create hardware interrupt - Input : hwiNum --- hwi num to create - hwiPrio --- priority of the hwi - hwiMode --- hwi interrupt mode - hwiHandler --- hwi handler - irqParam --- param of the hwi handler - Output : None - Return : LOS_OK on success or error code on failure - *****************************************************************************/ -LITE_OS_SEC_TEXT UINT32 LOS_HwiCreate(HWI_HANDLE_T hwiNum, - HWI_PRIOR_T hwiPrio, - HWI_MODE_T hwiMode, - HWI_PROC_FUNC hwiHandler, - HWI_IRQ_PARAM_S irqParam) -{ - UINT32 intSave; - - if (hwiHandler == NULL) { - return OS_ERRNO_HWI_PROC_FUNC_NULL; - } - if (hwiNum >= OS_HWI_MAX_NUM) { - return OS_ERRNO_HWI_NUM_INVALID; - } - if (g_hwiForm[hwiNum].pfnHook == NULL) { - return OS_ERRNO_HWI_NUM_INVALID; - } else if (g_hwiForm[hwiNum].pfnHook != OsHwiDefaultHandler) { - return OS_ERRNO_HWI_NUM_INVALID; - } - if ((hwiPrio < OS_HWI_PRIO_LOWEST) || (hwiPrio > OS_HWI_PRIO_HIGHEST)) { - return OS_ERRNO_HWI_PRIO_INVALID; - } - - intSave = LOS_IntLock(); - g_hwiForm[hwiNum].pfnHook = hwiHandler; - g_hwiForm[hwiNum].uwParam = irqParam; - - if (hwiNum >= OS_RISCV_SYS_VECTOR_CNT) { - OsSetLocalInterPri(hwiNum, hwiPrio); - } - - LOS_IntRestore(intSave); - - return LOS_OK; -} - -/***************************************************************************** - Function : LOS_HwiDelete - 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) -{ - UINT32 intSave; - - if (hwiNum >= OS_HWI_MAX_NUM) { - return OS_ERRNO_HWI_NUM_INVALID; - } - - intSave = LOS_IntLock(); - g_hwiForm[hwiNum].pfnHook = OsHwiDefaultHandler; - g_hwiForm[hwiNum].uwParam = 0; - LOS_IntRestore(intSave); - return LOS_OK; -} - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ diff --git a/kernel/base/mem/common/los_slab.c b/kernel/base/mem/common/los_slab.c deleted file mode 100755 index 6ee33c95..00000000 --- a/kernel/base/mem/common/los_slab.c +++ /dev/null @@ -1,390 +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 -#include -#include "securec.h" -#include "los_slab_pri.h" -#include "los_heap_pri.h" - -#define LOW_BITS_MASK 31 -#define NUM_BITS_IN_ONE_BYTE 32 -#define NUMBITS_TO_NUMBYTES(numBits) (((numBits) + LOW_BITS_MASK) / 8) - -VOID OsAtomicBitsetInit(struct AtomicBitset *set, UINT32 numBits) -{ - set->numBits = numBits; - // Ignore the return code when matching CSEC rule 6.6(2). - (VOID)memset_s(set->words, NUMBITS_TO_NUMBYTES(numBits), 0, NUMBITS_TO_NUMBYTES(numBits)); - // mark all high bits so that OsAtomicBitsetFindClearAndSet() is simpler - if (numBits & LOW_BITS_MASK) { - set->words[numBits / NUM_BITS_IN_ONE_BYTE] = - ((UINT32)((INT32) - 1LL)) << (numBits & LOW_BITS_MASK); - } -} - -inline UINT32 OsAtomicBitsetGetNumBits(const struct AtomicBitset *set) -{ - return set->numBits; -} - -/************************************************************************** - Function : OsAtomicBitsetGetBit - Description : get the specified bit in set - Input : set --- pointer to the bitset - num --- the num to fetch - Output : None - Return : LOS_OK on success or error code on failure -**************************************************************************/ -BOOL OsAtomicBitsetGetBit(const struct AtomicBitset *set, UINT32 num) -{ - /* any value is as good as the next */ - if (num >= set->numBits) { - return FALSE; - } - return !!((set->words[num / NUM_BITS_IN_ONE_BYTE]) & (1UL << (num & LOW_BITS_MASK))); -} - -/************************************************************************** - Function : OsAtomicBitsetClearBit - Description : clear the specified bit in set - Input : set --- pointer to the bitset - num --- the num to clear - Output : None - Return : None -**************************************************************************/ -VOID OsAtomicBitsetClearBit(struct AtomicBitset *set, UINT32 num) -{ - UINT32 *wordPtr = set->words + (num / NUM_BITS_IN_ONE_BYTE); - - if (num >= set->numBits) { - return; - } - (*wordPtr) &= ~(1UL << (num & LOW_BITS_MASK)); -} - -/* find from the high bit to high bit return the address of the first available bit */ -INT32 OsAtomicBitsetFindClearAndSet(struct AtomicBitset *set) -{ - UINT32 idx; - UINT32 numWords = (set->numBits + LOW_BITS_MASK) / NUM_BITS_IN_ONE_BYTE; - UINT32 *wordPtr = set->words; - UINT32 tmpWord; - INT32 count = 0; - - for (idx = 0; idx < numWords; idx++, wordPtr++) { - if (*wordPtr == 0xFFFFFFFF) { - continue; - } - - tmpWord = ~(*wordPtr); - - while (tmpWord) { - tmpWord = tmpWord >> 1UL; - count++; - } - - *wordPtr |= (1UL << (count - 1)); - - return (INT32)(idx * NUM_BITS_IN_ONE_BYTE + count - 1); - } - - return -1; -} - -/* change the order of the output idx of OsAtomicBitsetFindClearAndSet to order of natural numbers */ -INT32 OsAtomicBitsetIdxChgToNatural(struct AtomicBitset *bitset, INT32 index) -{ - UINT32 ret; - UINT32 bit; - if (index < 0) { - return index; - } - bit = LOW_BITS_MASK + (index & ~LOW_BITS_MASK); - if (bit > bitset->numBits - 1) { - bit = bitset->numBits - 1; - } - ret = bit - (index & LOW_BITS_MASK); - return ret; -} - -/************************************************************************** - Function : OsAtomicBitsetEmpty - Description : check whether bitset is empty - Input : bitset --- pointer to the bitset - Output : None - Return : LOS_OK on success or error code on failure -**************************************************************************/ -BOOL OsAtomicBitsetEmpty(struct AtomicBitset *bitset) -{ - UINT32 idx = 0; - for (idx = 0; idx < (bitset->numBits / NUM_BITS_IN_ONE_BYTE);) { - if (bitset->words[idx] != 0) { - return FALSE; - } - idx++; - } - if (bitset->numBits & LOW_BITS_MASK) { - if (bitset->words[idx] & ~(0xFFFFFFFF << (bitset->numBits & LOW_BITS_MASK))) { - return FALSE; - } - } - return TRUE; -} - -/************************************************************************** - Function : OsSlabAllocatorNew - Description : create a new allocator - Input : pool --- pointer to the pool - itemSz --- alloc size - itemAlign --- aligned size - numItems --- item num - Output : None - Return : the pointer to a new allocator -**************************************************************************/ -OsSlabAllocator* OsSlabAllocatorNew(VOID *pool, UINT32 itemSz, UINT32 itemAlign, UINT32 numItems) -{ - OsSlabAllocator *allocator = NULL; - UINT32 bitSetSz; - UINT32 dataSz; - UINT32 itemSize; - - /* calculate size */ - bitSetSz = ATOMIC_BITSET_SZ(numItems); - - bitSetSz = (bitSetSz + itemAlign - 1) & (~(itemAlign - 1)); - itemSize = (itemSz + itemAlign - 1) & (~(itemAlign - 1)); - dataSz = itemSize * numItems; - - allocator = (OsSlabAllocator*)LOS_HeapAlloc(pool, sizeof(OsSlabAllocator) + bitSetSz + dataSz); - - if (allocator != NULL) { - allocator->itemSz = itemSize; - - allocator->bitset = (struct AtomicBitset *)(VOID *)((UINT8*)allocator + sizeof(OsSlabAllocator)); - allocator->dataChunks = ((UINT8*)allocator->bitset) + bitSetSz; - OsAtomicBitsetInit(allocator->bitset, numItems); - } - - return allocator; -} - - -/************************************************************************** - Function : OsSlabAllocatorDestroy - Description : free the specified allocator - Input : pool --- pointer to the pool - allocator --- pointer to the allocator - Output : None - Return : None -**************************************************************************/ -VOID OsSlabAllocatorDestroy(VOID *pool, OsSlabAllocator *allocator) -{ - (VOID)LOS_HeapFree(pool, allocator); -} - -/************************************************************************** - Function : OsSlabAllocatorAlloc - Description : alloc one bit from the specified allocator - Input : allocator --- pointer to the allocator - Output : None - Return : NULL on failure or one bit from the specified allocator -**************************************************************************/ -VOID* OsSlabAllocatorAlloc(OsSlabAllocator *allocator) -{ - INT32 itemIdx = OsAtomicBitsetFindClearAndSet(allocator->bitset); - if (itemIdx < 0) { - return NULL; - } - - return allocator->dataChunks + allocator->itemSz * itemIdx; -} - -/************************************************************************** - Function : OsSlabAllocatorFree - Description : free the specified bit in the specified allocator - Input : allocator --- pointer to the allocator - ptr --- pointer to the mem chunk to be freed - Output : None - Return : TRUE or FALSE -**************************************************************************/ -BOOL OsSlabAllocatorFree(OsSlabAllocator *allocator, VOID* ptr) -{ - UINT8 *ptrTmp = (UINT8*)ptr; - UINT32 itemOffset = ptrTmp - allocator->dataChunks; - UINT32 itemIdx = itemOffset / allocator->itemSz; - - // check for invalid inputs - if ((itemOffset % allocator->itemSz) || (itemIdx >= OsAtomicBitsetGetNumBits(allocator->bitset)) || - !(OsAtomicBitsetGetBit(allocator->bitset, itemIdx))) { - return FALSE; - } - - OsAtomicBitsetClearBit(allocator->bitset, itemIdx); - return TRUE; -} - -/************************************************************************** - Function : OsSlabAllocatorGetNth - Description : get the specified data chunk from the allocator - Input : allocator --- pointer to the allocator - idx --- chunk num - Output : None - Return : NULL on failure or specified data chunk on success -**************************************************************************/ -VOID* OsSlabAllocatorGetNth(OsSlabAllocator *allocator, UINT32 idx) -{ - if (!OsAtomicBitsetGetBit(allocator->bitset, idx)) { - return NULL; - } - - return allocator->dataChunks + allocator->itemSz * idx; -} - -/************************************************************************** - Function : OsSlabAllocatorGetIdxP - Description : get the specified dataChunk from the specified allocator - Input : allocator --- pointer to the allocator - idx --- chunk num - Output : None - Return : the specified data Chunk from the specified allocator -**************************************************************************/ -VOID* OsSlabAllocatorGetIdxP(OsSlabAllocator *allocator, UINT32 idx) -{ - return allocator->dataChunks + allocator->itemSz * idx; -} - -/************************************************************************** - Function : OsSlabAllocatorGetIndex - Description : get item index from the specified allocator - Input : allocator --- pointer to the allocator - ptr --- pointer to the mem chunk to get index - Output : None - Return : the item index from the specified allocator -**************************************************************************/ -UINT32 OsSlabAllocatorGetIndex(OsSlabAllocator *allocator, VOID* ptr) -{ - UINT8 *ptrTmp = (UINT8*)ptr; - UINT32 itemOffset = ptrTmp - allocator->dataChunks; - UINT32 itemIdx = itemOffset / allocator->itemSz; - - if ((itemOffset % allocator->itemSz) || - (itemIdx >= OsAtomicBitsetGetNumBits(allocator->bitset)) || - !(OsAtomicBitsetGetBit(allocator->bitset, itemIdx))) { - return (UINT32)(-1); - } - - return itemIdx; -} - -/************************************************************************** - Function : OsSlabAllocatorGetNumItems - Description : get num bits of the specified allocator - Input : allocator --- pointer to the allocator - Output : None - Return : LOS_OK on success or error code on failure -**************************************************************************/ -UINT32 OsSlabAllocatorGetNumItems(OsSlabAllocator *allocator) -{ - return OsAtomicBitsetGetNumBits(allocator->bitset); -} - -/************************************************************************** - Function : OsSlabAllocatorEmpty - Description : check whether the allocator is empty - Input : allocator --- pointer to the allocator - Output : None - Return : LOS_OK on success or error code on failure -**************************************************************************/ -BOOL OsSlabAllocatorEmpty(OsSlabAllocator *allocator) -{ - return OsAtomicBitsetEmpty(allocator->bitset); -} - -/************************************************************************** - Function : OsSlabAllocatorGetUsedItemCnt - Description : get used num of the specified allocator - Input : allocator --- pointer to the allocator - Output : None - Return : used num of the specifiedd allocator -**************************************************************************/ -UINT32 OsSlabAllocatorGetUsedItemCnt(OsSlabAllocator *allocator) -{ - UINT32 used; - UINT32 idx; - struct AtomicBitset *bitset = allocator->bitset; - for (used = 0, idx = 0; idx < bitset->numBits; idx++) { - if (OsAtomicBitsetGetBit(bitset, idx)) { - used++; - } - } - return used; -} - -/************************************************************************** - Function : OsSlabAllocatorGetSlabInfo - Description : get slab info from the specified allocator - Input : allocator --- pointer to the allocator - Output : pitemSz --- item size - itemCnt --- item count - curUsage --- current usage - Return : None -**************************************************************************/ -VOID OsSlabAllocatorGetSlabInfo(OsSlabAllocator *allocator, UINT32 *pitemSz, UINT32 *itemCnt, UINT32 *curUsage) -{ - *pitemSz = allocator->itemSz; - *itemCnt = OsAtomicBitsetGetNumBits(allocator->bitset); - *curUsage = OsSlabAllocatorGetUsedItemCnt(allocator); -} - -/************************************************************************** - Function : OsSlabAllocatorCheck - Description : check whether ptr is in allocator - Input : allocator --- pointer to the allocator - ptr --- pointer to the mem chunk to check - Output : None - Return : TRUE or FALSE -**************************************************************************/ -BOOL OsSlabAllocatorCheck(OsSlabAllocator *allocator, VOID* ptr) -{ - UINT8 *ptrTmp = (UINT8*)ptr; - UINT32 itemOffset = ptrTmp - allocator->dataChunks; - UINT32 itemIdx = itemOffset / allocator->itemSz; - - // check for invalid inputs - if ((itemOffset % allocator->itemSz) || (itemIdx >= OsAtomicBitsetGetNumBits(allocator->bitset)) || - !(OsAtomicBitsetGetBit(allocator->bitset, itemIdx))) { - return FALSE; - } - - return TRUE; -} - diff --git a/kernel/base/mem/common/los_slabmem.c b/kernel/base/mem/common/los_slabmem.c deleted file mode 100755 index c37e9b91..00000000 --- a/kernel/base/mem/common/los_slabmem.c +++ /dev/null @@ -1,307 +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. - */ - -#define _LOS_SLAB_MEM_C_ -#include -#include -#include - -VOID *OsSlabBlockHeadFill(OsSlabBlockNode *slabNode, UINT32 blkSz) -{ - OS_SLAB_BLOCK_MAGIC_SET(slabNode); - OS_SLAB_BLOCK_SIZE_SET(slabNode, blkSz); - OS_SLAB_BLOCK_ID_SET(slabNode, 0); // now undefine how to use ID - return (VOID *)(slabNode + 1); -} - -/***************************************************************************** - Function : OsSlabMemInit - Description : To initialize the slab memory management - Input : None - Output : None - Return : TRUE --- initialize OK, FALSE --- initialize false -*****************************************************************************/ -BOOL OsSlabMemInit(VOID *pool) -{ - struct LosSlabControlHeader *slabMemHead = OsSlabCtrlHdrGet(pool); - UINT32 idx = 0; - UINT32 tmp = 0; - UINT32 blkSz = 0; - UINT32 blkCnt = 0; - - for (idx = 0; idx < SLAB_MEM_COUNT; idx++) { - blkSz = (SLAB_MEM_CALSS_STEP_SIZE << idx); - blkCnt = SLAB_MEM_ALLOCATOR_SIZE / blkSz; - slabMemHead->slabClass[idx].blkSz = blkSz; - slabMemHead->slabClass[idx].blkCnt = blkCnt; - slabMemHead->slabClass[idx].blkUsedCnt = 0; - if (slabMemHead->slabClass[idx].alloc != NULL) { - PRINT_WARN("SlabMemAllocator[%d] inited before\n", idx); - tmp++; - } else { - slabMemHead->slabClass[idx].alloc = - OsSlabAllocatorNew(pool, blkSz + sizeof(OsSlabBlockNode), (UINT32)sizeof(VOID *), blkCnt); - } - } - - return ((tmp == 0) ? TRUE : FALSE); -} - -/***************************************************************************** - Function : OsSlabMemAlloc - Description : To alloc memory block - Input : pool --- pointer to the memory pool - size --- size of the memory we want to alloc - Output : None - Return : pointer :the address of the memory we alloced -*****************************************************************************/ -VOID *OsSlabMemAlloc(VOID *pool, UINT32 size) -{ - VOID *ret = NULL; - UINTPTR intSave; - struct LosSlabControlHeader *slabMem = OsSlabCtrlHdrGet(pool); - OsSlabMem *slabAlloc = NULL; - UINT32 idx; - - if (size > (SLAB_MEM_CALSS_STEP_SIZE << (SLAB_MEM_COUNT - 1))) { - return NULL; - } - - for (idx = 0; idx < SLAB_MEM_COUNT; idx++) { - if (size <= slabMem->slabClass[idx].blkSz) { - intSave = LOS_IntLock(); - - if (slabMem->slabClass[idx].blkUsedCnt >= slabMem->slabClass[idx].blkCnt) { - LOS_IntRestore(intSave); - return NULL; - } - - if (slabMem->slabClass[idx].alloc == NULL) { - LOS_IntRestore(intSave); - return NULL; - } - - slabAlloc = &(slabMem->slabClass[idx]); - ret = OsSlabAllocatorAlloc(slabAlloc->alloc); - if (ret != NULL) { - /* alloc success */ - ret = OsSlabBlockHeadFill((OsSlabBlockNode *)ret, slabMem->slabClass[idx].blkSz); - slabMem->slabClass[idx].blkUsedCnt++; - } - - LOS_IntRestore(intSave); - return ret; - } - } - - return NULL; -} - -/***************************************************************************** - Function : OsSlabMemFree - Description : To free the memory block - Input : pool --- Pointer to the memory pool that contains the memory block to be allocated - ptr --- the pointer of heap memory we want to free - Output : None - Return : TRUE:success FALSE:error -*****************************************************************************/ -BOOL OsSlabMemFree(VOID *pool, VOID* ptr) -{ - UINTPTR intSave; - struct LosSlabControlHeader *slabMem = OsSlabCtrlHdrGet(pool); - BOOL ret = FALSE; - OsSlabMem *slabAlloc = NULL; - UINT32 idx; - OsSlabBlockNode *slabNode = OS_SLAB_BLOCK_HEAD_GET(ptr); - - if (!OS_ALLOC_FROM_SLAB_CHECK(slabNode)) { - return FALSE; - } - for (idx = 0; idx < SLAB_MEM_COUNT; idx++) { - if (slabMem->slabClass[idx].blkSz >= OS_SLAB_BLOCK_SIZE_GET(slabNode)) { - intSave = LOS_IntLock(); - - slabAlloc = &(slabMem->slabClass[idx]); - if (TRUE == OsSlabAllocatorFree(slabAlloc->alloc, slabNode)) { - ret = TRUE; - slabMem->slabClass[idx].blkUsedCnt--; - } - - LOS_IntRestore(intSave); - return ret; - } - } - return FALSE; -} - -/***************************************************************************** - Function : OsSlabMemDeinit - Description : deinitialize the slab memory ,set back to the original status - Input : pool --- Pointer to the memory pool - Output : None - Return : None -*****************************************************************************/ -VOID OsSlabMemDeinit(VOID *pool) -{ - UINT32 idx; - struct LosSlabControlHeader *slabMem = NULL; - OsSlabMem *slabAlloc = NULL; - UINT32 blkSz; - UINT32 blkCnt; - - if (pool == NULL) { - return ; - } - slabMem = OsSlabCtrlHdrGet(pool); - - for (idx = 0; idx < SLAB_MEM_COUNT; idx++) { - blkSz = (SLAB_MEM_CALSS_STEP_SIZE << idx); - blkCnt = SLAB_MEM_ALLOCATOR_SIZE / blkSz; - slabMem->slabClass[idx].blkSz = blkSz; - slabMem->slabClass[idx].blkCnt = blkCnt; - if (slabMem->slabClass[idx].alloc != NULL) { - slabAlloc = &(slabMem->slabClass[idx]); - OsSlabAllocatorDestroy(pool, slabAlloc->alloc); - slabMem->slabClass[idx].alloc = NULL; - } - } - return ; -} - -/************************************************************************** - Function : OsSlabMemCheck - Description : check slab memory - Input : pool --- pointer to the memory pool - ptr --- pointer to the memory chunk - Output : None - Return : LOS_OK on success or error code on failure -**************************************************************************/ -UINT32 OsSlabMemCheck(VOID *pool, VOID* ptr) -{ - UINTPTR intSave; - struct LosSlabControlHeader *slabMem = OsSlabCtrlHdrGet(pool); - UINT32 retBlkSz = (UINT32)-1; - OsSlabMem *slabAlloc = NULL; - UINT32 idx; - OsSlabBlockNode *slabNode = OS_SLAB_BLOCK_HEAD_GET(ptr); - - if ((!OS_ALLOC_FROM_SLAB_CHECK(slabNode)) || - slabMem->slabClass[SLAB_MEM_COUNT - 1].blkSz > (OS_SLAB_BLOCK_SIZE_GET(slabNode))) { - return retBlkSz; - } - - intSave = LOS_IntLock(); - for (idx = 0; idx < SLAB_MEM_COUNT; idx++) { - slabAlloc = &(slabMem->slabClass[idx]); - if (OsSlabAllocatorCheck(slabAlloc->alloc, slabNode) == TRUE) { - retBlkSz = slabMem->slabClass[idx].blkSz; - } - } - LOS_IntRestore(intSave); - - return retBlkSz; -} - -/************************************************************************** - Function : OsSlabStatisticsGet - Description : collect slab statistics - Input : pool --- pointer to the memory pool - Output : status --- memory pool statistics - Return : LOS_OK on success or error code on failure -**************************************************************************/ -UINT32 OsSlabStatisticsGet(VOID *pool, LosSlabStatus *status) -{ - struct LosSlabControlHeader *slabMem = NULL; - OsSlabMem *slabAlloc = NULL; - UINT32 itemSz = 0; - UINT32 itemCnt = 0; - UINT32 curUsage = 0; - UINT32 totalUsage = 0; - UINT32 totalMem = 0; - UINT32 totalAllocCount = 0; - UINT32 totalFreeCount = 0; - UINT32 idx; - - if ((status == NULL) || (pool == NULL)) { - return LOS_NOK; - } - slabMem = OsSlabCtrlHdrGet(pool); - - for (idx = 0; idx < SLAB_MEM_COUNT; idx++) { - slabAlloc = &(slabMem->slabClass[idx]); - - OsSlabAllocatorGetSlabInfo(slabAlloc->alloc, &itemSz, &itemCnt, &curUsage); - totalUsage += (curUsage * itemSz); - totalMem += (itemCnt * itemSz); - totalAllocCount += slabMem->slabClass[idx].blkUsedCnt; - totalFreeCount += slabMem->slabClass[idx].blkCnt - slabMem->slabClass[idx].blkUsedCnt; - } - - if (totalMem < totalUsage) { - return LOS_NOK; - } - - status->totalSize = totalMem; - status->usedSize = totalUsage; - status->freeSize = status->totalSize - status->usedSize; - status->allocCount = totalAllocCount; - status->freeCount = totalFreeCount; - return LOS_OK; -} - -/************************************************************************** - Function : OsSlabGetMaxFreeBlkSize - Description : get max free block size - Input : pool --- pointer to the memory pool - Output : None - Return : max free block size -**************************************************************************/ -UINT32 OsSlabGetMaxFreeBlkSize(VOID *pool) -{ - struct LosSlabControlHeader *slabMem = OsSlabCtrlHdrGet(pool); - OsSlabMem *slabAlloc = NULL; - UINT32 itemSz = 0; - UINT32 itemCnt = 0; - UINT32 curUsage = 0; - int idx; - - for (idx = SLAB_MEM_COUNT - 1; idx >= 0; idx--) { - slabAlloc = &(slabMem->slabClass[idx]); - if (slabAlloc->alloc) { - OsSlabAllocatorGetSlabInfo(slabAlloc->alloc, &itemSz, &itemCnt, &curUsage); - if (curUsage != itemCnt) { - return itemSz; - } - } - } - - return 0; -} diff --git a/kernel/include/los_base.h b/kernel/include/los_base.h deleted file mode 100755 index fe5a3dcb..00000000 --- a/kernel/include/los_base.h +++ /dev/null @@ -1,261 +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. - */ - -/** - * @defgroup kernel Kernel - * @defgroup los_base Basic definitions - * @ingroup kernel - */ - -#ifndef _LOS_BASE_H -#define _LOS_BASE_H - -#include "los_builddef.h" -#include "los_typedef.h" -#include "los_config.h" -#include "los_list.h" -#include "los_errno.h" -#include "los_compiler.h" -#include "los_hwi.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#define SIZE(a) (a) - -#define LOS_ASSERT_COND(expression) - -/** - * @ingroup los_base - * Define the timeout interval as LOS_NO_WAIT. - */ -#define LOS_NO_WAIT 0 - -/** - * @ingroup los_base - * Define the timeout interval as LOS_WAIT_FOREVER. - */ -#define LOS_WAIT_FOREVER 0xFFFFFFFF - -/** - * @ingroup los_base - * Align the beginning of the object with the base address addr, - * with boundary bytes being the smallest unit of alignment. - */ -#ifndef ALIGN -#define ALIGN(addr, boundary) LOS_Align(addr, boundary) -#endif -/** - * @ingroup los_base - * Align the tail of the object with the base address addr, with size bytes being the smallest unit of alignment. - */ -#define TRUNCATE(addr, size) ((addr) & ~((size)-1)) - -/** - * @ingroup los_base - * Read a UINT8 value from addr and stroed in value. - */ -#define READ_UINT8(value, addr) ((value) = *((volatile UINT8 *)(addr))) -/** - * @ingroup los_base - * Read a UINT16 value from addr and stroed in addr. - */ -#define READ_UINT16(value, addr) ((value) = *((volatile UINT16 *)(addr))) -/** - * @ingroup los_base - * Read a UINT32 value from addr and stroed in value. - */ -#define READ_UINT32(value, addr) ((value) = *((volatile UINT32 *)(addr))) -/** - * @ingroup los_base - * Read a UINT64 value from addr and stroed in value. - */ -#define READ_UINT64(value, addr) ((value) = *((volatile UINT64 *)(addr))) - -/** - * @ingroup los_base - * Get a UINT8 value from addr. - */ -#define GET_UINT8(addr) (*((volatile UINT8 *)(addr))) -/** - * @ingroup los_base - * Get a UINT16 value from addr. - */ -#define GET_UINT16(addr) (*((volatile UINT16 *)(addr))) -/** - * @ingroup los_base - * Get a UINT32 value from addr. - */ -#define GET_UINT32(addr) (*((volatile UINT32 *)(addr))) -/** - * @ingroup los_base - * Get a UINT64 value from addr. - */ -#define GET_UINT64(addr) (*((volatile UINT64 *)(addr))) - -/** - * @ingroup los_base - * Write a UINT8 value to addr. - */ -#define WRITE_UINT8(value, addr) (*((volatile UINT8 *)(addr)) = (value)) -/** - * @ingroup los_base - * Write a UINT16 value to addr. - */ -#define WRITE_UINT16(value, addr) (*((volatile UINT16 *)(addr)) = (value)) -/** - * @ingroup los_base - * Write a UINT32 value to addr. - */ -#define WRITE_UINT32(value, addr) (*((volatile UINT32 *)(addr)) = (value)) -/** - * @ingroup los_base - * Write a UINT64 addr to addr. - */ -#define WRITE_UINT64(value, addr) (*((volatile UINT64 *)(addr)) = (value)) - -#if PRINT_LEVEL < LOS_ERR_LEVEL -#define LOS_ASSERT(judge) -#else -#define LOS_ASSERT(judge) \ - do { \ - if ((judge) == 0) { \ - (VOID)LOS_IntLock(); \ - PRINT_ERR("ASSERT ERROR! %s, %d, %s\n", __FILE__, __LINE__, __func__); \ - while (1) { } \ - } \ - } while (0) -#endif - -/** - * @ingroup los_base - * @brief Align the value (addr) by some bytes (boundary) you specify. - * - * @par Description: - * This API is used to align the value (addr) by some bytes (boundary) you specify. - * - * @attention - *
    - *
  • the value of boundary usually is 4,8,16,32.
  • - *
- * - * @param addr [IN] The variable what you want to align. - * @param boundary [IN] The align size what you want to align. - * - * @retval #UINT32 The variable what have been aligned. - * @par Dependency: - *
  • los_base.h: the header file that contains the API declaration.
- * @see - */ -extern UINT32 LOS_Align(UINT32 addr, UINT32 boundary); - -/** - * @ingroup los_base - * @brief Sleep the current task. - * - * @par Description: - * This API is used to delay the execution of the current task. The task is able to be scheduled - * after it is delayed for a specified number of Ticks. - * - * @attention - *
    - *
  • The task fails to be delayed if it is being delayed during interrupt processing or it is locked.
  • - *
  • If 0 is passed in and the task scheduling is not locked, - * execute the next task in the queue of tasks with the priority of the current task. - * If no ready task with the priority of the current task is available, - * the task scheduling will not occur, and the current task continues to be executed.
  • - *
  • The parameter passed in can not be equal to LOS_WAIT_FOREVER(0xFFFFFFFF). - * If that happens, the task will not sleep 0xFFFFFFFF milliseconds or sleep forever but sleep 0xFFFFFFFF Ticks.
  • - *
- * - * @param mSecs [IN] Type #UINT32 Number of MS for which the task is delayed. - * - * @retval None - * @par Dependency: - *
  • los_base.h: the header file that contains the API declaration.
- * @see None - */ -extern VOID LOS_Msleep(UINT32 mSecs); - -/** - * @ingroup los_base - * @brief System kernel initialization function. - * - * @par Description: - * This API is used to start liteOS . - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param: None. - * - * @retval #LOS_OK 0:LiteOS start success. - * - * @par Dependency: - *
  • los_config.h: the header file that contains the API declaration.
- * @see - */ -extern UINT32 LOS_Start(VOID); - -/** - * @ingroup los_base - * @brief System kernel initialization function. - * - * @par Description: - * This API is used to Initialize kernel ,configure all system modules. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param: None. - * - * @retval #LOS_OK 0:System kernel initialization success. - * - * @par Dependency: - *
  • los_config.h: the header file that contains the API declaration.
- * @see - */ -extern UINT32 LOS_KernelInit(VOID); - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_BASE_H */ diff --git a/kernel/include/los_builddef.h b/kernel/include/los_builddef.h deleted file mode 100755 index ad7bce00..00000000 --- a/kernel/include/los_builddef.h +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: 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. - * --------------------------------------------------------------------------- - * 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_builddef - * @ingroup kernel - */ - -#ifndef _LOS_BUILDEF_H -#define _LOS_BUILDEF_H - -#include "los_compiler.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cpluscplus */ -#endif /* __cpluscplus */ - -/** - * @ingroup los_builddef - * Define inline keyword - */ -#ifndef INLINE -#define INLINE static inline -#endif - -/** - * @ingroup los_builddef - * Little endian - */ -#define OS_LITTLE_ENDIAN 0x1234 - -/** - * @ingroup los_builddef - * Big endian - */ -#define OS_BIG_ENDIAN 0x4321 - -/** - * @ingroup los_builddef - * Byte order - */ -#ifndef OS_BYTE_ORDER -#define OS_BYTE_ORDER OS_LITTLE_ENDIAN -#endif - -/* Define OS code data sections */ -/* The indicator function is inline */ - -/** - * @ingroup los_builddef - * Allow inline sections - */ -#ifndef LITE_OS_SEC_ALW_INLINE -#define LITE_OS_SEC_ALW_INLINE //__attribute__((always_inline)) -#endif - -/** - * @ingroup los_builddef - * Vector table section - */ -#ifndef LITE_OS_SEC_VEC -#define LITE_OS_SEC_VEC __attribute__ ((section(".vector"))) -#endif - -/** - * @ingroup los_builddef - * .Text section (Code section) - */ -#ifndef LITE_OS_SEC_TEXT -#define LITE_OS_SEC_TEXT //__attribute__((section(".sram.text"))) -#endif - -/** - * @ingroup los_builddef - * .Text.ddr section - */ -#ifndef LITE_OS_SEC_TEXT_MINOR -#define LITE_OS_SEC_TEXT_MINOR // __attribute__((section(".dyn.text"))) -#endif - -/** - * @ingroup los_builddef - * .Text.init section - */ -#ifndef LITE_OS_SEC_TEXT_INIT -#define LITE_OS_SEC_TEXT_INIT //__attribute__((section(".dyn.text"))) -#endif - -/** - * @ingroup los_builddef - * .Data section - */ -#ifndef LITE_OS_SEC_DATA -#define LITE_OS_SEC_DATA //__attribute__((section(".dyn.data"))) -#endif - -/** - * @ingroup los_builddef - * .Data.init section - */ -#ifndef LITE_OS_SEC_DATA_INIT -#define LITE_OS_SEC_DATA_INIT //__attribute__((section(".dyn.data"))) -#endif - -/** - * @ingroup los_builddef - * Not initialized variable section - */ -#ifndef LITE_OS_SEC_BSS -#define LITE_OS_SEC_BSS //__attribute__((section(".sym.bss"))) -#endif - -/** - * @ingroup los_builddef - * .bss.ddr section - */ -#ifndef LITE_OS_SEC_BSS_MINOR -#define LITE_OS_SEC_BSS_MINOR -#endif - -/** - * @ingroup los_builddef - * .bss.init sections - */ -#ifndef LITE_OS_SEC_BSS_INIT -#define LITE_OS_SEC_BSS_INIT -#endif - -#ifndef LITE_OS_SEC_TEXT_DATA -#define LITE_OS_SEC_TEXT_DATA //__attribute__((section(".dyn.data"))) -#define LITE_OS_SEC_TEXT_BSS //__attribute__((section(".dyn.bss"))) -#define LITE_OS_SEC_TEXT_RODATA //__attribute__((section(".dyn.rodata"))) -#endif - -#ifndef LITE_OS_SEC_SYMDATA -#define LITE_OS_SEC_SYMDATA //__attribute__((section(".sym.data"))) -#endif - -#ifndef LITE_OS_SEC_SYMBSS -#define LITE_OS_SEC_SYMBSS //__attribute__((section(".sym.bss"))) -#endif - - -#ifndef LITE_OS_SEC_KEEP_DATA_DDR -#define LITE_OS_SEC_KEEP_DATA_DDR //__attribute__((section(".keep.data.ddr"))) -#endif - -#ifndef LITE_OS_SEC_KEEP_TEXT_DDR -#define LITE_OS_SEC_KEEP_TEXT_DDR //__attribute__((section(".keep.text.ddr"))) -#endif - -#ifndef LITE_OS_SEC_KEEP_DATA_SRAM -#define LITE_OS_SEC_KEEP_DATA_SRAM //__attribute__((section(".keep.data.sram"))) -#endif - -#ifndef LITE_OS_SEC_KEEP_TEXT_SRAM -#define LITE_OS_SEC_KEEP_TEXT_SRAM //__attribute__((section(".keep.text.sram"))) -#endif - -#ifndef LITE_OS_SEC_BSS_MINOR -#define LITE_OS_SEC_BSS_MINOR -#endif - -#ifndef INCLUDE_pxTaskGetStackStart -#define INCLUDE_pxTaskGetStackStart 0 -#endif - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cpluscplus */ -#endif /* __cpluscplus */ - - -#endif /* _LOS_BUILDEF_H */ diff --git a/kernel/include/los_compiler.h b/kernel/include/los_compiler.h deleted file mode 100755 index e3ac96c0..00000000 --- a/kernel/include/los_compiler.h +++ /dev/null @@ -1,143 +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. - */ - -#ifndef _LOS_COMPILER_H -#define _LOS_COMPILER_H - -/* for IAR Compiler */ -#ifdef __ICCARM__ -#include"iccarm_builtin.h" -#endif - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -/* for IAR Compiler */ -#ifdef __ICCARM__ - -#ifndef ASM -#define ASM __asm -#endif - -#ifndef INLINE -#define INLINE inline -#endif - -#ifndef STATIC_INLINE -#define STATIC_INLINE static inline -#endif - -#ifndef USED -#define USED __root -#endif - -#ifndef WEAK -#define WEAK __weak -#endif - -#ifndef CLZ -#define CLZ __iar_builtin_CLZ -#endif - -/* for ARM Compiler */ -#elif defined(__CC_ARM) - -#ifndef ASM -#define ASM __asm -#endif - -#ifndef INLINE -#define INLINE __inline -#endif - -#ifndef STATIC_INLINE -#define STATIC_INLINE static __inline -#endif - -#ifndef USED -#define USED __attribute__((used)) -#endif - -#ifndef WEAK -#define WEAK __attribute__((weak)) -#endif - -#ifndef CLZ -#define CLZ __clz -#endif - -#pragma anon_unions - -/* for GNU Compiler */ -#elif defined(__GNUC__) - -#ifndef ASM -#define ASM __asm -#endif - -#ifndef INLINE -#define INLINE inline -#endif - -#ifndef STATIC -#define STATIC static -#endif - -#ifndef STATIC_INLINE -#define STATIC_INLINE static inline -#endif - -#ifndef USED -#define USED __attribute__((used)) -#endif - -#ifndef WEAK -#define WEAK __attribute__((weak)) -#endif - -#ifndef CLZ -#define CLZ __builtin_clz -#endif - -#else -#error Unknown compiler. -#endif - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_COMPILER_H */ diff --git a/kernel/include/los_config.h b/kernel/include/los_config.h index 6463d9d0..5fc03de9 100755 --- a/kernel/include/los_config.h +++ b/kernel/include/los_config.h @@ -37,7 +37,6 @@ #ifndef _LOS_CONFIG_H #define _LOS_CONFIG_H -#include "los_typedef.h" #include "target_config.h" #ifdef __cplusplus @@ -442,7 +441,7 @@ extern UINT32 g_sysMemAddrEnd; * Configuration module tailoring of more mempry pool checking */ #ifndef LOSCFG_MEM_MUL_POOL -#define LOSCFG_MEM_MUL_POOL NO +#define LOSCFG_MEM_MUL_POOL YES #endif /** diff --git a/kernel/include/los_cpup.h b/kernel/include/los_cpup.h deleted file mode 100755 index 27826b89..00000000 --- a/kernel/include/los_cpup.h +++ /dev/null @@ -1,308 +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. - */ - -/** - * @defgroup los_cpup CPU usage - * @ingroup kernel - */ - -#ifndef _LOS_CPUP_H -#define _LOS_CPUP_H - -#include "los_hwi.h" -#include "los_base.h" -#include "los_sys.h" -#include "los_task.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - - -/** -* @ingroup los_cpup -* CPU usage error code: The request for memory fails. -* -* Value: 0x02001e00 -* -* Solution: Decrease the maximum number of tasks. -*/ -#define LOS_ERRNO_CPUP_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_CPUP, 0x00) - -/** -* @ingroup los_cpup -* CPU usage error code: The pointer to an input parameter is NULL. -* -* Value: 0x02001e01 -* -* Solution: Check whether the pointer to the input parameter is usable. -*/ -#define LOS_ERRNO_CPUP_TASK_PTR_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_CPUP, 0x01) - -/** -* @ingroup los_cpup -* CPU usage error code: The CPU usage is not initialized. -* -* Value: 0x02001e02 -* -* Solution: Check whether the CPU usage is initialized. -*/ -#define LOS_ERRNO_CPUP_NO_INIT LOS_ERRNO_OS_ERROR(LOS_MOD_CPUP, 0x02) - -/** -* @ingroup los_cpup -* CPU usage error code: The number of threads is invalid. -* -* Value: 0x02001e03 -* -* Solution: Check whether the number of threads is applicable for the current operation. -*/ -#define LOS_ERRNO_CPUP_MAXNUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_CPUP, 0x03) - -/** -* @ingroup los_cpup -* CPU usage error code: The target thread is not created. -* -* Value: 0x02001e04 -* -* Solution: Check whether the target thread is created. -*/ -#define LOS_ERRNO_CPUP_THREAD_NO_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_CPUP, 0x04) - -/** -* @ingroup los_cpup -* CPU usage error code: The target task ID is invalid. -* -* Value: 0x02001e05 -* -* Solution: Check whether the target task ID is applicable for the current operation. -*/ -#define LOS_ERRNO_CPUP_TSK_ID_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_CPUP, 0x05) - -/** -* @ingroup los_cpup -* Sum of cpup with all tasks. It means the value of cpup is a permillage. -*/ -#define LOS_CPUP_PRECISION 1000 - -/** -* @ingroup los_cpup -* Multiple of current cpup precision change to percent. -*/ -#define LOS_CPUP_PRECISION_MULT (LOS_CPUP_PRECISION / 100) - -/** - * @ingroup los_cpup - * Count the CPU usage structures of all tasks. - */ -typedef struct tagCpupInfo { - UINT16 usStatus; /**< save the cur task status */ - UINT32 uwUsage; /**< Usage. The value range is [0,1000]. */ -} CPUP_INFO_S; - -/** - * @ingroup los_monitor - * Type of the CPU usage query. - */ -typedef enum { - SYS_CPU_USAGE = 0, /* system cpu occupancy rate */ - TASK_CPU_USAGE, /* task cpu occupancy rate */ -} CPUP_TYPE_E; - -/** - * @ingroup los_monitor - * Mode of the CPU usage query. - */ -typedef enum { - CPUP_IN_10S = 0, /* cpu occupancy rate in 10s */ - CPUP_IN_1S, /* cpu occupancy rate in 1s */ - CPUP_LESS_THAN_1S, /* cpu occupancy rate less than 1s, if the input mode is none of them, it will be this. */ -} CPUP_MODE_E; - -/** - * @ingroup los_cpup - * @brief Obtain the current CPU usage. - * - * @par Description: - * This API is used to obtain the current CPU usage. - * @attention - *
    - *
  • This API can be called only after the CPU usage is initialized. Otherwise, error codes will be returned.
  • - *
  • The precision of the CPU usage can be adjusted by changing the value of the CPUP_PRECISION macro.
  • - *
- * - * @param None. - * - * @retval #OS_ERRNO_CPUP_NO_INIT 0x02001e02: The CPU usage is not initialized. - * @retval #cpup [0,100], current CPU usage, of which the precision is adjustable. - * @par Dependency: - *
  • los_cpup.h: the header file that contains the API declaration.
- * @see LOS_SysCpuUsage - */ -extern UINT32 LOS_SysCpuUsage(VOID); - -/** - * @ingroup los_cpup - * @brief Obtain the historical CPU usage. - * - * @par Description: - * This API is used to obtain the historical CPU usage. - * @attention - *
    - *
  • This API can be called only after the CPU usage is initialized. Otherwise, the CPU usage fails to be obtained.
  • - *
- * - * @param mode [IN] UINT16. Task mode. The parameter value 0 indicates that the CPU usage within 10s will be - * obtained, and the parameter value 1 indicates that the CPU usage in the former 1s will be obtained. Other values - * indicate that the CPU usage in the period that is less than 1s will be obtained. - * - * @retval #OS_ERRNO_CPUP_NO_INIT 0x02001e02: The CPU usage is not initialized. - * @retval #cpup [0,100], historical CPU usage, of which the precision is adjustable. - * @par Dependency: - *
  • los_cpup.h: the header file that contains the API declaration.
- * @see LOS_HistoryTaskCpuUsage - */ -extern UINT32 LOS_HistorySysCpuUsage(UINT16 mode); - -/** - * @ingroup los_cpup - * @brief Obtain the CPU usage of a specified task. - * - * @par Description: - * This API is used to obtain the CPU usage of a task specified by a passed-in task ID. - * @attention - *
    - *
  • This API can be called only after the CPU usage is initialized. Otherwise, the CPU usage fails to be obtained.
  • - *
  • The passed-in task ID must be valid and the task specified by the task ID must be created. Otherwise, - * the CPU usage fails to be obtained.
  • - *
- * - * @param taskID [IN] UINT32. Task ID. - * - * @retval #OS_ERRNO_CPUP_NO_INIT 0x02001e02: The CPU usage is not initialized. - * @retval #OS_ERRNO_CPUP_TSK_ID_INVALID 0x02001e05: The target task ID is invalid. - * @retval #OS_ERRNO_CPUP_THREAD_NO_CREATED 0x02001e04: The target thread is not created. - * @retval #cpup [0,100], CPU usage of the specified task. - * @par Dependency: - *
  • los_cpup.h: the header file that contains the API declaration.
- * @see LOS_HistoryTaskCpuUsage - */ -extern UINT32 LOS_TaskCpuUsage(UINT32 taskID); - -/** - * @ingroup los_cpup - * @brief Obtain the historical CPU usage of a specified task. - * - * @par Description: - * This API is used to obtain the historical CPU usage of a task specified by a passed-in task ID. - * @attention - *
    - *
  • This API can be called only after the CPU usage is initialized. Otherwise, - * the CPU usage fails to be obtained.
  • - *
  • The passed-in task ID must be valid and the task specified by the task ID must be created. Otherwise, - * the CPU usage fails to be obtained.
  • - *
- * - * @param taskID [IN] UINT32. Task ID. - * @param mode [IN] UINT16. Task mode. The parameter value 0 indicates that the CPU usage within 10s - * will be obtained, and the parameter value 1 indicates that the CPU usage in the former 1s will be obtained. - * Other values indicate that the CPU usage in the period that is less than 1s will be obtained. - * - * @retval #OS_ERRNO_CPUP_NO_INIT 0x02001e02: The CPU usage is not initialized. - * @retval #OS_ERRNO_CPUP_TSK_ID_INVALID 0x02001e05: The target task ID is invalid. - * @retval #OS_ERRNO_CPUP_THREAD_NO_CREATED 0x02001e04: The target thread is not created. - * @retval #cpup [0,100], CPU usage of the specified task. - * @par Dependency: - *
  • los_cpup.h: the header file that contains the API declaration.
- * @see LOS_HistorySysCpuUsage - */ -extern UINT32 LOS_HistoryTaskCpuUsage(UINT32 taskID, UINT16 mode); - -/** - * @ingroup los_cpup - * @brief Obtain the CPU usage of all tasks. - * - * @par Description: - * This API is used to obtain the CPU usage of all tasks according to maximum number of threads. - * @attention - *
    - *
  • This API can be called only after the CPU usage is initialized. Otherwise, the CPU usage fails to be obtained.
  • - *
  • The input parameter pointer must not be NULL, Otherwise, the CPU usage fails to be obtained.
  • - *
- * - * @param cpupInfo [OUT]Type. CPUP_INFO_S* Pointer to the task CPUP information structure to be obtained. - * @param mode [IN] UINT16. Task mode. The parameter value 0 indicates that the CPU usage within 10s - * will be obtained, and the parameter value 1 indicates that the CPU usage in the former 1s will be obtained. - * Other values indicate that the CPU usage in the period that is less than 1s will be obtained. - * - * @retval #OS_ERRNO_CPUP_NO_INIT 0x02001e02: The CPU usage is not initialized. - * @retval #OS_ERRNO_CPUP_TASK_PTR_NULL 0x02001e01: The input parameter pointer is NULL. - * @retval #LOS_OK 0x00000000: The CPU usage of all tasks is successfully obtained. - * @par Dependency: - *
  • los_cpup.h: the header file that contains the API declaration.
- * @see LOS_SysCpuUsage - */ -extern UINT32 LOS_AllTaskCpuUsage(CPUP_INFO_S *cpupInfo, UINT16 mode); - -/** - * @ingroup los_monitor - * @brief Obtain CPU usage history of certain task. - * - * @par Description: - * This API is used to obtain CPU usage history of certain task. - * @attention - *
    - *
  • This API can be called only after the CPU usage is initialized. Otherwise, -1 will be returned.
  • - *
  • Only in SYS_CPU_USAGE type, uwTaskID is invalid.
  • - *
- * - * @param type [IN] cpup type, SYS_CPU_USAGE and TASK_CPU_USAGE - * @param mode [IN] mode,CPUP_IN_10S = usage in 10s,CPUP_IN_1S = usage in last 1s, - * CPUP_LESS_THAN_1S = less than 1s, if the inpuit mode is none of them, it will be as CPUP_LESS_THAN_1S. - * @param taskID [IN] task ID, Only in SYS_CPU_USAGE type, taskID is invalid - * - * @retval #OS_ERROR -1:CPU usage info obtain failed. - * @retval #LOS_OK 0:CPU usage info is successfully obtained. - * @par Dependency: - *
  • los_monitor.h: the header file that contains the API declaration.
- * @see LOS_CpupUsageMonitor - */ -extern UINT32 LOS_CpupUsageMonitor(CPUP_TYPE_E type, CPUP_MODE_E mode, UINT32 taskID); - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_CPUP_H */ diff --git a/kernel/include/los_errno.h b/kernel/include/los_errno.h deleted file mode 100755 index 7a964733..00000000 --- a/kernel/include/los_errno.h +++ /dev/null @@ -1,115 +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. - */ - -/** - * @defgroup los_errno Error code - * @ingroup kernel - */ - -#ifndef _LOS_ERRNO_H -#define _LOS_ERRNO_H - -#include "los_typedef.h" -#include "los_err.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - - -/** - * @ingroup los_errno - * OS error code flag. - */ -#define LOS_ERRNO_OS_ID ((UINT32)0x00 << 16) - -/** - * @ingroup los_errno - * Define the error level as informative. - */ -#define LOS_ERRTYPE_NORMAL ((UINT32)0x00 << 24) - -/** - * @ingroup los_errno - * Define the error level as warning. - */ -#define LOS_ERRTYPE_WARN ((UINT32)0x01 << 24) - -/** - * @ingroup los_errno - * Define the error level as critical. - */ -#define LOS_ERRTYPE_ERROR ((UINT32)0x02 << 24) - -/** - * @ingroup los_errno - * Define the error level as fatal. - */ -#define LOS_ERRTYPE_FATAL ((UINT32)0x03 << 24) - -/** - * @ingroup los_errno - * Define fatal OS errors. - */ -#define LOS_ERRNO_OS_FATAL(moduleID, errno) \ - (LOS_ERRTYPE_FATAL | LOS_ERRNO_OS_ID | ((UINT32)(moduleID) << 8) | (errno)) - -/** - * @ingroup los_errno - * Define critical OS errors. - */ -#define LOS_ERRNO_OS_ERROR(moduleID, errno) \ - (LOS_ERRTYPE_ERROR | LOS_ERRNO_OS_ID | ((UINT32)(moduleID) << 8) | (errno)) - -/** - * @ingroup los_errno - * Define warning OS errors. - */ -#define LOS_ERRNO_OS_WARN(moduleID, errno) \ - (LOS_ERRTYPE_WARN | LOS_ERRNO_OS_ID | ((UINT32)(moduleID) << 8) | (errno)) - -/** - * @ingroup los_errno - * Define informative OS errors. - */ -#define LOS_ERRNO_OS_NORMAL(moduleID, errno) \ - (LOS_ERRTYPE_NORMAL | LOS_ERRNO_OS_ID | ((UINT32)(moduleID) << 8) | (errno)) - - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_ERRNO_H */ diff --git a/kernel/include/los_event.h b/kernel/include/los_event.h index 77dc0ce8..7e0c0cf1 100755 --- a/kernel/include/los_event.h +++ b/kernel/include/los_event.h @@ -37,7 +37,6 @@ #ifndef _LOS_EVENT_H #define _LOS_EVENT_H -#include "los_base.h" #include "los_list.h" #ifdef __cplusplus @@ -321,6 +320,9 @@ extern UINT32 LOS_EventClear(PEVENT_CB_S eventCB, UINT32 events); */ extern UINT32 LOS_EventDestroy(PEVENT_CB_S eventCB); +extern UINT32 OsEventReadOnce(PEVENT_CB_S eventCB, UINT32 eventMask, UINT32 mode, UINT32 timeOut); +extern UINT32 OsEventWriteOnce(PEVENT_CB_S eventCB, UINT32 events); + #ifdef __cplusplus #if __cplusplus } diff --git a/kernel/include/los_heap.h b/kernel/include/los_heap.h deleted file mode 100755 index 06d9d16d..00000000 --- a/kernel/include/los_heap.h +++ /dev/null @@ -1,232 +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. - */ - -/** - * @defgroup los_heap Heap - * @ingroup kernel - */ - -#ifndef _LOS_HEAP_H -#define _LOS_HEAP_H - -#include -#include "los_base.h" -#if (LOSCFG_KERNEL_MEM_SLAB == YES) -#include "los_slab.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#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)) - -#define RAM_HEAP_SIZE ((OS_SYS_MEM_SIZE) & (~7)) -#define RAM_HEAP_START (OS_SYS_MEM_ADDR) - -#ifdef CONFIG_DDR_HEAP -#define DDR_HEAP_INIT() LOS_HeapInit((VOID *)DDR_HEAP_START, DDR_HEAP_SIZE) -#define DDR_HEAP_ALLOC(sz) LOS_HeapAllocAlign((VOID *)DDR_HEAP_START, \ - OS_MEM_ALIGN(sz, DCACHE_LINE_SIZE), DCACHE_LINE_SIZE) -#define DDR_HEAP_FREE(p) LOS_HeapFree((VOID *)DDR_HEAP_START, p) -#endif - -/* extra 2 blocks is for idle and extra temparary task */ -#define TASK_BLOCK_NUM (LOSCFG_BASE_CORE_TSK_LIMIT + 2) - -#if (LOSCFG_KERNEL_MEM_STATISTICS == YES) -#define TASKID_BITS 7 -/* 2 bits for used and align flag, 30 bits left */ -#define SIZE_BITS (30 - TASKID_BITS) -#if (SIZE_BITS <= 0) -#error task id bits too big! -#endif -#if (TASK_BLOCK_NUM > ((1 << TASKID_BITS) - 1)) -#error task id bits too small! -#endif -#endif - -struct LOS_HEAP_NODE { - struct LOS_HEAP_NODE* pstPrev; -#if (LOSCFG_KERNEL_MEM_STATISTICS == YES) - UINT32 uwSize : SIZE_BITS; - UINT32 taskID : TASKID_BITS; -#else - UINT32 uwSize : 30; -#endif - UINT32 uwUsed : 1; - UINT32 uwAlign : 1; - UINT8 ucData[0]; /*lint !e43*/ -}; - -/** - * @ingroup los_heap - * @brief Initialization heap memory. - * - * @par Description: - * This API is used to initialization heap memory. - * @attention - *
    - *
  • None.
  • - *
- * - * @param pool [IN/OUT] A pointer pointed to the memory pool. - * @param size [IN] Size of heap memory. - * - * @retval TRUE Initialization success. - * @retval FALSE Initialization failed. - * @par Dependency: - *
  • los_heap.h: the header file that contains the API declaration.
- * @see None. - */ -extern BOOL LOS_HeapInit(VOID *pool, UINT32 size); - -/** - * @ingroup los_heap - * @brief Alloc memory block from heap memory. - * - * @par Description: - * This API is used to alloc memory block from heap memory. - * @attention - *
    - *
  • None.
  • - *
- * - * @param pool [IN/OUT] A pointer pointed to the memory pool. - * @param size [IN] Size of heap memory. - * - * @retval VOID* - * @par Dependency: - *
  • los_heap.h: the header file that contains the API declaration.
- * @see LOS_HeapFree - */ -extern VOID* LOS_HeapAlloc(VOID *pool, UINT32 size); - -/** - * @ingroup los_heap - * @brief Alloc aligned memory block from heap memory. - * - * @par Description: - * This API is used to alloc aligned memory block from heap memory. - * @attention - *
    - *
  • None.
  • - *
- * - * @param pool [IN/OUT] A pointer pointed to the memory pool. - * @param size [IN] Size of heap memory. - * @param boundary [IN] Boundary the heap needs align - * - * @retval VOID* - * @par Dependency: - *
  • los_heap.h: the header file that contains the API declaration.
- * @see LOS_HeapFree - */ -extern VOID* LOS_HeapAllocAlign(VOID *pool, UINT32 size, UINT32 boundary); - -/** - * @ingroup los_heap - * @brief Free memory block from heap memory. - * - * @par Description: - * This API is used to free memory block from heap memory. - * @attention - *
    - *
  • None.
  • - *
- * - * @param pool [IN/OUT] A pointer pointed to the memory pool. - * @param ptr [IN] Point to be freed. - * - * @retval BOOL TRUE free success FALSE free failed - * @par Dependency: - *
  • los_heap.h: the header file that contains the API declaration.
- * @see LOS_HeapAlloc - */ -extern BOOL LOS_HeapFree(VOID *pool, VOID* ptr); - -/** - * @ingroup los_memory - * @brief Get the memory info from Heap. - * - * @par Description: - * This API is used to get the memory info from Heap. - * @attention - *
    - *
  • None.
  • - *
- * @param None. - * - * @retval UINT32 Max size of heap memory being used. - * - * @par Dependency: - *
  • los_heap.h: the header file that contains the API declaration.
- * @see None. - */ -#if (LOSCFG_HEAP_MEMORY_PEAK_STATISTICS == YES) -extern UINT32 LOS_HeapGetHeapMemoryPeak(VOID); -#endif - -/** - * @ingroup los_memory - * @brief Get the memory statistics from Heap. - * - * @par Description: - * This API is used to get the memory statistics from Heap. - * @attention - *
    - *
  • None.
  • - *
- * @param None. - * - * @retval None. - * - * @par Dependency: - *
  • los_heap.h: the header file that contains the API declaration.
- * @see None. - */ -#if (LOSCFG_KERNEL_MEM_STATISTICS == YES) -VOID LOS_HeapDumpMemoryStats(VOID *pool); -#endif - -#ifdef __cplusplus -} -#endif - - -#endif - diff --git a/kernel/include/los_membox.h b/kernel/include/los_membox.h index b09cc281..07bb6777 100755 --- a/kernel/include/los_membox.h +++ b/kernel/include/los_membox.h @@ -32,9 +32,8 @@ #ifndef _LOS_MEMBOX_H #define _LOS_MEMBOX_H -#include "los_config.h" #if (LOSCFG_PLATFORM_EXC == YES) -#include "los_memcheck.h" +#include "los_memory.h" #endif #define BOX_ALIGN_8 0x80000000 @@ -198,4 +197,18 @@ extern VOID LOS_MemboxClr(const VOID *boxMem, VOID *box); */ extern UINT32 LOS_MemboxStatisticsGet(const VOID *boxMem, UINT32 *maxBlk, UINT32 *blkCnt, UINT32 *blkSize); +#define OS_MEMBOX_NEXT(addr, blkSize) (LOS_MEMBOX_NODE *)((UINT8 *)(addr) + (blkSize)) + +#ifdef LOS_MEMBOX_CHECK +#define OS_MEMBOX_MAGIC 0xa55a5aa5 +#define OS_MEMBOX_SET_MAGIC(addr) (*((UINT32 *)(addr)) = OS_MEMBOX_MAGIC) +#define OS_MEMBOX_CHECK_MAGIC(addr) ((*((UINT32 *)(addr)) == OS_MEMBOX_MAGIC) ? LOS_OK : LOS_NOK) +#else +#define OS_MEMBOX_SET_MAGIC(addr) +#define OS_MEMBOX_CHECK_MAGIC(addr) LOS_OK +#endif + +#define OS_MEMBOX_USER_ADDR(addr) ((VOID *)((UINT8 *)(addr) + LOS_MEMBOX_MAGIC_SIZE)) +#define OS_MEMBOX_NODE_ADDR(addr) ((LOS_MEMBOX_NODE *)((UINT8 *)(addr) - LOS_MEMBOX_MAGIC_SIZE)) + #endif diff --git a/kernel/include/los_memcheck.h b/kernel/include/los_memcheck.h deleted file mode 100755 index e3b51e7b..00000000 --- a/kernel/include/los_memcheck.h +++ /dev/null @@ -1,116 +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. - */ - -#ifndef _LOS_MEMCHECK_H -#define _LOS_MEMCHECK_H - -#include "los_base.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cpluscplus */ -#endif /* __cpluscplus */ - -#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; - -/** - * @ingroup los_memboxcheck - * @brief Get the information of the exc memory. - * - * @par Description: - *
    - *
  • This API is used to get the information of the exc memory.
  • - *
- * @attention - *
    - *
  • None.
  • - *
- * - * @param memNum [IN] Type #UINT32 Memory pool number. - * @param memExcInfo [IN/OUT] Type #MEM_INFO_S * information of the exc memory. - * - * @retval UINT32 Get information result. - * @par Dependency: - *
    - *
  • los_memboxcheck.h: the header file that contains the API declaration.
  • - *
- * @see None. - */ -UINT32 LOS_MemExcInfoGet(UINT32 memNum, MEM_INFO_S *memExcInfo); - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cpluscplus */ -#endif /* __cpluscplus */ - -#endif /* _LOS_MEMCHECK_H */ \ No newline at end of file diff --git a/kernel/include/los_memory.h b/kernel/include/los_memory.h index ae0d78a5..10f54ad8 100755 --- a/kernel/include/los_memory.h +++ b/kernel/include/los_memory.h @@ -31,11 +31,9 @@ #ifndef _LOS_MEMORY_H #define _LOS_MEMORY_H -#include "los_base.h" -#if (LOSCFG_KERNEL_MEM_SLAB == YES) -#include -#endif -#include + +#include "los_config.h" +#include "los_list.h" #ifdef __cplusplus #if __cplusplus @@ -43,15 +41,13 @@ extern "C" { #endif /* __cplusplus */ #endif /* __cplusplus */ -typedef struct __s_LOS_MEM_STATUS { - UINT32 totalSize; - UINT32 usedSize; - UINT32 freeSize; - UINT32 allocCount; - UINT32 freeCount; -} LOS_MEM_STATUS; - -#if (LOSCFG_MEMORY_BESTFIT == YES) +#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)) /** * @ingroup los_memory @@ -64,11 +60,93 @@ typedef struct { UINT32 uwPoolWaterLine; /**< Maximum usage size in a memory pool */ UINT32 uwPoolCurUsedSize; /**< Current usage size in a memory pool */ #endif -#ifdef LOSCFG_MEM_MUL_POOL +//#ifdef LOSCFG_MEM_MUL_POOL VOID *pNextPool; -#endif +//#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; + +/** + * @ingroup los_memboxcheck + * @brief Get the information of the exc memory. + * + * @par Description: + *
    + *
  • This API is used to get the information of the exc memory.
  • + *
+ * @attention + *
    + *
  • None.
  • + *
+ * + * @param memNum [IN] Type #UINT32 Memory pool number. + * @param memExcInfo [IN/OUT] Type #MEM_INFO_S * information of the exc memory. + * + * @retval UINT32 Get information result. + * @par Dependency: + *
    + *
  • los_memboxcheck.h: the header file that contains the API declaration.
  • + *
+ * @see None. + */ +UINT32 LOS_MemExcInfoGet(UINT32 memNum, MEM_INFO_S *memExcInfo); + +//#if (LOSCFG_MEMORY_BESTFIT == YES) + + #if (LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK == YES) extern UINT8 g_memMang[]; #endif @@ -82,6 +160,7 @@ extern UINT8 g_memMang[]; #ifdef LOSCFG_MEM_MUL_POOL extern VOID *g_memPoolHead; #endif + typedef VOID (*MALLOC_HOOK)(VOID); extern MALLOC_HOOK g_mallocHook; @@ -364,7 +443,6 @@ extern UINT8 LOS_MemCheckLevelGet(VOID); *
  • los_memory.h: the header file that contains the API declaration.
*/ extern UINT32 LOS_MemInfoGet(VOID *pool, LOS_MEM_STATUS *status); -#else /** * @ingroup los_memory @@ -412,7 +490,7 @@ extern UINT32 LOS_MemStatisticsGet(VOID *pool, LOS_MEM_STATUS *status); * @see LOS_MemAlloc | LOS_MemRealloc | LOS_MemFree */ extern UINT32 LOS_MemGetMaxFreeBlkSize(VOID *pool); -#endif +//#endif /** * @ingroup los_memory @@ -601,6 +679,225 @@ extern UINT32 LOS_MemDeInit(const VOID *pool); 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 + *
    + *
  • None.
  • + *
+ * + * @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 + *
    + *
  • None.
  • + *
+ * + * @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 index bd644938..0a8ad6aa 100755 --- a/kernel/include/los_mux.h +++ b/kernel/include/los_mux.h @@ -37,11 +37,9 @@ #ifndef _LOS_MUX_H #define _LOS_MUX_H -#include "los_base.h" -#include "los_sys.h" -#include "los_list.h" #include "los_task.h" + #ifdef __cplusplus #if __cplusplus extern "C" { @@ -284,6 +282,65 @@ extern UINT32 LOS_MuxPend(UINT32 muxHandle, UINT32 timeout); */ extern UINT32 LOS_MuxPost(UINT32 muxHandle); +/** + * @ingroup los_mux + * Mutex object. + */ +typedef struct { + UINT8 muxStat; /**< State OS_MUX_UNUSED,OS_MUX_USED */ + UINT16 muxCount; /**< Times of locking a mutex */ + UINT32 muxID; /**< Handle ID */ + LOS_DL_LIST muxList; /**< Mutex linked list */ + LosTaskCB *owner; /**< The current thread that is locking a mutex */ + UINT16 priority; /**< Priority of the thread that is locking a mutex */ +} LosMuxCB; + +/** + * @ingroup los_mux + * Mutex state: not in use. + */ +#define OS_MUX_UNUSED 0 + +/** + * @ingroup los_mux + * Mutex state: in use. + */ +#define OS_MUX_USED 1 + +extern LosMuxCB *g_allMux; + +/** + * @ingroup los_mux + * Obtain the pointer to a mutex object of the mutex that has a specified handle. + */ +#define GET_MUX(muxid) (((LosMuxCB *)g_allMux) + (muxid)) + +/** + * @ingroup los_mux + * @brief Initializes the mutex. + * + * @par Description: + * This API is used to initializes the mutex. + * @attention + *
    + *
  • None.
  • + *
+ * + * @param None. + * + * @retval UINT32 Initialization result. + * @par Dependency: + *
  • los_mux_pri.h: the header file that contains the API declaration.
+ * @see LOS_MuxDelete + */ +extern UINT32 OsMuxInit(VOID); + +/** + * @ingroup los_mux + * Obtain the pointer to the linked list in the mutex pointed to by a specified pointer. + */ +#define GET_MUX_LIST(ptr) LOS_DL_LIST_ENTRY(ptr, LosMuxCB, muxList) + #ifdef __cplusplus #if __cplusplus } diff --git a/kernel/include/los_printf.h b/kernel/include/los_printf.h deleted file mode 100755 index 51235db2..00000000 --- a/kernel/include/los_printf.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: 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. - * --------------------------------------------------------------------------- - * 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_printf Printf - * @ingroup kernel - */ - -#ifndef _LOS_PRINTF_H -#define _LOS_PRINTF_H - -#include "stdarg.h" -#include "los_typedef.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - - -#define LOS_EMG_LEVEL 0 - -#define LOS_COMMOM_LEVEL (LOS_EMG_LEVEL + 1) - -#define LOS_ERR_LEVEL (LOS_COMMOM_LEVEL + 1) - -#define LOS_WARN_LEVEL (LOS_ERR_LEVEL + 1) - -#define LOS_INFO_LEVEL (LOS_WARN_LEVEL + 1) - -#define LOS_DEBUG_LEVEL (LOS_INFO_LEVEL + 1) - -#ifndef PRINT_LEVEL -#define PRINT_LEVEL LOS_ERR_LEVEL -#endif - -/** - *@ingroup los_printf - *@brief Format and print data. - * - * @par Description: - * Print argument(s) according to fmt. - * - * @attention - *
    - *
  • None
  • - *
- * - *@param fmt [IN] Type char* controls the ouput as in C printf. - * - *@retval None - *@par Dependency: - *
  • los_printf.h: the header file that contains the API declaration.
- *@see printf - *@since Huawei LiteOS V100R001C00 - */ -extern int printf(char const *str, ...); -#define PRINT printf - - -#if PRINT_LEVEL < LOS_DEBUG_LEVEL -#define PRINT_DEBUG(fmt, args...) -#else -#define PRINT_DEBUG(fmt, args...) do{(PRINT("[DEBUG] "), PRINT(fmt, ##args));}while(0) -#endif - -#if PRINT_LEVEL < LOS_INFO_LEVEL -#define PRINT_INFO(fmt, args...) -#else -#define PRINT_INFO(fmt, args...) do{(PRINT("[INFO] "), PRINT(fmt, ##args));}while(0) -#endif - -#if PRINT_LEVEL < LOS_WARN_LEVEL -#define PRINT_WARN(fmt, args...) -#else -#define PRINT_WARN(fmt, args...) do{(PRINT("[WARN] "), PRINT(fmt, ##args));}while(0) -#endif - -#if PRINT_LEVEL < LOS_ERR_LEVEL -#define PRINT_ERR(fmt, args...) -#else -#define PRINT_ERR(fmt, args...) do{(PRINT("[ERR] "), PRINT(fmt, ##args));}while(0) -#endif - -#if PRINT_LEVEL < LOS_COMMOM_LEVEL -#define PRINTK(fmt, args...) -#else -#define PRINTK(fmt, args...) PRINT(fmt, ##args) -#endif - -#if PRINT_LEVEL < LOS_EMG_LEVEL -#define PRINT_EMG(fmt, args...) -#else -#define PRINT_EMG(fmt, args...) do{(PRINT("[EMG] "), PRINT(fmt, ##args));}while(0) -#endif - -#define PRINT_RELEASE(fmt, args...) PRINT(fmt, ##args) - - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_PRINTF_H */ diff --git a/kernel/include/los_queue.h b/kernel/include/los_queue.h index f6c47348..fb6cff77 100755 --- a/kernel/include/los_queue.h +++ b/kernel/include/los_queue.h @@ -37,7 +37,6 @@ #ifndef _LOS_QUEUE_H #define _LOS_QUEUE_H -#include "los_base.h" #include "los_list.h" #ifdef __cplusplus @@ -719,6 +718,191 @@ extern UINT32 LOS_QueueDelete(UINT32 queueID); */ extern UINT32 LOS_QueueInfoGet(UINT32 queueID, QUEUE_INFO_S *queueInfo); +typedef enum { + OS_QUEUE_READ, + OS_QUEUE_WRITE +} QueueReadWrite; + +typedef enum { + OS_QUEUE_HEAD, + OS_QUEUE_TAIL +} QueueHeadTail; + +typedef enum { + OS_QUEUE_NOT_POINT, + OS_QUEUE_POINT +} QueuePointOrNot; + +#define OS_QUEUE_OPERATE_TYPE(ReadOrWrite, HeadOrTail, PointOrNot) \ + (((UINT32)(PointOrNot) << 2) | ((UINT32)(HeadOrTail) << 1) | (ReadOrWrite)) +#define OS_QUEUE_READ_WRITE_GET(type) ((type) & (0x01)) +#define OS_QUEUE_READ_HEAD (OS_QUEUE_READ | (OS_QUEUE_HEAD << 1)) +#define OS_QUEUE_READ_TAIL (OS_QUEUE_READ | (OS_QUEUE_TAIL << 1)) +#define OS_QUEUE_WRITE_HEAD (OS_QUEUE_WRITE | (OS_QUEUE_HEAD << 1)) +#define OS_QUEUE_WRITE_TAIL (OS_QUEUE_WRITE | (OS_QUEUE_TAIL << 1)) +#define OS_QUEUE_OPERATE_GET(type) ((type) & (0x03)) +#define OS_QUEUE_IS_POINT(type) ((type) & (0x04)) +#define OS_QUEUE_IS_READ(type) (OS_QUEUE_READ_WRITE_GET(type) == OS_QUEUE_READ) +#define OS_QUEUE_IS_WRITE(type) (OS_QUEUE_READ_WRITE_GET(type) == OS_QUEUE_WRITE) +#define OS_READWRITE_LEN 2 + +/** + * @ingroup los_queue + * Queue information block structure + */ +typedef struct { + UINT8 *queue; /**< Pointer to a queue handle */ + UINT16 queueState; /**< Queue state */ + UINT16 queueLen; /**< Queue length */ + UINT16 queueSize; /**< Node size */ + UINT16 queueID; /**< queueID */ + UINT16 queueHead; /**< Node head */ + UINT16 queueTail; /**< Node tail */ + UINT16 readWriteableCnt[OS_READWRITE_LEN]; /**< Count of readable or writable resources, 0:readable, 1:writable */ + LOS_DL_LIST readWriteList[OS_READWRITE_LEN]; /**< Pointer to the linked list to be read or written, + 0:readlist, 1:writelist */ + LOS_DL_LIST memList; /**< Pointer to the memory linked list */ +} LosQueueCB; + +/* queue state */ +/** + * @ingroup los_queue + * Message queue state: not in use. + */ +#define OS_QUEUE_UNUSED 0 + +/** + * @ingroup los_queue + * Message queue state: used. + */ +#define OS_QUEUE_INUSED 1 + +/** + * @ingroup los_queue + * Not in use. + */ +#define OS_QUEUE_WAIT_FOR_POOL 1 + +/** + * @ingroup los_queue + * Normal message queue. + */ +#define OS_QUEUE_NORMAL 0 + +/** + * @ingroup los_queue + * Queue information control block + */ +extern LosQueueCB *g_allQueue; + +/** + * @ingroup los_queue + * Obtain a handle of the queue that has a specified ID. + */ +#define GET_QUEUE_HANDLE(QueueID) (((LosQueueCB *)g_allQueue) + (QueueID)) + +/** + * @ingroup los_queue + * Obtain the head node in a queue doubly linked list. + */ +#define GET_QUEUE_LIST(ptr) LOS_DL_LIST_ENTRY(ptr, LosQueueCB, readWriteList[OS_QUEUE_WRITE]) + +/** + * @ingroup los_queue + * @brief Alloc a stationary memory for a mail. + * + * @par Description: + * This API is used to alloc a stationary memory for a mail according to queueID. + * @attention + *
    + *
  • Do not alloc memory in unblocking modes such as interrupt.
  • + *
  • This API cannot be called before the Huawei LiteOS is initialized.
  • + *
  • The argument timeOut is a relative time.
  • + *
+ * + * @param queueID [IN] Queue ID. The value range is [1,LOSCFG_BASE_IPC_QUEUE_LIMIT]. + * @param mailPool [IN] The memory poll that stores the mail. + * @param timeOut [IN] Expiry time. The value range is [0,LOS_WAIT_FOREVER]. + * + * @retval #NULL The memory allocation is failed. + * @retval #mem The address of alloc memory. + * @par Dependency: + *
  • los_queue_pri.h: the header file that contains the API declaration.
+ * @see OsQueueMailFree + */ +extern VOID *OsQueueMailAlloc(UINT32 queueID, VOID *mailPool, UINT32 timeOut); + +/** + * @ingroup los_queue + * @brief Free a stationary memory of a mail. + * + * @par Description: + * This API is used to free a stationary memory for a mail according to queueID. + * @attention + *
    + *
  • This API cannot be called before the Huawei LiteOS is initialized.
  • + *
+ * + * @param queueID [IN] Queue ID. The value range is [1,LOSCFG_BASE_IPC_QUEUE_LIMIT]. + * @param mailPool [IN] The mail memory poll address. + * @param mailMem [IN] The mail memory block address. + * + * @retval #LOS_OK 0x00000000: The memory free successfully. + * @retval #OS_ERRNO_QUEUE_MAIL_HANDLE_INVALID 0x02000619: The handle of the queue passed-in when the memory for + the queue is being freed is invalid. + * @retval #OS_ERRNO_QUEUE_MAIL_PTR_INVALID 0x0200061a: The pointer to the memory to be freed is null. + * @retval #OS_ERRNO_QUEUE_MAIL_FREE_ERROR 0x0200061b: The memory for the queue fails to be freed. + * @par Dependency: + *
  • los_queue_pri.h: the header file that contains the API declaration.
+ * @see OsQueueMailAlloc + */ +extern UINT32 OsQueueMailFree(UINT32 queueID, VOID *mailPool, VOID *mailMem); + +/** + * @ingroup los_queue + * @brief Initialization queue. + * + * @par Description: + * This API is used to initialization queue. + * @attention + *
    + *
  • None.
  • + *
+ * + * @param None. + * + * @retval UINT32 Initialization result. + * @par Dependency: + *
  • los_queue_pri.h: the header file that contains the API declaration.
+ * @see None. + */ +extern UINT32 OsQueueInit(VOID); + +/** + * @ingroup los_queue + * @brief Handle when read or write queue. + * + * @par Description: + * This API is used to handle when read or write queue. + * @attention + *
    + *
  • None.
  • + *
+ * + * @param queueID [IN] Queue id. + * @param operateType [IN] Operate type + * @param bufferAddr [IN] Buffer address. + * @param bufferSize [IN] Buffer size. + * @param timeOut [IN] Timeout. + * + * @retval UINT32 Handle result. + * @par Dependency: + *
  • los_queue_pri.h: the header file that contains the API declaration.
+ * @see None. + */ +extern UINT32 OsQueueOperate(UINT32 queueID, UINT32 operateType, VOID *bufferAddr, UINT32 *bufferSize, + UINT32 timeOut); + #ifdef __cplusplus #if __cplusplus } diff --git a/kernel/include/los_sem.h b/kernel/include/los_sem.h index 57f912fa..3da51967 100755 --- a/kernel/include/los_sem.h +++ b/kernel/include/los_sem.h @@ -37,9 +37,6 @@ #ifndef _LOS_SEM_H #define _LOS_SEM_H -#include "los_base.h" -#include "los_err.h" -#include "los_list.h" #include "los_task.h" #ifdef __cplusplus @@ -288,6 +285,91 @@ extern UINT32 LOS_SemPend(UINT32 semHandle, UINT32 timeout); */ extern UINT32 LOS_SemPost(UINT32 semHandle); +enum LosSemMaxCount { + OS_SEM_COUNTING_MAX_COUNT = 0xFFFF, /**< Max count of counting semaphores */ + OS_SEM_BINARY_MAX_COUNT = 1 /**< Max count of binary semaphores */ +}; + +/** + * @ingroup los_sem + * Semaphore control structure. + */ +typedef struct { + UINT16 semStat; /**< Semaphore state */ + UINT16 semCount; /**< Number of available semaphores */ + UINT16 maxSemCount; /**< Max number of available semaphores */ + UINT16 semID; /**< Semaphore control structure ID */ + LOS_DL_LIST semList; /**< Queue of tasks that are waiting on a semaphore */ +} LosSemCB; + +/** + * @ingroup los_sem + * The semaphore is not in use. + * + */ +#define OS_SEM_UNUSED 0 +/** + * @ingroup los_sem + * The semaphore is used. + * + */ +#define OS_SEM_USED 1 +/** + * @ingroup los_sem + * Obtain the head node in a semaphore doubly linked list. + * + */ +#define GET_SEM_LIST(ptr) LOS_DL_LIST_ENTRY(ptr, LosSemCB, semList) +extern LosSemCB *g_allSem; +/** + * @ingroup los_sem + * Obtain a semaphore ID. + * + */ +#define GET_SEM(semid) (((LosSemCB *)g_allSem) + (semid)) + +/** + * @ingroup los_sem + * @brief Initialize the Semaphore doubly linked list. + * + * @par Description: + * This API is used to initialize the Semaphore doubly linked list. + * @attention + *
    + *
  • None.
  • + *
+ * + * @param None. + * + * @retval UINT32 Initialization result. + * @par Dependency: + *
  • los_sem_pri.h: the header file that contains the API declaration.
+ * @see None. + */ +extern UINT32 OsSemInit(VOID); + +/** + * @ingroup los_sem + * @brief Create Semaphore. + * + * @par Description: + * This API is used to create Semaphore. + * @attention + *
    + *
  • None.
  • + *
+ * + * @param count [IN]Type #UINT16 Semaphore count. + * @param maxCount [IN]Type #UINT16 Max semaphore count. + * @param semHandle [OUT]Type #UINT32 * Index of semaphore. + * + * @retval UINT32 Create result. + * @par Dependency: + *
  • los_sem_pri.h: the header file that contains the API declaration.
+ * @see None. + */ +UINT32 OsSemCreate(UINT16 count, UINT16 maxCount, UINT32 *semHandle); + #ifdef __cplusplus #if __cplusplus } diff --git a/kernel/include/los_slab.h b/kernel/include/los_slab.h deleted file mode 100755 index 4bdedbc8..00000000 --- a/kernel/include/los_slab.h +++ /dev/null @@ -1,66 +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. - */ - -/** - * @defgroup los_slab Slab - * @ingroup kernel - */ - -#ifndef _LOS_SLAB_H -#define _LOS_SLAB_H - -#include - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -// number of slab class -#define SLAB_MEM_COUNT 4 - -// step size of each class -#define SLAB_MEM_CALSS_STEP_SIZE 0x10 - -// max size of each class -#define SLAB_MEM_ALLOCATOR_SIZE 512 - -#define SLAB_BASIC_NEED_SIZE 0x1000 - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif - diff --git a/kernel/include/los_swtmr.h b/kernel/include/los_swtmr.h index bcf5ccbb..0a029643 100755 --- a/kernel/include/los_swtmr.h +++ b/kernel/include/los_swtmr.h @@ -37,8 +37,6 @@ #ifndef _LOS_SWTMR_H #define _LOS_SWTMR_H -#include "los_base.h" -#include "los_task.h" #ifdef __cplusplus #if __cplusplus @@ -433,6 +431,119 @@ extern UINT32 LOS_SwtmrCreate(UINT32 interval, */ extern UINT32 LOS_SwtmrDelete(UINT16 swtmrID); +/** + * @ingroup los_swtmr + * Software timer state + */ +enum SwtmrState { + OS_SWTMR_STATUS_UNUSED, /**< The software timer is not used. */ + OS_SWTMR_STATUS_CREATED, /**< The software timer is created. */ + OS_SWTMR_STATUS_TICKING /**< The software timer is timing. */ +}; + +/** + * @ingroup los_swtmr + * Structure of the callback function that handles software timer timeout + */ +typedef struct { + SWTMR_PROC_FUNC handler; /**< Callback function that handles software timer timeout */ + UINT32 arg; /**< Parameter passed in when the callback function + that handles software timer timeout is called */ +} SwtmrHandlerItem; + +extern SWTMR_CTRL_S *g_swtmrCBArray; + +#define OS_SWT_FROM_SID(swtmrId) ((SWTMR_CTRL_S *)g_swtmrCBArray + ((swtmrId) % LOSCFG_BASE_CORE_SWTMR_LIMIT)) + +/** + * @ingroup los_swtmr + * @brief Scan a software timer. + * + * @par Description: + *
    + *
  • This API is used to scan a software timer when a Tick interrupt occurs and determine whether the software timer + expires.
  • + *
+ * @attention + *
    + *
  • None.
  • + *
+ * + * @param None. + * + * @retval None. + * @par Dependency: + *
  • los_swtmr_pri.h: the header file that contains the API declaration.
+ * @see LOS_SwtmrStop + */ +extern UINT32 OsSwtmrScan(VOID); + +/** + * @ingroup los_swtmr + * @brief Initialization software timer. + * + * @par Description: + *
    + *
  • This API is used to initialization software.
  • + *
+ * @attention + *
    + *
  • None.
  • + *
+ * + * @param None. + * + * @retval None. + * @par Dependency: + *
  • los_swtmr_pri.h: the header file that contains the API declaration.
+ * @see None. + */ +extern UINT32 OsSwtmrInit(VOID); + +/** + * @ingroup los_swtmr + * @brief Get next timeout. + * + * @par Description: + *
    + *
  • This API is used to get next timeout.
  • + *
+ * @attention + *
    + *
  • None.
  • + *
+ * + * @param None. + * + * @retval None. + * @par Dependency: + *
  • los_swtmr_pri.h: the header file that contains the API declaration.
+ * @see None. + */ +extern UINT32 OsSwtmrGetNextTimeout(VOID); + +/** + * @ingroup los_swtmr + * @brief Adjust software timer list. + * + * @par Description: + *
    + *
  • This API is used to adjust software timer list.
  • + *
+ * @attention + *
    + *
  • None.
  • + *
+ * + * @param sleepTime [IN] UINT32 Sleep time. + * + * @retval UINT32 Sleep time. + * @par Dependency: + *
  • los_swtmr_pri.h: the header file that contains the API declaration.
+ * @see None. + */ +extern VOID OsSwtmrAdjust(UINT32 sleepTime); + #ifdef __cplusplus #if __cplusplus } diff --git a/kernel/include/los_sys.h b/kernel/include/los_sys.h deleted file mode 100755 index 5ede80f1..00000000 --- a/kernel/include/los_sys.h +++ /dev/null @@ -1,212 +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. - */ - -/** - * @defgroup los_sys System time - * @ingroup kernel - */ - -#ifndef _LOS_SYS_H -#define _LOS_SYS_H - -#include "los_hwi.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -/** - * @ingroup los_sys - * Number of milliseconds in one second. - */ -#define OS_SYS_MS_PER_SECOND 1000 - -/** - * @ingroup los_sys - * Number of microseconds in one second. - */ -#define OS_SYS_US_PER_SECOND 1000000 - -/** - * @ingroup los_sys - * System time basic function error code: Null pointer. - * - * Value: 0x02000010 - * - * Solution: Check whether the input parameter is null. - */ -#define LOS_ERRNO_SYS_PTR_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_SYS, 0x10) - -/** - * @ingroup los_sys - * System time basic function error code: Invalid system clock configuration. - * - * Value: 0x02000011 - * - * Solution: Configure a valid system clock in los_config.h. - */ -#define LOS_ERRNO_SYS_CLOCK_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_SYS, 0x11) - -/** - * @ingroup los_sys - * System time basic function error code: This error code is not in use temporarily. - * - * Value: 0x02000012 - * - * Solution: None. - */ -#define LOS_ERRNO_SYS_MAXNUMOFCORES_IS_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_SYS, 0x12) - -/** - * @ingroup los_sys - * System time error code: This error code is not in use temporarily. - * - * Value: 0x02000013 - * - * Solution: None. - */ -#define LOS_ERRNO_SYS_PERIERRCOREID_IS_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_SYS, 0x13) - -/** - * @ingroup los_sys - * System time error code: This error code is not in use temporarily. - * - * Value: 0x02000014 - * - * Solution: None. - */ -#define LOS_ERRNO_SYS_HOOK_IS_FULL LOS_ERRNO_OS_ERROR(LOS_MOD_SYS, 0x14) - -/** - * @ingroup los_typedef - * system time structure. - */ -typedef struct tagSysTime { - UINT16 uwYear; /**< value 1970 ~ 2038 or 1970 ~ 2100 */ - UINT8 ucMonth; /**< value 1 - 12 */ - UINT8 ucDay; /**< value 1 - 31 */ - UINT8 ucHour; /**< value 0 - 23 */ - UINT8 ucMinute; /**< value 0 - 59 */ - UINT8 ucSecond; /**< value 0 - 59 */ - UINT8 ucWeek; /**< value 0 - 6 */ -} SYS_TIME_S; - -/** - * @ingroup los_sys - * @brief Obtain the number of Ticks. - * - * @par Description: - * This API is used to obtain the number of Ticks. - * @attention - *
    - *
  • None
  • - *
- * - * @param None - * - * @retval UINT64 The number of Ticks. - * @par Dependency: - *
  • los_sys.h: the header file that contains the API declaration.
- * @see None - */ -extern UINT64 LOS_TickCountGet(VOID); - -/** - * @ingroup los_sys - * @brief Obtain the number of cycles in one second. - * - * @par Description: - * This API is used to obtain the number of cycles in one second. - * @attention - *
    - *
  • None
  • - *
- * - * @param None - * - * @retval UINT32 Number of cycles obtained in one second. - * @par Dependency: - *
  • los_sys.h: the header file that contains the API declaration.
- * @see None - */ -extern UINT32 LOS_CyclePerTickGet(VOID); - -/** - * @ingroup los_sys - * @brief Convert Ticks to milliseconds. - * - * @par Description: - * This API is used to convert Ticks to milliseconds. - * @attention - *
    - *
  • The number of milliseconds obtained through the conversion is 32-bit.
  • - *
- * - * @param ticks [IN] Number of Ticks. The value range is (0,OS_SYS_CLOCK). - * - * @retval UINT32 Number of milliseconds obtained through the conversion. Ticks are successfully converted to - * milliseconds. - * @par Dependency: - *
  • los_sys.h: the header file that contains the API declaration.
- * @see LOS_MS2Tick - */ -extern UINT32 LOS_Tick2MS(UINT32 ticks); - -/** - * @ingroup los_sys - * @brief Convert milliseconds to Ticks. - * - * @par Description: - * This API is used to convert milliseconds to Ticks. - * @attention - *
    - *
  • If the parameter passed in is equal to 0xFFFFFFFF, the retval is 0xFFFFFFFF. Pay attention to the value to be - * converted because data possibly overflows.
  • - *
- * - * @param millisec [IN] Number of milliseconds. - * - * @retval UINT32 Number of Ticks obtained through the conversion. - * @par Dependency: - *
  • los_sys.h: the header file that contains the API declaration.
- * @see LOS_Tick2MS - */ -extern UINT32 LOS_MS2Tick(UINT32 millisec); - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_SYS_H */ diff --git a/kernel/include/los_tables.h b/kernel/include/los_tables.h deleted file mode 100755 index 0d90ab0e..00000000 --- a/kernel/include/los_tables.h +++ /dev/null @@ -1,128 +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. - */ - -#ifndef _LOS_TABLES_H -#define _LOS_TABLES_H - -#include "los_typedef.h" - -#define TO_STRING(x) #x -#define X_TO_STRING(x) TO_STRING(x) - -#ifndef LOS_HAL_TABLE_WOW_BEGIN -#define LOS_HAL_TABLE_WOW_BEGIN(label, name) \ - __asm__(".section \".liteos.table." X_TO_STRING(name) ".wow.begin\",\"aw\"\n" \ - ".globl " X_TO_STRING(LOS_LABEL_DEFN(label)) "\n" \ - ".type " X_TO_STRING(LOS_LABEL_DEFN(label)) ",object\n" \ - ".p2align " X_TO_STRING(LOSARC_P2ALIGNMENT) "\n" X_TO_STRING(LOS_LABEL_DEFN(label)) ":\n" \ - ".previous\n") -#endif - -#ifndef LOS_HAL_TABLE_WOW_END -#define LOS_HAL_TABLE_WOW_END(label, name) \ - __asm__(".section \".liteos.table." X_TO_STRING(name) ".wow.finish\",\"aw\"\n" \ - ".globl " X_TO_STRING(LOS_LABEL_DEFN(label)) "\n" \ - ".type " X_TO_STRING(LOS_LABEL_DEFN(label)) ",object\n" \ - ".p2align " X_TO_STRING(LOSARC_P2ALIGNMENT) "\n" X_TO_STRING(LOS_LABEL_DEFN(label)) ":\n" \ - ".previous\n") -#endif - -#ifndef LOS_HAL_TABLE_SCATTER_BEGIN -#define LOS_HAL_TABLE_SCATTER_BEGIN(label, name) \ - __asm__(".section \".liteos.table." X_TO_STRING(name) ".scatter.begin\",\"aw\"\n" \ - ".globl " X_TO_STRING(LOS_LABEL_DEFN(label)) "\n" \ - ".type " X_TO_STRING(LOS_LABEL_DEFN(label)) ",object\n" \ - ".p2align " X_TO_STRING(LOSARC_P2ALIGNMENT) "\n" X_TO_STRING(LOS_LABEL_DEFN(label)) ":\n" \ - ".previous\n") -#endif - -#ifndef LOS_HAL_TABLE_SCATTER_END -#define LOS_HAL_TABLE_SCATTER_END(label, name) \ - __asm__(".section \".liteos.table." X_TO_STRING(name) ".scatter.finish\",\"aw\"\n" \ - ".globl " X_TO_STRING(LOS_LABEL_DEFN(label)) "\n" \ - ".type " X_TO_STRING(LOS_LABEL_DEFN(label)) ",object\n" \ - ".p2align " X_TO_STRING(LOSARC_P2ALIGNMENT) "\n" X_TO_STRING(LOS_LABEL_DEFN(label)) ":\n" \ - ".previous\n") -#endif - -#ifndef LOS_HAL_TABLE_BEGIN -#define LOS_HAL_TABLE_BEGIN(label, name) \ - __asm__(".section \".liteos.table." X_TO_STRING(name) ".begin\",\"aw\"\n" \ - ".globl " X_TO_STRING(LOS_LABEL_DEFN(label)) "\n" \ - ".type " X_TO_STRING(LOS_LABEL_DEFN(label)) ",object\n" \ - ".p2align " X_TO_STRING(LOSARC_P2ALIGNMENT) "\n" X_TO_STRING(LOS_LABEL_DEFN(label)) ":\n" \ - ".previous\n") -#endif - -#ifndef LOS_HAL_TABLE_END -#define LOS_HAL_TABLE_END(label, name) \ - __asm__(".section \".liteos.table." X_TO_STRING(name) ".finish\",\"aw\"\n" \ - ".globl " X_TO_STRING(LOS_LABEL_DEFN(label)) "\n" \ - ".type " X_TO_STRING(LOS_LABEL_DEFN(label)) ",object\n" \ - ".p2align " X_TO_STRING(LOSARC_P2ALIGNMENT) "\n" X_TO_STRING(LOS_LABEL_DEFN(label)) ":\n" \ - ".previous\n") -#endif - -// This macro must be applied to any types whose objects are to be placed in tables -#ifndef LOS_HAL_TABLE_TYPE -#define LOS_HAL_TABLE_TYPE LOSBLD_ATTRIB_ALIGN(LOSARC_ALIGNMENT) -#endif - -#ifndef LOS_HAL_TABLE_EXTRA -#define LOS_HAL_TABLE_EXTRA(name) \ - LOSBLD_ATTRIB_SECTION(".liteos.table." X_TO_STRING(name) ".extra") -#endif - -#ifndef LOS_HAL_TABLE_WOW_ENTRY -#define LOS_HAL_TABLE_WOW_ENTRY(name) \ - LOSBLD_ATTRIB_SECTION(".liteos.table." X_TO_STRING(name) ".wow.data") \ - LOSBLD_ATTRIB_USED -#endif - -#ifndef LOS_HAL_TABLE_SCATTER_ENTRY -#define LOS_HAL_TABLE_SCATTER_ENTRY(name) \ - LOSBLD_ATTRIB_SECTION(".liteos.table." X_TO_STRING(name) ".scatter.data") \ - LOSBLD_ATTRIB_USED -#endif - -#ifndef LOS_HAL_TABLE_ENTRY -#define LOS_HAL_TABLE_ENTRY(name) \ - LOSBLD_ATTRIB_SECTION(".liteos.table." X_TO_STRING(name) ".data") \ - LOSBLD_ATTRIB_USED -#endif - -#ifndef LOS_HAL_TABLE_QUALIFIED_ENTRY -#define LOS_HAL_TABLE_QUALIFIED_ENTRY(name, qual) \ - LOSBLD_ATTRIB_SECTION(".liteos.table." X_TO_STRING(name) ".data." X_TO_STRING(qual)) \ - LOSBLD_ATTRIB_USED -#endif - -#endif /* _LOS_TABLES_H */ diff --git a/kernel/include/los_task.h b/kernel/include/los_task.h index a9e3e82e..52fe294d 100755 --- a/kernel/include/los_task.h +++ b/kernel/include/los_task.h @@ -37,13 +37,9 @@ #ifndef _LOS_TASK_H #define _LOS_TASK_H -#include "los_base.h" -#include "los_list.h" -#include "los_sys.h" -#include "los_hw.h" #include "los_tick.h" +#include "los_context.h" #include "los_event.h" -#include "los_err.h" #ifdef __cplusplus #if __cplusplus @@ -439,6 +435,94 @@ typedef struct tagTskInfo { BOOL bOvf; /**< Flag that indicates whether a task stack overflow occurs */ } TSK_INFO_S; + + +/** + * @ingroup los_base + * Define the timeout interval as LOS_NO_WAIT. + */ +#define LOS_NO_WAIT 0 + +/** + * @ingroup los_base + * Define the timeout interval as LOS_WAIT_FOREVER. + */ +#define LOS_WAIT_FOREVER 0xFFFFFFFF + + + +/** + * @ingroup los_base + * @brief Sleep the current task. + * + * @par Description: + * This API is used to delay the execution of the current task. The task is able to be scheduled + * after it is delayed for a specified number of Ticks. + * + * @attention + *
    + *
  • The task fails to be delayed if it is being delayed during interrupt processing or it is locked.
  • + *
  • If 0 is passed in and the task scheduling is not locked, + * execute the next task in the queue of tasks with the priority of the current task. + * If no ready task with the priority of the current task is available, + * the task scheduling will not occur, and the current task continues to be executed.
  • + *
  • The parameter passed in can not be equal to LOS_WAIT_FOREVER(0xFFFFFFFF). + * If that happens, the task will not sleep 0xFFFFFFFF milliseconds or sleep forever but sleep 0xFFFFFFFF Ticks.
  • + *
+ * + * @param mSecs [IN] Type #UINT32 Number of MS for which the task is delayed. + * + * @retval None + * @par Dependency: + *
  • los_base.h: the header file that contains the API declaration.
+ * @see None + */ +extern VOID LOS_Msleep(UINT32 mSecs); + +/** + * @ingroup los_base + * @brief System kernel initialization function. + * + * @par Description: + * This API is used to start liteOS . + * + * @attention + *
    + *
  • None.
  • + *
+ * + * @param: None. + * + * @retval #LOS_OK 0:LiteOS start success. + * + * @par Dependency: + *
  • los_config.h: the header file that contains the API declaration.
+ * @see + */ +extern UINT32 LOS_Start(VOID); + +/** + * @ingroup los_base + * @brief System kernel initialization function. + * + * @par Description: + * This API is used to Initialize kernel ,configure all system modules. + * + * @attention + *
    + *
  • None.
  • + *
+ * + * @param: None. + * + * @retval #LOS_OK 0:System kernel initialization success. + * + * @par Dependency: + *
  • los_config.h: the header file that contains the API declaration.
+ * @see + */ +extern UINT32 LOS_KernelInit(VOID); + /** * @ingroup los_task * @brief Create a task and suspend. @@ -1036,6 +1120,920 @@ extern VOID OsSchedule(VOID); extern VOID LOS_Schedule(VOID); extern UINT32 OsTaskNextSwitchTimeGet(VOID); + + + +/** +* @ingroup los_cpup +* CPU usage error code: The request for memory fails. +* +* Value: 0x02001e00 +* +* Solution: Decrease the maximum number of tasks. +*/ +#define LOS_ERRNO_CPUP_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_CPUP, 0x00) + +/** +* @ingroup los_cpup +* CPU usage error code: The pointer to an input parameter is NULL. +* +* Value: 0x02001e01 +* +* Solution: Check whether the pointer to the input parameter is usable. +*/ +#define LOS_ERRNO_CPUP_TASK_PTR_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_CPUP, 0x01) + +/** +* @ingroup los_cpup +* CPU usage error code: The CPU usage is not initialized. +* +* Value: 0x02001e02 +* +* Solution: Check whether the CPU usage is initialized. +*/ +#define LOS_ERRNO_CPUP_NO_INIT LOS_ERRNO_OS_ERROR(LOS_MOD_CPUP, 0x02) + +/** +* @ingroup los_cpup +* CPU usage error code: The number of threads is invalid. +* +* Value: 0x02001e03 +* +* Solution: Check whether the number of threads is applicable for the current operation. +*/ +#define LOS_ERRNO_CPUP_MAXNUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_CPUP, 0x03) + +/** +* @ingroup los_cpup +* CPU usage error code: The target thread is not created. +* +* Value: 0x02001e04 +* +* Solution: Check whether the target thread is created. +*/ +#define LOS_ERRNO_CPUP_THREAD_NO_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_CPUP, 0x04) + +/** +* @ingroup los_cpup +* CPU usage error code: The target task ID is invalid. +* +* Value: 0x02001e05 +* +* Solution: Check whether the target task ID is applicable for the current operation. +*/ +#define LOS_ERRNO_CPUP_TSK_ID_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_CPUP, 0x05) + +/** +* @ingroup los_cpup +* Sum of cpup with all tasks. It means the value of cpup is a permillage. +*/ +#define LOS_CPUP_PRECISION 1000 + +/** +* @ingroup los_cpup +* Multiple of current cpup precision change to percent. +*/ +#define LOS_CPUP_PRECISION_MULT (LOS_CPUP_PRECISION / 100) + +/** + * @ingroup los_cpup + * Count the CPU usage structures of all tasks. + */ +typedef struct tagCpupInfo { + UINT16 usStatus; /**< save the cur task status */ + UINT32 uwUsage; /**< Usage. The value range is [0,1000]. */ +} CPUP_INFO_S; + +/** + * @ingroup los_monitor + * Type of the CPU usage query. + */ +typedef enum { + SYS_CPU_USAGE = 0, /* system cpu occupancy rate */ + TASK_CPU_USAGE, /* task cpu occupancy rate */ +} CPUP_TYPE_E; + +/** + * @ingroup los_monitor + * Mode of the CPU usage query. + */ +typedef enum { + CPUP_IN_10S = 0, /* cpu occupancy rate in 10s */ + CPUP_IN_1S, /* cpu occupancy rate in 1s */ + CPUP_LESS_THAN_1S, /* cpu occupancy rate less than 1s, if the input mode is none of them, it will be this. */ +} CPUP_MODE_E; + +/** + * @ingroup los_cpup + * @brief Obtain the current CPU usage. + * + * @par Description: + * This API is used to obtain the current CPU usage. + * @attention + *
    + *
  • This API can be called only after the CPU usage is initialized. Otherwise, error codes will be returned.
  • + *
  • The precision of the CPU usage can be adjusted by changing the value of the CPUP_PRECISION macro.
  • + *
+ * + * @param None. + * + * @retval #OS_ERRNO_CPUP_NO_INIT 0x02001e02: The CPU usage is not initialized. + * @retval #cpup [0,100], current CPU usage, of which the precision is adjustable. + * @par Dependency: + *
  • los_cpup.h: the header file that contains the API declaration.
+ * @see LOS_SysCpuUsage + */ +extern UINT32 LOS_SysCpuUsage(VOID); + +/** + * @ingroup los_cpup + * @brief Obtain the historical CPU usage. + * + * @par Description: + * This API is used to obtain the historical CPU usage. + * @attention + *
    + *
  • This API can be called only after the CPU usage is initialized. Otherwise, the CPU usage fails to be obtained.
  • + *
+ * + * @param mode [IN] UINT16. Task mode. The parameter value 0 indicates that the CPU usage within 10s will be + * obtained, and the parameter value 1 indicates that the CPU usage in the former 1s will be obtained. Other values + * indicate that the CPU usage in the period that is less than 1s will be obtained. + * + * @retval #OS_ERRNO_CPUP_NO_INIT 0x02001e02: The CPU usage is not initialized. + * @retval #cpup [0,100], historical CPU usage, of which the precision is adjustable. + * @par Dependency: + *
  • los_cpup.h: the header file that contains the API declaration.
+ * @see LOS_HistoryTaskCpuUsage + */ +extern UINT32 LOS_HistorySysCpuUsage(UINT16 mode); + +/** + * @ingroup los_cpup + * @brief Obtain the CPU usage of a specified task. + * + * @par Description: + * This API is used to obtain the CPU usage of a task specified by a passed-in task ID. + * @attention + *
    + *
  • This API can be called only after the CPU usage is initialized. Otherwise, the CPU usage fails to be obtained.
  • + *
  • The passed-in task ID must be valid and the task specified by the task ID must be created. Otherwise, + * the CPU usage fails to be obtained.
  • + *
+ * + * @param taskID [IN] UINT32. Task ID. + * + * @retval #OS_ERRNO_CPUP_NO_INIT 0x02001e02: The CPU usage is not initialized. + * @retval #OS_ERRNO_CPUP_TSK_ID_INVALID 0x02001e05: The target task ID is invalid. + * @retval #OS_ERRNO_CPUP_THREAD_NO_CREATED 0x02001e04: The target thread is not created. + * @retval #cpup [0,100], CPU usage of the specified task. + * @par Dependency: + *
  • los_cpup.h: the header file that contains the API declaration.
+ * @see LOS_HistoryTaskCpuUsage + */ +extern UINT32 LOS_TaskCpuUsage(UINT32 taskID); + +/** + * @ingroup los_cpup + * @brief Obtain the historical CPU usage of a specified task. + * + * @par Description: + * This API is used to obtain the historical CPU usage of a task specified by a passed-in task ID. + * @attention + *
    + *
  • This API can be called only after the CPU usage is initialized. Otherwise, + * the CPU usage fails to be obtained.
  • + *
  • The passed-in task ID must be valid and the task specified by the task ID must be created. Otherwise, + * the CPU usage fails to be obtained.
  • + *
+ * + * @param taskID [IN] UINT32. Task ID. + * @param mode [IN] UINT16. Task mode. The parameter value 0 indicates that the CPU usage within 10s + * will be obtained, and the parameter value 1 indicates that the CPU usage in the former 1s will be obtained. + * Other values indicate that the CPU usage in the period that is less than 1s will be obtained. + * + * @retval #OS_ERRNO_CPUP_NO_INIT 0x02001e02: The CPU usage is not initialized. + * @retval #OS_ERRNO_CPUP_TSK_ID_INVALID 0x02001e05: The target task ID is invalid. + * @retval #OS_ERRNO_CPUP_THREAD_NO_CREATED 0x02001e04: The target thread is not created. + * @retval #cpup [0,100], CPU usage of the specified task. + * @par Dependency: + *
  • los_cpup.h: the header file that contains the API declaration.
+ * @see LOS_HistorySysCpuUsage + */ +extern UINT32 LOS_HistoryTaskCpuUsage(UINT32 taskID, UINT16 mode); + +/** + * @ingroup los_cpup + * @brief Obtain the CPU usage of all tasks. + * + * @par Description: + * This API is used to obtain the CPU usage of all tasks according to maximum number of threads. + * @attention + *
    + *
  • This API can be called only after the CPU usage is initialized. Otherwise, the CPU usage fails to be obtained.
  • + *
  • The input parameter pointer must not be NULL, Otherwise, the CPU usage fails to be obtained.
  • + *
+ * + * @param cpupInfo [OUT]Type. CPUP_INFO_S* Pointer to the task CPUP information structure to be obtained. + * @param mode [IN] UINT16. Task mode. The parameter value 0 indicates that the CPU usage within 10s + * will be obtained, and the parameter value 1 indicates that the CPU usage in the former 1s will be obtained. + * Other values indicate that the CPU usage in the period that is less than 1s will be obtained. + * + * @retval #OS_ERRNO_CPUP_NO_INIT 0x02001e02: The CPU usage is not initialized. + * @retval #OS_ERRNO_CPUP_TASK_PTR_NULL 0x02001e01: The input parameter pointer is NULL. + * @retval #LOS_OK 0x00000000: The CPU usage of all tasks is successfully obtained. + * @par Dependency: + *
  • los_cpup.h: the header file that contains the API declaration.
+ * @see LOS_SysCpuUsage + */ +extern UINT32 LOS_AllTaskCpuUsage(CPUP_INFO_S *cpupInfo, UINT16 mode); + +/** + * @ingroup los_monitor + * @brief Obtain CPU usage history of certain task. + * + * @par Description: + * This API is used to obtain CPU usage history of certain task. + * @attention + *
    + *
  • This API can be called only after the CPU usage is initialized. Otherwise, -1 will be returned.
  • + *
  • Only in SYS_CPU_USAGE type, uwTaskID is invalid.
  • + *
+ * + * @param type [IN] cpup type, SYS_CPU_USAGE and TASK_CPU_USAGE + * @param mode [IN] mode,CPUP_IN_10S = usage in 10s,CPUP_IN_1S = usage in last 1s, + * CPUP_LESS_THAN_1S = less than 1s, if the inpuit mode is none of them, it will be as CPUP_LESS_THAN_1S. + * @param taskID [IN] task ID, Only in SYS_CPU_USAGE type, taskID is invalid + * + * @retval #OS_ERROR -1:CPU usage info obtain failed. + * @retval #LOS_OK 0:CPU usage info is successfully obtained. + * @par Dependency: + *
  • los_monitor.h: the header file that contains the API declaration.
+ * @see LOS_CpupUsageMonitor + */ +extern UINT32 LOS_CpupUsageMonitor(CPUP_TYPE_E type, CPUP_MODE_E mode, UINT32 taskID); + +/** + * @ingroup los_task + * Null task ID + * + */ +#define OS_TASK_ERRORID 0xFFFFFFFF + +/** + * @ingroup los_task + * Define a usable task priority. + * + * Highest task priority. + */ +#define OS_TASK_PRIORITY_HIGHEST 0 + +/** + * @ingroup los_task + * Define a usable task priority. + * + * Lowest task priority. + */ +#define OS_TASK_PRIORITY_LOWEST 31 + +/** + * @ingroup los_task + * Flag that indicates the task or task control block status. + * + * The task control block is unused. + */ +#define OS_TASK_STATUS_UNUSED 0x0001 + +/** + * @ingroup los_task + * Flag that indicates the task or task control block status. + * + * The task is suspended. + */ +#define OS_TASK_STATUS_SUSPEND 0x0002 + +/** + * @ingroup los_task + * Flag that indicates the task or task control block status. + * + * The task is ready. + */ +#define OS_TASK_STATUS_READY 0x0004 + +/** + * @ingroup los_task + * Flag that indicates the task or task control block status. + * + * The task is blocked. + */ +#define OS_TASK_STATUS_PEND 0x0008 + +/** + * @ingroup los_task + * Flag that indicates the task or task control block status. + * + * The task is running. + */ +#define OS_TASK_STATUS_RUNNING 0x0010 + +/** + * @ingroup los_task + * Flag that indicates the task or task control block status. + * + * The task is delayed. + */ +#define OS_TASK_STATUS_DELAY 0x0020 + +/** + * @ingroup los_task + * Flag that indicates the task or task control block status. + * + * The time for waiting for an event to occur expires. + */ +#define OS_TASK_STATUS_TIMEOUT 0x0040 + +/** + * @ingroup los_task + * Flag that indicates the task or task control block status. + * + * The task is waiting for an event to occur. + */ +#define OS_TASK_STATUS_EVENT 0x0400 + +/** + * @ingroup los_task + * Flag that indicates the task or task control block status. + * + * The task is reading an event. + */ +#define OS_TASK_STATUS_EVENT_READ 0x0800 + +/** + * @ingroup los_task + * Flag that indicates the task or task control block status. + * + * A software timer is waiting for an event to occur. + */ +#define OS_TASK_STATUS_SWTMR_WAIT 0x1000 + +/** + * @ingroup los_task + * Flag that indicates the task or task control block status. + * + * The task is blocked on a queue. + */ +#define OS_TASK_STATUS_PEND_QUEUE 0x2000 + +/** + * @ingroup los_task + * Flag that indicates the task is in userspace. + * + * The task is a user task. + */ +#define OS_TASK_STATUS_USERSPACE 0x8000 + +/** + * @ingroup los_task + * Boundary on which the stack size is aligned. + * + */ +#define OS_TASK_STACK_SIZE_ALIGN 16 + +/** + * @ingroup los_task + * Boundary on which the stack address is aligned. + * + */ +#define OS_TASK_STACK_ADDR_ALIGN 8 + +/** + * @ingroup los_task + * Task stack top magic number. + * + */ +#define OS_TASK_MAGIC_WORD 0xCCCCCCCC + +/** + * @ingroup los_task + * Initial task stack value. + * + */ +#define OS_TASK_STACK_INIT 0xCACACACA + +/** + * @ingroup los_task + * Number of usable task priorities. + */ +#define OS_TSK_PRINUM ((OS_TASK_PRIORITY_LOWEST - OS_TASK_PRIORITY_HIGHEST) + 1) + +/** + * @ingroup los_task + * @brief the num of delayed tasks bucket + */ +#define OS_TSK_SORTLINK_LEN 32 + +/** + * @ingroup los_task + * @brief the bit width occupied by the delayed ticks of task + */ +#define OS_TSK_SORTLINK_LOGLEN 5 + +/** + * @ingroup los_task + * @brief the mask of delayed tasks bucket id. + */ +#define OS_TSK_SORTLINK_MASK (OS_TSK_SORTLINK_LEN - 1) + +/** + * @ingroup los_task + * @brief the max task count for switch. + */ +#define OS_TASK_SWITCH_INFO_COUNT 0xA + +/** + * @ingroup los_task + * @brief Check whether a task ID is valid. + * + * @par Description: + * This API is used to check whether a task ID, excluding the idle task ID, is valid. + * @attention None. + * + * @param taskID [IN] Task ID. + * + * @retval 0 or 1. One indicates that the task ID is invalid, whereas zero indicates that the task ID is valid. + * @par Dependency: + *
  • los_task_pri.h: the header file that contains the API declaration.
+ * @see + */ +#define OS_TSK_GET_INDEX(taskID) (taskID) + +/** + * @ingroup los_task + * @brief Obtain the pointer to a task control block. + * + * @par Description: + * This API is used to obtain the pointer to a task control block using a corresponding parameter. + * @attention None. + * + * @param ptr [IN] Parameter used for obtaining the task control block. + * + * @retval Pointer to the task control block. + * @par Dependency: + *
  • los_task_pri.h: the header file that contains the API declaration.
+ * @see + */ +#define OS_TCB_FROM_PENDLIST(ptr) LOS_DL_LIST_ENTRY(ptr, LosTaskCB, pendList) + +/** + * @ingroup los_task + * @brief Obtain the pointer to a task control block. + * + * @par Description: + * This API is used to obtain the pointer to a task control block that has a specified task ID. + * @attention None. + * + * @param taskID [IN] task ID. + * + * @retval Pointer to the task control block. + * @par Dependency: + *
  • los_task_pri.h: the header file that contains the API declaration.
+ * @see + */ +#define OS_TCB_FROM_TID(taskID) (((LosTaskCB *)g_taskCBArray) + (taskID)) +#define OS_IDLE_TASK_ENTRY ((TSK_ENTRY_FUNC)OsIdleTask) + + +/** + * @ingroup los_task + * Define the task control block structure. + */ +typedef struct { + VOID *stackPointer; /**< Task stack pointer */ + UINT16 taskStatus; + UINT16 priority; + UINT32 stackSize; /**< Task stack size */ + UINT32 topOfStack; /**< Task stack top */ + UINT32 taskID; /**< Task ID */ + TSK_ENTRY_FUNC taskEntry; /**< Task entrance function */ + VOID *taskSem; /**< Task-held semaphore */ + VOID *taskMux; /**< Task-held mutex */ + UINT32 arg; /**< Parameter */ + CHAR *taskName; /**< Task name */ + LOS_DL_LIST pendList; + LOS_DL_LIST timerList; + UINT32 idxRollNum; + EVENT_CB_S event; + UINT32 eventMask; /**< Event mask */ + UINT32 eventMode; /**< Event mode */ + VOID *msg; /**< Memory allocated to queues */ +} LosTaskCB; + +typedef struct { + LosTaskCB *runTask; + LosTaskCB *newTask; +} LosTask; + +typedef struct { + LOS_DL_LIST *sortLink; + UINT16 cursor; + UINT16 unused; +} TaskSortLinkAttr; + +/** + * @ingroup los_task + * Time slice structure. + */ +typedef struct TaskTimeSlice { + LosTaskCB *task; /**< Current running task */ + UINT16 time; /**< Expiration time point */ + UINT16 tout; /**< Expiration duration */ +} OsTaskRobin; + +typedef struct { + UINT8 maxCnt : 7; // bits [6:0] store count of task switch info + UINT8 isFull : 1; // bit [7] store isfull status +} TaskCountInfo; + +/** + * @ingroup los_task + * Task switch information structure. + * + */ +typedef struct { + UINT8 idx; + TaskCountInfo cntInfo; + UINT16 pid[OS_TASK_SWITCH_INFO_COUNT]; + CHAR name[OS_TASK_SWITCH_INFO_COUNT][LOS_TASK_NAMELEN]; +}TaskSwitchInfo; + + +extern LosTask g_losTask; + +/** + * @ingroup los_task + * Task lock flag. + * + */ +extern UINT16 g_losTaskLock; + +/** + * @ingroup los_task + * Maximum number of tasks. + * + */ +extern UINT32 g_taskMaxNum; + +/** + * @ingroup los_task + * Idle task ID. + * + */ +extern UINT32 g_idleTaskID; + +/** + * @ingroup los_task + * Software timer task ID. + * + */ +extern UINT32 g_swtmrTaskID; + +/** + * @ingroup los_task + * Starting address of a task. + * + */ +extern LosTaskCB *g_taskCBArray; + +/** + * @ingroup los_task + * Free task linked list. + * + */ +extern LOS_DL_LIST g_losFreeTask; + +/** + * @ingroup los_task + * Circular linked list that stores tasks that are deleted automatically. + * + */ +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. + * + * @par Description: + * This API is used to modify the priority of task. + * + * @attention + *
    + *
  • The taskCB should be a correct pointer to task control block structure.
  • + *
  • the priority should be in [0, OS_TASK_PRIORITY_LOWEST].
  • + *
+ * + * @param taskCB [IN] Type #LosTaskCB * pointer to task control block structure. + * @param priority [IN] Type #UINT16 the priority of task. + * + * @retval None. + * @par Dependency: + *
  • los_task_pri.h: the header file that contains the API declaration.
+ * @see + */ +extern VOID OsTaskPriModify(LosTaskCB *taskCB, UINT16 priority); + +/** + * @ingroup los_task + * @brief Scan a task. + * + * @par Description: + * This API is used to scan a task. + * + * @attention + *
    + *
  • None.
  • + *
+ * + * @param None. + * + * @retval None. + * @par Dependency: + *
  • los_task_pri.h: the header file that contains the API declaration.
+ * @see + */ +extern VOID OsTaskScan(VOID); + +/** + * @ingroup los_task + * @brief Initialization a task. + * + * @par Description: + * This API is used to initialization a task. + * + * @attention + *
    + *
  • None.
  • + *
+ * + * @param None. + * + * @retval UINT32 Initialization result. + * @par Dependency: + *
  • los_task_pri.h: the header file that contains the API declaration.
+ * @see + */ +extern UINT32 OsTaskInit(VOID); + +/** + * @ingroup los_task + * @brief Create idle task. + * + * @par Description: + * This API is used to create idle task. + * + * @attention + *
    + *
  • None.
  • + *
+ * + * @param None. + * + * @retval UINT32 Create result. + * @par Dependency: + *
  • los_task_pri.h: the header file that contains the API declaration.
+ * @see + */ +extern UINT32 OsIdleTaskCreate(VOID); + +/** + * @ingroup los_task + * @brief Check task switch. + * + * @par Description: + * This API is used to check task switch. + * + * @attention + *
    + *
  • None.
  • + *
+ * + * @param None. + * + * @retval None. + * @par Dependency: + *
  • los_task_pri.h: the header file that contains the API declaration.
+ * @see + */ +extern VOID OsTaskSwitchCheck(VOID); + +/** + * @ingroup los_task + * @brief TaskMonInit. + * + * @par Description: + * This API is used to taskMonInit. + * + * @attention + *
    + *
  • None.
  • + *
+ * + * @param None. + * + * @retval None. + * @par Dependency: + *
  • los_task_pri.h: the header file that contains the API declaration.
+ * @see + */ +extern VOID OsTaskMonInit(VOID); + +/** + * @ingroup los_task + * @brief Task entry. + * + * @par Description: + * This API is used to task entry. + * + * @attention + *
    + *
  • None.
  • + *
+ * + * @param taskID [IN] Type #UINT32 task id. + * + * @retval None. + * @par Dependency: + *
  • los_task_pri.h: the header file that contains the API declaration.
+ * @see + */ +extern VOID OsTaskEntry(UINT32 taskID); + +/** + * @ingroup los_task + * @brief pend running task to pendlist + * + * @par Description: + * This API is used to pend task to pendlist and add to sorted delay list. + * + * @attention + *
    + *
  • The pstList should be a vaild pointer to pendlist.
  • + *
+ * + * @param list [IN] Type #LOS_DL_LIST * pointer to list which running task will be pended. + * @param taskStatus [IN] Type #UINT32 Task Status. + * @param timeOut [IN] Type #UINT32 Expiry time. The value range is [0,LOS_WAIT_FOREVER]. + * + * @retval LOS_OK wait success + * @retval LOS_NOK pend out + * @par Dependency: + *
  • los_task_pri.h: the header file that contains the API declaration.
+ * @see OsTaskWake + */ +extern VOID OsTaskWait(LOS_DL_LIST *list, UINT32 taskStatus, UINT32 timeOut); + +/** + * @ingroup los_task + * @brief delete task from pendlist. + * + * @par Description: + * This API is used to delete task from pendlist and also add to the priqueue. + * + * @attention + *
    + *
  • The pstList should be a vaild pointer to pend list.
  • + *
+ * + * @param resumedTask [IN] Type #LosTaskCB * pointer to the task which will be add to priqueue. + * @param taskStatus [IN] Type #UINT32 Task Status. + * + * @retval None. + * @par Dependency: + *
  • los_task_pri.h: the header file that contains the API declaration.
+ * @see OsTaskWait + */ +extern VOID OsTaskWake(LosTaskCB *resumedTask, UINT32 taskStatus); + +/** + * @ingroup los_task + * @brief Get the task water line. + * + * @par Description: + * This API is used to get the task water line. + * + * @attention + *
    + *
  • None.
  • + *
+ * + * @param taskID [IN] Type #UINT32 task id. + * + * @retval UINT32 Task water line. + * @par Dependency: + *
  • los_task_pri.h: the header file that contains the API declaration.
+ * @see None. + */ +extern UINT32 OsGetTaskWaterLine(UINT32 taskID); + +/** + * @ingroup los_task + * @brief Convert task status to string. + * + * @par Description: + * This API is used to convert task status to string. + * + * @attention + *
    + *
  • None.
  • + *
+ * + * @param taskStatus [IN] Type #UINT16 task status. + * + * @retval UINT8 * String. + * @par Dependency: + *
  • los_task_pri.h: the header file that contains the API declaration.
+ * @see None. + */ +extern UINT8 *OsConvertTskStatus(UINT16 taskStatus); + +/** + * @ingroup los_task + * @brief Add task to sorted delay list. + * + * @par Description: + * This API is used to add task to sorted delay list. + * + * @attention + *
    + *
  • The taskCB should be a correct pointer to task control block structure.
  • + *
+ * + * @param taskCB [IN] Type #LosTaskCB * pointer to task control block structure. + * @param timeout [IN] Type #UINT32 wait time, ticks. + * + * @retval None. + * @par Dependency: + *
  • los_task_pri.h: the header file that contains the API declaration.
+ * @see OsTimerListDelete + */ +extern VOID OsTaskAdd2TimerList(LosTaskCB *taskCB, UINT32 timeout); + +/** + * @ingroup los_task + * @brief delete task from sorted delay list. + * + * @par Description: + * This API is used to delete task from sorted delay list. + * + * @attention + *
    + *
  • The taskCB should be a correct pointer to task control block structure.
  • + *
+ * + * @param taskCB [IN] Type #LosTaskCB * pointer to task control block structure. + * + * @retval None. + * @par Dependency: + *
  • los_task_pri.h: the header file that contains the API declaration.
+ * @see OsTaskAdd2TimerList + */ +extern VOID OsTimerListDelete(LosTaskCB *taskCB); + +/** + * @ingroup los_task + * @brief Get all task information. + * + * @par Description: + * This API is used to get all task information. + * + * @attention + *
    + *
  • None.
  • + *
+ * + * @param None. + * + * @retval UINT32 All task information. + * @par Dependency: + *
  • los_task_pri.h: the header file that contains the API declaration.
+ * @see None. + */ +extern UINT32 OsGetAllTskInfo(VOID); + + +extern VOID *OsTskUserStackInit(VOID* stackPtr, VOID* userSP, UINT32 userStackSize); + +extern VOID *OsTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack); + +extern VOID OsSchedule(VOID); + +extern VOID osTaskSchedule(VOID); + #ifdef __cplusplus #if __cplusplus } diff --git a/kernel/include/los_tick.h b/kernel/include/los_tick.h index 60c5d3e2..b199cf38 100755 --- a/kernel/include/los_tick.h +++ b/kernel/include/los_tick.h @@ -37,7 +37,7 @@ #ifndef _LOS_TICK_H #define _LOS_TICK_H -#include "los_errno.h" +#include "los_error.h" #ifdef __cplusplus #if __cplusplus @@ -98,6 +98,466 @@ 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 + * Number of milliseconds in one second. + */ +#define OS_SYS_MS_PER_SECOND 1000 + +/** + * @ingroup los_sys + * Number of microseconds in one second. + */ +#define OS_SYS_US_PER_SECOND 1000000 + +/** + * @ingroup los_sys + * System time basic function error code: Null pointer. + * + * Value: 0x02000010 + * + * Solution: Check whether the input parameter is null. + */ +#define LOS_ERRNO_SYS_PTR_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_SYS, 0x10) + +/** + * @ingroup los_sys + * System time basic function error code: Invalid system clock configuration. + * + * Value: 0x02000011 + * + * Solution: Configure a valid system clock in los_config.h. + */ +#define LOS_ERRNO_SYS_CLOCK_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_SYS, 0x11) + +/** + * @ingroup los_sys + * System time basic function error code: This error code is not in use temporarily. + * + * Value: 0x02000012 + * + * Solution: None. + */ +#define LOS_ERRNO_SYS_MAXNUMOFCORES_IS_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_SYS, 0x12) + +/** + * @ingroup los_sys + * System time error code: This error code is not in use temporarily. + * + * Value: 0x02000013 + * + * Solution: None. + */ +#define LOS_ERRNO_SYS_PERIERRCOREID_IS_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_SYS, 0x13) + +/** + * @ingroup los_sys + * System time error code: This error code is not in use temporarily. + * + * Value: 0x02000014 + * + * Solution: None. + */ +#define LOS_ERRNO_SYS_HOOK_IS_FULL LOS_ERRNO_OS_ERROR(LOS_MOD_SYS, 0x14) + +/** + * @ingroup los_typedef + * system time structure. + */ +typedef struct tagSysTime { + UINT16 uwYear; /**< value 1970 ~ 2038 or 1970 ~ 2100 */ + UINT8 ucMonth; /**< value 1 - 12 */ + UINT8 ucDay; /**< value 1 - 31 */ + UINT8 ucHour; /**< value 0 - 23 */ + UINT8 ucMinute; /**< value 0 - 59 */ + UINT8 ucSecond; /**< value 0 - 59 */ + UINT8 ucWeek; /**< value 0 - 6 */ +} SYS_TIME_S; + +/** + * @ingroup los_sys + * @brief Obtain the number of Ticks. + * + * @par Description: + * This API is used to obtain the number of Ticks. + * @attention + *
    + *
  • None
  • + *
+ * + * @param None + * + * @retval UINT64 The number of Ticks. + * @par Dependency: + *
  • los_sys.h: the header file that contains the API declaration.
+ * @see None + */ +extern UINT64 LOS_TickCountGet(VOID); + +/** + * @ingroup los_sys + * @brief Obtain the number of cycles in one second. + * + * @par Description: + * This API is used to obtain the number of cycles in one second. + * @attention + *
    + *
  • None
  • + *
+ * + * @param None + * + * @retval UINT32 Number of cycles obtained in one second. + * @par Dependency: + *
  • los_sys.h: the header file that contains the API declaration.
+ * @see None + */ +extern UINT32 LOS_CyclePerTickGet(VOID); + +/** + * @ingroup los_sys + * @brief Convert Ticks to milliseconds. + * + * @par Description: + * This API is used to convert Ticks to milliseconds. + * @attention + *
    + *
  • The number of milliseconds obtained through the conversion is 32-bit.
  • + *
+ * + * @param ticks [IN] Number of Ticks. The value range is (0,OS_SYS_CLOCK). + * + * @retval UINT32 Number of milliseconds obtained through the conversion. Ticks are successfully converted to + * milliseconds. + * @par Dependency: + *
  • los_sys.h: the header file that contains the API declaration.
+ * @see LOS_MS2Tick + */ +extern UINT32 LOS_Tick2MS(UINT32 ticks); + +/** + * @ingroup los_sys + * @brief Convert milliseconds to Ticks. + * + * @par Description: + * This API is used to convert milliseconds to Ticks. + * @attention + *
    + *
  • If the parameter passed in is equal to 0xFFFFFFFF, the retval is 0xFFFFFFFF. Pay attention to the value to be + * converted because data possibly overflows.
  • + *
+ * + * @param millisec [IN] Number of milliseconds. + * + * @retval UINT32 Number of Ticks obtained through the conversion. + * @par Dependency: + *
  • los_sys.h: the header file that contains the API declaration.
+ * @see LOS_Tick2MS + */ +extern UINT32 LOS_MS2Tick(UINT32 millisec); + +/** + * @ingroup los_tick + * Count of Ticks + */ +extern UINT64 g_ullTickCount; + +/** + * @ingroup los_tick + * Ticks per second + */ +extern UINT32 g_ticksPerSec; + +/** + * @ingroup los_tick + * Cycles per Second + */ +extern UINT32 g_uwCyclePerSec; + +/** + * @ingroup los_tick + * Cycles per Tick + */ +extern UINT32 g_cyclesPerTick; + +/** + * @ingroup los_tick + * System Clock + */ +extern UINT32 g_sysClock; +/** + * @ingroup los_tick + * @brief Handle the system tick timeout. + * + * @par Description: + * This API is called when the system tick timeout and triggers the interrupt. + * + * @attention + *
    + *
  • None.
  • + *
+ * + * @param none. + * + * @retval None. + * @par Dependency: + *
  • los_tick_pri.h: the header file that contains the API declaration.
+ * @see None. + */ +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 + *
    + *
  • None.
  • + *
+ * + * @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 + *
    + *
  • None.
  • + *
+ * + * @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 + *
    + *
  • None.
  • + *
+ * + * @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. + */ +typedef struct tagCpuTick { + UINT32 cntHi; /* < Upper 32 bits of the tick value */ + UINT32 cntLo; /* < Lower 32 bits of the tick value */ +} CpuTick; + +/** + * @ingroup los_sys + * Number of operable bits of a 32-bit operand + */ +#define OS_SYS_MV_32_BIT 32 + +/** + * @ingroup los_sys + * Number of milliseconds in one second. + */ +#define OS_SYS_MS_PER_SECOND 1000 + +/** + * @ingroup los_sys + * Number of microseconds in one second. + */ +#define OS_SYS_US_PER_SECOND 1000000 + +/** + * @ingroup los_sys + * The maximum length of name. + */ +#define OS_SYS_APPVER_NAME_MAX 64 + +/** + * @ingroup los_sys + * The magic word. + */ +#define OS_SYS_MAGIC_WORD 0xAAAAAAAA + +/** + * @ingroup los_sys + * The initialization value of stack space. + */ +#define OS_SYS_EMPTY_STACK 0xCACACACA + +/** + * @ingroup los_sys + * @brief Convert cycles to milliseconds. + * + * @par Description: + * This API is used to convert cycles to milliseconds. + * @attention + *
    + *
  • None.
  • + *
+ * + * @param cpuTick [IN] Number of CPU cycles. + * @param msHi [OUT] Upper 32 bits of the number of milliseconds. + * @param msLo [OUT] Lower 32 bits of the number of milliseconds. + * + * @retval #LOS_ERRNO_SYS_PTR_NULL 0x02000011: Invalid parameter. + * @retval #LOS_OK 0: Cycles are successfully converted to microseconds. + * @par Dependency: + *
  • los_sys_pri.h: the header file that contains the API declaration.
+ * @see None. + */ +extern UINT32 OsCpuTick2MS(CpuTick *cpuTick, UINT32 *msHi, UINT32 *msLo); + +/** + * @ingroup los_sys + * @brief Convert cycles to microseconds. + * + * @par Description: + * This API is used to convert cycles to microseconds. + * @attention + *
    + *
  • None.
  • + *
+ * + * @param cpuTick [IN] Number of CPU cycles. + * @param usHi [OUT] Upper 32 bits of the number of microseconds. + * @param usLo [OUT] Lower 32 bits of the number of microseconds. + * + * @retval #LOS_ERRNO_SYS_PTR_NULL 0x02000011: Invalid parameter. + * @retval #LOS_OK 0: Cycles are successfully converted to microseconds. + * @par Dependency: + *
  • los_sys_pri.h: the header file that contains the API declaration.
+ * @see None. + */ +extern UINT32 OsCpuTick2US(CpuTick *cpuTick, UINT32 *usHi, UINT32 *usLo); + +/** + * @ingroup los_sys + * @brief Convert cycles to milliseconds. + * + * @par Description: + * This API is used to convert cycles to milliseconds. + * @attention + *
    + *
  • None.
  • + *
+ * + * @param cycle [IN] Number of cycles. + * + * @retval Number of milliseconds obtained through the conversion. Cycles are successfully converted to milliseconds. + * @par Dependency: + *
  • los_sys_pri.h: the header file that contains the API declaration.
+ * @see None. + */ +STATIC_INLINE UINT64 OsCycle2MS(UINT64 cycle) +{ + return (UINT64)((cycle / (g_sysClock / OS_SYS_MS_PER_SECOND))); +} + +/** + * @ingroup los_sys + * @brief Convert cycles to microseconds. + * + * @par Description: + * This API is used to convert cycles to microseconds. + * @attention + *
    + *
  • None.
  • + *
+ * + * @param cycle [IN] Number of cycles. + * + * @retval Number of microseconds obtained through the conversion. Cycles are successfully converted to microseconds. + * @par Dependency: + *
  • los_sys_pri.h: the header file that contains the API declaration.
+ * @see None. + */ +STATIC_INLINE UINT64 OsCycle2US(UINT64 cycle) +{ + UINT64 tmp = g_sysClock / OS_SYS_US_PER_SECOND; + if (tmp == 0) { + return 0; + } + return (UINT64)(cycle / tmp); +} + + #ifdef __cplusplus #if __cplusplus } diff --git a/kernel/include/los_tickless.h b/kernel/include/los_tickless.h deleted file mode 100755 index a73e1345..00000000 --- a/kernel/include/los_tickless.h +++ /dev/null @@ -1,91 +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. - */ - -/** - * @defgroup los_tickless Tickless - * @ingroup kernel - */ - -#ifndef _LOS_TICKLESS_H -#define _LOS_TICKLESS_H - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -/** - * @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); - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif diff --git a/kernel/include/los_typedef.h b/kernel/include/los_typedef.h deleted file mode 100755 index 96bacbae..00000000 --- a/kernel/include/los_typedef.h +++ /dev/null @@ -1,121 +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. - */ - -/** - * @defgroup los_typedef Type define - * @ingroup kernel - */ - -#ifndef _LOS_TYPEDEF_H -#define _LOS_TYPEDEF_H - -#include "los_builddef.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#ifndef LOS_TYPE_DEF -#define LOS_TYPE_DEF - -/* type definitions */ -typedef unsigned char UINT8; -typedef unsigned short UINT16; -typedef unsigned int UINT32; -typedef signed char INT8; -typedef signed short INT16; -typedef signed int INT32; -typedef float FLOAT; -typedef double DOUBLE; -typedef char CHAR; - -typedef unsigned int BOOL; -typedef unsigned long long UINT64; -typedef signed long long INT64; -typedef unsigned int UINTPTR; -typedef signed int INTPTR; - -#define VOID void -#endif /* end of #ifndef LOS_TYPE_DEF */ - -#ifndef FALSE -#define FALSE ((BOOL)0) -#endif - -#ifndef TRUE -#define TRUE ((BOOL)1) -#endif - -#ifndef NULL -#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) - -#ifndef LOS_OK -#define LOS_OK 0U -#endif - -#ifndef LOS_NOK -#define LOS_NOK 1U -#endif - -#define OS_FAIL 1 -#define OS_ERROR (UINT32)(-1) -#define OS_INVALID (UINT32)(-1) - -#define asm __asm -#ifdef typeof -#undef typeof -#endif -#define typeof __typeof__ - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_TYPEDEF_H */ diff --git a/kernel/src/los_base_pri.h b/kernel/src/los_base_pri.h deleted file mode 100755 index 8b712311..00000000 --- a/kernel/src/los_base_pri.h +++ /dev/null @@ -1,63 +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. - */ - -#ifndef _LOS_BASE_PRI_H -#define _LOS_BASE_PRI_H - -#include "los_base.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -/** - * @ingroup los_base - * Define the CPU Tick structure. - */ -typedef struct tagCpuTick { - UINT32 cntHi; /* < Upper 32 bits of the tick value */ - UINT32 cntLo; /* < Lower 32 bits of the tick value */ -} CpuTick; - -#define OS_GOTO_ERREND() \ - do { \ - goto LOS_ERREND; \ - } while (0) - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_BASE_PRI_H */ diff --git a/kernel/src/los_err_pri.h b/kernel/src/los_err_pri.h deleted file mode 100755 index 84c16ec8..00000000 --- a/kernel/src/los_err_pri.h +++ /dev/null @@ -1,132 +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. - */ - -#ifndef _LOS_ERR_PRI_H -#define _LOS_ERR_PRI_H - -#include "los_err.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - - -/** - * @ingroup los_err - * Define the error magic word. - */ -#define OS_ERR_MAGIC_WORD 0xa1b2c3f8 - -/** - * @ingroup los_err - * @brief Error handling macro capable of returning error codes. - * - * @par Description: - * This API is used to call the error handling function by using an error code and return the same error code. - * @attention - *
    - *
  • None.
  • - *
- * - * @param errNo [IN] Error code. - * - * @retval errNo - * @par Dependency: - *
  • los_err_pri.h: the header file that contains the API declaration.
- * @see None. - */ -#define OS_RETURN_ERROR(errNo) \ - do { \ - (VOID)LOS_ErrHandle("os_unspecific_file", OS_ERR_MAGIC_WORD, errNo, 0, NULL); \ - return (errNo); \ - } while (0) - -/** - * @ingroup los_err - * @brief Error handling macro capable of returning error codes. - * - * @par Description: - * This API is used to call the error handling function by using an error code and the line number of the erroneous line, - and return the same error code. - * @attention - *
    - *
  • None.
  • - *
- * - * @param errLine [IN] Line number of the erroneous line. - * @param errNo [IN] Error code. - * - * @retval errNo - * @par Dependency: - *
  • los_err_pri.h: the header file that contains the API declaration.
- * @see None. - */ -#define OS_RETURN_ERROR_P2(errLine, errNo) \ - do { \ - (VOID)LOS_ErrHandle("os_unspecific_file", errLine, errNo, 0, NULL); \ - return (errNo); \ - } while (0) - -/** - * @ingroup los_err - * @brief Macro for jumping to error handler. - * - * @par Description: - * This API is used to call the error handling function by using an error code. - * @attention - *
    - *
  • None.
  • - *
- * - * @param errorNo [IN] Error code. - * - * @retval None. - * @par Dependency: - *
  • los_err_pri.h: the header file that contains the API declaration.
- * @see None. - */ -#define OS_GOTO_ERR_HANDLER(errorNo) \ - do { \ - errNo = (errorNo); \ - errLine = OS_ERR_MAGIC_WORD; \ - goto ERR_HANDLER; \ - } while (0) - - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_ERR_PRI_H */ diff --git a/kernel/src/los_event.c b/kernel/src/los_event.c index ac8163e3..3862a173 100755 --- a/kernel/src/los_event.c +++ b/kernel/src/los_event.c @@ -29,12 +29,8 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "los_event_pri.h" -#include "los_priqueue_pri.h" -#include "los_task_pri.h" -#include "los_hw.h" -#include "los_hwi.h" - +#include "los_task.h" +#include "los_interrupt.h" #ifdef __cplusplus #if __cplusplus extern "C" { @@ -56,6 +52,9 @@ LITE_OS_SEC_TEXT UINT32 LOS_EventPoll(UINT32 *eventID, UINT32 eventMask, UINT32 UINT32 ret = 0; UINTPTR intSave; + if (eventID == NULL) { + return LOS_ERRNO_EVENT_PTR_NULL; + } intSave = LOS_IntLock(); if (mode & LOS_WAITMODE_OR) { if ((*eventID & eventMask) != 0) { diff --git a/kernel/src/los_event_pri.h b/kernel/src/los_event_pri.h deleted file mode 100755 index 7a437a10..00000000 --- a/kernel/src/los_event_pri.h +++ /dev/null @@ -1,52 +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. - */ - -#ifndef _LOS_EVENT_PRI_H -#define _LOS_EVENT_PRI_H - -#include "los_event.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -extern UINT32 OsEventReadOnce(PEVENT_CB_S eventCB, UINT32 eventMask, UINT32 mode, UINT32 timeOut); -extern UINT32 OsEventWriteOnce(PEVENT_CB_S eventCB, UINT32 events); - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_EVENT_PRI_H */ diff --git a/kernel/src/los_heap_pri.h b/kernel/src/los_heap_pri.h deleted file mode 100755 index c4c39614..00000000 --- a/kernel/src/los_heap_pri.h +++ /dev/null @@ -1,159 +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. - */ - -/** - * @defgroup los_heap Heap - * @ingroup kernel - */ - -#ifndef _LOS_HEAP_PRI_H -#define _LOS_HEAP_PRI_H - -#include "los_heap.h" -#include "los_slab_pri.h" -#include "los_memstat_pri.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct tagLosHeapStatus { - UINT32 totalSize; - UINT32 usedSize; - UINT32 freeSize; - UINT32 allocCount; - UINT32 freeCount; -} LosHeapStatus; - -struct LosHeapManager { - struct LOS_HEAP_NODE *head; - struct LOS_HEAP_NODE *tail; - UINT32 size; -#if (LOSCFG_MEM_MUL_POOL == YES) - VOID *nextPool; -#endif -#if (LOSCFG_KERNEL_MEM_SLAB == YES) - struct LosSlabControlHeader slabCtrlHdr; -#endif -#if (LOSCFG_KERNEL_MEM_STATISTICS == YES) - TaskMemUsedInfo memStats[LOSCFG_BASE_CORE_TSK_LIMIT + 2]; -#endif -}; - -/** - * @ingroup los_heap - * @brief Look up the next memory node according to one memory node in the memory block list. - * - * @par Description: - * This API is used to look up the next memory node according to one memory node in the memory block list. - * @attention - *
    - *
  • None.
  • - *
- * @param heapMan [IN] Type #LosHeapManager * Pointer to the manager,to distinguish heap. - * @param node [IN] Type #LOS_HEAP_NODE * Size of memory in bytes to allocate. - * - * @retval LOS_HEAP_NODE * Pointer to next memory node. - * - * @par Dependency: - *
  • los_heap_pri.h: the header file that contains the API declaration.
- * @see None. - */ -extern struct LOS_HEAP_NODE* OsHeapPrvGetNext(struct LosHeapManager *heapMan, struct LOS_HEAP_NODE* node); - -/** - * @ingroup los_heap - * @brief Obtain the heap information. - * - * @par Description: - * This API is used to obtain the heap information. - * @attention - *
    - *
  • None.
  • - *
- * @param pool [IN] Type #VOID * A pointer pointed to the heap memory pool. - * - * @retval None. - * - * @par Dependency: - *
  • los_heap_pri.h: the header file that contains the API declaration.
- * @see None. - */ -extern VOID OsAlarmHeapInfo(VOID *pool); - -/** - * @ingroup los_heap - * @brief Obtain the heap status. - * - * @par Description: - * This API is used to obtain the heap status. - * @attention - *
    - *
  • None.
  • - *
- * @param pool [IN] Type #VOID * A pointer pointed to the heap memory pool. - * @param status [OUT] Type #LosHeapStatus * Heap status. - * - * @retval UINT32 Get status result. - * - * @par Dependency: - *
  • los_heap_pri.h: the header file that contains the API declaration.
- * @see None. - */ -extern UINT32 OsHeapStatisticsGet(VOID *pool, LosHeapStatus *status); - -/** - * @ingroup los_heap - * @brief Get the max free block size. - * - * @par Description: - * This API is used to Get the max free block size. - * @attention - *
    - *
  • None.
  • - *
- * @param pool [IN] Type #VOID * A pointer pointed to the heap memory pool. - * - * @retval UINT32 Max free block size. - * - * @par Dependency: - *
  • los_heap_pri.h: the header file that contains the API declaration.
- * @see None. - */ -extern UINT32 OsHeapGetMaxFreeBlkSize(VOID *pool); - -#ifdef __cplusplus -} -#endif - - -#endif - diff --git a/kernel/src/los_init.c b/kernel/src/los_init.c index 96532e1e..91e849f0 100755 --- a/kernel/src/los_init.c +++ b/kernel/src/los_init.c @@ -29,27 +29,23 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "los_sys.h" -#include "los_tick.h" -#include "los_task_pri.h" -#include "los_tick_pri.h" #include "los_config.h" -#if (LOSCFG_KERNEL_RUNSTOP == YES) -#include "los_sr.h" -#endif +#include "los_queue.h" +#include "los_memory.h" +#include "los_mux.h" #if (LOSCFG_PLATFORM_EXC == YES) -#include "los_exc_pri.h" +#include "los_interrupt.h" #endif #if (LOSCFG_KERNEL_TRACE == YES) -#include "los_trace.h" +#include "los_debug.h" #endif #if (LOSCFG_KERNEL_CPPSUPPORT == YES) #include "los_cppsupport.h" #endif -#include "los_printf.h" +#include "los_debug.h" #ifdef __cplusplus @@ -113,6 +109,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_Start(VOID) } extern UINT8 g_memStart[OS_SYS_MEM_SIZE]; + /***************************************************************************** Function : LOS_KernelInit Description : System kernel initialization function, configure all system modules @@ -122,8 +119,8 @@ extern UINT8 g_memStart[OS_SYS_MEM_SIZE]; *****************************************************************************/ LITE_OS_SEC_TEXT_INIT UINT32 LOS_KernelInit(VOID) { - printf("entering kernel init...\n"); UINT32 ret; + printf("entering kernel init...\n"); OsRegister(); m_aucSysMem0 = g_memStart; @@ -138,10 +135,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_KernelInit(VOID) OsHwiInit(); #endif -#if (LOSCFG_PLATFORM_EXC == YES) - OsExcInit(MAX_EXC_MEM_SIZE); -#endif - ret = OsTaskInit(); if (ret != LOS_OK) { PRINT_ERR("OsTaskInit error\n"); diff --git a/kernel/src/los_membox_pri.h b/kernel/src/los_membox_pri.h deleted file mode 100755 index f89d2f7c..00000000 --- a/kernel/src/los_membox_pri.h +++ /dev/null @@ -1,65 +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. - */ - -#ifndef _LOS_MEMBOX_PRI_H -#define _LOS_MEMBOX_PRI_H - -#include "los_membox.h" - -#define OS_MEMBOX_NEXT(addr, blkSize) (LOS_MEMBOX_NODE *)((UINT8 *)(addr) + (blkSize)) - -#ifdef LOS_MEMBOX_CHECK -#define OS_MEMBOX_MAGIC 0xa55a5aa5 -#define OS_MEMBOX_SET_MAGIC(addr) (*((UINT32 *)(addr)) = OS_MEMBOX_MAGIC) -#define OS_MEMBOX_CHECK_MAGIC(addr) ((*((UINT32 *)(addr)) == OS_MEMBOX_MAGIC) ? LOS_OK : LOS_NOK) -#else -#define OS_MEMBOX_SET_MAGIC(addr) -#define OS_MEMBOX_CHECK_MAGIC(addr) LOS_OK -#endif - -#define OS_MEMBOX_USER_ADDR(addr) ((VOID *)((UINT8 *)(addr) + LOS_MEMBOX_MAGIC_SIZE)) -#define OS_MEMBOX_NODE_ADDR(addr) ((LOS_MEMBOX_NODE *)((UINT8 *)(addr) - LOS_MEMBOX_MAGIC_SIZE)) - - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_MEMBOX_PRI_H */ diff --git a/kernel/src/los_memcheck_pri.h b/kernel/src/los_memcheck_pri.h deleted file mode 100755 index 48e304a1..00000000 --- a/kernel/src/los_memcheck_pri.h +++ /dev/null @@ -1,75 +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. - */ - -#ifndef _LOS_MEMCHECK_PRI_H -#define _LOS_MEMCHECK_PRI_H - -#include "los_memcheck.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cpluscplus */ -#endif /* __cpluscplus */ - -/** - * @ingroup los_memboxcheck - * @brief Update the information of the memory. - * - * @par Description: - *
    - *
  • This API is used to update the information of the memory.
  • - *
- * @attention - *
    - *
  • None.
  • - *
- * - * @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); - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cpluscplus */ -#endif /* __cpluscplus */ - -#endif /* _LOS_MEMCHECK_PRI_H */ diff --git a/kernel/src/los_memory_pri.h b/kernel/src/los_memory_pri.h deleted file mode 100755 index 3e6f1c65..00000000 --- a/kernel/src/los_memory_pri.h +++ /dev/null @@ -1,179 +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. - */ - -#ifndef _LOS_MEMORY_PRI_H -#define _LOS_MEMORY_PRI_H - -#include "los_memory.h" - - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#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 - *
    - *
  • None.
  • - *
- * - * @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) - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_MEMORY_PRI_H */ diff --git a/kernel/src/los_memstat_pri.h b/kernel/src/los_memstat_pri.h deleted file mode 100755 index a3628b62..00000000 --- a/kernel/src/los_memstat_pri.h +++ /dev/null @@ -1,82 +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. - */ - -#ifndef _LOS_MEMSTAT_PRI_H -#define _LOS_MEMSTAT_PRI_H - -#include "los_typedef.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#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 -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_MEMSTAT_PRI_H */ diff --git a/kernel/src/los_multipledlinkhead_pri.h b/kernel/src/los_multipledlinkhead_pri.h deleted file mode 100755 index dbf46499..00000000 --- a/kernel/src/los_multipledlinkhead_pri.h +++ /dev/null @@ -1,79 +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. - */ - -#ifndef _LOS_MULTIPLE_DLINK_HEAD_PRI_H -#define _LOS_MULTIPLE_DLINK_HEAD_PRI_H - -#include "los_list.h" - - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#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); - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_MULTIPLE_DLINK_HEAD_PRI_H */ diff --git a/kernel/src/los_mux.c b/kernel/src/los_mux.c index 37424b1b..71839860 100755 --- a/kernel/src/los_mux.c +++ b/kernel/src/los_mux.c @@ -28,16 +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_pri.h" -#include "los_err_pri.h" -#include "los_memory_pri.h" -#include "los_priqueue_pri.h" -#include "los_task_pri.h" -#if (LOSCFG_PLATFORM_EXC == YES) -#include "los_exc.h" -#endif -#include "los_hw.h" +#include "los_mux.h" +#include "los_interrupt.h" +#include "los_memory.h" +#include "los_debug.h" #ifdef __cplusplus #if __cplusplus diff --git a/kernel/src/los_mux_pri.h b/kernel/src/los_mux_pri.h deleted file mode 100755 index 99c1f5a5..00000000 --- a/kernel/src/los_mux_pri.h +++ /dev/null @@ -1,110 +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. - */ - -#ifndef _LOS_MUX_PRI_H -#define _LOS_MUX_PRI_H - -#include "los_task_pri.h" - -#include "los_mux.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -/** - * @ingroup los_mux - * Mutex object. - */ -typedef struct { - UINT8 muxStat; /**< State OS_MUX_UNUSED,OS_MUX_USED */ - UINT16 muxCount; /**< Times of locking a mutex */ - UINT32 muxID; /**< Handle ID */ - LOS_DL_LIST muxList; /**< Mutex linked list */ - LosTaskCB *owner; /**< The current thread that is locking a mutex */ - UINT16 priority; /**< Priority of the thread that is locking a mutex */ -} LosMuxCB; - -/** - * @ingroup los_mux - * Mutex state: not in use. - */ -#define OS_MUX_UNUSED 0 - -/** - * @ingroup los_mux - * Mutex state: in use. - */ -#define OS_MUX_USED 1 - -extern LosMuxCB *g_allMux; - -/** - * @ingroup los_mux - * Obtain the pointer to a mutex object of the mutex that has a specified handle. - */ -#define GET_MUX(muxid) (((LosMuxCB *)g_allMux) + (muxid)) - -/** - * @ingroup los_mux - * @brief Initializes the mutex. - * - * @par Description: - * This API is used to initializes the mutex. - * @attention - *
    - *
  • None.
  • - *
- * - * @param None. - * - * @retval UINT32 Initialization result. - * @par Dependency: - *
  • los_mux_pri.h: the header file that contains the API declaration.
- * @see LOS_MuxDelete - */ -extern UINT32 OsMuxInit(VOID); - -/** - * @ingroup los_mux - * Obtain the pointer to the linked list in the mutex pointed to by a specified pointer. - */ -#define GET_MUX_LIST(ptr) LOS_DL_LIST_ENTRY(ptr, LosMuxCB, muxList) - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_MUX_PRI_H */ diff --git a/kernel/src/los_priqueue.c b/kernel/src/los_priqueue.c deleted file mode 100755 index 24b4b155..00000000 --- a/kernel/src/los_priqueue.c +++ /dev/null @@ -1,113 +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_priqueue_pri.h" -#include "los_base_pri.h" -#include "los_task_pri.h" -#include "los_memory.h" -#include "los_compiler.h" - -LITE_OS_SEC_BSS LOS_DL_LIST *g_losPriorityQueueList = NULL; -static LITE_OS_SEC_BSS UINT32 g_priqueueBitmap = 0; - -#define PRIQUEUE_PRIOR0_BIT (UINT32)0x80000000 - -UINT32 OsPriqueueInit(VOID) -{ - UINT32 priority; - UINT32 size = OS_PRIORITY_QUEUE_PRIORITYNUM * sizeof(LOS_DL_LIST); - - g_losPriorityQueueList = (LOS_DL_LIST *)LOS_MemAlloc(m_aucSysMem0, size); - if (g_losPriorityQueueList == NULL) { - return LOS_NOK; - } - - for (priority = 0; priority < OS_PRIORITY_QUEUE_PRIORITYNUM; ++priority) { - LOS_ListInit(&g_losPriorityQueueList[priority]); - } - return LOS_OK; -} - -VOID OsPriqueueEnqueue(LOS_DL_LIST *priqueueItem, UINT32 priority) -{ - if (LOS_ListEmpty(&g_losPriorityQueueList[priority])) { - g_priqueueBitmap |= (PRIQUEUE_PRIOR0_BIT >> priority); - } - - LOS_ListTailInsert(&g_losPriorityQueueList[priority], priqueueItem); -} - -VOID OsPriqueueDequeue(LOS_DL_LIST *priqueueItem) -{ - LosTaskCB *runningTask = NULL; - LOS_ListDelete(priqueueItem); - - runningTask = LOS_DL_LIST_ENTRY(priqueueItem, LosTaskCB, pendList); - if (LOS_ListEmpty(&g_losPriorityQueueList[runningTask->priority])) { - g_priqueueBitmap &= ~(PRIQUEUE_PRIOR0_BIT >> runningTask->priority); - } -} - -LOS_DL_LIST *OsPriqueueTop(VOID) -{ - UINT32 priority; - - if (g_priqueueBitmap != 0) { - priority = CLZ(g_priqueueBitmap); - return LOS_DL_LIST_FIRST(&g_losPriorityQueueList[priority]); - } - - return (LOS_DL_LIST *)NULL; -} - -UINT32 OsPriqueueSize(UINT32 priority) -{ - UINT32 itemCnt = 0; - LOS_DL_LIST *curPQNode = (LOS_DL_LIST *)NULL; - - LOS_DL_LIST_FOR_EACH(curPQNode, &g_losPriorityQueueList[priority]) { - ++itemCnt; - } - - return itemCnt; -} - -UINT32 OsPriqueueTotalSize(VOID) -{ - UINT32 priority; - UINT32 totalSize = 0; - - for (priority = 0; priority < OS_PRIORITY_QUEUE_PRIORITYNUM; ++priority) { - totalSize += OsPriqueueSize(priority); - } - - return totalSize; -} diff --git a/kernel/src/los_priqueue_pri.h b/kernel/src/los_priqueue_pri.h deleted file mode 100755 index 9a7c59af..00000000 --- a/kernel/src/los_priqueue_pri.h +++ /dev/null @@ -1,171 +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. - */ - -#ifndef _LOS_PRIQUEUE_PRI_H -#define _LOS_PRIQUEUE_PRI_H - -#include "los_list.h" -#include "los_typedef.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#define OS_PRIORITY_QUEUE_PRIORITYNUM 32 - -/** - * @ingroup los_priqueue - * @brief Initialize the priority queue. - * - * @par Description: - * This API is used to initialize the priority queue. - * @attention - *
    - *
  • None.
  • - *
- * @param none. - * - * @retval LOS_OK on success . - * @retval LOS_NOK on failure. - * @par Dependency: - *
  • los_priqueue_pri.h: the header file that contains the API declaration.
- * @see none. - */ -extern UINT32 OsPriqueueInit(VOID); - -/** - * @ingroup los_priqueue - * @brief Insert a item to the priority queue. - * - * @par Description: - * This API is used to insert a item to the priority queue according to the priority of this item. - * @attention - *
    - *
  • Param priqueueItem must point to valid memory.
  • - *
  • Param priority rang is [0, OS_PRIORITY_QUEUE_PRIORITYNUM),included 0 and not included - LOS_PRIORITY_QUEUE_PRIORITYNUM.
  • - *
- * @param priqueueItem [IN] The node of item to be inserted. - * @param priority [IN] Priority of the item be inserted. - * - * @retval none. - * @par Dependency: - *
  • los_priqueue_pri.h: the header file that contains the API declaration.
- * @see OsPriqueueDequeue. - */ -extern VOID OsPriqueueEnqueue(LOS_DL_LIST *priqueueItem, UINT32 priority); - -/** - * @ingroup los_priqueue - * @brief Delete a item from the priority queue. - * - * @par Description: - * This API is used to delete a item from the priority queue. - * @attention - *
    - *
  • Param priqueueItem must point to valid memory.
  • - *
- * @param priqueueItem [IN] The node of item to be deleted. - * - * @retval none. - * @par Dependency: - *
  • los_priqueue_pri.h: the header file that contains the API declaration.
- * @see OsPriqueueEnqueue. - */ -extern VOID OsPriqueueDequeue(LOS_DL_LIST *priqueueItem); - -/** - * @ingroup los_priqueue - * @brief Obtain the item with highest priority. - * - * @par Description: - * This API is used to obtain the item with highest priority in the priority queue. - * @attention - *
    - *
  • None.
  • - *
- * @param none. - * - * @retval NULL : The priority queue is empty. - * @retval item node : The node of the item with highest priority. - * @par Dependency: - *
  • los_priqueue_pri.h: the header file that contains the API declaration.
- * @see none. - */ -extern LOS_DL_LIST *OsPriqueueTop(VOID); - -/** - * @ingroup los_priqueue - * @brief Obtain the number of items with the specified priority. - * - * @par Description: - * This API is used to obtain the number of items with the specified priority. - * @attention - *
    - *
  • Param priority rang is [0, OS_PRIORITY_QUEUE_PRIORITYNUM),included 0 and not included - LOS_PRIORITY_QUEUE_PRIORITYNUM.
  • - *
- * @param priority [IN] Obtain the number of items with the specified priority of priority. - * - * @retval The number of items :The number of items with the specified priority. - * @par Dependency: - *
  • los_priqueue_pri.h: the header file that contains the API declaration.
- * @see none. - */ -extern UINT32 OsPriqueueSize(UINT32 priority); - -/** - * @ingroup los_priqueue - * @brief Obtain the total number of items in the priority queue. - * - * @par Description: - * This API is used to obtain the number of items in the priority queue. - * @attention - *
    - *
  • None.
  • - *
- * - * @retval The number of items: The total number of items in the priority queue. - * @par Dependency: - *
  • los_priqueue_pri.h: the header file that contains the API declaration.
- * @see none. - */ -extern UINT32 OsPriqueueTotalSize(VOID); - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_PRIQUEUE_PRI_H */ diff --git a/kernel/src/los_queue.c b/kernel/src/los_queue.c index dcaf8e98..e78edaf1 100755 --- a/kernel/src/los_queue.c +++ b/kernel/src/los_queue.c @@ -28,18 +28,15 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#include "string.h" +#include "los_interrupt.h" #include "securec.h" -#include "los_queue_pri.h" -#include "los_membox_pri.h" -#include "los_memory_pri.h" -#include "los_priqueue_pri.h" -#include "los_task_pri.h" +#include "los_queue.h" +#include "los_membox.h" +#include "los_task.h" #if (LOSCFG_PLATFORM_EXC == YES) -#include "los_exc_pri.h" +#include "los_interrupt.h" #endif -#include "los_printf.h" +#include "los_debug.h" #ifdef __cplusplus diff --git a/kernel/src/los_queue_pri.h b/kernel/src/los_queue_pri.h deleted file mode 100755 index 8ad5a145..00000000 --- a/kernel/src/los_queue_pri.h +++ /dev/null @@ -1,234 +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. - */ - -#ifndef _LOS_QUEUE_PRI_H -#define _LOS_QUEUE_PRI_H - -#include "los_queue.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -typedef enum { - OS_QUEUE_READ, - OS_QUEUE_WRITE -} QueueReadWrite; - -typedef enum { - OS_QUEUE_HEAD, - OS_QUEUE_TAIL -} QueueHeadTail; - -typedef enum { - OS_QUEUE_NOT_POINT, - OS_QUEUE_POINT -} QueuePointOrNot; - -#define OS_QUEUE_OPERATE_TYPE(ReadOrWrite, HeadOrTail, PointOrNot) \ - (((UINT32)(PointOrNot) << 2) | ((UINT32)(HeadOrTail) << 1) | (ReadOrWrite)) -#define OS_QUEUE_READ_WRITE_GET(type) ((type) & (0x01)) -#define OS_QUEUE_READ_HEAD (OS_QUEUE_READ | (OS_QUEUE_HEAD << 1)) -#define OS_QUEUE_READ_TAIL (OS_QUEUE_READ | (OS_QUEUE_TAIL << 1)) -#define OS_QUEUE_WRITE_HEAD (OS_QUEUE_WRITE | (OS_QUEUE_HEAD << 1)) -#define OS_QUEUE_WRITE_TAIL (OS_QUEUE_WRITE | (OS_QUEUE_TAIL << 1)) -#define OS_QUEUE_OPERATE_GET(type) ((type) & (0x03)) -#define OS_QUEUE_IS_POINT(type) ((type) & (0x04)) -#define OS_QUEUE_IS_READ(type) (OS_QUEUE_READ_WRITE_GET(type) == OS_QUEUE_READ) -#define OS_QUEUE_IS_WRITE(type) (OS_QUEUE_READ_WRITE_GET(type) == OS_QUEUE_WRITE) -#define OS_READWRITE_LEN 2 - -/** - * @ingroup los_queue - * Queue information block structure - */ -typedef struct { - UINT8 *queue; /**< Pointer to a queue handle */ - UINT16 queueState; /**< Queue state */ - UINT16 queueLen; /**< Queue length */ - UINT16 queueSize; /**< Node size */ - UINT16 queueID; /**< queueID */ - UINT16 queueHead; /**< Node head */ - UINT16 queueTail; /**< Node tail */ - UINT16 readWriteableCnt[OS_READWRITE_LEN]; /**< Count of readable or writable resources, 0:readable, 1:writable */ - LOS_DL_LIST readWriteList[OS_READWRITE_LEN]; /**< Pointer to the linked list to be read or written, - 0:readlist, 1:writelist */ - LOS_DL_LIST memList; /**< Pointer to the memory linked list */ -} LosQueueCB; - -/* queue state */ -/** - * @ingroup los_queue - * Message queue state: not in use. - */ -#define OS_QUEUE_UNUSED 0 - -/** - * @ingroup los_queue - * Message queue state: used. - */ -#define OS_QUEUE_INUSED 1 - -/** - * @ingroup los_queue - * Not in use. - */ -#define OS_QUEUE_WAIT_FOR_POOL 1 - -/** - * @ingroup los_queue - * Normal message queue. - */ -#define OS_QUEUE_NORMAL 0 - -/** - * @ingroup los_queue - * Queue information control block - */ -extern LosQueueCB *g_allQueue; - -/** - * @ingroup los_queue - * Obtain a handle of the queue that has a specified ID. - */ -#define GET_QUEUE_HANDLE(QueueID) (((LosQueueCB *)g_allQueue) + (QueueID)) - -/** - * @ingroup los_queue - * Obtain the head node in a queue doubly linked list. - */ -#define GET_QUEUE_LIST(ptr) LOS_DL_LIST_ENTRY(ptr, LosQueueCB, readWriteList[OS_QUEUE_WRITE]) - -/** - * @ingroup los_queue - * @brief Alloc a stationary memory for a mail. - * - * @par Description: - * This API is used to alloc a stationary memory for a mail according to queueID. - * @attention - *
    - *
  • Do not alloc memory in unblocking modes such as interrupt.
  • - *
  • This API cannot be called before the Huawei LiteOS is initialized.
  • - *
  • The argument timeOut is a relative time.
  • - *
- * - * @param queueID [IN] Queue ID. The value range is [1,LOSCFG_BASE_IPC_QUEUE_LIMIT]. - * @param mailPool [IN] The memory poll that stores the mail. - * @param timeOut [IN] Expiry time. The value range is [0,LOS_WAIT_FOREVER]. - * - * @retval #NULL The memory allocation is failed. - * @retval #mem The address of alloc memory. - * @par Dependency: - *
  • los_queue_pri.h: the header file that contains the API declaration.
- * @see OsQueueMailFree - */ -extern VOID *OsQueueMailAlloc(UINT32 queueID, VOID *mailPool, UINT32 timeOut); - -/** - * @ingroup los_queue - * @brief Free a stationary memory of a mail. - * - * @par Description: - * This API is used to free a stationary memory for a mail according to queueID. - * @attention - *
    - *
  • This API cannot be called before the Huawei LiteOS is initialized.
  • - *
- * - * @param queueID [IN] Queue ID. The value range is [1,LOSCFG_BASE_IPC_QUEUE_LIMIT]. - * @param mailPool [IN] The mail memory poll address. - * @param mailMem [IN] The mail memory block address. - * - * @retval #LOS_OK 0x00000000: The memory free successfully. - * @retval #OS_ERRNO_QUEUE_MAIL_HANDLE_INVALID 0x02000619: The handle of the queue passed-in when the memory for - the queue is being freed is invalid. - * @retval #OS_ERRNO_QUEUE_MAIL_PTR_INVALID 0x0200061a: The pointer to the memory to be freed is null. - * @retval #OS_ERRNO_QUEUE_MAIL_FREE_ERROR 0x0200061b: The memory for the queue fails to be freed. - * @par Dependency: - *
  • los_queue_pri.h: the header file that contains the API declaration.
- * @see OsQueueMailAlloc - */ -extern UINT32 OsQueueMailFree(UINT32 queueID, VOID *mailPool, VOID *mailMem); - -/** - * @ingroup los_queue - * @brief Initialization queue. - * - * @par Description: - * This API is used to initialization queue. - * @attention - *
    - *
  • None.
  • - *
- * - * @param None. - * - * @retval UINT32 Initialization result. - * @par Dependency: - *
  • los_queue_pri.h: the header file that contains the API declaration.
- * @see None. - */ -extern UINT32 OsQueueInit(VOID); - -/** - * @ingroup los_queue - * @brief Handle when read or write queue. - * - * @par Description: - * This API is used to handle when read or write queue. - * @attention - *
    - *
  • None.
  • - *
- * - * @param queueID [IN] Queue id. - * @param operateType [IN] Operate type - * @param bufferAddr [IN] Buffer address. - * @param bufferSize [IN] Buffer size. - * @param timeOut [IN] Timeout. - * - * @retval UINT32 Handle result. - * @par Dependency: - *
  • los_queue_pri.h: the header file that contains the API declaration.
- * @see None. - */ -extern UINT32 OsQueueOperate(UINT32 queueID, UINT32 operateType, VOID *bufferAddr, UINT32 *bufferSize, - UINT32 timeOut); - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_QUEUE_PRI_H */ diff --git a/kernel/src/los_sem.c b/kernel/src/los_sem.c index 18e96811..653d0108 100755 --- a/kernel/src/los_sem.c +++ b/kernel/src/los_sem.c @@ -28,17 +28,12 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#include "los_sem_pri.h" -#include "los_base_pri.h" -#include "los_err_pri.h" -#include "los_memory_pri.h" -#include "los_priqueue_pri.h" -#include "los_sys_pri.h" -#include "los_task_pri.h" +#include "los_sem.h" +#include "los_memory.h" #if (LOSCFG_PLATFORM_EXC == YES) -#include "los_exc.h" +#include "los_interrupt.h" #endif +#include "los_debug.h" #ifdef __cplusplus #if __cplusplus diff --git a/kernel/src/los_sem_pri.h b/kernel/src/los_sem_pri.h deleted file mode 100755 index a17e14ba..00000000 --- a/kernel/src/los_sem_pri.h +++ /dev/null @@ -1,134 +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. - */ - -#ifndef _LOS_SEM_PRI_H -#define _LOS_SEM_PRI_H - -#include "los_sem.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -enum LosSemMaxCount { - OS_SEM_COUNTING_MAX_COUNT = 0xFFFF, /**< Max count of counting semaphores */ - OS_SEM_BINARY_MAX_COUNT = 1 /**< Max count of binary semaphores */ -}; - -/** - * @ingroup los_sem - * Semaphore control structure. - */ -typedef struct { - UINT16 semStat; /**< Semaphore state */ - UINT16 semCount; /**< Number of available semaphores */ - UINT16 maxSemCount; /**< Max number of available semaphores */ - UINT16 semID; /**< Semaphore control structure ID */ - LOS_DL_LIST semList; /**< Queue of tasks that are waiting on a semaphore */ -} LosSemCB; - -/** - * @ingroup los_sem - * The semaphore is not in use. - * - */ -#define OS_SEM_UNUSED 0 -/** - * @ingroup los_sem - * The semaphore is used. - * - */ -#define OS_SEM_USED 1 -/** - * @ingroup los_sem - * Obtain the head node in a semaphore doubly linked list. - * - */ -#define GET_SEM_LIST(ptr) LOS_DL_LIST_ENTRY(ptr, LosSemCB, semList) -extern LosSemCB *g_allSem; -/** - * @ingroup los_sem - * Obtain a semaphore ID. - * - */ -#define GET_SEM(semid) (((LosSemCB *)g_allSem) + (semid)) - -/** - * @ingroup los_sem - * @brief Initialize the Semaphore doubly linked list. - * - * @par Description: - * This API is used to initialize the Semaphore doubly linked list. - * @attention - *
    - *
  • None.
  • - *
- * - * @param None. - * - * @retval UINT32 Initialization result. - * @par Dependency: - *
  • los_sem_pri.h: the header file that contains the API declaration.
- * @see None. - */ -extern UINT32 OsSemInit(VOID); - -/** - * @ingroup los_sem - * @brief Create Semaphore. - * - * @par Description: - * This API is used to create Semaphore. - * @attention - *
    - *
  • None.
  • - *
- * - * @param count [IN]Type #UINT16 Semaphore count. - * @param maxCount [IN]Type #UINT16 Max semaphore count. - * @param semHandle [OUT]Type #UINT32 * Index of semaphore. - * - * @retval UINT32 Create result. - * @par Dependency: - *
  • los_sem_pri.h: the header file that contains the API declaration.
- * @see None. - */ -UINT32 OsSemCreate(UINT16 count, UINT16 maxCount, UINT32 *semHandle); - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_SEM_PRI_H */ diff --git a/kernel/src/los_slab_pri.h b/kernel/src/los_slab_pri.h deleted file mode 100755 index 4cef0bad..00000000 --- a/kernel/src/los_slab_pri.h +++ /dev/null @@ -1,687 +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. - */ - -/** - * @defgroup los_slab Slab - * @ingroup kernel - */ - -#ifndef _LOS_SLAB_PRI_H -#define _LOS_SLAB_PRI_H - -#include "los_base.h" -#include "los_slab.h" -#include - -typedef struct tagLosSlabStatus { - UINT32 totalSize; - UINT32 usedSize; - UINT32 freeSize; - UINT32 allocCount; - UINT32 freeCount; -} LosSlabStatus; - -typedef struct tagOsSlabBlockNode { - UINT16 magic; - UINT8 blkSz; - UINT8 recordId; -} OsSlabBlockNode; - -struct AtomicBitset { - UINT32 numBits; - UINT32 words[0]; -}; - -typedef struct tagOsSlabAllocator { - UINT32 itemSz; - UINT8 *dataChunks; - struct AtomicBitset *bitset; -} OsSlabAllocator; - -typedef struct tagOsSlabMem { - UINT32 blkSz; - UINT32 blkCnt; - UINT32 blkUsedCnt; - OsSlabAllocator *alloc; -} OsSlabMem; - -struct LosSlabControlHeader { - OsSlabMem slabClass[SLAB_MEM_COUNT]; -}; - -#define OS_SLAB_MAGIC 0xdede -#define OS_SLAB_BLOCK_HEAD_GET(ptr) ((OsSlabBlockNode *)(VOID *)((UINT8 *)(ptr) - \ - sizeof(OsSlabBlockNode))) -#define OS_SLAB_BLOCK_MAGIC_SET(slabNode) (((OsSlabBlockNode *)(slabNode))->magic = (UINT16)OS_SLAB_MAGIC) -#define OS_SLAB_BLOCK_MAGIC_GET(slabNode) (((OsSlabBlockNode *)(slabNode))->magic) -#define OS_SLAB_BLOCK_SIZE_SET(slabNode, size) (((OsSlabBlockNode *)(slabNode))->blkSz = (size)) -#define OS_SLAB_BLOCK_SIZE_GET(slabNode) (((OsSlabBlockNode *)(slabNode))->blkSz) -#define OS_SLAB_BLOCK_ID_SET(slabNode, id) (((OsSlabBlockNode *)(slabNode))->recordId = (id)) -#define OS_SLAB_BLOCK_ID_GET(slabNode) (((OsSlabBlockNode *)(slabNode))->recordId) -#define OS_ALLOC_FROM_SLAB_CHECK(slabNode) (((OsSlabBlockNode *)(slabNode))->magic == (UINT16)OS_SLAB_MAGIC) - -#define ATOMIC_BITSET_SZ(numbits) (sizeof(struct AtomicBitset) + ((numbits) + 31) / 8) - -/** - * @ingroup los_slab - * @brief Initialization atomic bitset. - * - * @par Description: - * This API is used to initialization atomic bitset. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param set [IN/OUT] Type #AtomicBitset * Atomic bitset. - * @param numBits [IN] Type #UINT32 Bits number. - * - * @retval None. - * @par Dependency: - *
  • los_slab_pri.h: the header file that contains the API declaration.
- * @see OsSlabAllocatorDestroy - */ -VOID OsAtomicBitsetInit(struct AtomicBitset *set, UINT32 numBits); - -/** - * @ingroup los_slab - * @brief Get atomic bitset number. - * - * @par Description: - * This API is used to get atomic bitset number. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param set [IN] Type #AtomicBitset * Atomic bitset. - * - * @retval UINT32 Atomic bitset number. - * @par Dependency: - *
  • los_slab_pri.h: the header file that contains the API declaration.
- * @see OsSlabAllocatorDestroy - */ -UINT32 OsAtomicBitsetGetNumBits(const struct AtomicBitset *set); - -/** - * @ingroup los_slab - * @brief Get atomic bitset bit. - * - * @par Description: - * This API is used to get atomic bitset bit. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param set [IN] Type #AtomicBitset * Atomic bitset. - * @param num [IN] Type #UINT32 Bit number. - * - * @retval BOOL success or failed - * @par Dependency: - *
  • los_slab_pri.h: the header file that contains the API declaration.
- * @see OsSlabAllocatorDestroy - */ -BOOL OsAtomicBitsetGetBit(const struct AtomicBitset *set, UINT32 num); - -/** - * @ingroup los_slab - * @brief Clear the atomic bitset bit. - * - * @par Description: - * This API is used to clear the atomic bitset bit. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param set [IN] Type #AtomicBitset * Atomic bitset. - * @param num [IN] Type #UINT32 Bit number. - * - * @retval None. - * @par Dependency: - *
  • los_slab_pri.h: the header file that contains the API declaration.
- * @see OsSlabAllocatorDestroy - */ -VOID OsAtomicBitsetClearBit(struct AtomicBitset *set, UINT32 num); - -/** - * @ingroup los_slab - * @brief Clear and set the atomic bitset bit. - * - * @par Description: - * This API is used to clear and set the atomic bitset bit. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param set [IN] Type #AtomicBitset * Atomic bitset. - * - * @retval INT32 The address of the first available bit. - * @par Dependency: - *
  • los_slab_pri.h: the header file that contains the API declaration.
- * @see OsSlabAllocatorDestroy - */ -INT32 OsAtomicBitsetFindClearAndSet(struct AtomicBitset *set); - -/** - * @ingroup los_slab - * @brief Change the order of the output idx of OsAtomicBitsetFindClearAndSet to order of natural numbers. - * - * @par Description: - * This API is used to change the order of the output idx of OsAtomicBitsetFindClearAndSet to order of natural numbers. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param bitset [IN] Type #AtomicBitset * Atomic bitset. - * @param index [IN] Type #INT32 index. - * - * @retval INT32 Index to natural numbers. - * @par Dependency: - *
  • los_slab_pri.h: the header file that contains the API declaration.
- * @see OsSlabAllocatorDestroy - */ -INT32 OsAtomicBitsetIdxChgToNatural(struct AtomicBitset *bitset, INT32 index); - -/** - * @ingroup los_slab - * @brief Judgment the atomic bitset is empty. - * - * @par Description: - * This API is used to judgment the atomic bitset is empty. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param bitset [IN] Type #AtomicBitset * Atomic bitset. - * - * @retval BOOL Judgment result. - * @par Dependency: - *
  • los_slab_pri.h: the header file that contains the API declaration.
- * @see OsSlabAllocatorDestroy - */ -BOOL OsAtomicBitsetEmpty(struct AtomicBitset *bitset); - -// thread/interrupt safe. allocations will not fail if space exists. even in interrupts. -// itemAlign over 4 will not be guaranteed since the heap does not hand out chunks with that kind of alignment -/** - * @ingroup los_slab - * @brief create a new slab allocator. - * - * @par Description: - * This API is used to create a new slab allocator. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param pool [IN] Pointer to the memory pool that contains the memory block to be allocated. - * @param itemSz [IN] The size of one slab page. - * @param itemAlign [IN] Type alignment, 4 byte-aligned, 8 byte-aligned, etc. - * @param numItems [IN] The number of slab page. - * - * @retval #OS_SLAB_ALLOCATOR* The address of slab allocator. - * @par Dependency: - *
  • los_slab_pri.h: the header file that contains the API declaration.
- * @see OsSlabAllocatorDestroy - */ -OsSlabAllocator *OsSlabAllocatorNew(VOID *pool, UINT32 itemSz, UINT32 itemAlign, UINT32 numItems); - -/** - * @ingroup los_slab - * @brief Destroy a slab allocator. - * - * @par Description: - * This API is used to Destroy a slab allocator. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param pool [IN] Pointer to the memory pool that contains the memory block to be allocated. - * @param allocator [IN] a slab allocator. - * - * @retval #VOID - * @par Dependency: - *
  • los_slab_pri.h: the header file that contains the API declaration.
- * @see OsSlabAllocatorNew - */ -VOID OsSlabAllocatorDestroy(VOID *pool, OsSlabAllocator *allocator); - -/** - * @ingroup los_slab - * @brief Allocate a slab page form allocator. - * - * @par Description: - * This API is used to allocate a slab page form allocator. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param allocator [IN] a slab allocator. - * - * @retval #VOID* return a slab page. - * @par Dependency: - *
  • los_slab_pri.h: the header file that contains the API declaration.
- * @see OsSlabAllocatorFree - */ -VOID* OsSlabAllocatorAlloc(OsSlabAllocator *allocator); - -/** - * @ingroup los_slab - * @brief Free a slab page. - * - * @par Description: - * This API is used to free a slab page. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param allocator [IN] a slab allocator. - * @param ptr [IN] a slab page. - * - * @retval #FALSE Failed to free a slab page. - * @retval #TRUE Succees to free a slab page. - * @par Dependency: - *
  • los_slab_pri.h: the header file that contains the API declaration.
- * @see LOS_SlabAllocatorAlloc - */ -BOOL OsSlabAllocatorFree(OsSlabAllocator *allocator, VOID* ptr); - -/** - * @ingroup los_slab - * @brief Get a slab page index with judgment. - * - * @par Description: - * This API is used to get a slab page index with judgment. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param allocator [IN] a slab allocator. - * @param idx [IN] index - * - * @retval VOID * - * @par Dependency: - *
  • los_slab_pri.h: the header file that contains the API declaration.
- * @see None. - */ -/* -> pointer or NULL if that slot is empty may be not int-safe. YMMV */ -VOID* OsSlabAllocatorGetNth(OsSlabAllocator *allocator, UINT32 idx); - -/** - * @ingroup los_slab - * @brief Get a slab page index without judgment. - * - * @par Description: - * This API is used to get a slab page index without judgment. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param allocator [IN] a slab allocator. - * @param idx [IN] index - * - * @retval VOID * - * @par Dependency: - *
  • los_slab_pri.h: the header file that contains the API declaration.
- * @see None. - */ -VOID* OsSlabAllocatorGetIdxP(OsSlabAllocator *allocator, UINT32 idx); - -/** - * @ingroup los_slab - * @brief Get the index of slab page in slab allocator. - * - * @par Description: - * This API is used to get the index of slab page in slab allocator. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param allocator [IN] a slab allocator. - * @param ptr [IN] a slab page. - * - * @retval #-1 Illegal index . - * @retval #UINT32 Succees to get index. - * @par Dependency: - *
  • los_slab_pri.h: the header file that contains the API declaration.
- * @see - */ -UINT32 OsSlabAllocatorGetIndex(OsSlabAllocator *allocator, VOID *ptr); - -/** - * @ingroup los_slab - * @brief Get the number of slab page. - * - * @par Description: - * This API is used to get the number of slab page. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param allocator [IN] a slab allocator. - * - * @retval #UINT32 Succees to get the number of slab page. - * @par Dependency: - *
  • los_slab_pri.h: the header file that contains the API declaration.
- * @see - */ -UINT32 OsSlabAllocatorGetNumItems(OsSlabAllocator *allocator); - -/** - * @ingroup los_slab - * @brief Check the slab allocator. - * - * @par Description: - * This API is used to check the slab allocator. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param allocator [IN] a slab allocator. - * - * @retval #FALSE The slab allocator is already used. - * @retval #TRUE The slab allocator is not used. - * @par Dependency: - *
  • los_slab_pri.h: the header file that contains the API declaration.
- * @see - */ -BOOL OsSlabAllocatorEmpty(OsSlabAllocator *allocator); - -/** - * @ingroup los_slab - * @brief Get the used number of slab page in slab allocator. - * - * @par Description: - * This API is used to get the used number of slab page in slab allocator. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param allocator [IN] a slab allocator. - * - * @retval #UINT32 The used number of slab page in slab allocator. - * @par Dependency: - *
  • los_slab_pri.h: the header file that contains the API declaration.
- * @see - */ -UINT32 OsSlabAllocatorGetUsedItemCnt(OsSlabAllocator *allocator); - -/** - * @ingroup los_slab - * @brief Get the info of slab allocator. - * - * @par Description: - * This API is used to get the info of slab allocator. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param allocator [IN] a slab allocator. - * @param itemSize [OUT] a slab page size. - * @param itemCnt [OUT] a slab page num. - * @param curUsage [OUT] a used number of slab page. - * - * @retval #VOID - * @par Dependency: - *
  • los_slab_pri.h: the header file that contains the API declaration.
- * @see - */ -VOID OsSlabAllocatorGetSlabInfo(OsSlabAllocator *allocator, UINT32 *itemSize, UINT32 *itemCnt, UINT32 *curUsage); - -/** - * @ingroup los_slab - * @brief init slab allocator. - * - * @par Description: - * This API is used to init slab allocator. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param pool [IN] Pointer to the memory pool that contains the memory block to be allocated. - * - * @retval BOOL - * @par Dependency: - *
  • los_slab_pri.h: the header file that contains the API declaration.
- * @see - */ -extern BOOL OsSlabMemInit(VOID *pool); - -/** - * @ingroup los_slab - * @brief alloc mem by slab allocator. - * - * @par Description: - * This API is used to alloc mem by slab allocator. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param pool [IN] Pointer to the memory pool that contains the memory block to be allocated. - * @param sz [IN] Size of mem to alloc - * - * @retval VOID * The address of alloced mem or NULL. - * @par Dependency: - *
  • los_slab_pri.h: the header file that contains the API declaration.
- * @see - */ -extern VOID *OsSlabMemAlloc(VOID *pool, UINT32 sz); - -/** - * @ingroup los_slab - * @brief free mem by slab allocator. - * - * @par Description: - * This API is used to free mem by slab allocator. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param pool [IN] Pointer to the memory pool that contains the memory block to be allocated. - * @param ptr [IN] Pointer to the memory that to be free - * - * @retval BOOL success or failed - * @par Dependency: - *
  • los_slab_pri.h: the header file that contains the API declaration.
- * @see - */ -extern BOOL OsSlabMemFree(VOID *pool, VOID *ptr); - -/** - * @ingroup los_slab - * @brief deinit slab allocator. - * - * @par Description: - * This API is used to deinit slab allocator. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param pool [IN] Pointer to the memory pool that contains the memory block to be allocated. - * - * @retval VOID - * @par Dependency: - *
  • los_slab_pri.h: the header file that contains the API declaration.
- * @see - */ -extern VOID OsSlabMemDeinit(VOID *pool); - -/** - * @ingroup los_slab - * @brief Check slab allocator. - * - * @par Description: - * This API is used to check slab allocator. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param allocator [IN] a slab allocator. - * @param ptr [IN] Slab node. - * - * @retval VOID - * @par Dependency: - *
  • los_slab_pri.h: the header file that contains the API declaration.
- * @see None. - */ -extern BOOL OsSlabAllocatorCheck(OsSlabAllocator *allocator, VOID *ptr); - -/** - * @ingroup los_slab - * @brief Get SlabCtrlHdr. - * - * @par Description: - * This API is used to get SlabCtrlHdr. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param pool [IN] Pointer to the memory pool that contains the memory block to be allocated. - * - * @retval VOID - * @par Dependency: - *
  • los_slab_pri.h: the header file that contains the API declaration.
- * @see None. - */ -extern VOID *OsSlabCtrlHdrGet(const VOID *pool); - -/** - * @ingroup los_slab - * @brief Check the slab memory. - * - * @par Description: - * This API is used to check the slab memory. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param pool [IN] Pointer to the memory pool that contains the memory block to be allocated. - * @param ptr [IN] Slab block head. - * - * @retval UINT32 block size. - * @par Dependency: - *
  • los_slab_pri.h: the header file that contains the API declaration.
- * @see None. - */ -extern UINT32 OsSlabMemCheck(VOID *pool, VOID *ptr); - -/** - * @ingroup los_slab - * @brief Get the slab status. - * - * @par Description: - * This API is used to get the slab status. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param pool [IN] Pointer to the memory pool that contains the memory block to be allocated. - * @param status [IN/OUT] Slab block status. - * - * @retval UINT32 Get status result. - * @par Dependency: - *
  • los_slab_pri.h: the header file that contains the API declaration.
- * @see None. - */ -extern UINT32 OsSlabStatisticsGet(VOID *pool, LosSlabStatus *status); - -/** - * @ingroup los_slab - * @brief Get the max free block size. - * - * @par Description: - * This API is used to get the max free block size. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param pool [IN] Pointer to the memory pool that contains the memory block to be allocated. - * - * @retval UINT32 Max free block size. - * @par Dependency: - *
  • los_slab_pri.h: the header file that contains the API declaration.
- * @see None. - */ -extern UINT32 OsSlabGetMaxFreeBlkSize(VOID *pool); - -#endif - diff --git a/kernel/src/los_sr.h b/kernel/src/los_sr.h deleted file mode 100755 index 76ccbe11..00000000 --- a/kernel/src/los_sr.h +++ /dev/null @@ -1,87 +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. - */ - -#ifndef __LOS_SR_H__ -#define __LOS_SR_H__ - -#include "los_typedef.h" -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cpluscplus */ -#endif /* __cpluscplus */ - -#define SENSORHUB_COLDBOOT 0x1 -#define SENSORHUB_SLEEP 0x2 - - -#define OS_WAKEUP_INFO_COUNT 32 -typedef struct tagWakeupInfo -{ - UINT64 uwSleepTimeTotal; - UINT8 ucIdx; - UINT8 ucIsFull; - UINT8 auwPID[OS_WAKEUP_INFO_COUNT]; -}OS_WAKEUP_INFO; - - -extern unsigned int g_uwSrStateFlag; -extern unsigned int g_uwOneshotLoadValue; - -extern unsigned int osDelayTskSuspend(); -extern void osDelayTskResume(unsigned int sleep_time); - -extern unsigned int osSwTmrGetNextTimeout(void); -extern void osSwTmrAdjust(unsigned int sleep_time); - -extern void osTickLock(void); -extern void osTickUnlock(void); -extern int osSRSuspend(void); -extern void osSRResume(void); - -extern unsigned int getSleepTime(); -extern void DisableWakeUpTimer(void); -extern void enterSleepMode(unsigned int SleepTime); -extern void enterStopMode(unsigned int SleepTime); -extern void StopMode_Measure(unsigned int sleepTime, unsigned int WakeUpClock); - -extern void LOS_SrIdleTaskProcess(void); - -extern void LOS_SystemWakeup(unsigned int uwHwiIndex); -extern void osSRSaveRegister(); -extern void osSRRestoreRegister(); -extern int GetMCURunAndSleepTime(unsigned int *runningTime, unsigned int *sleepTime); -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cpluscplus */ -#endif /* __cpluscplus */ -#endif diff --git a/kernel/src/los_swtmr.c b/kernel/src/los_swtmr.c index fc53a333..f394a1a0 100755 --- a/kernel/src/los_swtmr.c +++ b/kernel/src/los_swtmr.c @@ -28,23 +28,13 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#include "string.h" #include "securec.h" -#include "los_swtmr_pri.h" -#include "los_base_pri.h" -#include "los_sys.h" -#include "los_membox_pri.h" -#include "los_memory_pri.h" -#include "los_queue_pri.h" -#include "los_task_pri.h" -#include "los_hwi.h" -#include "los_printf.h" -#if (LOSCFG_PLATFORM_EXC == YES) -#include "los_exc.h" -#endif - -#include "los_printf.h" +#include "los_interrupt.h" +#include "los_swtmr.h" +#include "los_task.h" +#include "los_memory.h" +#include "los_queue.h" +#include "los_debug.h" #ifdef __cplusplus #if __cplusplus @@ -344,7 +334,9 @@ LITE_OS_SEC_TEXT VOID OsSwtmrStop(const SWTMR_CTRL_S *swtmr) prev = cur; cur = cur->pstNext; } - + if (cur == NULL) { + return; + } if (cur->pstNext != NULL) { cur->pstNext->uwCount += cur->uwCount; } diff --git a/kernel/src/los_swtmr_pri.h b/kernel/src/los_swtmr_pri.h deleted file mode 100755 index a61dbcd3..00000000 --- a/kernel/src/los_swtmr_pri.h +++ /dev/null @@ -1,163 +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. - */ - -#ifndef _LOS_SWTMR_PRI_H -#define _LOS_SWTMR_PRI_H - -#include "los_swtmr.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - - -/** - * @ingroup los_swtmr - * Software timer state - */ -enum SwtmrState { - OS_SWTMR_STATUS_UNUSED, /**< The software timer is not used. */ - OS_SWTMR_STATUS_CREATED, /**< The software timer is created. */ - OS_SWTMR_STATUS_TICKING /**< The software timer is timing. */ -}; - -/** - * @ingroup los_swtmr - * Structure of the callback function that handles software timer timeout - */ -typedef struct { - SWTMR_PROC_FUNC handler; /**< Callback function that handles software timer timeout */ - UINT32 arg; /**< Parameter passed in when the callback function - that handles software timer timeout is called */ -} SwtmrHandlerItem; - -extern SWTMR_CTRL_S *g_swtmrCBArray; - -#define OS_SWT_FROM_SID(swtmrId) ((SWTMR_CTRL_S *)g_swtmrCBArray + ((swtmrId) % LOSCFG_BASE_CORE_SWTMR_LIMIT)) - -/** - * @ingroup los_swtmr - * @brief Scan a software timer. - * - * @par Description: - *
    - *
  • This API is used to scan a software timer when a Tick interrupt occurs and determine whether the software timer - expires.
  • - *
- * @attention - *
    - *
  • None.
  • - *
- * - * @param None. - * - * @retval None. - * @par Dependency: - *
  • los_swtmr_pri.h: the header file that contains the API declaration.
- * @see LOS_SwtmrStop - */ -extern UINT32 OsSwtmrScan(VOID); - -/** - * @ingroup los_swtmr - * @brief Initialization software timer. - * - * @par Description: - *
    - *
  • This API is used to initialization software.
  • - *
- * @attention - *
    - *
  • None.
  • - *
- * - * @param None. - * - * @retval None. - * @par Dependency: - *
  • los_swtmr_pri.h: the header file that contains the API declaration.
- * @see None. - */ -extern UINT32 OsSwtmrInit(VOID); - -/** - * @ingroup los_swtmr - * @brief Get next timeout. - * - * @par Description: - *
    - *
  • This API is used to get next timeout.
  • - *
- * @attention - *
    - *
  • None.
  • - *
- * - * @param None. - * - * @retval None. - * @par Dependency: - *
  • los_swtmr_pri.h: the header file that contains the API declaration.
- * @see None. - */ -extern UINT32 OsSwtmrGetNextTimeout(VOID); - -/** - * @ingroup los_swtmr - * @brief Adjust software timer list. - * - * @par Description: - *
    - *
  • This API is used to adjust software timer list.
  • - *
- * @attention - *
    - *
  • None.
  • - *
- * - * @param sleepTime [IN] UINT32 Sleep time. - * - * @retval UINT32 Sleep time. - * @par Dependency: - *
  • los_swtmr_pri.h: the header file that contains the API declaration.
- * @see None. - */ -extern VOID OsSwtmrAdjust(UINT32 sleepTime); - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_SWTMR_PRI_H */ diff --git a/kernel/src/los_sys.c b/kernel/src/los_sys.c deleted file mode 100755 index 2ba64e1b..00000000 --- a/kernel/src/los_sys.c +++ /dev/null @@ -1,159 +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_sys_pri.h" -#include "los_tick_pri.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -/***************************************************************************** -Function : LOS_TickCountGet -Description : get current tick -Input : None -Output : None -Return : current tick -*****************************************************************************/ -LITE_OS_SEC_TEXT_MINOR UINT64 LOS_TickCountGet(VOID) -{ - return g_ullTickCount; -} - -/***************************************************************************** -Function : LOS_CyclePerTickGet -Description : Get System cycle number corresponding to each tick -Input : None -Output : None -Return : cycle number corresponding to each tick -*****************************************************************************/ -LITE_OS_SEC_TEXT_MINOR UINT32 LOS_CyclePerTickGet(VOID) -{ - return g_cyclesPerTick; -} - -/***************************************************************************** -Function : LOS_MS2Tick -Description : milliseconds convert to Tick -Input : millisec ---------- milliseconds -Output : None -Return : Tick -*****************************************************************************/ -LITE_OS_SEC_TEXT_MINOR UINT32 LOS_MS2Tick(UINT32 millisec) -{ - if (millisec == OS_NULL_INT) { - return OS_NULL_INT; - } - - return ((UINT64)millisec * LOSCFG_BASE_CORE_TICK_PER_SECOND) / OS_SYS_MS_PER_SECOND; -} - -/***************************************************************************** -Function : LOS_Tick2MS -Description : Tick convert to milliseconds -Input : ticks ---------- ticks -Output : None -Return : milliseconds -*****************************************************************************/ -LITE_OS_SEC_TEXT_MINOR UINT32 LOS_Tick2MS(UINT32 ticks) -{ - return ((UINT64)ticks * OS_SYS_MS_PER_SECOND) / LOSCFG_BASE_CORE_TICK_PER_SECOND; -} - -/***************************************************************************** -Function : OsCpuTick2MS -Description : cycle convert to milliseconds -Input : cpuTick ---------- cycle -Output : msHi ---------- High 32 milliseconds - msLo ---------- Low 32 milliseconds -Return : LOS_OK on success ,or error code on failure -*****************************************************************************/ -LITE_OS_SEC_TEXT_INIT UINT32 OsCpuTick2MS(CpuTick *cpuTick, UINT32 *msHi, UINT32 *msLo) -{ - UINT64 tmpCpuTick; - DOUBLE temp; - - if ((cpuTick == NULL) || (msHi == NULL) || (msLo == NULL)) { - return LOS_ERRNO_SYS_PTR_NULL; - } - - if (g_sysClock == 0) { - return LOS_ERRNO_SYS_CLOCK_INVALID; - } - tmpCpuTick = ((UINT64)cpuTick->cntHi << OS_SYS_MV_32_BIT) | cpuTick->cntLo; - temp = tmpCpuTick / ((DOUBLE)g_sysClock / OS_SYS_MS_PER_SECOND); - - tmpCpuTick = (UINT64)temp; - - *msLo = (UINT32)tmpCpuTick; - *msHi = (UINT32)(tmpCpuTick >> OS_SYS_MV_32_BIT); - - return LOS_OK; -} - -/***************************************************************************** -Function : OsCpuTick2US -Description : cycle convert to Microsecond -Input : cpuTick ---------- cycle -Output : usHi ---------- High 32 Microsecond - usLo ---------- Low 32 Microsecond -Return : LOS_OK on success ,or error code on failure -*****************************************************************************/ -LITE_OS_SEC_TEXT_INIT UINT32 OsCpuTick2US(CpuTick *cpuTick, UINT32 *usHi, UINT32 *usLo) -{ - UINT64 tmpCpuTick; - DOUBLE temp; - - if ((cpuTick == NULL) || (usHi == NULL) || (usLo == NULL)) { - return LOS_ERRNO_SYS_PTR_NULL; - } - - if (g_sysClock == 0) { - return LOS_ERRNO_SYS_CLOCK_INVALID; - } - tmpCpuTick = ((UINT64)cpuTick->cntHi << OS_SYS_MV_32_BIT) | cpuTick->cntLo; - temp = tmpCpuTick / ((DOUBLE)g_sysClock / OS_SYS_US_PER_SECOND); - - tmpCpuTick = (UINT64)temp; - - *usLo = (UINT32)tmpCpuTick; - *usHi = (UINT32)(tmpCpuTick >> OS_SYS_MV_32_BIT); - - return LOS_OK; -} - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ diff --git a/kernel/src/los_sys_pri.h b/kernel/src/los_sys_pri.h deleted file mode 100755 index 27b85e5d..00000000 --- a/kernel/src/los_sys_pri.h +++ /dev/null @@ -1,183 +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. - */ - -#ifndef _LOS_SYS_PRI_H -#define _LOS_SYS_PRI_H - -#include "los_base_pri.h" -#include "los_tick_pri.h" -#include "los_sys.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -/** - * @ingroup los_sys - * Number of operable bits of a 32-bit operand - */ -#define OS_SYS_MV_32_BIT 32 - -/** - * @ingroup los_sys - * Number of milliseconds in one second. - */ -#define OS_SYS_MS_PER_SECOND 1000 - -/** - * @ingroup los_sys - * Number of microseconds in one second. - */ -#define OS_SYS_US_PER_SECOND 1000000 - -/** - * @ingroup los_sys - * The maximum length of name. - */ -#define OS_SYS_APPVER_NAME_MAX 64 - -/** - * @ingroup los_sys - * The magic word. - */ -#define OS_SYS_MAGIC_WORD 0xAAAAAAAA - -/** - * @ingroup los_sys - * The initialization value of stack space. - */ -#define OS_SYS_EMPTY_STACK 0xCACACACA - -/** - * @ingroup los_sys - * @brief Convert cycles to milliseconds. - * - * @par Description: - * This API is used to convert cycles to milliseconds. - * @attention - *
    - *
  • None.
  • - *
- * - * @param cpuTick [IN] Number of CPU cycles. - * @param msHi [OUT] Upper 32 bits of the number of milliseconds. - * @param msLo [OUT] Lower 32 bits of the number of milliseconds. - * - * @retval #LOS_ERRNO_SYS_PTR_NULL 0x02000011: Invalid parameter. - * @retval #LOS_OK 0: Cycles are successfully converted to microseconds. - * @par Dependency: - *
  • los_sys_pri.h: the header file that contains the API declaration.
- * @see None. - */ -extern UINT32 OsCpuTick2MS(CpuTick *cpuTick, UINT32 *msHi, UINT32 *msLo); - -/** - * @ingroup los_sys - * @brief Convert cycles to microseconds. - * - * @par Description: - * This API is used to convert cycles to microseconds. - * @attention - *
    - *
  • None.
  • - *
- * - * @param cpuTick [IN] Number of CPU cycles. - * @param usHi [OUT] Upper 32 bits of the number of microseconds. - * @param usLo [OUT] Lower 32 bits of the number of microseconds. - * - * @retval #LOS_ERRNO_SYS_PTR_NULL 0x02000011: Invalid parameter. - * @retval #LOS_OK 0: Cycles are successfully converted to microseconds. - * @par Dependency: - *
  • los_sys_pri.h: the header file that contains the API declaration.
- * @see None. - */ -extern UINT32 OsCpuTick2US(CpuTick *cpuTick, UINT32 *usHi, UINT32 *usLo); - -/** - * @ingroup los_sys - * @brief Convert cycles to milliseconds. - * - * @par Description: - * This API is used to convert cycles to milliseconds. - * @attention - *
    - *
  • None.
  • - *
- * - * @param cycle [IN] Number of cycles. - * - * @retval Number of milliseconds obtained through the conversion. Cycles are successfully converted to milliseconds. - * @par Dependency: - *
  • los_sys_pri.h: the header file that contains the API declaration.
- * @see None. - */ -STATIC_INLINE UINT64 OsCycle2MS(UINT64 cycle) -{ - return (UINT64)((cycle / (g_sysClock / OS_SYS_MS_PER_SECOND))); -} - -/** - * @ingroup los_sys - * @brief Convert cycles to microseconds. - * - * @par Description: - * This API is used to convert cycles to microseconds. - * @attention - *
    - *
  • None.
  • - *
- * - * @param cycle [IN] Number of cycles. - * - * @retval Number of microseconds obtained through the conversion. Cycles are successfully converted to microseconds. - * @par Dependency: - *
  • los_sys_pri.h: the header file that contains the API declaration.
- * @see None. - */ -STATIC_INLINE UINT64 OsCycle2US(UINT64 cycle) -{ - UINT64 tmp = g_sysClock / OS_SYS_US_PER_SECOND; - if (tmp == 0) { - return 0; - } - return (UINT64)(cycle / tmp); -} - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_SYS_PRI_H */ diff --git a/kernel/src/los_task.c b/kernel/src/los_task.c index b512e73f..53e55c38 100755 --- a/kernel/src/los_task.c +++ b/kernel/src/los_task.c @@ -28,32 +28,26 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#include "los_task_pri.h" -#include "string.h" +#include "los_config.h" #include "securec.h" -#include "los_base_pri.h" -#include "los_memory_pri.h" -#include "los_memstat_pri.h" -#include "los_priqueue_pri.h" -#include "los_sem_pri.h" -#include "los_mux_pri.h" +#include "los_sem.h" +#include "los_mux.h" +#include "los_memory.h" #if (LOSCFG_PLATFORM_EXC == YES) -#include "los_exc_pri.h" +#include "los_interrupt.h" #endif #if (LOSCFG_KERNEL_TICKLESS == YES) -#include "los_tickless_pri.h" +#include "los_tick.h" #endif #if (LOSCFG_BASE_CORE_CPUP == YES) -#include "los_cpup_pri.h" +#include "los_cpup.h" #endif -#include "los_hw.h" #if (LOSCFG_KERNEL_TRACE == YES) -#include "los_trace.h" +#include "los_debug.h" #endif //#include "los_sleep.h" -#include "los_printf.h" +#include "los_debug.h" #ifdef __cplusplus #if __cplusplus extern "C" { @@ -108,6 +102,12 @@ extern "C" { */ #define OS_TASK_STACK_TOP_OFFSET 4 +LITE_OS_SEC_BSS LOS_DL_LIST *g_losPriorityQueueList = NULL; +static LITE_OS_SEC_BSS UINT32 g_priqueueBitmap = 0; + +#define PRIQUEUE_PRIOR0_BIT (UINT32)0x80000000 +#define OS_PRIORITY_QUEUE_PRIORITYNUM 32 + LITE_OS_SEC_BSS LosTaskCB *g_taskCBArray = NULL; LITE_OS_SEC_BSS LosTask g_losTask; LITE_OS_SEC_BSS UINT16 g_losTaskLock; @@ -130,6 +130,66 @@ TSKSWITCHHOOK g_pfnUsrTskSwitchHook = NULL; TaskSwitchInfo g_taskSwitchInfo; #endif +STATIC UINT32 OsPriqueueInit(VOID) +{ + UINT32 priority; + UINT32 size = OS_PRIORITY_QUEUE_PRIORITYNUM * sizeof(LOS_DL_LIST); + + g_losPriorityQueueList = (LOS_DL_LIST *)LOS_MemAlloc(m_aucSysMem0, size); + if (g_losPriorityQueueList == NULL) { + return LOS_NOK; + } + + for (priority = 0; priority < OS_PRIORITY_QUEUE_PRIORITYNUM; ++priority) { + LOS_ListInit(&g_losPriorityQueueList[priority]); + } + return LOS_OK; +} + +STATIC VOID OsPriqueueEnqueue(LOS_DL_LIST *priqueueItem, UINT32 priority) +{ + if (LOS_ListEmpty(&g_losPriorityQueueList[priority])) { + g_priqueueBitmap |= (PRIQUEUE_PRIOR0_BIT >> priority); + } + + LOS_ListTailInsert(&g_losPriorityQueueList[priority], priqueueItem); +} + +STATIC VOID OsPriqueueDequeue(LOS_DL_LIST *priqueueItem) +{ + LosTaskCB *runningTask = NULL; + LOS_ListDelete(priqueueItem); + + runningTask = LOS_DL_LIST_ENTRY(priqueueItem, LosTaskCB, pendList); + if (LOS_ListEmpty(&g_losPriorityQueueList[runningTask->priority])) { + g_priqueueBitmap &= ~(PRIQUEUE_PRIOR0_BIT >> runningTask->priority); + } +} + +STATIC LOS_DL_LIST *OsPriqueueTop(VOID) +{ + UINT32 priority; + + if (g_priqueueBitmap != 0) { + priority = CLZ(g_priqueueBitmap); + return LOS_DL_LIST_FIRST(&g_losPriorityQueueList[priority]); + } + + return (LOS_DL_LIST *)NULL; +} + +STATIC UINT32 OsPriqueueSize(UINT32 priority) +{ + UINT32 itemCnt = 0; + LOS_DL_LIST *curPQNode = (LOS_DL_LIST *)NULL; + + LOS_DL_LIST_FOR_EACH(curPQNode, &g_losPriorityQueueList[priority]) { + ++itemCnt; + } + + return itemCnt; +} + STATIC_INLINE UINT32 OsCheckTaskIDValid(UINT32 taskID) { UINT32 ret = LOS_OK; @@ -1580,6 +1640,66 @@ VOID LOS_Schedule(VOID) } + +#if (LOSCFG_BASE_CORE_TIMESLICE == YES) +LITE_OS_SEC_BSS OsTaskRobin g_taskTimeSlice; + +/***************************************************************************** + Function : OsTimesliceInit + Description : Initialztion Timeslice + Input : None + Output : None + Return : None + *****************************************************************************/ +LITE_OS_SEC_TEXT_INIT VOID OsTimesliceInit(VOID) +{ + g_taskTimeSlice.task = (LosTaskCB *)NULL; + g_taskTimeSlice.tout = LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT; +} + +/***************************************************************************** + Function : OsTimesliceCheck + Description : check Timeslice + Input : None + Output : None + Return : None + *****************************************************************************/ +LITE_OS_SEC_TEXT VOID OsTimesliceCheck(VOID) +{ + if (g_taskTimeSlice.task != g_losTask.runTask) { + g_taskTimeSlice.task = g_losTask.runTask; + g_taskTimeSlice.time = ((UINT16)g_ullTickCount + g_taskTimeSlice.tout) - 1; + } + + if (g_taskTimeSlice.time == (UINT16)g_ullTickCount) { + g_taskTimeSlice.task = (LosTaskCB *)NULL; + if (LOS_TaskYield() != LOS_OK) { + PRINT_INFO("%s, %d\n", __FUNCTION__, __LINE__); + } + } +} +#endif + +LITE_OS_SEC_TEXT_MINOR VOID LOS_Msleep(UINT32 mSecs) +{ + UINT32 interval; + + if (OS_INT_ACTIVE) { + return; + } + + if (mSecs == 0) { + interval = 0; + } else { + interval = LOS_MS2Tick(mSecs); + if (interval == 0) { + interval = 1; + } + } + + (VOID)LOS_TaskDelay(interval); +} + #ifdef __cplusplus #if __cplusplus } diff --git a/kernel/src/los_task_pri.h b/kernel/src/los_task_pri.h deleted file mode 100755 index b3f9b106..00000000 --- a/kernel/src/los_task_pri.h +++ /dev/null @@ -1,711 +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. - */ - -#ifndef _LOS_TASK_PRI_H -#define _LOS_TASK_PRI_H - -#include "los_task.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - - -/** - * @ingroup los_task - * Null task ID - * - */ -#define OS_TASK_ERRORID 0xFFFFFFFF - -/** - * @ingroup los_task - * Define a usable task priority. - * - * Highest task priority. - */ -#define OS_TASK_PRIORITY_HIGHEST 0 - -/** - * @ingroup los_task - * Define a usable task priority. - * - * Lowest task priority. - */ -#define OS_TASK_PRIORITY_LOWEST 31 - -/** - * @ingroup los_task - * Flag that indicates the task or task control block status. - * - * The task control block is unused. - */ -#define OS_TASK_STATUS_UNUSED 0x0001 - -/** - * @ingroup los_task - * Flag that indicates the task or task control block status. - * - * The task is suspended. - */ -#define OS_TASK_STATUS_SUSPEND 0x0002 - -/** - * @ingroup los_task - * Flag that indicates the task or task control block status. - * - * The task is ready. - */ -#define OS_TASK_STATUS_READY 0x0004 - -/** - * @ingroup los_task - * Flag that indicates the task or task control block status. - * - * The task is blocked. - */ -#define OS_TASK_STATUS_PEND 0x0008 - -/** - * @ingroup los_task - * Flag that indicates the task or task control block status. - * - * The task is running. - */ -#define OS_TASK_STATUS_RUNNING 0x0010 - -/** - * @ingroup los_task - * Flag that indicates the task or task control block status. - * - * The task is delayed. - */ -#define OS_TASK_STATUS_DELAY 0x0020 - -/** - * @ingroup los_task - * Flag that indicates the task or task control block status. - * - * The time for waiting for an event to occur expires. - */ -#define OS_TASK_STATUS_TIMEOUT 0x0040 - -/** - * @ingroup los_task - * Flag that indicates the task or task control block status. - * - * The task is waiting for an event to occur. - */ -#define OS_TASK_STATUS_EVENT 0x0400 - -/** - * @ingroup los_task - * Flag that indicates the task or task control block status. - * - * The task is reading an event. - */ -#define OS_TASK_STATUS_EVENT_READ 0x0800 - -/** - * @ingroup los_task - * Flag that indicates the task or task control block status. - * - * A software timer is waiting for an event to occur. - */ -#define OS_TASK_STATUS_SWTMR_WAIT 0x1000 - -/** - * @ingroup los_task - * Flag that indicates the task or task control block status. - * - * The task is blocked on a queue. - */ -#define OS_TASK_STATUS_PEND_QUEUE 0x2000 - -/** - * @ingroup los_task - * Flag that indicates the task is in userspace. - * - * The task is a user task. - */ -#define OS_TASK_STATUS_USERSPACE 0x8000 - -/** - * @ingroup los_task - * Boundary on which the stack size is aligned. - * - */ -#define OS_TASK_STACK_SIZE_ALIGN 16 - -/** - * @ingroup los_task - * Boundary on which the stack address is aligned. - * - */ -#define OS_TASK_STACK_ADDR_ALIGN 8 - -/** - * @ingroup los_task - * Task stack top magic number. - * - */ -#define OS_TASK_MAGIC_WORD 0xCCCCCCCC - -/** - * @ingroup los_task - * Initial task stack value. - * - */ -#define OS_TASK_STACK_INIT 0xCACACACA - -/** - * @ingroup los_task - * Number of usable task priorities. - */ -#define OS_TSK_PRINUM ((OS_TASK_PRIORITY_LOWEST - OS_TASK_PRIORITY_HIGHEST) + 1) - -/** - * @ingroup los_task - * @brief the num of delayed tasks bucket - */ -#define OS_TSK_SORTLINK_LEN 32 - -/** - * @ingroup los_task - * @brief the bit width occupied by the delayed ticks of task - */ -#define OS_TSK_SORTLINK_LOGLEN 5 - -/** - * @ingroup los_task - * @brief the mask of delayed tasks bucket id. - */ -#define OS_TSK_SORTLINK_MASK (OS_TSK_SORTLINK_LEN - 1) - -/** - * @ingroup los_task - * @brief the max task count for switch. - */ -#define OS_TASK_SWITCH_INFO_COUNT 0xA - -/** - * @ingroup los_task - * @brief Check whether a task ID is valid. - * - * @par Description: - * This API is used to check whether a task ID, excluding the idle task ID, is valid. - * @attention None. - * - * @param taskID [IN] Task ID. - * - * @retval 0 or 1. One indicates that the task ID is invalid, whereas zero indicates that the task ID is valid. - * @par Dependency: - *
  • los_task_pri.h: the header file that contains the API declaration.
- * @see - */ -#define OS_TSK_GET_INDEX(taskID) (taskID) - -/** - * @ingroup los_task - * @brief Obtain the pointer to a task control block. - * - * @par Description: - * This API is used to obtain the pointer to a task control block using a corresponding parameter. - * @attention None. - * - * @param ptr [IN] Parameter used for obtaining the task control block. - * - * @retval Pointer to the task control block. - * @par Dependency: - *
  • los_task_pri.h: the header file that contains the API declaration.
- * @see - */ -#define OS_TCB_FROM_PENDLIST(ptr) LOS_DL_LIST_ENTRY(ptr, LosTaskCB, pendList) - -/** - * @ingroup los_task - * @brief Obtain the pointer to a task control block. - * - * @par Description: - * This API is used to obtain the pointer to a task control block that has a specified task ID. - * @attention None. - * - * @param taskID [IN] task ID. - * - * @retval Pointer to the task control block. - * @par Dependency: - *
  • los_task_pri.h: the header file that contains the API declaration.
- * @see - */ -#define OS_TCB_FROM_TID(taskID) (((LosTaskCB *)g_taskCBArray) + (taskID)) -#define OS_IDLE_TASK_ENTRY ((TSK_ENTRY_FUNC)OsIdleTask) - - -/** - * @ingroup los_task - * Define the task control block structure. - */ -typedef struct { - VOID *stackPointer; /**< Task stack pointer */ - UINT16 taskStatus; - UINT16 priority; - UINT32 stackSize; /**< Task stack size */ - UINT32 topOfStack; /**< Task stack top */ - UINT32 taskID; /**< Task ID */ - TSK_ENTRY_FUNC taskEntry; /**< Task entrance function */ - VOID *taskSem; /**< Task-held semaphore */ - VOID *taskMux; /**< Task-held mutex */ - UINT32 arg; /**< Parameter */ - CHAR *taskName; /**< Task name */ - LOS_DL_LIST pendList; - LOS_DL_LIST timerList; - UINT32 idxRollNum; - EVENT_CB_S event; - UINT32 eventMask; /**< Event mask */ - UINT32 eventMode; /**< Event mode */ - VOID *msg; /**< Memory allocated to queues */ -} LosTaskCB; - -typedef struct { - LosTaskCB *runTask; - LosTaskCB *newTask; -} LosTask; - -typedef struct { - LOS_DL_LIST *sortLink; - UINT16 cursor; - UINT16 unused; -} TaskSortLinkAttr; - -/** - * @ingroup los_task - * Time slice structure. - */ -typedef struct TaskTimeSlice { - LosTaskCB *task; /**< Current running task */ - UINT16 time; /**< Expiration time point */ - UINT16 tout; /**< Expiration duration */ -} OsTaskRobin; - -typedef struct { - UINT8 maxCnt : 7; // bits [6:0] store count of task switch info - UINT8 isFull : 1; // bit [7] store isfull status -} TaskCountInfo; - -/** - * @ingroup los_task - * Task switch information structure. - * - */ -typedef struct { - UINT8 idx; - TaskCountInfo cntInfo; - UINT16 pid[OS_TASK_SWITCH_INFO_COUNT]; - CHAR name[OS_TASK_SWITCH_INFO_COUNT][LOS_TASK_NAMELEN]; -}TaskSwitchInfo; - - -extern LosTask g_losTask; - -/** - * @ingroup los_task - * Task lock flag. - * - */ -extern UINT16 g_losTaskLock; - -/** - * @ingroup los_task - * Maximum number of tasks. - * - */ -extern UINT32 g_taskMaxNum; - -/** - * @ingroup los_task - * Idle task ID. - * - */ -extern UINT32 g_idleTaskID; - -/** - * @ingroup los_task - * Software timer task ID. - * - */ -extern UINT32 g_swtmrTaskID; - -/** - * @ingroup los_task - * Starting address of a task. - * - */ -extern LosTaskCB *g_taskCBArray; - -/** - * @ingroup los_task - * Free task linked list. - * - */ -extern LOS_DL_LIST g_losFreeTask; - -/** - * @ingroup los_task - * Circular linked list that stores tasks that are deleted automatically. - * - */ -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. - * - * @par Description: - * This API is used to modify the priority of task. - * - * @attention - *
    - *
  • The taskCB should be a correct pointer to task control block structure.
  • - *
  • the priority should be in [0, OS_TASK_PRIORITY_LOWEST].
  • - *
- * - * @param taskCB [IN] Type #LosTaskCB * pointer to task control block structure. - * @param priority [IN] Type #UINT16 the priority of task. - * - * @retval None. - * @par Dependency: - *
  • los_task_pri.h: the header file that contains the API declaration.
- * @see - */ -extern VOID OsTaskPriModify(LosTaskCB *taskCB, UINT16 priority); - -/** - * @ingroup los_task - * @brief Scan a task. - * - * @par Description: - * This API is used to scan a task. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param None. - * - * @retval None. - * @par Dependency: - *
  • los_task_pri.h: the header file that contains the API declaration.
- * @see - */ -extern VOID OsTaskScan(VOID); - -/** - * @ingroup los_task - * @brief Initialization a task. - * - * @par Description: - * This API is used to initialization a task. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param None. - * - * @retval UINT32 Initialization result. - * @par Dependency: - *
  • los_task_pri.h: the header file that contains the API declaration.
- * @see - */ -extern UINT32 OsTaskInit(VOID); - -/** - * @ingroup los_task - * @brief Create idle task. - * - * @par Description: - * This API is used to create idle task. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param None. - * - * @retval UINT32 Create result. - * @par Dependency: - *
  • los_task_pri.h: the header file that contains the API declaration.
- * @see - */ -extern UINT32 OsIdleTaskCreate(VOID); - -/** - * @ingroup los_task - * @brief Check task switch. - * - * @par Description: - * This API is used to check task switch. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param None. - * - * @retval None. - * @par Dependency: - *
  • los_task_pri.h: the header file that contains the API declaration.
- * @see - */ -extern VOID OsTaskSwitchCheck(VOID); - -/** - * @ingroup los_task - * @brief TaskMonInit. - * - * @par Description: - * This API is used to taskMonInit. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param None. - * - * @retval None. - * @par Dependency: - *
  • los_task_pri.h: the header file that contains the API declaration.
- * @see - */ -extern VOID OsTaskMonInit(VOID); - -/** - * @ingroup los_task - * @brief Task entry. - * - * @par Description: - * This API is used to task entry. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param taskID [IN] Type #UINT32 task id. - * - * @retval None. - * @par Dependency: - *
  • los_task_pri.h: the header file that contains the API declaration.
- * @see - */ -extern VOID OsTaskEntry(UINT32 taskID); - -/** - * @ingroup los_task - * @brief pend running task to pendlist - * - * @par Description: - * This API is used to pend task to pendlist and add to sorted delay list. - * - * @attention - *
    - *
  • The pstList should be a vaild pointer to pendlist.
  • - *
- * - * @param list [IN] Type #LOS_DL_LIST * pointer to list which running task will be pended. - * @param taskStatus [IN] Type #UINT32 Task Status. - * @param timeOut [IN] Type #UINT32 Expiry time. The value range is [0,LOS_WAIT_FOREVER]. - * - * @retval LOS_OK wait success - * @retval LOS_NOK pend out - * @par Dependency: - *
  • los_task_pri.h: the header file that contains the API declaration.
- * @see OsTaskWake - */ -extern VOID OsTaskWait(LOS_DL_LIST *list, UINT32 taskStatus, UINT32 timeOut); - -/** - * @ingroup los_task - * @brief delete task from pendlist. - * - * @par Description: - * This API is used to delete task from pendlist and also add to the priqueue. - * - * @attention - *
    - *
  • The pstList should be a vaild pointer to pend list.
  • - *
- * - * @param resumedTask [IN] Type #LosTaskCB * pointer to the task which will be add to priqueue. - * @param taskStatus [IN] Type #UINT32 Task Status. - * - * @retval None. - * @par Dependency: - *
  • los_task_pri.h: the header file that contains the API declaration.
- * @see OsTaskWait - */ -extern VOID OsTaskWake(LosTaskCB *resumedTask, UINT32 taskStatus); - -/** - * @ingroup los_task - * @brief Get the task water line. - * - * @par Description: - * This API is used to get the task water line. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param taskID [IN] Type #UINT32 task id. - * - * @retval UINT32 Task water line. - * @par Dependency: - *
  • los_task_pri.h: the header file that contains the API declaration.
- * @see None. - */ -extern UINT32 OsGetTaskWaterLine(UINT32 taskID); - -/** - * @ingroup los_task - * @brief Convert task status to string. - * - * @par Description: - * This API is used to convert task status to string. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param taskStatus [IN] Type #UINT16 task status. - * - * @retval UINT8 * String. - * @par Dependency: - *
  • los_task_pri.h: the header file that contains the API declaration.
- * @see None. - */ -extern UINT8 *OsConvertTskStatus(UINT16 taskStatus); - -/** - * @ingroup los_task - * @brief Add task to sorted delay list. - * - * @par Description: - * This API is used to add task to sorted delay list. - * - * @attention - *
    - *
  • The taskCB should be a correct pointer to task control block structure.
  • - *
- * - * @param taskCB [IN] Type #LosTaskCB * pointer to task control block structure. - * @param timeout [IN] Type #UINT32 wait time, ticks. - * - * @retval None. - * @par Dependency: - *
  • los_task_pri.h: the header file that contains the API declaration.
- * @see OsTimerListDelete - */ -extern VOID OsTaskAdd2TimerList(LosTaskCB *taskCB, UINT32 timeout); - -/** - * @ingroup los_task - * @brief delete task from sorted delay list. - * - * @par Description: - * This API is used to delete task from sorted delay list. - * - * @attention - *
    - *
  • The taskCB should be a correct pointer to task control block structure.
  • - *
- * - * @param taskCB [IN] Type #LosTaskCB * pointer to task control block structure. - * - * @retval None. - * @par Dependency: - *
  • los_task_pri.h: the header file that contains the API declaration.
- * @see OsTaskAdd2TimerList - */ -extern VOID OsTimerListDelete(LosTaskCB *taskCB); - -/** - * @ingroup los_task - * @brief Get all task information. - * - * @par Description: - * This API is used to get all task information. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param None. - * - * @retval UINT32 All task information. - * @par Dependency: - *
  • los_task_pri.h: the header file that contains the API declaration.
- * @see None. - */ -extern UINT32 OsGetAllTskInfo(VOID); - - -extern VOID *OsTskUserStackInit(VOID* stackPtr, VOID* userSP, UINT32 userStackSize); - -extern VOID *OsTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack); - -extern VOID OsSchedule(VOID); - -extern VOID osTaskSchedule(VOID); - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_TASK_PRI_H */ diff --git a/kernel/src/los_tick.c b/kernel/src/los_tick.c index 90a98718..20188758 100755 --- a/kernel/src/los_tick.c +++ b/kernel/src/los_tick.c @@ -29,14 +29,10 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "los_tick_pri.h" -#include "los_base_pri.h" -#include "los_swtmr_pri.h" -#include "los_task_pri.h" -#include "los_timeslice_pri.h" -#if (LOSCFG_KERNEL_TICKLESS == YES) -#include "los_tickless_pri.h" -#endif +#include "los_tick.h" +#include "los_config.h" +#include "los_task.h" +#include "los_swtmr.h" #ifdef __cplusplus #if __cplusplus @@ -110,6 +106,122 @@ UINT32 LOS_SysClockGet(VOID) return g_sysClock; } + +/***************************************************************************** +Function : LOS_TickCountGet +Description : get current tick +Input : None +Output : None +Return : current tick +*****************************************************************************/ +LITE_OS_SEC_TEXT_MINOR UINT64 LOS_TickCountGet(VOID) +{ + return g_ullTickCount; +} + +/***************************************************************************** +Function : LOS_CyclePerTickGet +Description : Get System cycle number corresponding to each tick +Input : None +Output : None +Return : cycle number corresponding to each tick +*****************************************************************************/ +LITE_OS_SEC_TEXT_MINOR UINT32 LOS_CyclePerTickGet(VOID) +{ + return g_cyclesPerTick; +} + +/***************************************************************************** +Function : LOS_MS2Tick +Description : milliseconds convert to Tick +Input : millisec ---------- milliseconds +Output : None +Return : Tick +*****************************************************************************/ +LITE_OS_SEC_TEXT_MINOR UINT32 LOS_MS2Tick(UINT32 millisec) +{ + if (millisec == OS_NULL_INT) { + return OS_NULL_INT; + } + + return ((UINT64)millisec * LOSCFG_BASE_CORE_TICK_PER_SECOND) / OS_SYS_MS_PER_SECOND; +} + +/***************************************************************************** +Function : LOS_Tick2MS +Description : Tick convert to milliseconds +Input : ticks ---------- ticks +Output : None +Return : milliseconds +*****************************************************************************/ +LITE_OS_SEC_TEXT_MINOR UINT32 LOS_Tick2MS(UINT32 ticks) +{ + return ((UINT64)ticks * OS_SYS_MS_PER_SECOND) / LOSCFG_BASE_CORE_TICK_PER_SECOND; +} + +/***************************************************************************** +Function : OsCpuTick2MS +Description : cycle convert to milliseconds +Input : cpuTick ---------- cycle +Output : msHi ---------- High 32 milliseconds + msLo ---------- Low 32 milliseconds +Return : LOS_OK on success ,or error code on failure +*****************************************************************************/ +LITE_OS_SEC_TEXT_INIT UINT32 OsCpuTick2MS(CpuTick *cpuTick, UINT32 *msHi, UINT32 *msLo) +{ + UINT64 tmpCpuTick; + DOUBLE temp; + + if ((cpuTick == NULL) || (msHi == NULL) || (msLo == NULL)) { + return LOS_ERRNO_SYS_PTR_NULL; + } + + if (g_sysClock == 0) { + return LOS_ERRNO_SYS_CLOCK_INVALID; + } + tmpCpuTick = ((UINT64)cpuTick->cntHi << OS_SYS_MV_32_BIT) | cpuTick->cntLo; + temp = tmpCpuTick / ((DOUBLE)g_sysClock / OS_SYS_MS_PER_SECOND); + + tmpCpuTick = (UINT64)temp; + + *msLo = (UINT32)tmpCpuTick; + *msHi = (UINT32)(tmpCpuTick >> OS_SYS_MV_32_BIT); + + return LOS_OK; +} + +/***************************************************************************** +Function : OsCpuTick2US +Description : cycle convert to Microsecond +Input : cpuTick ---------- cycle +Output : usHi ---------- High 32 Microsecond + usLo ---------- Low 32 Microsecond +Return : LOS_OK on success ,or error code on failure +*****************************************************************************/ +LITE_OS_SEC_TEXT_INIT UINT32 OsCpuTick2US(CpuTick *cpuTick, UINT32 *usHi, UINT32 *usLo) +{ + UINT64 tmpCpuTick; + DOUBLE temp; + + if ((cpuTick == NULL) || (usHi == NULL) || (usLo == NULL)) { + return LOS_ERRNO_SYS_PTR_NULL; + } + + if (g_sysClock == 0) { + return LOS_ERRNO_SYS_CLOCK_INVALID; + } + tmpCpuTick = ((UINT64)cpuTick->cntHi << OS_SYS_MV_32_BIT) | cpuTick->cntLo; + temp = tmpCpuTick / ((DOUBLE)g_sysClock / OS_SYS_US_PER_SECOND); + + tmpCpuTick = (UINT64)temp; + + *usLo = (UINT32)tmpCpuTick; + *usHi = (UINT32)(tmpCpuTick >> OS_SYS_MV_32_BIT); + + return LOS_OK; +} + + #ifdef __cplusplus #if __cplusplus } diff --git a/kernel/src/los_tick_pri.h b/kernel/src/los_tick_pri.h deleted file mode 100755 index eceec947..00000000 --- a/kernel/src/los_tick_pri.h +++ /dev/null @@ -1,126 +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. - */ - -#ifndef _LOS_TICK_PRI_H -#define _LOS_TICK_PRI_H - -#include "los_tick.h" -#include "los_config.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -/** - * @ingroup los_tick - * Count of Ticks - */ -extern UINT64 g_ullTickCount; - -/** - * @ingroup los_tick - * Ticks per second - */ -extern UINT32 g_ticksPerSec; - -/** - * @ingroup los_tick - * Cycles per Second - */ -extern UINT32 g_uwCyclePerSec; - -/** - * @ingroup los_tick - * Cycles per Tick - */ -extern UINT32 g_cyclesPerTick; - -/** - * @ingroup los_tick - * System Clock - */ -extern UINT32 g_sysClock; -/** - * @ingroup los_tick - * @brief Handle the system tick timeout. - * - * @par Description: - * This API is called when the system tick timeout and triggers the interrupt. - * - * @attention - *
    - *
  • None.
  • - *
- * - * @param none. - * - * @retval None. - * @par Dependency: - *
  • los_tick_pri.h: the header file that contains the API declaration.
- * @see None. - */ -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 - *
    - *
  • None.
  • - *
- * - * @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); - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_TICK_PRI_H */ diff --git a/kernel/src/los_timeslice.c b/kernel/src/los_timeslice.c deleted file mode 100755 index a8f6a8ed..00000000 --- a/kernel/src/los_timeslice.c +++ /dev/null @@ -1,91 +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_sys_pri.h" -#include "los_task_pri.h" -#include "los_tick_pri.h" -#include "los_typedef.h" -#include "los_timeslice_pri.h" -#include "los_printf.h" - - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#if (LOSCFG_BASE_CORE_TIMESLICE == YES) -LITE_OS_SEC_BSS OsTaskRobin g_taskTimeSlice; - -/***************************************************************************** - Function : OsTimesliceInit - Description : Initialztion Timeslice - Input : None - Output : None - Return : None - *****************************************************************************/ -LITE_OS_SEC_TEXT_INIT VOID OsTimesliceInit(VOID) -{ - g_taskTimeSlice.task = (LosTaskCB *)NULL; - g_taskTimeSlice.tout = LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT; -} - -/***************************************************************************** - Function : OsTimesliceCheck - Description : check Timeslice - Input : None - Output : None - Return : None - *****************************************************************************/ -LITE_OS_SEC_TEXT VOID OsTimesliceCheck(VOID) -{ - if (g_taskTimeSlice.task != g_losTask.runTask) { - g_taskTimeSlice.task = g_losTask.runTask; - g_taskTimeSlice.time = ((UINT16)g_ullTickCount + g_taskTimeSlice.tout) - 1; - } - - if (g_taskTimeSlice.time == (UINT16)g_ullTickCount) { - g_taskTimeSlice.task = (LosTaskCB *)NULL; - if (LOS_TaskYield() != LOS_OK) { - PRINT_INFO("%s, %d\n", __FUNCTION__, __LINE__); - } - } -} - -#endif - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - diff --git a/kernel/src/los_timeslice_pri.h b/kernel/src/los_timeslice_pri.h deleted file mode 100755 index 8d18eb1a..00000000 --- a/kernel/src/los_timeslice_pri.h +++ /dev/null @@ -1,99 +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. - */ - -/** - * @defgroup los_timeslice Timeslice - * @ingroup kernel - */ - -#ifndef _LOS_TIMESLICE_PRI_H -#define _LOS_TIMESLICE_PRI_H - -#include "los_typedef.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -/** - * @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 - *
    - *
  • None.
  • - *
- * - * @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 - *
    - *
  • None.
  • - *
- * - * @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 -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_TIMESLICE_PRI_H */ diff --git a/kernel/src/mm/los_membox.c b/kernel/src/mm/los_membox.c index 217fafa1..3eea3ab1 100755 --- a/kernel/src/mm/los_membox.c +++ b/kernel/src/mm/los_membox.c @@ -29,13 +29,11 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include "securec.h" -#include "los_hwi.h" -#include "los_typedef.h" +#include "los_interrupt.h" #include "los_membox.h" #include "los_memory.h" -#include "los_memcheck_pri.h" +#include "los_debug.h" #if (LOSCFG_PLATFORM_EXC == YES) || (LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK == YES) UINT8 g_memMang[MEM_INFO_SIZE]; @@ -110,6 +108,9 @@ VOID *LOS_MemboxAlloc(VOID *boxMem) VOID *ret = NULL; UINTPTR intSave; + if (boxMem == NULL) { + return NULL; + } intSave = LOS_IntLock(); if (((OS_MEMBOX_S_P)boxMem)->uwBlkCnt < ((OS_MEMBOX_S_P)boxMem)->uwMaxBlk) { ret = LOS_MemAlloc(m_aucSysMem0, ((OS_MEMBOX_S_P)boxMem)->uwBlkSize); @@ -149,6 +150,9 @@ UINT32 LOS_MemboxFree(const VOID *boxMem, VOID *box) UINT32 freeRes; UINTPTR intSave; + if (boxMem == NULL) { + return LOS_NOK; + } freeRes = LOS_MemFree(m_aucSysMem0, box); if (freeRes == LOS_OK) { intSave = LOS_IntLock(); @@ -183,6 +187,9 @@ UINT32 LOS_MemboxFree(const VOID *boxMem, VOID *box) /* --------------------------- LOS_MemboxClr ---------------------------------- */ VOID LOS_MemboxClr(const VOID *boxMem, VOID *box) { + if (boxMem == NULL || box == NULL) { + return; + } // Ignore the return code when matching CSEC rule 6.6(2). (VOID)memset_s(box, ((OS_MEMBOX_S_P)boxMem)->uwBlkSize, 0, ((OS_MEMBOX_S_P)boxMem)->uwBlkSize); } diff --git a/kernel/src/mm/los_memcheck.c b/kernel/src/mm/los_memcheck.c index c3094028..78c7b0c6 100755 --- a/kernel/src/mm/los_memcheck.c +++ b/kernel/src/mm/los_memcheck.c @@ -29,10 +29,8 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "los_memcheck.h" -#include "los_memory_pri.h" -#include "los_membox_pri.h" -#include "los_multipledlinkhead_pri.h" +#include "los_membox.h" +//#include "los_multipledlinkhead_pri.h" #ifdef __cplusplus #if __cplusplus extern "C" { diff --git a/kernel/src/mm/los_memory.c b/kernel/src/mm/los_memory.c index 8fb7555c..04fc5467 100755 --- a/kernel/src/mm/los_memory.c +++ b/kernel/src/mm/los_memory.c @@ -28,23 +28,16 @@ * 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_memory_pri.h" -#include "los_memstat_pri.h" -#include "los_multipledlinkhead_pri.h" -#include "los_task_pri.h" -#include "los_exc.h" -#include "los_printf.h" -#ifdef LOS_MEM_LEAK_CHECK -#include "los_membox_pri.h" -#endif -#if (LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK == YES) -#include "los_memcheck_pri.h" -#endif +#include "los_memory.h" +#include "los_task.h" +#include "los_interrupt.h" +#include "los_debug.h" +#include "los_membox.h" #ifdef LOSCFG_LIB_LIBC -#include "string.h" #endif + + #ifdef __cplusplus #if __cplusplus extern "C" { @@ -55,6 +48,8 @@ extern "C" { VOID *g_memPoolHead = NULL; #endif +MALLOC_HOOK g_mallocHook = (MALLOC_HOOK)(UINTPTR)NULL; + #if (LOSCFG_BASE_CORE_TASKSTACK_INDEPENDENT == YES) __attribute__((section(".data"))) UINT32 g_sysStackAddrEnd; #endif @@ -76,7 +71,39 @@ int g_memCheckFlag = 0; UINT32 g_memInfo[MEM_MODULE_MAX + 1] = {0}; #endif -MALLOC_HOOK g_mallocHook = (MALLOC_HOOK)(UINTPTR)NULL; +#define OS_BITS_PER_BYTE 8 +STATIC_INLINE UINT32 OsLog2(UINT32 size) +{ + 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; @@ -269,6 +296,9 @@ STATIC_INLINE VOID OsMemFreeNode(LosMemDynNode *node, VOID *pool) 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); @@ -1515,6 +1545,10 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_MemNodeSizeCheck(VOID *pool, VOID *ptr, UINT32 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; diff --git a/kernel/src/mm/los_memstat.c b/kernel/src/mm/los_memstat.c index 0ffb1b36..e244cebd 100755 --- a/kernel/src/mm/los_memstat.c +++ b/kernel/src/mm/los_memstat.c @@ -29,11 +29,8 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "los_memstat_pri.h" -#include "los_task_pri.h" -#include "los_config.h" -#include "los_printf.h" - +#include "los_debug.h" +#include "los_interrupt.h" typedef struct { UINT32 memUsed; diff --git a/kernel/src/mm/los_multipledlinkhead.c b/kernel/src/mm/los_multipledlinkhead.c deleted file mode 100755 index 7c03c77f..00000000 --- a/kernel/src/mm/los_multipledlinkhead.c +++ /dev/null @@ -1,66 +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_multipledlinkhead_pri.h" -#include "los_compiler.h" - -#define OS_BITS_PER_BYTE 8 -STATIC_INLINE UINT32 OsLog2(UINT32 size) -{ - 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); -} diff --git a/targets/cortex-m3_stm32f103_simulator_keil/Driver/STM32F103/uart.c b/targets/cortex-m3_stm32f103_simulator_keil/Driver/STM32F103/uart.c new file mode 100755 index 00000000..cba8a6e5 --- /dev/null +++ b/targets/cortex-m3_stm32f103_simulator_keil/Driver/STM32F103/uart.c @@ -0,0 +1,409 @@ +#include +#include "los_compiler.h" + +#define OS_USART1 0x40013800 +#define OS_USART2 0x40004400 +#define OS_USART3 0x40004800 +#define OS_USART4 0x40004C00 +#define OS_USART5 0x40005000 + +#define OS_USART_USR OS_USART1 + + +#define GPIO_Pin_0 ((UINT16)0x0001) /* Pin 0 selected */ +#define GPIO_Pin_1 ((UINT16)0x0002) /* Pin 1 selected */ +#define GPIO_Pin_2 ((UINT16)0x0004) /* Pin 2 selected */ +#define GPIO_Pin_3 ((UINT16)0x0008) /* Pin 3 selected */ +#define GPIO_Pin_4 ((UINT16)0x0010) /* Pin 4 selected */ +#define GPIO_Pin_5 ((UINT16)0x0020) /* Pin 5 selected */ +#define GPIO_Pin_6 ((UINT16)0x0040) /* Pin 6 selected */ +#define GPIO_Pin_7 ((UINT16)0x0080) /* Pin 7 selected */ +#define GPIO_Pin_8 ((UINT16)0x0100) /* Pin 8 selected */ +#define GPIO_Pin_9 ((UINT16)0x0200) /* Pin 9 selected */ +#define GPIO_Pin_10 ((UINT16)0x0400) /* Pin 10 selected */ +#define GPIO_Pin_11 ((UINT16)0x0800) /* Pin 11 selected */ +#define GPIO_Pin_12 ((UINT16)0x1000) /* Pin 12 selected */ +#define GPIO_Pin_13 ((UINT16)0x2000) /* Pin 13 selected */ +#define GPIO_Pin_14 ((UINT16)0x4000) /* Pin 14 selected */ +#define GPIO_Pin_15 ((UINT16)0x8000) /* Pin 15 selected */ +#define GPIO_Pin_All ((UINT16)0xFFFF) /* All pins selected */ + +#define GPIOA 0x40010800 +#define GPIOB 0x40010C00 +#define GPIOC 0x40011000 +#define GPIOD 0x40011400 +#define GPIOE 0x40011800 +#define GPIOF 0x40011C00 +#define GPIOG 0x40012000 + +#define RCC_REG_BASE 0x40021000 +#define RCC_APB2ENR_OFFSET 0x18 +#define RCC_APB1ENR_OFFSET 0x1C + +#if (OS_USART_USR == OS_USART1) +#define RCC_APBENR_USART_EN 0x4004 +#define GPIO_RxPin GPIO_Pin_10 +#define GPIO_TxPin GPIO_Pin_9 +#define GPIOx GPIOA + +#elif (OS_USART_USR == OS_USART2) +#define RCC_APBENR_USART_EN 0x20000 +#define GPIO_TxPin GPIO_Pin_5 +#define GPIO_RxPin GPIO_Pin_6 +#define GPIOx GPIOD + +#elif (OS_USART_USR == OS_USART3) +#define RCC_APBENR_USART_EN 0x40000 +#define GPIO_RxPin GPIO_Pin_11 +#define GPIO_TxPin GPIO_Pin_10 +#define GPIOx GPIOB + +#elif (OS_USART_USR == OS_USART4) +#define RCC_APBENR_USART_EN 0x80000 +#define GPIO_RxPin GPIO_Pin_11 +#define GPIO_TxPin GPIO_Pin_10 +#define GPIOx GPIOC + +#elif (OS_USART_USR == OS_USART5) +#define RCC_APBENR_USART_EN 0x100000 +#define GPIO_RxPin GPIO_Pin_2 +#define GPIO_TxPin GPIO_Pin_12 +#define GPIOx GPIOC + +#endif + +typedef struct tagUsartMap +{ + volatile UINT32 SR; + volatile UINT32 DR; + volatile UINT32 BRR; + volatile UINT32 CR1; + volatile UINT32 CR2; + volatile UINT32 CR3; + volatile UINT32 GTPR; +}USART_MAP_S; + +typedef struct +{ + UINT32 USART_BaudRate; + UINT16 USART_WordLength; + UINT16 USART_StopBits; + UINT16 USART_Parity; + UINT16 USART_Mode; + UINT16 USART_HardwareFlowControl; + UINT16 USART_Clock; + UINT16 USART_CPOL; + UINT16 USART_CPHA; + UINT16 USART_LastBit; +}USART_INIT_S; + +/* USART Word Length ---------------------------------------------------------*/ +#define USART_WordLength_8b ((UINT16)0x0000) +#define USART_WordLength_9b ((UINT16)0x1000) + +/* USART Stop Bits -----------------------------------------------------------*/ +#define USART_StopBits_1 ((UINT16)0x0000) +#define USART_StopBits_0_5 ((UINT16)0x1000) +#define USART_StopBits_2 ((UINT16)0x2000) +#define USART_StopBits_1_5 ((UINT16)0x3000) + +/* USART Parity --------------------------------------------------------------*/ +#define USART_Parity_No ((UINT16)0x0000) +#define USART_Parity_Even ((UINT16)0x0400) +#define USART_Parity_Odd ((UINT16)0x0600) + +/* USART Mode ----------------------------------------------------------------*/ +#define USART_Mode_Rx ((UINT16)0x0004) +#define USART_Mode_Tx ((UINT16)0x0008) + +/* USART Hardware Flow Control -----------------------------------------------*/ +#define USART_HardwareFlowControl_None ((UINT16)0x0000) +#define USART_HardwareFlowControl_RTS ((UINT16)0x0100) +#define USART_HardwareFlowControl_CTS ((UINT16)0x0200) +#define USART_HardwareFlowControl_RTS_CTS ((UINT16)0x0300) + +/* USART Clock ---------------------------------------------------------------*/ +#define USART_Clock_Disable ((UINT16)0x0000) +#define USART_Clock_Enable ((UINT16)0x0800) + +/* USART Clock Polarity ------------------------------------------------------*/ +#define USART_CPOL_Low ((UINT16)0x0000) +#define USART_CPOL_High ((UINT16)0x0400) + +/* USART Clock Phase ---------------------------------------------------------*/ +#define USART_CPHA_1Edge ((UINT16)0x0000) +#define USART_CPHA_2Edge ((UINT16)0x0200) + + +/* USART Last Bit ------------------------------------------------------------*/ +#define USART_LastBit_Disable ((UINT16)0x0000) +#define USART_LastBit_Enable ((UINT16)0x0100) + +enum GPIOSpeed_TypeDef +{ + GPIO_Speed_10MHz = 1, + GPIO_Speed_2MHz, + GPIO_Speed_50MHz +}; + +enum GPIOMode_TypeDef +{ GPIO_Mode_AIN = 0x0, + GPIO_Mode_IN_FLOATING = 0x04, + GPIO_Mode_IPD = 0x28, + GPIO_Mode_IPU = 0x48, + GPIO_Mode_Out_OD = 0x14, + GPIO_Mode_Out_PP = 0x10, + GPIO_Mode_AF_OD = 0x1C, + GPIO_Mode_AF_PP = 0x18 +}; + +typedef struct +{ + UINT16 GPIO_Pin; + enum GPIOSpeed_TypeDef GPIO_Speed; + enum GPIOMode_TypeDef GPIO_Mode; +}GPIO_InitTypeDef; + +typedef struct +{ + volatile UINT32 CRL; + volatile UINT32 CRH; + volatile UINT32 IDR; + volatile UINT32 ODR; + volatile UINT32 BSRR; + volatile UINT32 BRR; + volatile UINT32 LCKR; +}GPIO_TypeDef; + +VOID GPIO_Init(GPIO_TypeDef * pGPIO, GPIO_InitTypeDef * GPIO_InitStruct) +{ + UINT32 currentmode = 0x00, currentpin = 0x00, pinpos = 0x00, pos = 0x00; + UINT32 tmpreg = 0x00, pinmask = 0x00; + +/*---------------------------- GPIO Mode Configuration -----------------------*/ + currentmode = ((UINT32)GPIO_InitStruct->GPIO_Mode) & ((UINT32)0x0F); + + if ((((UINT32)GPIO_InitStruct->GPIO_Mode) & ((UINT32)0x10)) != 0x00) + { + /* Output mode */ + currentmode |= (UINT32)GPIO_InitStruct->GPIO_Speed; + } + +/*---------------------------- GPIO CRL Configuration ------------------------*/ + /* Configure the eight low port pins */ + if (((UINT32)GPIO_InitStruct->GPIO_Pin & ((UINT32)0x00FF)) != 0x00) + { + tmpreg = pGPIO->CRL; + + for (pinpos = 0x00; pinpos < 0x08; pinpos++) + { + pos = ((UINT32)0x01) << pinpos; + /* Get the port pins position */ + currentpin = (GPIO_InitStruct->GPIO_Pin) & pos; + + if (currentpin == pos) + { + pos = pinpos << 2; + /* Clear the corresponding low control register bits */ + pinmask = ((UINT32)0x0F) << pos; + tmpreg &= ~pinmask; + + /* Write the mode configuration in the corresponding bits */ + tmpreg |= (currentmode << pos); + + /* Reset the corresponding ODR bit */ + if (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_IPD) + { + pGPIO->BRR = (((UINT32)0x01) << pinpos); + } + /* Set the corresponding ODR bit */ + if (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_IPU) + { + pGPIO->BSRR = (((UINT32)0x01) << pinpos); + } + } + } + pGPIO->CRL = tmpreg; + } +/*---------------------------- GPIO CRH Configuration ------------------------*/ + /* Configure the eight high port pins */ + if (GPIO_InitStruct->GPIO_Pin > 0x00FF) + { + tmpreg = pGPIO->CRH; + for (pinpos = 0x00; pinpos < 0x08; pinpos++) + { + pos = (((UINT32)0x01) << (pinpos + 0x08)); + /* Get the port pins position */ + currentpin = ((GPIO_InitStruct->GPIO_Pin) & pos); + if (currentpin == pos) + { + pos = pinpos << 2; + /* Clear the corresponding high control register bits */ + pinmask = ((UINT32)0x0F) << pos; + tmpreg &= ~pinmask; + + /* Write the mode configuration in the corresponding bits */ + tmpreg |= (currentmode << pos); + + /* Reset the corresponding ODR bit */ + if (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_IPD) + { + pGPIO->BRR = (((UINT32)0x01) << (pinpos + 0x08)); + } + /* Set the corresponding ODR bit */ + if (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_IPU) + { + pGPIO->BSRR = (((UINT32)0x01) << (pinpos + 0x08)); + } + } + } + pGPIO->CRH = tmpreg; + } +} + +UINT32 USART_Init(USART_MAP_S * USARTx, USART_INIT_S * pstInitParam) +{ + UINT32 tmpreg; + UINT32 apbclock; + UINT32 integerdivider; + UINT32 fractionaldivider; + + /*---------------------------- USART CR2 Configuration -----------------------*/ + tmpreg = USARTx->CR2; + /* Clear STOP[13:12], CLKEN, CPOL, CPHA and LBCL bits */ + tmpreg &= 0xC0FF; + + /* Configure the USART Stop Bits, Clock, CPOL, CPHA and LastBit ------------*/ + /* Set STOP[13:12] bits according to USART_Mode value */ + /* Set CPOL bit according to USART_CPOL value */ + /* Set CPHA bit according to USART_CPHA value */ + /* Set LBCL bit according to USART_LastBit value */ + tmpreg |= (UINT32)pstInitParam->USART_StopBits | pstInitParam->USART_Clock | + pstInitParam->USART_CPOL | pstInitParam->USART_CPHA | + pstInitParam->USART_LastBit; + + /* Write to USART CR2 */ + USARTx->CR2 = (UINT16)tmpreg; + + /*---------------------------- USART CR1 Configuration -----------------------*/ + tmpreg = 0x00; + tmpreg = USARTx->CR1; + /* Clear M, PCE, PS, TE and RE bits */ + tmpreg &= 0xE9F3; + + /* Configure the USART Word Length, Parity and mode ----------------------- */ + /* Set the M bits according to USART_WordLength value */ + /* Set PCE and PS bits according to USART_Parity value */ + /* Set TE and RE bits according to USART_Mode value */ + tmpreg |= (UINT32)pstInitParam->USART_WordLength | pstInitParam->USART_Parity | + pstInitParam->USART_Mode; + + /* Write to USART CR1 */ + USARTx->CR1 = (UINT16)tmpreg; + + /*---------------------------- USART CR3 Configuration -----------------------*/ + tmpreg = 0x00; + tmpreg = USARTx->CR3; + /* Clear CTSE and RTSE bits */ + tmpreg &= 0xFCFF; + + /* Configure the USART HFC -------------------------------------------------*/ + /* Set CTSE and RTSE bits according to USART_HardwareFlowControl value */ + tmpreg |= pstInitParam->USART_HardwareFlowControl; + + /* Write to USART CR3 */ + USARTx->CR3 = (UINT16)tmpreg; + + /*---------------------------- USART BRR Configuration -----------------------*/ + tmpreg = 0x00; + + /* Configure the USART Baud Rate -------------------------------------------*/ + if ((*(UINT32*)&USARTx) == OS_USART1) + { + apbclock = 8000000; + } + else + { + apbclock = 36000000; + } + + /* Determine the integer part */ + integerdivider = ((0x19 * apbclock) / (0x04 * (pstInitParam->USART_BaudRate))); + tmpreg = (integerdivider / 0x64) << 0x04; + + /* Determine the fractional part */ + fractionaldivider = integerdivider - (0x64 * (tmpreg >> 0x04)); + tmpreg |= ((((fractionaldivider * 0x10) + 0x32) / 0x64)) & ((UINT8)0x0F); + + /* Write to USART BRR */ + USARTx->BRR = (UINT16)tmpreg; + + /* UART enable */ + USARTx->CR1 |= 0x2000; + + return LOS_OK; +} + +int fputc(int ch, FILE *f) +{ + USART_MAP_S * USARTx = (USART_MAP_S *)OS_USART_USR; + + USARTx->DR = (UINT8)ch; + + while((USARTx->SR & 0x80) == 0); + + return ch; +} + +void uart_puts(char * s) +{ + USART_MAP_S * USARTx = (USART_MAP_S *)OS_USART_USR; + + while (*s) + { + USARTx->DR = *s++; + while((USARTx->SR & 0x80) == 0); + } +} + +UINT32 LOS_UartBaseInit(void) +{ + GPIO_InitTypeDef GPIO_InitStructure; + USART_INIT_S USART_InitStructure; + USART_MAP_S * USARTx = (USART_MAP_S *)OS_USART_USR; + + /* uart rcc enable */ +#if (OS_USART_USR == OS_USART1) + *(volatile UINT32 *)(RCC_REG_BASE + RCC_APB2ENR_OFFSET) |= RCC_APBENR_USART_EN; +#else + *(volatile UINT32 *)(RCC_REG_BASE + RCC_APB1ENR_OFFSET) |= RCC_APBENR_USART_EN; +#endif + + /* Configure USARTx_Tx as alternate function push-pull */ + GPIO_InitStructure.GPIO_Pin = GPIO_TxPin; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; + GPIO_Init((GPIO_TypeDef*)GPIOx, &GPIO_InitStructure); + + /* Configure USARTx_Rx as input floating */ + GPIO_InitStructure.GPIO_Pin = GPIO_RxPin; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; + GPIO_Init((GPIO_TypeDef*)GPIOx, &GPIO_InitStructure); + + USART_InitStructure.USART_BaudRate = 115200; + USART_InitStructure.USART_WordLength = USART_WordLength_8b; + USART_InitStructure.USART_StopBits = USART_StopBits_1; + USART_InitStructure.USART_Parity = USART_Parity_No ; + USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; + USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx; + + USART_InitStructure.USART_Clock = USART_Clock_Disable; + USART_InitStructure.USART_CPOL = USART_CPOL_Low; + USART_InitStructure.USART_CPHA = USART_CPHA_2Edge; + USART_InitStructure.USART_LastBit = USART_LastBit_Disable; + + + USART_Init(USARTx, &USART_InitStructure); + + return 0; +} diff --git a/targets/cortex-m3_stm32f103_simulator_keil/main.c b/targets/cortex-m3_stm32f103_simulator_keil/main.c new file mode 100755 index 00000000..9a820fd8 --- /dev/null +++ b/targets/cortex-m3_stm32f103_simulator_keil/main.c @@ -0,0 +1,135 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. + * Description: 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. + * --------------------------------------------------------------------------- + * 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" +#include "los_interrupt.h" +#include "los_debug.h" +#include "los_compiler.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +#pragma data_alignment=8 +UINT8 g_memStart[OS_SYS_MEM_SIZE]; + +VOID taskSampleEntry2(VOID) +{ + UINT32 uwRet; + while(1) { + LOS_TaskDelay(10000); + printf("taskSampleEntry2 running...\n"); + } +} + + +VOID taskSampleEntry1(VOID) +{ + UINT32 uwRet; + while(1) { + LOS_TaskDelay(2000); + printf("taskSampleEntry1 running...\n"); + } + +} + +UINT32 taskSample(VOID) +{ + UINT32 uwRet; + 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); + + stTask1.pfnTaskEntry = (TSK_ENTRY_FUNC)taskSampleEntry2; + stTask1.uwStackSize = 0X1000; + stTask1.pcName = "taskSampleEntry2"; + stTask1.usTaskPrio = 7; + uwRet = LOS_TaskCreate(&taskID2, &stTask1); + + return LOS_OK; +} + + +void LOS_HardBootInit() +{ + UINT32 uwRet = LOS_OK; + + uwRet = LOS_UartBaseInit(); + if (uwRet != LOS_OK) + { + return ; + } + + return ; +} + + +/***************************************************************************** + Function : main + Description : Main function entry + Input : None + Output : None + Return : None + *****************************************************************************/ +LITE_OS_SEC_TEXT_INIT int main(void) +{ + unsigned int ret; + + //USART_Config(); + + printf("\n\rhello world!!\n\r"); + + ret = LOS_KernelInit(); + taskSample(); + if (ret == LOS_OK) { + LOS_Start(); + } + + while (1) { + __asm volatile("wfi"); + } +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/targets/cortex-m3_stm32f103_simulator_keil/project/los_demo.sct b/targets/cortex-m3_stm32f103_simulator_keil/project/los_demo.sct new file mode 100755 index 00000000..c9230778 --- /dev/null +++ b/targets/cortex-m3_stm32f103_simulator_keil/project/los_demo.sct @@ -0,0 +1,24 @@ +; ************************************************************* +; *** Scatter-Loading Description File generated by uVision *** +; ************************************************************* + +LR_IROM1 0x08000000 0x00200000 { ; load region size_region + ER_IROM1 0x08000000 0x00200000 { ; load address = execution address + LOS_vendor.o (RESET, +First) + *(InRoot$$Sections) + * (+RO) + } + RW_IRAM1 0x20000000 0x00200000 { ; RW data + * (.data, .bss, .data.init) + } + VECTOR 0x20200000 0x400 ; Vector + { + * (.vector) + } + + ARM_LIB_STACKHEAP 0x08100000 EMPTY 0x1000 + { + + } +} + diff --git a/targets/cortex-m3_stm32f103_simulator_keil/project/los_demo.uvopt b/targets/cortex-m3_stm32f103_simulator_keil/project/los_demo.uvopt new file mode 100755 index 00000000..fddb63dd --- /dev/null +++ b/targets/cortex-m3_stm32f103_simulator_keil/project/los_demo.uvopt @@ -0,0 +1,727 @@ + + + + 1.0 + +
### uVision Project, (C) Keil Software
+ + + *.c + *.s*; *.src; *.a* + *.obj + *.lib + *.txt; *.h; *.inc + *.plm + *.cpp + + + + 0 + 0 + + + + los_demo + 0x4 + ARM-ADS + + 8000000 + + 1 + 1 + 1 + 0 + + + 1 + 65535 + 0 + 0 + 0 + + + 79 + 66 + 8 + .\output\ + + + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + + + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + + + 1 + 0 + 1 + + 255 + + + 0 + Reference Manual + DATASHTS\ST\STM32F10xxx.PDF + + + 1 + Technical Reference Manual + datashts\arm\cortex_m3\r1p1\DDI0337E_CORTEX_M3_R1P1_TRM.PDF + + + 2 + Generic User Guide + datashts\arm\cortex_m3\r2p1\DUI0552A_CORTEX_M3_DGUG.PDF + + + + SARMCM3.DLL + + DARMSTM.DLL + -pSTM32F103RB + SARMCM3.DLL + + TARMSTM.DLL + -pSTM32F103RB + + + 1 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + + + + + + + + + + + BIN\UL2CM3.DLL + + + + 0 + DLGDARM + (1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(100=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=-1,-1,-1,-1,0)(121=-1,-1,-1,-1,0)(122=-1,-1,-1,-1,0)(123=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=-1,-1,-1,-1,0)(190=-1,-1,-1,-1,0)(200=-1,-1,-1,-1,0)(170=-1,-1,-1,-1,0)(130=-1,-1,-1,-1,0)(131=-1,-1,-1,-1,0)(132=-1,-1,-1,-1,0)(133=-1,-1,-1,-1,0)(160=-1,-1,-1,-1,0)(161=-1,-1,-1,-1,0)(162=-1,-1,-1,-1,0)(210=-1,-1,-1,-1,0)(211=-1,-1,-1,-1,0)(220=-1,-1,-1,-1,0)(221=-1,-1,-1,-1,0)(230=-1,-1,-1,-1,0)(234=-1,-1,-1,-1,0)(231=-1,-1,-1,-1,0)(232=-1,-1,-1,-1,0)(233=-1,-1,-1,-1,0)(150=-1,-1,-1,-1,0)(151=-1,-1,-1,-1,0) + + + 0 + ARMDBGFLAGS + -T0 + + + 0 + UL2CM3 + UL2CM3(-O14 -S0 -C0 -N00("ARM Cortex-M3") -D00(1BA00477) -L00(4) -FO7 -FN1 -FC800 -FD20000000 -FF0STM32F10x_128 -FL020000 -FS08000000 + + + + + 0 + + + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + liteos-m + 1 + 0 + 0 + 0 + + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\..\..\kernel\arch\arm\cortex-m3\keil\los_hw.c + los_hw.c + 0 + 0 + + + 1 + 2 + 1 + 0 + 0 + 23 + 0 + 32 + 33 + 0 + ..\..\..\kernel\arch\arm\cortex-m3\keil\los_hw_tick.c + los_hw_tick.c + 0 + 0 + + + 1 + 3 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\..\..\kernel\src\los_err.c + los_err.c + 0 + 0 + + + 1 + 4 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\..\..\kernel\src\los_event.c + los_event.c + 0 + 0 + + + 1 + 5 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\..\..\kernel\src\los_init.c + los_init.c + 0 + 0 + + + 1 + 6 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\..\..\kernel\src\los_misc.c + los_misc.c + 0 + 0 + + + 1 + 7 + 1 + 0 + 0 + 0 + 0 + 13 + 36 + 0 + ..\..\..\kernel\src\los_mux.c + los_mux.c + 0 + 0 + + + 1 + 8 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\..\..\kernel\src\los_queue.c + los_queue.c + 0 + 0 + + + 1 + 9 + 1 + 0 + 0 + 0 + 0 + 19 + 36 + 0 + ..\..\..\kernel\src\los_sem.c + los_sem.c + 0 + 0 + + + 1 + 10 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\..\..\kernel\src\los_swtmr.c + los_swtmr.c + 0 + 0 + + + 1 + 11 + 1 + 0 + 0 + 0 + 0 + 95 + 240 + 0 + ..\..\..\kernel\src\los_task.c + los_task.c + 0 + 0 + + + 1 + 12 + 1 + 0 + 0 + 22 + 0 + 11 + 33 + 0 + ..\..\..\kernel\src\los_tick.c + los_tick.c + 0 + 0 + + + 1 + 13 + 1 + 0 + 0 + 0 + 0 + 16 + 36 + 0 + ..\..\..\kernel\src\mm\los_membox.c + los_membox.c + 0 + 0 + + + 1 + 14 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\..\..\kernel\src\mm\los_memcheck.c + los_memcheck.c + 0 + 0 + + + 1 + 15 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\..\..\kernel\src\mm\los_memory.c + los_memory.c + 0 + 0 + + + 1 + 16 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\..\..\kernel\src\mm\los_memstat.c + los_memstat.c + 0 + 0 + + + 1 + 17 + 2 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\..\..\kernel\arch\arm\cortex-m3\keil\los_dispatch.S + los_dispatch.S + 0 + 0 + + + 1 + 18 + 2 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\..\..\kernel\arch\arm\cortex-m3\keil\los_hw_exc.S + los_hw_exc.S + 0 + 0 + + + 1 + 19 + 2 + 0 + 0 + 0 + 0 + 11 + 45 + 0 + ..\..\..\kernel\arch\arm\cortex-m3\keil\los_vendor.s + los_vendor.s + 0 + 0 + + + 1 + 20 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\..\..\kernel\arch\arm\cortex-m3\keil\cmsis\ARMCM3.h + ARMCM3.h + 0 + 0 + + + 1 + 21 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\..\..\kernel\arch\arm\cortex-m3\keil\cmsis\core_cm3.h + core_cm3.h + 0 + 0 + + + 1 + 22 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\..\..\kernel\arch\arm\cortex-m3\keil\cmsis\core_cmFunc.h + core_cmFunc.h + 0 + 0 + + + 1 + 23 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\..\..\kernel\arch\arm\cortex-m3\keil\cmsis\core_cmInstr.h + core_cmInstr.h + 0 + 0 + + + 1 + 24 + 1 + 0 + 0 + 22 + 0 + 370 + 33 + 0 + ..\..\..\components\cpup\los_cpup.c + los_cpup.c + 0 + 0 + + + 1 + 25 + 1 + 0 + 0 + 0 + 0 + 113 + 133 + 0 + ..\..\..\kernel\arch\arm\cortex-m3\keil\los_interrupt.c + los_interrupt.c + 0 + 0 + + + + + main + 1 + 0 + 0 + 0 + + 2 + 26 + 1 + 0 + 0 + 0 + 0 + 1 + 3 + 0 + ..\Driver\STM32F103\uart.c + uart.c + 0 + 0 + + + 2 + 27 + 1 + 0 + 0 + 0 + 0 + 92 + 118 + 0 + ..\main.c + main.c + 0 + 0 + + + + + component + 0 + 0 + 0 + 0 + + 3 + 28 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\..\..\components\bounds_checking_function\src\memcpy_s.c + memcpy_s.c + 0 + 0 + + + 3 + 29 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\..\..\components\bounds_checking_function\src\memmove_s.c + memmove_s.c + 0 + 0 + + + 3 + 30 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\..\..\components\bounds_checking_function\src\memset_s.c + memset_s.c + 0 + 0 + + + 3 + 31 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\..\..\components\bounds_checking_function\src\strcpy_s.c + strcpy_s.c + 0 + 0 + + + 3 + 32 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\..\..\components\bounds_checking_function\src\strncpy_s.c + strncpy_s.c + 0 + 0 + + + +
diff --git a/targets/cortex-m3_stm32f103_simulator_keil/project/los_demo.uvproj b/targets/cortex-m3_stm32f103_simulator_keil/project/los_demo.uvproj new file mode 100755 index 00000000..85fc34bb --- /dev/null +++ b/targets/cortex-m3_stm32f103_simulator_keil/project/los_demo.uvproj @@ -0,0 +1,571 @@ + + + + 1.1 + +
### uVision Project, (C) Keil Software
+ + + + los_demo + 0x4 + ARM-ADS + + + STM32F103RB + STMicroelectronics + IRAM(0x20000000-0x20004FFF) IROM(0x8000000-0x801FFFF) CLOCK(8000000) CPUTYPE("Cortex-M3") + + "STARTUP\ST\STM32F10x\startup_stm32f10x_md.s" ("STM32 Medium Density Line Startup Code") + UL2CM3(-O14 -S0 -C0 -N00("ARM Cortex-M3") -D00(1BA00477) -L00(4) -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F10x_128 -FS08000000 -FL020000) + 4231 + stm32f10x.h + + + + + + + + + + SFD\ST\STM32F1xx\STM32F103xx.sfr + 0 + + + + ST\STM32F10x\ + ST\STM32F10x\ + + 0 + 0 + 0 + 0 + 1 + + .\output\ + los_demo + 1 + 0 + 0 + 1 + 1 + .\output\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + + + 0 + 0 + + + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + + + SARMCM3.DLL + + DARMSTM.DLL + -pSTM32F103RB + SARMCM3.DLL + + TARMSTM.DLL + -pSTM32F103RB + + + + 1 + 0 + 0 + 0 + 16 + + + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + + + 0 + 1 + 0 + 1 + 1 + 1 + 0 + 1 + 1 + + 0 + 0 + + + + + + + + + + + + + + BIN\UL2CM3.DLL + + + + + 1 + 0 + 0 + 1 + 0 + -1 + + 1 + BIN\UL2CM3.DLL + + + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + "Cortex-M3" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 0 + 0 + 3 + 3 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x5000 + + + 1 + 0x8000000 + 0x20000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x8000000 + 0x200000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x500000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 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 + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + 0 + 1 + 0 + 0x08000000 + 0x20000000 + .\los_demo.sct + + + + + + + + + + + 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_err.c + 1 + ..\..\..\kernel\src\los_err.c + + + los_event.c + 1 + ..\..\..\kernel\src\los_event.c + + + los_init.c + 1 + ..\..\..\kernel\src\los_init.c + + + los_misc.c + 1 + ..\..\..\kernel\src\los_misc.c + + + los_mux.c + 1 + ..\..\..\kernel\src\los_mux.c + + + los_queue.c + 1 + ..\..\..\kernel\src\los_queue.c + + + los_sem.c + 1 + ..\..\..\kernel\src\los_sem.c + + + los_swtmr.c + 1 + ..\..\..\kernel\src\los_swtmr.c + + + los_task.c + 1 + ..\..\..\kernel\src\los_task.c + + + los_tick.c + 1 + ..\..\..\kernel\src\los_tick.c + + + los_membox.c + 1 + ..\..\..\kernel\src\mm\los_membox.c + + + los_memcheck.c + 1 + ..\..\..\kernel\src\mm\los_memcheck.c + + + los_memory.c + 1 + ..\..\..\kernel\src\mm\los_memory.c + + + los_memstat.c + 1 + ..\..\..\kernel\src\mm\los_memstat.c + + + los_dispatch.S + 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 + ..\..\..\kernel\arch\arm\cortex-m3\keil\cmsis\ARMCM3.h + + + core_cm3.h + 5 + ..\..\..\kernel\arch\arm\cortex-m3\keil\cmsis\core_cm3.h + + + core_cmFunc.h + 5 + ..\..\..\kernel\arch\arm\cortex-m3\keil\cmsis\core_cmFunc.h + + + core_cmInstr.h + 5 + ..\..\..\kernel\arch\arm\cortex-m3\keil\cmsis\core_cmInstr.h + + + los_cpup.c + 1 + ..\..\..\components\cpup\los_cpup.c + + + los_interrupt.c + 1 + ..\..\..\kernel\arch\arm\cortex-m3\keil\los_interrupt.c + + + + + main + + + uart.c + 1 + ..\Driver\STM32F103\uart.c + + + main.c + 1 + ..\main.c + + + + + component + + + memcpy_s.c + 1 + ..\..\..\components\bounds_checking_function\src\memcpy_s.c + + + memmove_s.c + 1 + ..\..\..\components\bounds_checking_function\src\memmove_s.c + + + memset_s.c + 1 + ..\..\..\components\bounds_checking_function\src\memset_s.c + + + strcpy_s.c + 1 + ..\..\..\components\bounds_checking_function\src\strcpy_s.c + + + strncpy_s.c + 1 + ..\..\..\components\bounds_checking_function\src\strncpy_s.c + + + + + + + +
diff --git a/targets/cortex-m3_stm32f103_simulator_keil/target_config.h b/targets/cortex-m3_stm32f103_simulator_keil/target_config.h new file mode 100755 index 00000000..8c59f5eb --- /dev/null +++ b/targets/cortex-m3_stm32f103_simulator_keil/target_config.h @@ -0,0 +1,438 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. + * Description: 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. + * --------------------------------------------------------------------------- + * 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 + * @ingroup kernel + */ + +#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 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 +/*============================================================================= + 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_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_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_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 + + +/*============================================================================= + 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 + + +/*============================================================================= + 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 + + +/*============================================================================= + 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 + + +/*============================================================================= + 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_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 + + +/*============================================================================= + 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 + + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cplusplus */ +#endif /* __cplusplus */ + + +#endif /* _TARGET_CONFIG_H */ diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/dprintf.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/dprintf.c index 95e0847e..90e20b18 100755 --- a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/dprintf.c +++ b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/dprintf.c @@ -31,7 +31,7 @@ #include "stdarg.h" #include -#include "los_printf.h" +#include "los_debug.h" #include "stm32f4xx_usart.h" #include "stm324x9i_eval.h" diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/main.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/main.c index 5290ff1d..a6ce45a7 100755 --- a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/main.c +++ b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/main.c @@ -1,120 +1,120 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: 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. - * --------------------------------------------------------------------------- - * 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_sys.h" -#include "los_tick.h" -#include "los_task.h" -#include "los_config.h" -#include "los_exc.h" -#include "los_printf.h" -#include "iar_stm32f429ig_fire-challenger.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cpluscplus */ -#endif /* __cpluscplus */ - -#pragma data_alignment=8 -UINT8 g_memStart[OS_SYS_MEM_SIZE]; - -VOID taskSampleEntry2(VOID) -{ - UINT32 uwRet; - while(1) { - LOS_TaskDelay(10000); - printf("taskSampleEntry2 running...\n"); - } -} - - -VOID taskSampleEntry1(VOID) -{ - UINT32 uwRet; - while(1) { - LOS_TaskDelay(2000); - printf("taskSampleEntry1 running...\n"); - } - -} - -UINT32 taskSample(VOID) -{ - UINT32 uwRet; - 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); - - stTask1.pfnTaskEntry = (TSK_ENTRY_FUNC)taskSampleEntry2; - stTask1.uwStackSize = 0X1000; - stTask1.pcName = "taskSampleEntry2"; - stTask1.usTaskPrio = 7; - uwRet = LOS_TaskCreate(&taskID2, &stTask1); - - return LOS_OK; -} - -/***************************************************************************** - Function : main - Description : Main function entry - Input : None - Output : None - Return : None - *****************************************************************************/ -LITE_OS_SEC_TEXT_INIT int main(void) -{ - unsigned int ret; - - USART_Config(); - - printf("\n\rhello world!!\n\r"); - - ret = LOS_KernelInit(); - taskSample(); - if (ret == LOS_OK) { - LOS_Start(); - } - - while (1) { - __asm volatile("wfi"); - } -} - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cpluscplus */ -#endif /* __cpluscplus */ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. + * Description: 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. + * --------------------------------------------------------------------------- + * 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" +#include "los_interrupt.h" +#include "los_debug.h" +#include "los_compiler.h" +#include "iar_stm32f429ig_fire-challenger.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +#pragma data_alignment=8 +UINT8 g_memStart[OS_SYS_MEM_SIZE]; + +VOID taskSampleEntry2(VOID) +{ + UINT32 uwRet; + while(1) { + LOS_TaskDelay(10000); + printf("taskSampleEntry2 running...\n"); + } +} + + +VOID taskSampleEntry1(VOID) +{ + UINT32 uwRet; + while(1) { + LOS_TaskDelay(2000); + printf("taskSampleEntry1 running...\n"); + } + +} + +UINT32 taskSample(VOID) +{ + UINT32 uwRet; + 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); + + stTask1.pfnTaskEntry = (TSK_ENTRY_FUNC)taskSampleEntry2; + stTask1.uwStackSize = 0X1000; + stTask1.pcName = "taskSampleEntry2"; + stTask1.usTaskPrio = 7; + uwRet = LOS_TaskCreate(&taskID2, &stTask1); + + return LOS_OK; +} + +/***************************************************************************** + Function : main + Description : Main function entry + Input : None + Output : None + Return : None + *****************************************************************************/ +LITE_OS_SEC_TEXT_INIT int main(void) +{ + unsigned int ret; + + USART_Config(); + + printf("\n\rhello world!!\n\r"); + + ret = LOS_KernelInit(); + taskSample(); + if (ret == LOS_OK) { + LOS_Start(); + } + + while (1) { + __asm volatile("wfi"); + } +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ 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 index 6035e5b1..ae8b9ba1 100755 --- 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,589 +1,273 @@ 2 - 1016431235 + 3664498414 Debug - $PROJ_DIR$\..\..\..\components\bounds_checking_function\include\securec.h - $PROJ_DIR$\..\..\..\components\bounds_checking_function\include\securectype.h - $PROJ_DIR$\..\..\..\kernel\src\los_err.c - $PROJ_DIR$\..\..\..\kernel\src\los_misc.c - $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw.c - $PROJ_DIR$\..\..\..\components\cpup\los_cpup.c - $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_exc.c - $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_exc_iar.S - $PROJ_DIR$\..\..\..\kernel\src\mm\los_membox.c - $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_dispatch_iar.S - $PROJ_DIR$\..\..\..\kernel\src\mm\los_multipledlinkhead.c - $PROJ_DIR$\..\..\..\kernel\src\los_mux.c - $PROJ_DIR$\..\..\..\kernel\src\los_event.c - $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_tick.c - $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hwi.c - $PROJ_DIR$\..\..\..\kernel\src\los_init.c - $PROJ_DIR$\..\..\..\kernel\src\mm\los_memstat.c - $PROJ_DIR$\..\..\..\kernel\src\los_priqueue.c - $PROJ_DIR$\..\..\..\kernel\src\los_queue.c - $PROJ_DIR$\..\..\..\kernel\src\mm\los_memcheck.c - $PROJ_DIR$\..\..\..\kernel\src\mm\los_memory.c - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_spdifrx.h - $PROJ_DIR$\..\..\..\kernel\include\los_typedef.h - $PROJ_DIR$\Debug\Obj\los_hw_tick.o - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_dac.c - $PROJ_DIR$\Debug\Obj\stm32f4xx_hash_sha1.o - $PROJ_DIR$\Debug\Obj\stm32f4xx_hash_sha1.__cstat.et - $PROJ_DIR$\Debug\Obj\stm32f4xx_dma2d.pbi - $PROJ_DIR$\Debug\Obj\los_task.__cstat.et - $PROJ_DIR$\Debug\Obj\main.pbi - $PROJ_DIR$\Debug\Obj\stm32f4xx_gpio.o - $PROJ_DIR$\Debug\Obj\stm32f4xx_cryp_aes.o - $PROJ_DIR$\Debug\Obj\stm32f4xx_can.o - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_rng.c - $PROJ_DIR$\..\..\..\kernel\src\los_memcheck_pri.h - $PROJ_DIR$\Debug\Obj\los_exc.__cstat.et - $PROJ_DIR$\..\..\..\kernel\include\los_sys.h - $PROJ_DIR$\..\..\..\kernel\include\los_compiler.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_spi.pbi - $PROJ_DIR$\Debug\Obj\stm32f4xx_fmpi2c.pbi - $PROJ_DIR$\Debug\Obj\stm32f4xx_wwdg.pbi - $TOOLKIT_DIR$\inc\c\DLib_Product_string.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_cryp_aes.__cstat.et - $PROJ_DIR$\Debug\Obj\los_err.pbi - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_spdifrx.c - $PROJ_DIR$\..\..\..\kernel\src\los_memstat_pri.h - $PROJ_DIR$\..\..\..\components\cpup\los_cpup_pri.h - $PROJ_DIR$\Debug\Obj\los_err.o - $PROJ_DIR$\..\Utilities\STM32_EVAL\Common\fonts.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_fsmc.pbi - $PROJ_DIR$\Debug\Obj\system_stm32f4xx.pbi - $PROJ_DIR$\..\Utilities\STM32_EVAL\Common\lcd_log.c - $PROJ_DIR$\Debug\Obj\los_priqueue.o - $PROJ_DIR$\Debug\Obj\los_hw_tick.pbi - $TOOLKIT_DIR$\inc\c\DLib_Defaults.h - $TOOLKIT_DIR$\inc\c\DLib_Product_stdlib.h - $PROJ_DIR$\Debug\Obj\stm324x9i_eval_ioe16.pbi - $PROJ_DIR$\..\..\..\kernel\src\los_timeslice_pri.h - $PROJ_DIR$\Debug\Obj\stm324x9i_eval.o - $PROJ_DIR$\Debug\Obj\stm324x9i_eval_audio_codec.o - $PROJ_DIR$\Debug\Obj\los_task.o - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_hash_md5.c - $PROJ_DIR$\..\..\..\kernel\src\los_priqueue_pri.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_fmpi2c.__cstat.et - $PROJ_DIR$\Debug\Obj\stm32f4xx_crc.pbi - $PROJ_DIR$\..\..\..\utils\bounds_checking_function\include\securectype.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_adc.__cstat.et - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_cryp_tdes.c - $PROJ_DIR$\Debug\Obj\stm32f4xx_sdio.o - $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_sleep.c - $PROJ_DIR$\Debug\Obj\los_sem.o - $PROJ_DIR$\..\..\..\kernel\include\los_base.h - $PROJ_DIR$\..\..\..\kernel\include\los_queue.h - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_spi.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_dma.__cstat.et - $PROJ_DIR$\Debug\Obj\stm32f4xx_crc.__cstat.et - $PROJ_DIR$\Debug\Obj\stm32f4xx_hash.__cstat.et - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_usart.h - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_flash.c - $PROJ_DIR$\Debug\Obj\stm32f4xx_rng.pbi - $PROJ_DIR$\Debug\Obj\stm32f4xx_sai.pbi - $PROJ_DIR$\Debug\Obj\stm32f4xx_hash_md5.pbi - $PROJ_DIR$\Debug\Obj\stm32f4xx_exti.__cstat.et - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_rtc.c - $PROJ_DIR$\..\..\..\kernel\include\los_err.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_flash_ramfunc.o - $PROJ_DIR$\..\..\..\kernel\src\los_tick_pri.h - $PROJ_DIR$\..\Utilities\STM32_EVAL\Common\lcd_log.h - $PROJ_DIR$\Debug\Obj\los_multipledlinkhead.__cstat.et - $PROJ_DIR$\Debug\Obj\stm324x9i_eval_fmc_nor.pbi - $PROJ_DIR$\Debug\Obj\stm32f4xx_i2c.o - $PROJ_DIR$\..\..\..\kernel\src\mem_to_rename\los_memstat.c - $PROJ_DIR$\Debug\Obj\los_sys.__cstat.et - $PROJ_DIR$\Debug\Obj\stm32f4xx_i2c.pbi - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_qspi.c - $PROJ_DIR$\Debug\Obj\los_memory.o - $PROJ_DIR$\Debug\Obj\los_hwi.o - $PROJ_DIR$\Debug\Obj\stm32f4xx_cryp.o - $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_exc.h - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_ltdc.c - $PROJ_DIR$\..\Libraries\CMSIS\Device\ST\STM32F4xx\Include\stm32f4xx.h - $PROJ_DIR$\..\..\..\kernel\src\mem_to_rename\los_memory.c - $PROJ_DIR$\Debug\Obj\stm32f4xx_rcc.o - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_hash_sha1.c - $PROJ_DIR$\Debug\Obj\dprintf.pbi - $PROJ_DIR$\Debug\Obj\stm32f4xx_spdifrx.o - $PROJ_DIR$\Debug\Obj\stm32f4xx_dcmi.__cstat.et - $PROJ_DIR$\Debug\Obj\los_misc.o - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_fsmc.h - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\misc.h - $PROJ_DIR$\Debug\Obj\stm324x9i_eval_lcd.pbi - $TOOLKIT_DIR$\inc\c\stdio.h - $TOOLKIT_DIR$\inc\c\errno.h - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_sdio.h - $PROJ_DIR$\..\..\..\kernel\src\los_memory_pri.h - $PROJ_DIR$\..\..\..\kernel\src\los_sr.h - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_dbgmcu.h - $PROJ_DIR$\..\..\..\kernel\src\mem_to_rename\los_multipledlinkhead.c - $TOOLKIT_DIR$\lib\m7M_tls.a - $PROJ_DIR$\Debug\Obj\stm32f4xx_syscfg.__cstat.et - $PROJ_DIR$\Debug\Obj\stm32f4xx_cec.pbi - $PROJ_DIR$\Debug\Obj\los_membox.o - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_cryp_aes.c - $PROJ_DIR$\Debug\Obj\stm32f4xx_iwdg.__cstat.et - $PROJ_DIR$\Debug\Obj\stm32f4xx_dac.o - $PROJ_DIR$\..\..\..\kernel\src\mem_to_rename\los_membox.c - $PROJ_DIR$\Debug\Obj\stm32f4xx_hash_sha1.pbi - $PROJ_DIR$\..\..\..\kernel\src\mem_to_rename\los_memcheck.c - $PROJ_DIR$\Debug\Obj\stm32f4xx_lptim.pbi - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_hash.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_usart.o - $PROJ_DIR$\Debug\Obj\stm32f4xx_sdio.pbi - $PROJ_DIR$\Debug\Obj\los_multipledlinkhead.pbi - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_fmpi2c.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_crc.o - $PROJ_DIR$\Debug\Obj\stm32f4xx_cryp_tdes.__cstat.et - $PROJ_DIR$\Debug\Obj\misc.__cstat.et - $TOOLKIT_DIR$\lib\dl7M_tlf.a - $PROJ_DIR$\Debug\Obj\stm32f4xx_hash_md5.o - $TOOLKIT_DIR$\inc\c\DLib_Config_Full.h - $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw.h - $PROJ_DIR$\Debug\Obj\los_sleep.o - $PROJ_DIR$\..\..\..\kernel\include\los_printf.h - $TOOLKIT_DIR$\lib\rt7M_tl.a - $PROJ_DIR$\Debug\Obj\stm32f4xx_wwdg.o - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_spi.c - $PROJ_DIR$\Debug\Obj\stm32f4xx_can.pbi - $PROJ_DIR$\Debug\Obj\stm32f4xx_pwr.pbi - $PROJ_DIR$\Debug\Obj\stm32f4xx_fmc.pbi - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_dma.h - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_sai.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_rng.__cstat.et - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_flash_ramfunc.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_pwr.o - $PROJ_DIR$\Debug\Obj\stm32f4xx_gpio.pbi - $PROJ_DIR$\..\..\..\components\cpup\los_cpup.h - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_dac.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_gpio.__cstat.et - $PROJ_DIR$\Debug\Obj\stm32f4xx_wwdg.__cstat.et - $PROJ_DIR$\Debug\Obj\stm32f4xx_adc.o - $PROJ_DIR$\Debug\Obj\stm32f4xx_cec.__cstat.et - $PROJ_DIR$\..\..\..\kernel\include\los_event.h - $PROJ_DIR$\Debug\Obj\los_memstat.o - $PROJ_DIR$\Debug\Obj\stm32f4xx_cryp_tdes.pbi - $PROJ_DIR$\Debug\Obj\stm32f4xx_dac.pbi - $TOOLKIT_DIR$\inc\c\stdarg.h - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_cec.c - $PROJ_DIR$\Debug\Obj\stm32f4xx_flash_ramfunc.__cstat.et - $PROJ_DIR$\Debug\Obj\los_priqueue.__cstat.et - $PROJ_DIR$\Debug\Obj\stm32f4xx_cryp_des.pbi - $PROJ_DIR$\..\board\iar_stm32f429ig_fire-challenger.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_spdifrx.__cstat.et - $PROJ_DIR$\Debug\Obj\stm32f4xx_cryp_des.__cstat.et - $PROJ_DIR$\Debug\Obj\stm32f4xx_flash_ramfunc.pbi - $PROJ_DIR$\Debug\Obj\iar_stm32f429ig_fire-challenger.pbi - $PROJ_DIR$\Debug\Obj\stm32f4xx_lptim.o - $PROJ_DIR$\Debug\Obj\los_hw_exc_iar.o - $PROJ_DIR$\Debug\Obj\los_init.__cstat.et - $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval_audio_codec.c - $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval_ioe16.h - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_sdio.c - $PROJ_DIR$\Debug\Obj\stm32f4xx_cryp.pbi - $PROJ_DIR$\..\..\..\utils\print_std\los_printf.c - $PROJ_DIR$\Debug\Obj\stm32f4xx_dfsdm.pbi - $PROJ_DIR$\Debug\Obj\stm32f4xx_iwdg.pbi + $PROJ_DIR$\..\..\..\kernel\src\los_timeslice.c $PROJ_DIR$\Debug\Obj\system_stm32f4xx.o - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_dsi.h - $PROJ_DIR$\..\stm32f4xx_conf.h - $PROJ_DIR$\Debug\Obj\main.o - $PROJ_DIR$\Debug\Obj\los_dispatch_iar.o - $TOOLKIT_DIR$\CMSIS\Include\core_cm4.h - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_i2c.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_cryp_des.o - $PROJ_DIR$\Debug\Obj\misc.pbi - $PROJ_DIR$\..\..\..\kernel\src\los_multipledlinkhead_pri.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_ltdc.pbi - $PROJ_DIR$\Debug\Obj\stm32f4xx_cryp_tdes.o - $PROJ_DIR$\Debug\Obj\stm32f4xx_rtc.__cstat.et - $PROJ_DIR$\Debug\List\los_demo.map - $PROJ_DIR$\Debug\Obj\stm324x9i_eval_ioe16.o - $TOOLKIT_DIR$\inc\c\stdlib.h - $PROJ_DIR$\..\..\..\kernel\include\los_task.h - $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval_sdio_sd.h - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_gpio.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_spi.__cstat.et - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_lptim.c - $PROJ_DIR$\Debug\Obj\stm32f4xx_syscfg.pbi - $PROJ_DIR$\Debug\Obj\stm32f4xx_dsi.o - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_tim.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_dbgmcu.o - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_dcmi.c - $PROJ_DIR$\Debug\Obj\los_memstat.__cstat.et - $PROJ_DIR$\Debug\Obj\stm32f4xx_rcc.pbi - $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval_lcd.h - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_fmpi2c.c - $PROJ_DIR$\Debug\Obj\stm32f4xx_fsmc.__cstat.et - $PROJ_DIR$\..\..\..\kernel\src\los_swtmr_pri.h - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_qspi.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_exti.pbi - $PROJ_DIR$\..\..\..\kernel\src\los_sys_pri.h - $PROJ_DIR$\Debug\Obj\los_sleep.pbi - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_i2c.c - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_dcmi.h - $TOOLKIT_DIR$\inc\c\ycheck.h + $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_context.h + $PROJ_DIR$\Debug\Obj\los_sem.o + $PROJ_DIR$\Debug\Obj\los_init.pbi + $PROJ_DIR$\Debug\Obj\los_init.o + $PROJ_DIR$\Debug\Obj\los_swtmr.o + $PROJ_DIR$\Debug\Obj\los_misc.pbi + $PROJ_DIR$\Debug\Obj\los_memstat.o + $PROJ_DIR$\Debug\Obj\los_sys.o + $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval.h + $PROJ_DIR$\Debug\Obj\los_event.pbi + $PROJ_DIR$\Debug\Obj\los_priqueue.pbi + $PROJ_DIR$\Debug\Obj\stm324x9i_eval.pbi + $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_exc_iar.S + $PROJ_DIR$\Debug\Obj\los_hw_tick.__cstat.et + $PROJ_DIR$\Debug\Obj\los_err.o + $PROJ_DIR$\Debug\Obj\stm32f4xx_rcc.o + $PROJ_DIR$\Debug\Obj\los_task.o + $PROJ_DIR$\Debug\Obj\los_err.pbi + $PROJ_DIR$\Debug\Obj\los_misc.o $PROJ_DIR$\Debug\Obj\los_timeslice.o - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_pwr.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_dsi.__cstat.et - $PROJ_DIR$\Debug\Obj\los_tick.__cstat.et - $PROJ_DIR$\Debug\Obj\stm324x9i_eval_fmc_sram.pbi - $PROJ_DIR$\Debug\Obj\stm32f4xx_syscfg.o + $PROJ_DIR$\Debug\Obj\los_task.pbi + $PROJ_DIR$\Debug\Obj\los_sem.pbi + $PROJ_DIR$\Debug\Obj\los_tick.o + $PROJ_DIR$\Debug\Obj\los_membox.o + $PROJ_DIR$\Debug\Obj\los_swtmr.pbi + $PROJ_DIR$\Debug\Obj\los_memcheck.o + $PROJ_DIR$\Debug\Obj\stm324x9i_eval.o + $PROJ_DIR$\Debug\Obj\los_tick.pbi + $PROJ_DIR$\Debug\Obj\los_event.o + $PROJ_DIR$\Debug\Obj\stm32f4xx_gpio.pbi + $TOOLKIT_DIR$\lib\shb_l.a + $PROJ_DIR$\Debug\Obj\stm32f4xx_rcc.__cstat.et + $PROJ_DIR$\Debug\Obj\stm32f4xx_wwdg.__cstat.et + $TOOLKIT_DIR$\lib\rt7M_tl.a + $PROJ_DIR$\Debug\Obj\los_priqueue.__cstat.et + $PROJ_DIR$\Debug\Obj\los_sem.__cstat.et + $PROJ_DIR$\Debug\Obj\iar_stm32f429ig_fire-challenger.pbi + $PROJ_DIR$\Debug\Obj\stm32f4xx_tim.__cstat.et + $TOOLKIT_DIR$\lib\m7M_tls.a + $PROJ_DIR$\Debug\Obj\stm324x9i_eval.__cstat.et + $PROJ_DIR$\..\stm32f4xx_conf.h + $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_dispatch_iar.S + $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_exc.c + $PROJ_DIR$\Debug\Obj\stm32f4xx_exti.__cstat.et + $PROJ_DIR$\Debug\Obj\misc.__cstat.et + $PROJ_DIR$\Debug\Obj\los_task.__cstat.et + $PROJ_DIR$\Debug\Obj\los_mux.__cstat.et + $PROJ_DIR$\Debug\Obj\stm32f4xx_usart.__cstat.et + $TOOLKIT_DIR$\inc\c\cmsis_iar.h + $PROJ_DIR$\Debug\Obj\stm32f4xx_gpio.__cstat.et $PROJ_DIR$\Debug\Obj\startup_stm32f429_439xx.o - $PROJ_DIR$\Debug\Obj\los_mux.o - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_ltdc.h - $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hwi.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_adc.pbi + $PROJ_DIR$\Debug\Obj\los_queue.__cstat.et + $PROJ_DIR$\Debug\Obj\system_stm32f4xx.__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$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_gpio.h + $PROJ_DIR$\Debug\Obj\los_mux.pbi + $PROJ_DIR$\Debug\Obj\los_sys.__cstat.et + $PROJ_DIR$\Debug\Obj\los_tick.__cstat.et + $PROJ_DIR$\Debug\Obj\iar_stm32f429ig_fire-challenger.o + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_adc.h + $PROJ_DIR$\Debug\Obj\los_swtmr.__cstat.et + $TOOLKIT_DIR$\inc\c\DLib_Product_string.h + $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$\Debug\Obj\los_timeslice.__cstat.et + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_fmc.h + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_can.h + $PROJ_DIR$\..\..\..\components\bounds_checking_function\include\securec.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_dac.h + $TOOLKIT_DIR$\inc\c\stdint.h + $TOOLKIT_DIR$\inc\c\stdlib.h + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_sai.h + $PROJ_DIR$\Debug\Obj\los_cpup.o + $PROJ_DIR$\Debug\Obj\main.__cstat.et + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_iwdg.h + $PROJ_DIR$\Debug\Obj\iar_stm32f429ig_fire-challenger.__cstat.et + $PROJ_DIR$\..\..\..\kernel\include\los_membox.h + $TOOLKIT_DIR$\inc\c\DLib_Product_stdlib.h + $TOOLKIT_DIR$\inc\c\stddef.h + $PROJ_DIR$\..\..\..\kernel\include\los_queue.h + $PROJ_DIR$\..\..\..\kernel\include\los_tick.h + $PROJ_DIR$\..\..\..\utils\los_list.h + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_dcmi.h + $TOOLKIT_DIR$\inc\c\errno.h + $PROJ_DIR$\..\..\..\utils\los_error.h + $PROJ_DIR$\..\..\..\kernel\include\los_memory.h + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_sdio.h + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_spi.h + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_cryp.h + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_dbgmcu.h + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\misc.h $PROJ_DIR$\Debug\Obj\los_demo.pbd $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_syscfg.h - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_dfsdm.h - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_fmc.h - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_rcc.h - $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval_ioe8.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_can.__cstat.et - $PROJ_DIR$\Debug\Obj\stm32f4xx_dma2d.o - $PROJ_DIR$\Debug\Obj\los_queue.__cstat.et - $PROJ_DIR$\Debug\Obj\stm32f4xx_fmc.o - $PROJ_DIR$\Debug\Obj\stm32f4xx_qspi.pbi - $PROJ_DIR$\Debug\Obj\los_hwi.pbi - $PROJ_DIR$\Debug\Obj\stm32f4xx_tim.pbi - $PROJ_DIR$\..\Utilities\STM32_EVAL\Common\fonts.c - $PROJ_DIR$\Debug\Obj\los_event.pbi - $PROJ_DIR$\..\..\..\kernel\include\los_errno.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_exti.o - $TOOLKIT_DIR$\inc\c\stdint.h - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_cryp_des.c - $PROJ_DIR$\Debug\Obj\los_hw.pbi - $PROJ_DIR$\..\Libraries\CMSIS\Device\ST\STM32F4xx\Include\system_stm32f4xx.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_sai.o - $PROJ_DIR$\Debug\Obj\stm32f4xx_flash.pbi - $PROJ_DIR$\Debug\Obj\stm32f4xx_rtc.pbi - $PROJ_DIR$\Debug\Obj\stm32f4xx_i2c.__cstat.et - $PROJ_DIR$\Debug\Obj\system_stm32f4xx.__cstat.et - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_adc.h - $PROJ_DIR$\Debug\Obj\stm324x9i_eval_lcd.o - $PROJ_DIR$\Debug\Obj\stm32f4xx_pwr.__cstat.et - $PROJ_DIR$\Debug\Obj\los_sys.o - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_pwr.c - $PROJ_DIR$\Debug\Obj\stm324x9i_eval.pbi - $PROJ_DIR$\Debug\Obj\los_queue.o - $PROJ_DIR$\..\..\..\utils\sleep_std\los_sleep.c - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_dfsdm.c - $PROJ_DIR$\config\stm32f429xG.icf - $PROJ_DIR$\Debug\Obj\los_memory.pbi - $PROJ_DIR$\..\..\..\kernel\src\los_queue_pri.h - $PROJ_DIR$\Debug\Obj\los_memcheck.o - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_rng.h - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_crc.h - $PROJ_DIR$\Debug\Obj\los_queue.pbi - $PROJ_DIR$\Debug\Obj\stm324x9i_eval_fmc_sram.o - $PROJ_DIR$\Debug\Obj\stm324x9i_eval_fmc_sdram.pbi - $PROJ_DIR$\Debug\Obj\stm324x9i_eval_ioe8.o - $PROJ_DIR$\Debug\Obj\los_multipledlinkhead.o - $PROJ_DIR$\Debug\Obj\stm32f4xx_cryp_aes.pbi - $PROJ_DIR$\..\..\..\kernel\src\los_event_pri.h - $PROJ_DIR$\Debug\Obj\dprintf.o - $PROJ_DIR$\Debug\Obj\los_tick.pbi - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_flash_ramfunc.c - $PROJ_DIR$\Debug\Obj\los_timeslice.__cstat.et - $PROJ_DIR$\Debug\Obj\los_exc.pbi - $PROJ_DIR$\Debug\Obj\misc.o - $PROJ_DIR$\Debug\Obj\los_priqueue.pbi - $PROJ_DIR$\Debug\Obj\los_memcheck.pbi - $PROJ_DIR$\Debug\Obj\los_exc.o - $PROJ_DIR$\Debug\Obj\stm32f4xx_dsi.pbi - $PROJ_DIR$\Debug\Obj\main.__cstat.et - $PROJ_DIR$\Debug\Obj\los_membox.pbi - $PROJ_DIR$\..\..\..\kernel\include\los_heap.h - $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval.h - $PROJ_DIR$\Debug\Obj\stm324x9i_eval_sdio_sd.pbi - $PROJ_DIR$\Debug\Obj\stm324x9i_eval_fmc_nor.o - $PROJ_DIR$\Debug\Obj\los_swtmr.o - $PROJ_DIR$\Debug\Obj\los_task.pbi - $PROJ_DIR$\Debug\Obj\fonts.pbi - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_flash.h - $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval_audio_codec.h - $PROJ_DIR$\Debug\Obj\stm324x9i_eval_audio_codec.pbi - $PROJ_DIR$\..\..\..\utils\bounds_checking_function\include\securec.h - $PROJ_DIR$\Debug\Obj\los_sem.pbi - $PROJ_DIR$\Debug\Obj\stm32f4xx_cryp.__cstat.et - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_can.c - $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_exc_pri.h - $PROJ_DIR$\..\..\..\kernel\src\los_err_pri.h - $TOOLKIT_DIR$\CMSIS\Include\cmsis_compiler.h - $PROJ_DIR$\Debug\Obj\los_init.o - $PROJ_DIR$\..\..\..\kernel\src\los_base_pri.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_tim.__cstat.et - $PROJ_DIR$\Debug\Obj\los_tick.o - $PROJ_DIR$\Debug\Obj\stm324x9i_eval_sdio_sd.o - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_fsmc.c - $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval_fmc_nor.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_dcmi.pbi - $PROJ_DIR$\Debug\Obj\los_memstat.pbi - $PROJ_DIR$\Debug\Obj\fonts.o - $PROJ_DIR$\Debug\Obj\stm32f4xx_dcmi.o - $PROJ_DIR$\Debug\Obj\stm32f4xx_dbgmcu.__cstat.et - $PROJ_DIR$\..\..\..\kernel\include\los_membox.h - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_exti.h - $PROJ_DIR$\..\..\..\kernel\include\los_memory.h $PROJ_DIR$\..\..\..\kernel\include\los_config.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_dfsdm.o - $PROJ_DIR$\..\..\..\kernel\include\los_mux.h - $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval_fmc_sdram.h - $PROJ_DIR$\..\..\..\kernel\src\los_task_pri.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_hash.o - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_cec.h - $PROJ_DIR$\Debug\Obj\los_cpup.o - $PROJ_DIR$\Debug\Obj\stm32f4xx_ltdc.o - $PROJ_DIR$\Debug\Obj\stm32f4xx_tim.o - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_dma2d.c - $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval_fmc_nor.c - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_can.h - $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval_sdio_sd.c - $PROJ_DIR$\Debug\Obj\stm32f4xx_usart.pbi - $PROJ_DIR$\Debug\Obj\stm32f4xx_qspi.o - $PROJ_DIR$\Debug\Obj\stm324x9i_eval_fmc_sdram.o - $PROJ_DIR$\..\..\..\kernel\src\los_membox_pri.h - $PROJ_DIR$\..\..\..\kernel\include\los_tick.h - $PROJ_DIR$\Debug\Obj\los_sys.pbi - $PROJ_DIR$\Debug\Obj\stm324x9i_eval_ioe8.pbi - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_sai.c - $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval_lcd.c - $PROJ_DIR$\Debug\Obj\lcd_log.pbi - $PROJ_DIR$\Debug\Obj\los_membox.__cstat.et - $TOOLKIT_DIR$\inc\c\DLib_Product.h - $PROJ_DIR$\Debug\Obj\los_timeslice.pbi - $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval_fmc_sram.c - $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval_fmc_sdram.c - $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval_ioe8.c - $PROJ_DIR$\Debug\Obj\stm32f4xx_fmc.__cstat.et - $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval_ioe16.c - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_cryp.h - $PROJ_DIR$\Debug\Obj\los_memcheck.__cstat.et - $PROJ_DIR$\Debug\Obj\stm32f4xx_dfsdm.__cstat.et - $PROJ_DIR$\Debug\Obj\stm32f4xx_hash.pbi - $PROJ_DIR$\Debug\Obj\los_sem.__cstat.et - $PROJ_DIR$\Debug\Obj\los_swtmr.__cstat.et - $PROJ_DIR$\Debug\Obj\stm32f4xx_flash.__cstat.et - $PROJ_DIR$\Debug\Obj\iar_stm32f429ig_fire-challenger.o - $TOOLKIT_DIR$\inc\c\yvals.h - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_adc.c - $PROJ_DIR$\..\..\..\kernel\include\los_builddef.h - $PROJ_DIR$\Debug\Obj\los_printf.pbi - $PROJ_DIR$\..\..\..\kernel\include\los_sem.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_dma.o - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_fmc.c - $PROJ_DIR$\Debug\Obj\los_cpup.pbi - $TOOLKIT_DIR$\inc\c\cmsis_iar.h - $TOOLKIT_DIR$\inc\c\stddef.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_rtc.o - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_cryp.c - $PROJ_DIR$\Debug\Obj\stm32f4xx_flash.o $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_rtc.h - $PROJ_DIR$\Debug\Obj\los_mux.__cstat.et - $PROJ_DIR$\..\Utilities\STM32_EVAL\Common\stm32_eval_legacy.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_cec.o - $PROJ_DIR$\..\..\..\utils\sleep_std\los_sleep.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_spi.o - $TOOLKIT_DIR$\inc\c\string.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_rcc.__cstat.et - $PROJ_DIR$\Debug\Obj\stm32f4xx_iwdg.o - $PROJ_DIR$\Debug\Obj\los_mux.pbi - $PROJ_DIR$\Debug\Obj\stm32f4xx_dma.pbi + $PROJ_DIR$\Debug\Obj\los_event.__cstat.et + $PROJ_DIR$\Debug\Obj\los_cppsupport.o + $PROJ_DIR$\Debug\Obj\dprintf.o + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_exti.h + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_usart.h + $PROJ_DIR$\Debug\Obj\los_hw_tick.pbi + $TOOLKIT_DIR$\CMSIS\Include\core_cm4.h + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_pwr.h + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_tim.h + $PROJ_DIR$\..\Libraries\CMSIS\Device\ST\STM32F4xx\Include\system_stm32f4xx.h + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_flash.h + $TOOLKIT_DIR$\inc\c\iccarm_builtin.h + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_ltdc.h + $PROJ_DIR$\Debug\Obj\los_cppsupport.pbi + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_wwdg.h + $PROJ_DIR$\..\..\..\utils\los_debug.h + $TOOLKIT_DIR$\inc\c\DLib_Config_Full.h + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_crc.h + $PROJ_DIR$\Debug\Obj\los_misc.__cstat.et + $PROJ_DIR$\..\..\..\kernel\include\los_task.h + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_rcc.h + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_dma2d.h + $PROJ_DIR$\..\..\..\kernel\src\los_queue.c + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_exti.c + $PROJ_DIR$\..\..\..\kernel\src\mm\los_memstat.c + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_gpio.c + $PROJ_DIR$\..\..\..\kernel\src\mm\los_memcheck.c + $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_exc.S + $PROJ_DIR$\..\..\..\kernel\src\los_tick.c + $PROJ_DIR$\..\..\..\kernel\src\los_event.c + $PROJ_DIR$\..\..\..\kernel\src\los_err.c + $PROJ_DIR$\..\..\..\kernel\src\los_init.c + $PROJ_DIR$\..\..\..\kernel\src\los_misc.c + $PROJ_DIR$\..\board\iar_stm32f429ig_fire-challenger.c + $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_interrupt.c $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\misc.c - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_wwdg.c - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_hash.c - $PROJ_DIR$\..\main.c - $PROJ_DIR$\..\..\..\kernel\include\los_memcheck.h - $PROJ_DIR$\..\..\..\kernel\src\los_timeslice.c + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_rcc.c + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_syscfg.c + $PROJ_DIR$\..\..\..\components\cpup\los_cpup.c + $PROJ_DIR$\..\..\..\kernel\src\mm\los_membox.c + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_tim.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$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_syscfg.c - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_tim.c - $PROJ_DIR$\..\..\..\kernel\src\los_tick.c - $PROJ_DIR$\..\..\..\kernel\src\los_sem.c - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_dbgmcu.c - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_exti.c - $PROJ_DIR$\Debug\Obj\stm32f4xx_dbgmcu.pbi - $PROJ_DIR$\..\..\..\kernel\include\los_swtmr.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_qspi.__cstat.et - $PROJ_DIR$\..\board\iar_stm32f429ig_fire-challenger.c - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_lptim.h - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_gpio.c - $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval.c - $PROJ_DIR$\..\..\..\kernel\src\los_task.c - $PROJ_DIR$\Debug\Obj\los_event.__cstat.et + $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_dispatch.S + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_wwdg.c + $PROJ_DIR$\..\..\..\kernel\src\los_mux.c + $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw.c $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_usart.c - $PROJ_DIR$\..\dprintf.c - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_rcc.c - $PROJ_DIR$\..\..\..\kernel\src\los_sem_pri.h - $PROJ_DIR$\..\target_config.h - $PROJ_DIR$\Debug\Obj\los_err.__cstat.et - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_iwdg.h + $PROJ_DIR$\..\..\..\components\cppsupport\los_cppsupport.c + $PROJ_DIR$\..\..\..\kernel\src\los_sem.c $PROJ_DIR$\..\..\..\kernel\src\los_swtmr.c - $PROJ_DIR$\..\..\..\kernel\src\los_sys.c - $PROJ_DIR$\Debug\Obj\los_misc.__cstat.et - $PROJ_DIR$\Debug\Obj\los_swtmr.pbi - $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval_fmc_sram.h - $PROJ_DIR$\Debug\Obj\los_event.o - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_iwdg.c - $TOOLKIT_DIR$\inc\c\ysizet.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_rng.o - $PROJ_DIR$\Debug\Obj\stm32f4xx_sai.__cstat.et - $PROJ_DIR$\Debug\Obj\los_init.pbi - $PROJ_DIR$\Debug\Obj\stm32f4xx_sdio.__cstat.et - $PROJ_DIR$\Debug\Obj\stm32f4xx_usart.__cstat.et - $PROJ_DIR$\Debug\Obj\stm32f4xx_fmpi2c.o - $PROJ_DIR$\Debug\Obj\stm32f4xx_hash_md5.__cstat.et - $TOOLKIT_DIR$\inc\c\iccarm_builtin.h - $PROJ_DIR$\Debug\Obj\los_misc.pbi - $PROJ_DIR$\Debug\Obj\stm32f4xx_ltdc.__cstat.et - $PROJ_DIR$\..\..\..\kernel\include\los_list.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_dac.__cstat.et - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_dma.c - $PROJ_DIR$\..\..\..\kernel\src\los_mux_pri.h - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_wwdg.h - $PROJ_DIR$\Debug\Obj\stm32f4xx_dma2d.__cstat.et - $PROJ_DIR$\Debug\Obj\stm32f4xx_lptim.__cstat.et - $TOOLKIT_DIR$\lib\shb_l.a - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_dsi.c - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_crc.c - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_dma2d.h - $PROJ_DIR$\Debug\Obj\los_hw.o + $PROJ_DIR$\..\..\..\kernel\src\los_task.c + $PROJ_DIR$\..\..\..\kernel\src\mm\los_memory.c + $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_tick.c + $PROJ_DIR$\..\dprintf.c + $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval.c + $PROJ_DIR$\Debug\Obj\los_membox.__cstat.et + $PROJ_DIR$\..\main.c + $PROJ_DIR$\..\target_config.h + $PROJ_DIR$\Debug\Obj\los_timeslice.pbi + $PROJ_DIR$\Debug\Obj\los_memstat.__cstat.et + $PROJ_DIR$\Debug\Obj\main.o + $PROJ_DIR$\Debug\Obj\dprintf.__cstat.et + $TOOLKIT_DIR$\CMSIS\Include\cmsis_compiler.h + $PROJ_DIR$\Debug\Obj\los_exc.pbi + $TOOLKIT_DIR$\inc\c\ycheck.h + $TOOLKIT_DIR$\inc\c\yvals.h + $PROJ_DIR$\Debug\Obj\dprintf.pbi + $PROJ_DIR$\Debug\Obj\los_hw.__cstat.et + $TOOLKIT_DIR$\lib\dl7M_tlf.a $PROJ_DIR$\Debug\Exe\los_demo.out + $TOOLKIT_DIR$\inc\c\ysizet.h + $PROJ_DIR$\..\board\iar_stm32f429ig_fire-challenger.h + $PROJ_DIR$\config\stm32f429xG.icf + $PROJ_DIR$\Debug\Obj\los_exc.__cstat.et + $PROJ_DIR$\Debug\Obj\main.pbi + $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_interrupt.h + $PROJ_DIR$\..\Utilities\STM32_EVAL\Common\stm32_eval_legacy.h + $TOOLKIT_DIR$\inc\c\DLib_Product.h + $PROJ_DIR$\Debug\Obj\misc.o + $PROJ_DIR$\Debug\Obj\los_cppsupport.__cstat.et + $TOOLKIT_DIR$\inc\c\stdio.h + $PROJ_DIR$\..\..\..\kernel\include\los_sem.h + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_rng.h + $PROJ_DIR$\Debug\Obj\los_hw_exc_iar.o + $PROJ_DIR$\Debug\Obj\los_init.__cstat.et + $PROJ_DIR$\Debug\Obj\los_hw.pbi + $TOOLKIT_DIR$\inc\c\DLib_Defaults.h + $PROJ_DIR$\Debug\Obj\los_dispatch_iar.o + $PROJ_DIR$\..\..\..\kernel\include\los_swtmr.h + $PROJ_DIR$\Debug\Obj\los_hw_tick.o + $PROJ_DIR$\Debug\Obj\los_hw.o + $PROJ_DIR$\Debug\Obj\los_memory.pbi + $PROJ_DIR$\Debug\Obj\los_err.__cstat.et + $PROJ_DIR$\Debug\Obj\stm32f4xx_exti.o + $PROJ_DIR$\..\..\..\components\cpup\los_cpup.h + $PROJ_DIR$\Debug\Obj\los_priqueue.o + $PROJ_DIR$\..\Libraries\CMSIS\Device\ST\STM32F4xx\Include\stm32f4xx.h + $PROJ_DIR$\Debug\Obj\stm32f4xx_wwdg.o + $PROJ_DIR$\..\..\..\kernel\src\los_priqueue.c + $PROJ_DIR$\Debug\Obj\stm32f4xx_syscfg.o + $PROJ_DIR$\Debug\Obj\stm32f4xx_usart.pbi + $PROJ_DIR$\Debug\Obj\los_cpup.__cstat.et + $PROJ_DIR$\..\..\..\utils\los_compiler.h + $PROJ_DIR$\Debug\Obj\los_cpup.pbi + $PROJ_DIR$\Debug\Obj\los_memcheck.pbi $PROJ_DIR$\Debug\Obj\los_memory.__cstat.et - $PROJ_DIR$\Debug\Obj\stm32f4xx_spdifrx.pbi + $PROJ_DIR$\Debug\Obj\los_memory.o + $PROJ_DIR$\Debug\Obj\stm32f4xx_exti.pbi + $PROJ_DIR$\Debug\Obj\los_mux.o + $PROJ_DIR$\Debug\Obj\los_membox.pbi + $PROJ_DIR$\Debug\Obj\stm32f4xx_gpio.o + $PROJ_DIR$\Debug\Obj\misc.pbi + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_hash.h + $PROJ_DIR$\Debug\Obj\los_memstat.pbi + $PROJ_DIR$\Debug\Obj\los_queue.pbi + $PROJ_DIR$\Debug\Obj\los_memcheck.__cstat.et + $PROJ_DIR$\..\..\..\components\cppsupport\los_cppsupport.h + $PROJ_DIR$\Debug\Obj\stm32f4xx_tim.pbi + $PROJ_DIR$\Debug\Obj\stm32f4xx_wwdg.pbi + $PROJ_DIR$\Debug\Obj\stm32f4xx_usart.o + $PROJ_DIR$\..\..\..\kernel\src\los_sys.c + $PROJ_DIR$\Debug\Obj\stm32f4xx_tim.o + $PROJ_DIR$\Debug\Obj\los_hw_exc.o + $PROJ_DIR$\Debug\Obj\los_interrupt.o + $PROJ_DIR$\Debug\Obj\stm32f4xx_rcc.pbi + $PROJ_DIR$\Debug\Obj\los_dispatch.o + $PROJ_DIR$\Debug\Obj\stm32f4xx_syscfg.pbi + $PROJ_DIR$\Debug\Obj\los_interrupt.pbi + $PROJ_DIR$\Debug\Obj\los_queue.o + $TOOLKIT_DIR$\inc\c\stdarg.h + $PROJ_DIR$\..\..\..\utils\los_error.c + $PROJ_DIR$\Debug\Obj\los_error.o + $PROJ_DIR$\Debug\Obj\los_error.pbi - $PROJ_DIR$\..\..\..\kernel\src\los_err.c + $PROJ_DIR$\..\..\..\kernel\src\los_timeslice.c + + ICCARM + 21 + BICOMP - 43 + 163 __cstat - 419 - - - ICCARM - 47 + 69 - - BICOMP - 325 100 436 252 359 187 113 232 37 139 311 223 261 420 77 156 369 352 190 116 203 239 236 109 274 449 84 22 367 54 255 375 275 149 302 191 225 380 73 208 443 129 339 222 238 150 310 - ICCARM - 310 84 22 369 37 436 367 54 139 352 100 190 252 223 311 375 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 + 180 102 162 207 115 170 191 120 182 201 110 78 169 167 50 113 42 63 121 98 74 107 114 58 73 83 111 124 103 95 96 101 112 108 118 99 97 217 187 71 77 91 125 70 116 80 123 89 93 2 75 90 - - - - $PROJ_DIR$\..\..\..\kernel\src\los_misc.c - BICOMP - 437 - - - __cstat - 423 - - - ICCARM - 107 - - - - - BICOMP - 190 239 327 449 201 439 436 116 109 100 418 233 37 139 252 203 236 274 22 331 71 369 250 352 187 311 223 261 325 420 113 77 359 156 232 161 219 367 54 255 375 275 149 302 191 225 380 73 208 443 129 339 222 238 150 86 140 313 84 36 345 - - - ICCARM - 313 71 369 37 436 367 54 139 352 22 100 190 252 223 311 375 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 327 418 439 250 84 233 36 219 86 345 331 201 140 161 - - - - - $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw.c - - - BICOMP - 254 - - - ICCARM - 450 - - - - - BICOMP - 191 22 339 112 367 37 352 311 223 436 208 428 140 252 187 149 380 238 100 0 439 161 139 190 375 275 302 225 73 443 129 222 150 165 201 71 36 345 84 369 327 250 233 54 255 261 116 325 203 420 239 113 236 77 109 359 274 156 449 232 41 55 331 418 1 111 386 200 376 - - - ICCARM - 331 201 71 369 37 436 367 54 139 352 22 100 190 252 223 311 375 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 327 418 439 250 84 233 36 140 345 161 0 1 111 428 386 41 200 55 376 112 - - - - - $PROJ_DIR$\..\..\..\components\cpup\los_cpup.c - - - BICOMP - 374 - - - ICCARM - 334 - - - - - BICOMP - 109 369 100 327 428 71 250 367 116 22 84 386 223 86 239 449 114 54 139 55 203 236 274 326 46 352 1 111 200 376 201 233 37 436 255 252 261 325 420 113 77 359 156 232 418 36 439 0 331 41 165 112 155 190 187 311 375 275 149 302 191 225 380 73 208 443 129 339 222 238 150 345 140 161 295 - - - ICCARM - 386 223 367 54 139 352 428 41 0 1 111 200 55 376 112 46 155 233 71 369 37 436 22 100 190 252 311 375 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 327 418 439 250 84 36 201 140 345 161 86 331 114 326 295 - - - - - $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_exc.c - - - BICOMP - 287 - - - __cstat - 35 - - - ICCARM - 291 - - - - - BICOMP - 313 113 255 100 250 223 367 71 37 232 233 252 325 359 140 111 142 54 139 219 327 436 261 420 77 156 395 41 34 428 352 36 72 369 116 203 239 236 109 274 449 200 376 22 309 0 98 331 439 190 187 311 375 275 149 302 191 225 380 73 208 443 129 339 222 238 150 84 201 161 165 112 386 55 418 345 86 1 - - - ICCARM - 111 223 367 54 139 352 428 309 98 36 233 71 369 37 436 22 100 190 252 311 375 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 327 418 439 250 84 331 201 140 345 161 72 395 219 313 86 34 0 1 386 41 200 55 376 112 142 + 115 74 113 103 70 201 207 73 112 71 170 191 50 121 114 111 96 118 217 91 80 123 102 162 120 182 110 78 42 167 169 63 98 107 58 83 124 95 101 108 99 97 187 77 125 116 2 180 89 75 93 90 @@ -592,189 +276,75 @@ AARM - 176 + 188 - - $PROJ_DIR$\..\..\..\kernel\src\mm\los_membox.c - - - BICOMP - 294 - - - ICCARM - 121 - - - - - BICOMP - 150 223 252 187 73 100 22 112 302 129 295 324 428 165 367 36 439 311 375 275 225 443 222 84 233 34 41 37 190 436 149 191 380 208 339 238 0 326 54 139 352 1 111 386 200 376 55 71 327 369 250 255 261 116 325 203 420 239 113 236 77 109 359 274 156 449 232 395 418 - - - ICCARM - 386 223 367 54 139 352 428 41 0 1 111 200 55 376 112 233 71 369 37 436 22 100 190 252 311 375 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 327 418 439 250 84 36 324 395 326 295 34 - - - $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_dispatch_iar.S AARM - 189 + 192 - $PROJ_DIR$\..\..\..\kernel\src\mm\los_multipledlinkhead.c + $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_exc.c BICOMP - 132 - - - ICCARM - 280 - - - - - BICOMP - 100 443 367 275 54 375 225 222 302 73 129 150 439 255 436 149 191 380 208 339 238 37 22 369 139 352 190 252 187 311 223 261 116 325 203 420 239 113 236 77 109 359 274 156 449 232 194 - - - ICCARM - 194 439 22 369 37 436 367 54 139 352 100 190 252 223 311 375 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 - - - - - $PROJ_DIR$\..\..\..\kernel\src\los_mux.c - - - BICOMP - 389 + 168 __cstat - 381 - - - ICCARM - 231 + 178 - - - BICOMP - 109 100 329 436 116 140 36 327 190 239 449 331 84 233 37 139 252 203 236 274 114 71 345 369 250 352 187 311 223 261 325 420 113 77 359 156 232 22 439 310 62 98 201 161 367 54 255 375 275 149 302 191 225 380 73 208 443 129 339 222 238 150 295 395 86 442 418 326 72 219 313 - - - ICCARM - 442 331 201 71 369 37 436 367 54 139 352 22 100 190 252 223 311 375 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 327 418 439 250 84 233 36 140 345 161 329 310 114 326 295 62 98 72 395 219 313 86 - - - $PROJ_DIR$\..\..\..\kernel\src\los_event.c + $PROJ_DIR$\..\..\..\kernel\src\los_queue.c + + ICCARM + 233 + BICOMP - 249 + 219 __cstat - 413 - - - ICCARM - 426 - - - - - BICOMP - 233 100 139 236 439 161 37 252 203 274 327 436 190 116 239 109 449 36 71 331 369 250 352 187 311 223 261 325 420 113 77 359 156 232 345 62 140 22 367 54 255 375 275 149 302 191 225 380 73 208 443 129 339 222 238 150 84 282 418 201 - - - ICCARM - 282 161 71 369 37 436 367 54 139 352 22 100 190 252 223 311 375 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 327 418 439 250 84 233 36 62 331 201 140 345 - - - - - $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_tick.c - - - BICOMP 53 - - ICCARM - 23 - - - BICOMP - 418 100 352 109 116 22 190 239 449 439 233 327 369 252 203 236 274 84 331 250 37 436 139 187 311 223 261 325 420 113 77 359 156 232 36 71 406 345 367 54 255 375 275 149 302 191 225 380 73 208 443 129 339 222 238 150 86 201 140 161 - ICCARM - 86 345 250 22 369 37 436 367 54 139 352 100 190 252 223 311 375 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 84 327 418 71 439 233 36 331 201 140 161 406 + 180 102 162 207 115 170 191 120 182 201 110 78 169 167 50 113 42 63 121 98 74 107 114 58 73 83 111 124 103 95 96 101 112 108 118 99 97 217 187 71 77 91 125 70 116 80 72 68 185 175 76 65 79 86 87 92 88 90 85 94 123 89 93 2 75 119 - $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hwi.c + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_exti.c - - BICOMP - 246 - ICCARM - 96 + 198 - - BICOMP - 139 73 233 150 37 252 302 129 100 22 71 327 436 190 375 275 225 443 222 418 142 369 250 352 187 311 223 149 191 380 208 339 238 165 115 36 439 367 54 255 261 116 325 203 420 239 113 236 77 109 359 274 156 449 232 84 - - - ICCARM - 233 71 369 37 436 367 54 139 352 22 100 190 252 223 311 375 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 327 418 439 250 84 36 115 142 - - - - - $PROJ_DIR$\..\..\..\kernel\src\los_init.c - - - BICOMP - 431 + 212 __cstat - 177 - - - ICCARM - 312 + 45 - - BICOMP - 77 369 100 367 261 22 420 156 71 327 37 252 325 113 359 232 331 36 439 54 255 116 203 239 236 109 274 449 84 250 140 395 86 165 223 345 309 142 233 436 139 352 190 187 311 375 275 149 302 191 225 380 73 208 443 129 339 222 238 150 201 161 98 418 219 72 313 - ICCARM - 36 233 71 369 37 436 367 54 139 352 22 100 190 252 223 311 375 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 327 418 439 250 84 345 331 201 140 161 86 309 98 72 395 219 313 142 + 107 201 110 78 169 170 191 120 182 167 50 115 113 42 63 121 98 74 114 58 73 83 111 124 103 95 96 101 112 108 118 99 97 217 187 71 77 91 125 70 116 80 @@ -782,1421 +352,376 @@ $PROJ_DIR$\..\..\..\kernel\src\mm\los_memstat.c - BICOMP - 320 + ICCARM + 8 - ICCARM - 162 + BICOMP + 218 + + + __cstat + 164 - - BICOMP - 449 22 255 239 233 116 109 100 203 236 274 201 439 327 367 54 252 261 325 420 113 77 359 156 232 161 37 165 223 331 142 369 436 139 352 190 187 311 375 275 149 302 191 225 380 73 208 443 129 339 222 238 150 140 418 71 45 36 345 84 250 - ICCARM - 45 22 369 37 436 367 54 139 352 100 190 252 223 311 375 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 331 201 71 327 418 439 250 84 233 36 140 345 161 142 + 119 207 115 170 191 120 182 180 102 162 201 110 78 169 167 50 113 42 63 121 98 74 107 114 58 73 83 111 124 103 95 96 101 112 108 118 99 97 217 187 71 77 91 125 70 116 80 - $PROJ_DIR$\..\..\..\kernel\src\los_priqueue.c + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_gpio.c + + ICCARM + 215 + BICOMP - 289 + 31 __cstat - 168 - - - ICCARM - 52 + 51 - - BICOMP - 100 443 367 275 54 375 225 222 71 37 302 73 129 150 331 439 255 436 149 191 380 208 339 238 22 345 313 326 369 139 352 190 252 187 311 223 261 116 325 203 420 239 113 236 77 109 359 274 156 449 232 418 327 233 36 84 62 250 201 140 161 295 - ICCARM - 62 439 22 369 37 436 367 54 139 352 100 190 252 223 311 375 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 313 71 327 418 250 84 233 36 331 201 140 345 161 326 295 - - - - - $PROJ_DIR$\..\..\..\kernel\src\los_queue.c - - - BICOMP - 276 - - - __cstat - 243 - - - ICCARM - 267 - - - - - BICOMP - 367 233 325 252 359 71 223 37 255 113 232 100 114 41 428 327 436 261 420 77 156 22 140 250 219 272 331 142 165 112 369 116 203 239 236 109 274 449 418 326 86 345 0 344 62 309 54 139 352 1 111 386 200 376 55 72 439 190 187 311 375 275 149 302 191 225 380 73 208 443 129 339 222 238 150 201 161 36 84 324 395 295 98 313 - - - ICCARM - 386 223 367 54 139 352 428 41 0 1 111 200 55 376 112 272 72 71 369 37 436 22 100 190 252 311 375 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 327 418 439 250 84 233 36 344 324 395 114 326 295 62 331 201 140 345 161 309 98 219 313 86 142 + 58 201 110 78 169 170 191 120 182 167 50 115 113 42 63 121 98 74 107 114 73 83 111 124 103 95 96 101 112 108 118 99 97 217 187 71 77 91 125 70 116 80 $PROJ_DIR$\..\..\..\kernel\src\mm\los_memcheck.c - - BICOMP - 290 - ICCARM - 273 + 27 - - BICOMP - 420 369 156 100 22 352 311 223 261 77 250 252 187 325 113 359 232 327 344 233 37 436 139 190 116 203 239 236 109 274 449 84 439 114 194 71 367 54 255 375 275 149 302 191 225 380 73 208 443 129 339 222 238 150 36 326 395 418 295 324 - - - ICCARM - 395 71 369 37 436 367 54 139 352 22 100 190 252 223 311 375 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 327 418 439 250 84 233 36 114 326 295 344 324 194 - - - - - $PROJ_DIR$\..\..\..\kernel\src\mm\los_memory.c - - - BICOMP - 271 - - - ICCARM - 95 - - - - - BICOMP - 41 369 100 302 326 250 165 428 71 129 22 345 331 367 223 55 73 150 327 439 72 313 45 142 112 233 37 436 255 375 275 225 443 222 36 114 194 98 34 1 111 386 200 376 54 139 352 295 190 252 187 311 149 191 380 208 339 238 418 84 219 395 0 261 116 325 203 420 239 113 236 77 109 359 274 156 449 232 201 140 161 86 - - - ICCARM - 0 1 111 223 367 54 139 352 428 386 41 200 55 376 112 114 326 71 369 37 436 22 100 190 252 311 375 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 327 418 439 250 84 233 36 295 45 194 331 201 140 345 161 98 72 395 219 313 86 142 34 - - - - - [ROOT_NODE] - - - ILINK - 451 198 - - - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_dac.c - - - BICOMP - 164 + 209 __cstat - 440 - - - ICCARM - 124 - - - - - BICOMP - 339 191 100 252 208 190 149 380 238 187 311 223 275 302 225 73 443 129 222 150 239 255 367 54 139 352 375 436 261 116 325 203 420 113 236 77 109 359 274 156 449 232 - - - ICCARM - 156 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 222 449 238 232 150 - - - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_rng.c - - - BICOMP - 79 - - - __cstat - 151 - - - ICCARM - 429 - - - - - BICOMP - 187 252 129 302 100 73 150 311 223 275 225 443 222 190 149 191 380 208 339 238 239 255 367 54 139 352 375 436 261 116 325 203 420 113 236 77 109 359 274 156 449 232 - - - ICCARM - 274 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 339 156 222 449 238 232 150 - - - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_spdifrx.c - - - BICOMP - 453 - - - __cstat - 171 - - - ICCARM - 105 - - - - - BICOMP - 339 191 100 252 208 190 149 380 238 187 311 223 275 302 225 73 443 129 222 150 239 255 367 54 139 352 375 436 261 116 325 203 420 113 236 77 109 359 274 156 449 232 21 - - - ICCARM - 21 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 - - - - - $PROJ_DIR$\..\Utilities\STM32_EVAL\Common\lcd_log.c - - - BICOMP - 350 - - - - - BICOMP - 87 - - - ICCARM - 87 - - - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_hash_md5.c - - - BICOMP - 81 - - - __cstat - 435 - - - ICCARM - 138 - - - - - BICOMP - 100 203 274 436 236 367 352 116 239 109 449 255 54 139 375 261 325 420 113 77 359 156 232 190 252 187 311 223 275 149 302 191 225 380 73 208 443 129 339 222 238 150 - - - ICCARM - 129 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 274 339 156 222 449 238 232 150 - - - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_cryp_tdes.c - - - BICOMP - 163 - - - __cstat - 135 - - - ICCARM - 196 - - - - - BICOMP - 339 191 100 252 208 190 149 380 238 187 311 223 275 302 225 73 443 129 222 150 255 367 54 139 352 375 436 261 116 325 203 420 239 113 236 77 109 359 274 156 449 232 - - - ICCARM - 359 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 129 274 339 156 222 449 238 232 150 - - - - - $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_sleep.c - - - BICOMP 220 - - ICCARM - 141 - - - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_flash.c - - - BICOMP - 257 - - - __cstat - 365 - - - ICCARM - 379 - - - BICOMP - 150 100 73 252 187 302 129 311 223 275 225 443 222 190 149 191 380 208 339 238 255 367 54 139 352 375 436 261 116 325 203 420 239 113 236 77 109 359 274 156 449 232 - ICCARM - 302 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 + 85 94 102 162 207 115 170 191 120 182 201 110 78 169 167 50 113 42 63 121 98 74 107 114 58 73 83 111 124 103 95 96 101 112 108 118 99 97 217 187 71 77 91 125 70 116 80 90 - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_rtc.c + $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_exc.S + + AARM + 227 + + + + + $PROJ_DIR$\..\..\..\kernel\src\los_tick.c + + + ICCARM + 24 + BICOMP - 258 + 29 + + + __cstat + 61 + + + + + ICCARM + 89 93 207 115 170 191 120 182 102 162 201 110 78 169 167 50 113 42 63 121 98 74 107 114 58 73 83 111 124 103 95 96 101 112 108 118 99 97 217 187 71 77 91 125 70 116 80 123 2 75 90 193 + + + + + $PROJ_DIR$\..\..\..\kernel\src\los_event.c + + + ICCARM + 30 + + + BICOMP + 11 + + + __cstat + 104 + + + + + ICCARM + 123 89 93 207 115 170 191 120 182 2 75 90 180 102 162 201 110 78 169 167 50 113 42 63 121 98 74 107 114 58 73 83 111 124 103 95 96 101 112 108 118 99 97 217 187 71 77 91 125 70 116 80 + + + + + $PROJ_DIR$\..\..\..\kernel\src\los_err.c + + + ICCARM + 16 + + + BICOMP + 19 __cstat 197 - - ICCARM - 377 - - - BICOMP - 339 191 100 252 208 190 149 380 238 187 311 223 275 302 225 73 443 129 222 150 255 367 54 139 352 375 436 261 116 325 203 420 239 113 236 77 109 359 274 156 449 232 - ICCARM - 380 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 + 93 207 115 170 191 120 182 - $PROJ_DIR$\..\..\..\kernel\src\mem_to_rename\los_memstat.c + $PROJ_DIR$\..\..\..\kernel\src\los_init.c + + ICCARM + 5 + BICOMP - 320 + 4 __cstat - 211 - - - ICCARM - 162 + 189 - - BICOMP - 449 22 255 239 233 116 109 100 203 236 274 201 439 327 367 54 252 261 325 420 113 77 359 156 232 161 37 165 223 331 142 369 436 139 352 190 187 311 375 275 149 302 191 225 380 73 208 443 129 339 222 238 150 140 418 71 45 36 345 84 250 - ICCARM - 45 22 369 37 436 367 54 139 352 100 190 252 223 311 375 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 331 201 71 327 418 439 250 84 233 36 140 345 161 142 + 102 162 207 115 170 191 120 182 201 110 78 169 167 50 113 42 63 121 98 74 107 114 58 73 83 111 124 103 95 96 101 112 108 118 99 97 217 187 71 77 91 125 70 116 80 88 90 94 66 123 89 93 2 75 180 119 - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_qspi.c + $PROJ_DIR$\..\..\..\kernel\src\los_misc.c + + ICCARM + 20 + BICOMP - 245 + 7 __cstat - 407 - - - ICCARM - 342 - - - - - BICOMP - 156 100 54 375 420 139 261 77 255 325 113 359 232 367 352 436 116 203 239 236 109 274 449 190 252 187 311 223 275 149 302 191 225 380 73 208 443 129 339 222 238 150 217 - - - ICCARM - 217 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 - - - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_ltdc.c - - - BICOMP - 195 - - - __cstat - 438 - - - ICCARM - 335 - - - - - BICOMP - 367 239 449 352 116 109 100 436 203 236 274 255 54 139 375 261 325 420 113 77 359 156 232 190 252 187 311 223 275 149 302 191 225 380 73 208 443 129 339 222 238 150 - - - ICCARM - 232 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 150 - - - - - $PROJ_DIR$\..\..\..\kernel\src\mem_to_rename\los_memory.c - - - BICOMP - 271 - - - __cstat - 452 - - - ICCARM - 95 + 122 ICCARM - 305 65 111 223 367 54 139 352 428 386 41 200 55 376 112 114 326 71 369 37 436 22 100 190 252 311 375 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 327 418 439 250 84 233 36 295 45 194 331 201 140 345 161 98 72 395 219 313 86 142 34 + 180 102 162 207 115 170 191 120 182 201 110 78 169 167 50 113 42 63 121 98 74 107 114 58 73 83 111 124 103 95 96 101 112 108 118 99 97 217 187 71 77 91 125 70 116 80 123 89 93 2 75 90 - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_hash_sha1.c + $PROJ_DIR$\..\board\iar_stm32f429ig_fire-challenger.c - - BICOMP - 126 - - - __cstat - 26 - ICCARM - 25 + 62 - - - - BICOMP - 325 100 255 359 113 232 54 139 375 261 420 77 156 367 352 436 116 203 239 236 109 274 449 190 252 187 311 223 275 149 302 191 225 380 73 208 443 129 339 222 238 150 - - - ICCARM - 129 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 274 339 156 222 449 238 232 150 - - - - - $PROJ_DIR$\..\..\..\kernel\src\mem_to_rename\los_multipledlinkhead.c - - - BICOMP - 132 - - - __cstat - 88 - - - ICCARM - 280 - - - - - BICOMP - 100 443 367 275 54 375 225 222 302 73 129 150 439 255 436 149 191 380 208 339 238 37 22 369 139 352 190 252 187 311 223 261 116 325 203 420 239 113 236 77 109 359 274 156 449 232 194 - - - ICCARM - 194 439 22 369 37 436 367 54 139 352 100 190 252 223 311 375 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 - - - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_cryp_aes.c - - - BICOMP - 281 - - - __cstat - 42 - - - ICCARM - 31 - - - - - BICOMP - 190 252 149 380 238 100 191 208 339 187 311 223 275 302 225 73 443 129 222 150 255 367 54 139 352 375 436 261 116 325 203 420 239 113 236 77 109 359 274 156 449 232 - - - ICCARM - 359 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 129 274 339 156 222 449 238 232 150 - - - - - $PROJ_DIR$\..\..\..\kernel\src\mem_to_rename\los_membox.c - - - BICOMP - 294 - - - __cstat - 351 - - - ICCARM - 121 - - - - - BICOMP - 150 223 252 187 73 100 22 112 302 129 295 324 428 165 367 36 439 311 375 275 225 443 222 84 233 34 41 37 190 436 149 191 380 208 339 238 305 326 54 139 352 65 111 386 200 376 55 71 327 369 250 255 261 116 325 203 420 239 113 236 77 109 359 274 156 449 232 395 418 - - - ICCARM - 386 223 367 54 139 352 428 41 305 65 111 200 55 376 112 233 71 369 37 436 22 100 190 252 311 375 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 327 418 439 250 84 36 324 395 326 295 34 - - - - - $PROJ_DIR$\..\..\..\kernel\src\mem_to_rename\los_memcheck.c - - - BICOMP - 290 - - - __cstat - 360 - - - ICCARM - 273 - - - - - ICCARM - 395 71 369 37 436 367 54 139 352 22 100 190 252 223 311 375 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 327 418 439 250 84 233 36 114 326 295 344 324 194 - - - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_spi.c - BICOMP 38 __cstat - 204 - - - ICCARM - 385 - - - - - BICOMP - 325 255 359 100 113 232 54 139 375 261 420 77 156 367 352 436 116 203 239 236 109 274 449 190 252 187 311 223 275 149 302 191 225 380 73 208 443 129 339 222 238 150 - - - ICCARM - 73 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 - - - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_cec.c - - - BICOMP - 120 - - - __cstat - 160 - - - ICCARM - 383 - - - - - BICOMP - 339 191 100 252 208 190 149 380 238 187 311 223 275 302 225 73 443 129 222 150 239 255 367 54 139 352 375 436 261 116 325 203 420 113 236 77 109 359 274 156 449 232 333 - - - ICCARM - 333 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 - - - - - $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval_audio_codec.c - - - BICOMP - 304 - - - ICCARM - 59 - - - - - BICOMP - 100 156 54 375 420 139 261 77 296 255 325 113 359 232 382 367 352 436 116 203 239 236 109 274 449 190 252 187 311 223 275 149 302 191 225 380 73 208 443 129 339 222 238 150 303 - - - ICCARM - 303 296 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 382 - - - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_sdio.c - - - BICOMP - 131 - - - __cstat - 432 - - - ICCARM - 68 - - - - - BICOMP - 100 436 236 203 274 367 352 116 239 109 449 255 54 139 375 261 325 420 113 77 359 156 232 190 252 187 311 223 275 149 302 191 225 380 73 208 443 129 339 222 238 150 - - - ICCARM - 113 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 - - - - - $PROJ_DIR$\..\..\..\utils\print_std\los_printf.c - - - BICOMP - 370 - - - - - BICOMP - 352 77 311 223 261 100 369 420 156 36 250 252 187 325 113 359 232 327 233 37 436 139 190 116 203 239 236 109 274 449 71 22 439 367 54 255 375 275 149 302 191 225 380 73 208 443 129 339 222 238 150 418 84 - - - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_lptim.c - - - BICOMP - 128 - - - __cstat - 445 - - - ICCARM - 175 - - - - - BICOMP - 156 100 54 375 420 139 261 77 255 325 113 359 232 367 352 436 116 203 239 236 109 274 449 190 252 187 311 223 275 149 302 191 225 380 73 208 443 129 339 222 238 150 409 - - - ICCARM - 409 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 - - - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_dcmi.c - - - BICOMP - 319 - - - __cstat - 106 - - - ICCARM - 322 - - - - - BICOMP - 139 100 261 77 54 375 420 156 255 325 113 359 232 367 352 436 116 203 239 236 109 274 449 190 252 187 311 223 275 149 302 191 225 380 73 208 443 129 339 222 238 150 - - - ICCARM - 222 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 449 238 232 150 - - - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_fmpi2c.c - - - BICOMP - 39 - - - __cstat - 63 - - - ICCARM - 434 - - - - - BICOMP - 339 191 100 252 208 190 149 380 238 187 311 223 275 302 225 73 443 129 222 150 239 255 367 54 139 352 375 436 261 116 325 203 420 113 236 77 109 359 274 156 449 232 133 - - - ICCARM - 133 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 - - - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_i2c.c - - - BICOMP - 93 - - - __cstat - 259 - - - ICCARM - 90 - - - - - BICOMP - 239 367 449 100 352 116 109 436 203 236 274 255 54 139 375 261 325 420 113 77 359 156 232 190 252 187 311 223 275 149 302 191 225 380 73 208 443 129 339 222 238 150 - - - ICCARM - 191 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 - - - - - $PROJ_DIR$\..\Utilities\STM32_EVAL\Common\fonts.c - - - BICOMP - 301 - - - ICCARM - 321 - - - - - BICOMP - 54 352 223 252 367 139 48 - - - ICCARM - 48 252 223 367 54 139 352 - - - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_cryp_des.c - - - BICOMP - 169 - - - __cstat - 172 - - - ICCARM - 192 - - - - - BICOMP - 252 208 191 339 100 190 149 380 238 187 311 223 275 302 225 73 443 129 222 150 255 367 54 139 352 375 436 261 116 325 203 420 239 113 236 77 109 359 274 156 449 232 - - - ICCARM - 359 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 129 274 339 156 222 449 238 232 150 - - - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_pwr.c - - - BICOMP - 147 - - - __cstat - 263 - - - ICCARM - 153 - - - - - BICOMP - 261 139 100 77 54 375 420 156 255 325 113 359 232 367 352 436 116 203 239 236 109 274 449 190 252 187 311 223 275 149 302 191 225 380 73 208 443 129 339 222 238 150 - - - ICCARM - 225 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 - - - - - $PROJ_DIR$\..\..\..\utils\sleep_std\los_sleep.c - - - BICOMP - 220 - - - ICCARM - 141 - - - - - BICOMP - 100 345 236 36 22 369 252 203 274 406 352 190 116 239 109 449 250 233 37 436 139 187 311 223 261 325 420 113 77 359 156 232 71 201 327 418 367 54 255 375 275 149 302 191 225 380 73 208 443 129 339 222 238 150 84 439 384 140 161 - - - ICCARM - 384 327 22 369 37 436 367 54 139 352 100 190 252 223 311 375 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 418 233 71 439 250 84 36 201 140 345 161 406 - - - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_dfsdm.c - - - BICOMP - 183 - - - __cstat - 361 - - - ICCARM - 328 - - - - - BICOMP - 449 367 239 352 116 109 100 436 203 236 274 255 54 139 375 261 325 420 113 77 359 156 232 190 252 187 311 223 275 149 302 191 225 380 73 208 443 129 339 222 238 150 237 - - - ICCARM - 237 239 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 - - - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_flash_ramfunc.c - - - BICOMP - 173 - - - __cstat - 167 - - - ICCARM - 85 - - - - - BICOMP - 203 100 274 436 236 367 352 116 239 109 449 255 54 139 375 261 325 420 113 77 359 156 232 190 252 187 311 223 275 149 302 191 225 380 73 208 443 129 339 222 238 150 152 - - - ICCARM - 152 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 - - - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_can.c - - - BICOMP - 146 - - - __cstat - 241 - - - ICCARM - 32 - - - - - BICOMP - 252 208 191 339 100 190 149 380 238 187 311 223 275 302 225 73 443 129 222 150 239 255 367 54 139 352 375 436 261 116 325 203 420 113 236 77 109 359 274 156 449 232 - - - ICCARM - 339 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 156 222 449 238 232 150 - - - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_fsmc.c - - - BICOMP - 49 - - - __cstat - 215 - - - - - BICOMP - 255 359 325 113 232 100 54 139 375 261 420 77 156 367 352 436 116 203 239 236 109 274 449 190 252 187 311 223 275 149 302 191 225 380 73 208 443 129 339 222 238 150 108 - - - ICCARM - 108 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 - - - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_dma2d.c - - - BICOMP - 27 - - - __cstat - 444 - - - ICCARM - 242 - - - - - BICOMP - 380 100 238 190 252 149 191 208 339 187 311 223 275 302 225 73 443 129 222 150 239 255 367 54 139 352 375 436 261 116 325 203 420 113 236 77 109 359 274 156 449 232 - - - ICCARM - 449 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 238 232 150 - - - - - $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval_fmc_nor.c - - - BICOMP - 89 - - - ICCARM - 298 + 84 ICCARM - 318 296 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 382 + 10 201 110 78 169 170 191 120 182 167 50 115 113 42 63 121 98 74 107 114 58 73 83 111 124 103 95 96 101 112 108 118 99 97 217 187 71 77 91 125 70 116 80 181 - $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval_sdio_sd.c + $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_interrupt.c - - BICOMP - 297 - ICCARM - 316 - - - - - ICCARM - 202 296 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 382 179 - - - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_sai.c - - - BICOMP - 80 - - - __cstat - 430 - - - ICCARM - 256 - - - - - BICOMP - 380 100 238 190 252 149 191 208 339 187 311 223 275 302 225 73 443 129 222 150 239 255 367 54 139 352 375 436 261 116 325 203 420 113 236 77 109 359 274 156 449 232 - - - ICCARM - 150 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 - - - - - $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval_lcd.c - - - BICOMP - 110 - - - ICCARM - 262 - - - - - ICCARM - 213 296 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 382 330 48 240 248 - - - - - $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval_fmc_sram.c - - - BICOMP 228 - ICCARM - 277 + BICOMP + 232 ICCARM - 425 296 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 382 - - - - - $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval_fmc_sdram.c - - - BICOMP - 278 - - - ICCARM - 343 - - - - - ICCARM - 330 296 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 382 - - - - - $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval_ioe8.c - - - BICOMP - 347 - - - ICCARM - 279 - - - - - ICCARM - 240 296 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 382 213 330 48 - - - - - $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval_ioe16.c - - - BICOMP - 56 - - - ICCARM - 199 - - - - - ICCARM - 179 296 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 382 - - - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_adc.c - - - BICOMP - 234 - - - __cstat - 66 - - - ICCARM - 159 - - - - - BICOMP - 100 109 352 116 367 239 449 436 203 236 274 255 54 139 375 261 325 420 113 77 359 156 232 190 252 187 311 223 275 149 302 191 225 380 73 208 443 129 339 222 238 150 - - - ICCARM - 261 100 190 252 223 367 54 139 352 311 375 436 255 187 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 - - - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_fmc.c - - - BICOMP - 148 - - - __cstat - 357 - - - ICCARM - 244 - - - - - BICOMP - 54 375 420 100 156 139 261 77 255 325 113 359 232 367 352 436 116 203 239 236 109 274 449 190 252 187 311 223 275 149 302 191 225 380 73 208 443 129 339 222 238 150 - - - ICCARM - 238 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 232 150 - - - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_cryp.c - - - BICOMP - 181 - - - __cstat - 307 - - - ICCARM - 97 - - - - - BICOMP - 252 149 100 190 380 238 191 208 339 187 311 223 275 302 225 73 443 129 222 150 239 255 367 54 139 352 375 436 261 116 325 203 420 113 236 77 109 359 274 156 449 232 - - - ICCARM - 359 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 129 274 339 156 222 449 238 232 150 + 180 102 162 207 115 170 191 120 182 201 110 78 169 167 50 113 42 63 121 98 74 107 114 58 73 83 111 124 103 95 96 101 112 108 118 99 97 217 187 71 77 91 125 70 116 80 119 123 89 93 2 75 90 $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\misc.c + + ICCARM + 183 + BICOMP - 193 + 216 __cstat - 136 - - - ICCARM - 288 + 46 - - BICOMP - 113 232 100 255 325 359 54 139 375 261 420 77 156 367 352 436 116 203 239 236 109 274 449 190 252 187 311 223 275 149 302 191 225 380 73 208 443 129 339 222 238 150 - ICCARM - 109 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 359 129 274 339 156 222 449 238 232 150 + 99 201 110 78 169 170 191 120 182 167 50 115 113 42 63 121 98 74 107 114 58 73 83 111 124 103 95 96 101 112 108 118 97 217 187 71 77 91 125 70 116 80 - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_wwdg.c + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_rcc.c + + ICCARM + 17 + BICOMP - 40 + 229 __cstat - 158 - - - ICCARM - 144 + 33 - - BICOMP - 109 352 116 100 367 239 449 436 203 236 274 255 54 139 375 261 325 420 113 77 359 156 232 190 252 187 311 223 275 149 302 191 225 380 73 208 443 129 339 222 238 150 - ICCARM - 443 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 109 359 129 274 339 156 222 449 238 232 150 + 124 201 110 78 169 170 191 120 182 167 50 115 113 42 63 121 98 74 107 114 58 73 83 111 103 95 96 101 112 108 118 99 97 217 187 71 77 91 125 70 116 80 - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_hash.c + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_syscfg.c + + ICCARM + 204 + BICOMP - 362 + 231 __cstat - 76 - - - ICCARM - 332 + 56 - - BICOMP - 100 156 54 375 420 139 261 77 255 325 113 359 232 367 352 436 116 203 239 236 109 274 449 190 252 187 311 223 275 149 302 191 225 380 73 208 443 129 339 222 238 150 - ICCARM - 129 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 274 339 156 222 449 238 232 150 + 101 201 110 78 169 170 191 120 182 167 50 115 113 42 63 121 98 74 107 114 58 73 83 111 124 103 95 96 112 108 118 99 97 217 187 71 77 91 125 70 116 80 - $PROJ_DIR$\..\main.c + $PROJ_DIR$\..\..\..\components\cpup\los_cpup.c + + ICCARM + 81 + BICOMP - 29 + 208 __cstat - 293 - - - ICCARM - 188 + 206 - BICOMP - 187 380 100 327 252 250 238 149 22 98 369 352 311 223 436 191 208 339 439 201 170 233 71 37 139 190 375 275 302 225 73 443 129 222 150 161 331 313 165 345 142 36 367 54 255 261 116 325 203 420 239 113 236 77 109 359 274 156 449 232 418 140 395 84 72 219 86 + ICCARM + 199 180 102 162 207 115 170 191 120 182 201 110 78 169 167 50 113 42 63 121 98 74 107 114 58 73 83 111 124 103 95 96 101 112 108 118 99 97 217 187 71 77 91 125 70 116 80 123 89 93 2 75 90 119 - ICCARM - 36 233 71 369 37 436 367 54 139 352 22 100 190 252 223 311 375 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 327 418 439 250 84 345 201 140 161 98 331 72 395 219 313 86 142 170 + BICOMP + 118 201 170 121 191 50 111 91 114 96 217 80 123 207 162 113 115 74 73 103 112 71 70 119 180 102 120 182 110 78 42 167 169 63 98 107 58 83 124 95 101 108 99 97 187 77 125 116 2 199 89 75 93 90 - $PROJ_DIR$\..\..\..\kernel\src\los_timeslice.c + $PROJ_DIR$\..\..\..\kernel\src\mm\los_membox.c + + ICCARM + 25 + BICOMP - 353 + 214 __cstat - 286 - - - ICCARM - 224 + 160 - BICOMP - 77 369 100 439 367 261 345 22 420 156 57 37 252 325 113 359 232 36 86 54 255 116 203 239 236 109 274 449 71 165 223 331 142 313 327 250 233 436 139 352 190 187 311 375 275 149 302 191 225 380 73 208 443 129 339 222 238 150 84 219 418 201 140 161 + ICCARM + 72 68 185 169 170 191 120 182 175 76 65 79 86 87 92 180 102 162 207 115 201 110 78 167 50 113 42 63 121 98 74 107 114 58 73 83 111 124 103 95 96 101 112 108 118 99 97 217 187 71 77 91 125 70 116 80 85 94 90 119 + + + + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_tim.c + ICCARM - 219 313 71 369 37 436 367 54 139 352 22 100 190 252 223 311 375 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 327 418 439 250 84 233 36 86 345 331 201 140 161 57 142 + 226 + + + BICOMP + 222 + + + __cstat + 39 + + + + + ICCARM + 112 201 110 78 169 170 191 120 182 167 50 115 113 42 63 121 98 74 107 114 58 73 83 111 124 103 95 96 101 108 118 99 97 217 187 71 77 91 125 70 116 80 @@ -2205,560 +730,441 @@ AARM - 230 + 52 $PROJ_DIR$\..\Libraries\CMSIS\Device\ST\STM32F4xx\Source\Templates\system_stm32f4xx.c + + ICCARM + 1 + BICOMP - 50 + 57 __cstat - 260 - - - ICCARM - 185 + 54 - - BICOMP - 238 380 100 190 252 149 191 208 339 187 311 223 275 302 225 73 443 129 222 150 255 367 54 139 352 375 436 261 116 325 203 420 239 113 236 77 109 359 274 156 449 232 - ICCARM - 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 + 201 110 78 169 170 191 120 182 167 50 115 113 42 63 121 98 74 107 114 58 73 83 111 124 103 95 96 101 112 108 118 99 97 217 187 71 77 91 125 70 116 80 - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_syscfg.c + $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_dispatch.S + + AARM + 230 + + + + + $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_wwdg.c + + + ICCARM + 202 + BICOMP - 206 + 223 __cstat - 119 - - - ICCARM - 229 + 34 - - BICOMP - 436 236 100 203 274 367 352 116 239 109 449 255 54 139 375 261 325 420 113 77 359 156 232 190 252 187 311 223 275 149 302 191 225 380 73 208 443 129 339 222 238 150 - ICCARM - 236 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 208 77 443 109 359 129 274 339 156 222 449 238 232 150 + 118 201 110 78 169 170 191 120 182 167 50 115 113 42 63 121 98 74 107 114 58 73 83 111 124 103 95 96 101 112 108 99 97 217 187 71 77 91 125 70 116 80 - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_tim.c + $PROJ_DIR$\..\..\..\kernel\src\los_mux.c + + ICCARM + 213 + BICOMP - 247 + 59 __cstat - 314 - - - ICCARM - 336 + 48 - - BICOMP - 109 352 116 100 367 239 449 436 203 236 274 255 54 139 375 261 325 420 113 77 359 156 232 190 252 187 311 223 275 149 302 191 225 380 73 208 443 129 339 222 238 150 - ICCARM - 208 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 77 443 109 359 129 274 339 156 222 449 238 232 150 + 66 123 89 93 207 115 170 191 120 182 2 75 90 180 102 162 201 110 78 169 167 50 113 42 63 121 98 74 107 114 58 73 83 111 124 103 95 96 101 112 108 118 99 97 217 187 71 77 91 125 70 116 80 94 119 - $PROJ_DIR$\..\..\..\kernel\src\los_tick.c + $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw.c + + ICCARM + 195 + BICOMP - 284 + 190 __cstat - 227 - - - ICCARM - 315 + 172 - - BICOMP - 436 208 369 84 191 339 100 418 57 255 149 380 238 22 216 345 367 54 375 275 302 225 73 443 129 222 150 71 250 36 201 313 331 327 37 139 352 190 252 187 311 223 261 116 325 203 420 239 113 236 77 109 359 274 156 449 232 233 406 439 86 140 161 - ICCARM - 86 345 250 22 369 37 436 367 54 139 352 100 190 252 223 311 375 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 84 327 418 313 71 439 233 36 216 406 201 140 161 331 57 - - - - - $PROJ_DIR$\..\..\..\kernel\src\los_sem.c - - - BICOMP - 306 - - - __cstat - 363 - - - ICCARM - 70 - - - - - BICOMP - 37 150 73 439 302 129 100 22 331 62 369 367 375 275 225 443 222 36 327 310 71 54 255 436 149 191 380 208 339 238 84 313 114 219 98 371 201 250 233 139 352 190 252 187 311 223 261 116 325 203 420 239 113 236 77 109 359 274 156 449 232 345 295 86 395 417 418 140 161 326 72 - - - ICCARM - 417 371 71 369 37 436 367 54 139 352 22 100 190 252 223 311 375 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 327 418 439 250 84 233 36 201 140 345 161 313 310 114 326 295 62 219 86 331 98 72 395 - - - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_dbgmcu.c - - - BICOMP - 405 - - - __cstat - 323 - - - ICCARM - 209 - - - - - BICOMP - 380 238 100 190 252 149 191 208 339 187 311 223 275 302 225 73 443 129 222 150 255 367 54 139 352 375 436 261 116 325 203 420 239 113 236 77 109 359 274 156 449 232 - - - ICCARM - 116 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 - - - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_exti.c - - - BICOMP - 218 - - - __cstat - 82 - - - ICCARM - 251 - - - - - BICOMP - 100 238 380 190 252 149 191 208 339 187 311 223 275 302 225 73 443 129 222 150 255 367 54 139 352 375 436 261 116 325 203 420 239 113 236 77 109 359 274 156 449 232 - - - ICCARM - 325 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 - - - - - $PROJ_DIR$\..\board\iar_stm32f429ig_fire-challenger.c - - - BICOMP - 174 - - - ICCARM - 366 - - - - - BICOMP - 436 236 100 203 274 367 352 116 239 109 449 255 54 139 375 261 325 420 113 77 359 156 232 382 190 252 187 311 223 275 149 302 191 225 380 73 208 443 129 339 222 238 150 296 - - - ICCARM - 296 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 382 - - - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_gpio.c - - - BICOMP - 154 - - - __cstat - 157 - - - ICCARM - 30 - - - - - BICOMP - 238 380 100 190 252 149 191 208 339 187 311 223 275 302 225 73 443 129 222 150 239 255 367 54 139 352 375 436 261 116 325 203 420 113 236 77 109 359 274 156 449 232 - - - ICCARM - 203 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 - - - - - $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval.c - - - BICOMP - 266 - - - ICCARM - 58 - - - - - BICOMP - 232 113 255 325 359 100 54 139 375 261 420 77 156 149 382 367 352 436 116 203 239 236 109 274 449 191 190 252 187 311 223 275 302 225 380 73 208 443 129 339 222 238 150 296 - - - ICCARM - 296 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 382 - - - - - $PROJ_DIR$\..\..\..\kernel\src\los_task.c - - - BICOMP - 300 - - - __cstat - 28 - - - ICCARM - 60 - - - - - BICOMP - 223 436 327 443 100 46 275 201 442 36 190 375 225 222 367 219 114 142 84 233 37 139 252 302 73 129 150 22 72 313 0 62 71 345 369 250 352 187 311 149 191 380 208 339 238 41 428 295 386 45 417 309 140 439 161 54 255 261 116 325 203 420 239 113 236 77 109 359 274 156 449 232 418 1 371 329 86 331 165 112 111 200 376 55 326 98 395 155 - - - ICCARM - 331 201 71 369 37 436 367 54 139 352 22 100 190 252 223 311 375 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 327 418 439 250 84 233 36 140 345 161 386 428 41 0 1 111 200 55 376 112 313 114 326 295 45 62 417 371 442 329 309 98 72 395 219 86 46 155 142 + 123 89 93 207 115 170 191 120 182 2 75 90 72 68 185 169 175 76 65 79 86 87 92 $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_usart.c + + ICCARM + 224 + BICOMP - 341 + 205 __cstat - 433 - - - ICCARM - 130 + 49 - - BICOMP - 222 100 311 223 225 275 443 252 187 302 73 129 150 190 149 191 380 208 339 238 239 255 367 54 139 352 375 436 261 116 325 203 420 113 236 77 109 359 274 156 449 232 - ICCARM - 77 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 443 109 359 129 274 339 156 222 449 238 232 150 + 108 201 110 78 169 170 191 120 182 167 50 115 113 42 63 121 98 74 107 114 58 73 83 111 124 103 95 96 101 112 118 99 97 217 187 71 77 91 125 70 116 80 - $PROJ_DIR$\..\dprintf.c + $PROJ_DIR$\..\..\..\components\cppsupport\los_cppsupport.c - BICOMP - 104 + ICCARM + 105 - ICCARM - 283 + BICOMP + 117 + + + __cstat + 184 - - BICOMP - 239 139 436 449 100 223 54 367 116 109 296 165 37 203 236 274 142 352 369 255 252 261 325 420 113 77 359 156 232 111 428 22 190 187 311 375 275 149 302 191 225 380 73 208 443 129 339 222 238 150 382 - ICCARM - 111 223 367 54 139 352 428 142 22 369 37 436 100 190 252 311 375 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 296 382 + 221 207 115 170 191 120 182 - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_rcc.c + $PROJ_DIR$\..\..\..\kernel\src\los_sem.c + + ICCARM + 3 + BICOMP - 212 + 23 __cstat - 387 - - - ICCARM - 102 + 37 - - BICOMP - 449 367 239 352 116 109 100 436 203 236 274 255 54 139 375 261 325 420 113 77 359 156 232 190 252 187 311 223 275 149 302 191 225 380 73 208 443 129 339 222 238 150 - ICCARM - 239 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 + 186 123 89 93 207 115 170 191 120 182 2 75 90 94 102 162 201 110 78 169 167 50 113 42 63 121 98 74 107 114 58 73 83 111 124 103 95 96 101 112 108 118 99 97 217 187 71 77 91 125 70 116 80 180 119 $PROJ_DIR$\..\..\..\kernel\src\los_swtmr.c + + ICCARM + 6 + BICOMP - 424 + 26 __cstat - 364 - - - ICCARM - 299 + 64 - BICOMP - 37 439 149 376 367 100 22 331 200 223 190 380 238 36 352 1 111 252 436 191 208 339 327 71 295 395 216 114 142 54 139 386 428 55 406 201 187 311 375 275 302 225 73 443 129 222 150 233 161 313 0 344 272 98 41 165 112 369 250 255 261 116 325 203 420 239 113 236 77 109 359 274 156 449 232 418 140 324 72 345 84 326 219 86 + ICCARM + 72 68 185 169 170 191 120 182 175 76 65 79 86 87 92 180 102 162 207 115 201 110 78 167 50 113 42 63 121 98 74 107 114 58 73 83 111 124 103 95 96 101 112 108 118 99 97 217 187 71 77 91 125 70 116 80 193 123 89 93 2 75 90 94 88 119 + + + + $PROJ_DIR$\..\..\..\kernel\src\los_task.c + ICCARM - 386 223 367 54 139 352 428 41 0 1 111 200 55 376 112 216 406 71 369 37 436 22 100 190 252 311 375 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 327 418 439 250 84 233 36 201 140 345 161 313 344 324 395 114 326 295 272 72 331 142 98 219 86 + 18 + + + BICOMP + 22 + + + __cstat + 47 + + + + + ICCARM + 102 162 207 115 170 191 120 182 201 110 78 169 167 50 113 42 63 121 98 74 107 114 58 73 83 111 124 103 95 96 101 112 108 118 99 97 217 187 71 77 91 125 70 116 80 72 68 185 175 76 65 79 86 87 92 186 123 89 93 2 75 90 66 94 180 199 119 + + + BICOMP + 96 207 80 78 114 217 201 170 94 199 182 110 50 121 111 118 91 169 186 115 120 42 167 74 73 103 112 71 70 102 72 66 180 119 162 191 113 63 98 107 58 83 124 95 101 108 99 97 187 77 125 116 68 175 2 90 123 234 92 185 76 79 87 65 86 89 75 93 + + + + + $PROJ_DIR$\..\..\..\kernel\src\mm\los_memory.c + + + ICCARM + 211 + + + BICOMP + 196 + + + __cstat + 210 + + + + + ICCARM + 72 68 185 169 170 191 120 182 175 76 65 79 86 87 92 94 102 162 207 115 201 110 78 167 50 113 42 63 121 98 74 107 114 58 73 83 111 124 103 95 96 101 112 108 118 99 97 217 187 71 77 91 125 70 116 80 90 123 89 93 2 75 180 119 85 + + + + + $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_tick.c + + + ICCARM + 194 + + + BICOMP + 109 + + + __cstat + 15 + + + + + ICCARM + 89 93 207 115 170 191 120 182 180 102 162 201 110 78 169 167 50 113 42 63 121 98 74 107 114 58 73 83 111 124 103 95 96 101 112 108 118 99 97 217 187 71 77 91 125 70 116 80 + + + + + $PROJ_DIR$\..\dprintf.c + + + ICCARM + 106 + + + BICOMP + 171 + + + __cstat + 166 + + + + + ICCARM + 185 169 170 191 120 182 175 119 207 115 108 201 110 78 167 50 113 42 63 121 98 74 107 114 58 73 83 111 124 103 95 96 101 112 118 99 97 217 187 71 77 91 125 70 116 80 10 181 + + + + + $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval.c + + + ICCARM + 28 + + + BICOMP + 13 + + + __cstat + 41 + + + + + ICCARM + 10 201 110 78 169 170 191 120 182 167 50 115 113 42 63 121 98 74 107 114 58 73 83 111 124 103 95 96 101 112 108 118 99 97 217 187 71 77 91 125 70 116 80 181 + + + + + $PROJ_DIR$\..\main.c + + + ICCARM + 165 + + + BICOMP + 179 + + + __cstat + 82 + + + + + ICCARM + 89 93 207 115 170 191 120 182 123 2 75 90 102 162 201 110 78 169 167 50 113 42 63 121 98 74 107 114 58 73 83 111 124 103 95 96 101 112 108 118 99 97 217 187 71 77 91 125 70 116 80 180 119 176 + + + + + [ROOT_NODE] + + + ILINK + 174 55 + + + + + $PROJ_DIR$\Debug\Exe\los_demo.out + + + ILINK + 55 + + + + + ILINK + 177 106 62 105 81 230 16 30 195 227 194 5 228 25 27 211 8 20 213 233 3 6 18 24 165 183 52 28 198 215 17 204 226 224 202 1 32 35 40 173 + + + + + $PROJ_DIR$\..\..\..\kernel\src\los_priqueue.c + + + ICCARM + 200 + + + BICOMP + 12 + + + __cstat + 36 + + + + + ICCARM + 88 90 207 115 170 191 120 182 123 89 93 2 75 102 162 201 110 78 169 167 50 113 42 63 121 98 74 107 114 58 73 83 111 124 103 95 96 101 112 108 118 99 97 217 187 71 77 91 125 70 116 80 $PROJ_DIR$\..\..\..\kernel\src\los_sys.c + + ICCARM + 9 + BICOMP - 346 + 67 __cstat - 92 - - - ICCARM - 264 + 60 - BICOMP - 149 439 367 255 380 238 100 86 54 436 191 208 339 22 37 369 375 275 302 225 73 443 129 222 150 36 345 313 71 327 250 233 139 352 190 252 187 311 223 261 116 325 203 420 239 113 236 77 109 359 274 156 449 232 84 219 418 + ICCARM + 89 93 207 115 170 191 120 182 102 162 201 110 78 169 167 50 113 42 63 121 98 74 107 114 58 73 83 111 124 103 95 96 101 112 108 118 99 97 217 187 71 77 91 125 70 116 80 - ICCARM - 219 313 71 369 37 436 367 54 139 352 22 100 190 252 223 311 375 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 327 418 439 250 84 233 36 86 345 + BICOMP + 71 115 162 73 201 207 112 113 74 103 70 170 191 50 121 114 111 96 118 217 91 80 102 93 120 182 110 78 42 167 169 63 98 107 58 83 124 95 101 108 99 97 187 77 125 116 89 - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_iwdg.c + $PROJ_DIR$\..\..\..\utils\los_error.c - - BICOMP - 184 - - - __cstat - 123 - ICCARM - 388 + 236 + + + BICOMP + 237 BICOMP - 449 367 239 100 352 116 109 436 203 236 274 255 54 139 375 261 325 420 113 77 359 156 232 190 252 187 311 223 275 149 302 191 225 380 73 208 443 129 339 222 238 150 - - - ICCARM - 420 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 - - - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_dma.c - - - BICOMP - 390 - - - __cstat - 74 - - - ICCARM - 372 - - - - - BICOMP - 275 443 100 311 223 225 222 252 187 302 73 129 150 190 149 191 380 208 339 238 239 255 367 54 139 352 375 436 261 116 325 203 420 113 236 77 109 359 274 156 449 232 - - - ICCARM - 149 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 - - - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_dsi.c - - - BICOMP - 292 - - - __cstat - 226 - - - ICCARM - 207 - - - - - BICOMP - 156 100 54 375 420 139 261 77 255 325 113 359 232 367 352 436 116 203 239 236 109 274 449 190 252 187 311 223 275 149 302 191 225 380 73 208 443 129 339 222 238 150 186 - - - ICCARM - 186 100 190 252 223 367 54 139 352 311 375 436 255 187 261 275 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 - - - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_crc.c - - - BICOMP - 64 - - - __cstat - 75 - - - ICCARM - 134 - - - - - BICOMP - 236 436 100 203 274 367 352 116 239 109 449 255 54 139 375 261 325 420 113 77 359 156 232 190 252 187 311 223 275 149 302 191 225 380 73 208 443 129 339 222 238 150 - - - ICCARM - 275 100 190 252 223 367 54 139 352 311 375 436 255 187 261 116 149 325 302 203 191 420 225 239 380 113 73 236 208 77 443 109 359 129 274 339 156 222 449 238 232 150 - - - - - $PROJ_DIR$\Debug\Exe\los_demo.out - - - ILINK - 198 - - - - - ILINK - 270 283 366 334 189 47 426 291 450 176 23 96 312 121 273 95 162 107 280 231 52 267 70 299 264 60 315 224 188 288 230 58 251 30 102 229 336 130 144 185 446 143 118 137 + 170 182 207 115 120 93 191 - $PROJ_DIR$\..\Utilities\STM32_EVAL\Common\lcd_log.c - ICCARM - - - $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_fsmc.c - ICCARM + [MULTI_TOOL] + ILINK @@ -2768,5 +1174,8 @@ [MULTI_TOOL] ILINK + + [REBUILD_ALL] + 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 index 1dcfc50e..589a43d6 100755 --- a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/los_demo.ewd +++ b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/los_demo.ewd @@ -1098,7 +1098,7 @@ 1