Externals: update libusb to version 1.0.19

This commit is contained in:
Tillmann Karras 2014-12-27 15:39:17 +01:00 committed by mathieui
parent 4ff5ec7117
commit 4fa38f0c02
183 changed files with 27264 additions and 2665 deletions

View File

@ -1,23 +1,26 @@
Copyright © 2001 Johannes Erdfelt <johannes@erdfelt.com>
Copyright © 2007-2009 Daniel Drake <dsd@gentoo.org>
Copyright © 2010-2012 Peter Stuge <peter@stuge.se>
Copyright © 2008-2011 Nathan Hjelm <hjelmn@users.sourceforge.net>
Copyright © 2009-2012 Pete Batard <pete@akeo.ie>
Copyright © 2009-2012 Ludovic Rousseau <ludovic.rousseau@gmail.com>
Copyright © 2008-2013 Nathan Hjelm <hjelmn@users.sourceforge.net>
Copyright © 2009-2013 Pete Batard <pete@akeo.ie>
Copyright © 2009-2013 Ludovic Rousseau <ludovic.rousseau@gmail.com>
Copyright © 2010-2012 Michael Plante <michael.plante@gmail.com>
Copyright © 2011-2012 Hans de Goede <hdegoede@redhat.com>
Copyright © 2012 Martin Pieuchot <mpi@openbsd.org>
Copyright © 2011-2013 Hans de Goede <hdegoede@redhat.com>
Copyright © 2012-2013 Martin Pieuchot <mpi@openbsd.org>
Copyright © 2012-2013 Toby Gray <toby.gray@realvnc.com>
Other contributors:
Alan Ott
Alan Stern
Alex Vatchenko
Andrew Fernandes
Anthony Clay
Artem Egorkine
Aurelien Jarno
Bastien Nocera
Bei Zhang
Benjamin Dobell
Carl Karsten
Chris Dickens
Colin Walters
Dave Camarillo
@ -26,22 +29,36 @@ David Moore
Davidlohr Bueso
Federico Manzan
Felipe Balbi
Florian Albrechtskirchinger
Francesco Montorsi
Francisco Facioni
Graeme Gill
Gustavo Zacarias
Hans Ulrich Niedermann
Hector Martin
Hoi-Ho Chan
Ilya Konstantinov
James Hanko
John Sheu
Joshua Blake
Justin Bischoff
Karsten Koenig
Konrad Rzepecki
Kuangye Guo
Lars Kanis
Lars Wirzenius
Luca Longinotti
Markus Heidelberg
Martin Koegler
Matthias Bolte
Mike Frysinger
Mikhail Gusarov
Moritz Fischer
Ларионов Даниил
Nicholas Corgan
Omri Iluz
Orin Eman
Paul Fertser
Pekka Nikander
Rob Walker
Sean McBride
@ -58,3 +75,4 @@ Vitali Lovich
Xiaofan Chen
Zoltán Kovács
Роман Донченко
xantares

View File

@ -1,5 +1,42 @@
For detailed information about the changes below, please see the git log or
visit: http://log.libusbx.org
visit: http://log.libusb.info
2014-05-30: v1.0.19
* Add support for USB bulk streams on Linux and Mac OS X (#11)
* Windows: Add AMD and Intel USB-3.0 root hub support
* Windows: Fix USB 3.0 speed detection on Windows 8 or later (#10)
* Added Russian translation for libusb_strerror strings
* All: Various small fixes and cleanups
The (#xx) numbers are libusb issue numbers, see ie:
https://github.com/libusb/libusb/issues/11
2014-01-25: v1.0.18
* Fix multiple memory leaks
* Fix a crash when HID transfers return no data on Windows
* Ensure all pending events are consumed
* Improve Android and ucLinux support
* Multiple Windows improvements (error logging, VS2013, VIA xHCI support)
* Multiple OS X improvements (broken compilation, SIGFPE, 64bit support)
2013-09-06: v1.0.17
* Hotplug callbacks now always get passed a libusb_context, even if it is
the default context. Previously NULL would be passed for the default context,
but since the first context created is the default context, and most apps
use only 1 context, this meant that apps explicitly creating a context would
still get passed NULL
* Android: Add .mk files to build with the Android NDK
* Darwin: Add Xcode project
* Darwin: Fix crash on unplug (#121)
* Linux: Fix hang (deadlock) on libusb_exit
* Linux: Fix libusb build failure with --disable-udev (#124)
* Linux: Fix libusb_get_device_list() hang with --disable-udev (#130)
* OpenBSD: Update OpenBSD backend with support for control transfers to
non-ugen(4) devices and make get_configuration() no longer generate I/O.
Note that using this libusb version on OpenBSD requires using
OpenBSD 5.3-current or later. Users of older OpenBSD versions are advised
to stay with the libusb shipped with OpenBSD (mpi)
* Windows: fix libusb_dll_2010.vcxproj link errors (#129)
* Various other bug fixes and improvements
2013-07-11: v1.0.16
* Add hotplug support for Darwin and Linux (#9)
@ -40,7 +77,7 @@ https://github.com/libusbx/libusbx/issues/9
* Reverts the previous API change with regards to bMaxPower.
If this doesn't matter to you, you are encouraged to keep using v1.0.13,
as it will use the same attribute as v2.0, to be released soon.
* Note that LIBUSBX_API_VERSION is *decreased* to 0x010000FF and the previous
* Note that LIBUSB_API_VERSION is *decreased* to 0x010000FF and the previous
guidelines with regards to concurrent use of MaxPower/bMaxPower still apply.
2012-09-20: v1.0.13
@ -51,11 +88,11 @@ https://github.com/libusbx/libusbx/issues/9
* Fix broken support for the 0.1 -> 1.0 libusb-compat layer
* Fix unwanted cancellation of pending timeouts as well as major timeout related bugs
* Fix handling of HID and composite devices on Windows
* Introduce LIBUSBX_API_VERSION macro
* Introduce LIBUSB_API_VERSION macro
* Add Cypress FX/FX2 firmware upload sample, based on fxload from
http://linux-hotplug.sourceforge.net
* Add libusb0 (libusb-win32) and libusbK driver support on Windows. Note that while
the drivers allow it, isochronous transfers are not supported yet in libusbx. Also
the drivers allow it, isochronous transfers are not supported yet in libusb. Also
not supported yet is the use of libusb-win32 filter drivers on composite interfaces
* Add support for the new get_capabilities ioctl on Linux and avoid unnecessary
splitting of bulk transfers
@ -156,18 +193,18 @@ https://github.com/libusbx/libusbx/issues/9
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
APPENDIX A - How to maintain code compatibility with versions of libusb and
libusbx that use MaxPower:
libusb that use MaxPower:
If you must to maintain compatibility with versions of the library that aren't
using the bMaxPower attribute in struct libusb_config_descriptor, the
recommended way is to use the new LIBUSBX_API_VERSION macro with an #ifdef.
recommended way is to use the new LIBUSB_API_VERSION macro with an #ifdef.
For instance, if your code was written as follows:
if (dev->config[0].MaxPower < 250)
Then you should modify it to have:
#if defined(LIBUSBX_API_VERSION) && (LIBUSBX_API_VERSION >= 0x01000100)
#if defined(LIBUSB_API_VERSION) && (LIBUSB_API_VERSION >= 0x01000100)
if (dev->config[0].bMaxPower < 250)
#else
if (dev->config[0].MaxPower < 250)

View File

@ -2,7 +2,8 @@ AUTOMAKE_OPTIONS = dist-bzip2 no-dist-gzip
ACLOCAL_AMFLAGS = -I m4
DISTCLEANFILES = libusb-1.0.pc
EXTRA_DIST = TODO PORTING msvc libusb/libusb-1.0.def libusb/version_nano.h \
examples/getopt/getopt.c examples/getopt/getopt1.c examples/getopt/getopt.h
examples/getopt/getopt.c examples/getopt/getopt1.c examples/getopt/getopt.h \
android Xcode
SUBDIRS = libusb doc
if BUILD_EXAMPLES

View File

@ -1,4 +1,4 @@
# Makefile.in generated by automake 1.13.4 from Makefile.am.
# Makefile.in generated by automake 1.14.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
@ -84,9 +84,9 @@ subdir = .
DIST_COMMON = INSTALL NEWS README AUTHORS ChangeLog \
$(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(top_srcdir)/configure $(am__configure_deps) \
$(srcdir)/config.h.in $(srcdir)/libusb-1.0.pc.in COPYING \
THANKS TODO compile config.guess config.sub depcomp install-sh \
missing ltmain.sh
$(srcdir)/config.h.in $(srcdir)/libusb-1.0.pc.in COPYING TODO \
compile config.guess config.sub depcomp install-sh missing \
ltmain.sh
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
@ -279,6 +279,7 @@ OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OS_DARWIN = @OS_DARWIN@
OS_LINUX = @OS_LINUX@
OS_NETBSD = @OS_NETBSD@
OS_OPENBSD = @OS_OPENBSD@
OS_WINDOWS = @OS_WINDOWS@
OTOOL = @OTOOL@
@ -355,7 +356,8 @@ AUTOMAKE_OPTIONS = dist-bzip2 no-dist-gzip
ACLOCAL_AMFLAGS = -I m4
DISTCLEANFILES = libusb-1.0.pc
EXTRA_DIST = TODO PORTING msvc libusb/libusb-1.0.def libusb/version_nano.h \
examples/getopt/getopt.c examples/getopt/getopt1.c examples/getopt/getopt.h
examples/getopt/getopt.c examples/getopt/getopt1.c examples/getopt/getopt.h \
android Xcode
SUBDIRS = libusb doc $(am__append_1) $(am__append_2)
pkgconfigdir = $(libdir)/pkgconfig
@ -401,8 +403,8 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
$(am__aclocal_m4_deps):
config.h: stamp-h1
@if test ! -f $@; then rm -f stamp-h1; else :; fi
@if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi
@test -f $@ || rm -f stamp-h1
@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1
stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
@rm -f stamp-h1
@ -633,10 +635,16 @@ dist-xz: distdir
$(am__post_remove_distdir)
dist-tarZ: distdir
@echo WARNING: "Support for shar distribution archives is" \
"deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
$(am__post_remove_distdir)
dist-shar: distdir
@echo WARNING: "Support for distribution archives compressed with" \
"legacy program 'compress' is deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
$(am__post_remove_distdir)
@ -678,9 +686,10 @@ distcheck: dist
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
&& am__cwd=`pwd` \
&& $(am__cd) $(distdir)/_build \
&& ../configure --srcdir=.. --prefix="$$dc_install_base" \
&& ../configure \
$(AM_DISTCHECK_CONFIGURE_FLAGS) \
$(DISTCHECK_CONFIGURE_FLAGS) \
--srcdir=.. --prefix="$$dc_install_base" \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \

2
Externals/libusb/NEWS vendored Normal file
View File

@ -0,0 +1,2 @@
For the latest libusb news, please refer to the ChangeLog file, or visit:
http://libusb.info

View File

@ -1,15 +1,15 @@
PORTING LIBUSBX TO OTHER PLATFORMS
PORTING LIBUSB TO OTHER PLATFORMS
Introduction
============
This document is aimed at developers wishing to port libusbx to unsupported
platforms. I believe the libusbx API is OS-independent, so by supporting
This document is aimed at developers wishing to port libusb to unsupported
platforms. I believe the libusb API is OS-independent, so by supporting
multiple operating systems we pave the way for cross-platform USB device
drivers.
Implementation-wise, the basic idea is that you provide an interface to
libusbx's internal "backend" API, which performs the appropriate operations on
libusb's internal "backend" API, which performs the appropriate operations on
your target platform.
In terms of USB I/O, your backend provides functionality to submit
@ -27,16 +27,16 @@ e.g. setting configuration, obtaining descriptors, etc.
File descriptors for I/O polling
================================
For libusbx to work, your event handling function obviously needs to be called
For libusb to work, your event handling function obviously needs to be called
at various points in time. Your backend must provide a set of file descriptors
which libusbx and its users can pass to poll() or select() to determine when
which libusb and its users can pass to poll() or select() to determine when
it is time to call the event handling function.
On Linux, this is easy: the usbfs kernel interface exposes a file descriptor
which can be passed to poll(). If something similar is not true for your
platform, you can emulate this using an internal library thread to reap I/O as
necessary, and a pipe() with the main library to raise events. The file
descriptor of the pipe can then be provided to libusbx as an event source.
descriptor of the pipe can then be provided to libusb as an event source.
Interface semantics and documentation
@ -46,7 +46,7 @@ Documentation of the backend interface can be found in libusbi.h inside the
usbi_os_backend structure definition.
Your implementations of these functions will need to call various internal
libusbx functions, prefixed with "usbi_". Documentation for these functions
libusb functions, prefixed with "usbi_". Documentation for these functions
can be found in the .c files where they are implemented.
You probably want to skim over *all* the documentation before starting your
@ -72,18 +72,18 @@ right usbi_backend for your platform.
4. Produce and test your implementation.
5. Send your implementation to libusbx-devel mailing list.
5. Send your implementation to libusb-devel mailing list.
Implementation difficulties? Questions?
=======================================
If you encounter difficulties porting libusbx to your platform, please raise
these issues on the libusbx-devel mailing list. Where possible and sensible, I
am interested in solving problems preventing libusbx from operating on other
If you encounter difficulties porting libusb to your platform, please raise
these issues on the libusb-devel mailing list. Where possible and sensible, I
am interested in solving problems preventing libusb from operating on other
platforms.
The libusbx-devel mailing list is also a good place to ask questions and
The libusb-devel mailing list is also a good place to ask questions and
make suggestions about the internal API. Hopefully we can produce some
better documentation based on your questions and other input.

27
Externals/libusb/README vendored Normal file
View File

@ -0,0 +1,27 @@
libusb
======
libusb is a library for USB device access from Linux, Mac OS X,
Windows and OpenBSD/NetBSD userspace.
It is written in C and licensed under the GNU Lesser General Public
License version 2.1 or, at your option, any later version (see COPYING).
libusb is abstracted internally in such a way that it can hopefully
be ported to other operating systems. Please see the PORTING file
for more information.
libusb homepage:
http://libusb.info/
Developers will wish to consult the API documentation:
http://api.libusb.info
Use the mailing list for questions, comments, etc:
http://mailing-list.libusb.info
- Pete Batard <pete@akeo.ie>
- Hans de Goede <hdegoede@redhat.com>
- Xiaofan Chen <xiaofanc@gmail.com>
- Ludovic Rousseau <ludovic.rousseau@gmail.com>
- Nathan Hjelm <hjelmn@users.sourceforge.net>
(Please use the mailing list rather than mailing developers directly)

2
Externals/libusb/TODO vendored Normal file
View File

@ -0,0 +1,2 @@
Please see the libusb roadmap by visiting:
https://github.com/libusb/libusb/issues/milestones?direction=asc&sort=due_date

49
Externals/libusb/Xcode/common.xcconfig vendored Normal file
View File

@ -0,0 +1,49 @@
//
// libusb Xcode configuration file
// Copyright © 2012 Pete Batard <pete@akeo.ie>
// For more information, please visit: <http://libusb.info>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
// libusb does not follow C99 strict aliasing rules, so disable it.
GCC_STRICT_ALIASING = NO
// Use C99 dialect.
GCC_C_LANGUAGE_STANDARD = c99
// Compiler warnings.
GCC_WARN_64_TO_32_BIT_CONVERSION = YES
GCC_WARN_ABOUT_RETURN_TYPE = YES
GCC_WARN_UNINITIALIZED_AUTOS = YES
GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES
GCC_WARN_SHADOW = YES
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES
GCC_WARN_ABOUT_MISSING_NEWLINE = YES
GCC_WARN_UNKNOWN_PRAGMAS = YES
GCC_WARN_UNUSED_FUNCTION = YES
GCC_WARN_UNUSED_LABEL = YES
GCC_WARN_UNUSED_VARIABLE = YES
CLANG_WARN_EMPTY_BODY = YES
CLANG_WARN_CONSTANT_CONVERSION = YES
CLANG_WARN_ENUM_CONVERSION = YES
CLANG_WARN_INT_CONVERSION = YES
CLANG_WARN_DOCUMENTATION_COMMENTS = YES
CLANG_WARN_BOOL_CONVERSION = YES
// Static analyzer warnings.
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES
CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES

28
Externals/libusb/Xcode/config.h vendored Normal file
View File

@ -0,0 +1,28 @@
/* config.h. Manually generated for Xcode. */
/* Default visibility */
#define DEFAULT_VISIBILITY /**/
/* Message logging */
#define ENABLE_LOGGING 1
/* Define to 1 if you have the `gettimeofday' function. */
#define HAVE_GETTIMEOFDAY 1
/* Define to 1 if you have the <poll.h> header file. */
#define HAVE_POLL_H 1
/* Define to 1 if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
/* Darwin backend */
#define OS_DARWIN 1
/* type of second poll() argument */
#define POLL_NFDS_TYPE nfds_t
/* Use POSIX Threads */
#define THREADS_POSIX 1
/* Use GNU extensions */
#define _GNU_SOURCE 1

29
Externals/libusb/Xcode/debug.xcconfig vendored Normal file
View File

@ -0,0 +1,29 @@
//
// libusb Xcode configuration file
// Copyright © 2012 Pete Batard <pete@akeo.ie>
// For more information, please visit: <http://libusb.info>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include "common.xcconfig"
// Embed debug symbols in binary itself.
DEBUG_INFORMATION_FORMAT = dwarf
// No optimizations in debug.
GCC_OPTIMIZATION_LEVEL = 0
//
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) DEBUG=1

21
Externals/libusb/Xcode/libusb.xcconfig vendored Normal file
View File

@ -0,0 +1,21 @@
//
// libusb Xcode configuration file
// Copyright © 2012 Pete Batard <pete@akeo.ie>
// For more information, please visit: <http://libusb.info>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
PRODUCT_NAME = libusb-1.0.0
LD_DYLIB_INSTALL_NAME = @rpath/libusb-1.0.0.dylib

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,21 @@
//
// libusb Xcode configuration file
// Copyright © 2012 Pete Batard <pete@akeo.ie>
// For more information, please visit: <http://libusb.info>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include "debug.xcconfig"
#include "libusb.xcconfig"

View File

@ -0,0 +1,21 @@
//
// libusb Xcode configuration file
// Copyright © 2012 Pete Batard <pete@akeo.ie>
// For more information, please visit: <http://libusb.info>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include "release.xcconfig"
#include "libusb.xcconfig"

30
Externals/libusb/Xcode/release.xcconfig vendored Normal file
View File

@ -0,0 +1,30 @@
//
// libusb Xcode configuration file
// Copyright © 2012 Pete Batard <pete@akeo.ie>
// For more information, please visit: <http://libusb.info>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include "common.xcconfig"
// Put debug symbols in separate .dym file.
DEBUG_INFORMATION_FORMAT = dwarf-with-dsym
// Optimizations in release.
GCC_OPTIMIZATION_LEVEL = s
LLVM_LTO = YES
// Define NDEBUG so asserts go away in release.
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) NDEBUG=1

View File

@ -1,4 +1,4 @@
# generated automatically by aclocal 1.13.4 -*- Autoconf -*-
# generated automatically by aclocal 1.14.1 -*- Autoconf -*-
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
@ -32,10 +32,10 @@ To do so, use the procedure documented by the package, typically 'autoreconf'.])
# generated from the m4 files accompanying Automake X.Y.
# (This private macro should not be called outside this file.)
AC_DEFUN([AM_AUTOMAKE_VERSION],
[am__api_version='1.13'
[am__api_version='1.14'
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
dnl require some minimum version. Point them to the right macro.
m4_if([$1], [1.13.4], [],
m4_if([$1], [1.14.1], [],
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
])
@ -51,7 +51,7 @@ m4_define([_AM_AUTOCONF_VERSION], [])
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.13.4])dnl
[AM_AUTOMAKE_VERSION([1.14.1])dnl
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
@ -418,6 +418,12 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
# This macro actually does too much. Some checks are only needed if
# your package does certain things. But this isn't really a big deal.
dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O.
m4_define([AC_PROG_CC],
m4_defn([AC_PROG_CC])
[_AM_PROG_CC_C_O
])
# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
# AM_INIT_AUTOMAKE([OPTIONS])
# -----------------------------------------------
@ -526,7 +532,48 @@ dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below.
AC_CONFIG_COMMANDS_PRE(dnl
[m4_provide_if([_AM_COMPILER_EXEEXT],
[AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
])
# POSIX will say in a future version that running "rm -f" with no argument
# is OK; and we want to be able to make that assumption in our Makefile
# recipes. So use an aggressive probe to check that the usage we want is
# actually supported "in the wild" to an acceptable degree.
# See automake bug#10828.
# To make any issue more visible, cause the running configure to be aborted
# by default if the 'rm' program in use doesn't match our expectations; the
# user can still override this though.
if rm -f && rm -fr && rm -rf; then : OK; else
cat >&2 <<'END'
Oops!
Your 'rm' program seems unable to run without file operands specified
on the command line, even when the '-f' option is present. This is contrary
to the behaviour of most rm programs out there, and not conforming with
the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542>
Please tell bug-automake@gnu.org about your system, including the value
of your $PATH and any error possibly output before this message. This
can help us improve future automake versions.
END
if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
echo 'Configuration will proceed anyway, since you have set the' >&2
echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
echo >&2
else
cat >&2 <<'END'
Aborting the configuration process, to ensure you take notice of the issue.
You can download and install GNU coreutils to get an 'rm' implementation
that behaves properly: <http://www.gnu.org/software/coreutils/>.
If you want to complete the configuration process using your problematic
'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
to "yes", and re-run configure.
END
AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
fi
fi])
dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not
dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
@ -534,7 +581,6 @@ dnl mangled by Autoconf and run in a shell conditional statement.
m4_define([_AC_COMPILER_EXEEXT],
m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
# When config.status generates a header, we must update the stamp-h file.
# This file resides in the same directory as the config header
# that is generated. The stamp files are numbered to have different names.
@ -682,38 +728,6 @@ AC_MSG_RESULT([$_am_result])
rm -f confinc confmf
])
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_PROG_CC_C_O
# --------------
# Like AC_PROG_CC_C_O, but changed for automake.
AC_DEFUN([AM_PROG_CC_C_O],
[AC_REQUIRE([AC_PROG_CC_C_O])dnl
AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
AC_REQUIRE_AUX_FILE([compile])dnl
# FIXME: we rely on the cache variable name because
# there is no other way.
set dummy $CC
am_cc=`echo $[2] | sed ['s/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/']`
eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o
if test "$am_t" != yes; then
# Losing compiler, so override with the script.
# FIXME: It is wrong to rewrite CC.
# But if we don't then we get into trouble of one sort or another.
# A longer-term fix would be to have automake use am__CC in this case,
# and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
CC="$am_aux_dir/compile $CC"
fi
dnl Make sure AC_PROG_CC is never called again, or it will override our
dnl setting of CC.
m4_define([AC_PROG_CC],
[m4_fatal([AC_PROG_CC cannot be called after AM_PROG_CC_C_O])])
])
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
# Copyright (C) 1997-2013 Free Software Foundation, Inc.
@ -784,6 +798,70 @@ AC_DEFUN([_AM_SET_OPTIONS],
AC_DEFUN([_AM_IF_OPTION],
[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# _AM_PROG_CC_C_O
# ---------------
# Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC
# to automatically call this.
AC_DEFUN([_AM_PROG_CC_C_O],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
AC_REQUIRE_AUX_FILE([compile])dnl
AC_LANG_PUSH([C])dnl
AC_CACHE_CHECK(
[whether $CC understands -c and -o together],
[am_cv_prog_cc_c_o],
[AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
# Make sure it works both with $CC and with simple cc.
# Following AC_PROG_CC_C_O, we do the test twice because some
# compilers refuse to overwrite an existing .o file with -o,
# though they will create one.
am_cv_prog_cc_c_o=yes
for am_i in 1 2; do
if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \
&& test -f conftest2.$ac_objext; then
: OK
else
am_cv_prog_cc_c_o=no
break
fi
done
rm -f core conftest*
unset am_i])
if test "$am_cv_prog_cc_c_o" != yes; then
# Losing compiler, so override with the script.
# FIXME: It is wrong to rewrite CC.
# But if we don't then we get into trouble of one sort or another.
# A longer-term fix would be to have automake use am__CC in this case,
# and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
CC="$am_aux_dir/compile $CC"
fi
AC_LANG_POP([C])])
# For backward compatibility.
AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_RUN_LOG(COMMAND)
# -------------------
# Run COMMAND, save the exit status in ac_status, and log it.
# (This has been adapted from Autoconf's _AC_RUN_LOG macro.)
AC_DEFUN([AM_RUN_LOG],
[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD
($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
(exit $ac_status); }])
# Check to make sure that the build environment is sane. -*- Autoconf -*-
# Copyright (C) 1996-2013 Free Software Foundation, Inc.

114
Externals/libusb/android/README vendored Normal file
View File

@ -0,0 +1,114 @@
libusb for Android
==================
Building:
---------
To build libusb for Android do the following:
1. Download the latest NDK from:
http://developer.android.com/tools/sdk/ndk/index.html
2. Extract the NDK.
3. Open a shell and make sure there exist an NDK global variable
set to the directory where you extracted the NDK.
4. Change directory to libusb's "android/jni"
5. Run "$NDK/ndk-build".
The libusb library, examples and tests can then be found in:
"android/libs/$ARCH"
Where $ARCH is one of:
armeabi
armeabi-v7a
x86
Installing:
-----------
If you wish to use libusb from native code in own Android application
then you should add the following line to your Android.mk file:
include $(PATH_TO_LIBUSB_SRC)/android/jni/libusb.mk
You will then need to add the following lines to the build
configuration for each native binary which uses libusb:
LOCAL_C_INCLUDES += $(LIBUSB_ROOT_ABS)
LOCAL_SHARED_LIBRARIES += libusb1.0
The Android build system will then correctly include libusb in the
application package (APK) file, provided ndk-build is invoked before
the package is built.
For a rooted device it is possible to install libusb into the system
image of a running device:
1. Enable ADB on the device.
2. Connect the device to a machine running ADB.
3. Execute the following commands on the machine
running ADB:
# Make the system partition writable
adb shell su -c "mount -o remount,rw /system"
# Install libusb
adb push obj/local/armeabi/libusb1.0.so /sdcard/
adb shell su -c "cat > /system/lib/libusb1.0.so < /sdcard/libusb1.0.so"
adb shell rm /system/lib/libusb1.0.so
# Install the samples and tests
for B in listdevs fxload xusb sam3u_benchmark hotplugtest stress
do
adb push "obj/local/armeabi/$B" /sdcard/
adb shell su -c "cat > /system/bin/$B < /sdcard/$B"
adb shell su -c "chmod 0755 /system/bin/$B"
adb shell rm "/sdcard/$B"
done
# Make the system partition read only again
adb shell su -c "mount -o remount,ro /system"
# Run listdevs to
adb shell su -c "listdevs"
4. If your device only has a single OTG port then ADB can generally
be switched to using Wifi with the following commands when connected
via USB:
adb shell netcfg
# Note the wifi IP address of the phone
adb tcpip 5555
# Use the IP address from netcfg
adb connect 192.168.1.123:5555
Runtime Permissions:
--------------------
The default system configuration on most Android device will not allow
access to USB devices. There are several options for changing this.
If you have control of the system image then you can modify the
ueventd.rc used in the image to change the permissions on
/dev/bus/usb/*/*. If using this approach then it is advisable to
create a new Android permission to protect access to these files.
It is not advisable to give all applications read and write permissions
to these files.
For rooted devices the code using libusb could be executed as root
using the "su" command. An alternative would be to use the "su" command
to change the permissions on the appropriate /dev/bus/usb/ files.
Users have reported success in using android.hardware.usb.UsbManager
to request permission to use the UsbDevice and then opening the
device. The difficulties in this method is that there is no guarantee
that it will continue to work in the future Android versions, it
requires invoking Java APIs and running code to match each
android.hardware.usb.UsbDevice to a libusb_device.

81
Externals/libusb/android/config.h vendored Normal file
View File

@ -0,0 +1,81 @@
/*
* Android build config for libusb
* Copyright © 2012-2013 RealVNC Ltd. <toby.gray@realvnc.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* Start with debug message logging enabled */
/* #undef ENABLE_DEBUG_LOGGING */
/* Message logging */
#define ENABLE_LOGGING
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
/* Define to 1 if you have the `gettimeofday' function. */
#define HAVE_GETTIMEOFDAY 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Linux backend */
#define OS_LINUX 1
/* Enable output to system log */
#define USE_SYSTEM_LOGGING_FACILITY 1
/* type of second poll() argument */
#define POLL_NFDS_TYPE nfds_t
/* Use POSIX Threads */
#define THREADS_POSIX 1
/* Default visibility */
#define DEFAULT_VISIBILITY __attribute__((visibility("default")))
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the <poll.h> header file. */
#define HAVE_POLL_H 1
/* Define to 1 if you have the <signal.h> header file. */
#define HAVE_SIGNAL_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to 1 if you have the <linux/filter.h> header file. */
#define HAVE_LINUX_FILTER_H 1
/* Define to 1 if you have the <linux/netlink.h> header file. */
#define HAVE_LINUX_NETLINK_H 1
/* Define to 1 if you have the <asm/types.h> header file. */
#define HAVE_ASM_TYPES_H 1
/* Define to 1 if you have the <sys/socket.h> header file. */
#define HAVE_SYS_SOCKET_H 1

23
Externals/libusb/android/jni/Android.mk vendored Normal file
View File

@ -0,0 +1,23 @@
# Android build config for libusb, examples and tests
# Copyright © 2012-2013 RealVNC Ltd. <toby.gray@realvnc.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
LOCAL_PATH:= $(call my-dir)
include $(LOCAL_PATH)/libusb.mk
include $(LOCAL_PATH)/examples.mk
include $(LOCAL_PATH)/tests.mk

View File

@ -0,0 +1,24 @@
# Android application build config for libusb
# Copyright © 2012-2013 RealVNC Ltd. <toby.gray@realvnc.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
APP_ABI := all
# Workaround for MIPS toolchain linker being unable to find liblog dependency
# of shared object in NDK versions at least up to r9.
#
APP_LDFLAGS := -llog

134
Externals/libusb/android/jni/examples.mk vendored Normal file
View File

@ -0,0 +1,134 @@
# Android build config for libusb examples
# Copyright © 2012-2013 RealVNC Ltd. <toby.gray@realvnc.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
LOCAL_PATH:= $(call my-dir)
LIBUSB_ROOT_REL:= ../..
LIBUSB_ROOT_ABS:= $(LOCAL_PATH)/../..
# listdevs
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(LIBUSB_ROOT_REL)/examples/listdevs.c
LOCAL_C_INCLUDES += \
$(LIBUSB_ROOT_ABS)
LOCAL_SHARED_LIBRARIES += libusb1.0
LOCAL_MODULE:= listdevs
include $(BUILD_EXECUTABLE)
# xusb
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(LIBUSB_ROOT_REL)/examples/xusb.c
LOCAL_C_INCLUDES += \
$(LIBUSB_ROOT_ABS)
LOCAL_SHARED_LIBRARIES += libusb1.0
LOCAL_MODULE:= xusb
include $(BUILD_EXECUTABLE)
# hotplugtest
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(LIBUSB_ROOT_REL)/examples/hotplugtest.c
LOCAL_C_INCLUDES += \
$(LIBUSB_ROOT_ABS)
LOCAL_SHARED_LIBRARIES += libusb1.0
LOCAL_MODULE:= hotplugtest
include $(BUILD_EXECUTABLE)
# fxload
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(LIBUSB_ROOT_REL)/examples/fxload.c \
$(LIBUSB_ROOT_REL)/examples/ezusb.c
LOCAL_C_INCLUDES += \
$(LIBUSB_ROOT_ABS)
LOCAL_SHARED_LIBRARIES += libusb1.0
LOCAL_MODULE:= fxload
include $(BUILD_EXECUTABLE)
# sam3u_benchmake
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(LIBUSB_ROOT_REL)/examples/sam3u_benchmark.c
LOCAL_C_INCLUDES += \
$(LIBUSB_ROOT_ABS)
LOCAL_SHARED_LIBRARIES += libusb1.0
LOCAL_MODULE:= sam3u_benchmark
include $(BUILD_EXECUTABLE)
# dpfp
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(LIBUSB_ROOT_REL)/examples/dpfp.c
LOCAL_C_INCLUDES += \
$(LIBUSB_ROOT_ABS)
LOCAL_SHARED_LIBRARIES += libusb1.0
LOCAL_MODULE:= dpfp
include $(BUILD_EXECUTABLE)
# dpfp_threaded
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(LIBUSB_ROOT_REL)/examples/dpfp_threaded.c
LOCAL_C_INCLUDES += \
$(LIBUSB_ROOT_ABS)
LOCAL_SHARED_LIBRARIES += libusb1.0
LOCAL_MODULE:= dpfp_threaded
include $(BUILD_EXECUTABLE)

54
Externals/libusb/android/jni/libusb.mk vendored Normal file
View File

@ -0,0 +1,54 @@
# Android build config for libusb
# Copyright © 2012-2013 RealVNC Ltd. <toby.gray@realvnc.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
LOCAL_PATH:= $(call my-dir)
LIBUSB_ROOT_REL:= ../..
LIBUSB_ROOT_ABS:= $(LOCAL_PATH)/../..
# libusb
include $(CLEAR_VARS)
LIBUSB_ROOT_REL:= ../..
LIBUSB_ROOT_ABS:= $(LOCAL_PATH)/../..
LOCAL_SRC_FILES := \
$(LIBUSB_ROOT_REL)/libusb/core.c \
$(LIBUSB_ROOT_REL)/libusb/descriptor.c \
$(LIBUSB_ROOT_REL)/libusb/hotplug.c \
$(LIBUSB_ROOT_REL)/libusb/io.c \
$(LIBUSB_ROOT_REL)/libusb/sync.c \
$(LIBUSB_ROOT_REL)/libusb/strerror.c \
$(LIBUSB_ROOT_REL)/libusb/os/linux_usbfs.c \
$(LIBUSB_ROOT_REL)/libusb/os/poll_posix.c \
$(LIBUSB_ROOT_REL)/libusb/os/threads_posix.c \
$(LIBUSB_ROOT_REL)/libusb/os/linux_netlink.c
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/.. \
$(LIBUSB_ROOT_ABS)/libusb \
$(LIBUSB_ROOT_ABS)/libusb/os
LOCAL_EXPORT_C_INCLUDES := \
$(LIBUSB_ROOT_ABS)/libusb
LOCAL_LDLIBS := -llog
LOCAL_MODULE := libusb1.0
include $(BUILD_SHARED_LIBRARY)

56
Externals/libusb/android/jni/tests.mk vendored Normal file
View File

@ -0,0 +1,56 @@
# Android build config for libusb tests
# Copyright © 2012-2013 RealVNC Ltd. <toby.gray@realvnc.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
LOCAL_PATH:= $(call my-dir)
LIBUSB_ROOT_REL:= ../..
LIBUSB_ROOT_ABS:= $(LOCAL_PATH)/../..
# testlib
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(LIBUSB_ROOT_REL)/tests/testlib.c
LOCAL_C_INCLUDES += \
$(LIBUSB_ROOT_ABS)/tests
LOCAL_EXPORT_C_INCLUDES := \
$(LIBUSB_ROOT_ABS)/tests
LOCAL_MODULE := testlib
include $(BUILD_STATIC_LIBRARY)
# stress
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(LIBUSB_ROOT_REL)/tests/stress.c
LOCAL_C_INCLUDES += \
$(LIBUSB_ROOT_ABS)
LOCAL_SHARED_LIBRARIES += libusb1.0
LOCAL_STATIC_LIBRARIES += testlib
LOCAL_MODULE:= stress
include $(BUILD_EXECUTABLE)

0
Externals/libusbx/compile → Externals/libusb/compile vendored Normal file → Executable file
View File

161
Externals/libusbx/config.guess → Externals/libusb/config.guess vendored Normal file → Executable file
View File

@ -1,10 +1,8 @@
#! /bin/sh
# Attempt to guess a canonical system name.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012, 2013 Free Software Foundation, Inc.
# Copyright 1992-2013 Free Software Foundation, Inc.
timestamp='2012-12-29'
timestamp='2013-11-29'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@ -26,7 +24,7 @@ timestamp='2012-12-29'
# program. This Exception is an additional permission under section 7
# of the GNU General Public License, version 3 ("GPLv3").
#
# Originally written by Per Bothner.
# Originally written by Per Bothner.
#
# You can get the latest version of this script from:
# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
@ -52,9 +50,7 @@ version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
2012, 2013 Free Software Foundation, Inc.
Copyright 1992-2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@ -136,6 +132,27 @@ UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
case "${UNAME_SYSTEM}" in
Linux|GNU|GNU/*)
# If the system lacks a compiler, then just pick glibc.
# We could probably try harder.
LIBC=gnu
eval $set_cc_for_build
cat <<-EOF > $dummy.c
#include <features.h>
#if defined(__UCLIBC__)
LIBC=uclibc
#elif defined(__dietlibc__)
LIBC=dietlibc
#else
LIBC=gnu
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
;;
esac
# Note: order is significant - the case branches are not exclusive.
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
@ -857,21 +874,21 @@ EOF
exit ;;
*:GNU:*:*)
# the GNU system
echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
exit ;;
*:GNU/*:*:*)
# other systems with GNU libc and userland
echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC}
exit ;;
i*86:Minix:*:*)
echo ${UNAME_MACHINE}-pc-minix
exit ;;
aarch64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
aarch64_be:Linux:*:*)
UNAME_MACHINE=aarch64_be
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
alpha:Linux:*:*)
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
@ -884,59 +901,54 @@ EOF
EV68*) UNAME_MACHINE=alphaev68 ;;
esac
objdump --private-headers /bin/sh | grep -q ld.so.1
if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
if test "$?" = 0 ; then LIBC="gnulibc1" ; fi
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
arc:Linux:*:* | arceb:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
arm*:Linux:*:*)
eval $set_cc_for_build
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_EABI__
then
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
else
if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_PCS_VFP
then
echo ${UNAME_MACHINE}-unknown-linux-gnueabi
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi
else
echo ${UNAME_MACHINE}-unknown-linux-gnueabihf
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf
fi
fi
exit ;;
avr32*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
cris:Linux:*:*)
echo ${UNAME_MACHINE}-axis-linux-gnu
echo ${UNAME_MACHINE}-axis-linux-${LIBC}
exit ;;
crisv32:Linux:*:*)
echo ${UNAME_MACHINE}-axis-linux-gnu
echo ${UNAME_MACHINE}-axis-linux-${LIBC}
exit ;;
frv:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
hexagon:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
i*86:Linux:*:*)
LIBC=gnu
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#ifdef __dietlibc__
LIBC=dietlibc
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
echo ${UNAME_MACHINE}-pc-linux-${LIBC}
exit ;;
ia64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
m32r*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
m68*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
mips:Linux:*:* | mips64:Linux:*:*)
eval $set_cc_for_build
@ -955,54 +967,63 @@ EOF
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
;;
or1k:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
or32:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
padre:Linux:*:*)
echo sparc-unknown-linux-gnu
echo sparc-unknown-linux-${LIBC}
exit ;;
parisc64:Linux:*:* | hppa64:Linux:*:*)
echo hppa64-unknown-linux-gnu
echo hppa64-unknown-linux-${LIBC}
exit ;;
parisc:Linux:*:* | hppa:Linux:*:*)
# Look for CPU level
case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
PA7*) echo hppa1.1-unknown-linux-gnu ;;
PA8*) echo hppa2.0-unknown-linux-gnu ;;
*) echo hppa-unknown-linux-gnu ;;
PA7*) echo hppa1.1-unknown-linux-${LIBC} ;;
PA8*) echo hppa2.0-unknown-linux-${LIBC} ;;
*) echo hppa-unknown-linux-${LIBC} ;;
esac
exit ;;
ppc64:Linux:*:*)
echo powerpc64-unknown-linux-gnu
echo powerpc64-unknown-linux-${LIBC}
exit ;;
ppc:Linux:*:*)
echo powerpc-unknown-linux-gnu
echo powerpc-unknown-linux-${LIBC}
exit ;;
ppc64le:Linux:*:*)
echo powerpc64le-unknown-linux-${LIBC}
exit ;;
ppcle:Linux:*:*)
echo powerpcle-unknown-linux-${LIBC}
exit ;;
s390:Linux:*:* | s390x:Linux:*:*)
echo ${UNAME_MACHINE}-ibm-linux
echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
exit ;;
sh64*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
sh*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
sparc:Linux:*:* | sparc64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
tile*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
vax:Linux:*:*)
echo ${UNAME_MACHINE}-dec-linux-gnu
echo ${UNAME_MACHINE}-dec-linux-${LIBC}
exit ;;
x86_64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
xtensa*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
i*86:DYNIX/ptx:4*:*)
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
@ -1235,19 +1256,31 @@ EOF
exit ;;
*:Darwin:*:*)
UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
case $UNAME_PROCESSOR in
i386)
eval $set_cc_for_build
if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
then
UNAME_PROCESSOR="x86_64"
fi
fi ;;
unknown) UNAME_PROCESSOR=powerpc ;;
esac
eval $set_cc_for_build
if test "$UNAME_PROCESSOR" = unknown ; then
UNAME_PROCESSOR=powerpc
fi
if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then
if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
then
case $UNAME_PROCESSOR in
i386) UNAME_PROCESSOR=x86_64 ;;
powerpc) UNAME_PROCESSOR=powerpc64 ;;
esac
fi
fi
elif test "$UNAME_PROCESSOR" = i386 ; then
# Avoid executing cc on OS X 10.9, as it ships with a stub
# that puts up a graphical alert prompting to install
# developer tools. Any system running Mac OS X 10.7 or
# later (Darwin 11 and later) is required to have a 64-bit
# processor. This is not true of the ARM version of Darwin
# that Apple uses in portable devices.
UNAME_PROCESSOR=x86_64
fi
echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
exit ;;
*:procnto*:*:* | *:QNX:[0123456789]*:*)

View File

@ -9,6 +9,9 @@
/* Message logging */
#undef ENABLE_LOGGING
/* Define to 1 if you have the <asm/types.h> header file. */
#undef HAVE_ASM_TYPES_H
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
@ -54,6 +57,15 @@
/* Define to 1 if the system has the type `struct timespec'. */
#undef HAVE_STRUCT_TIMESPEC
/* syslog() function available */
#undef HAVE_SYSLOG_FUNC
/* Define to 1 if you have the <syslog.h> header file. */
#undef HAVE_SYSLOG_H
/* Define to 1 if you have the <sys/socket.h> header file. */
#undef HAVE_SYS_SOCKET_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
@ -70,16 +82,16 @@
*/
#undef LT_OBJDIR
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
#undef NO_MINUS_C_MINUS_O
/* Darwin backend */
#undef OS_DARWIN
/* Linux backend */
#undef OS_LINUX
/* OpenBSD/NetBSD backend */
/* NetBSD backend */
#undef OS_NETBSD
/* OpenBSD backend */
#undef OS_OPENBSD
/* Windows backend */
@ -118,6 +130,9 @@
/* timerfd headers available */
#undef USBI_TIMERFD_AVAILABLE
/* Enable output to system log */
#undef USE_SYSTEM_LOGGING_FACILITY
/* Use udev for device enumeration/hotplug */
#undef USE_UDEV

45
Externals/libusbx/config.sub → Externals/libusb/config.sub vendored Normal file → Executable file
View File

@ -1,10 +1,8 @@
#! /bin/sh
# Configuration validation subroutine script.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012, 2013 Free Software Foundation, Inc.
# Copyright 1992-2013 Free Software Foundation, Inc.
timestamp='2012-12-29'
timestamp='2013-10-01'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@ -70,9 +68,7 @@ Report bugs and patches to <config-patches@gnu.org>."
version="\
GNU config.sub ($timestamp)
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
2012, 2013 Free Software Foundation, Inc.
Copyright 1992-2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@ -256,12 +252,12 @@ case $basic_machine in
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
| am33_2.0 \
| arc \
| arc | arceb \
| arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
| avr | avr32 \
| be32 | be64 \
| bfin \
| c4x | clipper \
| c4x | c8051 | clipper \
| d10v | d30v | dlx | dsp16xx \
| epiphany \
| fido | fr30 | frv \
@ -269,6 +265,7 @@ case $basic_machine in
| hexagon \
| i370 | i860 | i960 | ia64 \
| ip2k | iq2000 \
| k1om \
| le32 | le64 \
| lm32 \
| m32c | m32r | m32rle | m68000 | m68k | m88k \
@ -290,16 +287,17 @@ case $basic_machine in
| mipsisa64r2 | mipsisa64r2el \
| mipsisa64sb1 | mipsisa64sb1el \
| mipsisa64sr71k | mipsisa64sr71kel \
| mipsr5900 | mipsr5900el \
| mipstx39 | mipstx39el \
| mn10200 | mn10300 \
| moxie \
| mt \
| msp430 \
| nds32 | nds32le | nds32be \
| nios | nios2 \
| nios | nios2 | nios2eb | nios2el \
| ns16k | ns32k \
| open8 \
| or32 \
| or1k | or32 \
| pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle \
| pyramid \
@ -327,7 +325,7 @@ case $basic_machine in
c6x)
basic_machine=tic6x-unknown
;;
m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)
m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip)
basic_machine=$basic_machine-unknown
os=-none
;;
@ -369,13 +367,13 @@ case $basic_machine in
| aarch64-* | aarch64_be-* \
| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
| avr-* | avr32-* \
| be32-* | be64-* \
| bfin-* | bs2000-* \
| c[123]* | c30-* | [cjt]90-* | c4x-* \
| clipper-* | craynv-* | cydra-* \
| c8051-* | clipper-* | craynv-* | cydra-* \
| d10v-* | d30v-* | dlx-* \
| elxsi-* \
| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
@ -384,6 +382,7 @@ case $basic_machine in
| hexagon-* \
| i*86-* | i860-* | i960-* | ia64-* \
| ip2k-* | iq2000-* \
| k1om-* \
| le32-* | le64-* \
| lm32-* \
| m32c-* | m32r-* | m32rle-* \
@ -407,12 +406,13 @@ case $basic_machine in
| mipsisa64r2-* | mipsisa64r2el-* \
| mipsisa64sb1-* | mipsisa64sb1el-* \
| mipsisa64sr71k-* | mipsisa64sr71kel-* \
| mipsr5900-* | mipsr5900el-* \
| mipstx39-* | mipstx39el-* \
| mmix-* \
| mt-* \
| msp430-* \
| nds32-* | nds32le-* | nds32be-* \
| nios-* | nios2-* \
| nios-* | nios2-* | nios2eb-* | nios2el-* \
| none-* | np1-* | ns16k-* | ns32k-* \
| open8-* \
| orion-* \
@ -796,7 +796,7 @@ case $basic_machine in
os=-mingw64
;;
mingw32)
basic_machine=i386-pc
basic_machine=i686-pc
os=-mingw32
;;
mingw32ce)
@ -832,7 +832,7 @@ case $basic_machine in
basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
;;
msys)
basic_machine=i386-pc
basic_machine=i686-pc
os=-msys
;;
mvs)
@ -1354,7 +1354,7 @@ case $os in
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
| -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
| -sym* | -kopensolaris* \
| -sym* | -kopensolaris* | -plan9* \
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
| -aos* | -aros* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
@ -1500,9 +1500,6 @@ case $os in
-aros*)
os=-aros
;;
-kaos*)
os=-kaos
;;
-zvmoe)
os=-zvmoe
;;
@ -1551,6 +1548,9 @@ case $basic_machine in
c4x-* | tic4x-*)
os=-coff
;;
c8051-*)
os=-elf
;;
hexagon-*)
os=-elf
;;
@ -1594,6 +1594,9 @@ case $basic_machine in
mips*-*)
os=-elf
;;
or1k-*)
os=-elf
;;
or32-*)
os=-coff
;;

439
Externals/libusbx/configure → Externals/libusb/configure vendored Normal file → Executable file
View File

@ -1,8 +1,8 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for libusbx 1.0.16.
# Generated by GNU Autoconf 2.69 for libusb 1.0.19.
#
# Report bugs to <libusbx-devel@lists.sourceforge.net>.
# Report bugs to <libusb-devel@lists.sourceforge.net>.
#
#
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@ -275,7 +275,7 @@ fi
$as_echo "$0: be upgraded to zsh 4.3.4 or later."
else
$as_echo "$0: Please tell bug-autoconf@gnu.org and
$0: libusbx-devel@lists.sourceforge.net about your system,
$0: libusb-devel@lists.sourceforge.net about your system,
$0: including any error possibly output before this
$0: message. Then install a modern shell, or manually run
$0: the script under such a shell if you do have one."
@ -588,12 +588,12 @@ MFLAGS=
MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='libusbx'
PACKAGE_TARNAME='libusbx'
PACKAGE_VERSION='1.0.16'
PACKAGE_STRING='libusbx 1.0.16'
PACKAGE_BUGREPORT='libusbx-devel@lists.sourceforge.net'
PACKAGE_URL='http://libusbx.org'
PACKAGE_NAME='libusb'
PACKAGE_TARNAME='libusb'
PACKAGE_VERSION='1.0.19'
PACKAGE_STRING='libusb 1.0.19'
PACKAGE_BUGREPORT='libusb-devel@lists.sourceforge.net'
PACKAGE_URL='http://libusb.info'
ac_unique_file="libusb/core.c"
# Factoring default headers for most tests.
@ -652,6 +652,8 @@ THREADS_POSIX_FALSE
THREADS_POSIX_TRUE
OS_WINDOWS_FALSE
OS_WINDOWS_TRUE
OS_NETBSD_FALSE
OS_NETBSD_TRUE
OS_OPENBSD_FALSE
OS_OPENBSD_TRUE
OS_DARWIN_FALSE
@ -659,6 +661,7 @@ OS_DARWIN_TRUE
OS_LINUX_FALSE
OS_LINUX_TRUE
OS_WINDOWS
OS_NETBSD
OS_OPENBSD
OS_DARWIN
USE_UDEV
@ -796,6 +799,7 @@ enable_udev
enable_timerfd
enable_log
enable_debug_log
enable_system_log
enable_examples_build
enable_tests_build
'
@ -1348,7 +1352,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures libusbx 1.0.16 to adapt to many kinds of systems.
\`configure' configures libusb 1.0.19 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1396,7 +1400,7 @@ Fine tuning of the installation directories:
--infodir=DIR info documentation [DATAROOTDIR/info]
--localedir=DIR locale-dependent data [DATAROOTDIR/locale]
--mandir=DIR man documentation [DATAROOTDIR/man]
--docdir=DIR documentation root [DATAROOTDIR/doc/libusbx]
--docdir=DIR documentation root [DATAROOTDIR/doc/libusb]
--htmldir=DIR html documentation [DOCDIR]
--dvidir=DIR dvi documentation [DOCDIR]
--pdfdir=DIR pdf documentation [DOCDIR]
@ -1418,7 +1422,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of libusbx 1.0.16:";;
short | recursive ) echo "Configuration of libusb 1.0.19:";;
esac
cat <<\_ACEOF
@ -1441,12 +1445,15 @@ Optional Features:
optimize for fast installation [default=yes]
--disable-libtool-lock avoid locking (might break parallel builds)
--enable-udev use udev for device enumeration and hotplug support
(recommended, default: yes)
--enable-timerfd use timerfd for timing (default auto)
(recommended) [default=yes]
--enable-timerfd use timerfd for timing [default=auto]
--disable-log disable all logging
--enable-debug-log start with debug message logging enabled (default n)
--enable-examples-build build example applications (default n)
--enable-tests-build build test applications (default n)
--enable-debug-log start with debug message logging enabled
[default=no]
--enable-system-log output logging messages to system wide log, if
supported by the OS [default=no]
--enable-examples-build build example applications [default=no]
--enable-tests-build build test applications [default=no]
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@ -1470,8 +1477,8 @@ Some influential environment variables:
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
Report bugs to <libusbx-devel@lists.sourceforge.net>.
libusbx home page: <http://libusbx.org>.
Report bugs to <libusb-devel@lists.sourceforge.net>.
libusb home page: <http://libusb.info>.
_ACEOF
ac_status=$?
fi
@ -1534,7 +1541,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
libusbx configure 1.0.16
libusb configure 1.0.19
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@ -1879,9 +1886,9 @@ $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
( $as_echo "## -------------------------------------------------- ##
## Report this to libusbx-devel@lists.sourceforge.net ##
## -------------------------------------------------- ##"
( $as_echo "## ------------------------------------------------- ##
## Report this to libusb-devel@lists.sourceforge.net ##
## ------------------------------------------------- ##"
) | sed "s/^/$as_me: WARNING: /" >&2
;;
esac
@ -2003,7 +2010,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by libusbx $as_me 1.0.16, which was
It was created by libusb $as_me 1.0.19, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@ -2361,7 +2368,7 @@ lt_revision="0"
lt_age="1"
LTLDFLAGS="-version-info ${lt_current}:${lt_revision}:${lt_age}"
am__api_version='1.13'
am__api_version='1.14'
ac_aux_dir=
for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
@ -2875,8 +2882,8 @@ fi
# Define the identity of the package.
PACKAGE='libusbx'
VERSION='1.0.16'
PACKAGE='libusb'
VERSION='1.0.19'
cat >>confdefs.h <<_ACEOF
@ -2927,6 +2934,47 @@ am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'
# POSIX will say in a future version that running "rm -f" with no argument
# is OK; and we want to be able to make that assumption in our Makefile
# recipes. So use an aggressive probe to check that the usage we want is
# actually supported "in the wild" to an acceptable degree.
# See automake bug#10828.
# To make any issue more visible, cause the running configure to be aborted
# by default if the 'rm' program in use doesn't match our expectations; the
# user can still override this though.
if rm -f && rm -fr && rm -rf; then : OK; else
cat >&2 <<'END'
Oops!
Your 'rm' program seems unable to run without file operands specified
on the command line, even when the '-f' option is present. This is contrary
to the behaviour of most rm programs out there, and not conforming with
the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542>
Please tell bug-automake@gnu.org about your system, including the value
of your $PATH and any error possibly output before this message. This
can help us improve future automake versions.
END
if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
echo 'Configuration will proceed anyway, since you have set the' >&2
echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
echo >&2
else
cat >&2 <<'END'
Aborting the configuration process, to ensure you take notice of the issue.
You can download and install GNU coreutils to get an 'rm' implementation
that behaves properly: <http://www.gnu.org/software/coreutils/>.
If you want to complete the configuration process using your problematic
'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
to "yes", and re-run configure.
END
as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5
$as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; }
@ -3784,6 +3832,65 @@ ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5
$as_echo_n "checking whether $CC understands -c and -o together... " >&6; }
if ${am_cv_prog_cc_c_o+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
# Make sure it works both with $CC and with simple cc.
# Following AC_PROG_CC_C_O, we do the test twice because some
# compilers refuse to overwrite an existing .o file with -o,
# though they will create one.
am_cv_prog_cc_c_o=yes
for am_i in 1 2; do
if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5
($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } \
&& test -f conftest2.$ac_objext; then
: OK
else
am_cv_prog_cc_c_o=no
break
fi
done
rm -f core conftest*
unset am_i
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5
$as_echo "$am_cv_prog_cc_c_o" >&6; }
if test "$am_cv_prog_cc_c_o" != yes; then
# Losing compiler, so override with the script.
# FIXME: It is wrong to rewrite CC.
# But if we don't then we get into trouble of one sort or another.
# A longer-term fix would be to have automake use am__CC in this case,
# and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
CC="$am_aux_dir/compile $CC"
fi
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
DEPDIR="${am__leading_dot}deps"
ac_config_commands="$ac_config_commands depfiles"
@ -6386,7 +6493,7 @@ ia64-*-hpux*)
rm -rf conftest*
;;
x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
# Find out which ABI we are using.
echo 'int i;' > conftest.$ac_ext
@ -6404,7 +6511,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
x86_64-*linux*)
LD="${LD-ld} -m elf_i386"
;;
ppc64-*linux*|powerpc64-*linux*)
powerpc64le-*linux*)
LD="${LD-ld} -m elf32lppclinux"
;;
powerpc64-*linux*)
LD="${LD-ld} -m elf32ppclinux"
;;
s390x-*linux*)
@ -6423,7 +6533,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
x86_64-*linux*)
LD="${LD-ld} -m elf_x86_64"
;;
ppc*-*linux*|powerpc*-*linux*)
powerpcle-*linux*)
LD="${LD-ld} -m elf64lppc"
;;
powerpc-*linux*)
LD="${LD-ld} -m elf64ppc"
;;
s390*-*linux*|s390*-*tpf*)
@ -11781,131 +11894,6 @@ _ACEOF
;;
esac
if test "x$CC" != xcc; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC and cc understand -c and -o together" >&5
$as_echo_n "checking whether $CC and cc understand -c and -o together... " >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cc understands -c and -o together" >&5
$as_echo_n "checking whether cc understands -c and -o together... " >&6; }
fi
set dummy $CC; ac_cc=`$as_echo "$2" |
sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'`
if eval \${ac_cv_prog_cc_${ac_cc}_c_o+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
# Make sure it works both with $CC and with simple cc.
# We do the test twice because some compilers refuse to overwrite an
# existing .o file with -o, though they will create one.
ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&5'
rm -f conftest2.*
if { { case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_try") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } &&
test -f conftest2.$ac_objext && { { case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_try") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; };
then
eval ac_cv_prog_cc_${ac_cc}_c_o=yes
if test "x$CC" != xcc; then
# Test first that cc exists at all.
if { ac_try='cc -c conftest.$ac_ext >&5'
{ { case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_try") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; }; then
ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&5'
rm -f conftest2.*
if { { case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_try") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } &&
test -f conftest2.$ac_objext && { { case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_try") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; };
then
# cc works too.
:
else
# cc exists but doesn't like -o.
eval ac_cv_prog_cc_${ac_cc}_c_o=no
fi
fi
fi
else
eval ac_cv_prog_cc_${ac_cc}_c_o=no
fi
rm -f core conftest*
fi
if eval test \$ac_cv_prog_cc_${ac_cc}_c_o = yes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
$as_echo "#define NO_MINUS_C_MINUS_O 1" >>confdefs.h
fi
# FIXME: we rely on the cache variable name because
# there is no other way.
set dummy $CC
am_cc=`echo $2 | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'`
eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o
if test "$am_t" != yes; then
# Losing compiler, so override with the script.
# FIXME: It is wrong to rewrite CC.
# But if we don't then we get into trouble of one sort or another.
# A longer-term fix would be to have automake use am__CC in this case,
# and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
CC="$am_aux_dir/compile $CC"
fi
$as_echo "#define _GNU_SOURCE 1" >>confdefs.h
@ -11917,7 +11905,17 @@ LTLDFLAGS="${LTLDFLAGS} -no-undefined"
$as_echo_n "checking operating system... " >&6; }
case $host in
*-linux*)
*-linux-android*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: This is a Linux-Android system" >&5
$as_echo "This is a Linux-Android system" >&6; }
is_backend_android="yes"
;;
*)
is_backend_android="no"
esac
case $host in
*-linux* | *-uclinux*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: Linux" >&5
$as_echo "Linux" >&6; }
backend="linux"
@ -11932,13 +11930,13 @@ $as_echo "Darwin/Mac OS X" >&6; }
*-openbsd*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: OpenBSD" >&5
$as_echo "OpenBSD" >&6; }
backend="bsd"
backend="openbsd"
threads="posix"
;;
*-netbsd*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: NetBSD (using OpenBSD backend)" >&5
$as_echo "NetBSD (using OpenBSD backend)" >&6; }
backend="bsd"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: NetBSD" >&5
$as_echo "NetBSD" >&6; }
backend="netbsd"
threads="posix"
;;
*-mingw*)
@ -12095,7 +12093,7 @@ fi
$as_echo "#define USE_UDEV 1" >>confdefs.h
else
for ac_header in linux/netlink.h linux/filter.h
for ac_header in asm/types.h sys/socket.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
@ -12104,6 +12102,27 @@ if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_header in linux/netlink.h linux/filter.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "
#ifdef HAVE_ASM_TYPES_H
#include <asm/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
else
as_fn_error $? "\"Linux netlink headers not found\"" "$LINENO" 5
fi
@ -12112,8 +12131,20 @@ done
fi
case $is_backend_android in
yes)
THREAD_CFLAGS="-c"
LIBS="${LIBS} -c"
$as_echo "#define HAVE_GETTIMEOFDAY 1" >>confdefs.h
;;
*)
THREAD_CFLAGS="-pthread"
LIBS="${LIBS} -pthread"
esac
for ac_header in poll.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "poll.h" "ac_cv_header_poll_h" "$ac_includes_default"
@ -12162,7 +12193,7 @@ $as_echo "#define POLL_NFDS_TYPE unsigned int" >>confdefs.h
fi
;;
bsd)
openbsd)
$as_echo "#define OS_OPENBSD 1" >>confdefs.h
@ -12182,6 +12213,29 @@ fi
done
$as_echo "#define POLL_NFDS_TYPE nfds_t" >>confdefs.h
;;
netbsd)
$as_echo "#define OS_NETBSD 1" >>confdefs.h
THREAD_CFLAGS="-pthread"
LIBS="-pthread"
for ac_header in poll.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "poll.h" "ac_cv_header_poll_h" "$ac_includes_default"
if test "x$ac_cv_header_poll_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_POLL_H 1
_ACEOF
fi
done
$as_echo "#define POLL_NFDS_TYPE nfds_t" >>confdefs.h
;;
@ -12216,7 +12270,7 @@ else
OS_DARWIN_FALSE=
fi
if test "x$backend" = xbsd; then
if test "x$backend" = xopenbsd; then
OS_OPENBSD_TRUE=
OS_OPENBSD_FALSE='#'
else
@ -12224,6 +12278,14 @@ else
OS_OPENBSD_FALSE=
fi
if test "x$backend" = xnetbsd; then
OS_NETBSD_TRUE=
OS_NETBSD_FALSE='#'
else
OS_NETBSD_TRUE='#'
OS_NETBSD_FALSE=
fi
if test "x$backend" = xwindows; then
OS_WINDOWS_TRUE=
OS_WINDOWS_FALSE='#'
@ -12351,6 +12413,45 @@ $as_echo "#define ENABLE_DEBUG_LOGGING 1" >>confdefs.h
fi
# Check whether --enable-system-log was given.
if test "${enable_system_log+set}" = set; then :
enableval=$enable_system_log; system_log_enabled=$enableval
else
system_log_enabled='no'
fi
if test "x$system_log_enabled" != "xno"; then
$as_echo "#define USE_SYSTEM_LOGGING_FACILITY 1" >>confdefs.h
fi
# Check if syslog is available in standard C library
for ac_header in syslog.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "syslog.h" "ac_cv_header_syslog_h" "$ac_includes_default"
if test "x$ac_cv_header_syslog_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_SYSLOG_H 1
_ACEOF
fi
done
ac_fn_c_check_func "$LINENO" "syslog" "ac_cv_func_syslog"
if test "x$ac_cv_func_syslog" = xyes; then :
have_syslog=yes
else
have_syslog=no
fi
if test "x$have_syslog" != "xno"; then
$as_echo "#define HAVE_SYSLOG_FUNC 1" >>confdefs.h
fi
# Examples build
# Check whether --enable-examples-build was given.
if test "${enable_examples_build+set}" = set; then :
@ -12658,6 +12759,10 @@ if test -z "${OS_OPENBSD_TRUE}" && test -z "${OS_OPENBSD_FALSE}"; then
as_fn_error $? "conditional \"OS_OPENBSD\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${OS_NETBSD_TRUE}" && test -z "${OS_NETBSD_FALSE}"; then
as_fn_error $? "conditional \"OS_NETBSD\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${OS_WINDOWS_TRUE}" && test -z "${OS_WINDOWS_FALSE}"; then
as_fn_error $? "conditional \"OS_WINDOWS\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
@ -13083,7 +13188,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by libusbx $as_me 1.0.16, which was
This file was extended by libusb $as_me 1.0.19, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@ -13143,14 +13248,14 @@ $config_headers
Configuration commands:
$config_commands
Report bugs to <libusbx-devel@lists.sourceforge.net>.
libusbx home page: <http://libusbx.org>."
Report bugs to <libusb-devel@lists.sourceforge.net>.
libusb home page: <http://libusb.info>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
libusbx config.status 1.0.16
libusb config.status 1.0.19
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"

View File

@ -15,7 +15,7 @@ LU_DEFINE_VERSION_ATOM([LIBUSB_MINOR])
LU_DEFINE_VERSION_ATOM([LIBUSB_MICRO])
LU_DEFINE_VERSION_RC_ATOM([LIBUSB_RC])
AC_INIT([libusbx],[LIBUSB_MAJOR[.]LIBUSB_MINOR[.]LIBUSB_MICRO[]LIBUSB_RC],[libusbx-devel@lists.sourceforge.net],[libusbx],[http://libusbx.org])
AC_INIT([libusb],[LIBUSB_MAJOR[.]LIBUSB_MINOR[.]LIBUSB_MICRO[]LIBUSB_RC],[libusb-devel@lists.sourceforge.net],[libusb],[http://libusb.info])
# Library versioning
# These numbers should be tweaked on every release. Read carefully:
@ -46,8 +46,18 @@ LTLDFLAGS="${LTLDFLAGS} -no-undefined"
AC_MSG_CHECKING([operating system])
dnl on linux-android platform, some functions are in different places
case $host in
*-linux*)
*-linux-android*)
AC_MSG_RESULT([This is a Linux-Android system])
is_backend_android="yes"
;;
*)
is_backend_android="no"
esac
case $host in
*-linux* | *-uclinux*)
AC_MSG_RESULT([Linux])
backend="linux"
threads="posix"
@ -59,12 +69,12 @@ case $host in
;;
*-openbsd*)
AC_MSG_RESULT([OpenBSD])
backend="bsd"
backend="openbsd"
threads="posix"
;;
*-netbsd*)
AC_MSG_RESULT([NetBSD (using OpenBSD backend)])
backend="bsd"
AC_MSG_RESULT([NetBSD])
backend="netbsd"
threads="posix"
;;
*-mingw*)
@ -89,7 +99,7 @@ linux)
AC_SUBST(OS_LINUX)
AC_SEARCH_LIBS(clock_gettime, rt, [], [], -pthread)
AC_ARG_ENABLE([udev],
[AC_HELP_STRING([--enable-udev], [use udev for device enumeration and hotplug support (recommended, default: yes)])],
[AC_HELP_STRING([--enable-udev], [use udev for device enumeration and hotplug support (recommended) [default=yes]])],
[], [enable_udev="yes"])
if test "x$enable_udev" = "xyes" ; then
# system has udev. use it or fail!
@ -97,11 +107,31 @@ linux)
AC_CHECK_LIB([udev], [udev_new], [], [AC_ERROR(["udev support requested but libudev not installed"])])
AC_DEFINE(USE_UDEV, 1, [Use udev for device enumeration/hotplug])
else
AC_CHECK_HEADERS([linux/netlink.h linux/filter.h], [], [AC_ERROR(["Linux netlink headers not found"])])
AC_CHECK_HEADERS([asm/types.h sys/socket.h], [], [])
AC_CHECK_HEADERS([linux/netlink.h linux/filter.h], [], [AC_ERROR(["Linux netlink headers not found"])], [
#ifdef HAVE_ASM_TYPES_H
#include <asm/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
])
fi
AC_SUBST(USE_UDEV)
case $is_backend_android in
yes)
dnl some pthread functions is in libc
THREAD_CFLAGS="-c"
LIBS="${LIBS} -c"
dnl there are gettimeofday function but configure doesn't seem to be able to find it.
AC_DEFINE([HAVE_GETTIMEOFDAY], [1], [Define if you have gettimeofday])
;;
*)
THREAD_CFLAGS="-pthread"
LIBS="${LIBS} -pthread"
esac
AC_CHECK_HEADERS([poll.h])
AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
;;
@ -116,14 +146,22 @@ darwin)
[AC_DEFINE([POLL_NFDS_TYPE],[unsigned int],[type of second poll() argument])],
[#include <poll.h>])
;;
bsd)
AC_DEFINE(OS_OPENBSD, 1, [OpenBSD/NetBSD backend])
openbsd)
AC_DEFINE(OS_OPENBSD, 1, [OpenBSD backend])
AC_SUBST(OS_OPENBSD)
THREAD_CFLAGS="-pthread"
LIBS="-pthread"
AC_CHECK_HEADERS([poll.h])
AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
;;
netbsd)
AC_DEFINE(OS_NETBSD, 1, [NetBSD backend])
AC_SUBST(OS_NETBSD)
THREAD_CFLAGS="-pthread"
LIBS="-pthread"
AC_CHECK_HEADERS([poll.h])
AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
;;
windows)
AC_DEFINE(OS_WINDOWS, 1, [Windows backend])
AC_SUBST(OS_WINDOWS)
@ -137,7 +175,8 @@ AC_SUBST(LIBS)
AM_CONDITIONAL(OS_LINUX, test "x$backend" = xlinux)
AM_CONDITIONAL(OS_DARWIN, test "x$backend" = xdarwin)
AM_CONDITIONAL(OS_OPENBSD, test "x$backend" = xbsd)
AM_CONDITIONAL(OS_OPENBSD, test "x$backend" = xopenbsd)
AM_CONDITIONAL(OS_NETBSD, test "x$backend" = xnetbsd)
AM_CONDITIONAL(OS_WINDOWS, test "x$backend" = xwindows)
AM_CONDITIONAL(THREADS_POSIX, test "x$threads" = xposix)
AM_CONDITIONAL(CREATE_IMPORT_LIB, test "x$create_import_lib" = "xyes")
@ -150,7 +189,7 @@ fi
AC_CHECK_HEADER([sys/timerfd.h], [timerfd_h=1], [timerfd_h=0])
AC_ARG_ENABLE([timerfd],
[AS_HELP_STRING([--enable-timerfd],
[use timerfd for timing (default auto)])],
[use timerfd for timing [default=auto]])],
[use_timerfd=$enableval], [use_timerfd='auto'])
if test "x$use_timerfd" = "xyes" -a "x$timerfd_h" = "x0"; then
@ -185,23 +224,38 @@ if test "x$log_enabled" != "xno"; then
fi
AC_ARG_ENABLE([debug-log], [AS_HELP_STRING([--enable-debug-log],
[start with debug message logging enabled (default n)])],
[start with debug message logging enabled [default=no]])],
[debug_log_enabled=$enableval],
[debug_log_enabled='no'])
if test "x$debug_log_enabled" != "xno"; then
AC_DEFINE([ENABLE_DEBUG_LOGGING], 1, [Start with debug message logging enabled])
fi
AC_ARG_ENABLE([system-log], [AS_HELP_STRING([--enable-system-log],
[output logging messages to system wide log, if supported by the OS [default=no]])],
[system_log_enabled=$enableval],
[system_log_enabled='no'])
if test "x$system_log_enabled" != "xno"; then
AC_DEFINE([USE_SYSTEM_LOGGING_FACILITY], 1, [Enable output to system log])
fi
# Check if syslog is available in standard C library
AC_CHECK_HEADERS(syslog.h)
AC_CHECK_FUNC([syslog], [have_syslog=yes], [have_syslog=no])
if test "x$have_syslog" != "xno"; then
AC_DEFINE([HAVE_SYSLOG_FUNC], 1, [syslog() function available])
fi
# Examples build
AC_ARG_ENABLE([examples-build], [AS_HELP_STRING([--enable-examples-build],
[build example applications (default n)])],
[build example applications [default=no]])],
[build_examples=$enableval],
[build_examples='no'])
AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$build_examples" != "xno"])
# Tests build
AC_ARG_ENABLE([tests-build], [AS_HELP_STRING([--enable-tests-build],
[build test applications (default n)])],
[build test applications [default=no]])],
[build_tests=$enableval],
[build_tests='no'])
AM_CONDITIONAL([BUILD_TESTS], [test "x$build_tests" != "xno"])

3
Externals/libusbx/depcomp → Externals/libusb/depcomp vendored Normal file → Executable file
View File

@ -1,7 +1,7 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2012-10-18.11; # UTC
scriptversion=2013-05-30.07; # UTC
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
@ -552,6 +552,7 @@ $ {
G
p
}' >> "$depfile"
echo >> "$depfile" # make sure the fragment doesn't end with a backslash
rm -f "$tmpdepfile"
;;

9
Externals/libusb/doc/Makefile.am vendored Normal file
View File

@ -0,0 +1,9 @@
EXTRA_DIST = doxygen.cfg.in
docs: doxygen.cfg
doxygen $^
docs-upload: docs
ln -s html api-1.0
scp -r api-1.0 pbatard@web.sourceforge.net:/home/project-web/libusb/htdocs
rm -f api-1.0

443
Externals/libusb/doc/Makefile.in vendored Normal file
View File

@ -0,0 +1,443 @@
# Makefile.in generated by automake 1.14.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = doc
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(srcdir)/doxygen.cfg.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/libusb/version.h $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES = doxygen.cfg
CONFIG_CLEAN_VPATH_FILES =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
SOURCES =
DIST_SOURCES =
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_CFLAGS = @AM_CFLAGS@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLDFLAGS = @LTLDFLAGS@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OS_DARWIN = @OS_DARWIN@
OS_LINUX = @OS_LINUX@
OS_NETBSD = @OS_NETBSD@
OS_OPENBSD = @OS_OPENBSD@
OS_WINDOWS = @OS_WINDOWS@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
RC = @RC@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
USE_UDEV = @USE_UDEV@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
EXTRA_DIST = doxygen.cfg.in
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu doc/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu doc/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
doxygen.cfg: $(top_builddir)/config.status $(srcdir)/doxygen.cfg.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
tags TAGS:
ctags CTAGS:
cscope cscopelist:
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am:
.MAKE: install-am install-strip
.PHONY: all all-am check check-am clean clean-generic clean-libtool \
cscopelist-am ctags-am distclean distclean-generic \
distclean-libtool distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags-am uninstall uninstall-am
docs: doxygen.cfg
doxygen $^
docs-upload: docs
ln -s html api-1.0
scp -r api-1.0 pbatard@web.sourceforge.net:/home/project-web/libusb/htdocs
rm -f api-1.0
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

1288
Externals/libusb/doc/doxygen.cfg.in vendored Normal file

File diff suppressed because it is too large Load Diff

19
Externals/libusb/examples/Makefile.am vendored Normal file
View File

@ -0,0 +1,19 @@
AM_CPPFLAGS = -I$(top_srcdir)/libusb
LDADD = ../libusb/libusb-1.0.la
noinst_PROGRAMS = listdevs xusb fxload hotplugtest
if HAVE_SIGACTION
noinst_PROGRAMS += dpfp
if THREADS_POSIX
dpfp_threaded_CFLAGS = $(AM_CFLAGS)
noinst_PROGRAMS += dpfp_threaded
endif
sam3u_benchmark_SOURCES = sam3u_benchmark.c
noinst_PROGRAMS += sam3u_benchmark
endif
fxload_SOURCES = ezusb.c ezusb.h fxload.c
fxload_CFLAGS = $(THREAD_CFLAGS) $(AM_CFLAGS)

700
Externals/libusb/examples/Makefile.in vendored Normal file
View File

@ -0,0 +1,700 @@
# Makefile.in generated by automake 1.14.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
noinst_PROGRAMS = listdevs$(EXEEXT) xusb$(EXEEXT) fxload$(EXEEXT) \
hotplugtest$(EXEEXT) $(am__EXEEXT_1) $(am__EXEEXT_2) \
$(am__EXEEXT_3)
@HAVE_SIGACTION_TRUE@am__append_1 = dpfp
@HAVE_SIGACTION_TRUE@@THREADS_POSIX_TRUE@am__append_2 = dpfp_threaded
@HAVE_SIGACTION_TRUE@am__append_3 = sam3u_benchmark
subdir = examples
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(top_srcdir)/depcomp
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/libusb/version.h $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
@HAVE_SIGACTION_TRUE@am__EXEEXT_1 = dpfp$(EXEEXT)
@HAVE_SIGACTION_TRUE@@THREADS_POSIX_TRUE@am__EXEEXT_2 = dpfp_threaded$(EXEEXT)
@HAVE_SIGACTION_TRUE@am__EXEEXT_3 = sam3u_benchmark$(EXEEXT)
PROGRAMS = $(noinst_PROGRAMS)
dpfp_SOURCES = dpfp.c
dpfp_OBJECTS = dpfp.$(OBJEXT)
dpfp_LDADD = $(LDADD)
dpfp_DEPENDENCIES = ../libusb/libusb-1.0.la
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
dpfp_threaded_SOURCES = dpfp_threaded.c
dpfp_threaded_OBJECTS = dpfp_threaded-dpfp_threaded.$(OBJEXT)
dpfp_threaded_LDADD = $(LDADD)
dpfp_threaded_DEPENDENCIES = ../libusb/libusb-1.0.la
dpfp_threaded_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(dpfp_threaded_CFLAGS) \
$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
am_fxload_OBJECTS = fxload-ezusb.$(OBJEXT) fxload-fxload.$(OBJEXT)
fxload_OBJECTS = $(am_fxload_OBJECTS)
fxload_LDADD = $(LDADD)
fxload_DEPENDENCIES = ../libusb/libusb-1.0.la
fxload_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(fxload_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
hotplugtest_SOURCES = hotplugtest.c
hotplugtest_OBJECTS = hotplugtest.$(OBJEXT)
hotplugtest_LDADD = $(LDADD)
hotplugtest_DEPENDENCIES = ../libusb/libusb-1.0.la
listdevs_SOURCES = listdevs.c
listdevs_OBJECTS = listdevs.$(OBJEXT)
listdevs_LDADD = $(LDADD)
listdevs_DEPENDENCIES = ../libusb/libusb-1.0.la
am__sam3u_benchmark_SOURCES_DIST = sam3u_benchmark.c
@HAVE_SIGACTION_TRUE@am_sam3u_benchmark_OBJECTS = \
@HAVE_SIGACTION_TRUE@ sam3u_benchmark.$(OBJEXT)
sam3u_benchmark_OBJECTS = $(am_sam3u_benchmark_OBJECTS)
sam3u_benchmark_LDADD = $(LDADD)
sam3u_benchmark_DEPENDENCIES = ../libusb/libusb-1.0.la
xusb_SOURCES = xusb.c
xusb_OBJECTS = xusb.$(OBJEXT)
xusb_LDADD = $(LDADD)
xusb_DEPENDENCIES = ../libusb/libusb-1.0.la
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
am__v_CC_1 =
CCLD = $(CC)
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = dpfp.c dpfp_threaded.c $(fxload_SOURCES) hotplugtest.c \
listdevs.c $(sam3u_benchmark_SOURCES) xusb.c
DIST_SOURCES = dpfp.c dpfp_threaded.c $(fxload_SOURCES) hotplugtest.c \
listdevs.c $(am__sam3u_benchmark_SOURCES_DIST) xusb.c
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_CFLAGS = @AM_CFLAGS@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLDFLAGS = @LTLDFLAGS@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OS_DARWIN = @OS_DARWIN@
OS_LINUX = @OS_LINUX@
OS_NETBSD = @OS_NETBSD@
OS_OPENBSD = @OS_OPENBSD@
OS_WINDOWS = @OS_WINDOWS@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
RC = @RC@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
USE_UDEV = @USE_UDEV@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AM_CPPFLAGS = -I$(top_srcdir)/libusb
LDADD = ../libusb/libusb-1.0.la
@HAVE_SIGACTION_TRUE@@THREADS_POSIX_TRUE@dpfp_threaded_CFLAGS = $(AM_CFLAGS)
@HAVE_SIGACTION_TRUE@sam3u_benchmark_SOURCES = sam3u_benchmark.c
fxload_SOURCES = ezusb.c ezusb.h fxload.c
fxload_CFLAGS = $(THREAD_CFLAGS) $(AM_CFLAGS)
all: all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu examples/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu examples/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
clean-noinstPROGRAMS:
@list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
echo " rm -f" $$list; \
rm -f $$list || exit $$?; \
test -n "$(EXEEXT)" || exit 0; \
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
echo " rm -f" $$list; \
rm -f $$list
dpfp$(EXEEXT): $(dpfp_OBJECTS) $(dpfp_DEPENDENCIES) $(EXTRA_dpfp_DEPENDENCIES)
@rm -f dpfp$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(dpfp_OBJECTS) $(dpfp_LDADD) $(LIBS)
dpfp_threaded$(EXEEXT): $(dpfp_threaded_OBJECTS) $(dpfp_threaded_DEPENDENCIES) $(EXTRA_dpfp_threaded_DEPENDENCIES)
@rm -f dpfp_threaded$(EXEEXT)
$(AM_V_CCLD)$(dpfp_threaded_LINK) $(dpfp_threaded_OBJECTS) $(dpfp_threaded_LDADD) $(LIBS)
fxload$(EXEEXT): $(fxload_OBJECTS) $(fxload_DEPENDENCIES) $(EXTRA_fxload_DEPENDENCIES)
@rm -f fxload$(EXEEXT)
$(AM_V_CCLD)$(fxload_LINK) $(fxload_OBJECTS) $(fxload_LDADD) $(LIBS)
hotplugtest$(EXEEXT): $(hotplugtest_OBJECTS) $(hotplugtest_DEPENDENCIES) $(EXTRA_hotplugtest_DEPENDENCIES)
@rm -f hotplugtest$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(hotplugtest_OBJECTS) $(hotplugtest_LDADD) $(LIBS)
listdevs$(EXEEXT): $(listdevs_OBJECTS) $(listdevs_DEPENDENCIES) $(EXTRA_listdevs_DEPENDENCIES)
@rm -f listdevs$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(listdevs_OBJECTS) $(listdevs_LDADD) $(LIBS)
sam3u_benchmark$(EXEEXT): $(sam3u_benchmark_OBJECTS) $(sam3u_benchmark_DEPENDENCIES) $(EXTRA_sam3u_benchmark_DEPENDENCIES)
@rm -f sam3u_benchmark$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(sam3u_benchmark_OBJECTS) $(sam3u_benchmark_LDADD) $(LIBS)
xusb$(EXEEXT): $(xusb_OBJECTS) $(xusb_DEPENDENCIES) $(EXTRA_xusb_DEPENDENCIES)
@rm -f xusb$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(xusb_OBJECTS) $(xusb_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dpfp.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dpfp_threaded-dpfp_threaded.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fxload-ezusb.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fxload-fxload.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hotplugtest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/listdevs.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sam3u_benchmark.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xusb.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
.c.obj:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
dpfp_threaded-dpfp_threaded.o: dpfp_threaded.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(dpfp_threaded_CFLAGS) $(CFLAGS) -MT dpfp_threaded-dpfp_threaded.o -MD -MP -MF $(DEPDIR)/dpfp_threaded-dpfp_threaded.Tpo -c -o dpfp_threaded-dpfp_threaded.o `test -f 'dpfp_threaded.c' || echo '$(srcdir)/'`dpfp_threaded.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/dpfp_threaded-dpfp_threaded.Tpo $(DEPDIR)/dpfp_threaded-dpfp_threaded.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dpfp_threaded.c' object='dpfp_threaded-dpfp_threaded.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(dpfp_threaded_CFLAGS) $(CFLAGS) -c -o dpfp_threaded-dpfp_threaded.o `test -f 'dpfp_threaded.c' || echo '$(srcdir)/'`dpfp_threaded.c
dpfp_threaded-dpfp_threaded.obj: dpfp_threaded.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(dpfp_threaded_CFLAGS) $(CFLAGS) -MT dpfp_threaded-dpfp_threaded.obj -MD -MP -MF $(DEPDIR)/dpfp_threaded-dpfp_threaded.Tpo -c -o dpfp_threaded-dpfp_threaded.obj `if test -f 'dpfp_threaded.c'; then $(CYGPATH_W) 'dpfp_threaded.c'; else $(CYGPATH_W) '$(srcdir)/dpfp_threaded.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/dpfp_threaded-dpfp_threaded.Tpo $(DEPDIR)/dpfp_threaded-dpfp_threaded.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dpfp_threaded.c' object='dpfp_threaded-dpfp_threaded.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(dpfp_threaded_CFLAGS) $(CFLAGS) -c -o dpfp_threaded-dpfp_threaded.obj `if test -f 'dpfp_threaded.c'; then $(CYGPATH_W) 'dpfp_threaded.c'; else $(CYGPATH_W) '$(srcdir)/dpfp_threaded.c'; fi`
fxload-ezusb.o: ezusb.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fxload_CFLAGS) $(CFLAGS) -MT fxload-ezusb.o -MD -MP -MF $(DEPDIR)/fxload-ezusb.Tpo -c -o fxload-ezusb.o `test -f 'ezusb.c' || echo '$(srcdir)/'`ezusb.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/fxload-ezusb.Tpo $(DEPDIR)/fxload-ezusb.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ezusb.c' object='fxload-ezusb.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fxload_CFLAGS) $(CFLAGS) -c -o fxload-ezusb.o `test -f 'ezusb.c' || echo '$(srcdir)/'`ezusb.c
fxload-ezusb.obj: ezusb.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fxload_CFLAGS) $(CFLAGS) -MT fxload-ezusb.obj -MD -MP -MF $(DEPDIR)/fxload-ezusb.Tpo -c -o fxload-ezusb.obj `if test -f 'ezusb.c'; then $(CYGPATH_W) 'ezusb.c'; else $(CYGPATH_W) '$(srcdir)/ezusb.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/fxload-ezusb.Tpo $(DEPDIR)/fxload-ezusb.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ezusb.c' object='fxload-ezusb.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fxload_CFLAGS) $(CFLAGS) -c -o fxload-ezusb.obj `if test -f 'ezusb.c'; then $(CYGPATH_W) 'ezusb.c'; else $(CYGPATH_W) '$(srcdir)/ezusb.c'; fi`
fxload-fxload.o: fxload.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fxload_CFLAGS) $(CFLAGS) -MT fxload-fxload.o -MD -MP -MF $(DEPDIR)/fxload-fxload.Tpo -c -o fxload-fxload.o `test -f 'fxload.c' || echo '$(srcdir)/'`fxload.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/fxload-fxload.Tpo $(DEPDIR)/fxload-fxload.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fxload.c' object='fxload-fxload.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fxload_CFLAGS) $(CFLAGS) -c -o fxload-fxload.o `test -f 'fxload.c' || echo '$(srcdir)/'`fxload.c
fxload-fxload.obj: fxload.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fxload_CFLAGS) $(CFLAGS) -MT fxload-fxload.obj -MD -MP -MF $(DEPDIR)/fxload-fxload.Tpo -c -o fxload-fxload.obj `if test -f 'fxload.c'; then $(CYGPATH_W) 'fxload.c'; else $(CYGPATH_W) '$(srcdir)/fxload.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/fxload-fxload.Tpo $(DEPDIR)/fxload-fxload.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fxload.c' object='fxload-fxload.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fxload_CFLAGS) $(CFLAGS) -c -o fxload-fxload.obj `if test -f 'fxload.c'; then $(CYGPATH_W) 'fxload.c'; else $(CYGPATH_W) '$(srcdir)/fxload.c'; fi`
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-am
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-am
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(PROGRAMS)
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \
mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am:
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
clean-libtool clean-noinstPROGRAMS cscopelist-am ctags \
ctags-am distclean distclean-compile distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-pdf install-pdf-am \
install-ps install-ps-am install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags tags-am uninstall uninstall-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

506
Externals/libusb/examples/dpfp.c vendored Normal file
View File

@ -0,0 +1,506 @@
/*
* libusb example program to manipulate U.are.U 4000B fingerprint scanner.
* Copyright © 2007 Daniel Drake <dsd@gentoo.org>
*
* Basic image capture program only, does not consider the powerup quirks or
* the fact that image encryption may be enabled. Not expected to work
* flawlessly all of the time.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <errno.h>
#include <signal.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "libusb.h"
#define EP_INTR (1 | LIBUSB_ENDPOINT_IN)
#define EP_DATA (2 | LIBUSB_ENDPOINT_IN)
#define CTRL_IN (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_IN)
#define CTRL_OUT (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_OUT)
#define USB_RQ 0x04
#define INTR_LENGTH 64
enum {
MODE_INIT = 0x00,
MODE_AWAIT_FINGER_ON = 0x10,
MODE_AWAIT_FINGER_OFF = 0x12,
MODE_CAPTURE = 0x20,
MODE_SHUT_UP = 0x30,
MODE_READY = 0x80,
};
static int next_state(void);
enum {
STATE_AWAIT_MODE_CHANGE_AWAIT_FINGER_ON = 1,
STATE_AWAIT_IRQ_FINGER_DETECTED,
STATE_AWAIT_MODE_CHANGE_CAPTURE,
STATE_AWAIT_IMAGE,
STATE_AWAIT_MODE_CHANGE_AWAIT_FINGER_OFF,
STATE_AWAIT_IRQ_FINGER_REMOVED,
};
static int state = 0;
static struct libusb_device_handle *devh = NULL;
static unsigned char imgbuf[0x1b340];
static unsigned char irqbuf[INTR_LENGTH];
static struct libusb_transfer *img_transfer = NULL;
static struct libusb_transfer *irq_transfer = NULL;
static int img_idx = 0;
static int do_exit = 0;
static int find_dpfp_device(void)
{
devh = libusb_open_device_with_vid_pid(NULL, 0x05ba, 0x000a);
return devh ? 0 : -EIO;
}
static int print_f0_data(void)
{
unsigned char data[0x10];
int r;
unsigned int i;
r = libusb_control_transfer(devh, CTRL_IN, USB_RQ, 0xf0, 0, data,
sizeof(data), 0);
if (r < 0) {
fprintf(stderr, "F0 error %d\n", r);
return r;
}
if ((unsigned int) r < sizeof(data)) {
fprintf(stderr, "short read (%d)\n", r);
return -1;
}
printf("F0 data:");
for (i = 0; i < sizeof(data); i++)
printf("%02x ", data[i]);
printf("\n");
return 0;
}
static int get_hwstat(unsigned char *status)
{
int r;
r = libusb_control_transfer(devh, CTRL_IN, USB_RQ, 0x07, 0, status, 1, 0);
if (r < 0) {
fprintf(stderr, "read hwstat error %d\n", r);
return r;
}
if ((unsigned int) r < 1) {
fprintf(stderr, "short read (%d)\n", r);
return -1;
}
printf("hwstat reads %02x\n", *status);
return 0;
}
static int set_hwstat(unsigned char data)
{
int r;
printf("set hwstat to %02x\n", data);
r = libusb_control_transfer(devh, CTRL_OUT, USB_RQ, 0x07, 0, &data, 1, 0);
if (r < 0) {
fprintf(stderr, "set hwstat error %d\n", r);
return r;
}
if ((unsigned int) r < 1) {
fprintf(stderr, "short write (%d)", r);
return -1;
}
return 0;
}
static int set_mode(unsigned char data)
{
int r;
printf("set mode %02x\n", data);
r = libusb_control_transfer(devh, CTRL_OUT, USB_RQ, 0x4e, 0, &data, 1, 0);
if (r < 0) {
fprintf(stderr, "set mode error %d\n", r);
return r;
}
if ((unsigned int) r < 1) {
fprintf(stderr, "short write (%d)", r);
return -1;
}
return 0;
}
static void LIBUSB_CALL cb_mode_changed(struct libusb_transfer *transfer)
{
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
fprintf(stderr, "mode change transfer not completed!\n");
do_exit = 2;
}
printf("async cb_mode_changed length=%d actual_length=%d\n",
transfer->length, transfer->actual_length);
if (next_state() < 0)
do_exit = 2;
}
static int set_mode_async(unsigned char data)
{
unsigned char *buf = (unsigned char*) malloc(LIBUSB_CONTROL_SETUP_SIZE + 1);
struct libusb_transfer *transfer;
if (!buf)
return -ENOMEM;
transfer = libusb_alloc_transfer(0);
if (!transfer) {
free(buf);
return -ENOMEM;
}
printf("async set mode %02x\n", data);
libusb_fill_control_setup(buf, CTRL_OUT, USB_RQ, 0x4e, 0, 1);
buf[LIBUSB_CONTROL_SETUP_SIZE] = data;
libusb_fill_control_transfer(transfer, devh, buf, cb_mode_changed, NULL,
1000);
transfer->flags = LIBUSB_TRANSFER_SHORT_NOT_OK
| LIBUSB_TRANSFER_FREE_BUFFER | LIBUSB_TRANSFER_FREE_TRANSFER;
return libusb_submit_transfer(transfer);
}
static int do_sync_intr(unsigned char *data)
{
int r;
int transferred;
r = libusb_interrupt_transfer(devh, EP_INTR, data, INTR_LENGTH,
&transferred, 1000);
if (r < 0) {
fprintf(stderr, "intr error %d\n", r);
return r;
}
if (transferred < INTR_LENGTH) {
fprintf(stderr, "short read (%d)\n", r);
return -1;
}
printf("recv interrupt %04x\n", *((uint16_t *) data));
return 0;
}
static int sync_intr(unsigned char type)
{
int r;
unsigned char data[INTR_LENGTH];
while (1) {
r = do_sync_intr(data);
if (r < 0)
return r;
if (data[0] == type)
return 0;
}
}
static int save_to_file(unsigned char *data)
{
FILE *fd;
char filename[64];
snprintf(filename, sizeof(filename), "finger%d.pgm", img_idx++);
fd = fopen(filename, "w");
if (!fd)
return -1;
fputs("P5 384 289 255 ", fd);
(void) fwrite(data + 64, 1, 384*289, fd);
fclose(fd);
printf("saved image to %s\n", filename);
return 0;
}
static int next_state(void)
{
int r = 0;
printf("old state: %d\n", state);
switch (state) {
case STATE_AWAIT_IRQ_FINGER_REMOVED:
state = STATE_AWAIT_MODE_CHANGE_AWAIT_FINGER_ON;
r = set_mode_async(MODE_AWAIT_FINGER_ON);
break;
case STATE_AWAIT_MODE_CHANGE_AWAIT_FINGER_ON:
state = STATE_AWAIT_IRQ_FINGER_DETECTED;
break;
case STATE_AWAIT_IRQ_FINGER_DETECTED:
state = STATE_AWAIT_MODE_CHANGE_CAPTURE;
r = set_mode_async(MODE_CAPTURE);
break;
case STATE_AWAIT_MODE_CHANGE_CAPTURE:
state = STATE_AWAIT_IMAGE;
break;
case STATE_AWAIT_IMAGE:
state = STATE_AWAIT_MODE_CHANGE_AWAIT_FINGER_OFF;
r = set_mode_async(MODE_AWAIT_FINGER_OFF);
break;
case STATE_AWAIT_MODE_CHANGE_AWAIT_FINGER_OFF:
state = STATE_AWAIT_IRQ_FINGER_REMOVED;
break;
default:
printf("unrecognised state %d\n", state);
}
if (r < 0) {
fprintf(stderr, "error detected changing state\n");
return r;
}
printf("new state: %d\n", state);
return 0;
}
static void LIBUSB_CALL cb_irq(struct libusb_transfer *transfer)
{
unsigned char irqtype = transfer->buffer[0];
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
fprintf(stderr, "irq transfer status %d?\n", transfer->status);
do_exit = 2;
libusb_free_transfer(transfer);
irq_transfer = NULL;
return;
}
printf("IRQ callback %02x\n", irqtype);
switch (state) {
case STATE_AWAIT_IRQ_FINGER_DETECTED:
if (irqtype == 0x01) {
if (next_state() < 0) {
do_exit = 2;
return;
}
} else {
printf("finger-on-sensor detected in wrong state!\n");
}
break;
case STATE_AWAIT_IRQ_FINGER_REMOVED:
if (irqtype == 0x02) {
if (next_state() < 0) {
do_exit = 2;
return;
}
} else {
printf("finger-on-sensor detected in wrong state!\n");
}
break;
}
if (libusb_submit_transfer(irq_transfer) < 0)
do_exit = 2;
}
static void LIBUSB_CALL cb_img(struct libusb_transfer *transfer)
{
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
fprintf(stderr, "img transfer status %d?\n", transfer->status);
do_exit = 2;
libusb_free_transfer(transfer);
img_transfer = NULL;
return;
}
printf("Image callback\n");
save_to_file(imgbuf);
if (next_state() < 0) {
do_exit = 2;
return;
}
if (libusb_submit_transfer(img_transfer) < 0)
do_exit = 2;
}
static int init_capture(void)
{
int r;
r = libusb_submit_transfer(irq_transfer);
if (r < 0)
return r;
r = libusb_submit_transfer(img_transfer);
if (r < 0) {
libusb_cancel_transfer(irq_transfer);
while (irq_transfer)
if (libusb_handle_events(NULL) < 0)
break;
return r;
}
/* start state machine */
state = STATE_AWAIT_IRQ_FINGER_REMOVED;
return next_state();
}
static int do_init(void)
{
unsigned char status;
int r;
r = get_hwstat(&status);
if (r < 0)
return r;
if (!(status & 0x80)) {
r = set_hwstat(status | 0x80);
if (r < 0)
return r;
r = get_hwstat(&status);
if (r < 0)
return r;
}
status &= ~0x80;
r = set_hwstat(status);
if (r < 0)
return r;
r = get_hwstat(&status);
if (r < 0)
return r;
r = sync_intr(0x56);
if (r < 0)
return r;
return 0;
}
static int alloc_transfers(void)
{
img_transfer = libusb_alloc_transfer(0);
if (!img_transfer)
return -ENOMEM;
irq_transfer = libusb_alloc_transfer(0);
if (!irq_transfer)
return -ENOMEM;
libusb_fill_bulk_transfer(img_transfer, devh, EP_DATA, imgbuf,
sizeof(imgbuf), cb_img, NULL, 0);
libusb_fill_interrupt_transfer(irq_transfer, devh, EP_INTR, irqbuf,
sizeof(irqbuf), cb_irq, NULL, 0);
return 0;
}
static void sighandler(int signum)
{
do_exit = 1;
}
int main(void)
{
struct sigaction sigact;
int r = 1;
r = libusb_init(NULL);
if (r < 0) {
fprintf(stderr, "failed to initialise libusb\n");
exit(1);
}
r = find_dpfp_device();
if (r < 0) {
fprintf(stderr, "Could not find/open device\n");
goto out;
}
r = libusb_claim_interface(devh, 0);
if (r < 0) {
fprintf(stderr, "usb_claim_interface error %d\n", r);
goto out;
}
printf("claimed interface\n");
r = print_f0_data();
if (r < 0)
goto out_release;
r = do_init();
if (r < 0)
goto out_deinit;
/* async from here onwards */
r = alloc_transfers();
if (r < 0)
goto out_deinit;
r = init_capture();
if (r < 0)
goto out_deinit;
sigact.sa_handler = sighandler;
sigemptyset(&sigact.sa_mask);
sigact.sa_flags = 0;
sigaction(SIGINT, &sigact, NULL);
sigaction(SIGTERM, &sigact, NULL);
sigaction(SIGQUIT, &sigact, NULL);
while (!do_exit) {
r = libusb_handle_events(NULL);
if (r < 0)
goto out_deinit;
}
printf("shutting down...\n");
if (irq_transfer) {
r = libusb_cancel_transfer(irq_transfer);
if (r < 0)
goto out_deinit;
}
if (img_transfer) {
r = libusb_cancel_transfer(img_transfer);
if (r < 0)
goto out_deinit;
}
while (irq_transfer || img_transfer)
if (libusb_handle_events(NULL) < 0)
break;
if (do_exit == 1)
r = 0;
else
r = 1;
out_deinit:
libusb_free_transfer(img_transfer);
libusb_free_transfer(irq_transfer);
set_mode(0);
set_hwstat(0x80);
out_release:
libusb_release_interface(devh, 0);
out:
libusb_close(devh);
libusb_exit(NULL);
return r >= 0 ? r : -r;
}

View File

@ -0,0 +1,544 @@
/*
* libusb example program to manipulate U.are.U 4000B fingerprint scanner.
* Copyright © 2007 Daniel Drake <dsd@gentoo.org>
*
* Basic image capture program only, does not consider the powerup quirks or
* the fact that image encryption may be enabled. Not expected to work
* flawlessly all of the time.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <errno.h>
#include <pthread.h>
#include <signal.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "libusb.h"
#define EP_INTR (1 | LIBUSB_ENDPOINT_IN)
#define EP_DATA (2 | LIBUSB_ENDPOINT_IN)
#define CTRL_IN (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_IN)
#define CTRL_OUT (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_OUT)
#define USB_RQ 0x04
#define INTR_LENGTH 64
enum {
MODE_INIT = 0x00,
MODE_AWAIT_FINGER_ON = 0x10,
MODE_AWAIT_FINGER_OFF = 0x12,
MODE_CAPTURE = 0x20,
MODE_SHUT_UP = 0x30,
MODE_READY = 0x80,
};
static int next_state(void);
enum {
STATE_AWAIT_MODE_CHANGE_AWAIT_FINGER_ON = 1,
STATE_AWAIT_IRQ_FINGER_DETECTED,
STATE_AWAIT_MODE_CHANGE_CAPTURE,
STATE_AWAIT_IMAGE,
STATE_AWAIT_MODE_CHANGE_AWAIT_FINGER_OFF,
STATE_AWAIT_IRQ_FINGER_REMOVED,
};
static int state = 0;
static struct libusb_device_handle *devh = NULL;
static unsigned char imgbuf[0x1b340];
static unsigned char irqbuf[INTR_LENGTH];
static struct libusb_transfer *img_transfer = NULL;
static struct libusb_transfer *irq_transfer = NULL;
static int img_idx = 0;
static int do_exit = 0;
static pthread_t poll_thread;
static pthread_cond_t exit_cond = PTHREAD_COND_INITIALIZER;
static pthread_mutex_t exit_cond_lock = PTHREAD_MUTEX_INITIALIZER;
static void request_exit(int code)
{
do_exit = code;
pthread_cond_signal(&exit_cond);
}
static void *poll_thread_main(void *arg)
{
int r = 0;
printf("poll thread running\n");
while (!do_exit) {
struct timeval tv = { 1, 0 };
r = libusb_handle_events_timeout(NULL, &tv);
if (r < 0) {
request_exit(2);
break;
}
}
printf("poll thread shutting down\n");
return NULL;
}
static int find_dpfp_device(void)
{
devh = libusb_open_device_with_vid_pid(NULL, 0x05ba, 0x000a);
return devh ? 0 : -EIO;
}
static int print_f0_data(void)
{
unsigned char data[0x10];
int r;
unsigned int i;
r = libusb_control_transfer(devh, CTRL_IN, USB_RQ, 0xf0, 0, data,
sizeof(data), 0);
if (r < 0) {
fprintf(stderr, "F0 error %d\n", r);
return r;
}
if ((unsigned int) r < sizeof(data)) {
fprintf(stderr, "short read (%d)\n", r);
return -1;
}
printf("F0 data:");
for (i = 0; i < sizeof(data); i++)
printf("%02x ", data[i]);
printf("\n");
return 0;
}
static int get_hwstat(unsigned char *status)
{
int r;
r = libusb_control_transfer(devh, CTRL_IN, USB_RQ, 0x07, 0, status, 1, 0);
if (r < 0) {
fprintf(stderr, "read hwstat error %d\n", r);
return r;
}
if ((unsigned int) r < 1) {
fprintf(stderr, "short read (%d)\n", r);
return -1;
}
printf("hwstat reads %02x\n", *status);
return 0;
}
static int set_hwstat(unsigned char data)
{
int r;
printf("set hwstat to %02x\n", data);
r = libusb_control_transfer(devh, CTRL_OUT, USB_RQ, 0x07, 0, &data, 1, 0);
if (r < 0) {
fprintf(stderr, "set hwstat error %d\n", r);
return r;
}
if ((unsigned int) r < 1) {
fprintf(stderr, "short write (%d)", r);
return -1;
}
return 0;
}
static int set_mode(unsigned char data)
{
int r;
printf("set mode %02x\n", data);
r = libusb_control_transfer(devh, CTRL_OUT, USB_RQ, 0x4e, 0, &data, 1, 0);
if (r < 0) {
fprintf(stderr, "set mode error %d\n", r);
return r;
}
if ((unsigned int) r < 1) {
fprintf(stderr, "short write (%d)", r);
return -1;
}
return 0;
}
static void LIBUSB_CALL cb_mode_changed(struct libusb_transfer *transfer)
{
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
fprintf(stderr, "mode change transfer not completed!\n");
request_exit(2);
}
printf("async cb_mode_changed length=%d actual_length=%d\n",
transfer->length, transfer->actual_length);
if (next_state() < 0)
request_exit(2);
}
static int set_mode_async(unsigned char data)
{
unsigned char *buf = (unsigned char*) malloc(LIBUSB_CONTROL_SETUP_SIZE + 1);
struct libusb_transfer *transfer;
if (!buf)
return -ENOMEM;
transfer = libusb_alloc_transfer(0);
if (!transfer) {
free(buf);
return -ENOMEM;
}
printf("async set mode %02x\n", data);
libusb_fill_control_setup(buf, CTRL_OUT, USB_RQ, 0x4e, 0, 1);
buf[LIBUSB_CONTROL_SETUP_SIZE] = data;
libusb_fill_control_transfer(transfer, devh, buf, cb_mode_changed, NULL,
1000);
transfer->flags = LIBUSB_TRANSFER_SHORT_NOT_OK
| LIBUSB_TRANSFER_FREE_BUFFER | LIBUSB_TRANSFER_FREE_TRANSFER;
return libusb_submit_transfer(transfer);
}
static int do_sync_intr(unsigned char *data)
{
int r;
int transferred;
r = libusb_interrupt_transfer(devh, EP_INTR, data, INTR_LENGTH,
&transferred, 1000);
if (r < 0) {
fprintf(stderr, "intr error %d\n", r);
return r;
}
if (transferred < INTR_LENGTH) {
fprintf(stderr, "short read (%d)\n", r);
return -1;
}
printf("recv interrupt %04x\n", *((uint16_t *) data));
return 0;
}
static int sync_intr(unsigned char type)
{
int r;
unsigned char data[INTR_LENGTH];
while (1) {
r = do_sync_intr(data);
if (r < 0)
return r;
if (data[0] == type)
return 0;
}
}
static int save_to_file(unsigned char *data)
{
FILE *fd;
char filename[64];
snprintf(filename, sizeof(filename), "finger%d.pgm", img_idx++);
fd = fopen(filename, "w");
if (!fd)
return -1;
fputs("P5 384 289 255 ", fd);
(void) fwrite(data + 64, 1, 384*289, fd);
fclose(fd);
printf("saved image to %s\n", filename);
return 0;
}
static int next_state(void)
{
int r = 0;
printf("old state: %d\n", state);
switch (state) {
case STATE_AWAIT_IRQ_FINGER_REMOVED:
state = STATE_AWAIT_MODE_CHANGE_AWAIT_FINGER_ON;
r = set_mode_async(MODE_AWAIT_FINGER_ON);
break;
case STATE_AWAIT_MODE_CHANGE_AWAIT_FINGER_ON:
state = STATE_AWAIT_IRQ_FINGER_DETECTED;
break;
case STATE_AWAIT_IRQ_FINGER_DETECTED:
state = STATE_AWAIT_MODE_CHANGE_CAPTURE;
r = set_mode_async(MODE_CAPTURE);
break;
case STATE_AWAIT_MODE_CHANGE_CAPTURE:
state = STATE_AWAIT_IMAGE;
break;
case STATE_AWAIT_IMAGE:
state = STATE_AWAIT_MODE_CHANGE_AWAIT_FINGER_OFF;
r = set_mode_async(MODE_AWAIT_FINGER_OFF);
break;
case STATE_AWAIT_MODE_CHANGE_AWAIT_FINGER_OFF:
state = STATE_AWAIT_IRQ_FINGER_REMOVED;
break;
default:
printf("unrecognised state %d\n", state);
}
if (r < 0) {
fprintf(stderr, "error detected changing state\n");
return r;
}
printf("new state: %d\n", state);
return 0;
}
static void LIBUSB_CALL cb_irq(struct libusb_transfer *transfer)
{
unsigned char irqtype = transfer->buffer[0];
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
fprintf(stderr, "irq transfer status %d?\n", transfer->status);
irq_transfer = NULL;
request_exit(2);
return;
}
printf("IRQ callback %02x\n", irqtype);
switch (state) {
case STATE_AWAIT_IRQ_FINGER_DETECTED:
if (irqtype == 0x01) {
if (next_state() < 0) {
request_exit(2);
return;
}
} else {
printf("finger-on-sensor detected in wrong state!\n");
}
break;
case STATE_AWAIT_IRQ_FINGER_REMOVED:
if (irqtype == 0x02) {
if (next_state() < 0) {
request_exit(2);
return;
}
} else {
printf("finger-on-sensor detected in wrong state!\n");
}
break;
}
if (libusb_submit_transfer(irq_transfer) < 0)
request_exit(2);
}
static void LIBUSB_CALL cb_img(struct libusb_transfer *transfer)
{
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
fprintf(stderr, "img transfer status %d?\n", transfer->status);
img_transfer = NULL;
request_exit(2);
return;
}
printf("Image callback\n");
save_to_file(imgbuf);
if (next_state() < 0) {
request_exit(2);
return;
}
if (libusb_submit_transfer(img_transfer) < 0)
request_exit(2);
}
static int init_capture(void)
{
int r;
r = libusb_submit_transfer(irq_transfer);
if (r < 0)
return r;
r = libusb_submit_transfer(img_transfer);
if (r < 0) {
libusb_cancel_transfer(irq_transfer);
while (irq_transfer)
if (libusb_handle_events(NULL) < 0)
break;
return r;
}
/* start state machine */
state = STATE_AWAIT_IRQ_FINGER_REMOVED;
return next_state();
}
static int do_init(void)
{
unsigned char status;
int r;
r = get_hwstat(&status);
if (r < 0)
return r;
if (!(status & 0x80)) {
r = set_hwstat(status | 0x80);
if (r < 0)
return r;
r = get_hwstat(&status);
if (r < 0)
return r;
}
status &= ~0x80;
r = set_hwstat(status);
if (r < 0)
return r;
r = get_hwstat(&status);
if (r < 0)
return r;
r = sync_intr(0x56);
if (r < 0)
return r;
return 0;
}
static int alloc_transfers(void)
{
img_transfer = libusb_alloc_transfer(0);
if (!img_transfer)
return -ENOMEM;
irq_transfer = libusb_alloc_transfer(0);
if (!irq_transfer)
return -ENOMEM;
libusb_fill_bulk_transfer(img_transfer, devh, EP_DATA, imgbuf,
sizeof(imgbuf), cb_img, NULL, 0);
libusb_fill_interrupt_transfer(irq_transfer, devh, EP_INTR, irqbuf,
sizeof(irqbuf), cb_irq, NULL, 0);
return 0;
}
static void sighandler(int signum)
{
request_exit(1);
}
int main(void)
{
struct sigaction sigact;
int r = 1;
r = libusb_init(NULL);
if (r < 0) {
fprintf(stderr, "failed to initialise libusb\n");
exit(1);
}
r = find_dpfp_device();
if (r < 0) {
fprintf(stderr, "Could not find/open device\n");
goto out;
}
r = libusb_claim_interface(devh, 0);
if (r < 0) {
fprintf(stderr, "usb_claim_interface error %d %s\n", r, strerror(-r));
goto out;
}
printf("claimed interface\n");
r = print_f0_data();
if (r < 0)
goto out_release;
r = do_init();
if (r < 0)
goto out_deinit;
/* async from here onwards */
sigact.sa_handler = sighandler;
sigemptyset(&sigact.sa_mask);
sigact.sa_flags = 0;
sigaction(SIGINT, &sigact, NULL);
sigaction(SIGTERM, &sigact, NULL);
sigaction(SIGQUIT, &sigact, NULL);
r = pthread_create(&poll_thread, NULL, poll_thread_main, NULL);
if (r)
goto out_deinit;
r = alloc_transfers();
if (r < 0) {
request_exit(1);
pthread_join(poll_thread, NULL);
goto out_deinit;
}
r = init_capture();
if (r < 0) {
request_exit(1);
pthread_join(poll_thread, NULL);
goto out_deinit;
}
while (!do_exit) {
pthread_mutex_lock(&exit_cond_lock);
pthread_cond_wait(&exit_cond, &exit_cond_lock);
pthread_mutex_unlock(&exit_cond_lock);
}
printf("shutting down...\n");
pthread_join(poll_thread, NULL);
r = libusb_cancel_transfer(irq_transfer);
if (r < 0) {
request_exit(1);
goto out_deinit;
}
r = libusb_cancel_transfer(img_transfer);
if (r < 0) {
request_exit(1);
goto out_deinit;
}
while (img_transfer || irq_transfer)
if (libusb_handle_events(NULL) < 0)
break;
if (do_exit == 1)
r = 0;
else
r = 1;
out_deinit:
libusb_free_transfer(img_transfer);
libusb_free_transfer(irq_transfer);
set_mode(0);
set_hwstat(0x80);
out_release:
libusb_release_interface(devh, 0);
out:
libusb_close(devh);
libusb_exit(NULL);
return r >= 0 ? r : -r;
}

831
Externals/libusb/examples/ezusb.c vendored Normal file
View File

@ -0,0 +1,831 @@
/*
* Copyright © 2001 Stephen Williams (steve@icarus.com)
* Copyright © 2001-2002 David Brownell (dbrownell@users.sourceforge.net)
* Copyright © 2008 Roger Williams (rawqux@users.sourceforge.net)
* Copyright © 2012 Pete Batard (pete@akeo.ie)
* Copyright © 2013 Federico Manzan (f.manzan@gmail.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
* General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "libusb.h"
#include "ezusb.h"
extern void logerror(const char *format, ...)
__attribute__ ((format(printf, 1, 2)));
/*
* This file contains functions for uploading firmware into Cypress
* EZ-USB microcontrollers. These chips use control endpoint 0 and vendor
* specific commands to support writing into the on-chip SRAM. They also
* support writing into the CPUCS register, which is how we reset the
* processor after loading firmware (including the reset vector).
*
* These Cypress devices are 8-bit 8051 based microcontrollers with
* special support for USB I/O. They come in several packages, and
* some can be set up with external memory when device costs allow.
* Note that the design was originally by AnchorChips, so you may find
* references to that vendor (which was later merged into Cypress).
* The Cypress FX parts are largely compatible with the Anchorhip ones.
*/
int verbose = 1;
/*
* return true if [addr,addr+len] includes external RAM
* for Anchorchips EZ-USB or Cypress EZ-USB FX
*/
static bool fx_is_external(uint32_t addr, size_t len)
{
/* with 8KB RAM, 0x0000-0x1b3f can be written
* we can't tell if it's a 4KB device here
*/
if (addr <= 0x1b3f)
return ((addr + len) > 0x1b40);
/* there may be more RAM; unclear if we can write it.
* some bulk buffers may be unused, 0x1b3f-0x1f3f
* firmware can set ISODISAB for 2KB at 0x2000-0x27ff
*/
return true;
}
/*
* return true if [addr,addr+len] includes external RAM
* for Cypress EZ-USB FX2
*/
static bool fx2_is_external(uint32_t addr, size_t len)
{
/* 1st 8KB for data/code, 0x0000-0x1fff */
if (addr <= 0x1fff)
return ((addr + len) > 0x2000);
/* and 512 for data, 0xe000-0xe1ff */
else if (addr >= 0xe000 && addr <= 0xe1ff)
return ((addr + len) > 0xe200);
/* otherwise, it's certainly external */
else
return true;
}
/*
* return true if [addr,addr+len] includes external RAM
* for Cypress EZ-USB FX2LP
*/
static bool fx2lp_is_external(uint32_t addr, size_t len)
{
/* 1st 16KB for data/code, 0x0000-0x3fff */
if (addr <= 0x3fff)
return ((addr + len) > 0x4000);
/* and 512 for data, 0xe000-0xe1ff */
else if (addr >= 0xe000 && addr <= 0xe1ff)
return ((addr + len) > 0xe200);
/* otherwise, it's certainly external */
else
return true;
}
/*****************************************************************************/
/*
* These are the requests (bRequest) that the bootstrap loader is expected
* to recognize. The codes are reserved by Cypress, and these values match
* what EZ-USB hardware, or "Vend_Ax" firmware (2nd stage loader) uses.
* Cypress' "a3load" is nice because it supports both FX and FX2, although
* it doesn't have the EEPROM support (subset of "Vend_Ax").
*/
#define RW_INTERNAL 0xA0 /* hardware implements this one */
#define RW_MEMORY 0xA3
/*
* Issues the specified vendor-specific write request.
*/
static int ezusb_write(libusb_device_handle *device, const char *label,
uint8_t opcode, uint32_t addr, const unsigned char *data, size_t len)
{
int status;
if (verbose > 1)
logerror("%s, addr 0x%08x len %4u (0x%04x)\n", label, addr, (unsigned)len, (unsigned)len);
status = libusb_control_transfer(device,
LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE,
opcode, addr & 0xFFFF, addr >> 16,
(unsigned char*)data, (uint16_t)len, 1000);
if (status != len) {
if (status < 0)
logerror("%s: %s\n", label, libusb_error_name(status));
else
logerror("%s ==> %d\n", label, status);
}
return (status < 0) ? -EIO : 0;
}
/*
* Issues the specified vendor-specific read request.
*/
static int ezusb_read(libusb_device_handle *device, const char *label,
uint8_t opcode, uint32_t addr, const unsigned char *data, size_t len)
{
int status;
if (verbose > 1)
logerror("%s, addr 0x%08x len %4u (0x%04x)\n", label, addr, (unsigned)len, (unsigned)len);
status = libusb_control_transfer(device,
LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE,
opcode, addr & 0xFFFF, addr >> 16,
(unsigned char*)data, (uint16_t)len, 1000);
if (status != len) {
if (status < 0)
logerror("%s: %s\n", label, libusb_error_name(status));
else
logerror("%s ==> %d\n", label, status);
}
return (status < 0) ? -EIO : 0;
}
/*
* Modifies the CPUCS register to stop or reset the CPU.
* Returns false on error.
*/
static bool ezusb_cpucs(libusb_device_handle *device, uint32_t addr, bool doRun)
{
int status;
uint8_t data = doRun ? 0x00 : 0x01;
if (verbose)
logerror("%s\n", data ? "stop CPU" : "reset CPU");
status = libusb_control_transfer(device,
LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE,
RW_INTERNAL, addr & 0xFFFF, addr >> 16,
&data, 1, 1000);
if ((status != 1) &&
/* We may get an I/O error from libusb as the device disappears */
((!doRun) || (status != LIBUSB_ERROR_IO)))
{
const char *mesg = "can't modify CPUCS";
if (status < 0)
logerror("%s: %s\n", mesg, libusb_error_name(status));
else
logerror("%s\n", mesg);
return false;
} else
return true;
}
/*
* Send an FX3 jumpt to address command
* Returns false on error.
*/
static bool ezusb_fx3_jump(libusb_device_handle *device, uint32_t addr)
{
int status;
if (verbose)
logerror("transfer execution to Program Entry at 0x%08x\n", addr);
status = libusb_control_transfer(device,
LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE,
RW_INTERNAL, addr & 0xFFFF, addr >> 16,
NULL, 0, 1000);
/* We may get an I/O error from libusb as the device disappears */
if ((status != 0) && (status != LIBUSB_ERROR_IO))
{
const char *mesg = "failed to send jump command";
if (status < 0)
logerror("%s: %s\n", mesg, libusb_error_name(status));
else
logerror("%s\n", mesg);
return false;
} else
return true;
}
/*****************************************************************************/
/*
* Parse an Intel HEX image file and invoke the poke() function on the
* various segments to implement policies such as writing to RAM (with
* a one or two stage loader setup, depending on the firmware) or to
* EEPROM (two stages required).
*
* image - the hex image file
* context - for use by poke()
* is_external - if non-null, used to check which segments go into
* external memory (writable only by software loader)
* poke - called with each memory segment; errors indicated
* by returning negative values.
*
* Caller is responsible for halting CPU as needed, such as when
* overwriting a second stage loader.
*/
static int parse_ihex(FILE *image, void *context,
bool (*is_external)(uint32_t addr, size_t len),
int (*poke) (void *context, uint32_t addr, bool external,
const unsigned char *data, size_t len))
{
unsigned char data[1023];
uint32_t data_addr = 0;
size_t data_len = 0;
int rc;
int first_line = 1;
bool external = false;
/* Read the input file as an IHEX file, and report the memory segments
* as we go. Each line holds a max of 16 bytes, but uploading is
* faster (and EEPROM space smaller) if we merge those lines into larger
* chunks. Most hex files keep memory segments together, which makes
* such merging all but free. (But it may still be worth sorting the
* hex files to make up for undesirable behavior from tools.)
*
* Note that EEPROM segments max out at 1023 bytes; the upload protocol
* allows segments of up to 64 KBytes (more than a loader could handle).
*/
for (;;) {
char buf[512], *cp;
char tmp, type;
size_t len;
unsigned idx, off;
cp = fgets(buf, sizeof(buf), image);
if (cp == NULL) {
logerror("EOF without EOF record!\n");
break;
}
/* EXTENSION: "# comment-till-end-of-line", for copyrights etc */
if (buf[0] == '#')
continue;
if (buf[0] != ':') {
logerror("not an ihex record: %s", buf);
return -2;
}
/* ignore any newline */
cp = strchr(buf, '\n');
if (cp)
*cp = 0;
if (verbose >= 3)
logerror("** LINE: %s\n", buf);
/* Read the length field (up to 16 bytes) */
tmp = buf[3];
buf[3] = 0;
len = strtoul(buf+1, NULL, 16);
buf[3] = tmp;
/* Read the target offset (address up to 64KB) */
tmp = buf[7];
buf[7] = 0;
off = (int)strtoul(buf+3, NULL, 16);
buf[7] = tmp;
/* Initialize data_addr */
if (first_line) {
data_addr = off;
first_line = 0;
}
/* Read the record type */
tmp = buf[9];
buf[9] = 0;
type = (char)strtoul(buf+7, NULL, 16);
buf[9] = tmp;
/* If this is an EOF record, then make it so. */
if (type == 1) {
if (verbose >= 2)
logerror("EOF on hexfile\n");
break;
}
if (type != 0) {
logerror("unsupported record type: %u\n", type);
return -3;
}
if ((len * 2) + 11 > strlen(buf)) {
logerror("record too short?\n");
return -4;
}
/* FIXME check for _physically_ contiguous not just virtually
* e.g. on FX2 0x1f00-0x2100 includes both on-chip and external
* memory so it's not really contiguous */
/* flush the saved data if it's not contiguous,
* or when we've buffered as much as we can.
*/
if (data_len != 0
&& (off != (data_addr + data_len)
/* || !merge */
|| (data_len + len) > sizeof(data))) {
if (is_external)
external = is_external(data_addr, data_len);
rc = poke(context, data_addr, external, data, data_len);
if (rc < 0)
return -1;
data_addr = off;
data_len = 0;
}
/* append to saved data, flush later */
for (idx = 0, cp = buf+9 ; idx < len ; idx += 1, cp += 2) {
tmp = cp[2];
cp[2] = 0;
data[data_len + idx] = (uint8_t)strtoul(cp, NULL, 16);
cp[2] = tmp;
}
data_len += len;
}
/* flush any data remaining */
if (data_len != 0) {
if (is_external)
external = is_external(data_addr, data_len);
rc = poke(context, data_addr, external, data, data_len);
if (rc < 0)
return -1;
}
return 0;
}
/*
* Parse a binary image file and write it as is to the target.
* Applies to Cypress BIX images for RAM or Cypress IIC images
* for EEPROM.
*
* image - the BIX image file
* context - for use by poke()
* is_external - if non-null, used to check which segments go into
* external memory (writable only by software loader)
* poke - called with each memory segment; errors indicated
* by returning negative values.
*
* Caller is responsible for halting CPU as needed, such as when
* overwriting a second stage loader.
*/
static int parse_bin(FILE *image, void *context,
bool (*is_external)(uint32_t addr, size_t len), int (*poke)(void *context,
uint32_t addr, bool external, const unsigned char *data, size_t len))
{
unsigned char data[4096];
uint32_t data_addr = 0;
size_t data_len = 0;
int rc;
bool external = false;
for (;;) {
data_len = fread(data, 1, 4096, image);
if (data_len == 0)
break;
if (is_external)
external = is_external(data_addr, data_len);
rc = poke(context, data_addr, external, data, data_len);
if (rc < 0)
return -1;
data_addr += (uint32_t)data_len;
}
return feof(image)?0:-1;
}
/*
* Parse a Cypress IIC image file and invoke the poke() function on the
* various segments for writing to RAM
*
* image - the IIC image file
* context - for use by poke()
* is_external - if non-null, used to check which segments go into
* external memory (writable only by software loader)
* poke - called with each memory segment; errors indicated
* by returning negative values.
*
* Caller is responsible for halting CPU as needed, such as when
* overwriting a second stage loader.
*/
static int parse_iic(FILE *image, void *context,
bool (*is_external)(uint32_t addr, size_t len),
int (*poke)(void *context, uint32_t addr, bool external, const unsigned char *data, size_t len))
{
unsigned char data[4096];
uint32_t data_addr = 0;
size_t data_len = 0, read_len;
uint8_t block_header[4];
int rc;
bool external = false;
long file_size, initial_pos;
initial_pos = ftell(image);
if (initial_pos < 0)
return -1;
if (fseek(image, 0L, SEEK_END) != 0)
return -1;
file_size = ftell(image);
if (fseek(image, initial_pos, SEEK_SET) != 0)
return -1;
for (;;) {
/* Ignore the trailing reset IIC data (5 bytes) */
if (ftell(image) >= (file_size - 5))
break;
if (fread(&block_header, 1, sizeof(block_header), image) != 4) {
logerror("unable to read IIC block header\n");
return -1;
}
data_len = (block_header[0] << 8) + block_header[1];
data_addr = (block_header[2] << 8) + block_header[3];
if (data_len > sizeof(data)) {
/* If this is ever reported as an error, switch to using malloc/realloc */
logerror("IIC data block too small - please report this error to libusb.info\n");
return -1;
}
read_len = fread(data, 1, data_len, image);
if (read_len != data_len) {
logerror("read error\n");
return -1;
}
if (is_external)
external = is_external(data_addr, data_len);
rc = poke(context, data_addr, external, data, data_len);
if (rc < 0)
return -1;
}
return 0;
}
/* the parse call will be selected according to the image type */
static int (*parse[IMG_TYPE_MAX])(FILE *image, void *context, bool (*is_external)(uint32_t addr, size_t len),
int (*poke)(void *context, uint32_t addr, bool external, const unsigned char *data, size_t len))
= { parse_ihex, parse_iic, parse_bin };
/*****************************************************************************/
/*
* For writing to RAM using a first (hardware) or second (software)
* stage loader and 0xA0 or 0xA3 vendor requests
*/
typedef enum {
_undef = 0,
internal_only, /* hardware first-stage loader */
skip_internal, /* first phase, second-stage loader */
skip_external /* second phase, second-stage loader */
} ram_mode;
struct ram_poke_context {
libusb_device_handle *device;
ram_mode mode;
size_t total, count;
};
#define RETRY_LIMIT 5
static int ram_poke(void *context, uint32_t addr, bool external,
const unsigned char *data, size_t len)
{
struct ram_poke_context *ctx = (struct ram_poke_context*)context;
int rc;
unsigned retry = 0;
switch (ctx->mode) {
case internal_only: /* CPU should be stopped */
if (external) {
logerror("can't write %u bytes external memory at 0x%08x\n",
(unsigned)len, addr);
return -EINVAL;
}
break;
case skip_internal: /* CPU must be running */
if (!external) {
if (verbose >= 2) {
logerror("SKIP on-chip RAM, %u bytes at 0x%08x\n",
(unsigned)len, addr);
}
return 0;
}
break;
case skip_external: /* CPU should be stopped */
if (external) {
if (verbose >= 2) {
logerror("SKIP external RAM, %u bytes at 0x%08x\n",
(unsigned)len, addr);
}
return 0;
}
break;
case _undef:
default:
logerror("bug\n");
return -EDOM;
}
ctx->total += len;
ctx->count++;
/* Retry this till we get a real error. Control messages are not
* NAKed (just dropped) so time out means is a real problem.
*/
while ((rc = ezusb_write(ctx->device,
external ? "write external" : "write on-chip",
external ? RW_MEMORY : RW_INTERNAL,
addr, data, len)) < 0
&& retry < RETRY_LIMIT) {
if (rc != LIBUSB_ERROR_TIMEOUT)
break;
retry += 1;
}
return rc;
}
/*
* Load a Cypress Image file into target RAM.
* See http://www.cypress.com/?docID=41351 (AN76405 PDF) for more info.
*/
static int fx3_load_ram(libusb_device_handle *device, const char *path)
{
uint32_t dCheckSum, dExpectedCheckSum, dAddress, i, dLen, dLength;
uint32_t* dImageBuf;
unsigned char *bBuf, hBuf[4], blBuf[4], rBuf[4096];
FILE *image;
int ret = 0;
image = fopen(path, "rb");
if (image == NULL) {
logerror("unable to open '%s' for input\n", path);
return -2;
} else if (verbose)
logerror("open firmware image %s for RAM upload\n", path);
// Read header
if (fread(hBuf, sizeof(char), sizeof(hBuf), image) != sizeof(hBuf)) {
logerror("could not read image header");
ret = -3;
goto exit;
}
// check "CY" signature byte and format
if ((hBuf[0] != 'C') || (hBuf[1] != 'Y')) {
logerror("image doesn't have a CYpress signature\n");
ret = -3;
goto exit;
}
// Check bImageType
switch(hBuf[3]) {
case 0xB0:
if (verbose)
logerror("normal FW binary %s image with checksum\n", (hBuf[2]&0x01)?"data":"executable");
break;
case 0xB1:
logerror("security binary image is not currently supported\n");
ret = -3;
goto exit;
case 0xB2:
logerror("VID:PID image is not currently supported\n");
ret = -3;
goto exit;
default:
logerror("invalid image type 0x%02X\n", hBuf[3]);
ret = -3;
goto exit;
}
// Read the bootloader version
if (verbose) {
if ((ezusb_read(device, "read bootloader version", RW_INTERNAL, 0xFFFF0020, blBuf, 4) < 0)) {
logerror("Could not read bootloader version\n");
ret = -8;
goto exit;
}
logerror("FX3 bootloader version: 0x%02X%02X%02X%02X\n", blBuf[3], blBuf[2], blBuf[1], blBuf[0]);
}
dCheckSum = 0;
if (verbose)
logerror("writing image...\n");
while (1) {
if ((fread(&dLength, sizeof(uint32_t), 1, image) != 1) || // read dLength
(fread(&dAddress, sizeof(uint32_t), 1, image) != 1)) { // read dAddress
logerror("could not read image");
ret = -3;
goto exit;
}
if (dLength == 0)
break; // done
// coverity[tainted_data]
dImageBuf = (uint32_t*)calloc(dLength, sizeof(uint32_t));
if (dImageBuf == NULL) {
logerror("could not allocate buffer for image chunk\n");
ret = -4;
goto exit;
}
// read sections
if (fread(dImageBuf, sizeof(uint32_t), dLength, image) != dLength) {
logerror("could not read image");
free(dImageBuf);
ret = -3;
goto exit;
}
for (i = 0; i < dLength; i++)
dCheckSum += dImageBuf[i];
dLength <<= 2; // convert to Byte length
bBuf = (unsigned char*) dImageBuf;
while (dLength > 0) {
dLen = 4096; // 4K max
if (dLen > dLength)
dLen = dLength;
if ((ezusb_write(device, "write firmware", RW_INTERNAL, dAddress, bBuf, dLen) < 0) ||
(ezusb_read(device, "read firmware", RW_INTERNAL, dAddress, rBuf, dLen) < 0)) {
logerror("R/W error\n");
free(dImageBuf);
ret = -5;
goto exit;
}
// Verify data: rBuf with bBuf
for (i = 0; i < dLen; i++) {
if (rBuf[i] != bBuf[i]) {
logerror("verify error");
free(dImageBuf);
ret = -6;
goto exit;
}
}
dLength -= dLen;
bBuf += dLen;
dAddress += dLen;
}
free(dImageBuf);
}
// read pre-computed checksum data
if ((fread(&dExpectedCheckSum, sizeof(uint32_t), 1, image) != 1) ||
(dCheckSum != dExpectedCheckSum)) {
logerror("checksum error\n");
ret = -7;
goto exit;
}
// transfer execution to Program Entry
if (!ezusb_fx3_jump(device, dAddress)) {
ret = -6;
}
exit:
fclose(image);
return ret;
}
/*
* Load a firmware file into target RAM. device is the open libusb
* device, and the path is the name of the source file. Open the file,
* parse the bytes, and write them in one or two phases.
*
* If stage == 0, this uses the first stage loader, built into EZ-USB
* hardware but limited to writing on-chip memory or CPUCS. Everything
* is written during one stage, unless there's an error such as the image
* holding data that needs to be written to external memory.
*
* Otherwise, things are written in two stages. First the external
* memory is written, expecting a second stage loader to have already
* been loaded. Then file is re-parsed and on-chip memory is written.
*/
int ezusb_load_ram(libusb_device_handle *device, const char *path, int fx_type, int img_type, int stage)
{
FILE *image;
uint32_t cpucs_addr;
bool (*is_external)(uint32_t off, size_t len);
struct ram_poke_context ctx;
int status;
uint8_t iic_header[8] = { 0 };
int ret = 0;
if (fx_type == FX_TYPE_FX3)
return fx3_load_ram(device, path);
image = fopen(path, "rb");
if (image == NULL) {
logerror("%s: unable to open for input.\n", path);
return -2;
} else if (verbose > 1)
logerror("open firmware image %s for RAM upload\n", path);
if (img_type == IMG_TYPE_IIC) {
if ( (fread(iic_header, 1, sizeof(iic_header), image) != sizeof(iic_header))
|| (((fx_type == FX_TYPE_FX2LP) || (fx_type == FX_TYPE_FX2)) && (iic_header[0] != 0xC2))
|| ((fx_type == FX_TYPE_AN21) && (iic_header[0] != 0xB2))
|| ((fx_type == FX_TYPE_FX1) && (iic_header[0] != 0xB6)) ) {
logerror("IIC image does not contain executable code - cannot load to RAM.\n");
ret = -1;
goto exit;
}
}
/* EZ-USB original/FX and FX2 devices differ, apart from the 8051 core */
switch(fx_type) {
case FX_TYPE_FX2LP:
cpucs_addr = 0xe600;
is_external = fx2lp_is_external;
break;
case FX_TYPE_FX2:
cpucs_addr = 0xe600;
is_external = fx2_is_external;
break;
default:
cpucs_addr = 0x7f92;
is_external = fx_is_external;
break;
}
/* use only first stage loader? */
if (stage == 0) {
ctx.mode = internal_only;
/* if required, halt the CPU while we overwrite its code/data */
if (cpucs_addr && !ezusb_cpucs(device, cpucs_addr, false))
{
ret = -1;
goto exit;
}
/* 2nd stage, first part? loader was already uploaded */
} else {
ctx.mode = skip_internal;
/* let CPU run; overwrite the 2nd stage loader later */
if (verbose)
logerror("2nd stage: write external memory\n");
}
/* scan the image, first (maybe only) time */
ctx.device = device;
ctx.total = ctx.count = 0;
status = parse[img_type](image, &ctx, is_external, ram_poke);
if (status < 0) {
logerror("unable to upload %s\n", path);
ret = status;
goto exit;
}
/* second part of 2nd stage: rescan */
// TODO: what should we do for non HEX images there?
if (stage) {
ctx.mode = skip_external;
/* if needed, halt the CPU while we overwrite the 1st stage loader */
if (cpucs_addr && !ezusb_cpucs(device, cpucs_addr, false))
{
ret = -1;
goto exit;
}
/* at least write the interrupt vectors (at 0x0000) for reset! */
rewind(image);
if (verbose)
logerror("2nd stage: write on-chip memory\n");
status = parse_ihex(image, &ctx, is_external, ram_poke);
if (status < 0) {
logerror("unable to completely upload %s\n", path);
ret = status;
goto exit;
}
}
if (verbose && (ctx.count != 0)) {
logerror("... WROTE: %d bytes, %d segments, avg %d\n",
(int)ctx.total, (int)ctx.count, (int)(ctx.total/ctx.count));
}
/* if required, reset the CPU so it runs what we just uploaded */
if (cpucs_addr && !ezusb_cpucs(device, cpucs_addr, true))
ret = -1;
exit:
fclose(image);
return ret;
}

120
Externals/libusb/examples/ezusb.h vendored Normal file
View File

@ -0,0 +1,120 @@
#ifndef __ezusb_H
#define __ezusb_H
/*
* Copyright © 2001 Stephen Williams (steve@icarus.com)
* Copyright © 2002 David Brownell (dbrownell@users.sourceforge.net)
* Copyright © 2013 Federico Manzan (f.manzan@gmail.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
* General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(_MSC_VER)
#include <stdbool.h>
#else
#define __attribute__(x)
#if !defined(bool)
#define bool int
#endif
#if !defined(true)
#define true (1 == 1)
#endif
#if !defined(false)
#define false (!true)
#endif
#if defined(_PREFAST_)
#pragma warning(disable:28193)
#endif
#endif
#define FX_TYPE_UNDEFINED -1
#define FX_TYPE_AN21 0 /* Original AnchorChips parts */
#define FX_TYPE_FX1 1 /* Updated Cypress versions */
#define FX_TYPE_FX2 2 /* USB 2.0 versions */
#define FX_TYPE_FX2LP 3 /* Updated FX2 */
#define FX_TYPE_FX3 4 /* USB 3.0 versions */
#define FX_TYPE_MAX 5
#define FX_TYPE_NAMES { "an21", "fx", "fx2", "fx2lp", "fx3" }
#define IMG_TYPE_UNDEFINED -1
#define IMG_TYPE_HEX 0 /* Intel HEX */
#define IMG_TYPE_IIC 1 /* Cypress 8051 IIC */
#define IMG_TYPE_BIX 2 /* Cypress 8051 BIX */
#define IMG_TYPE_IMG 3 /* Cypress IMG format */
#define IMG_TYPE_MAX 4
#define IMG_TYPE_NAMES { "Intel HEX", "Cypress 8051 IIC", "Cypress 8051 BIX", "Cypress IMG format" }
#ifdef __cplusplus
extern "C" {
#endif
/*
* Automatically identified devices (VID, PID, type, designation).
* TODO: Could use some validation. Also where's the FX2?
*/
typedef struct {
uint16_t vid;
uint16_t pid;
int type;
const char* designation;
} fx_known_device;
#define FX_KNOWN_DEVICES { \
{ 0x0547, 0x2122, FX_TYPE_AN21, "Cypress EZ-USB (2122S)" },\
{ 0x0547, 0x2125, FX_TYPE_AN21, "Cypress EZ-USB (2121S/2125S)" },\
{ 0x0547, 0x2126, FX_TYPE_AN21, "Cypress EZ-USB (2126S)" },\
{ 0x0547, 0x2131, FX_TYPE_AN21, "Cypress EZ-USB (2131Q/2131S/2135S)" },\
{ 0x0547, 0x2136, FX_TYPE_AN21, "Cypress EZ-USB (2136S)" },\
{ 0x0547, 0x2225, FX_TYPE_AN21, "Cypress EZ-USB (2225)" },\
{ 0x0547, 0x2226, FX_TYPE_AN21, "Cypress EZ-USB (2226)" },\
{ 0x0547, 0x2235, FX_TYPE_AN21, "Cypress EZ-USB (2235)" },\
{ 0x0547, 0x2236, FX_TYPE_AN21, "Cypress EZ-USB (2236)" },\
{ 0x04b4, 0x6473, FX_TYPE_FX1, "Cypress EZ-USB FX1" },\
{ 0x04b4, 0x8613, FX_TYPE_FX2LP, "Cypress EZ-USB FX2LP (68013A/68014A/68015A/68016A)" }, \
{ 0x04b4, 0x00f3, FX_TYPE_FX3, "Cypress FX3" },\
}
/*
* This function uploads the firmware from the given file into RAM.
* Stage == 0 means this is a single stage load (or the first of
* two stages). Otherwise it's the second of two stages; the
* caller having preloaded the second stage loader.
*
* The target processor is reset at the end of this upload.
*/
extern int ezusb_load_ram(libusb_device_handle *device,
const char *path, int fx_type, int img_type, int stage);
/*
* This function uploads the firmware from the given file into EEPROM.
* This uses the right CPUCS address to terminate the EEPROM load with
* a reset command where FX parts behave differently than FX2 ones.
* The configuration byte is as provided here (zero for an21xx parts)
* and the EEPROM type is set so that the microcontroller will boot
* from it.
*
* The caller must have preloaded a second stage loader that knows
* how to respond to the EEPROM write request.
*/
extern int ezusb_load_eeprom(libusb_device_handle *device,
const char *path, int fx_type, int img_type, int config);
/* Verbosity level (default 1). Can be increased or decreased with options v/q */
extern int verbose;
#ifdef __cplusplus
}
#endif
#endif

287
Externals/libusb/examples/fxload.c vendored Normal file
View File

@ -0,0 +1,287 @@
/*
* Copyright © 2001 Stephen Williams (steve@icarus.com)
* Copyright © 2001-2002 David Brownell (dbrownell@users.sourceforge.net)
* Copyright © 2008 Roger Williams (rawqux@users.sourceforge.net)
* Copyright © 2012 Pete Batard (pete@akeo.ie)
* Copyright © 2013 Federico Manzan (f.manzan@gmail.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
* General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <stdarg.h>
#include <sys/types.h>
#include <getopt.h>
#include "libusb.h"
#include "ezusb.h"
#if !defined(_WIN32) || defined(__CYGWIN__ )
#include <syslog.h>
static bool dosyslog = false;
#include <strings.h>
#define _stricmp strcasecmp
#endif
#ifndef FXLOAD_VERSION
#define FXLOAD_VERSION (__DATE__ " (libusb)")
#endif
#ifndef ARRAYSIZE
#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
#endif
void logerror(const char *format, ...)
__attribute__ ((format (__printf__, 1, 2)));
void logerror(const char *format, ...)
{
va_list ap;
va_start(ap, format);
#if !defined(_WIN32) || defined(__CYGWIN__ )
if (dosyslog)
vsyslog(LOG_ERR, format, ap);
else
#endif
vfprintf(stderr, format, ap);
va_end(ap);
}
static int print_usage(int error_code) {
fprintf(stderr, "\nUsage: fxload [-v] [-V] [-t type] [-d vid:pid] [-p bus,addr] -i firmware\n");
fprintf(stderr, " -i <path> -- Firmware to upload\n");
fprintf(stderr, " -t <type> -- Target type: an21, fx, fx2, fx2lp, fx3\n");
fprintf(stderr, " -d <vid:pid> -- Target device, as an USB VID:PID\n");
fprintf(stderr, " -p <bus,addr> -- Target device, as a libusb bus number and device address path\n");
fprintf(stderr, " -v -- Increase verbosity\n");
fprintf(stderr, " -q -- Decrease verbosity (silent mode)\n");
fprintf(stderr, " -V -- Print program version\n");
return error_code;
}
#define FIRMWARE 0
#define LOADER 1
int main(int argc, char*argv[])
{
fx_known_device known_device[] = FX_KNOWN_DEVICES;
const char *path[] = { NULL, NULL };
const char *device_id = NULL;
const char *device_path = getenv("DEVICE");
const char *type = NULL;
const char *fx_name[FX_TYPE_MAX] = FX_TYPE_NAMES;
const char *ext, *img_name[] = IMG_TYPE_NAMES;
int fx_type = FX_TYPE_UNDEFINED, img_type[ARRAYSIZE(path)];
int i, j, opt, status;
unsigned vid = 0, pid = 0;
unsigned busnum = 0, devaddr = 0, _busnum, _devaddr;
libusb_device *dev, **devs;
libusb_device_handle *device = NULL;
struct libusb_device_descriptor desc;
while ((opt = getopt(argc, argv, "qvV?hd:p:i:I:t:")) != EOF)
switch (opt) {
case 'd':
device_id = optarg;
if (sscanf(device_id, "%x:%x" , &vid, &pid) != 2 ) {
fputs ("please specify VID & PID as \"vid:pid\" in hexadecimal format\n", stderr);
return -1;
}
break;
case 'p':
device_path = optarg;
if (sscanf(device_path, "%u,%u", &busnum, &devaddr) != 2 ) {
fputs ("please specify bus number & device number as \"bus,dev\" in decimal format\n", stderr);
return -1;
}
break;
case 'i':
case 'I':
path[FIRMWARE] = optarg;
break;
case 'V':
puts(FXLOAD_VERSION);
return 0;
case 't':
type = optarg;
break;
case 'v':
verbose++;
break;
case 'q':
verbose--;
break;
case '?':
case 'h':
default:
return print_usage(-1);
}
if (path[FIRMWARE] == NULL) {
logerror("no firmware specified!\n");
return print_usage(-1);
}
if ((device_id != NULL) && (device_path != NULL)) {
logerror("only one of -d or -p can be specified\n");
return print_usage(-1);
}
/* determine the target type */
if (type != NULL) {
for (i=0; i<FX_TYPE_MAX; i++) {
if (strcmp(type, fx_name[i]) == 0) {
fx_type = i;
break;
}
}
if (i >= FX_TYPE_MAX) {
logerror("illegal microcontroller type: %s\n", type);
return print_usage(-1);
}
}
/* open the device using libusb */
status = libusb_init(NULL);
if (status < 0) {
logerror("libusb_init() failed: %s\n", libusb_error_name(status));
return -1;
}
libusb_set_debug(NULL, verbose);
/* try to pick up missing parameters from known devices */
if ((type == NULL) || (device_id == NULL) || (device_path != NULL)) {
if (libusb_get_device_list(NULL, &devs) < 0) {
logerror("libusb_get_device_list() failed: %s\n", libusb_error_name(status));
goto err;
}
for (i=0; (dev=devs[i]) != NULL; i++) {
_busnum = libusb_get_bus_number(dev);
_devaddr = libusb_get_device_address(dev);
if ((type != NULL) && (device_path != NULL)) {
// if both a type and bus,addr were specified, we just need to find our match
if ((libusb_get_bus_number(dev) == busnum) && (libusb_get_device_address(dev) == devaddr))
break;
} else {
status = libusb_get_device_descriptor(dev, &desc);
if (status >= 0) {
if (verbose >= 3) {
logerror("examining %04x:%04x (%d,%d)\n",
desc.idVendor, desc.idProduct, _busnum, _devaddr);
}
for (j=0; j<ARRAYSIZE(known_device); j++) {
if ((desc.idVendor == known_device[j].vid)
&& (desc.idProduct == known_device[j].pid)) {
if (// nothing was specified
((type == NULL) && (device_id == NULL) && (device_path == NULL)) ||
// vid:pid was specified and we have a match
((type == NULL) && (device_id != NULL) && (vid == desc.idVendor) && (pid == desc.idProduct)) ||
// bus,addr was specified and we have a match
((type == NULL) && (device_path != NULL) && (busnum == _busnum) && (devaddr == _devaddr)) ||
// type was specified and we have a match
((type != NULL) && (device_id == NULL) && (device_path == NULL) && (fx_type == known_device[j].type)) ) {
fx_type = known_device[j].type;
vid = desc.idVendor;
pid = desc.idProduct;
busnum = _busnum;
devaddr = _devaddr;
break;
}
}
}
if (j < ARRAYSIZE(known_device)) {
if (verbose)
logerror("found device '%s' [%04x:%04x] (%d,%d)\n",
known_device[j].designation, vid, pid, busnum, devaddr);
break;
}
}
}
}
if (dev == NULL) {
libusb_free_device_list(devs, 1);
logerror("could not find a known device - please specify type and/or vid:pid and/or bus,dev\n");
return print_usage(-1);
}
status = libusb_open(dev, &device);
if (status < 0) {
logerror("libusb_open() failed: %s\n", libusb_error_name(status));
goto err;
}
libusb_free_device_list(devs, 1);
} else if (device_id != NULL) {
device = libusb_open_device_with_vid_pid(NULL, (uint16_t)vid, (uint16_t)pid);
if (device == NULL) {
logerror("libusb_open() failed\n");
goto err;
}
}
/* We need to claim the first interface */
libusb_set_auto_detach_kernel_driver(device, 1);
status = libusb_claim_interface(device, 0);
if (status != LIBUSB_SUCCESS) {
logerror("libusb_claim_interface failed: %s\n", libusb_error_name(status));
goto err;
}
if (verbose)
logerror("microcontroller type: %s\n", fx_name[fx_type]);
for (i=0; i<ARRAYSIZE(path); i++) {
if (path[i] != NULL) {
ext = path[i] + strlen(path[i]) - 4;
if ((_stricmp(ext, ".hex") == 0) || (strcmp(ext, ".ihx") == 0))
img_type[i] = IMG_TYPE_HEX;
else if (_stricmp(ext, ".iic") == 0)
img_type[i] = IMG_TYPE_IIC;
else if (_stricmp(ext, ".bix") == 0)
img_type[i] = IMG_TYPE_BIX;
else if (_stricmp(ext, ".img") == 0)
img_type[i] = IMG_TYPE_IMG;
else {
logerror("%s is not a recognized image type\n", path[i]);
goto err;
}
}
if (verbose && path[i] != NULL)
logerror("%s: type %s\n", path[i], img_name[img_type[i]]);
}
/* single stage, put into internal memory */
if (verbose > 1)
logerror("single stage: load on-chip memory\n");
status = ezusb_load_ram(device, path[FIRMWARE], fx_type, img_type[FIRMWARE], 0);
libusb_release_interface(device, 0);
libusb_close(device);
libusb_exit(NULL);
return status;
err:
libusb_exit(NULL);
return -1;
}

1060
Externals/libusb/examples/getopt/getopt.c vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,180 @@
/* Declarations for getopt.
Copyright (C) 1989-1994, 1996-1999, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#ifndef _GETOPT_H
#ifndef __need_getopt
# define _GETOPT_H 1
#endif
/* If __GNU_LIBRARY__ is not already defined, either we are being used
standalone, or this is the first header included in the source file.
If we are being used with glibc, we need to include <features.h>, but
that does not exist if we are standalone. So: if __GNU_LIBRARY__ is
not defined, include <ctype.h>, which will pull in <features.h> for us
if it's from glibc. (Why ctype.h? It's guaranteed to exist and it
doesn't flood the namespace with stuff the way some other headers do.) */
#if !defined __GNU_LIBRARY__
# include <ctype.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* For communication from `getopt' to the caller.
When `getopt' finds an option that takes an argument,
the argument value is returned here.
Also, when `ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
extern char *optarg;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
and for communication between successive calls to `getopt'.
On entry to `getopt', zero means this is the first call; initialize.
When `getopt' returns -1, this is the index of the first of the
non-option elements that the caller should itself scan.
Otherwise, `optind' communicates from one call to the next
how much of ARGV has been scanned so far. */
extern int optind;
/* Callers store zero here to inhibit the error message `getopt' prints
for unrecognized options. */
extern int opterr;
/* Set to an option character which was unrecognized. */
extern int optopt;
#ifndef __need_getopt
/* Describe the long-named options requested by the application.
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
of `struct option' terminated by an element containing a name which is
zero.
The field `has_arg' is:
no_argument (or 0) if the option does not take an argument,
required_argument (or 1) if the option requires an argument,
optional_argument (or 2) if the option takes an optional argument.
If the field `flag' is not NULL, it points to a variable that is set
to the value given in the field `val' when the option is found, but
left unchanged if the option is not found.
To have a long-named option do something other than set an `int' to
a compiled-in constant, such as set a value from `optarg', set the
option's `flag' field to zero and its `val' field to a nonzero
value (the equivalent single-letter option character, if there is
one). For long options that have a zero `flag' field, `getopt'
returns the contents of the `val' field. */
struct option
{
# if (defined __STDC__ && __STDC__) || defined __cplusplus
const char *name;
# else
char *name;
# endif
/* has_arg can't be an enum because some compilers complain about
type mismatches in all the code that assumes it is an int. */
int has_arg;
int *flag;
int val;
};
/* Names for the values of the `has_arg' field of `struct option'. */
# define no_argument 0
# define required_argument 1
# define optional_argument 2
#endif /* need getopt */
/* Get definitions and prototypes for functions to process the
arguments in ARGV (ARGC of them, minus the program name) for
options given in OPTS.
Return the option character from OPTS just read. Return -1 when
there are no more options. For unrecognized options, or options
missing arguments, `optopt' is set to the option letter, and '?' is
returned.
The OPTS string is a list of characters which are recognized option
letters, optionally followed by colons, specifying that that letter
takes an argument, to be placed in `optarg'.
If a letter in OPTS is followed by two colons, its argument is
optional. This behavior is specific to the GNU `getopt'.
The argument `--' causes premature termination of argument
scanning, explicitly telling `getopt' that there are no more
options.
If OPTS begins with `--', then non-option arguments are treated as
arguments to the option '\0'. This behavior is specific to the GNU
`getopt'. */
#if (defined __STDC__ && __STDC__) || defined __cplusplus
# ifdef __GNU_LIBRARY__
/* Many other libraries have conflicting prototypes for getopt, with
differences in the consts, in stdlib.h. To avoid compilation
errors, only prototype getopt for the GNU C library. */
extern int getopt (int __argc, char *const *__argv, const char *__shortopts);
# else /* not __GNU_LIBRARY__ */
extern int getopt ();
# endif /* __GNU_LIBRARY__ */
# ifndef __need_getopt
extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts,
const struct option *__longopts, int *__longind);
extern int getopt_long_only (int __argc, char *const *__argv,
const char *__shortopts,
const struct option *__longopts, int *__longind);
/* Internal only. Users should not call this directly. */
extern int _getopt_internal (int __argc, char *const *__argv,
const char *__shortopts,
const struct option *__longopts, int *__longind,
int __long_only);
# endif
#else /* not __STDC__ */
extern int getopt ();
# ifndef __need_getopt
extern int getopt_long ();
extern int getopt_long_only ();
extern int _getopt_internal ();
# endif
#endif /* __STDC__ */
#ifdef __cplusplus
}
#endif
/* Make sure we later can get all the definitions and declarations. */
#undef __need_getopt
#endif /* getopt.h */

View File

@ -0,0 +1,188 @@
/* getopt_long and getopt_long_only entry points for GNU getopt.
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "getopt.h"
#if !defined __STDC__ || !__STDC__
/* This is a separate conditional since some stdc systems
reject `defined (const)'. */
#ifndef const
#define const
#endif
#endif
#include <stdio.h>
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C
Library, but also included in many other GNU distributions. Compiling
and linking in this code is a waste when using the GNU C library
(especially if it is a shared library). Rather than having every GNU
program understand `configure --with-gnu-libc' and omit the object files,
it is simpler to just do this in the source for each such file. */
#define GETOPT_INTERFACE_VERSION 2
#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
#include <gnu-versions.h>
#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
#define ELIDE_CODE
#endif
#endif
#ifndef ELIDE_CODE
/* This needs to come after some library #include
to get __GNU_LIBRARY__ defined. */
#ifdef __GNU_LIBRARY__
#include <stdlib.h>
#endif
#ifndef NULL
#define NULL 0
#endif
int
getopt_long (argc, argv, options, long_options, opt_index)
int argc;
char *const *argv;
const char *options;
const struct option *long_options;
int *opt_index;
{
return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
}
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
If an option that starts with '-' (not '--') doesn't match a long option,
but does match a short option, it is parsed as a short option
instead. */
int
getopt_long_only (argc, argv, options, long_options, opt_index)
int argc;
char *const *argv;
const char *options;
const struct option *long_options;
int *opt_index;
{
return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
}
#endif /* Not ELIDE_CODE. */
#ifdef TEST
#include <stdio.h>
int
main (argc, argv)
int argc;
char **argv;
{
int c;
int digit_optind = 0;
while (1)
{
int this_option_optind = optind ? optind : 1;
int option_index = 0;
static struct option long_options[] =
{
{"add", 1, 0, 0},
{"append", 0, 0, 0},
{"delete", 1, 0, 0},
{"verbose", 0, 0, 0},
{"create", 0, 0, 0},
{"file", 1, 0, 0},
{0, 0, 0, 0}
};
c = getopt_long (argc, argv, "abc:d:0123456789",
long_options, &option_index);
if (c == -1)
break;
switch (c)
{
case 0:
printf ("option %s", long_options[option_index].name);
if (optarg)
printf (" with arg %s", optarg);
printf ("\n");
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
if (digit_optind != 0 && digit_optind != this_option_optind)
printf ("digits occur in two different argv-elements.\n");
digit_optind = this_option_optind;
printf ("option %c\n", c);
break;
case 'a':
printf ("option a\n");
break;
case 'b':
printf ("option b\n");
break;
case 'c':
printf ("option c with value `%s'\n", optarg);
break;
case 'd':
printf ("option d with value `%s'\n", optarg);
break;
case '?':
break;
default:
printf ("?? getopt returned character code 0%o ??\n", c);
}
}
if (optind < argc)
{
printf ("non-option ARGV-elements: ");
while (optind < argc)
printf ("%s ", argv[optind++]);
printf ("\n");
}
exit (0);
}
#endif /* TEST */

104
Externals/libusb/examples/hotplugtest.c vendored Normal file
View File

@ -0,0 +1,104 @@
/* -*- Mode: C; indent-tabs-mode:t ; c-basic-offset:8 -*- */
/*
* libusb example program for hotplug API
* Copyright © 2012-2013 Nathan Hjelm <hjelmn@mac.ccom>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdlib.h>
#include <stdio.h>
#include "libusb.h"
int done = 0;
libusb_device_handle *handle;
static int LIBUSB_CALL hotplug_callback(libusb_context *ctx, libusb_device *dev, libusb_hotplug_event event, void *user_data)
{
struct libusb_device_descriptor desc;
int rc;
rc = libusb_get_device_descriptor(dev, &desc);
if (LIBUSB_SUCCESS != rc) {
fprintf (stderr, "Error getting device descriptor\n");
}
printf ("Device attached: %04x:%04x\n", desc.idVendor, desc.idProduct);
libusb_open (dev, &handle);
done++;
return 0;
}
static int LIBUSB_CALL hotplug_callback_detach(libusb_context *ctx, libusb_device *dev, libusb_hotplug_event event, void *user_data)
{
printf ("Device detached\n");
libusb_close (handle);
done++;
return 0;
}
int main(int argc, char *argv[])
{
libusb_hotplug_callback_handle hp[2];
int product_id, vendor_id, class_id;
int rc;
vendor_id = (argc > 1) ? strtol (argv[1], NULL, 0) : 0x045a;
product_id = (argc > 2) ? strtol (argv[2], NULL, 0) : 0x5005;
class_id = (argc > 3) ? strtol (argv[3], NULL, 0) : LIBUSB_HOTPLUG_MATCH_ANY;
rc = libusb_init (NULL);
if (rc < 0)
{
printf("failed to initialise libusb: %s\n", libusb_error_name(rc));
return EXIT_FAILURE;
}
if (!libusb_has_capability (LIBUSB_CAP_HAS_HOTPLUG)) {
printf ("Hotplug capabilites are not supported on this platform\n");
libusb_exit (NULL);
return EXIT_FAILURE;
}
rc = libusb_hotplug_register_callback (NULL, LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, 0, vendor_id,
product_id, class_id, hotplug_callback, NULL, &hp[0]);
if (LIBUSB_SUCCESS != rc) {
fprintf (stderr, "Error registering callback 0\n");
libusb_exit (NULL);
return EXIT_FAILURE;
}
rc = libusb_hotplug_register_callback (NULL, LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT, 0, vendor_id,
product_id,class_id, hotplug_callback_detach, NULL, &hp[1]);
if (LIBUSB_SUCCESS != rc) {
fprintf (stderr, "Error registering callback 1\n");
libusb_exit (NULL);
return EXIT_FAILURE;
}
while (done < 2) {
rc = libusb_handle_events (NULL);
if (rc < 0)
printf("libusb_handle_events() failed: %s\n", libusb_error_name(rc));
}
libusb_exit (NULL);
}

71
Externals/libusb/examples/listdevs.c vendored Normal file
View File

@ -0,0 +1,71 @@
/*
* libusb example program to list devices on the bus
* Copyright © 2007 Daniel Drake <dsd@gentoo.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdio.h>
#include "libusb.h"
static void print_devs(libusb_device **devs)
{
libusb_device *dev;
int i = 0, j = 0;
uint8_t path[8];
while ((dev = devs[i++]) != NULL) {
struct libusb_device_descriptor desc;
int r = libusb_get_device_descriptor(dev, &desc);
if (r < 0) {
fprintf(stderr, "failed to get device descriptor");
return;
}
printf("%04x:%04x (bus %d, device %d)",
desc.idVendor, desc.idProduct,
libusb_get_bus_number(dev), libusb_get_device_address(dev));
r = libusb_get_port_numbers(dev, path, sizeof(path));
if (r > 0) {
printf(" path: %d", path[0]);
for (j = 1; j < r; j++)
printf(".%d", path[j]);
}
printf("\n");
}
}
int main(void)
{
libusb_device **devs;
int r;
ssize_t cnt;
r = libusb_init(NULL);
if (r < 0)
return r;
cnt = libusb_get_device_list(NULL, &devs);
if (cnt < 0)
return (int) cnt;
print_devs(devs);
libusb_free_device_list(devs, 1);
libusb_exit(NULL);
return 0;
}

View File

@ -0,0 +1,193 @@
/*
* libusb example program to measure Atmel SAM3U isochronous performance
* Copyright (C) 2012 Harald Welte <laforge@gnumonks.org>
*
* Copied with the author's permission under LGPL-2.1 from
* http://git.gnumonks.org/cgi-bin/gitweb.cgi?p=sam3u-tests.git;a=blob;f=usb-benchmark-project/host/benchmark.c;h=74959f7ee88f1597286cd435f312a8ff52c56b7e
*
* An Atmel SAM3U test firmware is also available in the above repository.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <signal.h>
#include <libusb.h>
#define EP_DATA_IN 0x82
#define EP_ISO_IN 0x86
static int do_exit = 0;
static struct libusb_device_handle *devh = NULL;
static unsigned long num_bytes = 0, num_xfer = 0;
static struct timeval tv_start;
static void LIBUSB_CALL cb_xfr(struct libusb_transfer *xfr)
{
unsigned int i;
if (xfr->status != LIBUSB_TRANSFER_COMPLETED) {
fprintf(stderr, "transfer status %d\n", xfr->status);
libusb_free_transfer(xfr);
exit(3);
}
if (xfr->type == LIBUSB_TRANSFER_TYPE_ISOCHRONOUS) {
for (i = 0; i < xfr->num_iso_packets; i++) {
struct libusb_iso_packet_descriptor *pack = &xfr->iso_packet_desc[i];
if (pack->status != LIBUSB_TRANSFER_COMPLETED) {
fprintf(stderr, "Error: pack %u status %d\n", i, pack->status);
exit(5);
}
printf("pack%u length:%u, actual_length:%u\n", i, pack->length, pack->actual_length);
}
}
printf("length:%u, actual_length:%u\n", xfr->length, xfr->actual_length);
for (i = 0; i < xfr->actual_length; i++) {
printf("%02x", xfr->buffer[i]);
if (i % 16)
printf("\n");
else if (i % 8)
printf(" ");
else
printf(" ");
}
num_bytes += xfr->actual_length;
num_xfer++;
if (libusb_submit_transfer(xfr) < 0) {
fprintf(stderr, "error re-submitting URB\n");
exit(1);
}
}
static int benchmark_in(uint8_t ep)
{
static uint8_t buf[2048];
static struct libusb_transfer *xfr;
int num_iso_pack = 0;
if (ep == EP_ISO_IN)
num_iso_pack = 16;
xfr = libusb_alloc_transfer(num_iso_pack);
if (!xfr)
return -ENOMEM;
if (ep == EP_ISO_IN) {
libusb_fill_iso_transfer(xfr, devh, ep, buf,
sizeof(buf), num_iso_pack, cb_xfr, NULL, 0);
libusb_set_iso_packet_lengths(xfr, sizeof(buf)/num_iso_pack);
} else
libusb_fill_bulk_transfer(xfr, devh, ep, buf,
sizeof(buf), cb_xfr, NULL, 0);
gettimeofday(&tv_start, NULL);
/* NOTE: To reach maximum possible performance the program must
* submit *multiple* transfers here, not just one.
*
* When only one transfer is submitted there is a gap in the bus
* schedule from when the transfer completes until a new transfer
* is submitted by the callback. This causes some jitter for
* isochronous transfers and loss of throughput for bulk transfers.
*
* This is avoided by queueing multiple transfers in advance, so
* that the host controller is always kept busy, and will schedule
* more transfers on the bus while the callback is running for
* transfers which have completed on the bus.
*/
return libusb_submit_transfer(xfr);
}
static void measure(void)
{
struct timeval tv_stop;
unsigned int diff_msec;
gettimeofday(&tv_stop, NULL);
diff_msec = (tv_stop.tv_sec - tv_start.tv_sec)*1000;
diff_msec += (tv_stop.tv_usec - tv_start.tv_usec)/1000;
printf("%lu transfers (total %lu bytes) in %u miliseconds => %lu bytes/sec\n",
num_xfer, num_bytes, diff_msec, (num_bytes*1000)/diff_msec);
}
static void sig_hdlr(int signum)
{
switch (signum) {
case SIGINT:
measure();
do_exit = 1;
break;
}
}
int main(int argc, char **argv)
{
int rc;
struct sigaction sigact;
sigact.sa_handler = sig_hdlr;
sigemptyset(&sigact.sa_mask);
sigact.sa_flags = 0;
sigaction(SIGINT, &sigact, NULL);
rc = libusb_init(NULL);
if (rc < 0) {
fprintf(stderr, "Error initializing libusb: %s\n", libusb_error_name(rc));
exit(1);
}
devh = libusb_open_device_with_vid_pid(NULL, 0x16c0, 0x0763);
if (!devh) {
fprintf(stderr, "Error finding USB device\n");
goto out;
}
rc = libusb_claim_interface(devh, 2);
if (rc < 0) {
fprintf(stderr, "Error claiming interface: %s\n", libusb_error_name(rc));
goto out;
}
benchmark_in(EP_ISO_IN);
while (!do_exit) {
rc = libusb_handle_events(NULL);
if (rc != LIBUSB_SUCCESS)
break;
}
/* Measurement has already been done by the signal handler. */
libusb_release_interface(devh, 0);
out:
if (devh)
libusb_close(devh);
libusb_exit(NULL);
return rc;
}

1129
Externals/libusb/examples/xusb.c vendored Normal file

File diff suppressed because it is too large Load Diff

0
Externals/libusbx/install-sh → Externals/libusb/install-sh vendored Normal file → Executable file
View File

View File

@ -3,7 +3,7 @@ exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: libusbx-1.0
Name: libusb-1.0
Description: C API for USB device access from Linux, Mac OS X, Windows and OpenBSD/NetBSD userspace
Version: @VERSION@
Libs: -L${libdir} -lusb-1.0

View File

@ -1,16 +1,19 @@
all: libusb-1.0.la libusb-1.0.dll
AUTOMAKE_OPTIONS = subdir-objects
lib_LTLIBRARIES = libusb-1.0.la
POSIX_POLL_SRC = os/poll_posix.c
LINUX_USBFS_SRC = os/linux_usbfs.c
DARWIN_USB_SRC = os/darwin_usb.c
OPENBSD_USB_SRC = os/openbsd_usb.c
NETBSD_USB_SRC = os/netbsd_usb.c
WINDOWS_USB_SRC = os/poll_windows.c os/windows_usb.c libusb-1.0.rc libusb-1.0.def
WINCE_USB_SRC = os/wince_usb.c os/wince_usb.h
EXTRA_DIST = $(LINUX_USBFS_SRC) $(DARWIN_USB_SRC) $(OPENBSD_USB_SRC) \
$(WINDOWS_USB_SRC) $(WINCE_USB_SRC) \
$(NETBSD_USB_SRC) $(WINDOWS_USB_SRC) $(WINCE_USB_SRC) \
$(POSIX_POLL_SRC) \
os/threads_posix.c os/threads_windows.c \
os/linux_udev.c os/linux_netlink.c
@ -36,6 +39,10 @@ if OS_OPENBSD
OS_SRC = $(OPENBSD_USB_SRC) $(POSIX_POLL_SRC)
endif
if OS_NETBSD
OS_SRC = $(NETBSD_USB_SRC) $(POSIX_POLL_SRC)
endif
if OS_WINDOWS
OS_SRC = $(WINDOWS_USB_SRC)
@ -45,7 +52,7 @@ OS_SRC = $(WINDOWS_USB_SRC)
libusb-1.0.rc: version.h version_nano.h
endif
libusb-1.0.dll: libusb-1.0.def
libusb-1.0.dll: libusb-1.0.def libusb-1.0.la
if CREATE_IMPORT_LIB
# Rebuild the import lib from the .def so that MS and MinGW DLLs can be interchanged
$(AM_V_GEN)$(DLLTOOL) $(DLLTOOLFLAGS) --kill-at --input-def $(srcdir)/libusb-1.0.def --dllname $@ --output-lib .libs/$@.a

View File

@ -1,4 +1,4 @@
# Makefile.in generated by automake 1.13.4 from Makefile.am.
# Makefile.in generated by automake 1.14.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
@ -129,30 +129,36 @@ am__libusb_1_0_la_SOURCES_DIST = libusbi.h core.c descriptor.c io.c \
os/threads_windows.h os/threads_windows.c os/threads_posix.h \
os/threads_posix.c os/darwin_usb.c os/poll_posix.c \
os/linux_usbfs.c os/linux_netlink.c os/linux_udev.c \
os/openbsd_usb.c os/poll_windows.c os/windows_usb.c \
libusb-1.0.rc libusb-1.0.def os/poll_posix.h os/poll_windows.h
@THREADS_POSIX_FALSE@am__objects_1 = libusb_1_0_la-threads_windows.lo
@THREADS_POSIX_TRUE@am__objects_1 = libusb_1_0_la-threads_posix.lo
am__objects_2 = libusb_1_0_la-darwin_usb.lo
am__objects_3 = libusb_1_0_la-poll_posix.lo
am__objects_4 = libusb_1_0_la-linux_usbfs.lo
am__objects_5 = libusb_1_0_la-openbsd_usb.lo
am__objects_6 = libusb_1_0_la-poll_windows.lo \
libusb_1_0_la-windows_usb.lo libusb-1.0.lo
@OS_DARWIN_FALSE@@OS_LINUX_FALSE@@OS_OPENBSD_FALSE@@OS_WINDOWS_TRUE@am__objects_7 = $(am__objects_6)
@OS_DARWIN_FALSE@@OS_LINUX_FALSE@@OS_OPENBSD_TRUE@am__objects_7 = $(am__objects_5) \
@OS_DARWIN_FALSE@@OS_LINUX_FALSE@@OS_OPENBSD_TRUE@ $(am__objects_3)
@OS_DARWIN_FALSE@@OS_LINUX_TRUE@@USE_UDEV_FALSE@am__objects_7 = $(am__objects_4) \
os/netbsd_usb.c os/openbsd_usb.c os/poll_windows.c \
os/windows_usb.c libusb-1.0.rc libusb-1.0.def os/poll_posix.h \
os/poll_windows.h
am__dirstamp = $(am__leading_dot)dirstamp
@THREADS_POSIX_FALSE@am__objects_1 = \
@THREADS_POSIX_FALSE@ os/libusb_1_0_la-threads_windows.lo
@THREADS_POSIX_TRUE@am__objects_1 = os/libusb_1_0_la-threads_posix.lo
am__objects_2 = os/libusb_1_0_la-darwin_usb.lo
am__objects_3 = os/libusb_1_0_la-poll_posix.lo
am__objects_4 = os/libusb_1_0_la-linux_usbfs.lo
am__objects_5 = os/libusb_1_0_la-netbsd_usb.lo
am__objects_6 = os/libusb_1_0_la-openbsd_usb.lo
am__objects_7 = os/libusb_1_0_la-poll_windows.lo \
os/libusb_1_0_la-windows_usb.lo libusb-1.0.lo
@OS_DARWIN_FALSE@@OS_LINUX_FALSE@@OS_NETBSD_FALSE@@OS_OPENBSD_FALSE@@OS_WINDOWS_TRUE@am__objects_8 = $(am__objects_7)
@OS_DARWIN_FALSE@@OS_LINUX_FALSE@@OS_NETBSD_FALSE@@OS_OPENBSD_TRUE@am__objects_8 = $(am__objects_6) \
@OS_DARWIN_FALSE@@OS_LINUX_FALSE@@OS_NETBSD_FALSE@@OS_OPENBSD_TRUE@ $(am__objects_3)
@OS_DARWIN_FALSE@@OS_LINUX_FALSE@@OS_NETBSD_TRUE@am__objects_8 = $(am__objects_5) \
@OS_DARWIN_FALSE@@OS_LINUX_FALSE@@OS_NETBSD_TRUE@ $(am__objects_3)
@OS_DARWIN_FALSE@@OS_LINUX_TRUE@@USE_UDEV_FALSE@am__objects_8 = $(am__objects_4) \
@OS_DARWIN_FALSE@@OS_LINUX_TRUE@@USE_UDEV_FALSE@ $(am__objects_3) \
@OS_DARWIN_FALSE@@OS_LINUX_TRUE@@USE_UDEV_FALSE@ libusb_1_0_la-linux_netlink.lo
@OS_DARWIN_FALSE@@OS_LINUX_TRUE@@USE_UDEV_TRUE@am__objects_7 = $(am__objects_4) \
@OS_DARWIN_FALSE@@OS_LINUX_TRUE@@USE_UDEV_FALSE@ os/libusb_1_0_la-linux_netlink.lo
@OS_DARWIN_FALSE@@OS_LINUX_TRUE@@USE_UDEV_TRUE@am__objects_8 = $(am__objects_4) \
@OS_DARWIN_FALSE@@OS_LINUX_TRUE@@USE_UDEV_TRUE@ $(am__objects_3) \
@OS_DARWIN_FALSE@@OS_LINUX_TRUE@@USE_UDEV_TRUE@ libusb_1_0_la-linux_udev.lo
@OS_DARWIN_TRUE@am__objects_7 = $(am__objects_2) $(am__objects_3)
@OS_DARWIN_FALSE@@OS_LINUX_TRUE@@USE_UDEV_TRUE@ os/libusb_1_0_la-linux_udev.lo
@OS_DARWIN_TRUE@am__objects_8 = $(am__objects_2) $(am__objects_3)
am_libusb_1_0_la_OBJECTS = libusb_1_0_la-core.lo \
libusb_1_0_la-descriptor.lo libusb_1_0_la-io.lo \
libusb_1_0_la-strerror.lo libusb_1_0_la-sync.lo \
libusb_1_0_la-hotplug.lo $(am__objects_1) $(am__objects_7)
libusb_1_0_la-hotplug.lo $(am__objects_1) $(am__objects_8)
libusb_1_0_la_OBJECTS = $(am_libusb_1_0_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
@ -274,6 +280,7 @@ OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OS_DARWIN = @OS_DARWIN@
OS_LINUX = @OS_LINUX@
OS_NETBSD = @OS_NETBSD@
OS_OPENBSD = @OS_OPENBSD@
OS_WINDOWS = @OS_WINDOWS@
OTOOL = @OTOOL@
@ -346,15 +353,17 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = subdir-objects
lib_LTLIBRARIES = libusb-1.0.la
POSIX_POLL_SRC = os/poll_posix.c
LINUX_USBFS_SRC = os/linux_usbfs.c
DARWIN_USB_SRC = os/darwin_usb.c
OPENBSD_USB_SRC = os/openbsd_usb.c
NETBSD_USB_SRC = os/netbsd_usb.c
WINDOWS_USB_SRC = os/poll_windows.c os/windows_usb.c libusb-1.0.rc libusb-1.0.def
WINCE_USB_SRC = os/wince_usb.c os/wince_usb.h
EXTRA_DIST = $(LINUX_USBFS_SRC) $(DARWIN_USB_SRC) $(OPENBSD_USB_SRC) \
$(WINDOWS_USB_SRC) $(WINCE_USB_SRC) \
$(NETBSD_USB_SRC) $(WINDOWS_USB_SRC) $(WINCE_USB_SRC) \
$(POSIX_POLL_SRC) \
os/threads_posix.c os/threads_windows.c \
os/linux_udev.c os/linux_netlink.c
@ -366,6 +375,7 @@ EXTRA_DIST = $(LINUX_USBFS_SRC) $(DARWIN_USB_SRC) $(OPENBSD_USB_SRC) \
@OS_LINUX_TRUE@@USE_UDEV_TRUE@OS_SRC = $(LINUX_USBFS_SRC) $(POSIX_POLL_SRC) \
@OS_LINUX_TRUE@@USE_UDEV_TRUE@ os/linux_udev.c
@OS_NETBSD_TRUE@OS_SRC = $(NETBSD_USB_SRC) $(POSIX_POLL_SRC)
@OS_OPENBSD_TRUE@OS_SRC = $(OPENBSD_USB_SRC) $(POSIX_POLL_SRC)
@OS_WINDOWS_TRUE@OS_SRC = $(WINDOWS_USB_SRC)
@OS_DARWIN_TRUE@AM_CFLAGS_EXT = -no-cpp-precomp
@ -449,50 +459,84 @@ clean-libLTLIBRARIES:
echo rm -f $${locs}; \
rm -f $${locs}; \
}
os/$(am__dirstamp):
@$(MKDIR_P) os
@: > os/$(am__dirstamp)
os/$(DEPDIR)/$(am__dirstamp):
@$(MKDIR_P) os/$(DEPDIR)
@: > os/$(DEPDIR)/$(am__dirstamp)
os/libusb_1_0_la-threads_windows.lo: os/$(am__dirstamp) \
os/$(DEPDIR)/$(am__dirstamp)
os/libusb_1_0_la-threads_posix.lo: os/$(am__dirstamp) \
os/$(DEPDIR)/$(am__dirstamp)
os/libusb_1_0_la-darwin_usb.lo: os/$(am__dirstamp) \
os/$(DEPDIR)/$(am__dirstamp)
os/libusb_1_0_la-poll_posix.lo: os/$(am__dirstamp) \
os/$(DEPDIR)/$(am__dirstamp)
os/libusb_1_0_la-linux_usbfs.lo: os/$(am__dirstamp) \
os/$(DEPDIR)/$(am__dirstamp)
os/libusb_1_0_la-linux_netlink.lo: os/$(am__dirstamp) \
os/$(DEPDIR)/$(am__dirstamp)
os/libusb_1_0_la-linux_udev.lo: os/$(am__dirstamp) \
os/$(DEPDIR)/$(am__dirstamp)
os/libusb_1_0_la-netbsd_usb.lo: os/$(am__dirstamp) \
os/$(DEPDIR)/$(am__dirstamp)
os/libusb_1_0_la-openbsd_usb.lo: os/$(am__dirstamp) \
os/$(DEPDIR)/$(am__dirstamp)
os/libusb_1_0_la-poll_windows.lo: os/$(am__dirstamp) \
os/$(DEPDIR)/$(am__dirstamp)
os/libusb_1_0_la-windows_usb.lo: os/$(am__dirstamp) \
os/$(DEPDIR)/$(am__dirstamp)
libusb-1.0.la: $(libusb_1_0_la_OBJECTS) $(libusb_1_0_la_DEPENDENCIES) $(EXTRA_libusb_1_0_la_DEPENDENCIES)
$(AM_V_CCLD)$(libusb_1_0_la_LINK) -rpath $(libdir) $(libusb_1_0_la_OBJECTS) $(libusb_1_0_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
-rm -f os/*.$(OBJEXT)
-rm -f os/*.lo
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libusb_1_0_la-core.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libusb_1_0_la-darwin_usb.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libusb_1_0_la-descriptor.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libusb_1_0_la-hotplug.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libusb_1_0_la-io.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libusb_1_0_la-linux_netlink.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libusb_1_0_la-linux_udev.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libusb_1_0_la-linux_usbfs.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libusb_1_0_la-openbsd_usb.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libusb_1_0_la-poll_posix.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libusb_1_0_la-poll_windows.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libusb_1_0_la-strerror.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libusb_1_0_la-sync.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libusb_1_0_la-threads_posix.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libusb_1_0_la-threads_windows.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libusb_1_0_la-windows_usb.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@os/$(DEPDIR)/libusb_1_0_la-darwin_usb.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@os/$(DEPDIR)/libusb_1_0_la-linux_netlink.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@os/$(DEPDIR)/libusb_1_0_la-linux_udev.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@os/$(DEPDIR)/libusb_1_0_la-linux_usbfs.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@os/$(DEPDIR)/libusb_1_0_la-netbsd_usb.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@os/$(DEPDIR)/libusb_1_0_la-openbsd_usb.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@os/$(DEPDIR)/libusb_1_0_la-poll_posix.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@os/$(DEPDIR)/libusb_1_0_la-poll_windows.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@os/$(DEPDIR)/libusb_1_0_la-threads_posix.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@os/$(DEPDIR)/libusb_1_0_la-threads_windows.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@os/$(DEPDIR)/libusb_1_0_la-windows_usb.Plo@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $<
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
.c.obj:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
@ -539,81 +583,89 @@ libusb_1_0_la-hotplug.lo: hotplug.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -c -o libusb_1_0_la-hotplug.lo `test -f 'hotplug.c' || echo '$(srcdir)/'`hotplug.c
libusb_1_0_la-threads_windows.lo: os/threads_windows.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -MT libusb_1_0_la-threads_windows.lo -MD -MP -MF $(DEPDIR)/libusb_1_0_la-threads_windows.Tpo -c -o libusb_1_0_la-threads_windows.lo `test -f 'os/threads_windows.c' || echo '$(srcdir)/'`os/threads_windows.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libusb_1_0_la-threads_windows.Tpo $(DEPDIR)/libusb_1_0_la-threads_windows.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='os/threads_windows.c' object='libusb_1_0_la-threads_windows.lo' libtool=yes @AMDEPBACKSLASH@
os/libusb_1_0_la-threads_windows.lo: os/threads_windows.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -MT os/libusb_1_0_la-threads_windows.lo -MD -MP -MF os/$(DEPDIR)/libusb_1_0_la-threads_windows.Tpo -c -o os/libusb_1_0_la-threads_windows.lo `test -f 'os/threads_windows.c' || echo '$(srcdir)/'`os/threads_windows.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) os/$(DEPDIR)/libusb_1_0_la-threads_windows.Tpo os/$(DEPDIR)/libusb_1_0_la-threads_windows.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='os/threads_windows.c' object='os/libusb_1_0_la-threads_windows.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -c -o libusb_1_0_la-threads_windows.lo `test -f 'os/threads_windows.c' || echo '$(srcdir)/'`os/threads_windows.c
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -c -o os/libusb_1_0_la-threads_windows.lo `test -f 'os/threads_windows.c' || echo '$(srcdir)/'`os/threads_windows.c
libusb_1_0_la-threads_posix.lo: os/threads_posix.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -MT libusb_1_0_la-threads_posix.lo -MD -MP -MF $(DEPDIR)/libusb_1_0_la-threads_posix.Tpo -c -o libusb_1_0_la-threads_posix.lo `test -f 'os/threads_posix.c' || echo '$(srcdir)/'`os/threads_posix.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libusb_1_0_la-threads_posix.Tpo $(DEPDIR)/libusb_1_0_la-threads_posix.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='os/threads_posix.c' object='libusb_1_0_la-threads_posix.lo' libtool=yes @AMDEPBACKSLASH@
os/libusb_1_0_la-threads_posix.lo: os/threads_posix.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -MT os/libusb_1_0_la-threads_posix.lo -MD -MP -MF os/$(DEPDIR)/libusb_1_0_la-threads_posix.Tpo -c -o os/libusb_1_0_la-threads_posix.lo `test -f 'os/threads_posix.c' || echo '$(srcdir)/'`os/threads_posix.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) os/$(DEPDIR)/libusb_1_0_la-threads_posix.Tpo os/$(DEPDIR)/libusb_1_0_la-threads_posix.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='os/threads_posix.c' object='os/libusb_1_0_la-threads_posix.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -c -o libusb_1_0_la-threads_posix.lo `test -f 'os/threads_posix.c' || echo '$(srcdir)/'`os/threads_posix.c
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -c -o os/libusb_1_0_la-threads_posix.lo `test -f 'os/threads_posix.c' || echo '$(srcdir)/'`os/threads_posix.c
libusb_1_0_la-darwin_usb.lo: os/darwin_usb.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -MT libusb_1_0_la-darwin_usb.lo -MD -MP -MF $(DEPDIR)/libusb_1_0_la-darwin_usb.Tpo -c -o libusb_1_0_la-darwin_usb.lo `test -f 'os/darwin_usb.c' || echo '$(srcdir)/'`os/darwin_usb.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libusb_1_0_la-darwin_usb.Tpo $(DEPDIR)/libusb_1_0_la-darwin_usb.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='os/darwin_usb.c' object='libusb_1_0_la-darwin_usb.lo' libtool=yes @AMDEPBACKSLASH@
os/libusb_1_0_la-darwin_usb.lo: os/darwin_usb.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -MT os/libusb_1_0_la-darwin_usb.lo -MD -MP -MF os/$(DEPDIR)/libusb_1_0_la-darwin_usb.Tpo -c -o os/libusb_1_0_la-darwin_usb.lo `test -f 'os/darwin_usb.c' || echo '$(srcdir)/'`os/darwin_usb.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) os/$(DEPDIR)/libusb_1_0_la-darwin_usb.Tpo os/$(DEPDIR)/libusb_1_0_la-darwin_usb.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='os/darwin_usb.c' object='os/libusb_1_0_la-darwin_usb.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -c -o libusb_1_0_la-darwin_usb.lo `test -f 'os/darwin_usb.c' || echo '$(srcdir)/'`os/darwin_usb.c
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -c -o os/libusb_1_0_la-darwin_usb.lo `test -f 'os/darwin_usb.c' || echo '$(srcdir)/'`os/darwin_usb.c
libusb_1_0_la-poll_posix.lo: os/poll_posix.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -MT libusb_1_0_la-poll_posix.lo -MD -MP -MF $(DEPDIR)/libusb_1_0_la-poll_posix.Tpo -c -o libusb_1_0_la-poll_posix.lo `test -f 'os/poll_posix.c' || echo '$(srcdir)/'`os/poll_posix.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libusb_1_0_la-poll_posix.Tpo $(DEPDIR)/libusb_1_0_la-poll_posix.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='os/poll_posix.c' object='libusb_1_0_la-poll_posix.lo' libtool=yes @AMDEPBACKSLASH@
os/libusb_1_0_la-poll_posix.lo: os/poll_posix.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -MT os/libusb_1_0_la-poll_posix.lo -MD -MP -MF os/$(DEPDIR)/libusb_1_0_la-poll_posix.Tpo -c -o os/libusb_1_0_la-poll_posix.lo `test -f 'os/poll_posix.c' || echo '$(srcdir)/'`os/poll_posix.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) os/$(DEPDIR)/libusb_1_0_la-poll_posix.Tpo os/$(DEPDIR)/libusb_1_0_la-poll_posix.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='os/poll_posix.c' object='os/libusb_1_0_la-poll_posix.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -c -o libusb_1_0_la-poll_posix.lo `test -f 'os/poll_posix.c' || echo '$(srcdir)/'`os/poll_posix.c
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -c -o os/libusb_1_0_la-poll_posix.lo `test -f 'os/poll_posix.c' || echo '$(srcdir)/'`os/poll_posix.c
libusb_1_0_la-linux_usbfs.lo: os/linux_usbfs.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -MT libusb_1_0_la-linux_usbfs.lo -MD -MP -MF $(DEPDIR)/libusb_1_0_la-linux_usbfs.Tpo -c -o libusb_1_0_la-linux_usbfs.lo `test -f 'os/linux_usbfs.c' || echo '$(srcdir)/'`os/linux_usbfs.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libusb_1_0_la-linux_usbfs.Tpo $(DEPDIR)/libusb_1_0_la-linux_usbfs.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='os/linux_usbfs.c' object='libusb_1_0_la-linux_usbfs.lo' libtool=yes @AMDEPBACKSLASH@
os/libusb_1_0_la-linux_usbfs.lo: os/linux_usbfs.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -MT os/libusb_1_0_la-linux_usbfs.lo -MD -MP -MF os/$(DEPDIR)/libusb_1_0_la-linux_usbfs.Tpo -c -o os/libusb_1_0_la-linux_usbfs.lo `test -f 'os/linux_usbfs.c' || echo '$(srcdir)/'`os/linux_usbfs.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) os/$(DEPDIR)/libusb_1_0_la-linux_usbfs.Tpo os/$(DEPDIR)/libusb_1_0_la-linux_usbfs.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='os/linux_usbfs.c' object='os/libusb_1_0_la-linux_usbfs.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -c -o libusb_1_0_la-linux_usbfs.lo `test -f 'os/linux_usbfs.c' || echo '$(srcdir)/'`os/linux_usbfs.c
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -c -o os/libusb_1_0_la-linux_usbfs.lo `test -f 'os/linux_usbfs.c' || echo '$(srcdir)/'`os/linux_usbfs.c
libusb_1_0_la-linux_netlink.lo: os/linux_netlink.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -MT libusb_1_0_la-linux_netlink.lo -MD -MP -MF $(DEPDIR)/libusb_1_0_la-linux_netlink.Tpo -c -o libusb_1_0_la-linux_netlink.lo `test -f 'os/linux_netlink.c' || echo '$(srcdir)/'`os/linux_netlink.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libusb_1_0_la-linux_netlink.Tpo $(DEPDIR)/libusb_1_0_la-linux_netlink.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='os/linux_netlink.c' object='libusb_1_0_la-linux_netlink.lo' libtool=yes @AMDEPBACKSLASH@
os/libusb_1_0_la-linux_netlink.lo: os/linux_netlink.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -MT os/libusb_1_0_la-linux_netlink.lo -MD -MP -MF os/$(DEPDIR)/libusb_1_0_la-linux_netlink.Tpo -c -o os/libusb_1_0_la-linux_netlink.lo `test -f 'os/linux_netlink.c' || echo '$(srcdir)/'`os/linux_netlink.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) os/$(DEPDIR)/libusb_1_0_la-linux_netlink.Tpo os/$(DEPDIR)/libusb_1_0_la-linux_netlink.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='os/linux_netlink.c' object='os/libusb_1_0_la-linux_netlink.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -c -o libusb_1_0_la-linux_netlink.lo `test -f 'os/linux_netlink.c' || echo '$(srcdir)/'`os/linux_netlink.c
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -c -o os/libusb_1_0_la-linux_netlink.lo `test -f 'os/linux_netlink.c' || echo '$(srcdir)/'`os/linux_netlink.c
libusb_1_0_la-linux_udev.lo: os/linux_udev.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -MT libusb_1_0_la-linux_udev.lo -MD -MP -MF $(DEPDIR)/libusb_1_0_la-linux_udev.Tpo -c -o libusb_1_0_la-linux_udev.lo `test -f 'os/linux_udev.c' || echo '$(srcdir)/'`os/linux_udev.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libusb_1_0_la-linux_udev.Tpo $(DEPDIR)/libusb_1_0_la-linux_udev.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='os/linux_udev.c' object='libusb_1_0_la-linux_udev.lo' libtool=yes @AMDEPBACKSLASH@
os/libusb_1_0_la-linux_udev.lo: os/linux_udev.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -MT os/libusb_1_0_la-linux_udev.lo -MD -MP -MF os/$(DEPDIR)/libusb_1_0_la-linux_udev.Tpo -c -o os/libusb_1_0_la-linux_udev.lo `test -f 'os/linux_udev.c' || echo '$(srcdir)/'`os/linux_udev.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) os/$(DEPDIR)/libusb_1_0_la-linux_udev.Tpo os/$(DEPDIR)/libusb_1_0_la-linux_udev.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='os/linux_udev.c' object='os/libusb_1_0_la-linux_udev.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -c -o libusb_1_0_la-linux_udev.lo `test -f 'os/linux_udev.c' || echo '$(srcdir)/'`os/linux_udev.c
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -c -o os/libusb_1_0_la-linux_udev.lo `test -f 'os/linux_udev.c' || echo '$(srcdir)/'`os/linux_udev.c
libusb_1_0_la-openbsd_usb.lo: os/openbsd_usb.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -MT libusb_1_0_la-openbsd_usb.lo -MD -MP -MF $(DEPDIR)/libusb_1_0_la-openbsd_usb.Tpo -c -o libusb_1_0_la-openbsd_usb.lo `test -f 'os/openbsd_usb.c' || echo '$(srcdir)/'`os/openbsd_usb.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libusb_1_0_la-openbsd_usb.Tpo $(DEPDIR)/libusb_1_0_la-openbsd_usb.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='os/openbsd_usb.c' object='libusb_1_0_la-openbsd_usb.lo' libtool=yes @AMDEPBACKSLASH@
os/libusb_1_0_la-netbsd_usb.lo: os/netbsd_usb.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -MT os/libusb_1_0_la-netbsd_usb.lo -MD -MP -MF os/$(DEPDIR)/libusb_1_0_la-netbsd_usb.Tpo -c -o os/libusb_1_0_la-netbsd_usb.lo `test -f 'os/netbsd_usb.c' || echo '$(srcdir)/'`os/netbsd_usb.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) os/$(DEPDIR)/libusb_1_0_la-netbsd_usb.Tpo os/$(DEPDIR)/libusb_1_0_la-netbsd_usb.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='os/netbsd_usb.c' object='os/libusb_1_0_la-netbsd_usb.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -c -o libusb_1_0_la-openbsd_usb.lo `test -f 'os/openbsd_usb.c' || echo '$(srcdir)/'`os/openbsd_usb.c
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -c -o os/libusb_1_0_la-netbsd_usb.lo `test -f 'os/netbsd_usb.c' || echo '$(srcdir)/'`os/netbsd_usb.c
libusb_1_0_la-poll_windows.lo: os/poll_windows.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -MT libusb_1_0_la-poll_windows.lo -MD -MP -MF $(DEPDIR)/libusb_1_0_la-poll_windows.Tpo -c -o libusb_1_0_la-poll_windows.lo `test -f 'os/poll_windows.c' || echo '$(srcdir)/'`os/poll_windows.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libusb_1_0_la-poll_windows.Tpo $(DEPDIR)/libusb_1_0_la-poll_windows.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='os/poll_windows.c' object='libusb_1_0_la-poll_windows.lo' libtool=yes @AMDEPBACKSLASH@
os/libusb_1_0_la-openbsd_usb.lo: os/openbsd_usb.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -MT os/libusb_1_0_la-openbsd_usb.lo -MD -MP -MF os/$(DEPDIR)/libusb_1_0_la-openbsd_usb.Tpo -c -o os/libusb_1_0_la-openbsd_usb.lo `test -f 'os/openbsd_usb.c' || echo '$(srcdir)/'`os/openbsd_usb.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) os/$(DEPDIR)/libusb_1_0_la-openbsd_usb.Tpo os/$(DEPDIR)/libusb_1_0_la-openbsd_usb.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='os/openbsd_usb.c' object='os/libusb_1_0_la-openbsd_usb.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -c -o libusb_1_0_la-poll_windows.lo `test -f 'os/poll_windows.c' || echo '$(srcdir)/'`os/poll_windows.c
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -c -o os/libusb_1_0_la-openbsd_usb.lo `test -f 'os/openbsd_usb.c' || echo '$(srcdir)/'`os/openbsd_usb.c
libusb_1_0_la-windows_usb.lo: os/windows_usb.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -MT libusb_1_0_la-windows_usb.lo -MD -MP -MF $(DEPDIR)/libusb_1_0_la-windows_usb.Tpo -c -o libusb_1_0_la-windows_usb.lo `test -f 'os/windows_usb.c' || echo '$(srcdir)/'`os/windows_usb.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libusb_1_0_la-windows_usb.Tpo $(DEPDIR)/libusb_1_0_la-windows_usb.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='os/windows_usb.c' object='libusb_1_0_la-windows_usb.lo' libtool=yes @AMDEPBACKSLASH@
os/libusb_1_0_la-poll_windows.lo: os/poll_windows.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -MT os/libusb_1_0_la-poll_windows.lo -MD -MP -MF os/$(DEPDIR)/libusb_1_0_la-poll_windows.Tpo -c -o os/libusb_1_0_la-poll_windows.lo `test -f 'os/poll_windows.c' || echo '$(srcdir)/'`os/poll_windows.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) os/$(DEPDIR)/libusb_1_0_la-poll_windows.Tpo os/$(DEPDIR)/libusb_1_0_la-poll_windows.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='os/poll_windows.c' object='os/libusb_1_0_la-poll_windows.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -c -o libusb_1_0_la-windows_usb.lo `test -f 'os/windows_usb.c' || echo '$(srcdir)/'`os/windows_usb.c
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -c -o os/libusb_1_0_la-poll_windows.lo `test -f 'os/poll_windows.c' || echo '$(srcdir)/'`os/poll_windows.c
os/libusb_1_0_la-windows_usb.lo: os/windows_usb.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -MT os/libusb_1_0_la-windows_usb.lo -MD -MP -MF os/$(DEPDIR)/libusb_1_0_la-windows_usb.Tpo -c -o os/libusb_1_0_la-windows_usb.lo `test -f 'os/windows_usb.c' || echo '$(srcdir)/'`os/windows_usb.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) os/$(DEPDIR)/libusb_1_0_la-windows_usb.Tpo os/$(DEPDIR)/libusb_1_0_la-windows_usb.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='os/windows_usb.c' object='os/libusb_1_0_la-windows_usb.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libusb_1_0_la_CFLAGS) $(CFLAGS) -c -o os/libusb_1_0_la-windows_usb.lo `test -f 'os/windows_usb.c' || echo '$(srcdir)/'`os/windows_usb.c
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
-rm -rf os/.libs os/_libs
install-hdrHEADERS: $(hdr_HEADERS)
@$(NORMAL_INSTALL)
@list='$(hdr_HEADERS)'; test -n "$(hdrdir)" || list=; \
@ -751,6 +803,8 @@ clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
-rm -f os/$(DEPDIR)/$(am__dirstamp)
-rm -f os/$(am__dirstamp)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@ -761,7 +815,7 @@ clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -rf ./$(DEPDIR) os/$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
@ -807,7 +861,7 @@ install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -rf ./$(DEPDIR) os/$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
@ -851,7 +905,7 @@ all: libusb-1.0.la libusb-1.0.dll
@OS_WINDOWS_TRUE@libusb-1.0.rc: version.h version_nano.h
libusb-1.0.dll: libusb-1.0.def
libusb-1.0.dll: libusb-1.0.def libusb-1.0.la
# Rebuild the import lib from the .def so that MS and MinGW DLLs can be interchanged
@CREATE_IMPORT_LIB_TRUE@ $(AM_V_GEN)$(DLLTOOL) $(DLLTOOLFLAGS) --kill-at --input-def $(srcdir)/libusb-1.0.def --dllname $@ --output-lib .libs/$@.a

View File

@ -1,6 +1,6 @@
/* -*- Mode: C; indent-tabs-mode:t ; c-basic-offset:8 -*- */
/*
* Core functions for libusbx
* Core functions for libusb
* Copyright © 2012-2013 Nathan Hjelm <hjelmn@cs.unm.edu>
* Copyright © 2007-2008 Daniel Drake <dsd@gentoo.org>
* Copyright © 2001 Johannes Erdfelt <johannes@erdfelt.com>
@ -33,6 +33,9 @@
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE_SYSLOG_H
#include <syslog.h>
#endif
#ifdef __ANDROID__
#include <android/log.h>
@ -47,6 +50,8 @@ const struct usbi_os_backend * const usbi_backend = &linux_usbfs_backend;
const struct usbi_os_backend * const usbi_backend = &darwin_backend;
#elif defined(OS_OPENBSD)
const struct usbi_os_backend * const usbi_backend = &openbsd_backend;
#elif defined(OS_NETBSD)
const struct usbi_os_backend * const usbi_backend = &netbsd_backend;
#elif defined(OS_WINDOWS)
const struct usbi_os_backend * const usbi_backend = &windows_backend;
#elif defined(OS_WINCE)
@ -56,9 +61,9 @@ const struct usbi_os_backend * const usbi_backend = &wince_backend;
#endif
struct libusb_context *usbi_default_context = NULL;
const struct libusb_version libusb_version_internal =
static const struct libusb_version libusb_version_internal =
{ LIBUSB_MAJOR, LIBUSB_MINOR, LIBUSB_MICRO, LIBUSB_NANO,
LIBUSB_RC, "http://libusbx.org" };
LIBUSB_RC, "http://libusb.info" };
static int default_context_refcnt = 0;
static usbi_mutex_static_t default_context_lock = USBI_MUTEX_INITIALIZER;
static struct timeval timestamp_origin = { 0, 0 };
@ -67,18 +72,18 @@ usbi_mutex_static_t active_contexts_lock = USBI_MUTEX_INITIALIZER;
struct list_head active_contexts_list;
/**
* \mainpage libusbx-1.0 API Reference
* \mainpage libusb-1.0 API Reference
*
* \section intro Introduction
*
* libusbx is an open source library that allows you to communicate with USB
* libusb is an open source library that allows you to communicate with USB
* devices from userspace. For more info, see the
* <a href="http://libusbx.org">libusbx homepage</a>.
* <a href="http://libusb.info">libusb homepage</a>.
*
* This documentation is aimed at application developers wishing to
* communicate with USB peripherals from their own software. After reviewing
* this documentation, feedback and questions can be sent to the
* <a href="http://mailing-list.libusbx.org">libusbx-devel mailing list</a>.
* <a href="http://mailing-list.libusb.info">libusb-devel mailing list</a>.
*
* This documentation assumes knowledge of how to operate USB devices from
* a software standpoint (descriptors, configurations, interfaces, endpoints,
@ -102,25 +107,25 @@ struct list_head active_contexts_list;
* \section gettingstarted Getting Started
*
* To begin reading the API documentation, start with the Modules page which
* links to the different categories of libusbx's functionality.
* links to the different categories of libusb's functionality.
*
* One decision you will have to make is whether to use the synchronous
* or the asynchronous data transfer interface. The \ref io documentation
* provides some insight into this topic.
*
* Some example programs can be found in the libusbx source distribution under
* the "examples" subdirectory. The libusbx homepage includes a list of
* real-life project examples which use libusbx.
* Some example programs can be found in the libusb source distribution under
* the "examples" subdirectory. The libusb homepage includes a list of
* real-life project examples which use libusb.
*
* \section errorhandling Error handling
*
* libusbx functions typically return 0 on success or a negative error code
* libusb functions typically return 0 on success or a negative error code
* on failure. These negative error codes relate to LIBUSB_ERROR constants
* which are listed on the \ref misc "miscellaneous" documentation page.
*
* \section msglog Debug message logging
*
* libusbx uses stderr for all logging. By default, logging is set to NONE,
* libusb uses stderr for all logging. By default, logging is set to NONE,
* which means that no output will be produced. However, unless the library
* has been compiled with logging disabled, then any application calls to
* libusb_set_debug(), or the setting of the environmental variable
@ -129,19 +134,19 @@ struct list_head active_contexts_list;
* direct it to the null device if its output is undesireable.
*
* The libusb_set_debug() function can be used to enable logging of certain
* messages. Under standard configuration, libusbx doesn't really log much
* messages. Under standard configuration, libusb doesn't really log much
* so you are advised to use this function to enable all error/warning/
* informational messages. It will help debug problems with your software.
*
* The logged messages are unstructured. There is no one-to-one correspondence
* between messages being logged and success or failure return codes from
* libusbx functions. There is no format to the messages, so you should not
* libusb functions. There is no format to the messages, so you should not
* try to capture or parse them. They are not and will not be localized.
* These messages are not intended to being passed to your application user;
* instead, you should interpret the error codes returned from libusbx functions
* instead, you should interpret the error codes returned from libusb functions
* and provide appropriate notification to the user. The messages are simply
* there to aid you as a programmer, and if you're confused because you're
* getting a strange error code from a libusbx function, enabling message
* getting a strange error code from a libusb function, enabling message
* logging may give you a suitable explanation.
*
* The LIBUSB_DEBUG environment variable can be used to enable message logging
@ -150,18 +155,18 @@ struct list_head active_contexts_list;
* environment variable is set, the message logging verbosity level is fixed
* and libusb_set_debug() effectively does nothing.
*
* libusbx can be compiled without any logging functions, useful for embedded
* libusb can be compiled without any logging functions, useful for embedded
* systems. In this case, libusb_set_debug() and the LIBUSB_DEBUG environment
* variable have no effects.
*
* libusbx can also be compiled with verbose debugging messages always. When
* libusb can also be compiled with verbose debugging messages always. When
* the library is compiled in this way, all messages of all verbosities are
* always logged. libusb_set_debug() and the LIBUSB_DEBUG environment variable
* have no effects.
*
* \section remarks Other remarks
*
* libusbx does have imperfections. The \ref caveats "caveats" page attempts
* libusb does have imperfections. The \ref caveats "caveats" page attempts
* to document these.
*/
@ -176,7 +181,7 @@ struct list_head active_contexts_list;
* reset).
*
* The problem is that any other program could reset the device your program
* is working with, at any time. libusbx does not offer a mechanism to inform
* is working with, at any time. libusb does not offer a mechanism to inform
* you when this has happened, so if someone else resets your device it will
* not be clear to your own program why the device state has changed.
*
@ -201,7 +206,7 @@ struct list_head active_contexts_list;
*
* \section configsel Configuration selection and handling
*
* When libusbx presents a device handle to an application, there is a chance
* When libusb presents a device handle to an application, there is a chance
* that the corresponding device may be in unconfigured state. For devices
* with multiple configurations, there is also a chance that the configuration
* currently selected is not the one that the application wants to use.
@ -212,13 +217,13 @@ struct list_head active_contexts_list;
* -# If the device is already in the desired configuration, calling
* libusb_set_configuration() using the same configuration value will cause
* a lightweight device reset. This may not be desirable behaviour.
* -# libusbx will be unable to change configuration if the device is in
* -# libusb will be unable to change configuration if the device is in
* another configuration and other programs or drivers have claimed
* interfaces under that configuration.
* -# In the case where the desired configuration is already active, libusbx
* -# In the case where the desired configuration is already active, libusb
* may not even be able to perform a lightweight device reset. For example,
* take my USB keyboard with fingerprint reader: I'm interested in driving
* the fingerprint reader interface through libusbx, but the kernel's
* the fingerprint reader interface through libusb, but the kernel's
* USB-HID driver will almost always have claimed the keyboard interface.
* Because the kernel has claimed an interface, it is not even possible to
* perform the lightweight device reset, so libusb_set_configuration() will
@ -258,13 +263,13 @@ if (cfg != desired)
* considerations apply to Darwin or other platforms.
*
* When a transfer completes early (i.e. when less data is received/sent in
* any one packet than the transfer buffer allows for) then libusbx is designed
* any one packet than the transfer buffer allows for) then libusb is designed
* to terminate the transfer immediately, not transferring or receiving any
* more data unless other transfers have been queued by the user.
*
* On legacy platforms, libusbx is unable to do this in all situations. After
* On legacy platforms, libusb is unable to do this in all situations. After
* the incomplete packet occurs, "surplus" data may be transferred. For recent
* versions of libusbx, this information is kept (the data length of the
* versions of libusb, this information is kept (the data length of the
* transfer is updated) and, for device-to-host transfers, any surplus data was
* added to the buffer. Still, this is not a nice solution because it loses the
* information about the end of the short packet, and the user probably wanted
@ -273,7 +278,7 @@ if (cfg != desired)
*
* \section zlp Zero length packets
*
* - libusbx is able to send a packet of zero length to an endpoint simply by
* - libusb is able to send a packet of zero length to an endpoint simply by
* submitting a transfer of zero length.
* - The \ref libusb_transfer_flags::LIBUSB_TRANSFER_ADD_ZERO_PACKET
* "LIBUSB_TRANSFER_ADD_ZERO_PACKET" flag is currently only supported on Linux.
@ -282,24 +287,24 @@ if (cfg != desired)
/**
* \page contexts Contexts
*
* It is possible that libusbx may be used simultaneously from two independent
* It is possible that libusb may be used simultaneously from two independent
* libraries linked into the same executable. For example, if your application
* has a plugin-like system which allows the user to dynamically load a range
* of modules into your program, it is feasible that two independently
* developed modules may both use libusbx.
* developed modules may both use libusb.
*
* libusbx is written to allow for these multiple user scenarios. The two
* "instances" of libusbx will not interfere: libusb_set_debug() calls
* libusb is written to allow for these multiple user scenarios. The two
* "instances" of libusb will not interfere: libusb_set_debug() calls
* from one user will not affect the same settings for other users, other
* users can continue using libusbx after one of them calls libusb_exit(), etc.
* users can continue using libusb after one of them calls libusb_exit(), etc.
*
* This is made possible through libusbx's <em>context</em> concept. When you
* This is made possible through libusb's <em>context</em> concept. When you
* call libusb_init(), you are (optionally) given a context. You can then pass
* this context pointer back into future libusbx functions.
* this context pointer back into future libusb functions.
*
* In order to keep things simple for more simplistic applications, it is
* legal to pass NULL to all functions requiring a context pointer (as long as
* you're sure no other code will attempt to use libusbx from the same process).
* you're sure no other code will attempt to use libusb from the same process).
* When you pass NULL, the default context will be used. The default context
* is created the first time a process calls libusb_init() when no other
* context is alive. Contexts are destroyed during libusb_exit().
@ -312,17 +317,17 @@ if (cfg != desired)
* reference count goes from 0 to 1, and is deinitialized and destroyed when
* its reference count goes from 1 to 0.
*
* You may be wondering why only a subset of libusbx functions require a
* context pointer in their function definition. Internally, libusbx stores
* You may be wondering why only a subset of libusb functions require a
* context pointer in their function definition. Internally, libusb stores
* context pointers in other objects (e.g. libusb_device instances) and hence
* can infer the context from those objects.
*/
/**
* @defgroup lib Library initialization/deinitialization
* This page details how to initialize and deinitialize libusbx. Initialization
* must be performed before using any libusbx functionality, and similarly you
* must not call any libusbx functions after deinitialization.
* This page details how to initialize and deinitialize libusb. Initialization
* must be performed before using any libusb functionality, and similarly you
* must not call any libusb functions after deinitialization.
*/
/**
@ -379,7 +384,7 @@ libusb_free_device_list(list, 1);
* device.
*
* \section devshandles Devices and device handles
* libusbx has a concept of a USB device, represented by the
* libusb has a concept of a USB device, represented by the
* \ref libusb_device opaque type. A device represents a USB device that
* is currently or was previously connected to the system. Using a reference
* to a device, you can determine certain information about the device (e.g.
@ -395,8 +400,8 @@ libusb_free_device_list(list, 1);
* using the device.
*
* When you've found a device that you'd like to operate, you must ask
* libusbx to open the device using the libusb_open() function. Assuming
* success, libusbx then returns you a <em>device handle</em>
* libusb to open the device using the libusb_open() function. Assuming
* success, libusb then returns you a <em>device handle</em>
* (a \ref libusb_device_handle pointer). All "real" I/O operations then
* operate on the handle rather than the original device pointer.
*
@ -404,10 +409,10 @@ libusb_free_device_list(list, 1);
*
* Device discovery (i.e. calling libusb_get_device_list()) returns a
* freshly-allocated list of devices. The list itself must be freed when
* you are done with it. libusbx also needs to know when it is OK to free
* you are done with it. libusb also needs to know when it is OK to free
* the contents of the list - the devices themselves.
*
* To handle these issues, libusbx provides you with two separate items:
* To handle these issues, libusb provides you with two separate items:
* - A function to free the list itself
* - A reference counting system for the devices inside
*
@ -564,6 +569,10 @@ void usbi_disconnect_device(struct libusb_device *dev)
dev->attached = 0;
usbi_mutex_unlock(&dev->lock);
usbi_mutex_lock(&ctx->usb_devs_lock);
list_del(&dev->list);
usbi_mutex_unlock(&ctx->usb_devs_lock);
/* Signal that an event has occurred for this device if we support hotplug AND
* the hotplug pipe is ready. This prevents an event from getting raised during
* initial enumeration. libusb_handle_events will take care of dereferencing the
@ -574,10 +583,6 @@ void usbi_disconnect_device(struct libusb_device *dev)
usbi_err(DEVICE_CTX(dev), "error writing hotplug message");
}
}
usbi_mutex_lock(&ctx->usb_devs_lock);
list_del(&dev->list);
usbi_mutex_unlock(&ctx->usb_devs_lock);
}
/* Perform some final sanity checks on a newly discovered device. If this
@ -603,7 +608,7 @@ int usbi_sanitize_device(struct libusb_device *dev)
return 0;
}
/* Examine libusbx's internal list of known devices, looking for one with
/* Examine libusb's internal list of known devices, looking for one with
* a specific session ID. Returns the matching device if it was found, and
* NULL otherwise. */
struct libusb_device *usbi_get_device_by_session_id(struct libusb_context *ctx,
@ -615,7 +620,7 @@ struct libusb_device *usbi_get_device_by_session_id(struct libusb_context *ctx,
usbi_mutex_lock(&ctx->usb_devs_lock);
list_for_each_entry(dev, &ctx->usb_devs, list, struct libusb_device)
if (dev->session_data == session_id) {
ret = dev;
ret = libusb_ref_device(dev);
break;
}
usbi_mutex_unlock(&ctx->usb_devs_lock);
@ -758,7 +763,7 @@ uint8_t API_EXPORTED libusb_get_port_number(libusb_device *dev)
/** \ingroup dev
* Get the list of all port numbers from root for the specified device
*
* Since version 1.0.16, \ref LIBUSBX_API_VERSION >= 0x01000102
* Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
* \param dev a device
* \param port_numbers the array that should contain the port numbers
* \param port_numbers_len the maximum length of the array. As per the USB 3.0
@ -770,22 +775,22 @@ int API_EXPORTED libusb_get_port_numbers(libusb_device *dev,
uint8_t* port_numbers, int port_numbers_len)
{
int i = port_numbers_len;
struct libusb_context *ctx = DEVICE_CTX(dev);
while(dev) {
// HCDs can be listed as devices and would have port #0
// TODO: see how the other backends want to implement HCDs as parents
if (dev->port_number == 0)
break;
i--;
if (i < 0) {
usbi_warn(DEVICE_CTX(dev),
"port numbers array too small");
if (port_numbers_len <= 0)
return LIBUSB_ERROR_INVALID_PARAM;
// HCDs can be listed as devices with port #0
while((dev) && (dev->port_number != 0)) {
if (--i < 0) {
usbi_warn(ctx, "port numbers array is too small");
return LIBUSB_ERROR_OVERFLOW;
}
port_numbers[i] = dev->port_number;
dev = dev->parent_dev;
}
memmove(port_numbers, &port_numbers[i], port_numbers_len - i);
if (i < port_numbers_len)
memmove(port_numbers, &port_numbers[i], port_numbers_len - i);
return port_numbers_len - i;
}
@ -806,7 +811,7 @@ int API_EXPORTED libusb_get_port_path(libusb_context *ctx, libusb_device *dev,
* \returns the device parent or NULL if not available
* You should issue a \ref libusb_get_device_list() before calling this
* function and make sure that you only access the parent before issuing
* \ref libusb_free_device_list(). The reason is that libusbx currently does
* \ref libusb_free_device_list(). The reason is that libusb currently does
* not maintain a permanent list of device instances, and therefore can
* only guarantee that parents are fully instantiated within a
* libusb_get_device_list() - libusb_free_device_list() block.
@ -894,10 +899,14 @@ int API_EXPORTED libusb_get_max_packet_size(libusb_device *dev,
}
ep = find_endpoint(config, endpoint);
if (!ep)
return LIBUSB_ERROR_NOT_FOUND;
if (!ep) {
r = LIBUSB_ERROR_NOT_FOUND;
goto out;
}
r = ep->wMaxPacketSize;
out:
libusb_free_config_descriptor(config);
return r;
}
@ -945,17 +954,21 @@ int API_EXPORTED libusb_get_max_iso_packet_size(libusb_device *dev,
}
ep = find_endpoint(config, endpoint);
if (!ep)
return LIBUSB_ERROR_NOT_FOUND;
if (!ep) {
r = LIBUSB_ERROR_NOT_FOUND;
goto out;
}
val = ep->wMaxPacketSize;
ep_type = (enum libusb_transfer_type) (ep->bmAttributes & 0x3);
libusb_free_config_descriptor(config);
r = val & 0x07ff;
if (ep_type == LIBUSB_TRANSFER_TYPE_ISOCHRONOUS
|| ep_type == LIBUSB_TRANSFER_TYPE_INTERRUPT)
r *= (1 + ((val >> 11) & 3));
out:
libusb_free_config_descriptor(config);
return r;
}
@ -1115,7 +1128,7 @@ int API_EXPORTED libusb_open(libusb_device *dev,
/* At this point, we want to interrupt any existing event handlers so
* that they realise the addition of the new device's poll fd. One
* example when this is desirable is if the user is running a separate
* dedicated libusbx events handling thread, which is running with a long
* dedicated libusb events handling thread, which is running with a long
* or infinite timeout. We want to interrupt that iteration of the loop,
* so that it picks up the new fd, and then continues. */
usbi_fd_notification(ctx);
@ -1126,7 +1139,7 @@ int API_EXPORTED libusb_open(libusb_device *dev,
/** \ingroup dev
* Convenience function for finding a device with a particular
* <tt>idVendor</tt>/<tt>idProduct</tt> combination. This function is intended
* for those scenarios where you are using libusbx to knock up a quick test
* for those scenarios where you are using libusb to knock up a quick test
* application - it allows you to avoid calling libusb_get_device_list() and
* worrying about traversing/freeing the list.
*
@ -1420,7 +1433,7 @@ int API_EXPORTED libusb_set_configuration(libusb_device_handle *dev,
* you wish to use before you can perform I/O on any of its endpoints.
*
* It is legal to attempt to claim an already-claimed interface, in which
* case libusbx just returns 0 without doing anything.
* case libusb just returns 0 without doing anything.
*
* If auto_detach_kernel_driver is set to 1 for <tt>dev</tt>, the kernel driver
* will be detached if necessary, on failure the detach error is returned.
@ -1610,9 +1623,72 @@ int API_EXPORTED libusb_reset_device(libusb_device_handle *dev)
return usbi_backend->reset_device(dev);
}
/** \ingroup asyncio
* Allocate up to num_streams usb bulk streams on the specified endpoints. This
* function takes an array of endpoints rather then a single endpoint because
* some protocols require that endpoints are setup with similar stream ids.
* All endpoints passed in must belong to the same interface.
*
* Note this function may return less streams then requested. Also note that the
* same number of streams are allocated for each endpoint in the endpoint array.
*
* Stream id 0 is reserved, and should not be used to communicate with devices.
* If libusb_alloc_streams() returns with a value of N, you may use stream ids
* 1 to N.
*
* Since version 1.0.19, \ref LIBUSB_API_VERSION >= 0x01000103
*
* \param dev a device handle
* \param num_streams number of streams to try to allocate
* \param endpoints array of endpoints to allocate streams on
* \param num_endpoints length of the endpoints array
* \returns number of streams allocated, or a LIBUSB_ERROR code on failure
*/
int API_EXPORTED libusb_alloc_streams(libusb_device_handle *dev,
uint32_t num_streams, unsigned char *endpoints, int num_endpoints)
{
usbi_dbg("streams %u eps %d", (unsigned) num_streams, num_endpoints);
if (!dev->dev->attached)
return LIBUSB_ERROR_NO_DEVICE;
if (usbi_backend->alloc_streams)
return usbi_backend->alloc_streams(dev, num_streams, endpoints,
num_endpoints);
else
return LIBUSB_ERROR_NOT_SUPPORTED;
}
/** \ingroup asyncio
* Free usb bulk streams allocated with libusb_alloc_streams().
*
* Note streams are automatically free-ed when releasing an interface.
*
* Since version 1.0.19, \ref LIBUSB_API_VERSION >= 0x01000103
*
* \param dev a device handle
* \param endpoints array of endpoints to free streams on
* \param num_endpoints length of the endpoints array
* \returns LIBUSB_SUCCESS, or a LIBUSB_ERROR code on failure
*/
int API_EXPORTED libusb_free_streams(libusb_device_handle *dev,
unsigned char *endpoints, int num_endpoints)
{
usbi_dbg("eps %d", num_endpoints);
if (!dev->dev->attached)
return LIBUSB_ERROR_NO_DEVICE;
if (usbi_backend->free_streams)
return usbi_backend->free_streams(dev, endpoints,
num_endpoints);
else
return LIBUSB_ERROR_NOT_SUPPORTED;
}
/** \ingroup dev
* Determine if a kernel driver is active on an interface. If a kernel driver
* is active, you cannot claim the interface, and libusbx will be unable to
* is active, you cannot claim the interface, and libusb will be unable to
* perform I/O.
*
* This functionality is not available on Windows.
@ -1647,7 +1723,7 @@ int API_EXPORTED libusb_kernel_driver_active(libusb_device_handle *dev,
*
* This functionality is not available on Darwin or Windows.
*
* Note that libusbx itself also talks to the device through a special kernel
* Note that libusb itself also talks to the device through a special kernel
* driver, if this driver is already attached to the device, this call will
* not detach it and return LIBUSB_ERROR_NOT_FOUND.
*
@ -1711,15 +1787,15 @@ int API_EXPORTED libusb_attach_kernel_driver(libusb_device_handle *dev,
}
/** \ingroup dev
* Enable/disable libusbx's automatic kernel driver detachment. When this is
* enabled libusbx will automatically detach the kernel driver on an interface
* Enable/disable libusb's automatic kernel driver detachment. When this is
* enabled libusb will automatically detach the kernel driver on an interface
* when claiming the interface, and attach it when releasing the interface.
*
* Automatic kernel driver detachment is disabled on newly opened device
* handles by default.
*
* On platforms which do not have LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER
* this function will return LIBUSB_ERROR_NOT_SUPPORTED, and libusbx will
* this function will return LIBUSB_ERROR_NOT_SUPPORTED, and libusb will
* continue as if this function was never called.
*
* \param dev a device handle
@ -1749,19 +1825,19 @@ int API_EXPORTED libusb_set_auto_detach_kernel_driver(
* printed. If you choose to increase the message verbosity level, ensure
* that your application does not close the stdout/stderr file descriptors.
*
* You are advised to use level LIBUSB_LOG_LEVEL_WARNING. libusbx is conservative
* You are advised to use level LIBUSB_LOG_LEVEL_WARNING. libusb is conservative
* with its message logging and most of the time, will only log messages that
* explain error conditions and other oddities. This will help you debug
* your software.
*
* If the LIBUSB_DEBUG environment variable was set when libusbx was
* If the LIBUSB_DEBUG environment variable was set when libusb was
* initialized, this function does nothing: the message verbosity is fixed
* to the value in the environment variable.
*
* If libusbx was compiled without any message logging, this function does
* If libusb was compiled without any message logging, this function does
* nothing: you'll never get any messages.
*
* If libusbx was compiled with verbose debug message logging, this function
* If libusb was compiled with verbose debug message logging, this function
* does nothing: you'll always get messages from all levels.
*
* \param ctx the context to operate on, or NULL for the default context
@ -1776,7 +1852,7 @@ void API_EXPORTED libusb_set_debug(libusb_context *ctx, int level)
/** \ingroup lib
* Initialize libusb. This function must be called before calling any other
* libusbx function.
* libusb function.
*
* If you do not provide an output location for a context pointer, a default
* context will be created. If there was already a default context, it will
@ -1831,7 +1907,7 @@ int API_EXPORTED libusb_init(libusb_context **context)
usbi_dbg("created default context");
}
usbi_dbg("libusbx v%d.%d.%d.%d", libusb_version_internal.major, libusb_version_internal.minor,
usbi_dbg("libusb v%d.%d.%d.%d", libusb_version_internal.major, libusb_version_internal.minor,
libusb_version_internal.micro, libusb_version_internal.nano);
usbi_mutex_init(&ctx->usb_devs_lock, NULL);
@ -1873,10 +1949,6 @@ err_free_ctx:
if (ctx == usbi_default_context)
usbi_default_context = NULL;
usbi_mutex_destroy(&ctx->open_devs_lock);
usbi_mutex_destroy(&ctx->usb_devs_lock);
usbi_mutex_destroy(&ctx->hotplug_cbs_lock);
usbi_mutex_static_lock(&active_contexts_lock);
list_del (&ctx->list);
usbi_mutex_static_unlock(&active_contexts_lock);
@ -1888,6 +1960,10 @@ err_free_ctx:
}
usbi_mutex_unlock(&ctx->usb_devs_lock);
usbi_mutex_destroy(&ctx->open_devs_lock);
usbi_mutex_destroy(&ctx->usb_devs_lock);
usbi_mutex_destroy(&ctx->hotplug_cbs_lock);
free(ctx);
err_unlock:
usbi_mutex_static_unlock(&default_context_lock);
@ -1902,6 +1978,7 @@ err_unlock:
void API_EXPORTED libusb_exit(struct libusb_context *ctx)
{
struct libusb_device *dev, *next;
struct timeval tv = { 0, 0 };
usbi_dbg("");
USBI_GET_CONTEXT(ctx);
@ -1926,6 +2003,19 @@ void API_EXPORTED libusb_exit(struct libusb_context *ctx)
if (libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG)) {
usbi_hotplug_deregister_all(ctx);
/*
* Ensure any pending unplug events are read from the hotplug
* pipe. The usb_device-s hold in the events are no longer part
* of usb_devs, but the events still hold a reference!
*
* Note we don't do this if the application has left devices
* open (which implies a buggy app) to avoid packet completion
* handlers running when the app does not expect them to run.
*/
if (list_empty(&ctx->open_devs))
libusb_handle_events_timeout(ctx, &tv);
usbi_mutex_lock(&ctx->usb_devs_lock);
list_for_each_entry_safe(dev, next, &ctx->usb_devs, list, struct libusb_device) {
list_del(&dev->list);
@ -2026,10 +2116,42 @@ int usbi_gettimeofday(struct timeval *tp, void *tzp)
}
#endif
static void usbi_log_str(struct libusb_context *ctx, const char * str)
static void usbi_log_str(struct libusb_context *ctx,
enum libusb_log_level level, const char * str)
{
UNUSED(ctx);
#if defined(USE_SYSTEM_LOGGING_FACILITY)
#if defined(OS_WINDOWS) || defined(OS_WINCE)
/* Windows CE only supports the Unicode version of OutputDebugString. */
WCHAR wbuf[USBI_MAX_LOG_LEN];
MultiByteToWideChar(CP_UTF8, 0, str, -1, wbuf, sizeof(wbuf));
OutputDebugStringW(wbuf);
#elif defined(__ANDROID__)
int priority = ANDROID_LOG_UNKNOWN;
switch (level) {
case LIBUSB_LOG_LEVEL_INFO: priority = ANDROID_LOG_INFO; break;
case LIBUSB_LOG_LEVEL_WARNING: priority = ANDROID_LOG_WARN; break;
case LIBUSB_LOG_LEVEL_ERROR: priority = ANDROID_LOG_ERROR; break;
case LIBUSB_LOG_LEVEL_DEBUG: priority = ANDROID_LOG_DEBUG; break;
}
__android_log_write(priority, "libusb", str);
#elif defined(HAVE_SYSLOG_FUNC)
int syslog_level = LOG_INFO;
switch (level) {
case LIBUSB_LOG_LEVEL_INFO: syslog_level = LOG_INFO; break;
case LIBUSB_LOG_LEVEL_WARNING: syslog_level = LOG_WARNING; break;
case LIBUSB_LOG_LEVEL_ERROR: syslog_level = LOG_ERR; break;
case LIBUSB_LOG_LEVEL_DEBUG: syslog_level = LOG_DEBUG; break;
}
syslog(syslog_level, "%s", str);
#else /* All of gcc, Clang, XCode seem to use #warning */
#warning System logging is not supported on this platform. Logging to stderr will be used instead.
fputs(str, stderr);
#endif
#else
fputs(str, stderr);
#endif /* USE_SYSTEM_LOGGING_FACILITY */
UNUSED(ctx);
UNUSED(level);
}
void usbi_log_v(struct libusb_context *ctx, enum libusb_log_level level,
@ -2045,47 +2167,32 @@ void usbi_log_v(struct libusb_context *ctx, enum libusb_log_level level,
global_debug = 1;
UNUSED(ctx);
#else
int ctx_level = 0;
USBI_GET_CONTEXT(ctx);
if (ctx == NULL)
if (ctx) {
ctx_level = ctx->debug;
} else {
char *dbg = getenv("LIBUSB_DEBUG");
if (dbg)
ctx_level = atoi(dbg);
}
global_debug = (ctx_level == LIBUSB_LOG_LEVEL_DEBUG);
if (!ctx_level)
return;
global_debug = (ctx->debug == LIBUSB_LOG_LEVEL_DEBUG);
if (!ctx->debug)
if (level == LIBUSB_LOG_LEVEL_WARNING && ctx_level < LIBUSB_LOG_LEVEL_WARNING)
return;
if (level == LIBUSB_LOG_LEVEL_WARNING && ctx->debug < LIBUSB_LOG_LEVEL_WARNING)
if (level == LIBUSB_LOG_LEVEL_INFO && ctx_level < LIBUSB_LOG_LEVEL_INFO)
return;
if (level == LIBUSB_LOG_LEVEL_INFO && ctx->debug < LIBUSB_LOG_LEVEL_INFO)
return;
if (level == LIBUSB_LOG_LEVEL_DEBUG && ctx->debug < LIBUSB_LOG_LEVEL_DEBUG)
if (level == LIBUSB_LOG_LEVEL_DEBUG && ctx_level < LIBUSB_LOG_LEVEL_DEBUG)
return;
#endif
#ifdef __ANDROID__
int prio;
switch (level) {
case LOG_LEVEL_INFO:
prio = ANDROID_LOG_INFO;
break;
case LOG_LEVEL_WARNING:
prio = ANDROID_LOG_WARN;
break;
case LOG_LEVEL_ERROR:
prio = ANDROID_LOG_ERROR;
break;
case LOG_LEVEL_DEBUG:
prio = ANDROID_LOG_DEBUG;
break;
default:
prio = ANDROID_LOG_UNKNOWN;
break;
}
__android_log_vprint(prio, "LibUsb", format, args);
#else
usbi_gettimeofday(&now, NULL);
if ((global_debug) && (!has_debug_header_been_displayed)) {
has_debug_header_been_displayed = 1;
usbi_log_str(ctx, "[timestamp] [threadID] facility level [function call] <message>\n");
usbi_log_str(ctx, "--------------------------------------------------------------------------------\n");
usbi_log_str(ctx, LIBUSB_LOG_LEVEL_DEBUG, "[timestamp] [threadID] facility level [function call] <message>\n");
usbi_log_str(ctx, LIBUSB_LOG_LEVEL_DEBUG, "--------------------------------------------------------------------------------\n");
}
if (now.tv_usec < timestamp_origin.tv_usec) {
now.tv_sec--;
@ -2108,7 +2215,7 @@ void usbi_log_v(struct libusb_context *ctx, enum libusb_log_level level,
prefix = "debug";
break;
case LIBUSB_LOG_LEVEL_NONE:
break;
return;
default:
prefix = "unknown";
break;
@ -2116,11 +2223,11 @@ void usbi_log_v(struct libusb_context *ctx, enum libusb_log_level level,
if (global_debug) {
header_len = snprintf(buf, sizeof(buf),
"[%2d.%06d] [%08x] libusbx: %s [%s] ",
"[%2d.%06d] [%08x] libusb: %s [%s] ",
(int)now.tv_sec, (int)now.tv_usec, usbi_get_tid(), prefix, function);
} else {
header_len = snprintf(buf, sizeof(buf),
"libusbx: %s [%s] ", prefix, function);
"libusb: %s [%s] ", prefix, function);
}
if (header_len < 0 || header_len >= sizeof(buf)) {
@ -2143,8 +2250,7 @@ void usbi_log_v(struct libusb_context *ctx, enum libusb_log_level level,
}
strcpy(buf + header_len + text_len, USBI_LOG_LINE_END);
usbi_log_str(ctx, buf);
#endif
usbi_log_str(ctx, level, buf);
}
void usbi_log(struct libusb_context *ctx, enum libusb_log_level level,
@ -2158,7 +2264,7 @@ void usbi_log(struct libusb_context *ctx, enum libusb_log_level level,
}
/** \ingroup misc
* Returns a constant NULL-terminated string with the ASCII name of a libusbx
* Returns a constant NULL-terminated string with the ASCII name of a libusb
* error or transfer status code. The caller must not free() the returned
* string.
*

View File

@ -1,6 +1,6 @@
/* -*- Mode: C; indent-tabs-mode:t ; c-basic-offset:8 -*- */
/*
* USB descriptor handling functions for libusbx
* USB descriptor handling functions for libusb
* Copyright © 2007 Daniel Drake <dsd@gentoo.org>
* Copyright © 2001 Johannes Erdfelt <johannes@erdfelt.com>
*
@ -541,7 +541,7 @@ int usbi_device_cache_descriptor(libusb_device *dev)
*
* This is a non-blocking function; the device descriptor is cached in memory.
*
* Note since libusbx-1.0.16, \ref LIBUSBX_API_VERSION >= 0x01000102, this
* Note since libusb-1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102, this
* function always succeeds.
*
* \param dev the device
@ -660,7 +660,7 @@ int API_EXPORTED libusb_get_config_descriptor(libusb_device *dev,
/* iterate through all configurations, returning the index of the configuration
* matching a specific bConfigurationValue in the idx output parameter, or -1
* if the config was not found.
* returns 0 or a LIBUSB_ERROR code
* returns 0 on success or a LIBUSB_ERROR code
*/
int usbi_get_config_index_by_value(struct libusb_device *dev,
uint8_t bConfigurationValue, int *idx)
@ -673,8 +673,10 @@ int usbi_get_config_index_by_value(struct libusb_device *dev,
int host_endian;
int r = usbi_backend->get_config_descriptor(dev, i, tmp, sizeof(tmp),
&host_endian);
if (r < 0)
if (r < 0) {
*idx = -1;
return r;
}
if (tmp[5] == bConfigurationValue) {
*idx = i;
return 0;

View File

@ -1,6 +1,6 @@
/* -*- Mode: C; indent-tabs-mode:t ; c-basic-offset:8 -*- */
/*
* Hotplug functions for libusbx
* Hotplug functions for libusb
* Copyright © 2012-2013 Nathan Hjelm <hjelmn@mac.com>
* Copyright © 2012-2013 Peter Stuge <peter@stuge.se>
*
@ -45,7 +45,7 @@
*
* \section intro Introduction
*
* Version 1.0.16, \ref LIBUSBX_API_VERSION >= 0x01000102, has added support
* Version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102, has added support
* for hotplug events on <b>some</b> platforms (you should test if your platform
* supports hotplug notification by calling \ref libusb_has_capability() with
* parameter \ref LIBUSB_CAP_HAS_HOTPLUG).
@ -59,7 +59,11 @@
*
* A callback function must return an int (0 or 1) indicating whether the callback is
* expecting additional events. Returning 0 will rearm the callback and 1 will cause
* the callback to be deregistered.
* the callback to be deregistered. Note that when callbacks are called from
* libusb_hotplug_register_callback() because of the \ref LIBUSB_HOTPLUG_ENUMERATE
* flag, the callback return value is ignored, iow you cannot cause a callback
* to be deregistered by returning 1 when it is called from
* libusb_hotplug_register_callback().
*
* Callbacks for a particular context are automatically deregistered by libusb_exit().
*
@ -76,12 +80,16 @@
* are invalid and will remain so even if the device comes back.
*
* When handling a LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED event it is considered
* safe to call any libusbx function that takes a libusb_device. On the other hand,
* safe to call any libusb function that takes a libusb_device. On the other hand,
* when handling a LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT event the only safe function
* is libusb_get_device_descriptor().
*
* The following code provides an example of the usage of the hotplug interface:
\code
#include <stdio.h>
#include <stdlib.h>
#include <libusb.h>
static int count = 0;
int hotplug_callback(struct libusb_context *ctx, struct libusb_device *dev,
@ -127,10 +135,11 @@ int main (void) {
}
while (count < 2) {
libusb_handle_events_completed(NULL, NULL);
usleep(10000);
}
libusb_hotplug_deregister_callback(handle);
libusb_hotplug_deregister_callback(NULL, handle);
libusb_exit(NULL);
return 0;
@ -167,8 +176,7 @@ static int usbi_hotplug_match_cb (struct libusb_context *ctx,
return 0;
}
return hotplug_cb->cb (ctx == usbi_default_context ? NULL : ctx,
dev, event, hotplug_cb->user_data);
return hotplug_cb->cb (ctx, dev, event, hotplug_cb->user_data);
}
void usbi_hotplug_match(struct libusb_context *ctx, struct libusb_device *dev,
@ -192,18 +200,7 @@ void usbi_hotplug_match(struct libusb_context *ctx, struct libusb_device *dev,
usbi_mutex_unlock(&ctx->hotplug_cbs_lock);
/* loop through and disconnect all open handles for this device */
if (LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT == event) {
struct libusb_device_handle *handle;
usbi_mutex_lock(&ctx->open_devs_lock);
list_for_each_entry(handle, &ctx->open_devs, list, struct libusb_device_handle) {
if (dev == handle->dev) {
usbi_handle_disconnect (handle);
}
}
usbi_mutex_unlock(&ctx->open_devs_lock);
}
/* the backend is expected to call the callback for each active transfer */
}
int API_EXPORTED libusb_hotplug_register_callback(libusb_context *ctx,
@ -253,19 +250,29 @@ int API_EXPORTED libusb_hotplug_register_callback(libusb_context *ctx,
list_add(&new_callback->list, &ctx->hotplug_cbs);
usbi_mutex_unlock(&ctx->hotplug_cbs_lock);
if (flags & LIBUSB_HOTPLUG_ENUMERATE) {
struct libusb_device *dev;
int i, len;
struct libusb_device **devs;
usbi_mutex_lock(&ctx->usb_devs_lock);
list_for_each_entry(dev, &ctx->usb_devs, list, struct libusb_device) {
(void) usbi_hotplug_match_cb (ctx, dev, LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, new_callback);
len = (int) libusb_get_device_list(ctx, &devs);
if (len < 0) {
libusb_hotplug_deregister_callback(ctx,
new_callback->handle);
return len;
}
usbi_mutex_unlock(&ctx->usb_devs_lock);
for (i = 0; i < len; i++) {
usbi_hotplug_match_cb(ctx, devs[i],
LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED,
new_callback);
}
libusb_free_device_list(devs, 1);
}
usbi_mutex_unlock(&ctx->hotplug_cbs_lock);
if (handle) {
*handle = new_callback->handle;

View File

@ -1,6 +1,6 @@
/* -*- Mode: C; indent-tabs-mode:t ; c-basic-offset:8 -*- */
/*
* Hotplug support for libusbx
* Hotplug support for libusb
* Copyright © 2012-2013 Nathan Hjelm <hjelmn@mac.com>
* Copyright © 2012-2013 Peter Stuge <peter@stuge.se>
*

View File

@ -1,6 +1,6 @@
/* -*- Mode: C; indent-tabs-mode:t ; c-basic-offset:8 -*- */
/*
* I/O functions for libusbx
* I/O functions for libusb
* Copyright © 2007-2009 Daniel Drake <dsd@gentoo.org>
* Copyright © 2001 Johannes Erdfelt <johannes@erdfelt.com>
*
@ -43,10 +43,10 @@
*
* \section intro Introduction
*
* If you're using libusbx in your application, you're probably wanting to
* If you're using libusb in your application, you're probably wanting to
* perform I/O with devices - you want to perform USB data transfers.
*
* libusbx offers two separate interfaces for device I/O. This page aims to
* libusb offers two separate interfaces for device I/O. This page aims to
* introduce the two in order to help you decide which one is more suitable
* for your application. You can also choose to use both interfaces in your
* application by considering each transfer on a case-by-case basis.
@ -76,7 +76,7 @@
* Data will arrive when the button is pressed by the user, which is
* potentially hours later.
*
* libusbx offers both a synchronous and an asynchronous interface to performing
* libusb offers both a synchronous and an asynchronous interface to performing
* USB transfers. The main difference is that the synchronous interface
* combines both steps indicated above into a single function call, whereas
* the asynchronous interface separates them.
@ -131,9 +131,9 @@ if (r == 0 && actual_length == sizeof(data)) {
* above.
*
* Instead of providing which functions that block until the I/O has complete,
* libusbx's asynchronous interface presents non-blocking functions which
* libusb's asynchronous interface presents non-blocking functions which
* begin a transfer and then return immediately. Your application passes a
* callback function pointer to this non-blocking function, which libusbx will
* callback function pointer to this non-blocking function, which libusb will
* call with the results of the transaction when it has completed.
*
* Transfers which have been submitted through the non-blocking functions
@ -144,12 +144,12 @@ if (r == 0 && actual_length == sizeof(data)) {
* to use threads.
*
* This added flexibility does come with some complications though:
* - In the interest of being a lightweight library, libusbx does not create
* - In the interest of being a lightweight library, libusb does not create
* threads and can only operate when your application is calling into it. Your
* application must call into libusbx from it's main loop when events are ready
* to be handled, or you must use some other scheme to allow libusbx to
* application must call into libusb from it's main loop when events are ready
* to be handled, or you must use some other scheme to allow libusb to
* undertake whatever work needs to be done.
* - libusbx also needs to be called into at certain fixed points in time in
* - libusb also needs to be called into at certain fixed points in time in
* order to accurately handle transfer timeouts.
* - Memory handling becomes more complex. You cannot use stack memory unless
* the function with that stack is guaranteed not to return until the transfer
@ -159,7 +159,7 @@ if (r == 0 && actual_length == sizeof(data)) {
* results are handled. This becomes particularly obvious when you want to
* submit a second transfer based on the results of an earlier transfer.
*
* Internally, libusbx's synchronous interface is expressed in terms of function
* Internally, libusb's synchronous interface is expressed in terms of function
* calls to the asynchronous interface.
*
* For details on how to use the asynchronous API, see the
@ -176,25 +176,25 @@ if (r == 0 && actual_length == sizeof(data)) {
* constraints on packet size defined by endpoint descriptors. The host must
* not send data payloads larger than the endpoint's maximum packet size.
*
* libusbx and the underlying OS abstract out the packet concept, allowing you
* libusb and the underlying OS abstract out the packet concept, allowing you
* to request transfers of any size. Internally, the request will be divided
* up into correctly-sized packets. You do not have to be concerned with
* packet sizes, but there is one exception when considering overflows.
*
* \section overflow Bulk/interrupt transfer overflows
*
* When requesting data on a bulk endpoint, libusbx requires you to supply a
* buffer and the maximum number of bytes of data that libusbx can put in that
* When requesting data on a bulk endpoint, libusb requires you to supply a
* buffer and the maximum number of bytes of data that libusb can put in that
* buffer. However, the size of the buffer is not communicated to the device -
* the device is just asked to send any amount of data.
*
* There is no problem if the device sends an amount of data that is less than
* or equal to the buffer size. libusbx reports this condition to you through
* or equal to the buffer size. libusb reports this condition to you through
* the \ref libusb_transfer::actual_length "libusb_transfer.actual_length"
* field.
*
* Problems may occur if the device attempts to send more data than can fit in
* the buffer. libusbx reports LIBUSB_TRANSFER_OVERFLOW for this condition but
* the buffer. libusb reports LIBUSB_TRANSFER_OVERFLOW for this condition but
* other behaviour is largely undefined: actual_length may or may not be
* accurate, the chunk of data that can fit in the buffer (before overflow)
* may or may not have been transferred.
@ -212,7 +212,7 @@ if (r == 0 && actual_length == sizeof(data)) {
/**
* @defgroup asyncio Asynchronous device I/O
*
* This page details libusbx's asynchronous (non-blocking) API for USB device
* This page details libusb's asynchronous (non-blocking) API for USB device
* I/O. This interface is very powerful but is also quite complex - you will
* need to read this page carefully to understand the necessary considerations
* and issues surrounding use of this interface. Simplistic applications
@ -227,7 +227,7 @@ if (r == 0 && actual_length == sizeof(data)) {
*
* \section asyncabstraction Transfer abstraction
*
* For the asynchronous I/O, libusbx implements the concept of a generic
* For the asynchronous I/O, libusb implements the concept of a generic
* transfer entity for all types of I/O (control, bulk, interrupt,
* isochronous). The generic transfer object must be treated slightly
* differently depending on which type of I/O you are performing with it.
@ -240,7 +240,7 @@ if (r == 0 && actual_length == sizeof(data)) {
* -# <b>Allocation</b>: allocate a libusb_transfer
* -# <b>Filling</b>: populate the libusb_transfer instance with information
* about the transfer you wish to perform
* -# <b>Submission</b>: ask libusbx to submit the transfer
* -# <b>Submission</b>: ask libusb to submit the transfer
* -# <b>Completion handling</b>: examine transfer results in the
* libusb_transfer structure
* -# <b>Deallocation</b>: clean up resources
@ -287,7 +287,7 @@ if (r == 0 && actual_length == sizeof(data)) {
*
* The user-specified callback is passed a pointer to the libusb_transfer
* structure which was used to setup and submit the transfer. At completion
* time, libusbx has populated this structure with results of the transfer:
* time, libusb has populated this structure with results of the transfer:
* success or failure reason, number of bytes of data transferred, etc. See
* the libusb_transfer structure documentation for more information.
*
@ -326,7 +326,7 @@ if (r == 0 && actual_length == sizeof(data)) {
* has completed will result in undefined behaviour.
*
* When a transfer is cancelled, some of the data may have been transferred.
* libusbx will communicate this to you in the transfer callback. Do not assume
* libusb will communicate this to you in the transfer callback. Do not assume
* that no data was transferred.
*
* \section bulk_overflows Overflows on device-to-host bulk/interrupt endpoints
@ -468,7 +468,7 @@ if (r == 0 && actual_length == sizeof(data)) {
*
* In most circumstances, it is not safe to use stack memory for transfer
* buffers. This is because the function that fired off the asynchronous
* transfer may return before libusbx has finished using the buffer, and when
* transfer may return before libusb has finished using the buffer, and when
* the function returns it's stack gets destroyed. This is true for both
* host-to-device and device-to-host transfers.
*
@ -488,43 +488,43 @@ if (r == 0 && actual_length == sizeof(data)) {
* \ref libusb_transfer_status::LIBUSB_TRANSFER_ERROR "LIBUSB_TRANSFER_ERROR"
* (they would normally be regarded as COMPLETED)
* - \ref libusb_transfer_flags::LIBUSB_TRANSFER_FREE_BUFFER
* "LIBUSB_TRANSFER_FREE_BUFFER" allows you to ask libusbx to free the transfer
* "LIBUSB_TRANSFER_FREE_BUFFER" allows you to ask libusb to free the transfer
* buffer when freeing the transfer.
* - \ref libusb_transfer_flags::LIBUSB_TRANSFER_FREE_TRANSFER
* "LIBUSB_TRANSFER_FREE_TRANSFER" causes libusbx to automatically free the
* "LIBUSB_TRANSFER_FREE_TRANSFER" causes libusb to automatically free the
* transfer after the transfer callback returns.
*
* \section asyncevent Event handling
*
* An asynchronous model requires that libusbx perform work at various
* An asynchronous model requires that libusb perform work at various
* points in time - namely processing the results of previously-submitted
* transfers and invoking the user-supplied callback function.
*
* This gives rise to the libusb_handle_events() function which your
* application must call into when libusbx has work do to. This gives libusbx
* application must call into when libusb has work do to. This gives libusb
* the opportunity to reap pending transfers, invoke callbacks, etc.
*
* There are 2 different approaches to dealing with libusb_handle_events:
*
* -# Repeatedly call libusb_handle_events() in blocking mode from a dedicated
* thread.
* -# Integrate libusbx with your application's main event loop. libusbx
* -# Integrate libusb with your application's main event loop. libusb
* exposes a set of file descriptors which allow you to do this.
*
* The first approach has the big advantage that it will also work on Windows
* were libusbx' poll API for select / poll integration is not available. So
* were libusb' poll API for select / poll integration is not available. So
* if you want to support Windows and use the async API, you must use this
* approach, see the \ref eventthread "Using an event handling thread" section
* below for details.
*
* If you prefer a single threaded approach with a single central event loop,
* see the \ref poll "polling and timing" section for how to integrate libusbx
* see the \ref poll "polling and timing" section for how to integrate libusb
* into your application's main event loop.
*
* \section eventthread Using an event handling thread
*
* Lets begin with stating the obvious: If you're going to use a separate
* thread for libusbx event handling, your callback functions MUST be
* thread for libusb event handling, your callback functions MUST be
* threadsafe.
*
* Other then that doing event handling from a separate thread, is mostly
@ -545,7 +545,7 @@ void *event_thread_func(void *ctx)
* libusb_handle_events() will not return.
*
* There are 2 different ways of dealing with this, depending on if your
* application uses libusbx' \ref hotplug "hotplug" support or not.
* application uses libusb' \ref hotplug "hotplug" support or not.
*
* Applications which do not use hotplug support, should not start the event
* thread until after their first call to libusb_open(), and should stop the
@ -582,7 +582,7 @@ void my_libusb_exit(void)
/**
* @defgroup poll Polling and timing
*
* This page documents libusbx's functions for polling events and timing.
* This page documents libusb's functions for polling events and timing.
* These functions are only necessary for users of the
* \ref asyncio "asynchronous API". If you are only using the simpler
* \ref syncio "synchronous API" then you do not need to ever call these
@ -590,28 +590,28 @@ void my_libusb_exit(void)
*
* The justification for the functionality described here has already been
* discussed in the \ref asyncevent "event handling" section of the
* asynchronous API documentation. In summary, libusbx does not create internal
* asynchronous API documentation. In summary, libusb does not create internal
* threads for event processing and hence relies on your application calling
* into libusbx at certain points in time so that pending events can be handled.
* into libusb at certain points in time so that pending events can be handled.
*
* Your main loop is probably already calling poll() or select() or a
* variant on a set of file descriptors for other event sources (e.g. keyboard
* button presses, mouse movements, network sockets, etc). You then add
* libusbx's file descriptors to your poll()/select() calls, and when activity
* libusb's file descriptors to your poll()/select() calls, and when activity
* is detected on such descriptors you know it is time to call
* libusb_handle_events().
*
* There is one final event handling complication. libusbx supports
* There is one final event handling complication. libusb supports
* asynchronous transfers which time out after a specified time period.
*
* On some platforms a timerfd is used, so the timeout handling is just another
* fd, on other platforms this requires that libusbx is called into at or after
* the timeout to handle it. So, in addition to considering libusbx's file
* descriptors in your main event loop, you must also consider that libusbx
* fd, on other platforms this requires that libusb is called into at or after
* the timeout to handle it. So, in addition to considering libusb's file
* descriptors in your main event loop, you must also consider that libusb
* sometimes needs to be called into at fixed points in time even when there
* is no file descriptor activity, see \ref polltime details.
*
* In order to know precisely when libusbx needs to be called into, libusbx
* In order to know precisely when libusb needs to be called into, libusb
* offers you a set of pollable file descriptors and information about when
* the next timeout expires.
*
@ -620,10 +620,10 @@ void my_libusb_exit(void)
*
* \section pollsimple The simple option
*
* If your application revolves solely around libusbx and does not need to
* If your application revolves solely around libusb and does not need to
* handle other event sources, you can have a program structure as follows:
\code
// initialize libusbx
// initialize libusb
// find and open device
// maybe fire off some initial async I/O
@ -646,15 +646,15 @@ while (user_has_not_requested_exit)
*
* In more advanced applications, you will already have a main loop which
* is monitoring other event sources: network sockets, X11 events, mouse
* movements, etc. Through exposing a set of file descriptors, libusbx is
* movements, etc. Through exposing a set of file descriptors, libusb is
* designed to cleanly integrate into such main loops.
*
* In addition to polling file descriptors for the other event sources, you
* take a set of file descriptors from libusbx and monitor those too. When you
* detect activity on libusbx's file descriptors, you call
* take a set of file descriptors from libusb and monitor those too. When you
* detect activity on libusb's file descriptors, you call
* libusb_handle_events_timeout() in non-blocking mode.
*
* What's more, libusbx may also need to handle events at specific moments in
* What's more, libusb may also need to handle events at specific moments in
* time. No file descriptor activity is generated at these times, so your
* own application needs to be continually aware of when the next one of these
* moments occurs (through calling libusb_get_next_timeout()), and then it
@ -662,25 +662,25 @@ while (user_has_not_requested_exit)
* these moments occur. This means that you need to adjust your
* poll()/select() timeout accordingly.
*
* libusbx provides you with a set of file descriptors to poll and expects you
* libusb provides you with a set of file descriptors to poll and expects you
* to poll all of them, treating them as a single entity. The meaning of each
* file descriptor in the set is an internal implementation detail,
* platform-dependent and may vary from release to release. Don't try and
* interpret the meaning of the file descriptors, just do as libusbx indicates,
* interpret the meaning of the file descriptors, just do as libusb indicates,
* polling all of them at once.
*
* In pseudo-code, you want something that looks like:
\code
// initialise libusbx
// initialise libusb
libusb_get_pollfds(ctx)
while (user has not requested application exit) {
libusb_get_next_timeout(ctx);
poll(on libusbx file descriptors plus any other event sources of interest,
using a timeout no larger than the value libusbx just suggested)
if (poll() indicated activity on libusbx file descriptors)
poll(on libusb file descriptors plus any other event sources of interest,
using a timeout no larger than the value libusb just suggested)
if (poll() indicated activity on libusb file descriptors)
libusb_handle_events_timeout(ctx, &zero_tv);
if (time has elapsed to or beyond the libusbx timeout)
if (time has elapsed to or beyond the libusb timeout)
libusb_handle_events_timeout(ctx, &zero_tv);
// handle events from other sources here
}
@ -690,7 +690,7 @@ while (user has not requested application exit) {
*
* \subsection polltime Notes on time-based events
*
* The above complication with having to track time and call into libusbx at
* The above complication with having to track time and call into libusb at
* specific moments is a bit of a headache. For maximum compatibility, you do
* need to write your main loop as above, but you may decide that you can
* restrict the supported platforms of your application and get away with
@ -702,18 +702,18 @@ while (user has not requested application exit) {
* - Linux, provided that the following version requirements are satisfied:
* - Linux v2.6.27 or newer, compiled with timerfd support
* - glibc v2.9 or newer
* - libusbx v1.0.5 or newer
* - libusb v1.0.5 or newer
*
* Under these configurations, libusb_get_next_timeout() will \em always return
* 0, so your main loop can be simplified to:
\code
// initialise libusbx
// initialise libusb
libusb_get_pollfds(ctx)
while (user has not requested application exit) {
poll(on libusbx file descriptors plus any other event sources of interest,
poll(on libusb file descriptors plus any other event sources of interest,
using any timeout that you like)
if (poll() indicated activity on libusbx file descriptors)
if (poll() indicated activity on libusb file descriptors)
libusb_handle_events_timeout(ctx, &zero_tv);
// handle events from other sources here
}
@ -723,20 +723,20 @@ while (user has not requested application exit) {
*
* Do remember that if you simplify your main loop to the above, you will
* lose compatibility with some platforms (including legacy Linux platforms,
* and <em>any future platforms supported by libusbx which may have time-based
* and <em>any future platforms supported by libusb which may have time-based
* event requirements</em>). The resultant problems will likely appear as
* strange bugs in your application.
*
* You can use the libusb_pollfds_handle_timeouts() function to do a runtime
* check to see if it is safe to ignore the time-based event complications.
* If your application has taken the shortcut of ignoring libusbx's next timeout
* If your application has taken the shortcut of ignoring libusb's next timeout
* in your main loop, then you are advised to check the return value of
* libusb_pollfds_handle_timeouts() during application startup, and to abort
* if the platform does suffer from these timing complications.
*
* \subsection fdsetchange Changes in the file descriptor set
*
* The set of file descriptors that libusbx uses as event sources may change
* The set of file descriptors that libusb uses as event sources may change
* during the life of your application. Rather than having to repeatedly
* call libusb_get_pollfds(), you can set up notification functions for when
* the file descriptor set changes using libusb_set_pollfd_notifiers().
@ -757,10 +757,10 @@ while (user has not requested application exit) {
/** \page mtasync Multi-threaded applications and asynchronous I/O
*
* libusbx is a thread-safe library, but extra considerations must be applied
* to applications which interact with libusbx from multiple threads.
* libusb is a thread-safe library, but extra considerations must be applied
* to applications which interact with libusb from multiple threads.
*
* The underlying issue that must be addressed is that all libusbx I/O
* The underlying issue that must be addressed is that all libusb I/O
* revolves around monitoring file descriptors through the poll()/select()
* system calls. This is directly exposed at the
* \ref asyncio "asynchronous interface" but it is important to note that the
@ -768,13 +768,13 @@ while (user has not requested application exit) {
* asynchonrous interface, therefore the same considerations apply.
*
* The issue is that if two or more threads are concurrently calling poll()
* or select() on libusbx's file descriptors then only one of those threads
* or select() on libusb's file descriptors then only one of those threads
* will be woken up when an event arrives. The others will be completely
* oblivious that anything has happened.
*
* Consider the following pseudo-code, which submits an asynchronous transfer
* then waits for its completion. This style is one way you could implement a
* synchronous interface on top of the asynchronous interface (and libusbx
* synchronous interface on top of the asynchronous interface (and libusb
* does something similar, albeit more advanced due to the complications
* explained on this page).
*
@ -787,7 +787,7 @@ void cb(struct libusb_transfer *transfer)
void myfunc() {
struct libusb_transfer *transfer;
unsigned char buffer[LIBUSB_CONTROL_SETUP_SIZE];
unsigned char buffer[LIBUSB_CONTROL_SETUP_SIZE] __attribute__ ((aligned (2)));
int completed = 0;
transfer = libusb_alloc_transfer(0);
@ -797,7 +797,7 @@ void myfunc() {
libusb_submit_transfer(transfer);
while (!completed) {
poll(libusbx file descriptors, 120*1000);
poll(libusb file descriptors, 120*1000);
if (poll indicates activity)
libusb_handle_events_timeout(ctx, &zero_tv);
}
@ -811,7 +811,7 @@ void myfunc() {
* The poll() loop has a long timeout to minimize CPU usage during situations
* when nothing is happening (it could reasonably be unlimited).
*
* If this is the only thread that is polling libusbx's file descriptors, there
* If this is the only thread that is polling libusb's file descriptors, there
* is no problem: there is no danger that another thread will swallow up the
* event that we are interested in. On the other hand, if there is another
* thread polling the same descriptors, there is a chance that it will receive
@ -823,13 +823,13 @@ void myfunc() {
*
* The solution here is to ensure that no two threads are ever polling the
* file descriptors at the same time. A naive implementation of this would
* impact the capabilities of the library, so libusbx offers the scheme
* impact the capabilities of the library, so libusb offers the scheme
* documented below to ensure no loss of functionality.
*
* Before we go any further, it is worth mentioning that all libusb-wrapped
* event handling procedures fully adhere to the scheme documented below.
* This includes libusb_handle_events() and its variants, and all the
* synchronous I/O functions - libusbx hides this headache from you.
* synchronous I/O functions - libusb hides this headache from you.
*
* \section Using libusb_handle_events() from multiple threads
*
@ -875,17 +875,17 @@ void myfunc() {
*
* \section eventlock The events lock
*
* The problem is when we consider the fact that libusbx exposes file
* The problem is when we consider the fact that libusb exposes file
* descriptors to allow for you to integrate asynchronous USB I/O into
* existing main loops, effectively allowing you to do some work behind
* libusbx's back. If you do take libusbx's file descriptors and pass them to
* libusb's back. If you do take libusb's file descriptors and pass them to
* poll()/select() yourself, you need to be aware of the associated issues.
*
* The first concept to be introduced is the events lock. The events lock
* is used to serialize threads that want to handle events, such that only
* one thread is handling events at any one time.
*
* You must take the events lock before polling libusbx file descriptors,
* You must take the events lock before polling libusb file descriptors,
* using libusb_lock_events(). You must release the lock as soon as you have
* aborted your poll()/select() loop, using libusb_unlock_events().
*
@ -896,7 +896,7 @@ void myfunc() {
\code
libusb_lock_events(ctx);
while (!completed) {
poll(libusbx file descriptors, 120*1000);
poll(libusb file descriptors, 120*1000);
if (poll indicates activity)
libusb_handle_events_timeout(ctx, &zero_tv);
}
@ -912,7 +912,7 @@ void myfunc() {
* status of its transfer until the code above has finished (30 seconds later)
* due to contention on the lock.
*
* To solve this, libusbx offers you a mechanism to determine when another
* To solve this, libusb offers you a mechanism to determine when another
* thread is handling events. It also offers a mechanism to block your thread
* until the event handling thread has completed an event (and this mechanism
* does not involve polling of file descriptors).
@ -938,7 +938,7 @@ if (libusb_try_lock_events(ctx) == 0) {
libusb_unlock_events(ctx);
goto retry;
}
poll(libusbx file descriptors, 120*1000);
poll(libusb file descriptors, 120*1000);
if (poll indicates activity)
libusb_handle_events_locked(ctx, 0);
}
@ -984,8 +984,8 @@ printf("completed!\n");
* should be apparent from the code shown above.
* -# libusb_try_lock_events() is a non-blocking function which attempts
* to acquire the events lock but returns a failure code if it is contended.
* -# libusb_event_handling_ok() checks that libusbx is still happy for your
* thread to be performing event handling. Sometimes, libusbx needs to
* -# libusb_event_handling_ok() checks that libusb is still happy for your
* thread to be performing event handling. Sometimes, libusb needs to
* interrupt the event handler, and this is how you can check if you have
* been interrupted. If this function returns 0, the correct behaviour is
* for you to give up the event handling lock, and then to repeat the cycle.
@ -995,12 +995,12 @@ printf("completed!\n");
* libusb_handle_events_timeout() that you can call while holding the
* events lock. libusb_handle_events_timeout() itself implements similar
* logic to the above, so be sure not to call it when you are
* "working behind libusbx's back", as is the case here.
* "working behind libusb's back", as is the case here.
* -# libusb_event_handler_active() determines if someone is currently
* holding the events lock
*
* You might be wondering why there is no function to wake up all threads
* blocked on libusb_wait_for_event(). This is because libusbx can do this
* blocked on libusb_wait_for_event(). This is because libusb can do this
* internally: it will wake up all such threads when someone calls
* libusb_unlock_events() or when a transfer completes (at the point after its
* callback has returned).
@ -1009,7 +1009,7 @@ printf("completed!\n");
*
* The above explanation should be enough to get you going, but if you're
* really thinking through the issues then you may be left with some more
* questions regarding libusbx's internals. If you're curious, read on, and if
* questions regarding libusb's internals. If you're curious, read on, and if
* not, skip to the next section to avoid confusing yourself!
*
* The immediate question that may spring to mind is: what if one thread
@ -1024,14 +1024,14 @@ printf("completed!\n");
* are all kinds of race conditions that could arise here, so it is
* important that nobody is doing event handling at this time.
*
* libusbx handles these issues internally, so application developers do not
* libusb handles these issues internally, so application developers do not
* have to stop their event handlers while opening/closing devices. Here's how
* it works, focusing on the libusb_close() situation first:
*
* -# During initialization, libusbx opens an internal pipe, and it adds the read
* -# During initialization, libusb opens an internal pipe, and it adds the read
* end of this pipe to the set of file descriptors to be polled.
* -# During libusb_close(), libusbx writes some dummy data on this control pipe.
* This immediately interrupts the event handler. libusbx also records
* -# During libusb_close(), libusb writes some dummy data on this control pipe.
* This immediately interrupts the event handler. libusb also records
* internally that it is trying to interrupt event handlers for this
* high-priority event.
* -# At this point, some of the functions described above start behaving
@ -1046,7 +1046,7 @@ printf("completed!\n");
* giving up the events lock very quickly, giving the high-priority
* libusb_close() operation a "free ride" to acquire the events lock. All
* threads that are competing to do event handling become event waiters.
* -# With the events lock held inside libusb_close(), libusbx can safely remove
* -# With the events lock held inside libusb_close(), libusb can safely remove
* a file descriptor from the poll set, in the safety of knowledge that
* nobody is polling those descriptors or trying to access the poll set.
* -# After obtaining the events lock, the close operation completes very
@ -1063,7 +1063,7 @@ printf("completed!\n");
* call to libusb_open():
*
* -# The device is opened and a file descriptor is added to the poll set.
* -# libusbx sends some dummy data on the control pipe, and records that it
* -# libusb sends some dummy data on the control pipe, and records that it
* is trying to modify the poll descriptor set.
* -# The event handler is interrupted, and the same behaviour change as for
* libusb_close() takes effect, causing all event handling threads to become
@ -1079,7 +1079,7 @@ printf("completed!\n");
*
* The above may seem a little complicated, but hopefully I have made it clear
* why such complications are necessary. Also, do not forget that this only
* applies to applications that take libusbx's file descriptors and integrate
* applies to applications that take libusb's file descriptors and integrate
* them into their own polling loops.
*
* You may decide that it is OK for your multi-threaded application to ignore
@ -1291,7 +1291,7 @@ out:
}
/** \ingroup asyncio
* Allocate a libusbx transfer with a specified number of isochronous packet
* Allocate a libusb transfer with a specified number of isochronous packet
* descriptors. The returned transfer is pre-initialized for you. When the new
* transfer is no longer needed, it should be freed with
* libusb_free_transfer().
@ -1439,6 +1439,7 @@ int API_EXPORTED libusb_submit_transfer(struct libusb_transfer *transfer)
int r;
int updated_fds;
usbi_mutex_lock(&ctx->flying_transfers_lock);
usbi_mutex_lock(&itransfer->lock);
itransfer->transferred = 0;
itransfer->flags = 0;
@ -1448,7 +1449,6 @@ int API_EXPORTED libusb_submit_transfer(struct libusb_transfer *transfer)
goto out;
}
usbi_mutex_lock(&ctx->flying_transfers_lock);
r = add_to_flying_list(itransfer);
if (r == LIBUSB_SUCCESS) {
r = usbi_backend->submit_transfer(itransfer);
@ -1456,12 +1456,14 @@ int API_EXPORTED libusb_submit_transfer(struct libusb_transfer *transfer)
if (r != LIBUSB_SUCCESS) {
list_del(&itransfer->list);
arm_timerfd_for_next_timeout(ctx);
} else {
/* keep a reference to this device */
libusb_ref_device(transfer->dev_handle->dev);
}
usbi_mutex_unlock(&ctx->flying_transfers_lock);
out:
updated_fds = (itransfer->flags & USBI_TRANSFER_UPDATED_FDS);
usbi_mutex_unlock(&itransfer->lock);
usbi_mutex_unlock(&ctx->flying_transfers_lock);
if (updated_fds)
usbi_fd_notification(ctx);
return r;
@ -1508,6 +1510,43 @@ int API_EXPORTED libusb_cancel_transfer(struct libusb_transfer *transfer)
return r;
}
/** \ingroup asyncio
* Set a transfers bulk stream id. Note users are advised to use
* libusb_fill_bulk_stream_transfer() instead of calling this function
* directly.
*
* Since version 1.0.19, \ref LIBUSB_API_VERSION >= 0x01000103
*
* \param transfer the transfer to set the stream id for
* \param stream_id the stream id to set
* \see libusb_alloc_streams()
*/
void API_EXPORTED libusb_transfer_set_stream_id(
struct libusb_transfer *transfer, uint32_t stream_id)
{
struct usbi_transfer *itransfer =
LIBUSB_TRANSFER_TO_USBI_TRANSFER(transfer);
itransfer->stream_id = stream_id;
}
/** \ingroup asyncio
* Get a transfers bulk stream id.
*
* Since version 1.0.19, \ref LIBUSB_API_VERSION >= 0x01000103
*
* \param transfer the transfer to get the stream id for
* \returns the stream id for the transfer
*/
uint32_t API_EXPORTED libusb_transfer_get_stream_id(
struct libusb_transfer *transfer)
{
struct usbi_transfer *itransfer =
LIBUSB_TRANSFER_TO_USBI_TRANSFER(transfer);
return itransfer->stream_id;
}
/* Handle completion of a transfer (completion might be an error condition).
* This will invoke the user-supplied callback function, which may end up
* freeing the transfer. Therefore you cannot use the transfer structure
@ -1522,6 +1561,7 @@ int usbi_handle_transfer_completion(struct usbi_transfer *itransfer,
struct libusb_transfer *transfer =
USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
struct libusb_context *ctx = TRANSFER_CTX(transfer);
struct libusb_device_handle *handle = transfer->dev_handle;
uint8_t flags;
int r = 0;
@ -1562,6 +1602,7 @@ int usbi_handle_transfer_completion(struct usbi_transfer *itransfer,
usbi_mutex_lock(&ctx->event_waiters_lock);
usbi_cond_broadcast(&ctx->event_waiters_cond);
usbi_mutex_unlock(&ctx->event_waiters_lock);
libusb_unref_device(handle->dev);
return 0;
}
@ -1585,11 +1626,11 @@ int usbi_handle_transfer_cancellation(struct usbi_transfer *transfer)
/** \ingroup poll
* Attempt to acquire the event handling lock. This lock is used to ensure that
* only one thread is monitoring libusbx event sources at any one time.
* only one thread is monitoring libusb event sources at any one time.
*
* You only need to use this lock if you are developing an application
* which calls poll() or select() on libusbx's file descriptors directly.
* If you stick to libusbx's event handling loop functions (e.g.
* which calls poll() or select() on libusb's file descriptors directly.
* If you stick to libusb's event handling loop functions (e.g.
* libusb_handle_events()) then you do not need to be concerned with this
* locking.
*
@ -1600,7 +1641,7 @@ int usbi_handle_transfer_cancellation(struct usbi_transfer *transfer)
* \param ctx the context to operate on, or NULL for the default context
* \returns 0 if the lock was obtained successfully
* \returns 1 if the lock was not obtained (i.e. another thread holds the lock)
* \see \ref mtasync
* \ref mtasync
*/
int API_EXPORTED libusb_try_lock_events(libusb_context *ctx)
{
@ -1629,11 +1670,11 @@ int API_EXPORTED libusb_try_lock_events(libusb_context *ctx)
/** \ingroup poll
* Acquire the event handling lock, blocking until successful acquisition if
* it is contended. This lock is used to ensure that only one thread is
* monitoring libusbx event sources at any one time.
* monitoring libusb event sources at any one time.
*
* You only need to use this lock if you are developing an application
* which calls poll() or select() on libusbx's file descriptors directly.
* If you stick to libusbx's event handling loop functions (e.g.
* which calls poll() or select() on libusb's file descriptors directly.
* If you stick to libusb's event handling loop functions (e.g.
* libusb_handle_events()) then you do not need to be concerned with this
* locking.
*
@ -1642,7 +1683,7 @@ int API_EXPORTED libusb_try_lock_events(libusb_context *ctx)
* as soon as possible.
*
* \param ctx the context to operate on, or NULL for the default context
* \see \ref mtasync
* \ref mtasync
*/
void API_EXPORTED libusb_lock_events(libusb_context *ctx)
{
@ -1657,7 +1698,7 @@ void API_EXPORTED libusb_lock_events(libusb_context *ctx)
* on libusb_wait_for_event().
*
* \param ctx the context to operate on, or NULL for the default context
* \see \ref mtasync
* \ref mtasync
*/
void API_EXPORTED libusb_unlock_events(libusb_context *ctx)
{
@ -1676,7 +1717,7 @@ void API_EXPORTED libusb_unlock_events(libusb_context *ctx)
/** \ingroup poll
* Determine if it is still OK for this thread to be doing event handling.
*
* Sometimes, libusbx needs to temporarily pause all event handlers, and this
* Sometimes, libusb needs to temporarily pause all event handlers, and this
* is the function you should use before polling file descriptors to see if
* this is the case.
*
@ -1692,7 +1733,7 @@ void API_EXPORTED libusb_unlock_events(libusb_context *ctx)
* \param ctx the context to operate on, or NULL for the default context
* \returns 1 if event handling can start or continue
* \returns 0 if this thread must give up the events lock
* \see \ref fullstory "Multi-threaded I/O: the full story"
* \ref fullstory "Multi-threaded I/O: the full story"
*/
int API_EXPORTED libusb_event_handling_ok(libusb_context *ctx)
{
@ -1720,7 +1761,7 @@ int API_EXPORTED libusb_event_handling_ok(libusb_context *ctx)
* \param ctx the context to operate on, or NULL for the default context
* \returns 1 if a thread is handling events
* \returns 0 if there are no threads currently handling events
* \see \ref mtasync
* \ref mtasync
*/
int API_EXPORTED libusb_event_handler_active(libusb_context *ctx)
{
@ -1750,14 +1791,14 @@ int API_EXPORTED libusb_event_handler_active(libusb_context *ctx)
* events, then call libusb_wait_for_event().
*
* You only need to use this lock if you are developing an application
* which calls poll() or select() on libusbx's file descriptors directly,
* which calls poll() or select() on libusb's file descriptors directly,
* <b>and</b> may potentially be handling events from 2 threads simultaenously.
* If you stick to libusbx's event handling loop functions (e.g.
* If you stick to libusb's event handling loop functions (e.g.
* libusb_handle_events()) then you do not need to be concerned with this
* locking.
*
* \param ctx the context to operate on, or NULL for the default context
* \see \ref mtasync
* \ref mtasync
*/
void API_EXPORTED libusb_lock_event_waiters(libusb_context *ctx)
{
@ -1768,7 +1809,7 @@ void API_EXPORTED libusb_lock_event_waiters(libusb_context *ctx)
/** \ingroup poll
* Release the event waiters lock.
* \param ctx the context to operate on, or NULL for the default context
* \see \ref mtasync
* \ref mtasync
*/
void API_EXPORTED libusb_unlock_event_waiters(libusb_context *ctx)
{
@ -1799,7 +1840,7 @@ void API_EXPORTED libusb_unlock_event_waiters(libusb_context *ctx)
* indicates unlimited timeout.
* \returns 0 after a transfer completes or another thread stops event handling
* \returns 1 if the timeout expired
* \see \ref mtasync
* \ref mtasync
*/
int API_EXPORTED libusb_wait_for_event(libusb_context *ctx, struct timeval *tv)
{
@ -1926,6 +1967,7 @@ static int handle_events(struct libusb_context *ctx, struct timeval *tv)
struct pollfd *fds = NULL;
int i = -1;
int timeout_ms;
int special_event;
usbi_mutex_lock(&ctx->pollfds_lock);
list_for_each_entry(ipollfd, &ctx->pollfds, list, struct usbi_pollfd)
@ -1955,6 +1997,7 @@ static int handle_events(struct libusb_context *ctx, struct timeval *tv)
if (tv->tv_usec % 1000)
timeout_ms++;
redo_poll:
usbi_dbg("poll() %d fds with timeout in %dms", nfds, timeout_ms);
r = usbi_poll(fds, nfds, timeout_ms);
usbi_dbg("poll() returned %d", r);
@ -1970,6 +2013,8 @@ static int handle_events(struct libusb_context *ctx, struct timeval *tv)
return LIBUSB_ERROR_IO;
}
special_event = 0;
/* fd[0] is always the ctrl pipe */
if (fds[0].revents) {
/* another thread wanted to interrupt event handling, and it succeeded!
@ -1993,11 +2038,12 @@ static int handle_events(struct libusb_context *ctx, struct timeval *tv)
ssize_t ret;
usbi_dbg("caught a fish on the hotplug pipe");
special_event = 1;
/* read the message from the hotplug thread */
ret = usbi_read(ctx->hotplug_pipe[0], &message, sizeof (message));
if (ret < sizeof(message)) {
usbi_err(ctx, "hotplug pipe read error %d < %d",
if (ret != sizeof(message)) {
usbi_err(ctx, "hotplug pipe read error %d != %u",
ret, sizeof(message));
r = LIBUSB_ERROR_OTHER;
goto handled;
@ -2020,6 +2066,7 @@ static int handle_events(struct libusb_context *ctx, struct timeval *tv)
/* timerfd indicates that a timeout has expired */
int ret;
usbi_dbg("timerfd triggered");
special_event = 1;
ret = handle_timerfd_trigger(ctx);
if (ret < 0) {
@ -2044,6 +2091,11 @@ static int handle_events(struct libusb_context *ctx, struct timeval *tv)
usbi_err(ctx, "backend handle_events failed with error %d", r);
handled:
if (r == 0 && special_event) {
timeout_ms = 0;
goto redo_poll;
}
free(fds);
return r;
}
@ -2078,7 +2130,7 @@ static int get_next_timeout(libusb_context *ctx, struct timeval *tv,
/** \ingroup poll
* Handle any pending events.
*
* libusbx determines "pending events" by checking if any timeouts have expired
* libusb determines "pending events" by checking if any timeouts have expired
* and by checking the set of file descriptors for activity.
*
* If a zero timeval is passed, this function will handle any already-pending
@ -2099,7 +2151,7 @@ static int get_next_timeout(libusb_context *ctx, struct timeval *tv,
* timeval struct for non-blocking mode
* \param completed pointer to completion integer to check, or NULL
* \returns 0 on success, or a LIBUSB_ERROR code on failure
* \see \ref mtasync
* \ref mtasync
*/
int API_EXPORTED libusb_handle_events_timeout_completed(libusb_context *ctx,
struct timeval *tv, int *completed)
@ -2210,7 +2262,7 @@ int API_EXPORTED libusb_handle_events(libusb_context *ctx)
* \param ctx the context to operate on, or NULL for the default context
* \param completed pointer to completion integer to check, or NULL
* \returns 0 on success, or a LIBUSB_ERROR code on failure
* \see \ref mtasync
* \ref mtasync
*/
int API_EXPORTED libusb_handle_events_completed(libusb_context *ctx,
int *completed)
@ -2227,16 +2279,16 @@ int API_EXPORTED libusb_handle_events_completed(libusb_context *ctx,
* held, see libusb_lock_events().
*
* This function is designed to be called under the situation where you have
* taken the event lock and are calling poll()/select() directly on libusbx's
* taken the event lock and are calling poll()/select() directly on libusb's
* file descriptors (as opposed to using libusb_handle_events() or similar).
* You detect events on libusbx's descriptors, so you then call this function
* You detect events on libusb's descriptors, so you then call this function
* with a zero timeout value (while still holding the event lock).
*
* \param ctx the context to operate on, or NULL for the default context
* \param tv the maximum time to block waiting for events, or zero for
* non-blocking mode
* \returns 0 on success, or a LIBUSB_ERROR code on failure
* \see \ref mtasync
* \ref mtasync
*/
int API_EXPORTED libusb_handle_events_locked(libusb_context *ctx,
struct timeval *tv)
@ -2256,19 +2308,19 @@ int API_EXPORTED libusb_handle_events_locked(libusb_context *ctx,
/** \ingroup poll
* Determines whether your application must apply special timing considerations
* when monitoring libusbx's file descriptors.
* when monitoring libusb's file descriptors.
*
* This function is only useful for applications which retrieve and poll
* libusbx's file descriptors in their own main loop (\ref pollmain).
* libusb's file descriptors in their own main loop (\ref pollmain).
*
* Ordinarily, libusbx's event handler needs to be called into at specific
* Ordinarily, libusb's event handler needs to be called into at specific
* moments in time (in addition to times when there is activity on the file
* descriptor set). The usual approach is to use libusb_get_next_timeout()
* to learn about when the next timeout occurs, and to adjust your
* poll()/select() timeout accordingly so that you can make a call into the
* library at that time.
*
* Some platforms supported by libusbx do not come with this baggage - any
* Some platforms supported by libusb do not come with this baggage - any
* events relevant to timing will be represented by activity on the file
* descriptor set, and libusb_get_next_timeout() will always return 0.
* This function allows you to detect whether you are running on such a
@ -2277,10 +2329,10 @@ int API_EXPORTED libusb_handle_events_locked(libusb_context *ctx,
* Since v1.0.5.
*
* \param ctx the context to operate on, or NULL for the default context
* \returns 0 if you must call into libusbx at times determined by
* \returns 0 if you must call into libusb at times determined by
* libusb_get_next_timeout(), or 1 if all timeout events are handled internally
* or through regular activity on the file descriptors.
* \see \ref pollmain "Polling libusbx file descriptors for event handling"
* \ref pollmain "Polling libusb file descriptors for event handling"
*/
int API_EXPORTED libusb_pollfds_handle_timeouts(libusb_context *ctx)
{
@ -2294,21 +2346,21 @@ int API_EXPORTED libusb_pollfds_handle_timeouts(libusb_context *ctx)
}
/** \ingroup poll
* Determine the next internal timeout that libusbx needs to handle. You only
* Determine the next internal timeout that libusb needs to handle. You only
* need to use this function if you are calling poll() or select() or similar
* on libusbx's file descriptors yourself - you do not need to use it if you
* on libusb's file descriptors yourself - you do not need to use it if you
* are calling libusb_handle_events() or a variant directly.
*
* You should call this function in your main loop in order to determine how
* long to wait for select() or poll() to return results. libusbx needs to be
* long to wait for select() or poll() to return results. libusb needs to be
* called into at this timeout, so you should use it as an upper bound on
* your select() or poll() call.
*
* When the timeout has expired, call into libusb_handle_events_timeout()
* (perhaps in non-blocking mode) so that libusbx can handle the timeout.
* (perhaps in non-blocking mode) so that libusb can handle the timeout.
*
* This function may return 1 (success) and an all-zero timeval. If this is
* the case, it indicates that libusbx has a timeout that has already expired
* the case, it indicates that libusb has a timeout that has already expired
* so you should call libusb_handle_events_timeout() or similar immediately.
* A return code of 0 indicates that there are no pending timeouts.
*
@ -2317,7 +2369,7 @@ int API_EXPORTED libusb_pollfds_handle_timeouts(libusb_context *ctx)
*
* \param ctx the context to operate on, or NULL for the default context
* \param tv output location for a relative time against the current
* clock in which libusbx must be called into in order to process timeout events
* clock in which libusb must be called into in order to process timeout events
* \returns 0 if there are no pending timeouts, 1 if a timeout was returned,
* or LIBUSB_ERROR_OTHER on failure
*/
@ -2384,7 +2436,7 @@ int API_EXPORTED libusb_get_next_timeout(libusb_context *ctx,
/** \ingroup poll
* Register notification functions for file descriptor additions/removals.
* These functions will be invoked for every new or removed file descriptor
* that libusbx uses as an event source.
* that libusb uses as an event source.
*
* To remove notifiers, pass NULL values for the function pointers.
*
@ -2462,7 +2514,7 @@ void usbi_remove_pollfd(struct libusb_context *ctx, int fd)
/** \ingroup poll
* Retrieve a list of file descriptors that should be polled by your main loop
* as libusbx event sources.
* as libusb event sources.
*
* The returned list is NULL-terminated and should be freed with free() when
* done. The actual list contents must not be touched.
@ -2502,7 +2554,7 @@ out:
usbi_mutex_unlock(&ctx->pollfds_lock);
return (const struct libusb_pollfd **) ret;
#else
usbi_err(ctx, "external polling of libusbx's internal descriptors "\
usbi_err(ctx, "external polling of libusb's internal descriptors "\
"is not yet supported on Windows platforms");
return NULL;
#endif

View File

@ -1,5 +1,7 @@
LIBRARY "libusb-1.0.dll"
EXPORTS
libusb_alloc_streams
libusb_alloc_streams@16 = libusb_alloc_streams
libusb_alloc_transfer
libusb_alloc_transfer@4 = libusb_alloc_transfer
libusb_attach_kernel_driver
@ -38,6 +40,8 @@ EXPORTS
libusb_free_ss_endpoint_companion_descriptor@4 = libusb_free_ss_endpoint_companion_descriptor
libusb_free_ss_usb_device_capability_descriptor
libusb_free_ss_usb_device_capability_descriptor@4 = libusb_free_ss_usb_device_capability_descriptor
libusb_free_streams
libusb_free_streams@12 = libusb_free_streams
libusb_free_transfer
libusb_free_transfer@4 = libusb_free_transfer
libusb_free_usb_2_0_extension_descriptor
@ -146,6 +150,10 @@ EXPORTS
libusb_strerror@4 = libusb_strerror
libusb_submit_transfer
libusb_submit_transfer@4 = libusb_submit_transfer
libusb_transfer_get_stream_id
libusb_transfer_get_stream_id@4 = libusb_transfer_get_stream_id
libusb_transfer_set_stream_id
libusb_transfer_set_stream_id@8 = libusb_transfer_set_stream_id
libusb_try_lock_events
libusb_try_lock_events@4 = libusb_try_lock_events
libusb_unlock_event_waiters

View File

@ -41,7 +41,7 @@ BEGIN
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "libusbx.org\0"
VALUE "CompanyName", "libusb.info\0"
VALUE "FileDescription", "C library for writing portable USB drivers in userspace\0"
VALUE "FileVersion", LIBUSB_VERSIONSTRING
VALUE "InternalName", "libusb\0"

View File

@ -1,10 +1,10 @@
/*
* Public libusbx header file
* Public libusb header file
* Copyright © 2001 Johannes Erdfelt <johannes@erdfelt.com>
* Copyright © 2007-2008 Daniel Drake <dsd@gentoo.org>
* Copyright © 2012 Pete Batard <pete@akeo.ie>
* Copyright © 2012 Nathan Hjelm <hjelmn@cs.unm.edu>
* For more information, please visit: http://libusbx.org
* For more information, please visit: http://libusb.info
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -62,7 +62,7 @@ typedef unsigned __int32 uint32_t;
#include <limits.h>
/* 'interface' might be defined as a macro on Windows, so we need to
* undefine it so as not to break the current libusbx API, because
* undefine it so as not to break the current libusb API, because
* libusb_config_descriptor has an 'interface' member
* As this can be problematic if you include windows.h after libusb.h
* in your sources, we force windows.h to be included first. */
@ -85,14 +85,14 @@ typedef unsigned __int32 uint32_t;
/** \def LIBUSB_CALL
* \ingroup misc
* libusbx's Windows calling convention.
* libusb's Windows calling convention.
*
* Under Windows, the selection of available compilers and configurations
* means that, unlike other platforms, there is not <em>one true calling
* convention</em> (calling convention: the manner in which parameters are
* passed to funcions in the generated assembly code).
*
* Matching the Windows API itself, libusbx uses the WINAPI convention (which
* Matching the Windows API itself, libusb uses the WINAPI convention (which
* translates to the <tt>stdcall</tt> convention) and guarantees that the
* library is compiled in this way. The public header file also includes
* appropriate annotations so that your own software will use the right
@ -100,7 +100,7 @@ typedef unsigned __int32 uint32_t;
* your codebase.
*
* The one consideration that you must apply in your software is to mark
* all functions which you use as libusbx callbacks with this LIBUSB_CALL
* all functions which you use as libusb callbacks with this LIBUSB_CALL
* annotation, so that they too get compiled for the correct calling
* convention.
*
@ -108,7 +108,7 @@ typedef unsigned __int32 uint32_t;
* means that you can apply it to your code without worrying about
* cross-platform compatibility.
*/
/* LIBUSB_CALL must be defined on both definition and declaration of libusbx
/* LIBUSB_CALL must be defined on both definition and declaration of libusb
* functions. You'd think that declaration would be enough, but cygwin will
* complain about conflicting types unless both are marked this way.
* The placement of this macro is important too; it must appear after the
@ -121,36 +121,39 @@ typedef unsigned __int32 uint32_t;
#define LIBUSB_CALL
#endif
/** \def LIBUSBX_API_VERSION
/** \def LIBUSB_API_VERSION
* \ingroup misc
* libusbx's API version.
* libusb's API version.
*
* Since version 1.0.13, to help with feature detection, libusbx defines
* a LIBUSBX_API_VERSION macro that gets increased every time there is a
* Since version 1.0.13, to help with feature detection, libusb defines
* a LIBUSB_API_VERSION macro that gets increased every time there is a
* significant change to the API, such as the introduction of a new call,
* the definition of a new macro/enum member, or any other element that
* libusbx applications may want to detect at compilation time.
* libusb applications may want to detect at compilation time.
*
* The macro is typically used in an application as follows:
* \code
* #if defined(LIBUSBX_API_VERSION) && (LIBUSBX_API_VERSION >= 0x01001234)
* // Use one of the newer features from the libusbx API
* #if defined(LIBUSB_API_VERSION) && (LIBUSB_API_VERSION >= 0x01001234)
* // Use one of the newer features from the libusb API
* #endif
* \endcode
*
* Another feature of LIBUSBX_API_VERSION is that it can be used to detect
* whether you are compiling against the libusb or the libusbx library.
* Another feature of LIBUSB_API_VERSION is that it can be used to detect
* whether you are compiling against the libusb or the libusb library.
*
* Internally, LIBUSBX_API_VERSION is defined as follows:
* (libusbx major << 24) | (libusbx minor << 16) | (16 bit incremental)
* Internally, LIBUSB_API_VERSION is defined as follows:
* (libusb major << 24) | (libusb minor << 16) | (16 bit incremental)
*/
#define LIBUSBX_API_VERSION 0x01000102
#define LIBUSB_API_VERSION 0x01000103
/* The following is kept for compatibility, but will be deprecated in the future */
#define LIBUSBX_API_VERSION LIBUSB_API_VERSION
#ifdef __cplusplus
extern "C" {
#endif
/** \def libusb_cpu_to_le16
/**
* \ingroup misc
* Convert a 16-bit value from host-endian to little-endian format. On
* little endian systems, this function does nothing. On big endian systems,
@ -340,7 +343,10 @@ enum libusb_transfer_type {
LIBUSB_TRANSFER_TYPE_BULK = 2,
/** Interrupt endpoint */
LIBUSB_TRANSFER_TYPE_INTERRUPT = 3
LIBUSB_TRANSFER_TYPE_INTERRUPT = 3,
/** Stream endpoint */
LIBUSB_TRANSFER_TYPE_BULK_STREAM = 4,
};
/** \ingroup misc
@ -562,7 +568,7 @@ struct libusb_endpoint_descriptor {
/** For audio devices only: the address if the synch endpoint */
uint8_t bSynchAddress;
/** Extra descriptors. If libusbx encounters unknown endpoint descriptors,
/** Extra descriptors. If libusb encounters unknown endpoint descriptors,
* it will store them here, should you wish to parse them. */
const unsigned char *extra;
@ -612,7 +618,7 @@ struct libusb_interface_descriptor {
* by the bNumEndpoints field. */
const struct libusb_endpoint_descriptor *endpoint;
/** Extra descriptors. If libusbx encounters unknown interface descriptors,
/** Extra descriptors. If libusb encounters unknown interface descriptors,
* it will store them here, should you wish to parse them. */
const unsigned char *extra;
@ -670,7 +676,7 @@ struct libusb_config_descriptor {
* this array is determined by the bNumInterfaces field. */
const struct libusb_interface *interface;
/** Extra descriptors. If libusbx encounters unknown configuration
/** Extra descriptors. If libusb encounters unknown configuration
* descriptors, it will store them here, should you wish to parse them. */
const unsigned char *extra;
@ -889,7 +895,7 @@ struct libusb_control_setup {
#define LIBUSB_CONTROL_SETUP_SIZE (sizeof(struct libusb_control_setup))
/* libusbx */
/* libusb */
struct libusb_context;
struct libusb_device;
@ -897,7 +903,7 @@ struct libusb_device_handle;
struct libusb_hotplug_callback;
/** \ingroup lib
* Structure providing the version of the libusbx runtime
* Structure providing the version of the libusb runtime
*/
struct libusb_version {
/** Library major version. */
@ -920,16 +926,16 @@ struct libusb_version {
};
/** \ingroup lib
* Structure representing a libusbx session. The concept of individual libusbx
* Structure representing a libusb session. The concept of individual libusb
* sessions allows for your program to use two libraries (or dynamically
* load two modules) which both independently use libusb. This will prevent
* interference between the individual libusbx users - for example
* interference between the individual libusb users - for example
* libusb_set_debug() will not affect the other user of the library, and
* libusb_exit() will not destroy resources that the other user is still
* using.
*
* Sessions are created by libusb_init() and destroyed through libusb_exit().
* If your application is guaranteed to only ever include a single libusbx
* If your application is guaranteed to only ever include a single libusb
* user (i.e. you), you do not have to worry about contexts: pass NULL in
* every function call where a context is required. The default context
* will be used.
@ -1042,7 +1048,7 @@ enum libusb_bos_type {
};
/** \ingroup misc
* Error codes. Most libusbx functions return 0 on success or one of these
* Error codes. Most libusb functions return 0 on success or one of these
* codes on failure.
* You can call libusb_error_name() to retrieve a string representation of an
* error code or libusb_strerror() to get an end-user suitable description of
@ -1188,7 +1194,7 @@ struct libusb_transfer;
* Asynchronous transfer callback function type. When submitting asynchronous
* transfers, you pass a pointer to a callback function of this type via the
* \ref libusb_transfer::callback "callback" member of the libusb_transfer
* structure. libusbx will call this function later, when the transfer has
* structure. libusb will call this function later, when the transfer has
* completed or failed. See \ref asyncio for more information.
* \param transfer The libusb_transfer struct the callback function is being
* notified about.
@ -1271,7 +1277,7 @@ enum libusb_capability {
LIBUSB_CAP_HAS_HOTPLUG = 0x0001,
/** The library can access HID devices without requiring user intervention.
* Note that before being able to actually access an HID device, you may
* still have to call additional libusbx functions such as
* still have to call additional libusb functions such as
* \ref libusb_detach_kernel_driver(). */
LIBUSB_CAP_HAS_HID_ACCESS = 0x0100,
/** The library supports detaching of the default USB driver, using
@ -1384,6 +1390,11 @@ int LIBUSB_CALL libusb_clear_halt(libusb_device_handle *dev,
unsigned char endpoint);
int LIBUSB_CALL libusb_reset_device(libusb_device_handle *dev);
int LIBUSB_CALL libusb_alloc_streams(libusb_device_handle *dev,
uint32_t num_streams, unsigned char *endpoints, int num_endpoints);
int LIBUSB_CALL libusb_free_streams(libusb_device_handle *dev,
unsigned char *endpoints, int num_endpoints);
int LIBUSB_CALL libusb_kernel_driver_active(libusb_device_handle *dev,
int interface_number);
int LIBUSB_CALL libusb_detach_kernel_driver(libusb_device_handle *dev,
@ -1428,7 +1439,7 @@ static inline unsigned char *libusb_control_transfer_get_data(
static inline struct libusb_control_setup *libusb_control_transfer_get_setup(
struct libusb_transfer *transfer)
{
return (struct libusb_control_setup *) transfer->buffer;
return (struct libusb_control_setup *)(void *) transfer->buffer;
}
/** \ingroup asyncio
@ -1437,6 +1448,7 @@ static inline struct libusb_control_setup *libusb_control_transfer_get_setup(
* be given in host-endian byte order.
*
* \param buffer buffer to output the setup packet into
* This pointer must be aligned to at least 2 bytes boundary.
* \param bmRequestType see the
* \ref libusb_control_setup::bmRequestType "bmRequestType" field of
* \ref libusb_control_setup
@ -1457,7 +1469,7 @@ static inline void libusb_fill_control_setup(unsigned char *buffer,
uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex,
uint16_t wLength)
{
struct libusb_control_setup *setup = (struct libusb_control_setup *) buffer;
struct libusb_control_setup *setup = (struct libusb_control_setup *)(void *) buffer;
setup->bmRequestType = bmRequestType;
setup->bRequest = bRequest;
setup->wValue = libusb_cpu_to_le16(wValue);
@ -1469,6 +1481,10 @@ struct libusb_transfer * LIBUSB_CALL libusb_alloc_transfer(int iso_packets);
int LIBUSB_CALL libusb_submit_transfer(struct libusb_transfer *transfer);
int LIBUSB_CALL libusb_cancel_transfer(struct libusb_transfer *transfer);
void LIBUSB_CALL libusb_free_transfer(struct libusb_transfer *transfer);
void LIBUSB_CALL libusb_transfer_set_stream_id(
struct libusb_transfer *transfer, uint32_t stream_id);
uint32_t LIBUSB_CALL libusb_transfer_get_stream_id(
struct libusb_transfer *transfer);
/** \ingroup asyncio
* Helper function to populate the required \ref libusb_transfer fields
@ -1493,6 +1509,7 @@ void LIBUSB_CALL libusb_free_transfer(struct libusb_transfer *transfer);
* \param dev_handle handle of the device that will handle the transfer
* \param buffer data buffer. If provided, this function will interpret the
* first 8 bytes as a setup packet and infer the transfer length from that.
* This pointer must be aligned to at least 2 bytes boundary.
* \param callback callback function to be invoked on transfer completion
* \param user_data user data to pass to callback function
* \param timeout timeout for the transfer in milliseconds
@ -1502,7 +1519,7 @@ static inline void libusb_fill_control_transfer(
unsigned char *buffer, libusb_transfer_cb_fn callback, void *user_data,
unsigned int timeout)
{
struct libusb_control_setup *setup = (struct libusb_control_setup *) buffer;
struct libusb_control_setup *setup = (struct libusb_control_setup *)(void *) buffer;
transfer->dev_handle = dev_handle;
transfer->endpoint = 0;
transfer->type = LIBUSB_TRANSFER_TYPE_CONTROL;
@ -1543,6 +1560,34 @@ static inline void libusb_fill_bulk_transfer(struct libusb_transfer *transfer,
transfer->callback = callback;
}
/** \ingroup asyncio
* Helper function to populate the required \ref libusb_transfer fields
* for a bulk transfer using bulk streams.
*
* Since version 1.0.19, \ref LIBUSB_API_VERSION >= 0x01000103
*
* \param transfer the transfer to populate
* \param dev_handle handle of the device that will handle the transfer
* \param endpoint address of the endpoint where this transfer will be sent
* \param stream_id bulk stream id for this transfer
* \param buffer data buffer
* \param length length of data buffer
* \param callback callback function to be invoked on transfer completion
* \param user_data user data to pass to callback function
* \param timeout timeout for the transfer in milliseconds
*/
static inline void libusb_fill_bulk_stream_transfer(
struct libusb_transfer *transfer, libusb_device_handle *dev_handle,
unsigned char endpoint, uint32_t stream_id,
unsigned char *buffer, int length, libusb_transfer_cb_fn callback,
void *user_data, unsigned int timeout)
{
libusb_fill_bulk_transfer(transfer, dev_handle, endpoint, buffer,
length, callback, user_data, timeout);
transfer->type = LIBUSB_TRANSFER_TYPE_BULK_STREAM;
libusb_transfer_set_stream_id(transfer, stream_id);
}
/** \ingroup asyncio
* Helper function to populate the required \ref libusb_transfer fields
* for an interrupt transfer.
@ -1827,7 +1872,7 @@ void LIBUSB_CALL libusb_set_pollfd_notifiers(libusb_context *ctx,
* per libusb_context and it is safe to call libusb_hotplug_deregister_callback()
* on an already deregisted callback.
*
* Since version 1.0.16, \ref LIBUSBX_API_VERSION >= 0x01000102
* Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
*
* For more information, see \ref hotplug.
*/
@ -1835,7 +1880,7 @@ typedef int libusb_hotplug_callback_handle;
/** \ingroup hotplug
*
* Since version 1.0.16, \ref LIBUSBX_API_VERSION >= 0x01000102
* Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
*
* Flags for hotplug events */
typedef enum {
@ -1845,7 +1890,7 @@ typedef enum {
/** \ingroup hotplug
*
* Since version 1.0.16, \ref LIBUSBX_API_VERSION >= 0x01000102
* Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
*
* Hotplug events */
typedef enum {
@ -1869,15 +1914,15 @@ typedef enum {
* This callback may be called by an internal event thread and as such it is
* recommended the callback do minimal processing before returning.
*
* libusbx will call this function later, when a matching event had happened on
* libusb will call this function later, when a matching event had happened on
* a matching device. See \ref hotplug for more information.
*
* It is safe to call either libusb_hotplug_register_callback() or
* libusb_hotplug_deregister_callback() from within a callback function.
*
* Since version 1.0.16, \ref LIBUSBX_API_VERSION >= 0x01000102
* Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
*
* \param libusb_context context of this notification
* \param ctx context of this notification
* \param device libusb_device this event occurred on
* \param event event that occurred
* \param user_data user data provided when this callback was registered
@ -1897,7 +1942,19 @@ typedef int (LIBUSB_CALL *libusb_hotplug_callback_fn)(libusb_context *ctx,
* armed until either it is deregistered with libusb_hotplug_deregister_callback()
* or the supplied callback returns 1 to indicate it is finished processing events.
*
* Since version 1.0.16, \ref LIBUSBX_API_VERSION >= 0x01000102
* If the \ref LIBUSB_HOTPLUG_ENUMERATE is passed the callback will be
* called with a \ref LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED for all devices
* already plugged into the machine. Note that libusb modifies its internal
* device list from a separate thread, while calling hotplug callbacks from
* libusb_handle_events(), so it is possible for a device to already be present
* on, or removed from, its internal device list, while the hotplug callbacks
* still need to be dispatched. This means that when using \ref
* LIBUSB_HOTPLUG_ENUMERATE, your callback may be called twice for the arrival
* of the same device, once from libusb_hotplug_register_callback() and once
* from libusb_handle_events(); and/or your callback may be called for the
* removal of a device for which an arrived call was never made.
*
* Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
*
* \param[in] ctx context to register this callback with
* \param[in] events bitwise or of events that will trigger this callback. See \ref
@ -1926,7 +1983,7 @@ int LIBUSB_CALL libusb_hotplug_register_callback(libusb_context *ctx,
* Deregister a callback from a libusb_context. This function is safe to call from within
* a hotplug callback.
*
* Since version 1.0.16, \ref LIBUSBX_API_VERSION >= 0x01000102
* Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
*
* \param[in] ctx context this callback is registered with
* \param[in] handle the handle of the callback to deregister

View File

@ -1,5 +1,5 @@
/*
* Internal header for libusbx
* Internal header for libusb
* Copyright © 2007-2009 Daniel Drake <dsd@gentoo.org>
* Copyright © 2001 Johannes Erdfelt <johannes@erdfelt.com>
*
@ -23,6 +23,8 @@
#include "config.h"
#include <stdlib.h>
#include <stddef.h>
#include <stdint.h>
#include <time.h>
@ -37,11 +39,11 @@
#include "libusb.h"
#include "version.h"
/* Inside the libusbx code, mark all public functions as follows:
/* Inside the libusb code, mark all public functions as follows:
* return_type API_EXPORTED function_name(params) { ... }
* But if the function returns a pointer, mark it as follows:
* DEFAULT_VISIBILITY return_type * LIBUSB_CALL function_name(params) { ... }
* In the libusbx public header, mark all declarations as:
* In the libusb public header, mark all declarations as:
* return_type LIBUSB_CALL function_name(params);
*/
#define API_EXPORTED LIBUSB_CALL DEFAULT_VISIBILITY
@ -147,6 +149,15 @@ static inline void *usbi_reallocf(void *ptr, size_t size)
#define TIMESPEC_IS_SET(ts) ((ts)->tv_sec != 0 || (ts)->tv_nsec != 0)
/* Some platforms don't have this define */
#ifndef TIMESPEC_TO_TIMEVAL
#define TIMESPEC_TO_TIMEVAL(tv, ts) \
do { \
(tv)->tv_sec = (ts)->tv_sec; \
(tv)->tv_usec = (ts)->tv_nsec / 1000; \
} while (0)
#endif
void usbi_log(struct libusb_context *ctx, enum libusb_log_level level,
const char *function, const char *format, ...);
@ -355,6 +366,7 @@ struct usbi_transfer {
struct list_head list;
struct timeval timeout;
int transferred;
uint32_t stream_id;
uint8_t flags;
/* this lock is held during libusb_submit_transfer() and
@ -433,7 +445,7 @@ void usbi_connect_device (struct libusb_device *dev);
void usbi_disconnect_device (struct libusb_device *dev);
/* Internal abstraction for poll (needs struct usbi_transfer on Windows) */
#if defined(OS_LINUX) || defined(OS_DARWIN) || defined(OS_OPENBSD)
#if defined(OS_LINUX) || defined(OS_DARWIN) || defined(OS_OPENBSD) || defined(OS_NETBSD)
#include <unistd.h>
#include "os/poll_posix.h"
#elif defined(OS_WINDOWS) || defined(OS_WINCE)
@ -501,7 +513,7 @@ struct usbi_os_backend {
* to determine specific capabilities of the system, allocate required
* data structures for later, etc.
*
* This function is called when a libusbx user initializes the library
* This function is called when a libusb user initializes the library
* prior to use.
*
* Return 0 on success, or a LIBUSB_ERROR code on failure.
@ -531,9 +543,9 @@ struct usbi_os_backend {
* but that is an unlikely case.
*
* After computing a session ID for a device, call
* usbi_get_device_by_session_id(). This function checks if libusbx already
* knows about the device, and if so, it provides you with a libusb_device
* structure for it.
* usbi_get_device_by_session_id(). This function checks if libusb already
* knows about the device, and if so, it provides you with a reference
* to a libusb_device structure for it.
*
* If usbi_get_device_by_session_id() returns NULL, it is time to allocate
* a new device structure for the device. Call usbi_alloc_device() to
@ -592,7 +604,7 @@ struct usbi_os_backend {
*
* Your backend should allocate any internal resources required for I/O
* and other operations so that those operations can happen (hopefully)
* without hiccup. This is also a good place to inform libusbx that it
* without hiccup. This is also a good place to inform libusb that it
* should monitor certain file descriptors related to this device -
* see the usbi_add_pollfd() function.
*
@ -616,7 +628,7 @@ struct usbi_os_backend {
/* Close a device such that the handle cannot be used again. Your backend
* should destroy any resources that were allocated in the open path.
* This may also be a good place to call usbi_remove_pollfd() to inform
* libusbx of any file descriptors associated with this device that should
* libusb of any file descriptors associated with this device that should
* no longer be monitored.
*
* This function is called when the user closes a device handle.
@ -689,7 +701,7 @@ struct usbi_os_backend {
* (LE). If it returns the multi-byte values in host-endian format,
* set the host_endian output parameter to "1".
*
* Return 0 on success or a LIBUSB_ERROR code on failure.
* Return the length read on success or a LIBUSB_ERROR code on failure.
*/
int (*get_config_descriptor)(struct libusb_device *device,
uint8_t config_index, unsigned char *buffer, size_t len,
@ -717,7 +729,7 @@ struct usbi_os_backend {
*
* If you cannot retrieve this from cache, either do not implement this
* function, or return LIBUSB_ERROR_NOT_SUPPORTED. This will cause
* libusbx to retrieve the information through a standard control transfer.
* libusb to retrieve the information through a standard control transfer.
*
* This function must be non-blocking.
* Return:
@ -832,6 +844,14 @@ struct usbi_os_backend {
*/
int (*reset_device)(struct libusb_device_handle *handle);
/* Alloc num_streams usb3 bulk streams on the passed in endpoints */
int (*alloc_streams)(struct libusb_device_handle *handle,
uint32_t num_streams, unsigned char *endpoints, int num_endpoints);
/* Free usb3 bulk streams allocated with alloc_streams */
int (*free_streams)(struct libusb_device_handle *handle,
unsigned char *endpoints, int num_endpoints);
/* Determine if a kernel driver is active on an interface. Optional.
*
* The presence of a kernel driver on an interface indicates that any
@ -916,7 +936,7 @@ struct usbi_os_backend {
* all private data from the transfer as if you were just about to report
* completion or cancellation.
*
* This function might seem a bit out of place. It is used when libusbx
* This function might seem a bit out of place. It is used when libusb
* detects a disconnected device - it calls this function for all pending
* transfers before reporting completion (with the disconnect code) to
* the user. Maybe we can improve upon this internal interface in future.
@ -995,6 +1015,7 @@ extern const struct usbi_os_backend * const usbi_backend;
extern const struct usbi_os_backend linux_usbfs_backend;
extern const struct usbi_os_backend darwin_backend;
extern const struct usbi_os_backend openbsd_backend;
extern const struct usbi_os_backend netbsd_backend;
extern const struct usbi_os_backend windows_backend;
extern const struct usbi_os_backend wince_backend;

View File

@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode:nil -*- */
/*
* darwin backend for libusbx 1.0
* Copyright © 2008-2013 Nathan Hjelm <hjelmn@users.sourceforge.net>
* darwin backend for libusb 1.0
* Copyright © 2008-2014 Nathan Hjelm <hjelmn@users.sourceforge.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -71,6 +71,7 @@ static int process_new_device (struct libusb_context *ctx, io_service_t service)
#if defined(ENABLE_LOGGING)
static const char *darwin_error_str (int result) {
static char string_buffer[50];
switch (result) {
case kIOReturnSuccess:
return "no error";
@ -103,7 +104,8 @@ static const char *darwin_error_str (int result) {
case kIOUSBHighSpeedSplitError:
return "high speed split error";
default:
return "unknown error";
snprintf(string_buffer, sizeof(string_buffer), "unknown error (0x%x)", result);
return string_buffer;
}
}
#endif
@ -149,7 +151,7 @@ static void darwin_ref_cached_device(struct darwin_cached_device *cached_dev) {
cached_dev->refcount++;
}
static int ep_to_pipeRef(struct libusb_device_handle *dev_handle, uint8_t ep, uint8_t *pipep, uint8_t *ifcp) {
static int ep_to_pipeRef(struct libusb_device_handle *dev_handle, uint8_t ep, uint8_t *pipep, uint8_t *ifcp, struct darwin_interface **interface_out) {
struct darwin_device_handle_priv *priv = (struct darwin_device_handle_priv *)dev_handle->os_priv;
/* current interface */
@ -166,8 +168,14 @@ static int ep_to_pipeRef(struct libusb_device_handle *dev_handle, uint8_t ep, ui
for (i = 0 ; i < cInterface->num_endpoints ; i++) {
if (cInterface->endpoint_addrs[i] == ep) {
*pipep = i + 1;
*ifcp = iface;
usbi_dbg ("pipe %d on interface %d matches", *pipep, *ifcp);
if (ifcp)
*ifcp = iface;
if (interface_out)
*interface_out = cInterface;
usbi_dbg ("pipe %d on interface %d matches", *pipep, iface);
return 0;
}
}
@ -177,7 +185,7 @@ static int ep_to_pipeRef(struct libusb_device_handle *dev_handle, uint8_t ep, ui
/* No pipe found with the correct endpoint address */
usbi_warn (HANDLE_CTX(dev_handle), "no pipeRef found with endpoint address 0x%02x.", ep);
return -1;
return LIBUSB_ERROR_NOT_FOUND;
}
static int usb_setup_device_iterator (io_iterator_t *deviceIterator, UInt32 location) {
@ -210,6 +218,7 @@ static int usb_setup_device_iterator (io_iterator_t *deviceIterator, UInt32 loca
return IOServiceGetMatchingServices(kIOMasterPortDefault, matchingDict, deviceIterator);
}
/* Returns 1 on success, 0 on failure. */
static int get_ioregistry_value_number (io_service_t service, CFStringRef property, CFNumberType type, void *p) {
CFTypeRef cfNumber = IORegistryEntryCreateCFProperty (service, property, kCFAllocatorDefault, 0);
int ret = 0;
@ -275,6 +284,8 @@ static void darwin_devices_detached (void *ptr, io_iterator_t rem_devices) {
UInt64 session;
int ret;
usbi_mutex_lock(&active_contexts_lock);
while ((device = IOIteratorNext (rem_devices)) != 0) {
/* get the location from the i/o registry */
ret = get_ioregistry_value_number (device, CFSTR("sessionID"), kCFNumberSInt64Type, &session);
@ -282,21 +293,31 @@ static void darwin_devices_detached (void *ptr, io_iterator_t rem_devices) {
if (!ret)
continue;
usbi_mutex_lock(&active_contexts_lock);
list_for_each_entry(ctx, &active_contexts_list, list, struct libusb_context) {
usbi_dbg ("notifying context %p of device disconnect", ctx);
dev = usbi_get_device_by_session_id(ctx, session);
dev = usbi_get_device_by_session_id(ctx, (unsigned long) session);
if (dev) {
/* signal the core that this device has been disconnected. the core will tear down this device
when the reference count reaches 0 */
usbi_disconnect_device(dev);
libusb_unref_device(dev);
}
}
usbi_mutex_unlock(&active_contexts_lock);
}
usbi_mutex_unlock(&active_contexts_lock);
}
static void darwin_hotplug_poll (void)
{
/* not sure if 5 seconds will be too long/short but it should work ok */
mach_timespec_t timeout = {.tv_sec = 5, .tv_nsec = 0};
/* since a kernel thread may nodify the IOInterators used for
* hotplug notidication we can't just clear the iterators.
* instead just wait until all IOService providers are quiet */
(void) IOKitWaitQuiet (kIOMasterPortDefault, &timeout);
}
static void darwin_clear_iterator (io_iterator_t iter) {
@ -342,8 +363,8 @@ static void *darwin_event_thread_main (void *arg0) {
/* create notifications for removed devices */
kresult = IOServiceAddMatchingNotification (libusb_notification_port, kIOTerminatedNotification,
IOServiceMatching(kIOUSBDeviceClassName),
(IOServiceMatchingCallback)darwin_devices_detached,
(void *)ctx, &libusb_rem_device_iterator);
darwin_devices_detached,
ctx, &libusb_rem_device_iterator);
if (kresult != kIOReturnSuccess) {
usbi_err (ctx, "could not add hotplug event source: %s", darwin_error_str (kresult));
@ -354,8 +375,8 @@ static void *darwin_event_thread_main (void *arg0) {
/* create notifications for attached devices */
kresult = IOServiceAddMatchingNotification(libusb_notification_port, kIOFirstMatchNotification,
IOServiceMatching(kIOUSBDeviceClassName),
(IOServiceMatchingCallback)darwin_devices_attached,
(void *)ctx, &libusb_add_device_iterator);
darwin_devices_attached,
ctx, &libusb_add_device_iterator);
if (kresult != kIOReturnSuccess) {
usbi_err (ctx, "could not add hotplug event source: %s", darwin_error_str (kresult));
@ -397,7 +418,8 @@ static void *darwin_event_thread_main (void *arg0) {
pthread_exit (NULL);
}
static void _darwin_finalize(void) {
/* cleanup function to destroy cached devices */
static void __attribute__((destructor)) _darwin_finalize(void) {
struct darwin_cached_device *dev, *next;
usbi_mutex_lock(&darwin_cached_devices_lock);
@ -409,7 +431,6 @@ static void _darwin_finalize(void) {
static int darwin_init(struct libusb_context *ctx) {
host_name_port_t host_self;
static int initted = 0;
int rc;
rc = darwin_scan_devices (ctx);
@ -420,17 +441,12 @@ static int darwin_init(struct libusb_context *ctx) {
if (OSAtomicIncrement32Barrier(&initCount) == 1) {
/* create the clocks that will be used */
if (!initted) {
initted = 1;
atexit(_darwin_finalize);
}
host_self = mach_host_self();
host_get_clock_service(host_self, CALENDAR_CLOCK, &clock_realtime);
host_get_clock_service(host_self, SYSTEM_CLOCK, &clock_monotonic);
mach_port_deallocate(mach_task_self(), host_self);
pthread_create (&libusb_darwin_at, NULL, darwin_event_thread_main, (void *)ctx);
pthread_create (&libusb_darwin_at, NULL, darwin_event_thread_main, ctx);
pthread_mutex_lock (&libusb_darwin_at_mutex);
while (!libusb_darwin_acfl)
@ -524,7 +540,7 @@ static int darwin_get_config_descriptor(struct libusb_device *dev, uint8_t confi
if (ret != LIBUSB_SUCCESS)
return ret;
return len;
return (int) len;
}
/* check whether the os has configured the device */
@ -701,7 +717,7 @@ static int darwin_cache_device_descriptor (struct libusb_context *ctx, struct da
else
usbi_warn (ctx, "could not retrieve device descriptor %.4x:%.4x: %s (%x). skipping device",
idVendor, idProduct, darwin_error_str (ret), ret);
return -1;
return darwin_to_libusb (ret);
}
/* catch buggy hubs (which appear to be virtual). Apple's own USB prober has problems with these devices. */
@ -709,7 +725,7 @@ static int darwin_cache_device_descriptor (struct libusb_context *ctx, struct da
/* not a valid device */
usbi_warn (ctx, "idProduct from iokit (%04x) does not match idProduct in descriptor (%04x). skipping device",
idProduct, libusb_le16_to_cpu (dev->dev_descriptor.idProduct));
return -1;
return LIBUSB_ERROR_NO_DEVICE;
}
usbi_dbg ("cached device descriptor:");
@ -729,26 +745,24 @@ static int darwin_cache_device_descriptor (struct libusb_context *ctx, struct da
dev->can_enumerate = 1;
return 0;
return LIBUSB_SUCCESS;
}
static int darwin_get_cached_device(struct libusb_context *ctx, io_service_t service,
struct darwin_cached_device **cached_out) {
struct darwin_cached_device *new_device;
UInt64 sessionID, parent_sessionID;
UInt64 sessionID = 0, parent_sessionID = 0;
int ret = LIBUSB_SUCCESS;
usb_device_t **device;
io_service_t parent;
kern_return_t result;
UInt8 port = 0;
*cached_out = NULL;
/* get some info from the io registry */
(void) get_ioregistry_value_number (service, CFSTR("sessionID"), kCFNumberSInt64Type, &sessionID);
(void) get_ioregistry_value_number (service, CFSTR("PortNum"), kCFNumberSInt8Type, &port);
usbi_dbg("finding cached device for sessionID 0x\n" PRIx64, sessionID);
usbi_dbg("finding cached device for sessionID 0x%" PRIx64, sessionID);
result = IORegistryEntryGetParentEntry (service, kIOUSBPlane, &parent);
@ -759,8 +773,10 @@ static int darwin_get_cached_device(struct libusb_context *ctx, io_service_t ser
usbi_mutex_lock(&darwin_cached_devices_lock);
do {
*cached_out = NULL;
list_for_each_entry(new_device, &darwin_cached_devices, list, struct darwin_cached_device) {
usbi_dbg("matching sessionID 0x%x against cached device with sessionID 0x%x", sessionID, new_device->session);
usbi_dbg("matching sessionID 0x%" PRIx64 " against cached device with sessionID 0x%" PRIx64, sessionID, new_device->session);
if (new_device->session == sessionID) {
usbi_dbg("using cached device for device");
*cached_out = new_device;
@ -771,19 +787,17 @@ static int darwin_get_cached_device(struct libusb_context *ctx, io_service_t ser
if (*cached_out)
break;
usbi_dbg("caching new device with sessionID 0x%x\n", sessionID);
new_device = calloc (1, sizeof (*new_device));
if (!new_device) {
ret = LIBUSB_ERROR_NO_MEM;
break;
}
usbi_dbg("caching new device with sessionID 0x%" PRIx64, sessionID);
device = darwin_device_from_service (service);
if (!device) {
ret = LIBUSB_ERROR_NO_DEVICE;
free (new_device);
new_device = NULL;
break;
}
new_device = calloc (1, sizeof (*new_device));
if (!new_device) {
ret = LIBUSB_ERROR_NO_MEM;
break;
}
@ -833,7 +847,7 @@ static int process_new_device (struct libusb_context *ctx, io_service_t service)
do {
ret = darwin_get_cached_device (ctx, service, &cached_device);
if (ret < 0 || (cached_device && !cached_device->can_enumerate)) {
if (ret < 0 || !cached_device->can_enumerate) {
return ret;
}
@ -843,10 +857,10 @@ static int process_new_device (struct libusb_context *ctx, io_service_t service)
if (ret)
break;
usbi_dbg ("allocating new device in context %p for with session 0x%08x",
usbi_dbg ("allocating new device in context %p for with session 0x%" PRIx64,
ctx, cached_device->session);
dev = usbi_alloc_device(ctx, cached_device->session);
dev = usbi_alloc_device(ctx, (unsigned long) cached_device->session);
if (!dev) {
return LIBUSB_ERROR_NO_MEM;
}
@ -857,7 +871,7 @@ static int process_new_device (struct libusb_context *ctx, io_service_t service)
darwin_ref_cached_device (priv->dev);
if (cached_device->parent_session > 0) {
dev->parent_dev = usbi_get_device_by_session_id (ctx, cached_device->parent_session);
dev->parent_dev = usbi_get_device_by_session_id (ctx, (unsigned long) cached_device->parent_session);
} else {
dev->parent_dev = NULL;
}
@ -865,11 +879,6 @@ static int process_new_device (struct libusb_context *ctx, io_service_t service)
dev->bus_number = cached_device->location >> 24;
dev->device_address = cached_device->address;
/* need to add a reference to the parent device */
if (dev->parent_dev) {
libusb_ref_device(dev->parent_dev);
}
(*(priv->dev->device))->GetDeviceSpeed (priv->dev->device, &devSpeed);
switch (devSpeed) {
@ -1129,7 +1138,7 @@ static int get_endpoints (struct libusb_device_handle *dev_handle, int iface) {
usbi_dbg ("interface: %i pipe %i: dir: %i number: %i", iface, i, direction, number);
cInterface->endpoint_addrs[i - 1] = ((direction << 7 & LIBUSB_ENDPOINT_DIR_MASK) | (number & LIBUSB_ENDPOINT_ADDRESS_MASK));
cInterface->endpoint_addrs[i - 1] = (((kUSBIn == direction) << kUSBRqDirnShift) | (number & LIBUSB_ENDPOINT_ADDRESS_MASK));
}
cInterface->num_endpoints = numep;
@ -1301,22 +1310,18 @@ static int darwin_set_interface_altsetting(struct libusb_device_handle *dev_hand
}
static int darwin_clear_halt(struct libusb_device_handle *dev_handle, unsigned char endpoint) {
struct darwin_device_handle_priv *priv = (struct darwin_device_handle_priv *)dev_handle->os_priv;
/* current interface */
struct darwin_interface *cInterface;
uint8_t pipeRef, iface;
IOReturn kresult;
uint8_t pipeRef;
/* determine the interface/endpoint to use */
if (ep_to_pipeRef (dev_handle, endpoint, &pipeRef, &iface) != 0) {
if (ep_to_pipeRef (dev_handle, endpoint, &pipeRef, NULL, &cInterface) != 0) {
usbi_err (HANDLE_CTX (dev_handle), "endpoint not found on any open interface");
return LIBUSB_ERROR_NOT_FOUND;
}
cInterface = &priv->interfaces[iface];
/* newer versions of darwin support clearing additional bits on the device's endpoint */
kresult = (*(cInterface->interface))->ClearPipeStallBothEnds(cInterface->interface, pipeRef);
if (kresult)
@ -1430,26 +1435,29 @@ static void darwin_destroy_device(struct libusb_device *dev) {
static int submit_bulk_transfer(struct usbi_transfer *itransfer) {
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
struct darwin_device_handle_priv *priv = (struct darwin_device_handle_priv *)transfer->dev_handle->os_priv;
IOReturn ret;
uint8_t transferType;
/* None of the values below are used in libusbx for bulk transfers */
uint8_t direction, number, interval, pipeRef, iface;
uint8_t direction, number, interval, pipeRef;
uint16_t maxPacketSize;
struct darwin_interface *cInterface;
if (ep_to_pipeRef (transfer->dev_handle, transfer->endpoint, &pipeRef, &iface) != 0) {
if (ep_to_pipeRef (transfer->dev_handle, transfer->endpoint, &pipeRef, NULL, &cInterface) != 0) {
usbi_err (TRANSFER_CTX (transfer), "endpoint not found on any open interface");
return LIBUSB_ERROR_NOT_FOUND;
}
cInterface = &priv->interfaces[iface];
ret = (*(cInterface->interface))->GetPipeProperties (cInterface->interface, pipeRef, &direction, &number,
&transferType, &maxPacketSize, &interval);
(*(cInterface->interface))->GetPipeProperties (cInterface->interface, pipeRef, &direction, &number,
&transferType, &maxPacketSize, &interval);
if (ret) {
usbi_err (TRANSFER_CTX (transfer), "bulk transfer failed (dir = %s): %s (code = 0x%08x)", IS_XFERIN(transfer) ? "In" : "Out",
darwin_error_str(ret), ret);
return darwin_to_libusb (ret);
}
if (0 != (transfer->length % maxPacketSize)) {
/* do not need a zero packet */
@ -1485,13 +1493,44 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer) {
return darwin_to_libusb (ret);
}
#if InterfaceVersion >= 550
static int submit_stream_transfer(struct usbi_transfer *itransfer) {
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
struct darwin_interface *cInterface;
uint8_t pipeRef;
IOReturn ret;
if (ep_to_pipeRef (transfer->dev_handle, transfer->endpoint, &pipeRef, NULL, &cInterface) != 0) {
usbi_err (TRANSFER_CTX (transfer), "endpoint not found on any open interface");
return LIBUSB_ERROR_NOT_FOUND;
}
itransfer->flags |= USBI_TRANSFER_OS_HANDLES_TIMEOUT;
if (IS_XFERIN(transfer))
ret = (*(cInterface->interface))->ReadStreamsPipeAsyncTO(cInterface->interface, pipeRef, itransfer->stream_id,
transfer->buffer, transfer->length, transfer->timeout,
transfer->timeout, darwin_async_io_callback, (void *)itransfer);
else
ret = (*(cInterface->interface))->WriteStreamsPipeAsyncTO(cInterface->interface, pipeRef, itransfer->stream_id,
transfer->buffer, transfer->length, transfer->timeout,
transfer->timeout, darwin_async_io_callback, (void *)itransfer);
if (ret)
usbi_err (TRANSFER_CTX (transfer), "bulk stream transfer failed (dir = %s): %s (code = 0x%08x)", IS_XFERIN(transfer) ? "In" : "Out",
darwin_error_str(ret), ret);
return darwin_to_libusb (ret);
}
#endif
static int submit_iso_transfer(struct usbi_transfer *itransfer) {
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
struct darwin_transfer_priv *tpriv = usbi_transfer_get_os_priv(itransfer);
struct darwin_device_handle_priv *priv = (struct darwin_device_handle_priv *)transfer->dev_handle->os_priv;
IOReturn kresult;
uint8_t direction, number, interval, pipeRef, iface, transferType;
uint8_t direction, number, interval, pipeRef, transferType;
uint16_t maxPacketSize;
UInt64 frame;
AbsoluteTime atTime;
@ -1512,19 +1551,17 @@ static int submit_iso_transfer(struct usbi_transfer *itransfer) {
return LIBUSB_ERROR_NO_MEM;
}
/* copy the frame list from the libusbx descriptor (the structures differ only is member order) */
/* copy the frame list from the libusb descriptor (the structures differ only is member order) */
for (i = 0 ; i < transfer->num_iso_packets ; i++)
tpriv->isoc_framelist[i].frReqCount = transfer->iso_packet_desc[i].length;
/* determine the interface/endpoint to use */
if (ep_to_pipeRef (transfer->dev_handle, transfer->endpoint, &pipeRef, &iface) != 0) {
if (ep_to_pipeRef (transfer->dev_handle, transfer->endpoint, &pipeRef, NULL, &cInterface) != 0) {
usbi_err (TRANSFER_CTX (transfer), "endpoint not found on any open interface");
return LIBUSB_ERROR_NOT_FOUND;
}
cInterface = &priv->interfaces[iface];
/* determine the properties of this endpoint and the speed of the device */
(*(cInterface->interface))->GetPipeProperties (cInterface->interface, pipeRef, &direction, &number,
&transferType, &maxPacketSize, &interval);
@ -1579,7 +1616,6 @@ static int submit_control_transfer(struct usbi_transfer *itransfer) {
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
struct libusb_control_setup *setup = (struct libusb_control_setup *) transfer->buffer;
struct darwin_cached_device *dpriv = DARWIN_CACHED_DEVICE(transfer->dev_handle->dev);
struct darwin_device_handle_priv *priv = (struct darwin_device_handle_priv *)transfer->dev_handle->os_priv;
struct darwin_transfer_priv *tpriv = usbi_transfer_get_os_priv(itransfer);
IOReturn kresult;
@ -1593,7 +1629,7 @@ static int submit_control_transfer(struct usbi_transfer *itransfer) {
tpriv->req.wValue = OSSwapLittleToHostInt16 (setup->wValue);
tpriv->req.wIndex = OSSwapLittleToHostInt16 (setup->wIndex);
tpriv->req.wLength = OSSwapLittleToHostInt16 (setup->wLength);
/* data is stored after the libusbx control block */
/* data is stored after the libusb control block */
tpriv->req.pData = transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE;
tpriv->req.completionTimeout = transfer->timeout;
tpriv->req.noDataTimeout = transfer->timeout;
@ -1604,16 +1640,14 @@ static int submit_control_transfer(struct usbi_transfer *itransfer) {
if (transfer->endpoint) {
struct darwin_interface *cInterface;
uint8_t pipeRef, iface;
uint8_t pipeRef;
if (ep_to_pipeRef (transfer->dev_handle, transfer->endpoint, &pipeRef, &iface) != 0) {
if (ep_to_pipeRef (transfer->dev_handle, transfer->endpoint, &pipeRef, NULL, &cInterface) != 0) {
usbi_err (TRANSFER_CTX (transfer), "endpoint not found on any open interface");
return LIBUSB_ERROR_NOT_FOUND;
}
cInterface = &priv->interfaces[iface];
kresult = (*(cInterface->interface))->ControlRequestAsyncTO (cInterface->interface, pipeRef, &(tpriv->req), darwin_async_io_callback, itransfer);
} else
/* control request on endpoint 0 */
@ -1636,6 +1670,13 @@ static int darwin_submit_transfer(struct usbi_transfer *itransfer) {
return submit_bulk_transfer(itransfer);
case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
return submit_iso_transfer(itransfer);
case LIBUSB_TRANSFER_TYPE_BULK_STREAM:
#if InterfaceVersion >= 550
return submit_stream_transfer(itransfer);
#else
usbi_err (TRANSFER_CTX(transfer), "IOUSBFamily version does not support bulk stream transfers");
return LIBUSB_ERROR_NOT_SUPPORTED;
#endif
default:
usbi_err (TRANSFER_CTX(transfer), "unknown endpoint type %d", transfer->type);
return LIBUSB_ERROR_INVALID_PARAM;
@ -1660,26 +1701,28 @@ static int cancel_control_transfer(struct usbi_transfer *itransfer) {
static int darwin_abort_transfers (struct usbi_transfer *itransfer) {
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
struct darwin_cached_device *dpriv = DARWIN_CACHED_DEVICE(transfer->dev_handle->dev);
struct darwin_device_handle_priv *priv = (struct darwin_device_handle_priv *)transfer->dev_handle->os_priv;
struct darwin_interface *cInterface;
uint8_t pipeRef, iface;
IOReturn kresult;
if (ep_to_pipeRef (transfer->dev_handle, transfer->endpoint, &pipeRef, &iface) != 0) {
if (ep_to_pipeRef (transfer->dev_handle, transfer->endpoint, &pipeRef, &iface, &cInterface) != 0) {
usbi_err (TRANSFER_CTX (transfer), "endpoint not found on any open interface");
return LIBUSB_ERROR_NOT_FOUND;
}
cInterface = &priv->interfaces[iface];
if (!dpriv->device)
return LIBUSB_ERROR_NO_DEVICE;
usbi_warn (ITRANSFER_CTX (itransfer), "aborting all transactions on interface %d pipe %d", iface, pipeRef);
/* abort transactions */
(*(cInterface->interface))->AbortPipe (cInterface->interface, pipeRef);
#if InterfaceVersion >= 550
if (LIBUSB_TRANSFER_TYPE_BULK_STREAM == transfer->type)
(*(cInterface->interface))->AbortStreamsPipe (cInterface->interface, pipeRef, itransfer->stream_id);
else
#endif
(*(cInterface->interface))->AbortPipe (cInterface->interface, pipeRef);
usbi_dbg ("calling clear pipe stall to clear the data toggle bit");
@ -1727,10 +1770,9 @@ static void darwin_async_io_callback (void *refcon, IOReturn result, void *arg0)
/* if requested write a zero packet */
if (kIOReturnSuccess == result && IS_XFEROUT(transfer) && transfer->flags & LIBUSB_TRANSFER_ADD_ZERO_PACKET) {
struct darwin_interface *cInterface;
uint8_t iface, pipeRef;
uint8_t pipeRef;
(void) ep_to_pipeRef (transfer->dev_handle, transfer->endpoint, &pipeRef, &iface);
cInterface = &priv->interfaces[iface];
(void) ep_to_pipeRef (transfer->dev_handle, transfer->endpoint, &pipeRef, NULL, &cInterface);
(*(cInterface->interface))->WritePipe (cInterface->interface, pipeRef, transfer->buffer, 0);
}
@ -1861,6 +1903,64 @@ static int darwin_clock_gettime(int clk_id, struct timespec *tp) {
return 0;
}
#if InterfaceVersion >= 550
static int darwin_alloc_streams (struct libusb_device_handle *dev_handle, uint32_t num_streams, unsigned char *endpoints,
int num_endpoints) {
struct darwin_interface *cInterface;
UInt32 supportsStreams;
uint8_t pipeRef;
int rc, i;
/* find the mimimum number of supported streams on the endpoint list */
for (i = 0 ; i < num_endpoints ; ++i) {
if (0 != (rc = ep_to_pipeRef (dev_handle, endpoints[i], &pipeRef, NULL, &cInterface))) {
return rc;
}
(*(cInterface->interface))->SupportsStreams (cInterface->interface, pipeRef, &supportsStreams);
if (num_streams > supportsStreams)
num_streams = supportsStreams;
}
/* it is an error if any endpoint in endpoints does not support streams */
if (0 == num_streams)
return LIBUSB_ERROR_INVALID_PARAM;
/* create the streams */
for (i = 0 ; i < num_endpoints ; ++i) {
(void) ep_to_pipeRef (dev_handle, endpoints[i], &pipeRef, NULL, &cInterface);
rc = (*(cInterface->interface))->CreateStreams (cInterface->interface, pipeRef, num_streams);
if (kIOReturnSuccess != rc)
return darwin_to_libusb(rc);
}
return num_streams;
}
static int darwin_free_streams (struct libusb_device_handle *dev_handle, unsigned char *endpoints, int num_endpoints) {
struct darwin_interface *cInterface;
UInt32 supportsStreams;
uint8_t pipeRef;
int rc;
for (int i = 0 ; i < num_endpoints ; ++i) {
if (0 != (rc = ep_to_pipeRef (dev_handle, endpoints[i], &pipeRef, NULL, &cInterface)))
return rc;
(*(cInterface->interface))->SupportsStreams (cInterface->interface, pipeRef, &supportsStreams);
if (0 == supportsStreams)
return LIBUSB_ERROR_INVALID_PARAM;
rc = (*(cInterface->interface))->CreateStreams (cInterface->interface, pipeRef, 0);
if (kIOReturnSuccess != rc)
return darwin_to_libusb(rc);
}
return LIBUSB_SUCCESS;
}
#endif
const struct usbi_os_backend darwin_backend = {
.name = "Darwin",
.caps = 0,
@ -1870,6 +1970,7 @@ const struct usbi_os_backend darwin_backend = {
.get_device_descriptor = darwin_get_device_descriptor,
.get_active_config_descriptor = darwin_get_active_config_descriptor,
.get_config_descriptor = darwin_get_config_descriptor,
.hotplug_poll = darwin_hotplug_poll,
.open = darwin_open,
.close = darwin_close,
@ -1882,6 +1983,11 @@ const struct usbi_os_backend darwin_backend = {
.clear_halt = darwin_clear_halt,
.reset_device = darwin_reset_device,
#if InterfaceVersion >= 550
.alloc_streams = darwin_alloc_streams,
.free_streams = darwin_free_streams,
#endif
.kernel_driver_active = darwin_kernel_driver_active,
.detach_kernel_driver = darwin_detach_kernel_driver,
.attach_kernel_driver = darwin_attach_kernel_driver,

View File

@ -1,5 +1,5 @@
/*
* darwin backend for libusbx 1.0
* darwin backend for libusb 1.0
* Copyright © 2008-2013 Nathan Hjelm <hjelmn@users.sourceforge.net>
*
* This library is free software; you can redistribute it and/or
@ -137,7 +137,7 @@ struct darwin_device_handle_priv {
uint8_t num_endpoints;
CFRunLoopSourceRef cfSource;
uint64_t frames[256];
uint8_t endpoint_addrs[USB_MAXENDPOINTS];
uint8_t endpoint_addrs[USB_MAXENDPOINTS];
} interfaces[USB_MAXINTERFACES];
};

View File

@ -21,6 +21,10 @@
*/
#include "config.h"
#include "libusb.h"
#include "libusbi.h"
#include "linux_usbfs.h"
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
@ -30,46 +34,113 @@
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#ifdef HAVE_ASM_TYPES_H
#include <asm/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#include <arpa/inet.h>
#include "libusb.h"
#include "libusbi.h"
#include "linux_usbfs.h"
#ifdef HAVE_LINUX_NETLINK_H
#include <linux/netlink.h>
#endif
#ifdef HAVE_LINUX_FILTER_H
#include <linux/filter.h>
#endif
#define KERNEL 1
static int linux_netlink_socket = -1;
static int netlink_control_pipe[2] = { -1, -1 };
static pthread_t libusb_linux_event_thread;
static void *linux_netlink_event_thread_main(void *arg);
struct sockaddr_nl snl = { .nl_family=AF_NETLINK, .nl_groups=KERNEL };
static int set_fd_cloexec_nb (int fd)
{
int flags;
#if defined(FD_CLOEXEC)
flags = fcntl (linux_netlink_socket, F_GETFD);
if (0 > flags) {
return -1;
}
if (!(flags & FD_CLOEXEC)) {
fcntl (linux_netlink_socket, F_SETFD, flags | FD_CLOEXEC);
}
#endif
flags = fcntl (linux_netlink_socket, F_GETFL);
if (0 > flags) {
return -1;
}
if (!(flags & O_NONBLOCK)) {
fcntl (linux_netlink_socket, F_SETFL, flags | O_NONBLOCK);
}
return 0;
}
int linux_netlink_start_event_monitor(void)
{
int socktype = SOCK_RAW;
int ret;
snl.nl_groups = KERNEL;
linux_netlink_socket = socket(PF_NETLINK, SOCK_RAW|SOCK_CLOEXEC|SOCK_NONBLOCK, NETLINK_KOBJECT_UEVENT);
#if defined(SOCK_CLOEXEC)
socktype |= SOCK_CLOEXEC;
#endif
#if defined(SOCK_NONBLOCK)
socktype |= SOCK_NONBLOCK;
#endif
linux_netlink_socket = socket(PF_NETLINK, socktype, NETLINK_KOBJECT_UEVENT);
if (-1 == linux_netlink_socket && EINVAL == errno) {
linux_netlink_socket = socket(PF_NETLINK, SOCK_RAW, NETLINK_KOBJECT_UEVENT);
}
if (-1 == linux_netlink_socket) {
return LIBUSB_ERROR_OTHER;
}
ret = set_fd_cloexec_nb (linux_netlink_socket);
if (0 != ret) {
close (linux_netlink_socket);
linux_netlink_socket = -1;
return LIBUSB_ERROR_OTHER;
}
ret = bind(linux_netlink_socket, (struct sockaddr *) &snl, sizeof(snl));
if (0 != ret) {
close(linux_netlink_socket);
return LIBUSB_ERROR_OTHER;
}
/* TODO -- add authentication */
/* setsockopt(linux_netlink_socket, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one)); */
ret = usbi_pipe(netlink_control_pipe);
if (ret) {
usbi_err(NULL, "could not create netlink control pipe");
close(linux_netlink_socket);
return LIBUSB_ERROR_OTHER;
}
ret = pthread_create(&libusb_linux_event_thread, NULL, linux_netlink_event_thread_main, NULL);
if (0 != ret) {
close(netlink_control_pipe[0]);
close(netlink_control_pipe[1]);
close(linux_netlink_socket);
return LIBUSB_ERROR_OTHER;
}
@ -79,22 +150,30 @@ int linux_netlink_start_event_monitor(void)
int linux_netlink_stop_event_monitor(void)
{
int r;
char dummy = 1;
if (-1 == linux_netlink_socket) {
/* already closed. nothing to do */
return LIBUSB_SUCCESS;
}
r = close(linux_netlink_socket);
if (0 > r) {
usbi_err(NULL, "error closing netlink socket. %s", strerror(errno));
return LIBUSB_ERROR_OTHER;
/* Write some dummy data to the control pipe and
* wait for the thread to exit */
r = usbi_write(netlink_control_pipe[1], &dummy, sizeof(dummy));
if (r <= 0) {
usbi_warn(NULL, "netlink control pipe signal failed");
}
pthread_join(libusb_linux_event_thread, NULL);
pthread_cancel(libusb_linux_event_thread);
close(linux_netlink_socket);
linux_netlink_socket = -1;
/* close and reset control pipe */
close(netlink_control_pipe[0]);
close(netlink_control_pipe[1]);
netlink_control_pipe[0] = -1;
netlink_control_pipe[1] = -1;
return LIBUSB_SUCCESS;
}
@ -145,8 +224,32 @@ static int linux_netlink_parse(char *buffer, size_t len, int *detached, const ch
tmp = netlink_message_parse(buffer, len, "BUSNUM");
if (NULL == tmp) {
/* no bus number (likely a usb interface). ignore*/
return -1;
/* no bus number. try "DEVICE" */
tmp = netlink_message_parse(buffer, len, "DEVICE");
if (NULL == tmp) {
/* not usb. ignore */
return -1;
}
/* Parse a device path such as /dev/bus/usb/003/004 */
char *pLastSlash = (char*)strrchr(tmp,'/');
if(NULL == pLastSlash) {
return -1;
}
*devaddr = strtoul(pLastSlash + 1, NULL, 10);
if (errno) {
errno = 0;
return -1;
}
*busnum = strtoul(pLastSlash - 3, NULL, 10);
if (errno) {
errno = 0;
return -1;
}
return 0;
}
*busnum = (uint8_t)(strtoul(tmp, NULL, 10) & 0xff);
@ -214,7 +317,7 @@ static int linux_netlink_read_message(void)
/* signal device is available (or not) to all contexts */
if (detached)
linux_hotplug_disconnected(busnum, devaddr, sys_name);
linux_device_disconnected(busnum, devaddr, sys_name);
else
linux_hotplug_enumerate(busnum, devaddr, sys_name);
@ -223,20 +326,32 @@ static int linux_netlink_read_message(void)
static void *linux_netlink_event_thread_main(void *arg)
{
struct pollfd fds = {.fd = linux_netlink_socket,
.events = POLLIN};
char dummy;
int r;
struct pollfd fds[] = {
{ .fd = netlink_control_pipe[0],
.events = POLLIN },
{ .fd = linux_netlink_socket,
.events = POLLIN },
};
/* silence compiler warning */
(void) arg;
while (1 == poll(&fds, 1, -1)) {
if (POLLIN != fds.revents) {
while (poll(fds, 2, -1) >= 0) {
if (fds[0].revents & POLLIN) {
/* activity on control pipe, read the byte and exit */
r = usbi_read(netlink_control_pipe[0], &dummy, sizeof(dummy));
if (r <= 0) {
usbi_warn(NULL, "netlink control pipe read failed");
}
break;
}
usbi_mutex_static_lock(&linux_hotplug_lock);
linux_netlink_read_message();
usbi_mutex_static_unlock(&linux_hotplug_lock);
if (fds[1].revents & POLLIN) {
usbi_mutex_static_lock(&linux_hotplug_lock);
linux_netlink_read_message();
usbi_mutex_static_unlock(&linux_hotplug_lock);
}
}
return NULL;

View File

@ -46,6 +46,7 @@
/* udev context */
static struct udev *udev_ctx = NULL;
static int udev_monitor_fd = -1;
static int udev_control_pipe[2] = {-1, -1};
static struct udev_monitor *udev_monitor = NULL;
static pthread_t linux_event_thread;
@ -60,7 +61,7 @@ int linux_udev_start_event_monitor(void)
udev_ctx = udev_new();
if (!udev_ctx) {
usbi_err(NULL, "could not create udev context");
return LIBUSB_ERROR_OTHER;
goto err;
}
udev_monitor = udev_monitor_new_from_netlink(udev_ctx, "udev");
@ -95,34 +96,49 @@ int linux_udev_start_event_monitor(void)
goto err_free_monitor;
}
r = usbi_pipe(udev_control_pipe);
if (r) {
usbi_err(NULL, "could not create udev control pipe");
goto err_free_monitor;
}
r = pthread_create(&linux_event_thread, NULL, linux_udev_event_thread_main, NULL);
if (r) {
usbi_err(NULL, "creating hotplug event thread (%d)", r);
goto err_free_monitor;
goto err_close_pipe;
}
return LIBUSB_SUCCESS;
err_close_pipe:
close(udev_control_pipe[0]);
close(udev_control_pipe[1]);
err_free_monitor:
udev_monitor_unref(udev_monitor);
udev_monitor = NULL;
udev_monitor_fd = -1;
err_free_ctx:
udev_unref(udev_ctx);
err:
udev_ctx = NULL;
return LIBUSB_ERROR_OTHER;
}
int linux_udev_stop_event_monitor(void)
{
char dummy = 1;
int r;
assert(udev_ctx != NULL);
assert(udev_monitor != NULL);
assert(udev_monitor_fd != -1);
/* Cancel the event thread. This is the only way to guarantee the
thread exits since closing the monitor fd won't necessarily cause
poll to return. */
pthread_cancel(linux_event_thread);
/* Write some dummy data to the control pipe and
* wait for the thread to exit */
r = usbi_write(udev_control_pipe[1], &dummy, sizeof(dummy));
if (r <= 0) {
usbi_warn(NULL, "udev control pipe signal failed");
}
pthread_join(linux_event_thread, NULL);
/* Release the udev monitor */
@ -134,27 +150,45 @@ int linux_udev_stop_event_monitor(void)
udev_unref(udev_ctx);
udev_ctx = NULL;
/* close and reset control pipe */
close(udev_control_pipe[0]);
close(udev_control_pipe[1]);
udev_control_pipe[0] = -1;
udev_control_pipe[1] = -1;
return LIBUSB_SUCCESS;
}
static void *linux_udev_event_thread_main(void *arg)
{
char dummy;
int r;
struct udev_device* udev_dev;
struct pollfd fds = {.fd = udev_monitor_fd,
.events = POLLIN};
struct pollfd fds[] = {
{.fd = udev_control_pipe[0],
.events = POLLIN},
{.fd = udev_monitor_fd,
.events = POLLIN},
};
usbi_dbg("udev event thread entering.");
while (1 == poll(&fds, 1, -1)) {
if (NULL == udev_monitor || POLLIN != fds.revents) {
while (poll(fds, 2, -1) >= 0) {
if (fds[0].revents & POLLIN) {
/* activity on control pipe, read the byte and exit */
r = usbi_read(udev_control_pipe[0], &dummy, sizeof(dummy));
if (r <= 0) {
usbi_warn(NULL, "udev control pipe read failed");
}
break;
}
usbi_mutex_static_lock(&linux_hotplug_lock);
udev_dev = udev_monitor_receive_device(udev_monitor);
if (udev_dev)
udev_hotplug_event(udev_dev);
usbi_mutex_static_unlock(&linux_hotplug_lock);
if (fds[1].revents & POLLIN) {
usbi_mutex_static_lock(&linux_hotplug_lock);
udev_dev = udev_monitor_receive_device(udev_monitor);
if (udev_dev)
udev_hotplug_event(udev_dev);
usbi_mutex_static_unlock(&linux_hotplug_lock);
}
}
usbi_dbg("udev event thread exiting");
@ -207,7 +241,7 @@ static void udev_hotplug_event(struct udev_device* udev_dev)
if (strncmp(udev_action, "add", 3) == 0) {
linux_hotplug_enumerate(busnum, devaddr, sys_name);
} else if (detached) {
linux_hotplug_disconnected(busnum, devaddr, sys_name);
linux_device_disconnected(busnum, devaddr, sys_name);
} else {
usbi_err(NULL, "ignoring udev action %s", udev_action);
}

View File

@ -1,5 +1,6 @@
/* -*- Mode: C; c-basic-offset:8 ; indent-tabs-mode:t -*- */
/*
* Linux usbfs backend for libusbx
* Linux usbfs backend for libusb
* Copyright © 2007-2009 Daniel Drake <dsd@gentoo.org>
* Copyright © 2001 Johannes Erdfelt <johannes@erdfelt.com>
* Copyright © 2013 Nathan Hjelm <hjelmn@mac.com>
@ -48,7 +49,7 @@
* sysfs allows us to read the kernel's in-memory copies of device descriptors
* and so forth, avoiding the need to open the device:
* - The binary "descriptors" file contains all config descriptors since
* 2.6.26, commit 217a9081d8e69026186067711131b77f0ce219ed
* 2.6.26, commit 217a9081d8e69026186067711131b77f0ce219ed
* - The binary "descriptors" file was added in 2.6.23, commit
* 69d42a78f935d19384d1f6e4f94b65bb162b36df, but it only contains the
* active config descriptors
@ -118,9 +119,11 @@ static int sysfs_can_relate_devices = -1;
static int sysfs_has_descriptors = -1;
/* how many times have we initted (and not exited) ? */
static volatile int init_count = 0;
static int init_count = 0;
/* Serialize hotplug start/stop, scan-devices, event-thread, and poll */
/* Serialize hotplug start/stop */
usbi_mutex_static_t linux_hotplug_startstop_lock = USBI_MUTEX_INITIALIZER;
/* Serialize scan-devices, event-thread, and poll */
usbi_mutex_static_t linux_hotplug_lock = USBI_MUTEX_INITIALIZER;
static int linux_start_event_monitor(void);
@ -181,6 +184,7 @@ static int _get_usbfs_fd(struct libusb_device *dev, mode_t mode, int silent)
struct libusb_context *ctx = DEVICE_CTX(dev);
char path[PATH_MAX];
int fd;
int delay = 10000;
if (usbdev_names)
snprintf(path, PATH_MAX, "%s/usbdev%d.%d",
@ -193,11 +197,23 @@ static int _get_usbfs_fd(struct libusb_device *dev, mode_t mode, int silent)
if (fd != -1)
return fd; /* Success */
if (errno == ENOENT) {
if (!silent)
usbi_err(ctx, "File doesn't exist, wait %d ms and try again\n", delay/1000);
/* Wait 10ms for USB device path creation.*/
usleep(delay);
fd = open(path, mode);
if (fd != -1)
return fd; /* Success */
}
if (!silent) {
usbi_err(ctx, "libusbx couldn't open USB device %s: %s",
usbi_err(ctx, "libusb couldn't open USB device %s: %s",
path, strerror(errno));
if (errno == EACCES && mode == O_RDWR)
usbi_err(ctx, "libusbx requires write access to USB "
usbi_err(ctx, "libusb requires write access to USB "
"device nodes.");
}
@ -419,7 +435,7 @@ static int op_init(struct libusb_context *ctx)
if (sysfs_has_descriptors)
usbi_dbg("sysfs has complete descriptors");
usbi_mutex_static_lock(&linux_hotplug_lock);
usbi_mutex_static_lock(&linux_hotplug_startstop_lock);
r = LIBUSB_SUCCESS;
if (init_count == 0) {
/* start up hotplug event handler */
@ -433,20 +449,20 @@ static int op_init(struct libusb_context *ctx)
linux_stop_event_monitor();
} else
usbi_err(ctx, "error starting hotplug event monitor");
usbi_mutex_static_unlock(&linux_hotplug_lock);
usbi_mutex_static_unlock(&linux_hotplug_startstop_lock);
return r;
}
static void op_exit(void)
{
usbi_mutex_static_lock(&linux_hotplug_lock);
usbi_mutex_static_lock(&linux_hotplug_startstop_lock);
assert(init_count != 0);
if (!--init_count) {
/* tear down event handler */
(void)linux_stop_event_monitor();
}
usbi_mutex_static_unlock(&linux_hotplug_lock);
usbi_mutex_static_unlock(&linux_hotplug_startstop_lock);
}
static int linux_start_event_monitor(void)
@ -469,11 +485,19 @@ static int linux_stop_event_monitor(void)
static int linux_scan_devices(struct libusb_context *ctx)
{
int ret;
usbi_mutex_static_lock(&linux_hotplug_lock);
#if defined(USE_UDEV)
return linux_udev_scan_devices(ctx);
ret = linux_udev_scan_devices(ctx);
#else
return linux_default_scan_devices(ctx);
ret = linux_default_scan_devices(ctx);
#endif
usbi_mutex_static_unlock(&linux_hotplug_lock);
return ret;
}
static void op_hotplug_poll(void)
@ -553,7 +577,7 @@ static int op_get_device_descriptor(struct libusb_device *dev,
static int sysfs_get_active_config(struct libusb_device *dev, int *config)
{
char *endptr;
char tmp[4] = {0, 0, 0, 0};
char tmp[5] = {0, 0, 0, 0, 0};
long num;
int fd;
ssize_t r;
@ -565,7 +589,7 @@ static int sysfs_get_active_config(struct libusb_device *dev, int *config)
r = read(fd, tmp, sizeof(tmp));
close(fd);
if (r < 0) {
usbi_err(DEVICE_CTX(dev),
usbi_err(DEVICE_CTX(dev),
"read bConfigurationValue failed ret=%d errno=%d", r, errno);
return LIBUSB_ERROR_IO;
} else if (r == 0) {
@ -596,6 +620,8 @@ int linux_get_device_address (struct libusb_context *ctx, int detached,
uint8_t *busnum, uint8_t *devaddr,const char *dev_node,
const char *sys_name)
{
int sysfs_attr;
usbi_dbg("getting address for device: %s detached: %d", sys_name, detached);
/* can't use sysfs to read the bus and device number if the
* device has been detached */
@ -616,17 +642,22 @@ int linux_get_device_address (struct libusb_context *ctx, int detached,
usbi_dbg("scan %s", sys_name);
*busnum = __read_sysfs_attr(ctx, sys_name, "busnum");
if (0 > *busnum)
return *busnum;
sysfs_attr = __read_sysfs_attr(ctx, sys_name, "busnum");
if (0 > sysfs_attr)
return sysfs_attr;
if (sysfs_attr > 255)
return LIBUSB_ERROR_INVALID_PARAM;
*busnum = (uint8_t) sysfs_attr;
*devaddr = __read_sysfs_attr(ctx, sys_name, "devnum");
if (0 > *devaddr)
return *devaddr;
sysfs_attr = __read_sysfs_attr(ctx, sys_name, "devnum");
if (0 > sysfs_attr)
return sysfs_attr;
if (sysfs_attr > 255)
return LIBUSB_ERROR_INVALID_PARAM;
*devaddr = (uint8_t) sysfs_attr;
usbi_dbg("bus=%d dev=%d", *busnum, *devaddr);
if (*busnum > 255 || *devaddr > 255)
return LIBUSB_ERROR_INVALID_PARAM;
return LIBUSB_SUCCESS;
}
@ -895,7 +926,7 @@ static int initialize_device(struct libusb_device *dev, uint8_t busnum,
}
priv->descriptors_len += r;
} while (priv->descriptors_len == descriptors_size);
close(fd);
if (priv->descriptors_len < DEVICE_DESC_LENGTH) {
@ -1030,9 +1061,11 @@ int linux_enumerate_device(struct libusb_context *ctx,
usbi_dbg("busnum %d devaddr %d session_id %ld", busnum, devaddr,
session_id);
if (usbi_get_device_by_session_id(ctx, session_id)) {
dev = usbi_get_device_by_session_id(ctx, session_id);
if (dev) {
/* device already exists in the context */
usbi_dbg("session_id %ld already exists", session_id);
libusb_unref_device(dev);
return LIBUSB_SUCCESS;
}
@ -1072,7 +1105,7 @@ void linux_hotplug_enumerate(uint8_t busnum, uint8_t devaddr, const char *sys_na
usbi_mutex_static_unlock(&active_contexts_lock);
}
void linux_hotplug_disconnected(uint8_t busnum, uint8_t devaddr, const char *sys_name)
void linux_device_disconnected(uint8_t busnum, uint8_t devaddr, const char *sys_name)
{
struct libusb_context *ctx;
struct libusb_device *dev;
@ -1083,6 +1116,7 @@ void linux_hotplug_disconnected(uint8_t busnum, uint8_t devaddr, const char *sys
dev = usbi_get_device_by_session_id (ctx, session_id);
if (NULL != dev) {
usbi_disconnect_device (dev);
libusb_unref_device(dev);
} else {
usbi_dbg("device not found for session %x", session_id);
}
@ -1247,8 +1281,20 @@ static int op_open(struct libusb_device_handle *handle)
int r;
hpriv->fd = _get_usbfs_fd(handle->dev, O_RDWR, 0);
if (hpriv->fd < 0)
if (hpriv->fd < 0) {
if (hpriv->fd == LIBUSB_ERROR_NO_DEVICE) {
/* device will still be marked as attached if hotplug monitor thread
* hasn't processed remove event yet */
usbi_mutex_static_lock(&linux_hotplug_lock);
if (handle->dev->attached) {
usbi_dbg("open failed with no device, but device still attached");
linux_device_disconnected(handle->dev->bus_number,
handle->dev->device_address, NULL);
}
usbi_mutex_static_unlock(&linux_hotplug_lock);
}
return hpriv->fd;
}
r = ioctl(hpriv->fd, IOCTL_USBFS_GET_CAPABILITIES, &hpriv->caps);
if (r < 0) {
@ -1449,6 +1495,56 @@ out:
return ret;
}
static int do_streams_ioctl(struct libusb_device_handle *handle, long req,
uint32_t num_streams, unsigned char *endpoints, int num_endpoints)
{
int r, fd = _device_handle_priv(handle)->fd;
struct usbfs_streams *streams;
if (num_endpoints > 30) /* Max 15 in + 15 out eps */
return LIBUSB_ERROR_INVALID_PARAM;
streams = malloc(sizeof(struct usbfs_streams) + num_endpoints);
if (!streams)
return LIBUSB_ERROR_NO_MEM;
streams->num_streams = num_streams;
streams->num_eps = num_endpoints;
memcpy(streams->eps, endpoints, num_endpoints);
r = ioctl(fd, req, streams);
free(streams);
if (r < 0) {
if (errno == ENOTTY)
return LIBUSB_ERROR_NOT_SUPPORTED;
else if (errno == EINVAL)
return LIBUSB_ERROR_INVALID_PARAM;
else if (errno == ENODEV)
return LIBUSB_ERROR_NO_DEVICE;
usbi_err(HANDLE_CTX(handle),
"streams-ioctl failed error %d errno %d", r, errno);
return LIBUSB_ERROR_OTHER;
}
return r;
}
static int op_alloc_streams(struct libusb_device_handle *handle,
uint32_t num_streams, unsigned char *endpoints, int num_endpoints)
{
return do_streams_ioctl(handle, IOCTL_USBFS_ALLOC_STREAMS,
num_streams, endpoints, num_endpoints);
}
static int op_free_streams(struct libusb_device_handle *handle,
unsigned char *endpoints, int num_endpoints)
{
return do_streams_ioctl(handle, IOCTL_USBFS_FREE_STREAMS, 0,
endpoints, num_endpoints);
}
static int op_kernel_driver_active(struct libusb_device_handle *handle,
int interface)
{
@ -1656,8 +1752,7 @@ static void free_iso_urbs(struct linux_transfer_priv *tpriv)
tpriv->iso_urbs = NULL;
}
static int submit_bulk_transfer(struct usbi_transfer *itransfer,
unsigned char urb_type)
static int submit_bulk_transfer(struct usbi_transfer *itransfer)
{
struct libusb_transfer *transfer =
USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
@ -1745,7 +1840,19 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer,
for (i = 0; i < num_urbs; i++) {
struct usbfs_urb *urb = &urbs[i];
urb->usercontext = itransfer;
urb->type = urb_type;
switch (transfer->type) {
case LIBUSB_TRANSFER_TYPE_BULK:
urb->type = USBFS_URB_TYPE_BULK;
urb->stream_id = 0;
break;
case LIBUSB_TRANSFER_TYPE_BULK_STREAM:
urb->type = USBFS_URB_TYPE_BULK;
urb->stream_id = itransfer->stream_id;
break;
case LIBUSB_TRANSFER_TYPE_INTERRUPT:
urb->type = USBFS_URB_TYPE_INTERRUPT;
break;
}
urb->endpoint = transfer->endpoint;
urb->buffer = transfer->buffer + (i * bulk_buffer_len);
/* don't set the short not ok flag for the last URB */
@ -1775,7 +1882,7 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer,
"submiturb failed error %d errno=%d", r, errno);
r = LIBUSB_ERROR_IO;
}
/* if the first URB submission fails, we can simply free up and
* return failure immediately. */
if (i == 0) {
@ -1790,7 +1897,7 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer,
* complications:
* - discarding is asynchronous - discarded urbs will be reaped
* later. the user must not have freed the transfer when the
* discarded URBs are reaped, otherwise libusbx will be using
* discarded URBs are reaped, otherwise libusb will be using
* freed memory.
* - the earlier URBs may have completed successfully and we do
* not want to throw away any data.
@ -1952,7 +2059,7 @@ static int submit_iso_transfer(struct usbi_transfer *itransfer)
* complications:
* - discarding is asynchronous - discarded urbs will be reaped
* later. the user must not have freed the transfer when the
* discarded URBs are reaped, otherwise libusbx will be using
* discarded URBs are reaped, otherwise libusb will be using
* freed memory.
* - the earlier URBs may have completed successfully and we do
* not want to throw away any data.
@ -2028,9 +2135,10 @@ static int op_submit_transfer(struct usbi_transfer *itransfer)
case LIBUSB_TRANSFER_TYPE_CONTROL:
return submit_control_transfer(itransfer);
case LIBUSB_TRANSFER_TYPE_BULK:
return submit_bulk_transfer(itransfer, USBFS_URB_TYPE_BULK);
case LIBUSB_TRANSFER_TYPE_BULK_STREAM:
return submit_bulk_transfer(itransfer);
case LIBUSB_TRANSFER_TYPE_INTERRUPT:
return submit_bulk_transfer(itransfer, USBFS_URB_TYPE_INTERRUPT);
return submit_bulk_transfer(itransfer);
case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
return submit_iso_transfer(itransfer);
default:
@ -2048,6 +2156,7 @@ static int op_cancel_transfer(struct usbi_transfer *itransfer)
switch (transfer->type) {
case LIBUSB_TRANSFER_TYPE_BULK:
case LIBUSB_TRANSFER_TYPE_BULK_STREAM:
if (tpriv->reap_action == ERROR)
break;
/* else, fall through */
@ -2078,6 +2187,7 @@ static void op_clear_transfer_priv(struct usbi_transfer *itransfer)
switch (transfer->type) {
case LIBUSB_TRANSFER_TYPE_CONTROL:
case LIBUSB_TRANSFER_TYPE_BULK:
case LIBUSB_TRANSFER_TYPE_BULK_STREAM:
case LIBUSB_TRANSFER_TYPE_INTERRUPT:
usbi_mutex_lock(&itransfer->lock);
if (tpriv->urbs)
@ -2127,7 +2237,7 @@ static int handle_bulk_completion(struct usbi_transfer *itransfer,
*
* When this happens, our objectives are not to lose any "surplus" data,
* and also to stick it at the end of the previously-received data
* (closing any holes), so that libusbx reports the total amount of
* (closing any holes), so that libusb reports the total amount of
* transferred data and presents it in a contiguous chunk.
*/
if (urb->actual_length > 0) {
@ -2446,6 +2556,7 @@ static int reap_for_handle(struct libusb_device_handle *handle)
case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
return handle_iso_completion(itransfer, urb);
case LIBUSB_TRANSFER_TYPE_BULK:
case LIBUSB_TRANSFER_TYPE_BULK_STREAM:
case LIBUSB_TRANSFER_TYPE_INTERRUPT:
return handle_bulk_completion(itransfer, urb);
case LIBUSB_TRANSFER_TYPE_CONTROL:
@ -2479,9 +2590,22 @@ static int op_handle_events(struct libusb_context *ctx,
break;
}
if (!hpriv || hpriv->fd != pollfd->fd) {
usbi_err(ctx, "cannot find handle for fd %d\n",
pollfd->fd);
continue;
}
if (pollfd->revents & POLLERR) {
usbi_remove_pollfd(HANDLE_CTX(handle), hpriv->fd);
usbi_handle_disconnect(handle);
/* device will still be marked as attached if hotplug monitor thread
* hasn't processed remove event yet */
usbi_mutex_static_lock(&linux_hotplug_lock);
if (handle->dev->attached)
linux_device_disconnected(handle->dev->bus_number,
handle->dev->device_address, NULL);
usbi_mutex_static_unlock(&linux_hotplug_lock);
continue;
}
@ -2543,6 +2667,9 @@ const struct usbi_os_backend linux_usbfs_backend = {
.clear_halt = op_clear_halt,
.reset_device = op_reset_device,
.alloc_streams = op_alloc_streams,
.free_streams = op_free_streams,
.kernel_driver_active = op_kernel_driver_active,
.detach_kernel_driver = op_detach_kernel_driver,
.attach_kernel_driver = op_attach_kernel_driver,

View File

@ -94,7 +94,10 @@ struct usbfs_urb {
int buffer_length;
int actual_length;
int start_frame;
int number_of_packets;
union {
int number_of_packets; /* Only used for isoc urbs */
unsigned int stream_id; /* Only used with bulk streams */
};
int error_count;
unsigned int signr;
void *usercontext;
@ -132,6 +135,12 @@ struct usbfs_disconnect_claim {
char driver[USBFS_MAXDRIVERNAME + 1];
};
struct usbfs_streams {
unsigned int num_streams; /* Not used by USBDEVFS_FREE_STREAMS */
unsigned int num_eps;
unsigned char eps[0];
};
#define IOCTL_USBFS_CONTROL _IOWR('U', 0, struct usbfs_ctrltransfer)
#define IOCTL_USBFS_BULK _IOWR('U', 2, struct usbfs_bulktransfer)
#define IOCTL_USBFS_RESETEP _IOR('U', 3, unsigned int)
@ -155,6 +164,8 @@ struct usbfs_disconnect_claim {
#define IOCTL_USBFS_RELEASE_PORT _IOR('U', 25, unsigned int)
#define IOCTL_USBFS_GET_CAPABILITIES _IOR('U', 26, __u32)
#define IOCTL_USBFS_DISCONNECT_CLAIM _IOR('U', 27, struct usbfs_disconnect_claim)
#define IOCTL_USBFS_ALLOC_STREAMS _IOR('U', 28, struct usbfs_streams)
#define IOCTL_USBFS_FREE_STREAMS _IOR('U', 29, struct usbfs_streams)
extern usbi_mutex_static_t linux_hotplug_lock;
@ -170,7 +181,7 @@ void linux_netlink_hotplug_poll(void);
#endif
void linux_hotplug_enumerate(uint8_t busnum, uint8_t devaddr, const char *sys_name);
void linux_hotplug_disconnected(uint8_t busnum, uint8_t devaddr, const char *sys_name);
void linux_device_disconnected(uint8_t busnum, uint8_t devaddr, const char *sys_name);
int linux_get_device_address (struct libusb_context *ctx, int detached,
uint8_t *busnum, uint8_t *devaddr, const char *dev_node,

View File

@ -47,36 +47,36 @@ struct handle_priv {
/*
* Backend functions
*/
static int obsd_get_device_list(struct libusb_context *,
static int netbsd_get_device_list(struct libusb_context *,
struct discovered_devs **);
static int obsd_open(struct libusb_device_handle *);
static void obsd_close(struct libusb_device_handle *);
static int netbsd_open(struct libusb_device_handle *);
static void netbsd_close(struct libusb_device_handle *);
static int obsd_get_device_descriptor(struct libusb_device *, unsigned char *,
static int netbsd_get_device_descriptor(struct libusb_device *, unsigned char *,
int *);
static int obsd_get_active_config_descriptor(struct libusb_device *,
static int netbsd_get_active_config_descriptor(struct libusb_device *,
unsigned char *, size_t, int *);
static int obsd_get_config_descriptor(struct libusb_device *, uint8_t,
static int netbsd_get_config_descriptor(struct libusb_device *, uint8_t,
unsigned char *, size_t, int *);
static int obsd_get_configuration(struct libusb_device_handle *, int *);
static int obsd_set_configuration(struct libusb_device_handle *, int);
static int netbsd_get_configuration(struct libusb_device_handle *, int *);
static int netbsd_set_configuration(struct libusb_device_handle *, int);
static int obsd_claim_interface(struct libusb_device_handle *, int);
static int obsd_release_interface(struct libusb_device_handle *, int);
static int netbsd_claim_interface(struct libusb_device_handle *, int);
static int netbsd_release_interface(struct libusb_device_handle *, int);
static int obsd_set_interface_altsetting(struct libusb_device_handle *, int,
static int netbsd_set_interface_altsetting(struct libusb_device_handle *, int,
int);
static int obsd_clear_halt(struct libusb_device_handle *, unsigned char);
static int obsd_reset_device(struct libusb_device_handle *);
static void obsd_destroy_device(struct libusb_device *);
static int netbsd_clear_halt(struct libusb_device_handle *, unsigned char);
static int netbsd_reset_device(struct libusb_device_handle *);
static void netbsd_destroy_device(struct libusb_device *);
static int obsd_submit_transfer(struct usbi_transfer *);
static int obsd_cancel_transfer(struct usbi_transfer *);
static void obsd_clear_transfer_priv(struct usbi_transfer *);
static int obsd_handle_events(struct libusb_context *ctx, struct pollfd *,
static int netbsd_submit_transfer(struct usbi_transfer *);
static int netbsd_cancel_transfer(struct usbi_transfer *);
static void netbsd_clear_transfer_priv(struct usbi_transfer *);
static int netbsd_handle_events(struct libusb_context *ctx, struct pollfd *,
nfds_t, int);
static int obsd_clock_gettime(int, struct timespec *);
static int netbsd_clock_gettime(int, struct timespec *);
/*
* Private functions
@ -87,44 +87,47 @@ static int _sync_control_transfer(struct usbi_transfer *);
static int _sync_gen_transfer(struct usbi_transfer *);
static int _access_endpoint(struct libusb_transfer *);
const struct usbi_os_backend openbsd_backend = {
"Synchronous OpenBSD backend",
const struct usbi_os_backend netbsd_backend = {
"Synchronous NetBSD backend",
0,
NULL, /* init() */
NULL, /* exit() */
obsd_get_device_list,
netbsd_get_device_list,
NULL, /* hotplug_poll */
obsd_open,
obsd_close,
netbsd_open,
netbsd_close,
obsd_get_device_descriptor,
obsd_get_active_config_descriptor,
obsd_get_config_descriptor,
netbsd_get_device_descriptor,
netbsd_get_active_config_descriptor,
netbsd_get_config_descriptor,
NULL, /* get_config_descriptor_by_value() */
obsd_get_configuration,
obsd_set_configuration,
netbsd_get_configuration,
netbsd_set_configuration,
obsd_claim_interface,
obsd_release_interface,
netbsd_claim_interface,
netbsd_release_interface,
obsd_set_interface_altsetting,
obsd_clear_halt,
obsd_reset_device,
netbsd_set_interface_altsetting,
netbsd_clear_halt,
netbsd_reset_device,
NULL, /* alloc_streams */
NULL, /* free_streams */
NULL, /* kernel_driver_active() */
NULL, /* detach_kernel_driver() */
NULL, /* attach_kernel_driver() */
obsd_destroy_device,
netbsd_destroy_device,
obsd_submit_transfer,
obsd_cancel_transfer,
obsd_clear_transfer_priv,
netbsd_submit_transfer,
netbsd_cancel_transfer,
netbsd_clear_transfer_priv,
obsd_handle_events,
netbsd_handle_events,
obsd_clock_gettime,
netbsd_clock_gettime,
sizeof(struct device_priv),
sizeof(struct handle_priv),
0, /* transfer_priv_size */
@ -132,7 +135,7 @@ const struct usbi_os_backend openbsd_backend = {
};
int
obsd_get_device_list(struct libusb_context * ctx,
netbsd_get_device_list(struct libusb_context * ctx,
struct discovered_devs **discdevs)
{
struct libusb_device *dev;
@ -161,9 +164,7 @@ obsd_get_device_list(struct libusb_context * ctx,
session_id = (di.udi_bus << 8 | di.udi_addr);
dev = usbi_get_device_by_session_id(ctx, session_id);
if (dev) {
dev = libusb_ref_device(dev);
} else {
if (dev == NULL) {
dev = usbi_alloc_device(ctx, session_id);
if (dev == NULL)
return (LIBUSB_ERROR_NO_MEM);
@ -207,7 +208,7 @@ error:
}
int
obsd_open(struct libusb_device_handle *handle)
netbsd_open(struct libusb_device_handle *handle)
{
struct handle_priv *hpriv = (struct handle_priv *)handle->os_priv;
struct device_priv *dpriv = (struct device_priv *)handle->dev->os_priv;
@ -228,7 +229,7 @@ obsd_open(struct libusb_device_handle *handle)
}
void
obsd_close(struct libusb_device_handle *handle)
netbsd_close(struct libusb_device_handle *handle)
{
struct handle_priv *hpriv = (struct handle_priv *)handle->os_priv;
struct device_priv *dpriv = (struct device_priv *)handle->dev->os_priv;
@ -245,7 +246,7 @@ obsd_close(struct libusb_device_handle *handle)
}
int
obsd_get_device_descriptor(struct libusb_device *dev, unsigned char *buf,
netbsd_get_device_descriptor(struct libusb_device *dev, unsigned char *buf,
int *host_endian)
{
struct device_priv *dpriv = (struct device_priv *)dev->os_priv;
@ -260,7 +261,7 @@ obsd_get_device_descriptor(struct libusb_device *dev, unsigned char *buf,
}
int
obsd_get_active_config_descriptor(struct libusb_device *dev,
netbsd_get_active_config_descriptor(struct libusb_device *dev,
unsigned char *buf, size_t len, int *host_endian)
{
struct device_priv *dpriv = (struct device_priv *)dev->os_priv;
@ -279,7 +280,7 @@ obsd_get_active_config_descriptor(struct libusb_device *dev,
}
int
obsd_get_config_descriptor(struct libusb_device *dev, uint8_t idx,
netbsd_get_config_descriptor(struct libusb_device *dev, uint8_t idx,
unsigned char *buf, size_t len, int *host_endian)
{
struct device_priv *dpriv = (struct device_priv *)dev->os_priv;
@ -317,7 +318,7 @@ obsd_get_config_descriptor(struct libusb_device *dev, uint8_t idx,
}
int
obsd_get_configuration(struct libusb_device_handle *handle, int *config)
netbsd_get_configuration(struct libusb_device_handle *handle, int *config)
{
struct device_priv *dpriv = (struct device_priv *)handle->dev->os_priv;
@ -332,7 +333,7 @@ obsd_get_configuration(struct libusb_device_handle *handle, int *config)
}
int
obsd_set_configuration(struct libusb_device_handle *handle, int config)
netbsd_set_configuration(struct libusb_device_handle *handle, int config)
{
struct device_priv *dpriv = (struct device_priv *)handle->dev->os_priv;
@ -345,7 +346,7 @@ obsd_set_configuration(struct libusb_device_handle *handle, int config)
}
int
obsd_claim_interface(struct libusb_device_handle *handle, int iface)
netbsd_claim_interface(struct libusb_device_handle *handle, int iface)
{
struct handle_priv *hpriv = (struct handle_priv *)handle->os_priv;
int i;
@ -357,7 +358,7 @@ obsd_claim_interface(struct libusb_device_handle *handle, int iface)
}
int
obsd_release_interface(struct libusb_device_handle *handle, int iface)
netbsd_release_interface(struct libusb_device_handle *handle, int iface)
{
struct handle_priv *hpriv = (struct handle_priv *)handle->os_priv;
int i;
@ -370,7 +371,7 @@ obsd_release_interface(struct libusb_device_handle *handle, int iface)
}
int
obsd_set_interface_altsetting(struct libusb_device_handle *handle, int iface,
netbsd_set_interface_altsetting(struct libusb_device_handle *handle, int iface,
int altsetting)
{
struct device_priv *dpriv = (struct device_priv *)handle->dev->os_priv;
@ -390,7 +391,7 @@ obsd_set_interface_altsetting(struct libusb_device_handle *handle, int iface,
}
int
obsd_clear_halt(struct libusb_device_handle *handle, unsigned char endpoint)
netbsd_clear_halt(struct libusb_device_handle *handle, unsigned char endpoint)
{
struct device_priv *dpriv = (struct device_priv *)handle->dev->os_priv;
struct usb_ctl_request req;
@ -410,7 +411,7 @@ obsd_clear_halt(struct libusb_device_handle *handle, unsigned char endpoint)
}
int
obsd_reset_device(struct libusb_device_handle *handle)
netbsd_reset_device(struct libusb_device_handle *handle)
{
usbi_dbg("");
@ -418,7 +419,7 @@ obsd_reset_device(struct libusb_device_handle *handle)
}
void
obsd_destroy_device(struct libusb_device *dev)
netbsd_destroy_device(struct libusb_device *dev)
{
struct device_priv *dpriv = (struct device_priv *)dev->os_priv;
@ -428,7 +429,7 @@ obsd_destroy_device(struct libusb_device *dev)
}
int
obsd_submit_transfer(struct usbi_transfer *itransfer)
netbsd_submit_transfer(struct usbi_transfer *itransfer)
{
struct libusb_transfer *transfer;
struct handle_priv *hpriv;
@ -460,6 +461,9 @@ obsd_submit_transfer(struct usbi_transfer *itransfer)
}
err = _sync_gen_transfer(itransfer);
break;
case LIBUSB_TRANSFER_TYPE_BULK_STREAM:
err = LIBUSB_ERROR_NOT_SUPPORTED;
break;
}
if (err)
@ -472,7 +476,7 @@ obsd_submit_transfer(struct usbi_transfer *itransfer)
}
int
obsd_cancel_transfer(struct usbi_transfer *itransfer)
netbsd_cancel_transfer(struct usbi_transfer *itransfer)
{
usbi_dbg("");
@ -480,7 +484,7 @@ obsd_cancel_transfer(struct usbi_transfer *itransfer)
}
void
obsd_clear_transfer_priv(struct usbi_transfer *itransfer)
netbsd_clear_transfer_priv(struct usbi_transfer *itransfer)
{
usbi_dbg("");
@ -488,7 +492,7 @@ obsd_clear_transfer_priv(struct usbi_transfer *itransfer)
}
int
obsd_handle_events(struct libusb_context *ctx, struct pollfd *fds, nfds_t nfds,
netbsd_handle_events(struct libusb_context *ctx, struct pollfd *fds, nfds_t nfds,
int num_ready)
{
struct libusb_device_handle *handle;
@ -548,7 +552,7 @@ obsd_handle_events(struct libusb_context *ctx, struct pollfd *fds, nfds_t nfds,
}
int
obsd_clock_gettime(int clkid, struct timespec *tp)
netbsd_clock_gettime(int clkid, struct timespec *tp)
{
usbi_dbg("clock %d", clkid);
@ -641,7 +645,7 @@ _sync_control_transfer(struct usbi_transfer *itransfer)
req.ucr_request.bmRequestType = setup->bmRequestType;
req.ucr_request.bRequest = setup->bRequest;
/* Don't use USETW, libusbx already deals with the endianness */
/* Don't use USETW, libusb already deals with the endianness */
(*(uint16_t *)req.ucr_request.wValue) = setup->wValue;
(*(uint16_t *)req.ucr_request.wIndex) = setup->wIndex;
(*(uint16_t *)req.ucr_request.wLength) = setup->wLength;

832
Externals/libusb/libusb/os/openbsd_usb.c vendored Normal file
View File

@ -0,0 +1,832 @@
/*
* Copyright © 2011-2013 Martin Pieuchot <mpi@openbsd.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <sys/time.h>
#include <sys/types.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <dev/usb/usb.h>
#include "libusb.h"
#include "libusbi.h"
struct device_priv {
char *devname; /* name of the ugen(4) node */
int fd; /* device file descriptor */
unsigned char *cdesc; /* active config descriptor */
usb_device_descriptor_t ddesc; /* usb device descriptor */
};
struct handle_priv {
int pipe[2]; /* for event notification */
int endpoints[USB_MAX_ENDPOINTS];
};
/*
* Backend functions
*/
static int obsd_get_device_list(struct libusb_context *,
struct discovered_devs **);
static int obsd_open(struct libusb_device_handle *);
static void obsd_close(struct libusb_device_handle *);
static int obsd_get_device_descriptor(struct libusb_device *, unsigned char *,
int *);
static int obsd_get_active_config_descriptor(struct libusb_device *,
unsigned char *, size_t, int *);
static int obsd_get_config_descriptor(struct libusb_device *, uint8_t,
unsigned char *, size_t, int *);
static int obsd_get_configuration(struct libusb_device_handle *, int *);
static int obsd_set_configuration(struct libusb_device_handle *, int);
static int obsd_claim_interface(struct libusb_device_handle *, int);
static int obsd_release_interface(struct libusb_device_handle *, int);
static int obsd_set_interface_altsetting(struct libusb_device_handle *, int,
int);
static int obsd_clear_halt(struct libusb_device_handle *, unsigned char);
static int obsd_reset_device(struct libusb_device_handle *);
static void obsd_destroy_device(struct libusb_device *);
static int obsd_submit_transfer(struct usbi_transfer *);
static int obsd_cancel_transfer(struct usbi_transfer *);
static void obsd_clear_transfer_priv(struct usbi_transfer *);
static int obsd_handle_events(struct libusb_context *ctx, struct pollfd *,
nfds_t, int);
static int obsd_clock_gettime(int, struct timespec *);
/*
* Private functions
*/
static int _errno_to_libusb(int);
static int _cache_active_config_descriptor(struct libusb_device *);
static int _sync_control_transfer(struct usbi_transfer *);
static int _sync_gen_transfer(struct usbi_transfer *);
static int _access_endpoint(struct libusb_transfer *);
static int _bus_open(int);
const struct usbi_os_backend openbsd_backend = {
"Synchronous OpenBSD backend",
0,
NULL, /* init() */
NULL, /* exit() */
obsd_get_device_list,
NULL, /* hotplug_poll */
obsd_open,
obsd_close,
obsd_get_device_descriptor,
obsd_get_active_config_descriptor,
obsd_get_config_descriptor,
NULL, /* get_config_descriptor_by_value() */
obsd_get_configuration,
obsd_set_configuration,
obsd_claim_interface,
obsd_release_interface,
obsd_set_interface_altsetting,
obsd_clear_halt,
obsd_reset_device,
NULL, /* alloc_streams */
NULL, /* free_streams */
NULL, /* kernel_driver_active() */
NULL, /* detach_kernel_driver() */
NULL, /* attach_kernel_driver() */
obsd_destroy_device,
obsd_submit_transfer,
obsd_cancel_transfer,
obsd_clear_transfer_priv,
obsd_handle_events,
obsd_clock_gettime,
sizeof(struct device_priv),
sizeof(struct handle_priv),
0, /* transfer_priv_size */
0, /* add_iso_packet_size */
};
#define DEVPATH "/dev/"
#define USBDEV DEVPATH "usb"
int
obsd_get_device_list(struct libusb_context * ctx,
struct discovered_devs **discdevs)
{
struct discovered_devs *ddd;
struct libusb_device *dev;
struct device_priv *dpriv;
struct usb_device_info di;
struct usb_device_ddesc dd;
unsigned long session_id;
char devices[USB_MAX_DEVICES];
char busnode[16];
char *udevname;
int fd, addr, i, j;
usbi_dbg("");
for (i = 0; i < 8; i++) {
snprintf(busnode, sizeof(busnode), USBDEV "%d", i);
if ((fd = open(busnode, O_RDWR)) < 0) {
if (errno != ENOENT && errno != ENXIO)
usbi_err(ctx, "could not open %s", busnode);
continue;
}
bzero(devices, sizeof(devices));
for (addr = 1; addr < USB_MAX_DEVICES; addr++) {
if (devices[addr])
continue;
di.udi_addr = addr;
if (ioctl(fd, USB_DEVICEINFO, &di) < 0)
continue;
/*
* XXX If ugen(4) is attached to the USB device
* it will be used.
*/
udevname = NULL;
for (j = 0; j < USB_MAX_DEVNAMES; j++)
if (!strncmp("ugen", di.udi_devnames[j], 4)) {
udevname = strdup(di.udi_devnames[j]);
break;
}
session_id = (di.udi_bus << 8 | di.udi_addr);
dev = usbi_get_device_by_session_id(ctx, session_id);
if (dev == NULL) {
dev = usbi_alloc_device(ctx, session_id);
if (dev == NULL) {
close(fd);
return (LIBUSB_ERROR_NO_MEM);
}
dev->bus_number = di.udi_bus;
dev->device_address = di.udi_addr;
dev->speed = di.udi_speed;
dpriv = (struct device_priv *)dev->os_priv;
dpriv->fd = -1;
dpriv->cdesc = NULL;
dpriv->devname = udevname;
dd.udd_bus = di.udi_bus;
dd.udd_addr = di.udi_addr;
if (ioctl(fd, USB_DEVICE_GET_DDESC, &dd) < 0) {
libusb_unref_device(dev);
continue;
}
dpriv->ddesc = dd.udd_desc;
if (_cache_active_config_descriptor(dev)) {
libusb_unref_device(dev);
continue;
}
if (usbi_sanitize_device(dev)) {
libusb_unref_device(dev);
continue;
}
}
ddd = discovered_devs_append(*discdevs, dev);
if (ddd == NULL) {
close(fd);
return (LIBUSB_ERROR_NO_MEM);
}
libusb_unref_device(dev);
*discdevs = ddd;
devices[addr] = 1;
}
close(fd);
}
return (LIBUSB_SUCCESS);
}
int
obsd_open(struct libusb_device_handle *handle)
{
struct handle_priv *hpriv = (struct handle_priv *)handle->os_priv;
struct device_priv *dpriv = (struct device_priv *)handle->dev->os_priv;
char devnode[16];
if (dpriv->devname) {
/*
* Only open ugen(4) attached devices read-write, all
* read-only operations are done through the bus node.
*/
snprintf(devnode, sizeof(devnode), DEVPATH "%s.00",
dpriv->devname);
dpriv->fd = open(devnode, O_RDWR);
if (dpriv->fd < 0)
return _errno_to_libusb(errno);
usbi_dbg("open %s: fd %d", devnode, dpriv->fd);
}
if (pipe(hpriv->pipe) < 0)
return _errno_to_libusb(errno);
return usbi_add_pollfd(HANDLE_CTX(handle), hpriv->pipe[0], POLLIN);
}
void
obsd_close(struct libusb_device_handle *handle)
{
struct handle_priv *hpriv = (struct handle_priv *)handle->os_priv;
struct device_priv *dpriv = (struct device_priv *)handle->dev->os_priv;
if (dpriv->devname) {
usbi_dbg("close: fd %d", dpriv->fd);
close(dpriv->fd);
dpriv->fd = -1;
}
usbi_remove_pollfd(HANDLE_CTX(handle), hpriv->pipe[0]);
close(hpriv->pipe[0]);
close(hpriv->pipe[1]);
}
int
obsd_get_device_descriptor(struct libusb_device *dev, unsigned char *buf,
int *host_endian)
{
struct device_priv *dpriv = (struct device_priv *)dev->os_priv;
usbi_dbg("");
memcpy(buf, &dpriv->ddesc, DEVICE_DESC_LENGTH);
*host_endian = 0;
return (LIBUSB_SUCCESS);
}
int
obsd_get_active_config_descriptor(struct libusb_device *dev,
unsigned char *buf, size_t len, int *host_endian)
{
struct device_priv *dpriv = (struct device_priv *)dev->os_priv;
usb_config_descriptor_t *ucd = (usb_config_descriptor_t *)dpriv->cdesc;
len = MIN(len, UGETW(ucd->wTotalLength));
usbi_dbg("len %d", len);
memcpy(buf, dpriv->cdesc, len);
*host_endian = 0;
return (len);
}
int
obsd_get_config_descriptor(struct libusb_device *dev, uint8_t idx,
unsigned char *buf, size_t len, int *host_endian)
{
struct usb_device_fdesc udf;
int fd, err;
if ((fd = _bus_open(dev->bus_number)) < 0)
return _errno_to_libusb(errno);
udf.udf_bus = dev->bus_number;
udf.udf_addr = dev->device_address;
udf.udf_config_index = idx;
udf.udf_size = len;
udf.udf_data = buf;
usbi_dbg("index %d, len %d", udf.udf_config_index, len);
if (ioctl(fd, USB_DEVICE_GET_FDESC, &udf) < 0) {
err = errno;
close(fd);
return _errno_to_libusb(err);
}
close(fd);
*host_endian = 0;
return (len);
}
int
obsd_get_configuration(struct libusb_device_handle *handle, int *config)
{
struct device_priv *dpriv = (struct device_priv *)handle->dev->os_priv;
usb_config_descriptor_t *ucd = (usb_config_descriptor_t *)dpriv->cdesc;
*config = ucd->bConfigurationValue;
usbi_dbg("bConfigurationValue %d", *config);
return (LIBUSB_SUCCESS);
}
int
obsd_set_configuration(struct libusb_device_handle *handle, int config)
{
struct device_priv *dpriv = (struct device_priv *)handle->dev->os_priv;
if (dpriv->devname == NULL)
return (LIBUSB_ERROR_NOT_SUPPORTED);
usbi_dbg("bConfigurationValue %d", config);
if (ioctl(dpriv->fd, USB_SET_CONFIG, &config) < 0)
return _errno_to_libusb(errno);
return _cache_active_config_descriptor(handle->dev);
}
int
obsd_claim_interface(struct libusb_device_handle *handle, int iface)
{
struct handle_priv *hpriv = (struct handle_priv *)handle->os_priv;
int i;
for (i = 0; i < USB_MAX_ENDPOINTS; i++)
hpriv->endpoints[i] = -1;
return (LIBUSB_SUCCESS);
}
int
obsd_release_interface(struct libusb_device_handle *handle, int iface)
{
struct handle_priv *hpriv = (struct handle_priv *)handle->os_priv;
int i;
for (i = 0; i < USB_MAX_ENDPOINTS; i++)
if (hpriv->endpoints[i] >= 0)
close(hpriv->endpoints[i]);
return (LIBUSB_SUCCESS);
}
int
obsd_set_interface_altsetting(struct libusb_device_handle *handle, int iface,
int altsetting)
{
struct device_priv *dpriv = (struct device_priv *)handle->dev->os_priv;
struct usb_alt_interface intf;
if (dpriv->devname == NULL)
return (LIBUSB_ERROR_NOT_SUPPORTED);
usbi_dbg("iface %d, setting %d", iface, altsetting);
memset(&intf, 0, sizeof(intf));
intf.uai_interface_index = iface;
intf.uai_alt_no = altsetting;
if (ioctl(dpriv->fd, USB_SET_ALTINTERFACE, &intf) < 0)
return _errno_to_libusb(errno);
return (LIBUSB_SUCCESS);
}
int
obsd_clear_halt(struct libusb_device_handle *handle, unsigned char endpoint)
{
struct usb_ctl_request req;
int fd, err;
if ((fd = _bus_open(handle->dev->bus_number)) < 0)
return _errno_to_libusb(errno);
usbi_dbg("");
req.ucr_addr = handle->dev->device_address;
req.ucr_request.bmRequestType = UT_WRITE_ENDPOINT;
req.ucr_request.bRequest = UR_CLEAR_FEATURE;
USETW(req.ucr_request.wValue, UF_ENDPOINT_HALT);
USETW(req.ucr_request.wIndex, endpoint);
USETW(req.ucr_request.wLength, 0);
if (ioctl(fd, USB_REQUEST, &req) < 0) {
err = errno;
close(fd);
return _errno_to_libusb(err);
}
close(fd);
return (LIBUSB_SUCCESS);
}
int
obsd_reset_device(struct libusb_device_handle *handle)
{
usbi_dbg("");
return (LIBUSB_ERROR_NOT_SUPPORTED);
}
void
obsd_destroy_device(struct libusb_device *dev)
{
struct device_priv *dpriv = (struct device_priv *)dev->os_priv;
usbi_dbg("");
free(dpriv->cdesc);
free(dpriv->devname);
}
int
obsd_submit_transfer(struct usbi_transfer *itransfer)
{
struct libusb_transfer *transfer;
struct handle_priv *hpriv;
int err = 0;
usbi_dbg("");
transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
hpriv = (struct handle_priv *)transfer->dev_handle->os_priv;
switch (transfer->type) {
case LIBUSB_TRANSFER_TYPE_CONTROL:
err = _sync_control_transfer(itransfer);
break;
case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
if (IS_XFEROUT(transfer)) {
/* Isochronous write is not supported */
err = LIBUSB_ERROR_NOT_SUPPORTED;
break;
}
err = _sync_gen_transfer(itransfer);
break;
case LIBUSB_TRANSFER_TYPE_BULK:
case LIBUSB_TRANSFER_TYPE_INTERRUPT:
if (IS_XFEROUT(transfer) &&
transfer->flags & LIBUSB_TRANSFER_ADD_ZERO_PACKET) {
err = LIBUSB_ERROR_NOT_SUPPORTED;
break;
}
err = _sync_gen_transfer(itransfer);
break;
case LIBUSB_TRANSFER_TYPE_BULK_STREAM:
err = LIBUSB_ERROR_NOT_SUPPORTED;
break;
}
if (err)
return (err);
if (write(hpriv->pipe[1], &itransfer, sizeof(itransfer)) < 0)
return _errno_to_libusb(errno);
return (LIBUSB_SUCCESS);
}
int
obsd_cancel_transfer(struct usbi_transfer *itransfer)
{
usbi_dbg("");
return (LIBUSB_ERROR_NOT_SUPPORTED);
}
void
obsd_clear_transfer_priv(struct usbi_transfer *itransfer)
{
usbi_dbg("");
/* Nothing to do */
}
int
obsd_handle_events(struct libusb_context *ctx, struct pollfd *fds, nfds_t nfds,
int num_ready)
{
struct libusb_device_handle *handle;
struct handle_priv *hpriv = NULL;
struct usbi_transfer *itransfer;
struct pollfd *pollfd;
int i, err = 0;
usbi_dbg("");
pthread_mutex_lock(&ctx->open_devs_lock);
for (i = 0; i < nfds && num_ready > 0; i++) {
pollfd = &fds[i];
if (!pollfd->revents)
continue;
hpriv = NULL;
num_ready--;
list_for_each_entry(handle, &ctx->open_devs, list,
struct libusb_device_handle) {
hpriv = (struct handle_priv *)handle->os_priv;
if (hpriv->pipe[0] == pollfd->fd)
break;
hpriv = NULL;
}
if (NULL == hpriv) {
usbi_dbg("fd %d is not an event pipe!", pollfd->fd);
err = ENOENT;
break;
}
if (pollfd->revents & POLLERR) {
usbi_remove_pollfd(HANDLE_CTX(handle), hpriv->pipe[0]);
usbi_handle_disconnect(handle);
continue;
}
if (read(hpriv->pipe[0], &itransfer, sizeof(itransfer)) < 0) {
err = errno;
break;
}
if ((err = usbi_handle_transfer_completion(itransfer,
LIBUSB_TRANSFER_COMPLETED)))
break;
}
pthread_mutex_unlock(&ctx->open_devs_lock);
if (err)
return _errno_to_libusb(err);
return (LIBUSB_SUCCESS);
}
int
obsd_clock_gettime(int clkid, struct timespec *tp)
{
usbi_dbg("clock %d", clkid);
if (clkid == USBI_CLOCK_REALTIME)
return clock_gettime(CLOCK_REALTIME, tp);
if (clkid == USBI_CLOCK_MONOTONIC)
return clock_gettime(CLOCK_MONOTONIC, tp);
return (LIBUSB_ERROR_INVALID_PARAM);
}
int
_errno_to_libusb(int err)
{
usbi_dbg("error: %s (%d)", strerror(err), err);
switch (err) {
case EIO:
return (LIBUSB_ERROR_IO);
case EACCES:
return (LIBUSB_ERROR_ACCESS);
case ENOENT:
return (LIBUSB_ERROR_NO_DEVICE);
case ENOMEM:
return (LIBUSB_ERROR_NO_MEM);
case ETIMEDOUT:
return (LIBUSB_ERROR_TIMEOUT);
}
return (LIBUSB_ERROR_OTHER);
}
int
_cache_active_config_descriptor(struct libusb_device *dev)
{
struct device_priv *dpriv = (struct device_priv *)dev->os_priv;
struct usb_device_cdesc udc;
struct usb_device_fdesc udf;
unsigned char* buf;
int fd, len, err;
if ((fd = _bus_open(dev->bus_number)) < 0)
return _errno_to_libusb(errno);
usbi_dbg("fd %d, addr %d", fd, dev->device_address);
udc.udc_bus = dev->bus_number;
udc.udc_addr = dev->device_address;
udc.udc_config_index = USB_CURRENT_CONFIG_INDEX;
if (ioctl(fd, USB_DEVICE_GET_CDESC, &udc) < 0) {
err = errno;
close(fd);
return _errno_to_libusb(errno);
}
usbi_dbg("active bLength %d", udc.udc_desc.bLength);
len = UGETW(udc.udc_desc.wTotalLength);
buf = malloc(len);
if (buf == NULL)
return (LIBUSB_ERROR_NO_MEM);
udf.udf_bus = dev->bus_number;
udf.udf_addr = dev->device_address;
udf.udf_config_index = udc.udc_config_index;
udf.udf_size = len;
udf.udf_data = buf;
usbi_dbg("index %d, len %d", udf.udf_config_index, len);
if (ioctl(fd, USB_DEVICE_GET_FDESC, &udf) < 0) {
err = errno;
close(fd);
free(buf);
return _errno_to_libusb(err);
}
close(fd);
if (dpriv->cdesc)
free(dpriv->cdesc);
dpriv->cdesc = buf;
return (LIBUSB_SUCCESS);
}
int
_sync_control_transfer(struct usbi_transfer *itransfer)
{
struct libusb_transfer *transfer;
struct libusb_control_setup *setup;
struct device_priv *dpriv;
struct usb_ctl_request req;
transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
dpriv = (struct device_priv *)transfer->dev_handle->dev->os_priv;
setup = (struct libusb_control_setup *)transfer->buffer;
usbi_dbg("type %x request %x value %x index %d length %d timeout %d",
setup->bmRequestType, setup->bRequest,
libusb_le16_to_cpu(setup->wValue),
libusb_le16_to_cpu(setup->wIndex),
libusb_le16_to_cpu(setup->wLength), transfer->timeout);
req.ucr_addr = transfer->dev_handle->dev->device_address;
req.ucr_request.bmRequestType = setup->bmRequestType;
req.ucr_request.bRequest = setup->bRequest;
/* Don't use USETW, libusb already deals with the endianness */
(*(uint16_t *)req.ucr_request.wValue) = setup->wValue;
(*(uint16_t *)req.ucr_request.wIndex) = setup->wIndex;
(*(uint16_t *)req.ucr_request.wLength) = setup->wLength;
req.ucr_data = transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE;
if ((transfer->flags & LIBUSB_TRANSFER_SHORT_NOT_OK) == 0)
req.ucr_flags = USBD_SHORT_XFER_OK;
if (dpriv->devname == NULL) {
/*
* XXX If the device is not attached to ugen(4) it is
* XXX still possible to submit a control transfer but
* XXX with the default timeout only.
*/
int fd, err;
if ((fd = _bus_open(transfer->dev_handle->dev->bus_number)) < 0)
return _errno_to_libusb(errno);
if ((ioctl(fd, USB_REQUEST, &req)) < 0) {
err = errno;
close(fd);
return _errno_to_libusb(err);
}
close(fd);
} else {
if ((ioctl(dpriv->fd, USB_SET_TIMEOUT, &transfer->timeout)) < 0)
return _errno_to_libusb(errno);
if ((ioctl(dpriv->fd, USB_DO_REQUEST, &req)) < 0)
return _errno_to_libusb(errno);
}
itransfer->transferred = req.ucr_actlen;
usbi_dbg("transferred %d", itransfer->transferred);
return (0);
}
int
_access_endpoint(struct libusb_transfer *transfer)
{
struct handle_priv *hpriv;
struct device_priv *dpriv;
char devnode[16];
int fd, endpt;
mode_t mode;
hpriv = (struct handle_priv *)transfer->dev_handle->os_priv;
dpriv = (struct device_priv *)transfer->dev_handle->dev->os_priv;
endpt = UE_GET_ADDR(transfer->endpoint);
mode = IS_XFERIN(transfer) ? O_RDONLY : O_WRONLY;
usbi_dbg("endpoint %d mode %d", endpt, mode);
if (hpriv->endpoints[endpt] < 0) {
/* Pick the right endpoint node */
snprintf(devnode, sizeof(devnode), DEVPATH "%s.%02d",
dpriv->devname, endpt);
/* We may need to read/write to the same endpoint later. */
if (((fd = open(devnode, O_RDWR)) < 0) && (errno == ENXIO))
if ((fd = open(devnode, mode)) < 0)
return (-1);
hpriv->endpoints[endpt] = fd;
}
return (hpriv->endpoints[endpt]);
}
int
_sync_gen_transfer(struct usbi_transfer *itransfer)
{
struct libusb_transfer *transfer;
struct device_priv *dpriv;
int fd, nr = 1;
transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
dpriv = (struct device_priv *)transfer->dev_handle->dev->os_priv;
if (dpriv->devname == NULL)
return (LIBUSB_ERROR_NOT_SUPPORTED);
/*
* Bulk, Interrupt or Isochronous transfer depends on the
* endpoint and thus the node to open.
*/
if ((fd = _access_endpoint(transfer)) < 0)
return _errno_to_libusb(errno);
if ((ioctl(fd, USB_SET_TIMEOUT, &transfer->timeout)) < 0)
return _errno_to_libusb(errno);
if (IS_XFERIN(transfer)) {
if ((transfer->flags & LIBUSB_TRANSFER_SHORT_NOT_OK) == 0)
if ((ioctl(fd, USB_SET_SHORT_XFER, &nr)) < 0)
return _errno_to_libusb(errno);
nr = read(fd, transfer->buffer, transfer->length);
} else {
nr = write(fd, transfer->buffer, transfer->length);
}
if (nr < 0)
return _errno_to_libusb(errno);
itransfer->transferred = nr;
return (0);
}
int
_bus_open(int number)
{
char busnode[16];
snprintf(busnode, sizeof(busnode), USBDEV "%d", number);
return open(busnode, O_RDWR);
}

View File

@ -22,7 +22,7 @@
*/
/*
* poll() and pipe() Windows compatibility layer for libusbx 1.0
* poll() and pipe() Windows compatibility layer for libusb 1.0
*
* The way this layer works is by using OVERLAPPED with async I/O transfers, as
* OVERLAPPED have an associated event which is flagged for I/O completion.
@ -252,7 +252,7 @@ void exit_polling(void)
/*
* Create a fake pipe.
* As libusbx only uses pipes for signaling, all we need from a pipe is an
* As libusb only uses pipes for signaling, all we need from a pipe is an
* event. To that extent, we create a single wfd and overlapped as a means
* to access that event.
*/
@ -428,7 +428,7 @@ struct winfd fd_to_winfd(int fd)
CHECK_INIT_POLLING;
if (fd <= 0)
if (fd < 0)
return INVALID_WINFD;
for (i=0; i<MAX_FDS; i++) {

View File

@ -40,14 +40,20 @@
#define DUMMY_HANDLE ((HANDLE)(LONG_PTR)-2)
/* Windows versions */
enum windows_version {
WINDOWS_UNSUPPORTED,
WINDOWS_CE,
WINDOWS_XP,
WINDOWS_2003, // also includes XP 64
WINDOWS_VISTA_AND_LATER,
WINDOWS_CE = -2,
WINDOWS_UNDEFINED = -1,
WINDOWS_UNSUPPORTED = 0,
WINDOWS_XP = 0x51,
WINDOWS_2003 = 0x52, // Also XP x64
WINDOWS_VISTA = 0x60,
WINDOWS_7 = 0x61,
WINDOWS_8 = 0x62,
WINDOWS_8_1_OR_LATER = 0x63,
WINDOWS_MAX
};
extern enum windows_version windows_version;
extern int windows_version;
#define MAX_FDS 256

View File

@ -1,5 +1,5 @@
/*
* libusbx synchronization using POSIX Threads
* libusb synchronization using POSIX Threads
*
* Copyright © 2011 Vitali Lovich <vlovich@aliph.com>
* Copyright © 2011 Peter Stuge <peter@stuge.se>
@ -63,7 +63,9 @@ finish:
int usbi_get_tid(void)
{
int ret = -1;
#if defined(__linux__)
#if defined(__ANDROID__)
ret = gettid();
#elif defined(__linux__)
ret = syscall(SYS_gettid);
#elif defined(__OpenBSD__)
/* The following only works with OpenBSD > 5.1 as it requires

View File

@ -1,5 +1,5 @@
/*
* libusbx synchronization using POSIX Threads
* libusb synchronization using POSIX Threads
*
* Copyright © 2010 Peter Stuge <peter@stuge.se>
*

View File

@ -1,5 +1,5 @@
/*
* libusbx synchronization on Microsoft Windows
* libusb synchronization on Microsoft Windows
*
* Copyright © 2010 Michael Plante <michael.plante@gmail.com>
*

View File

@ -1,5 +1,5 @@
/*
* libusbx synchronization on Microsoft Windows
* libusb synchronization on Microsoft Windows
*
* Copyright © 2010 Michael Plante <michael.plante@gmail.com>
*

View File

@ -1,5 +1,5 @@
/*
* Windows CE backend for libusbx 1.0
* Windows CE backend for libusb 1.0
* Copyright © 2011-2013 RealVNC Ltd.
* Large portions taken from Windows backend, which is
* Copyright © 2009-2010 Pete Batard <pbatard@gmail.com>
@ -38,7 +38,7 @@ unsigned __stdcall wince_clock_gettime_threaded(void* param);
uint64_t hires_frequency, hires_ticks_to_ps;
int errno;
const uint64_t epoch_time = UINT64_C(116444736000000000); // 1970.01.01 00:00:000 in MS Filetime
enum windows_version windows_version = WINDOWS_CE;
int windows_version = WINDOWS_CE;
static int concurrent_usage = -1;
// Timer thread
// NB: index 0 is for monotonic and 1 is for the thread exit event
@ -234,6 +234,12 @@ static int wince_init(struct libusb_context *ctx)
usbi_err(ctx, "Unable to create timer thread - aborting");
goto init_exit;
}
// Wait for timer thread to init before continuing.
if (WaitForSingleObject(timer_response, INFINITE) != WAIT_OBJECT_0) {
usbi_err(ctx, "Failed to wait for timer thread to become ready - aborting");
goto init_exit;
}
}
// At this stage, either we went through full init successfully, or didn't need to
r = LIBUSB_SUCCESS;
@ -366,7 +372,6 @@ static int wince_get_device_list(
if (dev) {
usbi_dbg("using existing device for %d/%d (session %ld)",
bus_addr, dev_addr, session_id);
libusb_ref_device(dev);
// Release just this element in the device list (as we already hold a
// reference to it).
UkwReleaseDeviceList(driver_handle, &devices[i], 1);
@ -684,6 +689,8 @@ static int wince_submit_transfer(
return wince_submit_control_or_bulk_transfer(itransfer);
case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
return wince_submit_iso_transfer(itransfer);
case LIBUSB_TRANSFER_TYPE_BULK_STREAM:
return LIBUSB_ERROR_NOT_SUPPORTED;
default:
usbi_err(TRANSFER_CTX(transfer), "unknown endpoint type %d", transfer->type);
return LIBUSB_ERROR_INVALID_PARAM;
@ -796,6 +803,8 @@ static void wince_handle_callback (struct usbi_transfer *itransfer, uint32_t io_
case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
wince_transfer_callback (itransfer, io_result, io_size);
break;
case LIBUSB_TRANSFER_TYPE_BULK_STREAM:
return LIBUSB_ERROR_NOT_SUPPORTED;
default:
usbi_err(ITRANSFER_CTX(itransfer), "unknown endpoint type %d", transfer->type);
}
@ -877,6 +886,11 @@ unsigned __stdcall wince_clock_gettime_threaded(void* param)
usbi_dbg("hires timer available (Frequency: %"PRIu64" Hz)", hires_frequency);
}
// Signal wince_init() that we're ready to service requests
if (ReleaseSemaphore(timer_response, 1, NULL) == 0) {
usbi_dbg("unable to release timer semaphore: %s", windows_error_str(0));
}
// Main loop - wait for requests
while (1) {
timer_index = WaitForMultipleObjects(2, timer_request, FALSE, INFINITE) - WAIT_OBJECT_0;
@ -911,7 +925,7 @@ unsigned __stdcall wince_clock_gettime_threaded(void* param)
nb_responses = InterlockedExchange((LONG*)&request_count[0], 0);
if ( (nb_responses)
&& (ReleaseSemaphore(timer_response, nb_responses, NULL) == 0) ) {
usbi_dbg("unable to release timer semaphore %d: %s", windows_error_str(0));
usbi_dbg("unable to release timer semaphore: %s", windows_error_str(0));
}
continue;
case 1: // time to quit
@ -995,6 +1009,9 @@ const struct usbi_os_backend wince_backend = {
wince_clear_halt,
wince_reset_device,
NULL, /* alloc_streams */
NULL, /* free_streams */
wince_kernel_driver_active,
wince_detach_kernel_driver,
wince_attach_kernel_driver,

View File

@ -1,5 +1,5 @@
/*
* Windows CE backend for libusbx 1.0
* Windows CE backend for libusb 1.0
* Copyright © 2011-2013 RealVNC Ltd.
* Portions taken from Windows backend, which is
* Copyright © 2009-2010 Pete Batard <pbatard@gmail.com>
@ -36,7 +36,7 @@
// This backend dynamically loads ceusbkwrapper.dll and doesn't include
// ceusbkwrapper.h directly to simplify the build process. The kernel
// side wrapper driver is built using the platform image build tools,
// which makes it difficult to reference directly from the libusbx build
// which makes it difficult to reference directly from the libusb build
// system.
struct UKW_DEVICE_PRIV;
typedef struct UKW_DEVICE_PRIV *UKW_DEVICE;

View File

@ -1,5 +1,5 @@
/*
* Windows backend common header for libusbx 1.0
* Windows backend common header for libusb 1.0
*
* This file brings together header code common between
* the desktop Windows and Windows CE backends.

View File

@ -1,5 +1,5 @@
/*
* windows backend for libusbx 1.0
* windows backend for libusb 1.0
* Copyright © 2009-2012 Pete Batard <pete@akeo.ie>
* With contributions from Michael Plante, Orin Eman et al.
* Parts of this code adapted from libusb-win32-v1 by Stephan Meyer
@ -100,7 +100,8 @@ static int composite_copy_transfer_data(int sub_api, struct usbi_transfer *itran
// Global variables
uint64_t hires_frequency, hires_ticks_to_ps;
const uint64_t epoch_time = UINT64_C(116444736000000000); // 1970.01.01 00:00:000 in MS Filetime
enum windows_version windows_version = WINDOWS_UNSUPPORTED;
int windows_version = WINDOWS_UNDEFINED;
static char windows_version_str[128] = "Windows Undefined";
// Concurrency
static int concurrent_usage = -1;
usbi_mutex_t autoclaim_lock;
@ -158,6 +159,20 @@ static char err_string[ERR_BUFFER_SIZE];
safe_sprintf(err_string, ERR_BUFFER_SIZE, "[%u] ", error_code);
// Translate codes returned by SetupAPI. The ones we are dealing with are either
// in 0x0000xxxx or 0xE000xxxx and can be distinguished from standard error codes.
// See http://msdn.microsoft.com/en-us/library/windows/hardware/ff545011.aspx
switch (error_code & 0xE0000000) {
case 0:
error_code = HRESULT_FROM_WIN32(error_code); // Still leaves ERROR_SUCCESS unmodified
break;
case 0xE0000000:
error_code = 0x80000000 | (FACILITY_SETUPAPI << 16) | (error_code & 0x0000FFFF);
break;
default:
break;
}
size = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, error_code,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), &err_string[safe_strlen(err_string)],
ERR_BUFFER_SIZE - (DWORD)safe_strlen(err_string), NULL);
@ -195,7 +210,7 @@ static char* sanitize_path(const char* path)
size = safe_strlen(path)+1;
root_size = sizeof(root_prefix)-1;
// Microsoft indiscriminatly uses '\\?\', '\\.\', '##?#" or "##.#" for root prefixes.
// Microsoft indiscriminately uses '\\?\', '\\.\', '##?#" or "##.#" for root prefixes.
if (!((size > 3) && (((path[0] == '\\') && (path[1] == '\\') && (path[3] == '\\')) ||
((path[0] == '#') && (path[1] == '#') && (path[3] == '#'))))) {
add_root = root_size;
@ -207,7 +222,7 @@ static char* sanitize_path(const char* path)
safe_strcpy(&ret_path[add_root], size-add_root, path);
// Ensure consistancy with root prefix
// Ensure consistency with root prefix
for (j=0; j<root_size; j++)
ret_path[j] = root_prefix[j];
@ -790,17 +805,128 @@ static void auto_release(struct usbi_transfer *itransfer)
usbi_mutex_unlock(&autoclaim_lock);
}
/* Windows version dtection */
static BOOL is_x64(void)
{
BOOL ret = FALSE;
// Detect if we're running a 32 or 64 bit system
if (sizeof(uintptr_t) < 8) {
DLL_LOAD_PREFIXED(Kernel32.dll, p, IsWow64Process, FALSE);
if (pIsWow64Process != NULL) {
(*pIsWow64Process)(GetCurrentProcess(), &ret);
}
} else {
ret = TRUE;
}
return ret;
}
static void get_windows_version(void)
{
OSVERSIONINFOEXA vi, vi2;
const char* w = 0;
const char* w64 = "32 bit";
char* vptr;
size_t vlen;
unsigned major, minor;
ULONGLONG major_equal, minor_equal;
BOOL ws;
memset(&vi, 0, sizeof(vi));
vi.dwOSVersionInfoSize = sizeof(vi);
if (!GetVersionExA((OSVERSIONINFOA *)&vi)) {
memset(&vi, 0, sizeof(vi));
vi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
if (!GetVersionExA((OSVERSIONINFOA *)&vi))
return;
}
if (vi.dwPlatformId == VER_PLATFORM_WIN32_NT) {
if (vi.dwMajorVersion > 6 || (vi.dwMajorVersion == 6 && vi.dwMinorVersion >= 2)) {
// Starting with Windows 8.1 Preview, GetVersionEx() does no longer report the actual OS version
// See: http://msdn.microsoft.com/en-us/library/windows/desktop/dn302074.aspx
major_equal = VerSetConditionMask(0, VER_MAJORVERSION, VER_EQUAL);
for (major = vi.dwMajorVersion; major <= 9; major++) {
memset(&vi2, 0, sizeof(vi2));
vi2.dwOSVersionInfoSize = sizeof(vi2); vi2.dwMajorVersion = major;
if (!VerifyVersionInfoA(&vi2, VER_MAJORVERSION, major_equal))
continue;
if (vi.dwMajorVersion < major) {
vi.dwMajorVersion = major; vi.dwMinorVersion = 0;
}
minor_equal = VerSetConditionMask(0, VER_MINORVERSION, VER_EQUAL);
for (minor = vi.dwMinorVersion; minor <= 9; minor++) {
memset(&vi2, 0, sizeof(vi2)); vi2.dwOSVersionInfoSize = sizeof(vi2);
vi2.dwMinorVersion = minor;
if (!VerifyVersionInfoA(&vi2, VER_MINORVERSION, minor_equal))
continue;
vi.dwMinorVersion = minor;
break;
}
break;
}
}
if (vi.dwMajorVersion <= 0xf && vi.dwMinorVersion <= 0xf) {
ws = (vi.wProductType <= VER_NT_WORKSTATION);
windows_version = vi.dwMajorVersion << 4 | vi.dwMinorVersion;
switch (windows_version) {
case 0x50: w = "2000";
break;
case 0x51: w = "XP";
break;
case 0x52: w = ("2003");
break;
case 0x60: w = (ws?"Vista":"2008");
break;
case 0x61: w = (ws?"7":"2008_R2");
break;
case 0x62: w = (ws?"8":"2012");
break;
case 0x63: w = (ws?"8.1":"2012_R2");
break;
case 0x64: w = (ws?"8.2":"2012_R3");
break;
default:
if (windows_version < 0x50)
windows_version = WINDOWS_UNSUPPORTED;
else
w = "9 or later";
break;
}
}
}
if (is_x64())
w64 = "64-bit";
vptr = &windows_version_str[sizeof("Windows ") - 1];
vlen = sizeof(windows_version_str) - sizeof("Windows ") - 1;
if (!w)
safe_sprintf(vptr, vlen, "%s %u.%u %s", (vi.dwPlatformId==VER_PLATFORM_WIN32_NT?"NT":"??"),
(unsigned)vi.dwMajorVersion, (unsigned)vi.dwMinorVersion, w64);
else if (vi.wServicePackMinor)
safe_sprintf(vptr, vlen, "%s SP%u.%u %s", w, vi.wServicePackMajor, vi.wServicePackMinor, w64);
else if (vi.wServicePackMajor)
safe_sprintf(vptr, vlen, "%s SP%u %s", w, vi.wServicePackMajor, w64);
else
safe_sprintf(vptr, vlen, "%s %s", w, w64);
}
/*
* init: libusbx backend init function
* init: libusb backend init function
*
* This function enumerates the HCDs (Host Controller Drivers) and populates our private HCD list
* In our implementation, we equate Windows' "HCD" to libusbx's "bus". Note that bus is zero indexed.
* In our implementation, we equate Windows' "HCD" to libusb's "bus". Note that bus is zero indexed.
* HCDs are not expected to change after init (might not hold true for hot pluggable USB PCI card?)
*/
static int windows_init(struct libusb_context *ctx)
{
int i, r = LIBUSB_ERROR_OTHER;
OSVERSIONINFO os_version;
HANDLE semaphore;
char sem_name[11+1+8]; // strlen(libusb_init)+'\0'+(32-bit hex PID)
@ -822,19 +948,8 @@ static int windows_init(struct libusb_context *ctx)
// NB: concurrent usage supposes that init calls are equally balanced with
// exit calls. If init is called more than exit, we will not exit properly
if ( ++concurrent_usage == 0 ) { // First init?
// Detect OS version
memset(&os_version, 0, sizeof(OSVERSIONINFO));
os_version.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
windows_version = WINDOWS_UNSUPPORTED;
if ((GetVersionEx(&os_version) != 0) && (os_version.dwPlatformId == VER_PLATFORM_WIN32_NT)) {
if ((os_version.dwMajorVersion == 5) && (os_version.dwMinorVersion == 1)) {
windows_version = WINDOWS_XP;
} else if ((os_version.dwMajorVersion == 5) && (os_version.dwMinorVersion == 2)) {
windows_version = WINDOWS_2003; // also includes XP 64
} else if (os_version.dwMajorVersion >= 6) {
windows_version = WINDOWS_VISTA_AND_LATER;
}
}
get_windows_version();
usbi_dbg(windows_version_str);
if (windows_version == WINDOWS_UNSUPPORTED) {
usbi_err(ctx, "This version of Windows is NOT supported");
r = LIBUSB_ERROR_NOT_SUPPORTED;
@ -886,6 +1001,12 @@ static int windows_init(struct libusb_context *ctx)
}
SetThreadAffinityMask(timer_thread, 0);
// Wait for timer thread to init before continuing.
if (WaitForSingleObject(timer_response, INFINITE) != WAIT_OBJECT_0) {
usbi_err(ctx, "Failed to wait for timer thread to become ready - aborting");
goto init_exit;
}
// Create a hash table to store session ids. Second parameter is better if prime
htab_create(ctx, HTAB_SIZE);
}
@ -1008,6 +1129,7 @@ static int cache_config_descriptors(struct libusb_device *dev, HANDLE hub_handle
// Dummy call to get the required data size. Initial failures are reported as info rather
// than error as they can occur for non-penalizing situations, such as with some hubs.
// coverity[tainted_data_argument]
if (!DeviceIoControl(hub_handle, IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, &cd_buf_short, size,
&cd_buf_short, size, &ret_size, NULL)) {
usbi_info(ctx, "could not access configuration descriptor (dummy) for '%s': %s", device_id, windows_error_str(0));
@ -1058,14 +1180,14 @@ static int cache_config_descriptors(struct libusb_device *dev, HANDLE hub_handle
// Cache the descriptor
priv->config_descriptor[i] = (unsigned char*) malloc(cd_data->wTotalLength);
if (priv->config_descriptor[i] == NULL)
return LIBUSB_ERROR_NO_MEM;
LOOP_BREAK(LIBUSB_ERROR_NO_MEM);
memcpy(priv->config_descriptor[i], cd_data, cd_data->wTotalLength);
}
return LIBUSB_SUCCESS;
}
/*
* Populate a libusbx device structure
* Populate a libusb device structure
*/
static int init_device(struct libusb_device* dev, struct libusb_device* parent_dev,
uint8_t port_number, char* device_id, DWORD devinst)
@ -1073,14 +1195,16 @@ static int init_device(struct libusb_device* dev, struct libusb_device* parent_d
HANDLE handle;
DWORD size;
USB_NODE_CONNECTION_INFORMATION_EX conn_info;
USB_NODE_CONNECTION_INFORMATION_EX_V2 conn_info_v2;
struct windows_device_priv *priv, *parent_priv;
struct libusb_context *ctx = DEVICE_CTX(dev);
struct libusb_context *ctx;
struct libusb_device* tmp_dev;
unsigned i;
if ((dev == NULL) || (parent_dev == NULL)) {
return LIBUSB_ERROR_NOT_FOUND;
}
ctx = DEVICE_CTX(dev);
priv = _device_priv(dev);
parent_priv = _device_priv(parent_dev);
if (parent_priv->apib->id != USB_API_HUB) {
@ -1097,8 +1221,10 @@ static int init_device(struct libusb_device* dev, struct libusb_device* parent_d
if (tmp_dev->bus_number != 0) {
usbi_dbg("got bus number from ancestor #%d", i);
parent_dev->bus_number = tmp_dev->bus_number;
libusb_unref_device(tmp_dev);
break;
}
libusb_unref_device(tmp_dev);
}
}
if (parent_dev->bus_number == 0) {
@ -1110,7 +1236,7 @@ static int init_device(struct libusb_device* dev, struct libusb_device* parent_d
dev->port_number = port_number;
priv->depth = parent_priv->depth + 1;
priv->parent_dev = parent_dev;
dev->parent_dev = libusb_ref_device(parent_dev);
dev->parent_dev = parent_dev;
// If the device address is already set, we can stop here
if (dev->device_address != 0) {
@ -1126,6 +1252,7 @@ static int init_device(struct libusb_device* dev, struct libusb_device* parent_d
}
size = sizeof(conn_info);
conn_info.ConnectionIndex = (ULONG)port_number;
// coverity[tainted_data_argument]
if (!DeviceIoControl(handle, IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX, &conn_info, size,
&conn_info, size, &size, NULL)) {
usbi_warn(ctx, "could not get node connection information for device '%s': %s",
@ -1147,6 +1274,23 @@ static int init_device(struct libusb_device* dev, struct libusb_device* parent_d
dev->num_configurations = 0;
priv->dev_descriptor.bNumConfigurations = 0;
}
// In their great wisdom, Microsoft decided to BREAK the USB speed report between Windows 7 and Windows 8
if (windows_version >= WINDOWS_8) {
memset(&conn_info_v2, 0, sizeof(conn_info_v2));
size = sizeof(conn_info_v2);
conn_info_v2.ConnectionIndex = (ULONG)port_number;
conn_info_v2.Length = size;
conn_info_v2.SupportedUsbProtocols.Usb300 = 1;
if (!DeviceIoControl(handle, IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX_V2,
&conn_info_v2, size, &conn_info_v2, size, &size, NULL)) {
usbi_warn(ctx, "could not get node connection information (V2) for device '%s': %s",
device_id, windows_error_str(0));
} else if (conn_info_v2.Flags.DeviceIsOperatingAtSuperSpeedOrHigher) {
conn_info.Speed = 3;
}
}
safe_closehandle(handle);
if (conn_info.DeviceAddress > UINT8_MAX) {
@ -1224,7 +1368,7 @@ static void get_api_type(struct libusb_context *ctx, HDEVINFO *dev_info,
for (k=0; k<3; k++) {
j = get_sub_api(lookup[k].list, i);
if (j >= 0) {
usbi_dbg("matched %s name against %s API",
usbi_dbg("matched %s name against %s",
lookup[k].designation, (i!=USB_API_WINUSBX)?usb_api_backend[i].designation:sub_api_name[j]);
*api = i;
*sub_api = j;
@ -1317,7 +1461,7 @@ static int set_hid_interface(struct libusb_context* ctx, struct libusb_device* d
}
/*
* get_device_list: libusbx backend device enumeration function
* get_device_list: libusb backend device enumeration function
*/
static int windows_get_device_list(struct libusb_context *ctx, struct discovered_devs **_discdevs)
{
@ -1467,7 +1611,7 @@ static int windows_get_device_list(struct libusb_context *ctx, struct discovered
if (!pSetupDiGetDeviceRegistryPropertyA(dev_info, &dev_info_data, SPDRP_DRIVER,
&reg_type, (BYTE*)strbuf, size, &size)) {
usbi_info(ctx, "The following device has no driver: '%s'", dev_id_path);
usbi_info(ctx, "libusbx will not be able to access it.");
usbi_info(ctx, "libusb will not be able to access it.");
}
// ...and to add the additional device interface GUIDs
key = pSetupDiOpenDevRegKey(dev_info, &dev_info_data, DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_READ);
@ -1531,6 +1675,7 @@ static int windows_get_device_list(struct libusb_context *ctx, struct discovered
parent_priv = _device_priv(parent_dev);
// virtual USB devices are also listed during GEN - don't process these yet
if ( (pass == GEN_PASS) && (parent_priv->apib->id != USB_API_HUB) ) {
libusb_unref_device(parent_dev);
continue;
}
break;
@ -1553,20 +1698,20 @@ static int windows_get_device_list(struct libusb_context *ctx, struct discovered
LOOP_BREAK(LIBUSB_ERROR_NO_MEM);
}
windows_device_priv_init(dev);
// Keep track of devices that need unref
unref_list[unref_cur++] = dev;
if (unref_cur >= unref_size) {
unref_size += 64;
unref_list = usbi_reallocf(unref_list, unref_size*sizeof(libusb_device*));
if (unref_list == NULL) {
usbi_err(ctx, "could not realloc list for unref - aborting.");
LOOP_BREAK(LIBUSB_ERROR_NO_MEM);
}
}
} else {
usbi_dbg("found existing device for session [%X] (%d.%d)",
session_id, dev->bus_number, dev->device_address);
}
// Keep track of devices that need unref
unref_list[unref_cur++] = dev;
if (unref_cur >= unref_size) {
unref_size += 64;
unref_list = usbi_reallocf(unref_list, unref_size*sizeof(libusb_device*));
if (unref_list == NULL) {
usbi_err(ctx, "could not realloc list for unref - aborting.");
LOOP_BREAK(LIBUSB_ERROR_NO_MEM);
}
}
priv = _device_priv(dev);
}
@ -1652,6 +1797,7 @@ static int windows_get_device_list(struct libusb_context *ctx, struct discovered
break;
}
}
libusb_unref_device(parent_dev);
break;
}
}
@ -1663,16 +1809,18 @@ static int windows_get_device_list(struct libusb_context *ctx, struct discovered
}
// Unref newly allocated devs
for (i=0; i<unref_cur; i++) {
safe_unref_device(unref_list[i]);
if (unref_list != NULL) {
for (i=0; i<unref_cur; i++) {
safe_unref_device(unref_list[i]);
}
free(unref_list);
}
safe_free(unref_list);
return r;
}
/*
* exit: libusbx backend deinitialization function
* exit: libusb backend deinitialization function
*/
static void windows_exit(void)
{
@ -1759,7 +1907,7 @@ static int windows_get_config_descriptor(struct libusb_device *dev, uint8_t conf
memcpy(buffer, priv->config_descriptor[config_index], size);
*host_endian = 0;
return size;
return (int)size;
}
/*
@ -1995,6 +2143,8 @@ static int windows_submit_transfer(struct usbi_transfer *itransfer)
return submit_bulk_transfer(itransfer);
case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
return submit_iso_transfer(itransfer);
case LIBUSB_TRANSFER_TYPE_BULK_STREAM:
return LIBUSB_ERROR_NOT_SUPPORTED;
default:
usbi_err(TRANSFER_CTX(transfer), "unknown endpoint type %d", transfer->type);
return LIBUSB_ERROR_INVALID_PARAM;
@ -2028,6 +2178,8 @@ static int windows_cancel_transfer(struct usbi_transfer *itransfer)
case LIBUSB_TRANSFER_TYPE_INTERRUPT:
case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
return windows_abort_transfers(itransfer);
case LIBUSB_TRANSFER_TYPE_BULK_STREAM:
return LIBUSB_ERROR_NOT_SUPPORTED;
default:
usbi_err(ITRANSFER_CTX(itransfer), "unknown endpoint type %d", transfer->type);
return LIBUSB_ERROR_INVALID_PARAM;
@ -2068,7 +2220,7 @@ static void windows_transfer_callback(struct usbi_transfer *itransfer, uint32_t
}
break;
default:
usbi_err(ITRANSFER_CTX(itransfer), "detected I/O error %d: %s", io_result, windows_error_str(0));
usbi_err(ITRANSFER_CTX(itransfer), "detected I/O error %d: %s", io_result, windows_error_str(io_result));
status = LIBUSB_TRANSFER_ERROR;
break;
}
@ -2087,6 +2239,9 @@ static void windows_handle_callback (struct usbi_transfer *itransfer, uint32_t i
case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
windows_transfer_callback (itransfer, io_result, io_size);
break;
case LIBUSB_TRANSFER_TYPE_BULK_STREAM:
usbi_warn(ITRANSFER_CTX(itransfer), "bulk stream transfers are not yet supported on this platform");
break;
default:
usbi_err(ITRANSFER_CTX(itransfer), "unknown endpoint type %d", transfer->type);
}
@ -2172,6 +2327,11 @@ unsigned __stdcall windows_clock_gettime_threaded(void* param)
usbi_dbg("hires timer available (Frequency: %"PRIu64" Hz)", hires_frequency);
}
// Signal windows_init() that we're ready to service requests
if (ReleaseSemaphore(timer_response, 1, NULL) == 0) {
usbi_dbg("unable to release timer semaphore: %s", windows_error_str(0));
}
// Main loop - wait for requests
while (1) {
timer_index = WaitForMultipleObjects(2, timer_request, FALSE, INFINITE) - WAIT_OBJECT_0;
@ -2193,7 +2353,7 @@ unsigned __stdcall windows_clock_gettime_threaded(void* param)
case 0:
WaitForSingleObject(timer_mutex, INFINITE);
// Requests to this thread are for hires always
if (QueryPerformanceCounter(&hires_counter) != 0) {
if ((QueryPerformanceCounter(&hires_counter) != 0) && (hires_frequency != 0)) {
timer_tp.tv_sec = (long)(hires_counter.QuadPart / hires_frequency);
timer_tp.tv_nsec = (long)(((hires_counter.QuadPart % hires_frequency)/1000) * hires_ticks_to_ps);
} else {
@ -2206,7 +2366,7 @@ unsigned __stdcall windows_clock_gettime_threaded(void* param)
nb_responses = InterlockedExchange((LONG*)&request_count[0], 0);
if ( (nb_responses)
&& (ReleaseSemaphore(timer_response, nb_responses, NULL) == 0) ) {
usbi_dbg("unable to release timer semaphore %d: %s", windows_error_str(0));
usbi_dbg("unable to release timer semaphore: %s", windows_error_str(0));
}
continue;
case 1: // time to quit
@ -2288,6 +2448,9 @@ const struct usbi_os_backend windows_backend = {
windows_clear_halt,
windows_reset_device,
NULL, /* alloc_streams */
NULL, /* free_streams */
windows_kernel_driver_active,
windows_detach_kernel_driver,
windows_attach_kernel_driver,
@ -2366,7 +2529,7 @@ static int common_configure_endpoints(int sub_api, struct libusb_device_handle *
return LIBUSB_SUCCESS;
}
// These names must be uppercase
const char* hub_driver_names[] = {"USBHUB", "USBHUB3", "NUSB3HUB", "RUSB3HUB", "FLXHCIH", "TIHUB3", "ETRONHUB3", "VIAHUB3", "ASMTHUB3", "IUSB3HUB"};
const char* hub_driver_names[] = {"USBHUB", "USBHUB3", "USB3HUB", "NUSB3HUB", "RUSB3HUB", "FLXHCIH", "TIHUB3", "ETRONHUB3", "VIAHUB3", "ASMTHUB3", "IUSB3HUB", "VUSB3HUB", "AMDHUB30"};
const char* composite_driver_names[] = {"USBCCGP"};
const char* winusbx_driver_names[] = WINUSBX_DRV_NAMES;
const char* hid_driver_names[] = {"HIDUSB", "MOUHID", "KBDHID"};
@ -2726,11 +2889,10 @@ static int winusbx_claim_interface(int sub_api, struct libusb_device_handle *dev
usbi_err(ctx, "could not open device %s: %s", filter_path, windows_error_str(0));
} else {
WinUSBX[sub_api].Free(winusb_handle);
if (!WinUSBX[sub_api].Initialize(file_handle, &winusb_handle)) {
continue;
}
found_filter = true;
break;
if (WinUSBX[sub_api].Initialize(file_handle, &winusb_handle))
found_filter = true;
else
usbi_err(ctx, "could not initialize filter driver for %s", filter_path);
}
}
}
@ -4146,19 +4308,21 @@ static int hid_copy_transfer_data(int sub_api, struct usbi_transfer *itransfer,
if (transfer_priv->hid_buffer != NULL) {
// If we have a valid hid_buffer, it means the transfer was async
if (transfer_priv->hid_dest != NULL) { // Data readout
// First, check for overflow
if (corrected_size > transfer_priv->hid_expected_size) {
usbi_err(ctx, "OVERFLOW!");
corrected_size = (uint32_t)transfer_priv->hid_expected_size;
r = LIBUSB_TRANSFER_OVERFLOW;
}
if (corrected_size > 0) {
// First, check for overflow
if (corrected_size > transfer_priv->hid_expected_size) {
usbi_err(ctx, "OVERFLOW!");
corrected_size = (uint32_t)transfer_priv->hid_expected_size;
r = LIBUSB_TRANSFER_OVERFLOW;
}
if (transfer_priv->hid_buffer[0] == 0) {
// Discard the 1 byte report ID prefix
corrected_size--;
memcpy(transfer_priv->hid_dest, transfer_priv->hid_buffer+1, corrected_size);
} else {
memcpy(transfer_priv->hid_dest, transfer_priv->hid_buffer, corrected_size);
if (transfer_priv->hid_buffer[0] == 0) {
// Discard the 1 byte report ID prefix
corrected_size--;
memcpy(transfer_priv->hid_dest, transfer_priv->hid_buffer+1, corrected_size);
} else {
memcpy(transfer_priv->hid_dest, transfer_priv->hid_buffer, corrected_size);
}
}
transfer_priv->hid_dest = NULL;
}
@ -4286,7 +4450,7 @@ static int composite_submit_control_transfer(int sub_api, struct usbi_transfer *
}
}
usbi_err(ctx, "no libusbx supported interfaces to complete request");
usbi_err(ctx, "no libusb supported interfaces to complete request");
return LIBUSB_ERROR_NOT_FOUND;
}

View File

@ -1,5 +1,5 @@
/*
* Windows backend for libusbx 1.0
* Windows backend for libusb 1.0
* Copyright © 2009-2012 Pete Batard <pete@akeo.ie>
* With contributions from Michael Plante, Orin Eman et al.
* Parts of this code adapted from libusb-win32-v1 by Stephan Meyer
@ -40,6 +40,11 @@
#define SPDRP_INSTALL_STATE 34
#endif
// Missing from MinGW
#if !defined(FACILITY_SETUPAPI)
#define FACILITY_SETUPAPI 15
#endif
#if defined(__CYGWIN__ )
#define _stricmp stricmp
// cygwin produces a warning unless these prototypes are defined
@ -305,6 +310,9 @@ struct driver_lookup {
/* OLE32 dependency */
DLL_DECLARE_PREFIXED(WINAPI, HRESULT, p, CLSIDFromString, (LPCOLESTR, LPCLSID));
/* This call is only available from XP SP2 */
DLL_DECLARE_PREFIXED(WINAPI, BOOL, p, IsWow64Process, (HANDLE, PBOOL));
/* SetupAPI dependencies */
DLL_DECLARE_PREFIXED(WINAPI, HDEVINFO, p, SetupDiGetClassDevsA, (const GUID*, PCSTR, HWND, DWORD));
DLL_DECLARE_PREFIXED(WINAPI, BOOL, p, SetupDiEnumDeviceInfo, (HDEVINFO, DWORD, PSP_DEVINFO_DATA));
@ -359,6 +367,9 @@ typedef RETURN_TYPE CONFIGRET;
#if !defined(USB_GET_HUB_CAPABILITIES_EX)
#define USB_GET_HUB_CAPABILITIES_EX 276
#endif
#if !defined(USB_GET_NODE_CONNECTION_INFORMATION_EX_V2)
#define USB_GET_NODE_CONNECTION_INFORMATION_EX_V2 279
#endif
#ifndef METHOD_BUFFERED
#define METHOD_BUFFERED 0
@ -419,6 +430,9 @@ DLL_DECLARE(WINAPI, CONFIGRET, CM_Get_Device_IDA, (DEVINST, PCHAR, ULONG, ULONG)
#define IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX \
CTL_CODE(FILE_DEVICE_USB, USB_GET_NODE_CONNECTION_INFORMATION_EX, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX_V2 \
CTL_CODE(FILE_DEVICE_USB, USB_GET_NODE_CONNECTION_INFORMATION_EX_V2, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_USB_GET_NODE_CONNECTION_ATTRIBUTES \
CTL_CODE(FILE_DEVICE_USB, USB_GET_NODE_CONNECTION_ATTRIBUTES, METHOD_BUFFERED, FILE_ANY_ACCESS)
@ -559,6 +573,32 @@ typedef struct USB_NODE_CONNECTION_INFORMATION_EX {
// USB_PIPE_INFO PipeList[0];
} USB_NODE_CONNECTION_INFORMATION_EX, *PUSB_NODE_CONNECTION_INFORMATION_EX;
typedef union _USB_PROTOCOLS {
ULONG ul;
struct {
ULONG Usb110:1;
ULONG Usb200:1;
ULONG Usb300:1;
ULONG ReservedMBZ:29;
};
} USB_PROTOCOLS, *PUSB_PROTOCOLS;
typedef union _USB_NODE_CONNECTION_INFORMATION_EX_V2_FLAGS {
ULONG ul;
struct {
ULONG DeviceIsOperatingAtSuperSpeedOrHigher:1;
ULONG DeviceIsSuperSpeedCapableOrHigher:1;
ULONG ReservedMBZ:30;
};
} USB_NODE_CONNECTION_INFORMATION_EX_V2_FLAGS, *PUSB_NODE_CONNECTION_INFORMATION_EX_V2_FLAGS;
typedef struct _USB_NODE_CONNECTION_INFORMATION_EX_V2 {
ULONG ConnectionIndex;
ULONG Length;
USB_PROTOCOLS SupportedUsbProtocols;
USB_NODE_CONNECTION_INFORMATION_EX_V2_FLAGS Flags;
} USB_NODE_CONNECTION_INFORMATION_EX_V2, *PUSB_NODE_CONNECTION_INFORMATION_EX_V2;
typedef struct USB_HUB_CAP_FLAGS {
ULONG HubIsHighSpeedCapable:1;
ULONG HubIsHighSpeed:1;

View File

@ -35,7 +35,7 @@ static size_t usbi_locale = 0;
* How to add a new \ref libusb_strerror() translation:
* <ol>
* <li> Download the latest \c strerror.c from:<br>
* https://raw.github.com/libusbx/libusbx/master/libusb/sterror.c </li>
* https://raw.github.com/libusb/libusb/master/libusb/sterror.c </li>
* <li> Open the file in an UTF-8 capable editor </li>
* <li> Add the 2 letter <a href="http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes">ISO 639-1</a>
* code for your locale at the end of \c usbi_locale_supported[]<br>
@ -53,11 +53,11 @@ static size_t usbi_locale = 0;
* }
* };\endcode </li>
* <li> Translate each of the English messages from the section you copied into your language </li>
* <li> Save the file (in UTF-8 format) and send it to \c libusbx-devel@lists.sourceforge.net </li>
* <li> Save the file (in UTF-8 format) and send it to \c libusb-devel\@lists.sourceforge.net </li>
* </ol>
*/
static const char* usbi_locale_supported[] = { "en", "nl", "fr" };
static const char* usbi_locale_supported[] = { "en", "nl", "fr", "ru" };
static const char* usbi_localized_errors[ARRAYSIZE(usbi_locale_supported)][LIBUSB_ERROR_COUNT] = {
{ /* English (en) */
"Success",
@ -103,7 +103,22 @@ static const char* usbi_localized_errors[ARRAYSIZE(usbi_locale_supported)][LIBUS
"Appel système abandonné (peut-être à cause dun signal)",
"Mémoire insuffisante",
"Opération non supportée or non implémentée sur cette plateforme",
"Autre erreur"
"Autre erreur",
}, { /* Russian (ru) */
"Успех",
"Ошибка ввода/вывода",
"Неверный параметр",
"Доступ запрещён (не хватает прав)",
"Устройство отсутствует (возможно, оно было отсоединено)",
"Элемент не найден",
"Ресурс занят",
"Истекло время ожидания операции",
"Переполнение",
"Ошибка канала",
"Системный вызов прерван (возможно, сигналом)",
"Память исчерпана",
"Операция не поддерживается данной платформой",
"Неизвестная ошибка"
}
};

View File

@ -1,5 +1,5 @@
/*
* Synchronous I/O functions for libusbx
* Synchronous I/O functions for libusb
* Copyright © 2007-2008 Daniel Drake <dsd@gentoo.org>
*
* This library is free software; you can redistribute it and/or
@ -28,7 +28,7 @@
/**
* @defgroup syncio Synchronous device I/O
*
* This page documents libusbx's synchronous (blocking) API for USB device I/O.
* This page documents libusb's synchronous (blocking) API for USB device I/O.
* This interface is easy to use but has some limitations. More advanced users
* may wish to consider using the \ref asyncio "asynchronous I/O API" instead.
*/
@ -222,9 +222,9 @@ static int do_sync_bulk_transfer(struct libusb_device_handle *dev_handle,
* Not all of the data may have been written.
*
* Also check <tt>transferred</tt> when dealing with a timeout error code.
* libusbx may have to split your transfer into a number of chunks to satisfy
* libusb may have to split your transfer into a number of chunks to satisfy
* underlying O/S requirements, meaning that the timeout may expire after
* the first few chunks have completed. libusbx is careful not to lose any data
* the first few chunks have completed. libusb is careful not to lose any data
* that may have been transferred; do not assume that timeout conditions
* indicate a complete lack of I/O.
*
@ -270,9 +270,9 @@ int API_EXPORTED libusb_bulk_transfer(struct libusb_device_handle *dev_handle,
* writes. Not all of the data may have been written.
*
* Also check <tt>transferred</tt> when dealing with a timeout error code.
* libusbx may have to split your transfer into a number of chunks to satisfy
* libusb may have to split your transfer into a number of chunks to satisfy
* underlying O/S requirements, meaning that the timeout may expire after
* the first few chunks have completed. libusbx is careful not to lose any data
* the first few chunks have completed. libusb is careful not to lose any data
* that may have been transferred; do not assume that timeout conditions
* indicate a complete lack of I/O.
*

View File

@ -7,7 +7,7 @@
#define LIBUSB_MINOR 0
#endif
#ifndef LIBUSB_MICRO
#define LIBUSB_MICRO 16
#define LIBUSB_MICRO 19
#endif
#ifndef LIBUSB_NANO
#define LIBUSB_NANO 0

View File

@ -0,0 +1 @@
#define LIBUSB_NANO 10903

View File

@ -1312,7 +1312,7 @@ ia64-*-hpux*)
rm -rf conftest*
;;
x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
# Find out which ABI we are using.
echo 'int i;' > conftest.$ac_ext
@ -1326,7 +1326,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
x86_64-*linux*)
LD="${LD-ld} -m elf_i386"
;;
ppc64-*linux*|powerpc64-*linux*)
powerpc64le-*linux*)
LD="${LD-ld} -m elf32lppclinux"
;;
powerpc64-*linux*)
LD="${LD-ld} -m elf32ppclinux"
;;
s390x-*linux*)
@ -1345,7 +1348,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
x86_64-*linux*)
LD="${LD-ld} -m elf_x86_64"
;;
ppc*-*linux*|powerpc*-*linux*)
powerpcle-*linux*)
LD="${LD-ld} -m elf64lppc"
;;
powerpc-*linux*)
LD="${LD-ld} -m elf64ppc"
;;
s390*-*linux*|s390*-*tpf*)

4
Externals/libusbx/missing → Externals/libusb/missing vendored Normal file → Executable file
View File

@ -1,7 +1,7 @@
#! /bin/sh
# Common wrapper for a few potentially missing GNU programs.
scriptversion=2012-06-26.16; # UTC
scriptversion=2013-10-28.13; # UTC
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
@ -160,7 +160,7 @@ give_advice ()
;;
autom4te*)
echo "You might have modified some maintainer files that require"
echo "the 'automa4te' program to be rebuilt."
echo "the 'autom4te' program to be rebuilt."
program_details 'autom4te'
;;
bison*|yacc*)

View File

@ -25,6 +25,9 @@
/* Uncomment to start with debug message logging enabled */
// #define ENABLE_DEBUG_LOGGING 1
/* Uncomment to enabling logging to system log */
// #define USE_SYSTEM_LOGGING_FACILITY
/* type of second poll() argument */
#define POLL_NFDS_TYPE unsigned int

102
Externals/libusb/msvc/errno.h vendored Normal file
View File

@ -0,0 +1,102 @@
/*
* errno.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Error numbers and access to error reporting.
*
*/
#ifndef _ERRNO_H_
#define _ERRNO_H_
#include <crtdefs.h>
/*
* Error numbers.
* TODO: Can't be sure of some of these assignments, I guessed from the
* names given by strerror and the defines in the Cygnus errno.h. A lot
* of the names from the Cygnus errno.h are not represented, and a few
* of the descriptions returned by strerror do not obviously match
* their error naming.
*/
#define EPERM 1 /* Operation not permitted */
#define ENOFILE 2 /* No such file or directory */
#define ENOENT 2
#define ESRCH 3 /* No such process */
#define EINTR 4 /* Interrupted function call */
#define EIO 5 /* Input/output error */
#define ENXIO 6 /* No such device or address */
#define E2BIG 7 /* Arg list too long */
#define ENOEXEC 8 /* Exec format error */
#define EBADF 9 /* Bad file descriptor */
#define ECHILD 10 /* No child processes */
#define EAGAIN 11 /* Resource temporarily unavailable */
#define ENOMEM 12 /* Not enough space */
#define EACCES 13 /* Permission denied */
#define EFAULT 14 /* Bad address */
/* 15 - Unknown Error */
#define EBUSY 16 /* strerror reports "Resource device" */
#define EEXIST 17 /* File exists */
#define EXDEV 18 /* Improper link (cross-device link?) */
#define ENODEV 19 /* No such device */
#define ENOTDIR 20 /* Not a directory */
#define EISDIR 21 /* Is a directory */
#define EINVAL 22 /* Invalid argument */
#define ENFILE 23 /* Too many open files in system */
#define EMFILE 24 /* Too many open files */
#define ENOTTY 25 /* Inappropriate I/O control operation */
/* 26 - Unknown Error */
#define EFBIG 27 /* File too large */
#define ENOSPC 28 /* No space left on device */
#define ESPIPE 29 /* Invalid seek (seek on a pipe?) */
#define EROFS 30 /* Read-only file system */
#define EMLINK 31 /* Too many links */
#define EPIPE 32 /* Broken pipe */
#define EDOM 33 /* Domain error (math functions) */
#define ERANGE 34 /* Result too large (possibly too small) */
/* 35 - Unknown Error */
#define EDEADLOCK 36 /* Resource deadlock avoided (non-Cyg) */
#define EDEADLK 36
#if 0
/* 37 - Unknown Error */
#define ENAMETOOLONG 38 /* Filename too long (91 in Cyg?) */
#define ENOLCK 39 /* No locks available (46 in Cyg?) */
#define ENOSYS 40 /* Function not implemented (88 in Cyg?) */
#define ENOTEMPTY 41 /* Directory not empty (90 in Cyg?) */
#define EILSEQ 42 /* Illegal byte sequence */
#endif
/*
* NOTE: ENAMETOOLONG and ENOTEMPTY conflict with definitions in the
* sockets.h header provided with windows32api-0.1.2.
* You should go and put an #if 0 ... #endif around the whole block
* of errors (look at the comment above them).
*/
#ifndef RC_INVOKED
#ifdef __cplusplus
extern "C" {
#endif
/*
* Definitions of errno. For _doserrno, sys_nerr and * sys_errlist, see
* stdlib.h.
*/
#if defined(_UWIN) || defined(_WIN32_WCE)
#undef errno
extern int errno;
#else
_CRTIMP int* __cdecl _errno(void);
#define errno (*_errno())
#endif
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* Not _ERRNO_H_ */

View File

@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectName>fxload</ProjectName>
<ProjectGuid>{9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}</ProjectGuid>
<RootNamespace>examples</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)..\$(Platform)\$(Configuration)\examples\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)..\$(Platform)\$(Configuration)\examples\$(ProjectName)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)..\$(Platform)\$(Configuration)\examples\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)..\$(Platform)\$(Configuration)\examples\$(ProjectName)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)..\$(Platform)\$(Configuration)\examples\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)..\$(Platform)\$(Configuration)\examples\$(ProjectName)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)..\$(Platform)\$(Configuration)\examples\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)..\$(Platform)\$(Configuration)\examples\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<BuildLog>
<Path>$(IntDir)$(ProjectName).htm</Path>
</BuildLog>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.;..\examples\getopt;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;__GNU_LIBRARY__;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<BuildLog>
<Path>$(IntDir)$(ProjectName).htm</Path>
</BuildLog>
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.;..\examples\getopt;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;__GNU_LIBRARY__;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<BuildLog>
<Path>$(IntDir)$(ProjectName).htm</Path>
</BuildLog>
<ClCompile>
<AdditionalIncludeDirectories>.;..\examples\getopt;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;__GNU_LIBRARY__;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<BuildLog>
<Path>$(IntDir)$(ProjectName).htm</Path>
</BuildLog>
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<AdditionalIncludeDirectories>.;..\examples\getopt;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;__GNU_LIBRARY__;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\examples\ezusb.c" />
<ClCompile Include="..\examples\fxload.c" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include=".\libusb_static_2010.vcxproj">
<Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="getopt_2010.vcxproj">
<Project>{ae83e1b4-ce06-47ee-b7a3-c3a1d7c2d71e}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\examples\ezusb.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{651ff73d-037b-4903-8dd3-56e9950be25c}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\examples\fxload.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\examples\ezusb.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\examples\ezusb.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

Some files were not shown because too many files have changed in this diff Show More