2 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #include <linux/version.h>
36 #include <sys/timex.h>
37 #include <linux/ioctl.h>
38 #include <linux/rtc.h>
50 else if (!verbose(tcp))
51 tprintf("%#lx", addr);
52 else if (umove(tcp, addr, &tv) < 0)
55 tprintf("{%lu, %lu}", (long) tv.tv_sec, (long) tv.tv_usec);
74 else if (!verbose(tcp))
75 tprintf("%#lx", addr);
76 else if (umove(tcp, addr, &tv) < 0)
79 tprintf("{%u, %u}", tv.tv_sec, tv.tv_usec);
90 printnum(tcp, tcp->u_arg[0], "%ld");
101 printnum(tcp, tcp->u_arg[0], "%ld");
107 sys_gettimeofday(tcp)
112 tprintf("%#lx, %#lx",
113 tcp->u_arg[0], tcp->u_arg[1]);
116 printtv(tcp, tcp->u_arg[0]);
119 printtv(tcp, tcp->u_arg[1]);
128 sys_osf_gettimeofday(tcp)
133 tprintf("%#lx, %#lx",
134 tcp->u_arg[0], tcp->u_arg[1]);
137 printtv32(tcp, tcp->u_arg[0]);
140 printtv32(tcp, tcp->u_arg[1]);
148 sys_settimeofday(tcp)
152 printtv(tcp, tcp->u_arg[0]);
155 printtv(tcp, tcp->u_arg[1]);
163 sys_osf_settimeofday(tcp)
167 printtv32(tcp, tcp->u_arg[0]);
170 printtv32(tcp, tcp->u_arg[1]);
182 printtv(tcp, tcp->u_arg[0]);
186 tprintf("%#lx", tcp->u_arg[1]);
188 printtv(tcp, tcp->u_arg[1]);
193 static const struct xlat which[] = {
194 { ITIMER_REAL, "ITIMER_REAL" },
195 { ITIMER_VIRTUAL,"ITIMER_VIRTUAL"},
196 { ITIMER_PROF, "ITIMER_PROF" },
205 struct itimerval itv;
209 else if (!verbose(tcp))
210 tprintf("%#lx", addr);
211 else if (umove(tcp, addr, &itv) < 0)
214 tprintf("{it_interval={%lu, %lu}, it_value={%lu, %lu}}",
215 (long) itv.it_interval.tv_sec, (long) itv.it_interval.tv_usec,
216 (long) itv.it_value.tv_sec, (long) itv.it_value.tv_usec);
223 printitv32(tcp, addr)
229 struct timeval32 it_interval;
230 struct timeval32 it_value;
235 else if (!verbose(tcp))
236 tprintf("%#lx", addr);
237 else if (umove(tcp, addr, &itv) < 0)
240 tprintf("{it_interval={%u, %u}, it_value={%u, %u}}",
241 itv.it_interval.tv_sec, itv.it_interval.tv_usec,
242 itv.it_value.tv_sec, itv.it_value.tv_usec);
252 printxval(which, tcp->u_arg[0], "ITIMER_???");
256 tprintf("%#lx", tcp->u_arg[1]);
258 printitv(tcp, tcp->u_arg[1]);
266 sys_osf_getitimer(tcp)
270 printxval(which, tcp->u_arg[0], "ITIMER_???");
274 tprintf("%#lx", tcp->u_arg[1]);
276 printitv32(tcp, tcp->u_arg[1]);
287 printxval(which, tcp->u_arg[0], "ITIMER_???");
289 printitv(tcp, tcp->u_arg[1]);
293 tprintf("%#lx", tcp->u_arg[2]);
295 printitv(tcp, tcp->u_arg[2]);
302 sys_osf_setitimer(tcp)
306 printxval(which, tcp->u_arg[0], "ITIMER_???");
308 printitv32(tcp, tcp->u_arg[1]);
312 tprintf("%#lx", tcp->u_arg[2]);
314 printitv32(tcp, tcp->u_arg[2]);
329 if (tcp->u_arg[0] == 0)
331 else if (syserror(tcp) || !verbose(tcp))
332 tprintf("%#lx", tcp->u_arg[0]);
333 else if (umove(tcp, tcp->u_arg[0], &txc) < 0)
336 #if LINUX_VERSION_CODE < 66332
337 tprintf("{mode=%d, offset=%ld, frequency=%ld, ",
338 txc.mode, txc.offset, txc.frequency);
339 tprintf("maxerror=%ld, esterror=%lu, status=%u, ",
340 txc.maxerror, txc.esterror, txc.status);
341 tprintf("time_constant=%ld, precision=%lu, ",
342 txc.time_constant, txc.precision);
343 tprintf("tolerance=%ld, time={%lu, %lu}}",
344 txc.tolerance, (long) txc.time.tv_sec,
345 (long) txc.time.tv_usec);
347 tprintf("{modes=%d, offset=%ld, freq=%ld, ",
348 txc.modes, txc.offset, txc.freq);
349 tprintf("maxerror=%ld, esterror=%lu, status=%u, ",
350 txc.maxerror, txc.esterror, txc.status);
351 tprintf("constant=%ld, precision=%lu, ",
352 txc.constant, txc.precision);
353 tprintf("tolerance=%ld, time={%lu, %lu}}",
354 txc.tolerance, (long) txc.time.tv_sec,
355 (long) txc.time.tv_usec);
356 /* there's a bunch of other stuff, but it's not
357 * worth the time or the trouble to include */
364 static const struct xlat clockflags[] = {
365 { TIMER_ABSTIME, "TIMER_ABSTIME" },
369 static const struct xlat clocknames[] = {
370 #ifdef CLOCK_REALTIME
371 { CLOCK_REALTIME, "CLOCK_REALTIME" },
373 #ifdef CLOCK_MONOTONIC
374 { CLOCK_MONOTONIC, "CLOCK_MONOTONIC" },
380 sys_clock_settime(tcp)
384 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
386 printtv(tcp, tcp->u_arg[1]);
392 sys_clock_gettime(tcp)
396 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
400 tprintf("%#lx", tcp->u_arg[1]);
402 printtv(tcp, tcp->u_arg[1]);
408 sys_clock_nanosleep(tcp)
412 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
414 printflags(clockflags, tcp->u_arg[1], "TIMER_???");
416 printtv(tcp, tcp->u_arg[2]);
420 tprintf("%#lx", tcp->u_arg[3]);
422 printtv(tcp, tcp->u_arg[3]);
427 #ifndef SIGEV_THREAD_ID
428 # define SIGEV_THREAD_ID 4
430 static const struct xlat sigev_value[] = {
431 { SIGEV_SIGNAL+1, "SIGEV_SIGNAL" },
432 { SIGEV_NONE+1, "SIGEV_NONE" },
433 { SIGEV_THREAD+1, "SIGEV_THREAD" },
434 { SIGEV_THREAD_ID+1, "SIGEV_THREAD_ID" },
439 printsigevent(tcp, arg)
444 if (umove (tcp, arg, &sev) < 0)
447 tprintf("{%p, ", sev.sigev_value.sival_ptr);
448 if (sev.sigev_notify == SIGEV_SIGNAL)
449 tprintf("%s, ", signame(sev.sigev_signo));
451 tprintf("%u, ", sev.sigev_signo);
452 printxval(sigev_value, sev.sigev_notify+1, "SIGEV_???");
454 if (sev.sigev_notify == SIGEV_THREAD_ID)
455 /* _pad[0] is the _tid field which might not be
456 present in the userlevel definition of the
458 tprintf("{%d}", sev._sigev_un._pad[0]);
459 else if (sev.sigev_notify == SIGEV_THREAD)
460 tprintf("{%p, %p}", sev.sigev_notify_function,
461 sev.sigev_notify_attributes);
469 sys_timer_create(tcp)
473 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
475 printsigevent(tcp, tcp->u_arg[1]);
479 tprintf("%#lx", tcp->u_arg[2]);
482 umove(tcp, tcp->u_arg[2], &p);
490 sys_timer_settime(tcp)
494 tprintf("%#lx, ", tcp->u_arg[0]);
495 printflags(clockflags, tcp->u_arg[1], "TIMER_???");
497 printitv(tcp, tcp->u_arg[2]);
501 tprintf("%#lx", tcp->u_arg[3]);
503 printitv(tcp, tcp->u_arg[3]);
509 sys_timer_gettime(tcp)
513 tprintf("%#lx, ", tcp->u_arg[0]);
516 tprintf("%#lx", tcp->u_arg[1]);
518 printitv(tcp, tcp->u_arg[1]);
526 const struct rtc_time *rt;
528 tprintf("{tm_sec=%d, tm_min=%d, tm_hour=%d, "
529 "tm_mday=%d, tm_mon=%d, tm_year=%d, ",
530 rt->tm_sec, rt->tm_min, rt->tm_hour,
531 rt->tm_mday, rt->tm_mon, rt->tm_year);
533 tprintf("tm_wday=%d, tm_yday=%d, tm_isdst=%d}",
534 rt->tm_wday, rt->tm_yday, rt->tm_isdst);
540 rtc_ioctl(tcp, code, arg)
550 if (umove(tcp, arg, &rt) < 0)
551 tprintf(", %#lx", arg);
562 if (syserror(tcp) || umove(tcp, arg, &rt) < 0)
563 tprintf(", %#lx", arg);
573 tprintf(", %lu", arg);
578 tprintf(", %lu", arg);
582 struct rtc_wkalrm wk;
583 if (umove(tcp, arg, &wk) < 0)
584 tprintf(", %#lx", arg);
586 tprintf(", {enabled=%d, pending=%d, ",
587 wk.enabled, wk.pending);
588 print_rtc(tcp, &wk.time);
595 struct rtc_wkalrm wk;
596 if (syserror(tcp) || umove(tcp, arg, &wk) < 0)
597 tprintf(", %#lx", arg);
599 tprintf(", {enabled=%d, pending=%d, ",
600 wk.enabled, wk.pending);
601 print_rtc(tcp, &wk.time);
608 tprintf(", %#lx", arg);