47 #include <linux/wait.h> |
47 #include <linux/wait.h> |
48 #include <asm/atomic.h> |
48 #include <asm/atomic.h> |
49 #include <asm/semaphore.h> |
49 #include <asm/semaphore.h> |
50 |
50 |
51 #include "device.h" |
51 #include "device.h" |
52 #include "device_id.h" |
|
53 #include "domain.h" |
52 #include "domain.h" |
54 #include "fsm_master.h" |
53 #include "fsm_master.h" |
55 |
54 |
56 /*****************************************************************************/ |
55 /*****************************************************************************/ |
57 |
56 |
92 Manages slaves, domains and IO. |
91 Manages slaves, domains and IO. |
93 */ |
92 */ |
94 |
93 |
95 struct ec_master |
94 struct ec_master |
96 { |
95 { |
97 struct list_head list; /**< list item for module's master list */ |
|
98 atomic_t available; /**< zero, if the master is reserved for RT */ |
96 atomic_t available; /**< zero, if the master is reserved for RT */ |
99 unsigned int index; /**< master index */ |
97 unsigned int index; /**< master index */ |
100 |
98 |
101 struct kobject kobj; /**< kobject */ |
99 struct kobject kobj; /**< kobject */ |
102 |
100 |
103 ec_device_t main_device; /**< EtherCAT device */ |
101 ec_device_t main_device; /**< EtherCAT device */ |
104 const ec_device_id_t *main_device_id; /**< ID of main device */ |
102 const uint8_t *main_mac; /**< MAC address of main device */ |
105 ec_device_t backup_device; /**< EtherCAT backup device */ |
103 ec_device_t backup_device; /**< EtherCAT backup device */ |
106 const ec_device_id_t *backup_device_id; /**< ID of backup device */ |
104 const uint8_t *backup_mac; /**< MAC address of backup device */ |
107 struct semaphore device_sem; /**< device semaphore */ |
105 struct semaphore device_sem; /**< device semaphore */ |
108 |
106 |
109 ec_fsm_master_t fsm; /**< master state machine */ |
107 ec_fsm_master_t fsm; /**< master state machine */ |
110 ec_datagram_t fsm_datagram; /**< datagram used for state machines */ |
108 ec_datagram_t fsm_datagram; /**< datagram used for state machines */ |
111 ec_master_mode_t mode; /**< master mode */ |
109 ec_master_mode_t mode; /**< master mode */ |
162 |
160 |
163 /*****************************************************************************/ |
161 /*****************************************************************************/ |
164 |
162 |
165 // master creation/deletion |
163 // master creation/deletion |
166 int ec_master_init(ec_master_t *, struct kobject *, unsigned int, |
164 int ec_master_init(ec_master_t *, struct kobject *, unsigned int, |
167 const ec_device_id_t *, const ec_device_id_t *, unsigned int); |
165 const uint8_t *, const uint8_t *); |
168 void ec_master_destroy(ec_master_t *); |
166 void ec_master_clear(ec_master_t *); |
169 |
167 |
170 // mode transitions |
168 // mode transitions |
171 int ec_master_enter_idle_mode(ec_master_t *); |
169 int ec_master_enter_idle_mode(ec_master_t *); |
172 void ec_master_leave_idle_mode(ec_master_t *); |
170 void ec_master_leave_idle_mode(ec_master_t *); |
173 int ec_master_enter_operation_mode(ec_master_t *); |
171 int ec_master_enter_operation_mode(ec_master_t *); |