fp@922: /****************************************************************************** fp@922: * fp@922: * $Id$ fp@922: * fp@1326: * Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH fp@922: * fp@922: * This file is part of the IgH EtherCAT Master. fp@922: * fp@1326: * The IgH EtherCAT Master is free software; you can redistribute it and/or fp@1326: * modify it under the terms of the GNU General Public License version 2, as fp@1326: * published by the Free Software Foundation. fp@1326: * fp@1326: * The IgH EtherCAT Master is distributed in the hope that it will be useful, fp@1326: * but WITHOUT ANY WARRANTY; without even the implied warranty of fp@1326: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General fp@1326: * Public License for more details. fp@1326: * fp@1326: * You should have received a copy of the GNU General Public License along fp@1326: * with the IgH EtherCAT Master; if not, write to the Free Software fp@922: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA fp@922: * fp@1363: * --- fp@1363: * fp@1363: * The license mentioned above concerns the source code only. Using the fp@1363: * EtherCAT technology and brand is only permitted in compliance with the fp@1363: * industrial property and similar rights of Beckhoff Automation GmbH. fp@922: * fp@922: *****************************************************************************/ fp@922: fp@922: /** fp@922: \file fp@922: EtherCAT master character device IOCTL commands. fp@922: */ fp@922: fp@922: /*****************************************************************************/ fp@922: fp@922: #ifndef __EC_IOCTL_H__ fp@922: #define __EC_IOCTL_H__ fp@922: fp@971: #include fp@971: fp@989: #include "globals.h" fp@989: fp@971: /*****************************************************************************/ fp@971: fp@1082: /** \cond */ fp@1082: fp@1079: #define EC_IOCTL_TYPE 0xa4 fp@1079: fp@1079: #define EC_IO(nr) _IO(EC_IOCTL_TYPE, nr) fp@1079: #define EC_IOR(nr, type) _IOR(EC_IOCTL_TYPE, nr, type) fp@1079: #define EC_IOW(nr, type) _IOW(EC_IOCTL_TYPE, nr, type) fp@1079: #define EC_IOWR(nr, type) _IOWR(EC_IOCTL_TYPE, nr, type) fp@1079: fp@1259: // Command-line tool fp@1079: #define EC_IOCTL_MASTER EC_IOR(0x00, ec_ioctl_master_t) fp@1079: #define EC_IOCTL_SLAVE EC_IOWR(0x01, ec_ioctl_slave_t) fp@1079: #define EC_IOCTL_SLAVE_SYNC EC_IOWR(0x02, ec_ioctl_slave_sync_t) fp@1079: #define EC_IOCTL_SLAVE_SYNC_PDO EC_IOWR(0x03, ec_ioctl_slave_sync_pdo_t) fp@1079: #define EC_IOCTL_SLAVE_SYNC_PDO_ENTRY EC_IOWR(0x04, ec_ioctl_slave_sync_pdo_entry_t) fp@1079: #define EC_IOCTL_DOMAIN EC_IOWR(0x05, ec_ioctl_domain_t) fp@1079: #define EC_IOCTL_DOMAIN_FMMU EC_IOWR(0x06, ec_ioctl_domain_fmmu_t) fp@1079: #define EC_IOCTL_DOMAIN_DATA EC_IOWR(0x07, ec_ioctl_domain_data_t) fp@1079: #define EC_IOCTL_MASTER_DEBUG EC_IO(0x08) fp@1079: #define EC_IOCTL_SLAVE_STATE EC_IOW(0x09, ec_ioctl_slave_state_t) fp@1079: #define EC_IOCTL_SLAVE_SDO EC_IOWR(0x0a, ec_ioctl_slave_sdo_t) fp@1079: #define EC_IOCTL_SLAVE_SDO_ENTRY EC_IOWR(0x0b, ec_ioctl_slave_sdo_entry_t) fp@1079: #define EC_IOCTL_SLAVE_SDO_UPLOAD EC_IOWR(0x0c, ec_ioctl_slave_sdo_upload_t) fp@1079: #define EC_IOCTL_SLAVE_SDO_DOWNLOAD EC_IOWR(0x0d, ec_ioctl_slave_sdo_download_t) fp@1079: #define EC_IOCTL_SLAVE_SII_READ EC_IOWR(0x0e, ec_ioctl_slave_sii_t) fp@1079: #define EC_IOCTL_SLAVE_SII_WRITE EC_IOW(0x0f, ec_ioctl_slave_sii_t) fp@1200: #define EC_IOCTL_SLAVE_PHY_READ EC_IOWR(0x10, ec_ioctl_slave_phy_t) fp@1200: #define EC_IOCTL_SLAVE_PHY_WRITE EC_IOW(0x11, ec_ioctl_slave_phy_t) fp@1335: #define EC_IOCTL_SLAVE_FOE_READ EC_IOWR(0x12, ec_ioctl_slave_foe_t) fp@1335: #define EC_IOCTL_SLAVE_FOE_WRITE EC_IOW(0x13, ec_ioctl_slave_foe_t) fp@1335: #define EC_IOCTL_CONFIG EC_IOWR(0x14, ec_ioctl_config_t) fp@1335: #define EC_IOCTL_CONFIG_PDO EC_IOWR(0x15, ec_ioctl_config_pdo_t) fp@1335: #define EC_IOCTL_CONFIG_PDO_ENTRY EC_IOWR(0x16, ec_ioctl_config_pdo_entry_t) fp@1335: #define EC_IOCTL_CONFIG_SDO EC_IOWR(0x17, ec_ioctl_config_sdo_t) fp@1244: fp@1259: // Application interface fp@1335: #define EC_IOCTL_REQUEST EC_IO(0x18) fp@1335: #define EC_IOCTL_CREATE_DOMAIN EC_IO(0x19) fp@1335: #define EC_IOCTL_CREATE_SLAVE_CONFIG EC_IOWR(0x1a, ec_ioctl_config_t) fp@1335: #define EC_IOCTL_ACTIVATE EC_IOR(0x1b, size_t) fp@1335: #define EC_IOCTL_SEND EC_IO(0x1c) fp@1335: #define EC_IOCTL_RECEIVE EC_IO(0x1d) fp@1335: #define EC_IOCTL_MASTER_STATE EC_IOR(0x1e, ec_master_state_t) fp@1335: #define EC_IOCTL_SC_SYNC EC_IOW(0x1f, ec_ioctl_config_t) fp@1335: #define EC_IOCTL_SC_ADD_PDO EC_IOW(0x20, ec_ioctl_config_pdo_t) fp@1335: #define EC_IOCTL_SC_CLEAR_PDOS EC_IOW(0x21, ec_ioctl_config_pdo_t) fp@1335: #define EC_IOCTL_SC_ADD_ENTRY EC_IOW(0x22, ec_ioctl_add_pdo_entry_t) fp@1335: #define EC_IOCTL_SC_CLEAR_ENTRIES EC_IOW(0x23, ec_ioctl_config_pdo_t) fp@1335: #define EC_IOCTL_SC_REG_PDO_ENTRY EC_IOWR(0x24, ec_ioctl_reg_pdo_entry_t) fp@1335: #define EC_IOCTL_SC_SDO EC_IOW(0x25, ec_ioctl_sc_sdo_t) fp@1352: #define EC_IOCTL_SC_SDO_REQUEST EC_IOWR(0x26, ec_ioctl_sdo_request_t) fp@1352: #define EC_IOCTL_SC_VOE EC_IOWR(0x27, ec_ioctl_voe_t) fp@1352: #define EC_IOCTL_SC_STATE EC_IOWR(0x28, ec_ioctl_sc_state_t) fp@1352: #define EC_IOCTL_DOMAIN_OFFSET EC_IO(0x29) fp@1352: #define EC_IOCTL_DOMAIN_PROCESS EC_IO(0x2a) fp@1352: #define EC_IOCTL_DOMAIN_QUEUE EC_IO(0x2b) fp@1352: #define EC_IOCTL_DOMAIN_STATE EC_IOWR(0x2c, ec_ioctl_domain_state_t) fp@1352: #define EC_IOCTL_SDO_REQUEST_TIMEOUT EC_IOWR(0x2d, ec_ioctl_sdo_request_t) fp@1352: #define EC_IOCTL_SDO_REQUEST_STATE EC_IOWR(0x2e, ec_ioctl_sdo_request_t) fp@1352: #define EC_IOCTL_SDO_REQUEST_READ EC_IOWR(0x2f, ec_ioctl_sdo_request_t) fp@1352: #define EC_IOCTL_SDO_REQUEST_WRITE EC_IOWR(0x30, ec_ioctl_sdo_request_t) fp@1352: #define EC_IOCTL_SDO_REQUEST_DATA EC_IOWR(0x31, ec_ioctl_sdo_request_t) fp@1352: #define EC_IOCTL_VOE_SEND_HEADER EC_IOW(0x32, ec_ioctl_voe_t) fp@1352: #define EC_IOCTL_VOE_REC_HEADER EC_IOWR(0x33, ec_ioctl_voe_t) fp@1352: #define EC_IOCTL_VOE_READ EC_IOW(0x34, ec_ioctl_voe_t) fp@1352: #define EC_IOCTL_VOE_READ_NOSYNC EC_IOW(0x35, ec_ioctl_voe_t) fp@1352: #define EC_IOCTL_VOE_WRITE EC_IOWR(0x36, ec_ioctl_voe_t) fp@1352: #define EC_IOCTL_VOE_EXEC EC_IOWR(0x37, ec_ioctl_voe_t) fp@1352: #define EC_IOCTL_VOE_DATA EC_IOWR(0x38, ec_ioctl_voe_t) fp@1259: fp@1259: /*****************************************************************************/ fp@990: fp@990: #define EC_IOCTL_STRING_SIZE 64 fp@978: fp@978: /*****************************************************************************/ fp@978: fp@978: typedef struct { fp@978: uint32_t slave_count; fp@990: uint32_t config_count; fp@1001: uint32_t domain_count; fp@1029: uint8_t phase; fp@957: struct { fp@957: uint8_t address[6]; fp@957: uint8_t attached; fp@978: uint32_t tx_count; fp@978: uint32_t rx_count; fp@957: } devices[2]; fp@957: } ec_ioctl_master_t; fp@957: fp@957: /*****************************************************************************/ fp@957: fp@935: typedef struct { fp@935: // input fp@935: uint16_t position; fp@935: fp@935: // outputs fp@922: uint32_t vendor_id; fp@922: uint32_t product_code; fp@938: uint32_t revision_number; fp@938: uint32_t serial_number; fp@922: uint16_t alias; fp@1337: uint16_t boot_rx_mailbox_offset; fp@1337: uint16_t boot_rx_mailbox_size; fp@1337: uint16_t boot_tx_mailbox_offset; fp@1337: uint16_t boot_tx_mailbox_size; fp@1337: uint16_t std_rx_mailbox_offset; fp@1337: uint16_t std_rx_mailbox_size; fp@1337: uint16_t std_tx_mailbox_offset; fp@1337: uint16_t std_tx_mailbox_size; fp@989: uint16_t mailbox_protocols; fp@989: uint8_t has_general_category; fp@989: ec_sii_coe_details_t coe_details; fp@989: ec_sii_general_flags_t general_flags; fp@989: int16_t current_on_ebus; fp@1379: ec_slave_port_desc_t ports[EC_MAX_PORTS]; fp@1379: uint8_t fmmu_bit; fp@1379: uint8_t dc_supported; fp@1379: ec_slave_dc_range_t dc_range; fp@1148: uint8_t al_state; fp@987: uint8_t error_flag; fp@935: uint8_t sync_count; fp@965: uint16_t sdo_count; fp@978: uint32_t sii_nwords; fp@1109: char group[EC_IOCTL_STRING_SIZE]; fp@1109: char image[EC_IOCTL_STRING_SIZE]; fp@1109: char order[EC_IOCTL_STRING_SIZE]; fp@990: char name[EC_IOCTL_STRING_SIZE]; fp@935: } ec_ioctl_slave_t; fp@935: fp@935: /*****************************************************************************/ fp@935: fp@935: typedef struct { fp@935: // inputs fp@935: uint16_t slave_position; fp@978: uint32_t sync_index; fp@935: fp@935: // outputs fp@935: uint16_t physical_start_address; fp@935: uint16_t default_size; fp@935: uint8_t control_register; fp@935: uint8_t enable; fp@935: uint8_t pdo_count; fp@1079: } ec_ioctl_slave_sync_t; fp@935: fp@935: /*****************************************************************************/ fp@935: fp@935: typedef struct { fp@935: // inputs fp@935: uint16_t slave_position; fp@978: uint32_t sync_index; fp@978: uint32_t pdo_pos; fp@935: fp@935: // outputs fp@935: uint16_t index; fp@935: uint8_t entry_count; fp@990: int8_t name[EC_IOCTL_STRING_SIZE]; fp@1079: } ec_ioctl_slave_sync_pdo_t; fp@935: fp@935: /*****************************************************************************/ fp@935: fp@935: typedef struct { fp@935: // inputs fp@935: uint16_t slave_position; fp@978: uint32_t sync_index; fp@978: uint32_t pdo_pos; fp@978: uint32_t entry_pos; fp@935: fp@935: // outputs fp@935: uint16_t index; fp@935: uint8_t subindex; fp@935: uint8_t bit_length; fp@990: int8_t name[EC_IOCTL_STRING_SIZE]; fp@1079: } ec_ioctl_slave_sync_pdo_entry_t; fp@922: fp@922: /*****************************************************************************/ fp@922: fp@948: typedef struct { fp@948: // inputs fp@978: uint32_t index; fp@978: fp@978: // outputs fp@978: uint32_t data_size; fp@948: uint32_t logical_base_address; fp@948: uint16_t working_counter; fp@948: uint16_t expected_working_counter; fp@978: uint32_t fmmu_count; fp@948: } ec_ioctl_domain_t; fp@948: fp@948: /*****************************************************************************/ fp@948: fp@949: typedef struct { fp@949: // inputs fp@978: uint32_t domain_index; fp@978: uint32_t fmmu_index; fp@950: fp@950: // outputs fp@950: uint16_t slave_config_alias; fp@950: uint16_t slave_config_position; fp@1055: uint8_t sync_index; fp@1055: ec_direction_t dir; fp@950: uint32_t logical_address; fp@978: uint32_t data_size; fp@950: } ec_ioctl_domain_fmmu_t; fp@950: fp@950: /*****************************************************************************/ fp@950: fp@950: typedef struct { fp@950: // inputs fp@978: uint32_t domain_index; fp@978: uint32_t data_size; fp@990: uint8_t *target; fp@1079: } ec_ioctl_domain_data_t; fp@949: fp@949: /*****************************************************************************/ fp@949: fp@960: typedef struct { fp@960: // inputs fp@960: uint16_t slave_position; fp@1148: uint8_t al_state; fp@960: } ec_ioctl_slave_state_t; fp@960: fp@960: /*****************************************************************************/ fp@960: fp@965: typedef struct { fp@965: // inputs fp@965: uint16_t slave_position; fp@965: uint16_t sdo_position; fp@965: fp@965: // outputs fp@965: uint16_t sdo_index; fp@965: uint8_t max_subindex; fp@990: int8_t name[EC_IOCTL_STRING_SIZE]; fp@1079: } ec_ioctl_slave_sdo_t; fp@965: fp@965: /*****************************************************************************/ fp@965: fp@965: typedef struct { fp@965: // inputs fp@965: uint16_t slave_position; fp@968: int sdo_spec; // positive: index, negative: list position fp@965: uint8_t sdo_entry_subindex; fp@965: fp@965: // outputs fp@965: uint16_t data_type; fp@965: uint16_t bit_length; fp@990: int8_t description[EC_IOCTL_STRING_SIZE]; fp@1079: } ec_ioctl_slave_sdo_entry_t; fp@965: fp@965: /*****************************************************************************/ fp@965: fp@968: typedef struct { fp@968: // inputs fp@968: uint16_t slave_position; fp@968: uint16_t sdo_index; fp@968: uint8_t sdo_entry_subindex; fp@978: uint32_t target_size; fp@968: uint8_t *target; fp@968: fp@968: // outputs fp@978: uint32_t data_size; fp@1037: uint32_t abort_code; fp@1079: } ec_ioctl_slave_sdo_upload_t; fp@968: fp@968: /*****************************************************************************/ fp@968: fp@974: typedef struct { fp@974: // inputs fp@974: uint16_t slave_position; fp@974: uint16_t sdo_index; fp@974: uint8_t sdo_entry_subindex; fp@978: uint32_t data_size; fp@974: uint8_t *data; fp@1037: fp@1037: // outputs fp@1037: uint32_t abort_code; fp@1079: } ec_ioctl_slave_sdo_download_t; fp@974: fp@974: /*****************************************************************************/ fp@974: fp@978: typedef struct { fp@978: // inputs fp@978: uint16_t slave_position; fp@978: uint16_t offset; fp@978: uint32_t nwords; fp@978: uint16_t *words; fp@1079: } ec_ioctl_slave_sii_t; fp@978: fp@978: /*****************************************************************************/ fp@978: fp@990: typedef struct { fp@990: // inputs fp@1200: uint16_t slave_position; fp@1200: uint16_t offset; fp@1200: uint16_t length; fp@1200: uint8_t *data; fp@1200: } ec_ioctl_slave_phy_t; fp@1200: fp@1200: /*****************************************************************************/ fp@1200: fp@1200: typedef struct { fp@1200: // inputs fp@1335: uint16_t slave_position; fp@1335: uint16_t offset; fp@1335: uint32_t buffer_size; fp@1335: uint8_t *buffer; fp@1335: fp@1335: // outputs fp@1335: uint32_t data_size; fp@1336: uint32_t result; fp@1336: uint32_t error_code; fp@1335: char file_name[32]; fp@1335: } ec_ioctl_slave_foe_t; fp@1335: fp@1335: /*****************************************************************************/ fp@1335: fp@1335: typedef struct { fp@1335: // inputs fp@990: uint32_t config_index; fp@990: fp@990: // outputs fp@990: uint16_t alias; fp@990: uint16_t position; fp@990: uint32_t vendor_id; fp@990: uint32_t product_code; fp@1055: struct { fp@1055: ec_direction_t dir; fp@1055: uint32_t pdo_count; fp@1082: } syncs[EC_MAX_SYNC_MANAGERS]; fp@990: uint32_t sdo_count; fp@1147: int32_t slave_position; fp@990: } ec_ioctl_config_t; fp@990: fp@990: /*****************************************************************************/ fp@990: fp@990: typedef struct { fp@990: // inputs fp@990: uint32_t config_index; fp@1055: uint8_t sync_index; fp@1055: uint16_t pdo_pos; fp@990: fp@990: // outputs fp@990: uint16_t index; fp@990: uint8_t entry_count; fp@990: int8_t name[EC_IOCTL_STRING_SIZE]; fp@990: } ec_ioctl_config_pdo_t; fp@990: fp@990: /*****************************************************************************/ fp@990: fp@990: typedef struct { fp@990: // inputs fp@990: uint32_t config_index; fp@1055: uint8_t sync_index; fp@1055: uint16_t pdo_pos; fp@1055: uint8_t entry_pos; fp@990: fp@990: // outputs fp@990: uint16_t index; fp@990: uint8_t subindex; fp@990: uint8_t bit_length; fp@990: int8_t name[EC_IOCTL_STRING_SIZE]; fp@990: } ec_ioctl_config_pdo_entry_t; fp@990: fp@990: /*****************************************************************************/ fp@990: fp@990: typedef struct { fp@990: // inputs fp@990: uint32_t config_index; fp@990: uint32_t sdo_pos; fp@990: fp@990: // outputs fp@990: uint16_t index; fp@990: uint8_t subindex; fp@990: uint32_t size; fp@990: uint8_t data[4]; fp@990: } ec_ioctl_config_sdo_t; fp@990: fp@990: /*****************************************************************************/ fp@990: fp@1255: typedef struct { fp@1255: // inputs fp@1255: uint32_t config_index; fp@1255: uint16_t pdo_index; fp@1255: uint16_t entry_index; fp@1255: uint8_t entry_subindex; fp@1255: uint8_t entry_bit_length; fp@1255: } ec_ioctl_add_pdo_entry_t; fp@1255: fp@1255: /*****************************************************************************/ fp@1255: fp@1255: typedef struct { fp@1255: // inputs fp@1255: uint32_t config_index; fp@1255: uint16_t entry_index; fp@1255: uint8_t entry_subindex; fp@1255: uint32_t domain_index; fp@1255: fp@1255: // outputs fp@1255: unsigned int bit_position; fp@1255: } ec_ioctl_reg_pdo_entry_t; fp@1255: fp@1255: /*****************************************************************************/ fp@1255: fp@1255: typedef struct { fp@1255: // inputs fp@1255: uint32_t config_index; fp@1255: uint16_t index; fp@1255: uint8_t subindex; fp@1255: const uint8_t *data; fp@1255: size_t size; fp@1255: } ec_ioctl_sc_sdo_t; fp@1255: fp@1255: /*****************************************************************************/ fp@1255: fp@1259: typedef struct { fp@1259: // inputs fp@1259: uint32_t config_index; fp@1259: fp@1259: // outputs fp@1259: ec_slave_config_state_t *state; fp@1259: } ec_ioctl_sc_state_t; fp@1259: fp@1259: /*****************************************************************************/ fp@1259: fp@1259: typedef struct { fp@1259: // inputs fp@1259: uint32_t domain_index; fp@1259: fp@1259: // outputs fp@1259: ec_domain_state_t *state; fp@1259: } ec_ioctl_domain_state_t; fp@1259: fp@1259: /*****************************************************************************/ fp@1259: fp@1264: typedef struct { fp@1264: // inputs fp@1264: uint32_t config_index; fp@1264: fp@1264: // inputs/outputs fp@1352: uint32_t request_index; fp@1352: uint16_t sdo_index; fp@1352: uint8_t sdo_subindex; fp@1352: size_t size; fp@1352: uint8_t *data; fp@1352: uint32_t timeout; fp@1352: ec_request_state_t state; fp@1352: } ec_ioctl_sdo_request_t; fp@1352: fp@1352: /*****************************************************************************/ fp@1352: fp@1352: typedef struct { fp@1352: // inputs fp@1352: uint32_t config_index; fp@1352: fp@1352: // inputs/outputs fp@1264: uint32_t voe_index; fp@1264: uint32_t *vendor_id; fp@1264: uint16_t *vendor_type; fp@1264: size_t size; fp@1264: uint8_t *data; fp@1264: ec_request_state_t state; fp@1264: } ec_ioctl_voe_t; fp@1264: fp@1264: /*****************************************************************************/ fp@1264: fp@1082: /** \endcond */ fp@1082: fp@922: #endif