RTEMS  5.0.0
asm.h
Go to the documentation of this file.
1 
17 /*
18  * COPYRIGHT:
19  *
20  * This file is based on similar code found in newlib available
21  * from ftp.cygnus.com. The file which was used had no copyright
22  * notice. This file is freely distributable as long as the source
23  * of the file is noted. This file is:
24  *
25  * COPYRIGHT (c) 1995.
26  * i-cubed ltd.
27  *
28  * COPYRIGHT (c) 1994.
29  * On-Line Applications Research Corporation (OAR).
30  */
31 
32 #ifndef _RTEMS_ASM_H
33 #define _RTEMS_ASM_H
34 
35 /*
36  * Indicate we are in an assembly file and get the basic CPU definitions.
37  */
38 
39 #ifndef ASM
40 #define ASM
41 #endif
42 #include <rtems/score/cpuopts.h>
43 #include <rtems/score/powerpc.h>
44 
55 /*
56  * Recent versions of GNU cpp define variables which indicate the
57  * need for underscores and percents. If not using GNU cpp or
58  * the version does not support this, then you will obviously
59  * have to define these as appropriate.
60  */
61 
62 #ifndef __USER_LABEL_PREFIX__
63 #define __USER_LABEL_PREFIX__
64 #endif
65 
66 #ifndef __REGISTER_PREFIX__
67 #define __REGISTER_PREFIX__
68 #endif
69 
70 #ifndef __FLOAT_REGISTER_PREFIX__
71 #define __FLOAT_REGISTER_PREFIX__ __REGISTER_PREFIX__
72 #endif
73 
74 #ifndef __PROC_LABEL_PREFIX__
75 #define __PROC_LABEL_PREFIX__ __USER_LABEL_PREFIX__
76 #endif
77 
78 #include <rtems/concat.h>
79 
80 /* Use the right prefix for global labels. */
81 
82 #define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x)
83 
84 /* Use the right prefix for procedure labels. */
85 
86 #define PROC(x) CONCAT1 (__PROC_LABEL_PREFIX__, x)
87 
88 /* Use the right prefix for registers. */
89 
90 #define REG(x) CONCAT1 (__REGISTER_PREFIX__, x)
91 
92 /* Use the right prefix for floating point registers. */
93 
94 #define FREG(x) CONCAT1 (__FLOAT_REGISTER_PREFIX__, x)
95 
96 /*
97  * define macros for all of the registers on this CPU
98  *
99  * EXAMPLE: #define d0 REG (d0)
100  */
101 #define r0 REG(0)
102 #define r1 REG(1)
103 #define r2 REG(2)
104 #define r3 REG(3)
105 #define r4 REG(4)
106 #define r5 REG(5)
107 #define r6 REG(6)
108 #define r7 REG(7)
109 #define r8 REG(8)
110 #define r9 REG(9)
111 #define r10 REG(10)
112 #define r11 REG(11)
113 #define r12 REG(12)
114 #define r13 REG(13)
115 #define r14 REG(14)
116 #define r15 REG(15)
117 #define r16 REG(16)
118 #define r17 REG(17)
119 #define r18 REG(18)
120 #define r19 REG(19)
121 #define r20 REG(20)
122 #define r21 REG(21)
123 #define r22 REG(22)
124 #define r23 REG(23)
125 #define r24 REG(24)
126 #define r25 REG(25)
127 #define r26 REG(26)
128 #define r27 REG(27)
129 #define r28 REG(28)
130 #define r29 REG(29)
131 #define r30 REG(30)
132 #define r31 REG(31)
133 #define f0 FREG(0)
134 #define f1 FREG(1)
135 #define f2 FREG(2)
136 #define f3 FREG(3)
137 #define f4 FREG(4)
138 #define f5 FREG(5)
139 #define f6 FREG(6)
140 #define f7 FREG(7)
141 #define f8 FREG(8)
142 #define f9 FREG(9)
143 #define f10 FREG(10)
144 #define f11 FREG(11)
145 #define f12 FREG(12)
146 #define f13 FREG(13)
147 #define f14 FREG(14)
148 #define f15 FREG(15)
149 #define f16 FREG(16)
150 #define f17 FREG(17)
151 #define f18 FREG(18)
152 #define f19 FREG(19)
153 #define f20 FREG(20)
154 #define f21 FREG(21)
155 #define f22 FREG(22)
156 #define f23 FREG(23)
157 #define f24 FREG(24)
158 #define f25 FREG(25)
159 #define f26 FREG(26)
160 #define f27 FREG(27)
161 #define f28 FREG(28)
162 #define f29 FREG(29)
163 #define f30 FREG(30)
164 #define f31 FREG(31)
165 #define v0 0
166 #define v1 1
167 #define v2 2
168 #define v3 3
169 #define v4 4
170 #define v5 5
171 #define v6 6
172 #define v7 7
173 #define v8 8
174 #define v9 9
175 #define v10 10
176 #define v11 11
177 #define v12 12
178 #define v13 13
179 #define v14 14
180 #define v15 15
181 #define v16 16
182 #define v17 17
183 #define v18 18
184 #define v19 19
185 #define v20 20
186 #define v21 21
187 #define v22 22
188 #define v23 23
189 #define v24 24
190 #define v25 25
191 #define v26 26
192 #define v27 27
193 #define v28 28
194 #define v29 29
195 #define v30 30
196 #define v31 31
197 
198 /*
199  * Some special purpose registers (SPRs).
200  */
201 #define srr0 0x01a
202 #define srr1 0x01b
203 #define srr2 0x3de /* IBM 400 series only */
204 #define srr3 0x3df /* IBM 400 series only */
205 #define csrr0 58 /* Book E */
206 #define csrr1 59 /* Book E */
207 #define mcsrr0 570 /* e500 */
208 #define mcsrr1 571 /* e500 */
209 #define dsrr0 574 /* e200 */
210 #define dsrr1 575 /* e200 */
211 
212 #define sprg0 0x110
213 #define sprg1 0x111
214 #define sprg2 0x112
215 #define sprg3 0x113
216 #define sprg4 276
217 #define sprg5 277
218 #define sprg6 278
219 #define sprg7 279
220 
221 #define usprg0 256
222 
223 #define dar 0x013 /* Data Address Register */
224 #define dec 0x016 /* Decrementer Register */
225 
226 #if defined(ppc403) || defined(ppc405)
227 /* the following SPR/DCR registers exist only in IBM 400 series */
228 #define dear 0x3d5
229 #define evpr 0x3d6 /* SPR: exception vector prefix register */
230 #define iccr 0x3fb /* SPR: instruction cache control reg. */
231 #define dccr 0x3fa /* SPR: data cache control reg. */
232 
233 #if defined (ppc403)
234 #define exisr 0x040 /* DCR: external interrupt status register */
235 #define exier 0x042 /* DCR: external interrupt enable register */
236 #endif /* ppc403 */
237 #if defined(ppc405)
238 #define exisr 0x0C0 /* DCR: external interrupt status register */
239 #define exier 0x0C2 /* DCR: external interrupt enable register */
240 #endif /* ppc405 */
241 
242 #define br0 0x080 /* DCR: memory bank register 0 */
243 #define br1 0x081 /* DCR: memory bank register 1 */
244 #define br2 0x082 /* DCR: memory bank register 2 */
245 #define br3 0x083 /* DCR: memory bank register 3 */
246 #define br4 0x084 /* DCR: memory bank register 4 */
247 #define br5 0x085 /* DCR: memory bank register 5 */
248 #define br6 0x086 /* DCR: memory bank register 6 */
249 #define br7 0x087 /* DCR: memory bank register 7 */
250 
251 /* end of IBM400 series register definitions */
252 
253 #elif defined(mpc860) || defined(mpc821)
254 /* The following registers are for the MPC8x0 */
255 #define der 0x095 /* Debug Enable Register */
256 #define ictrl 0x09E /* Instruction Support Control Register */
257 #define immr 0x27E /* Internal Memory Map Register */
258 /* end of MPC8x0 registers */
259 #endif
260 
261 /*
262  * Following must be tailor for a particular flavor of the C compiler.
263  * They may need to put underscores in front of the symbols.
264  */
265 
266 #define PUBLIC_VAR(sym) .globl SYM (sym)
267 #define EXTERN_VAR(sym) .extern SYM (sym)
268 #define PUBLIC_PROC(sym) .globl PROC (sym)
269 #define EXTERN_PROC(sym) .extern PROC (sym)
270 
271 /* Other potentially assembler specific operations */
272 #if PPC_ASM == PPC_ASM_ELF
273 #define ALIGN(n,p) .align p
274 #define DESCRIPTOR(x) \
275  .section .descriptors,"aw"; \
276  PUBLIC_VAR (x); \
277 SYM (x):; \
278  .long PROC (x); \
279  .long s.got; \
280  .long 0
281 
282 #define EXT_SYM_REF(x) .long x
283 #define EXT_PROC_REF(x) .long x
284 
285 /*
286  * Define macros to handle section beginning and ends.
287  */
288 
289 #define BEGIN_CODE_DCL .text
290 #define END_CODE_DCL
291 #define BEGIN_DATA_DCL .data
292 #define END_DATA_DCL
293 #define BEGIN_CODE .text
294 #define END_CODE
295 #define BEGIN_DATA .data
296 #define END_DATA
297 #define BEGIN_BSS .bss
298 #define END_BSS
299 #define END
300 
301 #else
302 #error "PPC_ASM_TYPE is not properly defined"
303 #endif
304 #ifndef PPC_ASM
305 #error "PPC_ASM_TYPE is not properly defined"
306 #endif
307 
308 #if defined(__powerpc64__)
309 #define PPC64_NOP_FOR_LINKER_TOC_POINTER_RESTORE nop
310 #else
311 #define PPC64_NOP_FOR_LINKER_TOC_POINTER_RESTORE
312 #endif
313 
314 #endif
315 
IBM/Motorola PowerPC Definitions.