ev64260_locore.S revision 1.4 1 /* $NetBSD: ev64260_locore.S,v 1.4 2003/03/24 17:07:17 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 GLOBAL(intrnames)
72 GLOBAL(eintrnames)
73 GLOBAL(intrcnt)
74 GLOBAL(eintrcnt)
75 .long 0 /* vmstat needs these. XXX */
76
77 /*
78 * File-scope for locore.S
79 */
80 #ifdef DINK
81 .data
82 dink_return:
83 .long 0 /* fake uarea during idle after exit */
84 dink_stack:
85 .long 0 /* fake uarea during idle after exit */
86 #endif
87
88
89 /*
90 * This symbol is here for the benefit of kvm_mkdb, and is supposed to
91 * mark the start of kernel text.
92 */
93 .text
94 .globl _C_LABEL(kernel_text)
95 _C_LABEL(kernel_text):
96
97 /*
98 * Startup entry. Note, this must be the first thing in the text
99 * segment!
100 */
101 .text
102 .globl __start
103 __start:
104 #ifdef DINK
105 mflr 0
106 lis 8, dink_stack@ha
107 stw 1, dink_stack@l(8)
108 lis 8, dink_return@ha
109 stw 0, dink_return@l(8)
110 #endif
111
112 #if 0
113 eieio; sync
114 lis 8, 0xf100f104@ha
115 lwz 7, -3836(8)
116 li 0, 1
117 andc 7,7,0
118 stw 7, -3836(8)
119 eieio; sync
120 #endif
121
122 /*
123 * Make sure that .bss is zeroed.
124 */
125 li 0,0
126 lis 8,edata@ha
127 addi 8,8,edata@l
128 lis 9,end@ha
129 addi 9,9,end@l
130 5: cmpw 0,8,9 /* edata & end are >= word aligned */
131 bge 6f
132 stw 0,0(8)
133 addi 8,8,4
134 b 5b
135 6:
136
137 li 0,0
138 mtmsr 0 /* Disable FPU/MMU/exceptions */
139 sync ; isync
140
141 #if 1
142 mfpvr 0
143 srwi 0,0,16
144 cmplwi 0,MPC7410
145 bne 16f
146
147 #if 0
148 /* flush and disable L2 */
149 mfspr 8,SPR_L2CR
150 lis 0,(L2CR_L2E|L2CR_L2WT)@h /* disable the L2 mode */
151 andc 8,8,0
152 ori 8,8,L2CR_L2HWF /* enable hardware flush */
153 sync
154 mtspr SPR_L2CR,8 /* do it */
155 sync /* wait for it to finish */
156
157 /* Disable data lock mode */
158 mfspr 8,SPR_HID0
159 li 0,HID0_DLOCK
160 andc 8,8,0
161 mtspr SPR_HID0,8
162 sync
163 #endif
164 #if 0
165 /*
166 * Flush the L1 cache
167 */
168 mfspr 8,SPR_MSSCR0
169 oris 8,8,MSSCR0_DL1HWF@h
170 sync
171 mtspr SPR_MSSCR0,8
172 sync
173 #endif
174 #if 1
175 /* disable data and instruction caches */
176 mfspr 8,SPR_HID0
177 li 0,HID0_DLOCK@l
178 andc 8,8,0
179 sync
180 mtspr SPR_HID0,8
181 sync
182 isync
183 #endif
184 7:
185 #if 0
186 /* disable data and instruction caches */
187 mfspr 8,SPR_HID0
188 li 0,(HID0_ICE|HID0_DCE)@l
189 andc 8,8,0
190 sync
191 mtspr SPR_HID0,8
192 sync
193 isync
194 #endif
195 7:
196 #if 0
197 /* Enable and flush data and instruction caches */
198 ori 8,8,(HID0_ICFI|HID0_ICE|HID0_DCFI|HID0_DCE)
199 # ori 8,8,(HID0_ICFI|HID0_ICE)
200 mtspr SPR_HID0,8
201 isync
202 8: sync
203 mfspr 8,SPR_HID0
204 andi. 0,8,(HID0_ICFI|HID0_DCFI)
205 bne 8b
206 #endif
207
208 #if 0
209 mfspr 8,SPR_L2CR
210 oris 8,8,L2CR_L2E@h
211 sync
212 mtspr SPR_L2CR,8
213 sync
214 #endif
215 16:
216 #endif
217
218 /* compute end of kernel memory */
219 lis 8,_C_LABEL(end)@ha
220 addi 8,8,_C_LABEL(end)@l
221 #if defined(DDB) || defined(KERNFS)
222 lis 7,_C_LABEL(startsym)@ha
223 addi 7,7,_C_LABEL(startsym)@l
224 stw 3,0(7)
225 lis 7,_C_LABEL(endsym)@ha
226 addi 7,7,_C_LABEL(endsym)@l
227 stw 4,0(7)
228 /* mr 8,4 * end of symbol table */
229 #endif
230 mr 4,8 /* end of mem reserved for kernel */
231 INIT_CPUINFO(4,1,9,0)
232
233 lis 3,__start@ha
234 addi 3,3,__start@l
235 li 5,0
236 li 6,0
237
238 bl _C_LABEL(initppc)
239 bl _C_LABEL(main)
240
241 loop: b loop /* XXX not reached */
242
243 #if 0
244 .globl _C_LABEL(extintr_enable)
245 _C_LABEL(extintr_enable):
246 mfmsr 3
247 ori 3,3,PSL_EE@l
248 sync
249 mtmsr 3
250 blr
251
252 .globl _C_LABEL(extintr_restore)
253 _C_LABEL(extintr_restore):
254 mfmsr 4
255 or 3,4,3
256 sync
257 mtmsr 3
258 blr
259
260 .globl _C_LABEL(extintr_disable)
261 _C_LABEL(extintr_disable):
262 mfmsr 3
263 andi. 4,3,~PSL_EE@l
264 sync
265 mtmsr 4
266 andi. 3,3,PSL_EE@l
267 blr
268
269 .globl _C_LABEL(mvpppc_reboot)
270 _C_LABEL(mvpppc_reboot):
271 mfmsr 3
272 ori 3,3,PSL_IP@l
273 sync
274 mtmsr 3
275 b 0xFFF00100
276 #endif
277
278 #ifdef DINK
279 .globl _C_LABEL(return_to_dink)
280 _C_LABEL(return_to_dink):
281 sync
282 lis 4, dink_stack@ha
283 lwz 1, dink_stack@l(4)
284 lis 4, dink_return@ha
285 lwz 5, dink_return@l(4)
286 mtlr 5
287 blr
288 #endif
289
290 /*
291 * Include common switch / setfault code
292 */
293 #include <powerpc/powerpc/locore_subr.S>
294
295 /*
296 * Include common trap / execption code
297 */
298 #include <powerpc/powerpc/trap_subr.S>
299
300 /*
301 * Include PIO routines
302 */
303 #include <powerpc/powerpc/pio_subr.S>
304