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