explora_start.S revision 1.1 1 1.1 hannken /* $NetBSD: explora_start.S,v 1.1 2003/03/11 10:57:56 hannken 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 hannken #include <machine/param.h>
52 1.1 hannken #include <machine/psl.h>
53 1.1 hannken #include <machine/trap.h>
54 1.1 hannken #include <machine/asm.h>
55 1.1 hannken
56 1.1 hannken #include <powerpc/spr.h>
57 1.1 hannken #include <powerpc/ibm4xx/dcr403cgx.h>
58 1.1 hannken #include <powerpc/ibm4xx/pmap.h>
59 1.1 hannken
60 1.1 hannken #include "opt_ddb.h"
61 1.1 hannken #include "opt_ppcparam.h"
62 1.1 hannken
63 1.1 hannken GLOBAL(proc0paddr)
64 1.1 hannken .long 0 /* proc0 p_addr */
65 1.1 hannken
66 1.1 hannken GLOBAL(intrnames)
67 1.1 hannken .asciz "irq0", "irq1", "irq2", "irq3"
68 1.1 hannken .asciz "irq4", "irq5", "irq6", "irq7"
69 1.1 hannken .asciz "irq8", "irq9", "irq10", "irq11"
70 1.1 hannken .asciz "irq12", "irq13", "irq14", "irq15"
71 1.1 hannken .asciz "irq16", "irq17", "irq18", "softnet"
72 1.1 hannken .asciz "softclock", "softserial", "clock", "statclock"
73 1.1 hannken .asciz "irq24", "irq25", "irq26", "irq27"
74 1.1 hannken .asciz "irq28", "irq29", "irq30", "irq31"
75 1.1 hannken GLOBAL(eintrnames)
76 1.1 hannken .align 4
77 1.1 hannken GLOBAL(intrcnt)
78 1.1 hannken .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
79 1.1 hannken .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
80 1.1 hannken GLOBAL(eintrcnt)
81 1.1 hannken
82 1.1 hannken /*
83 1.1 hannken * Initially the dram starts at 0x01000000. This is way too high.
84 1.1 hannken * We relocate dram to 0x00000000. We use the video ram at 0xf0000000
85 1.1 hannken * as a temporary staging area.
86 1.1 hannken */
87 1.1 hannken
88 1.1 hannken #define STAGE1_BASE 0xf0000000
89 1.1 hannken
90 1.1 hannken .text
91 1.1 hannken .globl __start
92 1.1 hannken __start:
93 1.1 hannken b 1f
94 1.1 hannken nop
95 1.1 hannken nop
96 1.1 hannken .long 0
97 1.1 hannken .ascii "XncdPPC\0"
98 1.1 hannken .long 0
99 1.1 hannken .long 0
100 1.1 hannken
101 1.1 hannken 1:
102 1.1 hannken /* Disable exceptions, caches, invalidate all TLB's. */
103 1.1 hannken
104 1.1 hannken li 0,0
105 1.1 hannken mtmsr 0
106 1.1 hannken mttcr 0
107 1.1 hannken mtdccr 0
108 1.1 hannken mticcr 0
109 1.1 hannken sync
110 1.1 hannken isync
111 1.1 hannken
112 1.1 hannken /* Clear caches and invalidate tlbs */
113 1.1 hannken li 7,256
114 1.1 hannken mtctr 7
115 1.1 hannken li 6,0
116 1.1 hannken 1:
117 1.1 hannken dccci 0,6
118 1.1 hannken addi 6,6,16
119 1.1 hannken bdnz 1b
120 1.1 hannken
121 1.1 hannken li 7,512
122 1.1 hannken mtctr 7
123 1.1 hannken li 6,0
124 1.1 hannken 1:
125 1.1 hannken iccci 0,6
126 1.1 hannken addi 6,6,16
127 1.1 hannken bdnz 1b
128 1.1 hannken
129 1.1 hannken tlbia
130 1.1 hannken sync
131 1.1 hannken isync
132 1.1 hannken
133 1.1 hannken /* Get current address -- NOT the same as . */
134 1.1 hannken
135 1.1 hannken bl _next
136 1.1 hannken _next:
137 1.1 hannken mflr 3
138 1.1 hannken subi 3,3,_next-__start
139 1.1 hannken lis 4,STAGE1_BASE@h
140 1.1 hannken ori 4,4,STAGE1_BASE@l
141 1.1 hannken li 5,stage1size
142 1.1 hannken
143 1.1 hannken 1:
144 1.1 hannken lbz 1,0(3)
145 1.1 hannken mr 0,5
146 1.1 hannken cmpwi 0,0
147 1.1 hannken stb 1,0(4)
148 1.1 hannken addi 3,3,1
149 1.1 hannken addi 4,4,1
150 1.1 hannken addi 5,5,-1
151 1.1 hannken bgt 1b
152 1.1 hannken
153 1.1 hannken /* Jump into the staging area so we can remap the dram. */
154 1.1 hannken
155 1.1 hannken lis 0,stage1reloc@h
156 1.1 hannken ori 0,0,stage1reloc@l
157 1.1 hannken mtlr 0
158 1.1 hannken blr
159 1.1 hannken
160 1.1 hannken stage1reloc = .-__start+STAGE1_BASE
161 1.1 hannken
162 1.1 hannken /* Remap the dram from 0x01000000 to 0x00000000. */
163 1.1 hannken
164 1.1 hannken #define REMAP(r, tmp1, tmp2) \
165 1.1 hannken mfbr##r tmp1 ; \
166 1.1 hannken lis tmp2,0xff ; \
167 1.1 hannken ori tmp2,tmp2,0xffff ; \
168 1.1 hannken cmplw tmp1,tmp2 ; \
169 1.1 hannken ble 1f ; \
170 1.1 hannken addis tmp1,tmp1,0xf000 ; \
171 1.1 hannken mtbr##r tmp1 ; \
172 1.1 hannken 1:
173 1.1 hannken
174 1.1 hannken REMAP(4, 1, 2)
175 1.1 hannken REMAP(5, 1, 2)
176 1.1 hannken REMAP(6, 1, 2)
177 1.1 hannken REMAP(7, 1, 2)
178 1.1 hannken
179 1.1 hannken #undef REMAP
180 1.1 hannken
181 1.1 hannken /* Initial setup. */
182 1.1 hannken
183 1.1 hannken ba stage2
184 1.1 hannken
185 1.1 hannken stage2:
186 1.1 hannken
187 1.1 hannken #ifdef PPC_4XX_NOCACHE
188 1.1 hannken li 0,0
189 1.1 hannken #else
190 1.1 hannken lis 0,0xfffc
191 1.1 hannken #endif
192 1.1 hannken mtdccr 0
193 1.1 hannken mticcr 0
194 1.1 hannken sync
195 1.1 hannken isync
196 1.1 hannken
197 1.1 hannken /* get start of bss */
198 1.1 hannken lis 7,_C_LABEL(edata)-4@h
199 1.1 hannken ori 7,7,_C_LABEL(edata)-4@l
200 1.1 hannken /* get end of kernel */
201 1.1 hannken lis 4,_C_LABEL(end)@h
202 1.1 hannken ori 4,4,_C_LABEL(end)@l
203 1.1 hannken /* clear bss */
204 1.1 hannken li 3,0
205 1.1 hannken 1:
206 1.1 hannken stwu 3,4(7)
207 1.1 hannken cmpw 7,4
208 1.1 hannken bne+ 1b
209 1.1 hannken
210 1.1 hannken INIT_CPUINFO(4,1,9,0)
211 1.1 hannken
212 1.1 hannken lis 3,__start@h
213 1.1 hannken ori 3,3,__start@l
214 1.1 hannken
215 1.1 hannken /* Run the remaining setup in C. */
216 1.1 hannken bl _C_LABEL(bootstrap)
217 1.1 hannken
218 1.1 hannken bl _C_LABEL(main)
219 1.1 hannken
220 1.1 hannken /* NOTREACHED */
221 1.1 hannken 2: nop
222 1.1 hannken b 2b
223 1.1 hannken
224 1.1 hannken stage1size = .-__start
225 1.1 hannken
226 1.1 hannken #include <powerpc/ibm4xx/4xx_locore.S>
227