IgH EtherCAT Master  1.5.2
ioctl.h
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * $Id$
4  *
5  * Copyright (C) 2006-2012 Florian Pose, Ingenieurgemeinschaft IgH
6  *
7  * This file is part of the IgH EtherCAT Master.
8  *
9  * The IgH EtherCAT Master is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License version 2, as
11  * published by the Free Software Foundation.
12  *
13  * The IgH EtherCAT Master is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
16  * Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with the IgH EtherCAT Master; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  * ---
23  *
24  * The license mentioned above concerns the source code only. Using the
25  * EtherCAT technology and brand is only permitted in compliance with the
26  * industrial property and similar rights of Beckhoff Automation GmbH.
27  *
28  *****************************************************************************/
29 
35 /*****************************************************************************/
36 
37 #ifndef __EC_IOCTL_H__
38 #define __EC_IOCTL_H__
39 
40 #include <linux/ioctl.h>
41 
42 #include "globals.h"
43 
44 /*****************************************************************************/
45 
48 #define EC_IOCTL_TYPE 0xa4
49 
50 #define EC_IO(nr) _IO(EC_IOCTL_TYPE, nr)
51 #define EC_IOR(nr, type) _IOR(EC_IOCTL_TYPE, nr, type)
52 #define EC_IOW(nr, type) _IOW(EC_IOCTL_TYPE, nr, type)
53 #define EC_IOWR(nr, type) _IOWR(EC_IOCTL_TYPE, nr, type)
54 
59 #define EC_IOCTL_VERSION_MAGIC 36
60 
61 // Command-line tool
62 #define EC_IOCTL_MODULE EC_IOR(0x00, ec_ioctl_module_t)
63 #define EC_IOCTL_MASTER EC_IOR(0x01, ec_ioctl_master_t)
64 #define EC_IOCTL_SLAVE EC_IOWR(0x02, ec_ioctl_slave_t)
65 #define EC_IOCTL_SLAVE_SYNC EC_IOWR(0x03, ec_ioctl_slave_sync_t)
66 #define EC_IOCTL_SLAVE_SYNC_PDO EC_IOWR(0x04, ec_ioctl_slave_sync_pdo_t)
67 #define EC_IOCTL_SLAVE_SYNC_PDO_ENTRY EC_IOWR(0x05, ec_ioctl_slave_sync_pdo_entry_t)
68 #define EC_IOCTL_DOMAIN EC_IOWR(0x06, ec_ioctl_domain_t)
69 #define EC_IOCTL_DOMAIN_FMMU EC_IOWR(0x07, ec_ioctl_domain_fmmu_t)
70 #define EC_IOCTL_DOMAIN_DATA EC_IOWR(0x08, ec_ioctl_domain_data_t)
71 #define EC_IOCTL_MASTER_DEBUG EC_IO(0x09)
72 #define EC_IOCTL_MASTER_RESCAN EC_IO(0x0a)
73 #define EC_IOCTL_SLAVE_STATE EC_IOW(0x0b, ec_ioctl_slave_state_t)
74 #define EC_IOCTL_SLAVE_SDO EC_IOWR(0x0c, ec_ioctl_slave_sdo_t)
75 #define EC_IOCTL_SLAVE_SDO_ENTRY EC_IOWR(0x0d, ec_ioctl_slave_sdo_entry_t)
76 #define EC_IOCTL_SLAVE_SDO_UPLOAD EC_IOWR(0x0e, ec_ioctl_slave_sdo_upload_t)
77 #define EC_IOCTL_SLAVE_SDO_DOWNLOAD EC_IOWR(0x0f, ec_ioctl_slave_sdo_download_t)
78 #define EC_IOCTL_SLAVE_SII_READ EC_IOWR(0x10, ec_ioctl_slave_sii_t)
79 #define EC_IOCTL_SLAVE_SII_WRITE EC_IOW(0x11, ec_ioctl_slave_sii_t)
80 #define EC_IOCTL_SLAVE_REG_READ EC_IOWR(0x12, ec_ioctl_slave_reg_t)
81 #define EC_IOCTL_SLAVE_REG_WRITE EC_IOW(0x13, ec_ioctl_slave_reg_t)
82 #define EC_IOCTL_SLAVE_FOE_READ EC_IOWR(0x14, ec_ioctl_slave_foe_t)
83 #define EC_IOCTL_SLAVE_FOE_WRITE EC_IOW(0x15, ec_ioctl_slave_foe_t)
84 #define EC_IOCTL_SLAVE_SOE_READ EC_IOWR(0x16, ec_ioctl_slave_soe_read_t)
85 #define EC_IOCTL_SLAVE_SOE_WRITE EC_IOWR(0x17, ec_ioctl_slave_soe_write_t)
86 #ifdef EC_EOE
87 #define EC_IOCTL_SLAVE_EOE_IP_PARAM EC_IOW(0x18, ec_ioctl_slave_eoe_ip_t)
88 #endif
89 #define EC_IOCTL_CONFIG EC_IOWR(0x19, ec_ioctl_config_t)
90 #define EC_IOCTL_CONFIG_PDO EC_IOWR(0x1a, ec_ioctl_config_pdo_t)
91 #define EC_IOCTL_CONFIG_PDO_ENTRY EC_IOWR(0x1b, ec_ioctl_config_pdo_entry_t)
92 #define EC_IOCTL_CONFIG_SDO EC_IOWR(0x1c, ec_ioctl_config_sdo_t)
93 #define EC_IOCTL_CONFIG_IDN EC_IOWR(0x1d, ec_ioctl_config_idn_t)
94 #ifdef EC_EOE
95 #define EC_IOCTL_EOE_HANDLER EC_IOWR(0x1e, ec_ioctl_eoe_handler_t)
96 #endif
97 #define EC_IOCTL_SLAVE_DICT_UPLOAD EC_IOW(0x7f, ec_ioctl_slave_dict_upload_t)
98 
99 // Application interface
100 #define EC_IOCTL_REQUEST EC_IO(0x1f)
101 #define EC_IOCTL_CREATE_DOMAIN EC_IO(0x20)
102 #define EC_IOCTL_CREATE_SLAVE_CONFIG EC_IOWR(0x21, ec_ioctl_config_t)
103 #define EC_IOCTL_SELECT_REF_CLOCK EC_IOW(0x22, uint32_t)
104 #define EC_IOCTL_ACTIVATE EC_IOR(0x23, ec_ioctl_master_activate_t)
105 #define EC_IOCTL_DEACTIVATE EC_IO(0x24)
106 #define EC_IOCTL_SEND EC_IO(0x25)
107 #define EC_IOCTL_RECEIVE EC_IO(0x26)
108 #define EC_IOCTL_MASTER_STATE EC_IOR(0x27, ec_master_state_t)
109 #define EC_IOCTL_MASTER_LINK_STATE EC_IOWR(0x28, ec_ioctl_link_state_t)
110 #define EC_IOCTL_APP_TIME EC_IOW(0x29, uint64_t)
111 #define EC_IOCTL_SYNC_REF EC_IO(0x2a)
112 #define EC_IOCTL_SYNC_REF_TO EC_IOW(0x2b, uint64_t)
113 #define EC_IOCTL_SYNC_SLAVES EC_IO(0x2c)
114 #define EC_IOCTL_REF_CLOCK_TIME EC_IOR(0x2d, uint32_t)
115 #define EC_IOCTL_SYNC_MON_QUEUE EC_IO(0x2e)
116 #define EC_IOCTL_SYNC_MON_PROCESS EC_IOR(0x2f, uint32_t)
117 #define EC_IOCTL_RESET EC_IO(0x30)
118 #define EC_IOCTL_SC_SYNC EC_IOW(0x31, ec_ioctl_config_t)
119 #define EC_IOCTL_SC_WATCHDOG EC_IOW(0x32, ec_ioctl_config_t)
120 #define EC_IOCTL_SC_ADD_PDO EC_IOW(0x33, ec_ioctl_config_pdo_t)
121 #define EC_IOCTL_SC_CLEAR_PDOS EC_IOW(0x34, ec_ioctl_config_pdo_t)
122 #define EC_IOCTL_SC_ADD_ENTRY EC_IOW(0x35, ec_ioctl_add_pdo_entry_t)
123 #define EC_IOCTL_SC_CLEAR_ENTRIES EC_IOW(0x36, ec_ioctl_config_pdo_t)
124 #define EC_IOCTL_SC_REG_PDO_ENTRY EC_IOWR(0x37, ec_ioctl_reg_pdo_entry_t)
125 #define EC_IOCTL_SC_REG_PDO_POS EC_IOWR(0x38, ec_ioctl_reg_pdo_pos_t)
126 #define EC_IOCTL_SC_DC EC_IOW(0x39, ec_ioctl_config_t)
127 #define EC_IOCTL_SC_SDO EC_IOW(0x3a, ec_ioctl_sc_sdo_t)
128 #define EC_IOCTL_SC_EMERG_SIZE EC_IOW(0x3b, ec_ioctl_sc_emerg_t)
129 #define EC_IOCTL_SC_EMERG_POP EC_IOWR(0x3c, ec_ioctl_sc_emerg_t)
130 #define EC_IOCTL_SC_EMERG_CLEAR EC_IOW(0x3d, ec_ioctl_sc_emerg_t)
131 #define EC_IOCTL_SC_EMERG_OVERRUNS EC_IOWR(0x3e, ec_ioctl_sc_emerg_t)
132 #define EC_IOCTL_SC_SDO_REQUEST EC_IOWR(0x3f, ec_ioctl_sdo_request_t)
133 #define EC_IOCTL_SC_REG_REQUEST EC_IOWR(0x40, ec_ioctl_reg_request_t)
134 #define EC_IOCTL_SC_VOE EC_IOWR(0x41, ec_ioctl_voe_t)
135 #define EC_IOCTL_SC_STATE EC_IOWR(0x42, ec_ioctl_sc_state_t)
136 #define EC_IOCTL_SC_IDN EC_IOW(0x43, ec_ioctl_sc_idn_t)
137 #define EC_IOCTL_DOMAIN_SIZE EC_IO(0x44)
138 #define EC_IOCTL_DOMAIN_OFFSET EC_IO(0x45)
139 #define EC_IOCTL_DOMAIN_PROCESS EC_IO(0x46)
140 #define EC_IOCTL_DOMAIN_QUEUE EC_IO(0x47)
141 #define EC_IOCTL_DOMAIN_STATE EC_IOWR(0x48, ec_ioctl_domain_state_t)
142 #define EC_IOCTL_SDO_REQUEST_INDEX EC_IOWR(0x49, ec_ioctl_sdo_request_t)
143 #define EC_IOCTL_SDO_REQUEST_TIMEOUT EC_IOWR(0x4a, ec_ioctl_sdo_request_t)
144 #define EC_IOCTL_SDO_REQUEST_STATE EC_IOWR(0x4b, ec_ioctl_sdo_request_t)
145 #define EC_IOCTL_SDO_REQUEST_READ EC_IOWR(0x4c, ec_ioctl_sdo_request_t)
146 #define EC_IOCTL_SDO_REQUEST_WRITE EC_IOWR(0x4d, ec_ioctl_sdo_request_t)
147 #define EC_IOCTL_SDO_REQUEST_DATA EC_IOWR(0x4e, ec_ioctl_sdo_request_t)
148 #define EC_IOCTL_REG_REQUEST_DATA EC_IOWR(0x4f, ec_ioctl_reg_request_t)
149 #define EC_IOCTL_REG_REQUEST_STATE EC_IOWR(0x50, ec_ioctl_reg_request_t)
150 #define EC_IOCTL_REG_REQUEST_WRITE EC_IOWR(0x51, ec_ioctl_reg_request_t)
151 #define EC_IOCTL_REG_REQUEST_READ EC_IOWR(0x52, ec_ioctl_reg_request_t)
152 #define EC_IOCTL_VOE_SEND_HEADER EC_IOW(0x53, ec_ioctl_voe_t)
153 #define EC_IOCTL_VOE_REC_HEADER EC_IOWR(0x54, ec_ioctl_voe_t)
154 #define EC_IOCTL_VOE_READ EC_IOW(0x55, ec_ioctl_voe_t)
155 #define EC_IOCTL_VOE_READ_NOSYNC EC_IOW(0x56, ec_ioctl_voe_t)
156 #define EC_IOCTL_VOE_WRITE EC_IOWR(0x57, ec_ioctl_voe_t)
157 #define EC_IOCTL_VOE_EXEC EC_IOWR(0x58, ec_ioctl_voe_t)
158 #define EC_IOCTL_VOE_DATA EC_IOWR(0x59, ec_ioctl_voe_t)
159 #define EC_IOCTL_SET_SEND_INTERVAL EC_IOW(0x5a, size_t)
160 #define EC_IOCTL_SC_OVERLAPPING_IO EC_IOW(0x5b, ec_ioctl_config_t)
161 #define EC_IOCTL_SLAVE_REBOOT EC_IOW(0x5c, ec_ioctl_slave_reboot_t)
162 #define EC_IOCTL_SLAVE_REG_READWRITE EC_IOWR(0x5d, ec_ioctl_slave_reg_t)
163 #define EC_IOCTL_REG_REQUEST_READWRITE EC_IOWR(0x5e, ec_ioctl_reg_request_t)
164 #define EC_IOCTL_SETUP_DOMAIN_MEMORY EC_IOR(0x60, ec_ioctl_master_activate_t)
165 #define EC_IOCTL_DEACTIVATE_SLAVES EC_IO(0x61)
166 #define EC_IOCTL_64_REF_CLK_TIME_QUEUE EC_IO(0x62)
167 #define EC_IOCTL_64_REF_CLK_TIME EC_IOR(0x63, uint64_t)
168 #define EC_IOCTL_SC_FOE_REQUEST EC_IOWR(0x64, ec_ioctl_foe_request_t)
169 #define EC_IOCTL_FOE_REQUEST_FILE EC_IOWR(0x65, ec_ioctl_foe_request_t)
170 #define EC_IOCTL_FOE_REQUEST_TIMEOUT EC_IOWR(0x66, ec_ioctl_foe_request_t)
171 #define EC_IOCTL_FOE_REQUEST_STATE EC_IOWR(0x67, ec_ioctl_foe_request_t)
172 #define EC_IOCTL_FOE_REQUEST_READ EC_IOWR(0x68, ec_ioctl_foe_request_t)
173 #define EC_IOCTL_FOE_REQUEST_WRITE EC_IOWR(0x69, ec_ioctl_foe_request_t)
174 #define EC_IOCTL_FOE_REQUEST_DATA EC_IOWR(0x6a, ec_ioctl_foe_request_t)
175 #define EC_IOCTL_RT_SLAVE_REQUESTS EC_IOW(0x6b, uint32_t)
176 #define EC_IOCTL_EXEC_SLAVE_REQUESTS EC_IO(0x6c)
177 
178 #if defined(EC_RTDM) && (EC_EOE)
179 #define EC_IOCTL_EOE_IS_OPEN EC_IO(0x6d)
180 #define EC_IOCTL_EOE_PROCESS EC_IO(0x6e)
181 #define EC_IOCTL_SEND_EXT EC_IO(0x6f)
182 #endif
183 
184 #ifdef EC_EOE
185 #define EC_IOCTL_EOE_ADDIF EC_IOWR(0x70, ec_ioctl_eoe_if_t)
186 #define EC_IOCTL_EOE_DELIF EC_IOWR(0x71, ec_ioctl_eoe_if_t)
187 #endif
188 
189 #define EC_IOCTL_PCAP_DATA EC_IOWR(0x72, ec_ioctl_pcap_data_t)
190 
191 // Mailbox Gateway
192 #define EC_IOCTL_MBOX_GATEWAY EC_IOWR(0x73, ec_ioctl_mbox_gateway_t)
193 
194 /*****************************************************************************/
195 
196 #define EC_IOCTL_STRING_SIZE 64
197 
198 /*****************************************************************************/
199 
200 typedef struct {
201  uint32_t ioctl_version_magic;
202  uint32_t master_count;
203 } ec_ioctl_module_t;
204 
205 /*****************************************************************************/
206 
207 typedef struct {
208  uint32_t slave_count;
209  uint32_t config_count;
210  uint32_t domain_count;
211 #ifdef EC_EOE
212  uint32_t eoe_handler_count;
213 #endif
214  uint8_t phase;
215  uint8_t active;
216  uint8_t scan_busy;
217  struct ec_ioctl_device {
218  uint8_t address[6];
219  uint8_t attached;
220  uint8_t link_state;
221  uint64_t tx_count;
222  uint64_t rx_count;
223  uint64_t tx_bytes;
224  uint64_t rx_bytes;
225  uint64_t tx_errors;
226  int32_t tx_frame_rates[EC_RATE_COUNT];
227  int32_t rx_frame_rates[EC_RATE_COUNT];
228  int32_t tx_byte_rates[EC_RATE_COUNT];
229  int32_t rx_byte_rates[EC_RATE_COUNT];
230  } devices[EC_MAX_NUM_DEVICES];
231  uint32_t num_devices;
232  uint64_t tx_count;
233  uint64_t rx_count;
234  uint64_t tx_bytes;
235  uint64_t rx_bytes;
236  int32_t tx_frame_rates[EC_RATE_COUNT];
237  int32_t rx_frame_rates[EC_RATE_COUNT];
238  int32_t tx_byte_rates[EC_RATE_COUNT];
239  int32_t rx_byte_rates[EC_RATE_COUNT];
240  int32_t loss_rates[EC_RATE_COUNT];
241  uint64_t app_time;
242  uint64_t dc_ref_time;
243  uint16_t ref_clock;
244  uint32_t pcap_size;
245 } ec_ioctl_master_t;
246 
247 /*****************************************************************************/
248 
249 typedef struct {
250  // input
251  uint16_t position;
252 
253  // outputs
254  unsigned int device_index;
255  uint32_t vendor_id;
256  uint32_t product_code;
257  uint32_t revision_number;
258  uint32_t serial_number;
259  uint16_t alias;
260  uint16_t boot_rx_mailbox_offset;
261  uint16_t boot_rx_mailbox_size;
262  uint16_t boot_tx_mailbox_offset;
263  uint16_t boot_tx_mailbox_size;
264  uint16_t std_rx_mailbox_offset;
265  uint16_t std_rx_mailbox_size;
266  uint16_t std_tx_mailbox_offset;
267  uint16_t std_tx_mailbox_size;
268  uint16_t mailbox_protocols;
269  uint8_t has_general_category;
270  ec_sii_coe_details_t coe_details;
271  ec_sii_general_flags_t general_flags;
272  int16_t current_on_ebus;
273  struct {
276  uint32_t receive_time;
277  uint16_t next_slave;
278  uint32_t delay_to_next_dc;
279  } ports[EC_MAX_PORTS];
280  uint8_t upstream_port;
281  uint8_t fmmu_bit;
282  uint8_t dc_supported;
283  ec_slave_dc_range_t dc_range;
284  uint8_t has_dc_system_time;
285  uint32_t transmission_delay;
286  uint8_t al_state;
287  uint8_t error_flag;
288  uint8_t scan_required;
289  uint8_t ready;
290  uint8_t sync_count;
291  uint16_t sdo_count;
292  uint32_t sii_nwords;
293  char group[EC_IOCTL_STRING_SIZE];
294  char image[EC_IOCTL_STRING_SIZE];
295  char order[EC_IOCTL_STRING_SIZE];
296  char name[EC_IOCTL_STRING_SIZE];
297 } ec_ioctl_slave_t;
298 
299 /*****************************************************************************/
300 
301 typedef struct {
302  // inputs
303  uint16_t slave_position;
304  uint32_t sync_index;
305 
306  // outputs
307  uint16_t physical_start_address;
308  uint16_t default_size;
309  uint8_t control_register;
310  uint8_t enable;
311  uint8_t pdo_count;
312 } ec_ioctl_slave_sync_t;
313 
314 /*****************************************************************************/
315 
316 typedef struct {
317  // inputs
318  uint16_t slave_position;
319  uint32_t sync_index;
320  uint32_t pdo_pos;
321 
322  // outputs
323  uint16_t index;
324  uint8_t entry_count;
325  int8_t name[EC_IOCTL_STRING_SIZE];
326 } ec_ioctl_slave_sync_pdo_t;
327 
328 /*****************************************************************************/
329 
330 typedef struct {
331  // inputs
332  uint16_t slave_position;
333  uint32_t sync_index;
334  uint32_t pdo_pos;
335  uint32_t entry_pos;
336 
337  // outputs
338  uint16_t index;
339  uint8_t subindex;
340  uint8_t bit_length;
341  int8_t name[EC_IOCTL_STRING_SIZE];
342 } ec_ioctl_slave_sync_pdo_entry_t;
343 
344 /*****************************************************************************/
345 
346 typedef struct {
347  // inputs
348  uint32_t index;
349 
350  // outputs
351  uint32_t data_size;
352  uint32_t logical_base_address;
353  uint16_t working_counter[EC_MAX_NUM_DEVICES];
354  uint16_t expected_working_counter;
355  uint32_t fmmu_count;
356 } ec_ioctl_domain_t;
357 
358 /*****************************************************************************/
359 
360 typedef struct {
361  // inputs
362  uint32_t domain_index;
363  uint32_t fmmu_index;
364 
365  // outputs
366  uint16_t slave_config_alias;
367  uint16_t slave_config_position;
368  uint8_t sync_index;
369  ec_direction_t dir;
370  uint32_t logical_address;
371  uint32_t data_size;
372 } ec_ioctl_domain_fmmu_t;
373 
374 /*****************************************************************************/
375 
376 typedef struct {
377  // inputs
378  uint32_t domain_index;
379  uint32_t data_size;
380  uint8_t *target;
381 } ec_ioctl_domain_data_t;
382 
383 /*****************************************************************************/
384 
385 typedef struct {
386  // inputs
387  uint32_t data_size;
388  uint8_t reset_data;
389  uint8_t *target;
390 } ec_ioctl_pcap_data_t;
391 
392 /*****************************************************************************/
393 
394 typedef struct {
395  // inputs
396  uint16_t slave_position;
397  uint8_t al_state;
398 } ec_ioctl_slave_state_t;
399 
400 /*****************************************************************************/
401 
402 typedef struct {
403  // inputs
404  uint16_t slave_position;
405  uint16_t sdo_position;
406 
407  // outputs
408  uint16_t sdo_index;
409  uint8_t max_subindex;
410  int8_t name[EC_IOCTL_STRING_SIZE];
411 } ec_ioctl_slave_sdo_t;
412 
413 /*****************************************************************************/
414 
415 typedef struct {
416  // inputs
417  uint16_t slave_position;
418  int sdo_spec; // positive: index, negative: list position
419  uint8_t sdo_entry_subindex;
420 
421  // outputs
422  uint16_t data_type;
423  uint16_t bit_length;
424  uint8_t read_access[EC_SDO_ENTRY_ACCESS_COUNT];
425  uint8_t write_access[EC_SDO_ENTRY_ACCESS_COUNT];
426  int8_t description[EC_IOCTL_STRING_SIZE];
427 } ec_ioctl_slave_sdo_entry_t;
428 
429 /*****************************************************************************/
430 
431 typedef struct {
432  // inputs
433  uint16_t slave_position;
434  uint16_t sdo_index;
435  uint8_t sdo_entry_subindex;
436  uint8_t complete_access;
437  size_t target_size;
438  uint8_t *target;
439 
440  // outputs
441  size_t data_size;
442  uint32_t abort_code;
443 } ec_ioctl_slave_sdo_upload_t;
444 
445 /*****************************************************************************/
446 
447 typedef struct {
448  // inputs
449  uint16_t slave_position;
450  uint16_t sdo_index;
451  uint8_t sdo_entry_subindex;
452  uint8_t complete_access;
453  size_t data_size;
454  const uint8_t *data;
455 
456  // outputs
457  uint32_t abort_code;
458 } ec_ioctl_slave_sdo_download_t;
459 
460 /*****************************************************************************/
461 
462 typedef struct {
463  // inputs
464  uint16_t slave_position;
465  uint16_t offset;
466  uint32_t nwords;
467  uint16_t *words;
468 } ec_ioctl_slave_sii_t;
469 
470 /*****************************************************************************/
471 
472 typedef struct {
473  // inputs
474  uint16_t slave_position;
475  uint8_t emergency;
476  uint16_t address;
477  size_t size;
478  uint8_t *data;
479 } ec_ioctl_slave_reg_t;
480 
481 /*****************************************************************************/
482 
483 typedef struct {
484  // inputs
485  uint16_t slave_position;
486  uint8_t broadcast;
487 } ec_ioctl_slave_reboot_t;
488 
489 /*****************************************************************************/
490 
491 typedef struct {
492  // inputs
493  uint32_t password;
494  uint16_t slave_position;
495  uint16_t offset;
496  size_t buffer_size;
497  uint8_t *buffer;
498 
499  // outputs
500  size_t data_size;
501  uint32_t result;
502  uint32_t error_code;
503 
504  char file_name[255];
505 } ec_ioctl_slave_foe_t;
506 
507 /*****************************************************************************/
508 
509 typedef struct {
510  // inputs
511  uint16_t slave_position;
512  uint8_t drive_no;
513  uint16_t idn;
514  size_t mem_size;
515  uint8_t *data;
516 
517  // outputs
518  size_t data_size;
519  uint16_t error_code;
520 } ec_ioctl_slave_soe_read_t;
521 
522 /*****************************************************************************/
523 
524 typedef struct {
525  // inputs
526  uint16_t slave_position;
527  uint8_t drive_no;
528  uint16_t idn;
529  size_t data_size;
530  uint8_t *data;
531 
532  // outputs
533  uint16_t error_code;
534 } ec_ioctl_slave_soe_write_t;
535 
536 /*****************************************************************************/
537 
538 typedef struct {
539  // inputs
540  uint32_t config_index;
541 
542  // outputs
543  uint16_t alias;
544  uint16_t position;
545  uint32_t vendor_id;
546  uint32_t product_code;
547  struct {
548  ec_direction_t dir;
549  ec_watchdog_mode_t watchdog_mode;
550  uint32_t pdo_count;
551  uint8_t config_this;
552  } syncs[EC_MAX_SYNC_MANAGERS];
553  uint16_t watchdog_divider;
554  uint16_t watchdog_intervals;
555  uint32_t sdo_count;
556  uint32_t idn_count;
557  int32_t slave_position;
558  uint16_t dc_assign_activate;
560  uint8_t allow_overlapping_pdos;
561 } ec_ioctl_config_t;
562 
563 /*****************************************************************************/
564 
565 typedef struct {
566  // inputs
567  uint32_t config_index;
568  uint8_t sync_index;
569  uint16_t pdo_pos;
570 
571  // outputs
572  uint16_t index;
573  uint8_t entry_count;
574  int8_t name[EC_IOCTL_STRING_SIZE];
575 } ec_ioctl_config_pdo_t;
576 
577 /*****************************************************************************/
578 
579 typedef struct {
580  // inputs
581  uint32_t config_index;
582  uint8_t sync_index;
583  uint16_t pdo_pos;
584  uint8_t entry_pos;
585 
586  // outputs
587  uint16_t index;
588  uint8_t subindex;
589  uint8_t bit_length;
590  int8_t name[EC_IOCTL_STRING_SIZE];
591 } ec_ioctl_config_pdo_entry_t;
592 
593 /*****************************************************************************/
594 
598 #define EC_MAX_SDO_DATA_SIZE 1024
599 
600 typedef struct {
601  // inputs
602  uint32_t config_index;
603  uint32_t sdo_pos;
604 
605  // outputs
606  uint16_t index;
607  uint8_t subindex;
608  size_t size;
609  uint8_t data[EC_MAX_SDO_DATA_SIZE];
610  uint8_t complete_access;
611 } ec_ioctl_config_sdo_t;
612 
613 /*****************************************************************************/
614 
618 #define EC_MAX_IDN_DATA_SIZE 1024
619 
620 typedef struct {
621  // inputs
622  uint32_t config_index;
623  uint32_t idn_pos;
624 
625  // outputs
626  uint8_t drive_no;
627  uint16_t idn;
628  ec_al_state_t state;
629  size_t size;
630  uint8_t data[EC_MAX_IDN_DATA_SIZE];
631 } ec_ioctl_config_idn_t;
632 
633 /*****************************************************************************/
634 
635 #ifdef EC_EOE
636 
637 typedef struct {
638  // input
639  uint16_t eoe_index;
640 
641  // outputs
642  char name[EC_DATAGRAM_NAME_SIZE];
643  uint16_t slave_position;
644  uint8_t open;
645  uint32_t rx_bytes;
646  uint32_t rx_rate;
647  uint32_t tx_bytes;
648  uint32_t tx_rate;
649  uint32_t tx_queued_frames;
650  uint32_t tx_queue_size;
651 } ec_ioctl_eoe_handler_t;
652 
653 /*****************************************************************************/
654 
655 typedef struct {
656  // input
657  uint16_t alias;
658  uint16_t position;
659 } ec_ioctl_eoe_if_t;
660 
661 #endif
662 
663 /*****************************************************************************/
664 
665 #define EC_ETH_ALEN 6
666 #ifdef ETH_ALEN
667 #if ETH_ALEN != EC_ETH_ALEN
668 #error Ethernet address length mismatch
669 #endif
670 #endif
671 
672 #ifdef EC_EOE
673 typedef struct {
674  // input
675  uint16_t slave_position;
676 
677  uint8_t mac_address_included;
678  uint8_t ip_address_included;
679  uint8_t subnet_mask_included;
680  uint8_t gateway_included;
681  uint8_t dns_included;
682  uint8_t name_included;
683 
684  unsigned char mac_address[EC_ETH_ALEN];
685  uint32_t ip_address;
686  uint32_t subnet_mask;
687  uint32_t gateway;
688  uint32_t dns;
689  char name[EC_MAX_HOSTNAME_SIZE];
690 
691  // output
692  uint16_t result;
693 } ec_ioctl_slave_eoe_ip_t;
694 
695 #endif
696 /*****************************************************************************/
697 
698 typedef struct {
699  // outputs
700  void *process_data;
701  size_t process_data_size;
702 } ec_ioctl_master_activate_t;
703 
704 /*****************************************************************************/
705 
706 typedef struct {
707  // inputs
708  uint32_t config_index;
709  uint16_t pdo_index;
710  uint16_t entry_index;
711  uint8_t entry_subindex;
712  uint8_t entry_bit_length;
713 } ec_ioctl_add_pdo_entry_t;
714 
715 /*****************************************************************************/
716 
717 typedef struct {
718  // inputs
719  uint32_t config_index;
720  uint16_t entry_index;
721  uint8_t entry_subindex;
722  uint32_t domain_index;
723 
724  // outputs
725  unsigned int bit_position;
726 } ec_ioctl_reg_pdo_entry_t;
727 
728 /*****************************************************************************/
729 
730 typedef struct {
731  // inputs
732  uint32_t config_index;
733  uint32_t sync_index;
734  uint32_t pdo_pos;
735  uint32_t entry_pos;
736  uint32_t domain_index;
737 
738  // outputs
739  unsigned int bit_position;
740 } ec_ioctl_reg_pdo_pos_t;
741 
742 /*****************************************************************************/
743 
744 typedef struct {
745  // inputs
746  uint32_t config_index;
747  uint16_t index;
748  uint8_t subindex;
749  const uint8_t *data;
750  size_t size;
751  uint8_t complete_access;
752 } ec_ioctl_sc_sdo_t;
753 
754 /*****************************************************************************/
755 
756 typedef struct {
757  // inputs
758  uint32_t config_index;
759  size_t size;
760  uint8_t *target;
761 
762  // outputs
763  int32_t overruns;
764 } ec_ioctl_sc_emerg_t;
765 
766 /*****************************************************************************/
767 
768 typedef struct {
769  // inputs
770  uint32_t config_index;
771 
772  // outputs
774 } ec_ioctl_sc_state_t;
775 
776 /*****************************************************************************/
777 
778 typedef struct {
779  // inputs
780  uint32_t config_index;
781  uint8_t drive_no;
782  uint16_t idn;
783  ec_al_state_t al_state;
784  const uint8_t *data;
785  size_t size;
786 } ec_ioctl_sc_idn_t;
787 
788 /*****************************************************************************/
789 
790 typedef struct {
791  // inputs
792  uint32_t domain_index;
793 
794  // outputs
795  ec_domain_state_t *state;
796 } ec_ioctl_domain_state_t;
797 
798 /*****************************************************************************/
799 
800 typedef struct {
801  // inputs
802  uint32_t config_index;
803 
804  // inputs/outputs
805  uint32_t request_index;
806  uint16_t sdo_index;
807  uint8_t sdo_subindex;
808  uint8_t complete_access;
809  size_t size;
810  uint8_t *data;
811  uint32_t timeout;
812  ec_request_state_t state;
813 } ec_ioctl_sdo_request_t;
814 
815 /*****************************************************************************/
816 
817 typedef struct {
818  // inputs
819  uint32_t config_index;
820 
821  // inputs/outputs
822  uint32_t request_index;
823  uint32_t password;
824  size_t size;
825  size_t progress;
826  uint8_t *data;
827  uint32_t timeout;
828  ec_request_state_t state;
829  ec_foe_error_t result;
830  uint32_t error_code;
831 
832  char file_name[255];
833 } ec_ioctl_foe_request_t;
834 
835 /*****************************************************************************/
836 
837 typedef struct {
838  // inputs
839  uint32_t config_index;
840  size_t mem_size;
841 
842  // inputs/outputs
843  uint32_t request_index;
844  uint8_t *data;
845  ec_request_state_t state;
846  uint8_t new_data;
847  uint16_t address;
848  size_t transfer_size;
849 } ec_ioctl_reg_request_t;
850 
851 /*****************************************************************************/
852 
853 typedef struct {
854  // inputs
855  uint32_t config_index;
856 
857  // inputs/outputs
858  uint32_t voe_index;
859  uint32_t *vendor_id;
860  uint16_t *vendor_type;
861  size_t size;
862  uint8_t *data;
863  ec_request_state_t state;
864 } ec_ioctl_voe_t;
865 
866 /*****************************************************************************/
867 
868 typedef struct {
869  // inputs
870  uint32_t dev_idx;
871 
872  // outputs
873  ec_master_link_state_t *state;
874 } ec_ioctl_link_state_t;
875 
876 /*****************************************************************************/
877 
878 typedef struct {
879  // inputs
880  uint16_t slave_position;
881 } ec_ioctl_slave_dict_upload_t;
882 
883 /*****************************************************************************/
884 
885 typedef struct {
886  // input / output
887  size_t data_size;
888  size_t buff_size;
889  uint8_t *data;
890 } ec_ioctl_mbox_gateway_t;
891 
892 /*****************************************************************************/
893 
894 #ifdef __KERNEL__
895 
898 typedef struct {
899  unsigned int writable;
900  unsigned int requested;
901  uint8_t *process_data;
902  size_t process_data_size;
903 } ec_ioctl_context_t;
904 
905 long ec_ioctl(ec_master_t *, ec_ioctl_context_t *, unsigned int,
906  void __user *);
907 
908 #ifdef EC_RTDM
909 
910 long ec_ioctl_rtdm(ec_master_t *, ec_ioctl_context_t *, unsigned int,
911  void __user *);
912 int ec_rtdm_mmap(ec_ioctl_context_t *, void **);
913 
914 #endif
915 
916 #endif
917 
918 /*****************************************************************************/
919 
922 #endif
Slave information interface general flags.
Definition: globals.h:203
uint8_t upstream_port
Index of master-facing port.
Definition: slave.h:232
#define EC_DATAGRAM_NAME_SIZE
Size of the datagram description string.
Definition: globals.h:142
ec_watchdog_mode_t
Watchdog mode for sync manager configuration.
Definition: ecrt.h:450
ec_slave_port_desc_t
EtherCAT slave port descriptor.
Definition: ecrt.h:354
ec_al_state_t
Application-layer state.
Definition: ecrt.h:572
ec_slave_port_t ports[EC_MAX_PORTS]
Ports.
Definition: slave.h:231
ec_foe_error_t
FoE error enumeration type.
Definition: ecrt.h:548
#define EC_RATE_COUNT
Number of statistic rate intervals to maintain.
Definition: globals.h:71
#define EC_MAX_HOSTNAME_SIZE
Maximum hostname size.
Definition: globals.h:148
Global definitions and macros.
Slave configuration state.
Definition: ecrt.h:318
Slave information interface CANopen over EtherCAT details flags.
Definition: globals.h:192
Domain state.
Definition: ecrt.h:426
static unsigned int master_count
Number of masters.
Definition: module.c:58
uint32_t transmission_delay
DC system time transmission delay (offset from reference clock).
Definition: slave.h:262
Number of states.
Definition: globals.h:231
ec_direction_t
Direction type for PDO assignment functions.
Definition: ecrt.h:436
ec_slave_dc_range_t
EtherCAT slave distributed clocks range.
Definition: globals.h:210
uint8_t has_dc_system_time
The slave supports the DC system time register.
Definition: slave.h:259
int ec_rtdm_mmap(ec_ioctl_context_t *ioctl_ctx, void **user_address)
Memory-map process data to user space.
Definition: rtdm.c:220
#define EC_MAX_PORTS
Maximum number of slave ports.
Definition: ecrt.h:217
EtherCAT slave sync signal configuration.
Definition: globals.h:218
unsigned long pcap_size
Pcap buffer size in bytes.
Definition: module.c:67
ec_device_index_t device_index
Index of device the slave responds on.
Definition: slave.h:217
ec_request_state_t
Request state.
Definition: ecrt.h:537
uint8_t scan_required
Scan required.
Definition: slave.h:270
unsigned int error_flag
Stop processing after an error.
Definition: slave.h:239
EtherCAT master.
Definition: master.h:202
#define EC_MAX_SYNC_MANAGERS
Maximum number of sync managers per slave.
Definition: ecrt.h:208
#define EC_SYNC_SIGNAL_COUNT
Number of DC sync signals.
Definition: globals.h:136