Commit | Line | Data |
---|---|---|
88a7e859 KM |
1 | /* |
2 | * Copyright (c) 1988 University of Utah. | |
df7778ec KB |
3 | * Copyright (c) 1982, 1986, 1990, 1993 |
4 | * The Regents of the University of California. All rights reserved. | |
88a7e859 KM |
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 | * | |
b1c25049 | 12 | * from: Utah $Hdr: machparam.h 1.16 92/12/20$ |
88a7e859 | 13 | * |
e914cdf5 | 14 | * @(#)param.h 8.4 (Berkeley) %G% |
88a7e859 KM |
15 | */ |
16 | ||
17 | /* | |
18 | * Machine dependent constants for HP9000 series 300. | |
19 | */ | |
20 | #define MACHINE "hp300" | |
702e05af | 21 | #define NCPUS 1 |
88a7e859 | 22 | |
d04ccb97 | 23 | /* |
bc2f18e8 KB |
24 | * Round p (pointer or byte index) up to a correctly-aligned value for all |
25 | * data types (int, long, ...). The result is u_int and must be cast to | |
26 | * any desired pointer type. | |
d04ccb97 | 27 | */ |
83305898 KB |
28 | #define ALIGNBYTES 3 |
29 | #define ALIGN(p) (((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES) | |
d04ccb97 | 30 | |
88a7e859 KM |
31 | #define NBPG 4096 /* bytes/page */ |
32 | #define PGOFSET (NBPG-1) /* byte offset into page */ | |
33 | #define PGSHIFT 12 /* LOG2(NBPG) */ | |
34 | #define NPTEPG (NBPG/(sizeof (struct pte))) | |
35 | ||
9acfa6cd | 36 | #define NBSEG 0x400000 /* bytes/segment */ |
88a7e859 KM |
37 | #define SEGOFSET (NBSEG-1) /* byte offset into segment */ |
38 | #define SEGSHIFT 22 /* LOG2(NBSEG) */ | |
39 | ||
40 | #define KERNBASE 0x00000000 /* start of kernel virtual */ | |
41 | #define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) | |
42 | ||
43 | #define DEV_BSIZE 512 | |
44 | #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ | |
45 | #define BLKDEV_IOSIZE 2048 | |
46 | #define MAXPHYS (64 * 1024) /* max raw I/O transfer size */ | |
47 | ||
48 | #define CLSIZE 1 | |
49 | #define CLSIZELOG2 0 | |
50 | ||
98a9a1f2 | 51 | /* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */ |
88a7e859 KM |
52 | #define SSIZE 1 /* initial stack size/NBPG */ |
53 | #define SINCR 1 /* increment of stack/NBPG */ | |
54 | ||
b1c25049 | 55 | #define UPAGES 2 /* pages of u-area */ |
88a7e859 KM |
56 | |
57 | /* | |
58 | * Constants related to network buffer management. | |
59 | * MCLBYTES must be no larger than CLBYTES (the software page size), and, | |
60 | * on machines that exchange pages of input or output buffers with mbuf | |
61 | * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple | |
62 | * of the hardware page size. | |
63 | */ | |
64 | #define MSIZE 128 /* size of an mbuf */ | |
b1c25049 MH |
65 | #define MCLBYTES 2048 /* large enough for ether MTU */ |
66 | #define MCLSHIFT 11 | |
88a7e859 KM |
67 | #define MCLOFSET (MCLBYTES - 1) |
68 | #ifndef NMBCLUSTERS | |
69 | #ifdef GATEWAY | |
70 | #define NMBCLUSTERS 512 /* map size, max cluster allocation */ | |
71 | #else | |
72 | #define NMBCLUSTERS 256 /* map size, max cluster allocation */ | |
73 | #endif | |
74 | #endif | |
75 | ||
76 | /* | |
77 | * Size of kernel malloc arena in CLBYTES-sized logical pages | |
78 | */ | |
79 | #ifndef NKMEMCLUSTERS | |
db6c00fa | 80 | #define NKMEMCLUSTERS (2048*1024/CLBYTES) |
88a7e859 KM |
81 | #endif |
82 | ||
96b316eb | 83 | /* pages ("clicks") (4096 bytes) to disk blocks */ |
88a7e859 KM |
84 | #define ctod(x) ((x)<<(PGSHIFT-DEV_BSHIFT)) |
85 | #define dtoc(x) ((x)>>(PGSHIFT-DEV_BSHIFT)) | |
86 | #define dtob(x) ((x)<<DEV_BSHIFT) | |
87 | ||
96b316eb | 88 | /* pages to bytes */ |
88a7e859 KM |
89 | #define ctob(x) ((x)<<PGSHIFT) |
90 | ||
96b316eb | 91 | /* bytes to pages */ |
88a7e859 KM |
92 | #define btoc(x) (((unsigned)(x)+(NBPG-1))>>PGSHIFT) |
93 | ||
b1c25049 MH |
94 | #define LABELSECTOR (1024/DEV_BSIZE) |
95 | #define LABELOFFSET 0 | |
96 | ||
88a7e859 | 97 | #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ |
989fbb91 | 98 | ((bytes) >> DEV_BSHIFT) |
88a7e859 | 99 | #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ |
989fbb91 | 100 | ((db) << DEV_BSHIFT) |
88a7e859 KM |
101 | |
102 | /* | |
103 | * Map a ``block device block'' to a file system block. | |
98a9a1f2 MK |
104 | * This should be device dependent, and should use the bsize |
105 | * field from the disk label. | |
88a7e859 KM |
106 | * For now though just use DEV_BSIZE. |
107 | */ | |
108 | #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) | |
109 | ||
4534a638 KM |
110 | /* |
111 | * Mach derived conversion macros | |
112 | */ | |
4534a638 KM |
113 | #define hp300_round_page(x) ((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1)) |
114 | #define hp300_trunc_page(x) ((unsigned)(x) & ~(NBPG-1)) | |
4534a638 KM |
115 | #define hp300_btop(x) ((unsigned)(x) >> PGSHIFT) |
116 | #define hp300_ptob(x) ((unsigned)(x) << PGSHIFT) | |
117 | ||
88a7e859 | 118 | /* |
98a9a1f2 | 119 | * spl functions; all but spl0 are done in-line |
88a7e859 | 120 | */ |
98a9a1f2 MK |
121 | #include <machine/psl.h> |
122 | ||
123 | #define _spl(s) \ | |
124 | ({ \ | |
125 | register int _spl_r; \ | |
126 | \ | |
127 | asm __volatile ("clrl %0; movew sr,%0; movew %1,sr" : \ | |
128 | "&=d" (_spl_r) : "di" (s)); \ | |
129 | _spl_r; \ | |
130 | }) | |
131 | ||
132 | /* spl0 requires checking for software interrupts */ | |
133 | #define spl1() _spl(PSL_S|PSL_IPL1) | |
134 | #define spl2() _spl(PSL_S|PSL_IPL2) | |
135 | #define spl3() _spl(PSL_S|PSL_IPL3) | |
136 | #define spl4() _spl(PSL_S|PSL_IPL4) | |
137 | #define spl5() _spl(PSL_S|PSL_IPL5) | |
138 | #define spl6() _spl(PSL_S|PSL_IPL6) | |
139 | #define spl7() _spl(PSL_S|PSL_IPL7) | |
140 | ||
ce0d9cf2 KM |
141 | #define splsoftclock() spl1() |
142 | #define splnet() spl1() | |
143 | #define splbio() spl5() | |
144 | #define splimp() spl5() | |
145 | #define spltty() spl5() | |
146 | #define splclock() spl6() | |
147 | #define splstatclock() spl6() | |
148 | #define splvm() spl6() | |
149 | #define splhigh() spl7() | |
150 | #define splsched() spl7() | |
98a9a1f2 MK |
151 | |
152 | /* watch out for side effects */ | |
153 | #define splx(s) (s & PSL_IPL ? _spl(s) : spl0()) | |
88a7e859 KM |
154 | |
155 | #ifdef KERNEL | |
156 | #ifndef LOCORE | |
157 | int cpuspeed; | |
158 | #define DELAY(n) { register int N = cpuspeed * (n); while (--N > 0); } | |
159 | #endif | |
ffbc6a8d | 160 | #else |
88a7e859 | 161 | #define DELAY(n) { register int N = (n); while (--N > 0); } |
ffbc6a8d | 162 | #endif |
88a7e859 KM |
163 | |
164 | #ifdef HPUXCOMPAT | |
165 | /* | |
166 | * Constants/macros for HPUX multiple mapping of user address space. | |
167 | * Pages in the first 256Mb are mapped in at every 256Mb segment. | |
168 | */ | |
169 | #define HPMMMASK 0xF0000000 | |
9acfa6cd | 170 | #define ISHPMMADDR(v) \ |
b1c25049 MH |
171 | ((curproc->p_md.md_flags & MDP_HPUXMMAP) && \ |
172 | ((unsigned)(v) & HPMMMASK) && \ | |
9acfa6cd MH |
173 | ((unsigned)(v) & HPMMMASK) != HPMMMASK) |
174 | #define HPMMBASEADDR(v) \ | |
175 | ((unsigned)(v) & ~HPMMMASK) | |
88a7e859 | 176 | #endif |
702e05af | 177 | |
e914cdf5 KM |
178 | #ifndef _SIMPLELOCK_H_ |
179 | #define _SIMPLELOCK_H_ | |
702e05af KM |
180 | /* |
181 | * A simple spin lock. | |
182 | * | |
183 | * This structure only sets one bit of data, but is sized based on the | |
184 | * minimum word size that can be operated on by the hardware test-and-set | |
185 | * instruction. It is only needed for multiprocessors, as uniprocessors | |
186 | * will always run to completion or a sleep. It is an error to hold one | |
187 | * of these locks while a process is sleeping. | |
188 | */ | |
189 | struct simplelock { | |
190 | int lock_data; | |
191 | }; | |
192 | ||
193 | #if !defined(DEBUG) && NCPUS > 1 | |
194 | /* | |
195 | * The simple-lock routines are the primitives out of which the lock | |
196 | * package is built. The machine-dependent code must implement an | |
197 | * atomic test_and_set operation that indivisibly sets the simple lock | |
198 | * to non-zero and returns its old value. It also assumes that the | |
199 | * setting of the lock to zero below is indivisible. Simple locks may | |
200 | * only be used for exclusive locks. | |
201 | */ | |
202 | static __inline void | |
203 | simple_lock_init(lkp) | |
204 | struct simplelock *lkp; | |
205 | { | |
206 | ||
207 | lkp->lock_data = 0; | |
208 | } | |
209 | ||
210 | static __inline void | |
211 | simple_lock(lkp) | |
212 | __volatile struct simplelock *lkp; | |
213 | { | |
214 | ||
215 | while (test_and_set(&lkp->lock_data)) | |
216 | continue; | |
217 | } | |
218 | ||
219 | static __inline int | |
220 | simple_lock_try(lkp) | |
221 | __volatile struct simplelock *lkp; | |
222 | { | |
223 | ||
224 | return (!test_and_set(&lkp->lock_data)) | |
225 | } | |
226 | ||
227 | static __inline void | |
228 | simple_unlock(lkp) | |
229 | __volatile struct simplelock *lkp; | |
230 | { | |
231 | ||
232 | lkp->lock_data = 0; | |
233 | } | |
234 | #endif /* NCPUS > 1 */ | |
e914cdf5 | 235 | #endif /* !_SIMPLELOCK_H_ */ |