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 * $FreeBSD$ 35f9bac91bSBenno Rice */ 36f9bac91bSBenno Rice 37f9bac91bSBenno Rice #ifndef _MACHINE_VMPARAM_H_ 38f9bac91bSBenno Rice #define _MACHINE_VMPARAM_H_ 39f9bac91bSBenno Rice 409a8196ceSNathan Whitehorn #ifndef LOCORE 419a8196ceSNathan Whitehorn #include <machine/md_var.h> 429a8196ceSNathan Whitehorn #endif 439a8196ceSNathan Whitehorn 44640c77e1SKonstantin Belousov #define USRSTACK SHAREDPAGE 45f9bac91bSBenno Rice 46f9bac91bSBenno Rice #ifndef MAXTSIZ 47615df4c1SJustin Hibbits #define MAXTSIZ (1*1024*1024*1024) /* max text size */ 48f9bac91bSBenno Rice #endif 49f9bac91bSBenno Rice 50f9bac91bSBenno Rice #ifndef DFLDSIZ 5150b8e360SNathan Whitehorn #define DFLDSIZ (128*1024*1024) /* default data size */ 52f9bac91bSBenno Rice #endif 53f9bac91bSBenno Rice 54f9bac91bSBenno Rice #ifndef MAXDSIZ 5587879ba8SJustin Hibbits #ifdef __powerpc64__ 5687879ba8SJustin Hibbits #define MAXDSIZ (32UL*1024*1024*1024) /* max data size */ 5787879ba8SJustin Hibbits #else 5850b8e360SNathan Whitehorn #define MAXDSIZ (1*1024*1024*1024) /* max data size */ 59f9bac91bSBenno Rice #endif 6087879ba8SJustin Hibbits #endif 61f9bac91bSBenno Rice 62f9bac91bSBenno Rice #ifndef DFLSSIZ 6350b8e360SNathan Whitehorn #define DFLSSIZ (8*1024*1024) /* default stack size */ 64f9bac91bSBenno Rice #endif 65f9bac91bSBenno Rice 66f9bac91bSBenno Rice #ifndef MAXSSIZ 677e792cb8SAndreas Tobler #ifdef __powerpc64__ 687e792cb8SAndreas Tobler #define MAXSSIZ (512*1024*1024) /* max stack size */ 697e792cb8SAndreas Tobler #else 7050b8e360SNathan Whitehorn #define MAXSSIZ (64*1024*1024) /* max stack size */ 71f9bac91bSBenno Rice #endif 727e792cb8SAndreas Tobler #endif 73f9bac91bSBenno Rice 749932a3feSNathan Whitehorn #ifdef AIM 756793e5b2SJustin Hibbits #define VM_MAXUSER_ADDRESS32 0xfffff000 769932a3feSNathan Whitehorn #else 776793e5b2SJustin Hibbits #define VM_MAXUSER_ADDRESS32 0x7ffff000 789932a3feSNathan Whitehorn #endif 799932a3feSNathan Whitehorn 80f9bac91bSBenno Rice /* 81ffb56695SRafal Jaworowski * Would like to have MAX addresses = 0, but this doesn't (currently) work 82ffb56695SRafal Jaworowski */ 83c3e289e1SNathan Whitehorn #ifdef __powerpc64__ 8465bbba25SJustin Hibbits /* 8565bbba25SJustin Hibbits * Virtual addresses of things. Derived from the page directory and 8665bbba25SJustin Hibbits * page table indexes from pmap.h for precision. 8765bbba25SJustin Hibbits * 8865bbba25SJustin Hibbits * kernel map should be able to start at 0xc008000000000000 - 8965bbba25SJustin Hibbits * but at least the functional simulator doesn't like it 9065bbba25SJustin Hibbits * 9165bbba25SJustin Hibbits * 0x0000000000000000 - 0x000fffffffffffff user map 9265bbba25SJustin Hibbits * 0xc000000000000000 - 0xc007ffffffffffff direct map 9365bbba25SJustin Hibbits * 0xc008000000000000 - 0xc00fffffffffffff kernel map 9465bbba25SJustin Hibbits * 9565bbba25SJustin Hibbits */ 966793e5b2SJustin Hibbits #define VM_MIN_ADDRESS 0x0000000000000000 9765bbba25SJustin Hibbits #define VM_MAXUSER_ADDRESS 0x000fffffc0000000 9865bbba25SJustin Hibbits #define VM_MAX_ADDRESS 0xc00fffffffffffff 9965bbba25SJustin Hibbits #define VM_MIN_KERNEL_ADDRESS 0xc008000000000000 10065bbba25SJustin Hibbits #define VM_MAX_KERNEL_ADDRESS 0xc0080007ffffffff 1016793e5b2SJustin Hibbits #define VM_MAX_SAFE_KERNEL_ADDRESS VM_MAX_KERNEL_ADDRESS 102e683c328SJustin Hibbits #else 1036793e5b2SJustin Hibbits #define VM_MIN_ADDRESS 0 1046793e5b2SJustin Hibbits #define VM_MAXUSER_ADDRESS VM_MAXUSER_ADDRESS32 1056793e5b2SJustin Hibbits #define VM_MAX_ADDRESS 0xffffffff 106c3e289e1SNathan Whitehorn #endif 1076793e5b2SJustin Hibbits 1086793e5b2SJustin Hibbits #define SHAREDPAGE (VM_MAXUSER_ADDRESS - PAGE_SIZE) 109ffb56695SRafal Jaworowski 1109932a3feSNathan Whitehorn #define FREEBSD32_SHAREDPAGE (VM_MAXUSER_ADDRESS32 - PAGE_SIZE) 111640c77e1SKonstantin Belousov #define FREEBSD32_USRSTACK FREEBSD32_SHAREDPAGE 112ffb56695SRafal Jaworowski 1138f69e36dSJustin Hibbits #define KERNBASE 0x00100100 /* start of kernel virtual */ 114e683c328SJustin Hibbits 1156793e5b2SJustin Hibbits #ifdef AIM 116e683c328SJustin Hibbits #ifndef __powerpc64__ 117c3e289e1SNathan Whitehorn #define VM_MIN_KERNEL_ADDRESS ((vm_offset_t)KERNEL_SR << ADDR_SR_SHFT) 118ab739706SNathan Whitehorn #define VM_MAX_SAFE_KERNEL_ADDRESS (VM_MIN_KERNEL_ADDRESS + 2*SEGMENT_LENGTH -1) 119ab739706SNathan Whitehorn #define VM_MAX_KERNEL_ADDRESS (VM_MIN_KERNEL_ADDRESS + 3*SEGMENT_LENGTH - 1) 120c3e289e1SNathan Whitehorn #endif 121ffb56695SRafal Jaworowski 122ffb56695SRafal Jaworowski /* 123db55e39aSPeter Grehan * Use the direct-mapped BAT registers for UMA small allocs. This 124db55e39aSPeter Grehan * takes pressure off the small amount of available KVA. 125db55e39aSPeter Grehan */ 126db55e39aSPeter Grehan #define UMA_MD_SMALL_ALLOC 127db55e39aSPeter Grehan 128c3e289e1SNathan Whitehorn #else /* Book-E */ 129f9bac91bSBenno Rice 130141a0ab0SJustin Hibbits /* Use the direct map for UMA small allocs on powerpc64. */ 131141a0ab0SJustin Hibbits #ifdef __powerpc64__ 132141a0ab0SJustin Hibbits #define UMA_MD_SMALL_ALLOC 1336793e5b2SJustin Hibbits #else 13445b33e80SJustin Hibbits #define VM_MIN_KERNEL_ADDRESS 0xc0000000 135009dedabSJustin Hibbits #define VM_MAX_KERNEL_ADDRESS 0xffffefff 136a7bb5efaSNathan Whitehorn #define VM_MAX_SAFE_KERNEL_ADDRESS VM_MAX_KERNEL_ADDRESS 137e683c328SJustin Hibbits #endif 138ffb56695SRafal Jaworowski 139ffb56695SRafal Jaworowski #endif /* AIM/E500 */ 1407c277971SPeter Grehan 141ffb56695SRafal Jaworowski #if !defined(LOCORE) 142f9bac91bSBenno Rice struct pmap_physseg { 143f9bac91bSBenno Rice struct pv_entry *pvent; 144f9bac91bSBenno Rice char *attrs; 145f9bac91bSBenno Rice }; 146ffb56695SRafal Jaworowski #endif 147f9bac91bSBenno Rice 14865bbba25SJustin Hibbits #ifdef __powerpc64__ 14965bbba25SJustin Hibbits #define VM_PHYSSEG_MAX 63 /* 1? */ 15065bbba25SJustin Hibbits #else 15165bbba25SJustin Hibbits #define VM_PHYSSEG_MAX 16 /* 1? */ 15265bbba25SJustin Hibbits #endif 15321943937SJeff Roberson 15421943937SJeff Roberson #define PHYS_AVAIL_SZ 256 /* Allows up to 16GB Ram on pSeries with 15521943937SJeff Roberson * logical memory block size of 64MB. 15621943937SJeff Roberson * For more Ram increase the lmb or this value. 15721943937SJeff Roberson */ 15821943937SJeff Roberson 15921943937SJeff Roberson /* XXX This is non-sensical. Phys avail should hold contiguous regions. */ 16021943937SJeff Roberson #define PHYS_AVAIL_ENTRIES PHYS_AVAIL_SZ 161f9bac91bSBenno Rice 16204a18977SAlan Cox /* 1632bb4662eSNathan Whitehorn * The physical address space is densely populated on 32-bit systems, 1642bb4662eSNathan Whitehorn * but may not be on 64-bit ones. 16504a18977SAlan Cox */ 1666d4bd090SJustin Hibbits #ifdef __powerpc64__ 1672bb4662eSNathan Whitehorn #define VM_PHYSSEG_SPARSE 1682bb4662eSNathan Whitehorn #else 16904a18977SAlan Cox #define VM_PHYSSEG_DENSE 1702bb4662eSNathan Whitehorn #endif 17104a18977SAlan Cox 1722446e4f0SAlan Cox /* 173966272caSAlan Cox * Create two free page pools: VM_FREEPOOL_DEFAULT is the default pool 1742446e4f0SAlan Cox * from which physical pages are allocated and VM_FREEPOOL_DIRECT is 1752446e4f0SAlan Cox * the pool from which physical pages for small UMA objects are 1762446e4f0SAlan Cox * allocated. 1772446e4f0SAlan Cox */ 178966272caSAlan Cox #define VM_NFREEPOOL 2 1792446e4f0SAlan Cox #define VM_FREEPOOL_DEFAULT 0 1802446e4f0SAlan Cox #define VM_FREEPOOL_DIRECT 1 1812446e4f0SAlan Cox 1822446e4f0SAlan Cox /* 1832446e4f0SAlan Cox * Create one free page list. 1842446e4f0SAlan Cox */ 185f9bac91bSBenno Rice #define VM_NFREELIST 1 186f9bac91bSBenno Rice #define VM_FREELIST_DEFAULT 0 187f9bac91bSBenno Rice 1882446e4f0SAlan Cox /* 1892446e4f0SAlan Cox * The largest allocation size is 4MB. 1902446e4f0SAlan Cox */ 19165bbba25SJustin Hibbits #ifdef __powerpc64__ 19265bbba25SJustin Hibbits #define VM_NFREEORDER 13 19365bbba25SJustin Hibbits #else 1942446e4f0SAlan Cox #define VM_NFREEORDER 11 19565bbba25SJustin Hibbits #endif 1962446e4f0SAlan Cox 19765bbba25SJustin Hibbits #ifndef VM_NRESERVLEVEL 19865bbba25SJustin Hibbits #ifdef __powerpc64__ 19965bbba25SJustin Hibbits #define VM_NRESERVLEVEL 1 20065bbba25SJustin Hibbits #else 201b8e7fc24SAlan Cox /* 202b8e7fc24SAlan Cox * Disable superpage reservations. 203b8e7fc24SAlan Cox */ 204b8e7fc24SAlan Cox #define VM_NRESERVLEVEL 0 205b8e7fc24SAlan Cox #endif 20665bbba25SJustin Hibbits #endif 20765bbba25SJustin Hibbits 20865bbba25SJustin Hibbits /* 20965bbba25SJustin Hibbits * Level 0 reservations consist of 512 pages. 21065bbba25SJustin Hibbits */ 21165bbba25SJustin Hibbits #ifndef VM_LEVEL_0_ORDER 21265bbba25SJustin Hibbits #define VM_LEVEL_0_ORDER 9 21365bbba25SJustin Hibbits #endif 21465bbba25SJustin Hibbits 21565bbba25SJustin Hibbits #ifdef __powerpc64__ 21665bbba25SJustin Hibbits #ifdef SMP 21765bbba25SJustin Hibbits #define PA_LOCK_COUNT 256 21865bbba25SJustin Hibbits #endif 21965bbba25SJustin Hibbits #endif 220b8e7fc24SAlan Cox 221f9bac91bSBenno Rice #ifndef VM_INITIAL_PAGEIN 222f9bac91bSBenno Rice #define VM_INITIAL_PAGEIN 16 223f9bac91bSBenno Rice #endif 224f9bac91bSBenno Rice 225f9bac91bSBenno Rice #ifndef SGROWSIZ 226f9bac91bSBenno Rice #define SGROWSIZ (128UL*1024) /* amount to grow stack */ 227f9bac91bSBenno Rice #endif 228f9bac91bSBenno Rice 229a7bb5efaSNathan Whitehorn /* 230c70af487SAlan Cox * How many physical pages per kmem arena virtual page. 231a7bb5efaSNathan Whitehorn */ 232c3e289e1SNathan Whitehorn #ifndef VM_KMEM_SIZE_SCALE 233c3e289e1SNathan Whitehorn #define VM_KMEM_SIZE_SCALE (3) 234c3e289e1SNathan Whitehorn #endif 235c3e289e1SNathan Whitehorn 236a7bb5efaSNathan Whitehorn /* 237c70af487SAlan Cox * Optional floor (in bytes) on the size of the kmem arena. 238c70af487SAlan Cox */ 239c70af487SAlan Cox #ifndef VM_KMEM_SIZE_MIN 240c70af487SAlan Cox #define VM_KMEM_SIZE_MIN (12 * 1024 * 1024) 241c70af487SAlan Cox #endif 242c70af487SAlan Cox 243c70af487SAlan Cox /* 244c70af487SAlan Cox * Optional ceiling (in bytes) on the size of the kmem arena: 40% of the 245c70af487SAlan Cox * usable KVA space. 246a7bb5efaSNathan Whitehorn */ 247c3e289e1SNathan Whitehorn #ifndef VM_KMEM_SIZE_MAX 248a7bb5efaSNathan Whitehorn #define VM_KMEM_SIZE_MAX ((VM_MAX_SAFE_KERNEL_ADDRESS - \ 249a7bb5efaSNathan Whitehorn VM_MIN_KERNEL_ADDRESS + 1) * 2 / 5) 250c3e289e1SNathan Whitehorn #endif 251c3e289e1SNathan Whitehorn 25265bbba25SJustin Hibbits #ifdef __powerpc64__ 25365bbba25SJustin Hibbits #define ZERO_REGION_SIZE (2 * 1024 * 1024) /* 2MB */ 25465bbba25SJustin Hibbits #else 255cfb00e5aSMatthew D Fleming #define ZERO_REGION_SIZE (64 * 1024) /* 64KB */ 25665bbba25SJustin Hibbits #endif 25765bbba25SJustin Hibbits 25865bbba25SJustin Hibbits /* 25965bbba25SJustin Hibbits * Use a fairly large batch size since we expect ppc64 systems to have lots of 26065bbba25SJustin Hibbits * memory. 26165bbba25SJustin Hibbits */ 26265bbba25SJustin Hibbits #ifdef __powerpc64__ 26365bbba25SJustin Hibbits #define VM_BATCHQUEUE_SIZE 31 26465bbba25SJustin Hibbits #endif 265cfb00e5aSMatthew D Fleming 266c8d2ffd6SGleb Smirnoff /* 267c8d2ffd6SGleb Smirnoff * On 32-bit OEA, the only purpose for which sf_buf is used is to implement 268c8d2ffd6SGleb Smirnoff * an opaque pointer required by the machine-independent parts of the kernel. 269c8d2ffd6SGleb Smirnoff * That pointer references the vm_page that is "mapped" by the sf_buf. The 270c8d2ffd6SGleb Smirnoff * actual mapping is provided by the direct virtual-to-physical mapping. 271c8d2ffd6SGleb Smirnoff * 272c8d2ffd6SGleb Smirnoff * On OEA64 and Book-E, we need to do something a little more complicated. Use 273c8d2ffd6SGleb Smirnoff * the runtime-detected hw_direct_map to pick between the two cases. Our 274c8d2ffd6SGleb Smirnoff * friends in vm_machdep.c will do the same to ensure nothing gets confused. 275c8d2ffd6SGleb Smirnoff */ 276c8d2ffd6SGleb Smirnoff #define SFBUF 277c8d2ffd6SGleb Smirnoff #define SFBUF_NOMD 27868b9c019SNathan Whitehorn 27968b9c019SNathan Whitehorn /* 2809a8196ceSNathan Whitehorn * We (usually) have a direct map of all physical memory, so provide 281f9edb09dSNathan Whitehorn * a macro to use to get the kernel VA address for a given PA. Check the 282f9edb09dSNathan Whitehorn * value of PMAP_HAS_PMAP before using. 28368b9c019SNathan Whitehorn */ 284f9edb09dSNathan Whitehorn #ifndef LOCORE 2859a8196ceSNathan Whitehorn #ifdef __powerpc64__ 286f9edb09dSNathan Whitehorn #define DMAP_BASE_ADDRESS 0xc000000000000000UL 28765bbba25SJustin Hibbits #define DMAP_MIN_ADDRESS DMAP_BASE_ADDRESS 28865bbba25SJustin Hibbits #define DMAP_MAX_ADDRESS 0xc007ffffffffffffUL 2899a8196ceSNathan Whitehorn #else 2909a8196ceSNathan Whitehorn #define DMAP_BASE_ADDRESS 0x00000000UL 291f9edb09dSNathan Whitehorn #define DMAP_MAX_ADDRESS 0xbfffffffUL 292f9edb09dSNathan Whitehorn #endif 2939a8196ceSNathan Whitehorn #endif 2949a8196ceSNathan Whitehorn 295caef3e12SJustin Hibbits #if defined(__powerpc64__) || defined(BOOKE) 296caef3e12SJustin Hibbits /* 297caef3e12SJustin Hibbits * powerpc64 and Book-E will provide their own page array allocators. 298caef3e12SJustin Hibbits * 299caef3e12SJustin Hibbits * On AIM, this will allocate a single virtual array, with pages from the 300caef3e12SJustin Hibbits * correct memory domains. 301caef3e12SJustin Hibbits * On Book-E this will let us put the array in TLB1, removing the need for TLB 302caef3e12SJustin Hibbits * thrashing. 303caef3e12SJustin Hibbits * 304caef3e12SJustin Hibbits * VM_MIN_KERNEL_ADDRESS is just a dummy. It will get set by the MMU driver. 305caef3e12SJustin Hibbits */ 306caef3e12SJustin Hibbits #define PA_MIN_ADDRESS VM_MIN_KERNEL_ADDRESS 307caef3e12SJustin Hibbits #define PMAP_HAS_PAGE_ARRAY 1 308caef3e12SJustin Hibbits #endif 309caef3e12SJustin Hibbits 310ab041f71SD Scott Phillips #if defined(__powerpc64__) 311ab041f71SD Scott Phillips /* 312ab041f71SD Scott Phillips * Need a page dump array for minidump. 313ab041f71SD Scott Phillips */ 314ab041f71SD Scott Phillips #define MINIDUMP_PAGE_TRACKING 1 315ab041f71SD Scott Phillips #else 316ab041f71SD Scott Phillips /* 317ab041f71SD Scott Phillips * No minidump with 32-bit powerpc. 318ab041f71SD Scott Phillips */ 319ab041f71SD Scott Phillips #define MINIDUMP_PAGE_TRACKING 0 320ab041f71SD Scott Phillips #endif 321ab041f71SD Scott Phillips 3229a8196ceSNathan Whitehorn #define PMAP_HAS_DMAP (hw_direct_map) 3239a8196ceSNathan Whitehorn #define PHYS_TO_DMAP(x) ({ \ 3249a8196ceSNathan Whitehorn KASSERT(hw_direct_map, ("Direct map not provided by PMAP")); \ 3259a8196ceSNathan Whitehorn (x) | DMAP_BASE_ADDRESS; }) 3269a8196ceSNathan Whitehorn #define DMAP_TO_PHYS(x) ({ \ 3279a8196ceSNathan Whitehorn KASSERT(hw_direct_map, ("Direct map not provided by PMAP")); \ 3289a8196ceSNathan Whitehorn (x) &~ DMAP_BASE_ADDRESS; }) 329c8d2ffd6SGleb Smirnoff 330*78257765SMark Johnston /* 331*78257765SMark Johnston * No non-transparent large page support in the pmap. 332*78257765SMark Johnston */ 333*78257765SMark Johnston #define PMAP_HAS_LARGEPAGES 0 334*78257765SMark Johnston 335f9bac91bSBenno Rice #endif /* _MACHINE_VMPARAM_H_ */ 336