Home | History | Annotate | Line # | Download | only in include
param.h revision 1.9.4.1
      1 /*	$NetBSD: param.h,v 1.9.4.1 1999/06/21 01:02:33 thorpej 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 /*
     48  * Copyright (c) 1996-1999 Eduardo Horvath
     49  *
     50  * Redistribution and use in source and binary forms, with or without
     51  * modification, are permitted provided that the following conditions
     52  * are met:
     53  * 1. Redistributions of source code must retain the above copyright
     54  *    notice, this list of conditions and the following disclaimer.
     55  *
     56  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR  ``AS IS'' AND
     57  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     58  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     59  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR  BE LIABLE
     60  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     61  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     62  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     63  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     64  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     65  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     66  * SUCH DAMAGE.
     67  *
     68  */
     69 
     70 
     71 
     72 #define	_MACHINE	sparc64
     73 #define	MACHINE		"sparc64"
     74 #ifdef __arch64__
     75 #define	_MACHINE_ARCH	sparc64
     76 #define	MACHINE_ARCH	"sparc64"
     77 #define	MID_MACHINE	MID_SPARC64
     78 #else
     79 #define	_MACHINE_ARCH	sparc
     80 #define	MACHINE_ARCH	"sparc"
     81 #define	MID_MACHINE	MID_SPARC
     82 #endif
     83 
     84 #ifdef _KERNEL				/* XXX */
     85 #ifndef _LOCORE				/* XXX */
     86 #include <machine/cpu.h>		/* XXX */
     87 #endif					/* XXX */
     88 #endif					/* XXX */
     89 
     90 /*
     91  * Round p (pointer or byte index) up to a correctly-aligned value for
     92  * the machine's strictest data type.  The result is u_int and must be
     93  * cast to any desired pointer type.
     94  *
     95  * ALIGNED_POINTER is a boolean macro that checks whether an address
     96  * is valid to fetch data elements of type t from on this architecture.
     97  * This does not reflect the optimal alignment, just the possibility
     98  * (within reasonable limits).
     99  *
    100  */
    101 #define ALIGNBYTES32		0x7
    102 #define ALIGNBYTES64		0xf
    103 #ifdef __arch64__
    104 #define	ALIGNBYTES		ALIGNBYTES64
    105 #else
    106 #define	ALIGNBYTES		ALIGNBYTES32
    107 #endif
    108 #define	ALIGN(p)		(((u_long)(p) + ALIGNBYTES) & ~ALIGNBYTES)
    109 #define ALIGN32(p)		(((u_long)(p) + ALIGNBYTES32) & ~ALIGNBYTES32)
    110 #define ALIGNED_POINTER(p,t)	((((u_long)(p)) & (sizeof(t)-1)) == 0)
    111 
    112 
    113 /*
    114  * The following variables are always defined and initialized (in locore)
    115  * so independently compiled modules (e.g. LKMs) can be used irrespective
    116  * of the `options SUN4?' combination a particular kernel was configured with.
    117  * See also the definitions of NBPG, PGOFSET and PGSHIFT below.
    118  */
    119 #if defined(_KERNEL) && !defined(_LOCORE)
    120 extern int nbpg, pgofset, pgshift;
    121 #endif
    122 
    123 #define	KERNBASE	0xf8000000	/* start of kernel virtual space */
    124 #define	KERNTEXTOFF	(KERNBASE+0x4000)	/* start of kernel text */
    125 
    126 #define	DEV_BSIZE	512
    127 #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
    128 #define	BLKDEV_IOSIZE	2048
    129 #define	MAXPHYS		(64 * 1024)
    130 
    131 #define	CLSIZE		1
    132 #define	CLSIZELOG2	0
    133 
    134 /* NOTE: SSIZE must be multiple of CLSIZE */
    135 #ifdef __arch64__
    136 /* We get stack overflows w/8K stacks in 64-bit mode */
    137 #define	SSIZE		2		/* initial stack size in pages */
    138 #else
    139 #define	SSIZE		1
    140 #endif
    141 #define	USPACE		(SSIZE*8192)
    142 
    143 /*
    144  * Constants related to network buffer management.
    145  * MCLBYTES must be no larger than CLBYTES (the software page size), and,
    146  * on machines that exchange pages of input or output buffers with mbuf
    147  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
    148  * of the hardware page size.
    149  */
    150 #define	MSIZE		128		/* size of an mbuf */
    151 #define	MCLBYTES	2048		/* enough for whole Ethernet packet */
    152 #define	MCLSHIFT	11		/* log2(MCLBYTES) */
    153 #define	MCLOFSET	(MCLBYTES - 1)
    154 
    155 #if defined(_KERNEL) && !defined(_LKM)
    156 #include "opt_gateway.h"
    157 #endif /* _KERNEL && ! _LKM */
    158 
    159 #ifndef NMBCLUSTERS
    160 #ifdef GATEWAY
    161 #define	NMBCLUSTERS	512		/* map size, max cluster allocation */
    162 #else
    163 #define	NMBCLUSTERS	256		/* map size, max cluster allocation */
    164 #endif
    165 #endif
    166 
    167 #define MSGBUFSIZE	NBPG
    168 
    169 /*
    170  * Size of kernel malloc arena in CLBYTES-sized logical pages.
    171  */
    172 #ifndef	NKMEMCLUSTERS
    173 #define	NKMEMCLUSTERS	(6 * 1024 * 1024 / CLBYTES)
    174 #endif
    175 
    176 /* pages ("clicks") to disk blocks */
    177 #define	ctod(x)		((x) << (PGSHIFT - DEV_BSHIFT))
    178 #define	dtoc(x)		((x) >> (PGSHIFT - DEV_BSHIFT))
    179 
    180 /* pages to bytes */
    181 #define	ctob(x)		((x) << PGSHIFT)
    182 #define	btoc(x)		(((x) + PGOFSET) >> PGSHIFT)
    183 
    184 /* bytes to disk blocks */
    185 #define	btodb(x)	((x) >> DEV_BSHIFT)
    186 #define	dbtob(x)	((x) << DEV_BSHIFT)
    187 
    188 /*
    189  * Map a ``block device block'' to a file system block.
    190  * This should be device dependent, and should use the bsize
    191  * field from the disk label.
    192  * For now though just use DEV_BSIZE.
    193  */
    194 #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE / DEV_BSIZE))
    195 
    196 /*
    197  * dvmamap manages a range of DVMA addresses intended to create double
    198  * mappings of physical memory. In a way, `dvmamap' is a submap of the
    199  * VM map `phys_map'. The difference is the use of the `resource map'
    200  * routines to manage page allocation, allowing DVMA addresses to be
    201  * allocated and freed from within interrupt routines.
    202  *
    203  * Note that `phys_map' can still be used to allocate memory-backed pages
    204  * in DVMA space.
    205  */
    206 #ifdef _KERNEL
    207 #ifndef _LOCORE
    208 extern vaddr_t	dvma_base;
    209 extern vaddr_t	dvma_end;
    210 extern struct map	*dvmamap;
    211 /*
    212  * The dvma resource map is defined in page units, which are numbered 1 to N.
    213  * Use these macros to convert to/from virtual addresses.
    214  */
    215 #define rctov(n)		(ctob(((n)-1))+dvma_base)
    216 #define vtorc(v)		((btoc((v)-dvma_base))+1)
    217 
    218 extern caddr_t	kdvma_mapin __P((caddr_t, int, int));
    219 extern caddr_t	dvma_malloc __P((size_t, void *, int));
    220 extern void	dvma_free __P((caddr_t, size_t, void *));
    221 
    222 extern void	delay __P((unsigned int));
    223 #define	DELAY(n)	delay(n)
    224 
    225 extern int cputyp;
    226 extern int cpumod;
    227 extern int mmumod;
    228 
    229 #endif /* _LOCORE */
    230 #endif /* _KERNEL */
    231 
    232 /*
    233  * Values for the cputyp variable.
    234  */
    235 #define CPU_SUN4	0
    236 #define CPU_SUN4C	1
    237 #define CPU_SUN4M	2
    238 #define CPU_SUN4U	3
    239 
    240 /*
    241  * Shorthand CPU-type macros. Enumerate all eight cases.
    242  * Let compiler optimize away code conditional on constants.
    243  *
    244  * On a sun4 machine, the page size is 8192, while on a sun4c and sun4m
    245  * it is 4096. Therefore, in the (SUN4 && (SUN4C || SUN4M)) cases below,
    246  * NBPG, PGOFSET and PGSHIFT are defined as variables which are initialized
    247  * early in locore.s after the machine type has been detected.
    248  *
    249  * Note that whenever the macros defined below evaluate to expressions
    250  * involving variables, the kernel will perform slighly worse due to the
    251  * extra memory references they'll generate.
    252  */
    253 
    254 #define CPU_ISSUN4M	(0)
    255 #define CPU_ISSUN4C	(0)
    256 #define CPU_ISSUN4	(0)
    257 #define CPU_ISSUN4OR4C	(0)
    258 #define CPU_ISSUN4COR4M	(0)
    259 #define	NBPG		8192		/* bytes/page */
    260 #define	PGOFSET		(NBPG-1)	/* byte offset into page */
    261 #define	PGSHIFT		13		/* log2(NBPG) */
    262