xref: /original-bsd/sys/tahoe/include/param.h (revision a22df252)
1 /*	param.h	1.7	87/04/02	*/
2 
3 /*
4  * Machine dependent constants for TAHOE.
5  */
6 
7 #ifndef ENDIAN
8 /*
9  * Definitions for byte order,
10  * according to byte significance from low address to high.
11  */
12 #define	LITTLE	1234		/* least-significant byte first (vax) */
13 #define	BIG	4321		/* most-significant byte first */
14 #define	PDP	3412		/* LSB first in word, MSW first in long (pdp) */
15 #define	ENDIAN	BIG		/* byte order on tahoe */
16 
17 /*
18  * Macros for network/external number representation conversion.
19  */
20 #if ENDIAN == BIG && !defined(lint)
21 #define	ntohl(x)	(x)
22 #define	ntohs(x)	(x)
23 #define	htonl(x)	(x)
24 #define	htons(x)	(x)
25 #else
26 u_short	ntohs(), htons();
27 u_long	ntohl(), htonl();
28 #endif
29 
30 #define	NBPG		1024		/* bytes/page */
31 #define	PGOFSET		(NBPG-1)	/* byte offset into page */
32 #define	PGSHIFT		10		/* LOG2(NBPG) */
33 #define	NPTEPG		(NBPG/(sizeof (struct pte)))
34 
35 #define	KERNBASE	0xc0000000	/* start of kernel virtual */
36 #define	BTOPKERNBASE	((u_long)KERNBASE >> PGSHIFT)
37 
38 #define	DEV_BSIZE	1024
39 #define	DEV_BSHIFT	10		/* log2(DEV_BSIZE) */
40 #define BLKDEV_IOSIZE	1024		/* NBPG for physical controllers */
41 #define	MAXPHYS		(64 * 1024)	/* max raw I/O transfer size */
42 
43 #define	CLSIZE		1
44 #define	CLSIZELOG2	0
45 
46 #define	SSIZE		2		/* initial stack size/NBPG */
47 #define	SINCR		2		/* increment of stack/NBPG */
48 #define	UPAGES		6		/* pages of u-area (2 stack pages) */
49 
50 #define	MAXCKEY	255		/* maximal allowed code key */
51 #define	MAXDKEY	255		/* maximal allowed data key */
52 #define	NCKEY	(MAXCKEY+1)	/* # code keys, including 0 (reserved) */
53 #define	NDKEY	(MAXDKEY+1)	/* # data keys, including 0 (reserved) */
54 
55 /*
56  * Some macros for units conversion
57  */
58 /* Core clicks (1024 bytes) to segments and vice versa */
59 #define	ctos(x)	(x)
60 #define	stoc(x)	(x)
61 
62 /* Core clicks (1024 bytes) to disk blocks */
63 #define	ctod(x)	(x)
64 #define	dtoc(x)	(x)
65 #define	dtob(x)	((x)<<PGSHIFT)
66 
67 /* clicks to bytes */
68 #define	ctob(x)	((x)<<PGSHIFT)
69 
70 /* bytes to clicks */
71 #define	btoc(x)	((((unsigned)(x)+NBPG-1) >> PGSHIFT))
72 
73 #define	btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
74 	((unsigned)(bytes) >> DEV_BSHIFT)
75 #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
76 	((unsigned)(db) << DEV_BSHIFT)
77 
78 /*
79  * Map a ``block device block'' to a file system block.
80  * This should be device dependent, and will be if we
81  * add an entry to cdevsw/bdevsw for that purpose.
82  * For now though just use DEV_BSIZE.
83  */
84 #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
85 
86 /*
87  * Macros to decode processor status word.
88  */
89 #define	USERMODE(ps)	(((ps) & PSL_CURMOD) == PSL_CURMOD)
90 #define	BASEPRI(ps)	(((ps) & PSL_IPL) == 0)
91 
92 #define	DELAY(n)	{ register int N = 3*(n); while (--N > 0); }
93 #endif
94