Changeset 20eaa82 in mainline for uspace/lib/usbhost/include
- Timestamp:
- 2017-10-15T13:44:39Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2770b66
- Parents:
- 867b375
- Location:
- uspace/lib/usbhost/include/usb/host
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/include/usb/host/bus.h
r867b375 r20eaa82 45 45 #include <usb/usb.h> 46 46 47 #include <assert.h> 47 48 #include <fibril_synch.h> 48 49 #include <stdbool.h> … … 51 52 typedef struct endpoint endpoint_t; 52 53 typedef struct bus bus_t; 54 typedef struct ddf_fun ddf_fun_t; 55 56 typedef 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; 53 78 54 79 typedef struct { 80 int (*enumerate_device)(bus_t *, hcd_t *, device_t *); 81 int (*remove_device)(bus_t *, hcd_t *, device_t *); 82 55 83 endpoint_t *(*create_endpoint)(bus_t *); 56 84 int (*register_endpoint)(bus_t *, endpoint_t *); … … 59 87 60 88 int (*request_address)(bus_t *, usb_address_t*, bool, usb_speed_t); 61 int (*get_speed)(bus_t *, usb_address_t, usb_speed_t *);62 89 int (*release_address)(bus_t *, usb_address_t); 63 90 … … 77 104 fibril_mutex_t guard; 78 105 106 size_t device_size; 107 79 108 /* Do not call directly, ops are synchronized. */ 80 109 bus_ops_t ops; … … 83 112 } bus_t; 84 113 85 void bus_init(bus_t *); 114 void bus_init(bus_t *, size_t); 115 int device_init(device_t *); 116 117 extern 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); 120 extern int bus_remove_ep(bus_t *bus, usb_target_t target, usb_direction_t dir); 121 122 int device_set_default_name(device_t *); 123 124 int bus_enumerate_device(bus_t *, hcd_t *, device_t *); 125 int bus_remove_device(bus_t *, hcd_t *, device_t *); 86 126 87 127 endpoint_t *bus_create_endpoint(bus_t *); … … 93 133 94 134 int 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 *);96 135 int bus_release_address(bus_t *, usb_address_t); 136 137 static 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 145 static inline int bus_release_default_address(bus_t *bus) { 146 return bus_release_address(bus, USB_ADDRESS_DEFAULT); 147 } 97 148 98 149 int bus_reset_toggle(bus_t *, usb_target_t, bool); -
uspace/lib/usbhost/include/usb/host/ddf_helpers.h
r867b375 r20eaa82 59 59 typedef struct { 60 60 hcd_ops_t ops; 61 usb_speed_t hc_speed;62 61 const char *name; 63 62 … … 83 82 int hcd_setup_virtual_root_hub(hcd_t *, ddf_dev_t *); 84 83 84 device_t *hcd_ddf_device_create(ddf_dev_t *, size_t); 85 void hcd_ddf_device_destroy(device_t *); 86 int hcd_ddf_device_explore(hcd_t *, device_t *); 87 85 88 hcd_t *dev_to_hcd(ddf_dev_t *dev); 86 89 … … 93 96 void ddf_hcd_gen_irq_handler(ipc_callid_t iid, ipc_call_t *call, ddf_dev_t *dev); 94 97 95 /* For xHCI, we need to drive the roothub without roothub having assigned an96 * address. Thus we cannot create function for it, and we have to carry the97 * 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 106 98 #endif 107 99 -
uspace/lib/usbhost/include/usb/host/endpoint.h
r867b375 r20eaa82 47 47 48 48 typedef struct bus bus_t; 49 typedef struct device device_t; 49 50 50 51 /** Host controller side endpoint structure. */ … … 56 57 /** Part of linked list. */ 57 58 link_t link; 59 /** USB device */ 60 device_t *device; 58 61 /** USB address. */ 59 62 usb_target_t target; … … 78 81 /** Signals change of active status. */ 79 82 fibril_condvar_t avail; 80 /** High speed TT data */81 usb_tt_address_t tt;82 83 83 84 /* This structure is meant to be extended by overriding. */ -
uspace/lib/usbhost/include/usb/host/hcd.h
r867b375 r20eaa82 103 103 extern usb_address_t hcd_request_address(hcd_t *, usb_speed_t); 104 104 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 114 105 extern int hcd_add_ep(hcd_t *, usb_target_t, usb_direction_t, 115 106 usb_transfer_type_t, size_t, unsigned int, size_t, usb_tt_address_t);
Note:
See TracChangeset
for help on using the changeset viewer.