149429Sbostic /*- 249429Sbostic * Copyright (c) 1982, 1986, 1988 The Regents of the University of California. 349429Sbostic * All rights reserved. 433282Skarels * 549429Sbostic * This code is derived from software contributed to Berkeley by 649429Sbostic * Computer Consoles Inc. 749429Sbostic * 849429Sbostic * %sccs.include.proprietary.c% 949429Sbostic * 10*53671Sbostic * @(#)param.h 7.11 (Berkeley) 05/26/92 1133282Skarels */ 1225681Ssam 1325681Ssam /* 1425681Ssam * Machine dependent constants for TAHOE. 1525681Ssam */ 1631163Sbostic #define MACHINE "tahoe" 1731163Sbostic 1840722Skarels /* 1952587Sbostic * Round p (pointer or byte index) up to a correctly-aligned value for all 2052587Sbostic * data types (int, long, ...). The result is u_int and must be cast to 2152587Sbostic * any desired pointer type. 2240722Skarels */ 23*53671Sbostic #define ALIGNBYTES 3 24*53671Sbostic #define ALIGN(p) (((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES) 2540722Skarels 2630407Skarels #define NBPG 1024 /* bytes/page */ 2730407Skarels #define PGOFSET (NBPG-1) /* byte offset into page */ 2830407Skarels #define PGSHIFT 10 /* LOG2(NBPG) */ 2930407Skarels #define NPTEPG (NBPG/(sizeof (struct pte))) 3025681Ssam 3130752Skarels #define KERNBASE 0xc0000000 /* start of kernel virtual */ 3240212Smarc #define KERNTEXTOFF (KERNBASE + 0x800) /* start of kernel text */ 3330752Skarels #define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) 3430752Skarels 3530407Skarels #define DEV_BSIZE 1024 3630407Skarels #define DEV_BSHIFT 10 /* log2(DEV_BSIZE) */ 3730407Skarels #define BLKDEV_IOSIZE 1024 /* NBPG for physical controllers */ 3830752Skarels #define MAXPHYS (64 * 1024) /* max raw I/O transfer size */ 3930407Skarels 4025681Ssam #define CLSIZE 1 4125681Ssam #define CLSIZELOG2 0 4225681Ssam 4348795Sbostic /* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */ 4430407Skarels #define SSIZE 2 /* initial stack size/NBPG */ 4530407Skarels #define SINCR 2 /* increment of stack/NBPG */ 4639819Smckusick #define UPAGES 8 /* pages of u-area (2 stack pages) */ 4725681Ssam 4838968Skarels /* 4938968Skarels * Constants related to network buffer management. 5038968Skarels * MCLBYTES must be no larger than CLBYTES (the software page size), and, 5138968Skarels * on machines that exchange pages of input or output buffers with mbuf 5238968Skarels * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple 5338968Skarels * of the hardware page size. 5438968Skarels */ 5538968Skarels #define MSIZE 128 /* size of an mbuf */ 5638968Skarels #define MAPPED_MBUFS /* can do scatter-gather I/O */ 5738968Skarels #if CLBYTES > 1024 5838968Skarels #define MCLBYTES 1024 5938968Skarels #define MCLSHIFT 10 6038968Skarels #define MCLOFSET (MCLBYTES - 1) 6138968Skarels #else 6238968Skarels #define MCLBYTES CLBYTES 6338968Skarels #define MCLSHIFT CLSHIFT 6438968Skarels #define MCLOFSET CLOFSET 6538968Skarels #endif 6638968Skarels #ifdef GATEWAY 6738968Skarels #define NMBCLUSTERS 512 /* map size, max cluster allocation */ 6838968Skarels #else 6938968Skarels #define NMBCLUSTERS 256 /* map size, max cluster allocation */ 7038968Skarels #endif 7138968Skarels 7225681Ssam #define MAXCKEY 255 /* maximal allowed code key */ 7325681Ssam #define MAXDKEY 255 /* maximal allowed data key */ 7425681Ssam #define NCKEY (MAXCKEY+1) /* # code keys, including 0 (reserved) */ 7525681Ssam #define NDKEY (MAXDKEY+1) /* # data keys, including 0 (reserved) */ 7625681Ssam 7725681Ssam /* 7841524Smckusick * Size of kernel malloc arena in CLBYTES-sized logical pages 7941524Smckusick */ 8041524Smckusick #ifndef NKMEMCLUSTERS 8141524Smckusick #define NKMEMCLUSTERS (512*1024/CLBYTES) 8241524Smckusick #endif 8341524Smckusick 8441524Smckusick /* 8525681Ssam * Some macros for units conversion 8625681Ssam */ 8725681Ssam /* Core clicks (1024 bytes) to segments and vice versa */ 8825681Ssam #define ctos(x) (x) 8925681Ssam #define stoc(x) (x) 9025681Ssam 9125681Ssam /* Core clicks (1024 bytes) to disk blocks */ 9225681Ssam #define ctod(x) (x) 9325681Ssam #define dtoc(x) (x) 9425681Ssam #define dtob(x) ((x)<<PGSHIFT) 9525681Ssam 9625681Ssam /* clicks to bytes */ 9725681Ssam #define ctob(x) ((x)<<PGSHIFT) 9825681Ssam 9925681Ssam /* bytes to clicks */ 10025681Ssam #define btoc(x) ((((unsigned)(x)+NBPG-1) >> PGSHIFT)) 10125681Ssam 10230407Skarels #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ 10330407Skarels ((unsigned)(bytes) >> DEV_BSHIFT) 10430407Skarels #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ 10530407Skarels ((unsigned)(db) << DEV_BSHIFT) 10630407Skarels 10725681Ssam /* 10830407Skarels * Map a ``block device block'' to a file system block. 10930407Skarels * This should be device dependent, and will be if we 11030407Skarels * add an entry to cdevsw/bdevsw for that purpose. 11130407Skarels * For now though just use DEV_BSIZE. 11230407Skarels */ 11330407Skarels #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) 11430407Skarels 11530407Skarels /* 11625681Ssam * Macros to decode processor status word. 11725681Ssam */ 11825681Ssam #define USERMODE(ps) (((ps) & PSL_CURMOD) == PSL_CURMOD) 11925681Ssam #define BASEPRI(ps) (((ps) & PSL_IPL) == 0) 12025681Ssam 12125681Ssam #define DELAY(n) { register int N = 3*(n); while (--N > 0); } 122