1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Motorola M68K CPU Dependent Source |
---|
5 | * |
---|
6 | * This include file contains information pertaining to the Motorola |
---|
7 | * m68xxx processor family. |
---|
8 | */ |
---|
9 | |
---|
10 | /* |
---|
11 | * COPYRIGHT (c) 1989-2011. |
---|
12 | * On-Line Applications Research Corporation (OAR). |
---|
13 | * |
---|
14 | * The license and distribution terms for this file may be |
---|
15 | * found in the file LICENSE in this distribution or at |
---|
16 | * http://www.rtems.org/license/LICENSE. |
---|
17 | */ |
---|
18 | |
---|
19 | #ifndef _RTEMS_SCORE_CPU_H |
---|
20 | #define _RTEMS_SCORE_CPU_H |
---|
21 | |
---|
22 | #ifdef __cplusplus |
---|
23 | extern "C" { |
---|
24 | #endif |
---|
25 | |
---|
26 | #include <rtems/score/basedefs.h> |
---|
27 | #include <rtems/score/m68k.h> |
---|
28 | |
---|
29 | /* conditional compilation parameters */ |
---|
30 | |
---|
31 | /* |
---|
32 | * Does the CPU follow the simple vectored interrupt model? |
---|
33 | * |
---|
34 | * If TRUE, then RTEMS allocates the vector table it internally manages. |
---|
35 | * If FALSE, then the BSP is assumed to allocate and manage the vector |
---|
36 | * table |
---|
37 | * |
---|
38 | * M68K Specific Information: |
---|
39 | * |
---|
40 | * XXX document implementation including references if appropriate |
---|
41 | */ |
---|
42 | #define CPU_SIMPLE_VECTORED_INTERRUPTS TRUE |
---|
43 | |
---|
44 | /* |
---|
45 | * Use the m68k's hardware interrupt stack support and have the |
---|
46 | * interrupt manager allocate the memory for it. |
---|
47 | */ |
---|
48 | |
---|
49 | #if ( M68K_HAS_SEPARATE_STACKS == 1) |
---|
50 | #define CPU_HAS_SOFTWARE_INTERRUPT_STACK 0 |
---|
51 | #define CPU_HAS_HARDWARE_INTERRUPT_STACK 1 |
---|
52 | #else |
---|
53 | #define CPU_HAS_SOFTWARE_INTERRUPT_STACK 1 |
---|
54 | #define CPU_HAS_HARDWARE_INTERRUPT_STACK 0 |
---|
55 | #endif |
---|
56 | #define CPU_ALLOCATE_INTERRUPT_STACK 1 |
---|
57 | |
---|
58 | /* |
---|
59 | * Does the RTEMS invoke the user's ISR with the vector number and |
---|
60 | * a pointer to the saved interrupt frame (1) or just the vector |
---|
61 | * number (0)? |
---|
62 | */ |
---|
63 | |
---|
64 | #define CPU_ISR_PASSES_FRAME_POINTER FALSE |
---|
65 | |
---|
66 | /* |
---|
67 | * Some family members have no FP, some have an FPU such as the |
---|
68 | * MC68881/MC68882 for the MC68020, others have it built in (MC68030, 040). |
---|
69 | * |
---|
70 | * NOTE: If on a CPU without hardware FP, then one can use software |
---|
71 | * emulation. The gcc software FP emulation code has data which |
---|
72 | * must be contexted switched on a per task basis. |
---|
73 | */ |
---|
74 | |
---|
75 | #if ( M68K_HAS_FPU == 1 ) || ( M68K_HAS_EMAC == 1 ) |
---|
76 | #define CPU_HARDWARE_FP TRUE |
---|
77 | #define CPU_SOFTWARE_FP FALSE |
---|
78 | #else |
---|
79 | #define CPU_HARDWARE_FP FALSE |
---|
80 | #if defined( __GNUC__ ) |
---|
81 | #define CPU_SOFTWARE_FP TRUE |
---|
82 | #else |
---|
83 | #define CPU_SOFTWARE_FP FALSE |
---|
84 | #endif |
---|
85 | #endif |
---|
86 | |
---|
87 | /* |
---|
88 | * All tasks are not by default floating point tasks on this CPU. |
---|
89 | * The IDLE task does not have a floating point context on this CPU. |
---|
90 | * It is safe to use the deferred floating point context switch |
---|
91 | * algorithm on this CPU. |
---|
92 | */ |
---|
93 | |
---|
94 | #define CPU_ALL_TASKS_ARE_FP FALSE |
---|
95 | #define CPU_IDLE_TASK_IS_FP FALSE |
---|
96 | #define CPU_USE_DEFERRED_FP_SWITCH TRUE |
---|
97 | #define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE |
---|
98 | |
---|
99 | #define CPU_PROVIDES_IDLE_THREAD_BODY TRUE |
---|
100 | #define CPU_STACK_GROWS_UP FALSE |
---|
101 | |
---|
102 | /* FIXME: Is this the right value? */ |
---|
103 | #define CPU_CACHE_LINE_BYTES 16 |
---|
104 | |
---|
105 | #define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES ) |
---|
106 | |
---|
107 | #define CPU_MAXIMUM_PROCESSORS 32 |
---|
108 | |
---|
109 | #if ( CPU_HARDWARE_FP == TRUE ) && !defined( __mcoldfire__ ) |
---|
110 | #if defined( __mc68060__ ) |
---|
111 | #define M68K_FP_STATE_SIZE 16 |
---|
112 | #else |
---|
113 | #define M68K_FP_STATE_SIZE 216 |
---|
114 | #endif |
---|
115 | #endif |
---|
116 | |
---|
117 | #ifndef ASM |
---|
118 | |
---|
119 | /* structures */ |
---|
120 | |
---|
121 | /* |
---|
122 | * Basic integer context for the m68k family. |
---|
123 | */ |
---|
124 | |
---|
125 | typedef struct { |
---|
126 | uint32_t sr; /* (sr) status register */ |
---|
127 | uint32_t d2; /* (d2) data register 2 */ |
---|
128 | uint32_t d3; /* (d3) data register 3 */ |
---|
129 | uint32_t d4; /* (d4) data register 4 */ |
---|
130 | uint32_t d5; /* (d5) data register 5 */ |
---|
131 | uint32_t d6; /* (d6) data register 6 */ |
---|
132 | uint32_t d7; /* (d7) data register 7 */ |
---|
133 | void *a2; /* (a2) address register 2 */ |
---|
134 | void *a3; /* (a3) address register 3 */ |
---|
135 | void *a4; /* (a4) address register 4 */ |
---|
136 | void *a5; /* (a5) address register 5 */ |
---|
137 | void *a6; /* (a6) address register 6 */ |
---|
138 | void *a7_msp; /* (a7) master stack pointer */ |
---|
139 | #if defined( __mcoldfire__ ) && ( M68K_HAS_FPU == 1 ) |
---|
140 | uint8_t fpu_dis; |
---|
141 | #endif |
---|
142 | } Context_Control; |
---|
143 | |
---|
144 | #define _CPU_Context_Get_SP( _context ) \ |
---|
145 | (_context)->a7_msp |
---|
146 | |
---|
147 | /* |
---|
148 | * Floating point context areas and support routines |
---|
149 | */ |
---|
150 | |
---|
151 | #if ( CPU_SOFTWARE_FP == TRUE ) |
---|
152 | /* |
---|
153 | * This is the same as gcc's view of the software FP condition code |
---|
154 | * register _fpCCR. The implementation of the emulation code is |
---|
155 | * in the gcc-VERSION/config/m68k directory. This structure is |
---|
156 | * correct as of gcc 2.7.2.2. |
---|
157 | */ |
---|
158 | typedef struct { |
---|
159 | uint16_t _exception_bits; |
---|
160 | uint16_t _trap_enable_bits; |
---|
161 | uint16_t _sticky_bits; |
---|
162 | uint16_t _rounding_mode; |
---|
163 | uint16_t _format; |
---|
164 | uint16_t _last_operation; |
---|
165 | union { |
---|
166 | float sf; |
---|
167 | double df; |
---|
168 | } _operand1; |
---|
169 | union { |
---|
170 | float sf; |
---|
171 | double df; |
---|
172 | } _operand2; |
---|
173 | } Context_Control_fp; |
---|
174 | |
---|
175 | #define _CPU_Context_Initialize_fp( _fp_area ) \ |
---|
176 | { \ |
---|
177 | Context_Control_fp *_fp; \ |
---|
178 | _fp = *(Context_Control_fp **)_fp_area; \ |
---|
179 | _fp->_exception_bits = 0; \ |
---|
180 | _fp->_trap_enable_bits = 0; \ |
---|
181 | _fp->_sticky_bits = 0; \ |
---|
182 | _fp->_rounding_mode = 0; /* ROUND_TO_NEAREST */ \ |
---|
183 | _fp->_format = 0; /* NIL */ \ |
---|
184 | _fp->_last_operation = 0; /* NOOP */ \ |
---|
185 | _fp->_operand1.df = 0; \ |
---|
186 | _fp->_operand2.df = 0; \ |
---|
187 | } |
---|
188 | #endif |
---|
189 | |
---|
190 | #if ( CPU_HARDWARE_FP == TRUE ) |
---|
191 | #if defined( __mcoldfire__ ) |
---|
192 | /* We need memset() to initialize the FP context */ |
---|
193 | #include <string.h> |
---|
194 | |
---|
195 | #if ( M68K_HAS_FPU == 1 ) |
---|
196 | /* |
---|
197 | * The Cache Control Register (CACR) has write-only access. It is also |
---|
198 | * used to enable and disable the FPU. We need to maintain a copy of |
---|
199 | * this register to allow per thread values. |
---|
200 | */ |
---|
201 | extern uint32_t _CPU_cacr_shadow; |
---|
202 | #endif |
---|
203 | |
---|
204 | /* We assume that each ColdFire core with a FPU has also an EMAC unit */ |
---|
205 | typedef struct { |
---|
206 | uint32_t emac_macsr; |
---|
207 | uint32_t emac_acc0; |
---|
208 | uint32_t emac_acc1; |
---|
209 | uint32_t emac_acc2; |
---|
210 | uint32_t emac_acc3; |
---|
211 | uint32_t emac_accext01; |
---|
212 | uint32_t emac_accext23; |
---|
213 | uint32_t emac_mask; |
---|
214 | #if ( M68K_HAS_FPU == 1 ) |
---|
215 | uint16_t fp_state_format; |
---|
216 | uint16_t fp_state_fpcr; |
---|
217 | double fp_state_op; |
---|
218 | uint32_t fp_state_fpsr; |
---|
219 | |
---|
220 | /* |
---|
221 | * We need to save the FP Instruction Address Register (FPIAR), because |
---|
222 | * a context switch can occur within a FP exception before the handler |
---|
223 | * was able to save this register. |
---|
224 | */ |
---|
225 | uint32_t fp_fpiar; |
---|
226 | |
---|
227 | double fp_data [8]; |
---|
228 | #endif |
---|
229 | } Context_Control_fp; |
---|
230 | |
---|
231 | /* |
---|
232 | * The reset value for all context relevant registers except the FP data |
---|
233 | * registers is zero. The reset value of the FP data register is NAN. The |
---|
234 | * restore of the reset FP state will reset the FP data registers, so the |
---|
235 | * initial value of them can be arbitrary here. |
---|
236 | */ |
---|
237 | #define _CPU_Context_Initialize_fp( _fp_area ) \ |
---|
238 | memset( *(_fp_area), 0, sizeof( Context_Control_fp ) ) |
---|
239 | #else |
---|
240 | /* |
---|
241 | * FP context save area for the M68881/M68882 and 68060 numeric |
---|
242 | * coprocessors. |
---|
243 | */ |
---|
244 | typedef struct { |
---|
245 | /* |
---|
246 | * M68K_FP_STATE_SIZE bytes for FSAVE/FRESTORE |
---|
247 | * 96 bytes for FMOVEM FP0-7 |
---|
248 | * 12 bytes for FMOVEM CREGS |
---|
249 | * 4 bytes for non-null flag |
---|
250 | */ |
---|
251 | uint8_t fp_save_area [M68K_FP_STATE_SIZE + 112]; |
---|
252 | } Context_Control_fp; |
---|
253 | |
---|
254 | /* |
---|
255 | * The floating-point context is saved/restored via FSAVE/FRESTORE which |
---|
256 | * use a growing down stack. Initialize the stack and adjust the FP area |
---|
257 | * pointer accordingly. |
---|
258 | */ |
---|
259 | #define _CPU_Context_Initialize_fp( _fp_area ) \ |
---|
260 | { \ |
---|
261 | uint32_t *_fp_context = _Addresses_Add_offset( \ |
---|
262 | *(_fp_area), CPU_CONTEXT_FP_SIZE - 4); \ |
---|
263 | *(--(_fp_context)) = 0; \ |
---|
264 | *(_fp_area) = (void *)(_fp_context); \ |
---|
265 | } |
---|
266 | #endif |
---|
267 | #endif |
---|
268 | |
---|
269 | /* |
---|
270 | * The following structures define the set of information saved |
---|
271 | * on the current stack by RTEMS upon receipt of each exc/interrupt. |
---|
272 | * These are not used by m68k handlers. |
---|
273 | * The exception frame is for rdbg. |
---|
274 | */ |
---|
275 | |
---|
276 | typedef struct { |
---|
277 | uint32_t vecnum; /* vector number */ |
---|
278 | } CPU_Interrupt_frame; |
---|
279 | |
---|
280 | typedef struct { |
---|
281 | uint32_t vecnum; /* vector number */ |
---|
282 | uint32_t sr; /* status register */ |
---|
283 | uint32_t pc; /* program counter */ |
---|
284 | uint32_t d0, d1, d2, d3, d4, d5, d6, d7; |
---|
285 | uint32_t a0, a1, a2, a3, a4, a5, a6, a7; |
---|
286 | } CPU_Exception_frame; |
---|
287 | |
---|
288 | /* variables */ |
---|
289 | |
---|
290 | extern void* _VBR; |
---|
291 | |
---|
292 | #endif /* ASM */ |
---|
293 | |
---|
294 | /* constants */ |
---|
295 | |
---|
296 | /* |
---|
297 | * This defines the number of levels and the mask used to pick those |
---|
298 | * bits out of a thread mode. |
---|
299 | */ |
---|
300 | |
---|
301 | #define CPU_MODES_INTERRUPT_MASK 0x00000007 /* interrupt level in mode */ |
---|
302 | |
---|
303 | /* |
---|
304 | * context size area for floating point |
---|
305 | */ |
---|
306 | |
---|
307 | #define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp ) |
---|
308 | |
---|
309 | /* |
---|
310 | * extra stack required by the MPCI receive server thread |
---|
311 | */ |
---|
312 | |
---|
313 | #define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 1024 |
---|
314 | |
---|
315 | /* |
---|
316 | * m68k family supports 256 distinct vectors. |
---|
317 | */ |
---|
318 | |
---|
319 | #define CPU_INTERRUPT_NUMBER_OF_VECTORS 256 |
---|
320 | #define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER (CPU_INTERRUPT_NUMBER_OF_VECTORS - 1) |
---|
321 | |
---|
322 | /* |
---|
323 | * This is defined if the port has a special way to report the ISR nesting |
---|
324 | * level. Most ports maintain the variable _ISR_Nest_level. |
---|
325 | */ |
---|
326 | |
---|
327 | #define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE |
---|
328 | |
---|
329 | /* |
---|
330 | * Minimum size of a thread's stack. |
---|
331 | */ |
---|
332 | |
---|
333 | #define CPU_STACK_MINIMUM_SIZE M68K_CPU_STACK_MINIMUM_SIZE |
---|
334 | |
---|
335 | /* |
---|
336 | * Maximum priority of a thread. Note based from 0 which is the idle task. |
---|
337 | */ |
---|
338 | #define CPU_PRIORITY_MAXIMUM M68K_CPU_PRIORITY_MAXIMUM |
---|
339 | |
---|
340 | #define CPU_SIZEOF_POINTER 4 |
---|
341 | |
---|
342 | /* |
---|
343 | * m68k is pretty tolerant of alignment. Just put things on 4 byte boundaries. |
---|
344 | */ |
---|
345 | |
---|
346 | #define CPU_ALIGNMENT 4 |
---|
347 | #define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT |
---|
348 | #define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT |
---|
349 | |
---|
350 | /* |
---|
351 | * On m68k thread stacks require no further alignment after allocation |
---|
352 | * from the Workspace. |
---|
353 | */ |
---|
354 | |
---|
355 | #define CPU_STACK_ALIGNMENT 0 |
---|
356 | |
---|
357 | #define CPU_INTERRUPT_STACK_ALIGNMENT CPU_CACHE_LINE_BYTES |
---|
358 | |
---|
359 | #ifndef ASM |
---|
360 | |
---|
361 | /* macros */ |
---|
362 | |
---|
363 | /* |
---|
364 | * ISR handler macros |
---|
365 | * |
---|
366 | * These macros perform the following functions: |
---|
367 | * + initialize the RTEMS vector table |
---|
368 | * + disable all maskable CPU interrupts |
---|
369 | * + restore previous interrupt level (enable) |
---|
370 | * + temporarily restore interrupts (flash) |
---|
371 | * + set a particular level |
---|
372 | */ |
---|
373 | |
---|
374 | #define _CPU_Initialize_vectors() |
---|
375 | |
---|
376 | #define _CPU_ISR_Disable( _level ) \ |
---|
377 | m68k_disable_interrupts( _level ) |
---|
378 | |
---|
379 | #define _CPU_ISR_Enable( _level ) \ |
---|
380 | m68k_enable_interrupts( _level ) |
---|
381 | |
---|
382 | #define _CPU_ISR_Flash( _level ) \ |
---|
383 | m68k_flash_interrupts( _level ) |
---|
384 | |
---|
385 | RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) |
---|
386 | { |
---|
387 | return ( level & 0x0700 ) == 0; |
---|
388 | } |
---|
389 | |
---|
390 | #define _CPU_ISR_Set_level( _newlevel ) \ |
---|
391 | m68k_set_interrupt_level( _newlevel ) |
---|
392 | |
---|
393 | uint32_t _CPU_ISR_Get_level( void ); |
---|
394 | |
---|
395 | /* end of ISR handler macros */ |
---|
396 | |
---|
397 | /* |
---|
398 | * Context handler macros |
---|
399 | * |
---|
400 | * These macros perform the following functions: |
---|
401 | * + initialize a context area |
---|
402 | * + restart the current thread |
---|
403 | * + calculate the initial pointer into a FP context area |
---|
404 | * + initialize an FP context area |
---|
405 | */ |
---|
406 | |
---|
407 | void _CPU_Context_Initialize( |
---|
408 | Context_Control *the_context, |
---|
409 | void *stack_area_begin, |
---|
410 | size_t stack_area_size, |
---|
411 | uint32_t new_level, |
---|
412 | void (*entry_point)( void ), |
---|
413 | bool is_fp, |
---|
414 | void *tls_area |
---|
415 | ); |
---|
416 | |
---|
417 | /* end of Context handler macros */ |
---|
418 | |
---|
419 | /* |
---|
420 | * _CPU_Thread_Idle_body |
---|
421 | * |
---|
422 | * This routine is the CPU dependent IDLE thread body. |
---|
423 | * |
---|
424 | * NOTE: It need only be provided if CPU_PROVIDES_IDLE_THREAD_BODY |
---|
425 | * is TRUE. |
---|
426 | */ |
---|
427 | |
---|
428 | void *_CPU_Thread_Idle_body( uintptr_t ignored ); |
---|
429 | |
---|
430 | /* |
---|
431 | * Fatal Error manager macros |
---|
432 | * |
---|
433 | * These macros perform the following functions: |
---|
434 | * + disable interrupts and halt the CPU |
---|
435 | */ |
---|
436 | |
---|
437 | #if ( defined(__mcoldfire__) ) |
---|
438 | #define _CPU_Fatal_halt( _source, _error ) \ |
---|
439 | { __asm__ volatile( "move.w %%sr,%%d0\n\t" \ |
---|
440 | "or.l %2,%%d0\n\t" \ |
---|
441 | "move.w %%d0,%%sr\n\t" \ |
---|
442 | "move.l %1,%%d0\n\t" \ |
---|
443 | "move.l #0xDEADBEEF,%%d1\n\t" \ |
---|
444 | "halt" \ |
---|
445 | : "=g" (_error) \ |
---|
446 | : "0" (_error), "d"(0x0700) \ |
---|
447 | : "d0", "d1" ); \ |
---|
448 | } |
---|
449 | #else |
---|
450 | #define _CPU_Fatal_halt( _source, _error ) \ |
---|
451 | { __asm__ volatile( "movl %0,%%d0; " \ |
---|
452 | "orw #0x0700,%%sr; " \ |
---|
453 | "stop #0x2700" : "=d" ((_error)) : "0" ((_error)) ); \ |
---|
454 | } |
---|
455 | #endif |
---|
456 | |
---|
457 | /* end of Fatal Error manager macros */ |
---|
458 | |
---|
459 | /* |
---|
460 | * Bitfield handler macros |
---|
461 | * |
---|
462 | * These macros perform the following functions: |
---|
463 | * + scan for the highest numbered (MSB) set in a 16 bit bitfield |
---|
464 | * |
---|
465 | * NOTE: |
---|
466 | * |
---|
467 | * It appears that on the M68020 bitfield are always 32 bits wide |
---|
468 | * when in a register. This code forces the bitfield to be in |
---|
469 | * memory (it really always is anyway). This allows us to |
---|
470 | * have a real 16 bit wide bitfield which operates "correctly." |
---|
471 | */ |
---|
472 | |
---|
473 | #define CPU_USE_GENERIC_BITFIELD_CODE FALSE |
---|
474 | |
---|
475 | #if ( M68K_HAS_BFFFO != 1 ) |
---|
476 | /* |
---|
477 | * Lookup table for BFFFO simulation |
---|
478 | */ |
---|
479 | extern const unsigned char _CPU_m68k_BFFFO_table[256]; |
---|
480 | #endif |
---|
481 | |
---|
482 | #if ( M68K_HAS_BFFFO == 1 ) |
---|
483 | |
---|
484 | #define _CPU_Bitfield_Find_first_bit( _value, _output ) \ |
---|
485 | __asm__ volatile( "bfffo (%1),#0,#16,%0" : "=d" (_output) : "a" (&_value)); |
---|
486 | |
---|
487 | #elif ( __mcfisaaplus__ ) |
---|
488 | /* This is simplified by the fact that RTEMS never calls it with _value=0 */ |
---|
489 | #define _CPU_Bitfield_Find_first_bit( _value, _output ) \ |
---|
490 | __asm__ volatile ( \ |
---|
491 | " swap %0\n" \ |
---|
492 | " ff1.l %0\n" \ |
---|
493 | : "=d" ((_output)) \ |
---|
494 | : "0" ((_value)) \ |
---|
495 | : "cc" ) ; |
---|
496 | |
---|
497 | #else |
---|
498 | /* duplicates BFFFO results for 16 bits (i.e., 15-(_priority) in |
---|
499 | _CPU_Priority_bits_index is not needed), handles the 0 case, and |
---|
500 | does not molest _value -- jsg */ |
---|
501 | #if ( defined(__mcoldfire__) ) |
---|
502 | |
---|
503 | #define _CPU_Bitfield_Find_first_bit( _value, _output ) \ |
---|
504 | { \ |
---|
505 | int dumby; \ |
---|
506 | \ |
---|
507 | __asm__ volatile ( \ |
---|
508 | " clr.l %1\n" \ |
---|
509 | " move.w %2,%1\n" \ |
---|
510 | " lsr.l #8,%1\n" \ |
---|
511 | " beq.s 1f\n" \ |
---|
512 | " move.b (%3,%1),%0\n" \ |
---|
513 | " bra.s 0f\n" \ |
---|
514 | "1: move.w %2,%1\n" \ |
---|
515 | " move.b (%3,%1),%0\n" \ |
---|
516 | " addq.l #8,%0\n" \ |
---|
517 | "0: and.l #0xff,%0\n" \ |
---|
518 | : "=&d" ((_output)), "=&d" ((dumby)) \ |
---|
519 | : "d" ((_value)), "ao" ((_CPU_m68k_BFFFO_table)) \ |
---|
520 | : "cc" ) ; \ |
---|
521 | } |
---|
522 | #elif ( M68K_HAS_EXTB_L == 1 ) |
---|
523 | #define _CPU_Bitfield_Find_first_bit( _value, _output ) \ |
---|
524 | { \ |
---|
525 | int dumby; \ |
---|
526 | \ |
---|
527 | __asm__ volatile ( " move.w %2,%1\n" \ |
---|
528 | " lsr.w #8,%1\n" \ |
---|
529 | " beq.s 1f\n" \ |
---|
530 | " move.b (%3,%1.w),%0\n" \ |
---|
531 | " extb.l %0\n" \ |
---|
532 | " bra.s 0f\n" \ |
---|
533 | "1: moveq.l #8,%0\n" \ |
---|
534 | " add.b (%3,%2.w),%0\n" \ |
---|
535 | "0:\n" \ |
---|
536 | : "=&d" ((_output)), "=&d" ((dumby)) \ |
---|
537 | : "d" ((_value)), "ao" ((_CPU_m68k_BFFFO_table)) \ |
---|
538 | : "cc" ) ; \ |
---|
539 | } |
---|
540 | #else |
---|
541 | #define _CPU_Bitfield_Find_first_bit( _value, _output ) \ |
---|
542 | { \ |
---|
543 | int dumby; \ |
---|
544 | \ |
---|
545 | __asm__ volatile ( " move.w %2,%1\n" \ |
---|
546 | " lsr.w #8,%1\n" \ |
---|
547 | " beq.s 1f\n" \ |
---|
548 | " move.b (%3,%1.w),%0\n" \ |
---|
549 | " and.l #0x000000ff,%0\n"\ |
---|
550 | " bra.s 0f\n" \ |
---|
551 | "1: moveq.l #8,%0\n" \ |
---|
552 | " add.b (%3,%2.w),%0\n" \ |
---|
553 | "0:\n" \ |
---|
554 | : "=&d" ((_output)), "=&d" ((dumby)) \ |
---|
555 | : "d" ((_value)), "ao" ((_CPU_m68k_BFFFO_table)) \ |
---|
556 | : "cc" ) ; \ |
---|
557 | } |
---|
558 | #endif |
---|
559 | |
---|
560 | #endif |
---|
561 | |
---|
562 | /* end of Bitfield handler macros */ |
---|
563 | |
---|
564 | /* |
---|
565 | * Priority handler macros |
---|
566 | * |
---|
567 | * These macros perform the following functions: |
---|
568 | * + return a mask with the bit for this major/minor portion of |
---|
569 | * of thread priority set. |
---|
570 | * + translate the bit number returned by "Bitfield_find_first_bit" |
---|
571 | * into an index into the thread ready chain bit maps |
---|
572 | */ |
---|
573 | |
---|
574 | #define _CPU_Priority_Mask( _bit_number ) \ |
---|
575 | ( 0x8000 >> (_bit_number) ) |
---|
576 | |
---|
577 | #define _CPU_Priority_bits_index( _priority ) \ |
---|
578 | (_priority) |
---|
579 | |
---|
580 | /* end of Priority handler macros */ |
---|
581 | |
---|
582 | /* functions */ |
---|
583 | |
---|
584 | /* |
---|
585 | * _CPU_Initialize |
---|
586 | * |
---|
587 | * This routine performs CPU dependent initialization. |
---|
588 | */ |
---|
589 | |
---|
590 | void _CPU_Initialize(void); |
---|
591 | |
---|
592 | /* |
---|
593 | * _CPU_ISR_install_raw_handler |
---|
594 | * |
---|
595 | * This routine installs a "raw" interrupt handler directly into the |
---|
596 | * processor's vector table. |
---|
597 | */ |
---|
598 | |
---|
599 | void _CPU_ISR_install_raw_handler( |
---|
600 | uint32_t vector, |
---|
601 | proc_ptr new_handler, |
---|
602 | proc_ptr *old_handler |
---|
603 | ); |
---|
604 | |
---|
605 | /* |
---|
606 | * _CPU_ISR_install_vector |
---|
607 | * |
---|
608 | * This routine installs an interrupt vector. |
---|
609 | */ |
---|
610 | |
---|
611 | void _CPU_ISR_install_vector( |
---|
612 | uint32_t vector, |
---|
613 | proc_ptr new_handler, |
---|
614 | proc_ptr *old_handler |
---|
615 | ); |
---|
616 | |
---|
617 | /* |
---|
618 | * _CPU_Install_interrupt_stack |
---|
619 | * |
---|
620 | * This routine installs the hardware interrupt stack pointer. |
---|
621 | */ |
---|
622 | |
---|
623 | void _CPU_Install_interrupt_stack( void ); |
---|
624 | |
---|
625 | /* |
---|
626 | * _CPU_Context_switch |
---|
627 | * |
---|
628 | * This routine switches from the run context to the heir context. |
---|
629 | */ |
---|
630 | |
---|
631 | void _CPU_Context_switch( |
---|
632 | Context_Control *run, |
---|
633 | Context_Control *heir |
---|
634 | ); |
---|
635 | |
---|
636 | void _CPU_Context_Restart_self( |
---|
637 | Context_Control *the_context |
---|
638 | ) RTEMS_NO_RETURN; |
---|
639 | |
---|
640 | /* |
---|
641 | * _CPU_Context_save_fp |
---|
642 | * |
---|
643 | * This routine saves the floating point context passed to it. |
---|
644 | */ |
---|
645 | |
---|
646 | void _CPU_Context_save_fp( |
---|
647 | Context_Control_fp **fp_context_ptr |
---|
648 | ); |
---|
649 | |
---|
650 | /* |
---|
651 | * _CPU_Context_restore_fp |
---|
652 | * |
---|
653 | * This routine restores the floating point context passed to it. |
---|
654 | */ |
---|
655 | |
---|
656 | void _CPU_Context_restore_fp( |
---|
657 | Context_Control_fp **fp_context_ptr |
---|
658 | ); |
---|
659 | |
---|
660 | static inline void _CPU_Context_volatile_clobber( uintptr_t pattern ) |
---|
661 | { |
---|
662 | /* TODO */ |
---|
663 | } |
---|
664 | |
---|
665 | static inline void _CPU_Context_validate( uintptr_t pattern ) |
---|
666 | { |
---|
667 | while (1) { |
---|
668 | /* TODO */ |
---|
669 | } |
---|
670 | } |
---|
671 | |
---|
672 | /** |
---|
673 | * This method prints the CPU exception frame. |
---|
674 | * |
---|
675 | * @param[in] frame points to the frame to be printed |
---|
676 | */ |
---|
677 | void _CPU_Exception_frame_print( |
---|
678 | const CPU_Exception_frame *frame |
---|
679 | ); |
---|
680 | |
---|
681 | typedef uint32_t CPU_Counter_ticks; |
---|
682 | |
---|
683 | uint32_t _CPU_Counter_frequency( void ); |
---|
684 | |
---|
685 | CPU_Counter_ticks _CPU_Counter_read( void ); |
---|
686 | |
---|
687 | static inline CPU_Counter_ticks _CPU_Counter_difference( |
---|
688 | CPU_Counter_ticks second, |
---|
689 | CPU_Counter_ticks first |
---|
690 | ) |
---|
691 | { |
---|
692 | return second - first; |
---|
693 | } |
---|
694 | |
---|
695 | #if (M68K_HAS_FPSP_PACKAGE == 1) |
---|
696 | /* |
---|
697 | * Hooks for the Floating Point Support Package (FPSP) provided by Motorola |
---|
698 | * |
---|
699 | * NOTES: |
---|
700 | * |
---|
701 | * Motorola 68k family CPU's before the 68040 used a coprocessor |
---|
702 | * (68881 or 68882) to handle floating point. The 68040 has internal |
---|
703 | * floating point support -- but *not* the complete support provided by |
---|
704 | * the 68881 or 68882. The leftover functions are taken care of by the |
---|
705 | * M68040 Floating Point Support Package. Quoting from the MC68040 |
---|
706 | * Microprocessors User's Manual, Section 9, Floating-Point Unit (MC68040): |
---|
707 | * |
---|
708 | * "When used with the M68040FPSP, the MC68040 FPU is fully |
---|
709 | * compliant with IEEE floating-point standards." |
---|
710 | * |
---|
711 | * M68KFPSPInstallExceptionHandlers is in libcpu/m68k/MODEL/fpsp and |
---|
712 | * is invoked early in the application code to ensure that proper FP |
---|
713 | * behavior is installed. This is not left to the BSP to call, since |
---|
714 | * this would force all applications using that BSP to use FPSP which |
---|
715 | * is not necessarily desirable. |
---|
716 | * |
---|
717 | * There is a similar package for the 68060 but RTEMS does not yet |
---|
718 | * support the 68060. |
---|
719 | */ |
---|
720 | |
---|
721 | void M68KFPSPInstallExceptionHandlers (void); |
---|
722 | |
---|
723 | extern int (*_FPSP_install_raw_handler)( |
---|
724 | uint32_t vector, |
---|
725 | proc_ptr new_handler, |
---|
726 | proc_ptr *old_handler |
---|
727 | ); |
---|
728 | |
---|
729 | #endif |
---|
730 | |
---|
731 | /** Type that can store a 32-bit integer or a pointer. */ |
---|
732 | typedef uintptr_t CPU_Uint32ptr; |
---|
733 | |
---|
734 | #endif |
---|
735 | |
---|
736 | #ifdef __cplusplus |
---|
737 | } |
---|
738 | #endif |
---|
739 | |
---|
740 | #endif |
---|