netbsd32_time.c revision 1.36.4.1 1 1.36.4.1 rmind /* $NetBSD: netbsd32_time.c,v 1.36.4.1 2010/05/30 05:17:15 rmind Exp $ */
2 1.1 mrg
3 1.1 mrg /*
4 1.1 mrg * Copyright (c) 1998, 2001 Matthew R. Green
5 1.1 mrg * All rights reserved.
6 1.1 mrg *
7 1.1 mrg * Redistribution and use in source and binary forms, with or without
8 1.1 mrg * modification, are permitted provided that the following conditions
9 1.1 mrg * are met:
10 1.1 mrg * 1. Redistributions of source code must retain the above copyright
11 1.1 mrg * notice, this list of conditions and the following disclaimer.
12 1.1 mrg * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 mrg * notice, this list of conditions and the following disclaimer in the
14 1.1 mrg * documentation and/or other materials provided with the distribution.
15 1.1 mrg *
16 1.1 mrg * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 1.1 mrg * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 1.1 mrg * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 1.1 mrg * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 1.1 mrg * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 1.1 mrg * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 1.1 mrg * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 1.1 mrg * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 1.1 mrg * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 1.1 mrg * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 1.1 mrg * SUCH DAMAGE.
27 1.1 mrg */
28 1.3 lukem
29 1.3 lukem #include <sys/cdefs.h>
30 1.36.4.1 rmind __KERNEL_RCSID(0, "$NetBSD: netbsd32_time.c,v 1.36.4.1 2010/05/30 05:17:15 rmind Exp $");
31 1.1 mrg
32 1.2 mrg #if defined(_KERNEL_OPT)
33 1.1 mrg #include "opt_ntp.h"
34 1.21 drochner #include "opt_compat_netbsd.h"
35 1.1 mrg #endif
36 1.1 mrg
37 1.1 mrg #include <sys/param.h>
38 1.1 mrg #include <sys/systm.h>
39 1.1 mrg #include <sys/mount.h>
40 1.1 mrg #include <sys/time.h>
41 1.1 mrg #include <sys/timex.h>
42 1.13 cube #include <sys/timevar.h>
43 1.1 mrg #include <sys/proc.h>
44 1.5 thorpej #include <sys/pool.h>
45 1.1 mrg #include <sys/resourcevar.h>
46 1.12 christos #include <sys/dirent.h>
47 1.20 elad #include <sys/kauth.h>
48 1.1 mrg
49 1.1 mrg #include <compat/netbsd32/netbsd32.h>
50 1.1 mrg #include <compat/netbsd32/netbsd32_syscallargs.h>
51 1.1 mrg #include <compat/netbsd32/netbsd32_conv.h>
52 1.1 mrg
53 1.1 mrg #ifdef NTP
54 1.19 he
55 1.1 mrg int
56 1.35 christos netbsd32___ntp_gettime50(struct lwp *l,
57 1.35 christos const struct netbsd32___ntp_gettime50_args *uap, register_t *retval)
58 1.1 mrg {
59 1.30 dsl /* {
60 1.1 mrg syscallarg(netbsd32_ntptimevalp_t) ntvp;
61 1.30 dsl } */
62 1.1 mrg struct netbsd32_ntptimeval ntv32;
63 1.1 mrg struct ntptimeval ntv;
64 1.1 mrg int error = 0;
65 1.1 mrg
66 1.27 dsl if (SCARG_P32(uap, ntvp)) {
67 1.21 drochner ntp_gettime(&ntv);
68 1.1 mrg
69 1.21 drochner ntv32.time.tv_sec = ntv.time.tv_sec;
70 1.21 drochner ntv32.time.tv_nsec = ntv.time.tv_nsec;
71 1.1 mrg ntv32.maxerror = (netbsd32_long)ntv.maxerror;
72 1.1 mrg ntv32.esterror = (netbsd32_long)ntv.esterror;
73 1.21 drochner ntv32.tai = (netbsd32_long)ntv.tai;
74 1.21 drochner ntv32.time_state = ntv.time_state;
75 1.27 dsl error = copyout(&ntv32, SCARG_P32(uap, ntvp), sizeof(ntv32));
76 1.1 mrg }
77 1.1 mrg if (!error) {
78 1.21 drochner *retval = ntp_timestatus();
79 1.21 drochner }
80 1.1 mrg
81 1.21 drochner return (error);
82 1.21 drochner }
83 1.1 mrg
84 1.35 christos #ifdef COMPAT_50
85 1.35 christos int
86 1.35 christos compat_50_netbsd32_ntp_gettime(struct lwp *l,
87 1.35 christos const struct compat_50_netbsd32_ntp_gettime_args *uap, register_t *retval)
88 1.35 christos {
89 1.35 christos /* {
90 1.35 christos syscallarg(netbsd32_ntptimeval50p_t) ntvp;
91 1.35 christos } */
92 1.35 christos struct netbsd32_ntptimeval50 ntv32;
93 1.35 christos struct ntptimeval ntv;
94 1.35 christos int error = 0;
95 1.35 christos
96 1.35 christos if (SCARG_P32(uap, ntvp)) {
97 1.35 christos ntp_gettime(&ntv);
98 1.35 christos
99 1.35 christos ntv32.time.tv_sec = (int32_t)ntv.time.tv_sec;
100 1.35 christos ntv32.time.tv_nsec = ntv.time.tv_nsec;
101 1.35 christos ntv32.maxerror = (netbsd32_long)ntv.maxerror;
102 1.35 christos ntv32.esterror = (netbsd32_long)ntv.esterror;
103 1.35 christos ntv32.tai = (netbsd32_long)ntv.tai;
104 1.35 christos ntv32.time_state = ntv.time_state;
105 1.35 christos error = copyout(&ntv32, SCARG_P32(uap, ntvp), sizeof(ntv32));
106 1.35 christos }
107 1.35 christos if (!error) {
108 1.35 christos *retval = ntp_timestatus();
109 1.35 christos }
110 1.35 christos
111 1.35 christos return (error);
112 1.35 christos }
113 1.35 christos #endif
114 1.35 christos
115 1.21 drochner #ifdef COMPAT_30
116 1.21 drochner int
117 1.30 dsl compat_30_netbsd32_ntp_gettime(struct lwp *l, const struct compat_30_netbsd32_ntp_gettime_args *uap, register_t *retval)
118 1.21 drochner {
119 1.30 dsl /* {
120 1.21 drochner syscallarg(netbsd32_ntptimevalp_t) ntvp;
121 1.30 dsl } */
122 1.21 drochner struct netbsd32_ntptimeval30 ntv32;
123 1.21 drochner struct ntptimeval ntv;
124 1.21 drochner int error = 0;
125 1.1 mrg
126 1.27 dsl if (SCARG_P32(uap, ntvp)) {
127 1.21 drochner ntp_gettime(&ntv);
128 1.1 mrg
129 1.21 drochner ntv32.time.tv_sec = ntv.time.tv_sec;
130 1.21 drochner ntv32.time.tv_usec = ntv.time.tv_nsec / 1000;
131 1.21 drochner ntv32.maxerror = (netbsd32_long)ntv.maxerror;
132 1.21 drochner ntv32.esterror = (netbsd32_long)ntv.esterror;
133 1.27 dsl error = copyout(&ntv32, SCARG_P32(uap, ntvp), sizeof(ntv32));
134 1.21 drochner }
135 1.21 drochner if (!error) {
136 1.21 drochner *retval = ntp_timestatus();
137 1.1 mrg }
138 1.21 drochner
139 1.1 mrg return (error);
140 1.1 mrg }
141 1.21 drochner #endif
142 1.1 mrg
143 1.1 mrg int
144 1.30 dsl netbsd32_ntp_adjtime(struct lwp *l, const struct netbsd32_ntp_adjtime_args *uap, register_t *retval)
145 1.1 mrg {
146 1.30 dsl /* {
147 1.1 mrg syscallarg(netbsd32_timexp_t) tp;
148 1.30 dsl } */
149 1.1 mrg struct netbsd32_timex ntv32;
150 1.1 mrg struct timex ntv;
151 1.1 mrg int error = 0;
152 1.1 mrg int modes;
153 1.1 mrg
154 1.27 dsl if ((error = copyin(SCARG_P32(uap, tp), &ntv32, sizeof(ntv32))))
155 1.1 mrg return (error);
156 1.22 kardel
157 1.1 mrg netbsd32_to_timex(&ntv32, &ntv);
158 1.1 mrg
159 1.1 mrg /*
160 1.1 mrg * Update selected clock variables - only the superuser can
161 1.1 mrg * change anything. Note that there is no error checking here on
162 1.1 mrg * the assumption the superuser should know what it is doing.
163 1.1 mrg */
164 1.1 mrg modes = ntv.modes;
165 1.24 elad if (modes != 0 && (error = kauth_authorize_system(l->l_cred,
166 1.24 elad KAUTH_SYSTEM_TIME, KAUTH_REQ_SYSTEM_TIME_NTPADJTIME, NULL, NULL,
167 1.24 elad NULL)))
168 1.1 mrg return (error);
169 1.1 mrg
170 1.22 kardel ntp_adjtime1(&ntv);
171 1.1 mrg
172 1.1 mrg netbsd32_from_timex(&ntv, &ntv32);
173 1.27 dsl error = copyout(&ntv32, SCARG_P32(uap, tp), sizeof(ntv32));
174 1.1 mrg if (!error) {
175 1.22 kardel *retval = ntp_timestatus();
176 1.1 mrg }
177 1.1 mrg return error;
178 1.1 mrg }
179 1.21 drochner #endif /* NTP */
180 1.1 mrg
181 1.1 mrg int
182 1.35 christos netbsd32___setitimer50(struct lwp *l, const struct netbsd32___setitimer50_args *uap, register_t *retval)
183 1.1 mrg {
184 1.30 dsl /* {
185 1.1 mrg syscallarg(int) which;
186 1.1 mrg syscallarg(const netbsd32_itimervalp_t) itv;
187 1.1 mrg syscallarg(netbsd32_itimervalp_t) oitv;
188 1.30 dsl } */
189 1.5 thorpej struct proc *p = l->l_proc;
190 1.10 cube struct netbsd32_itimerval s32it, *itv32;
191 1.1 mrg int which = SCARG(uap, which);
192 1.35 christos struct netbsd32___getitimer50_args getargs;
193 1.1 mrg struct itimerval aitv;
194 1.10 cube int error;
195 1.1 mrg
196 1.1 mrg if ((u_int)which > ITIMER_PROF)
197 1.1 mrg return (EINVAL);
198 1.27 dsl itv32 = SCARG_P32(uap, itv);
199 1.10 cube if (itv32) {
200 1.10 cube if ((error = copyin(itv32, &s32it, sizeof(s32it))))
201 1.10 cube return (error);
202 1.10 cube netbsd32_to_itimerval(&s32it, &aitv);
203 1.10 cube }
204 1.26 dsl if (SCARG_P32(uap, oitv) != 0) {
205 1.1 mrg SCARG(&getargs, which) = which;
206 1.1 mrg SCARG(&getargs, itv) = SCARG(uap, oitv);
207 1.35 christos if ((error = netbsd32___getitimer50(l, &getargs, retval)) != 0)
208 1.1 mrg return (error);
209 1.1 mrg }
210 1.10 cube if (itv32 == 0)
211 1.10 cube return 0;
212 1.5 thorpej
213 1.10 cube return dosetitimer(p, which, &aitv);
214 1.1 mrg }
215 1.1 mrg
216 1.1 mrg int
217 1.35 christos netbsd32___getitimer50(struct lwp *l, const struct netbsd32___getitimer50_args *uap, register_t *retval)
218 1.1 mrg {
219 1.30 dsl /* {
220 1.1 mrg syscallarg(int) which;
221 1.1 mrg syscallarg(netbsd32_itimervalp_t) itv;
222 1.30 dsl } */
223 1.5 thorpej struct proc *p = l->l_proc;
224 1.1 mrg struct netbsd32_itimerval s32it;
225 1.1 mrg struct itimerval aitv;
226 1.10 cube int error;
227 1.1 mrg
228 1.10 cube error = dogetitimer(p, SCARG(uap, which), &aitv);
229 1.10 cube if (error)
230 1.10 cube return error;
231 1.5 thorpej
232 1.1 mrg netbsd32_from_itimerval(&aitv, &s32it);
233 1.27 dsl return copyout(&s32it, SCARG_P32(uap, itv), sizeof(s32it));
234 1.1 mrg }
235 1.1 mrg
236 1.1 mrg int
237 1.35 christos netbsd32___gettimeofday50(struct lwp *l, const struct netbsd32___gettimeofday50_args *uap, register_t *retval)
238 1.1 mrg {
239 1.30 dsl /* {
240 1.1 mrg syscallarg(netbsd32_timevalp_t) tp;
241 1.1 mrg syscallarg(netbsd32_timezonep_t) tzp;
242 1.30 dsl } */
243 1.1 mrg struct timeval atv;
244 1.1 mrg struct netbsd32_timeval tv32;
245 1.1 mrg int error = 0;
246 1.1 mrg struct netbsd32_timezone tzfake;
247 1.1 mrg
248 1.26 dsl if (SCARG_P32(uap, tp)) {
249 1.1 mrg microtime(&atv);
250 1.1 mrg netbsd32_from_timeval(&atv, &tv32);
251 1.27 dsl error = copyout(&tv32, SCARG_P32(uap, tp), sizeof(tv32));
252 1.1 mrg if (error)
253 1.1 mrg return (error);
254 1.1 mrg }
255 1.26 dsl if (SCARG_P32(uap, tzp)) {
256 1.1 mrg /*
257 1.1 mrg * NetBSD has no kernel notion of time zone, so we just
258 1.1 mrg * fake up a timezone struct and return it if demanded.
259 1.1 mrg */
260 1.1 mrg tzfake.tz_minuteswest = 0;
261 1.1 mrg tzfake.tz_dsttime = 0;
262 1.27 dsl error = copyout(&tzfake, SCARG_P32(uap, tzp), sizeof(tzfake));
263 1.1 mrg }
264 1.1 mrg return (error);
265 1.1 mrg }
266 1.1 mrg
267 1.1 mrg int
268 1.35 christos netbsd32___settimeofday50(struct lwp *l, const struct netbsd32___settimeofday50_args *uap, register_t *retval)
269 1.1 mrg {
270 1.30 dsl /* {
271 1.1 mrg syscallarg(const netbsd32_timevalp_t) tv;
272 1.1 mrg syscallarg(const netbsd32_timezonep_t) tzp;
273 1.30 dsl } */
274 1.1 mrg struct netbsd32_timeval atv32;
275 1.1 mrg struct timeval atv;
276 1.16 christos struct timespec ats;
277 1.1 mrg int error;
278 1.5 thorpej struct proc *p = l->l_proc;
279 1.1 mrg
280 1.16 christos /* Verify all parameters before changing time. */
281 1.16 christos
282 1.1 mrg /*
283 1.1 mrg * NetBSD has no kernel notion of time zone, and only an
284 1.1 mrg * obsolete program would try to set it, so we log a warning.
285 1.1 mrg */
286 1.26 dsl if (SCARG_P32(uap, tzp))
287 1.1 mrg printf("pid %d attempted to set the "
288 1.8 perry "(obsolete) kernel time zone\n", p->p_pid);
289 1.16 christos
290 1.26 dsl if (SCARG_P32(uap, tv) == 0)
291 1.16 christos return 0;
292 1.16 christos
293 1.27 dsl if ((error = copyin(SCARG_P32(uap, tv), &atv32, sizeof(atv32))) != 0)
294 1.16 christos return error;
295 1.16 christos
296 1.16 christos netbsd32_to_timeval(&atv32, &atv);
297 1.16 christos TIMEVAL_TO_TIMESPEC(&atv, &ats);
298 1.16 christos return settime(p, &ats);
299 1.1 mrg }
300 1.1 mrg
301 1.1 mrg int
302 1.35 christos netbsd32___adjtime50(struct lwp *l, const struct netbsd32___adjtime50_args *uap, register_t *retval)
303 1.1 mrg {
304 1.30 dsl /* {
305 1.1 mrg syscallarg(const netbsd32_timevalp_t) delta;
306 1.1 mrg syscallarg(netbsd32_timevalp_t) olddelta;
307 1.30 dsl } */
308 1.1 mrg struct netbsd32_timeval atv;
309 1.22 kardel int error;
310 1.1 mrg
311 1.32 joerg extern int time_adjusted; /* in kern_ntptime.c */
312 1.32 joerg extern int64_t time_adjtime; /* in kern_ntptime.c */
313 1.32 joerg
314 1.24 elad if ((error = kauth_authorize_system(l->l_cred,
315 1.24 elad KAUTH_SYSTEM_TIME, KAUTH_REQ_SYSTEM_TIME_ADJTIME, NULL, NULL,
316 1.24 elad NULL)) != 0)
317 1.1 mrg return (error);
318 1.23 ad
319 1.32 joerg if (SCARG_P32(uap, olddelta)) {
320 1.32 joerg atv.tv_sec = time_adjtime / 1000000;
321 1.32 joerg atv.tv_usec = time_adjtime % 1000000;
322 1.32 joerg if (atv.tv_usec < 0) {
323 1.32 joerg atv.tv_usec += 1000000;
324 1.32 joerg atv.tv_sec--;
325 1.22 kardel }
326 1.32 joerg (void) copyout(&atv,
327 1.32 joerg SCARG_P32(uap, olddelta),
328 1.32 joerg sizeof(atv));
329 1.32 joerg if (error)
330 1.32 joerg return (error);
331 1.32 joerg }
332 1.22 kardel
333 1.32 joerg if (SCARG_P32(uap, delta)) {
334 1.27 dsl error = copyin(SCARG_P32(uap, delta), &atv,
335 1.22 kardel sizeof(struct timeval));
336 1.22 kardel if (error)
337 1.22 kardel return (error);
338 1.1 mrg
339 1.32 joerg time_adjtime = (int64_t)atv.tv_sec * 1000000 + atv.tv_usec;
340 1.32 joerg
341 1.32 joerg if (time_adjtime)
342 1.32 joerg /* We need to save the system time during shutdown */
343 1.32 joerg time_adjusted |= 1;
344 1.1 mrg }
345 1.32 joerg
346 1.1 mrg return (0);
347 1.1 mrg }
348 1.1 mrg
349 1.1 mrg int
350 1.35 christos netbsd32___clock_gettime50(struct lwp *l, const struct netbsd32___clock_gettime50_args *uap, register_t *retval)
351 1.1 mrg {
352 1.30 dsl /* {
353 1.1 mrg syscallarg(netbsd32_clockid_t) clock_id;
354 1.1 mrg syscallarg(netbsd32_timespecp_t) tp;
355 1.30 dsl } */
356 1.36.4.1 rmind int error;
357 1.1 mrg struct timespec ats;
358 1.1 mrg struct netbsd32_timespec ts32;
359 1.1 mrg
360 1.36.4.1 rmind error = clock_gettime1(SCARG(uap, clock_id), &ats);
361 1.36.4.1 rmind if (error != 0)
362 1.36.4.1 rmind return error;
363 1.1 mrg
364 1.1 mrg netbsd32_from_timespec(&ats, &ts32);
365 1.27 dsl return copyout(&ts32, SCARG_P32(uap, tp), sizeof(ts32));
366 1.1 mrg }
367 1.1 mrg
368 1.1 mrg int
369 1.35 christos netbsd32___clock_settime50(struct lwp *l, const struct netbsd32___clock_settime50_args *uap, register_t *retval)
370 1.1 mrg {
371 1.30 dsl /* {
372 1.1 mrg syscallarg(netbsd32_clockid_t) clock_id;
373 1.1 mrg syscallarg(const netbsd32_timespecp_t) tp;
374 1.30 dsl } */
375 1.1 mrg struct netbsd32_timespec ts32;
376 1.1 mrg struct timespec ats;
377 1.1 mrg int error;
378 1.1 mrg
379 1.27 dsl if ((error = copyin(SCARG_P32(uap, tp), &ts32, sizeof(ts32))) != 0)
380 1.1 mrg return (error);
381 1.1 mrg
382 1.1 mrg netbsd32_to_timespec(&ts32, &ats);
383 1.36.4.1 rmind return clock_settime1(l->l_proc, SCARG(uap, clock_id), &ats, true);
384 1.1 mrg }
385 1.1 mrg
386 1.1 mrg int
387 1.35 christos netbsd32___clock_getres50(struct lwp *l, const struct netbsd32___clock_getres50_args *uap, register_t *retval)
388 1.1 mrg {
389 1.30 dsl /* {
390 1.1 mrg syscallarg(netbsd32_clockid_t) clock_id;
391 1.1 mrg syscallarg(netbsd32_timespecp_t) tp;
392 1.30 dsl } */
393 1.1 mrg struct netbsd32_timespec ts32;
394 1.1 mrg struct timespec ts;
395 1.1 mrg int error = 0;
396 1.1 mrg
397 1.36.4.1 rmind error = clock_getres1(SCARG(uap, clock_id), &ts);
398 1.36.4.1 rmind if (error != 0)
399 1.36.4.1 rmind return error;
400 1.1 mrg
401 1.26 dsl if (SCARG_P32(uap, tp)) {
402 1.1 mrg netbsd32_from_timespec(&ts, &ts32);
403 1.36.4.1 rmind error = copyout(&ts32, SCARG_P32(uap, tp), sizeof(ts32));
404 1.1 mrg }
405 1.1 mrg
406 1.1 mrg return error;
407 1.1 mrg }
408 1.1 mrg
409 1.1 mrg int
410 1.35 christos netbsd32___nanosleep50(struct lwp *l, const struct netbsd32___nanosleep50_args *uap, register_t *retval)
411 1.1 mrg {
412 1.30 dsl /* {
413 1.1 mrg syscallarg(const netbsd32_timespecp_t) rqtp;
414 1.1 mrg syscallarg(netbsd32_timespecp_t) rmtp;
415 1.30 dsl } */
416 1.1 mrg struct netbsd32_timespec ts32;
417 1.36.4.1 rmind struct timespec rqt, rmt;
418 1.36.4.1 rmind int error, error1;
419 1.1 mrg
420 1.27 dsl error = copyin(SCARG_P32(uap, rqtp), &ts32, sizeof(ts32));
421 1.1 mrg if (error)
422 1.1 mrg return (error);
423 1.1 mrg netbsd32_to_timespec(&ts32, &rqt);
424 1.1 mrg
425 1.36.4.1 rmind error = nanosleep1(l, &rqt, SCARG_P32(uap, rmtp) ? &rmt : NULL);
426 1.36.4.1 rmind if (SCARG_P32(uap, rmtp) == NULL || (error != 0 && error != EINTR))
427 1.36.4.1 rmind return error;
428 1.1 mrg
429 1.36.4.1 rmind netbsd32_from_timespec(&rmt, &ts32);
430 1.36.4.1 rmind error1 = copyout(&ts32, SCARG_P32(uap,rmtp), sizeof(ts32));
431 1.36.4.1 rmind return error1 ? error1 : error;
432 1.1 mrg }
433 1.11 cube
434 1.11 cube static int
435 1.11 cube netbsd32_timer_create_fetch(const void *src, void *dst, size_t size)
436 1.11 cube {
437 1.11 cube struct sigevent *evp = dst;
438 1.11 cube struct netbsd32_sigevent ev32;
439 1.11 cube int error;
440 1.11 cube
441 1.11 cube error = copyin(src, &ev32, sizeof(ev32));
442 1.11 cube if (error)
443 1.11 cube return error;
444 1.11 cube
445 1.11 cube netbsd32_to_sigevent(&ev32, evp);
446 1.11 cube return 0;
447 1.11 cube }
448 1.11 cube
449 1.11 cube int
450 1.30 dsl netbsd32_timer_create(struct lwp *l, const struct netbsd32_timer_create_args *uap, register_t *retval)
451 1.11 cube {
452 1.30 dsl /* {
453 1.11 cube syscallarg(netbsd32_clockid_t) clock_id;
454 1.11 cube syscallarg(netbsd32_sigeventp_t) evp;
455 1.11 cube syscallarg(netbsd32_timerp_t) timerid;
456 1.30 dsl } */
457 1.11 cube
458 1.27 dsl return timer_create1(SCARG_P32(uap, timerid),
459 1.27 dsl SCARG(uap, clock_id), SCARG_P32(uap, evp),
460 1.23 ad netbsd32_timer_create_fetch, l);
461 1.11 cube }
462 1.11 cube
463 1.11 cube int
464 1.30 dsl netbsd32_timer_delete(struct lwp *l, const struct netbsd32_timer_delete_args *uap, register_t *retval)
465 1.11 cube {
466 1.30 dsl /* {
467 1.11 cube syscallarg(netbsd32_timer_t) timerid;
468 1.30 dsl } */
469 1.11 cube struct sys_timer_delete_args ua;
470 1.11 cube
471 1.11 cube NETBSD32TO64_UAP(timerid);
472 1.11 cube return sys_timer_delete(l, (void *)&ua, retval);
473 1.11 cube }
474 1.11 cube
475 1.11 cube int
476 1.35 christos netbsd32___timer_settime50(struct lwp *l, const struct netbsd32___timer_settime50_args *uap, register_t *retval)
477 1.11 cube {
478 1.30 dsl /* {
479 1.11 cube syscallarg(netbsd32_timer_t) timerid;
480 1.11 cube syscallarg(int) flags;
481 1.11 cube syscallarg(const netbsd32_itimerspecp_t) value;
482 1.11 cube syscallarg(netbsd32_itimerspecp_t) ovalue;
483 1.30 dsl } */
484 1.11 cube int error;
485 1.11 cube struct itimerspec value, ovalue, *ovp = NULL;
486 1.11 cube struct netbsd32_itimerspec its32;
487 1.11 cube
488 1.27 dsl if ((error = copyin(SCARG_P32(uap, value), &its32, sizeof(its32))) != 0)
489 1.11 cube return (error);
490 1.11 cube netbsd32_to_timespec(&its32.it_interval, &value.it_interval);
491 1.11 cube netbsd32_to_timespec(&its32.it_value, &value.it_value);
492 1.11 cube
493 1.26 dsl if (SCARG_P32(uap, ovalue))
494 1.11 cube ovp = &ovalue;
495 1.11 cube
496 1.11 cube if ((error = dotimer_settime(SCARG(uap, timerid), &value, ovp,
497 1.11 cube SCARG(uap, flags), l->l_proc)) != 0)
498 1.11 cube return error;
499 1.11 cube
500 1.11 cube if (ovp) {
501 1.11 cube netbsd32_from_timespec(&ovp->it_interval, &its32.it_interval);
502 1.11 cube netbsd32_from_timespec(&ovp->it_value, &its32.it_value);
503 1.27 dsl return copyout(&its32, SCARG_P32(uap, ovalue), sizeof(its32));
504 1.11 cube }
505 1.11 cube return 0;
506 1.11 cube }
507 1.11 cube
508 1.11 cube int
509 1.35 christos netbsd32___timer_gettime50(struct lwp *l, const struct netbsd32___timer_gettime50_args *uap, register_t *retval)
510 1.11 cube {
511 1.30 dsl /* {
512 1.11 cube syscallarg(netbsd32_timer_t) timerid;
513 1.11 cube syscallarg(netbsd32_itimerspecp_t) value;
514 1.30 dsl } */
515 1.11 cube int error;
516 1.11 cube struct itimerspec its;
517 1.11 cube struct netbsd32_itimerspec its32;
518 1.11 cube
519 1.11 cube if ((error = dotimer_gettime(SCARG(uap, timerid), l->l_proc,
520 1.11 cube &its)) != 0)
521 1.11 cube return error;
522 1.11 cube
523 1.11 cube netbsd32_from_timespec(&its.it_interval, &its32.it_interval);
524 1.11 cube netbsd32_from_timespec(&its.it_value, &its32.it_value);
525 1.11 cube
526 1.27 dsl return copyout(&its32, SCARG_P32(uap, value), sizeof(its32));
527 1.11 cube }
528 1.11 cube
529 1.11 cube int
530 1.30 dsl netbsd32_timer_getoverrun(struct lwp *l, const struct netbsd32_timer_getoverrun_args *uap, register_t *retval)
531 1.11 cube {
532 1.30 dsl /* {
533 1.11 cube syscallarg(netbsd32_timer_t) timerid;
534 1.30 dsl } */
535 1.11 cube struct sys_timer_getoverrun_args ua;
536 1.11 cube
537 1.11 cube NETBSD32TO64_UAP(timerid);
538 1.11 cube return sys_timer_getoverrun(l, (void *)&ua, retval);
539 1.11 cube }
540