Signed-off-by: Mohamad Al-Jaf mohamadaljaf@gmail.com --- GUID was uppercased for copyright reasons. --- include/Makefile.in | 1 + include/ddk/winusbio.h | 58 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 include/ddk/winusbio.h
diff --git a/include/Makefile.in b/include/Makefile.in index 047e7ff9146..25cd9c6f4eb 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -209,6 +209,7 @@ SOURCES = \ ddk/wdm.h \ ddk/winddiui.h \ ddk/winsplp.h \ + ddk/winusbio.h \ ddk/wsk.h \ ddraw.h \ ddrawgdi.h \ diff --git a/include/ddk/winusbio.h b/include/ddk/winusbio.h new file mode 100644 index 00000000000..7b6b7c92efc --- /dev/null +++ b/include/ddk/winusbio.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2022 Mohamad Al-Jaf + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef _WINUSBIO_H_ +#define _WINUSBIO_H_ + +#define SHORT_PACKET_TERMINATE 0x01 +#define AUTO_CLEAR_STALL 0x02 +#define PIPE_TRANSFER_TIMEOUT 0x03 +#define IGNORE_SHORT_PACKETS 0x04 +#define ALLOW_PARTIAL_READS 0x05 +#define AUTO_FLUSH 0x06 +#define RAW_IO 0x07 +#define MAXIMUM_TRANSFER_SIZE 0x08 +#define RESET_PIPE_ON_RESUME 0x09 + +#define AUTO_SUSPEND 0x81 +#define SUSPEND_DELAY 0x83 + +#define DEVICE_SPEED 0x01 + +#define LowSpeed 0x01 +#define FullSpeed 0x02 +#define HighSpeed 0x03 + +DEFINE_GUID(WinUSB_TestGuid, 0XDA812BFF, 0X12C3, 0X46A2, 0X8E, 0X2B, 0XDB, 0XD3, 0XB7, 0X83, 0X4C, 0X43); + +typedef struct _WINUSB_PIPE_INFORMATION { + USBD_PIPE_TYPE PipeType; + UCHAR PipeId; + USHORT MaximumPacketSize; + UCHAR Interval; +} WINUSB_PIPE_INFORMATION, *PWINUSB_PIPE_INFORMATION; + +typedef struct _WINUSB_PIPE_INFORMATION_EX { + USBD_PIPE_TYPE PipeType; + UCHAR PipeId; + USHORT MaximumPacketSize; + UCHAR Interval; + ULONG MaximumBytesPerInterval; +} WINUSB_PIPE_INFORMATION_EX, *PWINUSB_PIPE_INFORMATION_EX; + +#endif /* _WINUSBIO_H_ */
Signed-off-by: Mohamad Al-Jaf mohamadaljaf@gmail.com --- v4: - Remove unnecessary winapifamily header. - Add all the functions in winusb.h. --- include/Makefile.in | 1 + include/winusb.h | 103 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 include/winusb.h
diff --git a/include/Makefile.in b/include/Makefile.in index 25cd9c6f4eb..e703706ecb4 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -837,6 +837,7 @@ SOURCES = \ wintabx.h \ winternl.h \ wintrust.h \ + winusb.h \ winuser.h \ winuser.rh \ winver.h \ diff --git a/include/winusb.h b/include/winusb.h new file mode 100644 index 00000000000..7e3fe865f83 --- /dev/null +++ b/include/winusb.h @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2022 Mohamad Al-Jaf + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef _WINUSB_H_ +#define _WINUSB_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "ddk/winusbio.h" + +typedef PVOID WINUSB_INTERFACE_HANDLE, *PWINUSB_INTERFACE_HANDLE; + +typedef PVOID WINUSB_ISOCH_BUFFER_HANDLE, *PWINUSB_ISOCH_BUFFER_HANDLE; + +typedef struct _WINUSB_SETUP_PACKET { + UCHAR RequestType; + UCHAR Request; + USHORT Value; + USHORT Index; + USHORT Length; +} WINUSB_SETUP_PACKET, *PWINUSB_SETUP_PACKET; + +typedef struct _USB_START_TRACKING_FOR_TIME_SYNC_INFORMATION { + HANDLE TimeTrackingHandle; + BOOLEAN IsStartupDelayTolerable; +} USB_START_TRACKING_FOR_TIME_SYNC_INFORMATION, *PUSB_START_TRACKING_FOR_TIME_SYNC_INFORMATION; + +typedef struct _USB_STOP_TRACKING_FOR_TIME_SYNC_INFORMATION { + HANDLE TimeTrackingHandle; +} USB_STOP_TRACKING_FOR_TIME_SYNC_INFORMATION, *PUSB_STOP_TRACKING_FOR_TIME_SYNC_INFORMATION; + +typedef struct _USB_FRAME_NUMBER_AND_QPC_FOR_TIME_SYNC_INFORMATION { + HANDLE TimeTrackingHandle; + ULONG InputFrameNumber; + ULONG InputMicroFrameNumber; + LARGE_INTEGER QueryPerformanceCounterAtInputFrameOrMicroFrame; + LARGE_INTEGER QueryPerformanceCounterFrequency; + ULONG PredictedAccuracyInMicroSeconds; + ULONG CurrentGenerationID; + LARGE_INTEGER CurrentQueryPerformanceCounter; + ULONG CurrentHardwareFrameNumber; + ULONG CurrentHardwareMicroFrameNumber; + ULONG CurrentUSBFrameNumber; +} USB_FRAME_NUMBER_AND_QPC_FOR_TIME_SYNC_INFORMATION, *PUSB_FRAME_NUMBER_AND_QPC_FOR_TIME_SYNC_INFORMATION; + +BOOL WINAPI WinUsb_AbortPipe(WINUSB_INTERFACE_HANDLE,UCHAR); +BOOL WINAPI WinUsb_ControlTransfer(WINUSB_INTERFACE_HANDLE,WINUSB_SETUP_PACKET,PUCHAR,ULONG,PULONG,LPOVERLAPPED); +BOOL WINAPI WinUsb_FlushPipe(WINUSB_INTERFACE_HANDLE,UCHAR); +BOOL WINAPI WinUsb_Free(WINUSB_INTERFACE_HANDLE); +BOOL WINAPI WinUsb_GetAdjustedFrameNumber(PULONG,LARGE_INTEGER); +BOOL WINAPI WinUsb_GetAssociatedInterface(WINUSB_INTERFACE_HANDLE,UCHAR,PWINUSB_INTERFACE_HANDLE); +BOOL WINAPI WinUsb_GetCurrentAlternateSetting(WINUSB_INTERFACE_HANDLE,PUCHAR); +BOOL WINAPI WinUsb_GetCurrentFrameNumber(WINUSB_INTERFACE_HANDLE,PULONG,LARGE_INTEGER*); +BOOL WINAPI WinUsb_GetCurrentFrameNumberAndQpc(WINUSB_INTERFACE_HANDLE,PUSB_FRAME_NUMBER_AND_QPC_FOR_TIME_SYNC_INFORMATION); +BOOL WINAPI WinUsb_GetDescriptor(WINUSB_INTERFACE_HANDLE,UCHAR,UCHAR,USHORT,PUCHAR,ULONG,PULONG); +BOOL WINAPI WinUsb_GetOverlappedResult(WINUSB_INTERFACE_HANDLE,LPOVERLAPPED,LPDWORD,BOOL); +BOOL WINAPI WinUsb_GetPipePolicy(WINUSB_INTERFACE_HANDLE,UCHAR,ULONG,PULONG,PVOID); +BOOL WINAPI WinUsb_GetPowerPolicy(WINUSB_INTERFACE_HANDLE,ULONG,PULONG,PVOID); +BOOL WINAPI WinUsb_Initialize(HANDLE,PWINUSB_INTERFACE_HANDLE); +BOOL WINAPI WinUsb_QueryDeviceInformation(WINUSB_INTERFACE_HANDLE,ULONG,PULONG,PVOID); +BOOL WINAPI WinUsb_QueryInterfaceSettings(WINUSB_INTERFACE_HANDLE,UCHAR,PUSB_INTERFACE_DESCRIPTOR); +BOOL WINAPI WinUsb_QueryPipe(WINUSB_INTERFACE_HANDLE,UCHAR,UCHAR,PWINUSB_PIPE_INFORMATION); +BOOL WINAPI WinUsb_QueryPipeEx(WINUSB_INTERFACE_HANDLE,UCHAR,UCHAR,PWINUSB_PIPE_INFORMATION_EX); +BOOL WINAPI WinUsb_ReadIsochPipe(WINUSB_ISOCH_BUFFER_HANDLE,ULONG,ULONG,PULONG,ULONG,PUSBD_ISO_PACKET_DESCRIPTOR,LPOVERLAPPED); +BOOL WINAPI WinUsb_ReadIsochPipeAsap(WINUSB_ISOCH_BUFFER_HANDLE,ULONG,ULONG,BOOL,ULONG,PUSBD_ISO_PACKET_DESCRIPTOR,LPOVERLAPPED); +BOOL WINAPI WinUsb_ReadPipe(WINUSB_INTERFACE_HANDLE,UCHAR,PUCHAR,ULONG,PULONG,LPOVERLAPPED); +BOOL WINAPI WinUsb_RegisterIsochBuffer(WINUSB_INTERFACE_HANDLE,UCHAR,PUCHAR,ULONG,PWINUSB_ISOCH_BUFFER_HANDLE); +BOOL WINAPI WinUsb_ResetPipe(WINUSB_INTERFACE_HANDLE,UCHAR); +BOOL WINAPI WinUsb_SetCurrentAlternateSetting(WINUSB_INTERFACE_HANDLE,UCHAR); +BOOL WINAPI WinUsb_SetPipePolicy(WINUSB_INTERFACE_HANDLE,UCHAR,ULONG,ULONG,PVOID); +BOOL WINAPI WinUsb_SetPowerPolicy(WINUSB_INTERFACE_HANDLE,ULONG,ULONG,PVOID); +BOOL WINAPI WinUsb_StartTrackingForTimeSync(WINUSB_INTERFACE_HANDLE,PUSB_START_TRACKING_FOR_TIME_SYNC_INFORMATION); +BOOL WINAPI WinUsb_StopTrackingForTimeSync(WINUSB_INTERFACE_HANDLE,PUSB_STOP_TRACKING_FOR_TIME_SYNC_INFORMATION); +BOOL WINAPI WinUsb_UnregisterIsochBuffer(WINUSB_ISOCH_BUFFER_HANDLE); +BOOL WINAPI WinUsb_WriteIsochPipe(WINUSB_ISOCH_BUFFER_HANDLE,ULONG,ULONG,PULONG,LPOVERLAPPED); +BOOL WINAPI WinUsb_WriteIsochPipeAsap(WINUSB_ISOCH_BUFFER_HANDLE,ULONG,ULONG,BOOL,LPOVERLAPPED); +BOOL WINAPI WinUsb_WritePipe(WINUSB_INTERFACE_HANDLE,UCHAR,PUCHAR,ULONG,PULONG,LPOVERLAPPED); + +PUSB_INTERFACE_DESCRIPTOR WINAPI WinUsb_ParseConfigurationDescriptor(PUSB_CONFIGURATION_DESCRIPTOR,PVOID,LONG,LONG,LONG,LONG,LONG); +PUSB_COMMON_DESCRIPTOR WINAPI WinUsb_ParseDescriptors(PVOID,ULONG,PVOID,LONG); + +#ifdef __cplusplus +} +#endif + +#endif /* _WINUSB_H_ */
Hi,
I have no idea why this isn't getting committed. Is it because I added all the functions? I thought that when it comes to public headers it's better to add all the flags and functions even if they're not used. Is this not the case? Please let me know so I can improve.
-- Kind regards, Mohamad
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52677 Signed-off-by: Mohamad Al-Jaf mohamadaljaf@gmail.com --- v4: - Use winusb channel instead of usb. - Add some necessary headers. --- dlls/winusb/Makefile.in | 5 +++++ dlls/winusb/main.c | 41 +++++++++++++++++++++++++++++++++++++++++ dlls/winusb/winusb.spec | 2 +- 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 dlls/winusb/main.c
diff --git a/dlls/winusb/Makefile.in b/dlls/winusb/Makefile.in index c8cab4dbed9..b6f01a1346c 100644 --- a/dlls/winusb/Makefile.in +++ b/dlls/winusb/Makefile.in @@ -1 +1,6 @@ MODULE = winusb.dll + +EXTRADLLFLAGS = -Wb,--prefer-native + +C_SRCS = \ + main.c diff --git a/dlls/winusb/main.c b/dlls/winusb/main.c new file mode 100644 index 00000000000..3d93d3968a3 --- /dev/null +++ b/dlls/winusb/main.c @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Mohamad Al-Jaf + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <stdarg.h> + +#include "ntstatus.h" +#define WIN32_NO_STATUS +#include "windef.h" +#include "winbase.h" +#include "winternl.h" +#include "ddk/wdm.h" +#include "ddk/usb.h" +#include "winusb.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(winusb); + +/*********************************************************************** + * WinUsb_Free (winusb.@) + */ +BOOL WINAPI WinUsb_Free(WINUSB_INTERFACE_HANDLE handle) +{ + FIXME( "(%p) - stub\n", handle ); + return TRUE; +} diff --git a/dlls/winusb/winusb.spec b/dlls/winusb/winusb.spec index 09371e9ee46..a0b57d58096 100644 --- a/dlls/winusb/winusb.spec +++ b/dlls/winusb/winusb.spec @@ -1,7 +1,7 @@ @ stub WinUsb_AbortPipe @ stub WinUsb_ControlTransfer @ stub WinUsb_FlushPipe -@ stub WinUsb_Free +@ stdcall WinUsb_Free(ptr) @ stub WinUsb_GetAssociatedInterface @ stub WinUsb_GetCurrentAlternateSetting @ stub WinUsb_GetDescriptor
Signed-off-by: Mohamad Al-Jaf mohamadaljaf@gmail.com --- There are some more USB_REQUEST flags but they belong in usbspec.h. Doesn't seem necessary to add a new file just for the flags. --- include/ddk/usb100.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/include/ddk/usb100.h b/include/ddk/usb100.h index 7ec74933d0f..0942c8f615a 100644 --- a/include/ddk/usb100.h +++ b/include/ddk/usb100.h @@ -28,6 +28,18 @@ #define USB_CONFIG_POWER_DESCRIPTOR_TYPE 0x07 #define USB_INTERFACE_POWER_DESCRIPTOR_TYPE 0x08
+#define USB_REQUEST_GET_STATUS 0x00 +#define USB_REQUEST_CLEAR_FEATURE 0x01 +#define USB_REQUEST_SET_FEATURE 0x03 +#define USB_REQUEST_SET_ADDRESS 0x05 +#define USB_REQUEST_GET_DESCRIPTOR 0x06 +#define USB_REQUEST_SET_DESCRIPTOR 0x07 +#define USB_REQUEST_GET_CONFIGURATION 0x08 +#define USB_REQUEST_SET_CONFIGURATION 0x09 +#define USB_REQUEST_GET_INTERFACE 0x0A +#define USB_REQUEST_SET_INTERFACE 0x0B +#define USB_REQUEST_SYNC_FRAME 0x0C + #include <pshpack1.h>
typedef struct _USB_DEVICE_DESCRIPTOR {