Home | History | Annotate | Line # | Download | only in include
param.h revision 1.3
      1 /*	$NetBSD: param.h,v 1.3 1994/10/26 08:02:18 cgd Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1990 The Regents of the University of California.
      5  * All rights reserved.
      6  *
      7  * Modified for VAX 940213/Ragge
      8  *
      9  * This code is derived from software contributed to Berkeley by
     10  * William Jolitz.
     11  *
     12  * Redistribution and use in source and binary forms, with or without
     13  * modification, are permitted provided that the following conditions
     14  * are met:
     15  * 1. Redistributions of source code must retain the above copyright
     16  *    notice, this list of conditions and the following disclaimer.
     17  * 2. Redistributions in binary form must reproduce the above copyright
     18  *    notice, this list of conditions and the following disclaimer in the
     19  *    documentation and/or other materials provided with the distribution.
     20  * 3. All advertising materials mentioning features or use of this software
     21  *    must display the following acknowledgement:
     22  *	This product includes software developed by the University of
     23  *	California, Berkeley and its contributors.
     24  * 4. Neither the name of the University nor the names of its contributors
     25  *    may be used to endorse or promote products derived from this software
     26  *    without specific prior written permission.
     27  *
     28  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     29  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     30  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     31  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     32  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     33  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     34  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     35  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     36  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     37  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     38  * SUCH DAMAGE.
     39  *
     40  *	@(#)param.h	5.8 (Berkeley) 6/28/91
     41  */
     42 
     43 #ifndef PARAM_H
     44 #define PARAM_H
     45 
     46 #include "psl.h"
     47 
     48 /*
     49  * Machine dependent constants for VAX.
     50  */
     51 
     52 #define MACHINE		"vax"
     53 #define MID_MACHINE	MID_VAX
     54 #define UNIX		"vmunix"
     55 
     56 /*
     57  * Round p (pointer or byte index) up to a correctly-aligned value
     58  * for all data types (int, long, ...).   The result is u_int and
     59  * must be cast to any desired pointer type.
     60  */
     61 
     62 #define ALIGNBYTES	(sizeof(int) - 1)
     63 #define ALIGN(p)	(((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
     64 
     65 #define	PGSHIFT	 9                             /* LOG2(NBPG) */
     66 #define	NBPG     (1<<PGSHIFT)                  /* (1 << PGSHIFT) bytes/page */
     67 #define	PGOFSET	 (NBPG-1)	               /* byte offset into page */
     68 #define	NPTEPG	 (NBPG/(sizeof (struct pte)))
     69 
     70 #define	KERNBASE     0x80000000	               /* start of kernel virtual */
     71 #define	BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT)
     72 
     73 #define	DEV_BSHIFT   9		               /* log2(DEV_BSIZE) */
     74 #define	DEV_BSIZE    (1 << DEV_BSHIFT)
     75 
     76 #define BLKDEV_IOSIZE 2048
     77 #define	MAXPHYS	      (63 * 1024)     /* max raw I/O transfer size */
     78 
     79 #define	CLSIZELOG2    1
     80 #define	CLSIZE	      2
     81 
     82 /* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */
     83 #define	SSIZE	4		/* initial stack size/NBPG */
     84 #define	SINCR	4		/* increment of stack/NBPG */
     85 
     86 #define	UPAGES	16		/* pages of u-area */
     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	(512*1024/CLBYTES)
    120 #endif
    121 
    122 /*
    123  * Some macros for units conversion
    124  */
    125 
    126 /* Core clicks (512 bytes) to segments and vice versa */
    127 
    128 #define	ctos(x)	(x)
    129 #define	stoc(x)	(x)
    130 
    131 /* Core clicks (512 bytes) to disk blocks */
    132 
    133 #define	ctod(x)	((x)<<(PGSHIFT-DEV_BSHIFT))
    134 #define	dtoc(x)	((x)>>(PGSHIFT-DEV_BSHIFT))
    135 #define	dtob(x)	((x)<<DEV_BSHIFT)
    136 
    137 /* clicks to bytes */
    138 
    139 #define	ctob(x)	((x)<<PGSHIFT)
    140 
    141 /* bytes to clicks */
    142 
    143 #define	btoc(x)	(((unsigned)(x)+(NBPG-1))>>PGSHIFT)
    144 
    145 #define	btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
    146 	((unsigned)(bytes) >> DEV_BSHIFT)
    147 #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
    148 	((unsigned)(db) << DEV_BSHIFT)
    149 
    150 /*
    151  * Map a ``block device block'' to a file system block.
    152  * This should be device dependent, and will be if we
    153  * add an entry to cdevsw/bdevsw for that purpose.
    154  * For now though just use DEV_BSIZE.
    155  */
    156 
    157 #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
    158 
    159 /*
    160  * Mach derived conversion macros
    161  */
    162 
    163 #define vax_round_pdr(x)	((((unsigned)(x)) + NBPDR - 1) & ~(NBPDR-1))
    164 #define vax_trunc_pdr(x)	((unsigned)(x) & ~(NBPDR-1))
    165 #define vax_round_page(x)	((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1))
    166 #define vax_trunc_page(x)	((unsigned)(x) & ~(NBPG-1))
    167 #define vax_btod(x)		((unsigned)(x) >> PDRSHIFT)
    168 #define vax_dtob(x)		((unsigned)(x) << PDRSHIFT)
    169 #define vax_btop(x)		((unsigned)(x) >> PGSHIFT)
    170 #define vax_ptob(x)		((unsigned)(x) << PGSHIFT)
    171 
    172 #define DELAY(x)		kern_delay(x)
    173 
    174 /*
    175 #define _spl(s) \
    176 ({ \
    177         register int _spl_r; \
    178 \
    179         asm __volatile ("mfpr $18,%0; mtpr $%1,$18; " : \
    180                 "&=r" (_spl_r) : "ir" (s)); \
    181         _spl_r; \
    182 })
    183 */
    184 
    185 /* spl0 requires checking for software interrupts */
    186 
    187 
    188 #define splsoftclock()  _spl(PSL2IPL(PSL_IPL08))
    189 #define splnet()        _spl(PSL2IPL(PSL_IPL0C))
    190 #define spl4()          _spl(PSL2IPL(PSL_IPL14))
    191 #define spltty()        _spl(PSL2IPL(PSL_IPL15))
    192 #define splbio()        _spl(PSL2IPL(PSL_IPL15))
    193 #define splimp()        _spl(PSL2IPL(PSL_IPL16))
    194 #define splclock()      _spl(PSL2IPL(PSL_IPL18))
    195 #define splhigh()       _spl(PSL2IPL(PSL_IPL1F))
    196 #define	splstatclock()	splclock()
    197 /*
    198 #define splvm()         _spl(PSL2IPL(PSL_IPL14))
    199 #define splsched()      _spl(PSL2IPL(PSL_IPL14))
    200 */
    201 
    202 /* watch out for side effects */
    203 #define splx(s)         (s ? _spl(s) : spl0())
    204 
    205 #define	ovbcopy(x,y,z)	bcopy(x,y,z)	/* This should work i hope... */
    206 
    207 #endif
    208