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>
29 #define N_SAVED_REGS 9
32 .block REG_SZ * N_SAVED_REGS
36 /************************ 32-bit real-mode calls ***********************/
37 /* This can be called in both narrow and wide kernels */
41 .export real32_call_asm
43 /* unsigned long real32_call_asm(unsigned int *sp,
44 * unsigned int *arg0p,
45 * unsigned int iodc_fn)
46 * sp is value of stack pointer to adopt before calling PDC (virt)
47 * arg0p points to where saved arg values may be found
48 * iodc_fn is the IODC function to call
52 STREG %rp, -RP_OFFSET(%sp) /* save RP */
55 ldo 2*REG_SZ(%sp), %sp /* room for a couple more saves */
56 STREG %r27, -1*REG_SZ(%sp)
57 STREG %r29, -2*REG_SZ(%sp)
59 STREG %sp, -REG_SZ(%arg0) /* save SP on real-mode stack */
60 copy %arg0, %sp /* adopt the real-mode SP */
65 /* load up the arg registers from the saved arg area */
66 /* 32-bit calling convention passes first 4 args in registers */
67 ldw 0(%arg1), %arg0 /* note overwriting arg0 */
70 ldw -4(%arg1), %arg1 /* obviously must do this one last! */
77 b,l save_control_regs,%r2 /* modifies r1, r2, r28 */
81 rsm PSW_SM_W, %r0 /* go narrow */
84 ldil L%PA(ric_ret), %r2
85 ldo R%PA(ric_ret)(%r2), %r2
90 ssm PSW_SM_W, %r0 /* go wide */
92 /* restore CRs before going virtual in case we page fault */
93 b,l restore_control_regs, %r2 /* modifies r1, r2, r26 */
100 LDREG -REG_SZ(%sp), %sp /* restore SP */
102 LDREG -1*REG_SZ(%sp), %r27
103 LDREG -2*REG_SZ(%sp), %r29
104 ldo -2*REG_SZ(%sp), %sp
107 LDREG -RP_OFFSET(%sp), %rp /* restore RP */
112 # define PUSH_CR(r, where) mfctl r, %r1 ! STREG,ma %r1, REG_SZ(where)
113 # define POP_CR(r, where) LDREG,mb -REG_SZ(where), %r1 ! mtctl %r1, r
117 load32 PA(save_cr_space), %r28
130 restore_control_regs:
131 load32 PA(save_cr_end), %r26
144 /* rfi_virt2real() and rfi_real2virt() could perhaps be adapted for
145 * more general-purpose use by the several places which need RFIs
150 /* switch to real mode... */
151 ssm 0,0 /* See "relied upon translation" */
152 nop /* comment in interruption.S */
161 rsm (PSW_SM_Q|PSW_SM_I),%r0 /* disable Q & I bits to load iia queue */
162 mtctl %r0, %cr17 /* Clear IIASQ tail */
163 mtctl %r0, %cr17 /* Clear IIASQ head */
164 load32 PA(rfi_v2r_1), %r1
165 mtctl %r1, %cr18 /* IIAOQ head */
167 mtctl %r1, %cr18 /* IIAOQ tail */
168 load32 REAL_MODE_PSW, %r1
188 ssm 0,0 /* See "relied upon translation" */
189 nop /* comment in interruption.S */
198 rsm PSW_SM_Q,%r0 /* disable Q bit to load iia queue */
199 mtctl %r0, %cr17 /* Clear IIASQ tail */
200 mtctl %r0, %cr17 /* Clear IIASQ head */
201 load32 (rfi_r2v_1), %r1
202 mtctl %r1, %cr18 /* IIAOQ head */
204 mtctl %r1, %cr18 /* IIAOQ tail */
205 load32 KERNEL_PSW, %r1
224 /************************ 64-bit real-mode calls ***********************/
225 /* This is only usable in wide kernels right now and will probably stay so */
227 .export real64_call_asm
228 /* unsigned long real64_call_asm(unsigned long *sp,
229 * unsigned long *arg0p,
231 * sp is value of stack pointer to adopt before calling PDC (virt)
232 * arg0p points to where saved arg values may be found
233 * iodc_fn is the IODC function to call
236 std %rp, -0x10(%sp) /* save RP */
237 std %sp, -8(%arg0) /* save SP on real-mode stack */
238 copy %arg0, %sp /* adopt the real-mode SP */
243 /* set up the new ap */
246 /* load up the arg registers from the saved arg area */
247 /* 32-bit calling convention passes first 4 args in registers */
248 ldd 0*REG_SZ(%arg1), %arg0 /* note overwriting arg0 */
249 ldd 2*REG_SZ(%arg1), %arg2
250 ldd 3*REG_SZ(%arg1), %arg3
251 ldd 4*REG_SZ(%arg1), %r22
252 ldd 5*REG_SZ(%arg1), %r21
253 ldd 6*REG_SZ(%arg1), %r20
254 ldd 7*REG_SZ(%arg1), %r19
255 ldd 1*REG_SZ(%arg1), %arg1 /* do this one last! */
259 b,l rfi_virt2real,%r2
262 b,l save_control_regs,%r2 /* modifies r1, r2, r28 */
265 load32 PA(r64_ret), %r2
269 /* restore CRs before going virtual in case we page fault */
270 b,l restore_control_regs, %r2 /* modifies r1, r2, r26 */
273 b,l rfi_real2virt,%r2
277 ldd -8(%sp), %sp /* restore SP */
278 ldd -0x10(%sp), %rp /* restore RP */
284 .export pc_in_user_space
286 /* Doesn't belong here but I couldn't find a nicer spot. */
287 /* Should never get called, only used by profile stuff in time.c */
293 .export __canonicalize_funcptr_for_compare
295 /* http://lists.parisc-linux.org/hypermail/parisc-linux/10916.html
296 ** GCC 3.3 and later has a new function in libgcc.a for
297 ** comparing function pointers.
299 __canonicalize_funcptr_for_compare: