machdep.c revision 1.4.2.2 1 1.4.2.2 skrll /* $NetBSD: machdep.c,v 1.4.2.2 2015/06/06 14:39:59 skrll Exp $ */
2 1.4.2.2 skrll
3 1.4.2.2 skrll /*
4 1.4.2.2 skrll * Copyright 2001, 2002 Wasabi Systems, Inc.
5 1.4.2.2 skrll * All rights reserved.
6 1.4.2.2 skrll *
7 1.4.2.2 skrll * Written by Jason R. Thorpe and Simon Burge for Wasabi Systems, Inc.
8 1.4.2.2 skrll *
9 1.4.2.2 skrll * Redistribution and use in source and binary forms, with or without
10 1.4.2.2 skrll * modification, are permitted provided that the following conditions
11 1.4.2.2 skrll * are met:
12 1.4.2.2 skrll * 1. Redistributions of source code must retain the above copyright
13 1.4.2.2 skrll * notice, this list of conditions and the following disclaimer.
14 1.4.2.2 skrll * 2. Redistributions in binary form must reproduce the above copyright
15 1.4.2.2 skrll * notice, this list of conditions and the following disclaimer in the
16 1.4.2.2 skrll * documentation and/or other materials provided with the distribution.
17 1.4.2.2 skrll * 3. All advertising materials mentioning features or use of this software
18 1.4.2.2 skrll * must display the following acknowledgement:
19 1.4.2.2 skrll * This product includes software developed for the NetBSD Project by
20 1.4.2.2 skrll * Wasabi Systems, Inc.
21 1.4.2.2 skrll * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22 1.4.2.2 skrll * or promote products derived from this software without specific prior
23 1.4.2.2 skrll * written permission.
24 1.4.2.2 skrll *
25 1.4.2.2 skrll * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26 1.4.2.2 skrll * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 1.4.2.2 skrll * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 1.4.2.2 skrll * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
29 1.4.2.2 skrll * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 1.4.2.2 skrll * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 1.4.2.2 skrll * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 1.4.2.2 skrll * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 1.4.2.2 skrll * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 1.4.2.2 skrll * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 1.4.2.2 skrll * POSSIBILITY OF SUCH DAMAGE.
36 1.4.2.2 skrll */
37 1.4.2.2 skrll
38 1.4.2.2 skrll /*
39 1.4.2.2 skrll * Copyright (c) 1992, 1993
40 1.4.2.2 skrll * The Regents of the University of California. All rights reserved.
41 1.4.2.2 skrll *
42 1.4.2.2 skrll * This code is derived from software contributed to Berkeley by
43 1.4.2.2 skrll * the Systems Programming Group of the University of Utah Computer
44 1.4.2.2 skrll * Science Department, The Mach Operating System project at
45 1.4.2.2 skrll * Carnegie-Mellon University and Ralph Campbell.
46 1.4.2.2 skrll *
47 1.4.2.2 skrll * Redistribution and use in source and binary forms, with or without
48 1.4.2.2 skrll * modification, are permitted provided that the following conditions
49 1.4.2.2 skrll * are met:
50 1.4.2.2 skrll * 1. Redistributions of source code must retain the above copyright
51 1.4.2.2 skrll * notice, this list of conditions and the following disclaimer.
52 1.4.2.2 skrll * 2. Redistributions in binary form must reproduce the above copyright
53 1.4.2.2 skrll * notice, this list of conditions and the following disclaimer in the
54 1.4.2.2 skrll * documentation and/or other materials provided with the distribution.
55 1.4.2.2 skrll * 3. Neither the name of the University nor the names of its contributors
56 1.4.2.2 skrll * may be used to endorse or promote products derived from this software
57 1.4.2.2 skrll * without specific prior written permission.
58 1.4.2.2 skrll *
59 1.4.2.2 skrll * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
60 1.4.2.2 skrll * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
61 1.4.2.2 skrll * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
62 1.4.2.2 skrll * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
63 1.4.2.2 skrll * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
64 1.4.2.2 skrll * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
65 1.4.2.2 skrll * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
66 1.4.2.2 skrll * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
67 1.4.2.2 skrll * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
68 1.4.2.2 skrll * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
69 1.4.2.2 skrll * SUCH DAMAGE.
70 1.4.2.2 skrll *
71 1.4.2.2 skrll * @(#)machdep.c 8.3 (Berkeley) 1/12/94
72 1.4.2.2 skrll * from: Utah Hdr: machdep.c 1.63 91/04/24
73 1.4.2.2 skrll */
74 1.4.2.2 skrll /*
75 1.4.2.2 skrll * Copyright (c) 1988 University of Utah.
76 1.4.2.2 skrll *
77 1.4.2.2 skrll * This code is derived from software contributed to Berkeley by
78 1.4.2.2 skrll * the Systems Programming Group of the University of Utah Computer
79 1.4.2.2 skrll * Science Department, The Mach Operating System project at
80 1.4.2.2 skrll * Carnegie-Mellon University and Ralph Campbell.
81 1.4.2.2 skrll *
82 1.4.2.2 skrll * Redistribution and use in source and binary forms, with or without
83 1.4.2.2 skrll * modification, are permitted provided that the following conditions
84 1.4.2.2 skrll * are met:
85 1.4.2.2 skrll * 1. Redistributions of source code must retain the above copyright
86 1.4.2.2 skrll * notice, this list of conditions and the following disclaimer.
87 1.4.2.2 skrll * 2. Redistributions in binary form must reproduce the above copyright
88 1.4.2.2 skrll * notice, this list of conditions and the following disclaimer in the
89 1.4.2.2 skrll * documentation and/or other materials provided with the distribution.
90 1.4.2.2 skrll * 3. All advertising materials mentioning features or use of this software
91 1.4.2.2 skrll * must display the following acknowledgement:
92 1.4.2.2 skrll * This product includes software developed by the University of
93 1.4.2.2 skrll * California, Berkeley and its contributors.
94 1.4.2.2 skrll * 4. Neither the name of the University nor the names of its contributors
95 1.4.2.2 skrll * may be used to endorse or promote products derived from this software
96 1.4.2.2 skrll * without specific prior written permission.
97 1.4.2.2 skrll *
98 1.4.2.2 skrll * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
99 1.4.2.2 skrll * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
100 1.4.2.2 skrll * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
101 1.4.2.2 skrll * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
102 1.4.2.2 skrll * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
103 1.4.2.2 skrll * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
104 1.4.2.2 skrll * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
105 1.4.2.2 skrll * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
106 1.4.2.2 skrll * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
107 1.4.2.2 skrll * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
108 1.4.2.2 skrll * SUCH DAMAGE.
109 1.4.2.2 skrll *
110 1.4.2.2 skrll * @(#)machdep.c 8.3 (Berkeley) 1/12/94
111 1.4.2.2 skrll * from: Utah Hdr: machdep.c 1.63 91/04/24
112 1.4.2.2 skrll */
113 1.4.2.2 skrll
114 1.4.2.2 skrll #include <sys/cdefs.h>
115 1.4.2.2 skrll __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.4.2.2 2015/06/06 14:39:59 skrll Exp $");
116 1.4.2.2 skrll
117 1.4.2.2 skrll #include <sys/param.h>
118 1.4.2.2 skrll #include <sys/systm.h>
119 1.4.2.2 skrll #include <sys/kernel.h>
120 1.4.2.2 skrll #include <sys/buf.h>
121 1.4.2.2 skrll #include <sys/cpu.h>
122 1.4.2.2 skrll #include <sys/reboot.h>
123 1.4.2.2 skrll #include <sys/mount.h>
124 1.4.2.2 skrll #include <sys/kcore.h>
125 1.4.2.2 skrll #include <sys/boot_flag.h>
126 1.4.2.2 skrll #include <sys/termios.h>
127 1.4.2.2 skrll #include <sys/ksyms.h>
128 1.4.2.2 skrll
129 1.4.2.2 skrll #include <uvm/uvm_extern.h>
130 1.4.2.2 skrll
131 1.4.2.2 skrll #include <dev/cons.h>
132 1.4.2.2 skrll
133 1.4.2.2 skrll #include "ksyms.h"
134 1.4.2.2 skrll
135 1.4.2.2 skrll #if NKSYMS || defined(DDB) || defined(LKM)
136 1.4.2.2 skrll #include <machine/db_machdep.h>
137 1.4.2.2 skrll #include <ddb/db_extern.h>
138 1.4.2.2 skrll #endif
139 1.4.2.2 skrll
140 1.4.2.2 skrll #include <machine/psl.h>
141 1.4.2.2 skrll #include <machine/locore.h>
142 1.4.2.2 skrll
143 1.4.2.2 skrll #include <mips/cavium/autoconf.h>
144 1.4.2.2 skrll #include <mips/cavium/octeonvar.h>
145 1.4.2.2 skrll #include <mips/cavium/include/iobusvar.h>
146 1.4.2.2 skrll #include <mips/cavium/include/bootbusvar.h>
147 1.4.2.2 skrll
148 1.4.2.2 skrll #include <mips/cavium/dev/octeon_uartreg.h>
149 1.4.2.2 skrll #include <mips/cavium/dev/octeon_ciureg.h>
150 1.4.2.2 skrll #include <mips/cavium/dev/octeon_gpioreg.h>
151 1.4.2.2 skrll
152 1.4.2.2 skrll #include <evbmips/cavium/octeon_uboot.h>
153 1.4.2.2 skrll
154 1.4.2.2 skrll static void mach_init_bss(void);
155 1.4.2.2 skrll static void mach_init_vector(void);
156 1.4.2.2 skrll static void mach_init_bus_space(void);
157 1.4.2.2 skrll static void mach_init_console(void);
158 1.4.2.2 skrll static void mach_init_memory(u_quad_t);
159 1.4.2.2 skrll
160 1.4.2.2 skrll #include "com.h"
161 1.4.2.2 skrll #if NCOM > 0
162 1.4.2.2 skrll #include <dev/ic/comreg.h>
163 1.4.2.2 skrll #include <dev/ic/comvar.h>
164 1.4.2.2 skrll int comcnrate = 115200; /* XXX should be config option */
165 1.4.2.2 skrll #endif /* NCOM > 0 */
166 1.4.2.2 skrll
167 1.4.2.2 skrll /* Maps for VM objects. */
168 1.4.2.2 skrll struct vm_map *phys_map = NULL;
169 1.4.2.2 skrll
170 1.4.2.2 skrll int netboot;
171 1.4.2.2 skrll
172 1.4.2.2 skrll phys_ram_seg_t mem_clusters[VM_PHYSSEG_MAX];
173 1.4.2.2 skrll int mem_cluster_cnt;
174 1.4.2.2 skrll
175 1.4.2.2 skrll
176 1.4.2.2 skrll void configure(void);
177 1.4.2.2 skrll void mach_init(uint64_t, uint64_t, uint64_t, uint64_t);
178 1.4.2.2 skrll
179 1.4.2.2 skrll struct octeon_config octeon_configuration;
180 1.4.2.2 skrll struct octeon_btinfo octeon_btinfo;
181 1.4.2.2 skrll
182 1.4.2.2 skrll /*
183 1.4.2.2 skrll * Do all the stuff that locore normally does before calling main().
184 1.4.2.2 skrll */
185 1.4.2.2 skrll void
186 1.4.2.2 skrll mach_init(uint64_t arg0, uint64_t arg1, uint64_t arg2, uint64_t arg3)
187 1.4.2.2 skrll {
188 1.4.2.2 skrll uint64_t btinfo_paddr;
189 1.4.2.2 skrll u_quad_t memsize;
190 1.4.2.2 skrll int corefreq;
191 1.4.2.2 skrll
192 1.4.2.2 skrll mach_init_bss();
193 1.4.2.2 skrll
194 1.4.2.2 skrll KASSERT(MIPS_XKPHYS_P(arg3));
195 1.4.2.2 skrll btinfo_paddr = mips64_ld_a64(arg3 + OCTEON_BTINFO_PADDR_OFFSET);
196 1.4.2.2 skrll
197 1.4.2.2 skrll /* Should be in first 256MB segment */
198 1.4.2.2 skrll KASSERT(btinfo_paddr < 256 * 1024 * 1024);
199 1.4.2.2 skrll memcpy(&octeon_btinfo,
200 1.4.2.2 skrll (struct octeon_btinfo *)MIPS_PHYS_TO_KSEG0(btinfo_paddr),
201 1.4.2.2 skrll sizeof(octeon_btinfo));
202 1.4.2.2 skrll
203 1.4.2.2 skrll corefreq = octeon_btinfo.obt_eclock_hz;
204 1.4.2.2 skrll memsize = octeon_btinfo.obt_dram_size * 1024 * 1024;
205 1.4.2.2 skrll
206 1.4.2.2 skrll octeon_cal_timer(corefreq);
207 1.4.2.2 skrll
208 1.4.2.2 skrll switch (MIPS_PRID_IMPL(mips_options.mips_cpu_id)) {
209 1.4.2.2 skrll case 0: cpu_setmodel("Cavium Octeon CN38XX/CN36XX"); break;
210 1.4.2.2 skrll case 1: cpu_setmodel("Cavium Octeon CN31XX/CN3020"); break;
211 1.4.2.2 skrll case 2: cpu_setmodel("Cavium Octeon CN3005/CN3010"); break;
212 1.4.2.2 skrll case 3: cpu_setmodel("Cavium Octeon CN58XX"); break;
213 1.4.2.2 skrll case 4: cpu_setmodel("Cavium Octeon CN5[4-7]XX"); break;
214 1.4.2.2 skrll case 6: cpu_setmodel("Cavium Octeon CN50XX"); break;
215 1.4.2.2 skrll case 7: cpu_setmodel("Cavium Octeon CN52XX"); break;
216 1.4.2.2 skrll default: cpu_setmodel("Cavium Octeon"); break;
217 1.4.2.2 skrll }
218 1.4.2.2 skrll
219 1.4.2.2 skrll mach_init_vector();
220 1.4.2.2 skrll
221 1.4.2.2 skrll /* set the VM page size */
222 1.4.2.2 skrll uvm_setpagesize();
223 1.4.2.2 skrll
224 1.4.2.2 skrll mach_init_bus_space();
225 1.4.2.2 skrll
226 1.4.2.2 skrll mach_init_console();
227 1.4.2.2 skrll
228 1.4.2.2 skrll mach_init_memory(memsize);
229 1.4.2.2 skrll
230 1.4.2.2 skrll /*
231 1.4.2.2 skrll * Allocate uarea page for lwp0 and set it.
232 1.4.2.2 skrll */
233 1.4.2.2 skrll mips_init_lwp0_uarea();
234 1.4.2.2 skrll
235 1.4.2.2 skrll boothowto = RB_AUTOBOOT;
236 1.4.2.2 skrll
237 1.4.2.2 skrll #if defined(DDB)
238 1.4.2.2 skrll if (boothowto & RB_KDB)
239 1.4.2.2 skrll Debugger();
240 1.4.2.2 skrll #endif
241 1.4.2.2 skrll }
242 1.4.2.2 skrll
243 1.4.2.2 skrll void
244 1.4.2.2 skrll consinit(void)
245 1.4.2.2 skrll {
246 1.4.2.2 skrll
247 1.4.2.2 skrll /*
248 1.4.2.2 skrll * Everything related to console initialization is done
249 1.4.2.2 skrll * in mach_init().
250 1.4.2.2 skrll */
251 1.4.2.2 skrll }
252 1.4.2.2 skrll
253 1.4.2.2 skrll void
254 1.4.2.2 skrll mach_init_bss(void)
255 1.4.2.2 skrll {
256 1.4.2.2 skrll extern char edata[], end[];
257 1.4.2.2 skrll
258 1.4.2.2 skrll /*
259 1.4.2.2 skrll * Clear the BSS segment.
260 1.4.2.2 skrll */
261 1.4.2.2 skrll memset(edata, 0, mips_round_page(end) - (uintptr_t)edata);
262 1.4.2.2 skrll }
263 1.4.2.2 skrll
264 1.4.2.2 skrll void
265 1.4.2.2 skrll mach_init_vector(void)
266 1.4.2.2 skrll {
267 1.4.2.2 skrll
268 1.4.2.2 skrll /* Make sure exception base at 0 (MIPS_COP_0_EBASE) */
269 1.4.2.2 skrll asm volatile("mtc0 %0, $15, 1" : : "r"(0x80000000) );
270 1.4.2.2 skrll
271 1.4.2.2 skrll /*
272 1.4.2.2 skrll * Set up the exception vectors and CPU-specific function
273 1.4.2.2 skrll * vectors early on. We need the wbflush() vector set up
274 1.4.2.2 skrll * before comcnattach() is called (or at least before the
275 1.4.2.2 skrll * first printf() after that is called).
276 1.4.2.2 skrll * Also clears the I+D caches.
277 1.4.2.2 skrll */
278 1.4.2.2 skrll #if MULTIPROCESSOR
279 1.4.2.2 skrll mips_vector_init(NULL, true);
280 1.4.2.2 skrll #else
281 1.4.2.2 skrll mips_vector_init(NULL, false);
282 1.4.2.2 skrll #endif
283 1.4.2.2 skrll }
284 1.4.2.2 skrll
285 1.4.2.2 skrll void
286 1.4.2.2 skrll mach_init_bus_space(void)
287 1.4.2.2 skrll {
288 1.4.2.2 skrll struct octeon_config *mcp = &octeon_configuration;
289 1.4.2.2 skrll
290 1.4.2.2 skrll octeon_dma_init(mcp);
291 1.4.2.2 skrll
292 1.4.2.2 skrll iobus_bootstrap(mcp);
293 1.4.2.2 skrll bootbus_bootstrap(mcp);
294 1.4.2.2 skrll }
295 1.4.2.2 skrll
296 1.4.2.2 skrll void
297 1.4.2.2 skrll mach_init_console(void)
298 1.4.2.2 skrll {
299 1.4.2.2 skrll #if NCOM > 0
300 1.4.2.2 skrll struct octeon_config *mcp = &octeon_configuration;
301 1.4.2.2 skrll int status;
302 1.4.2.2 skrll extern int octeon_uart_com_cnattach(bus_space_tag_t, int, int);
303 1.4.2.2 skrll
304 1.4.2.2 skrll /*
305 1.4.2.2 skrll * Delay to allow firmware putchars to complete.
306 1.4.2.2 skrll * FIFO depth * character time.
307 1.4.2.2 skrll * character time = (1000000 / (defaultrate / 10))
308 1.4.2.2 skrll */
309 1.4.2.2 skrll delay(640000000 / comcnrate);
310 1.4.2.2 skrll
311 1.4.2.2 skrll status = octeon_uart_com_cnattach(
312 1.4.2.2 skrll &mcp->mc_iobus_bust,
313 1.4.2.2 skrll 0, /* XXX port 0 */
314 1.4.2.2 skrll comcnrate);
315 1.4.2.2 skrll if (status != 0)
316 1.4.2.2 skrll panic("can't initialize console!"); /* XXX print to nowhere! */
317 1.4.2.2 skrll #else
318 1.4.2.2 skrll panic("octeon: not configured to use serial console");
319 1.4.2.2 skrll #endif /* NCOM > 0 */
320 1.4.2.2 skrll }
321 1.4.2.2 skrll
322 1.4.2.2 skrll void
323 1.4.2.2 skrll mach_init_memory(u_quad_t memsize)
324 1.4.2.2 skrll {
325 1.4.2.2 skrll extern char kernel_text[];
326 1.4.2.2 skrll extern char end[];
327 1.4.2.2 skrll
328 1.4.2.2 skrll physmem = btoc(memsize);
329 1.4.2.2 skrll
330 1.4.2.2 skrll if (memsize <= 256 * 1024 * 1024) {
331 1.4.2.2 skrll mem_clusters[0].start = 0;
332 1.4.2.2 skrll mem_clusters[0].size = memsize;
333 1.4.2.2 skrll mem_cluster_cnt = 1;
334 1.4.2.2 skrll } else if (memsize <= 512 * 1024 * 1024) {
335 1.4.2.2 skrll mem_clusters[0].start = 0;
336 1.4.2.2 skrll mem_clusters[0].size = 256 * 1024 * 1024;
337 1.4.2.2 skrll mem_clusters[1].start = 0x410000000ULL;
338 1.4.2.2 skrll mem_clusters[1].size = memsize - 256 * 1024 * 1024;
339 1.4.2.2 skrll mem_cluster_cnt = 2;
340 1.4.2.2 skrll } else {
341 1.4.2.2 skrll mem_clusters[0].start = 0;
342 1.4.2.2 skrll mem_clusters[0].size = 256 * 1024 * 1024;
343 1.4.2.2 skrll mem_clusters[1].start = 0x20000000;
344 1.4.2.2 skrll mem_clusters[1].size = memsize - 512 * 1024 * 1024;
345 1.4.2.2 skrll mem_clusters[2].start = 0x410000000ULL;
346 1.4.2.2 skrll mem_clusters[2].size = 256 * 1024 * 1024;
347 1.4.2.2 skrll mem_cluster_cnt = 3;
348 1.4.2.2 skrll }
349 1.4.2.2 skrll
350 1.4.2.2 skrll
351 1.4.2.2 skrll #ifdef MULTIPROCESSOR
352 1.4.2.2 skrll const u_int cores = mipsNN_cp0_ebase_read() & MIPS_EBASE_CPUNUM;
353 1.4.2.2 skrll mem_clusters[0].start = cores * 4096;
354 1.4.2.2 skrll #endif
355 1.4.2.2 skrll
356 1.4.2.2 skrll /*
357 1.4.2.2 skrll * Load the rest of the available pages into the VM system.
358 1.4.2.2 skrll */
359 1.4.2.2 skrll mips_page_physload(mips_trunc_page(kernel_text), mips_round_page(end),
360 1.4.2.2 skrll mem_clusters, mem_cluster_cnt, NULL, 0);
361 1.4.2.2 skrll
362 1.4.2.2 skrll /*
363 1.4.2.2 skrll * Initialize error message buffer (at end of core).
364 1.4.2.2 skrll */
365 1.4.2.2 skrll mips_init_msgbuf();
366 1.4.2.2 skrll
367 1.4.2.2 skrll pmap_bootstrap();
368 1.4.2.2 skrll }
369 1.4.2.2 skrll
370 1.4.2.2 skrll /*
371 1.4.2.2 skrll * cpu_startup
372 1.4.2.2 skrll * cpu_reboot
373 1.4.2.2 skrll */
374 1.4.2.2 skrll
375 1.4.2.2 skrll int waittime = -1;
376 1.4.2.2 skrll
377 1.4.2.2 skrll /*
378 1.4.2.2 skrll * Allocate memory for variable-sized tables,
379 1.4.2.2 skrll */
380 1.4.2.2 skrll void
381 1.4.2.2 skrll cpu_startup(void)
382 1.4.2.2 skrll {
383 1.4.2.2 skrll /*
384 1.4.2.2 skrll * Do the common startup items.
385 1.4.2.2 skrll */
386 1.4.2.2 skrll cpu_startup_common();
387 1.4.2.2 skrll
388 1.4.2.2 skrll /*
389 1.4.2.2 skrll * Virtual memory is bootstrapped -- notify the bus spaces
390 1.4.2.2 skrll * that memory allocation is now safe.
391 1.4.2.2 skrll */
392 1.4.2.2 skrll octeon_configuration.mc_mallocsafe = 1;
393 1.4.2.2 skrll }
394 1.4.2.2 skrll
395 1.4.2.2 skrll void
396 1.4.2.2 skrll cpu_reboot(int howto, char *bootstr)
397 1.4.2.2 skrll {
398 1.4.2.2 skrll
399 1.4.2.2 skrll /* Take a snapshot before clobbering any registers. */
400 1.4.2.2 skrll savectx(curpcb);
401 1.4.2.2 skrll
402 1.4.2.2 skrll if (cold) {
403 1.4.2.2 skrll howto |= RB_HALT;
404 1.4.2.2 skrll goto haltsys;
405 1.4.2.2 skrll }
406 1.4.2.2 skrll
407 1.4.2.2 skrll /* If "always halt" was specified as a boot flag, obey. */
408 1.4.2.2 skrll if (boothowto & RB_HALT)
409 1.4.2.2 skrll howto |= RB_HALT;
410 1.4.2.2 skrll
411 1.4.2.2 skrll boothowto = howto;
412 1.4.2.2 skrll if ((howto & RB_NOSYNC) == 0 && (waittime < 0)) {
413 1.4.2.2 skrll waittime = 0;
414 1.4.2.2 skrll vfs_shutdown();
415 1.4.2.2 skrll
416 1.4.2.2 skrll /*
417 1.4.2.2 skrll * If we've been adjusting the clock, the todr
418 1.4.2.2 skrll * will be out of synch; adjust it now.
419 1.4.2.2 skrll */
420 1.4.2.2 skrll resettodr();
421 1.4.2.2 skrll }
422 1.4.2.2 skrll
423 1.4.2.2 skrll splhigh();
424 1.4.2.2 skrll
425 1.4.2.2 skrll if (howto & RB_DUMP)
426 1.4.2.2 skrll dumpsys();
427 1.4.2.2 skrll
428 1.4.2.2 skrll haltsys:
429 1.4.2.2 skrll doshutdownhooks();
430 1.4.2.2 skrll
431 1.4.2.2 skrll if (howto & RB_HALT) {
432 1.4.2.2 skrll printf("\n");
433 1.4.2.2 skrll printf("The operating system has halted.\n");
434 1.4.2.2 skrll printf("Please press any key to reboot.\n\n");
435 1.4.2.2 skrll }
436 1.4.2.2 skrll
437 1.4.2.2 skrll printf("%s\n\n", ((howto & RB_HALT) != 0) ? "halted." : "rebooting...");
438 1.4.2.2 skrll
439 1.4.2.2 skrll /*
440 1.4.2.2 skrll * Need a small delay here, otherwise we see the first few characters of
441 1.4.2.2 skrll * the warning below.
442 1.4.2.2 skrll */
443 1.4.2.2 skrll delay(80000);
444 1.4.2.2 skrll
445 1.4.2.2 skrll /* initiate chip soft-reset */
446 1.4.2.2 skrll uint64_t fuse = octeon_read_csr(CIU_FUSE);
447 1.4.2.2 skrll octeon_write_csr(CIU_SOFT_BIST, fuse);
448 1.4.2.2 skrll octeon_read_csr(CIU_SOFT_RST);
449 1.4.2.2 skrll octeon_write_csr(CIU_SOFT_RST, fuse);
450 1.4.2.2 skrll
451 1.4.2.2 skrll delay(1000000);
452 1.4.2.2 skrll
453 1.4.2.2 skrll printf("WARNING: reset failed!\nSpinning...");
454 1.4.2.2 skrll
455 1.4.2.2 skrll for (;;)
456 1.4.2.2 skrll /* spin forever */ ; /* XXX */
457 1.4.2.2 skrll }
458