author | Florian Pose <fp@igh-essen.com> |
Thu, 26 Jun 2008 14:24:49 +0000 | |
changeset 1060 | 5e51425da89f |
parent 1057 | 435d7f36f13d |
child 1075 | 94c6e36e0f8d |
permissions | -rw-r--r-- |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/****************************************************************************** |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
* $Id$ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
5 |
* Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
6 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT Master. |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
8 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
10 |
* and/or modify it under the terms of the GNU General Public License |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
11 |
* as published by the Free Software Foundation; either version 2 of the |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
12 |
* License, or (at your option) any later version. |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
13 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
14 |
* The IgH EtherCAT Master is distributed in the hope that it will be |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
15 |
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
17 |
* GNU General Public License for more details. |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
18 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
19 |
* You should have received a copy of the GNU General Public License |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
20 |
* along with the IgH EtherCAT Master; if not, write to the Free Software |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
21 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
22 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
23 |
* The right to use EtherCAT Technology is granted and comes free of |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
24 |
* charge under condition of compatibility of product made by |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
25 |
* Licensee. People intending to distribute/sell products based on the |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
26 |
* code, have to sign an agreement to guarantee that products using |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
27 |
* software based on IgH EtherCAT master stay compatible with the actual |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
* EtherCAT specification (which are released themselves as an open |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
29 |
* standard) as the (only) precondition to have the right to use EtherCAT |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
30 |
* Technology, IP and trade marks. |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
31 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
32 |
*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
34 |
/** |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
35 |
\file |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
36 |
EtherCAT master character device. |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
*/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
39 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
40 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
#include <linux/module.h> |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
#include "cdev.h" |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
44 |
#include "master.h" |
950
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
45 |
#include "slave_config.h" |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
46 |
#include "ioctl.h" |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
47 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
48 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
49 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
50 |
/** \cond */ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
51 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
52 |
int eccdev_open(struct inode *, struct file *); |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
53 |
int eccdev_release(struct inode *, struct file *); |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
54 |
long eccdev_ioctl(struct file *, unsigned int, unsigned long); |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
55 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
56 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
57 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
58 |
static struct file_operations eccdev_fops = { |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
59 |
.owner = THIS_MODULE, |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
60 |
.open = eccdev_open, |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
61 |
.release = eccdev_release, |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
62 |
.unlocked_ioctl = eccdev_ioctl |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
63 |
}; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
64 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
65 |
/** \endcond */ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
66 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
67 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
68 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
69 |
/** Constructor. |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
70 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
71 |
* \return 0 in case of success, else < 0 |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
72 |
*/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
73 |
int ec_cdev_init( |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
74 |
ec_cdev_t *cdev, /**< EtherCAT master character device. */ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
75 |
ec_master_t *master, /**< Parent master. */ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
76 |
dev_t dev_num /**< Device number. */ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
77 |
) |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
78 |
{ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
79 |
cdev->master = master; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
80 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
81 |
cdev_init(&cdev->cdev, &eccdev_fops); |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
82 |
cdev->cdev.owner = THIS_MODULE; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
83 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
84 |
if (cdev_add(&cdev->cdev, |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
85 |
MKDEV(MAJOR(dev_num), master->index), 1)) { |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
86 |
EC_ERR("Failed to add character device!\n"); |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
87 |
return -1; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
88 |
} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
89 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
90 |
return 0; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
91 |
} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
92 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
93 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
94 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
95 |
/** Destructor. |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
96 |
*/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
97 |
void ec_cdev_clear(ec_cdev_t *cdev /**< EtherCAT XML device */) |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
98 |
{ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
99 |
cdev_del(&cdev->cdev); |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
100 |
} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
101 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
102 |
/****************************************************************************** |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
103 |
* File operations |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
104 |
*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
105 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
106 |
int eccdev_open(struct inode *inode, struct file *filp) |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
107 |
{ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
108 |
ec_cdev_t *cdev = container_of(inode->i_cdev, ec_cdev_t, cdev); |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
109 |
ec_master_t *master = cdev->master; |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
110 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
111 |
filp->private_data = cdev; |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
112 |
if (master->debug_level) |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
113 |
EC_DBG("File opened.\n"); |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
114 |
return 0; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
115 |
} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
116 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
117 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
118 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
119 |
int eccdev_release(struct inode *inode, struct file *filp) |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
120 |
{ |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
121 |
ec_cdev_t *cdev = (ec_cdev_t *) filp->private_data; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
122 |
ec_master_t *master = cdev->master; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
123 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
124 |
if (master->debug_level) |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
125 |
EC_DBG("File closed.\n"); |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
126 |
return 0; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
127 |
} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
128 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
129 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
130 |
|
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
131 |
long eccdev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
132 |
{ |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
133 |
ec_cdev_t *cdev = (ec_cdev_t *) filp->private_data; |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
134 |
ec_master_t *master = cdev->master; |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
135 |
long retval = 0; |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
136 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
137 |
if (master->debug_level) |
981
5a2bd04c555c
Output decoded ioctl command number.
Florian Pose <fp@igh-essen.com>
parents:
980
diff
changeset
|
138 |
EC_DBG("ioctl(filp = %x, cmd = %u (%u), arg = %x)\n", |
5a2bd04c555c
Output decoded ioctl command number.
Florian Pose <fp@igh-essen.com>
parents:
980
diff
changeset
|
139 |
(u32) filp, (u32) cmd, (u32) _IOC_NR(cmd), (u32) arg); |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
140 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
141 |
// FIXME lock |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
142 |
|
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
143 |
switch (cmd) { |
957
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
144 |
case EC_IOCTL_MASTER: |
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
145 |
{ |
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
146 |
ec_ioctl_master_t data; |
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
147 |
|
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
148 |
data.slave_count = master->slave_count; |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
149 |
data.config_count = ec_master_config_count(master); |
1001
a8eab75aa8e3
Removed EC_IOCTL_DOMAIN_COUNT.
Florian Pose <fp@igh-essen.com>
parents:
999
diff
changeset
|
150 |
data.domain_count = ec_master_domain_count(master); |
1029
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1019
diff
changeset
|
151 |
data.phase = (uint8_t) master->phase; |
957
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
152 |
|
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
153 |
memcpy(data.devices[0].address, master->main_mac, ETH_ALEN); |
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
154 |
data.devices[0].attached = master->main_device.dev ? 1 : 0; |
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
155 |
data.devices[0].tx_count = master->main_device.tx_count; |
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
156 |
data.devices[0].rx_count = master->main_device.rx_count; |
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
157 |
memcpy(data.devices[1].address, master->backup_mac, ETH_ALEN); |
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
158 |
data.devices[1].attached = master->backup_device.dev ? 1 : 0; |
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
159 |
data.devices[1].tx_count = master->backup_device.tx_count; |
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
160 |
data.devices[1].rx_count = master->backup_device.rx_count; |
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
161 |
|
999 | 162 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
163 |
retval = -EFAULT; |
|
164 |
break; |
|
165 |
} |
|
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
166 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
167 |
case EC_IOCTL_SLAVE: |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
168 |
{ |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
169 |
ec_ioctl_slave_t data; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
170 |
const ec_slave_t *slave; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
171 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
172 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
173 |
retval = -EFAULT; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
174 |
break; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
175 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
176 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
177 |
if (!(slave = ec_master_find_slave( |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
178 |
master, 0, data.position))) { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
179 |
EC_ERR("Slave %u does not exist!\n", data.position); |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
180 |
retval = -EINVAL; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
181 |
break; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
182 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
183 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
184 |
data.vendor_id = slave->sii.vendor_id; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
185 |
data.product_code = slave->sii.product_code; |
938
5b936e8e39fa
Added 'xml' command to generate a slave description file from a real
Florian Pose <fp@igh-essen.com>
parents:
935
diff
changeset
|
186 |
data.revision_number = slave->sii.revision_number; |
5b936e8e39fa
Added 'xml' command to generate a slave description file from a real
Florian Pose <fp@igh-essen.com>
parents:
935
diff
changeset
|
187 |
data.serial_number = slave->sii.serial_number; |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
188 |
data.alias = slave->sii.alias; |
989
816663ca9370
Slave information via 'ethercat slave'.
Florian Pose <fp@igh-essen.com>
parents:
987
diff
changeset
|
189 |
data.rx_mailbox_offset = slave->sii.rx_mailbox_offset; |
816663ca9370
Slave information via 'ethercat slave'.
Florian Pose <fp@igh-essen.com>
parents:
987
diff
changeset
|
190 |
data.rx_mailbox_size = slave->sii.rx_mailbox_size; |
816663ca9370
Slave information via 'ethercat slave'.
Florian Pose <fp@igh-essen.com>
parents:
987
diff
changeset
|
191 |
data.tx_mailbox_offset = slave->sii.tx_mailbox_offset; |
816663ca9370
Slave information via 'ethercat slave'.
Florian Pose <fp@igh-essen.com>
parents:
987
diff
changeset
|
192 |
data.tx_mailbox_size = slave->sii.tx_mailbox_size; |
816663ca9370
Slave information via 'ethercat slave'.
Florian Pose <fp@igh-essen.com>
parents:
987
diff
changeset
|
193 |
data.mailbox_protocols = slave->sii.mailbox_protocols; |
816663ca9370
Slave information via 'ethercat slave'.
Florian Pose <fp@igh-essen.com>
parents:
987
diff
changeset
|
194 |
data.has_general_category = slave->sii.has_general; |
816663ca9370
Slave information via 'ethercat slave'.
Florian Pose <fp@igh-essen.com>
parents:
987
diff
changeset
|
195 |
data.coe_details = slave->sii.coe_details; |
816663ca9370
Slave information via 'ethercat slave'.
Florian Pose <fp@igh-essen.com>
parents:
987
diff
changeset
|
196 |
data.general_flags = slave->sii.general_flags; |
816663ca9370
Slave information via 'ethercat slave'.
Florian Pose <fp@igh-essen.com>
parents:
987
diff
changeset
|
197 |
data.current_on_ebus = slave->sii.current_on_ebus; |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
198 |
data.state = slave->current_state; |
987
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
981
diff
changeset
|
199 |
data.error_flag = slave->error_flag; |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
200 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
201 |
data.sync_count = slave->sii.sync_count; |
965
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
202 |
data.sdo_count = ec_slave_sdo_count(slave); |
978 | 203 |
data.sii_nwords = slave->sii_nwords; |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
204 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
205 |
if (slave->sii.name) { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
206 |
strncpy(data.name, slave->sii.name, |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
207 |
EC_IOCTL_STRING_SIZE); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
208 |
data.name[EC_IOCTL_STRING_SIZE - 1] = 0; |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
209 |
} else { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
210 |
data.name[0] = 0; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
211 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
212 |
|
999 | 213 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
214 |
retval = -EFAULT; |
|
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
215 |
break; |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
216 |
} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
217 |
|
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
218 |
case EC_IOCTL_SYNC: |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
219 |
{ |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
220 |
ec_ioctl_sync_t data; |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
221 |
const ec_slave_t *slave; |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
222 |
const ec_sync_t *sync; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
223 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
224 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
225 |
retval = -EFAULT; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
226 |
break; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
227 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
228 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
229 |
if (!(slave = ec_master_find_slave( |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
230 |
master, 0, data.slave_position))) { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
231 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
232 |
retval = -EINVAL; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
233 |
break; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
234 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
235 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
236 |
if (data.sync_index >= slave->sii.sync_count) { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
237 |
EC_ERR("Sync manager %u does not exist in slave %u!\n", |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
238 |
data.sync_index, data.slave_position); |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
239 |
retval = -EINVAL; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
240 |
break; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
241 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
242 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
243 |
sync = &slave->sii.syncs[data.sync_index]; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
244 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
245 |
data.physical_start_address = sync->physical_start_address; |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1037
diff
changeset
|
246 |
data.default_size = sync->default_length; |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
247 |
data.control_register = sync->control_register; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
248 |
data.enable = sync->enable; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
249 |
data.assign_source = sync->assign_source; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
250 |
data.pdo_count = ec_pdo_list_count(&sync->pdos); |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
251 |
|
999 | 252 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
253 |
retval = -EFAULT; |
|
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
254 |
break; |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
255 |
} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
256 |
|
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
257 |
case EC_IOCTL_PDO: |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
258 |
{ |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
259 |
ec_ioctl_pdo_t data; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
260 |
const ec_slave_t *slave; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
261 |
const ec_sync_t *sync; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
262 |
const ec_pdo_t *pdo; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
263 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
264 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
265 |
retval = -EFAULT; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
266 |
break; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
267 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
268 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
269 |
if (!(slave = ec_master_find_slave( |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
270 |
master, 0, data.slave_position))) { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
271 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
272 |
retval = -EINVAL; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
273 |
break; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
274 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
275 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
276 |
if (data.sync_index >= slave->sii.sync_count) { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
277 |
EC_ERR("Sync manager %u does not exist in slave %u!\n", |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
278 |
data.sync_index, data.slave_position); |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
279 |
retval = -EINVAL; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
280 |
break; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
281 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
282 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
283 |
sync = &slave->sii.syncs[data.sync_index]; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
284 |
if (!(pdo = ec_pdo_list_find_pdo_by_pos_const( |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
285 |
&sync->pdos, data.pdo_pos))) { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
286 |
EC_ERR("Sync manager %u does not contain a Pdo with " |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
287 |
"position %u in slave %u!\n", data.sync_index, |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
288 |
data.pdo_pos, data.slave_position); |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
289 |
retval = -EINVAL; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
290 |
break; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
291 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
292 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
293 |
data.index = pdo->index; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
294 |
data.entry_count = ec_pdo_entry_count(pdo); |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
295 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
296 |
if (pdo->name) { |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
297 |
strncpy(data.name, pdo->name, EC_IOCTL_STRING_SIZE); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
298 |
data.name[EC_IOCTL_STRING_SIZE - 1] = 0; |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
299 |
} else { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
300 |
data.name[0] = 0; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
301 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
302 |
|
999 | 303 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
304 |
retval = -EFAULT; |
|
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
305 |
break; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
306 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
307 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
308 |
case EC_IOCTL_PDO_ENTRY: |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
309 |
{ |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
310 |
ec_ioctl_pdo_entry_t data; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
311 |
const ec_slave_t *slave; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
312 |
const ec_sync_t *sync; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
313 |
const ec_pdo_t *pdo; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
314 |
const ec_pdo_entry_t *entry; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
315 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
316 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
317 |
retval = -EFAULT; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
318 |
break; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
319 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
320 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
321 |
if (!(slave = ec_master_find_slave( |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
322 |
master, 0, data.slave_position))) { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
323 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
324 |
retval = -EINVAL; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
325 |
break; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
326 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
327 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
328 |
if (data.sync_index >= slave->sii.sync_count) { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
329 |
EC_ERR("Sync manager %u does not exist in slave %u!\n", |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
330 |
data.sync_index, data.slave_position); |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
331 |
retval = -EINVAL; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
332 |
break; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
333 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
334 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
335 |
sync = &slave->sii.syncs[data.sync_index]; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
336 |
if (!(pdo = ec_pdo_list_find_pdo_by_pos_const( |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
337 |
&sync->pdos, data.pdo_pos))) { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
338 |
EC_ERR("Sync manager %u does not contain a Pdo with " |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
339 |
"position %u in slave %u!\n", data.sync_index, |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
340 |
data.pdo_pos, data.slave_position); |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
341 |
retval = -EINVAL; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
342 |
break; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
343 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
344 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
345 |
if (!(entry = ec_pdo_find_entry_by_pos_const( |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
346 |
pdo, data.entry_pos))) { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
347 |
EC_ERR("Pdo 0x%04X does not contain an entry with " |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
348 |
"position %u in slave %u!\n", data.pdo_pos, |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
349 |
data.entry_pos, data.slave_position); |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
350 |
retval = -EINVAL; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
351 |
break; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
352 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
353 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
354 |
data.index = entry->index; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
355 |
data.subindex = entry->subindex; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
356 |
data.bit_length = entry->bit_length; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
357 |
if (entry->name) { |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
358 |
strncpy(data.name, entry->name, EC_IOCTL_STRING_SIZE); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
359 |
data.name[EC_IOCTL_STRING_SIZE - 1] = 0; |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
360 |
} else { |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
361 |
data.name[0] = 0; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
362 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
363 |
|
999 | 364 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
365 |
retval = -EFAULT; |
|
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
366 |
break; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
367 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
368 |
|
948
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
369 |
case EC_IOCTL_DOMAIN: |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
370 |
{ |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
371 |
ec_ioctl_domain_t data; |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
372 |
const ec_domain_t *domain; |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
373 |
|
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
374 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
375 |
retval = -EFAULT; |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
376 |
break; |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
377 |
} |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
378 |
|
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
379 |
if (!(domain = ec_master_find_domain(master, data.index))) { |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
380 |
EC_ERR("Domain %u does not exist!\n", data.index); |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
381 |
retval = -EINVAL; |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
382 |
break; |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
383 |
} |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
384 |
|
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
385 |
data.data_size = domain->data_size; |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
386 |
data.logical_base_address = domain->logical_base_address; |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
387 |
data.working_counter = domain->working_counter; |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
388 |
data.expected_working_counter = domain->expected_working_counter; |
950
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
389 |
data.fmmu_count = ec_domain_fmmu_count(domain); |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
390 |
|
999 | 391 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
392 |
retval = -EFAULT; |
|
950
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
393 |
break; |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
394 |
} |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
395 |
|
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
396 |
case EC_IOCTL_DOMAIN_FMMU: |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
397 |
{ |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
398 |
ec_ioctl_domain_fmmu_t data; |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
399 |
const ec_domain_t *domain; |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
400 |
const ec_fmmu_config_t *fmmu; |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
401 |
|
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
402 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
403 |
retval = -EFAULT; |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
404 |
break; |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
405 |
} |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
406 |
|
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
407 |
if (!(domain = ec_master_find_domain(master, data.domain_index))) { |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
408 |
EC_ERR("Domain %u does not exist!\n", data.domain_index); |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
409 |
retval = -EINVAL; |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
410 |
break; |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
411 |
} |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
412 |
|
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
413 |
if (!(fmmu = ec_domain_find_fmmu(domain, data.fmmu_index))) { |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
414 |
EC_ERR("Domain %u has less than %u fmmu configurations.\n", |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
415 |
data.domain_index, data.fmmu_index + 1); |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
416 |
retval = -EINVAL; |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
417 |
break; |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
418 |
} |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
419 |
|
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
420 |
data.slave_config_alias = fmmu->sc->alias; |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
421 |
data.slave_config_position = fmmu->sc->position; |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1037
diff
changeset
|
422 |
data.sync_index = fmmu->sync_index; |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1037
diff
changeset
|
423 |
data.dir = fmmu->dir; |
950
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
424 |
data.logical_address = fmmu->logical_start_address; |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
425 |
data.data_size = fmmu->data_size; |
948
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
426 |
|
999 | 427 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
428 |
retval = -EFAULT; |
|
948
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
429 |
break; |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
430 |
} |
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
431 |
|
949
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
432 |
case EC_IOCTL_DATA: |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
433 |
{ |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
434 |
ec_ioctl_data_t data; |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
435 |
const ec_domain_t *domain; |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
436 |
|
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
437 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
438 |
retval = -EFAULT; |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
439 |
break; |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
440 |
} |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
441 |
|
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
442 |
if (!(domain = ec_master_find_domain(master, data.domain_index))) { |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
443 |
EC_ERR("Domain %u does not exist!\n", data.domain_index); |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
444 |
retval = -EINVAL; |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
445 |
break; |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
446 |
} |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
447 |
|
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
448 |
if (domain->data_size != data.data_size) { |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
449 |
EC_ERR("Data size mismatch %u/%u!\n", |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
450 |
data.data_size, domain->data_size); |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
451 |
retval = -EFAULT; |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
452 |
break; |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
453 |
} |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
454 |
|
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
455 |
if (copy_to_user((void __user *) data.target, domain->data, |
999 | 456 |
domain->data_size)) |
457 |
retval = -EFAULT; |
|
949
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
458 |
break; |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
459 |
} |
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
460 |
|
957
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
461 |
case EC_IOCTL_SET_DEBUG: |
972 | 462 |
if (!(filp->f_mode & FMODE_WRITE)) |
463 |
return -EPERM; |
|
999 | 464 |
if (ec_master_debug_level(master, (unsigned int) arg)) |
956
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
950
diff
changeset
|
465 |
retval = -EINVAL; |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
950
diff
changeset
|
466 |
break; |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
950
diff
changeset
|
467 |
|
960
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
468 |
case EC_IOCTL_SLAVE_STATE: |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
469 |
{ |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
470 |
ec_ioctl_slave_state_t data; |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
471 |
ec_slave_t *slave; |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
472 |
|
972 | 473 |
if (!(filp->f_mode & FMODE_WRITE)) |
474 |
return -EPERM; |
|
475 |
||
960
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
476 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
477 |
retval = -EFAULT; |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
478 |
break; |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
479 |
} |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
480 |
|
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
481 |
if (!(slave = ec_master_find_slave( |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
482 |
master, 0, data.slave_position))) { |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
483 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
484 |
retval = -EINVAL; |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
485 |
break; |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
486 |
} |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
487 |
|
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
488 |
ec_slave_request_state(slave, data.requested_state); |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
489 |
break; |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
490 |
} |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
491 |
|
965
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
492 |
case EC_IOCTL_SDO: |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
493 |
{ |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
494 |
ec_ioctl_sdo_t data; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
495 |
const ec_slave_t *slave; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
496 |
const ec_sdo_t *sdo; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
497 |
|
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
498 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
499 |
retval = -EFAULT; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
500 |
break; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
501 |
} |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
502 |
|
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
503 |
if (!(slave = ec_master_find_slave( |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
504 |
master, 0, data.slave_position))) { |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
505 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
506 |
retval = -EINVAL; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
507 |
break; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
508 |
} |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
509 |
|
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
510 |
if (!(sdo = ec_slave_get_sdo_by_pos_const( |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
511 |
slave, data.sdo_position))) { |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
512 |
EC_ERR("Sdo %u does not exist in slave %u!\n", |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
513 |
data.sdo_position, data.slave_position); |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
514 |
retval = -EINVAL; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
515 |
break; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
516 |
} |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
517 |
|
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
518 |
data.sdo_index = sdo->index; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
519 |
data.max_subindex = sdo->max_subindex; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
520 |
|
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
521 |
if (sdo->name) { |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
522 |
strncpy(data.name, sdo->name, EC_IOCTL_STRING_SIZE); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
523 |
data.name[EC_IOCTL_STRING_SIZE - 1] = 0; |
965
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
524 |
} else { |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
525 |
data.name[0] = 0; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
526 |
} |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
527 |
|
999 | 528 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
529 |
retval = -EFAULT; |
|
965
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
530 |
break; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
531 |
} |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
532 |
|
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
533 |
case EC_IOCTL_SDO_ENTRY: |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
534 |
{ |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
535 |
ec_ioctl_sdo_entry_t data; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
536 |
const ec_slave_t *slave; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
537 |
const ec_sdo_t *sdo; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
538 |
const ec_sdo_entry_t *entry; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
539 |
|
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
540 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
541 |
retval = -EFAULT; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
542 |
break; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
543 |
} |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
544 |
|
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
545 |
if (!(slave = ec_master_find_slave( |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
546 |
master, 0, data.slave_position))) { |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
547 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
548 |
retval = -EINVAL; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
549 |
break; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
550 |
} |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
551 |
|
968
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
552 |
if (data.sdo_spec <= 0) { |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
553 |
if (!(sdo = ec_slave_get_sdo_by_pos_const( |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
554 |
slave, -data.sdo_spec))) { |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
555 |
EC_ERR("Sdo %u does not exist in slave %u!\n", |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
556 |
-data.sdo_spec, data.slave_position); |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
557 |
retval = -EINVAL; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
558 |
break; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
559 |
} |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
560 |
} else { |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
561 |
if (!(sdo = ec_slave_get_sdo_const( |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
562 |
slave, data.sdo_spec))) { |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
563 |
EC_ERR("Sdo 0x%04X does not exist in slave %u!\n", |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
564 |
data.sdo_spec, data.slave_position); |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
565 |
retval = -EINVAL; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
566 |
break; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
567 |
} |
965
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
568 |
} |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
569 |
|
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
570 |
if (!(entry = ec_sdo_get_entry_const( |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
571 |
sdo, data.sdo_entry_subindex))) { |
968
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
572 |
EC_ERR("Sdo entry 0x%04X:%02X does not exist " |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
573 |
"in slave %u!\n", sdo->index, |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
574 |
data.sdo_entry_subindex, data.slave_position); |
965
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
575 |
retval = -EINVAL; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
576 |
break; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
577 |
} |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
578 |
|
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
579 |
data.data_type = entry->data_type; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
580 |
data.bit_length = entry->bit_length; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
581 |
|
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
582 |
if (entry->description) { |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
583 |
strncpy(data.description, entry->description, |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
584 |
EC_IOCTL_STRING_SIZE); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
585 |
data.description[EC_IOCTL_STRING_SIZE - 1] |
965
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
586 |
= 0; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
587 |
} else { |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
588 |
data.description[0] = 0; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
589 |
} |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
590 |
|
999 | 591 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
592 |
retval = -EFAULT; |
|
965
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
593 |
break; |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
594 |
} |
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
595 |
|
968
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
596 |
case EC_IOCTL_SDO_UPLOAD: |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
597 |
{ |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
598 |
ec_ioctl_sdo_upload_t data; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
599 |
ec_master_sdo_request_t request; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
600 |
|
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
601 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
602 |
retval = -EFAULT; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
603 |
break; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
604 |
} |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
605 |
|
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
606 |
if (!(request.slave = ec_master_find_slave( |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
607 |
master, 0, data.slave_position))) { |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
608 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
609 |
retval = -EINVAL; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
610 |
break; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
611 |
} |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
612 |
|
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
613 |
ec_sdo_request_init(&request.req); |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
614 |
ec_sdo_request_address(&request.req, |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
615 |
data.sdo_index, data.sdo_entry_subindex); |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
616 |
ecrt_sdo_request_read(&request.req); |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
617 |
|
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
618 |
// schedule request. |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
619 |
down(&master->sdo_sem); |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
620 |
list_add_tail(&request.list, &master->slave_sdo_requests); |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
621 |
up(&master->sdo_sem); |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
622 |
|
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
623 |
// wait for processing through FSM |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
624 |
if (wait_event_interruptible(master->sdo_queue, |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
625 |
request.req.state != EC_REQUEST_QUEUED)) { |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
626 |
// interrupted by signal |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
627 |
down(&master->sdo_sem); |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
628 |
if (request.req.state == EC_REQUEST_QUEUED) { |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
629 |
list_del(&request.req.list); |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
630 |
up(&master->sdo_sem); |
1037
59f191c9185b
Store abort code in sdo request; output it in user space; added some
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
631 |
ec_sdo_request_clear(&request.req); |
968
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
632 |
retval = -EINTR; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
633 |
break; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
634 |
} |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
635 |
// request already processing: interrupt not possible. |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
636 |
up(&master->sdo_sem); |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
637 |
} |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
638 |
|
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
639 |
// wait until master FSM has finished processing |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
640 |
wait_event(master->sdo_queue, request.req.state != EC_REQUEST_BUSY); |
1037
59f191c9185b
Store abort code in sdo request; output it in user space; added some
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
641 |
|
59f191c9185b
Store abort code in sdo request; output it in user space; added some
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
642 |
data.abort_code = request.req.abort_code; |
968
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
643 |
|
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
644 |
if (request.req.state != EC_REQUEST_SUCCESS) { |
1037
59f191c9185b
Store abort code in sdo request; output it in user space; added some
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
645 |
data.data_size = 0; |
968
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
646 |
retval = -EIO; |
1037
59f191c9185b
Store abort code in sdo request; output it in user space; added some
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
647 |
} else { |
59f191c9185b
Store abort code in sdo request; output it in user space; added some
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
648 |
if (request.req.data_size > data.target_size) { |
59f191c9185b
Store abort code in sdo request; output it in user space; added some
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
649 |
EC_ERR("Buffer too small.\n"); |
59f191c9185b
Store abort code in sdo request; output it in user space; added some
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
650 |
ec_sdo_request_clear(&request.req); |
59f191c9185b
Store abort code in sdo request; output it in user space; added some
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
651 |
retval = -EOVERFLOW; |
59f191c9185b
Store abort code in sdo request; output it in user space; added some
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
652 |
break; |
59f191c9185b
Store abort code in sdo request; output it in user space; added some
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
653 |
} |
59f191c9185b
Store abort code in sdo request; output it in user space; added some
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
654 |
data.data_size = request.req.data_size; |
59f191c9185b
Store abort code in sdo request; output it in user space; added some
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
655 |
|
59f191c9185b
Store abort code in sdo request; output it in user space; added some
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
656 |
if (copy_to_user((void __user *) data.target, |
59f191c9185b
Store abort code in sdo request; output it in user space; added some
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
657 |
request.req.data, data.data_size)) { |
59f191c9185b
Store abort code in sdo request; output it in user space; added some
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
658 |
ec_sdo_request_clear(&request.req); |
59f191c9185b
Store abort code in sdo request; output it in user space; added some
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
659 |
retval = -EFAULT; |
59f191c9185b
Store abort code in sdo request; output it in user space; added some
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
660 |
break; |
59f191c9185b
Store abort code in sdo request; output it in user space; added some
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
661 |
} |
59f191c9185b
Store abort code in sdo request; output it in user space; added some
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
662 |
} |
59f191c9185b
Store abort code in sdo request; output it in user space; added some
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
663 |
|
968
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
664 |
if (__copy_to_user((void __user *) arg, &data, sizeof(data))) { |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
665 |
retval = -EFAULT; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
666 |
} |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
667 |
|
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
668 |
ec_sdo_request_clear(&request.req); |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
669 |
break; |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
670 |
} |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
965
diff
changeset
|
671 |
|
974
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
672 |
case EC_IOCTL_SDO_DOWNLOAD: |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
673 |
{ |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
674 |
ec_ioctl_sdo_download_t data; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
675 |
ec_master_sdo_request_t request; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
676 |
|
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
677 |
if (!(filp->f_mode & FMODE_WRITE)) |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
678 |
return -EPERM; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
679 |
|
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
680 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
681 |
retval = -EFAULT; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
682 |
break; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
683 |
} |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
684 |
|
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
685 |
if (!(request.slave = ec_master_find_slave( |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
686 |
master, 0, data.slave_position))) { |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
687 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
688 |
retval = -EINVAL; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
689 |
break; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
690 |
} |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
691 |
|
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
692 |
// copy data to download |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
693 |
if (!data.data_size) { |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
694 |
EC_ERR("Zero data size!\n"); |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
695 |
retval = -EINVAL; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
696 |
break; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
697 |
} |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
698 |
|
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
699 |
ec_sdo_request_init(&request.req); |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
700 |
ec_sdo_request_address(&request.req, |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
701 |
data.sdo_index, data.sdo_entry_subindex); |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
702 |
if (ec_sdo_request_alloc(&request.req, data.data_size)) { |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
703 |
ec_sdo_request_clear(&request.req); |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
704 |
retval = -ENOMEM; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
705 |
break; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
706 |
} |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
707 |
if (copy_from_user(request.req.data, |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
708 |
(void __user *) data.data, data.data_size)) { |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
709 |
ec_sdo_request_clear(&request.req); |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
710 |
retval = -EFAULT; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
711 |
break; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
712 |
} |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
713 |
request.req.data_size = data.data_size; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
714 |
ecrt_sdo_request_write(&request.req); |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
715 |
|
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
716 |
// schedule request. |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
717 |
down(&master->sdo_sem); |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
718 |
list_add_tail(&request.list, &master->slave_sdo_requests); |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
719 |
up(&master->sdo_sem); |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
720 |
|
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
721 |
// wait for processing through FSM |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
722 |
if (wait_event_interruptible(master->sdo_queue, |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
723 |
request.req.state != EC_REQUEST_QUEUED)) { |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
724 |
// interrupted by signal |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
725 |
down(&master->sdo_sem); |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
726 |
if (request.req.state == EC_REQUEST_QUEUED) { |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
727 |
list_del(&request.req.list); |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
728 |
up(&master->sdo_sem); |
1037
59f191c9185b
Store abort code in sdo request; output it in user space; added some
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
729 |
ec_sdo_request_clear(&request.req); |
974
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
730 |
retval = -EINTR; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
731 |
break; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
732 |
} |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
733 |
// request already processing: interrupt not possible. |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
734 |
up(&master->sdo_sem); |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
735 |
} |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
736 |
|
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
737 |
// wait until master FSM has finished processing |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
738 |
wait_event(master->sdo_queue, request.req.state != EC_REQUEST_BUSY); |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
739 |
|
1037
59f191c9185b
Store abort code in sdo request; output it in user space; added some
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
740 |
data.abort_code = request.req.abort_code; |
59f191c9185b
Store abort code in sdo request; output it in user space; added some
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
741 |
|
974
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
742 |
if (request.req.state != EC_REQUEST_SUCCESS) { |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
743 |
retval = -EIO; |
1037
59f191c9185b
Store abort code in sdo request; output it in user space; added some
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
744 |
} |
59f191c9185b
Store abort code in sdo request; output it in user space; added some
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
745 |
|
59f191c9185b
Store abort code in sdo request; output it in user space; added some
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
746 |
if (__copy_to_user((void __user *) arg, &data, sizeof(data))) { |
59f191c9185b
Store abort code in sdo request; output it in user space; added some
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
747 |
retval = -EFAULT; |
974
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
748 |
} |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
749 |
|
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
750 |
ec_sdo_request_clear(&request.req); |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
751 |
break; |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
752 |
} |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
753 |
|
978 | 754 |
case EC_IOCTL_SII_READ: |
755 |
{ |
|
980
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
756 |
ec_ioctl_sii_t data; |
978 | 757 |
const ec_slave_t *slave; |
758 |
||
759 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
|
760 |
retval = -EFAULT; |
|
761 |
break; |
|
762 |
} |
|
763 |
||
764 |
if (!(slave = ec_master_find_slave( |
|
765 |
master, 0, data.slave_position))) { |
|
766 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
|
767 |
retval = -EINVAL; |
|
768 |
break; |
|
769 |
} |
|
770 |
||
771 |
if (!data.nwords |
|
772 |
|| data.offset + data.nwords > slave->sii_nwords) { |
|
773 |
EC_ERR("Invalid SII read offset/size %u/%u for slave " |
|
774 |
"SII size %u!\n", data.offset, |
|
775 |
data.nwords, slave->sii_nwords); |
|
776 |
retval = -EINVAL; |
|
777 |
break; |
|
778 |
} |
|
779 |
||
780 |
if (copy_to_user((void __user *) data.words, |
|
999 | 781 |
slave->sii_words + data.offset, data.nwords * 2)) |
782 |
retval = -EFAULT; |
|
978 | 783 |
break; |
784 |
} |
|
785 |
||
980
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
786 |
case EC_IOCTL_SII_WRITE: |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
787 |
{ |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
788 |
ec_ioctl_sii_t data; |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
789 |
ec_slave_t *slave; |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
790 |
unsigned int byte_size; |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
791 |
uint16_t *words; |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
792 |
|
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
793 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
794 |
retval = -EFAULT; |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
795 |
break; |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
796 |
} |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
797 |
|
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
798 |
if (!(slave = ec_master_find_slave( |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
799 |
master, 0, data.slave_position))) { |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
800 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
801 |
retval = -EINVAL; |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
802 |
break; |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
803 |
} |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
804 |
|
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
805 |
if (!data.nwords) |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
806 |
break; |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
807 |
|
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
808 |
byte_size = sizeof(uint16_t) * data.nwords; |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
809 |
if (!(words = kmalloc(byte_size, GFP_KERNEL))) { |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
810 |
EC_ERR("Failed to allocate %u bytes for SII contents.\n", |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
811 |
byte_size); |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
812 |
retval = -ENOMEM; |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
813 |
break; |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
814 |
} |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
815 |
|
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
816 |
if (copy_from_user(words, |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
817 |
(void __user *) data.words, byte_size)) { |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
818 |
retval = -EFAULT; |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
819 |
kfree(words); |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
820 |
break; |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
821 |
} |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
822 |
|
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
823 |
if (ec_slave_write_sii(slave, |
999 | 824 |
data.offset, data.nwords, words)) |
980
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
825 |
retval = -EIO; |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
826 |
|
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
827 |
kfree(words); |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
828 |
break; |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
829 |
} |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
830 |
|
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
831 |
case EC_IOCTL_CONFIG: |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
832 |
{ |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
833 |
ec_ioctl_config_t data; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
834 |
const ec_slave_config_t *sc; |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1037
diff
changeset
|
835 |
uint8_t i; |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
836 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
837 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
838 |
retval = -EFAULT; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
839 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
840 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
841 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
842 |
if (!(sc = ec_master_get_config_const( |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
843 |
master, data.config_index))) { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
844 |
EC_ERR("Slave config %u does not exist!\n", |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
845 |
data.config_index); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
846 |
retval = -EINVAL; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
847 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
848 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
849 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
850 |
data.alias = sc->alias; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
851 |
data.position = sc->position; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
852 |
data.vendor_id = sc->vendor_id; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
853 |
data.product_code = sc->product_code; |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1037
diff
changeset
|
854 |
for (i = 0; i < EC_MAX_SYNCS; i++) { |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1037
diff
changeset
|
855 |
data.syncs[i].dir = sc->sync_configs[i].dir; |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1037
diff
changeset
|
856 |
data.syncs[i].pdo_count = |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1037
diff
changeset
|
857 |
ec_pdo_list_count(&sc->sync_configs[i].pdos); |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1037
diff
changeset
|
858 |
} |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
859 |
data.sdo_count = ec_slave_config_sdo_count(sc); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
860 |
data.attached = sc->slave != NULL; |
1057
435d7f36f13d
Operational flag in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
861 |
data.operational = sc->slave && |
435d7f36f13d
Operational flag in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
862 |
sc->slave->current_state == EC_SLAVE_STATE_OP; |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
863 |
|
999 | 864 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
865 |
retval = -EFAULT; |
|
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
866 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
867 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
868 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
869 |
case EC_IOCTL_CONFIG_PDO: |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
870 |
{ |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
871 |
ec_ioctl_config_pdo_t data; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
872 |
const ec_slave_config_t *sc; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
873 |
const ec_pdo_t *pdo; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
874 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
875 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
876 |
retval = -EFAULT; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
877 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
878 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
879 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
880 |
if (!(sc = ec_master_get_config_const( |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
881 |
master, data.config_index))) { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
882 |
EC_ERR("Slave config %u does not exist!\n", |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
883 |
data.config_index); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
884 |
retval = -EINVAL; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
885 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
886 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
887 |
|
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1037
diff
changeset
|
888 |
if (data.sync_index >= EC_MAX_SYNCS) { |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1037
diff
changeset
|
889 |
EC_ERR("Invalid sync manager index %u!\n", |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1037
diff
changeset
|
890 |
data.sync_index); |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
891 |
retval = -EINVAL; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
892 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
893 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
894 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
895 |
if (!(pdo = ec_pdo_list_find_pdo_by_pos_const( |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1037
diff
changeset
|
896 |
&sc->sync_configs[data.sync_index].pdos, |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1037
diff
changeset
|
897 |
data.pdo_pos))) { |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
898 |
EC_ERR("Invalid Pdo position!\n"); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
899 |
retval = -EINVAL; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
900 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
901 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
902 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
903 |
data.index = pdo->index; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
904 |
data.entry_count = ec_pdo_entry_count(pdo); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
905 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
906 |
if (pdo->name) { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
907 |
strncpy(data.name, pdo->name, EC_IOCTL_STRING_SIZE); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
908 |
data.name[EC_IOCTL_STRING_SIZE - 1] = 0; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
909 |
} else { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
910 |
data.name[0] = 0; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
911 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
912 |
|
999 | 913 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
914 |
retval = -EFAULT; |
|
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
915 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
916 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
917 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
918 |
case EC_IOCTL_CONFIG_PDO_ENTRY: |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
919 |
{ |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
920 |
ec_ioctl_config_pdo_entry_t data; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
921 |
const ec_slave_config_t *sc; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
922 |
const ec_pdo_t *pdo; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
923 |
const ec_pdo_entry_t *entry; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
924 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
925 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
926 |
retval = -EFAULT; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
927 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
928 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
929 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
930 |
if (!(sc = ec_master_get_config_const( |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
931 |
master, data.config_index))) { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
932 |
EC_ERR("Slave config %u does not exist!\n", |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
933 |
data.config_index); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
934 |
retval = -EINVAL; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
935 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
936 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
937 |
|
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1037
diff
changeset
|
938 |
if (data.sync_index >= EC_MAX_SYNCS) { |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1037
diff
changeset
|
939 |
EC_ERR("Invalid sync manager index %u!\n", |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1037
diff
changeset
|
940 |
data.sync_index); |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
941 |
retval = -EINVAL; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
942 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
943 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
944 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
945 |
if (!(pdo = ec_pdo_list_find_pdo_by_pos_const( |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1037
diff
changeset
|
946 |
&sc->sync_configs[data.sync_index].pdos, |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1037
diff
changeset
|
947 |
data.pdo_pos))) { |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
948 |
EC_ERR("Invalid Pdo position!\n"); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
949 |
retval = -EINVAL; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
950 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
951 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
952 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
953 |
if (!(entry = ec_pdo_find_entry_by_pos_const( |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
954 |
pdo, data.entry_pos))) { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
955 |
EC_ERR("Entry not found!\n"); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
956 |
retval = -EINVAL; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
957 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
958 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
959 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
960 |
data.index = entry->index; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
961 |
data.subindex = entry->subindex; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
962 |
data.bit_length = entry->bit_length; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
963 |
if (entry->name) { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
964 |
strncpy(data.name, entry->name, EC_IOCTL_STRING_SIZE); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
965 |
data.name[EC_IOCTL_STRING_SIZE - 1] = 0; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
966 |
} else { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
967 |
data.name[0] = 0; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
968 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
969 |
|
999 | 970 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
971 |
retval = -EFAULT; |
|
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
972 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
973 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
974 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
975 |
case EC_IOCTL_CONFIG_SDO: |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
976 |
{ |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
977 |
ec_ioctl_config_sdo_t data; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
978 |
const ec_slave_config_t *sc; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
979 |
const ec_sdo_request_t *req; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
980 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
981 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
982 |
retval = -EFAULT; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
983 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
984 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
985 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
986 |
if (!(sc = ec_master_get_config_const( |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
987 |
master, data.config_index))) { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
988 |
EC_ERR("Slave config %u does not exist!\n", |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
989 |
data.config_index); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
990 |
retval = -EINVAL; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
991 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
992 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
993 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
994 |
if (!(req = ec_slave_config_get_sdo_by_pos_const( |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
995 |
sc, data.sdo_pos))) { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
996 |
EC_ERR("Invalid Sdo position!\n"); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
997 |
retval = -EINVAL; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
998 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
999 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
1000 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
1001 |
data.index = req->index; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
1002 |
data.subindex = req->subindex; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
1003 |
data.size = req->data_size; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
1004 |
memcpy(&data.data, req->data, min((u32) data.size, (u32) 4)); |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
1005 |
|
999 | 1006 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
1007 |
retval = -EFAULT; |
|
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
1008 |
break; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
1009 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
1010 |
|
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1011 |
default: |
972 | 1012 |
retval = -ENOTTY; |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1013 |
} |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
1014 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
1015 |
return retval; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
1016 |
} |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
1017 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
1018 |
/*****************************************************************************/ |