usbd.sys: add usbd.sys (try 3)
Damjan Jovanovic
damjan.jov at gmail.com
Sat Mar 13 14:09:30 CST 2010
Changelog:
* usbd.sys: add usbd.sys
Try 3 orders copyright lines by year.
Damjan Jovanovic
-------------- next part --------------
diff --git a/configure.ac b/configure.ac
index 8eb37a2..bc73a1b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2527,6 +2527,7 @@ WINE_CONFIG_DLL(updspapi)
WINE_CONFIG_DLL(url,,[url])
WINE_CONFIG_DLL(urlmon,,[urlmon])
WINE_CONFIG_TEST(dlls/urlmon/tests)
+WINE_CONFIG_DLL(usbd.sys)
WINE_CONFIG_DLL(user.exe16,enable_win16)
WINE_CONFIG_DLL(user32,,[user32])
WINE_CONFIG_TEST(dlls/user32/tests)
diff --git a/dlls/usbd.sys/Makefile.in b/dlls/usbd.sys/Makefile.in
new file mode 100644
index 0000000..f745ffb
--- /dev/null
+++ b/dlls/usbd.sys/Makefile.in
@@ -0,0 +1,15 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../..
+SRCDIR = @srcdir@
+VPATH = @srcdir@
+MODULE = usbd.sys
+IMPORTLIB = usbd.sys
+IMPORTS = kernel32 ntoskrnl.exe
+EXTRADLLFLAGS = -Wb,--subsystem,native
+
+C_SRCS = \
+ usbd.c
+
+ at MAKE_DLL_RULES@
+
+ at DEPENDENCIES@ # everything below this line is overwritten by make depend
diff --git a/dlls/usbd.sys/usbd.c b/dlls/usbd.sys/usbd.c
new file mode 100644
index 0000000..49102d0
--- /dev/null
+++ b/dlls/usbd.sys/usbd.c
@@ -0,0 +1,211 @@
+/*
+ * Copyright (C) 2009 Alexander Morozov
+ * Copyright (C) 2010 Damjan Jovanovic
+ *
+ * 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>
+
+#define NONAMELESSUNION
+#define NONAMELESSSTRUCT
+
+#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 "ddk/usbdlib.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(usbd);
+
+PURB WINAPI USBD_CreateConfigurationRequestEx(
+ PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
+ PUSBD_INTERFACE_LIST_ENTRY InterfaceList )
+{
+ URB *urb;
+ UCHAR k, num_interfaces = 0;
+ SIZE_T size;
+ struct _URB_SELECT_CONFIGURATION *sel_conf;
+ USBD_INTERFACE_INFORMATION *if_info;
+ USB_INTERFACE_DESCRIPTOR *if_desc;
+ USBD_INTERFACE_LIST_ENTRY *entry;
+
+ TRACE( "%p, %p\n", ConfigurationDescriptor, InterfaceList );
+
+ entry = InterfaceList;
+ size = sizeof(struct _URB_SELECT_CONFIGURATION);
+ while (entry->InterfaceDescriptor)
+ {
+ size += (entry->InterfaceDescriptor->bNumEndpoints - 1) *
+ sizeof(USBD_PIPE_INFORMATION);
+ ++num_interfaces;
+ ++entry;
+ }
+ size += (num_interfaces - 1) * sizeof(USBD_INTERFACE_INFORMATION);
+
+ urb = ExAllocatePool( NonPagedPool, size );
+ RtlZeroMemory( urb, size );
+
+ sel_conf = &urb->u.UrbSelectConfiguration;
+ sel_conf->Hdr.Length = size;
+ sel_conf->Hdr.Function = URB_FUNCTION_SELECT_CONFIGURATION;
+ sel_conf->ConfigurationDescriptor = ConfigurationDescriptor;
+
+ entry = InterfaceList;
+ if_info = &sel_conf->Interface;
+ while (entry->InterfaceDescriptor)
+ {
+ if_desc = entry->InterfaceDescriptor;
+ entry->Interface = if_info;
+ if_info->InterfaceNumber = if_desc->bInterfaceNumber;
+ if_info->NumberOfPipes = if_desc->bNumEndpoints;
+ for (k = 0; k < if_info->NumberOfPipes; ++k)
+ if_info->Pipes[k].MaximumTransferSize = 4096;
+ if_info->Length = sizeof(USBD_INTERFACE_INFORMATION) +
+ (k - 1) * sizeof(USBD_PIPE_INFORMATION);
+ if_info = (USBD_INTERFACE_INFORMATION *)((char *)if_info +
+ if_info->Length);
+ ++entry;
+ }
+
+ return urb;
+}
+
+PUSB_INTERFACE_DESCRIPTOR WINAPI USBD_ParseConfigurationDescriptorEx(
+ PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
+ PVOID StartPosition, LONG InterfaceNumber,
+ LONG AlternateSetting, LONG InterfaceClass,
+ LONG InterfaceSubClass, LONG InterfaceProtocol )
+{
+ int i;
+ char *p = (char*)(ConfigurationDescriptor + 1);
+
+ TRACE( "%p, %p, %d, %d, %d, %d, %d\n", ConfigurationDescriptor,
+ StartPosition, InterfaceNumber, AlternateSetting,
+ InterfaceClass, InterfaceSubClass, InterfaceProtocol );
+
+ for (i = 0; i < ConfigurationDescriptor->bNumInterfaces; i++)
+ {
+ PUSB_COMMON_DESCRIPTOR common;
+ PUSB_INTERFACE_DESCRIPTOR interface;
+ do
+ {
+ common = (PUSB_COMMON_DESCRIPTOR) p;
+ p += common->bLength;
+ } while (common->bDescriptorType != USB_INTERFACE_DESCRIPTOR_TYPE);
+ interface = (PUSB_INTERFACE_DESCRIPTOR) common;
+ if (StartPosition <= (PVOID) interface &&
+ (InterfaceNumber == -1 || interface->bInterfaceNumber == InterfaceNumber) &&
+ (AlternateSetting == -1 || interface->bAlternateSetting == AlternateSetting) &&
+ (InterfaceClass == -1 || interface->bInterfaceClass == InterfaceClass) &&
+ (InterfaceSubClass == -1 || interface->bInterfaceSubClass == InterfaceSubClass) &&
+ (InterfaceProtocol == -1 || interface->bInterfaceProtocol == InterfaceProtocol))
+ {
+ return interface;
+ }
+ }
+ return NULL;
+}
+
+PURB WINAPI USBD_CreateConfigurationRequest(
+ PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, PUSHORT Siz )
+{
+ USBD_INTERFACE_LIST_ENTRY *uile;
+ USB_INTERFACE_DESCRIPTOR *if_desc, *max;
+ ULONG uile_size, k = 0;
+ URB *urb;
+
+ TRACE( "%p, %p\n", ConfigurationDescriptor, Siz );
+
+ uile_size = (ConfigurationDescriptor->bNumInterfaces + 1) *
+ sizeof(USBD_INTERFACE_LIST_ENTRY);
+ uile = ExAllocatePool( NonPagedPool, uile_size );
+ if (NULL == uile)
+ return NULL;
+ RtlZeroMemory( uile, uile_size );
+
+ if_desc = (USB_INTERFACE_DESCRIPTOR *)(ConfigurationDescriptor + 1);
+ max = (USB_INTERFACE_DESCRIPTOR *)((char *)ConfigurationDescriptor +
+ ConfigurationDescriptor->wTotalLength);
+ while (if_desc < max && k < ConfigurationDescriptor->bNumInterfaces)
+ {
+ if (USB_INTERFACE_DESCRIPTOR_TYPE == if_desc->bDescriptorType)
+ uile[k++].InterfaceDescriptor = if_desc;
+ if_desc = (USB_INTERFACE_DESCRIPTOR *)((char *)if_desc +
+ if_desc->bLength);
+ }
+
+ urb = USBD_CreateConfigurationRequestEx( ConfigurationDescriptor, uile );
+ *Siz = (NULL == urb) ? 0 : urb->u.UrbSelectConfiguration.Hdr.Length;
+
+ ExFreePool( uile );
+
+ return urb;
+}
+
+ULONG WINAPI USBD_GetInterfaceLength(
+ PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor,
+ PUCHAR BufferEnd)
+{
+ PUSB_COMMON_DESCRIPTOR common;
+ ULONG total = InterfaceDescriptor->bLength;
+
+ TRACE( "%p, %p\n", InterfaceDescriptor, BufferEnd );
+
+ for (common = (PUSB_COMMON_DESCRIPTOR)(InterfaceDescriptor + 1);
+ (((PUCHAR)common) + sizeof(USB_COMMON_DESCRIPTOR)) <= BufferEnd &&
+ common->bDescriptorType != USB_INTERFACE_DESCRIPTOR_TYPE;
+ common = (PUSB_COMMON_DESCRIPTOR)(((char*)common) + common->bLength))
+ {
+ total += common->bLength;
+ }
+ return total;
+}
+
+void WINAPI USBD_GetUSBDIVersion( PUSBD_VERSION_INFORMATION VersionInformation )
+{
+ TRACE( "%p\n", VersionInformation );
+ VersionInformation->USBDI_Version = 0x300;
+ VersionInformation->Supported_USB_Version = 0x100;
+}
+
+PUSB_COMMON_DESCRIPTOR WINAPI USBD_ParseDescriptors(
+ PVOID DescriptorBuffer,
+ ULONG TotalLength,
+ PVOID StartPosition,
+ LONG DescriptorType)
+{
+ PUSB_COMMON_DESCRIPTOR common;
+
+ TRACE( "%p, %u, %p, %d\n", DescriptorBuffer, TotalLength, StartPosition, DescriptorType );
+
+ for (common = (PUSB_COMMON_DESCRIPTOR)DescriptorBuffer;
+ ((char*)common) + sizeof(USB_COMMON_DESCRIPTOR) <= ((char*)DescriptorBuffer) + TotalLength;
+ common = (PUSB_COMMON_DESCRIPTOR)(((char*)common) + common->bLength))
+ {
+ if (StartPosition <= (PVOID)common && common->bDescriptorType == DescriptorType)
+ return common;
+ }
+ return NULL;
+}
+
+NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *path )
+{
+ return STATUS_SUCCESS;
+}
diff --git a/dlls/usbd.sys/usbd.sys.spec b/dlls/usbd.sys/usbd.sys.spec
new file mode 100644
index 0000000..0784894
--- /dev/null
+++ b/dlls/usbd.sys/usbd.sys.spec
@@ -0,0 +1,35 @@
+@ stdcall USBD_CreateConfigurationRequestEx(ptr ptr)
+@ stdcall USBD_ParseConfigurationDescriptorEx(ptr ptr)
+@ stdcall USBD_ParseDescriptors(ptr long ptr long)
+@ stub DllInitialize
+@ stub DllUnload
+@ stub USBD_AllocateDeviceName
+@ stub USBD_CalculateUsbBandwidth
+@ stub USBD_CompleteRequest
+@ stdcall USBD_CreateConfigurationRequest(ptr ptr)
+@ stdcall _USBD_CreateConfigurationRequestEx at 8(ptr ptr) USBD_CreateConfigurationRequestEx
+@ stub USBD_CreateDevice
+@ stub USBD_Debug_GetHeap
+@ stub USBD_Debug_LogEntry
+@ stub USBD_Debug_RetHeap
+@ stub USBD_Dispatch
+@ stub USBD_FreeDeviceMutex
+@ stub USBD_FreeDeviceName
+@ stub USBD_GetDeviceInformation
+@ stdcall USBD_GetInterfaceLength(ptr ptr)
+@ stub USBD_GetPdoRegistryParameter
+@ stub USBD_GetSuspendPowerState
+@ stdcall USBD_GetUSBDIVersion(ptr)
+@ stub USBD_InitializeDevice
+@ stub USBD_MakePdoName
+@ stub USBD_ParseConfigurationDescriptor
+@ stdcall _USBD_ParseConfigurationDescriptorEx at 28(ptr ptr long long long long long) USBD_ParseConfigurationDescriptorEx
+@ stdcall _USBD_ParseDescriptors at 16(ptr long ptr long) USBD_ParseDescriptors
+@ stub USBD_QueryBusTime
+@ stub USBD_RegisterHcDeviceCapabilities
+@ stub USBD_RegisterHcFilter
+@ stub USBD_RegisterHostController
+@ stub USBD_RemoveDevice
+@ stub USBD_RestoreDevice
+@ stub USBD_SetSuspendPowerState
+@ stub USBD_WaitDeviceMutex
More information about the wine-patches
mailing list