author | Florian Pose <fp@igh-essen.com> |
Wed, 15 Oct 2008 16:08:29 +0000 | |
changeset 1271 | 19f9e9b6cf2c |
parent 1268 | d9599395e89b |
child 1272 | 288c982acd23 |
permissions | -rw-r--r-- |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/****************************************************************************** |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
* $Id$ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
5 |
* Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
6 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT Master. |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
8 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
10 |
* and/or modify it under the terms of the GNU General Public License |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
11 |
* as published by the Free Software Foundation; either version 2 of the |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
12 |
* License, or (at your option) any later version. |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
13 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
14 |
* The IgH EtherCAT Master is distributed in the hope that it will be |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
15 |
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
17 |
* GNU General Public License for more details. |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
18 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
19 |
* You should have received a copy of the GNU General Public License |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
20 |
* along with the IgH EtherCAT Master; if not, write to the Free Software |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
21 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
22 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
23 |
* The right to use EtherCAT Technology is granted and comes free of |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
24 |
* charge under condition of compatibility of product made by |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
25 |
* Licensee. People intending to distribute/sell products based on the |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
26 |
* code, have to sign an agreement to guarantee that products using |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
27 |
* software based on IgH EtherCAT master stay compatible with the actual |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
* EtherCAT specification (which are released themselves as an open |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
29 |
* standard) as the (only) precondition to have the right to use EtherCAT |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
30 |
* Technology, IP and trade marks. |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
31 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
32 |
*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
34 |
/** |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
35 |
\file |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
36 |
EtherCAT master character device. |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
*/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
39 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
40 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
#include <linux/module.h> |
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
42 |
#include <linux/vmalloc.h> |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
43 |
#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
|
44 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
45 |
#include "cdev.h" |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
46 |
#include "master.h" |
950
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
47 |
#include "slave_config.h" |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
48 |
#include "voe_handler.h" |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
49 |
#include "ioctl.h" |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
50 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
51 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
52 |
|
1268 | 53 |
static int eccdev_open(struct inode *, struct file *); |
54 |
static int eccdev_release(struct inode *, struct file *); |
|
55 |
static long eccdev_ioctl(struct file *, unsigned int, unsigned long); |
|
56 |
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
|
57 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
58 |
static struct page *eccdev_vma_nopage( |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
59 |
struct vm_area_struct *, unsigned long, int *); |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
60 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
61 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
62 |
|
1268 | 63 |
/** File operation callbacks for the EtherCAT character device. |
64 |
*/ |
|
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
65 |
static struct file_operations eccdev_fops = { |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
66 |
.owner = THIS_MODULE, |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
67 |
.open = eccdev_open, |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
68 |
.release = eccdev_release, |
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
69 |
.unlocked_ioctl = eccdev_ioctl, |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
70 |
.mmap = eccdev_mmap |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
71 |
}; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
72 |
|
1268 | 73 |
/** Callbacks for a virtual memory area retrieved with ecdevc_mmap(). |
74 |
*/ |
|
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
75 |
struct vm_operations_struct eccdev_vm_ops = { |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
76 |
.nopage = eccdev_vma_nopage |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
77 |
}; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
78 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
79 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
80 |
|
1242
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
81 |
/** 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
|
82 |
*/ |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
83 |
typedef struct { |
1268 | 84 |
ec_cdev_t *cdev; /**< Character device. */ |
85 |
unsigned int requested; /**< Master wac requested via this file handle. */ |
|
86 |
uint8_t *process_data; /**< Total process data area. */ |
|
87 |
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
|
88 |
} ec_cdev_priv_t; |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
89 |
|
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
90 |
/*****************************************************************************/ |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
91 |
|
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
92 |
/** Constructor. |
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 |
* \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
|
95 |
*/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
96 |
int ec_cdev_init( |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
97 |
ec_cdev_t *cdev, /**< EtherCAT master character device. */ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
98 |
ec_master_t *master, /**< Parent master. */ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
99 |
dev_t dev_num /**< Device number. */ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
100 |
) |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
101 |
{ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
102 |
cdev->master = master; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
103 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
104 |
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
|
105 |
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
|
106 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
107 |
if (cdev_add(&cdev->cdev, |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
108 |
MKDEV(MAJOR(dev_num), master->index), 1)) { |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
109 |
EC_ERR("Failed to add character device!\n"); |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
110 |
return -1; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
111 |
} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
112 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
113 |
return 0; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
114 |
} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
115 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
116 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
117 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
118 |
/** Destructor. |
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 |
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
|
121 |
{ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
122 |
cdev_del(&cdev->cdev); |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
123 |
} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
124 |
|
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
125 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
126 |
|
1108
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
127 |
/** Copies a string to an ioctl structure. |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
128 |
*/ |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
129 |
void ec_cdev_strcpy( |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
130 |
char *target, /**< Target. */ |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
131 |
const char *source /**< Source. */ |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
132 |
) |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
133 |
{ |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
134 |
if (source) { |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
135 |
strncpy(target, source, EC_IOCTL_STRING_SIZE); |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
136 |
target[EC_IOCTL_STRING_SIZE - 1] = 0; |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
137 |
} else { |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
138 |
target[0] = 0; |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
139 |
} |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
140 |
} |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
141 |
|
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
142 |
/*****************************************************************************/ |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
143 |
|
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
144 |
/** Get master information. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
145 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
146 |
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
|
147 |
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
|
148 |
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
|
149 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
150 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
151 |
ec_ioctl_master_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
152 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
153 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
154 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
155 |
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
|
156 |
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
|
157 |
data.domain_count = ec_master_domain_count(master); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
158 |
data.phase = (uint8_t) master->phase; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
159 |
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
|
160 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
161 |
if (down_interruptible(&master->device_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
162 |
return -EINTR; |
1162
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
163 |
if (master->main_device.dev) { |
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
164 |
memcpy(data.devices[0].address, |
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
165 |
master->main_device.dev->dev_addr, ETH_ALEN); |
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
166 |
} else { |
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
167 |
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
|
168 |
} |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
169 |
data.devices[0].attached = master->main_device.dev ? 1 : 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
170 |
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
|
171 |
data.devices[0].rx_count = master->main_device.rx_count; |
1162
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
172 |
|
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
173 |
if (master->backup_device.dev) { |
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
174 |
memcpy(data.devices[1].address, |
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
175 |
master->backup_device.dev->dev_addr, ETH_ALEN); |
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
176 |
} else { |
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
177 |
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
|
178 |
} |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
179 |
data.devices[1].attached = master->backup_device.dev ? 1 : 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
180 |
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
|
181 |
data.devices[1].rx_count = master->backup_device.rx_count; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
182 |
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
|
183 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
184 |
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
|
185 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
186 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
187 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
188 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
189 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
190 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
191 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
192 |
/** Get slave information. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
193 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
194 |
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
|
195 |
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
|
196 |
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
|
197 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
198 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
199 |
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
|
200 |
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
|
201 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
202 |
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
|
203 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
204 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
205 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
206 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
207 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
208 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
209 |
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
|
210 |
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
|
211 |
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
|
212 |
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
|
213 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
214 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
215 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
216 |
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
|
217 |
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
|
218 |
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
|
219 |
data.serial_number = slave->sii.serial_number; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
220 |
data.alias = slave->sii.alias; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
221 |
data.rx_mailbox_offset = slave->sii.rx_mailbox_offset; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
222 |
data.rx_mailbox_size = slave->sii.rx_mailbox_size; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
223 |
data.tx_mailbox_offset = slave->sii.tx_mailbox_offset; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
224 |
data.tx_mailbox_size = slave->sii.tx_mailbox_size; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
225 |
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
|
226 |
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
|
227 |
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
|
228 |
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
|
229 |
data.current_on_ebus = slave->sii.current_on_ebus; |
1148
1762296870bd
Renamed state field to al_state.
Florian Pose <fp@igh-essen.com>
parents:
1147
diff
changeset
|
230 |
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
|
231 |
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
|
232 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
233 |
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
|
234 |
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
|
235 |
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
|
236 |
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
|
237 |
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
|
238 |
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
|
239 |
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
|
240 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
241 |
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
|
242 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
243 |
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
|
244 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
245 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
246 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
247 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
248 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
249 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
250 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
251 |
/** 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
|
252 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
253 |
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
|
254 |
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
|
255 |
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
|
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 |
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
|
259 |
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
|
260 |
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
|
261 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
262 |
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
|
263 |
return -EFAULT; |
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 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
266 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
267 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
268 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
269 |
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
|
270 |
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
|
271 |
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
|
272 |
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
|
273 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
274 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
275 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
276 |
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
|
277 |
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
|
278 |
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
|
279 |
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
|
280 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
281 |
} |
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 |
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
|
284 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
285 |
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
|
286 |
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
|
287 |
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
|
288 |
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
|
289 |
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
|
290 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
291 |
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
|
292 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
293 |
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
|
294 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
295 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
296 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
297 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
298 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
299 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
300 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
301 |
/** Get slave sync manager Pdo information. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
302 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
303 |
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
|
304 |
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
|
305 |
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
|
306 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
307 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
308 |
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
|
309 |
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
|
310 |
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
|
311 |
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
|
312 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
313 |
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
|
314 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
315 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
316 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
317 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
318 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
319 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
320 |
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
|
321 |
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
|
322 |
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
|
323 |
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
|
324 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
325 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
326 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
327 |
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
|
328 |
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
|
329 |
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
|
330 |
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
|
331 |
return -EINVAL; |
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 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
334 |
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
|
335 |
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
|
336 |
&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
|
337 |
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
|
338 |
EC_ERR("Sync manager %u does not contain a Pdo with " |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
339 |
"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
|
340 |
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
|
341 |
return -EINVAL; |
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 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
344 |
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
|
345 |
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
|
346 |
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
|
347 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
348 |
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
|
349 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
350 |
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
|
351 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
352 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
353 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
354 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
355 |
|
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 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
358 |
/** Get slave sync manager Pdo entry information. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
359 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
360 |
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
|
361 |
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
|
362 |
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
|
363 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
364 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
365 |
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
|
366 |
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
|
367 |
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
|
368 |
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
|
369 |
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
|
370 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
371 |
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
|
372 |
return -EFAULT; |
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 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
375 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
376 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
377 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
378 |
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
|
379 |
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
|
380 |
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
|
381 |
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
|
382 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
383 |
} |
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 (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
|
386 |
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
|
387 |
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
|
388 |
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
|
389 |
return -EINVAL; |
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 |
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
|
393 |
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
|
394 |
&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
|
395 |
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
|
396 |
EC_ERR("Sync manager %u does not contain a Pdo with " |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
397 |
"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
|
398 |
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
|
399 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
400 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
401 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
402 |
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
|
403 |
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
|
404 |
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
|
405 |
EC_ERR("Pdo 0x%04X does not contain an entry with " |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
406 |
"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
|
407 |
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
|
408 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
409 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
410 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
411 |
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
|
412 |
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
|
413 |
data.bit_length = entry->bit_length; |
1108
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
414 |
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
|
415 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
416 |
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
|
417 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
418 |
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
|
419 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
420 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
421 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
422 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
423 |
|
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 |
/** Get domain information. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
427 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
428 |
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
|
429 |
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
|
430 |
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
|
431 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
432 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
433 |
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
|
434 |
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
|
435 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
436 |
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
|
437 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
438 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
439 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
440 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
441 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
442 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
443 |
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
|
444 |
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
|
445 |
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
|
446 |
return -EINVAL; |
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 |
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
|
450 |
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
|
451 |
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
|
452 |
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
|
453 |
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
|
454 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
455 |
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
|
456 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
457 |
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
|
458 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
459 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
460 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
461 |
} |
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 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
464 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
465 |
/** 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
|
466 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
467 |
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
|
468 |
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
|
469 |
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
|
470 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
471 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
472 |
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
|
473 |
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
|
474 |
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
|
475 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
476 |
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
|
477 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
478 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
479 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
480 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
481 |
return -EINTR; |
1079
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 |
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
|
484 |
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
|
485 |
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
|
486 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
487 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
488 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
489 |
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
|
490 |
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
|
491 |
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
|
492 |
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
|
493 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
494 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
495 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
496 |
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
|
497 |
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
|
498 |
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
|
499 |
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
|
500 |
data.logical_address = fmmu->logical_start_address; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
501 |
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
|
502 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
503 |
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
|
504 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
505 |
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
|
506 |
return -EFAULT; |
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 |
return 0; |
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 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
511 |
/*****************************************************************************/ |
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 |
/** Get domain data. |
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 |
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
|
516 |
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
|
517 |
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
|
518 |
) |
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 |
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
|
521 |
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
|
522 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
523 |
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
|
524 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
525 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
526 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
527 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
528 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
529 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
530 |
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
|
531 |
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
|
532 |
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
|
533 |
return -EINVAL; |
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 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
536 |
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
|
537 |
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
|
538 |
EC_ERR("Data size mismatch %u/%u!\n", |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
539 |
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
|
540 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
541 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
542 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
543 |
if (copy_to_user((void __user *) data.target, domain->data, |
1223 | 544 |
domain->data_size)) { |
545 |
up(&master->master_sem); |
|
546 |
return -EFAULT; |
|
547 |
} |
|
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
548 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
549 |
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
|
550 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
551 |
} |
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 |
/*****************************************************************************/ |
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 |
/** 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
|
556 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
557 |
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
|
558 |
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
|
559 |
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
|
560 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
561 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
562 |
if (ec_master_debug_level(master, (unsigned int) arg)) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
563 |
return -EINVAL; |
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 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
566 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
567 |
|
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 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
570 |
/** Set slave state. |
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 |
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
|
573 |
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
|
574 |
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
|
575 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
576 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
577 |
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
|
578 |
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
|
579 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
580 |
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
|
581 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
582 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
583 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
584 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
585 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
586 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
587 |
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
|
588 |
master, 0, data.slave_position))) { |
1196 | 589 |
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
|
590 |
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
|
591 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
592 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
593 |
|
1150 | 594 |
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
|
595 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
596 |
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
|
597 |
return 0; |
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 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
600 |
/*****************************************************************************/ |
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 |
/** Get slave Sdo information. |
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 |
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
|
605 |
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
|
606 |
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
|
607 |
) |
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 |
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
|
610 |
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
|
611 |
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
|
612 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
613 |
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
|
614 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
615 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
616 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
617 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
618 |
return -EINTR; |
1079
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 |
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
|
621 |
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
|
622 |
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
|
623 |
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
|
624 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
625 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
626 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
627 |
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
|
628 |
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
|
629 |
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
|
630 |
EC_ERR("Sdo %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
|
631 |
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
|
632 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
633 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
634 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
635 |
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
|
636 |
data.max_subindex = sdo->max_subindex; |
1108
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
637 |
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
|
638 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
639 |
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
|
640 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
641 |
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
|
642 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
643 |
|
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 |
/** Get slave Sdo entry information. |
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_slave_sdo_entry( |
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 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
656 |
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
|
657 |
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
|
658 |
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
|
659 |
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
|
660 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
661 |
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
|
662 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
663 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
664 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
665 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
666 |
return -EINTR; |
1079
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 |
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
|
669 |
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
|
670 |
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
|
671 |
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
|
672 |
return -EINVAL; |
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 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
675 |
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
|
676 |
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
|
677 |
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
|
678 |
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
|
679 |
EC_ERR("Sdo %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
|
680 |
-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
|
681 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
682 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
683 |
} else { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
684 |
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
|
685 |
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
|
686 |
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
|
687 |
EC_ERR("Sdo 0x%04X 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
|
688 |
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
|
689 |
return -EINVAL; |
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 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
693 |
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
|
694 |
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
|
695 |
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
|
696 |
EC_ERR("Sdo entry 0x%04X:%02X does not exist " |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
697 |
"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
|
698 |
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
|
699 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
700 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
701 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
702 |
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
|
703 |
data.bit_length = entry->bit_length; |
1108
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
704 |
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
|
705 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
706 |
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
|
707 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
708 |
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
|
709 |
return -EFAULT; |
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 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
712 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
713 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
714 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
715 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
716 |
/** Upload Sdo. |
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 |
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
|
719 |
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
|
720 |
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
|
721 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
722 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
723 |
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
|
724 |
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
|
725 |
int retval; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
726 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
727 |
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
|
728 |
return -EFAULT; |
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 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
731 |
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
|
732 |
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
|
733 |
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
|
734 |
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
|
735 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
736 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
737 |
return -EINTR; |
1079
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 |
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
|
740 |
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
|
741 |
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
|
742 |
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
|
743 |
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
|
744 |
return -EINVAL; |
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 |
// schedule request. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
748 |
list_add_tail(&request.list, &master->slave_sdo_requests); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
749 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
750 |
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
|
751 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
752 |
// 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
|
753 |
if (wait_event_interruptible(master->sdo_queue, |
1209 | 754 |
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
|
755 |
// interrupted by signal |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
756 |
down(&master->master_sem); |
1209 | 757 |
if (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
|
758 |
list_del(&request.req.list); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
759 |
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
|
760 |
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
|
761 |
return -EINTR; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
762 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
763 |
// 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
|
764 |
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
|
765 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
766 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
767 |
// wait until master FSM has finished processing |
1209 | 768 |
wait_event(master->sdo_queue, 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
|
769 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
770 |
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
|
771 |
|
1209 | 772 |
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
|
773 |
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
|
774 |
retval = -EIO; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
775 |
} else { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
776 |
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
|
777 |
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
|
778 |
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
|
779 |
return -EOVERFLOW; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
780 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
781 |
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
|
782 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
783 |
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
|
784 |
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
|
785 |
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
|
786 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
787 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
788 |
retval = 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
789 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
790 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
791 |
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
|
792 |
retval = -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
793 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
794 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
795 |
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
|
796 |
return retval; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
797 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
798 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
799 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
800 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
801 |
/** Download Sdo. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
802 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
803 |
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
|
804 |
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
|
805 |
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
|
806 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
807 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
808 |
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
|
809 |
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
|
810 |
int retval; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
811 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
812 |
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
|
813 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
814 |
} |
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 |
// 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
|
817 |
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
|
818 |
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
|
819 |
return -EINVAL; |
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 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
822 |
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
|
823 |
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
|
824 |
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
|
825 |
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
|
826 |
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
|
827 |
return -ENOMEM; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
828 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
829 |
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
|
830 |
(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
|
831 |
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
|
832 |
return -EFAULT; |
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 |
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
|
835 |
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
|
836 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
837 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
838 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
839 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
840 |
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
|
841 |
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
|
842 |
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
|
843 |
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
|
844 |
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
|
845 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
846 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
847 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
848 |
// schedule request. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
849 |
list_add_tail(&request.list, &master->slave_sdo_requests); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
850 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
851 |
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
|
852 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
853 |
// 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
|
854 |
if (wait_event_interruptible(master->sdo_queue, |
1209 | 855 |
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
|
856 |
// interrupted by signal |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
857 |
down(&master->master_sem); |
1209 | 858 |
if (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
|
859 |
list_del(&request.req.list); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
860 |
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
|
861 |
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
|
862 |
return -EINTR; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
863 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
864 |
// 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
|
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 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
867 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
868 |
// wait until master FSM has finished processing |
1209 | 869 |
wait_event(master->sdo_queue, 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
|
870 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
871 |
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
|
872 |
|
1209 | 873 |
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
|
874 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
875 |
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
|
876 |
retval = -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
877 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
878 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
879 |
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
|
880 |
return retval; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
881 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
882 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
883 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
884 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
885 |
/** 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
|
886 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
887 |
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
|
888 |
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
|
889 |
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
|
890 |
) |
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 |
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
|
893 |
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
|
894 |
int retval; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
895 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
896 |
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
|
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 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
900 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
901 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
902 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
903 |
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
|
904 |
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
|
905 |
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
|
906 |
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
|
907 |
return -EINVAL; |
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 |
if (!data.nwords |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
911 |
|| 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
|
912 |
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
|
913 |
EC_ERR("Invalid SII read offset/size %u/%u for slave " |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
914 |
"SII size %u!\n", data.offset, |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
915 |
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
|
916 |
return -EINVAL; |
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 |
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
|
920 |
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
|
921 |
retval = -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
922 |
else |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
923 |
retval = 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
924 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
925 |
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
|
926 |
return retval; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
927 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
928 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
929 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
930 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
931 |
/** 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
|
932 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
933 |
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
|
934 |
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
|
935 |
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
|
936 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
937 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
938 |
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
|
939 |
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
|
940 |
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
|
941 |
uint16_t *words; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
942 |
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
|
943 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
944 |
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
|
945 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
946 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
947 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
948 |
if (!data.nwords) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
949 |
return 0; |
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 |
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
|
952 |
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
|
953 |
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
|
954 |
byte_size); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
955 |
return -ENOMEM; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
956 |
} |
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 |
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
|
959 |
(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
|
960 |
kfree(words); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
961 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
962 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
963 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
964 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
965 |
return -EINTR; |
1079
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 |
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
|
968 |
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
|
969 |
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
|
970 |
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
|
971 |
kfree(words); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
972 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
973 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
974 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
975 |
// 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
|
976 |
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
|
977 |
request.slave = slave; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
978 |
request.words = words; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
979 |
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
|
980 |
request.nwords = data.nwords; |
1209 | 981 |
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
|
982 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
983 |
// 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
|
984 |
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
|
985 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
986 |
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
|
987 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
988 |
// 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
|
989 |
if (wait_event_interruptible(master->sii_queue, |
1209 | 990 |
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
|
991 |
// interrupted by signal |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
992 |
down(&master->master_sem); |
1209 | 993 |
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
|
994 |
// abort request |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
995 |
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
|
996 |
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
|
997 |
kfree(words); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
998 |
return -EINTR; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
999 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1000 |
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
|
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 |
// wait until master FSM has finished processing |
1209 | 1004 |
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
|
1005 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1006 |
kfree(words); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1007 |
|
1209 | 1008 |
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
|
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 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1012 |
|
1200 | 1013 |
/** Read a slave's physical memory. |
1014 |
*/ |
|
1015 |
int ec_cdev_ioctl_slave_phy_read( |
|
1016 |
ec_master_t *master, /**< EtherCAT master. */ |
|
1017 |
unsigned long arg /**< ioctl() argument. */ |
|
1018 |
) |
|
1019 |
{ |
|
1020 |
ec_ioctl_slave_phy_t data; |
|
1021 |
ec_slave_t *slave; |
|
1022 |
uint8_t *contents; |
|
1023 |
ec_phy_request_t request; |
|
1024 |
||
1025 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
|
1026 |
return -EFAULT; |
|
1027 |
} |
|
1028 |
||
1029 |
if (!data.length) |
|
1030 |
return 0; |
|
1031 |
||
1032 |
if (!(contents = kmalloc(data.length, GFP_KERNEL))) { |
|
1033 |
EC_ERR("Failed to allocate %u bytes for phy data.\n", data.length); |
|
1034 |
return -ENOMEM; |
|
1035 |
} |
|
1036 |
||
1037 |
if (down_interruptible(&master->master_sem)) |
|
1038 |
return -EINTR; |
|
1039 |
||
1040 |
if (!(slave = ec_master_find_slave( |
|
1041 |
master, 0, data.slave_position))) { |
|
1042 |
up(&master->master_sem); |
|
1043 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
|
1044 |
return -EINVAL; |
|
1045 |
} |
|
1046 |
||
1047 |
// init phy request |
|
1048 |
INIT_LIST_HEAD(&request.list); |
|
1049 |
request.slave = slave; |
|
1050 |
request.dir = EC_DIR_INPUT; |
|
1051 |
request.data = contents; |
|
1052 |
request.offset = data.offset; |
|
1053 |
request.length = data.length; |
|
1209 | 1054 |
request.state = EC_INT_REQUEST_QUEUED; |
1200 | 1055 |
|
1056 |
// schedule request. |
|
1057 |
list_add_tail(&request.list, &master->phy_requests); |
|
1058 |
||
1059 |
up(&master->master_sem); |
|
1060 |
||
1061 |
// wait for processing through FSM |
|
1062 |
if (wait_event_interruptible(master->phy_queue, |
|
1209 | 1063 |
request.state != EC_INT_REQUEST_QUEUED)) { |
1200 | 1064 |
// interrupted by signal |
1065 |
down(&master->master_sem); |
|
1209 | 1066 |
if (request.state == EC_INT_REQUEST_QUEUED) { |
1200 | 1067 |
// abort request |
1068 |
list_del(&request.list); |
|
1069 |
up(&master->master_sem); |
|
1070 |
kfree(contents); |
|
1071 |
return -EINTR; |
|
1072 |
} |
|
1073 |
up(&master->master_sem); |
|
1074 |
} |
|
1075 |
||
1076 |
// wait until master FSM has finished processing |
|
1209 | 1077 |
wait_event(master->phy_queue, request.state != EC_INT_REQUEST_BUSY); |
1078 |
||
1079 |
if (request.state == EC_INT_REQUEST_SUCCESS) { |
|
1200 | 1080 |
if (copy_to_user((void __user *) data.data, contents, data.length)) |
1081 |
return -EFAULT; |
|
1082 |
} |
|
1083 |
kfree(contents); |
|
1084 |
||
1209 | 1085 |
return request.state == EC_INT_REQUEST_SUCCESS ? 0 : -EIO; |
1200 | 1086 |
} |
1087 |
||
1088 |
/*****************************************************************************/ |
|
1089 |
||
1090 |
/** Write a slave's physical memory. |
|
1091 |
*/ |
|
1092 |
int ec_cdev_ioctl_slave_phy_write( |
|
1093 |
ec_master_t *master, /**< EtherCAT master. */ |
|
1094 |
unsigned long arg /**< ioctl() argument. */ |
|
1095 |
) |
|
1096 |
{ |
|
1097 |
ec_ioctl_slave_phy_t data; |
|
1098 |
ec_slave_t *slave; |
|
1099 |
uint8_t *contents; |
|
1100 |
ec_phy_request_t request; |
|
1101 |
||
1102 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
|
1103 |
return -EFAULT; |
|
1104 |
} |
|
1105 |
||
1106 |
if (!data.length) |
|
1107 |
return 0; |
|
1108 |
||
1109 |
if (!(contents = kmalloc(data.length, GFP_KERNEL))) { |
|
1110 |
EC_ERR("Failed to allocate %u bytes for phy data.\n", data.length); |
|
1111 |
return -ENOMEM; |
|
1112 |
} |
|
1113 |
||
1114 |
if (copy_from_user(contents, (void __user *) data.data, data.length)) { |
|
1115 |
kfree(contents); |
|
1116 |
return -EFAULT; |
|
1117 |
} |
|
1118 |
||
1119 |
if (down_interruptible(&master->master_sem)) |
|
1120 |
return -EINTR; |
|
1121 |
||
1122 |
if (!(slave = ec_master_find_slave( |
|
1123 |
master, 0, data.slave_position))) { |
|
1124 |
up(&master->master_sem); |
|
1125 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
|
1126 |
kfree(contents); |
|
1127 |
return -EINVAL; |
|
1128 |
} |
|
1129 |
||
1130 |
// init phy request |
|
1131 |
INIT_LIST_HEAD(&request.list); |
|
1132 |
request.slave = slave; |
|
1133 |
request.dir = EC_DIR_OUTPUT; |
|
1134 |
request.data = contents; |
|
1135 |
request.offset = data.offset; |
|
1136 |
request.length = data.length; |
|
1209 | 1137 |
request.state = EC_INT_REQUEST_QUEUED; |
1200 | 1138 |
|
1139 |
// schedule request. |
|
1140 |
list_add_tail(&request.list, &master->phy_requests); |
|
1141 |
||
1142 |
up(&master->master_sem); |
|
1143 |
||
1144 |
// wait for processing through FSM |
|
1145 |
if (wait_event_interruptible(master->phy_queue, |
|
1209 | 1146 |
request.state != EC_INT_REQUEST_QUEUED)) { |
1200 | 1147 |
// interrupted by signal |
1148 |
down(&master->master_sem); |
|
1209 | 1149 |
if (request.state == EC_INT_REQUEST_QUEUED) { |
1200 | 1150 |
// abort request |
1151 |
list_del(&request.list); |
|
1152 |
up(&master->master_sem); |
|
1153 |
kfree(contents); |
|
1154 |
return -EINTR; |
|
1155 |
} |
|
1156 |
up(&master->master_sem); |
|
1157 |
} |
|
1158 |
||
1159 |
// wait until master FSM has finished processing |
|
1209 | 1160 |
wait_event(master->phy_queue, request.state != EC_INT_REQUEST_BUSY); |
1200 | 1161 |
|
1162 |
kfree(contents); |
|
1163 |
||
1209 | 1164 |
return request.state == EC_INT_REQUEST_SUCCESS ? 0 : -EIO; |
1200 | 1165 |
} |
1166 |
||
1167 |
/*****************************************************************************/ |
|
1168 |
||
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1169 |
/** 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
|
1170 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1171 |
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
|
1172 |
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
|
1173 |
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
|
1174 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1175 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1176 |
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
|
1177 |
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
|
1178 |
uint8_t i; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1179 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1180 |
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
|
1181 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1182 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1183 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
1184 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
1185 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1186 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1187 |
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
|
1188 |
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
|
1189 |
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
|
1190 |
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
|
1191 |
data.config_index); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1192 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1193 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1194 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1195 |
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
|
1196 |
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
|
1197 |
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
|
1198 |
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
|
1199 |
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
|
1200 |
data.syncs[i].dir = sc->sync_configs[i].dir; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1201 |
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
|
1202 |
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
|
1203 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1204 |
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
|
1205 |
data.slave_position = sc->slave ? sc->slave->ring_position : -1; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1206 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1207 |
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
|
1208 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1209 |
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
|
1210 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1211 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1212 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1213 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1214 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1215 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1216 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1217 |
/** Get slave configuration Pdo information. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1218 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1219 |
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
|
1220 |
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
|
1221 |
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
|
1222 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1223 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1224 |
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
|
1225 |
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
|
1226 |
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
|
1227 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1228 |
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
|
1229 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1230 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1231 |
|
1082
ff06c58e269c
Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
1232 |
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
|
1233 |
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
|
1234 |
data.sync_index); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1235 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1236 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1237 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
1238 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
1239 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1240 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1241 |
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
|
1242 |
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
|
1243 |
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
|
1244 |
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
|
1245 |
data.config_index); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1246 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1247 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1248 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1249 |
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
|
1250 |
&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
|
1251 |
data.pdo_pos))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1252 |
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
|
1253 |
EC_ERR("Invalid Pdo position!\n"); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1254 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1255 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1256 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1257 |
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
|
1258 |
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
|
1259 |
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
|
1260 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1261 |
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
|
1262 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1263 |
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
|
1264 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1265 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1266 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1267 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1268 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1269 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1270 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1271 |
/** Get slave configuration Pdo entry information. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1272 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1273 |
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
|
1274 |
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
|
1275 |
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
|
1276 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1277 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1278 |
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
|
1279 |
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
|
1280 |
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
|
1281 |
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
|
1282 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1283 |
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
|
1284 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1285 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1286 |
|
1082
ff06c58e269c
Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
1287 |
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
|
1288 |
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
|
1289 |
data.sync_index); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1290 |
return -EINVAL; |
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 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
1293 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
1294 |
return -EINTR; |
1079
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 |
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
|
1297 |
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
|
1298 |
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
|
1299 |
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
|
1300 |
data.config_index); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1301 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1302 |
} |
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 |
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
|
1305 |
&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
|
1306 |
data.pdo_pos))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1307 |
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
|
1308 |
EC_ERR("Invalid Pdo position!\n"); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1309 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1310 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1311 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1312 |
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
|
1313 |
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
|
1314 |
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
|
1315 |
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
|
1316 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1317 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1318 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1319 |
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
|
1320 |
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
|
1321 |
data.bit_length = entry->bit_length; |
1108
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
1322 |
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
|
1323 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1324 |
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
|
1325 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1326 |
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
|
1327 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1328 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1329 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1330 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1331 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1332 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1333 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1334 |
/** Get slave configuration Sdo information. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1335 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1336 |
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
|
1337 |
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
|
1338 |
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
|
1339 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1340 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1341 |
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
|
1342 |
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
|
1343 |
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
|
1344 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1345 |
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
|
1346 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1347 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1348 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
1349 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
1350 |
return -EINTR; |
1079
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 |
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
|
1353 |
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
|
1354 |
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
|
1355 |
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
|
1356 |
data.config_index); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1357 |
return -EINVAL; |
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 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1360 |
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
|
1361 |
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
|
1362 |
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
|
1363 |
EC_ERR("Invalid Sdo position!\n"); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1364 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1365 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1366 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1367 |
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
|
1368 |
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
|
1369 |
data.size = req->data_size; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1370 |
memcpy(&data.data, req->data, min((u32) data.size, (u32) 4)); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1371 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1372 |
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
|
1373 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1374 |
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
|
1375 |
return -EFAULT; |
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 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1378 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1379 |
|
1242
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1380 |
/*****************************************************************************/ |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1381 |
|
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1382 |
/** Request the master from userspace. |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1383 |
*/ |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1384 |
int ec_cdev_ioctl_request( |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1385 |
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
|
1386 |
unsigned long arg, /**< ioctl() argument. */ |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1387 |
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
|
1388 |
) |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1389 |
{ |
1244
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1390 |
ec_master_t *m; |
1242
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1391 |
int ret = 0; |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1392 |
|
1244
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1393 |
m = ecrt_request_master(master->index); |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1394 |
if (IS_ERR(m)) { |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1395 |
ret = PTR_ERR(m); |
1242
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1396 |
} else { |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1397 |
priv->requested = 1; |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1398 |
} |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1399 |
|
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1400 |
return ret; |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1401 |
} |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
1402 |
|
1244
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1403 |
/*****************************************************************************/ |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1404 |
|
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1405 |
/** Create a domain. |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1406 |
*/ |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1407 |
int ec_cdev_ioctl_create_domain( |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1408 |
ec_master_t *master, /**< EtherCAT master. */ |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1409 |
unsigned long arg, /**< ioctl() argument. */ |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1410 |
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
|
1411 |
) |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1412 |
{ |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1413 |
ec_domain_t *domain; |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1414 |
|
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1415 |
if (unlikely(!priv->requested)) |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1416 |
return -EPERM; |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1417 |
|
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1418 |
domain = ecrt_master_create_domain(master); |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1419 |
if (!domain) |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1420 |
return -ENOMEM; |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1421 |
|
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1422 |
return domain->index; |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1423 |
} |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
1424 |
|
1246
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1425 |
/*****************************************************************************/ |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1426 |
|
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1427 |
/** Create a slave configuration. |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1428 |
*/ |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1429 |
int ec_cdev_ioctl_create_slave_config( |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1430 |
ec_master_t *master, /**< EtherCAT master. */ |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1431 |
unsigned long arg, /**< ioctl() argument. */ |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1432 |
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
|
1433 |
) |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1434 |
{ |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1435 |
ec_ioctl_config_t data; |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1436 |
ec_slave_config_t *sc, *entry; |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1437 |
|
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1438 |
if (unlikely(!priv->requested)) |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1439 |
return -EPERM; |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1440 |
|
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1441 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1442 |
return -EFAULT; |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1443 |
} |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1444 |
|
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1445 |
sc = ecrt_master_slave_config(master, data.alias, data.position, |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1446 |
data.vendor_id, data.product_code); |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1447 |
if (!sc) |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1448 |
return -ENODEV; // FIXME |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1449 |
|
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1450 |
data.config_index = 0; |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1451 |
|
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1452 |
if (down_interruptible(&master->master_sem)) |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1453 |
return -EINTR; |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1454 |
|
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1455 |
list_for_each_entry(entry, &master->configs, list) { |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1456 |
if (entry == sc) |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1457 |
break; |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1458 |
data.config_index++; |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1459 |
} |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1460 |
|
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1461 |
up(&master->master_sem); |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1462 |
|
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1463 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1464 |
return -EFAULT; |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1465 |
|
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1466 |
return 0; |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1467 |
} |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
1468 |
|
1247
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1469 |
/*****************************************************************************/ |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1470 |
|
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1471 |
/** Activates the master. |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1472 |
*/ |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1473 |
int ec_cdev_ioctl_activate( |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1474 |
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
|
1475 |
unsigned long arg, /**< ioctl() argument. */ |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1476 |
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
|
1477 |
) |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1478 |
{ |
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1479 |
ec_domain_t *domain; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1480 |
off_t offset; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1481 |
|
1247
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1482 |
if (unlikely(!priv->requested)) |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1483 |
return -EPERM; |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1484 |
|
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1485 |
/* Get the sum of the domains' process data sizes. */ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1486 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1487 |
priv->process_data_size = 0; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1488 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1489 |
if (down_interruptible(&master->master_sem)) |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1490 |
return -EINTR; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1491 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1492 |
list_for_each_entry(domain, &master->domains, list) { |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1493 |
priv->process_data_size += ecrt_domain_size(domain); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1494 |
} |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1495 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1496 |
up(&master->master_sem); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1497 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1498 |
if (priv->process_data_size) { |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1499 |
priv->process_data = vmalloc(priv->process_data_size); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1500 |
if (!priv->process_data) { |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1501 |
priv->process_data_size = 0; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1502 |
return -ENOMEM; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1503 |
} |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1504 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1505 |
/* 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
|
1506 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1507 |
offset = 0; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1508 |
list_for_each_entry(domain, &master->domains, list) { |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1509 |
ecrt_domain_external_memory(domain, priv->process_data + offset); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1510 |
offset += ecrt_domain_size(domain); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1511 |
} |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1512 |
} |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1513 |
|
1247
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1514 |
if (ecrt_master_activate(master)) |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1515 |
return -EIO; |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1516 |
|
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1517 |
if (copy_to_user((void __user *) arg, |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1518 |
&priv->process_data_size, sizeof(size_t))) |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1519 |
return -EFAULT; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1520 |
|
1247
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1521 |
return 0; |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1522 |
} |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1523 |
|
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1524 |
/*****************************************************************************/ |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1525 |
|
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1526 |
/** Send frames. |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1527 |
*/ |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1528 |
int ec_cdev_ioctl_send( |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1529 |
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
|
1530 |
unsigned long arg, /**< ioctl() argument. */ |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1531 |
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
|
1532 |
) |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1533 |
{ |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1534 |
if (unlikely(!priv->requested)) |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1535 |
return -EPERM; |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1536 |
|
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1537 |
spin_lock_bh(&master->internal_lock); |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1538 |
ecrt_master_send(master); |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1539 |
spin_unlock_bh(&master->internal_lock); |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1540 |
return 0; |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1541 |
} |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1542 |
|
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1543 |
/*****************************************************************************/ |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1544 |
|
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1545 |
/** Receive frames. |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1546 |
*/ |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1547 |
int ec_cdev_ioctl_receive( |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1548 |
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
|
1549 |
unsigned long arg, /**< ioctl() argument. */ |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1550 |
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
|
1551 |
) |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1552 |
{ |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1553 |
if (unlikely(!priv->requested)) |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1554 |
return -EPERM; |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1555 |
|
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1556 |
spin_lock_bh(&master->internal_lock); |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1557 |
ecrt_master_receive(master); |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1558 |
spin_unlock_bh(&master->internal_lock); |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1559 |
return 0; |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1560 |
} |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
1561 |
|
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1562 |
/*****************************************************************************/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1563 |
|
1259
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1564 |
/** Get the master state. |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1565 |
*/ |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1566 |
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
|
1567 |
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
|
1568 |
unsigned long arg, /**< ioctl() argument. */ |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1569 |
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
|
1570 |
) |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1571 |
{ |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1572 |
ec_master_state_t data; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1573 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1574 |
if (unlikely(!priv->requested)) |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1575 |
return -EPERM; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1576 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1577 |
ecrt_master_state(master, &data); |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1578 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1579 |
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
|
1580 |
return -EFAULT; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1581 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1582 |
return 0; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1583 |
} |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1584 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1585 |
/*****************************************************************************/ |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1586 |
|
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1587 |
/** Set the direction of a sync manager. |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1588 |
*/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1589 |
int ec_cdev_ioctl_sc_sync( |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1590 |
ec_master_t *master, /**< EtherCAT master. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1591 |
unsigned long arg, /**< ioctl() argument. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1592 |
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
|
1593 |
) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1594 |
{ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1595 |
ec_ioctl_config_t data; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1596 |
ec_slave_config_t *sc; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1597 |
unsigned int i; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1598 |
int ret = 0; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1599 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1600 |
if (unlikely(!priv->requested)) { |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1601 |
ret = -EPERM; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1602 |
goto out_return; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1603 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1604 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1605 |
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
|
1606 |
ret = -EFAULT; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1607 |
goto out_return; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1608 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1609 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1610 |
if (down_interruptible(&master->master_sem)) { |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1611 |
ret = -EINTR; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1612 |
goto out_return; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1613 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1614 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1615 |
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
|
1616 |
ret = -ESRCH; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1617 |
goto out_up; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1618 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1619 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1620 |
for (i = 0; i < EC_MAX_SYNC_MANAGERS; i++) { |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1621 |
ec_direction_t dir = data.syncs[i].dir; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1622 |
if (dir == EC_DIR_INPUT || dir == EC_DIR_OUTPUT) { |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1623 |
if (ecrt_slave_config_sync_manager(sc, i, dir)) { |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1624 |
ret = -EINVAL; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1625 |
goto out_up; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1626 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1627 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1628 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1629 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1630 |
out_up: |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1631 |
up(&master->master_sem); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1632 |
out_return: |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1633 |
return ret; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1634 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1635 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1636 |
/*****************************************************************************/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1637 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1638 |
/** Add a Pdo to the assignment. |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1639 |
*/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1640 |
int ec_cdev_ioctl_sc_add_pdo( |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1641 |
ec_master_t *master, /**< EtherCAT master. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1642 |
unsigned long arg, /**< ioctl() argument. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1643 |
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
|
1644 |
) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1645 |
{ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1646 |
ec_ioctl_config_pdo_t data; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1647 |
ec_slave_config_t *sc; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1648 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1649 |
if (unlikely(!priv->requested)) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1650 |
return -EPERM; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1651 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1652 |
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
|
1653 |
return -EFAULT; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1654 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1655 |
if (down_interruptible(&master->master_sem)) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1656 |
return -EINTR; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1657 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1658 |
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
|
1659 |
up(&master->master_sem); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1660 |
return -ESRCH; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1661 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1662 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1663 |
up(&master->master_sem); // FIXME |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1664 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1665 |
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
|
1666 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1667 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1668 |
/*****************************************************************************/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1669 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1670 |
/** Clears the Pdo assignment. |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1671 |
*/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1672 |
int ec_cdev_ioctl_sc_clear_pdos( |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1673 |
ec_master_t *master, /**< EtherCAT master. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1674 |
unsigned long arg, /**< ioctl() argument. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1675 |
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
|
1676 |
) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1677 |
{ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1678 |
ec_ioctl_config_pdo_t data; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1679 |
ec_slave_config_t *sc; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1680 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1681 |
if (unlikely(!priv->requested)) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1682 |
return -EPERM; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1683 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1684 |
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
|
1685 |
return -EFAULT; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1686 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1687 |
if (down_interruptible(&master->master_sem)) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1688 |
return -EINTR; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1689 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1690 |
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
|
1691 |
up(&master->master_sem); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1692 |
return -ESRCH; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1693 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1694 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1695 |
up(&master->master_sem); // FIXME |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1696 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1697 |
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
|
1698 |
return 0; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1699 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1700 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1701 |
/*****************************************************************************/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1702 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1703 |
/** Add an entry to a Pdo's mapping. |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1704 |
*/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1705 |
int ec_cdev_ioctl_sc_add_entry( |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1706 |
ec_master_t *master, /**< EtherCAT master. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1707 |
unsigned long arg, /**< ioctl() argument. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1708 |
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
|
1709 |
) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1710 |
{ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1711 |
ec_ioctl_add_pdo_entry_t data; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1712 |
ec_slave_config_t *sc; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1713 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1714 |
if (unlikely(!priv->requested)) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1715 |
return -EPERM; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1716 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1717 |
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
|
1718 |
return -EFAULT; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1719 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1720 |
if (down_interruptible(&master->master_sem)) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1721 |
return -EINTR; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1722 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1723 |
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
|
1724 |
up(&master->master_sem); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1725 |
return -ESRCH; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1726 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1727 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1728 |
up(&master->master_sem); // FIXME |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1729 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1730 |
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
|
1731 |
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
|
1732 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1733 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1734 |
/*****************************************************************************/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1735 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1736 |
/** Clears the mapping of a Pdo. |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1737 |
*/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1738 |
int ec_cdev_ioctl_sc_clear_entries( |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1739 |
ec_master_t *master, /**< EtherCAT master. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1740 |
unsigned long arg, /**< ioctl() argument. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1741 |
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
|
1742 |
) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1743 |
{ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1744 |
ec_ioctl_config_pdo_t data; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1745 |
ec_slave_config_t *sc; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1746 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1747 |
if (unlikely(!priv->requested)) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1748 |
return -EPERM; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1749 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1750 |
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
|
1751 |
return -EFAULT; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1752 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1753 |
if (down_interruptible(&master->master_sem)) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1754 |
return -EINTR; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1755 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1756 |
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
|
1757 |
up(&master->master_sem); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1758 |
return -ESRCH; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1759 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1760 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1761 |
up(&master->master_sem); // FIXME |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1762 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1763 |
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
|
1764 |
return 0; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1765 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1766 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1767 |
/*****************************************************************************/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1768 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1769 |
/** Registers a Pdo entry. |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1770 |
*/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1771 |
int ec_cdev_ioctl_sc_reg_pdo_entry( |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1772 |
ec_master_t *master, /**< EtherCAT master. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1773 |
unsigned long arg, /**< ioctl() argument. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1774 |
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
|
1775 |
) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1776 |
{ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1777 |
ec_ioctl_reg_pdo_entry_t data; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1778 |
ec_slave_config_t *sc; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1779 |
ec_domain_t *domain; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1780 |
int ret; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1781 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1782 |
if (unlikely(!priv->requested)) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1783 |
return -EPERM; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1784 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1785 |
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
|
1786 |
return -EFAULT; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1787 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1788 |
if (down_interruptible(&master->master_sem)) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1789 |
return -EINTR; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1790 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1791 |
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
|
1792 |
up(&master->master_sem); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1793 |
return -ESRCH; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1794 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1795 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1796 |
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
|
1797 |
up(&master->master_sem); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1798 |
return -ESRCH; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1799 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1800 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1801 |
up(&master->master_sem); // FIXME |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1802 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1803 |
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
|
1804 |
data.entry_subindex, domain, &data.bit_position); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1805 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1806 |
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
|
1807 |
return -EFAULT; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1808 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1809 |
return ret; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1810 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1811 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1812 |
/*****************************************************************************/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1813 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1814 |
/** Configures an Sdo. |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1815 |
*/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1816 |
int ec_cdev_ioctl_sc_sdo( |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1817 |
ec_master_t *master, /**< EtherCAT master. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1818 |
unsigned long arg, /**< ioctl() argument. */ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1819 |
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
|
1820 |
) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1821 |
{ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1822 |
ec_ioctl_sc_sdo_t data; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1823 |
ec_slave_config_t *sc; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1824 |
uint8_t *sdo_data = NULL; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1825 |
int ret; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1826 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1827 |
if (unlikely(!priv->requested)) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1828 |
return -EPERM; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1829 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1830 |
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
|
1831 |
return -EFAULT; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1832 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1833 |
if (!data.size) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1834 |
return -EINVAL; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1835 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1836 |
if (!(sdo_data = kmalloc(data.size, GFP_KERNEL))) { |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1837 |
return -ENOMEM; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1838 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1839 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1840 |
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
|
1841 |
kfree(sdo_data); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1842 |
return -EFAULT; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1843 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1844 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1845 |
if (down_interruptible(&master->master_sem)) { |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1846 |
kfree(sdo_data); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1847 |
return -EINTR; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1848 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1849 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1850 |
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
|
1851 |
up(&master->master_sem); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1852 |
kfree(sdo_data); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1853 |
return -ESRCH; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1854 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1855 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1856 |
up(&master->master_sem); // FIXME |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1857 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1858 |
ret = ecrt_slave_config_sdo(sc, data.index, data.subindex, sdo_data, |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1859 |
data.size); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1860 |
kfree(sdo_data); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1861 |
return ret; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1862 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
1863 |
|
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1864 |
/*****************************************************************************/ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1865 |
|
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1866 |
/** Create a VoE handler. |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1867 |
*/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1868 |
int ec_cdev_ioctl_sc_create_voe_handler( |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1869 |
ec_master_t *master, /**< EtherCAT master. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1870 |
unsigned long arg, /**< ioctl() argument. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1871 |
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
|
1872 |
) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1873 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1874 |
ec_ioctl_voe_t data; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1875 |
ec_slave_config_t *sc; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1876 |
ec_voe_handler_t *voe; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1877 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1878 |
if (unlikely(!priv->requested)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1879 |
return -EPERM; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1880 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1881 |
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
|
1882 |
return -EFAULT; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1883 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1884 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1885 |
data.voe_index = 0; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1886 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1887 |
if (down_interruptible(&master->master_sem)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1888 |
return -EINTR; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1889 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1890 |
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
|
1891 |
if (!sc) { |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1892 |
up(&master->master_sem); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1893 |
return -ESRCH; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1894 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1895 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1896 |
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
|
1897 |
data.voe_index++; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1898 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1899 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1900 |
up(&master->master_sem); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1901 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1902 |
voe = ecrt_slave_config_create_voe_handler(sc, data.size); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1903 |
if (!voe) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1904 |
return -ENOMEM; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1905 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1906 |
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
|
1907 |
return -EFAULT; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1908 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1909 |
return 0; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1910 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1911 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1912 |
/*****************************************************************************/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
1913 |
|
1259
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1914 |
/** 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
|
1915 |
*/ |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1916 |
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
|
1917 |
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
|
1918 |
unsigned long arg, /**< ioctl() argument. */ |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1919 |
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
|
1920 |
) |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1921 |
{ |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1922 |
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
|
1923 |
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
|
1924 |
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
|
1925 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1926 |
if (unlikely(!priv->requested)) |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1927 |
return -EPERM; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1928 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1929 |
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
|
1930 |
return -EFAULT; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1931 |
} |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1932 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1933 |
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
|
1934 |
return -EINTR; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1935 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1936 |
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
|
1937 |
up(&master->master_sem); |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1938 |
return -ESRCH; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1939 |
} |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1940 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1941 |
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
|
1942 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1943 |
up(&master->master_sem); |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1944 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1945 |
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
|
1946 |
return -EFAULT; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1947 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1948 |
return 0; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1949 |
} |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1950 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1951 |
/*****************************************************************************/ |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
1952 |
|
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1953 |
/** 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
|
1954 |
*/ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1955 |
int ec_cdev_ioctl_domain_offset( |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1956 |
ec_master_t *master, /**< EtherCAT master. */ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1957 |
unsigned long arg, /**< ioctl() argument. */ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1958 |
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
|
1959 |
) |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1960 |
{ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1961 |
int offset = 0; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1962 |
const ec_domain_t *domain; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1963 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1964 |
if (unlikely(!priv->requested)) |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1965 |
return -EPERM; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1966 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1967 |
if (down_interruptible(&master->master_sem)) { |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1968 |
return -EINTR; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1969 |
} |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1970 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1971 |
list_for_each_entry(domain, &master->domains, list) { |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1972 |
if (domain->index == arg) { |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1973 |
up(&master->master_sem); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1974 |
return offset; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1975 |
} |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1976 |
offset += ecrt_domain_size(domain); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1977 |
} |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1978 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1979 |
up(&master->master_sem); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1980 |
return -ESRCH; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1981 |
} |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1982 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1983 |
/*****************************************************************************/ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1984 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1985 |
/** Process the domain. |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1986 |
*/ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1987 |
int ec_cdev_ioctl_domain_process( |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1988 |
ec_master_t *master, /**< EtherCAT master. */ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1989 |
unsigned long arg, /**< ioctl() argument. */ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1990 |
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
|
1991 |
) |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1992 |
{ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1993 |
ec_domain_t *domain; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1994 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1995 |
if (unlikely(!priv->requested)) |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1996 |
return -EPERM; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1997 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1998 |
if (down_interruptible(&master->master_sem)) |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
1999 |
return -EINTR; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2000 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2001 |
if (!(domain = ec_master_find_domain(master, arg))) { |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2002 |
up(&master->master_sem); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2003 |
return -ESRCH; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2004 |
} |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2005 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2006 |
ecrt_domain_process(domain); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2007 |
up(&master->master_sem); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2008 |
return 0; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2009 |
} |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2010 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2011 |
/*****************************************************************************/ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2012 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2013 |
/** Queue the domain. |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2014 |
*/ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2015 |
int ec_cdev_ioctl_domain_queue( |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2016 |
ec_master_t *master, /**< EtherCAT master. */ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2017 |
unsigned long arg, /**< ioctl() argument. */ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2018 |
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
|
2019 |
) |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2020 |
{ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2021 |
ec_domain_t *domain; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2022 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2023 |
if (unlikely(!priv->requested)) |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2024 |
return -EPERM; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2025 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2026 |
if (down_interruptible(&master->master_sem)) |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2027 |
return -EINTR; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2028 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2029 |
if (!(domain = ec_master_find_domain(master, arg))) { |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2030 |
up(&master->master_sem); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2031 |
return -ESRCH; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2032 |
} |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2033 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2034 |
ecrt_domain_queue(domain); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2035 |
up(&master->master_sem); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2036 |
return 0; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2037 |
} |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2038 |
|
1259
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2039 |
/*****************************************************************************/ |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2040 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2041 |
/** Get the domain state. |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2042 |
*/ |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2043 |
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
|
2044 |
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
|
2045 |
unsigned long arg, /**< ioctl() argument. */ |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2046 |
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
|
2047 |
) |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2048 |
{ |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2049 |
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
|
2050 |
const ec_domain_t *domain; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2051 |
ec_domain_state_t state; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2052 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2053 |
if (unlikely(!priv->requested)) |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2054 |
return -EPERM; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2055 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2056 |
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
|
2057 |
return -EFAULT; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2058 |
} |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2059 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2060 |
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
|
2061 |
return -EINTR; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2062 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2063 |
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
|
2064 |
up(&master->master_sem); |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2065 |
return -ESRCH; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2066 |
} |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2067 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2068 |
ecrt_domain_state(domain, &state); |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2069 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2070 |
up(&master->master_sem); |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2071 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2072 |
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
|
2073 |
return -EFAULT; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2074 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2075 |
return 0; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2076 |
} |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2077 |
|
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2078 |
/*****************************************************************************/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2079 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2080 |
/** Sets the VoE send header. |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2081 |
*/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2082 |
int ec_cdev_ioctl_voe_send_header( |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2083 |
ec_master_t *master, /**< EtherCAT master. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2084 |
unsigned long arg, /**< ioctl() argument. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2085 |
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
|
2086 |
) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2087 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2088 |
ec_ioctl_voe_t data; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2089 |
ec_slave_config_t *sc; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2090 |
ec_voe_handler_t *voe; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2091 |
uint32_t vendor_id; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2092 |
uint16_t vendor_type; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2093 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2094 |
if (unlikely(!priv->requested)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2095 |
return -EPERM; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2096 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2097 |
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
|
2098 |
return -EFAULT; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2099 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2100 |
if (get_user(vendor_id, data.vendor_id)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2101 |
return -EFAULT; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2102 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2103 |
if (get_user(vendor_type, data.vendor_type)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2104 |
return -EFAULT; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2105 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2106 |
if (down_interruptible(&master->master_sem)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2107 |
return -EINTR; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2108 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2109 |
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
|
2110 |
up(&master->master_sem); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2111 |
return -ESRCH; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2112 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2113 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2114 |
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
|
2115 |
up(&master->master_sem); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2116 |
return -ESRCH; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2117 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2118 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2119 |
up(&master->master_sem); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2120 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2121 |
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
|
2122 |
return 0; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2123 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2124 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2125 |
/*****************************************************************************/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2126 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2127 |
/** Gets the received VoE header. |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2128 |
*/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2129 |
int ec_cdev_ioctl_voe_rec_header( |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2130 |
ec_master_t *master, /**< EtherCAT master. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2131 |
unsigned long arg, /**< ioctl() argument. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2132 |
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
|
2133 |
) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2134 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2135 |
ec_ioctl_voe_t data; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2136 |
ec_slave_config_t *sc; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2137 |
ec_voe_handler_t *voe; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2138 |
uint32_t vendor_id; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2139 |
uint16_t vendor_type; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2140 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2141 |
if (unlikely(!priv->requested)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2142 |
return -EPERM; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2143 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2144 |
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
|
2145 |
return -EFAULT; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2146 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2147 |
if (down_interruptible(&master->master_sem)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2148 |
return -EINTR; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2149 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2150 |
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
|
2151 |
up(&master->master_sem); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2152 |
return -ESRCH; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2153 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2154 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2155 |
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
|
2156 |
up(&master->master_sem); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2157 |
return -ESRCH; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2158 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2159 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2160 |
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
|
2161 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2162 |
up(&master->master_sem); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2163 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2164 |
if (likely(data.vendor_id)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2165 |
if (put_user(vendor_id, data.vendor_id)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2166 |
return -EFAULT; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2167 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2168 |
if (likely(data.vendor_type)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2169 |
if (put_user(vendor_type, data.vendor_type)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2170 |
return -EFAULT; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2171 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2172 |
return 0; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2173 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2174 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2175 |
/*****************************************************************************/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2176 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2177 |
/** Starts a VoE read operation. |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2178 |
*/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2179 |
int ec_cdev_ioctl_voe_read( |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2180 |
ec_master_t *master, /**< EtherCAT master. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2181 |
unsigned long arg, /**< ioctl() argument. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2182 |
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
|
2183 |
) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2184 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2185 |
ec_ioctl_voe_t data; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2186 |
ec_slave_config_t *sc; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2187 |
ec_voe_handler_t *voe; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2188 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2189 |
if (unlikely(!priv->requested)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2190 |
return -EPERM; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2191 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2192 |
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
|
2193 |
return -EFAULT; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2194 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2195 |
if (down_interruptible(&master->master_sem)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2196 |
return -EINTR; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2197 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2198 |
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
|
2199 |
up(&master->master_sem); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2200 |
return -ESRCH; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2201 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2202 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2203 |
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
|
2204 |
up(&master->master_sem); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2205 |
return -ESRCH; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2206 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2207 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2208 |
up(&master->master_sem); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2209 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2210 |
ecrt_voe_handler_read(voe); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2211 |
return 0; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2212 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2213 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2214 |
/*****************************************************************************/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2215 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2216 |
/** Starts a VoE write operation. |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2217 |
*/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2218 |
int ec_cdev_ioctl_voe_write( |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2219 |
ec_master_t *master, /**< EtherCAT master. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2220 |
unsigned long arg, /**< ioctl() argument. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2221 |
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
|
2222 |
) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2223 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2224 |
ec_ioctl_voe_t data; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2225 |
ec_slave_config_t *sc; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2226 |
ec_voe_handler_t *voe; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2227 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2228 |
if (unlikely(!priv->requested)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2229 |
return -EPERM; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2230 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2231 |
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
|
2232 |
return -EFAULT; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2233 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2234 |
if (down_interruptible(&master->master_sem)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2235 |
return -EINTR; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2236 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2237 |
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
|
2238 |
up(&master->master_sem); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2239 |
return -ESRCH; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2240 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2241 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2242 |
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
|
2243 |
up(&master->master_sem); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2244 |
return -ESRCH; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2245 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2246 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2247 |
up(&master->master_sem); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2248 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2249 |
if (data.size) { |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2250 |
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
|
2251 |
return -EOVERFLOW; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2252 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2253 |
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
|
2254 |
(void __user *) data.data, data.size)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2255 |
return -EFAULT; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2256 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2257 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2258 |
ecrt_voe_handler_write(voe, data.size); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2259 |
return 0; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2260 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2261 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2262 |
/*****************************************************************************/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2263 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2264 |
/** Executes the VoE state machine. |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2265 |
*/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2266 |
int ec_cdev_ioctl_voe_exec( |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2267 |
ec_master_t *master, /**< EtherCAT master. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2268 |
unsigned long arg, /**< ioctl() argument. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2269 |
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
|
2270 |
) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2271 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2272 |
ec_ioctl_voe_t data; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2273 |
ec_slave_config_t *sc; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2274 |
ec_voe_handler_t *voe; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2275 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2276 |
if (unlikely(!priv->requested)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2277 |
return -EPERM; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2278 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2279 |
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
|
2280 |
return -EFAULT; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2281 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2282 |
if (down_interruptible(&master->master_sem)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2283 |
return -EINTR; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2284 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2285 |
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
|
2286 |
up(&master->master_sem); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2287 |
return -ESRCH; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2288 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2289 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2290 |
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
|
2291 |
up(&master->master_sem); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2292 |
return -ESRCH; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2293 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2294 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2295 |
up(&master->master_sem); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2296 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2297 |
data.state = ecrt_voe_handler_execute(voe); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2298 |
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
|
2299 |
data.size = ecrt_voe_handler_data_size(voe); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2300 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2301 |
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
|
2302 |
return -EFAULT; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2303 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2304 |
return 0; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2305 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2306 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2307 |
/*****************************************************************************/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2308 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2309 |
/** Reads the received VoE data. |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2310 |
*/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2311 |
int ec_cdev_ioctl_voe_data( |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2312 |
ec_master_t *master, /**< EtherCAT master. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2313 |
unsigned long arg, /**< ioctl() argument. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2314 |
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
|
2315 |
) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2316 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2317 |
ec_ioctl_voe_t data; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2318 |
ec_slave_config_t *sc; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2319 |
ec_voe_handler_t *voe; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2320 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2321 |
if (unlikely(!priv->requested)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2322 |
return -EPERM; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2323 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2324 |
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
|
2325 |
return -EFAULT; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2326 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2327 |
if (down_interruptible(&master->master_sem)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2328 |
return -EINTR; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2329 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2330 |
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
|
2331 |
up(&master->master_sem); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2332 |
return -ESRCH; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2333 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2334 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2335 |
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
|
2336 |
up(&master->master_sem); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2337 |
return -ESRCH; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2338 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2339 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2340 |
up(&master->master_sem); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2341 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2342 |
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
|
2343 |
ecrt_voe_handler_data_size(voe))) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2344 |
return -EFAULT; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2345 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2346 |
return 0; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2347 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2348 |
|
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2349 |
/****************************************************************************** |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2350 |
* File operations |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2351 |
*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2352 |
|
1092 | 2353 |
/** Called when the cdev is opened. |
2354 |
*/ |
|
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2355 |
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
|
2356 |
{ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2357 |
ec_cdev_t *cdev = container_of(inode->i_cdev, ec_cdev_t, cdev); |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
2358 |
ec_master_t *master = cdev->master; |
1242
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
2359 |
ec_cdev_priv_t *priv; |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
2360 |
|
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
2361 |
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
|
2362 |
if (!priv) { |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
2363 |
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
|
2364 |
return -ENOMEM; |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
2365 |
} |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
2366 |
|
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
2367 |
priv->cdev = cdev; |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
2368 |
priv->requested = 0; |
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2369 |
priv->process_data = NULL; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2370 |
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
|
2371 |
|
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
2372 |
filp->private_data = priv; |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
2373 |
if (master->debug_level) |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
2374 |
EC_DBG("File opened.\n"); |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2375 |
return 0; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2376 |
} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2377 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2378 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2379 |
|
1092 | 2380 |
/** Called when the cdev is closed. |
2381 |
*/ |
|
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2382 |
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
|
2383 |
{ |
1242
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
2384 |
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
|
2385 |
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
|
2386 |
|
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
2387 |
if (priv->requested) |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
2388 |
ecrt_release_master(master); |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
2389 |
|
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2390 |
if (priv->process_data) |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2391 |
vfree(priv->process_data); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2392 |
|
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
2393 |
if (master->debug_level) |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
2394 |
EC_DBG("File closed.\n"); |
1242
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
2395 |
kfree(priv); |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2396 |
return 0; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2397 |
} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2398 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2399 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2400 |
|
1092 | 2401 |
/** Called when an ioctl() command is issued. |
2402 |
*/ |
|
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
2403 |
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
|
2404 |
{ |
1242
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
2405 |
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
|
2406 |
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
|
2407 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2408 |
if (master->debug_level) |
981
5a2bd04c555c
Output decoded ioctl command number.
Florian Pose <fp@igh-essen.com>
parents:
980
diff
changeset
|
2409 |
EC_DBG("ioctl(filp = %x, cmd = %u (%u), arg = %x)\n", |
5a2bd04c555c
Output decoded ioctl command number.
Florian Pose <fp@igh-essen.com>
parents:
980
diff
changeset
|
2410 |
(u32) filp, (u32) cmd, (u32) _IOC_NR(cmd), (u32) arg); |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
2411 |
|
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2412 |
switch (cmd) { |
957
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
2413 |
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
|
2414 |
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
|
2415 |
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
|
2416 |
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
|
2417 |
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
|
2418 |
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
|
2419 |
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
|
2420 |
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
|
2421 |
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
|
2422 |
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
|
2423 |
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
|
2424 |
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
|
2425 |
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
|
2426 |
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
|
2427 |
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
|
2428 |
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
|
2429 |
case EC_IOCTL_MASTER_DEBUG: |
972 | 2430 |
if (!(filp->f_mode & FMODE_WRITE)) |
2431 |
return -EPERM; |
|
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
2432 |
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
|
2433 |
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
|
2434 |
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
|
2435 |
return -EPERM; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
2436 |
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
|
2437 |
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
|
2438 |
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
|
2439 |
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
|
2440 |
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
|
2441 |
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
|
2442 |
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
|
2443 |
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
|
2444 |
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
|
2445 |
return -EPERM; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
2446 |
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
|
2447 |
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
|
2448 |
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
|
2449 |
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
|
2450 |
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
|
2451 |
return -EPERM; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
2452 |
return ec_cdev_ioctl_slave_sii_write(master, arg); |
1200 | 2453 |
case EC_IOCTL_SLAVE_PHY_READ: |
2454 |
return ec_cdev_ioctl_slave_phy_read(master, arg); |
|
2455 |
case EC_IOCTL_SLAVE_PHY_WRITE: |
|
2456 |
if (!(filp->f_mode & FMODE_WRITE)) |
|
2457 |
return -EPERM; |
|
2458 |
return ec_cdev_ioctl_slave_phy_write(master, arg); |
|
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
2459 |
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
|
2460 |
return ec_cdev_ioctl_config(master, arg); |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
2461 |
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
|
2462 |
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
|
2463 |
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
|
2464 |
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
|
2465 |
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
|
2466 |
return ec_cdev_ioctl_config_sdo(master, arg); |
1242
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
2467 |
case EC_IOCTL_REQUEST: |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
2468 |
if (!(filp->f_mode & FMODE_WRITE)) |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
2469 |
return -EPERM; |
632a6b91f8e4
First version of userspace library with requesting/releasing.
Florian Pose <fp@igh-essen.com>
parents:
1223
diff
changeset
|
2470 |
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
|
2471 |
case EC_IOCTL_CREATE_DOMAIN: |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
2472 |
if (!(filp->f_mode & FMODE_WRITE)) |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
2473 |
return -EPERM; |
0b70040d3daa
No kernel handles in userspace; Domain creation.
Florian Pose <fp@igh-essen.com>
parents:
1242
diff
changeset
|
2474 |
return ec_cdev_ioctl_create_domain(master, arg, priv); |
1246
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
2475 |
case EC_IOCTL_CREATE_SLAVE_CONFIG: |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
2476 |
if (!(filp->f_mode & FMODE_WRITE)) |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
2477 |
return -EPERM; |
4042bda8c980
Creating slave configurations.
Florian Pose <fp@igh-essen.com>
parents:
1244
diff
changeset
|
2478 |
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
|
2479 |
case EC_IOCTL_ACTIVATE: |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
2480 |
if (!(filp->f_mode & FMODE_WRITE)) |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
2481 |
return -EPERM; |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
2482 |
return ec_cdev_ioctl_activate(master, arg, priv); |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
2483 |
case EC_IOCTL_SEND: |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
2484 |
if (!(filp->f_mode & FMODE_WRITE)) |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
2485 |
return -EPERM; |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
2486 |
return ec_cdev_ioctl_send(master, arg, priv); |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
2487 |
case EC_IOCTL_RECEIVE: |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
2488 |
if (!(filp->f_mode & FMODE_WRITE)) |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
2489 |
return -EPERM; |
5f1f1a3e6636
Activate, Send and received; cyclic timer with setitimer().
Florian Pose <fp@igh-essen.com>
parents:
1246
diff
changeset
|
2490 |
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
|
2491 |
case EC_IOCTL_MASTER_STATE: |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2492 |
return ec_cdev_ioctl_master_state(master, arg, priv); |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2493 |
case EC_IOCTL_SC_SYNC: |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2494 |
if (!(filp->f_mode & FMODE_WRITE)) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2495 |
return -EPERM; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2496 |
return ec_cdev_ioctl_sc_sync(master, arg, priv); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2497 |
case EC_IOCTL_SC_ADD_PDO: |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2498 |
if (!(filp->f_mode & FMODE_WRITE)) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2499 |
return -EPERM; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2500 |
return ec_cdev_ioctl_sc_add_pdo(master, arg, priv); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2501 |
case EC_IOCTL_SC_CLEAR_PDOS: |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2502 |
if (!(filp->f_mode & FMODE_WRITE)) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2503 |
return -EPERM; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2504 |
return ec_cdev_ioctl_sc_clear_pdos(master, arg, priv); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2505 |
case EC_IOCTL_SC_ADD_ENTRY: |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2506 |
if (!(filp->f_mode & FMODE_WRITE)) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2507 |
return -EPERM; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2508 |
return ec_cdev_ioctl_sc_add_entry(master, arg, priv); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2509 |
case EC_IOCTL_SC_CLEAR_ENTRIES: |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2510 |
if (!(filp->f_mode & FMODE_WRITE)) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2511 |
return -EPERM; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2512 |
return ec_cdev_ioctl_sc_clear_entries(master, arg, priv); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2513 |
case EC_IOCTL_SC_REG_PDO_ENTRY: |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2514 |
if (!(filp->f_mode & FMODE_WRITE)) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2515 |
return -EPERM; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2516 |
return ec_cdev_ioctl_sc_reg_pdo_entry(master, arg, priv); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2517 |
case EC_IOCTL_SC_SDO: |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2518 |
if (!(filp->f_mode & FMODE_WRITE)) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2519 |
return -EPERM; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
1247
diff
changeset
|
2520 |
return ec_cdev_ioctl_sc_sdo(master, arg, priv); |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2521 |
case EC_IOCTL_SC_VOE: |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2522 |
if (!(filp->f_mode & FMODE_WRITE)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2523 |
return -EPERM; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2524 |
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
|
2525 |
case EC_IOCTL_SC_STATE: |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2526 |
return ec_cdev_ioctl_sc_state(master, arg, priv); |
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2527 |
case EC_IOCTL_DOMAIN_OFFSET: |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2528 |
return ec_cdev_ioctl_domain_offset(master, arg, priv); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2529 |
case EC_IOCTL_DOMAIN_PROCESS: |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2530 |
if (!(filp->f_mode & FMODE_WRITE)) |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2531 |
return -EPERM; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2532 |
return ec_cdev_ioctl_domain_process(master, arg, priv); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2533 |
case EC_IOCTL_DOMAIN_QUEUE: |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2534 |
if (!(filp->f_mode & FMODE_WRITE)) |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2535 |
return -EPERM; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2536 |
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
|
2537 |
case EC_IOCTL_DOMAIN_STATE: |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1258
diff
changeset
|
2538 |
return ec_cdev_ioctl_domain_state(master, arg, priv); |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2539 |
case EC_IOCTL_VOE_SEND_HEADER: |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2540 |
if (!(filp->f_mode & FMODE_WRITE)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2541 |
return -EPERM; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2542 |
return ec_cdev_ioctl_voe_send_header(master, arg, priv); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2543 |
case EC_IOCTL_VOE_REC_HEADER: |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2544 |
return ec_cdev_ioctl_voe_rec_header(master, arg, priv); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2545 |
case EC_IOCTL_VOE_READ: |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2546 |
if (!(filp->f_mode & FMODE_WRITE)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2547 |
return -EPERM; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2548 |
return ec_cdev_ioctl_voe_read(master, arg, priv); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2549 |
case EC_IOCTL_VOE_WRITE: |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2550 |
if (!(filp->f_mode & FMODE_WRITE)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2551 |
return -EPERM; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2552 |
return ec_cdev_ioctl_voe_write(master, arg, priv); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2553 |
case EC_IOCTL_VOE_EXEC: |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2554 |
if (!(filp->f_mode & FMODE_WRITE)) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2555 |
return -EPERM; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2556 |
return ec_cdev_ioctl_voe_exec(master, arg, priv); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2557 |
case EC_IOCTL_VOE_DATA: |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
2558 |
return ec_cdev_ioctl_voe_data(master, arg, priv); |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2559 |
default: |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
2560 |
return -ENOTTY; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
2561 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
2562 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
2563 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
2564 |
/*****************************************************************************/ |
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2565 |
|
1268 | 2566 |
/** Memory-map callback for the EtherCAT character device. |
2567 |
* |
|
2568 |
* The actual mapping will be done in the eccdev_vma_nopage() callback of the |
|
2569 |
* virtual memory area. |
|
2570 |
*/ |
|
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2571 |
int eccdev_mmap( |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2572 |
struct file *filp, |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2573 |
struct vm_area_struct *vma |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2574 |
) |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2575 |
{ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2576 |
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
|
2577 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2578 |
if (priv->cdev->master->debug_level) |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2579 |
EC_DBG("mmap()\n"); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2580 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2581 |
vma->vm_ops = &eccdev_vm_ops; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2582 |
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
|
2583 |
vma->vm_private_data = priv; |
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 |
return 0; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2586 |
} |
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 |
/*****************************************************************************/ |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2589 |
|
1268 | 2590 |
/** Page fault callback for a virtual memory area. |
2591 |
* |
|
2592 |
* Called at the first access on a virtual-memory area retrieved with |
|
2593 |
* ecdev_mmap(). |
|
2594 |
*/ |
|
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2595 |
struct page *eccdev_vma_nopage( |
1268 | 2596 |
struct vm_area_struct *vma, /**< Virtual memory area initialized by |
2597 |
the kernel. */ |
|
2598 |
unsigned long address, /**< Requested virtual address. */ |
|
2599 |
int *type /**< Type output parameter. */ |
|
1258
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2600 |
) |
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 |
unsigned long offset; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2603 |
struct page *page = NOPAGE_SIGBUS; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2604 |
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
|
2605 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2606 |
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
|
2607 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2608 |
if (offset >= priv->process_data_size) |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2609 |
return NOPAGE_SIGBUS; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2610 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2611 |
page = vmalloc_to_page(priv->process_data + offset); |
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 (priv->cdev->master->debug_level) |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2614 |
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
|
2615 |
address, offset, page); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2616 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2617 |
get_page(page); |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2618 |
if (type) |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2619 |
*type = VM_FAULT_MINOR; |
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 |
return page; |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2622 |
} |
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2623 |
|
900f1124e8f8
Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
2624 |
/*****************************************************************************/ |