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
38 #define N_SAVED_REGS 9
41 .block REG_SZ * N_SAVED_REGS
45 /************************ 32-bit real-mode calls ***********************/
46 /* This can be called in both narrow and wide kernels */
50 /* unsigned long real32_call_asm(unsigned int *sp,
51 * unsigned int *arg0p,
52 * unsigned int iodc_fn)
53 * sp is value of stack pointer to adopt before calling PDC (virt)
54 * arg0p points to where saved arg values may be found
55 * iodc_fn is the IODC function to call
58 ENTRY_CFI(real32_call_asm)
59 STREG %rp, -RP_OFFSET(%sp) /* save RP */
62 ldo 2*REG_SZ(%sp), %sp /* room for a couple more saves */
63 STREG %r27, -1*REG_SZ(%sp)
64 STREG %r29, -2*REG_SZ(%sp)
66 STREG %sp, -REG_SZ(%arg0) /* save SP on real-mode stack */
67 copy %arg0, %sp /* adopt the real-mode SP */
72 /* load up the arg registers from the saved arg area */
73 /* 32-bit calling convention passes first 4 args in registers */
74 ldw 0(%arg1), %arg0 /* note overwriting arg0 */
77 ldw -4(%arg1), %arg1 /* obviously must do this one last! */
84 b,l save_control_regs,%r2 /* modifies r1, r2, r28 */
88 rsm PSW_SM_W, %r0 /* go narrow */
91 load32 PA(ric_ret), %r2
96 ssm PSW_SM_W, %r0 /* go wide */
98 /* restore CRs before going virtual in case we page fault */
99 b,l restore_control_regs, %r2 /* modifies r1, r2, r26 */
102 b,l rfi_real2virt,%r2
106 LDREG -REG_SZ(%sp), %sp /* restore SP */
108 LDREG -1*REG_SZ(%sp), %r27
109 LDREG -2*REG_SZ(%sp), %r29
110 ldo -2*REG_SZ(%sp), %sp
113 LDREG -RP_OFFSET(%sp), %rp /* restore RP */
116 ENDPROC_CFI(real32_call_asm)
119 # define PUSH_CR(r, where) mfctl r, %r1 ! STREG,ma %r1, REG_SZ(where)
120 # define POP_CR(r, where) LDREG,mb -REG_SZ(where), %r1 ! mtctl %r1, r
123 ENTRY_CFI(save_control_regs)
124 load32 PA(save_cr_space), %r28
136 ENDPROC_CFI(save_control_regs)
138 ENTRY_CFI(restore_control_regs)
139 load32 PA(save_cr_end), %r26
151 ENDPROC_CFI(restore_control_regs)
153 /* rfi_virt2real() and rfi_real2virt() could perhaps be adapted for
154 * more general-purpose use by the several places which need RFIs
158 ENTRY_CFI(rfi_virt2real)
159 #if !defined(BOOTLOADER)
160 /* switch to real mode... */
162 load32 PA(rfi_v2r_1), %r1
169 rsm PSW_SM_Q,%r0 /* disable Q & I bits to load iia queue */
170 mtctl %r0, %cr17 /* Clear IIASQ tail */
171 mtctl %r0, %cr17 /* Clear IIASQ head */
172 mtctl %r1, %cr18 /* IIAOQ head */
174 mtctl %r1, %cr18 /* IIAOQ tail */
175 load32 REAL_MODE_PSW, %r1
189 #endif /* defined(BOOTLOADER) */
192 ENDPROC_CFI(rfi_virt2real)
196 ENTRY_CFI(rfi_real2virt)
197 #if !defined(BOOTLOADER)
199 load32 (rfi_r2v_1), %r1
206 rsm PSW_SM_Q,%r0 /* disable Q bit to load iia queue */
207 mtctl %r0, %cr17 /* Clear IIASQ tail */
208 mtctl %r0, %cr17 /* Clear IIASQ head */
209 mtctl %r1, %cr18 /* IIAOQ head */
211 mtctl %r1, %cr18 /* IIAOQ tail */
212 load32 KERNEL_PSW, %r1
226 #endif /* defined(BOOTLOADER) */
229 ENDPROC_CFI(rfi_real2virt)
233 /************************ 64-bit real-mode calls ***********************/
234 /* This is only usable in wide kernels right now and will probably stay so */
236 /* unsigned long real64_call_asm(unsigned long *sp,
237 * unsigned long *arg0p,
239 * sp is value of stack pointer to adopt before calling PDC (virt)
240 * arg0p points to where saved arg values may be found
241 * iodc_fn is the IODC function to call
243 ENTRY_CFI(real64_call_asm)
244 std %rp, -0x10(%sp) /* save RP */
245 std %sp, -8(%arg0) /* save SP on real-mode stack */
246 copy %arg0, %sp /* adopt the real-mode SP */
251 /* set up the new ap */
254 /* load up the arg registers from the saved arg area */
255 /* 32-bit calling convention passes first 4 args in registers */
256 ldd 0*REG_SZ(%arg1), %arg0 /* note overwriting arg0 */
257 ldd 2*REG_SZ(%arg1), %arg2
258 ldd 3*REG_SZ(%arg1), %arg3
259 ldd 4*REG_SZ(%arg1), %r22
260 ldd 5*REG_SZ(%arg1), %r21
261 ldd 6*REG_SZ(%arg1), %r20
262 ldd 7*REG_SZ(%arg1), %r19
263 ldd 1*REG_SZ(%arg1), %arg1 /* do this one last! */
267 b,l rfi_virt2real,%r2
270 b,l save_control_regs,%r2 /* modifies r1, r2, r28 */
273 load32 PA(r64_ret), %r2
277 /* restore CRs before going virtual in case we page fault */
278 b,l restore_control_regs, %r2 /* modifies r1, r2, r26 */
281 b,l rfi_real2virt,%r2
285 ldd -8(%sp), %sp /* restore SP */
286 ldd -0x10(%sp), %rp /* restore RP */
289 ENDPROC_CFI(real64_call_asm)
294 /* http://lists.parisc-linux.org/hypermail/parisc-linux/10916.html
295 ** GCC 3.3 and later has a new function in libgcc.a for
296 ** comparing function pointers.
298 ENTRY_CFI(__canonicalize_funcptr_for_compare)
305 ENDPROC_CFI(__canonicalize_funcptr_for_compare)