machdep.c revision 1.1.6.1 1 1.1.6.1 joerg /* $NetBSD: machdep.c,v 1.1.6.1 2007/11/02 13:34:37 joerg Exp $ */
2 1.1.6.1 joerg
3 1.1.6.1 joerg /*
4 1.1.6.1 joerg * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 1.1.6.1 joerg * All rights reserved.
6 1.1.6.1 joerg *
7 1.1.6.1 joerg * This code is derived from software contributed to The NetBSD Foundation
8 1.1.6.1 joerg * by Lennart Augustsson (lennart (at) augustsson.net) at Sandburst Corp.
9 1.1.6.1 joerg *
10 1.1.6.1 joerg * Redistribution and use in source and binary forms, with or without
11 1.1.6.1 joerg * modification, are permitted provided that the following conditions
12 1.1.6.1 joerg * are met:
13 1.1.6.1 joerg * 1. Redistributions of source code must retain the above copyright
14 1.1.6.1 joerg * notice, this list of conditions and the following disclaimer.
15 1.1.6.1 joerg * 2. Redistributions in binary form must reproduce the above copyright
16 1.1.6.1 joerg * notice, this list of conditions and the following disclaimer in the
17 1.1.6.1 joerg * documentation and/or other materials provided with the distribution.
18 1.1.6.1 joerg * 3. All advertising materials mentioning features or use of this software
19 1.1.6.1 joerg * must display the following acknowledgement:
20 1.1.6.1 joerg * This product includes software developed by the NetBSD
21 1.1.6.1 joerg * Foundation, Inc. and its contributors.
22 1.1.6.1 joerg * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1.6.1 joerg * contributors may be used to endorse or promote products derived
24 1.1.6.1 joerg * from this software without specific prior written permission.
25 1.1.6.1 joerg *
26 1.1.6.1 joerg * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1.6.1 joerg * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1.6.1 joerg * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1.6.1 joerg * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1.6.1 joerg * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1.6.1 joerg * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1.6.1 joerg * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1.6.1 joerg * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1.6.1 joerg * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1.6.1 joerg * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1.6.1 joerg * POSSIBILITY OF SUCH DAMAGE.
37 1.1.6.1 joerg */
38 1.1.6.1 joerg
39 1.1.6.1 joerg /*
40 1.1.6.1 joerg * Copyright (C) 1995, 1996 Wolfgang Solfrank.
41 1.1.6.1 joerg * Copyright (C) 1995, 1996 TooLs GmbH.
42 1.1.6.1 joerg * All rights reserved.
43 1.1.6.1 joerg *
44 1.1.6.1 joerg * Redistribution and use in source and binary forms, with or without
45 1.1.6.1 joerg * modification, are permitted provided that the following conditions
46 1.1.6.1 joerg * are met:
47 1.1.6.1 joerg * 1. Redistributions of source code must retain the above copyright
48 1.1.6.1 joerg * notice, this list of conditions and the following disclaimer.
49 1.1.6.1 joerg * 2. Redistributions in binary form must reproduce the above copyright
50 1.1.6.1 joerg * notice, this list of conditions and the following disclaimer in the
51 1.1.6.1 joerg * documentation and/or other materials provided with the distribution.
52 1.1.6.1 joerg * 3. All advertising materials mentioning features or use of this software
53 1.1.6.1 joerg * must display the following acknowledgement:
54 1.1.6.1 joerg * This product includes software developed by TooLs GmbH.
55 1.1.6.1 joerg * 4. The name of TooLs GmbH may not be used to endorse or promote products
56 1.1.6.1 joerg * derived from this software without specific prior written permission.
57 1.1.6.1 joerg *
58 1.1.6.1 joerg * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
59 1.1.6.1 joerg * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
60 1.1.6.1 joerg * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
61 1.1.6.1 joerg * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
62 1.1.6.1 joerg * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
63 1.1.6.1 joerg * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
64 1.1.6.1 joerg * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
65 1.1.6.1 joerg * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
66 1.1.6.1 joerg * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
67 1.1.6.1 joerg * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
68 1.1.6.1 joerg */
69 1.1.6.1 joerg
70 1.1.6.1 joerg #include <sys/cdefs.h>
71 1.1.6.1 joerg __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.1.6.1 2007/11/02 13:34:37 joerg Exp $");
72 1.1.6.1 joerg
73 1.1.6.1 joerg #include "opt_compat_netbsd.h"
74 1.1.6.1 joerg #include "opt_ddb.h"
75 1.1.6.1 joerg #include "opt_ddbparam.h"
76 1.1.6.1 joerg #include "opt_inet.h"
77 1.1.6.1 joerg #include "opt_ccitt.h"
78 1.1.6.1 joerg #include "opt_iso.h"
79 1.1.6.1 joerg #include "opt_ns.h"
80 1.1.6.1 joerg #include "opt_ipkdb.h"
81 1.1.6.1 joerg
82 1.1.6.1 joerg #include <sys/param.h>
83 1.1.6.1 joerg #include <sys/buf.h>
84 1.1.6.1 joerg #include <sys/conf.h>
85 1.1.6.1 joerg #include <sys/device.h>
86 1.1.6.1 joerg #include <sys/exec.h>
87 1.1.6.1 joerg #include <sys/extent.h>
88 1.1.6.1 joerg #include <sys/kernel.h>
89 1.1.6.1 joerg #include <sys/kgdb.h>
90 1.1.6.1 joerg #include <sys/malloc.h>
91 1.1.6.1 joerg #include <sys/mbuf.h>
92 1.1.6.1 joerg #include <sys/mount.h>
93 1.1.6.1 joerg #include <sys/msgbuf.h>
94 1.1.6.1 joerg #include <sys/proc.h>
95 1.1.6.1 joerg #include <sys/reboot.h>
96 1.1.6.1 joerg #include <sys/syscallargs.h>
97 1.1.6.1 joerg #include <sys/syslog.h>
98 1.1.6.1 joerg #include <sys/sysctl.h>
99 1.1.6.1 joerg #include <sys/systm.h>
100 1.1.6.1 joerg #include <sys/user.h>
101 1.1.6.1 joerg #include <sys/ksyms.h>
102 1.1.6.1 joerg
103 1.1.6.1 joerg #include <uvm/uvm.h>
104 1.1.6.1 joerg #include <uvm/uvm_extern.h>
105 1.1.6.1 joerg
106 1.1.6.1 joerg #include <net/netisr.h>
107 1.1.6.1 joerg
108 1.1.6.1 joerg #include <machine/bus.h>
109 1.1.6.1 joerg #include <machine/db_machdep.h>
110 1.1.6.1 joerg #include <machine/intr.h>
111 1.1.6.1 joerg #include <machine/pio.h>
112 1.1.6.1 joerg #include <machine/pmap.h>
113 1.1.6.1 joerg #include <machine/powerpc.h>
114 1.1.6.1 joerg #include <machine/trap.h>
115 1.1.6.1 joerg #include <machine/pmppc.h>
116 1.1.6.1 joerg
117 1.1.6.1 joerg #include <powerpc/oea/bat.h>
118 1.1.6.1 joerg #include <arch/powerpc/pic/picvar.h>
119 1.1.6.1 joerg
120 1.1.6.1 joerg #include <ddb/db_extern.h>
121 1.1.6.1 joerg
122 1.1.6.1 joerg #include <dev/cons.h>
123 1.1.6.1 joerg
124 1.1.6.1 joerg #include <dev/ic/cpc700reg.h>
125 1.1.6.1 joerg #include <dev/ic/cpc700uic.h>
126 1.1.6.1 joerg
127 1.1.6.1 joerg #include "com.h"
128 1.1.6.1 joerg #if (NCOM > 0)
129 1.1.6.1 joerg #include <sys/termios.h>
130 1.1.6.1 joerg #include <dev/ic/comreg.h>
131 1.1.6.1 joerg #include <dev/ic/comvar.h>
132 1.1.6.1 joerg #endif
133 1.1.6.1 joerg
134 1.1.6.1 joerg #include "ksyms.h"
135 1.1.6.1 joerg
136 1.1.6.1 joerg struct powerpc_bus_space pmppc_mem_tag = {
137 1.1.6.1 joerg _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
138 1.1.6.1 joerg 0, 0, 0xffffffff,
139 1.1.6.1 joerg NULL,
140 1.1.6.1 joerg };
141 1.1.6.1 joerg struct powerpc_bus_space pmppc_pci_io_tag = {
142 1.1.6.1 joerg _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
143 1.1.6.1 joerg 0, CPC_PCI_IO_BASE, 0xffffffff,
144 1.1.6.1 joerg NULL,
145 1.1.6.1 joerg };
146 1.1.6.1 joerg
147 1.1.6.1 joerg static char ex_storage[1][EXTENT_FIXED_STORAGE_SIZE(8)]
148 1.1.6.1 joerg __attribute__((aligned(8)));
149 1.1.6.1 joerg
150 1.1.6.1 joerg
151 1.1.6.1 joerg #ifdef KGDB
152 1.1.6.1 joerg char kgdb_devname[] = KGDB_DEVNAME;
153 1.1.6.1 joerg int comkgdbaddr = KGDB_DEVADDR;
154 1.1.6.1 joerg int comkgdbrate = KGDB_DEVRATE;
155 1.1.6.1 joerg
156 1.1.6.1 joerg #ifndef KGDB_DEVMODE
157 1.1.6.1 joerg #define KGDB_DEVMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
158 1.1.6.1 joerg #endif
159 1.1.6.1 joerg int comkgdbmode = KGDB_DEVMODE;
160 1.1.6.1 joerg
161 1.1.6.1 joerg void kgdb_port_init(void);
162 1.1.6.1 joerg #endif /* KGDB */
163 1.1.6.1 joerg
164 1.1.6.1 joerg /*
165 1.1.6.1 joerg * Global variables used here and there
166 1.1.6.1 joerg */
167 1.1.6.1 joerg struct mem_region physmemr[2], availmemr[2];
168 1.1.6.1 joerg
169 1.1.6.1 joerg struct a_config a_config;
170 1.1.6.1 joerg
171 1.1.6.1 joerg void initppc(u_int, u_int, u_int, void *); /* Called from locore */
172 1.1.6.1 joerg void pmppc_setup(void);
173 1.1.6.1 joerg void setleds(int leds);
174 1.1.6.1 joerg
175 1.1.6.1 joerg /*
176 1.1.6.1 joerg * Force cpu_info to be in the data segment to avoid the
177 1.1.6.1 joerg * memset() blowing away the data set up by locore.S.
178 1.1.6.1 joerg */
179 1.1.6.1 joerg #if 0
180 1.1.6.1 joerg /* this is defined in powerpc/oea/cpu_subr.c, I don't understand the above
181 1.1.6.1 joerg * comment however.
182 1.1.6.1 joerg */
183 1.1.6.1 joerg struct cpu_info cpu_info[1] = { { .ci_curlwp = &lwp0, }, };
184 1.1.6.1 joerg #endif
185 1.1.6.1 joerg
186 1.1.6.1 joerg void
187 1.1.6.1 joerg initppc(u_int startkernel, u_int endkernel, u_int args, void *btinfo)
188 1.1.6.1 joerg {
189 1.1.6.1 joerg extern void consinit(void);
190 1.1.6.1 joerg extern u_long ticks_per_sec;
191 1.1.6.1 joerg extern unsigned char edata[], end[];
192 1.1.6.1 joerg
193 1.1.6.1 joerg memset(&edata, 0, end - edata); /* clear BSS */
194 1.1.6.1 joerg
195 1.1.6.1 joerg pmppc_setup();
196 1.1.6.1 joerg
197 1.1.6.1 joerg physmemr[0].start = 0;
198 1.1.6.1 joerg physmemr[0].size = a_config.a_mem_size;
199 1.1.6.1 joerg physmemr[1].size = 0;
200 1.1.6.1 joerg availmemr[0].start = (endkernel + PGOFSET) & ~PGOFSET;
201 1.1.6.1 joerg availmemr[0].size = a_config.a_mem_size - availmemr[0].start;
202 1.1.6.1 joerg availmemr[1].size = 0;
203 1.1.6.1 joerg
204 1.1.6.1 joerg #ifdef BOOTHOWTO
205 1.1.6.1 joerg /*
206 1.1.6.1 joerg * boothowto
207 1.1.6.1 joerg */
208 1.1.6.1 joerg boothowto = BOOTHOWTO;
209 1.1.6.1 joerg #endif
210 1.1.6.1 joerg
211 1.1.6.1 joerg if (bus_space_init(&pmppc_mem_tag, "iomem",
212 1.1.6.1 joerg ex_storage[0], sizeof(ex_storage[0])))
213 1.1.6.1 joerg panic("bus_space_init failed");
214 1.1.6.1 joerg
215 1.1.6.1 joerg /*
216 1.1.6.1 joerg * Get CPU clock
217 1.1.6.1 joerg */
218 1.1.6.1 joerg ticks_per_sec = a_config.a_bus_freq;
219 1.1.6.1 joerg ticks_per_sec /= 4; /* 4 cycles per DEC tick */
220 1.1.6.1 joerg cpu_timebase = ticks_per_sec;
221 1.1.6.1 joerg cpu_initclocks();
222 1.1.6.1 joerg
223 1.1.6.1 joerg /*
224 1.1.6.1 joerg * Initialize the BAT registers
225 1.1.6.1 joerg */
226 1.1.6.1 joerg oea_batinit(
227 1.1.6.1 joerg PMPPC_FLASH_BASE, BAT_BL_256M, /* flash (etc) memory 256M area */
228 1.1.6.1 joerg CPC_PCI_MEM_BASE, BAT_BL_256M, /* PCI memory 256M area */
229 1.1.6.1 joerg CPC_PCI_IO_BASE, BAT_BL_128M, /* PCI I/O 128M area */
230 1.1.6.1 joerg 0);
231 1.1.6.1 joerg
232 1.1.6.1 joerg /*
233 1.1.6.1 joerg * Set up trap vectors
234 1.1.6.1 joerg */
235 1.1.6.1 joerg oea_init(NULL);
236 1.1.6.1 joerg
237 1.1.6.1 joerg /*
238 1.1.6.1 joerg * Set up console.
239 1.1.6.1 joerg */
240 1.1.6.1 joerg consinit(); /* XXX should not be here */
241 1.1.6.1 joerg
242 1.1.6.1 joerg printf("console set up\n");
243 1.1.6.1 joerg
244 1.1.6.1 joerg /*
245 1.1.6.1 joerg * Set the page size.
246 1.1.6.1 joerg */
247 1.1.6.1 joerg uvm_setpagesize();
248 1.1.6.1 joerg
249 1.1.6.1 joerg /*
250 1.1.6.1 joerg * Initialize pmap module.
251 1.1.6.1 joerg */
252 1.1.6.1 joerg pmap_bootstrap(startkernel, endkernel);
253 1.1.6.1 joerg
254 1.1.6.1 joerg #if NKSYMS || defined(DDB) || defined(LKM)
255 1.1.6.1 joerg #ifdef SYMTAB_SPACE
256 1.1.6.1 joerg ksyms_init(0, NULL, NULL);
257 1.1.6.1 joerg #else
258 1.1.6.1 joerg #error "No SYMTAB_SPACE"
259 1.1.6.1 joerg #endif
260 1.1.6.1 joerg #endif
261 1.1.6.1 joerg #ifdef IPKDB
262 1.1.6.1 joerg /*
263 1.1.6.1 joerg * Now trap to IPKDB
264 1.1.6.1 joerg */
265 1.1.6.1 joerg ipkdb_init();
266 1.1.6.1 joerg if (boothowto & RB_KDB)
267 1.1.6.1 joerg ipkdb_connect(0);
268 1.1.6.1 joerg #endif
269 1.1.6.1 joerg #ifdef KGDB
270 1.1.6.1 joerg kgdb_port_init();
271 1.1.6.1 joerg if (boothowto & RB_KDB) {
272 1.1.6.1 joerg kgdb_debug_init = 1;
273 1.1.6.1 joerg kgdb_connect(1);
274 1.1.6.1 joerg }
275 1.1.6.1 joerg #endif
276 1.1.6.1 joerg }
277 1.1.6.1 joerg
278 1.1.6.1 joerg void
279 1.1.6.1 joerg mem_regions(struct mem_region **mem, struct mem_region **avail)
280 1.1.6.1 joerg {
281 1.1.6.1 joerg *mem = physmemr;
282 1.1.6.1 joerg *avail = availmemr;
283 1.1.6.1 joerg }
284 1.1.6.1 joerg
285 1.1.6.1 joerg /*
286 1.1.6.1 joerg * Machine dependent startup code.
287 1.1.6.1 joerg */
288 1.1.6.1 joerg void
289 1.1.6.1 joerg cpu_startup()
290 1.1.6.1 joerg {
291 1.1.6.1 joerg
292 1.1.6.1 joerg oea_startup(NULL);
293 1.1.6.1 joerg
294 1.1.6.1 joerg /*
295 1.1.6.1 joerg * Now that we have VM, malloc()s are OK in bus_space.
296 1.1.6.1 joerg */
297 1.1.6.1 joerg bus_space_mallocok();
298 1.1.6.1 joerg
299 1.1.6.1 joerg /* Set up the PCI bus tag. */
300 1.1.6.1 joerg if (bus_space_init(&pmppc_pci_io_tag, "pcimem", NULL, 0))
301 1.1.6.1 joerg panic("bus_space_init pci failed");
302 1.1.6.1 joerg
303 1.1.6.1 joerg /* Set up interrupt controller */
304 1.1.6.1 joerg cpc700_init_intr(&pmppc_mem_tag, CPC_UIC_BASE,
305 1.1.6.1 joerg CPC_INTR_MASK(PMPPC_I_ETH_INT), 0);
306 1.1.6.1 joerg
307 1.1.6.1 joerg pic_init();
308 1.1.6.1 joerg (void)setup_cpc700();
309 1.1.6.1 joerg oea_install_extint(pic_ext_intr);
310 1.1.6.1 joerg
311 1.1.6.1 joerg #if 0
312 1.1.6.1 joerg /* XXX doesn't seem to be needed anymore */
313 1.1.6.1 joerg /*
314 1.1.6.1 joerg * Now allow hardware interrupts.
315 1.1.6.1 joerg */
316 1.1.6.1 joerg __asm volatile ("mfmsr %0; ori %0,%0,%1; mtmsr %0"
317 1.1.6.1 joerg : "=r"(msr) : "K"(PSL_EE));
318 1.1.6.1 joerg #endif
319 1.1.6.1 joerg }
320 1.1.6.1 joerg
321 1.1.6.1 joerg /*
322 1.1.6.1 joerg * consinit
323 1.1.6.1 joerg * Initialize system console.
324 1.1.6.1 joerg */
325 1.1.6.1 joerg void
326 1.1.6.1 joerg consinit(void)
327 1.1.6.1 joerg {
328 1.1.6.1 joerg static int initted;
329 1.1.6.1 joerg #if (NCOM > 0)
330 1.1.6.1 joerg bus_space_tag_t tag;
331 1.1.6.1 joerg #endif
332 1.1.6.1 joerg
333 1.1.6.1 joerg if (initted)
334 1.1.6.1 joerg return;
335 1.1.6.1 joerg initted = 1;
336 1.1.6.1 joerg
337 1.1.6.1 joerg #if (NCOM > 0)
338 1.1.6.1 joerg tag = &pmppc_mem_tag;
339 1.1.6.1 joerg
340 1.1.6.1 joerg if(comcnattach(tag, CPC_COM0, 9600, CPC_COM_SPEED(a_config.a_bus_freq),
341 1.1.6.1 joerg COM_TYPE_NORMAL,
342 1.1.6.1 joerg ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8)))
343 1.1.6.1 joerg panic("can't init serial console");
344 1.1.6.1 joerg else
345 1.1.6.1 joerg return;
346 1.1.6.1 joerg #endif
347 1.1.6.1 joerg
348 1.1.6.1 joerg panic("console device missing -- serial console not in kernel");
349 1.1.6.1 joerg /* Of course, this is moot if there is no console... */
350 1.1.6.1 joerg }
351 1.1.6.1 joerg
352 1.1.6.1 joerg #ifdef KGDB
353 1.1.6.1 joerg void
354 1.1.6.1 joerg kgdb_port_init(void)
355 1.1.6.1 joerg {
356 1.1.6.1 joerg #if (NCOM > 0)
357 1.1.6.1 joerg if(!strcmp(kgdb_devname, "com")) {
358 1.1.6.1 joerg bus_space_tag_t tag = &pmppc_mem_tag;
359 1.1.6.1 joerg com_kgdb_attach(tag, comkgdbaddr, comkgdbrate,
360 1.1.6.1 joerg CPC_COM_SPEED(a_config.a_bus_freq),
361 1.1.6.1 joerg COM_TYPE_NORMAL, comkgdbmode);
362 1.1.6.1 joerg }
363 1.1.6.1 joerg #endif
364 1.1.6.1 joerg }
365 1.1.6.1 joerg #endif
366 1.1.6.1 joerg
367 1.1.6.1 joerg /*
368 1.1.6.1 joerg * Halt or reboot the machine after syncing/dumping according to howto.
369 1.1.6.1 joerg */
370 1.1.6.1 joerg void
371 1.1.6.1 joerg cpu_reboot(int howto, char *what)
372 1.1.6.1 joerg {
373 1.1.6.1 joerg static int syncing;
374 1.1.6.1 joerg static char str[256];
375 1.1.6.1 joerg char *ap = str, *ap1 = ap;
376 1.1.6.1 joerg extern void disable_intr(void);
377 1.1.6.1 joerg
378 1.1.6.1 joerg boothowto = howto;
379 1.1.6.1 joerg if (!cold && !(howto & RB_NOSYNC) && !syncing) {
380 1.1.6.1 joerg syncing = 1;
381 1.1.6.1 joerg vfs_shutdown(); /* sync */
382 1.1.6.1 joerg resettodr(); /* set wall clock */
383 1.1.6.1 joerg }
384 1.1.6.1 joerg splhigh();
385 1.1.6.1 joerg if (howto & RB_HALT) {
386 1.1.6.1 joerg doshutdownhooks();
387 1.1.6.1 joerg printf("halted\n\n");
388 1.1.6.1 joerg while(1);
389 1.1.6.1 joerg }
390 1.1.6.1 joerg if (!cold && (howto & RB_DUMP))
391 1.1.6.1 joerg oea_dumpsys();
392 1.1.6.1 joerg doshutdownhooks();
393 1.1.6.1 joerg printf("rebooting\n\n");
394 1.1.6.1 joerg if (what && *what) {
395 1.1.6.1 joerg if (strlen(what) > sizeof str - 5)
396 1.1.6.1 joerg printf("boot string too large, ignored\n");
397 1.1.6.1 joerg else {
398 1.1.6.1 joerg strcpy(str, what);
399 1.1.6.1 joerg ap1 = ap = str + strlen(str);
400 1.1.6.1 joerg *ap++ = ' ';
401 1.1.6.1 joerg }
402 1.1.6.1 joerg }
403 1.1.6.1 joerg *ap++ = '-';
404 1.1.6.1 joerg if (howto & RB_SINGLE)
405 1.1.6.1 joerg *ap++ = 's';
406 1.1.6.1 joerg if (howto & RB_KDB)
407 1.1.6.1 joerg *ap++ = 'd';
408 1.1.6.1 joerg *ap++ = 0;
409 1.1.6.1 joerg if (ap[-2] == '-')
410 1.1.6.1 joerg *ap1 = 0;
411 1.1.6.1 joerg
412 1.1.6.1 joerg disable_intr();
413 1.1.6.1 joerg
414 1.1.6.1 joerg /* Write the two byte reset sequence to the reset register. */
415 1.1.6.1 joerg out8(PMPPC_RESET, PMPPC_RESET_SEQ_STEP1);
416 1.1.6.1 joerg out8(PMPPC_RESET, PMPPC_RESET_SEQ_STEP2);
417 1.1.6.1 joerg
418 1.1.6.1 joerg while (1);
419 1.1.6.1 joerg }
420 1.1.6.1 joerg
421 1.1.6.1 joerg void
422 1.1.6.1 joerg setleds(int leds)
423 1.1.6.1 joerg {
424 1.1.6.1 joerg out8(PMPPC_LEDS, leds);
425 1.1.6.1 joerg }
426 1.1.6.1 joerg
427 1.1.6.1 joerg void
428 1.1.6.1 joerg pmppc_setup(void)
429 1.1.6.1 joerg {
430 1.1.6.1 joerg uint config0, config1;
431 1.1.6.1 joerg
432 1.1.6.1 joerg config0 = in8(PMPPC_CONFIG0);
433 1.1.6.1 joerg config1 = in8(PMPPC_CONFIG1);
434 1.1.6.1 joerg
435 1.1.6.1 joerg /* from page 2-8 in the Artesyn User's manual */
436 1.1.6.1 joerg a_config.a_boot_device = config1 & 0x80 ? A_BOOT_FLASH : A_BOOT_ROM;
437 1.1.6.1 joerg a_config.a_has_ecc = (config1 & 0x40) != 0;
438 1.1.6.1 joerg switch (config1 & 0x30) {
439 1.1.6.1 joerg case 0x00: a_config.a_mem_size = 32 * 1024 * 1024; break;
440 1.1.6.1 joerg case 0x10: a_config.a_mem_size = 64 * 1024 * 1024; break;
441 1.1.6.1 joerg case 0x20: a_config.a_mem_size = 128 * 1024 * 1024; break;
442 1.1.6.1 joerg case 0x30: a_config.a_mem_size = 256 * 1024 * 1024; break;
443 1.1.6.1 joerg }
444 1.1.6.1 joerg a_config.a_l2_cache = (config1 >> 2) & 3;
445 1.1.6.1 joerg switch (config1 & 0x03) {
446 1.1.6.1 joerg case 0x00: a_config.a_bus_freq = 66666666; break;
447 1.1.6.1 joerg case 0x01: a_config.a_bus_freq = 83333333; break;
448 1.1.6.1 joerg case 0x02: a_config.a_bus_freq = 100000000; break;
449 1.1.6.1 joerg case 0x03: a_config.a_bus_freq = 0; break; /* XXX */
450 1.1.6.1 joerg }
451 1.1.6.1 joerg a_config.a_is_monarch = (config0 & 0x80) == 0;
452 1.1.6.1 joerg a_config.a_has_eth = (config0 & 0x20) != 0;
453 1.1.6.1 joerg a_config.a_has_rtc = (config0 & 0x10) == 0;
454 1.1.6.1 joerg switch (config0 & 0x0c) {
455 1.1.6.1 joerg case 0x00: a_config.a_flash_size = 256 * 1024 * 1024; break;
456 1.1.6.1 joerg case 0x04: a_config.a_flash_size = 128 * 1024 * 1024; break;
457 1.1.6.1 joerg case 0x08: a_config.a_flash_size = 64 * 1024 * 1024; break;
458 1.1.6.1 joerg case 0x0c: a_config.a_flash_size = 32 * 1024 * 1024; break;
459 1.1.6.1 joerg }
460 1.1.6.1 joerg switch (config0 & 0x03) {
461 1.1.6.1 joerg case 0x00: a_config.a_flash_width = 64; break;
462 1.1.6.1 joerg case 0x01: a_config.a_flash_width = 32; break;
463 1.1.6.1 joerg case 0x02: a_config.a_flash_width = 16; break;
464 1.1.6.1 joerg case 0x03: a_config.a_flash_width = 0; break;
465 1.1.6.1 joerg }
466 1.1.6.1 joerg }
467