equal
deleted
inserted
replaced
52 void ec_domain_clear_data(ec_domain_t *); |
52 void ec_domain_clear_data(ec_domain_t *); |
53 ssize_t ec_show_domain_attribute(struct kobject *, struct attribute *, char *); |
53 ssize_t ec_show_domain_attribute(struct kobject *, struct attribute *, char *); |
54 |
54 |
55 /*****************************************************************************/ |
55 /*****************************************************************************/ |
56 |
56 |
|
57 /** Working counter increment values for logical read/write operations. |
|
58 * |
|
59 * \attention This is indexed by ec_direction_t. |
|
60 */ |
|
61 static const unsigned int working_counter_increment[] = {2, 1}; |
|
62 |
|
63 /*****************************************************************************/ |
|
64 |
57 /** \cond */ |
65 /** \cond */ |
58 |
66 |
59 EC_SYSFS_READ_ATTR(image_size); |
67 EC_SYSFS_READ_ATTR(image_size); |
60 |
68 |
61 static struct attribute *def_attrs[] = { |
69 static struct attribute *def_attrs[] = { |
89 ) |
97 ) |
90 { |
98 { |
91 domain->master = master; |
99 domain->master = master; |
92 domain->index = index; |
100 domain->index = index; |
93 domain->data_size = 0; |
101 domain->data_size = 0; |
|
102 domain->expected_working_counter = 0; |
94 domain->data = NULL; |
103 domain->data = NULL; |
95 domain->data_origin = EC_ORIG_INTERNAL; |
104 domain->data_origin = EC_ORIG_INTERNAL; |
96 domain->logical_base_address = 0L; |
105 domain->logical_base_address = 0L; |
97 domain->working_counter = 0xFFFFFFFF; |
106 domain->working_counter = 0xFFFFFFFF; |
|
107 domain->state = 0; |
|
108 domain->working_counter_changes = 0; |
98 domain->notify_jiffies = 0; |
109 domain->notify_jiffies = 0; |
99 domain->working_counter_changes = 0; |
|
100 |
110 |
101 INIT_LIST_HEAD(&domain->datagrams); |
111 INIT_LIST_HEAD(&domain->datagrams); |
102 |
112 |
103 // init kobject and add it to the hierarchy |
113 // init kobject and add it to the hierarchy |
104 memset(&domain->kobj, 0x00, sizeof(struct kobject)); |
114 memset(&domain->kobj, 0x00, sizeof(struct kobject)); |
119 return 0; |
129 return 0; |
120 } |
130 } |
121 |
131 |
122 /*****************************************************************************/ |
132 /*****************************************************************************/ |
123 |
133 |
124 /** |
134 /** Domain destructor. |
125 Domain destructor. |
135 * |
126 Clears and frees a domain object. |
136 * Clears and frees a domain object. |
127 */ |
137 */ |
128 |
|
129 void ec_domain_destroy(ec_domain_t *domain /**< EtherCAT domain */) |
138 void ec_domain_destroy(ec_domain_t *domain /**< EtherCAT domain */) |
130 { |
139 { |
131 ec_datagram_t *datagram; |
140 ec_datagram_t *datagram; |
132 |
141 |
133 // dequeue datagrams |
142 // dequeue datagrams |
141 kobject_put(&domain->kobj); |
150 kobject_put(&domain->kobj); |
142 } |
151 } |
143 |
152 |
144 /*****************************************************************************/ |
153 /*****************************************************************************/ |
145 |
154 |
146 /** |
155 /** Clear and free domain. |
147 Clear and free domain. |
156 * |
148 This method is called by the kobject, |
157 * This method is called by the kobject, once there are no more references |
149 once there are no more references to it. |
158 * to it. |
150 */ |
159 */ |
151 |
|
152 void ec_domain_clear(struct kobject *kobj /**< kobject of the domain */) |
160 void ec_domain_clear(struct kobject *kobj /**< kobject of the domain */) |
153 { |
161 { |
154 ec_domain_t *domain; |
162 ec_domain_t *domain; |
155 ec_datagram_t *datagram, *next; |
163 ec_datagram_t *datagram, *next; |
156 |
164 |
176 { |
184 { |
177 if (domain->data_origin == EC_ORIG_INTERNAL && domain->data) |
185 if (domain->data_origin == EC_ORIG_INTERNAL && domain->data) |
178 kfree(domain->data); |
186 kfree(domain->data); |
179 domain->data = NULL; |
187 domain->data = NULL; |
180 domain->data_origin = EC_ORIG_INTERNAL; |
188 domain->data_origin = EC_ORIG_INTERNAL; |
|
189 } |
|
190 |
|
191 /*****************************************************************************/ |
|
192 |
|
193 /** Adds an FMMU configuration to the domain. |
|
194 */ |
|
195 void ec_domain_add_fmmu_config( |
|
196 ec_domain_t *domain, /**< EtherCAT domain. */ |
|
197 ec_fmmu_config_t *fmmu /**< FMMU configuration. */ |
|
198 ) |
|
199 { |
|
200 fmmu->domain = domain; |
|
201 |
|
202 domain->data_size += fmmu->data_size; |
|
203 domain->expected_working_counter += working_counter_increment[fmmu->dir]; |
181 } |
204 } |
182 |
205 |
183 /*****************************************************************************/ |
206 /*****************************************************************************/ |
184 |
207 |
185 /** Allocates a domain datagram and appends it to the list. |
208 /** Allocates a domain datagram and appends it to the list. |
447 /*****************************************************************************/ |
470 /*****************************************************************************/ |
448 |
471 |
449 void ecrt_domain_state(const ec_domain_t *domain, ec_domain_state_t *state) |
472 void ecrt_domain_state(const ec_domain_t *domain, ec_domain_state_t *state) |
450 { |
473 { |
451 state->working_counter = domain->working_counter; |
474 state->working_counter = domain->working_counter; |
452 state->wc_state = EC_WC_ZERO; // FIXME |
475 |
|
476 if (domain->working_counter) { |
|
477 if (domain->working_counter == domain->expected_working_counter) { |
|
478 state->wc_state = EC_WC_COMPLETE; |
|
479 } else { |
|
480 state->wc_state = EC_WC_INCOMPLETE; |
|
481 } |
|
482 } else { |
|
483 state->wc_state = EC_WC_ZERO; |
|
484 } |
453 } |
485 } |
454 |
486 |
455 /*****************************************************************************/ |
487 /*****************************************************************************/ |
456 |
488 |
457 /** \cond */ |
489 /** \cond */ |