author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Sat, 29 Sep 2018 23:58:09 +0200 | |
branch | stable-1.5 |
changeset 2714 | ec417efca1fd |
parent 2713 | 2e2f57fd2131 |
child 2719 | 94c9657e0bee |
permissions | -rw-r--r-- |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/***************************************************************************** |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
* $Id$ |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
* |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
5 |
* Copyright (C) 2009-2010 Moehwald GmbH B. Benner |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
6 |
* 2011 IgH Andreas Stewering-Bone |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
7 |
* 2012 Florian Pose <fp@igh-essen.com> |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
8 |
* |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
9 |
* This file is part of the IgH EtherCAT master. |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
10 |
* |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
11 |
* The IgH EtherCAT master is free software; you can redistribute it and/or |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
12 |
* modify it under the terms of the GNU General Public License as published |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
13 |
* by the Free Software Foundation; version 2 of the License. |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
14 |
* |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
15 |
* The IgH EtherCAT master is distributed in the hope that it will be useful, |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
18 |
* Public License for more details. |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
19 |
* |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
20 |
* You should have received a copy of the GNU General Public License along |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
21 |
* with the IgH EtherCAT master. If not, see <http://www.gnu.org/licenses/>. |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
22 |
* |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
23 |
* The license mentioned above concerns the source code only. Using the |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
24 |
* EtherCAT technology and brand is only permitted in compliance with the |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
25 |
* industrial property and similar rights of Beckhoff Automation GmbH. |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
26 |
* |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
27 |
****************************************************************************/ |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
|
2524
6d9865c37b6f
Some more doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2522
diff
changeset
|
29 |
/** \file |
6d9865c37b6f
Some more doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2522
diff
changeset
|
30 |
* RTDM interface. |
6d9865c37b6f
Some more doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2522
diff
changeset
|
31 |
*/ |
6d9865c37b6f
Some more doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2522
diff
changeset
|
32 |
|
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
#include <linux/module.h> |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
34 |
#include <linux/slab.h> |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
35 |
#include <linux/mman.h> |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
36 |
|
2700
93ef210e9b56
Intermediate state while updating master's RTDM part to Xenomai 3
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2524
diff
changeset
|
37 |
#include <rtdm/driver.h> |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
|
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
39 |
#include "master.h" |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
40 |
#include "ioctl.h" |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
#include "rtdm.h" |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
|
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
/** Set to 1 to enable device operations debugging. |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
44 |
*/ |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
45 |
#define DEBUG 0 |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
46 |
|
2707
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
47 |
|
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
48 |
/****************************************************************************/ |
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
49 |
|
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
50 |
int ec_rtdm_open(struct rtdm_fd *, int); |
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
51 |
void ec_rtdm_close(struct rtdm_fd *); |
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
52 |
int ec_rtdm_ioctl(struct rtdm_fd *, |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
53 |
unsigned int, void __user *); |
2712
5d21d80777a6
Use new RTDM's mmap, not anymore a special case compared to normal linux mmap.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2707
diff
changeset
|
54 |
int ec_rtdm_mmap(struct rtdm_fd *fd, struct vm_area_struct *vma); |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
55 |
|
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
56 |
/****************************************************************************/ |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
57 |
|
2700
93ef210e9b56
Intermediate state while updating master's RTDM part to Xenomai 3
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2524
diff
changeset
|
58 |
static struct rtdm_driver ec_rtdm_driver = { |
93ef210e9b56
Intermediate state while updating master's RTDM part to Xenomai 3
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2524
diff
changeset
|
59 |
.profile_info = RTDM_PROFILE_INFO(foo, |
93ef210e9b56
Intermediate state while updating master's RTDM part to Xenomai 3
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2524
diff
changeset
|
60 |
RTDM_CLASS_EXPERIMENTAL, |
93ef210e9b56
Intermediate state while updating master's RTDM part to Xenomai 3
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2524
diff
changeset
|
61 |
222, |
93ef210e9b56
Intermediate state while updating master's RTDM part to Xenomai 3
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2524
diff
changeset
|
62 |
1), |
93ef210e9b56
Intermediate state while updating master's RTDM part to Xenomai 3
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2524
diff
changeset
|
63 |
.device_flags = RTDM_NAMED_DEVICE, |
93ef210e9b56
Intermediate state while updating master's RTDM part to Xenomai 3
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2524
diff
changeset
|
64 |
.device_count = 1, |
2707
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
65 |
.context_size = sizeof(ec_ioctl_context_t), |
2700
93ef210e9b56
Intermediate state while updating master's RTDM part to Xenomai 3
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2524
diff
changeset
|
66 |
.ops = { |
2707
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
67 |
.open = ec_rtdm_open, |
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
68 |
.close = ec_rtdm_close, |
2700
93ef210e9b56
Intermediate state while updating master's RTDM part to Xenomai 3
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2524
diff
changeset
|
69 |
.ioctl_rt = ec_rtdm_ioctl, |
2712
5d21d80777a6
Use new RTDM's mmap, not anymore a special case compared to normal linux mmap.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2707
diff
changeset
|
70 |
.ioctl_nrt = ec_rtdm_ioctl, |
5d21d80777a6
Use new RTDM's mmap, not anymore a special case compared to normal linux mmap.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2707
diff
changeset
|
71 |
.mmap = ec_rtdm_mmap |
2700
93ef210e9b56
Intermediate state while updating master's RTDM part to Xenomai 3
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2524
diff
changeset
|
72 |
}, |
93ef210e9b56
Intermediate state while updating master's RTDM part to Xenomai 3
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2524
diff
changeset
|
73 |
}; |
93ef210e9b56
Intermediate state while updating master's RTDM part to Xenomai 3
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2524
diff
changeset
|
74 |
|
2524
6d9865c37b6f
Some more doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2522
diff
changeset
|
75 |
/** Initialize an RTDM device. |
6d9865c37b6f
Some more doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2522
diff
changeset
|
76 |
* |
6d9865c37b6f
Some more doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2522
diff
changeset
|
77 |
* \return Zero on success, otherwise a negative error code. |
6d9865c37b6f
Some more doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2522
diff
changeset
|
78 |
*/ |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
79 |
int ec_rtdm_dev_init( |
2524
6d9865c37b6f
Some more doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2522
diff
changeset
|
80 |
ec_rtdm_dev_t *rtdm_dev, /**< EtherCAT RTDM device. */ |
6d9865c37b6f
Some more doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2522
diff
changeset
|
81 |
ec_master_t *master /**< EtherCAT master. */ |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
82 |
) |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
83 |
{ |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
84 |
int ret; |
2707
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
85 |
char* devlabel; |
2700
93ef210e9b56
Intermediate state while updating master's RTDM part to Xenomai 3
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2524
diff
changeset
|
86 |
|
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
87 |
rtdm_dev->master = master; |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
88 |
|
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
89 |
rtdm_dev->dev = kzalloc(sizeof(struct rtdm_device), GFP_KERNEL); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
90 |
if (!rtdm_dev->dev) { |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
91 |
EC_MASTER_ERR(master, "Failed to reserve memory for RTDM device.\n"); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
92 |
return -ENOMEM; |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
93 |
} |
2700
93ef210e9b56
Intermediate state while updating master's RTDM part to Xenomai 3
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2524
diff
changeset
|
94 |
|
2707
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
95 |
devlabel = kzalloc(RTDM_MAX_DEVNAME_LEN+1, GFP_KERNEL); |
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
96 |
if (!devlabel) { |
2700
93ef210e9b56
Intermediate state while updating master's RTDM part to Xenomai 3
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2524
diff
changeset
|
97 |
EC_MASTER_ERR(master, "Failed to reserve memory for RTDM device name.\n"); |
93ef210e9b56
Intermediate state while updating master's RTDM part to Xenomai 3
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2524
diff
changeset
|
98 |
return -ENOMEM; |
93ef210e9b56
Intermediate state while updating master's RTDM part to Xenomai 3
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2524
diff
changeset
|
99 |
kfree(rtdm_dev->dev); |
93ef210e9b56
Intermediate state while updating master's RTDM part to Xenomai 3
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2524
diff
changeset
|
100 |
} |
2707
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
101 |
snprintf(devlabel, RTDM_MAX_DEVNAME_LEN, |
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
102 |
"EtherCAT%u", master->index); |
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
103 |
|
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
104 |
rtdm_dev->dev->label = devlabel; |
2700
93ef210e9b56
Intermediate state while updating master's RTDM part to Xenomai 3
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2524
diff
changeset
|
105 |
rtdm_dev->dev->driver = &ec_rtdm_driver; |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
106 |
rtdm_dev->dev->device_data = rtdm_dev; /* pointer to parent */ |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
107 |
|
2700
93ef210e9b56
Intermediate state while updating master's RTDM part to Xenomai 3
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2524
diff
changeset
|
108 |
|
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
109 |
EC_MASTER_INFO(master, "Registering RTDM device %s.\n", |
2707
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
110 |
devlabel); |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
111 |
ret = rtdm_dev_register(rtdm_dev->dev); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
112 |
if (ret) { |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
113 |
EC_MASTER_ERR(master, "Initialization of RTDM interface failed" |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
114 |
" (return value %i).\n", ret); |
2700
93ef210e9b56
Intermediate state while updating master's RTDM part to Xenomai 3
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2524
diff
changeset
|
115 |
kfree(rtdm_dev->dev->label); |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
116 |
kfree(rtdm_dev->dev); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
117 |
} |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
118 |
|
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
119 |
return ret; |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
120 |
} |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
121 |
|
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
122 |
/****************************************************************************/ |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
123 |
|
2524
6d9865c37b6f
Some more doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2522
diff
changeset
|
124 |
/** Clear an RTDM device. |
6d9865c37b6f
Some more doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2522
diff
changeset
|
125 |
*/ |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
126 |
void ec_rtdm_dev_clear( |
2524
6d9865c37b6f
Some more doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2522
diff
changeset
|
127 |
ec_rtdm_dev_t *rtdm_dev /**< EtherCAT RTDM device. */ |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
128 |
) |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
129 |
{ |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
130 |
EC_MASTER_INFO(rtdm_dev->master, "Unregistering RTDM device %s.\n", |
2700
93ef210e9b56
Intermediate state while updating master's RTDM part to Xenomai 3
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2524
diff
changeset
|
131 |
rtdm_dev->dev->label); |
2707
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
132 |
rtdm_dev_unregister(rtdm_dev->dev); |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
133 |
|
2700
93ef210e9b56
Intermediate state while updating master's RTDM part to Xenomai 3
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2524
diff
changeset
|
134 |
kfree(rtdm_dev->dev->label); |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
135 |
kfree(rtdm_dev->dev); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
136 |
} |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
137 |
|
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
138 |
/****************************************************************************/ |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
139 |
|
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
140 |
/** Driver open. |
2524
6d9865c37b6f
Some more doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2522
diff
changeset
|
141 |
* |
6d9865c37b6f
Some more doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2522
diff
changeset
|
142 |
* \return Always zero (success). |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
143 |
*/ |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
144 |
int ec_rtdm_open( |
2706
43f8e40a183d
Continued update of master's rtdm part to xenomai 3 : rtdm_user_info_t now replaced by rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2700
diff
changeset
|
145 |
struct rtdm_fd *fd, /**< User data. */ |
2524
6d9865c37b6f
Some more doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2522
diff
changeset
|
146 |
int oflags /**< Open flags. */ |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
147 |
) |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
148 |
{ |
2707
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
149 |
ec_ioctl_context_t *ctx = (ec_ioctl_context_t *) rtdm_fd_to_private(fd); |
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
150 |
#if DEBUG |
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
151 |
ec_rtdm_dev_t *rtdm_dev = (ec_rtdm_dev_t *) rtdm_fd_device(fd)->device_data; |
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
152 |
#endif |
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
153 |
|
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
154 |
ctx->writable = oflags & O_WRONLY || oflags & O_RDWR; |
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
155 |
ctx->requested = 0; |
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
156 |
ctx->process_data = NULL; |
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
157 |
ctx->process_data_size = 0; |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
158 |
|
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
159 |
#if DEBUG |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
160 |
EC_MASTER_INFO(rtdm_dev->master, "RTDM device %s opened.\n", |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
161 |
context->device->device_name); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
162 |
#endif |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
163 |
return 0; |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
164 |
} |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
165 |
|
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
166 |
/****************************************************************************/ |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
167 |
|
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
168 |
/** Driver close. |
2524
6d9865c37b6f
Some more doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2522
diff
changeset
|
169 |
* |
6d9865c37b6f
Some more doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2522
diff
changeset
|
170 |
* \return Always zero (success). |
6d9865c37b6f
Some more doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2522
diff
changeset
|
171 |
*/ |
2707
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
172 |
void ec_rtdm_close( |
2706
43f8e40a183d
Continued update of master's rtdm part to xenomai 3 : rtdm_user_info_t now replaced by rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2700
diff
changeset
|
173 |
struct rtdm_fd *fd /**< User data. */ |
2524
6d9865c37b6f
Some more doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2522
diff
changeset
|
174 |
) |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
175 |
{ |
2707
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
176 |
ec_ioctl_context_t *ctx = (ec_ioctl_context_t *) rtdm_fd_to_private(fd); |
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
177 |
ec_rtdm_dev_t *rtdm_dev = (ec_rtdm_dev_t *) rtdm_fd_device(fd)->device_data; |
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
178 |
|
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
179 |
if (ctx->requested) { |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
180 |
ecrt_release_master(rtdm_dev->master); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
181 |
} |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
182 |
|
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
183 |
#if DEBUG |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
184 |
EC_MASTER_INFO(rtdm_dev->master, "RTDM device %s closed.\n", |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
185 |
context->device->device_name); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
186 |
#endif |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
187 |
} |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
188 |
|
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
189 |
/****************************************************************************/ |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
190 |
|
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
191 |
/** Driver ioctl. |
2524
6d9865c37b6f
Some more doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2522
diff
changeset
|
192 |
* |
6d9865c37b6f
Some more doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2522
diff
changeset
|
193 |
* \return ioctl() return code. |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
194 |
*/ |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
195 |
int ec_rtdm_ioctl( |
2706
43f8e40a183d
Continued update of master's rtdm part to xenomai 3 : rtdm_user_info_t now replaced by rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2700
diff
changeset
|
196 |
struct rtdm_fd *fd, /**< User data. */ |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
197 |
unsigned int request, /**< Request. */ |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
198 |
void __user *arg /**< Argument. */ |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
199 |
) |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
200 |
{ |
2707
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
201 |
ec_ioctl_context_t *ctx = (ec_ioctl_context_t *) rtdm_fd_to_private(fd); |
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
202 |
ec_rtdm_dev_t *rtdm_dev = (ec_rtdm_dev_t *) rtdm_fd_device(fd)->device_data; |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
203 |
|
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
204 |
#if DEBUG |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
205 |
EC_MASTER_INFO(rtdm_dev->master, "ioctl(request = %u, ctl = %02x)" |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
206 |
" on RTDM device %s.\n", request, _IOC_NR(request), |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
207 |
context->device->device_name); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
208 |
#endif |
2707
245d8592cfdc
Continued update of master's rtdm part to xenomai 3 : ioctl context now obtained from rtdm_fd
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2706
diff
changeset
|
209 |
return ec_ioctl_rtdm(rtdm_dev->master, ctx, request, arg); |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
210 |
} |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
211 |
|
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
212 |
/****************************************************************************/ |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
213 |
|
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
214 |
/** Memory-map process data to user space. |
2524
6d9865c37b6f
Some more doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2522
diff
changeset
|
215 |
* |
2712
5d21d80777a6
Use new RTDM's mmap, not anymore a special case compared to normal linux mmap.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2707
diff
changeset
|
216 |
*/ |
5d21d80777a6
Use new RTDM's mmap, not anymore a special case compared to normal linux mmap.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2707
diff
changeset
|
217 |
int ec_rtdm_mmap(struct rtdm_fd *fd, struct vm_area_struct *vma) |
5d21d80777a6
Use new RTDM's mmap, not anymore a special case compared to normal linux mmap.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2707
diff
changeset
|
218 |
{ |
2713
2e2f57fd2131
More check in rtdm mmap, also use kernel memory instead of virtual memory.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2712
diff
changeset
|
219 |
size_t len; |
2e2f57fd2131
More check in rtdm mmap, also use kernel memory instead of virtual memory.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2712
diff
changeset
|
220 |
ec_ioctl_context_t *ctx = (ec_ioctl_context_t *) rtdm_fd_to_private(fd); |
2e2f57fd2131
More check in rtdm mmap, also use kernel memory instead of virtual memory.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2712
diff
changeset
|
221 |
len = vma->vm_end - vma->vm_start; |
2e2f57fd2131
More check in rtdm mmap, also use kernel memory instead of virtual memory.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2712
diff
changeset
|
222 |
if (ctx->process_data_size != len) |
2e2f57fd2131
More check in rtdm mmap, also use kernel memory instead of virtual memory.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2712
diff
changeset
|
223 |
return -EINVAL; |
2e2f57fd2131
More check in rtdm mmap, also use kernel memory instead of virtual memory.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2712
diff
changeset
|
224 |
return rtdm_mmap_kmem(vma, (void *)ctx->process_data); |
2e2f57fd2131
More check in rtdm mmap, also use kernel memory instead of virtual memory.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2712
diff
changeset
|
225 |
} |
2e2f57fd2131
More check in rtdm mmap, also use kernel memory instead of virtual memory.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2712
diff
changeset
|
226 |
|
2e2f57fd2131
More check in rtdm mmap, also use kernel memory instead of virtual memory.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2712
diff
changeset
|
227 |
/****************************************************************************/ |