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