1 /* 2 * Copyright (c) 1988 University of Utah. 3 * Copyright (c) 1992 The Regents of the University of California. 4 * 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 7.9 (Berkeley) 02/04/93 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 KERNBASE 0x80000000 /* 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 (24 * 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 #define UADDR 0xffffd000 /* address of u */ 52 #define UVPN (UADDR>>PGSHIFT)/* virtual page number of u */ 53 #define KERNELSTACK (UADDR+UPAGES*NBPG) /* top of kernel stack */ 54 55 /* 56 * Constants related to network buffer management. 57 * MCLBYTES must be no larger than CLBYTES (the software page size), and, 58 * on machines that exchange pages of input or output buffers with mbuf 59 * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple 60 * of the hardware page size. 61 */ 62 #define MSIZE 128 /* size of an mbuf */ 63 #define MCLBYTES 1024 64 #define MCLSHIFT 10 65 #define MCLOFSET (MCLBYTES - 1) 66 #ifndef NMBCLUSTERS 67 #ifdef GATEWAY 68 #define NMBCLUSTERS 512 /* map size, max cluster allocation */ 69 #else 70 #define NMBCLUSTERS 256 /* map size, max cluster allocation */ 71 #endif 72 #endif 73 74 /* 75 * Size of kernel malloc arena in CLBYTES-sized logical pages 76 */ 77 #ifndef NKMEMCLUSTERS 78 #define NKMEMCLUSTERS (512*1024/CLBYTES) 79 #endif 80 81 /* pages ("clicks") (4096 bytes) to disk blocks */ 82 #define ctod(x) ((x)<<(PGSHIFT-DEV_BSHIFT)) 83 #define dtoc(x) ((x)>>(PGSHIFT-DEV_BSHIFT)) 84 #define dtob(x) ((x)<<DEV_BSHIFT) 85 86 /* pages to bytes */ 87 #define ctob(x) ((x)<<PGSHIFT) 88 89 /* bytes to pages */ 90 #define btoc(x) (((unsigned)(x)+(NBPG-1))>>PGSHIFT) 91 92 #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ 93 ((unsigned)(bytes) >> DEV_BSHIFT) 94 #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ 95 ((unsigned)(db) << DEV_BSHIFT) 96 97 /* 98 * Map a ``block device block'' to a file system block. 99 * This should be device dependent, and should use the bsize 100 * field from the disk label. 101 * For now though just use DEV_BSIZE. 102 */ 103 #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) 104 105 /* 106 * Mach derived conversion macros 107 */ 108 #define pmax_round_page(x) ((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1)) 109 #define pmax_trunc_page(x) ((unsigned)(x) & ~(NBPG-1)) 110 #define pmax_btop(x) ((unsigned)(x) >> PGSHIFT) 111 #define pmax_ptob(x) ((unsigned)(x) << PGSHIFT) 112 113 #ifdef KERNEL 114 #ifndef LOCORE 115 extern int (*Mach_splnet)(), (*Mach_splbio)(), (*Mach_splimp)(), 116 (*Mach_spltty)(), (*Mach_splclock)(), (*Mach_splstatclock)(); 117 #define splnet() ((*Mach_splnet)()) 118 #define splbio() ((*Mach_splbio)()) 119 #define splimp() ((*Mach_splimp)()) 120 #define spltty() ((*Mach_spltty)()) 121 #define splclock() ((*Mach_splclock)()) 122 #define splstatclock() ((*Mach_splstatclock)()) 123 extern int cpuspeed; 124 #define DELAY(n) { register int N = cpuspeed * (n); while (--N > 0); } 125 #endif 126 127 #else /* !KERNEL */ 128 #define DELAY(n) { register int N = (n); while (--N > 0); } 129 #endif /* !KERNEL */ 130