1 /* $NetBSD: pmap_bootstrap.c,v 1.62 2005/02/05 23:50:05 chs Exp $ */ 2 3 /* 4 * Copyright (c) 1991, 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 * @(#)pmap_bootstrap.c 8.1 (Berkeley) 6/10/93 36 */ 37 38 #include <sys/cdefs.h> 39 __KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.62 2005/02/05 23:50:05 chs Exp $"); 40 41 #include "opt_ddb.h" 42 #include "opt_kgdb.h" 43 #include "zsc.h" 44 45 #include <sys/param.h> 46 #include <sys/systm.h> 47 #include <sys/reboot.h> 48 49 #include <uvm/uvm_extern.h> 50 51 #include <machine/pte.h> 52 #include <mac68k/mac68k/clockreg.h> 53 #include <machine/vmparam.h> 54 #include <machine/cpu.h> 55 #include <machine/pmap.h> 56 #include <machine/autoconf.h> 57 58 #include <ufs/mfs/mfs_extern.h> 59 60 #include <mac68k/mac68k/macrom.h> 61 62 #define PA2VA(v, t) (t)((u_int)(v) - firstpa) 63 64 extern char *etext; 65 extern int Sysptsize; 66 extern char *extiobase, *proc0paddr; 67 extern st_entry_t *Sysseg; 68 extern pt_entry_t *Sysptmap, *Sysmap; 69 70 extern int physmem; 71 extern paddr_t avail_start; 72 extern paddr_t avail_end; 73 extern vaddr_t virtual_avail, virtual_end; 74 extern vsize_t mem_size; 75 extern int protection_codes[]; 76 77 #if NZSC > 0 78 extern int zsinited; 79 #endif 80 81 /* 82 * These are used to map the RAM: 83 */ 84 int numranges; /* = 0 == don't use the ranges */ 85 u_long low[8]; 86 u_long high[8]; 87 u_long maxaddr; /* PA of the last physical page */ 88 int vidlen; 89 #define VIDMAPSIZE btoc(vidlen) 90 extern u_int32_t mac68k_vidphys; 91 extern u_int32_t videoaddr; 92 extern u_int32_t videorowbytes; 93 extern u_int32_t videosize; 94 static u_int32_t newvideoaddr; 95 96 extern caddr_t ROMBase; 97 98 /* 99 * Special purpose kernel virtual addresses, used for mapping 100 * physical pages for a variety of temporary or permanent purposes: 101 * 102 * CADDR1, CADDR2: pmap zero/copy operations 103 * vmmap: /dev/mem, crash dumps, parity error checking 104 * msgbufaddr: kernel message buffer 105 */ 106 caddr_t CADDR1, CADDR2, vmmap; 107 extern caddr_t msgbufaddr; 108 109 void pmap_bootstrap(paddr_t, paddr_t); 110 void bootstrap_mac68k(int); 111 112 /* 113 * Bootstrap the VM system. 114 * 115 * This is called with the MMU either on or off. If it's on, we assume 116 * that it's mapped with the same PA <=> LA mapping that we eventually 117 * want. The page sizes and the protections will be wrong, anyway. 118 * 119 * nextpa is the first address following the loaded kernel. On a IIsi 120 * on 12 May 1996, that was 0xf9000 beyond firstpa. 121 */ 122 void 123 pmap_bootstrap(paddr_t nextpa, paddr_t firstpa) 124 { 125 paddr_t kstpa, kptpa, vidpa, iiopa, rompa, kptmpa, lkptpa, p0upa; 126 u_int nptpages, kstsize; 127 paddr_t avail_next; 128 int avail_remaining; 129 int avail_range; 130 int i; 131 st_entry_t protoste, *ste; 132 pt_entry_t protopte, *pte, *epte; 133 extern char start[]; 134 135 vidlen = m68k_round_page(((videosize >> 16) & 0xffff) * videorowbytes + 136 m68k_page_offset(mac68k_vidphys)); 137 138 /* 139 * Calculate important physical addresses: 140 * 141 * kstpa kernel segment table 1 page (!040) 142 * N pages (040) 143 * 144 * kptpa statically allocated 145 * kernel PT pages Sysptsize+ pages 146 * 147 * vidpa internal video space for some machines 148 * PT pages VIDMAPSIZE pages 149 * 150 * rompa ROM space 151 * PT pages ROMMAPSIZE pages 152 * 153 * iiopa internal IO space 154 * PT pages IIOMAPSIZE pages 155 * 156 * [ Sysptsize is the number of pages of PT, IIOMAPSIZE and 157 * NBMAPSIZE are the number of PTEs, hence we need to round 158 * the total to a page boundary with IO maps at the end. ] 159 * 160 * kptmpa kernel PT map 1 page 161 * 162 * lkptpa last kernel PT page 1 page 163 * 164 * p0upa proc 0 u-area UPAGES pages 165 * 166 */ 167 if (mmutype == MMU_68040) 168 kstsize = MAXKL2SIZE / (NPTEPG/SG4_LEV2SIZE); 169 else 170 kstsize = 1; 171 kstpa = nextpa; 172 nextpa += kstsize * PAGE_SIZE; 173 kptpa = nextpa; 174 nptpages = Sysptsize + 175 (IIOMAPSIZE + ROMMAPSIZE + VIDMAPSIZE + NPTEPG - 1) / NPTEPG; 176 nextpa += nptpages * PAGE_SIZE; 177 vidpa = nextpa - VIDMAPSIZE * sizeof(pt_entry_t); 178 rompa = vidpa - ROMMAPSIZE * sizeof(pt_entry_t); 179 iiopa = rompa - IIOMAPSIZE * sizeof(pt_entry_t); 180 kptmpa = nextpa; 181 nextpa += PAGE_SIZE; 182 lkptpa = nextpa; 183 nextpa += PAGE_SIZE; 184 p0upa = nextpa; 185 nextpa += USPACE; 186 187 188 for (i = 0; i < numranges; i++) 189 if (low[i] <= firstpa && firstpa < high[i]) 190 break; 191 if (i >= numranges || nextpa > high[i]) { 192 if (mac68k_machine.do_graybars) { 193 printf("Failure in NetBSD boot; "); 194 if (i < numranges) 195 printf("nextpa=0x%lx, high[%d]=0x%lx.\n", 196 nextpa, i, high[i]); 197 else 198 printf("can't find kernel RAM segment.\n"); 199 printf("You're hosed! Try booting with 32-bit "); 200 printf("addressing enabled in the memory control "); 201 printf("panel.\n"); 202 printf("Older machines may need Mode32 to get that "); 203 printf("option.\n"); 204 } 205 panic("Cannot work with the current memory mappings."); 206 } 207 208 /* 209 * Initialize segment table and kernel page table map. 210 * 211 * On 68030s and earlier MMUs the two are identical except for 212 * the valid bits so both are initialized with essentially the 213 * same values. On the 68040, which has a mandatory 3-level 214 * structure, the segment table holds the level 1 table and part 215 * (or all) of the level 2 table and hence is considerably 216 * different. Here the first level consists of 128 descriptors 217 * (512 bytes) each mapping 32mb of address space. Each of these 218 * points to blocks of 128 second level descriptors (512 bytes) 219 * each mapping 256kb. Note that there may be additional "segment 220 * table" pages depending on how large MAXKL2SIZE is. 221 * 222 * XXX cramming two levels of mapping into the single "segment" 223 * table on the 68040 is intended as a temporary hack to get things 224 * working. The 224mb of address space that this allows will most 225 * likely be insufficient in the future (at least for the kernel). 226 */ 227 if (mmutype == MMU_68040) { 228 int num; 229 230 /* 231 * First invalidate the entire "segment table" pages 232 * (levels 1 and 2 have the same "invalid" value). 233 */ 234 pte = PA2VA(kstpa, u_int *); 235 epte = &pte[kstsize * NPTEPG]; 236 while (pte < epte) 237 *pte++ = SG_NV; 238 /* 239 * Initialize level 2 descriptors (which immediately 240 * follow the level 1 table). We need: 241 * NPTEPG / SG4_LEV3SIZE 242 * level 2 descriptors to map each of the nptpages+1 243 * pages of PTEs. Note that we set the "used" bit 244 * now to save the HW the expense of doing it. 245 */ 246 num = (nptpages + 1) * (NPTEPG / SG4_LEV3SIZE); 247 pte = &(PA2VA(kstpa, u_int *))[SG4_LEV1SIZE]; 248 epte = &pte[num]; 249 protoste = kptpa | SG_U | SG_RW | SG_V; 250 while (pte < epte) { 251 *pte++ = protoste; 252 protoste += (SG4_LEV3SIZE * sizeof(st_entry_t)); 253 } 254 /* 255 * Initialize level 1 descriptors. We need: 256 * roundup(num, SG4_LEV2SIZE) / SG4_LEV2SIZE 257 * level 1 descriptors to map the `num' level 2's. 258 */ 259 pte = PA2VA(kstpa, u_int *); 260 epte = &pte[roundup(num, SG4_LEV2SIZE) / SG4_LEV2SIZE]; 261 protoste = (u_int)&pte[SG4_LEV1SIZE] | SG_U | SG_RW | SG_V; 262 while (pte < epte) { 263 *pte++ = protoste; 264 protoste += (SG4_LEV2SIZE * sizeof(st_entry_t)); 265 } 266 /* 267 * Initialize the final level 1 descriptor to map the last 268 * block of level 2 descriptors. 269 */ 270 ste = &(PA2VA(kstpa, u_int*))[SG4_LEV1SIZE-1]; 271 pte = &(PA2VA(kstpa, u_int*))[kstsize*NPTEPG - SG4_LEV2SIZE]; 272 *ste = (u_int)pte | SG_U | SG_RW | SG_V; 273 /* 274 * Now initialize the final portion of that block of 275 * descriptors to map the "last PT page". 276 */ 277 pte = &(PA2VA(kstpa, u_int*)) 278 [kstsize*NPTEPG - NPTEPG/SG4_LEV3SIZE]; 279 epte = &pte[NPTEPG/SG4_LEV3SIZE]; 280 protoste = lkptpa | SG_U | SG_RW | SG_V; 281 while (pte < epte) { 282 *pte++ = protoste; 283 protoste += (SG4_LEV3SIZE * sizeof(st_entry_t)); 284 } 285 /* 286 * Initialize Sysptmap 287 */ 288 pte = PA2VA(kptmpa, u_int *); 289 epte = &pte[nptpages+1]; 290 protopte = kptpa | PG_RW | PG_CI | PG_V; 291 while (pte < epte) { 292 *pte++ = protopte; 293 protopte += PAGE_SIZE; 294 } 295 /* 296 * Invalidate all but the last remaining entries in both. 297 */ 298 epte = &(PA2VA(kptmpa, u_int *))[NPTEPG-1]; 299 while (pte < epte) { 300 *pte++ = PG_NV; 301 } 302 /* 303 * Initialize the last to point to the page 304 * table page allocated earlier. 305 */ 306 *pte = lkptpa | PG_RW | PG_CI | PG_V; 307 } else { 308 /* 309 * Map the page table pages in both the HW segment table 310 * and the software Sysptmap. Note that Sysptmap is also 311 * considered a PT page hence the +1. 312 */ 313 ste = PA2VA(kstpa, u_int*); 314 pte = PA2VA(kptmpa, u_int*); 315 epte = &pte[nptpages+1]; 316 protoste = kptpa | SG_RW | SG_V; 317 protopte = kptpa | PG_RW | PG_CI | PG_V; 318 while (pte < epte) { 319 *ste++ = protoste; 320 *pte++ = protopte; 321 protoste += PAGE_SIZE; 322 protopte += PAGE_SIZE; 323 } 324 /* 325 * Invalidate all but the last remaining entries in both. 326 */ 327 epte = &(PA2VA(kptmpa, u_int *))[NPTEPG-1]; 328 while (pte < epte) { 329 *ste++ = SG_NV; 330 *pte++ = PG_NV; 331 } 332 /* 333 * Initialize the last to point to point to the page 334 * table page allocated earlier. 335 */ 336 *ste = lkptpa | SG_RW | SG_V; 337 *pte = lkptpa | PG_RW | PG_CI | PG_V; 338 } 339 /* 340 * Invalidate all entries in the last kernel PT page 341 * (u-area PTEs will be validated later). 342 */ 343 pte = PA2VA(lkptpa, u_int *); 344 epte = &pte[NPTEPG]; 345 while (pte < epte) 346 *pte++ = PG_NV; 347 348 /* 349 * Initialize kernel page table. 350 * Start by invalidating the `nptpages' that we have allocated. 351 */ 352 pte = PA2VA(kptpa, u_int *); 353 epte = &pte[nptpages * NPTEPG]; 354 while (pte < epte) 355 *pte++ = PG_NV; 356 357 /* 358 * Validate PTEs for kernel text (RO). 359 * Pages up to "start" must be writable for the ROM. 360 */ 361 pte = &(PA2VA(kptpa, u_int *))[m68k_btop(KERNBASE)]; 362 epte = &pte[m68k_btop(m68k_round_page(start))]; 363 protopte = firstpa | PG_RW | PG_V; 364 while (pte < epte) { 365 *pte++ = protopte; 366 protopte += PAGE_SIZE; 367 } 368 epte = &pte[m68k_btop(m68k_trunc_page(&etext))]; 369 protopte = (protopte & ~PG_PROT) | PG_RO; 370 while (pte < epte) { 371 *pte++ = protopte; 372 protopte += PAGE_SIZE; 373 } 374 /* 375 * Validate PTEs for kernel data/bss, dynamic data allocated 376 * by us so far (nextpa - firstpa bytes), and pages for proc0 377 * u-area and page table allocated below (RW). 378 */ 379 epte = &(PA2VA(kptpa, u_int *))[m68k_btop(nextpa - firstpa)]; 380 protopte = (protopte & ~PG_PROT) | PG_RW; 381 /* 382 * Enable copy-back caching of data pages 383 */ 384 if (mmutype == MMU_68040) 385 protopte |= PG_CCB; 386 while (pte < epte) { 387 *pte++ = protopte; 388 protopte += PAGE_SIZE; 389 } 390 /* 391 * Finally, validate the internal IO space, ROM space, and 392 * framebuffer PTEs (RW+CI). 393 */ 394 pte = PA2VA(iiopa, u_int *); 395 epte = PA2VA(rompa, u_int *); 396 protopte = IOBase | PG_RW | PG_CI | PG_V; 397 while (pte < epte) { 398 *pte++ = protopte; 399 protopte += PAGE_SIZE; 400 } 401 402 pte = PA2VA(rompa, u_int *); 403 epte = PA2VA(vidpa, u_int *); 404 protopte = ((u_int) ROMBase) | PG_RO | PG_V; 405 while (pte < epte) { 406 *pte++ = protopte; 407 protopte += PAGE_SIZE; 408 } 409 410 if (vidlen) { 411 pte = PA2VA(vidpa, u_int *); 412 epte = pte + VIDMAPSIZE; 413 protopte = m68k_trunc_page(mac68k_vidphys) | 414 PG_RW | PG_V | PG_CI; 415 while (pte < epte) { 416 *pte++ = protopte; 417 protopte += PAGE_SIZE; 418 } 419 } 420 421 /* 422 * Calculate important exported kernel virtual addresses 423 */ 424 /* 425 * Sysseg: base of kernel segment table 426 */ 427 Sysseg = PA2VA(kstpa, st_entry_t *); 428 /* 429 * Sysptmap: base of kernel page table map 430 */ 431 Sysptmap = PA2VA(kptmpa, pt_entry_t *); 432 /* 433 * Sysmap: kernel page table (as mapped through Sysptmap) 434 * Immediately follows `nptpages' of static kernel page table. 435 */ 436 Sysmap = (pt_entry_t *)m68k_ptob(nptpages * NPTEPG); 437 438 IOBase = (u_long)m68k_ptob(nptpages * NPTEPG - 439 (IIOMAPSIZE + ROMMAPSIZE + VIDMAPSIZE)); 440 441 ROMBase = (char *)m68k_ptob(nptpages * NPTEPG - 442 (ROMMAPSIZE + VIDMAPSIZE)); 443 444 if (vidlen) { 445 newvideoaddr = (u_int32_t)m68k_ptob(nptpages * NPTEPG - 446 VIDMAPSIZE) + m68k_page_offset(mac68k_vidphys); 447 } 448 449 /* 450 * Setup u-area for process 0. 451 */ 452 /* 453 * Zero the u-area. 454 * NOTE: `pte' and `epte' aren't PTEs here. 455 */ 456 pte = PA2VA(p0upa, u_int *); 457 epte = (u_int *)(PA2VA(p0upa, u_int) + USPACE); 458 while (pte < epte) 459 *pte++ = 0; 460 /* 461 * Remember the u-area address so it can be loaded in the 462 * proc struct p_addr field later. 463 */ 464 proc0paddr = PA2VA(p0upa, char *); 465 466 /* 467 * VM data structures are now initialized, set up data for 468 * the pmap module. 469 * 470 * Note about avail_end: msgbuf is initialized just after 471 * avail_end in machdep.c. Since the last page is used 472 * for rebooting the system (code is copied there and 473 * excution continues from copied code before the MMU 474 * is disabled), the msgbuf will get trounced between 475 * reboots if it's placed in the last physical page. 476 * To work around this, we move avail_end back one more 477 * page so the msgbuf can be preserved. 478 */ 479 avail_next = avail_start = m68k_round_page(nextpa); 480 avail_remaining = 0; 481 avail_range = -1; 482 for (i = 0; i < numranges; i++) { 483 if (low[i] <= avail_next && avail_next < high[i]) { 484 avail_range = i; 485 avail_remaining = high[i] - avail_next; 486 } else if (avail_range != -1) { 487 avail_remaining += (high[i] - low[i]); 488 } 489 } 490 physmem = m68k_btop(avail_remaining + nextpa - firstpa); 491 492 maxaddr = high[numranges - 1] - m68k_ptob(1); 493 high[numranges - 1] -= (m68k_round_page(MSGBUFSIZE) + m68k_ptob(1)); 494 avail_end = high[numranges - 1]; 495 mem_size = m68k_ptob(physmem); 496 virtual_avail = VM_MIN_KERNEL_ADDRESS + (nextpa - firstpa); 497 virtual_end = VM_MAX_KERNEL_ADDRESS; 498 499 /* 500 * Initialize protection array. 501 * XXX don't use a switch statement, it might produce an 502 * absolute "jmp" table. 503 */ 504 { 505 int *kp; 506 507 kp = (int *)&protection_codes; 508 kp[VM_PROT_NONE|VM_PROT_NONE|VM_PROT_NONE] = 0; 509 kp[VM_PROT_READ|VM_PROT_NONE|VM_PROT_NONE] = PG_RO; 510 kp[VM_PROT_READ|VM_PROT_NONE|VM_PROT_EXECUTE] = PG_RO; 511 kp[VM_PROT_NONE|VM_PROT_NONE|VM_PROT_EXECUTE] = PG_RO; 512 kp[VM_PROT_NONE|VM_PROT_WRITE|VM_PROT_NONE] = PG_RW; 513 kp[VM_PROT_NONE|VM_PROT_WRITE|VM_PROT_EXECUTE] = PG_RW; 514 kp[VM_PROT_READ|VM_PROT_WRITE|VM_PROT_NONE] = PG_RW; 515 kp[VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE] = PG_RW; 516 } 517 518 /* 519 * Kernel page/segment table allocated in locore, 520 * just initialize pointers. 521 */ 522 { 523 struct pmap *kpm = (struct pmap *)&kernel_pmap_store; 524 525 kpm->pm_stab = Sysseg; 526 kpm->pm_ptab = Sysmap; 527 simple_lock_init(&kpm->pm_lock); 528 kpm->pm_count = 1; 529 kpm->pm_stpa = (st_entry_t *)kstpa; 530 /* 531 * For the 040 we also initialize the free level 2 532 * descriptor mask noting that we have used: 533 * 0: level 1 table 534 * 1 to `num': map page tables 535 * MAXKL2SIZE-1: maps last-page page table 536 */ 537 if (mmutype == MMU_68040) { 538 int num; 539 540 kpm->pm_stfree = ~l2tobm(0); 541 num = roundup((nptpages + 1) * (NPTEPG / SG4_LEV3SIZE), 542 SG4_LEV2SIZE) / SG4_LEV2SIZE; 543 while (num) 544 kpm->pm_stfree &= ~l2tobm(num--); 545 kpm->pm_stfree &= ~l2tobm(MAXKL2SIZE-1); 546 for (num = MAXKL2SIZE; 547 num < sizeof(kpm->pm_stfree)*NBBY; 548 num++) 549 kpm->pm_stfree &= ~l2tobm(num); 550 } 551 } 552 553 /* 554 * Allocate some fixed, special purpose kernel virtual addresses 555 */ 556 { 557 vaddr_t va = virtual_avail; 558 559 CADDR1 = (caddr_t)va; 560 va += PAGE_SIZE; 561 CADDR2 = (caddr_t)va; 562 va += PAGE_SIZE; 563 vmmap = (caddr_t)va; 564 va += PAGE_SIZE; 565 msgbufaddr = (caddr_t)va; 566 va += m68k_round_page(MSGBUFSIZE); 567 virtual_avail = va; 568 } 569 } 570 571 void 572 bootstrap_mac68k(int tc) 573 { 574 #if NZSC > 0 575 extern void zs_init(void); 576 #endif 577 extern int *esym; 578 paddr_t nextpa; 579 caddr_t oldROMBase; 580 581 if (mac68k_machine.do_graybars) 582 printf("Bootstrapping NetBSD/mac68k.\n"); 583 584 oldROMBase = ROMBase; 585 mac68k_vidphys = videoaddr; 586 587 if (((tc & 0x80000000) && (mmutype == MMU_68030)) || 588 ((tc & 0x8000) && (mmutype == MMU_68040))) { 589 if (mac68k_machine.do_graybars) 590 printf("Getting mapping from MMU.\n"); 591 (void) get_mapping(); 592 if (mac68k_machine.do_graybars) 593 printf("Done.\n"); 594 } else { 595 /* MMU not enabled. Fake up ranges. */ 596 numranges = 1; 597 low[0] = 0; 598 high[0] = mac68k_machine.mach_memsize * (1024 * 1024); 599 if (mac68k_machine.do_graybars) 600 printf("Faked range to byte 0x%lx.\n", high[0]); 601 } 602 nextpa = load_addr + m68k_round_page(esym); 603 604 if (mac68k_machine.do_graybars) 605 printf("Bootstrapping the pmap system.\n"); 606 607 pmap_bootstrap(nextpa, load_addr); 608 609 if (mac68k_machine.do_graybars) 610 printf("Pmap bootstrapped.\n"); 611 612 if (!vidlen) 613 panic("Don't know how to relocate video!"); 614 615 if (mac68k_machine.do_graybars) 616 printf("Moving ROMBase from %p to %p.\n", oldROMBase, ROMBase); 617 618 mrg_fixupROMBase(oldROMBase, ROMBase); 619 620 if (mac68k_machine.do_graybars) 621 printf("Video address 0x%lx -> 0x%lx.\n", 622 (unsigned long)videoaddr, (unsigned long)newvideoaddr); 623 624 mac68k_set_io_offsets(IOBase); 625 626 /* 627 * If the serial ports are going (for console or 'echo'), then 628 * we need to make sure the IO change gets propagated properly. 629 * This resets the base addresses for the 8530 (serial) driver. 630 * 631 * WARNING!!! No printfs() (etc) BETWEEN zs_init() and the end 632 * of this function (where we start using the MMU, so the new 633 * address is correct. 634 */ 635 #if NZSC > 0 636 if (zsinited != 0) 637 zs_init(); 638 #endif 639 640 videoaddr = newvideoaddr; 641 } 642 643 void 644 pmap_init_md(void) 645 { 646 vaddr_t addr; 647 648 addr = (vaddr_t)IOBase; 649 if (uvm_map(kernel_map, &addr, 650 m68k_ptob(IIOMAPSIZE + ROMMAPSIZE + VIDMAPSIZE), 651 NULL, UVM_UNKNOWN_OFFSET, 0, 652 UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, 653 UVM_INH_NONE, UVM_ADV_RANDOM, 654 UVM_FLAG_FIXED)) != 0) 655 panic("pmap_init_md: uvm_map failed"); 656 } 657