source: rtems/cpukit/score/cpu/powerpc/rtems/old-exceptions/cpu.h @ 74e9807

4.104.114.84.95
Last change on this file since 74e9807 was 74e9807, checked in by Ralf Corsepius <ralf.corsepius@…>, on 02/18/05 at 11:29:22

(CPU_HARDWARE_FP, CPU_ALL_TASKS_ARE_FP,

CPU_IDLE_TASK_IS_FP): Remove.

  • Property mode set to 100644
File size: 15.3 KB
Line 
1/*  cpu.h
2 *
3 *  This include file contains information pertaining to the PowerPC
4 *  processor.
5 *
6 *  Author:     Andrew Bray <andy@i-cubed.co.uk>
7 *
8 *  COPYRIGHT (c) 1995 by i-cubed ltd.
9 *
10 *  To anyone who acknowledges that this file is provided "AS IS"
11 *  without any express or implied warranty:
12 *      permission to use, copy, modify, and distribute this file
13 *      for any purpose is hereby granted without fee, provided that
14 *      the above copyright notice and this notice appears in all
15 *      copies, and that the name of i-cubed limited not be used in
16 *      advertising or publicity pertaining to distribution of the
17 *      software without specific, written prior permission.
18 *      i-cubed limited makes no representations about the suitability
19 *      of this software for any purpose.
20 *
21 *  Derived from c/src/exec/cpu/no_cpu/cpu.h:
22 *
23 *  COPYRIGHT (c) 1989-1997.
24 *  On-Line Applications Research Corporation (OAR).
25 *
26 *  The license and distribution terms for this file may in
27 *  the file LICENSE in this distribution or at
28 *  http://www.rtems.com/license/LICENSE.
29 *
30 *  $Id$
31 */
32
33#ifndef _RTEMS_OLD_EXCEPTIONS_CPU_H
34#define _RTEMS_OLD_EXCEPTIONS_CPU_H
35
36#ifndef _RTEMS_SCORE_CPU_H
37#error "You should include <rtems/score/cpu.h>"
38#endif
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44#ifndef ASM
45struct CPU_Interrupt_frame;
46typedef void ( *ppc_isr_entry )( int, struct CPU_Interrupt_frame * );
47#endif
48
49/* conditional compilation parameters */
50
51/*
52 *  Does RTEMS manage a dedicated interrupt stack in software?
53 *
54 *  If TRUE, then a stack is allocated in _ISR_Handler_initialization.
55 *  If FALSE, nothing is done.
56 *
57 *  If the CPU supports a dedicated interrupt stack in hardware,
58 *  then it is generally the responsibility of the BSP to allocate it
59 *  and set it up.
60 *
61 *  If the CPU does not support a dedicated interrupt stack, then
62 *  the porter has two options: (1) execute interrupts on the
63 *  stack of the interrupted task, and (2) have RTEMS manage a dedicated
64 *  interrupt stack.
65 *
66 *  If this is TRUE, CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE.
67 *
68 *  Only one of CPU_HAS_SOFTWARE_INTERRUPT_STACK and
69 *  CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE.  It is
70 *  possible that both are FALSE for a particular CPU.  Although it
71 *  is unclear what that would imply about the interrupt processing
72 *  procedure on that CPU.
73 */
74
75#define CPU_HAS_SOFTWARE_INTERRUPT_STACK FALSE
76
77/*
78 *  Does this CPU have hardware support for a dedicated interrupt stack?
79 *
80 *  If TRUE, then it must be installed during initialization.
81 *  If FALSE, then no installation is performed.
82 *
83 *  If this is TRUE, CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE.
84 *
85 *  Only one of CPU_HAS_SOFTWARE_INTERRUPT_STACK and
86 *  CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE.  It is
87 *  possible that both are FALSE for a particular CPU.  Although it
88 *  is unclear what that would imply about the interrupt processing
89 *  procedure on that CPU.
90 */
91
92/*
93 *  ACB: This is a lie, but it gets us a handle on a call to set up
94 *  a variable derived from the top of the interrupt stack.
95 */
96
97#define CPU_HAS_HARDWARE_INTERRUPT_STACK TRUE
98
99/*
100 *  Does RTEMS allocate a dedicated interrupt stack in the Interrupt Manager?
101 *
102 *  If TRUE, then the memory is allocated during initialization.
103 *  If FALSE, then the memory is allocated during initialization.
104 *
105 *  This should be TRUE is CPU_HAS_SOFTWARE_INTERRUPT_STACK is TRUE
106 *  or CPU_INSTALL_HARDWARE_INTERRUPT_STACK is TRUE.
107 */
108
109#define CPU_ALLOCATE_INTERRUPT_STACK TRUE
110
111/*
112 *  Does the RTEMS invoke the user's ISR with the vector number and
113 *  a pointer to the saved interrupt frame (1) or just the vector
114 *  number (0)?
115 */
116
117#define CPU_ISR_PASSES_FRAME_POINTER 1
118
119/*
120 *  Should the saving of the floating point registers be deferred
121 *  until a context switch is made to another different floating point
122 *  task?
123 *
124 *  If TRUE, then the floating point context will not be stored until
125 *  necessary.  It will remain in the floating point registers and not
126 *  disturned until another floating point task is switched to.
127 *
128 *  If FALSE, then the floating point context is saved when a floating
129 *  point task is switched out and restored when the next floating point
130 *  task is restored.  The state of the floating point registers between
131 *  those two operations is not specified.
132 *
133 *  If the floating point context does NOT have to be saved as part of
134 *  interrupt dispatching, then it should be safe to set this to TRUE.
135 *
136 *  Setting this flag to TRUE results in using a different algorithm
137 *  for deciding when to save and restore the floating point context.
138 *  The deferred FP switch algorithm minimizes the number of times
139 *  the FP context is saved and restored.  The FP context is not saved
140 *  until a context switch is made to another, different FP task.
141 *  Thus in a system with only one FP task, the FP context will never
142 *  be saved or restored.
143 */
144/*
145 *  ACB Note:  This could make debugging tricky..
146 */
147
148#define CPU_USE_DEFERRED_FP_SWITCH       TRUE
149
150/*
151 *  The following defines the number of bits actually used in the
152 *  interrupt field of the task mode.  How those bits map to the
153 *  CPU interrupt levels is defined by the routine _CPU_ISR_Set_level().
154 *
155 *  The interrupt level is bit mapped for the PowerPC family. The
156 *  bits are set to 0 to indicate that a particular exception source
157 *  enabled and 1 if it is disabled.  This keeps with RTEMS convention
158 *  that interrupt level 0 means all sources are enabled.
159 *
160 *  The bits are assigned to correspond to enable bits in the MSR.
161 */
162
163#define PPC_INTERRUPT_LEVEL_ME   0x01
164#define PPC_INTERRUPT_LEVEL_EE   0x02
165#define PPC_INTERRUPT_LEVEL_CE   0x04
166
167/* XXX should these be maskable? */
168#if 0
169#define PPC_INTERRUPT_LEVEL_DE   0x08
170#define PPC_INTERRUPT_LEVEL_BE   0x10
171#define PPC_INTERRUPT_LEVEL_SE   0x20
172#endif
173
174#define CPU_MODES_INTERRUPT_MASK   0x00000007
175
176/*
177 *  Processor defined structures required for cpukit/score.
178 */
179
180#ifndef ASM
181/*
182 *  The following table contains the information required to configure
183 *  the PowerPC processor specific parameters.
184 */
185
186typedef struct {
187  void       (*pretasking_hook)( void );
188  void       (*predriver_hook)( void );
189  void       (*postdriver_hook)( void );
190  void       (*idle_task)( void );
191  boolean      do_zero_of_workspace;
192  uint32_t     idle_task_stack_size;
193  uint32_t     interrupt_stack_size;
194  uint32_t     extra_mpci_receive_server_stack;
195  void *     (*stack_allocate_hook)( uint32_t   );
196  void       (*stack_free_hook)( void* );
197  /* end of fields required on all CPUs */
198
199  uint32_t     clicks_per_usec;        /* Timer clicks per microsecond */
200  void       (*spurious_handler)(uint32_t   vector, CPU_Interrupt_frame *);
201  boolean      exceptions_in_RAM;     /* TRUE if in RAM */
202
203#if (defined(ppc403) || defined(ppc405) \
204  || defined(mpc860) || defined(mpc821) || defined(mpc8260))
205  uint32_t     serial_per_sec;         /* Serial clocks per second */
206  boolean      serial_external_clock;
207  boolean      serial_xon_xoff;
208  boolean      serial_cts_rts;
209  uint32_t     serial_rate;
210  uint32_t     timer_average_overhead; /* Average overhead of timer in ticks */
211  uint32_t     timer_least_valid;      /* Least valid number from timer      */
212  boolean      timer_internal_clock;   /* TRUE, when timer runs with CPU clk */
213#endif
214
215#if (defined(mpc555) \
216  || defined(mpc860) || defined(mpc821) || defined(mpc8260))
217  uint32_t     clock_speed;            /* Speed of CPU in Hz */
218#endif
219}   rtems_cpu_table;
220#endif
221
222/*
223 *  Macros to access required entires in the CPU Table are in
224 *  the file rtems/system.h.
225 */
226
227/*
228 *  Macros to access PowerPC specific additions to the CPU Table
229 */
230
231#ifndef ASM
232#define rtems_cpu_configuration_get_spurious_handler() \
233   (_CPU_Table.spurious_handler)
234#endif /* ASM */
235
236/*
237 *  The following type defines an entry in the PPC's trap table.
238 *
239 *  NOTE: The instructions chosen are RTEMS dependent although one is
240 *        obligated to use two of the four instructions to perform a
241 *        long jump.  The other instructions load one register with the
242 *        trap type (a.k.a. vector) and another with the psr.
243 */
244 
245#ifndef ASM
246typedef struct {
247  uint32_t     stwu_r1;                       /* stwu  %r1, -(??+IP_END)(%1)*/
248  uint32_t     stw_r0;                        /* stw   %r0, IP_0(%r1)       */
249  uint32_t     li_r0_IRQ;                     /* li    %r0, _IRQ            */
250  uint32_t     b_Handler;                     /* b     PROC (_ISR_Handler)  */
251} CPU_Trap_table_entry;
252#endif
253
254/*
255 *  This variable is optional.  It is used on CPUs on which it is difficult
256 *  to generate an "uninitialized" FP context.  It is filled in by
257 *  _CPU_Initialize and copied into the task's FP context area during
258 *  _CPU_Context_Initialize.
259 */
260
261#ifndef ASM
262/* EXTERN Context_Control_fp  _CPU_Null_fp_context; */
263#endif
264
265/*
266 *  On some CPUs, RTEMS supports a software managed interrupt stack.
267 *  This stack is allocated by the Interrupt Manager and the switch
268 *  is performed in _ISR_Handler.  These variables contain pointers
269 *  to the lowest and highest addresses in the chunk of memory allocated
270 *  for the interrupt stack.  Since it is unknown whether the stack
271 *  grows up or down (in general), this give the CPU dependent
272 *  code the option of picking the version it wants to use.
273 *
274 *  NOTE: These two variables are required if the macro
275 *        CPU_HAS_SOFTWARE_INTERRUPT_STACK is defined as TRUE.
276 */
277
278#ifndef ASM
279SCORE_EXTERN void               *_CPU_Interrupt_stack_low;
280SCORE_EXTERN void               *_CPU_Interrupt_stack_high;
281#endif
282
283/*
284 *  With some compilation systems, it is difficult if not impossible to
285 *  call a high-level language routine from assembly language.  This
286 *  is especially true of commercial Ada compilers and name mangling
287 *  C++ ones.  This variable can be optionally defined by the CPU porter
288 *  and contains the address of the routine _Thread_Dispatch.  This
289 *  can make it easier to invoke that routine at the end of the interrupt
290 *  sequence (if a dispatch is necessary).
291 */
292
293#ifndef ASM
294/* EXTERN void           (*_CPU_Thread_dispatch_pointer)(); */
295#endif
296
297/*
298 *  Nothing prevents the porter from declaring more CPU specific variables.
299 */
300
301
302#ifndef ASM
303SCORE_EXTERN struct {
304  uint32_t   volatile* Nest_level;
305  uint32_t   volatile* Disable_level;
306  void *Vector_table;
307  void *Stack;
308  uint32_t   Default_r2;
309  uint32_t   Default_r13;
310  volatile boolean *Switch_necessary;
311  boolean *Signal;
312
313  uint32_t   msr_initial;
314} _CPU_IRQ_info CPU_STRUCTURE_ALIGNMENT;
315#endif
316
317/*
318 *  The size of the floating point context area.  On some CPUs this
319 *  will not be a "sizeof" because the format of the floating point
320 *  area is not defined -- only the size is.  This is usually on
321 *  CPUs with a "floating point save context" instruction.
322 */
323
324#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp )
325
326/*
327 * (Optional) # of bytes for libmisc/stackchk to check
328 * If not specifed, then it defaults to something reasonable
329 * for most architectures.
330 */
331
332#define CPU_STACK_CHECK_SIZE    (128)
333
334/*
335 *  Amount of extra stack (above minimum stack size) required by
336 *  MPCI receive server thread.  Remember that in a multiprocessor
337 *  system this thread must exist and be able to process all directives.
338 */
339
340#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0
341
342/*
343 *  This defines the number of entries in the ISR_Vector_table managed
344 *  by RTEMS.
345 */
346
347#define CPU_INTERRUPT_NUMBER_OF_VECTORS     (PPC_INTERRUPT_MAX)
348#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER (PPC_INTERRUPT_MAX - 1)
349
350/*
351 *  This is defined if the port has a special way to report the ISR nesting
352 *  level.  Most ports maintain the variable _ISR_Nest_level.
353 */
354
355#define CPU_PROVIDES_ISR_IS_IN_PROGRESS TRUE
356
357/*
358 *  ISR handler macros
359 */
360
361#ifndef ASM
362void _CPU_Initialize_vectors(void);
363#endif
364
365/*
366 *  Disable all interrupts for an RTEMS critical section.  The previous
367 *  level is returned in _isr_cookie.
368 */
369
370#ifndef ASM
371extern const unsigned int _PPC_MSR_DISABLE_MASK;
372
373#define _CPU_MSR_GET( _msr_value ) \
374  do { \
375    _msr_value = 0; \
376    asm volatile ("mfmsr %0" : "=&r" ((_msr_value)) : "0" ((_msr_value))); \
377  } while (0)
378
379/* FIXME: Backward compatibility
380 * new-exception-processing uses _CPU_MSR_GET
381 * old-exception-processing had used _CPU_MSR_Value
382 */
383#define _CPU_MSR_Value(_msr_value) _CPU_MSR_GET(_msr_value)
384
385#define _CPU_MSR_SET( _msr_value ) \
386{ asm volatile ("mtmsr %0" : "=&r" ((_msr_value)) : "0" ((_msr_value))); }
387
388#if 0
389#define _CPU_ISR_Disable( _isr_cookie ) \
390  { register unsigned int _disable_mask = _PPC_MSR_DISABLE_MASK; \
391    _isr_cookie = 0; \
392    asm volatile (
393        "mfmsr %0" : \
394        "=r" ((_isr_cookie)) : \
395        "0" ((_isr_cookie)) \
396    ); \
397    asm volatile (
398        "andc %1,%0,%1" : \
399        "=r" ((_isr_cookie)), "=&r" ((_disable_mask)) : \
400        "0" ((_isr_cookie)), "1" ((_disable_mask)) \
401    ); \
402    asm volatile (
403        "mtmsr %1" : \
404        "=r" ((_disable_mask)) : \
405        "0" ((_disable_mask)) \
406    ); \
407  }
408#endif
409
410#define _CPU_ISR_Disable( _isr_cookie ) \
411  { register unsigned int _disable_mask = _PPC_MSR_DISABLE_MASK; \
412    _isr_cookie = 0; \
413    asm volatile ( \
414        "mfmsr %0; andc %1,%0,%1; mtmsr %1" : \
415        "=&r" ((_isr_cookie)), "=&r" ((_disable_mask)) : \
416        "0" ((_isr_cookie)), "1" ((_disable_mask)) \
417        ); \
418  }
419#endif
420
421/*
422 *  Enable interrupts to the previous level (returned by _CPU_ISR_Disable).
423 *  This indicates the end of an RTEMS critical section.  The parameter
424 *  _isr_cookie is not modified.
425 */
426
427#ifndef ASM
428#define _CPU_ISR_Enable( _isr_cookie )  \
429  { \
430     asm volatile ( "mtmsr %0" : \
431                   "=r" ((_isr_cookie)) : \
432                   "0" ((_isr_cookie))); \
433  }
434#endif
435
436/*
437 *  This temporarily restores the interrupt to _isr_cookie before immediately
438 *  disabling them again.  This is used to divide long RTEMS critical
439 *  sections into two or more parts.  The parameter _isr_cookie is not
440 *  modified.
441 *
442 *  NOTE:  The version being used is not very optimized but it does
443 *         not trip a problem in gcc where the disable mask does not
444 *         get loaded.  Check this for future (post 10/97 gcc versions.
445 */
446
447#ifndef ASM
448#define _CPU_ISR_Flash( _isr_cookie ) \
449  { register unsigned int _disable_mask = _PPC_MSR_DISABLE_MASK; \
450    asm volatile ( \
451      "mtmsr %0; andc %1,%0,%1; mtmsr %1" : \
452      "=r" ((_isr_cookie)), "=r" ((_disable_mask)) : \
453      "0" ((_isr_cookie)), "1" ((_disable_mask)) \
454    ); \
455  }
456#endif
457
458/*
459 *  Map interrupt level in task mode onto the hardware that the CPU
460 *  actually provides.  Currently, interrupt levels which do not
461 *  map onto the CPU in a generic fashion are undefined.  Someday,
462 *  it would be nice if these were "mapped" by the application
463 *  via a callout.  For example, m68k has 8 levels 0 - 7, levels
464 *  8 - 255 would be available for bsp/application specific meaning.
465 *  This could be used to manage a programmable interrupt controller
466 *  via the rtems_task_mode directive.
467 */
468
469#ifndef ASM
470uint32_t   _CPU_ISR_Calculate_level(
471  uint32_t   new_level
472);
473
474void _CPU_ISR_Set_level(
475  uint32_t   new_level
476);
477 
478uint32_t   _CPU_ISR_Get_level( void );
479
480void _CPU_ISR_install_raw_handler(
481  uint32_t    vector,
482  proc_ptr    new_handler,
483  proc_ptr   *old_handler
484);
485#endif
486
487/* end of ISR handler macros */
488
489/* Fatal Error manager macros */
490
491/*
492 *  This routine copies _error into a known place -- typically a stack
493 *  location or a register, optionally disables interrupts, and
494 *  halts/stops the CPU.
495 */
496
497#define _CPU_Fatal_halt( _error ) \
498  _CPU_Fatal_error(_error)
499
500/* end of Fatal Error manager macros */
501
502
503#ifdef __cplusplus
504}
505#endif
506
507#endif
Note: See TracBrowser for help on using the repository browser.