xref: /original-bsd/sys/news3400/include/param.h (revision 0ac4996f)
1 /*
2  * Copyright (c) 1988 University of Utah.
3  * Copyright (c) 1992, 1993
4  *	The Regents of the University of California.  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 and Ralph Campbell.
9  *
10  * %sccs.include.redist.c%
11  *
12  * from: Utah $Hdr: machparam.h 1.11 89/08/14$
13  *
14  *	@(#)param.h	8.3 (Berkeley) 05/14/95
15  */
16 
17 /*
18  * Machine dependent constants for DEC Station 3100.
19  */
20 #define	MACHINE	"news3400"
21 #define NCPUS 1
22 #define COFF
23 
24 /*
25  * Round p (pointer or byte index) up to a correctly-aligned value for all
26  * data types (int, long, ...).   The result is u_int and must be cast to
27  * any desired pointer type.
28  */
29 #define	ALIGNBYTES	7
30 #define	ALIGN(p)	(((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
31 
32 #define	NBPG		4096		/* bytes/page */
33 #define	PGOFSET		(NBPG-1)	/* byte offset into page */
34 #define	PGSHIFT		12		/* LOG2(NBPG) */
35 #define	NPTEPG		(NBPG/4)
36 
37 #define NBSEG		0x400000	/* bytes/segment */
38 #define	SEGOFSET	(NBSEG-1)	/* byte offset into segment */
39 #define	SEGSHIFT	22		/* LOG2(NBSEG) */
40 
41 #define	KERNBASE	0x80000000	/* start of kernel virtual */
42 #define	BTOPKERNBASE	((u_long)KERNBASE >> PGSHIFT)
43 
44 #define	DEV_BSIZE	512
45 #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
46 #define BLKDEV_IOSIZE	2048
47 #define	MAXPHYS		(128 * 1024)	/* max raw I/O transfer size */
48 
49 #define	CLSIZE		1
50 #define	CLSIZELOG2	0
51 
52 /* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */
53 #define	SSIZE		1		/* initial stack size/NBPG */
54 #define	SINCR		1		/* increment of stack/NBPG */
55 
56 #define	UPAGES		2		/* pages of u-area */
57 #define	UADDR		0xffffd000	/* address of u */
58 #define	UVPN		(UADDR>>PGSHIFT)/* virtual page number of u */
59 #define	KERNELSTACK	(UADDR+UPAGES*NBPG)	/* top of kernel stack */
60 
61 /*
62  * Constants related to network buffer management.
63  * MCLBYTES must be no larger than CLBYTES (the software page size), and,
64  * on machines that exchange pages of input or output buffers with mbuf
65  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
66  * of the hardware page size.
67  */
68 #define	MSIZE		128		/* size of an mbuf */
69 #define	MCLBYTES	1024
70 #define	MCLSHIFT	10
71 #define	MCLOFSET	(MCLBYTES - 1)
72 #ifndef NMBCLUSTERS
73 #ifdef GATEWAY
74 #define	NMBCLUSTERS	512		/* map size, max cluster allocation */
75 #else
76 #define	NMBCLUSTERS	256		/* map size, max cluster allocation */
77 #endif
78 #endif
79 
80 /*
81  * Size of kernel malloc arena in CLBYTES-sized logical pages
82  */
83 #ifndef NKMEMCLUSTERS
84 #define	NKMEMCLUSTERS	(2048*1024/CLBYTES)
85 #endif
86 
87 /* pages ("clicks") (4096 bytes) to disk blocks */
88 #define	ctod(x)	((x)<<(PGSHIFT-DEV_BSHIFT))
89 #define	dtoc(x)	((x)>>(PGSHIFT-DEV_BSHIFT))
90 #define	dtob(x)	((x)<<DEV_BSHIFT)
91 
92 /* pages to bytes */
93 #define	ctob(x)	((x)<<PGSHIFT)
94 
95 /* bytes to pages */
96 #define	btoc(x)	(((unsigned)(x)+(NBPG-1))>>PGSHIFT)
97 
98 #define	btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
99 	((bytes) >> DEV_BSHIFT)
100 #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
101 	((db) << DEV_BSHIFT)
102 
103 /*
104  * Map a ``block device block'' to a file system block.
105  * This should be device dependent, and should use the bsize
106  * field from the disk label.
107  * For now though just use DEV_BSIZE.
108  */
109 #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
110 
111 /*
112  * Mach derived conversion macros
113  */
114 #define pmax_round_page(x)	((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1))
115 #define pmax_trunc_page(x)	((unsigned)(x) & ~(NBPG-1))
116 #define pmax_btop(x)		((unsigned)(x) >> PGSHIFT)
117 #define pmax_ptob(x)		((unsigned)(x) << PGSHIFT)
118 
119 #ifdef news3400
120 #define	splnet		spl2
121 #define	splsoftclock	spl2
122 #define	splbio		spl3
123 #define	spltty		spl4
124 #define	splimp		spl4
125 #define	splclock	spl5
126 #define	splstatclock	spl5
127 #endif /* news3400 */
128 
129 #ifdef KERNEL
130 #ifndef LOCORE
131 extern	int cpuspeed;
132 #define	DELAY(n)	{ register int N = cpuspeed * (n) / 2; while (--N > 0); }
133 #endif
134 #else /* !KERNEL */
135 #define	DELAY(n)	{ register int N = (n); while (--N > 0); }
136 #endif /* !KERNEL */
137 
138 #ifndef LOCORE
139 extern int	intrcnt[];
140 extern char	*intrnames[];
141 #endif /* !LOCORE */
142 
143 #define	INTR_CLOCK	0
144 #define	INTR_SOFTCLK	1
145 #define	INTR_SOFTINT	2
146 #define	INTR_AST	3
147 #define	INTR_SCSI00	4
148 #define	INTR_SCSI01	5
149 #define	INTR_SCSI02	6
150 #define	INTR_SCSI03	7
151 #define	INTR_SCSI04	8
152 #define	INTR_SCSI05	9
153 #define	INTR_SCSI06	10
154 #define	INTR_SCSI07	11
155 #define	INTR_SCSI10	12
156 #define	INTR_SCSI11	13
157 #define	INTR_SCSI12	14
158 #define	INTR_SCSI13	15
159 #define	INTR_SCSI14	16
160 #define	INTR_SCSI15	17
161 #define	INTR_SCSI16	18
162 #define	INTR_SCSI17	19
163 #define	INTR_ETHER0	20
164 #define	INTR_ETHER1	21
165 #define	INTR_ETHER2	22
166 #define	INTR_VME2	23
167 #define	INTR_VME4	24
168 #define	INTR_RS0	25
169 #define	INTR_RS1	26
170 #define	INTR_RS2	27
171 #define	INTR_RS3	28
172 #define	INTR_RS4	29
173 #define	INTR_RS5	30
174 #define	INTR_RS6	31
175 #define	INTR_RS7	32
176 #define	INTR_RS8	33
177 #define	INTR_RS9	34
178 #define	INTR_RS10	35
179 #define	INTR_RS11	36
180 #define	INTR_PRINTER	37
181 #define	INTR_FD		38
182 #define	INTR_AUDIO	39
183 #define	INTR_KEYBOARD	40
184 #define	INTR_MOUSE	41
185 #define	INTR_BITMAP	42
186 #define	INTR_FDDI	43
187 #define INTR_RENDER	44
188 
189 #define	NINTRSLOT	45		/* # of intrcnt[] slot */
190 
191 #ifndef _SIMPLELOCK_H_
192 #define _SIMPLELOCK_H_
193 /*
194  * A simple spin lock.
195  *
196  * This structure only sets one bit of data, but is sized based on the
197  * minimum word size that can be operated on by the hardware test-and-set
198  * instruction. It is only needed for multiprocessors, as uniprocessors
199  * will always run to completion or a sleep. It is an error to hold one
200  * of these locks while a process is sleeping.
201  */
202 struct simplelock {
203 	int	lock_data;
204 };
205 
206 #if !defined(DEBUG) && NCPUS > 1
207 /*
208  * The simple-lock routines are the primitives out of which the lock
209  * package is built. The machine-dependent code must implement an
210  * atomic test_and_set operation that indivisibly sets the simple lock
211  * to non-zero and returns its old value. It also assumes that the
212  * setting of the lock to zero below is indivisible. Simple locks may
213  * only be used for exclusive locks.
214  */
215 static __inline void
216 simple_lock_init(lkp)
217 	struct simplelock *lkp;
218 {
219 
220 	lkp->lock_data = 0;
221 }
222 
223 static __inline void
224 simple_lock(lkp)
225 	__volatile struct simplelock *lkp;
226 {
227 
228 	while (test_and_set(&lkp->lock_data))
229 		continue;
230 }
231 
232 static __inline int
233 simple_lock_try(lkp)
234 	__volatile struct simplelock *lkp;
235 {
236 
237 	return (!test_and_set(&lkp->lock_data))
238 }
239 
240 static __inline void
241 simple_unlock(lkp)
242 	__volatile struct simplelock *lkp;
243 {
244 
245 	lkp->lock_data = 0;
246 }
247 #endif /* NCPUS > 1 */
248 #endif /* !_SIMPLELOCK_H_ */
249