[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

svn path=/branches/usb-bringup/; revision=51487
This commit is contained in:
Johannes Anderwald 2011-04-28 23:59:53 +00:00
parent 823176506d
commit e8cf4c5591
3 changed files with 154 additions and 9 deletions

View file

@ -868,7 +868,6 @@ CHubController::HandleClassOther(
break;
default:
DPRINT("Unknown Value for Clear Feature %x \n", Urb->UrbControlVendorClassRequest.Value);
PC_ASSERT(FALSE);
break;
}
@ -1079,6 +1078,7 @@ CHubController::HandleGetDescriptor(
{
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 @@ CHubController::HandleGetDescriptor(
//
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 @@ CHubController::HandleGetDescriptor(
//
// sanity check
//
PC_ASSERT(UsbDevice->GetConfigurationDescriptorsLength() == Length);
PC_ASSERT(Urb->UrbControlDescriptorRequest.TransferBufferLength >= Length);
//
// store result size
@ -1223,6 +1223,41 @@ CHubController::HandleGetDescriptor(
}
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:
DPRINT1("CHubController::HandleGetDescriptor DescriptorType %x unimplemented\n", Urb->UrbControlDescriptorRequest.DescriptorType);
break;
@ -2049,8 +2084,45 @@ USBHI_RestoreUsbDevice(
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 @@ USBHI_SetDeviceHandleData(
//
return;
}
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);
//
// set device handle data
//
UsbDevice->SetDeviceHandleData(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);
}
}
//=================================================================================================

View file

@ -802,6 +802,17 @@ DECLARE_INTERFACE_(IUSBDevice, IUnknown)
//
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;

View file

@ -67,6 +67,8 @@ public:
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 @@ CUSBDevice::DumpConfigurationDescriptor(PUSB_CONFIGURATION_DESCRIPTOR Configurat
}
//----------------------------------------------------------------------------------------
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)
{