3 #include <linux/ptp_clock.h>
5 #include "xlat/ptp_flags_options.h"
7 int ptp_ioctl(struct tcb *tcp, long code, long arg)
13 case PTP_CLOCK_GETCAPS: /* decode on exit */
15 struct ptp_clock_caps caps;
17 if (entering(tcp) || syserror(tcp) ||
18 umove(tcp, arg, &caps) < 0)
21 tprintf(", {max_adj=%d, n_alarm=%d, n_ext_ts=%d, n_per_out=%d, pps=%d}",
22 caps.max_adj, caps.n_alarm, caps.n_ext_ts,
23 caps.n_per_out, caps.pps);
27 case PTP_EXTTS_REQUEST: /* decode on enter */
29 struct ptp_extts_request extts;
33 if (umove(tcp, arg, &extts) < 0) {
34 tprintf(", %#lx", arg);
37 tprintf(", {index=%d, flags=", extts.index);
38 printflags(ptp_flags_options, extts.flags, "PTP_???");
43 case PTP_PEROUT_REQUEST: /* decode on enter */
45 struct ptp_perout_request perout;
49 if (umove(tcp, arg, &perout) < 0) {
50 tprintf(", %#lx", arg);
54 tprintf(", {start={%" PRId64 ", %" PRIu32 "}"
55 ", period={%" PRId64 ", %" PRIu32 "}"
57 (int64_t)perout.start.sec, perout.start.nsec,
58 (int64_t)perout.period.sec, perout.period.nsec,
60 printflags(ptp_flags_options, perout.flags, "PTP_???");
65 case PTP_ENABLE_PPS: /* decode on enter */
67 tprintf(", %ld", arg);
70 case PTP_SYS_OFFSET: /* decode on exit */
72 struct ptp_sys_offset sysoff;
75 if (entering(tcp) || umove(tcp, arg, &sysoff) < 0)
78 tprintf(", {n_samples=%u, ts={", sysoff.n_samples);
83 if (sysoff.n_samples > PTP_MAX_SAMPLES)
84 sysoff.n_samples = PTP_MAX_SAMPLES;
85 tprintf("{%" PRId64 ", %" PRIu32 "}",
86 (int64_t)sysoff.ts[0].sec, sysoff.ts[0].nsec);
87 for (i = 1; i < 2*sysoff.n_samples+1; ++i)
88 tprintf(", {%" PRId64 ", %" PRIu32 "}",
89 (int64_t)sysoff.ts[i].sec, sysoff.ts[i].nsec);
94 default: /* decode on exit */