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 #define N_SAVED_REGS 9
28 .block REG_SZ * N_SAVED_REGS
32 /************************ 32-bit real-mode calls ***********************/
33 /* This can be called in both narrow and wide kernels */
37 /* unsigned long real32_call_asm(unsigned int *sp,
38 * unsigned int *arg0p,
39 * unsigned int iodc_fn)
40 * sp is value of stack pointer to adopt before calling PDC (virt)
41 * arg0p points to where saved arg values may be found
42 * iodc_fn is the IODC function to call
45 ENTRY_CFI(real32_call_asm)
46 STREG %rp, -RP_OFFSET(%sp) /* save RP */
49 ldo 2*REG_SZ(%sp), %sp /* room for a couple more saves */
50 STREG %r27, -1*REG_SZ(%sp)
51 STREG %r29, -2*REG_SZ(%sp)
53 STREG %sp, -REG_SZ(%arg0) /* save SP on real-mode stack */
54 copy %arg0, %sp /* adopt the real-mode SP */
59 /* load up the arg registers from the saved arg area */
60 /* 32-bit calling convention passes first 4 args in registers */
61 ldw 0(%arg1), %arg0 /* note overwriting arg0 */
64 ldw -4(%arg1), %arg1 /* obviously must do this one last! */
71 b,l save_control_regs,%r2 /* modifies r1, r2, r28 */
75 rsm PSW_SM_W, %r0 /* go narrow */
78 load32 PA(ric_ret), %r2
83 ssm PSW_SM_W, %r0 /* go wide */
85 /* restore CRs before going virtual in case we page fault */
86 b,l restore_control_regs, %r2 /* modifies r1, r2, r26 */
93 LDREG -REG_SZ(%sp), %sp /* restore SP */
95 LDREG -1*REG_SZ(%sp), %r27
96 LDREG -2*REG_SZ(%sp), %r29
97 ldo -2*REG_SZ(%sp), %sp
100 LDREG -RP_OFFSET(%sp), %rp /* restore RP */
103 ENDPROC_CFI(real32_call_asm)
106 # define PUSH_CR(r, where) mfctl r, %r1 ! STREG,ma %r1, REG_SZ(where)
107 # define POP_CR(r, where) LDREG,mb -REG_SZ(where), %r1 ! mtctl %r1, r
110 ENTRY_CFI(save_control_regs)
111 load32 PA(save_cr_space), %r28
123 ENDPROC_CFI(save_control_regs)
125 ENTRY_CFI(restore_control_regs)
126 load32 PA(save_cr_end), %r26
138 ENDPROC_CFI(restore_control_regs)
140 /* rfi_virt2real() and rfi_real2virt() could perhaps be adapted for
141 * more general-purpose use by the several places which need RFIs
145 ENTRY_CFI(rfi_virt2real)
146 #if !defined(BOOTLOADER)
147 /* switch to real mode... */
149 load32 PA(rfi_v2r_1), %r1
156 rsm PSW_SM_Q,%r0 /* disable Q & I bits to load iia queue */
157 mtctl %r0, %cr17 /* Clear IIASQ tail */
158 mtctl %r0, %cr17 /* Clear IIASQ head */
159 mtctl %r1, %cr18 /* IIAOQ head */
161 mtctl %r1, %cr18 /* IIAOQ tail */
162 load32 REAL_MODE_PSW, %r1
176 #endif /* defined(BOOTLOADER) */
179 ENDPROC_CFI(rfi_virt2real)
183 ENTRY_CFI(rfi_real2virt)
184 #if !defined(BOOTLOADER)
186 load32 (rfi_r2v_1), %r1
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 mtctl %r1, %cr18 /* IIAOQ head */
198 mtctl %r1, %cr18 /* IIAOQ tail */
199 load32 KERNEL_PSW, %r1
213 #endif /* defined(BOOTLOADER) */
216 ENDPROC_CFI(rfi_real2virt)
220 /************************ 64-bit real-mode calls ***********************/
221 /* This is only usable in wide kernels right now and will probably stay so */
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
230 ENTRY_CFI(real64_call_asm)
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 /* load up the arg registers from the saved arg area */
239 /* 32-bit calling convention passes first 4 args in registers */
240 ldd 0*REG_SZ(%arg1), %arg0 /* note overwriting arg0 */
241 ldd 2*REG_SZ(%arg1), %arg2
242 ldd 3*REG_SZ(%arg1), %arg3
243 ldd 4*REG_SZ(%arg1), %r22
244 ldd 5*REG_SZ(%arg1), %r21
245 ldd 6*REG_SZ(%arg1), %r20
246 ldd 7*REG_SZ(%arg1), %r19
247 ldd 1*REG_SZ(%arg1), %arg1 /* do this one last! */
249 /* set up real-mode stack and real-mode ap */
251 ldo -16(%sp), %r29 /* Reference param save area */
253 b,l rfi_virt2real,%r2
256 b,l save_control_regs,%r2 /* modifies r1, r2, r28 */
259 load32 PA(r64_ret), %r2
263 /* restore CRs before going virtual in case we page fault */
264 b,l restore_control_regs, %r2 /* modifies r1, r2, r26 */
267 b,l rfi_real2virt,%r2
271 ldd -8(%sp), %sp /* restore SP */
272 ldd -0x10(%sp), %rp /* restore RP */
275 ENDPROC_CFI(real64_call_asm)
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.
284 ENTRY_CFI(__canonicalize_funcptr_for_compare)
291 ENDPROC_CFI(__canonicalize_funcptr_for_compare)