1/*- 2 * SPDX-License-Identifier: BSD-4-Clause 3 * 4 * Copyright (c) 2003 5 * Bill Paul <wpaul@windriver.com>. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed by Bill Paul. 18 * 4. Neither the name of the author nor the names of any co-contributors 19 * may be used to endorse or promote products derived from this software 20 * without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD 26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 32 * THE POSSIBILITY OF SUCH DAMAGE. 33 * 34 * $FreeBSD$ 35 */ 36 37#ifndef _USBD_VAR_H_ 38#define _USBD_VAR_H_ 39 40#define IOCTL_INTERNAL_USB_SUBMIT_URB 0x00220003 41 42#define URB_FUNCTION_SELECT_CONFIGURATION 0x0000 43#define URB_FUNCTION_ABORT_PIPE 0x0002 44#define URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER 0x0009 45#define URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE 0x000B 46#define URB_FUNCTION_VENDOR_DEVICE 0x0017 47#define URB_FUNCTION_VENDOR_INTERFACE 0x0018 48#define URB_FUNCTION_VENDOR_ENDPOINT 0x0019 49#define URB_FUNCTION_CLASS_DEVICE 0x001A 50#define URB_FUNCTION_CLASS_INTERFACE 0x001B 51#define URB_FUNCTION_CLASS_ENDPOINT 0x001C 52#define URB_FUNCTION_CLASS_OTHER 0x001F 53#define URB_FUNCTION_VENDOR_OTHER 0x0020 54 55#define USBD_STATUS_SUCCESS 0x00000000 56#define USBD_STATUS_CANCELED 0x00010000 57#define USBD_STATUS_PENDING 0x40000000 58#define USBD_STATUS_NO_MEMORY 0x80000100 59#define USBD_STATUS_REQUEST_FAILED 0x80000500 60#define USBD_STATUS_INVALID_PIPE_HANDLE 0x80000600 61#define USBD_STATUS_ERROR_SHORT_TRANSFER 0x80000900 62#define USBD_STATUS_CRC 0xC0000001 63#define USBD_STATUS_BTSTUFF 0xC0000002 64#define USBD_STATUS_DATA_TOGGLE_MISMATCH 0xC0000003 65#define USBD_STATUS_STALL_PID 0xC0000004 66#define USBD_STATUS_DEV_NOT_RESPONDING 0xC0000005 67#define USBD_STATUS_PID_CHECK_FAILURE 0xC0000006 68#define USBD_STATUS_UNEXPECTED_PID 0xC0000007 69#define USBD_STATUS_DATA_OVERRUN 0xC0000008 70#define USBD_STATUS_DATA_UNDERRUN 0xC0000009 71#define USBD_STATUS_RESERVED1 0xC000000A 72#define USBD_STATUS_RESERVED2 0xC000000B 73#define USBD_STATUS_BUFFER_OVERRUN 0xC000000C 74#define USBD_STATUS_BUFFER_UNDERRUN 0xC000000D 75#define USBD_STATUS_NOT_ACCESSED 0xC000000F 76#define USBD_STATUS_FIFO 0xC0000010 77#define USBD_STATUS_XACT_ERROR 0xC0000011 78#define USBD_STATUS_BABBLE_DETECTED 0xC0000012 79#define USBD_STATUS_DATA_BUFFER_ERROR 0xC0000013 80#define USBD_STATUS_NOT_SUPPORTED 0xC0000E00 81#define USBD_STATUS_TIMEOUT 0xC0006000 82#define USBD_STATUS_DEVICE_GONE 0xC0007000 83 84struct usbd_urb_header { 85 uint16_t uuh_len; 86 uint16_t uuh_func; 87 int32_t uuh_status; 88 void *uuh_handle; 89 uint32_t uuh_flags; 90}; 91 92enum usbd_pipe_type { 93 UsbdPipeTypeControl = UE_CONTROL, 94 UsbdPipeTypeIsochronous = UE_ISOCHRONOUS, 95 UsbdPipeTypeBulk = UE_BULK, 96 UsbdPipeTypeInterrupt = UE_INTERRUPT 97}; 98 99struct usbd_pipe_information { 100 uint16_t upi_maxpktsize; 101 uint8_t upi_epaddr; 102 uint8_t upi_interval; 103 enum usbd_pipe_type upi_type; 104 usb_endpoint_descriptor_t *upi_handle; 105 uint32_t upi_maxtxsize; 106#define USBD_DEFAULT_MAXIMUM_TRANSFER_SIZE PAGE_SIZE 107 uint32_t upi_flags; 108}; 109 110struct usbd_interface_information { 111 uint16_t uii_len; 112 uint8_t uii_intfnum; 113 uint8_t uii_altset; 114 uint8_t uii_intfclass; 115 uint8_t uii_intfsubclass; 116 uint8_t uii_intfproto; 117 uint8_t uii_reserved; 118 void *uii_handle; 119 uint32_t uii_numeps; 120 struct usbd_pipe_information uii_pipes[1]; 121}; 122 123struct usbd_urb_select_interface { 124 struct usbd_urb_header usi_hdr; 125 void *usi_handle; 126 struct usbd_interface_information uusi_intf; 127}; 128 129struct usbd_urb_select_configuration { 130 struct usbd_urb_header usc_hdr; 131 usb_config_descriptor_t *usc_conf; 132 void *usc_handle; 133 struct usbd_interface_information usc_intf; 134}; 135 136struct usbd_urb_pipe_request { 137 struct usbd_urb_header upr_hdr; 138 usb_endpoint_descriptor_t *upr_handle; 139}; 140 141struct usbd_hcd_area { 142 void *reserved8[8]; 143}; 144 145struct usbd_urb_bulk_or_intr_transfer { 146 struct usbd_urb_header ubi_hdr; 147 usb_endpoint_descriptor_t *ubi_epdesc; 148 uint32_t ubi_trans_flags; 149#define USBD_SHORT_TRANSFER_OK 0x00000002 150 uint32_t ubi_trans_buflen; 151 void *ubi_trans_buf; 152 struct mdl *ubi_mdl; 153 union usbd_urb *ubi_urblink; 154 struct usbd_hcd_area ubi_hca; 155}; 156 157struct usbd_urb_control_descriptor_request { 158 struct usbd_urb_header ucd_hdr; 159 void *ucd_reserved0; 160 uint32_t ucd_reserved1; 161 uint32_t ucd_trans_buflen; 162 void *ucd_trans_buf; 163 struct mdl *ucd_mdl; 164 union nt_urb *ucd_urblink; 165 struct usbd_hcd_area ucd_hca; 166 uint16_t ucd_reserved2; 167 uint8_t ucd_idx; 168 uint8_t ucd_desctype; 169 uint16_t ucd_langid; 170 uint16_t ucd_reserved3; 171}; 172 173struct usbd_urb_vendor_or_class_request { 174 struct usbd_urb_header uvc_hdr; 175 void *uvc_reserved0; 176 uint32_t uvc_trans_flags; 177#define USBD_TRANSFER_DIRECTION_IN 1 178 uint32_t uvc_trans_buflen; 179 void *uvc_trans_buf; 180 struct mdl *uvc_mdl; 181 union nt_urb *uvc_urblink; 182 struct usbd_hcd_area uvc_hca; 183 uint8_t uvc_reserved1; 184 uint8_t uvc_req; 185 uint16_t uvc_value; 186 uint16_t uvc_idx; 187 uint16_t uvc_reserved2; 188}; 189 190struct usbd_interface_list_entry { 191 usb_interface_descriptor_t *uil_intfdesc; 192 struct usbd_interface_information *uil_intf; 193}; 194 195union usbd_urb { 196 struct usbd_urb_header uu_hdr; 197 struct usbd_urb_select_configuration uu_selconf; 198 struct usbd_urb_bulk_or_intr_transfer uu_bulkintr; 199 struct usbd_urb_control_descriptor_request uu_ctldesc; 200 struct usbd_urb_vendor_or_class_request uu_vcreq; 201 struct usbd_urb_pipe_request uu_pipe; 202}; 203 204#define USBD_URB_STATUS(urb) ((urb)->uu_hdr.uuh_status) 205 206#define USBDI_VERSION 0x00000500 207#define USB_VER_1_1 0x00000110 208#define USB_VER_2_0 0x00000200 209 210struct usbd_version_info { 211 uint32_t uvi_usbdi_vers; 212 uint32_t uvi_supported_vers; 213}; 214 215typedef struct usbd_version_info usbd_version_info; 216 217extern image_patch_table usbd_functbl[]; 218 219__BEGIN_DECLS 220extern int usbd_libinit(void); 221extern int usbd_libfini(void); 222__END_DECLS 223 224#endif /* _USBD_VAR_H_ */ 225