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