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