locore.S revision 1.11 1 /* $NetBSD: locore.S,v 1.11 2008/11/13 10:53:30 ad 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_multiprocessor.h"
40 #include "opt_ppcparam.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
55 #include "ksyms.h"
56
57 /*
58 * Some instructions gas doesn't understand (yet?)
59 */
60 #define bdneq bdnzf 2,
61
62 /*
63 * cache bit
64 */
65 #define HID0_BTCD (1<<1)
66 #define HID0_BHTE (1<<2)
67 #define HID0_SIED (1<<7)
68 #define HID0_DCI (1<<10)
69 #define HID0_ICFI (1<<11)
70 #define HID0_DCE (1<<14)
71 #define HID0_ICE (1<<15)
72
73 /*
74 * Globals
75 */
76 GLOBAL(startsym)
77 .long 0 /* start symbol table */
78 GLOBAL(endsym)
79 .long 0 /* end symbol table */
80 GLOBAL(proc0paddr)
81 .long 0 /* proc0 p_addr */
82 GLOBAL(oeacpufeat)
83 .long 0 /* cpu features */
84
85 /*
86 * This symbol is here for the benefit of kvm_mkdb, and is supposed to
87 * mark the start of kernel text.
88 */
89 .text
90 .globl _C_LABEL(kernel_text)
91 _C_LABEL(kernel_text):
92
93 /*
94 * Startup entry. Note, this must be the first thing in the text
95 * segment!
96 */
97 .text
98 .globl __start
99 __start:
100 li 0,0
101 mtmsr 0 /* Disable FPU/MMU/exceptions */
102 isync
103
104 /* compute end of kernel memory */
105 #if NKSYMS || defined(DDB) || defined(MODULAR) || defined(KERNFS)
106 lis 7,_C_LABEL(startsym)@ha
107 addi 7,7,_C_LABEL(startsym)@l
108 stw 3,0(7)
109 lis 7,_C_LABEL(endsym)@ha
110 addi 7,7,_C_LABEL(endsym)@l
111 stw 4,0(7)
112 #else
113 lis 4,_C_LABEL(end)@ha
114 addi 4,4,_C_LABEL(end)@l
115 #endif
116
117 INIT_CPUINFO(4,1,9,0)
118
119 lis 3,__start@ha
120 addi 3,3,__start@l
121
122 bl _C_LABEL(initppc)
123
124 /* enable internal i/d-cache */
125 mfpvr 9
126 rlwinm 9,9,16,16,31
127 cmpi 0,9,1
128 beq 3f /* not needed for 601 */
129 mfspr 11,SPR_HID0
130 andi. 0,11,HID0_DCE
131 ori 11,11,HID0_ICE|HID0_DCE
132 ori 8,11,HID0_ICFI
133 bne 1f /* don't invalidate the D-cache */
134 ori 8,8,HID0_DCI /* unless it wasn't enabled */
135 1:
136 sync
137 mtspr SPR_HID0,8 /* enable and invalidate caches */
138 sync
139 mtspr SPR_HID0,11 /* enable caches */
140 sync
141 isync
142 cmpi 0,9,4 /* check for 604 */
143 cmpi 1,9,9 /* or 604e */
144 cmpi 2,9,10 /* or mach5 */
145 cror 2,2,6
146 cror 2,2,10
147 bne 3f
148 ori 11,11,HID0_SIED|HID0_BHTE /* for 604[e], enable */
149 bne 2,2f
150 ori 11,11,HID0_BTCD
151 2:
152 mtspr SPR_HID0,11
153 3:
154 sync
155 isync
156
157 bl _C_LABEL(main)
158
159 loop:
160 b loop /* not reached */
161
162 .globl _C_LABEL(enable_intr)
163 _C_LABEL(enable_intr):
164 mfmsr 3
165 ori 4,3,PSL_EE@l
166 mtmsr 4
167 blr
168
169 .globl _C_LABEL(disable_intr)
170 _C_LABEL(disable_intr):
171 mfmsr 3
172 andi. 4,3,~PSL_EE@l
173 mtmsr 4
174 blr
175
176 /*
177 * Pull in common switch / setfault code.
178 */
179 #include <powerpc/powerpc/locore_subr.S>
180
181 /*
182 * Pull in common trap vector code.
183 */
184 #include <powerpc/powerpc/trap_subr.S>
185
186 /*
187 * Pull in common pio / bus_space code.
188 */
189 #include <powerpc/powerpc/pio_subr.S>
190