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)
13 #include <asm/assembly.h>
14 #include <asm/asm-offsets.h>
16 #include <linux/linkage.h>
25 .block ASM_PDC_RESULT_SIZE
27 .block ASM_PDC_RESULT_SIZE
44 #define N_SAVED_REGS 9
47 .block REG_SZ * N_SAVED_REGS
51 /************************ 32-bit real-mode calls ***********************/
52 /* This can be called in both narrow and wide kernels */
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
64 ENTRY_CFI(real32_call_asm)
65 STREG %rp, -RP_OFFSET(%sp) /* save RP */
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)
72 STREG %sp, -REG_SZ(%arg0) /* save SP on real-mode stack */
73 copy %arg0, %sp /* adopt the real-mode SP */
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 */
83 ldw -4(%arg1), %arg1 /* obviously must do this one last! */
90 b,l save_control_regs,%r2 /* modifies r1, r2, r28 */
94 rsm PSW_SM_W, %r0 /* go narrow */
97 load32 PA(ric_ret), %r2
102 ssm PSW_SM_W, %r0 /* go wide */
104 /* restore CRs before going virtual in case we page fault */
105 b,l restore_control_regs, %r2 /* modifies r1, r2, r26 */
108 b,l rfi_real2virt,%r2
112 LDREG -REG_SZ(%sp), %sp /* restore SP */
114 LDREG -1*REG_SZ(%sp), %r27
115 LDREG -2*REG_SZ(%sp), %r29
116 ldo -2*REG_SZ(%sp), %sp
119 LDREG -RP_OFFSET(%sp), %rp /* restore RP */
122 ENDPROC_CFI(real32_call_asm)
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
129 ENTRY_CFI(save_control_regs)
130 load32 PA(save_cr_space), %r28
142 ENDPROC_CFI(save_control_regs)
144 ENTRY_CFI(restore_control_regs)
145 load32 PA(save_cr_end), %r26
157 ENDPROC_CFI(restore_control_regs)
159 /* rfi_virt2real() and rfi_real2virt() could perhaps be adapted for
160 * more general-purpose use by the several places which need RFIs
164 ENTRY_CFI(rfi_virt2real)
165 #if !defined(BOOTLOADER)
166 /* switch to real mode... */
168 load32 PA(rfi_v2r_1), %r1
175 rsm PSW_SM_Q,%r0 /* disable Q & I bits to load iia queue */
176 mtctl %r0, %cr17 /* Clear IIASQ tail */
177 mtctl %r0, %cr17 /* Clear IIASQ head */
178 mtctl %r1, %cr18 /* IIAOQ head */
180 mtctl %r1, %cr18 /* IIAOQ tail */
181 load32 REAL_MODE_PSW, %r1
195 #endif /* defined(BOOTLOADER) */
198 ENDPROC_CFI(rfi_virt2real)
202 ENTRY_CFI(rfi_real2virt)
203 #if !defined(BOOTLOADER)
205 load32 (rfi_r2v_1), %r1
212 rsm PSW_SM_Q,%r0 /* disable Q bit to load iia queue */
213 mtctl %r0, %cr17 /* Clear IIASQ tail */
214 mtctl %r0, %cr17 /* Clear IIASQ head */
215 mtctl %r1, %cr18 /* IIAOQ head */
217 mtctl %r1, %cr18 /* IIAOQ tail */
218 load32 KERNEL_PSW, %r1
232 #endif /* defined(BOOTLOADER) */
235 ENDPROC_CFI(rfi_real2virt)
239 /************************ 64-bit real-mode calls ***********************/
240 /* This is only usable in wide kernels right now and will probably stay so */
242 /* unsigned long real64_call_asm(unsigned long *sp,
243 * unsigned long *arg0p,
245 * sp is value of stack pointer to adopt before calling PDC (virt)
246 * arg0p points to where saved arg values may be found
247 * iodc_fn is the IODC function to call
249 ENTRY_CFI(real64_call_asm)
250 std %rp, -0x10(%sp) /* save RP */
251 std %sp, -8(%arg0) /* save SP on real-mode stack */
252 copy %arg0, %sp /* adopt the real-mode SP */
257 /* set up the new ap */
260 /* load up the arg registers from the saved arg area */
261 /* 32-bit calling convention passes first 4 args in registers */
262 ldd 0*REG_SZ(%arg1), %arg0 /* note overwriting arg0 */
263 ldd 2*REG_SZ(%arg1), %arg2
264 ldd 3*REG_SZ(%arg1), %arg3
265 ldd 4*REG_SZ(%arg1), %r22
266 ldd 5*REG_SZ(%arg1), %r21
267 ldd 6*REG_SZ(%arg1), %r20
268 ldd 7*REG_SZ(%arg1), %r19
269 ldd 1*REG_SZ(%arg1), %arg1 /* do this one last! */
273 b,l rfi_virt2real,%r2
276 b,l save_control_regs,%r2 /* modifies r1, r2, r28 */
279 load32 PA(r64_ret), %r2
283 /* restore CRs before going virtual in case we page fault */
284 b,l restore_control_regs, %r2 /* modifies r1, r2, r26 */
287 b,l rfi_real2virt,%r2
291 ldd -8(%sp), %sp /* restore SP */
292 ldd -0x10(%sp), %rp /* restore RP */
295 ENDPROC_CFI(real64_call_asm)
300 /* http://lists.parisc-linux.org/hypermail/parisc-linux/10916.html
301 ** GCC 3.3 and later has a new function in libgcc.a for
302 ** comparing function pointers.
304 ENTRY_CFI(__canonicalize_funcptr_for_compare)
311 ENDPROC_CFI(__canonicalize_funcptr_for_compare)