| 1595 | } |
| 1596 | |
| 1597 | int |
| 1598 | pps_ioctl(u_long cmd, caddr_t data, struct pps_state *pps) |
| 1599 | { |
| 1600 | pps_params_t *app; |
| 1601 | struct pps_fetch_args *fapi; |
| 1602 | #ifdef FFCLOCK |
| 1603 | struct pps_fetch_ffc_args *fapi_ffc; |
| 1604 | #endif |
| 1605 | #ifdef PPS_SYNC |
| 1606 | struct pps_kcbind_args *kapi; |
| 1607 | #endif |
| 1608 | |
| 1609 | KASSERT(pps != NULL, ("NULL pps pointer in pps_ioctl")); |
| 1610 | switch (cmd) { |
| 1611 | case PPS_IOC_CREATE: |
| 1612 | return (0); |
| 1613 | case PPS_IOC_DESTROY: |
| 1614 | return (0); |
| 1615 | case PPS_IOC_SETPARAMS: |
| 1616 | app = (pps_params_t *)data; |
| 1617 | if (app->mode & ~pps->ppscap) |
| 1618 | return (EINVAL); |
| 1619 | #ifdef FFCLOCK |
| 1620 | /* Ensure only a single clock is selected for ffc timestamp. */ |
| 1621 | if ((app->mode & PPS_TSCLK_MASK) == PPS_TSCLK_MASK) |
| 1622 | return (EINVAL); |
| 1623 | #endif |
| 1624 | pps->ppsparam = *app; |
| 1625 | return (0); |
| 1626 | case PPS_IOC_GETPARAMS: |
| 1627 | app = (pps_params_t *)data; |
| 1628 | *app = pps->ppsparam; |
| 1629 | app->api_version = PPS_API_VERS_1; |
| 1630 | return (0); |
| 1631 | case PPS_IOC_GETCAP: |
| 1632 | *(int*)data = pps->ppscap; |
| 1633 | return (0); |
| 1634 | case PPS_IOC_FETCH: |
| 1635 | fapi = (struct pps_fetch_args *)data; |
| 1636 | return (pps_fetch(fapi, pps)); |
| 1637 | #ifdef FFCLOCK |
| 1638 | case PPS_IOC_FETCH_FFCOUNTER: |
| 1639 | fapi_ffc = (struct pps_fetch_ffc_args *)data; |
| 1640 | if (fapi_ffc->tsformat && fapi_ffc->tsformat != |
| 1641 | PPS_TSFMT_TSPEC) |
| 1642 | return (EINVAL); |
| 1643 | if (fapi_ffc->timeout.tv_sec || fapi_ffc->timeout.tv_nsec) |
| 1644 | return (EOPNOTSUPP); |
| 1645 | pps->ppsinfo_ffc.current_mode = pps->ppsparam.mode; |
| 1646 | fapi_ffc->pps_info_buf_ffc = pps->ppsinfo_ffc; |
| 1647 | /* Overwrite timestamps if feedback clock selected. */ |
| 1648 | switch (pps->ppsparam.mode & PPS_TSCLK_MASK) { |
| 1649 | case PPS_TSCLK_FBCK: |
| 1650 | fapi_ffc->pps_info_buf_ffc.assert_timestamp = |
| 1651 | pps->ppsinfo.assert_timestamp; |
| 1652 | fapi_ffc->pps_info_buf_ffc.clear_timestamp = |
| 1653 | pps->ppsinfo.clear_timestamp; |
| 1654 | break; |
no test coverage detected