xref: /csrg-svn/sys/sparc/include/param.h (revision 55121)
1 /*
2  * Copyright (c) 1992 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * This software was developed by the Computer Systems Engineering group
6  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
7  * contributed to Berkeley.
8  *
9  * %sccs.include.redist.c%
10  *
11  *	@(#)param.h	7.1 (Berkeley) 07/13/92
12  *
13  * from: $Header: param.h,v 1.11 92/06/24 08:52:05 torek Exp $ (LBL)
14  */
15 
16 /*
17  * Machine dependent constants for Sun-4c (SPARCstation)
18  */
19 #define	MACHINE	"sparc"
20 
21 #ifdef KERNEL				/* XXX */
22 #include "machine/cpu.h"		/* XXX */
23 #endif					/* XXX */
24 
25 /*
26  * Round p (pointer or byte index) up to a correctly-aligned value for
27  * the machine's strictest data type.  The result is u_int and must be
28  * cast to any desired pointer type.
29  */
30 #define	ALIGNBYTES	7
31 #define	ALIGN(p)	(((u_int)(p) + ALIGNBYTES) & ~ALIGNBYTES)
32 
33 #define	NBPG		4096		/* bytes/page */
34 #define	PGOFSET		(NBPG-1)	/* byte offset into page */
35 #define	PGSHIFT		12		/* log2(NBPG) */
36 
37 #define	KERNBASE	0xf8000000	/* start of kernel virtual space */
38 #define	KERNTEXTOFF	0xf8004000	/* start of kernel text */
39 #define	BTOPKERNBASE	((u_long)KERNBASE >> PG_SHIFT)
40 
41 #define	DEV_BSIZE	512
42 #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
43 #define	BLKDEV_IOSIZE	2048
44 #define	MAXPHYS		(64 * 1024)
45 
46 #define	CLSIZE		1
47 #define	CLSIZELOG2	0
48 
49 /* NOTE: SSIZE and UPAGES must be multiples of CLSIZE */
50 #define	SSIZE		1		/* initial stack size/NBPG */
51 #define	UPAGES		2		/* pages of u-area */
52 
53 /*
54  * Constants related to network buffer management.
55  * MCLBYTES must be no larger than CLBYTES (the software page size), and,
56  * on machines that exchange pages of input or output buffers with mbuf
57  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
58  * of the hardware page size.
59  */
60 #define	MSIZE		128		/* size of an mbuf */
61 #define	MCLBYTES	2048		/* enough for whole Ethernet packet */
62 #define	MCLSHIFT	11		/* log2(MCLBYTES) */
63 #define	MCLOFSET	(MCLBYTES - 1)
64 
65 #ifndef NMBCLUSTERS
66 #ifdef GATEWAY
67 #define	NMBCLUSTERS	512		/* map size, max cluster allocation */
68 #else
69 #define	NMBCLUSTERS	256		/* map size, max cluster allocation */
70 #endif
71 #endif
72 
73 /*
74  * Size of kernel malloc arena in CLBYTES-sized logical pages.
75  */
76 #ifndef	NKMEMCLUSTERS
77 #define	NKMEMCLUSTERS	(3 * 1024 * 1024 / CLBYTES)
78 #endif
79 
80 /* pages ("clicks") (4096 bytes) to disk blocks */
81 #define	ctod(x)	((x) << (PGSHIFT - DEV_BSHIFT))
82 #define	dtoc(x)	((x) >> (PGSHIFT - DEV_BSHIFT))
83 #define	dtob(x)	((x) << DEV_BSHIFT)
84 
85 /* pages to bytes */
86 #define	ctob(x)	((x) << PGSHIFT)
87 
88 /* bytes to pages */
89 #define	btoc(x)	(((unsigned)(x) + PGOFSET) >> PGSHIFT)
90 
91 #define	btodb(bytes)		/* calculates (bytes / DEV_BSIZE) */ \
92 	((unsigned)(bytes) >> DEV_BSHIFT)
93 #define	dbtob(db)		/* calculates (db * DEV_BSIZE) */ \
94 	((unsigned)(db) << DEV_BSHIFT)
95 
96 /*
97  * Map a ``block device block'' to a file system block.
98  * This should be device dependent, and should use the bsize
99  * field from the disk label.
100  * For now though just use DEV_BSIZE.
101  */
102 #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE / DEV_BSIZE))
103 
104 #ifdef KERNEL
105 #ifndef LOCORE
106 #define	DELAY(n)	delay(n)
107 #endif
108 #else
109 #define	DELAY(n)	{ register volatile int N = (n); while (--N > 0); }
110 #endif
111