Author: mjmartin
Date: Sun Apr 17 22:06:20 2011
New Revision: 51386
URL:
http://svn.reactos.org/svn/reactos?rev=51386&view=rev
Log:
[USBEHCI_NEW]
- Update interfaces with new methods needed for UsbHardWare class.
- Remove GetDmaMemoryManager as the DmaMemory will only be needed by UsbQueue class.
- GetDeviceDetails: Only fill in a parameter if its not null.
- Start implementing UsbQueue class.
Added:
branches/usb-bringup/drivers/usb/usbehci_new/usb_queue.cpp (with props)
Modified:
branches/usb-bringup/drivers/usb/usbehci_new/CMakeLists.txt
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/usbehci.h
Modified: branches/usb-bringup/drivers/usb/usbehci_new/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci…
==============================================================================
--- branches/usb-bringup/drivers/usb/usbehci_new/CMakeLists.txt [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbehci_new/CMakeLists.txt [iso-8859-1] Sun Apr 17
22:06:20 2011
@@ -7,6 +7,7 @@
add_library(usbehci SHARED
usbehci.cpp
usb_device.cpp
+ usb_queue.cpp
hcd_controller.cpp
hardware.cpp
misc.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] Sun Apr 17
22:06:20 2011
@@ -52,12 +52,17 @@
NTSTATUS PnpStop(void);
NTSTATUS HandlePower(PIRP Irp);
NTSTATUS GetDeviceDetails(PUSHORT VendorId, PUSHORT DeviceId, PULONG NumberOfPorts,
PULONG Speed);
- NTSTATUS GetDmaMemoryManager(OUT struct IDMAMemoryManager **OutMemoryManager);
+ NTSTATUS GetDmaAdapter(OUT PDMA_ADAPTER AdapterObject);
NTSTATUS GetUSBQueue(OUT struct IUSBQueue **OutUsbQueue);
+
NTSTATUS StartController();
NTSTATUS StopController();
NTSTATUS ResetController();
NTSTATUS ResetPort(ULONG PortIndex);
+
+ VOID SetAsyncListAddressRegister(ULONG PhysicalAddress);
+ VOID SetPeriodicListRegister(ULONG PhysicalAddress);
+
KIRQL AcquireDeviceLock(void);
VOID ReleaseDeviceLock(KIRQL OldLevel);
// local
@@ -83,10 +88,10 @@
PULONG m_Base;
PDMA_ADAPTER m_Adapter;
ULONG m_MapRegisters;
- PQUEUE_HEAD m_AsyncListQueueHead;
EHCI_CAPS m_Capabilities;
USHORT m_VendorID;
USHORT m_DeviceID;
+ PUSBQUEUE m_UsbQueue;
VOID SetCommandRegister(PEHCI_USBCMD_CONTENT UsbCmd);
VOID GetCommandRegister(PEHCI_USBCMD_CONTENT UsbCmd);
@@ -127,6 +132,12 @@
DPRINT1("CUSBHardwareDevice::Initialize\n");
+ Status = CreateUSBQueue(&m_UsbQueue);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Failed to create UsbQueue!\n");
+ return Status;
+ }
//
// store device objects
//
@@ -322,11 +333,6 @@
}
//
- // FIXME: Create a QueueHead that will always be the address of the AsyncList
- //
- m_AsyncListQueueHead = NULL;
-
- //
// Start the controller
//
DPRINT1("Starting Controller\n");
@@ -355,20 +361,16 @@
OUT OPTIONAL PULONG NumberOfPorts,
OUT OPTIONAL PULONG Speed)
{
- *VendorId = m_VendorID;
- *DeviceId = m_DeviceID;
- *NumberOfPorts = m_Capabilities.HCSParams.PortCount;
+ if (VendorId)
+ *VendorId = m_VendorID;
+ if (DeviceId)
+ *DeviceId = m_DeviceID;
+ if (NumberOfPorts)
+ *NumberOfPorts = m_Capabilities.HCSParams.PortCount;
//FIXME: What to returned here?
- *Speed = 0;
+ if (Speed)
+ *Speed = 0;
return STATUS_SUCCESS;
-}
-
-NTSTATUS
-CUSBHardwareDevice::GetDmaMemoryManager(
- OUT struct IDMAMemoryManager **OutMemoryManager)
-{
- UNIMPLEMENTED
- return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
@@ -563,6 +565,30 @@
return STATUS_SUCCESS;
}
+//-----------------------------------------------------------------------------------------
+//
+// SetAsyncListAddressRegister
+//
+// Description: this functions sets the register to a address that is the physical
address of a QueueHead.
+// This is the location at which the controller will start executing the Asynchronous
Schedule.
+//
+VOID CUSBHardwareDevice::SetAsyncListAddressRegister(ULONG PhysicalAddress)
+{
+ EHCI_WRITE_REGISTER_ULONG(EHCI_ASYNCLISTBASE, PhysicalAddress);
+}
+
+//-----------------------------------------------------------------------------------------
+//
+// SetPeriodicListRegister
+//
+// Description: this functions sets the register to a address that is the physical
address of a ???.
+// This is the location at which the controller will start executing the Periodic
Schedule.
+//
+VOID CUSBHardwareDevice::SetPeriodicListRegister(ULONG PhysicalAddress)
+{
+ EHCI_WRITE_REGISTER_ULONG(EHCI_PERIODICLISTBASE, PhysicalAddress);
+}
+
KIRQL
CUSBHardwareDevice::AcquireDeviceLock(void)
{
@@ -642,14 +668,15 @@
IN PVOID SystemArgument2)
{
CUSBHardwareDevice *This;
- ULONG CStatus, PortStatus, i;
+ ULONG CStatus, PortStatus, PortCount, i;
This = (CUSBHardwareDevice*) SystemArgument1;
CStatus = (ULONG) SystemArgument2;
+ This->GetDeviceDetails(NULL, NULL, &PortCount, NULL);
if (CStatus & EHCI_STS_PCD)
{
- for (i = 0; i < This->m_Capabilities.HCSParams.PortCount; i++)
+ for (i = 0; i < PortCount; i++)
{
PortStatus = This->EHCI_READ_REGISTER_ULONG(EHCI_PORTSC + (4 * i));
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] Sun Apr 17
22:06:20 2011
@@ -164,16 +164,6 @@
//-----------------------------------------------------------------------------------------
//
-// GetDmaMemoryManager
-//
-// Description: returns interface to DMAMemoryManager
-// Interface is reference counted, you need to call Release method when you are done with
it
-// Do not call Initialize on IDMAMemoryManager, the object is already initialized
-
- virtual NTSTATUS GetDmaMemoryManager(OUT struct IDMAMemoryManager **OutMemoryManager)
= 0;
-
-//-----------------------------------------------------------------------------------------
-//
// GetUSBQueue
//
// Description: returns interface to internal IUSBQueue
@@ -190,6 +180,26 @@
// Returns STATUS_SUCCESS when the controller was successfully reset
virtual NTSTATUS ResetController() = 0;
+
+//-----------------------------------------------------------------------------------------
+//
+// StartController
+//
+// Description: this functions starts controller allowing interrupts for device
connects/removal, and execution of
+// Periodic and Asynchronous Schedules.
+//
+
+ virtual NTSTATUS StartController() = 0;
+
+//-----------------------------------------------------------------------------------------
+//
+// StopController
+//
+// Description: this functions stops controller disabling interrupts for device
connects/removal, and execution of
+// Periodic and Asynchronous Schedules.
+//
+
+ virtual NTSTATUS StopController() = 0;
//-----------------------------------------------------------------------------------------
//
@@ -364,8 +374,8 @@
// Description: initializes the object
virtual NTSTATUS Initialize(IN PUSBHARDWAREDEVICE Hardware,
- IN OPTIONAL PKSPIN_LOCK Lock,
- IN PDMAMEMORYMANAGER MemoryManager) = 0;
+ PADAPTER_OBJECT AdapterObject,
+ IN OPTIONAL PKSPIN_LOCK Lock) = 0;
//-----------------------------------------------------------------------------------------
//
@@ -383,7 +393,7 @@
// Returns status success when successful
virtual NTSTATUS AddUSBRequest(IUSBRequest * Request) = 0;
-
+ virtual NTSTATUS AddUSBRequest(PURB Urb) = 0;
//-----------------------------------------------------------------------------------------
//
// CancelRequests()
Added: 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 (added)
+++ branches/usb-bringup/drivers/usb/usbehci_new/usb_queue.cpp [iso-8859-1] Sun Apr 17
22:06:20 2011
@@ -1,0 +1,165 @@
+/*
+ * PROJECT: ReactOS Universal Serial Bus Bulk Enhanced Host Controller Interface
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: drivers/usb/usbehci/usb_queue.cpp
+ * PURPOSE: USB EHCI device driver.
+ * PROGRAMMERS:
+ * Michael Martin (michael.martin(a)reactos.org)
+ * Johannes Anderwald (johannes.anderwald(a)reactos.org)
+ */
+
+#include "usbehci.h"
+#include "hardware.h"
+
+class CUSBQueue : public IUSBQueue
+{
+public:
+ STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface);
+
+ STDMETHODIMP_(ULONG) AddRef()
+ {
+ InterlockedIncrement(&m_Ref);
+ return m_Ref;
+ }
+ STDMETHODIMP_(ULONG) Release()
+ {
+ InterlockedDecrement(&m_Ref);
+
+ if (!m_Ref)
+ {
+ delete this;
+ return 0;
+ }
+ return m_Ref;
+ }
+
+ NTSTATUS Initialize(IN PUSBHARDWAREDEVICE Hardware, PADAPTER_OBJECT AdapterObject, IN
OPTIONAL PKSPIN_LOCK Lock);
+ ULONG GetPendingRequestCount();
+ NTSTATUS AddUSBRequest(PURB Urb);
+ NTSTATUS AddUSBRequest(IUSBRequest * Request);
+ NTSTATUS CancelRequests();
+ NTSTATUS CreateUSBRequest(IUSBRequest **OutRequest);
+
+ // constructor / destructor
+ CUSBQueue(IUnknown *OuterUnknown){}
+ virtual ~CUSBQueue(){}
+
+protected:
+ LONG m_Ref;
+ PDMA_ADAPTER m_Adapter;
+ PQUEUE_HEAD ExecutingList;
+ PQUEUE_HEAD PendingList;
+ IDMAMemoryManager *m_MemoryManager;
+};
+
+//=================================================================================================
+// COM
+//
+NTSTATUS
+STDMETHODCALLTYPE
+CUSBQueue::QueryInterface(
+ IN REFIID refiid,
+ OUT PVOID* Output)
+{
+ if (IsEqualGUIDAligned(refiid, IID_IUnknown))
+ {
+ *Output = PVOID(PUNKNOWN(this));
+ PUNKNOWN(*Output)->AddRef();
+ return STATUS_SUCCESS;
+ }
+
+ return STATUS_UNSUCCESSFUL;
+}
+
+NTSTATUS
+CUSBQueue::Initialize(
+ IN PUSBHARDWAREDEVICE Hardware,
+ PADAPTER_OBJECT AdapterObject,
+ IN OPTIONAL PKSPIN_LOCK Lock)
+{
+ NTSTATUS Status;
+
+ ASSERT(Hardware);
+ ASSERT(AdapterObject);
+
+ Status = CreateDMAMemoryManager(&m_MemoryManager);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Failed to create DMAMemoryManager Object\n");
+ return Status;
+ }
+
+ return STATUS_SUCCESS;
+}
+
+ULONG
+CUSBQueue::GetPendingRequestCount()
+{
+ UNIMPLEMENTED
+ return 0;
+}
+
+NTSTATUS
+CUSBQueue::AddUSBRequest(
+ IUSBRequest * Request)
+{
+ UNIMPLEMENTED
+ return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+CUSBQueue::AddUSBRequest(
+ PURB Urb)
+{
+ UNIMPLEMENTED
+ return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+CUSBQueue::CancelRequests()
+{
+ UNIMPLEMENTED
+ return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+CUSBQueue::CreateUSBRequest(
+ IUSBRequest **OutRequest)
+{
+ UNIMPLEMENTED
+ return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+CreateUSBQueue(
+ PUSBQUEUE *OutUsbQueue)
+{
+ PUSBQUEUE This;
+
+ //
+ // allocate controller
+ //
+ This = new(NonPagedPool, TAG_USBEHCI) CUSBQueue(0);
+ if (!This)
+ {
+ //
+ // failed to allocate
+ //
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ //
+ // add reference count
+ //
+ This->AddRef();
+
+ //
+ // return result
+ //
+ *OutUsbQueue = (PUSBQUEUE)This;
+
+ //
+ // done
+ //
+ return STATUS_SUCCESS;
+}
Propchange: branches/usb-bringup/drivers/usb/usbehci_new/usb_queue.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Modified: branches/usb-bringup/drivers/usb/usbehci_new/usbehci.h
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci…
==============================================================================
--- branches/usb-bringup/drivers/usb/usbehci_new/usbehci.h [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbehci_new/usbehci.h [iso-8859-1] Sun Apr 17
22:06:20 2011
@@ -72,4 +72,9 @@
//
NTSTATUS CreateUSBDevice(PUSBDEVICE *OutDevice);
+//
+// usb_queue.cpp
+//
+NTSTATUS CreateUSBQueue(PUSBQUEUE *OutUsbQueue);
+
#endif