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