File:  [Power 6/32 Unix Tahoe 4.2BSD] / cci / d / event / vtrans_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


#
#	Demand paging fault with read modify instruction 
#
#	R10 = PC of instruction used to force fault
#	R0  = error code
#	     1 - Expected translation fault did not happen
#		 R2 = Virtual address that should cause fault
#	     2 - Destination operand is modified after even fault is genearted
#		 R1 = actual,  R2 = expected
#	     3 - Too many parameters pushed on the stack
#		 R1 = actual SP,  R2 = expected SP
#	     4 - Fault virtual address pushed on the stack is not correct
#		 R1 = actual,  R2 = expected
#	     5 - PC pushed on the stack is not correct
#		 R1 = actual,  R2 = expected
#	     6 - PSL pushed on the stack is not correct
#		 R1 = actual,  R2 = expected
#
 	.globl	_trans_evt		
_trans_evt:
	.word	0x1fff			

	mtpr	$1,$TBIA		/* Purge Translation buffer */
	clrl	lpcnt
	movl	$TRANS,r0		/* R0 = vector no of transl. fault */
	movl	_scb[r0],_savvec0	/* Save original trans. fault handler */
	movab	_Trans,_scb[r0]		/* Set new trans. fault handler */	
	mtpr	$512,$DCR		/* Disable translation buffer */ 

	incl	lpcnt			/* Trying ANDL2 */
	movl	$0x55555555,_iob3	/* Set mask for andl2 */
	movab	_iob3,r7
	andl3	r7,$0x3fffffff,r2	/* R2 = address of mask */
	shar	$PGSHIFT,r2,r2		/* PTE no of the mask (_iob3) */
	andl2	$0x7fffffff,_Sysmap[r2]	/* Invalidate this PTE */
	movl	$0xaaaaaaaa,r8

	movab	_Ret0,Retadr		/* Set return adr for fault handler */
	movab	(sp),exp_isp		/* Set expected SP */
	movl	r8,exp_dop		/*     expected destination operand */
	movl	r7,exp_fva		/*     expected fault virtual adr */
	movab	_Etpc,exp_upc		/*     expected PC at fault */
	movab	_Etpc,r10
	movpsl	exp_upsl		/*     expected PSL at fault */

_Etpc:	andl2	(r7),r8			/* Should cause translation fault */
	movl	$1,r0
	movl	r7,r2
	jmp	*badrtn
_Ret0:
	incl	lpcnt			/* Trying ORL2 */
	movab	_iob3,r7
	movl	$0xcccccccc,r8

	movab	_Ret1,Retadr		/* Set return adr for fault handler */
	movab	(sp),exp_isp		/* Set expected SP */
	movl	r8,exp_dop		/*     expected destination operand */
	movl	r7,exp_fva		/*     expected fault virtual adr */
	movab	_Etpc1,exp_upc		/*     expected PC at fault */
	movab	_Etpc1,r10
	movpsl	exp_upsl		/*     expected PSL at fault */

_Etpc1:	orl2	(r7),r8			/* Should cause translation fault */
	movl	$1,r0
	movl	r7,r2
	jmp	*badrtn
_Ret1:
	movl	$TRANS,r0		/* R0 = vector no of transl. fault */
	movl	_savvec0,_scb[r0]	/* Restore original handler */
	movab	_iob3,r7
	andl3	r7,$0x3fffffff,r2	/* R2 = address of mask */
	shar	$PGSHIFT,r2,r2		/* PTE no of the mask (_iob3) */
	orl2	$0x80000000,_Sysmap[r2]	/* Validate this PTE */
	mtpr	$1,$TBIA		/* Purge translation buffer */ 
	mtpr	$256,$DCR		/* Disable translation buffer */ 
	ret

#
#	Translation fault Handler 
#
	.align	2
_Trans:

	movl	exp_dop,r2	/* Expected op2 after fault */
	movl	r8,r1		/* Actual op2 after fault */
	cmpl	r2,r1		/* Check if destination operand is modified */
	jeql	1f
	movl	$2,r0
	jmp	*badrtn

1:	movab	(sp),r1		/* R1 = current ISP */
	subl3	$0x10,exp_isp,r2	/* R2 = Expected ISP after exception */	
	cmpl	r1,r2
	beql	1f
	movl	$3,r0			
	jmp	*badrtn		/* Error : too many parameters pushed on ISP */
1:
	movl	(sp)+,r1	/* 1st parameter of Trans. fault : don't care */

      	movl	exp_fva,r2 	/* R2 = expected addr that cause fault */
	movl	(sp)+,r1	/* R1 = actual address */
	cmpl	r1,r2
	beql	1f
	movl	$4,r0			
	jmp	*badrtn
1:
      	movl	exp_upc,r2 	/* R2 = expected PC at fault */
	movl	(sp),r1		/* R1 = actual PC pushed */
	cmpl	r1,r2
	beql	1f
	movl	$5,r0			
	jmp	*badrtn
1:
	movl	Retadr,(sp)	/* Modify PC on SP to return */

      	andl3	$0xfffffff0,exp_upsl,r2	/* R2 = expected PSL */
	andl3	$0xfffffff0,4(sp),r1	/* R1 = actual PSL pushed */
	cmpl	r1,r2		/* Check PSL pushed on the ISP */
	beql	1f
	movl	$6,r0			
	jmp	*badrtn
1:
	rei			/* REI back ! */
#
#	*********
#	Data area
#	*********
#
	.align	2
exp_upc:
	.long	0		/* Expected PC at fault  */
exp_upsl:
	.long	0		/* Expected PSL at fault */
exp_isp:
	.long	0
exp_fva:
	.long	0		/* Expected virtual addr that cause fault */
Retadr:
	.long 	0		/* Addr used by handler to return */
lpcnt:
	.long	0
exp_dop:
	.long	0		/* Expected destination operand */

unix.superglobalmegacorp.com

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