usb 1.7.2 → 1.8.0-libusb.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitmodules +1 -1
- package/Readme.md +2 -2
- package/binding.gyp +2 -2
- package/libusb/.private/pre-commit.sh +7 -1
- package/libusb/.travis.yml +49 -0
- package/libusb/AUTHORS +44 -3
- package/libusb/Brewfile +4 -0
- package/libusb/ChangeLog +74 -2
- package/libusb/README.md +32 -0
- package/libusb/TODO +1 -1
- package/libusb/Xcode/common.xcconfig +12 -0
- package/libusb/Xcode/config.h +25 -0
- package/libusb/Xcode/libusb.xcodeproj/project.pbxproj +959 -1
- package/libusb/android/README +4 -2
- package/libusb/android/config.h +75 -0
- package/libusb/appveyor.yml +41 -0
- package/libusb/appveyor_cygwin.bat +11 -0
- package/libusb/appveyor_minGW.bat +19 -0
- package/libusb/autogen.sh +1 -1
- package/libusb/bootstrap.sh +3 -16
- package/libusb/configure.ac +108 -80
- package/libusb/doc/doxygen.cfg.in +1785 -739
- package/libusb/examples/Makefile.am +1 -1
- package/libusb/examples/dpfp.c +3 -1
- package/libusb/examples/dpfp_threaded.c +23 -10
- package/libusb/examples/ezusb.c +3 -3
- package/libusb/examples/ezusb.h +2 -2
- package/libusb/examples/fxload.c +31 -9
- package/libusb/examples/hotplugtest.c +35 -7
- package/libusb/examples/listdevs.c +3 -1
- package/libusb/examples/sam3u_benchmark.c +3 -3
- package/libusb/examples/testlibusb.c +277 -0
- package/libusb/examples/xusb.c +40 -34
- package/libusb/libusb/Makefile.am +49 -23
- package/libusb/libusb/core.c +855 -457
- package/libusb/libusb/descriptor.c +72 -78
- package/libusb/libusb/hotplug.c +122 -76
- package/libusb/libusb/hotplug.h +42 -25
- package/libusb/libusb/io.c +625 -390
- package/libusb/libusb/libusb-1.0.def +12 -0
- package/libusb/libusb/libusb.h +218 -150
- package/libusb/libusb/libusbi.h +346 -176
- package/libusb/libusb/os/darwin_usb.c +604 -319
- package/libusb/libusb/os/darwin_usb.h +61 -20
- package/libusb/libusb/os/haiku_pollfs.cpp +367 -0
- package/libusb/libusb/os/haiku_usb.h +113 -0
- package/libusb/libusb/os/haiku_usb_backend.cpp +533 -0
- package/libusb/libusb/os/haiku_usb_raw.cpp +267 -0
- package/libusb/libusb/os/haiku_usb_raw.h +188 -0
- package/libusb/libusb/os/linux_netlink.c +186 -146
- package/libusb/libusb/os/linux_udev.c +36 -14
- package/libusb/libusb/os/linux_usbfs.c +426 -225
- package/libusb/libusb/os/linux_usbfs.h +5 -3
- package/libusb/libusb/os/netbsd_usb.c +21 -77
- package/libusb/libusb/os/openbsd_usb.c +32 -115
- package/libusb/libusb/os/poll_posix.c +38 -5
- package/libusb/libusb/os/poll_posix.h +3 -0
- package/libusb/libusb/os/poll_windows.c +277 -626
- package/libusb/libusb/os/poll_windows.h +11 -44
- package/libusb/libusb/os/sunos_usb.c +1695 -0
- package/libusb/libusb/os/sunos_usb.h +80 -0
- package/libusb/libusb/os/threads_posix.c +24 -26
- package/libusb/libusb/os/threads_posix.h +73 -21
- package/libusb/libusb/os/threads_windows.c +71 -157
- package/libusb/libusb/os/threads_windows.h +68 -44
- package/libusb/libusb/os/wince_usb.c +276 -420
- package/libusb/libusb/os/wince_usb.h +23 -28
- package/libusb/libusb/os/windows_common.h +78 -58
- package/libusb/libusb/os/windows_nt_common.c +1010 -0
- package/libusb/libusb/os/windows_nt_common.h +110 -0
- package/libusb/libusb/os/windows_nt_shared_types.h +147 -0
- package/libusb/libusb/os/windows_usbdk.c +830 -0
- package/libusb/libusb/os/windows_usbdk.h +103 -0
- package/libusb/libusb/os/windows_winusb.c +4391 -0
- package/libusb/libusb/os/windows_winusb.h +783 -0
- package/libusb/libusb/strerror.c +41 -7
- package/libusb/libusb/sync.c +41 -13
- package/libusb/libusb/version.h +1 -1
- package/libusb/libusb/version_nano.h +1 -1
- package/libusb/libusb-1.0.pc.in +1 -1
- package/libusb/msvc/appveyor.bat +27 -0
- package/libusb/msvc/config.h +5 -4
- package/libusb/msvc/ddk_build.cmd +87 -43
- package/libusb/msvc/fxload_2010.vcxproj +24 -104
- package/libusb/msvc/fxload_2012.vcxproj +24 -107
- package/libusb/msvc/fxload_2013.vcxproj +24 -107
- package/libusb/msvc/fxload_2015.vcxproj +91 -0
- package/libusb/msvc/fxload_2017.vcxproj +114 -0
- package/libusb/msvc/fxload_sources +1 -1
- package/libusb/msvc/getopt_2010.vcxproj +16 -75
- package/libusb/msvc/getopt_2012.vcxproj +16 -79
- package/libusb/msvc/getopt_2013.vcxproj +16 -79
- package/libusb/msvc/getopt_2015.vcxproj +73 -0
- package/libusb/msvc/getopt_2017.vcxproj +98 -0
- package/libusb/msvc/getopt_sources +6 -2
- package/libusb/msvc/hotplugtest_2010.vcxproj +18 -99
- package/libusb/msvc/hotplugtest_2012.vcxproj +18 -102
- package/libusb/msvc/hotplugtest_2013.vcxproj +18 -102
- package/libusb/msvc/hotplugtest_2015.vcxproj +83 -0
- package/libusb/msvc/hotplugtest_2017.vcxproj +106 -0
- package/libusb/msvc/hotplugtest_sources +1 -1
- package/libusb/msvc/libusb_2005.sln +20 -20
- package/libusb/msvc/libusb_2010.sln +57 -46
- package/libusb/msvc/libusb_2012.sln +57 -46
- package/libusb/msvc/libusb_2013.sln +57 -50
- package/libusb/msvc/libusb_2015.sln +59 -52
- package/libusb/msvc/libusb_2017.sln +186 -0
- package/libusb/msvc/libusb_dll.dsp +2 -2
- package/libusb/msvc/libusb_dll_2005.vcproj +30 -2
- package/libusb/msvc/libusb_dll_2010.vcxproj +26 -90
- package/libusb/msvc/libusb_dll_2012.vcxproj +28 -96
- package/libusb/msvc/libusb_dll_2013.vcxproj +28 -96
- package/libusb/msvc/libusb_dll_2015.vcxproj +107 -0
- package/libusb/msvc/libusb_dll_2017.vcxproj +134 -0
- package/libusb/msvc/libusb_dll_wince.vcproj +9 -1
- package/libusb/msvc/libusb_sources +10 -5
- package/libusb/msvc/libusb_static.dsp +2 -2
- package/libusb/msvc/libusb_static_2005.vcproj +32 -4
- package/libusb/msvc/libusb_static_2010.vcxproj +24 -83
- package/libusb/msvc/libusb_static_2012.vcxproj +25 -87
- package/libusb/msvc/libusb_static_2013.vcxproj +25 -87
- package/libusb/msvc/libusb_static_2015.vcxproj +98 -0
- package/libusb/msvc/libusb_static_2017.vcxproj +117 -0
- package/libusb/msvc/libusb_static_wince.vcproj +20 -26
- package/libusb/msvc/libusb_wince.sln +88 -88
- package/libusb/msvc/listdevs_2010.vcxproj +16 -99
- package/libusb/msvc/listdevs_2012.vcxproj +16 -102
- package/libusb/msvc/listdevs_2013.vcxproj +16 -102
- package/libusb/msvc/listdevs_2015.vcxproj +83 -0
- package/libusb/msvc/listdevs_2017.vcxproj +106 -0
- package/libusb/msvc/listdevs_sources +2 -1
- package/libusb/msvc/stress_2010.vcxproj +20 -101
- package/libusb/msvc/stress_2012.vcxproj +20 -104
- package/libusb/msvc/stress_2013.vcxproj +20 -104
- package/libusb/msvc/stress_2015.vcxproj +87 -0
- package/libusb/msvc/stress_2017.vcxproj +110 -0
- package/libusb/msvc/stress_sources +21 -0
- package/libusb/msvc/testlibusb_2010.vcxproj +82 -0
- package/libusb/msvc/testlibusb_2012.vcxproj +83 -0
- package/libusb/msvc/testlibusb_2013.vcxproj +83 -0
- package/libusb/msvc/testlibusb_2015.vcxproj +83 -0
- package/libusb/msvc/testlibusb_2017.vcxproj +106 -0
- package/libusb/msvc/testlibusb_sources +20 -0
- package/libusb/msvc/xusb_2010.vcxproj +17 -98
- package/libusb/msvc/xusb_2012.vcxproj +17 -101
- package/libusb/msvc/xusb_2013.vcxproj +17 -101
- package/libusb/msvc/xusb_2015.vcxproj +83 -0
- package/libusb/msvc/xusb_2017.vcxproj +106 -0
- package/libusb/msvc/xusb_sources +1 -1
- package/libusb/tests/stress.c +2 -2
- package/libusb/tests/testlib.c +0 -4
- package/libusb/travis-autogen.sh +39 -0
- package/libusb.gypi +13 -2
- package/package.json +20 -11
- package/prebuilds/android-arm/node.napi.armv7.node +0 -0
- package/prebuilds/android-arm64/node.napi.armv8.node +0 -0
- package/prebuilds/darwin-x64+arm64/node.napi.node +0 -0
- package/prebuilds/linux-arm/node.napi.armv6.node +0 -0
- package/prebuilds/linux-arm/node.napi.armv7.node +0 -0
- package/prebuilds/linux-arm64/node.napi.armv8.node +0 -0
- package/prebuilds/linux-ia32/node.napi.node +0 -0
- package/prebuilds/linux-x64/node.napi.glibc.node +0 -0
- package/prebuilds/linux-x64/node.napi.musl.node +0 -0
- package/prebuilds/win32-ia32/node.napi.node +0 -0
- package/prebuilds/win32-x64/node.napi.node +0 -0
- package/src/device.cc +1 -1
- package/usb.js +1 -1
- package/.github/workflows/prebuild.yml +0 -49
- package/libusb/INSTALL +0 -234
- package/libusb/README +0 -28
- package/libusb/libusb/os/windows_usb.c +0 -5347
- package/libusb/libusb/os/windows_usb.h +0 -971
- package/libusb/msvc/fxload_2010.vcxproj.filters +0 -25
- package/libusb/msvc/fxload_2012.vcxproj.filters +0 -25
- package/libusb/msvc/getopt_2010.vcxproj.filters +0 -26
- package/libusb/msvc/getopt_2012.vcxproj.filters +0 -26
- package/libusb/msvc/hotplugtest_2010.vcxproj.filters +0 -14
- package/libusb/msvc/hotplugtest_2012.vcxproj.filters +0 -14
- package/libusb/msvc/libusb_dll_2010.vcxproj.filters +0 -81
- package/libusb/msvc/libusb_dll_2012.vcxproj.filters +0 -84
- package/libusb/msvc/libusb_static_2010.vcxproj.filters +0 -74
- package/libusb/msvc/libusb_static_2012.vcxproj.filters +0 -74
- package/libusb/msvc/listdevs_2010.vcxproj.filters +0 -14
- package/libusb/msvc/listdevs_2012.vcxproj.filters +0 -14
- package/libusb/msvc/stress_2010.vcxproj.filters +0 -25
- package/libusb/msvc/stress_2012.vcxproj.filters +0 -25
- package/libusb/msvc/xusb_2010.vcxproj.filters +0 -14
- package/libusb/msvc/xusb_2012.vcxproj.filters +0 -14
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Haiku Backend for libusb
|
|
3
|
+
* Copyright © 2014 Akshay Jaggi <akshay1994.leo@gmail.com>
|
|
4
|
+
*
|
|
5
|
+
* This library is free software; you can redistribute it and/or
|
|
6
|
+
* modify it under the terms of the GNU Lesser General Public
|
|
7
|
+
* License as published by the Free Software Foundation; either
|
|
8
|
+
* version 2.1 of the License, or (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* This library is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
13
|
+
* Lesser General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Lesser General Public
|
|
16
|
+
* License along with this library; if not, write to the Free Software
|
|
17
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
#include <unistd.h>
|
|
22
|
+
#include <string.h>
|
|
23
|
+
#include <stdlib.h>
|
|
24
|
+
#include <new>
|
|
25
|
+
#include <vector>
|
|
26
|
+
|
|
27
|
+
#include "haiku_usb.h"
|
|
28
|
+
|
|
29
|
+
USBRoster gUsbRoster;
|
|
30
|
+
int32 gInitCount = 0;
|
|
31
|
+
|
|
32
|
+
static int haiku_get_config_descriptor(struct libusb_device *, uint8_t,
|
|
33
|
+
unsigned char *, size_t, int *);
|
|
34
|
+
|
|
35
|
+
static int
|
|
36
|
+
haiku_init(struct libusb_context *ctx)
|
|
37
|
+
{
|
|
38
|
+
if (atomic_add(&gInitCount, 1) == 0)
|
|
39
|
+
return gUsbRoster.Start();
|
|
40
|
+
return LIBUSB_SUCCESS;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
static void
|
|
44
|
+
haiku_exit(struct libusb_context *ctx)
|
|
45
|
+
{
|
|
46
|
+
UNUSED(ctx);
|
|
47
|
+
if (atomic_add(&gInitCount, -1) == 1)
|
|
48
|
+
gUsbRoster.Stop();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
static int
|
|
52
|
+
haiku_open(struct libusb_device_handle *dev_handle)
|
|
53
|
+
{
|
|
54
|
+
USBDevice *dev = *((USBDevice **)dev_handle->dev->os_priv);
|
|
55
|
+
USBDeviceHandle *handle = new(std::nothrow) USBDeviceHandle(dev);
|
|
56
|
+
if (handle == NULL)
|
|
57
|
+
return LIBUSB_ERROR_NO_MEM;
|
|
58
|
+
if (handle->InitCheck() == false) {
|
|
59
|
+
delete handle;
|
|
60
|
+
return LIBUSB_ERROR_NO_DEVICE;
|
|
61
|
+
}
|
|
62
|
+
*((USBDeviceHandle **)dev_handle->os_priv) = handle;
|
|
63
|
+
return LIBUSB_SUCCESS;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
static void
|
|
67
|
+
haiku_close(struct libusb_device_handle *dev_handle)
|
|
68
|
+
{
|
|
69
|
+
USBDeviceHandle *handle = *((USBDeviceHandle **)dev_handle->os_priv);
|
|
70
|
+
if (handle == NULL)
|
|
71
|
+
return;
|
|
72
|
+
delete handle;
|
|
73
|
+
*((USBDeviceHandle **)dev_handle->os_priv) = NULL;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
static int
|
|
77
|
+
haiku_get_device_descriptor(struct libusb_device *device, unsigned char *buffer, int *host_endian)
|
|
78
|
+
{
|
|
79
|
+
USBDevice *dev = *((USBDevice **)device->os_priv);
|
|
80
|
+
memcpy(buffer, dev->Descriptor(), DEVICE_DESC_LENGTH);
|
|
81
|
+
*host_endian = 0;
|
|
82
|
+
return LIBUSB_SUCCESS;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
static int
|
|
86
|
+
haiku_get_active_config_descriptor(struct libusb_device *device, unsigned char *buffer, size_t len, int *host_endian)
|
|
87
|
+
{
|
|
88
|
+
USBDevice *dev = *((USBDevice **)device->os_priv);
|
|
89
|
+
return haiku_get_config_descriptor(device, dev->ActiveConfigurationIndex(), buffer, len, host_endian);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
static int
|
|
93
|
+
haiku_get_config_descriptor(struct libusb_device *device, uint8_t config_index, unsigned char *buffer, size_t len, int *host_endian)
|
|
94
|
+
{
|
|
95
|
+
USBDevice *dev = *((USBDevice **)device->os_priv);
|
|
96
|
+
const usb_configuration_descriptor *config = dev->ConfigurationDescriptor(config_index);
|
|
97
|
+
if (config == NULL) {
|
|
98
|
+
usbi_err(DEVICE_CTX(device), "failed getting configuration descriptor");
|
|
99
|
+
return LIBUSB_ERROR_INVALID_PARAM;
|
|
100
|
+
}
|
|
101
|
+
if (len > config->total_length) {
|
|
102
|
+
len = config->total_length;
|
|
103
|
+
}
|
|
104
|
+
memcpy(buffer, config, len);
|
|
105
|
+
*host_endian = 0;
|
|
106
|
+
return len;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
static int
|
|
110
|
+
haiku_set_configuration(struct libusb_device_handle *dev_handle, int config)
|
|
111
|
+
{
|
|
112
|
+
USBDeviceHandle *handle= *((USBDeviceHandle **)dev_handle->os_priv);
|
|
113
|
+
return handle->SetConfiguration(config);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
static int
|
|
117
|
+
haiku_claim_interface(struct libusb_device_handle *dev_handle, int interface_number)
|
|
118
|
+
{
|
|
119
|
+
USBDeviceHandle *handle = *((USBDeviceHandle **)dev_handle->os_priv);
|
|
120
|
+
return handle->ClaimInterface(interface_number);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
static int
|
|
124
|
+
haiku_set_altsetting(struct libusb_device_handle *dev_handle, int interface_number, int altsetting)
|
|
125
|
+
{
|
|
126
|
+
USBDeviceHandle *handle = *((USBDeviceHandle **)dev_handle->os_priv);
|
|
127
|
+
return handle->SetAltSetting(interface_number, altsetting);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
static int
|
|
131
|
+
haiku_clear_halt(struct libusb_device_handle *dev_handle, unsigned char endpoint)
|
|
132
|
+
{
|
|
133
|
+
USBDeviceHandle *handle = *((USBDeviceHandle **)dev_handle->os_priv);
|
|
134
|
+
return handle->ClearHalt(endpoint);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
static int
|
|
138
|
+
haiku_reset_device(struct libusb_device_handle *dev_handle)
|
|
139
|
+
{
|
|
140
|
+
/* TODO */
|
|
141
|
+
return LIBUSB_ERROR_NOT_SUPPORTED;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
static int
|
|
145
|
+
haiku_release_interface(struct libusb_device_handle *dev_handle, int interface_number)
|
|
146
|
+
{
|
|
147
|
+
USBDeviceHandle *handle = *((USBDeviceHandle **)dev_handle->os_priv);
|
|
148
|
+
haiku_set_altsetting(dev_handle,interface_number, 0);
|
|
149
|
+
return handle->ReleaseInterface(interface_number);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
static int
|
|
153
|
+
haiku_submit_transfer(struct usbi_transfer *itransfer)
|
|
154
|
+
{
|
|
155
|
+
struct libusb_transfer *fLibusbTransfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
|
|
156
|
+
USBDeviceHandle *fDeviceHandle = *((USBDeviceHandle **)fLibusbTransfer->dev_handle->os_priv);
|
|
157
|
+
return fDeviceHandle->SubmitTransfer(itransfer);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
static int
|
|
161
|
+
haiku_cancel_transfer(struct usbi_transfer *itransfer)
|
|
162
|
+
{
|
|
163
|
+
struct libusb_transfer *fLibusbTransfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
|
|
164
|
+
USBDeviceHandle *fDeviceHandle = *((USBDeviceHandle **)fLibusbTransfer->dev_handle->os_priv);
|
|
165
|
+
return fDeviceHandle->CancelTransfer(*((USBTransfer **)usbi_transfer_get_os_priv(itransfer)));
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
static void
|
|
169
|
+
haiku_clear_transfer_priv(struct usbi_transfer *itransfer)
|
|
170
|
+
{
|
|
171
|
+
USBTransfer *transfer = *((USBTransfer **)usbi_transfer_get_os_priv(itransfer));
|
|
172
|
+
delete transfer;
|
|
173
|
+
*((USBTransfer **)usbi_transfer_get_os_priv(itransfer)) = NULL;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
static int
|
|
177
|
+
haiku_handle_transfer_completion(struct usbi_transfer *itransfer)
|
|
178
|
+
{
|
|
179
|
+
USBTransfer *transfer = *((USBTransfer **)usbi_transfer_get_os_priv(itransfer));
|
|
180
|
+
|
|
181
|
+
usbi_mutex_lock(&itransfer->lock);
|
|
182
|
+
if (transfer->IsCancelled()) {
|
|
183
|
+
delete transfer;
|
|
184
|
+
*((USBTransfer **)usbi_transfer_get_os_priv(itransfer)) = NULL;
|
|
185
|
+
usbi_mutex_unlock(&itransfer->lock);
|
|
186
|
+
if (itransfer->transferred < 0)
|
|
187
|
+
itransfer->transferred = 0;
|
|
188
|
+
return usbi_handle_transfer_cancellation(itransfer);
|
|
189
|
+
}
|
|
190
|
+
libusb_transfer_status status = LIBUSB_TRANSFER_COMPLETED;
|
|
191
|
+
if (itransfer->transferred < 0) {
|
|
192
|
+
usbi_err(ITRANSFER_CTX(itransfer), "error in transfer");
|
|
193
|
+
status = LIBUSB_TRANSFER_ERROR;
|
|
194
|
+
itransfer->transferred = 0;
|
|
195
|
+
}
|
|
196
|
+
delete transfer;
|
|
197
|
+
*((USBTransfer **)usbi_transfer_get_os_priv(itransfer)) = NULL;
|
|
198
|
+
usbi_mutex_unlock(&itransfer->lock);
|
|
199
|
+
return usbi_handle_transfer_completion(itransfer, status);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
static int
|
|
203
|
+
haiku_clock_gettime(int clkid, struct timespec *tp)
|
|
204
|
+
{
|
|
205
|
+
if (clkid == USBI_CLOCK_REALTIME)
|
|
206
|
+
return clock_gettime(CLOCK_REALTIME, tp);
|
|
207
|
+
if (clkid == USBI_CLOCK_MONOTONIC)
|
|
208
|
+
return clock_gettime(CLOCK_MONOTONIC, tp);
|
|
209
|
+
return LIBUSB_ERROR_INVALID_PARAM;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const struct usbi_os_backend usbi_backend = {
|
|
213
|
+
.name = "Haiku usbfs",
|
|
214
|
+
.caps = 0,
|
|
215
|
+
.init = haiku_init,
|
|
216
|
+
.exit = haiku_exit,
|
|
217
|
+
.set_option = NULL,
|
|
218
|
+
.get_device_list = NULL,
|
|
219
|
+
.hotplug_poll = NULL,
|
|
220
|
+
.wrap_sys_device = NULL,
|
|
221
|
+
.open = haiku_open,
|
|
222
|
+
.close = haiku_close,
|
|
223
|
+
.get_device_descriptor = haiku_get_device_descriptor,
|
|
224
|
+
.get_active_config_descriptor = haiku_get_active_config_descriptor,
|
|
225
|
+
.get_config_descriptor = haiku_get_config_descriptor,
|
|
226
|
+
.get_config_descriptor_by_value = NULL,
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
.get_configuration = NULL,
|
|
230
|
+
.set_configuration = haiku_set_configuration,
|
|
231
|
+
.claim_interface = haiku_claim_interface,
|
|
232
|
+
.release_interface = haiku_release_interface,
|
|
233
|
+
|
|
234
|
+
.set_interface_altsetting = haiku_set_altsetting,
|
|
235
|
+
.clear_halt = haiku_clear_halt,
|
|
236
|
+
.reset_device = haiku_reset_device,
|
|
237
|
+
|
|
238
|
+
.alloc_streams = NULL,
|
|
239
|
+
.free_streams = NULL,
|
|
240
|
+
|
|
241
|
+
.dev_mem_alloc = NULL,
|
|
242
|
+
.dev_mem_free = NULL,
|
|
243
|
+
|
|
244
|
+
.kernel_driver_active = NULL,
|
|
245
|
+
.detach_kernel_driver = NULL,
|
|
246
|
+
.attach_kernel_driver = NULL,
|
|
247
|
+
|
|
248
|
+
.destroy_device = NULL,
|
|
249
|
+
|
|
250
|
+
.submit_transfer = haiku_submit_transfer,
|
|
251
|
+
.cancel_transfer = haiku_cancel_transfer,
|
|
252
|
+
.clear_transfer_priv = haiku_clear_transfer_priv,
|
|
253
|
+
|
|
254
|
+
.handle_events = NULL,
|
|
255
|
+
.handle_transfer_completion = haiku_handle_transfer_completion,
|
|
256
|
+
|
|
257
|
+
.clock_gettime = haiku_clock_gettime,
|
|
258
|
+
|
|
259
|
+
#ifdef USBI_TIMERFD_AVAILABLE
|
|
260
|
+
.get_timerfd_clockid = NULL,
|
|
261
|
+
#endif
|
|
262
|
+
|
|
263
|
+
.context_priv_size = 0,
|
|
264
|
+
.device_priv_size = sizeof(USBDevice *),
|
|
265
|
+
.device_handle_priv_size = sizeof(USBDeviceHandle *),
|
|
266
|
+
.transfer_priv_size = sizeof(USBTransfer *),
|
|
267
|
+
};
|
|
@@ -0,0 +1,188 @@
|
|
|
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
|
+
#define B_USB_RAW_ACTIVE_ALTERNATE 0xffffffff
|
|
13
|
+
|
|
14
|
+
typedef enum {
|
|
15
|
+
B_USB_RAW_COMMAND_GET_VERSION = 0x1000,
|
|
16
|
+
|
|
17
|
+
B_USB_RAW_COMMAND_GET_DEVICE_DESCRIPTOR = 0x2000,
|
|
18
|
+
B_USB_RAW_COMMAND_GET_CONFIGURATION_DESCRIPTOR,
|
|
19
|
+
B_USB_RAW_COMMAND_GET_INTERFACE_DESCRIPTOR,
|
|
20
|
+
B_USB_RAW_COMMAND_GET_ENDPOINT_DESCRIPTOR,
|
|
21
|
+
B_USB_RAW_COMMAND_GET_STRING_DESCRIPTOR,
|
|
22
|
+
B_USB_RAW_COMMAND_GET_GENERIC_DESCRIPTOR,
|
|
23
|
+
B_USB_RAW_COMMAND_GET_ALT_INTERFACE_COUNT,
|
|
24
|
+
B_USB_RAW_COMMAND_GET_ACTIVE_ALT_INTERFACE_INDEX,
|
|
25
|
+
B_USB_RAW_COMMAND_GET_INTERFACE_DESCRIPTOR_ETC,
|
|
26
|
+
B_USB_RAW_COMMAND_GET_ENDPOINT_DESCRIPTOR_ETC,
|
|
27
|
+
B_USB_RAW_COMMAND_GET_GENERIC_DESCRIPTOR_ETC,
|
|
28
|
+
B_USB_RAW_COMMAND_GET_CONFIGURATION_DESCRIPTOR_ETC,
|
|
29
|
+
|
|
30
|
+
B_USB_RAW_COMMAND_SET_CONFIGURATION = 0x3000,
|
|
31
|
+
B_USB_RAW_COMMAND_SET_FEATURE,
|
|
32
|
+
B_USB_RAW_COMMAND_CLEAR_FEATURE,
|
|
33
|
+
B_USB_RAW_COMMAND_GET_STATUS,
|
|
34
|
+
B_USB_RAW_COMMAND_GET_DESCRIPTOR,
|
|
35
|
+
B_USB_RAW_COMMAND_SET_ALT_INTERFACE,
|
|
36
|
+
|
|
37
|
+
B_USB_RAW_COMMAND_CONTROL_TRANSFER = 0x4000,
|
|
38
|
+
B_USB_RAW_COMMAND_INTERRUPT_TRANSFER,
|
|
39
|
+
B_USB_RAW_COMMAND_BULK_TRANSFER,
|
|
40
|
+
B_USB_RAW_COMMAND_ISOCHRONOUS_TRANSFER
|
|
41
|
+
} usb_raw_command_id;
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
typedef enum {
|
|
45
|
+
B_USB_RAW_STATUS_SUCCESS = 0,
|
|
46
|
+
|
|
47
|
+
B_USB_RAW_STATUS_FAILED,
|
|
48
|
+
B_USB_RAW_STATUS_ABORTED,
|
|
49
|
+
B_USB_RAW_STATUS_STALLED,
|
|
50
|
+
B_USB_RAW_STATUS_CRC_ERROR,
|
|
51
|
+
B_USB_RAW_STATUS_TIMEOUT,
|
|
52
|
+
|
|
53
|
+
B_USB_RAW_STATUS_INVALID_CONFIGURATION,
|
|
54
|
+
B_USB_RAW_STATUS_INVALID_INTERFACE,
|
|
55
|
+
B_USB_RAW_STATUS_INVALID_ENDPOINT,
|
|
56
|
+
B_USB_RAW_STATUS_INVALID_STRING,
|
|
57
|
+
|
|
58
|
+
B_USB_RAW_STATUS_NO_MEMORY
|
|
59
|
+
} usb_raw_command_status;
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
typedef union {
|
|
63
|
+
struct {
|
|
64
|
+
status_t status;
|
|
65
|
+
} version;
|
|
66
|
+
|
|
67
|
+
struct {
|
|
68
|
+
status_t status;
|
|
69
|
+
usb_device_descriptor *descriptor;
|
|
70
|
+
} device;
|
|
71
|
+
|
|
72
|
+
struct {
|
|
73
|
+
status_t status;
|
|
74
|
+
usb_configuration_descriptor *descriptor;
|
|
75
|
+
uint32 config_index;
|
|
76
|
+
} config;
|
|
77
|
+
|
|
78
|
+
struct {
|
|
79
|
+
status_t status;
|
|
80
|
+
usb_configuration_descriptor *descriptor;
|
|
81
|
+
uint32 config_index;
|
|
82
|
+
size_t length;
|
|
83
|
+
} config_etc;
|
|
84
|
+
|
|
85
|
+
struct {
|
|
86
|
+
status_t status;
|
|
87
|
+
uint32 alternate_info;
|
|
88
|
+
uint32 config_index;
|
|
89
|
+
uint32 interface_index;
|
|
90
|
+
} alternate;
|
|
91
|
+
|
|
92
|
+
struct {
|
|
93
|
+
status_t status;
|
|
94
|
+
usb_interface_descriptor *descriptor;
|
|
95
|
+
uint32 config_index;
|
|
96
|
+
uint32 interface_index;
|
|
97
|
+
} interface;
|
|
98
|
+
|
|
99
|
+
struct {
|
|
100
|
+
status_t status;
|
|
101
|
+
usb_interface_descriptor *descriptor;
|
|
102
|
+
uint32 config_index;
|
|
103
|
+
uint32 interface_index;
|
|
104
|
+
uint32 alternate_index;
|
|
105
|
+
} interface_etc;
|
|
106
|
+
|
|
107
|
+
struct {
|
|
108
|
+
status_t status;
|
|
109
|
+
usb_endpoint_descriptor *descriptor;
|
|
110
|
+
uint32 config_index;
|
|
111
|
+
uint32 interface_index;
|
|
112
|
+
uint32 endpoint_index;
|
|
113
|
+
} endpoint;
|
|
114
|
+
|
|
115
|
+
struct {
|
|
116
|
+
status_t status;
|
|
117
|
+
usb_endpoint_descriptor *descriptor;
|
|
118
|
+
uint32 config_index;
|
|
119
|
+
uint32 interface_index;
|
|
120
|
+
uint32 alternate_index;
|
|
121
|
+
uint32 endpoint_index;
|
|
122
|
+
} endpoint_etc;
|
|
123
|
+
|
|
124
|
+
struct {
|
|
125
|
+
status_t status;
|
|
126
|
+
usb_descriptor *descriptor;
|
|
127
|
+
uint32 config_index;
|
|
128
|
+
uint32 interface_index;
|
|
129
|
+
uint32 generic_index;
|
|
130
|
+
size_t length;
|
|
131
|
+
} generic;
|
|
132
|
+
|
|
133
|
+
struct {
|
|
134
|
+
status_t status;
|
|
135
|
+
usb_descriptor *descriptor;
|
|
136
|
+
uint32 config_index;
|
|
137
|
+
uint32 interface_index;
|
|
138
|
+
uint32 alternate_index;
|
|
139
|
+
uint32 generic_index;
|
|
140
|
+
size_t length;
|
|
141
|
+
} generic_etc;
|
|
142
|
+
|
|
143
|
+
struct {
|
|
144
|
+
status_t status;
|
|
145
|
+
usb_string_descriptor *descriptor;
|
|
146
|
+
uint32 string_index;
|
|
147
|
+
size_t length;
|
|
148
|
+
} string;
|
|
149
|
+
|
|
150
|
+
struct {
|
|
151
|
+
status_t status;
|
|
152
|
+
uint8 type;
|
|
153
|
+
uint8 index;
|
|
154
|
+
uint16 language_id;
|
|
155
|
+
void *data;
|
|
156
|
+
size_t length;
|
|
157
|
+
} descriptor;
|
|
158
|
+
|
|
159
|
+
struct {
|
|
160
|
+
status_t status;
|
|
161
|
+
uint8 request_type;
|
|
162
|
+
uint8 request;
|
|
163
|
+
uint16 value;
|
|
164
|
+
uint16 index;
|
|
165
|
+
uint16 length;
|
|
166
|
+
void *data;
|
|
167
|
+
} control;
|
|
168
|
+
|
|
169
|
+
struct {
|
|
170
|
+
status_t status;
|
|
171
|
+
uint32 interface;
|
|
172
|
+
uint32 endpoint;
|
|
173
|
+
void *data;
|
|
174
|
+
size_t length;
|
|
175
|
+
} transfer;
|
|
176
|
+
|
|
177
|
+
struct {
|
|
178
|
+
status_t status;
|
|
179
|
+
uint32 interface;
|
|
180
|
+
uint32 endpoint;
|
|
181
|
+
void *data;
|
|
182
|
+
size_t length;
|
|
183
|
+
usb_iso_packet_descriptor *packet_descriptors;
|
|
184
|
+
uint32 packet_count;
|
|
185
|
+
} isochronous;
|
|
186
|
+
} usb_raw_command;
|
|
187
|
+
|
|
188
|
+
#endif // _USB_RAW_H_
|