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