summaryrefslogtreecommitdiff
path: root/libcpu/v850
diff options
context:
space:
mode:
authordzzxzz <[email protected]>2011-09-09 10:08:52 +0000
committerdzzxzz <[email protected]>2011-09-09 10:08:52 +0000
commit46a823ed917c34307dc5d7bb14b98a2dfce10812 (patch)
tree4444dc9a476d985f9439d0787f8c0d0e1c874b3e /libcpu/v850
parentf7d1ca323b4957e8ee7cc2425df9e2459594bddc (diff)
improve NEC V850 porting
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1705 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'libcpu/v850')
-rw-r--r--libcpu/v850/context.asm46
-rw-r--r--libcpu/v850/cpuport.c (renamed from libcpu/v850/stack.c)47
-rw-r--r--libcpu/v850/interrupt.c22
3 files changed, 41 insertions, 74 deletions
diff --git a/libcpu/v850/context.asm b/libcpu/v850/context.asm
index dc743f0818..a384c2f065 100644
--- a/libcpu/v850/context.asm
+++ b/libcpu/v850/context.asm
@@ -40,8 +40,6 @@
PUBLIC rt_hw_interrupt_disable
PUBLIC rt_hw_interrupt_enable
PUBLIC rt_hw_context_switch_to
- PUBLIC rt_hw_context_switch
- PUBLIC rt_hw_context_switch_interrupt
PUBLIC OSCtxSW
PUBLIC OS_Restore_CPU_Context
@@ -121,14 +119,6 @@ rt_hw_context_switch_to:
OSCtxSW:
SAVE_CPU_CTX ;Save all CPU registers
-
- mov rt_thread_switch_interrupt_flag, r1
- ld.w 0[r1],r5
- cmp 0, r5
- be exit
-
- mov 0, r5
- st.b r5, 0[r1]
mov rt_interrupt_from_thread, r21
ld.w 0[r21], r21
@@ -138,44 +128,10 @@ OSCtxSW:
ld.w 0[r1], r1
ld.w 0[r1], sp
-exit:
;Restore all Processor registers from stack and return from interrupt
jr OS_Restore_CPU_Context
-;R1 -> rt_interrupt_from_thread
-;R5 -> rt_interrupt_to_thread
-rt_hw_context_switch:
- mov rt_thread_switch_interrupt_flag, r8
- ld.w 0[r8],r9
- cmp 1, r9
- be jump1
- ;mov rt_thread_switch_interrupt_flag, r1
- mov 1, r9
- st.b r9, 0[r8]
- mov rt_interrupt_from_thread, r10
- st.w r1, 0[r10]
-jump1
- mov rt_interrupt_to_thread, r11
- st.w r5, 0[r11]
- trap 0x10
- jmp [lp]
-
-rt_hw_context_switch_interrupt:
- mov rt_thread_switch_interrupt_flag, r8
- ld.w 0[r8],r9
- cmp 1, r9
- be jump2
- ;mov rt_thread_switch_interrupt_flag, r1
- mov 1, r9
- st.b r9, 0[r8]
- mov rt_interrupt_from_thread, r10
- st.w r1, 0[r10]
-jump2
- mov rt_interrupt_to_thread, r11
- st.w r5, 0[r11]
- jmp [lp]
-
-rt_hw_context_switch_interrupt_do
+rt_hw_context_switch_interrupt_do:
mov rt_thread_switch_interrupt_flag, r8
mov 0, r9
st.b r9, 0[r8]
diff --git a/libcpu/v850/stack.c b/libcpu/v850/cpuport.c
index 2658716485..d5fee8ffa9 100644
--- a/libcpu/v850/stack.c
+++ b/libcpu/v850/cpuport.c
@@ -1,7 +1,7 @@
/*
- * File : stack.c
+ * File : cpuport.c
* This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2009, RT-Thread Development Team
+ * COPYRIGHT (C) 2009 - 2011, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
@@ -9,14 +9,30 @@
*
* Change Logs:
* Date Author Notes
- * 2010-06-29 lgnq the first version
- *
- * For : NEC V850E
- * Toolchain : IAR Embedded Workbench for V850 v3.71
-*/
+ * 2011-02-23 Bernard the first version
+ */
#include <rtthread.h>
+extern volatile rt_uint8_t rt_interrupt_nest;
+
+/* switch flag on interrupt and thread pointer to save switch record */
+rt_uint32_t rt_interrupt_from_thread;
+rt_uint32_t rt_interrupt_to_thread;
+rt_uint32_t rt_thread_switch_interrupt_flag;
+
+/**
+ * This function will initialize hardware interrupt
+ */
+void rt_hw_interrupt_init(void)
+{
+ /* init interrupt nest, and context in thread sp */
+ rt_interrupt_nest = 0;
+ rt_interrupt_from_thread = 0;
+ rt_interrupt_to_thread = 0;
+ rt_thread_switch_interrupt_flag = 0;
+}
+
/**
* This function will initialize thread stack
*
@@ -59,3 +75,20 @@ rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter, rt_uint8_t *stack_ad
*(--stk) = (rt_uint32_t) parameter; /* r1 */
return ((rt_uint8_t *)stk);
}
+
+void rt_hw_context_switch(rt_uint32_t from, rt_uint32_t to)
+{
+ rt_interrupt_from_thread = from;
+ rt_interrupt_to_thread = to;
+ asm("trap 0x10");
+}
+
+void rt_hw_context_switch_interrupt(rt_uint32_t from, rt_uint32_t to)
+{
+ if (rt_thread_switch_interrupt_flag != 1)
+ {
+ rt_thread_switch_interrupt_flag = 1;
+ rt_interrupt_from_thread = from;
+ }
+ rt_interrupt_to_thread = to;
+} \ No newline at end of file
diff --git a/libcpu/v850/interrupt.c b/libcpu/v850/interrupt.c
deleted file mode 100644
index cb85a053f1..0000000000
--- a/libcpu/v850/interrupt.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * File : interrupt.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2009, 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
- * 2010-06-29 lgnq the first version
- *
- * For : NEC V850E
- * Toolchain : IAR Embedded Workbench for V850 v3.71
-*/
-
-#include <rtthread.h>
-
-rt_uint32_t rt_interrupt_from_thread;
-rt_uint32_t rt_interrupt_to_thread;
-rt_uint32_t rt_thread_switch_interrupt_flag; \ No newline at end of file