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