1 /* 2 * Copyright 2006-2008, Haiku Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 #ifndef _USB_RAW_H_ 7 #define _USB_RAW_H_ 8 9 #include <USB3.h> 10 11 #define B_USB_RAW_PROTOCOL_VERSION 0x0015 12 #define B_USB_RAW_ACTIVE_ALTERNATE 0xffffffff 13 14 typedef enum { 15 B_USB_RAW_COMMAND_GET_VERSION = 0x1000, 16 17 B_USB_RAW_COMMAND_GET_DEVICE_DESCRIPTOR = 0x2000, 18 B_USB_RAW_COMMAND_GET_CONFIGURATION_DESCRIPTOR, 19 B_USB_RAW_COMMAND_GET_INTERFACE_DESCRIPTOR, 20 B_USB_RAW_COMMAND_GET_ENDPOINT_DESCRIPTOR, 21 B_USB_RAW_COMMAND_GET_STRING_DESCRIPTOR, 22 B_USB_RAW_COMMAND_GET_GENERIC_DESCRIPTOR, 23 B_USB_RAW_COMMAND_GET_ALT_INTERFACE_COUNT, 24 B_USB_RAW_COMMAND_GET_ACTIVE_ALT_INTERFACE_INDEX, 25 B_USB_RAW_COMMAND_GET_INTERFACE_DESCRIPTOR_ETC, 26 B_USB_RAW_COMMAND_GET_ENDPOINT_DESCRIPTOR_ETC, 27 B_USB_RAW_COMMAND_GET_GENERIC_DESCRIPTOR_ETC, 28 29 B_USB_RAW_COMMAND_SET_CONFIGURATION = 0x3000, 30 B_USB_RAW_COMMAND_SET_FEATURE, 31 B_USB_RAW_COMMAND_CLEAR_FEATURE, 32 B_USB_RAW_COMMAND_GET_STATUS, 33 B_USB_RAW_COMMAND_GET_DESCRIPTOR, 34 B_USB_RAW_COMMAND_SET_ALT_INTERFACE, 35 36 B_USB_RAW_COMMAND_CONTROL_TRANSFER = 0x4000, 37 B_USB_RAW_COMMAND_INTERRUPT_TRANSFER, 38 B_USB_RAW_COMMAND_BULK_TRANSFER, 39 B_USB_RAW_COMMAND_ISOCHRONOUS_TRANSFER 40 } usb_raw_command_id; 41 42 43 typedef enum { 44 B_USB_RAW_STATUS_SUCCESS = 0, 45 46 B_USB_RAW_STATUS_FAILED, 47 B_USB_RAW_STATUS_ABORTED, 48 B_USB_RAW_STATUS_STALLED, 49 B_USB_RAW_STATUS_CRC_ERROR, 50 B_USB_RAW_STATUS_TIMEOUT, 51 52 B_USB_RAW_STATUS_INVALID_CONFIGURATION, 53 B_USB_RAW_STATUS_INVALID_INTERFACE, 54 B_USB_RAW_STATUS_INVALID_ENDPOINT, 55 B_USB_RAW_STATUS_INVALID_STRING, 56 57 B_USB_RAW_STATUS_NO_MEMORY 58 } usb_raw_command_status; 59 60 61 typedef union { 62 struct { 63 status_t status; 64 } version; 65 66 struct { 67 status_t status; 68 usb_device_descriptor *descriptor; 69 } device; 70 71 struct { 72 status_t status; 73 usb_configuration_descriptor *descriptor; 74 uint32 config_index; 75 } config; 76 77 struct { 78 status_t status; 79 uint32 alternate_info; 80 uint32 config_index; 81 uint32 interface_index; 82 } alternate; 83 84 struct { 85 status_t status; 86 usb_interface_descriptor *descriptor; 87 uint32 config_index; 88 uint32 interface_index; 89 } interface; 90 91 struct { 92 status_t status; 93 usb_interface_descriptor *descriptor; 94 uint32 config_index; 95 uint32 interface_index; 96 uint32 alternate_index; 97 } interface_etc; 98 99 struct { 100 status_t status; 101 usb_endpoint_descriptor *descriptor; 102 uint32 config_index; 103 uint32 interface_index; 104 uint32 endpoint_index; 105 } endpoint; 106 107 struct { 108 status_t status; 109 usb_endpoint_descriptor *descriptor; 110 uint32 config_index; 111 uint32 interface_index; 112 uint32 alternate_index; 113 uint32 endpoint_index; 114 } endpoint_etc; 115 116 struct { 117 status_t status; 118 usb_descriptor *descriptor; 119 uint32 config_index; 120 uint32 interface_index; 121 uint32 generic_index; 122 size_t length; 123 } generic; 124 125 struct { 126 status_t status; 127 usb_descriptor *descriptor; 128 uint32 config_index; 129 uint32 interface_index; 130 uint32 alternate_index; 131 uint32 generic_index; 132 size_t length; 133 } generic_etc; 134 135 struct { 136 status_t status; 137 usb_string_descriptor *descriptor; 138 uint32 string_index; 139 size_t length; 140 } string; 141 142 struct { 143 status_t status; 144 uint8 type; 145 uint8 index; 146 uint16 language_id; 147 void *data; 148 size_t length; 149 } descriptor; 150 151 struct { 152 status_t status; 153 uint8 request_type; 154 uint8 request; 155 uint16 value; 156 uint16 index; 157 uint16 length; 158 void *data; 159 } control; 160 161 struct { 162 status_t status; 163 uint32 interface; 164 uint32 endpoint; 165 void *data; 166 size_t length; 167 } transfer; 168 169 struct { 170 status_t status; 171 uint32 interface; 172 uint32 endpoint; 173 void *data; 174 size_t length; 175 usb_iso_packet_descriptor *packet_descriptors; 176 uint32 packet_count; 177 } isochronous; 178 } usb_raw_command; 179 180 #endif // _USB_RAW_H_ 181