Implemented USBD_ParseConfigurationDescriptorEx and USBD_ParseDescriptors for bulkusb...
authorJames Tabor <james.tabor@reactos.org>
Sun, 14 Aug 2005 13:18:50 +0000 (13:18 +0000)
committerJames Tabor <james.tabor@reactos.org>
Sun, 14 Aug 2005 13:18:50 +0000 (13:18 +0000)
svn path=/trunk/; revision=17382

reactos/drivers/usb/usbd/usbd.c

index 6aae920..fef69c1 100644 (file)
@@ -21,7 +21,7 @@
  *    USBD_GetPdoRegistryParameters (implemented)
  */
 
-#include <windows.h>
+#include <ddk/ntddk.h>
 #include <ddk/usbdi.h>
 #ifndef PLUGPLAY_REGKEY_DRIVER
 #define PLUGPLAY_REGKEY_DRIVER              2
@@ -368,6 +368,31 @@ USBD_GetInterfaceLength(
     return Length;
 }
 
+/*
+ * @unimplemented
+ */
+PUSB_COMMON_DESCRIPTOR STDCALL
+USBD_ParseDescriptors(
+    PVOID  DescriptorBuffer,
+    ULONG  TotalLength,
+    PVOID  StartPosition,
+    LONG  DescriptorType
+    )
+{
+    PUSB_COMMON_DESCRIPTOR PComDes = StartPosition;
+
+    while(PComDes)
+    {
+       if (PComDes >= (PUSB_COMMON_DESCRIPTOR)
+                            ((PLONG)DescriptorBuffer + TotalLength) ) break;
+       if (PComDes->bDescriptorType == DescriptorType) return PComDes;
+       if (PComDes->bLength == 0) break;
+       PComDes = PComDes + PComDes->bLength;
+    }
+    return NULL;
+}
+
+
 /*
  * @unimplemented
  */
@@ -382,7 +407,46 @@ USBD_ParseConfigurationDescriptorEx(
     LONG InterfaceProtocol
     )
 {
-    return NULL;
+    int x = 0;
+    PUSB_INTERFACE_DESCRIPTOR UsbInterfaceDesc = StartPosition;
+
+    while(UsbInterfaceDesc)
+    {
+       UsbInterfaceDesc = (PUSB_INTERFACE_DESCRIPTOR)
+                           USBD_ParseDescriptors(ConfigurationDescriptor,
+                                        ConfigurationDescriptor->wTotalLength,
+                                        UsbInterfaceDesc,
+                                        USB_INTERFACE_DESCRIPTOR_TYPE);
+
+       if (!UsbInterfaceDesc) break;
+
+       if(InterfaceNumber != -1)
+       {
+          if(InterfaceNumber != UsbInterfaceDesc->bInterfaceNumber) x = 1;
+       }
+       if(AlternateSetting != -1)
+       {
+          if(AlternateSetting != UsbInterfaceDesc->bAlternateSetting) x = 1;
+       }
+       if(InterfaceClass != -1)
+       {
+          if(InterfaceClass != UsbInterfaceDesc->bInterfaceClass) x = 1;
+       }
+       if(InterfaceSubClass != -1)
+       {
+          if(InterfaceSubClass != UsbInterfaceDesc->bInterfaceSubClass) x = 1;
+       }
+       if(InterfaceProtocol != -1)
+       {
+          if(InterfaceProtocol != UsbInterfaceDesc->bInterfaceProtocol) x = 1;
+       }
+
+       if (!x) return UsbInterfaceDesc;
+
+       if (UsbInterfaceDesc->bLength == 0) break;
+       UsbInterfaceDesc = UsbInterfaceDesc + UsbInterfaceDesc->bLength;
+    }    
+    return NULL;    
 }
 
 /*
@@ -400,19 +464,6 @@ USBD_ParseConfigurationDescriptor(
         -1, -1, -1);
 }
 
-/*
- * @unimplemented
- */
-PUSB_COMMON_DESCRIPTOR STDCALL
-USBD_ParseDescriptors(
-    PVOID  DescriptorBuffer,
-    ULONG  TotalLength,
-    PVOID  StartPosition,
-    LONG  DescriptorType
-    )
-{
-    return NULL; 
-}
 
 /*
  * @implemented