xref: /original-bsd/sys/i386/include/param.h (revision 95a66346)
1 /*-
2  * Copyright (c) 1990 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * William Jolitz.
7  *
8  * %sccs.include.redist.c%
9  *
10  *	@(#)param.h	5.3 (Berkeley) 01/18/91
11  */
12 
13 /*
14  * Machine dependent constants for Intel 386.
15  */
16 
17 #define MACHINE "i386"
18 
19 #define	NBPG		4096		/* bytes/page */
20 #define	PGOFSET		(NBPG-1)	/* byte offset into page */
21 #define	PGSHIFT		12		/* LOG2(NBPG) */
22 #define	NPTEPG		(NBPG/(sizeof (struct pte)))
23 
24 #define NBPDR		(1024*NBPG)	/* bytes/page dir */
25 #define	PDROFSET	(NBPDR-1)	/* byte offset into page dir */
26 #define	PDRSHIFT	22		/* LOG2(NBPDR) */
27 
28 #define	KERNBASE	0xFE000000	/* start of kernel virtual */
29 #define	BTOPKERNBASE	((u_long)KERNBASE >> PGSHIFT)
30 
31 #define	DEV_BSIZE	512
32 #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
33 #define BLKDEV_IOSIZE	2048
34 #define	MAXPHYS		(64 * 1024)	/* max raw I/O transfer size */
35 
36 #define	CLSIZE		1
37 #define	CLSIZELOG2	0
38 
39 #define	SSIZE	1		/* initial stack size/NBPG */
40 #define	SINCR	1		/* increment of stack/NBPG */
41 
42 #define	UPAGES	2		/* pages of u-area */
43 
44 /*
45  * Constants related to network buffer management.
46  * MCLBYTES must be no larger than CLBYTES (the software page size), and,
47  * on machines that exchange pages of input or output buffers with mbuf
48  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
49  * of the hardware page size.
50  */
51 #define	MSIZE		128		/* size of an mbuf */
52 #define	MCLBYTES	1024
53 #define	MCLSHIFT	10
54 #define	MCLOFSET	(MCLBYTES - 1)
55 #ifndef NMBCLUSTERS
56 #ifdef GATEWAY
57 #define	NMBCLUSTERS	512		/* map size, max cluster allocation */
58 #else
59 #define	NMBCLUSTERS	256		/* map size, max cluster allocation */
60 #endif
61 #endif
62 
63 /*
64  * Size of kernel malloc arena in CLBYTES-sized logical pages
65  */
66 #ifndef NKMEMCLUSTERS
67 #define	NKMEMCLUSTERS	(512*1024/CLBYTES)
68 #endif
69 /*
70  * Some macros for units conversion
71  */
72 /* Core clicks (4096 bytes) to segments and vice versa */
73 #define	ctos(x)	(x)
74 #define	stoc(x)	(x)
75 
76 /* Core clicks (4096 bytes) to disk blocks */
77 #define	ctod(x)	((x)<<(PGSHIFT-DEV_BSHIFT))
78 #define	dtoc(x)	((x)>>(PGSHIFT-DEV_BSHIFT))
79 #define	dtob(x)	((x)<<DEV_BSHIFT)
80 
81 /* clicks to bytes */
82 #define	ctob(x)	((x)<<PGSHIFT)
83 
84 /* bytes to clicks */
85 #define	btoc(x)	(((unsigned)(x)+(NBPG-1))>>PGSHIFT)
86 
87 #define	btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
88 	((unsigned)(bytes) >> DEV_BSHIFT)
89 #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
90 	((unsigned)(db) << DEV_BSHIFT)
91 
92 /*
93  * Map a ``block device block'' to a file system block.
94  * This should be device dependent, and will be if we
95  * add an entry to cdevsw/bdevsw for that purpose.
96  * For now though just use DEV_BSIZE.
97  */
98 #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
99 
100 #ifdef KERNEL
101 #ifndef LOCORE
102 int	cpuspeed;
103 #endif
104 #define	DELAY(n)	{ register int N = cpuspeed * (n); while (--N > 0); }
105 
106 #else KERNEL
107 #define	DELAY(n)	{ register int N = (n); while (--N > 0); }
108 #endif KERNEL
109