Home | History | Annotate | Line # | Download | only in include
param.h revision 1.64.4.1
      1 /*	$NetBSD: param.h,v 1.64.4.1 2006/04/22 11:37:59 simonb 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. Neither the name of the University nor the names of its contributors
     25  *    may be used to endorse or promote products derived from this software
     26  *    without specific prior written permission.
     27  *
     28  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     29  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     30  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     31  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     32  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     33  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     34  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     35  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     36  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     37  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     38  * SUCH DAMAGE.
     39  *
     40  *	@(#)param.h	8.1 (Berkeley) 6/11/93
     41  */
     42 /*
     43  * Sun4M support by Aaron Brown, Harvard University.
     44  * Changes Copyright (c) 1995 The President and Fellows of Harvard College.
     45  * All rights reserved.
     46  */
     47 #define	_MACHINE	sparc
     48 #define	MACHINE		"sparc"
     49 #define	_MACHINE_ARCH	sparc
     50 #define	MACHINE_ARCH	"sparc"
     51 #define	MID_MACHINE	MID_SPARC
     52 
     53 #include <machine/cpuconf.h>		/* XXX */
     54 #ifdef _KERNEL				/* XXX */
     55 #ifndef _LOCORE				/* XXX */
     56 #include <machine/cpu.h>		/* XXX */
     57 #endif					/* XXX */
     58 #endif					/* XXX */
     59 
     60 /*
     61  * Round p (pointer or byte index) up to a correctly-aligned value for
     62  * the machine's strictest data type.  The result is u_int and must be
     63  * cast to any desired pointer type.
     64  *
     65  * ALIGNED_POINTER is a boolean macro that checks whether an address
     66  * is valid to fetch data elements of type t from on this architecture.
     67  * This does not reflect the optimal alignment, just the possibility
     68  * (within reasonable limits).
     69  *
     70  */
     71 #define	ALIGNBYTES		7
     72 #define	ALIGN(p)		(((u_int)(p) + ALIGNBYTES) & ~ALIGNBYTES)
     73 #define ALIGNED_POINTER(p,t)	((((u_long)(p)) & (sizeof(t)-1)) == 0)
     74 
     75 #define SUN4_PGSHIFT	13	/* for a sun4 machine */
     76 #define SUN4CM_PGSHIFT	12	/* for a sun4c or sun4m machine */
     77 
     78 /*
     79  * The following variables are always defined and initialized (in locore)
     80  * so independently compiled modules (e.g. LKMs) can be used irrespective
     81  * of the `options SUN4?' combination a particular kernel was configured with.
     82  * See also the definitions of NBPG, PGOFSET and PGSHIFT below.
     83  */
     84 #if (defined(_KERNEL) || defined(_STANDALONE)) && !defined(_LOCORE)
     85 extern int nbpg, pgofset, pgshift;
     86 #endif
     87 
     88 #if !(defined(PROM_AT_F0) || defined(MSIIEP))
     89 #define	KERNBASE	0xf0000000	/* start of kernel virtual space */
     90 #else
     91 /*
     92  * JS1/OF has prom sitting in f000.0000..f007.ffff, modify kernel VA
     93  * layout to work around that. XXX - kernel should live beyound prom on
     94  * those machines.
     95  */
     96 #define	KERNBASE	0xe8000000
     97 #endif
     98 #define KERNEND		0xfe000000	/* end of kernel virtual space */
     99 /* Arbitrarily only use 1/4 of the kernel address space for buffers. */
    100 #define VM_MAX_KERNEL_BUF	((KERNEND - KERNBASE)/4)
    101 #define PROM_LOADADDR	0x00004000	/* where the prom loads us */
    102 #define	KERNTEXTOFF	(KERNBASE+PROM_LOADADDR)/* start of kernel text */
    103 
    104 #define	DEV_BSIZE	512
    105 #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
    106 #define	BLKDEV_IOSIZE	2048
    107 #define	MAXPHYS		(64 * 1024)
    108 
    109 #define	SSIZE		1		/* initial stack size in pages */
    110 #define	USPACE		8192
    111 
    112 /*
    113  * Constants related to network buffer management.
    114  * MCLBYTES must be no larger than NBPG (the software page size), and,
    115  * on machines that exchange pages of input or output buffers with mbuf
    116  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
    117  * of the hardware page size.
    118  */
    119 #define	MSIZE		256		/* size of an mbuf */
    120 
    121 #ifndef MCLSHIFT
    122 #define	MCLSHIFT	11		/* convert bytes to m_buf clusters */
    123 					/* 2K cluster can hold Ether frame */
    124 #endif	/* MCLSHIFT */
    125 
    126 #define	MCLBYTES	(1 << MCLSHIFT)	/* size of a m_buf cluster */
    127 
    128 #ifndef NMBCLUSTERS
    129 #if defined(_KERNEL_OPT)
    130 #include "opt_gateway.h"
    131 #endif
    132 
    133 #ifdef GATEWAY
    134 #define	NMBCLUSTERS	512		/* map size, max cluster allocation */
    135 #else
    136 #define	NMBCLUSTERS	256		/* map size, max cluster allocation */
    137 #endif
    138 #endif
    139 
    140 /*
    141  * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized
    142  * logical pages.
    143  */
    144 #define	NKMEMPAGES_MIN_DEFAULT	((6 * 1024 * 1024) >> PAGE_SHIFT)
    145 #define	NKMEMPAGES_MAX_DEFAULT	((32 * 1024 * 1024) >> PAGE_SHIFT)
    146 
    147 /* pages ("clicks") to disk blocks */
    148 #define	ctod(x)		((x) << (PGSHIFT - DEV_BSHIFT))
    149 #define	dtoc(x)		((x) >> (PGSHIFT - DEV_BSHIFT))
    150 
    151 /* pages to bytes */
    152 #define	ctob(x)		((x) << PGSHIFT)
    153 #define	btoc(x)		(((x) + PGOFSET) >> PGSHIFT)
    154 
    155 /* bytes to disk blocks */
    156 #define	btodb(x)	((x) >> DEV_BSHIFT)
    157 #define	dbtob(x)	((x) << DEV_BSHIFT)
    158 
    159 /*
    160  * Map a ``block device block'' to a file system block.
    161  * This should be device dependent, and should use the bsize
    162  * field from the disk label.
    163  * For now though just use DEV_BSIZE.
    164  */
    165 #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE / DEV_BSIZE))
    166 
    167 #if defined(_KERNEL) || defined(_STANDALONE)
    168 #ifndef _LOCORE
    169 extern void	delay(unsigned int);
    170 #define	DELAY(n)	delay(n)
    171 #endif /* _LOCORE */
    172 
    173 /*
    174  * microSPARC-IIep is a sun4m but with an integrated PCI controller.
    175  * In a lot of places (like pmap &c) we want it to be treated as SUN4M.
    176  * But since various low-level things are done very differently from
    177  * normal sparcs (and since for now it requires a relocated kernel
    178  * anyway), the MSIIEP kernels are not supposed to support any other
    179  * system.  So insist on SUN4M defined and SUN4 and SUN4C not defined.
    180  */
    181 #if defined(MSIIEP)
    182 #if defined(SUN4) || defined(SUN4C) || defined(SUN4D)
    183 #error "microSPARC-IIep kernels cannot support sun4, sun4c, or sun4d"
    184 #endif
    185 #if !defined(SUN4M)
    186 #error "microSPARC-IIep kernel must have 'options SUN4M'"
    187 #endif
    188 #endif /* MSIIEP */
    189 
    190 /*
    191  * Sun4 machines have a page size of 8192.  All other machines have a page
    192  * size of 4096.  Short cut page size variables if we can.
    193  */
    194 #if CPU_NTYPES != 0 && !defined(SUN4)
    195 #	define NBPG		4096
    196 #	define PGOFSET		(NBPG-1)
    197 #	define PGSHIFT		SUN4CM_PGSHIFT
    198 #elif CPU_NTYPES == 1 && defined(SUN4)
    199 #	define NBPG		8192
    200 #	define PGOFSET		(NBPG-1)
    201 #	define PGSHIFT		SUN4_PGSHIFT
    202 #else
    203 #	define NBPG		nbpg
    204 #	define PGOFSET		pgofset
    205 #	define PGSHIFT		pgshift
    206 #endif
    207 
    208 #endif /* _KERNEL || _STANDALONE */
    209