1 /* $NetBSD: vmparam.h,v 1.52 2014/01/25 15:16:50 christos 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_multiprocessor.h" 46 #include "opt_cputype.h" 47 #endif 48 49 /* 50 * Machine dependent VM constants for MIPS. 51 */ 52 53 /* 54 * We normally use a 4K page but may use 16K on MIPS systems. 55 * Override PAGE_* definitions to compile-time constants. 56 */ 57 #ifdef ENABLE_MIPS_16KB_PAGE 58 #define PAGE_SHIFT 14 59 #elif defined(ENABLE_MIPS_4KB_PAGE) || 1 60 #define PAGE_SHIFT 12 61 #else 62 #error ENABLE_MIPS_xKB_PAGE not defined 63 #endif 64 #define PAGE_SIZE (1 << PAGE_SHIFT) 65 #define PAGE_MASK (PAGE_SIZE - 1) 66 67 /* 68 * USRSTACK is the top (end) of the user stack. 69 * 70 * USRSTACK needs to start a little below 0x8000000 because the R8000 71 * and some QED CPUs perform some virtual address checks before the 72 * offset is calculated. We use 0x8000 since that's the max displacement 73 * in an instruction. 74 */ 75 #define USRSTACK (VM_MAXUSER_ADDRESS-0x8000) /* Start of user stack */ 76 #define USRSTACK32 ((uint32_t)VM_MAXUSER32_ADDRESS-0x8000) 77 78 /* 79 * Virtual memory related constants, all in bytes 80 */ 81 #if defined(__mips_o32) 82 #ifndef MAXTSIZ 83 #define MAXTSIZ (64*1024*1024) /* max text size */ 84 #endif 85 #ifndef DFLDSIZ 86 #define DFLDSIZ (128*1024*1024) /* initial data size limit */ 87 #endif 88 #ifndef MAXDSIZ 89 #define MAXDSIZ (512*1024*1024) /* max data size */ 90 #endif 91 #ifndef DFLSSIZ 92 #define DFLSSIZ (4*1024*1024) /* initial stack size limit */ 93 #endif 94 #ifndef MAXSSIZ 95 #define MAXSSIZ (32*1024*1024) /* max stack size */ 96 #endif 97 #else 98 /* 99 * 64-bit ABIs need more space. 100 */ 101 #ifndef MAXTSIZ 102 #define MAXTSIZ (128*1024*1024) /* max text size */ 103 #endif 104 #ifndef DFLDSIZ 105 #define DFLDSIZ (256*1024*1024) /* initial data size limit */ 106 #endif 107 #ifndef MAXDSIZ 108 #define MAXDSIZ (1536*1024*1024) /* max data size */ 109 #endif 110 #ifndef DFLSSIZ 111 #define DFLSSIZ (16*1024*1024) /* initial stack size limit */ 112 #endif 113 #ifndef MAXSSIZ 114 #define MAXSSIZ (120*1024*1024) /* max stack size */ 115 #endif 116 #endif /* !__mips_o32 */ 117 118 /* 119 * Virtual memory related constants, all in bytes 120 */ 121 #ifndef MAXTSIZ32 122 #define MAXTSIZ32 MAXTSIZ /* max text size */ 123 #endif 124 #ifndef DFLDSIZ32 125 #define DFLDSIZ32 DFLDSIZ /* initial data size limit */ 126 #endif 127 #ifndef MAXDSIZ32 128 #define MAXDSIZ32 MAXDSIZ /* max data size */ 129 #endif 130 #ifndef DFLSSIZ32 131 #define DFLSSIZ32 DFLTSIZ /* initial stack size limit */ 132 #endif 133 #ifndef MAXSSIZ32 134 #define MAXSSIZ32 MAXSSIZ /* max stack size */ 135 #endif 136 137 /* 138 * PTEs for mapping user space into the kernel for phyio operations. 139 * The default PTE number is enough to cover 8 disks * MAXBSIZE. 140 */ 141 #ifndef USRIOSIZE 142 #define USRIOSIZE (MAXBSIZE/PAGE_SIZE * 8) 143 #endif 144 145 /* 146 * Mach derived constants 147 */ 148 149 /* 150 * user/kernel map constants 151 * These are negative addresses since MIPS addresses are signed. 152 */ 153 #define VM_MIN_ADDRESS ((vaddr_t)0x00000000) 154 #ifdef _LP64 155 #define MIPS_VM_MAXUSER_ADDRESS ((vaddr_t) 1L << (4*PGSHIFT-8)) 156 #ifdef ENABLE_MIPS_16KB_PAGE 157 #define VM_MAXUSER_ADDRESS mips_vm_maxuser_address 158 #else 159 #define VM_MAXUSER_ADDRESS MIPS_VM_MAXUSER_ADDRESS 160 #endif 161 /* 0x0000010000000000 */ 162 #define VM_MAX_ADDRESS VM_MAXUSER_ADDRESS 163 #define VM_MIN_KERNEL_ADDRESS ((vaddr_t) 3L << 62) /* 0xC000000000000000 */ 164 #define VM_MAX_KERNEL_ADDRESS ((vaddr_t) -1L << 31) /* 0xFFFFFFFF80000000 */ 165 #else 166 #define VM_MAXUSER_ADDRESS ((vaddr_t)-0x7fffffff-1)/* 0xFFFFFFFF80000000 */ 167 #define VM_MAX_ADDRESS ((vaddr_t)-0x7fffffff-1)/* 0xFFFFFFFF80000000 */ 168 #define VM_MIN_KERNEL_ADDRESS ((vaddr_t)-0x40000000) /* 0xFFFFFFFFC0000000 */ 169 #ifdef ENABLE_MIPS_TX3900 170 #define VM_MAX_KERNEL_ADDRESS ((vaddr_t)-0x01000000) /* 0xFFFFFFFFFF000000 */ 171 #else 172 #define VM_MAX_KERNEL_ADDRESS ((vaddr_t)-0x00004000) /* 0xFFFFFFFFFFFFC000 */ 173 #endif 174 #endif 175 #define VM_MAXUSER32_ADDRESS ((vaddr_t)(1UL << 31))/* 0x0000000080000000 */ 176 177 /* 178 * The address to which unspecified mapping requests default 179 */ 180 #define __USE_TOPDOWN_VM 181 182 #define VM_DEFAULT_ADDRESS_TOPDOWN(da, sz) \ 183 trunc_page(USRSTACK - MAXSSIZ - (sz)) 184 #define VM_DEFAULT_ADDRESS_BOTTOMUP(da, sz) \ 185 round_page((vaddr_t)(da) + (vsize_t)maxdmap) 186 187 #define VM_DEFAULT_ADDRESS32_TOPDOWN(da, sz) \ 188 trunc_page(USRSTACK32 - MAXSSIZ32 - (sz)) 189 #define VM_DEFAULT_ADDRESS32_BOTTOMUP(da, sz) \ 190 round_page((vaddr_t)(da) + (vsize_t)MAXDSIZ32) 191 192 /* virtual sizes (bytes) for various kernel submaps */ 193 #define VM_PHYS_SIZE (USRIOSIZE*PAGE_SIZE) 194 195 /* VM_PHYSSEG_MAX defined by platform-dependent code. */ 196 #define VM_PHYSSEG_STRAT VM_PSTRAT_BSEARCH 197 #define VM_PHYSSEG_NOADD /* can add RAM after vm_mem_init */ 198 199 #ifndef VM_NFREELIST 200 #define VM_NFREELIST 16 /* 16 distinct memory segments */ 201 #define VM_FREELIST_DEFAULT 0 202 #define VM_FREELIST_MAX 1 203 #endif 204 205 #ifdef _KERNEL 206 #define UVM_KM_VMFREELIST mips_poolpage_vmfreelist 207 extern int mips_poolpage_vmfreelist; 208 #ifdef ENABLE_MIPS_16KB_PAGE 209 extern vaddr_t mips_vm_maxuser_address; 210 #endif 211 #endif 212 213 #endif /* ! _MIPS_VMPARAM_H_ */ 214