/
/	Version 1.1 of 6/18/86
/
	.data
/
/
	.globl	tmpstk
	.globl	nxtppt
	.globl	pptsiz
	.globl	pptnum
	.globl	pptlim
	.globl	typcpu
	.globl	savbot
	.globl	vecbot
	.globl	vecall
	.globl	begmod
	.globl	endmod
	.globl	ready
	.globl	lastk
	.globl	last
	.globl	baseis
	.globl	baseds
	.globl	userpc
	.globl	KSP		/ kernel stack pointer
	.globl	maksav		/ do context save if nonzero
	.globl	kernpc		/ for performance analysis
/
/
intvec:	nucl; 340; nucl; 340; nucl; 340; nucl; 340;
	nucl; 340; nucl; 340; nucl; 340; nucl; 340;
	nucl; 340; nucl; 340; nucl; 340; nucl; 340;
	nucl; 340; nucl; 340; nucl; 340; nucl; 340;
	nucl; 340; nucl; 340; nucl; 340; nucl; 340;
	nucl; 340; nucl; 340; nucl; 340; nucl; 340;
	nucl; 340; nucl; 340; nucl; 340; nucl; 340;
	nucl; 340; nucl; 340; nucl; 340; nucl; 340;
	nucl; 340; nucl; 340; nucl; 340; nucl; 340;
	nucl; 340; nucl; 340; nucl; 340; nucl; 340;
	nucl; 340; nucl; 340; nucl; 340; nucl; 340;
	nucl; 340; nucl; 340; nucl; 340; nucl; 340;
	nucl; 340; nucl; 340; nucl; 340; nucl; 340;
	nucl; 340; nucl; 340; nucl; 340; nucl; 340;
	nucl; 340; nucl; 340; nucl; 340; nucl; 340;
	nucl; 340; nucl; 340; nucl; 340; nucl; 340;
endvec:
/
/
/
/       Nucleus variables ...
/
	.=.+200
tmpstk: 0                       / temporary stack location
/
nxtppt: 0                       / adr ( next ppt to allocate )
pptsiz: 0                       / size of ppt entry
pptnum: 0                       / number of ppt entries
pptlim: 0                       / adr ( top of ppt )
typcpu:	0			/ boolean ... cpu type (true iff 70)
/
savbot: 0                       / bottom of interrupt vector save area
vecbot: 0                       / bottom of interrupt vector area
vecall: 0                       / allocation of vectors
/
begmod: 0                       / beginning of modula stack area
endmod: 0                       / end of modula stack area
/
ready:  0                       / head of ready queue
lastk:  0                       / end of Kernel processes in ready queue
last:   0                       / end of ready queue
/
baseis: 0                       / base address (in blocks) of i-space
baseds: 0                       / base address (in blocks) of d-space
/
userpc:	0			/ user process PC save area
/
KSP:	0			/ user process Kernel stack pointer
/
maksav:	0			/ boolean ... do context save if true
/
/
kernpc:	0			/ for performance analysis, only needed
				/ if TRACE == 1 in nuc.s

/
	<@(#)nuc_front.s	1.1\0>
	.even
/
/
	.text
/
/
/	Memory Dumper - to dump memory:
/	(Depending on which dumper is configured)
/	DEFINE RKD = 1 for RK dump
	RKD = 1
/
/	1. Depress the HALT switch
/	2. Mount a tape (RK disk) on unit 0
/	3. Load address 0
/	4. Push START switch
/	5. Raise HALT switch
/	6. Push START switch
/	RK dump only...
/	7. Wait for "write protect" light to come on
/
/
/	instructions...
reset = 5
/	Hardware addresses
/
	ps	= 17777776		/ process status
	runpar	= 17772340		/ text par
	runpdr	= 17772300		/ text pdr
	devpar	= 17772356		/ device page par
	devpdr	= 17772316		/ device page pdr
	modpar	= 17772374		/ modula stack par
	modpdr	= 17772334		/ modula stack pdr
	mmr0	= 17777572		/ Memory Management Register 0
	mmr3	= 17772516		/ Memory Management Register 3
/
	mtcs1	= 17772440		/ mag tape control and status
	mtwc	= 17772442		/ word count 
	mtba	= 17772444		/ unibus address
	mtfc	= 17772446		/ frame count
	mtcs2	= 17772450		/ control and status 2
	mtds	= 17772452		/ drive status
	mttc	= 17772472		/ tape control
/
/
/	bit patterns
/
/
	rwpdr	= 77406			/ read write PDR
	rdpdr	= 3402			/ read only PDR
	dvpar	= 7600			/ device page PAR
	addr	= 20000			/ data address to write
	wc	= -256.			/ word count to write
	bc	= -512.			/ byte count to write
	dnsty	= 1300			/ tape density
	wrtgo	= 61			/ write forward and go
	wrtmrk	= 27			/ write tape mark
	clear	= 40011			/ clear drive
	revrse	= 33			/ reverse tape
	erase	= 25			/ erase record
	rewind	= 7			/ rewind tape
	blklen	= 10			/ length of tp block in mem blocks
	disps	= 340			/ disable interrupts
	mmron	= 1			/ turn on mm
/
/	instructions
/
/
/
/	parameters
/
	maxadr	= 760			/ end of dump
/
/
/
dump:	mov	$disps,*$ps		/ disable interrupts
/
	clr	*$runpar		/ set to bottom of physical memory
	mov	$rwpdr,*$runpdr		/ set PDR for read write
/
	mov	$dvpar,*$devpar		/ set up device page par
	mov	$rwpdr,*$devpdr		/ set PDR for read write
/
	clr	*$mmr3			/ reset mmr3
	mov	$mmron,*$mmr0		/ turn on memory management
/
	mov	r0,tparea		/ save r0
	mov	$tparea,r0		/ get adr( save area )
	mov	r1,-(r0)		/ save r1
	mov	r2,-(r0)		/ save r2
	mov	r3,-(r0)		/ save r3
	mov	r4,-(r0)		/ save r4
	mov	r5,-(r0)		/ save r5
	mov	sp,-(r0)		/ save sp
/
	mov	*$modpar,-(r0)		/ save Modula stack par
	mov	*$modpdr,-(r0)		/ save Modula stack pdr
/
/
	clr	r0			/ initial par to write out
/
	mov	$mtcs1,r1		/ r1 = mtcs1
	mov	$mtds,r2		/ r2 = mtds
	mov	$mtfc,r3		/ r3 = mtfc
/
.if RKD
/ onto RK0 with address 177404 
/ initial coding by Phil Reinders, LOGICON, 02/06/80
/ modified by John Codd, LOGICON, 10/24/80, for San Diego's crash rk pack
/ modified (and pulled from 11/45 unix) by Tom Perrine, LOGICON, 14 July, 1983


/	reset				/set up for transfer
dmplp:	mov	$177400,r2		/DSR address for RK
	mov	$0,4(r2)		/reset control of rk05's
	inc	4(r2)
1:
	tstb	4(r2)			/control ready?
	bpl	1b			/not yet
	mov	$0,r3			/r3 = number of blocks xfered
	clr	10(r2)			/clear RKBA 1777410 to start from
					/absolute 0 in memory xfer
	mov	$0,12(r2)		/set RKDA to start from drive=0
					/cyl=0,surface=0,sector=0(=>blk=0)
	mov	$10,4(r2)		/seek to beginning sector
	inc	4(r2)			/do the seek
1:
	tstb	4(r2)			/control ready?
	bpl	1b			/not yet
	bit	$100,(r2)		/drive ready?
	beq	1b			/not yet

	mov	$2,4(r2)		/set write command up
1:
	mov	$-256.,6(r2)		/set word count RKWC to 256 words
	inc	4(r2)			/do write command
	inc	r3			/increment r3 to show writting of block
2:
	tstb	4(r2)			/done yet writing block?
	bpl	2b			/not yet
	tst	4(r2)			/error or done?
	bpl	1b			/not yet then write another block
	mov	$0,4(r2)		/reset control of drive from error
	inc	4(r2)			/perform reset
1:
	tstb	4(r2)			/done yet?
	bpl	1b			/not yet
	mov	$0,12(r2)		/reset RKDA to select from drive=0
	mov	$17,4(r2)		/turn write protect on to signal done
	inc	4(r2)			/turn it on now
	reset
	br	.			/loop forever
.endif
/
/
/	Tape dumper
.if RKD-1
/
dmplp:	mov	r0,r4			/ current address
	ash	$11,r4			/ * 512
	mov	r4,*$mtba		/ address
/
	mov	$bc,(r3)		/ skip frame count
	mov	$wc,*$mtwc		/ word count
	mov	$dnsty,*$mttc		/ density
	clr	*$mtcs2			/ clear control and status 2
/
	mov	r0,r4			/ current address
	asl	r4			/ * 2
	bic	$!1400,r4		/ extension bits
	bis	$wrtgo,r4		/ write forward and go
	mov	r4,(r1)			/ start write
/
2:	tstb	(r1)			/ wait until ready
	bge	2b			/ not ready
/
	tst	(r1)			/ error ?
	blt	2f			/ yes
/
	inc	r0			/ increase address
	cmp	$maxadr,r0		/ end of memory?
	bhi	dmplp			/ no - continue
/
	mov	$wrtmrk,(r1)		/ write tape mark
/
3:	tstb	(r2)			/ drive ready?
	bge	3b			/ no
/
	mov	$rewind,(r1)		/ rewind tape
	br	.
/
2:	mov	$clear,(r1)		/ tape clear
	mov	$-1,(r3)		/ set up for erase
	mov	$revrse,(r1)		/ back up
/
2:	tstb	(r2)			/ drive ready?
	bge	2b			/ no
/
	mov	$erase,(r1)		/ erase
2:	tstb	(r2)			/ drive ready?
	bge	2b			/ no
/
	mov	$clear,(r1)		/ tape clear
	br	dmplp			/ continue
.endif
/
/
/
/	save area for registers
/
/
svarea:	.=.+20
tparea:	0
/
/
