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
7 * Copyright (C) 2000 Hewlett Packard (Paul Bame bame@puffin.external.hp.com)
10 #include <asm/assembly.h>
25 #define N_SAVED_REGS 9
28 .block REG_SZ * N_SAVED_REGS
31 /************************ 32-bit real-mode calls ***********************/
32 /* This can be called in both narrow and wide kernels */
36 .export real32_call_asm
38 /* unsigned long real32_call_asm(unsigned int *sp,
39 * unsigned int *arg0p,
40 * unsigned int iodc_fn)
41 * sp is value of stack pointer to adopt before calling PDC (virt)
42 * arg0p points to where saved arg values may be found
43 * iodc_fn is the IODC function to call
47 STREG %rp, -RP_OFFSET(%sp) /* save RP */
50 ldo 2*REG_SZ(%sp), %sp /* room for a couple more saves */
51 STREG %r27, -1*REG_SZ(%sp)
52 STREG %r29, -2*REG_SZ(%sp)
54 STREG %sp, -REG_SZ(%arg0) /* save SP on real-mode stack */
55 copy %arg0, %sp /* adopt the real-mode SP */
60 /* load up the arg registers from the saved arg area */
61 /* 32-bit calling convention passes first 4 args in registers */
62 ldw 0(%arg1), %arg0 /* note overwriting arg0 */
65 ldw -4(%arg1), %arg1 /* obviously must do this one last! */
72 b,l save_control_regs,%r2 /* modifies r1, r2, r28 */
76 rsm PSW_SM_W, %r0 /* go narrow */
79 ldil L%PA(ric_ret), %r2
80 ldo R%PA(ric_ret)(%r2), %r2
85 ssm PSW_SM_W, %r0 /* go wide */
87 /* restore CRs before going virtual in case we page fault */
88 b,l restore_control_regs, %r2 /* modifies r1, r2, r26 */
95 LDREG -REG_SZ(%sp), %sp /* restore SP */
97 LDREG -1*REG_SZ(%sp), %r27
98 LDREG -2*REG_SZ(%sp), %r29
99 ldo -2*REG_SZ(%sp), %sp
102 LDREG -RP_OFFSET(%sp), %rp /* restore RP */
107 # define PUSH_CR(r, where) mfctl r, %r1 ! STREG,ma %r1, REG_SZ(where)
108 # define POP_CR(r, where) LDREG,mb -REG_SZ(where), %r1 ! mtctl %r1, r
112 load32 PA(save_cr_space), %r28
125 restore_control_regs:
126 load32 PA(save_cr_space+(N_SAVED_REGS*REG_SZ)), %r26
139 /* rfi_virt2real() and rfi_real2virt() could perhaps be adapted for
140 * more general-purpose use by the several places which need RFIs
145 /* switch to real mode... */
146 ssm 0,0 /* See "relied upon translation" */
147 nop /* comment in interruption.S */
156 rsm (PSW_SM_Q|PSW_SM_I),%r0 /* disable Q & I bits to load iia queue */
157 mtctl %r0, %cr17 /* Clear IIASQ tail */
158 mtctl %r0, %cr17 /* Clear IIASQ head */
159 load32 PA(rfi_v2r_1), %r1
160 mtctl %r1, %cr18 /* IIAOQ head */
162 mtctl %r1, %cr18 /* IIAOQ tail */
163 load32 REAL_MODE_PSW, %r1
183 ssm 0,0 /* See "relied upon translation" */
184 nop /* comment in interruption.S */
193 rsm PSW_SM_Q,%r0 /* disable Q bit to load iia queue */
194 mtctl %r0, %cr17 /* Clear IIASQ tail */
195 mtctl %r0, %cr17 /* Clear IIASQ head */
196 load32 (rfi_r2v_1), %r1
197 mtctl %r1, %cr18 /* IIAOQ head */
199 mtctl %r1, %cr18 /* IIAOQ tail */
200 load32 KERNEL_PSW, %r1
219 /************************ 64-bit real-mode calls ***********************/
220 /* This is only usable in wide kernels right now and will probably stay so */
222 .export real64_call_asm
223 /* unsigned long real64_call_asm(unsigned long *sp,
224 * unsigned long *arg0p,
226 * sp is value of stack pointer to adopt before calling PDC (virt)
227 * arg0p points to where saved arg values may be found
228 * iodc_fn is the IODC function to call
231 std %rp, -0x10(%sp) /* save RP */
232 std %sp, -8(%arg0) /* save SP on real-mode stack */
233 copy %arg0, %sp /* adopt the real-mode SP */
238 /* set up the new ap */
241 /* load up the arg registers from the saved arg area */
242 /* 32-bit calling convention passes first 4 args in registers */
243 ldd 0*REG_SZ(%arg1), %arg0 /* note overwriting arg0 */
244 ldd 2*REG_SZ(%arg1), %arg2
245 ldd 3*REG_SZ(%arg1), %arg3
246 ldd 4*REG_SZ(%arg1), %r22
247 ldd 5*REG_SZ(%arg1), %r21
248 ldd 6*REG_SZ(%arg1), %r20
249 ldd 7*REG_SZ(%arg1), %r19
250 ldd 1*REG_SZ(%arg1), %arg1 /* do this one last! */
254 b,l rfi_virt2real,%r2
257 b,l save_control_regs,%r2 /* modifies r1, r2, r28 */
260 load32 PA(r64_ret), %r2
264 /* restore CRs before going virtual in case we page fault */
265 b,l restore_control_regs, %r2 /* modifies r1, r2, r26 */
268 b,l rfi_real2virt,%r2
272 ldd -8(%sp), %sp /* restore SP */
273 ldd -0x10(%sp), %rp /* restore RP */
279 .export pc_in_user_space
281 /* Doesn't belong here but I couldn't find a nicer spot. */
282 /* Should never get called, only used by profile stuff in time.c */
288 .export __canonicalize_funcptr_for_compare
290 /* http://lists.parisc-linux.org/hypermail/parisc-linux/10916.html
291 ** GCC 3.3 and later has a new function in libgcc.a for
292 ** comparing function pointers.
294 __canonicalize_funcptr_for_compare: