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