Changes in uspace/drv/uhci-hcd/batch.c [48563a3:30a4301] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/batch.c
r48563a3 r30a4301 33 33 */ 34 34 #include <errno.h> 35 #include <str_error.h>36 35 37 36 #include <usb/debug.h> … … 52 51 53 52 54 batch_t * batch_get(d df_fun_t *fun, usb_target_t target,53 batch_t * batch_get(device_t *dev, usb_target_t target, 55 54 usb_transfer_type_t transfer_type, size_t max_packet_size, 56 usb_speed_t speed, char *buffer, size_t size,55 dev_speed_t speed, char *buffer, size_t size, 57 56 char* setup_buffer, size_t setup_size, 58 57 usbhc_iface_transfer_in_callback_t func_in, … … 129 128 instance->buffer_size = size; 130 129 instance->setup_size = setup_size; 131 instance-> fun = fun;130 instance->dev = dev; 132 131 instance->arg = arg; 133 132 instance->speed = speed; … … 140 139 { 141 140 assert(instance); 142 usb_log_debug 2("Batch(%p) checking %d packet(s)for completion.\n",141 usb_log_debug("Checking(%p) %d packet for completion.\n", 143 142 instance, instance->packets); 144 143 instance->transfered_size = 0; … … 152 151 if (i > 0) 153 152 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);156 153 return true; 157 154 } … … 159 156 transfer_descriptor_actual_size(&instance->tds[i]); 160 157 } 158 /* This is just an ugly trick to support the old API */ 161 159 instance->transfered_size -= instance->setup_size; 162 160 return true; … … 170 168 memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size); 171 169 172 const bool low_speed = instance->speed == USB_SPEED_LOW;173 170 int toggle = 0; 174 171 /* setup stage */ 175 172 transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT, 176 instance->setup_size, toggle, false, low_speed, 177 instance->target, USB_PID_SETUP, instance->setup_buffer, 178 &instance->tds[1]); 173 instance->setup_size, toggle, false, instance->target, 174 USB_PID_SETUP, instance->setup_buffer, &instance->tds[1]); 179 175 180 176 /* data stage */ … … 186 182 187 183 transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT, 188 instance->max_packet_size, toggle++, false, low_speed,189 instance->target,USB_PID_OUT, data, &instance->tds[i + 1]);184 instance->max_packet_size, toggle++, false, instance->target, 185 USB_PID_OUT, data, &instance->tds[i + 1]); 190 186 } 191 187 … … 193 189 i = instance->packets - 1; 194 190 transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT, 195 0, 1, false, low_speed,instance->target, USB_PID_IN, NULL, NULL);191 0, 1, false, instance->target, USB_PID_IN, NULL, NULL); 196 192 197 193 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);200 194 201 195 instance->next_step = batch_call_out_and_dispose; … … 207 201 assert(instance); 208 202 209 const bool low_speed = instance->speed == USB_SPEED_LOW;210 203 int toggle = 0; 211 204 /* setup stage */ 212 205 transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT, 213 instance->setup_size, toggle, false, low_speed,instance->target,206 instance->setup_size, toggle, false, instance->target, 214 207 USB_PID_SETUP, instance->setup_buffer, &instance->tds[1]); 215 208 … … 222 215 223 216 transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT, 224 instance->max_packet_size, toggle, false, low_speed,225 instance->target,USB_PID_IN, data, &instance->tds[i + 1]);217 instance->max_packet_size, toggle, false, instance->target, 218 USB_PID_IN, data, &instance->tds[i + 1]); 226 219 } 227 220 … … 229 222 i = instance->packets - 1; 230 223 transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT, 231 0, 1, false, low_speed,instance->target, USB_PID_OUT, NULL, NULL);224 0, 1, false, instance->target, USB_PID_OUT, NULL, NULL); 232 225 233 226 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);236 227 237 228 instance->next_step = batch_call_in_and_dispose; … … 243 234 assert(instance); 244 235 245 const bool low_speed = instance->speed == USB_SPEED_LOW;246 236 int toggle = 1; 247 237 size_t i = 0; … … 254 244 255 245 transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT, 256 instance->max_packet_size, toggle, false, low_speed,257 instance->target,USB_PID_IN, data, next);246 instance->max_packet_size, toggle, false, instance->target, 247 USB_PID_IN, data, next); 258 248 } 259 249 … … 270 260 memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size); 271 261 272 const bool low_speed = instance->speed == USB_SPEED_LOW;273 262 int toggle = 1; 274 263 size_t i = 0; … … 281 270 282 271 transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT, 283 instance->max_packet_size, toggle++, false, low_speed,284 instance->target,USB_PID_OUT, data, next);272 instance->max_packet_size, toggle++, false, instance->target, 273 USB_PID_OUT, data, next); 285 274 } 286 275 … … 299 288 300 289 int err = instance->error; 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, 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, 306 294 err, instance->transfered_size, 307 295 instance->arg); … … 314 302 315 303 int err = instance->error; 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, 304 usb_log_info("Callback OUT(%d): %d.\n", instance->transfer_type, err); 305 instance->callback_out(instance->dev, 319 306 err, instance->arg); 320 307 } … … 324 311 assert(instance); 325 312 batch_call_in(instance); 326 usb_log_debug(" Batch(%p) disposing.\n", instance);313 usb_log_debug("Disposing batch: %p.\n", instance); 327 314 free32(instance->tds); 328 315 free32(instance->qh); … … 336 323 assert(instance); 337 324 batch_call_out(instance); 338 usb_log_debug(" Batch(%p) disposing.\n", instance);325 usb_log_debug("Disposing batch: %p.\n", instance); 339 326 free32(instance->tds); 340 327 free32(instance->qh); … … 347 334 { 348 335 assert(instance); 349 uhci_t *hc = fun_to_uhci(instance->fun);336 uhci_t *hc = dev_to_uhci(instance->dev); 350 337 assert(hc); 351 338 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); 352 388 } 353 389 /**
Note:
See TracChangeset
for help on using the changeset viewer.