Home | History | Annotate | Line # | Download | only in sun3x
machdep.c revision 1.131
      1 /*	$NetBSD: machdep.c,v 1.131 2011/12/12 19:03:12 mrg 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. Neither the name of the University nor the names of its contributors
     21  *    may be used to endorse or promote products derived from this software
     22  *    without specific prior written permission.
     23  *
     24  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     34  * SUCH DAMAGE.
     35  *
     36  *	from: Utah Hdr: machdep.c 1.74 92/12/20
     37  *	from: @(#)machdep.c	8.10 (Berkeley) 4/20/94
     38  */
     39 
     40 #include <sys/cdefs.h>
     41 __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.131 2011/12/12 19:03:12 mrg Exp $");
     42 
     43 #include "opt_ddb.h"
     44 #include "opt_kgdb.h"
     45 #include "opt_modular.h"
     46 
     47 #include <sys/param.h>
     48 #include <sys/systm.h>
     49 #include <sys/kernel.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/device.h>
     56 #include <sys/malloc.h>
     57 #include <sys/mbuf.h>
     58 #include <sys/msgbuf.h>
     59 #include <sys/ioctl.h>
     60 #include <sys/tty.h>
     61 #include <sys/mount.h>
     62 #include <sys/exec.h>
     63 #include <sys/exec_aout.h>		/* for MID_* */
     64 #include <sys/core.h>
     65 #include <sys/kcore.h>
     66 #include <sys/vnode.h>
     67 #include <sys/syscallargs.h>
     68 #include <sys/ksyms.h>
     69 #include <sys/module.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 #include <dev/mm.h>
     80 
     81 #include <machine/cpu.h>
     82 #include <machine/dvma.h>
     83 #include <machine/idprom.h>
     84 #include <machine/kcore.h>
     85 #include <machine/reg.h>
     86 #include <machine/pcb.h>
     87 #include <machine/psl.h>
     88 #include <machine/pte.h>
     89 #include <machine/mon.h>
     90 
     91 #if defined(DDB)
     92 #include <machine/db_machdep.h>
     93 #include <ddb/db_sym.h>
     94 #include <ddb/db_extern.h>
     95 #endif
     96 
     97 #include <sun3/sun3/machdep.h>
     98 
     99 #include "ksyms.h"
    100 
    101 /* Defined in locore.s */
    102 extern char kernel_text[];
    103 /* Defined by the linker */
    104 extern char etext[];
    105 
    106 /* kernel_arch specific values required by module(9) */
    107 const vaddr_t kernbase = KERNBASE3X;
    108 const vaddr_t kern_end = KERN_END3X;
    109 
    110 /* Our exported CPU info; we can have only one. */
    111 struct cpu_info cpu_info_store;
    112 
    113 struct vm_map *phys_map = NULL;
    114 
    115 int	physmem;
    116 int	fputype;
    117 void *	msgbufaddr;
    118 
    119 /* Virtual page frame for /dev/mem (see mem.c) */
    120 vaddr_t vmmap;
    121 
    122 /*
    123  * safepri is a safe priority for sleep to set for a spin-wait
    124  * during autoconfiguration or after a panic.
    125  */
    126 int	safepri = PSL_LOWIPL;
    127 
    128 u_char cpu_machine_id = 0;
    129 const char *cpu_string = NULL;
    130 int cpu_has_vme = 0;
    131 int has_iocache = 0;
    132 
    133 vaddr_t dumppage;
    134 
    135 static void identifycpu(void);
    136 static void initcpu(void);
    137 
    138 /*
    139  * Console initialization: called early on from main,
    140  * before vm init or cpu_startup.  This system is able
    141  * to use the console for output immediately (via PROM)
    142  * but can not use it for input until after this point.
    143  */
    144 void
    145 consinit(void)
    146 {
    147 
    148 	/*
    149 	 * Switch from the PROM console (output only)
    150 	 * to our own console driver.
    151 	 */
    152 	cninit();
    153 
    154 #if NKSYMS || defined(DDB) || defined(MODULAR)
    155 	{
    156 		extern int nsym;
    157 		extern char *ssym, *esym;
    158 
    159 		ksyms_addsyms_elf(nsym, ssym, esym);
    160 	}
    161 #endif	/* DDB */
    162 
    163 	/*
    164 	 * Now that the console can do input as well as
    165 	 * output, consider stopping for a debugger.
    166 	 */
    167 	if (boothowto & RB_KDB) {
    168 #ifdef KGDB
    169 		/* XXX - Ask on console for kgdb_dev? */
    170 		/* Note: this will just return if kgdb_dev==NODEV */
    171 		kgdb_connect(1);
    172 #else	/* KGDB */
    173 		/* Either DDB or no debugger (just PROM). */
    174 		Debugger();
    175 #endif	/* KGDB */
    176 	}
    177 }
    178 
    179 /*
    180  * cpu_startup: allocate memory for variable-sized tables,
    181  * initialize CPU, and do autoconfiguration.
    182  *
    183  * This is called early in init_main.c:main(), after the
    184  * kernel memory allocator is ready for use, but before
    185  * the creation of processes 1,2, and mountroot, etc.
    186  */
    187 void
    188 cpu_startup(void)
    189 {
    190 	char *v;
    191 	vaddr_t minaddr, maxaddr;
    192 	char pbuf[9];
    193 
    194 	/*
    195 	 * Initialize message buffer (for kernel printf).
    196 	 * This is put in physical page zero so it will
    197 	 * always be in the same place after a reboot.
    198 	 * Its mapping was prepared in pmap_bootstrap().
    199 	 * Also, offset some to avoid PROM scribbles.
    200 	 */
    201 	v = (char *)KERNBASE3X;
    202 	msgbufaddr = v + MSGBUFOFF;
    203 	initmsgbuf(msgbufaddr, MSGBUFSIZE);
    204 
    205 	/*
    206 	 * Good {morning,afternoon,evening,night}.
    207 	 */
    208 	printf("%s%s", copyright, version);
    209 	identifycpu();
    210 	initfpu();	/* also prints FPU type */
    211 
    212 	format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
    213 	printf("total memory = %s\n", pbuf);
    214 
    215 	/*
    216 	 * Get scratch page for dumpsys().
    217 	 */
    218 	dumppage = uvm_km_alloc(kernel_map, PAGE_SIZE, 0, UVM_KMF_WIRED);
    219 	if (dumppage == 0)
    220 		panic("startup: alloc dumppage");
    221 
    222 	minaddr = 0;
    223 
    224 	/*
    225 	 * Allocate a submap for physio
    226 	 */
    227 	phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
    228 				   VM_PHYS_SIZE, 0, false, NULL);
    229 
    230 	format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
    231 	printf("avail memory = %s\n", pbuf);
    232 
    233 	/*
    234 	 * Allocate a virtual page (for use by /dev/mem)
    235 	 * This page is handed to pmap_enter() therefore
    236 	 * it has to be in the normal kernel VA range.
    237 	 */
    238 	vmmap = uvm_km_alloc(kernel_map, PAGE_SIZE, 0,
    239 	    UVM_KMF_VAONLY | UVM_KMF_WAITVA);
    240 
    241 	/*
    242 	 * Create the DVMA maps.
    243 	 */
    244 	dvma_init();
    245 
    246 	/*
    247 	 * Set up CPU-specific registers, cache, etc.
    248 	 */
    249 	initcpu();
    250 }
    251 
    252 /*
    253  * Info for CTL_HW
    254  */
    255 char	machine[16] = MACHINE;		/* from <machine/param.h> */
    256 char	kernel_arch[16] = "sun3x";	/* XXX needs a sysctl node */
    257 char	cpu_model[120];
    258 
    259 /*
    260  * XXX - Should empirically estimate the divisor...
    261  * Note that the value of delay_divisor is roughly
    262  * 2048 / cpuclock	(where cpuclock is in MHz).
    263  */
    264 int delay_divisor = 62;		/* assume the fastest (33 MHz) */
    265 
    266 void
    267 identifycpu(void)
    268 {
    269 	u_char machtype;
    270 
    271 	machtype = identity_prom.idp_machtype;
    272 	if ((machtype & IDM_ARCH_MASK) != IDM_ARCH_SUN3X) {
    273 		printf("Bad IDPROM arch!\n");
    274 		sunmon_abort();
    275 	}
    276 
    277 	cpu_machine_id = machtype;
    278 	switch (cpu_machine_id) {
    279 
    280 	case ID_SUN3X_80:
    281 		cpu_string = "80";  	/* Hydra */
    282 		delay_divisor = 102;	/* 20 MHz */
    283 		cpu_has_vme = false;
    284 		break;
    285 
    286 	case ID_SUN3X_470:
    287 		cpu_string = "470"; 	/* Pegasus */
    288 		delay_divisor = 62; 	/* 33 MHz */
    289 		cpu_has_vme = true;
    290 		break;
    291 
    292 	default:
    293 		printf("unknown sun3x model\n");
    294 		sunmon_abort();
    295 	}
    296 
    297 	/* Other stuff? (VAC, mc6888x version, etc.) */
    298 	/* Note: miniroot cares about the kernel_arch part. */
    299 	sprintf(cpu_model, "%s %s", kernel_arch, cpu_string);
    300 
    301 	printf("Model: %s\n", cpu_model);
    302 }
    303 
    304 /*
    305  * machine dependent system variables.
    306  */
    307 #if 0   /* XXX - Not yet... */
    308 static int
    309 sysctl_machdep_root_device(SYSCTLFN_ARGS)
    310 {
    311 	struct sysctlnode node = *rnode;
    312 
    313 	node.sysctl_data = some permutation on root_device;
    314 	node.sysctl_size = strlen(root_device) + 1;
    315 	return (sysctl_lookup(SYSCTLFN_CALL(&node)));
    316 }
    317 
    318 static int
    319 sysctl_machdep_booted_kernel(SYSCTLFN_ARGS)
    320 {
    321 	struct sysctlnode node = *rnode;
    322 
    323 	node.sysctl_data = some permutation on booted_kernel;
    324 	node.sysctl_size = strlen(booted_kernel) + 1;
    325 	return (sysctl_lookup(SYSCTLFN_CALL(&node)));
    326 }
    327 #endif
    328 
    329 SYSCTL_SETUP(sysctl_machdep_setup, "sysctl machdep subtree setup")
    330 {
    331 
    332 	sysctl_createv(clog, 0, NULL, NULL,
    333 		       CTLFLAG_PERMANENT,
    334 		       CTLTYPE_NODE, "machdep", NULL,
    335 		       NULL, 0, NULL, 0,
    336 		       CTL_MACHDEP, CTL_EOL);
    337 
    338 	sysctl_createv(clog, 0, NULL, NULL,
    339 		       CTLFLAG_PERMANENT,
    340 		       CTLTYPE_STRUCT, "console_device", NULL,
    341 		       sysctl_consdev, 0, NULL, sizeof(dev_t),
    342 		       CTL_MACHDEP, CPU_CONSDEV, CTL_EOL);
    343 #if 0 /* XXX - Not yet... */
    344 	sysctl_createv(clog, 0, NULL, NULL,
    345 		       CTLFLAG_PERMANENT,
    346 		       CTLTYPE_STRING, "root_device", NULL,
    347 		       sysctl_machdep_root_device, 0, NULL, 0,
    348 		       CTL_MACHDEP, CPU_ROOT_DEVICE, CTL_EOL);
    349 	sysctl_createv(clog, 0, NULL, NULL,
    350 		       CTLFLAG_PERMANENT,
    351 		       CTLTYPE_STRING, "booted_kernel", NULL,
    352 		       sysctl_machdep_booted_kernel, 0, NULL, 0,
    353 		       CTL_MACHDEP, CPU_BOOTED_KERNEL, CTL_EOL);
    354 #endif
    355 }
    356 
    357 /* See: sig_machdep.c */
    358 
    359 /*
    360  * Do a sync in preparation for a reboot.
    361  * XXX - This could probably be common code.
    362  * XXX - And now, most of it is in vfs_shutdown()
    363  * XXX - Put waittime checks in there too?
    364  */
    365 int waittime = -1;	/* XXX - Who else looks at this? -gwr */
    366 static void
    367 reboot_sync(void)
    368 {
    369 
    370 	/* Check waittime here to localize its use to this function. */
    371 	if (waittime >= 0)
    372 		return;
    373 	waittime = 0;
    374 	vfs_shutdown();
    375 }
    376 
    377 /*
    378  * Common part of the BSD and SunOS reboot system calls.
    379  */
    380 __dead void
    381 cpu_reboot(int howto, char *user_boot_string)
    382 {
    383 	/* Note: this string MUST be static! */
    384 	static char bootstr[128];
    385 	char *p;
    386 
    387 	/* If system is cold, just halt. (early panic?) */
    388 	if (cold)
    389 		goto haltsys;
    390 
    391 	/* Un-blank the screen if appropriate. */
    392 	cnpollc(1);
    393 
    394 	if ((howto & RB_NOSYNC) == 0) {
    395 		reboot_sync();
    396 		/*
    397 		 * If we've been adjusting the clock, the todr
    398 		 * will be out of synch; adjust it now.
    399 		 *
    400 		 * XXX - However, if the kernel has been sitting in ddb,
    401 		 * the time will be way off, so don't set the HW clock!
    402 		 * XXX - Should do sanity check against HW clock. -gwr
    403 		 */
    404 		/* resettodr(); */
    405 	}
    406 
    407 	/* Disable interrupts. */
    408 	splhigh();
    409 
    410 	/* Write out a crash dump if asked. */
    411 	if (howto & RB_DUMP)
    412 		dumpsys();
    413 
    414 	/* run any shutdown hooks */
    415 	doshutdownhooks();
    416 
    417 	pmf_system_shutdown(boothowto);
    418 
    419 	if (howto & RB_HALT) {
    420 	haltsys:
    421 		printf("halted.\n");
    422 		sunmon_halt();
    423 	}
    424 
    425 	/*
    426 	 * Automatic reboot.
    427 	 */
    428 	if (user_boot_string)
    429 		strncpy(bootstr, user_boot_string, sizeof(bootstr));
    430 	else {
    431 		/*
    432 		 * Build our own boot string with an empty
    433 		 * boot device/file and (maybe) some flags.
    434 		 * The PROM will supply the device/file name.
    435 		 */
    436 		p = bootstr;
    437 		*p = '\0';
    438 		if (howto & (RB_KDB|RB_ASKNAME|RB_SINGLE)) {
    439 			/* Append the boot flags. */
    440 			*p++ = ' ';
    441 			*p++ = '-';
    442 			if (howto & RB_KDB)
    443 				*p++ = 'd';
    444 			if (howto & RB_ASKNAME)
    445 				*p++ = 'a';
    446 			if (howto & RB_SINGLE)
    447 				*p++ = 's';
    448 			*p = '\0';
    449 		}
    450 	}
    451 	printf("rebooting...\n");
    452 	sunmon_reboot(bootstr);
    453 	for (;;) ;
    454 	/*NOTREACHED*/
    455 }
    456 
    457 /*
    458  * These variables are needed by /sbin/savecore
    459  */
    460 uint32_t dumpmag = 0x8fca0101;	/* magic number */
    461 int 	dumpsize = 0;		/* pages */
    462 long	dumplo = 0; 		/* blocks */
    463 
    464 #define DUMP_EXTRA	1	/* CPU-dependent extra pages */
    465 
    466 /*
    467  * This is called by main to set dumplo, dumpsize.
    468  * Dumps always skip the first PAGE_SIZE of disk space
    469  * in case there might be a disk label stored there.
    470  * If there is extra space, put dump at the end to
    471  * reduce the chance that swapping trashes it.
    472  */
    473 void
    474 cpu_dumpconf(void)
    475 {
    476 	int devblks;	/* size of dump device in blocks */
    477 	int dumpblks;	/* size of dump image in blocks */
    478 
    479 	if (dumpdev == NODEV)
    480 		return;
    481 
    482 	devblks = bdev_size(dumpdev);
    483 	if (devblks <= ctod(1))
    484 		return;
    485 	devblks &= ~(ctod(1) - 1);
    486 
    487 	/*
    488 	 * Note: savecore expects dumpsize to be the
    489 	 * number of pages AFTER the dump header.
    490 	 */
    491 	dumpsize = physmem; 	/* pages */
    492 
    493 	/* Position dump image near end of space, page aligned. */
    494 	dumpblks = ctod(physmem + DUMP_EXTRA);
    495 	dumplo = devblks - dumpblks;
    496 
    497 	/* If it does not fit, truncate it by moving dumplo. */
    498 	/* Note: Must force signed comparison. */
    499 	if (dumplo < ((long)ctod(1))) {
    500 		dumplo = ctod(1);
    501 		dumpsize = dtoc(devblks - dumplo) - DUMP_EXTRA;
    502 	}
    503 }
    504 
    505 /* Note: gdb looks for "dumppcb" in a kernel crash dump. */
    506 struct pcb dumppcb;
    507 
    508 /*
    509  * Write a crash dump.  The format while in swap is:
    510  *   kcore_seg_t cpu_hdr;
    511  *   cpu_kcore_hdr_t cpu_data;
    512  *   padding (PAGE_SIZE-sizeof(kcore_seg_t))
    513  *   pagemap (2*PAGE_SIZE)
    514  *   physical memory...
    515  */
    516 void
    517 dumpsys(void)
    518 {
    519 	const struct bdevsw *dsw;
    520 	kcore_seg_t *kseg_p;
    521 	cpu_kcore_hdr_t *chdr_p;
    522 	struct sun3x_kcore_hdr *sh;
    523 	phys_ram_seg_t *crs_p;
    524 	char *vaddr;
    525 	paddr_t paddr;
    526 	int psize, todo, seg, segsz;
    527 	daddr_t blkno;
    528 	int error = 0;
    529 
    530 	if (dumpdev == NODEV)
    531 		return;
    532 	dsw = bdevsw_lookup(dumpdev);
    533 	if (dsw == NULL || dsw->d_psize == NULL)
    534 		return;
    535 
    536 	/*
    537 	 * For dumps during autoconfiguration,
    538 	 * if dump device has already configured...
    539 	 */
    540 	if (dumpsize == 0)
    541 		cpu_dumpconf();
    542 	if (dumplo <= 0) {
    543 		printf("\ndump to dev %u,%u not possible\n",
    544 		    major(dumpdev), minor(dumpdev));
    545 		return;
    546 	}
    547 	savectx(&dumppcb);
    548 
    549 	psize = bdev_size(dumpdev);
    550 	if (psize == -1) {
    551 		printf("dump area unavailable\n");
    552 		return;
    553 	}
    554 
    555 	printf("\ndumping to dev %u,%u offset %ld\n",
    556 	    major(dumpdev), minor(dumpdev), dumplo);
    557 
    558 	/*
    559 	 * Prepare the dump header
    560 	 */
    561 	blkno = dumplo;
    562 	todo = dumpsize;	/* pages */
    563 	vaddr = (char *)dumppage;
    564 	memset(vaddr, 0, PAGE_SIZE);
    565 
    566 	/* Set pointers to all three parts. */
    567 	kseg_p = (kcore_seg_t *)vaddr;
    568 	chdr_p = (cpu_kcore_hdr_t *)(kseg_p + 1);
    569 	sh = &chdr_p->un._sun3x;
    570 
    571 	/* Fill in kcore_seg_t part. */
    572 	CORE_SETMAGIC(*kseg_p, KCORE_MAGIC, MID_MACHINE, CORE_CPU);
    573 	kseg_p->c_size = (ctob(DUMP_EXTRA) - sizeof(*kseg_p));
    574 
    575 	/* Fill in cpu_kcore_hdr_t part. */
    576 	strncpy(chdr_p->name, kernel_arch, sizeof(chdr_p->name));
    577 	chdr_p->page_size = PAGE_SIZE;
    578 	chdr_p->kernbase = KERNBASE3X;
    579 
    580 	/* Fill in the sun3x_kcore_hdr part. */
    581 	pmap_kcore_hdr(sh);
    582 
    583 	/* Write out the dump header. */
    584 	error = (*dsw->d_dump)(dumpdev, blkno, vaddr, PAGE_SIZE);
    585 	if (error)
    586 		goto fail;
    587 	blkno += btodb(PAGE_SIZE);
    588 
    589 	/*
    590 	 * Now dump physical memory.  Note that physical memory
    591 	 * might NOT be congiguous, so do it by segments.
    592 	 */
    593 
    594 	vaddr = (char *)vmmap;	/* Borrow /dev/mem VA */
    595 
    596 	for (seg = 0; seg < SUN3X_NPHYS_RAM_SEGS; seg++) {
    597 		crs_p = &sh->ram_segs[seg];
    598 		paddr = crs_p->start;
    599 		segsz = crs_p->size;
    600 
    601 		while (todo && (segsz > 0)) {
    602 
    603 			/* Print pages left after every 16. */
    604 			if ((todo & 0xf) == 0)
    605 				printf_nolog("\r%4d", todo);
    606 
    607 			/* Make a temporary mapping for the page. */
    608 			pmap_kenter_pa(vmmap, paddr | PMAP_NC, VM_PROT_READ, 0);
    609 			pmap_update(pmap_kernel());
    610 			error = (*dsw->d_dump)(dumpdev, blkno, vaddr,
    611 					       PAGE_SIZE);
    612 			pmap_kremove(vmmap, PAGE_SIZE);
    613 			pmap_update(pmap_kernel());
    614 			if (error)
    615 				goto fail;
    616 			paddr += PAGE_SIZE;
    617 			segsz -= PAGE_SIZE;
    618 			blkno += btodb(PAGE_SIZE);
    619 			todo--;
    620 		}
    621 	}
    622 	printf("\rdump succeeded\n");
    623 	return;
    624 fail:
    625 	printf(" dump error=%d\n", error);
    626 }
    627 
    628 static void
    629 initcpu(void)
    630 {
    631 	/* XXX: Enable RAM parity/ECC checking? */
    632 	/* XXX: parityenable(); */
    633 
    634 #ifdef	HAVECACHE
    635 	cache_enable();
    636 #endif
    637 }
    638 
    639 /* straptrap() in trap.c */
    640 
    641 /* from hp300: badaddr() */
    642 /* peek_byte(), peek_word() moved to bus_subr.c */
    643 
    644 /* XXX: parityenable() ? */
    645 /* regdump() moved to regdump.c */
    646 
    647 /*
    648  * cpu_exec_aout_makecmds():
    649  *	CPU-dependent a.out format hook for execve().
    650  *
    651  * Determine if the given exec package refers to something which we
    652  * understand and, if so, set up the vmcmds for it.
    653  */
    654 int
    655 cpu_exec_aout_makecmds(struct lwp *l, struct exec_package *epp)
    656 {
    657 	return ENOEXEC;
    658 }
    659 
    660 int
    661 mm_md_physacc(paddr_t pa, vm_prot_t prot)
    662 {
    663 
    664 	return pmap_pa_exists(pa) ? 0 : EFAULT;
    665 }
    666 
    667 bool
    668 mm_md_direct_mapped_phys(paddr_t paddr, vaddr_t *vaddr)
    669 {
    670 	extern paddr_t avail_start;
    671 
    672 	if (paddr >= avail_start)
    673 		return false;
    674 	*vaddr = KERNBASE3X + paddr;
    675 	return true;
    676 }
    677 
    678 /*
    679  * Allow access to the PROM mapping similiar to uvm_kernacc().
    680  */
    681 int
    682 mm_md_kernacc(void *ptr, vm_prot_t prot, bool *handled)
    683 {
    684 
    685 	if ((vaddr_t)ptr < SUN3X_PROM_BASE || (vaddr_t)ptr > SUN3X_MONEND) {
    686 		*handled = false;
    687 		return 0;
    688 	}
    689 
    690 	*handled = true;
    691 	/* Read in the PROM itself is OK. */
    692 	if ((prot & VM_PROT_WRITE) == 0)
    693 		return 0;
    694 
    695 	/* PROM data page is OK for read/write. */
    696 	if ((vaddr_t)ptr >= SUN3X_MONDATA &&
    697 	    (vaddr_t)ptr < SUN3X_MONDATA + PAGE_SIZE)
    698 		return 0;
    699 	return EFAULT;
    700 }
    701 
    702 #ifdef MODULAR
    703 /*
    704  * Push any modules loaded by the bootloader etc.
    705  */
    706 void
    707 module_init_md(void)
    708 {
    709 }
    710 #endif
    711