/*		@(#)vmparam.h	13.2 (RC Computer) 91/09/09	*/

/*
 * Machine dependent constants for MIPS R2000 (RC9000)
 */

/*
 * USRTEXT is the start of the user text, USRDATA is the start of the
 * user data, and USRSTACK is the top (end) of the user stack.  
 * LOWPAGES is the number of pages from the beginning of the text region
 * to the beginning of text.
 * HIGHPAGES is the number of pages from the beginning of the stack region
 * to the beginning of the stack.
 */

#define	LOWPAGES	0
#define	REDZONEPAGES	1
#define	HIGHPAGES	REDZONEPAGES
#define	USRTEXT		0x400000	/* user text starts at 4 MB */
#define USRDATA		0x10000000	/* user data starts at 256 MB */
#define	EA_SIZE		32		/* EMULATE_AREA size */
#define	USRSTACK	(0x80000000-REDZONEPAGES*NBPG)/* Top of user stack */
#define EMULATE_AREA	USRSTACK-EA_SIZE/* area for bp emulation */
#define SYSBASE		K2BASE		/* address mapped by Sysmap[0] */
#define	V_BASE		0xe0000000	/* base address of virtual window area*/

/*
 * Virtual memory related constants, all in bytes
 */
#ifndef MAXTSIZ
#define	MAXTSIZ		(24*1024*1024)		/* max text size */
#endif
#ifndef DFLDSIZ
#define	DFLDSIZ		(32*1024*1024)		/* initial data size limit */
#endif
#ifndef MAXDSIZ
#define	MAXDSIZ		(124*1024*1024-16*1024)	/* max data size */
#endif
#ifndef	DFLSSIZ
#define	DFLSSIZ		(1024*1024)		/* initial stack size limit */
#endif
#ifndef	MAXSSIZ
#define	MAXSSIZ		MAXDSIZ			/* max stack size */
#endif

/*
 * Default sizes of swap allocation chunks (see dmap.h).
 * The  following table gives the max program size (all expressed
 * in DEV_BSIZE blocks (1Kbytes)):
 *		data/stack		text (& shm)
 *	NDMAP	     38		  NXDAD	      24
 *	DMMIN	     16		  DMTEXT    1024
 *	DMMAX	   4096		  DMSHM	    1024
 *	---------------------     --------------------
 *		    124M-16K		      24Mbytes
 */
#define	DMMIN	16			/* smallest swap allocation */
#define	DMMAX	4096			/* largest potential swap allocation */
#define	DMTEXT	1024			/* swap allocation for text */
#define DMSHM	1024			/* shm segment size */

/*
 * Size of the system and user page table.
 */
#define	SYSPTSIZE	(0x200000/NBPG)	/* allow 2Mb max of buffers */
#define	USRPTSIZE 	(3*32*48+20*3) /* 8 procs/user + 20 daemons */

/*
 * The size of the clock loop.
 */
#define	LOOPPAGES	(maxfree - firstfree)

/*
 * The time for a process to be blocked before being very swappable.
 * This is a number of seconds which the system takes as being a non-trivial
 * amount of real time.  You probably shouldn't change this;
 * it is used in subtle ways (fractions and multiples of it are, that is, like
 * half of a ``long time'', almost a long time, etc.)
 * It is related to human patience and other factors which don't really
 * change over time.
 */
#define	MAXSLP 		20

/*
 * A swapped in process is given a small amount of core without being bothered
 * by the page replacement algorithm.  Basically this says that if you are
 * swapped in you deserve some resources.  We protect the last SAFERSS
 * pages against paging and will just swap you out rather than paging you.
 * Note that each process has at least UPAGES+CLSIZE pages which are not
 * paged anyways (this is currently 8+2=10 pages or 5k bytes), so this
 * number just means a swapped in process is given around 25k bytes.
 * Just for fun: current memory prices are 4600$ a megabyte on VAX (4/22/81),
 * so we loan each swapped in process memory worth 100$, or just admit
 * that we don't consider it worthwhile and swap it out to disk which costs
 * $30/mb or about $0.75.
 */
#define	SAFERSS		6		/* nominal ``small'' resident set size
					   protected against replacement */

/*
 * DISKRPM is used to estimate the number of paging i/o operations
 * which one can expect from a single disk controller.
 */
#define	DISKRPM		60

/*
 * Klustering constants.  Klustering is the gathering
 * of pages together for pagein/pageout, while clustering
 * is the treatment of hardware page size as though it were
 * larger than it really is.
 *
 * KLMAX gives maximum cluster size in CLSIZE page (cluster-page)
 * units. 
 * Note that KLMAX*CLSIZE must be <= dtoc(DMMIN) in dmap.h
 *	     KLMAX*CLSIZE must be <= dtoc(MAX_IOVLEN - 1) 
 * 	     KLMAX*CLSIZE must be a divisor of dmmin.
 */

#define	KLMAX	(4/CLSIZE)
#define	KLSEQL	(4/CLSIZE)		/* in klust if vadvise(VA_SEQL) */
#define	KLIN	(2/CLSIZE)		/* default data/stack in klust */
#define	KLTXT	(2/CLSIZE)		/* default text in klust */
#define	KLOUT	(4/CLSIZE)		/* default data/stack out kluster */
#define KLSHM	(KLIN)			/* default shm in kluster */

/*
 * KLSDIST is the advance or retard of the fifo reclaim for sequential
 * processes data space.
 */
#define	KLSDIST	2		/* klusters advance/retard for seq. fifo */

/*
 * Paging thresholds (see vm_sched.c).
 * Strategy of 4/22/81:
 *	lotsfree is 512k bytes, but at most 1/4 of memory
 *	desfree is 256K bytes, but at most 1/8 of memory
 *	minfree is 96K bytes, but at most 1/2 of desfree
 */
#define	LOTSFREE	(128 * 4096)
#define	LOTSFREEFRACT	4
#define	DESFREE		(64 * 4096)
#define	DESFREEFRACT	8
#define	MINFREE		(24 * 4096)
#define	MINFREEFRACT	2

/*
 * There are two clock hands, initially separated by HANDSPREAD bytes
 * (but at most all of user memory).  The amount of time to reclaim
 * a page once the pageout process examines it increases with this
 * distance and decreases as the scan rate rises.
 */
#define	HANDSPREAD	(2 * 1024 * 4096)

/*
 * The number of times per second to recompute the desired paging rate
 * and poke the pagedaemon.
 */
#define	RATETOSCHEDPAGING	4

/*
 * Pages per second to scan when out of memory (targeted toward ~10%
 * of cpu)
 */
#define	MAXSCAN 	400

/*
 * Processes waiting in retire wake up frequently.  Therefore,
 * we give them more time to settle before we determine they are
 * really long term sleepers, and therefore deserve to be swapped
 * out.
 */
#define	RETIRESLPFACT	4
