Ignore:
Timestamp:
2017-10-12T14:07:27Z (8 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a5976973
Parents:
7e74911
Message:

WIP usbhost refactoring

This commit replaces callbacks with more systematic virtual-like inheritance-like solution. Currently breaks build of HelenOS, but both xhci and usbhost are buildable. More refactoring follows…

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhost/include/usb/host/endpoint.h

    r7e74911 r41924f30  
    3232/** @file
    3333 *
     34 * Endpoint structure is tightly coupled to the bus. The bus controls the
     35 * life-cycle of endpoint. In order to keep endpoints lightweight, operations
     36 * on endpoints are part of the bus structure.
     37 *
    3438 */
    3539#ifndef LIBUSBHOST_HOST_ENDPOINT_H
     
    4246#include <atomic.h>
    4347
     48typedef struct bus bus_t;
     49
    4450/** Host controller side endpoint structure. */
    4551typedef struct endpoint {
     52        /** Managing bus */
     53        bus_t *bus;
    4654        /** Reference count. */
    4755        atomic_t refcnt;
     
    4957        link_t link;
    5058        /** USB address. */
    51         usb_address_t address;
    52         /** USB endpoint number. */
    53         usb_endpoint_t endpoint;
     59        usb_target_t target;
    5460        /** Communication direction. */
    5561        usb_direction_t direction;
     
    6268        /** Additional opportunities per uframe */
    6369        unsigned packets;
    64         /** Necessary bandwidth. */
     70        /** Reserved bandwidth. */
    6571        size_t bandwidth;
    6672        /** Value of the toggle bit. */
    6773        unsigned toggle:1;
    6874        /** True if there is a batch using this scheduled for this endpoint. */
    69         volatile bool active;
     75        bool active;
    7076        /** Protects resources and active status changes. */
    7177        fibril_mutex_t guard;
     
    7783                unsigned port;
    7884        } tt;
    79         /** Optional device specific data. */
    80         struct {
    81                 /** Device specific data. */
    82                 void *data;
    83                 /** Callback to get the value of toggle bit. */
    84                 int (*toggle_get)(void *);
    85                 /** Callback to set the value of toggle bit. */
    86                 void (*toggle_set)(void *, int);
    87                 /** Device slot id. */
    88                 uint8_t slot_id;
    89         } hc_data;
     85
     86        /* This structure is meant to be extended by overriding. */
    9087} endpoint_t;
    9188
    92 extern endpoint_t *endpoint_create(usb_address_t, usb_endpoint_t,
    93     usb_direction_t, usb_transfer_type_t, usb_speed_t, size_t, unsigned int,
    94     size_t, usb_address_t, unsigned int);
    95 extern void endpoint_destroy(endpoint_t *);
     89extern void endpoint_init(endpoint_t *, bus_t *);
    9690
    9791extern void endpoint_add_ref(endpoint_t *);
    9892extern void endpoint_del_ref(endpoint_t *);
    99 
    100 extern void endpoint_set_hc_data(endpoint_t *, void *, int (*)(void *),
    101     void (*)(void *, int));
    102 extern void endpoint_clear_hc_data(endpoint_t *);
    10393
    10494extern void endpoint_use(endpoint_t *);
     
    10696
    10797extern int endpoint_toggle_get(endpoint_t *);
    108 extern void endpoint_toggle_set(endpoint_t *, int);
     98extern void endpoint_toggle_set(endpoint_t *, unsigned);
    10999
    110100/** list_get_instance wrapper.
Note: See TracChangeset for help on using the changeset viewer.