28 #ifndef __EC_IOCTL_H__ 29 #define __EC_IOCTL_H__ 31 #include <linux/ioctl.h> 39 #define EC_IOCTL_TYPE 0xa4 41 #define EC_IO(nr) _IO(EC_IOCTL_TYPE, nr) 42 #define EC_IOR(nr, type) _IOR(EC_IOCTL_TYPE, nr, type) 43 #define EC_IOW(nr, type) _IOW(EC_IOCTL_TYPE, nr, type) 44 #define EC_IOWR(nr, type) _IOWR(EC_IOCTL_TYPE, nr, type) 50 #define EC_IOCTL_VERSION_MAGIC 38 54 #define EC_IOCTL_MODULE EC_IOR(0x00, ec_ioctl_module_t) 55 #define EC_IOCTL_MASTER EC_IOR(0x01, ec_ioctl_master_t) 56 #define EC_IOCTL_SLAVE EC_IOWR(0x02, ec_ioctl_slave_t) 57 #define EC_IOCTL_SLAVE_SYNC EC_IOWR(0x03, ec_ioctl_slave_sync_t) 58 #define EC_IOCTL_SLAVE_SYNC_PDO EC_IOWR(0x04, ec_ioctl_slave_sync_pdo_t) 59 #define EC_IOCTL_SLAVE_SYNC_PDO_ENTRY EC_IOWR(0x05, ec_ioctl_slave_sync_pdo_entry_t) 60 #define EC_IOCTL_DOMAIN EC_IOWR(0x06, ec_ioctl_domain_t) 61 #define EC_IOCTL_DOMAIN_FMMU EC_IOWR(0x07, ec_ioctl_domain_fmmu_t) 62 #define EC_IOCTL_DOMAIN_DATA EC_IOWR(0x08, ec_ioctl_domain_data_t) 63 #define EC_IOCTL_MASTER_DEBUG EC_IO(0x09) 64 #define EC_IOCTL_MASTER_RESCAN EC_IO(0x0a) 65 #define EC_IOCTL_SLAVE_STATE EC_IOW(0x0b, ec_ioctl_slave_state_t) 66 #define EC_IOCTL_SLAVE_SDO EC_IOWR(0x0c, ec_ioctl_slave_sdo_t) 67 #define EC_IOCTL_SLAVE_SDO_ENTRY EC_IOWR(0x0d, ec_ioctl_slave_sdo_entry_t) 68 #define EC_IOCTL_SLAVE_SDO_UPLOAD EC_IOWR(0x0e, ec_ioctl_slave_sdo_upload_t) 69 #define EC_IOCTL_SLAVE_SDO_DOWNLOAD EC_IOWR(0x0f, ec_ioctl_slave_sdo_download_t) 70 #define EC_IOCTL_SLAVE_SII_READ EC_IOWR(0x10, ec_ioctl_slave_sii_t) 71 #define EC_IOCTL_SLAVE_SII_WRITE EC_IOW(0x11, ec_ioctl_slave_sii_t) 72 #define EC_IOCTL_SLAVE_REG_READ EC_IOWR(0x12, ec_ioctl_slave_reg_t) 73 #define EC_IOCTL_SLAVE_REG_WRITE EC_IOW(0x13, ec_ioctl_slave_reg_t) 74 #define EC_IOCTL_SLAVE_FOE_READ EC_IOWR(0x14, ec_ioctl_slave_foe_t) 75 #define EC_IOCTL_SLAVE_FOE_WRITE EC_IOW(0x15, ec_ioctl_slave_foe_t) 76 #define EC_IOCTL_SLAVE_SOE_READ EC_IOWR(0x16, ec_ioctl_slave_soe_read_t) 77 #define EC_IOCTL_SLAVE_SOE_WRITE EC_IOWR(0x17, ec_ioctl_slave_soe_write_t) 79 #define EC_IOCTL_SLAVE_EOE_IP_PARAM EC_IOW(0x18, ec_ioctl_eoe_ip_t) 81 #define EC_IOCTL_CONFIG EC_IOWR(0x19, ec_ioctl_config_t) 82 #define EC_IOCTL_CONFIG_PDO EC_IOWR(0x1a, ec_ioctl_config_pdo_t) 83 #define EC_IOCTL_CONFIG_PDO_ENTRY EC_IOWR(0x1b, ec_ioctl_config_pdo_entry_t) 84 #define EC_IOCTL_CONFIG_SDO EC_IOWR(0x1c, ec_ioctl_config_sdo_t) 85 #define EC_IOCTL_CONFIG_IDN EC_IOWR(0x1d, ec_ioctl_config_idn_t) 86 #define EC_IOCTL_CONFIG_FLAG EC_IOWR(0x1e, ec_ioctl_config_flag_t) 88 #define EC_IOCTL_CONFIG_EOE_IP_PARAM EC_IOWR(0x1f, ec_ioctl_eoe_ip_t) 89 #define EC_IOCTL_EOE_HANDLER EC_IOWR(0x20, ec_ioctl_eoe_handler_t) 93 #define EC_IOCTL_REQUEST EC_IO(0x21) 94 #define EC_IOCTL_CREATE_DOMAIN EC_IO(0x22) 95 #define EC_IOCTL_CREATE_SLAVE_CONFIG EC_IOWR(0x23, ec_ioctl_config_t) 96 #define EC_IOCTL_SELECT_REF_CLOCK EC_IOW(0x24, uint32_t) 97 #define EC_IOCTL_ACTIVATE EC_IOR(0x25, ec_ioctl_master_activate_t) 98 #define EC_IOCTL_DEACTIVATE EC_IO(0x26) 99 #define EC_IOCTL_SEND EC_IO(0x27) 100 #define EC_IOCTL_RECEIVE EC_IO(0x28) 101 #define EC_IOCTL_MASTER_STATE EC_IOR(0x29, ec_master_state_t) 102 #define EC_IOCTL_MASTER_LINK_STATE EC_IOWR(0x2a, ec_ioctl_link_state_t) 103 #define EC_IOCTL_APP_TIME EC_IOW(0x2b, uint64_t) 104 #define EC_IOCTL_SYNC_REF EC_IO(0x2c) 105 #define EC_IOCTL_SYNC_REF_TO EC_IOW(0x2d, uint64_t) 106 #define EC_IOCTL_SYNC_SLAVES EC_IO(0x2e) 107 #define EC_IOCTL_REF_CLOCK_TIME EC_IOR(0x2f, uint32_t) 108 #define EC_IOCTL_SYNC_MON_QUEUE EC_IO(0x30) 109 #define EC_IOCTL_SYNC_MON_PROCESS EC_IOR(0x31, uint32_t) 110 #define EC_IOCTL_RESET EC_IO(0x32) 111 #define EC_IOCTL_SC_SYNC EC_IOW(0x33, ec_ioctl_config_t) 112 #define EC_IOCTL_SC_WATCHDOG EC_IOW(0x34, ec_ioctl_config_t) 113 #define EC_IOCTL_SC_ADD_PDO EC_IOW(0x35, ec_ioctl_config_pdo_t) 114 #define EC_IOCTL_SC_CLEAR_PDOS EC_IOW(0x36, ec_ioctl_config_pdo_t) 115 #define EC_IOCTL_SC_ADD_ENTRY EC_IOW(0x37, ec_ioctl_add_pdo_entry_t) 116 #define EC_IOCTL_SC_CLEAR_ENTRIES EC_IOW(0x38, ec_ioctl_config_pdo_t) 117 #define EC_IOCTL_SC_REG_PDO_ENTRY EC_IOWR(0x39, ec_ioctl_reg_pdo_entry_t) 118 #define EC_IOCTL_SC_REG_PDO_POS EC_IOWR(0x3a, ec_ioctl_reg_pdo_pos_t) 119 #define EC_IOCTL_SC_DC EC_IOW(0x3b, ec_ioctl_config_t) 120 #define EC_IOCTL_SC_SDO EC_IOW(0x3c, ec_ioctl_sc_sdo_t) 121 #define EC_IOCTL_SC_EMERG_SIZE EC_IOW(0x3d, ec_ioctl_sc_emerg_t) 122 #define EC_IOCTL_SC_EMERG_POP EC_IOWR(0x3e, ec_ioctl_sc_emerg_t) 123 #define EC_IOCTL_SC_EMERG_CLEAR EC_IOW(0x3f, ec_ioctl_sc_emerg_t) 124 #define EC_IOCTL_SC_EMERG_OVERRUNS EC_IOWR(0x40, ec_ioctl_sc_emerg_t) 125 #define EC_IOCTL_SC_SDO_REQUEST EC_IOWR(0x41, ec_ioctl_sdo_request_t) 126 #define EC_IOCTL_SC_SOE_REQUEST EC_IOWR(0x42, ec_ioctl_soe_request_t) 127 #define EC_IOCTL_SC_REG_REQUEST EC_IOWR(0x43, ec_ioctl_reg_request_t) 128 #define EC_IOCTL_SC_VOE EC_IOWR(0x44, ec_ioctl_voe_t) 129 #define EC_IOCTL_SC_STATE EC_IOWR(0x45, ec_ioctl_sc_state_t) 130 #define EC_IOCTL_SC_IDN EC_IOW(0x46, ec_ioctl_sc_idn_t) 131 #define EC_IOCTL_SC_FLAG EC_IOW(0x47, ec_ioctl_sc_flag_t) 133 #define EC_IOCTL_SC_EOE_IP_PARAM EC_IOW(0x48, ec_ioctl_eoe_ip_t) 135 #define EC_IOCTL_SC_STATE_TIMEOUT EC_IOW(0x49, ec_ioctl_sc_state_timeout_t) 136 #define EC_IOCTL_DOMAIN_SIZE EC_IO(0x4a) 137 #define EC_IOCTL_DOMAIN_OFFSET EC_IO(0x4b) 138 #define EC_IOCTL_DOMAIN_PROCESS EC_IO(0x4c) 139 #define EC_IOCTL_DOMAIN_QUEUE EC_IO(0x4d) 140 #define EC_IOCTL_DOMAIN_STATE EC_IOWR(0x4e, ec_ioctl_domain_state_t) 141 #define EC_IOCTL_SDO_REQUEST_INDEX EC_IOWR(0x4f, ec_ioctl_sdo_request_t) 142 #define EC_IOCTL_SDO_REQUEST_TIMEOUT EC_IOWR(0x50, ec_ioctl_sdo_request_t) 143 #define EC_IOCTL_SDO_REQUEST_STATE EC_IOWR(0x51, ec_ioctl_sdo_request_t) 144 #define EC_IOCTL_SDO_REQUEST_READ EC_IOWR(0x52, ec_ioctl_sdo_request_t) 145 #define EC_IOCTL_SDO_REQUEST_WRITE EC_IOWR(0x53, ec_ioctl_sdo_request_t) 146 #define EC_IOCTL_SDO_REQUEST_DATA EC_IOWR(0x54, ec_ioctl_sdo_request_t) 147 #define EC_IOCTL_SOE_REQUEST_IDN EC_IOWR(0x55, ec_ioctl_soe_request_t) 148 #define EC_IOCTL_SOE_REQUEST_TIMEOUT EC_IOWR(0x56, ec_ioctl_soe_request_t) 149 #define EC_IOCTL_SOE_REQUEST_STATE EC_IOWR(0x57, ec_ioctl_soe_request_t) 150 #define EC_IOCTL_SOE_REQUEST_READ EC_IOWR(0x58, ec_ioctl_soe_request_t) 151 #define EC_IOCTL_SOE_REQUEST_WRITE EC_IOWR(0x59, ec_ioctl_soe_request_t) 152 #define EC_IOCTL_SOE_REQUEST_DATA EC_IOWR(0x5a, ec_ioctl_soe_request_t) 153 #define EC_IOCTL_REG_REQUEST_DATA EC_IOWR(0x5b, ec_ioctl_reg_request_t) 154 #define EC_IOCTL_REG_REQUEST_STATE EC_IOWR(0x5c, ec_ioctl_reg_request_t) 155 #define EC_IOCTL_REG_REQUEST_WRITE EC_IOWR(0x5d, ec_ioctl_reg_request_t) 156 #define EC_IOCTL_REG_REQUEST_READ EC_IOWR(0x5e, ec_ioctl_reg_request_t) 157 #define EC_IOCTL_VOE_SEND_HEADER EC_IOW(0x5f, ec_ioctl_voe_t) 158 #define EC_IOCTL_VOE_REC_HEADER EC_IOWR(0x60, ec_ioctl_voe_t) 159 #define EC_IOCTL_VOE_READ EC_IOW(0x61, ec_ioctl_voe_t) 160 #define EC_IOCTL_VOE_READ_NOSYNC EC_IOW(0x62, ec_ioctl_voe_t) 161 #define EC_IOCTL_VOE_WRITE EC_IOWR(0x63, ec_ioctl_voe_t) 162 #define EC_IOCTL_VOE_EXEC EC_IOWR(0x64, ec_ioctl_voe_t) 163 #define EC_IOCTL_VOE_DATA EC_IOWR(0x65, ec_ioctl_voe_t) 164 #define EC_IOCTL_SET_SEND_INTERVAL EC_IOW(0x66, size_t) 165 #define EC_IOCTL_SII_CACHING EC_IOW(0x67, uint32_t) 166 #define EC_IOCTL_SC_PDO_MODE EC_IOW(0x68, ec_ioctl_config_t) 171 #define EC_IOCTL_STRING_SIZE 64 176 uint32_t ioctl_version_magic;
183 uint32_t slave_count;
185 uint32_t config_count;
186 uint32_t domain_count;
187 uint32_t eoe_handler_count;
191 struct ec_ioctl_device {
204 } devices[EC_MAX_NUM_DEVICES];
205 uint32_t num_devices;
216 uint64_t dc_ref_time;
228 unsigned int device_index;
230 uint32_t product_code;
231 uint32_t revision_number;
232 uint32_t serial_number;
234 uint16_t boot_rx_mailbox_offset;
235 uint16_t boot_rx_mailbox_size;
236 uint16_t boot_tx_mailbox_offset;
237 uint16_t boot_tx_mailbox_size;
238 uint16_t std_rx_mailbox_offset;
239 uint16_t std_rx_mailbox_size;
240 uint16_t std_tx_mailbox_offset;
241 uint16_t std_tx_mailbox_size;
242 uint16_t mailbox_protocols;
243 uint8_t has_general_category;
246 int16_t current_on_ebus;
250 uint32_t receive_time;
252 uint32_t delay_to_next_dc;
255 uint8_t dc_supported;
257 uint8_t has_dc_system_time;
258 uint32_t transmission_delay;
264 uint32_t sii_parallel_words;
265 char group[EC_IOCTL_STRING_SIZE];
266 char image[EC_IOCTL_STRING_SIZE];
267 char order[EC_IOCTL_STRING_SIZE];
268 char name[EC_IOCTL_STRING_SIZE];
275 uint16_t slave_position;
279 uint16_t physical_start_address;
280 uint16_t default_size;
281 uint8_t control_register;
284 } ec_ioctl_slave_sync_t;
290 uint16_t slave_position;
297 int8_t name[EC_IOCTL_STRING_SIZE];
298 } ec_ioctl_slave_sync_pdo_t;
304 uint16_t slave_position;
313 int8_t name[EC_IOCTL_STRING_SIZE];
314 } ec_ioctl_slave_sync_pdo_entry_t;
324 uint32_t logical_base_address;
325 uint16_t working_counter[EC_MAX_NUM_DEVICES];
326 uint16_t expected_working_counter;
334 uint32_t domain_index;
338 uint16_t slave_config_alias;
339 uint16_t slave_config_position;
342 uint32_t logical_address;
344 } ec_ioctl_domain_fmmu_t;
350 uint32_t domain_index;
353 } ec_ioctl_domain_data_t;
359 uint16_t slave_position;
361 } ec_ioctl_slave_state_t;
367 uint16_t slave_position;
368 uint16_t sdo_position;
372 uint8_t max_subindex;
373 int8_t name[EC_IOCTL_STRING_SIZE];
374 } ec_ioctl_slave_sdo_t;
380 uint16_t slave_position;
382 uint8_t sdo_entry_subindex;
389 int8_t description[EC_IOCTL_STRING_SIZE];
390 } ec_ioctl_slave_sdo_entry_t;
396 uint16_t slave_position;
398 uint8_t sdo_entry_subindex;
405 } ec_ioctl_slave_sdo_upload_t;
411 uint16_t slave_position;
413 uint8_t sdo_entry_subindex;
414 uint8_t complete_access;
420 } ec_ioctl_slave_sdo_download_t;
426 uint16_t slave_position;
430 } ec_ioctl_slave_sii_t;
436 uint16_t slave_position;
441 } ec_ioctl_slave_reg_t;
447 uint16_t slave_position;
457 } ec_ioctl_slave_foe_t;
463 uint16_t slave_position;
472 } ec_ioctl_slave_soe_read_t;
478 uint16_t slave_position;
486 } ec_ioctl_slave_soe_write_t;
492 uint32_t config_index;
498 uint32_t product_code;
505 uint16_t watchdog_divider;
506 uint16_t watchdog_intervals;
512 int32_t slave_position;
513 uint16_t dc_assign_activate;
521 uint32_t config_index;
528 int8_t name[EC_IOCTL_STRING_SIZE];
529 } ec_ioctl_config_pdo_t;
535 uint32_t config_index;
544 int8_t name[EC_IOCTL_STRING_SIZE];
545 } ec_ioctl_config_pdo_entry_t;
552 #define EC_MAX_SDO_DATA_SIZE 1024 556 uint32_t config_index;
563 uint8_t data[EC_MAX_SDO_DATA_SIZE];
564 uint8_t complete_access;
565 } ec_ioctl_config_sdo_t;
572 #define EC_MAX_IDN_DATA_SIZE 1024 576 uint32_t config_index;
584 uint8_t data[EC_MAX_IDN_DATA_SIZE];
585 } ec_ioctl_config_idn_t;
591 #define EC_MAX_FLAG_KEY_SIZE 128 595 uint32_t config_index;
599 char key[EC_MAX_FLAG_KEY_SIZE];
601 } ec_ioctl_config_flag_t;
613 uint16_t slave_position;
619 uint32_t tx_queued_frames;
620 uint32_t tx_queue_size;
621 } ec_ioctl_eoe_handler_t;
627 #define EC_ETH_ALEN 6 629 #if ETH_ALEN != EC_ETH_ALEN 630 #error Ethernet address length mismatch 636 uint16_t slave_position;
637 uint16_t config_index;
639 uint8_t mac_address_included;
640 uint8_t ip_address_included;
641 uint8_t subnet_mask_included;
642 uint8_t gateway_included;
643 uint8_t dns_included;
644 uint8_t name_included;
646 unsigned char mac_address[EC_ETH_ALEN];
647 struct in_addr ip_address;
648 struct in_addr subnet_mask;
649 struct in_addr gateway;
662 size_t process_data_size;
663 } ec_ioctl_master_activate_t;
669 uint32_t config_index;
671 uint16_t entry_index;
672 uint8_t entry_subindex;
673 uint8_t entry_bit_length;
674 } ec_ioctl_add_pdo_entry_t;
680 uint32_t config_index;
681 uint16_t entry_index;
682 uint8_t entry_subindex;
683 uint32_t domain_index;
686 unsigned int bit_position;
687 } ec_ioctl_reg_pdo_entry_t;
693 uint32_t config_index;
697 uint32_t domain_index;
700 unsigned int bit_position;
701 } ec_ioctl_reg_pdo_pos_t;
707 uint32_t config_index;
712 uint8_t complete_access;
719 uint32_t config_index;
725 } ec_ioctl_sc_emerg_t;
731 uint32_t config_index;
735 } ec_ioctl_sc_state_t;
741 uint32_t config_index;
753 uint32_t config_index;
757 } ec_ioctl_sc_flag_t;
763 uint32_t config_index;
767 } ec_ioctl_sc_state_timeout_t;
773 uint32_t domain_index;
777 } ec_ioctl_domain_state_t;
783 uint32_t config_index;
786 uint32_t request_index;
788 uint8_t sdo_subindex;
793 } ec_ioctl_sdo_request_t;
799 uint32_t config_index;
802 uint32_t request_index;
809 } ec_ioctl_soe_request_t;
815 uint32_t config_index;
819 uint32_t request_index;
824 size_t transfer_size;
825 } ec_ioctl_reg_request_t;
831 uint32_t config_index;
836 uint16_t *vendor_type;
850 } ec_ioctl_link_state_t;
859 unsigned int writable;
860 unsigned int requested;
861 uint8_t *process_data;
862 size_t process_data_size;
863 } ec_ioctl_context_t;
870 long ec_ioctl_rtdm_rt(
ec_master_t *, ec_ioctl_context_t *,
unsigned int,
872 long ec_ioctl_rtdm_nrt(
ec_master_t *, ec_ioctl_context_t *,
unsigned int,
875 #ifndef EC_RTDM_XENOMAI_V3 Slave information interface general flags.
#define EC_DATAGRAM_NAME_SIZE
Size of the datagram description string.
ec_pdo_mode_t
PDO handling mode.
ec_watchdog_mode_t
Watchdog mode for sync manager configuration.
ec_slave_port_desc_t
EtherCAT slave port descriptor.
ec_al_state_t
Application-layer state.
#define EC_RATE_COUNT
Number of statistic rate intervals to maintain.
static unsigned int sii_caching
SII Caching mode.
EtherCAT slave port information.
#define EC_MAX_HOSTNAME_SIZE
Maximum hostname size.
Global definitions and macros.
Slave configuration state.
Slave information interface CANopen over EtherCAT details flags.
static unsigned int master_count
Number of masters.
ec_direction_t
Direction type for PDO assignment functions.
long ec_ioctl(ec_master_t *master, ec_ioctl_context_t *ctx, unsigned int cmd, void *arg)
Called when an ioctl() command is issued.
ec_slave_dc_range_t
EtherCAT slave distributed clocks range.
int ec_rtdm_mmap(ec_ioctl_context_t *ioctl_ctx, void **user_address)
Memory-map process data to user space.
#define EC_MAX_PORTS
Maximum number of slave ports.
EtherCAT slave sync signal configuration.
ec_request_state_t
Request state.
#define EC_MAX_SYNC_MANAGERS
Maximum number of sync managers per slave.
#define EC_SYNC_SIGNAL_COUNT
Number of DC sync signals.