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