Home | History | Annotate | Line # | Download | only in include
param.h revision 1.13
      1 /*      $NetBSD: param.h,v 1.13 1995/12/04 22:32:53 ragge Exp $    */
      2 
      3 /*-
      4  * Copyright (c) 1990 The Regents of the University of California.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to Berkeley by
      8  * William Jolitz.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *	This product includes software developed by the University of
     21  *	California, Berkeley and its contributors.
     22  * 4. Neither the name of the University nor the names of its contributors
     23  *    may be used to endorse or promote products derived from this software
     24  *    without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     36  * SUCH DAMAGE.
     37  *
     38  *	@(#)param.h	5.8 (Berkeley) 6/28/91
     39  */
     40 
     41 #ifndef _VAX_PARAM_H_
     42 #define _VAX_PARAM_H_
     43 
     44 #include "machine/macros.h"
     45 #include "machine/psl.h"
     46 
     47 /*
     48  * Machine dependent constants for VAX.
     49  */
     50 
     51 #define MACHINE		"vax"
     52 #define	MACHINE_ARCH	"vax"
     53 #define MID_MACHINE	MID_VAX
     54 
     55 /*
     56  * Round p (pointer or byte index) up to a correctly-aligned value
     57  * for all data types (int, long, ...).   The result is u_int and
     58  * must be cast to any desired pointer type.
     59  */
     60 
     61 #define ALIGNBYTES	(sizeof(int) - 1)
     62 #define ALIGN(p)	(((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
     63 
     64 #define	PGSHIFT	 9                             /* LOG2(NBPG) */
     65 #define	NBPG     (1<<PGSHIFT)                  /* (1 << PGSHIFT) bytes/page */
     66 #define	PGOFSET	 (NBPG-1)	               /* byte offset into page */
     67 #define	NPTEPG	 (NBPG/(sizeof (struct pte)))
     68 
     69 #define	KERNBASE     0x80000000	               /* start of kernel virtual */
     70 #define	BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT)
     71 
     72 #define	DEV_BSHIFT   9		               /* log2(DEV_BSIZE) */
     73 #define	DEV_BSIZE    (1 << DEV_BSHIFT)
     74 
     75 #define BLKDEV_IOSIZE 2048
     76 #define	MAXPHYS	      (63 * 1024)     /* max raw I/O transfer size */
     77 
     78 #define	CLSIZELOG2    1
     79 #define	CLSIZE	      2
     80 
     81 /* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */
     82 #define	SSIZE	4		/* initial stack size/NBPG */
     83 #define	SINCR	4		/* increment of stack/NBPG */
     84 
     85 #define	UPAGES	16		/* pages of u-area */
     86 #define USPACE  (NBPG*UPAGES)
     87 
     88 /*
     89  * Constants related to network buffer management.
     90  * MCLBYTES must be no larger than CLBYTES (the software page size), and,
     91  * on machines that exchange pages of input or output buffers with mbuf
     92  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
     93  * of the hardware page size.
     94  */
     95 
     96 #ifndef	MSIZE
     97 #define	MSIZE		128		/* size of an mbuf */
     98 #endif	/* MSIZE */
     99 
    100 #ifndef	MCLSHIFT
    101 #define	MCLSHIFT	10		/* convert bytes to m_buf clusters */
    102 #endif	/* MCLSHIFT */
    103 #define	MCLBYTES	(1 << MCLSHIFT)	/* size of an m_buf cluster */
    104 #define	MCLOFSET	(MCLBYTES - 1)	/* offset within an m_buf cluster */
    105 
    106 #ifndef NMBCLUSTERS
    107 #ifdef GATEWAY
    108 #define	NMBCLUSTERS	512		/* map size, max cluster allocation */
    109 #else
    110 #define	NMBCLUSTERS	256		/* map size, max cluster allocation */
    111 #endif	/* GATEWAY */
    112 #endif	/* NMBCLUSTERS */
    113 
    114 /*
    115  * Size of kernel malloc arena in CLBYTES-sized logical pages
    116  */
    117 
    118 #ifndef NKMEMCLUSTERS
    119 #define	NKMEMCLUSTERS	(2048*1024/CLBYTES)
    120 #endif
    121 
    122 /*
    123  * Some macros for units conversion
    124  */
    125 
    126 /* pages ("clicks") to disk blocks */
    127 #define	ctod(x)		((x) << (PGSHIFT - DEV_BSHIFT))
    128 #define	dtoc(x)		((x) >> (PGSHIFT - DEV_BSHIFT))
    129 
    130 /* clicks to bytes */
    131 #define	ctob(x)		((x) << PGSHIFT)
    132 #define	btoc(x)		(((x) + PGOFSET) >> PGSHIFT)
    133 #define	btop(x)		(((unsigned)(x)) >> PGSHIFT)
    134 
    135 /* bytes to disk blocks */
    136 #define	btodb(x)	((x) >> DEV_BSHIFT)
    137 #define	dbtob(x)	((x) << DEV_BSHIFT)
    138 
    139 /*
    140  * Map a ``block device block'' to a file system block.
    141  * This should be device dependent, and will be if we
    142  * add an entry to cdevsw/bdevsw for that purpose.
    143  * For now though just use DEV_BSIZE.
    144  */
    145 
    146 #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
    147 
    148 #define splx(reg)                                       \
    149 ({                                                      \
    150         register int val;                               \
    151         asm __volatile ("mfpr $0x12,%0;mtpr %1,$0x12"	\
    152                         : "=g" (val)                    \
    153                         : "g" (reg));                   \
    154         val;                                            \
    155 })
    156 
    157 
    158 #define	spl0()		splx(0)		/* IPL0  */
    159 #define splsoftclock()  splx(8)		/* IPL08 */
    160 #define splsoftnet()    splx(0xc)	/* IPL0C */
    161 #define	splddb()	splx(0xf)	/* IPL0F */
    162 #define spl4()          splx(0x14)	/* IPL14 */
    163 #define splbio()        splx(0x15)	/* IPL15 */
    164 #define splnet()        splx(0x15)	/* IPL15 */
    165 #define spltty()        splx(0x15)	/* IPL15 */
    166 #define splimp()        splx(0x16)	/* IPL16 */
    167 #define splclock()      splx(0x18)	/* IPL18 */
    168 #define splhigh()       splx(0x1f)	/* IPL1F */
    169 #define	splstatclock()	splclock()
    170 
    171 #define	ovbcopy(x,y,z)	bcopy(x,y,z)	/* This should work i hope... */
    172 
    173 #define vmapbuf(p,q)
    174 #define vunmapbuf(p,q)
    175 
    176 #define	DELAY(x) delay(x)
    177 
    178 #endif /* _VAX_PARAM_H_ */
    179