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.6 (Berkeley) 06/08/91 15 */ 16 17 /* 18 * Machine dependent constants for HP9000 series 300. 19 */ 20 #define MACHINE "hp300" 21 22 #define NBPG 4096 /* bytes/page */ 23 #define PGOFSET (NBPG-1) /* byte offset into page */ 24 #define PGSHIFT 12 /* LOG2(NBPG) */ 25 #define NPTEPG (NBPG/(sizeof (struct pte))) 26 27 #define NBSEG (1024*NBPG) /* bytes/segment */ 28 #define SEGOFSET (NBSEG-1) /* byte offset into segment */ 29 #define SEGSHIFT 22 /* LOG2(NBSEG) */ 30 31 #define KERNBASE 0x00000000 /* start of kernel virtual */ 32 #define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) 33 34 #define DEV_BSIZE 512 35 #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 36 #define BLKDEV_IOSIZE 2048 37 #define MAXPHYS (64 * 1024) /* max raw I/O transfer size */ 38 39 #define CLSIZE 1 40 #define CLSIZELOG2 0 41 42 /* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */ 43 #define SSIZE 1 /* initial stack size/NBPG */ 44 #define SINCR 1 /* increment of stack/NBPG */ 45 46 #define UPAGES 3 /* pages of u-area */ 47 48 /* 49 * Constants related to network buffer management. 50 * MCLBYTES must be no larger than CLBYTES (the software page size), and, 51 * on machines that exchange pages of input or output buffers with mbuf 52 * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple 53 * of the hardware page size. 54 */ 55 #define MSIZE 128 /* size of an mbuf */ 56 #define MCLBYTES 1024 57 #define MCLSHIFT 10 58 #define MCLOFSET (MCLBYTES - 1) 59 #ifndef NMBCLUSTERS 60 #ifdef GATEWAY 61 #define NMBCLUSTERS 512 /* map size, max cluster allocation */ 62 #else 63 #define NMBCLUSTERS 256 /* map size, max cluster allocation */ 64 #endif 65 #endif 66 67 /* 68 * Size of kernel malloc arena in CLBYTES-sized logical pages 69 */ 70 #ifndef NKMEMCLUSTERS 71 #define NKMEMCLUSTERS (512*1024/CLBYTES) 72 #endif 73 74 /* pages ("clicks") (4096 bytes) to disk blocks */ 75 #define ctod(x) ((x)<<(PGSHIFT-DEV_BSHIFT)) 76 #define dtoc(x) ((x)>>(PGSHIFT-DEV_BSHIFT)) 77 #define dtob(x) ((x)<<DEV_BSHIFT) 78 79 /* pages to bytes */ 80 #define ctob(x) ((x)<<PGSHIFT) 81 82 /* bytes to pages */ 83 #define btoc(x) (((unsigned)(x)+(NBPG-1))>>PGSHIFT) 84 85 #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ 86 ((unsigned)(bytes) >> DEV_BSHIFT) 87 #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ 88 ((unsigned)(db) << DEV_BSHIFT) 89 90 /* 91 * Map a ``block device block'' to a file system block. 92 * This should be device dependent, and should use the bsize 93 * field from the disk label. 94 * For now though just use DEV_BSIZE. 95 */ 96 #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) 97 98 /* 99 * Mach derived conversion macros 100 */ 101 #define hp300_round_seg(x) ((((unsigned)(x)) + NBSEG - 1) & ~(NBSEG-1)) 102 #define hp300_trunc_seg(x) ((unsigned)(x) & ~(NBSEG-1)) 103 #define hp300_round_page(x) ((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1)) 104 #define hp300_trunc_page(x) ((unsigned)(x) & ~(NBPG-1)) 105 #define hp300_btos(x) ((unsigned)(x) >> SEGSHIFT) 106 #define hp300_stob(x) ((unsigned)(x) << SEGSHIFT) 107 #define hp300_btop(x) ((unsigned)(x) >> PGSHIFT) 108 #define hp300_ptob(x) ((unsigned)(x) << PGSHIFT) 109 110 /* 111 * spl functions; all but spl0 are done in-line 112 */ 113 #include <machine/psl.h> 114 115 #define _spl(s) \ 116 ({ \ 117 register int _spl_r; \ 118 \ 119 asm __volatile ("clrl %0; movew sr,%0; movew %1,sr" : \ 120 "&=d" (_spl_r) : "di" (s)); \ 121 _spl_r; \ 122 }) 123 124 /* spl0 requires checking for software interrupts */ 125 #define spl1() _spl(PSL_S|PSL_IPL1) 126 #define spl2() _spl(PSL_S|PSL_IPL2) 127 #define spl3() _spl(PSL_S|PSL_IPL3) 128 #define spl4() _spl(PSL_S|PSL_IPL4) 129 #define spl5() _spl(PSL_S|PSL_IPL5) 130 #define spl6() _spl(PSL_S|PSL_IPL6) 131 #define spl7() _spl(PSL_S|PSL_IPL7) 132 133 #define splsoftclock() spl1() 134 #define splnet() spl1() 135 #define splbio() spl5() 136 #define splimp() spl5() 137 #define spltty() spl5() 138 #define splclock() spl6() 139 #define splvm() spl6() 140 #define splhigh() spl7() 141 #define splsched() spl7() 142 143 /* watch out for side effects */ 144 #define splx(s) (s & PSL_IPL ? _spl(s) : spl0()) 145 146 #ifdef KERNEL 147 #ifndef LOCORE 148 int cpuspeed; 149 #define DELAY(n) { register int N = cpuspeed * (n); while (--N > 0); } 150 #endif 151 152 #else 153 #define DELAY(n) { register int N = (n); while (--N > 0); } 154 #endif 155 156 #ifdef HPUXCOMPAT 157 /* 158 * Constants/macros for HPUX multiple mapping of user address space. 159 * Pages in the first 256Mb are mapped in at every 256Mb segment. 160 */ 161 #define HPMMMASK 0xF0000000 162 #define ISHPMMADDR(v) \ 163 ((curproc->p_addr->u_pcb.pcb_flags&PCB_HPUXMMAP) && ((unsigned)(v)&HPMMMASK) != HPMMMASK) 164 #define HPMMBASEADDR(v) ((unsigned)(v) & ~HPMMMASK) 165 #endif 166