Home | History | Annotate | Line # | Download | only in include
param.h revision 1.9
      1 /*	$NetBSD: param.h,v 1.9 2002/03/17 14:02:04 uch Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 2002 The NetBSD Foundation, Inc. All rights reserved.
      5  * Copyright (c) 1990 The Regents of the University of California.
      6  * All rights reserved.
      7  *
      8  * This code is derived from software contributed to Berkeley by
      9  * William Jolitz.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions and the following disclaimer.
     16  * 2. Redistributions in binary form must reproduce the above copyright
     17  *    notice, this list of conditions and the following disclaimer in the
     18  *    documentation and/or other materials provided with the distribution.
     19  * 3. All advertising materials mentioning features or use of this software
     20  *    must display the following acknowledgement:
     21  *	This product includes software developed by the University of
     22  *	California, Berkeley and its contributors.
     23  * 4. Neither the name of the University nor the names of its contributors
     24  *    may be used to endorse or promote products derived from this software
     25  *    without specific prior written permission.
     26  *
     27  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     28  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     29  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     30  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     31  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     32  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     33  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     34  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     35  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     36  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     37  * SUCH DAMAGE.
     38  *
     39  *	@(#)param.h	5.8 (Berkeley) 6/28/91
     40  */
     41 
     42 /*
     43  * SuperH dependent constants.
     44  */
     45 
     46 #if defined(_KERNEL) && !defined(_LOCORE)
     47 #include <machine/cpu.h>
     48 #endif
     49 
     50 /*
     51  * Round p (pointer or byte index) up to a correctly-aligned value
     52  * for all data types (int, long, ...).   The result is u_int and
     53  * must be cast to any desired pointer type.
     54  *
     55  * ALIGNED_POINTER is a boolean macro that checks whether an address
     56  * is valid to fetch data elements of type t from on this architecture.
     57  * This does not reflect the optimal alignment, just the possibility
     58  * (within reasonable limits).
     59  *
     60  */
     61 #define ALIGNBYTES		(sizeof(int) - 1)
     62 #define ALIGN(p)		(((u_int)(p) + ALIGNBYTES) & ~ALIGNBYTES)
     63 #define ALIGNED_POINTER(p, t)	((((u_long)(p)) & (sizeof(t) - 1)) == 0)
     64 
     65 #define	PGSHIFT		12		/* LOG2(NBPG) */
     66 #define	NBPG		(1 << PGSHIFT)	/* bytes/page */
     67 #define	PGOFSET		(NBPG - 1)	/* byte offset into page */
     68 #define	NPTEPG		(NBPG / (sizeof(pt_entry_t)))
     69 
     70 #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
     71 #define	DEV_BSIZE	(1 << DEV_BSHIFT)
     72 #define	BLKDEV_IOSIZE	2048
     73 #define	MAXPHYS		(64 * 1024)	/* max raw I/O transfer size */
     74 
     75 /*
     76  * u-space.
     77  */
     78 #define	UPAGES		3		/* pages of u-area */
     79 #define	USPACE		(UPAGES * NBPG)	/* total size of u-area */
     80 #if UPAGES == 1
     81 #error "too small u-area"
     82 #elif UPAGES == 2
     83 #define	P1_STACK	/* kernel stack is P1-area */
     84 #else
     85 #undef	P1_STACK	/* kernel stack is P3-area */
     86 #endif
     87 
     88 #ifndef MSGBUFSIZE
     89 #define MSGBUFSIZE	NBPG		/* default message buffer size */
     90 #endif
     91 
     92 /*
     93  * Constants related to network buffer management.
     94  * MCLBYTES must be no larger than NBPG (the software page size), and,
     95  * on machines that exchange pages of input or output buffers with mbuf
     96  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
     97  * of the hardware page size.
     98  */
     99 #define	MSIZE		256		/* size of an mbuf */
    100 
    101 #ifndef MCLSHIFT
    102 #define	MCLSHIFT	11		/* convert bytes to m_buf clusters */
    103 					/* 2K cluster can hold Ether frame */
    104 #endif	/* MCLSHIFT */
    105 
    106 #define	MCLBYTES	(1 << MCLSHIFT)	/* size of a m_buf cluster */
    107 
    108 #ifndef NMBCLUSTERS
    109 #if defined(_KERNEL_OPT)
    110 #include "opt_gateway.h"
    111 #endif
    112 
    113 #ifdef GATEWAY
    114 #define	NMBCLUSTERS	512		/* map size, max cluster allocation */
    115 #else
    116 #define	NMBCLUSTERS	256		/* map size, max cluster allocation */
    117 #endif
    118 #endif
    119 
    120 /*
    121  * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized
    122  * logical pages.
    123  */
    124 #define	NKMEMPAGES_MIN_DEFAULT	((6 * 1024 * 1024) >> PAGE_SHIFT)
    125 #define	NKMEMPAGES_MAX_DEFAULT	((6 * 1024 * 1024) >> PAGE_SHIFT)
    126 
    127 /* pages ("clicks") to disk blocks */
    128 #define	ctod(x)		((x) << (PGSHIFT - DEV_BSHIFT))
    129 #define	dtoc(x)		((x) >> (PGSHIFT - DEV_BSHIFT))
    130 
    131 /* bytes to pages */
    132 #define	ctob(x)		((x) << PGSHIFT)
    133 #define	btoc(x)		(((x) + PGOFSET) >> PGSHIFT)
    134 
    135 /* bytes to disk blocks */
    136 #define	dbtob(x)	((x) << DEV_BSHIFT)
    137 #define	btodb(x)	((x) >> DEV_BSHIFT)
    138 
    139 /*
    140  * Map a ``block device block'' to a file system block.
    141  * This should be device dependent, and should use the bsize
    142  * field from the disk label.
    143  * For now though just use DEV_BSIZE.
    144  */
    145 #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE / DEV_BSIZE))
    146 
    147 /*
    148  * Mach derived conversion macros
    149  */
    150 #define	sh3_round_pdr(x)	((((unsigned)(x)) + PDOFSET) & ~PDOFSET)
    151 #define	sh3_trunc_pdr(x)	((unsigned)(x) & ~PDOFSET)
    152 #define	sh3_btod(x)		((unsigned)(x) >> PDSHIFT)
    153 #define	sh3_dtob(x)		((unsigned)(x) << PDSHIFT)
    154 #define	sh3_round_page(x)	((((unsigned)(x)) + PGOFSET) & ~PGOFSET)
    155 #define	sh3_trunc_page(x)	((unsigned)(x) & ~PGOFSET)
    156 #define	sh3_btop(x)		((unsigned)(x) >> PGSHIFT)
    157 #define	sh3_ptob(x)		((unsigned)(x) << PGSHIFT)
    158