• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Windows backend common header for libusb 1.0
3  *
4  * This file brings together header code common between
5  * the desktop Windows backends.
6  * Copyright © 2012-2013 RealVNC Ltd.
7  * Copyright © 2009-2012 Pete Batard <pete@akeo.ie>
8  * With contributions from Michael Plante, Orin Eman et al.
9  * Parts of this code adapted from libusb-win32-v1 by Stephan Meyer
10  * Major code testing contribution by Xiaofan Chen
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public
14  * License as published by the Free Software Foundation; either
15  * version 2.1 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with this library; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25  */
26 
27 #pragma once
28 
29 // Missing from MinGW
30 #if !defined(FACILITY_SETUPAPI)
31 #define FACILITY_SETUPAPI	15
32 #endif
33 
34 typedef struct USB_CONFIGURATION_DESCRIPTOR {
35   UCHAR  bLength;
36   UCHAR  bDescriptorType;
37   USHORT wTotalLength;
38   UCHAR  bNumInterfaces;
39   UCHAR  bConfigurationValue;
40   UCHAR  iConfiguration;
41   UCHAR  bmAttributes;
42   UCHAR  MaxPower;
43 } USB_CONFIGURATION_DESCRIPTOR, *PUSB_CONFIGURATION_DESCRIPTOR;
44 
45 typedef struct libusb_device_descriptor USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR;
46 
47 int windows_common_init(struct libusb_context *ctx);
48 void windows_common_exit(void);
49 
50 unsigned long htab_hash(const char *str);
51 int windows_clock_gettime(int clk_id, struct timespec *tp);
52 
53 void windows_clear_transfer_priv(struct usbi_transfer *itransfer);
54 int windows_copy_transfer_data(struct usbi_transfer *itransfer, uint32_t io_size);
55 struct winfd *windows_get_fd(struct usbi_transfer *transfer);
56 void windows_get_overlapped_result(struct usbi_transfer *transfer, struct winfd *pollable_fd, DWORD *io_result, DWORD *io_size);
57 
58 void windows_handle_callback(struct usbi_transfer *itransfer, uint32_t io_result, uint32_t io_size);
59 int windows_handle_events(struct libusb_context *ctx, struct pollfd *fds, POLL_NFDS_TYPE nfds, int num_ready);
60 
61 #if defined(ENABLE_LOGGING)
62 const char *windows_error_str(DWORD retval);
63 #endif
64