229N/A/*
229N/A * CDDL HEADER START
229N/A *
229N/A * The contents of this file are subject to the terms of the
229N/A * Common Development and Distribution License (the "License").
229N/A * You may not use this file except in compliance with the License.
229N/A *
229N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
229N/A * or http://www.opensolaris.org/os/licensing.
229N/A * See the License for the specific language governing permissions
229N/A * and limitations under the License.
229N/A *
229N/A * When distributing Covered Code, include this CDDL HEADER in each
229N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
229N/A * If applicable, add the following below this CDDL HEADER, with the
229N/A * fields enclosed by brackets "[]" replaced with your own identifying
229N/A * information: Portions Copyright [yyyy] [name of copyright owner]
229N/A *
229N/A * CDDL HEADER END
229N/A */
229N/A/*
229N/A * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
229N/A */
229N/A
229N/A#ifndef _WR_LIBUSB_H
229N/A#define _WR_LIBUSB_H
229N/A
229N/A#ifdef __cplusplus
229N/Aextern "C" {
229N/A#endif
229N/A
229N/A/* debug levels */
229N/A#define DEBUG_NONE 0
229N/A#define DEBUG_ERRORS 1
229N/A#define DEBUG_RECOVERABLE 2
229N/A#define DEBUG_FUNCTIONS 3
229N/A#define DEBUG_DETAILED 4
229N/A#define DEBUG_DATA_DUMP 5
229N/A
229N/A#define MOD_SUFFIX ".so"
229N/A
229N/A/* consistent with the Makefile VER and mapfiles */
229N/A#define LIBUSB_WRAPPER_VERSION "1.1"
229N/A
229N/A#define PLUGIN_EXCLUSIVE 2
229N/A#define MAX_PLUGINS 10
229N/A#define MAX_VERSION_LEN 512
229N/A#define SUCCESS 0
229N/A#define FAILURE -1
229N/A#define DSYM (dlsym((handle), (symbol)))
229N/A
229N/A/* default plugin dir */
229N/A#define PLUGIN_DIR "/usr/lib/libusb_plugins"
229N/A
229N/A#define USB_OPEN 0
229N/A#define USB_CLOSE 1
229N/A#define USB_GET_STRING 2
229N/A#define USB_GET_STRING_SIMPLE 3
229N/A#define USB_GET_DESCRIPTOR_BY_ENDPOINT 4
229N/A#define USB_GET_DESCRIPTOR 5
229N/A#define USB_BULK_WRITE 6
229N/A#define USB_BULK_READ 7
229N/A#define USB_INTERRUPT_WRITE 8
229N/A#define USB_INTERRUPT_READ 9
229N/A#define USB_CONTROL_MSG 10
229N/A#define USB_SET_CONFIGURATION 11
229N/A#define USB_CLAIM_INTERFACE 12
229N/A#define USB_RELEASE_INTERFACE 13
229N/A#define USB_SET_ALTINTERFACE 14
229N/A#define USB_RESETEP 15
229N/A#define USB_CLEAR_HALT 16
229N/A#define USB_RESET 17
229N/A#define USB_INIT 18
229N/A#define USB_SET_DEBUG 19
229N/A#define USB_FIND_BUSSES 20
229N/A#define USB_FIND_DEVICES 21
229N/A#define USB_DEVICE 22
229N/A#define USB_GET_BUSSES 23
229N/A#define USB_STRERROR 24
229N/A#define USB_BUSSES 25
229N/A#define LIBUSB_INIT 26
229N/A#define LIBUSB_FINI 27
229N/A#define LIBUSB_VERSION 28
229N/A
229N/Achar *sym_names[] = {
229N/A "usb_open", /* 0 */
229N/A "usb_close", /* 1 */
229N/A "usb_get_string", /* 2 */
229N/A "usb_get_string_simple", /* 3 */
229N/A "usb_get_descriptor_by_endpoint", /* 4 */
229N/A "usb_get_descriptor", /* 5 */
229N/A "usb_bulk_write", /* 6 */
229N/A "usb_bulk_read", /* 7 */
229N/A "usb_interrupt_write", /* 8 */
229N/A "usb_interrupt_read", /* 9 */
229N/A "usb_control_msg", /* 10 */
229N/A "usb_set_configuration", /* 11 */
229N/A "usb_claim_interface", /* 12 */
229N/A "usb_release_interface", /* 13 */
229N/A "usb_set_altinterface", /* 14 */
229N/A "usb_resetep", /* 15 */
229N/A "usb_clear_halt", /* 16 */
229N/A "usb_reset", /* 17 */
229N/A "usb_init", /* 18 */
229N/A "usb_set_debug", /* 19 */
229N/A "usb_find_busses", /* 20 */
229N/A "usb_find_devices", /* 21 */
229N/A "usb_device", /* 22 */
229N/A "usb_get_busses", /* 23 */
229N/A "usb_strerror", /* 24 */
229N/A "usb_busses", /* 25 */
229N/A "libusb_init", /* 26 */
229N/A "libusb_fini", /* 27 */
229N/A "libusb_version" /* 28 */
229N/A};
229N/A
229N/A#define USB_OPEN_CAST (struct usb_dev_handle *(*) \
229N/A (struct usb_device *))
229N/A#define USB_CLOSE_CAST (int (*)(usb_dev_handle *))
229N/A#define USB_GET_STRING_CAST (int (*) (usb_dev_handle *, int, \
229N/A int, char *, size_t))
229N/A#define USB_GET_STRING_SIMPLE_CAST (int (*) (usb_dev_handle *, int, \
229N/A char *, size_t))
229N/A#define USB_GET_DESCRIPTOR_BY_ENDPOINT_CAST (int (*) (usb_dev_handle *, int, \
229N/A unsigned char, unsigned char, \
229N/A void *, int))
229N/A#define USB_GET_DESCRIPTOR_CAST (int (*)(usb_dev_handle *, unsigned \
229N/A char, unsigned char, void *, int))
229N/A#define USB_BULK_WRITE_CAST (int (*) (usb_dev_handle *, int, \
229N/A char *, int, int))
229N/A#define USB_BULK_READ_CAST (int (*) (usb_dev_handle *, int, \
229N/A char *, int, int))
229N/A#define USB_INTERRUPT_READ_CAST (int (*) (usb_dev_handle *, \
229N/A int, char *, int, int))
229N/A#define USB_INTERRUPT_WRITE_CAST (int (*) (usb_dev_handle *, int, \
229N/A char *, int, int))
229N/A#define USB_CONTROL_MSG_CAST (int (*)(usb_dev_handle *, int, int, \
229N/A int, int, char *, int, int))
229N/A#define USB_SET_CONFIGURATION_CAST (int (*)(usb_dev_handle *, int))
229N/A#define USB_CLAIM_INTERFACE_CAST (int (*)(usb_dev_handle *, int))
229N/A#define USB_RELEASE_INTERFACE_CAST (int (*)(usb_dev_handle *, int))
229N/A#define USB_SET_ALTINTERFACE_CAST (int (*)(usb_dev_handle *, int))
229N/A#define USB_RESETEP_CAST (int (*)(usb_dev_handle *, \
229N/A unsigned int))
229N/A#define USB_CLEAR_HALT_CAST (int (*)(usb_dev_handle *, \
229N/A unsigned int))
229N/A#define USB_RESET_CAST (int (*)(usb_dev_handle *))
229N/A#define USB_INIT_CAST (void (*)(void))
229N/A#define USB_SET_DEBUG_CAST (void (*)(int))
229N/A#define USB_FIND_BUSSES_CAST (int (*)(void))
229N/A#define USB_FIND_DEVICES_CAST (int (*) (void))
229N/A#define USB_DEVICE_CAST (struct usb_device *(*) \
229N/A (usb_dev_handle *))
229N/A#define USB_STRERROR_CAST (char *(*)(void))
229N/A#define USB_BUSSES_CAST (struct usb_bus **)
229N/A#define LIBUSB_INIT_CAST (int (*)(void))
229N/A#define LIBUSB_FINI_CAST (int (*)(void))
229N/A
229N/A#define NUM_SYMS (unsigned int)(sizeof (sym_names) / \
229N/A sizeof (char *))
229N/A
229N/A/*
229N/A * wrapper info structure - maintains wrapper state
229N/A * and plugins data
229N/A */
229N/Atypedef struct wrapper_info {
229N/A int ploaded; /* highest plugin index */
229N/A int last_pindex; /* last plugin index used by app */
229N/A int active_index; /* used to indicate single plugin */
229N/A int exclusive_index; /* if set then this plugin is excl */
229N/A struct usb_bus *head_busp; /* wrapper combined usb_busses ptr */
229N/A} wrapper_info_t;
229N/A
229N/A
229N/A/*
229N/A * this is the dev_handles struct that each plugin
229N/A * maintains a linked list of
229N/A */
229N/Atypedef struct dev_handles {
229N/A struct usb_dev_handle *dev; /* usb.h dev handle */
229N/A struct usb_device *device; /* usb.h device pointer */
229N/A struct dev_handles *next; /* for linked list */
229N/A struct dev_handles *prev;
229N/A} dev_handles_t;
229N/A
229N/A/*
229N/A * plugin state info
229N/A */
229N/Atypedef struct plugin_info {
229N/A char *p_name; /* module name */
229N/A char *p_path; /* module path */
229N/A void *p_handle; /* handle to plugin */
229N/A int exclusive_flag; /* plugin exclusivity */
229N/A int active_flag; /* is plugin single */
229N/A char *prefix; /* libusb_prefix symbol val */
229N/A dev_handles_t *dev_handles; /* list of open dev hdls */
229N/A struct usb_bus *busp; /* plugin bus pointer */
229N/A void *sym_hdl[NUM_SYMS]; /* plugin symbols */
229N/A} plugin_info_t;
229N/A
229N/A#ifdef __cplusplus
229N/A}
229N/A#endif
229N/A
229N/A#endif /* _WR_LIBUSB_H */