1 /* 2 * Copyright (c) 1988 University of Utah. 3 * Copyright (c) 1992, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * the Systems Programming Group of the University of Utah Computer 8 * Science Department and Ralph Campbell. 9 * 10 * %sccs.include.redist.c% 11 * 12 * from: Utah $Hdr: machparam.h 1.11 89/08/14$ 13 * 14 * @(#)param.h 8.2 (Berkeley) 03/29/95 15 */ 16 17 /* 18 * Machine dependent constants for DEC Station 3100. 19 */ 20 #define MACHINE "mips" 21 22 /* 23 * Round p (pointer or byte index) up to a correctly-aligned value for all 24 * data types (int, long, ...). The result is u_int and must be cast to 25 * any desired pointer type. 26 */ 27 #define ALIGNBYTES 7 28 #define ALIGN(p) (((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES) 29 30 #define NBPG 4096 /* bytes/page */ 31 #define PGOFSET (NBPG-1) /* byte offset into page */ 32 #define PGSHIFT 12 /* LOG2(NBPG) */ 33 #define NPTEPG (NBPG/4) 34 35 #define NBSEG 0x400000 /* bytes/segment */ 36 #define SEGOFSET (NBSEG-1) /* byte offset into segment */ 37 #define SEGSHIFT 22 /* LOG2(NBSEG) */ 38 39 #define KERNBASE 0x80000000 /* start of kernel virtual */ 40 #define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) 41 42 #define DEV_BSIZE 512 43 #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 44 #define BLKDEV_IOSIZE 2048 45 #define MAXPHYS (64 * 1024) /* max raw I/O transfer size */ 46 47 #define CLSIZE 1 48 #define CLSIZELOG2 0 49 50 /* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */ 51 #define SSIZE 1 /* initial stack size/NBPG */ 52 #define SINCR 1 /* increment of stack/NBPG */ 53 54 #define UPAGES 2 /* pages of u-area */ 55 #define UADDR 0xffffd000 /* address of u */ 56 #define UVPN (UADDR>>PGSHIFT)/* virtual page number of u */ 57 #define KERNELSTACK (UADDR+UPAGES*NBPG) /* top of kernel stack */ 58 59 /* 60 * Constants related to network buffer management. 61 * MCLBYTES must be no larger than CLBYTES (the software page size), and, 62 * on machines that exchange pages of input or output buffers with mbuf 63 * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple 64 * of the hardware page size. 65 */ 66 #define MSIZE 128 /* size of an mbuf */ 67 #define MCLBYTES 1024 68 #define MCLSHIFT 10 69 #define MCLOFSET (MCLBYTES - 1) 70 #ifndef NMBCLUSTERS 71 #ifdef GATEWAY 72 #define NMBCLUSTERS 512 /* map size, max cluster allocation */ 73 #else 74 #define NMBCLUSTERS 256 /* map size, max cluster allocation */ 75 #endif 76 #endif 77 78 /* 79 * Size of kernel malloc arena in CLBYTES-sized logical pages 80 */ 81 #ifndef NKMEMCLUSTERS 82 #define NKMEMCLUSTERS (512*1024/CLBYTES) 83 #endif 84 85 /* pages ("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 /* pages to bytes */ 91 #define ctob(x) ((x)<<PGSHIFT) 92 93 /* bytes to pages */ 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 should use the bsize 104 * field from the disk label. 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 pmax_round_page(x) ((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1)) 113 #define pmax_trunc_page(x) ((unsigned)(x) & ~(NBPG-1)) 114 #define pmax_btop(x) ((unsigned)(x) >> PGSHIFT) 115 #define pmax_ptob(x) ((unsigned)(x) << PGSHIFT) 116 117 #ifdef KERNEL 118 #ifndef LOCORE 119 extern int (*Mach_splnet)(), (*Mach_splbio)(), (*Mach_splimp)(), 120 (*Mach_spltty)(), (*Mach_splclock)(), (*Mach_splstatclock)(); 121 #define splnet() ((*Mach_splnet)()) 122 #define splbio() ((*Mach_splbio)()) 123 #define splimp() ((*Mach_splimp)()) 124 #define spltty() ((*Mach_spltty)()) 125 #define splclock() ((*Mach_splclock)()) 126 #define splstatclock() ((*Mach_splstatclock)()) 127 extern int cpuspeed; 128 #define DELAY(n) { register int N = cpuspeed * (n); while (--N > 0); } 129 #endif 130 131 #else /* !KERNEL */ 132 #define DELAY(n) { register int N = (n); while (--N > 0); } 133 #endif /* !KERNEL */ 134