Changes in uspace/drv/uhci-hcd/batch.c [30a4301:48563a3] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/batch.c
r30a4301 r48563a3 33 33 */ 34 34 #include <errno.h> 35 #include <str_error.h> 35 36 36 37 #include <usb/debug.h> … … 51 52 52 53 53 batch_t * batch_get(d evice_t *dev, usb_target_t target,54 batch_t * batch_get(ddf_fun_t *fun, usb_target_t target, 54 55 usb_transfer_type_t transfer_type, size_t max_packet_size, 55 dev_speed_t speed, char *buffer, size_t size,56 usb_speed_t speed, char *buffer, size_t size, 56 57 char* setup_buffer, size_t setup_size, 57 58 usbhc_iface_transfer_in_callback_t func_in, … … 128 129 instance->buffer_size = size; 129 130 instance->setup_size = setup_size; 130 instance-> dev = dev;131 instance->fun = fun; 131 132 instance->arg = arg; 132 133 instance->speed = speed; … … 139 140 { 140 141 assert(instance); 141 usb_log_debug ("Checking(%p) %d packetfor completion.\n",142 usb_log_debug2("Batch(%p) checking %d packet(s) for completion.\n", 142 143 instance, instance->packets); 143 144 instance->transfered_size = 0; … … 151 152 if (i > 0) 152 153 instance->transfered_size -= instance->setup_size; 154 usb_log_debug("Batch(%p) found error TD(%d):%x.\n", 155 instance, i, instance->tds[i].status); 153 156 return true; 154 157 } … … 156 159 transfer_descriptor_actual_size(&instance->tds[i]); 157 160 } 158 /* This is just an ugly trick to support the old API */159 161 instance->transfered_size -= instance->setup_size; 160 162 return true; … … 168 170 memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size); 169 171 172 const bool low_speed = instance->speed == USB_SPEED_LOW; 170 173 int toggle = 0; 171 174 /* setup stage */ 172 175 transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT, 173 instance->setup_size, toggle, false, instance->target, 174 USB_PID_SETUP, instance->setup_buffer, &instance->tds[1]); 176 instance->setup_size, toggle, false, low_speed, 177 instance->target, USB_PID_SETUP, instance->setup_buffer, 178 &instance->tds[1]); 175 179 176 180 /* data stage */ … … 182 186 183 187 transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT, 184 instance->max_packet_size, toggle++, false, instance->target,185 USB_PID_OUT, data, &instance->tds[i + 1]);188 instance->max_packet_size, toggle++, false, low_speed, 189 instance->target, USB_PID_OUT, data, &instance->tds[i + 1]); 186 190 } 187 191 … … 189 193 i = instance->packets - 1; 190 194 transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT, 191 0, 1, false, instance->target, USB_PID_IN, NULL, NULL);195 0, 1, false, low_speed, instance->target, USB_PID_IN, NULL, NULL); 192 196 193 197 instance->tds[i].status |= TD_STATUS_COMPLETE_INTERRUPT_FLAG; 198 usb_log_debug("Control write last TD status: %x.\n", 199 instance->tds[i].status); 194 200 195 201 instance->next_step = batch_call_out_and_dispose; … … 201 207 assert(instance); 202 208 209 const bool low_speed = instance->speed == USB_SPEED_LOW; 203 210 int toggle = 0; 204 211 /* setup stage */ 205 212 transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT, 206 instance->setup_size, toggle, false, instance->target,213 instance->setup_size, toggle, false, low_speed, instance->target, 207 214 USB_PID_SETUP, instance->setup_buffer, &instance->tds[1]); 208 215 … … 215 222 216 223 transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT, 217 instance->max_packet_size, toggle, false, instance->target,218 224 instance->max_packet_size, toggle, false, low_speed, 225 instance->target, USB_PID_IN, data, &instance->tds[i + 1]); 219 226 } 220 227 … … 222 229 i = instance->packets - 1; 223 230 transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT, 224 0, 1, false, instance->target, USB_PID_OUT, NULL, NULL);231 0, 1, false, low_speed, instance->target, USB_PID_OUT, NULL, NULL); 225 232 226 233 instance->tds[i].status |= TD_STATUS_COMPLETE_INTERRUPT_FLAG; 234 usb_log_debug("Control read last TD status: %x.\n", 235 instance->tds[i].status); 227 236 228 237 instance->next_step = batch_call_in_and_dispose; … … 234 243 assert(instance); 235 244 245 const bool low_speed = instance->speed == USB_SPEED_LOW; 236 246 int toggle = 1; 237 247 size_t i = 0; … … 244 254 245 255 transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT, 246 instance->max_packet_size, toggle, false, instance->target,247 USB_PID_IN, data, next);256 instance->max_packet_size, toggle, false, low_speed, 257 instance->target, USB_PID_IN, data, next); 248 258 } 249 259 … … 260 270 memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size); 261 271 272 const bool low_speed = instance->speed == USB_SPEED_LOW; 262 273 int toggle = 1; 263 274 size_t i = 0; … … 270 281 271 282 transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT, 272 instance->max_packet_size, toggle++, false, instance->target,273 USB_PID_OUT, data, next);283 instance->max_packet_size, toggle++, false, low_speed, 284 instance->target, USB_PID_OUT, data, next); 274 285 } 275 286 … … 288 299 289 300 int err = instance->error; 290 usb_log_info("Callback IN(%d): %d, %zu.\n", instance->transfer_type, 291 err, instance->transfered_size); 292 293 instance->callback_in(instance->dev, 301 usb_log_info("Batch(%p) callback IN(type:%d): %s(%d), %zu.\n", 302 instance, instance->transfer_type, str_error(err), err, 303 instance->transfered_size); 304 305 instance->callback_in(instance->fun, 294 306 err, instance->transfered_size, 295 307 instance->arg); … … 302 314 303 315 int err = instance->error; 304 usb_log_info("Callback OUT(%d): %d.\n", instance->transfer_type, err); 305 instance->callback_out(instance->dev, 316 usb_log_info("Batch(%p) callback OUT(type:%d): %s(%d).\n", 317 instance, instance->transfer_type, str_error(err), err); 318 instance->callback_out(instance->fun, 306 319 err, instance->arg); 307 320 } … … 311 324 assert(instance); 312 325 batch_call_in(instance); 313 usb_log_debug(" Disposing batch: %p.\n", instance);326 usb_log_debug("Batch(%p) disposing.\n", instance); 314 327 free32(instance->tds); 315 328 free32(instance->qh); … … 323 336 assert(instance); 324 337 batch_call_out(instance); 325 usb_log_debug(" Disposing batch: %p.\n", instance);338 usb_log_debug("Batch(%p) disposing.\n", instance); 326 339 free32(instance->tds); 327 340 free32(instance->qh); … … 334 347 { 335 348 assert(instance); 336 uhci_t *hc = dev_to_uhci(instance->dev);349 uhci_t *hc = fun_to_uhci(instance->fun); 337 350 assert(hc); 338 351 return uhci_schedule(hc, instance); 339 }340 /*----------------------------------------------------------------------------*/341 /* DEPRECATED FUNCTIONS NEEDED BY THE OLD API */342 void batch_control_setup_old(batch_t *instance)343 {344 assert(instance);345 instance->packets = 1;346 347 /* setup stage */348 transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT,349 instance->setup_size, 0, false, instance->target,350 USB_PID_SETUP, instance->setup_buffer, NULL);351 352 instance->next_step = batch_call_out_and_dispose;353 batch_schedule(instance);354 }355 /*----------------------------------------------------------------------------*/356 void batch_control_write_data_old(batch_t *instance)357 {358 assert(instance);359 instance->packets -= 2;360 batch_interrupt_out(instance);361 }362 /*----------------------------------------------------------------------------*/363 void batch_control_read_data_old(batch_t *instance)364 {365 assert(instance);366 instance->packets -= 2;367 batch_interrupt_in(instance);368 }369 /*----------------------------------------------------------------------------*/370 void batch_control_write_status_old(batch_t *instance)371 {372 assert(instance);373 instance->packets = 1;374 transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT,375 0, 1, false, instance->target, USB_PID_IN, NULL, NULL);376 instance->next_step = batch_call_in_and_dispose;377 batch_schedule(instance);378 }379 /*----------------------------------------------------------------------------*/380 void batch_control_read_status_old(batch_t *instance)381 {382 assert(instance);383 instance->packets = 1;384 transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT,385 0, 1, false, instance->target, USB_PID_OUT, NULL, NULL);386 instance->next_step = batch_call_out_and_dispose;387 batch_schedule(instance);388 352 } 389 353 /**
Note:
See TracChangeset
for help on using the changeset viewer.