From 8df637b7781107c1d9e783c2fa43eae907c63fcd Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Thu, 28 Apr 2011 13:13:13 +0000 Subject: [PATCH] [USBEHCI_NEW] - Check if the current request type is supported (currently only control is supported, bulk will be implemented soon) - Fix bug in IUSBRequest::CreateQueueHead - Code runs now until first device descriptor get request (async / periodic queue not yet enabled) - mjmartin usbehci status not yet reached - Let the fun now begin ;) svn path=/branches/usb-bringup/; revision=51474 --- drivers/usb/usbehci_new/usb_device.cpp | 1 - drivers/usb/usbehci_new/usb_queue.cpp | 68 +++++++++++++++++++++++-- drivers/usb/usbehci_new/usb_request.cpp | 10 ++++ 3 files changed, 75 insertions(+), 4 deletions(-) diff --git a/drivers/usb/usbehci_new/usb_device.cpp b/drivers/usb/usbehci_new/usb_device.cpp index 30dea3a8749..6eb73debf2c 100644 --- a/drivers/usb/usbehci_new/usb_device.cpp +++ b/drivers/usb/usbehci_new/usb_device.cpp @@ -550,7 +550,6 @@ CUSBDevice::CommitSetupPacket( return Status; } - // // now add the request // diff --git a/drivers/usb/usbehci_new/usb_queue.cpp b/drivers/usb/usbehci_new/usb_queue.cpp index e88c6b347cc..6d27d425ae9 100644 --- a/drivers/usb/usbehci_new/usb_queue.cpp +++ b/drivers/usb/usbehci_new/usb_queue.cpp @@ -157,20 +157,82 @@ CUSBQueue::AddUSBRequest( IUSBRequest * Request) { PQUEUE_HEAD QueueHead; + NTSTATUS Status; + ULONG Type; + + // + // sanity check + // ASSERT(Request != NULL); - Request->GetQueueHead(&QueueHead); + // + // get request type + // + Type = Request->GetTransferType(); // - // Add it to the pending list + // check if supported // - LinkQueueHead(PendingListQueueHead, QueueHead); + switch(Type) + { + case USB_ENDPOINT_TYPE_ISOCHRONOUS: + case USB_ENDPOINT_TYPE_INTERRUPT: + /* NOT IMPLEMENTED IN QUEUE */ + Status = STATUS_NOT_SUPPORTED; + break; + case USB_ENDPOINT_TYPE_BULK: + case USB_ENDPOINT_TYPE_CONTROL: + Status = STATUS_SUCCESS; + break; + default: + /* BUG */ + PC_ASSERT(FALSE); + } + + // + // check for success + // + if (!NT_SUCCESS(Status)) + { + // + // request not supported, please try later + // + return Status; + } + + if (Type == USB_ENDPOINT_TYPE_BULK || Type == USB_ENDPOINT_TYPE_CONTROL) + { + // + // get queue head + // + Status = Request->GetQueueHead(&QueueHead); + + // + // check for success + // + if (!NT_SUCCESS(Status)) + { + // + // failed to get queue head + // + return Status; + } + + DPRINT1("Request %p QueueHead %p inserted into AsyncQueue\n", Request, QueueHead); + + // + // Add it to the pending list + // + LinkQueueHead(PendingListQueueHead, QueueHead); + } + // // add extra reference which is released when the request is completed // Request->AddRef(); + return STATUS_SUCCESS; } diff --git a/drivers/usb/usbehci_new/usb_request.cpp b/drivers/usb/usbehci_new/usb_request.cpp index f196d3e835d..c7275f64a61 100644 --- a/drivers/usb/usbehci_new/usb_request.cpp +++ b/drivers/usb/usbehci_new/usb_request.cpp @@ -538,6 +538,11 @@ CUSBRequest::BuildControlTransferQueueHead( return STATUS_INSUFFICIENT_RESOURCES; } + // + // sanity check + // + PC_ASSERT(QueueHead); + // // create setup packet // @@ -773,6 +778,11 @@ CUSBRequest::CreateQueueHead( // QueueHead->PhysicalAddr = QueueHeadPhysicalAddress.LowPart; + // + // output queue head + // + *OutQueueHead = QueueHead; + // // done //