Changes in / [e18e0d6:11dd29b] in mainline
- Location:
- uspace/drv
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/ohci/main.c
re18e0d6 r11dd29b 158 158 if (ret != EOK) { 159 159 usb_log_warning("Failed to enable interrupts: %s.\n", 160 str_error(r et));160 str_error(rc)); 161 161 usb_log_info("HW interrupts not available, " \ 162 162 "falling back to polling.\n"); -
uspace/drv/uhci-hcd/batch.c
re18e0d6 r11dd29b 48 48 qh_t *qh; 49 49 td_t *tds; 50 size_t transfers;50 size_t packets; 51 51 usb_device_keeper_t *manager; 52 52 } uhci_batch_t; … … 64 64 * @param[in] target Device and endpoint target of the transaction. 65 65 * @param[in] transfer_type Interrupt, Control or Bulk. 66 * @param[in] max_packet_size maximum allowed size of data transfers.66 * @param[in] max_packet_size maximum allowed size of data packets. 67 67 * @param[in] speed Speed of the transaction. 68 68 * @param[in] buffer Data source/destination. … … 77 77 * NULL otherwise. 78 78 * 79 * Determines the number of needed transfers (TDs). Prepares a transport buffer79 * Determines the number of needed packets (TDs). Prepares a transport buffer 80 80 * (that is accessible by the hardware). Initializes parameters needed for the 81 81 * transaction and callback. … … 117 117 instance->private_data = data; 118 118 119 data-> transfers = (buffer_size + max_packet_size - 1) / max_packet_size;119 data->packets = (buffer_size + max_packet_size - 1) / max_packet_size; 120 120 if (transfer_type == USB_TRANSFER_CONTROL) { 121 data-> transfers += 2;122 } 123 124 data->tds = malloc32(sizeof(td_t) * data-> transfers);121 data->packets += 2; 122 } 123 124 data->tds = malloc32(sizeof(td_t) * data->packets); 125 125 CHECK_NULL_DISPOSE_RETURN( 126 126 data->tds, "Failed to allocate transfer descriptors.\n"); 127 bzero(data->tds, sizeof(td_t) * data-> transfers);127 bzero(data->tds, sizeof(td_t) * data->packets); 128 128 129 129 data->qh = malloc32(sizeof(qh_t)); … … 166 166 assert(data); 167 167 168 usb_log_debug2("Batch(%p) checking %d transfer(s) for completion.\n",169 instance, data-> transfers);168 usb_log_debug2("Batch(%p) checking %d packet(s) for completion.\n", 169 instance, data->packets); 170 170 instance->transfered_size = 0; 171 171 size_t i = 0; 172 for (;i < data-> transfers; ++i) {172 for (;i < data->packets; ++i) { 173 173 if (td_is_active(&data->tds[i])) { 174 174 return false; … … 298 298 * 299 299 * @param[in] instance Batch structure to use. 300 * @param[in] pid Pid to use for data transfers.300 * @param[in] pid to use for data packets. 301 301 * 302 302 * Packets with alternating toggle bit and supplied pid value. 303 * The last transferis marked with IOC flag.303 * The last packet is marked with IOC flag. 304 304 */ 305 305 void batch_data(usb_transfer_batch_t *instance, usb_packet_id pid) … … 314 314 assert(toggle == 0 || toggle == 1); 315 315 316 size_t transfer= 0;316 size_t packet = 0; 317 317 size_t remain_size = instance->buffer_size; 318 318 while (remain_size > 0) { … … 325 325 remain_size : instance->max_packet_size; 326 326 327 td_t *next_ transfer = (transfer + 1 < data->transfers)328 ? &data->tds[ transfer+ 1] : NULL;329 330 assert( transfer < data->transfers);327 td_t *next_packet = (packet + 1 < data->packets) 328 ? &data->tds[packet + 1] : NULL; 329 330 assert(packet < data->packets); 331 331 assert(packet_size <= remain_size); 332 332 333 333 td_init( 334 &data->tds[ transfer], DEFAULT_ERROR_COUNT, packet_size,334 &data->tds[packet], DEFAULT_ERROR_COUNT, packet_size, 335 335 toggle, false, low_speed, instance->target, pid, trans_data, 336 next_ transfer);336 next_packet); 337 337 338 338 339 339 toggle = 1 - toggle; 340 340 remain_size -= packet_size; 341 ++ transfer;342 } 343 td_set_ioc(&data->tds[ transfer- 1]);341 ++packet; 342 } 343 td_set_ioc(&data->tds[packet - 1]); 344 344 usb_device_keeper_set_toggle(data->manager, instance->target, 345 345 instance->direction, toggle); … … 349 349 * 350 350 * @param[in] instance Batch structure to use. 351 * @param[in] data_stage Pid to use for data transfers.352 * @param[in] status_stage Pid to use for data transfers.351 * @param[in] data_stage to use for data packets. 352 * @param[in] status_stage to use for data packets. 353 353 * 354 354 * Setup stage with toggle 0 and USB_PID_SETUP. 355 355 * Data stage with alternating toggle and pid supplied by parameter. 356 356 * Status stage with toggle 1 and pid supplied by parameter. 357 * The last transferis marked with IOC.357 * The last packet is marked with IOC. 358 358 */ 359 359 void batch_control(usb_transfer_batch_t *instance, … … 363 363 uhci_batch_t *data = instance->private_data; 364 364 assert(data); 365 assert(data-> transfers >= 2);365 assert(data->packets >= 2); 366 366 367 367 const bool low_speed = instance->speed == USB_SPEED_LOW; … … 374 374 375 375 /* data stage */ 376 size_t transfer= 1;376 size_t packet = 1; 377 377 size_t remain_size = instance->buffer_size; 378 378 while (remain_size > 0) { … … 388 388 389 389 td_init( 390 &data->tds[ transfer], DEFAULT_ERROR_COUNT, packet_size,390 &data->tds[packet], DEFAULT_ERROR_COUNT, packet_size, 391 391 toggle, false, low_speed, instance->target, data_stage, 392 control_data, &data->tds[ transfer+ 1]);393 394 ++ transfer;395 assert( transfer < data->transfers);392 control_data, &data->tds[packet + 1]); 393 394 ++packet; 395 assert(packet < data->packets); 396 396 assert(packet_size <= remain_size); 397 397 remain_size -= packet_size; … … 399 399 400 400 /* status stage */ 401 assert( transfer == data->transfers - 1);401 assert(packet == data->packets - 1); 402 402 403 403 td_init( 404 &data->tds[ transfer], DEFAULT_ERROR_COUNT, 0, 1, false, low_speed,404 &data->tds[packet], DEFAULT_ERROR_COUNT, 0, 1, false, low_speed, 405 405 instance->target, status_stage, NULL, NULL); 406 td_set_ioc(&data->tds[ transfer]);406 td_set_ioc(&data->tds[packet]); 407 407 408 408 usb_log_debug2("Control last TD status: %x.\n", 409 data->tds[ transfer].status);409 data->tds[packet].status); 410 410 } 411 411 /*----------------------------------------------------------------------------*/ -
uspace/drv/uhci-hcd/hc.c
re18e0d6 r11dd29b 67 67 static int hc_debug_checker(void *arg); 68 68 69 static bool usb_is_allowed(69 static bool allowed_usb_packet( 70 70 bool low_speed, usb_transfer_type_t transfer, size_t size); 71 71 /*----------------------------------------------------------------------------*/ … … 323 323 assert(batch); 324 324 const int low_speed = (batch->speed == USB_SPEED_LOW); 325 if (! usb_is_allowed(325 if (!allowed_usb_packet( 326 326 low_speed, batch->transfer_type, batch->max_packet_size)) { 327 327 usb_log_warning( 328 "Invalid USB transferspecified %s SPEED %d %zu.\n",328 "Invalid USB packet specified %s SPEED %d %zu.\n", 329 329 low_speed ? "LOW" : "FULL" , batch->transfer_type, 330 330 batch->max_packet_size); … … 471 471 } 472 472 /*----------------------------------------------------------------------------*/ 473 /** Check transfer sfor USB validity473 /** Check transfer packets, for USB validity 474 474 * 475 475 * @param[in] low_speed Transfer speed. 476 476 * @param[in] transfer Transer type 477 * @param[in] size Size of datapackets477 * @param[in] size Maximum size of used packets 478 478 * @return True if transaction is allowed by USB specs, false otherwise 479 479 */ 480 bool usb_is_allowed(480 bool allowed_usb_packet( 481 481 bool low_speed, usb_transfer_type_t transfer, size_t size) 482 482 { -
uspace/drv/uhci-hcd/hw_struct/transfer_descriptor.h
re18e0d6 r11dd29b 108 108 } 109 109 /*----------------------------------------------------------------------------*/ 110 /** Check whether less than max data were rec eived on SPD marked transfer.110 /** Check whether less than max data were recieved and packet is marked as SPD. 111 111 * 112 112 * @param[in] instance TD structure to use. 113 * @return True if data packet is short (less than max bytes and SPD set),114 * falseotherwise.113 * @return True if packet is short (less than max bytes and SPD set), false 114 * otherwise. 115 115 */ 116 116 static inline bool td_is_short(td_t *instance) -
uspace/drv/uhci-hcd/iface.c
re18e0d6 r11dd29b 279 279 * @param[in] target USB device to write to. 280 280 * @param[in] max_packet_size maximum size of data packet the device accepts. 281 * @param[in] setup_data Data to send with SETUP transfer.282 * @param[in] setup_size Size of data to send with SETUP transfer (always8B).281 * @param[in] setup_data Data to send with SETUP packet. 282 * @param[in] setup_size Size of data to send with SETUP packet (should be 8B). 283 283 * @param[in] data Source of data. 284 284 * @param[in] size Size of data source. -
uspace/drv/uhci-hcd/transfer_list.c
re18e0d6 r11dd29b 91 91 * The batch is added to the end of the list and queue. 92 92 */ 93 void transfer_list_add_batch( 94 transfer_list_t *instance, usb_transfer_batch_t *batch) 93 void transfer_list_add_batch(transfer_list_t *instance, usb_transfer_batch_t *batch) 95 94 { 96 95 assert(instance); … … 147 146 while (current != &instance->batch_list) { 148 147 link_t *next = current->next; 149 usb_transfer_batch_t *batch = 150 list_get_instance(current, usb_transfer_batch_t, link); 148 usb_transfer_batch_t *batch = list_get_instance(current, usb_transfer_batch_t, link); 151 149 152 150 if (batch_is_complete(batch)) { … … 162 160 link_t *item = done.next; 163 161 list_remove(item); 164 usb_transfer_batch_t *batch = 165 list_get_instance(item, usb_transfer_batch_t, link); 162 usb_transfer_batch_t *batch = list_get_instance(item, usb_transfer_batch_t, link); 166 163 batch->next_step(batch); 167 164 } … … 177 174 while (!list_empty(&instance->batch_list)) { 178 175 link_t *current = instance->batch_list.next; 179 usb_transfer_batch_t *batch = 180 list_get_instance(current, usb_transfer_batch_t, link); 176 usb_transfer_batch_t *batch = list_get_instance(current, usb_transfer_batch_t, link); 181 177 transfer_list_remove_batch(instance, batch); 182 178 usb_transfer_batch_finish(batch, EIO); … … 193 189 * Does not lock the transfer list, caller is responsible for that. 194 190 */ 195 void transfer_list_remove_batch( 196 transfer_list_t *instance, usb_transfer_batch_t *batch) 191 void transfer_list_remove_batch(transfer_list_t *instance, usb_transfer_batch_t *batch) 197 192 { 198 193 assert(instance); … … 215 210 } else { 216 211 usb_transfer_batch_t *prev = 217 list_get_instance( 218 batch->link.prev, usb_transfer_batch_t, link); 212 list_get_instance(batch->link.prev, usb_transfer_batch_t, link); 219 213 assert((batch_qh(prev)->next & LINK_POINTER_ADDRESS_MASK) 220 214 == addr_to_phys(batch_qh(batch))); -
uspace/drv/uhci-hcd/uhci.c
re18e0d6 r11dd29b 182 182 if (ret != EOK) { 183 183 usb_log_warning("Failed to enable interrupts: %s.\n", 184 str_error(r et));184 str_error(rc)); 185 185 usb_log_info("HW interrupts not available, " \ 186 186 "falling back to polling.\n");
Note:
See TracChangeset
for help on using the changeset viewer.