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