1 /* $NetBSD: vmparam.h,v 1.54 2015/06/30 04:20:19 matt Exp $ */ 2 3 /* 4 * Copyright (c) 1988 University of Utah. 5 * Copyright (c) 1992, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * This code is derived from software contributed to Berkeley by 9 * the Systems Programming Group of the University of Utah Computer 10 * Science Department and Ralph Campbell. 11 * 12 * Redistribution and use in source and binary forms, with or without 13 * modification, are permitted provided that the following conditions 14 * are met: 15 * 1. Redistributions of source code must retain the above copyright 16 * notice, this list of conditions and the following disclaimer. 17 * 2. Redistributions in binary form must reproduce the above copyright 18 * notice, this list of conditions and the following disclaimer in the 19 * documentation and/or other materials provided with the distribution. 20 * 3. Neither the name of the University nor the names of its contributors 21 * may be used to endorse or promote products derived from this software 22 * without specific prior written permission. 23 * 24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 * 36 * from: Utah Hdr: vmparam.h 1.16 91/01/18 37 * 38 * @(#)vmparam.h 8.2 (Berkeley) 4/22/94 39 */ 40 41 #ifndef _MIPS_VMPARAM_H_ 42 #define _MIPS_VMPARAM_H_ 43 44 #ifdef _KERNEL_OPT 45 #include "opt_cputype.h" 46 #include "opt_multiprocessor.h" 47 #include "opt_modular.h" 48 #endif 49 50 /* 51 * Machine dependent VM constants for MIPS. 52 */ 53 #if !defined(_RUMPKERNEL) && (defined(MODULAR) || defined(_MODULE)) 54 #define MAX_PAGE_SIZE 16384 55 #define MIN_PAGE_SIZE 4096 56 #endif 57 58 /* 59 * We normally use a 4K page but may use 16K on MIPS systems. 60 * Override PAGE_* definitions to compile-time constants. 61 */ 62 #ifdef ENABLE_MIPS_16KB_PAGE 63 #define PAGE_SHIFT 14 64 #elif defined(ENABLE_MIPS_4KB_PAGE) || 1 65 #define PAGE_SHIFT 12 66 #else 67 #error ENABLE_MIPS_xKB_PAGE not defined 68 #endif 69 #define PAGE_SIZE (1 << PAGE_SHIFT) 70 #define PAGE_MASK (PAGE_SIZE - 1) 71 72 /* 73 * USRSTACK is the top (end) of the user stack. 74 * 75 * USRSTACK needs to start a little below 0x8000000 because the R8000 76 * and some QED CPUs perform some virtual address checks before the 77 * offset is calculated. We use 0x8000 since that's the max displacement 78 * in an instruction. 79 */ 80 #define USRSTACK (VM_MAXUSER_ADDRESS-0x8000) /* Start of user stack */ 81 #define USRSTACK32 ((uint32_t)VM_MAXUSER32_ADDRESS-0x8000) 82 83 /* 84 * Virtual memory related constants, all in bytes 85 */ 86 #if defined(__mips_o32) 87 #ifndef MAXTSIZ 88 #define MAXTSIZ (64*1024*1024) /* max text size */ 89 #endif 90 #ifndef DFLDSIZ 91 #define DFLDSIZ (128*1024*1024) /* initial data size limit */ 92 #endif 93 #ifndef MAXDSIZ 94 #define MAXDSIZ (512*1024*1024) /* max data size */ 95 #endif 96 #ifndef DFLSSIZ 97 #define DFLSSIZ (4*1024*1024) /* initial stack size limit */ 98 #endif 99 #ifndef MAXSSIZ 100 #define MAXSSIZ (32*1024*1024) /* max stack size */ 101 #endif 102 #else 103 /* 104 * 64-bit ABIs need more space. 105 */ 106 #ifndef MAXTSIZ 107 #define MAXTSIZ (128*1024*1024) /* max text size */ 108 #endif 109 #ifndef DFLDSIZ 110 #define DFLDSIZ (256*1024*1024) /* initial data size limit */ 111 #endif 112 #ifndef MAXDSIZ 113 #define MAXDSIZ (1536*1024*1024) /* max data size */ 114 #endif 115 #ifndef DFLSSIZ 116 #define DFLSSIZ (16*1024*1024) /* initial stack size limit */ 117 #endif 118 #ifndef MAXSSIZ 119 #define MAXSSIZ (120*1024*1024) /* max stack size */ 120 #endif 121 #endif /* !__mips_o32 */ 122 123 /* 124 * Virtual memory related constants, all in bytes 125 */ 126 #ifndef MAXTSIZ32 127 #define MAXTSIZ32 MAXTSIZ /* max text size */ 128 #endif 129 #ifndef DFLDSIZ32 130 #define DFLDSIZ32 DFLDSIZ /* initial data size limit */ 131 #endif 132 #ifndef MAXDSIZ32 133 #define MAXDSIZ32 MAXDSIZ /* max data size */ 134 #endif 135 #ifndef DFLSSIZ32 136 #define DFLSSIZ32 DFLTSIZ /* initial stack size limit */ 137 #endif 138 #ifndef MAXSSIZ32 139 #define MAXSSIZ32 MAXSSIZ /* max stack size */ 140 #endif 141 142 /* 143 * PTEs for mapping user space into the kernel for phyio operations. 144 * The default PTE number is enough to cover 8 disks * MAXBSIZE. 145 */ 146 #ifndef USRIOSIZE 147 #define USRIOSIZE (MAXBSIZE/PAGE_SIZE * 8) 148 #endif 149 150 /* 151 * Mach derived constants 152 */ 153 154 /* 155 * user/kernel map constants 156 * These are negative addresses since MIPS addresses are signed. 157 */ 158 #define VM_MIN_ADDRESS ((vaddr_t)0x00000000) 159 #ifdef _LP64 160 #define MIPS_VM_MAXUSER_ADDRESS ((vaddr_t) 1L << (4*PGSHIFT-8)) 161 #ifdef ENABLE_MIPS_16KB_PAGE 162 #define VM_MAXUSER_ADDRESS mips_vm_maxuser_address 163 #else 164 #define VM_MAXUSER_ADDRESS MIPS_VM_MAXUSER_ADDRESS 165 #endif 166 /* 0x0000010000000000 */ 167 #define VM_MAX_ADDRESS VM_MAXUSER_ADDRESS 168 #define VM_MIN_KERNEL_ADDRESS ((vaddr_t) 3L << 62) /* 0xC000000000000000 */ 169 #define VM_MAX_KERNEL_ADDRESS ((vaddr_t) -1L << 31) /* 0xFFFFFFFF80000000 */ 170 #else 171 #define VM_MAXUSER_ADDRESS ((vaddr_t)-0x7fffffff-1)/* 0xFFFFFFFF80000000 */ 172 #define VM_MAX_ADDRESS ((vaddr_t)-0x7fffffff-1)/* 0xFFFFFFFF80000000 */ 173 #define VM_MIN_KERNEL_ADDRESS ((vaddr_t)-0x40000000) /* 0xFFFFFFFFC0000000 */ 174 #ifdef ENABLE_MIPS_TX3900 175 #define VM_MAX_KERNEL_ADDRESS ((vaddr_t)-0x01000000) /* 0xFFFFFFFFFF000000 */ 176 #else 177 #define VM_MAX_KERNEL_ADDRESS ((vaddr_t)-0x00004000) /* 0xFFFFFFFFFFFFC000 */ 178 #endif 179 #endif 180 #define VM_MAXUSER32_ADDRESS ((vaddr_t)(1UL << 31))/* 0x0000000080000000 */ 181 182 /* 183 * The address to which unspecified mapping requests default 184 */ 185 #define __USE_TOPDOWN_VM 186 187 #define VM_DEFAULT_ADDRESS_TOPDOWN(da, sz) \ 188 trunc_page(USRSTACK - MAXSSIZ - (sz)) 189 #define VM_DEFAULT_ADDRESS_BOTTOMUP(da, sz) \ 190 round_page((vaddr_t)(da) + (vsize_t)maxdmap) 191 192 #define VM_DEFAULT_ADDRESS32_TOPDOWN(da, sz) \ 193 trunc_page(USRSTACK32 - MAXSSIZ32 - (sz)) 194 #define VM_DEFAULT_ADDRESS32_BOTTOMUP(da, sz) \ 195 round_page((vaddr_t)(da) + (vsize_t)MAXDSIZ32) 196 197 /* virtual sizes (bytes) for various kernel submaps */ 198 #define VM_PHYS_SIZE (USRIOSIZE*PAGE_SIZE) 199 200 /* VM_PHYSSEG_MAX defined by platform-dependent code. */ 201 #define VM_PHYSSEG_STRAT VM_PSTRAT_BSEARCH 202 #define VM_PHYSSEG_NOADD /* can add RAM after vm_mem_init */ 203 204 #ifndef VM_NFREELIST 205 #define VM_NFREELIST 16 /* 16 distinct memory segments */ 206 #define VM_FREELIST_DEFAULT 0 207 #define VM_FREELIST_MAX 1 208 #endif 209 210 #ifdef _KERNEL 211 #define UVM_KM_VMFREELIST mips_poolpage_vmfreelist 212 extern int mips_poolpage_vmfreelist; 213 #ifdef ENABLE_MIPS_16KB_PAGE 214 extern vaddr_t mips_vm_maxuser_address; 215 #endif 216 #endif 217 218 #endif /* ! _MIPS_VMPARAM_H_ */ 219