param.h revision 1246
153494Sdillon/*- 253494Sdillon * Copyright (c) 1990 The Regents of the University of California. 353494Sdillon * All rights reserved. 453494Sdillon * 553494Sdillon * This code is derived from software contributed to Berkeley by 653494Sdillon * William Jolitz. 753494Sdillon * 853494Sdillon * Redistribution and use in source and binary forms, with or without 953494Sdillon * modification, are permitted provided that the following conditions 1053494Sdillon * are met: 1153494Sdillon * 1. Redistributions of source code must retain the above copyright 1253494Sdillon * notice, this list of conditions and the following disclaimer. 1353494Sdillon * 2. Redistributions in binary form must reproduce the above copyright 1453494Sdillon * notice, this list of conditions and the following disclaimer in the 1553494Sdillon * documentation and/or other materials provided with the distribution. 1653494Sdillon * 3. All advertising materials mentioning features or use of this software 1753494Sdillon * must display the following acknowledgement: 1853494Sdillon * This product includes software developed by the University of 1953494Sdillon * California, Berkeley and its contributors. 2053494Sdillon * 4. Neither the name of the University nor the names of its contributors 2153494Sdillon * may be used to endorse or promote products derived from this software 2253494Sdillon * without specific prior written permission. 2353494Sdillon * 2453494Sdillon * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2553494Sdillon * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2653494Sdillon * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2753494Sdillon * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28114601Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29114601Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3053494Sdillon * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3153494Sdillon * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3253494Sdillon * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3353494Sdillon * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34194880Sdfr * SUCH DAMAGE. 3553494Sdillon * 3653494Sdillon * from: @(#)param.h 5.8 (Berkeley) 6/28/91 3753494Sdillon * $Id: param.h,v 1.13 1994/01/31 04:18:54 davidg Exp $ 3880146Siedowse */ 3953494Sdillon 4053494Sdillon#ifndef _MACHINE_PARAM_H_ 4153494Sdillon#define _MACHINE_PARAM_H_ 1 4253494Sdillon 4353494Sdillon/* 4453494Sdillon * Machine dependent constants for Intel 386. 4553494Sdillon */ 4653494Sdillon 4753494Sdillon#define MACHINE "i386" 48201135Sdelphij#define MID_MACHINE MID_I386 4980146Siedowse 5053494Sdillon/* 5153494Sdillon * Round p (pointer or byte index) up to a correctly-aligned value 5253494Sdillon * for all data types (int, long, ...). The result is u_int and 5353494Sdillon * must be cast to any desired pointer type. 5453494Sdillon */ 55201252Sed#define ALIGNBYTES (sizeof(int) - 1) 56201252Sed#define ALIGN(p) (((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES) 5753494Sdillon 5853494Sdillon/* XXX PGSHIFT and PG_SHIFT are two names for the same thing */ 5953494Sdillon#define PGSHIFT 12 /* LOG2(NBPG) */ 6053494Sdillon#define PAGE_SHIFT 12 6153494Sdillon#define NBPG (1 << PAGE_SHIFT) /* bytes/page */ 6266814Sbde#define PAGE_SIZE (1 << PAGE_SHIFT) 6380146Siedowse#define PAGE_MASK (PAGE_SIZE-1) 6453494Sdillon#define PGOFSET (NBPG-1) /* byte offset into page */ 6553494Sdillon#define NPTEPG (NBPG/(sizeof (pt_entry_t))) 6653494Sdillon 6753494Sdillon/* XXX PDRSHIFT and PD_SHIFT are two names for the same thing */ 6853494Sdillon#define PDRSHIFT 22 /* LOG2(NBPDR) */ 6953494Sdillon#define NBPDR (1 << PDRSHIFT) /* bytes/page dir */ 7053494Sdillon#define PDROFSET (NBPDR-1) /* byte offset into page dir */ 7153494Sdillon 7253494Sdillon/* 73201252Sed * XXX This should really be KPTDPTDI << PDRSHIFT, but since KPTDPTDI is 74201252Sed * defined in pmap.h which is included after this we can't do that 7580146Siedowse * (YET!) 7653494Sdillon */ 7753494Sdillon#define BTOPKERNBASE (KERNBASE >> PGSHIFT) 7880146Siedowse 79201135Sdelphij#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 8080146Siedowse#define DEV_BSIZE (1 << DEV_BSHIFT) 8153494Sdillon 8253494Sdillon#define BLKDEV_IOSIZE 2048 8353494Sdillon#define MAXPHYS (64 * 1024) /* max raw I/O transfer size */ 8453494Sdillon 8553494Sdillon#define CLSIZELOG2 0 8653494Sdillon#define CLSIZE (1 << CLSIZELOG2) 8753494Sdillon 8853494Sdillon/* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */ 8953494Sdillon#define SSIZE 1 /* initial stack size/NBPG */ 9053494Sdillon#define SINCR 1 /* increment of stack/NBPG */ 91201135Sdelphij 9253494Sdillon#define UPAGES 2 /* pages of u-area */ 9353494Sdillon 9453494Sdillon/* 9553494Sdillon * Constants related to network buffer management. 9653494Sdillon * MCLBYTES must be no larger than CLBYTES (the software page size), and, 9753494Sdillon * on machines that exchange pages of input or output buffers with mbuf 9853494Sdillon * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple 9980146Siedowse * of the hardware page size. 10080146Siedowse */ 10153494Sdillon#ifndef MSIZE 10253494Sdillon#define MSIZE 128 /* size of an mbuf */ 10353494Sdillon#endif /* MSIZE */ 10480146Siedowse 10580146Siedowse#ifndef MCLSHIFT 10653494Sdillon#define MCLSHIFT 12 /* convert bytes to m_buf clusters */ 10753494Sdillon#endif /* MCLSHIFT */ 10853494Sdillon#define MCLBYTES (1 << MCLSHIFT) /* size of an m_buf cluster */ 10980146Siedowse#define MCLOFSET (MCLBYTES - 1) /* offset within an m_buf cluster */ 11080146Siedowse 11153494Sdillon#ifndef NMBCLUSTERS 11253494Sdillon#ifdef GATEWAY 11380146Siedowse#define NMBCLUSTERS 512 /* map size, max cluster allocation */ 11480146Siedowse#else 11580146Siedowse#define NMBCLUSTERS 256 /* map size, max cluster allocation */ 11653494Sdillon#endif /* GATEWAY */ 11753494Sdillon#endif /* NMBCLUSTERS */ 118201135Sdelphij 11953494Sdillon/* 12053494Sdillon * Some macros for units conversion 12153494Sdillon */ 12253494Sdillon/* Core clicks (4096 bytes) to segments and vice versa */ 12353494Sdillon#define ctos(x) (x) 124201135Sdelphij#define stoc(x) (x) 125194880Sdfr 126194880Sdfr/* Core clicks (4096 bytes) to disk blocks */ 127194880Sdfr#define ctod(x) ((x)<<(PGSHIFT-DEV_BSHIFT)) 128194880Sdfr#define dtoc(x) ((x)>>(PGSHIFT-DEV_BSHIFT)) 12953494Sdillon#define dtob(x) ((x)<<DEV_BSHIFT) 13053494Sdillon 13153494Sdillon/* clicks to bytes */ 13253494Sdillon#define ctob(x) ((x)<<PGSHIFT) 13353494Sdillon 13453494Sdillon/* bytes to clicks */ 13553494Sdillon#define btoc(x) (((unsigned)(x)+(NBPG-1))>>PGSHIFT) 13653494Sdillon 13753494Sdillon#define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ 13853494Sdillon ((unsigned)(bytes) >> DEV_BSHIFT) 13953494Sdillon#define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ 14053494Sdillon ((unsigned)(db) << DEV_BSHIFT) 14153494Sdillon 142201252Sed/* 143201252Sed * Map a ``block device block'' to a file system block. 14480146Siedowse * This should be device dependent, and will be if we 14553494Sdillon * add an entry to cdevsw/bdevsw for that purpose. 14653494Sdillon * For now though just use DEV_BSIZE. 14753494Sdillon */ 14853494Sdillon#define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) 14953494Sdillon 15053494Sdillon/* 15153494Sdillon * Mach derived conversion macros 15253494Sdillon */ 15353494Sdillon#define trunc_page(x) ((unsigned)(x) & ~(NBPG-1)) 15480146Siedowse#define round_page(x) ((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1)) 15580146Siedowse#define atop(x) ((unsigned)(x) >> PG_SHIFT) 15680146Siedowse#define ptoa(x) ((unsigned)(x) << PG_SHIFT) 15780146Siedowse 15880146Siedowse#define i386_round_pdr(x) ((((unsigned)(x)) + NBPDR - 1) & ~(NBPDR-1)) 15980146Siedowse#define i386_trunc_pdr(x) ((unsigned)(x) & ~(NBPDR-1)) 16080146Siedowse#define i386_round_page(x) ((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1)) 16180146Siedowse#define i386_trunc_page(x) ((unsigned)(x) & ~(NBPG-1)) 16280146Siedowse#define i386_btod(x) ((unsigned)(x) >> PDRSHIFT) 16380146Siedowse#define i386_dtob(x) ((unsigned)(x) << PDRSHIFT) 16480146Siedowse#define i386_btop(x) ((unsigned)(x) >> PGSHIFT) 16580146Siedowse#define i386_ptob(x) ((unsigned)(x) << PGSHIFT) 16680146Siedowse 16780146Siedowse#endif /* _MACHINE_PARAM_H_ */ 16880146Siedowse