Changes in uspace/drv/uhci-hcd/batch.c [4abc304:30a4301] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/batch.c
r4abc304 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; 134 133 135 134 queue_head_element_td(instance->qh, addr_to_phys(instance->tds)); 136 usb_log_debug("Batch(%p) %d:%d memory structures ready.\n",137 instance, target.address, target.endpoint);138 135 return instance; 139 136 } … … 142 139 { 143 140 assert(instance); 144 usb_log_debug 2("Batch(%p) checking %d packet(s)for completion.\n",141 usb_log_debug("Checking(%p) %d packet for completion.\n", 145 142 instance, instance->packets); 146 143 instance->transfered_size = 0; … … 154 151 if (i > 0) 155 152 instance->transfered_size -= instance->setup_size; 156 usb_log_debug("Batch(%p) found error TD(%d):%x.\n",157 instance, i, instance->tds[i].status);158 153 return true; 159 154 } … … 161 156 transfer_descriptor_actual_size(&instance->tds[i]); 162 157 } 158 /* This is just an ugly trick to support the old API */ 163 159 instance->transfered_size -= instance->setup_size; 164 160 return true; … … 172 168 memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size); 173 169 174 const bool low_speed = instance->speed == USB_SPEED_LOW;175 170 int toggle = 0; 176 171 /* setup stage */ 177 172 transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT, 178 instance->setup_size, toggle, false, low_speed, 179 instance->target, USB_PID_SETUP, instance->setup_buffer, 180 &instance->tds[1]); 173 instance->setup_size, toggle, false, instance->target, 174 USB_PID_SETUP, instance->setup_buffer, &instance->tds[1]); 181 175 182 176 /* data stage */ … … 188 182 189 183 transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT, 190 instance->max_packet_size, toggle++, false, low_speed,191 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]); 192 186 } 193 187 … … 195 189 i = instance->packets - 1; 196 190 transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT, 197 0, 1, false, low_speed,instance->target, USB_PID_IN, NULL, NULL);191 0, 1, false, instance->target, USB_PID_IN, NULL, NULL); 198 192 199 193 instance->tds[i].status |= TD_STATUS_COMPLETE_INTERRUPT_FLAG; 200 usb_log_debug2("Control write last TD status: %x.\n",201 instance->tds[i].status);202 194 203 195 instance->next_step = batch_call_out_and_dispose; 204 usb_log_debug("Batch(%p) CONTROL WRITE initialized.\n", instance);205 196 batch_schedule(instance); 206 197 } … … 210 201 assert(instance); 211 202 212 const bool low_speed = instance->speed == USB_SPEED_LOW;213 203 int toggle = 0; 214 204 /* setup stage */ 215 205 transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT, 216 instance->setup_size, toggle, false, low_speed,instance->target,206 instance->setup_size, toggle, false, instance->target, 217 207 USB_PID_SETUP, instance->setup_buffer, &instance->tds[1]); 218 208 … … 225 215 226 216 transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT, 227 instance->max_packet_size, toggle, false, low_speed,228 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]); 229 219 } 230 220 … … 232 222 i = instance->packets - 1; 233 223 transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT, 234 0, 1, false, low_speed,instance->target, USB_PID_OUT, NULL, NULL);224 0, 1, false, instance->target, USB_PID_OUT, NULL, NULL); 235 225 236 226 instance->tds[i].status |= TD_STATUS_COMPLETE_INTERRUPT_FLAG; 237 usb_log_debug2("Control read last TD status: %x.\n",238 instance->tds[i].status);239 227 240 228 instance->next_step = batch_call_in_and_dispose; 241 usb_log_debug("Batch(%p) CONTROL READ initialized.\n", instance);242 229 batch_schedule(instance); 243 230 } … … 247 234 assert(instance); 248 235 249 const bool low_speed = instance->speed == USB_SPEED_LOW;250 236 int toggle = 1; 251 237 size_t i = 0; … … 258 244 259 245 transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT, 260 instance->max_packet_size, toggle, false, low_speed,261 instance->target,USB_PID_IN, data, next);246 instance->max_packet_size, toggle, false, instance->target, 247 USB_PID_IN, data, next); 262 248 } 263 249 … … 265 251 266 252 instance->next_step = batch_call_in_and_dispose; 267 usb_log_debug("Batch(%p) INTERRUPT IN initialized.\n", instance);268 253 batch_schedule(instance); 269 254 } … … 275 260 memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size); 276 261 277 const bool low_speed = instance->speed == USB_SPEED_LOW;278 262 int toggle = 1; 279 263 size_t i = 0; … … 286 270 287 271 transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT, 288 instance->max_packet_size, toggle++, false, low_speed,289 instance->target,USB_PID_OUT, data, next);272 instance->max_packet_size, toggle++, false, instance->target, 273 USB_PID_OUT, data, next); 290 274 } 291 275 … … 293 277 294 278 instance->next_step = batch_call_out_and_dispose; 295 usb_log_debug("Batch(%p) INTERRUPT OUT initialized.\n", instance);296 279 batch_schedule(instance); 297 280 } … … 305 288 306 289 int err = instance->error; 307 usb_log_debug("Batch(%p) callback IN(type:%d): %s(%d), %zu.\n", 308 instance, instance->transfer_type, str_error(err), err, 309 instance->transfered_size); 310 311 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, 312 294 err, instance->transfered_size, 313 295 instance->arg); … … 320 302 321 303 int err = instance->error; 322 usb_log_debug("Batch(%p) callback OUT(type:%d): %s(%d).\n", 323 instance, instance->transfer_type, str_error(err), err); 324 instance->callback_out(instance->fun, 304 usb_log_info("Callback OUT(%d): %d.\n", instance->transfer_type, err); 305 instance->callback_out(instance->dev, 325 306 err, instance->arg); 326 307 } … … 330 311 assert(instance); 331 312 batch_call_in(instance); 332 usb_log_debug(" Batch(%p) disposing.\n", instance);313 usb_log_debug("Disposing batch: %p.\n", instance); 333 314 free32(instance->tds); 334 315 free32(instance->qh); … … 342 323 assert(instance); 343 324 batch_call_out(instance); 344 usb_log_debug(" Batch(%p) disposing.\n", instance);325 usb_log_debug("Disposing batch: %p.\n", instance); 345 326 free32(instance->tds); 346 327 free32(instance->qh); … … 353 334 { 354 335 assert(instance); 355 uhci_t *hc = fun_to_uhci(instance->fun);336 uhci_t *hc = dev_to_uhci(instance->dev); 356 337 assert(hc); 357 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); 358 388 } 359 389 /**
Note:
See TracChangeset
for help on using the changeset viewer.