param.h revision 40286
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 3740286Sdg * $Id: param.h,v 1.46 1998/09/09 01:21:25 jdp Exp $ 384Srgrimes */ 394Srgrimes 40719Swollman#ifndef _MACHINE_PARAM_H_ 412867Sbde#define _MACHINE_PARAM_H_ 42719Swollman 434Srgrimes/* 444Srgrimes * Machine dependent constants for Intel 386. 454Srgrimes */ 4638673Skato#define _MACHINE i386 47551Srgrimes#define MACHINE "i386" 4838673Skato#define _MACHINE_ARCH i386 4938673Skato#define MACHINE_ARCH "i386" 5036977Sbde#define MID_MACHINE MID_I386 5136977Sbde 5238960Sjdp/* 5338960Sjdp * OBJFORMAT_NAMES is a comma-separated list of the object formats 5438960Sjdp * that are supported on the architecture. 5538960Sjdp */ 5638960Sjdp#define OBJFORMAT_NAMES "elf", "aout" 5738960Sjdp#ifdef __ELF__ 5838960Sjdp#define OBJFORMAT_DEFAULT "elf" 5938960Sjdp#else 6038960Sjdp#define OBJFORMAT_DEFAULT "aout" 6138960Sjdp#endif 6238960Sjdp 6328354Sfsmp#ifdef SMP 6428354Sfsmp#define NCPUS 2 6528354Sfsmp#else 6622521Sdyson#define NCPUS 1 6728354Sfsmp#endif 684Srgrimes 694Srgrimes/* 704Srgrimes * Round p (pointer or byte index) up to a correctly-aligned value 712867Sbde * for all data types (int, long, ...). The result is unsigned int 722867Sbde * and must be cast to any desired pointer type. 734Srgrimes */ 74203Snate#define ALIGNBYTES (sizeof(int) - 1) 752867Sbde#define ALIGN(p) (((unsigned)(p) + ALIGNBYTES) & ~ALIGNBYTES) 764Srgrimes 7715543Sphk#define PAGE_SHIFT 12 /* LOG2(PAGE_SIZE) */ 7815565Sphk#define PAGE_SIZE (1<<PAGE_SHIFT) /* bytes/page */ 791045Sdg#define PAGE_MASK (PAGE_SIZE-1) 8015543Sphk#define NPTEPG (PAGE_SIZE/(sizeof (pt_entry_t))) 8115565Sphk 8215543Sphk#define NPDEPG (PAGE_SIZE/(sizeof (pd_entry_t))) 83584Srgrimes#define PDRSHIFT 22 /* LOG2(NBPDR) */ 8415565Sphk#define NBPDR (1<<PDRSHIFT) /* bytes/page dir */ 8527950Sdyson#define PDRMASK (NBPDR-1) 864Srgrimes 87584Srgrimes#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 8815565Sphk#define DEV_BSIZE (1<<DEV_BSHIFT) 89552Srgrimes 904Srgrimes#define BLKDEV_IOSIZE 2048 9136977Sbde#define DFLTPHYS (64 * 1024) /* default max raw I/O transfer size */ 9232724Sdyson#define MAXPHYS (128 * 1024) /* max raw I/O transfer size */ 934Srgrimes 9427993Sdyson#define IOPAGES 2 /* pages of i/o permission bitmap */ 95584Srgrimes#define UPAGES 2 /* pages of u-area */ 9624695Speter#define UPAGES_HOLE 2 /* pages of "hole" at top of user space where */ 9724695Speter /* the upages used to be. DO NOT CHANGE! */ 984Srgrimes 994Srgrimes/* 1004Srgrimes * Constants related to network buffer management. 1014Srgrimes * MCLBYTES must be no larger than CLBYTES (the software page size), and, 1024Srgrimes * on machines that exchange pages of input or output buffers with mbuf 1034Srgrimes * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple 1044Srgrimes * of the hardware page size. 1054Srgrimes */ 1064Srgrimes#ifndef MSIZE 107584Srgrimes#define MSIZE 128 /* size of an mbuf */ 1084Srgrimes#endif /* MSIZE */ 1094Srgrimes 1104Srgrimes#ifndef MCLSHIFT 1115809Sdg#define MCLSHIFT 11 /* convert bytes to m_buf clusters */ 1124Srgrimes#endif /* MCLSHIFT */ 113584Srgrimes#define MCLBYTES (1 << MCLSHIFT) /* size of an m_buf cluster */ 114584Srgrimes#define MCLOFSET (MCLBYTES - 1) /* offset within an m_buf cluster */ 1154Srgrimes 1164Srgrimes/* 1174Srgrimes * Some macros for units conversion 1184Srgrimes */ 1194Srgrimes 1204Srgrimes/* clicks to bytes */ 12115543Sphk#define ctob(x) ((x)<<PAGE_SHIFT) 1224Srgrimes 1234Srgrimes/* bytes to clicks */ 12415543Sphk#define btoc(x) (((unsigned)(x)+PAGE_MASK)>>PAGE_SHIFT) 1254Srgrimes 1266558Sgpalmer/* 12718770Sbde * btodb() is messy and perhaps slow because `bytes' may be an off_t. We 12818770Sbde * want to shift an unsigned type to avoid sign extension and we don't 12918770Sbde * want to widen `bytes' unnecessarily. Assume that the result fits in 13018770Sbde * a daddr_t. 1316558Sgpalmer */ 132584Srgrimes#define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ 1336558Sgpalmer (sizeof (bytes) > sizeof(long) \ 13436996Sbde ? (daddr_t)((unsigned long long)(bytes) >> DEV_BSHIFT) \ 13518770Sbde : (daddr_t)((unsigned long)(bytes) >> DEV_BSHIFT)) 13618770Sbde 137584Srgrimes#define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ 13818770Sbde ((off_t)(db) << DEV_BSHIFT) 1394Srgrimes 1404Srgrimes/* 1414Srgrimes * Mach derived conversion macros 1424Srgrimes */ 14340286Sdg#define trunc_page(x) ((x) & ~PAGE_MASK) 14440286Sdg#define round_page(x) (((x) + PAGE_MASK) & ~PAGE_MASK) 14527950Sdyson#define trunc_4mpage(x) ((unsigned)(x) & ~PDRMASK) 14627950Sdyson#define round_4mpage(x) ((((unsigned)(x)) + PDRMASK) & ~PDRMASK) 1471549Srgrimes 14815543Sphk#define atop(x) ((unsigned)(x) >> PAGE_SHIFT) 14915543Sphk#define ptoa(x) ((unsigned)(x) << PAGE_SHIFT) 1501045Sdg 15115543Sphk#define i386_btop(x) ((unsigned)(x) >> PAGE_SHIFT) 15215543Sphk#define i386_ptob(x) ((unsigned)(x) << PAGE_SHIFT) 153584Srgrimes 1542867Sbde#endif /* !_MACHINE_PARAM_H_ */ 155