1 /*- 2 * Copyright (c) 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * William Jolitz. 7 * 8 * %sccs.include.redist.c% 9 * 10 * @(#)param.h 8.2 (Berkeley) 03/29/95 11 */ 12 13 /* 14 * Machine dependent constants for Intel 386. 15 */ 16 17 #define MACHINE "i386" 18 19 /* 20 * Round p (pointer or byte index) up to a correctly-aligned value for all 21 * data types (int, long, ...). The result is u_int and must be cast to 22 * any desired pointer type. 23 */ 24 #define ALIGNBYTES 3 25 #define ALIGN(p) (((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES) 26 27 #define NBPG 4096 /* bytes/page */ 28 #define PGOFSET (NBPG-1) /* byte offset into page */ 29 #define PGSHIFT 12 /* LOG2(NBPG) */ 30 #define NPTEPG (NBPG/(sizeof (struct pte))) 31 32 #define NBPDR (1024*NBPG) /* bytes/page dir */ 33 #define PDROFSET (NBPDR-1) /* byte offset into page dir */ 34 #define PDRSHIFT 22 /* LOG2(NBPDR) */ 35 36 #define KERNBASE 0xFE000000 /* start of kernel virtual */ 37 #define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) 38 39 #define DEV_BSIZE 512 40 #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 41 #define BLKDEV_IOSIZE 2048 42 #define MAXPHYS (64 * 1024) /* max raw I/O transfer size */ 43 44 #define CLSIZE 1 45 #define CLSIZELOG2 0 46 47 /* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */ 48 #define SSIZE 1 /* initial stack size/NBPG */ 49 #define SINCR 1 /* increment of stack/NBPG */ 50 51 #define UPAGES 2 /* pages of u-area */ 52 53 /* 54 * Constants related to network buffer management. 55 * MCLBYTES must be no larger than CLBYTES (the software page size), and, 56 * on machines that exchange pages of input or output buffers with mbuf 57 * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple 58 * of the hardware page size. 59 */ 60 #define MSIZE 128 /* size of an mbuf */ 61 #define MCLBYTES 1024 62 #define MCLSHIFT 10 63 #define MCLOFSET (MCLBYTES - 1) 64 #ifndef NMBCLUSTERS 65 #ifdef GATEWAY 66 #define NMBCLUSTERS 512 /* map size, max cluster allocation */ 67 #else 68 #define NMBCLUSTERS 256 /* map size, max cluster allocation */ 69 #endif 70 #endif 71 72 /* 73 * Size of kernel malloc arena in CLBYTES-sized logical pages 74 */ 75 #ifndef NKMEMCLUSTERS 76 #define NKMEMCLUSTERS (2048*1024/CLBYTES) 77 #endif 78 /* 79 * Some macros for units conversion 80 */ 81 /* Core clicks (4096 bytes) to segments and vice versa */ 82 #define ctos(x) (x) 83 #define stoc(x) (x) 84 85 /* Core clicks (4096 bytes) to disk blocks */ 86 #define ctod(x) ((x)<<(PGSHIFT-DEV_BSHIFT)) 87 #define dtoc(x) ((x)>>(PGSHIFT-DEV_BSHIFT)) 88 #define dtob(x) ((x)<<DEV_BSHIFT) 89 90 /* clicks to bytes */ 91 #define ctob(x) ((x)<<PGSHIFT) 92 93 /* bytes to clicks */ 94 #define btoc(x) (((unsigned)(x)+(NBPG-1))>>PGSHIFT) 95 96 #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ 97 ((bytes) >> DEV_BSHIFT) 98 #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ 99 ((db) << DEV_BSHIFT) 100 101 /* 102 * Map a ``block device block'' to a file system block. 103 * This should be device dependent, and will be if we 104 * add an entry to cdevsw/bdevsw for that purpose. 105 * For now though just use DEV_BSIZE. 106 */ 107 #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) 108 109 /* 110 * Mach derived conversion macros 111 */ 112 #define i386_round_pdr(x) ((((unsigned)(x)) + NBPDR - 1) & ~(NBPDR-1)) 113 #define i386_trunc_pdr(x) ((unsigned)(x) & ~(NBPDR-1)) 114 #define i386_round_page(x) ((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1)) 115 #define i386_trunc_page(x) ((unsigned)(x) & ~(NBPG-1)) 116 #define i386_btod(x) ((unsigned)(x) >> PDRSHIFT) 117 #define i386_dtob(x) ((unsigned)(x) << PDRSHIFT) 118 #define i386_btop(x) ((unsigned)(x) >> PGSHIFT) 119 #define i386_ptob(x) ((unsigned)(x) << PGSHIFT) 120 121 #ifndef KERNEL 122 /* DELAY is in locore.s for the kernel */ 123 #define DELAY(n) { register int N = (n); while (--N > 0); } 124 #endif 125