Home | History | Annotate | Line # | Download | only in include
param.h revision 1.26
      1 /*	$NetBSD: param.h,v 1.26 1996/10/20 20:26:52 pk 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 #define	ALIGNBYTES	7
     69 #define	ALIGN(p)	(((u_int)(p) + ALIGNBYTES) & ~ALIGNBYTES)
     70 
     71 #define SUN4_PGSHIFT	13	/* for a sun4 machine */
     72 #define SUN4CM_PGSHIFT	12	/* for a sun4c or sun4m machine */
     73 
     74 /*
     75  * The following variables are always defined and initialized (in locore)
     76  * so independently compiled modules (e.g. LKMs) can be used irrespective
     77  * of the `options SUN4?' combination a particular kernel was configured with.
     78  * See also the definitions of NBPG, PGOFSET and PGSHIFT below.
     79  */
     80 #if defined(_KERNEL) && !defined(_LOCORE)
     81 extern int nbpg, pgofset, pgshift;
     82 #endif
     83 
     84 #define	KERNBASE	0xf8000000	/* start of kernel virtual space */
     85 #define	KERNTEXTOFF	0xf8004000	/* start of kernel text */
     86 
     87 #define	DEV_BSIZE	512
     88 #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
     89 #define	BLKDEV_IOSIZE	2048
     90 #define	MAXPHYS		(64 * 1024)
     91 
     92 #define	CLSIZE		1
     93 #define	CLSIZELOG2	0
     94 
     95 /* NOTE: SSIZE must be multiple of CLSIZE */
     96 #define	SSIZE		1		/* initial stack size in pages */
     97 #define	USPACE		8192
     98 
     99 /*
    100  * Constants related to network buffer management.
    101  * MCLBYTES must be no larger than CLBYTES (the software page size), and,
    102  * on machines that exchange pages of input or output buffers with mbuf
    103  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
    104  * of the hardware page size.
    105  */
    106 #define	MSIZE		128		/* size of an mbuf */
    107 #define	MCLBYTES	2048		/* enough for whole Ethernet packet */
    108 #define	MCLSHIFT	11		/* log2(MCLBYTES) */
    109 #define	MCLOFSET	(MCLBYTES - 1)
    110 
    111 #ifndef NMBCLUSTERS
    112 #ifdef GATEWAY
    113 #define	NMBCLUSTERS	512		/* map size, max cluster allocation */
    114 #else
    115 #define	NMBCLUSTERS	256		/* map size, max cluster allocation */
    116 #endif
    117 #endif
    118 
    119 /*
    120  * Size of kernel malloc arena in CLBYTES-sized logical pages.
    121  */
    122 #ifndef	NKMEMCLUSTERS
    123 #define	NKMEMCLUSTERS	(6 * 1024 * 1024 / CLBYTES)
    124 #endif
    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 /* pages to bytes */
    131 #define	ctob(x)		((x) << PGSHIFT)
    132 #define	btoc(x)		(((x) + PGOFSET) >> PGSHIFT)
    133 
    134 /* bytes to disk blocks */
    135 #define	btodb(x)	((x) >> DEV_BSHIFT)
    136 #define	dbtob(x)	((x) << DEV_BSHIFT)
    137 
    138 /*
    139  * Map a ``block device block'' to a file system block.
    140  * This should be device dependent, and should use the bsize
    141  * field from the disk label.
    142  * For now though just use DEV_BSIZE.
    143  */
    144 #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE / DEV_BSIZE))
    145 
    146 /*
    147  * dvmamap manages a range of DVMA addresses intended to create double
    148  * mappings of physical memory. In a way, `dvmamap' is a submap of the
    149  * VM map `phys_map'. The difference is the use of the `resource map'
    150  * routines to manage page allocation, allowing DVMA addresses to be
    151  * allocated and freed from within interrupt routines.
    152  *
    153  * Note that `phys_map' can still be used to allocate memory-backed pages
    154  * in DVMA space.
    155  */
    156 #ifdef _KERNEL
    157 #ifndef _LOCORE
    158 extern vm_offset_t	dvma_base;
    159 extern vm_offset_t	dvma_end;
    160 extern struct map	*dvmamap;
    161 /*
    162  * The dvma resource map is defined in page units, which are numbered 1 to N.
    163  * Use these macros to convert to/from virtual addresses.
    164  */
    165 #define rctov(n)		(ctob(((n)-1))+dvma_base)
    166 #define vtorc(v)		((btoc((v)-dvma_base))+1)
    167 
    168 extern caddr_t	kdvma_mapin __P((caddr_t, int, int));
    169 extern caddr_t	dvma_malloc __P((size_t, void *, int));
    170 extern void	dvma_free __P((caddr_t, size_t, void *));
    171 
    172 extern void	delay __P((unsigned int));
    173 #define	DELAY(n)	delay(n)
    174 
    175 extern int cputyp;
    176 extern int cpumod;
    177 extern int mmumod;
    178 
    179 #endif /* _LOCORE */
    180 #endif /* _KERNEL */
    181 
    182 /*
    183  * Values for the cputyp variable.
    184  */
    185 #define CPU_SUN4	0
    186 #define CPU_SUN4C	1
    187 #define CPU_SUN4M	2
    188 /*
    189  * Values for cpumod (cpu model) variable.  XXX currently valid only for sun4
    190  * or Sun4M
    191  */
    192 #define SUN4_100	0x22
    193 #define SUN4_200	0x21
    194 #define SUN4_300	0x23
    195 #define SUN4_400	0x24
    196 #define SUN4M_MS	0x04	/* MicroSPARC-II */
    197 #define SUN4M_SS	0x40	/* Generic SuperSPARC */
    198 #define SUN4M_HS	0x10	/* Generic ROSS sparc product (HyperSPARC) */
    199 #define SUN4M_RT620	0x1f	/* Ross HyperSPARC RT620 */
    200 #define SUN4M_STP1020N	0x41	/* TI SuperSPARC STP1020N */
    201 #define SUN4M_STP1020P	0x40	/* TI SuperSPARC STP1020P */
    202 #define SUN4M_STP1020A	0x40	/* TI SuperSPARC STP1020A */
    203 
    204 /* Values for mmumod (mmu model) variable. Valid only for Sun4M */
    205 #define	SUN4M_MMU_HS	0x1	/* ROSS HyperSparc */
    206 #define SUN4M_MMU_SS	0x0	/* TI SuperSPARC */
    207 #define SUN4M_MMU_MS1	0x4	/* MicroSPARC-I (??? XXX) */
    208 #define SUN4M_MMU_MS	0x0	/* MicroSPARC-II (ugh, conflicts w/SS) */
    209 
    210 /*
    211  * Shorthand CPU-type macros. Enumerate all eight cases.
    212  * Let compiler optimize away code conditional on constants.
    213  *
    214  * On a sun4 machine, the page size is 8192, while on a sun4c and sun4m
    215  * it is 4096. Therefore, in the (SUN4 && (SUN4C || SUN4M)) cases below,
    216  * NBPG, PGOFSET and PGSHIFT are defined as variables which are initialized
    217  * early in locore.s after the machine type has been detected.
    218  *
    219  * Note that whenever the macros defined below evaluate to expressions
    220  * involving variables, the kernel will perform slighly worse due to the
    221  * extra memory references they'll generate.
    222  */
    223 #if   defined(SUN4M) && defined(SUN4C) && defined(SUN4)
    224 #	define CPU_ISSUN4M	(cputyp == CPU_SUN4M)
    225 #	define CPU_ISSUN4C	(cputyp == CPU_SUN4C)
    226 #	define CPU_ISSUN4	(cputyp == CPU_SUN4)
    227 #	define CPU_ISSUN4OR4C	(cputyp == CPU_SUN4 || cputyp == CPU_SUN4C)
    228 #	define CPU_ISSUN4COR4M	(cputyp == CPU_SUN4C || cputyp == CPU_SUN4M)
    229 #	define NBPG		nbpg
    230 #	define PGOFSET		pgofset
    231 #	define PGSHIFT		pgshift
    232 #elif defined(SUN4M) && defined(SUN4C) && !defined(SUN4)
    233 #	define CPU_ISSUN4M	(cputyp == CPU_SUN4M)
    234 #	define CPU_ISSUN4C	(cputyp == CPU_SUN4C)
    235 #	define CPU_ISSUN4	(0)
    236 #	define CPU_ISSUN4OR4C	(cputyp == CPU_SUN4C)
    237 #	define CPU_ISSUN4COR4M	(cputyp == CPU_SUN4C || cputyp == CPU_SUN4M)
    238 #	define NBPG		4096
    239 #	define PGOFSET		(NBPG-1)
    240 #	define PGSHIFT		SUN4CM_PGSHIFT
    241 #elif defined(SUN4M) && !defined(SUN4C) && defined(SUN4)
    242 #	define CPU_ISSUN4M	(cputyp == CPU_SUN4M)
    243 #	define CPU_ISSUN4C	(0)
    244 #	define CPU_ISSUN4	(cputyp == CPU_SUN4)
    245 #	define CPU_ISSUN4OR4C	(cputyp == CPU_SUN4)
    246 #	define CPU_ISSUN4COR4M	(cputyp == CPU_SUN4M)
    247 #	define NBPG		nbpg
    248 #	define PGOFSET		pgofset
    249 #	define PGSHIFT		pgshift
    250 #elif defined(SUN4M) && !defined(SUN4C) && !defined(SUN4)
    251 #	define CPU_ISSUN4M	(1)
    252 #	define CPU_ISSUN4C	(0)
    253 #	define CPU_ISSUN4	(0)
    254 #	define CPU_ISSUN4OR4C	(0)
    255 #	define CPU_ISSUN4COR4M	(1)
    256 #	define NBPG		4096
    257 #	define PGOFSET		(NBPG-1)
    258 #	define PGSHIFT		SUN4CM_PGSHIFT
    259 #elif !defined(SUN4M) && defined(SUN4C) && defined(SUN4)
    260 #	define CPU_ISSUN4M	(0)
    261 #	define CPU_ISSUN4C	(cputyp == CPU_SUN4C)
    262 #	define CPU_ISSUN4	(cputyp == CPU_SUN4)
    263 #	define CPU_ISSUN4OR4C	(1)
    264 #	define CPU_ISSUN4COR4M	(cputyp == CPU_SUN4C)
    265 #	define NBPG		nbpg
    266 #	define PGOFSET		pgofset
    267 #	define PGSHIFT		pgshift
    268 #elif !defined(SUN4M) && defined(SUN4C) && !defined(SUN4)
    269 #	define CPU_ISSUN4M	(0)
    270 #	define CPU_ISSUN4C	(1)
    271 #	define CPU_ISSUN4	(0)
    272 #	define CPU_ISSUN4OR4C	(1)
    273 #	define CPU_ISSUN4COR4M	(1)
    274 #	define NBPG		4096
    275 #	define PGOFSET		(NBPG-1)
    276 #	define PGSHIFT		SUN4CM_PGSHIFT
    277 #elif !defined(SUN4M) && !defined(SUN4C) && defined(SUN4)
    278 #	define CPU_ISSUN4M	(0)
    279 #	define CPU_ISSUN4C	(0)
    280 #	define CPU_ISSUN4	(1)
    281 #	define CPU_ISSUN4OR4C	(1)
    282 #	define CPU_ISSUN4COR4M	(0)
    283 #	define NBPG		8192
    284 #	define PGOFSET		(NBPG-1)
    285 #	define PGSHIFT		SUN4_PGSHIFT
    286 #elif !defined(SUN4M) && !defined(SUN4C) && !defined(SUN4)
    287 #	define CPU_ISSUN4M	(0)
    288 #	define CPU_ISSUN4C	(0)
    289 #	define CPU_ISSUN4	(0)
    290 #	define CPU_ISSUN4OR4C	(0)
    291 #	define CPU_ISSUN4COR4M	(0)
    292 #	define NBPG		(0)
    293 #	define PGOFSET		(0)
    294 #	define PGSHIFT		(0)
    295 #endif
    296