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