Author: janderwald
Date: Thu Apr 28 23:59:53 2011
New Revision: 51487

URL: http://svn.reactos.org/svn/reactos?rev=51487&view=rev
Log:
[USBEHCI_NEW]
- Remove assert for unknown clear feature
- Implement retrieving string descriptors, based on mjmartin usbehci driver
- Start implementing USBHI_RestoreUsbDevice
- Fixup device stack in USBHI_SetDeviceHandleData. Needs more investigation

Modified:
    branches/usb-bringup/drivers/usb/usbehci_new/hub_controller.cpp
    branches/usb-bringup/drivers/usb/usbehci_new/interfaces.h
    branches/usb-bringup/drivers/usb/usbehci_new/usb_device.cpp

Modified: branches/usb-bringup/drivers/usb/usbehci_new/hub_controller.cpp
URL: 
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci_new/hub_controller.cpp?rev=51487&r1=51486&r2=51487&view=diff
==============================================================================
--- branches/usb-bringup/drivers/usb/usbehci_new/hub_controller.cpp 
[iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbehci_new/hub_controller.cpp 
[iso-8859-1] Thu Apr 28 23:59:53 2011
@@ -868,7 +868,6 @@
                     break;
                 default:
                     DPRINT("Unknown Value for Clear Feature %x \n", 
Urb->UrbControlVendorClassRequest.Value);
-                    PC_ASSERT(FALSE);
                     break;
            }
 
@@ -1079,6 +1078,7 @@
 {
     NTSTATUS Status = STATUS_NOT_IMPLEMENTED;
     PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor;
+    USB_DEFAULT_PIPE_SETUP_PACKET CtrlSetup;
     PUCHAR Buffer;
     PUSBDEVICE UsbDevice;
     ULONG Length;
@@ -1191,7 +1191,7 @@
                 //
                 UsbDevice = PUSBDEVICE(Urb->UrbHeader.UsbdDeviceHandle);
 
-                if (UsbDevice->GetConfigurationDescriptorsLength() > 
Urb->UrbControlDescriptorRequest.TransferBufferLength)
+                if (sizeof(USB_CONFIGURATION_DESCRIPTOR) > 
Urb->UrbControlDescriptorRequest.TransferBufferLength)
                 {
                     //
                     // buffer too small
@@ -1213,7 +1213,7 @@
                 //
                 // sanity check
                 //
-                PC_ASSERT(UsbDevice->GetConfigurationDescriptorsLength() == 
Length);
+                
PC_ASSERT(Urb->UrbControlDescriptorRequest.TransferBufferLength >= Length);
 
                 //
                 // store result size
@@ -1221,6 +1221,41 @@
                 Urb->UrbControlDescriptorRequest.TransferBufferLength = Length;
                 Status = STATUS_SUCCESS;
             }
+            break;
+        }
+        case USB_STRING_DESCRIPTOR_TYPE:
+        {
+            //
+            // sanity check
+            //
+            PC_ASSERT(Urb->UrbControlDescriptorRequest.TransferBuffer);
+            PC_ASSERT(Urb->UrbControlDescriptorRequest.TransferBufferLength);
+
+
+            //
+            // check if this is a valid usb device handle
+            //
+            
PC_ASSERT(ValidateUsbDevice(PUSBDEVICE(Urb->UrbHeader.UsbdDeviceHandle)));
+
+            //
+            // get device
+            //
+            UsbDevice = PUSBDEVICE(Urb->UrbHeader.UsbdDeviceHandle);
+
+            //
+            // generate setup packet
+            //
+            CtrlSetup.bRequest = USB_REQUEST_GET_DESCRIPTOR;
+            CtrlSetup.wValue.LowByte = Urb->UrbControlDescriptorRequest.Index;
+            CtrlSetup.wValue.HiByte = 
Urb->UrbControlDescriptorRequest.DescriptorType;
+            CtrlSetup.wIndex.W = Urb->UrbControlDescriptorRequest.LanguageId;
+            CtrlSetup.wLength = 
Urb->UrbControlDescriptorRequest.TransferBufferLength;
+            CtrlSetup.bmRequestType.B = 0x80;
+
+            //
+            // submit setup packet
+            //
+            Status = UsbDevice->SubmitSetupPacket(&CtrlSetup, 
Urb->UrbControlDescriptorRequest.TransferBufferLength, 
Urb->UrbControlDescriptorRequest.TransferBuffer);
             break;
         }
         default:
@@ -2049,8 +2084,45 @@
     PUSB_DEVICE_HANDLE OldDeviceHandle,
     PUSB_DEVICE_HANDLE NewDeviceHandle)
 {
-    UNIMPLEMENTED
-    return STATUS_NOT_IMPLEMENTED;
+    PUSBDEVICE OldUsbDevice, NewUsbDevice;
+    CHubController * Controller;
+    NTSTATUS Status;
+
+    DPRINT1("USBHI_RestoreUsbDevice\n");
+
+    //
+    // first get controller
+    //
+    Controller = (CHubController *)BusContext;
+    PC_ASSERT(Controller);
+
+    //
+    // get device object
+    //
+    OldUsbDevice = (PUSBDEVICE)OldDeviceHandle;
+    NewUsbDevice = (PUSBDEVICE)NewDeviceHandle;
+    PC_ASSERT(OldUsbDevice);
+    PC_ASSERT(NewDeviceHandle);
+
+    //
+    // validate device handle
+    //
+    PC_ASSERT(Controller->ValidateUsbDevice(NewUsbDevice));
+    PC_ASSERT(Controller->ValidateUsbDevice(OldUsbDevice));
+
+    DPRINT1("NewUsbDevice: DeviceAddress %x\n", 
NewUsbDevice->GetDeviceAddress());
+
+
+    DPRINT1("OldUsbDevice: DeviceAddress %x\n", 
OldUsbDevice->GetDeviceAddress());
+
+    PC_ASSERT(FALSE);
+
+    //
+    // remove old device handle
+    //
+    USBHI_RemoveUsbDevice(BusContext, OldDeviceHandle, 0);
+
+    return STATUS_SUCCESS;
 }
 
 NTSTATUS
@@ -2430,11 +2502,36 @@
         //
         return;
     }
-
-    //
-    // set device handle data
-    //
-    UsbDevice->SetDeviceHandleData(UsbDevicePdo);
+    else
+    {
+        //
+        // usbhub sends this request as a part of the Pnp startup sequence
+        // looks like we need apply a dragon voodoo to fixup the device stack
+        // otherwise usbhub will cause a bugcheck
+        //
+        DPRINT1("USBHI_SetDeviceHandleData %p\n", UsbDevicePdo);
+
+        //
+        // fixup device stack voodoo part #1
+        //
+        UsbDevicePdo->StackSize++;
+
+        //
+        // sanity check
+        //
+        PC_ASSERT(UsbDevicePdo->AttachedDevice);
+
+        //
+        // should be usbstor
+        // fixup device stack voodoo part #2
+        //
+        UsbDevicePdo->AttachedDevice->StackSize++;
+
+        //
+        // set device handle data
+        //
+        UsbDevice->SetDeviceHandleData(UsbDevicePdo);
+    }
 }
 
 
//=================================================================================================

Modified: branches/usb-bringup/drivers/usb/usbehci_new/interfaces.h
URL: 
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci_new/interfaces.h?rev=51487&r1=51486&r2=51487&view=diff
==============================================================================
--- branches/usb-bringup/drivers/usb/usbehci_new/interfaces.h [iso-8859-1] 
(original)
+++ branches/usb-bringup/drivers/usb/usbehci_new/interfaces.h [iso-8859-1] Thu 
Apr 28 23:59:53 2011
@@ -802,6 +802,17 @@
 //
      virtual ULONG GetConfigurationDescriptorsLength() = 0;
 
+//----------------------------------------------------------------------------------------
+//
+// SubmitSetupPacket
+//
+// Description: submits an setup packet. The usb device will then create an 
usb request from it and submit it to the queue
+
+     virtual NTSTATUS SubmitSetupPacket(IN PUSB_DEFAULT_PIPE_SETUP_PACKET 
SetupPacket,
+                                        IN OUT ULONG BufferLength,
+                                        OUT PVOID Buffer) = 0;
+
+
 };
 
 typedef IUSBDevice *PUSBDEVICE;

Modified: branches/usb-bringup/drivers/usb/usbehci_new/usb_device.cpp
URL: 
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci_new/usb_device.cpp?rev=51487&r1=51486&r2=51487&view=diff
==============================================================================
--- branches/usb-bringup/drivers/usb/usbehci_new/usb_device.cpp [iso-8859-1] 
(original)
+++ branches/usb-bringup/drivers/usb/usbehci_new/usb_device.cpp [iso-8859-1] 
Thu Apr 28 23:59:53 2011
@@ -67,6 +67,8 @@
     virtual NTSTATUS SubmitIrp(PIRP Irp);
     virtual VOID GetConfigurationDescriptors(IN PUSB_CONFIGURATION_DESCRIPTOR 
ConfigDescriptorBuffer, IN ULONG BufferLength, OUT PULONG OutBufferLength);
     virtual ULONG GetConfigurationDescriptorsLength();
+    virtual NTSTATUS SubmitSetupPacket(IN PUSB_DEFAULT_PIPE_SETUP_PACKET 
SetupPacket, OUT ULONG BufferLength, OUT PVOID Buffer);
+
 
     // local function
     virtual NTSTATUS CommitIrp(PIRP Irp);
@@ -1016,6 +1018,41 @@
 }
 
//----------------------------------------------------------------------------------------
 NTSTATUS
+CUSBDevice::SubmitSetupPacket(
+    IN PUSB_DEFAULT_PIPE_SETUP_PACKET SetupPacket, 
+    IN OUT ULONG BufferLength, 
+    OUT PVOID Buffer)
+{
+    NTSTATUS Status;
+    PMDL Mdl;
+
+    //
+    // allocate mdl
+    //
+    Mdl = IoAllocateMdl(Buffer, BufferLength, FALSE, FALSE, 0);
+
+    //
+    // HACK HACK HACK: assume the buffer is build from non paged pool
+    //
+    MmBuildMdlForNonPagedPool(Mdl);
+
+    //
+    // commit setup packet
+    //
+    Status = CommitSetupPacket(SetupPacket, BufferLength, Mdl);
+
+    //
+    // free mdl
+    //
+    IoFreeMdl(Mdl);
+
+    //
+    // done
+    //
+    return Status;
+}
+//----------------------------------------------------------------------------------------
+NTSTATUS
 CreateUSBDevice(
     PUSBDEVICE *OutDevice)
 {


Reply via email to