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