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