usb 2.12.1 → 2.13.0
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/CHANGELOG.md +8 -0
- package/README.md +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/usb/bindings.js +1 -1
- package/dist/usb/bindings.js.map +1 -1
- package/dist/usb/capability.js.map +1 -1
- package/dist/usb/device.js.map +1 -1
- package/dist/usb/endpoint.d.ts +1 -0
- package/dist/usb/endpoint.js +2 -2
- package/dist/usb/endpoint.js.map +1 -1
- package/dist/usb/index.js.map +1 -1
- package/dist/usb/interface.js +2 -2
- package/dist/usb/interface.js.map +1 -1
- package/dist/webusb/index.d.ts +2 -2
- package/dist/webusb/index.js.map +1 -1
- package/dist/webusb/webusb-device.js +10 -10
- package/dist/webusb/webusb-device.js.map +1 -1
- package/libusb/.codespellrc +3 -0
- package/libusb/.private/appveyor_build.sh +5 -1
- package/libusb/.private/ci-build.sh +26 -1
- package/libusb/.private/ci-container-build.sh +2 -5
- package/libusb/.private/wbs.txt +5 -8
- package/libusb/AUTHORS +22 -0
- package/libusb/ChangeLog +19 -2
- package/libusb/HACKING +25 -0
- package/libusb/INSTALL_WIN.txt +11 -10
- package/libusb/NEWS +2 -2
- package/libusb/README +3 -2
- package/libusb/README.git +1 -1
- package/libusb/Xcode/common.xcconfig +8 -1
- package/libusb/Xcode/config.h +0 -6
- package/libusb/Xcode/debug.xcconfig +4 -1
- package/libusb/Xcode/libusb.xcconfig +1 -1
- package/libusb/Xcode/libusb.xcodeproj/project.pbxproj +60 -30
- package/libusb/Xcode/libusb_debug.xcconfig +1 -1
- package/libusb/Xcode/libusb_release.xcconfig +1 -1
- package/libusb/Xcode/release.xcconfig +1 -1
- package/libusb/appveyor.yml +33 -9
- package/libusb/configure.ac +68 -37
- package/libusb/examples/dpfp.c +2 -2
- package/libusb/examples/fxload.c +2 -2
- package/libusb/examples/hotplugtest.c +28 -13
- package/libusb/examples/listdevs.c +1 -1
- package/libusb/examples/sam3u_benchmark.c +1 -1
- package/libusb/examples/testlibusb.c +1 -1
- package/libusb/examples/xusb.c +74 -19
- package/libusb/libusb/Makefile.am +11 -1
- package/libusb/libusb/core.c +364 -186
- package/libusb/libusb/descriptor.c +276 -16
- package/libusb/libusb/hotplug.c +5 -4
- package/libusb/libusb/io.c +72 -61
- package/libusb/libusb/libusb-1.0.def +14 -1
- package/libusb/libusb/libusb.h +245 -76
- package/libusb/libusb/libusbi.h +35 -13
- package/libusb/libusb/os/darwin_usb.c +542 -279
- package/libusb/libusb/os/darwin_usb.h +44 -115
- package/libusb/libusb/os/emscripten_webusb.cpp +870 -0
- package/libusb/libusb/os/events_posix.c +40 -0
- package/libusb/libusb/os/events_posix.h +3 -0
- package/libusb/libusb/os/linux_usbfs.c +27 -16
- package/libusb/libusb/os/netbsd_usb.c +36 -36
- package/libusb/libusb/os/openbsd_usb.c +34 -34
- package/libusb/libusb/os/sunos_usb.c +25 -15
- package/libusb/libusb/os/threads_posix.c +1 -5
- package/libusb/libusb/os/windows_common.c +13 -5
- package/libusb/libusb/os/windows_common.h +8 -0
- package/libusb/libusb/os/windows_winusb.c +366 -174
- package/libusb/libusb/os/windows_winusb.h +13 -9
- package/libusb/libusb/strerror.c +5 -5
- package/libusb/libusb/sync.c +24 -19
- package/libusb/libusb/version.h +1 -1
- package/libusb/libusb/version_nano.h +1 -1
- package/libusb/msvc/Base.props +60 -0
- package/libusb/msvc/Configuration.Application.props +7 -0
- package/libusb/msvc/Configuration.Base.props +47 -0
- package/libusb/msvc/Configuration.DynamicLibrary.props +21 -0
- package/libusb/msvc/Configuration.StaticLibrary.props +7 -0
- package/libusb/msvc/ProjectConfigurations.Base.props +69 -0
- package/libusb/msvc/build_all.ps1 +17 -0
- package/libusb/msvc/config.h +2 -2
- package/libusb/msvc/dpfp.vcxproj +33 -0
- package/libusb/msvc/dpfp_threaded.vcxproj +38 -0
- package/libusb/msvc/fxload.vcxproj +46 -0
- package/libusb/msvc/getopt.vcxproj +33 -0
- package/libusb/msvc/hotplugtest.vcxproj +32 -0
- package/libusb/msvc/init_context.vcxproj +35 -0
- package/libusb/msvc/libusb.sln +542 -0
- package/libusb/msvc/libusb_dll.vcxproj +61 -0
- package/libusb/msvc/libusb_static.vcxproj +49 -0
- package/libusb/msvc/listdevs.vcxproj +32 -0
- package/libusb/msvc/sam3u_benchmark.vcxproj +33 -0
- package/libusb/msvc/set_option.vcxproj +35 -0
- package/libusb/msvc/stress.vcxproj +35 -0
- package/libusb/msvc/stress_mt.vcxproj +33 -0
- package/libusb/msvc/testlibusb.vcxproj +32 -0
- package/libusb/msvc/xusb.vcxproj +38 -0
- package/libusb/tests/Makefile.am +25 -3
- package/libusb/tests/init_context.c +153 -0
- package/libusb/tests/macos.c +130 -0
- package/libusb/tests/set_option.c +253 -0
- package/libusb/tests/stress.c +17 -14
- package/libusb/tests/stress_mt.c +265 -0
- package/libusb/tests/testlib.c +1 -1
- package/libusb/tests/umockdev.c +9 -9
- package/libusb/tests/webusb-test-shim/index.js +12 -0
- package/libusb/tests/webusb-test-shim/package-lock.json +50 -0
- package/libusb/tests/webusb-test-shim/package.json +10 -0
- package/package.json +7 -7
- 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-arm64/node.napi.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 +15 -5
- package/libusb/msvc/dpfp_2013.vcxproj +0 -87
- package/libusb/msvc/dpfp_2013.vcxproj.filters +0 -26
- package/libusb/msvc/dpfp_2015.vcxproj +0 -87
- package/libusb/msvc/dpfp_2015.vcxproj.filters +0 -26
- package/libusb/msvc/dpfp_2017.vcxproj +0 -106
- package/libusb/msvc/dpfp_2017.vcxproj.filters +0 -26
- package/libusb/msvc/dpfp_2019.vcxproj +0 -106
- package/libusb/msvc/dpfp_2019.vcxproj.filters +0 -26
- package/libusb/msvc/dpfp_threaded_2013.vcxproj +0 -87
- package/libusb/msvc/dpfp_threaded_2013.vcxproj.filters +0 -26
- package/libusb/msvc/dpfp_threaded_2015.vcxproj +0 -87
- package/libusb/msvc/dpfp_threaded_2015.vcxproj.filters +0 -26
- package/libusb/msvc/dpfp_threaded_2017.vcxproj +0 -106
- package/libusb/msvc/dpfp_threaded_2017.vcxproj.filters +0 -26
- package/libusb/msvc/dpfp_threaded_2019.vcxproj +0 -106
- package/libusb/msvc/dpfp_threaded_2019.vcxproj.filters +0 -26
- package/libusb/msvc/fxload_2013.vcxproj +0 -94
- package/libusb/msvc/fxload_2013.vcxproj.filters +0 -35
- package/libusb/msvc/fxload_2015.vcxproj +0 -94
- package/libusb/msvc/fxload_2015.vcxproj.filters +0 -35
- package/libusb/msvc/fxload_2017.vcxproj +0 -113
- package/libusb/msvc/fxload_2017.vcxproj.filters +0 -35
- package/libusb/msvc/fxload_2019.vcxproj +0 -113
- package/libusb/msvc/fxload_2019.vcxproj.filters +0 -35
- package/libusb/msvc/getopt_2013.vcxproj +0 -72
- package/libusb/msvc/getopt_2013.vcxproj.filters +0 -26
- package/libusb/msvc/getopt_2015.vcxproj +0 -73
- package/libusb/msvc/getopt_2015.vcxproj.filters +0 -26
- package/libusb/msvc/getopt_2017.vcxproj +0 -92
- package/libusb/msvc/getopt_2017.vcxproj.filters +0 -26
- package/libusb/msvc/getopt_2019.vcxproj +0 -92
- package/libusb/msvc/getopt_2019.vcxproj.filters +0 -26
- package/libusb/msvc/hotplugtest_2013.vcxproj +0 -86
- package/libusb/msvc/hotplugtest_2013.vcxproj.filters +0 -23
- package/libusb/msvc/hotplugtest_2015.vcxproj +0 -86
- package/libusb/msvc/hotplugtest_2015.vcxproj.filters +0 -23
- package/libusb/msvc/hotplugtest_2017.vcxproj +0 -105
- package/libusb/msvc/hotplugtest_2017.vcxproj.filters +0 -23
- package/libusb/msvc/hotplugtest_2019.vcxproj +0 -105
- package/libusb/msvc/hotplugtest_2019.vcxproj.filters +0 -23
- package/libusb/msvc/libusb_2013.sln +0 -137
- package/libusb/msvc/libusb_2015.sln +0 -137
- package/libusb/msvc/libusb_2017.sln +0 -240
- package/libusb/msvc/libusb_2019.sln +0 -240
- package/libusb/msvc/libusb_dll_2013.vcxproj +0 -104
- package/libusb/msvc/libusb_dll_2013.vcxproj.filters +0 -94
- package/libusb/msvc/libusb_dll_2015.vcxproj +0 -105
- package/libusb/msvc/libusb_dll_2015.vcxproj.filters +0 -94
- package/libusb/msvc/libusb_dll_2017.vcxproj +0 -124
- package/libusb/msvc/libusb_dll_2017.vcxproj.filters +0 -94
- package/libusb/msvc/libusb_dll_2019.vcxproj +0 -124
- package/libusb/msvc/libusb_dll_2019.vcxproj.filters +0 -94
- package/libusb/msvc/libusb_static_2013.vcxproj +0 -94
- package/libusb/msvc/libusb_static_2013.vcxproj.filters +0 -80
- package/libusb/msvc/libusb_static_2015.vcxproj +0 -95
- package/libusb/msvc/libusb_static_2015.vcxproj.filters +0 -80
- package/libusb/msvc/libusb_static_2017.vcxproj +0 -114
- package/libusb/msvc/libusb_static_2017.vcxproj.filters +0 -80
- package/libusb/msvc/libusb_static_2019.vcxproj +0 -114
- package/libusb/msvc/libusb_static_2019.vcxproj.filters +0 -80
- package/libusb/msvc/listdevs_2013.vcxproj +0 -86
- package/libusb/msvc/listdevs_2013.vcxproj.filters +0 -23
- package/libusb/msvc/listdevs_2015.vcxproj +0 -86
- package/libusb/msvc/listdevs_2015.vcxproj.filters +0 -23
- package/libusb/msvc/listdevs_2017.vcxproj +0 -105
- package/libusb/msvc/listdevs_2017.vcxproj.filters +0 -23
- package/libusb/msvc/listdevs_2019.vcxproj +0 -105
- package/libusb/msvc/listdevs_2019.vcxproj.filters +0 -23
- package/libusb/msvc/sam3u_benchmark_2013.vcxproj +0 -87
- package/libusb/msvc/sam3u_benchmark_2013.vcxproj.filters +0 -26
- package/libusb/msvc/sam3u_benchmark_2015.vcxproj +0 -87
- package/libusb/msvc/sam3u_benchmark_2015.vcxproj.filters +0 -26
- package/libusb/msvc/sam3u_benchmark_2017.vcxproj +0 -106
- package/libusb/msvc/sam3u_benchmark_2017.vcxproj.filters +0 -26
- package/libusb/msvc/sam3u_benchmark_2019.vcxproj +0 -106
- package/libusb/msvc/sam3u_benchmark_2019.vcxproj.filters +0 -26
- package/libusb/msvc/stress_2013.vcxproj +0 -89
- package/libusb/msvc/stress_2013.vcxproj.filters +0 -32
- package/libusb/msvc/stress_2015.vcxproj +0 -89
- package/libusb/msvc/stress_2015.vcxproj.filters +0 -32
- package/libusb/msvc/stress_2017.vcxproj +0 -108
- package/libusb/msvc/stress_2017.vcxproj.filters +0 -32
- package/libusb/msvc/stress_2019.vcxproj +0 -108
- package/libusb/msvc/stress_2019.vcxproj.filters +0 -32
- package/libusb/msvc/testlibusb_2013.vcxproj +0 -86
- package/libusb/msvc/testlibusb_2013.vcxproj.filters +0 -23
- package/libusb/msvc/testlibusb_2015.vcxproj +0 -86
- package/libusb/msvc/testlibusb_2015.vcxproj.filters +0 -23
- package/libusb/msvc/testlibusb_2017.vcxproj +0 -105
- package/libusb/msvc/testlibusb_2017.vcxproj.filters +0 -23
- package/libusb/msvc/testlibusb_2019.vcxproj +0 -105
- package/libusb/msvc/testlibusb_2019.vcxproj.filters +0 -23
- package/libusb/msvc/xusb_2013.vcxproj +0 -86
- package/libusb/msvc/xusb_2013.vcxproj.filters +0 -23
- package/libusb/msvc/xusb_2015.vcxproj +0 -86
- package/libusb/msvc/xusb_2015.vcxproj.filters +0 -23
- package/libusb/msvc/xusb_2017.vcxproj +0 -105
- package/libusb/msvc/xusb_2017.vcxproj.filters +0 -23
- package/libusb/msvc/xusb_2019.vcxproj +0 -105
- package/libusb/msvc/xusb_2019.vcxproj.filters +0 -23
|
@@ -167,7 +167,7 @@ obsd_get_device_list(struct libusb_context * ctx,
|
|
|
167
167
|
dev = usbi_alloc_device(ctx, session_id);
|
|
168
168
|
if (dev == NULL) {
|
|
169
169
|
close(fd);
|
|
170
|
-
return
|
|
170
|
+
return LIBUSB_ERROR_NO_MEM;
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
dev->bus_number = di.udi_bus;
|
|
@@ -205,7 +205,7 @@ obsd_get_device_list(struct libusb_context * ctx,
|
|
|
205
205
|
ddd = discovered_devs_append(*discdevs, dev);
|
|
206
206
|
if (ddd == NULL) {
|
|
207
207
|
close(fd);
|
|
208
|
-
return
|
|
208
|
+
return LIBUSB_ERROR_NO_MEM;
|
|
209
209
|
}
|
|
210
210
|
libusb_unref_device(dev);
|
|
211
211
|
|
|
@@ -216,7 +216,7 @@ obsd_get_device_list(struct libusb_context * ctx,
|
|
|
216
216
|
close(fd);
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
return
|
|
219
|
+
return LIBUSB_SUCCESS;
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
int
|
|
@@ -241,7 +241,7 @@ obsd_open(struct libusb_device_handle *handle)
|
|
|
241
241
|
usbi_dbg(HANDLE_CTX(handle), "open %s: fd %d", devnode, dpriv->fd);
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
-
return
|
|
244
|
+
return LIBUSB_SUCCESS;
|
|
245
245
|
}
|
|
246
246
|
|
|
247
247
|
void
|
|
@@ -269,7 +269,7 @@ obsd_get_active_config_descriptor(struct libusb_device *dev,
|
|
|
269
269
|
|
|
270
270
|
memcpy(buf, dpriv->cdesc, len);
|
|
271
271
|
|
|
272
|
-
return (
|
|
272
|
+
return (int)len;
|
|
273
273
|
}
|
|
274
274
|
|
|
275
275
|
int
|
|
@@ -297,7 +297,7 @@ obsd_get_config_descriptor(struct libusb_device *dev, uint8_t idx,
|
|
|
297
297
|
}
|
|
298
298
|
close(fd);
|
|
299
299
|
|
|
300
|
-
return (
|
|
300
|
+
return (int)len;
|
|
301
301
|
}
|
|
302
302
|
|
|
303
303
|
int
|
|
@@ -309,7 +309,7 @@ obsd_get_configuration(struct libusb_device_handle *handle, uint8_t *config)
|
|
|
309
309
|
|
|
310
310
|
usbi_dbg(HANDLE_CTX(handle), "bConfigurationValue %u", *config);
|
|
311
311
|
|
|
312
|
-
return
|
|
312
|
+
return LIBUSB_SUCCESS;
|
|
313
313
|
}
|
|
314
314
|
|
|
315
315
|
int
|
|
@@ -318,7 +318,7 @@ obsd_set_configuration(struct libusb_device_handle *handle, int config)
|
|
|
318
318
|
struct device_priv *dpriv = usbi_get_device_priv(handle->dev);
|
|
319
319
|
|
|
320
320
|
if (dpriv->devname == NULL)
|
|
321
|
-
return
|
|
321
|
+
return LIBUSB_ERROR_NOT_SUPPORTED;
|
|
322
322
|
|
|
323
323
|
usbi_dbg(HANDLE_CTX(handle), "bConfigurationValue %d", config);
|
|
324
324
|
|
|
@@ -339,7 +339,7 @@ obsd_claim_interface(struct libusb_device_handle *handle, uint8_t iface)
|
|
|
339
339
|
for (i = 0; i < USB_MAX_ENDPOINTS; i++)
|
|
340
340
|
hpriv->endpoints[i] = -1;
|
|
341
341
|
|
|
342
|
-
return
|
|
342
|
+
return LIBUSB_SUCCESS;
|
|
343
343
|
}
|
|
344
344
|
|
|
345
345
|
int
|
|
@@ -354,7 +354,7 @@ obsd_release_interface(struct libusb_device_handle *handle, uint8_t iface)
|
|
|
354
354
|
if (hpriv->endpoints[i] >= 0)
|
|
355
355
|
close(hpriv->endpoints[i]);
|
|
356
356
|
|
|
357
|
-
return
|
|
357
|
+
return LIBUSB_SUCCESS;
|
|
358
358
|
}
|
|
359
359
|
|
|
360
360
|
int
|
|
@@ -365,7 +365,7 @@ obsd_set_interface_altsetting(struct libusb_device_handle *handle, uint8_t iface
|
|
|
365
365
|
struct usb_alt_interface intf;
|
|
366
366
|
|
|
367
367
|
if (dpriv->devname == NULL)
|
|
368
|
-
return
|
|
368
|
+
return LIBUSB_ERROR_NOT_SUPPORTED;
|
|
369
369
|
|
|
370
370
|
usbi_dbg(HANDLE_CTX(handle), "iface %u, setting %u", iface, altsetting);
|
|
371
371
|
|
|
@@ -377,7 +377,7 @@ obsd_set_interface_altsetting(struct libusb_device_handle *handle, uint8_t iface
|
|
|
377
377
|
if (ioctl(dpriv->fd, USB_SET_ALTINTERFACE, &intf) < 0)
|
|
378
378
|
return _errno_to_libusb(errno);
|
|
379
379
|
|
|
380
|
-
return
|
|
380
|
+
return LIBUSB_SUCCESS;
|
|
381
381
|
}
|
|
382
382
|
|
|
383
383
|
int
|
|
@@ -405,7 +405,7 @@ obsd_clear_halt(struct libusb_device_handle *handle, unsigned char endpoint)
|
|
|
405
405
|
}
|
|
406
406
|
close(fd);
|
|
407
407
|
|
|
408
|
-
return
|
|
408
|
+
return LIBUSB_SUCCESS;
|
|
409
409
|
}
|
|
410
410
|
|
|
411
411
|
void
|
|
@@ -456,11 +456,11 @@ obsd_submit_transfer(struct usbi_transfer *itransfer)
|
|
|
456
456
|
}
|
|
457
457
|
|
|
458
458
|
if (err)
|
|
459
|
-
return
|
|
459
|
+
return err;
|
|
460
460
|
|
|
461
461
|
usbi_signal_transfer_completion(itransfer);
|
|
462
462
|
|
|
463
|
-
return
|
|
463
|
+
return LIBUSB_SUCCESS;
|
|
464
464
|
}
|
|
465
465
|
|
|
466
466
|
int
|
|
@@ -470,7 +470,7 @@ obsd_cancel_transfer(struct usbi_transfer *itransfer)
|
|
|
470
470
|
|
|
471
471
|
usbi_dbg(ITRANSFER_CTX(itransfer), " ");
|
|
472
472
|
|
|
473
|
-
return
|
|
473
|
+
return LIBUSB_ERROR_NOT_SUPPORTED;
|
|
474
474
|
}
|
|
475
475
|
|
|
476
476
|
int
|
|
@@ -486,18 +486,18 @@ _errno_to_libusb(int err)
|
|
|
486
486
|
|
|
487
487
|
switch (err) {
|
|
488
488
|
case EIO:
|
|
489
|
-
return
|
|
489
|
+
return LIBUSB_ERROR_IO;
|
|
490
490
|
case EACCES:
|
|
491
|
-
return
|
|
491
|
+
return LIBUSB_ERROR_ACCESS;
|
|
492
492
|
case ENOENT:
|
|
493
|
-
return
|
|
493
|
+
return LIBUSB_ERROR_NO_DEVICE;
|
|
494
494
|
case ENOMEM:
|
|
495
|
-
return
|
|
495
|
+
return LIBUSB_ERROR_NO_MEM;
|
|
496
496
|
case ETIMEDOUT:
|
|
497
|
-
return
|
|
497
|
+
return LIBUSB_ERROR_TIMEOUT;
|
|
498
498
|
}
|
|
499
499
|
|
|
500
|
-
return
|
|
500
|
+
return LIBUSB_ERROR_OTHER;
|
|
501
501
|
}
|
|
502
502
|
|
|
503
503
|
int
|
|
@@ -528,7 +528,7 @@ _cache_active_config_descriptor(struct libusb_device *dev)
|
|
|
528
528
|
len = UGETW(udc.udc_desc.wTotalLength);
|
|
529
529
|
buf = malloc((size_t)len);
|
|
530
530
|
if (buf == NULL)
|
|
531
|
-
return
|
|
531
|
+
return LIBUSB_ERROR_NO_MEM;
|
|
532
532
|
|
|
533
533
|
udf.udf_bus = dev->bus_number;
|
|
534
534
|
udf.udf_addr = dev->device_address;
|
|
@@ -550,7 +550,7 @@ _cache_active_config_descriptor(struct libusb_device *dev)
|
|
|
550
550
|
free(dpriv->cdesc);
|
|
551
551
|
dpriv->cdesc = buf;
|
|
552
552
|
|
|
553
|
-
return
|
|
553
|
+
return LIBUSB_SUCCESS;
|
|
554
554
|
}
|
|
555
555
|
|
|
556
556
|
int
|
|
@@ -594,17 +594,17 @@ _sync_control_transfer(struct usbi_transfer *itransfer)
|
|
|
594
594
|
if ((fd = _bus_open(transfer->dev_handle->dev->bus_number)) < 0)
|
|
595
595
|
return _errno_to_libusb(errno);
|
|
596
596
|
|
|
597
|
-
if (
|
|
597
|
+
if (ioctl(fd, USB_REQUEST, &req) < 0) {
|
|
598
598
|
err = errno;
|
|
599
599
|
close(fd);
|
|
600
600
|
return _errno_to_libusb(err);
|
|
601
601
|
}
|
|
602
602
|
close(fd);
|
|
603
603
|
} else {
|
|
604
|
-
if (
|
|
604
|
+
if (ioctl(dpriv->fd, USB_SET_TIMEOUT, &transfer->timeout) < 0)
|
|
605
605
|
return _errno_to_libusb(errno);
|
|
606
606
|
|
|
607
|
-
if (
|
|
607
|
+
if (ioctl(dpriv->fd, USB_DO_REQUEST, &req) < 0)
|
|
608
608
|
return _errno_to_libusb(errno);
|
|
609
609
|
}
|
|
610
610
|
|
|
@@ -612,7 +612,7 @@ _sync_control_transfer(struct usbi_transfer *itransfer)
|
|
|
612
612
|
|
|
613
613
|
usbi_dbg(ITRANSFER_CTX(itransfer), "transferred %d", itransfer->transferred);
|
|
614
614
|
|
|
615
|
-
return
|
|
615
|
+
return 0;
|
|
616
616
|
}
|
|
617
617
|
|
|
618
618
|
int
|
|
@@ -640,12 +640,12 @@ _access_endpoint(struct libusb_transfer *transfer)
|
|
|
640
640
|
/* We may need to read/write to the same endpoint later. */
|
|
641
641
|
if (((fd = open(devnode, O_RDWR)) < 0) && (errno == ENXIO))
|
|
642
642
|
if ((fd = open(devnode, mode)) < 0)
|
|
643
|
-
return
|
|
643
|
+
return -1;
|
|
644
644
|
|
|
645
645
|
hpriv->endpoints[endpt] = fd;
|
|
646
646
|
}
|
|
647
647
|
|
|
648
|
-
return
|
|
648
|
+
return hpriv->endpoints[endpt];
|
|
649
649
|
}
|
|
650
650
|
|
|
651
651
|
int
|
|
@@ -659,7 +659,7 @@ _sync_gen_transfer(struct usbi_transfer *itransfer)
|
|
|
659
659
|
dpriv = usbi_get_device_priv(transfer->dev_handle->dev);
|
|
660
660
|
|
|
661
661
|
if (dpriv->devname == NULL)
|
|
662
|
-
return
|
|
662
|
+
return LIBUSB_ERROR_NOT_SUPPORTED;
|
|
663
663
|
|
|
664
664
|
/*
|
|
665
665
|
* Bulk, Interrupt or Isochronous transfer depends on the
|
|
@@ -668,12 +668,12 @@ _sync_gen_transfer(struct usbi_transfer *itransfer)
|
|
|
668
668
|
if ((fd = _access_endpoint(transfer)) < 0)
|
|
669
669
|
return _errno_to_libusb(errno);
|
|
670
670
|
|
|
671
|
-
if (
|
|
671
|
+
if (ioctl(fd, USB_SET_TIMEOUT, &transfer->timeout) < 0)
|
|
672
672
|
return _errno_to_libusb(errno);
|
|
673
673
|
|
|
674
674
|
if (IS_XFERIN(transfer)) {
|
|
675
675
|
if ((transfer->flags & LIBUSB_TRANSFER_SHORT_NOT_OK) == 0)
|
|
676
|
-
if (
|
|
676
|
+
if (ioctl(fd, USB_SET_SHORT_XFER, &nr) < 0)
|
|
677
677
|
return _errno_to_libusb(errno);
|
|
678
678
|
|
|
679
679
|
nr = read(fd, transfer->buffer, transfer->length);
|
|
@@ -686,7 +686,7 @@ _sync_gen_transfer(struct usbi_transfer *itransfer)
|
|
|
686
686
|
|
|
687
687
|
itransfer->transferred = nr;
|
|
688
688
|
|
|
689
|
-
return
|
|
689
|
+
return 0;
|
|
690
690
|
}
|
|
691
691
|
|
|
692
692
|
int
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
*
|
|
3
2
|
* Copyright (c) 2016, Oracle and/or its affiliates.
|
|
3
|
+
* Copyright 2023 Oxide Computer Company
|
|
4
4
|
*
|
|
5
5
|
* This library is free software; you can redistribute it and/or
|
|
6
6
|
* modify it under the terms of the GNU Lesser General Public
|
|
@@ -82,7 +82,7 @@ static int sunos_usb_ioctl(struct libusb_device *dev, int cmd);
|
|
|
82
82
|
|
|
83
83
|
static int sunos_get_link(di_devlink_t devlink, void *arg)
|
|
84
84
|
{
|
|
85
|
-
walk_link_t *
|
|
85
|
+
walk_link_t *link_arg = (walk_link_t *)arg;
|
|
86
86
|
const char *p;
|
|
87
87
|
const char *q;
|
|
88
88
|
|
|
@@ -112,21 +112,21 @@ static int sunos_get_link(di_devlink_t devlink, void *arg)
|
|
|
112
112
|
static int sunos_physpath_to_devlink(
|
|
113
113
|
const char *node_path, const char *match, char **link_path)
|
|
114
114
|
{
|
|
115
|
-
walk_link_t
|
|
115
|
+
walk_link_t link_arg;
|
|
116
116
|
di_devlink_handle_t hdl;
|
|
117
117
|
|
|
118
118
|
*link_path = NULL;
|
|
119
|
-
|
|
119
|
+
link_arg.linkpp = link_path;
|
|
120
120
|
if ((hdl = di_devlink_init(NULL, 0)) == NULL) {
|
|
121
121
|
usbi_dbg(NULL, "di_devlink_init failure");
|
|
122
122
|
return (-1);
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
link_arg.len = strlen(node_path);
|
|
126
|
+
link_arg.path = (char *)node_path;
|
|
127
127
|
|
|
128
128
|
(void) di_devlink_walk(hdl, match, NULL, DI_PRIMARY_LINK,
|
|
129
|
-
(void *)&
|
|
129
|
+
(void *)&link_arg, sunos_get_link);
|
|
130
130
|
|
|
131
131
|
(void) di_devlink_fini(&hdl);
|
|
132
132
|
|
|
@@ -624,7 +624,7 @@ sunos_add_devices(di_devlink_t link, void *arg)
|
|
|
624
624
|
}
|
|
625
625
|
if (usbi_sanitize_device(dev) < 0) {
|
|
626
626
|
libusb_unref_device(dev);
|
|
627
|
-
usbi_dbg(NULL, "
|
|
627
|
+
usbi_dbg(NULL, "sanitize failed: ");
|
|
628
628
|
return (DI_WALK_TERMINATE);
|
|
629
629
|
}
|
|
630
630
|
} else {
|
|
@@ -831,7 +831,7 @@ sunos_check_device_and_status_open(struct libusb_device_handle *hdl,
|
|
|
831
831
|
{
|
|
832
832
|
char filename[PATH_MAX + 1], statfilename[PATH_MAX + 1];
|
|
833
833
|
char cfg_num[16], alt_num[16];
|
|
834
|
-
int fd, fdstat, mode;
|
|
834
|
+
int fd, fdstat, mode, e;
|
|
835
835
|
uint8_t ifc = 0;
|
|
836
836
|
uint8_t ep_index;
|
|
837
837
|
sunos_dev_handle_priv_t *hpriv;
|
|
@@ -870,11 +870,22 @@ sunos_check_device_and_status_open(struct libusb_device_handle *hdl,
|
|
|
870
870
|
bzero(alt_num, sizeof(alt_num));
|
|
871
871
|
}
|
|
872
872
|
|
|
873
|
-
|
|
873
|
+
e = snprintf(filename, sizeof (filename), "%s/%sif%d%s%s%d",
|
|
874
874
|
hpriv->dpriv->ugenpath, cfg_num, ifc, alt_num,
|
|
875
|
-
(ep_addr & LIBUSB_ENDPOINT_DIR_MASK) ? "in" :
|
|
876
|
-
|
|
877
|
-
|
|
875
|
+
(ep_addr & LIBUSB_ENDPOINT_DIR_MASK) ? "in" : "out",
|
|
876
|
+
ep_addr & LIBUSB_ENDPOINT_ADDRESS_MASK);
|
|
877
|
+
if (e < 0 || e >= (int)sizeof (filename)) {
|
|
878
|
+
usbi_dbg(HANDLE_CTX(hdl),
|
|
879
|
+
"path buffer overflow for endpoint 0x%02x", ep_addr);
|
|
880
|
+
return (EINVAL);
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
e = snprintf(statfilename, sizeof (statfilename), "%sstat", filename);
|
|
884
|
+
if (e < 0 || e >= (int)sizeof (statfilename)) {
|
|
885
|
+
usbi_dbg(HANDLE_CTX(hdl),
|
|
886
|
+
"path buffer overflow for endpoint 0x%02x stat", ep_addr);
|
|
887
|
+
return (EINVAL);
|
|
888
|
+
}
|
|
878
889
|
|
|
879
890
|
/*
|
|
880
891
|
* In case configuration has been switched, the xfer endpoint needs
|
|
@@ -1379,8 +1390,7 @@ sunos_submit_transfer(struct usbi_transfer *itransfer)
|
|
|
1379
1390
|
|
|
1380
1391
|
err = sunos_check_device_and_status_open(hdl,
|
|
1381
1392
|
transfer->endpoint, transfer->type);
|
|
1382
|
-
if (err
|
|
1383
|
-
|
|
1393
|
+
if (err != 0) {
|
|
1384
1394
|
return (_errno_to_libusb(err));
|
|
1385
1395
|
}
|
|
1386
1396
|
|
|
@@ -32,8 +32,6 @@
|
|
|
32
32
|
#elif defined(__NetBSD__)
|
|
33
33
|
# include <lwp.h>
|
|
34
34
|
#elif defined(__OpenBSD__)
|
|
35
|
-
# define _BSD_SOURCE
|
|
36
|
-
# include <sys/syscall.h>
|
|
37
35
|
# include <unistd.h>
|
|
38
36
|
#elif defined(__sun__)
|
|
39
37
|
# include <sys/lwp.h>
|
|
@@ -109,9 +107,7 @@ unsigned int usbi_get_tid(void)
|
|
|
109
107
|
#elif defined(__NetBSD__)
|
|
110
108
|
tid = _lwp_self();
|
|
111
109
|
#elif defined(__OpenBSD__)
|
|
112
|
-
|
|
113
|
-
* real thread support. For 5.1 and earlier, -1 is returned. */
|
|
114
|
-
tid = syscall(SYS_getthrid);
|
|
110
|
+
tid = getthrid();
|
|
115
111
|
#elif defined(__sun__)
|
|
116
112
|
tid = _lwp_self();
|
|
117
113
|
#else
|
|
@@ -279,6 +279,7 @@ enum libusb_transfer_status usbd_status_to_libusb_transfer_status(USBD_STATUS st
|
|
|
279
279
|
case USBD_STATUS_CANCELED:
|
|
280
280
|
return LIBUSB_TRANSFER_CANCELLED;
|
|
281
281
|
case USBD_STATUS_ENDPOINT_HALTED:
|
|
282
|
+
case USBD_STATUS_STALL_PID:
|
|
282
283
|
return LIBUSB_TRANSFER_STALL;
|
|
283
284
|
case USBD_STATUS_DEVICE_GONE:
|
|
284
285
|
return LIBUSB_TRANSFER_NO_DEVICE;
|
|
@@ -331,6 +332,9 @@ static enum windows_version get_windows_version(void)
|
|
|
331
332
|
const char *w, *arch;
|
|
332
333
|
bool ws;
|
|
333
334
|
|
|
335
|
+
#ifndef ENABLE_LOGGING
|
|
336
|
+
UNUSED(w); UNUSED(arch);
|
|
337
|
+
#endif
|
|
334
338
|
memset(&vi, 0, sizeof(vi));
|
|
335
339
|
vi.dwOSVersionInfoSize = sizeof(vi);
|
|
336
340
|
if (!GetVersionExA((OSVERSIONINFOA *)&vi)) {
|
|
@@ -482,14 +486,15 @@ static unsigned __stdcall windows_iocp_thread(void *arg)
|
|
|
482
486
|
usbi_mutex_unlock(&ctx->open_devs_lock);
|
|
483
487
|
|
|
484
488
|
if (!found) {
|
|
485
|
-
usbi_dbg(ctx, "ignoring overlapped %p for handle %p
|
|
486
|
-
|
|
489
|
+
usbi_dbg(ctx, "ignoring overlapped %p for handle %p",
|
|
490
|
+
overlapped, dev_handle);
|
|
487
491
|
continue;
|
|
488
492
|
}
|
|
489
493
|
|
|
490
|
-
itransfer = (
|
|
494
|
+
itransfer = TRANSFER_PRIV_TO_USBI_TRANSFER(transfer_priv);
|
|
495
|
+
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
|
|
491
496
|
usbi_dbg(ctx, "transfer %p completed, length %lu",
|
|
492
|
-
|
|
497
|
+
transfer, ULONG_CAST(num_bytes));
|
|
493
498
|
usbi_signal_transfer_completion(itransfer);
|
|
494
499
|
}
|
|
495
500
|
|
|
@@ -801,8 +806,9 @@ static int windows_handle_transfer_completion(struct usbi_transfer *itransfer)
|
|
|
801
806
|
else
|
|
802
807
|
result = GetLastError();
|
|
803
808
|
|
|
809
|
+
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
|
|
804
810
|
usbi_dbg(ctx, "handling transfer %p completion with errcode %lu, length %lu",
|
|
805
|
-
|
|
811
|
+
transfer, ULONG_CAST(result), ULONG_CAST(bytes_transferred));
|
|
806
812
|
|
|
807
813
|
switch (result) {
|
|
808
814
|
case NO_ERROR:
|
|
@@ -848,6 +854,7 @@ static int windows_handle_transfer_completion(struct usbi_transfer *itransfer)
|
|
|
848
854
|
return usbi_handle_transfer_completion(itransfer, status);
|
|
849
855
|
}
|
|
850
856
|
|
|
857
|
+
#ifndef HAVE_CLOCK_GETTIME
|
|
851
858
|
void usbi_get_monotonic_time(struct timespec *tp)
|
|
852
859
|
{
|
|
853
860
|
static LONG hires_counter_init;
|
|
@@ -872,6 +879,7 @@ void usbi_get_monotonic_time(struct timespec *tp)
|
|
|
872
879
|
tp->tv_sec = (long)(hires_counter.QuadPart / hires_frequency);
|
|
873
880
|
tp->tv_nsec = (long)(((hires_counter.QuadPart % hires_frequency) * hires_ticks_to_ps) / UINT64_C(1000));
|
|
874
881
|
}
|
|
882
|
+
#endif
|
|
875
883
|
|
|
876
884
|
// NB: MSVC6 does not support named initializers.
|
|
877
885
|
const struct usbi_os_backend usbi_backend = {
|
|
@@ -131,6 +131,7 @@ typedef LONG USBD_STATUS;
|
|
|
131
131
|
|
|
132
132
|
#define USBD_SUCCESS(Status) ((USBD_STATUS)(Status) >= 0)
|
|
133
133
|
|
|
134
|
+
#define USBD_STATUS_STALL_PID ((USBD_STATUS)0xC0000004L)
|
|
134
135
|
#define USBD_STATUS_ENDPOINT_HALTED ((USBD_STATUS)0xC0000030L)
|
|
135
136
|
#define USBD_STATUS_TIMEOUT ((USBD_STATUS)0xC0006000L)
|
|
136
137
|
#define USBD_STATUS_DEVICE_GONE ((USBD_STATUS)0xC0007000L)
|
|
@@ -257,6 +258,13 @@ struct winusb_device_priv {
|
|
|
257
258
|
int current_altsetting;
|
|
258
259
|
bool restricted_functionality; // indicates if the interface functionality is restricted
|
|
259
260
|
// by Windows (eg. HID keyboards or mice cannot do R/W)
|
|
261
|
+
uint8_t num_associated_interfaces; // If non-zero, the interface is part of a grouped
|
|
262
|
+
// set of associated interfaces (defined by an IAD)
|
|
263
|
+
// and this is the number of interfaces within the
|
|
264
|
+
// associated group (bInterfaceCount in IAD).
|
|
265
|
+
uint8_t first_associated_interface; // For associated interfaces, this is the index of
|
|
266
|
+
// the first interface (bFirstInterface in IAD) for
|
|
267
|
+
// the grouped set of associated interfaces.
|
|
260
268
|
} usb_interface[USB_MAXINTERFACES];
|
|
261
269
|
struct hid_device_priv *hid;
|
|
262
270
|
PUSB_CONFIGURATION_DESCRIPTOR *config_descriptor; // list of pointers to the cached config descriptors
|