source: rtems/cpukit/score/cpu/powerpc/rtems/new-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: 11.4 KB
Line 
1/*  cpu.h
2 *
3 *  This include file contains information pertaining to the PowerPC
4 *  processor.
5 *
6 *  Modified for MPC8260 Andy Dachs <a.dachs@sstl.co.uk>
7 *  Surrey Satellite Technology Limited (SSTL), 2001
8 *
9 *  Author:     Andrew Bray <andy@i-cubed.co.uk>
10 *
11 *  COPYRIGHT (c) 1995 by i-cubed ltd.
12 *
13 *  To anyone who acknowledges that this file is provided "AS IS"
14 *  without any express or implied warranty:
15 *      permission to use, copy, modify, and distribute this file
16 *      for any purpose is hereby granted without fee, provided that
17 *      the above copyright notice and this notice appears in all
18 *      copies, and that the name of i-cubed limited not be used in
19 *      advertising or publicity pertaining to distribution of the
20 *      software without specific, written prior permission.
21 *      i-cubed limited makes no representations about the suitability
22 *      of this software for any purpose.
23 *
24 *  Derived from c/src/exec/cpu/no_cpu/cpu.h:
25 *
26 *  COPYRIGHT (c) 1989-1997.
27 *  On-Line Applications Research Corporation (OAR).
28 *
29 *  The license and distribution terms for this file may be found in
30 *  the file LICENSE in this distribution or at
31 *  http://www.rtems.com/license/LICENSE.
32 *
33 *  $Id$
34 */
35
36#ifndef _RTEMS_NEW_EXCEPTIONS_CPU_H
37#define _RTEMS_NEW_EXCEPTIONS_CPU_H
38
39#ifndef _RTEMS_SCORE_CPU_H
40#error "You should include <rtems/score/cpu.h>"
41#endif
42
43#include <rtems/powerpc/registers.h>
44
45#ifdef __cplusplus
46extern "C" {
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 TRUE
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#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE
93
94/*
95 *  Does RTEMS allocate a dedicated interrupt stack in the Interrupt Manager?
96 *
97 *  If TRUE, then the memory is allocated during initialization.
98 *  If FALSE, then the memory is allocated during initialization.
99 *
100 *  This should be TRUE is CPU_HAS_SOFTWARE_INTERRUPT_STACK is TRUE
101 *  or CPU_INSTALL_HARDWARE_INTERRUPT_STACK is TRUE.
102 */
103
104#define CPU_ALLOCATE_INTERRUPT_STACK FALSE
105
106/*
107 *  Does the RTEMS invoke the user's ISR with the vector number and
108 *  a pointer to the saved interrupt frame (1) or just the vector
109 *  number (0)?
110 */
111
112#define CPU_ISR_PASSES_FRAME_POINTER 0
113
114/*
115 *  Should the saving of the floating point registers be deferred
116 *  until a context switch is made to another different floating point
117 *  task?
118 *
119 *  If TRUE, then the floating point context will not be stored until
120 *  necessary.  It will remain in the floating point registers and not
121 *  disturned until another floating point task is switched to.
122 *
123 *  If FALSE, then the floating point context is saved when a floating
124 *  point task is switched out and restored when the next floating point
125 *  task is restored.  The state of the floating point registers between
126 *  those two operations is not specified.
127 *
128 *  If the floating point context does NOT have to be saved as part of
129 *  interrupt dispatching, then it should be safe to set this to TRUE.
130 *
131 *  Setting this flag to TRUE results in using a different algorithm
132 *  for deciding when to save and restore the floating point context.
133 *  The deferred FP switch algorithm minimizes the number of times
134 *  the FP context is saved and restored.  The FP context is not saved
135 *  until a context switch is made to another, different FP task.
136 *  Thus in a system with only one FP task, the FP context will never
137 *  be saved or restored.
138 *
139 *  Note, however that compilers may use floating point registers/
140 *  instructions for optimization or they may save/restore FP registers
141 *  on the stack. You must not use deferred switching in these cases
142 *  and on the PowerPC attempting to do so will raise a "FP unavailable"
143 *  exception.
144 */
145/*
146 *  ACB Note:  This could make debugging tricky..
147 */
148
149/* conservative setting (FALSE); probably doesn't affect performance too much */
150#define CPU_USE_DEFERRED_FP_SWITCH       FALSE
151
152/*
153 *  Processor defined structures required for cpukit/score.
154 */
155
156#ifndef ASM
157 
158/*
159 *  The following table contains the information required to configure
160 *  the PowerPC processor specific parameters.
161 */
162
163typedef struct {
164  void       (*pretasking_hook)( void );
165  void       (*predriver_hook)( void );
166  void       (*postdriver_hook)( void );
167  void       (*idle_task)( void );
168  boolean      do_zero_of_workspace;
169  uint32_t     idle_task_stack_size;
170  uint32_t     interrupt_stack_size;
171  uint32_t     extra_mpci_receive_server_stack;
172  void *     (*stack_allocate_hook)( uint32_t   );
173  void       (*stack_free_hook)( void* );
174  /* end of fields required on all CPUs */
175
176  uint32_t     clicks_per_usec;        /* Timer clicks per microsecond */
177  boolean      exceptions_in_RAM;     /* TRUE if in RAM */
178
179#if (defined(ppc403) || defined(ppc405) \
180  || defined(mpc860) || defined(mpc821) || defined(mpc8260))
181  uint32_t     serial_per_sec;         /* Serial clocks per second */
182  boolean      serial_external_clock;
183  boolean      serial_xon_xoff;
184  boolean      serial_cts_rts;
185  uint32_t     serial_rate;
186  uint32_t     timer_average_overhead; /* Average overhead of timer in ticks */
187  uint32_t     timer_least_valid;      /* Least valid number from timer      */
188  boolean      timer_internal_clock;   /* TRUE, when timer runs with CPU clk */
189#endif
190
191#if (defined(mpc555) \
192  || defined(mpc860) || defined(mpc821) || defined(mpc8260))
193  uint32_t     clock_speed;            /* Speed of CPU in Hz */
194#endif
195}   rtems_cpu_table;
196
197/*
198 *  Macros to access required entires in the CPU Table are in
199 *  the file rtems/system.h.
200 */
201
202/*
203 *  This variable is optional.  It is used on CPUs on which it is difficult
204 *  to generate an "uninitialized" FP context.  It is filled in by
205 *  _CPU_Initialize and copied into the task's FP context area during
206 *  _CPU_Context_Initialize.
207 */
208
209/* EXTERN Context_Control_fp  _CPU_Null_fp_context; */
210
211/*
212 *  On some CPUs, RTEMS supports a software managed interrupt stack.
213 *  This stack is allocated by the Interrupt Manager and the switch
214 *  is performed in _ISR_Handler.  These variables contain pointers
215 *  to the lowest and highest addresses in the chunk of memory allocated
216 *  for the interrupt stack.  Since it is unknown whether the stack
217 *  grows up or down (in general), this give the CPU dependent
218 *  code the option of picking the version it wants to use.
219 *
220 *  NOTE: These two variables are required if the macro
221 *        CPU_HAS_SOFTWARE_INTERRUPT_STACK is defined as TRUE.
222 */
223
224SCORE_EXTERN void               *_CPU_Interrupt_stack_low;
225SCORE_EXTERN void               *_CPU_Interrupt_stack_high;
226
227#endif /* ndef ASM */
228
229/*
230 *  This defines the number of levels and the mask used to pick those
231 *  bits out of a thread mode.
232 */
233
234#define CPU_MODES_INTERRUPT_LEVEL  0x00000001 /* interrupt level in mode */
235#define CPU_MODES_INTERRUPT_MASK   0x00000001 /* interrupt level in mode */
236
237/*
238 *  With some compilation systems, it is difficult if not impossible to
239 *  call a high-level language routine from assembly language.  This
240 *  is especially true of commercial Ada compilers and name mangling
241 *  C++ ones.  This variable can be optionally defined by the CPU porter
242 *  and contains the address of the routine _Thread_Dispatch.  This
243 *  can make it easier to invoke that routine at the end of the interrupt
244 *  sequence (if a dispatch is necessary).
245 */
246
247/* EXTERN void           (*_CPU_Thread_dispatch_pointer)(); */
248
249/*
250 *  Nothing prevents the porter from declaring more CPU specific variables.
251 */
252
253#ifndef ASM
254 
255SCORE_EXTERN struct {
256  uint32_t   *Disable_level;
257  void *Stack;
258  volatile boolean *Switch_necessary;
259  boolean *Signal;
260
261} _CPU_IRQ_info CPU_STRUCTURE_ALIGNMENT;
262
263#endif /* ndef ASM */
264
265/*
266 *  The size of the floating point context area.  On some CPUs this
267 *  will not be a "sizeof" because the format of the floating point
268 *  area is not defined -- only the size is.  This is usually on
269 *  CPUs with a "floating point save context" instruction.
270 */
271
272#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp )
273
274/*
275 * (Optional) # of bytes for libmisc/stackchk to check
276 * If not specifed, then it defaults to something reasonable
277 * for most architectures.
278 */
279
280#define CPU_STACK_CHECK_SIZE    (128)
281
282/*
283 *  Amount of extra stack (above minimum stack size) required by
284 *  MPCI receive server thread.  Remember that in a multiprocessor
285 *  system this thread must exist and be able to process all directives.
286 */
287
288#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0
289
290/*
291 *  This defines the number of entries in the ISR_Vector_table managed
292 *  by RTEMS.
293 */
294
295#define CPU_INTERRUPT_NUMBER_OF_VECTORS     (PPC_INTERRUPT_MAX)
296#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER (PPC_INTERRUPT_MAX - 1)
297
298/*
299 *  This is defined if the port has a special way to report the ISR nesting
300 *  level.  Most ports maintain the variable _ISR_Nest_level. Note that
301 *  this is not an option - RTEMS/score _relies_ on _ISR_Nest_level
302 *  being maintained (e.g. watchdog queues).
303 */
304
305#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE
306
307/*
308 *  ISR handler macros
309 */
310
311#define _CPU_Initialize_vectors()
312
313/*
314 *  Disable all interrupts for an RTEMS critical section.  The previous
315 *  level is returned in _isr_cookie.
316 */
317
318#ifndef ASM
319 
320static inline uint32_t   _CPU_ISR_Get_level( void )
321{
322  register unsigned int msr;
323  _CPU_MSR_GET(msr);
324  if (msr & MSR_EE) return 0;
325  else  return 1;
326}
327
328static inline void _CPU_ISR_Set_level( uint32_t   level )
329{
330  register unsigned int msr;
331  _CPU_MSR_GET(msr);
332  if (!(level & CPU_MODES_INTERRUPT_MASK)) {
333    msr |= MSR_EE;
334  }
335  else {
336    msr &= ~MSR_EE;
337  }
338  _CPU_MSR_SET(msr);
339}
340 
341void BSP_panic(char *);
342
343/* Fatal Error manager macros */
344
345/*
346 *  This routine copies _error into a known place -- typically a stack
347 *  location or a register, optionally disables interrupts, and
348 *  halts/stops the CPU.
349 */
350
351void _BSP_Fatal_error(unsigned int);
352
353#define _CPU_Fatal_halt( _error ) \
354  _BSP_Fatal_error(_error)
355
356/* end of Fatal Error manager macros */
357
358/*
359 *  Until all new-exception processing BSPs have fixed
360 *  PR288, we let the good BSPs pass
361 *
362 *  PPC_BSP_HAS_FIXED_PR288
363 *
364 *  in SPRG0 and let _CPU_Initialize assert this.
365 */
366
367#define PPC_BSP_HAS_FIXED_PR288 0x600dbabe
368
369#endif /* ASM */
370
371#ifdef __cplusplus
372}
373#endif
374
375#endif
Note: See TracBrowser for help on using the repository browser.