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