1 /*- 2 * SPDX-License-Identifier: BSD-4-Clause 3 * 4 * Copyright (C) 1995, 1996 Wolfgang Solfrank. 5 * Copyright (C) 1995, 1996 TooLs GmbH. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. All advertising materials mentioning features or use of this software 17 * must display the following acknowledgement: 18 * This product includes software developed by TooLs GmbH. 19 * 4. The name of TooLs GmbH may not be used to endorse or promote products 20 * derived from this software without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR 23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 * 33 * $NetBSD: vmparam.h,v 1.11 2000/02/11 19:25:16 thorpej Exp $ 34 * $FreeBSD$ 35 */ 36 37 #ifndef _MACHINE_VMPARAM_H_ 38 #define _MACHINE_VMPARAM_H_ 39 40 #ifndef LOCORE 41 #include <machine/md_var.h> 42 #endif 43 44 #define USRSTACK SHAREDPAGE 45 46 #ifndef MAXTSIZ 47 #define MAXTSIZ (1*1024*1024*1024) /* max text size */ 48 #endif 49 50 #ifndef DFLDSIZ 51 #define DFLDSIZ (128*1024*1024) /* default data size */ 52 #endif 53 54 #ifndef MAXDSIZ 55 #ifdef __powerpc64__ 56 #define MAXDSIZ (32UL*1024*1024*1024) /* max data size */ 57 #else 58 #define MAXDSIZ (1*1024*1024*1024) /* max data size */ 59 #endif 60 #endif 61 62 #ifndef DFLSSIZ 63 #define DFLSSIZ (8*1024*1024) /* default stack size */ 64 #endif 65 66 #ifndef MAXSSIZ 67 #ifdef __powerpc64__ 68 #define MAXSSIZ (512*1024*1024) /* max stack size */ 69 #else 70 #define MAXSSIZ (64*1024*1024) /* max stack size */ 71 #endif 72 #endif 73 74 #ifdef AIM 75 #define VM_MAXUSER_ADDRESS32 0xfffff000 76 #else 77 #define VM_MAXUSER_ADDRESS32 0x7ffff000 78 #endif 79 80 /* 81 * Would like to have MAX addresses = 0, but this doesn't (currently) work 82 */ 83 #ifdef __powerpc64__ 84 #define VM_MIN_ADDRESS 0x0000000000000000 85 #ifdef BOOKE 86 #define VM_MAXUSER_ADDRESS 0x000ffffffffff000 87 #else 88 #define VM_MAXUSER_ADDRESS 0x3ffffffffffff000 89 #endif 90 #define VM_MAX_ADDRESS 0xffffffffffffffff 91 #define VM_MIN_KERNEL_ADDRESS 0xe000000000000000 92 #define VM_MAX_KERNEL_ADDRESS 0xe0000007ffffffff 93 #define VM_MAX_SAFE_KERNEL_ADDRESS VM_MAX_KERNEL_ADDRESS 94 #else 95 #define VM_MIN_ADDRESS 0 96 #define VM_MAXUSER_ADDRESS VM_MAXUSER_ADDRESS32 97 #define VM_MAX_ADDRESS 0xffffffff 98 #endif 99 100 #define SHAREDPAGE (VM_MAXUSER_ADDRESS - PAGE_SIZE) 101 102 #define FREEBSD32_SHAREDPAGE (VM_MAXUSER_ADDRESS32 - PAGE_SIZE) 103 #define FREEBSD32_USRSTACK FREEBSD32_SHAREDPAGE 104 105 #define KERNBASE 0x00100100 /* start of kernel virtual */ 106 107 #ifdef AIM 108 #ifndef __powerpc64__ 109 #define VM_MIN_KERNEL_ADDRESS ((vm_offset_t)KERNEL_SR << ADDR_SR_SHFT) 110 #define VM_MAX_SAFE_KERNEL_ADDRESS (VM_MIN_KERNEL_ADDRESS + 2*SEGMENT_LENGTH -1) 111 #define VM_MAX_KERNEL_ADDRESS (VM_MIN_KERNEL_ADDRESS + 3*SEGMENT_LENGTH - 1) 112 #endif 113 114 /* 115 * Use the direct-mapped BAT registers for UMA small allocs. This 116 * takes pressure off the small amount of available KVA. 117 */ 118 #define UMA_MD_SMALL_ALLOC 119 120 #else /* Book-E */ 121 122 /* Use the direct map for UMA small allocs on powerpc64. */ 123 #ifdef __powerpc64__ 124 #define UMA_MD_SMALL_ALLOC 125 #else 126 #define VM_MIN_KERNEL_ADDRESS 0xc0000000 127 #define VM_MAX_KERNEL_ADDRESS 0xffffefff 128 #define VM_MAX_SAFE_KERNEL_ADDRESS VM_MAX_KERNEL_ADDRESS 129 #endif 130 131 #endif /* AIM/E500 */ 132 133 #if !defined(LOCORE) 134 struct pmap_physseg { 135 struct pv_entry *pvent; 136 char *attrs; 137 }; 138 #endif 139 140 #define VM_PHYSSEG_MAX 16 141 142 #define PHYS_AVAIL_SZ 256 /* Allows up to 16GB Ram on pSeries with 143 * logical memory block size of 64MB. 144 * For more Ram increase the lmb or this value. 145 */ 146 147 /* XXX This is non-sensical. Phys avail should hold contiguous regions. */ 148 #define PHYS_AVAIL_ENTRIES PHYS_AVAIL_SZ 149 150 /* 151 * The physical address space is densely populated on 32-bit systems, 152 * but may not be on 64-bit ones. 153 */ 154 #ifdef __powerpc64__ 155 #define VM_PHYSSEG_SPARSE 156 #else 157 #define VM_PHYSSEG_DENSE 158 #endif 159 160 /* 161 * Create two free page pools: VM_FREEPOOL_DEFAULT is the default pool 162 * from which physical pages are allocated and VM_FREEPOOL_DIRECT is 163 * the pool from which physical pages for small UMA objects are 164 * allocated. 165 */ 166 #define VM_NFREEPOOL 2 167 #define VM_FREEPOOL_DEFAULT 0 168 #define VM_FREEPOOL_DIRECT 1 169 170 /* 171 * Create one free page list. 172 */ 173 #define VM_NFREELIST 1 174 #define VM_FREELIST_DEFAULT 0 175 176 /* 177 * The largest allocation size is 4MB. 178 */ 179 #define VM_NFREEORDER 11 180 181 /* 182 * Disable superpage reservations. 183 */ 184 #ifndef VM_NRESERVLEVEL 185 #define VM_NRESERVLEVEL 0 186 #endif 187 188 #ifndef VM_INITIAL_PAGEIN 189 #define VM_INITIAL_PAGEIN 16 190 #endif 191 192 #ifndef SGROWSIZ 193 #define SGROWSIZ (128UL*1024) /* amount to grow stack */ 194 #endif 195 196 /* 197 * How many physical pages per kmem arena virtual page. 198 */ 199 #ifndef VM_KMEM_SIZE_SCALE 200 #define VM_KMEM_SIZE_SCALE (3) 201 #endif 202 203 /* 204 * Optional floor (in bytes) on the size of the kmem arena. 205 */ 206 #ifndef VM_KMEM_SIZE_MIN 207 #define VM_KMEM_SIZE_MIN (12 * 1024 * 1024) 208 #endif 209 210 /* 211 * Optional ceiling (in bytes) on the size of the kmem arena: 40% of the 212 * usable KVA space. 213 */ 214 #ifndef VM_KMEM_SIZE_MAX 215 #define VM_KMEM_SIZE_MAX ((VM_MAX_SAFE_KERNEL_ADDRESS - \ 216 VM_MIN_KERNEL_ADDRESS + 1) * 2 / 5) 217 #endif 218 219 #define ZERO_REGION_SIZE (64 * 1024) /* 64KB */ 220 221 /* 222 * On 32-bit OEA, the only purpose for which sf_buf is used is to implement 223 * an opaque pointer required by the machine-independent parts of the kernel. 224 * That pointer references the vm_page that is "mapped" by the sf_buf. The 225 * actual mapping is provided by the direct virtual-to-physical mapping. 226 * 227 * On OEA64 and Book-E, we need to do something a little more complicated. Use 228 * the runtime-detected hw_direct_map to pick between the two cases. Our 229 * friends in vm_machdep.c will do the same to ensure nothing gets confused. 230 */ 231 #define SFBUF 232 #define SFBUF_NOMD 233 234 /* 235 * We (usually) have a direct map of all physical memory, so provide 236 * a macro to use to get the kernel VA address for a given PA. Check the 237 * value of PMAP_HAS_PMAP before using. 238 */ 239 #ifndef LOCORE 240 #ifdef __powerpc64__ 241 #define DMAP_BASE_ADDRESS 0xc000000000000000UL 242 #define DMAP_MAX_ADDRESS 0xcfffffffffffffffUL 243 #else 244 #define DMAP_BASE_ADDRESS 0x00000000UL 245 #define DMAP_MAX_ADDRESS 0xbfffffffUL 246 #endif 247 #endif 248 249 #if defined(__powerpc64__) || defined(BOOKE) 250 /* 251 * powerpc64 and Book-E will provide their own page array allocators. 252 * 253 * On AIM, this will allocate a single virtual array, with pages from the 254 * correct memory domains. 255 * On Book-E this will let us put the array in TLB1, removing the need for TLB 256 * thrashing. 257 * 258 * VM_MIN_KERNEL_ADDRESS is just a dummy. It will get set by the MMU driver. 259 */ 260 #define PA_MIN_ADDRESS VM_MIN_KERNEL_ADDRESS 261 #define PMAP_HAS_PAGE_ARRAY 1 262 #endif 263 264 #define PMAP_HAS_DMAP (hw_direct_map) 265 #define PHYS_TO_DMAP(x) ({ \ 266 KASSERT(hw_direct_map, ("Direct map not provided by PMAP")); \ 267 (x) | DMAP_BASE_ADDRESS; }) 268 #define DMAP_TO_PHYS(x) ({ \ 269 KASSERT(hw_direct_map, ("Direct map not provided by PMAP")); \ 270 (x) &~ DMAP_BASE_ADDRESS; }) 271 272 #endif /* _MACHINE_VMPARAM_H_ */ 273