File:  [Power 6/32 Unix Tahoe 4.2BSD] / cci / d / event / vkcall_evt.s
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Sun Jul 28 12:24:19 2019 UTC (7 years ago) by root
Branches: bsd, MAIN
CVS tags: v12b, v121, HEAD
Power 6/32 Unix version 1.2b


#
#	*kernel call event test (virtual)
#	*Try KCALL 3 times with different operand specifiers
#
#	R3 = which KCALL is testing (1,2,3)
#	R0 = error code
#	     1 - Error in KSP after Kcall
#		 R1 = actual KSP,  R2 = expected KSP
#	     2 - Error in Kcall parameter pushed on the stack
#		 R1 = actual,  R2 = expected
#	     3 - Error in PC pushed on the stack
#		 R1 = actual,  R2 = expected
#	     4 - Error in PSL pushed on the stack
#		 R1 = actual,  R2 = expected
#
 	.globl	_kcall_evt		
_kcall_evt:
	.word	0x1fff			

	mtpr	$1,$TBIA		/* Purge Translation buffer */
	clrl	loopcnt			/* Try Kcall 3 times */
#
#	Set up user P2PT :
#					
	movl	$241,r1			
	movl	_unused,r2		
	movl	$255,r3			
1:
	orl3	$(PG_V|PG_UW),r2,_u0p2pt[r1]	
	incl	r2
	aobleq	r3,r1,1b

	movl	$255,r2
	andl2	$0x7fffffff,_u0p2pt[r2]   
					  
	movl	$250,r2
	andl2	$0x7fffffff,_u0p2pt[r2]   
	decl	r2
	andl2	$0x7fffffff,_u0p2pt[r2]   
	movl	$244,r2
	andl2	$0x7fffffff,_u0p2pt[r2]   
#
#	Set up User P0PT : Virtual page 0 to N are mapped
#	to physical pages that contain User code. PTEs are
#	set to valid, User/Kernel read.
#
	clrl	r2			
	andl3	$_utest,$0x3fffffff,r1	/* R1 = First addr of User code */
	andl3	$0x000003ff,r1,r7	
	shrl	$PGSHIFT,r1,r1		/* R1 = First page no of User code */
	movl	$_eutest+NBPG-1,r3	/* R3 = Last VA of user code */
	andl2	$0x3fffffff,r3
	shrl	$PGSHIFT,r3,r3		/* R3 = Last page no of User code */
1:
	orl3	$(PG_V|PG_UW),r1,_u0p0pt[r2]	/* Valid, User/Kernel write */
	incl	r2			/* Next page */
	aobleq	r3,r1,1b

	movab	_pcb0,r1		/* Initialize PCB #0 */
	movl	$0xbfffe3fc,PCB_KSP(r1)
	movl	$0xbfffe3fc,exp_ksp
	movl	$0xbffffbfc,PCB_USP(r1)
	movl	r7,PCB_PC(r1)
	movl	$0x01000000,PCB_PSL(r1)	/* PCB_PSL : User mode, IPL 0 */
	movl	$0x01000000,exp_upsl	/* Set expected PSL */
	movl	$_u0p0pt,PCB_P0BR(r1)
	movl	$_u0p1pt,PCB_P1BR(r1)
	movl	$0xbfc03400,PCB_P2BR(r1)
	movl	$3,PCB_P0LR(r1)
	movl	$8,PCB_P1LR(r1)
	movl	$0x000ffff0,PCB_P2LR(r1)

	movl	_scb+SYSVEC,_savvec0	/* Save original Kcall handler */
	movab	_u0ret,_scb+SYSVEC	/* Set new Kcall handler */	
	andl2	$0x3fffffff,r1
	mtpr	r1,$PCBB		/* Set PCBB */
	mtpr	$1,$TBIA		/* Purge translation buffer */
	mtpr	$1,$PADC		/* Purge data cache */
	movl	r13,_savvec1		/* Saved original FP */			

	ldpctx				/* Load user context */			
	rei				/* Switch to user */
#
#	Kcall Handler : service on Kernel stack
#
	.align	2
_u0ret:
	mtpr	$HIGH,$IPL
	mtpr	$1,$PADC	/* Purge data cache */

	movab	(sp),r1		/* R1 = current KSP */
	subl3	$0xc,exp_ksp,r2	/* R2 = Expected KSP after Kcall exception */	
	cmpl	r1,r2
	beql	1f
	movl	$1,r0			
	addl3	$1,loopcnt,r3
	jmp	*badrtn		/* Error : too many parameters pushed on KSP */
1:
	movl	(sp)+,r1	/* R1 = Parameter of Kcall */
	movl	$DONE,r2
	cmpl	r1,r2		/* Check Kcall parameter pushed on KSP */
	beql	1f
	movl	$2,r0		/* R0 = Which part is failed */	
	addl3	$1,loopcnt,r3
	jmp	*badrtn		/* Error : did not receive correct parameter */
1:					
      	movl	exp_upc,r2 	/* R2 = expected PC */
	movl	(sp),r1		/* R1 = actual PC pushed */
	cmpl	r1,r2		/* Check PC pushed on the KSP */
	beql	1f
	movl	$3,r0			
	addl3	$1,loopcnt,r3
	jmp	*badrtn
1:
      	movl	exp_upsl,r2 	/* R2 = expected PSL */
	andl3	$0xfffffff0,4(sp),r1	/* R1 = actual PSL pushed */
	cmpl	r1,r2		/* Check PSL pushed on the KSP */
	beql	1f
	movl	$4,r0			
	addl3	$1,loopcnt,r3
	jmp	*badrtn
1:
	incl	loopcnt		/* Increment counter */
	cmpl	$3,loopcnt
	jeql	endkct		/* If equal then end of test */
	rei			/* else REI back to user code */
endkct:
	movl	_savvec0,_scb+SYSVEC	/* Restore original Kcall handler */
	svpctx				/* Switch back to ISP */
	movl	_savvec1,r13		/* Restore original FP */		
	ret
#
#	******************************************
#	_utest = test to be mapped in user 0 space
#	******************************************
#
	.globl	_utest
_utest:
      	movab	_kc1,exp_upc 		/* expected PC after Kcall */
_kpc1:
	kcall	$DONE			/* Literal */
_kc1:
      	movab	_kc2,exp_upc 		/* expected PC after Kcall */
	movw	$DONE,r5
_kpc2:
	kcall	r5			/* Register */		
_kc2:
      	movab	_eutest,exp_upc 	/* expected PC after Kcall */
	movw	$DONE,kcpar
_kpc3:
	kcall	kcpar			/* memory */		
_eutest:
	halt			
#
#	Data area
#
	.align	2
loopcnt:
	.long	0		/* Try Kcall 3 times */		
exp_upc:
	.long	0		/* Expected PC after Kcall */
exp_upsl:
	.long	0		/* Expected PSL after Kcall */
exp_ksp:
	.long	0
kcpar:
	.long 	0

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.