Home | History | Annotate | Line # | Download | only in include
param.h revision 1.30
      1 /*	$NetBSD: param.h,v 1.30 1997/09/19 13:55:26 leo Exp $ */
      2 
      3 /*
      4  * Copyright (c) 1992, 1993
      5  *	The Regents of the University of California.  All rights reserved.
      6  *
      7  * This software was developed by the Computer Systems Engineering group
      8  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
      9  * contributed to Berkeley.
     10  *
     11  * All advertising materials mentioning features or use of this software
     12  * must display the following acknowledgement:
     13  *	This product includes software developed by the University of
     14  *	California, Lawrence Berkeley Laboratory.
     15  *
     16  * Redistribution and use in source and binary forms, with or without
     17  * modification, are permitted provided that the following conditions
     18  * are met:
     19  * 1. Redistributions of source code must retain the above copyright
     20  *    notice, this list of conditions and the following disclaimer.
     21  * 2. Redistributions in binary form must reproduce the above copyright
     22  *    notice, this list of conditions and the following disclaimer in the
     23  *    documentation and/or other materials provided with the distribution.
     24  * 3. All advertising materials mentioning features or use of this software
     25  *    must display the following acknowledgement:
     26  *	This product includes software developed by the University of
     27  *	California, Berkeley and its contributors.
     28  * 4. Neither the name of the University nor the names of its contributors
     29  *    may be used to endorse or promote products derived from this software
     30  *    without specific prior written permission.
     31  *
     32  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     33  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     34  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     35  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     36  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     37  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     38  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     39  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     40  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     41  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     42  * SUCH DAMAGE.
     43  *
     44  *	@(#)param.h	8.1 (Berkeley) 6/11/93
     45  */
     46 /*
     47  * Sun4M support by Aaron Brown, Harvard University.
     48  * Changes Copyright (c) 1995 The President and Fellows of Harvard College.
     49  * All rights reserved.
     50  */
     51 #define	_MACHINE	sparc
     52 #define	MACHINE		"sparc"
     53 #define	_MACHINE_ARCH	sparc
     54 #define	MACHINE_ARCH	"sparc"
     55 #define	MID_MACHINE	MID_SPARC
     56 
     57 #ifdef _KERNEL				/* XXX */
     58 #ifndef _LOCORE				/* XXX */
     59 #include <machine/cpu.h>		/* XXX */
     60 #endif					/* XXX */
     61 #endif					/* XXX */
     62 
     63 /*
     64  * Round p (pointer or byte index) up to a correctly-aligned value for
     65  * the machine's strictest data type.  The result is u_int and must be
     66  * cast to any desired pointer type.
     67  *
     68  * ALIGNED_POINTER is a boolean macro that checks whether an address
     69  * is valid to fetch data elements of type t from on this architecture.
     70  * This does not reflect the optimal alignment, just the possibility
     71  * (within reasonable limits).
     72  *
     73  */
     74 #define	ALIGNBYTES		7
     75 #define	ALIGN(p)		(((u_int)(p) + ALIGNBYTES) & ~ALIGNBYTES)
     76 #define ALIGNED_POINTER(p,t)	((((u_long)(p)) & (sizeof(t)-1)) == 0)
     77 
     78 #define SUN4_PGSHIFT	13	/* for a sun4 machine */
     79 #define SUN4CM_PGSHIFT	12	/* for a sun4c or sun4m machine */
     80 
     81 /*
     82  * The following variables are always defined and initialized (in locore)
     83  * so independently compiled modules (e.g. LKMs) can be used irrespective
     84  * of the `options SUN4?' combination a particular kernel was configured with.
     85  * See also the definitions of NBPG, PGOFSET and PGSHIFT below.
     86  */
     87 #if defined(_KERNEL) && !defined(_LOCORE)
     88 extern int nbpg, pgofset, pgshift;
     89 #endif
     90 
     91 #define	KERNBASE	0xf8000000	/* start of kernel virtual space */
     92 #define	KERNTEXTOFF	0xf8004000	/* start of kernel text */
     93 
     94 #define	DEV_BSIZE	512
     95 #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
     96 #define	BLKDEV_IOSIZE	2048
     97 #define	MAXPHYS		(64 * 1024)
     98 
     99 #define	CLSIZE		1
    100 #define	CLSIZELOG2	0
    101 
    102 /* NOTE: SSIZE must be multiple of CLSIZE */
    103 #define	SSIZE		1		/* initial stack size in pages */
    104 #define	USPACE		8192
    105 
    106 /*
    107  * Constants related to network buffer management.
    108  * MCLBYTES must be no larger than CLBYTES (the software page size), and,
    109  * on machines that exchange pages of input or output buffers with mbuf
    110  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
    111  * of the hardware page size.
    112  */
    113 #define	MSIZE		128		/* size of an mbuf */
    114 #define	MCLBYTES	2048		/* enough for whole Ethernet packet */
    115 #define	MCLSHIFT	11		/* log2(MCLBYTES) */
    116 #define	MCLOFSET	(MCLBYTES - 1)
    117 
    118 #ifndef NMBCLUSTERS
    119 #ifdef GATEWAY
    120 #define	NMBCLUSTERS	512		/* map size, max cluster allocation */
    121 #else
    122 #define	NMBCLUSTERS	256		/* map size, max cluster allocation */
    123 #endif
    124 #endif
    125 
    126 #define MSGBUFSIZE	(4096 - 3 * sizeof(long))
    127 
    128 /*
    129  * Size of kernel malloc arena in CLBYTES-sized logical pages.
    130  */
    131 #ifndef	NKMEMCLUSTERS
    132 #define	NKMEMCLUSTERS	(6 * 1024 * 1024 / CLBYTES)
    133 #endif
    134 
    135 /* pages ("clicks") to disk blocks */
    136 #define	ctod(x)		((x) << (PGSHIFT - DEV_BSHIFT))
    137 #define	dtoc(x)		((x) >> (PGSHIFT - DEV_BSHIFT))
    138 
    139 /* pages to bytes */
    140 #define	ctob(x)		((x) << PGSHIFT)
    141 #define	btoc(x)		(((x) + PGOFSET) >> PGSHIFT)
    142 
    143 /* bytes to disk blocks */
    144 #define	btodb(x)	((x) >> DEV_BSHIFT)
    145 #define	dbtob(x)	((x) << DEV_BSHIFT)
    146 
    147 /*
    148  * Map a ``block device block'' to a file system block.
    149  * This should be device dependent, and should use the bsize
    150  * field from the disk label.
    151  * For now though just use DEV_BSIZE.
    152  */
    153 #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE / DEV_BSIZE))
    154 
    155 /*
    156  * dvmamap manages a range of DVMA addresses intended to create double
    157  * mappings of physical memory. In a way, `dvmamap' is a submap of the
    158  * VM map `phys_map'. The difference is the use of the `resource map'
    159  * routines to manage page allocation, allowing DVMA addresses to be
    160  * allocated and freed from within interrupt routines.
    161  *
    162  * Note that `phys_map' can still be used to allocate memory-backed pages
    163  * in DVMA space.
    164  */
    165 #ifdef _KERNEL
    166 #ifndef _LOCORE
    167 extern vm_offset_t	dvma_base;
    168 extern vm_offset_t	dvma_end;
    169 extern struct map	*dvmamap;
    170 /*
    171  * The dvma resource map is defined in page units, which are numbered 1 to N.
    172  * Use these macros to convert to/from virtual addresses.
    173  */
    174 #define rctov(n)		(ctob(((n)-1))+dvma_base)
    175 #define vtorc(v)		((btoc((v)-dvma_base))+1)
    176 
    177 extern caddr_t	kdvma_mapin __P((caddr_t, int, int));
    178 extern caddr_t	dvma_malloc __P((size_t, void *, int));
    179 extern void	dvma_free __P((caddr_t, size_t, void *));
    180 
    181 extern void	delay __P((unsigned int));
    182 #define	DELAY(n)	delay(n)
    183 
    184 extern int cputyp;
    185 #if 0
    186 extern int cpumod;
    187 extern int mmumod;
    188 #endif
    189 
    190 #endif /* _LOCORE */
    191 #endif /* _KERNEL */
    192 
    193 /*
    194  * Values for the cputyp variable.
    195  */
    196 #define CPU_SUN4	0
    197 #define CPU_SUN4C	1
    198 #define CPU_SUN4M	2
    199 
    200 /*
    201  * Shorthand CPU-type macros. Enumerate all eight cases.
    202  * Let compiler optimize away code conditional on constants.
    203  *
    204  * On a sun4 machine, the page size is 8192, while on a sun4c and sun4m
    205  * it is 4096. Therefore, in the (SUN4 && (SUN4C || SUN4M)) cases below,
    206  * NBPG, PGOFSET and PGSHIFT are defined as variables which are initialized
    207  * early in locore.s after the machine type has been detected.
    208  *
    209  * Note that whenever the macros defined below evaluate to expressions
    210  * involving variables, the kernel will perform slighly worse due to the
    211  * extra memory references they'll generate.
    212  */
    213 #if   defined(SUN4M) && defined(SUN4C) && defined(SUN4)
    214 #	define CPU_ISSUN4M	(cputyp == CPU_SUN4M)
    215 #	define CPU_ISSUN4C	(cputyp == CPU_SUN4C)
    216 #	define CPU_ISSUN4	(cputyp == CPU_SUN4)
    217 #	define CPU_ISSUN4OR4C	(cputyp == CPU_SUN4 || cputyp == CPU_SUN4C)
    218 #	define CPU_ISSUN4COR4M	(cputyp == CPU_SUN4C || cputyp == CPU_SUN4M)
    219 #	define NBPG		nbpg
    220 #	define PGOFSET		pgofset
    221 #	define PGSHIFT		pgshift
    222 #elif defined(SUN4M) && defined(SUN4C) && !defined(SUN4)
    223 #	define CPU_ISSUN4M	(cputyp == CPU_SUN4M)
    224 #	define CPU_ISSUN4C	(cputyp == CPU_SUN4C)
    225 #	define CPU_ISSUN4	(0)
    226 #	define CPU_ISSUN4OR4C	(cputyp == CPU_SUN4C)
    227 #	define CPU_ISSUN4COR4M	(cputyp == CPU_SUN4C || cputyp == CPU_SUN4M)
    228 #	define NBPG		4096
    229 #	define PGOFSET		(NBPG-1)
    230 #	define PGSHIFT		SUN4CM_PGSHIFT
    231 #elif defined(SUN4M) && !defined(SUN4C) && defined(SUN4)
    232 #	define CPU_ISSUN4M	(cputyp == CPU_SUN4M)
    233 #	define CPU_ISSUN4C	(0)
    234 #	define CPU_ISSUN4	(cputyp == CPU_SUN4)
    235 #	define CPU_ISSUN4OR4C	(cputyp == CPU_SUN4)
    236 #	define CPU_ISSUN4COR4M	(cputyp == CPU_SUN4M)
    237 #	define NBPG		nbpg
    238 #	define PGOFSET		pgofset
    239 #	define PGSHIFT		pgshift
    240 #elif defined(SUN4M) && !defined(SUN4C) && !defined(SUN4)
    241 #	define CPU_ISSUN4M	(1)
    242 #	define CPU_ISSUN4C	(0)
    243 #	define CPU_ISSUN4	(0)
    244 #	define CPU_ISSUN4OR4C	(0)
    245 #	define CPU_ISSUN4COR4M	(1)
    246 #	define NBPG		4096
    247 #	define PGOFSET		(NBPG-1)
    248 #	define PGSHIFT		SUN4CM_PGSHIFT
    249 #elif !defined(SUN4M) && defined(SUN4C) && defined(SUN4)
    250 #	define CPU_ISSUN4M	(0)
    251 #	define CPU_ISSUN4C	(cputyp == CPU_SUN4C)
    252 #	define CPU_ISSUN4	(cputyp == CPU_SUN4)
    253 #	define CPU_ISSUN4OR4C	(1)
    254 #	define CPU_ISSUN4COR4M	(cputyp == CPU_SUN4C)
    255 #	define NBPG		nbpg
    256 #	define PGOFSET		pgofset
    257 #	define PGSHIFT		pgshift
    258 #elif !defined(SUN4M) && defined(SUN4C) && !defined(SUN4)
    259 #	define CPU_ISSUN4M	(0)
    260 #	define CPU_ISSUN4C	(1)
    261 #	define CPU_ISSUN4	(0)
    262 #	define CPU_ISSUN4OR4C	(1)
    263 #	define CPU_ISSUN4COR4M	(1)
    264 #	define NBPG		4096
    265 #	define PGOFSET		(NBPG-1)
    266 #	define PGSHIFT		SUN4CM_PGSHIFT
    267 #elif !defined(SUN4M) && !defined(SUN4C) && defined(SUN4)
    268 #	define CPU_ISSUN4M	(0)
    269 #	define CPU_ISSUN4C	(0)
    270 #	define CPU_ISSUN4	(1)
    271 #	define CPU_ISSUN4OR4C	(1)
    272 #	define CPU_ISSUN4COR4M	(0)
    273 #	define NBPG		8192
    274 #	define PGOFSET		(NBPG-1)
    275 #	define PGSHIFT		SUN4_PGSHIFT
    276 #elif !defined(SUN4M) && !defined(SUN4C) && !defined(SUN4)
    277 #	define CPU_ISSUN4M	(cputyp == CPU_SUN4M)
    278 #	define CPU_ISSUN4C	(cputyp == CPU_SUN4C)
    279 #	define CPU_ISSUN4	(cputyp == CPU_SUN4)
    280 #	define CPU_ISSUN4OR4C	(cputyp == CPU_SUN4 || cputyp == CPU_SUN4C)
    281 #	define CPU_ISSUN4COR4M	(cputyp == CPU_SUN4C || cputyp == CPU_SUN4M)
    282 #	define NBPG		nbpg
    283 #	define PGOFSET		pgofset
    284 #	define PGSHIFT		pgshift
    285 #endif
    286