From 4a2ce8bca5b3682a514de8b1a0499624ad6da1fc Mon Sep 17 00:00:00 2001 From: Huang bo Date: Thu, 18 Nov 2021 09:48:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bsp/ti-tms320c6678/driver/drv_timer.c | 8 +++--- libcpu/ti-dsp/c6x/interrupt.c | 7 +++++- libcpu/ti-dsp/c6x/trap.c | 28 +++++++++++++-------- libcpu/ti-dsp/c6x/trap.h | 36 +++++++++++++-------------- 4 files changed, 45 insertions(+), 34 deletions(-) diff --git a/bsp/ti-tms320c6678/driver/drv_timer.c b/bsp/ti-tms320c6678/driver/drv_timer.c index a755689df4..30b2770f24 100644 --- a/bsp/ti-tms320c6678/driver/drv_timer.c +++ b/bsp/ti-tms320c6678/driver/drv_timer.c @@ -35,7 +35,7 @@ void rt_hw_systick_isr(void) void rt_hw_system_timer_init(void) { // initial system timer interrupt, map local timer interrupt to INT14 - gpCGEM_regs->INTMUX3=(CSL_GEM_TINTLN<INTMUX3 = (CSL_GEM_TINTLN<TOUTSEL = (DNUM*2)<= MAX_HANDLERS) + { return; + } } /** @@ -56,7 +57,9 @@ void rt_hw_interrupt_mask(int vector) void rt_hw_interrupt_umask(int vector) { if (vector < 0 || vector >= MAX_HANDLERS) + { return; + } } /** @@ -90,5 +93,7 @@ rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler, void rt_hw_interrupt_clear(int vector) { if (vector < 0 || vector >= MAX_HANDLERS) + { return; + } } diff --git a/libcpu/ti-dsp/c6x/trap.c b/libcpu/ti-dsp/c6x/trap.c index 7d4c063798..c7030c9bec 100644 --- a/libcpu/ti-dsp/c6x/trap.c +++ b/libcpu/ti-dsp/c6x/trap.c @@ -12,9 +12,8 @@ #include "c66xx.h" #include -#include - #include +#include #define RT_SYS_STACK_SIZE 4096 @@ -136,16 +135,18 @@ static struct rt_exception_info iexcept_table[10] = { static int process_iexcept(struct rt_hw_exp_stack_register *regs) { unsigned int iexcept_report = get_iexcept(); - unsigned int iexcept_num; + unsigned int iexcept_num = 0; ack_exception(EXCEPT_TYPE_IXF); - while(iexcept_report) { + while(iexcept_report) + { iexcept_num = __ffs(iexcept_report); iexcept_report &= ~(1 << iexcept_num); set_iexcept(iexcept_report); - if (*(unsigned int *)regs->pc == BKPT_OPCODE) { + if (*(unsigned int *)regs->pc == BKPT_OPCODE) + { /* This is a breakpoint */ struct rt_exception_info bkpt_exception = { " - undefined instruction", ABORT_TYPE_UNDDEF, ABORT_BRKPT_ILL }; do_trap(&bkpt_exception, regs); @@ -300,10 +301,12 @@ static void process_except(struct rt_hw_exp_stack_register *regs) { int except_num; int bank = 0; - int i; + int i = 0; - for (i = 0; i <= 3; i++) { - while (INTC_MEXPMASK[i]) { + for (i = 0; i <= 3; i++) + { + while (INTC_MEXPMASK[i]) + { __dint(); except_num = __ffs(INTC_MEXPMASK[i]); INTC_MEXPMASK[i] &= ~(1 << except_num); /* ack the external exception */ @@ -317,14 +320,13 @@ static void process_except(struct rt_hw_exp_stack_register *regs) } extern void hw_nmi_handler(struct rt_hw_exp_stack_register *regs); - /* * Main exception processing */ int rt_hw_process_exception(struct rt_hw_exp_stack_register *regs) { - int type; - int type_num; + int type = 0; + int type_num = 0; int ie_num = 9; /* default is unknown exception */ while ((type = get_except_type()) != 0) { @@ -334,12 +336,16 @@ int rt_hw_process_exception(struct rt_hw_exp_stack_register *regs) case EXCEPT_TYPE_NXF: /* NMI exception */ ack_exception(EXCEPT_TYPE_NXF); /* clear exception */ if (hw_nmi_handler != RT_NULL) + { hw_nmi_handler(regs); + } break; case EXCEPT_TYPE_IXF: /* internal exception */ if (process_iexcept(regs)) + { return 1; + } break; case EXCEPT_TYPE_EXC: /* external exception */ diff --git a/libcpu/ti-dsp/c6x/trap.h b/libcpu/ti-dsp/c6x/trap.h index 062acee768..9c8f52dd14 100644 --- a/libcpu/ti-dsp/c6x/trap.h +++ b/libcpu/ti-dsp/c6x/trap.h @@ -41,34 +41,34 @@ enum SYSTEM_TRAP_CODE { - ABORT_BUS_ADDRERR = 0, // bus address error - ABORT_BUS_ACCERR, // bus access permission error - ABORT_OPCODE_ILL, // illegal opcode - ABORT_PRVREG_ILL, // privilege register - ABORT_PRVOPC_ILL, // privileged opcode - ABORT_ILLTRP_ILL, // illegal trap - ABORT_BRKPT_ILL, // handling breakpoints + ABORT_BUS_ADDRERR = 0, // bus address error + ABORT_BUS_ACCERR, // bus access permission error + ABORT_OPCODE_ILL, // illegal opcode + ABORT_PRVREG_ILL, // privilege register + ABORT_PRVOPC_ILL, // privileged opcode + ABORT_ILLTRP_ILL, // illegal trap + ABORT_BRKPT_ILL, // handling breakpoints }; /* * abort types */ -#define ABORT_TYPE_BUS 0 // bus access abnormal -#define ABORT_TYPE_MAP 1 // page table mapping error -#define ABORT_TYPE_UNDDEF 0xff // undefined exception -#define ABORT_TYPE_FATAL 0xffffffff // fatal error +#define ABORT_TYPE_BUS 0 // bus access abnormal +#define ABORT_TYPE_MAP 1 // page table mapping error +#define ABORT_TYPE_UNDDEF 0xff // undefined exception +#define ABORT_TYPE_FATAL 0xffffffff // fatal error struct rt_exception_info { - char *kernel_str; - int type; - int code; + char *kernel_str; + int type; + int code; }; -#define BKPT_OPCODE 0x56454314 /* illegal opcode */ -#define INTC_MEXPMASK __SYSREGA(0x018000e0, unsigned int) +#define BKPT_OPCODE 0x56454314 /* illegal opcode */ +#define INTC_MEXPMASK __SYSREGA(0x018000e0, unsigned int) -#define __ffs(a) (_lmbd(1, _bitr(a))) -#define __fls(a) (!(a) ? 0 : (32 - _lmbd(1, (a)))) +#define __ffs(a) (_lmbd(1, _bitr(a))) +#define __fls(a) (!(a) ? 0 : (32 - _lmbd(1, (a)))) extern void rt_trap_init(void); -- GitLab