Home | History | Annotate | Line # | Download | only in common
srt0.S revision 1.12
      1 /*	$NetBSD: srt0.S,v 1.12 2003/08/07 16:27:43 agc Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1982, 1990, 1993
      5  *	The Regents of the University of California.  All rights reserved.
      6  *
      7  * This code is derived from software contributed to Berkeley by
      8  * the Systems Programming Group of the University of Utah Computer
      9  * Science Department.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions and the following disclaimer.
     16  * 2. Redistributions in binary form must reproduce the above copyright
     17  *    notice, this list of conditions and the following disclaimer in the
     18  *    documentation and/or other materials provided with the distribution.
     19  * 3. Neither the name of the University nor the names of its contributors
     20  *    may be used to endorse or promote products derived from this software
     21  *    without specific prior written permission.
     22  *
     23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33  * SUCH DAMAGE.
     34  *
     35  * from: Utah $Hdr: srt0.c 1.18 92/12/21$
     36  *
     37  *	@(#)srt0.c	8.1 (Berkeley) 6/10/93
     38  */
     39 /*
     40  * Copyright (c) 1988 University of Utah.
     41  *
     42  * This code is derived from software contributed to Berkeley by
     43  * the Systems Programming Group of the University of Utah Computer
     44  * Science Department.
     45  *
     46  * Redistribution and use in source and binary forms, with or without
     47  * modification, are permitted provided that the following conditions
     48  * are met:
     49  * 1. Redistributions of source code must retain the above copyright
     50  *    notice, this list of conditions and the following disclaimer.
     51  * 2. Redistributions in binary form must reproduce the above copyright
     52  *    notice, this list of conditions and the following disclaimer in the
     53  *    documentation and/or other materials provided with the distribution.
     54  * 3. All advertising materials mentioning features or use of this software
     55  *    must display the following acknowledgement:
     56  *	This product includes software developed by the University of
     57  *	California, Berkeley and its contributors.
     58  * 4. Neither the name of the University nor the names of its contributors
     59  *    may be used to endorse or promote products derived from this software
     60  *    without specific prior written permission.
     61  *
     62  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     63  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     64  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     65  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     66  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     67  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     68  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     69  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     70  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     71  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     72  * SUCH DAMAGE.
     73  *
     74  * from: Utah $Hdr: srt0.c 1.18 92/12/21$
     75  *
     76  *	@(#)srt0.c	8.1 (Berkeley) 6/10/93
     77  */
     78 
     79 /*
     80  * Startup code for standalone system
     81  */
     82 
     83 /* For machineid and mmuid constants */
     84 #include <machine/hp300spu.h>
     85 
     86 /* For _C_LABEL() and friends. */
     87 #include <machine/asm.h>
     88 
     89 	STACK =	   0xfffff000		/* below the ROM page */
     90 	BOOTTYPE = 0xfffffdc0
     91 	LOWRAM =   0xfffffdce
     92 	SYSFLAG =  0xfffffed2		/* system flags */
     93 	MSUS =	   0xfffffedc		/* MSUS (?) structure */
     94 	VECTORS =  0xfffffee0		/* beginning of jump vectors */
     95 	NMIRESET = 0xffffff9c		/* reset vector */
     96 	BUSERR =   0xfffffffc
     97 	MAXADDR =  0xfffff000
     98 	NBPG =	   4096
     99 	MMUCMD =   0x005f400c		/* MMU command/status register */
    100 
    101 	.data
    102 GLOBAL(bootdev)
    103 	.long	0
    104 
    105 GLOBAL(howto)
    106 	.long	0
    107 
    108 GLOBAL(lowram)
    109 	.long	0
    110 
    111 GLOBAL(machineid)
    112 	.long	0
    113 
    114 GLOBAL(mmuid)
    115 	.long	0
    116 
    117 	.text
    118 ASENTRY_NOPROFILE(begin)
    119 	movl	#STACK,%sp
    120 	moveq	#47,%d0			/* # of vectors - 1 */
    121 	movl	#VECTORS+2,%a0		/* addr part of first vector */
    122 1:
    123 	movl	#_ASM_LABEL(__trap),%a0@ /* make it direct to __trap */
    124 	addql	#6,%a0			/* move to next vector addr */
    125 	dbf	%d0,1b			/* go til done */
    126 #ifdef ITECONSOLE
    127 	movl	#NMIRESET,%a0		/* NMI keyboard reset addr */
    128 	movl	#nmi,%a0@		/* catch in reset routine */
    129 #else
    130 	/*
    131 	 * Built without ITE console support; leave the ROM's NMI
    132 	 * vector in place, so the system will still reset if a
    133 	 * keyboard NMI is issued.
    134 	 */
    135 #endif
    136 
    137 /*
    138  * Determine our SPU type and look for internal HP-IB
    139  */
    140 	lea	_C_LABEL(machineid),%a0
    141 	movl	#0x808,%d0
    142 	movc	%d0,%cacr		/* clear and disable on-chip cache(s) */
    143 	movl	#0x200,%d0		/* data freeze bit */
    144 	movc	%d0,%cacr		/*   only exists on 68030 */
    145 	movc	%cacr,%d0		/* read it back */
    146 	tstl	%d0			/* zero? */
    147 	jeq	not68030		/* yes, we have 68020/68040 */
    148 
    149 	movl	#0x808,%d0
    150 	movc	%d0,%cacr		/* clear data freeze bit again */
    151 
    152 	/*
    153 	 * 68030 models
    154 	 */
    155 
    156 	movl	#0x80,MMUCMD		/* set magic cookie */
    157 	movl	MMUCMD,%d0		/* read it back */
    158 	btst	#7,%d0			/* cookie still on? */
    159 	jeq	not370			/* no, 360 or 375 */
    160 	movl	#HP_370,%a0@		/* consider a 370 for now */
    161 	movl	#0,MMUCMD		/* clear magic cookie */
    162 	movl	MMUCMD,%d0		/* read it back */
    163 	btst	#7,%d0			/* still on? */
    164 	jeq	ihpibcheck		/* no, a 370 */
    165 	movl	#HP_340,%a0@		/* yes, must be a 340 */
    166 	jra	ihpibcheck
    167 
    168 not370:
    169 	movl	#HP_360,%a0@		/* type is at least a 360 */
    170 	movl	#0,MMUCMD		/* clear magic cookie2 */
    171 	movl	MMUCMD,%d0		/* read it back */
    172 	btst	#16,%d0			/* still on? */
    173 	jeq	ihpibcheck		/* no, a 360 */
    174 	lea	_C_LABEL(mmuid),%a0
    175 	lsrl	#MMUID_SHIFT,%d0	/* save MMU ID */
    176 	andl	#MMUID_MASK,%d0
    177 	movl	%d0,%a0@
    178 	lea	_C_LABEL(machineid),%a0
    179 	cmpb	#MMUID_345,%d0		/* are we a 345? */
    180 	jeq	isa345
    181 	cmpb	#MMUID_375,%d0		/* how about a 375? */
    182 	jeq	isa375
    183 	movl	#HP_400,%a0@		/* must be a 400 */
    184 	jra	ihpibcheck
    185 isa345:
    186 	movl	#HP_345,%a0@
    187 	jra	ihpibcheck
    188 isa375:
    189 	movl	#HP_375,%a0@
    190 	jra	ihpibcheck
    191 
    192 	/*
    193 	 * End of 68030 section
    194 	 */
    195 
    196 not68030:
    197 	bset	#31,%d0			/* data cache enable bit */
    198 	movc	%d0,%cacr		/*   only exists on 68040 */
    199 	movc	%cacr,%d0		/* read it back */
    200 	tstl	%d0			/* zero? */
    201 	beq	is68020			/* yes, we have 68020 */
    202 	moveq	#0,%d0			/* now turn it back off */
    203 	movec	%d0,%cacr		/*   before we access any data */
    204 
    205 	.long	0x4e7b0004		/* movc %d0,%itt0 */
    206 	.long	0x4e7b0005		/* movc %d0,%itt1 */
    207 	.long	0x4e7b0006		/* movc %d0,%dtt0 */
    208 	.long	0x4e7b0007		/* movc %d0,%dtt1 */
    209 	.word	0xf4d8			/* cinva bc */
    210 
    211 	/*
    212 	 * 68040 models
    213 	 */
    214 
    215 	lea	_C_LABEL(mmuid),%a0
    216 	movl	MMUCMD,%d0		/* get MMU ID */
    217 	lsrl	#MMUID_SHIFT,%d0
    218 	andl	#MMUID_MASK,%d0
    219 	movl	%d0,%a0@		/* save it */
    220 	lea	_C_LABEL(machineid),%a0
    221 	cmpb	#MMUID_425_T,%d0	/* are we a 425t? */
    222 	jeq	isa425
    223 	cmpb	#MMUID_425_S,%d0	/* how about 425s? */
    224 	jeq	isa425
    225 	cmpb	#MMUID_425_E,%d0	/* or maybe a 425e? */
    226 	jeq	isa425
    227 	cmpb	#MMUID_433_T,%d0	/* or a 433t? */
    228 	jeq	isa433
    229 	cmpb	#MMUID_433_S,%d0	/* or a 433s? */
    230 	jeq	isa433
    231 	cmpb	#MMUID_385,%d0		/* or a 385? */
    232 	jeq	isa385
    233 	movl	#HP_380,%a0@		/* guess we are a 380 */
    234 	jra	ihpibcheck
    235 isa425:
    236 	movl	#HP_425,%a0@
    237 	jra	ihpibcheck
    238 isa433:
    239 	movl	#HP_433,%a0@
    240 	jra	ihpibcheck
    241 isa385:
    242 	movl	#HP_385,%a0@
    243 	jra	ihpibcheck
    244 
    245 	/*
    246 	 * End 68040 section
    247 	 */
    248 
    249 	/*
    250 	 * 68020 models
    251 	 */
    252 
    253 is68020:
    254 	movl	#HP_330,%a0@		/* consider a 330 for now */
    255 	movl	#1,MMUCMD		/* a 68020, write HP MMU location */
    256 	movl	MMUCMD,%d0		/* read it back */
    257 	btst	#0,%d0			/* zero? */
    258 	jeq	ihpibcheck		/* yes, a 330 */
    259 	movl	#HP_320,%a0@		/* no, consider a 320 for now */
    260 	movl	#0x80,MMUCMD		/* set magic cookie */
    261 	movl	MMUCMD,%d0		/* read it back */
    262 	btst	#7,%d0			/* cookie still on? */
    263 	jeq	ihpibcheck		/* no, just a 320 */
    264 	movl	#HP_350,%a0@		/* yes, a 350 */
    265 
    266 	/*
    267 	 * End 68020 section
    268 	 */
    269 
    270 ihpibcheck:
    271 	movl	#0,MMUCMD		/* make sure MMU is off */
    272 	btst	#5,SYSFLAG		/* do we have an internal HP-IB? */
    273 	jeq	boottype		/* yes, continue */
    274 	clrl	_C_LABEL(internalhpib)	/* no, clear the internal address */
    275 /*
    276  * If this is a reboot, extract howto/bootdev stored by kernel
    277  */
    278 boottype:
    279 	cmpw	#12,BOOTTYPE		/* is this a reboot (REQ_REBOOT)? */
    280 	jne	notreboot		/* no, skip */
    281 	lea	MAXADDR,%a0		/* find last page */
    282 	movl	%a0@+,%d7		/* and extract howto, bootdev */
    283 	movl	%a0@+,%d6		/*   from where doboot() left them */
    284 	jra	boot1
    285 /*
    286  * At this point we do not know which logical device the MSUS select
    287  * code refers to so we cannot construct bootdev.  So we just punt
    288  * and let configure() construct it.
    289  */
    290 notreboot:
    291 	moveq	#0,%d6			/* make sure bootdev is invalid */
    292 	cmpw	#18,BOOTTYPE		/* does the user want to interact? */
    293 	jeq	askme			/* yes, go to it */
    294 	moveq	#0,%d7			/* default to RB_AUTOBOOT */
    295 	jra	boot1
    296 askme:
    297 	moveq	#3,%d7			/* default to RB_SINGLE|RB_ASKNAME */
    298 boot1:
    299 	movl	%d6,_C_LABEL(bootdev)	/* save bootdev and howto */
    300 	movl	%d7,_C_LABEL(howto)	/*   globally so all can access */
    301 	movl	LOWRAM,%d0		/* read lowram value from bootrom */
    302 	/*
    303 	 * Must preserve the scratch area for the BOOT ROM.
    304 	 * Round up to the next 8k boundary.
    305 	 */
    306 	addl	#((2*NBPG)-1),%d0
    307 	andl	#-(2*NBPG),%d0
    308 	movl	%d0,_C_LABEL(lowram)	/* stash that value */
    309 start:
    310 	movl	#_C_LABEL(edata),%a2	/* start of BSS */
    311 	movl	#_C_LABEL(end),%a3	/* end */
    312 1:
    313 	clrb	%a2@+			/* clear BSS */
    314 	cmpl	%a2,%a3			/* done? */
    315 	bne	1b			/* no, keep going */
    316 	jsr	_C_LABEL(configure)	/* configure critical devices */
    317 	jsr	_C_LABEL(main)		/* lets go */
    318 GLOBAL(_rtt)
    319 	movl	#3,_C_LABEL(howto)	/* restarts get RB_SINGLE|RB_ASKNAME */
    320 	jmp	start
    321 
    322 /*
    323  * probe a location and see if it causes a bus error
    324  */
    325 ENTRY_NOPROFILE(badaddr)
    326 	movl	BUSERR,_C_LABEL(_bsave)	/* save ROM bus error handler address */
    327 	movl	%sp,_C_LABEL(_ssave)	/* and current stack pointer */
    328 	movl	#catchbad,BUSERR	/* plug in our handler */
    329 	movl	%sp@(4),%a0		/* address to probe */
    330 	movw	%a0@,%d1		/* do it */
    331 	movl	_C_LABEL(_bsave),BUSERR	/* if we got here, it did not fault */
    332 	clrl	%d0			/* return that this was not a bad */
    333 					/*   addr */
    334 	rts
    335 
    336 catchbad:
    337 	movl	_C_LABEL(_bsave),BUSERR	/* got a bus error, so restore */
    338 					/*   old handler */
    339 	movl	_C_LABEL(_ssave),%sp	/* manually restore stack */
    340 	moveq	#1,%d0			/* indicate that we got a fault */
    341 	rts				/* return to caller of badaddr() */
    342 
    343 	.data
    344 GLOBAL(_bsave)
    345 	.long	0
    346 
    347 GLOBAL(_ssave)
    348 	.long	0
    349 
    350 ASENTRY_NOPROFILE(__trap)
    351 	moveml	#0xFFFF,%sp@-		/* save registers */
    352 	movl	%sp,%sp@-		/* push pointer to frame */
    353 	jsr	_C_LABEL(trap)		/* call C routine to deal with it */
    354 	tstl	%d0
    355 	jeq	Lstop
    356 	addql	#4,%sp
    357 	moveml	%sp@+,#0x7FFF
    358 	addql	#8,%sp
    359 	rte
    360 Lstop:
    361 	stop	#0x2700			/* stop cold */
    362 
    363 #ifdef ITECONSOLE
    364 ASENTRY_NOPROFILE(nmi)
    365 	movw	#18,BOOTTYPE		/* mark as system switch */
    366 	jsr	_C_LABEL(kbdnmi)	/* clear the interrupt, and */
    367 					/*   reset the system */
    368 	stop	#0			/* SCREEEECH! */
    369 #endif
    370 
    371 ENTRY_NOPROFILE(call_req_reboot)
    372 	jmp	0x1A4			/* call ROM reboot function */
    373 	rts				/* XXX: just in case? */
    374 
    375 ENTRY_NOPROFILE(romout)
    376 	movl	%sp@(4),%d0		/* line number */
    377 	movl	%sp@(8),%a0		/* string */
    378 	jsr	0x150			/* do it */
    379 	rts
    380 
    381 /*
    382  * _transfer(entry, howto, opendev, conscode, lowram, esym)
    383  *
    384  *	Transfer control to the kernel.  We also set up registers
    385  *	as older kernels expect.
    386  */
    387 ENTRY_NOPROFILE(_transfer)
    388 	movl	%sp@(8),%d7		/* howto */
    389 	movl	%sp@(12),%d6		/* opendev (compat) */
    390 	movl	%sp@(16),%d5		/* conscode (compat) */
    391 	movl	%sp@(20),%a5		/* lowram */
    392 	movl	%sp@(24),%a4		/* esym (compat) */
    393 
    394 	movl	%sp@(4),%a0		/* load entry point */
    395 	jbsr	%a0@			/* GO! */
    396