1 /* $NetBSD: machdep.c,v 1.390 2026/11/15 15:16:24 thorpej Exp $ */ 2 3 /* 4 * Copyright (c) 1988 University of Utah. 5 * Copyright (c) 1982, 1990 The Regents of the University of California. 6 * 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. Neither the name of the University nor the names of its contributors 21 * may be used to endorse or promote products derived from this software 22 * without specific prior written permission. 23 * 24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 */ 36 37 /*- 38 * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo, 39 * Michael L. Finch, Bradley A. Grantham, and 40 * Lawrence A. Kesteloot 41 * All rights reserved. 42 * 43 * Redistribution and use in source and binary forms, with or without 44 * modification, are permitted provided that the following conditions 45 * are met: 46 * 1. Redistributions of source code must retain the above copyright 47 * notice, this list of conditions and the following disclaimer. 48 * 2. Redistributions in binary form must reproduce the above copyright 49 * notice, this list of conditions and the following disclaimer in the 50 * documentation and/or other materials provided with the distribution. 51 * 3. All advertising materials mentioning features or use of this software 52 * must display the following acknowledgement: 53 * This product includes software developed by the Alice Group. 54 * 4. The names of the Alice Group or any of its members may not be used 55 * to endorse or promote products derived from this software without 56 * specific prior written permission. 57 * 58 * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``AS IS'' AND ANY EXPRESS OR 59 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 60 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 61 * IN NO EVENT SHALL THE ALICE GROUP BE LIABLE FOR ANY DIRECT, INDIRECT, 62 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 63 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 64 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 65 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 66 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 67 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 68 * 69 */ 70 /* 71 * from: Utah $Hdr: machdep.c 1.63 91/04/24$ 72 * 73 * @(#)machdep.c 7.16 (Berkeley) 6/3/91 74 */ 75 76 #include <sys/cdefs.h> 77 __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.390 2026/11/15 15:16:24 thorpej Exp $"); 78 79 #include "opt_adb.h" 80 #include "opt_copy_symtab.h" 81 #include "opt_ddb.h" 82 #include "opt_ddbparam.h" 83 #include "opt_kgdb.h" 84 #include "opt_mac68k.h" 85 #include "opt_modular.h" 86 87 #include "akbd.h" 88 #include "audio.h" 89 #include "genfb.h" 90 #include "macfb.h" 91 #include "zsc.h" 92 93 #include <sys/param.h> 94 #include <sys/systm.h> 95 #include <sys/buf.h> 96 #include <sys/conf.h> 97 #include <sys/core.h> 98 #include <sys/exec.h> 99 #include <sys/extent.h> 100 #include <sys/file.h> 101 #include <sys/kcore.h> 102 #include <sys/kernel.h> 103 #include <sys/malloc.h> 104 #include <sys/mbuf.h> 105 #include <sys/mount.h> 106 #include <sys/msgbuf.h> 107 #include <sys/pool.h> 108 #include <sys/proc.h> 109 #include <sys/queue.h> 110 #include <sys/reboot.h> 111 #include <sys/signalvar.h> 112 #include <sys/syscallargs.h> 113 #include <sys/vnode.h> 114 #include <sys/ksyms.h> 115 #include <sys/module.h> 116 #ifdef KGDB 117 #include <sys/kgdb.h> 118 #endif 119 #include <sys/exec_elf.h> 120 #include <sys/device.h> 121 #include <sys/cpu.h> 122 123 #include <m68k/cacheops.h> 124 #include <m68k/mmu_40.h> 125 126 #include <machine/db_machdep.h> 127 #include <ddb/db_sym.h> 128 #include <ddb/db_extern.h> 129 130 #include <machine/autoconf.h> 131 #include <machine/cpu.h> 132 #include <machine/reg.h> 133 #include <machine/pcb.h> 134 #include <machine/psl.h> 135 #include <machine/pte.h> 136 #include <machine/kcore.h> /* XXX should be pulled in by sys/kcore.h */ 137 #include <machine/video.h> 138 139 #define MAXMEM 64*1024 /* XXX - from cmap.h */ 140 #include <uvm/uvm_extern.h> 141 142 #include <sys/sysctl.h> 143 144 #include <dev/cons.h> 145 #include <dev/mm.h> 146 147 #include <machine/iopreg.h> 148 #include <machine/psc.h> 149 #include <machine/viareg.h> 150 #include <mac68k/mac68k/macrom.h> 151 #include <mac68k/dev/adbvar.h> 152 #if NAKBD > 0 153 #include <mac68k/dev/akbdvar.h> 154 #endif 155 #if NMACFB > 0 156 #include <mac68k/dev/macfbvar.h> 157 #endif 158 #include <mac68k/dev/pm_direct.h> 159 #include <mac68k/dev/zs_cons.h> 160 161 #include "ksyms.h" 162 163 int symsize, end, *ssym, *esym; 164 165 struct mac68k_machine_S mac68k_machine; 166 167 volatile u_char *Via1Base, *Via2Base, *PSCBase = NULL; 168 u_long NuBusBase = NBBASE; 169 u_long IOBase; 170 171 vaddr_t SCSIBase; 172 173 /* These are used to map kernel space: */ 174 int numranges; 175 u_long low[8]; 176 u_long high[8]; 177 u_long last_page; /* PA of last physical page */ 178 vaddr_t newvideoaddr; 179 int vidlen; 180 181 extern paddr_t avail_start, avail_end; 182 183 extern int machineid; 184 185 /* These are used to map NuBus space: */ 186 #define NBMAXRANGES 16 187 int nbnumranges; /* = 0 == don't use the ranges */ 188 u_long nbphys[NBMAXRANGES]; /* Start physical addr of this range */ 189 u_long nblog[NBMAXRANGES]; /* Start logical addr of this range */ 190 long nblen[NBMAXRANGES]; /* Length of this range If the length is */ 191 /* negative, all phys addrs are the same. */ 192 193 /* Definitions for the variables defined in machine/video.h */ 194 struct mac68k_video mac68k_video; 195 196 /* Callback and cookie to run bell */ 197 int (*mac68k_bell_callback)(void *, int, int, int); 198 void * mac68k_bell_cookie; 199 200 int maxmem; /* max memory per process */ 201 202 /* 203 * Extent maps to manage all memory space, including I/O ranges. Allocate 204 * storage for 8 regions in each, initially. Later, iomem_malloc_safe 205 * will indicate that it's safe to use malloc() to dynamically allocate 206 * region descriptors. 207 * 208 * The extent maps are not static! Machine-dependent NuBus and on-board 209 * I/O routines need access to them for bus address space allocation. 210 */ 211 static long iomem_ex_storage[EXTENT_FIXED_STORAGE_SIZE(8) / sizeof(long)]; 212 struct extent *iomem_ex; 213 int iomem_malloc_safe; 214 215 static u_long get_physical(u_int, u_long *); 216 217 void initcpu(void); 218 int cpu_dumpsize(void); 219 int cpu_dump(int (*)(dev_t, daddr_t, void *, size_t), daddr_t *); 220 void cpu_init_kcore_hdr(void); 221 222 void getenvvars(u_long, char *); 223 static long getenv(const char *); 224 225 /* functions called from locore.s */ 226 void dumpsys(void); 227 void machine_init(paddr_t); 228 void nmihand(struct frame); 229 230 /* 231 * Machine-dependent crash dump header info. 232 */ 233 cpu_kcore_hdr_t cpu_kcore_hdr; 234 235 /* 236 * XXX: For zs serial driver. We always initialize the base address 237 * to avoid a bunch of #ifdefs. 238 */ 239 volatile unsigned char *sccA = 0; 240 241 /* 242 * Early initialization, before main() is called. 243 */ 244 void 245 machine_init(paddr_t nextpa) 246 { 247 int i; 248 249 /* 250 * Tell the VM system about available physical memory. 251 * Notice that we don't need to worry about avail_end here 252 * since it's equal to high[numranges-1]. 253 */ 254 for (i = 0; i < numranges; i++) { 255 if (low[i] <= avail_start && avail_start < high[i]) 256 uvm_page_physload(atop(avail_start), atop(high[i]), 257 atop(avail_start), atop(high[i]), 258 VM_FREELIST_DEFAULT); 259 else 260 uvm_page_physload(atop(low[i]), atop(high[i]), 261 atop(low[i]), atop(high[i]), 262 VM_FREELIST_DEFAULT); 263 } 264 265 #ifdef __HAVE_NEW_PMAP_68K 266 /* 267 * We mapped the kernel text read/write in pmap_bootstrap1() to 268 * deal with the vectors and Mac ROM variable region. Go ahead 269 * and write-protect &start - &etext here. 270 */ 271 extern char start[], etext[]; 272 pmap_protect(pmap_kernel(), m68k_round_page((vaddr_t)start), 273 m68k_trunc_page((vaddr_t)etext), 274 UVM_PROT_READ | UVM_PROT_EXEC); 275 pmap_update(pmap_kernel()); 276 #endif /* __HAVE_NEW_PMAP_68K */ 277 278 /* 279 * Initialize the I/O mem extent map. 280 * Note: we don't have to check the return value since 281 * creation of a fixed extent map will never fail (since 282 * descriptor storage has already been allocated). 283 * 284 * N.B. The iomem extent manages _all_ physical addresses 285 * on the machine. When the amount of RAM is found, all 286 * extents of RAM are allocated from the map. 287 */ 288 iomem_ex = extent_create("iomem", 0x0, 0xffffffff, 289 (void *)iomem_ex_storage, sizeof(iomem_ex_storage), 290 EX_NOCOALESCE|EX_NOWAIT); 291 292 /* Initialize the interrupt handlers. */ 293 intr_init(); 294 295 /* Initialize the IOPs (if present) */ 296 iop_init(1); 297 298 /* 299 * Initialize error message buffer (at end of core). 300 * high[numranges-1] was decremented in pmap_bootstrap. 301 */ 302 for (i = 0; i < btoc(MSGBUFSIZE); i++) 303 pmap_enter(pmap_kernel(), (vaddr_t)msgbufaddr + i * PAGE_SIZE, 304 high[numranges - 1] + i * PAGE_SIZE, 305 VM_PROT_READ|VM_PROT_WRITE, 306 VM_PROT_READ|VM_PROT_WRITE|PMAP_WIRED); 307 initmsgbuf(msgbufaddr, m68k_round_page(MSGBUFSIZE)); 308 pmap_update(pmap_kernel()); 309 } 310 311 /* 312 * Console initialization: called early on from main, 313 * before vm init or startup. Do enough configuration 314 * to choose and initialize a console. 315 */ 316 void 317 consinit(void) 318 { 319 /* 320 * Generic console: sys/dev/cons.c 321 * Initializes either ite or ser as console. 322 * Can be called from locore.s and init_main.c. (Ugh.) 323 */ 324 static int init; /* = 0 */ 325 326 if (!init) { 327 cninit(); 328 init = 1; 329 } else { 330 #if NAKBD > 0 && (NMACFB + NGENFB) > 0 331 /* 332 * XXX This is an evil hack on top of an evil hack! 333 * 334 * With the graybar stuff, we've got a catch-22: we need 335 * to do at least some console setup really early on, even 336 * before we're running with the mappings we need. On 337 * the other hand, we're not nearly ready to do anything 338 * with wscons or the ADB driver at that point. 339 * 340 * To get around this, maccninit() ignores the first call 341 * it gets (from cninit(), if not on a serial console). 342 * Once we're here, we call maccninit() again, which sets 343 * up the console devices and does the appropriate wscons 344 * initialization. 345 */ 346 if (mac68k_machine.serial_console == 0) { 347 void maccninit(struct consdev *); 348 maccninit(NULL); 349 } 350 #endif 351 352 mac68k_calibrate_delay(); 353 354 #if NZSC > 0 && defined(KGDB) 355 zs_kgdb_init(); 356 #endif 357 #if NKSYMS || defined(DDB) || defined(MODULAR) 358 /* 359 * Initialize kernel debugger, if compiled in. 360 */ 361 362 ksyms_addsyms_elf(symsize, ssym, esym); 363 #endif 364 365 if (boothowto & RB_KDB) { 366 #ifdef KGDB 367 /* XXX - Ask on console for kgdb_dev? */ 368 /* Note: this will just return if kgdb_dev==NODEV */ 369 kgdb_connect(1); 370 #else /* KGDB */ 371 #ifdef DDB 372 /* Enter DDB. We don't have a monitor PROM. */ 373 Debugger(); 374 #endif /* DDB */ 375 #endif /* KGDB */ 376 } 377 } 378 } 379 380 #define CURRENTBOOTERVER 111 381 382 /* 383 * cpu_startup: allocate memory for variable-sized tables, make 384 * (most of) kernel text read-only, and other miscellaneous bits 385 */ 386 void 387 cpu_startup(void) 388 { 389 int vers; 390 int xdelay; 391 392 /* 393 * Initialize the kernel crash dump header. 394 */ 395 cpu_init_kcore_hdr(); 396 397 cpu_startup_common(); 398 399 vers = mac68k_machine.booter_version; 400 if (vers < CURRENTBOOTERVER) { 401 /* fix older booters with indices, not versions */ 402 if (vers < 100) 403 vers += 99; 404 405 printf("\nYou booted with booter version %d.%d.\n", 406 vers / 100, vers % 100); 407 printf("Booter version %d.%d is necessary to fully support\n", 408 CURRENTBOOTERVER / 100, CURRENTBOOTERVER % 100); 409 printf("this kernel.\n\n"); 410 for (xdelay = 0; xdelay < 1000000; xdelay++); 411 } 412 413 extern u_int delay_factor; 414 printf("cpu: delay factor %d\n", delay_factor); 415 416 /* 417 * Set up CPU-specific registers, cache, etc. 418 */ 419 initcpu(); 420 421 /* Safe for extent allocation to use malloc now. */ 422 iomem_malloc_safe = 1; 423 } 424 425 void 426 initcpu(void) 427 { 428 /* Invalidate supervisor mode data cache. */ 429 DCIS(); 430 } 431 432 void doboot(void) __attribute__((__noreturn__)); 433 434 struct pcb dumppcb; 435 436 void 437 machine_powerdown(void) 438 { 439 /* First try to power down under VIA control. */ 440 via_powerdown(); 441 442 #ifndef MRG_ADB 443 /* 444 * Shut down machines whose power functions are accessed 445 * via modified ADB calls. adb_poweroff() is available 446 * only when the MRG ADB is not being used. 447 */ 448 adb_poweroff(); 449 #endif 450 /* 451 * Try to shutdown via the power manager (PowerBooks mainly). 452 */ 453 pm_poweroff(); 454 } 455 456 void 457 machine_reboot(int howto, char *bootstr) 458 { 459 extern u_long last_page; 460 461 /* Map the last physical page VA = PA for doboot() */ 462 pmap_enter(pmap_kernel(), (vaddr_t)last_page, (vaddr_t)last_page, 463 VM_PROT_ALL, VM_PROT_ALL|PMAP_WIRED); 464 pmap_update(pmap_kernel()); 465 doboot(); 466 } 467 468 /* 469 * Initialize the kernel crash dump header. 470 */ 471 void 472 cpu_init_kcore_hdr(void) 473 { 474 phys_ram_seg_t *ram_segs = pmap_init_kcore_hdr(&cpu_kcore_hdr); 475 int i; 476 477 /* mac68k has multiple RAM segments on some models. */ 478 for (i = 0; i < numranges; i++) { 479 ram_segs[i].start = low[i]; 480 ram_segs[i].size = high[i] - low[i]; 481 } 482 } 483 484 /* 485 * Compute the size of the machine-dependent crash dump header. 486 * Returns size in disk blocks. 487 */ 488 489 #define CHDRSIZE (ALIGN(sizeof(kcore_seg_t)) + ALIGN(sizeof(cpu_kcore_hdr_t))) 490 #define MDHDRSIZE roundup(CHDRSIZE, dbtob(1)) 491 492 int 493 cpu_dumpsize(void) 494 { 495 496 return btodb(MDHDRSIZE); 497 } 498 499 /* 500 * Called by dumpsys() to dump the machine-dependent header. 501 */ 502 int 503 cpu_dump(int (*dump)(dev_t, daddr_t, void *, size_t), daddr_t *blknop) 504 { 505 int buf[MDHDRSIZE / sizeof(int)]; 506 cpu_kcore_hdr_t *chdr; 507 kcore_seg_t *kseg; 508 int error; 509 510 kseg = (kcore_seg_t *)buf; 511 chdr = (cpu_kcore_hdr_t *)&buf[ALIGN(sizeof(kcore_seg_t)) / 512 sizeof(int)]; 513 514 /* Create the segment header. */ 515 CORE_SETMAGIC(*kseg, KCORE_MAGIC, MID_MACHINE, CORE_CPU); 516 kseg->c_size = MDHDRSIZE - ALIGN(sizeof(kcore_seg_t)); 517 518 memcpy(chdr, &cpu_kcore_hdr, sizeof(cpu_kcore_hdr_t)); 519 error = (*dump)(dumpdev, *blknop, (void *)buf, sizeof(buf)); 520 *blknop += btodb(sizeof(buf)); 521 return (error); 522 } 523 524 /* 525 * These variables are needed by /sbin/savecore 526 */ 527 u_int32_t dumpmag = 0x8fca0101; /* magic number */ 528 int dumpsize = 0; /* pages */ 529 long dumplo = 0; /* blocks */ 530 531 /* 532 * This is called by main to set dumplo and dumpsize. 533 * Dumps always skip the first PAGE_SIZE of disk space in 534 * case there might be a disk label stored there. If there 535 * is extra space, put dump at the end to reduce the chance 536 * that swapping trashes it. 537 */ 538 void 539 cpu_dumpconf(void) 540 { 541 cpu_kcore_hdr_t *h = &cpu_kcore_hdr; 542 struct m68k_kcore_hdr *m = &h->un._m68k; 543 int chdrsize; /* size of dump header */ 544 int nblks; /* size of dump area */ 545 int i; 546 547 if (dumpdev == NODEV) 548 return; 549 550 nblks = bdev_size(dumpdev); 551 chdrsize = cpu_dumpsize(); 552 553 dumpsize = 0; 554 for (i = 0; i < M68K_NPHYS_RAM_SEGS && m->ram_segs[i].size; i++) 555 dumpsize += btoc(m->ram_segs[i].size); 556 557 /* 558 * Check to see if we will fit. Note we always skip the 559 * first PAGE_SIZE in case there is a disk label there. 560 */ 561 if (nblks < (ctod(dumpsize) + chdrsize + ctod(1))) { 562 dumpsize = 0; 563 dumplo = -1; 564 return; 565 } 566 567 /* 568 * Put dump at the end of the partition. 569 */ 570 dumplo = (nblks - 1) - ctod(dumpsize) - chdrsize; 571 } 572 573 void 574 dumpsys(void) 575 { 576 cpu_kcore_hdr_t *h = &cpu_kcore_hdr; 577 struct m68k_kcore_hdr *m = &h->un._m68k; 578 const struct bdevsw *bdev; 579 daddr_t blkno; /* current block to write */ 580 /* dump routine */ 581 int (*dump)(dev_t, daddr_t, void *, size_t); 582 int pg; /* page being dumped */ 583 paddr_t maddr; /* PA being dumped */ 584 int seg; /* RAM segment being dumped */ 585 int error; /* error code from (*dump)() */ 586 vaddr_t vmmap = curcpu()->ci_tmpva_vmmap; 587 588 /* XXX initialized here because of gcc lossage */ 589 seg = 0; 590 maddr = m->ram_segs[seg].start; 591 pg = 0; 592 593 /* Make sure dump device is valid. */ 594 if (dumpdev == NODEV) 595 return; 596 bdev = bdevsw_lookup(dumpdev); 597 if (bdev == NULL) 598 return; 599 if (dumpsize == 0) { 600 cpu_dumpconf(); 601 if (dumpsize == 0) 602 return; 603 } 604 if (dumplo <= 0) { 605 printf("\ndump to dev %u,%u not possible\n", 606 major(dumpdev), minor(dumpdev)); 607 return; 608 } 609 dump = bdev->d_dump; 610 blkno = dumplo; 611 612 printf("\ndumping to dev %u,%u offset %ld\n", 613 major(dumpdev), minor(dumpdev), dumplo); 614 615 printf("dump "); 616 617 /* Write the dump header. */ 618 error = cpu_dump(dump, &blkno); 619 if (error) 620 goto bad; 621 622 for (pg = 0; pg < dumpsize; pg++) { 623 #define NPGMB (1024*1024/PAGE_SIZE) 624 /* print out how many MBs we have dumped */ 625 if (pg && (pg % NPGMB) == 0) 626 printf("%d ", pg / NPGMB); 627 #undef NPGMB 628 while (maddr >= 629 (m->ram_segs[seg].start + m->ram_segs[seg].size)) { 630 if (++seg >= M68K_NPHYS_RAM_SEGS || 631 m->ram_segs[seg].size == 0) { 632 error = EINVAL; /* XXX ?? */ 633 goto bad; 634 } 635 maddr = m->ram_segs[seg].start; 636 } 637 pmap_enter(pmap_kernel(), vmmap, maddr, 638 VM_PROT_READ, VM_PROT_READ|PMAP_WIRED); 639 pmap_update(pmap_kernel()); 640 641 error = (*dump)(dumpdev, blkno, (void *)vmmap, PAGE_SIZE); 642 bad: 643 switch (error) { 644 case 0: 645 maddr += PAGE_SIZE; 646 blkno += btodb(PAGE_SIZE); 647 break; 648 649 case ENXIO: 650 printf("device bad\n"); 651 return; 652 653 case EFAULT: 654 printf("device not ready\n"); 655 return; 656 657 case EINVAL: 658 printf("area improper\n"); 659 return; 660 661 case EIO: 662 printf("i/o error\n"); 663 return; 664 665 case EINTR: 666 printf("aborted from console\n"); 667 return; 668 669 default: 670 printf("error %d\n", error); 671 return; 672 } 673 } 674 printf("succeeded\n"); 675 } 676 677 /* 678 * Level 7 interrupts can be caused by the keyboard or parity errors. 679 */ 680 void nmihand(struct frame); 681 682 void 683 nmihand(struct frame frame) 684 { 685 static int nmihanddeep = 0; 686 687 if (nmihanddeep++) 688 return; 689 /* regdump((struct trapframe *)&frame, 128); 690 dumptrace(); */ 691 #ifdef DDB 692 printf("Panic switch: PC is 0x%x.\n", frame.f_pc); 693 Debugger(); 694 #endif 695 nmihanddeep = 0; 696 } 697 698 /* 699 * It should be possible to probe for the top of RAM, but Apple has 700 * memory structured so that in at least some cases, it's possible 701 * for RAM to be aliased across all memory--or for it to appear that 702 * there is more RAM than there really is. 703 */ 704 int get_top_of_ram(void); 705 706 int 707 get_top_of_ram(void) 708 { 709 return ((mac68k_machine.mach_memsize * (1024 * 1024)) - PAGE_SIZE); 710 } 711 712 /* 713 * machine dependent system variables. 714 */ 715 SYSCTL_SETUP(sysctl_machdep_setup, "sysctl machdep subtree setup") 716 { 717 718 sysctl_createv(clog, 0, NULL, NULL, 719 CTLFLAG_PERMANENT, 720 CTLTYPE_NODE, "machdep", NULL, 721 NULL, 0, NULL, 0, 722 CTL_MACHDEP, CTL_EOL); 723 724 sysctl_createv(clog, 0, NULL, NULL, 725 CTLFLAG_PERMANENT, 726 CTLTYPE_STRUCT, "console_device", NULL, 727 sysctl_consdev, 0, NULL, sizeof(dev_t), 728 CTL_MACHDEP, CPU_CONSDEV, CTL_EOL); 729 } 730 731 static char *envbuf = NULL; 732 733 /* 734 * getenvvars: Grab a few useful variables 735 */ 736 737 void 738 getenvvars(u_long flag, char *buf) 739 { 740 extern u_long bootdev; 741 extern u_long macos_boottime, MacOSROMBase; 742 extern long macos_gmtbias; 743 int root_scsi_id; 744 u_long root_ata_dev; 745 int i; 746 Elf_Ehdr *ehdr; 747 Elf_Shdr *shp; 748 vaddr_t minsym; 749 750 /* 751 * If flag & 0x80000000 == 0, then we're booting with the old booter 752 * and we should freak out. 753 */ 754 if ((flag & 0x80000000) == 0) { 755 /* Freak out; print something if that becomes available */ 756 } else 757 envbuf = buf; 758 759 /* These next two should give us mapped video & serial */ 760 /* We need these for pre-mapping graybars & echo, but probably */ 761 /* only on MacII or LC. -- XXX */ 762 /* mac68k_video.mv_kvaddr = getenv("MACOS_VIDEO"); */ 763 764 mac68k_video.mv_kvaddr = getenv("VIDEO_ADDR"); 765 mac68k_video.mv_stride = getenv("ROW_BYTES"); 766 mac68k_video.mv_depth = getenv("SCREEN_DEPTH"); 767 mac68k_video.mv_width = getenv("DIMENSIONS") & 0xffff; 768 mac68k_video.mv_height = (getenv("DIMENSIONS") >> 16) & 0xffff; 769 770 /* 771 * More misc stuff from booter. 772 */ 773 mac68k_machine.machineid = machineid = getenv("MACHINEID"); 774 mac68k_machine.mach_processor = getenv("PROCESSOR"); 775 #ifndef MAC68K_MEMSIZE 776 mac68k_machine.mach_memsize = getenv("MEMSIZE"); 777 #else 778 mac68k_machine.mach_memsize = MAC68K_MEMSIZE; 779 #endif 780 mac68k_machine.do_graybars = getenv("GRAYBARS"); 781 mac68k_machine.serial_boot_echo = getenv("SERIALECHO"); 782 mac68k_machine.serial_console = getenv("SERIALCONSOLE"); 783 784 mac68k_machine.modem_flags = getenv("SERIAL_MODEM_FLAGS"); 785 mac68k_machine.modem_cts_clk = getenv("SERIAL_MODEM_HSKICLK"); 786 mac68k_machine.modem_dcd_clk = getenv("SERIAL_MODEM_GPICLK"); 787 mac68k_machine.modem_d_speed = getenv("SERIAL_MODEM_DSPEED"); 788 mac68k_machine.print_flags = getenv("SERIAL_PRINT_FLAGS"); 789 mac68k_machine.print_cts_clk = getenv("SERIAL_PRINT_HSKICLK"); 790 mac68k_machine.print_dcd_clk = getenv("SERIAL_PRINT_GPICLK"); 791 mac68k_machine.print_d_speed = getenv("SERIAL_PRINT_DSPEED"); 792 mac68k_machine.booter_version = getenv("BOOTERVER"); 793 794 /* 795 * For now, we assume that the boot device is off the first controller. 796 * Booter versions 1.11.0 and later set a flag to tell us to construct 797 * bootdev using the SCSI ID passed in via the environment. 798 */ 799 root_scsi_id = getenv("ROOT_SCSI_ID"); 800 root_ata_dev = getenv("ROOT_ATA_DEV"); 801 if (((mac68k_machine.booter_version < CURRENTBOOTERVER) || 802 (flag & 0x40000)) && bootdev == 0) { 803 if (root_ata_dev) { 804 /* 805 * Consider only internal IDE drive. 806 * Buses(=channel) will be always 0. 807 * Because 68k Mac has only single channel. 808 */ 809 switch (root_ata_dev) { 810 default: /* fall through */ 811 case 0xffffffe0: /* buses,drive = 0,0 */ 812 case 0x20: /* buses,drive = 1,0 */ 813 case 0x21: /* buses,drive = 1,1 */ 814 bootdev = MAKEBOOTDEV(22, 0, 0, 0, 0); 815 break; 816 case 0xffffffe1: /* buses,drive = 0,1 */ 817 bootdev = MAKEBOOTDEV(22, 0, 0, 1, 0); 818 break; 819 } 820 } else { 821 bootdev = MAKEBOOTDEV(4, 0, 0, root_scsi_id, 0); 822 } 823 } 824 825 /* 826 * Booter 1.11.3 and later pass a BOOTHOWTO variable with the 827 * appropriate bits set. 828 */ 829 boothowto = getenv("BOOTHOWTO"); 830 if (boothowto == 0) 831 boothowto = getenv("SINGLE_USER"); 832 833 /* 834 * Get end of symbols for kernel debugging 835 */ 836 esym = (int *)getenv("END_SYM"); 837 #ifndef makeoptions_COPY_SYMTAB 838 if (esym == (int *)0) 839 #endif 840 esym = (int *)&end; 841 842 /* Get MacOS time */ 843 macos_boottime = getenv("BOOTTIME"); 844 845 /* Save GMT BIAS saved in Booter parameters dialog box */ 846 macos_gmtbias = getenv("GMTBIAS"); 847 848 /* 849 * Save globals stolen from MacOS 850 */ 851 852 ROMBase = (void *)getenv("ROMBASE"); 853 if (ROMBase == (void *)0) { 854 ROMBase = (void *)ROMBASE; 855 } 856 MacOSROMBase = (unsigned long)ROMBase; 857 TimeDBRA = getenv("TIMEDBRA"); 858 ADBDelay = (u_short)getenv("ADBDELAY"); 859 HwCfgFlags = getenv("HWCFGFLAGS"); 860 HwCfgFlags2 = getenv("HWCFGFLAG2"); 861 HwCfgFlags3 = getenv("HWCFGFLAG3"); 862 ADBReInit_JTBL = getenv("ADBREINIT_JTBL"); 863 mrg_ADBIntrPtr = (void *)getenv("ADBINTERRUPT"); 864 865 /* 866 * Check the ELF headers. 867 */ 868 869 ehdr = (void *)getenv("MARK_SYM"); 870 if (memcmp(ehdr->e_ident, ELFMAG, SELFMAG) != 0 || 871 ehdr->e_ident[EI_CLASS] != ELFCLASS32) { 872 return; 873 } 874 875 /* 876 * Find the end of the symbols and strings. 877 */ 878 879 minsym = ~0; 880 shp = (Elf_Shdr *)(end + ehdr->e_shoff); 881 for (i = 0; i < ehdr->e_shnum; i++) { 882 if (shp[i].sh_type != SHT_SYMTAB && 883 shp[i].sh_type != SHT_STRTAB) { 884 continue; 885 } 886 minsym = MIN(minsym, (vaddr_t)end + shp[i].sh_offset); 887 } 888 889 symsize = 1; 890 ssym = (int *)ehdr; 891 } 892 893 static long 894 getenv(const char *str) 895 { 896 /* 897 * Returns the value of the environment variable "str". 898 * 899 * Format of the buffer is "var=val\0var=val\0...\0var=val\0\0". 900 * 901 * Returns 0 if the variable is not there, and 1 if the variable is 902 * there without an "=val". 903 */ 904 905 char *s; 906 const char *s1; 907 int val, base; 908 909 s = envbuf; 910 while (1) { 911 for (s1 = str; *s1 && *s && *s != '='; s1++, s++) { 912 if (toupper(*s1) != toupper(*s)) { 913 break; 914 } 915 } 916 if (*s1) { /* No match */ 917 while (*s) { 918 s++; 919 } 920 s++; 921 if (*s == '\0') { /* Not found */ 922 /* Boolean flags are false (0) if not there */ 923 return 0; 924 } 925 continue; 926 } 927 if (*s == '=') {/* Has a value */ 928 s++; 929 val = 0; 930 base = 10; 931 if (*s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X')) { 932 base = 16; 933 s += 2; 934 } else 935 if (*s == '0') { 936 base = 8; 937 } 938 while (*s) { 939 if (toupper(*s) >= 'A' && toupper(*s) <= 'F') { 940 val = val * base + toupper(*s) - 'A' + 10; 941 } else { 942 val = val * base + (*s - '0'); 943 } 944 s++; 945 } 946 return val; 947 } else { /* TRUE (1) */ 948 return 1; 949 } 950 } 951 } 952 953 /* 954 * ROM Vector information for calling drivers in ROMs 955 * 956 * According to information published on the Web by Apple, there have 957 * been 9 different ROM families used in the Mac since the introduction 958 * of the Lisa/XL through the latest PowerMacs (May 96). Each family 959 * has zero or more version variants and in some cases a version variant 960 * may exist in one than one length format. Generally any one specific 961 * Mac will use a common set of routines within the ROM and a model-specific 962 * set also in the ROM. Luckily most of the routines used by NetBSD fall 963 * into the common set and can therefore be defined in the ROM Family. 964 * The offset addresses (address minus the ROM Base) of these common routines 965 * is the same for all machines which use that ROM. The offset addresses of 966 * the machine-specific routines is generally different for each machine. 967 * The machine-specific routines currently used by NetBSD/mac68k include: 968 * ADB_interrupt, PM_interrupt, ADBBase+130_interrupt, 969 * PMgrOp, jClkNoMem, Egret, InitEgret, and ADBReInit_JTBL 970 * 971 * It is possible that the routine at "jClkNoMem" is a common routine, but 972 * some variation in addresses has been seen. Also, execept for the very 973 * earliest machines which used Egret, the machine-specific value of the 974 * Egret routine may be unimportant as the machine-specific InitEgret code 975 * seems to always set the OS Trap vector for Egret. 976 * 977 * Only three of the nine different ROMs are important to NetBSD/mac68k. 978 * All other ROMs are used in early model Macs which are unable to run 979 * NetBSD due to other hardware limitations such as 68000 CPU, no MMU 980 * capability, or used only in PowerMacs. The three that we are interested 981 * in are: 982 * 983 * ROM Family $0178 - used in the II, IIx, IIcx, and SE/30 984 * All machines which use this ROM are now supported by NetBSD. 985 * There are no machine-dependent routines in these ROMs used by 986 * NetBSD/mac68k. This ROM is always 256K in length. 987 * 988 * ROM Family $067c - used in Classic, Color Classic, Color Classic II, 989 * IIci, IIsi, IIvi, IIvx, IIfx, LC, LC II, LC III, 990 * LC III+, LC475, LC520, LC550, LC575, LC580, LC630, 991 * MacTV, P200, P250, P275, P400/405/410/430, P450, 992 * P460/466/467, P475/476, P520, P550/560, P575/577/578, 993 * P580/588, P600, P630/631/635/636/637/638/640, Q605, 994 * Q610, C610, Q630, C650, Q650, Q700, Q800, Q900, Q950, 995 * PB140, PB145/145B, PB150, PB160, PB165, PB165c, PB170, 996 * PB180, PB180c, Duo 210, Duo 230, Duo 250, Duo 270c, 997 * Duo280, Duo 280c, PB 520/520c/540/540c/550 998 * This is the so-called "Universal" ROM used in almost all 68K 999 * machines. There are machine-dependent and machine-independent 1000 * routines used by NetBSD/mac68k in this ROM, and except for the 1001 * PowerBooks and the Duos, this ROM seems to be fairly well 1002 * known by NetBSD/mac68k. Desktop machines listed here that are 1003 * not yet running NetBSD probably only lack the necessary 1004 * addresses for the machine-dependent routines, or are waiting 1005 * for IDE disk support. This ROM is generally 1Meg in length, 1006 * however when used in the IIci, IIfx, IIsi, LC, Classic II, and 1007 * P400/405/410/430 it is 512K in length, and when used in the 1008 * PB 520/520c/540/540c/550 it is 2Meg in length. 1009 * 1010 * ROM Family - $077d - used in C660AV/Q660AV, Q840AV 1011 * The "Universal" ROM used on the PowerMacs and used in the 1012 * 68K line for the AV Macs only. When used in the 68K AV 1013 * machines the ROM is 2Meg in length; all uses in the PowerMac 1014 * use a length of 4Meg. 1015 * 1016 * Bob Nestor - <rnestor (at) metronet.com> 1017 */ 1018 static romvec_t romvecs[] = 1019 { 1020 /* Vectors verified for II, IIx, IIcx, SE/30 */ 1021 { /* 0 */ 1022 "Mac II class ROMs", 1023 (void *)0x40807002, /* where does ADB interrupt */ 1024 (void *)0x0, /* PM interrupt (?) */ 1025 (void *)0x4080a4d8, /* ADBBase + 130 interrupt; whatzit? */ 1026 (void *)0x40807778, /* CountADBs */ 1027 (void *)0x40807792, /* GetIndADB */ 1028 (void *)0x408077be, /* GetADBInfo */ 1029 (void *)0x408077c4, /* SetADBInfo */ 1030 (void *)0x40807704, /* ADBReInit */ 1031 (void *)0x408072fa, /* ADBOp */ 1032 (void *)0x0, /* PMgrOp */ 1033 (void *)0x4080d6d0, /* WriteParam */ 1034 (void *)0x4080d6fa, /* SetDateTime */ 1035 (void *)0x4080dbe8, /* InitUtil */ 1036 (void *)0x4080dd78, /* ReadXPRam */ 1037 (void *)0x4080dd82, /* WriteXPRam */ 1038 (void *)0x4080ddd6, /* jClkNoMem */ 1039 (void *)0x0, /* ADBAlternateInit */ 1040 (void *)0x0, /* Egret */ 1041 (void *)0x0, /* InitEgret */ 1042 (void *)0x0, /* ADBReInit_JTBL */ 1043 (void *)0x0, /* ROMResourceMap List Head */ 1044 (void *)0x40814c58, /* FixDiv */ 1045 (void *)0x40814b64, /* FixMul */ 1046 }, 1047 /* 1048 * Vectors verified for PB 140, PB 145, PB 170 1049 * (PB 100?) 1050 */ 1051 { /* 1 */ 1052 "Powerbook class ROMs", 1053 (void *)0x4088ae5e, /* ADB interrupt */ 1054 (void *)0x408885ec, /* PB ADB interrupt */ 1055 (void *)0x4088ae0e, /* ADBBase + 130 interrupt; whatzit? */ 1056 (void *)0x4080a360, /* CountADBs */ 1057 (void *)0x4080a37a, /* GetIndADB */ 1058 (void *)0x4080a3a6, /* GetADBInfo */ 1059 (void *)0x4080a3ac, /* SetADBInfo */ 1060 (void *)0x4080a752, /* ADBReInit */ 1061 (void *)0x4080a3dc, /* ADBOp */ 1062 (void *)0x408888ec, /* PMgrOp */ 1063 (void *)0x4080c05c, /* WriteParam */ 1064 (void *)0x4080c086, /* SetDateTime */ 1065 (void *)0x4080c5cc, /* InitUtil */ 1066 (void *)0x4080b186, /* ReadXPRam */ 1067 (void *)0x4080b190, /* WriteXPRam */ 1068 (void *)0x4080b1e4, /* jClkNoMem */ 1069 (void *)0x4080a818, /* ADBAlternateInit */ 1070 (void *)0x40814800, /* Egret */ 1071 (void *)0x408147c4, /* InitEgret */ 1072 (void *)0x0, /* ADBReInit_JTBL */ 1073 (void *)0x4087eb90, /* ROMResourceMap List Head */ 1074 (void *)0x4081c406, /* FixDiv */ 1075 (void *)0x4081c312, /* FixMul */ 1076 }, 1077 /* 1078 * Vectors verified for IIsi, IIvx, IIvi 1079 */ 1080 { /* 2 */ 1081 "Mac IIsi class ROMs", 1082 (void *)0x40814912, /* ADB interrupt */ 1083 (void *)0x0, /* PM ADB interrupt */ 1084 (void *)0x408150f0, /* ADBBase + 130 interrupt; whatzit? */ 1085 (void *)0x4080a360, /* CountADBs */ 1086 (void *)0x4080a37a, /* GetIndADB */ 1087 (void *)0x4080a3a6, /* GetADBInfo */ 1088 (void *)0x4080a3ac, /* SetADBInfo */ 1089 (void *)0x4080a752, /* ADBReInit */ 1090 (void *)0x4080a3dc, /* ADBOp */ 1091 (void *)0x0, /* PMgrOp */ 1092 (void *)0x4080c05c, /* WriteParam */ 1093 (void *)0x4080c086, /* SetDateTime */ 1094 (void *)0x4080c5cc, /* InitUtil */ 1095 (void *)0x4080b186, /* ReadXPRam */ 1096 (void *)0x4080b190, /* WriteXPRam */ 1097 (void *)0x4080b1e4, /* jClkNoMem */ 1098 (void *)0x4080a818, /* ADBAlternateInit */ 1099 (void *)0x40814800, /* Egret */ 1100 (void *)0x408147c4, /* InitEgret */ 1101 (void *)0x0, /* ADBReInit_JTBL */ 1102 (void *)0x4087eb90, /* ROMResourceMap List Head */ 1103 (void *)0x4081c406, /* FixDiv */ 1104 (void *)0x4081c312, /* FixMul */ 1105 }, 1106 /* 1107 * Vectors verified for Mac Classic II and LC II 1108 * (Other LC's? 680x0 Performas?) 1109 */ 1110 { /* 3 */ 1111 "Mac Classic II ROMs", 1112 (void *)0x40a14912, /* ADB interrupt */ 1113 (void *)0x0, /* PM ADB interrupt */ 1114 (void *)0x40a150f0, /* ADBBase + 130 interrupt; whatzit? */ 1115 (void *)0x40a0a360, /* CountADBs */ 1116 (void *)0x40a0a37a, /* GetIndADB */ 1117 (void *)0x40a0a3a6, /* GetADBInfo */ 1118 (void *)0x40a0a3ac, /* SetADBInfo */ 1119 (void *)0x40a0a752, /* ADBReInit */ 1120 (void *)0x40a0a3dc, /* ADBOp */ 1121 (void *)0x0, /* PMgrOp */ 1122 (void *)0x40a0c05c, /* WriteParam */ 1123 (void *)0x40a0c086, /* SetDateTime */ 1124 (void *)0x40a0c5cc, /* InitUtil */ 1125 (void *)0x40a0b186, /* ReadXPRam */ 1126 (void *)0x40a0b190, /* WriteXPRam */ 1127 (void *)0x40a0b1e4, /* jClkNoMem */ 1128 (void *)0x40a0a818, /* ADBAlternateInit */ 1129 (void *)0x40a14800, /* Egret */ 1130 (void *)0x40a147c4, /* InitEgret */ 1131 (void *)0x40a03ba6, /* ADBReInit_JTBL */ 1132 (void *)0x40a7eb90, /* ROMResourceMap List Head */ 1133 (void *)0x40a1c406, /* FixDiv, wild guess */ 1134 (void *)0x40a1c312, /* FixMul, wild guess */ 1135 }, 1136 /* 1137 * Vectors verified for IIci, Q700 1138 */ 1139 { /* 4 */ 1140 "Mac IIci/Q700 ROMs", 1141 (void *)0x4080a700, /* ADB interrupt */ 1142 (void *)0x0, /* PM ADB interrupt */ 1143 (void *)0x4080a5aa, /* ADBBase + 130 interrupt; whatzit? */ 1144 (void *)0x4080a360, /* CountADBs */ 1145 (void *)0x4080a37a, /* GetIndADB */ 1146 (void *)0x4080a3a6, /* GetADBInfo */ 1147 (void *)0x4080a3ac, /* SetADBInfo */ 1148 (void *)0x4080a752, /* ADBReInit */ 1149 (void *)0x4080a3dc, /* ADBOp */ 1150 (void *)0x0, /* PMgrOp */ 1151 (void *)0x4080c05c, /* WriteParam */ 1152 (void *)0x4080c086, /* SetDateTime */ 1153 (void *)0x4080c5cc, /* InitUtil */ 1154 (void *)0x4080b186, /* ReadXPRam */ 1155 (void *)0x4080b190, /* WriteXPRam */ 1156 (void *)0x4080b1e4, /* jClkNoMem */ 1157 (void *)0x4080a818, /* ADBAlternateInit */ 1158 (void *)0x0, /* Egret */ 1159 (void *)0x408147c4, /* InitEgret */ 1160 (void *)0x0, /* ADBReInit_JTBL */ 1161 (void *)0x4087eb90, /* ROMResourceMap List Head */ 1162 (void *)0x4081c406, /* FixDiv */ 1163 (void *)0x4081c312, /* FixMul */ 1164 }, 1165 /* 1166 * Vectors verified for Duo 230, PB 180, PB 160, PB 165/165C 1167 * (Duo 210? Duo 250? Duo 270?) 1168 */ 1169 { /* 5 */ 1170 "2nd Powerbook class ROMs", 1171 (void *)0x408b2eec, /* ADB interrupt */ 1172 (void *)0x408885ec, /* PB ADB interrupt */ 1173 (void *)0x408b2e76, /* ADBBase + 130 interrupt; whatzit? */ 1174 (void *)0x4080a360, /* CountADBs */ 1175 (void *)0x4080a37a, /* GetIndADB */ 1176 (void *)0x4080a3a6, /* GetADBInfo */ 1177 (void *)0x4080a3ac, /* SetADBInfo */ 1178 (void *)0x4080a752, /* ADBReInit */ 1179 (void *)0x4080a3dc, /* ADBOp */ 1180 (void *)0x408888ec, /* PMgrOp */ 1181 (void *)0x4080c05c, /* WriteParam */ 1182 (void *)0x4080c086, /* SetDateTime */ 1183 (void *)0x4080c5cc, /* InitUtil */ 1184 (void *)0x4080b186, /* ReadXPRam */ 1185 (void *)0x4080b190, /* WriteXPRam */ 1186 (void *)0x408b39b2, /* jClkNoMem */ /* From PB180 */ 1187 (void *)0x4080a818, /* ADBAlternateInit */ 1188 (void *)0x40814800, /* Egret */ 1189 (void *)0x40888400, /* InitPwrMgr */ /* From PB180 */ 1190 (void *)0x408cce28, /* ADBReInit_JTBL -- from PB160*/ 1191 (void *)0x4087eb90, /* ROMRsrcMap List Head -- from PB160*/ 1192 (void *)0x4081c406, /* FixDiv, wild guess */ 1193 (void *)0x4081c312, /* FixMul, wild guess */ 1194 }, 1195 /* 1196 * Vectors verified for the Quadra, Centris 650 1197 * (610, Q800?) 1198 */ 1199 { /* 6 */ 1200 "Quadra/Centris ROMs", 1201 (void *)0x408b2dea, /* ADB int */ 1202 (void *)0x0, /* PM intr */ 1203 (void *)0x408b2c72, /* ADBBase + 130 */ 1204 (void *)0x4080a360, /* CountADBs */ 1205 (void *)0x4080a37a, /* GetIndADB */ 1206 (void *)0x4080a3a6, /* GetADBInfo */ 1207 (void *)0x4080a3ac, /* SetADBInfo */ 1208 (void *)0x4080a752, /* ADBReInit */ 1209 (void *)0x4080a3dc, /* ADBOp */ 1210 (void *)0x40809ae6, /* PMgrOp */ 1211 (void *)0x4080c05c, /* WriteParam */ 1212 (void *)0x4080c086, /* SetDateTime */ 1213 (void *)0x4080c5cc, /* InitUtil */ 1214 (void *)0x4080b186, /* ReadXPRam */ 1215 (void *)0x4080b190, /* WriteXPRam */ 1216 (void *)0x408b39b6, /* jClkNoMem */ 1217 (void *)0x4080a818, /* ADBAlternateInit */ 1218 (void *)0x40814800, /* Egret */ 1219 (void *)0x408147c4, /* InitEgret */ 1220 (void *)0x408d2b64, /* ADBReInit_JTBL */ 1221 (void *)0x4087eb90, /* ROMResourceMap List Head */ 1222 (void *)0x4081c406, /* FixDiv, wild guess */ 1223 (void *)0x4081c312, /* FixMul, wild guess */ 1224 }, 1225 /* 1226 * Vectors verified for the Quadra 660AV 1227 * (Quadra 840AV?) 1228 */ 1229 { /* 7 */ 1230 "Quadra AV ROMs", 1231 (void *)0x4080cac6, /* ADB int */ 1232 (void *)0x0, /* PM int */ 1233 (void *)0x40805cd4, /* ADBBase + 130 */ 1234 (void *)0x40839600, /* CountADBs */ 1235 (void *)0x4083961a, /* GetIndADB */ 1236 (void *)0x40839646, /* GetADBInfo */ 1237 (void *)0x4083964c, /* SetADBInfo */ 1238 (void *)0x408397b8, /* ADBReInit */ 1239 (void *)0x4083967c, /* ADBOp */ 1240 (void *)0x0, /* PMgrOp */ 1241 (void *)0x4081141c, /* WriteParam */ 1242 (void *)0x4081144e, /* SetDateTime */ 1243 (void *)0x40811930, /* InitUtil */ 1244 (void *)0x4080b624, /* ReadXPRam */ 1245 (void *)0x4080b62e, /* WriteXPRam */ 1246 (void *)0x40806884, /* jClkNoMem */ 1247 (void *)0x408398c2, /* ADBAlternateInit */ 1248 (void *)0x4080cada, /* Egret */ 1249 (void *)0x4080de14, /* InitEgret */ 1250 (void *)0x408143b8, /* ADBReInit_JTBL */ 1251 (void *)0x409bdb60, /* ROMResourceMap List Head */ 1252 (void *)0x4083b3d8, /* FixDiv */ 1253 (void *)0x4083b2e4, /* FixMul */ 1254 }, 1255 /* 1256 * PB 540, PB 550 1257 * (PB 520? Duo 280?) 1258 */ 1259 { /* 8 */ 1260 "68040 PowerBook ROMs", 1261 (void *)0x400b2efc, /* ADB int */ 1262 (void *)0x400d8e66, /* PM int */ 1263 (void *)0x400b2e86, /* ADBBase + 130 */ 1264 (void *)0x4000a360, /* CountADBs */ 1265 (void *)0x4000a37a, /* GetIndADB */ 1266 (void *)0x4000a3a6, /* GetADBInfo */ 1267 (void *)0x4000a3ac, /* SetADBInfo */ 1268 (void *)0x4000a752, /* ADBReInit */ 1269 (void *)0x4000a3dc, /* ADBOp */ 1270 (void *)0x400d9302, /* PmgrOp */ 1271 (void *)0x4000c05c, /* WriteParam */ 1272 (void *)0x4000c086, /* SetDateTime */ 1273 (void *)0x4000c5cc, /* InitUtil */ 1274 (void *)0x4000b186, /* ReadXPRam */ 1275 (void *)0x4000b190, /* WriteXPRam */ 1276 (void *)0x400b3c08, /* jClkNoMem */ 1277 (void *)0x4000a818, /* ADBAlternateInit */ 1278 (void *)0x40009ae6, /* Egret */ /* From PB520 */ 1279 (void *)0x400147c4, /* InitEgret */ 1280 (void *)0x400a7a5c, /* ADBReInit_JTBL */ 1281 (void *)0x4007eb90, /* ROMResourceMap List Head */ 1282 (void *)0x4001c406, /* FixDiv, wild guess */ 1283 (void *)0x4001c312, /* FixMul, wild guess */ 1284 }, 1285 /* 1286 * Verified for the Q605 1287 */ 1288 { /* 9 */ 1289 "Quadra/Centris 605 ROMs", 1290 (void *)0x408a9b56, /* ADB int */ 1291 (void *)0x0, /* PM int */ 1292 (void *)0x408b2f94, /* ADBBase + 130 */ 1293 (void *)0x4080a360, /* CountADBs */ 1294 (void *)0x4080a37a, /* GetIndADB */ 1295 (void *)0x4080a3a6, /* GetADBInfo */ 1296 (void *)0x4080a3ac, /* SetADBInfo */ 1297 (void *)0x4080a752, /* ADBReInit */ 1298 (void *)0x4080a3dc, /* ADBOp */ 1299 (void *)0x0, /* PmgrOp */ 1300 (void *)0x4080c05c, /* WriteParam */ 1301 (void *)0x4080c086, /* SetDateTime */ 1302 (void *)0x4080c5cc, /* InitUtil */ 1303 (void *)0x4080b186, /* ReadXPRam */ 1304 (void *)0x4080b190, /* WriteXPRam */ 1305 (void *)0x408b3bf8, /* jClkNoMem */ 1306 (void *)0x4080a818, /* ADBAlternateInit */ 1307 (void *)0x408a99c0, /* Egret */ 1308 (void *)0x408147c4, /* InitEgret */ 1309 (void *)0x408a82c0, /* ADBReInit_JTBL */ 1310 (void *)0x4087eb90, /* ROMResourceMap List Head */ 1311 (void *)0x4081c406, /* FixDiv */ 1312 (void *)0x4081c312, /* FixMul */ 1313 }, 1314 /* 1315 * Vectors verified for Duo 270c, PB150 1316 */ 1317 { /* 10 */ 1318 "Duo 270C ROMs", 1319 (void *)0x408b2efc, /* ADB interrupt */ 1320 (void *)0x408885ec, /* PB ADB interrupt */ 1321 (void *)0x408b2e86, /* ADBBase + 130 interrupt; whatzit? */ 1322 (void *)0x4080a360, /* CountADBs */ 1323 (void *)0x4080a37a, /* GetIndADB */ 1324 (void *)0x4080a3a6, /* GetADBInfo */ 1325 (void *)0x4080a3ac, /* SetADBInfo */ 1326 (void *)0x4080a752, /* ADBReInit */ 1327 (void *)0x4080a3dc, /* ADBOp */ 1328 (void *)0x408888ec, /* PMgrOp */ 1329 (void *)0x4080c05c, /* WriteParam */ 1330 (void *)0x4080c086, /* SetDateTime */ 1331 (void *)0x4080c5cc, /* InitUtil */ 1332 (void *)0x4080b186, /* ReadXPRam */ 1333 (void *)0x4080b190, /* WriteXPRam */ 1334 (void *)0x408b3bf8, /* jClkNoMem */ /* from PB 150 */ 1335 (void *)0x4080a818, /* ADBAlternateInit */ 1336 (void *)0x40814800, /* Egret */ 1337 (void *)0x408147c4, /* InitEgret */ 1338 (void *)0x0, /* ADBReInit_JTBL */ 1339 (void *)0x4087eb90, /* ROMResourceMap List Head */ 1340 (void *)0x4081c406, /* FixDiv, wild guess */ 1341 (void *)0x4081c312, /* FixMul, wild guess */ 1342 }, 1343 /* 1344 * Vectors verified for Performa/LC 550 1345 */ 1346 { /* 11 */ 1347 "P/LC 550 ROMs", 1348 (void *)0x408d16d6, /* ADB interrupt */ 1349 (void *)0x0, /* PB ADB interrupt */ 1350 (void *)0x408b2f84, /* ADBBase + 130 interrupt; whatzit? */ 1351 (void *)0x4080a360, /* CountADBs */ 1352 (void *)0x4080a37a, /* GetIndADB */ 1353 (void *)0x4080a3a6, /* GetADBInfo */ 1354 (void *)0x4080a3ac, /* SetADBInfo */ 1355 (void *)0x4080a752, /* ADBReInit */ 1356 (void *)0x4080a3dc, /* ADBOp */ 1357 (void *)0x0, /* PMgrOp */ 1358 (void *)0x4080c05c, /* WriteParam */ 1359 (void *)0x4080c086, /* SetDateTime */ 1360 (void *)0x4080c5cc, /* InitUtil */ 1361 (void *)0x4080b186, /* ReadXPRam */ 1362 (void *)0x4080b190, /* WriteXPRam */ 1363 (void *)0x408b3c04, /* jClkNoMem */ 1364 (void *)0x4080a818, /* ADBAlternateInit */ 1365 (void *)0x408d1450, /* Egret */ 1366 (void *)0x408147c4, /* InitEgret */ 1367 (void *)0x408d24a4, /* ADBReInit_JTBL */ 1368 (void *)0x4087eb90, /* ROMResourceMap List Head */ 1369 (void *)0x4081c406, /* FixDiv for P550 */ 1370 (void *)0x4081c312, /* FixMul for P550 */ 1371 }, 1372 /* 1373 * Vectors verified for the MacTV 1374 */ 1375 { /* 12 */ 1376 "MacTV ROMs", 1377 (void *)0x40acfed6, /* ADB interrupt */ 1378 (void *)0x0, /* PB ADB interrupt */ 1379 (void *)0x40ab2f84, /* ADBBase + 130 interrupt; whatzit? */ 1380 (void *)0x40a0a360, /* CountADBs */ 1381 (void *)0x40a0a37a, /* GetIndADB */ 1382 (void *)0x40a0a3a6, /* GetADBInfo */ 1383 (void *)0x40a0a3ac, /* SetADBInfo */ 1384 (void *)0x40a0a752, /* ADBReInit */ 1385 (void *)0x40a0a3dc, /* ADBOp */ 1386 (void *)0x0, /* PMgrOp */ 1387 (void *)0x40a0c05c, /* WriteParam */ 1388 (void *)0x40a0c086, /* SetDateTime */ 1389 (void *)0x40a0c5cc, /* InitUtil */ 1390 (void *)0x40a0b186, /* ReadXPRam */ 1391 (void *)0x40a0b190, /* WriteXPRam */ 1392 (void *)0x40ab3bf4, /* jClkNoMem */ 1393 (void *)0x40a0a818, /* ADBAlternateInit */ 1394 (void *)0x40acfd40, /* Egret */ 1395 (void *)0x40a147c4, /* InitEgret */ 1396 (void *)0x40a038a0, /* ADBReInit_JTBL */ 1397 (void *)0x40a7eb90, /* ROMResourceMap List Head */ 1398 (void *)0x40a1c406, /* FixDiv */ 1399 (void *)0x40a1c312, /* FixMul */ 1400 }, 1401 /* 1402 * Vectors verified for the Quadra630 1403 */ 1404 { /* 13 */ 1405 "Quadra630 ROMs", 1406 (void *)0x408a9bd2, /* ADB int */ 1407 (void *)0x0, /* PM intr */ 1408 (void *)0x408b2f94, /* ADBBase + 130 */ 1409 (void *)0x4080a360, /* CountADBs */ 1410 (void *)0x4080a37a, /* GetIndADB */ 1411 (void *)0x4080a3a6, /* GetADBInfo */ 1412 (void *)0x4080a3ac, /* SetADBInfo */ 1413 (void *)0x4080a752, /* ADBReInit */ 1414 (void *)0x4080a3dc, /* ADBOp */ 1415 (void *)0, /* PMgrOp */ 1416 (void *)0x4080c05c, /* WriteParam */ 1417 (void *)0x4080c086, /* SetDateTime */ 1418 (void *)0x4080c5cc, /* InitUtil */ 1419 (void *)0x4080b186, /* Wild guess at ReadXPRam */ 1420 (void *)0x4080b190, /* Wild guess at WriteXPRam */ 1421 (void *)0x408b39f4, /* jClkNoMem */ 1422 (void *)0x4080a818, /* ADBAlternateInit */ 1423 (void *)0x408a99c0, /* Egret */ 1424 (void *)0x408147c8, /* InitEgret */ 1425 (void *)0x408a7ef8, /* ADBReInit_JTBL */ 1426 (void *)0x4087eb90, /* ROMResourceMap List Head */ 1427 (void *)0x4081c406, /* FixDiv */ 1428 (void *)0x4081c312, /* FixMul */ 1429 }, 1430 /* 1431 * Vectors verified for LC III 1432 */ 1433 { /* 14 */ 1434 "LC III ROMs", 1435 (void *)0x40814912, /* ADB interrupt */ 1436 (void *)0x0, /* PM ADB interrupt */ 1437 (void *)0x408b2f94, /* ADBBase + 130 interrupt */ 1438 (void *)0x4080a360, /* CountADBs */ 1439 (void *)0x4080a37a, /* GetIndADB */ 1440 (void *)0x4080a3a6, /* GetADBInfo */ 1441 (void *)0x4080a3ac, /* SetADBInfo */ 1442 (void *)0x4080a752, /* ADBReInit */ 1443 (void *)0x4080a3dc, /* ADBOp */ 1444 (void *)0x0, /* PMgrOp */ 1445 (void *)0x4080c05c, /* WriteParam */ 1446 (void *)0x4080c086, /* SetDateTime */ 1447 (void *)0x4080c5cc, /* InitUtil */ 1448 (void *)0x4080b186, /* ReadXPRam */ 1449 (void *)0x4080b190, /* WriteXPRam */ 1450 (void *)0x408b39b6, /* jClkNoMem */ 1451 (void *)0x4080a818, /* ADBAlternateInit */ 1452 (void *)0x40814800, /* Egret */ 1453 (void *)0x408147c4, /* InitEgret */ 1454 (void *)0x408d2918, /* ADBReInit_JTBL */ 1455 (void *)0x4087eb90, /* ROMResourceMap List Head */ 1456 (void *)0x4081c406, /* FixDiv */ 1457 (void *)0x4081c312, /* FixMul */ 1458 }, 1459 /* 1460 * Vectors verified for the LC520 1461 */ 1462 { /* 15 */ 1463 "MacLC520 ROMs", 1464 (void *)0x408d16d6, /* ADB interrupt */ 1465 (void *)0x0, /* PB ADB interrupt */ 1466 (void *)0x408b2f84, /* ADBBase + 130 interrupt; whatzit? */ 1467 (void *)0x4080a360, /* CountADBs */ 1468 (void *)0x4080a37a, /* GetIndADB */ 1469 (void *)0x4080a3a6, /* GetADBInfo */ 1470 (void *)0x4080a3ac, /* SetADBInfo */ 1471 (void *)0x4080a752, /* ADBReInit */ 1472 (void *)0x4080a3dc, /* ADBOp */ 1473 (void *)0x0, /* PMgrOp */ 1474 (void *)0x4080c05c, /* WriteParam */ 1475 (void *)0x4080c086, /* SetDateTime */ 1476 (void *)0x4080c5cc, /* InitUtil */ 1477 (void *)0x4080b186, /* ReadXPRam */ 1478 (void *)0x4080b190, /* WriteXPRam */ 1479 (void *)0x408b3c04, /* jClkNoMem */ 1480 (void *)0x4080a818, /* ADBAlternateInit */ 1481 (void *)0x408d1450, /* Egret */ 1482 (void *)0x408147c4, /* InitEgret */ 1483 (void *)0x408d2460, /* ADBReInit_JTBL */ 1484 (void *)0x4087eb90, /* ROMResourceMap List Head */ 1485 (void *)0x4081c406, /* FixDiv for P520 */ 1486 (void *)0x4081c312, /* FixMul for P520 */ 1487 }, 1488 /* 1489 * Vectors verified for the LC 575/577/578 1490 */ 1491 { /* 16 */ 1492 "MacLC575 ROMs", 1493 (void *)0x408a9b56, /* ADB interrupt */ 1494 (void *)0x0, /* PB ADB interrupt */ 1495 (void *)0x408b2f94, /* ADBBase + 130 interrupt; whatzit? */ 1496 (void *)0x4080a360, /* CountADBs */ 1497 (void *)0x4080a37a, /* GetIndADB */ 1498 (void *)0x4080a3a6, /* GetADBInfo */ 1499 (void *)0x4080a3ac, /* SetADBInfo */ 1500 (void *)0x4080a752, /* ADBReInit */ 1501 (void *)0x4080a3dc, /* ADBOp */ 1502 (void *)0x0, /* PMgrOp */ 1503 (void *)0x4080c05c, /* WriteParam */ 1504 (void *)0x4080c086, /* SetDateTime */ 1505 (void *)0x4080c5cc, /* InitUtil */ 1506 (void *)0x4080b186, /* ReadXPRam */ 1507 (void *)0x4080b190, /* WriteXPRam */ 1508 (void *)0x408b3bf8, /* jClkNoMem */ 1509 (void *)0x4080a818, /* ADBAlternateInit */ 1510 (void *)0x408a99c0, /* Egret */ 1511 (void *)0x408147c4, /* InitEgret */ 1512 (void *)0x408a81a0, /* ADBReInit_JTBL */ 1513 (void *)0x4087eb90, /* ROMResourceMap List Head */ 1514 (void *)0x4081c406, /* FixDiv for P520 */ 1515 (void *)0x4081c312, /* FixMul for P520 */ 1516 }, 1517 /* 1518 * Vectors verified for the Quadra 950 1519 */ 1520 { /* 17 */ 1521 "Quadra950 class ROMs", 1522 (void *)0x40814912, /* ADB interrupt */ 1523 (void *)0x0, /* PM ADB interrupt */ 1524 (void *)0x4080a4d8, /* ADBBase + 130 interrupt; whatzit? */ 1525 (void *)0x4080a360, /* CountADBs */ 1526 (void *)0x4080a37a, /* GetIndADB */ 1527 (void *)0x4080a3a6, /* GetADBInfo */ 1528 (void *)0x4080a3ac, /* SetADBInfo */ 1529 (void *)0x4080a752, /* ADBReInit */ 1530 (void *)0x4080a3dc, /* ADBOp */ 1531 (void *)0x0, /* PMgrOp */ 1532 (void *)0x4080c05c, /* WriteParam */ 1533 (void *)0x4080c086, /* SetDateTime */ 1534 (void *)0x4080c5cc, /* InitUtil */ 1535 (void *)0x4080b186, /* ReadXPRam */ 1536 (void *)0x4080b190, /* WriteXPRam */ 1537 (void *)0x4080b1e4, /* jClkNoMem */ 1538 (void *)0x4080a818, /* ADBAlternateInit */ 1539 (void *)0x40814800, /* Egret */ 1540 (void *)0x408147c4, /* InitEgret */ 1541 (void *)0x408038bc, /* ADBReInit_JTBL */ 1542 (void *)0x4087eb90, /* ROMResourceMap List Head */ 1543 (void *)0x4081c406, /* FixDiv */ 1544 (void *)0x4081c312, /* FixMul */ 1545 }, 1546 /* 1547 * Vectors verified for the Mac IIfx 1548 */ 1549 { /* 18 */ 1550 "Mac IIfx ROMs", 1551 (void *)0x40809f4a, /* ADB interrupt */ 1552 (void *)0x0, /* PM ADB interrupt */ 1553 (void *)0x4080a4d8, /* ADBBase + 130 interrupt */ 1554 (void *)0x4080a360, /* CountADBs */ 1555 (void *)0x4080a37a, /* GetIndADB */ 1556 (void *)0x4080a3a6, /* GetADBInfo */ 1557 (void *)0x4080a3ac, /* SetADBInfo */ 1558 (void *)0x4080a752, /* ADBReInit */ 1559 (void *)0x4080a3dc, /* ADBOp */ 1560 (void *)0x0, /* PMgrOp */ 1561 (void *)0x4080c05c, /* WriteParam */ 1562 (void *)0x4080c086, /* SetDateTime */ 1563 (void *)0x4080c5cc, /* InitUtil */ 1564 (void *)0x4080b186, /* ReadXPRam */ 1565 (void *)0x4080b190, /* WriteXPRam */ 1566 (void *)0x4080b1e4, /* jClkNoMem */ 1567 (void *)0x4080a818, /* ADBAlternateInit */ 1568 (void *)0x0, /* Egret */ 1569 (void *)0x0, /* InitEgret */ 1570 (void *)0x408037c0, /* ADBReInit_JTBL */ 1571 (void *)0x4087eb90, /* ROMResourceMap List Head */ 1572 (void *)0x4081c406, /* FixDiv */ 1573 (void *)0x4081c312, /* FixMul */ 1574 }, 1575 /* 1576 * Vectors verified for the Performa 588 (and 580?) 1577 */ 1578 { /* 19 */ 1579 "Performa 580 ROMs", 1580 (void *) 0x4089a8be, /* ADB interrupt */ 1581 (void *) 0x0, /* PM ADB interrupt */ 1582 (void *) 0x408b2f94, /* ADBBase + 130 interrupt */ 1583 (void *) 0x4080a360, /* CountADBs */ 1584 (void *) 0x4080a37a, /* GetIndADB */ 1585 (void *) 0x4080a3a6, /* GetADBInfo */ 1586 (void *) 0x4080a3ac, /* SetADBInfo */ 1587 (void *) 0x4080a752, /* ADBReInit */ 1588 (void *) 0x4080a3dc, /* ADBOp */ 1589 (void *) 0x0, /* PMgrOp */ 1590 (void *) 0x4080c05c, /* WriteParam */ 1591 (void *) 0x4080c086, /* SetDateTime */ 1592 (void *) 0x4080c5cc, /* InitUtil */ 1593 (void *) 0x4080b186, /* ReadXPRam */ 1594 (void *) 0x4080b190, /* WriteXPRam */ 1595 (void *) 0x408b3bf4, /* jClkNoMem */ 1596 (void *) 0x4080a818, /* ADBAlternateInit */ 1597 (void *) 0x408a99c0, /* Egret */ 1598 (void *) 0x408147c8, /* InitEgret */ 1599 (void *) 0x408a7f74, /* ADBReInit_JTBL */ 1600 (void *) 0x4087eb90, /* ROMResourceMap List Head */ 1601 (void *) 0x4081c406, /* FixDiv */ 1602 (void *) 0x4081c312, /* FixMul */ 1603 }, 1604 /* Please fill these in! -BG */ 1605 }; 1606 1607 1608 struct cpu_model_info cpu_models[] = { 1609 1610 /* The first four. */ 1611 {MACH_MACII, "II ", "", MACH_CLASSII, &romvecs[0]}, 1612 {MACH_MACIIX, "IIx ", "", MACH_CLASSII, &romvecs[0]}, 1613 {MACH_MACIICX, "IIcx ", "", MACH_CLASSII, &romvecs[0]}, 1614 {MACH_MACSE30, "SE/30 ", "", MACH_CLASSII, &romvecs[0]}, 1615 1616 /* The rest of the II series... */ 1617 {MACH_MACIICI, "IIci ", "", MACH_CLASSIIci, &romvecs[4]}, 1618 {MACH_MACIISI, "IIsi ", "", MACH_CLASSIIsi, &romvecs[2]}, 1619 {MACH_MACIIVI, "IIvi ", "", MACH_CLASSIIvx, &romvecs[2]}, 1620 {MACH_MACIIVX, "IIvx ", "", MACH_CLASSIIvx, &romvecs[2]}, 1621 {MACH_MACIIFX, "IIfx ", "", MACH_CLASSIIfx, &romvecs[18]}, 1622 1623 /* The Centris/Quadra series. */ 1624 {MACH_MACQ700, "Quadra", " 700 ", MACH_CLASSQ, &romvecs[4]}, 1625 {MACH_MACQ900, "Quadra", " 900 ", MACH_CLASSQ, &romvecs[6]}, 1626 {MACH_MACQ950, "Quadra", " 950 ", MACH_CLASSQ, &romvecs[17]}, 1627 {MACH_MACQ800, "Quadra", " 800 ", MACH_CLASSQ, &romvecs[6]}, 1628 {MACH_MACQ650, "Quadra", " 650 ", MACH_CLASSQ, &romvecs[6]}, 1629 {MACH_MACC650, "Centris", " 650 ", MACH_CLASSQ, &romvecs[6]}, 1630 {MACH_MACQ605, "Quadra", " 605 ", MACH_CLASSQ, &romvecs[9]}, 1631 {MACH_MACQ605_33, "Quadra", " 605/33 ", MACH_CLASSQ, &romvecs[9]}, 1632 {MACH_MACC610, "Centris", " 610 ", MACH_CLASSQ, &romvecs[6]}, 1633 {MACH_MACQ610, "Quadra", " 610 ", MACH_CLASSQ, &romvecs[6]}, 1634 {MACH_MACQ630, "Quadra", " 630 ", MACH_CLASSQ2, &romvecs[13]}, 1635 {MACH_MACC660AV, "Centris", " 660AV ", MACH_CLASSAV, &romvecs[7]}, 1636 {MACH_MACQ840AV, "Quadra", " 840AV ", MACH_CLASSAV, &romvecs[7]}, 1637 1638 /* The Powerbooks/Duos... */ 1639 {MACH_MACPB100, "PowerBook", " 100 ", MACH_CLASSPB, &romvecs[1]}, 1640 /* PB 100 has no MMU! */ 1641 {MACH_MACPB140, "PowerBook", " 140 ", MACH_CLASSPB, &romvecs[1]}, 1642 {MACH_MACPB145, "PowerBook", " 145 ", MACH_CLASSPB, &romvecs[1]}, 1643 {MACH_MACPB150, "PowerBook", " 150 ", MACH_CLASSDUO, &romvecs[10]}, 1644 {MACH_MACPB160, "PowerBook", " 160 ", MACH_CLASSPB, &romvecs[5]}, 1645 {MACH_MACPB165, "PowerBook", " 165 ", MACH_CLASSPB, &romvecs[5]}, 1646 {MACH_MACPB165C, "PowerBook", " 165c ", MACH_CLASSPB, &romvecs[5]}, 1647 {MACH_MACPB170, "PowerBook", " 170 ", MACH_CLASSPB, &romvecs[1]}, 1648 {MACH_MACPB180, "PowerBook", " 180 ", MACH_CLASSPB, &romvecs[5]}, 1649 {MACH_MACPB180C, "PowerBook", " 180c ", MACH_CLASSPB, &romvecs[5]}, 1650 {MACH_MACPB190, "PowerBook", " 190 ", MACH_CLASSPB, &romvecs[8]}, 1651 {MACH_MACPB190CS, "PowerBook", " 190cs ", MACH_CLASSPB, &romvecs[8]}, 1652 {MACH_MACPB500, "PowerBook", " 500 ", MACH_CLASSPB, &romvecs[8]}, 1653 1654 /* The Duos */ 1655 {MACH_MACPB210, "PowerBook Duo", " 210 ", MACH_CLASSDUO, &romvecs[5]}, 1656 {MACH_MACPB230, "PowerBook Duo", " 230 ", MACH_CLASSDUO, &romvecs[5]}, 1657 {MACH_MACPB250, "PowerBook Duo", " 250 ", MACH_CLASSDUO, &romvecs[5]}, 1658 {MACH_MACPB270, "PowerBook Duo", " 270C ", MACH_CLASSDUO, &romvecs[5]}, 1659 {MACH_MACPB280, "PowerBook Duo", " 280 ", MACH_CLASSDUO, &romvecs[5]}, 1660 {MACH_MACPB280C, "PowerBook Duo", " 280C ", MACH_CLASSDUO, &romvecs[5]}, 1661 1662 /* The Performas... */ 1663 {MACH_MACP600, "Performa", " 600 ", MACH_CLASSIIvx, &romvecs[2]}, 1664 {MACH_MACP460, "Performa", " 460 ", MACH_CLASSLC, &romvecs[14]}, 1665 {MACH_MACP550, "Performa", " 550 ", MACH_CLASSLC, &romvecs[11]}, 1666 {MACH_MACP580, "Performa", " 580 ", MACH_CLASSQ2, &romvecs[19]}, 1667 {MACH_MACTV, "TV ", "", MACH_CLASSLC, &romvecs[12]}, 1668 1669 /* The LCs... */ 1670 {MACH_MACLCII, "LC", " II ", MACH_CLASSLC, &romvecs[3]}, 1671 {MACH_MACLCIII, "LC", " III ", MACH_CLASSLC, &romvecs[14]}, 1672 {MACH_MACLC475, "LC", " 475 ", MACH_CLASSQ, &romvecs[9]}, 1673 {MACH_MACLC475_33, "LC", " 475/33 ", MACH_CLASSQ, &romvecs[9]}, 1674 {MACH_MACLC520, "LC", " 520 ", MACH_CLASSLC, &romvecs[15]}, 1675 {MACH_MACLC575, "LC", " 575 ", MACH_CLASSQ2, &romvecs[16]}, 1676 {MACH_MACCCLASSIC, "Color Classic ", "", MACH_CLASSLC, &romvecs[3]}, 1677 {MACH_MACCCLASSICII, "Color Classic"," II ", MACH_CLASSLC, &romvecs[3]}, 1678 /* Does this belong here? */ 1679 {MACH_MACCLASSICII, "Classic", " II ", MACH_CLASSLC, &romvecs[3]}, 1680 1681 /* The unknown one and the end... */ 1682 {0, "Unknown", "", MACH_CLASSII, NULL}, 1683 {0, NULL, NULL, 0, NULL}, 1684 }; /* End of cpu_models[] initialization. */ 1685 1686 struct intvid_info_t { 1687 int machineid; 1688 u_long fbbase; 1689 u_long fbmask; 1690 u_long fblen; 1691 } intvid_info[] = { 1692 { MACH_MACCLASSICII, 0x009f9a80, 0x0, 21888 }, 1693 { MACH_MACPB140, 0xfee08000, 0x0, 32 * 1024 }, 1694 { MACH_MACPB145, 0xfee08000, 0x0, 32 * 1024 }, 1695 { MACH_MACPB170, 0xfee08000, 0x0, 32 * 1024 }, 1696 { MACH_MACPB150, 0x60000000, 0x0, 128 * 1024 }, 1697 { MACH_MACPB160, 0x60000000, 0x0ffe0000, 128 * 1024 }, 1698 { MACH_MACPB165, 0x60000000, 0x0ffe0000, 128 * 1024 }, 1699 { MACH_MACPB180, 0x60000000, 0x0ffe0000, 128 * 1024 }, 1700 { MACH_MACPB210, 0x60000000, 0x0, 128 * 1024 }, 1701 { MACH_MACPB230, 0x60000000, 0x0, 128 * 1024 }, 1702 { MACH_MACPB250, 0x60000000, 0x0, 128 * 1024 }, 1703 { MACH_MACPB270, 0x60000000, 0x0, 128 * 1024 }, 1704 { MACH_MACPB280, 0x60000000, 0x0, 128 * 1024 }, 1705 { MACH_MACPB280C, 0x60000000, 0x0, 128 * 1024 }, 1706 { MACH_MACIICI, 0x0, 0x0, 320 * 1024 }, 1707 { MACH_MACIISI, 0x0, 0x0, 320 * 1024 }, 1708 { MACH_MACCCLASSIC, 0x50f40000, 0x0, 512 * 1024 }, 1709 /*??*/ { MACH_MACLCII, 0x50f40000, 0x0, 512 * 1024 }, 1710 { MACH_MACPB165C, 0xfc040000, 0x0, 512 * 1024 }, 1711 { MACH_MACPB180C, 0xfc040000, 0x0, 512 * 1024 }, 1712 { MACH_MACPB190, 0x60000000, 0x0, 512 * 1024 }, 1713 { MACH_MACPB190CS, 0x60000000, 0x0, 512 * 1024 }, 1714 { MACH_MACPB500, 0x60000000, 0x0, 512 * 1024 }, 1715 { MACH_MACLCIII, 0x60b00000, 0x0, 768 * 1024 }, 1716 { MACH_MACLC520, 0x60000000, 0x0, 1024 * 1024 }, 1717 { MACH_MACP550, 0x60000000, 0x0, 1024 * 1024 }, 1718 { MACH_MACTV, 0x60000000, 0x0, 1024 * 1024 }, 1719 { MACH_MACLC475, 0xf9000000, 0x0, 1024 * 1024 }, 1720 { MACH_MACLC475_33, 0xf9000000, 0x0, 1024 * 1024 }, 1721 { MACH_MACLC575, 0xf9000000, 0x0, 1024 * 1024 }, 1722 { MACH_MACC610, 0xf9000000, 0x0, 1024 * 1024 }, 1723 { MACH_MACC650, 0xf9000000, 0x0, 1024 * 1024 }, 1724 { MACH_MACP580, 0xf9000000, 0x0, 1024 * 1024 }, 1725 { MACH_MACQ605, 0xf9000000, 0x0, 1024 * 1024 }, 1726 { MACH_MACQ605_33, 0xf9000000, 0x0, 1024 * 1024 }, 1727 { MACH_MACQ610, 0xf9000000, 0x0, 1024 * 1024 }, 1728 { MACH_MACQ630, 0xf9000000, 0x0, 1024 * 1024 }, 1729 { MACH_MACQ650, 0xf9000000, 0x0, 1024 * 1024 }, 1730 { MACH_MACC660AV, 0x50100000, 0x0, 1024 * 1024 }, 1731 { MACH_MACQ700, 0xf9000000, 0x0, 1024 * 1024 }, 1732 { MACH_MACQ800, 0xf9000000, 0x0, 1024 * 1024 }, 1733 { MACH_MACQ900, 0xf9000000, 0x0, 1024 * 1024 }, 1734 { MACH_MACQ950, 0xf9000000, 0x0, 1024 * 1024 }, 1735 { MACH_MACQ840AV, 0x50100000, 0x0, 2048 * 1024 }, 1736 { 0, 0x0, 0x0, 0 }, 1737 }; /* End of intvid_info[] initialization. */ 1738 1739 /* 1740 * Missing Mac Models: 1741 * PowerMac 6100 1742 * PowerMac 7100 1743 * PowerMac 8100 1744 * PowerBook 540 1745 * PowerBook 520 1746 * PowerBook 150 1747 * Duo 280 1748 * Performa 6000s 1749 * ...? 1750 */ 1751 1752 int mach_cputype(void); 1753 1754 int 1755 mach_cputype(void) 1756 { 1757 return (mac68k_machine.mach_processor); 1758 } 1759 1760 void 1761 machine_set_model(void) 1762 { 1763 cpu_setmodel("Apple Macintosh %s%s", 1764 cpu_models[mac68k_machine.cpu_model_index].model_major, 1765 cpu_models[mac68k_machine.cpu_model_index].model_minor); 1766 } 1767 1768 static void get_machine_info(void); 1769 1770 static void 1771 get_machine_info(void) 1772 { 1773 int i; 1774 1775 for (i = 0; cpu_models[i].model_major; i++) 1776 if (mac68k_machine.machineid == cpu_models[i].machineid) 1777 break; 1778 1779 if (cpu_models[i].model_major == NULL) 1780 i--; 1781 1782 mac68k_machine.cpu_model_index = i; 1783 } 1784 1785 struct cpu_model_info *current_mac_model; 1786 romvec_t *mrg_MacOSROMVectors = 0; 1787 1788 /* 1789 * Sets a bunch of machine-specific variables 1790 */ 1791 void setmachdep(void); 1792 1793 void 1794 setmachdep(void) 1795 { 1796 struct cpu_model_info *cpui; 1797 1798 /* 1799 * First, set things that need to be set on the first pass only 1800 * Ideally, we'd only call this once, but for some reason, the 1801 * VIAs need interrupts turned off twice !? 1802 */ 1803 get_machine_info(); 1804 1805 load_addr = 0; 1806 cpui = &(cpu_models[mac68k_machine.cpu_model_index]); 1807 current_mac_model = cpui; 1808 1809 mac68k_machine.via1_ipl = 1; 1810 mac68k_machine.via2_ipl = 2; 1811 mac68k_machine.aux_interrupts = 0; 1812 1813 /* 1814 * Set up any machine specific stuff that we have to before 1815 * ANYTHING else happens 1816 */ 1817 switch (cpui->class) { /* Base this on class of machine... */ 1818 case MACH_CLASSII: 1819 VIA2 = VIA2OFF; 1820 IOBase = 0x50f00000; 1821 Via1Base = (volatile u_char *)IOBase; 1822 mac68k_machine.scsi80 = 1; 1823 mac68k_machine.zs_chip = 0; 1824 via_reg(VIA1, vIER) = 0x7f; /* disable VIA1 int */ 1825 via_reg(VIA2, vIER) = 0x7f; /* disable VIA2 int */ 1826 break; 1827 case MACH_CLASSPB: 1828 VIA2 = VIA2OFF; 1829 IOBase = 0x50f00000; 1830 Via1Base = (volatile u_char *)IOBase; 1831 mac68k_machine.scsi80 = 1; 1832 mac68k_machine.zs_chip = 0; 1833 /* Disable everything but PM; we need it. */ 1834 via_reg(VIA1, vIER) = 0x6f; /* disable VIA1 int */ 1835 /* Are we disabling something important? */ 1836 via_reg(VIA2, vIER) = 0x7f; /* disable VIA2 int */ 1837 if (cputype == CPU_68040) 1838 mac68k_machine.sonic = 1; 1839 break; 1840 case MACH_CLASSDUO: 1841 /* 1842 * The Duo definitely does not use a VIA2, but it looks 1843 * like the VIA2 functions might be on the MSC at the RBV 1844 * locations. The rest is copied from the Powerbooks. 1845 */ 1846 VIA2 = RBVOFF; 1847 IOBase = 0x50f00000; 1848 Via1Base = (volatile u_char *)IOBase; 1849 mac68k_machine.scsi80 = 1; 1850 mac68k_machine.zs_chip = 0; 1851 /* Disable everything but PM; we need it. */ 1852 via_reg(VIA1, vIER) = 0x6f; /* disable VIA1 int */ 1853 /* Are we disabling something important? */ 1854 via_reg(VIA2, rIER) = 0x7f; /* disable VIA2 int */ 1855 break; 1856 case MACH_CLASSQ: 1857 case MACH_CLASSQ2: 1858 VIA2 = VIA2OFF; 1859 IOBase = 0x50f00000; 1860 Via1Base = (volatile u_char *)IOBase; 1861 mac68k_machine.sonic = 1; 1862 mac68k_machine.scsi96 = 1; 1863 mac68k_machine.zs_chip = 0; 1864 via_reg(VIA1, vIER) = 0x7f; /* disable VIA1 int */ 1865 via_reg(VIA2, vIER) = 0x7f; /* disable VIA2 int */ 1866 1867 #if 1 1868 switch (current_mac_model->machineid) { 1869 default: 1870 /* case MACH_MACQ900: These three, at least, support the 1871 case MACH_MACQ950: A/UX interrupts. What Quadras don't? 1872 case MACH_MACQ700: */ 1873 /* Enable A/UX interrupt scheme */ 1874 mac68k_machine.aux_interrupts = 1; 1875 1876 via_reg(VIA1, vBufB) &= (0xff ^ DB1O_AuxIntEnb); 1877 via_reg(VIA1, vDirB) |= DB1O_AuxIntEnb; 1878 mac68k_machine.via1_ipl = 6; 1879 mac68k_machine.via2_ipl = 2; 1880 break; 1881 } 1882 #endif 1883 1884 break; 1885 case MACH_CLASSAV: 1886 case MACH_CLASSP580: 1887 VIA2 = VIA2OFF; 1888 IOBase = 0x50f00000; 1889 Via1Base = (volatile u_char *)IOBase; 1890 mac68k_machine.scsi96 = 1; 1891 mac68k_machine.zs_chip = 0; 1892 via_reg(VIA1, vIER) = 0x7f; /* disable VIA1 int */ 1893 via_reg(VIA2, vIER) = 0x7f; /* disable VIA2 int */ 1894 break; 1895 case MACH_CLASSIIci: 1896 VIA2 = RBVOFF; 1897 IOBase = 0x50f00000; 1898 Via1Base = (volatile u_char *)IOBase; 1899 mac68k_machine.scsi80 = 1; 1900 mac68k_machine.zs_chip = 0; 1901 via_reg(VIA1, vIER) = 0x7f; /* disable VIA1 int */ 1902 via_reg(VIA2, rIER) = 0x7f; /* disable RBV int */ 1903 break; 1904 case MACH_CLASSIIsi: 1905 VIA2 = RBVOFF; 1906 IOBase = 0x50f00000; 1907 Via1Base = (volatile u_char *)IOBase; 1908 mac68k_machine.scsi80 = 1; 1909 mac68k_machine.zs_chip = 0; 1910 via_reg(VIA1, vIER) = 0x7f; /* disable VIA1 int */ 1911 via_reg(VIA2, rIER) = 0x7f; /* disable RBV int */ 1912 break; 1913 case MACH_CLASSIIvx: 1914 VIA2 = RBVOFF; 1915 IOBase = 0x50f00000; 1916 Via1Base = (volatile u_char *)IOBase; 1917 mac68k_machine.scsi80 = 1; 1918 mac68k_machine.zs_chip = 0; 1919 via_reg(VIA1, vIER) = 0x7f; /* disable VIA1 int */ 1920 via_reg(VIA2, rIER) = 0x7f; /* disable RBV int */ 1921 break; 1922 case MACH_CLASSLC: 1923 VIA2 = RBVOFF; 1924 IOBase = 0x50f00000; 1925 Via1Base = (volatile u_char *)IOBase; 1926 mac68k_machine.scsi80 = 1; 1927 mac68k_machine.zs_chip = 0; 1928 via_reg(VIA1, vIER) = 0x7f; /* disable VIA1 int */ 1929 via_reg(VIA2, rIER) = 0x7f; /* disable RBV int */ 1930 break; 1931 case MACH_CLASSIIfx: 1932 VIA2 = OSSOFF; 1933 IOBase = 0x50f00000; 1934 Via1Base = (volatile u_char *)IOBase; 1935 mac68k_machine.scsi80 = 1; 1936 mac68k_machine.zs_chip = 0; 1937 via_reg(VIA1, vIER) = 0x7f; /* disable VIA1 int */ 1938 break; 1939 default: 1940 case MACH_CLASSH: 1941 break; 1942 } 1943 1944 /* 1945 * Set up current ROM Glue vectors. Actually now all we do 1946 * is save the address of the ROM Glue Vector table. This gets 1947 * used later when we re-map the vectors from MacOS Address 1948 * Space to NetBSD Address Space. 1949 */ 1950 mrg_MacOSROMVectors = cpui->rom_vectors; 1951 } 1952 1953 /* 1954 * Set IO offsets. 1955 */ 1956 void 1957 mac68k_set_io_offsets(vaddr_t base) 1958 { 1959 1960 Via1Base = (volatile u_char *)base; 1961 Via2Base = Via1Base + 0x2000 * VIA2; 1962 switch (current_mac_model->class) { 1963 case MACH_CLASSQ: 1964 switch (current_mac_model->machineid) { 1965 case MACH_MACQ900: 1966 case MACH_MACQ950: 1967 sccA = (volatile u_char *)base + 0xc020; 1968 SCSIBase = base + 0xf000; 1969 mac68k_machine.scsi96_2 = 1; 1970 iop_init(0); /* For console */ 1971 break; 1972 case MACH_MACQ800: 1973 /* 1974 * The H/W partially decode address for sccA; it is 1975 * available at offsets 0xc000, 0xc020, .... Here, 1976 * we choose 0xc020, where Mac toolbox ROM uses. 1977 */ 1978 sccA = (volatile u_char *)base + 0xc020; 1979 SCSIBase = base + 0x10000; 1980 break; 1981 case MACH_MACQ700: 1982 sccA = (volatile u_char *)base + 0xc000; 1983 SCSIBase = base + 0xf000; 1984 break; 1985 default: 1986 sccA = (volatile u_char *)base + 0xc000; 1987 SCSIBase = base + 0x10000; 1988 break; 1989 } 1990 break; 1991 case MACH_CLASSQ2: 1992 /* 1993 * Note the different offset for sccA for this class of 1994 * machines. This seems to be common on many of the 1995 * Quadra-type machines. 1996 */ 1997 sccA = (volatile u_char *)base + 0xc020; 1998 SCSIBase = base + 0x10000; 1999 break; 2000 case MACH_CLASSP580: 2001 /* 2002 * Here's a queer bird... it seems to be a cross between 2003 * the two different Quadra classes. 2004 */ 2005 sccA = (volatile u_char *)base + 0xc020; 2006 SCSIBase = base; 2007 break; 2008 case MACH_CLASSAV: 2009 sccA = (volatile u_char *)base + 0x4000; 2010 SCSIBase = base + 0x18000; 2011 PSCBase = (volatile u_char *)base + 0x31000; 2012 break; 2013 case MACH_CLASSII: 2014 case MACH_CLASSPB: 2015 case MACH_CLASSDUO: 2016 case MACH_CLASSIIci: 2017 case MACH_CLASSIIsi: 2018 case MACH_CLASSIIvx: 2019 case MACH_CLASSLC: 2020 sccA = (volatile u_char *)base + 0x4000; 2021 SCSIBase = base; 2022 break; 2023 case MACH_CLASSIIfx: 2024 /* 2025 * Note that sccA base address is based on having 2026 * the serial port in `compatible' mode (set in 2027 * the Serial Switch control panel before booting). 2028 */ 2029 sccA = (volatile u_char *)base + 0x4020; 2030 SCSIBase = base; 2031 iop_init(0); /* For console */ 2032 break; 2033 default: 2034 case MACH_CLASSH: 2035 panic("Unknown/unsupported machine class (%d).", 2036 current_mac_model->class); 2037 break; 2038 } 2039 } 2040 2041 #if GRAYBARS 2042 static u_long gray_nextaddr = 0; 2043 2044 void 2045 gray_bar(void) 2046 { 2047 static int i = 0; 2048 static int flag = 0; 2049 2050 /* MF basic premise as I see it: 2051 1) Save the scratch regs as they are not saved by the compilier. 2052 2) Check to see if we want gray bars, if so, 2053 display some lines of gray, 2054 a couple of lines of white(about 8), 2055 and loop to slow this down. 2056 3) restore regs 2057 */ 2058 2059 __asm volatile ( 2060 " movl %a0,%sp@-;" 2061 " movl %a1,%sp@-;" 2062 " movl %d0,%sp@-;" 2063 " movl %d1,%sp@-"); 2064 2065 /* check to see if gray bars are turned off */ 2066 if (mac68k_machine.do_graybars) { 2067 /* MF the 10*stride/4 is done lots, but we want this to be 2068 * slow */ 2069 for (i = 0; i < 10 * mac68k_video.mv_stride / 4; i++) 2070 ((u_long *)mac68k_video.mv_kvaddr) 2071 [gray_nextaddr++] = 0xaaaaaaaa; 2072 for (i = 0; i < 2 * mac68k_video.mv_stride / 4; i++) 2073 ((u_long *)mac68k_video.mv_kvaddr) 2074 [gray_nextaddr++] = 0x00000000; 2075 } 2076 2077 __asm volatile ( 2078 " movl %sp@+,%d1;" 2079 " movl %sp@+,%d0;" 2080 " movl %sp@+,%a1;" 2081 " movl %sp@+,%a0"); 2082 } 2083 #endif 2084 2085 /* in locore */ 2086 extern u_long ptest040(void *, u_int); 2087 extern u_long plpar060(void *, u_int); 2088 extern int get_pte(u_int, u_long *, u_short *); 2089 2090 /* 2091 * LAK (7/24/94): given a logical address, puts the physical address 2092 * in *phys and return 1, or returns 0 on failure. This is intended 2093 * to look through MacOS page tables. 2094 */ 2095 2096 static u_long 2097 get_physical(u_int addr, u_long * phys) 2098 { 2099 extern u_int macos_tc; 2100 u_long pte[2], ph, mask; 2101 u_short psr; 2102 int i, numbits; 2103 2104 if (cputype == CPU_68060) { 2105 ph = plpar060((void *)addr, FC_SUPERD); 2106 if (ph == (u_long)-1) { 2107 ph = plpar060((void *)addr, FC_USERD); 2108 if (ph == (u_long)-1) { 2109 return 0; 2110 } 2111 } 2112 *phys = ph; 2113 return 1; 2114 } else if (mmutype == MMU_68040) { 2115 ph = ptest040((void *)addr, FC_SUPERD); 2116 if ((ph & MMUSR40_R) == 0) { 2117 ph = ptest040((void *)addr, FC_USERD); 2118 if ((ph & MMUSR40_R) == 0) 2119 return 0; 2120 } 2121 if ((ph & MMUSR40_T) != 0) 2122 ph = addr; 2123 2124 mask = (macos_tc & TCR40_P) ? 0x00001fff : 0x00000fff; 2125 ph &= (~mask); 2126 } else { 2127 switch (get_pte(addr, pte, &psr)) { 2128 case (-1): 2129 return 0; 2130 case 0: 2131 ph = pte[0] & 0xFFFFFF00; 2132 break; 2133 case 1: 2134 ph = pte[1] & 0xFFFFFF00; 2135 break; 2136 default: 2137 panic("get_physical(): bad get_pte()"); 2138 } 2139 2140 /* 2141 * We must now figure out how many levels down we went and 2142 * mask the bits appropriately -- the returned value may only 2143 * be the upper n bits, and we have to take the rest from addr. 2144 */ 2145 numbits = 0; 2146 psr &= 0x0007; /* Number of levels we went */ 2147 for (i = 0; i < psr; i++) 2148 numbits += (macos_tc >> (12 - i * 4)) & 0x0f; 2149 2150 /* 2151 * We have to take the most significant "numbits" from 2152 * the returned value "ph", and the rest from our addr. 2153 * Assume that numbits != 0. 2154 */ 2155 mask = (1 << (32 - numbits)) - 1; 2156 } 2157 *phys = ph + (addr & mask); 2158 2159 return 1; 2160 } 2161 2162 static void check_video(const char *, u_long, u_long); 2163 2164 static void 2165 check_video(const char *id, u_long limit, u_long maxm) 2166 { 2167 u_long addr, phys; 2168 2169 if (!get_physical(mac68k_video.mv_kvaddr, &phys)) { 2170 if (mac68k_machine.do_graybars) 2171 printf("get_mapping(): %s. False start.\n", id); 2172 } else { 2173 mac68k_video.mv_log = mac68k_video.mv_kvaddr; 2174 mac68k_video.mv_phys = phys; 2175 mac68k_video.mv_len = 32768; 2176 addr = mac68k_video.mv_kvaddr + 32768; 2177 while (get_physical(addr, &phys)) { 2178 if ((phys - mac68k_video.mv_phys) 2179 != mac68k_video.mv_len) 2180 break; 2181 if (mac68k_video.mv_len + 32768 > limit) { 2182 if (mac68k_machine.do_graybars) { 2183 printf("mapping: %s. Does it never end?\n", 2184 id); 2185 printf(" Forcing VRAM size "); 2186 printf("to a conservative %ldK.\n", 2187 maxm/1024); 2188 } 2189 mac68k_video.mv_len = maxm; 2190 break; 2191 } 2192 mac68k_video.mv_len += 32768; 2193 addr += 32768; 2194 } 2195 if (mac68k_machine.do_graybars) { 2196 printf(" %s internal video at addr %p (phys %p), ", 2197 id, (void *)mac68k_video.mv_log, 2198 (void *)mac68k_video.mv_phys); 2199 printf("len 0x%x.\n", mac68k_video.mv_len); 2200 } 2201 } 2202 } 2203 2204 /* 2205 * Find out how MacOS has mapped itself so we can do the same thing. 2206 * Returns the address of logical 0 so that locore can map the kernel 2207 * properly. 2208 */ 2209 u_int 2210 get_mapping(void) 2211 { 2212 struct intvid_info_t *iip; 2213 u_long addr, lastpage, phys, len, limit; 2214 int i, last, same; 2215 2216 numranges = 0; 2217 for (i = 0; i < 8; i++) { 2218 low[i] = 0; 2219 high[i] = 0; 2220 } 2221 2222 lastpage = get_top_of_ram(); 2223 2224 get_physical(0, &load_addr); 2225 2226 if (mac68k_machine.do_graybars) 2227 printf("Loaded at 0x%0lx\n", load_addr); 2228 2229 last = 0; 2230 for (addr = 0; addr <= lastpage && get_physical(addr, &phys); 2231 addr += PAGE_SIZE) { 2232 if (numranges > 0 && phys != high[last]) { 2233 /* 2234 * Attempt to find if this page is already 2235 * accounted for in an existing physical segment. 2236 */ 2237 for (i = 0; i < numranges; i++) { 2238 if (low[i] <= phys && phys <= high[i]) { 2239 last = i; 2240 break; 2241 } 2242 } 2243 if (i >= numranges) 2244 last = numranges - 1; 2245 2246 if (low[last] <= phys && phys < high[last]) 2247 continue; /* Skip pages we've seen. */ 2248 } 2249 2250 if (numranges > 0 && phys == high[last]) { 2251 /* Common case: extend existing segment on high end */ 2252 high[last] += PAGE_SIZE; 2253 } else { 2254 /* This is a new physical segment. */ 2255 for (last = 0; last < numranges; last++) 2256 if (phys < low[last]) 2257 break; 2258 2259 /* Create space for segment, if necessary */ 2260 if (last < numranges && phys < low[last]) { 2261 for (i = numranges; i > last; i--) { 2262 low[i] = low[i - 1]; 2263 high[i] = high[i - 1]; 2264 } 2265 } 2266 2267 numranges++; 2268 low[last] = phys; 2269 high[last] = phys + PAGE_SIZE; 2270 } 2271 2272 /* Coalesce adjoining segments as appropriate */ 2273 if (last < (numranges - 1) && high[last] == low[last + 1] && 2274 low[last + 1] != load_addr) { 2275 high[last] = high[last + 1]; 2276 for (i = last + 1; i < numranges; i++) { 2277 low[i] = low[i + 1]; 2278 high[i] = high[i + 1]; 2279 } 2280 --numranges; 2281 } 2282 } 2283 if (mac68k_machine.do_graybars) { 2284 printf("System RAM: %ld bytes in %ld pages.\n", 2285 addr, addr / PAGE_SIZE); 2286 for (i = 0; i < numranges; i++) { 2287 printf(" Low = 0x%lx, high = 0x%lx\n", 2288 low[i], high[i]); 2289 } 2290 } 2291 2292 /* 2293 * If we can't figure out the PA of the frame buffer by groveling 2294 * the page tables, assume that we already have the correct 2295 * address. This is the case on several of the PowerBook 1xx 2296 * series, in particular. 2297 */ 2298 if (!get_physical(mac68k_video.mv_kvaddr, &phys)) 2299 phys = mac68k_video.mv_kvaddr; 2300 2301 /* 2302 * Find on-board video, if we have an idea of where to look 2303 * on this system. 2304 */ 2305 for (iip = intvid_info; iip->machineid; iip++) 2306 if (mac68k_machine.machineid == iip->machineid) 2307 break; 2308 2309 if (mac68k_machine.machineid == iip->machineid && 2310 (phys & ~iip->fbmask) >= iip->fbbase && 2311 (phys & ~iip->fbmask) < (iip->fbbase + iip->fblen)) { 2312 mac68k_video.mv_phys = phys & ~iip->fbmask; 2313 mac68k_video.mv_len = 32768 - (phys & 0x7fff); 2314 2315 limit = iip->fbbase + iip->fblen - mac68k_video.mv_phys; 2316 if (mac68k_video.mv_len > limit) { 2317 mac68k_video.mv_len = limit; 2318 } else { 2319 addr = mac68k_video.mv_kvaddr + mac68k_video.mv_len; 2320 while (get_physical(addr, &phys)) { 2321 phys &= ~iip->fbmask; 2322 if ((phys - mac68k_video.mv_phys) != 2323 mac68k_video.mv_len) 2324 break; 2325 if ((mac68k_video.mv_phys + 32768) > limit) { 2326 mac68k_video.mv_len = limit; 2327 break; 2328 } 2329 mac68k_video.mv_len += 32768; 2330 addr += 32768; 2331 } 2332 } 2333 } 2334 2335 if (mac68k_video.mv_len > 0) { 2336 /* 2337 * We've already figured out where internal video is. 2338 * Tell the user what we know. 2339 */ 2340 if (mac68k_machine.do_graybars) 2341 printf("On-board video at addr %p (phys %p), " 2342 "len 0x%x.\n", 2343 (void *)mac68k_video.mv_kvaddr, 2344 (void *)mac68k_video.mv_phys, 2345 mac68k_video.mv_len); 2346 } else { 2347 /* 2348 * We should now look through all of NuBus space to find where 2349 * the internal video is being mapped. Just to be sure we 2350 * handle all the cases, we simply map our NuBus space exactly 2351 * how MacOS did it. As above, we find a bunch of ranges that 2352 * are contiguously mapped. Since there are a lot of pages 2353 * that are all mapped to 0, we handle that as a special case 2354 * where the length is negative. We search in increments of 2355 * 32768 because that's the page size that MacOS uses. 2356 */ 2357 nbnumranges = 0; 2358 for (i = 0; i < NBMAXRANGES; i++) { 2359 nbphys[i] = 0; 2360 nblog[i] = 0; 2361 nblen[i] = 0; 2362 } 2363 2364 same = 0; 2365 for (addr = 0xF9000000; addr < 0xFF000000; addr += 32768) { 2366 if (!get_physical(addr, &phys)) { 2367 continue; 2368 } 2369 len = nbnumranges == 0 ? 0 : nblen[nbnumranges - 1]; 2370 2371 #ifdef __debug_mondo_verbose__ 2372 if (mac68k_machine.do_graybars) 2373 printf ("0x%lx --> 0x%lx\n", addr, phys); 2374 #endif 2375 2376 if (nbnumranges > 0 2377 && addr == nblog[nbnumranges - 1] + len 2378 && phys == nbphys[nbnumranges - 1]) { 2379 /* Same as last one */ 2380 nblen[nbnumranges - 1] += 32768; 2381 same = 1; 2382 } else { 2383 if ((nbnumranges > 0) 2384 && !same 2385 && (addr == nblog[nbnumranges - 1] + len) 2386 && (phys == nbphys[nbnumranges - 1] + len)) 2387 nblen[nbnumranges - 1] += 32768; 2388 else { 2389 if (same && 2390 nbnumranges > 0 /* XXXGCC14 */) { 2391 nblen[nbnumranges - 1] = -len; 2392 same = 0; 2393 } 2394 if (nbnumranges == NBMAXRANGES) { 2395 if (mac68k_machine.do_graybars) 2396 printf("get_mapping(): Too many NuBus ranges.\n"); 2397 break; 2398 } 2399 nbnumranges++; 2400 nblog[nbnumranges - 1] = addr; 2401 nbphys[nbnumranges - 1] = phys; 2402 nblen[nbnumranges - 1] = 32768; 2403 } 2404 } 2405 } 2406 if (same) { 2407 nblen[nbnumranges - 1] = -nblen[nbnumranges - 1]; 2408 same = 0; 2409 } 2410 if (mac68k_machine.do_graybars) { 2411 printf("Non-system RAM (nubus, etc.):\n"); 2412 for (i = 0; i < nbnumranges; i++) { 2413 printf(" Log = 0x%lx, Phys = 0x%lx, Len = 0x%lx (%lu)\n", 2414 nblog[i], nbphys[i], nblen[i], nblen[i]); 2415 } 2416 } 2417 2418 /* 2419 * We must now find the logical address of internal video in the 2420 * ranges we made above. Internal video is at physical 0, but 2421 * a lot of pages map there. Instead, we look for the logical 2422 * page that maps to 32768 and go back one page. 2423 */ 2424 for (i = 0; i < nbnumranges; i++) { 2425 if (nblen[i] > 0 2426 && nbphys[i] <= 32768 2427 && 32768 <= nbphys[i] + nblen[i]) { 2428 mac68k_video.mv_log = nblog[i] - nbphys[i]; 2429 mac68k_video.mv_len = nblen[i] + nbphys[i]; 2430 mac68k_video.mv_phys = 0; 2431 break; 2432 } 2433 } 2434 if (i == nbnumranges) { 2435 if (0x60000000 <= mac68k_video.mv_kvaddr 2436 && mac68k_video.mv_kvaddr < 0x70000000) { 2437 if (mac68k_machine.do_graybars) 2438 printf("Checking for Internal Video "); 2439 /* 2440 * Kludge for IIvx internal video (60b0 0000). 2441 * PB 520 (6000 0000) 2442 */ 2443 check_video("PB/IIvx (0x60?00000)", 2444 1 * 1024 * 1024, 1 * 1024 * 1024); 2445 } else if (0x50F40000 <= mac68k_video.mv_kvaddr 2446 && mac68k_video.mv_kvaddr < 0x50FBFFFF) { 2447 /* 2448 * Kludge for LC internal video 2449 */ 2450 check_video("LC video (0x50f40000)", 2451 512 * 1024, 512 * 1024); 2452 } else if (0x50100100 <= mac68k_video.mv_kvaddr 2453 && mac68k_video.mv_kvaddr < 0x50400000) { 2454 /* 2455 * Kludge for AV internal video 2456 */ 2457 check_video("AV video (0x50100100)", 2458 1 * 1024 * 1024, 1 * 1024 * 1024); 2459 } else { 2460 if (mac68k_machine.do_graybars) 2461 printf(" no internal video at " 2462 "address 0 -- " 2463 "mac68k_video.mv_kvaddr is " 2464 "0x%lx.\n", 2465 mac68k_video.mv_kvaddr); 2466 } 2467 } else if (mac68k_machine.do_graybars) { 2468 printf(" Video address = %p\n", 2469 (void *)mac68k_video.mv_kvaddr); 2470 printf(" Int video starts at %p\n", 2471 (void *)mac68k_video.mv_log); 2472 printf(" Length = 0x%x (%d) bytes\n", 2473 mac68k_video.mv_len, mac68k_video.mv_len); 2474 } 2475 } 2476 /* mv_len sanity check */ 2477 int reqsize = mac68k_video.mv_height * mac68k_video.mv_stride; 2478 if (mac68k_video.mv_len < reqsize) 2479 mac68k_video.mv_len = reqsize; 2480 2481 return load_addr; /* Return physical address of logical 0 */ 2482 } 2483 2484 /* 2485 * Debugging code for locore page-traversal routine. 2486 */ 2487 void printstar(void); 2488 void 2489 printstar(void) 2490 { 2491 /* 2492 * Be careful as we assume that no registers are clobbered 2493 * when we call this from assembly. 2494 */ 2495 __asm volatile ( 2496 " movl %a0,%sp@-;" 2497 " movl %a1,%sp@-;" 2498 " movl %d0,%sp@-;" 2499 " movl %d1,%sp@-"); 2500 2501 /* printf("*"); */ 2502 2503 __asm volatile ( 2504 " movl %sp@+,%d1;" 2505 " movl %sp@+,%d0;" 2506 " movl %sp@+,%a1;" 2507 " movl %sp@+,%a0"); 2508 } 2509 2510 /* 2511 * Console bell callback; modularizes the console terminal emulator 2512 * and the audio system, so neither requires direct knowledge of the 2513 * other. 2514 */ 2515 2516 void 2517 mac68k_set_bell_callback(int (*callback)(void *, int, int, int), void *cookie) 2518 { 2519 mac68k_bell_callback = callback; 2520 mac68k_bell_cookie = (void *)cookie; 2521 } 2522 2523 int 2524 mac68k_ring_bell(int freq, int length, int volume) 2525 { 2526 if (mac68k_bell_callback) 2527 return ((*mac68k_bell_callback)(mac68k_bell_cookie, 2528 freq, length, volume)); 2529 else 2530 return (ENXIO); 2531 } 2532 2533 int 2534 mm_md_physacc(paddr_t pa, vm_prot_t prot) 2535 { 2536 extern u_long last_page; 2537 2538 return (pa < last_page) ? 0 : EFAULT; 2539 } 2540 2541 void __attribute__((no_instrument_function)) 2542 pmap_machine_check_bootstrap_allocations(paddr_t nextpa, paddr_t firstpa) 2543 { 2544 int i; 2545 2546 for (i = 0; i < numranges; i++) { 2547 if (low[i] <= firstpa && firstpa < high[i]) { 2548 break; 2549 } 2550 } 2551 if (i >= numranges || nextpa > high[i]) { 2552 if (mac68k_machine.do_graybars) { 2553 printf("Failure in NetBSD boot; "); 2554 if (i < numranges) { 2555 printf("nextpa=0x%lx, high[%d]=0x%lx.\n", 2556 nextpa, i, high[i]); 2557 } else { 2558 printf("can't find kernel RAM segment.\n"); 2559 } 2560 printf("You're hosed! Try booting with 32-bit "); 2561 printf("addressing enabled in the memory control "); 2562 printf("panel.\n"); 2563 printf("Older machines may need Mode32 to get that "); 2564 printf("option.\n"); 2565 } 2566 panic("Cannot work with the current memory mappings."); 2567 } 2568 } 2569 2570 #define PMBM_IOBase 0 2571 #define PMBM_ROMBase 1 2572 #define PMBM_VIDBase 2 2573 struct pmap_bootmap machine_bootmap[] = { 2574 /* 2575 * Map the I/O region VA==PA; some of the ROM routines 2576 * have hard-coded addresses for e.g. VIA1. 2577 */ 2578 { .pmbm_vaddr = 0, /* initialized below */ 2579 .pmbm_paddr = 0, /* initialized below */ 2580 .pmbm_size = m68k_ptob(IIOMAPSIZE), 2581 .pmbm_flags = PMBM_F_FIXEDVA | PMBM_F_CI }, 2582 2583 { .pmbm_vaddr_ptr = (vaddr_t *)&ROMBase, 2584 .pmbm_paddr = 0, /* initialized below */ 2585 .pmbm_size = m68k_ptob(ROMMAPSIZE), 2586 .pmbm_flags = PMBM_F_RO }, 2587 2588 { .pmbm_vaddr_ptr = &newvideoaddr, 2589 .pmbm_paddr = 0, /* initialized below */ 2590 .pmbm_size = 0, /* initialized below */ 2591 .pmbm_flags = PMBM_F_CI }, 2592 2593 { .pmbm_vaddr = -1 }, 2594 }; 2595 2596 paddr_t bootstrap_mac68k(int); 2597 2598 paddr_t __attribute__((no_instrument_function)) 2599 bootstrap_mac68k(int tc) 2600 { 2601 #if NZSC > 0 2602 extern int zsinited; 2603 extern void zs_init(void); 2604 #endif 2605 extern int *esym; 2606 paddr_t nextpa; 2607 void *oldROMBase; 2608 char use_bootmem = 0; 2609 int i; 2610 2611 #ifdef DJMEMCMAX 2612 if(mac68k_machine.machineid == MACH_MACC650 || 2613 mac68k_machine.machineid == MACH_MACQ650 || 2614 mac68k_machine.machineid == MACH_MACQ610 || 2615 mac68k_machine.machineid == MACH_MACC610 || 2616 mac68k_machine.machineid == MACH_MACQ800) { 2617 use_bootmem = 1; 2618 } 2619 #endif 2620 2621 if (mac68k_machine.do_graybars) 2622 printf("Bootstrapping NetBSD/mac68k.\n"); 2623 2624 oldROMBase = ROMBase; 2625 mac68k_video.mv_phys = mac68k_video.mv_kvaddr; 2626 2627 if ((!use_bootmem) && (((tc & 0x80000000) && (mmutype == MMU_68030)) || 2628 ((tc & 0x8000) && (mmutype == MMU_68040)))) { 2629 if (mac68k_machine.do_graybars) 2630 printf("Getting mapping from MMU.\n"); 2631 (void) get_mapping(); 2632 if (mac68k_machine.do_graybars) 2633 printf("Done.\n"); 2634 } else { 2635 /* MMU not enabled. Fake up ranges. */ 2636 numranges = 1; 2637 low[0] = 0; 2638 high[0] = mac68k_machine.mach_memsize * (1024 * 1024); 2639 if (mac68k_machine.do_graybars) 2640 printf("Faked range to byte 0x%lx.\n", high[0]); 2641 } 2642 nextpa = load_addr + m68k_round_page(esym); 2643 2644 if (mac68k_machine.do_graybars) 2645 printf("Bootstrapping the pmap system.\n"); 2646 2647 vidlen = m68k_round_page(mac68k_video.mv_height * 2648 mac68k_video.mv_stride + m68k_page_offset(mac68k_video.mv_phys)); 2649 2650 /* Sum up the memory for pmap_bootstrap1(). */ 2651 vsize_t mem_size = 0; 2652 for (i = 0; i < numranges; i++) 2653 mem_size += high[i] - low[i]; 2654 physmem = m68k_btop(mem_size); 2655 2656 #ifdef __HAVE_NEW_PMAP_68K 2657 /* Initialize machine_bootmap[] for pmap_bootstrap1(). */ 2658 machine_bootmap[PMBM_IOBase].pmbm_vaddr = (vaddr_t)IOBase; 2659 machine_bootmap[PMBM_IOBase].pmbm_paddr = (paddr_t)IOBase; 2660 machine_bootmap[PMBM_ROMBase].pmbm_paddr = (paddr_t)ROMBase; 2661 machine_bootmap[PMBM_VIDBase].pmbm_paddr = 2662 m68k_trunc_page(mac68k_video.mv_phys); 2663 machine_bootmap[PMBM_VIDBase].pmbm_size = vidlen; 2664 #endif 2665 2666 nextpa = pmap_bootstrap1(nextpa, load_addr); 2667 2668 #ifdef __HAVE_NEW_PMAP_68K 2669 /* 2670 * machine_bootmap[] deals in whole pages; fixup newvideoaddr to 2671 * include the page offset. 2672 */ 2673 if (vidlen) { 2674 newvideoaddr += m68k_page_offset(mac68k_video.mv_phys); 2675 } 2676 #endif 2677 2678 /* 2679 * VM data structures are now initialized, set up data for 2680 * the pmap module. 2681 * 2682 * Note about avail_end: msgbuf is initialized just after 2683 * avail_end in machdep.c. Since the last page is used 2684 * for rebooting the system (code is copied there and 2685 * execution continues from copied code before the MMU 2686 * is disabled), the msgbuf will get trounced between 2687 * reboots if it's placed in the last physical page. 2688 * To work around this, we move avail_end back one more 2689 * page so the msgbuf can be preserved. 2690 */ 2691 avail_start = m68k_round_page(nextpa); 2692 last_page = high[numranges - 1] - m68k_ptob(1); 2693 #if NAUDIO > 0 2694 /* 2695 * Reduce high by an extra 7 pages which are used by the EASC on some 2696 * machines. last_page is unchanged as the last page can still be 2697 * safetly used to reboot the system. 2698 */ 2699 high[numranges - 1] -= (m68k_round_page(MSGBUFSIZE) + m68k_ptob(8)); 2700 #else 2701 high[numranges - 1] -= (m68k_round_page(MSGBUFSIZE) + m68k_ptob(1)); 2702 #endif 2703 avail_end = high[numranges - 1]; 2704 2705 if (mac68k_machine.do_graybars) 2706 printf("Pmap bootstrapped.\n"); 2707 2708 if (!vidlen) 2709 panic("Don't know how to relocate video!"); 2710 2711 if (mac68k_machine.do_graybars) 2712 printf("Moving ROMBase from %p to %p.\n", oldROMBase, ROMBase); 2713 2714 mrg_fixupROMBase(oldROMBase, ROMBase); 2715 2716 if (mac68k_machine.do_graybars) 2717 printf("Video address %p -> %p.\n", 2718 (void *)mac68k_video.mv_kvaddr, (void *)newvideoaddr); 2719 2720 mac68k_set_io_offsets(IOBase); 2721 2722 /* 2723 * If the serial ports are going (for console or 'echo'), then 2724 * we need to make sure the IO change gets propagated properly. 2725 * This resets the base addresses for the 8530 (serial) driver. 2726 * 2727 * WARNING!!! No printfs() (etc) BETWEEN zs_init() and the end 2728 * of this function (where we start using the MMU, so the new 2729 * address is correct. 2730 */ 2731 #if NZSC > 0 2732 if (zsinited != 0) 2733 zs_init(); 2734 #endif 2735 2736 mac68k_video.mv_kvaddr = newvideoaddr; 2737 2738 return nextpa; 2739 } 2740