master/globals.h
author Florian Pose <fp@igh-essen.com>
Wed, 17 May 2006 09:22:31 +0000
changeset 241 cd90a22cab28
parent 228 ec516cfa207e
child 246 0bf7c769de06
permissions -rw-r--r--
Minor changes in master.h
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 19
diff changeset
     1
/******************************************************************************
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 19
diff changeset
     3
 *  $Id$
0
05c992bf5847 trunk, tags und branches
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
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 196
diff changeset
    11
 *  as published by the Free Software Foundation; version 2 of the License.
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 196
diff changeset
    12
 *
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 196
diff changeset
    13
 *  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
    14
 *  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
    15
 *  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
    16
 *  GNU General Public License for more details.
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 196
diff changeset
    17
 *
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 196
diff changeset
    18
 *  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
    19
 *  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
    20
 *  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: 196
diff changeset
    21
 *
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 19
diff changeset
    22
 *****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    24
/**
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    25
   \file
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    26
   Global definitions and macros.
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    27
*/
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    28
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    29
/*****************************************************************************/
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    30
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
#ifndef _EC_GLOBALS_
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
#define _EC_GLOBALS_
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
152
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 141
diff changeset
    34
#include <linux/types.h>
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 141
diff changeset
    35
196
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    36
/******************************************************************************
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    37
 *  EtherCAT master
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    38
 *****************************************************************************/
41
42c66194c0c8 Schoenheitskorrekturen.
Florian Pose <fp@igh-essen.com>
parents: 39
diff changeset
    39
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 196
diff changeset
    40
/** master main version */
196
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    41
#define EC_MASTER_VERSION_MAIN  1
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 196
diff changeset
    42
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 196
diff changeset
    43
/** master sub version (after the dot) */
196
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    44
#define EC_MASTER_VERSION_SUB   0
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 196
diff changeset
    45
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 196
diff changeset
    46
/** master extra version (just a string) */
196
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    47
#define EC_MASTER_VERSION_EXTRA "trunk"
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    48
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    49
/** maximum number of FMMUs per slave */
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    50
#define EC_MAX_FMMUS 16
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    51
212
82980deb8b00 moved stats into eoe struct; persistent rx-skb; tx queue.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
    52
/** size of the EoE tx queue */
214
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 212
diff changeset
    53
#define EC_EOE_TX_QUEUE_SIZE 100
212
82980deb8b00 moved stats into eoe struct; persistent rx-skb; tx queue.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
    54
228
ec516cfa207e Added EC_EOE_FREQUENCY
Florian Pose <fp@igh-essen.com>
parents: 214
diff changeset
    55
/** clock frequency for the EoE state machines */
ec516cfa207e Added EC_EOE_FREQUENCY
Florian Pose <fp@igh-essen.com>
parents: 214
diff changeset
    56
#define EC_EOE_FREQUENCY 1000
ec516cfa207e Added EC_EOE_FREQUENCY
Florian Pose <fp@igh-essen.com>
parents: 214
diff changeset
    57
196
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    58
/******************************************************************************
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    59
 *  EtherCAT protocol
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    60
 *****************************************************************************/
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    61
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    62
/** size of an EtherCAT frame header */
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    63
#define EC_FRAME_HEADER_SIZE 2
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    64
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    65
/** size of an EtherCAT command header */
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    66
#define EC_COMMAND_HEADER_SIZE 10
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    67
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    68
/** size of an EtherCAT command footer */
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    69
#define EC_COMMAND_FOOTER_SIZE 2
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    70
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    71
/** size of a sync manager configuration page */
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    72
#define EC_SYNC_SIZE 8
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    73
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    74
/** size of an FMMU configuration page */
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    75
#define EC_FMMU_SIZE 16
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    76
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    77
/** resulting maximum data size of a single command in a frame */
211
c684b6b7adaf Using kernel Ethernet constants.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
    78
#define EC_MAX_DATA_SIZE (ETH_DATA_LEN - EC_FRAME_HEADER_SIZE \
196
f8a1e9f364a3 Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    79
                          - EC_COMMAND_HEADER_SIZE - EC_COMMAND_FOOTER_SIZE)
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
152
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 141
diff changeset
    81
/*****************************************************************************/
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 141
diff changeset
    82
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
    83
#define EC_INFO(fmt, args...) \
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
    84
    printk(KERN_INFO "EtherCAT: " fmt, ##args)
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
    85
#define EC_ERR(fmt, args...) \
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
    86
    printk(KERN_ERR "EtherCAT ERROR: " fmt, ##args)
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
    87
#define EC_WARN(fmt, args...) \
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
    88
    printk(KERN_WARNING "EtherCAT WARNING: " fmt, ##args)
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
    89
#define EC_DBG(fmt, args...) \
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
    90
    printk(KERN_DEBUG "EtherCAT DEBUG: " fmt, ##args)
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
    91
184
2fc86cec12df Macro for SysFS attribute definition
Florian Pose <fp@igh-essen.com>
parents: 164
diff changeset
    92
#define EC_LIT(X) #X
2fc86cec12df Macro for SysFS attribute definition
Florian Pose <fp@igh-essen.com>
parents: 164
diff changeset
    93
#define EC_STR(X) EC_LIT(X)
2fc86cec12df Macro for SysFS attribute definition
Florian Pose <fp@igh-essen.com>
parents: 164
diff changeset
    94
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    95
/**
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    96
   Convenience macro for defining SysFS attributes.
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    97
*/
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    98
184
2fc86cec12df Macro for SysFS attribute definition
Florian Pose <fp@igh-essen.com>
parents: 164
diff changeset
    99
#define EC_SYSFS_READ_ATTR(NAME) \
2fc86cec12df Macro for SysFS attribute definition
Florian Pose <fp@igh-essen.com>
parents: 164
diff changeset
   100
    static struct attribute attr_##NAME = { \
2fc86cec12df Macro for SysFS attribute definition
Florian Pose <fp@igh-essen.com>
parents: 164
diff changeset
   101
        .name = EC_STR(NAME), .owner = THIS_MODULE, .mode = S_IRUGO \
2fc86cec12df Macro for SysFS attribute definition
Florian Pose <fp@igh-essen.com>
parents: 164
diff changeset
   102
    }
2fc86cec12df Macro for SysFS attribute definition
Florian Pose <fp@igh-essen.com>
parents: 164
diff changeset
   103
41
42c66194c0c8 Schoenheitskorrekturen.
Florian Pose <fp@igh-essen.com>
parents: 39
diff changeset
   104
/*****************************************************************************/
42c66194c0c8 Schoenheitskorrekturen.
Florian Pose <fp@igh-essen.com>
parents: 39
diff changeset
   105
152
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 141
diff changeset
   106
extern void ec_print_data(const uint8_t *, size_t);
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 141
diff changeset
   107
extern void ec_print_data_diff(const uint8_t *, const uint8_t *, size_t);
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 141
diff changeset
   108
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 141
diff changeset
   109
/*****************************************************************************/
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 141
diff changeset
   110
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 152
diff changeset
   111
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   112
   Code - Message pair.
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 152
diff changeset
   113
   Some EtherCAT commands support reading a status code to display a certain
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 152
diff changeset
   114
   message. This type allows to map a code to a message string.
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 152
diff changeset
   115
*/
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 152
diff changeset
   116
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 152
diff changeset
   117
typedef struct
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 152
diff changeset
   118
{
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   119
    uint32_t code; /**< code */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   120
    const char *message; /**< message belonging to \a code */
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 152
diff changeset
   121
}
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 152
diff changeset
   122
ec_code_msg_t;
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 152
diff changeset
   123
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 152
diff changeset
   124
/*****************************************************************************/
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 152
diff changeset
   125
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   126
#endif
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 54
diff changeset
   127