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