master/domain.c
author Florian Pose <fp@igh-essen.com>
Fri, 10 Aug 2007 14:28:56 +0000
changeset 698 6693ea7c9047
parent 640 16e9ad7d8e12
child 708 90bdb315f560
permissions -rw-r--r--
removed rc.status dependencies from init script.
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"
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    44
#include "domain.h"
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
    45
#include "master.h"
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
    47
/*****************************************************************************/
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
    48
325
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
   Data registration type.
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
    51
*/
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
    52
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
    53
typedef struct
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
    54
{
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
    55
    struct list_head list; /**< list item */
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
    56
    ec_slave_t *slave; /**< slave */
626
a5e838c30733 Renamed ec_sii_sync_t to ec_sync_t.
Florian Pose <fp@igh-essen.com>
parents: 625
diff changeset
    57
    const ec_sync_t *sync; /**< sync manager */
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
    58
    off_t sync_offset; /**< pdo offset */
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
    59
    void **data_ptr; /**< pointer to process data pointer(s) */
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
    60
}
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
    61
ec_data_reg_t;
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
    62
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
    63
/*****************************************************************************/
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
    64
404
7f7f429e13c7 Removed clear functions from headers of kobject-classes.
Florian Pose <fp@igh-essen.com>
parents: 377
diff changeset
    65
void ec_domain_clear(struct kobject *);
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
    66
void ec_domain_clear_data_regs(ec_domain_t *);
179
fb4c9dd11ca0 Sourced SysFS attribute show method prototypes out of headers.
Florian Pose <fp@igh-essen.com>
parents: 178
diff changeset
    67
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
    68
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
/*****************************************************************************/
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    71
/** \cond */
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    72
315
119f967aead8 Renamed Sysfs attributes.
Florian Pose <fp@igh-essen.com>
parents: 294
diff changeset
    73
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
    74
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
    75
static struct attribute *def_attrs[] = {
315
119f967aead8 Renamed Sysfs attributes.
Florian Pose <fp@igh-essen.com>
parents: 294
diff changeset
    76
    &attr_image_size,
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
    77
    NULL,
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
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
    80
static struct sysfs_ops sysfs_ops = {
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
    81
    .show = &ec_show_domain_attribute,
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
    82
    .store = NULL
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
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
    85
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
    86
    .release = ec_domain_clear,
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
    87
    .sysfs_ops = &sysfs_ops,
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
    88
    .default_attrs = def_attrs
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
    89
};
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
    90
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    91
/** \endcond */
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    92
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
    93
/*****************************************************************************/
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
    94
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
    96
   Domain constructor.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
    97
   \return 0 in case of success, else < 0
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
    98
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
    99
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   100
int ec_domain_init(ec_domain_t *domain, /**< EtherCAT domain */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   101
                   ec_master_t *master, /**< owning master */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   102
                   unsigned int index /**< domain index */
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
   103
                   )
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   104
{
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   105
    domain->master = master;
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
   106
    domain->index = index;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   107
    domain->data_size = 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   108
    domain->base_address = 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   109
    domain->response_count = 0xFFFFFFFF;
344
5d8281f1aa2a Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents: 343
diff changeset
   110
    domain->notify_jiffies = 0;
332
e16093374dfd New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   111
    domain->working_counter_changes = 0;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   112
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   113
    INIT_LIST_HEAD(&domain->data_regs);
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   114
    INIT_LIST_HEAD(&domain->datagrams);
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
   115
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   116
    // 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
   117
    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
   118
    kobject_init(&domain->kobj);
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
   119
    domain->kobj.ktype = &ktype_ec_domain;
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
   120
    domain->kobj.parent = &master->kobj;
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
   121
    if (kobject_set_name(&domain->kobj, "domain%i", index)) {
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
   122
        EC_ERR("Failed to set kobj name.\n");
484
9fde4a17b820 kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents: 448
diff changeset
   123
        kobject_put(&domain->kobj);
9fde4a17b820 kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents: 448
diff changeset
   124
        return -1;
9fde4a17b820 kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents: 448
diff changeset
   125
    }
9fde4a17b820 kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents: 448
diff changeset
   126
    if (kobject_add(&domain->kobj)) {
9fde4a17b820 kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents: 448
diff changeset
   127
        EC_ERR("Failed to add domain kobject.\n");
9fde4a17b820 kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents: 448
diff changeset
   128
        kobject_put(&domain->kobj);
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
   129
        return -1;
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
   130
    }
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
   131
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
   132
    return 0;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   133
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   134
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   135
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   136
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   137
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   138
   Domain destructor.
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
   139
   Clears and frees a domain object.
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
*/
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
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
   143
{
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
    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
   145
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
    // 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
   147
    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
   148
        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
   149
            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
   150
    }
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
    // 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
   153
    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
   154
    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
   155
}
e4b76dc7910c FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents: 446
diff changeset
   156
e4b76dc7910c FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents: 446
diff changeset
   157
/*****************************************************************************/
e4b76dc7910c FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents: 446
diff changeset
   158
e4b76dc7910c FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents: 446
diff changeset
   159
/**
e4b76dc7910c FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents: 446
diff changeset
   160
   Clear and free 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
   161
   This method is called by the kobject,
e4b76dc7910c FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents: 446
diff changeset
   162
   once there are no more references to it.
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   163
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   164
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   165
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
   166
{
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   167
    ec_datagram_t *datagram, *next;
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
   168
    ec_domain_t *domain;
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
   169
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
   170
    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
   171
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   172
    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
   173
        ec_datagram_clear(datagram);
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   174
        kfree(datagram);
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   175
    }
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   176
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   177
    ec_domain_clear_data_regs(domain);
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
   178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
   179
    kfree(domain);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   180
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   181
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   182
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   183
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   184
/**
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   185
 * Registers a PDO entry.
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   186
 * \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
   187
 */
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   188
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   189
int ec_domain_reg_pdo_entry(
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   190
        ec_domain_t *domain, /**< EtherCAT domain */
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   191
        ec_sync_t *sync, /**< sync manager */
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   192
        const ec_pdo_entry_t *entry, /**< PDO entry to register */
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   193
        void **data_ptr /**< pointer to the process data pointer */
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   194
        )
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   195
{
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   196
    ec_data_reg_t *data_reg;
625
ec69acbbd156 Renamed ec_sii_pdo_t and ec_sii_pdo_entry_t to ec_pdo_t and
Florian Pose <fp@igh-essen.com>
parents: 619
diff changeset
   197
    const ec_pdo_t *other_pdo;
ec69acbbd156 Renamed ec_sii_pdo_t and ec_sii_pdo_entry_t to ec_pdo_t and
Florian Pose <fp@igh-essen.com>
parents: 619
diff changeset
   198
    const ec_pdo_entry_t *other_entry;
618
e4b89c862c43 SII sync managers as array instead of list, removed sync manager
Florian Pose <fp@igh-essen.com>
parents: 609
diff changeset
   199
    unsigned int bit_offset, byte_offset;
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   200
416
4f007cd2a79d ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents: 410
diff changeset
   201
    // Calculate offset (in sync manager) for process data pointer
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   202
    bit_offset = 0;
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   203
    byte_offset = 0;
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   204
    list_for_each_entry(other_pdo, &sync->pdos, list) {
353
beb26409ba22 Fixed bug in data pointer calculation.
Florian Pose <fp@igh-essen.com>
parents: 344
diff changeset
   205
        list_for_each_entry(other_entry, &other_pdo->entries, list) {
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   206
            if (other_entry == entry) {
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   207
                byte_offset = bit_offset / 8;
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   208
                break;
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   209
            }
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   210
            bit_offset += other_entry->bit_length;
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   211
        }
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   212
    }
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   213
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   214
    // Allocate memory for data registration object
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   215
    if (!(data_reg =
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   216
          (ec_data_reg_t *) kmalloc(sizeof(ec_data_reg_t), GFP_KERNEL))) {
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   217
        EC_ERR("Failed to allocate data registration.\n");
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   218
        return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   219
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   220
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   221
    if (ec_slave_prepare_fmmu(sync->slave, domain, sync)) {
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 76
diff changeset
   222
        EC_ERR("FMMU configuration failed.\n");
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   223
        kfree(data_reg);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   224
        return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   225
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   226
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   227
    data_reg->slave = sync->slave;
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   228
    data_reg->sync = sync;
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   229
    data_reg->sync_offset = byte_offset;
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   230
    data_reg->data_ptr = data_ptr;
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   231
    list_add_tail(&data_reg->list, &domain->data_regs);
446
8fede404c01f Persistent slave lists.
Florian Pose <fp@igh-essen.com>
parents: 416
diff changeset
   232
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   233
    return 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   234
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   235
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   236
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   237
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   238
/**
339
a3a4ee854bd8 Minor changes.
Florian Pose <fp@igh-essen.com>
parents: 332
diff changeset
   239
   Clears the list of the data registrations.
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   240
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   241
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   242
void ec_domain_clear_data_regs(ec_domain_t *domain /**< EtherCAT domain */)
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   243
{
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   244
    ec_data_reg_t *data_reg, *next;
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   245
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   246
    list_for_each_entry_safe(data_reg, next, &domain->data_regs, list) {
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   247
        list_del(&data_reg->list);
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   248
        kfree(data_reg);
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   249
    }
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   250
}
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   251
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   252
/*****************************************************************************/
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   253
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   254
/**
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   255
   Allocates a process data datagram and appends it to the list.
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   256
   \return 0 in case of success, else < 0
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   257
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   258
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   259
int ec_domain_add_datagram(ec_domain_t *domain, /**< EtherCAT domain */
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   260
                           uint32_t offset, /**< logical offset */
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   261
                           size_t data_size /**< size of the datagram data */
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   262
                           )
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   263
{
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   264
    ec_datagram_t *datagram;
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   265
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   266
    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
   267
        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
   268
        return -1;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   269
    }
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   270
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   271
    ec_datagram_init(datagram);
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   272
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   273
    if (ec_datagram_lrw(datagram, offset, data_size)) {
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   274
        kfree(datagram);
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   275
        return -1;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   276
    }
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   277
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   278
    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
   279
    return 0;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   280
}
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   281
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   282
/*****************************************************************************/
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   283
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   284
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   285
   Creates a domain.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   286
   Reserves domain memory, calculates the logical addresses of the
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   287
   corresponding FMMUs and sets the process data pointer of the registered
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   288
   process data.
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   289
   \return 0 in case of success, else < 0
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   290
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   291
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   292
int ec_domain_alloc(ec_domain_t *domain, /**< EtherCAT domain */
275
ba51285d4ef6 Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   293
                    uint32_t base_address /**< logical base address */
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   294
                    )
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   295
{
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   296
    ec_data_reg_t *data_reg;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   297
    ec_slave_t *slave;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   298
    ec_fmmu_t *fmmu;
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   299
    unsigned int i, j, datagram_count;
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   300
    uint32_t pdo_off, pdo_off_datagram;
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   301
    uint32_t datagram_offset;
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   302
    size_t datagram_data_size, sync_size;
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   303
    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
   304
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   305
    domain->base_address = base_address;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   306
275
ba51285d4ef6 Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   307
    // calculate size of process data and allocate memory
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   308
    domain->data_size = 0;
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   309
    datagram_offset = base_address;
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   310
    datagram_data_size = 0;
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   311
    datagram_count = 0;
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 179
diff changeset
   312
    list_for_each_entry(slave, &domain->master->slaves, list) {
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   313
        for (j = 0; j < slave->fmmu_count; j++) {
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   314
            fmmu = &slave->fmmus[j];
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   315
            if (fmmu->domain == domain) {
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   316
                fmmu->logical_start_address = base_address + domain->data_size;
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   317
                sync_size = ec_sync_size(fmmu->sync);
275
ba51285d4ef6 Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   318
                domain->data_size += sync_size;
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   319
                if (datagram_data_size + sync_size > EC_MAX_DATA_SIZE) {
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   320
                    if (ec_domain_add_datagram(domain, datagram_offset,
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   321
                                               datagram_data_size)) return -1;
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   322
                    datagram_offset += datagram_data_size;
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   323
                    datagram_data_size = 0;
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   324
                    datagram_count++;
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   325
                }
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   326
                datagram_data_size += sync_size;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   327
            }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   328
        }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   329
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   330
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   331
    // allocate last datagram
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   332
    if (datagram_data_size) {
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   333
        if (ec_domain_add_datagram(domain, datagram_offset,
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   334
                                   datagram_data_size))
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   335
            return -1;
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   336
        datagram_count++;
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   337
    }
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   338
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   339
    if (!datagram_count) {
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
   340
        EC_WARN("Domain %i contains no data!\n", domain->index);
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   341
        ec_domain_clear_data_regs(domain);
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   342
        return 0;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   343
    }
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   344
275
ba51285d4ef6 Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   345
    // set all process data pointers
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   346
    list_for_each_entry(data_reg, &domain->data_regs, list) {
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   347
        for (i = 0; i < data_reg->slave->fmmu_count; i++) {
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   348
            fmmu = &data_reg->slave->fmmus[i];
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   349
            if (fmmu->domain == domain && fmmu->sync == data_reg->sync) {
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   350
                pdo_off = fmmu->logical_start_address + data_reg->sync_offset;
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   351
                // search datagram
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   352
                list_for_each_entry(datagram, &domain->datagrams, list) {
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   353
                    pdo_off_datagram = pdo_off - datagram->address.logical;
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   354
                    if (pdo_off >= datagram->address.logical &&
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   355
                        pdo_off_datagram < datagram->mem_size) {
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   356
                        *data_reg->data_ptr = datagram->data +
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   357
                            pdo_off_datagram;
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   358
                    }
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   359
                }
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   360
                if (!data_reg->data_ptr) {
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   361
                    EC_ERR("Failed to assign data pointer!\n");
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   362
                    return -1;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   363
                }
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   364
                break;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   365
            }
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   366
        }
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   367
    }
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   368
377
ecac8252f114 Changes in ecrt_request_master(); minor output changes.
Florian Pose <fp@igh-essen.com>
parents: 363
diff changeset
   369
    EC_INFO("Domain %i - Allocated %i bytes in %i datagram%s.\n",
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   370
            domain->index, domain->data_size, datagram_count,
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   371
            datagram_count == 1 ? "" : "s");
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   372
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   373
    ec_domain_clear_data_regs(domain);
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   374
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   375
    return 0;
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   376
}
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   377
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   378
/*****************************************************************************/
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   379
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   380
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   381
   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
   382
   \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
   383
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   384
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   385
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
   386
                                 struct attribute *attr, /**< attribute */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   387
                                 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
   388
                                 )
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
   389
{
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
   390
    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
   391
315
119f967aead8 Renamed Sysfs attributes.
Florian Pose <fp@igh-essen.com>
parents: 294
diff changeset
   392
    if (attr == &attr_image_size) {
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
   393
        return sprintf(buffer, "%i\n", domain->data_size);
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
   394
    }
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
   395
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
   396
    return 0;
97
e6264685dd7b Link-Down-Verhalten verbessert.
Florian Pose <fp@igh-essen.com>
parents: 96
diff changeset
   397
}
e6264685dd7b Link-Down-Verhalten verbessert.
Florian Pose <fp@igh-essen.com>
parents: 96
diff changeset
   398
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   399
/******************************************************************************
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   400
 *  Realtime interface
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   401
 *****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   402
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   403
/**
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   404
 * Registers a PDO for a domain.
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
   405
 * \return 0 on success, else non-zero
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   406
 * \ingroup RealtimeInterface
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   407
 */
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   408
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
   409
int ecrt_domain_register_pdo(
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   410
        ec_domain_t *domain, /**< EtherCAT domain */
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
   411
        ec_slave_t *slave, /**< EtherCAT slave */
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   412
        uint16_t pdo_entry_index, /**< PDO entry index */
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   413
        uint8_t pdo_entry_subindex, /**< PDO entry subindex */
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   414
        void **data_ptr /**< address of the process data pointer */
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   415
        )
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   416
{
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   417
    ec_sync_t *sync;
625
ec69acbbd156 Renamed ec_sii_pdo_t and ec_sii_pdo_entry_t to ec_pdo_t and
Florian Pose <fp@igh-essen.com>
parents: 619
diff changeset
   418
    const ec_pdo_t *pdo;
ec69acbbd156 Renamed ec_sii_pdo_t and ec_sii_pdo_entry_t to ec_pdo_t and
Florian Pose <fp@igh-essen.com>
parents: 619
diff changeset
   419
    const ec_pdo_entry_t *entry;
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   420
    unsigned int i;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   421
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
   422
    // search for PDO entry
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   423
    for (i = 0; i < slave->sii_sync_count; i++) {
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   424
        sync = &slave->sii_syncs[i];
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   425
        list_for_each_entry(pdo, &sync->pdos, list) {
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   426
            list_for_each_entry(entry, &pdo->entries, list) {
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
   427
                if (entry->index != pdo_entry_index ||
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   428
                        entry->subindex != pdo_entry_subindex) continue;
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   429
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   430
                // PDO entry found
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   431
                if (ec_domain_reg_pdo_entry(domain, sync, entry, data_ptr)) {
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
   432
                    return -1;
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   433
                }
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   434
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
   435
                return 0;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   436
            }
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   437
        }
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   438
    }
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   439
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   440
    EC_ERR("PDO entry 0x%04X:%u is not mapped in slave %u.\n",
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
   441
           pdo_entry_index, pdo_entry_subindex, slave->ring_position);
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   442
    return -1;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   443
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   444
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   445
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   446
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   447
/**
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   448
 * Registers a bunch of data fields.
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   449
 * \attention The list has to be terminated with a NULL structure ({})!
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   450
 * \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
   451
 * \ingroup RealtimeInterface
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   452
 */
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   453
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   454
int ecrt_domain_register_pdo_list(
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   455
        ec_domain_t *domain, /**< EtherCAT domain */
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
   456
        const ec_pdo_reg_t *pdo_regs /**< array of PDO registrations */
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   457
        )
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   458
{
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
   459
    const ec_pdo_reg_t *reg;
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   460
    ec_slave_t *slave;
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   461
    
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   462
    for (reg = pdo_regs; reg->slave_address; reg++) {
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   463
        if (!(slave = ecrt_master_get_slave(domain->master,
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   464
                        reg->slave_address, reg->vendor_id,
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   465
                        reg->product_code)))
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   466
            return -1;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   467
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
   468
        if (ecrt_domain_register_pdo(domain, slave, reg->pdo_entry_index,
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   469
                    reg->pdo_entry_subindex, reg->data_ptr))
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   470
            return -1;
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   471
    }
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   472
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   473
    return 0;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   474
}
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   475
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   476
/*****************************************************************************/
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   477
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   478
/**
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
   479
 * Registers a PDO range in a domain.
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   480
 * \return 0 on success, else non-zero
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   481
 * \ingroup RealtimeInterface
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   482
 */
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   483
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   484
int ecrt_domain_register_pdo_range(
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   485
        ec_domain_t *domain, /**< EtherCAT domain */
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   486
        ec_slave_t *slave, /**< EtherCAT slave */
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   487
        ec_direction_t dir, /**< data direction */
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   488
        uint16_t offset, /**< offset in slave's PDO range */
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   489
        uint16_t length, /**< length of this range */
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   490
        void **data_ptr /**< address of the process data pointer */
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   491
        )
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   492
{
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   493
    ec_data_reg_t *data_reg;
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   494
    ec_sync_t *sync;
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   495
    uint16_t sync_length;
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   496
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   497
    if (!(sync = ec_slave_get_pdo_sync(slave, dir))) {
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   498
        EC_ERR("No sync manager found for PDO range.\n");
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   499
        return -1;
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   500
    }
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   501
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   502
    // Allocate memory for data registration object
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   503
    if (!(data_reg =
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   504
          (ec_data_reg_t *) kmalloc(sizeof(ec_data_reg_t), GFP_KERNEL))) {
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   505
        EC_ERR("Failed to allocate data registration.\n");
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   506
        return -1;
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   507
    }
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   508
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   509
    if (ec_slave_prepare_fmmu(slave, domain, sync)) {
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   510
        EC_ERR("FMMU configuration failed.\n");
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   511
        kfree(data_reg);
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   512
        return -1;
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   513
    }
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   514
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   515
    data_reg->slave = slave;
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   516
    data_reg->sync = sync;
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   517
    data_reg->sync_offset = offset;
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   518
    data_reg->data_ptr = data_ptr;
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   519
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   520
    // estimate sync manager length
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   521
    sync_length = offset + length;
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   522
    if (sync->est_length < sync_length) {
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   523
        sync->est_length = sync_length;
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   524
        if (domain->master->debug_level) {
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   525
            EC_DBG("Estimating length of sync manager %i of slave %i to %i.\n",
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   526
                   sync->index, slave->ring_position, sync_length);
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   527
        }
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   528
    }
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   529
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   530
    list_add_tail(&data_reg->list, &domain->data_regs);
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   531
    return 0;
416
4f007cd2a79d ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents: 410
diff changeset
   532
}
4f007cd2a79d ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents: 410
diff changeset
   533
4f007cd2a79d ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents: 410
diff changeset
   534
/*****************************************************************************/
4f007cd2a79d ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents: 410
diff changeset
   535
4f007cd2a79d ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents: 410
diff changeset
   536
/**
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   537
   Processes received process data and requeues the domain datagram(s).
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   538
   \ingroup RealtimeInterface
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   539
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   540
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   541
void ecrt_domain_process(ec_domain_t *domain /**< EtherCAT domain */)
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   542
{
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   543
    unsigned int working_counter_sum;
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   544
    ec_datagram_t *datagram;
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   545
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   546
    working_counter_sum = 0;
363
58588a3a1562 Bugfix: ecrt_domain_state() always returned -1.
Florian Pose <fp@igh-essen.com>
parents: 353
diff changeset
   547
    domain->state = 0;
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   548
    list_for_each_entry(datagram, &domain->datagrams, list) {
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   549
        if (datagram->state == EC_DATAGRAM_RECEIVED) {
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   550
            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
   551
        }
363
58588a3a1562 Bugfix: ecrt_domain_state() always returned -1.
Florian Pose <fp@igh-essen.com>
parents: 353
diff changeset
   552
        else {
58588a3a1562 Bugfix: ecrt_domain_state() always returned -1.
Florian Pose <fp@igh-essen.com>
parents: 353
diff changeset
   553
            domain->state = -1;
58588a3a1562 Bugfix: ecrt_domain_state() always returned -1.
Florian Pose <fp@igh-essen.com>
parents: 353
diff changeset
   554
        }
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   555
    }
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   556
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   557
    if (working_counter_sum != domain->response_count) {
332
e16093374dfd New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   558
        domain->working_counter_changes++;
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   559
        domain->response_count = working_counter_sum;
332
e16093374dfd New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   560
    }
e16093374dfd New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   561
e16093374dfd New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   562
    if (domain->working_counter_changes &&
344
5d8281f1aa2a Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents: 343
diff changeset
   563
        jiffies - domain->notify_jiffies > HZ) {
5d8281f1aa2a Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents: 343
diff changeset
   564
        domain->notify_jiffies = jiffies;
332
e16093374dfd New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   565
        if (domain->working_counter_changes == 1) {
e16093374dfd New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   566
            EC_INFO("Domain %i working counter change: %i\n", domain->index,
e16093374dfd New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   567
                    domain->response_count);
e16093374dfd New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   568
        }
e16093374dfd New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   569
        else {
e16093374dfd New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   570
            EC_INFO("Domain %i: %u WC changes. Current response count: %i\n",
e16093374dfd New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   571
                    domain->index, domain->working_counter_changes,
e16093374dfd New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   572
                    domain->response_count);
e16093374dfd New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   573
        }
e16093374dfd New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   574
        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
   575
    }
494
178b1b43a88c Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   576
}
178b1b43a88c Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   577
178b1b43a88c Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   578
/*****************************************************************************/
178b1b43a88c Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   579
178b1b43a88c Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   580
/**
178b1b43a88c Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   581
   Places all process data datagrams in the masters datagram queue.
178b1b43a88c Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   582
   \ingroup RealtimeInterface
178b1b43a88c Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   583
*/
178b1b43a88c Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   584
178b1b43a88c Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   585
void ecrt_domain_queue(ec_domain_t *domain /**< EtherCAT domain */)
178b1b43a88c Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   586
{
178b1b43a88c Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   587
    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
   588
178b1b43a88c Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   589
    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
   590
        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
   591
    }
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   592
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   593
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   594
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   595
105
fad6709a526f Dom?nen-Status (ecrt_domain_state) hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   596
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   597
   Returns the state of a domain.
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   598
   \return 0 if all datagrams were received, else -1.
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   599
   \ingroup RealtimeInterface
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   600
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   601
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   602
int ecrt_domain_state(const ec_domain_t *domain /**< EtherCAT domain */)
105
fad6709a526f Dom?nen-Status (ecrt_domain_state) hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   603
{
363
58588a3a1562 Bugfix: ecrt_domain_state() always returned -1.
Florian Pose <fp@igh-essen.com>
parents: 353
diff changeset
   604
    return domain->state;
105
fad6709a526f Dom?nen-Status (ecrt_domain_state) hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   605
}
fad6709a526f Dom?nen-Status (ecrt_domain_state) hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   606
fad6709a526f Dom?nen-Status (ecrt_domain_state) hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   607
/*****************************************************************************/
fad6709a526f Dom?nen-Status (ecrt_domain_state) hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   608
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   609
/** \cond */
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   610
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   611
EXPORT_SYMBOL(ecrt_domain_register_pdo);
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   612
EXPORT_SYMBOL(ecrt_domain_register_pdo_list);
416
4f007cd2a79d ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents: 410
diff changeset
   613
EXPORT_SYMBOL(ecrt_domain_register_pdo_range);
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   614
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
   615
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
   616
EXPORT_SYMBOL(ecrt_domain_state);
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   617
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   618
/** \endcond */
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   619
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   620
/*****************************************************************************/