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