win-pvdrivers

changeset 662:21e041d3e07d 0.10.0.113

Lots of little fixes.
usbview now works.
Advanced properties of HCD in device manager still crashes.
author James Harper <james.harper@bendigoit.com.au>
date Tue Sep 15 20:17:23 2009 +1000 (2009-09-15)
parents 3163b141fda5
children 607a160c9e65
files xenusb/xenusb.h xenusb/xenusb_fdo.c xenusb/xenusb_hub.c xenusb/xenusb_huburb.c
line diff
     1.1 --- a/xenusb/xenusb.h	Tue Sep 15 20:16:08 2009 +1000
     1.2 +++ b/xenusb/xenusb.h	Tue Sep 15 20:17:23 2009 +1000
     1.3 @@ -162,7 +162,10 @@ typedef struct _xenusb_device_t {
     1.4    USB_DEVICE_DESCRIPTOR device_descriptor;
     1.5    ULONG port_number;
     1.6    WDFQUEUE urb_queue;
     1.7 +  USB_DEVICE_SPEED device_speed;
     1.8 +  USB_DEVICE_TYPE device_type;
     1.9    xenusb_config_t *active_config;
    1.10 +  xenusb_interface_t *active_interface;
    1.11    xenusb_config_t **configs; /* pointer to an array of configs */
    1.12  } xenusb_device_t;
    1.13  
     2.1 --- a/xenusb/xenusb_fdo.c	Tue Sep 15 20:16:08 2009 +1000
     2.2 +++ b/xenusb/xenusb_fdo.c	Tue Sep 15 20:17:23 2009 +1000
     2.3 @@ -168,7 +168,7 @@ XenUsb_ExecuteRequest(
     2.4      //FUNCTION_EXIT();
     2.5      return status;
     2.6    }
     2.7 -  WdfDmaTransactionSetMaximumLength(shadow->dma_transaction, 512);
     2.8 +  WdfDmaTransactionSetMaximumLength(shadow->dma_transaction, (USBIF_MAX_SEGMENTS_PER_REQUEST - 1) * PAGE_SIZE);
     2.9    status = WdfDmaTransactionExecute(shadow->dma_transaction, shadow);
    2.10    if (!NT_SUCCESS(status))
    2.11    {
     3.1 --- a/xenusb/xenusb_hub.c	Tue Sep 15 20:16:08 2009 +1000
     3.2 +++ b/xenusb/xenusb_hub.c	Tue Sep 15 20:17:23 2009 +1000
     3.3 @@ -478,7 +478,10 @@ XenPciPdo_UBIH_InitializeUsbDevice(
     3.4    
     3.5    // get address from freelist and assign it to the device...
     3.6    usb_device->address = 2;
     3.7 +  // and get this stuff properly...
     3.8    usb_device->port_number = 1;
     3.9 +  xupdd->usb_device->device_speed = UsbHighSpeed;
    3.10 +  xupdd->usb_device->device_type = Usb20Device;
    3.11  
    3.12    buf = ExAllocatePoolWithTag(NonPagedPool, PAGE_SIZE, XENUSB_POOL_TAG);
    3.13    mdl = IoAllocateMdl(buf, PAGE_SIZE, FALSE, FALSE, NULL);
    3.14 @@ -644,6 +647,8 @@ XenPciPdo_UBIH_InitializeUsbDevice(
    3.15        }
    3.16      }
    3.17    }
    3.18 +  usb_device->active_config = usb_device->configs[0];
    3.19 +  usb_device->active_interface = usb_device->configs[0]->interfaces[0];
    3.20  
    3.21    WDF_IO_QUEUE_CONFIG_INIT(&queue_config, WdfIoQueueDispatchParallel);
    3.22    queue_config.EvtIoInternalDeviceControl = XenUsb_EvtIoInternalDeviceControl_DEVICE_SUBMIT_URB;
    3.23 @@ -780,6 +785,7 @@ XenPciPdo_UBIH_QueryDeviceInformation(
    3.24  {
    3.25    PUSB_DEVICE_INFORMATION_0 udi = DeviceInformationBuffer;
    3.26    xenusb_device_t *usb_device = DeviceHandle;
    3.27 +  ULONG i;
    3.28  
    3.29    FUNCTION_ENTER();
    3.30  
    3.31 @@ -788,7 +794,7 @@ XenPciPdo_UBIH_QueryDeviceInformation(
    3.32    KdPrint((__DRIVER_NAME "     DeviceInformationBuffer = %p\n", DeviceInformationBuffer));
    3.33    KdPrint((__DRIVER_NAME "     DeviceInformationBufferLength = %d\n", DeviceInformationBufferLength));
    3.34    KdPrint((__DRIVER_NAME "     ->InformationLevel = %d\n", udi->InformationLevel));
    3.35 -  if (DeviceInformationBufferLength < (ULONG)FIELD_OFFSET(USB_DEVICE_INFORMATION_0, PipeList[1]))
    3.36 +  if (DeviceInformationBufferLength < (ULONG)FIELD_OFFSET(USB_DEVICE_INFORMATION_0, PipeList[usb_device->active_interface->interface_descriptor.bNumEndpoints]))
    3.37    {
    3.38      KdPrint((__DRIVER_NAME "     STATUS_BUFFER_TOO_SMALL\n"));
    3.39      FUNCTION_EXIT();
    3.40 @@ -800,22 +806,20 @@ XenPciPdo_UBIH_QueryDeviceInformation(
    3.41      FUNCTION_EXIT();
    3.42      return STATUS_NOT_SUPPORTED;
    3.43    }
    3.44 -  udi->ActualLength = FIELD_OFFSET(USB_DEVICE_INFORMATION_0, PipeList[1]);
    3.45 -  udi->PortNumber = 0;
    3.46 +  udi->ActualLength = FIELD_OFFSET(USB_DEVICE_INFORMATION_0, PipeList[usb_device->active_interface->interface_descriptor.bNumEndpoints]);
    3.47 +  udi->PortNumber = 1;
    3.48    memcpy(&udi->DeviceDescriptor, &usb_device->device_descriptor, sizeof(USB_DEVICE_DESCRIPTOR));
    3.49    udi->CurrentConfigurationValue = usb_device->active_config->config_descriptor.bConfigurationValue;
    3.50    udi->DeviceAddress = usb_device->address;
    3.51 -  udi->HubAddress = usb_device->address; // ?
    3.52 -  udi->DeviceSpeed = UsbHighSpeed; // get from structure...
    3.53 -  udi->DeviceType = Usb20Device; // get from structure...
    3.54 -  udi->NumberOfOpenPipes = 1;
    3.55 -  udi->PipeList[0].EndpointDescriptor.bLength = sizeof(USB_ENDPOINT_DESCRIPTOR);
    3.56 -  udi->PipeList[0].EndpointDescriptor.bDescriptorType = USB_ENDPOINT_DESCRIPTOR_TYPE;
    3.57 -  udi->PipeList[0].EndpointDescriptor.bEndpointAddress = 0x81;
    3.58 -  udi->PipeList[0].EndpointDescriptor.bmAttributes = 0x3;
    3.59 -  udi->PipeList[0].EndpointDescriptor.wMaxPacketSize = 2;
    3.60 -  udi->PipeList[0].EndpointDescriptor.bInterval = 12;
    3.61 -  udi->PipeList[0].ScheduleOffset = 0; // not necessarily right
    3.62 +  udi->HubAddress = 1; // ?
    3.63 +  udi->DeviceSpeed = usb_device->device_speed;
    3.64 +  udi->DeviceType = usb_device->device_type;
    3.65 +  udi->NumberOfOpenPipes = usb_device->active_interface->interface_descriptor.bNumEndpoints;
    3.66 +  for (i = 0; i < usb_device->active_interface->interface_descriptor.bNumEndpoints; i++)
    3.67 +  {
    3.68 +    memcpy(&udi->PipeList[i].EndpointDescriptor, &usb_device->active_interface->endpoints[i]->endpoint_descriptor, sizeof(USB_ENDPOINT_DESCRIPTOR));
    3.69 +    udi->PipeList[0].ScheduleOffset = 0; // not necessarily right
    3.70 +  }
    3.71    *LengthOfDataReturned = udi->ActualLength;
    3.72    FUNCTION_EXIT();
    3.73    return STATUS_SUCCESS;
    3.74 @@ -853,6 +857,8 @@ XenPciPdo_UBIH_GetControllerInformation 
    3.75    }
    3.76    
    3.77    uci->ActualLength = sizeof(USB_CONTROLLER_INFORMATION_0);
    3.78 +  uci->SelectiveSuspendEnabled = FALSE;
    3.79 +  uci->IsHighSpeedController = TRUE;
    3.80    *LengthOfDataReturned = uci->ActualLength;
    3.81    
    3.82    FUNCTION_EXIT();
    3.83 @@ -1328,6 +1334,8 @@ XenUsb_EvtChildListCreateDevice(WDFCHILD
    3.84    // get address from freelist...
    3.85    xupdd->usb_device->pdo_device = child_device;
    3.86    xupdd->usb_device->address = 1;
    3.87 +  xupdd->usb_device->device_speed = UsbHighSpeed;
    3.88 +  xupdd->usb_device->device_type = Usb20Device;
    3.89    xupdd->usb_device->device_descriptor.bLength = sizeof(USB_DEVICE_DESCRIPTOR);
    3.90    xupdd->usb_device->device_descriptor.bDescriptorType = USB_DEVICE_DESCRIPTOR_TYPE;
    3.91    xupdd->usb_device->device_descriptor.bcdUSB = 0x0200;
    3.92 @@ -1355,6 +1363,7 @@ XenUsb_EvtChildListCreateDevice(WDFCHILD
    3.93    xupdd->usb_device->configs[0]->config_descriptor.bmAttributes = 0xe0;
    3.94    xupdd->usb_device->configs[0]->config_descriptor.MaxPower = 0;
    3.95    xupdd->usb_device->configs[0]->interfaces[0] = ExAllocatePoolWithTag(NonPagedPool, sizeof(xenusb_interface_t) + sizeof(PVOID) * 1, XENUSB_POOL_TAG);
    3.96 +  xupdd->usb_device->active_interface = xupdd->usb_device->configs[0]->interfaces[0];
    3.97    xupdd->usb_device->configs[0]->interfaces[0]->config = xupdd->usb_device->configs[0];
    3.98    xupdd->usb_device->configs[0]->interfaces[0]->interface_descriptor.bLength = 9;
    3.99    xupdd->usb_device->configs[0]->interfaces[0]->interface_descriptor.bDescriptorType = USB_INTERFACE_DESCRIPTOR_TYPE;
     4.1 --- a/xenusb/xenusb_huburb.c	Tue Sep 15 20:16:08 2009 +1000
     4.2 +++ b/xenusb/xenusb_huburb.c	Tue Sep 15 20:17:23 2009 +1000
     4.3 @@ -85,7 +85,7 @@ XenUsb_EvtIoInternalDeviceControl_ROOTHU
     4.4      KdPrint((__DRIVER_NAME "      ConfigurationHandle = %p\n", urb->UrbSelectConfiguration.ConfigurationHandle));
     4.5      if (urb->UrbSelectConfiguration.ConfigurationDescriptor)
     4.6      {
     4.7 -      urb->UrbSelectConfiguration.ConfigurationHandle = (PVOID)0xEEEEEEEE;
     4.8 +      urb->UrbSelectConfiguration.ConfigurationHandle = xupdd->usb_device->configs[0];
     4.9        interface_information = &urb->UrbSelectConfiguration.Interface;
    4.10        for (i = 0; i < urb->UrbSelectConfiguration.ConfigurationDescriptor->bNumInterfaces; i++)
    4.11        {
    4.12 @@ -99,7 +99,7 @@ XenUsb_EvtIoInternalDeviceControl_ROOTHU
    4.13          KdPrint((__DRIVER_NAME "      Reserved = %02x\n", (ULONG)interface_information->Reserved));
    4.14          KdPrint((__DRIVER_NAME "      InterfaceHandle = %p\n", interface_information->InterfaceHandle));
    4.15          KdPrint((__DRIVER_NAME "      NumberOfPipes = %d\n", interface_information->NumberOfPipes));
    4.16 -        interface_information->InterfaceHandle = (PVOID)0xBBBBBBBB; // do this on completion...
    4.17 +        interface_information->InterfaceHandle = xupdd->usb_device->configs[0]->interfaces[0];
    4.18          interface_information->Class = 0x09;
    4.19          interface_information->SubClass = 0x00;
    4.20          interface_information->SubClass = 0x00;
    4.21 @@ -117,7 +117,7 @@ XenUsb_EvtIoInternalDeviceControl_ROOTHU
    4.22            interface_information->Pipes[j].EndpointAddress = 0x81;
    4.23            interface_information->Pipes[j].Interval = 12;
    4.24            interface_information->Pipes[j].PipeType = UsbdPipeTypeInterrupt;
    4.25 -          interface_information->Pipes[j].PipeHandle = xupdd->usb_device->configs[0]->interfaces[0]->endpoints[0];
    4.26 +          interface_information->Pipes[j].PipeHandle = xupdd->usb_device->configs[0]->interfaces[0]->endpoints[j];
    4.27            interface_information->Pipes[j].MaximumTransferSize = 4096; /* made up number - possibly not used */
    4.28            // this is input actually interface_information->Pipes[j].PipeFlags = 0;
    4.29          }