37 #ifndef __EC_IOCTL_H__ 38 #define __EC_IOCTL_H__ 40 #include <linux/ioctl.h> 48 #define EC_IOCTL_TYPE 0xa4 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) 59 #define EC_IOCTL_VERSION_MAGIC 36 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) 87 #define EC_IOCTL_SLAVE_EOE_IP_PARAM EC_IOW(0x18, ec_ioctl_slave_eoe_ip_t) 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) 95 #define EC_IOCTL_EOE_HANDLER EC_IOWR(0x1e, ec_ioctl_eoe_handler_t) 97 #define EC_IOCTL_SLAVE_DICT_UPLOAD EC_IOW(0x7f, ec_ioctl_slave_dict_upload_t) 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) 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) 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) 189 #define EC_IOCTL_PCAP_DATA EC_IOWR(0x72, ec_ioctl_pcap_data_t) 192 #define EC_IOCTL_MBOX_GATEWAY EC_IOWR(0x73, ec_ioctl_mbox_gateway_t) 196 #define EC_IOCTL_STRING_SIZE 64 201 uint32_t ioctl_version_magic;
208 uint32_t slave_count;
209 uint32_t config_count;
210 uint32_t domain_count;
212 uint32_t eoe_handler_count;
217 struct ec_ioctl_device {
230 } devices[EC_MAX_NUM_DEVICES];
231 uint32_t num_devices;
242 uint64_t dc_ref_time;
256 uint32_t product_code;
257 uint32_t revision_number;
258 uint32_t serial_number;
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;
272 int16_t current_on_ebus;
276 uint32_t receive_time;
278 uint32_t delay_to_next_dc;
282 uint8_t dc_supported;
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];
303 uint16_t slave_position;
307 uint16_t physical_start_address;
308 uint16_t default_size;
309 uint8_t control_register;
312 } ec_ioctl_slave_sync_t;
318 uint16_t slave_position;
325 int8_t name[EC_IOCTL_STRING_SIZE];
326 } ec_ioctl_slave_sync_pdo_t;
332 uint16_t slave_position;
341 int8_t name[EC_IOCTL_STRING_SIZE];
342 } ec_ioctl_slave_sync_pdo_entry_t;
352 uint32_t logical_base_address;
353 uint16_t working_counter[EC_MAX_NUM_DEVICES];
354 uint16_t expected_working_counter;
362 uint32_t domain_index;
366 uint16_t slave_config_alias;
367 uint16_t slave_config_position;
370 uint32_t logical_address;
372 } ec_ioctl_domain_fmmu_t;
378 uint32_t domain_index;
381 } ec_ioctl_domain_data_t;
390 } ec_ioctl_pcap_data_t;
396 uint16_t slave_position;
398 } ec_ioctl_slave_state_t;
404 uint16_t slave_position;
405 uint16_t sdo_position;
409 uint8_t max_subindex;
410 int8_t name[EC_IOCTL_STRING_SIZE];
411 } ec_ioctl_slave_sdo_t;
417 uint16_t slave_position;
419 uint8_t sdo_entry_subindex;
426 int8_t description[EC_IOCTL_STRING_SIZE];
427 } ec_ioctl_slave_sdo_entry_t;
433 uint16_t slave_position;
435 uint8_t sdo_entry_subindex;
436 uint8_t complete_access;
443 } ec_ioctl_slave_sdo_upload_t;
449 uint16_t slave_position;
451 uint8_t sdo_entry_subindex;
452 uint8_t complete_access;
458 } ec_ioctl_slave_sdo_download_t;
464 uint16_t slave_position;
468 } ec_ioctl_slave_sii_t;
474 uint16_t slave_position;
479 } ec_ioctl_slave_reg_t;
485 uint16_t slave_position;
487 } ec_ioctl_slave_reboot_t;
494 uint16_t slave_position;
505 } ec_ioctl_slave_foe_t;
511 uint16_t slave_position;
520 } ec_ioctl_slave_soe_read_t;
526 uint16_t slave_position;
534 } ec_ioctl_slave_soe_write_t;
540 uint32_t config_index;
546 uint32_t product_code;
553 uint16_t watchdog_divider;
554 uint16_t watchdog_intervals;
557 int32_t slave_position;
558 uint16_t dc_assign_activate;
560 uint8_t allow_overlapping_pdos;
567 uint32_t config_index;
574 int8_t name[EC_IOCTL_STRING_SIZE];
575 } ec_ioctl_config_pdo_t;
581 uint32_t config_index;
590 int8_t name[EC_IOCTL_STRING_SIZE];
591 } ec_ioctl_config_pdo_entry_t;
598 #define EC_MAX_SDO_DATA_SIZE 1024 602 uint32_t config_index;
609 uint8_t data[EC_MAX_SDO_DATA_SIZE];
610 uint8_t complete_access;
611 } ec_ioctl_config_sdo_t;
618 #define EC_MAX_IDN_DATA_SIZE 1024 622 uint32_t config_index;
630 uint8_t data[EC_MAX_IDN_DATA_SIZE];
631 } ec_ioctl_config_idn_t;
643 uint16_t slave_position;
649 uint32_t tx_queued_frames;
650 uint32_t tx_queue_size;
651 } ec_ioctl_eoe_handler_t;
665 #define EC_ETH_ALEN 6 667 #if ETH_ALEN != EC_ETH_ALEN 668 #error Ethernet address length mismatch 675 uint16_t slave_position;
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;
684 unsigned char mac_address[EC_ETH_ALEN];
686 uint32_t subnet_mask;
693 } ec_ioctl_slave_eoe_ip_t;
701 size_t process_data_size;
702 } ec_ioctl_master_activate_t;
708 uint32_t config_index;
710 uint16_t entry_index;
711 uint8_t entry_subindex;
712 uint8_t entry_bit_length;
713 } ec_ioctl_add_pdo_entry_t;
719 uint32_t config_index;
720 uint16_t entry_index;
721 uint8_t entry_subindex;
722 uint32_t domain_index;
725 unsigned int bit_position;
726 } ec_ioctl_reg_pdo_entry_t;
732 uint32_t config_index;
736 uint32_t domain_index;
739 unsigned int bit_position;
740 } ec_ioctl_reg_pdo_pos_t;
746 uint32_t config_index;
751 uint8_t complete_access;
758 uint32_t config_index;
764 } ec_ioctl_sc_emerg_t;
770 uint32_t config_index;
774 } ec_ioctl_sc_state_t;
780 uint32_t config_index;
792 uint32_t domain_index;
796 } ec_ioctl_domain_state_t;
802 uint32_t config_index;
805 uint32_t request_index;
807 uint8_t sdo_subindex;
808 uint8_t complete_access;
813 } ec_ioctl_sdo_request_t;
819 uint32_t config_index;
822 uint32_t request_index;
833 } ec_ioctl_foe_request_t;
839 uint32_t config_index;
843 uint32_t request_index;
848 size_t transfer_size;
849 } ec_ioctl_reg_request_t;
855 uint32_t config_index;
860 uint16_t *vendor_type;
874 } ec_ioctl_link_state_t;
880 uint16_t slave_position;
881 } ec_ioctl_slave_dict_upload_t;
890 } ec_ioctl_mbox_gateway_t;
899 unsigned int writable;
900 unsigned int requested;
901 uint8_t *process_data;
902 size_t process_data_size;
903 } ec_ioctl_context_t;
905 long ec_ioctl(
ec_master_t *, ec_ioctl_context_t *,
unsigned int,
910 long ec_ioctl_rtdm(
ec_master_t *, ec_ioctl_context_t *,
unsigned int,
Slave information interface general flags.
uint8_t upstream_port
Index of master-facing port.
#define EC_DATAGRAM_NAME_SIZE
Size of the datagram description string.
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.
ec_slave_port_t ports[EC_MAX_PORTS]
Ports.
ec_foe_error_t
FoE error enumeration type.
#define EC_RATE_COUNT
Number of statistic rate intervals to maintain.
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.
uint32_t transmission_delay
DC system time transmission delay (offset from reference clock).
ec_direction_t
Direction type for PDO assignment functions.
ec_slave_dc_range_t
EtherCAT slave distributed clocks range.
uint8_t has_dc_system_time
The slave supports the DC system time register.
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.
unsigned long pcap_size
Pcap buffer size in bytes.
ec_device_index_t device_index
Index of device the slave responds on.
ec_request_state_t
Request state.
uint8_t scan_required
Scan required.
unsigned int error_flag
Stop processing after an error.
#define EC_MAX_SYNC_MANAGERS
Maximum number of sync managers per slave.
#define EC_SYNC_SIGNAL_COUNT
Number of DC sync signals.