Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * | |
3 | * This file is subject to the terms and conditions of the GNU General Public | |
4 | * License. See the file "COPYING" in the main directory of this archive | |
5 | * for more details. | |
6 | * | |
7 | * Copyright (C) 2000 Hewlett Packard (Paul Bame bame@puffin.external.hp.com) | |
8 | * | |
9 | */ | |
413059f2 | 10 | |
1da177e4 | 11 | #include <asm/psw.h> |
896a3756 | 12 | #include <asm/assembly.h> |
1da177e4 | 13 | |
8e9e9844 HD |
14 | #include <linux/linkage.h> |
15 | ||
1da177e4 LT |
16 | .section .bss |
17 | .export real_stack | |
18 | .export real32_stack | |
19 | .export real64_stack | |
20 | .align 64 | |
21 | real_stack: | |
22 | real32_stack: | |
23 | real64_stack: | |
24 | .block 8192 | |
25 | ||
413059f2 | 26 | #ifdef CONFIG_64BIT |
1da177e4 LT |
27 | # define REG_SZ 8 |
28 | #else | |
29 | # define REG_SZ 4 | |
30 | #endif | |
31 | ||
32 | #define N_SAVED_REGS 9 | |
33 | ||
34 | save_cr_space: | |
35 | .block REG_SZ * N_SAVED_REGS | |
36 | save_cr_end: | |
37 | ||
38 | ||
39 | /************************ 32-bit real-mode calls ***********************/ | |
40 | /* This can be called in both narrow and wide kernels */ | |
41 | ||
42 | .text | |
43 | ||
1da177e4 LT |
44 | /* unsigned long real32_call_asm(unsigned int *sp, |
45 | * unsigned int *arg0p, | |
46 | * unsigned int iodc_fn) | |
47 | * sp is value of stack pointer to adopt before calling PDC (virt) | |
48 | * arg0p points to where saved arg values may be found | |
49 | * iodc_fn is the IODC function to call | |
50 | */ | |
51 | ||
8e9e9844 | 52 | ENTRY(real32_call_asm) |
1da177e4 | 53 | STREG %rp, -RP_OFFSET(%sp) /* save RP */ |
413059f2 | 54 | #ifdef CONFIG_64BIT |
1da177e4 LT |
55 | callee_save |
56 | ldo 2*REG_SZ(%sp), %sp /* room for a couple more saves */ | |
57 | STREG %r27, -1*REG_SZ(%sp) | |
58 | STREG %r29, -2*REG_SZ(%sp) | |
59 | #endif | |
60 | STREG %sp, -REG_SZ(%arg0) /* save SP on real-mode stack */ | |
61 | copy %arg0, %sp /* adopt the real-mode SP */ | |
62 | ||
63 | /* save iodc_fn */ | |
64 | copy %arg2, %r31 | |
65 | ||
66 | /* load up the arg registers from the saved arg area */ | |
67 | /* 32-bit calling convention passes first 4 args in registers */ | |
68 | ldw 0(%arg1), %arg0 /* note overwriting arg0 */ | |
69 | ldw -8(%arg1), %arg2 | |
70 | ldw -12(%arg1), %arg3 | |
71 | ldw -4(%arg1), %arg1 /* obviously must do this one last! */ | |
72 | ||
73 | tophys_r1 %sp | |
74 | ||
75 | b,l rfi_virt2real,%r2 | |
76 | nop | |
77 | ||
78 | b,l save_control_regs,%r2 /* modifies r1, r2, r28 */ | |
79 | nop | |
80 | ||
413059f2 | 81 | #ifdef CONFIG_64BIT |
1da177e4 LT |
82 | rsm PSW_SM_W, %r0 /* go narrow */ |
83 | #endif | |
84 | ||
85 | load32 PA(ric_ret), %r2 | |
86 | bv 0(%r31) | |
87 | nop | |
88 | ric_ret: | |
413059f2 | 89 | #ifdef CONFIG_64BIT |
1da177e4 LT |
90 | ssm PSW_SM_W, %r0 /* go wide */ |
91 | #endif | |
92 | /* restore CRs before going virtual in case we page fault */ | |
93 | b,l restore_control_regs, %r2 /* modifies r1, r2, r26 */ | |
94 | nop | |
95 | ||
96 | b,l rfi_real2virt,%r2 | |
97 | nop | |
98 | ||
99 | tovirt_r1 %sp | |
100 | LDREG -REG_SZ(%sp), %sp /* restore SP */ | |
413059f2 | 101 | #ifdef CONFIG_64BIT |
1da177e4 LT |
102 | LDREG -1*REG_SZ(%sp), %r27 |
103 | LDREG -2*REG_SZ(%sp), %r29 | |
104 | ldo -2*REG_SZ(%sp), %sp | |
105 | callee_rest | |
106 | #endif | |
107 | LDREG -RP_OFFSET(%sp), %rp /* restore RP */ | |
108 | bv 0(%rp) | |
109 | nop | |
8e9e9844 | 110 | ENDPROC(real32_call_asm) |
1da177e4 LT |
111 | |
112 | ||
113 | # define PUSH_CR(r, where) mfctl r, %r1 ! STREG,ma %r1, REG_SZ(where) | |
114 | # define POP_CR(r, where) LDREG,mb -REG_SZ(where), %r1 ! mtctl %r1, r | |
115 | ||
116 | .text | |
117 | save_control_regs: | |
118 | load32 PA(save_cr_space), %r28 | |
119 | PUSH_CR(%cr24, %r28) | |
120 | PUSH_CR(%cr25, %r28) | |
121 | PUSH_CR(%cr26, %r28) | |
122 | PUSH_CR(%cr27, %r28) | |
123 | PUSH_CR(%cr28, %r28) | |
124 | PUSH_CR(%cr29, %r28) | |
125 | PUSH_CR(%cr30, %r28) | |
126 | PUSH_CR(%cr31, %r28) | |
127 | PUSH_CR(%cr15, %r28) | |
128 | bv 0(%r2) | |
129 | nop | |
130 | ||
131 | restore_control_regs: | |
132 | load32 PA(save_cr_end), %r26 | |
133 | POP_CR(%cr15, %r26) | |
134 | POP_CR(%cr31, %r26) | |
135 | POP_CR(%cr30, %r26) | |
136 | POP_CR(%cr29, %r26) | |
137 | POP_CR(%cr28, %r26) | |
138 | POP_CR(%cr27, %r26) | |
139 | POP_CR(%cr26, %r26) | |
140 | POP_CR(%cr25, %r26) | |
141 | POP_CR(%cr24, %r26) | |
142 | bv 0(%r2) | |
143 | nop | |
144 | ||
145 | /* rfi_virt2real() and rfi_real2virt() could perhaps be adapted for | |
146 | * more general-purpose use by the several places which need RFIs | |
147 | */ | |
1da177e4 | 148 | .text |
e55fb3e7 | 149 | .align 128 |
1da177e4 LT |
150 | rfi_virt2real: |
151 | /* switch to real mode... */ | |
896a3756 GG |
152 | rsm PSW_SM_I,%r0 |
153 | load32 PA(rfi_v2r_1), %r1 | |
1da177e4 LT |
154 | nop |
155 | nop | |
156 | nop | |
157 | nop | |
158 | nop | |
159 | ||
896a3756 | 160 | rsm PSW_SM_Q,%r0 /* disable Q & I bits to load iia queue */ |
1da177e4 LT |
161 | mtctl %r0, %cr17 /* Clear IIASQ tail */ |
162 | mtctl %r0, %cr17 /* Clear IIASQ head */ | |
1da177e4 LT |
163 | mtctl %r1, %cr18 /* IIAOQ head */ |
164 | ldo 4(%r1), %r1 | |
165 | mtctl %r1, %cr18 /* IIAOQ tail */ | |
166 | load32 REAL_MODE_PSW, %r1 | |
167 | mtctl %r1, %cr22 | |
168 | rfi | |
169 | ||
170 | nop | |
171 | nop | |
172 | nop | |
173 | nop | |
174 | nop | |
175 | nop | |
176 | nop | |
177 | nop | |
178 | rfi_v2r_1: | |
179 | tophys_r1 %r2 | |
180 | bv 0(%r2) | |
181 | nop | |
182 | ||
183 | .text | |
184 | .align 128 | |
185 | rfi_real2virt: | |
896a3756 GG |
186 | rsm PSW_SM_I,%r0 |
187 | load32 (rfi_r2v_1), %r1 | |
1da177e4 LT |
188 | nop |
189 | nop | |
190 | nop | |
191 | nop | |
192 | nop | |
193 | ||
194 | rsm PSW_SM_Q,%r0 /* disable Q bit to load iia queue */ | |
195 | mtctl %r0, %cr17 /* Clear IIASQ tail */ | |
196 | mtctl %r0, %cr17 /* Clear IIASQ head */ | |
1da177e4 LT |
197 | mtctl %r1, %cr18 /* IIAOQ head */ |
198 | ldo 4(%r1), %r1 | |
199 | mtctl %r1, %cr18 /* IIAOQ tail */ | |
200 | load32 KERNEL_PSW, %r1 | |
201 | mtctl %r1, %cr22 | |
202 | rfi | |
203 | ||
204 | nop | |
205 | nop | |
206 | nop | |
207 | nop | |
208 | nop | |
209 | nop | |
210 | nop | |
211 | nop | |
212 | rfi_r2v_1: | |
213 | tovirt_r1 %r2 | |
214 | bv 0(%r2) | |
215 | nop | |
216 | ||
413059f2 | 217 | #ifdef CONFIG_64BIT |
1da177e4 LT |
218 | |
219 | /************************ 64-bit real-mode calls ***********************/ | |
220 | /* This is only usable in wide kernels right now and will probably stay so */ | |
221 | .text | |
1da177e4 LT |
222 | /* unsigned long real64_call_asm(unsigned long *sp, |
223 | * unsigned long *arg0p, | |
224 | * unsigned long fn) | |
225 | * sp is value of stack pointer to adopt before calling PDC (virt) | |
226 | * arg0p points to where saved arg values may be found | |
227 | * iodc_fn is the IODC function to call | |
228 | */ | |
8e9e9844 | 229 | ENTRY(real64_call_asm) |
1da177e4 LT |
230 | std %rp, -0x10(%sp) /* save RP */ |
231 | std %sp, -8(%arg0) /* save SP on real-mode stack */ | |
232 | copy %arg0, %sp /* adopt the real-mode SP */ | |
233 | ||
234 | /* save fn */ | |
235 | copy %arg2, %r31 | |
236 | ||
237 | /* set up the new ap */ | |
238 | ldo 64(%arg1), %r29 | |
239 | ||
240 | /* load up the arg registers from the saved arg area */ | |
241 | /* 32-bit calling convention passes first 4 args in registers */ | |
242 | ldd 0*REG_SZ(%arg1), %arg0 /* note overwriting arg0 */ | |
243 | ldd 2*REG_SZ(%arg1), %arg2 | |
244 | ldd 3*REG_SZ(%arg1), %arg3 | |
245 | ldd 4*REG_SZ(%arg1), %r22 | |
246 | ldd 5*REG_SZ(%arg1), %r21 | |
247 | ldd 6*REG_SZ(%arg1), %r20 | |
248 | ldd 7*REG_SZ(%arg1), %r19 | |
249 | ldd 1*REG_SZ(%arg1), %arg1 /* do this one last! */ | |
250 | ||
251 | tophys_r1 %sp | |
252 | ||
253 | b,l rfi_virt2real,%r2 | |
254 | nop | |
255 | ||
256 | b,l save_control_regs,%r2 /* modifies r1, r2, r28 */ | |
257 | nop | |
258 | ||
259 | load32 PA(r64_ret), %r2 | |
260 | bv 0(%r31) | |
261 | nop | |
262 | r64_ret: | |
263 | /* restore CRs before going virtual in case we page fault */ | |
264 | b,l restore_control_regs, %r2 /* modifies r1, r2, r26 */ | |
265 | nop | |
266 | ||
267 | b,l rfi_real2virt,%r2 | |
268 | nop | |
269 | ||
270 | tovirt_r1 %sp | |
271 | ldd -8(%sp), %sp /* restore SP */ | |
272 | ldd -0x10(%sp), %rp /* restore RP */ | |
273 | bv 0(%rp) | |
274 | nop | |
8e9e9844 | 275 | ENDPROC(real64_call_asm) |
1da177e4 LT |
276 | |
277 | #endif | |
278 | ||
1da177e4 LT |
279 | .text |
280 | /* http://lists.parisc-linux.org/hypermail/parisc-linux/10916.html | |
281 | ** GCC 3.3 and later has a new function in libgcc.a for | |
282 | ** comparing function pointers. | |
283 | */ | |
8e9e9844 | 284 | ENTRY(__canonicalize_funcptr_for_compare) |
413059f2 | 285 | #ifdef CONFIG_64BIT |
1da177e4 LT |
286 | bve (%r2) |
287 | #else | |
288 | bv %r0(%r2) | |
289 | #endif | |
290 | copy %r26,%r28 | |
8e9e9844 HD |
291 | ENDPROC(__canonicalize_funcptr_for_compare) |
292 |