Changeset eb928c4 in mainline for uspace/drv/bus/usb/xhci/hc.c


Ignore:
Timestamp:
2018-01-08T00:07:00Z (6 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
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)
Message:

xhci: documentation & cleanup

Also, a simple refactoring to remove functions that only wraps another
functions unused anywhere else.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/xhci/hc.c

    recbad17 reb928c4  
    6666/**
    6767 * 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.
    6871 */
    6972static int hc_parse_ec(xhci_hc_t *hc)
     
    145148}
    146149
     150/**
     151 * Initialize MMIO spaces of xHC.
     152 */
    147153int hc_init_mmio(xhci_hc_t *hc, const hw_res_list_parsed_t *hw_res)
    148154{
     
    195201}
    196202
     203/**
     204 * Initialize structures kept in allocated memory.
     205 */
    197206int hc_init_memory(xhci_hc_t *hc, ddf_dev_t *device)
    198207{
     
    338347}
    339348
     349/**
     350 * Claim xHC from BIOS. Implements handoff as per Section 4.22.1 of xHCI spec.
     351 */
    340352int hc_claim(xhci_hc_t *hc, ddf_dev_t *dev)
    341353{
     
    344356                return EOK;
    345357
    346         /* Section 4.22.1 */
    347358        /* TODO: Test this with USB3-aware BIOS */
    348359        usb_log_debug2("LEGSUP: bios: %x, os: %x", hc->legsup->sem_bios, hc->legsup->sem_os);
     
    363374}
    364375
     376/**
     377 * Ask the xHC to reset its state. Implements sequence
     378 */
    365379static int hc_reset(xhci_hc_t *hc)
    366380{
     
    454468}
    455469
    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 
    469470typedef int (*event_handler) (xhci_hc_t *, xhci_trb_t *trb);
    470471
     
    484485}
    485486
     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 */
    486497static void hc_run_event_ring(xhci_hc_t *hc, xhci_event_ring_t *event_ring, xhci_interrupter_regs_t *intr)
    487498{
     
    541552}
    542553
     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 */
    543563void hc_interrupt(bus_t *bus, uint32_t status)
    544564{
     
    573593}
    574594
     595/**
     596 * Tear down all in-memory structures.
     597 */
    575598void hc_fini(xhci_hc_t *hc)
    576599{
     
    585608}
    586609
     610/**
     611 * Ring a xHC Doorbell. Implements section 4.7.
     612 */
    587613int hc_ring_doorbell(xhci_hc_t *hc, unsigned doorbell, unsigned target)
    588614{
     
    594620}
    595621
     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 */
    596627int hc_enable_slot(xhci_hc_t *hc, uint32_t *slot_id)
    597628{
     
    615646}
    616647
     648/**
     649 * Issue a Disable Slot command for a slot occupied by device.
     650 *
     651 * Frees the device context
     652 */
    617653int hc_disable_slot(xhci_hc_t *hc, xhci_device_t *dev)
    618654{
     
    634670}
    635671
     672/**
     673 * Prepare an empty Endpoint Input Context inside a dma buffer.
     674 */
    636675static int create_configure_ep_input_ctx(dma_buffer_t *dma_buf)
    637676{
     
    649688}
    650689
     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 */
    651696int hc_address_device(xhci_hc_t *hc, xhci_device_t *dev, xhci_endpoint_t *ep0)
    652697{
     
    713758}
    714759
     760/**
     761 * Issue a Configure Device command for a device in slot.
     762 *
     763 * @param slot_id Slot ID assigned to the device.
     764 */
    715765int hc_configure_device(xhci_hc_t *hc, uint32_t slot_id)
    716766{
     
    726776}
    727777
     778/**
     779 * Issue a Deconfigure Device command for a device in slot.
     780 *
     781 * @param slot_id Slot ID assigned to the device.
     782 */
    728783int hc_deconfigure_device(xhci_hc_t *hc, uint32_t slot_id)
    729784{
     
    732787}
    733788
     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 */
    734796int hc_add_endpoint(xhci_hc_t *hc, uint32_t slot_id, uint8_t ep_idx, xhci_ep_ctx_t *ep_ctx)
    735797{
     
    748810}
    749811
     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 */
    750818int hc_drop_endpoint(xhci_hc_t *hc, uint32_t slot_id, uint8_t ep_idx)
    751819{
     
    763831}
    764832
     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 */
    765841int hc_update_endpoint(xhci_hc_t *hc, uint32_t slot_id, uint8_t ep_idx, xhci_ep_ctx_t *ep_ctx)
    766842{
Note: See TracChangeset for help on using the changeset viewer.