Home | History | Annotate | Line # | Download | only in libtos
bsdstart.S revision 1.1.4.4
      1  1.1.4.4  skrll /*	$NetBSD: bsdstart.S,v 1.1.4.4 2004/09/21 13:14:11 skrll Exp $	*/
      2  1.1.4.2  skrll 
      3  1.1.4.2  skrll /*
      4  1.1.4.2  skrll  * Copyright (c) 1995 L. Weppelman
      5  1.1.4.2  skrll  * All rights reserved.
      6  1.1.4.2  skrll  *
      7  1.1.4.2  skrll  * Redistribution and use in source and binary forms, with or without
      8  1.1.4.2  skrll  * modification, are permitted provided that the following conditions
      9  1.1.4.2  skrll  * are met:
     10  1.1.4.2  skrll  * 1. Redistributions of source code must retain the above copyright
     11  1.1.4.2  skrll  *    notice, this list of conditions and the following disclaimer.
     12  1.1.4.2  skrll  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1.4.2  skrll  *    notice, this list of conditions and the following disclaimer in the
     14  1.1.4.2  skrll  *    documentation and/or other materials provided with the distribution.
     15  1.1.4.2  skrll  * 3. All advertising materials mentioning features or use of this software
     16  1.1.4.2  skrll  *    must display the following acknowledgement:
     17  1.1.4.2  skrll  *      This product includes software developed by Leo Weppelman.
     18  1.1.4.2  skrll  * 4. The name of the author may not be used to endorse or promote products
     19  1.1.4.2  skrll  *    derived from this software without specific prior written permission
     20  1.1.4.2  skrll  *
     21  1.1.4.2  skrll  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22  1.1.4.2  skrll  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23  1.1.4.2  skrll  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24  1.1.4.2  skrll  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25  1.1.4.2  skrll  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26  1.1.4.2  skrll  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27  1.1.4.2  skrll  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28  1.1.4.2  skrll  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29  1.1.4.2  skrll  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30  1.1.4.2  skrll  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  1.1.4.2  skrll  */
     32  1.1.4.2  skrll 
     33  1.1.4.2  skrll /*
     34  1.1.4.2  skrll  * This function sets up the registers according to the kernel parameter block,
     35  1.1.4.2  skrll  * disables the MMU and jumps to the kernel.
     36  1.1.4.2  skrll  *
     37  1.1.4.2  skrll  * bsd_startup(struct kparamb *)
     38  1.1.4.2  skrll  */
     39  1.1.4.2  skrll 
     40  1.1.4.2  skrll #ifndef TOSTOOLS
     41  1.1.4.2  skrll #include <machine/asm.h>
     42  1.1.4.2  skrll #endif
     43  1.1.4.2  skrll 
     44  1.1.4.2  skrll #ifdef TOSTOOLS
     45  1.1.4.2  skrll 	.globl _bsd_startup
     46  1.1.4.2  skrll _bsd_startup:
     47  1.1.4.2  skrll #else
     48  1.1.4.2  skrll ENTRY_NOPROFILE(bsd_startup)
     49  1.1.4.2  skrll #endif
     50  1.1.4.2  skrll 	movw	#0x2700,%sr
     51  1.1.4.2  skrll 
     52  1.1.4.2  skrll 	| the BSD kernel wants values into the following registers:
     53  1.1.4.2  skrll 	| d0:  ttmem-size
     54  1.1.4.2  skrll 	| d1:  stmem-size
     55  1.1.4.2  skrll 	| d2:  cputype
     56  1.1.4.2  skrll 	| d3:  boothowto
     57  1.1.4.2  skrll 	| d4:  length of loaded kernel
     58  1.1.4.2  skrll 	| d5:  start of fastram
     59  1.1.4.2  skrll 	| a0:  start of loaded kernel
     60  1.1.4.2  skrll 	| a1:  end of symbols (esym)
     61  1.1.4.2  skrll 	| All other registers zeroed for possible future requirements.
     62  1.1.4.2  skrll 
     63  1.1.4.2  skrll 	movl	%sp@(4),%a3		| a3 points to parameter block
     64  1.1.4.2  skrll #ifdef	TOSTOOLS
     65  1.1.4.2  skrll 	lea	_bsd_startup,%sp	| make sure we have a good stack ***
     66  1.1.4.2  skrll #endif
     67  1.1.4.2  skrll 	movl	%a3@,%a0		| loaded kernel
     68  1.1.4.2  skrll 	movl	%a3@(8),%d0		| kernel entry point
     69  1.1.4.2  skrll 	addl	%a0,%d0			| added makes our absolute entry point
     70  1.1.4.2  skrll 	movl	%d0,%sp@-		| push entry point		***
     71  1.1.4.2  skrll 	movl	%a3@(12),%d1		| stmem-size
     72  1.1.4.2  skrll 	movl	%a3@(16),%d0		| ttmem-size
     73  1.1.4.2  skrll 	movl	%a3@(20),%d2		| bootflags
     74  1.1.4.2  skrll 	movl	%a3@(24),%d3		| boothowto
     75  1.1.4.2  skrll 	movl	%a3@(4),%d4		| length of loaded kernel
     76  1.1.4.2  skrll 	movl	%a3@(28),%d5		| start of fastram
     77  1.1.4.2  skrll 	movl	%a3@(32),%a1		| end of symbols
     78  1.1.4.2  skrll 	subl	%a5,%a5			| target, load to 0
     79  1.1.4.2  skrll 	movl	%d2,%d6
     80  1.1.4.2  skrll 	andb	#0x50,%d6		| Is this an 68040/68060?
     81  1.1.4.2  skrll 	beqs	0f
     82  1.1.4.2  skrll 
     83  1.1.4.2  skrll 	| Turn off 68040 type MMU
     84  1.1.4.2  skrll 	.word 0x4e7b,0xd003		| movec a5,tc
     85  1.1.4.2  skrll 	.word 0x4e7b,0xd806		| movec a5,urp
     86  1.1.4.2  skrll 	.word 0x4e7b,0xd807		| movec a5,srp
     87  1.1.4.2  skrll 	.word 0x4e7b,0xd004		| movec a5,itt0
     88  1.1.4.2  skrll 	.word 0x4e7b,0xd005		| movec a5,itt1
     89  1.1.4.2  skrll 	.word 0x4e7b,0xd006		| movec a5,dtt0
     90  1.1.4.2  skrll 	.word 0x4e7b,0xd007		| movec a5,dtt1
     91  1.1.4.2  skrll 	.word	0xf4f8			|  cpusha bc - push and inval caches
     92  1.1.4.2  skrll 	bras	1f
     93  1.1.4.2  skrll 
     94  1.1.4.2  skrll 0:	lea	%pc@(zero),%a3
     95  1.1.4.2  skrll 	pmove	%a3@,%tc		| Turn off MMU
     96  1.1.4.2  skrll 	pmove	%a3@(-4),%crp		| crp = nullrp
     97  1.1.4.2  skrll 	pmove	%a3@(-4),%srp		| srp = nullrp
     98  1.1.4.2  skrll 	btst	#3,%d2			| Is this an 68030?
     99  1.1.4.2  skrll 	beqs	1f
    100  1.1.4.2  skrll 
    101  1.1.4.2  skrll 	| Turn off 68030 TT registers
    102  1.1.4.2  skrll 	.word	0xf013,0x0800		| pmove	a3@,tt0
    103  1.1.4.2  skrll 	.word	0xf013,0x0c00		| pmove	a3@,tt1
    104  1.1.4.2  skrll 
    105  1.1.4.2  skrll 1:	movq	#0,%d6			|  would have known contents
    106  1.1.4.2  skrll 	movc	%d6,%cacr		|  turn off the caches
    107  1.1.4.2  skrll 	movl	%d6,%d7
    108  1.1.4.2  skrll 	movl	%d6,%a2
    109  1.1.4.2  skrll 	movl	%d6,%a3
    110  1.1.4.2  skrll 	movl	%d6,%a4
    111  1.1.4.2  skrll 	movl	%d6,%a5
    112  1.1.4.2  skrll 	movl	%d6,%a6
    113  1.1.4.2  skrll 	rts				| enter kernel at address on stack ***
    114  1.1.4.2  skrll 
    115  1.1.4.2  skrll | A do-nothing MMU root pointer (includes the following long as well)
    116  1.1.4.2  skrll | Note that the above code makes assumptions about the order of the following
    117  1.1.4.2  skrll | items.
    118  1.1.4.2  skrll 
    119  1.1.4.2  skrll nullrp:	.long	0x80000202
    120  1.1.4.2  skrll zero:	.long	0
    121