1 /* 2 * Copyright (c) 1988 University of Utah. 3 * Copyright (c) 1982, 1986, 1990 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. 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/19/92 15 */ 16 17 /* 18 * Machine dependent constants for HP9000 series 300. 19 */ 20 #define MACHINE "hp300" 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 ALIGN(p) (((u_int)(p) + 3) &~ 3) 28 29 #define NBPG 4096 /* bytes/page */ 30 #define PGOFSET (NBPG-1) /* byte offset into page */ 31 #define PGSHIFT 12 /* LOG2(NBPG) */ 32 #define NPTEPG (NBPG/(sizeof (struct pte))) 33 34 #define NBSEG (1024*NBPG) /* bytes/segment */ 35 #define SEGOFSET (NBSEG-1) /* byte offset into segment */ 36 #define SEGSHIFT 22 /* LOG2(NBSEG) */ 37 38 #define KERNBASE 0x00000000 /* start of kernel virtual */ 39 #define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) 40 41 #define DEV_BSIZE 512 42 #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 43 #define BLKDEV_IOSIZE 2048 44 #define MAXPHYS (64 * 1024) /* max raw I/O transfer size */ 45 46 #define CLSIZE 1 47 #define CLSIZELOG2 0 48 49 /* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */ 50 #define SSIZE 1 /* initial stack size/NBPG */ 51 #define SINCR 1 /* increment of stack/NBPG */ 52 53 #define UPAGES 3 /* pages of u-area */ 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 (2048*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 hp300_round_seg(x) ((((unsigned)(x)) + NBSEG - 1) & ~(NBSEG-1)) 109 #define hp300_trunc_seg(x) ((unsigned)(x) & ~(NBSEG-1)) 110 #define hp300_round_page(x) ((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1)) 111 #define hp300_trunc_page(x) ((unsigned)(x) & ~(NBPG-1)) 112 #define hp300_btos(x) ((unsigned)(x) >> SEGSHIFT) 113 #define hp300_stob(x) ((unsigned)(x) << SEGSHIFT) 114 #define hp300_btop(x) ((unsigned)(x) >> PGSHIFT) 115 #define hp300_ptob(x) ((unsigned)(x) << PGSHIFT) 116 117 /* 118 * spl functions; all but spl0 are done in-line 119 */ 120 #include <machine/psl.h> 121 122 #define _spl(s) \ 123 ({ \ 124 register int _spl_r; \ 125 \ 126 asm __volatile ("clrl %0; movew sr,%0; movew %1,sr" : \ 127 "&=d" (_spl_r) : "di" (s)); \ 128 _spl_r; \ 129 }) 130 131 /* spl0 requires checking for software interrupts */ 132 #define spl1() _spl(PSL_S|PSL_IPL1) 133 #define spl2() _spl(PSL_S|PSL_IPL2) 134 #define spl3() _spl(PSL_S|PSL_IPL3) 135 #define spl4() _spl(PSL_S|PSL_IPL4) 136 #define spl5() _spl(PSL_S|PSL_IPL5) 137 #define spl6() _spl(PSL_S|PSL_IPL6) 138 #define spl7() _spl(PSL_S|PSL_IPL7) 139 140 #define splsoftclock() spl1() 141 #define splnet() spl1() 142 #define splbio() spl5() 143 #define splimp() spl5() 144 #define spltty() spl5() 145 #define splclock() spl6() 146 #define splvm() spl6() 147 #define splhigh() spl7() 148 #define splsched() spl7() 149 150 /* watch out for side effects */ 151 #define splx(s) (s & PSL_IPL ? _spl(s) : spl0()) 152 153 #ifdef KERNEL 154 #ifndef LOCORE 155 int cpuspeed; 156 #define DELAY(n) { register int N = cpuspeed * (n); while (--N > 0); } 157 #endif 158 159 #else 160 #define DELAY(n) { register int N = (n); while (--N > 0); } 161 #endif 162 163 #ifdef HPUXCOMPAT 164 /* 165 * Constants/macros for HPUX multiple mapping of user address space. 166 * Pages in the first 256Mb are mapped in at every 256Mb segment. 167 */ 168 #define HPMMMASK 0xF0000000 169 #define ISHPMMADDR(v) \ 170 ((curproc->p_addr->u_pcb.pcb_flags&PCB_HPUXMMAP) && ((unsigned)(v)&HPMMMASK) != HPMMMASK) 171 #define HPMMBASEADDR(v) ((unsigned)(v) & ~HPMMMASK) 172 #endif 173