153899Smckusick /*
253899Smckusick * Copyright (c) 1988 University of Utah.
363306Sbostic * Copyright (c) 1992, 1993
463306Sbostic * The Regents of the University of California. All rights reserved.
553899Smckusick *
653899Smckusick * This code is derived from software contributed to Berkeley by
753899Smckusick * the Systems Programming Group of the University of Utah Computer
853899Smckusick * Science Department and Ralph Campbell.
953899Smckusick *
1053899Smckusick * %sccs.include.redist.c%
1153899Smckusick *
1253899Smckusick * from: Utah $Hdr: machparam.h 1.11 89/08/14$
1353899Smckusick *
14*69465Smckusick * @(#)param.h 8.3 (Berkeley) 05/14/95
1553899Smckusick */
1653899Smckusick
1753899Smckusick /*
1853899Smckusick * Machine dependent constants for DEC Station 3100.
1953899Smckusick */
2058616Sutashiro #define MACHINE "news3400"
21*69465Smckusick #define NCPUS 1
2253899Smckusick #define COFF
2353899Smckusick
2453899Smckusick /*
2553899Smckusick * Round p (pointer or byte index) up to a correctly-aligned value for all
2653899Smckusick * data types (int, long, ...). The result is u_int and must be cast to
2753899Smckusick * any desired pointer type.
2853899Smckusick */
2958616Sutashiro #define ALIGNBYTES 7
3057185Sutashiro #define ALIGN(p) (((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
3153899Smckusick
3253899Smckusick #define NBPG 4096 /* bytes/page */
3353899Smckusick #define PGOFSET (NBPG-1) /* byte offset into page */
3453899Smckusick #define PGSHIFT 12 /* LOG2(NBPG) */
3553899Smckusick #define NPTEPG (NBPG/4)
3653899Smckusick
3760003Sutashiro #define NBSEG 0x400000 /* bytes/segment */
3860003Sutashiro #define SEGOFSET (NBSEG-1) /* byte offset into segment */
3960003Sutashiro #define SEGSHIFT 22 /* LOG2(NBSEG) */
4060003Sutashiro
4153899Smckusick #define KERNBASE 0x80000000 /* start of kernel virtual */
4253899Smckusick #define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT)
4353899Smckusick
4453899Smckusick #define DEV_BSIZE 512
4553899Smckusick #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
4653899Smckusick #define BLKDEV_IOSIZE 2048
4760003Sutashiro #define MAXPHYS (128 * 1024) /* max raw I/O transfer size */
4853899Smckusick
4953899Smckusick #define CLSIZE 1
5053899Smckusick #define CLSIZELOG2 0
5153899Smckusick
5253899Smckusick /* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */
5353899Smckusick #define SSIZE 1 /* initial stack size/NBPG */
5453899Smckusick #define SINCR 1 /* increment of stack/NBPG */
5553899Smckusick
5653899Smckusick #define UPAGES 2 /* pages of u-area */
5758616Sutashiro #define UADDR 0xffffd000 /* address of u */
5853899Smckusick #define UVPN (UADDR>>PGSHIFT)/* virtual page number of u */
5958616Sutashiro #define KERNELSTACK (UADDR+UPAGES*NBPG) /* top of kernel stack */
6053899Smckusick
6153899Smckusick /*
6253899Smckusick * Constants related to network buffer management.
6353899Smckusick * MCLBYTES must be no larger than CLBYTES (the software page size), and,
6453899Smckusick * on machines that exchange pages of input or output buffers with mbuf
6553899Smckusick * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
6653899Smckusick * of the hardware page size.
6753899Smckusick */
6853899Smckusick #define MSIZE 128 /* size of an mbuf */
6953899Smckusick #define MCLBYTES 1024
7053899Smckusick #define MCLSHIFT 10
7153899Smckusick #define MCLOFSET (MCLBYTES - 1)
7253899Smckusick #ifndef NMBCLUSTERS
7353899Smckusick #ifdef GATEWAY
7453899Smckusick #define NMBCLUSTERS 512 /* map size, max cluster allocation */
7553899Smckusick #else
7653899Smckusick #define NMBCLUSTERS 256 /* map size, max cluster allocation */
7753899Smckusick #endif
7853899Smckusick #endif
7953899Smckusick
8053899Smckusick /*
8153899Smckusick * Size of kernel malloc arena in CLBYTES-sized logical pages
8253899Smckusick */
8353899Smckusick #ifndef NKMEMCLUSTERS
8453899Smckusick #define NKMEMCLUSTERS (2048*1024/CLBYTES)
8553899Smckusick #endif
8653899Smckusick
8753899Smckusick /* pages ("clicks") (4096 bytes) to disk blocks */
8853899Smckusick #define ctod(x) ((x)<<(PGSHIFT-DEV_BSHIFT))
8953899Smckusick #define dtoc(x) ((x)>>(PGSHIFT-DEV_BSHIFT))
9053899Smckusick #define dtob(x) ((x)<<DEV_BSHIFT)
9153899Smckusick
9253899Smckusick /* pages to bytes */
9353899Smckusick #define ctob(x) ((x)<<PGSHIFT)
9453899Smckusick
9553899Smckusick /* bytes to pages */
9653899Smckusick #define btoc(x) (((unsigned)(x)+(NBPG-1))>>PGSHIFT)
9753899Smckusick
9853899Smckusick #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \
9968635Smckusick ((bytes) >> DEV_BSHIFT)
10053899Smckusick #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \
10168635Smckusick ((db) << DEV_BSHIFT)
10253899Smckusick
10353899Smckusick /*
10453899Smckusick * Map a ``block device block'' to a file system block.
10553899Smckusick * This should be device dependent, and should use the bsize
10653899Smckusick * field from the disk label.
10753899Smckusick * For now though just use DEV_BSIZE.
10853899Smckusick */
10953899Smckusick #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
11053899Smckusick
11153899Smckusick /*
11253899Smckusick * Mach derived conversion macros
11353899Smckusick */
11453899Smckusick #define pmax_round_page(x) ((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1))
11553899Smckusick #define pmax_trunc_page(x) ((unsigned)(x) & ~(NBPG-1))
11653899Smckusick #define pmax_btop(x) ((unsigned)(x) >> PGSHIFT)
11753899Smckusick #define pmax_ptob(x) ((unsigned)(x) << PGSHIFT)
11853899Smckusick
11953899Smckusick #ifdef news3400
12053899Smckusick #define splnet spl2
12153899Smckusick #define splsoftclock spl2
12253899Smckusick #define splbio spl3
12353899Smckusick #define spltty spl4
12453899Smckusick #define splimp spl4
12553899Smckusick #define splclock spl5
12655765Sbostic #define splstatclock spl5
12753899Smckusick #endif /* news3400 */
12853899Smckusick
12953899Smckusick #ifdef KERNEL
13053899Smckusick #ifndef LOCORE
13153899Smckusick extern int cpuspeed;
13253899Smckusick #define DELAY(n) { register int N = cpuspeed * (n) / 2; while (--N > 0); }
13353899Smckusick #endif
13453899Smckusick #else /* !KERNEL */
13553899Smckusick #define DELAY(n) { register int N = (n); while (--N > 0); }
13653899Smckusick #endif /* !KERNEL */
13753899Smckusick
13853899Smckusick #ifndef LOCORE
13953899Smckusick extern int intrcnt[];
14053899Smckusick extern char *intrnames[];
14153899Smckusick #endif /* !LOCORE */
14253899Smckusick
14353899Smckusick #define INTR_CLOCK 0
14453899Smckusick #define INTR_SOFTCLK 1
14553899Smckusick #define INTR_SOFTINT 2
14653899Smckusick #define INTR_AST 3
14753899Smckusick #define INTR_SCSI00 4
14853899Smckusick #define INTR_SCSI01 5
14953899Smckusick #define INTR_SCSI02 6
15053899Smckusick #define INTR_SCSI03 7
15153899Smckusick #define INTR_SCSI04 8
15253899Smckusick #define INTR_SCSI05 9
15353899Smckusick #define INTR_SCSI06 10
15453899Smckusick #define INTR_SCSI07 11
15553899Smckusick #define INTR_SCSI10 12
15653899Smckusick #define INTR_SCSI11 13
15753899Smckusick #define INTR_SCSI12 14
15853899Smckusick #define INTR_SCSI13 15
15953899Smckusick #define INTR_SCSI14 16
16053899Smckusick #define INTR_SCSI15 17
16153899Smckusick #define INTR_SCSI16 18
16253899Smckusick #define INTR_SCSI17 19
16353899Smckusick #define INTR_ETHER0 20
16453899Smckusick #define INTR_ETHER1 21
16553899Smckusick #define INTR_ETHER2 22
16653899Smckusick #define INTR_VME2 23
16753899Smckusick #define INTR_VME4 24
16853899Smckusick #define INTR_RS0 25
16953899Smckusick #define INTR_RS1 26
17053899Smckusick #define INTR_RS2 27
17153899Smckusick #define INTR_RS3 28
17253899Smckusick #define INTR_RS4 29
17353899Smckusick #define INTR_RS5 30
17453899Smckusick #define INTR_RS6 31
17553899Smckusick #define INTR_RS7 32
17653899Smckusick #define INTR_RS8 33
17753899Smckusick #define INTR_RS9 34
17853899Smckusick #define INTR_RS10 35
17953899Smckusick #define INTR_RS11 36
18053899Smckusick #define INTR_PRINTER 37
18153899Smckusick #define INTR_FD 38
18253899Smckusick #define INTR_AUDIO 39
18353899Smckusick #define INTR_KEYBOARD 40
18453899Smckusick #define INTR_MOUSE 41
18553899Smckusick #define INTR_BITMAP 42
18653899Smckusick #define INTR_FDDI 43
18753899Smckusick #define INTR_RENDER 44
18853899Smckusick
18953899Smckusick #define NINTRSLOT 45 /* # of intrcnt[] slot */
190*69465Smckusick
191*69465Smckusick #ifndef _SIMPLELOCK_H_
192*69465Smckusick #define _SIMPLELOCK_H_
193*69465Smckusick /*
194*69465Smckusick * A simple spin lock.
195*69465Smckusick *
196*69465Smckusick * This structure only sets one bit of data, but is sized based on the
197*69465Smckusick * minimum word size that can be operated on by the hardware test-and-set
198*69465Smckusick * instruction. It is only needed for multiprocessors, as uniprocessors
199*69465Smckusick * will always run to completion or a sleep. It is an error to hold one
200*69465Smckusick * of these locks while a process is sleeping.
201*69465Smckusick */
202*69465Smckusick struct simplelock {
203*69465Smckusick int lock_data;
204*69465Smckusick };
205*69465Smckusick
206*69465Smckusick #if !defined(DEBUG) && NCPUS > 1
207*69465Smckusick /*
208*69465Smckusick * The simple-lock routines are the primitives out of which the lock
209*69465Smckusick * package is built. The machine-dependent code must implement an
210*69465Smckusick * atomic test_and_set operation that indivisibly sets the simple lock
211*69465Smckusick * to non-zero and returns its old value. It also assumes that the
212*69465Smckusick * setting of the lock to zero below is indivisible. Simple locks may
213*69465Smckusick * only be used for exclusive locks.
214*69465Smckusick */
215*69465Smckusick static __inline void
simple_lock_init(lkp)216*69465Smckusick simple_lock_init(lkp)
217*69465Smckusick struct simplelock *lkp;
218*69465Smckusick {
219*69465Smckusick
220*69465Smckusick lkp->lock_data = 0;
221*69465Smckusick }
222*69465Smckusick
223*69465Smckusick static __inline void
simple_lock(lkp)224*69465Smckusick simple_lock(lkp)
225*69465Smckusick __volatile struct simplelock *lkp;
226*69465Smckusick {
227*69465Smckusick
228*69465Smckusick while (test_and_set(&lkp->lock_data))
229*69465Smckusick continue;
230*69465Smckusick }
231*69465Smckusick
232*69465Smckusick static __inline int
simple_lock_try(lkp)233*69465Smckusick simple_lock_try(lkp)
234*69465Smckusick __volatile struct simplelock *lkp;
235*69465Smckusick {
236*69465Smckusick
237*69465Smckusick return (!test_and_set(&lkp->lock_data))
238*69465Smckusick }
239*69465Smckusick
240*69465Smckusick static __inline void
241*69465Smckusick simple_unlock(lkp)
242*69465Smckusick __volatile struct simplelock *lkp;
243*69465Smckusick {
244*69465Smckusick
245*69465Smckusick lkp->lock_data = 0;
246*69465Smckusick }
247*69465Smckusick #endif /* NCPUS > 1 */
248*69465Smckusick #endif /* !_SIMPLELOCK_H_ */
249