vmparam.h revision 879
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * William Jolitz.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in the
15 *    documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 *    must display the following acknowledgement:
18 *	This product includes software developed by the University of
19 *	California, Berkeley and its contributors.
20 * 4. 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: @(#)vmparam.h	5.9 (Berkeley) 5/12/91
37 *	$Id: vmparam.h,v 1.8 1993/11/07 17:43:17 wollman Exp $
38 */
39
40
41#ifndef _MACHINE_VMPARAM_H_
42#define _MACHINE_VMPARAM_H_ 1
43
44/*
45 * Machine dependent constants for 386.
46 */
47
48/*
49 * Virtual address space arrangement. On 386, both user and kernel
50 * share the address space, not unlike the vax.
51 * USRTEXT is the start of the user text/data space, while USRSTACK
52 * is the top (end) of the user stack. Immediately above the user stack
53 * resides the user structure, which is UPAGES long and contains the
54 * kernel stack.
55 *
56 * Immediately after the user structure is the page table map, and then
57 * kernal address space.
58 */
59#define	USRTEXT		0UL
60#define	USRSTACK	0xFDBFE000UL
61#define	BTOPUSRSTACK	(0xFDC00-(UPAGES))	/* btop(USRSTACK) */
62#define	LOWPAGES	0UL
63#define HIGHPAGES	UPAGES
64
65/*
66 * Virtual memory related constants, all in bytes
67 */
68#define	MAXTSIZ		(6UL*1024*1024)		/* max text size */
69#ifndef DFLDSIZ
70#define	DFLDSIZ		(16UL*1024*1024) /* initial data size limit */
71#endif
72#ifndef MAXDSIZ
73#define	MAXDSIZ		(32UL*1024*1024)		/* max data size */
74#endif
75#ifndef	DFLSSIZ
76#define	DFLSSIZ		(512UL*1024)		/* initial stack size limit */
77#endif
78#ifndef	MAXSSIZ
79#define	MAXSSIZ		(8UL*1024*1024)		/* max stack size */
80#endif
81
82/*
83 * Default sizes of swap allocation chunks (see dmap.h).
84 * The actual values may be changed in vminit() based on MAXDSIZ.
85 * With MAXDSIZ of 16Mb and NDMAP of 38, dmmax will be 1024.
86 */
87#define	DMMIN	32			/* smallest swap allocation */
88#define	DMMAX	4096			/* largest potential swap allocation */
89#define	DMTEXT	1024			/* swap allocation for text */
90
91/*
92 * Sizes of the system and user portions of the system page table.
93 */
94#define	SYSPTSIZE 	(2*NPTEPG)
95#define	USRPTSIZE 	(2*NPTEPG)
96
97/*
98 * Size of the Shared Memory Pages page table.
99 */
100#ifndef	SHMMAXPGS
101#define	SHMMAXPGS	512		/* XXX until we have more kmap space */
102#endif
103
104/*
105 * Size of User Raw I/O map
106 */
107#define	USRIOSIZE 	300
108
109/*
110 * The size of the clock loop.
111 */
112#define	LOOPPAGES	(maxfree - firstfree)
113
114/*
115 * The time for a process to be blocked before being very swappable.
116 * This is a number of seconds which the system takes as being a non-trivial
117 * amount of real time.  You probably shouldn't change this;
118 * it is used in subtle ways (fractions and multiples of it are, that is, like
119 * half of a ``long time'', almost a long time, etc.)
120 * It is related to human patience and other factors which don't really
121 * change over time.
122 */
123#define	MAXSLP 		20
124
125/*
126 * A swapped in process is given a small amount of core without being bothered
127 * by the page replacement algorithm.  Basically this says that if you are
128 * swapped in you deserve some resources.  We protect the last SAFERSS
129 * pages against paging and will just swap you out rather than paging you.
130 * Note that each process has at least UPAGES+CLSIZE pages which are not
131 * paged anyways (this is currently 8+2=10 pages or 5k bytes), so this
132 * number just means a swapped in process is given around 25k bytes.
133 * Just for fun: current memory prices are 4600$ a megabyte on VAX (4/22/81),
134 * so we loan each swapped in process memory worth 100$, or just admit
135 * that we don't consider it worthwhile and swap it out to disk which costs
136 * $30/mb or about $0.75.
137 * { wfj 6/16/89: Retail AT memory expansion $800/megabyte, loan of $17
138 *   on disk costing $7/mb or $0.18 (in memory still 100:1 in cost!) }
139 */
140#define	SAFERSS		8		/* nominal ``small'' resident set size
141					   protected against replacement */
142
143/*
144 * DISKRPM is used to estimate the number of paging i/o operations
145 * which one can expect from a single disk controller.
146 */
147#define	DISKRPM		60
148
149/*
150 * Klustering constants.  Klustering is the gathering
151 * of pages together for pagein/pageout, while clustering
152 * is the treatment of hardware page size as though it were
153 * larger than it really is.
154 *
155 * KLMAX gives maximum cluster size in CLSIZE page (cluster-page)
156 * units.  Note that KLMAX*CLSIZE must be <= DMMIN in dmap.h.
157 */
158
159#define	KLMAX	(4/CLSIZE)
160#define	KLSEQL	(2/CLSIZE)		/* in klust if vadvise(VA_SEQL) */
161#define	KLIN	(4/CLSIZE)		/* default data/stack in klust */
162#define	KLTXT	(4/CLSIZE)		/* default text in klust */
163#define	KLOUT	(4/CLSIZE)
164
165/*
166 * KLSDIST is the advance or retard of the fifo reclaim for sequential
167 * processes data space.
168 */
169#define	KLSDIST	3		/* klusters advance/retard for seq. fifo */
170
171/*
172 * Paging thresholds (see vm_sched.c).
173 * Strategy of 1/19/85:
174 *	lotsfree is 512k bytes, but at most 1/4 of memory
175 *	desfree is 200k bytes, but at most 1/8 of memory
176 *	minfree is 64k bytes, but at most 1/2 of desfree
177 */
178#define	LOTSFREE	(512 * 1024)
179#define	LOTSFREEFRACT	4
180#define	DESFREE		(200 * 1024)
181#define	DESFREEFRACT	8
182#define	MINFREE		(64 * 1024)
183#define	MINFREEFRACT	2
184
185/*
186 * There are two clock hands, initially separated by HANDSPREAD bytes
187 * (but at most all of user memory).  The amount of time to reclaim
188 * a page once the pageout process examines it increases with this
189 * distance and decreases as the scan rate rises.
190 */
191#define	HANDSPREAD	(2 * 1024 * 1024)
192
193/*
194 * The number of times per second to recompute the desired paging rate
195 * and poke the pagedaemon.
196 */
197#define	RATETOSCHEDPAGING	4
198
199/*
200 * Believed threshold (in megabytes) for which interleaved
201 * swapping area is desirable.
202 */
203#define	LOTSOFMEM	2
204
205#define	mapin(pte, v, pfnum, prot) \
206	{(*(int *)(pte) = ((pfnum)<<PGSHIFT) | (prot)) ; }
207
208/*
209 * Mach derived constants
210 */
211
212/* user/kernel map constants */
213#define VM_MIN_ADDRESS		((vm_offset_t)0)
214#define VM_MAXUSER_ADDRESS	((vm_offset_t)0xFDBFE000UL)
215#define UPT_MIN_ADDRESS		((vm_offset_t)0xFDC00000UL)
216#define UPT_MAX_ADDRESS		((vm_offset_t)0xFDFF7000UL)
217#define VM_MAX_ADDRESS		UPT_MAX_ADDRESS
218#define VM_MIN_KERNEL_ADDRESS	((vm_offset_t)0xFDFF7000UL)
219#define UPDT			VM_MIN_KERNEL_ADDRESS
220#define KPT_MIN_ADDRESS		((vm_offset_t)0xFDFF8000UL)
221#define KPT_MAX_ADDRESS		((vm_offset_t)0xFDFFF000UL)
222#define VM_MAX_KERNEL_ADDRESS	((vm_offset_t)0xFF7FF000UL)
223
224/* virtual sizes (bytes) for various kernel submaps */
225#define VM_MBUF_SIZE		(NMBCLUSTERS*MCLBYTES)
226#define VM_KMEM_SIZE		(16 * 1024 * 1024)
227#define VM_PHYS_SIZE		(USRIOSIZE*CLBYTES)
228
229/* pcb base */
230#define	pcbb(p)		((u_int)(p)->p_addr)
231
232/*
233 * Flush MMU TLB
234 */
235
236#ifndef I386_CR3PAT
237#define	I386_CR3PAT	0x0
238#endif
239
240#ifdef notyet
241#define _cr3() ({u_long rtn; \
242	asm (" movl %%cr3,%%eax; movl %%eax,%0 " \
243		: "=g" (rtn) \
244		: \
245		: "ax"); \
246	rtn; \
247})
248
249#define load_cr3(s) ({ u_long val; \
250	val = (s) | I386_CR3PAT; \
251	asm ("movl %0,%%eax; movl %%eax,%%cr3" \
252		:  \
253		: "g" (val) \
254		: "ax"); \
255})
256
257#define tlbflush() ({ u_long val; \
258	val = u.u_pcb.pcb_ptd | I386_CR3PAT; \
259	asm ("movl %0,%%eax; movl %%eax,%%cr3" \
260		:  \
261		: "g" (val) \
262		: "ax"); \
263})
264#endif
265#endif /* _MACHINE_VMPARAM_H_ */
266