source: rtems/c/src/exec/score/cpu/powerpc/ppc.h @ 993e1b5

4.104.114.84.95
Last change on this file since 993e1b5 was 993e1b5, checked in by Joel Sherrill <joel.sherrill@…>, on 04/14/98 at 19:54:24

Refreshing effort from Avenger.

  • Property mode set to 100644
File size: 13.4 KB
Line 
1/*  ppc.h
2 *
3 *  This file contains definitions for the IBM/Motorola PowerPC
4 *  family members.
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/no_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.OARcorp.com/rtems/license.html.
29 *
30 *
31 * Note:
32 *      This file is included by both C and assembler code ( -DASM )
33 *
34 *  $Id$
35 */
36
37
38#ifndef _INCLUDE_PPC_h
39#define _INCLUDE_PPC_h
40
41#ifdef __cplusplus
42extern "C" {
43#endif
44
45/*
46 *  Define the name of the CPU family.
47 */
48
49#define CPU_NAME "PowerPC"
50
51/*
52 *  This file contains the information required to build
53 *  RTEMS for a particular member of the PowerPC family.  It does
54 *  this by setting variables to indicate which implementation
55 *  dependent features are present in a particular member
56 *  of the family.
57 *
58 *  The following architectural feature definitions are defaulted
59 *  unless specifically set by the model definition:
60 *
61 *    + PPC_DEBUG_MODEL          - PPC_DEBUG_MODEL_STANDARD
62 *    + PPC_INTERRUPT_MAX        - 16
63 *    + PPC_CACHE_ALIGNMENT      - 32
64 *    + PPC_LOW_POWER_MODE       - PPC_LOW_POWER_MODE_NONE
65 *    + PPC_HAS_EXCEPTION_PREFIX - 1
66 *    + PPC_HAS_FPU              - 1
67 *    + PPC_HAS_DOUBLE           - 1 if PPC_HAS_FPU,
68 *                               - 0 otherwise
69 *    + PPC_USE_MULTIPLE         - 0
70 */
71 
72/*
73 *  Define the debugging assistance models found in the PPC family.
74 *
75 *  Standard:         single step and branch trace
76 *  Single Step Only: single step only
77 *  IBM 4xx:          debug exception
78 */
79
80#define PPC_DEBUG_MODEL_STANDARD         1
81#define PPC_DEBUG_MODEL_SINGLE_STEP_ONLY 2
82#define PPC_DEBUG_MODEL_IBM4xx           3
83
84/*
85 *  Define the low power mode models
86 *
87 *  Standard:   as defined for 603e
88 *  Nap Mode:   nap mode only (604)
89 *  XXX 403GB, 603, 603e, 604, 821
90 */
91
92#define PPC_LOW_POWER_MODE_NONE      0
93#define PPC_LOW_POWER_MODE_STANDARD  1
94
95#if defined(ppc403)
96/*
97 *  IBM 403
98 *
99 *  Developed for 403GA.  Book checked for 403GB.
100 *
101 *  Does not have user mode.
102 */
103 
104#define CPU_MODEL_NAME "PowerPC 403"
105#define PPC_ALIGNMENT           4 
106#define PPC_CACHE_ALIGNMENT     16
107#define PPC_HAS_RFCI            1
108#define PPC_HAS_FPU             0
109#define PPC_USE_MULTIPLE        1
110#define PPC_I_CACHE             2048
111#define PPC_D_CACHE             1024
112
113#define PPC_DEBUG_MODEL          PPC_DEBUG_MODEL_IBM4xx
114#define PPC_HAS_EXCEPTION_PREFIX 0
115
116#elif defined(ppc601)
117/*
118 *  Submitted with original port -- book checked only.
119 */
120 
121#define CPU_MODEL_NAME  "PowerPC 601"
122
123#define PPC_ALIGNMENT           8
124#define PPC_USE_MULTIPLE        1
125#define PPC_I_CACHE             0
126#define PPC_D_CACHE             32768
127
128#define PPC_DEBUG_MODEL PPC_DEBUG_MODEL_SINGLE_STEP_ONLY
129
130#elif defined(ppc602)
131/*
132 *  Submitted with original port -- book checked only.
133 */
134 
135#define CPU_MODEL_NAME  "PowerPC 602"
136
137#define PPC_ALIGNMENT           4
138#define PPC_HAS_DOUBLE          0
139#define PPC_I_CACHE             4096
140#define PPC_D_CACHE             4096
141
142#elif defined(ppc603)
143/*
144 *  Submitted with original port -- book checked only.
145 */
146 
147#define CPU_MODEL_NAME  "PowerPC 603"
148
149#define PPC_ALIGNMENT           8
150#define PPC_I_CACHE             8192
151#define PPC_D_CACHE             8192
152
153#elif defined(ppc603e)
154 
155#define CPU_MODEL_NAME  "PowerPC 603e"
156/*
157 *  Submitted with original port.
158 *
159 *  Known to work on real hardware.
160 */
161
162#define PPC_ALIGNMENT           8
163#define PPC_I_CACHE             16384
164#define PPC_D_CACHE             16384
165
166#define PPC_LOW_POWER_MODE PPC_LOW_POWER_MODE_STANDARD
167
168#elif defined(ppc604)
169/*
170 *  Submitted with original port -- book checked only.
171 */
172 
173#define CPU_MODEL_NAME  "PowerPC 604"
174
175#define PPC_ALIGNMENT           8
176#define PPC_I_CACHE             16384
177#define PPC_D_CACHE             16384
178 
179#else
180 
181#error "Unsupported CPU Model"
182 
183#endif
184
185/*
186 *  Application binary interfaces.
187 *
188 *  PPC_ABI MUST be defined as one of these.
189 *  Only PPC_ABI_POWEROPEN is currently fully supported.
190 *  Only EABI will be supported in the end when
191 *  the tools are there.
192 *  Only big endian is currently supported.
193 */
194/*
195 *  PowerOpen ABI.  This is Andy's hack of the
196 *  PowerOpen ABI to ELF.  ELF rather than a
197 *  XCOFF assembler is used.  This may work
198 *  if PPC_ASM == PPC_ASM_XCOFF is defined.
199 */
200#define PPC_ABI_POWEROPEN       0
201/*
202 *  GCC 2.7.0 munched version of EABI, with
203 *  PowerOpen calling convention and stack frames,
204 *  but EABI style indirect function calls.
205 */
206#define PPC_ABI_GCC27           1
207/*
208 *  SVR4 ABI
209 */
210#define PPC_ABI_SVR4            2
211/*
212 *  Embedded ABI
213 */
214#define PPC_ABI_EABI            3
215
216#if (PPC_ABI == PPC_ABI_POWEROPEN)
217#define PPC_STACK_ALIGNMENT     8
218#elif (PPC_ABI == PPC_ABI_GCC27)
219#define PPC_STACK_ALIGNMENT     8
220#elif (PPC_ABI == PPC_ABI_SVR4)
221#define PPC_STACK_ALIGNMENT     16
222#elif (PPC_ABI == PPC_ABI_EABI)
223#define PPC_STACK_ALIGNMENT     8
224#else
225#error  "PPC_ABI is not properly defined"
226#endif
227#ifndef PPC_ABI
228#error  "PPC_ABI is not properly defined"
229#endif
230
231/*
232 *  Assemblers.
233 *  PPC_ASM MUST be defined as one of these.
234 *
235 *  PPC_ASM_ELF:   ELF assembler. Currently used for all ABIs.
236 *  PPC_ASM_XCOFF: XCOFF assembler. May be needed for PowerOpen ABI.
237 *
238 *  NOTE: Only PPC_ABI_ELF is currently fully supported.
239 */
240
241#define PPC_ASM_ELF   0
242#define PPC_ASM_XCOFF 1
243
244/*
245 *  Use the default debug scheme defined in the architectural specification
246 *  if another model has not been specified.
247 */
248
249#ifndef PPC_DEBUG_MODEL
250#define PPC_DEBUG_MODEL PPC_DEBUG_MODEL_STANDARD
251#endif
252
253/*
254 *  If the maximum number of exception sources has not been defined,
255 *  then default it to 16.
256 */
257
258#ifndef PPC_INTERRUPT_MAX
259#define PPC_INTERRUPT_MAX       16
260#endif
261
262/*
263 *  Unless specified otherwise, the cache line size is defaulted to 32.
264 *
265 *  The derive the power of 2 the cache line is.
266 */
267
268#ifndef PPC_CACHE_ALIGNMENT
269#define PPC_CACHE_ALIGNMENT 32
270#endif
271
272#if (PPC_CACHE_ALIGNMENT == 16)
273#define PPC_CACHE_ALIGN_POWER 4
274#elif (PPC_CACHE_ALIGNMENT == 32)
275#define PPC_CACHE_ALIGN_POWER 5
276#else
277#error "Undefined power of 2 for PPC_CACHE_ALIGNMENT"
278#endif
279
280/*
281 *  Unless otherwise specified, assume the model has an IP/EP bit to
282 *  set the exception address prefix.
283 */
284
285#ifndef PPC_HAS_EXCEPTION_PREFIX
286#define PPC_HAS_EXCEPTION_PREFIX 1
287#endif
288
289/*
290 *  If no low power mode model was specified, then assume there is none.
291 */
292
293#ifndef PPC_LOW_POWER_MODE
294#define PPC_LOW_POWER_MODE PPC_LOW_POWER_MODE_NONE
295#endif
296
297/*
298 *  Unless specified above, then assume the model has FP support.
299 */
300
301#ifndef PPC_HAS_FPU
302#define PPC_HAS_FPU 1
303#endif
304
305/*
306 *  Unless specified above, If the model has FP support, it is assumed to
307 *  support doubles (8-byte floating point numbers).
308 *
309 *  If the model does NOT have FP support, then the model does
310 *  NOT have double length FP registers.
311 */
312
313#ifndef PPC_HAS_DOUBLE
314#if (PPC_HAS_FPU)
315#define PPC_HAS_DOUBLE 1
316#else
317#define PPC_HAS_DOUBLE 0
318#endif
319#endif
320
321/*
322 *  Unless specified above, then assume the model does NOT have critical
323 *  interrupt support.
324 */
325
326#ifndef PPC_HAS_RFCI
327#define PPC_HAS_RFCI 0
328#endif
329
330/*
331 *  Unless specified above, do not use the load/store multiple instructions
332 *  in a context switch.
333 */
334
335#ifndef PPC_USE_MULTIPLE
336#define PPC_USE_MULTIPLE 0
337#endif
338
339/*
340 *  The following exceptions are not maskable, and are not
341 *  necessarily predictable, so cannot be offered to RTEMS:
342 *    Alignment exception - handled by the CPU module
343 *    Data exceptions.
344 *    Instruction exceptions.
345 */
346
347/*
348 *  Base Interrupt vectors supported on all models.
349 */
350#define PPC_IRQ_SYSTEM_RESET     0 /* 0x00100 - System reset.              */
351#define PPC_IRQ_MCHECK           1 /* 0x00200 - Machine check              */
352#define PPC_IRQ_PROTECT          2 /* 0x00300 - Protection violation       */
353#define PPC_IRQ_ISI              3 /* 0x00400 - Instruction Fetch error    */
354#define PPC_IRQ_EXTERNAL         4 /* 0x00500 - External interrupt         */
355#define PPC_IRQ_ALIGNMENT        5 /* 0X00600 - Alignment exception        */
356#define PPC_IRQ_PROGRAM          6 /* 0x00700 - Program exception          */
357#define PPC_IRQ_NOFP             7 /* 0x00800 - Floating point unavailable */
358#define PPC_IRQ_DECREMENTER      8 /* 0x00900 - Decrementer interrupt      */
359#define PPC_IRQ_RESERVED_A       9 /* 0x00a00 - Implementation Reserved    */
360#define PPC_IRQ_RESERVED_B      10 /* 0x00a00 - Implementation Reserved    */
361#define PPC_IRQ_SCALL           11 /* 0x00c00 - System call                */
362#define PPC_IRQ_TRACE           12 /* 0x00d00 - Trace Exception            */
363#define PPC_IRQ_FP_ASST         13 /* ox00e00 - Floating point assist      */
364#define PPC_STD_IRQ_LAST        PPC_IRQ_FP_ASST
365
366#define PPC_IRQ_FIRST           PPC_IRQ_SYSTEM_RESET
367
368#if defined(ppc403)
369                                 
370#define PPC_IRQ_CRIT     PPC_IRQ_SYSTEM_RESET /*0x00100- Critical int. pin */
371#define PPC_IRQ_PIT      (PPC_STD_IRQ_LAST+1) /*0x01000- Pgm interval timer*/
372#define PPC_IRQ_FIT      (PPC_STD_IRQ_LAST+2) /*0x01010- Fixed int. timer  */
373#define PPC_IRQ_WATCHDOG (PPC_STD_IRQ_LAST+3) /*0x01020- Watchdog timer    */
374#define PPC_IRQ_DEBUG    (PPC_STD_IRQ_LAST+4) /*0x02000- Debug exceptions  */
375#define PPC_IRQ_LAST     PPC_IRQ_DEBUG   
376
377#elif defined(ppc601)
378#define PPC_IRQ_TRACE    (PPC_STD_IRQ_LAST+1) /*0x02000-Run/Trace Exception*/
379#define PPC_IRQ_LAST     PPC_IRQ_TRACE       
380
381#elif defined(ppc602)
382#define PPC_IRQ_LAST     (PPC_STD_IRQ_LAST)
383
384#elif defined(ppc603)
385#define PPC_IRQ_TRANS_MISS (PPC_STD_IRQ_LAST+1) /*0x1000-Ins Translation Miss*/
386#define PPC_IRQ_DATA_LOAD  (PPC_STD_IRQ_LAST+2) /*0x1100-Data Load Trans Miss*/
387#define PPC_IRQ_DATA_STORE (PPC_STD_IRQ_LAST+3) /*0x1200-Data Store Miss     */
388#define PPC_IRQ_ADDR_BRK   (PPC_STD_IRQ_LAST+4) /*0x1300-Instruction Bkpoint */
389#define PPC_IRQ_SYS_MGT    (PPC_STD_IRQ_LAST+5) /*0x1400-System Management   */
390#define PPC_IRQ_LAST       PPC_IRQ_SYS_MGT   
391
392#elif defined(ppc603e)
393#define PPC_TLB_INST_MISS  (PPC_STD_IRQ_LAST+1) /*0x1000-Instruction TLB Miss*/
394#define PPC_TLB_LOAD_MISS  (PPC_STD_IRQ_LAST+2) /*0x1100-TLB miss on load  */
395#define PPC_TLB_STORE_MISS (PPC_STD_IRQ_LAST+3) /*0x1200-TLB Miss on store */
396#define PPC_IRQ_ADDRBRK    (PPC_STD_IRQ_LAST+4) /*0x1300-Instruct addr break */
397#define PPC_IRQ_SYS_MGT    (PPC_STD_IRQ_LAST+5) /*0x1400-System Management   */
398#define PPC_IRQ_LAST       PPC_IRQ_SYS_MGT   
399
400
401#elif defined(ppc604)
402#define PPC_IRQ_ADDR_BRK (PPC_STD_IRQ_LAST+1) /*0x1300- Inst. addr break  */
403#define PPC_IRQ_SYS_MGT  (PPC_STD_IRQ_LAST+2) /*0x1400- System Management */
404#define PPC_IRQ_LAST     PPC604_IRQ_SYS_MGT 
405
406#endif
407
408/*
409 *  Machine Status Register (MSR) Constants Used by RTEMS
410 */
411
412/*
413 *  Some PPC model manuals refer to the Exception Prefix (EP) bit as
414 *  IP for no apparent reason.
415 */
416
417#define PPC_MSR_RI       0x000000002 /* bit 30 - recoverable exception */
418#define PPC_MSR_DR       0x000000010 /* bit 27 - data address translation */
419#define PPC_MSR_IR       0x000000020 /* bit 26 - instruction addr translation*/
420
421#if (PPC_HAS_EXCEPTION_PREFIX)
422#define PPC_MSR_EP       0x000000040 /* bit 25 - exception prefix */
423#else
424#define PPC_MSR_EP       0x000000000 /* bit 25 - exception prefix */
425#endif
426
427#if (PPC_HAS_FPU)
428#define PPC_MSR_FP       0x000002000 /* bit 18 - floating point enable */
429#else
430#define PPC_MSR_FP       0x000000000 /* bit 18 - floating point enable */
431#endif
432
433#if (PPC_LOW_POWER_MODE == PPC_LOW_POWER_MODE_NONE)
434#define PPC_MSR_POW      0x000000000 /* bit 13 - power management enable */
435#else
436#define PPC_MSR_POW      0x000040000 /* bit 13 - power management enable */
437#endif
438
439/*
440 *  Interrupt/exception MSR bits set as defined on p. 2-20 in "The Programming
441 *  Environments" and the manuals for various PPC models.
442 */
443
444#if (PPC_DEBUG_MODEL == PPC_DEBUG_MODEL_STANDARD)
445#define PPC_MSR_DE       0x000000000 /* bit 22 - debug exception enable */
446#define PPC_MSR_BE       0x000000200 /* bit 22 - branch trace enable */
447#define PPC_MSR_SE       0x000000400 /* bit 21 - single step trace enable */
448#elif (PPC_DEBUG_MODEL == PPC_DEBUG_MODEL_SINGLE_STEP_ONLY)
449#define PPC_MSR_DE       0x000000000 /* bit 22 - debug exception enable */
450#define PPC_MSR_BE       0x000000200 /* bit 22 - branch trace enable */
451#define PPC_MSR_SE       0x000000000 /* bit 21 - single step trace enable */
452#elif (PPC_DEBUG_MODEL == PPC_DEBUG_MODEL_IBM4xx)
453#define PPC_MSR_DE       0x000000200 /* bit 22 - debug exception enable */
454#define PPC_MSR_BE       0x000000000 /* bit 22 - branch trace enable */
455#define PPC_MSR_SE       0x000000000 /* bit 21 - single step trace enable */
456#else
457#error "MSR constants -- unknown PPC_DEBUG_MODEL!!"
458#endif
459
460#define PPC_MSR_ME       0x000001000 /* bit 19 - machine check enable */
461#define PPC_MSR_EE       0x000008000 /* bit 16 - external interrupt enable */
462
463#if (PPC_HAS_RFCI)
464#define PPC_MSR_CE       0x000020000 /* bit 14 - critical interrupt enable */
465#else
466#define PPC_MSR_CE       0x000000000 /* bit 14 - critical interrupt enable */
467#endif
468
469#define PPC_MSR_DISABLE_MASK (PPC_MSR_ME|PPC_MSR_EE|PPC_MSR_CE)
470
471/*
472 *  Initial value for the FPSCR register
473 */
474
475#define PPC_INIT_FPSCR          0x000000f8
476
477#ifdef __cplusplus
478}
479#endif
480
481#endif /* ! _INCLUDE_PPC_h */
482/* end of include file */
483
484
Note: See TracBrowser for help on using the repository browser.