win-pvdrivers

changeset 930:95579023dfe9

usb updates. almost working under XP
author James Harper <james.harper@bendigoit.com.au>
date Fri Jun 10 20:47:09 2011 +1000 (2011-06-10)
parents 3aa213de2a31
children b655cd52f2ad
files xenusb/xenusb.h xenusb/xenusb_decode.c xenusb/xenusb_devurb.c xenusb/xenusb_fdo.c xenusb/xenusb_hub.c xenusb/xenusb_huburb.c
line diff
     1.1 --- a/xenusb/xenusb.h	Tue Jun 07 22:37:56 2011 +1000
     1.2 +++ b/xenusb/xenusb.h	Fri Jun 10 20:47:09 2011 +1000
     1.3 @@ -60,7 +60,7 @@ Foundation, Inc., 51 Franklin Street, Fi
     1.4  #define PORT_RESET          4
     1.5  #define PORT_POWER          8
     1.6  #define PORT_LOW_SPEED      9
     1.7 -#define PORT_HIGH_SPEED     9
     1.8 +#define PORT_HIGH_SPEED     10
     1.9  #define C_PORT_CONNECTION   16
    1.10  #define C_PORT_ENABLE       17
    1.11  #define C_PORT_SUSPEND      18
    1.12 @@ -185,6 +185,7 @@ typedef struct
    1.13    ULONG port_type;
    1.14    USHORT port_status;
    1.15    USHORT port_change;
    1.16 +  ULONG reset_counter;
    1.17  } xenusb_port_t;
    1.18  
    1.19  typedef struct {  
     2.1 --- a/xenusb/xenusb_decode.c	Tue Jun 07 22:37:56 2011 +1000
     2.2 +++ b/xenusb/xenusb_decode.c	Fri Jun 10 20:47:09 2011 +1000
     2.3 @@ -27,7 +27,7 @@ XenUsb_DecodeControlUrb(PURB urb, urb_de
     2.4  {
     2.5    ULONG retval;
     2.6    
     2.7 -  FUNCTION_ENTER();
     2.8 +  //FUNCTION_ENTER();
     2.9    switch(urb->UrbHeader.Function)
    2.10    {
    2.11    case URB_FUNCTION_SELECT_CONFIGURATION:
    2.12 @@ -76,14 +76,34 @@ XenUsb_DecodeControlUrb(PURB urb, urb_de
    2.13      decode_data->length = &urb->UrbControlTransfer.TransferBufferLength;
    2.14      retval = URB_DECODE_COMPLETE;
    2.15      break;
    2.16 +  case URB_FUNCTION_CLASS_DEVICE: /* CONTROL_TRANSFER has same underlying format as FUNCTION_CLASS_XXX */
    2.17 +FUNCTION_MSG("Function = %04x, RequestTypeReservedBits = %02x\n", urb->UrbHeader.Function, urb->UrbControlVendorClassRequest.RequestTypeReservedBits);
    2.18 +  case URB_FUNCTION_CLASS_OTHER:
    2.19 +  //case URB_FUNCTION_GET_STATUS_FROM_DEVICE: // seems to be missing fields...
    2.20    case URB_FUNCTION_CONTROL_TRANSFER:
    2.21 +#if (NTDDI_VERSION >= NTDDI_VISTA)  
    2.22    case URB_FUNCTION_CONTROL_TRANSFER_EX:
    2.23 -    KdPrint((__DRIVER_NAME "     URB_FUNCTION_CONTROL_TRANSFER\n"));
    2.24 +#endif
    2.25 +
    2.26 +    //KdPrint((__DRIVER_NAME "     URB_FUNCTION_CONTROL_TRANSFER\n"));
    2.27      decode_data->buffer = urb->UrbControlTransfer.TransferBuffer;
    2.28      decode_data->length = &urb->UrbControlTransfer.TransferBufferLength;
    2.29      memcpy(decode_data->setup_packet.raw, urb->UrbControlTransfer.SetupPacket, sizeof(decode_data->setup_packet.raw));
    2.30      retval = URB_DECODE_COMPLETE;
    2.31      break;
    2.32 +  case URB_FUNCTION_GET_STATUS_FROM_DEVICE:
    2.33 +    KdPrint((__DRIVER_NAME "     URB_FUNCTION_GET_STATUS_FROM_DEVICE\n"));
    2.34 +    decode_data->setup_packet.default_pipe_setup_packet.bmRequestType.Recipient = BMREQUEST_TO_DEVICE;
    2.35 +    decode_data->setup_packet.default_pipe_setup_packet.bmRequestType.Type = BMREQUEST_STANDARD;
    2.36 +    decode_data->setup_packet.default_pipe_setup_packet.bmRequestType.Dir = BMREQUEST_DEVICE_TO_HOST;
    2.37 +    decode_data->setup_packet.default_pipe_setup_packet.bRequest = USB_REQUEST_GET_STATUS;
    2.38 +    decode_data->setup_packet.default_pipe_setup_packet.wLength = 0;
    2.39 +    decode_data->setup_packet.default_pipe_setup_packet.wValue.W = 0;
    2.40 +    decode_data->setup_packet.default_pipe_setup_packet.wIndex.W = urb->UrbControlGetStatusRequest.Index;
    2.41 +    decode_data->buffer = urb->UrbControlTransfer.TransferBuffer;
    2.42 +    decode_data->length = &urb->UrbControlTransfer.TransferBufferLength;
    2.43 +    retval = URB_DECODE_COMPLETE;
    2.44 +    break;
    2.45  #if 0
    2.46    case URB_FUNCTION_GET_STATUS_FROM_DEVICE:
    2.47      KdPrint((__DRIVER_NAME "     URB_FUNCTION_GET_STATUS_FROM_DEVICE\n"));
    2.48 @@ -241,7 +261,7 @@ XenUsb_DecodeControlUrb(PURB urb, urb_de
    2.49        case PORT_RESET:
    2.50          KdPrint((__DRIVER_NAME "        PORT_RESET\n"));
    2.51          /* just fake the reset */
    2.52 -        xudd->ports[urb->UrbControlVendorClassRequest.Index - 1].port_change |= (1 << PORT_RESET);
    2.53 +        xudd->ports[urb->UrbControlVendorClassRequest.Index - 1].port_change |= (1 << C_PORT_RESET);
    2.54          break;
    2.55        default:
    2.56          KdPrint((__DRIVER_NAME "        Unknown Value %04X\n", urb->UrbControlVendorClassRequest.Value));
    2.57 @@ -258,11 +278,11 @@ XenUsb_DecodeControlUrb(PURB urb, urb_de
    2.58        {
    2.59        case C_PORT_CONNECTION:
    2.60          KdPrint((__DRIVER_NAME "        C_PORT_CONNECTION\n"));
    2.61 -        xudd->ports[urb->UrbControlVendorClassRequest.Index - 1].port_change &= ~(1 << PORT_CONNECTION);
    2.62 +        xudd->ports[urb->UrbControlVendorClassRequest.Index - 1].port_change &= ~(1 << C_PORT_CONNECTION);
    2.63          break;
    2.64        case C_PORT_RESET:
    2.65          KdPrint((__DRIVER_NAME "        C_PORT_RESET\n"));
    2.66 -        xudd->ports[urb->UrbControlVendorClassRequest.Index - 1].port_change &= ~(1 << PORT_RESET);
    2.67 +        xudd->ports[urb->UrbControlVendorClassRequest.Index - 1].port_change &= ~(1 << C_PORT_RESET);
    2.68          break;
    2.69        default:
    2.70          KdPrint((__DRIVER_NAME "        Unknown Value %04X\n", urb->UrbControlVendorClassRequest.Value));
    2.71 @@ -384,15 +404,15 @@ XenUsb_DecodeControlUrb(PURB urb, urb_de
    2.72  #endif
    2.73    case URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL:
    2.74    case URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER:
    2.75 -    FUNCTION_MSG("NOT_CONTROL URB_FUNCTION_%04x\n", urb->UrbHeader.Function);
    2.76 +    //FUNCTION_MSG("NOT_CONTROL URB_FUNCTION_%04x\n", urb->UrbHeader.Function);
    2.77      retval = URB_DECODE_NOT_CONTROL;
    2.78      break;
    2.79    default:
    2.80 -    FUNCTION_MSG("URB_FUNCTION_%04x\n", urb->UrbHeader.Function);
    2.81 +    FUNCTION_MSG("Unknown URB_FUNCTION_%04x\n", urb->UrbHeader.Function);
    2.82      retval = URB_DECODE_UNKNOWN;
    2.83      break;
    2.84    }
    2.85 -  FUNCTION_EXIT();
    2.86 +  //FUNCTION_EXIT();
    2.87    return retval;
    2.88  }
    2.89  
     3.1 --- a/xenusb/xenusb_devurb.c	Tue Jun 07 22:37:56 2011 +1000
     3.2 +++ b/xenusb/xenusb_devurb.c	Fri Jun 10 20:47:09 2011 +1000
     3.3 @@ -29,7 +29,7 @@ XenUsb_UrbCallback(usbif_shadow_t *shado
     3.4    PXENUSB_DEVICE_DATA xudd;
     3.5    //ULONG i;
     3.6  
     3.7 -  //FUNCTION_ENTER();
     3.8 +  FUNCTION_ENTER();
     3.9  
    3.10    ASSERT(shadow->request);
    3.11    queue = WdfRequestGetIoQueue(shadow->request);
    3.12 @@ -89,7 +89,7 @@ XenUsb_UrbCallback(usbif_shadow_t *shado
    3.13      shadow->urb->UrbControlVendorClassRequest.TransferBufferLength = shadow->total_length;
    3.14      break;
    3.15    case URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER:
    3.16 -    if (shadow->rsp.status)
    3.17 +//    if (shadow->rsp.status)
    3.18      {
    3.19        KdPrint((__DRIVER_NAME "     rsp id = %d\n", shadow->rsp.id));
    3.20        KdPrint((__DRIVER_NAME "     rsp start_frame = %d\n", shadow->rsp.start_frame));
    3.21 @@ -120,10 +120,11 @@ XenUsb_UrbCallback(usbif_shadow_t *shado
    3.22      shadow->urb->UrbHeader.Status = USBD_STATUS_CRC;
    3.23      KdPrint((__DRIVER_NAME "     rsp status = -EPROTO\n"));
    3.24      break;
    3.25 +  case -EPIPE: /* see linux code - EPIPE is when the HCD returned a stall */
    3.26 +    shadow->urb->UrbHeader.Status = USBD_STATUS_STALL_PID;
    3.27 +    KdPrint((__DRIVER_NAME "     rsp status = -EPIPE (USBD_STATUS_STALL_PID)\n"));
    3.28 +    break;
    3.29  #if 0
    3.30 -  case -EPIPE:
    3.31 -    shadow->urb->UrbHeader.Status USBD_STATUS_ENDPOINT_HALTED;
    3.32 -    break;
    3.33    case -EOVERFLOW:
    3.34      shadow->urb->UrbHeader.Status USBD_STATUS_DATA_OVERRUN;
    3.35      break;
    3.36 @@ -140,7 +141,7 @@ XenUsb_UrbCallback(usbif_shadow_t *shado
    3.37    WdfRequestComplete(shadow->request, STATUS_SUCCESS);
    3.38    put_shadow_on_freelist(xudd, shadow);
    3.39  
    3.40 -  //FUNCTION_EXIT();
    3.41 +  FUNCTION_EXIT();
    3.42  }
    3.43  
    3.44  VOID
    3.45 @@ -496,7 +497,7 @@ XenUsb_EvtIoInternalDeviceControl_DEVICE
    3.46      }    
    3.47      break;
    3.48    case URB_FUNCTION_CLASS_DEVICE:
    3.49 -#if 0
    3.50 +#if 1
    3.51      KdPrint((__DRIVER_NAME "     URB_FUNCTION_CLASS_DEVICE\n"));
    3.52      KdPrint((__DRIVER_NAME "      TransferBufferLength = %d\n", urb->UrbControlVendorClassRequest.TransferBufferLength));
    3.53      KdPrint((__DRIVER_NAME "      TransferBuffer = %p\n", urb->UrbControlVendorClassRequest.TransferBuffer));
    3.54 @@ -736,9 +737,9 @@ URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE 
    3.55  #endif
    3.56    case URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER: /* 11.12.4 */
    3.57      endpoint = urb->UrbBulkOrInterruptTransfer.PipeHandle;    
    3.58 -//    KdPrint((__DRIVER_NAME "      pipe_value = %08x\n", endpoint->pipe_value));
    3.59 +    KdPrint((__DRIVER_NAME "      pipe_value = %08x\n", endpoint->pipe_value));
    3.60      shadow = get_shadow_from_freelist(xudd);
    3.61 -    //KdPrint((__DRIVER_NAME "      id = %d\n", shadow->id));
    3.62 +    KdPrint((__DRIVER_NAME "      id = %d\n", shadow->id));
    3.63      shadow->request = request;
    3.64      shadow->urb = urb;
    3.65      shadow->callback = XenUsb_UrbCallback;
    3.66 @@ -750,7 +751,7 @@ URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE 
    3.67      switch(endpoint->endpoint_descriptor.bmAttributes & USB_ENDPOINT_TYPE_MASK)
    3.68      {
    3.69      case USB_ENDPOINT_TYPE_BULK:
    3.70 -      //KdPrint((__DRIVER_NAME "      USB_ENDPOINT_TYPE_BULK\n"));
    3.71 +      KdPrint((__DRIVER_NAME "      USB_ENDPOINT_TYPE_BULK\n"));
    3.72        break;
    3.73      case USB_ENDPOINT_TYPE_INTERRUPT:
    3.74        KdPrint((__DRIVER_NAME "      USB_ENDPOINT_TYPE_INTERRUPT\n"));
     4.1 --- a/xenusb/xenusb_fdo.c	Tue Jun 07 22:37:56 2011 +1000
     4.2 +++ b/xenusb/xenusb_fdo.c	Fri Jun 10 20:47:09 2011 +1000
     4.3 @@ -51,9 +51,10 @@ XenUsb_ExecuteRequest(
     4.4    ULONG remaining;
     4.5    USHORT offset;
     4.6    
     4.7 -  //FUNCTION_ENTER();
     4.8 +  FUNCTION_ENTER();
     4.9 +  FUNCTION_MSG("IRQL = %d\n", KeGetCurrentIrql());
    4.10    
    4.11 -  //KdPrint((__DRIVER_NAME "     transfer_buffer_length = %d\n", transfer_buffer_length));
    4.12 +  KdPrint((__DRIVER_NAME "     transfer_buffer_length = %d\n", transfer_buffer_length));
    4.13    shadow->total_length = 0;
    4.14    if (!transfer_buffer_length)
    4.15    {
    4.16 @@ -71,7 +72,7 @@ XenUsb_ExecuteRequest(
    4.17        xudd->vectors.EvtChn_Notify(xudd->vectors.context, xudd->event_channel);
    4.18      }
    4.19      KeReleaseSpinLock(&xudd->urb_ring_lock, old_irql);
    4.20 -    //FUNCTION_EXIT();
    4.21 +    FUNCTION_EXIT();
    4.22      return STATUS_SUCCESS;
    4.23    }
    4.24    ASSERT(transfer_buffer || transfer_buffer_mdl);
    4.25 @@ -104,8 +105,8 @@ XenUsb_ExecuteRequest(
    4.26      offset = 0;
    4.27      remaining -= shadow->req.seg[i].length;
    4.28    }
    4.29 -  //KdPrint((__DRIVER_NAME "     buffer_length = %d\n", shadow->req.buffer_length));
    4.30 -  //KdPrint((__DRIVER_NAME "     nr_buffer_segs = %d\n", shadow->req.nr_buffer_segs));
    4.31 +  KdPrint((__DRIVER_NAME "     buffer_length = %d\n", shadow->req.buffer_length));
    4.32 +  KdPrint((__DRIVER_NAME "     nr_buffer_segs = %d\n", shadow->req.nr_buffer_segs));
    4.33  
    4.34    KeAcquireSpinLock(&xudd->urb_ring_lock, &old_irql);
    4.35    *RING_GET_REQUEST(&xudd->urb_ring, xudd->urb_ring.req_prod_pvt) = shadow->req;
    4.36 @@ -118,7 +119,7 @@ XenUsb_ExecuteRequest(
    4.37    }
    4.38    KeReleaseSpinLock(&xudd->urb_ring_lock, old_irql);
    4.39    
    4.40 -  //FUNCTION_EXIT();
    4.41 +  FUNCTION_EXIT();
    4.42    return status;
    4.43  }
    4.44  
    4.45 @@ -249,23 +250,23 @@ XenUsb_HandleEvent(PVOID context)
    4.46        KdPrint((__DRIVER_NAME "     conn_rsp->portnum = %d\n", conn_rsp->portnum));
    4.47        KdPrint((__DRIVER_NAME "     conn_rsp->speed = %d\n", conn_rsp->speed));
    4.48        
    4.49 -      xudd->ports[conn_rsp->portnum].port_type = conn_rsp->speed;
    4.50 +      xudd->ports[conn_rsp->portnum - 1].port_type = conn_rsp->speed;
    4.51        switch (conn_rsp->speed)
    4.52        {
    4.53        case USB_PORT_TYPE_NOT_CONNECTED:
    4.54 -        xudd->ports[conn_rsp->portnum].port_status = (1 << PORT_ENABLE);
    4.55 +        xudd->ports[conn_rsp->portnum - 1].port_status = 0; //(1 << PORT_ENABLE);
    4.56          break;
    4.57        case USB_PORT_TYPE_LOW_SPEED:
    4.58 -        xudd->ports[conn_rsp->portnum].port_status = (1 << PORT_LOW_SPEED) | (1 << PORT_CONNECTION) | (1 << PORT_ENABLE);
    4.59 +        xudd->ports[conn_rsp->portnum - 1].port_status = (1 << PORT_LOW_SPEED) | (1 << PORT_CONNECTION); // | (1 << PORT_ENABLE);
    4.60          break;
    4.61        case USB_PORT_TYPE_FULL_SPEED:
    4.62 -        xudd->ports[conn_rsp->portnum].port_status = (1 << PORT_CONNECTION) | (1 << PORT_ENABLE);
    4.63 +        xudd->ports[conn_rsp->portnum - 1].port_status = (1 << PORT_CONNECTION); // | (1 << PORT_ENABLE);
    4.64          break;
    4.65        case USB_PORT_TYPE_HIGH_SPEED:
    4.66 -        xudd->ports[conn_rsp->portnum].port_status = (1 << PORT_HIGH_SPEED) | (1 << PORT_CONNECTION) | (1 << PORT_ENABLE);
    4.67 +        xudd->ports[conn_rsp->portnum - 1].port_status = (1 << PORT_HIGH_SPEED) | (1 << PORT_CONNECTION); // | (1 << PORT_ENABLE);
    4.68          break;
    4.69        }      
    4.70 -      xudd->ports[conn_rsp->portnum].port_change |= (1 << PORT_CONNECTION);
    4.71 +      xudd->ports[conn_rsp->portnum - 1].port_change |= (1 << PORT_CONNECTION);
    4.72        
    4.73        // notify pending interrupt urb?
    4.74        
    4.75 @@ -746,7 +747,7 @@ XenUsb_EvtChildListScanForChildren(WDFCH
    4.76    {
    4.77      xudd->ports[i].port_number = i + 1;
    4.78      xudd->ports[i].port_type = USB_PORT_TYPE_NOT_CONNECTED;
    4.79 -    xudd->ports[i].port_status = 1 << PORT_ENABLE;
    4.80 +    xudd->ports[i].port_status = 0; //1 << PORT_ENABLE;
    4.81      xudd->ports[i].port_change = 0x0000;
    4.82    }  
    4.83  
    4.84 @@ -875,13 +876,15 @@ XenUsb_EvtIoDeviceControl(
    4.85    {
    4.86      PUSB_HCD_DRIVERKEY_NAME uhdn;
    4.87      size_t length;
    4.88 -    ULONG required_length = 0;
    4.89 +    ULONG required_length = sizeof(USB_HCD_DRIVERKEY_NAME);
    4.90      
    4.91      KdPrint((__DRIVER_NAME "     IOCTL_USB_GET_ROOT_HUB_NAME\n"));
    4.92      KdPrint((__DRIVER_NAME "      output_buffer_length = %d\n", output_buffer_length));
    4.93        
    4.94      if (output_buffer_length < sizeof(USB_HCD_DRIVERKEY_NAME))
    4.95 +    {
    4.96        status = STATUS_BUFFER_TOO_SMALL;
    4.97 +    }
    4.98      else
    4.99      {
   4.100        status = WdfRequestRetrieveOutputBuffer(request, output_buffer_length, (PVOID *)&uhdn, &length);
   4.101 @@ -900,11 +903,21 @@ XenUsb_EvtIoDeviceControl(
   4.102            symbolic_link.Buffer += 4;
   4.103            symbolic_link.Length -= 4 * sizeof(WCHAR);
   4.104            required_length = FIELD_OFFSET(USB_HCD_DRIVERKEY_NAME, DriverKeyName) + symbolic_link.Length + sizeof(WCHAR);
   4.105 -          uhdn->ActualLength = required_length;
   4.106 +          FUNCTION_MSG("output_buffer_length = %d\n", output_buffer_length);
   4.107 +          FUNCTION_MSG("required_length = %d\n", required_length);
   4.108            if (output_buffer_length >= required_length)
   4.109            {
   4.110 +            uhdn->ActualLength = required_length;
   4.111              memcpy(uhdn->DriverKeyName, symbolic_link.Buffer, symbolic_link.Length);
   4.112              uhdn->DriverKeyName[symbolic_link.Length / 2] = 0;
   4.113 +            WdfRequestSetInformation(request, required_length);
   4.114 +          }
   4.115 +          else
   4.116 +          {
   4.117 +            uhdn->ActualLength = required_length;
   4.118 +            uhdn->DriverKeyName[0] = 0;
   4.119 +            status = STATUS_SUCCESS;
   4.120 +            WdfRequestSetInformation(request, output_buffer_length);
   4.121            }
   4.122          }
   4.123          else
   4.124 @@ -919,7 +932,6 @@ XenUsb_EvtIoDeviceControl(
   4.125        }
   4.126        KdPrint((__DRIVER_NAME "      uhdn->ActualLength = %d\n", uhdn->ActualLength));
   4.127        KdPrint((__DRIVER_NAME "      uhdn->DriverKeyName = %S\n", uhdn->DriverKeyName));
   4.128 -      WdfRequestSetInformation(request, required_length);
   4.129      }
   4.130      break;
   4.131    }
   4.132 @@ -927,7 +939,7 @@ XenUsb_EvtIoDeviceControl(
   4.133    {
   4.134      PUSB_HCD_DRIVERKEY_NAME uhdn;
   4.135      size_t length;
   4.136 -    ULONG required_length = 0;
   4.137 +    ULONG required_length = sizeof(USB_HCD_DRIVERKEY_NAME);
   4.138      
   4.139      KdPrint((__DRIVER_NAME "     IOCTL_GET_HCD_DRIVERKEY_NAME\n"));
   4.140      KdPrint((__DRIVER_NAME "      output_buffer_length = %d\n", output_buffer_length));
   4.141 @@ -943,26 +955,30 @@ XenUsb_EvtIoDeviceControl(
   4.142          status = WdfDeviceQueryProperty(device, DevicePropertyDriverKeyName, 0, NULL, &key_length);
   4.143          KdPrint((__DRIVER_NAME "      key_length = %d\n", key_length));
   4.144          status = STATUS_SUCCESS;
   4.145 -        required_length = FIELD_OFFSET(USB_HCD_DRIVERKEY_NAME, DriverKeyName) + key_length;
   4.146 +        required_length = FIELD_OFFSET(USB_HCD_DRIVERKEY_NAME, DriverKeyName) + key_length + 2;
   4.147          uhdn->ActualLength = required_length;
   4.148 +        FUNCTION_MSG("output_buffer_length = %d\n", output_buffer_length);
   4.149 +        FUNCTION_MSG("required_length = %d\n", required_length);
   4.150          if (output_buffer_length >= required_length)
   4.151          {
   4.152            status = WdfDeviceQueryProperty(device, DevicePropertyDriverKeyName, 
   4.153              required_length - FIELD_OFFSET(USB_HCD_DRIVERKEY_NAME, DriverKeyName), uhdn->DriverKeyName,
   4.154              &key_length);
   4.155 +          WdfRequestSetInformation(request, required_length);
   4.156          }
   4.157          else
   4.158          {
   4.159            uhdn->DriverKeyName[0] = 0;
   4.160 +          status = STATUS_SUCCESS;
   4.161 +          WdfRequestSetInformation(request, output_buffer_length);
   4.162          }
   4.163 +        FUNCTION_MSG(" uhdn->ActualLength = %d\n", uhdn->ActualLength);
   4.164 +        FUNCTION_MSG(" uhdn->DriverKeyName = %S\n", uhdn->DriverKeyName);
   4.165        }
   4.166        else
   4.167        {
   4.168          KdPrint((__DRIVER_NAME "     WdfRequestRetrieveOutputBuffer = %08x\n", status));
   4.169        }
   4.170 -      KdPrint((__DRIVER_NAME "      uhdn->ActualLength = %d\n", uhdn->ActualLength));
   4.171 -      KdPrint((__DRIVER_NAME "      uhdn->DriverKeyName = %S\n", uhdn->DriverKeyName));
   4.172 -      WdfRequestSetInformation(request, required_length);
   4.173      }
   4.174      break;
   4.175    }
   4.176 @@ -1007,11 +1023,17 @@ XenUsb_EvtIoInternalDeviceControl(
   4.177    switch(io_control_code)
   4.178    {
   4.179    case IOCTL_INTERNAL_USB_SUBMIT_URB:
   4.180 +    FUNCTION_MSG("IOCTL_INTERNAL_USB_SUBMIT_URB\n");
   4.181      urb = (PURB)wrp.Parameters.Others.Arg1;
   4.182 +    FUNCTION_MSG("urb = %p\n", urb);
   4.183      ASSERT(urb);
   4.184      usb_device = urb->UrbHeader.UsbdDeviceHandle;
   4.185 +    FUNCTION_MSG("usb_device = %p\n", usb_device);
   4.186      ASSERT(usb_device);
   4.187 -    WdfRequestForwardToIoQueue(request, usb_device->urb_queue);
   4.188 +    if (usb_device == (ULONG_PTR)0 - 1)
   4.189 +      WdfRequestComplete(request, STATUS_INVALID_PARAMETER);
   4.190 +    else
   4.191 +      WdfRequestForwardToIoQueue(request, usb_device->urb_queue);
   4.192      break;
   4.193    default:
   4.194      KdPrint((__DRIVER_NAME "     Unknown IOCTL %08x\n", io_control_code));
     5.1 --- a/xenusb/xenusb_hub.c	Tue Jun 07 22:37:56 2011 +1000
     5.2 +++ b/xenusb/xenusb_hub.c	Fri Jun 10 20:47:09 2011 +1000
     5.3 @@ -17,8 +17,6 @@ along with this program; if not, write t
     5.4  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     5.5  */
     5.6  
     5.7 -// STATUS_UNSUCCESSUFL -> STATUS_BAD_INITIAL_STACK 
     5.8 -
     5.9  #include "xenusb.h"
    5.10  #include <stdlib.h>
    5.11  #include <usbioctl.h>
    5.12 @@ -74,6 +72,10 @@ XenUsbHub_EvtDeviceWdmIrpPreprocessQUERY
    5.13      KdPrint((__DRIVER_NAME "     USB_BUS_INTERFACE_USBDI_GUID\n"));
    5.14    else if (memcmp(stack->Parameters.QueryInterface.InterfaceType, &GUID_TRANSLATOR_INTERFACE_STANDARD, sizeof(GUID)) == 0)
    5.15      KdPrint((__DRIVER_NAME "     GUID_TRANSLATOR_INTERFACE_STANDARD\n"));
    5.16 +#if (NTDDI_VERSION >= NTDDI_VISTA)
    5.17 +  else if (memcmp(stack->Parameters.QueryInterface.InterfaceType, &GUID_PNP_LOCATION_INTERFACE, sizeof(GUID)) == 0)
    5.18 +    KdPrint((__DRIVER_NAME "     GUID_PNP_LOCATION_INTERFACE\n"));
    5.19 +#endif
    5.20    else if (memcmp(stack->Parameters.QueryInterface.InterfaceType, &USB_BUS_INTERFACE_HUB_MINIDUMP_GUID, sizeof(GUID)) == 0)
    5.21      KdPrint((__DRIVER_NAME "     USB_BUS_INTERFACE_HUB_MINIDUMP_GUID\n"));
    5.22    else if (memcmp(stack->Parameters.QueryInterface.InterfaceType, &USB_BUS_INTERFACE_HUB_SS_GUID, sizeof(GUID)) == 0)
    5.23 @@ -115,7 +117,7 @@ XenUsbHub_EvtIoDefault(
    5.24  
    5.25    UNREFERENCED_PARAMETER(queue);
    5.26  
    5.27 -  status = STATUS_BAD_INITIAL_STACK;
    5.28 +  status = STATUS_UNSUCCESSFUL;
    5.29  
    5.30    WDF_REQUEST_PARAMETERS_INIT(&parameters);
    5.31    WdfRequestGetParameters(request, &parameters);
    5.32 @@ -235,7 +237,7 @@ XenUsbHub_EvtIoDeviceControl(
    5.33      KdPrint((__DRIVER_NAME "     IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX\n"));
    5.34      break;
    5.35    case IOCTL_GET_HCD_DRIVERKEY_NAME:
    5.36 -    KdPrint((__DRIVER_NAME "     IOCTL_GET_HCD_DRIVERKEY_NAME\n"));
    5.37 +    KdPrint((__DRIVER_NAME "     IOCTL_GET_HCD_DRIVERKEY_NAME (***)\n"));
    5.38      break;
    5.39    default:
    5.40      KdPrint((__DRIVER_NAME "     Unknown IOCTL %08x\n", io_control_code));
    5.41 @@ -261,14 +263,18 @@ XenUsbHub_EvtIoInternalDeviceControl(
    5.42    WDF_REQUEST_PARAMETERS wrp;
    5.43    PURB urb;
    5.44    PUSB_START_FAILDATA usfd;
    5.45 +#if (NTDDI_VERSION >= NTDDI_VISTA)
    5.46    PHUB_DEVICE_CONFIG_INFO hdci;
    5.47    PUSB_TOPOLOGY_ADDRESS uta;
    5.48 +  PUSB_HUB_NAME uhn;
    5.49 +#endif
    5.50    xenusb_device_t *usb_device;
    5.51 +  ULONG length;
    5.52  
    5.53    UNREFERENCED_PARAMETER(input_buffer_length);
    5.54    UNREFERENCED_PARAMETER(output_buffer_length);
    5.55  
    5.56 -  FUNCTION_ENTER();
    5.57 +  //FUNCTION_ENTER();
    5.58  
    5.59    status = STATUS_UNSUCCESSFUL;
    5.60  
    5.61 @@ -296,11 +302,17 @@ XenUsbHub_EvtIoInternalDeviceControl(
    5.62      (*(PULONG)wrp.Parameters.Others.Arg1)++;
    5.63      status = STATUS_SUCCESS;
    5.64      break;
    5.65 +#if (NTDDI_VERSION >= NTDDI_VISTA)
    5.66    case IOCTL_INTERNAL_USB_GET_HUB_NAME:
    5.67      KdPrint((__DRIVER_NAME "     IOCTL_INTERNAL_USB_GET_HUB_NAME\n"));
    5.68 +    status = WdfRequestRetrieveOutputBuffer(request, output_buffer_length, (PVOID *)&uhn, &length);
    5.69 +    uhn->ActualLength = sizeof(USB_HUB_NAME);
    5.70 +    uhn->HubName[0] = 0;
    5.71 +    status = STATUS_SUCCESS;
    5.72      break;
    5.73 +#endif
    5.74    case IOCTL_INTERNAL_USB_GET_PORT_STATUS:
    5.75 -    KdPrint((__DRIVER_NAME "     IOCTL_INTERNAL_USB_GET_PORT_STATUS\n"));
    5.76 +    //FUNCTION_MSG("IOCTL_INTERNAL_USB_GET_PORT_STATUS\n");
    5.77      *(PULONG)wrp.Parameters.Others.Arg1 = USBD_PORT_ENABLED | USBD_PORT_CONNECTED; /* enabled and connected */
    5.78      status = STATUS_SUCCESS;
    5.79      break;
    5.80 @@ -320,7 +332,7 @@ XenUsbHub_EvtIoInternalDeviceControl(
    5.81      KdPrint((__DRIVER_NAME "     IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION\n"));
    5.82      break;
    5.83    case IOCTL_INTERNAL_USB_SUBMIT_URB:
    5.84 -    KdPrint((__DRIVER_NAME "     IOCTL_INTERNAL_USB_SUBMIT_URB\n"));
    5.85 +    //KdPrint((__DRIVER_NAME "     IOCTL_INTERNAL_USB_SUBMIT_URB\n"));
    5.86      urb = (PURB)wrp.Parameters.Others.Arg1;
    5.87      ASSERT(urb);
    5.88      usb_device = urb->UrbHeader.UsbdDeviceHandle;
    5.89 @@ -333,6 +345,7 @@ XenUsbHub_EvtIoInternalDeviceControl(
    5.90      *(PVOID *)wrp.Parameters.Others.Arg1 = xupdd->usb_device;
    5.91      status = STATUS_SUCCESS;
    5.92      break;
    5.93 +#if (NTDDI_VERSION >= NTDDI_VISTA)
    5.94    case IOCTL_INTERNAL_USB_GET_DEVICE_HANDLE_EX: /* incomplete probably */
    5.95      FUNCTION_MSG("IOCTL_INTERNAL_USB_GET_DEVICE_HANDLE_EX (returning %p)\n", xupdd->usb_device);
    5.96      *(PVOID *)wrp.Parameters.Others.Arg1 = xupdd->usb_device;
    5.97 @@ -383,15 +396,17 @@ XenUsbHub_EvtIoInternalDeviceControl(
    5.98      FUNCTION_MSG(" DriverData[5] = %S\n", &usfd->DriverData[5]);
    5.99      status = STATUS_SUCCESS;
   5.100      break;  
   5.101 +#endif
   5.102    default:
   5.103      FUNCTION_MSG("Unknown IOCTL %08x\n", io_control_code);
   5.104      break;
   5.105    }  
   5.106  
   5.107 -  FUNCTION_MSG("Calling WdfRequestComplete with status = %08x\n", status);
   5.108 +  if (status != STATUS_SUCCESS)
   5.109 +    FUNCTION_MSG("Calling WdfRequestComplete with status = %08x\n", status);
   5.110    WdfRequestComplete(request, status);
   5.111  
   5.112 -  FUNCTION_EXIT();
   5.113 +  //FUNCTION_EXIT();
   5.114  }
   5.115  
   5.116  static NTSTATUS
   5.117 @@ -561,11 +576,11 @@ XenUsbHub_UBIH_CreateUsbDevice(
   5.118    USHORT PortNumber)
   5.119  {
   5.120    NTSTATUS status = STATUS_SUCCESS;
   5.121 +  xenusb_device_t *usb_device;
   5.122    
   5.123    UNREFERENCED_PARAMETER(BusContext);  
   5.124    UNREFERENCED_PARAMETER(HubDeviceHandle);
   5.125    UNREFERENCED_PARAMETER(PortStatus);
   5.126 -  UNREFERENCED_PARAMETER(PortNumber);
   5.127    
   5.128    FUNCTION_ENTER();
   5.129  
   5.130 @@ -576,8 +591,10 @@ XenUsbHub_UBIH_CreateUsbDevice(
   5.131    KdPrint((__DRIVER_NAME "     *HubDeviceHandle = %p\n", *HubDeviceHandle));
   5.132    KdPrint((__DRIVER_NAME "     PortStatus = %04X\n", PortStatus));
   5.133    KdPrint((__DRIVER_NAME "     PortNumber = %d\n", PortNumber));
   5.134 -  *DeviceHandle = ExAllocatePoolWithTag(NonPagedPool, sizeof(xenusb_device_t), XENUSB_POOL_TAG);
   5.135 -  
   5.136 +  usb_device = ExAllocatePoolWithTag(NonPagedPool, sizeof(xenusb_device_t), XENUSB_POOL_TAG);
   5.137 +  usb_device->port_number = PortNumber;
   5.138 +  *DeviceHandle = usb_device;  
   5.139 +
   5.140    FUNCTION_EXIT();
   5.141    return status;
   5.142  }
   5.143 @@ -618,10 +635,9 @@ XenUsbHub_UBIH_InitializeUsbDevice(
   5.144    KdPrint((__DRIVER_NAME "     usb_device = %p\n", usb_device));
   5.145    usb_device->pdo_device = BusContext;
   5.146    
   5.147 -  // get address from freelist and assign it to the device...
   5.148 +  // TODO: get address from freelist and assign it to the device...
   5.149    usb_device->address = 2;
   5.150 -  // and get this stuff properly...
   5.151 -  usb_device->port_number = 1;
   5.152 +  // TODO: get this stuff properly ...
   5.153    xupdd->usb_device->device_speed = UsbHighSpeed;
   5.154    xupdd->usb_device->device_type = Usb20Device;
   5.155  
   5.156 @@ -792,7 +808,7 @@ XenUsbHub_UBIH_InitializeUsbDevice(
   5.157    usb_device->active_config = usb_device->configs[0];
   5.158    usb_device->active_interface = usb_device->configs[0]->interfaces[0];
   5.159  
   5.160 -  WDF_IO_QUEUE_CONFIG_INIT(&queue_config, WdfIoQueueDispatchParallel);
   5.161 +  WDF_IO_QUEUE_CONFIG_INIT(&queue_config, WdfIoQueueDispatchParallel); // should this be serial?
   5.162    queue_config.EvtIoInternalDeviceControl = XenUsb_EvtIoInternalDeviceControl_DEVICE_SUBMIT_URB;
   5.163    queue_config.PowerManaged = TRUE; /* power managed queue for SUBMIT_URB */
   5.164    status = WdfIoQueueCreate(xupdd->wdf_device_bus_fdo, &queue_config, WDF_NO_OBJECT_ATTRIBUTES, &usb_device->urb_queue);
   5.165 @@ -841,6 +857,7 @@ XenUsbHub_UBIH_GetUsbDescriptors(
   5.166    KdPrint((__DRIVER_NAME "     memcpy(%p, %p, %d)\n", ptr, &usb_config->config_descriptor, sizeof(USB_CONFIGURATION_DESCRIPTOR)));
   5.167    memcpy(ptr, &usb_config->config_descriptor, sizeof(USB_CONFIGURATION_DESCRIPTOR));
   5.168    ptr += sizeof(USB_CONFIGURATION_DESCRIPTOR);
   5.169 +  ((PUSB_CONFIGURATION_DESCRIPTOR)ConfigDescriptorBuffer)->wTotalLength += 1;
   5.170  #if 0
   5.171    for (i = 0; i < usb_config->config_descriptor.bNumInterfaces; i++)
   5.172    {
   5.173 @@ -890,7 +907,7 @@ XenUsbHub_UBIH_RestoreUsbDevice(
   5.174    PUSB_DEVICE_HANDLE OldDeviceHandle,
   5.175    PUSB_DEVICE_HANDLE NewDeviceHandle)
   5.176  {
   5.177 -  NTSTATUS status = STATUS_BAD_INITIAL_STACK;
   5.178 +  NTSTATUS status = STATUS_UNSUCCESSFUL;
   5.179  
   5.180    UNREFERENCED_PARAMETER(BusContext);
   5.181    UNREFERENCED_PARAMETER(OldDeviceHandle);
   5.182 @@ -907,7 +924,7 @@ XenUsbHub_UBIH_GetPortHackFlags(
   5.183   PVOID BusContext,
   5.184   PULONG HackFlags)
   5.185  {
   5.186 -  NTSTATUS status = STATUS_BAD_INITIAL_STACK;
   5.187 +  NTSTATUS status = STATUS_UNSUCCESSFUL;
   5.188  
   5.189    UNREFERENCED_PARAMETER(BusContext);
   5.190    UNREFERENCED_PARAMETER(HackFlags);
   5.191 @@ -980,7 +997,7 @@ XenUsbHub_UBIH_GetControllerInformation 
   5.192    ULONG ControllerInformationBufferLength,
   5.193    PULONG LengthOfDataReturned)
   5.194  {
   5.195 -  NTSTATUS status = STATUS_BAD_INITIAL_STACK;
   5.196 +  NTSTATUS status = STATUS_UNSUCCESSFUL;
   5.197    PUSB_CONTROLLER_INFORMATION_0 uci = ControllerInformationBuffer;
   5.198    //WDFDEVICE device = BusContext;
   5.199    //xenusb_device_t *usb_device = DeviceHandle;
   5.200 @@ -1020,7 +1037,7 @@ XenUsbHub_UBIH_ControllerSelectiveSuspen
   5.201    PVOID BusContext,
   5.202    BOOLEAN Enable)
   5.203  {
   5.204 -  NTSTATUS status = STATUS_BAD_INITIAL_STACK;
   5.205 +  NTSTATUS status = STATUS_UNSUCCESSFUL;
   5.206  
   5.207    UNREFERENCED_PARAMETER(BusContext);
   5.208    UNREFERENCED_PARAMETER(Enable);
   5.209 @@ -1058,13 +1075,15 @@ XenUsbHub_UBIH_GetExtendedHubInformation
   5.210      FUNCTION_EXIT();
   5.211      return STATUS_BUFFER_TOO_SMALL;
   5.212    }
   5.213 +#if 0
   5.214    if (hib->InformationLevel != 0)
   5.215    {
   5.216      KdPrint((__DRIVER_NAME "     STATUS_NOT_SUPPORTED\n"));
   5.217      FUNCTION_EXIT();
   5.218      return STATUS_NOT_SUPPORTED;
   5.219    }
   5.220 -  //hib->InformationLevel = 0;
   5.221 +#endif
   5.222 +  hib->InformationLevel = 0;
   5.223    hib->NumberOfPorts = 8;
   5.224    for (i = 0; i < hib->NumberOfPorts; i++)
   5.225    {
   5.226 @@ -1326,7 +1345,7 @@ XenUsbHub_UBIH_GetDevicePerformanceInfo(
   5.227    UNREFERENCED_PARAMETER(BusContext);
   5.228    FUNCTION_ENTER();
   5.229    FUNCTION_EXIT();
   5.230 -  return STATUS_BAD_INITIAL_STACK;
   5.231 +  return STATUS_UNSUCCESSFUL;
   5.232  }
   5.233  
   5.234  static NTSTATUS
   5.235 @@ -1336,7 +1355,7 @@ XenUsbHub_UBIH_WaitAsyncPowerUp(
   5.236    UNREFERENCED_PARAMETER(BusContext);
   5.237    FUNCTION_ENTER();
   5.238    FUNCTION_EXIT();
   5.239 -  return STATUS_BAD_INITIAL_STACK;
   5.240 +  return STATUS_UNSUCCESSFUL;
   5.241  }
   5.242  
   5.243  static NTSTATUS
   5.244 @@ -1348,7 +1367,7 @@ XenUsbHub_UBIH_GetDeviceAddress(
   5.245    UNREFERENCED_PARAMETER(BusContext);
   5.246    FUNCTION_ENTER();
   5.247    FUNCTION_EXIT();
   5.248 -  return STATUS_BAD_INITIAL_STACK;
   5.249 +  return STATUS_UNSUCCESSFUL;
   5.250  }
   5.251  
   5.252  static NTSTATUS
   5.253 @@ -1361,7 +1380,7 @@ XenUsbHub_UBIH_RefDeviceHandle(
   5.254    UNREFERENCED_PARAMETER(BusContext);
   5.255    FUNCTION_ENTER();
   5.256    FUNCTION_EXIT();
   5.257 -  return STATUS_BAD_INITIAL_STACK;
   5.258 +  return STATUS_UNSUCCESSFUL;
   5.259  }
   5.260  
   5.261  static NTSTATUS
   5.262 @@ -1405,7 +1424,7 @@ XenUsbHub_UBIH_CreateUsbDeviceV7(
   5.263    UNREFERENCED_PARAMETER(BusContext);
   5.264    FUNCTION_ENTER();
   5.265    FUNCTION_EXIT();
   5.266 -  return STATUS_BAD_INITIAL_STACK;
   5.267 +  return STATUS_UNSUCCESSFUL;
   5.268  }
   5.269  
   5.270  static NTSTATUS
   5.271 @@ -1417,7 +1436,7 @@ XenUsbHub_UBIH_GetContainerIdForPort(
   5.272    UNREFERENCED_PARAMETER(BusContext);
   5.273    FUNCTION_ENTER();
   5.274    FUNCTION_EXIT();
   5.275 -  return STATUS_BAD_INITIAL_STACK;
   5.276 +  return STATUS_UNSUCCESSFUL;
   5.277  }
   5.278  
   5.279  static NTSTATUS
   5.280 @@ -1429,7 +1448,7 @@ XenUsbHub_UBIH_SetContainerIdForPort(
   5.281    UNREFERENCED_PARAMETER(BusContext);
   5.282    FUNCTION_ENTER();
   5.283    FUNCTION_EXIT();
   5.284 -  return STATUS_BAD_INITIAL_STACK;
   5.285 +  return STATUS_UNSUCCESSFUL;
   5.286  }
   5.287  
   5.288  static NTSTATUS
   5.289 @@ -1440,7 +1459,7 @@ XenUsbHub_UBIH_AbortAllDevicePipes(
   5.290    UNREFERENCED_PARAMETER(BusContext);
   5.291    FUNCTION_ENTER();
   5.292    FUNCTION_EXIT();
   5.293 -  return STATUS_BAD_INITIAL_STACK;
   5.294 +  return STATUS_UNSUCCESSFUL;
   5.295  }
   5.296  
   5.297  static VOID
   5.298 @@ -1462,7 +1481,7 @@ XenUsbHub_UBIU_GetUSBDIVersion(
   5.299    PULONG HcdCapabilities
   5.300    )
   5.301  {
   5.302 -  NTSTATUS status = STATUS_BAD_INITIAL_STACK;
   5.303 +  NTSTATUS status = STATUS_UNSUCCESSFUL;
   5.304  
   5.305    UNREFERENCED_PARAMETER(BusContext);
   5.306    UNREFERENCED_PARAMETER(VersionInformation);
   5.307 @@ -1480,13 +1499,14 @@ XenUsbHub_UBIU_QueryBusTime(
   5.308    PULONG CurrentFrame
   5.309    )
   5.310  {
   5.311 -  NTSTATUS status = STATUS_BAD_INITIAL_STACK;
   5.312 -
   5.313 +  NTSTATUS status = STATUS_SUCCESS;
   5.314 +  static ULONG frame_no = 0;
   5.315 +  
   5.316    UNREFERENCED_PARAMETER(BusContext);
   5.317    UNREFERENCED_PARAMETER(CurrentFrame);
   5.318    
   5.319    FUNCTION_ENTER();
   5.320 -
   5.321 +  *CurrentFrame = frame_no++;
   5.322    FUNCTION_EXIT();
   5.323    return status;
   5.324  }
   5.325 @@ -1497,7 +1517,7 @@ XenUsbHub_UBIU_SubmitIsoOutUrb(
   5.326    PURB Urb
   5.327    )
   5.328  {
   5.329 -  NTSTATUS status = STATUS_BAD_INITIAL_STACK;
   5.330 +  NTSTATUS status = STATUS_UNSUCCESSFUL;
   5.331  
   5.332    UNREFERENCED_PARAMETER(BusContext);
   5.333    UNREFERENCED_PARAMETER(Urb);
   5.334 @@ -1516,7 +1536,7 @@ XenUsbHub_UBIU_QueryBusInformation(
   5.335    PULONG BusInformationBufferLength,
   5.336    PULONG BusInformationActualLength)
   5.337  {
   5.338 -  NTSTATUS status = STATUS_BAD_INITIAL_STACK;
   5.339 +  NTSTATUS status = STATUS_UNSUCCESSFUL;
   5.340  
   5.341    UNREFERENCED_PARAMETER(BusContext);
   5.342    UNREFERENCED_PARAMETER(Level);
   5.343 @@ -1577,7 +1597,7 @@ XenUsbHub_UBIU_QueryBusTimeEx(
   5.344    UNREFERENCED_PARAMETER(HighSpeedFrameCounter);
   5.345    FUNCTION_ENTER();
   5.346    FUNCTION_EXIT();
   5.347 -  return STATUS_BAD_INITIAL_STACK;
   5.348 +  return STATUS_UNSUCCESSFUL;
   5.349  }
   5.350  
   5.351  static NTSTATUS
   5.352 @@ -1594,7 +1614,7 @@ XenUsbHub_UBIU_QueryControllerType(
   5.353    UNREFERENCED_PARAMETER(BusContext);
   5.354    FUNCTION_ENTER();
   5.355    FUNCTION_EXIT();
   5.356 -  return STATUS_BAD_INITIAL_STACK;
   5.357 +  return STATUS_UNSUCCESSFUL;
   5.358  }
   5.359  
   5.360  static NTSTATUS
   5.361 @@ -1604,7 +1624,7 @@ XenUsbHub_UBIHSS_SuspendHub(
   5.362    UNREFERENCED_PARAMETER(BusContext);
   5.363    FUNCTION_ENTER();
   5.364    FUNCTION_EXIT();
   5.365 -  return STATUS_BAD_INITIAL_STACK;
   5.366 +  return STATUS_UNSUCCESSFUL;
   5.367  }
   5.368  
   5.369  static NTSTATUS
   5.370 @@ -1614,60 +1634,9 @@ XenUsbHub_UBIHSS_ResumeHub(
   5.371    UNREFERENCED_PARAMETER(BusContext);
   5.372    FUNCTION_ENTER();
   5.373    FUNCTION_EXIT();
   5.374 -  return STATUS_BAD_INITIAL_STACK;
   5.375 +  return STATUS_UNSUCCESSFUL;
   5.376  }
   5.377  
   5.378 -#if 0
   5.379 -VOID
   5.380 -XenUsb_EnumeratePorts(WDFDEVICE device)
   5.381 -{
   5.382 -  PXENUSB_PDO_DEVICE_DATA xupdd = GetXupdd(device);
   5.383 -  PXENUSB_DEVICE_DATA xudd = GetXudd(xupdd->wdf_device_bus_fdo);
   5.384 -  CHAR path[128];
   5.385 -  PCHAR err;
   5.386 -  PCHAR value;
   5.387 -  ULONG i;
   5.388 -  
   5.389 -  for (i = 0; i < xudd->num_ports; i++)
   5.390 -  {
   5.391 -    ULONG port_value;
   5.392 -    RtlStringCbPrintfA(path, ARRAY_SIZE(path), "%s/port-%d", xudd->vectors.backend_path, i + 1);
   5.393 -    err = xudd->vectors.XenBus_Read(xudd->vectors.context, XBT_NIL, path, &value);
   5.394 -    if (err)
   5.395 -    {
   5.396 -      XenPci_FreeMem(err);
   5.397 -      KdPrint((__DRIVER_NAME "     Failed to read port-%d\n", i + 1));
   5.398 -      continue;
   5.399 -    }
   5.400 -    // 0=disconnected, 1=low_speed, 2=full_speed, 3= high_speed
   5.401 -    port_value = (ULONG)parse_numeric_string(value);
   5.402 -    XenPci_FreeMem(value);
   5.403 -    KdPrint((__DRIVER_NAME "     port-%d : %d -> %d\n", i, xudd->ports[i].port_type, port_value));
   5.404 -    if (port_value != xudd->ports[i].port_type)
   5.405 -    {
   5.406 -      xudd->ports[i].port_type = port_value;
   5.407 -      // need to do more than this - probably flush everything and ensure no more activity to the new port until it is set up...
   5.408 -      switch (port_value)
   5.409 -      {
   5.410 -      case USB_PORT_TYPE_NOT_CONNECTED:
   5.411 -        xudd->ports[i].port_status = (1 << PORT_ENABLE);
   5.412 -        break;
   5.413 -      case USB_PORT_TYPE_LOW_SPEED:
   5.414 -        xudd->ports[i].port_status = (1 << PORT_LOW_SPEED) | (1 << PORT_CONNECTION) | (1 << PORT_ENABLE);
   5.415 -        break;
   5.416 -      case USB_PORT_TYPE_FULL_SPEED:
   5.417 -        xudd->ports[i].port_status = (1 << PORT_CONNECTION) | (1 << PORT_ENABLE);
   5.418 -        break;
   5.419 -      case USB_PORT_TYPE_HIGH_SPEED:
   5.420 -        xudd->ports[i].port_status = (1 << PORT_HIGH_SPEED) | (1 << PORT_CONNECTION) | (1 << PORT_ENABLE);
   5.421 -        break;
   5.422 -      }      
   5.423 -      xudd->ports[i].port_change |= (1 << PORT_CONNECTION);
   5.424 -    }
   5.425 -  }  
   5.426 -}
   5.427 -#endif
   5.428 -
   5.429  static VOID
   5.430  XenUsbHub_HubInterruptTimer(WDFTIMER timer)
   5.431  {
   5.432 @@ -1681,14 +1650,14 @@ XenUsbHub_HubInterruptTimer(WDFTIMER tim
   5.433    PURB urb;
   5.434    ULONG i;
   5.435    
   5.436 -  FUNCTION_ENTER();
   5.437 +  //FUNCTION_ENTER();
   5.438    WdfSpinLockAcquire(endpoint->interrupt_lock);
   5.439    status = WdfIoQueueRetrieveNextRequest(endpoint->interrupt_queue, &request);
   5.440    if (status == STATUS_NO_MORE_ENTRIES)
   5.441    {
   5.442      WdfTimerStop(timer, FALSE);
   5.443      WdfSpinLockRelease(endpoint->interrupt_lock);
   5.444 -    KdPrint((__DRIVER_NAME "      No More Entries\n", status));
   5.445 +    //KdPrint((__DRIVER_NAME "      No More Entries\n", status));
   5.446      //FUNCTION_EXIT();
   5.447      return;
   5.448    }
   5.449 @@ -1710,18 +1679,34 @@ XenUsbHub_HubInterruptTimer(WDFTIMER tim
   5.450    RtlZeroMemory(urb->UrbBulkOrInterruptTransfer.TransferBuffer, urb->UrbBulkOrInterruptTransfer.TransferBufferLength);
   5.451    if (urb->UrbBulkOrInterruptTransfer.TransferFlags & (USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK))
   5.452    {
   5.453 -    //urb->UrbBulkOrInterruptTransfer.TransferBufferLength = 0;
   5.454 +    BOOLEAN port_change_flag = FALSE;
   5.455      // check for hub change too
   5.456      //((PUCHAR)urb->UrbBulkOrInterruptTransfer.TransferBuffer)[0] |= 1;
   5.457 +    urb->UrbBulkOrInterruptTransfer.TransferBufferLength = 0;
   5.458      for (i = 0; i < xudd->num_ports; i++)
   5.459      {
   5.460 +#if 0
   5.461 +      if (xudd->ports[i].port_status & (1 << PORT_RESET))
   5.462 +      {
   5.463 +        if (xudd->ports[i].reset_counter-- == 0)
   5.464 +        {
   5.465 +          xudd->ports[i].port_status &= ~(1 << PORT_RESET);
   5.466 +          xudd->ports[i].port_status |= (1 << PORT_ENABLE);
   5.467 +          xudd->ports[i].port_change |= (1 << PORT_RESET);
   5.468 +        }
   5.469 +        FUNCTION_MSG("reset counter = %d\n", xudd->ports[i].reset_counter);
   5.470 +      }
   5.471 +#endif
   5.472        if (xudd->ports[i].port_change)
   5.473        {
   5.474 -        KdPrint((__DRIVER_NAME "      Port change on port %d - status = %04x, change = %04x\n",
   5.475 -          xudd->ports[i].port_number, xudd->ports[i].port_status, xudd->ports[i].port_change));
   5.476 +        FUNCTION_MSG("Port change on port %d - status = %04x, change = %04x\n",
   5.477 +          xudd->ports[i].port_number, xudd->ports[i].port_status, xudd->ports[i].port_change);
   5.478          ((PUCHAR)urb->UrbBulkOrInterruptTransfer.TransferBuffer)[xudd->ports[i].port_number >> 3] |= 1 << (xudd->ports[i].port_number & 7);
   5.479 +        port_change_flag = TRUE;
   5.480        }
   5.481      }
   5.482 +    if (port_change_flag)
   5.483 +      urb->UrbBulkOrInterruptTransfer.TransferBufferLength = 2;
   5.484      urb->UrbHeader.Status = USBD_STATUS_SUCCESS;
   5.485      WdfSpinLockRelease(endpoint->interrupt_lock);
   5.486      WdfRequestComplete(request, STATUS_SUCCESS);
   5.487 @@ -1731,9 +1716,9 @@ XenUsbHub_HubInterruptTimer(WDFTIMER tim
   5.488      KdPrint((__DRIVER_NAME "      Direction mismatch\n"));
   5.489      urb->UrbHeader.Status = USBD_STATUS_INVALID_PARAMETER;
   5.490      WdfSpinLockRelease(endpoint->interrupt_lock);
   5.491 -    WdfRequestComplete(request, STATUS_BAD_INITIAL_STACK);
   5.492 +    WdfRequestComplete(request, STATUS_UNSUCCESSFUL);
   5.493    }
   5.494 -  FUNCTION_EXIT();
   5.495 +  //FUNCTION_EXIT();
   5.496    return;
   5.497  }
   5.498  
   5.499 @@ -1758,11 +1743,16 @@ XenUsb_EvtChildListCreateDevice(WDFCHILD
   5.500    WDF_QUERY_INTERFACE_CONFIG interface_config;
   5.501    union {
   5.502      USB_BUS_INTERFACE_HUB_V5 ubih5; /* support version 5 */
   5.503 +#if (NTDDI_VERSION >= NTDDI_VISTA)
   5.504      USB_BUS_INTERFACE_HUB_V7 ubih7; /* support versions 6,  and 7 - base definition changed */
   5.505 +#endif
   5.506    } ubih;
   5.507    union {
   5.508 +    USB_BUS_INTERFACE_USBDI_V1 ubiu1;
   5.509      USB_BUS_INTERFACE_USBDI_V2 ubiu2;
   5.510 +#if (NTDDI_VERSION >= NTDDI_VISTA)
   5.511      USB_BUS_INTERFACE_USBDI_V3 ubiu3;
   5.512 +#endif
   5.513    } ubiu;
   5.514    USB_BUS_INTERFACE_HUB_SELECTIVE_SUSPEND ubihss;
   5.515    WDF_TIMER_CONFIG timer_config;
   5.516 @@ -1949,35 +1939,32 @@ XenUsb_EvtChildListCreateDevice(WDFCHILD
   5.517    child_power_capabilities.DeviceState[PowerSystemShutdown]  = PowerDeviceD3;
   5.518    WdfDeviceSetPowerCapabilities(child_device, &child_power_capabilities);  
   5.519  
   5.520 -  ubih.ubih7.Size = sizeof(USB_BUS_INTERFACE_HUB_V7);
   5.521 -  ubih.ubih7.Version = USB_BUSIF_HUB_VERSION_7;
   5.522 -  ubih.ubih7.BusContext = child_device;
   5.523 -  ubih.ubih7.InterfaceReference = WdfDeviceInterfaceReferenceNoOp;
   5.524 -  ubih.ubih7.InterfaceDereference = WdfDeviceInterfaceDereferenceNoOp;
   5.525 -  ubih.ubih7.CreateUsbDevice = XenUsbHub_UBIH_CreateUsbDeviceEx;
   5.526 -  ubih.ubih7.InitializeUsbDevice = XenUsbHub_UBIH_InitializeUsbDeviceEx;
   5.527 -  ubih.ubih7.GetUsbDescriptors = XenUsbHub_UBIH_GetUsbDescriptors;
   5.528 -  ubih.ubih7.RemoveUsbDevice = XenUsbHub_UBIH_RemoveUsbDevice;
   5.529 -  ubih.ubih7.RestoreUsbDevice = XenUsbHub_UBIH_RestoreUsbDevice;
   5.530 -  ubih.ubih7.GetPortHackFlags = XenUsbHub_UBIH_GetPortHackFlags;
   5.531 -  ubih.ubih7.QueryDeviceInformation = XenUsbHub_UBIH_QueryDeviceInformation;
   5.532 -  ubih.ubih7.GetControllerInformation = XenUsbHub_UBIH_GetControllerInformation;
   5.533 -  ubih.ubih7.ControllerSelectiveSuspend = XenUsbHub_UBIH_ControllerSelectiveSuspend;
   5.534 -  ubih.ubih7.GetExtendedHubInformation = XenUsbHub_UBIH_GetExtendedHubInformation;
   5.535 -  ubih.ubih7.GetRootHubSymbolicName = XenUsbHub_UBIH_GetRootHubSymbolicName;
   5.536 -  ubih.ubih7.GetDeviceBusContext = XenUsbHub_UBIH_GetDeviceBusContext;
   5.537 -  ubih.ubih7.Initialize20Hub = XenUsbHub_UBIH_Initialize20Hub;
   5.538 -  ubih.ubih7.RootHubInitNotification = XenUsbHub_UBIH_RootHubInitNotification;
   5.539 -  ubih.ubih7.FlushTransfers = XenUsbHub_UBIH_FlushTransfers;
   5.540 -  ubih.ubih7.SetDeviceHandleData = XenUsbHub_UBIH_SetDeviceHandleData;
   5.541 -  ubih.ubih7.CreateUsbDevice = XenUsbHub_UBIH_CreateUsbDeviceEx;
   5.542 -  ubih.ubih7.InitializeUsbDevice = XenUsbHub_UBIH_InitializeUsbDeviceEx;
   5.543 -  ubih.ubih7.HubIsRoot = XenUsbHub_UBIH_HubIsRoot;
   5.544 -  ubih.ubih7.AcquireBusSemaphore = XenUsbHub_UBIH_AcquireBusSemaphore;
   5.545 -  ubih.ubih7.ReleaseBusSemaphore = XenUsbHub_UBIH_ReleaseBusSemaphore;
   5.546 -  ubih.ubih7.CaculatePipeBandwidth = XenUsbHub_UBIH_CaculatePipeBandwidth;
   5.547 -  ubih.ubih7.SetBusSystemWakeMode = XenUsbHub_UBIH_SetBusSystemWakeMode;
   5.548 -  ubih.ubih7.SetDeviceFlag = XenUsbHub_UBIH_SetDeviceFlag;
   5.549 +  ubih.ubih5.BusContext = child_device;
   5.550 +  ubih.ubih5.InterfaceReference = WdfDeviceInterfaceReferenceNoOp;
   5.551 +  ubih.ubih5.InterfaceDereference = WdfDeviceInterfaceDereferenceNoOp;
   5.552 +  ubih.ubih5.GetUsbDescriptors = XenUsbHub_UBIH_GetUsbDescriptors;
   5.553 +  ubih.ubih5.RemoveUsbDevice = XenUsbHub_UBIH_RemoveUsbDevice;
   5.554 +  ubih.ubih5.RestoreUsbDevice = XenUsbHub_UBIH_RestoreUsbDevice;
   5.555 +  ubih.ubih5.GetPortHackFlags = XenUsbHub_UBIH_GetPortHackFlags;
   5.556 +  ubih.ubih5.QueryDeviceInformation = XenUsbHub_UBIH_QueryDeviceInformation;
   5.557 +  ubih.ubih5.GetControllerInformation = XenUsbHub_UBIH_GetControllerInformation;
   5.558 +  ubih.ubih5.ControllerSelectiveSuspend = XenUsbHub_UBIH_ControllerSelectiveSuspend;
   5.559 +  ubih.ubih5.GetExtendedHubInformation = XenUsbHub_UBIH_GetExtendedHubInformation;
   5.560 +  ubih.ubih5.GetRootHubSymbolicName = XenUsbHub_UBIH_GetRootHubSymbolicName;
   5.561 +  ubih.ubih5.GetDeviceBusContext = XenUsbHub_UBIH_GetDeviceBusContext;
   5.562 +  ubih.ubih5.Initialize20Hub = XenUsbHub_UBIH_Initialize20Hub;
   5.563 +  ubih.ubih5.RootHubInitNotification = XenUsbHub_UBIH_RootHubInitNotification;
   5.564 +  ubih.ubih5.FlushTransfers = XenUsbHub_UBIH_FlushTransfers;
   5.565 +  ubih.ubih5.SetDeviceHandleData = XenUsbHub_UBIH_SetDeviceHandleData;
   5.566 +#if (NTDDI_VERSION >= NTDDI_VISTA)  
   5.567 +  ubih.ubih6.CreateUsbDevice = XenUsbHub_UBIH_CreateUsbDeviceEx;
   5.568 +  ubih.ubih6.InitializeUsbDevice = XenUsbHub_UBIH_InitializeUsbDeviceEx;
   5.569 +  ubih.ubih6.HubIsRoot = XenUsbHub_UBIH_HubIsRoot;
   5.570 +  ubih.ubih6.AcquireBusSemaphore = XenUsbHub_UBIH_AcquireBusSemaphore;
   5.571 +  ubih.ubih6.ReleaseBusSemaphore = XenUsbHub_UBIH_ReleaseBusSemaphore;
   5.572 +  ubih.ubih6.CaculatePipeBandwidth = XenUsbHub_UBIH_CaculatePipeBandwidth;
   5.573 +  ubih.ubih6.SetBusSystemWakeMode = XenUsbHub_UBIH_SetBusSystemWakeMode;
   5.574 +  ubih.ubih6.SetDeviceFlag = XenUsbHub_UBIH_SetDeviceFlag;
   5.575    ubih.ubih7.HubTestPoint = XenUsbHub_UBIH_HubTestPoint;
   5.576    ubih.ubih7.GetDevicePerformanceInfo = XenUsbHub_UBIH_GetDevicePerformanceInfo;
   5.577    ubih.ubih7.WaitAsyncPowerUp = XenUsbHub_UBIH_WaitAsyncPowerUp;
   5.578 @@ -2003,44 +1990,49 @@ XenUsb_EvtChildListCreateDevice(WDFCHILD
   5.579    ubih.ubih7.SetContainerIdForPort = XenUsbHub_UBIH_SetContainerIdForPort;
   5.580    ubih.ubih7.AbortAllDevicePipes = XenUsbHub_UBIH_AbortAllDevicePipes;
   5.581    ubih.ubih7.SetDeviceErrataFlag = XenUsbHub_UBIH_SetDeviceErrataFlag;  
   5.582 -  WDF_QUERY_INTERFACE_CONFIG_INIT(&interface_config, (PINTERFACE)&ubih, &USB_BUS_INTERFACE_HUB_GUID, NULL);
   5.583 -  status = WdfDeviceAddQueryInterface(child_device, &interface_config);
   5.584 -  if (!NT_SUCCESS(status))
   5.585 -    return status;
   5.586 -
   5.587 -  ubih.ubih7.Size = sizeof(USB_BUS_INTERFACE_HUB_V6);
   5.588 -  ubih.ubih7.Version = USB_BUSIF_HUB_VERSION_6;
   5.589 +  ubih.ubih7.Size = sizeof(USB_BUS_INTERFACE_HUB_V7);
   5.590 +  ubih.ubih7.Version = USB_BUSIF_HUB_VERSION_7;
   5.591    WDF_QUERY_INTERFACE_CONFIG_INIT(&interface_config, (PINTERFACE)&ubih, &USB_BUS_INTERFACE_HUB_GUID, NULL);
   5.592    status = WdfDeviceAddQueryInterface(child_device, &interface_config);
   5.593    if (!NT_SUCCESS(status))
   5.594      return status;
   5.595  
   5.596 +  ubih.ubih6.Size = sizeof(USB_BUS_INTERFACE_HUB_V6);
   5.597 +  ubih.ubih6.Version = USB_BUSIF_HUB_VERSION_6;
   5.598 +  WDF_QUERY_INTERFACE_CONFIG_INIT(&interface_config, (PINTERFACE)&ubih, &USB_BUS_INTERFACE_HUB_GUID, NULL);
   5.599 +  status = WdfDeviceAddQueryInterface(child_device, &interface_config);
   5.600 +  if (!NT_SUCCESS(status))
   5.601 +    return status;
   5.602 +#endif
   5.603 +
   5.604 +  ubih.ubih5.CreateUsbDevice = XenUsbHub_UBIH_CreateUsbDevice;
   5.605 +  ubih.ubih5.InitializeUsbDevice = XenUsbHub_UBIH_InitializeUsbDevice;
   5.606    ubih.ubih5.Size = sizeof(USB_BUS_INTERFACE_HUB_V5);
   5.607    ubih.ubih5.Version = USB_BUSIF_HUB_VERSION_5;
   5.608 -  ubih.ubih5.CreateUsbDevice = XenUsbHub_UBIH_CreateUsbDevice;
   5.609 -  ubih.ubih5.InitializeUsbDevice = XenUsbHub_UBIH_InitializeUsbDevice;
   5.610    WDF_QUERY_INTERFACE_CONFIG_INIT(&interface_config, (PINTERFACE)&ubih, &USB_BUS_INTERFACE_HUB_GUID, NULL);
   5.611    status = WdfDeviceAddQueryInterface(child_device, &interface_config);
   5.612    if (!NT_SUCCESS(status))
   5.613      return status;
   5.614  
   5.615 +  ubiu.ubiu1.BusContext = child_device;
   5.616 +  ubiu.ubiu1.InterfaceReference = WdfDeviceInterfaceReferenceNoOp;
   5.617 +  ubiu.ubiu1.InterfaceDereference = WdfDeviceInterfaceDereferenceNoOp;
   5.618 +  ubiu.ubiu1.GetUSBDIVersion = XenUsbHub_UBIU_GetUSBDIVersion;
   5.619 +  ubiu.ubiu1.QueryBusTime = XenUsbHub_UBIU_QueryBusTime;
   5.620 +  ubiu.ubiu1.SubmitIsoOutUrb = XenUsbHub_UBIU_SubmitIsoOutUrb;
   5.621 +  ubiu.ubiu1.QueryBusInformation = XenUsbHub_UBIU_QueryBusInformation;
   5.622 +  ubiu.ubiu1.IsDeviceHighSpeed = XenUsbHub_UBIU_IsDeviceHighSpeed;
   5.623 +  ubiu.ubiu2.EnumLogEntry  = XenUsbHub_UBIU_EnumLogEntry;
   5.624 +#if (NTDDI_VERSION >= NTDDI_VISTA)  
   5.625 +  ubiu.ubiu3.QueryBusTimeEx = XenUsbHub_UBIU_QueryBusTimeEx;
   5.626 +  ubiu.ubiu3.QueryControllerType = XenUsbHub_UBIU_QueryControllerType;
   5.627    ubiu.ubiu3.Size = sizeof(USB_BUS_INTERFACE_USBDI_V3);
   5.628    ubiu.ubiu3.Version = USB_BUSIF_HUB_VERSION_3;
   5.629 -  ubiu.ubiu2.BusContext = child_device;
   5.630 -  ubiu.ubiu2.InterfaceReference = WdfDeviceInterfaceReferenceNoOp;
   5.631 -  ubiu.ubiu2.InterfaceDereference = WdfDeviceInterfaceDereferenceNoOp;
   5.632 -  ubiu.ubiu2.GetUSBDIVersion = XenUsbHub_UBIU_GetUSBDIVersion;
   5.633 -  ubiu.ubiu2.QueryBusTime = XenUsbHub_UBIU_QueryBusTime;
   5.634 -  ubiu.ubiu2.SubmitIsoOutUrb = XenUsbHub_UBIU_SubmitIsoOutUrb;
   5.635 -  ubiu.ubiu2.QueryBusInformation = XenUsbHub_UBIU_QueryBusInformation;
   5.636 -  ubiu.ubiu2.IsDeviceHighSpeed = XenUsbHub_UBIU_IsDeviceHighSpeed;
   5.637 -  ubiu.ubiu2.EnumLogEntry  = XenUsbHub_UBIU_EnumLogEntry;
   5.638 -  ubiu.ubiu3.QueryBusTimeEx = XenUsbHub_UBIU_QueryBusTimeEx;
   5.639 -  ubiu.ubiu3.QueryControllerType = XenUsbHub_UBIU_QueryControllerType;
   5.640    WDF_QUERY_INTERFACE_CONFIG_INIT(&interface_config, (PINTERFACE)&ubiu, &USB_BUS_INTERFACE_USBDI_GUID, NULL);
   5.641    status = WdfDeviceAddQueryInterface(child_device, &interface_config);
   5.642    if (!NT_SUCCESS(status))
   5.643      return status;
   5.644 +#endif
   5.645  
   5.646    ubiu.ubiu2.Size = sizeof(USB_BUS_INTERFACE_USBDI_V2);
   5.647    ubiu.ubiu2.Version = USB_BUSIF_HUB_VERSION_2;
   5.648 @@ -2049,6 +2041,13 @@ XenUsb_EvtChildListCreateDevice(WDFCHILD
   5.649    if (!NT_SUCCESS(status))
   5.650    return status;
   5.651  
   5.652 +  ubiu.ubiu1.Size = sizeof(USB_BUS_INTERFACE_USBDI_V1);
   5.653 +  ubiu.ubiu1.Version = USB_BUSIF_HUB_VERSION_1;
   5.654 +  WDF_QUERY_INTERFACE_CONFIG_INIT(&interface_config, (PINTERFACE)&ubiu, &USB_BUS_INTERFACE_USBDI_GUID, NULL);
   5.655 +  status = WdfDeviceAddQueryInterface(child_device, &interface_config);
   5.656 +  if (!NT_SUCCESS(status))
   5.657 +    return status;
   5.658 +
   5.659    ubihss.BusContext = child_device;
   5.660    ubihss.Size = sizeof(USB_BUS_INTERFACE_HUB_SELECTIVE_SUSPEND);
   5.661    ubihss.Version = USB_BUSIF_HUB_SS_VERSION_0;
     6.1 --- a/xenusb/xenusb_huburb.c	Tue Jun 07 22:37:56 2011 +1000
     6.2 +++ b/xenusb/xenusb_huburb.c	Fri Jun 10 20:47:09 2011 +1000
     6.3 @@ -45,16 +45,14 @@ XenUsb_EvtIoInternalDeviceControl_ROOTHU
     6.4    UNREFERENCED_PARAMETER(output_buffer_length);
     6.5    UNREFERENCED_PARAMETER(io_control_code);
     6.6  
     6.7 -  FUNCTION_ENTER();
     6.8 -
     6.9 -  ASSERT(io_control_code == IOCTL_INTERNAL_USB_SUBMIT_URB);
    6.10 +  //FUNCTION_ENTER();
    6.11  
    6.12    WDF_REQUEST_PARAMETERS_INIT(&wrp);
    6.13    WdfRequestGetParameters(request, &wrp);
    6.14  
    6.15    urb = (PURB)wrp.Parameters.Others.Arg1;
    6.16    ASSERT(urb);
    6.17 -#if 1
    6.18 +#if 0
    6.19    KdPrint((__DRIVER_NAME "     urb = %p\n", urb));
    6.20    KdPrint((__DRIVER_NAME "      Length = %d\n", urb->UrbHeader.Length));
    6.21    KdPrint((__DRIVER_NAME "      Function = %d\n", urb->UrbHeader.Function));
    6.22 @@ -73,12 +71,12 @@ XenUsb_EvtIoInternalDeviceControl_ROOTHU
    6.23      FUNCTION_MSG("Calling WdfRequestCompletestatus with status = %08x\n", STATUS_UNSUCCESSFUL); //STATUS_UNSUCCESSFUL));
    6.24      urb->UrbHeader.Status = USBD_STATUS_INVALID_URB_FUNCTION;
    6.25      WdfRequestComplete(request, STATUS_UNSUCCESSFUL);
    6.26 -    FUNCTION_EXIT();
    6.27      return;
    6.28    }
    6.29  
    6.30    urb->UrbHeader.Status = USBD_STATUS_INVALID_URB_FUNCTION;
    6.31    
    6.32 +#if 0
    6.33    if (decode_retval != URB_DECODE_NOT_CONTROL)
    6.34    {
    6.35      FUNCTION_MSG("bmRequestType = %02x\n", decode_data.setup_packet.default_pipe_setup_packet.bmRequestType.B);
    6.36 @@ -94,6 +92,7 @@ XenUsb_EvtIoInternalDeviceControl_ROOTHU
    6.37      FUNCTION_MSG(" High = %02x\n", decode_data.setup_packet.default_pipe_setup_packet.wIndex.HiByte);
    6.38      FUNCTION_MSG("wLength = %04x\n", decode_data.setup_packet.default_pipe_setup_packet.wLength);
    6.39    }
    6.40 +#endif
    6.41    
    6.42    switch(urb->UrbHeader.Function)
    6.43    {
    6.44 @@ -181,44 +180,77 @@ XenUsb_EvtIoInternalDeviceControl_ROOTHU
    6.45      }
    6.46      urb->UrbHeader.Status = USBD_STATUS_INVALID_URB_FUNCTION;
    6.47      break;
    6.48 +#if (NTDDI_VERSION >= NTDDI_VISTA)  
    6.49    case URB_FUNCTION_CONTROL_TRANSFER_EX:
    6.50 -#if 0
    6.51 -    setup_packet = (PUSB_DEFAULT_PIPE_SETUP_PACKET)urb->UrbControlTransfer.SetupPacket;
    6.52 -    FUNCTION_MSG("URB_FUNCTION_CONTROL_TRANSFER_EX\n");
    6.53 -    FUNCTION_MSG(" PipeHandle = %p\n", urb->UrbControlTransfer.PipeHandle);
    6.54 -    FUNCTION_MSG(" TransferFlags = %08x\n", urb->UrbControlTransfer.TransferFlags);
    6.55 -    FUNCTION_MSG(" TransferBufferLength = %d\n", urb->UrbControlTransfer.TransferBufferLength);
    6.56 -    FUNCTION_MSG(" TransferBuffer = %p\n", urb->UrbControlTransfer.TransferBuffer);
    6.57 -    FUNCTION_MSG(" TransferBufferMdl = %p\n", urb->UrbControlTransfer.TransferBufferMDL);
    6.58 -    FUNCTION_MSG(" Timeout = %p\n", urb->UrbControlTransfer.TransferBufferMDL);
    6.59  #endif
    6.60 +  case URB_FUNCTION_CONTROL_TRANSFER:
    6.61 +  case URB_FUNCTION_CLASS_DEVICE:
    6.62 +  case URB_FUNCTION_CLASS_OTHER:
    6.63 +  case URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE:
    6.64 +  case URB_FUNCTION_GET_STATUS_FROM_DEVICE:
    6.65      switch(decode_data.setup_packet.default_pipe_setup_packet.bRequest)
    6.66      {
    6.67      case USB_REQUEST_GET_STATUS:
    6.68        // switch device, interface, endpoint
    6.69 -      FUNCTION_MSG(" USB_REQUEST_GET_STATUS\n");
    6.70        switch (decode_data.setup_packet.default_pipe_setup_packet.bmRequestType.Type)
    6.71        {
    6.72 -      case 0: /* Standard */
    6.73 -        KdPrint((__DRIVER_NAME "       Device Status\n"));
    6.74 -        *(PUSHORT)urb->UrbControlDescriptorRequest.TransferBuffer = 0x0003;
    6.75 -        urb->UrbHeader.Status = USBD_STATUS_SUCCESS;
    6.76 +      case BMREQUEST_STANDARD:
    6.77 +        FUNCTION_MSG(" USB_REQUEST_GET_STATUS\n");
    6.78 +        FUNCTION_MSG(" Type=Standard\n");
    6.79 +        switch (decode_data.setup_packet.default_pipe_setup_packet.bmRequestType.Recipient)
    6.80 +        {
    6.81 +        case BMREQUEST_TO_DEVICE:
    6.82 +          KdPrint((__DRIVER_NAME "       Recipient=Device\n"));
    6.83 +          ((PUSHORT)decode_data.buffer)[0] = 0x0001; /* self powered */
    6.84 +          urb->UrbHeader.Status = USBD_STATUS_SUCCESS;
    6.85 +          break;
    6.86 +        default:
    6.87 +          FUNCTION_MSG(" Recipient=%d\n", decode_data.setup_packet.default_pipe_setup_packet.bmRequestType.Recipient);
    6.88 +          break;
    6.89 +        }
    6.90          break;
    6.91 -      case 1: /* Class */
    6.92 -        KdPrint((__DRIVER_NAME "       Port Status\n"));
    6.93 -        ((PUSHORT)urb->UrbControlVendorClassRequest.TransferBuffer)[0] = xudd->ports[urb->UrbControlVendorClassRequest.Index - 1].port_status;
    6.94 -        ((PUSHORT)urb->UrbControlVendorClassRequest.TransferBuffer)[1] = xudd->ports[urb->UrbControlVendorClassRequest.Index - 1].port_change;
    6.95 -        urb->UrbHeader.Status = USBD_STATUS_SUCCESS;
    6.96 +      case BMREQUEST_CLASS:
    6.97 +        switch (decode_data.setup_packet.default_pipe_setup_packet.bmRequestType.Recipient)
    6.98 +        {
    6.99 +        case BMREQUEST_TO_DEVICE:
   6.100 +          ((PUSHORT)decode_data.buffer)[0] = 0x0000;
   6.101 +          ((PUSHORT)decode_data.buffer)[1] = 0x0000;
   6.102 +          urb->UrbHeader.Status = USBD_STATUS_SUCCESS;
   6.103 +          break;
   6.104 +        case BMREQUEST_TO_OTHER:
   6.105 +          FUNCTION_MSG(" USB_REQUEST_GET_STATUS\n");
   6.106 +          FUNCTION_MSG(" Type=Class\n");
   6.107 +          KdPrint((__DRIVER_NAME "       Recipient=Other (port = %d)\n", decode_data.setup_packet.default_pipe_setup_packet.wIndex.LowByte));
   6.108 +          ((PUSHORT)decode_data.buffer)[0] = xudd->ports[decode_data.setup_packet.default_pipe_setup_packet.wIndex.LowByte - 1].port_status;
   6.109 +          ((PUSHORT)decode_data.buffer)[1] = xudd->ports[decode_data.setup_packet.default_pipe_setup_packet.wIndex.LowByte - 1].port_change;
   6.110 +          urb->UrbHeader.Status = USBD_STATUS_SUCCESS;
   6.111 +          FUNCTION_MSG(" status = %04x, change = %04x\n",
   6.112 +            xudd->ports[decode_data.setup_packet.default_pipe_setup_packet.wIndex.LowByte - 1].port_status,
   6.113 +            xudd->ports[decode_data.setup_packet.default_pipe_setup_packet.wIndex.LowByte - 1].port_change);
   6.114 +          break;
   6.115 +        default:
   6.116 +          FUNCTION_MSG(" USB_REQUEST_GET_STATUS\n");
   6.117 +          FUNCTION_MSG(" Type=Class\n");
   6.118 +          FUNCTION_MSG(" Recipient=%d\n", decode_data.setup_packet.default_pipe_setup_packet.bmRequestType.Recipient);
   6.119 +          break;
   6.120 +        }
   6.121 +        break;
   6.122 +      default:
   6.123 +        FUNCTION_MSG(" USB_REQUEST_GET_STATUS\n");
   6.124 +        FUNCTION_MSG(" Type=%d\n", decode_data.setup_packet.default_pipe_setup_packet.bmRequestType.Type);
   6.125 +        break;
   6.126        }
   6.127 -      break;
   6.128 +      break;      
   6.129      case USB_REQUEST_GET_DESCRIPTOR:
   6.130        FUNCTION_MSG(" USB_REQUEST_GET_DESCRIPTOR\n");
   6.131 +      // should separate into Standard and Class
   6.132        switch (decode_data.setup_packet.default_pipe_setup_packet.wValue.HiByte)
   6.133        {
   6.134        case USB_DEVICE_DESCRIPTOR_TYPE:
   6.135          FUNCTION_MSG(" USB_DEVICE_DESCRIPTOR_TYPE\n");
   6.136 -        memcpy(urb->UrbControlDescriptorRequest.TransferBuffer, &usb_device->device_descriptor, sizeof(USB_DEVICE_DESCRIPTOR));
   6.137 -        urb->UrbControlDescriptorRequest.TransferBufferLength = sizeof(USB_DEVICE_DESCRIPTOR);
   6.138 +        FUNCTION_MSG(" length = %d\n", *decode_data.length);
   6.139 +        memcpy(decode_data.buffer, &usb_device->device_descriptor, sizeof(USB_DEVICE_DESCRIPTOR));
   6.140 +        *decode_data.length = sizeof(USB_DEVICE_DESCRIPTOR);
   6.141          urb->UrbHeader.Status = USBD_STATUS_SUCCESS;
   6.142          break;
   6.143        case USB_CONFIGURATION_DESCRIPTOR_TYPE:
   6.144 @@ -227,6 +259,7 @@ XenUsb_EvtIoInternalDeviceControl_ROOTHU
   6.145          PUCHAR ptr;
   6.146  
   6.147          FUNCTION_MSG(" USB_CONFIGURATION_DESCRIPTOR_TYPE\n");
   6.148 +        FUNCTION_MSG(" length = %d\n", *decode_data.length);
   6.149          usb_config = usb_device->active_config;
   6.150          ptr = (PUCHAR)decode_data.buffer;
   6.151          memcpy(ptr, &usb_config->config_descriptor, sizeof(USB_CONFIGURATION_DESCRIPTOR));
   6.152 @@ -253,14 +286,20 @@ XenUsb_EvtIoInternalDeviceControl_ROOTHU
   6.153          urb->UrbHeader.Status = USBD_STATUS_SUCCESS;
   6.154          break;
   6.155        } 
   6.156 +      case 0x00: // unknown... doing the same as 0x29 seems to work
   6.157 +        FUNCTION_MSG(" USB_00_DESCRIPTOR_TYPE (doesn't exist)\n");
   6.158 +        urb->UrbHeader.Status = USBD_STATUS_BAD_DESCRIPTOR;
   6.159 +        break;
   6.160        case 0x29: // Hub Descriptor
   6.161        {
   6.162          PUSB_HUB_DESCRIPTOR uhd;
   6.163          
   6.164 -        FUNCTION_MSG(" USB_HUB_DESCRIPTOR_TYPE\n");
   6.165 -        uhd = urb->UrbControlVendorClassRequest.TransferBuffer;
   6.166 -        urb->UrbControlVendorClassRequest.TransferBufferLength = FIELD_OFFSET(USB_HUB_DESCRIPTOR, bRemoveAndPowerMask[0]) + 2 + 1;
   6.167 -        uhd->bDescriptorLength = (UCHAR)urb->UrbControlVendorClassRequest.TransferBufferLength;
   6.168 +        FUNCTION_MSG(" USB_HUB_DESCRIPTOR_TYPE\n", decode_data.setup_packet.default_pipe_setup_packet.wValue.HiByte);
   6.169 +        FUNCTION_MSG(" length = %d\n", *decode_data.length);
   6.170 +        uhd = decode_data.buffer;
   6.171 +        // TODO adjust for real number of ports
   6.172 +        *decode_data.length = FIELD_OFFSET(USB_HUB_DESCRIPTOR, bRemoveAndPowerMask[0]) + 2 + 1;
   6.173 +        uhd->bDescriptorLength = (UCHAR)*decode_data.length;
   6.174          uhd->bDescriptorType = 0x29;
   6.175          uhd->bNumberOfPorts = 8;
   6.176          uhd->wHubCharacteristics = 0x0012; // no power switching no overcurrent protection
   6.177 @@ -276,6 +315,66 @@ XenUsb_EvtIoInternalDeviceControl_ROOTHU
   6.178        }
   6.179        default:
   6.180          FUNCTION_MSG(" USB_%02x_DESCRIPTOR_TYPE\n", (ULONG)decode_data.setup_packet.default_pipe_setup_packet.wValue.HiByte);
   6.181 +        FUNCTION_MSG("bmRequestType = %02x\n", decode_data.setup_packet.default_pipe_setup_packet.bmRequestType.B);
   6.182 +        FUNCTION_MSG(" Recipient = %x\n", decode_data.setup_packet.default_pipe_setup_packet.bmRequestType.Recipient);
   6.183 +        FUNCTION_MSG(" Type = %x\n", decode_data.setup_packet.default_pipe_setup_packet.bmRequestType.Type);
   6.184 +        FUNCTION_MSG(" Dir = %x\n", decode_data.setup_packet.default_pipe_setup_packet.bmRequestType.Dir);
   6.185 +        FUNCTION_MSG("bRequest = %02x\n", decode_data.setup_packet.default_pipe_setup_packet.bRequest);
   6.186 +        FUNCTION_MSG("wValue = %04x\n", decode_data.setup_packet.default_pipe_setup_packet.wValue.W);
   6.187 +        FUNCTION_MSG(" Low = %02x\n", decode_data.setup_packet.default_pipe_setup_packet.wValue.LowByte);
   6.188 +        FUNCTION_MSG(" High = %02x\n", decode_data.setup_packet.default_pipe_setup_packet.wValue.HiByte);
   6.189 +        FUNCTION_MSG("wIndex = %04x\n", decode_data.setup_packet.default_pipe_setup_packet.wIndex);
   6.190 +        FUNCTION_MSG(" Low = %02x\n", decode_data.setup_packet.default_pipe_setup_packet.wIndex.LowByte);
   6.191 +        FUNCTION_MSG(" High = %02x\n", decode_data.setup_packet.default_pipe_setup_packet.wIndex.HiByte);
   6.192 +        FUNCTION_MSG("wLength = %04x\n", decode_data.setup_packet.default_pipe_setup_packet.wLength);
   6.193 +        break;
   6.194 +      }
   6.195 +      break;
   6.196 +    case USB_REQUEST_CLEAR_FEATURE:
   6.197 +      FUNCTION_MSG(" USB_REQUEST_CLEAR_FEATURE\n");
   6.198 +      switch (decode_data.setup_packet.default_pipe_setup_packet.bmRequestType.Type)
   6.199 +      {
   6.200 +      case BMREQUEST_STANDARD: /* Standard */
   6.201 +        KdPrint((__DRIVER_NAME "       Type=Standard (unsupported)\n"));
   6.202 +        break;
   6.203 +      case BMREQUEST_CLASS: /* Class */
   6.204 +        KdPrint((__DRIVER_NAME "       Type=Class\n"));
   6.205 +        switch (decode_data.setup_packet.default_pipe_setup_packet.bmRequestType.Recipient)
   6.206 +        {
   6.207 +        case BMREQUEST_TO_OTHER:
   6.208 +          KdPrint((__DRIVER_NAME "       Recipient=Other (port = %d)\n", decode_data.setup_packet.default_pipe_setup_packet.wIndex.LowByte));
   6.209 +          switch (urb->UrbControlVendorClassRequest.Value)
   6.210 +          {
   6.211 +          case PORT_ENABLE:
   6.212 +            KdPrint((__DRIVER_NAME "        PORT_ENABLE\n"));
   6.213 +            xudd->ports[decode_data.setup_packet.default_pipe_setup_packet.wIndex.LowByte - 1].port_status &= ~(1 << PORT_ENABLE);
   6.214 +            urb->UrbHeader.Status = USBD_STATUS_SUCCESS;
   6.215 +            break;
   6.216 +          case C_PORT_CONNECTION:
   6.217 +            KdPrint((__DRIVER_NAME "        C_PORT_CONNECTION\n"));
   6.218 +            xudd->ports[decode_data.setup_packet.default_pipe_setup_packet.wIndex.LowByte - 1].port_change &= ~(1 << PORT_CONNECTION);
   6.219 +            urb->UrbHeader.Status = USBD_STATUS_SUCCESS;
   6.220 +            break;
   6.221 +          case C_PORT_RESET:
   6.222 +            KdPrint((__DRIVER_NAME "        C_PORT_RESET\n"));
   6.223 +            xudd->ports[decode_data.setup_packet.default_pipe_setup_packet.wIndex.LowByte - 1].port_change &= ~(1 << PORT_RESET);
   6.224 +            urb->UrbHeader.Status = USBD_STATUS_SUCCESS;
   6.225 +            break;
   6.226 +          default:
   6.227 +            KdPrint((__DRIVER_NAME "        Unknown Value %04X\n", urb->UrbControlVendorClassRequest.Value));
   6.228 +            break;
   6.229 +          }
   6.230 +          KdPrint((__DRIVER_NAME "        status = %04x, change = %04x\n",
   6.231 +            xudd->ports[decode_data.setup_packet.default_pipe_setup_packet.wIndex.LowByte - 1].port_status,
   6.232 +            xudd->ports[decode_data.setup_packet.default_pipe_setup_packet.wIndex.LowByte - 1].port_change));
   6.233 +          break;
   6.234 +        default:
   6.235 +          FUNCTION_MSG(" Recipient=%d\n", decode_data.setup_packet.default_pipe_setup_packet.bmRequestType.Recipient);
   6.236 +          break;
   6.237 +        }
   6.238 +        break;
   6.239 +      default:
   6.240 +        KdPrint((__DRIVER_NAME "       Type=%d\n", decode_data.setup_packet.default_pipe_setup_packet.bmRequestType.Type));
   6.241          break;
   6.242        }
   6.243        break;
   6.244 @@ -285,13 +384,14 @@ XenUsb_EvtIoInternalDeviceControl_ROOTHU
   6.245        switch (decode_data.setup_packet.default_pipe_setup_packet.bmRequestType.Type)
   6.246        {
   6.247        case 0: /* Standard */
   6.248 -        KdPrint((__DRIVER_NAME "       Standard\n"));
   6.249 +        KdPrint((__DRIVER_NAME "       Type=Standard (unsupported)\n"));
   6.250          break;
   6.251        case 1: /* Class */
   6.252 -        KdPrint((__DRIVER_NAME "       Class\n"));
   6.253 +        KdPrint((__DRIVER_NAME "       Type=Class\n"));
   6.254          switch (decode_data.setup_packet.default_pipe_setup_packet.bmRequestType.Recipient)
   6.255          {
   6.256          case BMREQUEST_TO_OTHER:
   6.257 +          KdPrint((__DRIVER_NAME "       Recipient=Other (port = %d)\n", decode_data.setup_packet.default_pipe_setup_packet.wIndex.LowByte));
   6.258            switch (decode_data.setup_packet.default_pipe_setup_packet.wValue.W)
   6.259            {
   6.260            case PORT_ENABLE:
   6.261 @@ -301,13 +401,18 @@ XenUsb_EvtIoInternalDeviceControl_ROOTHU
   6.262              break;
   6.263            case PORT_RESET:
   6.264              KdPrint((__DRIVER_NAME "        PORT_RESET\n"));
   6.265 -            /* just fake the reset */
   6.266 +            /* just fake the reset by setting the status bit to indicate that the reset is complete*/
   6.267 +            xudd->ports[decode_data.setup_packet.default_pipe_setup_packet.wIndex.LowByte - 1].port_status |= (1 << PORT_RESET);
   6.268 +            //xudd->ports[decode_data.setup_packet.default_pipe_setup_packet.wIndex.LowByte - 1].reset_counter = 10;
   6.269 +            // TODO: maybe fake a 10ms time here...
   6.270 +            xudd->ports[decode_data.setup_packet.default_pipe_setup_packet.wIndex.LowByte - 1].port_status &= ~(1 << PORT_RESET);
   6.271 +            xudd->ports[decode_data.setup_packet.default_pipe_setup_packet.wIndex.LowByte - 1].port_status |= (1 << PORT_ENABLE);
   6.272              xudd->ports[decode_data.setup_packet.default_pipe_setup_packet.wIndex.LowByte - 1].port_change |= (1 << PORT_RESET);
   6.273              urb->UrbHeader.Status = USBD_STATUS_SUCCESS;
   6.274              break;
   6.275            case PORT_POWER:
   6.276 -            KdPrint((__DRIVER_NAME "        PORT_POWER (NOOP)\n"));
   6.277 -            /* do something here */
   6.278 +            KdPrint((__DRIVER_NAME "        PORT_POWER\n"));
   6.279 +            xudd->ports[decode_data.setup_packet.default_pipe_setup_packet.wIndex.LowByte - 1].port_status |= (1 << PORT_POWER);
   6.280              urb->UrbHeader.Status = USBD_STATUS_SUCCESS;
   6.281              break;
   6.282            default:
   6.283 @@ -334,7 +439,7 @@ XenUsb_EvtIoInternalDeviceControl_ROOTHU
   6.284      urb->UrbHeader.Status = USBD_STATUS_SUCCESS;
   6.285      break;
   6.286    case URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER: /* 11.12.4 */
   6.287 -#if 1
   6.288 +#if 0
   6.289      KdPrint((__DRIVER_NAME "     URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER\n"));
   6.290      KdPrint((__DRIVER_NAME "      PipeHandle = %p\n", urb->UrbBulkOrInterruptTransfer.PipeHandle));
   6.291      KdPrint((__DRIVER_NAME "      TransferFlags = %08x\n", urb->UrbBulkOrInterruptTransfer.TransferFlags));
   6.292 @@ -350,7 +455,7 @@ XenUsb_EvtIoInternalDeviceControl_ROOTHU
   6.293      }
   6.294      WdfRequestForwardToIoQueue(request, endpoint->interrupt_queue);
   6.295      WdfSpinLockRelease(endpoint->interrupt_lock);
   6.296 -    FUNCTION_EXIT();
   6.297 +    //FUNCTION_EXIT();
   6.298      return;
   6.299      
   6.300  #if 0 // not using this bit
   6.301 @@ -604,12 +709,27 @@ XenUsb_EvtIoInternalDeviceControl_ROOTHU
   6.302  #endif
   6.303    default:
   6.304      FUNCTION_MSG("URB_FUNCTION_%04x\n", urb->UrbHeader.Function);
   6.305 +    if (decode_retval != URB_DECODE_NOT_CONTROL)
   6.306 +    {
   6.307 +      FUNCTION_MSG("bmRequestType = %02x\n", decode_data.setup_packet.default_pipe_setup_packet.bmRequestType.B);
   6.308 +      FUNCTION_MSG(" Recipient = %x\n", decode_data.setup_packet.default_pipe_setup_packet.bmRequestType.Recipient);
   6.309 +      FUNCTION_MSG(" Type = %x\n", decode_data.setup_packet.default_pipe_setup_packet.bmRequestType.Type);
   6.310 +      FUNCTION_MSG(" Dir = %x\n", decode_data.setup_packet.default_pipe_setup_packet.bmRequestType.Dir);
   6.311 +      FUNCTION_MSG("bRequest = %02x\n", decode_data.setup_packet.default_pipe_setup_packet.bRequest);
   6.312 +      FUNCTION_MSG("wValue = %04x\n", decode_data.setup_packet.default_pipe_setup_packet.wValue.W);
   6.313 +      FUNCTION_MSG(" Low = %02x\n", decode_data.setup_packet.default_pipe_setup_packet.wValue.LowByte);
   6.314 +      FUNCTION_MSG(" High = %02x\n", decode_data.setup_packet.default_pipe_setup_packet.wValue.HiByte);
   6.315 +      FUNCTION_MSG("wIndex = %04x\n", decode_data.setup_packet.default_pipe_setup_packet.wIndex);
   6.316 +      FUNCTION_MSG(" Low = %02x\n", decode_data.setup_packet.default_pipe_setup_packet.wIndex.LowByte);
   6.317 +      FUNCTION_MSG(" High = %02x\n", decode_data.setup_packet.default_pipe_setup_packet.wIndex.HiByte);
   6.318 +      FUNCTION_MSG("wLength = %04x\n", decode_data.setup_packet.default_pipe_setup_packet.wLength);
   6.319 +    }
   6.320      urb->UrbHeader.Status = USBD_STATUS_INVALID_URB_FUNCTION;
   6.321      break;
   6.322    }
   6.323    if (urb->UrbHeader.Status == USBD_STATUS_SUCCESS)
   6.324    {
   6.325 -    FUNCTION_MSG("Calling WdfRequestCompletestatus with status = %08x\n", STATUS_SUCCESS);
   6.326 +    //FUNCTION_MSG("Calling WdfRequestCompletestatus with status = %08x\n", STATUS_SUCCESS);
   6.327      WdfRequestComplete(request, STATUS_SUCCESS);
   6.328    }
   6.329    else
   6.330 @@ -617,6 +737,7 @@ XenUsb_EvtIoInternalDeviceControl_ROOTHU
   6.331      FUNCTION_MSG("Calling WdfRequestCompletestatus with status = %08x\n", STATUS_UNSUCCESSFUL);
   6.332      WdfRequestComplete(request, STATUS_UNSUCCESSFUL);
   6.333    }
   6.334 -  FUNCTION_EXIT();
   6.335 +  //FUNCTION_EXIT();
   6.336 +  return;
   6.337  }
   6.338