diff --git a/arch/stm8/iccarm/port.h b/arch/avr/ATMega32/iccavr/port.h similarity index 100% rename from arch/stm8/iccarm/port.h rename to arch/avr/ATMega32/iccavr/port.h diff --git a/arch/stm8/iccarm/port_c.c b/arch/avr/ATMega32/iccavr/port_c.c similarity index 100% rename from arch/stm8/iccarm/port_c.c rename to arch/avr/ATMega32/iccavr/port_c.c diff --git a/arch/stm8/iccarm/port_config.h b/arch/avr/ATMega32/iccavr/port_config.h similarity index 100% rename from arch/stm8/iccarm/port_config.h rename to arch/avr/ATMega32/iccavr/port_config.h diff --git a/arch/avr/ATMega32/iccavr/port_s.asm b/arch/avr/ATMega32/iccavr/port_s.asm new file mode 100644 index 00000000..bb0e52c7 --- /dev/null +++ b/arch/avr/ATMega32/iccavr/port_s.asm @@ -0,0 +1,157 @@ +#include + + RSEG CODE + + EXTERN k_curr_task + EXTERN k_next_task + + PUBLIC port_int_disable + PUBLIC port_int_enable + PUBLIC port_cpsr_save + PUBLIC port_cpsr_restore + PUBLIC port_sched_start + PUBLIC port_irq_context_switch + PUBLIC port_context_switch + +port_int_disable: + CLI + RET + + +port_int_enable: + SEI + RET + + +port_cpsr_save: + IN R16, SREG + CLI + RET + + +port_cpsr_restore: + OUT SREG, R16 + RET + + +port_sched_start: + JMP _context_restore + + +port_irq_context_switch: +port_context_switch: +_context_save: + PUSH R0 + + /* save SREG */ + IN R0, SREG + CLI + PUSH R0 + + PUSH R1 + PUSH R2 + PUSH R3 + PUSH R4 + PUSH R5 + PUSH R6 + PUSH R7 + PUSH R8 + PUSH R9 + PUSH R10 + PUSH R11 + PUSH R12 + PUSH R13 + PUSH R14 + PUSH R15 + PUSH R16 + PUSH R17 + PUSH R18 + PUSH R19 + PUSH R20 + PUSH R21 + PUSH R22 + PUSH R23 + PUSH R24 + PUSH R25 + PUSH R26 + PUSH R27 + PUSH R28 + PUSH R29 + PUSH R30 + PUSH R31 + + /* k_curr_task->sp = SP */ + LDS R30, k_curr_task + LDS R31, k_curr_task + 1 + + IN R0, SPL + IN R1, SPH + + ST Z, R0 + STD Z + 1, R1 + +_context_restore: + /* k_curr_task = k_next_task */ + LDI R28, low(k_curr_task) + LDI R29, high(k_curr_task) + + LDI R30, low(k_next_task) + LDI R31, high(k_next_task) + + LD R0, Z + LDD R1, Z + 1 + + ST Y, R0 + STD Y + 1, R1 + + /* SP = k_next_task->sp */ + LDS R30, k_next_task + LDS R31, k_next_task + 1 + + LD R0, Z + LDD R1, Z + 1 + + OUT SPL, R0 + OUT SPH, R1 + + /* do restore */ + POP R31 + POP R30 + POP R29 + POP R28 + POP R27 + POP R26 + POP R25 + POP R24 + POP R23 + POP R22 + POP R21 + POP R20 + POP R19 + POP R18 + POP R17 + POP R16 + POP R15 + POP R14 + POP R13 + POP R12 + POP R11 + POP R10 + POP R9 + POP R8 + POP R7 + POP R6 + POP R5 + POP R4 + POP R3 + POP R2 + POP R1 + + POP R0 + OUT SREG, R0 + POP R0 + + RET + + END + diff --git a/arch/avr/common/include/tos_cpu.h b/arch/avr/common/include/tos_cpu.h new file mode 100644 index 00000000..232e2162 --- /dev/null +++ b/arch/avr/common/include/tos_cpu.h @@ -0,0 +1,155 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#ifndef _TOS_CPU_H_ +#define _TOS_CPU_H_ + +typedef struct cpu_context_st { + cpu_data_t R31; + cpu_data_t R30; + cpu_data_t R29; + cpu_data_t R28; + cpu_data_t R27; + cpu_data_t R26; + cpu_data_t R25; + cpu_data_t R24; + cpu_data_t R23; + cpu_data_t R22; + cpu_data_t R21; + cpu_data_t R20; + cpu_data_t R19; + cpu_data_t R18; + cpu_data_t R17; + cpu_data_t R16; + cpu_data_t R15; + cpu_data_t R14; + cpu_data_t R13; + cpu_data_t R12; + cpu_data_t R11; + cpu_data_t R10; + cpu_data_t R9; + cpu_data_t R8; + cpu_data_t R7; + cpu_data_t R6; + cpu_data_t R5; + cpu_data_t R4; + cpu_data_t R3; + cpu_data_t R2; + cpu_data_t R1; + + cpu_data_t SREG; + cpu_data_t R0; + + cpu_data_t PCH; + cpu_data_t PCL; + cpu_data_t LRH; + cpu_data_t LRL; +} cpu_context_t; + +__API__ uint32_t tos_cpu_clz(uint32_t val); + +__API__ void tos_cpu_int_disable(void); + +__API__ void tos_cpu_int_enable(void); + +__API__ cpu_cpsr_t tos_cpu_cpsr_save(void); + +__API__ void tos_cpu_cpsr_restore(cpu_cpsr_t cpsr); + +#if (TOS_CFG_CPU_HRTIMER_EN > 0u) + +__API__ void tos_cpu_hrtimer_init(void); + +__API__ cpu_hrtimer_t tos_cpu_hrtimer_read(void); + +#endif + +__KNL__ void cpu_init(void); + +__KNL__ void cpu_reset(void); + +__KNL__ void cpu_systick_init(k_cycle_t cycle_per_tick); + +__KNL__ void cpu_sched_start(void); + +__KNL__ void cpu_context_switch(void); + +__KNL__ void cpu_irq_context_switch(void); + +#if TOS_CFG_TASK_STACK_DRAUGHT_DEPTH_DETACT_EN > 0u + +__KNL__ k_err_t cpu_task_stack_draught_depth(k_stack_t *stk_base, size_t stk_size, int *depth); + +#endif + +__KNL__ k_stack_t *cpu_task_stk_init(void *entry, + void *arg, + void *exit, + k_stack_t *stk_base, + size_t stk_size); + +#if TOS_CFG_TICKLESS_EN > 0u + +__KNL__ void cpu_systick_resume(void); + +__KNL__ void cpu_systick_suspend(void); + +__KNL__ void cpu_systick_reload_reset(void); + +__KNL__ void cpu_systick_pending_reset(void); + +__KNL__ k_time_t cpu_systick_max_delay_millisecond(void); + +__KNL__ void cpu_systick_expires_set(k_time_t millisecond); + +__KNL__ void cpu_systick_reset(void); + +#endif + +#if TOS_CFG_PWR_MGR_EN > 0u + +__KNL__ void cpu_sleep_mode_enter(void); + +__KNL__ void cpu_stop_mode_enter(void); + +__KNL__ void cpu_standby_mode_enter(void); + +#endif + +#if TOS_CFG_FAULT_BACKTRACE_EN > 0u + +__KNL__ void cpu_fault_diagnosis(void); + +#endif + +/* Allocates CPU status register word. */ +#define TOS_CPU_CPSR_ALLOC() cpu_cpsr_t cpu_cpsr = (cpu_cpsr_t)0u + +/* Save CPU status word & disable interrupts.*/ +#define TOS_CPU_INT_DISABLE() \ + do { \ + cpu_cpsr = tos_cpu_cpsr_save(); \ + } while (0) + +/* Restore CPU status word. */ +#define TOS_CPU_INT_ENABLE() \ + do { \ + tos_cpu_cpsr_restore(cpu_cpsr); \ + } while (0) + +#endif /* _TOS_CPU_H_ */ + diff --git a/arch/avr/common/include/tos_cpu_def.h b/arch/avr/common/include/tos_cpu_def.h new file mode 100644 index 00000000..50d0d838 --- /dev/null +++ b/arch/avr/common/include/tos_cpu_def.h @@ -0,0 +1,30 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#ifndef _TOS_CPU_DEF_H_ +#define _TOS_CPU_DEF_H_ + +#define CPU_WORD_SIZE_08 1 +#define CPU_WORD_SIZE_16 2 +#define CPU_WORD_SIZE_32 3 +#define CPU_WORD_SIZE_64 4 + +#define CPU_STK_GROWTH_ASCENDING 1 +#define CPU_STK_GROWTH_DESCENDING 2 + +#endif /* _TOS_CPU_DEF_H_ */ + diff --git a/arch/avr/common/include/tos_cpu_types.h b/arch/avr/common/include/tos_cpu_types.h new file mode 100644 index 00000000..8ee05361 --- /dev/null +++ b/arch/avr/common/include/tos_cpu_types.h @@ -0,0 +1,56 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#ifndef _TOS_CPU_TYPES_H_ +#define _TOS_CPU_TYPES_H_ + +/* CPU address type based on address bus size. */ +#if (TOS_CFG_CPU_ADDR_SIZE == CPU_WORD_SIZE_32) +typedef uint32_t cpu_addr_t; +#elif (TOS_CFG_CPU_ADDR_SIZE == CPU_WORD_SIZE_16) +typedef uint16_t cpu_addr_t; +#else +typedef uint8_t cpu_addr_t; +#endif + +/* CPU data type based on data bus size. */ +#if (TOS_CFG_CPU_DATA_SIZE == CPU_WORD_SIZE_32) +typedef uint32_t cpu_data_t; +#elif (TOS_CFG_CPU_DATA_SIZE == CPU_WORD_SIZE_16) +typedef uint16_t cpu_data_t; +#else +typedef uint8_t cpu_data_t; +#endif + +#if (TOS_CFG_CPU_HRTIMER_EN > 0) +#if (TOS_CFG_CPU_HRTIMER_SIZE == CPU_WORD_SIZE_08) +typedef uint8_t cpu_hrtimer_t; +#elif (TOS_CFG_CPU_HRTIMER_SIZE == CPU_WORD_SIZE_16) +typedef uint16_t cpu_hrtimer_t; +#elif (TOS_CFG_CPU_HRTIMER_SIZE == CPU_WORD_SIZE_64) +typedef uint64_t cpu_hrtimer_t; +#else +typedef uint32_t cpu_hrtimer_t; +#endif +#else +typedef uint32_t cpu_hrtimer_t; +#endif + +typedef cpu_addr_t cpu_cpsr_t; + +#endif + diff --git a/arch/avr/common/include/tos_fault.h b/arch/avr/common/include/tos_fault.h new file mode 100644 index 00000000..e0fc0781 --- /dev/null +++ b/arch/avr/common/include/tos_fault.h @@ -0,0 +1,206 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#ifndef _TOS_FAULT_H_ +#define _TOS_FAULT_H_ + +#if TOS_CFG_FAULT_BACKTRACE_EN > 0u + +typedef int (*k_fault_log_writer_t)(const char *format, ...); + +#define K_FAULT_STACK_DUMP_DEPTH 10u + +#define K_FAULT_CALL_STACK_BACKTRACE_DEPTH 5u + +typedef struct fault_cpu_frame_st { + cpu_data_t r0; + cpu_data_t r1; + cpu_data_t r2; + cpu_data_t r3; + cpu_data_t r12; + cpu_data_t lr; + cpu_data_t pc; + cpu_data_t spsr; +} fault_cpu_frame_t; + +typedef struct fault_exc_frame_st { + fault_cpu_frame_t cpu_frame; +} fault_exc_frame_t; + +/** + * information we need to do fault backtrace + */ +typedef struct fault_information_st { + int is_thumb : 1; /**< whether it is thumb we use when we fall into fault? */ + int is_on_task : 1; /**< whether we are on a task when fall into fault? */ + int is_stk_ovrf : 1; /**< whether we get a stack overflow */ + + cpu_addr_t pc; /**< just where fault happens */ + + cpu_addr_t sp_before_fault; /**< original sp just before the cpu push the fault exception frame */ + + /** + * we need main_stack_start & main_stack_limit to do call stack backtrace + * when we fall into fault during a task, we should do the call stack backtrace on the task's stack + * but if not, which means we are in kernel, we should do the call stack backtrace on the main stack + * in arm v7-m, this should be the MSP's start and limit + * in arm v7-a, call stack backtrace is another story(much more elegant because we have FP). + */ + cpu_addr_t stack_start; /**< current sp start address we use. if on task, it'll be the task's stack, otherwise it'll be the msp */ + cpu_addr_t stack_limit; /**< current sp limit address */ + cpu_addr_t code_start; /**< current code start address */ + cpu_addr_t code_limit; /**< current code limit address */ +} fault_info_t; + +#if defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) + +#define DEFAULT_CODE_SECTION_NAME ER_IROM1 +#define DEFAULT_CSTACK_SECTION_NAME STACK + +#define SECTION_START(_name_) _name_##$$Base +#define SECTION_END(_name_) _name_##$$Limit +#define IMAGE_SECTION_START(_name_) Image$$##_name_##$$Base +#define IMAGE_SECTION_END(_name_) Image$$##_name_##$$Limit +#define CSTACK_BLOCK_START(_name_) SECTION_START(_name_) +#define CSTACK_BLOCK_END(_name_) SECTION_END(_name_) +#define CODE_SECTION_START(_name_) IMAGE_SECTION_START(_name_) +#define CODE_SECTION_END(_name_) IMAGE_SECTION_END(_name_) + +extern const int CSTACK_BLOCK_START(DEFAULT_CSTACK_SECTION_NAME); +extern const int CSTACK_BLOCK_END(DEFAULT_CSTACK_SECTION_NAME); +extern const int CODE_SECTION_START(DEFAULT_CODE_SECTION_NAME); +extern const int CODE_SECTION_END(DEFAULT_CODE_SECTION_NAME); + +__STATIC_INLINE__ cpu_addr_t fault_code_start(void) +{ + return (cpu_addr_t)&CODE_SECTION_START(DEFAULT_CODE_SECTION_NAME); +} + +__STATIC_INLINE__ cpu_addr_t fault_code_limit(void) +{ + return (cpu_addr_t)&CODE_SECTION_END(DEFAULT_CODE_SECTION_NAME); +} + +__STATIC_INLINE__ cpu_addr_t fault_msp_start(void) +{ + return (cpu_addr_t)&CSTACK_BLOCK_START(DEFAULT_CSTACK_SECTION_NAME); +} + +__STATIC_INLINE__ cpu_addr_t fault_msp_limit(void) +{ + return (cpu_addr_t)&CSTACK_BLOCK_END(DEFAULT_CSTACK_SECTION_NAME); +} + +#elif defined(__ICCARM__) + +#define DEFAULT_CODE_SECTION_NAME ".text" +#define DEFAULT_CSTACK_SECTION_NAME "CSTACK" + +#pragma section=DEFAULT_CSTACK_SECTION_NAME +#pragma section=DEFAULT_CODE_SECTION_NAME + +__STATIC_INLINE__ cpu_addr_t fault_code_start(void) +{ + return (cpu_addr_t)__section_begin(DEFAULT_CODE_SECTION_NAME); +} + +__STATIC_INLINE__ cpu_addr_t fault_code_limit(void) +{ + return (cpu_addr_t)__section_end(DEFAULT_CODE_SECTION_NAME); +} + +__STATIC_INLINE__ cpu_addr_t fault_msp_start(void) +{ + return (cpu_addr_t)__section_begin(DEFAULT_CSTACK_SECTION_NAME); +} + +__STATIC_INLINE__ cpu_addr_t fault_msp_limit(void) +{ + return (cpu_addr_t)__section_end(DEFAULT_CSTACK_SECTION_NAME); +} + +#elif defined(__GNUC__) + +/** + * if we are using keil(armcc) or mdk(iccarm), we probably use the defult link script supplied by the IDE. + * the way to locate the text/stack section start and limit is to find them in default link script. + * but if we build our project by makefile(or something like scons, cmake, etc), we probably need to write + * our own link scrpit, if so, we should do like this(just a demo): + * + _stext = .; + .text : { + *(.text.startup) + *(.text) + *(.text.*) + } + _etext = .; + + __bss_start = .; + .bss : { + *(.bss) + *(.bss.*) + *(COMMON) + _sstack = .; + *(.cstack) + _estack = .; + } + __bss_end = .; + * by this, we can locate text/stack section start and limit by _stext/_etext and _sstack/_estack + */ +#define DEFAULT_CODE_SECTION_START _stext +#define DEFAULT_CODE_SECTION_END _etext +#define DEFAULT_CSTACK_SECTION_START _sstack +#define DEFAULT_CSTACK_SECTION_END _estack + +extern const int DEFAULT_CODE_SECTION_START; +extern const int DEFAULT_CODE_SECTION_END; + +extern const int DEFAULT_CSTACK_SECTION_START; +extern const int DEFAULT_CSTACK_SECTION_END; + +__STATIC_INLINE__ cpu_addr_t fault_code_start(void) +{ + return (cpu_addr_t)(&(DEFAULT_CODE_SECTION_START)); +} + +__STATIC_INLINE__ cpu_addr_t fault_code_limit(void) +{ + return (cpu_addr_t)(&(DEFAULT_CODE_SECTION_END)); +} + +__STATIC_INLINE__ cpu_addr_t fault_msp_start(void) +{ + return (cpu_addr_t)(&(DEFAULT_CSTACK_SECTION_START)); +} + +__STATIC_INLINE__ cpu_addr_t fault_msp_limit(void) +{ + return (cpu_addr_t)(&(DEFAULT_CSTACK_SECTION_END)); +} + +#endif + +__API__ void tos_fault_log_writer_set(k_fault_log_writer_t log_writer); + +__KNL__ int fault_default_log_writer(const char *format, ...); + +__KNL__ void fault_backtrace(cpu_addr_t lr, fault_exc_frame_t *frame); + +#endif + +#endif /* _TOS_FAULT_H_ */ + diff --git a/arch/avr/common/tos_cpu.c b/arch/avr/common/tos_cpu.c new file mode 100644 index 00000000..0c072394 --- /dev/null +++ b/arch/avr/common/tos_cpu.c @@ -0,0 +1,306 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#include "tos_k.h" + +__API__ uint32_t tos_cpu_clz(uint32_t val) +{ +#if defined(TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT) && (TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT == 0u) + uint32_t nbr_lead_zeros = 0; + + if (!(val & 0XFFFF0000)) { + val <<= 16; + nbr_lead_zeros += 16; + } + + if (!(val & 0XFF000000)) { + val <<= 8; + nbr_lead_zeros += 8; + } + + if (!(val & 0XF0000000)) { + val <<= 4; + nbr_lead_zeros += 4; + } + + if (!(val & 0XC0000000)) { + val <<= 2; + nbr_lead_zeros += 2; + } + + if (!(val & 0X80000000)) { + nbr_lead_zeros += 1; + } + + if (!val) { + nbr_lead_zeros += 1; + } + + return (nbr_lead_zeros); +#else + return port_clz(val); +#endif +} + +__API__ void tos_cpu_int_disable(void) +{ + port_int_disable(); +} + +__API__ void tos_cpu_int_enable(void) +{ + port_int_enable(); +} + +__API__ cpu_cpsr_t tos_cpu_cpsr_save(void) +{ + return port_cpsr_save(); +} + +__API__ void tos_cpu_cpsr_restore(cpu_cpsr_t cpsr) +{ + port_cpsr_restore(cpsr); +} + +__KNL__ void cpu_init(void) +{ + k_cpu_cycle_per_tick = TOS_CFG_CPU_CLOCK / k_cpu_tick_per_second; + cpu_systick_init(k_cpu_cycle_per_tick); + +#if (TOS_CFG_CPU_HRTIMER_EN > 0) + tos_cpu_hrtimer_init(); +#endif +} + +__KNL__ void cpu_reset(void) +{ + port_cpu_reset(); +} + +__KNL__ void cpu_sched_start(void) +{ + port_sched_start(); +} + +__KNL__ void cpu_context_switch(void) +{ + port_context_switch(); +} + +__KNL__ void cpu_irq_context_switch(void) +{ + port_irq_context_switch(); +} + +__KNL__ void cpu_systick_init(k_cycle_t cycle_per_tick) +{ +#if 0 + port_systick_priority_set(TOS_CFG_CPU_SYSTICK_PRIO); + port_systick_config(cycle_per_tick); +#endif +} + +#if TOS_CFG_TICKLESS_EN > 0u + +/** + * @brief Set value to systick reload value register + * + * @param cycles The value set to register + * + * @return None + */ +__STATIC_INLINE__ void cpu_systick_reload(k_cycle_t cycle_per_tick) +{ + port_systick_reload(cycle_per_tick); +} + +/** + * @brief Enable systick interrupt + * + * @return None + */ +__KNL__ void cpu_systick_resume(void) +{ + port_systick_resume(); +} + +/** + * @brief Disable systick interrupt + * + * @return None + */ +__KNL__ void cpu_systick_suspend(void) +{ + port_systick_suspend(); +} + +__KNL__ k_time_t cpu_systick_max_delay_millisecond(void) +{ + return port_systick_max_delay_millisecond(); +} + +__KNL__ void cpu_systick_expires_set(k_time_t millisecond) +{ + k_cycle_t cycles; + + cycles = (k_cycle_t)((uint64_t)millisecond * TOS_CFG_CPU_CLOCK / K_TIME_MILLISEC_PER_SEC); /* CLOCK means cycle per second */ + + cpu_systick_reload(cycles - 12); /* interrupt delay */ +} + +__KNL__ void cpu_systick_pending_reset(void) +{ + port_systick_pending_reset(); +} + +__KNL__ void cpu_systick_reset(void) +{ + cpu_systick_reload(k_cpu_cycle_per_tick); +} + +#endif /* TOS_CFG_TICKLESS_EN */ + +#if TOS_CFG_PWR_MGR_EN > 0u + +__KNL__ void cpu_sleep_mode_enter(void) +{ + port_sleep_mode_enter(); +} + +__KNL__ void cpu_stop_mode_enter(void) +{ + port_stop_mode_enter(); +} + +__KNL__ void cpu_standby_mode_enter(void) +{ + port_standby_mode_enter(); +} + +#endif /* TOS_CFG_PWR_MGR_EN */ + +__KNL__ k_stack_t *cpu_task_stk_init(void *entry, + void *arg, + void *exit, + k_stack_t *stk_base, + size_t stk_size) +{ + cpu_data_t *sp; + + sp = (cpu_data_t *)&stk_base[stk_size]; + +#if TOS_CFG_TASK_STACK_DRAUGHT_DEPTH_DETACT_EN > 0u + uint8_t *slot = (uint8_t *)&stk_base[0]; + for (; slot < (uint8_t *)sp; ++slot) { + *slot = 0xCC; + } +#endif + + *--sp = (cpu_data_t)((uint16_t)exit & 0xFF); /* LRL */ + *--sp = (cpu_data_t)(((uint16_t)exit >> 8) & 0xFF); /* LRH */ + + *--sp = (cpu_data_t)((uint16_t)entry & 0xFF); /* PCL */ + *--sp = (cpu_data_t)(((uint16_t)entry >> 8) & 0xFF); /* PCH */ + + *--sp = 0x00; /* R0 */ + + /* SREG: + --------------------------------- + | I | T | H | S | V | N | Z | C | + |-------------------------------- + | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | + --------------------------------- + */ + *--sp = 0x80; /* SREG */ + + *--sp = 0x01; /* R1 */ + *--sp = 0x02; /* R2 */ + *--sp = 0x03; /* R3 */ + *--sp = 0x04; /* R4 */ + *--sp = 0x05; /* R5 */ + *--sp = 0x06; /* R6 */ + *--sp = 0x07; /* R7 */ + *--sp = 0x08; /* R8 */ + *--sp = 0x09; /* R9 */ + *--sp = 0x10; /* R10 */ + *--sp = 0x11; /* R11 */ + *--sp = 0x12; /* R12 */ + *--sp = 0x13; /* R13 */ + *--sp = 0x14; /* R14 */ + *--sp = 0x15; /* R15 */ + *--sp = 0x16; /* R16 */ + *--sp = 0x17; /* R17 */ + *--sp = 0x18; /* R18 */ + *--sp = 0x19; /* R19 */ + *--sp = 0x20; /* R20 */ + *--sp = 0x21; /* R21 */ + *--sp = 0x22; /* R22 */ + *--sp = 0x23; /* R23 */ + + *--sp = (cpu_data_t)((uint16_t)arg & 0xFF); /* R24 */ + *--sp = (cpu_data_t)(((uint16_t)arg >> 8) & 0xFF); /* R25 */ + + *--sp = 0x26; /* R26 X */ + *--sp = 0x27; /* R27 */ + *--sp = 0x28; /* R28 Y */ + *--sp = 0x29; /* R29 */ + *--sp = 0x30; /* R30 Z */ + *--sp = 0x31; /* R31 */ + + /* ATTENTION: + must do a sp decrease here in AVR + */ + return (k_stack_t *)(--sp); +} + +#if TOS_CFG_TASK_STACK_DRAUGHT_DEPTH_DETACT_EN > 0u + +__KNL__ k_err_t cpu_task_stack_draught_depth(k_stack_t *stk_base, size_t stk_size, int *depth) +{ + uint8_t *slot; + uint8_t *sp, *bp; + int the_depth = 0; + + bp = (uint8_t *)&stk_base[0]; + + sp = &stk_base[stk_size]; + + for (slot = sp - 1; slot >= bp; --slot) { + if (*slot != 0xCC) { + the_depth = sp - slot; + } + } + + *depth = the_depth; + if (the_depth == stk_size) { + return K_ERR_TASK_STK_OVERFLOW; + } + + return K_ERR_NONE; +} + +#endif + +#if TOS_CFG_FAULT_BACKTRACE_EN > 0u + +__KNL__ void cpu_fault_diagnosis(void) +{ + port_fault_diagnosis(); +} + +#endif /* TOS_CFG_FAULT_BACKTRACE_EN */ + diff --git a/arch/avr/common/tos_fault.c b/arch/avr/common/tos_fault.c new file mode 100644 index 00000000..1bdbd215 --- /dev/null +++ b/arch/avr/common/tos_fault.c @@ -0,0 +1,205 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#include "tos_k.h" + +#if TOS_CFG_FAULT_BACKTRACE_EN > 0u + +__STATIC_INLINE__ void fault_spin(void) +{ + tos_knl_sched_lock(); + tos_cpu_int_disable(); + while (K_TRUE) { + ; + } +} + +/* EXC_RETURN: + 31 - 28 : EXC_RETURN flag + 27 - 5 : reserved + 4 : 1, basic stack frame; 0, extended stack frame + 3 : 1, return to Thread mode; 0, return to Handler mode + 2 : 1, return to PSP; 0, return to MSP + 1 : reserved, 0 + 0 : reserved, 1 + */ +__STATIC_INLINE__ int fault_is_on_task(cpu_data_t lr) +{ + return (lr & (1u << 2)) != 0; +} + +__STATIC_INLINE__ int fault_is_thumb(cpu_data_t psr) +{ + return (psr & (1u << 24)) != 0; +} + +__STATIC_INLINE__ int fault_is_code(fault_info_t *info, cpu_data_t value) +{ + return value >= info->code_start && value <= info->code_limit; +} + +__STATIC__ void fault_dump_cpu_frame(fault_cpu_frame_t *cpu_frame) +{ + k_fault_log_writer("\n\n====================== CPU Registers =======================\n"); + k_fault_log_writer(" %s: %08x %s: %08x %s: %08x %s: %08x\n", + "R0 ", cpu_frame->r0, + "R1 ", cpu_frame->r1, + "R2 ", cpu_frame->r2, + "R3 ", cpu_frame->r3); + k_fault_log_writer(" %s: %08x %s: %08x %s: %08x %s: %08x\n", + "R12", cpu_frame->r12, + "LR ", cpu_frame->lr, + "PC ", cpu_frame->pc, + "PSR", cpu_frame->spsr); +} + +__STATIC__ void fault_dump_stack(fault_info_t *info, size_t depth) +{ + cpu_addr_t sp = info->sp_before_fault;; + + k_fault_log_writer("\nTASK STACK DUMP:\n"); + while (sp <= info->stack_limit && depth--) { + k_fault_log_writer(" addr: %08x data: %08x\n", sp, (cpu_data_t)*(cpu_data_t *)sp); + sp += sizeof(cpu_addr_t); + } +} + +__STATIC__ void fault_call_stack_backtrace(fault_info_t *info, size_t depth) +{ + cpu_data_t value; + cpu_addr_t sp = info->sp_before_fault; + + if (info->is_stk_ovrf) { + return; + } + + k_fault_log_writer("\n\n====================== Dump Call Stack =====================\n"); + + k_fault_log_writer(" %x\n", info->pc); + + /* walk through the stack, check every content on stack whether is a instruction(code) */ + for (; sp < info->stack_limit && depth; sp += sizeof(cpu_addr_t)) { + value = *((cpu_addr_t *)sp) - sizeof(cpu_addr_t); + + /* if thumb, a instruction's first bit must be 1 */ + if (info->is_thumb && !(value & 1)) { + continue; + } + + if (fault_is_code(info, value)) { + k_fault_log_writer(" %x\n", value); + --depth; + } + } +} + +__STATIC__ void fault_dump_task(fault_info_t *info) +{ + k_task_t *task; + + if (!info->is_on_task) { + return; + } + + task = k_curr_task; + k_fault_log_writer("\n\n====================== Fault on task =======================\n"); + k_fault_log_writer(" TASK NAME: %s\n", task->name); + k_fault_log_writer(" STK BASE: %x\n", info->stack_start); + k_fault_log_writer(" STK SIZE: %x\n", task->stk_size * sizeof(k_stack_t)); + k_fault_log_writer(" STK LIMIT: %x\n", info->stack_limit); + + if (!info->is_stk_ovrf) { + fault_dump_stack(info, K_FAULT_STACK_DUMP_DEPTH); + } +} + +__STATIC__ void fault_dump_information(fault_info_t *info) +{ + k_fault_log_writer("\n\n================== Dump Fault Information ==================\n"); + k_fault_log_writer(" THUMB: %s\n", info->is_thumb ? "TRUE" : "FALSE"); + k_fault_log_writer(" ON TASK: %s\n", info->is_on_task? "TRUE" : "FALSE"); + k_fault_log_writer(" STK OVRF: %s\n", info->is_stk_ovrf? "TRUE" : "FALSE"); + + k_fault_log_writer(" PC: %08x\n", info->pc); + k_fault_log_writer(" SP: %08x\n", info->sp_before_fault); + k_fault_log_writer(" STK START: %08x\n", info->stack_start); + k_fault_log_writer(" STK LIMIT: %08x\n", info->stack_limit); + k_fault_log_writer(" COD START: %08x\n", info->code_start); + k_fault_log_writer(" COD LIMIT: %08x\n", info->code_limit); +} + +__STATIC__ void fault_gather_information(cpu_data_t lr, fault_exc_frame_t *frame, fault_info_t *info) +{ + info->is_thumb = fault_is_thumb(frame->cpu_frame.spsr); + info->is_on_task = fault_is_on_task(lr); + + info->pc = frame->cpu_frame.pc; + + info->sp_before_fault = (cpu_addr_t)frame + sizeof(fault_cpu_frame_t); + + info->code_start = fault_code_start(); + info->code_limit = fault_code_limit(); + + if (info->is_on_task) { + info->stack_start = (cpu_addr_t)k_curr_task->stk_base; + info->stack_limit = info->stack_start + k_curr_task->stk_size * sizeof(k_task_t); + } else { + info->stack_start = fault_msp_start(); + info->stack_limit = fault_msp_limit(); + } + + info->is_stk_ovrf = (info->sp_before_fault < info->stack_start || info->sp_before_fault > info->stack_limit); +} + +__KNL__ int fault_default_log_writer(const char *format, ...) +{ + int len; + va_list ap; + + va_start(ap, format); + len = vprintf(format, ap); + va_end(ap); + + return len; +} + +__API__ void tos_fault_log_writer_set(k_fault_log_writer_t log_writer) +{ + k_fault_log_writer = log_writer; +} + +__KNL__ void fault_backtrace(cpu_addr_t lr, fault_exc_frame_t *frame) +{ + fault_info_t info; + + fault_gather_information(lr, frame, &info); + + fault_dump_information(&info); + + fault_dump_task(&info); + + fault_dump_cpu_frame(&frame->cpu_frame); + + fault_call_stack_backtrace(&info, K_FAULT_CALL_STACK_BACKTRACE_DEPTH); + + cpu_fault_diagnosis(); + + fault_spin(); +} + +#endif + diff --git a/arch/stm8/iccstm8/port.h b/arch/stm8/iccstm8/port.h new file mode 100644 index 00000000..5c77cfa1 --- /dev/null +++ b/arch/stm8/iccstm8/port.h @@ -0,0 +1,70 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#ifndef _PORT_H_ +#define _PORT_H_ + +#if defined(TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT) && (TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT == 1u) +__PORT__ uint32_t port_clz(uint32_t val); +#endif + +__PORT__ void port_int_disable(void); + +__PORT__ void port_int_enable(void); + +__PORT__ cpu_cpsr_t port_cpsr_save(void); + +__PORT__ void port_cpsr_restore(cpu_cpsr_t cpsr); + +__PORT__ void port_cpu_reset(void); + +__PORT__ void port_sched_start(void) __NO_RETURN__; + +__PORT__ void port_context_switch(void); + +__PORT__ void port_irq_context_switch(void); + +__PORT__ void port_systick_config(uint32_t cycle_per_tick); + +__PORT__ void port_systick_priority_set(uint32_t prio); + +#if TOS_CFG_TICKLESS_EN > 0u + +__PORT__ void port_systick_resume(void); + +__PORT__ void port_systick_suspend(void); + +__PORT__ void port_systick_reload(uint32_t cycle_per_tick); + +__PORT__ void port_systick_pending_reset(void); + +__PORT__ k_time_t port_systick_max_delay_millisecond(void); + +#endif + +#if TOS_CFG_PWR_MGR_EN > 0u + +__PORT__ void port_sleep_mode_enter(void); + +__PORT__ void port_stop_mode_enter(void); + +__PORT__ void port_standby_mode_enter(void); + +#endif + +#endif /* _PORT_H_ */ + diff --git a/arch/stm8/iccstm8/port_c.c b/arch/stm8/iccstm8/port_c.c new file mode 100644 index 00000000..e258b678 --- /dev/null +++ b/arch/stm8/iccstm8/port_c.c @@ -0,0 +1,296 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +/* + * The MIT License (MIT) + * + * Copyright (c) 2016-2018 Armink (armink.ztl@gmail.com) + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * 'Software'), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "tos_k.h" + +__PORT__ void port_cpu_reset(void) +{ +#if 0 + NVIC_SystemReset(); +#endif +} + +__PORT__ void port_systick_config(uint32_t cycle_per_tick) +{ +#if 0 + (void)SysTick_Config(cycle_per_tick); +#endif +} + +__PORT__ void port_systick_priority_set(uint32_t prio) +{ +#if 0 + NVIC_SetPriority(SysTick_IRQn, prio); +#endif +} + +#if TOS_CFG_TICKLESS_EN > 0u + +__PORT__ k_time_t port_systick_max_delay_millisecond(void) +{ + k_time_t max_millisecond; + uint32_t max_cycle; + + max_cycle = SysTick_LOAD_RELOAD_Msk; // 24 bit + max_millisecond = (k_time_t)((uint64_t)max_cycle * K_TIME_MILLISEC_PER_SEC / TOS_CFG_CPU_CLOCK); // CLOCK: cycle per second + return max_millisecond; +} + +__PORT__ void port_systick_resume(void) +{ + SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk; + SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk; +} + +__PORT__ void port_systick_suspend(void) +{ + SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk; + SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk; +} + +__PORT__ k_cycle_t port_systick_max_reload_cycle(void) +{ + return SysTick_LOAD_RELOAD_Msk; +} + +__PORT__ void port_systick_reload(uint32_t cycle_per_tick) +{ + uint32_t max_cycle; + + max_cycle = SysTick_LOAD_RELOAD_Msk; // 24 bit + + if (max_cycle - SysTick->VAL > cycle_per_tick - 1u) { + SysTick->LOAD = max_cycle; + } else { + SysTick->LOAD = (cycle_per_tick - 1u) + SysTick->VAL; + } + + SysTick->VAL = 0; +} + +__PORT__ void port_systick_pending_reset(void) +{ + SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk; +} + +#endif + +#if TOS_CFG_PWR_MGR_EN > 0u + +__PORT__ void port_sleep_mode_enter(void) +{ +#if 1 + HAL_PWR_EnterSLEEPMode(PWR_LOWPOWERREGULATOR_ON, PWR_SLEEPENTRY_WFI); +#else + HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI); +#endif +} + +__PORT__ void port_stop_mode_enter(void) +{ + HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); +} + +__PORT__ void port_standby_mode_enter(void) +{ + HAL_PWR_EnterSTANDBYMode(); +} + +#endif + +#if TOS_CFG_FAULT_BACKTRACE_EN > 0u +__STATIC__ void port_fault_do_diagnosis(port_fault_regs_t *regs) +{ + k_fault_log_writer("\n\n====================== Fault Diagnosis =====================\n"); + + if (regs->hfsr.bits.VECTBL) { + k_fault_log_writer(fault_msg[FAULT_INFO_HFSR_VECTBL]); + } + if (regs->hfsr.bits.FORCED) { + /* Memory Management Fault */ + if (regs->cfsr.part.mfsr.value) { + if (regs->cfsr.part.mfsr.bits.IACCVIOL) { + k_fault_log_writer(fault_msg[FAULT_INFO_MFSR_IACCVIOL]); + } + if (regs->cfsr.part.mfsr.bits.DACCVIOL) { + k_fault_log_writer(fault_msg[FAULT_INFO_MFSR_DACCVIOL]); + } + if (regs->cfsr.part.mfsr.bits.MUNSTKERR) { + k_fault_log_writer(fault_msg[FAULT_INFO_MFSR_MUNSTKERR]); + } + if (regs->cfsr.part.mfsr.bits.MSTKERR) { + k_fault_log_writer(fault_msg[FAULT_INFO_MFSR_MSTKERR]); + } + + if (regs->cfsr.part.mfsr.bits.MLSPERR) { + k_fault_log_writer(fault_msg[FAULT_INFO_MFSR_MLSPERR]); + } + + if (regs->cfsr.part.mfsr.bits.MMARVALID) { + if (regs->cfsr.part.mfsr.bits.IACCVIOL || regs->cfsr.part.mfsr.bits.DACCVIOL) { + k_fault_log_writer(fault_msg[FAULT_INFO_MMAR], regs->mmar); + } + } + } + /* Bus Fault */ + if (regs->cfsr.part.bfsr.value) { + if (regs->cfsr.part.bfsr.bits.IBUSERR) { + k_fault_log_writer(fault_msg[FAULT_INFO_BFSR_IBUSERR]); + } + if (regs->cfsr.part.bfsr.bits.PRECISERR) { + k_fault_log_writer(fault_msg[FAULT_INFO_BFSR_PRECISERR]); + } + if (regs->cfsr.part.bfsr.bits.IMPREISERR) { + k_fault_log_writer(fault_msg[FAULT_INFO_BFSR_IMPREISERR]); + } + if (regs->cfsr.part.bfsr.bits.UNSTKERR) { + k_fault_log_writer(fault_msg[FAULT_INFO_BFSR_UNSTKERR]); + } + if (regs->cfsr.part.bfsr.bits.STKERR) { + k_fault_log_writer(fault_msg[FAULT_INFO_BFSR_STKERR]); + } + + if (regs->cfsr.part.bfsr.bits.LSPERR) { + k_fault_log_writer(fault_msg[FAULT_INFO_BFSR_LSPERR]); + } + + if (regs->cfsr.part.bfsr.bits.BFARVALID) { + if (regs->cfsr.part.bfsr.bits.PRECISERR) { + k_fault_log_writer(fault_msg[FAULT_INFO_BFAR], regs->bfar); + } + } + + } + /* Usage Fault */ + if (regs->cfsr.part.ufsr.value) { + if (regs->cfsr.part.ufsr.bits.UNDEFINSTR) { + k_fault_log_writer(fault_msg[FAULT_INFO_UFSR_UNDEFINSTR]); + } + if (regs->cfsr.part.ufsr.bits.INVSTATE) { + k_fault_log_writer(fault_msg[FAULT_INFO_UFSR_INVSTATE]); + } + if (regs->cfsr.part.ufsr.bits.INVPC) { + k_fault_log_writer(fault_msg[FAULT_INFO_UFSR_INVPC]); + } + if (regs->cfsr.part.ufsr.bits.NOCP) { + k_fault_log_writer(fault_msg[FAULT_INFO_UFSR_NOCP]); + } + if (regs->cfsr.part.ufsr.bits.UNALIGNED) { + k_fault_log_writer(fault_msg[FAULT_INFO_UFSR_UNALIGNED]); + } + if (regs->cfsr.part.ufsr.bits.DIVBYZERO0) { + k_fault_log_writer(fault_msg[FAULT_INFO_UFSR_DIVBYZERO0]); + } + } + } + /* Debug Fault */ + if (regs->hfsr.bits.DEBUGEVT) { + if (regs->dfsr.value) { + if (regs->dfsr.bits.HALTED) { + k_fault_log_writer(fault_msg[FAULT_INFO_DFSR_HALTED]); + } + if (regs->dfsr.bits.BKPT) { + k_fault_log_writer(fault_msg[FAULT_INFO_DFSR_BKPT]); + } + if (regs->dfsr.bits.DWTTRAP) { + k_fault_log_writer(fault_msg[FAULT_INFO_DFSR_DWTTRAP]); + } + if (regs->dfsr.bits.VCATCH) { + k_fault_log_writer(fault_msg[FAULT_INFO_DFSR_VCATCH]); + } + if (regs->dfsr.bits.EXTERNAL) { + k_fault_log_writer(fault_msg[FAULT_INFO_DFSR_EXTERNAL]); + } + } + } +} + +__PORT__ void port_fault_diagnosis(void) +{ + port_fault_regs_t regs; + + regs.syshndctrl.value = SCB->SHCSR; + regs.cfsr.value = SCB->CFSR; + regs.mmar = SCB->MMFAR; + regs.bfar = SCB->BFAR; + regs.hfsr.value = SCB->HFSR; + regs.dfsr.value = SCB->DFSR; + regs.afsr = SCB->AFSR; + + port_fault_do_diagnosis(®s); +} + +/*------------------ RealView Compiler -----------------*/ +/* V5 */ +#if defined(__CC_ARM) + +__PORT__ __ASM__ void HardFault_Handler(void) +{ + IMPORT fault_backtrace + + MOV r0, lr + TST lr, #0x04 + ITE EQ + MRSEQ r1, MSP + MRSNE r1, PSP + BL fault_backtrace +} + +/*------------------ ARM Compiler V6 -------------------*/ +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + +__PORT__ void __NAKED__ HardFault_Handler(void) +{ + __ASM__ __VOLATILE__ ( + "MOV r0, lr\n\t" + "TST lr, #0x04\n\t" + "ITE EQ\n\t" + "MRSEQ r1, MSP\n\t" + "MRSNE r1, PSP\n\t" + "BL fault_backtrace\n\t" + ); +} + +#endif /* ARMCC VERSION */ + +#endif /* TOS_CFG_FAULT_BACKTRACE_EN */ + diff --git a/arch/stm8/iccstm8/port_config.h b/arch/stm8/iccstm8/port_config.h new file mode 100644 index 00000000..8259022b --- /dev/null +++ b/arch/stm8/iccstm8/port_config.h @@ -0,0 +1,30 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#ifndef _PORT_CONFIG_H_ +#define _PORT_CONFIG_H_ + +#define TOS_CFG_CPU_ADDR_SIZE CPU_WORD_SIZE_08 +#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_08 +#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING +#define TOS_CFG_CPU_HRTIMER_EN 0u +#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u + +#define TOS_CFG_CPU_ARM_FPU_EN 0u + +#endif /* _PORT_CONFIG_H_ */ + diff --git a/arch/stm8/iccarm/port_s.S b/arch/stm8/iccstm8/port_s.S similarity index 97% rename from arch/stm8/iccarm/port_s.S rename to arch/stm8/iccstm8/port_s.S index 7cd3a585..59c86dad 100644 --- a/arch/stm8/iccarm/port_s.S +++ b/arch/stm8/iccstm8/port_s.S @@ -70,7 +70,7 @@ _context_save: LDW (X), Y _context_restore: - ; k_curr_task = k_next_task + /* k_curr_task = k_next_task */ LDW X, k_next_task LDW Y, #k_curr_task /* equals to: "ldr r0, =k_curr_task "*/ LDW (Y), X diff --git a/board/ATMega32/ATmega16_MINI_BOARD_SCH.pdf b/board/ATMega32/ATmega16_MINI_BOARD_SCH.pdf new file mode 100644 index 00000000..d72e5b45 Binary files /dev/null and b/board/ATMega32/ATmega16_MINI_BOARD_SCH.pdf differ diff --git a/board/ATMega32/BSP/include/tim.h b/board/ATMega32/BSP/include/tim.h new file mode 100644 index 00000000..f54ebf97 --- /dev/null +++ b/board/ATMega32/BSP/include/tim.h @@ -0,0 +1,7 @@ +#ifndef __TIM_H_ +#define __TIM_H_ + +// void Timer2_Init(uint32_t clock, uint32_t tick_per_second); + +#endif + diff --git a/board/ATMega32/BSP/include/uart.h b/board/ATMega32/BSP/include/uart.h new file mode 100644 index 00000000..8dc5a6e9 --- /dev/null +++ b/board/ATMega32/BSP/include/uart.h @@ -0,0 +1,13 @@ +#ifndef __USART_H_ +#define __USART_H_ + +void uart_send_byte(char data); + +void uart_send_string(char *string); + +unsigned char uart_receive(void); + +void uart_init(unsigned int baudrate); + +#endif + diff --git a/board/ATMega32/BSP/src/hal_uart.c b/board/ATMega32/BSP/src/hal_uart.c new file mode 100644 index 00000000..0cb2cde4 --- /dev/null +++ b/board/ATMega32/BSP/src/hal_uart.c @@ -0,0 +1,20 @@ +#if 0 + +#include "tos_hal.h" + +int tos_hal_uart_init(hal_uart_t *uart, hal_uart_port_t port) +{ + +} + +int tos_hal_uart_write(hal_uart_t *uart, const uint8_t *buf, size_t size, uint32_t timeout) +{ + int i = 0; + + for (i = 0; i < size; ++i) { + uart_send_byte(buf[i]); + } +} + + +#endif diff --git a/board/ATMega32/BSP/src/tim.c b/board/ATMega32/BSP/src/tim.c new file mode 100644 index 00000000..b3279547 --- /dev/null +++ b/board/ATMega32/BSP/src/tim.c @@ -0,0 +1,12 @@ +#include "iom32.h" +#include "tim.h" + +void timer1(void) +{ + TCCR1B = 0X00; + TCNT1 = 0; + OCR1B = 800; + TIMSK |= (1 << OCIE1B) | (1 << TOIE1); + TCCR1A = (1 << COM1B1) | (1 << WGM10) | (1 << WGM11); + TCCR1B = (0 << WGM13) | (1 << WGM12) | (0 << CS12) | (0 << CS11) | (1 << CS10); +} diff --git a/board/ATMega32/BSP/src/uart.c b/board/ATMega32/BSP/src/uart.c new file mode 100644 index 00000000..0881a06b --- /dev/null +++ b/board/ATMega32/BSP/src/uart.c @@ -0,0 +1,47 @@ +#include "iom32.h" +#include "uart.h" + +#define F_CPU 16777216 + +void uart_send_byte(char data) +{ + while (!(UCSRA & (1 << UDRE))) { + ; + } + UDR = data; +} + +void uart_send_string(char *string) +{ + for(; *string!='\0'; string++) { + uart_send_byte(*string); + } +} + +unsigned char uart_receive(void) +{ + while (!(UCSRA & (1 << RXC))) { + ; + } + return UDR; +} + +int putchar(int data) +{ + uart_send_byte(data); +} + +void uart_init(unsigned int baudrate) +{ + unsigned int tmp; + tmp = F_CPU / baudrate / 16 - 1; + + /* Set baud rate */ + UBRRH = (unsigned char)(tmp >> 8); + UBRRL = (unsigned char)tmp; + /* Enable receiver and transmitter, enable receive interrupt */ + UCSRB = (1 << RXCIE) | (1 << RXEN) | (1 << TXEN); + /* 8bit, 1 stopbit */ + UCSRC = (1 << URSEL) | (1 << UCSZ1) | (1<< UCSZ0); +} + diff --git a/board/ATMega32/IAR/hello_world-iar4.12/TencentOS_tiny.ewd b/board/ATMega32/IAR/hello_world-iar4.12/TencentOS_tiny.ewd new file mode 100644 index 00000000..3ca1f3ac --- /dev/null +++ b/board/ATMega32/IAR/hello_world-iar4.12/TencentOS_tiny.ewd @@ -0,0 +1,1275 @@ + + + + 1 + + Debug + + AVR + + 1 + + C-SPY + 3 + + 12 + 1 + 1 + + + + + + + + + + + + + + + + + + + + CCRAVR + 2 + + 1 + 1 + 1 + + + + + + + + + + + + + + + + + + + + ICE200AVR + 2 + + 1 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + JTAGICEAVR + 3 + + 2 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + JTAGICEMKIIAVR + 2 + + 4 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SIMAVR + 2 + + 1 + 1 + 1 + + + + + + + THIRDPARTYAVR + 2 + + 1 + 1 + 1 + + + + + + + + + + + + + $EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ewplugin + 1 + + + $EW_DIR$\common\plugins\Orti\Orti.ewplugin + 0 + + + $EW_DIR$\common\plugins\Profiling\Profiling.ewplugin + 1 + + + $EW_DIR$\common\plugins\Stack\Stack.ewplugin + 1 + + + + + Release + + AVR + + 0 + + C-SPY + 3 + + 12 + 1 + 0 + + + + + + + + + + + + + + + + + + + + CCRAVR + 2 + + 1 + 1 + 0 + + + + + + + + + + + + + + + + + + + + ICE200AVR + 2 + + 1 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + JTAGICEAVR + 3 + + 2 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + JTAGICEMKIIAVR + 2 + + 4 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SIMAVR + 2 + + 1 + 1 + 0 + + + + + + + THIRDPARTYAVR + 2 + + 1 + 1 + 0 + + + + + + + + + + + + + $EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ewplugin + 1 + + + $EW_DIR$\common\plugins\Orti\Orti.ewplugin + 0 + + + $EW_DIR$\common\plugins\Profiling\Profiling.ewplugin + 1 + + + $EW_DIR$\common\plugins\Stack\Stack.ewplugin + 1 + + + + + + diff --git a/board/ATMega32/IAR/hello_world-iar4.12/TencentOS_tiny.ewp b/board/ATMega32/IAR/hello_world-iar4.12/TencentOS_tiny.ewp new file mode 100644 index 00000000..94af7af1 --- /dev/null +++ b/board/ATMega32/IAR/hello_world-iar4.12/TencentOS_tiny.ewp @@ -0,0 +1,2081 @@ + + + + 1 + + Debug + + AVR + + 1 + + General + 3 + + 6 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ICCAVR + 3 + + 12 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AAVR + 3 + + 9 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CUSTOM + 3 + + + + + + + BICOMP + 0 + + + + BUILDACTION + 1 + + + + + + + XLINK + 2 + + 13 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + XAR + 2 + + 0 + 1 + 1 + + + + + + + BILINK + 0 + + + + + Release + + AVR + + 0 + + General + 3 + + 6 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ICCAVR + 3 + + 12 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AAVR + 3 + + 9 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CUSTOM + 3 + + + + + + + BICOMP + 0 + + + + BUILDACTION + 1 + + + + + + + XLINK + 2 + + 13 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + XAR + 2 + + 0 + 1 + 0 + + + + + + + BILINK + 0 + + + + + ARCH + + $PROJ_DIR$\..\..\..\..\arch\avr\ATMega32\iccavr\port.h + + + $PROJ_DIR$\..\..\..\..\arch\avr\ATMega32\iccavr\port_c.c + + + $PROJ_DIR$\..\..\..\..\arch\avr\ATMega32\iccavr\port_config.h + + + $PROJ_DIR$\..\..\..\..\arch\avr\ATMega32\iccavr\port_s.asm + + + $PROJ_DIR$\..\..\..\..\arch\avr\common\tos_cpu.c + + + $PROJ_DIR$\..\..\..\..\arch\avr\common\tos_fault.c + + + + BSP + + $PROJ_DIR$\..\..\BSP\src\hal_uart.c + + + $PROJ_DIR$\..\..\BSP\src\tim.c + + + $PROJ_DIR$\..\..\BSP\src\uart.c + + + + KERNEL + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_barrier.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_binary_heap.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_bitmap.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_char_fifo.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_completion.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_countdownlatch.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_event.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_global.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_mail_queue.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_message_queue.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_mmblk.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_mmheap.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_mutex.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_pend.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_priority_mail_queue.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_priority_message_queue.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_priority_queue.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_ring_queue.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_robin.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_rwlock.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_sched.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_sem.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_stopwatch.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_sys.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_task.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_tick.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_time.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_timer.c + + + + LIB + + $PROJ_DIR$\..\..\LIB\inc\stdint.h + + + + TOS-CONFIG + + $PROJ_DIR$\..\..\TOS-CONFIG\tos_config.h + + + + USER + + $PROJ_DIR$\..\..\USER\main.c + + + + + diff --git a/board/ATMega32/IAR/hello_world-iar4.12/TencentOS_tiny.eww b/board/ATMega32/IAR/hello_world-iar4.12/TencentOS_tiny.eww new file mode 100644 index 00000000..39a6f9df --- /dev/null +++ b/board/ATMega32/IAR/hello_world-iar4.12/TencentOS_tiny.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\TencentOS_tiny.ewp + + + + + diff --git a/board/ATMega32/IAR/hello_world-iar4.12/settings/TencentOS_tiny.dbgdt b/board/ATMega32/IAR/hello_world-iar4.12/settings/TencentOS_tiny.dbgdt new file mode 100644 index 00000000..cdcd4982 --- /dev/null +++ b/board/ATMega32/IAR/hello_world-iar4.12/settings/TencentOS_tiny.dbgdt @@ -0,0 +1,176 @@ + + + + + + + + + + + + + 160272727 + + + + + + 100 + + 20 + 1395 + 372 + 93 + + + + + + + + + + 100 + 136 + 120 + 100 + + + + + 10 + + + + + + 138164131100 + + + + + + + + + + + + TabID-3758-6520 + Debug Log + Debug-Log + + + + TabID-3236-6530 + Build + Build + + + TabID-1907-2220BreakpointsBreakpoints + + 0 + + + TabID-14507-6524 + Workspace + Workspace + + + TencentOS_tinyTencentOS_tiny/ARCHTencentOS_tiny/KERNELTencentOS_tiny/TOS-CONFIG + + + + 0 + + + TabID-25255-6527 + Disassembly + Disassembly + + + + + 0 + + + TabID-15366-20631 + Register + Register + + + + + + + 0002SPSREG + + + + 0 + + + TabID-24611-31306 + Quick Watch + QuickWatch + + k_curr_task + + + + TabID-28985-25270 + Live Watch + StaticWatch + + + + + k_curr_taskk_next_taskk_rdyq + + + + + + 0138164131100 + + + + 1 + + + TabID-29862-15633 + Memory + Memory + + + + + + + + + + + 17447441000046 + + + + 0 + + + + + + TextEditorD:\TOS\TencentOS-tiny\kernel\core\tos_task.c032787708770TextEditorD:\TOS\TencentOS-tiny\board\ATmega32\BSP\src\tim.c00176176TextEditorD:\TOS\TencentOS-tiny\kernel\core\tos_sem.c0000TextEditorD:\TOS\TencentOS-tiny\arch\AVR\common\tos_cpu.c010224702470TextEditorD:\TOS\TencentOS-tiny\kernel\core\include\tos_list.h012745154515TextEditorD:\TOS\TencentOS-tiny\kernel\core\tos_timer.c026876547654TextEditorD:\TOS\TencentOS-tiny\board\ATMega32\TOS-CONFIG\tos_config.h015843843TextEditorD:\TOS\TencentOS-tiny\kernel\core\tos_sched.c06723762376TextEditorD:\TOS\TencentOS-tiny\kernel\core\tos_tick.c09333383338TextEditorD:\TOS\TencentOS-tiny\arch\avr\ATMega32\iccavr\port_s.asm06310171017TextEditorD:\TOS\TencentOS-tiny\board\ATmega32\USER\main.c0641307130710TextEditorD:\TOS\TencentOS-tiny\kernel\core\tos_sys.c094246524650100000010000001 + + + + + + + iaridepm1debuggergui1-2-2459251-2-2364409189583447484131771504376-2-2459630-2-2364409189583447484329167504376-2628459985628-2364409189583447484185938504376-29834591220983-2364409189583447484123438504376-2-22411922-2-219242431002083265864189583447484239-23861922-223919241471002083160832189583447484 + + + + diff --git a/board/ATMega32/IAR/hello_world-iar4.12/settings/TencentOS_tiny.dni b/board/ATMega32/IAR/hello_world-iar4.12/settings/TencentOS_tiny.dni new file mode 100644 index 00000000..c2734be7 --- /dev/null +++ b/board/ATMega32/IAR/hello_world-iar4.12/settings/TencentOS_tiny.dni @@ -0,0 +1,18 @@ +[DisAssemblyWindow] +NumStates=_ 1 +State 1=_ 1 +[TraceHelper] +Enabled=0 +ShowSource=1 +[Log file] +LoggingEnabled=_ 0 +LogFile=_ "" +Category=_ 0 +[TermIOLog] +LoggingEnabled=_ 0 +LogFile=_ "" +[Breakpoints] +Bp0=_ "Code" "{D:\TOS\TencentOS-tiny\kernel\core\tos_sys.c}.107.5@1" 0 0 0 0 "" 0 "" +Bp1=_ "Code" "{D:\TOS\TencentOS-tiny\kernel\core\tos_sys.c}.101.19@1" 0 0 0 0 "" 0 "" +Bp2=_ "Code" "{D:\TOS\TencentOS-tiny\kernel\core\tos_tick.c}.112.9@1" 0 0 0 0 "" 0 "" +Count=3 diff --git a/board/ATMega32/IAR/hello_world-iar4.12/settings/TencentOS_tiny.wsdt b/board/ATMega32/IAR/hello_world-iar4.12/settings/TencentOS_tiny.wsdt new file mode 100644 index 00000000..659606b3 --- /dev/null +++ b/board/ATMega32/IAR/hello_world-iar4.12/settings/TencentOS_tiny.wsdt @@ -0,0 +1,76 @@ + + + + + + TencentOS_tiny/Debug + + + + + + + + + 130272727 + + + + + + + 20139537293 + + + + + + + + + + + + TabID-24042-2046 + Workspace + Workspace + + + TencentOS_tiny + + + + 0 + + + TabID-5514-2598 + Build + Build + + + + TabID-14450-14285 + Debug Log + Debug-Log + + + + + 0 + + + + + + TextEditorD:\TOS\TencentOS-tiny\kernel\core\tos_task.c032787708770TextEditorD:\TOS\TencentOS-tiny\board\ATmega32\BSP\src\tim.c00176176TextEditorD:\TOS\TencentOS-tiny\kernel\core\tos_sem.c0000TextEditorD:\TOS\TencentOS-tiny\arch\AVR\common\tos_cpu.c010224702470TextEditorD:\TOS\TencentOS-tiny\kernel\core\include\tos_list.h012745154515TextEditorD:\TOS\TencentOS-tiny\kernel\core\tos_timer.c026876547654TextEditorD:\TOS\TencentOS-tiny\board\ATMega32\TOS-CONFIG\tos_config.h015843843TextEditorD:\TOS\TencentOS-tiny\kernel\core\tos_sched.c06723762376TextEditorD:\TOS\TencentOS-tiny\kernel\core\tos_tick.c09333383338TextEditorD:\TOS\TencentOS-tiny\arch\avr\ATMega32\iccavr\port_s.asm06310171017TextEditorD:\TOS\TencentOS-tiny\board\ATmega32\USER\main.c0641654165410TextEditorD:\TOS\TencentOS-tiny\kernel\core\tos_sys.c094246524650100000010000001 + + + + + + + iaridepm1-2-2434204-2-21119977949154930144663682316-2-21601426-2-21428162100280925352177949154930 + + + + diff --git a/board/ATMega32/IAR/hello_world-iar7.20/TencentOS_tiny.ewd b/board/ATMega32/IAR/hello_world-iar7.20/TencentOS_tiny.ewd new file mode 100644 index 00000000..664a51e4 --- /dev/null +++ b/board/ATMega32/IAR/hello_world-iar7.20/TencentOS_tiny.ewd @@ -0,0 +1,2058 @@ + + + 3 + + Debug + + AVR + + 1 + + C-SPY + 6 + + 16 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ATMELICEAVR + 7 + + 4 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AVRONE + 4 + + 4 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + JTAGICE3AVR + 6 + + 7 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + JTAGICEMKIIAVR + 5 + + 7 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DRAGONAVR + 3 + + 3 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + POWERDEBUGGERAVR + 7 + + 4 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SIMAVR + 2 + + 1 + 1 + 1 + + + + + + + THIRDPARTYAVR + 2 + + 1 + 1 + 1 + + + + + + + + + + + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\Stk600\Stk600Plugin.ewplugin + 1 + + + $EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin + 1 + + + $EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin + 0 + + + $EW_DIR$\common\plugins\TargetAccessServer\TargetAccessServer.ENU.ewplugin + 0 + + + $EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin + 0 + + + + + Release + + AVR + + 0 + + C-SPY + 6 + + 16 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ATMELICEAVR + 7 + + 4 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AVRONE + 4 + + 4 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + JTAGICE3AVR + 6 + + 7 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + JTAGICEMKIIAVR + 5 + + 7 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DRAGONAVR + 3 + + 3 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + POWERDEBUGGERAVR + 7 + + 4 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SIMAVR + 2 + + 1 + 1 + 0 + + + + + + + THIRDPARTYAVR + 2 + + 1 + 1 + 0 + + + + + + + + + + + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\Stk600\Stk600Plugin.ewplugin + 1 + + + $EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin + 1 + + + $EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin + 0 + + + $EW_DIR$\common\plugins\TargetAccessServer\TargetAccessServer.ENU.ewplugin + 0 + + + $EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin + 0 + + + + diff --git a/board/ATMega32/IAR/hello_world-iar7.20/TencentOS_tiny.ewp b/board/ATMega32/IAR/hello_world-iar7.20/TencentOS_tiny.ewp new file mode 100644 index 00000000..000bf554 --- /dev/null +++ b/board/ATMega32/IAR/hello_world-iar7.20/TencentOS_tiny.ewp @@ -0,0 +1,2259 @@ + + + 3 + + Debug + + AVR + + 1 + + General + 12 + + 10 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ICCAVR + 6 + + 17 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AAVR + 5 + + 11 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CUSTOM + 3 + + + + 0 + + + + BICOMP + 0 + + + + BUILDACTION + 1 + + + + + + + XLINK + 3 + + 16 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + XAR + 2 + + 0 + 1 + 1 + + + + + + + BILINK + 0 + + + + + Release + + AVR + + 0 + + General + 12 + + 10 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ICCAVR + 6 + + 17 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AAVR + 5 + + 11 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CUSTOM + 3 + + + + 0 + + + + BICOMP + 0 + + + + BUILDACTION + 1 + + + + + + + XLINK + 3 + + 16 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + XAR + 2 + + 0 + 1 + 0 + + + + + + + BILINK + 0 + + + + + ARCH + + $PROJ_DIR$\..\..\..\..\arch\avr\ATMega32\iccavr\port.h + + + $PROJ_DIR$\..\..\..\..\arch\avr\ATMega32\iccavr\port_c.c + + + $PROJ_DIR$\..\..\..\..\arch\avr\ATMega32\iccavr\port_config.h + + + $PROJ_DIR$\..\..\..\..\arch\avr\ATMega32\iccavr\port_s.asm + + + $PROJ_DIR$\..\..\..\..\arch\avr\common\tos_cpu.c + + + $PROJ_DIR$\..\..\..\..\arch\avr\common\tos_fault.c + + + + BSP + + INC + + $PROJ_DIR$\..\..\BSP\include\tim.h + + + $PROJ_DIR$\..\..\BSP\include\uart.h + + + + SRC + + $PROJ_DIR$\..\..\BSP\src\hal_uart.c + + + $PROJ_DIR$\..\..\BSP\src\tim.c + + + $PROJ_DIR$\..\..\BSP\src\uart.c + + + + + EXAMPLE + + + KERNEL + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_barrier.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_binary_heap.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_bitmap.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_char_fifo.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_completion.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_countdownlatch.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_event.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_global.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_mail_queue.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_message_queue.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_mmblk.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_mmheap.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_mutex.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_pend.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_priority_mail_queue.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_priority_message_queue.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_priority_queue.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_ring_queue.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_robin.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_rwlock.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_sched.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_sem.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_stopwatch.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_sys.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_task.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_tick.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_time.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_timer.c + + + + LIB + + INC + + $PROJ_DIR$\..\..\LIB\inc\stdint.h + + + + + TOS_CONFIG + + $PROJ_DIR$\..\..\TOS-CONFIG\tos_config.h + + + + USER + + $PROJ_DIR$\..\..\USER\main.c + + + diff --git a/board/ATMega32/IAR/hello_world-iar7.20/TencentOS_tiny.ewt b/board/ATMega32/IAR/hello_world-iar7.20/TencentOS_tiny.ewt new file mode 100644 index 00000000..a71cd3d9 --- /dev/null +++ b/board/ATMega32/IAR/hello_world-iar7.20/TencentOS_tiny.ewt @@ -0,0 +1,2312 @@ + + + 3 + + Debug + + AVR + + 1 + + C-STAT + 261 + + 261 + + 0 + + 1 + 600 + 0 + 4 + 0 + 1 + 100 + + + 1.5.4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Release + + AVR + + 0 + + C-STAT + 261 + + 261 + + 0 + + 1 + 600 + 0 + 4 + 0 + 1 + 100 + + + 1.5.4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ARCH + + $PROJ_DIR$\..\..\..\..\arch\avr\ATMega32\iccavr\port.h + + + $PROJ_DIR$\..\..\..\..\arch\avr\ATMega32\iccavr\port_c.c + + + $PROJ_DIR$\..\..\..\..\arch\avr\ATMega32\iccavr\port_config.h + + + $PROJ_DIR$\..\..\..\..\arch\avr\ATMega32\iccavr\port_s.asm + + + $PROJ_DIR$\..\..\..\..\arch\avr\common\tos_cpu.c + + + $PROJ_DIR$\..\..\..\..\arch\avr\common\tos_fault.c + + + + BSP + + INC + + $PROJ_DIR$\..\..\BSP\include\tim.h + + + $PROJ_DIR$\..\..\BSP\include\uart.h + + + + SRC + + $PROJ_DIR$\..\..\BSP\src\hal_uart.c + + + $PROJ_DIR$\..\..\BSP\src\tim.c + + + $PROJ_DIR$\..\..\BSP\src\uart.c + + + + + EXAMPLE + + + KERNEL + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_barrier.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_binary_heap.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_bitmap.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_char_fifo.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_completion.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_countdownlatch.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_event.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_global.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_mail_queue.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_message_queue.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_mmblk.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_mmheap.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_mutex.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_pend.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_priority_mail_queue.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_priority_message_queue.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_priority_queue.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_ring_queue.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_robin.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_rwlock.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_sched.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_sem.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_stopwatch.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_sys.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_task.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_tick.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_time.c + + + $PROJ_DIR$\..\..\..\..\kernel\core\tos_timer.c + + + + LIB + + INC + + $PROJ_DIR$\..\..\LIB\inc\stdint.h + + + + + TOS_CONFIG + + $PROJ_DIR$\..\..\TOS-CONFIG\tos_config.h + + + + USER + + $PROJ_DIR$\..\..\USER\main.c + + + diff --git a/board/ATMega32/IAR/hello_world-iar7.20/TencentOS_tiny.eww b/board/ATMega32/IAR/hello_world-iar7.20/TencentOS_tiny.eww new file mode 100644 index 00000000..39a6f9df --- /dev/null +++ b/board/ATMega32/IAR/hello_world-iar7.20/TencentOS_tiny.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\TencentOS_tiny.ewp + + + + + diff --git a/board/ATMega32/IAR/hello_world-iar7.20/settings/TencentOS_tiny.Debug.cspy.bat b/board/ATMega32/IAR/hello_world-iar7.20/settings/TencentOS_tiny.Debug.cspy.bat new file mode 100644 index 00000000..07189154 --- /dev/null +++ b/board/ATMega32/IAR/hello_world-iar7.20/settings/TencentOS_tiny.Debug.cspy.bat @@ -0,0 +1,40 @@ +@REM This batch file has been generated by the IAR Embedded Workbench +@REM C-SPY Debugger, as an aid to preparing a command line for running +@REM the cspybat command line utility using the appropriate settings. +@REM +@REM Note that this file is generated every time a new debug session +@REM is initialized, so you may want to move or rename the file before +@REM making changes. +@REM +@REM You can launch cspybat by typing the name of this batch file followed +@REM by the name of the debug file (usually an ELF/DWARF or UBROF file). +@REM +@REM Read about available command line parameters in the C-SPY Debugging +@REM Guide. Hints about additional command line parameters that may be +@REM useful in specific cases: +@REM --download_only Downloads a code image without starting a debug +@REM session afterwards. +@REM --silent Omits the sign-on message. +@REM --timeout Limits the maximum allowed execution time. +@REM + + +@echo off + +if not "%~1" == "" goto debugFile + +@echo on + +"D:\Program Files\IAR Systems\Embedded Workbench 8.0 AVR\common\bin\cspybat" -f "D:\TOS\TencentOS-tiny\board\ATMega32\IAR\hello_world-iar7.20\settings\TencentOS_tiny.Debug.general.xcl" --backend -f "D:\TOS\TencentOS-tiny\board\ATMega32\IAR\hello_world-iar7.20\settings\TencentOS_tiny.Debug.driver.xcl" + +@echo off +goto end + +:debugFile + +@echo on + +"D:\Program Files\IAR Systems\Embedded Workbench 8.0 AVR\common\bin\cspybat" -f "D:\TOS\TencentOS-tiny\board\ATMega32\IAR\hello_world-iar7.20\settings\TencentOS_tiny.Debug.general.xcl" "--debug_file=%~1" --backend -f "D:\TOS\TencentOS-tiny\board\ATMega32\IAR\hello_world-iar7.20\settings\TencentOS_tiny.Debug.driver.xcl" + +@echo off +:end \ No newline at end of file diff --git a/board/ATMega32/IAR/hello_world-iar7.20/settings/TencentOS_tiny.Debug.cspy.ps1 b/board/ATMega32/IAR/hello_world-iar7.20/settings/TencentOS_tiny.Debug.cspy.ps1 new file mode 100644 index 00000000..897a62d1 --- /dev/null +++ b/board/ATMega32/IAR/hello_world-iar7.20/settings/TencentOS_tiny.Debug.cspy.ps1 @@ -0,0 +1,31 @@ +param([String]$debugfile = ""); + +# This powershell file has been generated by the IAR Embedded Workbench +# C - SPY Debugger, as an aid to preparing a command line for running +# the cspybat command line utility using the appropriate settings. +# +# Note that this file is generated every time a new debug session +# is initialized, so you may want to move or rename the file before +# making changes. +# +# You can launch cspybat by typing Powershell.exe -File followed by the name of this batch file, followed +# by the name of the debug file (usually an ELF / DWARF or UBROF file). +# +# Read about available command line parameters in the C - SPY Debugging +# Guide. Hints about additional command line parameters that may be +# useful in specific cases : +# --download_only Downloads a code image without starting a debug +# session afterwards. +# --silent Omits the sign - on message. +# --timeout Limits the maximum allowed execution time. +# + + +if ($debugfile -eq "") +{ +& "D:\Program Files\IAR Systems\Embedded Workbench 8.0 AVR\common\bin\cspybat" -f "D:\TOS\TencentOS-tiny\board\ATMega32\IAR\hello_world-iar7.20\settings\TencentOS_tiny.Debug.general.xcl" --backend -f "D:\TOS\TencentOS-tiny\board\ATMega32\IAR\hello_world-iar7.20\settings\TencentOS_tiny.Debug.driver.xcl" +} +else +{ +& "D:\Program Files\IAR Systems\Embedded Workbench 8.0 AVR\common\bin\cspybat" -f "D:\TOS\TencentOS-tiny\board\ATMega32\IAR\hello_world-iar7.20\settings\TencentOS_tiny.Debug.general.xcl" --debug_file=$debugfile --backend -f "D:\TOS\TencentOS-tiny\board\ATMega32\IAR\hello_world-iar7.20\settings\TencentOS_tiny.Debug.driver.xcl" +} diff --git a/board/ATMega32/IAR/hello_world-iar7.20/settings/TencentOS_tiny.Debug.driver.xcl b/board/ATMega32/IAR/hello_world-iar7.20/settings/TencentOS_tiny.Debug.driver.xcl new file mode 100644 index 00000000..fc0d0e21 --- /dev/null +++ b/board/ATMega32/IAR/hello_world-iar7.20/settings/TencentOS_tiny.Debug.driver.xcl @@ -0,0 +1,15 @@ +"--cpu=m32" + +"--enhanced_core" + +"-p" + +"D:\Program Files\IAR Systems\Embedded Workbench 8.0 AVR\avr\Config\iom32.ddf" + +"--eeprom_size" + +"1024" + + + + diff --git a/board/ATMega32/IAR/hello_world-iar7.20/settings/TencentOS_tiny.Debug.general.xcl b/board/ATMega32/IAR/hello_world-iar7.20/settings/TencentOS_tiny.Debug.general.xcl new file mode 100644 index 00000000..c06a909f --- /dev/null +++ b/board/ATMega32/IAR/hello_world-iar7.20/settings/TencentOS_tiny.Debug.general.xcl @@ -0,0 +1,11 @@ +"D:\Program Files\IAR Systems\Embedded Workbench 8.0 AVR\avr\bin\avrproc.dll" + +"D:\Program Files\IAR Systems\Embedded Workbench 8.0 AVR\avr\bin\avrsim.dll" + +"D:\TOS\TencentOS-tiny\board\ATMega32\IAR\hello_world-iar7.20\Debug\Exe\TencentOS_tiny.d90" + +--plugin "D:\Program Files\IAR Systems\Embedded Workbench 8.0 AVR\avr/bin/avrlibsupportbat.dll" + + + + diff --git a/board/ATMega32/IAR/hello_world-iar7.20/settings/TencentOS_tiny.dbgdt b/board/ATMega32/IAR/hello_world-iar7.20/settings/TencentOS_tiny.dbgdt new file mode 100644 index 00000000..1bc35f76 --- /dev/null +++ b/board/ATMega32/IAR/hello_world-iar7.20/settings/TencentOS_tiny.dbgdt @@ -0,0 +1,229 @@ + + + + + + + + 194 + 27 + 27 + 27 + + + + 1 + 0 + 0 + + + 20 + 1395 + 372 + 93 + + + + + + + TabID-10315-10600 + Debug Log + Debug-Log + + + + TabID-9792-10609 + Build + Build + + + + 0 + + + + + TabID-21063-10603 + Workspace + Workspace + + + TencentOS_tiny + + + + + 0 + + + + + TabID-31812-10606 + Disassembly + Disassembly + + + + 0 + + + + + + TextEditor + D:\Program Files\IAR Systems\Embedded Workbench 4.0 AVR\avr\INC\iom32.h + 0 + 0 + 537 + 537 + + + TextEditor + D:\TOS\TencentOS-tiny\board\ATmega32\USER\main.c + 0 + 39 + 879 + 879 + + 1 + + TextEditor + D:\TOS\TencentOS-tiny\board\ATmega32\BSP\src\tim.c + 0 + 0 + 0 + 0 + + + TextEditor + D:\TOS\TencentOS-tiny\board\ATmega32\BSP\src\hal_uart.c + 0 + 0 + 289 + 289 + + + TextEditor + D:\TOS\TencentOS-tiny\board\ATmega32\BSP\include\uart.h + 0 + 0 + 54 + 58 + + + TextEditor + D:\TOS\TencentOS-tiny\board\ATmega32\BSP\src\uart.c + 0 + 0 + 282 + 282 + + + TextEditor + D:\TOS\TencentOS-tiny\board\ATmega32\BSP\include\tim.h + 0 + 0 + 38 + 38 + + + 0 + + + 1000000 + 1000000 + + + 1 + + + + + + + iaridepm1 + + + + + + + debuggergui1 + + + + + + + + + + -2 + -2 + 561 + 268 + -2 + -2 + 270 + 286 + 140625 + 312910 + 140625 + 615974 + + + + + + + + + + + -2 + -2 + 561 + 268 + -2 + -2 + 270 + 286 + 140625 + 312910 + 140625 + 615974 + + + + + + + + + + + -2 + -2 + 284 + 1922 + -2 + -2 + 1924 + 286 + 1002083 + 312910 + 140625 + 312910 + + + + + + + + + + + + diff --git a/board/ATMega32/IAR/hello_world-iar7.20/settings/TencentOS_tiny.dni b/board/ATMega32/IAR/hello_world-iar7.20/settings/TencentOS_tiny.dni new file mode 100644 index 00000000..4d35cea3 --- /dev/null +++ b/board/ATMega32/IAR/hello_world-iar7.20/settings/TencentOS_tiny.dni @@ -0,0 +1,15 @@ +[TraceHelper] +Enabled=0 +ShowSource=1 +[DisAssemblyWindow] +NumStates=_ 1 +State 1=_ 1 +[Log file] +LoggingEnabled=_ 0 +LogFile=_ "" +Category=_ 0 +[TermIOLog] +LoggingEnabled=_ 0 +LogFile=_ "" +[Breakpoints] +Count=0 diff --git a/board/ATMega32/IAR/hello_world-iar7.20/settings/TencentOS_tiny.dnx b/board/ATMega32/IAR/hello_world-iar7.20/settings/TencentOS_tiny.dnx new file mode 100644 index 00000000..00261440 --- /dev/null +++ b/board/ATMega32/IAR/hello_world-iar7.20/settings/TencentOS_tiny.dnx @@ -0,0 +1,52 @@ + + + + 0 + 1 + + + _ 1 + _ 1 + + + _ 0 + _ "" + _ 0 + + + _ 0 + _ "" + + + 0 + + + 0 + 1 + 90 + 1 + 1 + 1 + main + 0 + 50 + + + 0 + 0 + 1 + 0 + 1 + + + 0 + + + 0 + 1 + + + 0 + 0 + + diff --git a/board/ATMega32/IAR/hello_world-iar7.20/settings/TencentOS_tiny.wsdt b/board/ATMega32/IAR/hello_world-iar7.20/settings/TencentOS_tiny.wsdt new file mode 100644 index 00000000..1fa664df --- /dev/null +++ b/board/ATMega32/IAR/hello_world-iar7.20/settings/TencentOS_tiny.wsdt @@ -0,0 +1,533 @@ + + + + + TencentOS_tiny/Debug + + + + + + + 196 + 27 + 27 + 27 + + + + 20 + 1023 + 273 + 68 + + + + + + + + + + TabID-32061-29655 + Workspace + Workspace + + + TencentOS_tiny + + + + + 0 + + + + + TabID-27648-29943 + Build + Build + + + + TabID-16066-10492 + Debug Log + Debug-Log + + + + 0 + + + + + + TextEditor + D:\Program Files\IAR Systems\Embedded Workbench 4.0 AVR\avr\INC\iom32.h + 0 + 0 + 537 + 537 + + + TextEditor + D:\TOS\TencentOS-tiny\board\ATmega32\USER\main.c + 0 + 39 + 879 + 879 + + + TextEditor + D:\TOS\TencentOS-tiny\board\ATmega32\BSP\src\tim.c + 0 + 0 + 0 + 0 + + + TextEditor + D:\TOS\TencentOS-tiny\board\ATmega32\BSP\src\hal_uart.c + 0 + 0 + 289 + 289 + + + TextEditor + D:\TOS\TencentOS-tiny\board\ATmega32\BSP\include\uart.h + 0 + 0 + 54 + 58 + + + TextEditor + D:\TOS\TencentOS-tiny\board\ATmega32\BSP\src\uart.c + 0 + 0 + 282 + 282 + + + TextEditor + D:\TOS\TencentOS-tiny\board\ATmega32\BSP\include\tim.h + 0 + 0 + 38 + 38 + + + TextEditor + D:\TOS\TencentOS-tiny\kernel\core\include\tos_ktypes.h + 0 + 0 + 1019 + 1019 + + 7 + + 0 + + + 1000000 + 1000000 + + + 1 + + + + + + + iaridepm1 + + + + + + + + + + -2 + -2 + 471 + 270 + -2 + -2 + 200 + 200 + 104167 + 218818 + 141667 + 517505 + + + + + + + + + + + + + + + + -2 + -2 + 398 + 1922 + -2 + -2 + 1924 + 400 + 1002083 + 437637 + 104167 + 218818 + + + + + + + + + + + + + 34048 + 34049 + 34050 + 34051 + 34052 + 34053 + 34054 + 34055 + 34056 + 34057 + 34058 + 34059 + 34060 + 34061 + + + + + 57600 + 57601 + 57603 + 33024 + 0 + 57607 + 0 + 57635 + 57634 + 57637 + 0 + 57643 + 57644 + 0 + 33090 + 33057 + 57636 + 57640 + 57641 + 33026 + 33065 + 33063 + 33064 + 33053 + 33054 + 0 + 33035 + 33036 + 34399 + 0 + 33038 + 33039 + 0 + + + + + 173 + 30 + 30 + 30 + + + TencentOS_tiny + + + + 14 + 16 + + + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 16000000040008B00000010000000C8100001400000014810000010000000B81000001000000 + + + 3E000D8400000F84000008840000FFFFFFFF54840000328100001C81000009840000818400007D8400008284000083840000848400005384000020F1000010F0000000F0000020F0000030F0000060F000007784000007840000808C000044D500000C8400003384000078840000706E000008800000098000000A8000000B8000000C800000158000000A81000001E8000001B0000002B0000003B0000004B0000005B0000006B0000007B0000008B0000009B000000AB000000BB000000CB000000DB000000EB000000FB0000010B0000000B00000248100000088000001880000028800000388000004880000058800000E84000030840000 + 1600048400004B000000048100001B000000268100002C00000031840000520000000F81000022000000208100002A0000000C8100001F000000068400004D000000098100001D000000038400004A0000000E810000210000001F810000290000000B8100001A000000058400004C0000000284000049000000058100001C000000328400005300000010840000500000000D8100001C0000000A8400004E00000002E100003600000035E1000043000000 + + + 0 + 0A0000000A0000006E0000006E000000 + 00000000800200009005000093020000 + 4096 + 0 + 0 + 32767 + 0 + + + 1 + + + 4294967295 + 00000000480000000601000013020000 + 000000003200000006010000EA000000 + 4096 + 0 + 0 + 32767 + 0 + + + 1 + + + 34049 + 000000001600000022010000C6000000 + 00000000020100009005000080020000 + 32768 + 0 + 0 + 32767 + 0 + + + 1 + + + 21 + 1408 + 375 + 93 + 2 + D:\TOS\TencentOS-tiny\board\ATmega32\IAR\hello_world\BuildLog.log + 0 + -1 + + + 34052 + 000000001600000022010000C6000000 + 04000000060100007C07000066020000 + 4096 + 0 + 0 + 32767 + 0 + + + 0 + + + + 34053 + 000000001600000022010000C6000000 + 04000000060100007C07000066020000 + 4096 + 0 + 0 + 32767 + 0 + + + 0 + + + + 34054 + 000000001600000022010000C6000000 + 04000000060100007C07000066020000 + 4096 + 0 + 0 + 32767 + 0 + + + 0 + + + + 34055 + 000000001600000022010000C6000000 + 04000000060100007C07000066020000 + 4096 + 0 + 0 + 32767 + 0 + + + 0 + + + + 34056 + 000000001600000022010000C6000000 + 04000000060100007C07000066020000 + 4096 + 0 + 0 + 32767 + 0 + + + 0 + + + + 34058 + 000000001600000022010000C6000000 + 04000000060100007C07000066020000 + 4096 + 0 + 0 + 32767 + 0 + + + 0 + + + + 34050 + 000000001600000080020000A6000000 + 00000000000000008002000090000000 + 32768 + 0 + 0 + 32767 + 0 + + + 0 + + + + 34051 + 000000001600000022010000C6000000 + 000000000000000022010000B0000000 + 32768 + 0 + 0 + 32767 + 0 + + + 0 + + + + 34057 + 00000000160000000601000076010000 + 040000004A00000002010000E3010000 + 4096 + 0 + 0 + 32767 + 0 + + + 0 + + + 2147483647 + 1 + + + 34059 + 00000000160000000601000076010000 + 000000004600000006010000EA000000 + 4096 + 0 + 0 + 32767 + 0 + + + 1 + + + 000000000C000000000000000010000001000000FFFFFFFFFFFFFFFF06010000320000000A010000EA000000010000000200001004000000010000000000000000000000FFFFFFFF02000000098500000B850000FFFF02000B004354616262656450616E65001000000100000000000000480000000601000013020000000000003200000006010000EA000000000000004010005602000000FFFEFF1C53006F0075007200630065002000420072006F00770073006500720020002D0020004E006F007400200065006E00610062006C0065006400000000000985000001000000FFFFFFFFFFFFFFFFFFFEFF0957006F0072006B0073007000610063006500010000000B85000001000000FFFFFFFFFFFFFFFF01000000000000000000000000000000000000000000000001000000FFFFFFFF0985000001000000FFFFFFFF09850000000000000080000000000000FFFFFFFFFFFFFFFF00000000000000000400000004000000000000000100000004000000010000000000000000000000038500000000000000000000000000000000000001000000038500000100000003850000000000000080000000000000FFFFFFFFFFFFFFFF00000000000000000400000004000000000000000100000004000000010000000000000000000000028500000000000000000000000000000000000001000000028500000100000002850000000000000080000001000000FFFFFFFFFFFFFFFF00000000EA00000090050000EE0000000100000001000010040000000100000058FDFFFF6F000000FFFFFFFF070000000185000004850000058500000685000007850000088500000A85000001800080000001000000000000001702000080070000A903000000000000EE0000009005000080020000000000004080005607000000FFFEFF054200750069006C006400010000000185000001000000FFFFFFFFFFFFFFFFFFFEFF094400650062007500670020004C006F006700000000000485000001000000FFFFFFFFFFFFFFFFFFFEFF0C4400650063006C00610072006100740069006F006E007300000000000585000001000000FFFFFFFFFFFFFFFFFFFEFF0A5200650066006500720065006E00630065007300000000000685000001000000FFFFFFFFFFFFFFFFFFFEFF0D460069006E006400200069006E002000460069006C0065007300000000000785000001000000FFFFFFFFFFFFFFFFFFFEFF1541006D0062006900670075006F0075007300200044006500660069006E006900740069006F006E007300000000000885000001000000FFFFFFFFFFFFFFFFFFFEFF0B54006F006F006C0020004F0075007400700075007400000000000A85000001000000FFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000001000000FFFFFFFF0185000001000000FFFFFFFF01850000000000000080000000000000FFFFFFFFFFFFFFFF000000000000000004000000040000000000000001000000040000000100000000000000000000000D85000000000000000000000000000000000000010000000D850000010000000D850000000000000080000000000000FFFFFFFFFFFFFFFF000000000000000004000000040000000000000001000000040000000100000000000000000000000C85000000000000000000000000000000000000010000000C850000010000000C850000000000000000000000000000 + + + Main + 00200000010000002000FFFF01001100434D4643546F6F6C426172427574746F6E00E100000000000030000000FFFEFF000000000000000000000000000100000001000000018001E100000000000031000000FFFEFF000000000000000000000000000100000001000000018003E100000000000033000000FFFEFF0000000000000000000000000001000000010000000180008100000000000014000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF000000000000000000000000000100000001000000018007E100000000000036000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF000000000000000000000000000100000001000000018023E100000000040038000000FFFEFF000000000000000000000000000100000001000000018022E100000000040037000000FFFEFF000000000000000000000000000100000001000000018025E10000000000003A000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF00000000000000000000000000010000000100000001802BE10000000004003D000000FFFEFF00000000000000000000000000010000000100000001802CE10000000004003E000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF000000000000000000000000000100000001000000FFFF01001900434D4643546F6F6C426172436F6D626F426F78427574746F6E4281000000000000FFFFFFFFFFFEFF0001000000000000000100000000000000010000007800000002002050FFFFFFFFFFFEFF00960000000000000000000180218100000000040027000000FFFEFF000000000000000000000000000100000001000000018024E100000000000039000000FFFEFF000000000000000000000000000100000001000000018028E10000000004003B000000FFFEFF000000000000000000000000000100000001000000018029E10000000000003C000000FFFEFF0000000000000000000000000001000000010000000180028100000000000016000000FFFEFF000000000000000000000000000100000001000000018029810000000000002B000000FFFEFF0000000000000000000000000001000000010000000180278100000000000029000000FFFEFF000000000000000000000000000100000001000000018028810000000000002A000000FFFEFF00000000000000000000000000010000000100000001801D8100000000040023000000FFFEFF00000000000000000000000000010000000100000001801E8100000000040024000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF00000000000000000000000000010000000100000001800B810000000000001A000000FFFEFF00000000000000000000000000010000000100000001800C810000000000001B000000FFFEFF00000000000000000000000000010000000100000001805F860000000000002F000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF00000000000000000000000000010000000100000001800E810000000000001D000000FFFEFF00000000000000000000000000010000000100000001800F810000000000001E000000FFFEFF00000000000000000000000000010000000100000000000000FFFEFF044D00610069006E00E8020000 + + + 34048 + 0A0000000A0000006E0000006E000000 + 0000000000000000FE0200001A000000 + 8192 + 0 + 0 + 744 + 0 + + + 1 + + + 34060 + 000000001600000022010000C6000000 + 000000000000000022010000B0000000 + 32768 + 0 + 0 + 32767 + 0 + + + 0 + + + + 34061 + 000000001600000022010000C6000000 + 000000000000000022010000B0000000 + 32768 + 0 + 0 + 32767 + 0 + + + 0 + + + + + + 010000000300000001000000000000000000000001000000010000000200000000000000010000000100000000000000280000002800000001000000060000000500000001000000FFFEFF352400570053005F0044004900520024005C002E002E005C002E002E005C002E002E005C002E002E005C006B00650072006E0065006C005C0063006F00720065005C0069006E0063006C007500640065005C0074006F0073005F006B00740079007000650073002E00680001000000FFFF010014004966436F6E74656E7453746F72616765496D706CFFFEFF00FFFEFFFF24013C003F0078006D006C002000760065007200730069006F006E003D00220031002E0030002200200065006E0063006F00640069006E0067003D0022005500540046002D00380022003F003E000A003C0052006F006F0074003E000A0020002000200020003C004E0075006D0052006F00770073003E0031003C002F004E0075006D0052006F00770073003E000A0020002000200020003C004E0075006D0043006F006C0073003E0031003C002F004E0075006D0043006F006C0073003E000A0020002000200020003C00580050006F0073003E0030003C002F00580050006F0073003E000A0020002000200020003C00590050006F0073003E0030003C002F00590050006F0073003E000A0020002000200020003C00530065006C00530074006100720074003E0030003C002F00530065006C00530074006100720074003E000A0020002000200020003C00530065006C0045006E0064003E0030003C002F00530065006C0045006E0064003E000A0020002000200020003C00580050006F00730032003E0030003C002F00580050006F00730032003E000A0020002000200020003C00590050006F00730032003E0034003C002F00590050006F00730032003E000A0020002000200020003C00530065006C005300740061007200740032003E003900330034003C002F00530065006C005300740061007200740032003E000A0020002000200020003C00530065006C0045006E00640032003E003900330034003C002F00530065006C0045006E00640032003E000A003C002F0052006F006F0074003E000A00FFFEFF0C74006F0073005F006B00740079007000650073002E00680000000000FFFFFFFFFFFFFFFFFFFEFF2C44003A005C0054004F0053005C00540065006E00630065006E0074004F0053002D00740069006E0079005C006B00650072006E0065006C005C0063006F00720065005C0074006F0073005F007400610073006B002E006300010000000180FFFEFF00FFFEFFFF21013C003F0078006D006C002000760065007200730069006F006E003D00220031002E0030002200200065006E0063006F00640069006E0067003D0022005500540046002D00380022003F003E000A003C0052006F006F0074003E000A0020002000200020003C004E0075006D0052006F00770073003E0031003C002F004E0075006D0052006F00770073003E000A0020002000200020003C004E0075006D0043006F006C0073003E0031003C002F004E0075006D0043006F006C0073003E000A0020002000200020003C00580050006F0073003E0030003C002F00580050006F0073003E000A0020002000200020003C00590050006F0073003E0030003C002F00590050006F0073003E000A0020002000200020003C00530065006C00530074006100720074003E0030003C002F00530065006C00530074006100720074003E000A0020002000200020003C00530065006C0045006E0064003E0030003C002F00530065006C0045006E0064003E000A0020002000200020003C00580050006F00730032003E0030003C002F00580050006F00730032003E000A0020002000200020003C00590050006F00730032003E00380031003C002F00590050006F00730032003E000A0020002000200020003C00530065006C005300740061007200740032003E0030003C002F00530065006C005300740061007200740032003E000A0020002000200020003C00530065006C0045006E00640032003E0030003C002F00530065006C0045006E00640032003E000A003C002F0052006F006F0074003E000A00FFFEFF0A74006F0073005F007400610073006B002E00630000000000FFFFFFFFFFFFFFFFFFFEFF2E44003A005C0054004F0053005C00540065006E00630065006E0074004F0053002D00740069006E0079005C006B00650072006E0065006C005C0063006F00720065005C0074006F0073005F0067006C006F00620061006C002E006300010000000180FFFEFF00FFFEFFFF27013C003F0078006D006C002000760065007200730069006F006E003D00220031002E0030002200200065006E0063006F00640069006E0067003D0022005500540046002D00380022003F003E000A003C0052006F006F0074003E000A0020002000200020003C004E0075006D0052006F00770073003E0031003C002F004E0075006D0052006F00770073003E000A0020002000200020003C004E0075006D0043006F006C0073003E0031003C002F004E0075006D0043006F006C0073003E000A0020002000200020003C00580050006F0073003E0030003C002F00580050006F0073003E000A0020002000200020003C00590050006F0073003E0030003C002F00590050006F0073003E000A0020002000200020003C00530065006C00530074006100720074003E0030003C002F00530065006C00530074006100720074003E000A0020002000200020003C00530065006C0045006E0064003E0030003C002F00530065006C0045006E0064003E000A0020002000200020003C00580050006F00730032003E0030003C002F00580050006F00730032003E000A0020002000200020003C00590050006F00730032003E00310039003C002F00590050006F00730032003E000A0020002000200020003C00530065006C005300740061007200740032003E0031003400300036003C002F00530065006C005300740061007200740032003E000A0020002000200020003C00530065006C0045006E00640032003E0031003400300036003C002F00530065006C0045006E00640032003E000A003C002F0052006F006F0074003E000A00FFFEFF0C74006F0073005F0067006C006F00620061006C002E00630000000000FFFFFFFFFFFFFFFFFFFEFF332400570053005F0044004900520024005C002E002E005C002E002E005C002E002E005C002E002E005C006B00650072006E0065006C005C0063006F00720065005C0069006E0063006C007500640065005C0074006F0073005F007400610073006B002E006800010000000180FFFEFF00FFFEFFFF27013C003F0078006D006C002000760065007200730069006F006E003D00220031002E0030002200200065006E0063006F00640069006E0067003D0022005500540046002D00380022003F003E000A003C0052006F006F0074003E000A0020002000200020003C004E0075006D0052006F00770073003E0031003C002F004E0075006D0052006F00770073003E000A0020002000200020003C004E0075006D0043006F006C0073003E0031003C002F004E0075006D0043006F006C0073003E000A0020002000200020003C00580050006F0073003E0030003C002F00580050006F0073003E000A0020002000200020003C00590050006F0073003E0030003C002F00590050006F0073003E000A0020002000200020003C00530065006C00530074006100720074003E0030003C002F00530065006C00530074006100720074003E000A0020002000200020003C00530065006C0045006E0064003E0030003C002F00530065006C0045006E0064003E000A0020002000200020003C00580050006F00730032003E0030003C002F00580050006F00730032003E000A0020002000200020003C00590050006F00730032003E00350038003C002F00590050006F00730032003E000A0020002000200020003C00530065006C005300740061007200740032003E0037003300310039003C002F00530065006C005300740061007200740032003E000A0020002000200020003C00530065006C0045006E00640032003E0037003300310039003C002F00530065006C0045006E00640032003E000A003C002F0052006F006F0074003E000A00FFFEFF0A74006F0073005F007400610073006B002E00680000000000FFFFFFFFFFFFFFFFFFFEFF262400570053005F0044004900520024005C002E002E005C002E002E005C0054004F0053002D0043004F004E004600490047005C0074006F0073005F0063006F006E006600690067002E006800010000000180FFFEFF00FFFEFFFF20013C003F0078006D006C002000760065007200730069006F006E003D00220031002E0030002200200065006E0063006F00640069006E0067003D0022005500540046002D00380022003F003E000A003C0052006F006F0074003E000A0020002000200020003C004E0075006D0052006F00770073003E0031003C002F004E0075006D0052006F00770073003E000A0020002000200020003C004E0075006D0043006F006C0073003E0031003C002F004E0075006D0043006F006C0073003E000A0020002000200020003C00580050006F0073003E0030003C002F00580050006F0073003E000A0020002000200020003C00590050006F0073003E0030003C002F00590050006F0073003E000A0020002000200020003C00530065006C00530074006100720074003E0030003C002F00530065006C00530074006100720074003E000A0020002000200020003C00530065006C0045006E0064003E0030003C002F00530065006C0045006E0064003E000A0020002000200020003C00580050006F00730032003E0030003C002F00580050006F00730032003E000A0020002000200020003C00590050006F00730032003E0032003C002F00590050006F00730032003E000A0020002000200020003C00530065006C005300740061007200740032003E0030003C002F00530065006C005300740061007200740032003E000A0020002000200020003C00530065006C0045006E00640032003E0030003C002F00530065006C0045006E00640032003E000A003C002F0052006F006F0074003E000A00FFFEFF0C74006F0073005F0063006F006E006600690067002E00680000000000FFFFFFFFFFFFFFFFFFFEFF1A2400570053005F0044004900520024005C002E002E005C002E002E005C0055005300450052005C006D00610069006E002E006300010000000180FFFEFF00FFFEFFFF27013C003F0078006D006C002000760065007200730069006F006E003D00220031002E0030002200200065006E0063006F00640069006E0067003D0022005500540046002D00380022003F003E000A003C0052006F006F0074003E000A0020002000200020003C004E0075006D0052006F00770073003E0031003C002F004E0075006D0052006F00770073003E000A0020002000200020003C004E0075006D0043006F006C0073003E0031003C002F004E0075006D0043006F006C0073003E000A0020002000200020003C00580050006F0073003E0030003C002F00580050006F0073003E000A0020002000200020003C00590050006F0073003E0030003C002F00590050006F0073003E000A0020002000200020003C00530065006C00530074006100720074003E0030003C002F00530065006C00530074006100720074003E000A0020002000200020003C00530065006C0045006E0064003E0030003C002F00530065006C0045006E0064003E000A0020002000200020003C00580050006F00730032003E0030003C002F00580050006F00730032003E000A0020002000200020003C00590050006F00730032003E00350036003C002F00590050006F00730032003E000A0020002000200020003C00530065006C005300740061007200740032003E0031003200320039003C002F00530065006C005300740061007200740032003E000A0020002000200020003C00530065006C0045006E00640032003E0031003200320039003C002F00530065006C0045006E00640032003E000A003C002F0052006F006F0074003E000A00FFFEFF066D00610069006E002E00630000000000FFFFFFFFFFFFFFFF0000000010000000C5D4F200FFDC7800BECEA100F0A0A100BCA8E1009CC1B600F7B88600D9ADC200A5C2D700B3A6BE00EAD6A300F6FA7D00B5E99D005FC3CF00C1838300CACAD50001000000010000000200000035020000D0000000BB06000088010000 + + + + diff --git a/board/ATMega32/LIB/inc/stdint.h b/board/ATMega32/LIB/inc/stdint.h new file mode 100644 index 00000000..072478fe --- /dev/null +++ b/board/ATMega32/LIB/inc/stdint.h @@ -0,0 +1,17 @@ +#ifndef _STDINT_H_ +#define _STDINT_H_ + +typedef unsigned char uint8_t; +typedef char int8_t; + +typedef unsigned short uint16_t; +typedef signed short int16_t; + +typedef unsigned long uint32_t; +typedef signed long int32_t; + +typedef unsigned long long uint64_t; +typedef signed long long int64_t; + +#endif + diff --git a/board/ATMega32/TOS-CONFIG/tos_config.h b/board/ATMega32/TOS-CONFIG/tos_config.h new file mode 100644 index 00000000..98b3e4a6 --- /dev/null +++ b/board/ATMega32/TOS-CONFIG/tos_config.h @@ -0,0 +1,53 @@ +#ifndef _TOS_CONFIG_H_ +#define _TOS_CONFIG_H_ + +#define TOS_CFG_TASK_PRIO_MAX 10u + +#define TOS_CFG_ROUND_ROBIN_EN 0u + +#define TOS_CFG_OBJECT_VERIFY_EN 0u + +#define TOS_CFG_TASK_DYNAMIC_CREATE_EN 0u + +#define TOS_CFG_EVENT_EN 1u + +#define TOS_CFG_MMBLK_EN 0u + +#define TOS_CFG_MMHEAP_EN 0u + +#define TOS_CFG_MMHEAP_DEFAULT_POOL_EN 1u + +#define TOS_CFG_MMHEAP_DEFAULT_POOL_SIZE 0x1000 + +#define TOS_CFG_MUTEX_EN 1u + +#define TOS_CFG_MESSAGE_QUEUE_EN 1u + +#define TOS_CFG_MAIL_QUEUE_EN 1u + +#define TOS_CFG_PRIORITY_MESSAGE_QUEUE_EN 0u + +#define TOS_CFG_PRIORITY_MAIL_QUEUE_EN 0u + +#define TOS_CFG_TIMER_EN 0u + +#define TOS_CFG_PWR_MGR_EN 0u + +#define TOS_CFG_TICKLESS_EN 0u + +#define TOS_CFG_SEM_EN 1u + +#define TOS_CFG_TASK_STACK_DRAUGHT_DEPTH_DETACT_EN 1u + +#define TOS_CFG_FAULT_BACKTRACE_EN 0u + +#define TOS_CFG_IDLE_TASK_STK_SIZE 128u + +#define TOS_CFG_CPU_TICK_PER_SECOND 1000u + +#define TOS_CFG_CPU_CLOCK (16000000) + +#define TOS_CFG_TIMER_AS_PROC 1u + +#endif + diff --git a/board/ATMega32/USER/main.c b/board/ATMega32/USER/main.c new file mode 100644 index 00000000..f24f960e --- /dev/null +++ b/board/ATMega32/USER/main.c @@ -0,0 +1,88 @@ +#include "iom32.h" +#include "uart.h" +#include "tos_k.h" + +#include "stdio.h" + +#pragma vector = TIMER1_OVF_vect +__interrupt void TIMER1_OVF(void) +{ + if (tos_knl_is_running()) { + tos_knl_irq_enter(); + tos_tick_handler(); + tos_knl_irq_leave(); + } +} + +#pragma vector = USART_RXC_vect +__interrupt void UART0_rx(void) +{ + unsigned char rx_data; + rx_data = UDR; +} + +void interrupt_enable(void) +{ + SREG |= (1 << 7); +} + +void task1_entry(void *arg) +{ + while (1) { + uart_send_string("task1\r\n"); + tos_task_delay(2000); + } +} + +void task2_entry(void *arg) +{ + while (1) { + uart_send_string("task2\r\n"); + tos_task_delay(3000); + } +} + +k_task_t task1; +k_stack_t task1_stack[128]; + +k_task_t task2; +k_stack_t task2_stack[128]; + +#define APPLICATION_TASK_STK_SIZE 256 + +k_task_t task_app; +k_stack_t task_app_stack[128]; + +void application_entry(void * arg) +{ + tos_task_create(&task1, "task1", task1_entry, NULL, + 4, + task1_stack, sizeof(task1_stack), + 0); + + tos_task_create(&task2, "task2", task2_entry, NULL, + 4, + task2_stack, sizeof(task2_stack), + 0); +} + +int main(void) +{ + uart_init(9600); + timer1(); + + uart_send_string("welcome to TencentOS tiny!\r\n"); + printf("welcome to TencentOS tiny!\r\n"); + + tos_knl_init(); + + tos_task_create(&task_app, "app", application_entry, NULL, + 4, + task_app_stack, sizeof(task_app_stack), + 0); + + tos_knl_start(); + + while (1); +} + diff --git a/board/STM8L052R8T6/BSP/include/tim.h b/board/STM8L052R8T6/BSP/include/tim.h index 23c36201..6b6297ce 100644 --- a/board/STM8L052R8T6/BSP/include/tim.h +++ b/board/STM8L052R8T6/BSP/include/tim.h @@ -1,7 +1,7 @@ #ifndef __TIM_H_ #define __TIM_H_ -void Timer2_Init(uint32_t clock, uint32_t tick_per_second); +void timer1(void); #endif diff --git a/board/STM8L052R8T6/BSP/src/uart.c b/board/STM8L052R8T6/BSP/src/uart.c index 10b10cf0..5f41d0a6 100644 --- a/board/STM8L052R8T6/BSP/src/uart.c +++ b/board/STM8L052R8T6/BSP/src/uart.c @@ -5,11 +5,13 @@ const uint8_t HEX_TABLE[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; -int putchar(int c) { +int putchar(int c) +{ if('\n' == (char)c) { USART_SendData8(USART1, '\r'); while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET); } + USART_SendData8(USART1, c); while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET); return (c); @@ -17,95 +19,90 @@ int putchar(int c) { void UART1_Send_Byte(uint8_t ucData) { - USART_SendData8(USART1, ucData); - while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == 0) - ; + USART_SendData8(USART1, ucData); + while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == 0) + ; } -//send string +/* send string */ void UART1_Send_String(char *Str) { - - while (*Str != '\0') // "\0" meaning is the end of a string - { - UART1_Send_Byte(*Str); - Str++; - } + while (*Str != '\0') { // "\0" meaning is the end of a string + UART1_Send_Byte(*Str); + Str++; + } } void UART1_Send_Dec(unsigned int num, unsigned char ucNumCount) { - char disp_buffer1[2]; - char disp_buffer2[3]; - char disp_buffer3[4]; - char disp_buffer4[5]; - char disp_buffer5[6]; - char disp_buffer6[7]; + char disp_buffer1[2]; + char disp_buffer2[3]; + char disp_buffer3[4]; + char disp_buffer4[5]; + char disp_buffer5[6]; + char disp_buffer6[7]; - switch (ucNumCount) - { - case 1: + switch (ucNumCount) + { + case 1: + disp_buffer1[0] = HEX_TABLE[num % 10]; + disp_buffer1[1] = 0; - disp_buffer1[0] = HEX_TABLE[num % 10]; - disp_buffer1[1] = 0; + UART1_Send_String(disp_buffer1); + break; - UART1_Send_String(disp_buffer1); - break; + case 2: + disp_buffer2[0] = HEX_TABLE[(num % 100) / 10]; + disp_buffer2[1] = HEX_TABLE[num % 10]; + disp_buffer2[2] = 0; + UART1_Send_String(disp_buffer2); + break; - case 2: - disp_buffer2[0] = HEX_TABLE[(num % 100) / 10]; - disp_buffer2[1] = HEX_TABLE[num % 10]; - disp_buffer2[2] = 0; - UART1_Send_String(disp_buffer2); - break; - case 3: - disp_buffer3[0] = HEX_TABLE[num / 100]; - disp_buffer3[1] = HEX_TABLE[(num % 100) / 10]; - disp_buffer3[2] = HEX_TABLE[num % 10]; - disp_buffer3[3] = 0; + case 3: + disp_buffer3[0] = HEX_TABLE[num / 100]; + disp_buffer3[1] = HEX_TABLE[(num % 100) / 10]; + disp_buffer3[2] = HEX_TABLE[num % 10]; + disp_buffer3[3] = 0; - UART1_Send_String(disp_buffer3); - break; + UART1_Send_String(disp_buffer3); + break; - case 4: - disp_buffer4[0] = HEX_TABLE[(num % 10000) / 1000]; - disp_buffer4[1] = HEX_TABLE[(num % 1000) / 100]; - disp_buffer4[2] = HEX_TABLE[(num % 100) / 10]; - disp_buffer4[3] = HEX_TABLE[num % 10]; - disp_buffer4[4] = 0; + case 4: + disp_buffer4[0] = HEX_TABLE[(num % 10000) / 1000]; + disp_buffer4[1] = HEX_TABLE[(num % 1000) / 100]; + disp_buffer4[2] = HEX_TABLE[(num % 100) / 10]; + disp_buffer4[3] = HEX_TABLE[num % 10]; + disp_buffer4[4] = 0; - UART1_Send_String(disp_buffer4); - break; + UART1_Send_String(disp_buffer4); + break; - case 5: + case 5: + disp_buffer5[0] = HEX_TABLE[(num % 100000) / 10000]; + disp_buffer5[1] = HEX_TABLE[(num % 10000) / 1000]; + disp_buffer5[2] = HEX_TABLE[(num % 1000) / 100]; + disp_buffer5[3] = HEX_TABLE[(num % 100) / 10]; + disp_buffer5[4] = HEX_TABLE[num % 10]; + disp_buffer5[5] = 0; - disp_buffer5[0] = HEX_TABLE[(num % 100000) / 10000]; - disp_buffer5[1] = HEX_TABLE[(num % 10000) / 1000]; - disp_buffer5[2] = HEX_TABLE[(num % 1000) / 100]; - disp_buffer5[3] = HEX_TABLE[(num % 100) / 10]; - disp_buffer5[4] = HEX_TABLE[num % 10]; - disp_buffer5[5] = 0; + UART1_Send_String(disp_buffer5); + break; - UART1_Send_String(disp_buffer5); - break; + case 6: + disp_buffer6[0] = HEX_TABLE[num / 100000]; + disp_buffer6[1] = HEX_TABLE[(num % 100000) / 10000]; + disp_buffer6[2] = HEX_TABLE[(num % 10000) / 1000]; + disp_buffer6[3] = HEX_TABLE[(num % 1000) / 100]; + disp_buffer6[4] = HEX_TABLE[(num % 100) / 10]; + disp_buffer6[5] = HEX_TABLE[num % 10]; + disp_buffer6[6] = 0; - case 6: + UART1_Send_String(disp_buffer6); + break; - disp_buffer6[0] = HEX_TABLE[num / 100000]; - disp_buffer6[1] = HEX_TABLE[(num % 100000) / 10000]; - disp_buffer6[2] = HEX_TABLE[(num % 10000) / 1000]; - disp_buffer6[3] = HEX_TABLE[(num % 1000) / 100]; - disp_buffer6[4] = HEX_TABLE[(num % 100) / 10]; - disp_buffer6[5] = HEX_TABLE[num % 10]; - disp_buffer6[6] = 0; - - UART1_Send_String(disp_buffer6); - break; - - default: - - break; - } + default: + break; + } } void UART1_Init(uint32_t uiBaudRate) @@ -128,3 +125,4 @@ void UART1_Init(uint32_t uiBaudRate) // enable UART1 USART_Cmd(USART1, ENABLE); } + diff --git a/board/STM8L052R8T6/IAR/hello_world/stm8_project.ewp b/board/STM8L052R8T6/IAR/hello_world/stm8_project.ewp index 6effe06c..047e0c65 100644 --- a/board/STM8L052R8T6/IAR/hello_world/stm8_project.ewp +++ b/board/STM8L052R8T6/IAR/hello_world/stm8_project.ewp @@ -259,7 +259,7 @@ CCIncludePath2 $PROJ_DIR$\..\..\..\..\kernel\core\include $PROJ_DIR$\..\..\..\..\arch\stm8\common\include - $PROJ_DIR$\..\..\..\..\arch\stm8\iccarm + $PROJ_DIR$\..\..\..\..\arch\stm8\iccstm8 $PROJ_DIR$\..\..\BSP\include $PROJ_DIR$\..\..\LIB\inc $PROJ_DIR$\..\..\TOS-CONFIG @@ -1646,16 +1646,16 @@ arch - $PROJ_DIR$\..\..\..\..\arch\stm8\iccarm\port.h + $PROJ_DIR$\..\..\..\..\arch\stm8\iccstm8\port.h - $PROJ_DIR$\..\..\..\..\arch\stm8\iccarm\port_c.c + $PROJ_DIR$\..\..\..\..\arch\stm8\iccstm8\port_c.c - $PROJ_DIR$\..\..\..\..\arch\stm8\iccarm\port_config.h + $PROJ_DIR$\..\..\..\..\arch\stm8\iccstm8\port_config.h - $PROJ_DIR$\..\..\..\..\arch\stm8\iccarm\port_s.S + $PROJ_DIR$\..\..\..\..\arch\stm8\iccstm8\port_s.S $PROJ_DIR$\..\..\..\..\arch\stm8\common\tos_cpu.c diff --git a/board/STM8L052R8T6/IAR/hello_world/stm8_project.ewt b/board/STM8L052R8T6/IAR/hello_world/stm8_project.ewt index 90ff2051..24b6bdc2 100644 --- a/board/STM8L052R8T6/IAR/hello_world/stm8_project.ewt +++ b/board/STM8L052R8T6/IAR/hello_world/stm8_project.ewt @@ -2160,16 +2160,16 @@ arch - $PROJ_DIR$\..\..\..\..\arch\stm8\iccarm\port.h + $PROJ_DIR$\..\..\..\..\arch\stm8\iccstm8\port.h - $PROJ_DIR$\..\..\..\..\arch\stm8\iccarm\port_c.c + $PROJ_DIR$\..\..\..\..\arch\stm8\iccstm8\port_c.c - $PROJ_DIR$\..\..\..\..\arch\stm8\iccarm\port_config.h + $PROJ_DIR$\..\..\..\..\arch\stm8\iccstm8\port_config.h - $PROJ_DIR$\..\..\..\..\arch\stm8\iccarm\port_s.S + $PROJ_DIR$\..\..\..\..\arch\stm8\iccstm8\port_s.S $PROJ_DIR$\..\..\..\..\arch\stm8\common\tos_cpu.c diff --git a/board/STM8L052R8T6/IAR/shell/stm8_project.ewp b/board/STM8L052R8T6/IAR/shell/stm8_project.ewp index 78bc6d11..14a7f743 100644 --- a/board/STM8L052R8T6/IAR/shell/stm8_project.ewp +++ b/board/STM8L052R8T6/IAR/shell/stm8_project.ewp @@ -259,7 +259,7 @@ CCIncludePath2 $PROJ_DIR$\..\..\..\..\kernel\core\include $PROJ_DIR$\..\..\..\..\arch\stm8\common\include - $PROJ_DIR$\..\..\..\..\arch\stm8\iccarm + $PROJ_DIR$\..\..\..\..\arch\stm8\iccstm8 $PROJ_DIR$\..\..\BSP\include $PROJ_DIR$\..\..\LIB\inc $PROJ_DIR$\..\..\TOS-CONFIG @@ -1648,16 +1648,16 @@ arch - $PROJ_DIR$\..\..\..\..\arch\stm8\iccarm\port.h + $PROJ_DIR$\..\..\..\..\arch\stm8\iccstm8\port.h - $PROJ_DIR$\..\..\..\..\arch\stm8\iccarm\port_c.c + $PROJ_DIR$\..\..\..\..\arch\stm8\iccstm8\port_c.c - $PROJ_DIR$\..\..\..\..\arch\stm8\iccarm\port_config.h + $PROJ_DIR$\..\..\..\..\arch\stm8\iccstm8\port_config.h - $PROJ_DIR$\..\..\..\..\arch\stm8\iccarm\port_s.S + $PROJ_DIR$\..\..\..\..\arch\stm8\iccstm8\port_s.S $PROJ_DIR$\..\..\..\..\arch\stm8\common\tos_cpu.c diff --git a/board/STM8L052R8T6/IAR/shell/stm8_project.ewt b/board/STM8L052R8T6/IAR/shell/stm8_project.ewt index 58f0cb5d..81cf0d35 100644 --- a/board/STM8L052R8T6/IAR/shell/stm8_project.ewt +++ b/board/STM8L052R8T6/IAR/shell/stm8_project.ewt @@ -2160,16 +2160,16 @@ arch - $PROJ_DIR$\..\..\..\..\arch\stm8\iccarm\port.h + $PROJ_DIR$\..\..\..\..\arch\stm8\iccstm8\port.h - $PROJ_DIR$\..\..\..\..\arch\stm8\iccarm\port_c.c + $PROJ_DIR$\..\..\..\..\arch\stm8\iccstm8\port_c.c - $PROJ_DIR$\..\..\..\..\arch\stm8\iccarm\port_config.h + $PROJ_DIR$\..\..\..\..\arch\stm8\iccstm8\port_config.h - $PROJ_DIR$\..\..\..\..\arch\stm8\iccarm\port_s.S + $PROJ_DIR$\..\..\..\..\arch\stm8\iccstm8\port_s.S $PROJ_DIR$\..\..\..\..\arch\stm8\common\tos_cpu.c diff --git a/kernel/core/include/tos_compiler.h b/kernel/core/include/tos_compiler.h index ffa86998..7a9df915 100644 --- a/kernel/core/include/tos_compiler.h +++ b/kernel/core/include/tos_compiler.h @@ -112,7 +112,7 @@ #define __NAKED__ #define __WEAK__ __weak -/*------------------ ICC Compiler for STM8 ----------------------*/ +/*------------------ ICC Compiler for STM8/AVR ----------------------*/ #elif defined(__IAR_SYSTEMS_ICC__) #define __ASM__ __asm diff --git a/kernel/core/include/tos_klib.h b/kernel/core/include/tos_klib.h index 156a4a19..94342e74 100644 --- a/kernel/core/include/tos_klib.h +++ b/kernel/core/include/tos_klib.h @@ -26,10 +26,10 @@ #define TOS_MACRO_BEGIN do { #define TOS_MACRO_END } while (0) -#define TOS_OFFSET_OF_FIELD(type, field) \ +#define TOS_OFFSET_OF_FIELD(type, field) \ ((uint32_t)&(((type *)0)->field)) -#define TOS_CONTAINER_OF_FIELD(ptr, type, field) \ +#define TOS_CONTAINER_OF_FIELD(ptr, type, field) \ ((type *)((uint8_t *)(ptr) - TOS_OFFSET_OF_FIELD(type, field))) #define TOS_COUNT_OF(array) (sizeof(array) / sizeof(array[0])) @@ -43,14 +43,14 @@ TOS_MACRO_END #define TOS_PTR_SANITY_CHECK_RC(ptr, return_code) \ TOS_MACRO_BEGIN \ - if (unlikely(!(ptr))) { \ - return return_code; \ + if (unlikely(!(ptr))) { \ + return return_code; \ } \ TOS_MACRO_END #define TOS_IN_IRQ_CHECK() \ TOS_MACRO_BEGIN \ - if (unlikely(knl_is_inirq())) { \ + if (unlikely(knl_is_inirq())) { \ return K_ERR_IN_IRQ; \ } \ TOS_MACRO_END @@ -60,9 +60,9 @@ TOS_MACRO_END #define TOS_OBJ_INIT(obj, obj_type) knl_object_init(&obj->knl_obj, obj_type) #define TOS_OBJ_DEINIT(obj) knl_object_deinit(&obj->knl_obj) -#define TOS_OBJ_VERIFY(obj, obj_type) \ +#define TOS_OBJ_VERIFY(obj, obj_type) \ TOS_MACRO_BEGIN \ - if (!knl_object_verify(&obj->knl_obj, obj_type)) { \ + if (!knl_object_verify(&obj->knl_obj, obj_type)) { \ return K_ERR_OBJ_INVALID; \ } \ TOS_MACRO_END @@ -70,7 +70,22 @@ TOS_MACRO_END #define TOS_OBJ_VERIFY_RC(obj, obj_type, return_code) \ TOS_MACRO_BEGIN \ - if (!knl_object_verify(&obj->knl_obj, obj_type)) { \ + if (!knl_object_verify(&obj->knl_obj, obj_type)) { \ + return return_code; \ + } \ +TOS_MACRO_END + +#define TOS_OBJ_TEST(obj, obj_type) \ +TOS_MACRO_BEGIN \ + if (knl_object_verify(&obj->knl_obj, obj_type)) { \ + return K_ERR_OBJ_INVALID; \ + } \ +TOS_MACRO_END + + +#define TOS_OBJ_TEST_RC(obj, obj_type, return_code) \ +TOS_MACRO_BEGIN \ + if (knl_object_verify(&obj->knl_obj, obj_type)) { \ return return_code; \ } \ TOS_MACRO_END @@ -81,6 +96,8 @@ TOS_MACRO_END #define TOS_OBJ_DEINIT(obj) #define TOS_OBJ_VERIFY(obj, obj_type) #define TOS_OBJ_VERIFY_RC(obj, obj_type, return_code) +#define TOS_OBJ_TEST(obj, obj_type) +#define TOS_OBJ_TEST_RC(obj, obj_type, return_code) #endif @@ -93,18 +110,18 @@ TOS_MACRO_END // currently we use default microlib supplied by mdk #define tos_kprintf(...) LIBC_PRINTF(__VA_ARGS__); -#define tos_kprintln(...) \ - LIBC_PRINTF(__VA_ARGS__); \ +#define tos_kprintln(...) \ + LIBC_PRINTF(__VA_ARGS__); \ LIBC_PRINTF("\n"); -#define TOS_ASSERT_AUX(exp, function, line) \ - if (!(exp)) { \ - tos_kprintln("assert failed: %s %d\n", function, line); \ - tos_knl_sched_lock(); \ - tos_cpu_int_disable(); \ - while (K_TRUE) { \ - ; \ - } \ +#define TOS_ASSERT_AUX(exp, function, line) \ + if (!(exp)) { \ + tos_kprintln("assert failed: %s %d\n", function, line); \ + tos_knl_sched_lock(); \ + tos_cpu_int_disable(); \ + while (K_TRUE) { \ + ; \ + } \ } #define TOS_ASSERT(exp) TOS_ASSERT_AUX(exp, __FUNCTION__, __LINE__) diff --git a/kernel/core/include/tos_sched.h b/kernel/core/include/tos_sched.h index 427b45f1..090c5698 100644 --- a/kernel/core/include/tos_sched.h +++ b/kernel/core/include/tos_sched.h @@ -21,10 +21,10 @@ __CDECLS_BEGIN #define K_PRIO_TBL_SIZE ((TOS_CFG_TASK_PRIO_MAX + 31) / 32) -#define K_PRIO_TBL_SLOT_SIZE (32u) +#define K_PRIO_TBL_SLOT_SIZE (8 * sizeof(uint32_t)) -#define K_PRIO_NDX(prio) ((prio) >> 5u) /* prio / 32u */ -#define K_PRIO_BIT(prio) ((uint32_t)1u << (K_PRIO_TBL_SLOT_SIZE - 1u - ((prio) & (K_PRIO_TBL_SLOT_SIZE - 1u)))) +#define K_PRIO_NDX(prio) ((prio) >> 5u) /* prio / 32u */ +#define K_PRIO_BIT(prio) ((uint32_t)1u << (K_PRIO_TBL_SLOT_SIZE - 1u - ((prio) & (K_PRIO_TBL_SLOT_SIZE - 1u)))) typedef struct readyqueue_st { k_list_t task_list_head[TOS_CFG_TASK_PRIO_MAX]; diff --git a/kernel/core/tos_rwlock.c b/kernel/core/tos_rwlock.c index d071f211..dcc030e7 100644 --- a/kernel/core/tos_rwlock.c +++ b/kernel/core/tos_rwlock.c @@ -189,7 +189,7 @@ __API__ k_err_t tos_rwlock_wpend_timed(k_rwlock_t *rwlock, k_tick_t timeout) } while (rwlock->n_readers > 0u || rwlock->is_writting) { - /* util no one is writting or reading */ + /* until no one is writting or reading */ err = tos_sem_pend(&rwlock->signal, timeout); if (err != K_ERR_NONE) { break; diff --git a/kernel/core/tos_task.c b/kernel/core/tos_task.c index 510e176c..7896a783 100644 --- a/kernel/core/tos_task.c +++ b/kernel/core/tos_task.c @@ -96,10 +96,8 @@ __API__ k_err_t tos_task_create(k_task_t *task, TOS_PTR_SANITY_CHECK(entry); TOS_PTR_SANITY_CHECK(stk_base); - if (task->knl_obj.type == KNL_OBJ_TYPE_TASK) { - /* try to re-create a task, kind of dangerous action */ - return K_ERR_TASK_ALREADY_CREATED; - } + /* try to re-create a task, kind of dangerous */ + TOS_OBJ_TEST_RC(task, KNL_OBJ_TYPE_TASK, K_ERR_TASK_ALREADY_CREATED); if (unlikely(stk_size < K_TASK_STK_SIZE_MIN)) { return K_ERR_TASK_STK_SIZE_INVALID; diff --git a/kernel/pm/tos_tickless.c b/kernel/pm/tos_tickless.c index 0203556a..22facf89 100644 --- a/kernel/pm/tos_tickless.c +++ b/kernel/pm/tos_tickless.c @@ -88,20 +88,20 @@ __STATIC__ k_time_t tickless_cpu_sleep_time_get(k_cpu_lpwr_mode_t lpwr_mode) return time_sleep_ms > max_delay_ms ? max_delay_ms : time_sleep_ms; } -__STATIC__ void tickless_systick_suspend(void) +__STATIC__ void tickless_tick_suspend(void) { cpu_systick_suspend(); cpu_systick_pending_reset(); } -__STATIC__ void tickless_systick_resume(void) +__STATIC__ void tickless_tick_resume(void) { cpu_systick_suspend(); cpu_systick_reset(); cpu_systick_resume(); } -__STATIC__ void tickless_systick_fix(k_tick_t tick_sleep) +__STATIC__ void tickless_tick_fix(k_tick_t tick_sleep) { TOS_CPU_CPSR_ALLOC(); @@ -114,14 +114,14 @@ __STATIC__ void tickless_systick_fix(k_tick_t tick_sleep) timer_update(); #endif - tickless_systick_resume(); + tickless_tick_resume(); TOS_CPU_INT_ENABLE(); } __STATIC__ void tickless_enter(void) { - tickless_systick_suspend(); + tickless_tick_suspend(); } __STATIC__ void tickless_leave(k_time_t time_sleep_ms) @@ -131,7 +131,7 @@ __STATIC__ void tickless_leave(k_time_t time_sleep_ms) /* how many "ticks" have we sleep */ tick_sleep = k_cpu_tick_per_second * time_sleep_ms / K_TIME_MILLISEC_PER_SEC; - tickless_systick_fix(tick_sleep); + tickless_tick_fix(tick_sleep); } __KNL__ void tickless_proc(void) diff --git a/osal/posix/include/private/pthread.h b/osal/posix/include/private/pthread.h index b0c8c9fd..d4a9689d 100644 --- a/osal/posix/include/private/pthread.h +++ b/osal/posix/include/private/pthread.h @@ -1,119 +1,119 @@ -/*---------------------------------------------------------------------------- - * Tencent is pleased to support the open source community by making TencentOS - * available. - * - * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. - * If you have downloaded a copy of the TencentOS binary from Tencent, please - * note that the TencentOS binary is licensed under the BSD 3-Clause License. - * - * If you have downloaded a copy of the TencentOS source code from Tencent, - * please note that TencentOS source code is licensed under the BSD 3-Clause - * License, except for the third-party components listed below which are - * subject to different license terms. Your integration of TencentOS into your - * own projects may require compliance with the BSD 3-Clause License, as well - * as the other licenses applicable to the third-party components included - * within TencentOS. - *---------------------------------------------------------------------------*/ - -#ifndef _POSIX_PRIVATE_PTHREAD_H_ -#define _POSIX_PRIVATE_PTHREAD_H_ - -#include "tos_k.h" - -#include "private/posix_config.h" - -#include "sys/types.h" - -__CDECLS_BEGIN - -typedef struct pthread_control_st { - uint16_t threadstate : 4; - uint16_t cancelstate : 2; - uint16_t canceltype : 2; - uint16_t cancelpending : 1; - - pthread_t id; - pthread_attr_t attr; - k_task_t ktask; - k_task_t *the_ktask; - - k_sem_t joinner_sem; - - void *(*start_routine)(void *); /* start routine of the pthread */ - void *arg; /* argument to start routine */ - void *retval; /* return value of start routine */ - void *stackaddr; /* memory of address */ - - k_slist_t cleanup_ctl_list; - - void **thread_data; -} pthread_ctl_t; - -typedef struct pthread_cleanup_control_st { - void (*routine)(void *); /* function to be called */ - void *arg; /* argument for the routine */ - k_slist_t list; -} pthread_cleanup_ctl_t; - -#define PTHREAD_KEYS_MAX (POSIX_CFG_PTHREAD_KEYS_MAX) - -typedef void (*key_destructor_t)(void*); - -typedef struct pthread_key_control_st { - k_bmtbl_t key_bitmap_tbl[TOS_BITMAP_SIZE(PTHREAD_KEYS_MAX)]; - k_bitmap_t key_bitmap; - key_destructor_t destructors[PTHREAD_KEYS_MAX]; -} pthread_key_ctl_t; - -#define PTHREAD_INFO_SIZE (sizeof(pthread_ctl_t)) -#define PTHREAD_STK_SIZE_MIN (K_TASK_STK_SIZE_MIN + PTHREAD_INFO_SIZE) - -#define PTHREAD_DEFAULT_TIMESLICE 20 -#define PTHREAD_DEFAULT_STACKSIZE (2048 + PTHREAD_INFO_SIZE) -#define PTHREAD_DEFAULT_INHERIT_SCHED PTHREAD_INHERIT_SCHED -#define PTHREAD_DEFAULT_SCHEDPOLICY SCHED_OTHER -#define PTHREAD_DEFAULT_PRIORITY (TOS_CFG_TASK_PRIO_MAX / 2) -#define PTHREAD_DEFAULT_DETACH_STATE PTHREAD_CREATE_JOINABLE - -#define PTHREAD_DESTRUCTOR_ITERATIONS (POSIX_CFG_PTHREAD_DESTRUCTOR_ITERATIONS) - -#define PTHREAD_THREADS_MAX (POSIX_CFG_PTHREAD_THREADS_MAX) - -__KNL__ pthread_ctl_t *pthread_ctl_self(void); - -__KNL__ pthread_ctl_t *pthread_ctl_by_id(pthread_t id); - -__KNL__ int pthread_id_add(pthread_t id, pthread_ctl_t *info); - -__KNL__ pthread_t pthread_id_alloc(void); - -__KNL__ int pthread_id_free(pthread_t id); - -__KNL__ void pthread_data_clear(pthread_key_t key); - -__KNL__ int pthread_key_ctl_init(void); - -__KNL__ pthread_key_t pthread_key_alloc(void); - -__KNL__ int pthread_key_is_alloc(pthread_key_t key); - -__KNL__ int pthread_key_free(pthread_key_t key); - -__KNL__ int pthread_key_destructor_register(pthread_key_t key, key_destructor_t destructor); - -__KNL__ key_destructor_t pthread_key_destructor_get(pthread_key_t key); - -__KNL__ int pthread_ctl_reap(int pthreads_ready2reap); - -__KNL__ void pthread_lock(void); - -__KNL__ void pthread_unlock(void); - -__KNL__ int pthread_lock_init(void); - -__KNL__ int pthread_init(void); - -__CDECLS_END - -#endif /* _POSIX_PRIVATE_PTHREAD_PRV_H_ */ - +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#ifndef _POSIX_PRIVATE_PTHREAD_H_ +#define _POSIX_PRIVATE_PTHREAD_H_ + +#include "tos_k.h" + +#include "private/posix_config.h" + +#include "sys/types.h" + +__CDECLS_BEGIN + +typedef struct pthread_control_st { + uint16_t threadstate : 4; + uint16_t cancelstate : 2; + uint16_t canceltype : 2; + uint16_t cancelpending : 1; + + pthread_t id; + pthread_attr_t attr; + k_task_t ktask; + k_task_t *the_ktask; + + k_sem_t joinner_sem; + + void *(*start_routine)(void *); /* start routine of the pthread */ + void *arg; /* argument for start routine */ + void *retval; /* return value of start routine */ + void *stackaddr; /* memory address of stack */ + + k_slist_t cleanup_ctl_list; + + void **thread_data; +} pthread_ctl_t; + +typedef struct pthread_cleanup_control_st { + void (*routine)(void *); /* function to be called */ + void *arg; /* argument for the routine */ + k_slist_t list; +} pthread_cleanup_ctl_t; + +#define PTHREAD_KEYS_MAX (POSIX_CFG_PTHREAD_KEYS_MAX) + +typedef void (*key_destructor_t)(void*); + +typedef struct pthread_key_control_st { + k_bmtbl_t key_bitmap_tbl[TOS_BITMAP_SIZE(PTHREAD_KEYS_MAX)]; + k_bitmap_t key_bitmap; + key_destructor_t destructors[PTHREAD_KEYS_MAX]; +} pthread_key_ctl_t; + +#define PTHREAD_INFO_SIZE (sizeof(pthread_ctl_t)) +#define PTHREAD_STK_SIZE_MIN (K_TASK_STK_SIZE_MIN + PTHREAD_INFO_SIZE) + +#define PTHREAD_DEFAULT_TIMESLICE 20 +#define PTHREAD_DEFAULT_STACKSIZE (2048 + PTHREAD_INFO_SIZE) +#define PTHREAD_DEFAULT_INHERIT_SCHED PTHREAD_INHERIT_SCHED +#define PTHREAD_DEFAULT_SCHEDPOLICY SCHED_OTHER +#define PTHREAD_DEFAULT_PRIORITY (TOS_CFG_TASK_PRIO_MAX / 2) +#define PTHREAD_DEFAULT_DETACH_STATE PTHREAD_CREATE_JOINABLE + +#define PTHREAD_DESTRUCTOR_ITERATIONS (POSIX_CFG_PTHREAD_DESTRUCTOR_ITERATIONS) + +#define PTHREAD_THREADS_MAX (POSIX_CFG_PTHREAD_THREADS_MAX) + +__KNL__ pthread_ctl_t *pthread_ctl_self(void); + +__KNL__ pthread_ctl_t *pthread_ctl_by_id(pthread_t id); + +__KNL__ int pthread_id_add(pthread_t id, pthread_ctl_t *info); + +__KNL__ pthread_t pthread_id_alloc(void); + +__KNL__ int pthread_id_free(pthread_t id); + +__KNL__ void pthread_data_clear(pthread_key_t key); + +__KNL__ int pthread_key_ctl_init(void); + +__KNL__ pthread_key_t pthread_key_alloc(void); + +__KNL__ int pthread_key_is_alloc(pthread_key_t key); + +__KNL__ int pthread_key_free(pthread_key_t key); + +__KNL__ int pthread_key_destructor_register(pthread_key_t key, key_destructor_t destructor); + +__KNL__ key_destructor_t pthread_key_destructor_get(pthread_key_t key); + +__KNL__ int pthread_ctl_reap(int pthreads_ready2reap); + +__KNL__ void pthread_lock(void); + +__KNL__ void pthread_unlock(void); + +__KNL__ int pthread_lock_init(void); + +__KNL__ int pthread_init(void); + +__CDECLS_END + +#endif /* _POSIX_PRIVATE_PTHREAD_PRV_H_ */ + diff --git a/osal/posix/mqueue_prv.c b/osal/posix/mqueue_prv.c index 165e1aee..249bf491 100644 --- a/osal/posix/mqueue_prv.c +++ b/osal/posix/mqueue_prv.c @@ -95,4 +95,3 @@ __KNL__ mqueue_ctl_t *mqueue_by_id(mqd_t id) return the_ctl; } - diff --git a/osal/posix/pthread.c b/osal/posix/pthread.c index 66a9a946..d21e3f77 100644 --- a/osal/posix/pthread.c +++ b/osal/posix/pthread.c @@ -212,7 +212,7 @@ __API__ int pthread_attr_setschedparam(pthread_attr_t *attr, const struct sched_ return 0; } -__API__ int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy) +__API__ int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy) { TOS_PTR_SANITY_CHECK_RC(attr, EINVAL); TOS_PTR_SANITY_CHECK_RC(policy, EINVAL);