123264Smckusick /* 229186Smckusick * Copyright (c) 1982, 1986 Regents of the University of California. 323264Smckusick * All rights reserved. The Berkeley software License Agreement 423264Smckusick * specifies the terms and conditions for redistribution. 523264Smckusick * 6*30407Skarels * @(#)param.h 7.4 (Berkeley) 01/16/87 723264Smckusick */ 89118Ssam 99118Ssam /* 109118Ssam * Machine dependent constants for vax. 119118Ssam */ 1229953Skarels 1329953Skarels #ifndef ENDIAN 1429953Skarels /* 1529953Skarels * Definitions for byte order, 1629953Skarels * according to byte significance from low address to high. 1729953Skarels */ 1829953Skarels #define LITTLE 1234 /* least-significant byte first (vax) */ 1929953Skarels #define BIG 4321 /* most-significant byte first */ 2029953Skarels #define PDP 3412 /* LSB first in word, MSW first in long (pdp) */ 2129953Skarels #define ENDIAN LITTLE /* byte order on vax */ 2229953Skarels 2330403Skarels /* 2430403Skarels * Macros for network/external number representation conversion. 2530403Skarels */ 2630403Skarels #if ENDIAN == BIG && !defined(lint) 2730403Skarels #define ntohl(x) (x) 2830403Skarels #define ntohs(x) (x) 2930403Skarels #define htonl(x) (x) 3030403Skarels #define htons(x) (x) 3130403Skarels #else 3230403Skarels u_short ntohs(), htons(); 3330403Skarels u_long ntohl(), htonl(); 3430403Skarels #endif 3530403Skarels 36*30407Skarels #define NBPG 512 /* bytes/page */ 37*30407Skarels #define PGOFSET (NBPG-1) /* byte offset into page */ 38*30407Skarels #define PGSHIFT 9 /* LOG2(NBPG) */ 39*30407Skarels #define NPTEPG (NBPG/(sizeof (struct pte))) 409118Ssam 41*30407Skarels #define DEV_BSIZE 512 42*30407Skarels #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 43*30407Skarels #define BLKDEV_IOSIZE 2048 44*30407Skarels 459118Ssam #define CLSIZE 2 469118Ssam #define CLSIZELOG2 1 479118Ssam 48*30407Skarels #define SSIZE 4 /* initial stack size/NBPG */ 49*30407Skarels #define SINCR 4 /* increment of stack/NBPG */ 509118Ssam 51*30407Skarels #define UPAGES 10 /* pages of u-area */ 529118Ssam 539118Ssam /* 549118Ssam * Some macros for units conversion 559118Ssam */ 569118Ssam /* Core clicks (512 bytes) to segments and vice versa */ 579118Ssam #define ctos(x) (x) 589118Ssam #define stoc(x) (x) 599118Ssam 609118Ssam /* Core clicks (512 bytes) to disk blocks */ 619118Ssam #define ctod(x) (x) 629118Ssam #define dtoc(x) (x) 639118Ssam #define dtob(x) ((x)<<9) 649118Ssam 659118Ssam /* clicks to bytes */ 669118Ssam #define ctob(x) ((x)<<9) 679118Ssam 689118Ssam /* bytes to clicks */ 699118Ssam #define btoc(x) ((((unsigned)(x)+511)>>9)) 709118Ssam 71*30407Skarels #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ 72*30407Skarels ((unsigned)(bytes) >> DEV_BSHIFT) 73*30407Skarels #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ 74*30407Skarels ((unsigned)(db) << DEV_BSHIFT) 75*30407Skarels 769118Ssam /* 77*30407Skarels * Map a ``block device block'' to a file system block. 78*30407Skarels * This should be device dependent, and will be if we 79*30407Skarels * add an entry to cdevsw/bdevsw for that purpose. 80*30407Skarels * For now though just use DEV_BSIZE. 81*30407Skarels */ 82*30407Skarels #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) 83*30407Skarels 84*30407Skarels /* 859118Ssam * Macros to decode processor status word. 869118Ssam */ 879118Ssam #define USERMODE(ps) (((ps) & PSL_CURMOD) == PSL_CURMOD) 889600Ssam #define BASEPRI(ps) (((ps) & PSL_IPL) == 0) 899118Ssam 9024887Skarels #ifdef KERNEL 9124887Skarels #ifndef LOCORE 9224887Skarels int cpuspeed; 9329953Skarels #define DELAY(n) { register int N = cpuspeed * (n); while (--N > 0); } 9424887Skarels #endif 9524887Skarels 9624887Skarels #else KERNEL 979118Ssam #define DELAY(n) { register int N = (n); while (--N > 0); } 9824887Skarels #endif KERNEL 9930403Skarels #endif ENDIAN 100