Home | History | Annotate | Line # | Download | only in include
vmparam.h revision 1.56
      1 /*	$NetBSD: vmparam.h,v 1.56 2016/11/04 08:24:36 skrll 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_8KB_PAGE) \
     65     || (!defined(ENABLE_MIPS_4KB_PAGE) && __mips >= 3)
     66 #define	PAGE_SHIFT	13
     67 #else /* defined(ENABLE_MIPS_4KB_PAGE) */
     68 #define	PAGE_SHIFT	12
     69 #endif
     70 #define	PAGE_SIZE	(1 << PAGE_SHIFT)
     71 #define	PAGE_MASK	(PAGE_SIZE - 1)
     72 
     73 /*
     74  * USRSTACK is the top (end) of the user stack.
     75  *
     76  * USRSTACK needs to start a little below 0x8000000 because the R8000
     77  * and some QED CPUs perform some virtual address checks before the
     78  * offset is calculated.  We use 0x8000 since that's the max displacement
     79  * in an instruction.
     80  */
     81 #define	USRSTACK	(VM_MAXUSER_ADDRESS-0x8000) /* Start of user stack */
     82 #define	USRSTACK32	((uint32_t)VM_MAXUSER32_ADDRESS-0x8000)
     83 
     84 /*
     85  * Virtual memory related constants, all in bytes
     86  */
     87 #if defined(__mips_o32)
     88 #ifndef MAXTSIZ
     89 #define	MAXTSIZ		(64*1024*1024)		/* max text size */
     90 #endif
     91 #ifndef DFLDSIZ
     92 #define	DFLDSIZ		(128*1024*1024)		/* initial data size limit */
     93 #endif
     94 #ifndef MAXDSIZ
     95 #define	MAXDSIZ		(512*1024*1024)		/* max data size */
     96 #endif
     97 #ifndef	DFLSSIZ
     98 #define	DFLSSIZ		(4*1024*1024)		/* initial stack size limit */
     99 #endif
    100 #ifndef	MAXSSIZ
    101 #define	MAXSSIZ		(32*1024*1024)		/* max stack size */
    102 #endif
    103 #else
    104 /*
    105  * 64-bit ABIs need more space.
    106  */
    107 #ifndef MAXTSIZ
    108 #define	MAXTSIZ		(128*1024*1024)		/* max text size */
    109 #endif
    110 #ifndef DFLDSIZ
    111 #define	DFLDSIZ		(256*1024*1024)		/* initial data size limit */
    112 #endif
    113 #ifndef MAXDSIZ
    114 #define	MAXDSIZ		(1536*1024*1024)	/* max data size */
    115 #endif
    116 #ifndef	DFLSSIZ
    117 #define	DFLSSIZ		(16*1024*1024)		/* initial stack size limit */
    118 #endif
    119 #ifndef	MAXSSIZ
    120 #define	MAXSSIZ		(120*1024*1024)		/* max stack size */
    121 #endif
    122 #endif /* !__mips_o32 */
    123 
    124 /*
    125  * Virtual memory related constants, all in bytes
    126  */
    127 #ifndef MAXTSIZ32
    128 #define	MAXTSIZ32	MAXTSIZ			/* max text size */
    129 #endif
    130 #ifndef DFLDSIZ32
    131 #define	DFLDSIZ32	DFLDSIZ			/* initial data size limit */
    132 #endif
    133 #ifndef MAXDSIZ32
    134 #define	MAXDSIZ32	MAXDSIZ			/* max data size */
    135 #endif
    136 #ifndef	DFLSSIZ32
    137 #define	DFLSSIZ32	DFLTSIZ			/* initial stack size limit */
    138 #endif
    139 #ifndef	MAXSSIZ32
    140 #define	MAXSSIZ32	MAXSSIZ			/* max stack size */
    141 #endif
    142 
    143 /*
    144  * PTEs for mapping user space into the kernel for phyio operations.
    145  * The default PTE number is enough to cover 8 disks * MAXBSIZE.
    146  */
    147 #ifndef USRIOSIZE
    148 #define USRIOSIZE	(MAXBSIZE/PAGE_SIZE * 8)
    149 #endif
    150 
    151 /*
    152  * Mach derived constants
    153  */
    154 
    155 /*
    156  * user/kernel map constants
    157  * These are negative addresses since MIPS addresses are signed.
    158  */
    159 #define VM_MIN_ADDRESS		((vaddr_t)0x00000000)
    160 #ifdef _LP64
    161 #define MIPS_VM_MAXUSER_ADDRESS	((vaddr_t) 1L << (4*PGSHIFT-8))
    162 #ifdef ENABLE_MIPS_16KB_PAGE
    163 #define VM_MAXUSER_ADDRESS	mips_vm_maxuser_address
    164 #else
    165 #define VM_MAXUSER_ADDRESS	MIPS_VM_MAXUSER_ADDRESS
    166 #endif
    167 #define VM_MAX_ADDRESS		VM_MAXUSER_ADDRESS	/* 0x0000010000000000 */
    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