xref: /csrg-svn/sys/hp300/stand/srt0.c (revision 49157)
141488Smckusick /*
241488Smckusick  * Copyright (c) 1988 University of Utah.
341488Smckusick  * Copyright (c) 1982, 1990 The Regents of the University of California.
441488Smckusick  * All rights reserved.
541488Smckusick  *
641488Smckusick  * This code is derived from software contributed to Berkeley by
741488Smckusick  * the Systems Programming Group of the University of Utah Computer
841488Smckusick  * Science Department.
941488Smckusick  *
1041488Smckusick  * %sccs.include.redist.c%
1141488Smckusick  *
1241488Smckusick  * from: Utah $Hdr: srt0.c 1.8 88/12/03$
1341488Smckusick  *
14*49157Sbostic  *	@(#)srt0.c	7.3 (Berkeley) 05/05/91
1541488Smckusick  */
1641488Smckusick 
1741488Smckusick /*
1841488Smckusick  * Startup code for standalone system
1941488Smckusick  */
2041488Smckusick 
2141488Smckusick 	.globl	begin
2241488Smckusick 	.globl	_end
2341488Smckusick 	.globl	_edata
2441488Smckusick 	.globl	_main
2541488Smckusick 	.globl	_configure
26*49157Sbostic 	.globl	_bootdev
27*49157Sbostic 	.globl	_firstopen
2841488Smckusick 	.globl	__rtt
2942378Smckusick 	.globl	_lowram,_howto,_devtype,_internalhpib
3041488Smckusick 
3141488Smckusick 	STACK =    0xfffff000	| below the ROM page
3241488Smckusick 	BOOTTYPE = 0xfffffdc0
3341488Smckusick 	LOWRAM =   0xfffffdce
3442378Smckusick 	SYSFLAG =  0xfffffed2	| system flags
3541488Smckusick 	MSUS =	   0xfffffedc	| MSUS (?) structure
3641488Smckusick 	VECTORS =  0xfffffee0	| beginning of jump vectors
3741488Smckusick 	NMIRESET = 0xffffff9c	| reset vector
3841488Smckusick 	BUSERR =   0xfffffffc
3941488Smckusick 	MAXADDR =  0xfffff000
4041488Smckusick 	NBPG =     4096
4141488Smckusick 
4241488Smckusick 	.data
43*49157Sbostic _bootdev:
4441488Smckusick 	.long	0
45*49157Sbostic _devtype:
46*49157Sbostic 	.long	0
4741488Smckusick _howto:
4841488Smckusick 	.long	0
49*49157Sbostic _lowram:
5041488Smckusick 	.long	0
5141488Smckusick 
5241488Smckusick 	.text
5341488Smckusick begin:
5441488Smckusick 	movl	#STACK,sp
5541488Smckusick 	moveq	#47,d0		| # of vectors - 1
5641488Smckusick 	movl	#VECTORS+2,a0	| addr part of first vector
5741488Smckusick vecloop:
5841488Smckusick 	movl	#trap,a0@	| make it direct to trap
5941488Smckusick 	addql	#6,a0		| move to next vector addr
6041488Smckusick 	dbf	d0,vecloop	| go til done
6141488Smckusick 	movl	#NMIRESET,a0	| NMI keyboard reset addr
6241488Smckusick 	movl	#nmi,a0@	| catch in reset routine
6342378Smckusick 	btst	#5,SYSFLAG	| do we have an internal HP-IB?
6442378Smckusick 	jeq	boottype	| yes, continue
6542378Smckusick 	clrl	_internalhpib	| no, clear the internal address
6642378Smckusick boottype:
6741488Smckusick 	cmpw	#12,BOOTTYPE	| is this a reboot (REQ_REBOOT)?
6841488Smckusick 	jne	notreboot	| no, skip
6941488Smckusick 	movl	#MAXADDR,a0	| find last page
7041488Smckusick 	movl	a0@+,d7		| and extract howto, devtype
7141488Smckusick 	movl	a0@+,d6		|   from where doboot() left them
7241488Smckusick 	jra	boot1
7341488Smckusick /*
7441488Smckusick  * At this point we do not know which logical hpib the given select
7541488Smckusick  * code refers to.  So we just put the select code in the adaptor field
7641488Smckusick  * where hpibinit() can replace it with the logical hpib number.
7741488Smckusick  * Note that this may clobber the B_DEVMAGIC field but that isn't set
7841488Smckusick  * til later anyway.
7941488Smckusick  */
8041488Smckusick notreboot:
8141488Smckusick 	cmpw	#18,BOOTTYPE	| does the user want to interact?
8241488Smckusick 	jeq	askme		| yes, go to it
8341488Smckusick 	movl	MSUS,d1		| no, get rom info
8441488Smckusick 	movw	d1,d6		| MSUS comes with SC in upper, unit in lower
8541488Smckusick 	swap	d6		| put in place
8641488Smckusick 	movw	#2,d6		| assume 'a' partition of rd disk
8741488Smckusick 	moveq	#0,d7		| default to RB_AUTOBOOT
8841488Smckusick 	jra	boot1
8941488Smckusick askme:
9041488Smckusick 	moveq	#7,d6		| default to HP-IB at sc7
9141488Smckusick 	lslw	#8,d6		| position as adaptor number
9241488Smckusick 	swap	d6		| put in place (note implied unit 0)
9341488Smckusick 	movw	#2,d6		| assume 'a' partition of rd disk
9441488Smckusick 	moveq	#3,d7		| default to RB_SINGLE|RB_ASKNAME
9541488Smckusick boot1:
9641488Smckusick 	movl	d6,_devtype	| save devtype and howto
9741488Smckusick 	movl	d7,_howto	|   globally so all can access
9841488Smckusick 	movl	LOWRAM,d0	| read lowram value from bootrom
9941488Smckusick 	addl	#NBPG,d0	| must preserve this for bootrom to reboot
10041488Smckusick 	andl	#0xfffff000,d0	| round to next page
10141488Smckusick 	movl	d0,_lowram	| stash that value
10241488Smckusick start:
10341488Smckusick 	movl	#_edata,a2	| start of BSS
10441488Smckusick 	movl	#_end,a3	| end
10541488Smckusick clr:
10641488Smckusick 	clrb	a2@+		| clear BSS
10741488Smckusick 	cmpl	a2,a3		| done?
10841488Smckusick 	bne	clr		| no, keep going
10941488Smckusick 	jsr	_configure	| configure critical devices
110*49157Sbostic 	movl	#1,_firstopen	| mark this as the first open
11141488Smckusick 	jsr	_main		| lets go
11241488Smckusick __rtt:
11341488Smckusick 	movl	#3,_howto	| restarts get RB_SINGLE|RB_ASKNAME
11441488Smckusick 	jmp	start
11541488Smckusick 
11641488Smckusick /*
11741488Smckusick  * probe a location and see if it causes a bus error
11841488Smckusick  */
11941488Smckusick 	.globl	_badaddr
12041488Smckusick _badaddr:
12141488Smckusick 	movl	BUSERR,__bsave	| save ROM bus error handler address
12241488Smckusick 	movl	sp,__ssave	| and current stack pointer
12341488Smckusick 	movl	#catchbad,BUSERR| plug in our handler
12441488Smckusick 	movl	sp@(4),a0	| address to probe
12541488Smckusick 	movw	a0@,d1		| do it
12641488Smckusick 	movl	__bsave,BUSERR	| if we got here, it didn't fault
12741488Smckusick 	clrl	d0		| return that this was not a bad addr
12841488Smckusick 	rts
12941488Smckusick 
13041488Smckusick catchbad:
13141488Smckusick 	movl	__bsave,BUSERR	| got a bus error, so restore old handler
13241488Smckusick 	movl	__ssave,sp	| manually restore stack
13341488Smckusick 	moveq	#1,d0		| indicate that we got a fault
13441488Smckusick 	rts			| return to caller of badaddr()
13541488Smckusick 
13641488Smckusick __bsave:
13741488Smckusick 	.long	0
13841488Smckusick __ssave:
13941488Smckusick 	.long	0
14041488Smckusick 
14141488Smckusick 	.globl	_trap
14241488Smckusick trap:
14341488Smckusick 	moveml	#0xFFFF,sp@-	| save registers
14441488Smckusick 	movl	sp,sp@-		| push pointer to frame
14541488Smckusick 	jsr	_trap		| call C routine to deal with it
14641488Smckusick 	stop	#0x2700		| stop cold
14741488Smckusick 
14841488Smckusick nmi:
14941488Smckusick 	movw	#18,BOOTTYPE	| mark as system switch
15041488Smckusick 	jsr	_kbdnmi		| clear the interrupt
15141488Smckusick 	jra	begin		| start over
15241488Smckusick 
15341488Smckusick #ifdef ROMPRF
15441488Smckusick 	.globl	_romout
15541488Smckusick _romout:
15641488Smckusick 	movl	sp@(4),d0	| line number
15741488Smckusick 	movl	sp@(8),a0	| string
15841488Smckusick 	jsr	0x150		| do it
15941488Smckusick 	rts
16041488Smckusick #endif
161