source: rtems/cpukit/score/cpu/m68k/rtems/score/cpu.h @ 8b56aa3

4.104.114.84.95
Last change on this file since 8b56aa3 was 8b56aa3, checked in by Ralf Corsepius <ralf.corsepius@…>, on 05/09/07 at 15:28:52

2007-05-09 Ralf Corsépius <ralf.corsepius@…>

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