Home | History | Annotate | Line # | Download | only in sun3x
machdep.c revision 1.81
      1 /*	$NetBSD: machdep.c,v 1.81 2002/09/06 13:18:43 gehenna Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1988 University of Utah.
      5  * Copyright (c) 1982, 1986, 1990, 1993
      6  *	The Regents of the University of California.  All rights reserved.
      7  *
      8  * This code is derived from software contributed to Berkeley by
      9  * the Systems Programming Group of the University of Utah Computer
     10  * Science Department.
     11  *
     12  * Redistribution and use in source and binary forms, with or without
     13  * modification, are permitted provided that the following conditions
     14  * are met:
     15  * 1. Redistributions of source code must retain the above copyright
     16  *    notice, this list of conditions and the following disclaimer.
     17  * 2. Redistributions in binary form must reproduce the above copyright
     18  *    notice, this list of conditions and the following disclaimer in the
     19  *    documentation and/or other materials provided with the distribution.
     20  * 3. All advertising materials mentioning features or use of this software
     21  *    must display the following acknowledgement:
     22  *	This product includes software developed by the University of
     23  *	California, Berkeley and its contributors.
     24  * 4. Neither the name of the University nor the names of its contributors
     25  *    may be used to endorse or promote products derived from this software
     26  *    without specific prior written permission.
     27  *
     28  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     29  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     30  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     31  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     32  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     33  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     34  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     35  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     36  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     37  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     38  * SUCH DAMAGE.
     39  *
     40  *	from: Utah Hdr: machdep.c 1.74 92/12/20
     41  *	from: @(#)machdep.c	8.10 (Berkeley) 4/20/94
     42  */
     43 
     44 #include "opt_ddb.h"
     45 #include "opt_kgdb.h"
     46 
     47 #include <sys/param.h>
     48 #include <sys/systm.h>
     49 #include <sys/kernel.h>
     50 #include <sys/map.h>
     51 #include <sys/proc.h>
     52 #include <sys/buf.h>
     53 #include <sys/reboot.h>
     54 #include <sys/conf.h>
     55 #include <sys/file.h>
     56 #include <sys/clist.h>
     57 #include <sys/device.h>
     58 #include <sys/malloc.h>
     59 #include <sys/mbuf.h>
     60 #include <sys/msgbuf.h>
     61 #include <sys/ioctl.h>
     62 #include <sys/tty.h>
     63 #include <sys/mount.h>
     64 #include <sys/user.h>
     65 #include <sys/exec.h>
     66 #include <sys/core.h>
     67 #include <sys/kcore.h>
     68 #include <sys/vnode.h>
     69 #include <sys/syscallargs.h>
     70 #ifdef	KGDB
     71 #include <sys/kgdb.h>
     72 #endif
     73 
     74 #include <uvm/uvm_extern.h>
     75 
     76 #include <sys/sysctl.h>
     77 
     78 #include <dev/cons.h>
     79 
     80 #include <machine/cpu.h>
     81 #include <machine/dvma.h>
     82 #include <machine/idprom.h>
     83 #include <machine/kcore.h>
     84 #include <machine/reg.h>
     85 #include <machine/psl.h>
     86 #include <machine/pte.h>
     87 
     88 #if defined(DDB)
     89 #include <machine/db_machdep.h>
     90 #include <ddb/db_sym.h>
     91 #include <ddb/db_extern.h>
     92 #endif
     93 
     94 #include <sun3/sun3/machdep.h>
     95 
     96 /* Defined in locore.s */
     97 extern char kernel_text[];
     98 /* Defined by the linker */
     99 extern char etext[];
    100 
    101 /* Our exported CPU info; we can have only one. */
    102 struct cpu_info cpu_info_store;
    103 
    104 struct vm_map *exec_map = NULL;
    105 struct vm_map *mb_map = NULL;
    106 struct vm_map *phys_map = NULL;
    107 
    108 int	physmem;
    109 int	fputype;
    110 caddr_t	msgbufaddr;
    111 
    112 /* Virtual page frame for /dev/mem (see mem.c) */
    113 vaddr_t vmmap;
    114 
    115 union sun3sir sun3sir;
    116 
    117 /*
    118  * safepri is a safe priority for sleep to set for a spin-wait
    119  * during autoconfiguration or after a panic.
    120  */
    121 int	safepri = PSL_LOWIPL;
    122 
    123 u_char cpu_machine_id = 0;
    124 char *cpu_string = NULL;
    125 int cpu_has_vme = 0;
    126 int has_iocache = 0;
    127 
    128 vaddr_t dumppage;
    129 
    130 static void identifycpu __P((void));
    131 static void initcpu __P((void));
    132 
    133 /*
    134  * Console initialization: called early on from main,
    135  * before vm init or cpu_startup.  This system is able
    136  * to use the console for output immediately (via PROM)
    137  * but can not use it for input until after this point.
    138  */
    139 void
    140 consinit()
    141 {
    142 
    143 	/*
    144 	 * Switch from the PROM console (output only)
    145 	 * to our own console driver.
    146 	 */
    147 	cninit();
    148 
    149 #ifdef DDB
    150 	{
    151 		extern int nsym;
    152 		extern char *ssym, *esym;
    153 
    154 		ddb_init(nsym, ssym, esym);
    155 	}
    156 #endif	/* DDB */
    157 
    158 	/*
    159 	 * Now that the console can do input as well as
    160 	 * output, consider stopping for a debugger.
    161 	 */
    162 	if (boothowto & RB_KDB) {
    163 #ifdef KGDB
    164 		/* XXX - Ask on console for kgdb_dev? */
    165 		/* Note: this will just return if kgdb_dev==NODEV */
    166 		kgdb_connect(1);
    167 #else	/* KGDB */
    168 		/* Either DDB or no debugger (just PROM). */
    169 		Debugger();
    170 #endif	/* KGDB */
    171 	}
    172 }
    173 
    174 /*
    175  * cpu_startup: allocate memory for variable-sized tables,
    176  * initialize cpu, and do autoconfiguration.
    177  *
    178  * This is called early in init_main.c:main(), after the
    179  * kernel memory allocator is ready for use, but before
    180  * the creation of processes 1,2, and mountroot, etc.
    181  */
    182 void
    183 cpu_startup()
    184 {
    185 	caddr_t v;
    186 	vsize_t size;
    187 	int sz, i, base, residual;
    188 	vaddr_t minaddr, maxaddr;
    189 	char pbuf[9];
    190 
    191 	/*
    192 	 * Initialize message buffer (for kernel printf).
    193 	 * This is put in physical page zero so it will
    194 	 * always be in the same place after a reboot.
    195 	 * Its mapping was prepared in pmap_bootstrap().
    196 	 * Also, offset some to avoid PROM scribbles.
    197 	 */
    198 	v = (caddr_t) KERNBASE;
    199 	msgbufaddr = (caddr_t)(v + MSGBUFOFF);
    200 	initmsgbuf(msgbufaddr, MSGBUFSIZE);
    201 
    202 	/*
    203 	 * Good {morning,afternoon,evening,night}.
    204 	 */
    205 	printf(version);
    206 	identifycpu();
    207 	initfpu();	/* also prints FPU type */
    208 
    209 	format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
    210 	printf("total memory = %s\n", pbuf);
    211 
    212 	/*
    213 	 * Get scratch page for dumpsys().
    214 	 */
    215 	if ((dumppage = uvm_km_alloc(kernel_map, NBPG)) == 0)
    216 		panic("startup: alloc dumppage");
    217 
    218 	/*
    219 	 * Find out how much space we need, allocate it,
    220 	 * and then give everything true virtual addresses.
    221 	 */
    222 	sz = (u_int)allocsys(NULL, NULL);
    223 	if ((v = (caddr_t)uvm_km_alloc(kernel_map, round_page(sz))) == 0)
    224 		panic("startup: no room for tables");
    225 	if (allocsys(v, NULL) - v != sz)
    226 		panic("startup: table size inconsistency");
    227 
    228 	/*
    229 	 * Now allocate buffers proper.  They are different than the above
    230 	 * in that they usually occupy more virtual memory than physical.
    231 	 */
    232 	size = MAXBSIZE * nbuf;
    233 	if (uvm_map(kernel_map, (vaddr_t *) &buffers, round_page(size),
    234 		    NULL, UVM_UNKNOWN_OFFSET, 0,
    235 		    UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
    236 				UVM_ADV_NORMAL, 0)) != 0)
    237 		panic("startup: cannot allocate VM for buffers");
    238 	minaddr = (vaddr_t)buffers;
    239 	if ((bufpages / nbuf) >= btoc(MAXBSIZE)) {
    240 		/* don't want to alloc more physical mem than needed */
    241 		bufpages = btoc(MAXBSIZE) * nbuf;
    242 	}
    243 	base = bufpages / nbuf;
    244 	residual = bufpages % nbuf;
    245 	for (i = 0; i < nbuf; i++) {
    246 		vsize_t curbufsize;
    247 		vaddr_t curbuf;
    248 		struct vm_page *pg;
    249 
    250 		/*
    251 		 * Each buffer has MAXBSIZE bytes of VM space allocated.  Of
    252 		 * that MAXBSIZE space, we allocate and map (base+1) pages
    253 		 * for the first "residual" buffers, and then we allocate
    254 		 * "base" pages for the rest.
    255 		 */
    256 		curbuf = (vaddr_t) buffers + (i * MAXBSIZE);
    257 		curbufsize = NBPG * ((i < residual) ? (base+1) : base);
    258 
    259 		while (curbufsize) {
    260 			pg = uvm_pagealloc(NULL, 0, NULL, 0);
    261 			if (pg == NULL)
    262 				panic("cpu_startup: not enough memory for "
    263 				    "buffer cache");
    264 			pmap_kenter_pa(curbuf, VM_PAGE_TO_PHYS(pg),
    265 				       VM_PROT_READ|VM_PROT_WRITE);
    266 			curbuf += PAGE_SIZE;
    267 			curbufsize -= PAGE_SIZE;
    268 		}
    269 	}
    270 	pmap_update(pmap_kernel());
    271 
    272 	/*
    273 	 * Allocate a submap for exec arguments.  This map effectively
    274 	 * limits the number of processes exec'ing at any time.
    275 	 */
    276 	exec_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
    277 				   16*NCARGS, VM_MAP_PAGEABLE, FALSE, NULL);
    278 
    279 	/*
    280 	 * We don't use a submap for physio, and use a separate map
    281 	 * for DVMA allocations.  Our vmapbuf just maps pages into
    282 	 * the kernel map (any kernel mapping is OK) and then the
    283 	 * device drivers clone the kernel mappings into DVMA space.
    284 	 */
    285 
    286 	/*
    287 	 * Finally, allocate mbuf cluster submap.
    288 	 */
    289 	mb_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
    290 				 nmbclusters * mclbytes, VM_MAP_INTRSAFE,
    291 				 FALSE, NULL);
    292 
    293 	format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
    294 	printf("avail memory = %s\n", pbuf);
    295 	format_bytes(pbuf, sizeof(pbuf), bufpages * NBPG);
    296 	printf("using %u buffers containing %s of memory\n", nbuf, pbuf);
    297 
    298 	/*
    299 	 * Allocate a virtual page (for use by /dev/mem)
    300 	 * This page is handed to pmap_enter() therefore
    301 	 * it has to be in the normal kernel VA range.
    302 	 */
    303 	vmmap = uvm_km_valloc_wait(kernel_map, NBPG);
    304 
    305 	/*
    306 	 * Create the DVMA maps.
    307 	 */
    308 	dvma_init();
    309 
    310 	/*
    311 	 * Set up CPU-specific registers, cache, etc.
    312 	 */
    313 	initcpu();
    314 
    315 	/*
    316 	 * Set up buffers, so they can be used to read disk labels.
    317 	 */
    318 	bufinit();
    319 }
    320 
    321 /*
    322  * Set registers on exec.
    323  */
    324 void
    325 setregs(p, pack, stack)
    326 	struct proc *p;
    327 	struct exec_package *pack;
    328 	u_long stack;
    329 {
    330 	struct trapframe *tf = (struct trapframe *)p->p_md.md_regs;
    331 
    332 	tf->tf_sr = PSL_USERSET;
    333 	tf->tf_pc = pack->ep_entry & ~1;
    334 	tf->tf_regs[D0] = 0;
    335 	tf->tf_regs[D1] = 0;
    336 	tf->tf_regs[D2] = 0;
    337 	tf->tf_regs[D3] = 0;
    338 	tf->tf_regs[D4] = 0;
    339 	tf->tf_regs[D5] = 0;
    340 	tf->tf_regs[D6] = 0;
    341 	tf->tf_regs[D7] = 0;
    342 	tf->tf_regs[A0] = 0;
    343 	tf->tf_regs[A1] = 0;
    344 	tf->tf_regs[A2] = (int)p->p_psstr;
    345 	tf->tf_regs[A3] = 0;
    346 	tf->tf_regs[A4] = 0;
    347 	tf->tf_regs[A5] = 0;
    348 	tf->tf_regs[A6] = 0;
    349 	tf->tf_regs[SP] = stack;
    350 
    351 	/* restore a null state frame */
    352 	p->p_addr->u_pcb.pcb_fpregs.fpf_null = 0;
    353 	if (fputype)
    354 		m68881_restore(&p->p_addr->u_pcb.pcb_fpregs);
    355 
    356 	p->p_md.md_flags = 0;
    357 }
    358 
    359 /*
    360  * Info for CTL_HW
    361  */
    362 char	machine[16] = MACHINE;		/* from <machine/param.h> */
    363 char	kernel_arch[16] = "sun3x";	/* XXX needs a sysctl node */
    364 char	cpu_model[120];
    365 
    366 /*
    367  * XXX - Should empirically estimate the divisor...
    368  * Note that the value of delay_divisor is roughly
    369  * 2048 / cpuclock	(where cpuclock is in MHz).
    370  */
    371 int delay_divisor = 62;		/* assume the fastest (33 MHz) */
    372 
    373 void
    374 identifycpu()
    375 {
    376 	u_char machtype;
    377 
    378 	machtype = identity_prom.idp_machtype;
    379 	if ((machtype & IDM_ARCH_MASK) != IDM_ARCH_SUN3X) {
    380 		printf("Bad IDPROM arch!\n");
    381 		sunmon_abort();
    382 	}
    383 
    384 	cpu_machine_id = machtype;
    385 	switch (cpu_machine_id) {
    386 
    387 	case SUN3X_MACH_80:
    388 		cpu_string = "80";  	/* Hydra */
    389 		delay_divisor = 102;	/* 20 MHz */
    390 		cpu_has_vme = FALSE;
    391 		break;
    392 
    393 	case SUN3X_MACH_470:
    394 		cpu_string = "470"; 	/* Pegasus */
    395 		delay_divisor = 62; 	/* 33 MHz */
    396 		cpu_has_vme = TRUE;
    397 		break;
    398 
    399 	default:
    400 		printf("unknown sun3x model\n");
    401 		sunmon_abort();
    402 	}
    403 
    404 	/* Other stuff? (VAC, mc6888x version, etc.) */
    405 	/* Note: miniroot cares about the kernel_arch part. */
    406 	sprintf(cpu_model, "%s %s", kernel_arch, cpu_string);
    407 
    408 	printf("Model: %s\n", cpu_model);
    409 }
    410 
    411 /*
    412  * machine dependent system variables.
    413  */
    414 int
    415 cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
    416 	int *name;
    417 	u_int namelen;
    418 	void *oldp;
    419 	size_t *oldlenp;
    420 	void *newp;
    421 	size_t newlen;
    422 	struct proc *p;
    423 {
    424 	int error;
    425 	dev_t consdev;
    426 
    427 	/* all sysctl names at this level are terminal */
    428 	if (namelen != 1)
    429 		return (ENOTDIR);		/* overloaded */
    430 
    431 	switch (name[0]) {
    432 	case CPU_CONSDEV:
    433 		if (cn_tab != NULL)
    434 			consdev = cn_tab->cn_dev;
    435 		else
    436 			consdev = NODEV;
    437 		error = sysctl_rdstruct(oldp, oldlenp, newp,
    438 		    &consdev, sizeof consdev);
    439 		break;
    440 
    441 #if 0	/* XXX - Not yet... */
    442 	case CPU_ROOT_DEVICE:
    443 		error = sysctl_rdstring(oldp, oldlenp, newp, root_device);
    444 		break;
    445 
    446 	case CPU_BOOTED_KERNEL:
    447 		error = sysctl_rdstring(oldp, oldlenp, newp, booted_kernel);
    448 		break;
    449 #endif
    450 
    451 	default:
    452 		error = EOPNOTSUPP;
    453 	}
    454 	return (error);
    455 }
    456 
    457 /* See: sig_machdep.c */
    458 
    459 /*
    460  * Do a sync in preparation for a reboot.
    461  * XXX - This could probably be common code.
    462  * XXX - And now, most of it is in vfs_shutdown()
    463  * XXX - Put waittime checks in there too?
    464  */
    465 int waittime = -1;	/* XXX - Who else looks at this? -gwr */
    466 static void
    467 reboot_sync __P((void))
    468 {
    469 
    470 	/* Check waittime here to localize its use to this function. */
    471 	if (waittime >= 0)
    472 		return;
    473 	waittime = 0;
    474 	vfs_shutdown();
    475 }
    476 
    477 /*
    478  * Common part of the BSD and SunOS reboot system calls.
    479  */
    480 __dead void
    481 cpu_reboot(howto, user_boot_string)
    482 	int howto;
    483 	char *user_boot_string;
    484 {
    485 	/* Note: this string MUST be static! */
    486 	static char bootstr[128];
    487 	char *p;
    488 
    489 	/* If system is cold, just halt. (early panic?) */
    490 	if (cold)
    491 		goto haltsys;
    492 
    493 	/* Un-blank the screen if appropriate. */
    494 	cnpollc(1);
    495 
    496 	if ((howto & RB_NOSYNC) == 0) {
    497 		reboot_sync();
    498 		/*
    499 		 * If we've been adjusting the clock, the todr
    500 		 * will be out of synch; adjust it now.
    501 		 *
    502 		 * XXX - However, if the kernel has been sitting in ddb,
    503 		 * the time will be way off, so don't set the HW clock!
    504 		 * XXX - Should do sanity check against HW clock. -gwr
    505 		 */
    506 		/* resettodr(); */
    507 	}
    508 
    509 	/* Disable interrupts. */
    510 	splhigh();
    511 
    512 	/* Write out a crash dump if asked. */
    513 	if (howto & RB_DUMP)
    514 		dumpsys();
    515 
    516 	/* run any shutdown hooks */
    517 	doshutdownhooks();
    518 
    519 	if (howto & RB_HALT) {
    520 	haltsys:
    521 		printf("halted.\n");
    522 		sunmon_halt();
    523 	}
    524 
    525 	/*
    526 	 * Automatic reboot.
    527 	 */
    528 	if (user_boot_string)
    529 		strncpy(bootstr, user_boot_string, sizeof(bootstr));
    530 	else {
    531 		/*
    532 		 * Build our own boot string with an empty
    533 		 * boot device/file and (maybe) some flags.
    534 		 * The PROM will supply the device/file name.
    535 		 */
    536 		p = bootstr;
    537 		*p = '\0';
    538 		if (howto & (RB_KDB|RB_ASKNAME|RB_SINGLE)) {
    539 			/* Append the boot flags. */
    540 			*p++ = ' ';
    541 			*p++ = '-';
    542 			if (howto & RB_KDB)
    543 				*p++ = 'd';
    544 			if (howto & RB_ASKNAME)
    545 				*p++ = 'a';
    546 			if (howto & RB_SINGLE)
    547 				*p++ = 's';
    548 			*p = '\0';
    549 		}
    550 	}
    551 	printf("rebooting...\n");
    552 	sunmon_reboot(bootstr);
    553 	for (;;) ;
    554 	/*NOTREACHED*/
    555 }
    556 
    557 /*
    558  * These variables are needed by /sbin/savecore
    559  */
    560 u_int32_t dumpmag = 0x8fca0101;	/* magic number */
    561 int 	dumpsize = 0;		/* pages */
    562 long	dumplo = 0; 		/* blocks */
    563 
    564 #define DUMP_EXTRA	1	/* CPU-dependent extra pages */
    565 
    566 /*
    567  * This is called by main to set dumplo, dumpsize.
    568  * Dumps always skip the first NBPG of disk space
    569  * in case there might be a disk label stored there.
    570  * If there is extra space, put dump at the end to
    571  * reduce the chance that swapping trashes it.
    572  */
    573 void
    574 cpu_dumpconf()
    575 {
    576 	const struct bdevsw *bdev;
    577 	int devblks;	/* size of dump device in blocks */
    578 	int dumpblks;	/* size of dump image in blocks */
    579 	int (*getsize)__P((dev_t));
    580 
    581 	if (dumpdev == NODEV)
    582 		return;
    583 
    584 	bdev = bdevsw_lookup(dumpdev);
    585 	if (bdev == NULL)
    586 		panic("dumpconf: bad dumpdev=0x%x", dumpdev);
    587 	getsize = bdev->d_psize;
    588 	if (getsize == NULL)
    589 		return;
    590 	devblks = (*getsize)(dumpdev);
    591 	if (devblks <= ctod(1))
    592 		return;
    593 	devblks &= ~(ctod(1) - 1);
    594 
    595 	/*
    596 	 * Note: savecore expects dumpsize to be the
    597 	 * number of pages AFTER the dump header.
    598 	 */
    599 	dumpsize = physmem; 	/* pages */
    600 
    601 	/* Position dump image near end of space, page aligned. */
    602 	dumpblks = ctod(physmem + DUMP_EXTRA);
    603 	dumplo = devblks - dumpblks;
    604 
    605 	/* If it does not fit, truncate it by moving dumplo. */
    606 	/* Note: Must force signed comparison. */
    607 	if (dumplo < ((long)ctod(1))) {
    608 		dumplo = ctod(1);
    609 		dumpsize = dtoc(devblks - dumplo) - DUMP_EXTRA;
    610 	}
    611 }
    612 
    613 /* Note: gdb looks for "dumppcb" in a kernel crash dump. */
    614 struct pcb dumppcb;
    615 
    616 /*
    617  * Write a crash dump.  The format while in swap is:
    618  *   kcore_seg_t cpu_hdr;
    619  *   cpu_kcore_hdr_t cpu_data;
    620  *   padding (NBPG-sizeof(kcore_seg_t))
    621  *   pagemap (2*NBPG)
    622  *   physical memory...
    623  */
    624 void
    625 dumpsys()
    626 {
    627 	const struct bdevsw *dsw;
    628 	kcore_seg_t *kseg_p;
    629 	cpu_kcore_hdr_t *chdr_p;
    630 	struct sun3x_kcore_hdr *sh;
    631 	phys_ram_seg_t *crs_p;
    632 	char *vaddr;
    633 	paddr_t paddr;
    634 	int psize, todo, seg, segsz;
    635 	daddr_t blkno;
    636 	int error = 0;
    637 
    638 	if (dumpdev == NODEV)
    639 		return;
    640 	dsw = bdevsw_lookup(dumpdev);
    641 	if (dsw == NULL || dsw->d_psize == NULL)
    642 		return;
    643 
    644 	/*
    645 	 * For dumps during autoconfiguration,
    646 	 * if dump device has already configured...
    647 	 */
    648 	if (dumpsize == 0)
    649 		cpu_dumpconf();
    650 	if (dumplo <= 0) {
    651 		printf("\ndump to dev %u,%u not possible\n", major(dumpdev),
    652 		    minor(dumpdev));
    653 		return;
    654 	}
    655 	savectx(&dumppcb);
    656 
    657 	psize = (*(dsw->d_psize))(dumpdev);
    658 	if (psize == -1) {
    659 		printf("dump area unavailable\n");
    660 		return;
    661 	}
    662 
    663 	printf("\ndumping to dev %u,%u offset %ld\n", major(dumpdev),
    664 	    minor(dumpdev), dumplo);
    665 
    666 	/*
    667 	 * Prepare the dump header
    668 	 */
    669 	blkno = dumplo;
    670 	todo = dumpsize;	/* pages */
    671 	vaddr = (char *)dumppage;
    672 	memset(vaddr, 0, NBPG);
    673 
    674 	/* Set pointers to all three parts. */
    675 	kseg_p = (kcore_seg_t *)vaddr;
    676 	chdr_p = (cpu_kcore_hdr_t *)(kseg_p + 1);
    677 	sh = &chdr_p->un._sun3x;
    678 
    679 	/* Fill in kcore_seg_t part. */
    680 	CORE_SETMAGIC(*kseg_p, KCORE_MAGIC, MID_MACHINE, CORE_CPU);
    681 	kseg_p->c_size = (ctob(DUMP_EXTRA) - sizeof(*kseg_p));
    682 
    683 	/* Fill in cpu_kcore_hdr_t part. */
    684 	strncpy(chdr_p->name, kernel_arch, sizeof(chdr_p->name));
    685 	chdr_p->page_size = NBPG;
    686 	chdr_p->kernbase = KERNBASE;
    687 
    688 	/* Fill in the sun3x_kcore_hdr part. */
    689 	pmap_kcore_hdr(sh);
    690 
    691 	/* Write out the dump header. */
    692 	error = (*dsw->d_dump)(dumpdev, blkno, vaddr, NBPG);
    693 	if (error)
    694 		goto fail;
    695 	blkno += btodb(NBPG);
    696 
    697 	/*
    698 	 * Now dump physical memory.  Note that physical memory
    699 	 * might NOT be congiguous, so do it by segments.
    700 	 */
    701 
    702 	vaddr = (char *)vmmap;	/* Borrow /dev/mem VA */
    703 
    704 	for (seg = 0; seg < SUN3X_NPHYS_RAM_SEGS; seg++) {
    705 		crs_p = &sh->ram_segs[seg];
    706 		paddr = crs_p->start;
    707 		segsz = crs_p->size;
    708 
    709 		while (todo && (segsz > 0)) {
    710 
    711 			/* Print pages left after every 16. */
    712 			if ((todo & 0xf) == 0)
    713 				printf("\r%4d", todo);
    714 
    715 			/* Make a temporary mapping for the page. */
    716 			pmap_kenter_pa(vmmap, paddr | PMAP_NC, VM_PROT_READ);
    717 			pmap_update(pmap_kernel());
    718 			error = (*dsw->d_dump)(dumpdev, blkno, vaddr, NBPG);
    719 			pmap_kremove(vmmap, NBPG);
    720 			pmap_update(pmap_kernel());
    721 			if (error)
    722 				goto fail;
    723 			paddr += NBPG;
    724 			segsz -= NBPG;
    725 			blkno += btodb(NBPG);
    726 			todo--;
    727 		}
    728 	}
    729 	printf("\rdump succeeded\n");
    730 	return;
    731 fail:
    732 	printf(" dump error=%d\n", error);
    733 }
    734 
    735 static void
    736 initcpu()
    737 {
    738 	/* XXX: Enable RAM parity/ECC checking? */
    739 	/* XXX: parityenable(); */
    740 
    741 #ifdef	HAVECACHE
    742 	cache_enable();
    743 #endif
    744 }
    745 
    746 /* straptrap() in trap.c */
    747 
    748 /* from hp300: badaddr() */
    749 /* peek_byte(), peek_word() moved to bus_subr.c */
    750 
    751 /* XXX: parityenable() ? */
    752 /* regdump() moved to regdump.c */
    753 
    754 /*
    755  * cpu_exec_aout_makecmds():
    756  *	cpu-dependent a.out format hook for execve().
    757  *
    758  * Determine if the given exec package refers to something which we
    759  * understand and, if so, set up the vmcmds for it.
    760  */
    761 int
    762 cpu_exec_aout_makecmds(p, epp)
    763 	struct proc *p;
    764 	struct exec_package *epp;
    765 {
    766 	return ENOEXEC;
    767 }
    768