1 /* $NetBSD: bsdstart.S,v 1.2 2005/12/11 12:17:00 christos Exp $ */
4 * Copyright (c) 1995 L. Weppelman
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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.
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.
29 * This function sets up the registers according to the kernel parameter block,
30 * disables the MMU and jumps to the kernel.
32 * bsd_startup(struct kparamb *)
36 #include <machine/asm.h>
43 ENTRY_NOPROFILE(bsd_startup)
47 | the BSD kernel wants values into the following registers:
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.
58 movl %sp@(4),%a3 | a3 points to parameter block
60 lea _bsd_startup,%sp | make sure we have a good stack ***
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
75 andb #0x50,%d6 | Is this an 68040/68060?
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
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?
96 | Turn off 68030 TT registers
97 .word 0xf013,0x0800 | pmove a3@,tt0
98 .word 0xf013,0x0c00 | pmove a3@,tt1
100 1: movq #0,%d6 | would have known contents
101 movc %d6,%cacr | turn off the caches
108 rts | enter kernel at address on stack ***
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
114 nullrp: .long 0x80000202