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