27 #include <linux/module.h> 28 #include <linux/vmalloc.h> 29 #include <rtdm/driver.h> 34 #include "rtdm_details.h" 46 struct rtdm_device *dev = rtdm_fd_device(fd);
52 ctx->
ioctl_ctx.writable = oflags & O_WRONLY || oflags & O_RDWR;
70 struct rtdm_device *dev = rtdm_fd_device(fd);
92 struct rtdm_device *dev = rtdm_fd_device(fd);
98 if (result == -ENOTTY)
111 struct rtdm_device *dev = rtdm_fd_device(fd);
114 return ec_ioctl_rtdm_nrt(rtdm_dev->
master, &ctx->
ioctl_ctx, request, arg);
119 static int ec_rtdm_mmap(
struct rtdm_fd *fd,
struct vm_area_struct *vma)
123 return rtdm_mmap_kmem(vma, (
void *)ctx->
ioctl_ctx.process_data);
128 static struct rtdm_driver ec_rtdm_driver = {
129 .profile_info = RTDM_PROFILE_INFO(ec_rtdm,
130 RTDM_CLASS_EXPERIMENTAL,
133 .device_flags = RTDM_NAMED_DEVICE,
149 struct rtdm_device *dev;
152 rtdm_dev->
master = master;
154 rtdm_dev->
dev = kzalloc(
sizeof(
struct rtdm_device), GFP_KERNEL);
155 if (!rtdm_dev->
dev) {
157 "Failed to reserve memory for RTDM device.\n");
163 dev->driver = &ec_rtdm_driver;
164 dev->device_data = rtdm_dev;
165 dev->label =
"EtherCAT%u";
166 dev->minor = master->
index;
168 ret = rtdm_dev_register(dev);
170 EC_MASTER_ERR(master,
"Initialization of RTDM interface failed" 171 " (return value %i).\n", ret);
176 EC_MASTER_INFO(master,
"Registered RTDM device %s.\n", dev->name);
185 rtdm_dev_unregister(rtdm_dev->
dev);
188 rtdm_dev->
dev->name);
190 kfree(rtdm_dev->
dev);
static int ec_rtdm_ioctl_nrt_handler(struct rtdm_dev_context *, rtdm_user_info_t *, unsigned int, void __user *)
Driver ioctl.
ec_ioctl_context_t ioctl_ctx
Context structure.
static int ec_rtdm_close(struct rtdm_dev_context *, rtdm_user_info_t *)
Driver close.
struct rtdm_device * dev
RTDM device.
static int ec_rtdm_open(struct rtdm_dev_context *, rtdm_user_info_t *, int)
Driver open.
ec_master_t * master
Master pointer.
Context structure for an open RTDM file handle.
EtherCAT master structure.
void ec_rtdm_dev_clear(ec_rtdm_dev_t *rtdm_dev)
Clear an RTDM device.
int ec_rtdm_dev_init(ec_rtdm_dev_t *rtdm_dev, ec_master_t *master)
Initialize an RTDM device.
EC_RTDM_USERFD_T * user_fd
RTDM user data.
#define EC_MASTER_ERR(master, fmt, args...)
Convenience macro for printing master-specific errors to syslog.
int ec_rtdm_mmap(ec_ioctl_context_t *ioctl_ctx, void **user_address)
Memory-map process data to user space.
#define EC_MAX_MASTERS
Maximum number of masters.
static int ec_rtdm_ioctl_rt_handler(struct rtdm_dev_context *, rtdm_user_info_t *, unsigned int, void __user *)
EtherCAT master character device IOCTL commands.
#define EC_MASTER_INFO(master, fmt, args...)
Convenience macro for printing master-specific information to syslog.
void ecrt_release_master(ec_master_t *master)
Releases a requested EtherCAT master.