xref: /csrg-svn/sys/i386/include/param.h (revision 47999)
141058Swilliam /*-
241058Swilliam  * Copyright (c) 1990 The Regents of the University of California.
341058Swilliam  * All rights reserved.
441058Swilliam  *
541058Swilliam  * This code is derived from software contributed to Berkeley by
641058Swilliam  * William Jolitz.
741058Swilliam  *
846006Swilliam  * %sccs.include.redist.c%
941058Swilliam  *
10*47999Swilliam  *	@(#)param.h	5.4 (Berkeley) 04/15/91
1141058Swilliam  */
1241058Swilliam 
1340461Sbill /*
1440461Sbill  * Machine dependent constants for Intel 386.
1540461Sbill  */
1640461Sbill 
1740461Sbill #define MACHINE "i386"
1840461Sbill 
1940461Sbill #define	NBPG		4096		/* bytes/page */
2040461Sbill #define	PGOFSET		(NBPG-1)	/* byte offset into page */
2140461Sbill #define	PGSHIFT		12		/* LOG2(NBPG) */
2240461Sbill #define	NPTEPG		(NBPG/(sizeof (struct pte)))
2340461Sbill 
2440461Sbill #define NBPDR		(1024*NBPG)	/* bytes/page dir */
2540461Sbill #define	PDROFSET	(NBPDR-1)	/* byte offset into page dir */
2640461Sbill #define	PDRSHIFT	22		/* LOG2(NBPDR) */
2740461Sbill 
2840461Sbill #define	KERNBASE	0xFE000000	/* start of kernel virtual */
2940461Sbill #define	BTOPKERNBASE	((u_long)KERNBASE >> PGSHIFT)
3040461Sbill 
3140461Sbill #define	DEV_BSIZE	512
3240461Sbill #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
3340461Sbill #define BLKDEV_IOSIZE	2048
3440461Sbill #define	MAXPHYS		(64 * 1024)	/* max raw I/O transfer size */
3540461Sbill 
3640461Sbill #define	CLSIZE		1
3740461Sbill #define	CLSIZELOG2	0
3840461Sbill 
3940461Sbill #define	SSIZE	1		/* initial stack size/NBPG */
4040461Sbill #define	SINCR	1		/* increment of stack/NBPG */
4140461Sbill 
4241058Swilliam #define	UPAGES	2		/* pages of u-area */
4340461Sbill 
4440461Sbill /*
4545964Swilliam  * Constants related to network buffer management.
4645964Swilliam  * MCLBYTES must be no larger than CLBYTES (the software page size), and,
4745964Swilliam  * on machines that exchange pages of input or output buffers with mbuf
4845964Swilliam  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
4945964Swilliam  * of the hardware page size.
5045964Swilliam  */
5145964Swilliam #define	MSIZE		128		/* size of an mbuf */
5245964Swilliam #define	MCLBYTES	1024
5345964Swilliam #define	MCLSHIFT	10
5445964Swilliam #define	MCLOFSET	(MCLBYTES - 1)
5545964Swilliam #ifndef NMBCLUSTERS
5645964Swilliam #ifdef GATEWAY
5745964Swilliam #define	NMBCLUSTERS	512		/* map size, max cluster allocation */
5845964Swilliam #else
5945964Swilliam #define	NMBCLUSTERS	256		/* map size, max cluster allocation */
6045964Swilliam #endif
6145964Swilliam #endif
6245964Swilliam 
6345964Swilliam /*
6445964Swilliam  * Size of kernel malloc arena in CLBYTES-sized logical pages
6545964Swilliam  */
6645964Swilliam #ifndef NKMEMCLUSTERS
6745964Swilliam #define	NKMEMCLUSTERS	(512*1024/CLBYTES)
6845964Swilliam #endif
6945964Swilliam /*
7040461Sbill  * Some macros for units conversion
7140461Sbill  */
7240461Sbill /* Core clicks (4096 bytes) to segments and vice versa */
7340461Sbill #define	ctos(x)	(x)
7440461Sbill #define	stoc(x)	(x)
7540461Sbill 
7640461Sbill /* Core clicks (4096 bytes) to disk blocks */
7740461Sbill #define	ctod(x)	((x)<<(PGSHIFT-DEV_BSHIFT))
7840461Sbill #define	dtoc(x)	((x)>>(PGSHIFT-DEV_BSHIFT))
7940461Sbill #define	dtob(x)	((x)<<DEV_BSHIFT)
8040461Sbill 
8140461Sbill /* clicks to bytes */
8240461Sbill #define	ctob(x)	((x)<<PGSHIFT)
8340461Sbill 
8440461Sbill /* bytes to clicks */
8540461Sbill #define	btoc(x)	(((unsigned)(x)+(NBPG-1))>>PGSHIFT)
8640461Sbill 
8740461Sbill #define	btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
8840461Sbill 	((unsigned)(bytes) >> DEV_BSHIFT)
8940461Sbill #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
9040461Sbill 	((unsigned)(db) << DEV_BSHIFT)
9140461Sbill 
9240461Sbill /*
9340461Sbill  * Map a ``block device block'' to a file system block.
9440461Sbill  * This should be device dependent, and will be if we
9540461Sbill  * add an entry to cdevsw/bdevsw for that purpose.
9640461Sbill  * For now though just use DEV_BSIZE.
9740461Sbill  */
9840461Sbill #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
9940461Sbill 
100*47999Swilliam /*
101*47999Swilliam  * Mach derived conversion macros
102*47999Swilliam  */
103*47999Swilliam #define i386_round_pdr(x)	((((unsigned)(x)) + NBPDR - 1) & ~(NBPDR-1))
104*47999Swilliam #define i386_trunc_pdr(x)	((unsigned)(x) & ~(NBPDR-1))
105*47999Swilliam #define i386_round_page(x)	((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1))
106*47999Swilliam #define i386_trunc_page(x)	((unsigned)(x) & ~(NBPG-1))
107*47999Swilliam #define i386_btod(x)		((unsigned)(x) >> PDRSHIFT)
108*47999Swilliam #define i386_dtob(x)		((unsigned)(x) << PDRSHIFT)
109*47999Swilliam #define i386_btop(x)		((unsigned)(x) >> PGSHIFT)
110*47999Swilliam #define i386_ptob(x)		((unsigned)(x) << PGSHIFT)
111*47999Swilliam 
11240461Sbill #ifdef KERNEL
11340461Sbill #ifndef LOCORE
11440461Sbill int	cpuspeed;
11540461Sbill #endif
11640461Sbill #define	DELAY(n)	{ register int N = cpuspeed * (n); while (--N > 0); }
11740461Sbill 
11840461Sbill #else KERNEL
11940461Sbill #define	DELAY(n)	{ register int N = (n); while (--N > 0); }
12040461Sbill #endif KERNEL
121