source: rtems/c/src/exec/score/cpu/m68k/cpu.h @ 702a31c

4.104.114.84.95
Last change on this file since 702a31c was 702a31c, checked in by Joel Sherrill <joel.sherrill@…>, on 08/12/96 at 20:08:36

removed comment about NO_UNINITIALIZED_WARNINGS since that macro
no longer exists.

  • Property mode set to 100644
File size: 11.9 KB
Line 
1/*  cpu.h
2 *
3 *  This include file contains information pertaining to the Motorola
4 *  m68xxx processor family.
5 *
6 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
7 *  On-Line Applications Research Corporation (OAR).
8 *  All rights assigned to U.S. Government, 1994.
9 *
10 *  This material may be reproduced by or for the U.S. Government pursuant
11 *  to the copyright license under the clause at DFARS 252.227-7013.  This
12 *  notice must appear in all copies of this file and its derivatives.
13 *
14 *  $Id$
15 */
16
17#ifndef __CPU_h
18#define __CPU_h
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24#include <rtems/score/m68k.h>
25#ifndef ASM
26#include <rtems/score/m68ktypes.h>
27#endif
28
29/* conditional compilation parameters */
30
31#define CPU_INLINE_ENABLE_DISPATCH       TRUE
32#define CPU_UNROLL_ENQUEUE_PRIORITY      FALSE
33
34/*
35 *  Use the m68k's hardware interrupt stack support and have the
36 *  interrupt manager allocate the memory for it.
37 *
38 *  NOTE:  The definitions when M68K_HAS_SEPARATE_STACKS is 0 should
39 *         change when the software interrupt stack support is implemented.
40 */
41
42#if ( M68K_HAS_SEPARATE_STACKS == 1)
43#define CPU_HAS_SOFTWARE_INTERRUPT_STACK FALSE
44#define CPU_HAS_HARDWARE_INTERRUPT_STACK TRUE
45#define CPU_ALLOCATE_INTERRUPT_STACK     TRUE
46#else
47#define CPU_HAS_SOFTWARE_INTERRUPT_STACK FALSE
48#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE
49#define CPU_ALLOCATE_INTERRUPT_STACK     FALSE
50#endif
51
52/*
53 *  Some family members have no FP, some have an FPU such as the
54 *  MC68881/MC68882 for the MC68020, others have it built in (MC68030, 040).
55 */
56
57#if ( M68K_HAS_FPU == 1 )
58#define CPU_HARDWARE_FP     TRUE
59#else
60#define CPU_HARDWARE_FP     FALSE
61#endif
62
63/*
64 *  All tasks are not by default floating point tasks on this CPU.
65 *  The IDLE task does not have a floating point context on this CPU.
66 *  It is safe to use the deferred floating point context switch
67 *  algorithm on this CPU.
68 */
69
70#define CPU_ALL_TASKS_ARE_FP             FALSE
71#define CPU_IDLE_TASK_IS_FP              FALSE
72#define CPU_USE_DEFERRED_FP_SWITCH       TRUE
73
74#define CPU_PROVIDES_IDLE_THREAD_BODY    FALSE
75#define CPU_STACK_GROWS_UP               FALSE
76#define CPU_STRUCTURE_ALIGNMENT
77
78/* structures */
79
80/*
81 *  Basic integer context for the m68k family.
82 */
83
84typedef struct {
85  unsigned32  sr;                /* (sr) status register */
86  unsigned32  d2;                /* (d2) data register 2 */
87  unsigned32  d3;                /* (d3) data register 3 */
88  unsigned32  d4;                /* (d4) data register 4 */
89  unsigned32  d5;                /* (d5) data register 5 */
90  unsigned32  d6;                /* (d6) data register 6 */
91  unsigned32  d7;                /* (d7) data register 7 */
92  void       *a2;                /* (a2) address register 2 */
93  void       *a3;                /* (a3) address register 3 */
94  void       *a4;                /* (a4) address register 4 */
95  void       *a5;                /* (a5) address register 5 */
96  void       *a6;                /* (a6) address register 6 */
97  void       *a7_msp;            /* (a7) master stack pointer */
98}   Context_Control;
99
100/*
101 *  FP context save area for the M68881/M68882 numeric coprocessors.
102 */
103
104typedef struct {
105  unsigned8   fp_save_area[332];    /*   216 bytes for FSAVE/FRESTORE    */
106                                    /*    96 bytes for FMOVEM FP0-7      */
107                                    /*    12 bytes for FMOVEM CREGS      */
108                                    /*     4 bytes for non-null flag     */
109} Context_Control_fp;
110
111/*
112 *  The following structure defines the set of information saved
113 *  on the current stack by RTEMS upon receipt of each interrupt.
114 */
115
116typedef struct {
117  unsigned32   TBD;   /* XXX Fix for this CPU */
118} CPU_Interrupt_frame;
119
120/*
121 *  The following table contains the information required to configure
122 *  the m68k specific parameters.
123 */
124
125typedef struct {
126  void       (*pretasking_hook)( void );
127  void       (*predriver_hook)( void );
128  void       (*postdriver_hook)( void );
129  void       (*idle_task)( void );
130  boolean      do_zero_of_workspace;
131  unsigned32   interrupt_stack_size;
132  unsigned32   extra_mpci_receive_server_stack;
133  void *     (*stack_allocate_hook)( unsigned32 );
134  void       (*stack_free_hook)( void* );
135  /* end of fields required on all CPUs */
136
137  m68k_isr    *interrupt_vector_table;
138}   rtems_cpu_table;
139
140/* variables */
141
142SCORE_EXTERN void               *_CPU_Interrupt_stack_low;
143SCORE_EXTERN void               *_CPU_Interrupt_stack_high;
144      /* points to jsr-exception-table in targets wo/ VBR register */
145extern char                      _VBR[];
146
147/* constants */
148
149/*
150 *  This defines the number of levels and the mask used to pick those
151 *  bits out of a thread mode.
152 */
153
154#define CPU_MODES_INTERRUPT_LEVEL  0x00000007 /* interrupt level in mode */
155#define CPU_MODES_INTERRUPT_MASK   0x00000007 /* interrupt level in mode */
156
157/*
158 *  context size area for floating point
159 */
160
161#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp )
162
163/*
164 *  extra stack required by the MPCI receive server thread
165 */
166
167#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 1024
168
169/*
170 *  m68k family supports 256 distinct vectors.
171 */
172
173#define CPU_INTERRUPT_NUMBER_OF_VECTORS      256
174#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER  (CPU_INTERRUPT_NUMBER_OF_VECTORS - 1)
175
176/*
177 *  Minimum size of a thread's stack.
178 */
179
180#define CPU_STACK_MINIMUM_SIZE           2048
181
182/*
183 *  m68k is pretty tolerant of alignment.  Just put things on 4 byte boundaries.
184 */
185
186#define CPU_ALIGNMENT                    4
187#define CPU_HEAP_ALIGNMENT               CPU_ALIGNMENT
188#define CPU_PARTITION_ALIGNMENT          CPU_ALIGNMENT
189
190/*
191 *  On m68k thread stacks require no further alignment after allocation
192 *  from the Workspace.
193 */
194
195#define CPU_STACK_ALIGNMENT        0
196
197/* macros */
198
199/*
200 *  ISR handler macros
201 *
202 *  These macros perform the following functions:
203 *     + disable all maskable CPU interrupts
204 *     + restore previous interrupt level (enable)
205 *     + temporarily restore interrupts (flash)
206 *     + set a particular level
207 */
208
209#define _CPU_ISR_Disable( _level ) \
210  m68k_disable_interrupts( _level )
211
212#define _CPU_ISR_Enable( _level ) \
213  m68k_enable_interrupts( _level )
214
215#define _CPU_ISR_Flash( _level ) \
216  m68k_flash_interrupts( _level )
217
218#define _CPU_ISR_Set_level( _newlevel ) \
219   m68k_set_interrupt_level( _newlevel )
220
221unsigned32 _CPU_ISR_Get_level( void );
222
223/* end of ISR handler macros */
224
225/*
226 *  Context handler macros
227 *
228 *  These macros perform the following functions:
229 *     + initialize a context area
230 *     + restart the current thread
231 *     + calculate the initial pointer into a FP context area
232 *     + initialize an FP context area
233 */
234
235#define _CPU_Context_Initialize( _the_context, _stack_base, _size, \
236                                 _isr, _entry_point, _is_fp ) \
237   do { \
238     void   *_stack; \
239     \
240     (_the_context)->sr      = 0x3000 | ((_isr) << 8); \
241     _stack                  = (void *)(_stack_base) + (_size) - 4; \
242     (_the_context)->a7_msp  = _stack; \
243     *(void **)_stack = (_entry_point); \
244   } while ( 0 )
245
246#define _CPU_Context_Restart_self( _the_context ) \
247  { asm volatile( "movew %0,%%sr ; " \
248                  "moval %1,%%a7 ; " \
249                  "rts"  \
250        : "=d" ((_the_context)->sr), "=d" ((_the_context)->a7_msp) \
251        : "0" ((_the_context)->sr), "1" ((_the_context)->a7_msp) ); \
252  }
253
254#define _CPU_Context_Fp_start( _base, _offset ) \
255   ((void *) \
256     _Addresses_Add_offset( \
257        (_base), \
258        (_offset) + CPU_CONTEXT_FP_SIZE - 4 \
259     ) \
260   )
261
262#define _CPU_Context_Initialize_fp( _fp_area ) \
263   { unsigned32 *_fp_context = (unsigned32 *)*(_fp_area); \
264     \
265     *(--(_fp_context)) = 0; \
266     *(_fp_area) = (unsigned8 *)(_fp_context); \
267   }
268
269/* end of Context handler macros */
270
271/*
272 *  Fatal Error manager macros
273 *
274 *  These macros perform the following functions:
275 *    + disable interrupts and halt the CPU
276 */
277
278#define _CPU_Fatal_halt( _error ) \
279  { asm volatile( "movl  %0,%%d0; " \
280                  "orw   #0x0700,%%sr; " \
281                  "stop  #0x2700" : "=d" ((_error)) : "0" ((_error)) ); \
282  }
283
284/* end of Fatal Error manager macros */
285
286/*
287 *  Bitfield handler macros
288 *
289 *  These macros perform the following functions:
290 *     + scan for the highest numbered (MSB) set in a 16 bit bitfield
291 *
292 *  NOTE:
293 *
294 *    It appears that on the M68020 bitfield are always 32 bits wide
295 *    when in a register.  This code forces the bitfield to be in
296 *    memory (it really always is anyway). This allows us to
297 *    have a real 16 bit wide bitfield which operates "correctly."
298 */
299
300#define CPU_USE_GENERIC_BITFIELD_CODE FALSE
301#define CPU_USE_GENERIC_BITFIELD_DATA FALSE
302
303#if ( M68K_HAS_BFFFO == 1 )
304
305#define _CPU_Bitfield_Find_first_bit( _value, _output ) \
306  asm volatile( "bfffo (%1),#0,#16,%0" : "=d" (_output) : "a" (&_value));
307#else
308
309/* duplicates BFFFO results for 16 bits (i.e., 15-(_priority) in
310   _CPU_Priority_bits_index is not needed), handles the 0 case, and
311   does not molest _value -- jsg */
312#if ( M68K_HAS_EXTB_L == 1 )
313#define _CPU_Bitfield_Find_first_bit( _value, _output ) \
314  { \
315    extern const unsigned char __BFFFOtable[256]; \
316    register int dumby; \
317    \
318    asm volatile ( "   move.w  %2,%1\n"        \
319       "   lsr.w   #8,%1\n"        \
320       "   beq.s   1f\n"           \
321       "   move.b  (%3,%1.w),%0\n" \
322       "   extb.l  %0\n"           \
323       "   bra.s   0f\n"           \
324       "1: moveq.l #8,%0\n"        \
325       "   add.b   (%3,%2.w),%0\n" \
326       "0:\n"                      \
327       : "=&d" ((_output)), "=&d" ((dumby)) \
328       : "d" ((_value)), "ao" ((__BFFFOtable)) \
329       : "cc" ) ; \
330  }
331#else
332#define _CPU_Bitfield_Find_first_bit( _value, _output ) \
333  { \
334    extern const unsigned char __BFFFOtable[256]; \
335    register int dumby; \
336    \
337    asm volatile ( "   move.w  %2,%1\n"        \
338       "   lsr.w   #8,%1\n"        \
339       "   beq.s   1f\n"           \
340       "   move.b  (%3,%1.w),%0\n" \
341       "   and.l   #0x000000ff,%0\n"\
342       "   bra.s   0f\n"           \
343       "1: moveq.l #8,%0\n"        \
344       "   add.b   (%3,%2.w),%0\n" \
345       "0:\n"                      \
346       : "=&d" ((_output)), "=&d" ((dumby)) \
347       : "d" ((_value)), "ao" ((__BFFFOtable)) \
348       : "cc" ) ; \
349  }
350#endif /* M68K_HAS_EXTB_L */
351
352#endif
353
354/* end of Bitfield handler macros */
355
356/*
357 *  Priority handler macros
358 *
359 *  These macros perform the following functions:
360 *    + return a mask with the bit for this major/minor portion of
361 *      of thread priority set.
362 *    + translate the bit number returned by "Bitfield_find_first_bit"
363 *      into an index into the thread ready chain bit maps
364 */
365
366#define _CPU_Priority_Mask( _bit_number ) \
367  ( 0x8000 >> (_bit_number) )
368
369#define _CPU_Priority_bits_index( _priority ) \
370  (_priority)
371
372/* end of Priority handler macros */
373
374/* functions */
375
376/*
377 *  _CPU_Initialize
378 *
379 *  This routine performs CPU dependent initialization.
380 */
381
382void _CPU_Initialize(
383  rtems_cpu_table  *cpu_table,
384  void      (*thread_dispatch)
385);
386
387/*
388 *  _CPU_ISR_install_raw_handler
389 *
390 *  This routine installs a "raw" interrupt handler directly into the
391 *  processor's vector table.
392 */
393 
394void _CPU_ISR_install_raw_handler(
395  unsigned32  vector,
396  proc_ptr    new_handler,
397  proc_ptr   *old_handler
398);
399
400/*
401 *  _CPU_ISR_install_vector
402 *
403 *  This routine installs an interrupt vector.
404 */
405
406void _CPU_ISR_install_vector(
407  unsigned32       vector,
408  proc_ptr         new_handler,
409  proc_ptr        *old_handler
410);
411
412/*
413 *  _CPU_Install_interrupt_stack
414 *
415 *  This routine installs the hardware interrupt stack pointer.
416 */
417
418void _CPU_Install_interrupt_stack( void );
419
420/*
421 *  _CPU_Context_switch
422 *
423 *  This routine switches from the run context to the heir context.
424 */
425
426void _CPU_Context_switch(
427  Context_Control  *run,
428  Context_Control  *heir
429);
430
431/*
432 *  _CPU_Context_save_fp
433 *
434 *  This routine saves the floating point context passed to it.
435 */
436
437void _CPU_Context_restore_fp(
438  void **fp_context_ptr
439);
440
441/*
442 *  _CPU_Context_restore_fp
443 *
444 *  This routine restores the floating point context passed to it.
445 */
446
447void _CPU_Context_save_fp(
448  void **fp_context_ptr
449);
450
451#ifdef __cplusplus
452}
453#endif
454
455#endif
456/* end of include file */
Note: See TracBrowser for help on using the repository browser.