[USBUHCI]

- OHCI -> UHCI
- Implement timer routine which checks for new detected devices. In case a port change is detected, the sce callback routine is invoked

svn path=/trunk/; revision=55828
This commit is contained in:
Johannes Anderwald 2012-02-23 01:27:19 +00:00
parent a982c0c4c9
commit 3d22956ff8
11 changed files with 131 additions and 66 deletions

View file

@ -1,8 +1,8 @@
/*
* PROJECT: ReactOS Universal Serial Bus Bulk Enhanced Host Controller Interface
* PROJECT: ReactOS Universal Serial Bus Host Controller Interface
* LICENSE: GPL - See COPYING in the top level directory
* FILE: drivers/usb/usbohci/hcd_controller.cpp
* PURPOSE: USB OHCI device driver.
* FILE: drivers/usb/usbuhci/hcd_controller.cpp
* PURPOSE: USB UHCI device driver.
* PROGRAMMERS:
* Michael Martin (michael.martin@reactos.org)
* Johannes Anderwald (johannes.anderwald@reactos.org)
@ -22,16 +22,27 @@ InterruptServiceRoutine(
VOID
NTAPI
OhciDefferedRoutine(
UhciDefferedRoutine(
IN PKDPC Dpc,
IN PVOID DeferredContext,
IN PVOID SystemArgument1,
IN PVOID SystemArgument2);
VOID
NTAPI
TimerDpcRoutine(
IN PKDPC Dpc,
IN PVOID DeferredContext,
IN PVOID SystemArgument1,
IN PVOID SystemArgument2);
VOID
NTAPI
StatusChangeWorkItemRoutine(PVOID Context);
class CUSBHardwareDevice : public IUSBHardwareDevice
{
public:
@ -86,7 +97,8 @@ public:
// friend function
friend BOOLEAN NTAPI InterruptServiceRoutine(IN PKINTERRUPT Interrupt, IN PVOID ServiceContext);
friend VOID NTAPI OhciDefferedRoutine(IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2);
friend VOID NTAPI UhciDefferedRoutine(IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2);
friend VOID NTAPI TimerDpcRoutine(IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2);
friend VOID NTAPI StatusChangeWorkItemRoutine(PVOID Context);
VOID WriteRegister8(IN ULONG Register, IN UCHAR value);
VOID WriteRegister16(ULONG Register, USHORT Value);
@ -120,7 +132,7 @@ protected:
PDMAMEMORYMANAGER m_MemoryManager; // memory manager
HD_INIT_CALLBACK* m_SCECallBack; // status change callback routine
PVOID m_SCEContext; // status change callback routine context
WORK_QUEUE_ITEM m_StatusChangeWorkItem; // work item for status change callback
//WORK_QUEUE_ITEM m_StatusChangeWorkItem; // work item for status change callback
ULONG m_InterruptMask; // interrupt enabled mask
ULONG m_PortResetChange; // port reset status
PULONG m_FrameList; // frame list
@ -129,6 +141,8 @@ protected:
PUHCI_QUEUE_HEAD m_QueueHead[5]; // queue heads
PHYSICAL_ADDRESS m_StrayDescriptorPhysicalAddress; // physical address stray descriptor
PUHCI_TRANSFER_DESCRIPTOR m_StrayDescriptor; // stray descriptor
KTIMER m_SCETimer; // SCE timer
KDPC m_SCETimerDpc; // timer dpc
};
//=================================================================================================
@ -200,7 +214,15 @@ CUSBHardwareDevice::Initialize(
//
// intialize status change work item
//
ExInitializeWorkItem(&m_StatusChangeWorkItem, StatusChangeWorkItemRoutine, PVOID(this));
//ExInitializeWorkItem(&m_StatusChangeWorkItem, StatusChangeWorkItemRoutine, PVOID(this));
// initialize timer
KeInitializeTimer(&m_SCETimer);
// initialize timer dpc
KeInitializeDpc(&m_SCETimerDpc, TimerDpcRoutine, PVOID(this));
m_VendorID = 0;
m_DeviceID = 0;
@ -258,7 +280,7 @@ CUSBHardwareDevice::PnpStart(
case CmResourceTypeInterrupt:
{
KeInitializeDpc(&m_IntDpcObject,
OhciDefferedRoutine,
UhciDefferedRoutine,
this);
Status = IoConnectInterrupt(&m_Interrupt,
@ -538,6 +560,13 @@ CUSBHardwareDevice::StartController(void)
DPRINT1("[USBUHCI] Controller Port Status 0 %x\n", ReadRegister16(UHCI_PORTSC1));
DPRINT1("[USBUHCI] Controller Port Status 1 %x\n", ReadRegister16(UHCI_PORTSC1 + 2));
// queue timer
LARGE_INTEGER Expires;
Expires.QuadPart = -10 * 10000;
KeSetTimerEx(&m_SCETimer, Expires, 1000, &m_SCETimerDpc);
//
// done
//
@ -979,8 +1008,9 @@ CUSBHardwareDevice::ResetPort(
}
m_PortResetChange |= (1 << PortIndex);
DPRINT1("[USBOHCI] Port Index %x Status after reset %x\n", PortIndex, ReadRegister16(Port));
DPRINT1("[USBUhci] Port Index %x Status after reset %x\n", PortIndex, ReadRegister16(Port));
#if 0
if (Status & UHCI_PORTSC_CURSTAT)
{
//
@ -989,6 +1019,7 @@ CUSBHardwareDevice::ResetPort(
DPRINT1("Queueing work item\n");
ExQueueWorkItem(&m_StatusChangeWorkItem, DelayedWorkQueue);
}
#endif
return STATUS_SUCCESS;
}
@ -1023,7 +1054,7 @@ CUSBHardwareDevice::GetPortStatus(
// read port status
//
Status = ReadRegister16(UHCI_PORTSC1 + PortId * 2);
DPRINT1("[USBUHCI] PortId %x Status %x\n", PortId, Status);
DPRINT("[USBUHCI] PortId %x Status %x\n", PortId, Status);
// build the status
if (Status & UHCI_PORTSC_CURSTAT)
@ -1398,7 +1429,7 @@ CUSBHardwareDevice::GetQueueHead(
VOID
NTAPI
OhciDefferedRoutine(
UhciDefferedRoutine(
IN PKDPC Dpc,
IN PVOID DeferredContext,
IN PVOID SystemArgument1,
@ -1412,7 +1443,7 @@ OhciDefferedRoutine(
//
This = (CUSBHardwareDevice*)DeferredContext;
DPRINT("OhciDefferedRoutine\n");
DPRINT("UhciDefferedRoutine\n");
//
// get status
@ -1433,6 +1464,40 @@ OhciDefferedRoutine(
DPRINT1("[USBUHCI] Status %x not handled\n", Status);
}
VOID
NTAPI
TimerDpcRoutine(
IN PKDPC Dpc,
IN PVOID DeferredContext,
IN PVOID SystemArgument1,
IN PVOID SystemArgument2)
{
CUSBHardwareDevice *This;
USHORT PortStatus = 0;
USHORT PortChange = 0;
// get parameters
This = (CUSBHardwareDevice*)DeferredContext;
// check port 0
This->GetPortStatus(0, &PortStatus, &PortChange);
if (PortChange)
{
// invoke status change work item routine
StatusChangeWorkItemRoutine(DeferredContext);
return;
}
// check port 1
This->GetPortStatus(1, &PortStatus, &PortChange);
if (PortChange)
{
// invoke status change work item routine
StatusChangeWorkItemRoutine(DeferredContext);
}
}
VOID
NTAPI
StatusChangeWorkItemRoutine(
@ -1462,7 +1527,7 @@ CreateUSBHardware(
{
PUSBHARDWAREDEVICE This;
This = new(NonPagedPool, TAG_USBOHCI) CUSBHardwareDevice(0);
This = new(NonPagedPool, TAG_USBUHCI) CUSBHardwareDevice(0);
if (!This)
return STATUS_INSUFFICIENT_RESOURCES;

View file

@ -1,8 +1,8 @@
/*
* PROJECT: ReactOS Universal Serial Bus Bulk Enhanced Host Controller Interface
* PROJECT: ReactOS Universal Serial Bus Host Controller Interface
* LICENSE: GPL - See COPYING in the top level directory
* FILE: drivers/usb/usbohci/hcd_controller.cpp
* PURPOSE: USB OHCI device driver.
* FILE: drivers/usb/usbuhci/hcd_controller.cpp
* PURPOSE: USB UHCI device driver.
* PROGRAMMERS:
* Michael Martin (michael.martin@reactos.org)
* Johannes Anderwald (johannes.anderwald@reactos.org)
@ -755,7 +755,7 @@ CreateHCDController(
//
// allocate controller
//
This = new(NonPagedPool, TAG_USBOHCI) CHCDController(0);
This = new(NonPagedPool, TAG_USBUHCI) CHCDController(0);
if (!This)
{
//

View file

@ -1,8 +1,8 @@
/*
* PROJECT: ReactOS Universal Serial Bus Bulk Enhanced Host Controller Interface
* PROJECT: ReactOS Universal Serial Bus Host Controller Interface
* LICENSE: GPL - See COPYING in the top level directory
* FILE: drivers/usb/usbohci/hub_controller.cpp
* PURPOSE: USB OHCI device driver.
* FILE: drivers/usb/usbuhci/hub_controller.cpp
* PURPOSE: USB UHCI device driver.
* PROGRAMMERS:
* Michael Martin (michael.martin@reactos.org)
* Johannes Anderwald (johannes.anderwald@reactos.org)
@ -209,7 +209,7 @@ CHubController::Initialize(
//
// allocate device address bitmap buffer
//
m_DeviceAddressBitmapBuffer = (PULONG)ExAllocatePoolWithTag(NonPagedPool, 16, TAG_USBOHCI);
m_DeviceAddressBitmapBuffer = (PULONG)ExAllocatePoolWithTag(NonPagedPool, 16, TAG_USBUHCI);
if (!m_DeviceAddressBitmapBuffer)
{
//
@ -484,7 +484,7 @@ CHubController::HandlePnp(
//
// allocate buffer
//
DeviceName = (LPWSTR)ExAllocatePoolWithTag(PagedPool, Length * sizeof(WCHAR), TAG_USBOHCI);
DeviceName = (LPWSTR)ExAllocatePoolWithTag(PagedPool, Length * sizeof(WCHAR), TAG_USBUHCI);
if (!DeviceName)
{
@ -556,7 +556,7 @@ CHubController::HandlePnp(
//
// allocate buffer
//
DeviceName = (LPWSTR)ExAllocatePoolWithTag(PagedPool, Index * sizeof(WCHAR), TAG_USBOHCI);
DeviceName = (LPWSTR)ExAllocatePoolWithTag(PagedPool, Index * sizeof(WCHAR), TAG_USBUHCI);
if (!DeviceName)
{
@ -664,7 +664,7 @@ CHubController::HandlePnp(
//
// allocate device relations
//
DeviceRelations = (PDEVICE_RELATIONS)ExAllocatePoolWithTag(PagedPool, sizeof(DEVICE_RELATIONS), TAG_USBOHCI);
DeviceRelations = (PDEVICE_RELATIONS)ExAllocatePoolWithTag(PagedPool, sizeof(DEVICE_RELATIONS), TAG_USBUHCI);
if (!DeviceRelations)
{
//
@ -1746,7 +1746,7 @@ CHubController::HandleSyncResetAndClearStall(
//
// abort pipe failed
//
DPRINT1("[USBOHCI] AbortPipe failed with %x\n", Status);
DPRINT1("[USBUHCI] AbortPipe failed with %x\n", Status);
}
//
@ -2288,7 +2288,7 @@ CHubController::RemoveUsbDevice(
//
// free entry
//
ExFreePoolWithTag(DeviceEntry, TAG_USBOHCI);
ExFreePoolWithTag(DeviceEntry, TAG_USBUHCI);
//
// done
@ -2383,7 +2383,7 @@ CHubController::AddUsbDevice(
//
// allocate device entry
//
DeviceEntry = (PUSBDEVICE_ENTRY)ExAllocatePoolWithTag(NonPagedPool, sizeof(USBDEVICE_ENTRY), TAG_USBOHCI);
DeviceEntry = (PUSBDEVICE_ENTRY)ExAllocatePoolWithTag(NonPagedPool, sizeof(USBDEVICE_ENTRY), TAG_USBUHCI);
if (!DeviceEntry)
{
//
@ -3693,7 +3693,7 @@ CreateHubController(
//
// allocate controller
//
This = new(NonPagedPool, TAG_USBOHCI) CHubController(0);
This = new(NonPagedPool, TAG_USBUHCI) CHubController(0);
if (!This)
{
//

View file

@ -1,8 +1,8 @@
/*
* PROJECT: ReactOS Universal Serial Bus Bulk Enhanced Host Controller Interface
* PROJECT: ReactOS Universal Serial Bus Host Controller Interface
* LICENSE: GPL - See COPYING in the top level directory
* FILE: drivers/usb/usbohci/memory_manager.cpp
* PURPOSE: USB OHCI device driver.
* FILE: drivers/usb/usbuhci/memory_manager.cpp
* PURPOSE: USB UHCI device driver.
* PROGRAMMERS:
* Michael Martin (michael.martin@reactos.org)
* Johannes Anderwald (johannes.anderwald@reactos.org)
@ -90,7 +90,7 @@ CDMAMemoryManager::Initialize(
//
// allocate bitmap buffer
//
m_BitmapBuffer = (PULONG)ExAllocatePoolWithTag(NonPagedPool, BitmapLength, TAG_USBOHCI);
m_BitmapBuffer = (PULONG)ExAllocatePoolWithTag(NonPagedPool, BitmapLength, TAG_USBUHCI);
if (!m_BitmapBuffer)
{
//
@ -342,7 +342,7 @@ CreateDMAMemoryManager(
//
// allocate controller
//
This = new(NonPagedPool, TAG_USBOHCI) CDMAMemoryManager(0);
This = new(NonPagedPool, TAG_USBUHCI) CDMAMemoryManager(0);
if (!This)
{
//

View file

@ -1,8 +1,8 @@
/*
* PROJECT: ReactOS Universal Serial Bus Bulk Enhanced Host Controller Interface
* PROJECT: ReactOS Universal Serial Bus Host Controller Interface
* LICENSE: GPL - See COPYING in the top level directory
* FILE: drivers/usb/usbohci/misc.cpp
* PURPOSE: USB OHCI device driver.
* FILE: drivers/usb/usbuhci/misc.cpp
* PURPOSE: USB UHCI device driver.
* PROGRAMMERS:
* Michael Martin (michael.martin@reactos.org)
* Johannes Anderwald (johannes.anderwald@reactos.org)

View file

@ -1,8 +1,8 @@
/*
* PROJECT: ReactOS Universal Serial Bus Bulk Enhanced Host Controller Interface
* PROJECT: ReactOS Universal Serial Bus Host Controller Interface
* LICENSE: GPL - See COPYING in the top level directory
* FILE: drivers/usb/usbohci/purecall.cpp
* PURPOSE: USB OHCI device driver.
* FILE: drivers/usb/usbuhci/purecall.cpp
* PURPOSE: USB UHCI device driver.
* PROGRAMMERS:
* Michael Martin (michael.martin@reactos.org)
* Johannes Anderwald (johannes.anderwald@reactos.org)

View file

@ -1,8 +1,8 @@
/*
* PROJECT: ReactOS Universal Serial Bus Bulk Enhanced Host Controller Interface
* PROJECT: ReactOS Universal Serial Bus Host Controller Interface
* LICENSE: GPL - See COPYING in the top level directory
* FILE: drivers/usb/usbohci/usb_device.cpp
* PURPOSE: USB OHCI device driver.
* FILE: drivers/usb/usbuhci/usb_device.cpp
* PURPOSE: USB UHCI device driver.
* PROGRAMMERS:
* Michael Martin (michael.martin@reactos.org)
* Johannes Anderwald (johannes.anderwald@reactos.org)
@ -115,7 +115,7 @@ CUSBDevice::~CUSBDevice()
// abort pipe
//
//Status = AbortPipe((PUSB_ENDPOINT_DESCRIPTOR)&m_ConfigurationDescriptors[Index].Interfaces[InterfaceIndex].EndPoints[EndpointIndex]);
//DPRINT1("[USBOHCI] Deleting Device Abort Pipe Status %x\n", Status);
//DPRINT1("[USBUHCI] Deleting Device Abort Pipe Status %x\n", Status);
}
if (m_ConfigurationDescriptors[Index].Interfaces[InterfaceIndex].InterfaceDescriptor.bNumEndpoints)
@ -373,7 +373,7 @@ CUSBDevice::SetDeviceAddress(
DPRINT1("CUSBDevice::SetDeviceAddress Address %d\n", DeviceAddress);
CtrlSetup = (PUSB_DEFAULT_PIPE_SETUP_PACKET)ExAllocatePoolWithTag(NonPagedPool, sizeof(USB_DEFAULT_PIPE_SETUP_PACKET), TAG_USBOHCI);
CtrlSetup = (PUSB_DEFAULT_PIPE_SETUP_PACKET)ExAllocatePoolWithTag(NonPagedPool, sizeof(USB_DEFAULT_PIPE_SETUP_PACKET), TAG_USBUHCI);
if (!CtrlSetup)
return STATUS_INSUFFICIENT_RESOURCES;
@ -396,7 +396,7 @@ CUSBDevice::SetDeviceAddress(
//
// free setup packet
//
ExFreePoolWithTag(CtrlSetup, TAG_USBOHCI);
ExFreePoolWithTag(CtrlSetup, TAG_USBUHCI);
//
// check for success
@ -451,7 +451,7 @@ CUSBDevice::SetDeviceAddress(
//
// allocate configuration descriptor
//
m_ConfigurationDescriptors = (PUSB_CONFIGURATION) ExAllocatePoolWithTag(NonPagedPool, sizeof(USB_CONFIGURATION) * m_DeviceDescriptor.bNumConfigurations, TAG_USBOHCI);
m_ConfigurationDescriptors = (PUSB_CONFIGURATION) ExAllocatePoolWithTag(NonPagedPool, sizeof(USB_CONFIGURATION) * m_DeviceDescriptor.bNumConfigurations, TAG_USBUHCI);
//
// zero configuration descriptor
@ -767,7 +767,7 @@ CUSBDevice::CreateConfigurationDescriptor(
//
// first allocate a buffer which should be enough to store all different interfaces and endpoints
//
Buffer = ExAllocatePoolWithTag(NonPagedPool, PAGE_SIZE, TAG_USBOHCI);
Buffer = ExAllocatePoolWithTag(NonPagedPool, PAGE_SIZE, TAG_USBUHCI);
if (!Buffer)
{
//
@ -798,7 +798,7 @@ CUSBDevice::CreateConfigurationDescriptor(
//
// failed to allocate mdl
//
ExFreePoolWithTag(Buffer, TAG_USBOHCI);
ExFreePoolWithTag(Buffer, TAG_USBUHCI);
return STATUS_INSUFFICIENT_RESOURCES;
}
@ -891,7 +891,7 @@ CUSBDevice::CreateConfigurationDescriptor(
//
// now allocate interface descriptors
//
m_ConfigurationDescriptors[Index].Interfaces = (PUSB_INTERFACE)ExAllocatePoolWithTag(NonPagedPool, sizeof(USB_INTERFACE) * ConfigurationDescriptor->bNumInterfaces, TAG_USBOHCI);
m_ConfigurationDescriptors[Index].Interfaces = (PUSB_INTERFACE)ExAllocatePoolWithTag(NonPagedPool, sizeof(USB_INTERFACE) * ConfigurationDescriptor->bNumInterfaces, TAG_USBUHCI);
if (!m_ConfigurationDescriptors[Index].Interfaces)
{
//
@ -940,7 +940,7 @@ CUSBDevice::CreateConfigurationDescriptor(
//
// allocate end point descriptors
//
m_ConfigurationDescriptors[Index].Interfaces[InterfaceIndex].EndPoints = (PUSB_ENDPOINT)ExAllocatePoolWithTag(NonPagedPool, sizeof(USB_ENDPOINT) * InterfaceDescriptor->bNumEndpoints, TAG_USBOHCI);
m_ConfigurationDescriptors[Index].Interfaces[InterfaceIndex].EndPoints = (PUSB_ENDPOINT)ExAllocatePoolWithTag(NonPagedPool, sizeof(USB_ENDPOINT) * InterfaceDescriptor->bNumEndpoints, TAG_USBUHCI);
if (!m_ConfigurationDescriptors[Index].Interfaces[InterfaceIndex].EndPoints)
{
//
@ -1408,7 +1408,7 @@ CreateUSBDevice(
//
// allocate controller
//
This = new(NonPagedPool, TAG_USBOHCI) CUSBDevice(0);
This = new(NonPagedPool, TAG_USBUHCI) CUSBDevice(0);
if (!This)
{
//

View file

@ -1,8 +1,8 @@
/*
* PROJECT: ReactOS Universal Serial Bus Bulk Enhanced Host Controller Interface
* PROJECT: ReactOS Universal Serial Bus Host Controller Interface
* LICENSE: GPL - See COPYING in the top level directory
* FILE: drivers/usb/usbohci/usb_queue.cpp
* PURPOSE: USB OHCI device driver.
* FILE: drivers/usb/usbuhci/usb_queue.cpp
* PURPOSE: USB UHCI device driver.
* PROGRAMMERS:
* Michael Martin (michael.martin@reactos.org)
* Johannes Anderwald (johannes.anderwald@reactos.org)
@ -544,7 +544,7 @@ CreateUSBQueue(
//
// allocate controller
//
This = new(NonPagedPool, TAG_USBOHCI) CUSBQueue(0);
This = new(NonPagedPool, TAG_USBUHCI) CUSBQueue(0);
if (!This)
{
//

View file

@ -1,8 +1,8 @@
/*
* PROJECT: ReactOS Universal Serial Bus Bulk Enhanced Host Controller Interface
* PROJECT: ReactOS Universal Serial Bus Host Controller Interface
* LICENSE: GPL - See COPYING in the top level directory
* FILE: drivers/usb/usbohci/usb_request.cpp
* PURPOSE: USB OHCI device driver.
* FILE: drivers/usb/usbuhci/usb_request.cpp
* PURPOSE: USB UHCI device driver.
* PROGRAMMERS:
* Michael Martin (michael.martin@reactos.org)
* Johannes Anderwald (johannes.anderwald@reactos.org)
@ -192,7 +192,7 @@ CUSBRequest::InitializeWithSetupPacket(
//
// allocate completion event
//
m_CompletionEvent = (PKEVENT)ExAllocatePoolWithTag(NonPagedPool, sizeof(KEVENT), TAG_USBOHCI);
m_CompletionEvent = (PKEVENT)ExAllocatePoolWithTag(NonPagedPool, sizeof(KEVENT), TAG_USBUHCI);
if (!m_CompletionEvent)
{
//
@ -1395,7 +1395,7 @@ InternalCreateUSBRequest(
//
// allocate requests
//
This = new(NonPagedPool, TAG_USBOHCI) CUSBRequest(0);
This = new(NonPagedPool, TAG_USBUHCI) CUSBRequest(0);
if (!This)
{
//

View file

@ -1,8 +1,8 @@
/*
* PROJECT: ReactOS Universal Serial Bus Bulk Enhanced Host Controller Interface
* PROJECT: ReactOS Universal Serial Bus Host Controller Interface
* LICENSE: GPL - See COPYING in the top level directory
* FILE: drivers/usb/usbohci/usbohci.cpp
* PURPOSE: USB OHCI device driver.
* FILE: drivers/usb/usbuhci/usbohci.cpp
* PURPOSE: USB UHCI device driver.
* PROGRAMMERS:
* Michael Martin (michael.martin@reactos.org)
* Johannes Anderwald (johannes.anderwald@reactos.org)

View file

@ -1,5 +1,5 @@
#ifndef USBOHCI_H__
#define USBOHCI_H__
#ifndef USBUHCI_H__
#define USBUHCI_H__
#include <ntddk.h>
#define NDEBUG
@ -56,7 +56,7 @@ typedef struct
//
// tag for allocations
//
#define TAG_USBOHCI 'ICHO'
#define TAG_USBUHCI 'ICHO'
//
// assert for c++ - taken from portcls