source: rtems/c/src/exec/score/cpu/i960/rtems/score/cpu.h @ 20f54e9

4.104.114.84.95
Last change on this file since 20f54e9 was 458bd34, checked in by Joel Sherrill <joel.sherrill@…>, on 11/05/99 at 16:44:02

This is another pass at making sure that nothing outside the BSP
unnecessarily uses any variables defined by the BSP. On this
sweep, use of BSP_Configuration and Cpu_table was eliminated.

A significant part of this modification was the addition of
macros to access fields in the RTEMS configuration structures.

This is necessary to strengthen the division between the BSP independent
parts of RTEMS and the BSPs themselves. This started after
comments and analysis by Ralf Corsepius <corsepiu@…>.

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