Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / openbios / libgcc / crtsavres.S
1 /*
2  * Special support for eabi and SVR4
3  *
4  *   Copyright (C) 1995, 1996, 1998, 2000, 2001 Free Software Foundation, Inc.
5  *   Copyright 2008 Freescale Semiconductor, Inc.
6  *   Written By Michael Meissner
7  *
8  * Based on gcc/config/rs6000/crtsavres.asm from gcc
9  * 64 bit additions from reading the PPC elf64abi document.
10  *
11  * This file is free software; you can redistribute it and/or modify it
12  * under the terms of the GNU General Public License as published by the
13  * Free Software Foundation; either version 2, or (at your option) any
14  * later version.
15  *
16  * In addition to the permissions in the GNU General Public License, the
17  * Free Software Foundation gives you unlimited permission to link the
18  * compiled version of this file with other programs, and to distribute
19  * those programs without any restriction coming from the use of this
20  * file.  (The General Public License restrictions do apply in other
21  * respects; for example, they cover modification of the file, and
22  * distribution when not linked into another program.)
23  *
24  * This file is distributed in the hope that it will be useful, but
25  * WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
27  * General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program; see the file COPYING.  If not, write to
31  * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
32  * Boston, MA 02110-1301, USA.
33  *
34  *    As a special exception, if you link this library with files
35  *    compiled with GCC to produce an executable, this does not cause
36  *    the resulting executable to be covered by the GNU General Public License.
37  *    This exception does not however invalidate any other reasons why
38  *    the executable file might be covered by the GNU General Public License.
39  */
40
41 /* taken from Linux arch/powerpc/lib/crtsavres.S */
42
43 /* arch/powerpc/include/asm/ppc_asm.h */
44 #ifdef CONFIG_PPC64
45
46 #define XGLUE(a,b) a##b
47 #define GLUE(a,b) XGLUE(a,b)
48
49 #define _GLOBAL(name) \
50         .section ".text"; \
51         .align 2 ; \
52         .globl name; \
53         .globl GLUE(.,name); \
54         .section ".opd","aw"; \
55 name: \
56         .quad GLUE(.,name); \
57         .quad .TOC.@tocbase; \
58         .quad 0; \
59         .previous; \
60         .type GLUE(.,name),@function; \
61 GLUE(.,name):
62
63 #else /* 32-bit */
64
65 /* include/linux/stringify.h */
66
67 /* Indirect stringification.  Doing two levels allows the parameter to be a
68  * macro itself.  For example, compile with -DFOO=bar, __stringify(FOO)
69  * converts to "bar".
70  */
71
72 #define __stringify_1(x...)     #x
73 #define __stringify(x...)       __stringify_1(x)
74
75 /* arch/powerpc/include/asm/ppc_asm.h continues */
76
77 #define _GLOBAL(n)      \
78         .text;          \
79         .stabs __stringify(n:F-1),N_FUN,0,0,n;\
80         .globl n;       \
81 n:
82
83 /* some stab codes */
84 #define N_FUN   36
85
86 #endif
87
88 /* arch/powerpc/lib/crtsavres.S continues */
89
90         .file   "crtsavres.S"
91         .section ".text"
92
93 #ifndef CONFIG_PPC64
94
95 /* Routines for saving integer registers, called by the compiler.  */
96 /* Called with r11 pointing to the stack header word of the caller of the */
97 /* function, just beyond the end of the integer save area.  */
98
99 _GLOBAL(_savegpr_14)
100 _GLOBAL(_save32gpr_14)
101         stw     14,-72(11)      /* save gp registers */
102 _GLOBAL(_savegpr_15)
103 _GLOBAL(_save32gpr_15)
104         stw     15,-68(11)
105 _GLOBAL(_savegpr_16)
106 _GLOBAL(_save32gpr_16)
107         stw     16,-64(11)
108 _GLOBAL(_savegpr_17)
109 _GLOBAL(_save32gpr_17)
110         stw     17,-60(11)
111 _GLOBAL(_savegpr_18)
112 _GLOBAL(_save32gpr_18)
113         stw     18,-56(11)
114 _GLOBAL(_savegpr_19)
115 _GLOBAL(_save32gpr_19)
116         stw     19,-52(11)
117 _GLOBAL(_savegpr_20)
118 _GLOBAL(_save32gpr_20)
119         stw     20,-48(11)
120 _GLOBAL(_savegpr_21)
121 _GLOBAL(_save32gpr_21)
122         stw     21,-44(11)
123 _GLOBAL(_savegpr_22)
124 _GLOBAL(_save32gpr_22)
125         stw     22,-40(11)
126 _GLOBAL(_savegpr_23)
127 _GLOBAL(_save32gpr_23)
128         stw     23,-36(11)
129 _GLOBAL(_savegpr_24)
130 _GLOBAL(_save32gpr_24)
131         stw     24,-32(11)
132 _GLOBAL(_savegpr_25)
133 _GLOBAL(_save32gpr_25)
134         stw     25,-28(11)
135 _GLOBAL(_savegpr_26)
136 _GLOBAL(_save32gpr_26)
137         stw     26,-24(11)
138 _GLOBAL(_savegpr_27)
139 _GLOBAL(_save32gpr_27)
140         stw     27,-20(11)
141 _GLOBAL(_savegpr_28)
142 _GLOBAL(_save32gpr_28)
143         stw     28,-16(11)
144 _GLOBAL(_savegpr_29)
145 _GLOBAL(_save32gpr_29)
146         stw     29,-12(11)
147 _GLOBAL(_savegpr_30)
148 _GLOBAL(_save32gpr_30)
149         stw     30,-8(11)
150 _GLOBAL(_savegpr_31)
151 _GLOBAL(_save32gpr_31)
152         stw     31,-4(11)
153         blr
154
155 /* Routines for restoring integer registers, called by the compiler.  */
156 /* Called with r11 pointing to the stack header word of the caller of the */
157 /* function, just beyond the end of the integer restore area.  */
158
159 _GLOBAL(_restgpr_14)
160 _GLOBAL(_rest32gpr_14)
161         lwz     14,-72(11)      /* restore gp registers */
162 _GLOBAL(_restgpr_15)
163 _GLOBAL(_rest32gpr_15)
164         lwz     15,-68(11)
165 _GLOBAL(_restgpr_16)
166 _GLOBAL(_rest32gpr_16)
167         lwz     16,-64(11)
168 _GLOBAL(_restgpr_17)
169 _GLOBAL(_rest32gpr_17)
170         lwz     17,-60(11)
171 _GLOBAL(_restgpr_18)
172 _GLOBAL(_rest32gpr_18)
173         lwz     18,-56(11)
174 _GLOBAL(_restgpr_19)
175 _GLOBAL(_rest32gpr_19)
176         lwz     19,-52(11)
177 _GLOBAL(_restgpr_20)
178 _GLOBAL(_rest32gpr_20)
179         lwz     20,-48(11)
180 _GLOBAL(_restgpr_21)
181 _GLOBAL(_rest32gpr_21)
182         lwz     21,-44(11)
183 _GLOBAL(_restgpr_22)
184 _GLOBAL(_rest32gpr_22)
185         lwz     22,-40(11)
186 _GLOBAL(_restgpr_23)
187 _GLOBAL(_rest32gpr_23)
188         lwz     23,-36(11)
189 _GLOBAL(_restgpr_24)
190 _GLOBAL(_rest32gpr_24)
191         lwz     24,-32(11)
192 _GLOBAL(_restgpr_25)
193 _GLOBAL(_rest32gpr_25)
194         lwz     25,-28(11)
195 _GLOBAL(_restgpr_26)
196 _GLOBAL(_rest32gpr_26)
197         lwz     26,-24(11)
198 _GLOBAL(_restgpr_27)
199 _GLOBAL(_rest32gpr_27)
200         lwz     27,-20(11)
201 _GLOBAL(_restgpr_28)
202 _GLOBAL(_rest32gpr_28)
203         lwz     28,-16(11)
204 _GLOBAL(_restgpr_29)
205 _GLOBAL(_rest32gpr_29)
206         lwz     29,-12(11)
207 _GLOBAL(_restgpr_30)
208 _GLOBAL(_rest32gpr_30)
209         lwz     30,-8(11)
210 _GLOBAL(_restgpr_31)
211 _GLOBAL(_rest32gpr_31)
212         lwz     31,-4(11)
213         blr
214
215 /* Routines for restoring integer registers, called by the compiler.  */
216 /* Called with r11 pointing to the stack header word of the caller of the */
217 /* function, just beyond the end of the integer restore area.  */
218
219 _GLOBAL(_restgpr_14_x)
220 _GLOBAL(_rest32gpr_14_x)
221         lwz     14,-72(11)      /* restore gp registers */
222 _GLOBAL(_restgpr_15_x)
223 _GLOBAL(_rest32gpr_15_x)
224         lwz     15,-68(11)
225 _GLOBAL(_restgpr_16_x)
226 _GLOBAL(_rest32gpr_16_x)
227         lwz     16,-64(11)
228 _GLOBAL(_restgpr_17_x)
229 _GLOBAL(_rest32gpr_17_x)
230         lwz     17,-60(11)
231 _GLOBAL(_restgpr_18_x)
232 _GLOBAL(_rest32gpr_18_x)
233         lwz     18,-56(11)
234 _GLOBAL(_restgpr_19_x)
235 _GLOBAL(_rest32gpr_19_x)
236         lwz     19,-52(11)
237 _GLOBAL(_restgpr_20_x)
238 _GLOBAL(_rest32gpr_20_x)
239         lwz     20,-48(11)
240 _GLOBAL(_restgpr_21_x)
241 _GLOBAL(_rest32gpr_21_x)
242         lwz     21,-44(11)
243 _GLOBAL(_restgpr_22_x)
244 _GLOBAL(_rest32gpr_22_x)
245         lwz     22,-40(11)
246 _GLOBAL(_restgpr_23_x)
247 _GLOBAL(_rest32gpr_23_x)
248         lwz     23,-36(11)
249 _GLOBAL(_restgpr_24_x)
250 _GLOBAL(_rest32gpr_24_x)
251         lwz     24,-32(11)
252 _GLOBAL(_restgpr_25_x)
253 _GLOBAL(_rest32gpr_25_x)
254         lwz     25,-28(11)
255 _GLOBAL(_restgpr_26_x)
256 _GLOBAL(_rest32gpr_26_x)
257         lwz     26,-24(11)
258 _GLOBAL(_restgpr_27_x)
259 _GLOBAL(_rest32gpr_27_x)
260         lwz     27,-20(11)
261 _GLOBAL(_restgpr_28_x)
262 _GLOBAL(_rest32gpr_28_x)
263         lwz     28,-16(11)
264 _GLOBAL(_restgpr_29_x)
265 _GLOBAL(_rest32gpr_29_x)
266         lwz     29,-12(11)
267 _GLOBAL(_restgpr_30_x)
268 _GLOBAL(_rest32gpr_30_x)
269         lwz     30,-8(11)
270 _GLOBAL(_restgpr_31_x)
271 _GLOBAL(_rest32gpr_31_x)
272         lwz     0,4(11)
273         lwz     31,-4(11)
274         mtlr    0
275         mr      1,11
276         blr
277
278 #else /* CONFIG_PPC64 */
279
280 .globl  _savegpr0_14
281 _savegpr0_14:
282         std     r14,-144(r1)
283 .globl  _savegpr0_15
284 _savegpr0_15:
285         std     r15,-136(r1)
286 .globl  _savegpr0_16
287 _savegpr0_16:
288         std     r16,-128(r1)
289 .globl  _savegpr0_17
290 _savegpr0_17:
291         std     r17,-120(r1)
292 .globl  _savegpr0_18
293 _savegpr0_18:
294         std     r18,-112(r1)
295 .globl  _savegpr0_19
296 _savegpr0_19:
297         std     r19,-104(r1)
298 .globl  _savegpr0_20
299 _savegpr0_20:
300         std     r20,-96(r1)
301 .globl  _savegpr0_21
302 _savegpr0_21:
303         std     r21,-88(r1)
304 .globl  _savegpr0_22
305 _savegpr0_22:
306         std     r22,-80(r1)
307 .globl  _savegpr0_23
308 _savegpr0_23:
309         std     r23,-72(r1)
310 .globl  _savegpr0_24
311 _savegpr0_24:
312         std     r24,-64(r1)
313 .globl  _savegpr0_25
314 _savegpr0_25:
315         std     r25,-56(r1)
316 .globl  _savegpr0_26
317 _savegpr0_26:
318         std     r26,-48(r1)
319 .globl  _savegpr0_27
320 _savegpr0_27:
321         std     r27,-40(r1)
322 .globl  _savegpr0_28
323 _savegpr0_28:
324         std     r28,-32(r1)
325 .globl  _savegpr0_29
326 _savegpr0_29:
327         std     r29,-24(r1)
328 .globl  _savegpr0_30
329 _savegpr0_30:
330         std     r30,-16(r1)
331 .globl  _savegpr0_31
332 _savegpr0_31:
333         std     r31,-8(r1)
334         std     r0,16(r1)
335         blr
336
337 .globl  _restgpr0_14
338 _restgpr0_14:
339         ld      r14,-144(r1)
340 .globl  _restgpr0_15
341 _restgpr0_15:
342         ld      r15,-136(r1)
343 .globl  _restgpr0_16
344 _restgpr0_16:
345         ld      r16,-128(r1)
346 .globl  _restgpr0_17
347 _restgpr0_17:
348         ld      r17,-120(r1)
349 .globl  _restgpr0_18
350 _restgpr0_18:
351         ld      r18,-112(r1)
352 .globl  _restgpr0_19
353 _restgpr0_19:
354         ld      r19,-104(r1)
355 .globl  _restgpr0_20
356 _restgpr0_20:
357         ld      r20,-96(r1)
358 .globl  _restgpr0_21
359 _restgpr0_21:
360         ld      r21,-88(r1)
361 .globl  _restgpr0_22
362 _restgpr0_22:
363         ld      r22,-80(r1)
364 .globl  _restgpr0_23
365 _restgpr0_23:
366         ld      r23,-72(r1)
367 .globl  _restgpr0_24
368 _restgpr0_24:
369         ld      r24,-64(r1)
370 .globl  _restgpr0_25
371 _restgpr0_25:
372         ld      r25,-56(r1)
373 .globl  _restgpr0_26
374 _restgpr0_26:
375         ld      r26,-48(r1)
376 .globl  _restgpr0_27
377 _restgpr0_27:
378         ld      r27,-40(r1)
379 .globl  _restgpr0_28
380 _restgpr0_28:
381         ld      r28,-32(r1)
382 .globl  _restgpr0_29
383 _restgpr0_29:
384         ld      r0,16(r1)
385         ld      r29,-24(r1)
386         mtlr    r0
387         ld      r30,-16(r1)
388         ld      r31,-8(r1)
389         blr
390
391 .globl  _restgpr0_30
392 _restgpr0_30:
393         ld      r30,-16(r1)
394 .globl  _restgpr0_31
395 _restgpr0_31:
396         ld      r0,16(r1)
397         ld      r31,-8(r1)
398         mtlr    r0
399         blr
400
401 #endif /* CONFIG_PPC64 */