File:  [Power 6/32 Unix Tahoe 4.2BSD] / cci / d / mem / init.x
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs
Sun Jul 28 12:30:15 2019 UTC (6 years, 11 months ago) by root
Branches: bsd, MAIN
CVS tags: v121, HEAD
Power 6/32 Unix version 1.21


/*	init.s    Memory Test memtst.					*/
/*					*/
/* Memtst Revision History */
/* V1.1     ?      ?  First original version */
/* R1.2 22-APR-86 rfw Updated for a 20 MB "mixed" config of 4 4Mb boards 0-3 */
/*			and 4 1Mb boards 4-7.                                */
/*		      Fixed user interface: (1) deleted redundant code to    */
/*		       query user again for test no and cycle count in diag  */
/*		       mode, (2) added a test number input validity check to */
/*		       prevent random runs and infinite loop on invalid input*/
/*		      Modules updated: monitor.c, locate.c, definitions.     */
/*					*/
/*	This file is a diagnostic version of locore.s.			*/
/*	It contains the following:					*/
/*	*system data area = scb, dump buffer, interrupt stack,		*/
/*	*system page table,user page tables,pcbs,iomap, & io buffers.	*/
/*									*/
/*	*system code = interrupt vectors, initialization of system data,*/
/*	*memory size calculation,initialization of SPT, zeroing of	*/
/*	*unused memory, & loading of SBR & SLR.				*/
/*	*								*/
/*	*at the end of this code, you are ready to go to virtual mode.	*/
/*	* --- GOOD LUCK!						*/


/*	privileged registers addresses	*/
#include	"prvreg.h"
	
/*	program status long word definition	*/
#include	"psl.h"	

/* 	page table entry definition		*/
#include	"pte.h"
	
/*	process control block offsets	*/
#include	"pcboffset.h"	

/*	fundamental constants for globl use	*/
#include	"const.h"	

/*	system control block offsets*/
#include	"scboffset.h"
/*	SPT offsets				*/
#include	"sptoffset.h"

/*	trap numbers*/
#include	"trap.h"	


#define V_TRAP		0
#define V_SYSCALL	4

	.set	HIGH,0x1f	/*mask for disabling all interrupts	*/
	.set	MCKVEC,4	/*scb offset for machinecheck vector	*/
	.set	NISP,2		/*no. of interrupt stack pages		*/
	.set	DONE,255	/*user process done code		*/

	.text

#include "pstorage.s"		/* PROCESSOR STORAGE AREA 		*/

	.globl	_Entry
_Entry:
	jmp	start
	.space  (1024-6)




/*		globl dump buffer to be used for communication		*/
/*		between tests & interrupt handlers, & other misc.	*/
/*		purposes.						*/
				
				/*physical page 3			*/

	.set	NLWU,41		/*no. of longwords already used		*/
				/*this must be changed when you define	*/
				/*additional variables below before	*/
				/*_dbuf					*/
	.globl	_restart
_restart:
	.space	4		/*contains restart address for restarting*/
				/*after power is restored (loaded by	*/
				/*power fail interrupt handler & used by*/
				/*CPU 2					*/	
	.globl	_maxmem
_maxmem:
	.space	4		/*memory size in no of bytes		*/

	.globl	_maxpages
_maxpages:
	.space	4		/*memory size in no. of physical pages	*/

	.globl	_lastadd
_lastadd:
	.space	4		/*address of the last long word		*/

	.globl	_unused
_unused:
	.space	4		/*first unused page in system space	*/

	.globl	_ctlblk
_ctlblk:
	.long	0		/* pointer to SCB */

	.globl	_savvec0	/*save vectors area			*/
_savvec0:
	.space	4

	.globl	_savvec1	/*save vectors area			*/
_savvec1:
	.space	4

	.globl	_savvec2	/*save vectors area			*/
_savvec2:
	.space	4

	.globl	_savvec3	/*save vectors area			*/
_savvec3:
	.space	4

	.globl	_savvec4	/*save vectors area			*/
_savvec4:
	.space	4

	.globl	_savvec5	/*save vectors area			*/
_savvec5:
	.space	4
	.globl	_savvec6	/*save vectors area			*/
_savvec6:
	.space	4
	.globl	_savvec7	/*save vectors area			*/
_savvec7:
	.space	4

	.globl	_savvec8	/*save vectors area			*/
_savvec8:
	.space	4

	.globl	badrtn
badrtn:
	.long	0 

	.long	0

	.globl	_dbuf		/*dump buffer left out of 1K		*/
	.globl	_r_no
_r_no:
	.long	0
	.globl	_pt_base
_pt_base:
	.long	0
	.globl	_saved_psl
_saved_psl:
	.long   0
	.globl	_saved_sp
_saved_sp:
	.long	0
	.globl	_saved_fp
_saved_fp:
	.long	0
	.globl	_p_ptr
_p_ptr:
	.long   0
	.globl	_ret_adr
_ret_adr:
	.long	0
	.globl	_exp_par0
_exp_par0:
	.long	0
	.globl	_exp_par1
_exp_par1:
	.long	0
	.globl	_exp_par2
_exp_par2:
	.long	0
	.globl	_exp_par3
_exp_par3:
	.long	0
	.globl	_act_par0
_act_par0:
	.long	0
	.globl	_act_par1
_act_par1:
	.long	0
	.globl	_act_par2
_act_par2:
	.long	0
	.globl	_act_par3
_act_par3:
	.long	0
	.long	0
	.globl	_clk_cnt
_clk_cnt:
	.long	0		/* Clock int. count */
	.globl	_loop_flg
_loop_flg:
	.long	0
	.globl	_errcnt
_errcnt:
	.long	0
	.globl	_cycle
_cycle:
	.long	0
	.globl	_hlt_flg
_hlt_flg:
	.long	0
	.long	0
	.globl	_endprog
_endprog:
	.long	0
	.globl	_nonstop
_nonstop:
	.long	0
_dbuf:
	.space	NBPG - (NLWU *4)
edbuf:


	.globl	_intstack	/* Interrupt stack			*/
_intstack:			/* Physical pages 4 & 5			*/
	.space	NISP*NBPG
eintstack:


	.set	SYSPTSIZE,512	/* No. of entries in SPT		*/
 
/*
	System Page Table -- physical page 6 & 7
*/ 
	.align	2
	.globl	_Sysmap
_Sysmap:
	.space	SYSPTSIZE*4 	/* 512 max pages allowed for system	*/
eSysmap:
	.globl	_Syssize
	.set	_Syssize,(eSysmap-_Sysmap)/4	/* should be SYSPTSIZE	*/
	
	.globl	_iomap		/* Physical page 8	*/
_iomap:	.space	1024		/* IOMAP - unused 	*/
	.globl	_eiomap
_eiomap:

	.globl	_pcb0		/* Physical page 9	*/
_pcb0:	.space	128		/*process control block 0		*/
	.globl	_pcb1
_pcb1:	.space 128		/*process control block 1		*/
	.globl	_pcb2
_pcb2:	.space 128		/*process control block 2		*/
	.globl	_pcb3
_pcb3:	.space 128		/*process control block 3		*/
	.globl	_pcb4
_pcb4:	.space 128		/*process control block 4		*/
	.globl	_pcb5
_pcb5:	.space 128		/*process control block 5		*/
	.globl	_pcb6
_pcb6:	.space 128		/*process control block 6		*/
	.globl	_pcb7
_pcb7:	.space 128		/*process control block 7		*/

/*
	*user #0 page tables -- P0PT, P1PT, P2PT			
	*physical memory     --  page10, 11, & 12  respectively
*/
	.align	2
	.globl	_u0p0pt
_u0p0pt:
	.space	1024		/*255 max pages for user #0 text	*/
	.globl	_u0p1pt
_u0p1pt:	
	.space	1024		/*255 max pages for user #0 data	*/
	.globl	_u0p2pt
_u0p2pt:	
	.space	1020		/*255 max pages for user #0 stack	*/
eu0p2pt:
	.space	4

/*
	*user #1 page tables -- P0PT, P1PT, P2PT			
	*physical memory     --  page13 ,14, & 15  respectively
*/
	.align	2
	.globl	_u1p0pt
_u1p0pt:
	.space	1024		/*255 max pages for user #1 text	*/
	.globl	_u1p1pt
_u1p1pt:	
	.space	1024		/*255 max pages for user #1 data	*/
	.globl	_u1p2pt
_u1p2pt:	
	.space	1020		/*255 max pages for user #1 stack	*/
eu1p2pt:
	.space	4


/*
	*user #2 page tables -- P0PT, P1PT, P2PT			
	*physical memory     --  page 16, 17 , & 18  respectively
*/
	.align	2
	.globl	_u2p0pt
_u2p0pt:
	.space	1024		/*255 max pages for user #2 text	*/
	.globl	_u2p1pt
_u2p1pt:	
	.space	1024		/*255 max pages for user #2 data	*/
	.globl	_u2p2pt
_u2p2pt:	
	.space	1020		/*255 max pages for user #2 stack	*/
eu2p2pt:
	.space	4


/*
	*user #3 page tables -- P0PT, P1PT, P2PT			
	*physical memory     --  page 19, 20 , & 21  respectively
*/
	.align	2
	.globl	_u3p0pt
_u3p0pt:
	.space	1024		/*255 max pages for user #3 text	*/
	.globl	_u3p1pt
_u3p1pt:	
	.space	1024		/*255 max pages for user #3 data	*/
	.globl	_u3p2pt
_u3p2pt:	
	.space	1020		/*255 max pages for user #3 stack	*/
eu3p2pt:
	.space	4

/*
	*user #4 thru 6 page tables
	*physical memory -- pages 22 thru 30
*/
	.globl	_u4p0pt
_u4p0pt:
	.space	(9*NBPG) - 4
eu6p2pt:
	.space	4

/*
	*user #7 page tables -- P0PT, P1PT, P2PT			
	*physical memory     --  page 31, 32 , & 33  respectively
*/
	.align	2
	.globl	_u7p0pt
_u7p0pt:
	.space	1024		/*255 max pages for user #7 text	*/
	.globl	_u7p1pt
_u7p1pt:	
	.space	1024		/*255 max pages for user #7 data	*/
	.globl	_u7p2pt
_u7p2pt:	
	.space	1020		/*255 max pages for user #7 stack	*/
eu7p2pt:
	.space	4

	.globl	_iob0		/*io buffer 0 */
_iob0:	.space	1024
	.globl	_iob1		/*io buffer 1 */
_iob1:	.space	1024
	.globl	_iob2		/*io buffer 2 */
_iob2:	.space	1024
	.globl	_iob3		/*io buffer 3 */
_iob3:	.space	1024
	.globl	_iob4		/*io buffer 4 */
_iob4:	.space	1024
	.globl	_iob5		/*io buffer 5 */
_iob5:	.space	1024
	.globl	_iob6		/*io buffer 6 */
_iob6:	.space	1024
esysdata:

#include "scblock.s"		/* SYSTEM CONTROL BLOCK 		*/

#include	"evthandlers.s"	/*event handlers			*/

#define	ACBL(_n1,_n2,_n3,_n4) \
addl2	_n2,_n3;\
cmpl	_n3,_n1;\
bleq	_n4;

	.set	MEMUNIT,64*1024
	.set	MAXPHYSMEM,32*1024*1024-1
	.set	ERRCD,0x7
	.set	APE,0x1
	.set	DCE,0x3
	.set	VTO,0x4



/*
	*INITIALIZATION CODE
	*
	* MME off; mode = k; IPL = 31; IS = 1
	*
*/

	.globl	start
start:
	mtpr	$0,$MME		/* Disable MME */
	andl3	$4,r11,_ss1	/* messages sense switch */
	movl	r0,_test_no	/* save test number */
	movl	r1,_OPTIONS	/* save option bits */
	clrl	_nonstop
	movl	r2,_count	/* save cycle count */
	cmpl	$0xffffffff,r2	/* Is count == -1 */
	bneq	1f
	movl	$1,_nonstop	/* Yes : NONSTOP */
1:
	cmpl	$0x0,r2		/* Is count == 0 */
	bneq	1f
	movl	$1,_count	/* Yes : set default count to 1 */
1:
	movab	_scb,r0
	andl2	$0x3ffffc00,r0
	mtpr	r0,$SCBB	/* Set SCBB  */
	mtpr	$0x1f,$IPL	/* Set IPL to HIGH */

	movpsl	r1
	andl2	$0xffffff00,r1		/* Mask out flags		*/
	cmpl	r1,$0x041f0000		/*IS on,modes =k & IPL = 31?	*/
	beql	1f
2:	movl	$1,r0
	movl	$0x041f0000,r2
	halt			/* PSL not initialized as expected	*/
/*
#	Mask out bit 30,31 of SCB vectors
#	Will turm them back on when ready to go virtual in 
#	system space
*/
1:
	clrl	_clk_cnt
	movl	$7,r0		/* R0 : Vector no. of clock int. */
	movab	_Hardclk,_scb[r0]	/* New vector for clock */

	movl	$_intstack+NISP*NBPG,r0
	andl2	$0x3fffffff,r0		/* Mask out bit 30,31 */
	mtpr	r0,$ISP			/* init. ISP		*/
	movl	r0,sp			/* in case we get exception	*/
	movab	(sp),fp			/* Initialize FP	  	*/
/*
 	Clear system data area all the way upto system code
 	this includes dump buffer,interrupt stack,spt,iomap,pcbs,user 
 	page tables, & io buffer area.
*/
3:	
	movab	esysdata,r7
	movab	_restart,r6
1:	clrl	(r6)
	ACBL(r7,$4,r6,1b)
/*
	Count memory
*/
	clrl	r3
	movl	_scb+BEVEC,r12
	movab	9f,_scb+BEVEC		/* new interrupt handler */
1:	tstl	(r3)
	clrl	r0			/* allow 100ns delay	*/
	addl2	$MEMUNIT,r3
	cmpl	r3,$MAXPHYSMEM		/* excess max memory size? */
	bleq	1b
2:
	subl3	$4,r3,_maxmem 
	movl	r12,_scb+BEVEC		/* restore interrupt handler */
	jmp	_ready

	.align	2
9:	andl3	4(sp),$ERRCD,r0		/* Here's where we get the bus err */
	cmpl	r0,$APE			/* data parity error */
	bneq	1f
	halt
1:	cmpl	r0,$VTO			/* versabus Error */
	bneq	1f
	halt
1:	movab	8(sp),sp
	movab	2b,(sp)
	mtpr 	$1,$TBIA		/* Purge all */
	mtpr 	$1,$PADC		/* Purge all data cache */
	rei

	.globl	_ready
_ready:
	mtpr	$64,$DCR	/* Enable fault */				
	andl3	$0x3ffffc00,$_end+NBPG-1,_endprog

	callf	$4,_monitor
	mtpr	$2,$27		/* Disable Data cache */
	clrl	_cycle
	clrl	_errcnt
2:
	movl	$1,_test_no
	bitl	$1,_tstmsk
	beql	1f
	callf	$4,_stest1
1:
	incl	_test_no
	bitl	$2,_tstmsk
	beql	1f
	callf	$4,_stest2
1:
	incl	_test_no
	bitl	$4,_tstmsk
	beql	1f
	callf	$4,_stest3
1:
	mtpr	$0x1e,$IPL	/* Set IPL to a low value*/
	callf	$4,_i_ecc	/* Init. memory + ECC */
	incl	_test_no
	bitl	$8,_tstmsk
	beql	1f
	callf	$4,_subtest4
1:
	incl	_test_no
	bitl	$16,_tstmsk
	beql	1f
	callf	$4,_subtest5
1:
	incl	_test_no
	bitl	$32,_tstmsk
	beql	1f
	callf	$4,_subtest6
1:
	pushl	$endmsg		/* Write cycle count */
	mtpr	$0x1f,$IPL	/* Set IPL to a high value*/
	bitl	$8,_OPTIONS	/* print message ? */
	beql	1f
	callf	$8,_writes
	incl	_cycle
	pushl	_cycle
	callf	$8,_writed
1:
	tstl	_nonstop	/* Is loop forever ? */
	beql	4f
	jmp	2b		/* Yes : Jump back */
4:
	decl	_count
	tstl	_count		/* Is count == 0 ? */
	beql	1f
	jmp	2b		/* No : Continue */
1:
	bitl	$8,_OPTIONS	/* suppress message ? */
	beql	1f
	pushl	$emsg
	callf	$8,_writes
	pushl	_cycle
	callf	$8,_writed
	pushl	$ermsg
	callf	$8,_writes
	pushl	_errcnt
	callf	$8,_writed
	pushl	$ermsg1
	callf	$8,_writes
1:
	movl	$0xCAFEBABE,r0
	halt
#
#
#	***********************************
#	* Routine to test an ECC location *
#	* ecccor(addr) : Read from this   *
#	* addr. ECC correction is enable. *
#	* Return in R0 :		  *
#	*    0 = Didnot get Buser 	  *
#	*   -1 = Got DCE		  *
#	*   -2 = Unexpected Buser 	  *
#	***********************************
#
	.align	2
	.globl  _ecccor
_ecccor: .word	0x1ffe
	movl	_scb+BEVEC,_savvec2	/* Save bus error vector */
	movab	9f,_scb+BEVEC		/* Set new vector */
	movl	4(fp),r1		/* get test address */
	movl	$0x3,0xffffb000		/* Turn ON ECC detection,correction */
	movl	0xffffb000,r0
	movl	(r1),*8(fp)		/* Read data */
	movl	$2,r0			/* timeout value*/
1:
	decl	r0
	bgtr	1b

	clrl	r0			/* indicate timeout */
	movl	$0x80,0xffffb000	/* Turn OFF ECC detection */
	movl	_savvec2,_scb+BEVEC
	ret
#
#
#	***********************************
#	* Routine to test an ECC location *
#	* eccloc(addr) : Read from this   *
#	* addr. ECC detection is enable.  *
#	* Return in R0 :		  *
#	*    0 = Didnot get Buser 	  *
#	*   -1 = Got DCE		  *
#	*   -2 = Unexpected Buser 	  *
#	***********************************
#
	.align	2
	.globl  _eccloc
_eccloc: .word	0x1ffe
	movl	_scb+BEVEC,_savvec2	/* Save bus error vector */
	movab	9f,_scb+BEVEC		/* Set new vector */
	movl	4(fp),r2		/* get test address */
	movl	$0x1,0xffffb000		/* Turn ON ECC detection */
	movl	0xffffb000,r0
	movl	(r2),r1			/* Read data */
	movl	$4,r0			/* timeout value*/
1:	decl	r0
	bgtr	1b

	movl	0xffffb000,_ber1	/* Read MCR */
	movl	0xffffb008,_ber3	/* Read MCBR */
	movl	r1,_ber2		/* Data read */

	clrl	r0			/* indicate timeout */
#
# 	Return after Bus error
#
2:
	movl	$0xc0,0xffffb000	/* Turn OFF ECC, clear error */
	movl	_savvec2,_scb+BEVEC
	ret
#
#	*********************
#	* Bus Error handler *
#	*********************
#
	.align	2
9:
	movl	$0xc0,0xffffb000	/* Turn OFF ECC detection */
	andl3	4(sp),$ERRCD,r0		/* Here's where we get the bus err */
	movl	(sp),_tmp_mcbr		/* save current MCBR  */
	movl	4(sp),_tmp_mear		/* save current MEAR  */
	cmpl	r0,$DCE			/* Data Check error ? */
	beql	3f
	movl	$-2,r0			/* indicate wrong Buser */
	brw 	4f
3:
	movl	$-1,r0			/* Indicate got a DCE */
4:	movab	8(sp),sp
	movab	2b,(sp)
	movl	_tmp_mcbr,_ber1
	movl	_tmp_mear,_ber2
	rei

	.align	2
	.globl	_ber1
_ber1:	.long	0		/* Bus error Parameter no. 1 */
	.globl	_ber2
_ber2:	.long	0		/* Bus error Parameter no. 1 */
	.globl	_ber3
_ber3:	.long	0
#
#	*********************
#
	.align	2
	.globl	_Hardclk
_Hardclk:
	incl	_clk_cnt
	rei

	.align 	2
	.globl  _tstmsk
_tstmsk: .long	0		/* tests to run */
	.globl	_ss1
_ss1:	.long	0	/* If 1 then donot print heading messages */
	.globl	_prt_flg
_prt_flg: .long	0		/* print enable */

	.globl	_OPTIONS
	.globl	_test_no
_test_no: .long 0
	.globl	_count
_count: .long 0
	.globl	_diagmode
_diagmode: .long 0
	.globl	_tmp_mcbr
_tmp_mcbr: .long 0
	.globl	_tmp_mear
_tmp_mear: .long 0
	.globl	err1
err1:
	.ascii	"\nRegisters : \0"
	.globl	err2
err2:	
	.ascii	"  \0"
	.globl	err3
err3:	
	.ascii	"\n            \0"
	.globl	err4
err4:	
	.ascii	"\n\0"
	.globl	e_type
e_type:	
	.ascii	"\n** Unexpected exception type :  \0"
	.globl	par_0
par_0:	
	.ascii	"** Par 0 : \0"
	.globl	par_1
par_1:	
	.ascii	"** Par	1 : \0"
	.globl	par_pc
par_pc:
	.ascii	"** PC    : \0"
	.globl	par_psl	
par_psl:
	.ascii	"** PSL	  : \0"
	.align 	2
Gregs:	.space	60	/* Space to save general registers */
	.align	2
	.globl	_Errmsg
_Errmsg:
	.long	0	/* Pointer to error message */
	.data	1
endmsg: .ascii	"\nEnd Cycle = \0"
emsg:   .ascii	"\nCycles Completed = \0"
ermsg:   .ascii	"\nError Count = \0"
ermsg1:  .ascii	"\nTest Complete \n\0"

unix.superglobalmegacorp.com

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