xref: /netbsd/sys/arch/algor/algor/machdep.c (revision 6550d01e)
1 /*	$NetBSD: machdep.c,v 1.47 2011/01/14 02:06:22 rmind Exp $	*/
2 
3 /*-
4  * Copyright (c) 2001 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Jason R. Thorpe.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 /*
33  * Copyright (c) 1992, 1993
34  *	The Regents of the University of California.  All rights reserved.
35  *
36  * This code is derived from software contributed to Berkeley by
37  * the Systems Programming Group of the University of Utah Computer
38  * Science Department, The Mach Operating System project at
39  * Carnegie-Mellon University and Ralph Campbell.
40  *
41  * Redistribution and use in source and binary forms, with or without
42  * modification, are permitted provided that the following conditions
43  * are met:
44  * 1. Redistributions of source code must retain the above copyright
45  *    notice, this list of conditions and the following disclaimer.
46  * 2. Redistributions in binary form must reproduce the above copyright
47  *    notice, this list of conditions and the following disclaimer in the
48  *    documentation and/or other materials provided with the distribution.
49  * 3. Neither the name of the University nor the names of its contributors
50  *    may be used to endorse or promote products derived from this software
51  *    without specific prior written permission.
52  *
53  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
54  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
55  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
56  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
57  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
58  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
59  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63  * SUCH DAMAGE.
64  *
65  *	@(#)machdep.c   8.3 (Berkeley) 1/12/94
66  *	from: Utah Hdr: machdep.c 1.63 91/04/24
67  */
68 /*
69  * Copyright (c) 1988 University of Utah.
70  *
71  * This code is derived from software contributed to Berkeley by
72  * the Systems Programming Group of the University of Utah Computer
73  * Science Department, The Mach Operating System project at
74  * Carnegie-Mellon University and Ralph Campbell.
75  *
76  * Redistribution and use in source and binary forms, with or without
77  * modification, are permitted provided that the following conditions
78  * are met:
79  * 1. Redistributions of source code must retain the above copyright
80  *    notice, this list of conditions and the following disclaimer.
81  * 2. Redistributions in binary form must reproduce the above copyright
82  *    notice, this list of conditions and the following disclaimer in the
83  *    documentation and/or other materials provided with the distribution.
84  * 3. All advertising materials mentioning features or use of this software
85  *    must display the following acknowledgement:
86  *	This product includes software developed by the University of
87  *	California, Berkeley and its contributors.
88  * 4. Neither the name of the University nor the names of its contributors
89  *    may be used to endorse or promote products derived from this software
90  *    without specific prior written permission.
91  *
92  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
93  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
94  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
95  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
96  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
97  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
98  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
99  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
100  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
101  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
102  * SUCH DAMAGE.
103  *
104  *	@(#)machdep.c   8.3 (Berkeley) 1/12/94
105  *	from: Utah Hdr: machdep.c 1.63 91/04/24
106  */
107 
108 #include <sys/cdefs.h>
109 __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.47 2011/01/14 02:06:22 rmind Exp $");
110 
111 #include "opt_algor_p4032.h"
112 #include "opt_algor_p5064.h"
113 #include "opt_algor_p6032.h"
114 
115 #include "opt_ddb.h"
116 #include "opt_kgdb.h"
117 
118 #include "opt_memsize.h"
119 #include "opt_ethaddr.h"
120 
121 #include <sys/param.h>
122 #include <sys/systm.h>
123 #include <sys/kernel.h>
124 #include <sys/buf.h>
125 #include <sys/reboot.h>
126 #include <sys/mount.h>
127 #include <sys/kcore.h>
128 #include <sys/boot_flag.h>
129 #include <sys/termios.h>
130 #include <sys/ksyms.h>
131 #include <sys/device.h>
132 #include <sys/lwp.h>
133 
134 #include <net/if.h>
135 #include <net/if_ether.h>
136 
137 #include <uvm/uvm_extern.h>
138 
139 #include <dev/cons.h>
140 
141 #ifdef DDB
142 #include <machine/db_machdep.h>
143 #include <ddb/db_extern.h>
144 #endif
145 
146 #include <machine/bus.h>
147 #include <machine/autoconf.h>
148 #include <machine/pmon.h>
149 #include <machine/pcb.h>
150 
151 #include <algor/pci/vtpbcvar.h>
152 
153 #include "ksyms.h"
154 
155 #include "com.h"
156 #if NCOM > 0
157 #include <dev/ic/comreg.h>
158 #include <dev/ic/comvar.h>
159 
160 int	comcnrate = TTYDEF_SPEED;
161 #endif /* NCOM > 0 */
162 
163 #if defined(ALGOR_P4032) + \
164     defined(ALGOR_P5064) + \
165     defined(ALGOR_P6032) + \
166     0 != 1
167 #error Must configure exactly one platform.
168 #endif
169 
170 #ifdef ALGOR_P4032
171 #include <algor/algor/algor_p4032reg.h>
172 #include <algor/algor/algor_p4032var.h>
173 struct p4032_config p4032_configuration;
174 #endif
175 
176 #ifdef ALGOR_P5064
177 #include <algor/algor/algor_p5064reg.h>
178 #include <algor/algor/algor_p5064var.h>
179 struct p5064_config p5064_configuration;
180 #endif
181 
182 #ifdef ALGOR_P6032
183 #include <algor/algor/algor_p6032reg.h>
184 #include <algor/algor/algor_p6032var.h>
185 struct p6032_config p6032_configuration;
186 #endif
187 
188 /* Our exported CPU info; we can have only one. */
189 struct cpu_info cpu_info_store;
190 
191 /* Maps for VM objects. */
192 struct vm_map *phys_map = NULL;
193 
194 int	physmem;		/* # pages of physical memory */
195 int	maxmem;			/* max memory per process */
196 
197 int	mem_cluster_cnt;
198 phys_ram_seg_t mem_clusters[VM_PHYSSEG_MAX];
199 
200 char	algor_ethaddr[ETHER_ADDR_LEN];
201 
202 void	mach_init(int, char *[], char *[]);	/* XXX */
203 
204 int	cpuspeed = 150;		/* XXX XXX XXX */
205 
206 void
207 mach_init(int argc, char *argv[], char *envp[])
208 {
209 	extern char kernel_text[], edata[], end[];
210 	vaddr_t kernstart, kernend;
211 	paddr_t kernstartpfn, kernendpfn, pfn0, pfn1;
212 	vsize_t size;
213 	const char *cp;
214 	char *cp0;
215 	size_t i;
216 
217 	/* Disable interrupts. */
218 	(void) splhigh();
219 
220 	/*
221 	 * First, find the start and end of the kernel and clear
222 	 * the BSS segment.  Account for a bit of space for the
223 	 * bootstrap stack.
224 	 */
225 	led_display('b', 's', 's', ' ');
226 	kernstart = (vaddr_t) mips_trunc_page(kernel_text) - 2 * NBPG;
227 	kernend   = (vaddr_t) mips_round_page(end);
228 	memset(edata, 0, kernend - (vaddr_t)edata);
229 
230 	/*
231 	 * Initialize PAGE_SIZE-dependent variables.
232 	 */
233 	led_display('p', 'g', 's', 'z');
234 	uvm_setpagesize();
235 
236 	kernstartpfn = atop(MIPS_KSEG0_TO_PHYS(kernstart));
237 	kernendpfn   = atop(MIPS_KSEG0_TO_PHYS(kernend));
238 
239 	/*
240 	 * Initialize bus space tags and bring up the console.
241 	 */
242 #if defined(ALGOR_P4032)
243 	    {
244 		struct p4032_config *acp = &p4032_configuration;
245 		struct vtpbc_config *vt = &vtpbc_configuration;
246 		bus_space_handle_t sh;
247 
248 		strcpy(cpu_model, "Algorithmics P-4032");
249 
250 		vt->vt_addr = MIPS_PHYS_TO_KSEG1(P4032_V962PBC);
251 		vt->vt_cfgbase = MIPS_PHYS_TO_KSEG1(P4032_PCICFG);
252 		vt->vt_adbase = 11;
253 
254 		led_display('v', '9', '6', '2');
255 		vtpbc_init(&acp->ac_pc, vt);
256 
257 		led_display('l', 'i', 'o', ' ');
258 		algor_p4032loc_bus_io_init(&acp->ac_lociot, acp);
259 
260 		led_display('i', 'o', ' ', ' ');
261 		algor_p4032_bus_io_init(&acp->ac_iot, acp);
262 
263 		led_display('m', 'e', 'm', ' ');
264 		algor_p4032_bus_mem_init(&acp->ac_memt, acp);
265 
266 		led_display('d', 'm', 'a', ' ');
267 		algor_p4032_dma_init(acp);
268 #if NCOM > 0
269 		/*
270 		 * Delay to allow firmware putchars to complete.
271 		 * FIFO depth * character time.
272 		 * character time = (1000000 / (defaultrate / 10))
273 		 */
274 		led_display('c', 'o', 'n', 's');
275 		DELAY(160000000 / comcnrate);
276 		if (comcnattach(&acp->ac_lociot, P4032_COM1, comcnrate,
277 		    COM_FREQ, COM_TYPE_NORMAL,
278 		    (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8) != 0)
279 			panic("p4032: unable to initialize serial console");
280 #else
281 		panic("p4032: not configured to use serial console");
282 #endif /* NCOM > 0 */
283 
284 		led_display('h', 'z', ' ', ' ');
285 		bus_space_map(&acp->ac_lociot, P4032_RTC, 2, 0, &sh);
286 		algor_p4032_cal_timer(&acp->ac_lociot, sh);
287 		bus_space_unmap(&acp->ac_lociot, sh, 2);
288 	    }
289 #elif defined(ALGOR_P5064)
290 	    {
291 		struct p5064_config *acp = &p5064_configuration;
292 		struct vtpbc_config *vt = &vtpbc_configuration;
293 		bus_space_handle_t sh;
294 
295 		strcpy(cpu_model, "Algorithmics P-5064");
296 
297 		vt->vt_addr = MIPS_PHYS_TO_KSEG1(P5064_V360EPC);
298 		vt->vt_cfgbase = MIPS_PHYS_TO_KSEG1(P5064_PCICFG);
299 		vt->vt_adbase = 24;
300 
301 		led_display('v', '3', '6', '0');
302 		vtpbc_init(&acp->ac_pc, vt);
303 
304 		led_display('i', 'o', ' ', ' ');
305 		algor_p5064_bus_io_init(&acp->ac_iot, acp);
306 
307 		led_display('m', 'e', 'm', ' ');
308 		algor_p5064_bus_mem_init(&acp->ac_memt, acp);
309 
310 		led_display('d', 'm', 'a', ' ');
311 		algor_p5064_dma_init(acp);
312 #if NCOM > 0
313 		/*
314 		 * Delay to allow firmware putchars to complete.
315 		 * FIFO depth * character time.
316 		 * character time = (1000000 / (defaultrate / 10))
317 		 */
318 		led_display('c', 'o', 'n', 's');
319 		DELAY(160000000 / comcnrate);
320 		if (comcnattach(&acp->ac_iot, 0x3f8, comcnrate,
321 		    COM_FREQ, COM_TYPE_NORMAL,
322 		    (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8) != 0)
323 			panic("p5064: unable to initialize serial console");
324 #else
325 		panic("p5064: not configured to use serial console");
326 #endif /* NCOM > 0 */
327 
328 		led_display('h', 'z', ' ', ' ');
329 		bus_space_map(&acp->ac_iot, 0x70, 2, 0, &sh);
330 		algor_p5064_cal_timer(&acp->ac_iot, sh);
331 		bus_space_unmap(&acp->ac_iot, sh, 2);
332 	    }
333 #elif defined(ALGOR_P6032)
334 	    {
335 		struct p6032_config *acp = &p6032_configuration;
336 		struct bonito_config *bc = &acp->ac_bonito;
337 		bus_space_handle_t sh;
338 
339 		strcpy(cpu_model, "Algorithmics P-6032");
340 
341 		bc->bc_adbase = 11;
342 
343 		led_display('b','n','t','o');
344 		bonito_pci_init(&acp->ac_pc, bc);
345 
346 		led_display('i','o',' ',' ');
347 		algor_p6032_bus_io_init(&acp->ac_iot, acp);
348 
349 		led_display('m','e','m',' ');
350 		algor_p6032_bus_mem_init(&acp->ac_memt, acp);
351 
352 		led_display('d','m','a',' ');
353 		algor_p6032_dma_init(acp);
354 #if NCOM > 0
355 		/*
356 		 * Delay to allow firmware putchars to complete.
357 		 * FIFO depth * character time.
358 		 * character time = (1000000 / (defaultrate / 10))
359 		 */
360 		led_display('c','o','n','s');
361 		DELAY(160000000 / comcnrate);
362 		if (comcnattach(&acp->ac_iot, 0x3f8, comcnrate,
363 		    COM_FREQ, COM_TYPE_NORMAL,
364 		    (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8) != 0)
365 			panic("p6032: unable to initialize serial console");
366 #else
367 		panic("p6032: not configured to use serial console");
368 #endif /* NCOM > 0 */
369 
370 		led_display('h','z',' ',' ');
371 		bus_space_map(&acp->ac_iot, 0x70, 2, 0, &sh);
372 		algor_p6032_cal_timer(&acp->ac_iot, sh);
373 		bus_space_unmap(&acp->ac_iot, sh, 2);
374 	    }
375 #endif /* ALGOR_P4032 || ALGOR_P5064 || ALGOR_P6032 */
376 
377 	/*
378 	 * The Algorithmics boards have PMON firmware; set up our
379 	 * PMON state.
380 	 */
381 	led_display('p', 'm', 'o', 'n');
382 	pmon_init(envp);
383 
384 	/*
385 	 * Get the Ethernet address of the on-board Ethernet.
386 	 */
387 #if defined(ETHADDR)
388 	cp = ETHADDR;
389 #else
390 	cp = pmon_getenv("ethaddr");
391 #endif
392 	if (cp != NULL) {
393 		for (i = 0; i < ETHER_ADDR_LEN; i++) {
394 			algor_ethaddr[i] = strtoul(cp, &cp0, 16);
395 			cp = cp0 + 1;
396 		}
397 	}
398 
399 	/*
400 	 * Get the boot options.
401 	 */
402 	led_display('b', 'o', 'p', 't');
403 	boothowto = 0;
404 	if (argc > 1) {
405 #ifdef _LP64
406 		cp = (void *)(intptr_t)((int32_t *)argv)[1];
407 #else
408 		cp = argv[1];
409 #endif
410 		for (; cp != NULL && *cp != '\0'; cp++) {
411 			switch (*cp) {
412 #if defined(KGDB) || defined(DDB)
413 			case 'd':	/* break into kernel debugger */
414 				boothowto |= RB_KDB;
415 				break;
416 #endif
417 
418 			case 'h':	/* always halt, never reboot */
419 				boothowto |= RB_HALT;
420 				break;
421 
422 			case 'n':	/* askname */
423 				boothowto |= RB_ASKNAME;
424 				break;
425 
426 			case 's':	/* single-user mode */
427 				boothowto |= RB_SINGLE;
428 				break;
429 
430 			case 'q':	/* quiet boot */
431 				boothowto |= AB_QUIET;
432 				break;
433 
434 			case 'v':	/* verbose boot */
435 				boothowto |= AB_VERBOSE;
436 				break;
437 
438 			case '-':
439 				/*
440 				 * Just ignore this.  It's not required,
441 				 * but it's common for it to be passed
442 				 * regardless.
443 				 */
444 				break;
445 
446 			default:
447 				printf("Unrecognized boto flag '%c'.\n", *cp);
448 				break;
449 			}
450 		}
451 	}
452 
453 	/*
454 	 * Determine the memory size.  Use the `memsize' PMON
455 	 * variable.  If that's not available, panic.
456 	 *
457 	 * Note: Reserve the first page!  That's where the trap
458 	 * vectors are located.
459 	 */
460 #if defined(MEMSIZE)
461 	size = MEMSIZE;
462 #else
463 	if ((cp = pmon_getenv("memsize")) != NULL)
464 		size = strtoul(cp, NULL, 0);
465 	else {
466 		printf("FATAL: `memsize' PMON variable not set.  Set it to\n");
467 		printf("       the amount of memory (in MB) and try again.\n");
468 		printf("       Or, build a kernel with the `MEMSIZE' "
469 		    "option.\n");
470 		panic("algor_init");
471 	}
472 #endif /* MEMSIZE */
473 	/*
474 	 * Deal with 2 different conventions of the contents
475 	 * of the memsize variable -- if it's > 1024, assume
476 	 * it's already in bytes, not megabytes.
477 	 */
478 	if (size < 1024) {
479 		printf("Memory size: %#"PRIxVSIZE" (%"PRIxVSIZE")\n",
480 		    size * 1024 * 1024, size);
481 		size *= 1024 * 1024;
482 	} else
483 		printf("Memory size: %#"PRIxVSIZE"\n", size);
484 
485 	mem_clusters[mem_cluster_cnt].start = PAGE_SIZE;
486 	mem_clusters[mem_cluster_cnt].size =
487 	    size - mem_clusters[mem_cluster_cnt].start;
488 	mem_cluster_cnt++;
489 
490 	/*
491 	 * Copy the exception-dispatch code down to the exception vector.
492 	 * Initialize the locore function vector.  Clear out the I- and
493 	 * D-caches.
494 	 *
495 	 * We can no longer call into PMON after this.
496 	 */
497 	led_display('v', 'e', 'c', 'i');
498 	mips_vector_init();
499 
500 	/*
501 	 * Load the physical memory clusters into the VM system.
502 	 */
503 	led_display('v', 'm', 'p', 'g');
504 	for (i = 0; i < mem_cluster_cnt; i++) {
505 		physmem += atop(mem_clusters[i].size);
506 		pfn0 = atop(mem_clusters[i].start);
507 		pfn1 = pfn0 + atop(mem_clusters[i].size);
508 		if (pfn0 <= kernstartpfn && kernendpfn <= pfn1) {
509 			/*
510 			 * Must compute the location of the kernel
511 			 * within the segment.
512 			 */
513 #if 1
514 			printf("Cluster %zu contains kernel\n", i);
515 #endif
516 			if (pfn0 < kernstartpfn) {
517 				/*
518 				 * There is a chunk before the kernel.
519 				 */
520 #if 1
521 				printf("Loading chunk before kernel: "
522 				    "%#"PRIxPADDR" / %#"PRIxPADDR"\n",
523 				    pfn0, kernstartpfn);
524 #endif
525 				uvm_page_physload(pfn0, kernstartpfn,
526 				    pfn0, kernstartpfn, VM_FREELIST_DEFAULT);
527 			}
528 			if (kernendpfn < pfn1) {
529 				/*
530 				 * There is a chunk after the kernel.
531 				 */
532 #if 1
533 				printf("Loading chunk after kernel: "
534 				    "%#"PRIxPADDR" / %#"PRIxPADDR"\n",
535 				    kernendpfn, pfn1);
536 #endif
537 				uvm_page_physload(kernendpfn, pfn1,
538 				    kernendpfn, pfn1, VM_FREELIST_DEFAULT);
539 			}
540 		} else {
541 			/*
542 			 * Just load this cluster as one chunk.
543 			 */
544 #if 1
545 			printf("Loading cluster %zu: %#"PRIxPADDR
546 			    " / %#"PRIxPADDR"\n", i, pfn0, pfn1);
547 #endif
548 			uvm_page_physload(pfn0, pfn1, pfn0, pfn1,
549 			    VM_FREELIST_DEFAULT);
550 		}
551 	}
552 
553 	if (physmem == 0)
554 		panic("can't happen: system seems to have no memory!");
555 	maxmem = physmem;
556 
557 	/*
558 	 * Initialize message buffer (at end of core).
559 	 */
560 	mips_init_msgbuf();
561 
562 	/*
563 	 * Initialize the virtual memory system.
564 	 */
565 	led_display('p', 'm', 'a', 'p');
566 	pmap_bootstrap();
567 
568 	/*
569 	 * Allocate uarea page for lwp0 and set it.
570 	 */
571 	led_display('u', 's', 'p', 'c');
572 	mips_init_lwp0_uarea();
573 
574 	/*
575 	 * Initialize debuggers, and break into them, if appropriate.
576 	 */
577 	if (boothowto & RB_KDB) {
578 #if defined(DDB)
579 		Debugger();
580 #endif
581 	}
582 }
583 
584 void
585 consinit(void)
586 {
587 
588 	/*
589 	 * Everything related to console initialization is done
590 	 * in mach_init().
591 	 */
592 	led_display('N', 'B', 'S', 'D');
593 }
594 
595 void
596 cpu_startup(void)
597 {
598 	vaddr_t minaddr, maxaddr;
599 	char pbuf[9];
600 #ifdef DEBUG
601 	extern int pmapdebug;
602 	int opmapdebug = pmapdebug;
603 
604 	pmapdebug = 0;		/* Shut up pmap debug during bootstrap */
605 #endif
606 
607 	/*
608 	 * Good {morning,afternoon,evening,night}.
609 	 */
610 	printf("%s%s", copyright, version);
611 	printf("%s\n", cpu_model);
612 	format_bytes(pbuf, sizeof(pbuf), ptoa(physmem));
613 	printf("total memory = %s\n", pbuf);
614 
615 	/*
616 	 * Virtual memory is bootstrapped -- notify the bus spaces
617 	 * that memory allocation is now safe.
618 	 */
619 #if defined(ALGOR_P4032)
620 	    {
621 		struct p4032_config *acp = &p4032_configuration;
622 
623 		acp->ac_mallocsafe = 1;
624 	    }
625 #elif defined(ALGOR_P5064)
626 	    {
627 		struct p5064_config *acp = &p5064_configuration;
628 
629 		acp->ac_mallocsafe = 1;
630 	    }
631 #elif defined(ALGOR_P6032)
632 	    {
633 		struct p6032_config *acp = &p6032_configuration;
634 
635 		acp->ac_mallocsafe = 1;
636 	    }
637 #endif
638 
639 	minaddr = 0;
640 
641 	/*
642 	 * Allocate a submap for physio.
643 	 */
644 	phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
645 	    VM_PHYS_SIZE, 0, false, NULL);
646 
647 	/*
648 	 * No need to allocate an mbuf cluster submap.  Mbuf clusters
649 	 * are allocate via the pool allocator, and we use KSEG0 to
650 	 * map those pages.
651 	 */
652 
653 #ifdef DEBUG
654 	pmapdebug = opmapdebug;
655 #endif
656 	format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
657 	printf("avail memory = %s\n", pbuf);
658 }
659 
660 int	waittime = -1;
661 struct pcb dumppcb;
662 
663 void
664 cpu_reboot(int howto, char *bootstr)
665 {
666 	int tmp;
667 
668 	/* Take a snapshot before clobbering any registers. */
669 	if (curlwp)
670 		savectx(curpcb);
671 
672 	/* If "always halt" was specified as a boot flag, obey. */
673 	if (boothowto & RB_HALT)
674 		howto |= RB_HALT;
675 
676 	boothowto = howto;
677 
678 	/* If system is cold, just halt. */
679 	if (cold) {
680 		boothowto |= RB_HALT;
681 		goto haltsys;
682 	}
683 
684 	if ((boothowto & RB_NOSYNC) == 0 && waittime < 0) {
685 		waittime = 0;
686 		vfs_shutdown();
687 		/*
688 		 * If we've been adjusting the clock, the todr
689 		 * will be out of synch; adjust it now.
690 		 */
691 		resettodr();
692 	}
693 
694 	/* Disable interrupts. */
695 	(void) splhigh();
696 
697 	if (boothowto & RB_DUMP)
698 		dumpsys();
699 
700  haltsys:
701 	/* Run any shutdown hooks. */
702 	doshutdownhooks();
703 
704 	pmf_system_shutdown(boothowto);
705 
706 	if (boothowto & RB_HALT) {
707 		printf("\n");
708 		printf("The operating system has halted.\n");
709 		printf("Please press any key to return to the monitor.\n\n");
710 		led_display('h','a','l','t');
711 		cnpollc(1);
712 		(void) cngetc();
713 		cnpollc(0);
714 	}
715 
716 	printf("Returning to the monitor...\n\n");
717 	led_display('r', 'v', 'e', 'c');
718 	/* Jump to the reset vector. */
719 	__asm volatile("li %0, 0xbfc00000; jr %0; nop"
720 		: "=r" (tmp)
721 		: /* no inputs */
722 		: "memory");
723 	led_display('R', 'S', 'T', 'F');
724 	for (;;)
725 		/* spin forever */ ;
726 }
727