From e1e563e85c831e40c43cb7801434700e779dd750 Mon Sep 17 00:00:00 2001 From: Grissiom Date: Sun, 20 Oct 2013 21:09:45 +0800 Subject: [PATCH] cortex-r4: remove RM48x50.h and add armv7.h --- libcpu/arm/cortex-r4/RM48x50.h | 39 -------------------------- libcpu/arm/cortex-r4/armv7.h | 47 ++++++++++++++++++++++++++++++++ libcpu/arm/cortex-r4/interrupt.c | 6 +++- libcpu/arm/cortex-r4/stack.c | 4 +-- libcpu/arm/cortex-r4/trap.c | 26 ++++++++---------- 5 files changed, 66 insertions(+), 56 deletions(-) delete mode 100644 libcpu/arm/cortex-r4/RM48x50.h create mode 100644 libcpu/arm/cortex-r4/armv7.h diff --git a/libcpu/arm/cortex-r4/RM48x50.h b/libcpu/arm/cortex-r4/RM48x50.h deleted file mode 100644 index 9f4bcc976f..0000000000 --- a/libcpu/arm/cortex-r4/RM48x50.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef RM48X50_H -#define RM48X50_H - -#include -#include - -#define USERMODE 0x10 -#define FIQMODE 0x11 -#define IRQMODE 0x12 -#define SVCMODE 0x13 -#define ABORTMODE 0x17 -#define UNDEFMODE 0x1b -#define MODEMASK 0x1f -#define NOINT 0xc0 - -struct rt_hw_register -{ - unsigned long r0; - unsigned long r1; - unsigned long r2; - unsigned long r3; - unsigned long r4; - unsigned long r5; - unsigned long r6; - unsigned long r7; - unsigned long r8; - unsigned long r9; - unsigned long r10; - unsigned long fp; - unsigned long ip; - unsigned long sp; - unsigned long lr; - unsigned long pc; - unsigned long cpsr; - unsigned long ORIG_r0; -}; - -#endif /* end of include guard: RM48X50_H */ - diff --git a/libcpu/arm/cortex-r4/armv7.h b/libcpu/arm/cortex-r4/armv7.h new file mode 100644 index 0000000000..bca4e516e1 --- /dev/null +++ b/libcpu/arm/cortex-r4/armv7.h @@ -0,0 +1,47 @@ +#ifndef __ARMV7_H__ +#define __ARMV7_H__ + +#ifndef VFP_DATA_NR +#define VFP_DATA_NR 32 +#endif + +/* the stack without VFP registers */ +struct rt_hw_base_stack +{ + unsigned long cpsr; + unsigned long r0; + unsigned long r1; + unsigned long r2; + unsigned long r3; + unsigned long r4; + unsigned long r5; + unsigned long r6; + unsigned long r7; + unsigned long r8; + unsigned long r9; + unsigned long r10; + unsigned long fp; + unsigned long ip; + unsigned long lr; + unsigned long pc; +}; + +#define USERMODE 0x10 +#define FIQMODE 0x11 +#define IRQMODE 0x12 +#define SVCMODE 0x13 +#define MONITORMODE 0x16 +#define ABORTMODE 0x17 +#define HYPMODE 0x1b +#define UNDEFMODE 0x1b +#define MODEMASK 0x1f +#define NOINT 0xc0 + +#define T_Bit (1<<5) +#define F_Bit (1<<6) +#define I_Bit (1<<7) +#define A_Bit (1<<8) +#define E_Bit (1<<9) +#define J_Bit (1<<24) + +#endif diff --git a/libcpu/arm/cortex-r4/interrupt.c b/libcpu/arm/cortex-r4/interrupt.c index d001b509ee..ba2d99e998 100644 --- a/libcpu/arm/cortex-r4/interrupt.c +++ b/libcpu/arm/cortex-r4/interrupt.c @@ -15,7 +15,11 @@ #include #include -#include "RM48x50.h" + +#include +#include + +#include "armv7.h" #define MAX_HANDLERS 96 diff --git a/libcpu/arm/cortex-r4/stack.c b/libcpu/arm/cortex-r4/stack.c index 769e3360ed..3c8e89444c 100644 --- a/libcpu/arm/cortex-r4/stack.c +++ b/libcpu/arm/cortex-r4/stack.c @@ -13,7 +13,8 @@ * 2013-05-24 Grissiom port to RM48x50 */ #include -#include "RM48x50.h" + +#include "armv7.h" /** * @addtogroup RM48x50 */ @@ -60,7 +61,6 @@ rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter, #if defined(__TI_VFP_SUPPORT__) || (defined (__VFP_FP__) && !defined(__SOFTFP__)) #ifndef RT_VFP_LAZY_STACKING { - #define VFP_DATA_NR 32 int i; for (i = 0; i < VFP_DATA_NR; i++) diff --git a/libcpu/arm/cortex-r4/trap.c b/libcpu/arm/cortex-r4/trap.c index d77f9734da..6b36b0bd87 100644 --- a/libcpu/arm/cortex-r4/trap.c +++ b/libcpu/arm/cortex-r4/trap.c @@ -15,8 +15,10 @@ #include #include -#include "RM48x50.h" -//#define BSP_INT_DEBUG + +#include + +#include "armv7.h" /** * @addtogroup RM48x50 @@ -28,26 +30,26 @@ * * @param regs the registers point */ -void rt_hw_show_register (struct rt_hw_register *regs) +void rt_hw_show_register (struct rt_hw_base_stack *regs) { rt_kprintf("Execption:\n"); rt_kprintf("r00:0x%08x r01:0x%08x r02:0x%08x r03:0x%08x\n", regs->r0, regs->r1, regs->r2, regs->r3); rt_kprintf("r04:0x%08x r05:0x%08x r06:0x%08x r07:0x%08x\n", regs->r4, regs->r5, regs->r6, regs->r7); rt_kprintf("r08:0x%08x r09:0x%08x r10:0x%08x\n", regs->r8, regs->r9, regs->r10); rt_kprintf("fp :0x%08x ip :0x%08x\n", regs->fp, regs->ip); - rt_kprintf("sp :0x%08x lr :0x%08x pc :0x%08x\n", regs->sp, regs->lr, regs->pc); + rt_kprintf("sp :0x%08x lr :0x%08x pc :0x%08x\n", regs+1, regs->lr, regs->pc); rt_kprintf("cpsr:0x%08x\n", regs->cpsr); } /** - * When ARM7TDMI comes across an instruction which it cannot handle, + * When comes across an instruction which it cannot handle, * it takes the undefined instruction trap. * * @param regs system registers * * @note never invoke this function in application */ -void rt_hw_trap_udef(struct rt_hw_register *regs) +void rt_hw_trap_udef(struct rt_hw_base_stack *regs) { rt_kprintf("undefined instruction\n"); rt_hw_show_register(regs); @@ -65,7 +67,7 @@ void rt_hw_trap_udef(struct rt_hw_register *regs) * * @note never invoke this function in application */ -void rt_hw_trap_swi(struct rt_hw_register *regs) +void rt_hw_trap_swi(struct rt_hw_base_stack *regs) { rt_kprintf("software interrupt\n"); rt_hw_show_register(regs); @@ -82,7 +84,7 @@ void rt_hw_trap_swi(struct rt_hw_register *regs) * * @note never invoke this function in application */ -void rt_hw_trap_pabt(struct rt_hw_register *regs) +void rt_hw_trap_pabt(struct rt_hw_base_stack *regs) { rt_kprintf("prefetch abort\n"); rt_hw_show_register(regs); @@ -99,7 +101,7 @@ void rt_hw_trap_pabt(struct rt_hw_register *regs) * * @note never invoke this function in application */ -void rt_hw_trap_dabt(struct rt_hw_register *regs) +void rt_hw_trap_dabt(struct rt_hw_base_stack *regs) { rt_kprintf("Data Abort "); rt_hw_show_register(regs); @@ -115,7 +117,7 @@ void rt_hw_trap_dabt(struct rt_hw_register *regs) * * @note never invoke this function in application */ -void rt_hw_trap_resv(struct rt_hw_register *regs) +void rt_hw_trap_resv(struct rt_hw_base_stack *regs) { rt_kprintf("not used\n"); rt_hw_show_register(regs); @@ -124,10 +126,6 @@ void rt_hw_trap_resv(struct rt_hw_register *regs) rt_hw_cpu_shutdown(); } -/* - *#pragma CODE_STATE(rt_hw_trap_irq, 32) - *#pragma INTERRUPT(rt_hw_trap_irq, IRQ) - */ extern rt_isr_handler_t isr_table[]; void rt_hw_trap_irq(void) {