Home | History | Annotate | Line # | Download | only in include
param.h revision 1.48.2.2
      1 /*	$NetBSD: param.h,v 1.48.2.2 2002/03/16 15:59:49 jdolecek 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_OPT
     58 #include "opt_sparc_arch.h"
     59 #endif
     60 #ifdef _KERNEL				/* XXX */
     61 #ifndef _LOCORE				/* XXX */
     62 #include <machine/cpu.h>		/* XXX */
     63 #endif					/* XXX */
     64 #endif					/* XXX */
     65 
     66 /*
     67  * Round p (pointer or byte index) up to a correctly-aligned value for
     68  * the machine's strictest data type.  The result is u_int and must be
     69  * cast to any desired pointer type.
     70  *
     71  * ALIGNED_POINTER is a boolean macro that checks whether an address
     72  * is valid to fetch data elements of type t from on this architecture.
     73  * This does not reflect the optimal alignment, just the possibility
     74  * (within reasonable limits).
     75  *
     76  */
     77 #define	ALIGNBYTES		7
     78 #define	ALIGN(p)		(((u_int)(p) + ALIGNBYTES) & ~ALIGNBYTES)
     79 #define ALIGNED_POINTER(p,t)	((((u_long)(p)) & (sizeof(t)-1)) == 0)
     80 
     81 #define SUN4_PGSHIFT	13	/* for a sun4 machine */
     82 #define SUN4CM_PGSHIFT	12	/* for a sun4c or sun4m machine */
     83 
     84 /*
     85  * The following variables are always defined and initialized (in locore)
     86  * so independently compiled modules (e.g. LKMs) can be used irrespective
     87  * of the `options SUN4?' combination a particular kernel was configured with.
     88  * See also the definitions of NBPG, PGOFSET and PGSHIFT below.
     89  */
     90 #if (defined(_KERNEL) || defined(_STANDALONE)) && !defined(_LOCORE)
     91 extern int nbpg, pgofset, pgshift;
     92 #endif
     93 
     94 #define	KERNBASE	0xf0000000	/* start of kernel virtual space */
     95 #define KERNEND		0xfe000000	/* end of kernel virtual space */
     96 /* Arbitrarily only use 1/4 of the kernel address space for buffers. */
     97 #define VM_MAX_KERNEL_BUF	((KERNEND - KERNBASE)/4)
     98 #define PROM_LOADADDR	0x00004000	/* where the prom loads us */
     99 #define	KERNTEXTOFF	(KERNBASE+PROM_LOADADDR)/* start of kernel text */
    100 
    101 #define	DEV_BSIZE	512
    102 #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
    103 #define	BLKDEV_IOSIZE	2048
    104 #define	MAXPHYS		(64 * 1024)
    105 
    106 #define	SSIZE		1		/* initial stack size in pages */
    107 #define	USPACE		8192
    108 
    109 /*
    110  * Constants related to network buffer management.
    111  * MCLBYTES must be no larger than NBPG (the software page size), and,
    112  * on machines that exchange pages of input or output buffers with mbuf
    113  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
    114  * of the hardware page size.
    115  */
    116 #define	MSIZE		256		/* size of an mbuf */
    117 
    118 #ifndef MCLSHIFT
    119 #define	MCLSHIFT	11		/* convert bytes to m_buf clusters */
    120 					/* 2K cluster can hold Ether frame */
    121 #endif	/* MCLSHIFT */
    122 
    123 #define	MCLBYTES	(1 << MCLSHIFT)	/* size of a m_buf cluster */
    124 
    125 #ifndef NMBCLUSTERS
    126 #if defined(_KERNEL_OPT)
    127 #include "opt_gateway.h"
    128 #endif
    129 
    130 #ifdef GATEWAY
    131 #define	NMBCLUSTERS	512		/* map size, max cluster allocation */
    132 #else
    133 #define	NMBCLUSTERS	256		/* map size, max cluster allocation */
    134 #endif
    135 #endif
    136 
    137 /*
    138  * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized
    139  * logical pages.
    140  */
    141 #define	NKMEMPAGES_MIN_DEFAULT	((6 * 1024 * 1024) >> PAGE_SHIFT)
    142 #define	NKMEMPAGES_MAX_DEFAULT	((6 * 1024 * 1024) >> PAGE_SHIFT)
    143 
    144 /* pages ("clicks") to disk blocks */
    145 #define	ctod(x)		((x) << (PGSHIFT - DEV_BSHIFT))
    146 #define	dtoc(x)		((x) >> (PGSHIFT - DEV_BSHIFT))
    147 
    148 /* pages to bytes */
    149 #define	ctob(x)		((x) << PGSHIFT)
    150 #define	btoc(x)		(((x) + PGOFSET) >> PGSHIFT)
    151 
    152 /* bytes to disk blocks */
    153 #define	btodb(x)	((x) >> DEV_BSHIFT)
    154 #define	dbtob(x)	((x) << DEV_BSHIFT)
    155 
    156 /*
    157  * Map a ``block device block'' to a file system block.
    158  * This should be device dependent, and should use the bsize
    159  * field from the disk label.
    160  * For now though just use DEV_BSIZE.
    161  */
    162 #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE / DEV_BSIZE))
    163 
    164 /*
    165  * Values for the cputyp variable.
    166  */
    167 #define CPU_SUN4	0
    168 #define CPU_SUN4C	1
    169 #define CPU_SUN4M	2
    170 #define CPU_SUN4U	3
    171 
    172 #if defined(_KERNEL) || defined(_STANDALONE)
    173 #ifndef _LOCORE
    174 
    175 extern int cputyp;
    176 
    177 extern void	delay __P((unsigned int));
    178 #define	DELAY(n)	delay(n)
    179 #endif /* _LOCORE */
    180 
    181 
    182 /*
    183  * microSPARC-IIep is a sun4m but with an integrated PCI controller.
    184  * In a lot of places (like pmap &c) we want it to be treated as SUN4M.
    185  * But since various low-level things are done very differently from
    186  * normal sparcs (and since for now it requires a relocated kernel
    187  * anyway), the MSIIEP kernels are not supposed to support any other
    188  * system.  So insist on SUN4M defined and SUN4 and SUN4C not defined.
    189  */
    190 #if defined(MSIIEP)
    191 #if defined(SUN4) || defined(SUN4C)
    192 #error "microSPARC-IIep kernels cannot support sun4 or sun4c"
    193 #endif
    194 #if !defined(SUN4M)
    195 #error "microSPARC-IIep kernel must have 'options SUN4M'"
    196 #endif
    197 #endif /* MSIIEP */
    198 
    199 /*
    200  * Shorthand CPU-type macros. Enumerate all eight cases.
    201  * Let compiler optimize away code conditional on constants.
    202  *
    203  * On a sun4 machine, the page size is 8192, while on a sun4c and sun4m
    204  * it is 4096. Therefore, in the (SUN4 && (SUN4C || SUN4M)) cases below,
    205  * NBPG, PGOFSET and PGSHIFT are defined as variables which are initialized
    206  * early in locore.s after the machine type has been detected.
    207  *
    208  * Note that whenever the macros defined below evaluate to expressions
    209  * involving variables, the kernel will perform slighly worse due to the
    210  * extra memory references they'll generate.
    211  */
    212 #define CPU_ISSUN4U	(0)
    213 #define CPU_ISSUN4MOR4U	(CPU_ISSUN4M)
    214 #if   defined(SUN4M) && defined(SUN4C) && defined(SUN4)
    215 #	define CPU_ISSUN4M	(cputyp == CPU_SUN4M)
    216 #	define CPU_ISSUN4C	(cputyp == CPU_SUN4C)
    217 #	define CPU_ISSUN4	(cputyp == CPU_SUN4)
    218 #	define CPU_ISSUN4OR4C	(cputyp == CPU_SUN4 || cputyp == CPU_SUN4C)
    219 #	define CPU_ISSUN4COR4M	(cputyp == CPU_SUN4C || cputyp == CPU_SUN4M)
    220 #	define NBPG		nbpg
    221 #	define PGOFSET		pgofset
    222 #	define PGSHIFT		pgshift
    223 #elif defined(SUN4M) && defined(SUN4C) && !defined(SUN4)
    224 #	define CPU_ISSUN4M	(cputyp == CPU_SUN4M)
    225 #	define CPU_ISSUN4C	(cputyp == CPU_SUN4C)
    226 #	define CPU_ISSUN4	(0)
    227 #	define CPU_ISSUN4OR4C	(cputyp == CPU_SUN4C)
    228 #	define CPU_ISSUN4COR4M	(cputyp == CPU_SUN4C || cputyp == CPU_SUN4M)
    229 #	define NBPG		4096
    230 #	define PGOFSET		(NBPG-1)
    231 #	define PGSHIFT		SUN4CM_PGSHIFT
    232 #elif defined(SUN4M) && !defined(SUN4C) && defined(SUN4)
    233 #	define CPU_ISSUN4M	(cputyp == CPU_SUN4M)
    234 #	define CPU_ISSUN4C	(0)
    235 #	define CPU_ISSUN4	(cputyp == CPU_SUN4)
    236 #	define CPU_ISSUN4OR4C	(cputyp == CPU_SUN4)
    237 #	define CPU_ISSUN4COR4M	(cputyp == CPU_SUN4M)
    238 #	define NBPG		nbpg
    239 #	define PGOFSET		pgofset
    240 #	define PGSHIFT		pgshift
    241 #elif defined(SUN4M) && !defined(SUN4C) && !defined(SUN4)
    242 #	define CPU_ISSUN4M	(1)
    243 #	define CPU_ISSUN4C	(0)
    244 #	define CPU_ISSUN4	(0)
    245 #	define CPU_ISSUN4OR4C	(0)
    246 #	define CPU_ISSUN4COR4M	(1)
    247 #	define NBPG		4096
    248 #	define PGOFSET		(NBPG-1)
    249 #	define PGSHIFT		SUN4CM_PGSHIFT
    250 #elif !defined(SUN4M) && defined(SUN4C) && defined(SUN4)
    251 #	define CPU_ISSUN4M	(0)
    252 #	define CPU_ISSUN4C	(cputyp == CPU_SUN4C)
    253 #	define CPU_ISSUN4	(cputyp == CPU_SUN4)
    254 #	define CPU_ISSUN4OR4C	(1)
    255 #	define CPU_ISSUN4COR4M	(cputyp == CPU_SUN4C)
    256 #	define NBPG		nbpg
    257 #	define PGOFSET		pgofset
    258 #	define PGSHIFT		pgshift
    259 #elif !defined(SUN4M) && defined(SUN4C) && !defined(SUN4)
    260 #	define CPU_ISSUN4M	(0)
    261 #	define CPU_ISSUN4C	(1)
    262 #	define CPU_ISSUN4	(0)
    263 #	define CPU_ISSUN4OR4C	(1)
    264 #	define CPU_ISSUN4COR4M	(1)
    265 #	define NBPG		4096
    266 #	define PGOFSET		(NBPG-1)
    267 #	define PGSHIFT		SUN4CM_PGSHIFT
    268 #elif !defined(SUN4M) && !defined(SUN4C) && defined(SUN4)
    269 #	define CPU_ISSUN4M	(0)
    270 #	define CPU_ISSUN4C	(0)
    271 #	define CPU_ISSUN4	(1)
    272 #	define CPU_ISSUN4OR4C	(1)
    273 #	define CPU_ISSUN4COR4M	(0)
    274 #	define NBPG		8192
    275 #	define PGOFSET		(NBPG-1)
    276 #	define PGSHIFT		SUN4_PGSHIFT
    277 #elif !defined(SUN4M) && !defined(SUN4C) && !defined(SUN4)
    278 #	define CPU_ISSUN4M	(cputyp == CPU_SUN4M)
    279 #	define CPU_ISSUN4C	(cputyp == CPU_SUN4C)
    280 #	define CPU_ISSUN4	(cputyp == CPU_SUN4)
    281 #	define CPU_ISSUN4OR4C	(cputyp == CPU_SUN4 || cputyp == CPU_SUN4C)
    282 #	define CPU_ISSUN4COR4M	(cputyp == CPU_SUN4C || cputyp == CPU_SUN4M)
    283 #	define NBPG		nbpg
    284 #	define PGOFSET		pgofset
    285 #	define PGSHIFT		pgshift
    286 #endif
    287 #endif /* _KERNEL || _STANDALONE */
    288