source: rtems/c/src/exec/score/cpu/hppa1.1/rtems/score/cpu.h @ fe7acdcf

4.104.114.84.95
Last change on this file since fe7acdcf was fe7acdcf, checked in by Joel Sherrill <joel.sherrill@…>, on 01/03/01 at 16:36:23

2001-01-03 Joel Sherrill <joel@…>

  • rtems/score/cpu.h: Added _CPU_Initialize_vectors().
  • cpu_asm.S: Modify to properly dereference _ISR_Vector_table now that it is dynamically allocated.
  • Property mode set to 100644
File size: 18.4 KB
Line 
1/*  cpu.h
2 *
3 *  This include file contains information pertaining to the HP
4 *  PA-RISC processor (Level 1.1).
5 *
6 *  COPYRIGHT (c) 1994 by Division Incorporated
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.OARcorp.com/rtems/license.html.
11 *
12 * Note:
13 *      This file is included by both C and assembler code ( -DASM )
14 *
15 *  $Id$
16 */
17
18#ifndef __CPU_h
19#define __CPU_h
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25#include <rtems/score/hppa.h>              /* pick up machine definitions */
26#ifndef ASM
27#include <rtems/score/hppatypes.h>
28#endif
29
30/* conditional compilation parameters */
31
32#define CPU_INLINE_ENABLE_DISPATCH       FALSE
33#define CPU_UNROLL_ENQUEUE_PRIORITY      TRUE
34
35/*
36 *  RTEMS manages an interrupt stack in software for the HPPA.
37 */
38
39#define CPU_HAS_SOFTWARE_INTERRUPT_STACK TRUE
40#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE
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 *  HPPA has hardware FP, it is assumed to exist by GCC so all tasks
53 *  may implicitly use it (especially for integer multiplies).  Because
54 *  the FP context is technically part of the basic integer context
55 *  on this CPU, we cannot use the deferred FP context switch algorithm.
56 */
57
58#define CPU_HARDWARE_FP                  TRUE
59#define CPU_SOFTWARE_FP                  FALSE
60#define CPU_ALL_TASKS_ARE_FP             TRUE
61#define CPU_IDLE_TASK_IS_FP              FALSE
62#define CPU_USE_DEFERRED_FP_SWITCH       FALSE
63
64#define CPU_PROVIDES_IDLE_THREAD_BODY    FALSE
65#define CPU_STACK_GROWS_UP               TRUE
66#define CPU_STRUCTURE_ALIGNMENT          __attribute__ ((__aligned__ (32)))
67
68/*
69 *  Define what is required to specify how the network to host conversion
70 *  routines are handled.
71 */
72
73#define CPU_HAS_OWN_HOST_TO_NETWORK_ROUTINES     FALSE
74#define CPU_BIG_ENDIAN                           TRUE
75#define CPU_LITTLE_ENDIAN                        FALSE
76
77/* constants */
78
79#define CPU_MODES_INTERRUPT_LEVEL  0x00000001 /* interrupt level in mode */
80#define CPU_MODES_INTERRUPT_MASK   0x00000001 /* interrupt level in mode */
81
82/*
83 * PSW contstants
84 */
85
86#define CPU_PSW_BASE (HPPA_PSW_C | HPPA_PSW_Q | HPPA_PSW_P | HPPA_PSW_D)
87#define CPU_PSW_INTERRUPTS_ON    (CPU_PSW_BASE | HPPA_PSW_I)
88#define CPU_PSW_INTERRUPTS_OFF   (CPU_PSW_BASE)
89
90#define CPU_PSW_DEFAULT     CPU_PSW_BASE
91
92
93#ifndef ASM
94
95/*
96 * Contexts
97 *
98 *  This means we have the following context items:
99 *    1. task level context stuff::  Context_Control
100 *    2. floating point task stuff:: Context_Control_fp
101 *
102 *  The PA-RISC is very fast so the expense of saving an extra register
103 *  or two is not of great concern at the present.  So we are not making
104 *  a distinction between what is saved during a task switch and what is
105 *  saved at each interrupt.  Plus saving the entire context should make
106 *  it easier to make gdb aware of RTEMS tasks.
107 */
108
109typedef struct {
110    unsigned32 flags;      /* whatever */
111    unsigned32 gr1;        /* scratch -- caller saves */
112    unsigned32 gr2;        /* RP -- return pointer */
113    unsigned32 gr3;        /* scratch -- callee saves */
114    unsigned32 gr4;        /* scratch -- callee saves */
115    unsigned32 gr5;        /* scratch -- callee saves */
116    unsigned32 gr6;        /* scratch -- callee saves */
117    unsigned32 gr7;        /* scratch -- callee saves */
118    unsigned32 gr8;        /* scratch -- callee saves */
119    unsigned32 gr9;        /* scratch -- callee saves */
120    unsigned32 gr10;       /* scratch -- callee saves */
121    unsigned32 gr11;       /* scratch -- callee saves */
122    unsigned32 gr12;       /* scratch -- callee saves */
123    unsigned32 gr13;       /* scratch -- callee saves */
124    unsigned32 gr14;       /* scratch -- callee saves */
125    unsigned32 gr15;       /* scratch -- callee saves */
126    unsigned32 gr16;       /* scratch -- callee saves */
127    unsigned32 gr17;       /* scratch -- callee saves */
128    unsigned32 gr18;       /* scratch -- callee saves */
129    unsigned32 gr19;       /* scratch -- caller saves */
130    unsigned32 gr20;       /* scratch -- caller saves */
131    unsigned32 gr21;       /* scratch -- caller saves */
132    unsigned32 gr22;       /* scratch -- caller saves */
133    unsigned32 gr23;       /* argument 3 */
134    unsigned32 gr24;       /* argument 2 */
135    unsigned32 gr25;       /* argument 1 */
136    unsigned32 gr26;       /* argument 0 */
137    unsigned32 gr27;       /* DP -- global data pointer */
138    unsigned32 gr28;       /* return values -- caller saves */
139    unsigned32 gr29;       /* return values -- caller saves */
140    unsigned32 sp;         /* gr30 */
141    unsigned32 gr31;
142
143    /* Various control registers */
144
145    unsigned32 sar;         /* cr11 */
146    unsigned32 ipsw;        /* cr22; full 32 bits of psw */
147    unsigned32 iir;         /* cr19; interrupt instruction register */
148    unsigned32 ior;         /* cr21; interrupt offset register */
149    unsigned32 isr;         /* cr20; interrupt space register (not used) */
150    unsigned32 pcoqfront;   /* cr18; front que offset */
151    unsigned32 pcoqback;    /* cr18; back que offset */
152    unsigned32 pcsqfront;   /* cr17; front que space (not used) */
153    unsigned32 pcsqback;    /* cr17; back que space (not used) */
154    unsigned32 itimer;      /* cr16; itimer value */
155
156} Context_Control;
157
158
159/* Must be double word aligned.
160 * This will be ok since our allocator returns 8 byte aligned chunks
161 */
162
163typedef struct {
164    double      fr0;        /* status */
165    double      fr1;        /* exception information */
166    double      fr2;        /* exception information */
167    double      fr3;        /* exception information */
168    double      fr4;        /* argument */
169    double      fr5;        /* argument */
170    double      fr6;        /* argument */
171    double      fr7;        /* argument */
172    double      fr8;        /* scratch -- caller saves */
173    double      fr9;        /* scratch -- caller saves */
174    double      fr10;       /* scratch -- caller saves */
175    double      fr11;       /* scratch -- caller saves */
176    double      fr12;       /* callee saves -- (PA-RISC 1.1 CPUs) */
177    double      fr13;       /* callee saves -- (PA-RISC 1.1 CPUs) */
178    double      fr14;       /* callee saves -- (PA-RISC 1.1 CPUs) */
179    double      fr15;       /* callee saves -- (PA-RISC 1.1 CPUs) */
180    double      fr16;       /* callee saves -- (PA-RISC 1.1 CPUs) */
181    double      fr17;       /* callee saves -- (PA-RISC 1.1 CPUs) */
182    double      fr18;       /* callee saves -- (PA-RISC 1.1 CPUs) */
183    double      fr19;       /* callee saves -- (PA-RISC 1.1 CPUs) */
184    double      fr20;       /* callee saves -- (PA-RISC 1.1 CPUs) */
185    double      fr21;       /* callee saves -- (PA-RISC 1.1 CPUs) */
186    double      fr22;       /* caller saves -- (PA-RISC 1.1 CPUs) */
187    double      fr23;       /* caller saves -- (PA-RISC 1.1 CPUs) */
188    double      fr24;       /* caller saves -- (PA-RISC 1.1 CPUs) */
189    double      fr25;       /* caller saves -- (PA-RISC 1.1 CPUs) */
190    double      fr26;       /* caller saves -- (PA-RISC 1.1 CPUs) */
191    double      fr27;       /* caller saves -- (PA-RISC 1.1 CPUs) */
192    double      fr28;       /* caller saves -- (PA-RISC 1.1 CPUs) */
193    double      fr29;       /* caller saves -- (PA-RISC 1.1 CPUs) */
194    double      fr30;       /* caller saves -- (PA-RISC 1.1 CPUs) */
195    double      fr31;       /* caller saves -- (PA-RISC 1.1 CPUs) */
196} Context_Control_fp;
197
198/*
199 *  The following structure defines the set of information saved
200 *  on the current stack by RTEMS upon receipt of each interrupt.
201 */
202
203typedef struct {
204  Context_Control             Integer;
205  Context_Control_fp          Floating_Point;
206} CPU_Interrupt_frame;
207
208/*
209 * Our interrupt handlers take a 2nd argument:
210 *   a pointer to a CPU_Interrupt_frame
211 * So we use our own prototype instead of rtems_isr_entry
212 */
213
214typedef void ( *hppa_rtems_isr_entry )(
215    unsigned32,
216    CPU_Interrupt_frame *
217 );
218
219/*
220 * The following table contains the information required to configure
221 * the HPPA specific parameters.
222 */
223
224typedef struct {
225  void       (*pretasking_hook)( void );
226  void       (*predriver_hook)( void );
227  void       (*postdriver_hook)( void );
228  void       (*idle_task)( void );
229  boolean      do_zero_of_workspace;
230  unsigned32   idle_task_stack_size;
231  unsigned32   interrupt_stack_size;
232  unsigned32   extra_mpci_receive_server_stack;
233  void *     (*stack_allocate_hook)( unsigned32 );
234  void       (*stack_free_hook)( void * );
235  /* end of fields required on all CPUs */
236
237  hppa_rtems_isr_entry spurious_handler;
238
239  unsigned32   itimer_clicks_per_microsecond; /* for use by Clock driver */
240}   rtems_cpu_table;
241
242/*
243 *  Macros to access required entires in the CPU Table are in
244 *  the file rtems/system.h.
245 */
246
247/*
248 *  Macros to access HPPA specific additions to the CPU Table
249 */
250
251#define rtems_cpu_configuration_get_spurious_handler() \
252   (_CPU_Table.spurious_handler)
253
254#define rtems_cpu_configuration_get_itimer_clicks_per_microsecond() \
255   (_CPU_Table.itimer_clicks_per_microsecond)
256
257/* variables */
258
259SCORE_EXTERN Context_Control_fp  _CPU_Null_fp_context;
260SCORE_EXTERN unsigned32          _CPU_Default_gr27;
261SCORE_EXTERN void               *_CPU_Interrupt_stack_low;
262SCORE_EXTERN void               *_CPU_Interrupt_stack_high;
263
264#endif          /* ! ASM */
265
266/*
267 *  context sizes
268 */
269
270#ifndef ASM
271#define CPU_CONTEXT_SIZE     sizeof( Context_Control )
272#define CPU_CONTEXT_FP_SIZE  sizeof( Context_Control_fp )
273#endif
274
275/*
276 *  size of a frame on the stack
277 */
278
279#define CPU_FRAME_SIZE (16 * 4)
280
281/*
282 * (Optional) # of bytes for libmisc/stackchk to check
283 * If not specifed, then it defaults to something reasonable
284 * for most architectures.
285 */
286
287#define CPU_STACK_CHECK_SIZE    (CPU_FRAME_SIZE * 2)
288
289/*
290 *  extra stack required by the MPCI receive server thread
291 */
292
293#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0
294
295/*
296 * HPPA has 32 traps, then 32 external interrupts
297 * Rtems (_ISR_Vector_Table) is aware ONLY of the first 32
298 * The BSP is aware of the external interrupts and possibly more.
299 *
300 */
301
302#define CPU_INTERRUPT_NUMBER_OF_VECTORS      (HPPA_INTERNAL_TRAPS)
303#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER  (CPU_INTERRUPT_NUMBER_OF_VECTORS - 1)
304
305/*
306 * Don't be chintzy here; we don't want to debug these problems
307 * Some of the tests eat almost 4k.
308 * Plus, the HPPA always allocates chunks of 64 bytes for stack
309 *       growth.
310 */
311
312#define CPU_STACK_MINIMUM_SIZE          (8 * 1024)
313
314/*
315 * HPPA double's must be on 8 byte boundary
316 */
317
318#define CPU_ALIGNMENT              8
319
320/*
321 * just follow the basic HPPA alignment for the heap and partition
322 */
323
324#define CPU_HEAP_ALIGNMENT         CPU_ALIGNMENT
325#define CPU_PARTITION_ALIGNMENT    CPU_ALIGNMENT
326
327/*
328 * HPPA stack is best when 64 byte aligned.
329 */
330
331#define CPU_STACK_ALIGNMENT        64
332
333#ifndef ASM
334
335/* macros */
336
337/*
338 *  ISR handler macros
339 *
340 *  These macros perform the following functions:
341 *     + initialize the RTEMS vector table
342 *     + disable all maskable CPU interrupts
343 *     + restore previous interrupt level (enable)
344 *     + temporarily restore interrupts (flash)
345 *     + set a particular level
346 */
347
348/*
349 *  Support routine to initialize the RTEMS vector table after it is allocated.
350 */
351
352#define _CPU_Initialize_vectors()
353
354/* Disable interrupts; returning previous psw bits in _isr_level */
355
356#define _CPU_ISR_Disable( _isr_level ) \
357  do { \
358         HPPA_ASM_RSM(HPPA_PSW_I, _isr_level);         \
359         if (_isr_level & HPPA_PSW_I) _isr_level = 0;  \
360         else                          _isr_level = 1; \
361  } while(0)
362
363/* Enable interrupts to previous level from _CPU_ISR_Disable
364 * does not change 'level'
365 */
366
367#define _CPU_ISR_Enable( _isr_level )  \
368  { \
369        register int _ignore; \
370        if (_isr_level == 0) HPPA_ASM_SSM(HPPA_PSW_I, _ignore); \
371        else                 HPPA_ASM_RSM(HPPA_PSW_I, _ignore); \
372  }
373
374/* restore, then disable interrupts; does not change level */
375#define _CPU_ISR_Flash( _isr_level ) \
376  { \
377        if (_isr_level == 0) \
378        { \
379              register int _ignore;  \
380              HPPA_ASM_SSM(HPPA_PSW_I, _ignore); \
381              HPPA_ASM_RSM(HPPA_PSW_I, _ignore); \
382        } \
383  }
384
385/*
386 * Interrupt task levels
387 *
388 * Future scheme proposal
389 *      level will be an index into a array.
390 *      Each entry of array will be the interrupt bits
391 *        enabled for that level.  There will be 32 bits of external
392 *        interrupts (to be placed in EIEM) and some (optional) bsp
393 *        specific bits
394 *
395 * For pixel flow this *may* mean something like:
396 *      level 0:   all interrupts enabled (external + rhino)
397 *      level 1:   rhino disabled
398 *      level 2:   all io interrupts disabled (timer still enabled)
399 *      level 7:   *ALL* disabled (timer disabled)
400 */
401
402/* set interrupts on or off; does not return new level */
403#define _CPU_ISR_Set_level( new_level ) \
404  { \
405        volatile int ignore; \
406        if ( new_level )  HPPA_ASM_RSM(HPPA_PSW_I, ignore); \
407        else              HPPA_ASM_SSM(HPPA_PSW_I, ignore); \
408  }
409
410/* return current level */
411unsigned32 _CPU_ISR_Get_level( void );
412
413/* end of ISR handler macros */
414
415/*
416 *  Context handler macros
417 *
418 *  These macros perform the following functions:
419 *     + initialize a context area
420 *     + restart the current thread
421 *     + calculate the initial pointer into a FP context area
422 *     + initialize an FP context area
423 *
424 *  HPPA port adds two macros which hide the "indirectness" of the
425 *  pointer passed the save/restore FP context assembly routines.
426 */
427
428#define _CPU_Context_Initialize( _the_context, _stack_base, _size, \
429                                  _new_level, _entry_point, _is_fp ) \
430  do { \
431    unsigned32 _stack; \
432    \
433    (_the_context)->flags = 0xfeedf00d; \
434    (_the_context)->pcoqfront = (unsigned32)(_entry_point); \
435    (_the_context)->pcoqback  = (unsigned32)(_entry_point) + 4; \
436    (_the_context)->pcsqfront = 0; \
437    (_the_context)->pcsqback  = 0; \
438    if ( (_new_level) ) \
439        (_the_context)->ipsw = CPU_PSW_INTERRUPTS_OFF; \
440    else \
441        (_the_context)->ipsw = CPU_PSW_INTERRUPTS_ON; \
442    \
443    _stack = ((unsigned32)(_stack_base) + (CPU_STACK_ALIGNMENT - 1)); \
444    _stack &= ~(CPU_STACK_ALIGNMENT - 1); \
445    if ((_stack - (unsigned32) (_stack_base)) < CPU_FRAME_SIZE) \
446       _stack += CPU_FRAME_SIZE; \
447    \
448    (_the_context)->sp = (_stack); \
449    (_the_context)->gr27 = _CPU_Default_gr27; \
450  } while (0)
451
452#define _CPU_Context_Restart_self( _the_context ) \
453    do { \
454         _CPU_Context_restore( (_the_context) ); \
455    } while (0)
456
457#define _CPU_Context_Fp_start( _base, _offset ) \
458   ( (void *) _Addresses_Add_offset( (_base), (_offset) ) )
459
460#define _CPU_Context_Initialize_fp( _destination ) \
461  do { \
462    *((Context_Control_fp *) *((void **) _destination)) = _CPU_Null_fp_context;\
463  } while(0)
464
465#define _CPU_Context_save_fp( _fp_context ) \
466   _CPU_Save_float_context( *(Context_Control_fp **)(_fp_context) )
467
468#define _CPU_Context_restore_fp( _fp_context ) \
469   _CPU_Restore_float_context( *(Context_Control_fp **)(_fp_context) )
470
471/* end of Context handler macros */
472
473/*
474 *  Fatal Error manager macros
475 *
476 *  These macros perform the following functions:
477 *    + disable interrupts and halt the CPU
478 */
479
480void    hppa_cpu_halt(unsigned32 the_error);
481#define _CPU_Fatal_halt( _error ) \
482    hppa_cpu_halt(_error)
483
484/* end of Fatal Error manager macros */
485
486/*
487 *  Bitfield handler macros
488 *
489 *  These macros perform the following functions:
490 *     + scan for the highest numbered (MSB) set in a 16 bit bitfield
491 *
492 *  NOTE:
493 *
494 *  The HPPA does not have a scan instruction.  This functionality
495 *  is implemented in software.
496 */
497
498#define CPU_USE_GENERIC_BITFIELD_CODE FALSE
499#define CPU_USE_GENERIC_BITFIELD_DATA FALSE
500
501int hppa_rtems_ffs(unsigned int value);
502#define _CPU_Bitfield_Find_first_bit( _value, _output ) \
503    _output = hppa_rtems_ffs(_value)
504
505/* end of Bitfield handler macros */
506
507/*
508 *  Priority handler macros
509 *
510 *  These macros perform the following functions:
511 *    + return a mask with the bit for this major/minor portion of
512 *      of thread priority set.
513 *    + translate the bit number returned by "Bitfield_find_first_bit"
514 *      into an index into the thread ready chain bit maps
515 *
516 *  Note: 255 is the lowest priority
517 */
518
519#define _CPU_Priority_Mask( _bit_number ) \
520  ( 1 << (_bit_number) )
521
522#define _CPU_Priority_bits_index( _priority ) \
523  (_priority)
524
525/* end of Priority handler macros */
526
527/* functions */
528
529/*
530 *  _CPU_Initialize
531 *
532 *  This routine performs CPU dependent initialization.
533 */
534
535void _CPU_Initialize(
536  rtems_cpu_table  *cpu_table,
537  void      (*thread_dispatch)
538);
539
540/*
541 *  _CPU_ISR_install_raw_handler
542 *
543 *  This routine installs a "raw" interrupt handler directly into the
544 *  processor's vector table.
545 */
546 
547void _CPU_ISR_install_raw_handler(
548  unsigned32  vector,
549  proc_ptr    new_handler,
550  proc_ptr   *old_handler
551);
552
553/*
554 *  _CPU_ISR_install_vector
555 *
556 *  This routine installs an interrupt vector.
557 */
558
559void _CPU_ISR_install_vector(
560  unsigned32  vector,
561  proc_ptr    new_handler,
562  proc_ptr   *old_handler
563);
564
565/*
566 *  _CPU_Context_switch
567 *
568 *  This routine switches from the run context to the heir context.
569 */
570
571void _CPU_Context_switch(
572  Context_Control  *run,
573  Context_Control  *heir
574);
575
576/*
577 *  _CPU_Context_restore
578 *
579 *  This routine is generally used only to restart self in an
580 *  efficient manner and avoid stack conflicts.
581 */
582
583void _CPU_Context_restore(
584  Context_Control *new_context
585);
586
587/*
588 *  _CPU_Save_float_context
589 *
590 *  This routine saves the floating point context passed to it.
591 *
592 *  NOTE:  _CPU_Context_save_fp is implemented as a macro on the HPPA
593 *         which dereferences the pointer before calling this.
594 */
595
596void _CPU_Save_float_context(
597  Context_Control_fp *fp_context
598);
599
600/*
601 *  _CPU_Restore_float_context
602 *
603 *  This routine restores the floating point context passed to it.
604 *
605 *  NOTE:  _CPU_Context_save_fp is implemented as a macro on the HPPA
606 *         which dereferences the pointer before calling this.
607 */
608
609void _CPU_Restore_float_context(
610  Context_Control_fp *fp_context
611);
612
613
614/*
615 * The raw interrupt handler for external interrupts
616 */
617
618extern void _Generic_ISR_Handler(
619    void
620);
621
622
623/*  The following routine swaps the endian format of an unsigned int.
624 *  It must be static so it can be referenced indirectly.
625 */
626
627static inline unsigned int
628CPU_swap_u32(unsigned32 value)
629{
630  unsigned32 swapped;
631
632  HPPA_ASM_SWAPBYTES(value, swapped);
633
634  return( swapped );
635}
636
637#define CPU_swap_u16( value ) \
638  (((value&0xff) << 8) | ((value >> 8)&0xff))
639
640#endif   /* ! ASM */
641
642#ifdef __cplusplus
643}
644#endif
645
646#endif   /* ! __CPU_h */
Note: See TracBrowser for help on using the repository browser.