Get generic kernels to be as forgiving of users with lossy hardware
[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
4c321944 39 * $Id: vmparam.h,v 1.11 1994/01/14 16:24:00 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
4c321944 78#define DFLSSIZ (8UL*1024*1024) /* initial stack size limit */
15637ed4
RG
79#endif
80#ifndef MAXSSIZ
c97b55c1 81#define MAXSSIZ (64UL*1024*1024) /* max stack size */
15637ed4 82#endif
4c321944
DG
83#ifndef SGROWSIZ
84#define SGROWSIZ (128UL*1024) /* amount to grow stack */
85#endif
15637ed4
RG
86
87/*
88 * Default sizes of swap allocation chunks (see dmap.h).
89 * The actual values may be changed in vminit() based on MAXDSIZ.
90 * With MAXDSIZ of 16Mb and NDMAP of 38, dmmax will be 1024.
91 */
92#define DMMIN 32 /* smallest swap allocation */
93#define DMMAX 4096 /* largest potential swap allocation */
94#define DMTEXT 1024 /* swap allocation for text */
95
96/*
97 * Sizes of the system and user portions of the system page table.
98 */
99#define SYSPTSIZE (2*NPTEPG)
100#define USRPTSIZE (2*NPTEPG)
101
37186655
RG
102/*
103 * Size of the Shared Memory Pages page table.
104 */
04595c74 105#ifndef SHMMAXPGS
adc13511 106#define SHMMAXPGS 512 /* XXX until we have more kmap space */
37186655
RG
107#endif
108
15637ed4
RG
109/*
110 * Size of User Raw I/O map
111 */
1d7f5b47 112#define USRIOSIZE 1024
15637ed4
RG
113
114/*
115 * The size of the clock loop.
116 */
117#define LOOPPAGES (maxfree - firstfree)
118
119/*
120 * The time for a process to be blocked before being very swappable.
121 * This is a number of seconds which the system takes as being a non-trivial
122 * amount of real time. You probably shouldn't change this;
123 * it is used in subtle ways (fractions and multiples of it are, that is, like
124 * half of a ``long time'', almost a long time, etc.)
125 * It is related to human patience and other factors which don't really
126 * change over time.
127 */
128#define MAXSLP 20
129
130/*
131 * A swapped in process is given a small amount of core without being bothered
132 * by the page replacement algorithm. Basically this says that if you are
133 * swapped in you deserve some resources. We protect the last SAFERSS
134 * pages against paging and will just swap you out rather than paging you.
135 * Note that each process has at least UPAGES+CLSIZE pages which are not
136 * paged anyways (this is currently 8+2=10 pages or 5k bytes), so this
137 * number just means a swapped in process is given around 25k bytes.
138 * Just for fun: current memory prices are 4600$ a megabyte on VAX (4/22/81),
139 * so we loan each swapped in process memory worth 100$, or just admit
140 * that we don't consider it worthwhile and swap it out to disk which costs
141 * $30/mb or about $0.75.
142 * { wfj 6/16/89: Retail AT memory expansion $800/megabyte, loan of $17
143 * on disk costing $7/mb or $0.18 (in memory still 100:1 in cost!) }
144 */
145#define SAFERSS 8 /* nominal ``small'' resident set size
146 protected against replacement */
147
148/*
149 * DISKRPM is used to estimate the number of paging i/o operations
150 * which one can expect from a single disk controller.
151 */
152#define DISKRPM 60
153
154/*
155 * Klustering constants. Klustering is the gathering
156 * of pages together for pagein/pageout, while clustering
157 * is the treatment of hardware page size as though it were
158 * larger than it really is.
159 *
160 * KLMAX gives maximum cluster size in CLSIZE page (cluster-page)
161 * units. Note that KLMAX*CLSIZE must be <= DMMIN in dmap.h.
162 */
163
164#define KLMAX (4/CLSIZE)
165#define KLSEQL (2/CLSIZE) /* in klust if vadvise(VA_SEQL) */
166#define KLIN (4/CLSIZE) /* default data/stack in klust */
167#define KLTXT (4/CLSIZE) /* default text in klust */
168#define KLOUT (4/CLSIZE)
169
170/*
171 * KLSDIST is the advance or retard of the fifo reclaim for sequential
172 * processes data space.
173 */
174#define KLSDIST 3 /* klusters advance/retard for seq. fifo */
175
176/*
177 * Paging thresholds (see vm_sched.c).
178 * Strategy of 1/19/85:
179 * lotsfree is 512k bytes, but at most 1/4 of memory
180 * desfree is 200k bytes, but at most 1/8 of memory
181 * minfree is 64k bytes, but at most 1/2 of desfree
182 */
183#define LOTSFREE (512 * 1024)
184#define LOTSFREEFRACT 4
185#define DESFREE (200 * 1024)
186#define DESFREEFRACT 8
187#define MINFREE (64 * 1024)
188#define MINFREEFRACT 2
189
190/*
191 * There are two clock hands, initially separated by HANDSPREAD bytes
192 * (but at most all of user memory). The amount of time to reclaim
193 * a page once the pageout process examines it increases with this
194 * distance and decreases as the scan rate rises.
195 */
196#define HANDSPREAD (2 * 1024 * 1024)
197
198/*
199 * The number of times per second to recompute the desired paging rate
200 * and poke the pagedaemon.
201 */
202#define RATETOSCHEDPAGING 4
203
204/*
205 * Believed threshold (in megabytes) for which interleaved
206 * swapping area is desirable.
207 */
208#define LOTSOFMEM 2
209
210#define mapin(pte, v, pfnum, prot) \
211 {(*(int *)(pte) = ((pfnum)<<PGSHIFT) | (prot)) ; }
212
213/*
214 * Mach derived constants
215 */
216
217/* user/kernel map constants */
1d7f5b47
DG
218#define KERNBASE (0-(NKPDE+1)*(NBPG*NPTEPG))
219#define KERNSIZE (NKPDE*NBPG*NPTEPG)
220
15637ed4 221#define VM_MIN_ADDRESS ((vm_offset_t)0)
1d7f5b47
DG
222#define VM_MAXUSER_ADDRESS ((vm_offset_t)KERNBASE - (NBPG*(NPTEPG+UPAGES)))
223#define USRSTACK VM_MAXUSER_ADDRESS
224#define UPT_MIN_ADDRESS ((vm_offset_t)KERNBASE - (NBPG*NPTEPG))
225#define UPT_MAX_ADDRESS ((vm_offset_t)KERNBASE - (NBPG*(NKPDE+2)))
15637ed4 226#define VM_MAX_ADDRESS UPT_MAX_ADDRESS
1d7f5b47 227#define VM_MIN_KERNEL_ADDRESS ((vm_offset_t)KERNBASE - (NBPG*(NKPDE+2)))
15637ed4 228#define UPDT VM_MIN_KERNEL_ADDRESS
1d7f5b47
DG
229#define KPT_MIN_ADDRESS ((vm_offset_t)(KERNBASE) - (NBPG*(NKPDE+1)))
230#define KPT_MAX_ADDRESS ((vm_offset_t)(KERNBASE) - NBPG)
231#define VM_MAX_KERNEL_ADDRESS ((vm_offset_t)ALT_MIN_ADDRESS - NBPG)
232#define ALT_MIN_ADDRESS ((vm_offset_t)((APTDPTDI) << 22))
233#define HIGHPAGES UPAGES
234
15637ed4
RG
235
236/* virtual sizes (bytes) for various kernel submaps */
237#define VM_MBUF_SIZE (NMBCLUSTERS*MCLBYTES)
adc13511 238#define VM_KMEM_SIZE (16 * 1024 * 1024)
15637ed4
RG
239#define VM_PHYS_SIZE (USRIOSIZE*CLBYTES)
240
15637ed4
RG
241/* pcb base */
242#define pcbb(p) ((u_int)(p)->p_addr)
243
244/*
245 * Flush MMU TLB
246 */
247
248#ifndef I386_CR3PAT
249#define I386_CR3PAT 0x0
250#endif
251
252#ifdef notyet
253#define _cr3() ({u_long rtn; \
254 asm (" movl %%cr3,%%eax; movl %%eax,%0 " \
255 : "=g" (rtn) \
256 : \
257 : "ax"); \
258 rtn; \
259})
260
261#define load_cr3(s) ({ u_long val; \
262 val = (s) | I386_CR3PAT; \
263 asm ("movl %0,%%eax; movl %%eax,%%cr3" \
264 : \
265 : "g" (val) \
266 : "ax"); \
267})
268
269#define tlbflush() ({ u_long val; \
270 val = u.u_pcb.pcb_ptd | I386_CR3PAT; \
271 asm ("movl %0,%%eax; movl %%eax,%%cr3" \
272 : \
273 : "g" (val) \
274 : "ax"); \
275})
276#endif
126bd309 277#endif /* _MACHINE_VMPARAM_H_ */