[try 2] [6/9] Add usbd.sys.

Alexander Morozov amorozov at etersoft.ru
Mon Oct 6 08:15:44 CDT 2008


Changed as directed Rob Shearman. Please use this instead of previous version 
of [6/9] patch.
-------------- next part --------------
From 47a2522abd0d197976b44980596fe309c3e456a7 Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov at etersoft.ru>
Date: Mon, 6 Oct 2008 17:08:33 +0400
Subject: [PATCH] Add usbd.sys.

---
 dlls/usbd.sys/Makefile.in   |   15 +++++
 dlls/usbd.sys/usbd.c        |  138 +++++++++++++++++++++++++++++++++++++++++++
 dlls/usbd.sys/usbd.sys.spec |   35 +++++++++++
 3 files changed, 188 insertions(+), 0 deletions(-)
 create mode 100644 dlls/usbd.sys/Makefile.in
 create mode 100644 dlls/usbd.sys/usbd.c
 create mode 100644 dlls/usbd.sys/usbd.sys.spec

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..1c0a6c3
--- /dev/null
+++ b/dlls/usbd.sys/usbd.c
@@ -0,0 +1,138 @@
+/*
+ * 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 )
+{
+    FIXME( "%p, %p, %d, %d, %d, %d, %d\n", ConfigurationDescriptor,
+            StartPosition, InterfaceNumber, AlternateSetting,
+            InterfaceClass, InterfaceSubClass, InterfaceProtocol );
+    return (PUSB_INTERFACE_DESCRIPTOR)++ConfigurationDescriptor;
+}
+
+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;
+}
+
+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..5d0377c
--- /dev/null
+++ b/dlls/usbd.sys/usbd.sys.spec
@@ -0,0 +1,35 @@
+@ stdcall USBD_CreateConfigurationRequestEx(ptr ptr)
+@ stdcall USBD_ParseConfigurationDescriptorEx(ptr ptr)
+@ stub USBD_ParseDescriptors
+@ 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
+@ stub USBD_GetInterfaceLength
+@ stub USBD_GetPdoRegistryParameter
+@ stub USBD_GetSuspendPowerState
+@ stub USBD_GetUSBDIVersion
+@ stub USBD_InitializeDevice
+@ stub USBD_MakePdoName
+@ stub USBD_ParseConfigurationDescriptor
+@ stdcall _USBD_ParseConfigurationDescriptorEx at 28(ptr ptr long long long long long) USBD_ParseConfigurationDescriptorEx
+@ stub _USBD_ParseDescriptors at 16
+@ stub USBD_QueryBusTime
+@ stub USBD_RegisterHcDeviceCapabilities
+@ stub USBD_RegisterHcFilter
+@ stub USBD_RegisterHostController
+@ stub USBD_RemoveDevice
+@ stub USBD_RestoreDevice
+@ stub USBD_SetSuspendPowerState
+@ stub USBD_WaitDeviceMutex
-- 
1.5.6.5.GIT



More information about the wine-patches mailing list