xref: /csrg-svn/sys/tahoe/include/param.h (revision 49429)
1*49429Sbostic /*-
2*49429Sbostic  * Copyright (c) 1982, 1986, 1988 The Regents of the University of California.
3*49429Sbostic  * All rights reserved.
433282Skarels  *
5*49429Sbostic  * This code is derived from software contributed to Berkeley by
6*49429Sbostic  * Computer Consoles Inc.
7*49429Sbostic  *
8*49429Sbostic  * %sccs.include.proprietary.c%
9*49429Sbostic  *
10*49429Sbostic  *	@(#)param.h	7.9 (Berkeley) 05/08/91
1133282Skarels  */
1225681Ssam 
1325681Ssam /*
1425681Ssam  * Machine dependent constants for TAHOE.
1525681Ssam  */
1631163Sbostic #define	MACHINE	"tahoe"
1731163Sbostic 
1840722Skarels /*
1940722Skarels  * Round p (pointer or byte index) up to a correctly-aligned value
2040722Skarels  * for all data types (int, long, ...).   The result is u_int and
2140722Skarels  * must be cast to any desired pointer type.
2240722Skarels  */
2340722Skarels #define	ALIGN(p)	(((u_int)(p) + (sizeof(int) - 1)) &~ (sizeof(int) - 1))
2440722Skarels 
2530407Skarels #define	NBPG		1024		/* bytes/page */
2630407Skarels #define	PGOFSET		(NBPG-1)	/* byte offset into page */
2730407Skarels #define	PGSHIFT		10		/* LOG2(NBPG) */
2830407Skarels #define	NPTEPG		(NBPG/(sizeof (struct pte)))
2925681Ssam 
3030752Skarels #define	KERNBASE	0xc0000000	/* start of kernel virtual */
3140212Smarc #define	KERNTEXTOFF	(KERNBASE + 0x800)	/* start of kernel text */
3230752Skarels #define	BTOPKERNBASE	((u_long)KERNBASE >> PGSHIFT)
3330752Skarels 
3430407Skarels #define	DEV_BSIZE	1024
3530407Skarels #define	DEV_BSHIFT	10		/* log2(DEV_BSIZE) */
3630407Skarels #define BLKDEV_IOSIZE	1024		/* NBPG for physical controllers */
3730752Skarels #define	MAXPHYS		(64 * 1024)	/* max raw I/O transfer size */
3830407Skarels 
3925681Ssam #define	CLSIZE		1
4025681Ssam #define	CLSIZELOG2	0
4125681Ssam 
4248795Sbostic /* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */
4330407Skarels #define	SSIZE		2		/* initial stack size/NBPG */
4430407Skarels #define	SINCR		2		/* increment of stack/NBPG */
4539819Smckusick #define	UPAGES		8		/* pages of u-area (2 stack pages) */
4625681Ssam 
4738968Skarels /*
4838968Skarels  * Constants related to network buffer management.
4938968Skarels  * MCLBYTES must be no larger than CLBYTES (the software page size), and,
5038968Skarels  * on machines that exchange pages of input or output buffers with mbuf
5138968Skarels  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
5238968Skarels  * of the hardware page size.
5338968Skarels  */
5438968Skarels #define	MSIZE		128		/* size of an mbuf */
5538968Skarels #define	MAPPED_MBUFS			/* can do scatter-gather I/O */
5638968Skarels #if CLBYTES > 1024
5738968Skarels #define	MCLBYTES	1024
5838968Skarels #define	MCLSHIFT	10
5938968Skarels #define	MCLOFSET	(MCLBYTES - 1)
6038968Skarels #else
6138968Skarels #define	MCLBYTES	CLBYTES
6238968Skarels #define	MCLSHIFT	CLSHIFT
6338968Skarels #define	MCLOFSET	CLOFSET
6438968Skarels #endif
6538968Skarels #ifdef GATEWAY
6638968Skarels #define	NMBCLUSTERS	512		/* map size, max cluster allocation */
6738968Skarels #else
6838968Skarels #define	NMBCLUSTERS	256		/* map size, max cluster allocation */
6938968Skarels #endif
7038968Skarels 
7125681Ssam #define	MAXCKEY	255		/* maximal allowed code key */
7225681Ssam #define	MAXDKEY	255		/* maximal allowed data key */
7325681Ssam #define	NCKEY	(MAXCKEY+1)	/* # code keys, including 0 (reserved) */
7425681Ssam #define	NDKEY	(MAXDKEY+1)	/* # data keys, including 0 (reserved) */
7525681Ssam 
7625681Ssam /*
7741524Smckusick  * Size of kernel malloc arena in CLBYTES-sized logical pages
7841524Smckusick  */
7941524Smckusick #ifndef NKMEMCLUSTERS
8041524Smckusick #define	NKMEMCLUSTERS	(512*1024/CLBYTES)
8141524Smckusick #endif
8241524Smckusick 
8341524Smckusick /*
8425681Ssam  * Some macros for units conversion
8525681Ssam  */
8625681Ssam /* Core clicks (1024 bytes) to segments and vice versa */
8725681Ssam #define	ctos(x)	(x)
8825681Ssam #define	stoc(x)	(x)
8925681Ssam 
9025681Ssam /* Core clicks (1024 bytes) to disk blocks */
9125681Ssam #define	ctod(x)	(x)
9225681Ssam #define	dtoc(x)	(x)
9325681Ssam #define	dtob(x)	((x)<<PGSHIFT)
9425681Ssam 
9525681Ssam /* clicks to bytes */
9625681Ssam #define	ctob(x)	((x)<<PGSHIFT)
9725681Ssam 
9825681Ssam /* bytes to clicks */
9925681Ssam #define	btoc(x)	((((unsigned)(x)+NBPG-1) >> PGSHIFT))
10025681Ssam 
10130407Skarels #define	btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
10230407Skarels 	((unsigned)(bytes) >> DEV_BSHIFT)
10330407Skarels #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
10430407Skarels 	((unsigned)(db) << DEV_BSHIFT)
10530407Skarels 
10625681Ssam /*
10730407Skarels  * Map a ``block device block'' to a file system block.
10830407Skarels  * This should be device dependent, and will be if we
10930407Skarels  * add an entry to cdevsw/bdevsw for that purpose.
11030407Skarels  * For now though just use DEV_BSIZE.
11130407Skarels  */
11230407Skarels #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
11330407Skarels 
11430407Skarels /*
11525681Ssam  * Macros to decode processor status word.
11625681Ssam  */
11725681Ssam #define	USERMODE(ps)	(((ps) & PSL_CURMOD) == PSL_CURMOD)
11825681Ssam #define	BASEPRI(ps)	(((ps) & PSL_IPL) == 0)
11925681Ssam 
12025681Ssam #define	DELAY(n)	{ register int N = 3*(n); while (--N > 0); }
121