| 1 | /*	$NetBSD: vmparam.h,v 1.67 2023/05/14 18:44:27 he 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 | |
| 54 | /* |
| 55 | * We normally use a 4K page but may use 16K on MIPS systems. |
| 56 | * Override PAGE_* definitions to compile-time constants. |
| 57 | */ |
| 58 | #ifdef ENABLE_MIPS_16KB_PAGE |
| 59 | #define	PAGE_SHIFT	14 |
| 60 | #elif defined(ENABLE_MIPS_8KB_PAGE) \ |
| 61 | || (!defined(ENABLE_MIPS_4KB_PAGE) && __mips >= 3) |
| 62 | #define	PAGE_SHIFT	13 |
| 63 | #else /* defined(ENABLE_MIPS_4KB_PAGE) */ |
| 64 | #define	PAGE_SHIFT	12 |
| 65 | #endif |
| 66 | #define	PAGE_SIZE	(1 << PAGE_SHIFT) |
| 67 | #define	PAGE_MASK	(PAGE_SIZE - 1) |
| 68 | |
| 69 | #define	MIN_PAGE_SHIFT	12 |
| 70 | #define	MAX_PAGE_SHIFT	14 |
| 71 | |
| 72 | #define	MAX_PAGE_SIZE	(1 << MAX_PAGE_SHIFT) |
| 73 | #define	MIN_PAGE_SIZE	(1 << MIN_PAGE_SHIFT) |
| 74 | |
| 75 | /* |
| 76 | * USRSTACK is the top (end) of the user stack. |
| 77 | * |
| 78 | * USRSTACK needs to start a little below 0x8000000 because the R8000 |
| 79 | * and some QED CPUs perform some virtual address checks before the |
| 80 | * offset is calculated. We use 0x8000 since that's the max displacement |
| 81 | * in an instruction. |
| 82 | */ |
| 83 | #define	USRSTACK	(VM_MAXUSER_ADDRESS-0x8000) /* Start of user stack */ |
| 84 | #define	USRSTACK32	((uint32_t)VM_MAXUSER_ADDRESS32-0x8000) |
| 85 | |
| 86 | /* |
| 87 | * Virtual memory related constants, all in bytes |
| 88 | */ |
| 89 | #if defined(__mips_o32) |
| 90 | #ifndef MAXTSIZ |
| 91 | #define	MAXTSIZ		(128*1024*1024)		/* max text size */ |
| 92 | #endif |
| 93 | #ifndef DFLDSIZ |
| 94 | #define	DFLDSIZ		(128*1024*1024)		/* initial data size limit */ |
| 95 | #endif |
| 96 | #ifndef MAXDSIZ |
| 97 | #define	MAXDSIZ		(512*1024*1024)		/* max data size */ |
| 98 | #endif |
| 99 | #ifndef	DFLSSIZ |
| 100 | #define	DFLSSIZ		(4*1024*1024)		/* initial stack size limit */ |
| 101 | #endif |
| 102 | #ifndef	MAXSSIZ |
| 103 | #define	MAXSSIZ		(32*1024*1024)		/* max stack size */ |
| 104 | #endif |
| 105 | #else |
| 106 | /* |
| 107 | * 64-bit ABIs need more space. |
| 108 | */ |
| 109 | #ifndef MAXTSIZ |
| 110 | #define	MAXTSIZ		(128*1024*1024)		/* max text size */ |
| 111 | #endif |
| 112 | #ifndef DFLDSIZ |
| 113 | #define	DFLDSIZ		(256*1024*1024)		/* initial data size limit */ |
| 114 | #endif |
| 115 | #ifndef MAXDSIZ |
| 116 | #define	MAXDSIZ		(1536*1024*1024)	/* max data size */ |
| 117 | #endif |
| 118 | #ifndef	DFLSSIZ |
| 119 | #define	DFLSSIZ		(4*1024*1024)		/* initial stack size limit */ |
| 120 | #endif |
| 121 | #ifndef	MAXSSIZ |
| 122 | #define	MAXSSIZ		(120*1024*1024)		/* max stack size */ |
| 123 | #endif |
| 124 | #endif /* !__mips_o32 */ |
| 125 | |
| 126 | /* |
| 127 | * Virtual memory related constants, all in bytes |
| 128 | */ |
| 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 << 40) |
| 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 | #define	VM_MAX_ADDRESS		VM_MAXUSER_ADDRESS	/* 0x0000010000000000 */ |
| 167 | #define	VM_MIN_KERNEL_ADDRESS	((vaddr_t) 3L << 62)	/* 0xC000000000000000 */ |
| 168 | #define	VM_MAX_KERNEL_ADDRESS	((vaddr_t) -1L << 31)	/* 0xFFFFFFFF80000000 */ |
| 169 | #else |
| 170 | #define	VM_MAXUSER_ADDRESS	((vaddr_t)-0x7fffffff-1)/* 0xFFFFFFFF80000000 */ |
| 171 | #define	VM_MAX_ADDRESS		((vaddr_t)-0x7fffffff-1)/* 0xFFFFFFFF80000000 */ |
| 172 | #define	VM_MIN_KERNEL_ADDRESS	((vaddr_t)-0x40000000)	/* 0xFFFFFFFFC0000000 */ |
| 173 | #ifdef ENABLE_MIPS_TX3900 |
| 174 | #define	VM_MAX_KERNEL_ADDRESS	((vaddr_t)-0x01000000)	/* 0xFFFFFFFFFF000000 */ |
| 175 | #else |
| 176 | #define	VM_MAX_KERNEL_ADDRESS	((vaddr_t)-0x00004000)	/* 0xFFFFFFFFFFFFC000 */ |
| 177 | #endif |
| 178 | #endif |
| 179 | #define	VM_MAXUSER_ADDRESS32	((vaddr_t)(1UL << 31))	/* 0x0000000080000000 */ |
| 180 | |
| 181 | /* |
| 182 | * The address to which unspecified mapping requests default |
| 183 | */ |
| 184 | #define	__USE_TOPDOWN_VM |
| 185 | |
| 186 | #define	VM_DEFAULT_ADDRESS_TOPDOWN(da, sz) \ |
| 187 | trunc_page(USRSTACK - MAXSSIZ - (sz) - user_stack_guard_size) |
| 188 | #define	VM_DEFAULT_ADDRESS_BOTTOMUP(da, sz) \ |
| 189 | round_page((vaddr_t)(da) + (vsize_t)maxdmap) |
| 190 | |
| 191 | #define	VM_DEFAULT_ADDRESS32_TOPDOWN(da, sz) \ |
| 192 | trunc_page(USRSTACK32 - MAXSSIZ32 - (sz) - user_stack_guard_size) |
| 193 | #define	VM_DEFAULT_ADDRESS32_BOTTOMUP(da, sz) \ |
| 194 | round_page((vaddr_t)(da) + (vsize_t)MAXDSIZ32) |
| 195 | |
| 196 | /* virtual sizes (bytes) for various kernel submaps */ |
| 197 | #define	VM_PHYS_SIZE		(USRIOSIZE*PAGE_SIZE) |
| 198 | |
| 199 | /* VM_PHYSSEG_MAX defined by platform-dependent code. */ |
| 200 | #define	VM_PHYSSEG_STRAT	VM_PSTRAT_BSEARCH |
| 201 | |
| 202 | #ifndef VM_NFREELIST |
| 203 | #define	VM_NFREELIST		16	/* 16 distinct memory segments */ |
| 204 | #define	VM_FREELIST_DEFAULT	0 |
| 205 | #define	VM_FREELIST_MAX		1 |
| 206 | #endif |
| 207 | |
| 208 | #ifdef _KERNEL |
| 209 | #ifdef ENABLE_MIPS_16KB_PAGE |
| 210 | extern vaddr_t mips_vm_maxuser_address; |
| 211 | #endif |
| 212 | #endif |
| 213 | |
| 214 | #endif /* ! _MIPS_VMPARAM_H_ */ |