Changeset f37f811 in mainline for uspace/lib/usbvirt/include/usbvirt/device.h
- Timestamp:
- 2010-12-15T22:25:01Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- cea3fca
- Parents:
- ea5dbaf (diff), e63a4e1 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbvirt/include/usbvirt/device.h
rea5dbaf rf37f811 40 40 #include <usb/devreq.h> 41 41 42 typedef enum { 43 USBVIRT_REQUEST_TYPE_STANDARD = 0, 44 USBVIRT_REQUEST_TYPE_CLASS = 1 45 } usbvirt_request_type_t; 46 47 typedef enum { 48 USBVIRT_REQUEST_RECIPIENT_DEVICE = 0, 49 USBVIRT_REQUEST_RECIPIENT_INTERFACE = 1, 50 USBVIRT_REQUEST_RECIPIENT_ENDPOINT = 2, 51 USBVIRT_REQUEST_RECIPIENT_OTHER = 3 52 } usbvirt_request_recipient_t; 53 54 /** Possible states of virtual USB device. 55 * Notice that these are not 1:1 mappings to those in USB specification. 56 */ 57 typedef enum { 58 USBVIRT_STATE_DEFAULT, 59 USBVIRT_STATE_ADDRESS, 60 USBVIRT_STATE_CONFIGURED 61 } usbvirt_device_state_t; 62 42 63 typedef struct usbvirt_device usbvirt_device_t; 43 64 struct usbvirt_control_transfer; … … 47 68 uint8_t *data); 48 69 49 /** Callbacks for standard device requests. 50 * When these functions are NULL or return EFORWARD, this 51 * framework will try to satisfy the request by itself. 52 */ 53 typedef struct { 54 u sbvirt_on_device_request_t on_get_status;55 u sbvirt_on_device_request_t on_clear_feature;56 usbvirt_on_device_request_t on_set_feature;57 usbvirt_ on_device_request_t on_set_address;58 usbvirt_on_device_request_t on_get_descriptor;59 usbvirt_on_device_request_t on_set_descriptor; 60 usbvirt_on_device_request_t on_get_configuration; 61 usbvirt_on_device_request_t on_set_configuration;62 usbvirt_on_device_request_t on_get_interface;63 usbvirt_on_device_request_t on_set_interface;64 usbvirt_on_device_request_t on_synch_frame; 65 } usbvirt_standard_device_request_ops_t; 70 typedef int (*usbvirt_control_request_callback_t)(usbvirt_device_t *dev, 71 usb_device_request_setup_packet_t *request, 72 uint8_t *data); 73 74 typedef struct { 75 uint8_t request_type; 76 uint8_t request; 77 const char *name; 78 usbvirt_control_request_callback_t callback; 79 } usbvirt_control_transfer_handler_t; 80 81 #define USBVIRT_MAKE_CONTROL_REQUEST_TYPE(direction, type, recipient) \ 82 ((((direction) == USB_DIRECTION_IN) ? 1 : 0) << 7) \ 83 | (((type) & 3) << 5) \ 84 | (((recipient) & 31)) 85 86 #define USBVIRT_CONTROL_TRANSFER_HANDLER_LAST { 0, 0, NULL, NULL } 66 87 67 88 /** Device operations. */ 68 89 typedef struct { 69 /** Callbacks for standard deivce requests. */ 70 usbvirt_standard_device_request_ops_t *standard_request_ops; 71 /** Callback for class-specific USB request. */ 72 usbvirt_on_device_request_t on_class_device_request; 73 90 /** Callbacks for transfers over control pipe zero. */ 91 usbvirt_control_transfer_handler_t *control_transfer_handlers; 92 74 93 int (*on_control_transfer)(usbvirt_device_t *dev, 75 94 usb_endpoint_t endpoint, struct usbvirt_control_transfer *transfer); … … 86 105 usb_direction_t (*decide_control_transfer_direction)( 87 106 usb_endpoint_t endpoint, void *buffer, size_t size); 107 108 /** Callback when device changes its state. 109 * 110 * It is correct that this function is called when both states 111 * are equal (e.g. this function is called during SET_CONFIGURATION 112 * request done on already configured device). 113 * 114 * @warning The value of <code>dev->state</code> before calling 115 * this function is not specified (i.e. can be @p old_state or 116 * @p new_state). 117 */ 118 void (*on_state_change)(usbvirt_device_t *dev, 119 usbvirt_device_state_t old_state, usbvirt_device_state_t new_state); 88 120 } usbvirt_device_ops_t; 89 121 … … 120 152 uint8_t current_configuration; 121 153 } usbvirt_descriptors_t; 122 123 /** Possible states of virtual USB device.124 * Notice that these are not 1:1 mappings to those in USB specification.125 */126 typedef enum {127 USBVIRT_STATE_DEFAULT,128 USBVIRT_STATE_ADDRESS,129 USBVIRT_STATE_CONFIGURED130 } usbvirt_device_state_t;131 154 132 155 /** Information about on-going control transfer. … … 157 180 usbvirt_device_ops_t *ops; 158 181 182 /** Custom device data. */ 183 void *device_data; 184 159 185 /** Reply onto control transfer. 160 186 */
Note:
See TracChangeset
for help on using the changeset viewer.