xref: /csrg-svn/sys/tahoe/include/param.h (revision 30407)
1*30407Skarels /*	param.h	1.6	87/01/16	*/
225681Ssam 
325681Ssam /*
425681Ssam  * Machine dependent constants for TAHOE.
525681Ssam  */
629950Skarels 
729950Skarels #ifndef ENDIAN
829950Skarels /*
929950Skarels  * Definitions for byte order,
1029950Skarels  * according to byte significance from low address to high.
1129950Skarels  */
1229950Skarels #define	LITTLE	1234		/* least-significant byte first (vax) */
1329950Skarels #define	BIG	4321		/* most-significant byte first */
1429950Skarels #define	PDP	3412		/* LSB first in word, MSW first in long (pdp) */
1529950Skarels #define	ENDIAN	BIG		/* byte order on tahoe */
1629950Skarels 
1730402Skarels /*
1830402Skarels  * Macros for network/external number representation conversion.
1930402Skarels  */
2030402Skarels #if ENDIAN == BIG && !defined(lint)
2130402Skarels #define	ntohl(x)	(x)
2230402Skarels #define	ntohs(x)	(x)
2330402Skarels #define	htonl(x)	(x)
2430402Skarels #define	htons(x)	(x)
2530402Skarels #else
2630402Skarels u_short	ntohs(), htons();
2730402Skarels u_long	ntohl(), htonl();
2830402Skarels #endif
2930402Skarels 
30*30407Skarels #define	NBPG		1024		/* bytes/page */
31*30407Skarels #define	PGOFSET		(NBPG-1)	/* byte offset into page */
32*30407Skarels #define	PGSHIFT		10		/* LOG2(NBPG) */
33*30407Skarels #define	NPTEPG		(NBPG/(sizeof (struct pte)))
3425681Ssam 
35*30407Skarels #define	DEV_BSIZE	1024
36*30407Skarels #define	DEV_BSHIFT	10		/* log2(DEV_BSIZE) */
37*30407Skarels #define BLKDEV_IOSIZE	1024		/* NBPG for physical controllers */
38*30407Skarels 
3925681Ssam #define	CLSIZE		1
4025681Ssam #define	CLSIZELOG2	0
4125681Ssam 
42*30407Skarels #define	SSIZE		2		/* initial stack size/NBPG */
43*30407Skarels #define	SINCR		2		/* increment of stack/NBPG */
44*30407Skarels #define	UPAGES		6		/* pages of u-area (2 stack pages) */
4525681Ssam 
4625681Ssam #define	MAXCKEY	255		/* maximal allowed code key */
4725681Ssam #define	MAXDKEY	255		/* maximal allowed data key */
4825681Ssam #define	NCKEY	(MAXCKEY+1)	/* # code keys, including 0 (reserved) */
4925681Ssam #define	NDKEY	(MAXDKEY+1)	/* # data keys, including 0 (reserved) */
5025681Ssam 
5125681Ssam /*
5225681Ssam  * Some macros for units conversion
5325681Ssam  */
5425681Ssam /* Core clicks (1024 bytes) to segments and vice versa */
5525681Ssam #define	ctos(x)	(x)
5625681Ssam #define	stoc(x)	(x)
5725681Ssam 
5825681Ssam /* Core clicks (1024 bytes) to disk blocks */
5925681Ssam #define	ctod(x)	(x)
6025681Ssam #define	dtoc(x)	(x)
6125681Ssam #define	dtob(x)	((x)<<PGSHIFT)
6225681Ssam 
6325681Ssam /* clicks to bytes */
6425681Ssam #define	ctob(x)	((x)<<PGSHIFT)
6525681Ssam 
6625681Ssam /* bytes to clicks */
6725681Ssam #define	btoc(x)	((((unsigned)(x)+NBPG-1) >> PGSHIFT))
6825681Ssam 
69*30407Skarels #define	btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
70*30407Skarels 	((unsigned)(bytes) >> DEV_BSHIFT)
71*30407Skarels #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
72*30407Skarels 	((unsigned)(db) << DEV_BSHIFT)
73*30407Skarels 
7425681Ssam /*
75*30407Skarels  * Map a ``block device block'' to a file system block.
76*30407Skarels  * This should be device dependent, and will be if we
77*30407Skarels  * add an entry to cdevsw/bdevsw for that purpose.
78*30407Skarels  * For now though just use DEV_BSIZE.
79*30407Skarels  */
80*30407Skarels #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
81*30407Skarels 
82*30407Skarels /*
8325681Ssam  * Macros to decode processor status word.
8425681Ssam  */
8525681Ssam #define	USERMODE(ps)	(((ps) & PSL_CURMOD) == PSL_CURMOD)
8625681Ssam #define	BASEPRI(ps)	(((ps) & PSL_IPL) == 0)
8725681Ssam 
8825681Ssam #define	DELAY(n)	{ register int N = 3*(n); while (--N > 0); }
8929950Skarels #endif
90