xref: /csrg-svn/sys/hp300/include/param.h (revision 45755)
1 /*
2  * Copyright (c) 1988 University of Utah.
3  * Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
4  * All rights reserved.
5  *
6  * This code is derived from software contributed to Berkeley by
7  * the Systems Programming Group of the University of Utah Computer
8  * Science Department.
9  *
10  * %sccs.include.redist.c%
11  *
12  * from: Utah $Hdr: machparam.h 1.11 89/08/14$
13  *
14  *	@(#)param.h	7.2 (Berkeley) 12/05/90
15  */
16 
17 /*
18  * Machine dependent constants for HP9000 series 300.
19  */
20 #define	MACHINE "hp300"
21 
22 #ifndef BYTE_ORDER
23 #include <machine/endian.h>
24 #endif
25 
26 #include <machine/machlimits.h>
27 
28 #define	NBPG		4096		/* bytes/page */
29 #define	PGOFSET		(NBPG-1)	/* byte offset into page */
30 #define	PGSHIFT		12		/* LOG2(NBPG) */
31 #define	NPTEPG		(NBPG/(sizeof (struct pte)))
32 
33 #define NBSEG		(1024*NBPG)	/* bytes/segment */
34 #define	SEGOFSET	(NBSEG-1)	/* byte offset into segment */
35 #define	SEGSHIFT	22		/* LOG2(NBSEG) */
36 
37 #define	KERNBASE	0x00000000	/* start of kernel virtual */
38 #define	BTOPKERNBASE	((u_long)KERNBASE >> PGSHIFT)
39 
40 #define	DEV_BSIZE	512
41 #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
42 #define BLKDEV_IOSIZE	2048
43 #define	MAXPHYS		(64 * 1024)	/* max raw I/O transfer size */
44 
45 #define	CLSIZE		1
46 #define	CLSIZELOG2	0
47 
48 #define	SSIZE		1		/* initial stack size/NBPG */
49 #define	SINCR		1		/* increment of stack/NBPG */
50 
51 #define	UPAGES		3		/* 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	1024
62 #define	MCLSHIFT	10
63 #define	MCLOFSET	(MCLBYTES - 1)
64 #ifndef NMBCLUSTERS
65 #ifdef GATEWAY
66 #define	NMBCLUSTERS	512		/* map size, max cluster allocation */
67 #else
68 #define	NMBCLUSTERS	256		/* map size, max cluster allocation */
69 #endif
70 #endif
71 
72 /*
73  * Size of kernel malloc arena in CLBYTES-sized logical pages
74  */
75 #ifndef NKMEMCLUSTERS
76 #define	NKMEMCLUSTERS	(512*1024/CLBYTES)
77 #endif
78 
79 /*
80  * Some macros for units conversion
81  */
82 /* Core clicks (4096 bytes) to segments and vice versa */
83 #define	ctos(x)	(x)
84 #define	stoc(x)	(x)
85 
86 /* Core clicks (4096 bytes) to disk blocks */
87 #define	ctod(x)	((x)<<(PGSHIFT-DEV_BSHIFT))
88 #define	dtoc(x)	((x)>>(PGSHIFT-DEV_BSHIFT))
89 #define	dtob(x)	((x)<<DEV_BSHIFT)
90 
91 /* clicks to bytes */
92 #define	ctob(x)	((x)<<PGSHIFT)
93 
94 /* bytes to clicks */
95 #define	btoc(x)	(((unsigned)(x)+(NBPG-1))>>PGSHIFT)
96 
97 #define	btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
98 	((unsigned)(bytes) >> DEV_BSHIFT)
99 #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
100 	((unsigned)(db) << DEV_BSHIFT)
101 
102 /*
103  * Map a ``block device block'' to a file system block.
104  * This should be device dependent, and will be if we
105  * add an entry to cdevsw/bdevsw for that purpose.
106  * For now though just use DEV_BSIZE.
107  */
108 #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
109 
110 /*
111  * Mach derived conversion macros
112  */
113 #define hp300_round_seg(x)	((((unsigned)(x)) + NBSEG - 1) & ~(NBSEG-1))
114 #define hp300_trunc_seg(x)	((unsigned)(x) & ~(NBSEG-1))
115 #define hp300_round_page(x)	((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1))
116 #define hp300_trunc_page(x)	((unsigned)(x) & ~(NBPG-1))
117 #define hp300_btos(x)		((unsigned)(x) >> SEGSHIFT)
118 #define hp300_stob(x)		((unsigned)(x) << SEGSHIFT)
119 #define hp300_btop(x)		((unsigned)(x) >> PGSHIFT)
120 #define hp300_ptob(x)		((unsigned)(x) << PGSHIFT)
121 
122 /*
123  * Macros to decode processor status word.
124  */
125 #define	USERMODE(ps)	(((ps) & PSL_S) == 0)
126 #define	BASEPRI(ps)	(((ps) & PSL_IPL7) == 0)
127 
128 #ifdef KERNEL
129 #ifndef LOCORE
130 int	cpuspeed;
131 #define	DELAY(n)	{ register int N = cpuspeed * (n); while (--N > 0); }
132 #endif
133 
134 #else KERNEL
135 #define	DELAY(n)	{ register int N = (n); while (--N > 0); }
136 #endif KERNEL
137 
138 #ifdef HPUXCOMPAT
139 /*
140  * Constants/macros for HPUX multiple mapping of user address space.
141  * Pages in the first 256Mb are mapped in at every 256Mb segment.
142  */
143 #define HPMMMASK	0xF0000000
144 #define ISHPMMADDR(v)	\
145     ((u.u_pcb.pcb_flags&PCB_HPUXMMAP) && ((unsigned)(v)&HPMMMASK) != HPMMMASK)
146 #define HPMMBASEADDR(v)	((unsigned)(v) & ~HPMMMASK)
147 #endif
148