ev64260_locore.S revision 1.2 1 /* $NetBSD: ev64260_locore.S,v 1.2 2003/03/16 07:07:19 matt Exp $ */
2 /* $OpenBSD: locore.S,v 1.4 1997/01/26 09:06:38 rahnds Exp $ */
3
4 /*
5 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
6 * Copyright (C) 1995, 1996 TooLs GmbH.
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by TooLs GmbH.
20 * 4. The name of TooLs GmbH may not be used to endorse or promote products
21 * derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
29 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
31 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 #include "opt_ddb.h"
36 #include "fs_kernfs.h"
37 #include "opt_ppcparam.h"
38 #include "opt_ipkdb.h"
39 #include "opt_multiprocessor.h"
40 #include "opt_openpic.h"
41 #include "assym.h"
42
43 #include <sys/syscall.h>
44
45 #include <machine/param.h>
46 #include <machine/vmparam.h>
47 #include <machine/pmap.h>
48 #include <machine/psl.h>
49 #include <machine/trap.h>
50 #include <machine/asm.h>
51
52 #include <powerpc/spr.h>
53 #include <powerpc/oea/bat.h>
54 #include <powerpc/oea/hid.h>
55
56 /*
57 * Some instructions gas doesn't understand (yet?)
58 */
59 #define bdneq bdnzf 2,
60
61 /*
62 * Globals
63 */
64 GLOBAL(startsym)
65 .long 0 /* start symbol table */
66 GLOBAL(endsym)
67 .long 0 /* end symbol table */
68 GLOBAL(proc0paddr)
69 .long 0 /* proc0 p_addr */
70
71 /*
72 * File-scope for locore.S
73 */
74 #ifdef DINK
75 .data
76 dink_return:
77 .long 0 /* fake uarea during idle after exit */
78 dink_stack:
79 .long 0 /* fake uarea during idle after exit */
80 #endif
81
82 /*
83 * This symbol is here for the benefit of kvm_mkdb, and is supposed to
84 * mark the start of kernel text.
85 */
86 .text
87 .globl _C_LABEL(kernel_text)
88 _C_LABEL(kernel_text):
89
90 /*
91 * Startup entry. Note, this must be the first thing in the text
92 * segment!
93 */
94 .text
95 .globl __start
96 __start:
97 #ifdef DINK
98 mflr 0
99 lis 8, dink_stack@ha
100 stw 1, dink_stack@l(8)
101 lis 8, dink_return@ha
102 stw 0, dink_return@l(8)
103 #endif
104
105 #if 0
106 eieio; sync
107 lis 8, 0xf100f104@ha
108 lwz 7, -3836(8)
109 li 0, 1
110 andc 7,7,0
111 stw 7, -3836(8)
112 eieio; sync
113 #endif
114
115 /*
116 * Make sure that .bss is zeroed.
117 */
118 li 0,0
119 lis 8,edata@ha
120 addi 8,8,edata@l
121 lis 9,end@ha
122 addi 9,9,end@l
123 5: cmpw 0,8,9 /* edata & end are >= word aligned */
124 bge 6f
125 stw 0,0(8)
126 addi 8,8,4
127 b 5b
128 6:
129
130 li 0,0
131 mtmsr 0 /* Disable FPU/MMU/exceptions */
132 sync ; isync
133
134 #if 1
135 /* Enable data and instruction caches */
136 mfspr 8,SPR_HID0
137 li 0,HID0_DLOCK
138 ori 8,8,(HID0_ICE | HID0_DCE)@l
139 andc 8,8,0
140 mtspr SPR_HID0,8
141 #endif
142
143 /* compute end of kernel memory */
144 lis 8,_C_LABEL(end)@ha
145 addi 8,8,_C_LABEL(end)@l
146 #if defined(DDB) || defined(KERNFS)
147 lis 7,_C_LABEL(startsym)@ha
148 addi 7,7,_C_LABEL(startsym)@l
149 stw 3,0(7)
150 lis 7,_C_LABEL(endsym)@ha
151 addi 7,7,_C_LABEL(endsym)@l
152 stw 4,0(7)
153 /* mr 8,4 * end of symbol table */
154 #endif
155 mr 4,8 /* end of mem reserved for kernel */
156 INIT_CPUINFO(4,1,9,0)
157
158 lis 3,__start@ha
159 addi 3,3,__start@l
160 li 5,0
161 li 6,0
162
163 bl _C_LABEL(initppc)
164 bl _C_LABEL(main)
165
166 loop: b loop /* XXX not reached */
167
168 #if 0
169 .globl _C_LABEL(extintr_enable)
170 _C_LABEL(extintr_enable):
171 mfmsr 3
172 ori 3,3,PSL_EE@l
173 sync
174 mtmsr 3
175 blr
176
177 .globl _C_LABEL(extintr_restore)
178 _C_LABEL(extintr_restore):
179 mfmsr 4
180 or 3,4,3
181 sync
182 mtmsr 3
183 blr
184
185 .globl _C_LABEL(extintr_disable)
186 _C_LABEL(extintr_disable):
187 mfmsr 3
188 andi. 4,3,~PSL_EE@l
189 sync
190 mtmsr 4
191 andi. 3,3,PSL_EE@l
192 blr
193
194 .globl _C_LABEL(mvpppc_reboot)
195 _C_LABEL(mvpppc_reboot):
196 mfmsr 3
197 ori 3,3,PSL_IP@l
198 sync
199 mtmsr 3
200 b 0xFFF00100
201 #endif
202
203 #ifdef DINK
204 .globl _C_LABEL(return_to_dink)
205 _C_LABEL(return_to_dink):
206 sync
207 lis 4, dink_stack@ha
208 lwz 1, dink_stack@l(4)
209 lis 4, dink_return@ha
210 lwz 5, dink_return@l(4)
211 mtlr 5
212 blr
213 #endif
214
215 /*
216 * Include common switch / setfault code
217 */
218 #include <powerpc/powerpc/locore_subr.S>
219
220 /*
221 * Include common trap / execption code
222 */
223 #include <powerpc/powerpc/trap_subr.S>
224
225 /*
226 * Include PIO routines
227 */
228 #include <powerpc/powerpc/pio_subr.S>
229