Changeset 6832245 in mainline for uspace/drv/bus/usb/uhci


Ignore:
Timestamp:
2017-12-14T23:01:57Z (8 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
837d53d
Parents:
bd05140
git-author:
Ondřej Hlavatý <aearsis@…> (2017-12-14 23:01:54)
git-committer:
Ondřej Hlavatý <aearsis@…> (2017-12-14 23:01:57)
Message:

usbhost bus: refactor the bus ops

This way, method names better represent the entity it is working with.
Their semantics was shifted a bit.

Regarding the tree of structures:

bus ← device ← endpoint ← batch

Previously, devices were kept in DDF function nodes, and endpoints had
pointer to the bus and device. Now, devices have pointer to bus,
endpoints don't.

Pointer to hcd_t in bus is WIP, and will be removed.

Location:
uspace/drv/bus/usb/uhci
Files:
3 edited

Legend:

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

    rbd05140 r6832245  
    9595
    9696static void hc_init_hw(const hc_t *instance);
    97 static int hc_init_mem_structures(hc_t *instance);
     97static int hc_init_mem_structures(hc_t *instance, hcd_t *);
    9898static int hc_init_transfer_lists(hc_t *instance);
    9999
     
    215215 * interrupt fibrils.
    216216 */
    217 int hc_init(hc_t *instance, const hw_res_list_parsed_t *hw_res)
     217int hc_init(hc_t *instance, hcd_t *hcd, const hw_res_list_parsed_t *hw_res)
    218218{
    219219        assert(instance);
     
    238238            hw_res->io_ranges.ranges[0].size);
    239239
    240         ret = hc_init_mem_structures(instance);
     240        ret = hc_init_mem_structures(instance, hcd);
    241241        if (ret != EOK) {
    242242                usb_log_error("Failed to init UHCI memory structures: %s.\n",
     
    309309}
    310310
    311 static usb_transfer_batch_t *create_transfer_batch(bus_t *bus, endpoint_t *ep)
     311static usb_transfer_batch_t *create_transfer_batch(endpoint_t *ep)
    312312{
    313313        uhci_transfer_batch_t *batch = uhci_transfer_batch_create(ep);
     
    319319        uhci_transfer_batch_destroy(uhci_transfer_batch_get(batch));
    320320}
     321
     322static const bus_ops_t uhci_bus_ops = {
     323        .parent = &usb2_bus_ops,
     324
     325        .endpoint_count_bw = bandwidth_count_usb11,
     326        .batch_create = create_transfer_batch,
     327        .batch_destroy = destroy_transfer_batch,
     328};
    321329
    322330/** Initialize UHCI hc memory structures.
     
    330338 *  - frame list page (needs to be one UHCI hw accessible 4K page)
    331339 */
    332 int hc_init_mem_structures(hc_t *instance)
     340int hc_init_mem_structures(hc_t *instance, hcd_t *hcd)
    333341{
    334342        int err;
    335343        assert(instance);
    336344
    337         if ((err = usb2_bus_init(&instance->bus, BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11)))
     345        if ((err = usb2_bus_init(&instance->bus, hcd, BANDWIDTH_AVAILABLE_USB11)))
    338346                return err;
    339347
    340         instance->bus.base.ops.create_batch = create_transfer_batch;
    341         instance->bus.base.ops.destroy_batch = destroy_transfer_batch;
     348        bus_t *bus = (bus_t *) &instance->bus;
     349        bus->ops = &uhci_bus_ops;
    342350
    343351        /* Init USB frame list page */
  • uspace/drv/bus/usb/uhci/hc.h

    rbd05140 r6832245  
    126126} hc_t;
    127127
    128 extern int hc_init(hc_t *, const hw_res_list_parsed_t *);
     128extern int hc_init(hc_t *, hcd_t *, const hw_res_list_parsed_t *);
    129129extern void hc_start(hc_t *);
    130130extern void hc_fini(hc_t *);
  • uspace/drv/bus/usb/uhci/main.c

    rbd05140 r6832245  
    8080                return ENOMEM;
    8181
    82         if ((err = hc_init(instance, res)) != EOK)
     82        if ((err = hc_init(instance, hcd, res)) != EOK)
    8383                goto err;
    8484
Note: See TracChangeset for help on using the changeset viewer.