Blame libusb/libusbi.h

Packit Service b0a153
/*
Packit Service b0a153
 * Internal header for libusb
Packit Service b0a153
 * Copyright © 2007-2009 Daniel Drake <dsd@gentoo.org>
Packit Service b0a153
 * Copyright © 2001 Johannes Erdfelt <johannes@erdfelt.com>
Packit Service b0a153
 * Copyright © 2019 Nathan Hjelm <hjelmn@cs.umm.edu>
Packit Service b0a153
 * Copyright © 2019 Google LLC. All rights reserved.
Packit Service b0a153
 *
Packit Service b0a153
 * This library is free software; you can redistribute it and/or
Packit Service b0a153
 * modify it under the terms of the GNU Lesser General Public
Packit Service b0a153
 * License as published by the Free Software Foundation; either
Packit Service b0a153
 * version 2.1 of the License, or (at your option) any later version.
Packit Service b0a153
 *
Packit Service b0a153
 * This library is distributed in the hope that it will be useful,
Packit Service b0a153
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service b0a153
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service b0a153
 * Lesser General Public License for more details.
Packit Service b0a153
 *
Packit Service b0a153
 * You should have received a copy of the GNU Lesser General Public
Packit Service b0a153
 * License along with this library; if not, write to the Free Software
Packit Service b0a153
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Packit Service b0a153
 */
Packit Service b0a153
Packit Service b0a153
#ifndef LIBUSBI_H
Packit Service b0a153
#define LIBUSBI_H
Packit Service b0a153
Packit Service b0a153
#include <config.h>
Packit Service b0a153
Packit Service b0a153
#include <stdlib.h>
Packit Service b0a153
#include <assert.h>
Packit Service b0a153
#include <stddef.h>
Packit Service b0a153
#include <stdint.h>
Packit Service b0a153
#include <time.h>
Packit Service b0a153
#include <stdarg.h>
Packit Service b0a153
#ifdef HAVE_POLL_H
Packit Service b0a153
#include <poll.h>
Packit Service b0a153
#endif
Packit Service b0a153
#ifdef HAVE_MISSING_H
Packit Service b0a153
#include <missing.h>
Packit Service b0a153
#endif
Packit Service b0a153
Packit Service b0a153
#include "libusb.h"
Packit Service b0a153
#include "version.h"
Packit Service b0a153
Packit Service b0a153
/* Attribute to ensure that a structure member is aligned to a natural
Packit Service b0a153
 * pointer alignment. Used for os_priv member. */
Packit Service b0a153
#if defined(_MSC_VER)
Packit Service b0a153
#if defined(_WIN64)
Packit Service b0a153
#define PTR_ALIGNED __declspec(align(8))
Packit Service b0a153
#else
Packit Service b0a153
#define PTR_ALIGNED __declspec(align(4))
Packit Service b0a153
#endif
Packit Service b0a153
#elif defined(__GNUC__) && (__GNUC__ >= 3)
Packit Service b0a153
#define PTR_ALIGNED __attribute__((aligned(sizeof(void *))))
Packit Service b0a153
#else
Packit Service b0a153
#define PTR_ALIGNED
Packit Service b0a153
#endif
Packit Service b0a153
Packit Service b0a153
/* Inside the libusb code, mark all public functions as follows:
Packit Service b0a153
 *   return_type API_EXPORTED function_name(params) { ... }
Packit Service b0a153
 * But if the function returns a pointer, mark it as follows:
Packit Service b0a153
 *   DEFAULT_VISIBILITY return_type * LIBUSB_CALL function_name(params) { ... }
Packit Service b0a153
 * In the libusb public header, mark all declarations as:
Packit Service b0a153
 *   return_type LIBUSB_CALL function_name(params);
Packit Service b0a153
 */
Packit Service b0a153
#define API_EXPORTED LIBUSB_CALL DEFAULT_VISIBILITY
Packit Service b0a153
Packit Service b0a153
/* Macro to decorate printf-like functions, in order to get
Packit Service b0a153
 * compiler warnings about format string mistakes.
Packit Service b0a153
 */
Packit Service b0a153
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)
Packit Service b0a153
#define USBI_PRINTFLIKE(formatarg, firstvararg) \
Packit Service b0a153
	__attribute__((__format__ (__printf__, formatarg, firstvararg)))
Packit Service b0a153
#else
Packit Service b0a153
#define USBI_PRINTFLIKE(formatarg, firstvararg)
Packit Service b0a153
#endif
Packit Service b0a153
Packit Service b0a153
#ifdef __cplusplus
Packit Service b0a153
extern "C" {
Packit Service b0a153
#endif
Packit Service b0a153
Packit Service b0a153
#define DEVICE_DESC_LENGTH	18
Packit Service b0a153
Packit Service b0a153
#define USB_MAXENDPOINTS	32
Packit Service b0a153
#define USB_MAXINTERFACES	32
Packit Service b0a153
#define USB_MAXCONFIG		8
Packit Service b0a153
Packit Service b0a153
/* Backend specific capabilities */
Packit Service b0a153
#define USBI_CAP_HAS_HID_ACCESS			0x00010000
Packit Service b0a153
#define USBI_CAP_SUPPORTS_DETACH_KERNEL_DRIVER	0x00020000
Packit Service b0a153
Packit Service b0a153
/* Maximum number of bytes in a log line */
Packit Service b0a153
#define USBI_MAX_LOG_LEN	1024
Packit Service b0a153
/* Terminator for log lines */
Packit Service b0a153
#define USBI_LOG_LINE_END	"\n"
Packit Service b0a153
Packit Service b0a153
/* The following is used to silence warnings for unused variables */
Packit Service b0a153
#define UNUSED(var)		do { (void)(var); } while(0)
Packit Service b0a153
Packit Service b0a153
#if !defined(ARRAYSIZE)
Packit Service b0a153
#define ARRAYSIZE(array) (sizeof(array) / sizeof(array[0]))
Packit Service b0a153
#endif
Packit Service b0a153
Packit Service b0a153
struct list_head {
Packit Service b0a153
	struct list_head *prev, *next;
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/* Get an entry from the list
Packit Service b0a153
 *  ptr - the address of this list_head element in "type"
Packit Service b0a153
 *  type - the data type that contains "member"
Packit Service b0a153
 *  member - the list_head element in "type"
Packit Service b0a153
 */
Packit Service b0a153
#define list_entry(ptr, type, member) \
Packit Service b0a153
	((type *)((uintptr_t)(ptr) - (uintptr_t)offsetof(type, member)))
Packit Service b0a153
Packit Service b0a153
#define list_first_entry(ptr, type, member) \
Packit Service b0a153
	list_entry((ptr)->next, type, member)
Packit Service b0a153
Packit Service b0a153
/* Get each entry from a list
Packit Service b0a153
 *  pos - A structure pointer has a "member" element
Packit Service b0a153
 *  head - list head
Packit Service b0a153
 *  member - the list_head element in "pos"
Packit Service b0a153
 *  type - the type of the first parameter
Packit Service b0a153
 */
Packit Service b0a153
#define list_for_each_entry(pos, head, member, type)			\
Packit Service b0a153
	for (pos = list_entry((head)->next, type, member);		\
Packit Service b0a153
		 &pos->member != (head);				\
Packit Service b0a153
		 pos = list_entry(pos->member.next, type, member))
Packit Service b0a153
Packit Service b0a153
#define list_for_each_entry_safe(pos, n, head, member, type)		\
Packit Service b0a153
	for (pos = list_entry((head)->next, type, member),		\
Packit Service b0a153
		 n = list_entry(pos->member.next, type, member);	\
Packit Service b0a153
		 &pos->member != (head);				\
Packit Service b0a153
		 pos = n, n = list_entry(n->member.next, type, member))
Packit Service b0a153
Packit Service b0a153
#define list_empty(entry) ((entry)->next == (entry))
Packit Service b0a153
Packit Service b0a153
static inline void list_init(struct list_head *entry)
Packit Service b0a153
{
Packit Service b0a153
	entry->prev = entry->next = entry;
Packit Service b0a153
}
Packit Service b0a153
Packit Service b0a153
static inline void list_add(struct list_head *entry, struct list_head *head)
Packit Service b0a153
{
Packit Service b0a153
	entry->next = head->next;
Packit Service b0a153
	entry->prev = head;
Packit Service b0a153
Packit Service b0a153
	head->next->prev = entry;
Packit Service b0a153
	head->next = entry;
Packit Service b0a153
}
Packit Service b0a153
Packit Service b0a153
static inline void list_add_tail(struct list_head *entry,
Packit Service b0a153
	struct list_head *head)
Packit Service b0a153
{
Packit Service b0a153
	entry->next = head;
Packit Service b0a153
	entry->prev = head->prev;
Packit Service b0a153
Packit Service b0a153
	head->prev->next = entry;
Packit Service b0a153
	head->prev = entry;
Packit Service b0a153
}
Packit Service b0a153
Packit Service b0a153
static inline void list_del(struct list_head *entry)
Packit Service b0a153
{
Packit Service b0a153
	entry->next->prev = entry->prev;
Packit Service b0a153
	entry->prev->next = entry->next;
Packit Service b0a153
	entry->next = entry->prev = NULL;
Packit Service b0a153
}
Packit Service b0a153
Packit Service b0a153
static inline void list_cut(struct list_head *list, struct list_head *head)
Packit Service b0a153
{
Packit Service b0a153
	if (list_empty(head))
Packit Service b0a153
		return;
Packit Service b0a153
Packit Service b0a153
	list->next = head->next;
Packit Service b0a153
	list->next->prev = list;
Packit Service b0a153
	list->prev = head->prev;
Packit Service b0a153
	list->prev->next = list;
Packit Service b0a153
Packit Service b0a153
	list_init(head);
Packit Service b0a153
}
Packit Service b0a153
Packit Service b0a153
static inline void *usbi_reallocf(void *ptr, size_t size)
Packit Service b0a153
{
Packit Service b0a153
	void *ret = realloc(ptr, size);
Packit Service b0a153
	if (!ret)
Packit Service b0a153
		free(ptr);
Packit Service b0a153
	return ret;
Packit Service b0a153
}
Packit Service b0a153
Packit Service b0a153
#define container_of(ptr, type, member) ({			\
Packit Service b0a153
	const typeof( ((type *)0)->member ) *mptr = (ptr);	\
Packit Service b0a153
	(type *)( (char *)mptr - offsetof(type,member) );})
Packit Service b0a153
Packit Service b0a153
#ifndef CLAMP
Packit Service b0a153
#define CLAMP(val, min, max) ((val) < (min) ? (min) : ((val) > (max) ? (max) : (val)))
Packit Service b0a153
#endif
Packit Service b0a153
#ifndef MIN
Packit Service b0a153
#define MIN(a, b)	((a) < (b) ? (a) : (b))
Packit Service b0a153
#endif
Packit Service b0a153
#ifndef MAX
Packit Service b0a153
#define MAX(a, b)	((a) > (b) ? (a) : (b))
Packit Service b0a153
#endif
Packit Service b0a153
Packit Service b0a153
#define TIMESPEC_IS_SET(ts) ((ts)->tv_sec != 0 || (ts)->tv_nsec != 0)
Packit Service b0a153
Packit Service b0a153
#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
Packit Service b0a153
#define TIMEVAL_TV_SEC_TYPE	long
Packit Service b0a153
#else
Packit Service b0a153
#define TIMEVAL_TV_SEC_TYPE	time_t
Packit Service b0a153
#endif
Packit Service b0a153
Packit Service b0a153
/* Some platforms don't have this define */
Packit Service b0a153
#ifndef TIMESPEC_TO_TIMEVAL
Packit Service b0a153
#define TIMESPEC_TO_TIMEVAL(tv, ts)					\
Packit Service b0a153
	do {								\
Packit Service b0a153
		(tv)->tv_sec = (TIMEVAL_TV_SEC_TYPE) (ts)->tv_sec;	\
Packit Service b0a153
		(tv)->tv_usec = (ts)->tv_nsec / 1000;			\
Packit Service b0a153
	} while (0)
Packit Service b0a153
#endif
Packit Service b0a153
Packit Service b0a153
#ifdef ENABLE_LOGGING
Packit Service b0a153
Packit Service b0a153
#if defined(_MSC_VER) && (_MSC_VER < 1900)
Packit Service b0a153
#define snprintf usbi_snprintf
Packit Service b0a153
#define vsnprintf usbi_vsnprintf
Packit Service b0a153
int usbi_snprintf(char *dst, size_t size, const char *format, ...);
Packit Service b0a153
int usbi_vsnprintf(char *dst, size_t size, const char *format, va_list ap);
Packit Service b0a153
#define LIBUSB_PRINTF_WIN32
Packit Service b0a153
#endif /* defined(_MSC_VER) && (_MSC_VER < 1900) */
Packit Service b0a153
Packit Service b0a153
void usbi_log(struct libusb_context *ctx, enum libusb_log_level level,
Packit Service b0a153
	const char *function, const char *format, ...) USBI_PRINTFLIKE(4, 5);
Packit Service b0a153
Packit Service b0a153
void usbi_log_v(struct libusb_context *ctx, enum libusb_log_level level,
Packit Service b0a153
	const char *function, const char *format, va_list args) USBI_PRINTFLIKE(4, 0);
Packit Service b0a153
Packit Service b0a153
#if !defined(_MSC_VER) || (_MSC_VER >= 1400)
Packit Service b0a153
Packit Service b0a153
#define _usbi_log(ctx, level, ...) usbi_log(ctx, level, __FUNCTION__, __VA_ARGS__)
Packit Service b0a153
Packit Service b0a153
#define usbi_err(ctx, ...) _usbi_log(ctx, LIBUSB_LOG_LEVEL_ERROR, __VA_ARGS__)
Packit Service b0a153
#define usbi_warn(ctx, ...) _usbi_log(ctx, LIBUSB_LOG_LEVEL_WARNING, __VA_ARGS__)
Packit Service b0a153
#define usbi_info(ctx, ...) _usbi_log(ctx, LIBUSB_LOG_LEVEL_INFO, __VA_ARGS__)
Packit Service b0a153
#define usbi_dbg(...) _usbi_log(NULL, LIBUSB_LOG_LEVEL_DEBUG, __VA_ARGS__)
Packit Service b0a153
Packit Service b0a153
#else /* !defined(_MSC_VER) || (_MSC_VER >= 1400) */
Packit Service b0a153
Packit Service b0a153
#define LOG_BODY(ctxt, level)				\
Packit Service b0a153
{							\
Packit Service b0a153
	va_list args;					\
Packit Service b0a153
	va_start(args, format);				\
Packit Service b0a153
	usbi_log_v(ctxt, level, "", format, args);	\
Packit Service b0a153
	va_end(args);					\
Packit Service b0a153
}
Packit Service b0a153
Packit Service b0a153
static inline void usbi_err(struct libusb_context *ctx, const char *format, ...)
Packit Service b0a153
	LOG_BODY(ctx, LIBUSB_LOG_LEVEL_ERROR)
Packit Service b0a153
static inline void usbi_warn(struct libusb_context *ctx, const char *format, ...)
Packit Service b0a153
	LOG_BODY(ctx, LIBUSB_LOG_LEVEL_WARNING)
Packit Service b0a153
static inline void usbi_info(struct libusb_context *ctx, const char *format, ...)
Packit Service b0a153
	LOG_BODY(ctx, LIBUSB_LOG_LEVEL_INFO)
Packit Service b0a153
static inline void usbi_dbg(const char *format, ...)
Packit Service b0a153
	LOG_BODY(NULL, LIBUSB_LOG_LEVEL_DEBUG)
Packit Service b0a153
Packit Service b0a153
#endif /* !defined(_MSC_VER) || (_MSC_VER >= 1400) */
Packit Service b0a153
Packit Service b0a153
#else /* ENABLE_LOGGING */
Packit Service b0a153
Packit Service b0a153
#define usbi_err(ctx, ...) do { (void)ctx; } while (0)
Packit Service b0a153
#define usbi_warn(ctx, ...) do { (void)ctx; } while (0)
Packit Service b0a153
#define usbi_info(ctx, ...) do { (void)ctx; } while (0)
Packit Service b0a153
#define usbi_dbg(...) do {} while (0)
Packit Service b0a153
Packit Service b0a153
#endif /* ENABLE_LOGGING */
Packit Service b0a153
Packit Service b0a153
#define USBI_GET_CONTEXT(ctx)				\
Packit Service b0a153
	do {						\
Packit Service b0a153
		if (!(ctx))				\
Packit Service b0a153
			(ctx) = usbi_default_context;	\
Packit Service b0a153
	} while(0)
Packit Service b0a153
Packit Service b0a153
#define DEVICE_CTX(dev)		((dev)->ctx)
Packit Service b0a153
#define HANDLE_CTX(handle)	(DEVICE_CTX((handle)->dev))
Packit Service b0a153
#define TRANSFER_CTX(transfer)	(HANDLE_CTX((transfer)->dev_handle))
Packit Service b0a153
#define ITRANSFER_CTX(transfer) \
Packit Service b0a153
	(TRANSFER_CTX(USBI_TRANSFER_TO_LIBUSB_TRANSFER(transfer)))
Packit Service b0a153
Packit Service b0a153
#define IS_EPIN(ep)		(0 != ((ep) & LIBUSB_ENDPOINT_IN))
Packit Service b0a153
#define IS_EPOUT(ep)		(!IS_EPIN(ep))
Packit Service b0a153
#define IS_XFERIN(xfer)		(0 != ((xfer)->endpoint & LIBUSB_ENDPOINT_IN))
Packit Service b0a153
#define IS_XFEROUT(xfer)	(!IS_XFERIN(xfer))
Packit Service b0a153
Packit Service b0a153
/* Internal abstraction for thread synchronization */
Packit Service b0a153
#if defined(THREADS_POSIX)
Packit Service b0a153
#include "os/threads_posix.h"
Packit Service b0a153
#elif defined(OS_WINDOWS) || defined(OS_WINCE)
Packit Service b0a153
#include "os/threads_windows.h"
Packit Service b0a153
#endif
Packit Service b0a153
Packit Service b0a153
extern struct libusb_context *usbi_default_context;
Packit Service b0a153
Packit Service b0a153
/* Forward declaration for use in context (fully defined inside poll abstraction) */
Packit Service b0a153
struct pollfd;
Packit Service b0a153
Packit Service b0a153
struct libusb_context {
Packit Service b0a153
#if defined(ENABLE_LOGGING) && !defined(ENABLE_DEBUG_LOGGING)
Packit Service b0a153
	enum libusb_log_level debug;
Packit Service b0a153
	int debug_fixed;
Packit Service b0a153
	libusb_log_cb log_handler;
Packit Service b0a153
#endif
Packit Service b0a153
Packit Service b0a153
	/* internal event pipe, used for signalling occurrence of an internal event. */
Packit Service b0a153
	int event_pipe[2];
Packit Service b0a153
Packit Service b0a153
	struct list_head usb_devs;
Packit Service b0a153
	usbi_mutex_t usb_devs_lock;
Packit Service b0a153
Packit Service b0a153
	/* A list of open handles. Backends are free to traverse this if required.
Packit Service b0a153
	 */
Packit Service b0a153
	struct list_head open_devs;
Packit Service b0a153
	usbi_mutex_t open_devs_lock;
Packit Service b0a153
Packit Service b0a153
	/* A list of registered hotplug callbacks */
Packit Service b0a153
	struct list_head hotplug_cbs;
Packit Service b0a153
	libusb_hotplug_callback_handle next_hotplug_cb_handle;
Packit Service b0a153
	usbi_mutex_t hotplug_cbs_lock;
Packit Service b0a153
Packit Service b0a153
	/* this is a list of in-flight transfer handles, sorted by timeout
Packit Service b0a153
	 * expiration. URBs to timeout the soonest are placed at the beginning of
Packit Service b0a153
	 * the list, URBs that will time out later are placed after, and urbs with
Packit Service b0a153
	 * infinite timeout are always placed at the very end. */
Packit Service b0a153
	struct list_head flying_transfers;
Packit Service b0a153
	/* Note paths taking both this and usbi_transfer->lock must always
Packit Service b0a153
	 * take this lock first */
Packit Service b0a153
	usbi_mutex_t flying_transfers_lock;
Packit Service b0a153
Packit Service b0a153
	/* user callbacks for pollfd changes */
Packit Service b0a153
	libusb_pollfd_added_cb fd_added_cb;
Packit Service b0a153
	libusb_pollfd_removed_cb fd_removed_cb;
Packit Service b0a153
	void *fd_cb_user_data;
Packit Service b0a153
Packit Service b0a153
	/* ensures that only one thread is handling events at any one time */
Packit Service b0a153
	usbi_mutex_t events_lock;
Packit Service b0a153
Packit Service b0a153
	/* used to see if there is an active thread doing event handling */
Packit Service b0a153
	int event_handler_active;
Packit Service b0a153
Packit Service b0a153
	/* A thread-local storage key to track which thread is performing event
Packit Service b0a153
	 * handling */
Packit Service b0a153
	usbi_tls_key_t event_handling_key;
Packit Service b0a153
Packit Service b0a153
	/* used to wait for event completion in threads other than the one that is
Packit Service b0a153
	 * event handling */
Packit Service b0a153
	usbi_mutex_t event_waiters_lock;
Packit Service b0a153
	usbi_cond_t event_waiters_cond;
Packit Service b0a153
Packit Service b0a153
	/* A lock to protect internal context event data. */
Packit Service b0a153
	usbi_mutex_t event_data_lock;
Packit Service b0a153
Packit Service b0a153
	/* A bitmask of flags that are set to indicate specific events that need to
Packit Service b0a153
	 * be handled. Protected by event_data_lock. */
Packit Service b0a153
	unsigned int event_flags;
Packit Service b0a153
Packit Service b0a153
	/* A counter that is set when we want to interrupt and prevent event handling,
Packit Service b0a153
	 * in order to safely close a device. Protected by event_data_lock. */
Packit Service b0a153
	unsigned int device_close;
Packit Service b0a153
Packit Service b0a153
	/* list and count of poll fds and an array of poll fd structures that is
Packit Service b0a153
	 * (re)allocated as necessary prior to polling. Protected by event_data_lock. */
Packit Service b0a153
	struct list_head ipollfds;
Packit Service b0a153
        /* list of pollfds that have been removed. keeps track of pollfd changes
Packit Service b0a153
         * between the poll call and */
Packit Service b0a153
        struct list_head removed_ipollfds;
Packit Service b0a153
	struct pollfd *pollfds;
Packit Service b0a153
	POLL_NFDS_TYPE pollfds_cnt;
Packit Service b0a153
Packit Service b0a153
	/* A list of pending hotplug messages. Protected by event_data_lock. */
Packit Service b0a153
	struct list_head hotplug_msgs;
Packit Service b0a153
Packit Service b0a153
	/* A list of pending completed transfers. Protected by event_data_lock. */
Packit Service b0a153
	struct list_head completed_transfers;
Packit Service b0a153
Packit Service b0a153
#ifdef USBI_TIMERFD_AVAILABLE
Packit Service b0a153
	/* used for timeout handling, if supported by OS.
Packit Service b0a153
	 * this timerfd is maintained to trigger on the next pending timeout */
Packit Service b0a153
	int timerfd;
Packit Service b0a153
#endif
Packit Service b0a153
Packit Service b0a153
	struct list_head list;
Packit Service b0a153
Packit Service b0a153
	PTR_ALIGNED unsigned char os_priv[ZERO_SIZED_ARRAY];
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
enum usbi_event_flags {
Packit Service b0a153
	/* The list of pollfds has been modified */
Packit Service b0a153
	USBI_EVENT_POLLFDS_MODIFIED = 1U << 0,
Packit Service b0a153
Packit Service b0a153
	/* The user has interrupted the event handler */
Packit Service b0a153
	USBI_EVENT_USER_INTERRUPT = 1U << 1,
Packit Service b0a153
Packit Service b0a153
	/* A hotplug callback deregistration is pending */
Packit Service b0a153
	USBI_EVENT_HOTPLUG_CB_DEREGISTERED = 1U << 2,
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/* Macros for managing event handling state */
Packit Service b0a153
#define usbi_handling_events(ctx) \
Packit Service b0a153
	(usbi_tls_key_get((ctx)->event_handling_key) != NULL)
Packit Service b0a153
Packit Service b0a153
#define usbi_start_event_handling(ctx) \
Packit Service b0a153
	usbi_tls_key_set((ctx)->event_handling_key, ctx)
Packit Service b0a153
Packit Service b0a153
#define usbi_end_event_handling(ctx) \
Packit Service b0a153
	usbi_tls_key_set((ctx)->event_handling_key, NULL)
Packit Service b0a153
Packit Service b0a153
/* Update the following macro if new event sources are added */
Packit Service b0a153
#define usbi_pending_events(ctx) \
Packit Service b0a153
	((ctx)->event_flags || (ctx)->device_close \
Packit Service b0a153
	 || !list_empty(&(ctx)->hotplug_msgs) || !list_empty(&(ctx)->completed_transfers))
Packit Service b0a153
Packit Service b0a153
#ifdef USBI_TIMERFD_AVAILABLE
Packit Service b0a153
#define usbi_using_timerfd(ctx) ((ctx)->timerfd >= 0)
Packit Service b0a153
#else
Packit Service b0a153
#define usbi_using_timerfd(ctx) (0)
Packit Service b0a153
#endif
Packit Service b0a153
Packit Service b0a153
struct libusb_device {
Packit Service b0a153
	/* lock protects refcnt, everything else is finalized at initialization
Packit Service b0a153
	 * time */
Packit Service b0a153
	usbi_mutex_t lock;
Packit Service b0a153
	int refcnt;
Packit Service b0a153
Packit Service b0a153
	struct libusb_context *ctx;
Packit Service b0a153
Packit Service b0a153
	uint8_t bus_number;
Packit Service b0a153
	uint8_t port_number;
Packit Service b0a153
	struct libusb_device* parent_dev;
Packit Service b0a153
	uint8_t device_address;
Packit Service b0a153
	uint8_t num_configurations;
Packit Service b0a153
	enum libusb_speed speed;
Packit Service b0a153
Packit Service b0a153
	struct list_head list;
Packit Service b0a153
	unsigned long session_data;
Packit Service b0a153
Packit Service b0a153
	struct libusb_device_descriptor device_descriptor;
Packit Service b0a153
	int attached;
Packit Service b0a153
Packit Service b0a153
	PTR_ALIGNED unsigned char os_priv[ZERO_SIZED_ARRAY];
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
struct libusb_device_handle {
Packit Service b0a153
	/* lock protects claimed_interfaces */
Packit Service b0a153
	usbi_mutex_t lock;
Packit Service b0a153
	unsigned long claimed_interfaces;
Packit Service b0a153
Packit Service b0a153
	struct list_head list;
Packit Service b0a153
	struct libusb_device *dev;
Packit Service b0a153
	int auto_detach_kernel_driver;
Packit Service b0a153
Packit Service b0a153
	PTR_ALIGNED unsigned char os_priv[ZERO_SIZED_ARRAY];
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
enum {
Packit Service b0a153
	USBI_CLOCK_MONOTONIC,
Packit Service b0a153
	USBI_CLOCK_REALTIME
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/* in-memory transfer layout:
Packit Service b0a153
 *
Packit Service b0a153
 * 1. struct usbi_transfer
Packit Service b0a153
 * 2. struct libusb_transfer (which includes iso packets) [variable size]
Packit Service b0a153
 * 3. os private data [variable size]
Packit Service b0a153
 *
Packit Service b0a153
 * from a libusb_transfer, you can get the usbi_transfer by rewinding the
Packit Service b0a153
 * appropriate number of bytes.
Packit Service b0a153
 * the usbi_transfer includes the number of allocated packets, so you can
Packit Service b0a153
 * determine the size of the transfer and hence the start and length of the
Packit Service b0a153
 * OS-private data.
Packit Service b0a153
 */
Packit Service b0a153
Packit Service b0a153
struct usbi_transfer {
Packit Service b0a153
	int num_iso_packets;
Packit Service b0a153
	struct list_head list;
Packit Service b0a153
	struct list_head completed_list;
Packit Service b0a153
	struct timeval timeout;
Packit Service b0a153
	int transferred;
Packit Service b0a153
	uint32_t stream_id;
Packit Service b0a153
	uint8_t state_flags;   /* Protected by usbi_transfer->lock */
Packit Service b0a153
	uint8_t timeout_flags; /* Protected by the flying_stransfers_lock */
Packit Service b0a153
Packit Service b0a153
	/* this lock is held during libusb_submit_transfer() and
Packit Service b0a153
	 * libusb_cancel_transfer() (allowing the OS backend to prevent duplicate
Packit Service b0a153
	 * cancellation, submission-during-cancellation, etc). the OS backend
Packit Service b0a153
	 * should also take this lock in the handle_events path, to prevent the user
Packit Service b0a153
	 * cancelling the transfer from another thread while you are processing
Packit Service b0a153
	 * its completion (presumably there would be races within your OS backend
Packit Service b0a153
	 * if this were possible).
Packit Service b0a153
	 * Note paths taking both this and the flying_transfers_lock must
Packit Service b0a153
	 * always take the flying_transfers_lock first */
Packit Service b0a153
	usbi_mutex_t lock;
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
enum usbi_transfer_state_flags {
Packit Service b0a153
	/* Transfer successfully submitted by backend */
Packit Service b0a153
	USBI_TRANSFER_IN_FLIGHT = 1U << 0,
Packit Service b0a153
Packit Service b0a153
	/* Cancellation was requested via libusb_cancel_transfer() */
Packit Service b0a153
	USBI_TRANSFER_CANCELLING = 1U << 1,
Packit Service b0a153
Packit Service b0a153
	/* Operation on the transfer failed because the device disappeared */
Packit Service b0a153
	USBI_TRANSFER_DEVICE_DISAPPEARED = 1U << 2,
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
enum usbi_transfer_timeout_flags {
Packit Service b0a153
	/* Set by backend submit_transfer() if the OS handles timeout */
Packit Service b0a153
	USBI_TRANSFER_OS_HANDLES_TIMEOUT = 1U << 0,
Packit Service b0a153
Packit Service b0a153
	/* The transfer timeout has been handled */
Packit Service b0a153
	USBI_TRANSFER_TIMEOUT_HANDLED = 1U << 1,
Packit Service b0a153
Packit Service b0a153
	/* The transfer timeout was successfully processed */
Packit Service b0a153
	USBI_TRANSFER_TIMED_OUT = 1U << 2,
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
#define USBI_TRANSFER_TO_LIBUSB_TRANSFER(transfer)			\
Packit Service b0a153
	((struct libusb_transfer *)(((unsigned char *)(transfer))	\
Packit Service b0a153
		+ sizeof(struct usbi_transfer)))
Packit Service b0a153
#define LIBUSB_TRANSFER_TO_USBI_TRANSFER(transfer)			\
Packit Service b0a153
	((struct usbi_transfer *)(((unsigned char *)(transfer))		\
Packit Service b0a153
		- sizeof(struct usbi_transfer)))
Packit Service b0a153
Packit Service b0a153
static inline void *usbi_transfer_get_os_priv(struct usbi_transfer *transfer)
Packit Service b0a153
{
Packit Service b0a153
	assert(transfer->num_iso_packets >= 0);
Packit Service b0a153
	return ((unsigned char *)transfer) + sizeof(struct usbi_transfer)
Packit Service b0a153
		+ sizeof(struct libusb_transfer)
Packit Service b0a153
		+ ((size_t)transfer->num_iso_packets
Packit Service b0a153
			* sizeof(struct libusb_iso_packet_descriptor));
Packit Service b0a153
}
Packit Service b0a153
Packit Service b0a153
/* bus structures */
Packit Service b0a153
Packit Service b0a153
/* All standard descriptors have these 2 fields in common */
Packit Service b0a153
struct usb_descriptor_header {
Packit Service b0a153
	uint8_t bLength;
Packit Service b0a153
	uint8_t bDescriptorType;
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
/* shared data and functions */
Packit Service b0a153
Packit Service b0a153
int usbi_io_init(struct libusb_context *ctx);
Packit Service b0a153
void usbi_io_exit(struct libusb_context *ctx);
Packit Service b0a153
Packit Service b0a153
struct libusb_device *usbi_alloc_device(struct libusb_context *ctx,
Packit Service b0a153
	unsigned long session_id);
Packit Service b0a153
struct libusb_device *usbi_get_device_by_session_id(struct libusb_context *ctx,
Packit Service b0a153
	unsigned long session_id);
Packit Service b0a153
int usbi_sanitize_device(struct libusb_device *dev);
Packit Service b0a153
void usbi_handle_disconnect(struct libusb_device_handle *dev_handle);
Packit Service b0a153
Packit Service b0a153
int usbi_handle_transfer_completion(struct usbi_transfer *itransfer,
Packit Service b0a153
	enum libusb_transfer_status status);
Packit Service b0a153
int usbi_handle_transfer_cancellation(struct usbi_transfer *transfer);
Packit Service b0a153
void usbi_signal_transfer_completion(struct usbi_transfer *transfer);
Packit Service b0a153
Packit Service b0a153
int usbi_parse_descriptor(const unsigned char *source, const char *descriptor,
Packit Service b0a153
	void *dest, int host_endian);
Packit Service b0a153
int usbi_device_cache_descriptor(libusb_device *dev);
Packit Service b0a153
int usbi_get_config_index_by_value(struct libusb_device *dev,
Packit Service b0a153
	uint8_t bConfigurationValue, int *idx);
Packit Service b0a153
Packit Service b0a153
void usbi_connect_device (struct libusb_device *dev);
Packit Service b0a153
void usbi_disconnect_device (struct libusb_device *dev);
Packit Service b0a153
Packit Service b0a153
int usbi_signal_event(struct libusb_context *ctx);
Packit Service b0a153
int usbi_clear_event(struct libusb_context *ctx);
Packit Service b0a153
Packit Service b0a153
/* Internal abstraction for poll (needs struct usbi_transfer on Windows) */
Packit Service b0a153
#if defined(OS_LINUX) || defined(OS_DARWIN) || defined(OS_OPENBSD) || defined(OS_NETBSD) ||\
Pino Toscano 541ef3
	defined(OS_HAIKU) || defined(OS_SUNOS) || defined(OS_NULL)
Packit Service b0a153
#include <unistd.h>
Packit Service b0a153
#include "os/poll_posix.h"
Packit Service b0a153
#elif defined(OS_WINDOWS) || defined(OS_WINCE)
Packit Service b0a153
#include "os/poll_windows.h"
Packit Service b0a153
#endif
Packit Service b0a153
Packit Service b0a153
struct usbi_pollfd {
Packit Service b0a153
	/* must come first */
Packit Service b0a153
	struct libusb_pollfd pollfd;
Packit Service b0a153
Packit Service b0a153
	struct list_head list;
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
int usbi_add_pollfd(struct libusb_context *ctx, int fd, short events);
Packit Service b0a153
void usbi_remove_pollfd(struct libusb_context *ctx, int fd);
Packit Service b0a153
Packit Service b0a153
/* device discovery */
Packit Service b0a153
Packit Service b0a153
/* we traverse usbfs without knowing how many devices we are going to find.
Packit Service b0a153
 * so we create this discovered_devs model which is similar to a linked-list
Packit Service b0a153
 * which grows when required. it can be freed once discovery has completed,
Packit Service b0a153
 * eliminating the need for a list node in the libusb_device structure
Packit Service b0a153
 * itself. */
Packit Service b0a153
struct discovered_devs {
Packit Service b0a153
	size_t len;
Packit Service b0a153
	size_t capacity;
Packit Service b0a153
	struct libusb_device *devices[ZERO_SIZED_ARRAY];
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
struct discovered_devs *discovered_devs_append(
Packit Service b0a153
	struct discovered_devs *discdevs, struct libusb_device *dev);
Packit Service b0a153
Packit Service b0a153
/* OS abstraction */
Packit Service b0a153
Packit Service b0a153
/* This is the interface that OS backends need to implement.
Packit Service b0a153
 * All fields are mandatory, except ones explicitly noted as optional. */
Packit Service b0a153
struct usbi_os_backend {
Packit Service b0a153
	/* A human-readable name for your backend, e.g. "Linux usbfs" */
Packit Service b0a153
	const char *name;
Packit Service b0a153
Packit Service b0a153
	/* Binary mask for backend specific capabilities */
Packit Service b0a153
	uint32_t caps;
Packit Service b0a153
Packit Service b0a153
	/* Perform initialization of your backend. You might use this function
Packit Service b0a153
	 * to determine specific capabilities of the system, allocate required
Packit Service b0a153
	 * data structures for later, etc.
Packit Service b0a153
	 *
Packit Service b0a153
	 * This function is called when a libusb user initializes the library
Packit Service b0a153
	 * prior to use.
Packit Service b0a153
	 *
Packit Service b0a153
	 * Return 0 on success, or a LIBUSB_ERROR code on failure.
Packit Service b0a153
	 */
Packit Service b0a153
	int (*init)(struct libusb_context *ctx);
Packit Service b0a153
Packit Service b0a153
	/* Deinitialization. Optional. This function should destroy anything
Packit Service b0a153
	 * that was set up by init.
Packit Service b0a153
	 *
Packit Service b0a153
	 * This function is called when the user deinitializes the library.
Packit Service b0a153
	 */
Packit Service b0a153
	void (*exit)(struct libusb_context *ctx);
Packit Service b0a153
Packit Service b0a153
	/* Set a backend-specific option. Optional.
Packit Service b0a153
	 *
Packit Service b0a153
	 * This function is called when the user calls libusb_set_option() and
Packit Service b0a153
	 * the option is not handled by the core library.
Packit Service b0a153
	 *
Packit Service b0a153
	 * Return 0 on success, or a LIBUSB_ERROR code on failure.
Packit Service b0a153
	 */
Packit Service b0a153
	int (*set_option)(struct libusb_context *ctx, enum libusb_option option,
Packit Service b0a153
		va_list args);
Packit Service b0a153
Packit Service b0a153
	/* Enumerate all the USB devices on the system, returning them in a list
Packit Service b0a153
	 * of discovered devices.
Packit Service b0a153
	 *
Packit Service b0a153
	 * Your implementation should enumerate all devices on the system,
Packit Service b0a153
	 * regardless of whether they have been seen before or not.
Packit Service b0a153
	 *
Packit Service b0a153
	 * When you have found a device, compute a session ID for it. The session
Packit Service b0a153
	 * ID should uniquely represent that particular device for that particular
Packit Service b0a153
	 * connection session since boot (i.e. if you disconnect and reconnect a
Packit Service b0a153
	 * device immediately after, it should be assigned a different session ID).
Packit Service b0a153
	 * If your OS cannot provide a unique session ID as described above,
Packit Service b0a153
	 * presenting a session ID of (bus_number << 8 | device_address) should
Packit Service b0a153
	 * be sufficient. Bus numbers and device addresses wrap and get reused,
Packit Service b0a153
	 * but that is an unlikely case.
Packit Service b0a153
	 *
Packit Service b0a153
	 * After computing a session ID for a device, call
Packit Service b0a153
	 * usbi_get_device_by_session_id(). This function checks if libusb already
Packit Service b0a153
	 * knows about the device, and if so, it provides you with a reference
Packit Service b0a153
	 * to a libusb_device structure for it.
Packit Service b0a153
	 *
Packit Service b0a153
	 * If usbi_get_device_by_session_id() returns NULL, it is time to allocate
Packit Service b0a153
	 * a new device structure for the device. Call usbi_alloc_device() to
Packit Service b0a153
	 * obtain a new libusb_device structure with reference count 1. Populate
Packit Service b0a153
	 * the bus_number and device_address attributes of the new device, and
Packit Service b0a153
	 * perform any other internal backend initialization you need to do. At
Packit Service b0a153
	 * this point, you should be ready to provide device descriptors and so
Packit Service b0a153
	 * on through the get_*_descriptor functions. Finally, call
Packit Service b0a153
	 * usbi_sanitize_device() to perform some final sanity checks on the
Packit Service b0a153
	 * device. Assuming all of the above succeeded, we can now continue.
Packit Service b0a153
	 * If any of the above failed, remember to unreference the device that
Packit Service b0a153
	 * was returned by usbi_alloc_device().
Packit Service b0a153
	 *
Packit Service b0a153
	 * At this stage we have a populated libusb_device structure (either one
Packit Service b0a153
	 * that was found earlier, or one that we have just allocated and
Packit Service b0a153
	 * populated). This can now be added to the discovered devices list
Packit Service b0a153
	 * using discovered_devs_append(). Note that discovered_devs_append()
Packit Service b0a153
	 * may reallocate the list, returning a new location for it, and also
Packit Service b0a153
	 * note that reallocation can fail. Your backend should handle these
Packit Service b0a153
	 * error conditions appropriately.
Packit Service b0a153
	 *
Packit Service b0a153
	 * This function should not generate any bus I/O and should not block.
Packit Service b0a153
	 * If I/O is required (e.g. reading the active configuration value), it is
Packit Service b0a153
	 * OK to ignore these suggestions :)
Packit Service b0a153
	 *
Packit Service b0a153
	 * This function is executed when the user wishes to retrieve a list
Packit Service b0a153
	 * of USB devices connected to the system.
Packit Service b0a153
	 *
Packit Service b0a153
	 * If the backend has hotplug support, this function is not used!
Packit Service b0a153
	 *
Packit Service b0a153
	 * Return 0 on success, or a LIBUSB_ERROR code on failure.
Packit Service b0a153
	 */
Packit Service b0a153
	int (*get_device_list)(struct libusb_context *ctx,
Packit Service b0a153
		struct discovered_devs **discdevs);
Packit Service b0a153
Packit Service b0a153
	/* Apps which were written before hotplug support, may listen for
Packit Service b0a153
	 * hotplug events on their own and call libusb_get_device_list on
Packit Service b0a153
	 * device addition. In this case libusb_get_device_list will likely
Packit Service b0a153
	 * return a list without the new device in there, as the hotplug
Packit Service b0a153
	 * event thread will still be busy enumerating the device, which may
Packit Service b0a153
	 * take a while, or may not even have seen the event yet.
Packit Service b0a153
	 *
Packit Service b0a153
	 * To avoid this libusb_get_device_list will call this optional
Packit Service b0a153
	 * function for backends with hotplug support before copying
Packit Service b0a153
	 * ctx->usb_devs to the user. In this function the backend should
Packit Service b0a153
	 * ensure any pending hotplug events are fully processed before
Packit Service b0a153
	 * returning.
Packit Service b0a153
	 *
Packit Service b0a153
	 * Optional, should be implemented by backends with hotplug support.
Packit Service b0a153
	 */
Packit Service b0a153
	void (*hotplug_poll)(void);
Packit Service b0a153
Packit Service b0a153
	/* Wrap a platform-specific device handle for I/O and other USB
Packit Service b0a153
	 * operations. The device handle is preallocated for you.
Packit Service b0a153
	 *
Packit Service b0a153
	 * Your backend should allocate any internal resources required for I/O
Packit Service b0a153
	 * and other operations so that those operations can happen (hopefully)
Packit Service b0a153
	 * without hiccup. This is also a good place to inform libusb that it
Packit Service b0a153
	 * should monitor certain file descriptors related to this device -
Packit Service b0a153
	 * see the usbi_add_pollfd() function.
Packit Service b0a153
	 *
Packit Service b0a153
	 * Your backend should also initialize the device structure
Packit Service b0a153
	 * (dev_handle->dev), which is NULL at the beginning of the call.
Packit Service b0a153
	 *
Packit Service b0a153
	 * This function should not generate any bus I/O and should not block.
Packit Service b0a153
	 *
Packit Service b0a153
	 * This function is called when the user attempts to wrap an existing
Packit Service b0a153
	 * platform-specific device handle for a device.
Packit Service b0a153
	 *
Packit Service b0a153
	 * Return:
Packit Service b0a153
	 * - 0 on success
Packit Service b0a153
	 * - LIBUSB_ERROR_ACCESS if the user has insufficient permissions
Packit Service b0a153
	 * - another LIBUSB_ERROR code on other failure
Packit Service b0a153
	 *
Packit Service b0a153
	 * Do not worry about freeing the handle on failed open, the upper layers
Packit Service b0a153
	 * do this for you.
Packit Service b0a153
	 */
Packit Service b0a153
	int (*wrap_sys_device)(struct libusb_context *ctx,
Packit Service b0a153
		struct libusb_device_handle *dev_handle, intptr_t sys_dev);
Packit Service b0a153
Packit Service b0a153
	/* Open a device for I/O and other USB operations. The device handle
Packit Service b0a153
	 * is preallocated for you, you can retrieve the device in question
Packit Service b0a153
	 * through handle->dev.
Packit Service b0a153
	 *
Packit Service b0a153
	 * Your backend should allocate any internal resources required for I/O
Packit Service b0a153
	 * and other operations so that those operations can happen (hopefully)
Packit Service b0a153
	 * without hiccup. This is also a good place to inform libusb that it
Packit Service b0a153
	 * should monitor certain file descriptors related to this device -
Packit Service b0a153
	 * see the usbi_add_pollfd() function.
Packit Service b0a153
	 *
Packit Service b0a153
	 * This function should not generate any bus I/O and should not block.
Packit Service b0a153
	 *
Packit Service b0a153
	 * This function is called when the user attempts to obtain a device
Packit Service b0a153
	 * handle for a device.
Packit Service b0a153
	 *
Packit Service b0a153
	 * Return:
Packit Service b0a153
	 * - 0 on success
Packit Service b0a153
	 * - LIBUSB_ERROR_ACCESS if the user has insufficient permissions
Packit Service b0a153
	 * - LIBUSB_ERROR_NO_DEVICE if the device has been disconnected since
Packit Service b0a153
	 *   discovery
Packit Service b0a153
	 * - another LIBUSB_ERROR code on other failure
Packit Service b0a153
	 *
Packit Service b0a153
	 * Do not worry about freeing the handle on failed open, the upper layers
Packit Service b0a153
	 * do this for you.
Packit Service b0a153
	 */
Packit Service b0a153
	int (*open)(struct libusb_device_handle *dev_handle);
Packit Service b0a153
Packit Service b0a153
	/* Close a device such that the handle cannot be used again. Your backend
Packit Service b0a153
	 * should destroy any resources that were allocated in the open path.
Packit Service b0a153
	 * This may also be a good place to call usbi_remove_pollfd() to inform
Packit Service b0a153
	 * libusb of any file descriptors associated with this device that should
Packit Service b0a153
	 * no longer be monitored.
Packit Service b0a153
	 *
Packit Service b0a153
	 * This function is called when the user closes a device handle.
Packit Service b0a153
	 */
Packit Service b0a153
	void (*close)(struct libusb_device_handle *dev_handle);
Packit Service b0a153
Packit Service b0a153
	/* Retrieve the device descriptor from a device.
Packit Service b0a153
	 *
Packit Service b0a153
	 * The descriptor should be retrieved from memory, NOT via bus I/O to the
Packit Service b0a153
	 * device. This means that you may have to cache it in a private structure
Packit Service b0a153
	 * during get_device_list enumeration. Alternatively, you may be able
Packit Service b0a153
	 * to retrieve it from a kernel interface (some Linux setups can do this)
Packit Service b0a153
	 * still without generating bus I/O.
Packit Service b0a153
	 *
Packit Service b0a153
	 * This function is expected to write DEVICE_DESC_LENGTH (18) bytes into
Packit Service b0a153
	 * buffer, which is guaranteed to be big enough.
Packit Service b0a153
	 *
Packit Service b0a153
	 * This function is called when sanity-checking a device before adding
Packit Service b0a153
	 * it to the list of discovered devices, and also when the user requests
Packit Service b0a153
	 * to read the device descriptor.
Packit Service b0a153
	 *
Packit Service b0a153
	 * This function is expected to return the descriptor in bus-endian format
Packit Service b0a153
	 * (LE). If it returns the multi-byte values in host-endian format,
Packit Service b0a153
	 * set the host_endian output parameter to "1".
Packit Service b0a153
	 *
Packit Service b0a153
	 * Return 0 on success or a LIBUSB_ERROR code on failure.
Packit Service b0a153
	 */
Packit Service b0a153
	int (*get_device_descriptor)(struct libusb_device *device,
Packit Service b0a153
		unsigned char *buffer, int *host_endian);
Packit Service b0a153
Packit Service b0a153
	/* Get the ACTIVE configuration descriptor for a device.
Packit Service b0a153
	 *
Packit Service b0a153
	 * The descriptor should be retrieved from memory, NOT via bus I/O to the
Packit Service b0a153
	 * device. This means that you may have to cache it in a private structure
Packit Service b0a153
	 * during get_device_list enumeration. You may also have to keep track
Packit Service b0a153
	 * of which configuration is active when the user changes it.
Packit Service b0a153
	 *
Packit Service b0a153
	 * This function is expected to write len bytes of data into buffer, which
Packit Service b0a153
	 * is guaranteed to be big enough. If you can only do a partial write,
Packit Service b0a153
	 * return an error code.
Packit Service b0a153
	 *
Packit Service b0a153
	 * This function is expected to return the descriptor in bus-endian format
Packit Service b0a153
	 * (LE). If it returns the multi-byte values in host-endian format,
Packit Service b0a153
	 * set the host_endian output parameter to "1".
Packit Service b0a153
	 *
Packit Service b0a153
	 * Return:
Packit Service b0a153
	 * - 0 on success
Packit Service b0a153
	 * - LIBUSB_ERROR_NOT_FOUND if the device is in unconfigured state
Packit Service b0a153
	 * - another LIBUSB_ERROR code on other failure
Packit Service b0a153
	 */
Packit Service b0a153
	int (*get_active_config_descriptor)(struct libusb_device *device,
Packit Service b0a153
		unsigned char *buffer, size_t len, int *host_endian);
Packit Service b0a153
Packit Service b0a153
	/* Get a specific configuration descriptor for a device.
Packit Service b0a153
	 *
Packit Service b0a153
	 * The descriptor should be retrieved from memory, NOT via bus I/O to the
Packit Service b0a153
	 * device. This means that you may have to cache it in a private structure
Packit Service b0a153
	 * during get_device_list enumeration.
Packit Service b0a153
	 *
Packit Service b0a153
	 * The requested descriptor is expressed as a zero-based index (i.e. 0
Packit Service b0a153
	 * indicates that we are requesting the first descriptor). The index does
Packit Service b0a153
	 * not (necessarily) equal the bConfigurationValue of the configuration
Packit Service b0a153
	 * being requested.
Packit Service b0a153
	 *
Packit Service b0a153
	 * This function is expected to write len bytes of data into buffer, which
Packit Service b0a153
	 * is guaranteed to be big enough. If you can only do a partial write,
Packit Service b0a153
	 * return an error code.
Packit Service b0a153
	 *
Packit Service b0a153
	 * This function is expected to return the descriptor in bus-endian format
Packit Service b0a153
	 * (LE). If it returns the multi-byte values in host-endian format,
Packit Service b0a153
	 * set the host_endian output parameter to "1".
Packit Service b0a153
	 *
Packit Service b0a153
	 * Return the length read on success or a LIBUSB_ERROR code on failure.
Packit Service b0a153
	 */
Packit Service b0a153
	int (*get_config_descriptor)(struct libusb_device *device,
Packit Service b0a153
		uint8_t config_index, unsigned char *buffer, size_t len,
Packit Service b0a153
		int *host_endian);
Packit Service b0a153
Packit Service b0a153
	/* Like get_config_descriptor but then by bConfigurationValue instead
Packit Service b0a153
	 * of by index.
Packit Service b0a153
	 *
Packit Service b0a153
	 * Optional, if not present the core will call get_config_descriptor
Packit Service b0a153
	 * for all configs until it finds the desired bConfigurationValue.
Packit Service b0a153
	 *
Packit Service b0a153
	 * Returns a pointer to the raw-descriptor in *buffer, this memory
Packit Service b0a153
	 * is valid as long as device is valid.
Packit Service b0a153
	 *
Packit Service b0a153
	 * Returns the length of the returned raw-descriptor on success,
Packit Service b0a153
	 * or a LIBUSB_ERROR code on failure.
Packit Service b0a153
	 */
Packit Service b0a153
	int (*get_config_descriptor_by_value)(struct libusb_device *device,
Packit Service b0a153
		uint8_t bConfigurationValue, unsigned char **buffer,
Packit Service b0a153
		int *host_endian);
Packit Service b0a153
Packit Service b0a153
	/* Get the bConfigurationValue for the active configuration for a device.
Packit Service b0a153
	 * Optional. This should only be implemented if you can retrieve it from
Packit Service b0a153
	 * cache (don't generate I/O).
Packit Service b0a153
	 *
Packit Service b0a153
	 * If you cannot retrieve this from cache, either do not implement this
Packit Service b0a153
	 * function, or return LIBUSB_ERROR_NOT_SUPPORTED. This will cause
Packit Service b0a153
	 * libusb to retrieve the information through a standard control transfer.
Packit Service b0a153
	 *
Packit Service b0a153
	 * This function must be non-blocking.
Packit Service b0a153
	 * Return:
Packit Service b0a153
	 * - 0 on success
Packit Service b0a153
	 * - LIBUSB_ERROR_NO_DEVICE if the device has been disconnected since it
Packit Service b0a153
	 *   was opened
Packit Service b0a153
	 * - LIBUSB_ERROR_NOT_SUPPORTED if the value cannot be retrieved without
Packit Service b0a153
	 *   blocking
Packit Service b0a153
	 * - another LIBUSB_ERROR code on other failure.
Packit Service b0a153
	 */
Packit Service b0a153
	int (*get_configuration)(struct libusb_device_handle *dev_handle, int *config);
Packit Service b0a153
Packit Service b0a153
	/* Set the active configuration for a device.
Packit Service b0a153
	 *
Packit Service b0a153
	 * A configuration value of -1 should put the device in unconfigured state.
Packit Service b0a153
	 *
Packit Service b0a153
	 * This function can block.
Packit Service b0a153
	 *
Packit Service b0a153
	 * Return:
Packit Service b0a153
	 * - 0 on success
Packit Service b0a153
	 * - LIBUSB_ERROR_NOT_FOUND if the configuration does not exist
Packit Service b0a153
	 * - LIBUSB_ERROR_BUSY if interfaces are currently claimed (and hence
Packit Service b0a153
	 *   configuration cannot be changed)
Packit Service b0a153
	 * - LIBUSB_ERROR_NO_DEVICE if the device has been disconnected since it
Packit Service b0a153
	 *   was opened
Packit Service b0a153
	 * - another LIBUSB_ERROR code on other failure.
Packit Service b0a153
	 */
Packit Service b0a153
	int (*set_configuration)(struct libusb_device_handle *dev_handle, int config);
Packit Service b0a153
Packit Service b0a153
	/* Claim an interface. When claimed, the application can then perform
Packit Service b0a153
	 * I/O to an interface's endpoints.
Packit Service b0a153
	 *
Packit Service b0a153
	 * This function should not generate any bus I/O and should not block.
Packit Service b0a153
	 * Interface claiming is a logical operation that simply ensures that
Packit Service b0a153
	 * no other drivers/applications are using the interface, and after
Packit Service b0a153
	 * claiming, no other drivers/applications can use the interface because
Packit Service b0a153
	 * we now "own" it.
Packit Service b0a153
	 *
Packit Service b0a153
	 * Return:
Packit Service b0a153
	 * - 0 on success
Packit Service b0a153
	 * - LIBUSB_ERROR_NOT_FOUND if the interface does not exist
Packit Service b0a153
	 * - LIBUSB_ERROR_BUSY if the interface is in use by another driver/app
Packit Service b0a153
	 * - LIBUSB_ERROR_NO_DEVICE if the device has been disconnected since it
Packit Service b0a153
	 *   was opened
Packit Service b0a153
	 * - another LIBUSB_ERROR code on other failure
Packit Service b0a153
	 */
Packit Service b0a153
	int (*claim_interface)(struct libusb_device_handle *dev_handle, int interface_number);
Packit Service b0a153
Packit Service b0a153
	/* Release a previously claimed interface.
Packit Service b0a153
	 *
Packit Service b0a153
	 * This function should also generate a SET_INTERFACE control request,
Packit Service b0a153
	 * resetting the alternate setting of that interface to 0. It's OK for
Packit Service b0a153
	 * this function to block as a result.
Packit Service b0a153
	 *
Packit Service b0a153
	 * You will only ever be asked to release an interface which was
Packit Service b0a153
	 * successfully claimed earlier.
Packit Service b0a153
	 *
Packit Service b0a153
	 * Return:
Packit Service b0a153
	 * - 0 on success
Packit Service b0a153
	 * - LIBUSB_ERROR_NO_DEVICE if the device has been disconnected since it
Packit Service b0a153
	 *   was opened
Packit Service b0a153
	 * - another LIBUSB_ERROR code on other failure
Packit Service b0a153
	 */
Packit Service b0a153
	int (*release_interface)(struct libusb_device_handle *dev_handle, int interface_number);
Packit Service b0a153
Packit Service b0a153
	/* Set the alternate setting for an interface.
Packit Service b0a153
	 *
Packit Service b0a153
	 * You will only ever be asked to set the alternate setting for an
Packit Service b0a153
	 * interface which was successfully claimed earlier.
Packit Service b0a153
	 *
Packit Service b0a153
	 * It's OK for this function to block.
Packit Service b0a153
	 *
Packit Service b0a153
	 * Return:
Packit Service b0a153
	 * - 0 on success
Packit Service b0a153
	 * - LIBUSB_ERROR_NOT_FOUND if the alternate setting does not exist
Packit Service b0a153
	 * - LIBUSB_ERROR_NO_DEVICE if the device has been disconnected since it
Packit Service b0a153
	 *   was opened
Packit Service b0a153
	 * - another LIBUSB_ERROR code on other failure
Packit Service b0a153
	 */
Packit Service b0a153
	int (*set_interface_altsetting)(struct libusb_device_handle *dev_handle,
Packit Service b0a153
		int interface_number, int altsetting);
Packit Service b0a153
Packit Service b0a153
	/* Clear a halt/stall condition on an endpoint.
Packit Service b0a153
	 *
Packit Service b0a153
	 * It's OK for this function to block.
Packit Service b0a153
	 *
Packit Service b0a153
	 * Return:
Packit Service b0a153
	 * - 0 on success
Packit Service b0a153
	 * - LIBUSB_ERROR_NOT_FOUND if the endpoint does not exist
Packit Service b0a153
	 * - LIBUSB_ERROR_NO_DEVICE if the device has been disconnected since it
Packit Service b0a153
	 *   was opened
Packit Service b0a153
	 * - another LIBUSB_ERROR code on other failure
Packit Service b0a153
	 */
Packit Service b0a153
	int (*clear_halt)(struct libusb_device_handle *dev_handle,
Packit Service b0a153
		unsigned char endpoint);
Packit Service b0a153
Packit Service b0a153
	/* Perform a USB port reset to reinitialize a device.
Packit Service b0a153
	 *
Packit Service b0a153
	 * If possible, the device handle should still be usable after the reset
Packit Service b0a153
	 * completes, assuming that the device descriptors did not change during
Packit Service b0a153
	 * reset and all previous interface state can be restored.
Packit Service b0a153
	 *
Packit Service b0a153
	 * If something changes, or you cannot easily locate/verify the resetted
Packit Service b0a153
	 * device, return LIBUSB_ERROR_NOT_FOUND. This prompts the application
Packit Service b0a153
	 * to close the old handle and re-enumerate the device.
Packit Service b0a153
	 *
Packit Service b0a153
	 * Return:
Packit Service b0a153
	 * - 0 on success
Packit Service b0a153
	 * - LIBUSB_ERROR_NOT_FOUND if re-enumeration is required, or if the device
Packit Service b0a153
	 *   has been disconnected since it was opened
Packit Service b0a153
	 * - another LIBUSB_ERROR code on other failure
Packit Service b0a153
	 */
Packit Service b0a153
	int (*reset_device)(struct libusb_device_handle *dev_handle);
Packit Service b0a153
Packit Service b0a153
	/* Alloc num_streams usb3 bulk streams on the passed in endpoints */
Packit Service b0a153
	int (*alloc_streams)(struct libusb_device_handle *dev_handle,
Packit Service b0a153
		uint32_t num_streams, unsigned char *endpoints, int num_endpoints);
Packit Service b0a153
Packit Service b0a153
	/* Free usb3 bulk streams allocated with alloc_streams */
Packit Service b0a153
	int (*free_streams)(struct libusb_device_handle *dev_handle,
Packit Service b0a153
		unsigned char *endpoints, int num_endpoints);
Packit Service b0a153
Packit Service b0a153
	/* Allocate persistent DMA memory for the given device, suitable for
Packit Service b0a153
	 * zerocopy. May return NULL on failure. Optional to implement.
Packit Service b0a153
	 */
Packit Service b0a153
	unsigned char *(*dev_mem_alloc)(struct libusb_device_handle *handle,
Packit Service b0a153
		size_t len);
Packit Service b0a153
Packit Service b0a153
	/* Free memory allocated by dev_mem_alloc. */
Packit Service b0a153
	int (*dev_mem_free)(struct libusb_device_handle *handle,
Packit Service b0a153
		unsigned char *buffer, size_t len);
Packit Service b0a153
Packit Service b0a153
	/* Determine if a kernel driver is active on an interface. Optional.
Packit Service b0a153
	 *
Packit Service b0a153
	 * The presence of a kernel driver on an interface indicates that any
Packit Service b0a153
	 * calls to claim_interface would fail with the LIBUSB_ERROR_BUSY code.
Packit Service b0a153
	 *
Packit Service b0a153
	 * Return:
Packit Service b0a153
	 * - 0 if no driver is active
Packit Service b0a153
	 * - 1 if a driver is active
Packit Service b0a153
	 * - LIBUSB_ERROR_NO_DEVICE if the device has been disconnected since it
Packit Service b0a153
	 *   was opened
Packit Service b0a153
	 * - another LIBUSB_ERROR code on other failure
Packit Service b0a153
	 */
Packit Service b0a153
	int (*kernel_driver_active)(struct libusb_device_handle *dev_handle,
Packit Service b0a153
		int interface_number);
Packit Service b0a153
Packit Service b0a153
	/* Detach a kernel driver from an interface. Optional.
Packit Service b0a153
	 *
Packit Service b0a153
	 * After detaching a kernel driver, the interface should be available
Packit Service b0a153
	 * for claim.
Packit Service b0a153
	 *
Packit Service b0a153
	 * Return:
Packit Service b0a153
	 * - 0 on success
Packit Service b0a153
	 * - LIBUSB_ERROR_NOT_FOUND if no kernel driver was active
Packit Service b0a153
	 * - LIBUSB_ERROR_INVALID_PARAM if the interface does not exist
Packit Service b0a153
	 * - LIBUSB_ERROR_NO_DEVICE if the device has been disconnected since it
Packit Service b0a153
	 *   was opened
Packit Service b0a153
	 * - another LIBUSB_ERROR code on other failure
Packit Service b0a153
	 */
Packit Service b0a153
	int (*detach_kernel_driver)(struct libusb_device_handle *dev_handle,
Packit Service b0a153
		int interface_number);
Packit Service b0a153
Packit Service b0a153
	/* Attach a kernel driver to an interface. Optional.
Packit Service b0a153
	 *
Packit Service b0a153
	 * Reattach a kernel driver to the device.
Packit Service b0a153
	 *
Packit Service b0a153
	 * Return:
Packit Service b0a153
	 * - 0 on success
Packit Service b0a153
	 * - LIBUSB_ERROR_NOT_FOUND if no kernel driver was active
Packit Service b0a153
	 * - LIBUSB_ERROR_INVALID_PARAM if the interface does not exist
Packit Service b0a153
	 * - LIBUSB_ERROR_NO_DEVICE if the device has been disconnected since it
Packit Service b0a153
	 *   was opened
Packit Service b0a153
	 * - LIBUSB_ERROR_BUSY if a program or driver has claimed the interface,
Packit Service b0a153
	 *   preventing reattachment
Packit Service b0a153
	 * - another LIBUSB_ERROR code on other failure
Packit Service b0a153
	 */
Packit Service b0a153
	int (*attach_kernel_driver)(struct libusb_device_handle *dev_handle,
Packit Service b0a153
		int interface_number);
Packit Service b0a153
Packit Service b0a153
	/* Destroy a device. Optional.
Packit Service b0a153
	 *
Packit Service b0a153
	 * This function is called when the last reference to a device is
Packit Service b0a153
	 * destroyed. It should free any resources allocated in the get_device_list
Packit Service b0a153
	 * path.
Packit Service b0a153
	 */
Packit Service b0a153
	void (*destroy_device)(struct libusb_device *dev);
Packit Service b0a153
Packit Service b0a153
	/* Submit a transfer. Your implementation should take the transfer,
Packit Service b0a153
	 * morph it into whatever form your platform requires, and submit it
Packit Service b0a153
	 * asynchronously.
Packit Service b0a153
	 *
Packit Service b0a153
	 * This function must not block.
Packit Service b0a153
	 *
Packit Service b0a153
	 * This function gets called with the flying_transfers_lock locked!
Packit Service b0a153
	 *
Packit Service b0a153
	 * Return:
Packit Service b0a153
	 * - 0 on success
Packit Service b0a153
	 * - LIBUSB_ERROR_NO_DEVICE if the device has been disconnected
Packit Service b0a153
	 * - another LIBUSB_ERROR code on other failure
Packit Service b0a153
	 */
Packit Service b0a153
	int (*submit_transfer)(struct usbi_transfer *itransfer);
Packit Service b0a153
Packit Service b0a153
	/* Cancel a previously submitted transfer.
Packit Service b0a153
	 *
Packit Service b0a153
	 * This function must not block. The transfer cancellation must complete
Packit Service b0a153
	 * later, resulting in a call to usbi_handle_transfer_cancellation()
Packit Service b0a153
	 * from the context of handle_events.
Packit Service b0a153
	 */
Packit Service b0a153
	int (*cancel_transfer)(struct usbi_transfer *itransfer);
Packit Service b0a153
Packit Service b0a153
	/* Clear a transfer as if it has completed or cancelled, but do not
Packit Service b0a153
	 * report any completion/cancellation to the library. You should free
Packit Service b0a153
	 * all private data from the transfer as if you were just about to report
Packit Service b0a153
	 * completion or cancellation.
Packit Service b0a153
	 *
Packit Service b0a153
	 * This function might seem a bit out of place. It is used when libusb
Packit Service b0a153
	 * detects a disconnected device - it calls this function for all pending
Packit Service b0a153
	 * transfers before reporting completion (with the disconnect code) to
Packit Service b0a153
	 * the user. Maybe we can improve upon this internal interface in future.
Packit Service b0a153
	 */
Packit Service b0a153
	void (*clear_transfer_priv)(struct usbi_transfer *itransfer);
Packit Service b0a153
Packit Service b0a153
	/* Handle any pending events on file descriptors. Optional.
Packit Service b0a153
	 *
Packit Service b0a153
	 * Provide this function when file descriptors directly indicate device
Packit Service b0a153
	 * or transfer activity. If your backend does not have such file descriptors,
Packit Service b0a153
	 * implement the handle_transfer_completion function below.
Packit Service b0a153
	 *
Packit Service b0a153
	 * This involves monitoring any active transfers and processing their
Packit Service b0a153
	 * completion or cancellation.
Packit Service b0a153
	 *
Packit Service b0a153
	 * The function is passed an array of pollfd structures (size nfds)
Packit Service b0a153
	 * as a result of the poll() system call. The num_ready parameter
Packit Service b0a153
	 * indicates the number of file descriptors that have reported events
Packit Service b0a153
	 * (i.e. the poll() return value). This should be enough information
Packit Service b0a153
	 * for you to determine which actions need to be taken on the currently
Packit Service b0a153
	 * active transfers.
Packit Service b0a153
	 *
Packit Service b0a153
	 * For any cancelled transfers, call usbi_handle_transfer_cancellation().
Packit Service b0a153
	 * For completed transfers, call usbi_handle_transfer_completion().
Packit Service b0a153
	 * For control/bulk/interrupt transfers, populate the "transferred"
Packit Service b0a153
	 * element of the appropriate usbi_transfer structure before calling the
Packit Service b0a153
	 * above functions. For isochronous transfers, populate the status and
Packit Service b0a153
	 * transferred fields of the iso packet descriptors of the transfer.
Packit Service b0a153
	 *
Packit Service b0a153
	 * This function should also be able to detect disconnection of the
Packit Service b0a153
	 * device, reporting that situation with usbi_handle_disconnect().
Packit Service b0a153
	 *
Packit Service b0a153
	 * When processing an event related to a transfer, you probably want to
Packit Service b0a153
	 * take usbi_transfer.lock to prevent races. See the documentation for
Packit Service b0a153
	 * the usbi_transfer structure.
Packit Service b0a153
	 *
Packit Service b0a153
	 * Return 0 on success, or a LIBUSB_ERROR code on failure.
Packit Service b0a153
	 */
Packit Service b0a153
	int (*handle_events)(struct libusb_context *ctx,
Packit Service b0a153
		struct pollfd *fds, POLL_NFDS_TYPE nfds, int num_ready);
Packit Service b0a153
Packit Service b0a153
	/* Handle transfer completion. Optional.
Packit Service b0a153
	 *
Packit Service b0a153
	 * Provide this function when there are no file descriptors available
Packit Service b0a153
	 * that directly indicate device or transfer activity. If your backend does
Packit Service b0a153
	 * have such file descriptors, implement the handle_events function above.
Packit Service b0a153
	 *
Packit Service b0a153
	 * Your backend must tell the library when a transfer has completed by
Packit Service b0a153
	 * calling usbi_signal_transfer_completion(). You should store any private
Packit Service b0a153
	 * information about the transfer and its completion status in the transfer's
Packit Service b0a153
	 * private backend data.
Packit Service b0a153
	 *
Packit Service b0a153
	 * During event handling, this function will be called on each transfer for
Packit Service b0a153
	 * which usbi_signal_transfer_completion() was called.
Packit Service b0a153
	 *
Packit Service b0a153
	 * For any cancelled transfers, call usbi_handle_transfer_cancellation().
Packit Service b0a153
	 * For completed transfers, call usbi_handle_transfer_completion().
Packit Service b0a153
	 * For control/bulk/interrupt transfers, populate the "transferred"
Packit Service b0a153
	 * element of the appropriate usbi_transfer structure before calling the
Packit Service b0a153
	 * above functions. For isochronous transfers, populate the status and
Packit Service b0a153
	 * transferred fields of the iso packet descriptors of the transfer.
Packit Service b0a153
	 *
Packit Service b0a153
	 * Return 0 on success, or a LIBUSB_ERROR code on failure.
Packit Service b0a153
	 */
Packit Service b0a153
	int (*handle_transfer_completion)(struct usbi_transfer *itransfer);
Packit Service b0a153
Packit Service b0a153
	/* Get time from specified clock. At least two clocks must be implemented
Packit Service b0a153
	   by the backend: USBI_CLOCK_REALTIME, and USBI_CLOCK_MONOTONIC.
Packit Service b0a153
Packit Service b0a153
	   Description of clocks:
Packit Service b0a153
	     USBI_CLOCK_REALTIME : clock returns time since system epoch.
Packit Service b0a153
	     USBI_CLOCK_MONOTONIC: clock returns time since unspecified start
Packit Service b0a153
	                             time (usually boot).
Packit Service b0a153
	 */
Packit Service b0a153
	int (*clock_gettime)(int clkid, struct timespec *tp);
Packit Service b0a153
Packit Service b0a153
#ifdef USBI_TIMERFD_AVAILABLE
Packit Service b0a153
	/* clock ID of the clock that should be used for timerfd */
Packit Service b0a153
	clockid_t (*get_timerfd_clockid)(void);
Packit Service b0a153
#endif
Packit Service b0a153
Packit Service b0a153
	/* Number of bytes to reserve for per-context private backend data.
Packit Service b0a153
	 * This private data area is accessible through the "os_priv" field of
Packit Service b0a153
	 * struct libusb_context. */
Packit Service b0a153
	size_t context_priv_size;
Packit Service b0a153
Packit Service b0a153
	/* Number of bytes to reserve for per-device private backend data.
Packit Service b0a153
	 * This private data area is accessible through the "os_priv" field of
Packit Service b0a153
	 * struct libusb_device. */
Packit Service b0a153
	size_t device_priv_size;
Packit Service b0a153
Packit Service b0a153
	/* Number of bytes to reserve for per-handle private backend data.
Packit Service b0a153
	 * This private data area is accessible through the "os_priv" field of
Packit Service b0a153
	 * struct libusb_device. */
Packit Service b0a153
	size_t device_handle_priv_size;
Packit Service b0a153
Packit Service b0a153
	/* Number of bytes to reserve for per-transfer private backend data.
Packit Service b0a153
	 * This private data area is accessible by calling
Packit Service b0a153
	 * usbi_transfer_get_os_priv() on the appropriate usbi_transfer instance.
Packit Service b0a153
	 */
Packit Service b0a153
	size_t transfer_priv_size;
Packit Service b0a153
};
Packit Service b0a153
Packit Service b0a153
extern const struct usbi_os_backend usbi_backend;
Packit Service b0a153
Packit Service b0a153
extern struct list_head active_contexts_list;
Packit Service b0a153
extern usbi_mutex_static_t active_contexts_lock;
Packit Service b0a153
Packit Service b0a153
#ifdef __cplusplus
Packit Service b0a153
}
Packit Service b0a153
#endif
Packit Service b0a153
Packit Service b0a153
#endif