Author: janderwald
Date: Thu Apr 28 15:16:33 2011
New Revision: 51476
URL:
http://svn.reactos.org/svn/reactos?rev=51476&view=rev
Log:
[USBEHCI_NEW]
- Change interface to return real async queue head
- Set the async queue head register after the controller has been started
- Enable async queue in StartController
- Port DumpDeviceDescriptor from mjmartin usbehci driver
- Remove pseudo queue head from usb queue, instead use the real async queue head exported
from IUSBHardwareDevice
- Get physical address for transfer data in BuildControlTransferQueueHead
- Retrieving device descriptor now ~works, currently stops at setting device address
(needs more work)
Modified:
branches/usb-bringup/drivers/usb/usbehci_new/hardware.cpp
branches/usb-bringup/drivers/usb/usbehci_new/interfaces.h
branches/usb-bringup/drivers/usb/usbehci_new/usb_device.cpp
branches/usb-bringup/drivers/usb/usbehci_new/usb_queue.cpp
branches/usb-bringup/drivers/usb/usbehci_new/usb_request.cpp
Modified: branches/usb-bringup/drivers/usb/usbehci_new/hardware.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci…
==============================================================================
--- branches/usb-bringup/drivers/usb/usbehci_new/hardware.cpp [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbehci_new/hardware.cpp [iso-8859-1] Thu Apr 28
15:16:33 2011
@@ -68,7 +68,7 @@
VOID SetAsyncListRegister(ULONG PhysicalAddress);
VOID SetPeriodicListRegister(ULONG PhysicalAddress);
- ULONG GetAsyncListRegister();
+ struct _QUEUE_HEAD * GetAsyncListQueueHead();
ULONG GetPeriodicListRegister();
VOID SetStatusChangeEndpointCallBack(PVOID CallBack, PVOID Context);
@@ -423,8 +423,6 @@
InitializeListHead(&AsyncQueueHead->LinkedQueueHeads);
- SetAsyncListRegister(AsyncQueueHead->PhysicalAddr);
-
//
// Initialize the UsbQueue now that we have an AdapterObject.
//
@@ -439,7 +437,24 @@
// Start the controller
//
DPRINT1("Starting Controller\n");
- return StartController();
+ Status = StartController();
+
+ //
+ // check for success
+ //
+ if (NT_SUCCESS(Status))
+ {
+ //
+ // set async list head
+ //
+ SetAsyncListRegister(AsyncQueueHead->PhysicalAddr);
+ }
+
+
+ //
+ // done
+ //
+ return Status;
}
NTSTATUS
@@ -553,7 +568,7 @@
//
GetCommandRegister(&UsbCmd);
UsbCmd.PeriodicEnable = FALSE;
- UsbCmd.AsyncEnable = FALSE; //FIXME: Need USB Memory Manager
+ UsbCmd.AsyncEnable = TRUE; //FIXME: Need USB Memory Manager
UsbCmd.IntThreshold = 1;
// FIXME: Set framelistsize when periodic is implemented.
@@ -876,10 +891,10 @@
EHCI_WRITE_REGISTER_ULONG(EHCI_PERIODICLISTBASE, PhysicalAddress);
}
-ULONG
-CUSBHardwareDevice::GetAsyncListRegister()
-{
- return AsyncQueueHead->PhysicalAddr;
+struct _QUEUE_HEAD *
+CUSBHardwareDevice::GetAsyncListQueueHead()
+{
+ return AsyncQueueHead;
}
ULONG CUSBHardwareDevice::GetPeriodicListRegister()
@@ -994,6 +1009,7 @@
// controller reported error
//
Status = STATUS_UNSUCCESSFUL;
+ PC_ASSERT(FALSE);
}
//
Modified: branches/usb-bringup/drivers/usb/usbehci_new/interfaces.h
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci…
==============================================================================
--- 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
15:16:33 2011
@@ -268,7 +268,7 @@
//
// Description: Returns the memory address used in the Asynchronous Register
//
- virtual ULONG GetAsyncListRegister() = 0;
+ virtual struct _QUEUE_HEAD * GetAsyncListQueueHead() = 0;
//-----------------------------------------------------------------------------------------
//
Modified: branches/usb-bringup/drivers/usb/usbehci_new/usb_device.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci…
==============================================================================
--- 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
15:16:33 2011
@@ -73,6 +73,7 @@
virtual NTSTATUS CommitSetupPacket(PUSB_DEFAULT_PIPE_SETUP_PACKET Packet, IN ULONG
BufferLength, IN OUT PMDL Mdl);
virtual NTSTATUS CreateConfigurationDescriptor(ULONG ConfigurationIndex);
virtual NTSTATUS CreateDeviceDescriptor();
+ virtual VOID DumpDeviceDescriptor(PUSB_DEVICE_DESCRIPTOR DeviceDescriptor);
// constructor / destructor
CUSBDevice(IUnknown *OuterUnknown){}
@@ -343,6 +344,11 @@
}
//
+ // lets have a short nap
+ //
+ KeStallExecutionProcessor(300);
+
+ //
// back up old address
//
OldAddress = m_DeviceAddress;
@@ -369,6 +375,8 @@
//
return Status;
}
+
+ PC_ASSERT(FALSE);
//
// sanity checks
@@ -628,6 +636,14 @@
// now free the mdl
//
IoFreeMdl(Mdl);
+
+ if (NT_SUCCESS(Status))
+ {
+ //
+ // informal dbg print
+ //
+ DumpDeviceDescriptor(&m_DeviceDescriptor);
+ }
//
// done
@@ -866,6 +882,26 @@
}
+VOID
+CUSBDevice::DumpDeviceDescriptor(PUSB_DEVICE_DESCRIPTOR DeviceDescriptor)
+{
+ DPRINT1("Dumping Device Descriptor %x\n", DeviceDescriptor);
+ DPRINT1("bLength %x\n", DeviceDescriptor->bLength);
+ DPRINT1("bDescriptorType %x\n", DeviceDescriptor->bDescriptorType);
+ DPRINT1("bcdUSB %x\n", DeviceDescriptor->bcdUSB);
+ DPRINT1("bDeviceClass %x\n", DeviceDescriptor->bDeviceClass);
+ DPRINT1("bDeviceSubClass %x\n", DeviceDescriptor->bDeviceSubClass);
+ DPRINT1("bDeviceProtocol %x\n", DeviceDescriptor->bDeviceProtocol);
+ DPRINT1("bMaxPacketSize0 %x\n", DeviceDescriptor->bMaxPacketSize0);
+ DPRINT1("idVendor %x\n", DeviceDescriptor->idVendor);
+ DPRINT1("idProduct %x\n", DeviceDescriptor->idProduct);
+ DPRINT1("bcdDevice %x\n", DeviceDescriptor->bcdDevice);
+ DPRINT1("iManufacturer %x\n", DeviceDescriptor->iManufacturer);
+ DPRINT1("iProduct %x\n", DeviceDescriptor->iProduct);
+ DPRINT1("iSerialNumber %x\n", DeviceDescriptor->iSerialNumber);
+ DPRINT1("bNumConfigurations %x\n",
DeviceDescriptor->bNumConfigurations);
+}
+
//----------------------------------------------------------------------------------------
NTSTATUS
CreateUSBDevice(
Modified: branches/usb-bringup/drivers/usb/usbehci_new/usb_queue.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci…
==============================================================================
--- branches/usb-bringup/drivers/usb/usbehci_new/usb_queue.cpp [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbehci_new/usb_queue.cpp [iso-8859-1] Thu Apr 28
15:16:33 2011
@@ -51,7 +51,6 @@
KSPIN_LOCK m_Lock;
PDMA_ADAPTER m_Adapter;
PQUEUE_HEAD AsyncListQueueHead;
- PQUEUE_HEAD PendingListQueueHead;
LIST_ENTRY m_CompletedRequestAsyncList;
// queue head manipulation functions
@@ -109,33 +108,17 @@
//
// Get the AsyncQueueHead
//
- AsyncListQueueHead = (PQUEUE_HEAD)Hardware->GetAsyncListRegister();
-
- //
- // Create the PendingListQueueHead from NONPAGEDPOOL. It will never be linked into
the Asynclist Schedule
- //
- PendingListQueueHead = (PQUEUE_HEAD)ExAllocatePoolWithTag(NonPagedPool,
sizeof(QUEUE_HEAD), TAG_USBEHCI);
- if (!PendingListQueueHead)
- {
- DPRINT1("Pool Allocation failed!\n");
- return STATUS_INSUFFICIENT_RESOURCES;
- }
+ AsyncListQueueHead = (PQUEUE_HEAD)Hardware->GetAsyncListQueueHead();
//
// Initialize the List Head
//
- InitializeListHead(&PendingListQueueHead->LinkedQueueHeads);
-
- //
- // fake the queue head as the first queue head
- //
- PendingListQueueHead->PhysicalAddr = ((ULONG_PTR)AsyncListQueueHead |
QH_TYPE_QH);
+ InitializeListHead(&AsyncListQueueHead->LinkedQueueHeads);
//
// Initialize completed async list head
//
InitializeListHead(&m_CompletedRequestAsyncList);
-
return Status;
}
@@ -223,7 +206,7 @@
//
// Add it to the pending list
//
- LinkQueueHead(PendingListQueueHead, QueueHead);
+ LinkQueueHead(AsyncListQueueHead, QueueHead);
}
@@ -300,7 +283,7 @@
Entry = NewQueueHead->LinkedQueueHeads.Flink;
NextQueueHead = CONTAINING_RECORD(Entry, QUEUE_HEAD, LinkedQueueHeads);
ASSERT(NextQueueHead == HeadQueueHead);
- NewQueueHead->HorizontalLinkPointer = NextQueueHead->PhysicalAddr;
+ NewQueueHead->HorizontalLinkPointer = (NextQueueHead->PhysicalAddr |
QH_TYPE_QH);
}
//
@@ -520,7 +503,7 @@
//
// add to pending list
//
- LinkQueueHead(PendingListQueueHead, NewQueueHead);
+ LinkQueueHead(AsyncListQueueHead, NewQueueHead);
}
else
{
@@ -549,9 +532,9 @@
//
// walk async list
//
- Entry = PendingListQueueHead->LinkedQueueHeads.Flink;
-
- while(Entry != &PendingListQueueHead->LinkedQueueHeads)
+ Entry = AsyncListQueueHead->LinkedQueueHeads.Flink;
+
+ while(Entry != &AsyncListQueueHead->LinkedQueueHeads)
{
//
// get queue head structure
@@ -573,6 +556,8 @@
// move to next entry
//
Entry = Entry->Flink;
+
+ DPRINT1("Request %p QueueHead %p Complete %d\n", Request, QueueHead,
Request->IsQueueHeadComplete(QueueHead));
//
// check if queue head is complete
@@ -604,6 +589,9 @@
IN NTSTATUS Status,
OUT PULONG ShouldRingDoorBell)
{
+
+ DPRINT1("CUSBQueue::InterruptCallback\n");
+
//
// iterate asynchronous list
//
@@ -671,6 +659,8 @@
PLIST_ENTRY Entry;
PQUEUE_HEAD CurrentQH;
+ DPRINT1("CUSBQueue::CompleteAsyncRequests\n");
+
//
// first acquire request lock
//
Modified: branches/usb-bringup/drivers/usb/usbehci_new/usb_request.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci…
==============================================================================
--- branches/usb-bringup/drivers/usb/usbehci_new/usb_request.cpp [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbehci_new/usb_request.cpp [iso-8859-1] Thu Apr 28
15:16:33 2011
@@ -604,6 +604,12 @@
m_TransferDescriptors[1]->Token.Bits.TotalBytesToTransfer =
m_TransferBufferLength;
//
+ // FIXME: check if the request spawns over a page -> fill other members
+ //
+ PC_ASSERT(m_TransferBufferLength <= PAGE_SIZE);
+ m_TransferDescriptors[1]->BufferPointer[0] =
MmGetPhysicalAddress(MmGetMdlVirtualAddress(m_TransferBufferMDL)).LowPart;
+
+ //
// setup out descriptor
//
m_TransferDescriptors[2]->Token.Bits.PIDCode = PID_CODE_OUT_TOKEN;
@@ -845,12 +851,11 @@
CUSBRequest::BuildSetupPacket()
{
NTSTATUS Status;
- PHYSICAL_ADDRESS PhysicalAddress;
//
// allocate common buffer setup packet
//
- Status = m_DmaManager->Allocate(sizeof(USB_DEFAULT_PIPE_SETUP_PACKET),
(PVOID*)&m_DescriptorPacket, &PhysicalAddress);
+ Status = m_DmaManager->Allocate(sizeof(USB_DEFAULT_PIPE_SETUP_PACKET),
(PVOID*)&m_DescriptorPacket, &m_DescriptorSetupPacket);
if (!NT_SUCCESS(Status))
{
//
@@ -865,7 +870,6 @@
// copy setup packet
//
RtlCopyMemory(m_DescriptorPacket, m_SetupPacket,
sizeof(USB_DEFAULT_PIPE_SETUP_PACKET));
- m_DescriptorSetupPacket = PhysicalAddress;
}
else
{