15b81b6b3SRodney W. Grimes /*- 251369649SPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause 351369649SPedro F. Giffuni * 45b81b6b3SRodney W. Grimes * Copyright (c) 1990 The Regents of the University of California. 55b81b6b3SRodney W. Grimes * All rights reserved. 67f8cb368SDavid Greenman * Copyright (c) 1994 John S. Dyson 77f8cb368SDavid Greenman * All rights reserved. 85b81b6b3SRodney W. Grimes * 95b81b6b3SRodney W. Grimes * This code is derived from software contributed to Berkeley by 105b81b6b3SRodney W. Grimes * William Jolitz. 115b81b6b3SRodney W. Grimes * 125b81b6b3SRodney W. Grimes * Redistribution and use in source and binary forms, with or without 135b81b6b3SRodney W. Grimes * modification, are permitted provided that the following conditions 145b81b6b3SRodney W. Grimes * are met: 155b81b6b3SRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 165b81b6b3SRodney W. Grimes * notice, this list of conditions and the following disclaimer. 175b81b6b3SRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 185b81b6b3SRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 195b81b6b3SRodney W. Grimes * documentation and/or other materials provided with the distribution. 20fbbd9655SWarner Losh * 3. Neither the name of the University nor the names of its contributors 215b81b6b3SRodney W. Grimes * may be used to endorse or promote products derived from this software 225b81b6b3SRodney W. Grimes * without specific prior written permission. 235b81b6b3SRodney W. Grimes * 245b81b6b3SRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 255b81b6b3SRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 265b81b6b3SRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 275b81b6b3SRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 285b81b6b3SRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 295b81b6b3SRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 305b81b6b3SRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 315b81b6b3SRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 325b81b6b3SRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 335b81b6b3SRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 345b81b6b3SRodney W. Grimes * SUCH DAMAGE. 355b81b6b3SRodney W. Grimes */ 365b81b6b3SRodney W. Grimes 376e393973SGarrett Wollman #ifndef _MACHINE_VMPARAM_H_ 386e393973SGarrett Wollman #define _MACHINE_VMPARAM_H_ 1 396e393973SGarrett Wollman 405b81b6b3SRodney W. Grimes /* 415b81b6b3SRodney W. Grimes * Machine dependent constants for 386. 425b81b6b3SRodney W. Grimes */ 435b81b6b3SRodney W. Grimes 445b81b6b3SRodney W. Grimes /* 455b81b6b3SRodney W. Grimes * Virtual memory related constants, all in bytes 465b81b6b3SRodney W. Grimes */ 47f4fabec6SDavid Greenman #define MAXTSIZ (128UL*1024*1024) /* max text size */ 485b81b6b3SRodney W. Grimes #ifndef DFLDSIZ 49f4fabec6SDavid Greenman #define DFLDSIZ (128UL*1024*1024) /* initial data size limit */ 505b81b6b3SRodney W. Grimes #endif 515b81b6b3SRodney W. Grimes #ifndef MAXDSIZ 527416845fSJordan K. Hubbard #define MAXDSIZ (512UL*1024*1024) /* max data size */ 535b81b6b3SRodney W. Grimes #endif 545b81b6b3SRodney W. Grimes #ifndef DFLSSIZ 5529360eb0SDavid Greenman #define DFLSSIZ (8UL*1024*1024) /* initial stack size limit */ 565b81b6b3SRodney W. Grimes #endif 575b81b6b3SRodney W. Grimes #ifndef MAXSSIZ 58e10a6186SDavid Greenman #define MAXSSIZ (64UL*1024*1024) /* max stack size */ 595b81b6b3SRodney W. Grimes #endif 6029360eb0SDavid Greenman #ifndef SGROWSIZ 6129360eb0SDavid Greenman #define SGROWSIZ (128UL*1024) /* amount to grow stack */ 6229360eb0SDavid Greenman #endif 635b81b6b3SRodney W. Grimes 645b81b6b3SRodney W. Grimes /* 65271f0f12SAlan Cox * Choose between DENSE and SPARSE based on whether lower execution time or 66271f0f12SAlan Cox * lower kernel address space consumption is desired. Under PAE, kernel 67271f0f12SAlan Cox * address space is often in short supply. 6804a18977SAlan Cox */ 69271f0f12SAlan Cox #ifdef PAE 70271f0f12SAlan Cox #define VM_PHYSSEG_SPARSE 71271f0f12SAlan Cox #else 7204a18977SAlan Cox #define VM_PHYSSEG_DENSE 73271f0f12SAlan Cox #endif 7404a18977SAlan Cox 7504a18977SAlan Cox /* 76e5c45405SAlan Cox * The number of PHYSSEG entries must be one greater than the number 77e5c45405SAlan Cox * of phys_avail entries because the phys_avail entry that spans the 78e5c45405SAlan Cox * largest physical address that is accessible by ISA DMA is split 79e5c45405SAlan Cox * into two PHYSSEG entries. 80e5c45405SAlan Cox */ 81e5c45405SAlan Cox #define VM_PHYSSEG_MAX 17 82e5c45405SAlan Cox 83e5c45405SAlan Cox /* 84966272caSAlan Cox * Create one free page pool. Since the i386 kernel virtual address 85e5c45405SAlan Cox * space does not include a mapping onto the machine's entire physical 86e5c45405SAlan Cox * memory, VM_FREEPOOL_DIRECT is defined as an alias for the default 87e5c45405SAlan Cox * pool, VM_FREEPOOL_DEFAULT. 88e5c45405SAlan Cox */ 89966272caSAlan Cox #define VM_NFREEPOOL 1 90e5c45405SAlan Cox #define VM_FREEPOOL_DEFAULT 0 91e5c45405SAlan Cox #define VM_FREEPOOL_DIRECT 0 92e5c45405SAlan Cox 93e5c45405SAlan Cox /* 949a527560SKonstantin Belousov * Create up to three free page lists: VM_FREELIST_DMA32 is for physical pages 959a527560SKonstantin Belousov * that have physical addresses below 4G but are not accessible by ISA DMA, 969a527560SKonstantin Belousov * and VM_FREELIST_ISADMA is for physical pages that are accessible by ISA 979a527560SKonstantin Belousov * DMA. 98e5c45405SAlan Cox */ 999a527560SKonstantin Belousov #define VM_NFREELIST 3 100e5c45405SAlan Cox #define VM_FREELIST_DEFAULT 0 1019a527560SKonstantin Belousov #define VM_FREELIST_DMA32 1 1029a527560SKonstantin Belousov #define VM_FREELIST_LOWMEM 2 10367d33338SWarner Losh 10467d33338SWarner Losh #define VM_LOWMEM_BOUNDARY (16 << 20) /* 16MB ISA DMA limit */ 105e5c45405SAlan Cox 106e5c45405SAlan Cox /* 1079a527560SKonstantin Belousov * Always create DMA32 freelist if there is any memory above 4G. 1089a527560SKonstantin Belousov * Bounce dma is extremely fragile and simultaneously intensively 1099a527560SKonstantin Belousov * used. 1109a527560SKonstantin Belousov */ 1119a527560SKonstantin Belousov #define VM_DMA32_NPAGES_THRESHOLD 1 1129a527560SKonstantin Belousov 1139a527560SKonstantin Belousov /* 114e5c45405SAlan Cox * The largest allocation size is 2MB under PAE and 4MB otherwise. 115e5c45405SAlan Cox */ 1169a527560SKonstantin Belousov #define VM_NFREEORDER_PAE 10 1179a527560SKonstantin Belousov #define VM_NFREEORDER_NOPAE 11 1189a527560SKonstantin Belousov #define VM_NFREEORDER_MAX VM_NFREEORDER_NOPAE 1199a527560SKonstantin Belousov #define VM_NFREEORDER i386_pmap_VM_NFREEORDER 120e5c45405SAlan Cox 121e5c45405SAlan Cox /* 122fdcd29b5SAlan Cox * Enable superpage reservations: 1 level. 123b8e7fc24SAlan Cox */ 124b8e7fc24SAlan Cox #ifndef VM_NRESERVLEVEL 125fdcd29b5SAlan Cox #define VM_NRESERVLEVEL 1 126b8e7fc24SAlan Cox #endif 127b8e7fc24SAlan Cox 128b8e7fc24SAlan Cox /* 12934c15db9SKonstantin Belousov * Level 0 reservations consist of 512 pages when PAE pagetables are 13034c15db9SKonstantin Belousov * used, and 1024 pages otherwise. 131b8e7fc24SAlan Cox */ 132b8e7fc24SAlan Cox #ifndef VM_LEVEL_0_ORDER 1339a527560SKonstantin Belousov #define VM_LEVEL_0_ORDER_PAE 9 1349a527560SKonstantin Belousov #define VM_LEVEL_0_ORDER_NOPAE 10 1359a527560SKonstantin Belousov #define VM_LEVEL_0_ORDER_MAX VM_LEVEL_0_ORDER_NOPAE 1369a527560SKonstantin Belousov #define VM_LEVEL_0_ORDER i386_pmap_VM_LEVEL_0_ORDER 137b8e7fc24SAlan Cox #else 1389a527560SKonstantin Belousov #define VM_LEVEL_0_ORDER_MAX VM_LEVEL_0_ORDER 139b8e7fc24SAlan Cox #endif 140b8e7fc24SAlan Cox 141b8e7fc24SAlan Cox /* 1426ccf265bSPeter Wemm * Kernel physical load address. 1436ccf265bSPeter Wemm */ 1446ccf265bSPeter Wemm #ifndef KERNLOAD 1459a527560SKonstantin Belousov #define KERNLOAD (8 * 1024 * 1024) 14693ee134aSKip Macy #endif /* !defined(KERNLOAD) */ 1476ccf265bSPeter Wemm 1486ccf265bSPeter Wemm /* 14968c1eb12SPoul-Henning Kamp * Virtual addresses of things. Derived from the page directory and 15068c1eb12SPoul-Henning Kamp * page table indexes from pmap.h for precision. 15168c1eb12SPoul-Henning Kamp * Because of the page that is both a PD and PT, it looks a little 15268c1eb12SPoul-Henning Kamp * messy at times, but hey, we'll do anything to save a page :-) 1535b81b6b3SRodney W. Grimes */ 1545b81b6b3SRodney W. Grimes 1559a527560SKonstantin Belousov #define VM_MAX_KERNEL_ADDRESS (0xffffffffU - 16 * 1024 * 1024 + 1) 15693ee134aSKip Macy 157d86c1f0dSKonstantin Belousov #define VM_MIN_KERNEL_ADDRESS 0 1587f8cb368SDavid Greenman 159d86c1f0dSKonstantin Belousov #define KERNBASE KERNLOAD 16068c1eb12SPoul-Henning Kamp 16168c1eb12SPoul-Henning Kamp #define UPT_MAX_ADDRESS VADDR(PTDPTDI, PTDPTDI) 16268c1eb12SPoul-Henning Kamp #define UPT_MIN_ADDRESS VADDR(PTDPTDI, 0) 16368c1eb12SPoul-Henning Kamp 1649a527560SKonstantin Belousov #define VM_MAXUSER_ADDRESS (0xffffffff - 4 * 1024 * 1024 + 1) 16568c1eb12SPoul-Henning Kamp 166d69ae412SKonstantin Belousov #define SHAREDPAGE (VM_MAXUSER_ADDRESS - PAGE_SIZE) 167d69ae412SKonstantin Belousov #define USRSTACK SHAREDPAGE 16868c1eb12SPoul-Henning Kamp 169d86c1f0dSKonstantin Belousov #define VM_MAX_ADDRESS VADDR(PTDPTDI, 0) 17068c1eb12SPoul-Henning Kamp #define VM_MIN_ADDRESS ((vm_offset_t)0) 1715b81b6b3SRodney W. Grimes 172d86c1f0dSKonstantin Belousov #define PMAP_TRM_MIN_ADDRESS VM_MAXUSER_ADDRESS 173d86c1f0dSKonstantin Belousov #define PMAP_TRM_MAX_ADDRESS 0xffffffff 174d86c1f0dSKonstantin Belousov 1759a527560SKonstantin Belousov #define PMAP_MAP_LOW (4 * 1024 * 1024) 176d86c1f0dSKonstantin Belousov 177d86c1f0dSKonstantin Belousov /* 178d86c1f0dSKonstantin Belousov * KVA layout. The unit of the system allocation is single PDE, which 179d86c1f0dSKonstantin Belousov * represents NBPDR bytes, aligned to NBPDR. NBPDR is 4M for non-PAE 1809a527560SKonstantin Belousov * page tables, and 2M for PAE, so PAE mode requires twice as many PTDs 1819a527560SKonstantin Belousov * to create the same memory map as non-PAE. 182d86c1f0dSKonstantin Belousov * 183d86c1f0dSKonstantin Belousov * 0x00000000 - 0x003fffff Transient identity map of low memory (0-4M), 184d86c1f0dSKonstantin Belousov * normally disabled to catch NULL derefs. 185f2ae19e5SAlan Cox * 0x00400000 - 0x007fffff Fixed mapping of the low memory (4-8M). 186d86c1f0dSKonstantin Belousov * 0x00800000 - 0xffbfffff KERNBASE (VA) == KERNLOAD (PA), kernel 187d86c1f0dSKonstantin Belousov * text + data and all kernel maps. Managed 188d86c1f0dSKonstantin Belousov * by MI VM. 189d86c1f0dSKonstantin Belousov * 0xffc00000 - 0xffdfffff Recursive kernel page table mapping, pointed 190f2ae19e5SAlan Cox * to by PTmap. PTD[] recursively points 191d86c1f0dSKonstantin Belousov * into PTmap. 192d86c1f0dSKonstantin Belousov * 0xffe00000 - 0xffffffff Kernel/User mode shared PDE, contains GDT, 193d86c1f0dSKonstantin Belousov * IDT, TSS, LDT, trampoline code and stacks. 194d86c1f0dSKonstantin Belousov * Managed by pmap_trm_alloc(). 195d86c1f0dSKonstantin Belousov */ 196d86c1f0dSKonstantin Belousov 197d9bed5beSJohn Dyson /* 198c70af487SAlan Cox * How many physical pages per kmem arena virtual page. 199d9bed5beSJohn Dyson */ 200d9bed5beSJohn Dyson #ifndef VM_KMEM_SIZE_SCALE 2019a527560SKonstantin Belousov #define VM_KMEM_SIZE_SCALE (1) 202d9bed5beSJohn Dyson #endif 203d9bed5beSJohn Dyson 204d9bed5beSJohn Dyson /* 205c70af487SAlan Cox * Optional floor (in bytes) on the size of the kmem arena. 206c70af487SAlan Cox */ 207c70af487SAlan Cox #ifndef VM_KMEM_SIZE_MIN 208c70af487SAlan Cox #define VM_KMEM_SIZE_MIN (12 * 1024 * 1024) 209c70af487SAlan Cox #endif 210c70af487SAlan Cox 211c70af487SAlan Cox /* 212c70af487SAlan Cox * Optional ceiling (in bytes) on the size of the kmem arena: 40% of the 213c70af487SAlan Cox * kernel map rounded to the nearest multiple of the superpage size. 214d9bed5beSJohn Dyson */ 215d9bed5beSJohn Dyson #ifndef VM_KMEM_SIZE_MAX 216c5ecbfb4SAlan Cox #define VM_KMEM_SIZE_MAX (((((VM_MAX_KERNEL_ADDRESS - \ 217c5ecbfb4SAlan Cox VM_MIN_KERNEL_ADDRESS) >> (PDRSHIFT - 2)) + 5) / 10) << PDRSHIFT) 2187bcc0f3dSTor Egge #endif 2195b81b6b3SRodney W. Grimes 22095461b45SJohn Dyson /* initial pagein size of beginning of executable file */ 22195461b45SJohn Dyson #ifndef VM_INITIAL_PAGEIN 22295461b45SJohn Dyson #define VM_INITIAL_PAGEIN 16 22395461b45SJohn Dyson #endif 22495461b45SJohn Dyson 225cfb00e5aSMatthew D Fleming #define ZERO_REGION_SIZE (64 * 1024) /* 64KB */ 226cfb00e5aSMatthew D Fleming 22779f62ed6SAlfred Perlstein #ifndef VM_MAX_AUTOTUNE_MAXUSERS 22879f62ed6SAlfred Perlstein #define VM_MAX_AUTOTUNE_MAXUSERS 384 22979f62ed6SAlfred Perlstein #endif 23079f62ed6SAlfred Perlstein 231c8d2ffd6SGleb Smirnoff #define SFBUF 232c8d2ffd6SGleb Smirnoff #define SFBUF_MAP 233c8d2ffd6SGleb Smirnoff #define SFBUF_CPUSET 234c8d2ffd6SGleb Smirnoff #define SFBUF_PROCESS_PAGE 235c8d2ffd6SGleb Smirnoff 2369a8196ceSNathan Whitehorn #define PMAP_HAS_DMAP 0 237ad6b97e7SNathan Whitehorn #define PHYS_TO_DMAP(x) ({ panic("No direct map exists"); 0; }) 238ad6b97e7SNathan Whitehorn #define DMAP_TO_PHYS(x) ({ panic("No direct map exists"); 0; }) 2399a8196ceSNathan Whitehorn 240ab041f71SD Scott Phillips /* 24178257765SMark Johnston * No non-transparent large page support in the pmap. 24278257765SMark Johnston */ 24378257765SMark Johnston #define PMAP_HAS_LARGEPAGES 0 24478257765SMark Johnston 24578257765SMark Johnston /* 246ab041f71SD Scott Phillips * Need a page dump array for minidump. 247ab041f71SD Scott Phillips */ 248ab041f71SD Scott Phillips #define MINIDUMP_PAGE_TRACKING 1 249*0a44b8a5SBojan Novković #define MINIDUMP_STARTUP_PAGE_TRACKING 0 250ab041f71SD Scott Phillips 2516e393973SGarrett Wollman #endif /* _MACHINE_VMPARAM_H_ */ 252