/libusbK/includes/libusbk.h
C Header | 2101 lines | 734 code | 422 blank | 945 comment | 5 complexity | 55180e509fbf0ff0065de404f6a34b43 MD5 | raw file
Possible License(s): GPL-3.0, LGPL-3.0, LGPL-2.0
Large files files are truncated, but you can click here to view the full file
- /*! \file libusbk.h
- * \brief functions for usb device communication.
- *
- * \note
- * This is the \b main libusbK USB user include file.
- */
-
- #ifndef _LIBUSBK_H__
- #define _LIBUSBK_H__
-
- #include "lusbk_shared.h"
-
- ///////////////////////////////////////////////////////////////////////
- // L I B U S B K PUBLIC STRUCTS, DEFINES, AND ENUMS //////////////////
- ///////////////////////////////////////////////////////////////////////
-
- #ifndef _LIBUSBK_LIBK_TYPES
-
- /*! \addtogroup libk
- * @{
- */
-
- #define _in
- #define _inopt
- #define _out
- #define _outopt
- #define _ref
- #define _refopt
-
- //! UsbK base function pointer, See \ref LibK_GetProcAddress.
- typedef INT_PTR (FAR WINAPI* KPROC)();
-
- //! Indicates that a function is an exported API call.
- #if defined(DYNAMIC_DLL)
- #define KUSB_EXP
- #else
- #define KUSB_EXP
- #endif
-
- //! Indicates the calling convention. This is always WINAPI (stdcall) by default.
- #if !defined(KUSB_API)
- #define KUSB_API WINAPI
- #endif
-
- #pragma warning(disable:4201)
-
- #if _MSC_VER >= 1200
- #pragma warning(push)
- #endif
- #pragma warning (disable:4201)
- #pragma warning(disable:4214) // named type definition in parentheses
-
- //! User defined handle context space, see \ref LibK_GetContext.
- typedef INT_PTR KLIB_USER_CONTEXT;
-
- //! KUSB control setup packet.
- /*!
- * This union structure is identical in size to a \ref WINUSB_SETUP_PACKET,
- * but provides additional field accessors. (see \ref libusbk.h for structure details)
- */
- typedef union _KUSB_SETUP_PACKET
- {
- UCHAR Bytes[8];
- USHORT Words[4];
- struct
- {
- //! Request value
- struct
- {
- UCHAR Recipient: 2;
- UCHAR Reserved: 3;
- UCHAR Type: 2;
- UCHAR Dir: 1;
- } BmRequest;
-
- //! Request type value
- UCHAR Request;
-
- //! wValue
- USHORT Value;
-
- //! wIndex
- USHORT Index;
-
- //! wLength ushort value
- USHORT Length;
- };
- struct
- {
- struct
- {
- UCHAR b0: 1;
- UCHAR b1: 1;
- UCHAR b2: 1;
- UCHAR b3: 1;
- UCHAR b4: 1;
- UCHAR b5: 1;
- UCHAR b6: 1;
- UCHAR b7: 1;
- } BmRequestBits;
-
- struct
- {
- UCHAR b0: 1;
- UCHAR b1: 1;
- UCHAR b2: 1;
- UCHAR b3: 1;
- UCHAR b4: 1;
- UCHAR b5: 1;
- UCHAR b6: 1;
- UCHAR b7: 1;
- } RequestBits;
-
- UCHAR ValueLo;
- UCHAR ValueHi;
- UCHAR IndexLo;
- UCHAR IndexHi;
- UCHAR LengthLo;
- UCHAR LengthHi;
- };
- } KUSB_SETUP_PACKET;
- // setup packet is eight bytes -- defined by spec
- C_ASSERT(sizeof(KUSB_SETUP_PACKET) == 8);
-
- #if _MSC_VER >= 1200
- #pragma warning(pop)
- #endif
-
-
- //! Base handle type for all library handles, See \ref KLIB_HANDLE_TYPE.
- typedef void* KLIB_HANDLE;
-
- //! Opaque UsbK handle, see \ref UsbK_Init.
- typedef KLIB_HANDLE KUSB_HANDLE;
-
- //! Opaque LstK handle, see \ref LstK_Init.
- typedef KLIB_HANDLE KLST_HANDLE;
-
- //! Opaque HotK handle, see \ref HotK_Init.
- typedef KLIB_HANDLE KHOT_HANDLE;
-
- //! Opaque OvlK handle, see \ref OvlK_Acquire.
- typedef KLIB_HANDLE KOVL_HANDLE;
-
-
- //! Opaque OvlPoolK handle, see \ref OvlK_Init.
- typedef KLIB_HANDLE KOVL_POOL_HANDLE;
-
- //! Opaque StmK handle, see \ref StmK_Init.
- typedef KLIB_HANDLE KSTM_HANDLE;
-
- //! Handle type enumeration.
- typedef enum _KLIB_HANDLE_TYPE
- {
- //! Hot plug handle. \ref KHOT_HANDLE
- KLIB_HANDLE_TYPE_HOTK,
-
- //! USB handle. \ref KUSB_HANDLE
- KLIB_HANDLE_TYPE_USBK,
-
- //! Shared USB handle. \ref KUSB_HANDLE
- KLIB_HANDLE_TYPE_USBSHAREDK,
-
- //! Device list handle. \ref KLST_HANDLE
- KLIB_HANDLE_TYPE_LSTK,
-
- //! Device info handle. \ref KLST_DEVINFO_HANDLE
- KLIB_HANDLE_TYPE_LSTINFOK,
-
- //! Overlapped handle. \ref KOVL_HANDLE
- KLIB_HANDLE_TYPE_OVLK,
-
- //! Overlapped pool handle. \ref KOVL_POOL_HANDLE
- KLIB_HANDLE_TYPE_OVLPOOLK,
-
- //! Pipe stream handle. \ref KSTM_HANDLE
- KLIB_HANDLE_TYPE_STMK,
-
- //! Max handle type count.
- KLIB_HANDLE_TYPE_COUNT
- } KLIB_HANDLE_TYPE;
-
- //! Function typedef for \ref LibK_SetCleanupCallback.
- typedef INT KUSB_API KLIB_HANDLE_CLEANUP_CB (_in KLIB_HANDLE Handle, _in KLIB_HANDLE_TYPE HandleType, _in KLIB_USER_CONTEXT UserContext);
-
- //! libusbK verson information structure.
- typedef struct _KLIB_VERSION
- {
- //! Major version number.
- INT Major;
-
- //! Minor version number.
- INT Minor;
-
- //! Micro version number.
- INT Micro;
-
- //! Nano version number.
- INT Nano;
- } KLIB_VERSION;
- //! Pointer to a \copybrief KLIB_VERSION
- typedef KLIB_VERSION* PKLIB_VERSION;
-
- /*! @} */
- #endif
-
- #ifndef _LIBUSBK_ISOK_TYPES
- /*! \addtogroup isok
- * @{
- */
-
-
- //! Callback function typedef for \ref IsoK_EnumPackets
- typedef BOOL KUSB_API KISO_ENUM_PACKETS_CB (_in UINT PacketIndex, _in PKISO_PACKET IsoPacket, _in PVOID UserState);
-
- /*! @} */
- #endif
-
- #ifndef _LIBUSBK_LSTK_TYPES
-
- /*! \addtogroup lstk
- * @{
- */
-
- //! Allocated length for all strings in a \ref KLST_DEVINFO structure.
- #define KLST_STRING_MAX_LEN 256
-
- //! Device list sync flags.
- /*!
- * These sync flags are also use by the hot plug module to indicate device
- * arrival/removal notifications:
- * - \b DeviceArrival = KLST_SYNC_FLAG_ADDED
- * - \b DeviceRemoval = KLST_SYNC_FLAG_REMOVED
- */
- typedef enum _KLST_SYNC_FLAG
- {
- //! Cleared/invalid state.
- KLST_SYNC_FLAG_NONE = 0L,
-
- //! Unchanged state,
- KLST_SYNC_FLAG_UNCHANGED = 0x0001,
-
- //! Added (Arrival) state,
- KLST_SYNC_FLAG_ADDED = 0x0002,
-
- //! Removed (Unplugged) state,
- KLST_SYNC_FLAG_REMOVED = 0x0004,
-
- //! Connect changed state.
- KLST_SYNC_FLAG_CONNECT_CHANGE = 0x0008,
-
- //! All states.
- KLST_SYNC_FLAG_MASK = 0x000F,
- } KLST_SYNC_FLAG;
-
- //! Common usb device information structure
- typedef struct _KLST_DEV_COMMON_INFO
- {
- //! VendorID parsed from \ref KLST_DEVINFO::DeviceID
- INT Vid;
-
- //! ProductID parsed from \ref KLST_DEVINFO::DeviceID
- INT Pid;
-
- //! Composite interface number parsed from \ref KLST_DEVINFO::DeviceID. Set to \b -1 for devices that do not have the composite parent driver.
- INT MI;
-
- // An ID that uniquely identifies a USB device.
- CHAR InstanceID[KLST_STRING_MAX_LEN];
-
- } KLST_DEV_COMMON_INFO;
- //! Pointer to a \c KLST_DEV_COMMON_INFO structure.
- typedef KLST_DEV_COMMON_INFO* PKLST_DEV_COMMON_INFO;
-
- //! Semi-opaque device information structure of a device list.
- /*!
- *
- * \attention This structure is semi-opaque.
- *
- */
- typedef struct _KLST_DEVINFO
- {
- //! Common usb device information
- KLST_DEV_COMMON_INFO Common;
-
- //! Driver id this device element is using
- INT DriverID;
-
- //! Device interface GUID
- CHAR DeviceInterfaceGUID[KLST_STRING_MAX_LEN];
-
- //! Device instance ID.
- /*!
- * A Device instance ID has the following format:
- * [enumerator]\[enumerator-specific-device-ID]\[instance-specific-ID]
- * - [enumerator]
- * - For USB device, the enumerator is always \c USB
- * - [enumerator-specific-device-ID]
- * - Contains the vendor and product id (VID_xxxx&PID_xxxx)
- * - If present, contains the usbccgp (windows composite device layer) interface number (MI_xx)
- * - [instance-specific-ID]
- * - If the device is composite, contains a unique interface ID generated by Windows.
- * - If the device is not composite and has a serial number, contains the devices serial number.
- * - If the device does not have a serial number, contains a unique ID generated by Windows.
- */
- CHAR DeviceID[KLST_STRING_MAX_LEN];
-
- //! Class GUID.
- CHAR ClassGUID[KLST_STRING_MAX_LEN];
-
- //! Manufacturer name as specified in the INF file.
- CHAR Mfg[KLST_STRING_MAX_LEN];
-
- //! Device description as specified in the INF file.
- CHAR DeviceDesc[KLST_STRING_MAX_LEN];
-
- //! Driver service name.
- CHAR Service[KLST_STRING_MAX_LEN];
-
- //! Unique identifier.
- CHAR SymbolicLink[KLST_STRING_MAX_LEN];
-
- //! physical device filename used with the Windows \c CreateFile()
- CHAR DevicePath[KLST_STRING_MAX_LEN];
-
- //! libusb-win32 filter index id.
- INT LUsb0FilterIndex;
-
- //! Indicates the devices connection state.
- BOOL Connected;
-
- //! Synchronization flags. (internal use only)
- KLST_SYNC_FLAG SyncFlags;
-
- INT BusNumber;
-
- INT DeviceAddress;
-
- //! If the the device is serialized, represents the string value of \ref USB_DEVICE_DESCRIPTOR::iSerialNumber. For Devices without a \b iSerialNumber, represents the unique \b InstanceID assigned by \b Windows.
- CHAR SerialNumber[KLST_STRING_MAX_LEN];
-
- } KLST_DEVINFO;
- //! Pointer to a \ref KLST_DEVINFO structure. (semi-opaque)
- typedef KLST_DEVINFO* KLST_DEVINFO_HANDLE;
-
- //! Device list initialization flags.
- typedef enum _KLST_FLAG
- {
- //! No flags (or 0)
- KLST_FLAG_NONE = 0L,
-
- //! Enable listings for the raw device interface GUID \b only. {A5DCBF10-6530-11D2-901F-00C04FB951ED}
- KLST_FLAG_INCLUDE_RAWGUID = 0x0001,
-
- //! List all libusbK devices including those not currently connected.
- KLST_FLAG_INCLUDE_DISCONNECT = 0x0002,
-
- } KLST_FLAG;
-
- //! Device list/hot-plug pattern match structure.
- /*!
- * \fixedstruct{1024}
- *
- * These ansi char strings are used to specify which devices should be included in a device list.
- * All strings file pattern match strings allowing asterisk or question mark chars as wildcards.
- *
- */
- typedef struct _KLST_PATTERN_MATCH
- {
- //! Pattern match a device instance id.
- CHAR DeviceID[KLST_STRING_MAX_LEN];
-
- //! Pattern match a device interface guid.
- CHAR DeviceInterfaceGUID[KLST_STRING_MAX_LEN];
-
- //! Pattern match a symbolic link.
- CHAR ClassGUID[KLST_STRING_MAX_LEN];
-
- //! fixed structure padding.
- UCHAR z_F_i_x_e_d[1024 - KLST_STRING_MAX_LEN * 3];
-
- } KLST_PATTERN_MATCH;
- C_ASSERT(sizeof(KLST_PATTERN_MATCH) == 1024);
-
- //! Pointer to a \ref KLST_PATTERN_MATCH structure.
- typedef KLST_PATTERN_MATCH* PKLST_PATTERN_MATCH;
-
- //! Device list enumeration function callback typedef.
- /*!
- *
- * \param DeviceList
- * The device list \c DeviceInfo belongs to
- *
- * \param DeviceInfo
- * Device information
- *
- * \param Context
- * User context that was passed into \ref LstK_Enumerate
- *
- * Use this typedef as a prototype for an enumeration function with \ref LstK_Enumerate.
- *
- */
- typedef BOOL KUSB_API KLST_ENUM_DEVINFO_CB (
- _in KLST_HANDLE DeviceList,
- _in KLST_DEVINFO_HANDLE DeviceInfo,
- _in PVOID Context);
-
- /*! @} */
-
- #endif
-
- #ifndef __USB_H__
-
- #include <pshpack1.h>
-
- /*! \addtogroup libk
- * @{
- */
-
- //! Maximum value that can be added to the current start frame.
- #define USBD_ISO_START_FRAME_RANGE 1024
-
-
- //! bmRequest.Dir
- typedef enum _BMREQUEST_DIR
- {
- BMREQUEST_DIR_HOST_TO_DEVICE = 0,
- BMREQUEST_DIR_DEVICE_TO_HOST = 1,
- } BMREQUEST_DIR;
-
- //! bmRequest.Type
- typedef enum _BMREQUEST_TYPE
- {
- //! Standard request. See \ref USB_REQUEST_ENUM
- BMREQUEST_TYPE_STANDARD = 0,
-
- //! Class-specific request.
- BMREQUEST_TYPE_CLASS = 1,
-
- //! Vendor-specific request
- BMREQUEST_TYPE_VENDOR = 2,
- } BMREQUEST_TYPE;
-
- //! bmRequest.Recipient
- typedef enum _BMREQUEST_RECIPIENT
- {
- //! Request is for a device.
- BMREQUEST_RECIPIENT_DEVICE = 0,
-
- //! Request is for an interface of a device.
- BMREQUEST_RECIPIENT_INTERFACE = 1,
-
- //! Request is for an endpoint of a device.
- BMREQUEST_RECIPIENT_ENDPOINT = 2,
-
- //! Request is for a vendor-specific purpose.
- BMREQUEST_RECIPIENT_OTHER = 3,
- } BMREQUEST_RECIPIENT;
-
- //! Maximum length (in bytes) of a usb string. USB strings are always stored in wide-char format.
- #define MAXIMUM_USB_STRING_LENGTH 255
-
- //! Values for the bits returned by the \ref USB_REQUEST_GET_STATUS request.
- typedef enum _USB_GETSTATUS
- {
- //! Device is self powered
- USB_GETSTATUS_SELF_POWERED = 0x01,
-
- //! Device can wake the system from a low power/sleeping state.
- USB_GETSTATUS_REMOTE_WAKEUP_ENABLED = 0x02
- } USB_GETSTATUS;
-
- //! Standard USB descriptor types. For more information, see section 9-5 of the USB 3.0 specifications.
- typedef enum _USB_DESCRIPTOR_TYPE
- {
- //! Device descriptor type.
- USB_DESCRIPTOR_TYPE_DEVICE = 0x01,
-
- //! Configuration descriptor type.
- USB_DESCRIPTOR_TYPE_CONFIGURATION = 0x02,
-
- //! String descriptor type.
- USB_DESCRIPTOR_TYPE_STRING = 0x03,
-
- //! Interface descriptor type.
- USB_DESCRIPTOR_TYPE_INTERFACE = 0x04,
-
- //! Endpoint descriptor type.
- USB_DESCRIPTOR_TYPE_ENDPOINT = 0x05,
-
- //! Device qualifier descriptor type.
- USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER = 0x06,
-
- //! Config power descriptor type.
- USB_DESCRIPTOR_TYPE_CONFIG_POWER = 0x07,
-
- //! Interface power descriptor type.
- USB_DESCRIPTOR_TYPE_INTERFACE_POWER = 0x08,
-
- //! Interface association descriptor type.
- USB_DESCRIPTOR_TYPE_INTERFACE_ASSOCIATION = 0x0B,
- } USB_DESCRIPTOR_TYPE;
-
- //! Makes \c wValue for a \ref USB_REQUEST_GET_DESCRIPTOR or \ref USB_REQUEST_SET_DESCRIPTOR request.
- #define USB_DESCRIPTOR_MAKE_TYPE_AND_INDEX(d, i) \
- ((USHORT)((USHORT)d<<8 | i))
-
- //! Endpoint type mask for the \c bmAttributes field of a \ref USB_ENDPOINT_DESCRIPTOR
- #define USB_ENDPOINT_TYPE_MASK 0x03
-
- //! Indicates a control endpoint
- #define USB_ENDPOINT_TYPE_CONTROL 0x00
-
- //! Indicates an isochronous endpoint
- #define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01
-
- //! Indicates a bulk endpoint
- #define USB_ENDPOINT_TYPE_BULK 0x02
-
- //! Indicates an interrupt endpoint
- #define USB_ENDPOINT_TYPE_INTERRUPT 0x03
-
- //! Config power mask for the \c bmAttributes field of a \ref USB_CONFIGURATION_DESCRIPTOR
- #define USB_CONFIG_POWERED_MASK 0xc0
-
- //! Values used in the \c bmAttributes field of a \ref USB_CONFIGURATION_DESCRIPTOR
- enum USB_CONFIG_BM_ATTRIBUTE_ENUM
- {
- //! The device is powered by it's host.
- USB_CONFIG_BUS_POWERED = 0x80,
-
- //! The device has an external power source.
- USB_CONFIG_SELF_POWERED = 0x40,
-
- //! The device is capable of waking the the host from a low power/sleeping state.
- USB_CONFIG_REMOTE_WAKEUP = 0x20,
- };
-
- //! Endpoint direction mask for the \c bEndpointAddress field of a \ref USB_ENDPOINT_DESCRIPTOR
- #define USB_ENDPOINT_DIRECTION_MASK 0x80
-
- //! Endpoint address mask for the \c bEndpointAddress field of a \ref USB_ENDPOINT_DESCRIPTOR
- #define USB_ENDPOINT_ADDRESS_MASK 0x0F
-
- //! Tests the \c bEndpointAddress direction bit. TRUE if the endpoint address is an OUT endpoint. (HostToDevice, PC Write)
- /*!
- * \param addr \c bEndpointAddress field of a \ref USB_ENDPOINT_DESCRIPTOR
- */
- #define USB_ENDPOINT_DIRECTION_OUT(addr) (!((addr) & USB_ENDPOINT_DIRECTION_MASK))
-
- //! Tests the \c bEndpointAddress direction bit. TRUE if the endpoint address is an IN endpoint. (DeviceToHost, PC Read)
- /*!
- * \param addr \c bEndpointAddress field of a \ref USB_ENDPOINT_DESCRIPTOR
- */
- #define USB_ENDPOINT_DIRECTION_IN(addr) ((addr) & USB_ENDPOINT_DIRECTION_MASK)
-
- //! USB defined request codes
- /*
- * see Chapter 9 of the USB 2.0 specification for
- * more information.
- *
- * These are the correct values based on the USB 2.0 specification.
- */
- enum USB_REQUEST_ENUM
- {
- //! Request status of the specific recipient
- USB_REQUEST_GET_STATUS = 0x00,
-
- //! Clear or disable a specific feature
- USB_REQUEST_CLEAR_FEATURE = 0x01,
-
- //! Set or enable a specific feature
- USB_REQUEST_SET_FEATURE = 0x03,
-
- //! Set device address for all future accesses
- USB_REQUEST_SET_ADDRESS = 0x05,
-
- //! Get the specified descriptor
- USB_REQUEST_GET_DESCRIPTOR = 0x06,
-
- //! Update existing descriptors or add new descriptors
- USB_REQUEST_SET_DESCRIPTOR = 0x07,
-
- //! Get the current device configuration value
- USB_REQUEST_GET_CONFIGURATION = 0x08,
-
- //! Set device configuration
- USB_REQUEST_SET_CONFIGURATION = 0x09,
-
- //! Return the selected alternate setting for the specified interface
- USB_REQUEST_GET_INTERFACE = 0x0A,
-
- //! Select an alternate interface for the specified interface
- USB_REQUEST_SET_INTERFACE = 0x0B,
-
- //! Set then report an endpoint's synchronization frame
- USB_REQUEST_SYNC_FRAME = 0x0C,
- };
-
- //! USB defined class codes
- /*!
- * see http://www.usb.org/developers/defined_class for more information.
- *
- */
- enum USB_DEVICE_CLASS_ENUM
- {
- //! Reserved class
- USB_DEVICE_CLASS_RESERVED = 0x00,
-
- //! Audio class
- USB_DEVICE_CLASS_AUDIO = 0x01,
-
- //! Communications class
- USB_DEVICE_CLASS_COMMUNICATIONS = 0x02,
-
- //! Human Interface Device class
- USB_DEVICE_CLASS_HUMAN_INTERFACE = 0x03,
-
- //! Imaging class
- USB_DEVICE_CLASS_IMAGING = 0x06,
-
- //! Printer class
- USB_DEVICE_CLASS_PRINTER = 0x07,
-
- //! Mass storage class
- USB_DEVICE_CLASS_STORAGE = 0x08,
-
- //! Hub class
- USB_DEVICE_CLASS_HUB = 0x09,
-
- //! vendor-specific class
- USB_DEVICE_CLASS_VENDOR_SPECIFIC = 0xFF,
- };
-
- //! A structure representing the standard USB device descriptor.
- /*!
- * This descriptor is documented in section 9.6.1 of the USB 2.0 specification.
- * All multiple-byte fields are represented in host-endian format.
- */
- typedef struct _USB_DEVICE_DESCRIPTOR
- {
- //! Size of this descriptor (in bytes)
- UCHAR bLength;
-
- //! Descriptor type
- UCHAR bDescriptorType;
-
- //! USB specification release number in binary-coded decimal.
- /*!
- * A value of 0x0200 indicates USB 2.0, 0x0110 indicates USB 1.1, etc.
- */
- USHORT bcdUSB;
-
- //! USB-IF class code for the device
- UCHAR bDeviceClass;
-
- //! USB-IF subclass code for the device
- UCHAR bDeviceSubClass;
-
- //! USB-IF protocol code for the device
- UCHAR bDeviceProtocol;
-
- //! Maximum packet size for control endpoint 0
- UCHAR bMaxPacketSize0;
-
- //! USB-IF vendor ID
- USHORT idVendor;
-
- //! USB-IF product ID
- USHORT idProduct;
-
- //! Device release number in binary-coded decimal
- USHORT bcdDevice;
-
- //! Index of string descriptor describing manufacturer
- UCHAR iManufacturer;
-
- //! Index of string descriptor describing product
- UCHAR iProduct;
-
- //! Index of string descriptor containing device serial number
- UCHAR iSerialNumber;
-
- //! Number of possible configurations
- UCHAR bNumConfigurations;
-
- } USB_DEVICE_DESCRIPTOR;
- //! pointer to a \c USB_DEVICE_DESCRIPTOR
- typedef USB_DEVICE_DESCRIPTOR* PUSB_DEVICE_DESCRIPTOR;
-
- //! A structure representing the standard USB endpoint descriptor.
- /*!
- * This descriptor is documented in section 9.6.3 of the USB 2.0 specification.
- * All multiple-byte fields are represented in host-endian format.
- */
- typedef struct _USB_ENDPOINT_DESCRIPTOR
- {
- //! Size of this descriptor (in bytes)
- UCHAR bLength;
-
- //! Descriptor type
- UCHAR bDescriptorType;
-
- //! The address of the endpoint described by this descriptor.
- /*!
- * - Bits 0:3 are the endpoint number
- * - Bits 4:6 are reserved
- * - Bit 7 indicates direction
- */
- UCHAR bEndpointAddress;
-
- //! Attributes which apply to the endpoint when it is configured using the bConfigurationValue.
- /*!
- * - Bits 0:1 determine the transfer type.
- * - Bits 2:3 are only used for isochronous endpoints and refer to sync type.
- * - Bits 4:5 are also only used for isochronous endpoints and refer to usage type.
- * - Bits 6:7 are reserved.
- */
- UCHAR bmAttributes;
-
- //! Maximum packet size this endpoint is capable of sending/receiving.
- USHORT wMaxPacketSize;
-
- //! Interval for polling endpoint for data transfers.
- UCHAR bInterval;
-
- } USB_ENDPOINT_DESCRIPTOR;
- //! pointer to a \c USB_ENDPOINT_DESCRIPTOR
- typedef USB_ENDPOINT_DESCRIPTOR* PUSB_ENDPOINT_DESCRIPTOR;
-
- //! A structure representing the standard USB configuration descriptor.
- /*
- *
- * This descriptor is documented in section 9.6.3 of the USB 2.0 specification.
- * All multiple-byte fields are represented in host-endian format.
- *
- */
- typedef struct _USB_CONFIGURATION_DESCRIPTOR
- {
- //! Size of this descriptor (in bytes)
- UCHAR bLength;
-
- //! Descriptor type
- UCHAR bDescriptorType;
-
- //! Total length of data returned for this configuration
- USHORT wTotalLength;
-
- //! Number of interfaces supported by this configuration
- UCHAR bNumInterfaces;
-
- //! Identifier value for this configuration
- UCHAR bConfigurationValue;
-
- //! Index of string descriptor describing this configuration
- UCHAR iConfiguration;
-
- //! Configuration characteristics
- UCHAR bmAttributes;
-
- //! Maximum power consumption of the USB device from this bus in this configuration when the device is fully operation.
- /*!
- * Expressed in units of 2 mA.
- */
- UCHAR MaxPower;
- } USB_CONFIGURATION_DESCRIPTOR;
- //! pointer to a \c USB_CONFIGURATION_DESCRIPTOR
- typedef USB_CONFIGURATION_DESCRIPTOR* PUSB_CONFIGURATION_DESCRIPTOR;
-
- //! A structure representing the standard USB interface descriptor.
- /*!
- * This descriptor is documented in section 9.6.5 of the USB 2.0 specification.
- * All multiple-byte fields are represented in host-endian format.
- */
- typedef struct _USB_INTERFACE_DESCRIPTOR
- {
- //! Size of this descriptor (in bytes)
- UCHAR bLength;
-
- //! Descriptor type
- UCHAR bDescriptorType;
-
- //! Number of this interface
- UCHAR bInterfaceNumber;
-
- //! Value used to select this alternate setting for this interface
- UCHAR bAlternateSetting;
-
- //! Number of endpoints used by this interface (excluding the control endpoint)
- UCHAR bNumEndpoints;
-
- //! USB-IF class code for this interface
- UCHAR bInterfaceClass;
-
- //! USB-IF subclass code for this interface
- UCHAR bInterfaceSubClass;
-
- //! USB-IF protocol code for this interface
- UCHAR bInterfaceProtocol;
-
- //! Index of string descriptor describing this interface
- UCHAR iInterface;
-
- } USB_INTERFACE_DESCRIPTOR;
- //! pointer to a \c USB_INTERFACE_DESCRIPTOR
- typedef USB_INTERFACE_DESCRIPTOR* PUSB_INTERFACE_DESCRIPTOR;
-
- //! A structure representing the standard USB string descriptor.
- /*!
- * This descriptor is documented in section 9.6.5 of the USB 2.0 specification.
- * All multiple-byte fields are represented in host-endian format.
- */
- typedef struct _USB_STRING_DESCRIPTOR
- {
- //! Size of this descriptor (in bytes)
- UCHAR bLength;
-
- //! Descriptor type
- UCHAR bDescriptorType;
-
- //! Content of the string
- WCHAR bString[1];
-
- } USB_STRING_DESCRIPTOR;
- //! pointer to a \c USB_STRING_DESCRIPTOR
- typedef USB_STRING_DESCRIPTOR* PUSB_STRING_DESCRIPTOR;
-
- //! A structure representing the common USB descriptor.
- typedef struct _USB_COMMON_DESCRIPTOR
- {
- //! Size of this descriptor (in bytes)
- UCHAR bLength;
-
- //! Descriptor type
- UCHAR bDescriptorType;
-
- } USB_COMMON_DESCRIPTOR;
- //! pointer to a \c USB_COMMON_DESCRIPTOR
- typedef USB_COMMON_DESCRIPTOR* PUSB_COMMON_DESCRIPTOR;
-
- #if _MSC_VER >= 1200
- #pragma warning(push)
- #endif
- #pragma warning (disable:4201)
- #pragma warning(disable:4214) // named type definition in parentheses
-
- //! Allows hardware manufacturers to define groupings of interfaces.
- /*!
- *
- * The ECN specifies a USB descriptor, called the Interface Association
- * Descriptor (IAD).
- *
- * The Universal Serial Bus Specification, revision 2.0, does not support
- * grouping more than one interface of a composite device within a single
- * function. However, the USB Device Working Group (DWG) created USB device
- * classes that allow for functions with multiple interfaces, and the USB
- * Implementor's Forum issued an Engineering Change Notification (ECN) that
- * defines a mechanism for grouping interfaces.
- *
- */
- typedef struct _USB_INTERFACE_ASSOCIATION_DESCRIPTOR
- {
- //! Size of this descriptor (in bytes)
- UCHAR bLength;
-
- //! Descriptor type
- UCHAR bDescriptorType;
-
- //! First interface number of the set of interfaces that follow this descriptor
- UCHAR bFirstInterface;
-
- //! The Number of interfaces follow this descriptor that are considered "associated"
- UCHAR bInterfaceCount;
-
- //! \c bInterfaceClass used for this associated interfaces
- UCHAR bFunctionClass;
-
- //! \c bInterfaceSubClass used for the associated interfaces
- UCHAR bFunctionSubClass;
-
- //! \c bInterfaceProtocol used for the associated interfaces
- UCHAR bFunctionProtocol;
-
- //! Index of string descriptor describing the associated interfaces
- UCHAR iFunction;
-
- } USB_INTERFACE_ASSOCIATION_DESCRIPTOR;
- //! pointer to a \c USB_INTERFACE_ASSOCIATION_DESCRIPTOR
- typedef USB_INTERFACE_ASSOCIATION_DESCRIPTOR* PUSB_INTERFACE_ASSOCIATION_DESCRIPTOR;
-
- #if _MSC_VER >= 1200
- #pragma warning(pop)
- #endif
-
- /*! @} */
-
- #include <poppack.h>
- #endif // __USB_H__
-
- #ifndef _LIBUSBK_LIBK_TYPES
-
- /*! \addtogroup libk
- * @{
- */
-
- //! Usb handle specific properties that can be retrieved with \ref UsbK_GetProperty.
- typedef enum _KUSB_PROPERTY
- {
- //! Get the internal device file handle used for operations such as GetOverlappedResult or DeviceIoControl.
- KUSB_PROPERTY_DEVICE_FILE_HANDLE,
-
- KUSB_PROPERTY_COUNT
-
- } KUSB_PROPERTY;
-
- //! Supported driver id enumeration.
- typedef enum _KUSB_DRVID
- {
- //! libusbK.sys driver ID
- KUSB_DRVID_LIBUSBK,
-
- //! libusb0.sys driver ID
- KUSB_DRVID_LIBUSB0,
-
- //! WinUSB.sys driver ID
- KUSB_DRVID_WINUSB,
-
- //! libusb0.sys filter driver ID
- KUSB_DRVID_LIBUSB0_FILTER,
-
- //! Supported driver count
- KUSB_DRVID_COUNT
-
- } KUSB_DRVID;
-
- //! Supported function id enumeration.
- typedef enum _KUSB_FNID
- {
- //! \ref UsbK_Init dynamic driver function id.
- KUSB_FNID_Init,
-
- //! \ref UsbK_Free dynamic driver function id.
- KUSB_FNID_Free,
-
- //! \ref UsbK_ClaimInterface dynamic driver function id.
- KUSB_FNID_ClaimInterface,
-
- //! \ref UsbK_ReleaseInterface dynamic driver function id.
- KUSB_FNID_ReleaseInterface,
-
- //! \ref UsbK_SetAltInterface dynamic driver function id.
- KUSB_FNID_SetAltInterface,
-
- //! \ref UsbK_GetAltInterface dynamic driver function id.
- KUSB_FNID_GetAltInterface,
-
- //! \ref UsbK_GetDescriptor dynamic driver function id.
- KUSB_FNID_GetDescriptor,
-
- //! \ref UsbK_ControlTransfer dynamic driver function id.
- KUSB_FNID_ControlTransfer,
-
- //! \ref UsbK_SetPowerPolicy dynamic driver function id.
- KUSB_FNID_SetPowerPolicy,
-
- //! \ref UsbK_GetPowerPolicy dynamic driver function id.
- KUSB_FNID_GetPowerPolicy,
-
- //! \ref UsbK_SetConfiguration dynamic driver function id.
- KUSB_FNID_SetConfiguration,
-
- //! \ref UsbK_GetConfiguration dynamic driver function id.
- KUSB_FNID_GetConfiguration,
-
- //! \ref UsbK_ResetDevice dynamic driver function id.
- KUSB_FNID_ResetDevice,
-
- //! \ref UsbK_Initialize dynamic driver function id.
- KUSB_FNID_Initialize,
-
- //! \ref UsbK_SelectInterface dynamic driver function id.
- KUSB_FNID_SelectInterface,
-
- //! \ref UsbK_GetAssociatedInterface dynamic driver function id.
- KUSB_FNID_GetAssociatedInterface,
-
- //! \ref UsbK_Clone dynamic driver function id.
- KUSB_FNID_Clone,
-
- //! \ref UsbK_QueryInterfaceSettings dynamic driver function id.
- KUSB_FNID_QueryInterfaceSettings,
-
- //! \ref UsbK_QueryDeviceInformation dynamic driver function id.
- KUSB_FNID_QueryDeviceInformation,
-
- //! \ref UsbK_SetCurrentAlternateSetting dynamic driver function id.
- KUSB_FNID_SetCurrentAlternateSetting,
-
- //! \ref UsbK_GetCurrentAlternateSetting dynamic driver function id.
- KUSB_FNID_GetCurrentAlternateSetting,
-
- //! \ref UsbK_QueryPipe dynamic driver function id.
- KUSB_FNID_QueryPipe,
-
- //! \ref UsbK_SetPipePolicy dynamic driver function id.
- KUSB_FNID_SetPipePolicy,
-
- //! \ref UsbK_GetPipePolicy dynamic driver function id.
- KUSB_FNID_GetPipePolicy,
-
- //! \ref UsbK_ReadPipe dynamic driver function id.
- KUSB_FNID_ReadPipe,
-
- //! \ref UsbK_WritePipe dynamic driver function id.
- KUSB_FNID_WritePipe,
-
- //! \ref UsbK_ResetPipe dynamic driver function id.
- KUSB_FNID_ResetPipe,
-
- //! \ref UsbK_AbortPipe dynamic driver function id.
- KUSB_FNID_AbortPipe,
-
- //! \ref UsbK_FlushPipe dynamic driver function id.
- KUSB_FNID_FlushPipe,
-
- //! \ref UsbK_IsoReadPipe dynamic driver function id.
- KUSB_FNID_IsoReadPipe,
-
- //! \ref UsbK_IsoWritePipe dynamic driver function id.
- KUSB_FNID_IsoWritePipe,
-
- //! \ref UsbK_GetCurrentFrameNumber dynamic driver function id.
- KUSB_FNID_GetCurrentFrameNumber,
-
- //! \ref UsbK_GetOverlappedResult dynamic driver function id.
- KUSB_FNID_GetOverlappedResult,
-
- //! \ref UsbK_GetProperty dynamic driver function id.
- KUSB_FNID_GetProperty,
-
-
- //! Supported function count
- KUSB_FNID_COUNT,
-
- } KUSB_FNID;
-
- typedef BOOL KUSB_API KUSB_Init (
- _out KUSB_HANDLE* InterfaceHandle,
- _in KLST_DEVINFO_HANDLE DevInfo);
-
- typedef BOOL KUSB_API KUSB_Free (
- _in KUSB_HANDLE InterfaceHandle);
-
- typedef BOOL KUSB_API KUSB_ClaimInterface (
- _in KUSB_HANDLE InterfaceHandle,
- _in UCHAR NumberOrIndex,
- _in BOOL IsIndex);
-
- typedef BOOL KUSB_API KUSB_ReleaseInterface (
- _in KUSB_HANDLE InterfaceHandle,
- _in UCHAR NumberOrIndex,
- _in BOOL IsIndex);
-
- typedef BOOL KUSB_API KUSB_SetAltInterface (
- _in KUSB_HANDLE InterfaceHandle,
- _in UCHAR NumberOrIndex,
- _in BOOL IsIndex,
- _in UCHAR AltSettingNumber);
-
- typedef BOOL KUSB_API KUSB_GetAltInterface (
- _in KUSB_HANDLE InterfaceHandle,
- _in UCHAR NumberOrIndex,
- _in BOOL IsIndex,
- _out PUCHAR AltSettingNumber);
-
- typedef BOOL KUSB_API KUSB_GetDescriptor (
- _in KUSB_HANDLE InterfaceHandle,
- _in UCHAR DescriptorType,
- _in UCHAR Index,
- _in USHORT LanguageID,
- _out PUCHAR Buffer,
- _in UINT BufferLength,
- _outopt PUINT LengthTransferred);
-
- typedef BOOL KUSB_API KUSB_ControlTransfer (
- _in KUSB_HANDLE InterfaceHandle,
- _in WINUSB_SETUP_PACKET SetupPacket,
- _refopt PUCHAR Buffer,
- _in UINT BufferLength,
- _outopt PUINT LengthTransferred,
- _inopt LPOVERLAPPED Overlapped);
-
- typedef BOOL KUSB_API KUSB_SetPowerPolicy (
- _in KUSB_HANDLE InterfaceHandle,
- _in UINT PolicyType,
- _in UINT ValueLength,
- _in PVOID Value);
-
- typedef BOOL KUSB_API KUSB_GetPowerPolicy (
- _in KUSB_HANDLE InterfaceHandle,
- _in UINT PolicyType,
- _ref PUINT ValueLength,
- _out PVOID Value);
-
- typedef BOOL KUSB_API KUSB_SetConfiguration (
- _in KUSB_HANDLE InterfaceHandle,
- _in UCHAR ConfigurationNumber);
-
- typedef BOOL KUSB_API KUSB_GetConfiguration (
- _in KUSB_HANDLE InterfaceHandle,
- _out PUCHAR ConfigurationNumber);
-
- typedef BOOL KUSB_API KUSB_ResetDevice (
- _in KUSB_HANDLE InterfaceHandle);
-
- typedef BOOL KUSB_API KUSB_Initialize (
- _in HANDLE DeviceHandle,
- _out KUSB_HANDLE* InterfaceHandle);
-
- typedef BOOL KUSB_API KUSB_SelectInterface (
- _in KUSB_HANDLE InterfaceHandle,
- _in UCHAR NumberOrIndex,
- _in BOOL IsIndex);
-
- typedef BOOL KUSB_API KUSB_GetAssociatedInterface (
- _in KUSB_HANDLE InterfaceHandle,
- _in UCHAR AssociatedInterfaceIndex,
- _out KUSB_HANDLE* AssociatedInterfaceHandle);
-
- typedef BOOL KUSB_API KUSB_Clone (
- _in KUSB_HANDLE InterfaceHandle,
- _out KUSB_HANDLE* DstInterfaceHandle);
-
- typedef BOOL KUSB_API KUSB_QueryInterfaceSettings (
- _in KUSB_HANDLE InterfaceHandle,
- _in UCHAR AltSettingIndex,
- _out PUSB_INTERFACE_DESCRIPTOR UsbAltInterfaceDescriptor);
-
- typedef BOOL KUSB_API KUSB_QueryDeviceInformation (
- _in KUSB_HANDLE InterfaceHandle,
- _in UINT InformationType,
- _ref PUINT BufferLength,
- _ref PVOID Buffer);
-
- typedef BOOL KUSB_API KUSB_SetCurrentAlternateSetting (
- _in KUSB_HANDLE InterfaceHandle,
- _in UCHAR AltSettingNumber);
-
- typedef BOOL KUSB_API KUSB_GetCurrentAlternateSetting (
- _in KUSB_HANDLE InterfaceHandle,
- _out PUCHAR AltSettingNumber);
-
- typedef BOOL KUSB_API KUSB_QueryPipe (
- _in KUSB_HANDLE InterfaceHandle,
- _in UCHAR AltSettingNumber,
- _in UCHAR PipeIndex,
- _out PWINUSB_PIPE_INFORMATION PipeInformation);
-
- typedef BOOL KUSB_API KUSB_SetPipePolicy (
- _in KUSB_HANDLE InterfaceHandle,
- _in UCHAR PipeID,
- _in UINT PolicyType,
- _in UINT ValueLength,
- _in PVOID Value);
-
- typedef BOOL KUSB_API KUSB_GetPipePolicy (
- _in KUSB_HANDLE InterfaceHandle,
- _in UCHAR PipeID,
- _in UINT PolicyType,
- _ref PUINT ValueLength,
- _out PVOID Value);
-
- typedef BOOL KUSB_API KUSB_ReadPipe (
- _in KUSB_HANDLE InterfaceHandle,
- _in UCHAR PipeID,
- _out PUCHAR Buffer,
- _in UINT BufferLength,
- _outopt PUINT LengthTransferred,
- _inopt LPOVERLAPPED Overlapped);
-
- typedef BOOL KUSB_API KUSB_WritePipe (
- _in KUSB_HANDLE InterfaceHandle,
- _in UCHAR PipeID,
- _in PUCHAR Buffer,
- _in UINT BufferLength,
- _outopt PUINT LengthTransferred,
- _inopt LPOVERLAPPED Overlapped);
-
- typedef BOOL KUSB_API KUSB_ResetPipe (
- _in KUSB_HANDLE InterfaceHandle,
- _in UCHAR PipeID);
-
- typedef BOOL KUSB_API KUSB_AbortPipe (
- _in KUSB_HANDLE InterfaceHandle,
- _in UCHAR PipeID);
-
- typedef BOOL KUSB_API KUSB_FlushPipe (
- _in KUSB_HANDLE InterfaceHandle,
- _in UCHAR PipeID);
-
- typedef BOOL KUSB_API KUSB_IsoReadPipe (
- _in KUSB_HANDLE InterfaceHandle,
- _in UCHAR PipeID,
- _out PUCHAR Buffer,
- _in UINT BufferLength,
- _in LPOVERLAPPED Overlapped,
- _refopt PKISO_CONTEXT IsoContext);
-
- typedef BOOL KUSB_API KUSB_IsoWritePipe (
- _in KUSB_HANDLE InterfaceHandle,
- _in UCHAR PipeID,
- _in PUCHAR Buffer,
- _in UINT BufferLength,
- _in LPOVERLAPPED Overlapped,
- _refopt PKISO_CONTEXT IsoContext);
-
- typedef BOOL KUSB_API KUSB_GetCurrentFrameNumber (
- _in KUSB_HANDLE InterfaceHandle,
- _out PUINT FrameNumber);
-
- typedef BOOL KUSB_API KUSB_GetOverlappedResult (
- _in KUSB_HANDLE InterfaceHandle,
- _in LPOVERLAPPED Overlapped,
- _out PUINT lpNumberOfBytesTransferred,
- _in BOOL bWait);
-
- typedef BOOL KUSB_API KUSB_GetProperty (
- _in KUSB_HANDLE InterfaceHandle,
- _in KUSB_PROPERTY PropertyType,
- _ref PUINT PropertySize,
- _out PVOID Value);
-
-
-
- //! USB core driver API information structure.
- /*!
- * This structure is part of \ref KUSB_DRIVER_API and contains
- * driver and user specific information.
- *
- */
- typedef struct _KUSB_DRIVER_API_INFO
- {
- //! \readonly Driver id of the driver api.
- INT DriverID;
-
- //! \readonly Number of valid functions contained in the driver API.
- INT FunctionCount;
-
- } KUSB_DRIVER_API_INFO;
-
- //! Driver API function set structure.
- /*
- * Contains the driver specific USB core function pointer set.
- *
- * \note
- * This structure has a fixed 512 byte structure size.
- */
- typedef struct _KUSB_DRIVER_API
- {
- //! Driver API information.
- KUSB_DRIVER_API_INFO Info;
-
- /*! \fn BOOL KUSB_API Init (_out KUSB_HANDLE* InterfaceHandle, _in KLST_DEVINFO_HANDLE DevInfo)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_Init
- */
- KUSB_Init* Init;
-
- /*! \fn BOOL KUSB_API Free (_in KUSB_HANDLE InterfaceHandle)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_Free
- */
- KUSB_Free* Free;
-
- /*! \fn BOOL KUSB_API ClaimInterface (_in KUSB_HANDLE InterfaceHandle, _in UCHAR NumberOrIndex, _in BOOL IsIndex)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_ClaimInterface
- */
- KUSB_ClaimInterface* ClaimInterface;
-
- /*! \fn BOOL KUSB_API ReleaseInterface (_in KUSB_HANDLE InterfaceHandle, _in UCHAR NumberOrIndex, _in BOOL IsIndex)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_ReleaseInterface
- */
- KUSB_ReleaseInterface* ReleaseInterface;
-
- /*! \fn BOOL KUSB_API SetAltInterface (_in KUSB_HANDLE InterfaceHandle, _in UCHAR NumberOrIndex, _in BOOL IsIndex, _in UCHAR AltSettingNumber)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_SetAltInterface
- */
- KUSB_SetAltInterface* SetAltInterface;
-
- /*! \fn BOOL KUSB_API GetAltInterface (_in KUSB_HANDLE InterfaceHandle, _in UCHAR NumberOrIndex, _in BOOL IsIndex, _out PUCHAR AltSettingNumber)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_GetAltInterface
- */
- KUSB_GetAltInterface* GetAltInterface;
-
- /*! \fn BOOL KUSB_API GetDescriptor (_in KUSB_HANDLE InterfaceHandle, _in UCHAR DescriptorType, _in UCHAR Index, _in USHORT LanguageID, _out PUCHAR Buffer, _in UINT BufferLength, _outopt PUINT LengthTransferred)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_GetDescriptor
- */
- KUSB_GetDescriptor* GetDescriptor;
-
- /*! \fn BOOL KUSB_API ControlTransfer (_in KUSB_HANDLE InterfaceHandle, _in WINUSB_SETUP_PACKET SetupPacket, _refopt PUCHAR Buffer, _in UINT BufferLength, _outopt PUINT LengthTransferred, _inopt LPOVERLAPPED Overlapped)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_ControlTransfer
- */
- KUSB_ControlTransfer* ControlTransfer;
-
- /*! \fn BOOL KUSB_API SetPowerPolicy (_in KUSB_HANDLE InterfaceHandle, _in UINT PolicyType, _in UINT ValueLength, _in PVOID Value)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_SetPowerPolicy
- */
- KUSB_SetPowerPolicy* SetPowerPolicy;
-
- /*! \fn BOOL KUSB_API GetPowerPolicy (_in KUSB_HANDLE InterfaceHandle, _in UINT PolicyType, _ref PUINT ValueLength, _out PVOID Value)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_GetPowerPolicy
- */
- KUSB_GetPowerPolicy* GetPowerPolicy;
-
- /*! \fn BOOL KUSB_API SetConfiguration (_in KUSB_HANDLE InterfaceHandle, _in UCHAR ConfigurationNumber)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_SetConfiguration
- */
- KUSB_SetConfiguration* SetConfiguration;
-
- /*! \fn BOOL KUSB_API GetConfiguration (_in KUSB_HANDLE InterfaceHandle, _out PUCHAR ConfigurationNumber)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_GetConfiguration
- */
- KUSB_GetConfiguration* GetConfiguration;
-
- /*! \fn BOOL KUSB_API ResetDevice (_in KUSB_HANDLE InterfaceHandle)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_ResetDevice
- */
- KUSB_ResetDevice* ResetDevice;
-
- /*! \fn BOOL KUSB_API Initialize (_in HANDLE DeviceHandle, _out KUSB_HANDLE* InterfaceHandle)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_Initialize
- */
- KUSB_Initialize* Initialize;
-
- /*! \fn BOOL KUSB_API SelectInterface (_in KUSB_HANDLE InterfaceHandle, _in UCHAR NumberOrIndex, _in BOOL IsIndex)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_SelectInterface
- */
- KUSB_SelectInterface* SelectInterface;
-
- /*! \fn BOOL KUSB_API GetAssociatedInterface (_in KUSB_HANDLE InterfaceHandle, _in UCHAR AssociatedInterfaceIndex, _out KUSB_HANDLE* AssociatedInterfaceHandle)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_GetAssociatedInterface
- */
- KUSB_GetAssociatedInterface* GetAssociatedInterface;
-
- /*! \fn BOOL KUSB_API Clone (_in KUSB_HANDLE InterfaceHandle, _out KUSB_HANDLE* DstInterfaceHandle)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_Clone
- */
- KUSB_Clone* Clone;
-
- /*! \fn BOOL KUSB_API QueryInterfaceSettings (_in KUSB_HANDLE InterfaceHandle, _in UCHAR AltSettingIndex, _out PUSB_INTERFACE_DESCRIPTOR UsbAltInterfaceDescriptor)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_QueryInterfaceSettings
- */
- KUSB_QueryInterfaceSettings* QueryInterfaceSettings;
-
- /*! \fn BOOL KUSB_API QueryDeviceInformation (_in KUSB_HANDLE InterfaceHandle, _in UINT InformationType, _ref PUINT BufferLength, _ref PVOID Buffer)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_QueryDeviceInformation
- */
- KUSB_QueryDeviceInformation* QueryDeviceInformation;
-
- /*! \fn BOOL KUSB_API SetCurrentAlternateSetting (_in KUSB_HANDLE InterfaceHandle, _in UCHAR AltSettingNumber)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_SetCurrentAlternateSetting
- */
- KUSB_SetCurrentAlternateSetting* SetCurrentAlternateSetting;
-
- /*! \fn BOOL KUSB_API GetCurrentAlternateSetting (_in KUSB_HANDLE InterfaceHandle, _out PUCHAR AltSettingNumber)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_GetCurrentAlternateSetting
- */
- KUSB_GetCurrentAlternateSetting* GetCurrentAlternateSetting;
-
- /*! \fn BOOL KUSB_API QueryPipe (_in KUSB_HANDLE InterfaceHandle, _in UCHAR AltSettingNumber, _in UCHAR PipeIndex, _out PWINUSB_PIPE_INFORMATION PipeInformation)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_QueryPipe
- */
- KUSB_QueryPipe* QueryPipe;
-
- /*! \fn BOOL KUSB_API SetPipePolicy (_in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID, _in UINT PolicyType, _in UINT ValueLength, _in PVOID Value)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_SetPipePolicy
- */
- KUSB_SetPipePolicy* SetPipePolicy;
-
- /*! \fn BOOL KUSB_API GetPipePolicy (_in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID, _in UINT PolicyType, _ref PUINT ValueLength, _out PVOID Value)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_GetPipePolicy
- */
- KUSB_GetPipePolicy* GetPipePolicy;
-
- /*! \fn BOOL KUSB_API ReadPipe (_in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID, _out PUCHAR Buffer, _in UINT BufferLength, _outopt PUINT LengthTransferred, _inopt LPOVERLAPPED Overlapped)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_ReadPipe
- */
- KUSB_ReadPipe* ReadPipe;
-
- /*! \fn BOOL KUSB_API WritePipe (_in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID, _in PUCHAR Buffer, _in UINT BufferLength, _outopt PUINT LengthTransferred, _inopt LPOVERLAPPED Overlapped)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_WritePipe
- */
- KUSB_WritePipe* WritePipe;
-
- /*! \fn BOOL KUSB_API ResetPipe (_in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_ResetPipe
- */
- KUSB_ResetPipe* ResetPipe;
-
- /*! \fn BOOL KUSB_API AbortPipe (_in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_AbortPipe
- */
- KUSB_AbortPipe* AbortPipe;
-
- /*! \fn BOOL KUSB_API FlushPipe (_in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_FlushPipe
- */
- KUSB_FlushPipe* FlushPipe;
-
- /*! \fn BOOL KUSB_API IsoReadPipe (_in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID, _out PUCHAR Buffer, _in UINT BufferLength, _in LPOVERLAPPED Overlapped, _refopt PKISO_CONTEXT IsoContext)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_IsoReadPipe
- */
- KUSB_IsoReadPipe* IsoReadPipe;
-
- /*! \fn BOOL KUSB_API IsoWritePipe (_in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID, _in PUCHAR Buffer, _in UINT BufferLength, _in LPOVERLAPPED Overlapped, _refopt PKISO_CONTEXT IsoContext)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_IsoWritePipe
- */
- KUSB_IsoWritePipe* IsoWritePipe;
-
- /*! \fn BOOL KUSB_API GetCurrentFrameNumber (_in KUSB_HANDLE InterfaceHandle, _out PUINT FrameNumber)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_GetCurrentFrameNumber
- */
- KUSB_GetCurrentFrameNumber* GetCurrentFrameNumber;
-
- /*! \fn BOOL KUSB_API GetOverlappedResult (_in KUSB_HANDLE InterfaceHandle, _in LPOVERLAPPED Overlapped, _out PUINT lpNumberOfBytesTransferred, _in BOOL bWait)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_GetOverlappedResult
- */
- KUSB_GetOverlappedResult* GetOverlappedResult;
-
- /*! \fn BOOL KUSB_API GetProperty (_in KUSB_HANDLE InterfaceHandle, _in KUSB_PROPERTY PropertyType, _ref PUINT PropertySize, _out PVOID Value)
- * \memberof KUSB_DRIVER_API
- * \copydoc UsbK_GetProperty
- */
- KUSB_GetProperty* GetProperty;
-
- //! fixed structure padding.
- UCHAR z_F_i_x_e_d[512 - sizeof(KUSB_DRIVER_API_INFO) - sizeof(UINT_PTR) * KUSB_FNID_COUNT];
-
- } KUSB_DRIVER_API;
- typedef KUSB_DRIVER_API* PKUSB_DRIVER_API;
- C_ASSERT(sizeof(KUSB_DRIVER_API) == 512);
- /**@}*/
- #endif
-
- #ifndef _LIBUSBK_HOTK_TYPES
-
- /*! \addtogroup hotk
- * @{
- */
-
- //! Hot plug config flags.
- typedef enum _KHOT_FLAG
- {
- //! No flags (or 0)
- KHOT_FLAG_NONE,
-
- //! Notify all devices which match upon a succuessful call to \ref HotK_Init.
- KHOT_FLAG_PLUG_ALL_ON_INIT = 0x0001,
-
- //! Allow other \ref KHOT_HANDLE instances to consume this match.
- KHOT_FLAG_PASS_DUPE_INSTANCE = 0x0002,
-
- //! If a \c UserHwnd is specified, use \c PostMessage instead of \c SendMessage.
- KHOT_FLAG_POST_USER_MESSAGE = 0x0004,
- } KHOT_FLAG;
-
- typedef VOID KUSB_API KHOT_PLUG_CB(
- _in KHOT_HANDLE HotHandle,
- _in KLST_DEVINFO_HANDLE DeviceInfo,
- _in KLST_SYNC_FLAG PlugType);
-
- //! Hot plug parameter structure.
- /*!
- * \fixedstruct{2048}
- *
- * This structure is intially passed as a parameter to \ref HotK_Init.
- *
- */
- typedef struct _KHOT_PARAMS
- {
- //! Hot plug event window handle to send/post messages when notifications occur.
- HWND UserHwnd;
-
- //! WM_USER message start offset used when sending/posting messages, See details.
- /*!
- * \attention The \ref hotk will send UserMessage+1 for arrival notifications and UserMessage+0 for removal notifications.
- *
- * - WPARAM = \ref KHOT_HANDLE
- * - LPARAM = \ref KLST_DEVINFO_HANDLE
- */
- UINT UserMessage;
-
- //! Additional init/config parameters
- KHOT_FLAG Flags;
-
- //! File pattern matches for restricting notifcations to a single/group or all supported usb devices.
- KLST_PATTERN_MATCH PatternMatch;
-
- //! Hot plug event callback function invoked when notifications occur.
- /*! \fn VOID KUSB_API OnHotPlug (_in KHOT_HANDLE HotHandle, _in KLST_DEVINFO_HANDLE DeviceInfo, _in KLST_SYNC_FLAG PlugType)
- * \memberof KHOT_PARAMS
- */
- KHOT_PLUG_CB* OnHotPlug;
-
- //! fixed structure padding.
- UCHAR z_F_i_x_e_d[2048 - sizeof(KLST_PATTERN_MATCH) - sizeof(UINT_PTR) * 2 - sizeof(UINT) * 2];
-
- } KHOT_PARAMS;
- C_ASSERT(sizeof(KHOT_PARAMS) == 2048);
-
- //! Pointer to a \ref KHOT_PARAMS structure.
- typedef KHOT_PARAMS* PKHOT_PARAMS;
-
- /**@}*/
-
- #endif
-
- #ifndef _LIBUSBK_OVLK_TYPES
-
- /*! \addtogroup ovlk
- * @{
- */
-
- //! \c WaitFlags used by \ref OvlK_Wait.
- /*!
- *
- */
- typedef enum _KOVL_WAIT_FLAG
- {
- //! Do not perform any additional actions upon exiting \ref OvlK_Wait.
- KOVL_WAIT_FLAG_NONE = 0L,
-
- //! If the i/o operation completes successfully, release the OverlappedK back to it's pool.
- KOVL_WAIT_FLAG_RELEASE_ON_SUCCESS = 0x0001,
-
- //! If the i/o operation fails, release the OverlappedK back to it's pool.
- KOVL_WAIT_FLAG_RELEASE_ON_FAIL = 0x0002,
-
- //! If the i/o operation fails or completes successfully, release the OverlappedK back to its pool. Perform no actions if it times-out.
- KOVL_WAIT_FLAG_RELEASE_ON_SUCCESS_FAIL = 0x0003,
-
- //! If the i/o operation times-out cancel it, but do not release the OverlappedK back to its pool.
- KOVL_WAIT_FLAG_CANCEL_ON_TIMEOUT = 0x0004,
-
- //! If the i/o operation times-out, cancel it and release the OverlappedK back to its pool.
- KOVL_WAIT_FLAG_RELEASE_ON_TIMEOUT = 0x000C,
-
- //! Always release the OverlappedK back to its pool. If the operation timed-out, cancel it before releasing back to its pool.
- KOVL_WAIT_FLAG_RELEASE_ALWAYS = 0x000F,
-
- //! Uses alterable wait functions. See http://msdn.microsoft.com/en-us/library/windows/desktop/ms687036%28v=vs.85%29.aspx
- KOVL_WAIT_FLAG_ALERTABLE = 0x0010,
-
- } KOVL_WAIT_FLAG;
-
- //! \c Overlapped pool config flags.
- /*!
- * \attention Currently not used.
- */
- typedef enum _KOVL_POOL_FLAG
- {
- KOVL_POOL_FLAG_NONE = 0L,
- } KOVL_POOL_FLAG;
-
- /**@}*/
-
- #endif
-
- #ifndef _LIBUSBK_STMK_TYPES
-
- /*! \addtogroup stmk
- * @{
- */
- //! Stream config flags.
- /*!
- * \attention Currently not used.
- */
- typedef enum _KSTM_FLAG
- {
- //! None
- KSTM_FLAG_NONE = 0L,
- KSTM_FLAG_NO_PARTIAL_XFERS = 0x00100000,
- KSTM_FLAG_USE_TIMEOUT = 0x80000000,
- KSTM_FLAG_TIMEOUT_MASK = 0x0001FFFF
- } KSTM_FLAG;
-
- //! Stream config flags.
- /*!
- * \attention Currently not used.
- */
- typedef enum _KSTM_COMPLETE_RESULT
- {
- //! Valid
- KSTM_COMPLETE_RESULT_VALID = 0L,
- //! Invalid
- KSTM_COMPLETE_RESULT_INVALID,
- } KSTM_COMPLETE_RESULT;
-
- //! Stream transfer context structure.
- /*!
- * This structure is passed into the stream callback functions.
- * The stream transfer context list is allocated upon a successful call to \ref StmK_Init. There is one
- * transfer context for each transfer. (0 to \c MaxPendingTransfers).
- *
- */
- typedef struct _KSTM_XFER_CONTEXT
- {
-
- //! Internal stream buffer.
- PUCHAR Buffer;
-
- //! Size of internal stream buffer.
- INT BufferSize;
-
- //! Number of bytes to write or number of bytes read.
- INT TransferLength;
-
- //! User defined state.
- PVOID UserState;
-
- } KSTM_XFER_CONTEXT;
- //! Pointer to a \ref KSTM_XFER_CONTEXT structure.
- typedef KSTM_XFER_CONTEXT* PKSTM_XFER_CONTEXT;
-
- //! Stream information structure.
- /*!
- * This structure is passed into the stream callback functions.
- * The stream context is allocated upon a successful call to \ref StmK_Init. There is only one
- * stream context per stream.
- *
- */
- typedef struct _KSTM_INFO
- {
- //! \ref KUSB_HANDLE this stream uses.
- KUSB_HANDLE UsbHandle;
-
- //! This parameter corresponds to the bEndpointAddress field in the endpoint descriptor.
- UCHAR PipeID;
-
- //! Maximum transfer read/write request allowed pending.
- INT MaxPendingTransfers;
-
- //! Maximum transfer sage size.
- INT MaxTransferSize;
-
- //! Maximum number of I/O request allowed pending.
- INT MaxPendingIO;
-
- //! Populated with the endpoint descriptor for the specified \c PipeID.
- USB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
-
- //! Populated with the driver api for the specified \c UsbHandle.
- KUSB_DRIVER_API DriverAPI;
-
- //! Populated with the device file handle for the specified \c UsbHandle.
- HANDLE DeviceHandle;
-
- //! Stream handle.
- KSTM_HANDLE StreamHandle;
-
- //! Stream info user defined state.
- PVOID UserState;
-
- } KSTM_INFO;
- //! Pointer to a \ref KSTM_INFO structure.
- typedef KSTM_INFO* PKSTM_INFO;
-
- //! Function definition for an optional user-defined callback; executed when a transfer error occurs.
- /*! \fn INT KUSB_API KSTM_ERROR_CB(_in PKSTM_INFO StreamInfo, _in PKSTM_XFER_CONTEXT XferContext, _in INT XferContextIndex, _in INT ErrorCode)
- * \memberof KSTM_CALLBACK
- */
- typedef INT KUSB_API KSTM_ERROR_CB(_in PKSTM_INFO StreamInfo, _in PKSTM_XFER_CONTEXT XferContext, _in INT XferContextIndex, _in INT ErrorCode);
-
- //! Function definition for an optional user-defined callback; executed to submit a transfer.
- /*! …
Large files files are truncated, but you can click here to view the full file