Home | History | Annotate | Line # | Download | only in boot
startit.s revision 1.1
      1  1.1  is /*	$NetBSD: startit.s,v 1.1 1996/11/29 23:36:29 is Exp $	*/
      2  1.1  is 
      3  1.1  is /*
      4  1.1  is  * Copyright (c) 1996 Ignatios Souvatzis
      5  1.1  is  * Copyright (c) 1994 Michael L. Hitch
      6  1.1  is  * All rights reserved.
      7  1.1  is  *
      8  1.1  is  * Redistribution and use in source and binary forms, with or without
      9  1.1  is  * modification, are permitted provided that the following conditions
     10  1.1  is  * are met:
     11  1.1  is  * 1. Redistributions of source code must retain the above copyright
     12  1.1  is  *    notice, this list of conditions and the following disclaimer.
     13  1.1  is  * 2. Redistributions in binary form must reproduce the above copyright
     14  1.1  is  *    notice, this list of conditions and the following disclaimer in the
     15  1.1  is  *    documentation and/or other materials provided with the distribution.
     16  1.1  is  * 3. All advertising materials mentioning features or use of this software
     17  1.1  is  *    must display the following acknowledgement:
     18  1.1  is  *      This product includes software developed by Michael L. Hitch.
     19  1.1  is  * 4. The name of the author may not be used to endorse or promote products
     20  1.1  is  *    derived from this software without specific prior written permission
     21  1.1  is  *
     22  1.1  is  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     23  1.1  is  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24  1.1  is  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25  1.1  is  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     26  1.1  is  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     27  1.1  is  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     28  1.1  is  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     29  1.1  is  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     30  1.1  is  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     31  1.1  is  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32  1.1  is  *
     33  1.1  is  *
     34  1.1  is  * From: $NetBSD: startit.s,v 1.1 1996/11/29 23:36:29 is Exp $
     35  1.1  is  */
     36  1.1  is 
     37  1.1  is 	.set	ABSEXECBASE,4
     38  1.1  is 
     39  1.1  is 	.text
     40  1.1  is 
     41  1.1  is 	.globl	_startit
     42  1.1  is 	.globl	_startit_end
     43  1.1  is 
     44  1.1  is _startit:
     45  1.1  is #if TESTONAMIGA
     46  1.1  is 	movew	#0x999,0xdff180		| gray
     47  1.1  is #endif
     48  1.1  is 	movel	sp,a3
     49  1.1  is 	movel	4:w,a6
     50  1.1  is 	lea	pc@(start_super:w),a5
     51  1.1  is 	jmp	a6@(-0x1e)		| supervisor-call
     52  1.1  is 
     53  1.1  is start_super:
     54  1.1  is #if TESTONAMIGA
     55  1.1  is 	movew	#0x900,0xdff180		| dark red
     56  1.1  is #endif
     57  1.1  is 	movew	#0x2700,sr
     58  1.1  is 
     59  1.1  is 	| the BSD kernel wants values into the following registers:
     60  1.1  is 	| a0:  fastmem-start
     61  1.1  is 	| d0:  fastmem-size
     62  1.1  is 	| d1:  chipmem-size
     63  1.1  is 	| d3:  Amiga specific flags
     64  1.1  is 	| d4:  E clock frequency
     65  1.1  is 	| d5:  AttnFlags (cpuid)
     66  1.1  is 	| d7:  boothowto
     67  1.1  is 	| a4:  esym location
     68  1.1  is 	| a2:  Inhibit sync flags
     69  1.1  is 	| All other registers zeroed for possible future requirements.
     70  1.1  is 
     71  1.1  is 	lea	pc@(_startit:w),sp	| make sure we have a good stack ***
     72  1.1  is 
     73  1.1  is 	movel	a3@(4),a1		| loaded kernel
     74  1.1  is 	movel	a3@(8),d2		| length of loaded kernel
     75  1.1  is |	movel	a3@(12),sp		| entry point in stack pointer
     76  1.1  is 	movel	a3@(12),a6		| entry point		***
     77  1.1  is 	movel	a3@(16),a0		| fastmem-start
     78  1.1  is 	movel	a3@(20),d0		| fastmem-size
     79  1.1  is 	movel	a3@(24),d1		| chipmem-size
     80  1.1  is 	movel	a3@(28),d7		| boothowto
     81  1.1  is 	movel	a3@(32),a4		| esym
     82  1.1  is 	movel	a3@(36),d5		| cpuid
     83  1.1  is 	movel	a3@(40),d4		| E clock frequency
     84  1.1  is 	movel	a3@(44),d3		| Amiga flags
     85  1.1  is 	movel	a3@(48),a2		| Inhibit sync flags
     86  1.1  is 	movel	a3@(52),d6		| Load to fastmem flag
     87  1.1  is 	subl	a5,a5			| target, load to 0
     88  1.1  is 
     89  1.1  is 	cmpb	#0x7D,a3@(36)		| is it DraCo?
     90  1.1  is 	beq	nott			| yes, switch off MMU later
     91  1.1  is 
     92  1.1  is 					| no, it is an Amiga:
     93  1.1  is 
     94  1.1  is #if TESTONAMIGA
     95  1.1  is 	movew	#0xf00,0xdff180		|red
     96  1.1  is #endif
     97  1.1  is |	moveb	#0,0x200003c8
     98  1.1  is |	moveb	#63,0x200003c9
     99  1.1  is |	moveb	#0,0x200003c9
    100  1.1  is |	moveb	#0,0x200003c9
    101  1.1  is 
    102  1.1  is 	movew	#(1<<9),0xdff096	| disable DMA on Amigas.
    103  1.1  is 
    104  1.1  is | ------ mmu off start -----
    105  1.1  is 
    106  1.1  is 	btst	#3,d5			| AFB_68040,SysBase->AttnFlags
    107  1.1  is 	beq	not040
    108  1.1  is 
    109  1.1  is | Turn off 68040/060 MMU
    110  1.1  is 
    111  1.1  is 	subl	a3,a3
    112  1.1  is 	.word 0x4e7b,0xb003		| movec a3,tc
    113  1.1  is 	.word 0x4e7b,0xb806		| movec a3,urp
    114  1.1  is 	.word 0x4e7b,0xb807		| movec a3,srp
    115  1.1  is 	.word 0x4e7b,0xb004		| movec a3,itt0
    116  1.1  is 	.word 0x4e7b,0xb005		| movec a3,itt1
    117  1.1  is 	.word 0x4e7b,0xb006		| movec a3,dtt0
    118  1.1  is 	.word 0x4e7b,0xb007		| movec a3,dtt1
    119  1.1  is 	bra	nott
    120  1.1  is 
    121  1.1  is not040:
    122  1.1  is 	lea	pc@(zero:w),a3
    123  1.1  is 	pmove	a3@,tc			| Turn off MMU
    124  1.1  is 	lea	pc@(nullrp:w),a3
    125  1.1  is 	pmove	a3@,crp			| Turn off MMU some more
    126  1.1  is 	pmove	a3@,srp			| Really, really, turn off MMU
    127  1.1  is 
    128  1.1  is | Turn off 68030 TT registers
    129  1.1  is 
    130  1.1  is 	btst	#2,d5			| AFB_68030,SysBase->AttnFlags
    131  1.1  is 	beq	nott			| Skip TT registers if not 68030
    132  1.1  is 	lea	pc@(zero:w),a3
    133  1.1  is 	.word 0xf013,0x0800		| pmove a3@,tt0 (gas only knows about 68851 ops..)
    134  1.1  is 	.word 0xf013,0x0c00		| pmove a3@,tt1 (gas only knows about 68851 ops..)
    135  1.1  is 
    136  1.1  is nott:
    137  1.1  is | ---- mmu off end ----
    138  1.1  is #if TESTONAMIGA
    139  1.1  is 	movew	#0xf60,0xdff180		| orange
    140  1.1  is #endif
    141  1.1  is |	moveb	#0,0x200003c8
    142  1.1  is |	moveb	#63,0x200003c9
    143  1.1  is |	moveb	#24,0x200003c9
    144  1.1  is |	moveb	#0,0x200003c9
    145  1.1  is 
    146  1.1  is | ---- copy kernel start ----
    147  1.1  is 
    148  1.1  is 	tstl	d6			| Can we load to fastmem?
    149  1.1  is 	beq	L0			| No, leave destination at 0
    150  1.1  is 	movl	a0,a5			| Move to start of fastmem chunk
    151  1.1  is 	addl	a0,a6			| relocate kernel entry point
    152  1.1  is L0:
    153  1.1  is 	movl	a1@+,a5@+
    154  1.1  is 	subl	#4,d2
    155  1.1  is 	bcc	L0
    156  1.1  is 
    157  1.1  is 	lea	pc@(ckend:w),a1
    158  1.1  is 	movl	a5,sp@-
    159  1.1  is 	pea	pc@(_startit_end:w)
    160  1.1  is L1:
    161  1.1  is 	movl	a1@+,a5@+
    162  1.1  is 	cmpl	sp@,a1
    163  1.1  is 	bcs	L1
    164  1.1  is 	addql	#4,sp
    165  1.1  is 
    166  1.1  is 	btst	#3,d5
    167  1.1  is 	jeq	L2
    168  1.1  is 	.word	0xf4f8
    169  1.1  is L2:	movql	#0,d2			| switch off cache to ensure we use
    170  1.1  is 	movec	d2,cacr			| valid kernel data
    171  1.1  is 
    172  1.1  is #if TESTONAMIGA
    173  1.1  is 	movew	#0xFF0,0xdff180		| yellow
    174  1.1  is #endif
    175  1.1  is |	moveb	#0,0x200003c8
    176  1.1  is |	moveb	#63,0x200003c9
    177  1.1  is |	moveb	#0,0x200003c9
    178  1.1  is |	moveb	#0,0x200003c9
    179  1.1  is 
    180  1.1  is 	rts
    181  1.1  is 
    182  1.1  is | ---- copy kernel end ----
    183  1.1  is 
    184  1.1  is ckend:
    185  1.1  is #if TESTONAMIGA
    186  1.1  is 	movew	#0x0ff,0xdff180		| petrol
    187  1.1  is #endif
    188  1.1  is |	moveb	#0,0x200003c8
    189  1.1  is |	moveb	#0,0x200003c9
    190  1.1  is |	moveb	#63,0x200003c9
    191  1.1  is |	moveb	#63,0x200003c9
    192  1.1  is 
    193  1.1  is 	movl	d5,d2
    194  1.1  is 	roll	#8,d2
    195  1.1  is 	cmpb	#0x7D,d2
    196  1.1  is 	jne	noDraCo
    197  1.1  is 
    198  1.1  is | DraCo: switch off MMU now:
    199  1.1  is 
    200  1.1  is 	subl	a3,a3
    201  1.1  is 	.word 0x4e7b,0xb003		| movec a3,tc
    202  1.1  is 	.word 0x4e7b,0xb806		| movec a3,urp
    203  1.1  is 	.word 0x4e7b,0xb807		| movec a3,srp
    204  1.1  is 	.word 0x4e7b,0xb004		| movec a3,itt0
    205  1.1  is 	.word 0x4e7b,0xb005		| movec a3,itt1
    206  1.1  is 	.word 0x4e7b,0xb006		| movec a3,dtt0
    207  1.1  is 	.word 0x4e7b,0xb007		| movec a3,dtt1
    208  1.1  is 
    209  1.1  is noDraCo:
    210  1.1  is 	moveq	#0,d2			| zero out unused registers
    211  1.1  is 	moveq	#0,d6			| (might make future compatibility
    212  1.1  is 	movel	d6,a1			|  would have known contents)
    213  1.1  is 	movel	d6,a3
    214  1.1  is 	movel	d6,a5
    215  1.1  is 	movel	a6,sp			| entry point into stack pointer
    216  1.1  is 	movel	d6,a6
    217  1.1  is 
    218  1.1  is #if TESTONAMIGA
    219  1.1  is 	movew	#0x0F0,0xdff180		| green
    220  1.1  is #endif
    221  1.1  is |	moveb	#0,0x200003c8
    222  1.1  is |	moveb	#0,0x200003c9
    223  1.1  is |	moveb	#63,0x200003c9
    224  1.1  is |	moveb	#0,0x200003c9
    225  1.1  is 
    226  1.1  is 	jmp	sp@			| jump to kernel entry point
    227  1.1  is 
    228  1.1  is 
    229  1.1  is | A do-nothing MMU root pointer (includes the following long as well)
    230  1.1  is 
    231  1.1  is nullrp:	.long	0x7fff0001
    232  1.1  is zero:	.long	0
    233  1.1  is 
    234  1.1  is _startit_end:
    235