1 /* $OpenBSD: param.h,v 1.40 2007/05/28 21:02:49 thib 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. Neither the name of the University nor the names of its contributors 20 * may be used to endorse or promote products derived from this software 21 * without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * 35 * @(#)param.h 5.8 (Berkeley) 6/28/91 36 */ 37 38 /* 39 * Machine dependent constants for Intel 386. 40 */ 41 42 #ifdef _KERNEL 43 #ifdef _LOCORE 44 #include <machine/psl.h> 45 #else 46 #include <machine/cpu.h> 47 #endif 48 #endif 49 50 #define _MACHINE i386 51 #define MACHINE "i386" 52 #define _MACHINE_ARCH i386 53 #define MACHINE_ARCH "i386" 54 #define MID_MACHINE MID_I386 55 56 /* 57 * Round p (pointer or byte index) up to a correctly-aligned value 58 * for all data types (int, long, ...). The result is u_int and 59 * must be cast to any desired pointer type. 60 * 61 * ALIGNED_POINTER is a boolean macro that checks whether an address 62 * is valid to fetch data elements of type t from on this architecture. 63 * This does not reflect the optimal alignment, just the possibility 64 * (within reasonable limits). 65 */ 66 #define ALIGNBYTES (sizeof(int) - 1) 67 #define ALIGN(p) (((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES) 68 #define ALIGNED_POINTER(p,t) 1 69 70 #define PGSHIFT 12 /* LOG2(NBPG) */ 71 #define NBPG (1 << PGSHIFT) /* bytes/page */ 72 #define PGOFSET (NBPG-1) /* byte offset into page */ 73 74 #define PAGE_SHIFT 12 75 #define PAGE_SIZE (1 << PAGE_SHIFT) 76 #define PAGE_MASK (PAGE_SIZE - 1) 77 78 #define NPTEPG (NBPG/(sizeof (pt_entry_t))) 79 80 /* 81 * Start of kernel virtual space. Remember to alter the memory and 82 * page table layout description in pmap.h when changing this. 83 */ 84 #define KERNBASE 0xd0000000 85 86 #define KERNTEXTOFF (KERNBASE+0x200000) /* start of kernel text */ 87 88 #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 89 #define DEV_BSIZE (1 << DEV_BSHIFT) 90 #define BLKDEV_IOSIZE 2048 91 #ifndef MAXPHYS 92 #define MAXPHYS (64 * 1024) /* max raw I/O transfer size */ 93 #endif 94 95 #define UPAGES 2 /* pages of u-area */ 96 #define USPACE (UPAGES * NBPG) /* total size of u-area */ 97 #define USPACE_ALIGN (0) /* u-area alignment 0-none */ 98 99 #ifndef MSGBUFSIZE 100 #define MSGBUFSIZE 4*NBPG /* default message buffer size */ 101 #endif 102 103 /* 104 * Constants related to network buffer management. 105 */ 106 #define NMBCLUSTERS 6144 /* map size, max cluster allocation */ 107 108 /* 109 * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized 110 * logical pages. 111 */ 112 #define NKMEMPAGES_MIN_DEFAULT ((8 * 1024 * 1024) >> PAGE_SHIFT) 113 #define NKMEMPAGES_MAX_DEFAULT ((64 * 1024 * 1024) >> PAGE_SHIFT) 114 115 /* pages ("clicks") to disk blocks */ 116 #define ctod(x) ((x) << (PGSHIFT - DEV_BSHIFT)) 117 #define dtoc(x) ((x) >> (PGSHIFT - DEV_BSHIFT)) 118 119 /* bytes to pages */ 120 #define ctob(x) ((x) << PGSHIFT) 121 #define btoc(x) (((x) + PGOFSET) >> PGSHIFT) 122 123 /* bytes to disk blocks */ 124 #define dbtob(x) ((x) << DEV_BSHIFT) 125 #define btodb(x) ((x) >> DEV_BSHIFT) 126 127 /* 128 * Mach derived conversion macros 129 */ 130 #define i386_round_pdr(x) ((((unsigned)(x)) + PDOFSET) & ~PDOFSET) 131 #define i386_trunc_pdr(x) ((unsigned)(x) & ~PDOFSET)