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