Changeset 867b375 in mainline for uspace/drv/bus/usb/xhci/main.c


Ignore:
Timestamp:
2017-10-15T02:04:10Z (7 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
20eaa82
Parents:
d7869d7e
Message:

hcd_ddf_new_device refactoring

This long function is now split into parts. Instead of passing dozens of arguments, it now creates the usb_dev_t right away, and uses that to pass it along. The address_device part is now modifiable by drivers.

There is still a work to be done. The biggest problem I see is in the addressing - currently, there is usb_address_t, and for high speed transaction translating there is another address. For (near) future extensibility, we should pass address as a structure. Or even better, make a way how to reference a device, maybe in a similar way how we work with endpoints.

File:
1 edited

Legend:

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

    rd7869d7e r867b375  
    4242
    4343#include "hc.h"
     44#include "rh.h"
    4445#include "endpoint.h"
    4546
     
    5051static int hcd_claim(hcd_t *, ddf_dev_t *);
    5152static int hcd_start(hcd_t *, bool);
     53static int hcd_setup_root_hub(hcd_t *, ddf_dev_t *);
    5254static int hcd_status(hcd_t *, uint32_t *);
    5355static void hcd_interrupt(hcd_t *, uint32_t);
    5456static int hcd_schedule(hcd_t *, usb_transfer_batch_t *);
     57static int hcd_address_device(hcd_t *, usb_speed_t, usb_tt_address_t, usb_address_t *);
    5558static void hc_driver_fini(hcd_t *);
    5659
     
    6265        .claim = hcd_claim,
    6366        .start = hcd_start,
     67        .setup_root_hub = hcd_setup_root_hub,
    6468        .fini = hc_driver_fini,
    6569        .ops = {
     
    6771                .irq_hook       = hcd_interrupt,
    6872                .status_hook    = hcd_status,
     73                .address_device = hcd_address_device,
    6974        }
    7075};
     
    116121}
    117122
     123static int hcd_setup_root_hub(hcd_t *hcd, ddf_dev_t *dev)
     124{
     125        xhci_hc_t *hc = hcd_get_driver_data(hcd);
     126        assert(hc);
     127
     128        hc->rh.hcd_rh = hcd_roothub_create(hcd, dev, USB_SPEED_SUPER);
     129        return hc->rh.hcd_rh ? EOK : ENOMEM;
     130}
     131
    118132static int hcd_schedule(hcd_t *hcd, usb_transfer_batch_t *batch)
    119133{
     
    139153
    140154        hc_interrupt(hc, status);
     155}
     156
     157static int hcd_address_device(hcd_t *hcd, usb_speed_t speed, usb_tt_address_t tt, usb_address_t *address)
     158{
     159        xhci_hc_t *hc = hcd_get_driver_data(hcd);
     160        assert(hc);
     161
     162        return xhci_rh_address_device(&hc->rh, speed, tt, address);
    141163}
    142164
Note: See TracChangeset for help on using the changeset viewer.