author | Martin Troxler <martin.troxler@komaxgroup.com> |
Fri, 07 May 2010 15:25:55 +0200 | |
changeset 1987 | f452c93f7723 |
parent 1984 | 02c8728bf9e4 |
child 1989 | 6aa393418fb3 |
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 |
* |
1326
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1314
diff
changeset
|
5 |
* Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH |
922
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 |
* |
1326
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1314
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it and/or |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1314
diff
changeset
|
10 |
* modify it under the terms of the GNU General Public License version 2, as |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1314
diff
changeset
|
11 |
* published by the Free Software Foundation. |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
12 |
* |
1326
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1314
diff
changeset
|
13 |
* The IgH EtherCAT Master is distributed in the hope that it will be useful, |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1314
diff
changeset
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1314
diff
changeset
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1314
diff
changeset
|
16 |
* Public License for more details. |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
17 |
* |
1326
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1314
diff
changeset
|
18 |
* You should have received a copy of the GNU General Public License along |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1314
diff
changeset
|
19 |
* with the IgH EtherCAT Master; if not, write to the Free Software |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
20 |
* 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
|
21 |
* |
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1362
diff
changeset
|
22 |
* --- |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1362
diff
changeset
|
23 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1362
diff
changeset
|
24 |
* The license mentioned above concerns the source code only. Using the |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1362
diff
changeset
|
25 |
* EtherCAT technology and brand is only permitted in compliance with the |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1362
diff
changeset
|
26 |
* industrial property and similar rights of Beckhoff Automation GmbH. |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
27 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
29 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
30 |
/** |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
31 |
\file |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
32 |
EtherCAT master character device. |
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 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
36 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
#include <linux/module.h> |
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
38 |
#include <linux/vmalloc.h> |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
39 |
#include <linux/mm.h> |
922
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 "cdev.h" |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
#include "master.h" |
950
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
43 |
#include "slave_config.h" |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
44 |
#include "voe_handler.h" |
1485 | 45 |
#include "ethernet.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 |
|
1465 | 48 |
/** Set to 1 to enable ioctl() command debugging. |
49 |
*/ |
|
1397 | 50 |
#define DEBUG_IOCTL 0 |
51 |
||
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
52 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
53 |
|
1268 | 54 |
static int eccdev_open(struct inode *, struct file *); |
55 |
static int eccdev_release(struct inode *, struct file *); |
|
56 |
static long eccdev_ioctl(struct file *, unsigned int, unsigned long); |
|
57 |
static int eccdev_mmap(struct file *, struct vm_area_struct *); |
|
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
58 |
|
1272
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
59 |
/** This is the kernel version from which the .fault member of the |
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
60 |
* vm_operations_struct is usable. |
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
61 |
*/ |
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
62 |
#define PAGE_FAULT_VERSION KERNEL_VERSION(2, 6, 23) |
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
63 |
|
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
64 |
#if LINUX_VERSION_CODE >= PAGE_FAULT_VERSION |
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
65 |
static int eccdev_vma_fault(struct vm_area_struct *, struct vm_fault *); |
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
66 |
#else |
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
67 |
static struct page *eccdev_vma_nopage( |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
68 |
struct vm_area_struct *, unsigned long, int *); |
1272
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
69 |
#endif |
922
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 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
72 |
|
1268 | 73 |
/** File operation callbacks for the EtherCAT character device. |
74 |
*/ |
|
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
75 |
static struct file_operations eccdev_fops = { |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
76 |
.owner = THIS_MODULE, |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
77 |
.open = eccdev_open, |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
78 |
.release = eccdev_release, |
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
79 |
.unlocked_ioctl = eccdev_ioctl, |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
80 |
.mmap = eccdev_mmap |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
81 |
}; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
82 |
|
1268 | 83 |
/** Callbacks for a virtual memory area retrieved with ecdevc_mmap(). |
84 |
*/ |
|
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
85 |
struct vm_operations_struct eccdev_vm_ops = { |
1272
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
86 |
#if LINUX_VERSION_CODE >= PAGE_FAULT_VERSION |
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
87 |
.fault = eccdev_vma_fault |
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
88 |
#else |
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
89 |
.nopage = eccdev_vma_nopage |
1272
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
90 |
#endif |
922
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 |
|
1242
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
95 |
/** Private data structure for file handles. |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
96 |
*/ |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
97 |
typedef struct { |
1268 | 98 |
ec_cdev_t *cdev; /**< Character device. */ |
99 |
unsigned int requested; /**< Master wac requested via this file handle. */ |
|
100 |
uint8_t *process_data; /**< Total process data area. */ |
|
101 |
size_t process_data_size; /**< Size of the \a process_data. */ |
|
1242
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
102 |
} ec_cdev_priv_t; |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
103 |
|
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
104 |
/*****************************************************************************/ |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
105 |
|
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
106 |
/** Constructor. |
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 |
* \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
|
109 |
*/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
110 |
int ec_cdev_init( |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
111 |
ec_cdev_t *cdev, /**< EtherCAT master character device. */ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
112 |
ec_master_t *master, /**< Parent master. */ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
113 |
dev_t dev_num /**< Device number. */ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
114 |
) |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
115 |
{ |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
116 |
int ret; |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
117 |
|
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
118 |
cdev->master = master; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
119 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
120 |
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
|
121 |
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
|
122 |
|
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
123 |
ret = cdev_add(&cdev->cdev, |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
124 |
MKDEV(MAJOR(dev_num), master->index), 1); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
125 |
if (ret) { |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
126 |
EC_ERR("Failed to add character device!\n"); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
127 |
} |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
128 |
|
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
129 |
return ret; |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
130 |
} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
131 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
132 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
133 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
134 |
/** Destructor. |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
135 |
*/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
136 |
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
|
137 |
{ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
138 |
cdev_del(&cdev->cdev); |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
139 |
} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
140 |
|
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
141 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
142 |
|
1108
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
143 |
/** Copies a string to an ioctl structure. |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
144 |
*/ |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
145 |
void ec_cdev_strcpy( |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
146 |
char *target, /**< Target. */ |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
147 |
const char *source /**< Source. */ |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
148 |
) |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
149 |
{ |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
150 |
if (source) { |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
151 |
strncpy(target, source, EC_IOCTL_STRING_SIZE); |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
152 |
target[EC_IOCTL_STRING_SIZE - 1] = 0; |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
153 |
} else { |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
154 |
target[0] = 0; |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
155 |
} |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
156 |
} |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
157 |
|
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
158 |
/*****************************************************************************/ |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
159 |
|
1826
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
160 |
/** Get module information. |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
161 |
*/ |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
162 |
int ec_cdev_ioctl_module( |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
163 |
unsigned long arg /**< Userspace address to store the results. */ |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
164 |
) |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
165 |
{ |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
166 |
ec_ioctl_module_t data; |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
167 |
|
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
168 |
data.ioctl_version_magic = EC_IOCTL_VERSION_MAGIC; |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
169 |
data.master_count = ec_master_count(); |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
170 |
|
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
171 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
172 |
return -EFAULT; |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
173 |
|
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
174 |
return 0; |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
175 |
} |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
176 |
|
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
177 |
/*****************************************************************************/ |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
178 |
|
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
179 |
/** Get master information. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
180 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
181 |
int ec_cdev_ioctl_master( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
182 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
183 |
unsigned long arg /**< Userspace address to store the results. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
184 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
185 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
186 |
ec_ioctl_master_t data; |
1851
a56bd34e20a1
Frame statistics in 'ethercat master' output.
Florian Pose <fp@igh-essen.com>
parents:
1839
diff
changeset
|
187 |
unsigned int i; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
188 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
189 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
190 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
191 |
data.slave_count = master->slave_count; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
192 |
data.config_count = ec_master_config_count(master); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
193 |
data.domain_count = ec_master_domain_count(master); |
1516
e3b09f847512
Fixed compiler error on --disable-eoe.
Florian Pose <fp@igh-essen.com>
parents:
1513
diff
changeset
|
194 |
#ifdef EC_EOE |
1485 | 195 |
data.eoe_handler_count = ec_master_eoe_handler_count(master); |
1516
e3b09f847512
Fixed compiler error on --disable-eoe.
Florian Pose <fp@igh-essen.com>
parents:
1513
diff
changeset
|
196 |
#endif |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
197 |
data.phase = (uint8_t) master->phase; |
1530
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1526
diff
changeset
|
198 |
data.active = (uint8_t) master->active; |
1447
846d75637c43
Added scan_busy flag to ioctl().
Florian Pose <fp@igh-essen.com>
parents:
1438
diff
changeset
|
199 |
data.scan_busy = master->scan_busy; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
200 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
201 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
202 |
if (down_interruptible(&master->device_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
203 |
return -EINTR; |
1415
9d1cdbf41247
Output reference clock and application time in 'ethercat Master'.
Florian Pose <fp@igh-essen.com>
parents:
1413
diff
changeset
|
204 |
|
1162
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
205 |
if (master->main_device.dev) { |
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
206 |
memcpy(data.devices[0].address, |
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
207 |
master->main_device.dev->dev_addr, ETH_ALEN); |
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
208 |
} else { |
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
209 |
memcpy(data.devices[0].address, master->main_mac, ETH_ALEN); |
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
210 |
} |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
211 |
data.devices[0].attached = master->main_device.dev ? 1 : 0; |
1401
96baef8a3162
Output link state in 'ethercat master'.
Florian Pose <fp@igh-essen.com>
parents:
1398
diff
changeset
|
212 |
data.devices[0].link_state = master->main_device.link_state ? 1 : 0; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
213 |
data.devices[0].tx_count = master->main_device.tx_count; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
214 |
data.devices[0].rx_count = master->main_device.rx_count; |
1857
ed8b490b5bc3
Output tx errors and tx rate in byte/s.
Florian Pose <fp@igh-essen.com>
parents:
1851
diff
changeset
|
215 |
data.devices[0].tx_bytes = master->main_device.tx_bytes; |
ed8b490b5bc3
Output tx errors and tx rate in byte/s.
Florian Pose <fp@igh-essen.com>
parents:
1851
diff
changeset
|
216 |
data.devices[0].tx_errors = master->main_device.tx_errors; |
1851
a56bd34e20a1
Frame statistics in 'ethercat master' output.
Florian Pose <fp@igh-essen.com>
parents:
1839
diff
changeset
|
217 |
for (i = 0; i < EC_RATE_COUNT; i++) { |
1857
ed8b490b5bc3
Output tx errors and tx rate in byte/s.
Florian Pose <fp@igh-essen.com>
parents:
1851
diff
changeset
|
218 |
data.devices[0].tx_frame_rates[i] = |
ed8b490b5bc3
Output tx errors and tx rate in byte/s.
Florian Pose <fp@igh-essen.com>
parents:
1851
diff
changeset
|
219 |
master->main_device.tx_frame_rates[i]; |
ed8b490b5bc3
Output tx errors and tx rate in byte/s.
Florian Pose <fp@igh-essen.com>
parents:
1851
diff
changeset
|
220 |
data.devices[0].tx_byte_rates[i] = |
ed8b490b5bc3
Output tx errors and tx rate in byte/s.
Florian Pose <fp@igh-essen.com>
parents:
1851
diff
changeset
|
221 |
master->main_device.tx_byte_rates[i]; |
1851
a56bd34e20a1
Frame statistics in 'ethercat master' output.
Florian Pose <fp@igh-essen.com>
parents:
1839
diff
changeset
|
222 |
data.devices[0].loss_rates[i] = master->main_device.loss_rates[i]; |
a56bd34e20a1
Frame statistics in 'ethercat master' output.
Florian Pose <fp@igh-essen.com>
parents:
1839
diff
changeset
|
223 |
} |
1162
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
224 |
|
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
225 |
if (master->backup_device.dev) { |
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
226 |
memcpy(data.devices[1].address, |
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
227 |
master->backup_device.dev->dev_addr, ETH_ALEN); |
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
228 |
} else { |
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
229 |
memcpy(data.devices[1].address, master->backup_mac, ETH_ALEN); |
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
230 |
} |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
231 |
data.devices[1].attached = master->backup_device.dev ? 1 : 0; |
1401
96baef8a3162
Output link state in 'ethercat master'.
Florian Pose <fp@igh-essen.com>
parents:
1398
diff
changeset
|
232 |
data.devices[1].link_state = master->backup_device.link_state ? 1 : 0; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
233 |
data.devices[1].tx_count = master->backup_device.tx_count; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
234 |
data.devices[1].rx_count = master->backup_device.rx_count; |
1857
ed8b490b5bc3
Output tx errors and tx rate in byte/s.
Florian Pose <fp@igh-essen.com>
parents:
1851
diff
changeset
|
235 |
data.devices[1].tx_bytes = master->backup_device.tx_bytes; |
ed8b490b5bc3
Output tx errors and tx rate in byte/s.
Florian Pose <fp@igh-essen.com>
parents:
1851
diff
changeset
|
236 |
data.devices[1].tx_errors = master->backup_device.tx_errors; |
1851
a56bd34e20a1
Frame statistics in 'ethercat master' output.
Florian Pose <fp@igh-essen.com>
parents:
1839
diff
changeset
|
237 |
for (i = 0; i < EC_RATE_COUNT; i++) { |
1857
ed8b490b5bc3
Output tx errors and tx rate in byte/s.
Florian Pose <fp@igh-essen.com>
parents:
1851
diff
changeset
|
238 |
data.devices[1].tx_frame_rates[i] = |
ed8b490b5bc3
Output tx errors and tx rate in byte/s.
Florian Pose <fp@igh-essen.com>
parents:
1851
diff
changeset
|
239 |
master->backup_device.tx_frame_rates[i]; |
ed8b490b5bc3
Output tx errors and tx rate in byte/s.
Florian Pose <fp@igh-essen.com>
parents:
1851
diff
changeset
|
240 |
data.devices[1].tx_byte_rates[i] = |
ed8b490b5bc3
Output tx errors and tx rate in byte/s.
Florian Pose <fp@igh-essen.com>
parents:
1851
diff
changeset
|
241 |
master->backup_device.tx_byte_rates[i]; |
1851
a56bd34e20a1
Frame statistics in 'ethercat master' output.
Florian Pose <fp@igh-essen.com>
parents:
1839
diff
changeset
|
242 |
data.devices[1].loss_rates[i] = master->backup_device.loss_rates[i]; |
a56bd34e20a1
Frame statistics in 'ethercat master' output.
Florian Pose <fp@igh-essen.com>
parents:
1839
diff
changeset
|
243 |
} |
1415
9d1cdbf41247
Output reference clock and application time in 'ethercat Master'.
Florian Pose <fp@igh-essen.com>
parents:
1413
diff
changeset
|
244 |
|
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
245 |
up(&master->device_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
246 |
|
1415
9d1cdbf41247
Output reference clock and application time in 'ethercat Master'.
Florian Pose <fp@igh-essen.com>
parents:
1413
diff
changeset
|
247 |
data.app_time = master->app_time; |
1435
f1df39224f49
Take ref clock address from dc_ref_clock pointer.
Florian Pose <fp@igh-essen.com>
parents:
1434
diff
changeset
|
248 |
data.ref_clock = |
f1df39224f49
Take ref clock address from dc_ref_clock pointer.
Florian Pose <fp@igh-essen.com>
parents:
1434
diff
changeset
|
249 |
master->dc_ref_clock ? master->dc_ref_clock->ring_position : 0xffff; |
1415
9d1cdbf41247
Output reference clock and application time in 'ethercat Master'.
Florian Pose <fp@igh-essen.com>
parents:
1413
diff
changeset
|
250 |
|
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
251 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
252 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
253 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
254 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
255 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
256 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
257 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
258 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
259 |
/** Get slave information. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
260 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
261 |
int ec_cdev_ioctl_slave( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
262 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
263 |
unsigned long arg /**< Userspace address to store the results. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
264 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
265 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
266 |
ec_ioctl_slave_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
267 |
const ec_slave_t *slave; |
1379
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
268 |
int i; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
269 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
270 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
271 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
272 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
273 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
274 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
275 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
276 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
277 |
if (!(slave = ec_master_find_slave_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
278 |
master, 0, data.position))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
279 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
280 |
EC_ERR("Slave %u does not exist!\n", data.position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
281 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
282 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
283 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
284 |
data.vendor_id = slave->sii.vendor_id; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
285 |
data.product_code = slave->sii.product_code; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
286 |
data.revision_number = slave->sii.revision_number; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
287 |
data.serial_number = slave->sii.serial_number; |
1909
ea3eb4c74c1b
Introduced effective_alias variable to separate reg12 alias from SII alias.
Florian Pose <fp@igh-essen.com>
parents:
1862
diff
changeset
|
288 |
data.alias = slave->effective_alias; |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1336
diff
changeset
|
289 |
data.boot_rx_mailbox_offset = slave->sii.boot_rx_mailbox_offset; |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1336
diff
changeset
|
290 |
data.boot_rx_mailbox_size = slave->sii.boot_rx_mailbox_size; |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1336
diff
changeset
|
291 |
data.boot_tx_mailbox_offset = slave->sii.boot_tx_mailbox_offset; |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1336
diff
changeset
|
292 |
data.boot_tx_mailbox_size = slave->sii.boot_tx_mailbox_size; |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1336
diff
changeset
|
293 |
data.std_rx_mailbox_offset = slave->sii.std_rx_mailbox_offset; |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1336
diff
changeset
|
294 |
data.std_rx_mailbox_size = slave->sii.std_rx_mailbox_size; |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1336
diff
changeset
|
295 |
data.std_tx_mailbox_offset = slave->sii.std_tx_mailbox_offset; |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1336
diff
changeset
|
296 |
data.std_tx_mailbox_size = slave->sii.std_tx_mailbox_size; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
297 |
data.mailbox_protocols = slave->sii.mailbox_protocols; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
298 |
data.has_general_category = slave->sii.has_general; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
299 |
data.coe_details = slave->sii.coe_details; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
300 |
data.general_flags = slave->sii.general_flags; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
301 |
data.current_on_ebus = slave->sii.current_on_ebus; |
1379
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
302 |
for (i = 0; i < EC_MAX_PORTS; i++) { |
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
303 |
data.ports[i].desc = slave->ports[i].desc; |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
304 |
data.ports[i].link.link_up = slave->ports[i].link.link_up; |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
305 |
data.ports[i].link.loop_closed = slave->ports[i].link.loop_closed; |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
306 |
data.ports[i].link.signal_detected = |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
307 |
slave->ports[i].link.signal_detected; |
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
308 |
data.ports[i].receive_time = slave->ports[i].receive_time; |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
309 |
if (slave->ports[i].next_slave) { |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
310 |
data.ports[i].next_slave = |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
311 |
slave->ports[i].next_slave->ring_position; |
1421 | 312 |
} else { |
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
313 |
data.ports[i].next_slave = 0xffff; |
1421 | 314 |
} |
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
315 |
data.ports[i].delay_to_next_dc = slave->ports[i].delay_to_next_dc; |
1379
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
316 |
} |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
317 |
data.fmmu_bit = slave->base_fmmu_bit_operation; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
318 |
data.dc_supported = slave->base_dc_supported; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
319 |
data.dc_range = slave->base_dc_range; |
1419
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1417
diff
changeset
|
320 |
data.has_dc_system_time = slave->has_dc_system_time; |
1426 | 321 |
data.transmission_delay = slave->transmission_delay; |
1148
1762296870bd
Renamed state field to al_state.
Florian Pose <fp@igh-essen.com>
parents:
1147
diff
changeset
|
322 |
data.al_state = slave->current_state; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
323 |
data.error_flag = slave->error_flag; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
324 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
325 |
data.sync_count = slave->sii.sync_count; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
326 |
data.sdo_count = ec_slave_sdo_count(slave); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
327 |
data.sii_nwords = slave->sii_nwords; |
1109
11ac4051db6b
Group/Image/Order strings in slave ioctl; order number as text content
Florian Pose <fp@igh-essen.com>
parents:
1108
diff
changeset
|
328 |
ec_cdev_strcpy(data.group, slave->sii.group); |
11ac4051db6b
Group/Image/Order strings in slave ioctl; order number as text content
Florian Pose <fp@igh-essen.com>
parents:
1108
diff
changeset
|
329 |
ec_cdev_strcpy(data.image, slave->sii.image); |
11ac4051db6b
Group/Image/Order strings in slave ioctl; order number as text content
Florian Pose <fp@igh-essen.com>
parents:
1108
diff
changeset
|
330 |
ec_cdev_strcpy(data.order, slave->sii.order); |
1108
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
331 |
ec_cdev_strcpy(data.name, slave->sii.name); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
332 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
333 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
334 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
335 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
336 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
337 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
338 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
339 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
340 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
341 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
342 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
343 |
/** Get slave sync manager information. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
344 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
345 |
int ec_cdev_ioctl_slave_sync( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
346 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
347 |
unsigned long arg /**< Userspace address to store the results. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
348 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
349 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
350 |
ec_ioctl_slave_sync_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
351 |
const ec_slave_t *slave; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
352 |
const ec_sync_t *sync; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
353 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
354 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
355 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
356 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
357 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
358 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
359 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
360 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
361 |
if (!(slave = ec_master_find_slave_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
362 |
master, 0, data.slave_position))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
363 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
364 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
365 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
366 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
367 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
368 |
if (data.sync_index >= slave->sii.sync_count) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
369 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
370 |
EC_ERR("Sync manager %u does not exist in slave %u!\n", |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
371 |
data.sync_index, data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
372 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
373 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
374 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
375 |
sync = &slave->sii.syncs[data.sync_index]; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
376 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
377 |
data.physical_start_address = sync->physical_start_address; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
378 |
data.default_size = sync->default_length; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
379 |
data.control_register = sync->control_register; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
380 |
data.enable = sync->enable; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
381 |
data.pdo_count = ec_pdo_list_count(&sync->pdos); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
382 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
383 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
384 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
385 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
386 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
387 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
388 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
389 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
390 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
391 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
392 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
393 |
/** Get slave sync manager PDO information. |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
394 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
395 |
int ec_cdev_ioctl_slave_sync_pdo( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
396 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
397 |
unsigned long arg /**< Userspace address to store the results. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
398 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
399 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
400 |
ec_ioctl_slave_sync_pdo_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
401 |
const ec_slave_t *slave; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
402 |
const ec_sync_t *sync; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
403 |
const ec_pdo_t *pdo; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
404 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
405 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
406 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
407 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
408 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
409 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
410 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
411 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
412 |
if (!(slave = ec_master_find_slave_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
413 |
master, 0, data.slave_position))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
414 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
415 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
416 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
417 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
418 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
419 |
if (data.sync_index >= slave->sii.sync_count) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
420 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
421 |
EC_ERR("Sync manager %u does not exist in slave %u!\n", |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
422 |
data.sync_index, data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
423 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
424 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
425 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
426 |
sync = &slave->sii.syncs[data.sync_index]; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
427 |
if (!(pdo = ec_pdo_list_find_pdo_by_pos_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
428 |
&sync->pdos, data.pdo_pos))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
429 |
up(&master->master_sem); |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
430 |
EC_ERR("Sync manager %u does not contain a PDO with " |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
431 |
"position %u in slave %u!\n", data.sync_index, |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
432 |
data.pdo_pos, data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
433 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
434 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
435 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
436 |
data.index = pdo->index; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
437 |
data.entry_count = ec_pdo_entry_count(pdo); |
1108
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
438 |
ec_cdev_strcpy(data.name, pdo->name); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
439 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
440 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
441 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
442 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
443 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
444 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
445 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
446 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
447 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
448 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
449 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
450 |
/** Get slave sync manager PDO entry information. |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
451 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
452 |
int ec_cdev_ioctl_slave_sync_pdo_entry( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
453 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
454 |
unsigned long arg /**< Userspace address to store the results. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
455 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
456 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
457 |
ec_ioctl_slave_sync_pdo_entry_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
458 |
const ec_slave_t *slave; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
459 |
const ec_sync_t *sync; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
460 |
const ec_pdo_t *pdo; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
461 |
const ec_pdo_entry_t *entry; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
462 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
463 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
464 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
465 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
466 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
467 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
468 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
469 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
470 |
if (!(slave = ec_master_find_slave_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
471 |
master, 0, data.slave_position))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
472 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
473 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
474 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
475 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
476 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
477 |
if (data.sync_index >= slave->sii.sync_count) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
478 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
479 |
EC_ERR("Sync manager %u does not exist in slave %u!\n", |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
480 |
data.sync_index, data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
481 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
482 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
483 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
484 |
sync = &slave->sii.syncs[data.sync_index]; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
485 |
if (!(pdo = ec_pdo_list_find_pdo_by_pos_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
486 |
&sync->pdos, data.pdo_pos))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
487 |
up(&master->master_sem); |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
488 |
EC_ERR("Sync manager %u does not contain a PDO with " |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
489 |
"position %u in slave %u!\n", data.sync_index, |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
490 |
data.pdo_pos, data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
491 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
492 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
493 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
494 |
if (!(entry = ec_pdo_find_entry_by_pos_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
495 |
pdo, data.entry_pos))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
496 |
up(&master->master_sem); |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
497 |
EC_ERR("PDO 0x%04X does not contain an entry with " |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
498 |
"position %u in slave %u!\n", data.pdo_pos, |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
499 |
data.entry_pos, data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
500 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
501 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
502 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
503 |
data.index = entry->index; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
504 |
data.subindex = entry->subindex; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
505 |
data.bit_length = entry->bit_length; |
1108
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
506 |
ec_cdev_strcpy(data.name, entry->name); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
507 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
508 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
509 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
510 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
511 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
512 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
513 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
514 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
515 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
516 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
517 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
518 |
/** Get domain information. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
519 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
520 |
int ec_cdev_ioctl_domain( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
521 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
522 |
unsigned long arg /**< Userspace address to store the results. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
523 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
524 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
525 |
ec_ioctl_domain_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
526 |
const ec_domain_t *domain; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
527 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
528 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
529 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
530 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
531 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
532 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
533 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
534 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
535 |
if (!(domain = ec_master_find_domain_const(master, data.index))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
536 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
537 |
EC_ERR("Domain %u does not exist!\n", data.index); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
538 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
539 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
540 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
541 |
data.data_size = domain->data_size; |
1984
02c8728bf9e4
Inplace I/O: fixed domain command (fmmu logical_address -> domain_address); show domain tx size
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1981
diff
changeset
|
542 |
data.tx_size = domain->tx_size; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
543 |
data.logical_base_address = domain->logical_base_address; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
544 |
data.working_counter = domain->working_counter; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
545 |
data.expected_working_counter = domain->expected_working_counter; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
546 |
data.fmmu_count = ec_domain_fmmu_count(domain); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
547 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
548 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
549 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
550 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
551 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
552 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
553 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
554 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
555 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
556 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
557 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
558 |
/** Get domain FMMU information. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
559 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
560 |
int ec_cdev_ioctl_domain_fmmu( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
561 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
562 |
unsigned long arg /**< Userspace address to store the results. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
563 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
564 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
565 |
ec_ioctl_domain_fmmu_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
566 |
const ec_domain_t *domain; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
567 |
const ec_fmmu_config_t *fmmu; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
568 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
569 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
570 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
571 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
572 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
573 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
574 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
575 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
576 |
if (!(domain = ec_master_find_domain_const(master, data.domain_index))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
577 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
578 |
EC_ERR("Domain %u does not exist!\n", data.domain_index); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
579 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
580 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
581 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
582 |
if (!(fmmu = ec_domain_find_fmmu(domain, data.fmmu_index))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
583 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
584 |
EC_ERR("Domain %u has less than %u fmmu configurations.\n", |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
585 |
data.domain_index, data.fmmu_index + 1); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
586 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
587 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
588 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
589 |
data.slave_config_alias = fmmu->sc->alias; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
590 |
data.slave_config_position = fmmu->sc->position; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
591 |
data.sync_index = fmmu->sync_index; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
592 |
data.dir = fmmu->dir; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
593 |
data.logical_address = fmmu->logical_start_address; |
1984
02c8728bf9e4
Inplace I/O: fixed domain command (fmmu logical_address -> domain_address); show domain tx size
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1981
diff
changeset
|
594 |
data.domain_address = fmmu->domain_address; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
595 |
data.data_size = fmmu->data_size; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
596 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
597 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
598 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
599 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
600 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
601 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
602 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
603 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
604 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
605 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
606 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
607 |
/** Get domain data. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
608 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
609 |
int ec_cdev_ioctl_domain_data( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
610 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
611 |
unsigned long arg /**< Userspace address to store the results. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
612 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
613 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
614 |
ec_ioctl_domain_data_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
615 |
const ec_domain_t *domain; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
616 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
617 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
618 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
619 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
620 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
621 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
622 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
623 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
624 |
if (!(domain = ec_master_find_domain_const(master, data.domain_index))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
625 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
626 |
EC_ERR("Domain %u does not exist!\n", data.domain_index); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
627 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
628 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
629 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
630 |
if (domain->data_size != data.data_size) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
631 |
up(&master->master_sem); |
1543
373cd456dc26
Avoid warnings on x86_64 platform. Thanks to Thomas Elste.
Florian Pose <fp@igh-essen.com>
parents:
1526
diff
changeset
|
632 |
EC_ERR("Data size mismatch %u/%zu!\n", |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
633 |
data.data_size, domain->data_size); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
634 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
635 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
636 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
637 |
if (copy_to_user((void __user *) data.target, domain->data, |
1223 | 638 |
domain->data_size)) { |
639 |
up(&master->master_sem); |
|
640 |
return -EFAULT; |
|
641 |
} |
|
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
642 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
643 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
644 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
645 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
646 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
647 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
648 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
649 |
/** Set master debug level. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
650 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
651 |
int ec_cdev_ioctl_master_debug( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
652 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
653 |
unsigned long arg /**< ioctl() argument. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
654 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
655 |
{ |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
656 |
return ec_master_debug_level(master, (unsigned int) arg); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
657 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
658 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
659 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
660 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
661 |
/** Set slave state. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
662 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
663 |
int ec_cdev_ioctl_slave_state( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
664 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
665 |
unsigned long arg /**< ioctl() argument. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
666 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
667 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
668 |
ec_ioctl_slave_state_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
669 |
ec_slave_t *slave; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
670 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
671 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
672 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
673 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
674 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
675 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
676 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
677 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
678 |
if (!(slave = ec_master_find_slave( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
679 |
master, 0, data.slave_position))) { |
1196 | 680 |
up(&master->master_sem); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
681 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
682 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
683 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
684 |
|
1150 | 685 |
ec_slave_request_state(slave, data.al_state); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
686 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
687 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
688 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
689 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
690 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
691 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
692 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
693 |
/** Get slave SDO information. |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
694 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
695 |
int ec_cdev_ioctl_slave_sdo( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
696 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
697 |
unsigned long arg /**< ioctl() argument. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
698 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
699 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
700 |
ec_ioctl_slave_sdo_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
701 |
const ec_slave_t *slave; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
702 |
const ec_sdo_t *sdo; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
703 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
704 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
705 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
706 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
707 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
708 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
709 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
710 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
711 |
if (!(slave = ec_master_find_slave_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
712 |
master, 0, data.slave_position))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
713 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
714 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
715 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
716 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
717 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
718 |
if (!(sdo = ec_slave_get_sdo_by_pos_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
719 |
slave, data.sdo_position))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
720 |
up(&master->master_sem); |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
721 |
EC_ERR("SDO %u does not exist in slave %u!\n", |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
722 |
data.sdo_position, data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
723 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
724 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
725 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
726 |
data.sdo_index = sdo->index; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
727 |
data.max_subindex = sdo->max_subindex; |
1108
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
728 |
ec_cdev_strcpy(data.name, sdo->name); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
729 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
730 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
731 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
732 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
733 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
734 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
735 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
736 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
737 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
738 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
739 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
740 |
/** Get slave SDO entry information. |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
741 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
742 |
int ec_cdev_ioctl_slave_sdo_entry( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
743 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
744 |
unsigned long arg /**< ioctl() argument. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
745 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
746 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
747 |
ec_ioctl_slave_sdo_entry_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
748 |
const ec_slave_t *slave; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
749 |
const ec_sdo_t *sdo; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
750 |
const ec_sdo_entry_t *entry; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
751 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
752 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
753 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
754 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
755 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
756 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
757 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
758 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
759 |
if (!(slave = ec_master_find_slave_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
760 |
master, 0, data.slave_position))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
761 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
762 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
763 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
764 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
765 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
766 |
if (data.sdo_spec <= 0) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
767 |
if (!(sdo = ec_slave_get_sdo_by_pos_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
768 |
slave, -data.sdo_spec))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
769 |
up(&master->master_sem); |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
770 |
EC_ERR("SDO %u does not exist in slave %u!\n", |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
771 |
-data.sdo_spec, data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
772 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
773 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
774 |
} else { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
775 |
if (!(sdo = ec_slave_get_sdo_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
776 |
slave, data.sdo_spec))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
777 |
up(&master->master_sem); |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
778 |
EC_ERR("SDO 0x%04X does not exist in slave %u!\n", |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
779 |
data.sdo_spec, data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
780 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
781 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
782 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
783 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
784 |
if (!(entry = ec_sdo_get_entry_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
785 |
sdo, data.sdo_entry_subindex))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
786 |
up(&master->master_sem); |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
787 |
EC_ERR("SDO entry 0x%04X:%02X does not exist " |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
788 |
"in slave %u!\n", sdo->index, |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
789 |
data.sdo_entry_subindex, data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
790 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
791 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
792 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
793 |
data.data_type = entry->data_type; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
794 |
data.bit_length = entry->bit_length; |
1382
cb2188d111f3
Read SDO entry access rights.
Florian Pose <fp@igh-essen.com>
parents:
1381
diff
changeset
|
795 |
data.read_access[EC_SDO_ENTRY_ACCESS_PREOP] = |
cb2188d111f3
Read SDO entry access rights.
Florian Pose <fp@igh-essen.com>
parents:
1381
diff
changeset
|
796 |
entry->read_access[EC_SDO_ENTRY_ACCESS_PREOP]; |
cb2188d111f3
Read SDO entry access rights.
Florian Pose <fp@igh-essen.com>
parents:
1381
diff
changeset
|
797 |
data.read_access[EC_SDO_ENTRY_ACCESS_SAFEOP] = |
cb2188d111f3
Read SDO entry access rights.
Florian Pose <fp@igh-essen.com>
parents:
1381
diff
changeset
|
798 |
entry->read_access[EC_SDO_ENTRY_ACCESS_SAFEOP]; |
cb2188d111f3
Read SDO entry access rights.
Florian Pose <fp@igh-essen.com>
parents:
1381
diff
changeset
|
799 |
data.read_access[EC_SDO_ENTRY_ACCESS_OP] = |
cb2188d111f3
Read SDO entry access rights.
Florian Pose <fp@igh-essen.com>
parents:
1381
diff
changeset
|
800 |
entry->read_access[EC_SDO_ENTRY_ACCESS_OP]; |
cb2188d111f3
Read SDO entry access rights.
Florian Pose <fp@igh-essen.com>
parents:
1381
diff
changeset
|
801 |
data.write_access[EC_SDO_ENTRY_ACCESS_PREOP] = |
cb2188d111f3
Read SDO entry access rights.
Florian Pose <fp@igh-essen.com>
parents:
1381
diff
changeset
|
802 |
entry->write_access[EC_SDO_ENTRY_ACCESS_PREOP]; |
cb2188d111f3
Read SDO entry access rights.
Florian Pose <fp@igh-essen.com>
parents:
1381
diff
changeset
|
803 |
data.write_access[EC_SDO_ENTRY_ACCESS_SAFEOP] = |
cb2188d111f3
Read SDO entry access rights.
Florian Pose <fp@igh-essen.com>
parents:
1381
diff
changeset
|
804 |
entry->write_access[EC_SDO_ENTRY_ACCESS_SAFEOP]; |
cb2188d111f3
Read SDO entry access rights.
Florian Pose <fp@igh-essen.com>
parents:
1381
diff
changeset
|
805 |
data.write_access[EC_SDO_ENTRY_ACCESS_OP] = |
cb2188d111f3
Read SDO entry access rights.
Florian Pose <fp@igh-essen.com>
parents:
1381
diff
changeset
|
806 |
entry->write_access[EC_SDO_ENTRY_ACCESS_OP]; |
1108
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
807 |
ec_cdev_strcpy(data.description, entry->description); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
808 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
809 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
810 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
811 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
812 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
813 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
814 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
815 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
816 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
817 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
818 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
819 |
/** Upload SDO. |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
820 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
821 |
int ec_cdev_ioctl_slave_sdo_upload( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
822 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
823 |
unsigned long arg /**< ioctl() argument. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
824 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
825 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
826 |
ec_ioctl_slave_sdo_upload_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
827 |
ec_master_sdo_request_t request; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
828 |
int retval; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
829 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
830 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
831 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
832 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
833 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
834 |
ec_sdo_request_init(&request.req); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
835 |
ec_sdo_request_address(&request.req, |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
836 |
data.sdo_index, data.sdo_entry_subindex); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
837 |
ecrt_sdo_request_read(&request.req); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
838 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
839 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
840 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
841 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
842 |
if (!(request.slave = ec_master_find_slave( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
843 |
master, 0, data.slave_position))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
844 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
845 |
ec_sdo_request_clear(&request.req); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
846 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
847 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
848 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
849 |
|
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1582
diff
changeset
|
850 |
if (master->debug_level) |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
851 |
EC_DBG("Schedule SDO upload request for slave %u\n", |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
852 |
request.slave->ring_position); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
853 |
// schedule request. |
1596
ea8d2b4ee742
Moved sdo request queue to slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1585
diff
changeset
|
854 |
list_add_tail(&request.list, &request.slave->slave_sdo_requests); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
855 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
856 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
857 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
858 |
// wait for processing through FSM |
1596
ea8d2b4ee742
Moved sdo request queue to slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1585
diff
changeset
|
859 |
if (wait_event_interruptible(request.slave->sdo_queue, |
1209 | 860 |
request.req.state != EC_INT_REQUEST_QUEUED)) { |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
861 |
// interrupted by signal |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
862 |
down(&master->master_sem); |
1209 | 863 |
if (request.req.state == EC_INT_REQUEST_QUEUED) { |
1582
7273aa7deb3d
Fixed SDO up/download kernel oops bug
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1535
diff
changeset
|
864 |
list_del(&request.list); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
865 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
866 |
ec_sdo_request_clear(&request.req); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
867 |
return -EINTR; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
868 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
869 |
// request already processing: interrupt not possible. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
870 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
871 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
872 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
873 |
// wait until master FSM has finished processing |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
874 |
wait_event(request.slave->sdo_queue, |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
875 |
request.req.state != EC_INT_REQUEST_BUSY); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
876 |
|
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1582
diff
changeset
|
877 |
if (master->debug_level) |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
878 |
EC_DBG("Scheduled SDO upload request for slave %u done\n", |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
879 |
request.slave->ring_position); |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1582
diff
changeset
|
880 |
|
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
881 |
data.abort_code = request.req.abort_code; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
882 |
|
1209 | 883 |
if (request.req.state != EC_INT_REQUEST_SUCCESS) { |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
884 |
data.data_size = 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
885 |
retval = -EIO; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
886 |
} else { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
887 |
if (request.req.data_size > data.target_size) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
888 |
EC_ERR("Buffer too small.\n"); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
889 |
ec_sdo_request_clear(&request.req); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
890 |
return -EOVERFLOW; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
891 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
892 |
data.data_size = request.req.data_size; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
893 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
894 |
if (copy_to_user((void __user *) data.target, |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
895 |
request.req.data, data.data_size)) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
896 |
ec_sdo_request_clear(&request.req); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
897 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
898 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
899 |
retval = 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
900 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
901 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
902 |
if (__copy_to_user((void __user *) arg, &data, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
903 |
retval = -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
904 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
905 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
906 |
ec_sdo_request_clear(&request.req); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
907 |
return retval; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
908 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
909 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
910 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
911 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
912 |
/** Download SDO. |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
913 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
914 |
int ec_cdev_ioctl_slave_sdo_download( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
915 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
916 |
unsigned long arg /**< ioctl() argument. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
917 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
918 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
919 |
ec_ioctl_slave_sdo_download_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
920 |
ec_master_sdo_request_t request; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
921 |
int retval; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
922 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
923 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
924 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
925 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
926 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
927 |
// copy data to download |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
928 |
if (!data.data_size) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
929 |
EC_ERR("Zero data size!\n"); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
930 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
931 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
932 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
933 |
ec_sdo_request_init(&request.req); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
934 |
ec_sdo_request_address(&request.req, |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
935 |
data.sdo_index, data.sdo_entry_subindex); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
936 |
if (ec_sdo_request_alloc(&request.req, data.data_size)) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
937 |
ec_sdo_request_clear(&request.req); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
938 |
return -ENOMEM; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
939 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
940 |
if (copy_from_user(request.req.data, |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
941 |
(void __user *) data.data, data.data_size)) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
942 |
ec_sdo_request_clear(&request.req); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
943 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
944 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
945 |
request.req.data_size = data.data_size; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
946 |
ecrt_sdo_request_write(&request.req); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
947 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
948 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
949 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
950 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
951 |
if (!(request.slave = ec_master_find_slave( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
952 |
master, 0, data.slave_position))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
953 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
954 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
955 |
ec_sdo_request_clear(&request.req); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
956 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
957 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
958 |
|
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1582
diff
changeset
|
959 |
if (master->debug_level) |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
960 |
EC_DBG("Schedule SDO download request for slave %u\n", |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
961 |
request.slave->ring_position); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
962 |
// schedule request. |
1596
ea8d2b4ee742
Moved sdo request queue to slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1585
diff
changeset
|
963 |
list_add_tail(&request.list, &request.slave->slave_sdo_requests); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
964 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
965 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
966 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
967 |
// wait for processing through FSM |
1596
ea8d2b4ee742
Moved sdo request queue to slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1585
diff
changeset
|
968 |
if (wait_event_interruptible(request.slave->sdo_queue, |
1209 | 969 |
request.req.state != EC_INT_REQUEST_QUEUED)) { |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
970 |
// interrupted by signal |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
971 |
down(&master->master_sem); |
1209 | 972 |
if (request.req.state == EC_INT_REQUEST_QUEUED) { |
1582
7273aa7deb3d
Fixed SDO up/download kernel oops bug
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1535
diff
changeset
|
973 |
list_del(&request.list); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
974 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
975 |
ec_sdo_request_clear(&request.req); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
976 |
return -EINTR; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
977 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
978 |
// request already processing: interrupt not possible. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
979 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
980 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
981 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
982 |
// wait until master FSM has finished processing |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
983 |
wait_event(request.slave->sdo_queue, |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
984 |
request.req.state != EC_INT_REQUEST_BUSY); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
985 |
|
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1582
diff
changeset
|
986 |
if (master->debug_level) |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
987 |
EC_DBG("Scheduled SDO download request for slave %u done\n", |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
988 |
request.slave->ring_position); |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1582
diff
changeset
|
989 |
|
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
990 |
data.abort_code = request.req.abort_code; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
991 |
|
1209 | 992 |
retval = request.req.state == EC_INT_REQUEST_SUCCESS ? 0 : -EIO; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
993 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
994 |
if (__copy_to_user((void __user *) arg, &data, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
995 |
retval = -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
996 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
997 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
998 |
ec_sdo_request_clear(&request.req); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
999 |
return retval; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1000 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1001 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1002 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1003 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1004 |
/** Read a slave's SII. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1005 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1006 |
int ec_cdev_ioctl_slave_sii_read( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1007 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1008 |
unsigned long arg /**< ioctl() argument. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1009 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1010 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1011 |
ec_ioctl_slave_sii_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1012 |
const ec_slave_t *slave; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1013 |
int retval; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1014 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1015 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1016 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1017 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1018 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
1019 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
1020 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1021 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1022 |
if (!(slave = ec_master_find_slave_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1023 |
master, 0, data.slave_position))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1024 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1025 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1026 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1027 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1028 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1029 |
if (!data.nwords |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1030 |
|| data.offset + data.nwords > slave->sii_nwords) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1031 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1032 |
EC_ERR("Invalid SII read offset/size %u/%u for slave " |
1543
373cd456dc26
Avoid warnings on x86_64 platform. Thanks to Thomas Elste.
Florian Pose <fp@igh-essen.com>
parents:
1526
diff
changeset
|
1033 |
"SII size %zu!\n", data.offset, |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1034 |
data.nwords, slave->sii_nwords); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1035 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1036 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1037 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1038 |
if (copy_to_user((void __user *) data.words, |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1039 |
slave->sii_words + data.offset, data.nwords * 2)) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1040 |
retval = -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1041 |
else |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1042 |
retval = 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1043 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1044 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1045 |
return retval; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1046 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1047 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1048 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1049 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1050 |
/** Write a slave's SII. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1051 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1052 |
int ec_cdev_ioctl_slave_sii_write( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1053 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1054 |
unsigned long arg /**< ioctl() argument. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1055 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1056 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1057 |
ec_ioctl_slave_sii_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1058 |
ec_slave_t *slave; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1059 |
unsigned int byte_size; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1060 |
uint16_t *words; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1061 |
ec_sii_write_request_t request; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1062 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1063 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1064 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1065 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1066 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1067 |
if (!data.nwords) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1068 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1069 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1070 |
byte_size = sizeof(uint16_t) * data.nwords; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1071 |
if (!(words = kmalloc(byte_size, GFP_KERNEL))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1072 |
EC_ERR("Failed to allocate %u bytes for SII contents.\n", |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1073 |
byte_size); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1074 |
return -ENOMEM; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1075 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1076 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1077 |
if (copy_from_user(words, |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1078 |
(void __user *) data.words, byte_size)) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1079 |
kfree(words); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1080 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1081 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1082 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
1083 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
1084 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1085 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1086 |
if (!(slave = ec_master_find_slave( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1087 |
master, 0, data.slave_position))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1088 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1089 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1090 |
kfree(words); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1091 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1092 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1093 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1094 |
// init SII write request |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1095 |
INIT_LIST_HEAD(&request.list); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1096 |
request.slave = slave; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1097 |
request.words = words; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1098 |
request.offset = data.offset; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1099 |
request.nwords = data.nwords; |
1209 | 1100 |
request.state = EC_INT_REQUEST_QUEUED; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1101 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1102 |
// schedule SII write request. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1103 |
list_add_tail(&request.list, &master->sii_requests); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1104 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1105 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1106 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1107 |
// wait for processing through FSM |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1108 |
if (wait_event_interruptible(master->sii_queue, |
1209 | 1109 |
request.state != EC_INT_REQUEST_QUEUED)) { |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1110 |
// interrupted by signal |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1111 |
down(&master->master_sem); |
1209 | 1112 |
if (request.state == EC_INT_REQUEST_QUEUED) { |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1113 |
// abort request |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1114 |
list_del(&request.list); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1115 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1116 |
kfree(words); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1117 |
return -EINTR; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1118 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1119 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1120 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1121 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1122 |
// wait until master FSM has finished processing |
1209 | 1123 |
wait_event(master->sii_queue, request.state != EC_INT_REQUEST_BUSY); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1124 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1125 |
kfree(words); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1126 |
|
1209 | 1127 |
return request.state == EC_INT_REQUEST_SUCCESS ? 0 : -EIO; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1128 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1129 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1130 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1131 |
|
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1382
diff
changeset
|
1132 |
/** Read a slave's registers. |
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1382
diff
changeset
|
1133 |
*/ |
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1382
diff
changeset
|
1134 |
int ec_cdev_ioctl_slave_reg_read( |
1200 | 1135 |
ec_master_t *master, /**< EtherCAT master. */ |
1136 |
unsigned long arg /**< ioctl() argument. */ |
|
1137 |
) |
|
1138 |
{ |
|
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1382
diff
changeset
|
1139 |
ec_ioctl_slave_reg_t data; |
1200 | 1140 |
ec_slave_t *slave; |
1141 |
uint8_t *contents; |
|
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1382
diff
changeset
|
1142 |
ec_reg_request_t request; |
1200 | 1143 |
|
1144 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
|
1145 |
return -EFAULT; |
|
1146 |
} |
|
1147 |
||
1148 |
if (!data.length) |
|
1149 |
return 0; |
|
1150 |
||
1151 |
if (!(contents = kmalloc(data.length, GFP_KERNEL))) { |
|
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
1152 |
EC_ERR("Failed to allocate %u bytes for register data.\n", |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
1153 |
data.length); |
1200 | 1154 |
return -ENOMEM; |
1155 |
} |
|
1156 |
||
1157 |
if (down_interruptible(&master->master_sem)) |
|
1158 |
return -EINTR; |
|
1159 |
||
1160 |
if (!(slave = ec_master_find_slave( |
|
1161 |
master, 0, data.slave_position))) { |
|
1162 |
up(&master->master_sem); |
|
1163 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
|
1164 |
return -EINVAL; |
|
1165 |
} |
|
1166 |
||
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1382
diff
changeset
|
1167 |
// init register request |
1200 | 1168 |
INIT_LIST_HEAD(&request.list); |
1169 |
request.slave = slave; |
|
1170 |
request.dir = EC_DIR_INPUT; |
|
1171 |
request.data = contents; |
|
1172 |
request.offset = data.offset; |
|
1173 |
request.length = data.length; |
|
1209 | 1174 |
request.state = EC_INT_REQUEST_QUEUED; |
1200 | 1175 |
|
1176 |
// schedule request. |
|
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1382
diff
changeset
|
1177 |
list_add_tail(&request.list, &master->reg_requests); |
1200 | 1178 |
|
1179 |
up(&master->master_sem); |
|
1180 |
||
1181 |
// wait for processing through FSM |
|
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1382
diff
changeset
|
1182 |
if (wait_event_interruptible(master->reg_queue, |
1209 | 1183 |
request.state != EC_INT_REQUEST_QUEUED)) { |
1200 | 1184 |
// interrupted by signal |
1185 |
down(&master->master_sem); |
|
1209 | 1186 |
if (request.state == EC_INT_REQUEST_QUEUED) { |
1200 | 1187 |
// abort request |
1188 |
list_del(&request.list); |
|
1189 |
up(&master->master_sem); |
|
1190 |
kfree(contents); |
|
1191 |
return -EINTR; |
|
1192 |
} |
|
1193 |
up(&master->master_sem); |
|
1194 |
} |
|
1195 |
||
1196 |
// wait until master FSM has finished processing |
|
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1382
diff
changeset
|
1197 |
wait_event(master->reg_queue, request.state != EC_INT_REQUEST_BUSY); |
1209 | 1198 |
|
1199 |
if (request.state == EC_INT_REQUEST_SUCCESS) { |
|
1200 | 1200 |
if (copy_to_user((void __user *) data.data, contents, data.length)) |
1201 |
return -EFAULT; |
|
1202 |
} |
|
1203 |
kfree(contents); |
|
1204 |
||
1209 | 1205 |
return request.state == EC_INT_REQUEST_SUCCESS ? 0 : -EIO; |
1200 | 1206 |
} |
1207 |
||
1208 |
/*****************************************************************************/ |
|
1209 |
||
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1382
diff
changeset
|
1210 |
/** Write a slave's registers. |
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1382
diff
changeset
|
1211 |
*/ |
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1382
diff
changeset
|
1212 |
int ec_cdev_ioctl_slave_reg_write( |
1200 | 1213 |
ec_master_t *master, /**< EtherCAT master. */ |
1214 |
unsigned long arg /**< ioctl() argument. */ |
|
1215 |
) |
|
1216 |
{ |
|
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1382
diff
changeset
|
1217 |
ec_ioctl_slave_reg_t data; |
1200 | 1218 |
ec_slave_t *slave; |
1219 |
uint8_t *contents; |
|
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1382
diff
changeset
|
1220 |
ec_reg_request_t request; |
1200 | 1221 |
|
1222 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
|
1223 |
return -EFAULT; |
|
1224 |
} |
|
1225 |
||
1226 |
if (!data.length) |
|
1227 |
return 0; |
|
1228 |
||
1229 |
if (!(contents = kmalloc(data.length, GFP_KERNEL))) { |
|
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
1230 |
EC_ERR("Failed to allocate %u bytes for register data.\n", |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
1231 |
data.length); |
1200 | 1232 |
return -ENOMEM; |
1233 |
} |
|
1234 |
||
1235 |
if (copy_from_user(contents, (void __user *) data.data, data.length)) { |
|
1236 |
kfree(contents); |
|
1237 |
return -EFAULT; |
|
1238 |
} |
|
1239 |
||
1240 |
if (down_interruptible(&master->master_sem)) |
|
1241 |
return -EINTR; |
|
1242 |
||
1243 |
if (!(slave = ec_master_find_slave( |
|
1244 |
master, 0, data.slave_position))) { |
|
1245 |
up(&master->master_sem); |
|
1246 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
|
1247 |
kfree(contents); |
|
1248 |
return -EINVAL; |
|
1249 |
} |
|
1250 |
||
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1382
diff
changeset
|
1251 |
// init register request |
1200 | 1252 |
INIT_LIST_HEAD(&request.list); |
1253 |
request.slave = slave; |
|
1254 |
request.dir = EC_DIR_OUTPUT; |
|
1255 |
request.data = contents; |
|
1256 |
request.offset = data.offset; |
|
1257 |
request.length = data.length; |
|
1209 | 1258 |
request.state = EC_INT_REQUEST_QUEUED; |
1200 | 1259 |
|
1260 |
// schedule request. |
|
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1382
diff
changeset
|
1261 |
list_add_tail(&request.list, &master->reg_requests); |
1200 | 1262 |
|
1263 |
up(&master->master_sem); |
|
1264 |
||
1265 |
// wait for processing through FSM |
|
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1382
diff
changeset
|
1266 |
if (wait_event_interruptible(master->reg_queue, |
1209 | 1267 |
request.state != EC_INT_REQUEST_QUEUED)) { |
1200 | 1268 |
// interrupted by signal |
1269 |
down(&master->master_sem); |
|
1209 | 1270 |
if (request.state == EC_INT_REQUEST_QUEUED) { |
1200 | 1271 |
// abort request |
1272 |
list_del(&request.list); |
|
1273 |
up(&master->master_sem); |
|
1274 |
kfree(contents); |
|
1275 |
return -EINTR; |
|
1276 |
} |
|
1277 |
up(&master->master_sem); |
|
1278 |
} |
|
1279 |
||
1280 |
// wait until master FSM has finished processing |
|
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1382
diff
changeset
|
1281 |
wait_event(master->reg_queue, request.state != EC_INT_REQUEST_BUSY); |
1200 | 1282 |
|
1283 |
kfree(contents); |
|
1284 |
||
1209 | 1285 |
return request.state == EC_INT_REQUEST_SUCCESS ? 0 : -EIO; |
1200 | 1286 |
} |
1287 |
||
1288 |
/*****************************************************************************/ |
|
1289 |
||
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1290 |
/** Get slave configuration information. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1291 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1292 |
int ec_cdev_ioctl_config( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1293 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1294 |
unsigned long arg /**< ioctl() argument. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1295 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1296 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1297 |
ec_ioctl_config_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1298 |
const ec_slave_config_t *sc; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1299 |
uint8_t i; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1300 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1301 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1302 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1303 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1304 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
1305 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
1306 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1307 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1308 |
if (!(sc = ec_master_get_config_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1309 |
master, data.config_index))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1310 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1311 |
EC_ERR("Slave config %u does not exist!\n", |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1312 |
data.config_index); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1313 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1314 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1315 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1316 |
data.alias = sc->alias; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1317 |
data.position = sc->position; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1318 |
data.vendor_id = sc->vendor_id; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1319 |
data.product_code = sc->product_code; |
1082
ff06c58e269c
Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
1320 |
for (i = 0; i < EC_MAX_SYNC_MANAGERS; i++) { |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1321 |
data.syncs[i].dir = sc->sync_configs[i].dir; |
1518
ab5694a51826
Output watchdog configuration in ethercat config.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
1322 |
data.syncs[i].watchdog_mode = sc->sync_configs[i].watchdog_mode; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1323 |
data.syncs[i].pdo_count = |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1324 |
ec_pdo_list_count(&sc->sync_configs[i].pdos); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1325 |
} |
1518
ab5694a51826
Output watchdog configuration in ethercat config.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
1326 |
data.watchdog_divider = sc->watchdog_divider; |
ab5694a51826
Output watchdog configuration in ethercat config.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
1327 |
data.watchdog_intervals = sc->watchdog_intervals; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1328 |
data.sdo_count = ec_slave_config_sdo_count(sc); |
1147
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1109
diff
changeset
|
1329 |
data.slave_position = sc->slave ? sc->slave->ring_position : -1; |
1455
aa18fcfe0fd1
Output DC config in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1454
diff
changeset
|
1330 |
data.dc_assign_activate = sc->dc_assign_activate; |
aa18fcfe0fd1
Output DC config in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1454
diff
changeset
|
1331 |
for (i = 0; i < EC_SYNC_SIGNAL_COUNT; i++) { |
aa18fcfe0fd1
Output DC config in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1454
diff
changeset
|
1332 |
data.dc_sync[i] = sc->dc_sync[i]; |
aa18fcfe0fd1
Output DC config in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1454
diff
changeset
|
1333 |
} |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1334 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1335 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1336 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1337 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1338 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1339 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1340 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1341 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1342 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1343 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1344 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
1345 |
/** Get slave configuration PDO information. |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1346 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1347 |
int ec_cdev_ioctl_config_pdo( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1348 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1349 |
unsigned long arg /**< ioctl() argument. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1350 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1351 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1352 |
ec_ioctl_config_pdo_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1353 |
const ec_slave_config_t *sc; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1354 |
const ec_pdo_t *pdo; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1355 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1356 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1357 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1358 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1359 |
|
1082
ff06c58e269c
Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
1360 |
if (data.sync_index >= EC_MAX_SYNC_MANAGERS) { |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1361 |
EC_ERR("Invalid sync manager index %u!\n", |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1362 |
data.sync_index); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1363 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1364 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1365 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
1366 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
1367 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1368 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1369 |
if (!(sc = ec_master_get_config_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1370 |
master, data.config_index))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1371 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1372 |
EC_ERR("Slave config %u does not exist!\n", |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1373 |
data.config_index); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1374 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1375 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1376 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1377 |
if (!(pdo = ec_pdo_list_find_pdo_by_pos_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1378 |
&sc->sync_configs[data.sync_index].pdos, |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1379 |
data.pdo_pos))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1380 |
up(&master->master_sem); |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
1381 |
EC_ERR("Invalid PDO position!\n"); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1382 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1383 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1384 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1385 |
data.index = pdo->index; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1386 |
data.entry_count = ec_pdo_entry_count(pdo); |
1108
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
1387 |
ec_cdev_strcpy(data.name, pdo->name); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1388 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1389 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1390 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1391 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1392 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1393 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1394 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1395 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1396 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1397 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1398 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
1399 |
/** Get slave configuration PDO entry information. |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1400 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1401 |
int ec_cdev_ioctl_config_pdo_entry( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1402 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1403 |
unsigned long arg /**< ioctl() argument. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1404 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1405 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1406 |
ec_ioctl_config_pdo_entry_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1407 |
const ec_slave_config_t *sc; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1408 |
const ec_pdo_t *pdo; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1409 |
const ec_pdo_entry_t *entry; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1410 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1411 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1412 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1413 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1414 |
|
1082
ff06c58e269c
Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
1415 |
if (data.sync_index >= EC_MAX_SYNC_MANAGERS) { |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1416 |
EC_ERR("Invalid sync manager index %u!\n", |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1417 |
data.sync_index); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1418 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1419 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1420 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
1421 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
1422 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1423 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1424 |
if (!(sc = ec_master_get_config_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1425 |
master, data.config_index))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1426 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1427 |
EC_ERR("Slave config %u does not exist!\n", |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1428 |
data.config_index); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1429 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1430 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1431 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1432 |
if (!(pdo = ec_pdo_list_find_pdo_by_pos_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1433 |
&sc->sync_configs[data.sync_index].pdos, |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1434 |
data.pdo_pos))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1435 |
up(&master->master_sem); |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
1436 |
EC_ERR("Invalid PDO position!\n"); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1437 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1438 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1439 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1440 |
if (!(entry = ec_pdo_find_entry_by_pos_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1441 |
pdo, data.entry_pos))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1442 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1443 |
EC_ERR("Entry not found!\n"); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1444 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1445 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1446 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1447 |
data.index = entry->index; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1448 |
data.subindex = entry->subindex; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1449 |
data.bit_length = entry->bit_length; |
1108
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
1450 |
ec_cdev_strcpy(data.name, entry->name); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1451 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1452 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1453 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1454 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1455 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1456 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1457 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1458 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1459 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1460 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1461 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
1462 |
/** Get slave configuration SDO information. |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1463 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1464 |
int ec_cdev_ioctl_config_sdo( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1465 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1466 |
unsigned long arg /**< ioctl() argument. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1467 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1468 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1469 |
ec_ioctl_config_sdo_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1470 |
const ec_slave_config_t *sc; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1471 |
const ec_sdo_request_t *req; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1472 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1473 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1474 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1475 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1476 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
1477 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
1478 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1479 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1480 |
if (!(sc = ec_master_get_config_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1481 |
master, data.config_index))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1482 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1483 |
EC_ERR("Slave config %u does not exist!\n", |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1484 |
data.config_index); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1485 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1486 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1487 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1488 |
if (!(req = ec_slave_config_get_sdo_by_pos_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1489 |
sc, data.sdo_pos))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1490 |
up(&master->master_sem); |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
1491 |
EC_ERR("Invalid SDO position!\n"); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1492 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1493 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1494 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1495 |
data.index = req->index; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1496 |
data.subindex = req->subindex; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1497 |
data.size = req->data_size; |
1526
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1518
diff
changeset
|
1498 |
memcpy(&data.data, req->data, |
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1518
diff
changeset
|
1499 |
min((u32) data.size, (u32) EC_MAX_SDO_DATA_SIZE)); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1500 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1501 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1502 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1503 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1504 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1505 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1506 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1507 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1508 |
|
1242
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1509 |
/*****************************************************************************/ |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1510 |
|
1516
e3b09f847512
Fixed compiler error on --disable-eoe.
Florian Pose <fp@igh-essen.com>
parents:
1513
diff
changeset
|
1511 |
#ifdef EC_EOE |
e3b09f847512
Fixed compiler error on --disable-eoe.
Florian Pose <fp@igh-essen.com>
parents:
1513
diff
changeset
|
1512 |
|
1485 | 1513 |
/** Get EoE handler information. |
1514 |
*/ |
|
1515 |
int ec_cdev_ioctl_eoe_handler( |
|
1516 |
ec_master_t *master, /**< EtherCAT master. */ |
|
1517 |
unsigned long arg /**< ioctl() argument. */ |
|
1518 |
) |
|
1519 |
{ |
|
1520 |
ec_ioctl_eoe_handler_t data; |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1521 |
const ec_eoe_t *eoe; |
1485 | 1522 |
|
1523 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
|
1524 |
return -EFAULT; |
|
1525 |
} |
|
1526 |
||
1527 |
if (down_interruptible(&master->master_sem)) |
|
1528 |
return -EINTR; |
|
1529 |
||
1530 |
if (!(eoe = ec_master_get_eoe_handler_const(master, data.eoe_index))) { |
|
1531 |
up(&master->master_sem); |
|
1532 |
EC_ERR("EoE handler %u does not exist!\n", data.eoe_index); |
|
1533 |
return -EINVAL; |
|
1534 |
} |
|
1535 |
||
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1536 |
if (eoe->slave) { |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1537 |
data.slave_position = eoe->slave->ring_position; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1538 |
} else { |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1539 |
data.slave_position = 0xffff; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1540 |
} |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1541 |
snprintf(data.name, EC_DATAGRAM_NAME_SIZE, eoe->dev->name); |
1485 | 1542 |
data.open = eoe->opened; |
1543 |
data.rx_bytes = eoe->stats.tx_bytes; |
|
1544 |
data.rx_rate = eoe->tx_rate; |
|
1545 |
data.tx_bytes = eoe->stats.rx_bytes; |
|
1546 |
data.tx_rate = eoe->tx_rate; |
|
1547 |
data.tx_queued_frames = eoe->tx_queued_frames; |
|
1548 |
data.tx_queue_size = eoe->tx_queue_size; |
|
1549 |
||
1550 |
up(&master->master_sem); |
|
1551 |
||
1552 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
|
1553 |
return -EFAULT; |
|
1554 |
||
1555 |
return 0; |
|
1556 |
} |
|
1557 |
||
1516
e3b09f847512
Fixed compiler error on --disable-eoe.
Florian Pose <fp@igh-essen.com>
parents:
1513
diff
changeset
|
1558 |
#endif |
e3b09f847512
Fixed compiler error on --disable-eoe.
Florian Pose <fp@igh-essen.com>
parents:
1513
diff
changeset
|
1559 |
|
1485 | 1560 |
/*****************************************************************************/ |
1561 |
||
1242
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1562 |
/** Request the master from userspace. |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1563 |
*/ |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1564 |
int ec_cdev_ioctl_request( |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1565 |
ec_master_t *master, /**< EtherCAT master. */ |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1566 |
unsigned long arg, /**< ioctl() argument. */ |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1567 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1568 |
) |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1569 |
{ |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1570 |
ec_master_t *m; |
1242
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1571 |
int ret = 0; |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1572 |
|
1312
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1284
diff
changeset
|
1573 |
m = ecrt_request_master_err(master->index); |
1244
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1574 |
if (IS_ERR(m)) { |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1575 |
ret = PTR_ERR(m); |
1242
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1576 |
} else { |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1577 |
priv->requested = 1; |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1578 |
} |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1579 |
|
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1580 |
return ret; |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1581 |
} |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1582 |
|
1244
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1583 |
/*****************************************************************************/ |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1584 |
|
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1585 |
/** Create a domain. |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1586 |
*/ |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1587 |
int ec_cdev_ioctl_create_domain( |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1588 |
ec_master_t *master, /**< EtherCAT master. */ |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1589 |
unsigned long arg, /**< ioctl() argument. */ |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1590 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1591 |
) |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1592 |
{ |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1593 |
ec_domain_t *domain; |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1594 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1595 |
if (unlikely(!priv->requested)) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1596 |
return -EPERM; |
1244
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1597 |
|
1312
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1284
diff
changeset
|
1598 |
domain = ecrt_master_create_domain_err(master); |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1284
diff
changeset
|
1599 |
if (IS_ERR(domain)) |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1284
diff
changeset
|
1600 |
return PTR_ERR(domain); |
1244
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1601 |
|
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1602 |
return domain->index; |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1603 |
} |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1604 |
|
1246
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1605 |
/*****************************************************************************/ |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1606 |
|
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1607 |
/** Create a slave configuration. |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1608 |
*/ |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1609 |
int ec_cdev_ioctl_create_slave_config( |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1610 |
ec_master_t *master, /**< EtherCAT master. */ |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1611 |
unsigned long arg, /**< ioctl() argument. */ |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1612 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1613 |
) |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1614 |
{ |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1615 |
ec_ioctl_config_t data; |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1616 |
ec_slave_config_t *sc, *entry; |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1617 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1618 |
if (unlikely(!priv->requested)) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1619 |
return -EPERM; |
1246
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1620 |
|
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1621 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1622 |
return -EFAULT; |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1623 |
} |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1624 |
|
1312
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1284
diff
changeset
|
1625 |
sc = ecrt_master_slave_config_err(master, data.alias, data.position, |
1246
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1626 |
data.vendor_id, data.product_code); |
1312
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1284
diff
changeset
|
1627 |
if (IS_ERR(sc)) |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1284
diff
changeset
|
1628 |
return PTR_ERR(sc); |
1246
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1629 |
|
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1630 |
data.config_index = 0; |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1631 |
|
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1632 |
if (down_interruptible(&master->master_sem)) |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1633 |
return -EINTR; |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1634 |
|
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1635 |
list_for_each_entry(entry, &master->configs, list) { |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1636 |
if (entry == sc) |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1637 |
break; |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1638 |
data.config_index++; |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1639 |
} |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1640 |
|
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1641 |
up(&master->master_sem); |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1642 |
|
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1643 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1644 |
return -EFAULT; |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1645 |
|
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1646 |
return 0; |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1647 |
} |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1648 |
|
1247
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1649 |
/*****************************************************************************/ |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1650 |
|
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1651 |
/** Activates the master. |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1652 |
*/ |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1653 |
int ec_cdev_ioctl_activate( |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1654 |
ec_master_t *master, /**< EtherCAT master. */ |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1655 |
unsigned long arg, /**< ioctl() argument. */ |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1656 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1657 |
) |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1658 |
{ |
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1659 |
ec_domain_t *domain; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1660 |
off_t offset; |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
1661 |
int ret; |
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1662 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1663 |
if (unlikely(!priv->requested)) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1664 |
return -EPERM; |
1247
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1665 |
|
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1666 |
/* Get the sum of the domains' process data sizes. */ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1667 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1668 |
priv->process_data_size = 0; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1669 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1670 |
if (down_interruptible(&master->master_sem)) |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1671 |
return -EINTR; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1672 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1673 |
list_for_each_entry(domain, &master->domains, list) { |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1674 |
priv->process_data_size += ecrt_domain_size(domain); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1675 |
} |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1676 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1677 |
up(&master->master_sem); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1678 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1679 |
if (priv->process_data_size) { |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1680 |
priv->process_data = vmalloc(priv->process_data_size); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1681 |
if (!priv->process_data) { |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1682 |
priv->process_data_size = 0; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1683 |
return -ENOMEM; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1684 |
} |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1685 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1686 |
/* Set the memory as external process data memory for the domains. */ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1687 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1688 |
offset = 0; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1689 |
list_for_each_entry(domain, &master->domains, list) { |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1690 |
ecrt_domain_external_memory(domain, priv->process_data + offset); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1691 |
offset += ecrt_domain_size(domain); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1692 |
} |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1693 |
} |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1694 |
|
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
1695 |
ecrt_master_callbacks(master, ec_master_internal_send_cb, |
1513
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1509
diff
changeset
|
1696 |
ec_master_internal_receive_cb, master); |
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
1697 |
|
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
1698 |
ret = ecrt_master_activate(master); |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
1699 |
if (ret < 0) |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
1700 |
return ret; |
1247
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1701 |
|
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1702 |
if (copy_to_user((void __user *) arg, |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1703 |
&priv->process_data_size, sizeof(size_t))) |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1704 |
return -EFAULT; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1705 |
|
1247
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1706 |
return 0; |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1707 |
} |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1708 |
|
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1709 |
/*****************************************************************************/ |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1710 |
|
1531
6c5478400e28
Implemented ecrt_master_deactivate() in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
1711 |
/** Deactivates the master. |
6c5478400e28
Implemented ecrt_master_deactivate() in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
1712 |
*/ |
6c5478400e28
Implemented ecrt_master_deactivate() in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
1713 |
int ec_cdev_ioctl_deactivate( |
6c5478400e28
Implemented ecrt_master_deactivate() in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
1714 |
ec_master_t *master, /**< EtherCAT master. */ |
6c5478400e28
Implemented ecrt_master_deactivate() in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
1715 |
unsigned long arg, /**< ioctl() argument. */ |
6c5478400e28
Implemented ecrt_master_deactivate() in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
1716 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
6c5478400e28
Implemented ecrt_master_deactivate() in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
1717 |
) |
6c5478400e28
Implemented ecrt_master_deactivate() in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
1718 |
{ |
6c5478400e28
Implemented ecrt_master_deactivate() in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
1719 |
if (unlikely(!priv->requested)) |
6c5478400e28
Implemented ecrt_master_deactivate() in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
1720 |
return -EPERM; |
6c5478400e28
Implemented ecrt_master_deactivate() in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
1721 |
|
6c5478400e28
Implemented ecrt_master_deactivate() in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
1722 |
ecrt_master_deactivate(master); |
6c5478400e28
Implemented ecrt_master_deactivate() in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
1723 |
return 0; |
6c5478400e28
Implemented ecrt_master_deactivate() in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
1724 |
} |
6c5478400e28
Implemented ecrt_master_deactivate() in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
1725 |
|
1585
1f640e321ee4
ecrt_master_set_max_cycle_size: limit SDO traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1583
diff
changeset
|
1726 |
|
1f640e321ee4
ecrt_master_set_max_cycle_size: limit SDO traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1583
diff
changeset
|
1727 |
/*****************************************************************************/ |
1f640e321ee4
ecrt_master_set_max_cycle_size: limit SDO traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1583
diff
changeset
|
1728 |
|
1f640e321ee4
ecrt_master_set_max_cycle_size: limit SDO traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1583
diff
changeset
|
1729 |
/** Set max. number of databytes in a cycle |
1f640e321ee4
ecrt_master_set_max_cycle_size: limit SDO traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1583
diff
changeset
|
1730 |
*/ |
1600
e36c92cf58a9
use given send interval to limit SDO/FOE traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1597
diff
changeset
|
1731 |
int ec_cdev_ioctl_set_send_interval( |
e36c92cf58a9
use given send interval to limit SDO/FOE traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1597
diff
changeset
|
1732 |
ec_master_t *master, /**< EtherCAT master. */ |
e36c92cf58a9
use given send interval to limit SDO/FOE traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1597
diff
changeset
|
1733 |
unsigned long arg, /**< ioctl() argument. */ |
e36c92cf58a9
use given send interval to limit SDO/FOE traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1597
diff
changeset
|
1734 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
e36c92cf58a9
use given send interval to limit SDO/FOE traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1597
diff
changeset
|
1735 |
) |
e36c92cf58a9
use given send interval to limit SDO/FOE traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1597
diff
changeset
|
1736 |
{ |
1804 | 1737 |
size_t send_interval; |
1738 |
||
1739 |
if (copy_from_user(&send_interval, (void __user *) arg, |
|
1740 |
sizeof(send_interval))) { |
|
1741 |
return -EFAULT; |
|
1742 |
} |
|
1743 |
||
1744 |
if (down_interruptible(&master->master_sem)) |
|
1745 |
return -EINTR; |
|
1746 |
ec_master_set_send_interval(master,send_interval); |
|
1585
1f640e321ee4
ecrt_master_set_max_cycle_size: limit SDO traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1583
diff
changeset
|
1747 |
up(&master->master_sem); |
1f640e321ee4
ecrt_master_set_max_cycle_size: limit SDO traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1583
diff
changeset
|
1748 |
|
1f640e321ee4
ecrt_master_set_max_cycle_size: limit SDO traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1583
diff
changeset
|
1749 |
return 0; |
1f640e321ee4
ecrt_master_set_max_cycle_size: limit SDO traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1583
diff
changeset
|
1750 |
} |
1f640e321ee4
ecrt_master_set_max_cycle_size: limit SDO traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1583
diff
changeset
|
1751 |
|
1f640e321ee4
ecrt_master_set_max_cycle_size: limit SDO traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1583
diff
changeset
|
1752 |
|
1531
6c5478400e28
Implemented ecrt_master_deactivate() in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
1753 |
/*****************************************************************************/ |
6c5478400e28
Implemented ecrt_master_deactivate() in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
1754 |
|
1247
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1755 |
/** Send frames. |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1756 |
*/ |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1757 |
int ec_cdev_ioctl_send( |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1758 |
ec_master_t *master, /**< EtherCAT master. */ |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1759 |
unsigned long arg, /**< ioctl() argument. */ |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1760 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1761 |
) |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1762 |
{ |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1763 |
if (unlikely(!priv->requested)) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1764 |
return -EPERM; |
1247
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1765 |
|
1489
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1766 |
down(&master->io_sem); |
1247
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1767 |
ecrt_master_send(master); |
1489
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1768 |
up(&master->io_sem); |
1247
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1769 |
return 0; |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1770 |
} |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1771 |
|
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1772 |
/*****************************************************************************/ |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1773 |
|
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1774 |
/** Receive frames. |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1775 |
*/ |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1776 |
int ec_cdev_ioctl_receive( |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1777 |
ec_master_t *master, /**< EtherCAT master. */ |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1778 |
unsigned long arg, /**< ioctl() argument. */ |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1779 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1780 |
) |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1781 |
{ |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1782 |
if (unlikely(!priv->requested)) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1783 |
return -EPERM; |
1247
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1784 |
|
1489
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1785 |
down(&master->io_sem); |
1247
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1786 |
ecrt_master_receive(master); |
1489
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1787 |
up(&master->io_sem); |
1247
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1788 |
return 0; |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1789 |
} |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1790 |
|
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1791 |
/*****************************************************************************/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1792 |
|
1259
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1793 |
/** Get the master state. |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1794 |
*/ |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1795 |
int ec_cdev_ioctl_master_state( |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1796 |
ec_master_t *master, /**< EtherCAT master. */ |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1797 |
unsigned long arg, /**< ioctl() argument. */ |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1798 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1799 |
) |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1800 |
{ |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1801 |
ec_master_state_t data; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1802 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1803 |
if (unlikely(!priv->requested)) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1804 |
return -EPERM; |
1259
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1805 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1806 |
ecrt_master_state(master, &data); |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1807 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1808 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1809 |
return -EFAULT; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1810 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1811 |
return 0; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1812 |
} |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1813 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1814 |
/*****************************************************************************/ |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1815 |
|
1978
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1862
diff
changeset
|
1816 |
/** Get the master state of all configured slaves. |
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1862
diff
changeset
|
1817 |
*/ |
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1862
diff
changeset
|
1818 |
int ec_cdev_ioctl_master_sc_state( |
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1862
diff
changeset
|
1819 |
ec_master_t *master, /**< EtherCAT master. */ |
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1862
diff
changeset
|
1820 |
unsigned long arg, /**< ioctl() argument. */ |
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1862
diff
changeset
|
1821 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1862
diff
changeset
|
1822 |
) |
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1862
diff
changeset
|
1823 |
{ |
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1862
diff
changeset
|
1824 |
ec_master_state_t data; |
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1862
diff
changeset
|
1825 |
|
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1862
diff
changeset
|
1826 |
if (unlikely(!priv->requested)) |
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1862
diff
changeset
|
1827 |
return -EPERM; |
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1862
diff
changeset
|
1828 |
|
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1862
diff
changeset
|
1829 |
ecrt_master_configured_slaves_state(master, &data); |
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1862
diff
changeset
|
1830 |
|
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1862
diff
changeset
|
1831 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1862
diff
changeset
|
1832 |
return -EFAULT; |
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1862
diff
changeset
|
1833 |
|
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1862
diff
changeset
|
1834 |
return 0; |
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1862
diff
changeset
|
1835 |
} |
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1862
diff
changeset
|
1836 |
|
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1862
diff
changeset
|
1837 |
/*****************************************************************************/ |
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1862
diff
changeset
|
1838 |
|
1454 | 1839 |
/** Get the master state. |
1840 |
*/ |
|
1841 |
int ec_cdev_ioctl_app_time( |
|
1842 |
ec_master_t *master, /**< EtherCAT master. */ |
|
1843 |
unsigned long arg, /**< ioctl() argument. */ |
|
1844 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
|
1845 |
) |
|
1846 |
{ |
|
1847 |
ec_ioctl_app_time_t data; |
|
1848 |
||
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1849 |
if (unlikely(!priv->requested)) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1850 |
return -EPERM; |
1454 | 1851 |
|
1852 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
|
1853 |
return -EFAULT; |
|
1854 |
} |
|
1855 |
||
1856 |
ecrt_master_application_time(master, data.app_time); |
|
1857 |
return 0; |
|
1858 |
} |
|
1859 |
||
1860 |
/*****************************************************************************/ |
|
1861 |
||
1413
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
1862 |
/** Sync the reference clock. |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
1863 |
*/ |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
1864 |
int ec_cdev_ioctl_sync_ref( |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
1865 |
ec_master_t *master, /**< EtherCAT master. */ |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
1866 |
unsigned long arg, /**< ioctl() argument. */ |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
1867 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
1868 |
) |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
1869 |
{ |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1870 |
if (unlikely(!priv->requested)) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1871 |
return -EPERM; |
1413
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
1872 |
|
1489
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1873 |
down(&master->io_sem); |
1434
4c6fe0ae37f1
Separated application time from synchronizing reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1426
diff
changeset
|
1874 |
ecrt_master_sync_reference_clock(master); |
1489
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1875 |
up(&master->io_sem); |
1413
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
1876 |
return 0; |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
1877 |
} |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
1878 |
|
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
1879 |
/*****************************************************************************/ |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
1880 |
|
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
1881 |
/** Sync the slave clocks. |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
1882 |
*/ |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
1883 |
int ec_cdev_ioctl_sync_slaves( |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
1884 |
ec_master_t *master, /**< EtherCAT master. */ |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
1885 |
unsigned long arg, /**< ioctl() argument. */ |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
1886 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
1887 |
) |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
1888 |
{ |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1889 |
if (unlikely(!priv->requested)) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1890 |
return -EPERM; |
1413
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
1891 |
|
1489
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1892 |
down(&master->io_sem); |
1413
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
1893 |
ecrt_master_sync_slave_clocks(master); |
1489
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1894 |
up(&master->io_sem); |
1413
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
1895 |
return 0; |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
1896 |
} |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
1897 |
|
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
1898 |
/*****************************************************************************/ |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
1899 |
|
1535
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1900 |
/** Queue the sync monitoring datagram. |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1901 |
*/ |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1902 |
int ec_cdev_ioctl_sync_mon_queue( |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1903 |
ec_master_t *master, /**< EtherCAT master. */ |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1904 |
unsigned long arg, /**< ioctl() argument. */ |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1905 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1906 |
) |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1907 |
{ |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1908 |
if (unlikely(!priv->requested)) |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1909 |
return -EPERM; |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1910 |
|
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1911 |
down(&master->io_sem); |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1912 |
ecrt_master_sync_monitor_queue(master); |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1913 |
up(&master->io_sem); |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1914 |
return 0; |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1915 |
} |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1916 |
|
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1917 |
/*****************************************************************************/ |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1918 |
|
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1919 |
/** Processes the sync monitoring datagram. |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1920 |
*/ |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1921 |
int ec_cdev_ioctl_sync_mon_process( |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1922 |
ec_master_t *master, /**< EtherCAT master. */ |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1923 |
unsigned long arg, /**< ioctl() argument. */ |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1924 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1925 |
) |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1926 |
{ |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1927 |
uint32_t time_diff; |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1928 |
|
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1929 |
if (unlikely(!priv->requested)) |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1930 |
return -EPERM; |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1931 |
|
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1932 |
down(&master->io_sem); |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1933 |
time_diff = ecrt_master_sync_monitor_process(master); |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1934 |
up(&master->io_sem); |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1935 |
|
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1936 |
if (copy_to_user((void __user *) arg, &time_diff, sizeof(time_diff))) |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1937 |
return -EFAULT; |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1938 |
|
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1939 |
return 0; |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1940 |
} |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1941 |
|
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1942 |
/*****************************************************************************/ |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
1943 |
|
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1944 |
/** Configure a sync manager. |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1945 |
*/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1946 |
int ec_cdev_ioctl_sc_sync( |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1947 |
ec_master_t *master, /**< EtherCAT master. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1948 |
unsigned long arg, /**< ioctl() argument. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1949 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1950 |
) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1951 |
{ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1952 |
ec_ioctl_config_t data; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1953 |
ec_slave_config_t *sc; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1954 |
unsigned int i; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1955 |
int ret = 0; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1956 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1957 |
if (unlikely(!priv->requested)) { |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1958 |
ret = -EPERM; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1959 |
goto out_return; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1960 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1961 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1962 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1963 |
ret = -EFAULT; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1964 |
goto out_return; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1965 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1966 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1967 |
if (down_interruptible(&master->master_sem)) { |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1968 |
ret = -EINTR; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1969 |
goto out_return; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1970 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1971 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1972 |
if (!(sc = ec_master_get_config(master, data.config_index))) { |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
1973 |
ret = -ENOENT; |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1974 |
goto out_up; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1975 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1976 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1977 |
for (i = 0; i < EC_MAX_SYNC_MANAGERS; i++) { |
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1978 |
if (data.syncs[i].config_this) { |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1979 |
if (ecrt_slave_config_sync_manager(sc, i, data.syncs[i].dir, |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1980 |
data.syncs[i].watchdog_mode)) { |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1981 |
ret = -EINVAL; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1982 |
goto out_up; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1983 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1984 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1985 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1986 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1987 |
out_up: |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1988 |
up(&master->master_sem); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1989 |
out_return: |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1990 |
return ret; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1991 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1992 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1993 |
/*****************************************************************************/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1994 |
|
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1995 |
/** Configure a slave's watchdogs. |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1996 |
*/ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1997 |
int ec_cdev_ioctl_sc_watchdog( |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1998 |
ec_master_t *master, /**< EtherCAT master. */ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1999 |
unsigned long arg, /**< ioctl() argument. */ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2000 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2001 |
) |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2002 |
{ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2003 |
ec_ioctl_config_t data; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2004 |
ec_slave_config_t *sc; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2005 |
int ret = 0; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2006 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2007 |
if (unlikely(!priv->requested)) { |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2008 |
ret = -EPERM; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2009 |
goto out_return; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2010 |
} |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2011 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2012 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2013 |
ret = -EFAULT; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2014 |
goto out_return; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2015 |
} |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2016 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2017 |
if (down_interruptible(&master->master_sem)) { |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2018 |
ret = -EINTR; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2019 |
goto out_return; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2020 |
} |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2021 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2022 |
if (!(sc = ec_master_get_config(master, data.config_index))) { |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2023 |
ret = -ENOENT; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2024 |
goto out_up; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2025 |
} |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2026 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2027 |
ecrt_slave_config_watchdog(sc, |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2028 |
data.watchdog_divider, data.watchdog_intervals); |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2029 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2030 |
out_up: |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2031 |
up(&master->master_sem); |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2032 |
out_return: |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2033 |
return ret; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2034 |
} |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2035 |
|
1981
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2036 |
|
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2037 |
/*****************************************************************************/ |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2038 |
|
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2039 |
/** Configure wether a slave allows overlapping PDOs. |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2040 |
*/ |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2041 |
int ec_cdev_ioctl_sc_allow_overlapping_pdos( |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2042 |
ec_master_t *master, /**< EtherCAT master. */ |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2043 |
unsigned long arg, /**< ioctl() argument. */ |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2044 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2045 |
) |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2046 |
{ |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2047 |
ec_ioctl_config_t data; |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2048 |
ec_slave_config_t *sc; |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2049 |
int ret = 0; |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2050 |
|
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2051 |
if (unlikely(!priv->requested)) { |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2052 |
ret = -EPERM; |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2053 |
goto out_return; |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2054 |
} |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2055 |
|
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2056 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2057 |
ret = -EFAULT; |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2058 |
goto out_return; |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2059 |
} |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2060 |
|
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2061 |
if (down_interruptible(&master->master_sem)) { |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2062 |
ret = -EINTR; |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2063 |
goto out_return; |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2064 |
} |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2065 |
|
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2066 |
if (!(sc = ec_master_get_config(master, data.config_index))) { |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2067 |
ret = -ENOENT; |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2068 |
goto out_up; |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2069 |
} |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2070 |
|
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2071 |
ecrt_slave_config_overlapping_pdos(sc, |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2072 |
data.allow_overlapping_pdos); |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2073 |
|
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2074 |
out_up: |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2075 |
up(&master->master_sem); |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2076 |
out_return: |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2077 |
return ret; |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2078 |
} |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
2079 |
|
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2080 |
/*****************************************************************************/ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2081 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
2082 |
/** Add a PDO to the assignment. |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2083 |
*/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2084 |
int ec_cdev_ioctl_sc_add_pdo( |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2085 |
ec_master_t *master, /**< EtherCAT master. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2086 |
unsigned long arg, /**< ioctl() argument. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2087 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2088 |
) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2089 |
{ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2090 |
ec_ioctl_config_pdo_t data; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2091 |
ec_slave_config_t *sc; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2092 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
2093 |
if (unlikely(!priv->requested)) |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2094 |
return -EPERM; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2095 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2096 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2097 |
return -EFAULT; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2098 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2099 |
if (down_interruptible(&master->master_sem)) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2100 |
return -EINTR; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2101 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2102 |
if (!(sc = ec_master_get_config(master, data.config_index))) { |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2103 |
up(&master->master_sem); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
2104 |
return -ENOENT; |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2105 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2106 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2107 |
up(&master->master_sem); // FIXME |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2108 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2109 |
return ecrt_slave_config_pdo_assign_add(sc, data.sync_index, data.index); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2110 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2111 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2112 |
/*****************************************************************************/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2113 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
2114 |
/** Clears the PDO assignment. |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2115 |
*/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2116 |
int ec_cdev_ioctl_sc_clear_pdos( |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2117 |
ec_master_t *master, /**< EtherCAT master. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2118 |
unsigned long arg, /**< ioctl() argument. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2119 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2120 |
) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2121 |
{ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2122 |
ec_ioctl_config_pdo_t data; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2123 |
ec_slave_config_t *sc; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2124 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
2125 |
if (unlikely(!priv->requested)) |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2126 |
return -EPERM; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2127 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2128 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2129 |
return -EFAULT; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2130 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2131 |
if (down_interruptible(&master->master_sem)) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2132 |
return -EINTR; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2133 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2134 |
if (!(sc = ec_master_get_config(master, data.config_index))) { |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2135 |
up(&master->master_sem); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
2136 |
return -ENOENT; |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2137 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2138 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2139 |
up(&master->master_sem); // FIXME |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2140 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2141 |
ecrt_slave_config_pdo_assign_clear(sc, data.sync_index); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2142 |
return 0; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2143 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2144 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2145 |
/*****************************************************************************/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2146 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
2147 |
/** Add an entry to a PDO's mapping. |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2148 |
*/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2149 |
int ec_cdev_ioctl_sc_add_entry( |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2150 |
ec_master_t *master, /**< EtherCAT master. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2151 |
unsigned long arg, /**< ioctl() argument. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2152 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2153 |
) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2154 |
{ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2155 |
ec_ioctl_add_pdo_entry_t data; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2156 |
ec_slave_config_t *sc; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2157 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
2158 |
if (unlikely(!priv->requested)) |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2159 |
return -EPERM; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2160 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2161 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2162 |
return -EFAULT; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2163 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2164 |
if (down_interruptible(&master->master_sem)) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2165 |
return -EINTR; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2166 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2167 |
if (!(sc = ec_master_get_config(master, data.config_index))) { |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2168 |
up(&master->master_sem); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
2169 |
return -ENOENT; |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2170 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2171 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2172 |
up(&master->master_sem); // FIXME |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2173 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2174 |
return ecrt_slave_config_pdo_mapping_add(sc, data.pdo_index, |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2175 |
data.entry_index, data.entry_subindex, data.entry_bit_length); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2176 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2177 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2178 |
/*****************************************************************************/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2179 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
2180 |
/** Clears the mapping of a PDO. |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2181 |
*/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2182 |
int ec_cdev_ioctl_sc_clear_entries( |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2183 |
ec_master_t *master, /**< EtherCAT master. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2184 |
unsigned long arg, /**< ioctl() argument. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2185 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2186 |
) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2187 |
{ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2188 |
ec_ioctl_config_pdo_t data; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2189 |
ec_slave_config_t *sc; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2190 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
2191 |
if (unlikely(!priv->requested)) |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2192 |
return -EPERM; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2193 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2194 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2195 |
return -EFAULT; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2196 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2197 |
if (down_interruptible(&master->master_sem)) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2198 |
return -EINTR; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2199 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2200 |
if (!(sc = ec_master_get_config(master, data.config_index))) { |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2201 |
up(&master->master_sem); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
2202 |
return -ENOENT; |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2203 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2204 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2205 |
up(&master->master_sem); // FIXME |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2206 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2207 |
ecrt_slave_config_pdo_mapping_clear(sc, data.index); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2208 |
return 0; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2209 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2210 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2211 |
/*****************************************************************************/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2212 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
2213 |
/** Registers a PDO entry. |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2214 |
*/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2215 |
int ec_cdev_ioctl_sc_reg_pdo_entry( |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2216 |
ec_master_t *master, /**< EtherCAT master. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2217 |
unsigned long arg, /**< ioctl() argument. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2218 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2219 |
) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2220 |
{ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2221 |
ec_ioctl_reg_pdo_entry_t data; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2222 |
ec_slave_config_t *sc; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2223 |
ec_domain_t *domain; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2224 |
int ret; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2225 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
2226 |
if (unlikely(!priv->requested)) |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2227 |
return -EPERM; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2228 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2229 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2230 |
return -EFAULT; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2231 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2232 |
if (down_interruptible(&master->master_sem)) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2233 |
return -EINTR; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2234 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2235 |
if (!(sc = ec_master_get_config(master, data.config_index))) { |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2236 |
up(&master->master_sem); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
2237 |
return -ENOENT; |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2238 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2239 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2240 |
if (!(domain = ec_master_find_domain(master, data.domain_index))) { |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2241 |
up(&master->master_sem); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
2242 |
return -ENOENT; |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2243 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2244 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2245 |
up(&master->master_sem); // FIXME |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2246 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2247 |
ret = ecrt_slave_config_reg_pdo_entry(sc, data.entry_index, |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2248 |
data.entry_subindex, domain, &data.bit_position); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2249 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2250 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2251 |
return -EFAULT; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2252 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2253 |
return ret; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2254 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2255 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2256 |
/*****************************************************************************/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2257 |
|
1448
d7ba0c408a07
Merged ecrt_slave_config_dc_assign_activate() and
Florian Pose <fp@igh-essen.com>
parents:
1447
diff
changeset
|
2258 |
/** Sets the DC AssignActivate word and the sync signal times. |
d7ba0c408a07
Merged ecrt_slave_config_dc_assign_activate() and
Florian Pose <fp@igh-essen.com>
parents:
1447
diff
changeset
|
2259 |
*/ |
d7ba0c408a07
Merged ecrt_slave_config_dc_assign_activate() and
Florian Pose <fp@igh-essen.com>
parents:
1447
diff
changeset
|
2260 |
int ec_cdev_ioctl_sc_dc( |
1413
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
2261 |
ec_master_t *master, /**< EtherCAT master. */ |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
2262 |
unsigned long arg, /**< ioctl() argument. */ |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
2263 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
2264 |
) |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
2265 |
{ |
1455
aa18fcfe0fd1
Output DC config in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1454
diff
changeset
|
2266 |
ec_ioctl_config_t data; |
1413
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
2267 |
ec_slave_config_t *sc; |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
2268 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
2269 |
if (unlikely(!priv->requested)) |
1413
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
2270 |
return -EPERM; |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
2271 |
|
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
2272 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
2273 |
return -EFAULT; |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
2274 |
|
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
2275 |
if (down_interruptible(&master->master_sem)) |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
2276 |
return -EINTR; |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
2277 |
|
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
2278 |
if (!(sc = ec_master_get_config(master, data.config_index))) { |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
2279 |
up(&master->master_sem); |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
2280 |
return -ENOENT; |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
2281 |
} |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
2282 |
|
1455
aa18fcfe0fd1
Output DC config in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1454
diff
changeset
|
2283 |
ecrt_slave_config_dc(sc, data.dc_assign_activate, |
aa18fcfe0fd1
Output DC config in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1454
diff
changeset
|
2284 |
data.dc_sync[0].cycle_time, |
aa18fcfe0fd1
Output DC config in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1454
diff
changeset
|
2285 |
data.dc_sync[0].shift_time, |
aa18fcfe0fd1
Output DC config in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1454
diff
changeset
|
2286 |
data.dc_sync[1].cycle_time, |
aa18fcfe0fd1
Output DC config in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1454
diff
changeset
|
2287 |
data.dc_sync[1].shift_time); |
1413
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
2288 |
|
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
2289 |
up(&master->master_sem); |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
2290 |
|
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
2291 |
return 0; |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
2292 |
} |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
2293 |
|
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
2294 |
/*****************************************************************************/ |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
2295 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
2296 |
/** Configures an SDO. |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2297 |
*/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2298 |
int ec_cdev_ioctl_sc_sdo( |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2299 |
ec_master_t *master, /**< EtherCAT master. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2300 |
unsigned long arg, /**< ioctl() argument. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2301 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2302 |
) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2303 |
{ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2304 |
ec_ioctl_sc_sdo_t data; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2305 |
ec_slave_config_t *sc; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2306 |
uint8_t *sdo_data = NULL; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2307 |
int ret; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2308 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
2309 |
if (unlikely(!priv->requested)) |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2310 |
return -EPERM; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2311 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2312 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2313 |
return -EFAULT; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2314 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2315 |
if (!data.size) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2316 |
return -EINVAL; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2317 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2318 |
if (!(sdo_data = kmalloc(data.size, GFP_KERNEL))) { |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2319 |
return -ENOMEM; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2320 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2321 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2322 |
if (copy_from_user(sdo_data, (void __user *) data.data, data.size)) { |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2323 |
kfree(sdo_data); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2324 |
return -EFAULT; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2325 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2326 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2327 |
if (down_interruptible(&master->master_sem)) { |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2328 |
kfree(sdo_data); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2329 |
return -EINTR; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2330 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2331 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2332 |
if (!(sc = ec_master_get_config(master, data.config_index))) { |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2333 |
up(&master->master_sem); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2334 |
kfree(sdo_data); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
2335 |
return -ENOENT; |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2336 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2337 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2338 |
up(&master->master_sem); // FIXME |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2339 |
|
1526
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1518
diff
changeset
|
2340 |
if (data.complete_access) { |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
2341 |
ret = ecrt_slave_config_complete_sdo(sc, |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
2342 |
data.index, sdo_data, data.size); |
1526
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1518
diff
changeset
|
2343 |
} else { |
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1518
diff
changeset
|
2344 |
ret = ecrt_slave_config_sdo(sc, data.index, data.subindex, sdo_data, |
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1518
diff
changeset
|
2345 |
data.size); |
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1518
diff
changeset
|
2346 |
} |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2347 |
kfree(sdo_data); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2348 |
return ret; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2349 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2350 |
|
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2351 |
/*****************************************************************************/ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2352 |
|
1352
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2353 |
/** Create an SDO request. |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2354 |
*/ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2355 |
int ec_cdev_ioctl_sc_create_sdo_request( |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2356 |
ec_master_t *master, /**< EtherCAT master. */ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2357 |
unsigned long arg, /**< ioctl() argument. */ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2358 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2359 |
) |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2360 |
{ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2361 |
ec_ioctl_sdo_request_t data; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2362 |
ec_slave_config_t *sc; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2363 |
ec_sdo_request_t *req; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2364 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
2365 |
if (unlikely(!priv->requested)) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
2366 |
return -EPERM; |
1352
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2367 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2368 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2369 |
return -EFAULT; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2370 |
} |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2371 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2372 |
data.request_index = 0; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2373 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2374 |
if (down_interruptible(&master->master_sem)) |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2375 |
return -EINTR; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2376 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2377 |
sc = ec_master_get_config(master, data.config_index); |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2378 |
if (!sc) { |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2379 |
up(&master->master_sem); |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2380 |
return -ENOENT; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2381 |
} |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2382 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2383 |
list_for_each_entry(req, &sc->sdo_requests, list) { |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2384 |
data.request_index++; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2385 |
} |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2386 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2387 |
up(&master->master_sem); |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2388 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2389 |
req = ecrt_slave_config_create_sdo_request_err(sc, data.sdo_index, |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2390 |
data.sdo_subindex, data.size); |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2391 |
if (IS_ERR(req)) |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2392 |
return PTR_ERR(req); |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2393 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2394 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2395 |
return -EFAULT; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2396 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2397 |
return 0; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2398 |
} |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2399 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2400 |
/*****************************************************************************/ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2401 |
|
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2402 |
/** Create a VoE handler. |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2403 |
*/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2404 |
int ec_cdev_ioctl_sc_create_voe_handler( |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2405 |
ec_master_t *master, /**< EtherCAT master. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2406 |
unsigned long arg, /**< ioctl() argument. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2407 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2408 |
) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2409 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2410 |
ec_ioctl_voe_t data; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2411 |
ec_slave_config_t *sc; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2412 |
ec_voe_handler_t *voe; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2413 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
2414 |
if (unlikely(!priv->requested)) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
2415 |
return -EPERM; |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2416 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2417 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2418 |
return -EFAULT; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2419 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2420 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2421 |
data.voe_index = 0; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2422 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2423 |
if (down_interruptible(&master->master_sem)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2424 |
return -EINTR; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2425 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2426 |
sc = ec_master_get_config(master, data.config_index); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2427 |
if (!sc) { |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2428 |
up(&master->master_sem); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
2429 |
return -ENOENT; |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2430 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2431 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2432 |
list_for_each_entry(voe, &sc->voe_handlers, list) { |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2433 |
data.voe_index++; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2434 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2435 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2436 |
up(&master->master_sem); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2437 |
|
1312
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1284
diff
changeset
|
2438 |
voe = ecrt_slave_config_create_voe_handler_err(sc, data.size); |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1284
diff
changeset
|
2439 |
if (IS_ERR(voe)) |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1284
diff
changeset
|
2440 |
return PTR_ERR(voe); |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2441 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2442 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2443 |
return -EFAULT; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2444 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2445 |
return 0; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2446 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2447 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2448 |
/*****************************************************************************/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2449 |
|
1259
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2450 |
/** Get the slave configuration's state. |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2451 |
*/ |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2452 |
int ec_cdev_ioctl_sc_state( |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2453 |
ec_master_t *master, /**< EtherCAT master. */ |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2454 |
unsigned long arg, /**< ioctl() argument. */ |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2455 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2456 |
) |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2457 |
{ |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2458 |
ec_ioctl_sc_state_t data; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2459 |
const ec_slave_config_t *sc; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2460 |
ec_slave_config_state_t state; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2461 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
2462 |
if (unlikely(!priv->requested)) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
2463 |
return -EPERM; |
1259
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2464 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2465 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2466 |
return -EFAULT; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2467 |
} |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2468 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2469 |
if (down_interruptible(&master->master_sem)) |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2470 |
return -EINTR; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2471 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2472 |
if (!(sc = ec_master_get_config_const(master, data.config_index))) { |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2473 |
up(&master->master_sem); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
2474 |
return -ENOENT; |
1259
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2475 |
} |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2476 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2477 |
ecrt_slave_config_state(sc, &state); |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2478 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2479 |
up(&master->master_sem); |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2480 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2481 |
if (copy_to_user((void __user *) data.state, &state, sizeof(state))) |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2482 |
return -EFAULT; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2483 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2484 |
return 0; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2485 |
} |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2486 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2487 |
/*****************************************************************************/ |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2488 |
|
1862
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2489 |
/** Configures an IDN. |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2490 |
*/ |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2491 |
int ec_cdev_ioctl_sc_idn( |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2492 |
ec_master_t *master, /**< EtherCAT master. */ |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2493 |
unsigned long arg, /**< ioctl() argument. */ |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2494 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2495 |
) |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2496 |
{ |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2497 |
ec_ioctl_sc_idn_t ioctl; |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2498 |
ec_slave_config_t *sc; |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2499 |
uint8_t *data = NULL; |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2500 |
int ret; |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2501 |
|
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2502 |
if (unlikely(!priv->requested)) |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2503 |
return -EPERM; |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2504 |
|
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2505 |
if (copy_from_user(&ioctl, (void __user *) arg, sizeof(ioctl))) |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2506 |
return -EFAULT; |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2507 |
|
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2508 |
if (!ioctl.size) |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2509 |
return -EINVAL; |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2510 |
|
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2511 |
if (!(data = kmalloc(ioctl.size, GFP_KERNEL))) { |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2512 |
return -ENOMEM; |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2513 |
} |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2514 |
|
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2515 |
if (copy_from_user(data, (void __user *) ioctl.data, ioctl.size)) { |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2516 |
kfree(data); |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2517 |
return -EFAULT; |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2518 |
} |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2519 |
|
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2520 |
if (down_interruptible(&master->master_sem)) { |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2521 |
kfree(data); |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2522 |
return -EINTR; |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2523 |
} |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2524 |
|
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2525 |
if (!(sc = ec_master_get_config(master, ioctl.config_index))) { |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2526 |
up(&master->master_sem); |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2527 |
kfree(data); |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2528 |
return -ENOENT; |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2529 |
} |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2530 |
|
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2531 |
up(&master->master_sem); // FIXME |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2532 |
|
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2533 |
ret = ecrt_slave_config_idn(sc, ioctl.idn, data, ioctl.size); |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2534 |
kfree(data); |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2535 |
return ret; |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2536 |
} |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2537 |
|
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2538 |
/*****************************************************************************/ |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
2539 |
|
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2540 |
/** Gets the domain's offset in the total process data. |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2541 |
*/ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2542 |
int ec_cdev_ioctl_domain_offset( |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2543 |
ec_master_t *master, /**< EtherCAT master. */ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2544 |
unsigned long arg, /**< ioctl() argument. */ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2545 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2546 |
) |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2547 |
{ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2548 |
int offset = 0; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2549 |
const ec_domain_t *domain; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2550 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
2551 |
if (unlikely(!priv->requested)) |
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2552 |
return -EPERM; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2553 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2554 |
if (down_interruptible(&master->master_sem)) { |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2555 |
return -EINTR; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2556 |
} |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2557 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2558 |
list_for_each_entry(domain, &master->domains, list) { |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2559 |
if (domain->index == arg) { |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2560 |
up(&master->master_sem); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2561 |
return offset; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2562 |
} |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2563 |
offset += ecrt_domain_size(domain); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2564 |
} |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2565 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2566 |
up(&master->master_sem); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
2567 |
return -ENOENT; |
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2568 |
} |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2569 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2570 |
/*****************************************************************************/ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2571 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2572 |
/** Process the domain. |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2573 |
*/ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2574 |
int ec_cdev_ioctl_domain_process( |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2575 |
ec_master_t *master, /**< EtherCAT master. */ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2576 |
unsigned long arg, /**< ioctl() argument. */ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2577 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2578 |
) |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2579 |
{ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2580 |
ec_domain_t *domain; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2581 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
2582 |
if (unlikely(!priv->requested)) |
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2583 |
return -EPERM; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2584 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2585 |
if (down_interruptible(&master->master_sem)) |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2586 |
return -EINTR; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2587 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2588 |
if (!(domain = ec_master_find_domain(master, arg))) { |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2589 |
up(&master->master_sem); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
2590 |
return -ENOENT; |
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2591 |
} |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2592 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2593 |
ecrt_domain_process(domain); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2594 |
up(&master->master_sem); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2595 |
return 0; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2596 |
} |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2597 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2598 |
/*****************************************************************************/ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2599 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2600 |
/** Queue the domain. |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2601 |
*/ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2602 |
int ec_cdev_ioctl_domain_queue( |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2603 |
ec_master_t *master, /**< EtherCAT master. */ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2604 |
unsigned long arg, /**< ioctl() argument. */ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2605 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2606 |
) |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2607 |
{ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2608 |
ec_domain_t *domain; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2609 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
2610 |
if (unlikely(!priv->requested)) |
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2611 |
return -EPERM; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2612 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2613 |
if (down_interruptible(&master->master_sem)) |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2614 |
return -EINTR; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2615 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2616 |
if (!(domain = ec_master_find_domain(master, arg))) { |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2617 |
up(&master->master_sem); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
2618 |
return -ENOENT; |
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2619 |
} |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2620 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2621 |
ecrt_domain_queue(domain); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2622 |
up(&master->master_sem); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2623 |
return 0; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2624 |
} |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2625 |
|
1259
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2626 |
/*****************************************************************************/ |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2627 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2628 |
/** Get the domain state. |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2629 |
*/ |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2630 |
int ec_cdev_ioctl_domain_state( |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2631 |
ec_master_t *master, /**< EtherCAT master. */ |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2632 |
unsigned long arg, /**< ioctl() argument. */ |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2633 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2634 |
) |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2635 |
{ |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2636 |
ec_ioctl_domain_state_t data; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2637 |
const ec_domain_t *domain; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2638 |
ec_domain_state_t state; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2639 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
2640 |
if (unlikely(!priv->requested)) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
2641 |
return -EPERM; |
1259
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2642 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2643 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2644 |
return -EFAULT; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2645 |
} |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2646 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2647 |
if (down_interruptible(&master->master_sem)) |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2648 |
return -EINTR; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2649 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2650 |
if (!(domain = ec_master_find_domain_const(master, data.domain_index))) { |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2651 |
up(&master->master_sem); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
2652 |
return -ENOENT; |
1259
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2653 |
} |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2654 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2655 |
ecrt_domain_state(domain, &state); |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2656 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2657 |
up(&master->master_sem); |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2658 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2659 |
if (copy_to_user((void __user *) data.state, &state, sizeof(state))) |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2660 |
return -EFAULT; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2661 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2662 |
return 0; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2663 |
} |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2664 |
|
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2665 |
/*****************************************************************************/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2666 |
|
1352
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2667 |
/** Sets an SDO request's timeout. |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2668 |
*/ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2669 |
int ec_cdev_ioctl_sdo_request_timeout( |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2670 |
ec_master_t *master, /**< EtherCAT master. */ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2671 |
unsigned long arg, /**< ioctl() argument. */ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2672 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2673 |
) |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2674 |
{ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2675 |
ec_ioctl_sdo_request_t data; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2676 |
ec_slave_config_t *sc; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2677 |
ec_sdo_request_t *req; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2678 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
2679 |
if (unlikely(!priv->requested)) |
1352
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2680 |
return -EPERM; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2681 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2682 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2683 |
return -EFAULT; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2684 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2685 |
if (down_interruptible(&master->master_sem)) |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2686 |
return -EINTR; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2687 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2688 |
if (!(sc = ec_master_get_config(master, data.config_index))) { |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2689 |
up(&master->master_sem); |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2690 |
return -ENOENT; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2691 |
} |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2692 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2693 |
if (!(req = ec_slave_config_find_sdo_request(sc, data.request_index))) { |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2694 |
up(&master->master_sem); |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2695 |
return -ENOENT; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2696 |
} |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2697 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2698 |
up(&master->master_sem); |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2699 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2700 |
ecrt_sdo_request_timeout(req, data.timeout); |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2701 |
return 0; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2702 |
} |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2703 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2704 |
/*****************************************************************************/ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2705 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2706 |
/** Gets an SDO request's state. |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2707 |
*/ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2708 |
int ec_cdev_ioctl_sdo_request_state( |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2709 |
ec_master_t *master, /**< EtherCAT master. */ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2710 |
unsigned long arg, /**< ioctl() argument. */ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2711 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2712 |
) |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2713 |
{ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2714 |
ec_ioctl_sdo_request_t data; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2715 |
ec_slave_config_t *sc; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2716 |
ec_sdo_request_t *req; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2717 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
2718 |
if (unlikely(!priv->requested)) |
1352
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2719 |
return -EPERM; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2720 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2721 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2722 |
return -EFAULT; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2723 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2724 |
if (down_interruptible(&master->master_sem)) |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2725 |
return -EINTR; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2726 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2727 |
if (!(sc = ec_master_get_config(master, data.config_index))) { |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2728 |
up(&master->master_sem); |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2729 |
return -ENOENT; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2730 |
} |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2731 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2732 |
if (!(req = ec_slave_config_find_sdo_request(sc, data.request_index))) { |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2733 |
up(&master->master_sem); |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2734 |
return -ENOENT; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2735 |
} |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2736 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2737 |
data.state = ecrt_sdo_request_state(req); |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2738 |
if (data.state == EC_REQUEST_SUCCESS && req->dir == EC_DIR_INPUT) |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2739 |
data.size = ecrt_sdo_request_data_size(req); |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2740 |
else |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2741 |
data.size = 0; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2742 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2743 |
up(&master->master_sem); |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2744 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2745 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2746 |
return -EFAULT; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2747 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2748 |
return 0; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2749 |
} |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2750 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2751 |
/*****************************************************************************/ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2752 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2753 |
/** Starts an SDO read operation. |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2754 |
*/ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2755 |
int ec_cdev_ioctl_sdo_request_read( |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2756 |
ec_master_t *master, /**< EtherCAT master. */ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2757 |
unsigned long arg, /**< ioctl() argument. */ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2758 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2759 |
) |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2760 |
{ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2761 |
ec_ioctl_sdo_request_t data; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2762 |
ec_slave_config_t *sc; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2763 |
ec_sdo_request_t *req; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2764 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
2765 |
if (unlikely(!priv->requested)) |
1352
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2766 |
return -EPERM; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2767 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2768 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2769 |
return -EFAULT; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2770 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2771 |
if (down_interruptible(&master->master_sem)) |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2772 |
return -EINTR; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2773 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2774 |
if (!(sc = ec_master_get_config(master, data.config_index))) { |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2775 |
up(&master->master_sem); |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2776 |
return -ENOENT; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2777 |
} |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2778 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2779 |
if (!(req = ec_slave_config_find_sdo_request(sc, data.request_index))) { |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2780 |
up(&master->master_sem); |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2781 |
return -ENOENT; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2782 |
} |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2783 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2784 |
up(&master->master_sem); |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2785 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2786 |
ecrt_sdo_request_read(req); |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2787 |
return 0; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2788 |
} |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2789 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2790 |
/*****************************************************************************/ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2791 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2792 |
/** Starts an SDO write operation. |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2793 |
*/ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2794 |
int ec_cdev_ioctl_sdo_request_write( |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2795 |
ec_master_t *master, /**< EtherCAT master. */ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2796 |
unsigned long arg, /**< ioctl() argument. */ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2797 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2798 |
) |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2799 |
{ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2800 |
ec_ioctl_sdo_request_t data; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2801 |
ec_slave_config_t *sc; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2802 |
ec_sdo_request_t *req; |
1361
9c16b62326fa
Fixed SDO download via library.
Florian Pose <fp@igh-essen.com>
parents:
1352
diff
changeset
|
2803 |
int ret; |
1352
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2804 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
2805 |
if (unlikely(!priv->requested)) |
1352
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2806 |
return -EPERM; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2807 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2808 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2809 |
return -EFAULT; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2810 |
|
1361
9c16b62326fa
Fixed SDO download via library.
Florian Pose <fp@igh-essen.com>
parents:
1352
diff
changeset
|
2811 |
if (!data.size) { |
9c16b62326fa
Fixed SDO download via library.
Florian Pose <fp@igh-essen.com>
parents:
1352
diff
changeset
|
2812 |
EC_ERR("Sdo download: Data size may not be zero!\n"); |
9c16b62326fa
Fixed SDO download via library.
Florian Pose <fp@igh-essen.com>
parents:
1352
diff
changeset
|
2813 |
return -EINVAL; |
9c16b62326fa
Fixed SDO download via library.
Florian Pose <fp@igh-essen.com>
parents:
1352
diff
changeset
|
2814 |
} |
9c16b62326fa
Fixed SDO download via library.
Florian Pose <fp@igh-essen.com>
parents:
1352
diff
changeset
|
2815 |
|
1352
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2816 |
if (down_interruptible(&master->master_sem)) |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2817 |
return -EINTR; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2818 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2819 |
if (!(sc = ec_master_get_config(master, data.config_index))) { |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2820 |
up(&master->master_sem); |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2821 |
return -ENOENT; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2822 |
} |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2823 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2824 |
if (!(req = ec_slave_config_find_sdo_request(sc, data.request_index))) { |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2825 |
up(&master->master_sem); |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2826 |
return -ENOENT; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2827 |
} |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2828 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2829 |
up(&master->master_sem); |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2830 |
|
1361
9c16b62326fa
Fixed SDO download via library.
Florian Pose <fp@igh-essen.com>
parents:
1352
diff
changeset
|
2831 |
ret = ec_sdo_request_alloc(req, data.size); |
9c16b62326fa
Fixed SDO download via library.
Florian Pose <fp@igh-essen.com>
parents:
1352
diff
changeset
|
2832 |
if (ret) |
9c16b62326fa
Fixed SDO download via library.
Florian Pose <fp@igh-essen.com>
parents:
1352
diff
changeset
|
2833 |
return ret; |
9c16b62326fa
Fixed SDO download via library.
Florian Pose <fp@igh-essen.com>
parents:
1352
diff
changeset
|
2834 |
|
9c16b62326fa
Fixed SDO download via library.
Florian Pose <fp@igh-essen.com>
parents:
1352
diff
changeset
|
2835 |
if (copy_from_user(req->data, (void __user *) data.data, data.size)) |
9c16b62326fa
Fixed SDO download via library.
Florian Pose <fp@igh-essen.com>
parents:
1352
diff
changeset
|
2836 |
return -EFAULT; |
9c16b62326fa
Fixed SDO download via library.
Florian Pose <fp@igh-essen.com>
parents:
1352
diff
changeset
|
2837 |
|
9c16b62326fa
Fixed SDO download via library.
Florian Pose <fp@igh-essen.com>
parents:
1352
diff
changeset
|
2838 |
req->data_size = data.size; |
1352
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2839 |
ecrt_sdo_request_write(req); |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2840 |
return 0; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2841 |
} |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2842 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2843 |
/*****************************************************************************/ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2844 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2845 |
/** Read SDO data. |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2846 |
*/ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2847 |
int ec_cdev_ioctl_sdo_request_data( |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2848 |
ec_master_t *master, /**< EtherCAT master. */ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2849 |
unsigned long arg, /**< ioctl() argument. */ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2850 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2851 |
) |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2852 |
{ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2853 |
ec_ioctl_sdo_request_t data; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2854 |
ec_slave_config_t *sc; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2855 |
ec_sdo_request_t *req; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2856 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
2857 |
if (unlikely(!priv->requested)) |
1352
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2858 |
return -EPERM; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2859 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2860 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2861 |
return -EFAULT; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2862 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2863 |
if (down_interruptible(&master->master_sem)) |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2864 |
return -EINTR; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2865 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2866 |
if (!(sc = ec_master_get_config(master, data.config_index))) { |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2867 |
up(&master->master_sem); |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2868 |
return -ENOENT; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2869 |
} |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2870 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2871 |
if (!(req = ec_slave_config_find_sdo_request(sc, data.request_index))) { |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2872 |
up(&master->master_sem); |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2873 |
return -ENOENT; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2874 |
} |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2875 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2876 |
up(&master->master_sem); |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2877 |
|
1362
2d6e0b01c80a
Fixed SDO upload via library.
Florian Pose <fp@igh-essen.com>
parents:
1361
diff
changeset
|
2878 |
if (copy_to_user((void __user *) data.data, ecrt_sdo_request_data(req), |
2d6e0b01c80a
Fixed SDO upload via library.
Florian Pose <fp@igh-essen.com>
parents:
1361
diff
changeset
|
2879 |
ecrt_sdo_request_data_size(req))) |
2d6e0b01c80a
Fixed SDO upload via library.
Florian Pose <fp@igh-essen.com>
parents:
1361
diff
changeset
|
2880 |
return -EFAULT; |
2d6e0b01c80a
Fixed SDO upload via library.
Florian Pose <fp@igh-essen.com>
parents:
1361
diff
changeset
|
2881 |
|
1352
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2882 |
return 0; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2883 |
} |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2884 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2885 |
/*****************************************************************************/ |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
2886 |
|
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2887 |
/** Sets the VoE send header. |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2888 |
*/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2889 |
int ec_cdev_ioctl_voe_send_header( |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2890 |
ec_master_t *master, /**< EtherCAT master. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2891 |
unsigned long arg, /**< ioctl() argument. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2892 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2893 |
) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2894 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2895 |
ec_ioctl_voe_t data; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2896 |
ec_slave_config_t *sc; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2897 |
ec_voe_handler_t *voe; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2898 |
uint32_t vendor_id; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2899 |
uint16_t vendor_type; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2900 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
2901 |
if (unlikely(!priv->requested)) |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2902 |
return -EPERM; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2903 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2904 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2905 |
return -EFAULT; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2906 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2907 |
if (get_user(vendor_id, data.vendor_id)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2908 |
return -EFAULT; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2909 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2910 |
if (get_user(vendor_type, data.vendor_type)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2911 |
return -EFAULT; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2912 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2913 |
if (down_interruptible(&master->master_sem)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2914 |
return -EINTR; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2915 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2916 |
if (!(sc = ec_master_get_config(master, data.config_index))) { |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2917 |
up(&master->master_sem); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
2918 |
return -ENOENT; |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2919 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2920 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2921 |
if (!(voe = ec_slave_config_find_voe_handler(sc, data.voe_index))) { |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2922 |
up(&master->master_sem); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
2923 |
return -ENOENT; |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2924 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2925 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2926 |
up(&master->master_sem); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2927 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2928 |
ecrt_voe_handler_send_header(voe, vendor_id, vendor_type); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2929 |
return 0; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2930 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2931 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2932 |
/*****************************************************************************/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2933 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2934 |
/** Gets the received VoE header. |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2935 |
*/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2936 |
int ec_cdev_ioctl_voe_rec_header( |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2937 |
ec_master_t *master, /**< EtherCAT master. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2938 |
unsigned long arg, /**< ioctl() argument. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2939 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2940 |
) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2941 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2942 |
ec_ioctl_voe_t data; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2943 |
ec_slave_config_t *sc; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2944 |
ec_voe_handler_t *voe; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2945 |
uint32_t vendor_id; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2946 |
uint16_t vendor_type; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2947 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
2948 |
if (unlikely(!priv->requested)) |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2949 |
return -EPERM; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2950 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2951 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2952 |
return -EFAULT; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2953 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2954 |
if (down_interruptible(&master->master_sem)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2955 |
return -EINTR; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2956 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2957 |
if (!(sc = ec_master_get_config(master, data.config_index))) { |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2958 |
up(&master->master_sem); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
2959 |
return -ENOENT; |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2960 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2961 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2962 |
if (!(voe = ec_slave_config_find_voe_handler(sc, data.voe_index))) { |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2963 |
up(&master->master_sem); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
2964 |
return -ENOENT; |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2965 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2966 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2967 |
ecrt_voe_handler_received_header(voe, &vendor_id, &vendor_type); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2968 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2969 |
up(&master->master_sem); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2970 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2971 |
if (likely(data.vendor_id)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2972 |
if (put_user(vendor_id, data.vendor_id)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2973 |
return -EFAULT; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2974 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2975 |
if (likely(data.vendor_type)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2976 |
if (put_user(vendor_type, data.vendor_type)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2977 |
return -EFAULT; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2978 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2979 |
return 0; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2980 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2981 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2982 |
/*****************************************************************************/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2983 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2984 |
/** Starts a VoE read operation. |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2985 |
*/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2986 |
int ec_cdev_ioctl_voe_read( |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2987 |
ec_master_t *master, /**< EtherCAT master. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2988 |
unsigned long arg, /**< ioctl() argument. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2989 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2990 |
) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2991 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2992 |
ec_ioctl_voe_t data; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2993 |
ec_slave_config_t *sc; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2994 |
ec_voe_handler_t *voe; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2995 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
2996 |
if (unlikely(!priv->requested)) |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2997 |
return -EPERM; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2998 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2999 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3000 |
return -EFAULT; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3001 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3002 |
if (down_interruptible(&master->master_sem)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3003 |
return -EINTR; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3004 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3005 |
if (!(sc = ec_master_get_config(master, data.config_index))) { |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3006 |
up(&master->master_sem); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
3007 |
return -ENOENT; |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3008 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3009 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3010 |
if (!(voe = ec_slave_config_find_voe_handler(sc, data.voe_index))) { |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3011 |
up(&master->master_sem); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
3012 |
return -ENOENT; |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3013 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3014 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3015 |
up(&master->master_sem); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3016 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3017 |
ecrt_voe_handler_read(voe); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3018 |
return 0; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3019 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3020 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3021 |
/*****************************************************************************/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3022 |
|
1314
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3023 |
/** Starts a VoE read operation without sending a sync message first. |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3024 |
*/ |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3025 |
int ec_cdev_ioctl_voe_read_nosync( |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3026 |
ec_master_t *master, /**< EtherCAT master. */ |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3027 |
unsigned long arg, /**< ioctl() argument. */ |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3028 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3029 |
) |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3030 |
{ |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3031 |
ec_ioctl_voe_t data; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3032 |
ec_slave_config_t *sc; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3033 |
ec_voe_handler_t *voe; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3034 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3035 |
if (unlikely(!priv->requested)) |
1314
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3036 |
return -EPERM; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3037 |
|
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3038 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3039 |
return -EFAULT; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3040 |
|
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3041 |
if (down_interruptible(&master->master_sem)) |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3042 |
return -EINTR; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3043 |
|
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3044 |
if (!(sc = ec_master_get_config(master, data.config_index))) { |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3045 |
up(&master->master_sem); |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3046 |
return -ENOENT; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3047 |
} |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3048 |
|
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3049 |
if (!(voe = ec_slave_config_find_voe_handler(sc, data.voe_index))) { |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3050 |
up(&master->master_sem); |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3051 |
return -ENOENT; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3052 |
} |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3053 |
|
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3054 |
up(&master->master_sem); |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3055 |
|
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3056 |
ecrt_voe_handler_read_nosync(voe); |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3057 |
return 0; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3058 |
} |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3059 |
|
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3060 |
/*****************************************************************************/ |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3061 |
|
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3062 |
/** Starts a VoE write operation. |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3063 |
*/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3064 |
int ec_cdev_ioctl_voe_write( |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3065 |
ec_master_t *master, /**< EtherCAT master. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3066 |
unsigned long arg, /**< ioctl() argument. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3067 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3068 |
) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3069 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3070 |
ec_ioctl_voe_t data; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3071 |
ec_slave_config_t *sc; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3072 |
ec_voe_handler_t *voe; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3073 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3074 |
if (unlikely(!priv->requested)) |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3075 |
return -EPERM; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3076 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3077 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3078 |
return -EFAULT; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3079 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3080 |
if (down_interruptible(&master->master_sem)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3081 |
return -EINTR; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3082 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3083 |
if (!(sc = ec_master_get_config(master, data.config_index))) { |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3084 |
up(&master->master_sem); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
3085 |
return -ENOENT; |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3086 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3087 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3088 |
if (!(voe = ec_slave_config_find_voe_handler(sc, data.voe_index))) { |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3089 |
up(&master->master_sem); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
3090 |
return -ENOENT; |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3091 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3092 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3093 |
up(&master->master_sem); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3094 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3095 |
if (data.size) { |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3096 |
if (data.size > ec_voe_handler_mem_size(voe)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3097 |
return -EOVERFLOW; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3098 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3099 |
if (copy_from_user(ecrt_voe_handler_data(voe), |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3100 |
(void __user *) data.data, data.size)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3101 |
return -EFAULT; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3102 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3103 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3104 |
ecrt_voe_handler_write(voe, data.size); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3105 |
return 0; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3106 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3107 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3108 |
/*****************************************************************************/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3109 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3110 |
/** Executes the VoE state machine. |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3111 |
*/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3112 |
int ec_cdev_ioctl_voe_exec( |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3113 |
ec_master_t *master, /**< EtherCAT master. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3114 |
unsigned long arg, /**< ioctl() argument. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3115 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3116 |
) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3117 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3118 |
ec_ioctl_voe_t data; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3119 |
ec_slave_config_t *sc; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3120 |
ec_voe_handler_t *voe; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3121 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3122 |
if (unlikely(!priv->requested)) |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3123 |
return -EPERM; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3124 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3125 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3126 |
return -EFAULT; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3127 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3128 |
if (down_interruptible(&master->master_sem)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3129 |
return -EINTR; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3130 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3131 |
if (!(sc = ec_master_get_config(master, data.config_index))) { |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3132 |
up(&master->master_sem); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
3133 |
return -ENOENT; |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3134 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3135 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3136 |
if (!(voe = ec_slave_config_find_voe_handler(sc, data.voe_index))) { |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3137 |
up(&master->master_sem); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
3138 |
return -ENOENT; |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3139 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3140 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3141 |
up(&master->master_sem); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3142 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3143 |
data.state = ecrt_voe_handler_execute(voe); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3144 |
if (data.state == EC_REQUEST_SUCCESS && voe->dir == EC_DIR_INPUT) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3145 |
data.size = ecrt_voe_handler_data_size(voe); |
1350 | 3146 |
else |
3147 |
data.size = 0; |
|
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3148 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3149 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3150 |
return -EFAULT; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3151 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3152 |
return 0; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3153 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3154 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3155 |
/*****************************************************************************/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3156 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3157 |
/** Reads the received VoE data. |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3158 |
*/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3159 |
int ec_cdev_ioctl_voe_data( |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3160 |
ec_master_t *master, /**< EtherCAT master. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3161 |
unsigned long arg, /**< ioctl() argument. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3162 |
ec_cdev_priv_t *priv /**< Private data structure of file handle. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3163 |
) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3164 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3165 |
ec_ioctl_voe_t data; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3166 |
ec_slave_config_t *sc; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3167 |
ec_voe_handler_t *voe; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3168 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3169 |
if (unlikely(!priv->requested)) |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3170 |
return -EPERM; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3171 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3172 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3173 |
return -EFAULT; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3174 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3175 |
if (down_interruptible(&master->master_sem)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3176 |
return -EINTR; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3177 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3178 |
if (!(sc = ec_master_get_config(master, data.config_index))) { |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3179 |
up(&master->master_sem); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
3180 |
return -ENOENT; |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3181 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3182 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3183 |
if (!(voe = ec_slave_config_find_voe_handler(sc, data.voe_index))) { |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3184 |
up(&master->master_sem); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
3185 |
return -ENOENT; |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3186 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3187 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3188 |
up(&master->master_sem); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3189 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3190 |
if (copy_to_user((void __user *) data.data, ecrt_voe_handler_data(voe), |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3191 |
ecrt_voe_handler_data_size(voe))) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3192 |
return -EFAULT; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3193 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3194 |
return 0; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3195 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3196 |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3197 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3198 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3199 |
/** Read a file from a slave via FoE. |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3200 |
*/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3201 |
int ec_cdev_ioctl_slave_foe_read( |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3202 |
ec_master_t *master, /**< EtherCAT master. */ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3203 |
unsigned long arg /**< ioctl() argument. */ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3204 |
) |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3205 |
{ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3206 |
ec_ioctl_slave_foe_t data; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3207 |
ec_master_foe_request_t request; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3208 |
int retval; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3209 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3210 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3211 |
return -EFAULT; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3212 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3213 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3214 |
ec_foe_request_init(&request.req, data.file_name); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3215 |
ec_foe_request_read(&request.req); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3216 |
ec_foe_request_alloc(&request.req, 10000); // FIXME |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3217 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3218 |
if (down_interruptible(&master->master_sem)) |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3219 |
return -EINTR; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3220 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3221 |
if (!(request.slave = ec_master_find_slave( |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3222 |
master, 0, data.slave_position))) { |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3223 |
up(&master->master_sem); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3224 |
ec_foe_request_clear(&request.req); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3225 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3226 |
return -EINVAL; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3227 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3228 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3229 |
// schedule request. |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
3230 |
list_add_tail(&request.list, &request.slave->foe_requests); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3231 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3232 |
up(&master->master_sem); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3233 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
3234 |
if (master->debug_level) { |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
3235 |
EC_DBG("Scheduled FoE read request on slave %u.\n", |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
3236 |
request.slave->ring_position); |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
3237 |
} |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
3238 |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3239 |
// wait for processing through FSM |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
3240 |
if (wait_event_interruptible(request.slave->foe_queue, |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3241 |
request.req.state != EC_INT_REQUEST_QUEUED)) { |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3242 |
// interrupted by signal |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3243 |
down(&master->master_sem); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3244 |
if (request.req.state == EC_INT_REQUEST_QUEUED) { |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3245 |
list_del(&request.list); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3246 |
up(&master->master_sem); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3247 |
ec_foe_request_clear(&request.req); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3248 |
return -EINTR; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3249 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3250 |
// request already processing: interrupt not possible. |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3251 |
up(&master->master_sem); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3252 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3253 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3254 |
// wait until master FSM has finished processing |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3255 |
wait_event(request.slave->foe_queue, |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3256 |
request.req.state != EC_INT_REQUEST_BUSY); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3257 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
3258 |
data.result = request.req.result; |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
3259 |
data.error_code = request.req.error_code; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3260 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3261 |
if (master->debug_level) { |
1543
373cd456dc26
Avoid warnings on x86_64 platform. Thanks to Thomas Elste.
Florian Pose <fp@igh-essen.com>
parents:
1526
diff
changeset
|
3262 |
EC_DBG("Read %zd bytes via FoE (result = 0x%x).\n", |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3263 |
request.req.data_size, request.req.result); |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3264 |
} |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3265 |
|
1349 | 3266 |
if (request.req.state != EC_INT_REQUEST_SUCCESS) { |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3267 |
data.data_size = 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3268 |
retval = -EIO; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3269 |
} else { |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3270 |
if (request.req.data_size > data.buffer_size) { |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3271 |
EC_ERR("Buffer too small.\n"); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3272 |
ec_foe_request_clear(&request.req); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3273 |
return -EOVERFLOW; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3274 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3275 |
data.data_size = request.req.data_size; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3276 |
if (copy_to_user((void __user *) data.buffer, |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3277 |
request.req.buffer, data.data_size)) { |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3278 |
ec_foe_request_clear(&request.req); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3279 |
return -EFAULT; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3280 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3281 |
retval = 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3282 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3283 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3284 |
if (__copy_to_user((void __user *) arg, &data, sizeof(data))) { |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3285 |
retval = -EFAULT; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3286 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3287 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
3288 |
if (master->debug_level) |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
3289 |
EC_DBG("FoE read request finished on slave %u.\n", |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
3290 |
request.slave->ring_position); |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
3291 |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3292 |
ec_foe_request_clear(&request.req); |
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
3293 |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3294 |
return retval; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3295 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3296 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3297 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3298 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3299 |
/** Write a file to a slave via FoE |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3300 |
*/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3301 |
int ec_cdev_ioctl_slave_foe_write( |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3302 |
ec_master_t *master, /**< EtherCAT master. */ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3303 |
unsigned long arg /**< ioctl() argument. */ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3304 |
) |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3305 |
{ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3306 |
ec_ioctl_slave_foe_t data; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3307 |
ec_master_foe_request_t request; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3308 |
int retval; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3309 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3310 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3311 |
return -EFAULT; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3312 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3313 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3314 |
INIT_LIST_HEAD(&request.list); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3315 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3316 |
ec_foe_request_init(&request.req, data.file_name); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3317 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3318 |
if (ec_foe_request_alloc(&request.req, data.buffer_size)) { |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3319 |
ec_foe_request_clear(&request.req); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3320 |
return -ENOMEM; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3321 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3322 |
if (copy_from_user(request.req.buffer, |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3323 |
(void __user *) data.buffer, data.buffer_size)) { |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3324 |
ec_foe_request_clear(&request.req); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3325 |
return -EFAULT; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3326 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3327 |
request.req.data_size = data.buffer_size; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3328 |
ec_foe_request_write(&request.req); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3329 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3330 |
if (down_interruptible(&master->master_sem)) |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3331 |
return -EINTR; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3332 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3333 |
if (!(request.slave = ec_master_find_slave( |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3334 |
master, 0, data.slave_position))) { |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3335 |
up(&master->master_sem); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3336 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3337 |
ec_foe_request_clear(&request.req); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3338 |
return -EINVAL; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3339 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3340 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3341 |
if (master->debug_level) { |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3342 |
EC_DBG("Scheduling FoE write request.\n"); |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3343 |
} |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3344 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3345 |
// schedule FoE write request. |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
3346 |
list_add_tail(&request.list, &request.slave->foe_requests); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3347 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3348 |
up(&master->master_sem); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3349 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3350 |
// wait for processing through FSM |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
3351 |
if (wait_event_interruptible(request.slave->foe_queue, |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3352 |
request.req.state != EC_INT_REQUEST_QUEUED)) { |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3353 |
// interrupted by signal |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3354 |
down(&master->master_sem); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3355 |
if (request.req.state == EC_INT_REQUEST_QUEUED) { |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3356 |
// abort request |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3357 |
list_del(&request.list); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3358 |
up(&master->master_sem); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3359 |
ec_foe_request_clear(&request.req); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3360 |
return -EINTR; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3361 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3362 |
up(&master->master_sem); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3363 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3364 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3365 |
// wait until master FSM has finished processing |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3366 |
wait_event(request.slave->foe_queue, |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3367 |
request.req.state != EC_INT_REQUEST_BUSY); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3368 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
3369 |
data.result = request.req.result; |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
3370 |
data.error_code = request.req.error_code; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3371 |
|
1349 | 3372 |
retval = request.req.state == EC_INT_REQUEST_SUCCESS ? 0 : -EIO; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3373 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3374 |
if (__copy_to_user((void __user *) arg, &data, sizeof(data))) { |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3375 |
retval = -EFAULT; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3376 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3377 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3378 |
ec_foe_request_clear(&request.req); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3379 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3380 |
if (master->debug_level) { |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3381 |
EC_DBG("Finished FoE writing.\n"); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3382 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3383 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3384 |
return retval; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3385 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3386 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3387 |
/*****************************************************************************/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3388 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3389 |
/** Read an SoE IDN. |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3390 |
*/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3391 |
int ec_cdev_ioctl_slave_soe_read( |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3392 |
ec_master_t *master, /**< EtherCAT master. */ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3393 |
unsigned long arg /**< ioctl() argument. */ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3394 |
) |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3395 |
{ |
1837
32136215c1fa
Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
3396 |
ec_ioctl_slave_soe_read_t ioctl; |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3397 |
ec_master_soe_request_t request; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3398 |
int retval; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3399 |
|
1837
32136215c1fa
Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
3400 |
if (copy_from_user(&ioctl, (void __user *) arg, sizeof(ioctl))) { |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3401 |
return -EFAULT; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3402 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3403 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3404 |
ec_soe_request_init(&request.req); |
1837
32136215c1fa
Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
3405 |
ec_soe_request_set_idn(&request.req, ioctl.idn); |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3406 |
ec_soe_request_read(&request.req); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3407 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3408 |
if (down_interruptible(&master->master_sem)) |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3409 |
return -EINTR; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3410 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3411 |
if (!(request.slave = ec_master_find_slave( |
1837
32136215c1fa
Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
3412 |
master, 0, ioctl.slave_position))) { |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3413 |
up(&master->master_sem); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3414 |
ec_soe_request_clear(&request.req); |
1837
32136215c1fa
Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
3415 |
EC_ERR("Slave %u does not exist!\n", ioctl.slave_position); |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3416 |
return -EINVAL; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3417 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3418 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3419 |
// schedule request. |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3420 |
list_add_tail(&request.list, &request.slave->soe_requests); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3421 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3422 |
up(&master->master_sem); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3423 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3424 |
if (master->debug_level) { |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3425 |
EC_DBG("Scheduled SoE read request on slave %u.\n", |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3426 |
request.slave->ring_position); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3427 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3428 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3429 |
// wait for processing through FSM |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3430 |
if (wait_event_interruptible(request.slave->soe_queue, |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3431 |
request.req.state != EC_INT_REQUEST_QUEUED)) { |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3432 |
// interrupted by signal |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3433 |
down(&master->master_sem); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3434 |
if (request.req.state == EC_INT_REQUEST_QUEUED) { |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3435 |
list_del(&request.list); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3436 |
up(&master->master_sem); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3437 |
ec_soe_request_clear(&request.req); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3438 |
return -EINTR; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3439 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3440 |
// request already processing: interrupt not possible. |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3441 |
up(&master->master_sem); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3442 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3443 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3444 |
// wait until master FSM has finished processing |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3445 |
wait_event(request.slave->soe_queue, |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3446 |
request.req.state != EC_INT_REQUEST_BUSY); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3447 |
|
1837
32136215c1fa
Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
3448 |
ioctl.error_code = request.req.error_code; |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3449 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3450 |
if (master->debug_level) { |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3451 |
EC_DBG("Read %zd bytes via SoE.\n", request.req.data_size); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3452 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3453 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3454 |
if (request.req.state != EC_INT_REQUEST_SUCCESS) { |
1837
32136215c1fa
Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
3455 |
ioctl.data_size = 0; |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3456 |
retval = -EIO; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3457 |
} else { |
1837
32136215c1fa
Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
3458 |
if (request.req.data_size > ioctl.mem_size) { |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3459 |
EC_ERR("Buffer too small.\n"); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3460 |
ec_soe_request_clear(&request.req); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3461 |
return -EOVERFLOW; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3462 |
} |
1837
32136215c1fa
Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
3463 |
ioctl.data_size = request.req.data_size; |
32136215c1fa
Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
3464 |
if (copy_to_user((void __user *) ioctl.data, |
32136215c1fa
Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
3465 |
request.req.data, ioctl.data_size)) { |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3466 |
ec_soe_request_clear(&request.req); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3467 |
return -EFAULT; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3468 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3469 |
retval = 0; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3470 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3471 |
|
1837
32136215c1fa
Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
3472 |
if (__copy_to_user((void __user *) arg, &ioctl, sizeof(ioctl))) { |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3473 |
retval = -EFAULT; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3474 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3475 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3476 |
if (master->debug_level) |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3477 |
EC_DBG("SoE read request finished on slave %u.\n", |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3478 |
request.slave->ring_position); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3479 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3480 |
ec_soe_request_clear(&request.req); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3481 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3482 |
return retval; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3483 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3484 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3485 |
/*****************************************************************************/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3486 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3487 |
/** Write an IDN to a slave via SoE. |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3488 |
*/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3489 |
int ec_cdev_ioctl_slave_soe_write( |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3490 |
ec_master_t *master, /**< EtherCAT master. */ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3491 |
unsigned long arg /**< ioctl() argument. */ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3492 |
) |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3493 |
{ |
1837
32136215c1fa
Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
3494 |
ec_ioctl_slave_soe_write_t ioctl; |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3495 |
ec_master_soe_request_t request; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3496 |
int retval; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3497 |
|
1837
32136215c1fa
Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
3498 |
if (copy_from_user(&ioctl, (void __user *) arg, sizeof(ioctl))) { |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3499 |
return -EFAULT; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3500 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3501 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3502 |
INIT_LIST_HEAD(&request.list); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3503 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3504 |
ec_soe_request_init(&request.req); |
1837
32136215c1fa
Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
3505 |
ec_soe_request_set_idn(&request.req, ioctl.idn); |
32136215c1fa
Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
3506 |
|
32136215c1fa
Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
3507 |
if (ec_soe_request_alloc(&request.req, ioctl.data_size)) { |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3508 |
ec_soe_request_clear(&request.req); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3509 |
return -ENOMEM; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3510 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3511 |
if (copy_from_user(request.req.data, |
1837
32136215c1fa
Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
3512 |
(void __user *) ioctl.data, ioctl.data_size)) { |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3513 |
ec_soe_request_clear(&request.req); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3514 |
return -EFAULT; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3515 |
} |
1837
32136215c1fa
Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
3516 |
request.req.data_size = ioctl.data_size; |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3517 |
ec_soe_request_write(&request.req); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3518 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3519 |
if (down_interruptible(&master->master_sem)) |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3520 |
return -EINTR; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3521 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3522 |
if (!(request.slave = ec_master_find_slave( |
1837
32136215c1fa
Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
3523 |
master, 0, ioctl.slave_position))) { |
32136215c1fa
Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
3524 |
up(&master->master_sem); |
32136215c1fa
Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
3525 |
EC_ERR("Slave %u does not exist!\n", ioctl.slave_position); |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3526 |
ec_soe_request_clear(&request.req); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3527 |
return -EINVAL; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3528 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3529 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3530 |
if (master->debug_level) { |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3531 |
EC_DBG("Scheduling SoE write request.\n"); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3532 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3533 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3534 |
// schedule SoE write request. |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3535 |
list_add_tail(&request.list, &request.slave->soe_requests); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3536 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3537 |
up(&master->master_sem); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3538 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3539 |
// wait for processing through FSM |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3540 |
if (wait_event_interruptible(request.slave->soe_queue, |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3541 |
request.req.state != EC_INT_REQUEST_QUEUED)) { |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3542 |
// interrupted by signal |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3543 |
down(&master->master_sem); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3544 |
if (request.req.state == EC_INT_REQUEST_QUEUED) { |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3545 |
// abort request |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3546 |
list_del(&request.list); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3547 |
up(&master->master_sem); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3548 |
ec_soe_request_clear(&request.req); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3549 |
return -EINTR; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3550 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3551 |
up(&master->master_sem); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3552 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3553 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3554 |
// wait until master FSM has finished processing |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3555 |
wait_event(request.slave->soe_queue, |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3556 |
request.req.state != EC_INT_REQUEST_BUSY); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3557 |
|
1839
7f36c38e2518
Fixed returning SoE error code.
Florian Pose <fp@igh-essen.com>
parents:
1837
diff
changeset
|
3558 |
ioctl.error_code = request.req.error_code; |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3559 |
retval = request.req.state == EC_INT_REQUEST_SUCCESS ? 0 : -EIO; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3560 |
|
1837
32136215c1fa
Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
3561 |
if (__copy_to_user((void __user *) arg, &ioctl, sizeof(ioctl))) { |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3562 |
retval = -EFAULT; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3563 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3564 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3565 |
ec_soe_request_clear(&request.req); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3566 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3567 |
if (master->debug_level) { |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3568 |
EC_DBG("Finished SoE writing.\n"); |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3569 |
} |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3570 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3571 |
return retval; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3572 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3573 |
|
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3574 |
/****************************************************************************** |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3575 |
* File operations |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3576 |
*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3577 |
|
1092 | 3578 |
/** Called when the cdev is opened. |
3579 |
*/ |
|
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3580 |
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
|
3581 |
{ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3582 |
ec_cdev_t *cdev = container_of(inode->i_cdev, ec_cdev_t, cdev); |
1242
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
3583 |
ec_cdev_priv_t *priv; |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
3584 |
|
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
3585 |
priv = kmalloc(sizeof(ec_cdev_priv_t), GFP_KERNEL); |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
3586 |
if (!priv) { |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
3587 |
EC_ERR("Failed to allocate memory for private data structure.\n"); |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
3588 |
return -ENOMEM; |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
3589 |
} |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
3590 |
|
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
3591 |
priv->cdev = cdev; |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
3592 |
priv->requested = 0; |
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3593 |
priv->process_data = NULL; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3594 |
priv->process_data_size = 0; |
1242
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
3595 |
|
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
3596 |
filp->private_data = priv; |
1397 | 3597 |
|
3598 |
#if DEBUG_IOCTL |
|
3599 |
EC_DBG("File opened.\n"); |
|
3600 |
#endif |
|
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3601 |
return 0; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3602 |
} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3603 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3604 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3605 |
|
1092 | 3606 |
/** Called when the cdev is closed. |
3607 |
*/ |
|
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3608 |
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
|
3609 |
{ |
1242
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
3610 |
ec_cdev_priv_t *priv = (ec_cdev_priv_t *) filp->private_data; |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
3611 |
ec_master_t *master = priv->cdev->master; |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
3612 |
|
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
3613 |
if (priv->requested) |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
3614 |
ecrt_release_master(master); |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
3615 |
|
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3616 |
if (priv->process_data) |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3617 |
vfree(priv->process_data); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3618 |
|
1397 | 3619 |
#if DEBUG_IOCTL |
3620 |
EC_DBG("File closed.\n"); |
|
3621 |
#endif |
|
3622 |
||
1242
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
3623 |
kfree(priv); |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3624 |
return 0; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3625 |
} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3626 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3627 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3628 |
|
1092 | 3629 |
/** Called when an ioctl() command is issued. |
3630 |
*/ |
|
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
3631 |
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
|
3632 |
{ |
1242
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
3633 |
ec_cdev_priv_t *priv = (ec_cdev_priv_t *) filp->private_data; |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
3634 |
ec_master_t *master = priv->cdev->master; |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3635 |
|
1397 | 3636 |
#if DEBUG_IOCTL |
3637 |
EC_DBG("ioctl(filp = 0x%x, cmd = 0x%08x (0x%02x), arg = 0x%x)\n", |
|
3638 |
(u32) filp, (u32) cmd, (u32) _IOC_NR(cmd), (u32) arg); |
|
3639 |
#endif |
|
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
3640 |
|
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3641 |
switch (cmd) { |
1826
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
3642 |
case EC_IOCTL_MODULE: |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
3643 |
return ec_cdev_ioctl_module(arg); |
957
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
3644 |
case EC_IOCTL_MASTER: |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3645 |
return ec_cdev_ioctl_master(master, arg); |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
3646 |
case EC_IOCTL_SLAVE: |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3647 |
return ec_cdev_ioctl_slave(master, arg); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3648 |
case EC_IOCTL_SLAVE_SYNC: |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3649 |
return ec_cdev_ioctl_slave_sync(master, arg); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3650 |
case EC_IOCTL_SLAVE_SYNC_PDO: |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3651 |
return ec_cdev_ioctl_slave_sync_pdo(master, arg); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3652 |
case EC_IOCTL_SLAVE_SYNC_PDO_ENTRY: |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3653 |
return ec_cdev_ioctl_slave_sync_pdo_entry(master, arg); |
948
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
3654 |
case EC_IOCTL_DOMAIN: |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3655 |
return ec_cdev_ioctl_domain(master, arg); |
950
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
3656 |
case EC_IOCTL_DOMAIN_FMMU: |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3657 |
return ec_cdev_ioctl_domain_fmmu(master, arg); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3658 |
case EC_IOCTL_DOMAIN_DATA: |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3659 |
return ec_cdev_ioctl_domain_data(master, arg); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3660 |
case EC_IOCTL_MASTER_DEBUG: |
972 | 3661 |
if (!(filp->f_mode & FMODE_WRITE)) |
3662 |
return -EPERM; |
|
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3663 |
return ec_cdev_ioctl_master_debug(master, arg); |
960
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
3664 |
case EC_IOCTL_SLAVE_STATE: |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3665 |
if (!(filp->f_mode & FMODE_WRITE)) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3666 |
return -EPERM; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3667 |
return ec_cdev_ioctl_slave_state(master, arg); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3668 |
case EC_IOCTL_SLAVE_SDO: |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3669 |
return ec_cdev_ioctl_slave_sdo(master, arg); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3670 |
case EC_IOCTL_SLAVE_SDO_ENTRY: |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3671 |
return ec_cdev_ioctl_slave_sdo_entry(master, arg); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3672 |
case EC_IOCTL_SLAVE_SDO_UPLOAD: |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3673 |
return ec_cdev_ioctl_slave_sdo_upload(master, arg); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3674 |
case EC_IOCTL_SLAVE_SDO_DOWNLOAD: |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3675 |
if (!(filp->f_mode & FMODE_WRITE)) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3676 |
return -EPERM; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3677 |
return ec_cdev_ioctl_slave_sdo_download(master, arg); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3678 |
case EC_IOCTL_SLAVE_SII_READ: |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3679 |
return ec_cdev_ioctl_slave_sii_read(master, arg); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3680 |
case EC_IOCTL_SLAVE_SII_WRITE: |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3681 |
if (!(filp->f_mode & FMODE_WRITE)) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3682 |
return -EPERM; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3683 |
return ec_cdev_ioctl_slave_sii_write(master, arg); |
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1382
diff
changeset
|
3684 |
case EC_IOCTL_SLAVE_REG_READ: |
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1382
diff
changeset
|
3685 |
return ec_cdev_ioctl_slave_reg_read(master, arg); |
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1382
diff
changeset
|
3686 |
case EC_IOCTL_SLAVE_REG_WRITE: |
1200 | 3687 |
if (!(filp->f_mode & FMODE_WRITE)) |
3688 |
return -EPERM; |
|
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1382
diff
changeset
|
3689 |
return ec_cdev_ioctl_slave_reg_write(master, arg); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3690 |
case EC_IOCTL_SLAVE_FOE_READ: |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3691 |
return ec_cdev_ioctl_slave_foe_read(master, arg); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3692 |
case EC_IOCTL_SLAVE_FOE_WRITE: |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3693 |
if (!(filp->f_mode & FMODE_WRITE)) |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3694 |
return -EPERM; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1328
diff
changeset
|
3695 |
return ec_cdev_ioctl_slave_foe_write(master, arg); |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3696 |
case EC_IOCTL_SLAVE_SOE_READ: |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3697 |
return ec_cdev_ioctl_slave_soe_read(master, arg); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3698 |
case EC_IOCTL_SLAVE_SOE_WRITE: |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3699 |
if (!(filp->f_mode & FMODE_WRITE)) |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3700 |
return -EPERM; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
3701 |
return ec_cdev_ioctl_slave_soe_write(master, arg); |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
3702 |
case EC_IOCTL_CONFIG: |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3703 |
return ec_cdev_ioctl_config(master, arg); |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
3704 |
case EC_IOCTL_CONFIG_PDO: |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3705 |
return ec_cdev_ioctl_config_pdo(master, arg); |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
3706 |
case EC_IOCTL_CONFIG_PDO_ENTRY: |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3707 |
return ec_cdev_ioctl_config_pdo_entry(master, arg); |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
3708 |
case EC_IOCTL_CONFIG_SDO: |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3709 |
return ec_cdev_ioctl_config_sdo(master, arg); |
1516
e3b09f847512
Fixed compiler error on --disable-eoe.
Florian Pose <fp@igh-essen.com>
parents:
1513
diff
changeset
|
3710 |
#ifdef EC_EOE |
1485 | 3711 |
case EC_IOCTL_EOE_HANDLER: |
3712 |
return ec_cdev_ioctl_eoe_handler(master, arg); |
|
1516
e3b09f847512
Fixed compiler error on --disable-eoe.
Florian Pose <fp@igh-essen.com>
parents:
1513
diff
changeset
|
3713 |
#endif |
1242
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
3714 |
case EC_IOCTL_REQUEST: |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
3715 |
if (!(filp->f_mode & FMODE_WRITE)) |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3716 |
return -EPERM; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3717 |
return ec_cdev_ioctl_request(master, arg, priv); |
1244
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
3718 |
case EC_IOCTL_CREATE_DOMAIN: |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
3719 |
if (!(filp->f_mode & FMODE_WRITE)) |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3720 |
return -EPERM; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3721 |
return ec_cdev_ioctl_create_domain(master, arg, priv); |
1246
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
3722 |
case EC_IOCTL_CREATE_SLAVE_CONFIG: |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
3723 |
if (!(filp->f_mode & FMODE_WRITE)) |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3724 |
return -EPERM; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3725 |
return ec_cdev_ioctl_create_slave_config(master, arg, priv); |
1247
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
3726 |
case EC_IOCTL_ACTIVATE: |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
3727 |
if (!(filp->f_mode & FMODE_WRITE)) |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3728 |
return -EPERM; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3729 |
return ec_cdev_ioctl_activate(master, arg, priv); |
1531
6c5478400e28
Implemented ecrt_master_deactivate() in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
3730 |
case EC_IOCTL_DEACTIVATE: |
6c5478400e28
Implemented ecrt_master_deactivate() in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
3731 |
if (!(filp->f_mode & FMODE_WRITE)) |
6c5478400e28
Implemented ecrt_master_deactivate() in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
3732 |
return -EPERM; |
6c5478400e28
Implemented ecrt_master_deactivate() in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
3733 |
return ec_cdev_ioctl_deactivate(master, arg, priv); |
1247
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
3734 |
case EC_IOCTL_SEND: |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
3735 |
if (!(filp->f_mode & FMODE_WRITE)) |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3736 |
return -EPERM; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3737 |
return ec_cdev_ioctl_send(master, arg, priv); |
1247
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
3738 |
case EC_IOCTL_RECEIVE: |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
3739 |
if (!(filp->f_mode & FMODE_WRITE)) |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3740 |
return -EPERM; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3741 |
return ec_cdev_ioctl_receive(master, arg, priv); |
1259
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
3742 |
case EC_IOCTL_MASTER_STATE: |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3743 |
return ec_cdev_ioctl_master_state(master, arg, priv); |
1978
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1862
diff
changeset
|
3744 |
case EC_IOCTL_MASTER_SC_STATE: |
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1862
diff
changeset
|
3745 |
return ec_cdev_ioctl_master_sc_state(master, arg, priv); |
1454 | 3746 |
case EC_IOCTL_APP_TIME: |
3747 |
if (!(filp->f_mode & FMODE_WRITE)) |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3748 |
return -EPERM; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3749 |
return ec_cdev_ioctl_app_time(master, arg, priv); |
1413
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
3750 |
case EC_IOCTL_SYNC_REF: |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
3751 |
if (!(filp->f_mode & FMODE_WRITE)) |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3752 |
return -EPERM; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3753 |
return ec_cdev_ioctl_sync_ref(master, arg, priv); |
1413
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
3754 |
case EC_IOCTL_SYNC_SLAVES: |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
3755 |
if (!(filp->f_mode & FMODE_WRITE)) |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3756 |
return -EPERM; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3757 |
return ec_cdev_ioctl_sync_slaves(master, arg, priv); |
1535
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
3758 |
case EC_IOCTL_SYNC_MON_QUEUE: |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
3759 |
if (!(filp->f_mode & FMODE_WRITE)) |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
3760 |
return -EPERM; |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
3761 |
return ec_cdev_ioctl_sync_mon_queue(master, arg, priv); |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
3762 |
case EC_IOCTL_SYNC_MON_PROCESS: |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
3763 |
if (!(filp->f_mode & FMODE_WRITE)) |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
3764 |
return -EPERM; |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1531
diff
changeset
|
3765 |
return ec_cdev_ioctl_sync_mon_process(master, arg, priv); |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
3766 |
case EC_IOCTL_SC_SYNC: |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
3767 |
if (!(filp->f_mode & FMODE_WRITE)) |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3768 |
return -EPERM; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3769 |
return ec_cdev_ioctl_sc_sync(master, arg, priv); |
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
3770 |
case EC_IOCTL_SC_WATCHDOG: |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
3771 |
if (!(filp->f_mode & FMODE_WRITE)) |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
3772 |
return -EPERM; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
3773 |
return ec_cdev_ioctl_sc_watchdog(master, arg, priv); |
1981
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
3774 |
case EC_IOCTL_SC_OVERLAPPING_IO: |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
3775 |
if (!(filp->f_mode & FMODE_WRITE)) |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
3776 |
return -EPERM; |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
3777 |
return ec_cdev_ioctl_sc_allow_overlapping_pdos(master,arg,priv); |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
3778 |
case EC_IOCTL_SC_ADD_PDO: |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
3779 |
if (!(filp->f_mode & FMODE_WRITE)) |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3780 |
return -EPERM; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3781 |
return ec_cdev_ioctl_sc_add_pdo(master, arg, priv); |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
3782 |
case EC_IOCTL_SC_CLEAR_PDOS: |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
3783 |
if (!(filp->f_mode & FMODE_WRITE)) |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3784 |
return -EPERM; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3785 |
return ec_cdev_ioctl_sc_clear_pdos(master, arg, priv); |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
3786 |
case EC_IOCTL_SC_ADD_ENTRY: |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
3787 |
if (!(filp->f_mode & FMODE_WRITE)) |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3788 |
return -EPERM; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3789 |
return ec_cdev_ioctl_sc_add_entry(master, arg, priv); |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
3790 |
case EC_IOCTL_SC_CLEAR_ENTRIES: |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
3791 |
if (!(filp->f_mode & FMODE_WRITE)) |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3792 |
return -EPERM; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3793 |
return ec_cdev_ioctl_sc_clear_entries(master, arg, priv); |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
3794 |
case EC_IOCTL_SC_REG_PDO_ENTRY: |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
3795 |
if (!(filp->f_mode & FMODE_WRITE)) |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3796 |
return -EPERM; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3797 |
return ec_cdev_ioctl_sc_reg_pdo_entry(master, arg, priv); |
1448
d7ba0c408a07
Merged ecrt_slave_config_dc_assign_activate() and
Florian Pose <fp@igh-essen.com>
parents:
1447
diff
changeset
|
3798 |
case EC_IOCTL_SC_DC: |
1413
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
3799 |
if (!(filp->f_mode & FMODE_WRITE)) |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3800 |
return -EPERM; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3801 |
return ec_cdev_ioctl_sc_dc(master, arg, priv); |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
3802 |
case EC_IOCTL_SC_SDO: |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
3803 |
if (!(filp->f_mode & FMODE_WRITE)) |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3804 |
return -EPERM; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3805 |
return ec_cdev_ioctl_sc_sdo(master, arg, priv); |
1352
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
3806 |
case EC_IOCTL_SC_SDO_REQUEST: |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
3807 |
if (!(filp->f_mode & FMODE_WRITE)) |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3808 |
return -EPERM; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3809 |
return ec_cdev_ioctl_sc_create_sdo_request(master, arg, priv); |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3810 |
case EC_IOCTL_SC_VOE: |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3811 |
if (!(filp->f_mode & FMODE_WRITE)) |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3812 |
return -EPERM; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3813 |
return ec_cdev_ioctl_sc_create_voe_handler(master, arg, priv); |
1259
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
3814 |
case EC_IOCTL_SC_STATE: |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3815 |
return ec_cdev_ioctl_sc_state(master, arg, priv); |
1862
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
3816 |
case EC_IOCTL_SC_IDN: |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
3817 |
if (!(filp->f_mode & FMODE_WRITE)) |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
3818 |
return -EPERM; |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1857
diff
changeset
|
3819 |
return ec_cdev_ioctl_sc_idn(master, arg, priv); |
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3820 |
case EC_IOCTL_DOMAIN_OFFSET: |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3821 |
return ec_cdev_ioctl_domain_offset(master, arg, priv); |
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3822 |
case EC_IOCTL_DOMAIN_PROCESS: |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3823 |
if (!(filp->f_mode & FMODE_WRITE)) |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3824 |
return -EPERM; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3825 |
return ec_cdev_ioctl_domain_process(master, arg, priv); |
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3826 |
case EC_IOCTL_DOMAIN_QUEUE: |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3827 |
if (!(filp->f_mode & FMODE_WRITE)) |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3828 |
return -EPERM; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3829 |
return ec_cdev_ioctl_domain_queue(master, arg, priv); |
1259
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
3830 |
case EC_IOCTL_DOMAIN_STATE: |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3831 |
return ec_cdev_ioctl_domain_state(master, arg, priv); |
1352
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
3832 |
case EC_IOCTL_SDO_REQUEST_TIMEOUT: |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
3833 |
if (!(filp->f_mode & FMODE_WRITE)) |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3834 |
return -EPERM; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3835 |
return ec_cdev_ioctl_sdo_request_timeout(master, arg, priv); |
1352
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
3836 |
case EC_IOCTL_SDO_REQUEST_STATE: |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3837 |
return ec_cdev_ioctl_sdo_request_state(master, arg, priv); |
1352
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
3838 |
case EC_IOCTL_SDO_REQUEST_READ: |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
3839 |
if (!(filp->f_mode & FMODE_WRITE)) |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3840 |
return -EPERM; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3841 |
return ec_cdev_ioctl_sdo_request_read(master, arg, priv); |
1352
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
3842 |
case EC_IOCTL_SDO_REQUEST_WRITE: |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
3843 |
if (!(filp->f_mode & FMODE_WRITE)) |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3844 |
return -EPERM; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3845 |
return ec_cdev_ioctl_sdo_request_write(master, arg, priv); |
1352
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
3846 |
case EC_IOCTL_SDO_REQUEST_DATA: |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3847 |
return ec_cdev_ioctl_sdo_request_data(master, arg, priv); |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3848 |
case EC_IOCTL_VOE_SEND_HEADER: |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3849 |
if (!(filp->f_mode & FMODE_WRITE)) |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3850 |
return -EPERM; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3851 |
return ec_cdev_ioctl_voe_send_header(master, arg, priv); |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3852 |
case EC_IOCTL_VOE_REC_HEADER: |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3853 |
return ec_cdev_ioctl_voe_rec_header(master, arg, priv); |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3854 |
case EC_IOCTL_VOE_READ: |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3855 |
if (!(filp->f_mode & FMODE_WRITE)) |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3856 |
return -EPERM; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3857 |
return ec_cdev_ioctl_voe_read(master, arg, priv); |
1314
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3858 |
case EC_IOCTL_VOE_READ_NOSYNC: |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
3859 |
if (!(filp->f_mode & FMODE_WRITE)) |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3860 |
return -EPERM; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3861 |
return ec_cdev_ioctl_voe_read_nosync(master, arg, priv); |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3862 |
case EC_IOCTL_VOE_WRITE: |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3863 |
if (!(filp->f_mode & FMODE_WRITE)) |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3864 |
return -EPERM; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3865 |
return ec_cdev_ioctl_voe_write(master, arg, priv); |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3866 |
case EC_IOCTL_VOE_EXEC: |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3867 |
if (!(filp->f_mode & FMODE_WRITE)) |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3868 |
return -EPERM; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3869 |
return ec_cdev_ioctl_voe_exec(master, arg, priv); |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
3870 |
case EC_IOCTL_VOE_DATA: |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
3871 |
return ec_cdev_ioctl_voe_data(master, arg, priv); |
1804 | 3872 |
case EC_IOCTL_SET_SEND_INTERVAL: |
3873 |
if (!(filp->f_mode & FMODE_WRITE)) |
|
3874 |
return -EPERM; |
|
3875 |
return ec_cdev_ioctl_set_send_interval(master,arg,priv); |
|
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3876 |
default: |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3877 |
return -ENOTTY; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3878 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3879 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3880 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
3881 |
/*****************************************************************************/ |
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3882 |
|
1268 | 3883 |
/** Memory-map callback for the EtherCAT character device. |
3884 |
* |
|
3885 |
* The actual mapping will be done in the eccdev_vma_nopage() callback of the |
|
3886 |
* virtual memory area. |
|
3887 |
*/ |
|
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3888 |
int eccdev_mmap( |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3889 |
struct file *filp, |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3890 |
struct vm_area_struct *vma |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3891 |
) |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3892 |
{ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3893 |
ec_cdev_priv_t *priv = (ec_cdev_priv_t *) filp->private_data; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3894 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3895 |
if (priv->cdev->master->debug_level) |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3896 |
EC_DBG("mmap()\n"); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3897 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3898 |
vma->vm_ops = &eccdev_vm_ops; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3899 |
vma->vm_flags |= VM_RESERVED; /* Pages will not be swapped out */ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3900 |
vma->vm_private_data = priv; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3901 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3902 |
return 0; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3903 |
} |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3904 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3905 |
/*****************************************************************************/ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3906 |
|
1272
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
3907 |
#if LINUX_VERSION_CODE >= PAGE_FAULT_VERSION |
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
3908 |
|
1268 | 3909 |
/** Page fault callback for a virtual memory area. |
3910 |
* |
|
3911 |
* Called at the first access on a virtual-memory area retrieved with |
|
3912 |
* ecdev_mmap(). |
|
3913 |
*/ |
|
1272
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
3914 |
static int eccdev_vma_fault( |
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
3915 |
struct vm_area_struct *vma, /**< Virtual memory area. */ |
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
3916 |
struct vm_fault *vmf /**< Fault data. */ |
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
3917 |
) |
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
3918 |
{ |
1284 | 3919 |
unsigned long offset = vmf->pgoff << PAGE_SHIFT; |
3920 |
ec_cdev_priv_t *priv = (ec_cdev_priv_t *) vma->vm_private_data; |
|
1272
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
3921 |
struct page *page; |
1284 | 3922 |
|
3923 |
if (offset >= priv->process_data_size) |
|
1272
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
3924 |
return VM_FAULT_SIGBUS; |
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
3925 |
|
1284 | 3926 |
page = vmalloc_to_page(priv->process_data + offset); |
3927 |
if (!page) |
|
3928 |
return VM_FAULT_SIGBUS; |
|
1272
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
3929 |
|
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
3930 |
get_page(page); |
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
3931 |
vmf->page = page; |
1284 | 3932 |
|
3933 |
if (priv->cdev->master->debug_level) |
|
3934 |
EC_DBG("Vma fault, virtual_address = %p, offset = %lu, page = %p\n", |
|
3935 |
vmf->virtual_address, offset, page); |
|
3936 |
||
1272
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
3937 |
return 0; |
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
3938 |
} |
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
3939 |
|
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
3940 |
#else |
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
3941 |
|
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
3942 |
/** Nopage callback for a virtual memory area. |
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
3943 |
* |
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
3944 |
* Called at the first access on a virtual-memory area retrieved with |
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
3945 |
* ecdev_mmap(). |
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
3946 |
*/ |
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3947 |
struct page *eccdev_vma_nopage( |
1268 | 3948 |
struct vm_area_struct *vma, /**< Virtual memory area initialized by |
3949 |
the kernel. */ |
|
3950 |
unsigned long address, /**< Requested virtual address. */ |
|
3951 |
int *type /**< Type output parameter. */ |
|
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3952 |
) |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3953 |
{ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3954 |
unsigned long offset; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3955 |
struct page *page = NOPAGE_SIGBUS; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3956 |
ec_cdev_priv_t *priv = (ec_cdev_priv_t *) vma->vm_private_data; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3957 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3958 |
offset = (address - vma->vm_start) + (vma->vm_pgoff << PAGE_SHIFT); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3959 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3960 |
if (offset >= priv->process_data_size) |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3961 |
return NOPAGE_SIGBUS; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3962 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3963 |
page = vmalloc_to_page(priv->process_data + offset); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3964 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3965 |
if (priv->cdev->master->debug_level) |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3966 |
EC_DBG("Nopage fault vma, address = %#lx, offset = %#lx, page = %p\n", |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3967 |
address, offset, page); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3968 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3969 |
get_page(page); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3970 |
if (type) |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3971 |
*type = VM_FAULT_MINOR; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3972 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3973 |
return page; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3974 |
} |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
3975 |
|
1272
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
3976 |
#endif |
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
3977 |
|
288c982acd23
Use .fault handler instead of .nopage handler from 2.6.23.
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
3978 |
/*****************************************************************************/ |