locore.S revision 1.12 1 /* $NetBSD: locore.S,v 1.12 2009/02/13 22:41:03 apb 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_ipkdb.h"
38 #include "opt_lockdebug.h"
39 #include "opt_modular.h"
40 #include "opt_multiprocessor.h"
41 #include "opt_ppcparam.h"
42 #include "assym.h"
43
44 #include <sys/syscall.h>
45
46 #include <machine/param.h>
47 #include <machine/vmparam.h>
48 #include <machine/pmap.h>
49 #include <machine/psl.h>
50 #include <machine/trap.h>
51 #define _NOREGNAMES
52 #include <machine/asm.h>
53
54 #include <powerpc/spr.h>
55
56 #include "ksyms.h"
57
58 /*
59 * Some instructions gas doesn't understand (yet?)
60 */
61 #define bdneq bdnzf 2,
62
63 /*
64 * cache bit
65 */
66 #define HID0_BTCD (1<<1)
67 #define HID0_BHTE (1<<2)
68 #define HID0_SIED (1<<7)
69 #define HID0_DCI (1<<10)
70 #define HID0_ICFI (1<<11)
71 #define HID0_DCE (1<<14)
72 #define HID0_ICE (1<<15)
73
74 /*
75 * Globals
76 */
77 GLOBAL(startsym)
78 .long 0 /* start symbol table */
79 GLOBAL(endsym)
80 .long 0 /* end symbol table */
81 GLOBAL(proc0paddr)
82 .long 0 /* proc0 p_addr */
83 GLOBAL(oeacpufeat)
84 .long 0 /* cpu features */
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 li 0,0
102 mtmsr 0 /* Disable FPU/MMU/exceptions */
103 isync
104
105 /* compute end of kernel memory */
106 #if NKSYMS || defined(DDB) || defined(MODULAR) || defined(KERNFS)
107 lis 7,_C_LABEL(startsym)@ha
108 addi 7,7,_C_LABEL(startsym)@l
109 stw 3,0(7)
110 lis 7,_C_LABEL(endsym)@ha
111 addi 7,7,_C_LABEL(endsym)@l
112 stw 4,0(7)
113 #else
114 lis 4,_C_LABEL(end)@ha
115 addi 4,4,_C_LABEL(end)@l
116 #endif
117
118 INIT_CPUINFO(4,1,9,0)
119
120 lis 3,__start@ha
121 addi 3,3,__start@l
122
123 bl _C_LABEL(initppc)
124
125 /* enable internal i/d-cache */
126 mfpvr 9
127 rlwinm 9,9,16,16,31
128 cmpi 0,9,1
129 beq 3f /* not needed for 601 */
130 mfspr 11,SPR_HID0
131 andi. 0,11,HID0_DCE
132 ori 11,11,HID0_ICE|HID0_DCE
133 ori 8,11,HID0_ICFI
134 bne 1f /* don't invalidate the D-cache */
135 ori 8,8,HID0_DCI /* unless it wasn't enabled */
136 1:
137 sync
138 mtspr SPR_HID0,8 /* enable and invalidate caches */
139 sync
140 mtspr SPR_HID0,11 /* enable caches */
141 sync
142 isync
143 cmpi 0,9,4 /* check for 604 */
144 cmpi 1,9,9 /* or 604e */
145 cmpi 2,9,10 /* or mach5 */
146 cror 2,2,6
147 cror 2,2,10
148 bne 3f
149 ori 11,11,HID0_SIED|HID0_BHTE /* for 604[e], enable */
150 bne 2,2f
151 ori 11,11,HID0_BTCD
152 2:
153 mtspr SPR_HID0,11
154 3:
155 sync
156 isync
157
158 bl _C_LABEL(main)
159
160 loop:
161 b loop /* not reached */
162
163 .globl _C_LABEL(enable_intr)
164 _C_LABEL(enable_intr):
165 mfmsr 3
166 ori 4,3,PSL_EE@l
167 mtmsr 4
168 blr
169
170 .globl _C_LABEL(disable_intr)
171 _C_LABEL(disable_intr):
172 mfmsr 3
173 andi. 4,3,~PSL_EE@l
174 mtmsr 4
175 blr
176
177 /*
178 * Pull in common switch / setfault code.
179 */
180 #include <powerpc/powerpc/locore_subr.S>
181
182 /*
183 * Pull in common trap vector code.
184 */
185 #include <powerpc/powerpc/trap_subr.S>
186
187 /*
188 * Pull in common pio / bus_space code.
189 */
190 #include <powerpc/powerpc/pio_subr.S>
191