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