win-pvdrivers

changeset 945:05c557d14752 0.11.0.311

Fix windows interface setup. Skip unknown USB descriptors.
author James Harper <james.harper@bendigoit.com.au>
date Sat Jul 23 19:13:06 2011 +1000 (2011-07-23)
parents 4de2e9e70971
children 88bae0c1735f
files xenusb/xenusb_fdo.c xenusb/xenusb_hub.c
line diff
     1.1 --- a/xenusb/xenusb_fdo.c	Sun Jul 10 15:42:48 2011 +1000
     1.2 +++ b/xenusb/xenusb_fdo.c	Sat Jul 23 19:13:06 2011 +1000
     1.3 @@ -94,7 +94,7 @@ XenUsb_ExecuteRequest(
     1.4    ASSERT(mdl);
     1.5    ASSERT(transfer_buffer_length);
     1.6  
     1.7 -  FUNCTION_MSG("MmGetMdlVirtualAddress = %d\n", MmGetMdlVirtualAddress(mdl));
     1.8 +  FUNCTION_MSG("MmGetMdlVirtualAddress = %p\n", MmGetMdlVirtualAddress(mdl));
     1.9    FUNCTION_MSG("MmGetMdlByteCount = %d\n", MmGetMdlByteCount(mdl));
    1.10    FUNCTION_MSG("MmGetMdlByteOffset = %d\n", MmGetMdlByteOffset(mdl));
    1.11    
     2.1 --- a/xenusb/xenusb_hub.c	Sun Jul 10 15:42:48 2011 +1000
     2.2 +++ b/xenusb/xenusb_hub.c	Sat Jul 23 19:13:06 2011 +1000
     2.3 @@ -719,7 +719,8 @@ XenUsbHub_UBIH_InitializeUsbDevice(
     2.4      usb_device->configs[i]->device = usb_device;
     2.5      memcpy(&usb_device->configs[i]->config_descriptor, config_descriptor, sizeof(USB_CONFIGURATION_DESCRIPTOR));
     2.6      ptr += config_descriptor->bLength;
     2.7 -    for (j = 0; j < config_descriptor->bNumInterfaces; j++)
     2.8 +    j = 0;
     2.9 +    while (j < config_descriptor->bNumInterfaces)
    2.10      {
    2.11        interface_descriptor = (PUSB_INTERFACE_DESCRIPTOR)ptr;
    2.12        KdPrint((__DRIVER_NAME "       Interface %d\n", j));
    2.13 @@ -736,9 +737,17 @@ XenUsbHub_UBIH_InitializeUsbDevice(
    2.14        usb_device->configs[i]->interfaces[j] = ExAllocatePoolWithTag(NonPagedPool, sizeof(xenusb_interface_t) + sizeof(PVOID) * interface_descriptor->bNumEndpoints, XENUSB_POOL_TAG);
    2.15        usb_device->configs[i]->interfaces[j]->config = usb_device->configs[i];
    2.16        memcpy(&usb_device->configs[i]->interfaces[j]->interface_descriptor, interface_descriptor, sizeof(USB_INTERFACE_DESCRIPTOR));
    2.17 -      for (k = 0; k < interface_descriptor->bNumEndpoints; k++)
    2.18 +      k = 0;
    2.19 +      while (k < interface_descriptor->bNumEndpoints)
    2.20        {
    2.21          endpoint_descriptor = (PUSB_ENDPOINT_DESCRIPTOR)ptr;
    2.22 +        if (endpoint_descriptor->bDescriptorType != 5)
    2.23 +        {
    2.24 +          KdPrint((__DRIVER_NAME "        Unknown bDescriptorType %d found length = %d\n", endpoint_descriptor->bDescriptorType, endpoint_descriptor->bLength));
    2.25 +          ptr += endpoint_descriptor->bLength;
    2.26 +          continue;
    2.27 +        }
    2.28 +
    2.29          KdPrint((__DRIVER_NAME "        Endpoint %d\n", k));
    2.30          KdPrint((__DRIVER_NAME "         bLength = %d\n", endpoint_descriptor->bLength));
    2.31          KdPrint((__DRIVER_NAME "         bDescriptorType = %d\n", endpoint_descriptor->bDescriptorType));
    2.32 @@ -769,7 +778,9 @@ XenUsbHub_UBIH_InitializeUsbDevice(
    2.33          usb_device->configs[i]->interfaces[j]->endpoints[k]->pipe_value |= (endpoint_descriptor->bEndpointAddress & 0x80);
    2.34          usb_device->configs[i]->interfaces[j]->endpoints[k]->pipe_value |= (endpoint_descriptor->bEndpointAddress & 0x0F) << 15;
    2.35          memcpy(&usb_device->configs[i]->interfaces[j]->endpoints[k]->endpoint_descriptor, endpoint_descriptor, sizeof(USB_ENDPOINT_DESCRIPTOR));
    2.36 +        k++;
    2.37        }
    2.38 +      j++;
    2.39      }
    2.40    }
    2.41    usb_device->active_config = usb_device->configs[0];
    2.42 @@ -1728,7 +1739,7 @@ XenUsbHub_EvtDeviceWdmIrpPreprocessQUERY
    2.43      USB_BUS_INTERFACE_HUB_V7 ubih6;
    2.44      USB_BUS_INTERFACE_HUB_V7 ubih7;
    2.45  #endif
    2.46 -  } ubih;
    2.47 +  } *ubih;
    2.48    union {
    2.49      USB_BUS_INTERFACE_USBDI_V1 ubiu0;
    2.50      USB_BUS_INTERFACE_USBDI_V1 ubiu1;
    2.51 @@ -1752,74 +1763,79 @@ XenUsbHub_EvtDeviceWdmIrpPreprocessQUERY
    2.52  #endif
    2.53      )
    2.54      {
    2.55 -      ubih.ubih5.Size = stack->Parameters.QueryInterface.Size;
    2.56 -      ubih.ubih5.Version = stack->Parameters.QueryInterface.Version;
    2.57 -      ubih.ubih5.BusContext = device;
    2.58 -      ubih.ubih5.InterfaceReference = WdfDeviceInterfaceReferenceNoOp;
    2.59 -      ubih.ubih5.InterfaceDereference = WdfDeviceInterfaceDereferenceNoOp;
    2.60 +      ubih = (PVOID)stack->Parameters.QueryInterface.Interface;
    2.61 +      ubih->ubih5.Size = stack->Parameters.QueryInterface.Size;
    2.62 +      ubih->ubih5.Version = stack->Parameters.QueryInterface.Version;
    2.63 +      ubih->ubih5.BusContext = device;
    2.64 +      ubih->ubih5.InterfaceReference = WdfDeviceInterfaceReferenceNoOp;
    2.65 +      ubih->ubih5.InterfaceDereference = WdfDeviceInterfaceDereferenceNoOp;
    2.66        /* these two were changed to the Ex functions in v6 so we set them here so they don't get overwritten */
    2.67 -      ubih.ubih5.CreateUsbDevice = XenUsbHub_UBIH_CreateUsbDevice;
    2.68 -      ubih.ubih5.InitializeUsbDevice = XenUsbHub_UBIH_InitializeUsbDevice;
    2.69 +      ubih->ubih5.CreateUsbDevice = XenUsbHub_UBIH_CreateUsbDevice;
    2.70 +      ubih->ubih5.InitializeUsbDevice = XenUsbHub_UBIH_InitializeUsbDevice;
    2.71        switch (stack->Parameters.QueryInterface.Version)
    2.72        {
    2.73  #if (NTDDI_VERSION >= NTDDI_VISTA)  
    2.74        case USB_BUSIF_HUB_VERSION_7:
    2.75 -        ubih.ubih7.HubTestPoint = XenUsbHub_UBIH_HubTestPoint;
    2.76 -        ubih.ubih7.GetDevicePerformanceInfo = XenUsbHub_UBIH_GetDevicePerformanceInfo;
    2.77 -        ubih.ubih7.WaitAsyncPowerUp = XenUsbHub_UBIH_WaitAsyncPowerUp;
    2.78 -        ubih.ubih7.GetDeviceAddress = XenUsbHub_UBIH_GetDeviceAddress;
    2.79 -        ubih.ubih7.RefDeviceHandle = XenUsbHub_UBIH_RefDeviceHandle;
    2.80 -        ubih.ubih7.DerefDeviceHandle = XenUsbHub_UBIH_DerefDeviceHandle;
    2.81 -        ubih.ubih7.SetDeviceHandleIdleReadyState = XenUsbHub_UBIH_SetDeviceHandleIdleReadyState;
    2.82 -        ubih.ubih7.HubIsRoot = XenUsbHub_UBIH_HubIsRoot;
    2.83 -        ubih.ubih7.AcquireBusSemaphore = XenUsbHub_UBIH_AcquireBusSemaphore;
    2.84 -        ubih.ubih7.ReleaseBusSemaphore = XenUsbHub_UBIH_ReleaseBusSemaphore;
    2.85 -        ubih.ubih7.CaculatePipeBandwidth = XenUsbHub_UBIH_CaculatePipeBandwidth;
    2.86 -        ubih.ubih7.SetBusSystemWakeMode = XenUsbHub_UBIH_SetBusSystemWakeMode;
    2.87 -        ubih.ubih7.SetDeviceFlag = XenUsbHub_UBIH_SetDeviceFlag;
    2.88 -        ubih.ubih7.HubTestPoint = XenUsbHub_UBIH_HubTestPoint;
    2.89 -        ubih.ubih7.GetDevicePerformanceInfo = XenUsbHub_UBIH_GetDevicePerformanceInfo;
    2.90 -        ubih.ubih7.WaitAsyncPowerUp = XenUsbHub_UBIH_WaitAsyncPowerUp;
    2.91 -        ubih.ubih7.GetDeviceAddress = XenUsbHub_UBIH_GetDeviceAddress;
    2.92 -        ubih.ubih7.RefDeviceHandle = XenUsbHub_UBIH_RefDeviceHandle;
    2.93 -        ubih.ubih7.DerefDeviceHandle = XenUsbHub_UBIH_DerefDeviceHandle;
    2.94 -        ubih.ubih7.SetDeviceHandleIdleReadyState = XenUsbHub_UBIH_SetDeviceHandleIdleReadyState;
    2.95 -        ubih.ubih7.CreateUsbDeviceV7 = XenUsbHub_UBIH_CreateUsbDeviceV7;
    2.96 -        ubih.ubih7.GetContainerIdForPort = XenUsbHub_UBIH_GetContainerIdForPort;
    2.97 -        ubih.ubih7.SetContainerIdForPort = XenUsbHub_UBIH_SetContainerIdForPort;
    2.98 -        ubih.ubih7.AbortAllDevicePipes = XenUsbHub_UBIH_AbortAllDevicePipes;
    2.99 -        ubih.ubih7.SetDeviceErrataFlag = XenUsbHub_UBIH_SetDeviceErrataFlag;  
   2.100 +        ubih->ubih7.HubTestPoint = XenUsbHub_UBIH_HubTestPoint;
   2.101 +        ubih->ubih7.GetDevicePerformanceInfo = XenUsbHub_UBIH_GetDevicePerformanceInfo;
   2.102 +        ubih->ubih7.WaitAsyncPowerUp = XenUsbHub_UBIH_WaitAsyncPowerUp;
   2.103 +        ubih->ubih7.GetDeviceAddress = XenUsbHub_UBIH_GetDeviceAddress;
   2.104 +        ubih->ubih7.RefDeviceHandle = XenUsbHub_UBIH_RefDeviceHandle;
   2.105 +        ubih->ubih7.DerefDeviceHandle = XenUsbHub_UBIH_DerefDeviceHandle;
   2.106 +        ubih->ubih7.SetDeviceHandleIdleReadyState = XenUsbHub_UBIH_SetDeviceHandleIdleReadyState;
   2.107 +        ubih->ubih7.HubIsRoot = XenUsbHub_UBIH_HubIsRoot;
   2.108 +        ubih->ubih7.AcquireBusSemaphore = XenUsbHub_UBIH_AcquireBusSemaphore;
   2.109 +        ubih->ubih7.ReleaseBusSemaphore = XenUsbHub_UBIH_ReleaseBusSemaphore;
   2.110 +        ubih->ubih7.CaculatePipeBandwidth = XenUsbHub_UBIH_CaculatePipeBandwidth;
   2.111 +        ubih->ubih7.SetBusSystemWakeMode = XenUsbHub_UBIH_SetBusSystemWakeMode;
   2.112 +        ubih->ubih7.SetDeviceFlag = XenUsbHub_UBIH_SetDeviceFlag;
   2.113 +        ubih->ubih7.HubTestPoint = XenUsbHub_UBIH_HubTestPoint;
   2.114 +        ubih->ubih7.GetDevicePerformanceInfo = XenUsbHub_UBIH_GetDevicePerformanceInfo;
   2.115 +        ubih->ubih7.WaitAsyncPowerUp = XenUsbHub_UBIH_WaitAsyncPowerUp;
   2.116 +        ubih->ubih7.GetDeviceAddress = XenUsbHub_UBIH_GetDeviceAddress;
   2.117 +        ubih->ubih7.RefDeviceHandle = XenUsbHub_UBIH_RefDeviceHandle;
   2.118 +        ubih->ubih7.DerefDeviceHandle = XenUsbHub_UBIH_DerefDeviceHandle;
   2.119 +        ubih->ubih7.SetDeviceHandleIdleReadyState = XenUsbHub_UBIH_SetDeviceHandleIdleReadyState;
   2.120 +        ubih->ubih7.CreateUsbDeviceV7 = XenUsbHub_UBIH_CreateUsbDeviceV7;
   2.121 +        ubih->ubih7.GetContainerIdForPort = XenUsbHub_UBIH_GetContainerIdForPort;
   2.122 +        ubih->ubih7.SetContainerIdForPort = XenUsbHub_UBIH_SetContainerIdForPort;
   2.123 +        ubih->ubih7.AbortAllDevicePipes = XenUsbHub_UBIH_AbortAllDevicePipes;
   2.124 +        ubih->ubih7.SetDeviceErrataFlag = XenUsbHub_UBIH_SetDeviceErrataFlag;  
   2.125          /* fall through */
   2.126        case USB_BUSIF_HUB_VERSION_6:
   2.127 -        ubih.ubih6.CreateUsbDevice = XenUsbHub_UBIH_CreateUsbDeviceEx;
   2.128 -        ubih.ubih6.InitializeUsbDevice = XenUsbHub_UBIH_InitializeUsbDeviceEx;
   2.129 -        ubih.ubih6.HubIsRoot = XenUsbHub_UBIH_HubIsRoot;
   2.130 -        ubih.ubih6.AcquireBusSemaphore = XenUsbHub_UBIH_AcquireBusSemaphore;
   2.131 -        ubih.ubih6.ReleaseBusSemaphore = XenUsbHub_UBIH_ReleaseBusSemaphore;
   2.132 -        ubih.ubih6.CaculatePipeBandwidth = XenUsbHub_UBIH_CaculatePipeBandwidth;
   2.133 -        ubih.ubih6.SetBusSystemWakeMode = XenUsbHub_UBIH_SetBusSystemWakeMode;
   2.134 -        ubih.ubih6.SetDeviceFlag = XenUsbHub_UBIH_SetDeviceFlag;
   2.135 +        ubih->ubih6.CreateUsbDevice = XenUsbHub_UBIH_CreateUsbDeviceEx;
   2.136 +        ubih->ubih6.InitializeUsbDevice = XenUsbHub_UBIH_InitializeUsbDeviceEx;
   2.137 +        ubih->ubih6.HubIsRoot = XenUsbHub_UBIH_HubIsRoot;
   2.138 +        ubih->ubih6.AcquireBusSemaphore = XenUsbHub_UBIH_AcquireBusSemaphore;
   2.139 +        ubih->ubih6.ReleaseBusSemaphore = XenUsbHub_UBIH_ReleaseBusSemaphore;
   2.140 +        ubih->ubih6.CaculatePipeBandwidth = XenUsbHub_UBIH_CaculatePipeBandwidth;
   2.141 +        ubih->ubih6.SetBusSystemWakeMode = XenUsbHub_UBIH_SetBusSystemWakeMode;
   2.142 +        ubih->ubih6.SetDeviceFlag = XenUsbHub_UBIH_SetDeviceFlag;
   2.143          /* fall through */
   2.144  #endif
   2.145        case USB_BUSIF_HUB_VERSION_5:
   2.146 -        ubih.ubih5.GetUsbDescriptors = XenUsbHub_UBIH_GetUsbDescriptors;
   2.147 -        ubih.ubih5.RemoveUsbDevice = XenUsbHub_UBIH_RemoveUsbDevice;
   2.148 -        ubih.ubih5.RestoreUsbDevice = XenUsbHub_UBIH_RestoreUsbDevice;
   2.149 -        ubih.ubih5.GetPortHackFlags = XenUsbHub_UBIH_GetPortHackFlags;
   2.150 -        ubih.ubih5.QueryDeviceInformation = XenUsbHub_UBIH_QueryDeviceInformation;
   2.151 -        ubih.ubih5.GetControllerInformation = XenUsbHub_UBIH_GetControllerInformation;
   2.152 -        ubih.ubih5.ControllerSelectiveSuspend = XenUsbHub_UBIH_ControllerSelectiveSuspend;
   2.153 -        ubih.ubih5.GetExtendedHubInformation = XenUsbHub_UBIH_GetExtendedHubInformation;
   2.154 -        ubih.ubih5.GetRootHubSymbolicName = XenUsbHub_UBIH_GetRootHubSymbolicName;
   2.155 -        ubih.ubih5.GetDeviceBusContext = XenUsbHub_UBIH_GetDeviceBusContext;
   2.156 -        ubih.ubih5.Initialize20Hub = XenUsbHub_UBIH_Initialize20Hub;
   2.157 -        ubih.ubih5.RootHubInitNotification = XenUsbHub_UBIH_RootHubInitNotification;
   2.158 -        ubih.ubih5.FlushTransfers = XenUsbHub_UBIH_FlushTransfers;
   2.159 -        ubih.ubih5.SetDeviceHandleData = XenUsbHub_UBIH_SetDeviceHandleData;
   2.160 +        ubih->ubih5.GetUsbDescriptors = XenUsbHub_UBIH_GetUsbDescriptors;
   2.161 +        ubih->ubih5.RemoveUsbDevice = XenUsbHub_UBIH_RemoveUsbDevice;
   2.162 +        ubih->ubih5.RestoreUsbDevice = XenUsbHub_UBIH_RestoreUsbDevice;
   2.163 +        ubih->ubih5.GetPortHackFlags = XenUsbHub_UBIH_GetPortHackFlags;
   2.164 +        ubih->ubih5.QueryDeviceInformation = XenUsbHub_UBIH_QueryDeviceInformation;
   2.165 +        ubih->ubih5.GetControllerInformation = XenUsbHub_UBIH_GetControllerInformation;
   2.166 +        ubih->ubih5.ControllerSelectiveSuspend = XenUsbHub_UBIH_ControllerSelectiveSuspend;
   2.167 +        ubih->ubih5.GetExtendedHubInformation = XenUsbHub_UBIH_GetExtendedHubInformation;
   2.168 +        ubih->ubih5.GetRootHubSymbolicName = XenUsbHub_UBIH_GetRootHubSymbolicName;
   2.169 +        ubih->ubih5.GetDeviceBusContext = XenUsbHub_UBIH_GetDeviceBusContext;
   2.170 +        ubih->ubih5.Initialize20Hub = XenUsbHub_UBIH_Initialize20Hub;
   2.171 +        ubih->ubih5.RootHubInitNotification = XenUsbHub_UBIH_RootHubInitNotification;
   2.172 +        ubih->ubih5.FlushTransfers = XenUsbHub_UBIH_FlushTransfers;
   2.173 +        ubih->ubih5.SetDeviceHandleData = XenUsbHub_UBIH_SetDeviceHandleData;
   2.174        }
   2.175        irp->IoStatus.Information = 0;
   2.176        irp->IoStatus.Status = STATUS_SUCCESS;
   2.177      }
   2.178 +    else
   2.179 +    {
   2.180 +      KdPrint((__DRIVER_NAME "     size/version mismatch\n"));
   2.181 +    }
   2.182    }
   2.183    else if (memcmp(stack->Parameters.QueryInterface.InterfaceType, &USB_BUS_INTERFACE_USBDI_GUID, sizeof(GUID)) == 0)
   2.184    {
   2.185 @@ -1861,6 +1877,10 @@ XenUsbHub_EvtDeviceWdmIrpPreprocessQUERY
   2.186        irp->IoStatus.Information = 0;
   2.187        irp->IoStatus.Status = STATUS_SUCCESS;
   2.188      }
   2.189 +    else
   2.190 +    {
   2.191 +      KdPrint((__DRIVER_NAME "     size/version mismatch\n"));
   2.192 +    }
   2.193    }
   2.194    else if (memcmp(stack->Parameters.QueryInterface.InterfaceType, &GUID_TRANSLATOR_INTERFACE_STANDARD, sizeof(GUID)) == 0)
   2.195      KdPrint((__DRIVER_NAME "     GUID_TRANSLATOR_INTERFACE_STANDARD\n"));