source: rtems/cpukit/score/cpu/powerpc/asm.h @ fc63544

4.104.114.84.95
Last change on this file since fc63544 was 8adc214, checked in by Ralf Corsepius <ralf.corsepius@…>, on 11/21/04 at 11:35:50

Cosmetics.

  • Property mode set to 100644
File size: 7.4 KB
Line 
1/**
2 * @file rtems/asm.h
3 *
4 *  This include file attempts to address the problems
5 *  caused by incompatible flavors of assemblers and
6 *  toolsets.  It primarily addresses variations in the
7 *  use of leading underscores on symbols and the requirement
8 *  that register names be preceded by a %.
9 */
10
11/*
12 *  NOTE: The spacing in the use of these macros
13 *        is critical to them working as advertised.
14 *
15 *  COPYRIGHT:
16 *
17 *  This file is based on similar code found in newlib available
18 *  from ftp.cygnus.com.  The file which was used had no copyright
19 *  notice.  This file is freely distributable as long as the source
20 *  of the file is noted.  This file is:
21 *
22 *  COPYRIGHT (c) 1995.
23 *  i-cubed ltd.
24 *
25 *  COPYRIGHT (c) 1994.
26 *  On-Line Applications Research Corporation (OAR).
27 *
28 *  $Id$
29 */
30
31#ifndef __PPC_ASM_h
32#define __PPC_ASM_h
33
34/*
35 *  Indicate we are in an assembly file and get the basic CPU definitions.
36 */
37
38#ifndef ASM
39#define ASM
40#endif
41#include <rtems/score/cpuopts.h>
42#include <rtems/score/powerpc.h>
43
44/*
45 *  Recent versions of GNU cpp define variables which indicate the
46 *  need for underscores and percents.  If not using GNU cpp or
47 *  the version does not support this, then you will obviously
48 *  have to define these as appropriate.
49 */
50
51#ifndef __USER_LABEL_PREFIX__
52#define __USER_LABEL_PREFIX__
53#endif
54
55#ifndef __REGISTER_PREFIX__
56#define __REGISTER_PREFIX__
57#endif
58
59#ifndef __FLOAT_REGISTER_PREFIX__
60#define __FLOAT_REGISTER_PREFIX__  __REGISTER_PREFIX__
61#endif
62
63#if (PPC_ABI == PPC_ABI_POWEROPEN)
64#ifndef __PROC_LABEL_PREFIX__
65#define __PROC_LABEL_PREFIX__ .
66#endif
67#endif
68
69#ifndef __PROC_LABEL_PREFIX__
70#define __PROC_LABEL_PREFIX__  __USER_LABEL_PREFIX__
71#endif
72
73/* ANSI concatenation macros.  */
74
75#define CONCAT1(a, b) CONCAT2(a, b)
76#define CONCAT2(a, b) a ## b
77
78/* Use the right prefix for global labels.  */
79
80#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x)
81
82/* Use the right prefix for procedure labels.  */
83
84#define PROC(x) CONCAT1 (__PROC_LABEL_PREFIX__, x)
85
86/* Use the right prefix for registers.  */
87
88#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x)
89
90/* Use the right prefix for floating point registers.  */
91
92#define FREG(x) CONCAT1 (__FLOAT_REGISTER_PREFIX__, x)
93
94/*
95 *  define macros for all of the registers on this CPU
96 *
97 *  EXAMPLE:     #define d0 REG (d0)
98 */
99#define r0 REG(0)
100#define r1 REG(1)
101#define r2 REG(2)
102#define r3 REG(3)
103#define r4 REG(4)
104#define r5 REG(5)
105#define r6 REG(6)
106#define r7 REG(7)
107#define r8 REG(8)
108#define r9 REG(9)
109#define r10 REG(10)
110#define r11 REG(11)
111#define r12 REG(12)
112#define r13 REG(13)
113#define r14 REG(14)
114#define r15 REG(15)
115#define r16 REG(16)
116#define r17 REG(17)
117#define r18 REG(18)
118#define r19 REG(19)
119#define r20 REG(20)
120#define r21 REG(21)
121#define r22 REG(22)
122#define r23 REG(23)
123#define r24 REG(24)
124#define r25 REG(25)
125#define r26 REG(26)
126#define r27 REG(27)
127#define r28 REG(28)
128#define r29 REG(29)
129#define r30 REG(30)
130#define r31 REG(31)
131#define f0 FREG(0)
132#define f1 FREG(1)
133#define f2 FREG(2)
134#define f3 FREG(3)
135#define f4 FREG(4)
136#define f5 FREG(5)
137#define f6 FREG(6)
138#define f7 FREG(7)
139#define f8 FREG(8)
140#define f9 FREG(9)
141#define f10 FREG(10)
142#define f11 FREG(11)
143#define f12 FREG(12)
144#define f13 FREG(13)
145#define f14 FREG(14)
146#define f15 FREG(15)
147#define f16 FREG(16)
148#define f17 FREG(17)
149#define f18 FREG(18)
150#define f19 FREG(19)
151#define f20 FREG(20)
152#define f21 FREG(21)
153#define f22 FREG(22)
154#define f23 FREG(23)
155#define f24 FREG(24)
156#define f25 FREG(25)
157#define f26 FREG(26)
158#define f27 FREG(27)
159#define f28 FREG(28)
160#define f29 FREG(29)
161#define f30 FREG(30)
162#define f31 FREG(31)
163
164/*
165 * Some special purpose registers (SPRs).
166 */
167#define srr0    0x01a
168#define srr1    0x01b
169#if defined(ppc403) || defined(ppc405)
170#define srr2    0x3de   /* IBM 400 series only */
171#define srr3    0x3df   /* IBM 400 series only */
172#endif /* ppc403 or ppc405 */
173
174#define sprg0   0x110
175#define sprg1   0x111
176#define sprg2   0x112
177#define sprg3   0x113
178
179#define dar     0x013   /* Data Address Register */
180#define dec             0x016   /* Decrementer Register */
181
182#if defined(ppc403) || defined(ppc405)
183/* the following SPR/DCR registers exist only in IBM 400 series */
184#define dear    0x3d5   
185#define evpr    0x3d6   /* SPR: exception vector prefix register   */
186#define iccr    0x3fb   /* SPR: instruction cache control reg.     */
187#define dccr    0x3fa   /* SPR: data cache control reg.            */
188
189#if defined (ppc403)
190#define exisr   0x040   /* DCR: external interrupt status register */
191#define exier   0x042   /* DCR: external interrupt enable register */
192#endif /* ppc403 */
193#if defined(ppc405)
194#define exisr   0x0C0   /* DCR: external interrupt status register */
195#define exier   0x0C2   /* DCR: external interrupt enable register */
196#endif /* ppc405 */
197
198#define br0     0x080   /* DCR: memory bank register 0             */
199#define br1     0x081   /* DCR: memory bank register 1             */
200#define br2     0x082   /* DCR: memory bank register 2             */
201#define br3     0x083   /* DCR: memory bank register 3             */
202#define br4     0x084   /* DCR: memory bank register 4             */
203#define br5     0x085   /* DCR: memory bank register 5             */
204#define br6     0x086   /* DCR: memory bank register 6             */
205#define br7     0x087   /* DCR: memory bank register 7             */
206/* end of IBM400 series register definitions */
207
208#elif defined(mpc555)
209/* The following registers are for the MPC5xx */
210#define eie     0x050   /* External Interrupt Enable Register */
211#define eid     0x051   /* External Interrupt Disable Register */
212#define nri     0x052   /* Non-Recoverable Interrupt Register */
213 
214#elif defined(mpc860) || defined(mpc821)
215/* The following registers are for the MPC8x0 */
216#define der     0x095   /* Debug Enable Register */
217#define ictrl   0x09E   /* Instruction Support Control Register */
218#define immr    0x27E   /* Internal Memory Map Register */
219/* end of MPC8x0 registers */
220#endif
221
222/*
223 *  Following must be tailor for a particular flavor of the C compiler.
224 *  They may need to put underscores in front of the symbols.
225 */
226
227#define PUBLIC_VAR(sym) .globl SYM (sym)
228#define EXTERN_VAR(sym) .extern SYM (sym)
229#define PUBLIC_PROC(sym) .globl PROC (sym)
230#define EXTERN_PROC(sym) .extern PROC (sym)
231
232/* Other potentially assembler specific operations */
233#if PPC_ASM == PPC_ASM_ELF
234#define ALIGN(n,p)      .align  p
235#define DESCRIPTOR(x)   \
236        .section .descriptors,"aw";     \
237        PUBLIC_VAR (x);                 \
238SYM (x):;                               \
239        .long   PROC (x);               \
240        .long   s.got;                  \
241        .long   0
242
243#define EXT_SYM_REF(x)  .long x
244#define EXT_PROC_REF(x) .long x
245
246/*
247 *  Define macros to handle section beginning and ends.
248 */
249
250#define BEGIN_CODE_DCL .text
251#define END_CODE_DCL
252#define BEGIN_DATA_DCL .data
253#define END_DATA_DCL
254#define BEGIN_CODE .text
255#define END_CODE
256#define BEGIN_DATA .data
257#define END_DATA
258#define BEGIN_BSS  .bss
259#define END_BSS
260#define END
261
262#elif PPC_ASM == PPC_ASM_XCOFF
263#define ALIGN(n,p)      .align  p
264#define DESCRIPTOR(x)   \
265        .csect  x[DS];          \
266        .globl  x[DS];          \
267        .long   PROC (x)[PR];   \
268        .long   TOC[tc0]
269
270#define EXT_SYM_REF(x)  .long x[RW]
271#define EXT_PROC_REF(x) .long x[DS]
272
273/*
274 *  Define macros to handle section beginning and ends.
275 */
276
277#define BEGIN_CODE_DCL .csect .text[PR]
278#define END_CODE_DCL
279#define BEGIN_DATA_DCL .csect .data[RW]
280#define END_DATA_DCL
281#define BEGIN_CODE .csect .text[PR]
282#define END_CODE
283#define BEGIN_DATA .csect .data[RW]
284#define END_DATA
285#define BEGIN_BSS  .bss
286#define END_BSS
287#define END
288
289#else
290#error "PPC_ASM_TYPE is not properly defined"
291#endif
292#ifndef PPC_ASM
293#error "PPC_ASM_TYPE is not properly defined"
294#endif
295
296
297#endif
Note: See TracBrowser for help on using the repository browser.