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