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