xref: /csrg-svn/sys/tahoe/include/param.h (revision 31107)
1*31107Skarels /*	param.h	1.8	87/05/12	*/
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
26*31107Skarels unsigned short	ntohs(), htons();
27*31107Skarels unsigned long	ntohl(), htonl();
2830402Skarels #endif
2930402Skarels 
3030407Skarels #define	NBPG		1024		/* bytes/page */
3130407Skarels #define	PGOFSET		(NBPG-1)	/* byte offset into page */
3230407Skarels #define	PGSHIFT		10		/* LOG2(NBPG) */
3330407Skarels #define	NPTEPG		(NBPG/(sizeof (struct pte)))
3425681Ssam 
3530752Skarels #define	KERNBASE	0xc0000000	/* start of kernel virtual */
3630752Skarels #define	BTOPKERNBASE	((u_long)KERNBASE >> PGSHIFT)
3730752Skarels 
3830407Skarels #define	DEV_BSIZE	1024
3930407Skarels #define	DEV_BSHIFT	10		/* log2(DEV_BSIZE) */
4030407Skarels #define BLKDEV_IOSIZE	1024		/* NBPG for physical controllers */
4130752Skarels #define	MAXPHYS		(64 * 1024)	/* max raw I/O transfer size */
4230407Skarels 
4325681Ssam #define	CLSIZE		1
4425681Ssam #define	CLSIZELOG2	0
4525681Ssam 
4630407Skarels #define	SSIZE		2		/* initial stack size/NBPG */
4730407Skarels #define	SINCR		2		/* increment of stack/NBPG */
4830407Skarels #define	UPAGES		6		/* pages of u-area (2 stack pages) */
4925681Ssam 
5025681Ssam #define	MAXCKEY	255		/* maximal allowed code key */
5125681Ssam #define	MAXDKEY	255		/* maximal allowed data key */
5225681Ssam #define	NCKEY	(MAXCKEY+1)	/* # code keys, including 0 (reserved) */
5325681Ssam #define	NDKEY	(MAXDKEY+1)	/* # data keys, including 0 (reserved) */
5425681Ssam 
5525681Ssam /*
5625681Ssam  * Some macros for units conversion
5725681Ssam  */
5825681Ssam /* Core clicks (1024 bytes) to segments and vice versa */
5925681Ssam #define	ctos(x)	(x)
6025681Ssam #define	stoc(x)	(x)
6125681Ssam 
6225681Ssam /* Core clicks (1024 bytes) to disk blocks */
6325681Ssam #define	ctod(x)	(x)
6425681Ssam #define	dtoc(x)	(x)
6525681Ssam #define	dtob(x)	((x)<<PGSHIFT)
6625681Ssam 
6725681Ssam /* clicks to bytes */
6825681Ssam #define	ctob(x)	((x)<<PGSHIFT)
6925681Ssam 
7025681Ssam /* bytes to clicks */
7125681Ssam #define	btoc(x)	((((unsigned)(x)+NBPG-1) >> PGSHIFT))
7225681Ssam 
7330407Skarels #define	btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
7430407Skarels 	((unsigned)(bytes) >> DEV_BSHIFT)
7530407Skarels #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
7630407Skarels 	((unsigned)(db) << DEV_BSHIFT)
7730407Skarels 
7825681Ssam /*
7930407Skarels  * Map a ``block device block'' to a file system block.
8030407Skarels  * This should be device dependent, and will be if we
8130407Skarels  * add an entry to cdevsw/bdevsw for that purpose.
8230407Skarels  * For now though just use DEV_BSIZE.
8330407Skarels  */
8430407Skarels #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
8530407Skarels 
8630407Skarels /*
8725681Ssam  * Macros to decode processor status word.
8825681Ssam  */
8925681Ssam #define	USERMODE(ps)	(((ps) & PSL_CURMOD) == PSL_CURMOD)
9025681Ssam #define	BASEPRI(ps)	(((ps) & PSL_IPL) == 0)
9125681Ssam 
9225681Ssam #define	DELAY(n)	{ register int N = 3*(n); while (--N > 0); }
9329950Skarels #endif
94