xref: /netbsd-src/sys/arch/atari/stand/tostools/libtos/bsdstart.S (revision 4988388746341ac3fc72e21abd79958515e8ad78)
1*49883887Ssnj/*	$NetBSD: bsdstart.S,v 1.3 2009/10/20 19:10:11 snj Exp $	*/
281c0d141She
381c0d141She/*
481c0d141She * Copyright (c) 1995 L. Weppelman
581c0d141She * All rights reserved.
681c0d141She *
781c0d141She * Redistribution and use in source and binary forms, with or without
881c0d141She * modification, are permitted provided that the following conditions
981c0d141She * are met:
1081c0d141She * 1. Redistributions of source code must retain the above copyright
1181c0d141She *    notice, this list of conditions and the following disclaimer.
1281c0d141She * 2. Redistributions in binary form must reproduce the above copyright
1381c0d141She *    notice, this list of conditions and the following disclaimer in the
1481c0d141She *    documentation and/or other materials provided with the distribution.
1581c0d141She *
1681c0d141She * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1781c0d141She * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1881c0d141She * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1981c0d141She * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2081c0d141She * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2181c0d141She * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2281c0d141She * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2381c0d141She * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2481c0d141She * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2581c0d141She * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2681c0d141She */
2781c0d141She
2881c0d141She/*
2981c0d141She * This function sets up the registers according to the kernel parameter block,
3081c0d141She * disables the MMU and jumps to the kernel.
3181c0d141She *
3281c0d141She * bsd_startup(struct kparamb *)
3381c0d141She */
3481c0d141She
3581c0d141She#ifndef TOSTOOLS
3681c0d141She#include <machine/asm.h>
3781c0d141She#endif
3881c0d141She
3981c0d141She#ifdef TOSTOOLS
4081c0d141She	.globl _bsd_startup
4181c0d141She_bsd_startup:
4281c0d141She#else
4381c0d141SheENTRY_NOPROFILE(bsd_startup)
4481c0d141She#endif
4581c0d141She	movw	#0x2700,%sr
4681c0d141She
4781c0d141She	| the BSD kernel wants values into the following registers:
4881c0d141She	| d0:  ttmem-size
4981c0d141She	| d1:  stmem-size
5081c0d141She	| d2:  cputype
5181c0d141She	| d3:  boothowto
5281c0d141She	| d4:  length of loaded kernel
5381c0d141She	| d5:  start of fastram
5481c0d141She	| a0:  start of loaded kernel
5581c0d141She	| a1:  end of symbols (esym)
5681c0d141She	| All other registers zeroed for possible future requirements.
5781c0d141She
5881c0d141She	movl	%sp@(4),%a3		| a3 points to parameter block
5981c0d141She#ifdef	TOSTOOLS
6081c0d141She	lea	_bsd_startup,%sp	| make sure we have a good stack ***
6181c0d141She#endif
6281c0d141She	movl	%a3@,%a0		| loaded kernel
6381c0d141She	movl	%a3@(8),%d0		| kernel entry point
6481c0d141She	addl	%a0,%d0			| added makes our absolute entry point
6581c0d141She	movl	%d0,%sp@-		| push entry point		***
6681c0d141She	movl	%a3@(12),%d1		| stmem-size
6781c0d141She	movl	%a3@(16),%d0		| ttmem-size
6881c0d141She	movl	%a3@(20),%d2		| bootflags
6981c0d141She	movl	%a3@(24),%d3		| boothowto
7081c0d141She	movl	%a3@(4),%d4		| length of loaded kernel
7181c0d141She	movl	%a3@(28),%d5		| start of fastram
7281c0d141She	movl	%a3@(32),%a1		| end of symbols
7381c0d141She	subl	%a5,%a5			| target, load to 0
7481c0d141She	movl	%d2,%d6
7581c0d141She	andb	#0x50,%d6		| Is this an 68040/68060?
7681c0d141She	beqs	0f
7781c0d141She
7881c0d141She	| Turn off 68040 type MMU
7981c0d141She	.word 0x4e7b,0xd003		| movec a5,tc
8081c0d141She	.word 0x4e7b,0xd806		| movec a5,urp
8181c0d141She	.word 0x4e7b,0xd807		| movec a5,srp
8281c0d141She	.word 0x4e7b,0xd004		| movec a5,itt0
8381c0d141She	.word 0x4e7b,0xd005		| movec a5,itt1
8481c0d141She	.word 0x4e7b,0xd006		| movec a5,dtt0
8581c0d141She	.word 0x4e7b,0xd007		| movec a5,dtt1
8681c0d141She	.word	0xf4f8			|  cpusha bc - push and inval caches
8781c0d141She	bras	1f
8881c0d141She
8981c0d141She0:	lea	%pc@(zero),%a3
9081c0d141She	pmove	%a3@,%tc		| Turn off MMU
9181c0d141She	pmove	%a3@(-4),%crp		| crp = nullrp
9281c0d141She	pmove	%a3@(-4),%srp		| srp = nullrp
9381c0d141She	btst	#3,%d2			| Is this an 68030?
9481c0d141She	beqs	1f
9581c0d141She
9681c0d141She	| Turn off 68030 TT registers
9781c0d141She	.word	0xf013,0x0800		| pmove	a3@,tt0
9881c0d141She	.word	0xf013,0x0c00		| pmove	a3@,tt1
9981c0d141She
10081c0d141She1:	movq	#0,%d6			|  would have known contents
10181c0d141She	movc	%d6,%cacr		|  turn off the caches
10281c0d141She	movl	%d6,%d7
10381c0d141She	movl	%d6,%a2
10481c0d141She	movl	%d6,%a3
10581c0d141She	movl	%d6,%a4
10681c0d141She	movl	%d6,%a5
10781c0d141She	movl	%d6,%a6
10881c0d141She	rts				| enter kernel at address on stack ***
10981c0d141She
11081c0d141She| A do-nothing MMU root pointer (includes the following long as well)
11181c0d141She| Note that the above code makes assumptions about the order of the following
11281c0d141She| items.
11381c0d141She
11481c0d141Shenullrp:	.long	0x80000202
11581c0d141Shezero:	.long	0
116