Changeset eb928c4 in mainline for uspace/drv/bus/usb/xhci/hc.c
- Timestamp:
- 2018-01-08T00:07:00Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1102eca
- Parents:
- ecbad17
- git-author:
- Ondřej Hlavatý <aearsis@…> (2018-01-08 00:05:39)
- git-committer:
- Ondřej Hlavatý <aearsis@…> (2018-01-08 00:07:00)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/hc.c
recbad17 reb928c4 66 66 /** 67 67 * Walk the list of extended capabilities. 68 * 69 * The most interesting thing hidden in extended capabilities is the mapping of 70 * ports to protocol versions and speeds. 68 71 */ 69 72 static int hc_parse_ec(xhci_hc_t *hc) … … 145 148 } 146 149 150 /** 151 * Initialize MMIO spaces of xHC. 152 */ 147 153 int hc_init_mmio(xhci_hc_t *hc, const hw_res_list_parsed_t *hw_res) 148 154 { … … 195 201 } 196 202 203 /** 204 * Initialize structures kept in allocated memory. 205 */ 197 206 int hc_init_memory(xhci_hc_t *hc, ddf_dev_t *device) 198 207 { … … 338 347 } 339 348 349 /** 350 * Claim xHC from BIOS. Implements handoff as per Section 4.22.1 of xHCI spec. 351 */ 340 352 int hc_claim(xhci_hc_t *hc, ddf_dev_t *dev) 341 353 { … … 344 356 return EOK; 345 357 346 /* Section 4.22.1 */347 358 /* TODO: Test this with USB3-aware BIOS */ 348 359 usb_log_debug2("LEGSUP: bios: %x, os: %x", hc->legsup->sem_bios, hc->legsup->sem_os); … … 363 374 } 364 375 376 /** 377 * Ask the xHC to reset its state. Implements sequence 378 */ 365 379 static int hc_reset(xhci_hc_t *hc) 366 380 { … … 454 468 } 455 469 456 int hc_schedule(usb_transfer_batch_t *batch)457 {458 assert(batch);459 xhci_hc_t *hc = bus_to_hc(endpoint_get_bus(batch->ep));460 461 if (!batch->target.address) {462 usb_log_error("Attempted to schedule transfer to address 0.");463 return EINVAL;464 }465 466 return xhci_transfer_schedule(hc, batch);467 }468 469 470 typedef int (*event_handler) (xhci_hc_t *, xhci_trb_t *trb); 470 471 … … 484 485 } 485 486 487 /** 488 * Dequeue from event ring and handle dequeued events. 489 * 490 * As there can be events, that blocks on waiting for subsequent events, 491 * we solve this problem by first copying the event TRBs from the event ring, 492 * then asserting EHB and only after, handling the events. 493 * 494 * Whenever the event handling blocks, it switches fibril, and incoming 495 * IPC notification will create new event handling fibril for us. 496 */ 486 497 static void hc_run_event_ring(xhci_hc_t *hc, xhci_event_ring_t *event_ring, xhci_interrupter_regs_t *intr) 487 498 { … … 541 552 } 542 553 554 /** 555 * Handle an interrupt request from xHC. Resolve all situations that trigger an 556 * interrupt separately. 557 * 558 * Note that all RW1C bits in USBSTS register are cleared at the time of 559 * handling the interrupt in irq_code. This method is the top-half. 560 * 561 * @param status contents of USBSTS register at the time of the interrupt. 562 */ 543 563 void hc_interrupt(bus_t *bus, uint32_t status) 544 564 { … … 573 593 } 574 594 595 /** 596 * Tear down all in-memory structures. 597 */ 575 598 void hc_fini(xhci_hc_t *hc) 576 599 { … … 585 608 } 586 609 610 /** 611 * Ring a xHC Doorbell. Implements section 4.7. 612 */ 587 613 int hc_ring_doorbell(xhci_hc_t *hc, unsigned doorbell, unsigned target) 588 614 { … … 594 620 } 595 621 622 /** 623 * Issue an Enable Slot command, returning the obtained Slot ID. 624 * 625 * @param slot_id Pointer where to store the obtained Slot ID. 626 */ 596 627 int hc_enable_slot(xhci_hc_t *hc, uint32_t *slot_id) 597 628 { … … 615 646 } 616 647 648 /** 649 * Issue a Disable Slot command for a slot occupied by device. 650 * 651 * Frees the device context 652 */ 617 653 int hc_disable_slot(xhci_hc_t *hc, xhci_device_t *dev) 618 654 { … … 634 670 } 635 671 672 /** 673 * Prepare an empty Endpoint Input Context inside a dma buffer. 674 */ 636 675 static int create_configure_ep_input_ctx(dma_buffer_t *dma_buf) 637 676 { … … 649 688 } 650 689 690 /** 691 * Initialize a device, assigning it an address. Implements section 4.3.4. 692 * 693 * @param dev Device to assing an address (unconfigured yet) 694 * @param ep0 EP0 of device TODO remove, can be fetched from dev 695 */ 651 696 int hc_address_device(xhci_hc_t *hc, xhci_device_t *dev, xhci_endpoint_t *ep0) 652 697 { … … 713 758 } 714 759 760 /** 761 * Issue a Configure Device command for a device in slot. 762 * 763 * @param slot_id Slot ID assigned to the device. 764 */ 715 765 int hc_configure_device(xhci_hc_t *hc, uint32_t slot_id) 716 766 { … … 726 776 } 727 777 778 /** 779 * Issue a Deconfigure Device command for a device in slot. 780 * 781 * @param slot_id Slot ID assigned to the device. 782 */ 728 783 int hc_deconfigure_device(xhci_hc_t *hc, uint32_t slot_id) 729 784 { … … 732 787 } 733 788 789 /** 790 * Instruct xHC to add an endpoint with supplied endpoint context. 791 * 792 * @param slot_id Slot ID assigned to the device. 793 * @param ep_idx Endpoint index (number + direction) in question 794 * @param ep_ctx Endpoint context of the endpoint 795 */ 734 796 int hc_add_endpoint(xhci_hc_t *hc, uint32_t slot_id, uint8_t ep_idx, xhci_ep_ctx_t *ep_ctx) 735 797 { … … 748 810 } 749 811 812 /** 813 * Instruct xHC to drop an endpoint. 814 * 815 * @param slot_id Slot ID assigned to the device. 816 * @param ep_idx Endpoint index (number + direction) in question 817 */ 750 818 int hc_drop_endpoint(xhci_hc_t *hc, uint32_t slot_id, uint8_t ep_idx) 751 819 { … … 763 831 } 764 832 833 /** 834 * Instruct xHC to update information about an endpoint, using supplied 835 * endpoint context. 836 * 837 * @param slot_id Slot ID assigned to the device. 838 * @param ep_idx Endpoint index (number + direction) in question 839 * @param ep_ctx Endpoint context of the endpoint 840 */ 765 841 int hc_update_endpoint(xhci_hc_t *hc, uint32_t slot_id, uint8_t ep_idx, xhci_ep_ctx_t *ep_ctx) 766 842 {
Note:
See TracChangeset
for help on using the changeset viewer.