xref: /openbmc/linux/arch/powerpc/lib/crtsavres.S (revision c819e2cf)
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#ifndef CONFIG_PPC64
48
49	.section ".text"
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	vr20,r11,r0
240_GLOBAL(_savevr_21)
241	li	r11,-176
242	stvx	vr21,r11,r0
243_GLOBAL(_savevr_22)
244	li	r11,-160
245	stvx	vr22,r11,r0
246_GLOBAL(_savevr_23)
247	li	r11,-144
248	stvx	vr23,r11,r0
249_GLOBAL(_savevr_24)
250	li	r11,-128
251	stvx	vr24,r11,r0
252_GLOBAL(_savevr_25)
253	li	r11,-112
254	stvx	vr25,r11,r0
255_GLOBAL(_savevr_26)
256	li	r11,-96
257	stvx	vr26,r11,r0
258_GLOBAL(_savevr_27)
259	li	r11,-80
260	stvx	vr27,r11,r0
261_GLOBAL(_savevr_28)
262	li	r11,-64
263	stvx	vr28,r11,r0
264_GLOBAL(_savevr_29)
265	li	r11,-48
266	stvx	vr29,r11,r0
267_GLOBAL(_savevr_30)
268	li	r11,-32
269	stvx	vr30,r11,r0
270_GLOBAL(_savevr_31)
271	li	r11,-16
272	stvx	vr31,r11,r0
273	blr
274
275_GLOBAL(_restvr_20)
276	li	r11,-192
277	lvx	vr20,r11,r0
278_GLOBAL(_restvr_21)
279	li	r11,-176
280	lvx	vr21,r11,r0
281_GLOBAL(_restvr_22)
282	li	r11,-160
283	lvx	vr22,r11,r0
284_GLOBAL(_restvr_23)
285	li	r11,-144
286	lvx	vr23,r11,r0
287_GLOBAL(_restvr_24)
288	li	r11,-128
289	lvx	vr24,r11,r0
290_GLOBAL(_restvr_25)
291	li	r11,-112
292	lvx	vr25,r11,r0
293_GLOBAL(_restvr_26)
294	li	r11,-96
295	lvx	vr26,r11,r0
296_GLOBAL(_restvr_27)
297	li	r11,-80
298	lvx	vr27,r11,r0
299_GLOBAL(_restvr_28)
300	li	r11,-64
301	lvx	vr28,r11,r0
302_GLOBAL(_restvr_29)
303	li	r11,-48
304	lvx	vr29,r11,r0
305_GLOBAL(_restvr_30)
306	li	r11,-32
307	lvx	vr30,r11,r0
308_GLOBAL(_restvr_31)
309	li	r11,-16
310	lvx	vr31,r11,r0
311	blr
312
313#endif /* CONFIG_ALTIVEC */
314
315#else /* CONFIG_PPC64 */
316
317	.section ".text.save.restore","ax",@progbits
318
319.globl	_savegpr0_14
320_savegpr0_14:
321	std	r14,-144(r1)
322.globl	_savegpr0_15
323_savegpr0_15:
324	std	r15,-136(r1)
325.globl	_savegpr0_16
326_savegpr0_16:
327	std	r16,-128(r1)
328.globl	_savegpr0_17
329_savegpr0_17:
330	std	r17,-120(r1)
331.globl	_savegpr0_18
332_savegpr0_18:
333	std	r18,-112(r1)
334.globl	_savegpr0_19
335_savegpr0_19:
336	std	r19,-104(r1)
337.globl	_savegpr0_20
338_savegpr0_20:
339	std	r20,-96(r1)
340.globl	_savegpr0_21
341_savegpr0_21:
342	std	r21,-88(r1)
343.globl	_savegpr0_22
344_savegpr0_22:
345	std	r22,-80(r1)
346.globl	_savegpr0_23
347_savegpr0_23:
348	std	r23,-72(r1)
349.globl	_savegpr0_24
350_savegpr0_24:
351	std	r24,-64(r1)
352.globl	_savegpr0_25
353_savegpr0_25:
354	std	r25,-56(r1)
355.globl	_savegpr0_26
356_savegpr0_26:
357	std	r26,-48(r1)
358.globl	_savegpr0_27
359_savegpr0_27:
360	std	r27,-40(r1)
361.globl	_savegpr0_28
362_savegpr0_28:
363	std	r28,-32(r1)
364.globl	_savegpr0_29
365_savegpr0_29:
366	std	r29,-24(r1)
367.globl	_savegpr0_30
368_savegpr0_30:
369	std	r30,-16(r1)
370.globl	_savegpr0_31
371_savegpr0_31:
372	std	r31,-8(r1)
373	std	r0,16(r1)
374	blr
375
376.globl	_restgpr0_14
377_restgpr0_14:
378	ld	r14,-144(r1)
379.globl	_restgpr0_15
380_restgpr0_15:
381	ld	r15,-136(r1)
382.globl	_restgpr0_16
383_restgpr0_16:
384	ld	r16,-128(r1)
385.globl	_restgpr0_17
386_restgpr0_17:
387	ld	r17,-120(r1)
388.globl	_restgpr0_18
389_restgpr0_18:
390	ld	r18,-112(r1)
391.globl	_restgpr0_19
392_restgpr0_19:
393	ld	r19,-104(r1)
394.globl	_restgpr0_20
395_restgpr0_20:
396	ld	r20,-96(r1)
397.globl	_restgpr0_21
398_restgpr0_21:
399	ld	r21,-88(r1)
400.globl	_restgpr0_22
401_restgpr0_22:
402	ld	r22,-80(r1)
403.globl	_restgpr0_23
404_restgpr0_23:
405	ld	r23,-72(r1)
406.globl	_restgpr0_24
407_restgpr0_24:
408	ld	r24,-64(r1)
409.globl	_restgpr0_25
410_restgpr0_25:
411	ld	r25,-56(r1)
412.globl	_restgpr0_26
413_restgpr0_26:
414	ld	r26,-48(r1)
415.globl	_restgpr0_27
416_restgpr0_27:
417	ld	r27,-40(r1)
418.globl	_restgpr0_28
419_restgpr0_28:
420	ld	r28,-32(r1)
421.globl	_restgpr0_29
422_restgpr0_29:
423	ld	r0,16(r1)
424	ld	r29,-24(r1)
425	mtlr	r0
426	ld	r30,-16(r1)
427	ld	r31,-8(r1)
428	blr
429
430.globl	_restgpr0_30
431_restgpr0_30:
432	ld	r30,-16(r1)
433.globl	_restgpr0_31
434_restgpr0_31:
435	ld	r0,16(r1)
436	ld	r31,-8(r1)
437	mtlr	r0
438	blr
439
440#ifdef CONFIG_ALTIVEC
441/* Called with r0 pointing just beyond the end of the vector save area.  */
442
443.globl	_savevr_20
444_savevr_20:
445	li	r12,-192
446	stvx	vr20,r12,r0
447.globl	_savevr_21
448_savevr_21:
449	li	r12,-176
450	stvx	vr21,r12,r0
451.globl	_savevr_22
452_savevr_22:
453	li	r12,-160
454	stvx	vr22,r12,r0
455.globl	_savevr_23
456_savevr_23:
457	li	r12,-144
458	stvx	vr23,r12,r0
459.globl	_savevr_24
460_savevr_24:
461	li	r12,-128
462	stvx	vr24,r12,r0
463.globl	_savevr_25
464_savevr_25:
465	li	r12,-112
466	stvx	vr25,r12,r0
467.globl	_savevr_26
468_savevr_26:
469	li	r12,-96
470	stvx	vr26,r12,r0
471.globl	_savevr_27
472_savevr_27:
473	li	r12,-80
474	stvx	vr27,r12,r0
475.globl	_savevr_28
476_savevr_28:
477	li	r12,-64
478	stvx	vr28,r12,r0
479.globl	_savevr_29
480_savevr_29:
481	li	r12,-48
482	stvx	vr29,r12,r0
483.globl	_savevr_30
484_savevr_30:
485	li	r12,-32
486	stvx	vr30,r12,r0
487.globl	_savevr_31
488_savevr_31:
489	li	r12,-16
490	stvx	vr31,r12,r0
491	blr
492
493.globl	_restvr_20
494_restvr_20:
495	li	r12,-192
496	lvx	vr20,r12,r0
497.globl	_restvr_21
498_restvr_21:
499	li	r12,-176
500	lvx	vr21,r12,r0
501.globl	_restvr_22
502_restvr_22:
503	li	r12,-160
504	lvx	vr22,r12,r0
505.globl	_restvr_23
506_restvr_23:
507	li	r12,-144
508	lvx	vr23,r12,r0
509.globl	_restvr_24
510_restvr_24:
511	li	r12,-128
512	lvx	vr24,r12,r0
513.globl	_restvr_25
514_restvr_25:
515	li	r12,-112
516	lvx	vr25,r12,r0
517.globl	_restvr_26
518_restvr_26:
519	li	r12,-96
520	lvx	vr26,r12,r0
521.globl	_restvr_27
522_restvr_27:
523	li	r12,-80
524	lvx	vr27,r12,r0
525.globl	_restvr_28
526_restvr_28:
527	li	r12,-64
528	lvx	vr28,r12,r0
529.globl	_restvr_29
530_restvr_29:
531	li	r12,-48
532	lvx	vr29,r12,r0
533.globl	_restvr_30
534_restvr_30:
535	li	r12,-32
536	lvx	vr30,r12,r0
537.globl	_restvr_31
538_restvr_31:
539	li	r12,-16
540	lvx	vr31,r12,r0
541	blr
542
543#endif /* CONFIG_ALTIVEC */
544
545#endif /* CONFIG_PPC64 */
546
547#endif
548