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