18d7e7a98SRuslan Bukin /*- 28d7e7a98SRuslan Bukin * Copyright (c) 1990 The Regents of the University of California. 38d7e7a98SRuslan Bukin * All rights reserved. 48d7e7a98SRuslan Bukin * Copyright (c) 1994 John S. Dyson 58d7e7a98SRuslan Bukin * All rights reserved. 68d7e7a98SRuslan Bukin * 78d7e7a98SRuslan Bukin * This code is derived from software contributed to Berkeley by 88d7e7a98SRuslan Bukin * William Jolitz. 98d7e7a98SRuslan Bukin * 108d7e7a98SRuslan Bukin * Redistribution and use in source and binary forms, with or without 118d7e7a98SRuslan Bukin * modification, are permitted provided that the following conditions 128d7e7a98SRuslan Bukin * are met: 138d7e7a98SRuslan Bukin * 1. Redistributions of source code must retain the above copyright 148d7e7a98SRuslan Bukin * notice, this list of conditions and the following disclaimer. 158d7e7a98SRuslan Bukin * 2. Redistributions in binary form must reproduce the above copyright 168d7e7a98SRuslan Bukin * notice, this list of conditions and the following disclaimer in the 178d7e7a98SRuslan Bukin * documentation and/or other materials provided with the distribution. 188d7e7a98SRuslan Bukin * 3. Neither the name of the University nor the names of its contributors 198d7e7a98SRuslan Bukin * may be used to endorse or promote products derived from this software 208d7e7a98SRuslan Bukin * without specific prior written permission. 218d7e7a98SRuslan Bukin * 228d7e7a98SRuslan Bukin * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 238d7e7a98SRuslan Bukin * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 248d7e7a98SRuslan Bukin * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 258d7e7a98SRuslan Bukin * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 268d7e7a98SRuslan Bukin * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 278d7e7a98SRuslan Bukin * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 288d7e7a98SRuslan Bukin * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 298d7e7a98SRuslan Bukin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 308d7e7a98SRuslan Bukin * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 318d7e7a98SRuslan Bukin * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 328d7e7a98SRuslan Bukin * SUCH DAMAGE. 338d7e7a98SRuslan Bukin * 348d7e7a98SRuslan Bukin * from: @(#)vmparam.h 5.9 (Berkeley) 5/12/91 358d7e7a98SRuslan Bukin * from: FreeBSD: src/sys/i386/include/vmparam.h,v 1.33 2000/03/30 368d7e7a98SRuslan Bukin * $FreeBSD$ 378d7e7a98SRuslan Bukin */ 388d7e7a98SRuslan Bukin 398d7e7a98SRuslan Bukin #ifndef _MACHINE_VMPARAM_H_ 408d7e7a98SRuslan Bukin #define _MACHINE_VMPARAM_H_ 418d7e7a98SRuslan Bukin 428d7e7a98SRuslan Bukin /* 438d7e7a98SRuslan Bukin * Virtual memory related constants, all in bytes 448d7e7a98SRuslan Bukin */ 458d7e7a98SRuslan Bukin #ifndef MAXTSIZ 46229f3f0dSRuslan Bukin #define MAXTSIZ (1*1024*1024*1024) /* max text size */ 478d7e7a98SRuslan Bukin #endif 488d7e7a98SRuslan Bukin #ifndef DFLDSIZ 498d7e7a98SRuslan Bukin #define DFLDSIZ (128*1024*1024) /* initial data size limit */ 508d7e7a98SRuslan Bukin #endif 518d7e7a98SRuslan Bukin #ifndef MAXDSIZ 52229f3f0dSRuslan Bukin #define MAXDSIZ (1*1024*1024*1024) /* max data size */ 538d7e7a98SRuslan Bukin #endif 548d7e7a98SRuslan Bukin #ifndef DFLSSIZ 55229f3f0dSRuslan Bukin #define DFLSSIZ (128*1024*1024) /* initial stack size limit */ 568d7e7a98SRuslan Bukin #endif 578d7e7a98SRuslan Bukin #ifndef MAXSSIZ 58229f3f0dSRuslan Bukin #define MAXSSIZ (1*1024*1024*1024) /* max stack size */ 598d7e7a98SRuslan Bukin #endif 608d7e7a98SRuslan Bukin #ifndef SGROWSIZ 618d7e7a98SRuslan Bukin #define SGROWSIZ (128*1024) /* amount to grow stack */ 628d7e7a98SRuslan Bukin #endif 638d7e7a98SRuslan Bukin 648d7e7a98SRuslan Bukin /* 658d7e7a98SRuslan Bukin * The physical address space is sparsely populated. 668d7e7a98SRuslan Bukin */ 678d7e7a98SRuslan Bukin #define VM_PHYSSEG_SPARSE 688d7e7a98SRuslan Bukin 698d7e7a98SRuslan Bukin /* 709ecd7fdeSWarner Losh * The number of PHYSSEG entries. 718d7e7a98SRuslan Bukin */ 728d7e7a98SRuslan Bukin #define VM_PHYSSEG_MAX 64 738d7e7a98SRuslan Bukin 748d7e7a98SRuslan Bukin /* 758d7e7a98SRuslan Bukin * Create two free page pools: VM_FREEPOOL_DEFAULT is the default pool 768d7e7a98SRuslan Bukin * from which physical pages are allocated and VM_FREEPOOL_DIRECT is 778d7e7a98SRuslan Bukin * the pool from which physical pages for small UMA objects are 788d7e7a98SRuslan Bukin * allocated. 798d7e7a98SRuslan Bukin */ 808d7e7a98SRuslan Bukin #define VM_NFREEPOOL 2 818d7e7a98SRuslan Bukin #define VM_FREEPOOL_DEFAULT 0 828d7e7a98SRuslan Bukin #define VM_FREEPOOL_DIRECT 1 838d7e7a98SRuslan Bukin 848d7e7a98SRuslan Bukin /* 859ecd7fdeSWarner Losh * Create one free page list: VM_FREELIST_DEFAULT is for all physical 869ecd7fdeSWarner Losh * pages. 878d7e7a98SRuslan Bukin */ 889ecd7fdeSWarner Losh #define VM_NFREELIST 1 898d7e7a98SRuslan Bukin #define VM_FREELIST_DEFAULT 0 908d7e7a98SRuslan Bukin 918d7e7a98SRuslan Bukin /* 928d7e7a98SRuslan Bukin * An allocation size of 16MB is supported in order to optimize the 938d7e7a98SRuslan Bukin * use of the direct map by UMA. Specifically, a cache line contains 948d7e7a98SRuslan Bukin * at most four TTEs, collectively mapping 16MB of physical memory. 958d7e7a98SRuslan Bukin * By reducing the number of distinct 16MB "pages" that are used by UMA, 968d7e7a98SRuslan Bukin * the physical memory allocator reduces the likelihood of both 4MB 978d7e7a98SRuslan Bukin * page TLB misses and cache misses caused by 4MB page TLB misses. 988d7e7a98SRuslan Bukin */ 998d7e7a98SRuslan Bukin #define VM_NFREEORDER 12 1008d7e7a98SRuslan Bukin 1018d7e7a98SRuslan Bukin /* 102f6893f09SMark Johnston * Enable superpage reservations: 1 level. 1038d7e7a98SRuslan Bukin */ 1048d7e7a98SRuslan Bukin #ifndef VM_NRESERVLEVEL 105f6893f09SMark Johnston #define VM_NRESERVLEVEL 1 1068d7e7a98SRuslan Bukin #endif 1078d7e7a98SRuslan Bukin 1088d7e7a98SRuslan Bukin /* 1098d7e7a98SRuslan Bukin * Level 0 reservations consist of 512 pages. 1108d7e7a98SRuslan Bukin */ 1118d7e7a98SRuslan Bukin #ifndef VM_LEVEL_0_ORDER 1128d7e7a98SRuslan Bukin #define VM_LEVEL_0_ORDER 9 1138d7e7a98SRuslan Bukin #endif 1148d7e7a98SRuslan Bukin 1158d7e7a98SRuslan Bukin /** 1168d7e7a98SRuslan Bukin * Address space layout. 1178d7e7a98SRuslan Bukin * 1181a153f42SMark Johnston * RISC-V implements multiple paging modes with different virtual address space 1191a153f42SMark Johnston * sizes: SV32, SV39 and SV48. SV39 permits a virtual address space size of 1201a153f42SMark Johnston * 512GB and uses a three-level page table. Since this is large enough for most 1211a153f42SMark Johnston * purposes, we currently use SV39 for both userland and the kernel, avoiding 1221a153f42SMark Johnston * the extra translation step required by SV48. 1238d7e7a98SRuslan Bukin * 1241a153f42SMark Johnston * The address space is split into two regions at each end of the 64-bit address 1251a153f42SMark Johnston * space: 1268d7e7a98SRuslan Bukin * 1271a153f42SMark Johnston * 0x0000000000000000 - 0x0000003fffffffff 256GB user map 1281a153f42SMark Johnston * 0x0000004000000000 - 0xffffffbfffffffff unmappable 1291a153f42SMark Johnston * 0xffffffc000000000 - 0xffffffc7ffffffff 32GB kernel map 1301a153f42SMark Johnston * 0xffffffc800000000 - 0xffffffcfffffffff 32GB unused 1311a153f42SMark Johnston * 0xffffffd000000000 - 0xffffffefffffffff 128GB direct map 1321a153f42SMark Johnston * 0xfffffff000000000 - 0xffffffffffffffff 64GB unused 1338d7e7a98SRuslan Bukin * 1341a153f42SMark Johnston * The kernel is loaded at the beginning of the kernel map. 1358d7e7a98SRuslan Bukin * 1368d7e7a98SRuslan Bukin * We define some interesting address constants: 1378d7e7a98SRuslan Bukin * 1388d7e7a98SRuslan Bukin * VM_MIN_ADDRESS and VM_MAX_ADDRESS define the start and end of the entire 1398d7e7a98SRuslan Bukin * 64 bit address space, mostly just for convenience. 1408d7e7a98SRuslan Bukin * 1418d7e7a98SRuslan Bukin * VM_MIN_KERNEL_ADDRESS and VM_MAX_KERNEL_ADDRESS define the start and end of 1428d7e7a98SRuslan Bukin * mappable kernel virtual address space. 1438d7e7a98SRuslan Bukin * 1448d7e7a98SRuslan Bukin * VM_MIN_USER_ADDRESS and VM_MAX_USER_ADDRESS define the start and end of the 1458d7e7a98SRuslan Bukin * user address space. 1468d7e7a98SRuslan Bukin */ 1478d7e7a98SRuslan Bukin #define VM_MIN_ADDRESS (0x0000000000000000UL) 1488d7e7a98SRuslan Bukin #define VM_MAX_ADDRESS (0xffffffffffffffffUL) 1498d7e7a98SRuslan Bukin 15002a37128SRuslan Bukin #define VM_MIN_KERNEL_ADDRESS (0xffffffc000000000UL) 15102a37128SRuslan Bukin #define VM_MAX_KERNEL_ADDRESS (0xffffffc800000000UL) 1528d7e7a98SRuslan Bukin 15302a37128SRuslan Bukin #define DMAP_MIN_ADDRESS (0xffffffd000000000UL) 1545f8228b2SRuslan Bukin #define DMAP_MAX_ADDRESS (0xfffffff000000000UL) 1558d7e7a98SRuslan Bukin 1565f8228b2SRuslan Bukin #define DMAP_MIN_PHYSADDR (dmap_phys_base) 1575f8228b2SRuslan Bukin #define DMAP_MAX_PHYSADDR (dmap_phys_max) 1588d7e7a98SRuslan Bukin 1598d7e7a98SRuslan Bukin /* True if pa is in the dmap range */ 160229f3f0dSRuslan Bukin #define PHYS_IN_DMAP(pa) ((pa) >= DMAP_MIN_PHYSADDR && \ 1615f8228b2SRuslan Bukin (pa) < DMAP_MAX_PHYSADDR) 1628d7e7a98SRuslan Bukin /* True if va is in the dmap range */ 1638d7e7a98SRuslan Bukin #define VIRT_IN_DMAP(va) ((va) >= DMAP_MIN_ADDRESS && \ 1645f8228b2SRuslan Bukin (va) < (dmap_max_addr)) 1658d7e7a98SRuslan Bukin 1669a8196ceSNathan Whitehorn #define PMAP_HAS_DMAP 1 1678d7e7a98SRuslan Bukin #define PHYS_TO_DMAP(pa) \ 1688d7e7a98SRuslan Bukin ({ \ 1698d7e7a98SRuslan Bukin KASSERT(PHYS_IN_DMAP(pa), \ 1708d7e7a98SRuslan Bukin ("%s: PA out of range, PA: 0x%lx", __func__, \ 1718d7e7a98SRuslan Bukin (vm_paddr_t)(pa))); \ 1725f8228b2SRuslan Bukin ((pa) - dmap_phys_base) + DMAP_MIN_ADDRESS; \ 1738d7e7a98SRuslan Bukin }) 1748d7e7a98SRuslan Bukin 1758d7e7a98SRuslan Bukin #define DMAP_TO_PHYS(va) \ 1768d7e7a98SRuslan Bukin ({ \ 1778d7e7a98SRuslan Bukin KASSERT(VIRT_IN_DMAP(va), \ 1788d7e7a98SRuslan Bukin ("%s: VA out of range, VA: 0x%lx", __func__, \ 1798d7e7a98SRuslan Bukin (vm_offset_t)(va))); \ 1805f8228b2SRuslan Bukin ((va) - DMAP_MIN_ADDRESS) + dmap_phys_base; \ 1818d7e7a98SRuslan Bukin }) 1828d7e7a98SRuslan Bukin 1838d7e7a98SRuslan Bukin #define VM_MIN_USER_ADDRESS (0x0000000000000000UL) 18402a37128SRuslan Bukin #define VM_MAX_USER_ADDRESS (0x0000004000000000UL) 1858d7e7a98SRuslan Bukin 1868d7e7a98SRuslan Bukin #define VM_MINUSER_ADDRESS (VM_MIN_USER_ADDRESS) 1878d7e7a98SRuslan Bukin #define VM_MAXUSER_ADDRESS (VM_MAX_USER_ADDRESS) 1888d7e7a98SRuslan Bukin 1898d7e7a98SRuslan Bukin #define KERNBASE (VM_MIN_KERNEL_ADDRESS) 190229f3f0dSRuslan Bukin #define SHAREDPAGE (VM_MAXUSER_ADDRESS - PAGE_SIZE) 191229f3f0dSRuslan Bukin #define USRSTACK SHAREDPAGE 192229f3f0dSRuslan Bukin 19324891abdSMitchell Horne #define VM_EARLY_DTB_ADDRESS (VM_MAX_KERNEL_ADDRESS - (2 * L2_SIZE)) 19424891abdSMitchell Horne 1958d7e7a98SRuslan Bukin /* 1968d7e7a98SRuslan Bukin * How many physical pages per kmem arena virtual page. 1978d7e7a98SRuslan Bukin */ 1988d7e7a98SRuslan Bukin #ifndef VM_KMEM_SIZE_SCALE 1998d7e7a98SRuslan Bukin #define VM_KMEM_SIZE_SCALE (3) 2008d7e7a98SRuslan Bukin #endif 2018d7e7a98SRuslan Bukin 2028d7e7a98SRuslan Bukin /* 2038d7e7a98SRuslan Bukin * Optional floor (in bytes) on the size of the kmem arena. 2048d7e7a98SRuslan Bukin */ 2058d7e7a98SRuslan Bukin #ifndef VM_KMEM_SIZE_MIN 2068d7e7a98SRuslan Bukin #define VM_KMEM_SIZE_MIN (16 * 1024 * 1024) 2078d7e7a98SRuslan Bukin #endif 2088d7e7a98SRuslan Bukin 2098d7e7a98SRuslan Bukin /* 2108d7e7a98SRuslan Bukin * Optional ceiling (in bytes) on the size of the kmem arena: 60% of the 2118d7e7a98SRuslan Bukin * kernel map. 2128d7e7a98SRuslan Bukin */ 2138d7e7a98SRuslan Bukin #ifndef VM_KMEM_SIZE_MAX 2148d7e7a98SRuslan Bukin #define VM_KMEM_SIZE_MAX ((VM_MAX_KERNEL_ADDRESS - \ 2158d7e7a98SRuslan Bukin VM_MIN_KERNEL_ADDRESS + 1) * 3 / 5) 2168d7e7a98SRuslan Bukin #endif 2178d7e7a98SRuslan Bukin 2188d7e7a98SRuslan Bukin /* 2198d7e7a98SRuslan Bukin * Initial pagein size of beginning of executable file. 2208d7e7a98SRuslan Bukin */ 2218d7e7a98SRuslan Bukin #ifndef VM_INITIAL_PAGEIN 2228d7e7a98SRuslan Bukin #define VM_INITIAL_PAGEIN 16 2238d7e7a98SRuslan Bukin #endif 2248d7e7a98SRuslan Bukin 2256371d0bdSRuslan Bukin #define UMA_MD_SMALL_ALLOC 2268d7e7a98SRuslan Bukin 2275f8228b2SRuslan Bukin #ifndef LOCORE 2285f8228b2SRuslan Bukin extern vm_paddr_t dmap_phys_base; 2295f8228b2SRuslan Bukin extern vm_paddr_t dmap_phys_max; 2305f8228b2SRuslan Bukin extern vm_offset_t dmap_max_addr; 2318d7e7a98SRuslan Bukin extern vm_offset_t vm_max_kernel_address; 2328d7e7a98SRuslan Bukin extern vm_offset_t init_pt_va; 2335f8228b2SRuslan Bukin #endif 2348d7e7a98SRuslan Bukin 2358d7e7a98SRuslan Bukin #define ZERO_REGION_SIZE (64 * 1024) /* 64KB */ 2368d7e7a98SRuslan Bukin 23730b72b68SRuslan Bukin #define DEVMAP_MAX_VADDR VM_MAX_KERNEL_ADDRESS 23830b72b68SRuslan Bukin 239ab041f71SD Scott Phillips /* 240*78257765SMark Johnston * No non-transparent large page support in the pmap. 241*78257765SMark Johnston */ 242*78257765SMark Johnston #define PMAP_HAS_LARGEPAGES 0 243*78257765SMark Johnston 244*78257765SMark Johnston /* 245ab041f71SD Scott Phillips * Need a page dump array for minidump. 246ab041f71SD Scott Phillips */ 247ab041f71SD Scott Phillips #define MINIDUMP_PAGE_TRACKING 1 248ab041f71SD Scott Phillips 2498d7e7a98SRuslan Bukin #endif /* !_MACHINE_VMPARAM_H_ */ 250