1 /* $OpenBSD: param.h,v 1.18 2001/07/18 10:47:04 art Exp $ */ 2 /* $NetBSD: param.h,v 1.29 1996/03/04 05:04:26 cgd Exp $ */ 3 4 /*- 5 * Copyright (c) 1990 The Regents of the University of California. 6 * All rights reserved. 7 * 8 * This code is derived from software contributed to Berkeley by 9 * William Jolitz. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 3. All advertising materials mentioning features or use of this software 20 * must display the following acknowledgement: 21 * This product includes software developed by the University of 22 * California, Berkeley and its contributors. 23 * 4. Neither the name of the University nor the names of its contributors 24 * may be used to endorse or promote products derived from this software 25 * without specific prior written permission. 26 * 27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * SUCH DAMAGE. 38 * 39 * @(#)param.h 5.8 (Berkeley) 6/28/91 40 */ 41 42 /* 43 * Machine dependent constants for Intel 386. 44 */ 45 46 #ifdef _KERNEL 47 #ifdef _LOCORE 48 #include <machine/psl.h> 49 #else 50 #include <machine/cpu.h> 51 #endif 52 #endif 53 54 #define _MACHINE i386 55 #define MACHINE "i386" 56 #define _MACHINE_ARCH i386 57 #define MACHINE_ARCH "i386" 58 #define MID_MACHINE MID_I386 59 60 /* 61 * Round p (pointer or byte index) up to a correctly-aligned value 62 * for all data types (int, long, ...). The result is u_int and 63 * must be cast to any desired pointer type. 64 */ 65 #define ALIGNBYTES (sizeof(int) - 1) 66 #define ALIGN(p) (((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES) 67 68 #define PGSHIFT 12 /* LOG2(NBPG) */ 69 #define NBPG (1 << PGSHIFT) /* bytes/page */ 70 #define PGOFSET (NBPG-1) /* byte offset into page */ 71 72 #define PAGE_SHIFT 12 73 #define PAGE_SIZE (1 << PAGE_SHIFT) 74 #define PAGE_MASK (PAGE_SIZE - 1) 75 76 #define NPTEPG (NBPG/(sizeof (pt_entry_t))) 77 78 #define KERNBASE 0xe0000000 /* start of kernel virtual space */ 79 #define KERNTEXTOFF (KERNBASE+0x100000) /* start of kernel text */ 80 #define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) 81 82 #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 83 #define DEV_BSIZE (1 << DEV_BSHIFT) 84 #define BLKDEV_IOSIZE 2048 85 #ifndef MAXPHYS 86 #define MAXPHYS (64 * 1024) /* max raw I/O transfer size */ 87 #endif 88 89 #define SSIZE 1 /* initial stack size/NBPG */ 90 #define SINCR 1 /* increment of stack/NBPG */ 91 #define UPAGES 2 /* pages of u-area */ 92 #define USPACE (UPAGES * NBPG) /* total size of u-area */ 93 94 #ifndef MSGBUFSIZE 95 #define MSGBUFSIZE 2*NBPG /* default message buffer size */ 96 #endif 97 98 /* 99 * Constants related to network buffer management. 100 * MCLBYTES must be no larger than the software page size, and, 101 * on machines that exchange pages of input or output buffers with mbuf 102 * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple 103 * of the hardware page size. 104 */ 105 #define MSIZE 256 /* size of an mbuf */ 106 #define MCLSHIFT 11 /* convert bytes to m_buf clusters */ 107 #define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */ 108 #define MCLOFSET (MCLBYTES - 1) /* offset within a m_buf cluster */ 109 110 #ifndef NMBCLUSTERS 111 #define NMBCLUSTERS 2048 /* map size, max cluster allocation */ 112 #endif 113 114 /* 115 * Size of kernel malloc arena in logical pages 116 */ 117 #ifndef NKMEMCLUSTERS 118 #define NKMEMCLUSTERS (16 * 1024 * 1024 / PAGE_SIZE) 119 #endif 120 121 /* pages ("clicks") to disk blocks */ 122 #define ctod(x) ((x) << (PGSHIFT - DEV_BSHIFT)) 123 #define dtoc(x) ((x) >> (PGSHIFT - DEV_BSHIFT)) 124 125 /* bytes to pages */ 126 #define ctob(x) ((x) << PGSHIFT) 127 #define btoc(x) (((x) + PGOFSET) >> PGSHIFT) 128 129 /* bytes to disk blocks */ 130 #define dbtob(x) ((x) << DEV_BSHIFT) 131 #define btodb(x) ((x) >> DEV_BSHIFT) 132 133 /* 134 * Map a ``block device block'' to a file system block. 135 * This should be device dependent, and should use the bsize 136 * field from the disk label. 137 * For now though just use DEV_BSIZE. 138 */ 139 #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE / DEV_BSIZE)) 140 141 /* 142 * Mach derived conversion macros 143 */ 144 #define i386_round_pdr(x) ((((unsigned)(x)) + PDOFSET) & ~PDOFSET) 145 #define i386_trunc_pdr(x) ((unsigned)(x) & ~PDOFSET) 146 #define i386_btod(x) ((unsigned)(x) >> PDSHIFT) 147 #define i386_dtob(x) ((unsigned)(x) << PDSHIFT) 148 #define i386_round_page(x) ((((unsigned)(x)) + PGOFSET) & ~PGOFSET) 149 #define i386_trunc_page(x) ((unsigned)(x) & ~PGOFSET) 150 #define i386_btop(x) ((unsigned)(x) >> PGSHIFT) 151 #define i386_ptob(x) ((unsigned)(x) << PGSHIFT) 152