author | Florian Pose <fp@igh-essen.com> |
Mon, 17 Mar 2008 09:38:48 +0000 | |
changeset 872 | d4e0380d63b3 |
parent 818 | b6c87ae254c9 |
child 885 | eaa10a277d52 |
permissions | -rw-r--r-- |
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/****************************************************************************** |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
* $Id$ |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
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:
195
diff
changeset
|
5 |
* Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
6 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
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:
195
diff
changeset
|
8 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
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:
195
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:
199
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:
199
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:
195
diff
changeset
|
13 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
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:
195
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:
195
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:
195
diff
changeset
|
17 |
* GNU General Public License for more details. |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
18 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
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:
195
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:
195
diff
changeset
|
21 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
22 |
* |
246
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
199
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:
199
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:
199
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:
199
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:
199
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:
199
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:
199
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:
199
diff
changeset
|
30 |
* Technology, IP and trade marks. |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
31 |
* |
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
32 |
*****************************************************************************/ |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
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 domain methods. |
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 |
|
294
feea8d850c65
Applied include patch by M. Schwerin.
Florian Pose <fp@igh-essen.com>
parents:
293
diff
changeset
|
41 |
#include <linux/module.h> |
feea8d850c65
Applied include patch by M. Schwerin.
Florian Pose <fp@igh-essen.com>
parents:
293
diff
changeset
|
42 |
|
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
43 |
#include "globals.h" |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
44 |
#include "master.h" |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
45 |
#include "slave_config.h" |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
46 |
|
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
47 |
#include "domain.h" |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
48 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
49 |
/*****************************************************************************/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
50 |
|
404
7f7f429e13c7
Removed clear functions from headers of kobject-classes.
Florian Pose <fp@igh-essen.com>
parents:
377
diff
changeset
|
51 |
void ec_domain_clear(struct kobject *); |
809 | 52 |
void ec_domain_clear_data(ec_domain_t *); |
179
fb4c9dd11ca0
Sourced SysFS attribute show method prototypes out of headers.
Florian Pose <fp@igh-essen.com>
parents:
178
diff
changeset
|
53 |
ssize_t ec_show_domain_attribute(struct kobject *, struct attribute *, char *); |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
97
diff
changeset
|
54 |
|
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
55 |
/*****************************************************************************/ |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
56 |
|
818
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
57 |
/** Working counter increment values for logical read/write operations. |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
58 |
* |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
59 |
* \attention This is indexed by ec_direction_t. |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
60 |
*/ |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
61 |
static const unsigned int working_counter_increment[] = {2, 1}; |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
62 |
|
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
63 |
/*****************************************************************************/ |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
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 |
|
315 | 67 |
EC_SYSFS_READ_ATTR(image_size); |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
68 |
|
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
69 |
static struct attribute *def_attrs[] = { |
315 | 70 |
&attr_image_size, |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
71 |
NULL, |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
72 |
}; |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
73 |
|
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
74 |
static struct sysfs_ops sysfs_ops = { |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
75 |
.show = &ec_show_domain_attribute, |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
76 |
.store = NULL |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
77 |
}; |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
78 |
|
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
79 |
static struct kobj_type ktype_ec_domain = { |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
80 |
.release = ec_domain_clear, |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
81 |
.sysfs_ops = &sysfs_ops, |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
82 |
.default_attrs = def_attrs |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
83 |
}; |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
84 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
85 |
/** \endcond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
86 |
|
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
87 |
/*****************************************************************************/ |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
88 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
89 |
/** Domain constructor. |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
90 |
* |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
91 |
* \return 0 in case of success, else < 0 |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
92 |
*/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
93 |
int ec_domain_init( |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
94 |
ec_domain_t *domain, /**< EtherCAT domain. */ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
95 |
ec_master_t *master, /**< Parent master. */ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
96 |
unsigned int index /**< Index. */ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
97 |
) |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
98 |
{ |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
99 |
domain->master = master; |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
100 |
domain->index = index; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
101 |
domain->data_size = 0; |
818
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
102 |
domain->expected_working_counter = 0; |
809 | 103 |
domain->data = NULL; |
104 |
domain->data_origin = EC_ORIG_INTERNAL; |
|
105 |
domain->logical_base_address = 0L; |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
106 |
domain->working_counter = 0xFFFFFFFF; |
818
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
107 |
domain->state = 0; |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
108 |
domain->working_counter_changes = 0; |
344
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
343
diff
changeset
|
109 |
domain->notify_jiffies = 0; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
110 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
111 |
INIT_LIST_HEAD(&domain->datagrams); |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
112 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
184
diff
changeset
|
113 |
// init kobject and add it to the hierarchy |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
114 |
memset(&domain->kobj, 0x00, sizeof(struct kobject)); |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
115 |
kobject_init(&domain->kobj); |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
116 |
domain->kobj.ktype = &ktype_ec_domain; |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
117 |
domain->kobj.parent = &master->kobj; |
783
0e16f97cf752
Esthetic surgery for domain.
Florian Pose <fp@igh-essen.com>
parents:
782
diff
changeset
|
118 |
if (kobject_set_name(&domain->kobj, "domain%u", index)) { |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
119 |
EC_ERR("Failed to set kobj name.\n"); |
484
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
448
diff
changeset
|
120 |
kobject_put(&domain->kobj); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
448
diff
changeset
|
121 |
return -1; |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
448
diff
changeset
|
122 |
} |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
448
diff
changeset
|
123 |
if (kobject_add(&domain->kobj)) { |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
448
diff
changeset
|
124 |
EC_ERR("Failed to add domain kobject.\n"); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
448
diff
changeset
|
125 |
kobject_put(&domain->kobj); |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
126 |
return -1; |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
127 |
} |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
128 |
|
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
129 |
return 0; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
130 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
131 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
132 |
/*****************************************************************************/ |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
133 |
|
818
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
134 |
/** Domain destructor. |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
135 |
* |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
136 |
* Clears and frees a domain object. |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
137 |
*/ |
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
|
138 |
void ec_domain_destroy(ec_domain_t *domain /**< EtherCAT domain */) |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
139 |
{ |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
140 |
ec_datagram_t *datagram; |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
141 |
|
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
142 |
// dequeue datagrams |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
143 |
list_for_each_entry(datagram, &domain->datagrams, list) { |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
144 |
if (!list_empty(&datagram->queue)) // datagram queued? |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
145 |
list_del_init(&datagram->queue); |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
146 |
} |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
147 |
|
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
148 |
// destroy self |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
149 |
kobject_del(&domain->kobj); |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
150 |
kobject_put(&domain->kobj); |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
151 |
} |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
152 |
|
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
153 |
/*****************************************************************************/ |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
154 |
|
818
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
155 |
/** Clear and free domain. |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
156 |
* |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
157 |
* This method is called by the kobject, once there are no more references |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
158 |
* to it. |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
159 |
*/ |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
184
diff
changeset
|
160 |
void ec_domain_clear(struct kobject *kobj /**< kobject of the domain */) |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
161 |
{ |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
162 |
ec_domain_t *domain; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
163 |
ec_datagram_t *datagram, *next; |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
164 |
|
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
165 |
domain = container_of(kobj, ec_domain_t, kobj); |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
166 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
167 |
list_for_each_entry_safe(datagram, next, &domain->datagrams, list) { |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
168 |
ec_datagram_clear(datagram); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
169 |
kfree(datagram); |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
138
diff
changeset
|
170 |
} |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
97
diff
changeset
|
171 |
|
809 | 172 |
ec_domain_clear_data(domain); |
173 |
||
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
174 |
kfree(domain); |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
175 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
176 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
177 |
/*****************************************************************************/ |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
178 |
|
809 | 179 |
/** Frees internally allocated memory. |
180 |
*/ |
|
181 |
void ec_domain_clear_data( |
|
182 |
ec_domain_t *domain /**< EtherCAT domain. */ |
|
183 |
) |
|
184 |
{ |
|
185 |
if (domain->data_origin == EC_ORIG_INTERNAL && domain->data) |
|
186 |
kfree(domain->data); |
|
187 |
domain->data = NULL; |
|
188 |
domain->data_origin = EC_ORIG_INTERNAL; |
|
189 |
} |
|
190 |
||
191 |
/*****************************************************************************/ |
|
192 |
||
818
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
193 |
/** Adds an FMMU configuration to the domain. |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
194 |
*/ |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
195 |
void ec_domain_add_fmmu_config( |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
196 |
ec_domain_t *domain, /**< EtherCAT domain. */ |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
197 |
ec_fmmu_config_t *fmmu /**< FMMU configuration. */ |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
198 |
) |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
199 |
{ |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
200 |
fmmu->domain = domain; |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
201 |
|
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
202 |
domain->data_size += fmmu->data_size; |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
203 |
domain->expected_working_counter += working_counter_increment[fmmu->dir]; |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
204 |
} |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
205 |
|
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
206 |
/*****************************************************************************/ |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
207 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
208 |
/** Allocates a domain datagram and appends it to the list. |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
209 |
* |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
210 |
* \return 0 in case of success, else < 0 |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
211 |
*/ |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
212 |
int ec_domain_add_datagram( |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
213 |
ec_domain_t *domain, /**< EtherCAT domain. */ |
809 | 214 |
uint32_t logical_offset, /**< Logical offset. */ |
215 |
size_t data_size, /**< Size of the data. */ |
|
817
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
216 |
uint8_t *data, /**< Process data. */ |
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
217 |
const unsigned int used[] /**< Used by inputs/outputs. */ |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
218 |
) |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
219 |
{ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
220 |
ec_datagram_t *datagram; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
221 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
222 |
if (!(datagram = kmalloc(sizeof(ec_datagram_t), GFP_KERNEL))) { |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
223 |
EC_ERR("Failed to allocate domain datagram!\n"); |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
138
diff
changeset
|
224 |
return -1; |
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
138
diff
changeset
|
225 |
} |
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
138
diff
changeset
|
226 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
227 |
ec_datagram_init(datagram); |
719
03d5b96632fb
Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents:
708
diff
changeset
|
228 |
snprintf(datagram->name, EC_DATAGRAM_NAME_SIZE, |
809 | 229 |
"domain%u-%u", domain->index, logical_offset); |
230 |
||
817
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
231 |
if (used[EC_DIR_OUTPUT] && used[EC_DIR_INPUT]) { // inputs and outputs |
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
232 |
if (ec_datagram_lrw(datagram, logical_offset, data_size, data)) { |
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
233 |
kfree(datagram); |
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
234 |
return -1; |
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
235 |
} |
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
236 |
} else if (used[EC_DIR_OUTPUT]) { // outputs only |
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
237 |
if (ec_datagram_lwr(datagram, logical_offset, data_size, data)) { |
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
238 |
kfree(datagram); |
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
239 |
return -1; |
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
240 |
} |
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
241 |
} else { // inputs only (or nothing) |
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
242 |
if (ec_datagram_lrd(datagram, logical_offset, data_size, data)) { |
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
243 |
kfree(datagram); |
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
244 |
return -1; |
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
245 |
} |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
138
diff
changeset
|
246 |
} |
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
138
diff
changeset
|
247 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
248 |
list_add_tail(&datagram->list, &domain->datagrams); |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
138
diff
changeset
|
249 |
return 0; |
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
138
diff
changeset
|
250 |
} |
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
138
diff
changeset
|
251 |
|
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
138
diff
changeset
|
252 |
/*****************************************************************************/ |
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
138
diff
changeset
|
253 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
254 |
/** Finishes a domain. |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
255 |
* |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
256 |
* This allocates the necessary datagrams and writes the correct logical |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
257 |
* addresses to every configured FMMU. |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
258 |
* |
809 | 259 |
* \todo Check for FMMUs that do not fit into any datagram. |
260 |
* |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
261 |
* \retval 0 in case of success |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
262 |
* \retval <0 on failure. |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
263 |
*/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
264 |
int ec_domain_finish( |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
265 |
ec_domain_t *domain, /**< EtherCAT domain. */ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
266 |
uint32_t base_address /**< Logical base address. */ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
267 |
) |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
268 |
{ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
269 |
uint32_t datagram_offset; |
809 | 270 |
size_t datagram_size; |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
271 |
unsigned int datagram_count, i; |
817
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
272 |
unsigned int datagram_used[2]; |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
273 |
ec_slave_config_t *sc; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
274 |
ec_fmmu_config_t *fmmu; |
817
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
275 |
const ec_datagram_t *datagram; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
276 |
|
809 | 277 |
domain->logical_base_address = base_address; |
278 |
||
279 |
if (domain->data_size && domain->data_origin == EC_ORIG_INTERNAL) { |
|
280 |
if (!(domain->data = |
|
281 |
(uint8_t *) kmalloc(domain->data_size, GFP_KERNEL))) { |
|
282 |
EC_ERR("Failed to allocate %u bytes internal memory for" |
|
283 |
" domain %u!\n", domain->data_size, domain->index); |
|
284 |
return -1; |
|
285 |
} |
|
286 |
} |
|
287 |
||
288 |
// Cycle through all domain FMMUS, correct the logical base addresses and |
|
289 |
// set up the datagrams to carry the process data. |
|
290 |
datagram_offset = 0; |
|
291 |
datagram_size = 0; |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
292 |
datagram_count = 0; |
817
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
293 |
datagram_used[EC_DIR_OUTPUT] = 0; |
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
294 |
datagram_used[EC_DIR_INPUT] = 0; |
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
295 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
296 |
list_for_each_entry(sc, &domain->master->configs, list) { |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
297 |
for (i = 0; i < sc->used_fmmus; i++) { |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
298 |
fmmu = &sc->fmmu_configs[i]; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
299 |
if (fmmu->domain != domain) |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
300 |
continue; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
301 |
|
809 | 302 |
// Correct logical FMMU address |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
303 |
fmmu->logical_start_address += base_address; |
809 | 304 |
|
817
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
305 |
// Increment Input/Output counter |
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
306 |
datagram_used[fmmu->dir]++; |
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
307 |
|
809 | 308 |
// If the current FMMU's data do not fit in the current datagram, |
309 |
// allocate a new one. |
|
310 |
if (datagram_size + fmmu->data_size > EC_MAX_DATA_SIZE) { |
|
311 |
if (ec_domain_add_datagram(domain, |
|
312 |
domain->logical_base_address + datagram_offset, |
|
817
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
313 |
datagram_size, domain->data + datagram_offset, |
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
314 |
datagram_used)) |
809 | 315 |
return -1; |
316 |
datagram_offset += datagram_size; |
|
317 |
datagram_size = 0; |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
318 |
datagram_count++; |
817
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
319 |
datagram_used[EC_DIR_OUTPUT] = 0; |
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
320 |
datagram_used[EC_DIR_INPUT] = 0; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
321 |
} |
809 | 322 |
|
323 |
datagram_size += fmmu->data_size; |
|
324 |
} |
|
325 |
} |
|
326 |
||
327 |
// allocate last datagram, if data are left |
|
328 |
if (datagram_size) { |
|
329 |
if (ec_domain_add_datagram(domain, |
|
330 |
domain->logical_base_address + datagram_offset, |
|
817
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
331 |
datagram_size, domain->data + datagram_offset, |
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
332 |
datagram_used)) |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
138
diff
changeset
|
333 |
return -1; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
334 |
datagram_count++; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
335 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
336 |
|
817
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
337 |
EC_INFO("Domain %u with logical offset %u contains %u bytes.\n", |
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
338 |
domain->index, domain->logical_base_address, domain->data_size); |
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
339 |
list_for_each_entry(datagram, &domain->datagrams, list) { |
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
340 |
EC_INFO(" Datagram %s, logical offset %u, size %u, type %s.\n", |
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
341 |
datagram->name, EC_READ_U32(datagram->address), |
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
342 |
datagram->data_size, ec_datagram_type_string(datagram)); |
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
343 |
} |
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
344 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
345 |
return 0; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
346 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
347 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
348 |
/*****************************************************************************/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
349 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
350 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
184
diff
changeset
|
351 |
Formats attribute data for SysFS reading. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
184
diff
changeset
|
352 |
\return number of bytes to read |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
184
diff
changeset
|
353 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
184
diff
changeset
|
354 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
184
diff
changeset
|
355 |
ssize_t ec_show_domain_attribute(struct kobject *kobj, /**< kobject */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
184
diff
changeset
|
356 |
struct attribute *attr, /**< attribute */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
184
diff
changeset
|
357 |
char *buffer /**< memory to store data in */ |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
358 |
) |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
359 |
{ |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
360 |
ec_domain_t *domain = container_of(kobj, ec_domain_t, kobj); |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
361 |
|
315 | 362 |
if (attr == &attr_image_size) { |
783
0e16f97cf752
Esthetic surgery for domain.
Florian Pose <fp@igh-essen.com>
parents:
782
diff
changeset
|
363 |
return sprintf(buffer, "%u\n", domain->data_size); |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
364 |
} |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
365 |
|
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
366 |
return 0; |
97
e6264685dd7b
Link-Down-Verhalten verbessert.
Florian Pose <fp@igh-essen.com>
parents:
96
diff
changeset
|
367 |
} |
e6264685dd7b
Link-Down-Verhalten verbessert.
Florian Pose <fp@igh-essen.com>
parents:
96
diff
changeset
|
368 |
|
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
369 |
/****************************************************************************** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
184
diff
changeset
|
370 |
* Realtime interface |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
371 |
*****************************************************************************/ |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
372 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
373 |
int ecrt_domain_reg_pdo_entry_list(ec_domain_t *domain, |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
374 |
const ec_pdo_entry_reg_t *regs) |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
375 |
{ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
376 |
const ec_pdo_entry_reg_t *reg; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
377 |
ec_slave_config_t *sc; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
378 |
int ret; |
640
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
635
diff
changeset
|
379 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
380 |
for (reg = regs; reg->index; reg++) { |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
381 |
if (!(sc = ecrt_master_slave_config(domain->master, reg->alias, |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
382 |
reg->position, reg->vendor_id, reg->product_code))) |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
97
diff
changeset
|
383 |
return -1; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
97
diff
changeset
|
384 |
|
807
f8bca95ab75d
Moved ecrt_domain_reg_pdo_entry() to
Florian Pose <fp@igh-essen.com>
parents:
792
diff
changeset
|
385 |
if ((ret = ecrt_slave_config_reg_pdo_entry(sc, reg->index, |
f8bca95ab75d
Moved ecrt_domain_reg_pdo_entry() to
Florian Pose <fp@igh-essen.com>
parents:
792
diff
changeset
|
386 |
reg->subindex, domain)) < 0) |
640
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
635
diff
changeset
|
387 |
return -1; |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
388 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
389 |
*reg->offset = ret; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
390 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
391 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
392 |
return 0; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
393 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
394 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
395 |
/*****************************************************************************/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
396 |
|
809 | 397 |
size_t ecrt_domain_size(ec_domain_t *domain) |
398 |
{ |
|
399 |
return domain->data_size; |
|
400 |
} |
|
401 |
||
402 |
/*****************************************************************************/ |
|
403 |
||
404 |
void ecrt_domain_external_memory(ec_domain_t *domain, uint8_t *mem) |
|
405 |
{ |
|
406 |
ec_domain_clear_data(domain); |
|
407 |
||
408 |
domain->data = mem; |
|
409 |
domain->data_origin = EC_ORIG_EXTERNAL; |
|
410 |
} |
|
411 |
||
412 |
/*****************************************************************************/ |
|
413 |
||
414 |
uint8_t *ecrt_domain_data(ec_domain_t *domain) |
|
415 |
{ |
|
416 |
return domain->data; |
|
417 |
} |
|
418 |
||
419 |
/*****************************************************************************/ |
|
420 |
||
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
421 |
void ecrt_domain_process(ec_domain_t *domain) |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
97
diff
changeset
|
422 |
{ |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
138
diff
changeset
|
423 |
unsigned int working_counter_sum; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
424 |
ec_datagram_t *datagram; |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
97
diff
changeset
|
425 |
|
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
97
diff
changeset
|
426 |
working_counter_sum = 0; |
363
58588a3a1562
Bugfix: ecrt_domain_state() always returned -1.
Florian Pose <fp@igh-essen.com>
parents:
353
diff
changeset
|
427 |
domain->state = 0; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
428 |
list_for_each_entry(datagram, &domain->datagrams, list) { |
719
03d5b96632fb
Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents:
708
diff
changeset
|
429 |
ec_datagram_output_stats(datagram); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
430 |
if (datagram->state == EC_DATAGRAM_RECEIVED) { |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
431 |
working_counter_sum += datagram->working_counter; |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
97
diff
changeset
|
432 |
} |
363
58588a3a1562
Bugfix: ecrt_domain_state() always returned -1.
Florian Pose <fp@igh-essen.com>
parents:
353
diff
changeset
|
433 |
else { |
58588a3a1562
Bugfix: ecrt_domain_state() always returned -1.
Florian Pose <fp@igh-essen.com>
parents:
353
diff
changeset
|
434 |
domain->state = -1; |
58588a3a1562
Bugfix: ecrt_domain_state() always returned -1.
Florian Pose <fp@igh-essen.com>
parents:
353
diff
changeset
|
435 |
} |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
97
diff
changeset
|
436 |
} |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
437 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
438 |
if (working_counter_sum != domain->working_counter) { |
332
e16093374dfd
New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
439 |
domain->working_counter_changes++; |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
440 |
domain->working_counter = working_counter_sum; |
332
e16093374dfd
New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
441 |
} |
e16093374dfd
New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
442 |
|
e16093374dfd
New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
443 |
if (domain->working_counter_changes && |
344
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
343
diff
changeset
|
444 |
jiffies - domain->notify_jiffies > HZ) { |
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
343
diff
changeset
|
445 |
domain->notify_jiffies = jiffies; |
332
e16093374dfd
New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
446 |
if (domain->working_counter_changes == 1) { |
783
0e16f97cf752
Esthetic surgery for domain.
Florian Pose <fp@igh-essen.com>
parents:
782
diff
changeset
|
447 |
EC_INFO("Domain %u working counter change: %u\n", domain->index, |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
448 |
domain->working_counter); |
332
e16093374dfd
New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
449 |
} |
e16093374dfd
New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
450 |
else { |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
451 |
EC_INFO("Domain %u: %u working counter changes. Currently %u\n", |
332
e16093374dfd
New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
452 |
domain->index, domain->working_counter_changes, |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
453 |
domain->working_counter); |
332
e16093374dfd
New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
454 |
} |
e16093374dfd
New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
455 |
domain->working_counter_changes = 0; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
456 |
} |
494
178b1b43a88c
Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents:
484
diff
changeset
|
457 |
} |
178b1b43a88c
Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents:
484
diff
changeset
|
458 |
|
178b1b43a88c
Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents:
484
diff
changeset
|
459 |
/*****************************************************************************/ |
178b1b43a88c
Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents:
484
diff
changeset
|
460 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
461 |
void ecrt_domain_queue(ec_domain_t *domain) |
494
178b1b43a88c
Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents:
484
diff
changeset
|
462 |
{ |
178b1b43a88c
Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents:
484
diff
changeset
|
463 |
ec_datagram_t *datagram; |
178b1b43a88c
Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents:
484
diff
changeset
|
464 |
|
178b1b43a88c
Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents:
484
diff
changeset
|
465 |
list_for_each_entry(datagram, &domain->datagrams, list) { |
178b1b43a88c
Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents:
484
diff
changeset
|
466 |
ec_master_queue_datagram(domain->master, datagram); |
178b1b43a88c
Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents:
484
diff
changeset
|
467 |
} |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
468 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
469 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
470 |
/*****************************************************************************/ |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
471 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
472 |
void ecrt_domain_state(const ec_domain_t *domain, ec_domain_state_t *state) |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
473 |
{ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
474 |
state->working_counter = domain->working_counter; |
818
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
475 |
|
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
476 |
if (domain->working_counter) { |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
477 |
if (domain->working_counter == domain->expected_working_counter) { |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
478 |
state->wc_state = EC_WC_COMPLETE; |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
479 |
} else { |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
480 |
state->wc_state = EC_WC_INCOMPLETE; |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
481 |
} |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
482 |
} else { |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
483 |
state->wc_state = EC_WC_ZERO; |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
484 |
} |
105
fad6709a526f
Dom?nen-Status (ecrt_domain_state) hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
485 |
} |
fad6709a526f
Dom?nen-Status (ecrt_domain_state) hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
486 |
|
fad6709a526f
Dom?nen-Status (ecrt_domain_state) hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
487 |
/*****************************************************************************/ |
fad6709a526f
Dom?nen-Status (ecrt_domain_state) hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
488 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
489 |
/** \cond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
490 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
491 |
EXPORT_SYMBOL(ecrt_domain_reg_pdo_entry_list); |
809 | 492 |
EXPORT_SYMBOL(ecrt_domain_size); |
493 |
EXPORT_SYMBOL(ecrt_domain_external_memory); |
|
494 |
EXPORT_SYMBOL(ecrt_domain_data); |
|
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
495 |
EXPORT_SYMBOL(ecrt_domain_process); |
494
178b1b43a88c
Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents:
484
diff
changeset
|
496 |
EXPORT_SYMBOL(ecrt_domain_queue); |
105
fad6709a526f
Dom?nen-Status (ecrt_domain_state) hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
497 |
EXPORT_SYMBOL(ecrt_domain_state); |
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
498 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
499 |
/** \endcond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
500 |
|
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
501 |
/*****************************************************************************/ |