source: rtems/cpukit/score/cpu/i960/rtems/score/cpu.h @ 17508d02

4.104.114.84.95
Last change on this file since 17508d02 was 17508d02, checked in by Joel Sherrill <joel.sherrill@…>, on 07/26/00 at 19:26:28

Port of RTEMS to the Texas Instruments C3x/C4x DSP families including
a BSP (c4xsim) supporting the simulator included with gdb. This port
was done by Joel Sherrill and Jennifer Averett of OAR Corporation.
Also included with this port is a space/time optimization to eliminate
FP context switch management on CPUs without hardware or software FP.

An issue with this port was that sizeof(unsigned32) = sizeof(unsigned8)
on this CPU. This required addressing alignment checks and assumptions
as well as fixing code that assumed sizeof(unsigned32) == 4.

  • Property mode set to 100644
File size: 13.0 KB
Line 
1/*  cpu.h
2 *
3 *  This include file contains information pertaining to the Intel
4 *  i960 processor family.
5 *
6 *  COPYRIGHT (c) 1989-1999.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.OARcorp.com/rtems/license.html.
12 *
13 *  $Id$
14 */
15
16#ifndef __CPU_h
17#define __CPU_h
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23#include <rtems/score/i960.h>              /* pick up machine definitions */
24#ifndef ASM
25#include <rtems/score/i960types.h>
26#endif
27
28#define CPU_INLINE_ENABLE_DISPATCH       FALSE
29#define CPU_UNROLL_ENQUEUE_PRIORITY      FALSE
30
31/*
32 *  Use the i960's hardware interrupt stack support and have the
33 *  interrupt manager allocate the memory for it.
34 */
35
36#define CPU_HAS_SOFTWARE_INTERRUPT_STACK FALSE
37#define CPU_HAS_HARDWARE_INTERRUPT_STACK TRUE
38#define CPU_ALLOCATE_INTERRUPT_STACK     TRUE
39
40/*
41 *  Does the RTEMS invoke the user's ISR with the vector number and
42 *  a pointer to the saved interrupt frame (1) or just the vector
43 *  number (0)?
44 */
45
46#define CPU_ISR_PASSES_FRAME_POINTER 0
47
48/*
49 *  Some family members have no FP (SA/KA/CA/CF), others have it built in
50 *  (KB/MC/MX).  There does not appear to be an external coprocessor
51 *  for this family.
52 */
53
54#if ( I960_HAS_FPU == 1 )
55#define CPU_HARDWARE_FP     TRUE
56#error "Floating point support for i960 family has been implemented!!!"
57#else
58#define CPU_HARDWARE_FP     FALSE
59#endif
60
61#define CPU_SOFTWARE_FP     FALSE
62
63#define CPU_ALL_TASKS_ARE_FP             FALSE
64#define CPU_IDLE_TASK_IS_FP              FALSE
65#define CPU_USE_DEFERRED_FP_SWITCH       TRUE
66
67#define CPU_PROVIDES_IDLE_THREAD_BODY    FALSE
68#define CPU_STACK_GROWS_UP               TRUE
69#define CPU_STRUCTURE_ALIGNMENT          /* __attribute__ ((aligned (16))) */
70
71/*
72 *  Define what is required to specify how the network to host conversion
73 *  routines are handled.
74 */
75
76#define CPU_HAS_OWN_HOST_TO_NETWORK_ROUTINES     FALSE
77#define CPU_BIG_ENDIAN                           TRUE
78#define CPU_LITTLE_ENDIAN                        FALSE
79
80
81/* structures */
82
83/*
84 *  Basic integer context for the i960 family.
85 */
86
87typedef struct {
88  void       *r0_pfp;                 /* (r0)  Previous Frame Pointer */
89  void       *r1_sp;                  /* (r1)  Stack Pointer */
90  unsigned32  pc;                     /* (pc)  Processor Control */
91  void       *g8;                     /* (g8)  Global Register 8 */
92  void       *g9;                     /* (g9)  Global Register 9 */
93  void       *g10;                    /* (g10) Global Register 10 */
94  void       *g11;                    /* (g11) Global Register 11 */
95  void       *g12;                    /* (g12) Global Register 12 */
96  void       *g13;                    /* (g13) Global Register 13 */
97  unsigned32  g14;                    /* (g14) Global Register 14 */
98  void       *g15_fp;                 /* (g15) Frame Pointer */
99}   Context_Control;
100
101/*
102 *  FP context save area for the i960 Numeric Extension
103 */
104
105typedef struct {
106   unsigned32  fp0_1;                 /* (fp0) first word  */
107   unsigned32  fp0_2;                 /* (fp0) second word */
108   unsigned32  fp0_3;                 /* (fp0) third word  */
109   unsigned32  fp1_1;                 /* (fp1) first word  */
110   unsigned32  fp1_2;                 /* (fp1) second word */
111   unsigned32  fp1_3;                 /* (fp1) third word  */
112   unsigned32  fp2_1;                 /* (fp2) first word  */
113   unsigned32  fp2_2;                 /* (fp2) second word */
114   unsigned32  fp2_3;                 /* (fp2) third word  */
115   unsigned32  fp3_1;                 /* (fp3) first word  */
116   unsigned32  fp3_2;                 /* (fp3) second word */
117   unsigned32  fp3_3;                 /* (fp3) third word  */
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 *  Call frame for the i960 family.
131 */
132
133typedef struct {
134  void       *r0_pfp;                 /* (r0)  Previous Frame Pointer */
135  void       *r1_sp;                  /* (r1)  Stack Pointer */
136  void       *r2_rip;                 /* (r2)  Return Instruction Pointer */
137  void       *r3;                     /* (r3)  Local Register 3 */
138  void       *r4;                     /* (r4)  Local Register 4 */
139  void       *r5;                     /* (r5)  Local Register 5 */
140  void       *r6;                     /* (r6)  Local Register 6 */
141  void       *r7;                     /* (r7)  Local Register 7 */
142  void       *r8;                     /* (r8)  Local Register 8 */
143  void       *r9;                     /* (r9)  Local Register 9 */
144  void       *r10;                    /* (r10) Local Register 10 */
145  void       *r11;                    /* (r11) Local Register 11 */
146  void       *r12;                    /* (r12) Local Register 12 */
147  void       *r13;                    /* (r13) Local Register 13 */
148  void       *r14;                    /* (r14) Local Register 14 */
149  void       *r15;                    /* (r15) Local Register 15 */
150  /* XXX Looks like sometimes there is FP stuff here (MC manual)? */
151}   CPU_Call_frame;
152
153/*
154 *  The following table contains the information required to configure
155 *  the i960 specific parameters.
156 */
157
158typedef struct {
159  void       (*pretasking_hook)( void );
160  void       (*predriver_hook)( void );
161  void       (*postdriver_hook)( void );
162  void       (*idle_task)( void );
163  boolean      do_zero_of_workspace;
164  unsigned32   idle_task_stack_size;
165  unsigned32   interrupt_stack_size;
166  unsigned32   extra_mpci_receive_server_stack;
167  void *     (*stack_allocate_hook)( unsigned32 );
168  void       (*stack_free_hook)( void* );
169  /* end of fields required on all CPUs */
170}   rtems_cpu_table;
171
172/*
173 *  Macros to access required entires in the CPU Table are in
174 *  the file rtems/system.h.
175 */
176
177/*
178 *  Macros to access i960 specific additions to the CPU Table
179 *
180 *  NONE
181 */
182
183/* variables */
184
185SCORE_EXTERN void               *_CPU_Interrupt_stack_low;
186SCORE_EXTERN void               *_CPU_Interrupt_stack_high;
187
188/* constants */
189
190/*
191 *  This defines the number of levels and the mask used to pick those
192 *  bits out of a thread mode.
193 */
194
195#define CPU_MODES_INTERRUPT_LEVEL  0x0000001f  /* interrupt level in mode */
196#define CPU_MODES_INTERRUPT_MASK   0x0000001f  /* interrupt level in mode */
197
198/*
199 *  context size area for floating point
200 */
201
202#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp )
203
204/*
205 *  extra stack required by the MPCI receive server thread
206 */
207
208#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK (CPU_STACK_MINIMUM_SIZE)
209
210/*
211 *  i960 family supports 256 distinct vectors.
212 */
213
214#define CPU_INTERRUPT_NUMBER_OF_VECTORS      256
215#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER  (CPU_INTERRUPT_NUMBER_OF_VECTORS - 1)
216
217/*
218 *  Minimum size of a thread's stack.
219 *
220 *  NOTE:  See CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK
221 */
222
223#define CPU_STACK_MINIMUM_SIZE          2048
224
225/*
226 *  i960 is pretty tolerant of alignment but some CPU models do
227 *  better with different default aligments so we use what the
228 *  CPU model selected in rtems/score/i960.h.
229 */
230
231#define CPU_ALIGNMENT                   I960_CPU_ALIGNMENT
232#define CPU_HEAP_ALIGNMENT              CPU_ALIGNMENT
233#define CPU_PARTITION_ALIGNMENT         CPU_ALIGNMENT
234
235/*
236 * i960ca stack requires 16 byte alignment
237 *
238 *  NOTE:  This factor may need to be family member dependent.
239 */
240
241#define CPU_STACK_ALIGNMENT        16
242
243/* macros */
244
245/*
246 *  ISR handler macros
247 *
248 *  These macros perform the following functions:
249 *     + disable all maskable CPU interrupts
250 *     + restore previous interrupt level (enable)
251 *     + temporarily restore interrupts (flash)
252 *     + set a particular level
253 */
254
255#define _CPU_ISR_Disable( _level ) i960_disable_interrupts( _level )
256#define _CPU_ISR_Enable( _level )  i960_enable_interrupts( _level )
257#define _CPU_ISR_Flash( _level )   i960_flash_interrupts( _level )
258
259#define _CPU_ISR_Set_level( newlevel ) \
260  { \
261    unsigned32 _mask = 0; \
262    unsigned32 _level = (newlevel); \
263    \
264    __asm__ volatile ( "ldconst 0x1f0000,%0; \
265                    modpc   0,%0,%1"     : "=d" (_mask), "=d" (_level) \
266                                         : "0"  (_mask), "1" (_level) \
267    ); \
268  }
269
270unsigned32 _CPU_ISR_Get_level( void );
271
272/* ISR handler section macros */
273
274/*
275 *  Context handler macros
276 *
277 *  These macros perform the following functions:
278 *     + initialize a context area
279 *     + restart the current thread
280 *     + calculate the initial pointer into a FP context area
281 *     + initialize an FP context area
282 */
283
284#define _CPU_Context_Initialize( _the_context, _stack_base, _size, \
285                                  _isr, _entry, _is_fp ) \
286 { CPU_Call_frame *_texit_frame; \
287   unsigned32 _mask; \
288   unsigned32 _base_pc; \
289   unsigned32  _stack_tmp; \
290   void       *_stack; \
291   \
292  _stack_tmp = (unsigned32)(_stack_base) + CPU_STACK_ALIGNMENT; \
293  _stack_tmp &= ~(CPU_STACK_ALIGNMENT - 1); \
294  _stack = (void *) _stack_tmp; \
295   \
296   __asm__ volatile ( "flushreg" : : );   /* flush register cache */ \
297   \
298   (_the_context)->r0_pfp = _stack; \
299   (_the_context)->g15_fp = _stack + (1 * sizeof(CPU_Call_frame)); \
300   (_the_context)->r1_sp  = _stack + (2 * sizeof(CPU_Call_frame)); \
301   __asm__ volatile ( "ldconst 0x1f0000,%0 ; " \
302                  "modpc   0,0,%1 ; " \
303                  "andnot  %0,%1,%1 ; " \
304                  : "=d" (_mask), "=d" (_base_pc) : ); \
305   (_the_context)->pc     = _base_pc | ((_isr) << 16); \
306   (_the_context)->g14    = 0; \
307   \
308   _texit_frame         = (CPU_Call_frame *)_stack; \
309   _texit_frame->r0_pfp = NULL; \
310   _texit_frame->r1_sp  = (_the_context)->g15_fp; \
311   _texit_frame->r2_rip = (_entry); \
312 }
313
314#define _CPU_Context_Restart_self( _the_context ) \
315   _CPU_Context_restore( (_the_context) );
316
317#define _CPU_Context_Fp_start( _base, _offset )         NULL
318
319#define _CPU_Context_Initialize_fp( _fp_area )
320
321/* end of Context handler macros */
322
323/*
324 *  Fatal Error manager macros
325 *
326 *  These macros perform the following functions:
327 *    + disable interrupts and halt the CPU
328 */
329
330#define _CPU_Fatal_halt( _errorcode ) \
331  { unsigned32 _mask, _level; \
332    unsigned32 _error = (_errorcode); \
333    \
334    __asm__ volatile ( "ldconst 0x1f0000,%0 ; \
335                    mov     %0,%1 ; \
336                    modpc   0,%0,%1 ; \
337                    mov     %2,g0 ; \
338            self:   b       self " \
339                    : "=d" (_mask), "=d" (_level), "=d" (_error) : ); \
340  }
341
342/* end of Fatal Error Manager macros */
343
344/*
345 *  Bitfield handler macros
346 *
347 *  These macros perform the following functions:
348 *     + scan for the highest numbered (MSB) set in a 16 bit bitfield
349 */
350
351#define CPU_USE_GENERIC_BITFIELD_CODE FALSE
352#define CPU_USE_GENERIC_BITFIELD_DATA FALSE
353
354#define _CPU_Bitfield_Find_first_bit( _value, _output ) \
355  { unsigned32 _search = (_value); \
356    \
357    (_output) = 0; /* to prevent warnings */ \
358    __asm__ volatile ( "scanbit   %0,%1  " \
359                    : "=d" (_search), "=d" (_output) \
360                    : "0"  (_search), "1"  (_output) ); \
361  }
362
363/* end of Bitfield handler macros */
364
365/*
366 *  Priority handler macros
367 *
368 *  These macros perform the following functions:
369 *    + return a mask with the bit for this major/minor portion of
370 *      of thread priority set.
371 *    + translate the bit number returned by "Bitfield_find_first_bit"
372 *      into an index into the thread ready chain bit maps
373 */
374
375#define _CPU_Priority_Mask( _bit_number ) \
376   ( 0x8000 >> (_bit_number) )
377
378#define _CPU_Priority_bits_index( _priority ) \
379   ( 15 - (_priority) )
380
381/* end of Priority handler macros */
382
383/* functions */
384
385/*
386 *  _CPU_Initialize
387 *
388 *  This routine performs CPU dependent initialization.
389 */
390
391void _CPU_Initialize(
392  rtems_cpu_table  *cpu_table,
393  void      (*thread_dispatch)
394);
395
396/*
397 *  _CPU_ISR_install_raw_handler
398 *
399 *  This routine installs a "raw" interrupt handler directly into the
400 *  processor's vector table.
401 */
402 
403void _CPU_ISR_install_raw_handler(
404  unsigned32  vector,
405  proc_ptr    new_handler,
406  proc_ptr   *old_handler
407);
408
409/*
410 *  _CPU_ISR_install_vector
411 *
412 *  This routine installs an interrupt vector.
413 */
414
415void _CPU_ISR_install_vector(
416  unsigned32  vector,
417  proc_ptr    new_handler,
418  proc_ptr   *old_handler
419);
420
421/*
422 *  _CPU_Install_interrupt_stack
423 *
424 *  This routine installs the hardware interrupt stack pointer.
425 */
426
427void _CPU_Install_interrupt_stack( void );
428
429/*
430 *  _CPU_Context_switch
431 *
432 *  This routine switches from the run context to the heir context.
433 */
434
435void _CPU_Context_switch(
436  Context_Control  *run,
437  Context_Control  *heir
438);
439
440/*
441 *  _CPU_Context_restore
442 *
443 *  This routine is generally used only to restart self in an
444 *  efficient manner and avoid stack conflicts.
445 */
446
447void _CPU_Context_restore(
448  Context_Control *new_context
449);
450
451/*
452 *  _CPU_Context_save_fp
453 *
454 *  This routine saves the floating point context passed to it.
455 */
456
457void _CPU_Context_save_fp(
458  void        **fp_context_ptr
459);
460
461/*
462 *  _CPU_Context_restore_fp
463 *
464 *  This routine restores the floating point context passed to it.
465 */
466
467void _CPU_Context_restore_fp(
468  void        **fp_context_ptr
469);
470
471#ifdef __cplusplus
472}
473#endif
474
475#endif
476/* end of include file */
Note: See TracBrowser for help on using the repository browser.