Changeset 20eaa82 in mainline for uspace/lib/usbhost/include


Ignore:
Timestamp:
2017-10-15T13:44:39Z (8 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2770b66
Parents:
867b375
Message:

usbhost refactoring: introduced bus→enumerate_device

Location:
uspace/lib/usbhost/include/usb/host
Files:
4 edited

Legend:

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

    r867b375 r20eaa82  
    4545#include <usb/usb.h>
    4646
     47#include <assert.h>
    4748#include <fibril_synch.h>
    4849#include <stdbool.h>
     
    5152typedef struct endpoint endpoint_t;
    5253typedef struct bus bus_t;
     54typedef struct ddf_fun ddf_fun_t;
     55
     56typedef struct device {
     57        /* Device tree keeping */
     58        link_t link;
     59        list_t devices;
     60        fibril_mutex_t guard;
     61
     62        /* Associated DDF function, if any */
     63        ddf_fun_t *fun;
     64
     65        /* Invalid for the roothub device */
     66        unsigned port;
     67        struct device *hub;
     68
     69        /* Transaction translator */
     70        usb_tt_address_t tt;
     71
     72        /* The following are not set by the library */
     73        usb_speed_t speed;
     74        usb_address_t address;
     75
     76        /* This structure is meant to be extended by overriding. */
     77} device_t;
    5378
    5479typedef struct {
     80        int (*enumerate_device)(bus_t *, hcd_t *, device_t *);
     81        int (*remove_device)(bus_t *, hcd_t *, device_t *);
     82
    5583        endpoint_t *(*create_endpoint)(bus_t *);
    5684        int (*register_endpoint)(bus_t *, endpoint_t *);
     
    5987
    6088        int (*request_address)(bus_t *, usb_address_t*, bool, usb_speed_t);
    61         int (*get_speed)(bus_t *, usb_address_t, usb_speed_t *);
    6289        int (*release_address)(bus_t *, usb_address_t);
    6390
     
    77104        fibril_mutex_t guard;
    78105
     106        size_t device_size;
     107
    79108        /* Do not call directly, ops are synchronized. */
    80109        bus_ops_t ops;
     
    83112} bus_t;
    84113
    85 void bus_init(bus_t *);
     114void bus_init(bus_t *, size_t);
     115int device_init(device_t *);
     116
     117extern int bus_add_ep(bus_t *bus, device_t *device, usb_endpoint_t endpoint,
     118    usb_direction_t dir, usb_transfer_type_t type, size_t max_packet_size,
     119    unsigned packets, size_t size);
     120extern int bus_remove_ep(bus_t *bus, usb_target_t target, usb_direction_t dir);
     121
     122int device_set_default_name(device_t *);
     123
     124int bus_enumerate_device(bus_t *, hcd_t *, device_t *);
     125int bus_remove_device(bus_t *, hcd_t *, device_t *);
    86126
    87127endpoint_t *bus_create_endpoint(bus_t *);
     
    93133
    94134int bus_request_address(bus_t *, usb_address_t *, bool, usb_speed_t);
    95 int bus_get_speed(bus_t *, usb_address_t, usb_speed_t *);
    96135int bus_release_address(bus_t *, usb_address_t);
     136
     137static inline int bus_reserve_default_address(bus_t *bus, usb_speed_t speed) {
     138        usb_address_t addr = USB_ADDRESS_DEFAULT;
     139
     140        const int r = bus_request_address(bus, &addr, true, speed);
     141        assert(addr == USB_ADDRESS_DEFAULT);
     142        return r;
     143}
     144
     145static inline int bus_release_default_address(bus_t *bus) {
     146        return bus_release_address(bus, USB_ADDRESS_DEFAULT);
     147}
    97148
    98149int bus_reset_toggle(bus_t *, usb_target_t, bool);
  • uspace/lib/usbhost/include/usb/host/ddf_helpers.h

    r867b375 r20eaa82  
    5959typedef struct {
    6060        hcd_ops_t ops;
    61         usb_speed_t hc_speed;
    6261        const char *name;
    6362
     
    8382int hcd_setup_virtual_root_hub(hcd_t *, ddf_dev_t *);
    8483
     84device_t *hcd_ddf_device_create(ddf_dev_t *, size_t);
     85void hcd_ddf_device_destroy(device_t *);
     86int hcd_ddf_device_explore(hcd_t *, device_t *);
     87
    8588hcd_t *dev_to_hcd(ddf_dev_t *dev);
    8689
     
    9396void ddf_hcd_gen_irq_handler(ipc_callid_t iid, ipc_call_t *call, ddf_dev_t *dev);
    9497
    95 /* For xHCI, we need to drive the roothub without roothub having assigned an
    96  * address. Thus we cannot create function for it, and we have to carry the
    97  * usb_dev_t somewhere.
    98  *
    99  * This is sort of hacky, but at least does not expose the internals of ddf_helpers.
    100  */
    101 typedef struct hcd_roothub hcd_roothub_t;
    102 
    103 hcd_roothub_t *hcd_roothub_create(hcd_t *, ddf_dev_t *, usb_speed_t);
    104 int hcd_roothub_new_device(hcd_roothub_t *, unsigned port);
    105 
    10698#endif
    10799
  • uspace/lib/usbhost/include/usb/host/endpoint.h

    r867b375 r20eaa82  
    4747
    4848typedef struct bus bus_t;
     49typedef struct device device_t;
    4950
    5051/** Host controller side endpoint structure. */
     
    5657        /** Part of linked list. */
    5758        link_t link;
     59        /** USB device */
     60        device_t *device;
    5861        /** USB address. */
    5962        usb_target_t target;
     
    7881        /** Signals change of active status. */
    7982        fibril_condvar_t avail;
    80         /** High speed TT data */
    81         usb_tt_address_t tt;
    8283
    8384        /* This structure is meant to be extended by overriding. */
  • uspace/lib/usbhost/include/usb/host/hcd.h

    r867b375 r20eaa82  
    103103extern usb_address_t hcd_request_address(hcd_t *, usb_speed_t);
    104104
    105 extern int hcd_release_address(hcd_t *, usb_address_t);
    106 
    107 extern int hcd_reserve_default_address(hcd_t *, usb_speed_t);
    108 
    109 static inline int hcd_release_default_address(hcd_t *hcd)
    110 {
    111         return hcd_release_address(hcd, USB_ADDRESS_DEFAULT);
    112 }
    113 
    114105extern int hcd_add_ep(hcd_t *, usb_target_t, usb_direction_t,
    115106    usb_transfer_type_t, size_t, unsigned int, size_t, usb_tt_address_t);
Note: See TracChangeset for help on using the changeset viewer.