explora_start.S revision 1.1.2.1 1 1.1.2.1 skrll /* $NetBSD: explora_start.S,v 1.1.2.1 2004/08/03 10:34:16 skrll Exp $ */
2 1.1 hannken
3 1.1 hannken /*-
4 1.1 hannken * Copyright (c) 2003 The NetBSD Foundation, Inc.
5 1.1 hannken * All rights reserved.
6 1.1 hannken *
7 1.1 hannken * This code is derived from software contributed to The NetBSD Foundation
8 1.1 hannken * by Juergen Hannken-Illjes.
9 1.1 hannken *
10 1.1 hannken * Redistribution and use in source and binary forms, with or without
11 1.1 hannken * modification, are permitted provided that the following conditions
12 1.1 hannken * are met:
13 1.1 hannken * 1. Redistributions of source code must retain the above copyright
14 1.1 hannken * notice, this list of conditions and the following disclaimer.
15 1.1 hannken * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 hannken * notice, this list of conditions and the following disclaimer in the
17 1.1 hannken * documentation and/or other materials provided with the distribution.
18 1.1 hannken * 3. All advertising materials mentioning features or use of this software
19 1.1 hannken * must display the following acknowledgement:
20 1.1 hannken * This product includes software developed by the NetBSD
21 1.1 hannken * Foundation, Inc. and its contributors.
22 1.1 hannken * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1 hannken * contributors may be used to endorse or promote products derived
24 1.1 hannken * from this software without specific prior written permission.
25 1.1 hannken *
26 1.1 hannken * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1 hannken * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1 hannken * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1 hannken * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1 hannken * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1 hannken * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1 hannken * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1 hannken * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1 hannken * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1 hannken * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1 hannken * POSSIBILITY OF SUCH DAMAGE.
37 1.1 hannken */
38 1.1 hannken
39 1.1 hannken /*
40 1.1 hannken * Initial state:
41 1.1 hannken *
42 1.1 hannken * iccr = 0x00008001 0x80000000-0x87ffffff 0xf80000000-0xffffffff
43 1.1 hannken * dccr = 0x00008001 0x80000000-0x87ffffff 0xf80000000-0xffffffff
44 1.1 hannken * dcwr = 0x00000000
45 1.1 hannken * msr = 0x00001000 ME=machine check enable
46 1.1 hannken *
47 1.1 hannken */
48 1.1 hannken
49 1.1 hannken #include "assym.h"
50 1.1 hannken
51 1.1.2.1 skrll #define _NOREGNAMES
52 1.1.2.1 skrll
53 1.1 hannken #include <machine/param.h>
54 1.1 hannken #include <machine/psl.h>
55 1.1 hannken #include <machine/trap.h>
56 1.1 hannken #include <machine/asm.h>
57 1.1 hannken
58 1.1 hannken #include <powerpc/spr.h>
59 1.1 hannken #include <powerpc/ibm4xx/dcr403cgx.h>
60 1.1 hannken #include <powerpc/ibm4xx/pmap.h>
61 1.1 hannken
62 1.1 hannken #include "opt_ddb.h"
63 1.1 hannken #include "opt_ppcparam.h"
64 1.1 hannken
65 1.1 hannken GLOBAL(proc0paddr)
66 1.1 hannken .long 0 /* proc0 p_addr */
67 1.1 hannken
68 1.1 hannken GLOBAL(intrnames)
69 1.1 hannken .asciz "irq0", "irq1", "irq2", "irq3"
70 1.1 hannken .asciz "irq4", "irq5", "irq6", "irq7"
71 1.1 hannken .asciz "irq8", "irq9", "irq10", "irq11"
72 1.1 hannken .asciz "irq12", "irq13", "irq14", "irq15"
73 1.1 hannken .asciz "irq16", "irq17", "irq18", "softnet"
74 1.1 hannken .asciz "softclock", "softserial", "clock", "statclock"
75 1.1 hannken .asciz "irq24", "irq25", "irq26", "irq27"
76 1.1 hannken .asciz "irq28", "irq29", "irq30", "irq31"
77 1.1 hannken GLOBAL(eintrnames)
78 1.1 hannken .align 4
79 1.1 hannken GLOBAL(intrcnt)
80 1.1 hannken .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
81 1.1 hannken .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
82 1.1 hannken GLOBAL(eintrcnt)
83 1.1 hannken
84 1.1 hannken /*
85 1.1 hannken * Initially the dram starts at 0x01000000. This is way too high.
86 1.1 hannken * We relocate dram to 0x00000000. We use the video ram at 0xf0000000
87 1.1 hannken * as a temporary staging area.
88 1.1 hannken */
89 1.1 hannken
90 1.1 hannken #define STAGE1_BASE 0xf0000000
91 1.1 hannken
92 1.1 hannken .text
93 1.1 hannken .globl __start
94 1.1 hannken __start:
95 1.1 hannken b 1f
96 1.1 hannken nop
97 1.1 hannken nop
98 1.1 hannken .long 0
99 1.1 hannken .ascii "XncdPPC\0"
100 1.1 hannken .long 0
101 1.1 hannken .long 0
102 1.1 hannken
103 1.1 hannken 1:
104 1.1 hannken /* Disable exceptions, caches, invalidate all TLB's. */
105 1.1 hannken
106 1.1 hannken li 0,0
107 1.1 hannken mtmsr 0
108 1.1 hannken mttcr 0
109 1.1 hannken mtdccr 0
110 1.1 hannken mticcr 0
111 1.1 hannken sync
112 1.1 hannken isync
113 1.1 hannken
114 1.1 hannken /* Clear caches and invalidate tlbs */
115 1.1 hannken li 7,256
116 1.1 hannken mtctr 7
117 1.1 hannken li 6,0
118 1.1 hannken 1:
119 1.1 hannken dccci 0,6
120 1.1 hannken addi 6,6,16
121 1.1 hannken bdnz 1b
122 1.1 hannken
123 1.1 hannken li 7,512
124 1.1 hannken mtctr 7
125 1.1 hannken li 6,0
126 1.1 hannken 1:
127 1.1 hannken iccci 0,6
128 1.1 hannken addi 6,6,16
129 1.1 hannken bdnz 1b
130 1.1 hannken
131 1.1 hannken tlbia
132 1.1 hannken sync
133 1.1 hannken isync
134 1.1 hannken
135 1.1 hannken /* Get current address -- NOT the same as . */
136 1.1 hannken
137 1.1 hannken bl _next
138 1.1 hannken _next:
139 1.1 hannken mflr 3
140 1.1 hannken subi 3,3,_next-__start
141 1.1 hannken lis 4,STAGE1_BASE@h
142 1.1 hannken ori 4,4,STAGE1_BASE@l
143 1.1 hannken li 5,stage1size
144 1.1 hannken
145 1.1 hannken 1:
146 1.1 hannken lbz 1,0(3)
147 1.1 hannken mr 0,5
148 1.1 hannken cmpwi 0,0
149 1.1 hannken stb 1,0(4)
150 1.1 hannken addi 3,3,1
151 1.1 hannken addi 4,4,1
152 1.1 hannken addi 5,5,-1
153 1.1 hannken bgt 1b
154 1.1 hannken
155 1.1 hannken /* Jump into the staging area so we can remap the dram. */
156 1.1 hannken
157 1.1 hannken lis 0,stage1reloc@h
158 1.1 hannken ori 0,0,stage1reloc@l
159 1.1 hannken mtlr 0
160 1.1 hannken blr
161 1.1 hannken
162 1.1 hannken stage1reloc = .-__start+STAGE1_BASE
163 1.1 hannken
164 1.1 hannken /* Remap the dram from 0x01000000 to 0x00000000. */
165 1.1 hannken
166 1.1 hannken #define REMAP(r, tmp1, tmp2) \
167 1.1 hannken mfbr##r tmp1 ; \
168 1.1 hannken lis tmp2,0xff ; \
169 1.1 hannken ori tmp2,tmp2,0xffff ; \
170 1.1 hannken cmplw tmp1,tmp2 ; \
171 1.1 hannken ble 1f ; \
172 1.1 hannken addis tmp1,tmp1,0xf000 ; \
173 1.1 hannken mtbr##r tmp1 ; \
174 1.1 hannken 1:
175 1.1 hannken
176 1.1 hannken REMAP(4, 1, 2)
177 1.1 hannken REMAP(5, 1, 2)
178 1.1 hannken REMAP(6, 1, 2)
179 1.1 hannken REMAP(7, 1, 2)
180 1.1 hannken
181 1.1 hannken #undef REMAP
182 1.1 hannken
183 1.1 hannken /* Initial setup. */
184 1.1 hannken
185 1.1 hannken ba stage2
186 1.1 hannken
187 1.1 hannken stage2:
188 1.1 hannken
189 1.1 hannken #ifdef PPC_4XX_NOCACHE
190 1.1 hannken li 0,0
191 1.1 hannken #else
192 1.1 hannken lis 0,0xfffc
193 1.1 hannken #endif
194 1.1 hannken mtdccr 0
195 1.1 hannken mticcr 0
196 1.1 hannken sync
197 1.1 hannken isync
198 1.1 hannken
199 1.1 hannken /* get start of bss */
200 1.1 hannken lis 7,_C_LABEL(edata)-4@h
201 1.1 hannken ori 7,7,_C_LABEL(edata)-4@l
202 1.1 hannken /* get end of kernel */
203 1.1 hannken lis 4,_C_LABEL(end)@h
204 1.1 hannken ori 4,4,_C_LABEL(end)@l
205 1.1 hannken /* clear bss */
206 1.1 hannken li 3,0
207 1.1 hannken 1:
208 1.1 hannken stwu 3,4(7)
209 1.1 hannken cmpw 7,4
210 1.1 hannken bne+ 1b
211 1.1 hannken
212 1.1 hannken INIT_CPUINFO(4,1,9,0)
213 1.1 hannken
214 1.1 hannken lis 3,__start@h
215 1.1 hannken ori 3,3,__start@l
216 1.1 hannken
217 1.1 hannken /* Run the remaining setup in C. */
218 1.1 hannken bl _C_LABEL(bootstrap)
219 1.1 hannken
220 1.1 hannken bl _C_LABEL(main)
221 1.1 hannken
222 1.1 hannken /* NOTREACHED */
223 1.1 hannken 2: nop
224 1.1 hannken b 2b
225 1.1 hannken
226 1.1 hannken stage1size = .-__start
227 1.1 hannken
228 1.1 hannken #include <powerpc/ibm4xx/4xx_locore.S>
229