ev64260_locore.S revision 1.1 1 /* $NetBSD: ev64260_locore.S,v 1.1 2003/03/05 22:08:26 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/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(proc0paddr)
68 .long 0 /* proc0 p_addr */
69
70 /*
71 * File-scope for locore.S
72 */
73 #ifdef DINK
74 .data
75 dink_return:
76 .long 0 /* fake uarea during idle after exit */
77 dink_stack:
78 .long 0 /* fake uarea during idle after exit */
79 #endif
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 li 0,0
115 mtmsr 0 /* Disable FPU/MMU/exceptions */
116 sync ; isync
117
118 /* Enable data and instruction caches */
119 mfspr 8,SPR_HID0
120 ori 8, 8, (HID0_ICE | HID0_DCE)@l
121 mtspr SPR_HID0,8
122
123 /* compute end of kernel memory */
124 lis 8,_C_LABEL(end)@ha
125 addi 8,8,_C_LABEL(end)@l
126 #if defined(DDB) || defined(KERNFS)
127 lis 7,_C_LABEL(startsym)@ha
128 addi 7,7,_C_LABEL(startsym)@l
129 stw 3,0(7)
130 lis 7,_C_LABEL(endsym)@ha
131 addi 7,7,_C_LABEL(endsym)@l
132 stw 4,0(7)
133 /* mr 8,4 * end of symbol table */
134 #endif
135 mr 4,8 /* end of mem reserved for kernel */
136 INIT_CPUINFO(4,1,9,0)
137
138 lis 3,__start@ha
139 addi 3,3,__start@l
140
141 li 5,0
142 li 6,0
143
144 bl _C_LABEL(initppc)
145 bl _C_LABEL(main)
146
147 loop: b loop /* XXX not reached */
148
149 #if 0
150 .globl _C_LABEL(extintr_enable)
151 _C_LABEL(extintr_enable):
152 mfmsr 3
153 ori 3,3,PSL_EE@l
154 sync
155 mtmsr 3
156 blr
157
158 .globl _C_LABEL(extintr_restore)
159 _C_LABEL(extintr_restore):
160 mfmsr 4
161 or 3,4,3
162 sync
163 mtmsr 3
164 blr
165
166 .globl _C_LABEL(extintr_disable)
167 _C_LABEL(extintr_disable):
168 mfmsr 3
169 andi. 4,3,~PSL_EE@l
170 sync
171 mtmsr 4
172 andi. 3,3,PSL_EE@l
173 blr
174
175 .globl _C_LABEL(mvpppc_reboot)
176 _C_LABEL(mvpppc_reboot):
177 mfmsr 3
178 ori 3,3,PSL_IP@l
179 sync
180 mtmsr 3
181 b 0xFFF00100
182 #endif
183
184 #ifdef DINK
185 .globl _C_LABEL(return_to_dink)
186 _C_LABEL(return_to_dink):
187 sync
188 lis 4, dink_stack@ha
189 lwz 1, dink_stack@l(4)
190 lis 4, dink_return@ha
191 lwz 5, dink_return@l(4)
192 mtlr 5
193 blr
194 #endif
195
196 /*
197 * Include common switch / setfault code
198 */
199 #include <powerpc/powerpc/locore_subr.S>
200
201 /*
202 * Include common trap / execption code
203 */
204 #include <powerpc/powerpc/trap_subr.S>
205