141058Swilliam /*- 263359Sbostic * Copyright (c) 1990, 1993 363359Sbostic * The Regents of the University of California. All rights reserved. 441058Swilliam * 541058Swilliam * This code is derived from software contributed to Berkeley by 641058Swilliam * William Jolitz. 741058Swilliam * 846006Swilliam * %sccs.include.redist.c% 941058Swilliam * 10*68632Smckusick * @(#)param.h 8.2 (Berkeley) 03/29/95 1141058Swilliam */ 1241058Swilliam 1340461Sbill /* 1440461Sbill * Machine dependent constants for Intel 386. 1540461Sbill */ 1640461Sbill 1740461Sbill #define MACHINE "i386" 1840461Sbill 1950141Ssklower /* 2052589Sbostic * Round p (pointer or byte index) up to a correctly-aligned value for all 2152589Sbostic * data types (int, long, ...). The result is u_int and must be cast to 2252589Sbostic * any desired pointer type. 2350141Ssklower */ 2453673Sbostic #define ALIGNBYTES 3 2553673Sbostic #define ALIGN(p) (((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES) 2650141Ssklower 2740461Sbill #define NBPG 4096 /* bytes/page */ 2840461Sbill #define PGOFSET (NBPG-1) /* byte offset into page */ 2940461Sbill #define PGSHIFT 12 /* LOG2(NBPG) */ 3040461Sbill #define NPTEPG (NBPG/(sizeof (struct pte))) 3140461Sbill 3240461Sbill #define NBPDR (1024*NBPG) /* bytes/page dir */ 3340461Sbill #define PDROFSET (NBPDR-1) /* byte offset into page dir */ 3440461Sbill #define PDRSHIFT 22 /* LOG2(NBPDR) */ 3540461Sbill 3640461Sbill #define KERNBASE 0xFE000000 /* start of kernel virtual */ 3740461Sbill #define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) 3840461Sbill 3940461Sbill #define DEV_BSIZE 512 4040461Sbill #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 4140461Sbill #define BLKDEV_IOSIZE 2048 4240461Sbill #define MAXPHYS (64 * 1024) /* max raw I/O transfer size */ 4340461Sbill 4440461Sbill #define CLSIZE 1 4540461Sbill #define CLSIZELOG2 0 4640461Sbill 4748796Sbostic /* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */ 4840461Sbill #define SSIZE 1 /* initial stack size/NBPG */ 4940461Sbill #define SINCR 1 /* increment of stack/NBPG */ 5040461Sbill 5141058Swilliam #define UPAGES 2 /* pages of u-area */ 5240461Sbill 5340461Sbill /* 5445964Swilliam * Constants related to network buffer management. 5545964Swilliam * MCLBYTES must be no larger than CLBYTES (the software page size), and, 5645964Swilliam * on machines that exchange pages of input or output buffers with mbuf 5745964Swilliam * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple 5845964Swilliam * of the hardware page size. 5945964Swilliam */ 6045964Swilliam #define MSIZE 128 /* size of an mbuf */ 6145964Swilliam #define MCLBYTES 1024 6245964Swilliam #define MCLSHIFT 10 6345964Swilliam #define MCLOFSET (MCLBYTES - 1) 6445964Swilliam #ifndef NMBCLUSTERS 6545964Swilliam #ifdef GATEWAY 6645964Swilliam #define NMBCLUSTERS 512 /* map size, max cluster allocation */ 6745964Swilliam #else 6845964Swilliam #define NMBCLUSTERS 256 /* map size, max cluster allocation */ 6945964Swilliam #endif 7045964Swilliam #endif 7145964Swilliam 7245964Swilliam /* 7345964Swilliam * Size of kernel malloc arena in CLBYTES-sized logical pages 7445964Swilliam */ 7545964Swilliam #ifndef NKMEMCLUSTERS 7650267Skarels #define NKMEMCLUSTERS (2048*1024/CLBYTES) 7745964Swilliam #endif 7845964Swilliam /* 7940461Sbill * Some macros for units conversion 8040461Sbill */ 8140461Sbill /* Core clicks (4096 bytes) to segments and vice versa */ 8240461Sbill #define ctos(x) (x) 8340461Sbill #define stoc(x) (x) 8440461Sbill 8540461Sbill /* Core clicks (4096 bytes) to disk blocks */ 8640461Sbill #define ctod(x) ((x)<<(PGSHIFT-DEV_BSHIFT)) 8740461Sbill #define dtoc(x) ((x)>>(PGSHIFT-DEV_BSHIFT)) 8840461Sbill #define dtob(x) ((x)<<DEV_BSHIFT) 8940461Sbill 9040461Sbill /* clicks to bytes */ 9140461Sbill #define ctob(x) ((x)<<PGSHIFT) 9240461Sbill 9340461Sbill /* bytes to clicks */ 9440461Sbill #define btoc(x) (((unsigned)(x)+(NBPG-1))>>PGSHIFT) 9540461Sbill 9640461Sbill #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ 97*68632Smckusick ((bytes) >> DEV_BSHIFT) 9840461Sbill #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ 99*68632Smckusick ((db) << DEV_BSHIFT) 10040461Sbill 10140461Sbill /* 10240461Sbill * Map a ``block device block'' to a file system block. 10340461Sbill * This should be device dependent, and will be if we 10440461Sbill * add an entry to cdevsw/bdevsw for that purpose. 10540461Sbill * For now though just use DEV_BSIZE. 10640461Sbill */ 10740461Sbill #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) 10840461Sbill 10947999Swilliam /* 11047999Swilliam * Mach derived conversion macros 11147999Swilliam */ 11247999Swilliam #define i386_round_pdr(x) ((((unsigned)(x)) + NBPDR - 1) & ~(NBPDR-1)) 11347999Swilliam #define i386_trunc_pdr(x) ((unsigned)(x) & ~(NBPDR-1)) 11447999Swilliam #define i386_round_page(x) ((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1)) 11547999Swilliam #define i386_trunc_page(x) ((unsigned)(x) & ~(NBPG-1)) 11647999Swilliam #define i386_btod(x) ((unsigned)(x) >> PDRSHIFT) 11747999Swilliam #define i386_dtob(x) ((unsigned)(x) << PDRSHIFT) 11847999Swilliam #define i386_btop(x) ((unsigned)(x) >> PGSHIFT) 11947999Swilliam #define i386_ptob(x) ((unsigned)(x) << PGSHIFT) 12047999Swilliam 12153638Sbostic #ifndef KERNEL 12253638Sbostic /* DELAY is in locore.s for the kernel */ 12340461Sbill #define DELAY(n) { register int N = (n); while (--N > 0); } 12450031Sbostic #endif 125