xref: /csrg-svn/sys/i386/include/param.h (revision 40461)
1*40461Sbill /*
2*40461Sbill  * Machine dependent constants for Intel 386.
3*40461Sbill  */
4*40461Sbill 
5*40461Sbill #define MACHINE "i386"
6*40461Sbill 
7*40461Sbill #ifndef BYTE_ORDER
8*40461Sbill #include <machine/endian.h>
9*40461Sbill #endif
10*40461Sbill 
11*40461Sbill #define	NBPG		4096		/* bytes/page */
12*40461Sbill #define	PGOFSET		(NBPG-1)	/* byte offset into page */
13*40461Sbill #define	PGSHIFT		12		/* LOG2(NBPG) */
14*40461Sbill #define	NPTEPG		(NBPG/(sizeof (struct pte)))
15*40461Sbill 
16*40461Sbill #define NBPDR		(1024*NBPG)	/* bytes/page dir */
17*40461Sbill #define	PDROFSET	(NBPDR-1)	/* byte offset into page dir */
18*40461Sbill #define	PDRSHIFT	22		/* LOG2(NBPDR) */
19*40461Sbill 
20*40461Sbill #define	KERNBASE	0xFE000000	/* start of kernel virtual */
21*40461Sbill #define	BTOPKERNBASE	((u_long)KERNBASE >> PGSHIFT)
22*40461Sbill 
23*40461Sbill #define	DEV_BSIZE	512
24*40461Sbill #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
25*40461Sbill #define BLKDEV_IOSIZE	2048
26*40461Sbill #define	MAXPHYS		(64 * 1024)	/* max raw I/O transfer size */
27*40461Sbill 
28*40461Sbill #define	CLSIZE		1
29*40461Sbill #define	CLSIZELOG2	0
30*40461Sbill 
31*40461Sbill #define	SSIZE	1		/* initial stack size/NBPG */
32*40461Sbill #define	SINCR	1		/* increment of stack/NBPG */
33*40461Sbill 
34*40461Sbill #define	UPAGES	3		/* pages of u-area */
35*40461Sbill 
36*40461Sbill /*
37*40461Sbill  * Some macros for units conversion
38*40461Sbill  */
39*40461Sbill /* Core clicks (4096 bytes) to segments and vice versa */
40*40461Sbill #define	ctos(x)	(x)
41*40461Sbill #define	stoc(x)	(x)
42*40461Sbill 
43*40461Sbill /* Core clicks (4096 bytes) to disk blocks */
44*40461Sbill #define	ctod(x)	((x)<<(PGSHIFT-DEV_BSHIFT))
45*40461Sbill #define	dtoc(x)	((x)>>(PGSHIFT-DEV_BSHIFT))
46*40461Sbill #define	dtob(x)	((x)<<DEV_BSHIFT)
47*40461Sbill 
48*40461Sbill /* clicks to bytes */
49*40461Sbill #define	ctob(x)	((x)<<PGSHIFT)
50*40461Sbill 
51*40461Sbill /* bytes to clicks */
52*40461Sbill #define	btoc(x)	(((unsigned)(x)+(NBPG-1))>>PGSHIFT)
53*40461Sbill 
54*40461Sbill #define	btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
55*40461Sbill 	((unsigned)(bytes) >> DEV_BSHIFT)
56*40461Sbill #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
57*40461Sbill 	((unsigned)(db) << DEV_BSHIFT)
58*40461Sbill 
59*40461Sbill /*
60*40461Sbill  * Map a ``block device block'' to a file system block.
61*40461Sbill  * This should be device dependent, and will be if we
62*40461Sbill  * add an entry to cdevsw/bdevsw for that purpose.
63*40461Sbill  * For now though just use DEV_BSIZE.
64*40461Sbill  */
65*40461Sbill #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
66*40461Sbill 
67*40461Sbill #ifdef KERNEL
68*40461Sbill #ifndef LOCORE
69*40461Sbill int	cpuspeed;
70*40461Sbill #endif
71*40461Sbill #define	DELAY(n)	{ register int N = cpuspeed * (n); while (--N > 0); }
72*40461Sbill 
73*40461Sbill #else KERNEL
74*40461Sbill #define	DELAY(n)	{ register int N = (n); while (--N > 0); }
75*40461Sbill #endif KERNEL
76