1 /* $NetBSD: pmap_bootstrap.c,v 1.9 2009/12/06 06:41:29 tsutsui Exp $ */ 2 3 /*- 4 * Copyright (c) 1999 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Jason R. Thorpe. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 /* 33 * Copyright (c) 1991 Regents of the University of California. 34 * All rights reserved. 35 * 36 * This code is derived from software contributed to Berkeley by 37 * the Systems Programming Group of the University of Utah Computer 38 * Science Department. 39 * 40 * Redistribution and use in source and binary forms, with or without 41 * modification, are permitted provided that the following conditions 42 * are met: 43 * 1. Redistributions of source code must retain the above copyright 44 * notice, this list of conditions and the following disclaimer. 45 * 2. Redistributions in binary form must reproduce the above copyright 46 * notice, this list of conditions and the following disclaimer in the 47 * documentation and/or other materials provided with the distribution. 48 * 3. Neither the name of the University nor the names of its contributors 49 * may be used to endorse or promote products derived from this software 50 * without specific prior written permission. 51 * 52 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 53 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 54 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 55 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 56 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 57 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 58 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 59 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 60 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 61 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 62 * SUCH DAMAGE. 63 * 64 * @(#)pmap.c 7.5 (Berkeley) 5/10/91 65 */ 66 67 #include <sys/cdefs.h> 68 __KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.9 2009/12/06 06:41:29 tsutsui Exp $"); 69 70 #include <sys/param.h> 71 #include <sys/systm.h> 72 #include <sys/proc.h> 73 #include <sys/malloc.h> 74 75 #include <uvm/uvm.h> 76 77 #include <machine/pte.h> 78 #include <machine/cpu.h> 79 #include <machine/vmparam.h> 80 81 #include <m68k/cacheops.h> 82 83 #include <amiga/amiga/memlist.h> 84 85 extern paddr_t avail_start; 86 extern paddr_t avail_end; 87 88 extern paddr_t msgbufpa; 89 90 u_long noncontig_enable; 91 92 extern paddr_t z2mem_start; 93 94 extern vaddr_t reserve_dumppages(vaddr_t); 95 96 /* 97 * All those kernel PT submaps that BSD is so fond of 98 */ 99 void *CADDR1, *CADDR2; 100 char *vmmap; 101 102 /* 103 * Bootstrap the system enough to run with virtual memory. 104 * 105 * This is called after mapping has already been enabled 106 * and just syncs the pmap module with what has already been done. 107 */ 108 void 109 pmap_bootstrap(paddr_t firstaddr, paddr_t loadaddr) 110 { 111 vaddr_t va; 112 int i; 113 struct boot_memseg *sp, *esp; 114 paddr_t fromads, toads; 115 116 fromads = firstaddr; 117 toads = maxmem << PGSHIFT; 118 119 /* XXX: allow for msgbuf */ 120 toads -= m68k_round_page(MSGBUFSIZE); 121 msgbufpa = toads; 122 /* 123 * first segment of memory is always the one loadbsd found 124 * for loading the kernel into. 125 */ 126 127 uvmexp.pagesize = NBPG; 128 uvm_setpagesize(); 129 130 /* 131 * May want to check if first segment is Zorro-II? 132 */ 133 uvm_page_physload(atop(fromads), atop(toads), 134 atop(fromads), atop(toads), VM_FREELIST_DEFAULT); 135 136 sp = memlist->m_seg; 137 esp = sp + memlist->m_nseg; 138 i = 1; 139 for (; noncontig_enable && sp < esp; sp++) { 140 if ((sp->ms_attrib & MEMF_FAST) == 0) 141 continue; /* skip if not FastMem */ 142 if (firstaddr >= sp->ms_start && 143 firstaddr < sp->ms_start + sp->ms_size) 144 continue; /* skip kernel segment */ 145 if (sp->ms_size == 0) 146 continue; /* skip zero size segments */ 147 fromads = sp->ms_start; 148 toads = sp->ms_start + sp->ms_size; 149 #ifdef DEBUG_A4000 150 /* 151 * My A4000 doesn't seem to like Zorro II memory - this 152 * hack is to skip the motherboard memory and use the 153 * Zorro II memory. Only for trying to debug the problem. 154 * Michael L. Hitch 155 */ 156 if (toads == 0x08000000) 157 continue; /* skip A4000 motherboard mem */ 158 #endif 159 /* 160 * Deal with Zorro II memory stolen for DMA bounce buffers. 161 * This needs to be handled better. 162 * 163 * XXX is: disabled. This is handled now in amiga_init.c 164 * by removing the stolen memory from the memlist. 165 * 166 * XXX is: enabled again, but check real size and position. 167 * We check z2mem_start is in this segment, and set its end 168 * to the z2mem_start. 169 * 170 */ 171 if ((fromads <= z2mem_start) && (toads > z2mem_start)) 172 toads = z2mem_start; 173 174 uvm_page_physload(atop(fromads), atop(toads), 175 atop(fromads), atop(toads), (fromads & 0xff000000) ? 176 VM_FREELIST_DEFAULT : VM_FREELIST_ZORROII); 177 physmem += (toads - fromads) / PAGE_SIZE; 178 ++i; 179 if (noncontig_enable == 1) 180 break; /* Only two segments enabled */ 181 } 182 183 mem_size = physmem << PGSHIFT; 184 185 avail_start = firstaddr; 186 avail_end = toads; 187 188 virtual_end = VM_MAX_KERNEL_ADDRESS; 189 190 /* 191 * Allocate all the submaps we need 192 */ 193 #define SYSMAP(c, v, n) \ 194 v = (c)va; va += ((n)*PAGE_SIZE); 195 196 va = virtual_avail; 197 198 SYSMAP(void * ,CADDR1 ,1 ) 199 SYSMAP(void * ,CADDR2 ,1 ) 200 SYSMAP(void * ,vmmap ,1 ) 201 SYSMAP(void * ,msgbufaddr ,btoc(MSGBUFSIZE) ) 202 203 DCIS(); 204 205 virtual_avail = reserve_dumppages(va); 206 } 207