xref: /csrg-svn/sys/i386/include/vmparam.h (revision 67059)
141062Swilliam /*-
263359Sbostic  * Copyright (c) 1990, 1993
363359Sbostic  *	The Regents of the University of California.  All rights reserved.
441062Swilliam  *
541062Swilliam  * This code is derived from software contributed to Berkeley by
641062Swilliam  * William Jolitz.
741062Swilliam  *
846006Swilliam  * %sccs.include.redist.c%
941062Swilliam  *
10*67059Smckusick  *	@(#)vmparam.h	8.2 (Berkeley) 04/22/94
1141062Swilliam  */
1241062Swilliam 
1345964Swilliam 
1441062Swilliam /*
1541062Swilliam  * Machine dependent constants for 386.
1641062Swilliam  */
1741062Swilliam 
1841062Swilliam /*
1941062Swilliam  * Virtual address space arrangement. On 386, both user and kernel
2045964Swilliam  * share the address space, not unlike the vax.
2141062Swilliam  * USRTEXT is the start of the user text/data space, while USRSTACK
2241062Swilliam  * is the top (end) of the user stack. Immediately above the user stack
2341062Swilliam  * resides the user structure, which is UPAGES long and contains the
2449523Swilliam  * kernel stack.
2549523Swilliam  *
2649523Swilliam  * Immediately after the user structure is the page table map, and then
2749523Swilliam  * kernal address space.
2841062Swilliam  */
2941062Swilliam #define	USRTEXT		0
3049693Swilliam #define	USRSTACK	0xFDBFE000
3148000Swilliam #define	BTOPUSRSTACK	(0xFDC00-(UPAGES))	/* btop(USRSTACK) */
3241062Swilliam #define	LOWPAGES	0
3341062Swilliam #define HIGHPAGES	UPAGES
3441062Swilliam 
3541062Swilliam /*
3641062Swilliam  * Virtual memory related constants, all in bytes
3741062Swilliam  */
3841062Swilliam #define	MAXTSIZ		(6*1024*1024)		/* max text size */
3941062Swilliam #ifndef DFLDSIZ
4041062Swilliam #define	DFLDSIZ		(6*1024*1024)		/* initial data size limit */
4141062Swilliam #endif
4241062Swilliam #ifndef MAXDSIZ
4341062Swilliam #define	MAXDSIZ		(32*1024*1024)		/* max data size */
4441062Swilliam #endif
4541062Swilliam #ifndef	DFLSSIZ
4641062Swilliam #define	DFLSSIZ		(512*1024)		/* initial stack size limit */
4741062Swilliam #endif
4841062Swilliam #ifndef	MAXSSIZ
4941062Swilliam #define	MAXSSIZ		MAXDSIZ			/* max stack size */
5041062Swilliam #endif
5141062Swilliam 
5241062Swilliam /*
5341062Swilliam  * Default sizes of swap allocation chunks (see dmap.h).
5441062Swilliam  * The actual values may be changed in vminit() based on MAXDSIZ.
5541062Swilliam  * With MAXDSIZ of 16Mb and NDMAP of 38, dmmax will be 1024.
5641062Swilliam  */
5741062Swilliam #define	DMMIN	32			/* smallest swap allocation */
5841062Swilliam #define	DMMAX	4096			/* largest potential swap allocation */
5941062Swilliam #define	DMTEXT	1024			/* swap allocation for text */
6041062Swilliam 
6141062Swilliam /*
6241062Swilliam  * Sizes of the system and user portions of the system page table.
6341062Swilliam  */
6441062Swilliam #define	SYSPTSIZE 	(2*NPTEPG)
6541062Swilliam #define	USRPTSIZE 	(2*NPTEPG)
6641062Swilliam 
6741062Swilliam /*
6845593Sbill  * Size of User Raw I/O map
6945593Sbill  */
7045964Swilliam #define	USRIOSIZE 	300
7145593Sbill 
7245593Sbill /*
7341062Swilliam  * The size of the clock loop.
7441062Swilliam  */
7541062Swilliam #define	LOOPPAGES	(maxfree - firstfree)
7641062Swilliam 
7741062Swilliam /*
7841062Swilliam  * The time for a process to be blocked before being very swappable.
7941062Swilliam  * This is a number of seconds which the system takes as being a non-trivial
8041062Swilliam  * amount of real time.  You probably shouldn't change this;
8141062Swilliam  * it is used in subtle ways (fractions and multiples of it are, that is, like
8241062Swilliam  * half of a ``long time'', almost a long time, etc.)
8341062Swilliam  * It is related to human patience and other factors which don't really
8441062Swilliam  * change over time.
8541062Swilliam  */
8641062Swilliam #define	MAXSLP 		20
8741062Swilliam 
8841062Swilliam /*
8941062Swilliam  * A swapped in process is given a small amount of core without being bothered
9041062Swilliam  * by the page replacement algorithm.  Basically this says that if you are
9141062Swilliam  * swapped in you deserve some resources.  We protect the last SAFERSS
9241062Swilliam  * pages against paging and will just swap you out rather than paging you.
9341062Swilliam  * Note that each process has at least UPAGES+CLSIZE pages which are not
9441062Swilliam  * paged anyways (this is currently 8+2=10 pages or 5k bytes), so this
9541062Swilliam  * number just means a swapped in process is given around 25k bytes.
9641062Swilliam  * Just for fun: current memory prices are 4600$ a megabyte on VAX (4/22/81),
9741062Swilliam  * so we loan each swapped in process memory worth 100$, or just admit
9841062Swilliam  * that we don't consider it worthwhile and swap it out to disk which costs
9941062Swilliam  * $30/mb or about $0.75.
10041062Swilliam  * { wfj 6/16/89: Retail AT memory expansion $800/megabyte, loan of $17
10141062Swilliam  *   on disk costing $7/mb or $0.18 (in memory still 100:1 in cost!) }
10241062Swilliam  */
10345593Sbill #define	SAFERSS		8		/* nominal ``small'' resident set size
10441062Swilliam 					   protected against replacement */
10541062Swilliam 
10641062Swilliam /*
10741062Swilliam  * DISKRPM is used to estimate the number of paging i/o operations
10841062Swilliam  * which one can expect from a single disk controller.
10941062Swilliam  */
11041062Swilliam #define	DISKRPM		60
11141062Swilliam 
11241062Swilliam /*
11341062Swilliam  * Klustering constants.  Klustering is the gathering
11441062Swilliam  * of pages together for pagein/pageout, while clustering
11541062Swilliam  * is the treatment of hardware page size as though it were
11641062Swilliam  * larger than it really is.
11741062Swilliam  *
11841062Swilliam  * KLMAX gives maximum cluster size in CLSIZE page (cluster-page)
11941062Swilliam  * units.  Note that KLMAX*CLSIZE must be <= DMMIN in dmap.h.
12041062Swilliam  */
12141062Swilliam 
12241062Swilliam #define	KLMAX	(4/CLSIZE)
12341062Swilliam #define	KLSEQL	(2/CLSIZE)		/* in klust if vadvise(VA_SEQL) */
12441062Swilliam #define	KLIN	(4/CLSIZE)		/* default data/stack in klust */
12541062Swilliam #define	KLTXT	(4/CLSIZE)		/* default text in klust */
12641062Swilliam #define	KLOUT	(4/CLSIZE)
12741062Swilliam 
12841062Swilliam /*
12941062Swilliam  * KLSDIST is the advance or retard of the fifo reclaim for sequential
13041062Swilliam  * processes data space.
13141062Swilliam  */
13241062Swilliam #define	KLSDIST	3		/* klusters advance/retard for seq. fifo */
13341062Swilliam 
13441062Swilliam /*
13541062Swilliam  * Paging thresholds (see vm_sched.c).
13641062Swilliam  * Strategy of 1/19/85:
13741062Swilliam  *	lotsfree is 512k bytes, but at most 1/4 of memory
13841062Swilliam  *	desfree is 200k bytes, but at most 1/8 of memory
13941062Swilliam  */
14041062Swilliam #define	LOTSFREE	(512 * 1024)
14141062Swilliam #define	LOTSFREEFRACT	4
14241062Swilliam #define	DESFREE		(200 * 1024)
14341062Swilliam #define	DESFREEFRACT	8
14441062Swilliam 
14541062Swilliam /*
14641062Swilliam  * There are two clock hands, initially separated by HANDSPREAD bytes
14741062Swilliam  * (but at most all of user memory).  The amount of time to reclaim
14841062Swilliam  * a page once the pageout process examines it increases with this
14941062Swilliam  * distance and decreases as the scan rate rises.
15041062Swilliam  */
15141062Swilliam #define	HANDSPREAD	(2 * 1024 * 1024)
15241062Swilliam 
15341062Swilliam /*
15441062Swilliam  * The number of times per second to recompute the desired paging rate
15541062Swilliam  * and poke the pagedaemon.
15641062Swilliam  */
15741062Swilliam #define	RATETOSCHEDPAGING	4
15841062Swilliam 
15941062Swilliam /*
16041062Swilliam  * Believed threshold (in megabytes) for which interleaved
16141062Swilliam  * swapping area is desirable.
16241062Swilliam  */
16341062Swilliam #define	LOTSOFMEM	2
16441062Swilliam 
16541062Swilliam #define	mapin(pte, v, pfnum, prot) \
16645964Swilliam 	{(*(int *)(pte) = ((pfnum)<<PGSHIFT) | (prot)) ; }
16741062Swilliam 
16841062Swilliam /*
16947996Swilliam  * Mach derived constants
17041062Swilliam  */
17145593Sbill 
17247996Swilliam /* user/kernel map constants */
17347996Swilliam #define VM_MIN_ADDRESS		((vm_offset_t)0)
17449523Swilliam #define VM_MAXUSER_ADDRESS	((vm_offset_t)0xFDBFD000)
17548000Swilliam #define UPT_MIN_ADDRESS		((vm_offset_t)0xFDC00000)
17648000Swilliam #define UPT_MAX_ADDRESS		((vm_offset_t)0xFDFF7000)
17748000Swilliam #define VM_MAX_ADDRESS		UPT_MAX_ADDRESS
17848000Swilliam #define VM_MIN_KERNEL_ADDRESS	((vm_offset_t)0xFDFF7000)
17948000Swilliam #define UPDT			VM_MIN_KERNEL_ADDRESS
18048000Swilliam #define KPT_MIN_ADDRESS		((vm_offset_t)0xFDFF8000)
18148000Swilliam #define KPT_MAX_ADDRESS		((vm_offset_t)0xFDFFF000)
18248000Swilliam #define VM_MAX_KERNEL_ADDRESS	((vm_offset_t)0xFF7FF000)
18347996Swilliam 
18447996Swilliam /* virtual sizes (bytes) for various kernel submaps */
18547996Swilliam #define VM_MBUF_SIZE		(NMBCLUSTERS*MCLBYTES)
18647996Swilliam #define VM_KMEM_SIZE		(NKMEMCLUSTERS*CLBYTES)
18747996Swilliam #define VM_PHYS_SIZE		(USRIOSIZE*CLBYTES)
18847996Swilliam 
18947996Swilliam /* # of kernel PT pages (initial only, can grow dynamically) */
19047996Swilliam #define VM_KERNEL_PT_PAGES	((vm_size_t)2)		/* XXX: SYSPTSIZE */
19147996Swilliam 
19247996Swilliam /* pcb base */
19347996Swilliam #define	pcbb(p)		((u_int)(p)->p_addr)
19447996Swilliam 
19545593Sbill /*
19645593Sbill  * Flush MMU TLB
19745593Sbill  */
19845593Sbill 
19945623Sbill #ifndef I386_CR3PAT
20045623Sbill #define	I386_CR3PAT	0x0
20145623Sbill #endif
20245623Sbill 
20348000Swilliam #ifdef notyet
20445623Sbill #define _cr3() ({u_long rtn; \
20545623Sbill 	asm (" movl %%cr3,%%eax; movl %%eax,%0 " \
20645623Sbill 		: "=g" (rtn) \
20745623Sbill 		: \
20845623Sbill 		: "ax"); \
20945623Sbill 	rtn; \
21045623Sbill })
21145623Sbill 
21245623Sbill #define load_cr3(s) ({ u_long val; \
21345623Sbill 	val = (s) | I386_CR3PAT; \
21445623Sbill 	asm ("movl %0,%%eax; movl %%eax,%%cr3" \
21545623Sbill 		:  \
21645623Sbill 		: "g" (val) \
21745623Sbill 		: "ax"); \
21845623Sbill })
21945964Swilliam 
22045964Swilliam #define tlbflush() ({ u_long val; \
22145964Swilliam 	val = u.u_pcb.pcb_ptd | I386_CR3PAT; \
22245964Swilliam 	asm ("movl %0,%%eax; movl %%eax,%%cr3" \
22345964Swilliam 		:  \
22445964Swilliam 		: "g" (val) \
22545964Swilliam 		: "ax"); \
22645964Swilliam })
22748000Swilliam #endif
228