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.4.1.1 (Berkeley) 04/02/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 u_short ntohs(), htons(); 33 u_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 #ifndef SECSIZE 45 #define DEV_BSIZE 512 46 #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 47 #define BLKDEV_IOSIZE 2048 48 #else SECSIZE 49 /* 50 * Devices without disk labels and the swap virtual device 51 * use "blocks" of exactly pagesize. Devices with disk labels 52 * use device-dependent sector sizes for block and character interfaces. 53 */ 54 #define DEV_BSIZE NBPG 55 #define DEV_BSHIFT PGSHIFT /* log2(DEV_BSIZE) */ 56 #define BLKDEV_IOSIZE NBPG /* NBPG for unlabeled block devices */ 57 #endif SECSIZE 58 #define MAXPHYS (63 * 1024) /* max raw I/O transfer size */ 59 60 #define CLSIZE 2 61 #define CLSIZELOG2 1 62 63 #define SSIZE 4 /* initial stack size/NBPG */ 64 #define SINCR 4 /* increment of stack/NBPG */ 65 66 #define UPAGES 10 /* pages of u-area */ 67 68 /* 69 * Some macros for units conversion 70 */ 71 /* Core clicks (512 bytes) to segments and vice versa */ 72 #define ctos(x) (x) 73 #define stoc(x) (x) 74 75 #ifndef SECSIZE 76 /* Core clicks (512 bytes) to disk blocks */ 77 #define ctod(x) (x) 78 #define dtoc(x) (x) 79 #define dtob(x) ((x)<<PGSHIFT) 80 #else SECSIZE 81 /* Core clicks (512 bytes) to disk blocks; deprecated */ 82 #define ctod(x) (x) /* XXX */ 83 #define dtoc(x) (x) /* XXX */ 84 #define dtob(x) ((x)<<PGSHIFT) /* XXX */ 85 #endif SECSIZE 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 #ifndef SECSIZE 94 #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ 95 ((unsigned)(bytes) >> DEV_BSHIFT) 96 #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ 97 ((unsigned)(db) << DEV_BSHIFT) 98 99 /* 100 * Map a ``block device block'' to a file system block. 101 * This should be device dependent, and will be if we 102 * add an entry to cdevsw/bdevsw for that purpose. 103 * For now though just use DEV_BSIZE. 104 */ 105 #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) 106 #else SECSIZE 107 /* bytes to "disk blocks" and back; deprecated */ 108 #define btodb(bytes) ((unsigned)(bytes) >> DEV_BSHIFT) /* XXX */ 109 #define dbtob(db) ((unsigned)(db) << DEV_BSHIFT) /* XXX */ 110 #endif SECSIZE 111 112 /* 113 * Macros to decode processor status word. 114 */ 115 #define USERMODE(ps) (((ps) & PSL_CURMOD) == PSL_CURMOD) 116 #define BASEPRI(ps) (((ps) & PSL_IPL) == 0) 117 118 #ifdef KERNEL 119 #ifndef LOCORE 120 int cpuspeed; 121 #define DELAY(n) { register int N = cpuspeed * (n); while (--N > 0); } 122 #endif 123 124 #else KERNEL 125 #define DELAY(n) { register int N = (n); while (--N > 0); } 126 #endif KERNEL 127 #endif ENDIAN 128