1 /*- 2 * Copyright (c) 1982, 1986, 1988 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Computer Consoles Inc. 7 * 8 * %sccs.include.proprietary.c% 9 * 10 * @(#)param.h 7.9 (Berkeley) 05/08/91 11 */ 12 13 /* 14 * Machine dependent constants for TAHOE. 15 */ 16 #define MACHINE "tahoe" 17 18 /* 19 * Round p (pointer or byte index) up to a correctly-aligned value 20 * for all data types (int, long, ...). The result is u_int and 21 * must be cast to any desired pointer type. 22 */ 23 #define ALIGN(p) (((u_int)(p) + (sizeof(int) - 1)) &~ (sizeof(int) - 1)) 24 25 #define NBPG 1024 /* bytes/page */ 26 #define PGOFSET (NBPG-1) /* byte offset into page */ 27 #define PGSHIFT 10 /* LOG2(NBPG) */ 28 #define NPTEPG (NBPG/(sizeof (struct pte))) 29 30 #define KERNBASE 0xc0000000 /* start of kernel virtual */ 31 #define KERNTEXTOFF (KERNBASE + 0x800) /* start of kernel text */ 32 #define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) 33 34 #define DEV_BSIZE 1024 35 #define DEV_BSHIFT 10 /* log2(DEV_BSIZE) */ 36 #define BLKDEV_IOSIZE 1024 /* NBPG for physical controllers */ 37 #define MAXPHYS (64 * 1024) /* max raw I/O transfer size */ 38 39 #define CLSIZE 1 40 #define CLSIZELOG2 0 41 42 /* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */ 43 #define SSIZE 2 /* initial stack size/NBPG */ 44 #define SINCR 2 /* increment of stack/NBPG */ 45 #define UPAGES 8 /* pages of u-area (2 stack pages) */ 46 47 /* 48 * Constants related to network buffer management. 49 * MCLBYTES must be no larger than CLBYTES (the software page size), and, 50 * on machines that exchange pages of input or output buffers with mbuf 51 * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple 52 * of the hardware page size. 53 */ 54 #define MSIZE 128 /* size of an mbuf */ 55 #define MAPPED_MBUFS /* can do scatter-gather I/O */ 56 #if CLBYTES > 1024 57 #define MCLBYTES 1024 58 #define MCLSHIFT 10 59 #define MCLOFSET (MCLBYTES - 1) 60 #else 61 #define MCLBYTES CLBYTES 62 #define MCLSHIFT CLSHIFT 63 #define MCLOFSET CLOFSET 64 #endif 65 #ifdef GATEWAY 66 #define NMBCLUSTERS 512 /* map size, max cluster allocation */ 67 #else 68 #define NMBCLUSTERS 256 /* map size, max cluster allocation */ 69 #endif 70 71 #define MAXCKEY 255 /* maximal allowed code key */ 72 #define MAXDKEY 255 /* maximal allowed data key */ 73 #define NCKEY (MAXCKEY+1) /* # code keys, including 0 (reserved) */ 74 #define NDKEY (MAXDKEY+1) /* # data keys, including 0 (reserved) */ 75 76 /* 77 * Size of kernel malloc arena in CLBYTES-sized logical pages 78 */ 79 #ifndef NKMEMCLUSTERS 80 #define NKMEMCLUSTERS (512*1024/CLBYTES) 81 #endif 82 83 /* 84 * Some macros for units conversion 85 */ 86 /* Core clicks (1024 bytes) to segments and vice versa */ 87 #define ctos(x) (x) 88 #define stoc(x) (x) 89 90 /* Core clicks (1024 bytes) to disk blocks */ 91 #define ctod(x) (x) 92 #define dtoc(x) (x) 93 #define dtob(x) ((x)<<PGSHIFT) 94 95 /* clicks to bytes */ 96 #define ctob(x) ((x)<<PGSHIFT) 97 98 /* bytes to clicks */ 99 #define btoc(x) ((((unsigned)(x)+NBPG-1) >> PGSHIFT)) 100 101 #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ 102 ((unsigned)(bytes) >> DEV_BSHIFT) 103 #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ 104 ((unsigned)(db) << DEV_BSHIFT) 105 106 /* 107 * Map a ``block device block'' to a file system block. 108 * This should be device dependent, and will be if we 109 * add an entry to cdevsw/bdevsw for that purpose. 110 * For now though just use DEV_BSIZE. 111 */ 112 #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) 113 114 /* 115 * Macros to decode processor status word. 116 */ 117 #define USERMODE(ps) (((ps) & PSL_CURMOD) == PSL_CURMOD) 118 #define BASEPRI(ps) (((ps) & PSL_IPL) == 0) 119 120 #define DELAY(n) { register int N = 3*(n); while (--N > 0); } 121