123264Smckusick /* 229186Smckusick * Copyright (c) 1982, 1986 Regents of the University of California. 323264Smckusick * All rights reserved. The Berkeley software License Agreement 423264Smckusick * specifies the terms and conditions for redistribution. 523264Smckusick * 6*48794Sbostic * @(#)param.h 7.18 (Berkeley) 04/28/91 723264Smckusick */ 89118Ssam 99118Ssam /* 1033278Sbostic * Machine dependent constants for VAX. 119118Ssam */ 1231162Sbostic #define MACHINE "vax" 1331162Sbostic 1440721Skarels /* 1540721Skarels * Round p (pointer or byte index) up to a correctly-aligned value 1640721Skarels * for all data types (int, long, ...). The result is u_int and 1740721Skarels * must be cast to any desired pointer type. 1840721Skarels */ 1940721Skarels #define ALIGN(p) (((u_int)(p) + (sizeof(int) - 1)) &~ (sizeof(int) - 1)) 2040721Skarels 2130407Skarels #define NBPG 512 /* bytes/page */ 2230407Skarels #define PGOFSET (NBPG-1) /* byte offset into page */ 2330407Skarels #define PGSHIFT 9 /* LOG2(NBPG) */ 2430407Skarels #define NPTEPG (NBPG/(sizeof (struct pte))) 259118Ssam 2633278Sbostic #define KERNBASE 0x80000000 /* start of kernel virtual */ 2740211Smarc #define KERNTEXTOFF KERNBASE /* start of kernel text */ 2833278Sbostic #define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) 2933278Sbostic 3030407Skarels #define DEV_BSIZE 512 3130407Skarels #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 3230407Skarels #define BLKDEV_IOSIZE 2048 3330766Skarels #define MAXPHYS (63 * 1024) /* max raw I/O transfer size */ 3430407Skarels 359118Ssam #define CLSIZE 2 369118Ssam #define CLSIZELOG2 1 379118Ssam 38*48794Sbostic /* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */ 3930407Skarels #define SSIZE 4 /* initial stack size/NBPG */ 4030407Skarels #define SINCR 4 /* increment of stack/NBPG */ 419118Ssam 4239820Smckusick #define UPAGES 16 /* pages of u-area */ 439118Ssam 449118Ssam /* 4538966Skarels * Constants related to network buffer management. 4638966Skarels * MCLBYTES must be no larger than CLBYTES (the software page size), and, 4738966Skarels * on machines that exchange pages of input or output buffers with mbuf 4838966Skarels * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple 4938966Skarels * of the hardware page size. 5038966Skarels */ 5138966Skarels #define MSIZE 128 /* size of an mbuf */ 5238966Skarels #define MAPPED_MBUFS /* can do scatter-gather I/O */ 5338966Skarels #if CLBYTES > 1024 5438966Skarels #define MCLBYTES 1024 5538966Skarels #define MCLSHIFT 10 5638966Skarels #define MCLOFSET (MCLBYTES - 1) 5738966Skarels #else 5838966Skarels #define MCLBYTES CLBYTES 5938966Skarels #define MCLSHIFT CLSHIFT 6038966Skarels #define MCLOFSET CLOFSET 6138966Skarels #endif 6238966Skarels #ifdef GATEWAY 6338966Skarels #define NMBCLUSTERS 512 /* map size, max cluster allocation */ 6438966Skarels #else 6538966Skarels #define NMBCLUSTERS 256 /* map size, max cluster allocation */ 6638966Skarels #endif 6738966Skarels 6838966Skarels /* 6941523Smckusick * Size of kernel malloc arena in CLBYTES-sized logical pages 7041523Smckusick */ 7141523Smckusick #ifndef NKMEMCLUSTERS 7241523Smckusick #define NKMEMCLUSTERS (512*1024/CLBYTES) 7341523Smckusick #endif 7441523Smckusick 7541523Smckusick /* 769118Ssam * Some macros for units conversion 779118Ssam */ 789118Ssam /* Core clicks (512 bytes) to segments and vice versa */ 799118Ssam #define ctos(x) (x) 809118Ssam #define stoc(x) (x) 819118Ssam 829118Ssam /* Core clicks (512 bytes) to disk blocks */ 839118Ssam #define ctod(x) (x) 849118Ssam #define dtoc(x) (x) 8530766Skarels #define dtob(x) ((x)<<PGSHIFT) 869118Ssam 879118Ssam /* clicks to bytes */ 889118Ssam #define ctob(x) ((x)<<9) 899118Ssam 909118Ssam /* bytes to clicks */ 919118Ssam #define btoc(x) ((((unsigned)(x)+511)>>9)) 929118Ssam 9330407Skarels #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ 9430407Skarels ((unsigned)(bytes) >> DEV_BSHIFT) 9530407Skarels #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ 9630407Skarels ((unsigned)(db) << DEV_BSHIFT) 9730407Skarels 989118Ssam /* 9930407Skarels * Map a ``block device block'' to a file system block. 10030407Skarels * This should be device dependent, and will be if we 10130407Skarels * add an entry to cdevsw/bdevsw for that purpose. 10230407Skarels * For now though just use DEV_BSIZE. 10330407Skarels */ 10430407Skarels #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) 10530407Skarels 10630407Skarels /* 1079118Ssam * Macros to decode processor status word. 1089118Ssam */ 1099118Ssam #define USERMODE(ps) (((ps) & PSL_CURMOD) == PSL_CURMOD) 1109600Ssam #define BASEPRI(ps) (((ps) & PSL_IPL) == 0) 1119118Ssam 11224887Skarels #ifdef KERNEL 11324887Skarels #ifndef LOCORE 11424887Skarels int cpuspeed; 11529953Skarels #define DELAY(n) { register int N = cpuspeed * (n); while (--N > 0); } 11624887Skarels #endif 11724887Skarels 11824887Skarels #else KERNEL 1199118Ssam #define DELAY(n) { register int N = (n); while (--N > 0); } 12024887Skarels #endif KERNEL 121