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