source: rtems/c/src/exec/score/cpu/m68k/cpu.h @ 75f09e5

4.104.114.84.95
Last change on this file since 75f09e5 was 75f09e5, checked in by Joel Sherrill <joel.sherrill@…>, on 02/21/96 at 14:43:34

Dispersal of internal thread handler resulted in IDLE thread becoming
part of the Thread Handler. This required the name of the optional
CPU dependent IDLE thread implementation to change.

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