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