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 */ 35 36 #ifndef _MACHINE_VMPARAM_H_ 37 #define _MACHINE_VMPARAM_H_ 38 39 #ifndef LOCORE 40 #include <machine/md_var.h> 41 #endif 42 43 #define USRSTACK SHAREDPAGE 44 45 #ifndef MAXTSIZ 46 #define MAXTSIZ (1*1024*1024*1024) /* max text size */ 47 #endif 48 49 #ifndef DFLDSIZ 50 #define DFLDSIZ (128*1024*1024) /* default data size */ 51 #endif 52 53 #ifndef MAXDSIZ 54 #ifdef __powerpc64__ 55 #define MAXDSIZ (32UL*1024*1024*1024) /* max data size */ 56 #else 57 #define MAXDSIZ (1*1024*1024*1024) /* max data size */ 58 #endif 59 #endif 60 61 #ifndef DFLSSIZ 62 #define DFLSSIZ (8*1024*1024) /* default stack size */ 63 #endif 64 65 #ifndef MAXSSIZ 66 #ifdef __powerpc64__ 67 #define MAXSSIZ (512*1024*1024) /* max stack size */ 68 #else 69 #define MAXSSIZ (64*1024*1024) /* max stack size */ 70 #endif 71 #endif 72 73 #ifdef AIM 74 #define VM_MAXUSER_ADDRESS32 0xfffff000 75 #else 76 #define VM_MAXUSER_ADDRESS32 0x7ffff000 77 #endif 78 79 /* 80 * Would like to have MAX addresses = 0, but this doesn't (currently) work 81 */ 82 #ifdef __powerpc64__ 83 /* 84 * Virtual addresses of things. Derived from the page directory and 85 * page table indexes from pmap.h for precision. 86 * 87 * kernel map should be able to start at 0xc008000000000000 - 88 * but at least the functional simulator doesn't like it 89 * 90 * 0x0000000000000000 - 0x000fffffffffffff user map 91 * 0xc000000000000000 - 0xc007ffffffffffff direct map 92 * 0xc008000000000000 - 0xc00fffffffffffff kernel map 93 * 94 */ 95 #define VM_MIN_ADDRESS 0x0000000000000000 96 #define VM_MAXUSER_ADDRESS 0x000fffffc0000000 97 #define VM_MAX_ADDRESS 0xc00fffffffffffff 98 #define VM_MIN_KERNEL_ADDRESS 0xc008000000000000 99 #define VM_MAX_KERNEL_ADDRESS 0xc0080007ffffffff 100 #define VM_MAX_SAFE_KERNEL_ADDRESS VM_MAX_KERNEL_ADDRESS 101 #else 102 #define VM_MIN_ADDRESS 0 103 #define VM_MAXUSER_ADDRESS VM_MAXUSER_ADDRESS32 104 #define VM_MAX_ADDRESS 0xffffffff 105 #endif 106 107 #define SHAREDPAGE (VM_MAXUSER_ADDRESS - PAGE_SIZE) 108 109 #define FREEBSD32_SHAREDPAGE (VM_MAXUSER_ADDRESS32 - PAGE_SIZE) 110 #define FREEBSD32_USRSTACK FREEBSD32_SHAREDPAGE 111 112 #define KERNBASE 0x00100100 /* start of kernel virtual */ 113 114 #define UMA_MD_SMALL_ALLOC 115 116 #ifdef AIM 117 #ifndef __powerpc64__ 118 #define VM_MIN_KERNEL_ADDRESS ((vm_offset_t)KERNEL_SR << ADDR_SR_SHFT) 119 #define VM_MAX_SAFE_KERNEL_ADDRESS (VM_MIN_KERNEL_ADDRESS + 2*SEGMENT_LENGTH -1) 120 #define VM_MAX_KERNEL_ADDRESS (VM_MIN_KERNEL_ADDRESS + 3*SEGMENT_LENGTH - 1) 121 #endif 122 123 /* 124 * Use the direct-mapped BAT registers for UMA small allocs. This 125 * takes pressure off the small amount of available KVA. 126 */ 127 #define UMA_USE_DMAP 128 129 #else /* Book-E */ 130 131 /* Use the direct map for UMA small allocs on powerpc64. */ 132 #ifdef __powerpc64__ 133 #define UMA_USE_DMAP 134 #else 135 #define VM_MIN_KERNEL_ADDRESS 0xc0000000 136 #define VM_MAX_KERNEL_ADDRESS 0xffffefff 137 #define VM_MAX_SAFE_KERNEL_ADDRESS VM_MAX_KERNEL_ADDRESS 138 #endif 139 140 #endif /* AIM/E500 */ 141 142 #if !defined(LOCORE) 143 struct pmap_physseg { 144 struct pv_entry *pvent; 145 char *attrs; 146 }; 147 #endif 148 149 #ifdef __powerpc64__ 150 #define VM_PHYSSEG_MAX 63 /* 1? */ 151 #else 152 #define VM_PHYSSEG_MAX 16 /* 1? */ 153 #endif 154 155 #define PHYS_AVAIL_SZ 256 /* Allows up to 16GB Ram on pSeries with 156 * logical memory block size of 64MB. 157 * For more Ram increase the lmb or this value. 158 */ 159 160 /* XXX This is non-sensical. Phys avail should hold contiguous regions. */ 161 #define PHYS_AVAIL_ENTRIES PHYS_AVAIL_SZ 162 163 /* 164 * The physical address space is densely populated on 32-bit systems, 165 * but may not be on 64-bit ones. 166 */ 167 #ifdef __powerpc64__ 168 #define VM_PHYSSEG_SPARSE 169 #else 170 #define VM_PHYSSEG_DENSE 171 #endif 172 173 /* 174 * Create two free page pools: VM_FREEPOOL_DEFAULT is the default pool 175 * from which physical pages are allocated and VM_FREEPOOL_DIRECT is 176 * the pool from which physical pages for small UMA objects are 177 * allocated. 178 */ 179 #define VM_NFREEPOOL 2 180 #define VM_FREEPOOL_DEFAULT 0 181 #define VM_FREEPOOL_DIRECT 1 182 183 /* 184 * Create one free page list. 185 */ 186 #define VM_NFREELIST 1 187 #define VM_FREELIST_DEFAULT 0 188 189 #ifdef __powerpc64__ 190 /* The largest allocation size is 16MB. */ 191 #define VM_NFREEORDER 13 192 #else 193 /* The largest allocation size is 4MB. */ 194 #define VM_NFREEORDER 11 195 #endif 196 197 #ifndef VM_NRESERVLEVEL 198 #ifdef __powerpc64__ 199 /* Enable superpage reservations: 1 level. */ 200 #define VM_NRESERVLEVEL 1 201 #else 202 /* Disable superpage reservations. */ 203 #define VM_NRESERVLEVEL 0 204 #endif 205 #endif 206 207 #ifndef VM_LEVEL_0_ORDER 208 /* Level 0 reservations consist of 512 (RPT) or 4096 (HPT) pages. */ 209 #define VM_LEVEL_0_ORDER vm_level_0_order 210 #ifndef __ASSEMBLER__ 211 extern int vm_level_0_order; 212 #endif 213 #endif 214 215 #ifndef VM_LEVEL_0_ORDER_MAX 216 #define VM_LEVEL_0_ORDER_MAX 12 217 #endif 218 219 #ifdef __powerpc64__ 220 #ifdef SMP 221 #define PA_LOCK_COUNT 256 222 #endif 223 #endif 224 225 #ifndef VM_INITIAL_PAGEIN 226 #define VM_INITIAL_PAGEIN 16 227 #endif 228 229 #ifndef SGROWSIZ 230 #define SGROWSIZ (128UL*1024) /* amount to grow stack */ 231 #endif 232 233 /* 234 * How many physical pages per kmem arena virtual page. 235 */ 236 #ifndef VM_KMEM_SIZE_SCALE 237 #define VM_KMEM_SIZE_SCALE (3) 238 #endif 239 240 /* 241 * Optional floor (in bytes) on the size of the kmem arena. 242 */ 243 #ifndef VM_KMEM_SIZE_MIN 244 #define VM_KMEM_SIZE_MIN (12 * 1024 * 1024) 245 #endif 246 247 /* 248 * Optional ceiling (in bytes) on the size of the kmem arena: 40% of the 249 * usable KVA space. 250 */ 251 #ifndef VM_KMEM_SIZE_MAX 252 #define VM_KMEM_SIZE_MAX ((VM_MAX_SAFE_KERNEL_ADDRESS - \ 253 VM_MIN_KERNEL_ADDRESS + 1) * 2 / 5) 254 #endif 255 256 #ifdef __powerpc64__ 257 #define ZERO_REGION_SIZE (2 * 1024 * 1024) /* 2MB */ 258 #else 259 #define ZERO_REGION_SIZE (64 * 1024) /* 64KB */ 260 #endif 261 262 /* 263 * On 32-bit OEA, the only purpose for which sf_buf is used is to implement 264 * an opaque pointer required by the machine-independent parts of the kernel. 265 * That pointer references the vm_page that is "mapped" by the sf_buf. The 266 * actual mapping is provided by the direct virtual-to-physical mapping. 267 * 268 * On OEA64 and Book-E, we need to do something a little more complicated. Use 269 * the runtime-detected hw_direct_map to pick between the two cases. Our 270 * friends in vm_machdep.c will do the same to ensure nothing gets confused. 271 */ 272 #define SFBUF 273 #define SFBUF_NOMD 274 275 /* 276 * We (usually) have a direct map of all physical memory, so provide 277 * a macro to use to get the kernel VA address for a given PA. Check the 278 * value of PMAP_HAS_PMAP before using. 279 */ 280 #ifndef LOCORE 281 #ifdef __powerpc64__ 282 #define DMAP_BASE_ADDRESS 0xc000000000000000UL 283 #define DMAP_MIN_ADDRESS DMAP_BASE_ADDRESS 284 #define DMAP_MAX_ADDRESS 0xc007ffffffffffffUL 285 #else 286 #define DMAP_BASE_ADDRESS 0x00000000UL 287 #define DMAP_MAX_ADDRESS 0xbfffffffUL 288 #endif 289 #endif 290 291 #if defined(__powerpc64__) || defined(BOOKE) 292 /* 293 * powerpc64 and Book-E will provide their own page array allocators. 294 * 295 * On AIM, this will allocate a single virtual array, with pages from the 296 * correct memory domains. 297 * On Book-E this will let us put the array in TLB1, removing the need for TLB 298 * thrashing. 299 * 300 * VM_MIN_KERNEL_ADDRESS is just a dummy. It will get set by the MMU driver. 301 */ 302 #define PA_MIN_ADDRESS VM_MIN_KERNEL_ADDRESS 303 #define PMAP_HAS_PAGE_ARRAY 1 304 #endif 305 306 #if defined(__powerpc64__) 307 /* 308 * Need a page dump array for minidump. 309 */ 310 #define MINIDUMP_PAGE_TRACKING 1 311 #define MINIDUMP_STARTUP_PAGE_TRACKING 1 312 #else 313 /* 314 * No minidump with 32-bit powerpc. 315 */ 316 #define MINIDUMP_PAGE_TRACKING 0 317 #define MINIDUMP_STARTUP_PAGE_TRACKING 0 318 #endif 319 320 #define PMAP_HAS_DMAP (hw_direct_map) 321 #define PHYS_TO_DMAP(x) ({ \ 322 KASSERT(hw_direct_map, ("Direct map not provided by PMAP")); \ 323 (x) | DMAP_BASE_ADDRESS; }) 324 #define DMAP_TO_PHYS(x) ({ \ 325 KASSERT(hw_direct_map, ("Direct map not provided by PMAP")); \ 326 (x) &~ DMAP_BASE_ADDRESS; }) 327 328 /* 329 * No non-transparent large page support in the pmap. 330 */ 331 #define PMAP_HAS_LARGEPAGES 0 332 333 #endif /* _MACHINE_VMPARAM_H_ */ 334