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