Changeset 6832245 in mainline for uspace/lib/usbhost/include/usb/host/bus.h
- Timestamp:
- 2017-12-14T23:01:57Z (6 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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);
Note:
See TracChangeset
for help on using the changeset viewer.