15b81b6b3SRodney W. Grimes /*- 25b81b6b3SRodney W. Grimes * Copyright (c) 1990 The Regents of the University of California. 35b81b6b3SRodney W. Grimes * All rights reserved. 45b81b6b3SRodney W. Grimes * 55b81b6b3SRodney W. Grimes * This code is derived from software contributed to Berkeley by 65b81b6b3SRodney W. Grimes * William Jolitz. 75b81b6b3SRodney W. Grimes * 85b81b6b3SRodney W. Grimes * Redistribution and use in source and binary forms, with or without 95b81b6b3SRodney W. Grimes * modification, are permitted provided that the following conditions 105b81b6b3SRodney W. Grimes * are met: 115b81b6b3SRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 125b81b6b3SRodney W. Grimes * notice, this list of conditions and the following disclaimer. 135b81b6b3SRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 145b81b6b3SRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 155b81b6b3SRodney W. Grimes * documentation and/or other materials provided with the distribution. 165b81b6b3SRodney W. Grimes * 3. All advertising materials mentioning features or use of this software 175b81b6b3SRodney W. Grimes * must display the following acknowledgement: 185b81b6b3SRodney W. Grimes * This product includes software developed by the University of 195b81b6b3SRodney W. Grimes * California, Berkeley and its contributors. 205b81b6b3SRodney W. Grimes * 4. Neither the name of the University nor the names of its contributors 215b81b6b3SRodney W. Grimes * may be used to endorse or promote products derived from this software 225b81b6b3SRodney W. Grimes * without specific prior written permission. 235b81b6b3SRodney W. Grimes * 245b81b6b3SRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 255b81b6b3SRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 265b81b6b3SRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 275b81b6b3SRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 285b81b6b3SRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 295b81b6b3SRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 305b81b6b3SRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 315b81b6b3SRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 325b81b6b3SRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 335b81b6b3SRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 345b81b6b3SRodney W. Grimes * SUCH DAMAGE. 355b81b6b3SRodney W. Grimes * 3689ec6ec6SRodney W. Grimes * from: @(#)param.h 5.8 (Berkeley) 6/28/91 37f0c2a198SBruce Evans * $Id: param.h,v 1.42 1998/01/24 02:01:09 dyson Exp $ 385b81b6b3SRodney W. Grimes */ 395b81b6b3SRodney W. Grimes 406e393973SGarrett Wollman #ifndef _MACHINE_PARAM_H_ 416052572aSBruce Evans #define _MACHINE_PARAM_H_ 426e393973SGarrett Wollman 435b81b6b3SRodney W. Grimes /* 445b81b6b3SRodney W. Grimes * Machine dependent constants for Intel 386. 455b81b6b3SRodney W. Grimes */ 465b81b6b3SRodney W. Grimes 475b81b6b3SRodney W. Grimes #define MACHINE "i386" 48f0c2a198SBruce Evans #define MID_MACHINE MID_I386 49f0c2a198SBruce Evans 5075d23f5fSSteve Passe #ifdef SMP 5175d23f5fSSteve Passe #define NCPUS 2 5275d23f5fSSteve Passe #else 53996c772fSJohn Dyson #define NCPUS 1 5475d23f5fSSteve Passe #endif 554a73d99fSSteve Passe 565b81b6b3SRodney W. Grimes /* 575b81b6b3SRodney W. Grimes * Round p (pointer or byte index) up to a correctly-aligned value 586052572aSBruce Evans * for all data types (int, long, ...). The result is unsigned int 596052572aSBruce Evans * and must be cast to any desired pointer type. 605b81b6b3SRodney W. Grimes */ 61f798d060SNate Williams #define ALIGNBYTES (sizeof(int) - 1) 626052572aSBruce Evans #define ALIGN(p) (((unsigned)(p) + ALIGNBYTES) & ~ALIGNBYTES) 63f798d060SNate Williams 64e911eafcSPoul-Henning Kamp #define PAGE_SHIFT 12 /* LOG2(PAGE_SIZE) */ 65e911eafcSPoul-Henning Kamp #define PAGE_SIZE (1<<PAGE_SHIFT) /* bytes/page */ 66ec120393SDavid Greenman #define PAGE_MASK (PAGE_SIZE-1) 67e911eafcSPoul-Henning Kamp #define NPTEPG (PAGE_SIZE/(sizeof (pt_entry_t))) 685b81b6b3SRodney W. Grimes 695084d10dSPoul-Henning Kamp #define NPDEPG (PAGE_SIZE/(sizeof (pd_entry_t))) 705b81b6b3SRodney W. Grimes #define PDRSHIFT 22 /* LOG2(NBPDR) */ 71c77ba360SRodney W. Grimes #define NBPDR (1<<PDRSHIFT) /* bytes/page dir */ 72d3d1eb99SJohn Dyson #define PDRMASK (NBPDR-1) 735b81b6b3SRodney W. Grimes 745b81b6b3SRodney W. Grimes #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 75c77ba360SRodney W. Grimes #define DEV_BSIZE (1<<DEV_BSHIFT) 76c77ba360SRodney W. Grimes 775b81b6b3SRodney W. Grimes #define BLKDEV_IOSIZE 2048 7850ce7ff4SJohn Dyson #define DFLTPHYS (64 * 1024) /* default max raw I/O transfer size */ 7950ce7ff4SJohn Dyson #define MAXPHYS (128 * 1024) /* max raw I/O transfer size */ 805b81b6b3SRodney W. Grimes 8148a09cf2SJohn Dyson #define IOPAGES 2 /* pages of i/o permission bitmap */ 825b81b6b3SRodney W. Grimes #define UPAGES 2 /* pages of u-area */ 83de871ab6SPeter Wemm #define UPAGES_HOLE 2 /* pages of "hole" at top of user space where */ 84de871ab6SPeter Wemm /* the upages used to be. DO NOT CHANGE! */ 855b81b6b3SRodney W. Grimes 865b81b6b3SRodney W. Grimes /* 875b81b6b3SRodney W. Grimes * Constants related to network buffer management. 885b81b6b3SRodney W. Grimes * MCLBYTES must be no larger than CLBYTES (the software page size), and, 895b81b6b3SRodney W. Grimes * on machines that exchange pages of input or output buffers with mbuf 905b81b6b3SRodney W. Grimes * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple 915b81b6b3SRodney W. Grimes * of the hardware page size. 925b81b6b3SRodney W. Grimes */ 935b81b6b3SRodney W. Grimes #ifndef MSIZE 945b81b6b3SRodney W. Grimes #define MSIZE 128 /* size of an mbuf */ 955b81b6b3SRodney W. Grimes #endif /* MSIZE */ 965b81b6b3SRodney W. Grimes 975b81b6b3SRodney W. Grimes #ifndef MCLSHIFT 98fb1322e4SDavid Greenman #define MCLSHIFT 11 /* convert bytes to m_buf clusters */ 995b81b6b3SRodney W. Grimes #endif /* MCLSHIFT */ 100c77ba360SRodney W. Grimes #define MCLBYTES (1 << MCLSHIFT) /* size of an m_buf cluster */ 101c77ba360SRodney W. Grimes #define MCLOFSET (MCLBYTES - 1) /* offset within an m_buf cluster */ 1025b81b6b3SRodney W. Grimes 1035b81b6b3SRodney W. Grimes /* 1045b81b6b3SRodney W. Grimes * Some macros for units conversion 1055b81b6b3SRodney W. Grimes */ 1065b81b6b3SRodney W. Grimes 1075b81b6b3SRodney W. Grimes /* clicks to bytes */ 108e911eafcSPoul-Henning Kamp #define ctob(x) ((x)<<PAGE_SHIFT) 1095b81b6b3SRodney W. Grimes 1105b81b6b3SRodney W. Grimes /* bytes to clicks */ 111e911eafcSPoul-Henning Kamp #define btoc(x) (((unsigned)(x)+PAGE_MASK)>>PAGE_SHIFT) 1125b81b6b3SRodney W. Grimes 1135b81b6b3SRodney W. Grimes /* 114bb2038d5SBruce Evans * btodb() is messy and perhaps slow because `bytes' may be an off_t. We 115bb2038d5SBruce Evans * want to shift an unsigned type to avoid sign extension and we don't 116bb2038d5SBruce Evans * want to widen `bytes' unnecessarily. Assume that the result fits in 117bb2038d5SBruce Evans * a daddr_t. 1185b81b6b3SRodney W. Grimes */ 11943decb53SGary Palmer #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ 12043decb53SGary Palmer (sizeof (bytes) > sizeof(long) \ 121f0c2a198SBruce Evans ? (daddr_t)((uoff_t)(bytes) >> DEV_BSHIFT) \ 122bb2038d5SBruce Evans : (daddr_t)((unsigned long)(bytes) >> DEV_BSHIFT)) 123bb2038d5SBruce Evans 12443decb53SGary Palmer #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ 125bb2038d5SBruce Evans ((off_t)(db) << DEV_BSHIFT) 1265b81b6b3SRodney W. Grimes 1275b81b6b3SRodney W. Grimes /* 1285b81b6b3SRodney W. Grimes * Mach derived conversion macros 1295b81b6b3SRodney W. Grimes */ 130e911eafcSPoul-Henning Kamp #define trunc_page(x) ((unsigned)(x) & ~PAGE_MASK) 131e911eafcSPoul-Henning Kamp #define round_page(x) ((((unsigned)(x)) + PAGE_MASK) & ~PAGE_MASK) 132d3d1eb99SJohn Dyson #define trunc_4mpage(x) ((unsigned)(x) & ~PDRMASK) 133d3d1eb99SJohn Dyson #define round_4mpage(x) ((((unsigned)(x)) + PDRMASK) & ~PDRMASK) 13426f9a767SRodney W. Grimes 135e911eafcSPoul-Henning Kamp #define atop(x) ((unsigned)(x) >> PAGE_SHIFT) 136e911eafcSPoul-Henning Kamp #define ptoa(x) ((unsigned)(x) << PAGE_SHIFT) 137ec120393SDavid Greenman 138e911eafcSPoul-Henning Kamp #define i386_btop(x) ((unsigned)(x) >> PAGE_SHIFT) 139e911eafcSPoul-Henning Kamp #define i386_ptob(x) ((unsigned)(x) << PAGE_SHIFT) 140d529c3d8SRodney W. Grimes 1416052572aSBruce Evans #endif /* !_MACHINE_PARAM_H_ */ 142