improve NEC V850 porting

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1705 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
dzzxzz
2011-09-09 10:08:52 +00:00
parent f7d1ca323b
commit 46a823ed91
13 changed files with 276 additions and 448 deletions
+1 -45
View File
@@ -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]
+40 -7
View File
@@ -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;
}
-22
View File
@@ -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;