Home | History | Annotate | Line # | Download | only in ofppc
machdep.c revision 1.50
      1 /*	$NetBSD: machdep.c,v 1.50 2000/01/19 03:28:23 danw Exp $	*/
      2 
      3 /*
      4  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
      5  * Copyright (C) 1995, 1996 TooLs GmbH.
      6  * All rights reserved.
      7  *
      8  * Redistribution and use in source and binary forms, with or without
      9  * modification, are permitted provided that the following conditions
     10  * are met:
     11  * 1. Redistributions of source code must retain the above copyright
     12  *    notice, this list of conditions and the following disclaimer.
     13  * 2. Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in the
     15  *    documentation and/or other materials provided with the distribution.
     16  * 3. All advertising materials mentioning features or use of this software
     17  *    must display the following acknowledgement:
     18  *	This product includes software developed by TooLs GmbH.
     19  * 4. The name of TooLs GmbH may not be used to endorse or promote products
     20  *    derived from this software without specific prior written permission.
     21  *
     22  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
     23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     27  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     28  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     29  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     30  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
     31  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32  */
     33 
     34 #include "opt_compat_netbsd.h"
     35 #include "opt_ddb.h"
     36 #include "opt_inet.h"
     37 #include "opt_ccitt.h"
     38 #include "opt_iso.h"
     39 #include "opt_ns.h"
     40 #include "ipkdb.h"
     41 
     42 #include <sys/param.h>
     43 #include <sys/buf.h>
     44 #include <sys/callout.h>
     45 #include <sys/exec.h>
     46 #include <sys/malloc.h>
     47 #include <sys/map.h>
     48 #include <sys/mbuf.h>
     49 #include <sys/mount.h>
     50 #include <sys/msgbuf.h>
     51 #include <sys/proc.h>
     52 #include <sys/reboot.h>
     53 #include <sys/syscallargs.h>
     54 #include <sys/syslog.h>
     55 #include <sys/systm.h>
     56 #include <sys/kernel.h>
     57 #include <sys/user.h>
     58 
     59 #include <vm/vm.h>
     60 #include <vm/vm_kern.h>
     61 
     62 #include <uvm/uvm_extern.h>
     63 
     64 #include <net/netisr.h>
     65 
     66 #include <machine/bat.h>
     67 #include <machine/pmap.h>
     68 #include <machine/powerpc.h>
     69 #include <machine/trap.h>
     70 
     71 /*
     72  * Global variables used here and there
     73  */
     74 vm_map_t exec_map = NULL;
     75 vm_map_t mb_map = NULL;
     76 vm_map_t phys_map = NULL;
     77 
     78 struct pcb *curpcb;
     79 struct pmap *curpm;
     80 struct proc *fpuproc;
     81 
     82 extern struct user *proc0paddr;
     83 
     84 struct bat battable[16];
     85 
     86 int astpending;
     87 
     88 char *bootpath;
     89 
     90 paddr_t msgbuf_paddr;
     91 vaddr_t msgbuf_vaddr;
     92 
     93 static int fake_spl __P((void));
     94 static int fake_splx __P((int));
     95 static void fake_setsoft __P((void));
     96 static void fake_clock_return __P((struct clockframe *, int));
     97 static void fake_irq_establish __P((int, int, void (*)(void *), void *));
     98 
     99 struct machvec machine_interface = {
    100 	fake_spl,
    101 	fake_spl,
    102 	fake_spl,
    103 	fake_spl,
    104 	fake_spl,
    105 	fake_spl,
    106 	fake_spl,
    107 	fake_spl,
    108 	fake_spl,
    109 	fake_spl,
    110 	fake_splx,
    111 	fake_setsoft,
    112 	fake_setsoft,
    113 	fake_clock_return,
    114 	fake_irq_establish,
    115 };
    116 
    117 void
    118 initppc(startkernel, endkernel, args)
    119 	u_int startkernel, endkernel;
    120 	char *args;
    121 {
    122 	int phandle, qhandle;
    123 	char name[32];
    124 	struct machvec *mp;
    125 	extern trapcode, trapsize;
    126 	extern alitrap, alisize;
    127 	extern dsitrap, dsisize;
    128 	extern isitrap, isisize;
    129 	extern decrint, decrsize;
    130 	extern tlbimiss, tlbimsize;
    131 	extern tlbdlmiss, tlbdlmsize;
    132 	extern tlbdsmiss, tlbdsmsize;
    133 #ifdef DDB
    134 	extern ddblow, ddbsize;
    135 	extern void *startsym, *endsym;
    136 #endif
    137 #if NIPKDB > 0
    138 	extern ipkdblow, ipkdbsize;
    139 #endif
    140 	extern void consinit __P((void));
    141 	extern void callback __P((void *));
    142 	int exc, scratch;
    143 
    144 	proc0.p_addr = proc0paddr;
    145 	bzero(proc0.p_addr, sizeof *proc0.p_addr);
    146 
    147 	curpcb = &proc0paddr->u_pcb;
    148 
    149 	curpm = curpcb->pcb_pmreal = curpcb->pcb_pm = pmap_kernel();
    150 
    151 	/*
    152 	 * i386 port says, that this shouldn't be here,
    153 	 * but I really think the console should be initialized
    154 	 * as early as possible.
    155 	 */
    156 	consinit();
    157 
    158 #ifdef	__notyet__		/* Needs some rethinking regarding real/virtual OFW */
    159 	OF_set_callback(callback);
    160 #endif
    161 	/*
    162 	 * Initialize BAT registers to unmapped to not generate
    163 	 * overlapping mappings below.
    164 	 */
    165 	asm volatile ("mtibatu 0,%0" :: "r"(0));
    166 	asm volatile ("mtibatu 1,%0" :: "r"(0));
    167 	asm volatile ("mtibatu 2,%0" :: "r"(0));
    168 	asm volatile ("mtibatu 3,%0" :: "r"(0));
    169 	asm volatile ("mtdbatu 0,%0" :: "r"(0));
    170 	asm volatile ("mtdbatu 1,%0" :: "r"(0));
    171 	asm volatile ("mtdbatu 2,%0" :: "r"(0));
    172 	asm volatile ("mtdbatu 3,%0" :: "r"(0));
    173 
    174 	/*
    175 	 * Set up initial BAT table to only map the lowest 256 MB area
    176 	 */
    177 	battable[0].batl = BATL(0x00000000, BAT_M, BAT_PP_RW);
    178 	battable[0].batu = BATU(0x00000000, BAT_BL_256M, BAT_Vs);
    179 
    180 	/*
    181 	 * Now setup fixed bat registers
    182 	 *
    183 	 * Note that we still run in real mode, and the BAT
    184 	 * registers were cleared above.
    185 	 */
    186 	/* IBAT0 used for initial 256 MB segment */
    187 	asm volatile ("mtibatl 0,%0; mtibatu 0,%1"
    188 		      :: "r"(battable[0].batl), "r"(battable[0].batu));
    189 	/* DBAT0 used similar */
    190 	asm volatile ("mtdbatl 0,%0; mtdbatu 0,%1"
    191 		      :: "r"(battable[0].batl), "r"(battable[0].batu));
    192 
    193 	/*
    194 	 * Set up trap vectors
    195 	 */
    196 	for (exc = EXC_RSVD; exc <= EXC_LAST; exc += 0x100)
    197 		switch (exc) {
    198 		default:
    199 			bcopy(&trapcode, (void *)exc, (size_t)&trapsize);
    200 			break;
    201 		case EXC_EXI:
    202 			/*
    203 			 * This one is (potentially) installed during autoconf
    204 			 */
    205 			break;
    206 		case EXC_ALI:
    207 			bcopy(&alitrap, (void *)EXC_ALI, (size_t)&alisize);
    208 			break;
    209 		case EXC_DSI:
    210 			bcopy(&dsitrap, (void *)EXC_DSI, (size_t)&dsisize);
    211 			break;
    212 		case EXC_ISI:
    213 			bcopy(&isitrap, (void *)EXC_ISI, (size_t)&isisize);
    214 			break;
    215 		case EXC_DECR:
    216 			bcopy(&decrint, (void *)EXC_DECR, (size_t)&decrsize);
    217 			break;
    218 		case EXC_IMISS:
    219 			bcopy(&tlbimiss, (void *)EXC_IMISS, (size_t)&tlbimsize);
    220 			break;
    221 		case EXC_DLMISS:
    222 			bcopy(&tlbdlmiss, (void *)EXC_DLMISS, (size_t)&tlbdlmsize);
    223 			break;
    224 		case EXC_DSMISS:
    225 			bcopy(&tlbdsmiss, (void *)EXC_DSMISS, (size_t)&tlbdsmsize);
    226 			break;
    227 #if defined(DDB) || NIPKDB > 0
    228 		case EXC_PGM:
    229 		case EXC_TRC:
    230 		case EXC_BPT:
    231 #if defined(DDB)
    232 			bcopy(&ddblow, (void *)exc, (size_t)&ddbsize);
    233 #else
    234 			bcopy(&ipkdblow, (void *)exc, (size_t)&ipkdbsize);
    235 #endif
    236 			break;
    237 #endif /* DDB || NIPKDB > 0 */
    238 		}
    239 
    240 	__syncicache((void *)EXC_RST, EXC_LAST - EXC_RST + 0x100);
    241 
    242 	/*
    243 	 * Now enable translation (and machine checks/recoverable interrupts).
    244 	 */
    245 	asm volatile ("mfmsr %0; ori %0,%0,%1; mtmsr %0; isync"
    246 		      : "=r"(scratch) : "K"(PSL_IR|PSL_DR|PSL_ME|PSL_RI));
    247 
    248 	/*
    249 	 * Parse arg string.
    250 	 */
    251 	bootpath = args;
    252 	while (*++args && *args != ' ');
    253 	if (*args) {
    254 		*args++ = 0;
    255 		while (*args) {
    256 			switch (*args++) {
    257 			case 'a':
    258 				boothowto |= RB_ASKNAME;
    259 				break;
    260 			case 's':
    261 				boothowto |= RB_SINGLE;
    262 				break;
    263 			case 'd':
    264 				boothowto |= RB_KDB;
    265 				break;
    266 			}
    267 		}
    268 	}
    269 
    270 #ifdef DDB
    271 	/* ddb_init((int)(endsym - startsym), startsym, endsym); */
    272 #endif
    273 #if NIPKDB > 0
    274 	/*
    275 	 * Now trap to IPKDB
    276 	 */
    277 	ipkdb_init();
    278 	if (boothowto & RB_KDB)
    279 		ipkdb_connect(0);
    280 #endif
    281 
    282 	/*
    283 	 * Set the page size.
    284 	 */
    285 	uvm_setpagesize();
    286 
    287 	/*
    288 	 * Initialize pmap module.
    289 	 */
    290 	pmap_bootstrap(startkernel, endkernel);
    291 }
    292 
    293 /*
    294  * This should probably be in autoconf!				XXX
    295  */
    296 int cpu;
    297 char cpu_model[80];
    298 char machine[] = MACHINE;		/* from <machine/param.h> */
    299 char machine_arch[] = MACHINE_ARCH;	/* from <machine/param.h> */
    300 
    301 void
    302 identifycpu()
    303 {
    304 	int phandle, pvr;
    305 	char name[32];
    306 
    307 	/*
    308 	 * Find cpu type (Do it by OpenFirmware?)
    309 	 */
    310 	asm ("mfpvr %0" : "=r"(pvr));
    311 	cpu = pvr >> 16;
    312 	switch (cpu) {
    313 	case 1:
    314 		sprintf(cpu_model, "601");
    315 		break;
    316 	case 3:
    317 		sprintf(cpu_model, "603");
    318 		break;
    319 	case 4:
    320 		sprintf(cpu_model, "604");
    321 		break;
    322 	case 5:
    323 		sprintf(cpu_model, "602");
    324 		break;
    325 	case 6:
    326 		sprintf(cpu_model, "603e");
    327 		break;
    328 	case 7:
    329 		sprintf(cpu_model, "603ev");
    330 		break;
    331 	case 9:
    332 		sprintf(cpu_model, "604ev");
    333 		break;
    334 	case 20:
    335 		sprintf(cpu_model, "620");
    336 		break;
    337 	default:
    338 		sprintf(cpu_model, "Version %x", cpu);
    339 		break;
    340 	}
    341 	sprintf(cpu_model + strlen(cpu_model), " (Revision %x)", pvr & 0xffff);
    342 	printf("CPU: %s\n", cpu_model);
    343 }
    344 
    345 void
    346 install_extint(handler)
    347 	void (*handler) __P((void));
    348 {
    349 	extern extint, extsize;
    350 	extern u_long extint_call;
    351 	u_long offset = (u_long)handler - (u_long)&extint_call;
    352 	int omsr, msr;
    353 
    354 #ifdef	DIAGNOSTIC
    355 	if (offset > 0x1ffffff)
    356 		panic("install_extint: too far away");
    357 #endif
    358 	asm volatile ("mfmsr %0; andi. %1,%0,%2; mtmsr %1"
    359 		      : "=r"(omsr), "=r"(msr) : "K"((u_short)~PSL_EE));
    360 	extint_call = (extint_call & 0xfc000003) | offset;
    361 	bcopy(&extint, (void *)EXC_EXI, (size_t)&extsize);
    362 	__syncicache((void *)&extint_call, sizeof extint_call);
    363 	__syncicache((void *)EXC_EXI, (int)&extsize);
    364 	asm volatile ("mtmsr %0" :: "r"(omsr));
    365 }
    366 
    367 /*
    368  * Machine dependent startup code.
    369  */
    370 void
    371 cpu_startup()
    372 {
    373 	int sz, i;
    374 	caddr_t v;
    375 	paddr_t minaddr, maxaddr;
    376 	int base, residual;
    377 	char pbuf[9];
    378 
    379 	proc0.p_addr = proc0paddr;
    380 	v = (caddr_t)proc0paddr + USPACE;
    381 
    382 	/*
    383 	 * Initialize error message buffer (at end of core).
    384 	 */
    385 	if (!(msgbuf_vaddr = uvm_km_alloc(kernel_map, round_page(MSGBUFSIZE))))
    386 		panic("startup: no room for message buffer");
    387 	for (i = 0; i < btoc(MSGBUFSIZE); i++)
    388 		pmap_enter(pmap_kernel(), msgbuf_vaddr + i * NBPG,
    389 		    msgbuf_paddr + i * NBPG, VM_PROT_READ|VM_PROT_WRITE,
    390 		    VM_PROT_READ|VM_PROT_WRITE|PMAP_WIRED);
    391 	initmsgbuf((caddr_t)msgbuf_vaddr, round_page(MSGBUFSIZE));
    392 
    393 	printf("%s", version);
    394 	identifycpu();
    395 
    396 	format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
    397 	printf("total memory = %s\n", pbuf);
    398 
    399 	/*
    400 	 * Find out how much space we need, allocate it,
    401 	 * and then give everything true virtual addresses.
    402 	 */
    403 	sz = (int)allocsys(NULL, NULL);
    404 	if ((v = (caddr_t)uvm_km_zalloc(kernel_map, round_page(sz))) == 0)
    405 		panic("startup: no room for tables");
    406 	if (allocsys(v, NULL) - v != sz)
    407 		panic("startup: table size inconsistency");
    408 
    409 	/*
    410 	 * Now allocate buffers proper.  They are different than the above
    411 	 * in that they usually occupy more virtual memory than physical.
    412 	 */
    413 	sz = MAXBSIZE * nbuf;
    414 	if (uvm_map(kernel_map, (vaddr_t *)&buffers, round_page(sz),
    415 		    NULL, UVM_UNKNOWN_OFFSET,
    416 		    UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
    417 				UVM_ADV_NORMAL, 0)) != KERN_SUCCESS)
    418 		panic("startup: cannot allocate VM for buffers");
    419 	minaddr = (vaddr_t)buffers;
    420 	base = bufpages / nbuf;
    421 	residual = bufpages % nbuf;
    422 	if (base >= MAXBSIZE) {
    423 		/* Don't want to alloc more physical mem than ever needed */
    424 		base = MAXBSIZE;
    425 		residual = 0;
    426 	}
    427 	for (i = 0; i < nbuf; i++) {
    428 		vsize_t curbufsize;
    429 		vaddr_t curbuf;
    430 		struct vm_page *pg;
    431 
    432 		/*
    433 		 * Each buffer has MAXBSIZE bytes of VM space allocated.  Of
    434 		 * that MAXBSIZE space, we allocate and map (base+1) pages
    435 		 * for the first "residual" buffers, and then we allocate
    436 		 * "base" pages for the rest.
    437 		 */
    438 		curbuf = (vaddr_t) buffers + (i * MAXBSIZE);
    439 		curbufsize = NBPG * ((i < residual) ? (base+1) : base);
    440 
    441 		while (curbufsize) {
    442 			pg = uvm_pagealloc(NULL, 0, NULL, 0);
    443 			if (pg == NULL)
    444 				panic("startup: not enough memory for "
    445 					"buffer cache");
    446 			pmap_enter(kernel_map->pmap, curbuf,
    447 			    VM_PAGE_TO_PHYS(pg), VM_PROT_READ|VM_PROT_WRITE,
    448 			    VM_PROT_READ|VM_PROT_WRITE|PMAP_WIRED);
    449 			curbuf += PAGE_SIZE;
    450 			curbufsize -= PAGE_SIZE;
    451 		}
    452 	}
    453 
    454 	/*
    455 	 * Allocate a submap for exec arguments.  This map effectively
    456 	 * limits the number of processes exec'ing at any time.
    457 	 */
    458 	exec_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
    459 				 16*NCARGS, VM_MAP_PAGEABLE, FALSE, NULL);
    460 
    461 	/*
    462 	 * Allocate a submap for physio
    463 	 */
    464 	phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
    465 				 VM_PHYS_SIZE, 0, FALSE, NULL);
    466 
    467 	/*
    468 	 * No need to allocate an mbuf cluster submap.  Mbuf clusters
    469 	 * are allocated via the pool allocator, and we use direct-mapped
    470 	 * pool pages.
    471 	 */
    472 
    473 	/*
    474 	 * Initialize callouts.
    475 	 */
    476 	callfree = callout;
    477 	for (i = 1; i < ncallout; i++)
    478 		callout[i - 1].c_next = &callout[i];
    479 
    480 	format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
    481 	printf("avail memory = %s\n", pbuf);
    482 	format_bytes(pbuf, sizeof(pbuf), bufpages * NBPG);
    483 	printf("using %d buffers containing %s of memory\n", nbuf, pbuf);
    484 
    485 	/*
    486 	 * Set up the buffers.
    487 	 */
    488 	bufinit();
    489 
    490 	/*
    491 	 * For now, use soft spl handling.
    492 	 */
    493 	{
    494 		extern struct machvec soft_machvec;
    495 
    496 		machine_interface = soft_machvec;
    497 	}
    498 
    499 	/*
    500 	 * Now allow hardware interrupts.
    501 	 */
    502 	{
    503 		int msr;
    504 
    505 		splhigh();
    506 		asm volatile ("mfmsr %0; ori %0,%0,%1; mtmsr %0"
    507 			      : "=r"(msr) : "K"((u_short)(PSL_EE|PSL_RI)));
    508 	}
    509 }
    510 
    511 /*
    512  * consinit
    513  * Initialize system console.
    514  */
    515 void
    516 consinit()
    517 {
    518 	static int initted;
    519 
    520 	if (initted)
    521 		return;
    522 	initted = 1;
    523 	cninit();
    524 }
    525 
    526 /*
    527  * Set set up registers on exec.
    528  */
    529 void
    530 setregs(p, pack, stack)
    531 	struct proc *p;
    532 	struct exec_package *pack;
    533 	u_long stack;
    534 {
    535 	struct trapframe *tf = trapframe(p);
    536 	struct ps_strings arginfo;
    537 
    538 	bzero(tf, sizeof *tf);
    539 	tf->fixreg[1] = -roundup(-stack + 8, 16);
    540 
    541 	/*
    542 	 * XXX Machine-independent code has already copied arguments and
    543 	 * XXX environment to userland.  Get them back here.
    544 	 */
    545 	(void)copyin((char *)PS_STRINGS, &arginfo, sizeof (arginfo));
    546 
    547 	/*
    548 	 * Set up arguments for _start():
    549 	 *	_start(argc, argv, envp, obj, cleanup, ps_strings);
    550 	 *
    551 	 * Notes:
    552 	 *	- obj and cleanup are the auxilliary and termination
    553 	 *	  vectors.  They are fixed up by ld.elf_so.
    554 	 *	- ps_strings is a NetBSD extention, and will be
    555 	 * 	  ignored by executables which are strictly
    556 	 *	  compliant with the SVR4 ABI.
    557 	 *
    558 	 * XXX We have to set both regs and retval here due to different
    559 	 * XXX calling convention in trap.c and init_main.c.
    560 	 */
    561 	tf->fixreg[3] = arginfo.ps_nargvstr;
    562 	tf->fixreg[4] = (register_t)arginfo.ps_argvstr;
    563 	tf->fixreg[5] = (register_t)arginfo.ps_envstr;
    564 	tf->fixreg[6] = 0;			/* auxillary vector */
    565 	tf->fixreg[7] = 0;			/* termination vector */
    566 	tf->fixreg[8] = (register_t)PS_STRINGS;	/* NetBSD extension */
    567 
    568 	tf->srr0 = pack->ep_entry;
    569 	tf->srr1 = PSL_MBO | PSL_USERSET | PSL_FE_DFLT;
    570 	p->p_addr->u_pcb.pcb_flags = 0;
    571 }
    572 
    573 /*
    574  * Machine dependent system variables.
    575  */
    576 int
    577 cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
    578 	int *name;
    579 	u_int namelen;
    580 	void *oldp;
    581 	size_t *oldlenp;
    582 	void *newp;
    583 	size_t newlen;
    584 	struct proc *p;
    585 {
    586 	/* all sysctl names at this level are terminal */
    587 	if (namelen != 1)
    588 		return (ENOTDIR);
    589 
    590 	switch (name[0]) {
    591 	case CPU_CACHELINE:
    592 		return sysctl_rdint(oldp, oldlenp, newp, CACHELINESIZE);
    593 	default:
    594 		return (EOPNOTSUPP);
    595 	}
    596 }
    597 
    598 /*
    599  * Crash dump handling.
    600  */
    601 u_long dumpmag = 0x8fca0101;		/* magic number */
    602 int dumpsize = 0;			/* size of dump in pages */
    603 long dumplo = -1;			/* blocks */
    604 
    605 void
    606 dumpsys()
    607 {
    608 	printf("dumpsys: TBD\n");
    609 }
    610 
    611 /*
    612  * Soft networking interrupts.
    613  */
    614 void
    615 softnet()
    616 {
    617 	int isr = netisr;
    618 
    619 	netisr = 0;
    620 #ifdef	INET
    621 #include "arp.h"
    622 #if NARP > 0
    623 	if (isr & (1 << NETISR_ARP))
    624 		arpintr();
    625 #endif
    626 	if (isr & (1 << NETISR_IP))
    627 		ipintr();
    628 #endif
    629 #ifdef	INET6
    630 	if (isr & (1 << NETISR_IPV6))
    631 		ip6intr();
    632 #endif
    633 #ifdef	IMP
    634 	if (isr & (1 << NETISR_IMP))
    635 		impintr();
    636 #endif
    637 #ifdef	NS
    638 	if (isr & (1 << NETISR_NS))
    639 		nsintr();
    640 #endif
    641 #ifdef	ISO
    642 	if (isr & (1 << NETISR_ISO))
    643 		clnlintr();
    644 #endif
    645 #ifdef	CCITT
    646 	if (isr & (1 << NETISR_CCITT))
    647 		ccittintr();
    648 #endif
    649 #include "ppp.h"
    650 #if NPPP > 0
    651 	if (isr & (1 << NETISR_PPP))
    652 		pppintr();
    653 #endif
    654 }
    655 
    656 /*
    657  * Stray interrupts.
    658  */
    659 void
    660 strayintr(irq)
    661 	int irq;
    662 {
    663 	log(LOG_ERR, "stray interrupt %d\n", irq);
    664 }
    665 
    666 /*
    667  * Halt or reboot the machine after syncing/dumping according to howto.
    668  */
    669 void
    670 cpu_reboot(howto, what)
    671 	int howto;
    672 	char *what;
    673 {
    674 	static int syncing;
    675 	static char str[256];
    676 	char *ap = str, *ap1 = ap;
    677 
    678 	boothowto = howto;
    679 	if (!cold && !(howto & RB_NOSYNC) && !syncing) {
    680 		syncing = 1;
    681 		vfs_shutdown();		/* sync */
    682 		resettodr();		/* set wall clock */
    683 	}
    684 	splhigh();
    685 	if (howto & RB_HALT) {
    686 		doshutdownhooks();
    687 		printf("halted\n\n");
    688 		ppc_exit();
    689 	}
    690 	if (!cold && (howto & RB_DUMP))
    691 		dumpsys();
    692 	doshutdownhooks();
    693 	printf("rebooting\n\n");
    694 	if (what && *what) {
    695 		if (strlen(what) > sizeof str - 5)
    696 			printf("boot string too large, ignored\n");
    697 		else {
    698 			strcpy(str, what);
    699 			ap1 = ap = str + strlen(str);
    700 			*ap++ = ' ';
    701 		}
    702 	}
    703 	*ap++ = '-';
    704 	if (howto & RB_SINGLE)
    705 		*ap++ = 's';
    706 	if (howto & RB_KDB)
    707 		*ap++ = 'd';
    708 	*ap++ = 0;
    709 	if (ap[-2] == '-')
    710 		*ap1 = 0;
    711 	ppc_boot(str);
    712 }
    713 
    714 /*
    715  * OpenFirmware callback routine
    716  */
    717 void
    718 callback(p)
    719 	void *p;
    720 {
    721 	panic("callback");	/* for now			XXX */
    722 }
    723 
    724 /*
    725  * Initial Machine Interface.
    726  */
    727 static int
    728 fake_spl()
    729 {
    730 	int scratch;
    731 
    732 	asm volatile ("mfmsr %0; andi. %0,%0,%1; mtmsr %0; isync"
    733 	    : "=r"(scratch) : "K"((u_short)~(PSL_EE|PSL_ME)));
    734 	return (-1);
    735 }
    736 
    737 static void
    738 fake_setsoft()
    739 {
    740 	/* Do nothing */
    741 }
    742 
    743 static int
    744 fake_splx(new)
    745 	int new;
    746 {
    747 	return (fake_spl());
    748 }
    749 
    750 static void
    751 fake_clock_return(frame, nticks)
    752 	struct clockframe *frame;
    753 	int nticks;
    754 {
    755 	/* Do nothing */
    756 }
    757 
    758 static void
    759 fake_irq_establish(irq, level, handler, arg)
    760 	int irq, level;
    761 	void (*handler) __P((void *));
    762 	void *arg;
    763 {
    764 	panic("fake_irq_establish");
    765 }
    766