1 /* $NetBSD: pmap_bootstrap.c,v 1.7 2010/04/13 09:49:54 tsutsui Exp $ */ 2 /*- 3 * Copyright (c) 1999 The NetBSD Foundation, Inc. 4 * All rights reserved. 5 * 6 * This code is derived from software contributed to The NetBSD Foundation 7 * by Jason R. Thorpe. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 /* 32 * Copyright (c) 1991 Regents of the University of California. 33 * All rights reserved. 34 * 35 * This code is derived from software contributed to Berkeley by 36 * the Systems Programming Group of the University of Utah Computer 37 * Science Department. 38 * 39 * Redistribution and use in source and binary forms, with or without 40 * modification, are permitted provided that the following conditions 41 * are met: 42 * 1. Redistributions of source code must retain the above copyright 43 * notice, this list of conditions and the following disclaimer. 44 * 2. Redistributions in binary form must reproduce the above copyright 45 * notice, this list of conditions and the following disclaimer in the 46 * documentation and/or other materials provided with the distribution. 47 * 3. Neither the name of the University nor the names of its contributors 48 * may be used to endorse or promote products derived from this software 49 * without specific prior written permission. 50 * 51 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 52 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 53 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 54 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 55 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 56 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 57 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 58 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 59 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 60 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 61 * SUCH DAMAGE. 62 * 63 * @(#)pmap.c 7.5 (Berkeley) 5/10/91 64 */ 65 66 #include <sys/cdefs.h> 67 68 #include <sys/param.h> 69 #include <sys/systm.h> 70 #include <sys/proc.h> 71 #include <sys/malloc.h> 72 73 #include <uvm/uvm.h> 74 75 #include <machine/pte.h> 76 #include <machine/cpu.h> 77 #include <machine/vmparam.h> 78 79 #include <m68k/cacheops.h> 80 81 struct memseg boot_segs[NMEM_SEGS]; 82 struct memseg usable_segs[NMEM_SEGS]; 83 84 extern paddr_t avail_start; 85 extern paddr_t avail_end; 86 87 extern paddr_t msgbufpa; 88 89 /* 90 * All those kernel PT submaps that BSD is so fond of 91 */ 92 void *CADDR1, *CADDR2; 93 char *vmmap; 94 95 /* 96 * Bootstrap the system enough to run with virtual memory. 97 * 98 * This is called after mapping has already been enabled 99 * and just syncs the pmap module with what has already been done. 100 */ 101 void 102 pmap_bootstrap(vaddr_t vstart) 103 { 104 vaddr_t va; 105 int i; 106 107 /* 108 * Announce page-size to the VM-system 109 */ 110 uvmexp.pagesize = NBPG; 111 uvm_setpagesize(); 112 113 /* 114 * Setup physical address ranges 115 */ 116 for (i = 0; usable_segs[i + 1].start; i++) 117 ; 118 /* XXX: allow for msgbuf */ 119 usable_segs[i].end -= m68k_round_page(MSGBUFSIZE); 120 msgbufpa = usable_segs[i].end; 121 122 /* 123 * Count physical memory 124 */ 125 mem_size = 0; 126 for (i = 0; i < NMEM_SEGS; i++) { 127 if (boot_segs[i].start == boot_segs[i].end) 128 break; 129 mem_size += boot_segs[i].end - boot_segs[i].start; 130 } 131 132 /* 133 * Announce available memory to the VM-system 134 */ 135 for (i = 0; usable_segs[i].start; i++) 136 uvm_page_physload(atop(usable_segs[i].start), 137 atop(usable_segs[i].end), 138 atop(usable_segs[i].start), 139 atop(usable_segs[i].end), 140 usable_segs[i].free_list); 141 142 avail_start = usable_segs[0].start; 143 avail_end = usable_segs[i - 1].end; 144 145 virtual_avail = vstart; 146 virtual_end = VM_MAX_KERNEL_ADDRESS; 147 148 /* 149 * Allocate all the submaps we need 150 */ 151 #define SYSMAP(c, v, n) \ 152 v = (c)va; va += ((n)*PAGE_SIZE); 153 154 va = virtual_avail; 155 156 SYSMAP(void * ,CADDR1 ,1 ) 157 SYSMAP(void * ,CADDR2 ,1 ) 158 SYSMAP(void * ,vmmap ,1 ) 159 SYSMAP(void * ,msgbufaddr ,btoc(MSGBUFSIZE) ) 160 161 DCIS(); 162 163 virtual_avail = reserve_dumppages(va); 164 } 165