/*
 * $Header: /smsa/bsd:include/arm/vmparam.h:bsd  1.18  $
 * $Source: /smsa/bsd:include/arm/vmparam.h: $
 *
 * Copyright (c) 1988 Acorn Computers Ltd., Cambridge, England
 * 
 */
/*
 * Copyright (c) 1982, 1986 Regents of the University of California.
 * All rights reserved.  The Berkeley software License Agreement
 * specifies the terms and conditions for redistribution.
 *
 *	@(#)vmparam.h	7.1 (Berkeley) 6/5/86
 */

#ifndef	__arm_vmparam_h
#define __arm_vmparam_h
#define __machine_vmparam_h	"arm"

#ifndef	__arm_machparam_h
#include "machparam.h"
#endif

/*
 * VM system parameters for RISC iX on ARM/MEMC1 systems.
 */

#define	KTLBASE		768		/* kernel text logical page base */

/*
 * KERNSTACK is the value of the kernel sp when the kernel stack is
 * empty; it is equal to the end of the u-area.  In RISC iX it is also
 * the same as the start of the kernel text, and is in fact defined in
 * terms of the kernel logical start address.
 */
#define	KERNSTACK	(KTLBASE*NBPG)		/* grows below kernel text */

/*
 * LOWPAGES and HIGHPAGES are the number of pages from the beginning
 * of the P0 region to the beginning of the text and from the
 * beginning of the (backwards- growing) P1 region to the beginning of
 * the stack respectively.  USRTEXT is the start of the user text/data
 * space, while USRSTACK is the top (end) of the user stack.
 */
#define	LOWPAGES	1		/* skip page with interrupt vector */
#define	HIGHPAGES	UPAGES

#define	USRTEXT		ctob(LOWPAGES)	/* start of user text */
#define	USRSTACK	(KERNSTACK-ctob(UPAGES)) /* back of user stack */

/*
 * Limits on virtual memory pages on disc (both paged out pages, and prototype
 * pages in program and shared library files).
 */
#define MAXBLOCKSPERPAGE   8	/* Caters for block sizes down to 4Kbytes */
#define MAXPAGESONDISC   512	/* Limit on swap + text + prototype data  */

/*
 * MAX_PHYS_PAGES is the maximum machine size supported. The actual
 * memory size is determined at boot time and recorded in physmem.
 * The value of this parameter affects the choice of types in cmap.h 
 * and pte.h, amongst other things.
 */
#define MAX_PHYS_PAGES	(128*4)			/* 4 MEMCs -> 16Mb */

/*
 * Allocations of space in kernel part of logical address space, i.e.
 * KTLBASE upwards.
 */

/*
 * Space for all the permanently-mapped pages of kernel
 */
#define	KMEMPAGES	64	/* 2Mb */

/*
 * Number of logical pages used for raw I/O.  This must include at
 * least enough room for a laser printer page bitmap + 1 page for
 * alignment.  In fact we make it 64 pages and attempt to support
 * multiple concurrent raw I/O access (i.e. physio() is nicer).  When
 * uarea.s (silly name!) is modified, the raw I/O segment will be
 * nicely aligned on a 2Mb virtual address boundary in order to allow
 * independent cache control for it on ARM-3 machines.
 */
#define	RAW_IO_PAGES	64

/*
 * Number of heap pages
 */
#define	MAX_HEAP_PAGES	16

/*
 * Pages used by calloc
 */
#define	CALLOC_PAGES	22

/*
 * Rest Area Page Count.
 *
 * It has recently (21-Aug-89) been discovered that it is actually
 * safe (in terms of hardware behaviour) to have only a single logical
 * page, to which all non-mapped physical pages are bound.  Formerly,
 * for reasons of caution and to aid debugging, each physical page had
 * a private slot in the rest area
 */
#define	REST_AREA_PAGES	1

/*
 * P0U_PFNUM is the physical page number of the u-area for process 0.
 */
#define	P0U_PFNUM	(physmem-2)

/*
 * Virtual memory related constants, all in bytes
 */
#ifndef MAXTSIZ
#define	MAXTSIZ		(4*1024*1024)		/* max text size */
#endif
#ifndef MAXDSIZ
#define	MAXDSIZ		(ctob(KTLBASE)-3)	/* max data size */
#endif
#ifndef DFLDSIZ
#define	DFLDSIZ		(8*1024*1024)		/* initial data size limit */
#endif
#ifndef	MAXSSIZ
#define	MAXSSIZ		MAXDSIZ			/* max stack size */
#endif
#ifndef	DFLSSIZ
#define	DFLSSIZ		(512*1024)		/* initial stack size limit */
#endif

/*
 * Default limit sizes of swap allocation chunks (see dmap.h) in 512 byte units.
 * The actual values may be changed in vminit() based on MAXDSIZ and NDMAP.
 */
#define	DMMIN	64			/* smallest swap allocation (32Kb) */
#define	DMMAX	(64*32) 		/* largest potential swap allocation */
#define	DMTEXT	512			/* swap allocation for text */

/*
 * 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		2		/* 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.  The name is
 * wrong, it should be DISKRPS!
 */
#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 <= DMMIN in dmap.h.
 */

#define	KLMAX	1
#define	KLSEQL	(16/CLSIZE)		/* in klust if vadvise(VA_SEQL) */
#define	KLIN	(8/CLSIZE)		/* default data/stack in klust */
#define	KLTXT	(4/CLSIZE)		/* default text in klust */
#define	KLOUT	(32/CLSIZE)

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

/*
 * Paging thresholds (see vm_sched.c).
 * Strategy of before 17/3/89:
 *	lotsfree is 256k bytes, but at most 1/4 of memory
 *	desfree is 128k bytes, but at most 1/8 of memory
 *	minfree is 64k bytes, but at most 1/2 of desfree
 *      changed by HMT.
 */
#define	LOTSFREE	(256 * 1024)
#define	LOTSFREEFRACT	4
#define	DESFREE		(128 * 1024)
#define	DESFREEFRACT	8
#define	MINFREE		(64 * 1024)
#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	(1 * 1024 * 1024)

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

/*
 * Believed threshold (in megabytes) for which interleaved
 * swapping area is desirable.
 */
#define	LOTSOFMEM	2

/*
 * Time period for calculating moving averages of paging IO rates.
 */
#define PGIORATE_WINDOW	8	/* seconds */

#define INC_PGIORATE(x) (x) += 256/PGIORATE_WINDOW
#define AGE_PGIORATE(x)	(x) = ((x) * (256 - (256/PGIORATE_WINDOW))) / 256

#endif/*__arm_vmparam_h*/

/* EOF vmparam.h */
