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