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