usbd_var.h revision 186507
1142399Swpaul/*- 2142399Swpaul * Copyright (c) 2003 3142399Swpaul * Bill Paul <wpaul@windriver.com>. All rights reserved. 4142399Swpaul * 5142399Swpaul * Redistribution and use in source and binary forms, with or without 6142399Swpaul * modification, are permitted provided that the following conditions 7142399Swpaul * are met: 8142399Swpaul * 1. Redistributions of source code must retain the above copyright 9142399Swpaul * notice, this list of conditions and the following disclaimer. 10142399Swpaul * 2. Redistributions in binary form must reproduce the above copyright 11142399Swpaul * notice, this list of conditions and the following disclaimer in the 12142399Swpaul * documentation and/or other materials provided with the distribution. 13142399Swpaul * 3. All advertising materials mentioning features or use of this software 14142399Swpaul * must display the following acknowledgement: 15142399Swpaul * This product includes software developed by Bill Paul. 16142399Swpaul * 4. Neither the name of the author nor the names of any co-contributors 17142399Swpaul * may be used to endorse or promote products derived from this software 18142399Swpaul * without specific prior written permission. 19142399Swpaul * 20142399Swpaul * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND 21142399Swpaul * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22142399Swpaul * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23142399Swpaul * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD 24142399Swpaul * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25142399Swpaul * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26142399Swpaul * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27142399Swpaul * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28142399Swpaul * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29142399Swpaul * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30142399Swpaul * THE POSSIBILITY OF SUCH DAMAGE. 31142399Swpaul * 32142399Swpaul * $FreeBSD: head/sys/compat/ndis/usbd_var.h 186507 2008-12-27 08:03:32Z weongyo $ 33142399Swpaul */ 34142399Swpaul 35142399Swpaul#ifndef _USBD_VAR_H_ 36142399Swpaul#define _USBD_VAR_H_ 37142399Swpaul 38186507Sweongyo#define IOCTL_INTERNAL_USB_SUBMIT_URB 0x00220003 39142399Swpaul 40186507Sweongyo#define URB_FUNCTION_SELECT_CONFIGURATION 0x0000 41186507Sweongyo#define URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER 0x0009 42186507Sweongyo#define URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE 0x000B 43186507Sweongyo#define URB_FUNCTION_VENDOR_DEVICE 0x0017 44186507Sweongyo#define URB_FUNCTION_VENDOR_INTERFACE 0x0018 45186507Sweongyo#define URB_FUNCTION_VENDOR_ENDPOINT 0x0019 46186507Sweongyo#define URB_FUNCTION_CLASS_DEVICE 0x001A 47186507Sweongyo#define URB_FUNCTION_CLASS_INTERFACE 0x001B 48186507Sweongyo#define URB_FUNCTION_CLASS_ENDPOINT 0x001C 49186507Sweongyo#define URB_FUNCTION_CLASS_OTHER 0x001F 50186507Sweongyo#define URB_FUNCTION_VENDOR_OTHER 0x0020 51186507Sweongyo 52186507Sweongyo#define USBD_STATUS_SUCCESS 0x00000000 53186507Sweongyo#define USBD_STATUS_CANCELED 0x00010000 54186507Sweongyo#define USBD_STATUS_PENDING 0x40000000 55186507Sweongyo#define USBD_STATUS_NO_MEMORY 0x80000100 56186507Sweongyo#define USBD_STATUS_REQUEST_FAILED 0x80000500 57186507Sweongyo#define USBD_STATUS_INVALID_PIPE_HANDLE 0x80000600 58186507Sweongyo#define USBD_STATUS_ERROR_SHORT_TRANSFER 0x80000900 59186507Sweongyo#define USBD_STATUS_CRC 0xC0000001 60186507Sweongyo#define USBD_STATUS_BTSTUFF 0xC0000002 61186507Sweongyo#define USBD_STATUS_DATA_TOGGLE_MISMATCH 0xC0000003 62186507Sweongyo#define USBD_STATUS_STALL_PID 0xC0000004 63186507Sweongyo#define USBD_STATUS_DEV_NOT_RESPONDING 0xC0000005 64186507Sweongyo#define USBD_STATUS_PID_CHECK_FAILURE 0xC0000006 65186507Sweongyo#define USBD_STATUS_UNEXPECTED_PID 0xC0000007 66186507Sweongyo#define USBD_STATUS_DATA_OVERRUN 0xC0000008 67186507Sweongyo#define USBD_STATUS_DATA_UNDERRUN 0xC0000009 68186507Sweongyo#define USBD_STATUS_RESERVED1 0xC000000A 69186507Sweongyo#define USBD_STATUS_RESERVED2 0xC000000B 70186507Sweongyo#define USBD_STATUS_BUFFER_OVERRUN 0xC000000C 71186507Sweongyo#define USBD_STATUS_BUFFER_UNDERRUN 0xC000000D 72186507Sweongyo#define USBD_STATUS_NOT_ACCESSED 0xC000000F 73186507Sweongyo#define USBD_STATUS_FIFO 0xC0000010 74186507Sweongyo#define USBD_STATUS_XACT_ERROR 0xC0000011 75186507Sweongyo#define USBD_STATUS_BABBLE_DETECTED 0xC0000012 76186507Sweongyo#define USBD_STATUS_DATA_BUFFER_ERROR 0xC0000013 77186507Sweongyo#define USBD_STATUS_NOT_SUPPORTED 0xC0000E00 78186507Sweongyo#define USBD_STATUS_TIMEOUT 0xC0006000 79186507Sweongyo#define USBD_STATUS_DEVICE_GONE 0xC0007000 80186507Sweongyo 81186507Sweongyostruct usbd_urb_header { 82186507Sweongyo uint16_t uuh_len; 83186507Sweongyo uint16_t uuh_func; 84186507Sweongyo int32_t uuh_status; 85186507Sweongyo void *uuh_handle; 86186507Sweongyo uint32_t uuh_flags; 87186507Sweongyo}; 88186507Sweongyo 89186507Sweongyoenum usbd_pipe_type { 90186507Sweongyo UsbdPipeTypeControl = UE_CONTROL, 91186507Sweongyo UsbdPipeTypeIsochronous = UE_ISOCHRONOUS, 92186507Sweongyo UsbdPipeTypeBulk = UE_BULK, 93186507Sweongyo UsbdPipeTypeInterrupt = UE_INTERRUPT 94186507Sweongyo}; 95186507Sweongyo 96186507Sweongyostruct usbd_pipe_information { 97186507Sweongyo uint16_t upi_maxpktsize; 98186507Sweongyo uint8_t upi_epaddr; 99186507Sweongyo uint8_t upi_interval; 100186507Sweongyo enum usbd_pipe_type upi_type; 101186507Sweongyo usb_endpoint_descriptor_t *upi_handle; 102186507Sweongyo uint32_t upi_maxtxsize; 103186507Sweongyo#define USBD_DEFAULT_MAXIMUM_TRANSFER_SIZE PAGE_SIZE 104186507Sweongyo uint32_t upi_flags; 105186507Sweongyo}; 106186507Sweongyo 107186507Sweongyostruct usbd_interface_information { 108186507Sweongyo uint16_t uii_len; 109186507Sweongyo uint8_t uii_intfnum; 110186507Sweongyo uint8_t uii_altset; 111186507Sweongyo uint8_t uii_intfclass; 112186507Sweongyo uint8_t uii_intfsubclass; 113186507Sweongyo uint8_t uii_intfproto; 114186507Sweongyo uint8_t uii_reserved; 115186507Sweongyo void *uii_handle; 116186507Sweongyo uint32_t uii_numeps; 117186507Sweongyo struct usbd_pipe_information uii_pipes[1]; 118186507Sweongyo}; 119186507Sweongyo 120186507Sweongyostruct usbd_urb_select_interface { 121186507Sweongyo struct usbd_urb_header usi_hdr; 122186507Sweongyo void *usi_handle; 123186507Sweongyo struct usbd_interface_information uusi_intf; 124186507Sweongyo}; 125186507Sweongyo 126186507Sweongyostruct usbd_urb_select_configuration { 127186507Sweongyo struct usbd_urb_header usc_hdr; 128186507Sweongyo usb_config_descriptor_t *usc_conf; 129186507Sweongyo void *usc_handle; 130186507Sweongyo struct usbd_interface_information usc_intf; 131186507Sweongyo}; 132186507Sweongyo 133186507Sweongyostruct usbd_hcd_area { 134186507Sweongyo void *reserved8[8]; 135186507Sweongyo}; 136186507Sweongyo 137186507Sweongyostruct usbd_urb_bulk_or_intr_transfer { 138186507Sweongyo struct usbd_urb_header ubi_hdr; 139186507Sweongyo usb_endpoint_descriptor_t *ubi_epdesc; 140186507Sweongyo uint32_t ubi_trans_flags; 141186507Sweongyo#define USBD_SHORT_TRANSFER_OK 0x00000002 142186507Sweongyo uint32_t ubi_trans_buflen; 143186507Sweongyo void *ubi_trans_buf; 144186507Sweongyo struct mdl *ubi_mdl; 145186507Sweongyo union usbd_urb *ubi_urblink; 146186507Sweongyo struct usbd_hcd_area ubi_hca; 147186507Sweongyo}; 148186507Sweongyo 149186507Sweongyostruct usbd_urb_control_descriptor_request { 150186507Sweongyo struct usbd_urb_header ucd_hdr; 151186507Sweongyo void *ucd_reserved0; 152186507Sweongyo uint32_t ucd_reserved1; 153186507Sweongyo uint32_t ucd_trans_buflen; 154186507Sweongyo void *ucd_trans_buf; 155186507Sweongyo struct mdl *ucd_mdl; 156186507Sweongyo union nt_urb *ucd_urblink; 157186507Sweongyo struct usbd_hcd_area ucd_hca; 158186507Sweongyo uint16_t ucd_reserved2; 159186507Sweongyo uint8_t ucd_idx; 160186507Sweongyo uint8_t ucd_desctype; 161186507Sweongyo uint16_t ucd_langid; 162186507Sweongyo uint16_t ucd_reserved3; 163186507Sweongyo}; 164186507Sweongyo 165186507Sweongyostruct usbd_urb_vendor_or_class_request { 166186507Sweongyo struct usbd_urb_header uvc_hdr; 167186507Sweongyo void *uvc_reserved0; 168186507Sweongyo uint32_t uvc_trans_flags; 169186507Sweongyo#define USBD_TRANSFER_DIRECTION_IN 1 170186507Sweongyo uint32_t uvc_trans_buflen; 171186507Sweongyo void *uvc_trans_buf; 172186507Sweongyo struct mdl *uvc_mdl; 173186507Sweongyo union nt_urb *uvc_urblink; 174186507Sweongyo struct usbd_hcd_area uvc_hca; 175186507Sweongyo uint8_t uvc_reserved1; 176186507Sweongyo uint8_t uvc_req; 177186507Sweongyo uint16_t uvc_value; 178186507Sweongyo uint16_t uvc_idx; 179186507Sweongyo uint16_t uvc_reserved2; 180186507Sweongyo}; 181186507Sweongyo 182186507Sweongyostruct usbd_interface_list_entry { 183186507Sweongyo usb_interface_descriptor_t *uil_intfdesc; 184186507Sweongyo struct usbd_interface_information *uil_intf; 185186507Sweongyo}; 186186507Sweongyo 187186507Sweongyounion usbd_urb { 188186507Sweongyo struct usbd_urb_header uu_hdr; 189186507Sweongyo struct usbd_urb_select_configuration uu_selconf; 190186507Sweongyo struct usbd_urb_bulk_or_intr_transfer uu_bulkintr; 191186507Sweongyo struct usbd_urb_control_descriptor_request uu_ctldesc; 192186507Sweongyo struct usbd_urb_vendor_or_class_request uu_vcreq; 193186507Sweongyo}; 194186507Sweongyo 195186507Sweongyo#define USBD_URB_STATUS(urb) ((urb)->uu_hdr.uuh_status) 196186507Sweongyo 197186507Sweongyo#define USBDI_VERSION 0x00000500 198186507Sweongyo#define USB_VER_1_1 0x00000110 199186507Sweongyo#define USB_VER_2_0 0x00000200 200186507Sweongyo 201142399Swpaulstruct usbd_version_info { 202142399Swpaul uint32_t uvi_usbdi_vers; 203142399Swpaul uint32_t uvi_supported_vers; 204142399Swpaul}; 205142399Swpaul 206142399Swpaultypedef struct usbd_version_info usbd_version_info; 207142399Swpaul 208186507Sweongyo/* used for IRP cancel. */ 209186507Sweongyostruct ndisusb_cancel { 210186507Sweongyo device_t dev; 211186507Sweongyo usbd_xfer_handle xfer; 212186507Sweongyo struct usb_task task; 213186507Sweongyo}; 214186507Sweongyo 215142399Swpaulextern image_patch_table usbd_functbl[]; 216142399Swpaul 217142399Swpaul__BEGIN_DECLS 218142399Swpaulextern int usbd_libinit(void); 219142399Swpaulextern int usbd_libfini(void); 220142399Swpaul__END_DECLS 221142399Swpaul 222142399Swpaul#endif /* _USBD_VAR_H_ */ 223