Changeset adb4e683 in mainline
- Timestamp:
- 2017-10-03T15:17:26Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- efe9463
- Parents:
- a1eb7c67
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/hc.c
ra1eb7c67 radb4e683 497 497 { 498 498 int err; 499 xhci_trb_t trb; 500 501 err = xhci_event_ring_dequeue(event_ring, &trb);; 499 size_t last_idx = 0; 500 size_t size = 16; // TODO: Define a macro, possibly do size += initial_size instead of *= 2. 501 xhci_trb_t *trbs = malloc32(sizeof(xhci_trb_t) * size); 502 503 err = xhci_event_ring_dequeue(event_ring, trbs + last_idx); 502 504 503 505 while (err != ENOENT) { 504 506 if (err == EOK) { 505 507 usb_log_debug2("Dequeued trb from event ring: %s", 506 xhci_trb_str_type(TRB_TYPE(trb))); 507 508 hc_handle_event(hc, &trb, intr); 508 xhci_trb_str_type(TRB_TYPE(trbs[last_idx]))); 509 509 } else { 510 --last_idx; /* If there are valid trbs they should still get handled. */ 510 511 usb_log_warning("Error while accessing event ring: %s", str_error(err)); 511 512 break; 512 513 } 513 514 514 err = xhci_event_ring_dequeue(event_ring, &trb);; 515 } 516 usb_log_debug2("Event ring processing finished."); 517 518 /* Update the ERDP to make room in the ring */ 515 ++last_idx; 516 err = xhci_event_ring_dequeue(event_ring, trbs + last_idx); 517 518 /* Expand the array if needed. */ 519 if (last_idx >= size) { 520 xhci_trb_t *trbs_old = trbs; 521 size_t size_old = size; 522 523 size *= 2; 524 trbs = malloc32(sizeof(xhci_trb_t) * size); 525 526 for (size_t i = 0; i < size_old; ++i) 527 xhci_trb_copy(trbs + i, trbs_old + i); 528 free32(trbs_old); 529 } 530 } 531 532 /* Update the ERDP to make room in the ring. */ 519 533 hc->event_ring.dequeue_ptr = host2xhci(64, addr_to_phys(hc->event_ring.dequeue_trb)); 520 534 uint64_t erdp = hc->event_ring.dequeue_ptr; … … 522 536 XHCI_REG_WR(intr, XHCI_INTR_ERDP_HI, UPPER32(erdp)); 523 537 XHCI_REG_SET(intr, XHCI_INTR_ERDP_EHB, 1); 538 539 /** 540 * After changing the way this function works, second port status change 541 * would not raise an interrupt because of IE being set to 0. This is 542 * a temporary hotfix that fixes this issue. 543 * TODO: Research & properly fix this. 544 */ 545 XHCI_REG_SET(intr, XHCI_INTR_IE, 1); 546 547 /* Handle all of the collected events if possible. */ 548 if (last_idx > 0) { 549 for (size_t i = 0; i < last_idx; ++i) 550 hc_handle_event(hc, trbs + i, intr); 551 usb_log_debug2("Event ring processing finished."); 552 } else { 553 usb_log_warning("No events to be handled!"); 554 } 555 556 free32(trbs); 524 557 } 525 558
Note:
See TracChangeset
for help on using the changeset viewer.