From d85981a715669d0f58119133b5983469bc88db73 Mon Sep 17 00:00:00 2001 From: xuzhuoyi Date: Sun, 2 Sep 2018 18:44:28 +0800 Subject: [BSP][tms320f28379d] Add port for tms320f28379d --- libcpu/c28x/context.s | 242 ++++++++++++++++++++++++++++++++++++++++++++++++++ libcpu/c28x/cpuport.c | 113 +++++++++++++++++++++++ 2 files changed, 355 insertions(+) create mode 100644 libcpu/c28x/context.s create mode 100644 libcpu/c28x/cpuport.c (limited to 'libcpu') diff --git a/libcpu/c28x/context.s b/libcpu/c28x/context.s new file mode 100644 index 0000000000..f01e5ea246 --- /dev/null +++ b/libcpu/c28x/context.s @@ -0,0 +1,242 @@ + + .ref _rt_interrupt_to_thread + .ref _rt_interrupt_from_thread + .ref _rt_thread_switch_interrupt_flag + + .def _RTOSINT_Handler + .def _rt_hw_get_st0 + .def _rt_hw_get_st1 + .def _rt_hw_context_switch_interrupt + .def _rt_hw_context_switch + .def _rt_hw_context_switch_to + .def _rt_hw_interrupt_thread_switch + .def _rt_hw_interrupt_disable + .def _rt_hw_interrupt_enable + + +RT_CTX_SAVE .macro + + + PUSH AR1H:AR0H + PUSH XAR2 + PUSH XAR3 + PUSH XAR4 + PUSH XAR5 + PUSH XAR6 + PUSH XAR7 + PUSH XT + PUSH RPC + + + .endm + + +RT_CTX_RESTORE .macro + + POP RPC + POP XT + POP XAR7 + POP XAR6 + POP XAR5 + POP XAR4 + POP XAR3 + POP XAR2 + + + MOVZ AR0 , @SP + SUBB XAR0, #6 + MOVL ACC , *XAR0 + AND ACC, #0xFFFF << 16 + MOV AL, IER + MOVL *XAR0, ACC + + + POP AR1H:AR0H + + .endm + + +.text + .newblock + +; +; rt_base_t rt_hw_interrupt_disable(); +; + .asmfunc +_rt_hw_interrupt_disable: + DINT + LRETR + .endasmfunc + +; +; void rt_hw_interrupt_enable(rt_base_t level); +; + .asmfunc +_rt_hw_interrupt_enable: + EINT + LRETR + .endasmfunc + +; +; void rt_hw_context_switch(rt_uint32 from, rt_uint32 to); +; r0 --> from +; r1 --> to + + + .asmfunc +_rt_hw_context_switch_interrupt: +_rt_hw_context_switch: + ; set rt_thread_switch_interrupt_flag to 1 + MOVL XAR2, #_rt_thread_switch_interrupt_flag + MOVL XAR3, *XAR2 + MOVL ACC, XAR3 + CMPB AL, #1 + B _reswitch, EQ + MOVL XAR3, #1 + MOVL *XAR2, XAR3 + + MOVL XAR2, #_rt_interrupt_from_thread ; set rt_interrupt_from_thread + MOVL *XAR2, XAR0 + +_reswitch: + MOVL XAR2, #_rt_interrupt_to_thread ; set rt_interrupt_to_thread + MOVL *XAR2, XAR1 + + TRAP #16 + LRETR + .endasmfunc + + .asmfunc +_RTOSINT_Handler: +; disable interrupt to protect context switch + DINT + + ; get rt_thread_switch_interrupt_flag + MOV AR0, #_rt_thread_switch_interrupt_flag + MOV AL, *AR0 + MOV AR1, AL + CMP AR1, #0 + B rtosint_exit, EQ ; pendsv already handled + + ; clear rt_thread_switch_interrupt_flag to 0 + MOV AR1, #0x00 + MOV *AR0, AR1 + + MOV AR0, #_rt_interrupt_from_thread + MOV AL, *AR0 + MOV AR1, AL + CMP AR1, #0 + B switch_to_thread, EQ ; skip register save at the first time + + ;MOVZ AR1, @SP ; get from thread stack pointer + +;#if defined (__VFP_FP__) && !defined(__SOFTFP__) +; TST lr, #0x10 ; if(!EXC_RETURN[4]) +; VSTMDBEQ r1!, {d8 - d15} ; push FPU register s16~s31 +;#endif + + RT_CTX_SAVE ; push r4 - r11 register + +;#if defined (__VFP_FP__) && !defined(__SOFTFP__) +; MOV r4, #0x00 ; flag = 0 + +; TST lr, #0x10 ; if(!EXC_RETURN[4]) +; MOVEQ r4, #0x01 ; flag = 1 + +; STMFD r1!, {r4} ; push flag +;#endif + + MOV AL, *AR0 + MOV AR1, AL + MOVZ AR1, @SP ; get from thread stack pointer + MOV *AR0, AR1 ; update from thread stack pointer + +switch_to_thread: + MOV AR1, #_rt_interrupt_to_thread + MOV AL, *AR1 + MOV AR1, AL + MOV AL, *AR1 + MOV AR1, AL ; load thread stack pointer + +;#if defined (__VFP_FP__) && !defined(__SOFTFP__) +; LDMFD r1!, {r3} ; pop flag +;#endif + + RT_CTX_RESTORE ; pop r4 - r11 register + + +;#if defined (__VFP_FP__) && !defined(__SOFTFP__) +; CMP r3, #0 ; if(flag_r3 != 0) +; VLDMIANE r1!, {d8 - d15} ; pop FPU register s16~s31 +;#endif + + MOV @SP, AR1 ; update stack pointer + +;#if defined (__VFP_FP__) && !defined(__SOFTFP__) +; ORR lr, lr, #0x10 ; lr |= (1 << 4), clean FPCA. +; CMP r3, #0 ; if(flag_r3 != 0) +; BICNE lr, lr, #0x10 ; lr &= ~(1 << 4), set FPCA. +;#endif + +rtosint_exit: + ; restore interrupt + EINT + + IRET + .endasmfunc + + .asmfunc +_rt_hw_get_st0: + PUSH ST0 + POP AL + LRETR + .endasmfunc + + .asmfunc +_rt_hw_get_st1: + PUSH ST1 + POP AL + LRETR + .endasmfunc + +; +; * void rt_hw_context_switch_to(rt_uint32 to); +; * r0 --> to + + .asmfunc +_rt_hw_context_switch_to: + MOV AR1, #_rt_interrupt_to_thread + MOV AL, *AR1 + MOV AR0, AL + +;#if defined (__VFP_FP__) && !defined(__SOFTFP__) + ; CLEAR CONTROL.FPCA +; MRS r2, CONTROL ; read +; BIC r2, #0x04 ; modify +; MSR CONTROL, r2 ; write-back +;#endif + + ; set from thread to 0 + MOV AR1, #_rt_interrupt_from_thread + MOV AR0, #0x0 + MOV *AR1, AR0 + + ; set interrupt flag to 1 + MOV AR1, #_rt_thread_switch_interrupt_flag + MOV AR0, #1 + MOV *AR1, AR0 + + TRAP #16 + + + ; never reach here! + .endasmfunc + +; compatible with old version + .asmfunc +_rt_hw_interrupt_thread_switch: + LRETR + NOP + .endasmfunc + +.end diff --git a/libcpu/c28x/cpuport.c b/libcpu/c28x/cpuport.c new file mode 100644 index 0000000000..0143656b6e --- /dev/null +++ b/libcpu/c28x/cpuport.c @@ -0,0 +1,113 @@ +/* + * File : cpuport.c + * This file is part of RT-Thread RTOS + * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rt-thread.org/license/LICENSE + * + * Change Logs: + * Date Author Notes + * 2018-09-01 xuzhuoyi the first version. + */ + +#include + +/* exception and interrupt handler table */ +rt_uint32_t rt_interrupt_from_thread; +rt_uint32_t rt_interrupt_to_thread; +rt_uint32_t rt_thread_switch_interrupt_flag; +/* exception hook */ +static rt_err_t (*rt_exception_hook)(void *context) = RT_NULL; + +struct exception_stack_frame +{ + rt_uint32_t t_st0; + rt_uint32_t acc; + rt_uint32_t p; + rt_uint32_t ar1_ar0; + rt_uint32_t dp_st1; + rt_uint32_t dbgstat_ier; + rt_uint32_t return_address; +}; + +struct stack_frame +{ + + /* r4 ~ r11 register */ + rt_uint16_t ar0h; + rt_uint16_t ar1h; + rt_uint32_t xar2; + rt_uint32_t xar3; + rt_uint32_t xar4; + rt_uint32_t xar5; + rt_uint32_t xar6; + rt_uint32_t xar7; + rt_uint32_t xt; + rt_uint32_t rpc; + + + struct exception_stack_frame exception_stack_frame; +}; + +rt_uint8_t *rt_hw_stack_init(void *tentry, + void *parameter, + rt_uint8_t *stack_addr, + void *texit) +{ + struct stack_frame *stack_frame; + rt_uint8_t *stk; + unsigned long i; + + stk = stack_addr + sizeof(rt_uint32_t); + stk = (rt_uint8_t *)RT_ALIGN_DOWN((rt_uint32_t)stk, 8); + stk -= sizeof(struct stack_frame); + + stack_frame = (struct stack_frame *)stk; + + /* init all register */ + for (i = 0; i < sizeof(struct stack_frame) / sizeof(rt_uint32_t); i ++) + { + ((rt_uint32_t *)stack_frame)[i] = 0xdeadbeef; + } + + stack_frame->exception_stack_frame.t_st0 = 0x11110000 | rt_hw_get_st0(); + stack_frame->exception_stack_frame.acc = 0x33332222; + stack_frame->exception_stack_frame.ar1_ar0 = 0x00001111 & (unsigned long)parameter; /* ar0 : argument */ + stack_frame->exception_stack_frame.p = 0x55554444; /* p */ + stack_frame->exception_stack_frame.dp_st1 = (0x00000000) | rt_hw_get_st1(); /* dp_st1 */ + stack_frame->exception_stack_frame.dbgstat_ier = 0; /* dbgstat_ier */ + stack_frame->exception_stack_frame.return_address = (unsigned long)tentry; /* return_address */ + + /* return task's current stack address */ + return stk; +} + +/** + * This function set the hook, which is invoked on fault exception handling. + * + * @param exception_handle the exception handling hook function. + */ +void rt_hw_exception_install(rt_err_t (*exception_handle)(void *context)) +{ + rt_exception_hook = exception_handle; +} + + +struct exception_info +{ + rt_uint32_t exc_return; + struct stack_frame stack_frame; +}; + + +/** + * shutdown CPU + */ +void rt_hw_cpu_shutdown(void) +{ + rt_kprintf("shutdown...\n"); + + RT_ASSERT(0); +} -- cgit v1.3.1 From 697a4495a6b40e01ea856cf1e3dc90bde2e368c7 Mon Sep 17 00:00:00 2001 From: xuzhuoyi Date: Mon, 3 Sep 2018 00:03:06 +0800 Subject: [bsp][tms320f28379d] Add support for upward-growing stack --- bsp/tms320f28379d/drivers/board.c | 3 +++ bsp/tms320f28379d/rtconfig.h | 4 +--- libcpu/c28x/context.s | 23 +++++------------------ libcpu/c28x/cpuport.c | 10 +++++----- src/thread.c | 6 ++++++ 5 files changed, 20 insertions(+), 26 deletions(-) (limited to 'libcpu') diff --git a/bsp/tms320f28379d/drivers/board.c b/bsp/tms320f28379d/drivers/board.c index a019e24cd6..30a33f91eb 100644 --- a/bsp/tms320f28379d/drivers/board.c +++ b/bsp/tms320f28379d/drivers/board.c @@ -16,6 +16,8 @@ #include "board.h" #include "F28x_Project.h" +extern interrupt void RTOSINT_Handler(); + /** * This is the timer interrupt service routine. @@ -51,6 +53,7 @@ void rt_hw_board_init() EALLOW; // This is needed to write to EALLOW protected registers PieVectTable.TIMER2_INT = &cpu_timer2_isr; + PieVectTable.RTOS_INT = &RTOSINT_Handler; EDIS; InitCpuTimers(); diff --git a/bsp/tms320f28379d/rtconfig.h b/bsp/tms320f28379d/rtconfig.h index 73de6650e4..5fafc1da5e 100644 --- a/bsp/tms320f28379d/rtconfig.h +++ b/bsp/tms320f28379d/rtconfig.h @@ -15,6 +15,7 @@ #define RT_USING_HOOK #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 1024 +#define RT_STACK_UPWARD_GROW #define RT_DEBUG /* Inter-Thread communication */ @@ -37,9 +38,6 @@ //#define RT_USING_CONSOLE #define RT_CONSOLEBUF_SIZE 128 #define RT_CONSOLE_DEVICE_NAME "uart2" -#define ARCH_ARM -#define ARCH_ARM_CORTEX_M -#define ARCH_ARM_CORTEX_M4 /* RT-Thread Components */ diff --git a/libcpu/c28x/context.s b/libcpu/c28x/context.s index f01e5ea246..9efec09fb2 100644 --- a/libcpu/c28x/context.s +++ b/libcpu/c28x/context.s @@ -86,6 +86,7 @@ _rt_hw_interrupt_enable: .asmfunc _rt_hw_context_switch_interrupt: _rt_hw_context_switch: + MOV AR0, AL ; set rt_thread_switch_interrupt_flag to 1 MOVL XAR2, #_rt_thread_switch_interrupt_flag MOVL XAR3, *XAR2 @@ -96,7 +97,7 @@ _rt_hw_context_switch: MOVL *XAR2, XAR3 MOVL XAR2, #_rt_interrupt_from_thread ; set rt_interrupt_from_thread - MOVL *XAR2, XAR0 + MOVL *XAR2, XAR0 _reswitch: MOVL XAR2, #_rt_interrupt_to_thread ; set rt_interrupt_to_thread @@ -162,21 +163,8 @@ switch_to_thread: ; LDMFD r1!, {r3} ; pop flag ;#endif - RT_CTX_RESTORE ; pop r4 - r11 register - - -;#if defined (__VFP_FP__) && !defined(__SOFTFP__) -; CMP r3, #0 ; if(flag_r3 != 0) -; VLDMIANE r1!, {d8 - d15} ; pop FPU register s16~s31 -;#endif - - MOV @SP, AR1 ; update stack pointer - -;#if defined (__VFP_FP__) && !defined(__SOFTFP__) -; ORR lr, lr, #0x10 ; lr |= (1 << 4), clean FPCA. -; CMP r3, #0 ; if(flag_r3 != 0) -; BICNE lr, lr, #0x10 ; lr &= ~(1 << 4), set FPCA. -;#endif + MOV @SP, AR1 + RT_CTX_RESTORE ; pop r4 - r11 register rtosint_exit: ; restore interrupt @@ -206,8 +194,7 @@ _rt_hw_get_st1: .asmfunc _rt_hw_context_switch_to: MOV AR1, #_rt_interrupt_to_thread - MOV AL, *AR1 - MOV AR0, AL + MOV *AR1, AL ;#if defined (__VFP_FP__) && !defined(__SOFTFP__) ; CLEAR CONTROL.FPCA diff --git a/libcpu/c28x/cpuport.c b/libcpu/c28x/cpuport.c index 0143656b6e..720bb01776 100644 --- a/libcpu/c28x/cpuport.c +++ b/libcpu/c28x/cpuport.c @@ -34,6 +34,7 @@ struct exception_stack_frame struct stack_frame { + struct exception_stack_frame exception_stack_frame; /* r4 ~ r11 register */ rt_uint16_t ar0h; @@ -48,7 +49,6 @@ struct stack_frame rt_uint32_t rpc; - struct exception_stack_frame exception_stack_frame; }; rt_uint8_t *rt_hw_stack_init(void *tentry, @@ -60,9 +60,9 @@ rt_uint8_t *rt_hw_stack_init(void *tentry, rt_uint8_t *stk; unsigned long i; - stk = stack_addr + sizeof(rt_uint32_t); - stk = (rt_uint8_t *)RT_ALIGN_DOWN((rt_uint32_t)stk, 8); - stk -= sizeof(struct stack_frame); + stk = stack_addr; + stk = (rt_uint8_t *)RT_ALIGN((rt_uint32_t)stk, 8); + //stk -= sizeof(struct stack_frame); stack_frame = (struct stack_frame *)stk; @@ -81,7 +81,7 @@ rt_uint8_t *rt_hw_stack_init(void *tentry, stack_frame->exception_stack_frame.return_address = (unsigned long)tentry; /* return_address */ /* return task's current stack address */ - return stk; + return stk + sizeof(struct stack_frame); } /** diff --git a/src/thread.c b/src/thread.c index b3d91b30d0..49e004e5cc 100644 --- a/src/thread.c +++ b/src/thread.c @@ -150,9 +150,15 @@ static rt_err_t _rt_thread_init(struct rt_thread *thread, /* init thread stack */ rt_memset(thread->stack_addr, '#', thread->stack_size); +#ifdef RT_STACK_UPWARD_GROW + thread->sp = (void *)rt_hw_stack_init(thread->entry, thread->parameter, + (void *)((char *)thread->stack_addr), + (void *)rt_thread_exit); +#else thread->sp = (void *)rt_hw_stack_init(thread->entry, thread->parameter, (void *)((char *)thread->stack_addr + thread->stack_size - 4), (void *)rt_thread_exit); +#endif /* priority init */ RT_ASSERT(priority < RT_THREAD_PRIORITY_MAX); -- cgit v1.3.1 From 5fd1213e73275d57489f879d5841e3ba3b8ab43f Mon Sep 17 00:00:00 2001 From: xuzhuoyi Date: Mon, 3 Sep 2018 21:39:56 +0800 Subject: [bsp][tms320f28379d] __rt_ffs() problem caused by 16-bit int --- bsp/tms320f28379d/rtconfig.h | 5 ++--- libcpu/c28x/context.s | 1 + libcpu/c28x/cpuport.c | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) (limited to 'libcpu') diff --git a/bsp/tms320f28379d/rtconfig.h b/bsp/tms320f28379d/rtconfig.h index 5fafc1da5e..b88a49d3d2 100644 --- a/bsp/tms320f28379d/rtconfig.h +++ b/bsp/tms320f28379d/rtconfig.h @@ -8,10 +8,9 @@ #define RT_NAME_MAX 8 #define RT_ALIGN_SIZE 4 -#define RT_THREAD_PRIORITY_32 -#define RT_THREAD_PRIORITY_MAX 32 +#define RT_THREAD_PRIORITY_MAX 16 #define RT_TICK_PER_SECOND 100 -#define RT_USING_OVERFLOW_CHECK +//#define RT_USING_OVERFLOW_CHECK #define RT_USING_HOOK #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 1024 diff --git a/libcpu/c28x/context.s b/libcpu/c28x/context.s index 9efec09fb2..020325e126 100644 --- a/libcpu/c28x/context.s +++ b/libcpu/c28x/context.s @@ -164,6 +164,7 @@ switch_to_thread: ;#endif MOV @SP, AR1 + INC SP RT_CTX_RESTORE ; pop r4 - r11 register rtosint_exit: diff --git a/libcpu/c28x/cpuport.c b/libcpu/c28x/cpuport.c index 720bb01776..2300eb0e9c 100644 --- a/libcpu/c28x/cpuport.c +++ b/libcpu/c28x/cpuport.c @@ -79,6 +79,7 @@ rt_uint8_t *rt_hw_stack_init(void *tentry, stack_frame->exception_stack_frame.dp_st1 = (0x00000000) | rt_hw_get_st1(); /* dp_st1 */ stack_frame->exception_stack_frame.dbgstat_ier = 0; /* dbgstat_ier */ stack_frame->exception_stack_frame.return_address = (unsigned long)tentry; /* return_address */ + stack_frame->rpc = (unsigned long)texit; /* return task's current stack address */ return stk + sizeof(struct stack_frame); -- cgit v1.3.1 From 9d8e27e626608d3d96efb774c882541380d21d5e Mon Sep 17 00:00:00 2001 From: xuzhuoyi Date: Mon, 3 Sep 2018 23:02:16 +0800 Subject: [bsp][tms320f28379d] Modify to C28x Compiler Register Conventions --- libcpu/c28x/context.s | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'libcpu') diff --git a/libcpu/c28x/context.s b/libcpu/c28x/context.s index 020325e126..226a17f5d4 100644 --- a/libcpu/c28x/context.s +++ b/libcpu/c28x/context.s @@ -80,28 +80,30 @@ _rt_hw_interrupt_enable: ; ; void rt_hw_context_switch(rt_uint32 from, rt_uint32 to); ; r0 --> from -; r1 --> to +; r4 --> to .asmfunc _rt_hw_context_switch_interrupt: _rt_hw_context_switch: + MOVL XAR0, #0 MOV AR0, AL + MOVL XAR4, *-SP[4] ; set rt_thread_switch_interrupt_flag to 1 - MOVL XAR2, #_rt_thread_switch_interrupt_flag - MOVL XAR3, *XAR2 - MOVL ACC, XAR3 + MOVL XAR5, #_rt_thread_switch_interrupt_flag + MOVL XAR6, *XAR5 + MOVL ACC, XAR6 CMPB AL, #1 B _reswitch, EQ - MOVL XAR3, #1 - MOVL *XAR2, XAR3 + MOVL XAR6, #1 + MOVL *XAR5, XAR6 - MOVL XAR2, #_rt_interrupt_from_thread ; set rt_interrupt_from_thread - MOVL *XAR2, XAR0 + MOVL XAR5, #_rt_interrupt_from_thread ; set rt_interrupt_from_thread + MOVL *XAR5, XAR0 _reswitch: - MOVL XAR2, #_rt_interrupt_to_thread ; set rt_interrupt_to_thread - MOVL *XAR2, XAR1 + MOVL XAR5, #_rt_interrupt_to_thread ; set rt_interrupt_to_thread + MOVL *XAR5, XAR4 TRAP #16 LRETR -- cgit v1.3.1 From b7a76b5e525c07dd0e5b0dd98f8057211beb0a79 Mon Sep 17 00:00:00 2001 From: xuzhuoyi Date: Fri, 16 Nov 2018 20:30:56 +0800 Subject: [bsp][tms320f28379d] Change license to Apache-2.0 --- bsp/tms320f28379d/applications/application.c | 8 ++------ bsp/tms320f28379d/applications/startup.c | 8 ++------ bsp/tms320f28379d/drivers/board.c | 8 ++------ bsp/tms320f28379d/drivers/board.h | 9 +++------ libcpu/c28x/context.s | 9 +++++++++ libcpu/c28x/cpuport.c | 8 ++------ 6 files changed, 20 insertions(+), 30 deletions(-) (limited to 'libcpu') diff --git a/bsp/tms320f28379d/applications/application.c b/bsp/tms320f28379d/applications/application.c index d0bffdc05e..bf4ce92a46 100644 --- a/bsp/tms320f28379d/applications/application.c +++ b/bsp/tms320f28379d/applications/application.c @@ -1,11 +1,7 @@ /* - * File : application.c - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2006, RT-Thread Development Team + * Copyright (c) 2006-2018, RT-Thread Development Team * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rt-thread.org/license/LICENSE + * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes diff --git a/bsp/tms320f28379d/applications/startup.c b/bsp/tms320f28379d/applications/startup.c index 0e29ca1752..419e779e55 100644 --- a/bsp/tms320f28379d/applications/startup.c +++ b/bsp/tms320f28379d/applications/startup.c @@ -1,11 +1,7 @@ /* - * File : startup.c - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2006, RT-Thread Develop Team + * Copyright (c) 2006-2018, RT-Thread Development Team * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://openlab.rt-thread.com/license/LICENSE + * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes diff --git a/bsp/tms320f28379d/drivers/board.c b/bsp/tms320f28379d/drivers/board.c index 30a33f91eb..7960d80d1b 100644 --- a/bsp/tms320f28379d/drivers/board.c +++ b/bsp/tms320f28379d/drivers/board.c @@ -1,11 +1,7 @@ /* - * File : board.c - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2009, RT-Thread Development Team + * Copyright (c) 2006-2018, RT-Thread Development Team * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rt-thread.org/license/LICENSE + * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes diff --git a/bsp/tms320f28379d/drivers/board.h b/bsp/tms320f28379d/drivers/board.h index b8ff975c3c..2f89b0e3bb 100644 --- a/bsp/tms320f28379d/drivers/board.h +++ b/bsp/tms320f28379d/drivers/board.h @@ -1,15 +1,12 @@ /* - * File : board.h - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2009, RT-Thread Development Team + * Copyright (c) 2006-2018, RT-Thread Development Team * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rt-thread.org/license/LICENSE + * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2009-09-22 Bernard add board.h to this bsp + * 2018-09-02 xuzhuoyi modify for TMS320F28379D version */ // <<< Use Configuration Wizard in Context Menu >>> #ifndef __BOARD_H__ diff --git a/libcpu/c28x/context.s b/libcpu/c28x/context.s index 226a17f5d4..019b5def13 100644 --- a/libcpu/c28x/context.s +++ b/libcpu/c28x/context.s @@ -1,3 +1,12 @@ +; +; Copyright (c) 2006-2018, RT-Thread Development Team +; +; SPDX-License-Identifier: Apache-2.0 +; +; Change Logs: +; Date Author Notes +; 2018-09-01 xuzhuoyi the first version. +; .ref _rt_interrupt_to_thread .ref _rt_interrupt_from_thread diff --git a/libcpu/c28x/cpuport.c b/libcpu/c28x/cpuport.c index 2300eb0e9c..8885f647a9 100644 --- a/libcpu/c28x/cpuport.c +++ b/libcpu/c28x/cpuport.c @@ -1,11 +1,7 @@ /* - * File : cpuport.c - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team + * Copyright (c) 2006-2018, RT-Thread Development Team * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rt-thread.org/license/LICENSE + * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes -- cgit v1.3.1 From 17301e463cb282cf96ec6874779e7aff4ec01920 Mon Sep 17 00:00:00 2001 From: xuzhuoyi Date: Sun, 18 Nov 2018 12:06:52 +0800 Subject: [bsp][tms320f28379d] Add support of Kconfig --- bsp/tms320f28379d/.config | 302 +++++++++++++++++++++++++++++++ bsp/tms320f28379d/Kconfig | 27 +++ bsp/tms320f28379d/applications/startup.c | 2 - bsp/tms320f28379d/rtconfig.h | 51 +++--- libcpu/Kconfig | 4 + 5 files changed, 361 insertions(+), 25 deletions(-) create mode 100644 bsp/tms320f28379d/.config create mode 100644 bsp/tms320f28379d/Kconfig (limited to 'libcpu') diff --git a/bsp/tms320f28379d/.config b/bsp/tms320f28379d/.config new file mode 100644 index 0000000000..5337bc7be1 --- /dev/null +++ b/bsp/tms320f28379d/.config @@ -0,0 +1,302 @@ +# +# Automatically generated file; DO NOT EDIT. +# RT-Thread Configuration +# +CONFIG_SOC_TMS320F28X=y + +# +# RT-Thread Kernel +# +CONFIG_RT_NAME_MAX=8 +CONFIG_RT_ALIGN_SIZE=4 +CONFIG_RT_THREAD_PRIORITY_8=y +# CONFIG_RT_THREAD_PRIORITY_32 is not set +# CONFIG_RT_THREAD_PRIORITY_256 is not set +CONFIG_RT_THREAD_PRIORITY_MAX=8 +CONFIG_RT_TICK_PER_SECOND=100 +CONFIG_RT_USING_OVERFLOW_CHECK=y +CONFIG_RT_USING_HOOK=y +CONFIG_RT_USING_IDLE_HOOK=y +CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 +CONFIG_IDLE_THREAD_STACK_SIZE=256 +# CONFIG_RT_USING_TIMER_SOFT is not set +CONFIG_RT_DEBUG=y +# CONFIG_RT_DEBUG_INIT_CONFIG is not set +# CONFIG_RT_DEBUG_THREAD_CONFIG is not set +# CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set +# CONFIG_RT_DEBUG_IPC_CONFIG is not set +# CONFIG_RT_DEBUG_TIMER_CONFIG is not set +# CONFIG_RT_DEBUG_IRQ_CONFIG is not set +# CONFIG_RT_DEBUG_MEM_CONFIG is not set +# CONFIG_RT_DEBUG_SLAB_CONFIG is not set +# CONFIG_RT_DEBUG_MEMHEAP_CONFIG is not set +# CONFIG_RT_DEBUG_MODULE_CONFIG is not set + +# +# Inter-Thread communication +# +CONFIG_RT_USING_SEMAPHORE=y +CONFIG_RT_USING_MUTEX=y +CONFIG_RT_USING_EVENT=y +CONFIG_RT_USING_MAILBOX=y +CONFIG_RT_USING_MESSAGEQUEUE=y +# CONFIG_RT_USING_SIGNALS is not set + +# +# Memory Management +# +CONFIG_RT_USING_MEMPOOL=y +# CONFIG_RT_USING_MEMHEAP is not set +# CONFIG_RT_USING_NOHEAP is not set +CONFIG_RT_USING_SMALL_MEM=y +# CONFIG_RT_USING_SLAB is not set +# CONFIG_RT_USING_MEMTRACE is not set +CONFIG_RT_USING_HEAP=y + +# +# Kernel Device Object +# +CONFIG_RT_USING_DEVICE=y +# CONFIG_RT_USING_DEVICE_OPS is not set +# CONFIG_RT_USING_INTERRUPT_INFO is not set +CONFIG_RT_USING_CONSOLE=y +CONFIG_RT_CONSOLEBUF_SIZE=128 +CONFIG_RT_CONSOLE_DEVICE_NAME="uart" +CONFIG_ARCH_C28X=y +CONFIG_ARCH_CPU_STACK_GROWS_UPWARD=y + +# +# RT-Thread Components +# +CONFIG_RT_USING_COMPONENTS_INIT=y +# CONFIG_RT_USING_USER_MAIN is not set + +# +# C++ features +# +# CONFIG_RT_USING_CPLUSPLUS is not set + +# +# Command shell +# +# CONFIG_RT_USING_FINSH is not set + +# +# Device virtual file system +# +CONFIG_RT_USING_DFS=y +CONFIG_DFS_USING_WORKDIR=y +CONFIG_DFS_FILESYSTEMS_MAX=2 +CONFIG_DFS_FILESYSTEM_TYPES_MAX=2 +CONFIG_DFS_FD_MAX=16 +# CONFIG_RT_USING_DFS_MNTTABLE is not set +# CONFIG_RT_USING_DFS_ELMFAT is not set +CONFIG_RT_USING_DFS_DEVFS=y +# CONFIG_RT_USING_DFS_ROMFS is not set +# CONFIG_RT_USING_DFS_RAMFS is not set +# CONFIG_RT_USING_DFS_UFFS is not set +# CONFIG_RT_USING_DFS_JFFS2 is not set + +# +# Device Drivers +# +CONFIG_RT_USING_DEVICE_IPC=y +CONFIG_RT_PIPE_BUFSZ=512 +CONFIG_RT_USING_SERIAL=y +# CONFIG_RT_USING_CAN is not set +# CONFIG_RT_USING_HWTIMER is not set +# CONFIG_RT_USING_CPUTIME is not set +# CONFIG_RT_USING_I2C is not set +CONFIG_RT_USING_PIN=y +# CONFIG_RT_USING_PWM is not set +# CONFIG_RT_USING_MTD_NOR is not set +# CONFIG_RT_USING_MTD_NAND is not set +# CONFIG_RT_USING_MTD is not set +# CONFIG_RT_USING_PM is not set +# CONFIG_RT_USING_RTC is not set +# CONFIG_RT_USING_SDIO is not set +# CONFIG_RT_USING_SPI is not set +# CONFIG_RT_USING_WDT is not set +# CONFIG_RT_USING_AUDIO is not set + +# +# Using WiFi +# +# CONFIG_RT_USING_WIFI is not set + +# +# Using USB +# +# CONFIG_RT_USING_USB_HOST is not set +# CONFIG_RT_USING_USB_DEVICE is not set + +# +# POSIX layer and C standard library +# +# CONFIG_RT_USING_LIBC is not set +# CONFIG_RT_USING_PTHREADS is not set + +# +# Network +# + +# +# Socket abstraction layer +# +# CONFIG_RT_USING_SAL is not set + +# +# light weight TCP/IP stack +# +# CONFIG_RT_USING_LWIP is not set + +# +# Modbus master and slave stack +# +# CONFIG_RT_USING_MODBUS is not set + +# +# AT commands +# +# CONFIG_RT_USING_AT is not set + +# +# VBUS(Virtual Software BUS) +# +# CONFIG_RT_USING_VBUS is not set + +# +# Utilities +# +# CONFIG_RT_USING_LOGTRACE is not set +# CONFIG_RT_USING_RYM is not set +# CONFIG_RT_USING_ULOG is not set + +# +# RT-Thread online packages +# + +# +# IoT - internet of things +# +# CONFIG_PKG_USING_PAHOMQTT is not set +# CONFIG_PKG_USING_WEBCLIENT is not set +# CONFIG_PKG_USING_MONGOOSE is not set +# CONFIG_PKG_USING_WEBTERMINAL is not set +# CONFIG_PKG_USING_CJSON is not set +# CONFIG_PKG_USING_JSMN is not set +# CONFIG_PKG_USING_LJSON is not set +# CONFIG_PKG_USING_EZXML is not set +# CONFIG_PKG_USING_NANOPB is not set + +# +# Wi-Fi +# + +# +# Marvell WiFi +# +# CONFIG_PKG_USING_WLANMARVELL is not set + +# +# Wiced WiFi +# +# CONFIG_PKG_USING_WLAN_WICED is not set +# CONFIG_PKG_USING_COAP is not set +# CONFIG_PKG_USING_NOPOLL is not set +# CONFIG_PKG_USING_NETUTILS is not set +# CONFIG_PKG_USING_AT_DEVICE is not set +# CONFIG_PKG_USING_WIZNET is not set + +# +# IoT Cloud +# +# CONFIG_PKG_USING_ONENET is not set +# CONFIG_PKG_USING_GAGENT_CLOUD is not set +# CONFIG_PKG_USING_ALI_IOTKIT is not set +# CONFIG_PKG_USING_AZURE is not set + +# +# security packages +# +# CONFIG_PKG_USING_MBEDTLS is not set +# CONFIG_PKG_USING_libsodium is not set +# CONFIG_PKG_USING_TINYCRYPT is not set + +# +# language packages +# +# CONFIG_PKG_USING_LUA is not set +# CONFIG_PKG_USING_JERRYSCRIPT is not set +# CONFIG_PKG_USING_MICROPYTHON is not set + +# +# multimedia packages +# +# CONFIG_PKG_USING_OPENMV is not set +# CONFIG_PKG_USING_MUPDF is not set + +# +# tools packages +# +# CONFIG_PKG_USING_CMBACKTRACE is not set +# CONFIG_PKG_USING_EASYFLASH is not set +# CONFIG_PKG_USING_EASYLOGGER is not set +# CONFIG_PKG_USING_SYSTEMVIEW is not set +# CONFIG_PKG_USING_RDB is not set + +# +# system packages +# +# CONFIG_PKG_USING_GUIENGINE is not set +# CONFIG_PKG_USING_CAIRO is not set +# CONFIG_PKG_USING_PIXMAN is not set +# CONFIG_PKG_USING_LWEXT4 is not set +# CONFIG_PKG_USING_PARTITION is not set +# CONFIG_PKG_USING_FAL is not set +# CONFIG_PKG_USING_SQLITE is not set +# CONFIG_PKG_USING_RTI is not set +# CONFIG_PKG_USING_LITTLEVGL2RTT is not set +# CONFIG_PKG_USING_CMSIS is not set +# CONFIG_PKG_USING_DFS_YAFFS is not set + +# +# peripheral libraries and drivers +# +# CONFIG_PKG_USING_REALTEK_AMEBA is not set +# CONFIG_PKG_USING_SHT2X is not set +# CONFIG_PKG_USING_AHT10 is not set +# CONFIG_PKG_USING_AP3216C is not set +# CONFIG_PKG_USING_STM32_SDIO is not set +# CONFIG_PKG_USING_ICM20608 is not set +# CONFIG_PKG_USING_U8G2 is not set + +# +# miscellaneous packages +# +# CONFIG_PKG_USING_LIBCSV is not set +# CONFIG_PKG_USING_OPTPARSE is not set +# CONFIG_PKG_USING_FASTLZ is not set +# CONFIG_PKG_USING_MINILZO is not set +# CONFIG_PKG_USING_QUICKLZ is not set +# CONFIG_PKG_USING_MULTIBUTTON is not set +# CONFIG_PKG_USING_CANFESTIVAL is not set +# CONFIG_PKG_USING_ZLIB is not set +# CONFIG_PKG_USING_DSTR is not set + +# +# sample package +# + +# +# samples: kernel and components samples +# +# CONFIG_PKG_USING_KERNEL_SAMPLES is not set +# CONFIG_PKG_USING_FILESYSTEM_SAMPLES is not set +# CONFIG_PKG_USING_NETWORK_SAMPLES is not set +# CONFIG_PKG_USING_PERIPHERAL_SAMPLES is not set + +# +# example package: hello +# +# CONFIG_PKG_USING_HELLO is not set diff --git a/bsp/tms320f28379d/Kconfig b/bsp/tms320f28379d/Kconfig new file mode 100644 index 0000000000..38b1a5b179 --- /dev/null +++ b/bsp/tms320f28379d/Kconfig @@ -0,0 +1,27 @@ +mainmenu "RT-Thread Configuration" + +config $BSP_DIR + string + option env="BSP_ROOT" + default "." + +config $RTT_DIR + string + option env="RTT_ROOT" + default "../.." + +# you can change the RTT_ROOT default "../.." to your rtthread_root, +# example : default "F:/git_repositories/rt-thread" + +config $PKGS_DIR + string + option env="PKGS_ROOT" + default "packages" + +config SOC_TMS320F28X + bool + select ARCH_C28X + default y + +source "$RTT_DIR/Kconfig" +source "$PKGS_DIR/Kconfig" diff --git a/bsp/tms320f28379d/applications/startup.c b/bsp/tms320f28379d/applications/startup.c index 419e779e55..301e63a00a 100644 --- a/bsp/tms320f28379d/applications/startup.c +++ b/bsp/tms320f28379d/applications/startup.c @@ -59,8 +59,6 @@ void rtthread_startup(void) /* init timer system */ rt_system_timer_init(); - //rt_system_heap_init((void*)STM32_SRAM_BEGIN, (void*)STM32_SRAM_END); - /* init scheduler system */ rt_system_scheduler_init(); diff --git a/bsp/tms320f28379d/rtconfig.h b/bsp/tms320f28379d/rtconfig.h index 3b2521a6c4..f0c62c21d2 100644 --- a/bsp/tms320f28379d/rtconfig.h +++ b/bsp/tms320f28379d/rtconfig.h @@ -2,19 +2,22 @@ #define RT_CONFIG_H__ /* Automatically generated file; DO NOT EDIT. */ -/* RT-Thread Project Configuration */ +/* RT-Thread Configuration */ + +#define SOC_TMS320F28X /* RT-Thread Kernel */ #define RT_NAME_MAX 8 #define RT_ALIGN_SIZE 4 -#define RT_THREAD_PRIORITY_MAX 16 +#define RT_THREAD_PRIORITY_8 +#define RT_THREAD_PRIORITY_MAX 8 #define RT_TICK_PER_SECOND 100 -//#define RT_USING_OVERFLOW_CHECK +#define RT_USING_OVERFLOW_CHECK #define RT_USING_HOOK +#define RT_USING_IDLE_HOOK #define RT_IDEL_HOOK_LIST_SIZE 4 -#define IDLE_THREAD_STACK_SIZE 1024 -#define ARCH_CPU_STACK_GROWS_UPWARD +#define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG /* Inter-Thread communication */ @@ -34,9 +37,11 @@ /* Kernel Device Object */ #define RT_USING_DEVICE -//#define RT_USING_CONSOLE +#define RT_USING_CONSOLE #define RT_CONSOLEBUF_SIZE 128 -#define RT_CONSOLE_DEVICE_NAME "uart2" +#define RT_CONSOLE_DEVICE_NAME "uart" +#define ARCH_C28X +#define ARCH_CPU_STACK_GROWS_UPWARD /* RT-Thread Components */ @@ -50,9 +55,12 @@ /* Device virtual file system */ - -/* elm-chan's FatFs, Generic FAT Filesystem Module */ - +#define RT_USING_DFS +#define DFS_USING_WORKDIR +#define DFS_FILESYSTEMS_MAX 2 +#define DFS_FILESYSTEM_TYPES_MAX 2 +#define DFS_FD_MAX 16 +#define RT_USING_DFS_DEVFS /* Device Drivers */ @@ -61,6 +69,9 @@ #define RT_USING_SERIAL #define RT_USING_PIN +/* Using WiFi */ + + /* Using USB */ @@ -71,18 +82,14 @@ /* Socket abstraction layer */ -#define RT_USING_SAL - -/* protocol stack implement */ - /* light weight TCP/IP stack */ -/* Static IPv4 Address */ +/* Modbus master and slave stack */ -/* Modbus master and slave stack */ +/* AT commands */ /* VBUS(Virtual Software BUS) */ @@ -91,9 +98,6 @@ /* Utilities */ -/* ARM CMSIS */ - - /* RT-Thread online packages */ /* IoT - internet of things */ @@ -107,6 +111,9 @@ /* Wiced WiFi */ +/* IoT Cloud */ + + /* security packages */ @@ -130,12 +137,10 @@ /* sample package */ +/* samples: kernel and components samples */ + /* example package: hello */ -#define SOC_STM32F4 -#define RT_USING_UART1 -#define RT_USING_UART2 -#define RT_USING_UART3 #endif diff --git a/libcpu/Kconfig b/libcpu/Kconfig index 3c80428b5d..72e6470b6a 100644 --- a/libcpu/Kconfig +++ b/libcpu/Kconfig @@ -86,6 +86,10 @@ config ARCH_RISCV config ARCH_IA32 bool +config ARCH_C28X + bool + select ARCH_CPU_STACK_GROWS_UPWARD + config ARCH_HOST_SIMULATOR bool -- cgit v1.3.1 From 6c081947b5c68819cc5ba9fd058e7bd29e9ca62a Mon Sep 17 00:00:00 2001 From: xuzhuoyi Date: Sat, 24 Nov 2018 17:41:55 +0800 Subject: [bsp][tms320f28379d] Classify c28x into ti-dsp --- bsp/tms320f28379d/.config | 3 +- bsp/tms320f28379d/.project | 8 +- .../.settings/org.eclipse.core.resources.prefs | 6 +- bsp/tms320f28379d/Kconfig | 2 +- bsp/tms320f28379d/rtconfig.h | 3 +- libcpu/Kconfig | 6 +- libcpu/c28x/context.s | 241 --------------------- libcpu/c28x/cpuport.c | 110 ---------- libcpu/ti-dsp/c28x/context.s | 241 +++++++++++++++++++++ libcpu/ti-dsp/c28x/cpuport.c | 110 ++++++++++ 10 files changed, 367 insertions(+), 363 deletions(-) delete mode 100644 libcpu/c28x/context.s delete mode 100644 libcpu/c28x/cpuport.c create mode 100644 libcpu/ti-dsp/c28x/context.s create mode 100644 libcpu/ti-dsp/c28x/cpuport.c (limited to 'libcpu') diff --git a/bsp/tms320f28379d/.config b/bsp/tms320f28379d/.config index 5337bc7be1..ddc9fd302e 100644 --- a/bsp/tms320f28379d/.config +++ b/bsp/tms320f28379d/.config @@ -62,7 +62,8 @@ CONFIG_RT_USING_DEVICE=y CONFIG_RT_USING_CONSOLE=y CONFIG_RT_CONSOLEBUF_SIZE=128 CONFIG_RT_CONSOLE_DEVICE_NAME="uart" -CONFIG_ARCH_C28X=y +CONFIG_ARCH_TIDSP=y +CONFIG_ARCH_TIDSP_C28X=y CONFIG_ARCH_CPU_STACK_GROWS_UPWARD=y # diff --git a/bsp/tms320f28379d/.project b/bsp/tms320f28379d/.project index 6d19540441..bab120e2b9 100644 --- a/bsp/tms320f28379d/.project +++ b/bsp/tms320f28379d/.project @@ -26,14 +26,14 @@ - C28X + Kernel 2 - PARENT-2-PROJECT_LOC/libcpu/c28x + PARENT-2-PROJECT_LOC/src - Kernel + c28x 2 - PARENT-2-PROJECT_LOC/src + PARENT-2-PROJECT_LOC/libcpu/ti-dsp/c28x diff --git a/bsp/tms320f28379d/.settings/org.eclipse.core.resources.prefs b/bsp/tms320f28379d/.settings/org.eclipse.core.resources.prefs index f5eae4d90c..288ca292c6 100644 --- a/bsp/tms320f28379d/.settings/org.eclipse.core.resources.prefs +++ b/bsp/tms320f28379d/.settings/org.eclipse.core.resources.prefs @@ -1,10 +1,10 @@ eclipse.preferences.version=1 -encoding//Debug/C28X/subdir_rules.mk=UTF-8 -encoding//Debug/C28X/subdir_vars.mk=UTF-8 encoding//Debug/Kernel/subdir_rules.mk=UTF-8 encoding//Debug/Kernel/subdir_vars.mk=UTF-8 encoding//Debug/applications/subdir_rules.mk=UTF-8 encoding//Debug/applications/subdir_vars.mk=UTF-8 +encoding//Debug/c28x/subdir_rules.mk=UTF-8 +encoding//Debug/c28x/subdir_vars.mk=UTF-8 encoding//Debug/drivers/subdir_rules.mk=UTF-8 encoding//Debug/drivers/subdir_vars.mk=UTF-8 encoding//Debug/libraries/common/source/subdir_rules.mk=UTF-8 @@ -13,8 +13,6 @@ encoding//Debug/libraries/headers/cmd/subdir_rules.mk=UTF-8 encoding//Debug/libraries/headers/cmd/subdir_vars.mk=UTF-8 encoding//Debug/libraries/headers/source/subdir_rules.mk=UTF-8 encoding//Debug/libraries/headers/source/subdir_vars.mk=UTF-8 -encoding//Debug/libraries/subdir_rules.mk=UTF-8 -encoding//Debug/libraries/subdir_vars.mk=UTF-8 encoding//Debug/makefile=UTF-8 encoding//Debug/objects.mk=UTF-8 encoding//Debug/sources.mk=UTF-8 diff --git a/bsp/tms320f28379d/Kconfig b/bsp/tms320f28379d/Kconfig index 38b1a5b179..de11cb4d79 100644 --- a/bsp/tms320f28379d/Kconfig +++ b/bsp/tms320f28379d/Kconfig @@ -20,7 +20,7 @@ config $PKGS_DIR config SOC_TMS320F28X bool - select ARCH_C28X + select ARCH_TIDSP_C28X default y source "$RTT_DIR/Kconfig" diff --git a/bsp/tms320f28379d/rtconfig.h b/bsp/tms320f28379d/rtconfig.h index f0c62c21d2..f74783569c 100644 --- a/bsp/tms320f28379d/rtconfig.h +++ b/bsp/tms320f28379d/rtconfig.h @@ -40,7 +40,8 @@ #define RT_USING_CONSOLE #define RT_CONSOLEBUF_SIZE 128 #define RT_CONSOLE_DEVICE_NAME "uart" -#define ARCH_C28X +#define ARCH_TIDSP +#define ARCH_TIDSP_C28X #define ARCH_CPU_STACK_GROWS_UPWARD /* RT-Thread Components */ diff --git a/libcpu/Kconfig b/libcpu/Kconfig index 72e6470b6a..22b4a6336a 100644 --- a/libcpu/Kconfig +++ b/libcpu/Kconfig @@ -86,8 +86,12 @@ config ARCH_RISCV config ARCH_IA32 bool -config ARCH_C28X +config ARCH_TIDSP bool + +config ARCH_TIDSP_C28X + bool + select ARCH_TIDSP select ARCH_CPU_STACK_GROWS_UPWARD config ARCH_HOST_SIMULATOR diff --git a/libcpu/c28x/context.s b/libcpu/c28x/context.s deleted file mode 100644 index 019b5def13..0000000000 --- a/libcpu/c28x/context.s +++ /dev/null @@ -1,241 +0,0 @@ -; -; Copyright (c) 2006-2018, RT-Thread Development Team -; -; SPDX-License-Identifier: Apache-2.0 -; -; Change Logs: -; Date Author Notes -; 2018-09-01 xuzhuoyi the first version. -; - - .ref _rt_interrupt_to_thread - .ref _rt_interrupt_from_thread - .ref _rt_thread_switch_interrupt_flag - - .def _RTOSINT_Handler - .def _rt_hw_get_st0 - .def _rt_hw_get_st1 - .def _rt_hw_context_switch_interrupt - .def _rt_hw_context_switch - .def _rt_hw_context_switch_to - .def _rt_hw_interrupt_thread_switch - .def _rt_hw_interrupt_disable - .def _rt_hw_interrupt_enable - - -RT_CTX_SAVE .macro - - - PUSH AR1H:AR0H - PUSH XAR2 - PUSH XAR3 - PUSH XAR4 - PUSH XAR5 - PUSH XAR6 - PUSH XAR7 - PUSH XT - PUSH RPC - - - .endm - - -RT_CTX_RESTORE .macro - - POP RPC - POP XT - POP XAR7 - POP XAR6 - POP XAR5 - POP XAR4 - POP XAR3 - POP XAR2 - - - MOVZ AR0 , @SP - SUBB XAR0, #6 - MOVL ACC , *XAR0 - AND ACC, #0xFFFF << 16 - MOV AL, IER - MOVL *XAR0, ACC - - - POP AR1H:AR0H - - .endm - - -.text - .newblock - -; -; rt_base_t rt_hw_interrupt_disable(); -; - .asmfunc -_rt_hw_interrupt_disable: - DINT - LRETR - .endasmfunc - -; -; void rt_hw_interrupt_enable(rt_base_t level); -; - .asmfunc -_rt_hw_interrupt_enable: - EINT - LRETR - .endasmfunc - -; -; void rt_hw_context_switch(rt_uint32 from, rt_uint32 to); -; r0 --> from -; r4 --> to - - - .asmfunc -_rt_hw_context_switch_interrupt: -_rt_hw_context_switch: - MOVL XAR0, #0 - MOV AR0, AL - MOVL XAR4, *-SP[4] - ; set rt_thread_switch_interrupt_flag to 1 - MOVL XAR5, #_rt_thread_switch_interrupt_flag - MOVL XAR6, *XAR5 - MOVL ACC, XAR6 - CMPB AL, #1 - B _reswitch, EQ - MOVL XAR6, #1 - MOVL *XAR5, XAR6 - - MOVL XAR5, #_rt_interrupt_from_thread ; set rt_interrupt_from_thread - MOVL *XAR5, XAR0 - -_reswitch: - MOVL XAR5, #_rt_interrupt_to_thread ; set rt_interrupt_to_thread - MOVL *XAR5, XAR4 - - TRAP #16 - LRETR - .endasmfunc - - .asmfunc -_RTOSINT_Handler: -; disable interrupt to protect context switch - DINT - - ; get rt_thread_switch_interrupt_flag - MOV AR0, #_rt_thread_switch_interrupt_flag - MOV AL, *AR0 - MOV AR1, AL - CMP AR1, #0 - B rtosint_exit, EQ ; pendsv already handled - - ; clear rt_thread_switch_interrupt_flag to 0 - MOV AR1, #0x00 - MOV *AR0, AR1 - - MOV AR0, #_rt_interrupt_from_thread - MOV AL, *AR0 - MOV AR1, AL - CMP AR1, #0 - B switch_to_thread, EQ ; skip register save at the first time - - ;MOVZ AR1, @SP ; get from thread stack pointer - -;#if defined (__VFP_FP__) && !defined(__SOFTFP__) -; TST lr, #0x10 ; if(!EXC_RETURN[4]) -; VSTMDBEQ r1!, {d8 - d15} ; push FPU register s16~s31 -;#endif - - RT_CTX_SAVE ; push r4 - r11 register - -;#if defined (__VFP_FP__) && !defined(__SOFTFP__) -; MOV r4, #0x00 ; flag = 0 - -; TST lr, #0x10 ; if(!EXC_RETURN[4]) -; MOVEQ r4, #0x01 ; flag = 1 - -; STMFD r1!, {r4} ; push flag -;#endif - - MOV AL, *AR0 - MOV AR1, AL - MOVZ AR1, @SP ; get from thread stack pointer - MOV *AR0, AR1 ; update from thread stack pointer - -switch_to_thread: - MOV AR1, #_rt_interrupt_to_thread - MOV AL, *AR1 - MOV AR1, AL - MOV AL, *AR1 - MOV AR1, AL ; load thread stack pointer - -;#if defined (__VFP_FP__) && !defined(__SOFTFP__) -; LDMFD r1!, {r3} ; pop flag -;#endif - - MOV @SP, AR1 - INC SP - RT_CTX_RESTORE ; pop r4 - r11 register - -rtosint_exit: - ; restore interrupt - EINT - - IRET - .endasmfunc - - .asmfunc -_rt_hw_get_st0: - PUSH ST0 - POP AL - LRETR - .endasmfunc - - .asmfunc -_rt_hw_get_st1: - PUSH ST1 - POP AL - LRETR - .endasmfunc - -; -; * void rt_hw_context_switch_to(rt_uint32 to); -; * r0 --> to - - .asmfunc -_rt_hw_context_switch_to: - MOV AR1, #_rt_interrupt_to_thread - MOV *AR1, AL - -;#if defined (__VFP_FP__) && !defined(__SOFTFP__) - ; CLEAR CONTROL.FPCA -; MRS r2, CONTROL ; read -; BIC r2, #0x04 ; modify -; MSR CONTROL, r2 ; write-back -;#endif - - ; set from thread to 0 - MOV AR1, #_rt_interrupt_from_thread - MOV AR0, #0x0 - MOV *AR1, AR0 - - ; set interrupt flag to 1 - MOV AR1, #_rt_thread_switch_interrupt_flag - MOV AR0, #1 - MOV *AR1, AR0 - - TRAP #16 - - - ; never reach here! - .endasmfunc - -; compatible with old version - .asmfunc -_rt_hw_interrupt_thread_switch: - LRETR - NOP - .endasmfunc - -.end diff --git a/libcpu/c28x/cpuport.c b/libcpu/c28x/cpuport.c deleted file mode 100644 index 8885f647a9..0000000000 --- a/libcpu/c28x/cpuport.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2018-09-01 xuzhuoyi the first version. - */ - -#include - -/* exception and interrupt handler table */ -rt_uint32_t rt_interrupt_from_thread; -rt_uint32_t rt_interrupt_to_thread; -rt_uint32_t rt_thread_switch_interrupt_flag; -/* exception hook */ -static rt_err_t (*rt_exception_hook)(void *context) = RT_NULL; - -struct exception_stack_frame -{ - rt_uint32_t t_st0; - rt_uint32_t acc; - rt_uint32_t p; - rt_uint32_t ar1_ar0; - rt_uint32_t dp_st1; - rt_uint32_t dbgstat_ier; - rt_uint32_t return_address; -}; - -struct stack_frame -{ - struct exception_stack_frame exception_stack_frame; - - /* r4 ~ r11 register */ - rt_uint16_t ar0h; - rt_uint16_t ar1h; - rt_uint32_t xar2; - rt_uint32_t xar3; - rt_uint32_t xar4; - rt_uint32_t xar5; - rt_uint32_t xar6; - rt_uint32_t xar7; - rt_uint32_t xt; - rt_uint32_t rpc; - - -}; - -rt_uint8_t *rt_hw_stack_init(void *tentry, - void *parameter, - rt_uint8_t *stack_addr, - void *texit) -{ - struct stack_frame *stack_frame; - rt_uint8_t *stk; - unsigned long i; - - stk = stack_addr; - stk = (rt_uint8_t *)RT_ALIGN((rt_uint32_t)stk, 8); - //stk -= sizeof(struct stack_frame); - - stack_frame = (struct stack_frame *)stk; - - /* init all register */ - for (i = 0; i < sizeof(struct stack_frame) / sizeof(rt_uint32_t); i ++) - { - ((rt_uint32_t *)stack_frame)[i] = 0xdeadbeef; - } - - stack_frame->exception_stack_frame.t_st0 = 0x11110000 | rt_hw_get_st0(); - stack_frame->exception_stack_frame.acc = 0x33332222; - stack_frame->exception_stack_frame.ar1_ar0 = 0x00001111 & (unsigned long)parameter; /* ar0 : argument */ - stack_frame->exception_stack_frame.p = 0x55554444; /* p */ - stack_frame->exception_stack_frame.dp_st1 = (0x00000000) | rt_hw_get_st1(); /* dp_st1 */ - stack_frame->exception_stack_frame.dbgstat_ier = 0; /* dbgstat_ier */ - stack_frame->exception_stack_frame.return_address = (unsigned long)tentry; /* return_address */ - stack_frame->rpc = (unsigned long)texit; - - /* return task's current stack address */ - return stk + sizeof(struct stack_frame); -} - -/** - * This function set the hook, which is invoked on fault exception handling. - * - * @param exception_handle the exception handling hook function. - */ -void rt_hw_exception_install(rt_err_t (*exception_handle)(void *context)) -{ - rt_exception_hook = exception_handle; -} - - -struct exception_info -{ - rt_uint32_t exc_return; - struct stack_frame stack_frame; -}; - - -/** - * shutdown CPU - */ -void rt_hw_cpu_shutdown(void) -{ - rt_kprintf("shutdown...\n"); - - RT_ASSERT(0); -} diff --git a/libcpu/ti-dsp/c28x/context.s b/libcpu/ti-dsp/c28x/context.s new file mode 100644 index 0000000000..019b5def13 --- /dev/null +++ b/libcpu/ti-dsp/c28x/context.s @@ -0,0 +1,241 @@ +; +; Copyright (c) 2006-2018, RT-Thread Development Team +; +; SPDX-License-Identifier: Apache-2.0 +; +; Change Logs: +; Date Author Notes +; 2018-09-01 xuzhuoyi the first version. +; + + .ref _rt_interrupt_to_thread + .ref _rt_interrupt_from_thread + .ref _rt_thread_switch_interrupt_flag + + .def _RTOSINT_Handler + .def _rt_hw_get_st0 + .def _rt_hw_get_st1 + .def _rt_hw_context_switch_interrupt + .def _rt_hw_context_switch + .def _rt_hw_context_switch_to + .def _rt_hw_interrupt_thread_switch + .def _rt_hw_interrupt_disable + .def _rt_hw_interrupt_enable + + +RT_CTX_SAVE .macro + + + PUSH AR1H:AR0H + PUSH XAR2 + PUSH XAR3 + PUSH XAR4 + PUSH XAR5 + PUSH XAR6 + PUSH XAR7 + PUSH XT + PUSH RPC + + + .endm + + +RT_CTX_RESTORE .macro + + POP RPC + POP XT + POP XAR7 + POP XAR6 + POP XAR5 + POP XAR4 + POP XAR3 + POP XAR2 + + + MOVZ AR0 , @SP + SUBB XAR0, #6 + MOVL ACC , *XAR0 + AND ACC, #0xFFFF << 16 + MOV AL, IER + MOVL *XAR0, ACC + + + POP AR1H:AR0H + + .endm + + +.text + .newblock + +; +; rt_base_t rt_hw_interrupt_disable(); +; + .asmfunc +_rt_hw_interrupt_disable: + DINT + LRETR + .endasmfunc + +; +; void rt_hw_interrupt_enable(rt_base_t level); +; + .asmfunc +_rt_hw_interrupt_enable: + EINT + LRETR + .endasmfunc + +; +; void rt_hw_context_switch(rt_uint32 from, rt_uint32 to); +; r0 --> from +; r4 --> to + + + .asmfunc +_rt_hw_context_switch_interrupt: +_rt_hw_context_switch: + MOVL XAR0, #0 + MOV AR0, AL + MOVL XAR4, *-SP[4] + ; set rt_thread_switch_interrupt_flag to 1 + MOVL XAR5, #_rt_thread_switch_interrupt_flag + MOVL XAR6, *XAR5 + MOVL ACC, XAR6 + CMPB AL, #1 + B _reswitch, EQ + MOVL XAR6, #1 + MOVL *XAR5, XAR6 + + MOVL XAR5, #_rt_interrupt_from_thread ; set rt_interrupt_from_thread + MOVL *XAR5, XAR0 + +_reswitch: + MOVL XAR5, #_rt_interrupt_to_thread ; set rt_interrupt_to_thread + MOVL *XAR5, XAR4 + + TRAP #16 + LRETR + .endasmfunc + + .asmfunc +_RTOSINT_Handler: +; disable interrupt to protect context switch + DINT + + ; get rt_thread_switch_interrupt_flag + MOV AR0, #_rt_thread_switch_interrupt_flag + MOV AL, *AR0 + MOV AR1, AL + CMP AR1, #0 + B rtosint_exit, EQ ; pendsv already handled + + ; clear rt_thread_switch_interrupt_flag to 0 + MOV AR1, #0x00 + MOV *AR0, AR1 + + MOV AR0, #_rt_interrupt_from_thread + MOV AL, *AR0 + MOV AR1, AL + CMP AR1, #0 + B switch_to_thread, EQ ; skip register save at the first time + + ;MOVZ AR1, @SP ; get from thread stack pointer + +;#if defined (__VFP_FP__) && !defined(__SOFTFP__) +; TST lr, #0x10 ; if(!EXC_RETURN[4]) +; VSTMDBEQ r1!, {d8 - d15} ; push FPU register s16~s31 +;#endif + + RT_CTX_SAVE ; push r4 - r11 register + +;#if defined (__VFP_FP__) && !defined(__SOFTFP__) +; MOV r4, #0x00 ; flag = 0 + +; TST lr, #0x10 ; if(!EXC_RETURN[4]) +; MOVEQ r4, #0x01 ; flag = 1 + +; STMFD r1!, {r4} ; push flag +;#endif + + MOV AL, *AR0 + MOV AR1, AL + MOVZ AR1, @SP ; get from thread stack pointer + MOV *AR0, AR1 ; update from thread stack pointer + +switch_to_thread: + MOV AR1, #_rt_interrupt_to_thread + MOV AL, *AR1 + MOV AR1, AL + MOV AL, *AR1 + MOV AR1, AL ; load thread stack pointer + +;#if defined (__VFP_FP__) && !defined(__SOFTFP__) +; LDMFD r1!, {r3} ; pop flag +;#endif + + MOV @SP, AR1 + INC SP + RT_CTX_RESTORE ; pop r4 - r11 register + +rtosint_exit: + ; restore interrupt + EINT + + IRET + .endasmfunc + + .asmfunc +_rt_hw_get_st0: + PUSH ST0 + POP AL + LRETR + .endasmfunc + + .asmfunc +_rt_hw_get_st1: + PUSH ST1 + POP AL + LRETR + .endasmfunc + +; +; * void rt_hw_context_switch_to(rt_uint32 to); +; * r0 --> to + + .asmfunc +_rt_hw_context_switch_to: + MOV AR1, #_rt_interrupt_to_thread + MOV *AR1, AL + +;#if defined (__VFP_FP__) && !defined(__SOFTFP__) + ; CLEAR CONTROL.FPCA +; MRS r2, CONTROL ; read +; BIC r2, #0x04 ; modify +; MSR CONTROL, r2 ; write-back +;#endif + + ; set from thread to 0 + MOV AR1, #_rt_interrupt_from_thread + MOV AR0, #0x0 + MOV *AR1, AR0 + + ; set interrupt flag to 1 + MOV AR1, #_rt_thread_switch_interrupt_flag + MOV AR0, #1 + MOV *AR1, AR0 + + TRAP #16 + + + ; never reach here! + .endasmfunc + +; compatible with old version + .asmfunc +_rt_hw_interrupt_thread_switch: + LRETR + NOP + .endasmfunc + +.end diff --git a/libcpu/ti-dsp/c28x/cpuport.c b/libcpu/ti-dsp/c28x/cpuport.c new file mode 100644 index 0000000000..8885f647a9 --- /dev/null +++ b/libcpu/ti-dsp/c28x/cpuport.c @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018-09-01 xuzhuoyi the first version. + */ + +#include + +/* exception and interrupt handler table */ +rt_uint32_t rt_interrupt_from_thread; +rt_uint32_t rt_interrupt_to_thread; +rt_uint32_t rt_thread_switch_interrupt_flag; +/* exception hook */ +static rt_err_t (*rt_exception_hook)(void *context) = RT_NULL; + +struct exception_stack_frame +{ + rt_uint32_t t_st0; + rt_uint32_t acc; + rt_uint32_t p; + rt_uint32_t ar1_ar0; + rt_uint32_t dp_st1; + rt_uint32_t dbgstat_ier; + rt_uint32_t return_address; +}; + +struct stack_frame +{ + struct exception_stack_frame exception_stack_frame; + + /* r4 ~ r11 register */ + rt_uint16_t ar0h; + rt_uint16_t ar1h; + rt_uint32_t xar2; + rt_uint32_t xar3; + rt_uint32_t xar4; + rt_uint32_t xar5; + rt_uint32_t xar6; + rt_uint32_t xar7; + rt_uint32_t xt; + rt_uint32_t rpc; + + +}; + +rt_uint8_t *rt_hw_stack_init(void *tentry, + void *parameter, + rt_uint8_t *stack_addr, + void *texit) +{ + struct stack_frame *stack_frame; + rt_uint8_t *stk; + unsigned long i; + + stk = stack_addr; + stk = (rt_uint8_t *)RT_ALIGN((rt_uint32_t)stk, 8); + //stk -= sizeof(struct stack_frame); + + stack_frame = (struct stack_frame *)stk; + + /* init all register */ + for (i = 0; i < sizeof(struct stack_frame) / sizeof(rt_uint32_t); i ++) + { + ((rt_uint32_t *)stack_frame)[i] = 0xdeadbeef; + } + + stack_frame->exception_stack_frame.t_st0 = 0x11110000 | rt_hw_get_st0(); + stack_frame->exception_stack_frame.acc = 0x33332222; + stack_frame->exception_stack_frame.ar1_ar0 = 0x00001111 & (unsigned long)parameter; /* ar0 : argument */ + stack_frame->exception_stack_frame.p = 0x55554444; /* p */ + stack_frame->exception_stack_frame.dp_st1 = (0x00000000) | rt_hw_get_st1(); /* dp_st1 */ + stack_frame->exception_stack_frame.dbgstat_ier = 0; /* dbgstat_ier */ + stack_frame->exception_stack_frame.return_address = (unsigned long)tentry; /* return_address */ + stack_frame->rpc = (unsigned long)texit; + + /* return task's current stack address */ + return stk + sizeof(struct stack_frame); +} + +/** + * This function set the hook, which is invoked on fault exception handling. + * + * @param exception_handle the exception handling hook function. + */ +void rt_hw_exception_install(rt_err_t (*exception_handle)(void *context)) +{ + rt_exception_hook = exception_handle; +} + + +struct exception_info +{ + rt_uint32_t exc_return; + struct stack_frame stack_frame; +}; + + +/** + * shutdown CPU + */ +void rt_hw_cpu_shutdown(void) +{ + rt_kprintf("shutdown...\n"); + + RT_ASSERT(0); +} -- cgit v1.3.1