author | Florian Pose <fp@igh-essen.com> |
Fri, 03 Nov 2006 14:18:05 +0000 | |
changeset 477 | 69d05643041f |
parent 453 | 2ecaa53c6291 |
child 484 | 9fde4a17b820 |
permissions | -rw-r--r-- |
27
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/****************************************************************************** |
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
* $Id$ |
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
* |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
196
diff
changeset
|
5 |
* Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
196
diff
changeset
|
6 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
196
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT Master. |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
196
diff
changeset
|
8 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
196
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
196
diff
changeset
|
10 |
* and/or modify it under the terms of the GNU General Public License |
246
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
201
diff
changeset
|
11 |
* as published by the Free Software Foundation; either version 2 of the |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
201
diff
changeset
|
12 |
* License, or (at your option) any later version. |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
196
diff
changeset
|
13 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
196
diff
changeset
|
14 |
* The IgH EtherCAT Master is distributed in the hope that it will be |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
196
diff
changeset
|
15 |
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
196
diff
changeset
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
196
diff
changeset
|
17 |
* GNU General Public License for more details. |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
196
diff
changeset
|
18 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
196
diff
changeset
|
19 |
* You should have received a copy of the GNU General Public License |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
196
diff
changeset
|
20 |
* along with the IgH EtherCAT Master; if not, write to the Free Software |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
196
diff
changeset
|
21 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
27
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
22 |
* |
246
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
201
diff
changeset
|
23 |
* The right to use EtherCAT Technology is granted and comes free of |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
201
diff
changeset
|
24 |
* charge under condition of compatibility of product made by |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
201
diff
changeset
|
25 |
* Licensee. People intending to distribute/sell products based on the |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
201
diff
changeset
|
26 |
* code, have to sign an agreement to guarantee that products using |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
201
diff
changeset
|
27 |
* software based on IgH EtherCAT master stay compatible with the actual |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
201
diff
changeset
|
28 |
* EtherCAT specification (which are released themselves as an open |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
201
diff
changeset
|
29 |
* standard) as the (only) precondition to have the right to use EtherCAT |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
201
diff
changeset
|
30 |
* Technology, IP and trade marks. |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
201
diff
changeset
|
31 |
* |
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
34
diff
changeset
|
32 |
*****************************************************************************/ |
27
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
34 |
/** |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
35 |
\file |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
36 |
EtherCAT master driver module. |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
37 |
*/ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
38 |
|
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
39 |
/*****************************************************************************/ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
40 |
|
27
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
#include <linux/module.h> |
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
#include <linux/kernel.h> |
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
#include <linux/init.h> |
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
44 |
|
184
2fc86cec12df
Macro for SysFS attribute definition
Florian Pose <fp@igh-essen.com>
parents:
178
diff
changeset
|
45 |
#include "globals.h" |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
46 |
#include "master.h" |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
47 |
#include "device.h" |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
48 |
|
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
49 |
/*****************************************************************************/ |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
50 |
|
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
51 |
int __init ec_init_module(void); |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
52 |
void __exit ec_cleanup_module(void); |
52 | 53 |
|
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
34
diff
changeset
|
54 |
/*****************************************************************************/ |
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
34
diff
changeset
|
55 |
|
286
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
56 |
static int ec_master_count = 1; /**< parameter value, number of masters */ |
321
64e20e6e9d0b
Renamed master parameter ec_eoe_devices to ec_eoeif_count.
Florian Pose <fp@igh-essen.com>
parents:
306
diff
changeset
|
57 |
static int ec_eoeif_count = 0; /**< parameter value, number of EoE interf. */ |
286
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
58 |
static struct list_head ec_masters; /**< list of masters */ |
361
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
356
diff
changeset
|
59 |
static dev_t device_number; |
27
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
60 |
|
444
31223539fc00
Compiler flag -DSVNREV only for module.c to avoid unnecessary recompiling.
Florian Pose <fp@igh-essen.com>
parents:
430
diff
changeset
|
61 |
char *ec_master_version_str = EC_MASTER_VERSION; |
31223539fc00
Compiler flag -DSVNREV only for module.c to avoid unnecessary recompiling.
Florian Pose <fp@igh-essen.com>
parents:
430
diff
changeset
|
62 |
|
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
34
diff
changeset
|
63 |
/*****************************************************************************/ |
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
34
diff
changeset
|
64 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
65 |
/** \cond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
66 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
67 |
module_param(ec_master_count, int, S_IRUGO); |
321
64e20e6e9d0b
Renamed master parameter ec_eoe_devices to ec_eoeif_count.
Florian Pose <fp@igh-essen.com>
parents:
306
diff
changeset
|
68 |
module_param(ec_eoeif_count, int, S_IRUGO); |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
69 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
70 |
MODULE_AUTHOR("Florian Pose <fp@igh-essen.com>"); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
71 |
MODULE_DESCRIPTION("EtherCAT master driver module"); |
27
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
72 |
MODULE_LICENSE("GPL"); |
382
72500991bcc3
Altered master version string.
Florian Pose <fp@igh-essen.com>
parents:
381
diff
changeset
|
73 |
MODULE_VERSION(EC_MASTER_VERSION); |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
74 |
MODULE_PARM_DESC(ec_master_count, "number of EtherCAT masters to initialize"); |
321
64e20e6e9d0b
Renamed master parameter ec_eoe_devices to ec_eoeif_count.
Florian Pose <fp@igh-essen.com>
parents:
306
diff
changeset
|
75 |
MODULE_PARM_DESC(ec_eoeif_count, "number of EoE interfaces per master"); |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
76 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
77 |
/** \endcond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
78 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
79 |
/*****************************************************************************/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
80 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
81 |
/** |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
82 |
Module initialization. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
83 |
Initializes \a ec_master_count masters. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
84 |
\return 0 on success, else < 0 |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
85 |
*/ |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
86 |
|
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
87 |
int __init ec_init_module(void) |
27
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
88 |
{ |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
89 |
unsigned int i; |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
90 |
ec_master_t *master, *next; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
91 |
|
382
72500991bcc3
Altered master version string.
Florian Pose <fp@igh-essen.com>
parents:
381
diff
changeset
|
92 |
EC_INFO("Master driver %s\n", EC_MASTER_VERSION); |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
93 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
94 |
if (ec_master_count < 1) { |
361
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
356
diff
changeset
|
95 |
EC_ERR("Invalid ec_master_count: %i\n", ec_master_count); |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
356
diff
changeset
|
96 |
goto out_return; |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
356
diff
changeset
|
97 |
} |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
356
diff
changeset
|
98 |
|
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
356
diff
changeset
|
99 |
if (alloc_chrdev_region(&device_number, 0, ec_master_count, "EtherCAT")) { |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
356
diff
changeset
|
100 |
EC_ERR("Failed to allocate device number!\n"); |
127
e67c80a76de4
Code aufger?umt und kleines Speicherleck entdeckt.
Florian Pose <fp@igh-essen.com>
parents:
111
diff
changeset
|
101 |
goto out_return; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
102 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
103 |
|
84
b4ae98855cea
printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents:
79
diff
changeset
|
104 |
EC_INFO("Initializing %i EtherCAT master(s)...\n", ec_master_count); |
b4ae98855cea
printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents:
79
diff
changeset
|
105 |
|
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
106 |
INIT_LIST_HEAD(&ec_masters); |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
107 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
108 |
for (i = 0; i < ec_master_count; i++) { |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
109 |
if (!(master = |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
110 |
(ec_master_t *) kmalloc(sizeof(ec_master_t), GFP_KERNEL))) { |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
111 |
EC_ERR("Failed to allocate memory for EtherCAT master %i.\n", i); |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
112 |
goto out_free; |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
113 |
} |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
114 |
|
361
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
356
diff
changeset
|
115 |
if (ec_master_init(master, i, ec_eoeif_count, device_number)) |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
116 |
goto out_free; |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
117 |
|
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
118 |
if (kobject_add(&master->kobj)) { |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
119 |
EC_ERR("Failed to add kobj.\n"); |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
120 |
kobject_put(&master->kobj); // free master |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
121 |
goto out_free; |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
122 |
} |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
123 |
|
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
124 |
list_add_tail(&master->list, &ec_masters); |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
125 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
126 |
|
84
b4ae98855cea
printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents:
79
diff
changeset
|
127 |
EC_INFO("Master driver initialized.\n"); |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
128 |
return 0; |
127
e67c80a76de4
Code aufger?umt und kleines Speicherleck entdeckt.
Florian Pose <fp@igh-essen.com>
parents:
111
diff
changeset
|
129 |
|
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
130 |
out_free: |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
131 |
list_for_each_entry_safe(master, next, &ec_masters, list) { |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
132 |
list_del(&master->list); |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
133 |
kobject_del(&master->kobj); |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
134 |
kobject_put(&master->kobj); |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
135 |
} |
127
e67c80a76de4
Code aufger?umt und kleines Speicherleck entdeckt.
Florian Pose <fp@igh-essen.com>
parents:
111
diff
changeset
|
136 |
out_return: |
e67c80a76de4
Code aufger?umt und kleines Speicherleck entdeckt.
Florian Pose <fp@igh-essen.com>
parents:
111
diff
changeset
|
137 |
return -1; |
27
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
138 |
} |
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
139 |
|
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
34
diff
changeset
|
140 |
/*****************************************************************************/ |
27
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
141 |
|
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
142 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
143 |
Module cleanup. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
144 |
Clears all master instances. |
27
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
145 |
*/ |
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
146 |
|
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
147 |
void __exit ec_cleanup_module(void) |
27
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
148 |
{ |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
149 |
ec_master_t *master, *next; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
150 |
|
84
b4ae98855cea
printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents:
79
diff
changeset
|
151 |
EC_INFO("Cleaning up master driver...\n"); |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
152 |
|
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
153 |
list_for_each_entry_safe(master, next, &ec_masters, list) { |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
154 |
list_del(&master->list); |
448
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
155 |
ec_master_destroy(master); |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
156 |
} |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
157 |
|
361
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
356
diff
changeset
|
158 |
unregister_chrdev_region(device_number, ec_master_count); |
29af81543ce1
Introduced per-master character devices for XML descriptions.
Florian Pose <fp@igh-essen.com>
parents:
356
diff
changeset
|
159 |
|
84
b4ae98855cea
printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents:
79
diff
changeset
|
160 |
EC_INFO("Master driver cleaned up.\n"); |
27
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
161 |
} |
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
162 |
|
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
163 |
/*****************************************************************************/ |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
164 |
|
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
165 |
/** |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
166 |
Gets a handle to a certain master. |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
167 |
\returns pointer to master |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
168 |
*/ |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
169 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
170 |
ec_master_t *ec_find_master(unsigned int master_index /**< master index */) |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
171 |
{ |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
172 |
ec_master_t *master; |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
173 |
|
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
174 |
list_for_each_entry(master, &ec_masters, list) { |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
175 |
if (master->index == master_index) return master; |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
176 |
} |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
177 |
|
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
178 |
EC_ERR("Master %i does not exist!\n", master_index); |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
179 |
return NULL; |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
180 |
} |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
181 |
|
196
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
182 |
/*****************************************************************************/ |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
183 |
|
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
184 |
/** |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
185 |
Outputs frame contents for debugging purposes. |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
186 |
*/ |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
187 |
|
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
188 |
void ec_print_data(const uint8_t *data, /**< pointer to data */ |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
189 |
size_t size /**< number of bytes to output */ |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
190 |
) |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
191 |
{ |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
192 |
unsigned int i; |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
193 |
|
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
194 |
EC_DBG(""); |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
195 |
for (i = 0; i < size; i++) { |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
196 |
printk("%02X ", data[i]); |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
197 |
if ((i + 1) % 16 == 0) { |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
198 |
printk("\n"); |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
199 |
EC_DBG(""); |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
200 |
} |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
201 |
} |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
202 |
printk("\n"); |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
203 |
} |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
204 |
|
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
205 |
/*****************************************************************************/ |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
206 |
|
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
207 |
/** |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
208 |
Outputs frame contents and differences for debugging purposes. |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
209 |
*/ |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
210 |
|
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
211 |
void ec_print_data_diff(const uint8_t *d1, /**< first data */ |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
212 |
const uint8_t *d2, /**< second data */ |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
213 |
size_t size /** number of bytes to output */ |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
214 |
) |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
215 |
{ |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
216 |
unsigned int i; |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
217 |
|
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
218 |
EC_DBG(""); |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
219 |
for (i = 0; i < size; i++) { |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
220 |
if (d1[i] == d2[i]) printk(".. "); |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
221 |
else printk("%02X ", d2[i]); |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
222 |
if ((i + 1) % 16 == 0) { |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
223 |
printk("\n"); |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
224 |
EC_DBG(""); |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
225 |
} |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
226 |
} |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
227 |
printk("\n"); |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
228 |
} |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
229 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
230 |
/*****************************************************************************/ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
231 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
232 |
/** |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
233 |
Prints slave states in clear text. |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
234 |
*/ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
235 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
236 |
size_t ec_state_string(uint8_t states, /**< slave states */ |
403
7bb931deccd9
Added EC_SLAVE_STATE_ACK_ERR to ec_state_string(); added EC_STATE_STRING_SIZE
Florian Pose <fp@igh-essen.com>
parents:
383
diff
changeset
|
237 |
char *buffer /**< target buffer |
7bb931deccd9
Added EC_SLAVE_STATE_ACK_ERR to ec_state_string(); added EC_STATE_STRING_SIZE
Florian Pose <fp@igh-essen.com>
parents:
383
diff
changeset
|
238 |
(min. EC_STATE_STRING_SIZE bytes) */ |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
239 |
) |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
240 |
{ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
241 |
off_t off = 0; |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
242 |
unsigned int first = 1; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
243 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
244 |
if (!states) { |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
245 |
off += sprintf(buffer + off, "(unknown)"); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
246 |
return off; |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
247 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
248 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
249 |
if (states & EC_SLAVE_STATE_INIT) { |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
250 |
off += sprintf(buffer + off, "INIT"); |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
251 |
first = 0; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
252 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
253 |
if (states & EC_SLAVE_STATE_PREOP) { |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
254 |
if (!first) off += sprintf(buffer + off, ", "); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
255 |
off += sprintf(buffer + off, "PREOP"); |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
256 |
first = 0; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
257 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
258 |
if (states & EC_SLAVE_STATE_SAVEOP) { |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
259 |
if (!first) off += sprintf(buffer + off, ", "); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
260 |
off += sprintf(buffer + off, "SAVEOP"); |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
261 |
first = 0; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
262 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
263 |
if (states & EC_SLAVE_STATE_OP) { |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
264 |
if (!first) off += sprintf(buffer + off, ", "); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
265 |
off += sprintf(buffer + off, "OP"); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
266 |
} |
403
7bb931deccd9
Added EC_SLAVE_STATE_ACK_ERR to ec_state_string(); added EC_STATE_STRING_SIZE
Florian Pose <fp@igh-essen.com>
parents:
383
diff
changeset
|
267 |
if (states & EC_SLAVE_STATE_ACK_ERR) { |
453
2ecaa53c6291
Changed output of ec_state_string() for error flag to "+ ERROR".
Florian Pose <fp@igh-essen.com>
parents:
448
diff
changeset
|
268 |
if (!first) off += sprintf(buffer + off, " + "); |
2ecaa53c6291
Changed output of ec_state_string() for error flag to "+ ERROR".
Florian Pose <fp@igh-essen.com>
parents:
448
diff
changeset
|
269 |
off += sprintf(buffer + off, "ERROR"); |
403
7bb931deccd9
Added EC_SLAVE_STATE_ACK_ERR to ec_state_string(); added EC_STATE_STRING_SIZE
Florian Pose <fp@igh-essen.com>
parents:
383
diff
changeset
|
270 |
} |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
271 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
272 |
return off; |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
273 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
274 |
|
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
275 |
/****************************************************************************** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
276 |
* Device interface |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
277 |
*****************************************************************************/ |
33
f4171b8aadf8
Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents:
27
diff
changeset
|
278 |
|
f4171b8aadf8
Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents:
27
diff
changeset
|
279 |
/** |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
280 |
Connects an EtherCAT device to a certain master. |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
281 |
The master will use the device for sending and receiving frames. It is |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
282 |
required that no other instance (for example the kernel IP stack) uses |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
283 |
the device. |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
284 |
\return 0 on success, else < 0 |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
285 |
\ingroup DeviceInterface |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
286 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
287 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
288 |
ec_device_t *ecdev_register(unsigned int master_index, /**< master index */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
289 |
struct net_device *net_dev, /**< net_device of |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
290 |
the device */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
291 |
ec_isr_t isr, /**< interrupt service routine */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
292 |
struct module *module /**< pointer to the module */ |
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
293 |
) |
91
0120d6214948
Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents:
88
diff
changeset
|
294 |
{ |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
295 |
ec_master_t *master; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
296 |
|
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
297 |
if (!(master = ec_find_master(master_index))) return NULL; |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
298 |
|
381
006d3653701d
Fixed race on duplicate device registering or device unregistering while requesting master.
Florian Pose <fp@igh-essen.com>
parents:
378
diff
changeset
|
299 |
if (down_interruptible(&master->device_sem)) { |
006d3653701d
Fixed race on duplicate device registering or device unregistering while requesting master.
Florian Pose <fp@igh-essen.com>
parents:
378
diff
changeset
|
300 |
EC_ERR("Interrupted while waiting for device!\n"); |
006d3653701d
Fixed race on duplicate device registering or device unregistering while requesting master.
Florian Pose <fp@igh-essen.com>
parents:
378
diff
changeset
|
301 |
goto out_return; |
006d3653701d
Fixed race on duplicate device registering or device unregistering while requesting master.
Florian Pose <fp@igh-essen.com>
parents:
378
diff
changeset
|
302 |
} |
006d3653701d
Fixed race on duplicate device registering or device unregistering while requesting master.
Florian Pose <fp@igh-essen.com>
parents:
378
diff
changeset
|
303 |
|
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
91
diff
changeset
|
304 |
if (master->device) { |
84
b4ae98855cea
printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents:
79
diff
changeset
|
305 |
EC_ERR("Master %i already has a device!\n", master_index); |
381
006d3653701d
Fixed race on duplicate device registering or device unregistering while requesting master.
Florian Pose <fp@igh-essen.com>
parents:
378
diff
changeset
|
306 |
goto out_up; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
307 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
308 |
|
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
309 |
if (!(master->device = |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
310 |
(ec_device_t *) kmalloc(sizeof(ec_device_t), GFP_KERNEL))) { |
161
ddb7266d1c56
Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents:
152
diff
changeset
|
311 |
EC_ERR("Failed to allocate device!\n"); |
381
006d3653701d
Fixed race on duplicate device registering or device unregistering while requesting master.
Florian Pose <fp@igh-essen.com>
parents:
378
diff
changeset
|
312 |
goto out_up; |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
91
diff
changeset
|
313 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
91
diff
changeset
|
314 |
|
127
e67c80a76de4
Code aufger?umt und kleines Speicherleck entdeckt.
Florian Pose <fp@igh-essen.com>
parents:
111
diff
changeset
|
315 |
if (ec_device_init(master->device, master, net_dev, isr, module)) { |
191 | 316 |
EC_ERR("Failed to init device!\n"); |
317 |
goto out_free; |
|
127
e67c80a76de4
Code aufger?umt und kleines Speicherleck entdeckt.
Florian Pose <fp@igh-essen.com>
parents:
111
diff
changeset
|
318 |
} |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
91
diff
changeset
|
319 |
|
381
006d3653701d
Fixed race on duplicate device registering or device unregistering while requesting master.
Florian Pose <fp@igh-essen.com>
parents:
378
diff
changeset
|
320 |
up(&master->device_sem); |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
91
diff
changeset
|
321 |
return master->device; |
191 | 322 |
|
323 |
out_free: |
|
324 |
kfree(master->device); |
|
325 |
master->device = NULL; |
|
381
006d3653701d
Fixed race on duplicate device registering or device unregistering while requesting master.
Florian Pose <fp@igh-essen.com>
parents:
378
diff
changeset
|
326 |
out_up: |
006d3653701d
Fixed race on duplicate device registering or device unregistering while requesting master.
Florian Pose <fp@igh-essen.com>
parents:
378
diff
changeset
|
327 |
up(&master->device_sem); |
191 | 328 |
out_return: |
329 |
return NULL; |
|
91
0120d6214948
Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents:
88
diff
changeset
|
330 |
} |
0120d6214948
Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents:
88
diff
changeset
|
331 |
|
0120d6214948
Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents:
88
diff
changeset
|
332 |
/*****************************************************************************/ |
0120d6214948
Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents:
88
diff
changeset
|
333 |
|
0120d6214948
Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents:
88
diff
changeset
|
334 |
/** |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
335 |
Disconnect an EtherCAT device from the master. |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
336 |
The device is disconnected from the master and all device ressources |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
337 |
are freed. |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
338 |
\attention Before calling this function, the ecdev_stop() function has |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
339 |
to be called, to be sure that the master does not use the device any more. |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
340 |
\ingroup DeviceInterface |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
341 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
342 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
343 |
void ecdev_unregister(unsigned int master_index, /**< master index */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
344 |
ec_device_t *device /**< EtherCAT device */ |
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
345 |
) |
55
059a9e712aa7
Mit neuer Schnittstelle wieder lauff?hig.
Florian Pose <fp@igh-essen.com>
parents:
54
diff
changeset
|
346 |
{ |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
347 |
ec_master_t *master; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
348 |
|
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
349 |
if (!(master = ec_find_master(master_index))) return; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
350 |
|
381
006d3653701d
Fixed race on duplicate device registering or device unregistering while requesting master.
Florian Pose <fp@igh-essen.com>
parents:
378
diff
changeset
|
351 |
down(&master->device_sem); |
006d3653701d
Fixed race on duplicate device registering or device unregistering while requesting master.
Florian Pose <fp@igh-essen.com>
parents:
378
diff
changeset
|
352 |
|
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
91
diff
changeset
|
353 |
if (!master->device || master->device != device) { |
381
006d3653701d
Fixed race on duplicate device registering or device unregistering while requesting master.
Florian Pose <fp@igh-essen.com>
parents:
378
diff
changeset
|
354 |
up(&master->device_sem); |
84
b4ae98855cea
printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents:
79
diff
changeset
|
355 |
EC_WARN("Unable to unregister device!\n"); |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
356 |
return; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
357 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
358 |
|
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
91
diff
changeset
|
359 |
ec_device_clear(master->device); |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
91
diff
changeset
|
360 |
kfree(master->device); |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
91
diff
changeset
|
361 |
master->device = NULL; |
381
006d3653701d
Fixed race on duplicate device registering or device unregistering while requesting master.
Florian Pose <fp@igh-essen.com>
parents:
378
diff
changeset
|
362 |
|
006d3653701d
Fixed race on duplicate device registering or device unregistering while requesting master.
Florian Pose <fp@igh-essen.com>
parents:
378
diff
changeset
|
363 |
up(&master->device_sem); |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
364 |
} |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
365 |
|
191 | 366 |
/*****************************************************************************/ |
367 |
||
368 |
/** |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
369 |
Starts the master associated with the device. |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
370 |
This function has to be called by the network device driver to tell the |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
371 |
master that the device is ready to send and receive data. The master |
306
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
372 |
will enter the idle mode then. |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
373 |
\ingroup DeviceInterface |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
374 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
375 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
376 |
int ecdev_start(unsigned int master_index /**< master index */) |
191 | 377 |
{ |
378 |
ec_master_t *master; |
|
379 |
if (!(master = ec_find_master(master_index))) return -1; |
|
380 |
||
381 |
if (ec_device_open(master->device)) { |
|
382 |
EC_ERR("Failed to open device!\n"); |
|
383 |
return -1; |
|
384 |
} |
|
385 |
||
446 | 386 |
ec_master_enter_idle_mode(master); |
387 |
||
191 | 388 |
return 0; |
389 |
} |
|
390 |
||
391 |
/*****************************************************************************/ |
|
392 |
||
393 |
/** |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
394 |
Stops the master associated with the device. |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
395 |
Tells the master to stop using the device for frame IO. Has to be called |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
396 |
before unregistering the device. |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
397 |
\ingroup DeviceInterface |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
398 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
399 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
400 |
void ecdev_stop(unsigned int master_index /**< master index */) |
191 | 401 |
{ |
402 |
ec_master_t *master; |
|
403 |
if (!(master = ec_find_master(master_index))) return; |
|
404 |
||
446 | 405 |
ec_master_leave_idle_mode(master); |
191 | 406 |
|
407 |
if (ec_device_close(master->device)) |
|
408 |
EC_WARN("Failed to close device!\n"); |
|
409 |
} |
|
410 |
||
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
411 |
/****************************************************************************** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
412 |
* Realtime interface |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
413 |
*****************************************************************************/ |
33
f4171b8aadf8
Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents:
27
diff
changeset
|
414 |
|
f4171b8aadf8
Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents:
27
diff
changeset
|
415 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
416 |
Reserves an EtherCAT master for realtime operation. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
417 |
\return pointer to reserved master, or NULL on error |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
418 |
\ingroup RealtimeInterface |
91
0120d6214948
Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents:
88
diff
changeset
|
419 |
*/ |
0120d6214948
Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents:
88
diff
changeset
|
420 |
|
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
421 |
ec_master_t *ecrt_request_master(unsigned int master_index |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
422 |
/**< master index */ |
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
423 |
) |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
424 |
{ |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
425 |
ec_master_t *master; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
426 |
|
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
427 |
EC_INFO("Requesting master %i...\n", master_index); |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
428 |
|
191 | 429 |
if (!(master = ec_find_master(master_index))) goto out_return; |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
430 |
|
378
8fe6cd43787a
Replaced master's reserved flag by atomic_t available.
Florian Pose <fp@igh-essen.com>
parents:
377
diff
changeset
|
431 |
if (!atomic_dec_and_test(&master->available)) { |
8fe6cd43787a
Replaced master's reserved flag by atomic_t available.
Florian Pose <fp@igh-essen.com>
parents:
377
diff
changeset
|
432 |
atomic_inc(&master->available); |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
433 |
EC_ERR("Master %i is already in use!\n", master_index); |
191 | 434 |
goto out_return; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
435 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
436 |
|
381
006d3653701d
Fixed race on duplicate device registering or device unregistering while requesting master.
Florian Pose <fp@igh-essen.com>
parents:
378
diff
changeset
|
437 |
if (down_interruptible(&master->device_sem)) { |
006d3653701d
Fixed race on duplicate device registering or device unregistering while requesting master.
Florian Pose <fp@igh-essen.com>
parents:
378
diff
changeset
|
438 |
EC_ERR("Interrupted while waiting for device!\n"); |
006d3653701d
Fixed race on duplicate device registering or device unregistering while requesting master.
Florian Pose <fp@igh-essen.com>
parents:
378
diff
changeset
|
439 |
goto out_release; |
006d3653701d
Fixed race on duplicate device registering or device unregistering while requesting master.
Florian Pose <fp@igh-essen.com>
parents:
378
diff
changeset
|
440 |
} |
006d3653701d
Fixed race on duplicate device registering or device unregistering while requesting master.
Florian Pose <fp@igh-essen.com>
parents:
378
diff
changeset
|
441 |
|
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
91
diff
changeset
|
442 |
if (!master->device) { |
381
006d3653701d
Fixed race on duplicate device registering or device unregistering while requesting master.
Florian Pose <fp@igh-essen.com>
parents:
378
diff
changeset
|
443 |
up(&master->device_sem); |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
444 |
EC_ERR("Master %i has no assigned device!\n", master_index); |
191 | 445 |
goto out_release; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
446 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
447 |
|
381
006d3653701d
Fixed race on duplicate device registering or device unregistering while requesting master.
Florian Pose <fp@igh-essen.com>
parents:
378
diff
changeset
|
448 |
if (!try_module_get(master->device->module)) { |
006d3653701d
Fixed race on duplicate device registering or device unregistering while requesting master.
Florian Pose <fp@igh-essen.com>
parents:
378
diff
changeset
|
449 |
up(&master->device_sem); |
006d3653701d
Fixed race on duplicate device registering or device unregistering while requesting master.
Florian Pose <fp@igh-essen.com>
parents:
378
diff
changeset
|
450 |
EC_ERR("Device module is unloading!\n"); |
191 | 451 |
goto out_release; |
452 |
} |
|
453 |
||
381
006d3653701d
Fixed race on duplicate device registering or device unregistering while requesting master.
Florian Pose <fp@igh-essen.com>
parents:
378
diff
changeset
|
454 |
up(&master->device_sem); |
006d3653701d
Fixed race on duplicate device registering or device unregistering while requesting master.
Florian Pose <fp@igh-essen.com>
parents:
378
diff
changeset
|
455 |
|
377
ecac8252f114
Changes in ecrt_request_master(); minor output changes.
Florian Pose <fp@igh-essen.com>
parents:
361
diff
changeset
|
456 |
if (!master->device->link_state) { |
ecac8252f114
Changes in ecrt_request_master(); minor output changes.
Florian Pose <fp@igh-essen.com>
parents:
361
diff
changeset
|
457 |
EC_ERR("Link is DOWN.\n"); |
ecac8252f114
Changes in ecrt_request_master(); minor output changes.
Florian Pose <fp@igh-essen.com>
parents:
361
diff
changeset
|
458 |
goto out_module_put; |
ecac8252f114
Changes in ecrt_request_master(); minor output changes.
Florian Pose <fp@igh-essen.com>
parents:
361
diff
changeset
|
459 |
} |
ecac8252f114
Changes in ecrt_request_master(); minor output changes.
Florian Pose <fp@igh-essen.com>
parents:
361
diff
changeset
|
460 |
|
446 | 461 |
if (ec_master_enter_operation_mode(master)) { |
462 |
EC_ERR("Failed to enter OPERATION mode!\n"); |
|
463 |
goto out_module_put; |
|
377
ecac8252f114
Changes in ecrt_request_master(); minor output changes.
Florian Pose <fp@igh-essen.com>
parents:
361
diff
changeset
|
464 |
} |
ecac8252f114
Changes in ecrt_request_master(); minor output changes.
Florian Pose <fp@igh-essen.com>
parents:
361
diff
changeset
|
465 |
|
ecac8252f114
Changes in ecrt_request_master(); minor output changes.
Florian Pose <fp@igh-essen.com>
parents:
361
diff
changeset
|
466 |
EC_INFO("Successfully requested master %i.\n", master_index); |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
467 |
return master; |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
468 |
|
191 | 469 |
out_module_put: |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
91
diff
changeset
|
470 |
module_put(master->device->module); |
191 | 471 |
out_release: |
378
8fe6cd43787a
Replaced master's reserved flag by atomic_t available.
Florian Pose <fp@igh-essen.com>
parents:
377
diff
changeset
|
472 |
atomic_inc(&master->available); |
191 | 473 |
out_return: |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
474 |
return NULL; |
27
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
475 |
} |
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
476 |
|
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
34
diff
changeset
|
477 |
/*****************************************************************************/ |
33
f4171b8aadf8
Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents:
27
diff
changeset
|
478 |
|
f4171b8aadf8
Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents:
27
diff
changeset
|
479 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
480 |
Releases a reserved EtherCAT master. |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
481 |
\ingroup RealtimeInterface |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
482 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
483 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
484 |
void ecrt_release_master(ec_master_t *master /**< EtherCAT master */) |
33
f4171b8aadf8
Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents:
27
diff
changeset
|
485 |
{ |
446 | 486 |
ec_master_leave_operation_mode(master); |
151
1961b674466c
Plugfest: master_open()/close() ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
127
diff
changeset
|
487 |
|
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
91
diff
changeset
|
488 |
module_put(master->device->module); |
378
8fe6cd43787a
Replaced master's reserved flag by atomic_t available.
Florian Pose <fp@igh-essen.com>
parents:
377
diff
changeset
|
489 |
atomic_inc(&master->available); |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
490 |
|
446 | 491 |
EC_INFO("Released master %i.\n", master->index); |
88
98335157e54e
Bessere Ausgaben beim Starten und beenden.
Florian Pose <fp@igh-essen.com>
parents:
85
diff
changeset
|
492 |
return; |
33
f4171b8aadf8
Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents:
27
diff
changeset
|
493 |
} |
f4171b8aadf8
Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents:
27
diff
changeset
|
494 |
|
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
34
diff
changeset
|
495 |
/*****************************************************************************/ |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
496 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
497 |
/** \cond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
498 |
|
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
499 |
module_init(ec_init_module); |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
500 |
module_exit(ec_cleanup_module); |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
501 |
|
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
502 |
EXPORT_SYMBOL(ecdev_register); |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
503 |
EXPORT_SYMBOL(ecdev_unregister); |
191 | 504 |
EXPORT_SYMBOL(ecdev_start); |
505 |
EXPORT_SYMBOL(ecdev_stop); |
|
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
506 |
EXPORT_SYMBOL(ecrt_request_master); |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
507 |
EXPORT_SYMBOL(ecrt_release_master); |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
508 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
509 |
/** \endcond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
510 |
|
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
511 |
/*****************************************************************************/ |