| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | /* | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This file is subject to the terms and conditions of the GNU General Public | 
					
						
							|  |  |  |  * License.  See the file "COPYING" in the main directory of this archive | 
					
						
							|  |  |  |  * for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Copyright (C) 2000 Hewlett Packard (Paul Bame bame@puffin.external.hp.com)
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2005-10-21 22:46:48 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-07-28 22:52:18 -04:00
										 |  |  | #include <asm/pdc.h> | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | #include <asm/psw.h> | 
					
						
							| 
									
										
										
										
											2005-10-21 22:40:07 -04:00
										 |  |  | #include <asm/assembly.h> | 
					
						
							| 
									
										
										
										
											2008-07-28 22:52:18 -04:00
										 |  |  | #include <asm/asm-offsets.h> | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-01-24 22:36:32 +01:00
										 |  |  | #include <linux/linkage.h> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-07-28 22:52:18 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	.section	.bss | 
					
						
							| 
									
										
										
										
											2008-07-28 22:52:18 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	.export pdc_result
 | 
					
						
							|  |  |  | 	.export pdc_result2
 | 
					
						
							|  |  |  | 	.align 8
 | 
					
						
							|  |  |  | pdc_result: | 
					
						
							|  |  |  | 	.block	ASM_PDC_RESULT_SIZE
 | 
					
						
							|  |  |  | pdc_result2: | 
					
						
							|  |  |  | 	.block	ASM_PDC_RESULT_SIZE
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	.export real_stack
 | 
					
						
							|  |  |  | 	.export real32_stack
 | 
					
						
							|  |  |  | 	.export real64_stack
 | 
					
						
							|  |  |  | 	.align	64
 | 
					
						
							|  |  |  | real_stack: | 
					
						
							|  |  |  | real32_stack: | 
					
						
							|  |  |  | real64_stack: | 
					
						
							|  |  |  | 	.block	8192
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-21 22:46:48 -04:00
										 |  |  | #ifdef CONFIG_64BIT | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | #  define REG_SZ 8 | 
					
						
							|  |  |  | #else | 
					
						
							|  |  |  | #  define REG_SZ 4 | 
					
						
							|  |  |  | #endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define N_SAVED_REGS 9 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | save_cr_space: | 
					
						
							|  |  |  | 	.block	REG_SZ * N_SAVED_REGS | 
					
						
							|  |  |  | save_cr_end: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /************************ 32-bit real-mode calls ***********************/ | 
					
						
							|  |  |  | /* This can be called in both narrow and wide kernels */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-05-22 14:36:31 -04:00
										 |  |  | 	.text | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* unsigned long real32_call_asm(unsigned int *sp, | 
					
						
							|  |  |  | 	 *		unsigned int *arg0p, | 
					
						
							|  |  |  | 	 *		unsigned int iodc_fn) | 
					
						
							|  |  |  | 	 *	sp is value of stack pointer to adopt before calling PDC (virt) | 
					
						
							|  |  |  | 	 *	arg0p points to where saved arg values may be found | 
					
						
							|  |  |  | 	 *	iodc_fn is the IODC function to call | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-01-24 22:36:32 +01:00
										 |  |  | ENTRY(real32_call_asm) | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	STREG	%rp, -RP_OFFSET(%sp)	/* save RP */ | 
					
						
							| 
									
										
										
										
											2005-10-21 22:46:48 -04:00
										 |  |  | #ifdef CONFIG_64BIT | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	callee_save | 
					
						
							|  |  |  | 	ldo	2*REG_SZ(%sp), %sp	/* room for a couple more saves */ | 
					
						
							|  |  |  | 	STREG	%r27, -1*REG_SZ(%sp) | 
					
						
							|  |  |  | 	STREG	%r29, -2*REG_SZ(%sp) | 
					
						
							|  |  |  | #endif | 
					
						
							|  |  |  | 	STREG	%sp, -REG_SZ(%arg0)	/* save SP on real-mode stack */ | 
					
						
							|  |  |  | 	copy	%arg0, %sp		/* adopt the real-mode SP */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* save iodc_fn */ | 
					
						
							|  |  |  | 	copy	%arg2, %r31 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* load up the arg registers from the saved arg area */ | 
					
						
							|  |  |  | 	/* 32-bit calling convention passes first 4 args in registers */ | 
					
						
							|  |  |  | 	ldw	0(%arg1), %arg0		/* note overwriting arg0 */ | 
					
						
							|  |  |  | 	ldw	-8(%arg1), %arg2 | 
					
						
							|  |  |  | 	ldw	-12(%arg1), %arg3 | 
					
						
							|  |  |  | 	ldw	-4(%arg1), %arg1	/* obviously must do this one last! */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	tophys_r1  %sp | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	b,l	rfi_virt2real,%r2 | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	b,l	save_control_regs,%r2		/* modifies r1, r2, r28 */ | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-21 22:46:48 -04:00
										 |  |  | #ifdef CONFIG_64BIT | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	rsm	PSW_SM_W, %r0		/* go narrow */ | 
					
						
							|  |  |  | #endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	load32	PA(ric_ret), %r2 | 
					
						
							|  |  |  | 	bv	0(%r31) | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | ric_ret: | 
					
						
							| 
									
										
										
										
											2005-10-21 22:46:48 -04:00
										 |  |  | #ifdef CONFIG_64BIT | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	ssm	PSW_SM_W, %r0		/* go wide */ | 
					
						
							|  |  |  | #endif | 
					
						
							|  |  |  | 	/* restore CRs before going virtual in case we page fault */ | 
					
						
							|  |  |  | 	b,l	restore_control_regs, %r2	/* modifies r1, r2, r26 */ | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	b,l	rfi_real2virt,%r2 | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	tovirt_r1 %sp | 
					
						
							|  |  |  | 	LDREG	-REG_SZ(%sp), %sp	/* restore SP */ | 
					
						
							| 
									
										
										
										
											2005-10-21 22:46:48 -04:00
										 |  |  | #ifdef CONFIG_64BIT | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	LDREG	-1*REG_SZ(%sp), %r27 | 
					
						
							|  |  |  | 	LDREG	-2*REG_SZ(%sp), %r29 | 
					
						
							|  |  |  | 	ldo	-2*REG_SZ(%sp), %sp | 
					
						
							|  |  |  | 	callee_rest | 
					
						
							|  |  |  | #endif | 
					
						
							|  |  |  | 	LDREG	-RP_OFFSET(%sp), %rp	/* restore RP */ | 
					
						
							|  |  |  | 	bv	0(%rp) | 
					
						
							|  |  |  | 	nop | 
					
						
							| 
									
										
										
										
											2007-01-24 22:36:32 +01:00
										 |  |  | ENDPROC(real32_call_asm) | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #  define PUSH_CR(r, where) mfctl r, %r1 ! STREG,ma %r1, REG_SZ(where) | 
					
						
							|  |  |  | #  define POP_CR(r, where) LDREG,mb -REG_SZ(where), %r1 ! mtctl %r1, r | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-05-22 14:36:31 -04:00
										 |  |  | 	.text | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | save_control_regs: | 
					
						
							|  |  |  | 	load32	PA(save_cr_space), %r28 | 
					
						
							|  |  |  | 	PUSH_CR(%cr24, %r28) | 
					
						
							|  |  |  | 	PUSH_CR(%cr25, %r28) | 
					
						
							|  |  |  | 	PUSH_CR(%cr26, %r28) | 
					
						
							|  |  |  | 	PUSH_CR(%cr27, %r28) | 
					
						
							|  |  |  | 	PUSH_CR(%cr28, %r28) | 
					
						
							|  |  |  | 	PUSH_CR(%cr29, %r28) | 
					
						
							|  |  |  | 	PUSH_CR(%cr30, %r28) | 
					
						
							|  |  |  | 	PUSH_CR(%cr31, %r28) | 
					
						
							|  |  |  | 	PUSH_CR(%cr15, %r28) | 
					
						
							|  |  |  | 	bv 0(%r2) | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | restore_control_regs: | 
					
						
							|  |  |  | 	load32	PA(save_cr_end), %r26 | 
					
						
							|  |  |  | 	POP_CR(%cr15, %r26) | 
					
						
							|  |  |  | 	POP_CR(%cr31, %r26) | 
					
						
							|  |  |  | 	POP_CR(%cr30, %r26) | 
					
						
							|  |  |  | 	POP_CR(%cr29, %r26) | 
					
						
							|  |  |  | 	POP_CR(%cr28, %r26) | 
					
						
							|  |  |  | 	POP_CR(%cr27, %r26) | 
					
						
							|  |  |  | 	POP_CR(%cr26, %r26) | 
					
						
							|  |  |  | 	POP_CR(%cr25, %r26) | 
					
						
							|  |  |  | 	POP_CR(%cr24, %r26) | 
					
						
							|  |  |  | 	bv 0(%r2) | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* rfi_virt2real() and rfi_real2virt() could perhaps be adapted for | 
					
						
							|  |  |  |  * more general-purpose use by the several places which need RFIs | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2008-05-22 14:36:31 -04:00
										 |  |  | 	.text | 
					
						
							| 
									
										
										
										
											2005-10-21 22:56:53 -04:00
										 |  |  | 	.align 128
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | rfi_virt2real: | 
					
						
							|  |  |  | 	/* switch to real mode... */ | 
					
						
							| 
									
										
										
										
											2005-10-21 22:40:07 -04:00
										 |  |  | 	rsm		PSW_SM_I,%r0 | 
					
						
							|  |  |  | 	load32		PA(rfi_v2r_1), %r1 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	nop | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2005-10-21 22:40:07 -04:00
										 |  |  | 	rsm             PSW_SM_Q,%r0  /* disable Q & I bits to load iia queue */ | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	mtctl		%r0, %cr17	/* Clear IIASQ tail */ | 
					
						
							|  |  |  | 	mtctl		%r0, %cr17	/* Clear IIASQ head */ | 
					
						
							|  |  |  | 	mtctl		%r1, %cr18	/* IIAOQ head */ | 
					
						
							|  |  |  | 	ldo		4(%r1), %r1 | 
					
						
							|  |  |  | 	mtctl		%r1, %cr18	/* IIAOQ tail */ | 
					
						
							|  |  |  | 	load32          REAL_MODE_PSW, %r1 | 
					
						
							|  |  |  | 	mtctl		%r1, %cr22 | 
					
						
							|  |  |  | 	rfi | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | rfi_v2r_1: | 
					
						
							|  |  |  | 	tophys_r1 %r2 | 
					
						
							|  |  |  | 	bv	0(%r2) | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-05-22 14:36:31 -04:00
										 |  |  | 	.text | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	.align 128
 | 
					
						
							|  |  |  | rfi_real2virt: | 
					
						
							| 
									
										
										
										
											2005-10-21 22:40:07 -04:00
										 |  |  | 	rsm		PSW_SM_I,%r0 | 
					
						
							|  |  |  | 	load32		(rfi_r2v_1), %r1 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	nop | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	rsm             PSW_SM_Q,%r0    /* disable Q bit to load iia queue */ | 
					
						
							|  |  |  | 	mtctl		%r0, %cr17	/* Clear IIASQ tail */ | 
					
						
							|  |  |  | 	mtctl		%r0, %cr17	/* Clear IIASQ head */ | 
					
						
							|  |  |  | 	mtctl		%r1, %cr18	/* IIAOQ head */ | 
					
						
							|  |  |  | 	ldo		4(%r1), %r1 | 
					
						
							|  |  |  | 	mtctl		%r1, %cr18	/* IIAOQ tail */ | 
					
						
							|  |  |  | 	load32		KERNEL_PSW, %r1 | 
					
						
							|  |  |  | 	mtctl		%r1, %cr22 | 
					
						
							|  |  |  | 	rfi | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | rfi_r2v_1: | 
					
						
							|  |  |  | 	tovirt_r1 %r2 | 
					
						
							|  |  |  | 	bv	0(%r2) | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-21 22:46:48 -04:00
										 |  |  | #ifdef CONFIG_64BIT | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | /************************ 64-bit real-mode calls ***********************/ | 
					
						
							|  |  |  | /* This is only usable in wide kernels right now and will probably stay so */ | 
					
						
							| 
									
										
										
										
											2008-05-22 14:36:31 -04:00
										 |  |  | 	.text | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	/* unsigned long real64_call_asm(unsigned long *sp, | 
					
						
							|  |  |  | 	 *		unsigned long *arg0p, | 
					
						
							|  |  |  | 	 *		unsigned long fn) | 
					
						
							|  |  |  | 	 *	sp is value of stack pointer to adopt before calling PDC (virt) | 
					
						
							|  |  |  | 	 *	arg0p points to where saved arg values may be found | 
					
						
							|  |  |  | 	 *	iodc_fn is the IODC function to call | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2007-01-24 22:36:32 +01:00
										 |  |  | ENTRY(real64_call_asm) | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	std	%rp, -0x10(%sp)		/* save RP */ | 
					
						
							|  |  |  | 	std	%sp, -8(%arg0)		/* save SP on real-mode stack */ | 
					
						
							|  |  |  | 	copy	%arg0, %sp		/* adopt the real-mode SP */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* save fn */ | 
					
						
							|  |  |  | 	copy	%arg2, %r31 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* set up the new ap */ | 
					
						
							|  |  |  | 	ldo	64(%arg1), %r29 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* load up the arg registers from the saved arg area */ | 
					
						
							|  |  |  | 	/* 32-bit calling convention passes first 4 args in registers */ | 
					
						
							|  |  |  | 	ldd	0*REG_SZ(%arg1), %arg0		/* note overwriting arg0 */ | 
					
						
							|  |  |  | 	ldd	2*REG_SZ(%arg1), %arg2 | 
					
						
							|  |  |  | 	ldd	3*REG_SZ(%arg1), %arg3 | 
					
						
							|  |  |  | 	ldd	4*REG_SZ(%arg1), %r22 | 
					
						
							|  |  |  | 	ldd	5*REG_SZ(%arg1), %r21 | 
					
						
							|  |  |  | 	ldd	6*REG_SZ(%arg1), %r20 | 
					
						
							|  |  |  | 	ldd	7*REG_SZ(%arg1), %r19 | 
					
						
							|  |  |  | 	ldd	1*REG_SZ(%arg1), %arg1		/* do this one last! */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	tophys_r1 %sp | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	b,l	rfi_virt2real,%r2 | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	b,l	save_control_regs,%r2		/* modifies r1, r2, r28 */ | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	load32	PA(r64_ret), %r2 | 
					
						
							|  |  |  | 	bv	0(%r31) | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | r64_ret: | 
					
						
							|  |  |  | 	/* restore CRs before going virtual in case we page fault */ | 
					
						
							|  |  |  | 	b,l	restore_control_regs, %r2	/* modifies r1, r2, r26 */ | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	b,l	rfi_real2virt,%r2 | 
					
						
							|  |  |  | 	nop | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	tovirt_r1 %sp | 
					
						
							|  |  |  | 	ldd	-8(%sp), %sp		/* restore SP */ | 
					
						
							|  |  |  | 	ldd	-0x10(%sp), %rp		/* restore RP */ | 
					
						
							|  |  |  | 	bv	0(%rp) | 
					
						
							|  |  |  | 	nop | 
					
						
							| 
									
										
										
										
											2007-01-24 22:36:32 +01:00
										 |  |  | ENDPROC(real64_call_asm) | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | #endif | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-05-22 14:36:31 -04:00
										 |  |  | 	.text | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	/* http://lists.parisc-linux.org/hypermail/parisc-linux/10916.html | 
					
						
							|  |  |  | 	**	GCC 3.3 and later has a new function in libgcc.a for | 
					
						
							|  |  |  | 	**	comparing function pointers. | 
					
						
							|  |  |  | 	*/ | 
					
						
							| 
									
										
										
										
											2007-01-24 22:36:32 +01:00
										 |  |  | ENTRY(__canonicalize_funcptr_for_compare) | 
					
						
							| 
									
										
										
										
											2005-10-21 22:46:48 -04:00
										 |  |  | #ifdef CONFIG_64BIT | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	bve (%r2) | 
					
						
							|  |  |  | #else | 
					
						
							|  |  |  | 	bv %r0(%r2) | 
					
						
							|  |  |  | #endif | 
					
						
							|  |  |  | 	copy %r26,%r28 | 
					
						
							| 
									
										
										
										
											2007-01-24 22:36:32 +01:00
										 |  |  | ENDPROC(__canonicalize_funcptr_for_compare) | 
					
						
							|  |  |  | 
 |