3 #include <linux/ptp_clock.h>
5 static const struct xlat ptp_flags_options[] = {
6 XLAT(PTP_ENABLE_FEATURE),
8 XLAT(PTP_FALLING_EDGE),
13 int ptp_ioctl(struct tcb *tcp, long code, long arg)
19 case PTP_CLOCK_GETCAPS: /* decode on exit */
21 struct ptp_clock_caps caps;
23 if (entering(tcp) || syserror(tcp) ||
24 umove(tcp, arg, &caps) < 0)
27 tprintf(", {max_adj=%d, n_alarm=%d, n_ext_ts=%d, n_per_out=%d, pps=%d}",
28 caps.max_adj, caps.n_alarm, caps.n_ext_ts,
29 caps.n_per_out, caps.pps);
33 case PTP_EXTTS_REQUEST: /* decode on enter */
35 struct ptp_extts_request extts;
39 if (umove(tcp, arg, &extts) < 0) {
40 tprintf(", %#lx", arg);
43 tprintf(", {index=%d, flags=", extts.index);
44 printflags(ptp_flags_options, extts.flags, "PTP_???");
49 case PTP_PEROUT_REQUEST: /* decode on enter */
51 struct ptp_perout_request perout;
55 if (umove(tcp, arg, &perout) < 0) {
56 tprintf(", %#lx", arg);
60 tprintf(", {start={%" PRId64 ", %" PRIu32 "}"
61 ", period={%" PRId64 ", %" PRIu32 "}"
63 (int64_t)perout.start.sec, perout.start.nsec,
64 (int64_t)perout.period.sec, perout.period.nsec,
66 printflags(ptp_flags_options, perout.flags, "PTP_???");
71 case PTP_ENABLE_PPS: /* decode on enter */
73 tprintf(", %ld", arg);
76 case PTP_SYS_OFFSET: /* decode on exit */
78 struct ptp_sys_offset sysoff;
81 if (entering(tcp) || umove(tcp, arg, &sysoff) < 0)
84 tprintf(", {n_samples=%u, ts={", sysoff.n_samples);
89 if (sysoff.n_samples > PTP_MAX_SAMPLES)
90 sysoff.n_samples = PTP_MAX_SAMPLES;
91 tprintf("{%" PRId64 ", %" PRIu32 "}",
92 (int64_t)sysoff.ts[0].sec, sysoff.ts[0].nsec);
93 for (i = 1; i < 2*sysoff.n_samples+1; ++i)
94 tprintf(", {%" PRId64 ", %" PRIu32 "}",
95 (int64_t)sysoff.ts[i].sec, sysoff.ts[i].nsec);
100 default: /* decode on exit */