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