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