[USBEHCI_NEW]

- Fix build 
- Implement retrieving configuration descriptor (USBHI_GetUsbDescriptors)
- Implement function to build a setup packet from urb (taken from mjmartin usbehci driver)

svn path=/branches/usb-bringup/; revision=51443
This commit is contained in:
Johannes Anderwald 2011-04-24 09:26:22 +00:00
parent 982eb59ba0
commit 346a95197f
4 changed files with 215 additions and 55 deletions

View file

@ -56,6 +56,7 @@ public:
NTSTATUS CreateQueueHead(PQUEUE_HEAD *OutQueueHead);
ULONG GetDeviceAddress();
NTSTATUS BuildSetupPacket();
NTSTATUS BuildSetupPacketFromURB();
// constructor / destructor
CUSBRequest(IUnknown *OuterUnknown){}
@ -84,7 +85,6 @@ protected:
//
PMDL m_TransferBufferMDL;
//
// caller provided setup packet
//
@ -181,7 +181,6 @@ CUSBRequest::InitializeWithIrp(
{
PIO_STACK_LOCATION IoStack;
PURB Urb;
NTSTATUS Status;
//
// sanity checks
@ -409,6 +408,10 @@ CUSBRequest::GetQueueHead(
DPRINT1("USB_ENDPOINT_TYPE_ISOCHRONOUS not implemented\n");
Status = STATUS_NOT_IMPLEMENTED;
break;
default:
PC_ASSERT(FALSE);
Status = STATUS_NOT_IMPLEMENTED;
break;
}
if (NT_SUCCESS(Status))
@ -837,11 +840,6 @@ CUSBRequest::BuildSetupPacket()
NTSTATUS Status;
PHYSICAL_ADDRESS PhysicalAddress;
//
// FIXME: generate setup packet from urb request
//
PC_ASSERT(m_SetupPacket);
//
// allocate common buffer setup packet
//
@ -862,6 +860,13 @@ CUSBRequest::BuildSetupPacket()
RtlCopyMemory(m_DescriptorPacket, m_SetupPacket, sizeof(USB_DEFAULT_PIPE_SETUP_PACKET));
m_DescriptorSetupPacket = PhysicalAddress;
}
else
{
//
// build setup packet from urb
//
Status = BuildSetupPacketFromURB();
}
//
// done
@ -869,6 +874,156 @@ CUSBRequest::BuildSetupPacket()
return Status;
}
NTSTATUS
CUSBRequest::BuildSetupPacketFromURB()
{
PIO_STACK_LOCATION IoStack;
PURB Urb;
NTSTATUS Status = STATUS_NOT_IMPLEMENTED;
//
// sanity checks
//
PC_ASSERT(m_Irp);
PC_ASSERT(m_DescriptorPacket);
//
// get stack location
//
IoStack = IoGetCurrentIrpStackLocation(m_Irp);
//
// get urb
//
Urb = (PURB)IoStack->Parameters.Others.Argument1;
//
// zero descriptor packet
//
RtlZeroMemory(m_DescriptorPacket, sizeof(USB_DEFAULT_PIPE_SETUP_PACKET));
switch (Urb->UrbHeader.Function)
{
/* CLEAR FEATURE */
case URB_FUNCTION_CLEAR_FEATURE_TO_DEVICE:
case URB_FUNCTION_CLEAR_FEATURE_TO_INTERFACE:
case URB_FUNCTION_CLEAR_FEATURE_TO_ENDPOINT:
UNIMPLEMENTED
break;
/* GET CONFIG */
case URB_FUNCTION_GET_CONFIGURATION:
m_DescriptorPacket->bRequest = USB_REQUEST_GET_CONFIGURATION;
m_DescriptorPacket->bmRequestType.B = 0x80;
m_DescriptorPacket->wLength = 1;
break;
/* GET DESCRIPTOR */
case URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE:
m_DescriptorPacket->bRequest = USB_REQUEST_GET_DESCRIPTOR;
m_DescriptorPacket->wValue.LowByte = Urb->UrbControlDescriptorRequest.Index;
m_DescriptorPacket->wValue.HiByte = Urb->UrbControlDescriptorRequest.DescriptorType;
m_DescriptorPacket->wIndex.W = Urb->UrbControlDescriptorRequest.LanguageId;
m_DescriptorPacket->wLength = Urb->UrbControlDescriptorRequest.TransferBufferLength;
m_DescriptorPacket->bmRequestType.B = 0x80;
break;
/* GET INTERFACE */
case URB_FUNCTION_GET_INTERFACE:
m_DescriptorPacket->bRequest = USB_REQUEST_GET_CONFIGURATION;
m_DescriptorPacket->wIndex.W = Urb->UrbControlGetStatusRequest.Index;
m_DescriptorPacket->bmRequestType.B = 0x80;
m_DescriptorPacket->wLength = 1;
break;
/* GET STATUS */
case URB_FUNCTION_GET_STATUS_FROM_DEVICE:
m_DescriptorPacket->bRequest = USB_REQUEST_GET_STATUS;
ASSERT(Urb->UrbControlGetStatusRequest.Index == 0);
m_DescriptorPacket->wIndex.W = Urb->UrbControlGetStatusRequest.Index;
m_DescriptorPacket->bmRequestType.B = 0x80;
m_DescriptorPacket->wLength = 2;
break;
case URB_FUNCTION_GET_STATUS_FROM_INTERFACE:
m_DescriptorPacket->bRequest = USB_REQUEST_GET_STATUS;
ASSERT(Urb->UrbControlGetStatusRequest.Index != 0);
m_DescriptorPacket->wIndex.W = Urb->UrbControlGetStatusRequest.Index;
m_DescriptorPacket->bmRequestType.B = 0x81;
m_DescriptorPacket->wLength = 2;
break;
case URB_FUNCTION_GET_STATUS_FROM_ENDPOINT:
m_DescriptorPacket->bRequest = USB_REQUEST_GET_STATUS;
ASSERT(Urb->UrbControlGetStatusRequest.Index != 0);
m_DescriptorPacket->wIndex.W = Urb->UrbControlGetStatusRequest.Index;
m_DescriptorPacket->bmRequestType.B = 0x82;
m_DescriptorPacket->wLength = 2;
break;
/* SET ADDRESS */
/* SET CONFIG */
case URB_FUNCTION_SELECT_CONFIGURATION:
m_DescriptorPacket->bRequest = USB_REQUEST_SET_CONFIGURATION;
m_DescriptorPacket->wValue.W = Urb->UrbSelectConfiguration.ConfigurationDescriptor->bConfigurationValue;
m_DescriptorPacket->wIndex.W = 0;
m_DescriptorPacket->wLength = 0;
m_DescriptorPacket->bmRequestType.B = 0x00;
break;
/* SET DESCRIPTOR */
case URB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE:
case URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE:
case URB_FUNCTION_SET_DESCRIPTOR_TO_ENDPOINT:
UNIMPLEMENTED
break;
/* SET FEATURE */
case URB_FUNCTION_SET_FEATURE_TO_DEVICE:
m_DescriptorPacket->bRequest = USB_REQUEST_SET_FEATURE;
ASSERT(Urb->UrbControlGetStatusRequest.Index == 0);
m_DescriptorPacket->wIndex.W = Urb->UrbControlGetStatusRequest.Index;
m_DescriptorPacket->bmRequestType.B = 0x80;
break;
case URB_FUNCTION_SET_FEATURE_TO_INTERFACE:
m_DescriptorPacket->bRequest = USB_REQUEST_SET_FEATURE;
ASSERT(Urb->UrbControlGetStatusRequest.Index == 0);
m_DescriptorPacket->wIndex.W = Urb->UrbControlGetStatusRequest.Index;
m_DescriptorPacket->bmRequestType.B = 0x81;
break;
case URB_FUNCTION_SET_FEATURE_TO_ENDPOINT:
m_DescriptorPacket->bRequest = USB_REQUEST_SET_FEATURE;
ASSERT(Urb->UrbControlGetStatusRequest.Index == 0);
m_DescriptorPacket->wIndex.W = Urb->UrbControlGetStatusRequest.Index;
m_DescriptorPacket->bmRequestType.B = 0x82;
break;
/* SET INTERFACE*/
case URB_FUNCTION_SELECT_INTERFACE:
m_DescriptorPacket->bRequest = USB_REQUEST_SET_INTERFACE;
m_DescriptorPacket->wValue.W = Urb->UrbSelectInterface.Interface.AlternateSetting;
m_DescriptorPacket->wIndex.W = Urb->UrbSelectInterface.Interface.InterfaceNumber;
m_DescriptorPacket->wLength = 0;
m_DescriptorPacket->bmRequestType.B = 0x01;
break;
/* SYNC FRAME */
case URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL:
UNIMPLEMENTED
break;
default:
UNIMPLEMENTED
break;
}
return Status;
}
//----------------------------------------------------------------------------------------
VOID
CUSBRequest::GetResultStatus(