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