1f9bac91bSBenno Rice /*- 251369649SPedro F. Giffuni * SPDX-License-Identifier: BSD-4-Clause 351369649SPedro F. Giffuni * 4f9bac91bSBenno Rice * Copyright (C) 1995, 1996 Wolfgang Solfrank. 5f9bac91bSBenno Rice * Copyright (C) 1995, 1996 TooLs GmbH. 6f9bac91bSBenno Rice * All rights reserved. 7f9bac91bSBenno Rice * 8f9bac91bSBenno Rice * Redistribution and use in source and binary forms, with or without 9f9bac91bSBenno Rice * modification, are permitted provided that the following conditions 10f9bac91bSBenno Rice * are met: 11f9bac91bSBenno Rice * 1. Redistributions of source code must retain the above copyright 12f9bac91bSBenno Rice * notice, this list of conditions and the following disclaimer. 13f9bac91bSBenno Rice * 2. Redistributions in binary form must reproduce the above copyright 14f9bac91bSBenno Rice * notice, this list of conditions and the following disclaimer in the 15f9bac91bSBenno Rice * documentation and/or other materials provided with the distribution. 16f9bac91bSBenno Rice * 3. All advertising materials mentioning features or use of this software 17f9bac91bSBenno Rice * must display the following acknowledgement: 18f9bac91bSBenno Rice * This product includes software developed by TooLs GmbH. 19f9bac91bSBenno Rice * 4. The name of TooLs GmbH may not be used to endorse or promote products 20f9bac91bSBenno Rice * derived from this software without specific prior written permission. 21f9bac91bSBenno Rice * 22f9bac91bSBenno Rice * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR 23f9bac91bSBenno Rice * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24f9bac91bSBenno Rice * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25f9bac91bSBenno Rice * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26f9bac91bSBenno Rice * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27f9bac91bSBenno Rice * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 28f9bac91bSBenno Rice * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29f9bac91bSBenno Rice * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 30f9bac91bSBenno Rice * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 31f9bac91bSBenno Rice * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32f9bac91bSBenno Rice * 33f9bac91bSBenno Rice * $NetBSD: vmparam.h,v 1.11 2000/02/11 19:25:16 thorpej Exp $ 34f9bac91bSBenno Rice */ 35f9bac91bSBenno Rice 36f9bac91bSBenno Rice #ifndef _MACHINE_VMPARAM_H_ 37f9bac91bSBenno Rice #define _MACHINE_VMPARAM_H_ 38f9bac91bSBenno Rice 399a8196ceSNathan Whitehorn #ifndef LOCORE 409a8196ceSNathan Whitehorn #include <machine/md_var.h> 419a8196ceSNathan Whitehorn #endif 429a8196ceSNathan Whitehorn 43640c77e1SKonstantin Belousov #define USRSTACK SHAREDPAGE 44f9bac91bSBenno Rice 45f9bac91bSBenno Rice #ifndef MAXTSIZ 46615df4c1SJustin Hibbits #define MAXTSIZ (1*1024*1024*1024) /* max text size */ 47f9bac91bSBenno Rice #endif 48f9bac91bSBenno Rice 49f9bac91bSBenno Rice #ifndef DFLDSIZ 5050b8e360SNathan Whitehorn #define DFLDSIZ (128*1024*1024) /* default data size */ 51f9bac91bSBenno Rice #endif 52f9bac91bSBenno Rice 53f9bac91bSBenno Rice #ifndef MAXDSIZ 5487879ba8SJustin Hibbits #ifdef __powerpc64__ 5587879ba8SJustin Hibbits #define MAXDSIZ (32UL*1024*1024*1024) /* max data size */ 5687879ba8SJustin Hibbits #else 5750b8e360SNathan Whitehorn #define MAXDSIZ (1*1024*1024*1024) /* max data size */ 58f9bac91bSBenno Rice #endif 5987879ba8SJustin Hibbits #endif 60f9bac91bSBenno Rice 61f9bac91bSBenno Rice #ifndef DFLSSIZ 6250b8e360SNathan Whitehorn #define DFLSSIZ (8*1024*1024) /* default stack size */ 63f9bac91bSBenno Rice #endif 64f9bac91bSBenno Rice 65f9bac91bSBenno Rice #ifndef MAXSSIZ 667e792cb8SAndreas Tobler #ifdef __powerpc64__ 677e792cb8SAndreas Tobler #define MAXSSIZ (512*1024*1024) /* max stack size */ 687e792cb8SAndreas Tobler #else 6950b8e360SNathan Whitehorn #define MAXSSIZ (64*1024*1024) /* max stack size */ 70f9bac91bSBenno Rice #endif 717e792cb8SAndreas Tobler #endif 72f9bac91bSBenno Rice 739932a3feSNathan Whitehorn #ifdef AIM 746793e5b2SJustin Hibbits #define VM_MAXUSER_ADDRESS32 0xfffff000 759932a3feSNathan Whitehorn #else 766793e5b2SJustin Hibbits #define VM_MAXUSER_ADDRESS32 0x7ffff000 779932a3feSNathan Whitehorn #endif 789932a3feSNathan Whitehorn 79f9bac91bSBenno Rice /* 80ffb56695SRafal Jaworowski * Would like to have MAX addresses = 0, but this doesn't (currently) work 81ffb56695SRafal Jaworowski */ 82c3e289e1SNathan Whitehorn #ifdef __powerpc64__ 8365bbba25SJustin Hibbits /* 8465bbba25SJustin Hibbits * Virtual addresses of things. Derived from the page directory and 8565bbba25SJustin Hibbits * page table indexes from pmap.h for precision. 8665bbba25SJustin Hibbits * 8765bbba25SJustin Hibbits * kernel map should be able to start at 0xc008000000000000 - 8865bbba25SJustin Hibbits * but at least the functional simulator doesn't like it 8965bbba25SJustin Hibbits * 9065bbba25SJustin Hibbits * 0x0000000000000000 - 0x000fffffffffffff user map 9165bbba25SJustin Hibbits * 0xc000000000000000 - 0xc007ffffffffffff direct map 9265bbba25SJustin Hibbits * 0xc008000000000000 - 0xc00fffffffffffff kernel map 9365bbba25SJustin Hibbits * 9465bbba25SJustin Hibbits */ 956793e5b2SJustin Hibbits #define VM_MIN_ADDRESS 0x0000000000000000 9665bbba25SJustin Hibbits #define VM_MAXUSER_ADDRESS 0x000fffffc0000000 9765bbba25SJustin Hibbits #define VM_MAX_ADDRESS 0xc00fffffffffffff 9865bbba25SJustin Hibbits #define VM_MIN_KERNEL_ADDRESS 0xc008000000000000 9965bbba25SJustin Hibbits #define VM_MAX_KERNEL_ADDRESS 0xc0080007ffffffff 1006793e5b2SJustin Hibbits #define VM_MAX_SAFE_KERNEL_ADDRESS VM_MAX_KERNEL_ADDRESS 101e683c328SJustin Hibbits #else 1026793e5b2SJustin Hibbits #define VM_MIN_ADDRESS 0 1036793e5b2SJustin Hibbits #define VM_MAXUSER_ADDRESS VM_MAXUSER_ADDRESS32 1046793e5b2SJustin Hibbits #define VM_MAX_ADDRESS 0xffffffff 105c3e289e1SNathan Whitehorn #endif 1066793e5b2SJustin Hibbits 1076793e5b2SJustin Hibbits #define SHAREDPAGE (VM_MAXUSER_ADDRESS - PAGE_SIZE) 108ffb56695SRafal Jaworowski 1099932a3feSNathan Whitehorn #define FREEBSD32_SHAREDPAGE (VM_MAXUSER_ADDRESS32 - PAGE_SIZE) 110640c77e1SKonstantin Belousov #define FREEBSD32_USRSTACK FREEBSD32_SHAREDPAGE 111ffb56695SRafal Jaworowski 1128f69e36dSJustin Hibbits #define KERNBASE 0x00100100 /* start of kernel virtual */ 113e683c328SJustin Hibbits 114da76d349SBojan Novković #define UMA_MD_SMALL_ALLOC 115da76d349SBojan Novković 1166793e5b2SJustin Hibbits #ifdef AIM 117e683c328SJustin Hibbits #ifndef __powerpc64__ 118c3e289e1SNathan Whitehorn #define VM_MIN_KERNEL_ADDRESS ((vm_offset_t)KERNEL_SR << ADDR_SR_SHFT) 119ab739706SNathan Whitehorn #define VM_MAX_SAFE_KERNEL_ADDRESS (VM_MIN_KERNEL_ADDRESS + 2*SEGMENT_LENGTH -1) 120ab739706SNathan Whitehorn #define VM_MAX_KERNEL_ADDRESS (VM_MIN_KERNEL_ADDRESS + 3*SEGMENT_LENGTH - 1) 121c3e289e1SNathan Whitehorn #endif 122ffb56695SRafal Jaworowski 123ffb56695SRafal Jaworowski /* 124db55e39aSPeter Grehan * Use the direct-mapped BAT registers for UMA small allocs. This 125db55e39aSPeter Grehan * takes pressure off the small amount of available KVA. 126db55e39aSPeter Grehan */ 127da76d349SBojan Novković #define UMA_USE_DMAP 128db55e39aSPeter Grehan 129c3e289e1SNathan Whitehorn #else /* Book-E */ 130f9bac91bSBenno Rice 131141a0ab0SJustin Hibbits /* Use the direct map for UMA small allocs on powerpc64. */ 132141a0ab0SJustin Hibbits #ifdef __powerpc64__ 133da76d349SBojan Novković #define UMA_USE_DMAP 1346793e5b2SJustin Hibbits #else 13545b33e80SJustin Hibbits #define VM_MIN_KERNEL_ADDRESS 0xc0000000 136009dedabSJustin Hibbits #define VM_MAX_KERNEL_ADDRESS 0xffffefff 137a7bb5efaSNathan Whitehorn #define VM_MAX_SAFE_KERNEL_ADDRESS VM_MAX_KERNEL_ADDRESS 138e683c328SJustin Hibbits #endif 139ffb56695SRafal Jaworowski 140ffb56695SRafal Jaworowski #endif /* AIM/E500 */ 1417c277971SPeter Grehan 142ffb56695SRafal Jaworowski #if !defined(LOCORE) 143f9bac91bSBenno Rice struct pmap_physseg { 144f9bac91bSBenno Rice struct pv_entry *pvent; 145f9bac91bSBenno Rice char *attrs; 146f9bac91bSBenno Rice }; 147ffb56695SRafal Jaworowski #endif 148f9bac91bSBenno Rice 14965bbba25SJustin Hibbits #ifdef __powerpc64__ 15065bbba25SJustin Hibbits #define VM_PHYSSEG_MAX 63 /* 1? */ 15165bbba25SJustin Hibbits #else 15265bbba25SJustin Hibbits #define VM_PHYSSEG_MAX 16 /* 1? */ 15365bbba25SJustin Hibbits #endif 15421943937SJeff Roberson 15521943937SJeff Roberson #define PHYS_AVAIL_SZ 256 /* Allows up to 16GB Ram on pSeries with 15621943937SJeff Roberson * logical memory block size of 64MB. 15721943937SJeff Roberson * For more Ram increase the lmb or this value. 15821943937SJeff Roberson */ 15921943937SJeff Roberson 16021943937SJeff Roberson /* XXX This is non-sensical. Phys avail should hold contiguous regions. */ 16121943937SJeff Roberson #define PHYS_AVAIL_ENTRIES PHYS_AVAIL_SZ 162f9bac91bSBenno Rice 16304a18977SAlan Cox /* 1642bb4662eSNathan Whitehorn * The physical address space is densely populated on 32-bit systems, 1652bb4662eSNathan Whitehorn * but may not be on 64-bit ones. 16604a18977SAlan Cox */ 1676d4bd090SJustin Hibbits #ifdef __powerpc64__ 1682bb4662eSNathan Whitehorn #define VM_PHYSSEG_SPARSE 1692bb4662eSNathan Whitehorn #else 17004a18977SAlan Cox #define VM_PHYSSEG_DENSE 1712bb4662eSNathan Whitehorn #endif 17204a18977SAlan Cox 1732446e4f0SAlan Cox /* 174966272caSAlan Cox * Create two free page pools: VM_FREEPOOL_DEFAULT is the default pool 1752446e4f0SAlan Cox * from which physical pages are allocated and VM_FREEPOOL_DIRECT is 1762446e4f0SAlan Cox * the pool from which physical pages for small UMA objects are 1772446e4f0SAlan Cox * allocated. 1782446e4f0SAlan Cox */ 179966272caSAlan Cox #define VM_NFREEPOOL 2 1802446e4f0SAlan Cox #define VM_FREEPOOL_DEFAULT 0 1812446e4f0SAlan Cox #define VM_FREEPOOL_DIRECT 1 1822446e4f0SAlan Cox 1832446e4f0SAlan Cox /* 1842446e4f0SAlan Cox * Create one free page list. 1852446e4f0SAlan Cox */ 186f9bac91bSBenno Rice #define VM_NFREELIST 1 187f9bac91bSBenno Rice #define VM_FREELIST_DEFAULT 0 188f9bac91bSBenno Rice 18965bbba25SJustin Hibbits #ifdef __powerpc64__ 190e2d6c417SLeandro Lupori /* The largest allocation size is 16MB. */ 19165bbba25SJustin Hibbits #define VM_NFREEORDER 13 19265bbba25SJustin Hibbits #else 193e2d6c417SLeandro Lupori /* The largest allocation size is 4MB. */ 1942446e4f0SAlan Cox #define VM_NFREEORDER 11 19565bbba25SJustin Hibbits #endif 1962446e4f0SAlan Cox 19765bbba25SJustin Hibbits #ifndef VM_NRESERVLEVEL 19865bbba25SJustin Hibbits #ifdef __powerpc64__ 199e2d6c417SLeandro Lupori /* Enable superpage reservations: 1 level. */ 20065bbba25SJustin Hibbits #define VM_NRESERVLEVEL 1 20165bbba25SJustin Hibbits #else 202e2d6c417SLeandro Lupori /* Disable superpage reservations. */ 203b8e7fc24SAlan Cox #define VM_NRESERVLEVEL 0 204b8e7fc24SAlan Cox #endif 20565bbba25SJustin Hibbits #endif 20665bbba25SJustin Hibbits 20765bbba25SJustin Hibbits #ifndef VM_LEVEL_0_ORDER 208e2d6c417SLeandro Lupori /* Level 0 reservations consist of 512 (RPT) or 4096 (HPT) pages. */ 209e2d6c417SLeandro Lupori #define VM_LEVEL_0_ORDER vm_level_0_order 210e2d6c417SLeandro Lupori #ifndef __ASSEMBLER__ 211e2d6c417SLeandro Lupori extern int vm_level_0_order; 212e2d6c417SLeandro Lupori #endif 213e2d6c417SLeandro Lupori #endif 214e2d6c417SLeandro Lupori 215e2d6c417SLeandro Lupori #ifndef VM_LEVEL_0_ORDER_MAX 216e2d6c417SLeandro Lupori #define VM_LEVEL_0_ORDER_MAX 12 21765bbba25SJustin Hibbits #endif 21865bbba25SJustin Hibbits 21965bbba25SJustin Hibbits #ifdef __powerpc64__ 22065bbba25SJustin Hibbits #ifdef SMP 22165bbba25SJustin Hibbits #define PA_LOCK_COUNT 256 22265bbba25SJustin Hibbits #endif 22365bbba25SJustin Hibbits #endif 224b8e7fc24SAlan Cox 225f9bac91bSBenno Rice #ifndef VM_INITIAL_PAGEIN 226f9bac91bSBenno Rice #define VM_INITIAL_PAGEIN 16 227f9bac91bSBenno Rice #endif 228f9bac91bSBenno Rice 229f9bac91bSBenno Rice #ifndef SGROWSIZ 230f9bac91bSBenno Rice #define SGROWSIZ (128UL*1024) /* amount to grow stack */ 231f9bac91bSBenno Rice #endif 232f9bac91bSBenno Rice 233a7bb5efaSNathan Whitehorn /* 234c70af487SAlan Cox * How many physical pages per kmem arena virtual page. 235a7bb5efaSNathan Whitehorn */ 236c3e289e1SNathan Whitehorn #ifndef VM_KMEM_SIZE_SCALE 237c3e289e1SNathan Whitehorn #define VM_KMEM_SIZE_SCALE (3) 238c3e289e1SNathan Whitehorn #endif 239c3e289e1SNathan Whitehorn 240a7bb5efaSNathan Whitehorn /* 241c70af487SAlan Cox * Optional floor (in bytes) on the size of the kmem arena. 242c70af487SAlan Cox */ 243c70af487SAlan Cox #ifndef VM_KMEM_SIZE_MIN 244c70af487SAlan Cox #define VM_KMEM_SIZE_MIN (12 * 1024 * 1024) 245c70af487SAlan Cox #endif 246c70af487SAlan Cox 247c70af487SAlan Cox /* 248c70af487SAlan Cox * Optional ceiling (in bytes) on the size of the kmem arena: 40% of the 249c70af487SAlan Cox * usable KVA space. 250a7bb5efaSNathan Whitehorn */ 251c3e289e1SNathan Whitehorn #ifndef VM_KMEM_SIZE_MAX 252a7bb5efaSNathan Whitehorn #define VM_KMEM_SIZE_MAX ((VM_MAX_SAFE_KERNEL_ADDRESS - \ 253a7bb5efaSNathan Whitehorn VM_MIN_KERNEL_ADDRESS + 1) * 2 / 5) 254c3e289e1SNathan Whitehorn #endif 255c3e289e1SNathan Whitehorn 25665bbba25SJustin Hibbits #ifdef __powerpc64__ 25765bbba25SJustin Hibbits #define ZERO_REGION_SIZE (2 * 1024 * 1024) /* 2MB */ 25865bbba25SJustin Hibbits #else 259cfb00e5aSMatthew D Fleming #define ZERO_REGION_SIZE (64 * 1024) /* 64KB */ 26065bbba25SJustin Hibbits #endif 26165bbba25SJustin Hibbits 26265bbba25SJustin Hibbits /* 263c8d2ffd6SGleb Smirnoff * On 32-bit OEA, the only purpose for which sf_buf is used is to implement 264c8d2ffd6SGleb Smirnoff * an opaque pointer required by the machine-independent parts of the kernel. 265c8d2ffd6SGleb Smirnoff * That pointer references the vm_page that is "mapped" by the sf_buf. The 266c8d2ffd6SGleb Smirnoff * actual mapping is provided by the direct virtual-to-physical mapping. 267c8d2ffd6SGleb Smirnoff * 268c8d2ffd6SGleb Smirnoff * On OEA64 and Book-E, we need to do something a little more complicated. Use 269c8d2ffd6SGleb Smirnoff * the runtime-detected hw_direct_map to pick between the two cases. Our 270c8d2ffd6SGleb Smirnoff * friends in vm_machdep.c will do the same to ensure nothing gets confused. 271c8d2ffd6SGleb Smirnoff */ 272c8d2ffd6SGleb Smirnoff #define SFBUF 273c8d2ffd6SGleb Smirnoff #define SFBUF_NOMD 27468b9c019SNathan Whitehorn 27568b9c019SNathan Whitehorn /* 2769a8196ceSNathan Whitehorn * We (usually) have a direct map of all physical memory, so provide 277f9edb09dSNathan Whitehorn * a macro to use to get the kernel VA address for a given PA. Check the 278f9edb09dSNathan Whitehorn * value of PMAP_HAS_PMAP before using. 27968b9c019SNathan Whitehorn */ 280f9edb09dSNathan Whitehorn #ifndef LOCORE 2819a8196ceSNathan Whitehorn #ifdef __powerpc64__ 282f9edb09dSNathan Whitehorn #define DMAP_BASE_ADDRESS 0xc000000000000000UL 28365bbba25SJustin Hibbits #define DMAP_MIN_ADDRESS DMAP_BASE_ADDRESS 28465bbba25SJustin Hibbits #define DMAP_MAX_ADDRESS 0xc007ffffffffffffUL 2859a8196ceSNathan Whitehorn #else 2869a8196ceSNathan Whitehorn #define DMAP_BASE_ADDRESS 0x00000000UL 287f9edb09dSNathan Whitehorn #define DMAP_MAX_ADDRESS 0xbfffffffUL 288f9edb09dSNathan Whitehorn #endif 2899a8196ceSNathan Whitehorn #endif 2909a8196ceSNathan Whitehorn 291caef3e12SJustin Hibbits #if defined(__powerpc64__) || defined(BOOKE) 292caef3e12SJustin Hibbits /* 293caef3e12SJustin Hibbits * powerpc64 and Book-E will provide their own page array allocators. 294caef3e12SJustin Hibbits * 295caef3e12SJustin Hibbits * On AIM, this will allocate a single virtual array, with pages from the 296caef3e12SJustin Hibbits * correct memory domains. 297caef3e12SJustin Hibbits * On Book-E this will let us put the array in TLB1, removing the need for TLB 298caef3e12SJustin Hibbits * thrashing. 299caef3e12SJustin Hibbits * 300caef3e12SJustin Hibbits * VM_MIN_KERNEL_ADDRESS is just a dummy. It will get set by the MMU driver. 301caef3e12SJustin Hibbits */ 302caef3e12SJustin Hibbits #define PA_MIN_ADDRESS VM_MIN_KERNEL_ADDRESS 303caef3e12SJustin Hibbits #define PMAP_HAS_PAGE_ARRAY 1 304caef3e12SJustin Hibbits #endif 305caef3e12SJustin Hibbits 306ab041f71SD Scott Phillips #if defined(__powerpc64__) 307ab041f71SD Scott Phillips /* 308ab041f71SD Scott Phillips * Need a page dump array for minidump. 309ab041f71SD Scott Phillips */ 310ab041f71SD Scott Phillips #define MINIDUMP_PAGE_TRACKING 1 311*0a44b8a5SBojan Novković #define MINIDUMP_STARTUP_PAGE_TRACKING 1 312ab041f71SD Scott Phillips #else 313ab041f71SD Scott Phillips /* 314ab041f71SD Scott Phillips * No minidump with 32-bit powerpc. 315ab041f71SD Scott Phillips */ 316ab041f71SD Scott Phillips #define MINIDUMP_PAGE_TRACKING 0 317*0a44b8a5SBojan Novković #define MINIDUMP_STARTUP_PAGE_TRACKING 0 318ab041f71SD Scott Phillips #endif 319ab041f71SD Scott Phillips 3209a8196ceSNathan Whitehorn #define PMAP_HAS_DMAP (hw_direct_map) 3219a8196ceSNathan Whitehorn #define PHYS_TO_DMAP(x) ({ \ 3229a8196ceSNathan Whitehorn KASSERT(hw_direct_map, ("Direct map not provided by PMAP")); \ 3239a8196ceSNathan Whitehorn (x) | DMAP_BASE_ADDRESS; }) 3249a8196ceSNathan Whitehorn #define DMAP_TO_PHYS(x) ({ \ 3259a8196ceSNathan Whitehorn KASSERT(hw_direct_map, ("Direct map not provided by PMAP")); \ 3269a8196ceSNathan Whitehorn (x) &~ DMAP_BASE_ADDRESS; }) 327c8d2ffd6SGleb Smirnoff 32878257765SMark Johnston /* 32978257765SMark Johnston * No non-transparent large page support in the pmap. 33078257765SMark Johnston */ 33178257765SMark Johnston #define PMAP_HAS_LARGEPAGES 0 33278257765SMark Johnston 333f9bac91bSBenno Rice #endif /* _MACHINE_VMPARAM_H_ */ 334