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