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