xref: /csrg-svn/sys/tahoe/include/param.h (revision 48795)
133282Skarels /*
234408Skarels  * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
333282Skarels  * All rights reserved.  The Berkeley software License Agreement
433282Skarels  * specifies the terms and conditions for redistribution.
533282Skarels  *
6*48795Sbostic  *	@(#)param.h	7.8 (Berkeley) 04/28/91
733282Skarels  */
825681Ssam 
925681Ssam /*
1025681Ssam  * Machine dependent constants for TAHOE.
1125681Ssam  */
1231163Sbostic #define	MACHINE	"tahoe"
1331163Sbostic 
1440722Skarels /*
1540722Skarels  * Round p (pointer or byte index) up to a correctly-aligned value
1640722Skarels  * for all data types (int, long, ...).   The result is u_int and
1740722Skarels  * must be cast to any desired pointer type.
1840722Skarels  */
1940722Skarels #define	ALIGN(p)	(((u_int)(p) + (sizeof(int) - 1)) &~ (sizeof(int) - 1))
2040722Skarels 
2130407Skarels #define	NBPG		1024		/* bytes/page */
2230407Skarels #define	PGOFSET		(NBPG-1)	/* byte offset into page */
2330407Skarels #define	PGSHIFT		10		/* LOG2(NBPG) */
2430407Skarels #define	NPTEPG		(NBPG/(sizeof (struct pte)))
2525681Ssam 
2630752Skarels #define	KERNBASE	0xc0000000	/* start of kernel virtual */
2740212Smarc #define	KERNTEXTOFF	(KERNBASE + 0x800)	/* start of kernel text */
2830752Skarels #define	BTOPKERNBASE	((u_long)KERNBASE >> PGSHIFT)
2930752Skarels 
3030407Skarels #define	DEV_BSIZE	1024
3130407Skarels #define	DEV_BSHIFT	10		/* log2(DEV_BSIZE) */
3230407Skarels #define BLKDEV_IOSIZE	1024		/* NBPG for physical controllers */
3330752Skarels #define	MAXPHYS		(64 * 1024)	/* max raw I/O transfer size */
3430407Skarels 
3525681Ssam #define	CLSIZE		1
3625681Ssam #define	CLSIZELOG2	0
3725681Ssam 
38*48795Sbostic /* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */
3930407Skarels #define	SSIZE		2		/* initial stack size/NBPG */
4030407Skarels #define	SINCR		2		/* increment of stack/NBPG */
4139819Smckusick #define	UPAGES		8		/* pages of u-area (2 stack pages) */
4225681Ssam 
4338968Skarels /*
4438968Skarels  * Constants related to network buffer management.
4538968Skarels  * MCLBYTES must be no larger than CLBYTES (the software page size), and,
4638968Skarels  * on machines that exchange pages of input or output buffers with mbuf
4738968Skarels  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
4838968Skarels  * of the hardware page size.
4938968Skarels  */
5038968Skarels #define	MSIZE		128		/* size of an mbuf */
5138968Skarels #define	MAPPED_MBUFS			/* can do scatter-gather I/O */
5238968Skarels #if CLBYTES > 1024
5338968Skarels #define	MCLBYTES	1024
5438968Skarels #define	MCLSHIFT	10
5538968Skarels #define	MCLOFSET	(MCLBYTES - 1)
5638968Skarels #else
5738968Skarels #define	MCLBYTES	CLBYTES
5838968Skarels #define	MCLSHIFT	CLSHIFT
5938968Skarels #define	MCLOFSET	CLOFSET
6038968Skarels #endif
6138968Skarels #ifdef GATEWAY
6238968Skarels #define	NMBCLUSTERS	512		/* map size, max cluster allocation */
6338968Skarels #else
6438968Skarels #define	NMBCLUSTERS	256		/* map size, max cluster allocation */
6538968Skarels #endif
6638968Skarels 
6725681Ssam #define	MAXCKEY	255		/* maximal allowed code key */
6825681Ssam #define	MAXDKEY	255		/* maximal allowed data key */
6925681Ssam #define	NCKEY	(MAXCKEY+1)	/* # code keys, including 0 (reserved) */
7025681Ssam #define	NDKEY	(MAXDKEY+1)	/* # data keys, including 0 (reserved) */
7125681Ssam 
7225681Ssam /*
7341524Smckusick  * Size of kernel malloc arena in CLBYTES-sized logical pages
7441524Smckusick  */
7541524Smckusick #ifndef NKMEMCLUSTERS
7641524Smckusick #define	NKMEMCLUSTERS	(512*1024/CLBYTES)
7741524Smckusick #endif
7841524Smckusick 
7941524Smckusick /*
8025681Ssam  * Some macros for units conversion
8125681Ssam  */
8225681Ssam /* Core clicks (1024 bytes) to segments and vice versa */
8325681Ssam #define	ctos(x)	(x)
8425681Ssam #define	stoc(x)	(x)
8525681Ssam 
8625681Ssam /* Core clicks (1024 bytes) to disk blocks */
8725681Ssam #define	ctod(x)	(x)
8825681Ssam #define	dtoc(x)	(x)
8925681Ssam #define	dtob(x)	((x)<<PGSHIFT)
9025681Ssam 
9125681Ssam /* clicks to bytes */
9225681Ssam #define	ctob(x)	((x)<<PGSHIFT)
9325681Ssam 
9425681Ssam /* bytes to clicks */
9525681Ssam #define	btoc(x)	((((unsigned)(x)+NBPG-1) >> PGSHIFT))
9625681Ssam 
9730407Skarels #define	btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
9830407Skarels 	((unsigned)(bytes) >> DEV_BSHIFT)
9930407Skarels #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
10030407Skarels 	((unsigned)(db) << DEV_BSHIFT)
10130407Skarels 
10225681Ssam /*
10330407Skarels  * Map a ``block device block'' to a file system block.
10430407Skarels  * This should be device dependent, and will be if we
10530407Skarels  * add an entry to cdevsw/bdevsw for that purpose.
10630407Skarels  * For now though just use DEV_BSIZE.
10730407Skarels  */
10830407Skarels #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
10930407Skarels 
11030407Skarels /*
11125681Ssam  * Macros to decode processor status word.
11225681Ssam  */
11325681Ssam #define	USERMODE(ps)	(((ps) & PSL_CURMOD) == PSL_CURMOD)
11425681Ssam #define	BASEPRI(ps)	(((ps) & PSL_IPL) == 0)
11525681Ssam 
11625681Ssam #define	DELAY(n)	{ register int N = 3*(n); while (--N > 0); }
117