xref: /csrg-svn/sys/tahoe/include/param.h (revision 41524)
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*41524Smckusick  *	@(#)param.h	7.6 (Berkeley) 05/10/90
733282Skarels  */
825681Ssam 
925681Ssam /*
1025681Ssam  * Machine dependent constants for TAHOE.
1125681Ssam  */
1231163Sbostic #define	MACHINE	"tahoe"
1331163Sbostic 
1433380Skarels #ifndef BYTE_ORDER
1533282Skarels #include <machine/endian.h>
1633282Skarels #endif
1733282Skarels 
1838968Skarels #include <machine/machlimits.h>
1932564Sbostic 
2040722Skarels /*
2140722Skarels  * Round p (pointer or byte index) up to a correctly-aligned value
2240722Skarels  * for all data types (int, long, ...).   The result is u_int and
2340722Skarels  * must be cast to any desired pointer type.
2440722Skarels  */
2540722Skarels #define	ALIGN(p)	(((u_int)(p) + (sizeof(int) - 1)) &~ (sizeof(int) - 1))
2640722Skarels 
2730407Skarels #define	NBPG		1024		/* bytes/page */
2830407Skarels #define	PGOFSET		(NBPG-1)	/* byte offset into page */
2930407Skarels #define	PGSHIFT		10		/* LOG2(NBPG) */
3030407Skarels #define	NPTEPG		(NBPG/(sizeof (struct pte)))
3125681Ssam 
3230752Skarels #define	KERNBASE	0xc0000000	/* start of kernel virtual */
3340212Smarc #define	KERNTEXTOFF	(KERNBASE + 0x800)	/* start of kernel text */
3430752Skarels #define	BTOPKERNBASE	((u_long)KERNBASE >> PGSHIFT)
3530752Skarels 
3630407Skarels #define	DEV_BSIZE	1024
3730407Skarels #define	DEV_BSHIFT	10		/* log2(DEV_BSIZE) */
3830407Skarels #define BLKDEV_IOSIZE	1024		/* NBPG for physical controllers */
3930752Skarels #define	MAXPHYS		(64 * 1024)	/* max raw I/O transfer size */
4030407Skarels 
4125681Ssam #define	CLSIZE		1
4225681Ssam #define	CLSIZELOG2	0
4325681Ssam 
4430407Skarels #define	SSIZE		2		/* initial stack size/NBPG */
4530407Skarels #define	SINCR		2		/* increment of stack/NBPG */
4639819Smckusick #define	UPAGES		8		/* pages of u-area (2 stack pages) */
4725681Ssam 
4838968Skarels /*
4938968Skarels  * Constants related to network buffer management.
5038968Skarels  * MCLBYTES must be no larger than CLBYTES (the software page size), and,
5138968Skarels  * on machines that exchange pages of input or output buffers with mbuf
5238968Skarels  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
5338968Skarels  * of the hardware page size.
5438968Skarels  */
5538968Skarels #define	MSIZE		128		/* size of an mbuf */
5638968Skarels #define	MAPPED_MBUFS			/* can do scatter-gather I/O */
5738968Skarels #if CLBYTES > 1024
5838968Skarels #define	MCLBYTES	1024
5938968Skarels #define	MCLSHIFT	10
6038968Skarels #define	MCLOFSET	(MCLBYTES - 1)
6138968Skarels #else
6238968Skarels #define	MCLBYTES	CLBYTES
6338968Skarels #define	MCLSHIFT	CLSHIFT
6438968Skarels #define	MCLOFSET	CLOFSET
6538968Skarels #endif
6638968Skarels #ifdef GATEWAY
6738968Skarels #define	NMBCLUSTERS	512		/* map size, max cluster allocation */
6838968Skarels #else
6938968Skarels #define	NMBCLUSTERS	256		/* map size, max cluster allocation */
7038968Skarels #endif
7138968Skarels 
7225681Ssam #define	MAXCKEY	255		/* maximal allowed code key */
7325681Ssam #define	MAXDKEY	255		/* maximal allowed data key */
7425681Ssam #define	NCKEY	(MAXCKEY+1)	/* # code keys, including 0 (reserved) */
7525681Ssam #define	NDKEY	(MAXDKEY+1)	/* # data keys, including 0 (reserved) */
7625681Ssam 
7725681Ssam /*
78*41524Smckusick  * Size of kernel malloc arena in CLBYTES-sized logical pages
79*41524Smckusick  */
80*41524Smckusick #ifndef NKMEMCLUSTERS
81*41524Smckusick #define	NKMEMCLUSTERS	(512*1024/CLBYTES)
82*41524Smckusick #endif
83*41524Smckusick 
84*41524Smckusick /*
8525681Ssam  * Some macros for units conversion
8625681Ssam  */
8725681Ssam /* Core clicks (1024 bytes) to segments and vice versa */
8825681Ssam #define	ctos(x)	(x)
8925681Ssam #define	stoc(x)	(x)
9025681Ssam 
9125681Ssam /* Core clicks (1024 bytes) to disk blocks */
9225681Ssam #define	ctod(x)	(x)
9325681Ssam #define	dtoc(x)	(x)
9425681Ssam #define	dtob(x)	((x)<<PGSHIFT)
9525681Ssam 
9625681Ssam /* clicks to bytes */
9725681Ssam #define	ctob(x)	((x)<<PGSHIFT)
9825681Ssam 
9925681Ssam /* bytes to clicks */
10025681Ssam #define	btoc(x)	((((unsigned)(x)+NBPG-1) >> PGSHIFT))
10125681Ssam 
10230407Skarels #define	btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
10330407Skarels 	((unsigned)(bytes) >> DEV_BSHIFT)
10430407Skarels #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
10530407Skarels 	((unsigned)(db) << DEV_BSHIFT)
10630407Skarels 
10725681Ssam /*
10830407Skarels  * Map a ``block device block'' to a file system block.
10930407Skarels  * This should be device dependent, and will be if we
11030407Skarels  * add an entry to cdevsw/bdevsw for that purpose.
11130407Skarels  * For now though just use DEV_BSIZE.
11230407Skarels  */
11330407Skarels #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
11430407Skarels 
11530407Skarels /*
11625681Ssam  * Macros to decode processor status word.
11725681Ssam  */
11825681Ssam #define	USERMODE(ps)	(((ps) & PSL_CURMOD) == PSL_CURMOD)
11925681Ssam #define	BASEPRI(ps)	(((ps) & PSL_IPL) == 0)
12025681Ssam 
12125681Ssam #define	DELAY(n)	{ register int N = 3*(n); while (--N > 0); }
122