133282Skarels /* 234408Skarels * Copyright (c) 1982, 1986, 1988 Regents of the University of California. 333282Skarels * All rights reserved. The Berkeley software License Agreement 433282Skarels * specifies the terms and conditions for redistribution. 533282Skarels * 6*40722Skarels * @(#)param.h 7.5 (Berkeley) 04/03/90 733282Skarels */ 825681Ssam 925681Ssam /* 1025681Ssam * Machine dependent constants for TAHOE. 1125681Ssam */ 1231163Sbostic #define MACHINE "tahoe" 1331163Sbostic 1433380Skarels #ifndef BYTE_ORDER 1533282Skarels #include <machine/endian.h> 1633282Skarels #endif 1733282Skarels 1838968Skarels #include <machine/machlimits.h> 1932564Sbostic 20*40722Skarels /* 21*40722Skarels * Round p (pointer or byte index) up to a correctly-aligned value 22*40722Skarels * for all data types (int, long, ...). The result is u_int and 23*40722Skarels * must be cast to any desired pointer type. 24*40722Skarels */ 25*40722Skarels #define ALIGN(p) (((u_int)(p) + (sizeof(int) - 1)) &~ (sizeof(int) - 1)) 26*40722Skarels 2730407Skarels #define NBPG 1024 /* bytes/page */ 2830407Skarels #define PGOFSET (NBPG-1) /* byte offset into page */ 2930407Skarels #define PGSHIFT 10 /* LOG2(NBPG) */ 3030407Skarels #define NPTEPG (NBPG/(sizeof (struct pte))) 3125681Ssam 3230752Skarels #define KERNBASE 0xc0000000 /* start of kernel virtual */ 3340212Smarc #define KERNTEXTOFF (KERNBASE + 0x800) /* start of kernel text */ 3430752Skarels #define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) 3530752Skarels 3630407Skarels #define DEV_BSIZE 1024 3730407Skarels #define DEV_BSHIFT 10 /* log2(DEV_BSIZE) */ 3830407Skarels #define BLKDEV_IOSIZE 1024 /* NBPG for physical controllers */ 3930752Skarels #define MAXPHYS (64 * 1024) /* max raw I/O transfer size */ 4030407Skarels 4125681Ssam #define CLSIZE 1 4225681Ssam #define CLSIZELOG2 0 4325681Ssam 4430407Skarels #define SSIZE 2 /* initial stack size/NBPG */ 4530407Skarels #define SINCR 2 /* increment of stack/NBPG */ 4639819Smckusick #define UPAGES 8 /* pages of u-area (2 stack pages) */ 4725681Ssam 4838968Skarels /* 4938968Skarels * Constants related to network buffer management. 5038968Skarels * MCLBYTES must be no larger than CLBYTES (the software page size), and, 5138968Skarels * on machines that exchange pages of input or output buffers with mbuf 5238968Skarels * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple 5338968Skarels * of the hardware page size. 5438968Skarels */ 5538968Skarels #define MSIZE 128 /* size of an mbuf */ 5638968Skarels #define MAPPED_MBUFS /* can do scatter-gather I/O */ 5738968Skarels #if CLBYTES > 1024 5838968Skarels #define MCLBYTES 1024 5938968Skarels #define MCLSHIFT 10 6038968Skarels #define MCLOFSET (MCLBYTES - 1) 6138968Skarels #else 6238968Skarels #define MCLBYTES CLBYTES 6338968Skarels #define MCLSHIFT CLSHIFT 6438968Skarels #define MCLOFSET CLOFSET 6538968Skarels #endif 6638968Skarels #ifdef GATEWAY 6738968Skarels #define NMBCLUSTERS 512 /* map size, max cluster allocation */ 6838968Skarels #else 6938968Skarels #define NMBCLUSTERS 256 /* map size, max cluster allocation */ 7038968Skarels #endif 7138968Skarels 7225681Ssam #define MAXCKEY 255 /* maximal allowed code key */ 7325681Ssam #define MAXDKEY 255 /* maximal allowed data key */ 7425681Ssam #define NCKEY (MAXCKEY+1) /* # code keys, including 0 (reserved) */ 7525681Ssam #define NDKEY (MAXDKEY+1) /* # data keys, including 0 (reserved) */ 7625681Ssam 7725681Ssam /* 7825681Ssam * Some macros for units conversion 7925681Ssam */ 8025681Ssam /* Core clicks (1024 bytes) to segments and vice versa */ 8125681Ssam #define ctos(x) (x) 8225681Ssam #define stoc(x) (x) 8325681Ssam 8425681Ssam /* Core clicks (1024 bytes) to disk blocks */ 8525681Ssam #define ctod(x) (x) 8625681Ssam #define dtoc(x) (x) 8725681Ssam #define dtob(x) ((x)<<PGSHIFT) 8825681Ssam 8925681Ssam /* clicks to bytes */ 9025681Ssam #define ctob(x) ((x)<<PGSHIFT) 9125681Ssam 9225681Ssam /* bytes to clicks */ 9325681Ssam #define btoc(x) ((((unsigned)(x)+NBPG-1) >> PGSHIFT)) 9425681Ssam 9530407Skarels #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ 9630407Skarels ((unsigned)(bytes) >> DEV_BSHIFT) 9730407Skarels #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ 9830407Skarels ((unsigned)(db) << DEV_BSHIFT) 9930407Skarels 10025681Ssam /* 10130407Skarels * Map a ``block device block'' to a file system block. 10230407Skarels * This should be device dependent, and will be if we 10330407Skarels * add an entry to cdevsw/bdevsw for that purpose. 10430407Skarels * For now though just use DEV_BSIZE. 10530407Skarels */ 10630407Skarels #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) 10730407Skarels 10830407Skarels /* 10925681Ssam * Macros to decode processor status word. 11025681Ssam */ 11125681Ssam #define USERMODE(ps) (((ps) & PSL_CURMOD) == PSL_CURMOD) 11225681Ssam #define BASEPRI(ps) (((ps) & PSL_IPL) == 0) 11325681Ssam 11425681Ssam #define DELAY(n) { register int N = 3*(n); while (--N > 0); } 115