xref: /openbmc/linux/arch/powerpc/lib/crtsavres.S (revision c25141062a82ae8bddced1b3ce2b57a1c0efabe0)
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 #include <asm/ppc_asm.h>
42 
43 	.file	"crtsavres.S"
44 
45 #ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
46 
47 	.section ".text"
48 
49 #ifndef CONFIG_PPC64
50 
51 /* Routines for saving integer registers, called by the compiler.  */
52 /* Called with r11 pointing to the stack header word of the caller of the */
53 /* function, just beyond the end of the integer save area.  */
54 
55 _GLOBAL(_savegpr_14)
56 _GLOBAL(_save32gpr_14)
57 	stw	14,-72(11)	/* save gp registers */
58 _GLOBAL(_savegpr_15)
59 _GLOBAL(_save32gpr_15)
60 	stw	15,-68(11)
61 _GLOBAL(_savegpr_16)
62 _GLOBAL(_save32gpr_16)
63 	stw	16,-64(11)
64 _GLOBAL(_savegpr_17)
65 _GLOBAL(_save32gpr_17)
66 	stw	17,-60(11)
67 _GLOBAL(_savegpr_18)
68 _GLOBAL(_save32gpr_18)
69 	stw	18,-56(11)
70 _GLOBAL(_savegpr_19)
71 _GLOBAL(_save32gpr_19)
72 	stw	19,-52(11)
73 _GLOBAL(_savegpr_20)
74 _GLOBAL(_save32gpr_20)
75 	stw	20,-48(11)
76 _GLOBAL(_savegpr_21)
77 _GLOBAL(_save32gpr_21)
78 	stw	21,-44(11)
79 _GLOBAL(_savegpr_22)
80 _GLOBAL(_save32gpr_22)
81 	stw	22,-40(11)
82 _GLOBAL(_savegpr_23)
83 _GLOBAL(_save32gpr_23)
84 	stw	23,-36(11)
85 _GLOBAL(_savegpr_24)
86 _GLOBAL(_save32gpr_24)
87 	stw	24,-32(11)
88 _GLOBAL(_savegpr_25)
89 _GLOBAL(_save32gpr_25)
90 	stw	25,-28(11)
91 _GLOBAL(_savegpr_26)
92 _GLOBAL(_save32gpr_26)
93 	stw	26,-24(11)
94 _GLOBAL(_savegpr_27)
95 _GLOBAL(_save32gpr_27)
96 	stw	27,-20(11)
97 _GLOBAL(_savegpr_28)
98 _GLOBAL(_save32gpr_28)
99 	stw	28,-16(11)
100 _GLOBAL(_savegpr_29)
101 _GLOBAL(_save32gpr_29)
102 	stw	29,-12(11)
103 _GLOBAL(_savegpr_30)
104 _GLOBAL(_save32gpr_30)
105 	stw	30,-8(11)
106 _GLOBAL(_savegpr_31)
107 _GLOBAL(_save32gpr_31)
108 	stw	31,-4(11)
109 	blr
110 
111 /* Routines for restoring integer registers, called by the compiler.  */
112 /* Called with r11 pointing to the stack header word of the caller of the */
113 /* function, just beyond the end of the integer restore area.  */
114 
115 _GLOBAL(_restgpr_14)
116 _GLOBAL(_rest32gpr_14)
117 	lwz	14,-72(11)	/* restore gp registers */
118 _GLOBAL(_restgpr_15)
119 _GLOBAL(_rest32gpr_15)
120 	lwz	15,-68(11)
121 _GLOBAL(_restgpr_16)
122 _GLOBAL(_rest32gpr_16)
123 	lwz	16,-64(11)
124 _GLOBAL(_restgpr_17)
125 _GLOBAL(_rest32gpr_17)
126 	lwz	17,-60(11)
127 _GLOBAL(_restgpr_18)
128 _GLOBAL(_rest32gpr_18)
129 	lwz	18,-56(11)
130 _GLOBAL(_restgpr_19)
131 _GLOBAL(_rest32gpr_19)
132 	lwz	19,-52(11)
133 _GLOBAL(_restgpr_20)
134 _GLOBAL(_rest32gpr_20)
135 	lwz	20,-48(11)
136 _GLOBAL(_restgpr_21)
137 _GLOBAL(_rest32gpr_21)
138 	lwz	21,-44(11)
139 _GLOBAL(_restgpr_22)
140 _GLOBAL(_rest32gpr_22)
141 	lwz	22,-40(11)
142 _GLOBAL(_restgpr_23)
143 _GLOBAL(_rest32gpr_23)
144 	lwz	23,-36(11)
145 _GLOBAL(_restgpr_24)
146 _GLOBAL(_rest32gpr_24)
147 	lwz	24,-32(11)
148 _GLOBAL(_restgpr_25)
149 _GLOBAL(_rest32gpr_25)
150 	lwz	25,-28(11)
151 _GLOBAL(_restgpr_26)
152 _GLOBAL(_rest32gpr_26)
153 	lwz	26,-24(11)
154 _GLOBAL(_restgpr_27)
155 _GLOBAL(_rest32gpr_27)
156 	lwz	27,-20(11)
157 _GLOBAL(_restgpr_28)
158 _GLOBAL(_rest32gpr_28)
159 	lwz	28,-16(11)
160 _GLOBAL(_restgpr_29)
161 _GLOBAL(_rest32gpr_29)
162 	lwz	29,-12(11)
163 _GLOBAL(_restgpr_30)
164 _GLOBAL(_rest32gpr_30)
165 	lwz	30,-8(11)
166 _GLOBAL(_restgpr_31)
167 _GLOBAL(_rest32gpr_31)
168 	lwz	31,-4(11)
169 	blr
170 
171 /* Routines for restoring integer registers, called by the compiler.  */
172 /* Called with r11 pointing to the stack header word of the caller of the */
173 /* function, just beyond the end of the integer restore area.  */
174 
175 _GLOBAL(_restgpr_14_x)
176 _GLOBAL(_rest32gpr_14_x)
177 	lwz	14,-72(11)	/* restore gp registers */
178 _GLOBAL(_restgpr_15_x)
179 _GLOBAL(_rest32gpr_15_x)
180 	lwz	15,-68(11)
181 _GLOBAL(_restgpr_16_x)
182 _GLOBAL(_rest32gpr_16_x)
183 	lwz	16,-64(11)
184 _GLOBAL(_restgpr_17_x)
185 _GLOBAL(_rest32gpr_17_x)
186 	lwz	17,-60(11)
187 _GLOBAL(_restgpr_18_x)
188 _GLOBAL(_rest32gpr_18_x)
189 	lwz	18,-56(11)
190 _GLOBAL(_restgpr_19_x)
191 _GLOBAL(_rest32gpr_19_x)
192 	lwz	19,-52(11)
193 _GLOBAL(_restgpr_20_x)
194 _GLOBAL(_rest32gpr_20_x)
195 	lwz	20,-48(11)
196 _GLOBAL(_restgpr_21_x)
197 _GLOBAL(_rest32gpr_21_x)
198 	lwz	21,-44(11)
199 _GLOBAL(_restgpr_22_x)
200 _GLOBAL(_rest32gpr_22_x)
201 	lwz	22,-40(11)
202 _GLOBAL(_restgpr_23_x)
203 _GLOBAL(_rest32gpr_23_x)
204 	lwz	23,-36(11)
205 _GLOBAL(_restgpr_24_x)
206 _GLOBAL(_rest32gpr_24_x)
207 	lwz	24,-32(11)
208 _GLOBAL(_restgpr_25_x)
209 _GLOBAL(_rest32gpr_25_x)
210 	lwz	25,-28(11)
211 _GLOBAL(_restgpr_26_x)
212 _GLOBAL(_rest32gpr_26_x)
213 	lwz	26,-24(11)
214 _GLOBAL(_restgpr_27_x)
215 _GLOBAL(_rest32gpr_27_x)
216 	lwz	27,-20(11)
217 _GLOBAL(_restgpr_28_x)
218 _GLOBAL(_rest32gpr_28_x)
219 	lwz	28,-16(11)
220 _GLOBAL(_restgpr_29_x)
221 _GLOBAL(_rest32gpr_29_x)
222 	lwz	29,-12(11)
223 _GLOBAL(_restgpr_30_x)
224 _GLOBAL(_rest32gpr_30_x)
225 	lwz	30,-8(11)
226 _GLOBAL(_restgpr_31_x)
227 _GLOBAL(_rest32gpr_31_x)
228 	lwz	0,4(11)
229 	lwz	31,-4(11)
230 	mtlr	0
231 	mr	1,11
232 	blr
233 
234 #ifdef CONFIG_ALTIVEC
235 /* Called with r0 pointing just beyond the end of the vector save area.  */
236 
237 _GLOBAL(_savevr_20)
238 	li	r11,-192
239 	stvx	v20,r11,r0
240 _GLOBAL(_savevr_21)
241 	li	r11,-176
242 	stvx	v21,r11,r0
243 _GLOBAL(_savevr_22)
244 	li	r11,-160
245 	stvx	v22,r11,r0
246 _GLOBAL(_savevr_23)
247 	li	r11,-144
248 	stvx	v23,r11,r0
249 _GLOBAL(_savevr_24)
250 	li	r11,-128
251 	stvx	v24,r11,r0
252 _GLOBAL(_savevr_25)
253 	li	r11,-112
254 	stvx	v25,r11,r0
255 _GLOBAL(_savevr_26)
256 	li	r11,-96
257 	stvx	v26,r11,r0
258 _GLOBAL(_savevr_27)
259 	li	r11,-80
260 	stvx	v27,r11,r0
261 _GLOBAL(_savevr_28)
262 	li	r11,-64
263 	stvx	v28,r11,r0
264 _GLOBAL(_savevr_29)
265 	li	r11,-48
266 	stvx	v29,r11,r0
267 _GLOBAL(_savevr_30)
268 	li	r11,-32
269 	stvx	v30,r11,r0
270 _GLOBAL(_savevr_31)
271 	li	r11,-16
272 	stvx	v31,r11,r0
273 	blr
274 
275 _GLOBAL(_restvr_20)
276 	li	r11,-192
277 	lvx	v20,r11,r0
278 _GLOBAL(_restvr_21)
279 	li	r11,-176
280 	lvx	v21,r11,r0
281 _GLOBAL(_restvr_22)
282 	li	r11,-160
283 	lvx	v22,r11,r0
284 _GLOBAL(_restvr_23)
285 	li	r11,-144
286 	lvx	v23,r11,r0
287 _GLOBAL(_restvr_24)
288 	li	r11,-128
289 	lvx	v24,r11,r0
290 _GLOBAL(_restvr_25)
291 	li	r11,-112
292 	lvx	v25,r11,r0
293 _GLOBAL(_restvr_26)
294 	li	r11,-96
295 	lvx	v26,r11,r0
296 _GLOBAL(_restvr_27)
297 	li	r11,-80
298 	lvx	v27,r11,r0
299 _GLOBAL(_restvr_28)
300 	li	r11,-64
301 	lvx	v28,r11,r0
302 _GLOBAL(_restvr_29)
303 	li	r11,-48
304 	lvx	v29,r11,r0
305 _GLOBAL(_restvr_30)
306 	li	r11,-32
307 	lvx	v30,r11,r0
308 _GLOBAL(_restvr_31)
309 	li	r11,-16
310 	lvx	v31,r11,r0
311 	blr
312 
313 #endif /* CONFIG_ALTIVEC */
314 
315 #else /* CONFIG_PPC64 */
316 
317 .globl	_savegpr0_14
318 _savegpr0_14:
319 	std	r14,-144(r1)
320 .globl	_savegpr0_15
321 _savegpr0_15:
322 	std	r15,-136(r1)
323 .globl	_savegpr0_16
324 _savegpr0_16:
325 	std	r16,-128(r1)
326 .globl	_savegpr0_17
327 _savegpr0_17:
328 	std	r17,-120(r1)
329 .globl	_savegpr0_18
330 _savegpr0_18:
331 	std	r18,-112(r1)
332 .globl	_savegpr0_19
333 _savegpr0_19:
334 	std	r19,-104(r1)
335 .globl	_savegpr0_20
336 _savegpr0_20:
337 	std	r20,-96(r1)
338 .globl	_savegpr0_21
339 _savegpr0_21:
340 	std	r21,-88(r1)
341 .globl	_savegpr0_22
342 _savegpr0_22:
343 	std	r22,-80(r1)
344 .globl	_savegpr0_23
345 _savegpr0_23:
346 	std	r23,-72(r1)
347 .globl	_savegpr0_24
348 _savegpr0_24:
349 	std	r24,-64(r1)
350 .globl	_savegpr0_25
351 _savegpr0_25:
352 	std	r25,-56(r1)
353 .globl	_savegpr0_26
354 _savegpr0_26:
355 	std	r26,-48(r1)
356 .globl	_savegpr0_27
357 _savegpr0_27:
358 	std	r27,-40(r1)
359 .globl	_savegpr0_28
360 _savegpr0_28:
361 	std	r28,-32(r1)
362 .globl	_savegpr0_29
363 _savegpr0_29:
364 	std	r29,-24(r1)
365 .globl	_savegpr0_30
366 _savegpr0_30:
367 	std	r30,-16(r1)
368 .globl	_savegpr0_31
369 _savegpr0_31:
370 	std	r31,-8(r1)
371 	std	r0,16(r1)
372 	blr
373 
374 .globl	_restgpr0_14
375 _restgpr0_14:
376 	ld	r14,-144(r1)
377 .globl	_restgpr0_15
378 _restgpr0_15:
379 	ld	r15,-136(r1)
380 .globl	_restgpr0_16
381 _restgpr0_16:
382 	ld	r16,-128(r1)
383 .globl	_restgpr0_17
384 _restgpr0_17:
385 	ld	r17,-120(r1)
386 .globl	_restgpr0_18
387 _restgpr0_18:
388 	ld	r18,-112(r1)
389 .globl	_restgpr0_19
390 _restgpr0_19:
391 	ld	r19,-104(r1)
392 .globl	_restgpr0_20
393 _restgpr0_20:
394 	ld	r20,-96(r1)
395 .globl	_restgpr0_21
396 _restgpr0_21:
397 	ld	r21,-88(r1)
398 .globl	_restgpr0_22
399 _restgpr0_22:
400 	ld	r22,-80(r1)
401 .globl	_restgpr0_23
402 _restgpr0_23:
403 	ld	r23,-72(r1)
404 .globl	_restgpr0_24
405 _restgpr0_24:
406 	ld	r24,-64(r1)
407 .globl	_restgpr0_25
408 _restgpr0_25:
409 	ld	r25,-56(r1)
410 .globl	_restgpr0_26
411 _restgpr0_26:
412 	ld	r26,-48(r1)
413 .globl	_restgpr0_27
414 _restgpr0_27:
415 	ld	r27,-40(r1)
416 .globl	_restgpr0_28
417 _restgpr0_28:
418 	ld	r28,-32(r1)
419 .globl	_restgpr0_29
420 _restgpr0_29:
421 	ld	r0,16(r1)
422 	ld	r29,-24(r1)
423 	mtlr	r0
424 	ld	r30,-16(r1)
425 	ld	r31,-8(r1)
426 	blr
427 
428 .globl	_restgpr0_30
429 _restgpr0_30:
430 	ld	r30,-16(r1)
431 .globl	_restgpr0_31
432 _restgpr0_31:
433 	ld	r0,16(r1)
434 	ld	r31,-8(r1)
435 	mtlr	r0
436 	blr
437 
438 #ifdef CONFIG_ALTIVEC
439 /* Called with r0 pointing just beyond the end of the vector save area.  */
440 
441 .globl	_savevr_20
442 _savevr_20:
443 	li	r12,-192
444 	stvx	v20,r12,r0
445 .globl	_savevr_21
446 _savevr_21:
447 	li	r12,-176
448 	stvx	v21,r12,r0
449 .globl	_savevr_22
450 _savevr_22:
451 	li	r12,-160
452 	stvx	v22,r12,r0
453 .globl	_savevr_23
454 _savevr_23:
455 	li	r12,-144
456 	stvx	v23,r12,r0
457 .globl	_savevr_24
458 _savevr_24:
459 	li	r12,-128
460 	stvx	v24,r12,r0
461 .globl	_savevr_25
462 _savevr_25:
463 	li	r12,-112
464 	stvx	v25,r12,r0
465 .globl	_savevr_26
466 _savevr_26:
467 	li	r12,-96
468 	stvx	v26,r12,r0
469 .globl	_savevr_27
470 _savevr_27:
471 	li	r12,-80
472 	stvx	v27,r12,r0
473 .globl	_savevr_28
474 _savevr_28:
475 	li	r12,-64
476 	stvx	v28,r12,r0
477 .globl	_savevr_29
478 _savevr_29:
479 	li	r12,-48
480 	stvx	v29,r12,r0
481 .globl	_savevr_30
482 _savevr_30:
483 	li	r12,-32
484 	stvx	v30,r12,r0
485 .globl	_savevr_31
486 _savevr_31:
487 	li	r12,-16
488 	stvx	v31,r12,r0
489 	blr
490 
491 .globl	_restvr_20
492 _restvr_20:
493 	li	r12,-192
494 	lvx	v20,r12,r0
495 .globl	_restvr_21
496 _restvr_21:
497 	li	r12,-176
498 	lvx	v21,r12,r0
499 .globl	_restvr_22
500 _restvr_22:
501 	li	r12,-160
502 	lvx	v22,r12,r0
503 .globl	_restvr_23
504 _restvr_23:
505 	li	r12,-144
506 	lvx	v23,r12,r0
507 .globl	_restvr_24
508 _restvr_24:
509 	li	r12,-128
510 	lvx	v24,r12,r0
511 .globl	_restvr_25
512 _restvr_25:
513 	li	r12,-112
514 	lvx	v25,r12,r0
515 .globl	_restvr_26
516 _restvr_26:
517 	li	r12,-96
518 	lvx	v26,r12,r0
519 .globl	_restvr_27
520 _restvr_27:
521 	li	r12,-80
522 	lvx	v27,r12,r0
523 .globl	_restvr_28
524 _restvr_28:
525 	li	r12,-64
526 	lvx	v28,r12,r0
527 .globl	_restvr_29
528 _restvr_29:
529 	li	r12,-48
530 	lvx	v29,r12,r0
531 .globl	_restvr_30
532 _restvr_30:
533 	li	r12,-32
534 	lvx	v30,r12,r0
535 .globl	_restvr_31
536 _restvr_31:
537 	li	r12,-16
538 	lvx	v31,r12,r0
539 	blr
540 
541 #endif /* CONFIG_ALTIVEC */
542 
543 #endif /* CONFIG_PPC64 */
544 
545 #endif
546