Home | History | Annotate | Line # | Download | only in common
srt0.S revision 1.14
      1 /*	$NetBSD: srt0.S,v 1.14 2006/07/19 19:29:02 tsutsui 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 	/*
    150 	 * 68030 models
    151 	 */
    152 
    153 	movl	#0x808,%d0
    154 	movc	%d0,%cacr		/* clear data freeze bit again */
    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 
    203 	/*
    204 	 * 68040 models
    205 	 */
    206 
    207 	moveq	#0,%d0			/* now turn it back off */
    208 	movec	%d0,%cacr		/*   before we access any data */
    209 
    210 	.long	0x4e7b0004		/* movc %d0,%itt0 */
    211 	.long	0x4e7b0005		/* movc %d0,%itt1 */
    212 	.long	0x4e7b0006		/* movc %d0,%dtt0 */
    213 	.long	0x4e7b0007		/* movc %d0,%dtt1 */
    214 	.word	0xf4d8			/* cinva bc */
    215 
    216 	lea	_C_LABEL(mmuid),%a0
    217 	movl	MMUCMD,%d0		/* get MMU ID */
    218 	lsrl	#MMUID_SHIFT,%d0
    219 	andl	#MMUID_MASK,%d0
    220 	movl	%d0,%a0@		/* save it */
    221 	lea	_C_LABEL(machineid),%a0
    222 	cmpb	#MMUID_425_T,%d0	/* are we a 425t? */
    223 	jeq	isa425
    224 	cmpb	#MMUID_425_S,%d0	/* how about 425s? */
    225 	jeq	isa425
    226 	cmpb	#MMUID_425_E,%d0	/* or maybe a 425e? */
    227 	jeq	isa425
    228 	cmpb	#MMUID_433_T,%d0	/* or a 433t? */
    229 	jeq	isa433
    230 	cmpb	#MMUID_433_S,%d0	/* or a 433s? */
    231 	jeq	isa433
    232 	cmpb	#MMUID_385,%d0		/* or a 385? */
    233 	jeq	isa385
    234 	movl	#HP_380,%a0@		/* guess we are a 380 */
    235 	jra	ihpibcheck
    236 isa425:
    237 	movl	#HP_425,%a0@
    238 	jra	ihpibcheck
    239 isa433:
    240 	movl	#HP_433,%a0@
    241 	jra	ihpibcheck
    242 isa385:
    243 	movl	#HP_385,%a0@
    244 	jra	ihpibcheck
    245 
    246 	/*
    247 	 * End 68040 section
    248 	 */
    249 
    250 	/*
    251 	 * 68020 models
    252 	 */
    253 
    254 is68020:
    255 	movl	#HP_330,%a0@		/* consider a 330 for now */
    256 	movl	#1,MMUCMD		/* a 68020, write HP MMU location */
    257 	movl	MMUCMD,%d0		/* read it back */
    258 	btst	#0,%d0			/* zero? */
    259 	jeq	ihpibcheck		/* yes, a 330 */
    260 	movl	#HP_320,%a0@		/* no, consider a 320 for now */
    261 	movl	#0x80,MMUCMD		/* set magic cookie */
    262 	movl	MMUCMD,%d0		/* read it back */
    263 	btst	#7,%d0			/* cookie still on? */
    264 	jeq	ihpibcheck		/* no, just a 320 */
    265 	movl	#HP_350,%a0@		/* yes, a 350 */
    266 
    267 	/*
    268 	 * End 68020 section
    269 	 */
    270 
    271 ihpibcheck:
    272 	movl	#0,MMUCMD		/* make sure MMU is off */
    273 	btst	#5,SYSFLAG		/* do we have an internal HP-IB? */
    274 	jeq	boottype		/* yes, continue */
    275 	clrl	_C_LABEL(internalhpib)	/* no, clear the internal address */
    276 /*
    277  * If this is a reboot, extract howto/bootdev stored by kernel
    278  */
    279 boottype:
    280 	cmpw	#12,BOOTTYPE		/* is this a reboot (REQ_REBOOT)? */
    281 	jne	notreboot		/* no, skip */
    282 	lea	MAXADDR,%a0		/* find last page */
    283 	movl	%a0@+,%d7		/* and extract howto, bootdev */
    284 	movl	%a0@+,%d6		/*   from where doboot() left them */
    285 	jra	boot1
    286 /*
    287  * At this point we do not know which logical device the MSUS select
    288  * code refers to so we cannot construct bootdev.  So we just punt
    289  * and let configure() construct it.
    290  */
    291 notreboot:
    292 	moveq	#0,%d6			/* make sure bootdev is invalid */
    293 	cmpw	#18,BOOTTYPE		/* does the user want to interact? */
    294 	jeq	askme			/* yes, go to it */
    295 	moveq	#0,%d7			/* default to RB_AUTOBOOT */
    296 	jra	boot1
    297 askme:
    298 	moveq	#3,%d7			/* default to RB_SINGLE|RB_ASKNAME */
    299 boot1:
    300 	movl	%d6,_C_LABEL(bootdev)	/* save bootdev and howto */
    301 	movl	%d7,_C_LABEL(howto)	/*   globally so all can access */
    302 	movl	LOWRAM,%d0		/* read lowram value from bootrom */
    303 	/*
    304 	 * Must preserve the scratch area for the BOOT ROM.
    305 	 * Round up to the next 8k boundary.
    306 	 */
    307 	addl	#((2*NBPG)-1),%d0
    308 	andl	#-(2*NBPG),%d0
    309 	movl	%d0,_C_LABEL(lowram)	/* stash that value */
    310 start:
    311 	movl	#_C_LABEL(edata),%a2	/* start of BSS */
    312 	movl	#_C_LABEL(end),%a3	/* end */
    313 1:
    314 	clrb	%a2@+			/* clear BSS */
    315 	cmpl	%a2,%a3			/* done? */
    316 	bne	1b			/* no, keep going */
    317 	jsr	_C_LABEL(configure)	/* configure critical devices */
    318 	jsr	_C_LABEL(main)		/* lets go */
    319 GLOBAL(_rtt)
    320 	movl	#3,_C_LABEL(howto)	/* restarts get RB_SINGLE|RB_ASKNAME */
    321 	jmp	start
    322 
    323 /*
    324  * probe a location and see if it causes a bus error
    325  */
    326 ENTRY_NOPROFILE(badaddr)
    327 	movl	BUSERR,_C_LABEL(_bsave)	/* save ROM bus error handler address */
    328 	movl	%sp,_C_LABEL(_ssave)	/* and current stack pointer */
    329 	movl	#catchbad,BUSERR	/* plug in our handler */
    330 	movl	%sp@(4),%a0		/* address to probe */
    331 	movw	%a0@,%d1		/* do it */
    332 	movl	_C_LABEL(_bsave),BUSERR	/* if we got here, it did not fault */
    333 	clrl	%d0			/* return that this was not a bad */
    334 					/*   addr */
    335 	rts
    336 
    337 catchbad:
    338 	movl	_C_LABEL(_bsave),BUSERR	/* got a bus error, so restore */
    339 					/*   old handler */
    340 	movl	_C_LABEL(_ssave),%sp	/* manually restore stack */
    341 	moveq	#1,%d0			/* indicate that we got a fault */
    342 	rts				/* return to caller of badaddr() */
    343 
    344 	.data
    345 GLOBAL(_bsave)
    346 	.long	0
    347 
    348 GLOBAL(_ssave)
    349 	.long	0
    350 
    351 ASENTRY_NOPROFILE(__trap)
    352 	moveml	#0xFFFF,%sp@-		/* save registers */
    353 	movl	%sp,%sp@-		/* push pointer to frame */
    354 	jsr	_C_LABEL(trap)		/* call C routine to deal with it */
    355 	tstl	%d0
    356 	jeq	Lstop
    357 	addql	#4,%sp
    358 	moveml	%sp@+,#0x7FFF
    359 	addql	#8,%sp
    360 	rte
    361 Lstop:
    362 	stop	#0x2700			/* stop cold */
    363 
    364 #ifdef ITECONSOLE
    365 ASENTRY_NOPROFILE(nmi)
    366 	movw	#18,BOOTTYPE		/* mark as system switch */
    367 	jsr	_C_LABEL(kbdnmi)	/* clear the interrupt, and */
    368 					/*   reset the system */
    369 	stop	#0			/* SCREEEECH! */
    370 #endif
    371 
    372 ENTRY_NOPROFILE(call_req_reboot)
    373 	jmp	0x1A4			/* call ROM reboot function */
    374 	rts				/* XXX: just in case? */
    375 
    376 ENTRY_NOPROFILE(romout)
    377 	movl	%sp@(4),%d0		/* line number */
    378 	movl	%sp@(8),%a0		/* string */
    379 	jsr	0x150			/* do it */
    380 	rts
    381 
    382 /*
    383  * _transfer(entry, howto, opendev, conscode, lowram, esym)
    384  *
    385  *	Transfer control to the kernel.  We also set up registers
    386  *	as older kernels expect.
    387  */
    388 ENTRY_NOPROFILE(_transfer)
    389 	movl	%sp@(8),%d7		/* howto */
    390 	movl	%sp@(12),%d6		/* opendev (compat) */
    391 	movl	%sp@(16),%d5		/* conscode (compat) */
    392 	movl	%sp@(20),%a5		/* lowram */
    393 	movl	%sp@(24),%a4		/* esym (compat) */
    394 
    395 	movl	%sp@(4),%a0		/* load entry point */
    396 	jbsr	%a0@			/* GO! */
    397