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

4.104.114.95
Last change on this file since e7344db9 was e7344db9, checked in by Joel Sherrill <joel.sherrill@…>, on 12/06/07 at 23:23:05

2007-12-06 Joel Sherrill <joel.sherrill@…>

  • rtems/old-exceptions/cpu.h: Remove extra ifndef.
  • Property mode set to 100644
File size: 13.5 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-2007.
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 */
107
108#define CPU_ALLOCATE_INTERRUPT_STACK TRUE
109
110/*
111 *  Does the RTEMS invoke the user's ISR with the vector number and
112 *  a pointer to the saved interrupt frame (1) or just the vector
113 *  number (0)?
114 */
115
116#define CPU_ISR_PASSES_FRAME_POINTER 1
117
118/*
119 *  Should the saving of the floating point registers be deferred
120 *  until a context switch is made to another different floating point
121 *  task?
122 *
123 *  If TRUE, then the floating point context will not be stored until
124 *  necessary.  It will remain in the floating point registers and not
125 *  disturned until another floating point task is switched to.
126 *
127 *  If FALSE, then the floating point context is saved when a floating
128 *  point task is switched out and restored when the next floating point
129 *  task is restored.  The state of the floating point registers between
130 *  those two operations is not specified.
131 *
132 *  If the floating point context does NOT have to be saved as part of
133 *  interrupt dispatching, then it should be safe to set this to TRUE.
134 *
135 *  Setting this flag to TRUE results in using a different algorithm
136 *  for deciding when to save and restore the floating point context.
137 *  The deferred FP switch algorithm minimizes the number of times
138 *  the FP context is saved and restored.  The FP context is not saved
139 *  until a context switch is made to another, different FP task.
140 *  Thus in a system with only one FP task, the FP context will never
141 *  be saved or restored.
142 */
143/*
144 *  ACB Note:  This could make debugging tricky..
145 */
146
147#define CPU_USE_DEFERRED_FP_SWITCH       TRUE
148
149/*
150 *  The following defines the number of bits actually used in the
151 *  interrupt field of the task mode.  How those bits map to the
152 *  CPU interrupt levels is defined by the routine _CPU_ISR_Set_level().
153 *
154 *  The interrupt level is bit mapped for the PowerPC family. The
155 *  bits are set to 0 to indicate that a particular exception source
156 *  enabled and 1 if it is disabled.  This keeps with RTEMS convention
157 *  that interrupt level 0 means all sources are enabled.
158 *
159 *  The bits are assigned to correspond to enable bits in the MSR.
160 */
161
162#define PPC_INTERRUPT_LEVEL_ME   0x01
163#define PPC_INTERRUPT_LEVEL_EE   0x02
164#define PPC_INTERRUPT_LEVEL_CE   0x04
165
166/* XXX should these be maskable? */
167#if 0
168#define PPC_INTERRUPT_LEVEL_DE   0x08
169#define PPC_INTERRUPT_LEVEL_BE   0x10
170#define PPC_INTERRUPT_LEVEL_SE   0x20
171#endif
172
173#define CPU_MODES_INTERRUPT_MASK   0x00000007
174
175/*
176 *  Processor defined structures required for cpukit/score.
177 */
178
179/*
180 *  The following type defines an entry in the PPC's trap table.
181 *
182 *  NOTE: The instructions chosen are RTEMS dependent although one is
183 *        obligated to use two of the four instructions to perform a
184 *        long jump.  The other instructions load one register with the
185 *        trap type (a.k.a. vector) and another with the psr.
186 */
187 
188#ifndef ASM
189typedef struct {
190  uint32_t     stwu_r1;                       /* stwu  %r1, -(??+IP_END)(%1)*/
191  uint32_t     stw_r0;                        /* stw   %r0, IP_0(%r1)       */
192  uint32_t     li_r0_IRQ;                     /* li    %r0, _IRQ            */
193  uint32_t     b_Handler;                     /* b     PROC (_ISR_Handler)  */
194} CPU_Trap_table_entry;
195#endif
196
197/*
198 *  This variable is optional.  It is used on CPUs on which it is difficult
199 *  to generate an "uninitialized" FP context.  It is filled in by
200 *  _CPU_Initialize and copied into the task's FP context area during
201 *  _CPU_Context_Initialize.
202 */
203
204#ifndef ASM
205/* EXTERN Context_Control_fp  _CPU_Null_fp_context; */
206#endif
207
208/*
209 *  On some CPUs, RTEMS supports a software managed interrupt stack.
210 *  This stack is allocated by the Interrupt Manager and the switch
211 *  is performed in _ISR_Handler.  These variables contain pointers
212 *  to the lowest and highest addresses in the chunk of memory allocated
213 *  for the interrupt stack.  Since it is unknown whether the stack
214 *  grows up or down (in general), this give the CPU dependent
215 *  code the option of picking the version it wants to use.
216 *
217 *  NOTE: These two variables are required if the macro
218 *        CPU_HAS_SOFTWARE_INTERRUPT_STACK is defined as TRUE.
219 */
220
221#ifndef ASM
222SCORE_EXTERN void               *_CPU_Interrupt_stack_low;
223SCORE_EXTERN void               *_CPU_Interrupt_stack_high;
224#endif
225
226/*
227 *  With some compilation systems, it is difficult if not impossible to
228 *  call a high-level language routine from assembly language.  This
229 *  is especially true of commercial Ada compilers and name mangling
230 *  C++ ones.  This variable can be optionally defined by the CPU porter
231 *  and contains the address of the routine _Thread_Dispatch.  This
232 *  can make it easier to invoke that routine at the end of the interrupt
233 *  sequence (if a dispatch is necessary).
234 */
235
236#ifndef ASM
237/* EXTERN void           (*_CPU_Thread_dispatch_pointer)(); */
238#endif
239
240/*
241 *  Nothing prevents the porter from declaring more CPU specific variables.
242 */
243
244
245#ifndef ASM
246SCORE_EXTERN struct {
247  uint32_t   volatile* Nest_level;
248  uint32_t   volatile* Disable_level;
249  void *Vector_table;
250  void *Stack;
251  uint32_t   Default_r2;
252  uint32_t   Default_r13;
253  volatile boolean *Switch_necessary;
254  boolean *Signal;
255
256  uint32_t   msr_initial;
257} _CPU_IRQ_info CPU_STRUCTURE_ALIGNMENT;
258#endif
259
260/*
261 *  The size of the floating point context area.  On some CPUs this
262 *  will not be a "sizeof" because the format of the floating point
263 *  area is not defined -- only the size is.  This is usually on
264 *  CPUs with a "floating point save context" instruction.
265 */
266
267#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp )
268
269/*
270 * (Optional) # of bytes for libmisc/stackchk to check
271 * If not specifed, then it defaults to something reasonable
272 * for most architectures.
273 */
274
275#define CPU_STACK_CHECK_SIZE    (128)
276
277/*
278 *  Amount of extra stack (above minimum stack size) required by
279 *  MPCI receive server thread.  Remember that in a multiprocessor
280 *  system this thread must exist and be able to process all directives.
281 */
282
283#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0
284
285/*
286 *  This defines the number of entries in the ISR_Vector_table managed
287 *  by RTEMS.
288 */
289
290#define CPU_INTERRUPT_NUMBER_OF_VECTORS     (PPC_INTERRUPT_MAX)
291#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER (PPC_INTERRUPT_MAX - 1)
292
293/*
294 *  This is defined if the port has a special way to report the ISR nesting
295 *  level.  Most ports maintain the variable _ISR_Nest_level.
296 */
297
298#define CPU_PROVIDES_ISR_IS_IN_PROGRESS TRUE
299
300/*
301 *  ISR handler macros
302 */
303
304#ifndef ASM
305void _CPU_Initialize_vectors(void);
306#endif
307
308/*
309 *  Disable all interrupts for an RTEMS critical section.  The previous
310 *  level is returned in _isr_cookie.
311 */
312
313#ifndef ASM
314extern const unsigned int _PPC_MSR_DISABLE_MASK;
315
316#define _CPU_MSR_GET( _msr_value ) \
317  do { \
318    _msr_value = 0; \
319    asm volatile ("mfmsr %0" : "=&r" ((_msr_value)) : "0" ((_msr_value))); \
320  } while (0)
321
322/* FIXME: Backward compatibility
323 * new-exception-processing uses _CPU_MSR_GET
324 * old-exception-processing had used _CPU_MSR_Value
325 */
326#define _CPU_MSR_Value(_msr_value) _CPU_MSR_GET(_msr_value)
327
328#define _CPU_MSR_SET( _msr_value ) \
329{ asm volatile ("mtmsr %0" : "=&r" ((_msr_value)) : "0" ((_msr_value))); }
330
331#if 0
332#define _CPU_ISR_Disable( _isr_cookie ) \
333  { register unsigned int _disable_mask = _PPC_MSR_DISABLE_MASK; \
334    _isr_cookie = 0; \
335    asm volatile (
336        "mfmsr %0" : \
337        "=r" ((_isr_cookie)) : \
338        "0" ((_isr_cookie)) \
339    ); \
340    asm volatile (
341        "andc %1,%0,%1" : \
342        "=r" ((_isr_cookie)), "=&r" ((_disable_mask)) : \
343        "0" ((_isr_cookie)), "1" ((_disable_mask)) \
344    ); \
345    asm volatile (
346        "mtmsr %1" : \
347        "=r" ((_disable_mask)) : \
348        "0" ((_disable_mask)) \
349    ); \
350  }
351#endif
352
353#define _CPU_ISR_Disable( _isr_cookie ) \
354  { register unsigned int _disable_mask = _PPC_MSR_DISABLE_MASK; \
355    _isr_cookie = 0; \
356    asm volatile ( \
357        "mfmsr %0; andc %1,%0,%1; mtmsr %1" : \
358        "=&r" ((_isr_cookie)), "=&r" ((_disable_mask)) : \
359        "0" ((_isr_cookie)), "1" ((_disable_mask)) \
360        ); \
361  }
362#endif
363
364/*
365 *  Enable interrupts to the previous level (returned by _CPU_ISR_Disable).
366 *  This indicates the end of an RTEMS critical section.  The parameter
367 *  _isr_cookie is not modified.
368 */
369
370#ifndef ASM
371#define _CPU_ISR_Enable( _isr_cookie )  \
372  { \
373     asm volatile ( "mtmsr %0" : \
374                   "=r" ((_isr_cookie)) : \
375                   "0" ((_isr_cookie))); \
376  }
377#endif
378
379/*
380 *  This temporarily restores the interrupt to _isr_cookie before immediately
381 *  disabling them again.  This is used to divide long RTEMS critical
382 *  sections into two or more parts.  The parameter _isr_cookie is not
383 *  modified.
384 *
385 *  NOTE:  The version being used is not very optimized but it does
386 *         not trip a problem in gcc where the disable mask does not
387 *         get loaded.  Check this for future (post 10/97 gcc versions.
388 */
389
390#ifndef ASM
391#define _CPU_ISR_Flash( _isr_cookie ) \
392  { register unsigned int _disable_mask = _PPC_MSR_DISABLE_MASK; \
393    asm volatile ( \
394      "mtmsr %0; andc %1,%0,%1; mtmsr %1" : \
395      "=&r" ((_isr_cookie)), "=&r" ((_disable_mask)) : \
396      "0" ((_isr_cookie)), "1" ((_disable_mask)) \
397    ); \
398  }
399#endif
400
401/*
402 *  Map interrupt level in task mode onto the hardware that the CPU
403 *  actually provides.  Currently, interrupt levels which do not
404 *  map onto the CPU in a generic fashion are undefined.  Someday,
405 *  it would be nice if these were "mapped" by the application
406 *  via a callout.  For example, m68k has 8 levels 0 - 7, levels
407 *  8 - 255 would be available for bsp/application specific meaning.
408 *  This could be used to manage a programmable interrupt controller
409 *  via the rtems_task_mode directive.
410 */
411
412#ifndef ASM
413uint32_t   _CPU_ISR_Calculate_level(
414  uint32_t   new_level
415);
416
417void _CPU_ISR_Set_level(
418  uint32_t   new_level
419);
420 
421uint32_t   _CPU_ISR_Get_level( void );
422
423void _CPU_ISR_install_raw_handler(
424  uint32_t    vector,
425  proc_ptr    new_handler,
426  proc_ptr   *old_handler
427);
428#endif
429
430/* end of ISR handler macros */
431
432/* Fatal Error manager macros */
433
434/*
435 *  This routine copies _error into a known place -- typically a stack
436 *  location or a register, optionally disables interrupts, and
437 *  halts/stops the CPU.
438 */
439
440#define _CPU_Fatal_halt( _error ) \
441  _CPU_Fatal_error(_error)
442
443/* end of Fatal Error manager macros */
444
445
446#ifdef __cplusplus
447}
448#endif
449
450#endif
Note: See TracBrowser for help on using the repository browser.