vmparam.h revision 247251
1139790Simp/*- 266458Sdfr * Copyright (c) 1988 University of Utah. 366458Sdfr * Copyright (c) 1992, 1993 466458Sdfr * The Regents of the University of California. All rights reserved. 566458Sdfr * 666458Sdfr * This code is derived from software contributed to Berkeley by 766458Sdfr * the Systems Programming Group of the University of Utah Computer 866458Sdfr * Science Department and Ralph Campbell. 966458Sdfr * 1066458Sdfr * Redistribution and use in source and binary forms, with or without 1166458Sdfr * modification, are permitted provided that the following conditions 1266458Sdfr * are met: 1366458Sdfr * 1. Redistributions of source code must retain the above copyright 1466458Sdfr * notice, this list of conditions and the following disclaimer. 1566458Sdfr * 2. Redistributions in binary form must reproduce the above copyright 1666458Sdfr * notice, this list of conditions and the following disclaimer in the 1766458Sdfr * documentation and/or other materials provided with the distribution. 1866458Sdfr * 4. Neither the name of the University nor the names of its contributors 1966458Sdfr * may be used to endorse or promote products derived from this software 2066458Sdfr * without specific prior written permission. 2166458Sdfr * 2266458Sdfr * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2366458Sdfr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2466458Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2566458Sdfr * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2666458Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2766458Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2866458Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2966458Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3066458Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3166458Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3266458Sdfr * SUCH DAMAGE. 3366458Sdfr * 3466458Sdfr * from: Utah $Hdr: vmparam.h 1.16 91/01/18$ 3566458Sdfr * 3666458Sdfr * @(#)vmparam.h 8.2 (Berkeley) 4/22/94 37178296Smarcel * 38178296Smarcel * $FreeBSD: head/sys/ia64/include/vmparam.h 247251 2013-02-25 02:41:38Z marcel $ 3966458Sdfr */ 4066458Sdfr 41178296Smarcel#ifndef _MACHINE_VMPARAM_H_ 42178296Smarcel#define _MACHINE_VMPARAM_H_ 43178296Smarcel 4466458Sdfr/* 4566458Sdfr * Virtual memory related constants, all in bytes 4666458Sdfr */ 4766458Sdfr#ifndef MAXTSIZ 4866458Sdfr#define MAXTSIZ (1<<30) /* max text size (1G) */ 4966458Sdfr#endif 5066458Sdfr#ifndef DFLDSIZ 5166458Sdfr#define DFLDSIZ (1<<27) /* initial data size (128M) */ 5266458Sdfr#endif 5366458Sdfr#ifndef MAXDSIZ 5466458Sdfr#define MAXDSIZ (1<<30) /* max data size (1G) */ 5566458Sdfr#endif 5666458Sdfr#ifndef DFLSSIZ 5766458Sdfr#define DFLSSIZ (1<<21) /* initial stack size (2M) */ 5866458Sdfr#endif 5966458Sdfr#ifndef MAXSSIZ 6092670Speter#define MAXSSIZ (1<<28) /* max stack size (256M) */ 6166458Sdfr#endif 6266458Sdfr#ifndef SGROWSIZ 6366458Sdfr#define SGROWSIZ (128UL*1024) /* amount to grow stack */ 6466458Sdfr#endif 6566458Sdfr 6666458Sdfr/* 67106486Smarcel * We need region 7 virtual addresses for pagetables. 68106486Smarcel */ 69106486Smarcel#define UMA_MD_SMALL_ALLOC 70106486Smarcel 71106486Smarcel/* 72169291Salc * The physical address space is sparsely populated. 73169291Salc */ 74169291Salc#define VM_PHYSSEG_SPARSE 75169291Salc 76169291Salc/* 77170519Salc * The number of PHYSSEG entries is equal to the number of phys_avail 78170519Salc * entries. 79170519Salc */ 80170519Salc#define VM_PHYSSEG_MAX 49 81170519Salc 82170519Salc/* 83172317Salc * Create three free page pools: VM_FREEPOOL_DEFAULT is the default pool 84170519Salc * from which physical pages are allocated and VM_FREEPOOL_DIRECT is 85170519Salc * the pool from which physical pages for small UMA objects are 86170519Salc * allocated. 87170519Salc */ 88172317Salc#define VM_NFREEPOOL 3 89172317Salc#define VM_FREEPOOL_CACHE 2 90170519Salc#define VM_FREEPOOL_DEFAULT 0 91170519Salc#define VM_FREEPOOL_DIRECT 1 92170519Salc 93170519Salc/* 94170519Salc * Create one free page list. 95170519Salc */ 96170519Salc#define VM_NFREELIST 1 97170519Salc#define VM_FREELIST_DEFAULT 0 98170519Salc 99170519Salc/* 100170519Salc * An allocation size of 256MB is supported in order to optimize the 101170519Salc * use of the identity mappings in region 7 by UMA. 102170519Salc */ 103170519Salc#define VM_NFREEORDER 16 104170519Salc 105170519Salc/* 106210550Sjhb * Only one memory domain. 107210550Sjhb */ 108210550Sjhb#ifndef VM_NDOMAIN 109210550Sjhb#define VM_NDOMAIN 1 110210550Sjhb#endif 111210550Sjhb 112210550Sjhb/* 113174938Salc * Disable superpage reservations. 114174938Salc */ 115174938Salc#ifndef VM_NRESERVLEVEL 116174938Salc#define VM_NRESERVLEVEL 0 117174938Salc#endif 118174938Salc 119219808Smarcel#define IA64_VM_MINKERN_REGION 4 120219808Smarcel 121174938Salc/* 12296912Smarcel * Manipulating region bits of an address. 12396912Smarcel */ 124208283Smarcel#define IA64_RR_BASE(n) (((uint64_t) (n)) << 61) 12596912Smarcel#define IA64_RR_MASK(x) ((x) & ((1L << 61) - 1)) 12696912Smarcel 127221271Smarcel#define IA64_PHYS_TO_RR6(x) ((x) | IA64_RR_BASE(6)) 128221271Smarcel#define IA64_PHYS_TO_RR7(x) ((x) | IA64_RR_BASE(7)) 12996912Smarcel 13096912Smarcel/* 131219691Smarcel * The Itanium architecture defines that all implementations support at 132219691Smarcel * least 51 virtual address bits (i.e. IMPL_VA_MSB=50). The unimplemented 133219691Smarcel * bits are sign-extended from VA{IMPL_VA_MSB}. As such, there's a gap in 134219691Smarcel * the virtual address range, which extends at most from 0x0004000000000000 135219691Smarcel * to 0x1ffbffffffffffff. We define the top half of a region in terms of 136219691Smarcel * this worst-case gap. 137219691Smarcel */ 138219808Smarcel#define IA64_REGION_GAP_START 0x0004000000000000 139219808Smarcel#define IA64_REGION_GAP_EXTEND 0x1ffc000000000000 140219691Smarcel 141219691Smarcel/* 142219691Smarcel * Parameters for Pre-Boot Virtual Memory (PBVM). 143219691Smarcel * The kernel, its modules and metadata are loaded in the PBVM by the loader. 144219691Smarcel * The PBVM consists of pages for which the mapping is maintained in a page 145219691Smarcel * table. The page table is at least 1 EFI page large (i.e. 4KB), but can be 146219691Smarcel * larger to accommodate more PBVM. The maximum page table size is 1MB. With 147219691Smarcel * 8 bytes per page table entry, this means that the PBVM has at least 512 148219691Smarcel * pages and at most 128K pages. 149219691Smarcel * The GNU toolchain (in particular GNU ld) does not support an alignment 150219691Smarcel * larger than 64K. This means that we cannot guarantee page alignment for 151219691Smarcel * a page size that's larger than 64K. We do want to have text and data in 152219691Smarcel * different pages, which means that the maximum usable page size is 64KB. 153219691Smarcel * Consequently: 154219691Smarcel * The maximum total PBVM size is 8GB -- enough for a DVD image. A page table 155219691Smarcel * of a single EFI page (4KB) allows for 32MB of PBVM. 156219691Smarcel * 157219691Smarcel * The kernel is given the PA and size of the page table that provides the 158219691Smarcel * mapping of the PBVM. The page table itself is assumed to be mapped at a 159219691Smarcel * known virtual address and using a single translation wired into the CPU. 160219691Smarcel * As such, the page table is assumed to be a power of 2 and naturally aligned. 161219691Smarcel * The kernel also assumes that a good portion of the kernel text is mapped 162219691Smarcel * and wired into the CPU, but does not assume that the mapping covers the 163219691Smarcel * whole of PBVM. 164219691Smarcel */ 165219808Smarcel#define IA64_PBVM_RR IA64_VM_MINKERN_REGION 166219691Smarcel#define IA64_PBVM_BASE \ 167219808Smarcel (IA64_RR_BASE(IA64_PBVM_RR) + IA64_REGION_GAP_EXTEND) 168219691Smarcel 169219691Smarcel#define IA64_PBVM_PGTBL_MAXSZ 1048576 170219691Smarcel#define IA64_PBVM_PGTBL \ 171219691Smarcel (IA64_RR_BASE(IA64_PBVM_RR + 1) - IA64_PBVM_PGTBL_MAXSZ) 172219691Smarcel 173219691Smarcel#define IA64_PBVM_PAGE_SHIFT 16 /* 64KB */ 174219691Smarcel#define IA64_PBVM_PAGE_SIZE (1 << IA64_PBVM_PAGE_SHIFT) 175219691Smarcel#define IA64_PBVM_PAGE_MASK (IA64_PBVM_PAGE_SIZE - 1) 176219691Smarcel 177219691Smarcel/* 17866458Sdfr * Mach derived constants 17966458Sdfr */ 18066458Sdfr 18166458Sdfr/* user/kernel map constants */ 182219808Smarcel#define VM_MIN_ADDRESS 0 183219808Smarcel#define VM_MAXUSER_ADDRESS IA64_RR_BASE(IA64_VM_MINKERN_REGION) 184247251Smarcel#define VM_MIN_KERNEL_ADDRESS VM_MAXUSER_ADDRESS 185247251Smarcel#define VM_INIT_KERNEL_ADDRESS IA64_RR_BASE(IA64_VM_MINKERN_REGION + 1) 186247251Smarcel#define VM_MAX_KERNEL_ADDRESS (IA64_RR_BASE(IA64_VM_MINKERN_REGION + 2) - 1) 187219741Smarcel#define VM_MAX_ADDRESS ~0UL 18866458Sdfr 189247251Smarcel/* We link the kernel at IA64_PBVM_BASE. */ 190247251Smarcel#define KERNBASE IA64_PBVM_BASE 19196912Smarcel 192219808Smarcel/* 193219808Smarcel * USRSTACK is the top (end) of the user stack. Immediately above the user 194219808Smarcel * stack resides the syscall gateway page. 195219808Smarcel */ 196219808Smarcel#define USRSTACK VM_MAXUSER_ADDRESS 197219808Smarcel#define IA64_BACKINGSTORE (USRSTACK - (2 * MAXSSIZ) - PAGE_SIZE) 198219808Smarcel 19966458Sdfr/* virtual sizes (bytes) for various kernel submaps */ 20066458Sdfr#ifndef VM_KMEM_SIZE 20166458Sdfr#define VM_KMEM_SIZE (12 * 1024 * 1024) 20266458Sdfr#endif 20366458Sdfr 20466458Sdfr/* 20566458Sdfr * How many physical pages per KVA page allocated. 206168920Ssepotvin * min(max(max(VM_KMEM_SIZE, Physical memory/VM_KMEM_SIZE_SCALE), 207168920Ssepotvin * VM_KMEM_SIZE_MIN), VM_KMEM_SIZE_MAX) 20866458Sdfr * is the total KVA space allocated for kmem_map. 20966458Sdfr */ 21066458Sdfr#ifndef VM_KMEM_SIZE_SCALE 21166458Sdfr#define VM_KMEM_SIZE_SCALE (4) /* XXX 8192 byte pages */ 21266458Sdfr#endif 21366458Sdfr 21466458Sdfr/* initial pagein size of beginning of executable file */ 21566458Sdfr#ifndef VM_INITIAL_PAGEIN 21666458Sdfr#define VM_INITIAL_PAGEIN 16 21766458Sdfr#endif 21866458Sdfr 219221855Smdf#define ZERO_REGION_SIZE (2 * 1024 * 1024) /* 2MB */ 220221855Smdf 221178296Smarcel#endif /* !_MACHINE_VMPARAM_H_ */ 222