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