1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * This file contains the basic algorithms for all assembly code used |
---|
5 | * in an specific CPU port of RTEMS. These algorithms must be implemented |
---|
6 | * in assembly language |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * COPYRIGHT (c) 1989-2012. |
---|
11 | * On-Line Applications Research Corporation (OAR). |
---|
12 | * |
---|
13 | * The license and distribution terms for this file may be |
---|
14 | * found in the file LICENSE in this distribution or at |
---|
15 | * http://www.rtems.org/license/LICENSE. |
---|
16 | */ |
---|
17 | |
---|
18 | #ifdef HAVE_CONFIG_H |
---|
19 | #include "config.h" |
---|
20 | #endif |
---|
21 | |
---|
22 | #if 0 |
---|
23 | /** |
---|
24 | * This routine is responsible for saving the FP context |
---|
25 | * at *fp_context_ptr. If the point to load the FP context |
---|
26 | * from is changed then the pointer is modified by this routine. |
---|
27 | * |
---|
28 | * Sometimes a macro implementation of this is in cpu.h which dereferences |
---|
29 | * the ** and a similarly named routine in this file is passed something |
---|
30 | * like a (Context_Control_fp *). The general rule on making this decision |
---|
31 | * is to avoid writing assembly language. |
---|
32 | * |
---|
33 | * v850 Specific Information: |
---|
34 | * |
---|
35 | * The v850 appears to always have soft float. |
---|
36 | */ |
---|
37 | void _CPU_Context_save_fp( |
---|
38 | Context_Control_fp **fp_context_ptr |
---|
39 | ) |
---|
40 | { |
---|
41 | } |
---|
42 | |
---|
43 | /** |
---|
44 | * This routine is responsible for restoring the FP context |
---|
45 | * at *fp_context_ptr. If the point to load the FP context |
---|
46 | * from is changed then the pointer is modified by this routine. |
---|
47 | * |
---|
48 | * Sometimes a macro implementation of this is in cpu.h which dereferences |
---|
49 | * the ** and a similarly named routine in this file is passed something |
---|
50 | * like a (Context_Control_fp *). The general rule on making this decision |
---|
51 | * is to avoid writing assembly language. |
---|
52 | * |
---|
53 | * v850 Specific Information: |
---|
54 | * |
---|
55 | * XXX document implementation including references if appropriate |
---|
56 | */ |
---|
57 | void _CPU_Context_restore_fp( |
---|
58 | Context_Control_fp **fp_context_ptr |
---|
59 | ) |
---|
60 | { |
---|
61 | } |
---|
62 | #endif |
---|
63 | |
---|
64 | /** |
---|
65 | * This routine performs a normal non-FP context switch. |
---|
66 | * |
---|
67 | * v850 Specific Information: |
---|
68 | * |
---|
69 | * + r6 - running thread |
---|
70 | * + r7 - heir thread |
---|
71 | */ |
---|
72 | #define V850_CONTEXT_CONTROL_R1_OFFSET 0 |
---|
73 | #define V850_CONTEXT_CONTROL_R3_OFFSET 4 |
---|
74 | #define V850_CONTEXT_CONTROL_R20_OFFSET 8 |
---|
75 | #define V850_CONTEXT_CONTROL_R21_OFFSET 12 |
---|
76 | #define V850_CONTEXT_CONTROL_R22_OFFSET 16 |
---|
77 | #define V850_CONTEXT_CONTROL_R23_OFFSET 20 |
---|
78 | #define V850_CONTEXT_CONTROL_R24_OFFSET 24 |
---|
79 | #define V850_CONTEXT_CONTROL_R25_OFFSET 28 |
---|
80 | #define V850_CONTEXT_CONTROL_R26_OFFSET 32 |
---|
81 | #define V850_CONTEXT_CONTROL_R27_OFFSET 36 |
---|
82 | #define V850_CONTEXT_CONTROL_R28_OFFSET 40 |
---|
83 | #define V850_CONTEXT_CONTROL_R29_OFFSET 44 |
---|
84 | #define V850_CONTEXT_CONTROL_R31_OFFSET 48 |
---|
85 | #define V850_CONTEXT_CONTROL_PSW_OFFSET 52 |
---|
86 | |
---|
87 | .section .text |
---|
88 | .global __CPU_Context_switch |
---|
89 | .type __CPU_Context_switch, @function |
---|
90 | __CPU_Context_switch: |
---|
91 | st.w r1,V850_CONTEXT_CONTROL_R1_OFFSET[r6] |
---|
92 | st.w r3,V850_CONTEXT_CONTROL_R3_OFFSET[r6] |
---|
93 | st.w r20,V850_CONTEXT_CONTROL_R20_OFFSET[r6] |
---|
94 | st.w r21,V850_CONTEXT_CONTROL_R21_OFFSET[r6] |
---|
95 | st.w r22,V850_CONTEXT_CONTROL_R22_OFFSET[r6] |
---|
96 | st.w r23,V850_CONTEXT_CONTROL_R23_OFFSET[r6] |
---|
97 | st.w r24,V850_CONTEXT_CONTROL_R24_OFFSET[r6] |
---|
98 | st.w r25,V850_CONTEXT_CONTROL_R25_OFFSET[r6] |
---|
99 | st.w r26,V850_CONTEXT_CONTROL_R27_OFFSET[r6] |
---|
100 | st.w r27,V850_CONTEXT_CONTROL_R27_OFFSET[r6] |
---|
101 | st.w r28,V850_CONTEXT_CONTROL_R28_OFFSET[r6] |
---|
102 | st.w r29,V850_CONTEXT_CONTROL_R29_OFFSET[r6] |
---|
103 | st.w r31,V850_CONTEXT_CONTROL_R31_OFFSET[r6] |
---|
104 | stsr psw,r21 |
---|
105 | st.w r21,V850_CONTEXT_CONTROL_PSW_OFFSET[r6] |
---|
106 | restore: |
---|
107 | ld.w V850_CONTEXT_CONTROL_R1_OFFSET[r7],r1 |
---|
108 | ld.w V850_CONTEXT_CONTROL_R3_OFFSET[r7],r3 |
---|
109 | ld.w V850_CONTEXT_CONTROL_R20_OFFSET[r7],r20 |
---|
110 | ld.w V850_CONTEXT_CONTROL_R21_OFFSET[r7],r21 |
---|
111 | ld.w V850_CONTEXT_CONTROL_R22_OFFSET[r7],r22 |
---|
112 | ld.w V850_CONTEXT_CONTROL_R23_OFFSET[r7],r23 |
---|
113 | ld.w V850_CONTEXT_CONTROL_R24_OFFSET[r7],r24 |
---|
114 | ld.w V850_CONTEXT_CONTROL_R25_OFFSET[r7],r25 |
---|
115 | ld.w V850_CONTEXT_CONTROL_R27_OFFSET[r7],r26 |
---|
116 | ld.w V850_CONTEXT_CONTROL_R27_OFFSET[r7],r27 |
---|
117 | ld.w V850_CONTEXT_CONTROL_R28_OFFSET[r7],r28 |
---|
118 | ld.w V850_CONTEXT_CONTROL_R29_OFFSET[r7],r29 |
---|
119 | ld.w V850_CONTEXT_CONTROL_R31_OFFSET[r7],r31 |
---|
120 | ld.w V850_CONTEXT_CONTROL_PSW_OFFSET[r7],r7 |
---|
121 | ldsr r7,psw |
---|
122 | jmp [r31] |
---|
123 | |
---|
124 | |
---|
125 | /** |
---|
126 | * This routine is generally used only to restart self in an |
---|
127 | * efficient manner. It may simply be a label in _CPU_Context_switch. |
---|
128 | * |
---|
129 | * NOTE: May be unnecessary to reload some registers. |
---|
130 | * |
---|
131 | * v850 Specific Information: |
---|
132 | * |
---|
133 | * Move second parameter to first and jump to normal restore |
---|
134 | */ |
---|
135 | .section .text |
---|
136 | .global __CPU_Context_restore |
---|
137 | .type __CPU_Context_restore, @function |
---|
138 | __CPU_Context_restore: |
---|
139 | mov r6, r7 /* move to second parameter register */ |
---|
140 | br restore |
---|
141 | |
---|
142 | #if 0 |
---|
143 | /** |
---|
144 | * This routine provides the RTEMS interrupt management. |
---|
145 | * |
---|
146 | * v850 Specific Information: |
---|
147 | * |
---|
148 | * XXX document implementation including references if appropriate |
---|
149 | */ |
---|
150 | void _ISR_Handler(void); /* C warning avoidance */ |
---|
151 | void _ISR_Handler(void) |
---|
152 | { |
---|
153 | /* |
---|
154 | * This discussion ignores a lot of the ugly details in a real |
---|
155 | * implementation such as saving enough registers/state to be |
---|
156 | * able to do something real. Keep in mind that the goal is |
---|
157 | * to invoke a user's ISR handler which is written in C and |
---|
158 | * uses a certain set of registers. |
---|
159 | * |
---|
160 | * Also note that the exact order is to a large extent flexible. |
---|
161 | * Hardware will dictate a sequence for a certain subset of |
---|
162 | * _ISR_Handler while requirements for setting |
---|
163 | */ |
---|
164 | |
---|
165 | /* |
---|
166 | * At entry to "common" _ISR_Handler, the vector number must be |
---|
167 | * available. On some CPUs the hardware puts either the vector |
---|
168 | * number or the offset into the vector table for this ISR in a |
---|
169 | * known place. If the hardware does not give us this information, |
---|
170 | * then the assembly portion of RTEMS for this port will contain |
---|
171 | * a set of distinct interrupt entry points which somehow place |
---|
172 | * the vector number in a known place (which is safe if another |
---|
173 | * interrupt nests this one) and branches to _ISR_Handler. |
---|
174 | * |
---|
175 | * save some or all context on stack |
---|
176 | * may need to save some special interrupt information for exit |
---|
177 | * |
---|
178 | * #if ( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE ) |
---|
179 | * if ( _ISR_Nest_level == 0 ) |
---|
180 | * switch to software interrupt stack |
---|
181 | * #endif |
---|
182 | * |
---|
183 | * _ISR_Nest_level++; |
---|
184 | * |
---|
185 | * _Thread_Dispatch_disable_level++; |
---|
186 | * |
---|
187 | * (*_ISR_Vector_table[ vector ])( vector ); |
---|
188 | * |
---|
189 | * _Thread_Dispatch_disable_level--; |
---|
190 | * |
---|
191 | * --_ISR_Nest_level; |
---|
192 | * |
---|
193 | * if ( _ISR_Nest_level ) |
---|
194 | * goto the label "exit interrupt (simple case)" |
---|
195 | * |
---|
196 | * if ( _Thread_Dispatch_disable_level ) |
---|
197 | * goto the label "exit interrupt (simple case)" |
---|
198 | * |
---|
199 | * if ( _Thread_Dispatch_necessary ) { |
---|
200 | * call _Thread_Dispatch() or prepare to return to _ISR_Dispatch |
---|
201 | * prepare to get out of interrupt |
---|
202 | * return from interrupt (maybe to _ISR_Dispatch) |
---|
203 | * |
---|
204 | * LABEL "exit interrupt (simple case): |
---|
205 | * #if ( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE ) |
---|
206 | * if outermost interrupt |
---|
207 | * restore stack |
---|
208 | * #endif |
---|
209 | * prepare to get out of interrupt |
---|
210 | * return from interrupt |
---|
211 | */ |
---|
212 | } |
---|
213 | #endif |
---|