]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/csu/powerpc/crtsavres.S
MFC r339738, r339744, r339770, r339773, r339864-r339866, r339907-r339908, r339912...
[FreeBSD/FreeBSD.git] / lib / csu / powerpc / crtsavres.S
1 /*-
2  * SPDX-License-Identifier: BSD-1-Clause
3  *
4  * Copyright 2019 Justin Hibbits
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
13  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
14  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
15  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
16  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
17  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
18  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
19  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
21  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22  */
23
24 #include <machine/asm.h>
25 __FBSDID("$FreeBSD$");
26
27 .text
28
29 /*
30  * The PowerPC ABI spec requires the following save/restore functions to be
31  * provided:
32  *
33  * _savefpr_N
34  * _restfpr_N
35  * _restfpr_N_x
36  * _savegpr_N
37  * _restgpr_N
38  * _restgpr_N_x
39  * 
40  * With N ranging from 14 to 31, to save the nonvolatile registers.
41  */
42
43 #define _CRTENTRY(name) \
44         .text; \
45         .globl  name; \
46         .type   name,@function; \
47         name:
48
49 #define SAVEFPR(r)      _CRTENTRY(__CONCAT(_savefpr_,r))        \
50         stfd    r,(-256 + r * 8)(11)
51
52 SAVEFPR(14)
53 SAVEFPR(15)
54 SAVEFPR(16)
55 SAVEFPR(17)
56 SAVEFPR(18)
57 SAVEFPR(19)
58 SAVEFPR(20)
59 SAVEFPR(21)
60 SAVEFPR(22)
61 SAVEFPR(23)
62 SAVEFPR(24)
63 SAVEFPR(25)
64 SAVEFPR(26)
65 SAVEFPR(27)
66 SAVEFPR(28)
67 SAVEFPR(29)
68 SAVEFPR(30)
69 SAVEFPR(31)
70         blr
71
72 #define RESTFPR(r)      _CRTENTRY(__CONCAT(_restfpr_,r))        \
73         lfd     r,(-256 + r * 8)(11)
74
75 RESTFPR(14)
76 RESTFPR(15)
77 RESTFPR(16)
78 RESTFPR(17)
79 RESTFPR(18)
80 RESTFPR(19)
81 RESTFPR(20)
82 RESTFPR(21)
83 RESTFPR(22)
84 RESTFPR(23)
85 RESTFPR(24)
86 RESTFPR(25)
87 RESTFPR(26)
88 RESTFPR(27)
89 RESTFPR(28)
90 RESTFPR(29)
91 RESTFPR(30)
92 RESTFPR(31)
93         blr
94
95 #define SAVEGPR(r)      _CRTENTRY(__CONCAT(_savegpr_,r))        \
96         stfd    r,(-128 + r*4)(11)
97
98 SAVEGPR(14)
99 SAVEGPR(15)
100 SAVEGPR(16)
101 SAVEGPR(17)
102 SAVEGPR(18)
103 SAVEGPR(19)
104 SAVEGPR(20)
105 SAVEGPR(21)
106 SAVEGPR(22)
107 SAVEGPR(23)
108 SAVEGPR(24)
109 SAVEGPR(25)
110 SAVEGPR(26)
111 SAVEGPR(27)
112 SAVEGPR(28)
113 SAVEGPR(29)
114 SAVEGPR(30)
115 SAVEGPR(31)
116         blr
117
118 #define RESTGPR(r)      _CRTENTRY(__CONCAT(_restgpr_,r))        \
119         lwz     r,(-128 + r*4)(11)
120
121 RESTGPR(14)
122 RESTGPR(15)
123 RESTGPR(16)
124 RESTGPR(17)
125 RESTGPR(18)
126 RESTGPR(19)
127 RESTGPR(20)
128 RESTGPR(21)
129 RESTGPR(22)
130 RESTGPR(23)
131 RESTGPR(24)
132 RESTGPR(25)
133 RESTGPR(26)
134 RESTGPR(27)
135 RESTGPR(28)
136 RESTGPR(29)
137 RESTGPR(30)
138 RESTGPR(31)
139         blr
140
141 #define RESTFPR_X(r)    _CRTENTRY(__CONCAT(__CONCAT(_restfpr_,r),_x))   \
142         lfd     r,(-256 + r * 8)(11)
143
144 RESTFPR_X(14)
145 RESTFPR_X(15)
146 RESTFPR_X(16)
147 RESTFPR_X(17)
148 RESTFPR_X(18)
149 RESTFPR_X(19)
150 RESTFPR_X(20)
151 RESTFPR_X(21)
152 RESTFPR_X(22)
153 RESTFPR_X(23)
154 RESTFPR_X(24)
155 RESTFPR_X(25)
156 RESTFPR_X(26)
157 RESTFPR_X(27)
158 RESTFPR_X(28)
159 RESTFPR_X(29)
160 RESTFPR_X(30)
161 RESTFPR_X(31)
162         lwz     0,4(11)
163         mtlr    0
164         mr      1,11
165         blr
166
167 #define RESTGPR_X(r)    _CRTENTRY(__CONCAT(__CONCAT(_restgpr_,r),_x))   \
168         lwz     r,(-128 + r*4)(11)
169
170 RESTGPR_X(14)
171 RESTGPR_X(15)
172 RESTGPR_X(16)
173 RESTGPR_X(17)
174 RESTGPR_X(18)
175 RESTGPR_X(19)
176 RESTGPR_X(20)
177 RESTGPR_X(21)
178 RESTGPR_X(22)
179 RESTGPR_X(23)
180 RESTGPR_X(24)
181 RESTGPR_X(25)
182 RESTGPR_X(26)
183 RESTGPR_X(27)
184 RESTGPR_X(28)
185 RESTGPR_X(29)
186 RESTGPR_X(30)
187 RESTGPR_X(31)
188         lwz     0,4(11)
189         mtlr    0
190         mr      1,11
191         blr