1*30752Skarels /* param.h 1.6.1.1 87/04/02 */ 225681Ssam 325681Ssam /* 425681Ssam * Machine dependent constants for TAHOE. 525681Ssam */ 629950Skarels 729950Skarels #ifndef ENDIAN 829950Skarels /* 929950Skarels * Definitions for byte order, 1029950Skarels * according to byte significance from low address to high. 1129950Skarels */ 1229950Skarels #define LITTLE 1234 /* least-significant byte first (vax) */ 1329950Skarels #define BIG 4321 /* most-significant byte first */ 1429950Skarels #define PDP 3412 /* LSB first in word, MSW first in long (pdp) */ 1529950Skarels #define ENDIAN BIG /* byte order on tahoe */ 1629950Skarels 1730402Skarels /* 1830402Skarels * Macros for network/external number representation conversion. 1930402Skarels */ 2030402Skarels #if ENDIAN == BIG && !defined(lint) 2130402Skarels #define ntohl(x) (x) 2230402Skarels #define ntohs(x) (x) 2330402Skarels #define htonl(x) (x) 2430402Skarels #define htons(x) (x) 2530402Skarels #else 2630402Skarels u_short ntohs(), htons(); 2730402Skarels u_long ntohl(), htonl(); 2830402Skarels #endif 2930402Skarels 3030407Skarels #define NBPG 1024 /* bytes/page */ 3130407Skarels #define PGOFSET (NBPG-1) /* byte offset into page */ 3230407Skarels #define PGSHIFT 10 /* LOG2(NBPG) */ 3330407Skarels #define NPTEPG (NBPG/(sizeof (struct pte))) 3425681Ssam 35*30752Skarels #define KERNBASE 0xc0000000 /* start of kernel virtual */ 36*30752Skarels #define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) 37*30752Skarels 38*30752Skarels #ifndef SECSIZE 3930407Skarels #define DEV_BSIZE 1024 4030407Skarels #define DEV_BSHIFT 10 /* log2(DEV_BSIZE) */ 4130407Skarels #define BLKDEV_IOSIZE 1024 /* NBPG for physical controllers */ 42*30752Skarels #else SECSIZE 43*30752Skarels /* 44*30752Skarels * Devices without disk labels and the swap virtual device 45*30752Skarels * use "blocks" of exactly pagesize. Devices with disk labels 46*30752Skarels * use device-dependent sector sizes for block and character interfaces. 47*30752Skarels */ 48*30752Skarels #define DEV_BSIZE NBPG 49*30752Skarels #define DEV_BSHIFT PGSHIFT /* log2(DEV_BSIZE) */ 50*30752Skarels #define BLKDEV_IOSIZE NBPG /* NBPG for unlabeled block devices */ 51*30752Skarels #endif SECSIZE 52*30752Skarels #define MAXPHYS (64 * 1024) /* max raw I/O transfer size */ 5330407Skarels 5425681Ssam #define CLSIZE 1 5525681Ssam #define CLSIZELOG2 0 5625681Ssam 5730407Skarels #define SSIZE 2 /* initial stack size/NBPG */ 5830407Skarels #define SINCR 2 /* increment of stack/NBPG */ 5930407Skarels #define UPAGES 6 /* pages of u-area (2 stack pages) */ 6025681Ssam 6125681Ssam #define MAXCKEY 255 /* maximal allowed code key */ 6225681Ssam #define MAXDKEY 255 /* maximal allowed data key */ 6325681Ssam #define NCKEY (MAXCKEY+1) /* # code keys, including 0 (reserved) */ 6425681Ssam #define NDKEY (MAXDKEY+1) /* # data keys, including 0 (reserved) */ 6525681Ssam 6625681Ssam /* 6725681Ssam * Some macros for units conversion 6825681Ssam */ 6925681Ssam /* Core clicks (1024 bytes) to segments and vice versa */ 7025681Ssam #define ctos(x) (x) 7125681Ssam #define stoc(x) (x) 7225681Ssam 73*30752Skarels #ifndef SECSIZE 7425681Ssam /* Core clicks (1024 bytes) to disk blocks */ 7525681Ssam #define ctod(x) (x) 7625681Ssam #define dtoc(x) (x) 7725681Ssam #define dtob(x) ((x)<<PGSHIFT) 78*30752Skarels #else SECSIZE 79*30752Skarels /* Core clicks (1024 bytes) to disk blocks; deprecated */ 80*30752Skarels #define ctod(x) (x) /* XXX */ 81*30752Skarels #define dtoc(x) (x) /* XXX */ 82*30752Skarels #define dtob(x) ((x)<<PGSHIFT) /* XXX */ 83*30752Skarels #endif SECSIZE 8425681Ssam 8525681Ssam /* clicks to bytes */ 8625681Ssam #define ctob(x) ((x)<<PGSHIFT) 8725681Ssam 8825681Ssam /* bytes to clicks */ 8925681Ssam #define btoc(x) ((((unsigned)(x)+NBPG-1) >> PGSHIFT)) 9025681Ssam 91*30752Skarels #ifndef SECSIZE 9230407Skarels #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ 9330407Skarels ((unsigned)(bytes) >> DEV_BSHIFT) 9430407Skarels #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ 9530407Skarels ((unsigned)(db) << DEV_BSHIFT) 9630407Skarels 9725681Ssam /* 9830407Skarels * Map a ``block device block'' to a file system block. 9930407Skarels * This should be device dependent, and will be if we 10030407Skarels * add an entry to cdevsw/bdevsw for that purpose. 10130407Skarels * For now though just use DEV_BSIZE. 10230407Skarels */ 10330407Skarels #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) 104*30752Skarels #else SECSIZE 105*30752Skarels /* bytes to "disk blocks" and back; deprecated */ 106*30752Skarels #define btodb(bytes) ((unsigned)(bytes) >> DEV_BSHIFT) /* XXX */ 107*30752Skarels #define dbtob(db) ((unsigned)(db) << DEV_BSHIFT) /* XXX */ 108*30752Skarels #endif SECSIZE 10930407Skarels 11030407Skarels /* 11125681Ssam * Macros to decode processor status word. 11225681Ssam */ 11325681Ssam #define USERMODE(ps) (((ps) & PSL_CURMOD) == PSL_CURMOD) 11425681Ssam #define BASEPRI(ps) (((ps) & PSL_IPL) == 0) 11525681Ssam 11625681Ssam #define DELAY(n) { register int N = 3*(n); while (--N > 0); } 11729950Skarels #endif 118