| @@ -1,712 +1,742 @@ | | | @@ -1,712 +1,742 @@ |
1 | /* $NetBSD: emul.c,v 1.80 2009/03/18 10:22:44 cegger Exp $ */ | | 1 | /* $NetBSD: emul.c,v 1.81 2009/03/18 17:56:15 pooka Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2007 Antti Kantee. All Rights Reserved. | | 4 | * Copyright (c) 2007 Antti Kantee. All Rights Reserved. |
5 | * | | 5 | * |
6 | * Development of this software was supported by Google Summer of Code. | | 6 | * Development of this software was supported by Google Summer of Code. |
7 | * | | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | | 8 | * Redistribution and use in source and binary forms, with or without |
9 | * modification, are permitted provided that the following conditions | | 9 | * modification, are permitted provided that the following conditions |
10 | * are met: | | 10 | * are met: |
11 | * 1. Redistributions of source code must retain the above copyright | | 11 | * 1. Redistributions of source code must retain the above copyright |
12 | * notice, this list of conditions and the following disclaimer. | | 12 | * notice, this list of conditions and the following disclaimer. |
13 | * 2. Redistributions in binary form must reproduce the above copyright | | 13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the | | 14 | * notice, this list of conditions and the following disclaimer in the |
15 | * documentation and/or other materials provided with the distribution. | | 15 | * documentation and/or other materials provided with the distribution. |
16 | * | | 16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS | | 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS |
18 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | | 18 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | | 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
20 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | | 20 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | | 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
23 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 23 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
27 | * SUCH DAMAGE. | | 27 | * SUCH DAMAGE. |
28 | */ | | 28 | */ |
29 | | | 29 | |
30 | #include <sys/cdefs.h> | | 30 | #include <sys/cdefs.h> |
31 | __KERNEL_RCSID(0, "$NetBSD: emul.c,v 1.80 2009/03/18 10:22:44 cegger Exp $"); | | 31 | __KERNEL_RCSID(0, "$NetBSD: emul.c,v 1.81 2009/03/18 17:56:15 pooka Exp $"); |
32 | | | 32 | |
33 | #include <sys/param.h> | | 33 | #include <sys/param.h> |
34 | #include <sys/malloc.h> | | 34 | #include <sys/malloc.h> |
35 | #include <sys/null.h> | | 35 | #include <sys/null.h> |
36 | #include <sys/vnode.h> | | 36 | #include <sys/vnode.h> |
37 | #include <sys/stat.h> | | 37 | #include <sys/stat.h> |
38 | #include <sys/select.h> | | 38 | #include <sys/select.h> |
39 | #include <sys/syslog.h> | | 39 | #include <sys/syslog.h> |
40 | #include <sys/namei.h> | | 40 | #include <sys/namei.h> |
41 | #include <sys/kauth.h> | | 41 | #include <sys/kauth.h> |
42 | #include <sys/conf.h> | | 42 | #include <sys/conf.h> |
43 | #include <sys/device.h> | | 43 | #include <sys/device.h> |
44 | #include <sys/queue.h> | | 44 | #include <sys/queue.h> |
45 | #include <sys/file.h> | | 45 | #include <sys/file.h> |
46 | #include <sys/filedesc.h> | | 46 | #include <sys/filedesc.h> |
47 | #include <sys/kthread.h> | | 47 | #include <sys/kthread.h> |
48 | #include <sys/cpu.h> | | 48 | #include <sys/cpu.h> |
49 | #include <sys/kmem.h> | | 49 | #include <sys/kmem.h> |
50 | #include <sys/poll.h> | | 50 | #include <sys/poll.h> |
51 | #include <sys/timetc.h> | | 51 | #include <sys/timetc.h> |
52 | #include <sys/tprintf.h> | | 52 | #include <sys/tprintf.h> |
53 | #include <sys/module.h> | | 53 | #include <sys/module.h> |
54 | #include <sys/tty.h> | | 54 | #include <sys/tty.h> |
55 | #include <sys/reboot.h> | | 55 | #include <sys/reboot.h> |
56 | | | 56 | |
57 | #include <dev/cons.h> | | 57 | #include <dev/cons.h> |
58 | | | 58 | |
59 | #include <machine/stdarg.h> | | 59 | #include <machine/stdarg.h> |
60 | | | 60 | |
61 | #include <rump/rumpuser.h> | | 61 | #include <rump/rumpuser.h> |
62 | | | 62 | |
63 | #include <uvm/uvm_map.h> | | 63 | #include <uvm/uvm_map.h> |
64 | | | 64 | |
65 | #include "rump_private.h" | | 65 | #include "rump_private.h" |
66 | | | 66 | |
67 | time_t time_second = 1; | | 67 | time_t time_second = 1; |
68 | | | 68 | |
69 | kmutex_t *proc_lock; | | 69 | kmutex_t *proc_lock; |
70 | struct lwp lwp0; | | 70 | struct lwp lwp0; |
71 | struct vnode *rootvp; | | 71 | struct vnode *rootvp; |
72 | struct device *root_device; | | 72 | struct device *root_device; |
73 | dev_t rootdev; | | 73 | dev_t rootdev; |
74 | int physmem = 256*256; /* 256 * 1024*1024 / 4k, PAGE_SIZE not always set */ | | 74 | int physmem = 256*256; /* 256 * 1024*1024 / 4k, PAGE_SIZE not always set */ |
75 | int doing_shutdown; | | 75 | int doing_shutdown; |
76 | int ncpu = 1; | | 76 | int ncpu = 1; |
77 | const int schedppq = 1; | | 77 | const int schedppq = 1; |
78 | int hardclock_ticks; | | 78 | int hardclock_ticks; |
79 | bool mp_online = false; | | 79 | bool mp_online = false; |
80 | struct vm_map *mb_map; | | 80 | struct vm_map *mb_map; |
81 | struct timeval boottime; | | 81 | struct timeval boottime; |
82 | struct emul emul_netbsd; | | 82 | struct emul emul_netbsd; |
83 | int cold = 1; | | 83 | int cold = 1; |
84 | int boothowto; | | 84 | int boothowto; |
85 | struct tty *constty; | | 85 | struct tty *constty; |
86 | | | 86 | |
87 | char hostname[MAXHOSTNAMELEN]; | | 87 | char hostname[MAXHOSTNAMELEN]; |
88 | size_t hostnamelen; | | 88 | size_t hostnamelen; |
89 | | | 89 | |
90 | u_long bufmem_valimit; | | 90 | u_long bufmem_valimit; |
91 | u_long bufmem_hiwater; | | 91 | u_long bufmem_hiwater; |
92 | u_long bufmem_lowater; | | 92 | u_long bufmem_lowater; |
93 | u_long bufmem; | | 93 | u_long bufmem; |
94 | u_int nbuf; | | 94 | u_int nbuf; |
95 | | | 95 | |
96 | const char *panicstr; | | 96 | const char *panicstr; |
97 | const char ostype[] = "NetBSD"; | | 97 | const char ostype[] = "NetBSD"; |
98 | const char osrelease[] = "999"; /* paradroid 4evah */ | | 98 | const char osrelease[] = "999"; /* paradroid 4evah */ |
99 | const char kernel_ident[] = "RUMP-ROAST"; | | 99 | const char kernel_ident[] = "RUMP-ROAST"; |
100 | const char *domainname; | | 100 | const char *domainname; |
101 | int domainnamelen; | | 101 | int domainnamelen; |
102 | | | 102 | |
103 | const struct filterops seltrue_filtops; | | 103 | const struct filterops seltrue_filtops; |
| | | 104 | const struct filterops sig_filtops; |
104 | | | 105 | |
105 | #define DEVSW_SIZE 255 | | 106 | #define DEVSW_SIZE 255 |
106 | const struct bdevsw *bdevsw0[DEVSW_SIZE]; /* XXX storage size */ | | 107 | const struct bdevsw *bdevsw0[DEVSW_SIZE]; /* XXX storage size */ |
107 | const struct bdevsw **bdevsw = bdevsw0; | | 108 | const struct bdevsw **bdevsw = bdevsw0; |
108 | const int sys_cdevsws = DEVSW_SIZE; | | 109 | const int sys_cdevsws = DEVSW_SIZE; |
109 | int max_cdevsws = DEVSW_SIZE; | | 110 | int max_cdevsws = DEVSW_SIZE; |
110 | | | 111 | |
111 | const struct cdevsw *cdevsw0[DEVSW_SIZE]; /* XXX storage size */ | | 112 | const struct cdevsw *cdevsw0[DEVSW_SIZE]; /* XXX storage size */ |
112 | const struct cdevsw **cdevsw = cdevsw0; | | 113 | const struct cdevsw **cdevsw = cdevsw0; |
113 | const int sys_bdevsws = DEVSW_SIZE; | | 114 | const int sys_bdevsws = DEVSW_SIZE; |
114 | int max_bdevsws = DEVSW_SIZE; | | 115 | int max_bdevsws = DEVSW_SIZE; |
115 | | | 116 | |
116 | struct devsw_conv devsw_conv0; | | 117 | struct devsw_conv devsw_conv0; |
117 | struct devsw_conv *devsw_conv = &devsw_conv0; | | 118 | struct devsw_conv *devsw_conv = &devsw_conv0; |
118 | int max_devsw_convs = 0; | | 119 | int max_devsw_convs = 0; |
119 | int mem_no = 2; | | 120 | int mem_no = 2; |
120 | | | 121 | |
121 | kmutex_t tty_lock; | | 122 | kmutex_t tty_lock; |
122 | | | 123 | |
123 | int | | 124 | int |
124 | copyin(const void *uaddr, void *kaddr, size_t len) | | 125 | copyin(const void *uaddr, void *kaddr, size_t len) |
125 | { | | 126 | { |
126 | | | 127 | |
127 | memcpy(kaddr, uaddr, len); | | 128 | memcpy(kaddr, uaddr, len); |
128 | return 0; | | 129 | return 0; |
129 | } | | 130 | } |
130 | | | 131 | |
131 | int | | 132 | int |
132 | copyout(const void *kaddr, void *uaddr, size_t len) | | 133 | copyout(const void *kaddr, void *uaddr, size_t len) |
133 | { | | 134 | { |
134 | | | 135 | |
135 | memcpy(uaddr, kaddr, len); | | 136 | memcpy(uaddr, kaddr, len); |
136 | return 0; | | 137 | return 0; |
137 | } | | 138 | } |
138 | | | 139 | |
139 | int | | 140 | int |
140 | copystr(const void *kfaddr, void *kdaddr, size_t len, size_t *done) | | 141 | copystr(const void *kfaddr, void *kdaddr, size_t len, size_t *done) |
141 | { | | 142 | { |
142 | | | 143 | |
143 | return copyinstr(kfaddr, kdaddr, len, done); | | 144 | return copyinstr(kfaddr, kdaddr, len, done); |
144 | } | | 145 | } |
145 | | | 146 | |
146 | int | | 147 | int |
147 | copyinstr(const void *uaddr, void *kaddr, size_t len, size_t *done) | | 148 | copyinstr(const void *uaddr, void *kaddr, size_t len, size_t *done) |
148 | { | | 149 | { |
149 | | | 150 | |
150 | strlcpy(kaddr, uaddr, len); | | 151 | strlcpy(kaddr, uaddr, len); |
151 | if (done) | | 152 | if (done) |
152 | *done = strlen(kaddr)+1; /* includes termination */ | | 153 | *done = strlen(kaddr)+1; /* includes termination */ |
153 | return 0; | | 154 | return 0; |
154 | } | | 155 | } |
155 | | | 156 | |
156 | int | | 157 | int |
| | | 158 | copyoutstr(const void *kaddr, void *uaddr, size_t len, size_t *done) |
| | | 159 | { |
| | | 160 | |
| | | 161 | strlcpy(uaddr, kaddr, len); |
| | | 162 | if (done) |
| | | 163 | *done = strlen(uaddr)+1; /* includes termination */ |
| | | 164 | return 0; |
| | | 165 | } |
| | | 166 | |
| | | 167 | int |
157 | copyin_vmspace(struct vmspace *vm, const void *uaddr, void *kaddr, size_t len) | | 168 | copyin_vmspace(struct vmspace *vm, const void *uaddr, void *kaddr, size_t len) |
158 | { | | 169 | { |
159 | | | 170 | |
160 | return copyin(uaddr, kaddr, len); | | 171 | return copyin(uaddr, kaddr, len); |
161 | } | | 172 | } |
162 | | | 173 | |
163 | int | | 174 | int |
164 | copyout_vmspace(struct vmspace *vm, const void *kaddr, void *uaddr, size_t len) | | 175 | copyout_vmspace(struct vmspace *vm, const void *kaddr, void *uaddr, size_t len) |
165 | { | | 176 | { |
166 | | | 177 | |
167 | return copyout(kaddr, uaddr, len); | | 178 | return copyout(kaddr, uaddr, len); |
168 | } | | 179 | } |
169 | | | 180 | |
170 | int | | 181 | int |
171 | kcopy(const void *src, void *dst, size_t len) | | 182 | kcopy(const void *src, void *dst, size_t len) |
172 | { | | 183 | { |
173 | | | 184 | |
174 | memcpy(dst, src, len); | | 185 | memcpy(dst, src, len); |
175 | return 0; | | 186 | return 0; |
176 | } | | 187 | } |
177 | | | 188 | |
178 | int | | 189 | int |
179 | uiomove(void *buf, size_t n, struct uio *uio) | | 190 | uiomove(void *buf, size_t n, struct uio *uio) |
180 | { | | 191 | { |
181 | struct iovec *iov; | | 192 | struct iovec *iov; |
182 | uint8_t *b = buf; | | 193 | uint8_t *b = buf; |
183 | size_t cnt; | | 194 | size_t cnt; |
184 | | | 195 | |
185 | if (uio->uio_vmspace != UIO_VMSPACE_SYS) | | 196 | if (uio->uio_vmspace != UIO_VMSPACE_SYS) |
186 | panic("%s: vmspace != UIO_VMSPACE_SYS", __func__); | | 197 | panic("%s: vmspace != UIO_VMSPACE_SYS", __func__); |
187 | | | 198 | |
188 | while (n && uio->uio_resid) { | | 199 | while (n && uio->uio_resid) { |
189 | iov = uio->uio_iov; | | 200 | iov = uio->uio_iov; |
190 | cnt = iov->iov_len; | | 201 | cnt = iov->iov_len; |
191 | if (cnt == 0) { | | 202 | if (cnt == 0) { |
192 | uio->uio_iov++; | | 203 | uio->uio_iov++; |
193 | uio->uio_iovcnt--; | | 204 | uio->uio_iovcnt--; |
194 | continue; | | 205 | continue; |
195 | } | | 206 | } |
196 | if (cnt > n) | | 207 | if (cnt > n) |
197 | cnt = n; | | 208 | cnt = n; |
198 | | | 209 | |
199 | if (uio->uio_rw == UIO_READ) | | 210 | if (uio->uio_rw == UIO_READ) |
200 | memcpy(iov->iov_base, b, cnt); | | 211 | memcpy(iov->iov_base, b, cnt); |
201 | else | | 212 | else |
202 | memcpy(b, iov->iov_base, cnt); | | 213 | memcpy(b, iov->iov_base, cnt); |
203 | | | 214 | |
204 | iov->iov_base = (uint8_t *)iov->iov_base + cnt; | | 215 | iov->iov_base = (uint8_t *)iov->iov_base + cnt; |
205 | iov->iov_len -= cnt; | | 216 | iov->iov_len -= cnt; |
206 | b += cnt; | | 217 | b += cnt; |
207 | uio->uio_resid -= cnt; | | 218 | uio->uio_resid -= cnt; |
208 | uio->uio_offset += cnt; | | 219 | uio->uio_offset += cnt; |
209 | n -= cnt; | | 220 | n -= cnt; |
210 | } | | 221 | } |
211 | | | 222 | |
212 | return 0; | | 223 | return 0; |
213 | } | | 224 | } |
214 | | | 225 | |
215 | void | | 226 | void |
216 | uio_setup_sysspace(struct uio *uio) | | 227 | uio_setup_sysspace(struct uio *uio) |
217 | { | | 228 | { |
218 | | | 229 | |
219 | uio->uio_vmspace = UIO_VMSPACE_SYS; | | 230 | uio->uio_vmspace = UIO_VMSPACE_SYS; |
220 | } | | 231 | } |
221 | | | 232 | |
222 | devclass_t | | 233 | devclass_t |
223 | device_class(device_t dev) | | 234 | device_class(device_t dev) |
224 | { | | 235 | { |
225 | | | 236 | |
226 | if (dev != root_device) | | 237 | if (dev != root_device) |
227 | panic("%s: dev != root_device not supported", __func__); | | 238 | panic("%s: dev != root_device not supported", __func__); |
228 | | | 239 | |
229 | return DV_DISK; | | 240 | return DV_DISK; |
230 | } | | 241 | } |
231 | | | 242 | |
232 | void | | 243 | void |
233 | getmicrouptime(struct timeval *tvp) | | 244 | getmicrouptime(struct timeval *tvp) |
234 | { | | 245 | { |
235 | uint64_t sec, nsec; | | 246 | uint64_t sec, nsec; |
236 | int error; | | 247 | int error; |
237 | | | 248 | |
238 | /* XXX: this is wrong, does not report *uptime* */ | | 249 | /* XXX: this is wrong, does not report *uptime* */ |
239 | rumpuser_gettime(&sec, &nsec, &error); | | 250 | rumpuser_gettime(&sec, &nsec, &error); |
240 | tvp->tv_sec = sec; | | 251 | tvp->tv_sec = sec; |
241 | tvp->tv_usec = nsec / 1000; | | 252 | tvp->tv_usec = nsec / 1000; |
242 | } | | 253 | } |
243 | | | 254 | |
244 | void | | 255 | void |
245 | malloc_type_attach(struct malloc_type *type) | | 256 | malloc_type_attach(struct malloc_type *type) |
246 | { | | 257 | { |
247 | | | 258 | |
248 | return; | | 259 | return; |
249 | } | | 260 | } |
250 | | | 261 | |
251 | void | | 262 | void |
252 | malloc_type_detach(struct malloc_type *type) | | 263 | malloc_type_detach(struct malloc_type *type) |
253 | { | | 264 | { |
254 | | | 265 | |
255 | return; | | 266 | return; |
256 | } | | 267 | } |
257 | | | 268 | |
258 | void * | | 269 | void * |
259 | kern_malloc(unsigned long size, struct malloc_type *type, int flags) | | 270 | kern_malloc(unsigned long size, struct malloc_type *type, int flags) |
260 | { | | 271 | { |
261 | void *rv; | | 272 | void *rv; |
262 | | | 273 | |
263 | rv = rumpuser_malloc(size, (flags & (M_CANFAIL | M_NOWAIT)) != 0); | | 274 | rv = rumpuser_malloc(size, (flags & (M_CANFAIL | M_NOWAIT)) != 0); |
264 | if (rv && flags & M_ZERO) | | 275 | if (rv && flags & M_ZERO) |
265 | memset(rv, 0, size); | | 276 | memset(rv, 0, size); |
266 | | | 277 | |
267 | return rv; | | 278 | return rv; |
268 | } | | 279 | } |
269 | | | 280 | |
270 | void * | | 281 | void * |
271 | kern_realloc(void *ptr, unsigned long size, struct malloc_type *type, int flags) | | 282 | kern_realloc(void *ptr, unsigned long size, struct malloc_type *type, int flags) |
272 | { | | 283 | { |
273 | | | 284 | |
274 | return rumpuser_malloc(size, (flags & (M_CANFAIL | M_NOWAIT)) != 0); | | 285 | return rumpuser_malloc(size, (flags & (M_CANFAIL | M_NOWAIT)) != 0); |
275 | } | | 286 | } |
276 | | | 287 | |
277 | void | | 288 | void |
278 | kern_free(void *ptr, struct malloc_type *type) | | 289 | kern_free(void *ptr, struct malloc_type *type) |
279 | { | | 290 | { |
280 | | | 291 | |
281 | rumpuser_free(ptr); | | 292 | rumpuser_free(ptr); |
282 | } | | 293 | } |
283 | | | 294 | |
284 | static void | | 295 | static void |
285 | gettime(struct timespec *ts) | | 296 | gettime(struct timespec *ts) |
286 | { | | 297 | { |
287 | uint64_t sec, nsec; | | 298 | uint64_t sec, nsec; |
288 | int error; | | 299 | int error; |
289 | | | 300 | |
290 | rumpuser_gettime(&sec, &nsec, &error); | | 301 | rumpuser_gettime(&sec, &nsec, &error); |
291 | ts->tv_sec = sec; | | 302 | ts->tv_sec = sec; |
292 | ts->tv_nsec = nsec; | | 303 | ts->tv_nsec = nsec; |
293 | } | | 304 | } |
294 | | | 305 | |
295 | void | | 306 | void |
296 | nanotime(struct timespec *ts) | | 307 | nanotime(struct timespec *ts) |
297 | { | | 308 | { |
298 | | | 309 | |
299 | if (rump_threads) { | | 310 | if (rump_threads) { |
300 | rump_gettime(ts); | | 311 | rump_gettime(ts); |
301 | } else { | | 312 | } else { |
302 | gettime(ts); | | 313 | gettime(ts); |
303 | } | | 314 | } |
304 | } | | 315 | } |
305 | | | 316 | |
306 | /* hooray for mick, so what if I do */ | | 317 | /* hooray for mick, so what if I do */ |
307 | void | | 318 | void |
308 | getnanotime(struct timespec *ts) | | 319 | getnanotime(struct timespec *ts) |
309 | { | | 320 | { |
310 | | | 321 | |
311 | nanotime(ts); | | 322 | nanotime(ts); |
312 | } | | 323 | } |
313 | | | 324 | |
314 | void | | 325 | void |
315 | microtime(struct timeval *tv) | | 326 | microtime(struct timeval *tv) |
316 | { | | 327 | { |
317 | struct timespec ts; | | 328 | struct timespec ts; |
318 | | | 329 | |
319 | if (rump_threads) { | | 330 | if (rump_threads) { |
320 | rump_gettime(&ts); | | 331 | rump_gettime(&ts); |
321 | TIMESPEC_TO_TIMEVAL(tv, &ts); | | 332 | TIMESPEC_TO_TIMEVAL(tv, &ts); |
322 | } else { | | 333 | } else { |
323 | gettime(&ts); | | 334 | gettime(&ts); |
324 | TIMESPEC_TO_TIMEVAL(tv, &ts); | | 335 | TIMESPEC_TO_TIMEVAL(tv, &ts); |
325 | } | | 336 | } |
326 | } | | 337 | } |
327 | | | 338 | |
328 | void | | 339 | void |
329 | getmicrotime(struct timeval *tv) | | 340 | getmicrotime(struct timeval *tv) |
330 | { | | 341 | { |
331 | | | 342 | |
332 | microtime(tv); | | 343 | microtime(tv); |
333 | } | | 344 | } |
334 | | | 345 | |
335 | struct kthdesc { | | 346 | struct kthdesc { |
336 | void (*f)(void *); | | 347 | void (*f)(void *); |
337 | void *arg; | | 348 | void *arg; |
338 | struct lwp *mylwp; | | 349 | struct lwp *mylwp; |
339 | }; | | 350 | }; |
340 | | | 351 | |
341 | static void * | | 352 | static void * |
342 | threadbouncer(void *arg) | | 353 | threadbouncer(void *arg) |
343 | { | | 354 | { |
344 | struct kthdesc *k = arg; | | 355 | struct kthdesc *k = arg; |
345 | void (*f)(void *); | | 356 | void (*f)(void *); |
346 | void *thrarg; | | 357 | void *thrarg; |
347 | | | 358 | |
348 | f = k->f; | | 359 | f = k->f; |
349 | thrarg = k->arg; | | 360 | thrarg = k->arg; |
350 | rumpuser_set_curlwp(k->mylwp); | | 361 | rumpuser_set_curlwp(k->mylwp); |
351 | kmem_free(k, sizeof(struct kthdesc)); | | 362 | kmem_free(k, sizeof(struct kthdesc)); |
352 | | | 363 | |
353 | if ((curlwp->l_pflag & LP_MPSAFE) == 0) | | 364 | if ((curlwp->l_pflag & LP_MPSAFE) == 0) |
354 | KERNEL_LOCK(1, NULL); | | 365 | KERNEL_LOCK(1, NULL); |
355 | f(thrarg); | | 366 | f(thrarg); |
356 | panic("unreachable, should kthread_exit()"); | | 367 | panic("unreachable, should kthread_exit()"); |
357 | } | | 368 | } |
358 | | | 369 | |
359 | int | | 370 | int |
360 | kthread_create(pri_t pri, int flags, struct cpu_info *ci, | | 371 | kthread_create(pri_t pri, int flags, struct cpu_info *ci, |
361 | void (*func)(void *), void *arg, lwp_t **newlp, const char *fmt, ...) | | 372 | void (*func)(void *), void *arg, lwp_t **newlp, const char *fmt, ...) |
362 | { | | 373 | { |
363 | char thrstore[MAXCOMLEN]; | | 374 | char thrstore[MAXCOMLEN]; |
364 | const char *thrname = NULL; | | 375 | const char *thrname = NULL; |
365 | va_list ap; | | 376 | va_list ap; |
366 | struct kthdesc *k; | | 377 | struct kthdesc *k; |
367 | struct lwp *l; | | 378 | struct lwp *l; |
368 | int rv; | | 379 | int rv; |
369 | | | 380 | |
370 | thrstore[0] = '\0'; | | 381 | thrstore[0] = '\0'; |
371 | if (fmt) { | | 382 | if (fmt) { |
372 | va_start(ap, fmt); | | 383 | va_start(ap, fmt); |
373 | vsnprintf(thrstore, sizeof(thrstore), fmt, ap); | | 384 | vsnprintf(thrstore, sizeof(thrstore), fmt, ap); |
374 | va_end(ap); | | 385 | va_end(ap); |
375 | thrname = thrstore; | | 386 | thrname = thrstore; |
376 | } | | 387 | } |
377 | | | 388 | |
378 | /* | | 389 | /* |
379 | * We don't want a module unload thread. | | 390 | * We don't want a module unload thread. |
380 | * (XXX: yes, this is a kludge too, and the kernel should | | 391 | * (XXX: yes, this is a kludge too, and the kernel should |
381 | * have a more flexible method for configuring which threads | | 392 | * have a more flexible method for configuring which threads |
382 | * we want). | | 393 | * we want). |
383 | */ | | 394 | */ |
384 | if (strcmp(thrstore, "modunload") == 0) { | | 395 | if (strcmp(thrstore, "modunload") == 0) { |
385 | return 0; | | 396 | return 0; |
386 | } | | 397 | } |
387 | | | 398 | |
388 | if (!rump_threads) { | | 399 | if (!rump_threads) { |
389 | /* fake them */ | | 400 | /* fake them */ |
390 | if (strcmp(thrstore, "vrele") == 0) { | | 401 | if (strcmp(thrstore, "vrele") == 0) { |
391 | printf("rump warning: threads not enabled, not starting" | | 402 | printf("rump warning: threads not enabled, not starting" |
392 | " vrele thread\n"); | | 403 | " vrele thread\n"); |
393 | return 0; | | 404 | return 0; |
394 | } else if (strcmp(thrstore, "cachegc") == 0) { | | 405 | } else if (strcmp(thrstore, "cachegc") == 0) { |
395 | printf("rump warning: threads not enabled, not starting" | | 406 | printf("rump warning: threads not enabled, not starting" |
396 | " namecache g/c thread\n"); | | 407 | " namecache g/c thread\n"); |
397 | return 0; | | 408 | return 0; |
398 | } else if (strcmp(thrstore, "nfssilly") == 0) { | | 409 | } else if (strcmp(thrstore, "nfssilly") == 0) { |
399 | printf("rump warning: threads not enabled, not enabling" | | 410 | printf("rump warning: threads not enabled, not enabling" |
400 | " nfs silly rename\n"); | | 411 | " nfs silly rename\n"); |
401 | return 0; | | 412 | return 0; |
402 | } else | | 413 | } else |
403 | panic("threads not available, setenv RUMP_THREADS 1"); | | 414 | panic("threads not available, setenv RUMP_THREADS 1"); |
404 | } | | 415 | } |
405 | | | 416 | |
406 | KASSERT(fmt != NULL); | | 417 | KASSERT(fmt != NULL); |
407 | if (ci != NULL) | | 418 | if (ci != NULL) |
408 | panic("%s: bounded threads not supported", __func__); | | 419 | panic("%s: bounded threads not supported", __func__); |
409 | | | 420 | |
410 | k = kmem_alloc(sizeof(struct kthdesc), KM_SLEEP); | | 421 | k = kmem_alloc(sizeof(struct kthdesc), KM_SLEEP); |
411 | k->f = func; | | 422 | k->f = func; |
412 | k->arg = arg; | | 423 | k->arg = arg; |
413 | k->mylwp = l = rump_setup_curlwp(0, rump_nextlid(), 0); | | 424 | k->mylwp = l = rump_setup_curlwp(0, rump_nextlid(), 0); |
414 | if (flags & KTHREAD_MPSAFE) | | 425 | if (flags & KTHREAD_MPSAFE) |
415 | l->l_pflag |= LP_MPSAFE; | | 426 | l->l_pflag |= LP_MPSAFE; |
416 | rv = rumpuser_thread_create(threadbouncer, k, thrname); | | 427 | rv = rumpuser_thread_create(threadbouncer, k, thrname); |
417 | if (rv) | | 428 | if (rv) |
418 | return rv; | | 429 | return rv; |
419 | | | 430 | |
420 | if (newlp) | | 431 | if (newlp) |
421 | *newlp = l; | | 432 | *newlp = l; |
422 | return 0; | | 433 | return 0; |
423 | } | | 434 | } |
424 | | | 435 | |
425 | void | | 436 | void |
426 | kthread_exit(int ecode) | | 437 | kthread_exit(int ecode) |
427 | { | | 438 | { |
428 | | | 439 | |
429 | if ((curlwp->l_pflag & LP_MPSAFE) == 0) | | 440 | if ((curlwp->l_pflag & LP_MPSAFE) == 0) |
430 | KERNEL_UNLOCK_ONE(NULL); | | 441 | KERNEL_UNLOCK_ONE(NULL); |
431 | rump_clear_curlwp(); | | 442 | rump_clear_curlwp(); |
432 | rumpuser_thread_exit(); | | 443 | rumpuser_thread_exit(); |
433 | } | | 444 | } |
434 | | | 445 | |
435 | struct proc * | | 446 | struct proc * |
436 | p_find(pid_t pid, uint flags) | | 447 | p_find(pid_t pid, uint flags) |
437 | { | | 448 | { |
438 | | | 449 | |
439 | panic("%s: not implemented", __func__); | | 450 | panic("%s: not implemented", __func__); |
440 | } | | 451 | } |
441 | | | 452 | |
442 | struct pgrp * | | 453 | struct pgrp * |
443 | pg_find(pid_t pid, uint flags) | | 454 | pg_find(pid_t pid, uint flags) |
444 | { | | 455 | { |
445 | | | 456 | |
446 | panic("%s: not implemented", __func__); | | 457 | panic("%s: not implemented", __func__); |
447 | } | | 458 | } |
448 | | | 459 | |
449 | void | | 460 | void |
450 | psignal(struct proc *p, int signo) | | 461 | psignal(struct proc *p, int signo) |
451 | { | | 462 | { |
452 | | | 463 | |
453 | switch (signo) { | | 464 | switch (signo) { |
454 | case SIGSYS: | | 465 | case SIGSYS: |
455 | break; | | 466 | break; |
456 | default: | | 467 | default: |
457 | panic("unhandled signal %d", signo); | | 468 | panic("unhandled signal %d", signo); |
458 | } | | 469 | } |
459 | } | | 470 | } |
460 | | | 471 | |
461 | void | | 472 | void |
462 | kpsignal(struct proc *p, ksiginfo_t *ksi, void *data) | | 473 | kpsignal(struct proc *p, ksiginfo_t *ksi, void *data) |
463 | { | | 474 | { |
464 | | | 475 | |
465 | panic("%s: not implemented", __func__); | | 476 | panic("%s: not implemented", __func__); |
466 | } | | 477 | } |
467 | | | 478 | |
468 | void | | 479 | void |
469 | kpgsignal(struct pgrp *pgrp, ksiginfo_t *ksi, void *data, int checkctty) | | 480 | kpgsignal(struct pgrp *pgrp, ksiginfo_t *ksi, void *data, int checkctty) |
470 | { | | 481 | { |
471 | | | 482 | |
472 | panic("%s: not implemented", __func__); | | 483 | panic("%s: not implemented", __func__); |
473 | } | | 484 | } |
474 | | | 485 | |
475 | int | | 486 | int |
476 | pgid_in_session(struct proc *p, pid_t pg_id) | | 487 | pgid_in_session(struct proc *p, pid_t pg_id) |
477 | { | | 488 | { |
478 | | | 489 | |
479 | panic("%s: not implemented", __func__); | | 490 | panic("%s: not implemented", __func__); |
480 | } | | 491 | } |
481 | | | 492 | |
482 | int | | 493 | int |
483 | sigispending(struct lwp *l, int signo) | | 494 | sigispending(struct lwp *l, int signo) |
484 | { | | 495 | { |
485 | | | 496 | |
486 | return 0; | | 497 | return 0; |
487 | } | | 498 | } |
488 | | | 499 | |
489 | void | | 500 | void |
490 | sigpending1(struct lwp *l, sigset_t *ss) | | 501 | sigpending1(struct lwp *l, sigset_t *ss) |
491 | { | | 502 | { |
492 | | | 503 | |
493 | panic("%s: not implemented", __func__); | | 504 | panic("%s: not implemented", __func__); |
494 | } | | 505 | } |
495 | | | 506 | |
496 | void | | | |
497 | knote_fdclose(int fd) | | | |
498 | { | | | |
499 | | | | |
500 | /* since we don't add knotes, we don't have to remove them */ | | | |
501 | } | | | |
502 | | | | |
503 | int | | | |
504 | seltrue_kqfilter(dev_t dev, struct knote *kn) | | | |
505 | { | | | |
506 | | | | |
507 | panic("%s: not implemented", __func__); | | | |
508 | } | | | |
509 | | | | |
510 | int | | 507 | int |
511 | kpause(const char *wmesg, bool intr, int timeo, kmutex_t *mtx) | | 508 | kpause(const char *wmesg, bool intr, int timeo, kmutex_t *mtx) |
512 | { | | 509 | { |
513 | extern int hz; | | 510 | extern int hz; |
514 | int rv, error; | | 511 | int rv, error; |
515 | uint64_t sec, nsec; | | 512 | uint64_t sec, nsec; |
516 | | | 513 | |
517 | if (mtx) | | 514 | if (mtx) |
518 | mutex_exit(mtx); | | 515 | mutex_exit(mtx); |
519 | | | 516 | |
520 | sec = timeo / hz; | | 517 | sec = timeo / hz; |
521 | nsec = (timeo % hz) * (1000000000 / hz); | | 518 | nsec = (timeo % hz) * (1000000000 / hz); |
522 | rv = rumpuser_nanosleep(&sec, &nsec, &error); | | 519 | rv = rumpuser_nanosleep(&sec, &nsec, &error); |
523 | | | 520 | |
524 | if (mtx) | | 521 | if (mtx) |
525 | mutex_enter(mtx); | | 522 | mutex_enter(mtx); |
526 | | | 523 | |
527 | if (rv) | | 524 | if (rv) |
528 | return error; | | 525 | return error; |
529 | | | 526 | |
530 | return 0; | | 527 | return 0; |
531 | } | | 528 | } |
532 | | | 529 | |
533 | void | | 530 | void |
534 | suspendsched(void) | | 531 | suspendsched(void) |
535 | { | | 532 | { |
536 | | | 533 | |
537 | panic("%s: not implemented", __func__); | | 534 | panic("%s: not implemented", __func__); |
538 | } | | 535 | } |
539 | | | 536 | |
540 | u_int | | 537 | u_int |
541 | lwp_unsleep(lwp_t *l, bool cleanup) | | 538 | lwp_unsleep(lwp_t *l, bool cleanup) |
542 | { | | 539 | { |
543 | | | 540 | |
544 | KASSERT(mutex_owned(l->l_mutex)); | | 541 | KASSERT(mutex_owned(l->l_mutex)); |
545 | | | 542 | |
546 | return (*l->l_syncobj->sobj_unsleep)(l, cleanup); | | 543 | return (*l->l_syncobj->sobj_unsleep)(l, cleanup); |
547 | } | | 544 | } |
548 | | | 545 | |
549 | vaddr_t | | 546 | vaddr_t |
550 | calc_cache_size(struct vm_map *map, int pct, int va_pct) | | 547 | calc_cache_size(struct vm_map *map, int pct, int va_pct) |
551 | { | | 548 | { |
552 | paddr_t t; | | 549 | paddr_t t; |
553 | | | 550 | |
554 | t = (paddr_t)physmem * pct / 100 * PAGE_SIZE; | | 551 | t = (paddr_t)physmem * pct / 100 * PAGE_SIZE; |
555 | if ((vaddr_t)t != t) { | | 552 | if ((vaddr_t)t != t) { |
556 | panic("%s: needs tweak", __func__); | | 553 | panic("%s: needs tweak", __func__); |
557 | } | | 554 | } |
558 | return t; | | 555 | return t; |
559 | } | | 556 | } |
560 | | | 557 | |
561 | int | | 558 | int |
562 | seltrue(dev_t dev, int events, struct lwp *l) | | 559 | seltrue(dev_t dev, int events, struct lwp *l) |
563 | { | | 560 | { |
564 | return (events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)); | | 561 | return (events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)); |
565 | } | | 562 | } |
566 | | | 563 | |
567 | void | | 564 | void |
568 | selrecord(lwp_t *selector, struct selinfo *sip) | | 565 | selrecord(lwp_t *selector, struct selinfo *sip) |
569 | { | | 566 | { |
570 | } | | 567 | } |
571 | | | 568 | |
572 | void | | 569 | void |
573 | selinit(struct selinfo *sip) | | 570 | selinit(struct selinfo *sip) |
574 | { | | 571 | { |
575 | } | | 572 | } |
576 | | | 573 | |
577 | void | | 574 | void |
578 | selnotify(struct selinfo *sip, int events, long knhint) | | 575 | selnotify(struct selinfo *sip, int events, long knhint) |
579 | { | | 576 | { |
580 | } | | 577 | } |
581 | | | 578 | |
582 | void | | 579 | void |
583 | seldestroy(struct selinfo *sip) | | 580 | seldestroy(struct selinfo *sip) |
584 | { | | 581 | { |
585 | } | | 582 | } |
586 | | | 583 | |
587 | const char * | | 584 | const char * |
588 | device_xname(device_t dv) | | 585 | device_xname(device_t dv) |
589 | { | | 586 | { |
590 | return "bogus0"; | | 587 | return "bogus0"; |
591 | } | | 588 | } |
592 | | | 589 | |
593 | void | | 590 | void |
594 | assert_sleepable(void) | | 591 | assert_sleepable(void) |
595 | { | | 592 | { |
596 | | | 593 | |
597 | /* always sleepable, although we should improve this */ | | 594 | /* always sleepable, although we should improve this */ |
598 | } | | 595 | } |
599 | | | 596 | |
600 | void | | 597 | void |
601 | tc_setclock(const struct timespec *ts) | | 598 | tc_setclock(const struct timespec *ts) |
602 | { | | 599 | { |
603 | | | 600 | |
604 | panic("%s: not implemented", __func__); | | 601 | panic("%s: not implemented", __func__); |
605 | } | | 602 | } |
606 | | | 603 | |
607 | void | | 604 | void |
608 | proc_crmod_enter(void) | | 605 | proc_crmod_enter(void) |
609 | { | | 606 | { |
610 | | | 607 | |
611 | panic("%s: not implemented", __func__); | | 608 | panic("%s: not implemented", __func__); |
612 | } | | 609 | } |
613 | | | 610 | |
614 | void | | 611 | void |
615 | proc_crmod_leave(kauth_cred_t c1, kauth_cred_t c2, bool sugid) | | 612 | proc_crmod_leave(kauth_cred_t c1, kauth_cred_t c2, bool sugid) |
616 | { | | 613 | { |
617 | | | 614 | |
618 | panic("%s: not implemented", __func__); | | 615 | panic("%s: not implemented", __func__); |
619 | } | | 616 | } |
620 | | | 617 | |
621 | void | | 618 | void |
622 | module_init_md(void) | | 619 | module_init_md(void) |
623 | { | | 620 | { |
624 | | | 621 | |
625 | /* | | 622 | /* |
626 | * Nothing for now. However, we should load the librump | | 623 | * Nothing for now. However, we should load the librump |
627 | * symbol table. | | 624 | * symbol table. |
628 | */ | | 625 | */ |
629 | } | | 626 | } |
630 | | | 627 | |
631 | /* us and them, after all we're only ordinary seconds */ | | 628 | /* us and them, after all we're only ordinary seconds */ |
632 | static void | | 629 | static void |
633 | rump_delay(unsigned int us) | | 630 | rump_delay(unsigned int us) |
634 | { | | 631 | { |
635 | uint64_t sec, nsec; | | 632 | uint64_t sec, nsec; |
636 | int error; | | 633 | int error; |
637 | | | 634 | |
638 | sec = us / 1000000; | | 635 | sec = us / 1000000; |
639 | nsec = (us % 1000000) * 1000; | | 636 | nsec = (us % 1000000) * 1000; |
640 | | | 637 | |
641 | if (__predict_false(sec != 0)) | | 638 | if (__predict_false(sec != 0)) |
642 | printf("WARNING: over 1s delay\n"); | | 639 | printf("WARNING: over 1s delay\n"); |
643 | | | 640 | |
644 | rumpuser_nanosleep(&sec, &nsec, &error); | | 641 | rumpuser_nanosleep(&sec, &nsec, &error); |
645 | } | | 642 | } |
646 | void (*delay_func)(unsigned int) = rump_delay; | | 643 | void (*delay_func)(unsigned int) = rump_delay; |
647 | | | 644 | |
648 | void | | 645 | void |
649 | kpreempt_disable(void) | | 646 | kpreempt_disable(void) |
650 | { | | 647 | { |
651 | | | 648 | |
652 | /* XXX: see below */ | | 649 | /* XXX: see below */ |
653 | KPREEMPT_DISABLE(curlwp); | | 650 | KPREEMPT_DISABLE(curlwp); |
654 | } | | 651 | } |
655 | | | 652 | |
656 | void | | 653 | void |
657 | kpreempt_enable(void) | | 654 | kpreempt_enable(void) |
658 | { | | 655 | { |
659 | | | 656 | |
660 | /* try to make sure kpreempt_disable() is only used from panic() */ | | 657 | /* try to make sure kpreempt_disable() is only used from panic() */ |
661 | panic("kpreempt not supported"); | | 658 | panic("kpreempt not supported"); |
662 | } | | 659 | } |
663 | | | 660 | |
664 | void | | 661 | void |
665 | sessdelete(struct session *ss) | | 662 | sessdelete(struct session *ss) |
666 | { | | 663 | { |
667 | | | 664 | |
668 | panic("sessdelete() impossible, session %p", ss); | | 665 | panic("sessdelete() impossible, session %p", ss); |
669 | } | | 666 | } |
670 | | | 667 | |
671 | int | | 668 | int |
672 | ttycheckoutq(struct tty *tp, int wait) | | 669 | ttycheckoutq(struct tty *tp, int wait) |
673 | { | | 670 | { |
674 | | | 671 | |
675 | return 1; | | 672 | return 1; |
676 | } | | 673 | } |
677 | | | 674 | |
678 | void | | 675 | void |
679 | cnputc(int c) | | 676 | cnputc(int c) |
680 | { | | 677 | { |
681 | int error; | | 678 | int error; |
682 | | | 679 | |
683 | rumpuser_putchar(c, &error); | | 680 | rumpuser_putchar(c, &error); |
684 | } | | 681 | } |
685 | | | 682 | |
686 | void | | 683 | void |
687 | cnflush(void) | | 684 | cnflush(void) |
688 | { | | 685 | { |
689 | | | 686 | |
690 | /* done */ | | 687 | /* done */ |
691 | } | | 688 | } |
692 | | | 689 | |
693 | int | | 690 | int |
694 | tputchar(int c, int flags, struct tty *tp) | | 691 | tputchar(int c, int flags, struct tty *tp) |
695 | { | | 692 | { |
696 | | | 693 | |
697 | cnputc(c); | | 694 | cnputc(c); |
698 | return 0; | | 695 | return 0; |
699 | } | | 696 | } |
700 | | | 697 | |
701 | void | | 698 | void |
702 | cpu_reboot(int howto, char *bootstr) | | 699 | cpu_reboot(int howto, char *bootstr) |
703 | { | | 700 | { |
704 | | | 701 | |
705 | rumpuser_panic(); | | 702 | rumpuser_panic(); |
706 | } | | 703 | } |
707 | | | 704 | |
708 | /* XXX: static, but not used except to make spcopy.S link */ | | 705 | /* XXX: static, but not used except to make spcopy.S link */ |
709 | #ifdef __hppa__ | | 706 | #ifdef __hppa__ |
710 | #undef curlwp | | 707 | #undef curlwp |
711 | struct lwp *curlwp = &lwp0; | | 708 | struct lwp *curlwp = &lwp0; |
712 | #endif | | 709 | #endif |
| | | 710 | |
| | | 711 | /* |
| | | 712 | * XXX: from sys_select.c, see that file for license. |
| | | 713 | * (these will go away really soon in favour of the real sys_select.c) |
| | | 714 | * ((really, the select code just needs cleanup)) |
| | | 715 | * (((seriously))) |
| | | 716 | */ |
| | | 717 | int |
| | | 718 | inittimeleft(struct timeval *tv, struct timeval *sleeptv) |
| | | 719 | { |
| | | 720 | if (itimerfix(tv)) |
| | | 721 | return -1; |
| | | 722 | getmicrouptime(sleeptv); |
| | | 723 | return 0; |
| | | 724 | } |
| | | 725 | |
| | | 726 | int |
| | | 727 | gettimeleft(struct timeval *tv, struct timeval *sleeptv) |
| | | 728 | { |
| | | 729 | /* |
| | | 730 | * We have to recalculate the timeout on every retry. |
| | | 731 | */ |
| | | 732 | struct timeval slepttv; |
| | | 733 | /* |
| | | 734 | * reduce tv by elapsed time |
| | | 735 | * based on monotonic time scale |
| | | 736 | */ |
| | | 737 | getmicrouptime(&slepttv); |
| | | 738 | timeradd(tv, sleeptv, tv); |
| | | 739 | timersub(tv, &slepttv, tv); |
| | | 740 | *sleeptv = slepttv; |
| | | 741 | return tvtohz(tv); |
| | | 742 | } |