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