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.6 (Berkeley) 05/12/87 7 */ 8 9 /* 10 * Machine dependent constants for vax. 11 */ 12 13 #ifndef ENDIAN 14 /* 15 * Definitions for byte order, 16 * according to byte significance from low address to high. 17 */ 18 #define LITTLE 1234 /* least-significant byte first (vax) */ 19 #define BIG 4321 /* most-significant byte first */ 20 #define PDP 3412 /* LSB first in word, MSW first in long (pdp) */ 21 #define ENDIAN LITTLE /* byte order on vax */ 22 23 /* 24 * Macros for network/external number representation conversion. 25 */ 26 #if ENDIAN == BIG && !defined(lint) 27 #define ntohl(x) (x) 28 #define ntohs(x) (x) 29 #define htonl(x) (x) 30 #define htons(x) (x) 31 #else 32 unsigned short ntohs(), htons(); 33 unsigned long ntohl(), htonl(); 34 #endif 35 36 #define KERNBASE 0x80000000 /* start of kernel virtual */ 37 #define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) 38 39 #define NBPG 512 /* bytes/page */ 40 #define PGOFSET (NBPG-1) /* byte offset into page */ 41 #define PGSHIFT 9 /* LOG2(NBPG) */ 42 #define NPTEPG (NBPG/(sizeof (struct pte))) 43 44 #define DEV_BSIZE 512 45 #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 46 #define BLKDEV_IOSIZE 2048 47 #define MAXPHYS (63 * 1024) /* max raw I/O transfer size */ 48 49 #define CLSIZE 2 50 #define CLSIZELOG2 1 51 52 #define SSIZE 4 /* initial stack size/NBPG */ 53 #define SINCR 4 /* increment of stack/NBPG */ 54 55 #define UPAGES 10 /* pages of u-area */ 56 57 /* 58 * Some macros for units conversion 59 */ 60 /* Core clicks (512 bytes) to segments and vice versa */ 61 #define ctos(x) (x) 62 #define stoc(x) (x) 63 64 /* Core clicks (512 bytes) to disk blocks */ 65 #define ctod(x) (x) 66 #define dtoc(x) (x) 67 #define dtob(x) ((x)<<PGSHIFT) 68 69 /* clicks to bytes */ 70 #define ctob(x) ((x)<<9) 71 72 /* bytes to clicks */ 73 #define btoc(x) ((((unsigned)(x)+511)>>9)) 74 75 #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ 76 ((unsigned)(bytes) >> DEV_BSHIFT) 77 #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ 78 ((unsigned)(db) << DEV_BSHIFT) 79 80 /* 81 * Map a ``block device block'' to a file system block. 82 * This should be device dependent, and will be if we 83 * add an entry to cdevsw/bdevsw for that purpose. 84 * For now though just use DEV_BSIZE. 85 */ 86 #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) 87 88 /* 89 * Macros to decode processor status word. 90 */ 91 #define USERMODE(ps) (((ps) & PSL_CURMOD) == PSL_CURMOD) 92 #define BASEPRI(ps) (((ps) & PSL_IPL) == 0) 93 94 #ifdef KERNEL 95 #ifndef LOCORE 96 int cpuspeed; 97 #define DELAY(n) { register int N = cpuspeed * (n); while (--N > 0); } 98 #endif 99 100 #else KERNEL 101 #define DELAY(n) { register int N = (n); while (--N > 0); } 102 #endif KERNEL 103 #endif ENDIAN 104