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