Home | History | Annotate | Line # | Download | only in include
param.h revision 1.35.2.1
      1  1.35.2.1    perry /*      $NetBSD: param.h,v 1.35.2.1 1999/05/03 12:57:36 perry Exp $    */
      2       1.1    ragge /*-
      3       1.1    ragge  * Copyright (c) 1990 The Regents of the University of California.
      4       1.1    ragge  * All rights reserved.
      5       1.1    ragge  *
      6       1.1    ragge  * This code is derived from software contributed to Berkeley by
      7       1.1    ragge  * William Jolitz.
      8       1.1    ragge  *
      9       1.1    ragge  * Redistribution and use in source and binary forms, with or without
     10       1.1    ragge  * modification, are permitted provided that the following conditions
     11       1.1    ragge  * are met:
     12       1.1    ragge  * 1. Redistributions of source code must retain the above copyright
     13       1.1    ragge  *    notice, this list of conditions and the following disclaimer.
     14       1.1    ragge  * 2. Redistributions in binary form must reproduce the above copyright
     15       1.1    ragge  *    notice, this list of conditions and the following disclaimer in the
     16       1.1    ragge  *    documentation and/or other materials provided with the distribution.
     17       1.1    ragge  * 3. All advertising materials mentioning features or use of this software
     18       1.1    ragge  *    must display the following acknowledgement:
     19       1.1    ragge  *	This product includes software developed by the University of
     20       1.1    ragge  *	California, Berkeley and its contributors.
     21       1.1    ragge  * 4. Neither the name of the University nor the names of its contributors
     22       1.1    ragge  *    may be used to endorse or promote products derived from this software
     23       1.1    ragge  *    without specific prior written permission.
     24       1.1    ragge  *
     25       1.1    ragge  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     26       1.1    ragge  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     27       1.1    ragge  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     28       1.1    ragge  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     29       1.1    ragge  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     30       1.1    ragge  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     31       1.1    ragge  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     32       1.1    ragge  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     33       1.1    ragge  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     34       1.1    ragge  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     35       1.1    ragge  * SUCH DAMAGE.
     36       1.1    ragge  *
     37       1.3      cgd  *	@(#)param.h	5.8 (Berkeley) 6/28/91
     38       1.1    ragge  */
     39       1.1    ragge 
     40       1.4    ragge #ifndef _VAX_PARAM_H_
     41       1.4    ragge #define _VAX_PARAM_H_
     42       1.1    ragge 
     43       1.1    ragge /*
     44       1.1    ragge  * Machine dependent constants for VAX.
     45       1.1    ragge  */
     46       1.1    ragge 
     47      1.19      cgd #define	_MACHINE	vax
     48      1.17      cgd #define	MACHINE		"vax"
     49      1.19      cgd #define	_MACHINE_ARCH	vax
     50      1.13    ragge #define	MACHINE_ARCH	"vax"
     51      1.17      cgd #define	MID_MACHINE	MID_VAX
     52       1.1    ragge 
     53       1.1    ragge /*
     54       1.1    ragge  * Round p (pointer or byte index) up to a correctly-aligned value
     55       1.1    ragge  * for all data types (int, long, ...).   The result is u_int and
     56       1.1    ragge  * must be cast to any desired pointer type.
     57      1.23     fvdl  *
     58      1.23     fvdl  * ALIGNED_POINTER is a boolean macro that checks whether an address
     59      1.23     fvdl  * is valid to fetch data elements of type t from on this architecture.
     60      1.23     fvdl  * This does not reflect the optimal alignment, just the possibility
     61      1.23     fvdl  * (within reasonable limits).
     62      1.23     fvdl  *
     63       1.1    ragge  */
     64       1.1    ragge 
     65      1.23     fvdl #define ALIGNBYTES		(sizeof(int) - 1)
     66      1.23     fvdl #define ALIGN(p)		(((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
     67      1.23     fvdl #define ALIGNED_POINTER(p,t)	((((u_long)(p)) & (sizeof(t)-1)) == 0)
     68       1.1    ragge 
     69      1.34    ragge #define	PGSHIFT		12			/* LOG2(NBPG) */
     70      1.34    ragge #define	NBPG		(1 << PGSHIFT)		/* (1 << PGSHIFT) bytes/page */
     71      1.34    ragge #define	PGOFSET		(NBPG - 1)               /* byte offset into page */
     72       1.1    ragge 
     73      1.34    ragge #define	VAX_PGSHIFT	9
     74      1.34    ragge #define	VAX_NBPG	(1 << VAX_PGSHIFT)
     75      1.34    ragge #define	VAX_PGOFSET	(VAX_NBPG - 1)
     76       1.1    ragge 
     77      1.34    ragge #define	KERNBASE	0x80000000		/* start of kernel virtual */
     78       1.1    ragge 
     79      1.34    ragge #define	DEV_BSHIFT	9		               /* log2(DEV_BSIZE) */
     80      1.34    ragge #define	DEV_BSIZE	(1 << DEV_BSHIFT)
     81      1.34    ragge 
     82      1.34    ragge #define BLKDEV_IOSIZE	2048
     83      1.22    ragge #define	MAXPHYS		(63 * 1024)	/* max raw I/O transfer size */
     84      1.22    ragge #define	MAXBSIZE	0x4000		/* max FS block size - XXX */
     85       1.1    ragge 
     86      1.34    ragge #define	CLSIZELOG2	0		/* XXX - die */
     87      1.34    ragge #define	CLSIZE		1		/* XXX - die */
     88       1.1    ragge 
     89  1.35.2.1    perry #define	UPAGES		2		/* pages of u-area */
     90      1.34    ragge #define USPACE		(NBPG*UPAGES)
     91  1.35.2.1    perry #define	REDZONEADDR	(VAX_NBPG*3)	/* Must be > sizeof(struct user) */
     92      1.25      leo 
     93      1.25      leo #ifndef MSGBUFSIZE
     94      1.34    ragge #define MSGBUFSIZE	NBPG		/* default message buffer size */
     95      1.25      leo #endif
     96       1.1    ragge 
     97       1.1    ragge /*
     98       1.1    ragge  * Constants related to network buffer management.
     99      1.34    ragge  * MCLBYTES must be no larger than NBPG (the software page size), and,
    100       1.1    ragge  * on machines that exchange pages of input or output buffers with mbuf
    101       1.1    ragge  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
    102       1.1    ragge  * of the hardware page size.
    103       1.1    ragge  */
    104       1.1    ragge 
    105       1.1    ragge #ifndef	MSIZE
    106       1.1    ragge #define	MSIZE		128		/* size of an mbuf */
    107       1.1    ragge #endif	/* MSIZE */
    108       1.1    ragge 
    109       1.1    ragge #ifndef	MCLSHIFT
    110      1.32    ragge #define	MCLSHIFT	11		/* convert bytes to m_buf clusters */
    111       1.1    ragge #endif	/* MCLSHIFT */
    112       1.1    ragge #define	MCLBYTES	(1 << MCLSHIFT)	/* size of an m_buf cluster */
    113       1.1    ragge #define	MCLOFSET	(MCLBYTES - 1)	/* offset within an m_buf cluster */
    114       1.1    ragge 
    115       1.1    ragge #ifndef NMBCLUSTERS
    116      1.29  thorpej 
    117      1.29  thorpej #if defined(_KERNEL) && !defined(_LKM)
    118      1.29  thorpej #include "opt_gateway.h"
    119      1.29  thorpej #endif /* _KERNEL && ! _LKM */
    120      1.29  thorpej 
    121       1.1    ragge #ifdef GATEWAY
    122       1.1    ragge #define	NMBCLUSTERS	512		/* map size, max cluster allocation */
    123       1.1    ragge #else
    124       1.1    ragge #define	NMBCLUSTERS	256		/* map size, max cluster allocation */
    125       1.1    ragge #endif	/* GATEWAY */
    126       1.1    ragge #endif	/* NMBCLUSTERS */
    127       1.1    ragge 
    128       1.1    ragge /*
    129      1.34    ragge  * Size of kernel malloc arena in NBPG-sized logical pages
    130       1.1    ragge  */
    131       1.1    ragge 
    132       1.1    ragge #ifndef NKMEMCLUSTERS
    133      1.34    ragge #define	NKMEMCLUSTERS	(4096*1024/NBPG)
    134       1.1    ragge #endif
    135       1.1    ragge 
    136       1.1    ragge /*
    137       1.1    ragge  * Some macros for units conversion
    138       1.1    ragge  */
    139       1.1    ragge 
    140      1.10      cgd /* pages ("clicks") to disk blocks */
    141      1.34    ragge #define	ctod(x)		((x) << (PGSHIFT - DEV_BSHIFT))
    142      1.34    ragge #define	dtoc(x)		((x) >> (PGSHIFT - DEV_BSHIFT))
    143       1.1    ragge 
    144       1.1    ragge /* clicks to bytes */
    145      1.34    ragge #define	ctob(x)		((x) << PGSHIFT)
    146      1.34    ragge #define	btoc(x)		(((unsigned)(x) + PGOFSET) >> PGSHIFT)
    147      1.34    ragge #define	btop(x)		(((unsigned)(x)) >> PGSHIFT)
    148       1.1    ragge 
    149      1.10      cgd /* bytes to disk blocks */
    150      1.10      cgd #define	btodb(x)	((x) >> DEV_BSHIFT)
    151      1.10      cgd #define	dbtob(x)	((x) << DEV_BSHIFT)
    152       1.1    ragge 
    153      1.34    ragge /* MD conversion macros */
    154      1.34    ragge #define	vax_btoc(x)	(((unsigned)(x) + VAX_PGOFSET) >> VAX_PGSHIFT)
    155      1.34    ragge #define	vax_btop(x)	(((unsigned)(x)) >> VAX_PGSHIFT)
    156      1.33    ragge 
    157       1.1    ragge /*
    158       1.1    ragge  * Map a ``block device block'' to a file system block.
    159       1.1    ragge  * This should be device dependent, and will be if we
    160       1.1    ragge  * add an entry to cdevsw/bdevsw for that purpose.
    161       1.1    ragge  * For now though just use DEV_BSIZE.
    162       1.1    ragge  */
    163       1.1    ragge 
    164      1.35    ragge #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
    165       1.1    ragge 
    166      1.33    ragge #ifdef _KERNEL
    167      1.33    ragge #ifndef lint
    168       1.4    ragge #define splx(reg)                                       \
    169       1.4    ragge ({                                                      \
    170       1.4    ragge         register int val;                               \
    171      1.28  thorpej         __asm__ __volatile ("mfpr $0x12,%0;mtpr %1,$0x12"	\
    172      1.14    ragge                         : "&=g" (val)                   \
    173       1.4    ragge                         : "g" (reg));                   \
    174       1.4    ragge         val;                                            \
    175       1.1    ragge })
    176      1.33    ragge #endif
    177       1.1    ragge 
    178       1.4    ragge #define	spl0()		splx(0)		/* IPL0  */
    179       1.4    ragge #define splsoftclock()  splx(8)		/* IPL08 */
    180      1.11  mycroft #define splsoftnet()    splx(0xc)	/* IPL0C */
    181       1.9    ragge #define	splddb()	splx(0xf)	/* IPL0F */
    182      1.11  mycroft #define splbio()        splx(0x15)	/* IPL15 */
    183      1.12  mycroft #define splnet()        splx(0x15)	/* IPL15 */
    184       1.4    ragge #define spltty()        splx(0x15)	/* IPL15 */
    185      1.18    ragge #define splimp()        splx(0x17)	/* IPL17 */
    186       1.4    ragge #define splclock()      splx(0x18)	/* IPL18 */
    187       1.4    ragge #define splhigh()       splx(0x1f)	/* IPL1F */
    188       1.1    ragge #define	splstatclock()	splclock()
    189      1.20    ragge 
    190      1.20    ragge /* These are better to use when playing with VAX buses */
    191      1.20    ragge #define	spl4()		splx(0x14)
    192      1.20    ragge #define	spl5()		splx(0x15)
    193      1.20    ragge #define	spl6()		splx(0x16)
    194      1.20    ragge #define	spl7()		splx(0x17)
    195       1.5    ragge 
    196      1.21    ragge #if !defined(VAX410) && !defined(VAX43)
    197       1.5    ragge #define vmapbuf(p,q)
    198       1.5    ragge #define vunmapbuf(p,q)
    199      1.21    ragge #endif
    200      1.16    ragge 
    201      1.16    ragge /* Prototype needed for delay() */
    202      1.16    ragge #ifndef	_LOCORE
    203      1.16    ragge void	delay __P((int));
    204      1.31    ragge /* inline macros used inside kernel */
    205      1.31    ragge #include <machine/macros.h>
    206      1.16    ragge #endif
    207       1.8    ragge 
    208      1.13    ragge #define	DELAY(x) delay(x)
    209      1.24    ragge #endif /* _KERNEL */
    210       1.1    ragge 
    211       1.4    ragge #endif /* _VAX_PARAM_H_ */
    212