Home | History | Annotate | Line # | Download | only in walnut
machdep.c revision 1.8
      1 /*	$NetBSD: machdep.c,v 1.8 2003/04/02 03:52:58 thorpej Exp $	*/
      2 
      3 /*
      4  * Copyright 2001, 2002 Wasabi Systems, Inc.
      5  * All rights reserved.
      6  *
      7  * Written by Eduardo Horvath and Simon Burge for Wasabi Systems, Inc.
      8  *
      9  * Redistribution and use in source and binary forms, with or without
     10  * modification, are permitted provided that the following conditions
     11  * are met:
     12  * 1. Redistributions of source code must retain the above copyright
     13  *    notice, this list of conditions and the following disclaimer.
     14  * 2. Redistributions in binary form must reproduce the above copyright
     15  *    notice, this list of conditions and the following disclaimer in the
     16  *    documentation and/or other materials provided with the distribution.
     17  * 3. All advertising materials mentioning features or use of this software
     18  *    must display the following acknowledgement:
     19  *      This product includes software developed for the NetBSD Project by
     20  *      Wasabi Systems, Inc.
     21  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
     22  *    or promote products derived from this software without specific prior
     23  *    written permission.
     24  *
     25  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
     26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     27  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     28  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
     29  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     31  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     32  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     33  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     34  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     35  * POSSIBILITY OF SUCH DAMAGE.
     36  */
     37 
     38 /*
     39  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
     40  * Copyright (C) 1995, 1996 TooLs GmbH.
     41  * All rights reserved.
     42  *
     43  * Redistribution and use in source and binary forms, with or without
     44  * modification, are permitted provided that the following conditions
     45  * are met:
     46  * 1. Redistributions of source code must retain the above copyright
     47  *    notice, this list of conditions and the following disclaimer.
     48  * 2. Redistributions in binary form must reproduce the above copyright
     49  *    notice, this list of conditions and the following disclaimer in the
     50  *    documentation and/or other materials provided with the distribution.
     51  * 3. All advertising materials mentioning features or use of this software
     52  *    must display the following acknowledgement:
     53  *	This product includes software developed by TooLs GmbH.
     54  * 4. The name of TooLs GmbH may not be used to endorse or promote products
     55  *    derived from this software without specific prior written permission.
     56  *
     57  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
     58  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     59  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     60  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     61  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     62  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     63  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     64  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     65  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
     66  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     67  */
     68 
     69 #include "opt_compat_netbsd.h"
     70 #include "opt_ddb.h"
     71 #include "opt_ipkdb.h"
     72 
     73 #include <sys/param.h>
     74 #include <sys/buf.h>
     75 #include <sys/exec.h>
     76 #include <sys/malloc.h>
     77 #include <sys/mbuf.h>
     78 #include <sys/mount.h>
     79 #include <sys/msgbuf.h>
     80 #include <sys/proc.h>
     81 #include <sys/reboot.h>
     82 #include <sys/sa.h>
     83 #include <sys/syscallargs.h>
     84 #include <sys/syslog.h>
     85 #include <sys/systm.h>
     86 #include <sys/kernel.h>
     87 #include <sys/user.h>
     88 #include <sys/boot_flag.h>
     89 #include <sys/properties.h>
     90 
     91 #include <uvm/uvm_extern.h>
     92 
     93 #include <net/netisr.h>
     94 
     95 #include <machine/bus.h>
     96 #include <machine/powerpc.h>
     97 #include <machine/trap.h>
     98 #include <machine/walnut.h>
     99 
    100 #include <powerpc/spr.h>
    101 #include <powerpc/ibm4xx/dcr405gp.h>
    102 #include <machine/bus.h>
    103 
    104 #include <dev/cons.h>
    105 
    106 #ifdef DDB
    107 #include <machine/db_machdep.h>
    108 #include <ddb/db_extern.h>
    109 #endif
    110 
    111 #include "com.h"
    112 #if NCOM > 0
    113 #include <dev/ic/comreg.h>	/* For COM_FREQ */
    114 #endif
    115 
    116 /*
    117  * Global variables used here and there
    118  */
    119 struct vm_map *exec_map = NULL;
    120 struct vm_map *mb_map = NULL;
    121 struct vm_map *phys_map = NULL;
    122 
    123 /*
    124  * This should probably be in autoconf!				XXX
    125  */
    126 char cpu_model[80];
    127 char machine[] = MACHINE;		/* from <machine/param.h> */
    128 char machine_arch[] = MACHINE_ARCH;	/* from <machine/param.h> */
    129 
    130 extern struct user *proc0paddr;
    131 
    132 char bootpath[256];
    133 paddr_t msgbuf_paddr;
    134 vaddr_t msgbuf_vaddr;
    135 
    136 #ifdef DDB
    137 void *startsym, *endsym;
    138 #endif
    139 
    140 int lcsplx(int);
    141 void initppc(u_int, u_int, char *, void *);
    142 
    143 static void dumpsys(void);
    144 static void install_extint(void (*)(void));
    145 
    146 #define MEMREGIONS	8
    147 struct mem_region physmemr[MEMREGIONS];		/* Hard code memory */
    148 struct mem_region availmemr[MEMREGIONS];	/* Who's supposed to set these up? */
    149 
    150 struct board_cfg_data board_data;
    151 struct propdb *board_info = NULL;
    152 
    153 void
    154 initppc(u_int startkernel, u_int endkernel, char *args, void *info_block)
    155 {
    156 	extern int defaulttrap, defaultsize;
    157 	extern int sctrap, scsize;
    158 	extern int alitrap, alisize;
    159 	extern int dsitrap, dsisize;
    160 	extern int isitrap, isisize;
    161 	extern int mchktrap, mchksize;
    162 	extern int tlbimiss4xx, tlbim4size;
    163 	extern int tlbdmiss4xx, tlbdm4size;
    164 	extern int pitfitwdog, pitfitwdogsize;
    165 	extern int debugtrap, debugsize;
    166 	extern int errata51handler, errata51size;
    167 #ifdef DDB
    168 	extern int ddblow, ddbsize;
    169 #endif
    170 #ifdef IPKDB
    171 	extern int ipkdblow, ipkdbsize;
    172 #endif
    173 	int exc;
    174 	struct cpu_info * const ci = curcpu();
    175 
    176 	/* Disable all external interrupts */
    177 	mtdcr(DCR_UIC0_ER, 0);
    178 
    179         /* Initialize cache info for memcpy, etc. */
    180         cpu_probe_cache();
    181 
    182 	/* Save info block */
    183 	if (info_block == NULL)
    184 		/* XXX why isn't r3 set correctly?!?!? */
    185 		info_block = (void *)0x8e10;
    186 	memcpy(&board_data, info_block, sizeof(board_data));
    187 
    188 	memset(physmemr, 0, sizeof physmemr);
    189 	memset(availmemr, 0, sizeof availmemr);
    190 	physmemr[0].start = 0;
    191 	physmemr[0].size = board_data.mem_size & ~PGOFSET;
    192 	/* Lower memory reserved by eval board BIOS */
    193 	availmemr[0].start = startkernel;
    194 	availmemr[0].size = board_data.mem_size - availmemr[0].start;
    195 
    196 	/*
    197 	 * Initialize lwp0 and current pcb and pmap pointers.
    198 	 */
    199 	lwp0.l_cpu = ci;
    200 	lwp0.l_addr = proc0paddr;
    201 	memset(lwp0.l_addr, 0, sizeof *lwp0.l_addr);
    202 
    203 	curpcb = &proc0paddr->u_pcb;
    204 	curpm = curpcb->pcb_pmreal = curpcb->pcb_pm = pmap_kernel();
    205 
    206 	/*
    207 	 * Set up trap vectors
    208 	 */
    209 	for (exc = EXC_RSVD; exc <= EXC_LAST; exc += 0x100)
    210 		switch (exc) {
    211 		default:
    212 			memcpy((void *)exc, &defaulttrap, (size_t)&defaultsize);
    213 			break;
    214 		case EXC_EXI:
    215 			/*
    216 			 * This one is (potentially) installed during autoconf
    217 			 */
    218 			break;
    219 		case EXC_SC:
    220 			memcpy((void *)EXC_SC, &sctrap, (size_t)&scsize);
    221 			break;
    222 		case EXC_ALI:
    223 			memcpy((void *)EXC_ALI, &alitrap, (size_t)&alisize);
    224 			break;
    225 		case EXC_DSI:
    226 			memcpy((void *)EXC_DSI, &dsitrap, (size_t)&dsisize);
    227 			break;
    228 		case EXC_ISI:
    229 			memcpy((void *)EXC_ISI, &isitrap, (size_t)&isisize);
    230 			break;
    231 		case EXC_MCHK:
    232 			memcpy((void *)EXC_MCHK, &mchktrap, (size_t)&mchksize);
    233 			break;
    234 		case EXC_ITMISS:
    235 			memcpy((void *)EXC_ITMISS, &tlbimiss4xx,
    236 				(size_t)&tlbim4size);
    237 			break;
    238 		case EXC_DTMISS:
    239 			memcpy((void *)EXC_DTMISS, &tlbdmiss4xx,
    240 				(size_t)&tlbdm4size);
    241 			break;
    242 		/*
    243 		 * EXC_PIT, EXC_FIT, EXC_WDOG handlers
    244 		 * are spaced by 0x10 bytes only..
    245 		 */
    246 		case EXC_PIT:
    247 			memcpy((void *)EXC_PIT, &pitfitwdog,
    248 				(size_t)&pitfitwdogsize);
    249 			break;
    250 		case EXC_DEBUG:
    251 			memcpy((void *)EXC_DEBUG, &debugtrap,
    252 				(size_t)&debugsize);
    253 			break;
    254 		case EXC_DTMISS|EXC_ALI:
    255                         /* PPC405GP Rev D errata item 51 */
    256 			memcpy((void *)(EXC_DTMISS|EXC_ALI), &errata51handler,
    257 				(size_t)&errata51size);
    258 			break;
    259 #if defined(DDB) || defined(IPKDB)
    260 		case EXC_PGM:
    261 #if defined(DDB)
    262 			memcpy((void *)exc, &ddblow, (size_t)&ddbsize);
    263 #elif defined(IPKDB)
    264 			memcpy((void *)exc, &ipkdblow, (size_t)&ipkdbsize);
    265 #endif
    266 #endif /* DDB | IPKDB */
    267 			break;
    268 		}
    269 
    270 	__syncicache((void *)EXC_RST, EXC_LAST - EXC_RST + 0x100);
    271 	mtspr(SPR_EVPR, 0);		/* Set Exception vector base */
    272 	consinit();
    273 
    274 	/* Handle trap instruction as PGM exception */
    275 	{
    276 	  int dbcr0;
    277 	  asm volatile("mfspr %0,%1":"=r"(dbcr0):"K"(SPR_DBCR0));
    278 	  asm volatile("mtspr %0,%1"::"K"(SPR_DBCR0),"r"(dbcr0 & ~DBCR0_TDE));
    279 	}
    280 
    281 	/*
    282 	 * external interrupt handler install
    283 	 */
    284 	install_extint(ext_intr);
    285 
    286 	/*
    287 	 * Now enable translation (and machine checks/recoverable interrupts).
    288 	 */
    289 	asm volatile ("mfmsr %0; ori %0,%0,%1; mtmsr %0; isync"
    290 		      : : "r"(0), "K"(PSL_IR|PSL_DR));
    291 	/* XXXX PSL_ME - With ME set kernel gets stuck... */
    292 
    293 	uvm_setpagesize();
    294 
    295 	/*
    296 	 * Initialize pmap module.
    297 	 */
    298 	pmap_bootstrap(startkernel, endkernel);
    299 
    300 	consinit();
    301 
    302 #ifdef DEBUG
    303 	printf("Board config data:\n");
    304 	printf("  usr_config_ver = %s\n", board_data.usr_config_ver);
    305 	printf("  rom_sw_ver = %s\n", board_data.rom_sw_ver);
    306 	printf("  mem_size = %u\n", board_data.mem_size);
    307 	printf("  mac_address_local = %02x:%02x:%02x:%02x:%02x:%02x\n",
    308 	    board_data.mac_address_local[0], board_data.mac_address_local[1],
    309 	    board_data.mac_address_local[2], board_data.mac_address_local[3],
    310 	    board_data.mac_address_local[4], board_data.mac_address_local[5]);
    311 	printf("  mac_address_pci = %02x:%02x:%02x:%02x:%02x:%02x\n",
    312 	    board_data.mac_address_pci[0], board_data.mac_address_pci[1],
    313 	    board_data.mac_address_pci[2], board_data.mac_address_pci[3],
    314 	    board_data.mac_address_pci[4], board_data.mac_address_pci[5]);
    315 	printf("  processor_speed = %u\n", board_data.processor_speed);
    316 	printf("  plb_speed = %u\n", board_data.plb_speed);
    317 	printf("  pci_speed = %u\n", board_data.pci_speed);
    318 #endif
    319 
    320 #ifdef DDB
    321 	ddb_init((int)((u_int)endsym - (u_int)startsym), startsym, endsym);
    322 	if (boothowto & RB_KDB)
    323 		Debugger();
    324 #endif
    325 #ifdef IPKDB
    326 	/*
    327 	 * Now trap to IPKDB
    328 	 */
    329 	ipkdb_init();
    330 	if (boothowto & RB_KDB)
    331 		ipkdb_connect(0);
    332 #endif
    333 	fake_mapiodev = 0;
    334 }
    335 
    336 static void
    337 install_extint(void (*handler)(void))
    338 {
    339 	extern int extint, extsize;
    340 	extern u_long extint_call;
    341 	u_long offset = (u_long)handler - (u_long)&extint_call;
    342 	int omsr, msr;
    343 
    344 #ifdef	DIAGNOSTIC
    345 	if (offset > 0x1ffffff)
    346 		panic("install_extint: too far away");
    347 #endif
    348 	asm volatile ("mfmsr %0; andi. %1,%0,%2; mtmsr %1"
    349 		      : "=r"(omsr), "=r"(msr) : "K"((u_short)~PSL_EE));
    350 	extint_call = (extint_call & 0xfc000003) | offset;
    351 	memcpy((void *)EXC_EXI, &extint, (size_t)&extsize);
    352 	__syncicache((void *)&extint_call, sizeof extint_call);
    353 	__syncicache((void *)EXC_EXI, (int)&extsize);
    354 	asm volatile ("mtmsr %0" :: "r"(omsr));
    355 }
    356 
    357 /*
    358  * Machine dependent startup code.
    359  */
    360 
    361 char msgbuf[MSGBUFSIZE];
    362 
    363 void
    364 cpu_startup(void)
    365 {
    366 	caddr_t v;
    367 	vaddr_t minaddr, maxaddr;
    368 	u_int sz, i, base, residual;
    369 	char pbuf[9];
    370 
    371 	/*
    372 	 * Initialize error message buffer (at end of core).
    373 	 */
    374 #if 0	/* For some reason this fails... --Artem
    375 	 * Besides, do we really have to put it at the end of core?
    376 	 * Let's use static buffer for now
    377 	 */
    378 	if (!(msgbuf_vaddr = uvm_km_alloc(kernel_map, round_page(MSGBUFSIZE))))
    379 		panic("startup: no room for message buffer");
    380 	for (i = 0; i < btoc(MSGBUFSIZE); i++)
    381 		pmap_kenter_pa(msgbuf_vaddr + i * PAGE_SIZE,
    382 		    msgbuf_paddr + i * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE);
    383 	initmsgbuf((caddr_t)msgbuf_vaddr, round_page(MSGBUFSIZE));
    384 #else
    385 	initmsgbuf((caddr_t)msgbuf, round_page(MSGBUFSIZE));
    386 #endif
    387 
    388 
    389 	printf("%s", version);
    390 	printf("Walnut PowerPC 405GP Evaluation Board\n");
    391 
    392 	format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
    393 	printf("total memory = %s\n", pbuf);
    394 
    395 	/*
    396 	 * Find out how much space we need, allocate it,
    397 	 * and then give everything true virtual addresses.
    398 	 */
    399 	sz = (u_int)allocsys(NULL, NULL);
    400 	if ((v = (caddr_t)uvm_km_zalloc(kernel_map, round_page(sz))) == 0)
    401 		panic("startup: no room for tables");
    402 	if (allocsys(v, NULL) - v != sz)
    403 		panic("startup: table size inconsistency");
    404 
    405 	/*
    406 	 * Now allocate buffers proper.  They are different than the above
    407 	 * in that they usually occupy more virtual memory than physical.
    408 	 */
    409 	sz = MAXBSIZE * nbuf;
    410 	minaddr = 0;
    411 	if (uvm_map(kernel_map, (vaddr_t *)&minaddr, round_page(sz),
    412 		NULL, UVM_UNKNOWN_OFFSET, 0,
    413 		UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
    414 			    UVM_ADV_NORMAL, 0)) != 0)
    415 		panic("startup: cannot allocate VM for buffers");
    416 	buffers = (char *)minaddr;
    417 	base = bufpages / nbuf;
    418 	residual = bufpages % nbuf;
    419 	if (base >= MAXBSIZE) {
    420 		/* Don't want to alloc more physical mem than ever needed */
    421 		base = MAXBSIZE;
    422 		residual = 0;
    423 	}
    424 	for (i = 0; i < nbuf; i++) {
    425 		vsize_t curbufsize;
    426 		vaddr_t curbuf;
    427 		struct vm_page *pg;
    428 
    429 		curbuf = (vaddr_t)buffers + i * MAXBSIZE;
    430 		curbufsize = PAGE_SIZE * (i < residual ? base + 1 : base);
    431 
    432 		while (curbufsize) {
    433 			pg = uvm_pagealloc(NULL, 0, NULL, 0);
    434 			if (pg == NULL)
    435 				panic("cpu_startup: not enough memory for "
    436 				    "buffer cache");
    437 			pmap_kenter_pa(curbuf, VM_PAGE_TO_PHYS(pg),
    438 			    VM_PROT_READ | VM_PROT_WRITE);
    439 			curbuf += PAGE_SIZE;
    440 			curbufsize -= PAGE_SIZE;
    441 		}
    442 	}
    443 
    444 	/*
    445 	 * Allocate a submap for exec arguments.  This map effectively
    446 	 * limits the number of processes exec'ing at any time.
    447 	 */
    448 	exec_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
    449 				 16*NCARGS, VM_MAP_PAGEABLE, FALSE, NULL);
    450 
    451 	/*
    452 	 * Allocate a submap for physio
    453 	 */
    454 	phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
    455 				 VM_PHYS_SIZE, 0, FALSE, NULL);
    456 
    457 	/*
    458 	 * No need to allocate an mbuf cluster submap.  Mbuf clusters
    459 	 * are allocated via the pool allocator, and we use direct-mapped
    460 	 * pool pages.
    461 	 */
    462 
    463 	format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
    464 	printf("avail memory = %s\n", pbuf);
    465 	format_bytes(pbuf, sizeof(pbuf), bufpages * PAGE_SIZE);
    466 	printf("using %u buffers containing %s of memory\n", nbuf, pbuf);
    467 
    468 	/*
    469 	 * Set up the buffers.
    470 	 */
    471 	bufinit();
    472 
    473 	/*
    474 	 * Set up the board properties database.
    475 	 */
    476 	if (!(board_info = propdb_create("board info")))
    477 		panic("Cannot create board info database");
    478 
    479 	if (board_info_set("mem-size", &board_data.mem_size,
    480 		sizeof(&board_data.mem_size), PROP_CONST, 0))
    481 		panic("setting mem-size");
    482 	if (board_info_set("emac-mac-addr", &board_data.mac_address_local,
    483 		sizeof(&board_data.mac_address_local), PROP_CONST, 0))
    484 		panic("setting emac-mac-addr");
    485 	if (board_info_set("sip0-mac-addr", &board_data.mac_address_pci,
    486 		sizeof(&board_data.mac_address_pci), PROP_CONST, 0))
    487 		panic("setting sip0-mac-addr");
    488 	if (board_info_set("processor-frequency", &board_data.processor_speed,
    489 		sizeof(&board_data.processor_speed), PROP_CONST, 0))
    490 		panic("setting processor-frequency");
    491 #if NCOM > 0
    492 	{
    493 		unsigned int comfreq = COM_FREQ * 6;
    494 		if (board_info_set("com-opb-frequency", &comfreq,
    495 			sizeof(&comfreq), 0, 0))
    496 			panic("setting com-opb-frequency");
    497 	}
    498 #endif
    499 }
    500 
    501 
    502 static void
    503 dumpsys(void)
    504 {
    505 
    506 	printf("dumpsys: TBD\n");
    507 }
    508 
    509 /*
    510  * Soft networking interrupts.
    511  */
    512 void
    513 softnet(void)
    514 {
    515 	int isr;
    516 
    517 	isr = netisr;
    518 	netisr = 0;
    519 
    520 #define DONETISR(bit, fn) do {		\
    521 	if (isr & (1 << bit))		\
    522 		fn();			\
    523 } while (0)
    524 
    525 #include <net/netisr_dispatch.h>
    526 
    527 #undef DONETISR
    528 
    529 }
    530 
    531 /*
    532  * Soft tty interrupts.
    533  */
    534 void
    535 softserial(void)
    536 {
    537 #if NCOM > 0
    538 	void comsoft(void);	/* XXX from dev/ic/com.c */
    539 
    540 	comsoft();
    541 #endif
    542 }
    543 
    544 /*
    545  * Halt or reboot the machine after syncing/dumping according to howto.
    546  */
    547 void
    548 cpu_reboot(int howto, char *what)
    549 {
    550 	static int syncing;
    551 	static char str[256];
    552 	char *ap = str, *ap1 = ap;
    553 
    554 	boothowto = howto;
    555 	if (!cold && !(howto & RB_NOSYNC) && !syncing) {
    556 		syncing = 1;
    557 		vfs_shutdown();		/* sync */
    558 		resettodr();		/* set wall clock */
    559 	}
    560 
    561 	splhigh();
    562 
    563 	if (!cold && (howto & RB_DUMP))
    564 		dumpsys();
    565 
    566 	doshutdownhooks();
    567 
    568 	if ((howto & RB_POWERDOWN) == RB_POWERDOWN) {
    569 	  /* Power off here if we know how...*/
    570 	}
    571 
    572 	if (howto & RB_HALT) {
    573 		printf("halted\n\n");
    574 
    575 		goto reboot;	/* XXX for now... */
    576 
    577 #ifdef DDB
    578 		printf("dropping to debugger\n");
    579 		while(1)
    580 			Debugger();
    581 #endif
    582 	}
    583 
    584 	printf("rebooting\n\n");
    585 	if (what && *what) {
    586 		if (strlen(what) > sizeof str - 5)
    587 			printf("boot string too large, ignored\n");
    588 		else {
    589 			strcpy(str, what);
    590 			ap1 = ap = str + strlen(str);
    591 			*ap++ = ' ';
    592 		}
    593 	}
    594 	*ap++ = '-';
    595 	if (howto & RB_SINGLE)
    596 		*ap++ = 's';
    597 	if (howto & RB_KDB)
    598 		*ap++ = 'd';
    599 	*ap++ = 0;
    600 	if (ap[-2] == '-')
    601 		*ap1 = 0;
    602 
    603 	/* flush cache for msgbuf */
    604 	__syncicache((void *)msgbuf_paddr, round_page(MSGBUFSIZE));
    605 
    606  reboot:
    607 	ppc4xx_reset();
    608 
    609 	printf("ppc4xx_reset() failed!\n");
    610 #ifdef DDB
    611 	while(1)
    612 		Debugger();
    613 #else
    614 	while (1)
    615 		/* nothing */;
    616 #endif
    617 }
    618 
    619 int
    620 lcsplx(int ipl)
    621 {
    622 
    623 	return spllower(ipl); 	/* XXX */
    624 }
    625 
    626 void
    627 mem_regions(struct mem_region **mem, struct mem_region **avail)
    628 {
    629 
    630 	*mem = physmemr;
    631 	*avail = availmemr;
    632 }
    633