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