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 13 typedef enum { 14 B_USB_RAW_COMMAND_GET_VERSION = 0x1000, 15 16 B_USB_RAW_COMMAND_GET_DEVICE_DESCRIPTOR = 0x2000, 17 B_USB_RAW_COMMAND_GET_CONFIGURATION_DESCRIPTOR, 18 B_USB_RAW_COMMAND_GET_INTERFACE_DESCRIPTOR, 19 B_USB_RAW_COMMAND_GET_ENDPOINT_DESCRIPTOR, 20 B_USB_RAW_COMMAND_GET_STRING_DESCRIPTOR, 21 B_USB_RAW_COMMAND_GET_GENERIC_DESCRIPTOR, 22 B_USB_RAW_COMMAND_GET_ALT_INTERFACE_COUNT, 23 B_USB_RAW_COMMAND_GET_ALT_INTERFACE_DESCRIPTOR, 24 25 B_USB_RAW_COMMAND_SET_CONFIGURATION = 0x3000, 26 B_USB_RAW_COMMAND_SET_FEATURE, 27 B_USB_RAW_COMMAND_CLEAR_FEATURE, 28 B_USB_RAW_COMMAND_GET_STATUS, 29 B_USB_RAW_COMMAND_GET_DESCRIPTOR, 30 B_USB_RAW_COMMAND_SET_ALT_INTERFACE, 31 32 B_USB_RAW_COMMAND_CONTROL_TRANSFER = 0x4000, 33 B_USB_RAW_COMMAND_INTERRUPT_TRANSFER, 34 B_USB_RAW_COMMAND_BULK_TRANSFER, 35 B_USB_RAW_COMMAND_ISOCHRONOUS_TRANSFER 36 } usb_raw_command_id; 37 38 39 typedef enum { 40 B_USB_RAW_STATUS_SUCCESS = 0, 41 42 B_USB_RAW_STATUS_FAILED, 43 B_USB_RAW_STATUS_ABORTED, 44 B_USB_RAW_STATUS_STALLED, 45 B_USB_RAW_STATUS_CRC_ERROR, 46 B_USB_RAW_STATUS_TIMEOUT, 47 48 B_USB_RAW_STATUS_INVALID_CONFIGURATION, 49 B_USB_RAW_STATUS_INVALID_INTERFACE, 50 B_USB_RAW_STATUS_INVALID_ENDPOINT, 51 B_USB_RAW_STATUS_INVALID_STRING, 52 53 B_USB_RAW_STATUS_NO_MEMORY 54 } usb_raw_command_status; 55 56 57 typedef union { 58 struct { 59 status_t status; 60 } version; 61 62 struct { 63 status_t status; 64 usb_device_descriptor *descriptor; 65 } device; 66 67 struct { 68 status_t status; 69 usb_configuration_descriptor *descriptor; 70 uint32 config_index; 71 } config; 72 73 struct { 74 status_t status; 75 usb_interface_descriptor *descriptor; 76 uint32 config_index; 77 uint32 interface_index; 78 } interface; 79 80 struct { 81 status_t status; 82 uint32 *alternate_count; 83 usb_interface_descriptor *descriptor; 84 uint32 config_index; 85 uint32 interface_index; 86 uint32 alternate_index; 87 } alternate; 88 89 struct { 90 status_t status; 91 usb_endpoint_descriptor *descriptor; 92 uint32 config_index; 93 uint32 interface_index; 94 uint32 endpoint_index; 95 } endpoint; 96 97 struct { 98 status_t status; 99 usb_string_descriptor *descriptor; 100 uint32 string_index; 101 size_t length; 102 } string; 103 104 struct { 105 status_t status; 106 usb_descriptor *descriptor; 107 uint32 config_index; 108 uint32 interface_index; 109 uint32 generic_index; 110 size_t length; 111 } generic; 112 113 struct { 114 status_t status; 115 uint8 type; 116 uint8 index; 117 uint16 language_id; 118 void *data; 119 size_t length; 120 } descriptor; 121 122 struct { 123 status_t status; 124 uint8 request_type; 125 uint8 request; 126 uint16 value; 127 uint16 index; 128 uint16 length; 129 void *data; 130 } control; 131 132 struct { 133 status_t status; 134 uint32 interface; 135 uint32 endpoint; 136 void *data; 137 size_t length; 138 } transfer; 139 140 struct { 141 status_t status; 142 uint32 interface; 143 uint32 endpoint; 144 void *data; 145 size_t length; 146 usb_iso_packet_descriptor *packet_descriptors; 147 uint32 packet_count; 148 } isochronous; 149 } usb_raw_command; 150 151 #endif // _USB_RAW_H_ 152