vmparam.h revision 221271
1292915Sdim/*- 2292915Sdim * Copyright (c) 1988 University of Utah. 3292915Sdim * Copyright (c) 1992, 1993 4292915Sdim * The Regents of the University of California. All rights reserved. 5292915Sdim * 6292915Sdim * This code is derived from software contributed to Berkeley by 7292915Sdim * the Systems Programming Group of the University of Utah Computer 8292915Sdim * Science Department and Ralph Campbell. 9292915Sdim * 10292915Sdim * Redistribution and use in source and binary forms, with or without 11292915Sdim * modification, are permitted provided that the following conditions 12292915Sdim * are met: 13292915Sdim * 1. Redistributions of source code must retain the above copyright 14292915Sdim * notice, this list of conditions and the following disclaimer. 15292915Sdim * 2. Redistributions in binary form must reproduce the above copyright 16292915Sdim * notice, this list of conditions and the following disclaimer in the 17292915Sdim * documentation and/or other materials provided with the distribution. 18292915Sdim * 4. Neither the name of the University nor the names of its contributors 19292915Sdim * may be used to endorse or promote products derived from this software 20292915Sdim * without specific prior written permission. 21292915Sdim * 22292915Sdim * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23292915Sdim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24292915Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25292915Sdim * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26292915Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27292915Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28292915Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29292915Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30292915Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31292915Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32292915Sdim * SUCH DAMAGE. 33292915Sdim * 34292915Sdim * from: Utah $Hdr: vmparam.h 1.16 91/01/18$ 35292915Sdim * 36292915Sdim * @(#)vmparam.h 8.2 (Berkeley) 4/22/94 37292915Sdim * 38292915Sdim * $FreeBSD: head/sys/ia64/include/vmparam.h 221271 2011-04-30 20:49:00Z marcel $ 39292915Sdim */ 40292915Sdim 41292915Sdim#ifndef _MACHINE_VMPARAM_H_ 42292915Sdim#define _MACHINE_VMPARAM_H_ 43292915Sdim 44292915Sdim/* 45292915Sdim * Virtual memory related constants, all in bytes 46292915Sdim */ 47292915Sdim#ifndef MAXTSIZ 48292915Sdim#define MAXTSIZ (1<<30) /* max text size (1G) */ 49292915Sdim#endif 50292915Sdim#ifndef DFLDSIZ 51292915Sdim#define DFLDSIZ (1<<27) /* initial data size (128M) */ 52292915Sdim#endif 53292915Sdim#ifndef MAXDSIZ 54292915Sdim#define MAXDSIZ (1<<30) /* max data size (1G) */ 55292915Sdim#endif 56292915Sdim#ifndef DFLSSIZ 57292915Sdim#define DFLSSIZ (1<<21) /* initial stack size (2M) */ 58292915Sdim#endif 59292915Sdim#ifndef MAXSSIZ 60292915Sdim#define MAXSSIZ (1<<28) /* max stack size (256M) */ 61292915Sdim#endif 62292915Sdim#ifndef SGROWSIZ 63292915Sdim#define SGROWSIZ (128UL*1024) /* amount to grow stack */ 64292915Sdim#endif 65292915Sdim 66292915Sdim/* 67292915Sdim * We need region 7 virtual addresses for pagetables. 68292915Sdim */ 69292915Sdim#define UMA_MD_SMALL_ALLOC 70292915Sdim 71292915Sdim/* 72292915Sdim * The physical address space is sparsely populated. 73292915Sdim */ 74292915Sdim#define VM_PHYSSEG_SPARSE 75292915Sdim 76292915Sdim/* 77292915Sdim * The number of PHYSSEG entries is equal to the number of phys_avail 78292915Sdim * entries. 79292915Sdim */ 80292915Sdim#define VM_PHYSSEG_MAX 49 81292915Sdim 82292915Sdim/* 83292915Sdim * Create three free page pools: VM_FREEPOOL_DEFAULT is the default pool 84292915Sdim * from which physical pages are allocated and VM_FREEPOOL_DIRECT is 85292915Sdim * the pool from which physical pages for small UMA objects are 86292915Sdim * allocated. 87292915Sdim */ 88292915Sdim#define VM_NFREEPOOL 3 89292915Sdim#define VM_FREEPOOL_CACHE 2 90292915Sdim#define VM_FREEPOOL_DEFAULT 0 91292915Sdim#define VM_FREEPOOL_DIRECT 1 92292915Sdim 93292915Sdim/* 94292915Sdim * Create one free page list. 95292915Sdim */ 96292915Sdim#define VM_NFREELIST 1 97292915Sdim#define VM_FREELIST_DEFAULT 0 98292915Sdim 99292915Sdim/* 100292915Sdim * An allocation size of 256MB is supported in order to optimize the 101292915Sdim * use of the identity mappings in region 7 by UMA. 102292915Sdim */ 103292915Sdim#define VM_NFREEORDER 16 104292915Sdim 105292915Sdim/* 106292915Sdim * Only one memory domain. 107292915Sdim */ 108292915Sdim#ifndef VM_NDOMAIN 109292915Sdim#define VM_NDOMAIN 1 110292915Sdim#endif 111292915Sdim 112292915Sdim/* 113292915Sdim * Disable superpage reservations. 114292915Sdim */ 115292915Sdim#ifndef VM_NRESERVLEVEL 116292915Sdim#define VM_NRESERVLEVEL 0 117292915Sdim#endif 118292915Sdim 119292915Sdim#define IA64_VM_MINKERN_REGION 4 120292915Sdim 121292915Sdim/* 122292915Sdim * Manipulating region bits of an address. 123292915Sdim */ 124292915Sdim#define IA64_RR_BASE(n) (((uint64_t) (n)) << 61) 125292915Sdim#define IA64_RR_MASK(x) ((x) & ((1L << 61) - 1)) 126292915Sdim 127292915Sdim#define IA64_PHYS_TO_RR6(x) ((x) | IA64_RR_BASE(6)) 128292915Sdim#define IA64_PHYS_TO_RR7(x) ((x) | IA64_RR_BASE(7)) 129292915Sdim 130292915Sdim/* 131292915Sdim * The Itanium architecture defines that all implementations support at 132292915Sdim * least 51 virtual address bits (i.e. IMPL_VA_MSB=50). The unimplemented 133292915Sdim * bits are sign-extended from VA{IMPL_VA_MSB}. As such, there's a gap in 134292915Sdim * the virtual address range, which extends at most from 0x0004000000000000 135292915Sdim * to 0x1ffbffffffffffff. We define the top half of a region in terms of 136292915Sdim * this worst-case gap. 137292915Sdim */ 138292915Sdim#define IA64_REGION_GAP_START 0x0004000000000000 139292915Sdim#define IA64_REGION_GAP_EXTEND 0x1ffc000000000000 140292915Sdim 141292915Sdim/* 142292915Sdim * Parameters for Pre-Boot Virtual Memory (PBVM). 143292915Sdim * The kernel, its modules and metadata are loaded in the PBVM by the loader. 144292915Sdim * The PBVM consists of pages for which the mapping is maintained in a page 145292915Sdim * table. The page table is at least 1 EFI page large (i.e. 4KB), but can be 146292915Sdim * larger to accommodate more PBVM. The maximum page table size is 1MB. With 147292915Sdim * 8 bytes per page table entry, this means that the PBVM has at least 512 148292915Sdim * pages and at most 128K pages. 149292915Sdim * The GNU toolchain (in particular GNU ld) does not support an alignment 150292915Sdim * larger than 64K. This means that we cannot guarantee page alignment for 151292915Sdim * a page size that's larger than 64K. We do want to have text and data in 152292915Sdim * different pages, which means that the maximum usable page size is 64KB. 153292915Sdim * Consequently: 154292915Sdim * The maximum total PBVM size is 8GB -- enough for a DVD image. A page table 155292915Sdim * of a single EFI page (4KB) allows for 32MB of PBVM. 156292915Sdim * 157292915Sdim * The kernel is given the PA and size of the page table that provides the 158292915Sdim * mapping of the PBVM. The page table itself is assumed to be mapped at a 159292915Sdim * known virtual address and using a single translation wired into the CPU. 160292915Sdim * As such, the page table is assumed to be a power of 2 and naturally aligned. 161292915Sdim * The kernel also assumes that a good portion of the kernel text is mapped 162292915Sdim * and wired into the CPU, but does not assume that the mapping covers the 163292915Sdim * whole of PBVM. 164292915Sdim */ 165292915Sdim#define IA64_PBVM_RR IA64_VM_MINKERN_REGION 166292915Sdim#define IA64_PBVM_BASE \ 167292915Sdim (IA64_RR_BASE(IA64_PBVM_RR) + IA64_REGION_GAP_EXTEND) 168292915Sdim 169292915Sdim#define IA64_PBVM_PGTBL_MAXSZ 1048576 170292915Sdim#define IA64_PBVM_PGTBL \ 171292915Sdim (IA64_RR_BASE(IA64_PBVM_RR + 1) - IA64_PBVM_PGTBL_MAXSZ) 172292915Sdim 173292915Sdim#define IA64_PBVM_PAGE_SHIFT 16 /* 64KB */ 174292915Sdim#define IA64_PBVM_PAGE_SIZE (1 << IA64_PBVM_PAGE_SHIFT) 175292915Sdim#define IA64_PBVM_PAGE_MASK (IA64_PBVM_PAGE_SIZE - 1) 176292915Sdim 177292915Sdim/* 178292915Sdim * Mach derived constants 179292915Sdim */ 180292915Sdim 181292915Sdim/* user/kernel map constants */ 182292915Sdim#define VM_MIN_ADDRESS 0 183292915Sdim#define VM_MAXUSER_ADDRESS IA64_RR_BASE(IA64_VM_MINKERN_REGION) 184292915Sdim#define VM_MIN_KERNEL_ADDRESS IA64_RR_BASE(IA64_VM_MINKERN_REGION + 1) 185292915Sdim#define VM_MAX_KERNEL_ADDRESS (IA64_RR_BASE(IA64_VM_MINKERN_REGION + 2) - 1) 186292915Sdim#define VM_MAX_ADDRESS ~0UL 187292915Sdim 188292915Sdim#define KERNBASE VM_MAXUSER_ADDRESS 189292915Sdim 190292915Sdim/* 191292915Sdim * USRSTACK is the top (end) of the user stack. Immediately above the user 192292915Sdim * stack resides the syscall gateway page. 193292915Sdim */ 194292915Sdim#define USRSTACK VM_MAXUSER_ADDRESS 195292915Sdim#define IA64_BACKINGSTORE (USRSTACK - (2 * MAXSSIZ) - PAGE_SIZE) 196292915Sdim 197292915Sdim/* virtual sizes (bytes) for various kernel submaps */ 198292915Sdim#ifndef VM_KMEM_SIZE 199292915Sdim#define VM_KMEM_SIZE (12 * 1024 * 1024) 200292915Sdim#endif 201292915Sdim 202292915Sdim/* 203292915Sdim * How many physical pages per KVA page allocated. 204292915Sdim * min(max(max(VM_KMEM_SIZE, Physical memory/VM_KMEM_SIZE_SCALE), 205292915Sdim * VM_KMEM_SIZE_MIN), VM_KMEM_SIZE_MAX) 206292915Sdim * is the total KVA space allocated for kmem_map. 207292915Sdim */ 208292915Sdim#ifndef VM_KMEM_SIZE_SCALE 209292915Sdim#define VM_KMEM_SIZE_SCALE (4) /* XXX 8192 byte pages */ 210292915Sdim#endif 211292915Sdim 212292915Sdim/* initial pagein size of beginning of executable file */ 213292915Sdim#ifndef VM_INITIAL_PAGEIN 214292915Sdim#define VM_INITIAL_PAGEIN 16 215292915Sdim#endif 216292915Sdim 217292915Sdim#endif /* !_MACHINE_VMPARAM_H_ */ 218292915Sdim