/* $Copyright:	$
 * Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
 * Sequent Computer Systems, Inc.   All rights reserved.
 *  
 * This software is furnished under a license and may be used
 * only in accordance with the terms of that license and with the
 * inclusion of the above copyright notice.   This software may not
 * be provided or otherwise made available to, or used by, any
 * other person.  No title to or ownership of the software is
 * hereby transferred.
 */

#ident	"$Header: param_space.c 1.58 90/10/29 $"

/*
 * param_space.c
 *	Configuration parameters file.  This is compiled as part of the
 *	kernel configuration process.
 *
 */

/* $Log:	param_space.c,v $
 */

#include "sys/types.h"
#include "sys/devsw.h"
#include "sys/signal.h"
#include "sys/param.h"
#include "sys/debug.h"
#include "sys/mutex.h"
#include "sys/systm.h"
#include "sys/vm.h"
#include "sys/user.h"
#include "sys/timer.h"
#include "sys/proc.h"
#include "sys/vnode.h"
#include "sys/ufsinode.h"
#include "sys/file.h"
#include "sys/callo.h"
#include "sys/cmap.h"
#include "sys/map.h"
#include "sys/fcntl.h"
#include "sys/flock.h"
#include "sys/var.h"
#include "sys/session.h"
#include "sys/stream.h"
#include "sys/pte.h"
#include "sys/plocal.h"
#include "sys/fifo.h"
#include "sys/dnlc.h"

#include "sys/clock.h"

#include "config.h"

/*
 * System parameter formulae.
 *
 * This file is copied into each directory where we compile
 * the kernel; it should be modified there to suit local taste
 * if necessary.
 *
 * Compiled with -DMAXUSERS=xx
 *
 * Determine defaults for various table sizes and other parameters.
 * All of these can be overridden via "options" lines in the configuration
 * file; eg, "options FIFOSZ=16384".
 */

#ifndef FIFOSZ
#define FIFOSZ		8192
#endif

#ifndef FIFOBSZ
#define FIFOBSZ		1024
#endif

#ifndef FIFODEV
#define FIFODEV		0xefffffff
#endif

#ifndef	CPUSPEED		/* approximate speed of cpu in VAX MIPS */
#define	CPUSPEED	25	/* used for spin loops in various places */
				/* normalised to 100 Mhz                 */
#endif
#if	defined(MODELD) && !defined(I486_CPUSPEED)
#define	I486_CPUSPEED	50
#endif	/* defined(MODELD) && !defined(I486_CPUSPEED) */
#ifndef	CPURATE			
#define	CPURATE	16		/* minimum cpu rate in Mhz */
#endif

#ifndef	DEV_MEM_INIT
#define	DEV_MEM_INIT 16 * NBPG	/* initial allocation for devs */
#endif

#ifndef	DEV_MEM_CLICK
#define	DEV_MEM_CLICK 1 * NBPG	/* subsequent allocations for devs */
#endif

#ifdef QUOTA
#ifndef NDQUOT			/* # of currently activedquot struct */
#define	NDQUOT  	(NINODE + (MAXUSERS * NMOUNT) / 4)
#endif

#ifndef NDQHASH			/* # quota hash buckets */
#define	NDQHASH		((NDQUOT) / 3)
#endif

#ifndef DQ_FTIMEDEFAULT		/*
				 * Amount of time given a user before the soft
				 * limits for inodes are treated as hard limits
				 * (usually resulting in an allocation
				 * failure). These may be  modified by the
				 * quotactl system call with the Q_SETQLIM or
				 * Q_SETQUOTA command codes.
				 */
#define	DQ_FTIMEDEFAULT	(7 * 24 * 60 * 60)	/* 1 week */
#endif

#ifndef	DQ_BTIMEDEFAULT		/* time limit for disk blocks */
#define	DQ_BTIMEDEFAULT	(7 * 24 * 60 * 60)	/* 1 week */
#endif
#endif /* QUOTA */


int	hz		= HZ;
int	tick		= 1000000 / HZ;
int	memintvl	= MEMINTVL * HZ;
int	tickadj		= TICKADJ;

int	maxsymlinks	= MAXSYMLINKS;
int	nmfile		= NMFILE;
int	nucred		= NUCRED;
int	nofile_tab	= NOFILETAB;
int	cpurate		= CPURATE;
int	lcpuspeed	= CPUSPEED;
#ifdef	MODELD
int	i486_lcpuspeed	= I486_CPUSPEED;
#endif	/* MODELD */
int	ncsize		= NCSIZE;
int	nchsize		= NCHSIZE;
int	dev_mem_init	= DEV_MEM_INIT;
int	dev_mem_click	= DEV_MEM_CLICK;
int	nabuf		= NABUF;	/* number of async I/O buffers */
int	maxaio		= MAXAIO;	/* max no. of request per proccess */
#ifdef QUOTA
int	ndquot		= NDQUOT;
int	ndqhash		= NDQHASH;

int	dq_ftimedefault = DQ_FTIMEDEFAULT;
int	dq_btimedefault = DQ_BTIMEDEFAULT;
#else
/*
 * Define ndquot and ndqhash and set them to zero so that quotas
 * take no space if kernel was source configured with quotas, but
 * binary configured without them.
 */
#ifndef lint
int	ndquot = 0;			/* no dquot struct's */
int	ndqhash = 0;			/* no quota hash buckets */
int	dq_ftimedefault;
int	dq_btimedefault;
#endif /* lint */
#endif /* QUOTA */

/*
 * Tuneable paging parameters.
 * maxRS, vt_maxRS are adjusted when system comes up to insure fit in memory.
 */

int	avg_size_process = AVGSZ_PROC * K;

long	maxRS		= MAXADDR/CLBYTES;	/* max # clusters for Rset */
long	maxRSslop	= (20*K)/NBPG;		/* slop for maxRS calculation */

struct	vm_tune	vmtune = {
	(DEF_MINRS*K)/CLBYTES,	/* (vt_minRS) min # clusters for Rset */
	MAXADDR/CLBYTES,	/* (vt_maxRS) max # clusters for Rset */
	(20*K)/NBPG,		/* (vt_RSexecslop) # HW pages slop in exec */
	4,			/* (vt_RSexecmult) Rset multipler */
	5,			/* (vt_RSexecdiv) Rset divider */
	0,			/* (vt_dirtylow) low dirty-list size */
	0,			/* (vt_dirtyhigh) high dirty-list size */
	32,			/* (vt_klout_look) pageout kluster look-ahead */
	1*HZ,			/* (vt_PFFvtime) ticks between PFF adjust */
	(8*K)/CLBYTES,		/* (vt_PFFdecr) pages to drop if PFF < PFFlow */
	2,			/* (vt_PFFlow) low PFF rate; <= PFFhigh */
	(20*K)/CLBYTES,		/* (vt_PFFincr) pages to add if PFF > PFFhigh */
	15,			/* (vt_PFFhigh) high PFF rate */
	0,			/* (vt_minfree) low free-list for swapping */
	0,			/* (vt_desfree) high free-list for swapping */
	0,			/* (vt_maxdirty) max dirty-list before swap */
};

bool_t	root_vm_setrs = 1;	/* must be root to do vm_ctl(VM_SETRS) */
bool_t	root_vm_swapable = 1;	/* must be root to do vm_ctl(VM_SWAPABLE,0) */
bool_t	root_vm_pffable = 1;	/* must be root to do vm_ctl(VM_PFFABLE,0) */
bool_t	root_prio_noage = 1;	/* must be root to do proc_ctl(PRIO_AGE,x,0) */

/*
 * Fork-map parameters; determine amount of memory the system will dedicate
 * to concurrent forks by mult/div initial free-space.
 */

long	forkmapmult =	2;	/* multiplier */
long	forkmapdiv =	3;	/* divisor */

/*
 * Variables initialized here to zero are initialized at bootstrap time
 * to values dependent on memory size.
 */

int	bufpages = 0;		/* # clusters allocated to buffer cache */
int	buf_hash_mult = 1;	/* bufhsz = nbuf * ... */
int	buf_hash_div = 2;	/*	... buf_hash_mult / buf_hash_div */
int	bufpct = BUFPCT;	/* pct of free mem to allocate to bufpages */

int	mmreg_maxb = 10;	/* max # buffers to use for mapped-file sync */
int	pageout_maxb = 10;	/* max # buffers to use for pageouts */

int	ummap_max_hole = (64*K)/NBPG;	/* max u_mmap concat hole */

/*
 * light_show decides which LED's are used to display system activity.
 * B8k's can only display on the processor board LED's; B21k's can display
 * on the front-panel and processor board LED's.  light_show == 1 displays
 * in one place (front-panel if B21k); light_show == 2 displays in both places
 * if possible; light_show == 0 doesn't flash at all (quite boring).
 */

int	light_show = 1;		/* display on most useful place (==1) */

/*
 * Non-zero resphysmem constrains amount of physical memory the system will
 * use, reserving some for special purpose drivers, accelerators, etc.
 * Physical address of reserved memory is held in `topmem'.
 * Must be a multiple of CLBYTES.
 */

#ifndef	RESPHYSMEM
#define	RESPHYSMEM	0	/* default: none reserved */
#endif

int	resphysmem = RESPHYSMEM;

/*
 * Dynamic swap space allocation postpones actual swap space allocation
 * for process private data and stack until the virtual memory is paged or
 * swapped out.  This can result in lower overhead and less consumption of
 * swap space, but kills processes if space isn't available when needed.
 */

#ifndef	DYNAMIC_SWAP_SPACE
#define	DYNAMIC_SWAP_SPACE	0	/* default: pre-allocate */
#endif

int	dynamic_swap_space = DYNAMIC_SWAP_SPACE;

/*
 * If swap space is dynamically allocated, a console message is generated when
 * physical swap space is allocated below swap_low_water (units in swap space
 * sectors (512 bytes)).  This is intended to warn a system administrator that
 * system memory resources are getting low.
 */

#ifndef	SWAP_LOW_WATER
#define	SWAP_LOW_WATER	0	/* default: no warning */
#endif

int	swap_low_water = SWAP_LOW_WATER;

/*
 * "Readonly" mounted filesystems means that when a block device gets
 * mounted, the raw device can be opened, but attempts to write to
 * it will fail.  This makes it possible for utilities like ncheck, icheck
 * and quotacheck to work on mounted filesystems (by reading the raw
 * device) but disallows doing a mkfs on a mounted filesystem.
 */

#ifndef	MOUNT_READONLY
#define	MOUNT_READONLY	1	/* default: make mounted devices readonly */
#endif

int	mount_readonly = MOUNT_READONLY;

/*
 * structures for record locking implementation
 */

struct	filock	flox[NFILCK];
struct	flckinfo flckinfo = { NFILCK };

/*
 * fifo stuff
 */
struct fifoinfo fifoinfo = {
	NFIFO,		/* number of fifo's in system (max) */
	FIFOSZ,		/* number of bytes fifo can hold */
	FIFOBSZ,	/* fifo "block size" */
	FIFODEV,	/* fifo "device" number */
	FIFOSANITY,	/* portion of buf cache to cap */
	};

/*
 * Streams stuff.
 * The following defines one dblock per buffer.
 */
#ifndef NDBLKTOTAL
#define NDBLKTOTAL (NBLKPRIV + NBLK4096 + NBLK2048 + NBLK1024 \
		  + NBLK512 + NBLK256 + NBLK128 + NBLK64 + NBLK16 + NBLK4)
#endif

/*
 * The following defines one mblock per dblock and then some extra
 * for dup'ed cases.
 */
#ifndef NMBLKTOTAL
#define NMBLKTOTAL (NDBLKTOTAL + (NDBLKTOTAL)/4)
#endif

int	nmuxlink = NMUXLINK;
int	nstrevent = NSTREVENT;
int	nstrpush = NSTRPUSH;
int	strmsgsz = STRMSGSZ;
int	strctlsz = STRCTLSZ;
int	strlofrac = STRLOFRAC;
int	strmedfrac = STRMEDFRAC;
int	strnsched = STRNSCHED;
int 	ndblock = NDBLKTOTAL;
int 	nmblock = NMBLKTOTAL;

/*
 * System Configuration Information
 */

struct	var	v = {
		NBUF,
		NCALL,
		NINODE,
		(struct inode *)(0),
		NFILE,
		(struct file *)(0),
		NMOUNT,
		(struct mount *)(0),
		NPROC,
		(struct proc *)(0),
		0,			/* unused */
		0,			/* unused (was NCLIST) */
		MAXUP,
		NHBUF,
		0,			/* unused */
		NPBUF,
		0,			/* unused */
		0,			/* unused */
		0,			/* unused */
		0,			/* unused */
		NOFILES,
		NQUEUE,
		NSTREAM,
		NBLKPRIV,
		NBLK4096,
		NBLK2048,
		NBLK1024,
		NBLK512,
		NBLK256,
		NBLK128,
		NBLK64,
		NBLK16,
		NBLK4,
		0,			/* unused */
		ULIMIT
};

/*
 * Tunable standards-related parameters.
 */

int cuserid_version = CUSERID_VERSION;  /* 0 == Traditional, 1 == POSIX.1 */


