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.8 (Berkeley) 10/28/87 7 */ 8 9 #ifndef ENDIAN 10 /* 11 * Machine dependent constants for vax. 12 */ 13 #define MACHINE "vax" 14 15 #define CHAR_BIT NBBY 16 #define CHAR_MAX 0x7f 17 #define CHAR_MIN 0x80 18 #define CLK_TCK UNDEFINED_FOR_NOW 19 #define INT_MAX 0x7fffffff 20 #define INT_MIN 0x80000000 21 #define LONG_MAX 0x7fffffff 22 #define LONG_MIN 0x80000000 23 #define SCHAR_MAX 0x7f 24 #define SCHAR_MIN 0x80 25 #define SHRT_MAX 0x7fff 26 #define SHRT_MIN 0x8000 27 #define UCHAR_MAX 0xff 28 #define UINT_MAX 0xffffffff 29 #define ULONG_MAX 0xffffffff 30 #define USHRT_MAX 0xffff 31 32 /* 33 * Definitions for byte order, 34 * according to byte significance from low address to high. 35 */ 36 #define LITTLE 1234 /* least-significant byte first (vax) */ 37 #define BIG 4321 /* most-significant byte first */ 38 #define PDP 3412 /* LSB first in word, MSW first in long (pdp) */ 39 #define ENDIAN LITTLE /* byte order on vax */ 40 41 /* 42 * Macros for network/external number representation conversion. 43 */ 44 #if ENDIAN == BIG && !defined(lint) 45 #define ntohl(x) (x) 46 #define ntohs(x) (x) 47 #define htonl(x) (x) 48 #define htons(x) (x) 49 #else 50 unsigned short ntohs(), htons(); 51 unsigned long ntohl(), htonl(); 52 #endif 53 54 #define KERNBASE 0x80000000 /* start of kernel virtual */ 55 #define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) 56 57 #define NBPG 512 /* bytes/page */ 58 #define PGOFSET (NBPG-1) /* byte offset into page */ 59 #define PGSHIFT 9 /* LOG2(NBPG) */ 60 #define NPTEPG (NBPG/(sizeof (struct pte))) 61 62 #define DEV_BSIZE 512 63 #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 64 #define BLKDEV_IOSIZE 2048 65 #define MAXPHYS (63 * 1024) /* max raw I/O transfer size */ 66 67 #define CLSIZE 2 68 #define CLSIZELOG2 1 69 70 #define SSIZE 4 /* initial stack size/NBPG */ 71 #define SINCR 4 /* increment of stack/NBPG */ 72 73 #define UPAGES 10 /* pages of u-area */ 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 #endif ENDIAN 122