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 |
---|