1
/* LIBUSB-WIN32, Generic Windows USB Library
2
* Copyright (c) 2002-2005 Stephan Meyer <ste_meyer@web.de>
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
#ifndef __LIBUSB_DRIVER_H__
21
#define __LIBUSB_DRIVER_H__
24
#include <ddk/usb100.h>
25
#include <ddk/usbdi.h>
26
#include <ddk/winddk.h>
27
#include "usbdlib_gcc.h"
39
#include "driver_debug.h"
40
#include "driver_api.h"
42
/* some missing defines */
45
#define USBD_TRANSFER_DIRECTION_OUT 0
46
#define USBD_TRANSFER_DIRECTION_BIT 0
47
#define USBD_TRANSFER_DIRECTION_IN (1 << USBD_TRANSFER_DIRECTION_BIT)
48
#define USBD_SHORT_TRANSFER_OK_BIT 1
49
#define USBD_SHORT_TRANSFER_OK (1 << USBD_SHORT_TRANSFER_OK_BIT)
50
#define USBD_START_ISO_TRANSFER_ASAP_BIT 2
51
#define USBD_START_ISO_TRANSFER_ASAP (1 << USBD_START_ISO_TRANSFER_ASAP_BIT)
56
#define USB_RECIP_DEVICE 0x00
57
#define USB_RECIP_INTERFACE 0x01
58
#define USB_RECIP_ENDPOINT 0x02
59
#define USB_RECIP_OTHER 0x03
61
#define USB_TYPE_STANDARD 0x00
62
#define USB_TYPE_CLASS 0x01
63
#define USB_TYPE_VENDOR 0x02
66
#define LIBUSB0_NT_DEVICE_NAME L"\\Device\\libusb0"
67
#define LIBUSB0_SYMBOLIC_LINK_NAME L"\\DosDevices\\libusb0-"
69
#define LIBUSB0_MAX_NUMBER_OF_ENDPOINTS 32
70
#define LIBUSB0_MAX_NUMBER_OF_INTERFACES 32
73
#define LIBUSB0_DEFAULT_TIMEOUT 5000
74
#define LIBUSB0_MAX_CONTROL_TRANSFER_TIMEOUT 240000
86
#define TRUE (!(FALSE))
97
} usb_descriptor_header_t;
107
} libusb_remove_lock_t;
112
USBD_PIPE_HANDLE handle;
119
libusb_endpoint_t endpoints[LIBUSB0_MAX_NUMBER_OF_ENDPOINTS];
120
} libusb_interface_t;
126
DEVICE_OBJECT *physical_device_object;
127
DEVICE_OBJECT *next_stack_device;
128
DEVICE_OBJECT *target_device;
129
libusb_remove_lock_t remove_lock;
133
bool_t surprise_removal_ok;
136
USBD_CONFIGURATION_HANDLE handle;
138
libusb_interface_t interfaces[LIBUSB0_MAX_NUMBER_OF_INTERFACES];
140
POWER_STATE power_state;
141
DEVICE_POWER_STATE device_power_states[PowerSystemMaximum];
146
NTSTATUS DDKAPI add_device(DRIVER_OBJECT *driver_object,
147
DEVICE_OBJECT *physical_device_object);
149
NTSTATUS DDKAPI dispatch(DEVICE_OBJECT *device_object, IRP *irp);
150
NTSTATUS dispatch_pnp(libusb_device_t *dev, IRP *irp);
151
NTSTATUS dispatch_power(libusb_device_t *dev, IRP *irp);
152
NTSTATUS dispatch_ioctl(libusb_device_t *dev, IRP *irp);
154
NTSTATUS complete_irp(IRP *irp, NTSTATUS status, ULONG info);
156
NTSTATUS call_usbd(libusb_device_t *dev, void *urb,
157
ULONG control_code, int timeout);
158
NTSTATUS pass_irp_down(libusb_device_t *dev, IRP *irp,
159
PIO_COMPLETION_ROUTINE completion_routine,
162
bool_t accept_irp(libusb_device_t *dev, IRP *irp);
164
bool_t get_pipe_handle(libusb_device_t *dev, int endpoint_address,
165
USBD_PIPE_HANDLE *pipe_handle);
166
void clear_pipe_info(libusb_device_t *dev);
167
bool_t update_pipe_info(libusb_device_t *dev,
168
USBD_INTERFACE_INFORMATION *interface_info);
170
void remove_lock_initialize(libusb_device_t *dev);
171
NTSTATUS remove_lock_acquire(libusb_device_t *dev);
172
void remove_lock_release(libusb_device_t *dev);
173
void remove_lock_release_and_wait(libusb_device_t *dev);
175
NTSTATUS set_configuration(libusb_device_t *dev,
176
int configuration, int timeout);
177
NTSTATUS get_configuration(libusb_device_t *dev,
178
unsigned char *configuration, int *ret,
180
NTSTATUS set_interface(libusb_device_t *dev,
181
int interface, int altsetting, int timeout);
182
NTSTATUS get_interface(libusb_device_t *dev,
183
int interface, unsigned char *altsetting,
184
int *ret, int timeout);
185
NTSTATUS set_feature(libusb_device_t *dev,
186
int recipient, int index, int feature, int timeout);
187
NTSTATUS clear_feature(libusb_device_t *dev,
188
int recipient, int index, int feature, int timeout);
189
NTSTATUS get_status(libusb_device_t *dev, int recipient,
190
int index, char *status, int *ret, int timeout);
191
NTSTATUS set_descriptor(libusb_device_t *dev,
192
void *buffer, int size,
193
int type, int recipient, int index, int language_id,
194
int *sent, int timeout);
195
NTSTATUS get_descriptor(libusb_device_t *dev, void *buffer, int size,
196
int type, int recipient, int index, int language_id,
197
int *received, int timeout);
198
USB_CONFIGURATION_DESCRIPTOR *
199
get_config_descriptor(libusb_device_t *dev, int value, int *size);
201
NTSTATUS transfer(libusb_device_t *dev, IRP *irp,
202
int direction, int urb_function, int endpoint,
203
int packet_size, MDL *buffer, int size);
205
NTSTATUS vendor_class_request(libusb_device_t *dev,
206
int type, int recipient,
207
int request, int value, int index,
208
void *buffer, int size, int direction,
209
int *ret, int timeout);
211
NTSTATUS abort_endpoint(libusb_device_t *dev, int endpoint, int timeout);
212
NTSTATUS reset_endpoint(libusb_device_t *dev, int endpoint, int timeout);
213
NTSTATUS reset_device(libusb_device_t *dev, int timeout);
215
NTSTATUS claim_interface(libusb_device_t *dev, int interface);
216
NTSTATUS release_interface(libusb_device_t *dev, int interface);
217
NTSTATUS release_all_interfaces(libusb_device_t *dev);
220
bool_t reg_get_hardware_id(DEVICE_OBJECT *physical_device_object,
221
char *data, int size);
222
bool_t reg_get_properties(libusb_device_t *dev);
225
void power_set_device_state(libusb_device_t *dev,
226
DEVICE_POWER_STATE device_state, bool_t block);
228
USB_INTERFACE_DESCRIPTOR *
229
find_interface_desc(USB_CONFIGURATION_DESCRIPTOR *config_desc,
230
unsigned int size, int interface_number, int altsetting);