/* * refclock_params - set ppsapi parameters * * This routine is called to set the PPSAPI parameters after the fudge * command. */ int refclock_params( int mode, /* mode bits */ struct refclock_atom *ap /* atom structure pointer */ ) { memset(&ap->pps_params, 0, sizeof(pps_params_t)); ap->pps_params.api_version = PPS_API_VERS_1; /* * Solaris serial ports provide PPS pulse capture only on the * assert edge. FreeBSD serial ports provide capture on the * clear edge, while FreeBSD parallel ports provide capture * on the assert edge. Your mileage may vary. */ if (mode & CLK_FLAG2) ap->pps_params.mode = PPS_TSFMT_TSPEC | PPS_CAPTURECLEAR; else ap->pps_params.mode = PPS_TSFMT_TSPEC | PPS_CAPTUREASSERT; if (time_pps_setparams(ap->handle, &ap->pps_params) < 0) { msyslog(LOG_ERR, "refclock_params: time_pps_setparams: %m"); return (0); } /* * If flag3 is lit, select the kernel PPS. */ if (mode & CLK_FLAG3) { if (time_pps_kcbind(ap->handle, PPS_KC_HARDPPS, ap->pps_params.mode & ~PPS_TSFMT_TSPEC, PPS_TSFMT_TSPEC) < 0) { if (errno != EOPNOTSUPP) { msyslog(LOG_ERR, "refclock_params: time_pps_kcbind: %m"); return (0); } } pps_enable = 1; } return (1); }
static inline int unbind(pps_handle_t handle) { return time_pps_kcbind(handle, PPS_KC_HARDPPS, 0, PPS_TSFMT_TSPEC); }
static inline int bind(pps_handle_t handle, int edge) { return time_pps_kcbind(handle, PPS_KC_HARDPPS, edge, PPS_TSFMT_TSPEC); }