Changeset 6832245 in mainline for uspace/lib/usbhost/include
- Timestamp:
- 2017-12-14T23:01:57Z (8 years ago)
- 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)
- Location:
- uspace/lib/usbhost/include/usb/host
- Files:
-
- 5 edited
-
bandwidth.h (modified) (1 diff)
-
bus.h (modified) (2 diffs)
-
ddf_helpers.h (modified) (1 diff)
-
endpoint.h (modified) (4 diffs)
-
usb2_bus.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/include/usb/host/bandwidth.h
rbd05140 r6832245 51 51 typedef struct endpoint endpoint_t; 52 52 53 extern s ize_t bandwidth_count_usb11(endpoint_t *, size_t);53 extern ssize_t bandwidth_count_usb11(endpoint_t *, size_t); 54 54 55 extern s ize_t bandwidth_count_usb20(endpoint_t *, size_t);55 extern ssize_t bandwidth_count_usb20(endpoint_t *, size_t); 56 56 57 57 #endif -
uspace/lib/usbhost/include/usb/host/bus.h
rbd05140 r6832245 77 77 usb_address_t address; 78 78 79 /* Managing bus */ 80 bus_t *bus; 81 79 82 /* This structure is meant to be extended by overriding. */ 80 83 } device_t; 81 84 82 typedef struct { 83 int (*enumerate_device)(bus_t *, hcd_t *, device_t *); 84 int (*remove_device)(bus_t *, hcd_t *, device_t *); 85 typedef struct bus_ops bus_ops_t; 85 86 86 int (*online_device)(bus_t *, hcd_t *, device_t *); /**< Optional */ 87 int (*offline_device)(bus_t *, hcd_t *, device_t *); /**< Optional */ 87 /** 88 * Operations structure serving as an interface of hc driver for the library 89 * (and the rest of the system). 90 */ 91 struct bus_ops { 92 /* Undefined operations will be delegated to parent ops */ 93 const bus_ops_t *parent; 88 94 89 /* The following operations are protected by a bus guard. */ 90 endpoint_t *(*create_endpoint)(bus_t *); 91 int (*register_endpoint)(bus_t *, device_t *, endpoint_t *, const usb_endpoint_desc_t *); 92 int (*unregister_endpoint)(bus_t *, endpoint_t *); 93 endpoint_t *(*find_endpoint)(bus_t *, device_t*, usb_target_t, usb_direction_t); 94 void (*destroy_endpoint)(endpoint_t *); /**< Optional */ 95 /* Global operations on the bus */ 96 int (*reserve_default_address)(bus_t *, usb_speed_t); 97 int (*release_default_address)(bus_t *); 98 int (*reset_toggle)(bus_t *, usb_target_t, toggle_reset_mode_t); 99 100 /* Operations on device */ 101 int (*device_enumerate)(device_t *); 102 int (*device_remove)(device_t *); 103 int (*device_online)(device_t *); /**< Optional */ 104 int (*device_offline)(device_t *); /**< Optional */ 105 endpoint_t *(*device_find_endpoint)(device_t*, usb_target_t, usb_direction_t); 106 endpoint_t *(*endpoint_create)(device_t *, const usb_endpoint_desc_t *); 107 108 /* Operations on endpoint */ 109 int (*endpoint_register)(endpoint_t *); 110 int (*endpoint_unregister)(endpoint_t *); 111 void (*endpoint_destroy)(endpoint_t *); /**< Optional */ 95 112 bool (*endpoint_get_toggle)(endpoint_t *); /**< Optional */ 96 113 void (*endpoint_set_toggle)(endpoint_t *, bool); /**< Optional */ 114 ssize_t (*endpoint_count_bw) (endpoint_t *, size_t); 115 usb_transfer_batch_t *(*batch_create)(endpoint_t *); /**< Optional */ 97 116 98 int (*reserve_default_address)(bus_t *, usb_speed_t); 99 int (*release_default_address)(bus_t *); 117 /* Operations on batch */ 118 void (*batch_destroy)(usb_transfer_batch_t *); /**< Optional */ 119 }; 100 120 101 int (*reset_toggle)(bus_t *, usb_target_t, toggle_reset_mode_t); 102 103 size_t (*count_bw) (endpoint_t *, size_t); 104 105 usb_transfer_batch_t *(*create_batch)(bus_t *, endpoint_t *); /**< Optional */ 106 void (*destroy_batch)(usb_transfer_batch_t *); /**< Optional */ 107 } bus_ops_t; 121 /** 122 * Use this macro to lookup virtual function. 123 */ 124 #define BUS_OPS_LOOKUP(start, fn) ({ bus_ops_t const * ops = (start); while (ops && ops->fn == NULL) ops = ops->parent; ops; }) 108 125 109 126 /** Endpoint management structure */ … … 112 129 fibril_mutex_t guard; 113 130 131 /* TODO: get rid of this one. */ 132 hcd_t *hcd; 133 114 134 size_t device_size; 115 135 116 136 /* Do not call directly, ops are synchronized. */ 117 bus_ops_tops;137 const bus_ops_t *ops; 118 138 119 139 /* This structure is meant to be extended by overriding. */ 120 140 } bus_t; 121 141 122 void bus_init(bus_t *, size_t);123 int device_init(device_t *);142 void bus_init(bus_t *, hcd_t *, size_t); 143 int bus_device_init(device_t *, bus_t *); 124 144 125 int device_set_default_name(device_t *);145 int bus_device_set_default_name(device_t *); 126 146 127 int bus_ enumerate_device(bus_t *, hcd_t *,device_t *);128 int bus_ remove_device(bus_t *, hcd_t *,device_t *);147 int bus_device_enumerate(device_t *); 148 int bus_device_remove(device_t *); 129 149 130 int bus_ online_device(bus_t *, hcd_t *,device_t *);131 int bus_ offline_device(bus_t *, hcd_t *,device_t *);150 int bus_device_online(device_t *); 151 int bus_device_offline(device_t *); 132 152 133 int bus_add_endpoint(bus_t *, device_t *, const usb_endpoint_desc_t *, endpoint_t **); 134 endpoint_t *bus_find_endpoint(bus_t *, device_t *, usb_target_t, usb_direction_t); 135 int bus_remove_endpoint(bus_t *, endpoint_t *); 136 137 size_t bus_count_bw(endpoint_t *, size_t); 153 int bus_endpoint_add(device_t *, const usb_endpoint_desc_t *, endpoint_t **); 154 endpoint_t *bus_find_endpoint(device_t *, usb_target_t, usb_direction_t); 155 int bus_endpoint_remove(endpoint_t *); 138 156 139 157 int bus_reserve_default_address(bus_t *, usb_speed_t); -
uspace/lib/usbhost/include/usb/host/ddf_helpers.h
rbd05140 r6832245 81 81 int hcd_setup_virtual_root_hub(hcd_t *, ddf_dev_t *); 82 82 83 device_t *hcd_ddf_device_create(ddf_dev_t *, size_t);83 device_t *hcd_ddf_device_create(ddf_dev_t *, bus_t *); 84 84 void hcd_ddf_device_destroy(device_t *); 85 int hcd_ddf_device_explore( hcd_t *,device_t *);85 int hcd_ddf_device_explore(device_t *); 86 86 int hcd_ddf_device_online(ddf_fun_t *); 87 87 int hcd_ddf_device_offline(ddf_fun_t *); -
uspace/lib/usbhost/include/usb/host/endpoint.h
rbd05140 r6832245 45 45 #include <stdbool.h> 46 46 #include <usb/usb.h> 47 #include <usb/host/bus.h> 47 48 48 49 typedef struct bus bus_t; … … 54 55 /** Part of linked list. */ 55 56 link_t link; 56 /** Managing bus*/57 bus_t *bus;57 /** USB device */ 58 device_t *device; 58 59 /** Reference count. */ 59 60 atomic_t refcnt; 60 /** USB device */61 device_t *device;62 61 /** Enpoint number */ 63 62 usb_endpoint_t endpoint; … … 84 83 } endpoint_t; 85 84 86 extern void endpoint_init(endpoint_t *, bus_t *);85 extern void endpoint_init(endpoint_t *, device_t *, const usb_endpoint_desc_t *); 87 86 88 87 extern void endpoint_add_ref(endpoint_t *); … … 103 102 void endpoint_abort(endpoint_t *); 104 103 104 /* Manage the toggle bit */ 105 105 extern int endpoint_toggle_get(endpoint_t *); 106 106 extern void endpoint_toggle_set(endpoint_t *, bool); 107 108 /* Calculate bandwidth */ 109 ssize_t endpoint_count_bw(endpoint_t *, size_t); 110 111 static inline bus_t *endpoint_get_bus(endpoint_t *ep) 112 { 113 return ep->device->bus; 114 } 107 115 108 116 /** list_get_instance wrapper. -
uspace/lib/usbhost/include/usb/host/usb2_bus.h
rbd05140 r6832245 46 46 typedef struct endpoint endpoint_t; 47 47 48 typedef size_t (*count_bw_func_t)(endpoint_t *, size_t);49 50 48 /** Endpoint management structure */ 51 49 typedef struct usb2_bus { … … 66 64 } usb2_bus_t; 67 65 68 extern int usb2_bus_init(usb2_bus_t *, size_t, count_bw_func_t); 66 extern const bus_ops_t usb2_bus_ops; 67 68 extern int usb2_bus_init(usb2_bus_t *, hcd_t *, size_t); 69 69 70 70 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
