machdep.c revision 1.51 1 /* $NetBSD: machdep.c,v 1.51 1999/05/26 19:16:35 thorpej 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, VM_MAP_PAGEABLE, 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, VM_MAP_INTRSAFE,
290 FALSE, NULL);
291
292 /*
293 * Initialize callouts
294 */
295 callfree = callout;
296 for (i = 1; i < ncallout; i++)
297 callout[i-1].c_next = &callout[i];
298 callout[i-1].c_next = NULL;
299
300 format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
301 printf("avail memory = %s\n", pbuf);
302 format_bytes(pbuf, sizeof(pbuf), bufpages * CLBYTES);
303 printf("using %d buffers containing %s of memory\n", nbuf, pbuf);
304
305 /*
306 * Tell the VM system that writing to kernel text isn't allowed.
307 * If we don't, we might end up COW'ing the text segment!
308 */
309 if (uvm_map_protect(kernel_map, (vm_offset_t) kernel_text,
310 m68k_trunc_page((vm_offset_t) etext),
311 UVM_PROT_READ|UVM_PROT_EXEC, TRUE) != KERN_SUCCESS)
312 panic("can't protect kernel text");
313
314 /*
315 * Allocate a virtual page (for use by /dev/mem)
316 * This page is handed to pmap_enter() therefore
317 * it has to be in the normal kernel VA range.
318 */
319 vmmap = uvm_km_valloc_wait(kernel_map, NBPG);
320
321 /*
322 * Create the DVMA maps.
323 */
324 dvma_init();
325
326 /*
327 * Set up CPU-specific registers, cache, etc.
328 */
329 initcpu();
330
331 /*
332 * Set up buffers, so they can be used to read disk labels.
333 */
334 bufinit();
335 }
336
337 /*
338 * Set registers on exec.
339 */
340 void
341 setregs(p, pack, stack)
342 struct proc *p;
343 struct exec_package *pack;
344 u_long stack;
345 {
346 struct trapframe *tf = (struct trapframe *)p->p_md.md_regs;
347
348 tf->tf_sr = PSL_USERSET;
349 tf->tf_pc = pack->ep_entry & ~1;
350 tf->tf_regs[D0] = 0;
351 tf->tf_regs[D1] = 0;
352 tf->tf_regs[D2] = 0;
353 tf->tf_regs[D3] = 0;
354 tf->tf_regs[D4] = 0;
355 tf->tf_regs[D5] = 0;
356 tf->tf_regs[D6] = 0;
357 tf->tf_regs[D7] = 0;
358 tf->tf_regs[A0] = 0;
359 tf->tf_regs[A1] = 0;
360 tf->tf_regs[A2] = (int)PS_STRINGS;
361 tf->tf_regs[A3] = 0;
362 tf->tf_regs[A4] = 0;
363 tf->tf_regs[A5] = 0;
364 tf->tf_regs[A6] = 0;
365 tf->tf_regs[SP] = stack;
366
367 /* restore a null state frame */
368 p->p_addr->u_pcb.pcb_fpregs.fpf_null = 0;
369 if (fputype)
370 m68881_restore(&p->p_addr->u_pcb.pcb_fpregs);
371
372 p->p_md.md_flags = 0;
373 }
374
375 /*
376 * Info for CTL_HW
377 */
378 char machine[16] = MACHINE; /* from <machine/param.h> */
379 char kernel_arch[16] = "sun3x"; /* XXX needs a sysctl node */
380 char cpu_model[120];
381
382 /*
383 * XXX - Should empirically estimate the divisor...
384 * Note that the value of delay_divisor is roughly
385 * 2048 / cpuclock (where cpuclock is in MHz).
386 */
387 int delay_divisor = 62; /* assume the fastest (33 MHz) */
388
389 void
390 identifycpu()
391 {
392 u_char machtype;
393
394 machtype = identity_prom.idp_machtype;
395 if ((machtype & IDM_ARCH_MASK) != IDM_ARCH_SUN3X) {
396 printf("Bad IDPROM arch!\n");
397 sunmon_abort();
398 }
399
400 cpu_machine_id = machtype;
401 switch (cpu_machine_id) {
402
403 case SUN3X_MACH_80:
404 cpu_string = "80"; /* Hydra */
405 delay_divisor = 102; /* 20 MHz */
406 cpu_has_vme = FALSE;
407 break;
408
409 case SUN3X_MACH_470:
410 cpu_string = "470"; /* Pegasus */
411 delay_divisor = 62; /* 33 MHz */
412 cpu_has_vme = TRUE;
413 break;
414
415 default:
416 printf("unknown sun3x model\n");
417 sunmon_abort();
418 }
419
420 /* Other stuff? (VAC, mc6888x version, etc.) */
421 /* Note: miniroot cares about the kernel_arch part. */
422 sprintf(cpu_model, "%s %s", kernel_arch, cpu_string);
423
424 printf("Model: %s\n", cpu_model);
425 }
426
427 /*
428 * machine dependent system variables.
429 */
430 int
431 cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
432 int *name;
433 u_int namelen;
434 void *oldp;
435 size_t *oldlenp;
436 void *newp;
437 size_t newlen;
438 struct proc *p;
439 {
440 int error;
441 dev_t consdev;
442
443 /* all sysctl names at this level are terminal */
444 if (namelen != 1)
445 return (ENOTDIR); /* overloaded */
446
447 switch (name[0]) {
448 case CPU_CONSDEV:
449 if (cn_tab != NULL)
450 consdev = cn_tab->cn_dev;
451 else
452 consdev = NODEV;
453 error = sysctl_rdstruct(oldp, oldlenp, newp,
454 &consdev, sizeof consdev);
455 break;
456
457 #if 0 /* XXX - Not yet... */
458 case CPU_ROOT_DEVICE:
459 error = sysctl_rdstring(oldp, oldlenp, newp, root_device);
460 break;
461
462 case CPU_BOOTED_KERNEL:
463 error = sysctl_rdstring(oldp, oldlenp, newp, booted_kernel);
464 break;
465 #endif
466
467 default:
468 error = EOPNOTSUPP;
469 }
470 return (error);
471 }
472
473 /* See: sig_machdep.c */
474
475 /*
476 * Do a sync in preparation for a reboot.
477 * XXX - This could probably be common code.
478 * XXX - And now, most of it is in vfs_shutdown()
479 * XXX - Put waittime checks in there too?
480 */
481 int waittime = -1; /* XXX - Who else looks at this? -gwr */
482 static void
483 reboot_sync __P((void))
484 {
485
486 /* Check waittime here to localize its use to this function. */
487 if (waittime >= 0)
488 return;
489 waittime = 0;
490 vfs_shutdown();
491 }
492
493 /*
494 * Common part of the BSD and SunOS reboot system calls.
495 */
496 __dead void
497 cpu_reboot(howto, user_boot_string)
498 int howto;
499 char *user_boot_string;
500 {
501 /* Note: this string MUST be static! */
502 static char bootstr[128];
503 char *p;
504
505 /* If system is cold, just halt. (early panic?) */
506 if (cold)
507 goto haltsys;
508
509 /* Un-blank the screen if appropriate. */
510 cnpollc(1);
511
512 if ((howto & RB_NOSYNC) == 0) {
513 reboot_sync();
514 /*
515 * If we've been adjusting the clock, the todr
516 * will be out of synch; adjust it now.
517 *
518 * XXX - However, if the kernel has been sitting in ddb,
519 * the time will be way off, so don't set the HW clock!
520 * XXX - Should do sanity check against HW clock. -gwr
521 */
522 /* resettodr(); */
523 }
524
525 /* Disable interrupts. */
526 splhigh();
527
528 /* Write out a crash dump if asked. */
529 if (howto & RB_DUMP)
530 dumpsys();
531
532 /* run any shutdown hooks */
533 doshutdownhooks();
534
535 if (howto & RB_HALT) {
536 haltsys:
537 printf("Kernel halted.\n");
538 #if 0
539 /*
540 * This calls the PROM monitor "exit_to_mon" function
541 * which appears to have problems... SunOS uses the
542 * "abort" function when you halt (bug work-around?)
543 * so we might as well do the same.
544 */
545 sunmon_halt(); /* provokes PROM monitor bug */
546 #else
547 sunmon_abort();
548 #endif
549 }
550
551 /*
552 * Automatic reboot.
553 */
554 if (user_boot_string)
555 strncpy(bootstr, user_boot_string, sizeof(bootstr));
556 else {
557 /*
558 * Build our own boot string with an empty
559 * boot device/file and (maybe) some flags.
560 * The PROM will supply the device/file name.
561 */
562 p = bootstr;
563 *p = '\0';
564 if (howto & (RB_KDB|RB_ASKNAME|RB_SINGLE)) {
565 /* Append the boot flags. */
566 *p++ = ' ';
567 *p++ = '-';
568 if (howto & RB_KDB)
569 *p++ = 'd';
570 if (howto & RB_ASKNAME)
571 *p++ = 'a';
572 if (howto & RB_SINGLE)
573 *p++ = 's';
574 *p = '\0';
575 }
576 }
577 printf("Kernel rebooting...\n");
578 sunmon_reboot(bootstr);
579 for (;;) ;
580 /*NOTREACHED*/
581 }
582
583 /*
584 * These variables are needed by /sbin/savecore
585 */
586 u_long dumpmag = 0x8fca0101; /* magic number */
587 int dumpsize = 0; /* pages */
588 long dumplo = 0; /* blocks */
589
590 /*
591 * This is called by main to set dumplo, dumpsize.
592 * Dumps always skip the first CLBYTES of disk space
593 * in case there might be a disk label stored there.
594 * If there is extra space, put dump at the end to
595 * reduce the chance that swapping trashes it.
596 */
597 void
598 cpu_dumpconf()
599 {
600 int nblks; /* size of dump area */
601 int maj;
602 int (*getsize)__P((dev_t));
603
604 /* Validate space in page zero for the kcore header. */
605 if (MSGBUFOFF < (sizeof(kcore_seg_t) + sizeof(cpu_kcore_hdr_t)))
606 panic("cpu_dumpconf: MSGBUFOFF too small");
607
608 if (dumpdev == NODEV)
609 return;
610
611 maj = major(dumpdev);
612 if (maj < 0 || maj >= nblkdev)
613 panic("dumpconf: bad dumpdev=0x%x", dumpdev);
614 getsize = bdevsw[maj].d_psize;
615 if (getsize == NULL)
616 return;
617 nblks = (*getsize)(dumpdev);
618 if (nblks <= ctod(1))
619 return;
620
621 /* Position dump image near end of space, page aligned. */
622 dumpsize = physmem; /* pages */
623 dumplo = nblks - ctod(dumpsize);
624 dumplo &= ~(ctod(1)-1);
625
626 /* If it does not fit, truncate it by moving dumplo. */
627 /* Note: Must force signed comparison. */
628 if (dumplo < ((long)ctod(1))) {
629 dumplo = ctod(1);
630 dumpsize = dtoc(nblks - dumplo);
631 }
632 }
633
634 /* Note: gdb looks for "dumppcb" in a kernel crash dump. */
635 struct pcb dumppcb;
636
637 /*
638 * Write a crash dump. The format while in swap is:
639 * kcore_seg_t cpu_hdr;
640 * cpu_kcore_hdr_t cpu_data;
641 * padding (NBPG-sizeof(kcore_seg_t))
642 * pagemap (2*NBPG)
643 * physical memory...
644 */
645 void
646 dumpsys()
647 {
648 struct bdevsw *dsw;
649 kcore_seg_t *kseg_p;
650 cpu_kcore_hdr_t *chdr_p;
651 struct sun3x_kcore_hdr *sh;
652 phys_ram_seg_t *crs_p;
653 char *vaddr;
654 vm_offset_t paddr;
655 int psize, todo, seg, segsz;
656 daddr_t blkno;
657 int error = 0;
658
659 msgbufenabled = 0;
660 if (dumpdev == NODEV)
661 return;
662
663 /*
664 * For dumps during autoconfiguration,
665 * if dump device has already configured...
666 */
667 if (dumpsize == 0)
668 cpu_dumpconf();
669 if (dumplo <= 0) {
670 printf("\ndump to dev %u,%u not possible\n", major(dumpdev),
671 minor(dumpdev));
672 return;
673 }
674 savectx(&dumppcb);
675
676 dsw = &bdevsw[major(dumpdev)];
677 psize = (*(dsw->d_psize))(dumpdev);
678 if (psize == -1) {
679 printf("dump area unavailable\n");
680 return;
681 }
682
683 printf("\ndumping to dev %u,%u offset %ld\n", major(dumpdev),
684 minor(dumpdev), dumplo);
685
686 /*
687 * We put the dump header is in physical page zero,
688 * so there is no extra work here to write it out.
689 * All we do is initialize the header.
690 */
691
692 /* Set pointers to all three parts. */
693 kseg_p = (kcore_seg_t *)KERNBASE;
694 chdr_p = (cpu_kcore_hdr_t *) (kseg_p + 1);
695 sh = &chdr_p->un._sun3x;
696
697 /* Fill in kcore_seg_t part. */
698 CORE_SETMAGIC(*kseg_p, KCORE_MAGIC, MID_MACHINE, CORE_CPU);
699 kseg_p->c_size = sizeof(*chdr_p);
700
701 /* Fill in cpu_kcore_hdr_t part. */
702 strncpy(chdr_p->name, kernel_arch, sizeof(chdr_p->name));
703 chdr_p->page_size = NBPG;
704 chdr_p->kernbase = KERNBASE;
705
706 /* Fill in the sun3x_kcore_hdr part. */
707 pmap_kcore_hdr(sh);
708
709 /*
710 * Now dump physical memory. Note that physical memory
711 * might NOT be congiguous, so do it by segments.
712 */
713
714 blkno = dumplo;
715 todo = dumpsize; /* pages */
716 vaddr = (char*)vmmap; /* Borrow /dev/mem VA */
717
718 for (seg = 0; seg < SUN3X_NPHYS_RAM_SEGS; seg++) {
719 crs_p = &sh->ram_segs[seg];
720 paddr = crs_p->start;
721 segsz = crs_p->size;
722 /*
723 * Our header lives in the first little bit of
724 * physical memory (not written separately), so
725 * we have to adjust the first ram segment size
726 * and start address to reflect the stolen RAM.
727 * (Nothing interesing in that RAM anyway 8^).
728 */
729 if (seg == 0) {
730 int adj = sizeof(*kseg_p) + sizeof(*chdr_p);
731 crs_p->start += adj;
732 crs_p->size -= adj;
733 }
734
735 while (todo && (segsz > 0)) {
736
737 /* Print pages left after every 16. */
738 if ((todo & 0xf) == 0)
739 printf("\r%4d", todo);
740
741 /* Make a temporary mapping for the page. */
742 pmap_enter(pmap_kernel(), vmmap, paddr | PMAP_NC,
743 VM_PROT_READ, FALSE, 0);
744 error = (*dsw->d_dump)(dumpdev, blkno, vaddr, NBPG);
745 pmap_remove(pmap_kernel(), vmmap, vmmap + NBPG);
746 if (error)
747 goto fail;
748 paddr += NBPG;
749 segsz -= NBPG;
750 blkno += btodb(NBPG);
751 todo--;
752 }
753 }
754 printf("\rdump succeeded\n");
755 return;
756 fail:
757 printf(" dump error=%d\n", error);
758 }
759
760 static void
761 initcpu()
762 {
763 /* XXX: Enable RAM parity/ECC checking? */
764 /* XXX: parityenable(); */
765
766 #ifdef HAVECACHE
767 cache_enable();
768 #endif
769 }
770
771 /* straptrap() in trap.c */
772
773 /* from hp300: badaddr() */
774 /* peek_byte(), peek_word() moved to bus_subr.c */
775
776 /* XXX: parityenable() ? */
777 /* regdump() moved to regdump.c */
778
779 /*
780 * cpu_exec_aout_makecmds():
781 * cpu-dependent a.out format hook for execve().
782 *
783 * Determine if the given exec package refers to something which we
784 * understand and, if so, set up the vmcmds for it.
785 */
786 int
787 cpu_exec_aout_makecmds(p, epp)
788 struct proc *p;
789 struct exec_package *epp;
790 {
791 return ENOEXEC;
792 }
793