|
Packit Service |
b0a153 |
/*
|
|
Packit Service |
b0a153 |
* Windows CE backend for libusb 1.0
|
|
Packit Service |
b0a153 |
* Copyright © 2011-2013 RealVNC Ltd.
|
|
Packit Service |
b0a153 |
* Portions taken from Windows backend, which is
|
|
Packit Service |
b0a153 |
* Copyright © 2009-2010 Pete Batard <pbatard@gmail.com>
|
|
Packit Service |
b0a153 |
* With contributions from Michael Plante, Orin Eman et al.
|
|
Packit Service |
b0a153 |
* Parts of this code adapted from libusb-win32-v1 by Stephan Meyer
|
|
Packit Service |
b0a153 |
* Major code testing contribution by Xiaofan Chen
|
|
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 |
#pragma once
|
|
Packit Service |
b0a153 |
|
|
Packit Service |
b0a153 |
#include "windows_common.h"
|
|
Packit Service |
b0a153 |
|
|
Packit Service |
b0a153 |
#include <windows.h>
|
|
Packit Service |
b0a153 |
#include "poll_windows.h"
|
|
Packit Service |
b0a153 |
|
|
Packit Service |
b0a153 |
#define MAX_DEVICE_COUNT 256
|
|
Packit Service |
b0a153 |
|
|
Packit Service |
b0a153 |
// This is a modified dump of the types in the ceusbkwrapper.h library header
|
|
Packit Service |
b0a153 |
// with functions transformed into extern pointers.
|
|
Packit Service |
b0a153 |
//
|
|
Packit Service |
b0a153 |
// This backend dynamically loads ceusbkwrapper.dll and doesn't include
|
|
Packit Service |
b0a153 |
// ceusbkwrapper.h directly to simplify the build process. The kernel
|
|
Packit Service |
b0a153 |
// side wrapper driver is built using the platform image build tools,
|
|
Packit Service |
b0a153 |
// which makes it difficult to reference directly from the libusb build
|
|
Packit Service |
b0a153 |
// system.
|
|
Packit Service |
b0a153 |
struct UKW_DEVICE_PRIV;
|
|
Packit Service |
b0a153 |
typedef struct UKW_DEVICE_PRIV *UKW_DEVICE;
|
|
Packit Service |
b0a153 |
typedef UKW_DEVICE *PUKW_DEVICE, *LPUKW_DEVICE;
|
|
Packit Service |
b0a153 |
|
|
Packit Service |
b0a153 |
typedef struct {
|
|
Packit Service |
b0a153 |
UINT8 bLength;
|
|
Packit Service |
b0a153 |
UINT8 bDescriptorType;
|
|
Packit Service |
b0a153 |
UINT16 bcdUSB;
|
|
Packit Service |
b0a153 |
UINT8 bDeviceClass;
|
|
Packit Service |
b0a153 |
UINT8 bDeviceSubClass;
|
|
Packit Service |
b0a153 |
UINT8 bDeviceProtocol;
|
|
Packit Service |
b0a153 |
UINT8 bMaxPacketSize0;
|
|
Packit Service |
b0a153 |
UINT16 idVendor;
|
|
Packit Service |
b0a153 |
UINT16 idProduct;
|
|
Packit Service |
b0a153 |
UINT16 bcdDevice;
|
|
Packit Service |
b0a153 |
UINT8 iManufacturer;
|
|
Packit Service |
b0a153 |
UINT8 iProduct;
|
|
Packit Service |
b0a153 |
UINT8 iSerialNumber;
|
|
Packit Service |
b0a153 |
UINT8 bNumConfigurations;
|
|
Packit Service |
b0a153 |
} UKW_DEVICE_DESCRIPTOR, *PUKW_DEVICE_DESCRIPTOR, *LPUKW_DEVICE_DESCRIPTOR;
|
|
Packit Service |
b0a153 |
|
|
Packit Service |
b0a153 |
typedef struct {
|
|
Packit Service |
b0a153 |
UINT8 bmRequestType;
|
|
Packit Service |
b0a153 |
UINT8 bRequest;
|
|
Packit Service |
b0a153 |
UINT16 wValue;
|
|
Packit Service |
b0a153 |
UINT16 wIndex;
|
|
Packit Service |
b0a153 |
UINT16 wLength;
|
|
Packit Service |
b0a153 |
} UKW_CONTROL_HEADER, *PUKW_CONTROL_HEADER, *LPUKW_CONTROL_HEADER;
|
|
Packit Service |
b0a153 |
|
|
Packit Service |
b0a153 |
// Collection of flags which can be used when issuing transfer requests
|
|
Packit Service |
b0a153 |
/* Indicates that the transfer direction is 'in' */
|
|
Packit Service |
b0a153 |
#define UKW_TF_IN_TRANSFER 0x00000001
|
|
Packit Service |
b0a153 |
/* Indicates that the transfer direction is 'out' */
|
|
Packit Service |
b0a153 |
#define UKW_TF_OUT_TRANSFER 0x00000000
|
|
Packit Service |
b0a153 |
/* Specifies that the transfer should complete as soon as possible,
|
|
Packit Service |
b0a153 |
* even if no OVERLAPPED structure has been provided. */
|
|
Packit Service |
b0a153 |
#define UKW_TF_NO_WAIT 0x00000100
|
|
Packit Service |
b0a153 |
/* Indicates that transfers shorter than the buffer are ok */
|
|
Packit Service |
b0a153 |
#define UKW_TF_SHORT_TRANSFER_OK 0x00000200
|
|
Packit Service |
b0a153 |
#define UKW_TF_SEND_TO_DEVICE 0x00010000
|
|
Packit Service |
b0a153 |
#define UKW_TF_SEND_TO_INTERFACE 0x00020000
|
|
Packit Service |
b0a153 |
#define UKW_TF_SEND_TO_ENDPOINT 0x00040000
|
|
Packit Service |
b0a153 |
/* Don't block when waiting for memory allocations */
|
|
Packit Service |
b0a153 |
#define UKW_TF_DONT_BLOCK_FOR_MEM 0x00080000
|
|
Packit Service |
b0a153 |
|
|
Packit Service |
b0a153 |
/* Value to use when dealing with configuration values, such as UkwGetConfigDescriptor,
|
|
Packit Service |
b0a153 |
* to specify the currently active configuration for the device. */
|
|
Packit Service |
b0a153 |
#define UKW_ACTIVE_CONFIGURATION -1
|
|
Packit Service |
b0a153 |
|
|
Packit Service |
b0a153 |
DLL_DECLARE_HANDLE(ceusbkwrapper);
|
|
Packit Service |
b0a153 |
DLL_DECLARE_FUNC(WINAPI, HANDLE, UkwOpenDriver, ());
|
|
Packit Service |
b0a153 |
DLL_DECLARE_FUNC(WINAPI, BOOL, UkwGetDeviceList, (HANDLE, LPUKW_DEVICE, DWORD, LPDWORD));
|
|
Packit Service |
b0a153 |
DLL_DECLARE_FUNC(WINAPI, void, UkwReleaseDeviceList, (HANDLE, LPUKW_DEVICE, DWORD));
|
|
Packit Service |
b0a153 |
DLL_DECLARE_FUNC(WINAPI, BOOL, UkwGetDeviceAddress, (UKW_DEVICE, unsigned char*, unsigned char*, unsigned long*));
|
|
Packit Service |
b0a153 |
DLL_DECLARE_FUNC(WINAPI, BOOL, UkwGetDeviceDescriptor, (UKW_DEVICE, LPUKW_DEVICE_DESCRIPTOR));
|
|
Packit Service |
b0a153 |
DLL_DECLARE_FUNC(WINAPI, BOOL, UkwGetConfigDescriptor, (UKW_DEVICE, DWORD, LPVOID, DWORD, LPDWORD));
|
|
Packit Service |
b0a153 |
DLL_DECLARE_FUNC(WINAPI, void, UkwCloseDriver, (HANDLE));
|
|
Packit Service |
b0a153 |
DLL_DECLARE_FUNC(WINAPI, BOOL, UkwCancelTransfer, (UKW_DEVICE, LPOVERLAPPED, DWORD));
|
|
Packit Service |
b0a153 |
DLL_DECLARE_FUNC(WINAPI, BOOL, UkwIssueControlTransfer, (UKW_DEVICE, DWORD, LPUKW_CONTROL_HEADER, LPVOID, DWORD, LPDWORD, LPOVERLAPPED));
|
|
Packit Service |
b0a153 |
DLL_DECLARE_FUNC(WINAPI, BOOL, UkwClaimInterface, (UKW_DEVICE, DWORD));
|
|
Packit Service |
b0a153 |
DLL_DECLARE_FUNC(WINAPI, BOOL, UkwReleaseInterface, (UKW_DEVICE, DWORD));
|
|
Packit Service |
b0a153 |
DLL_DECLARE_FUNC(WINAPI, BOOL, UkwSetInterfaceAlternateSetting, (UKW_DEVICE, DWORD, DWORD));
|
|
Packit Service |
b0a153 |
DLL_DECLARE_FUNC(WINAPI, BOOL, UkwClearHaltHost, (UKW_DEVICE, UCHAR));
|
|
Packit Service |
b0a153 |
DLL_DECLARE_FUNC(WINAPI, BOOL, UkwClearHaltDevice, (UKW_DEVICE, UCHAR));
|
|
Packit Service |
b0a153 |
DLL_DECLARE_FUNC(WINAPI, BOOL, UkwGetConfig, (UKW_DEVICE, PUCHAR));
|
|
Packit Service |
b0a153 |
DLL_DECLARE_FUNC(WINAPI, BOOL, UkwSetConfig, (UKW_DEVICE, UCHAR));
|
|
Packit Service |
b0a153 |
DLL_DECLARE_FUNC(WINAPI, BOOL, UkwResetDevice, (UKW_DEVICE));
|
|
Packit Service |
b0a153 |
DLL_DECLARE_FUNC(WINAPI, BOOL, UkwKernelDriverActive, (UKW_DEVICE, DWORD, PBOOL));
|
|
Packit Service |
b0a153 |
DLL_DECLARE_FUNC(WINAPI, BOOL, UkwAttachKernelDriver, (UKW_DEVICE, DWORD));
|
|
Packit Service |
b0a153 |
DLL_DECLARE_FUNC(WINAPI, BOOL, UkwDetachKernelDriver, (UKW_DEVICE, DWORD));
|
|
Packit Service |
b0a153 |
DLL_DECLARE_FUNC(WINAPI, BOOL, UkwIssueBulkTransfer, (UKW_DEVICE, DWORD, UCHAR, LPVOID, DWORD, LPDWORD, LPOVERLAPPED));
|
|
Packit Service |
b0a153 |
DLL_DECLARE_FUNC(WINAPI, BOOL, UkwIsPipeHalted, (UKW_DEVICE, UCHAR, LPBOOL));
|
|
Packit Service |
b0a153 |
|
|
Packit Service |
b0a153 |
// Used to determine if an endpoint status really is halted on a failed transfer.
|
|
Packit Service |
b0a153 |
#define STATUS_HALT_FLAG 0x1
|
|
Packit Service |
b0a153 |
|
|
Packit Service |
b0a153 |
struct wince_device_priv {
|
|
Packit Service |
b0a153 |
UKW_DEVICE dev;
|
|
Packit Service |
b0a153 |
UKW_DEVICE_DESCRIPTOR desc;
|
|
Packit Service |
b0a153 |
};
|
|
Packit Service |
b0a153 |
|
|
Packit Service |
b0a153 |
struct wince_transfer_priv {
|
|
Packit Service |
b0a153 |
struct winfd pollable_fd;
|
|
Packit Service |
b0a153 |
uint8_t interface_number;
|
|
Packit Service |
b0a153 |
};
|
|
Packit Service |
b0a153 |
|