diff -r 373cd456dc26 -r cfcaf46c5b3f master/cdev.c --- a/master/cdev.c Mon Oct 19 13:12:40 2009 +0200 +++ b/master/cdev.c Mon Oct 19 13:13:55 2009 +0200 @@ -175,6 +175,7 @@ data.eoe_handler_count = ec_master_eoe_handler_count(master); #endif data.phase = (uint8_t) master->phase; + data.active = (uint8_t) master->active; data.scan_busy = master->scan_busy; up(&master->master_sem); @@ -1647,6 +1648,23 @@ /*****************************************************************************/ +/** Deactivates the master. + */ +int ec_cdev_ioctl_deactivate( + ec_master_t *master, /**< EtherCAT master. */ + unsigned long arg, /**< ioctl() argument. */ + ec_cdev_priv_t *priv /**< Private data structure of file handle. */ + ) +{ + if (unlikely(!priv->requested)) + return -EPERM; + + ecrt_master_deactivate(master); + return 0; +} + +/*****************************************************************************/ + /** Send frames. */ int ec_cdev_ioctl_send( @@ -1769,6 +1787,50 @@ /*****************************************************************************/ +/** Queue the sync monitoring datagram. + */ +int ec_cdev_ioctl_sync_mon_queue( + ec_master_t *master, /**< EtherCAT master. */ + unsigned long arg, /**< ioctl() argument. */ + ec_cdev_priv_t *priv /**< Private data structure of file handle. */ + ) +{ + if (unlikely(!priv->requested)) + return -EPERM; + + down(&master->io_sem); + ecrt_master_sync_monitor_queue(master); + up(&master->io_sem); + return 0; +} + +/*****************************************************************************/ + +/** Processes the sync monitoring datagram. + */ +int ec_cdev_ioctl_sync_mon_process( + ec_master_t *master, /**< EtherCAT master. */ + unsigned long arg, /**< ioctl() argument. */ + ec_cdev_priv_t *priv /**< Private data structure of file handle. */ + ) +{ + uint32_t time_diff; + + if (unlikely(!priv->requested)) + return -EPERM; + + down(&master->io_sem); + time_diff = ecrt_master_sync_monitor_process(master); + up(&master->io_sem); + + if (copy_to_user((void __user *) arg, &time_diff, sizeof(time_diff))) + return -EFAULT; + + return 0; +} + +/*****************************************************************************/ + /** Configure a sync manager. */ int ec_cdev_ioctl_sc_sync( @@ -3262,6 +3324,10 @@ if (!(filp->f_mode & FMODE_WRITE)) return -EPERM; return ec_cdev_ioctl_activate(master, arg, priv); + case EC_IOCTL_DEACTIVATE: + if (!(filp->f_mode & FMODE_WRITE)) + return -EPERM; + return ec_cdev_ioctl_deactivate(master, arg, priv); case EC_IOCTL_SEND: if (!(filp->f_mode & FMODE_WRITE)) return -EPERM; @@ -3284,6 +3350,14 @@ if (!(filp->f_mode & FMODE_WRITE)) return -EPERM; return ec_cdev_ioctl_sync_slaves(master, arg, priv); + case EC_IOCTL_SYNC_MON_QUEUE: + if (!(filp->f_mode & FMODE_WRITE)) + return -EPERM; + return ec_cdev_ioctl_sync_mon_queue(master, arg, priv); + case EC_IOCTL_SYNC_MON_PROCESS: + if (!(filp->f_mode & FMODE_WRITE)) + return -EPERM; + return ec_cdev_ioctl_sync_mon_process(master, arg, priv); case EC_IOCTL_SC_SYNC: if (!(filp->f_mode & FMODE_WRITE)) return -EPERM;