Home | History | Annotate | Line # | Download | only in common
srt0.S revision 1.1
      1 /*	$NetBSD: srt0.S,v 1.1 1997/02/04 03:52:54 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 	.globl	begin
     50 	.globl	_end
     51 	.globl	_edata
     52 	.globl	_main
     53 	.globl	_configure
     54 	.globl	__rtt
     55 	.globl	_bootdev,_howto,_lowram,_machineid
     56 	.globl	_internalhpib
     57 
     58 	STACK =	   0xfffff000	| below the ROM page
     59 	BOOTTYPE = 0xfffffdc0
     60 	LOWRAM =   0xfffffdce
     61 	SYSFLAG =  0xfffffed2	| system flags
     62 	MSUS =	   0xfffffedc	| MSUS (?) structure
     63 	VECTORS =  0xfffffee0	| beginning of jump vectors
     64 	NMIRESET = 0xffffff9c	| reset vector
     65 	BUSERR =   0xfffffffc
     66 	MAXADDR =  0xfffff000
     67 	NBPG =	   4096
     68 	MMUCMD =   0x005f400c	| MMU command/status register
     69 
     70 	.data
     71 _bootdev:
     72 	.long	0
     73 _howto:
     74 	.long	0
     75 _lowram:
     76 	.long	0
     77 _machineid:
     78 	.long	0
     79 
     80 	.text
     81 begin:
     82 	movl	#STACK,sp
     83 	moveq	#47,d0		| # of vectors - 1
     84 	movl	#VECTORS+2,a0	| addr part of first vector
     85 vecloop:
     86 	movl	#trap,a0@	| make it direct to trap
     87 	addql	#6,a0		| move to next vector addr
     88 	dbf	d0,vecloop	| go til done
     89 	movl	#NMIRESET,a0	| NMI keyboard reset addr
     90 	movl	#nmi,a0@	| catch in reset routine
     91 /*
     92  * Determine our CPU type and look for internal HP-IB
     93  * (really only care about detecting 320 (no DIO-II) right now).
     94  */
     95 	lea	_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 	movl	#0x808,d0
    104 	movc	d0,cacr		| clear data freeze bit again
    105 
    106 	movl	#0x80,MMUCMD	| set magic cookie
    107 	movl	MMUCMD,d0	| read it back
    108 	btst	#7,d0		| cookie still on?
    109 	jeq	not370		| no, 360 or 375
    110 	movl	#4,a0@		| consider a 370 for now
    111 	movl	#0,MMUCMD	| clear magic cookie
    112 	movl	MMUCMD,d0	| read it back
    113 	btst	#7,d0		| still on?
    114 	jeq	ihpibcheck	| no, a 370
    115 	movl	#5,a0@		| yes, must be a 340
    116 	jra	ihpibcheck
    117 not370:
    118 	movl	#3,a0@		| type is at least a 360
    119 	movl	#0,MMUCMD	| clear magic cookie2
    120 	movl	MMUCMD,d0	| read it back
    121 	btst	#16,d0		| still on?
    122 	jeq	ihpibcheck	| no, a 360
    123 	movl	#6,a0@		| yes, must be a 345/375/400
    124 	jra	ihpibcheck
    125 not68030:
    126 	bset	#31,d0		| data cache enable bit
    127 	movc	d0,cacr		|   only exists on 68040
    128 	movc	cacr,d0		| read it back
    129 	tstl	d0		| zero?
    130 	beq	is68020		| yes, we have 68020
    131 	moveq	#0,d0		| now turn it back off
    132 	movec	d0,cacr		|   before we access any data
    133 	.long	0x4e7b0004	| movc d0,itt0
    134 	.long	0x4e7b0005	| movc d0,itt1
    135 	.long	0x4e7b0006	| movc d0,dtt0
    136 	.long	0x4e7b0007	| movc d0,dtt1
    137 	.word	0xf4d8		| cinva bc
    138 	movl	MMUCMD,d0	| get MMU register
    139 	lsrl	#8,d0		| get apparent ID
    140 	cmpb	#6,d0		| id == 6?
    141 	jeq	is33mhz		| yes, we have a 433s
    142 	movl	#7,a0@		| no, we have a 380/425t
    143 	jra	ihpibcheck
    144 is33mhz:
    145 	movl	#8,a0@		| 433s (XXX 425s returns same ID, ugh!)
    146 	jra	ihpibcheck
    147 is68020:
    148 	movl	#1,a0@		| consider a 330 for now
    149 	movl	#1,MMUCMD	| a 68020, write HP MMU location
    150 	movl	MMUCMD,d0	| read it back
    151 	btst	#0,d0		| zero?
    152 	jeq	ihpibcheck	| yes, a 330
    153 	movl	#0,a0@		| no, consider a 320 for now
    154 	movl	#0x80,MMUCMD	| set magic cookie
    155 	movl	MMUCMD,d0	| read it back
    156 	btst	#7,d0		| cookie still on?
    157 	jeq	ihpibcheck	| no, just a 320
    158 	movl	#2,a0@		| yes, a 350
    159 ihpibcheck:
    160 	movl	#0,MMUCMD	| make sure MMU is off
    161 	btst	#5,SYSFLAG	| do we have an internal HP-IB?
    162 	jeq	boottype	| yes, continue
    163 	clrl	_internalhpib	| no, clear the internal address
    164 /*
    165  * If this is a reboot, extract howto/bootdev stored by kernel
    166  */
    167 boottype:
    168 	cmpw	#12,BOOTTYPE	| is this a reboot (REQ_REBOOT)?
    169 	jne	notreboot	| no, skip
    170 	lea	MAXADDR,a0	| find last page
    171 	movl	a0@+,d7		| and extract howto, bootdev
    172 	movl	a0@+,d6		|   from where doboot() left them
    173 	jra	boot1
    174 /*
    175  * At this point we do not know which logical device the MSUS select
    176  * code refers to so we cannot construct bootdev.  So we just punt
    177  * and let configure() construct it.
    178  */
    179 notreboot:
    180 	moveq	#0,d6		| make sure bootdev is invalid
    181 	cmpw	#18,BOOTTYPE	| does the user want to interact?
    182 	jeq	askme		| yes, go to it
    183 	moveq	#0,d7		| default to RB_AUTOBOOT
    184 	jra	boot1
    185 askme:
    186 	moveq	#3,d7		| default to RB_SINGLE|RB_ASKNAME
    187 boot1:
    188 	movl	d6,_bootdev	| save bootdev and howto
    189 	movl	d7,_howto	|   globally so all can access
    190 	movl	LOWRAM,d0	| read lowram value from bootrom
    191 	addl	#NBPG,d0	| must preserve this for bootrom to reboot
    192 	andl	#0xfffff000,d0	| round to next page
    193 	movl	d0,_lowram	| stash that value
    194 start:
    195 	movl	#_edata,a2	| start of BSS
    196 	movl	#_end,a3	| end
    197 clr:
    198 	clrb	a2@+		| clear BSS
    199 	cmpl	a2,a3		| done?
    200 	bne	clr		| no, keep going
    201 	jsr	_configure	| configure critical devices
    202 	jsr	_main		| lets go
    203 __rtt:
    204 	movl	#3,_howto	| restarts get RB_SINGLE|RB_ASKNAME
    205 	jmp	start
    206 
    207 /*
    208  * probe a location and see if it causes a bus error
    209  */
    210 	.globl	_badaddr
    211 _badaddr:
    212 	movl	BUSERR,__bsave	| save ROM bus error handler address
    213 	movl	sp,__ssave	| and current stack pointer
    214 	movl	#catchbad,BUSERR| plug in our handler
    215 	movl	sp@(4),a0	| address to probe
    216 	movw	a0@,d1		| do it
    217 	movl	__bsave,BUSERR	| if we got here, it did not fault
    218 	clrl	d0		| return that this was not a bad addr
    219 	rts
    220 
    221 catchbad:
    222 	movl	__bsave,BUSERR	| got a bus error, so restore old handler
    223 	movl	__ssave,sp	| manually restore stack
    224 	moveq	#1,d0		| indicate that we got a fault
    225 	rts			| return to caller of badaddr()
    226 
    227 __bsave:
    228 	.long	0
    229 __ssave:
    230 	.long	0
    231 
    232 	.globl	_trap
    233 trap:
    234 	moveml	#0xFFFF,sp@-	| save registers
    235 	movl	sp,sp@-		| push pointer to frame
    236 	jsr	_trap		| call C routine to deal with it
    237 	tstl	d0
    238 	jeq	Lstop
    239 	addql	#4,sp
    240 	moveml	sp@+,#0x7FFF
    241 	addql	#8,sp
    242 	rte
    243 Lstop:
    244 	stop	#0x2700		| stop cold
    245 
    246 nmi:
    247 	movw	#18,BOOTTYPE	| mark as system switch
    248 	jsr	_kbdnmi		| clear the interrupt
    249 	jra	begin		| start over
    250 
    251 	.globl _call_req_reboot
    252 _call_req_reboot:
    253 	jmp	0x1A4		| call ROM reboot function
    254 	rts			| XXX: just in case?
    255 
    256 #ifdef ROMPRF
    257 	.globl	_romout
    258 _romout:
    259 	movl	sp@(4),d0	| line number
    260 	movl	sp@(8),a0	| string
    261 	jsr	0x150		| do it
    262 	rts
    263 #endif
    264