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