xref: /csrg-svn/sys/tahoe/include/param.h (revision 30752)
1 /*	param.h	1.6.1.1	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 #ifndef SECSIZE
39 #define	DEV_BSIZE	1024
40 #define	DEV_BSHIFT	10		/* log2(DEV_BSIZE) */
41 #define BLKDEV_IOSIZE	1024		/* NBPG for physical controllers */
42 #else SECSIZE
43 /*
44  * Devices without disk labels and the swap virtual device
45  * use "blocks" of exactly pagesize.  Devices with disk labels
46  * use device-dependent sector sizes for block and character interfaces.
47  */
48 #define	DEV_BSIZE	NBPG
49 #define	DEV_BSHIFT	PGSHIFT		/* log2(DEV_BSIZE) */
50 #define BLKDEV_IOSIZE	NBPG		/* NBPG for unlabeled block devices */
51 #endif SECSIZE
52 #define	MAXPHYS		(64 * 1024)	/* max raw I/O transfer size */
53 
54 #define	CLSIZE		1
55 #define	CLSIZELOG2	0
56 
57 #define	SSIZE		2		/* initial stack size/NBPG */
58 #define	SINCR		2		/* increment of stack/NBPG */
59 #define	UPAGES		6		/* pages of u-area (2 stack pages) */
60 
61 #define	MAXCKEY	255		/* maximal allowed code key */
62 #define	MAXDKEY	255		/* maximal allowed data key */
63 #define	NCKEY	(MAXCKEY+1)	/* # code keys, including 0 (reserved) */
64 #define	NDKEY	(MAXDKEY+1)	/* # data keys, including 0 (reserved) */
65 
66 /*
67  * Some macros for units conversion
68  */
69 /* Core clicks (1024 bytes) to segments and vice versa */
70 #define	ctos(x)	(x)
71 #define	stoc(x)	(x)
72 
73 #ifndef SECSIZE
74 /* Core clicks (1024 bytes) to disk blocks */
75 #define	ctod(x)	(x)
76 #define	dtoc(x)	(x)
77 #define	dtob(x)	((x)<<PGSHIFT)
78 #else SECSIZE
79 /* Core clicks (1024 bytes) to disk blocks; deprecated */
80 #define	ctod(x)	(x)				/* XXX */
81 #define	dtoc(x)	(x)				/* XXX */
82 #define	dtob(x)	((x)<<PGSHIFT)			/* XXX */
83 #endif SECSIZE
84 
85 /* clicks to bytes */
86 #define	ctob(x)	((x)<<PGSHIFT)
87 
88 /* bytes to clicks */
89 #define	btoc(x)	((((unsigned)(x)+NBPG-1) >> PGSHIFT))
90 
91 #ifndef SECSIZE
92 #define	btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
93 	((unsigned)(bytes) >> DEV_BSHIFT)
94 #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
95 	((unsigned)(db) << DEV_BSHIFT)
96 
97 /*
98  * Map a ``block device block'' to a file system block.
99  * This should be device dependent, and will be if we
100  * add an entry to cdevsw/bdevsw for that purpose.
101  * For now though just use DEV_BSIZE.
102  */
103 #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
104 #else SECSIZE
105 /* bytes to "disk blocks" and back; deprecated */
106 #define	btodb(bytes)	((unsigned)(bytes) >> DEV_BSHIFT)	/* XXX */
107 #define	dbtob(db)	((unsigned)(db) << DEV_BSHIFT)		/* XXX */
108 #endif SECSIZE
109 
110 /*
111  * Macros to decode processor status word.
112  */
113 #define	USERMODE(ps)	(((ps) & PSL_CURMOD) == PSL_CURMOD)
114 #define	BASEPRI(ps)	(((ps) & PSL_IPL) == 0)
115 
116 #define	DELAY(n)	{ register int N = 3*(n); while (--N > 0); }
117 #endif
118