param.h revision 36977
167761Smsmith/*- 267761Smsmith * Copyright (c) 1990 The Regents of the University of California. 367761Smsmith * All rights reserved. 467761Smsmith * 567761Smsmith * This code is derived from software contributed to Berkeley by 667761Smsmith * William Jolitz. 767761Smsmith * 867761Smsmith * Redistribution and use in source and binary forms, with or without 967761Smsmith * modification, are permitted provided that the following conditions 1067761Smsmith * are met: 1167761Smsmith * 1. Redistributions of source code must retain the above copyright 1267761Smsmith * notice, this list of conditions and the following disclaimer. 1367761Smsmith * 2. Redistributions in binary form must reproduce the above copyright 1467761Smsmith * notice, this list of conditions and the following disclaimer in the 1567761Smsmith * documentation and/or other materials provided with the distribution. 1667761Smsmith * 3. All advertising materials mentioning features or use of this software 1767761Smsmith * must display the following acknowledgement: 1867761Smsmith * This product includes software developed by the University of 1967761Smsmith * California, Berkeley and its contributors. 2067761Smsmith * 4. Neither the name of the University nor the names of its contributors 2167761Smsmith * may be used to endorse or promote products derived from this software 2267761Smsmith * without specific prior written permission. 2367761Smsmith * 2467761Smsmith * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2567761Smsmith * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2667761Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2767761Smsmith * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28143002Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2967761Smsmith * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3067761Smsmith * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31142753Snjl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32142753Snjl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33142753Snjl * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34142984Snjl * SUCH DAMAGE. 35142984Snjl * 36131283Snjl * from: @(#)param.h 5.8 (Berkeley) 6/28/91 3767761Smsmith * $Id: param.h,v 1.42 1998/01/24 02:01:09 dyson Exp $ 3867761Smsmith */ 39153171Snjl 40105280Sjhb#ifndef _MACHINE_PARAM_H_ 41105280Sjhb#define _MACHINE_PARAM_H_ 42170976Snjl 43133611Snjl/* 44153171Snjl * Machine dependent constants for Intel 386. 4567761Smsmith */ 4680028Stakawata 4780028Stakawata#define MACHINE "i386" 4880028Stakawata#define MID_MACHINE MID_I386 49170976Snjl 5067761Smsmith#ifdef SMP 5167761Smsmith#define NCPUS 2 52160824Snjl#else 5367761Smsmith#define NCPUS 1 5467761Smsmith#endif 5567761Smsmith 5687566Siwasaki/* 57216674Sjhb * Round p (pointer or byte index) up to a correctly-aligned value 5867761Smsmith * for all data types (int, long, ...). The result is unsigned int 5971001Sjhb * and must be cast to any desired pointer type. 6071001Sjhb */ 6167761Smsmith#define ALIGNBYTES (sizeof(int) - 1) 6267761Smsmith#define ALIGN(p) (((unsigned)(p) + ALIGNBYTES) & ~ALIGNBYTES) 6367761Smsmith 6478662Siwasaki#define PAGE_SHIFT 12 /* LOG2(PAGE_SIZE) */ 6585556Siwasaki#define PAGE_SIZE (1<<PAGE_SHIFT) /* bytes/page */ 6685556Siwasaki#define PAGE_MASK (PAGE_SIZE-1) 6785556Siwasaki#define NPTEPG (PAGE_SIZE/(sizeof (pt_entry_t))) 68102402Siwasaki 6986133Siwasaki#define NPDEPG (PAGE_SIZE/(sizeof (pd_entry_t))) 70159543Snjl#define PDRSHIFT 22 /* LOG2(NBPDR) */ 7185699Siwasaki#define NBPDR (1<<PDRSHIFT) /* bytes/page dir */ 72160824Snjl#define PDRMASK (NBPDR-1) 7385699Siwasaki 7480028Stakawata#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 7580028Stakawata#define DEV_BSIZE (1<<DEV_BSHIFT) 7680028Stakawata 77112581Sjake#define BLKDEV_IOSIZE 2048 78170976Snjl#define DFLTPHYS (64 * 1024) /* default max raw I/O transfer size */ 79170976Snjl#define MAXPHYS (128 * 1024) /* max raw I/O transfer size */ 80170976Snjl 81170976Snjl#define IOPAGES 2 /* pages of i/o permission bitmap */ 82170976Snjl#define UPAGES 2 /* pages of u-area */ 8367761Smsmith#define UPAGES_HOLE 2 /* pages of "hole" at top of user space where */ 8467761Smsmith /* the upages used to be. DO NOT CHANGE! */ 8567761Smsmith 8667761Smsmith/* 8767761Smsmith * Constants related to network buffer management. 8867761Smsmith * MCLBYTES must be no larger than CLBYTES (the software page size), and, 89131341Snjl * on machines that exchange pages of input or output buffers with mbuf 9067761Smsmith * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple 91128225Snjl * of the hardware page size. 9267761Smsmith */ 93129783Snjl#ifndef MSIZE 9478994Smsmith#define MSIZE 128 /* size of an mbuf */ 95170976Snjl#endif /* MSIZE */ 96170976Snjl 97170976Snjl#ifndef MCLSHIFT 98170976Snjl#define MCLSHIFT 11 /* convert bytes to m_buf clusters */ 99170976Snjl#endif /* MCLSHIFT */ 100170976Snjl#define MCLBYTES (1 << MCLSHIFT) /* size of an m_buf cluster */ 101170976Snjl#define MCLOFSET (MCLBYTES - 1) /* offset within an m_buf cluster */ 102170976Snjl 103170976Snjl/* 104170976Snjl * Some macros for units conversion 105170976Snjl */ 106170976Snjl 107170976Snjl/* clicks to bytes */ 108170976Snjl#define ctob(x) ((x)<<PAGE_SHIFT) 109170976Snjl 110170976Snjl/* bytes to clicks */ 111131341Snjl#define btoc(x) (((unsigned)(x)+PAGE_MASK)>>PAGE_SHIFT) 112131341Snjl 113129783Snjl/* 114129806Snjl * btodb() is messy and perhaps slow because `bytes' may be an off_t. We 115129806Snjl * want to shift an unsigned type to avoid sign extension and we don't 116129806Snjl * want to widen `bytes' unnecessarily. Assume that the result fits in 117131341Snjl * a daddr_t. 118131341Snjl */ 11967761Smsmith#define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ 12067761Smsmith (sizeof (bytes) > sizeof(long) \ 121129783Snjl ? (daddr_t)((uoff_t)(bytes) >> DEV_BSHIFT) \ 122131341Snjl : (daddr_t)((unsigned long)(bytes) >> DEV_BSHIFT)) 123129783Snjl 124135574Sjhb#define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ 125135574Sjhb ((off_t)(db) << DEV_BSHIFT) 126135574Sjhb 127135574Sjhb/* 12867761Smsmith * Mach derived conversion macros 129133611Snjl */ 130133611Snjl#define trunc_page(x) ((unsigned)(x) & ~PAGE_MASK) 131133611Snjl#define round_page(x) ((((unsigned)(x)) + PAGE_MASK) & ~PAGE_MASK) 132133611Snjl#define trunc_4mpage(x) ((unsigned)(x) & ~PDRMASK) 133133611Snjl#define round_4mpage(x) ((((unsigned)(x)) + PDRMASK) & ~PDRMASK) 134133611Snjl 135133611Snjl#define atop(x) ((unsigned)(x) >> PAGE_SHIFT) 136133611Snjl#define ptoa(x) ((unsigned)(x) << PAGE_SHIFT) 137133611Snjl 138133611Snjl#define i386_btop(x) ((unsigned)(x) >> PAGE_SHIFT) 139133611Snjl#define i386_ptob(x) ((unsigned)(x) << PAGE_SHIFT) 140133611Snjl 141133611Snjl#endif /* !_MACHINE_PARAM_H_ */ 142133611Snjl