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*30766Skarels * @(#)param.h 7.4.1.1 (Berkeley) 04/02/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*30766Skarels #define KERNBASE 0x80000000 /* start of kernel virtual */ 37*30766Skarels #define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) 38*30766Skarels 3930407Skarels #define NBPG 512 /* bytes/page */ 4030407Skarels #define PGOFSET (NBPG-1) /* byte offset into page */ 4130407Skarels #define PGSHIFT 9 /* LOG2(NBPG) */ 4230407Skarels #define NPTEPG (NBPG/(sizeof (struct pte))) 439118Ssam 44*30766Skarels #ifndef SECSIZE 4530407Skarels #define DEV_BSIZE 512 4630407Skarels #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 4730407Skarels #define BLKDEV_IOSIZE 2048 48*30766Skarels #else SECSIZE 49*30766Skarels /* 50*30766Skarels * Devices without disk labels and the swap virtual device 51*30766Skarels * use "blocks" of exactly pagesize. Devices with disk labels 52*30766Skarels * use device-dependent sector sizes for block and character interfaces. 53*30766Skarels */ 54*30766Skarels #define DEV_BSIZE NBPG 55*30766Skarels #define DEV_BSHIFT PGSHIFT /* log2(DEV_BSIZE) */ 56*30766Skarels #define BLKDEV_IOSIZE NBPG /* NBPG for unlabeled block devices */ 57*30766Skarels #endif SECSIZE 58*30766Skarels #define MAXPHYS (63 * 1024) /* max raw I/O transfer size */ 5930407Skarels 609118Ssam #define CLSIZE 2 619118Ssam #define CLSIZELOG2 1 629118Ssam 6330407Skarels #define SSIZE 4 /* initial stack size/NBPG */ 6430407Skarels #define SINCR 4 /* increment of stack/NBPG */ 659118Ssam 6630407Skarels #define UPAGES 10 /* pages of u-area */ 679118Ssam 689118Ssam /* 699118Ssam * Some macros for units conversion 709118Ssam */ 719118Ssam /* Core clicks (512 bytes) to segments and vice versa */ 729118Ssam #define ctos(x) (x) 739118Ssam #define stoc(x) (x) 749118Ssam 75*30766Skarels #ifndef SECSIZE 769118Ssam /* Core clicks (512 bytes) to disk blocks */ 779118Ssam #define ctod(x) (x) 789118Ssam #define dtoc(x) (x) 79*30766Skarels #define dtob(x) ((x)<<PGSHIFT) 80*30766Skarels #else SECSIZE 81*30766Skarels /* Core clicks (512 bytes) to disk blocks; deprecated */ 82*30766Skarels #define ctod(x) (x) /* XXX */ 83*30766Skarels #define dtoc(x) (x) /* XXX */ 84*30766Skarels #define dtob(x) ((x)<<PGSHIFT) /* XXX */ 85*30766Skarels #endif SECSIZE 869118Ssam 879118Ssam /* clicks to bytes */ 889118Ssam #define ctob(x) ((x)<<9) 899118Ssam 909118Ssam /* bytes to clicks */ 919118Ssam #define btoc(x) ((((unsigned)(x)+511)>>9)) 929118Ssam 93*30766Skarels #ifndef SECSIZE 9430407Skarels #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ 9530407Skarels ((unsigned)(bytes) >> DEV_BSHIFT) 9630407Skarels #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ 9730407Skarels ((unsigned)(db) << DEV_BSHIFT) 9830407Skarels 999118Ssam /* 10030407Skarels * Map a ``block device block'' to a file system block. 10130407Skarels * This should be device dependent, and will be if we 10230407Skarels * add an entry to cdevsw/bdevsw for that purpose. 10330407Skarels * For now though just use DEV_BSIZE. 10430407Skarels */ 10530407Skarels #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) 106*30766Skarels #else SECSIZE 107*30766Skarels /* bytes to "disk blocks" and back; deprecated */ 108*30766Skarels #define btodb(bytes) ((unsigned)(bytes) >> DEV_BSHIFT) /* XXX */ 109*30766Skarels #define dbtob(db) ((unsigned)(db) << DEV_BSHIFT) /* XXX */ 110*30766Skarels #endif SECSIZE 11130407Skarels 11230407Skarels /* 1139118Ssam * Macros to decode processor status word. 1149118Ssam */ 1159118Ssam #define USERMODE(ps) (((ps) & PSL_CURMOD) == PSL_CURMOD) 1169600Ssam #define BASEPRI(ps) (((ps) & PSL_IPL) == 0) 1179118Ssam 11824887Skarels #ifdef KERNEL 11924887Skarels #ifndef LOCORE 12024887Skarels int cpuspeed; 12129953Skarels #define DELAY(n) { register int N = cpuspeed * (n); while (--N > 0); } 12224887Skarels #endif 12324887Skarels 12424887Skarels #else KERNEL 1259118Ssam #define DELAY(n) { register int N = (n); while (--N > 0); } 12624887Skarels #endif KERNEL 12730403Skarels #endif ENDIAN 128