param.h revision 5809
14Srgrimes/*- 24Srgrimes * Copyright (c) 1990 The Regents of the University of California. 34Srgrimes * All rights reserved. 44Srgrimes * 54Srgrimes * This code is derived from software contributed to Berkeley by 64Srgrimes * William Jolitz. 74Srgrimes * 84Srgrimes * Redistribution and use in source and binary forms, with or without 94Srgrimes * modification, are permitted provided that the following conditions 104Srgrimes * are met: 114Srgrimes * 1. Redistributions of source code must retain the above copyright 124Srgrimes * notice, this list of conditions and the following disclaimer. 134Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 144Srgrimes * notice, this list of conditions and the following disclaimer in the 154Srgrimes * documentation and/or other materials provided with the distribution. 164Srgrimes * 3. All advertising materials mentioning features or use of this software 174Srgrimes * must display the following acknowledgement: 184Srgrimes * This product includes software developed by the University of 194Srgrimes * California, Berkeley and its contributors. 204Srgrimes * 4. Neither the name of the University nor the names of its contributors 214Srgrimes * may be used to endorse or promote products derived from this software 224Srgrimes * without specific prior written permission. 234Srgrimes * 244Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 254Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 264Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 274Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 284Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 294Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 304Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 314Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 324Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 334Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 344Srgrimes * SUCH DAMAGE. 354Srgrimes * 36551Srgrimes * from: @(#)param.h 5.8 (Berkeley) 6/28/91 375809Sdg * $Id: param.h,v 1.16 1994/09/18 22:05:22 bde Exp $ 384Srgrimes */ 394Srgrimes 40719Swollman#ifndef _MACHINE_PARAM_H_ 412867Sbde#define _MACHINE_PARAM_H_ 42719Swollman 434Srgrimes/* 444Srgrimes * Machine dependent constants for Intel 386. 454Srgrimes */ 464Srgrimes 47551Srgrimes#define MACHINE "i386" 48551Srgrimes#define MID_MACHINE MID_I386 494Srgrimes 504Srgrimes/* 514Srgrimes * Round p (pointer or byte index) up to a correctly-aligned value 522867Sbde * for all data types (int, long, ...). The result is unsigned int 532867Sbde * and must be cast to any desired pointer type. 544Srgrimes */ 55203Snate#define ALIGNBYTES (sizeof(int) - 1) 562867Sbde#define ALIGN(p) (((unsigned)(p) + ALIGNBYTES) & ~ALIGNBYTES) 574Srgrimes 58607Srgrimes/* XXX PGSHIFT and PG_SHIFT are two names for the same thing */ 59584Srgrimes#define PGSHIFT 12 /* LOG2(NBPG) */ 601045Sdg#define PAGE_SHIFT 12 611045Sdg#define NBPG (1 << PAGE_SHIFT) /* bytes/page */ 621045Sdg#define PAGE_SIZE (1 << PAGE_SHIFT) 631045Sdg#define PAGE_MASK (PAGE_SIZE-1) 64584Srgrimes#define PGOFSET (NBPG-1) /* byte offset into page */ 651246Sdg#define NPTEPG (NBPG/(sizeof (pt_entry_t))) 664Srgrimes 67607Srgrimes/* XXX PDRSHIFT and PD_SHIFT are two names for the same thing */ 68584Srgrimes#define PDRSHIFT 22 /* LOG2(NBPDR) */ 69552Srgrimes#define NBPDR (1 << PDRSHIFT) /* bytes/page dir */ 70584Srgrimes#define PDROFSET (NBPDR-1) /* byte offset into page dir */ 714Srgrimes 72607Srgrimes/* 73607Srgrimes * XXX This should really be KPTDPTDI << PDRSHIFT, but since KPTDPTDI is 74607Srgrimes * defined in pmap.h which is included after this we can't do that 75607Srgrimes * (YET!) 76607Srgrimes */ 77879Swollman#define BTOPKERNBASE (KERNBASE >> PGSHIFT) 784Srgrimes 79584Srgrimes#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 80584Srgrimes#define DEV_BSIZE (1 << DEV_BSHIFT) 81552Srgrimes 824Srgrimes#define BLKDEV_IOSIZE 2048 83584Srgrimes#define MAXPHYS (64 * 1024) /* max raw I/O transfer size */ 844Srgrimes 85584Srgrimes#define CLSIZELOG2 0 86584Srgrimes#define CLSIZE (1 << CLSIZELOG2) 874Srgrimes 884Srgrimes/* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */ 89584Srgrimes#define SSIZE 1 /* initial stack size/NBPG */ 90584Srgrimes#define SINCR 1 /* increment of stack/NBPG */ 914Srgrimes 92584Srgrimes#define UPAGES 2 /* pages of u-area */ 934Srgrimes 944Srgrimes/* 954Srgrimes * Constants related to network buffer management. 964Srgrimes * MCLBYTES must be no larger than CLBYTES (the software page size), and, 974Srgrimes * on machines that exchange pages of input or output buffers with mbuf 984Srgrimes * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple 994Srgrimes * of the hardware page size. 1004Srgrimes */ 1014Srgrimes#ifndef MSIZE 102584Srgrimes#define MSIZE 128 /* size of an mbuf */ 1034Srgrimes#endif /* MSIZE */ 1044Srgrimes 1054Srgrimes#ifndef MCLSHIFT 1065809Sdg#define MCLSHIFT 11 /* convert bytes to m_buf clusters */ 1074Srgrimes#endif /* MCLSHIFT */ 108584Srgrimes#define MCLBYTES (1 << MCLSHIFT) /* size of an m_buf cluster */ 109584Srgrimes#define MCLOFSET (MCLBYTES - 1) /* offset within an m_buf cluster */ 1104Srgrimes 1114Srgrimes#ifndef NMBCLUSTERS 1124Srgrimes#ifdef GATEWAY 113584Srgrimes#define NMBCLUSTERS 512 /* map size, max cluster allocation */ 1144Srgrimes#else 115584Srgrimes#define NMBCLUSTERS 256 /* map size, max cluster allocation */ 1164Srgrimes#endif /* GATEWAY */ 1174Srgrimes#endif /* NMBCLUSTERS */ 1184Srgrimes 1194Srgrimes/* 1204Srgrimes * Some macros for units conversion 1214Srgrimes */ 1224Srgrimes/* Core clicks (4096 bytes) to segments and vice versa */ 123584Srgrimes#define ctos(x) (x) 124584Srgrimes#define stoc(x) (x) 1254Srgrimes 1264Srgrimes/* Core clicks (4096 bytes) to disk blocks */ 127584Srgrimes#define ctod(x) ((x)<<(PGSHIFT-DEV_BSHIFT)) 128584Srgrimes#define dtoc(x) ((x)>>(PGSHIFT-DEV_BSHIFT)) 129584Srgrimes#define dtob(x) ((x)<<DEV_BSHIFT) 1304Srgrimes 1314Srgrimes/* clicks to bytes */ 132584Srgrimes#define ctob(x) ((x)<<PGSHIFT) 1334Srgrimes 1344Srgrimes/* bytes to clicks */ 135584Srgrimes#define btoc(x) (((unsigned)(x)+(NBPG-1))>>PGSHIFT) 1364Srgrimes 137584Srgrimes#define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ 1384Srgrimes ((unsigned)(bytes) >> DEV_BSHIFT) 139584Srgrimes#define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ 1404Srgrimes ((unsigned)(db) << DEV_BSHIFT) 1414Srgrimes 1424Srgrimes/* 1434Srgrimes * Map a ``block device block'' to a file system block. 1444Srgrimes * This should be device dependent, and will be if we 1454Srgrimes * add an entry to cdevsw/bdevsw for that purpose. 1464Srgrimes * For now though just use DEV_BSIZE. 1474Srgrimes */ 148584Srgrimes#define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) 1494Srgrimes 1504Srgrimes/* 1514Srgrimes * Mach derived conversion macros 1524Srgrimes */ 1531045Sdg#define trunc_page(x) ((unsigned)(x) & ~(NBPG-1)) 1541045Sdg#define round_page(x) ((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1)) 1551549Srgrimes 1561045Sdg#define atop(x) ((unsigned)(x) >> PG_SHIFT) 1571045Sdg#define ptoa(x) ((unsigned)(x) << PG_SHIFT) 1581045Sdg 1594Srgrimes#define i386_round_pdr(x) ((((unsigned)(x)) + NBPDR - 1) & ~(NBPDR-1)) 1604Srgrimes#define i386_trunc_pdr(x) ((unsigned)(x) & ~(NBPDR-1)) 1614Srgrimes#define i386_round_page(x) ((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1)) 1624Srgrimes#define i386_trunc_page(x) ((unsigned)(x) & ~(NBPG-1)) 1634Srgrimes#define i386_btod(x) ((unsigned)(x) >> PDRSHIFT) 1644Srgrimes#define i386_dtob(x) ((unsigned)(x) << PDRSHIFT) 1654Srgrimes#define i386_btop(x) ((unsigned)(x) >> PGSHIFT) 1664Srgrimes#define i386_ptob(x) ((unsigned)(x) << PGSHIFT) 167584Srgrimes 1682867Sbde#endif /* !_MACHINE_PARAM_H_ */ 169