1 | /* |
---|
2 | * Motorola MC68xxx Dependent Source |
---|
3 | * |
---|
4 | * COPYRIGHT (c) 1989-1999. |
---|
5 | * On-Line Applications Research Corporation (OAR). |
---|
6 | * |
---|
7 | * The license and distribution terms for this file may be |
---|
8 | * found in the file LICENSE in this distribution or at |
---|
9 | * http://www.rtems.com/license/LICENSE. |
---|
10 | * |
---|
11 | * $Id$ |
---|
12 | */ |
---|
13 | |
---|
14 | #include <rtems/system.h> |
---|
15 | #include <rtems/score/isr.h> |
---|
16 | |
---|
17 | /* _CPU_Initialize |
---|
18 | * |
---|
19 | * This routine performs processor dependent initialization. |
---|
20 | * |
---|
21 | * INPUT PARAMETERS: |
---|
22 | * cpu_table - CPU table to initialize |
---|
23 | * thread_dispatch - entry pointer to thread dispatcher |
---|
24 | * |
---|
25 | * OUTPUT PARAMETERS: NONE |
---|
26 | */ |
---|
27 | |
---|
28 | void _CPU_Initialize( |
---|
29 | rtems_cpu_table *cpu_table, |
---|
30 | void (*thread_dispatch) /* ignored on this CPU */ |
---|
31 | ) |
---|
32 | { |
---|
33 | #if ( M68K_HAS_VBR == 0 ) |
---|
34 | /* fill the isr redirect table with the code to place the format/id |
---|
35 | onto the stack */ |
---|
36 | |
---|
37 | uint32_t slot; |
---|
38 | |
---|
39 | for (slot = 0; slot < CPU_INTERRUPT_NUMBER_OF_VECTORS; slot++) |
---|
40 | { |
---|
41 | _CPU_ISR_jump_table[slot].move_a7 = M68K_MOVE_A7; |
---|
42 | _CPU_ISR_jump_table[slot].format_id = slot << 2; |
---|
43 | _CPU_ISR_jump_table[slot].jmp = M68K_JMP; |
---|
44 | _CPU_ISR_jump_table[slot].isr_handler = (uint32_t ) 0xDEADDEAD; |
---|
45 | } |
---|
46 | #endif /* M68K_HAS_VBR */ |
---|
47 | } |
---|
48 | |
---|
49 | /*PAGE |
---|
50 | * |
---|
51 | * _CPU_ISR_Get_level |
---|
52 | */ |
---|
53 | |
---|
54 | uint32_t _CPU_ISR_Get_level( void ) |
---|
55 | { |
---|
56 | uint32_t level; |
---|
57 | |
---|
58 | m68k_get_interrupt_level( level ); |
---|
59 | |
---|
60 | return level; |
---|
61 | } |
---|
62 | |
---|
63 | /*PAGE |
---|
64 | * |
---|
65 | * _CPU_ISR_install_raw_handler |
---|
66 | */ |
---|
67 | |
---|
68 | void _CPU_ISR_install_raw_handler( |
---|
69 | uint32_t vector, |
---|
70 | proc_ptr new_handler, |
---|
71 | proc_ptr *old_handler |
---|
72 | ) |
---|
73 | { |
---|
74 | proc_ptr *interrupt_table = NULL; |
---|
75 | |
---|
76 | #if (M68K_HAS_FPSP_PACKAGE == 1) |
---|
77 | /* |
---|
78 | * If this vector being installed is one related to FP, then the |
---|
79 | * FPSP will install the handler itself and handle it completely |
---|
80 | * with no intervention from RTEMS. |
---|
81 | */ |
---|
82 | |
---|
83 | if (*_FPSP_install_raw_handler && |
---|
84 | (*_FPSP_install_raw_handler)(vector, new_handler, *old_handler)) |
---|
85 | return; |
---|
86 | #endif |
---|
87 | |
---|
88 | |
---|
89 | /* |
---|
90 | * On CPU models without a VBR, it is necessary for there to be some |
---|
91 | * header code for each ISR which saves a register, loads the vector |
---|
92 | * number, and jumps to _ISR_Handler. |
---|
93 | */ |
---|
94 | |
---|
95 | m68k_get_vbr( interrupt_table ); |
---|
96 | #if ( M68K_HAS_VBR == 1 ) |
---|
97 | *old_handler = interrupt_table[ vector ]; |
---|
98 | interrupt_table[ vector ] = new_handler; |
---|
99 | #else |
---|
100 | |
---|
101 | /* |
---|
102 | * Install handler into RTEMS jump table and if VBR table is in |
---|
103 | * RAM, install the pointer to the appropriate jump table slot. |
---|
104 | * If the VBR table is in ROM, it is the BSP's responsibility to |
---|
105 | * load it appropriately to vector to the RTEMS jump table. |
---|
106 | */ |
---|
107 | |
---|
108 | *old_handler = (proc_ptr) _CPU_ISR_jump_table[vector].isr_handler; |
---|
109 | _CPU_ISR_jump_table[vector].isr_handler = (uint32_t ) new_handler; |
---|
110 | if ( (uint32_t ) interrupt_table != 0xFFFFFFFF ) |
---|
111 | interrupt_table[ vector ] = (proc_ptr) &_CPU_ISR_jump_table[vector]; |
---|
112 | #endif /* M68K_HAS_VBR */ |
---|
113 | } |
---|
114 | |
---|
115 | /*PAGE |
---|
116 | * |
---|
117 | * _CPU_ISR_install_vector |
---|
118 | * |
---|
119 | * This kernel routine installs the RTEMS handler for the |
---|
120 | * specified vector. |
---|
121 | * |
---|
122 | * Input parameters: |
---|
123 | * vector - interrupt vector number |
---|
124 | * new_handler - replacement ISR for this vector number |
---|
125 | * old_handler - former ISR for this vector number |
---|
126 | * |
---|
127 | * Output parameters: NONE |
---|
128 | */ |
---|
129 | |
---|
130 | void _CPU_ISR_install_vector( |
---|
131 | uint32_t vector, |
---|
132 | proc_ptr new_handler, |
---|
133 | proc_ptr *old_handler |
---|
134 | ) |
---|
135 | { |
---|
136 | proc_ptr ignored = 0; /* to avoid warning */ |
---|
137 | |
---|
138 | *old_handler = _ISR_Vector_table[ vector ]; |
---|
139 | |
---|
140 | _CPU_ISR_install_raw_handler( vector, _ISR_Handler, &ignored ); |
---|
141 | |
---|
142 | _ISR_Vector_table[ vector ] = new_handler; |
---|
143 | } |
---|
144 | |
---|
145 | |
---|
146 | /*PAGE |
---|
147 | * |
---|
148 | * _CPU_Install_interrupt_stack |
---|
149 | */ |
---|
150 | |
---|
151 | void _CPU_Install_interrupt_stack( void ) |
---|
152 | { |
---|
153 | #if ( M68K_HAS_SEPARATE_STACKS == 1 ) |
---|
154 | void *isp = _CPU_Interrupt_stack_high; |
---|
155 | |
---|
156 | asm volatile ( "movec %0,%%isp" : "=r" (isp) : "0" (isp) ); |
---|
157 | #endif |
---|
158 | } |
---|
159 | |
---|
160 | #if ( M68K_HAS_BFFFO != 1 ) |
---|
161 | /* |
---|
162 | * Returns table for duplication of the BFFFO instruction (16 bits only) |
---|
163 | */ |
---|
164 | const unsigned char __BFFFOtable[256] = { |
---|
165 | 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, |
---|
166 | 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, |
---|
167 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
168 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
---|
169 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
---|
170 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
---|
171 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
---|
172 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
---|
173 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
---|
174 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
---|
175 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
---|
176 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
---|
177 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
---|
178 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
---|
179 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
---|
180 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
---|
181 | }; |
---|
182 | #endif |
---|
183 | |
---|
184 | /*PAGE |
---|
185 | * |
---|
186 | * The following code context switches the software FPU emulation |
---|
187 | * code provided with GCC. |
---|
188 | */ |
---|
189 | |
---|
190 | #if (CPU_SOFTWARE_FP == TRUE) |
---|
191 | extern Context_Control_fp _fpCCR; |
---|
192 | |
---|
193 | void CPU_Context_save_fp (Context_Control_fp **fp_context_ptr) |
---|
194 | { |
---|
195 | Context_Control_fp *fp; |
---|
196 | |
---|
197 | fp = *fp_context_ptr; |
---|
198 | |
---|
199 | *fp = _fpCCR; |
---|
200 | } |
---|
201 | |
---|
202 | void CPU_Context_restore_fp (Context_Control_fp **fp_context_ptr) |
---|
203 | { |
---|
204 | Context_Control_fp *fp; |
---|
205 | |
---|
206 | fp = *fp_context_ptr; |
---|
207 | |
---|
208 | _fpCCR = *fp; |
---|
209 | } |
---|
210 | #endif |
---|