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

4.104.114.84.95
Last change on this file since b0aba4c4 was b0aba4c4, checked in by Joel Sherrill <joel.sherrill@…>, on 04/27/98 at 16:10:16

Added swap of unsigned16

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