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*41523Smckusick * @(#)param.h 7.16 (Berkeley) 05/10/90 723264Smckusick */ 89118Ssam 99118Ssam /* 1033278Sbostic * Machine dependent constants for VAX. 119118Ssam */ 1231162Sbostic #define MACHINE "vax" 1331162Sbostic 1433381Skarels #ifndef BYTE_ORDER 1533278Sbostic #include <machine/endian.h> 1633278Sbostic #endif 1733278Sbostic 1838966Skarels #include <machine/machlimits.h> 1932563Sbostic 2040721Skarels /* 2140721Skarels * Round p (pointer or byte index) up to a correctly-aligned value 2240721Skarels * for all data types (int, long, ...). The result is u_int and 2340721Skarels * must be cast to any desired pointer type. 2440721Skarels */ 2540721Skarels #define ALIGN(p) (((u_int)(p) + (sizeof(int) - 1)) &~ (sizeof(int) - 1)) 2640721Skarels 2730407Skarels #define NBPG 512 /* bytes/page */ 2830407Skarels #define PGOFSET (NBPG-1) /* byte offset into page */ 2930407Skarels #define PGSHIFT 9 /* LOG2(NBPG) */ 3030407Skarels #define NPTEPG (NBPG/(sizeof (struct pte))) 319118Ssam 3233278Sbostic #define KERNBASE 0x80000000 /* start of kernel virtual */ 3340211Smarc #define KERNTEXTOFF KERNBASE /* start of kernel text */ 3433278Sbostic #define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) 3533278Sbostic 3630407Skarels #define DEV_BSIZE 512 3730407Skarels #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 3830407Skarels #define BLKDEV_IOSIZE 2048 3930766Skarels #define MAXPHYS (63 * 1024) /* max raw I/O transfer size */ 4030407Skarels 419118Ssam #define CLSIZE 2 429118Ssam #define CLSIZELOG2 1 439118Ssam 4430407Skarels #define SSIZE 4 /* initial stack size/NBPG */ 4530407Skarels #define SINCR 4 /* increment of stack/NBPG */ 469118Ssam 4739820Smckusick #define UPAGES 16 /* pages of u-area */ 489118Ssam 499118Ssam /* 5038966Skarels * Constants related to network buffer management. 5138966Skarels * MCLBYTES must be no larger than CLBYTES (the software page size), and, 5238966Skarels * on machines that exchange pages of input or output buffers with mbuf 5338966Skarels * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple 5438966Skarels * of the hardware page size. 5538966Skarels */ 5638966Skarels #define MSIZE 128 /* size of an mbuf */ 5738966Skarels #define MAPPED_MBUFS /* can do scatter-gather I/O */ 5838966Skarels #if CLBYTES > 1024 5938966Skarels #define MCLBYTES 1024 6038966Skarels #define MCLSHIFT 10 6138966Skarels #define MCLOFSET (MCLBYTES - 1) 6238966Skarels #else 6338966Skarels #define MCLBYTES CLBYTES 6438966Skarels #define MCLSHIFT CLSHIFT 6538966Skarels #define MCLOFSET CLOFSET 6638966Skarels #endif 6738966Skarels #ifdef GATEWAY 6838966Skarels #define NMBCLUSTERS 512 /* map size, max cluster allocation */ 6938966Skarels #else 7038966Skarels #define NMBCLUSTERS 256 /* map size, max cluster allocation */ 7138966Skarels #endif 7238966Skarels 7338966Skarels /* 74*41523Smckusick * Size of kernel malloc arena in CLBYTES-sized logical pages 75*41523Smckusick */ 76*41523Smckusick #ifndef NKMEMCLUSTERS 77*41523Smckusick #define NKMEMCLUSTERS (512*1024/CLBYTES) 78*41523Smckusick #endif 79*41523Smckusick 80*41523Smckusick /* 819118Ssam * Some macros for units conversion 829118Ssam */ 839118Ssam /* Core clicks (512 bytes) to segments and vice versa */ 849118Ssam #define ctos(x) (x) 859118Ssam #define stoc(x) (x) 869118Ssam 879118Ssam /* Core clicks (512 bytes) to disk blocks */ 889118Ssam #define ctod(x) (x) 899118Ssam #define dtoc(x) (x) 9030766Skarels #define dtob(x) ((x)<<PGSHIFT) 919118Ssam 929118Ssam /* clicks to bytes */ 939118Ssam #define ctob(x) ((x)<<9) 949118Ssam 959118Ssam /* bytes to clicks */ 969118Ssam #define btoc(x) ((((unsigned)(x)+511)>>9)) 979118Ssam 9830407Skarels #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ 9930407Skarels ((unsigned)(bytes) >> DEV_BSHIFT) 10030407Skarels #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ 10130407Skarels ((unsigned)(db) << DEV_BSHIFT) 10230407Skarels 1039118Ssam /* 10430407Skarels * Map a ``block device block'' to a file system block. 10530407Skarels * This should be device dependent, and will be if we 10630407Skarels * add an entry to cdevsw/bdevsw for that purpose. 10730407Skarels * For now though just use DEV_BSIZE. 10830407Skarels */ 10930407Skarels #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) 11030407Skarels 11130407Skarels /* 1129118Ssam * Macros to decode processor status word. 1139118Ssam */ 1149118Ssam #define USERMODE(ps) (((ps) & PSL_CURMOD) == PSL_CURMOD) 1159600Ssam #define BASEPRI(ps) (((ps) & PSL_IPL) == 0) 1169118Ssam 11724887Skarels #ifdef KERNEL 11824887Skarels #ifndef LOCORE 11924887Skarels int cpuspeed; 12029953Skarels #define DELAY(n) { register int N = cpuspeed * (n); while (--N > 0); } 12124887Skarels #endif 12224887Skarels 12324887Skarels #else KERNEL 1249118Ssam #define DELAY(n) { register int N = (n); while (--N > 0); } 12524887Skarels #endif KERNEL 126