mirror of
https://github.com/reactos/reactos.git
synced 2025-05-18 16:51:18 +00:00
[usb/usbehci]
- Check the Interface GUID instead of only the version and size. - Handle up to USB_BUS_INTERFACE_USBDI_V2 and USB_BUS_INTERFACE_HUB_V5. Driver gets further in win2k. - Basic implementation of Direct Call Function CreateUsbDevice. - Fix GetRootHubSymbolicName to return RootHub20. - Change return status to not supported for functions not implemented yet. svn path=/trunk/; revision=46760
This commit is contained in:
parent
01f84db1d4
commit
56eef6c56d
2 changed files with 126 additions and 59 deletions
|
@ -17,6 +17,7 @@
|
|||
#include <wdmguid.h>
|
||||
#include <stdio.h>
|
||||
#include <debug.h>
|
||||
#include <guiddef.h>
|
||||
|
||||
/* Lifted from Linux with slight changes */
|
||||
const UCHAR ROOTHUB2_DEVICE_DESCRIPTOR [] =
|
||||
|
@ -98,7 +99,8 @@ UrbWorkerThread(PVOID Context)
|
|||
PVOID InternalCreateUsbDevice(UCHAR DeviceNumber, ULONG Port, PUSB_DEVICE Parent, BOOLEAN Hub)
|
||||
{
|
||||
PUSB_DEVICE UsbDevicePointer = NULL;
|
||||
UsbDevicePointer = ExAllocatePool(NonPagedPool, sizeof(USB_DEVICE));
|
||||
UsbDevicePointer = ExAllocatePoolWithTag(NonPagedPool, sizeof(USB_DEVICE), USB_POOL_TAG);
|
||||
|
||||
if (!UsbDevicePointer)
|
||||
{
|
||||
DPRINT1("Out of memory\n");
|
||||
|
@ -538,75 +540,132 @@ PdoDispatchPnp(
|
|||
case IRP_MN_QUERY_INTERFACE:
|
||||
{
|
||||
UNICODE_STRING GuidString;
|
||||
UNICODE_STRING InterfacMatchString;
|
||||
PUSB_BUS_INTERFACE_HUB_V5 InterfaceHub;
|
||||
PUSB_BUS_INTERFACE_USBDI_V2 InterfaceDI;
|
||||
PPDO_DEVICE_EXTENSION PdoDeviceExtension;
|
||||
PFDO_DEVICE_EXTENSION FdoDeviceExtension;
|
||||
NTSTATUS CompareStatus;
|
||||
|
||||
PdoDeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
FdoDeviceExtension = (PFDO_DEVICE_EXTENSION)PdoDeviceExtension->ControllerFdo->DeviceExtension;
|
||||
|
||||
Status = RtlStringFromGUID(Stack->Parameters.QueryInterface.InterfaceType, &GuidString);
|
||||
if (!NT_SUCCESS(Status))
|
||||
/* Assume success */
|
||||
Status = STATUS_SUCCESS;
|
||||
Information = 0;
|
||||
|
||||
CompareStatus = RtlStringFromGUID(Stack->Parameters.QueryInterface.InterfaceType, &GuidString);
|
||||
if (!NT_SUCCESS(CompareStatus))
|
||||
{
|
||||
DPRINT1("Failed to create string from GUID!\n");
|
||||
}
|
||||
|
||||
DPRINT1("Interface GUID requested %wZ\n", &GuidString);
|
||||
DPRINT1("QueryInterface.Size %x\n", Stack->Parameters.QueryInterface.Size);
|
||||
DPRINT1("QueryInterface.Version %x\n", Stack->Parameters.QueryInterface.Version);
|
||||
|
||||
Status = STATUS_SUCCESS;
|
||||
Information = 0;
|
||||
|
||||
/* FIXME: Check the actual Guid */
|
||||
if (Stack->Parameters.QueryInterface.Size == sizeof(USB_BUS_INTERFACE_USBDI_V2) && (Stack->Parameters.QueryInterface.Version == 2))
|
||||
CompareStatus = RtlStringFromGUID(&USB_BUS_INTERFACE_HUB_GUID, &InterfacMatchString);
|
||||
if (!NT_SUCCESS(CompareStatus))
|
||||
{
|
||||
InterfaceDI = (PUSB_BUS_INTERFACE_USBDI_V2) Stack->Parameters.QueryInterface.Interface;
|
||||
InterfaceDI->Size = sizeof(USB_BUS_INTERFACE_USBDI_V2);
|
||||
InterfaceDI->Version = 2;
|
||||
InterfaceDI->BusContext = PdoDeviceExtension->DeviceObject;
|
||||
InterfaceDI->InterfaceReference = (PINTERFACE_REFERENCE)InterfaceReference;
|
||||
InterfaceDI->InterfaceDereference = (PINTERFACE_DEREFERENCE)InterfaceDereference;
|
||||
InterfaceDI->GetUSBDIVersion = GetUSBDIVersion;
|
||||
InterfaceDI->QueryBusTime = QueryBusTime;
|
||||
InterfaceDI->SubmitIsoOutUrb = SubmitIsoOutUrb;
|
||||
InterfaceDI->QueryBusInformation = QueryBusInformation;
|
||||
InterfaceDI->IsDeviceHighSpeed = IsDeviceHighSpeed;
|
||||
InterfaceDI->EnumLogEntry = EnumLogEntry;
|
||||
DPRINT1("Failed to create string from GUID!\n");
|
||||
}
|
||||
/* FIXME: Check the actual Guid */
|
||||
else if (Stack->Parameters.QueryInterface.Size == sizeof(USB_BUS_INTERFACE_HUB_V5) &&
|
||||
(Stack->Parameters.QueryInterface.Version == 5))
|
||||
|
||||
CompareStatus = RtlCompareUnicodeString(&InterfacMatchString, &GuidString, TRUE);
|
||||
|
||||
if (NT_SUCCESS(CompareStatus))
|
||||
{
|
||||
InterfaceHub = (PUSB_BUS_INTERFACE_HUB_V5)Stack->Parameters.QueryInterface.Interface;
|
||||
InterfaceHub->Version = 5;
|
||||
InterfaceHub->Size = sizeof(USB_BUS_INTERFACE_HUB_V5);
|
||||
InterfaceHub->BusContext = PdoDeviceExtension->DeviceObject;
|
||||
InterfaceHub->InterfaceReference = (PINTERFACE_REFERENCE)InterfaceReference;
|
||||
InterfaceHub->InterfaceDereference = (PINTERFACE_DEREFERENCE)InterfaceDereference;
|
||||
InterfaceHub->CreateUsbDevice = CreateUsbDevice;
|
||||
InterfaceHub->InitializeUsbDevice = InitializeUsbDevice;
|
||||
InterfaceHub->GetUsbDescriptors = GetUsbDescriptors;
|
||||
InterfaceHub->RemoveUsbDevice = RemoveUsbDevice;
|
||||
InterfaceHub->RestoreUsbDevice = RestoreUsbDevice;
|
||||
InterfaceHub->GetPortHackFlags = GetPortHackFlags;
|
||||
InterfaceHub->QueryDeviceInformation = QueryDeviceInformation;
|
||||
InterfaceHub->GetControllerInformation = GetControllerInformation;
|
||||
InterfaceHub->ControllerSelectiveSuspend = ControllerSelectiveSuspend;
|
||||
InterfaceHub->GetExtendedHubInformation = GetExtendedHubInformation;
|
||||
InterfaceHub->GetRootHubSymbolicName = GetRootHubSymbolicName;
|
||||
InterfaceHub->GetDeviceBusContext = GetDeviceBusContext;
|
||||
InterfaceHub->Initialize20Hub = Initialize20Hub;
|
||||
InterfaceHub->RootHubInitNotification = RootHubInitNotification;
|
||||
InterfaceHub->FlushTransfers = FlushTransfers;
|
||||
InterfaceHub->SetDeviceHandleData = SetDeviceHandleData;
|
||||
InterfaceHub->Version = Stack->Parameters.QueryInterface.Version;
|
||||
if (Stack->Parameters.QueryInterface.Version >= 0)
|
||||
{
|
||||
InterfaceHub->Size = Stack->Parameters.QueryInterface.Size;
|
||||
InterfaceHub->BusContext = PdoDeviceExtension->DeviceObject;
|
||||
InterfaceHub->InterfaceReference = (PINTERFACE_REFERENCE)InterfaceReference;
|
||||
InterfaceHub->InterfaceDereference = (PINTERFACE_DEREFERENCE)InterfaceDereference;
|
||||
}
|
||||
if (Stack->Parameters.QueryInterface.Version >= 1)
|
||||
{
|
||||
InterfaceHub->CreateUsbDevice = CreateUsbDevice;
|
||||
InterfaceHub->InitializeUsbDevice = InitializeUsbDevice;
|
||||
InterfaceHub->GetUsbDescriptors = GetUsbDescriptors;
|
||||
InterfaceHub->RemoveUsbDevice = RemoveUsbDevice;
|
||||
InterfaceHub->RestoreUsbDevice = RestoreUsbDevice;
|
||||
InterfaceHub->GetPortHackFlags = GetPortHackFlags;
|
||||
InterfaceHub->QueryDeviceInformation = QueryDeviceInformation;
|
||||
}
|
||||
if (Stack->Parameters.QueryInterface.Version >= 2)
|
||||
{
|
||||
InterfaceHub->GetControllerInformation = GetControllerInformation;
|
||||
InterfaceHub->ControllerSelectiveSuspend = ControllerSelectiveSuspend;
|
||||
InterfaceHub->GetExtendedHubInformation = GetExtendedHubInformation;
|
||||
InterfaceHub->GetRootHubSymbolicName = GetRootHubSymbolicName;
|
||||
InterfaceHub->GetDeviceBusContext = GetDeviceBusContext;
|
||||
InterfaceHub->Initialize20Hub = Initialize20Hub;
|
||||
|
||||
}
|
||||
if (Stack->Parameters.QueryInterface.Version >= 3)
|
||||
{
|
||||
InterfaceHub->RootHubInitNotification = RootHubInitNotification;
|
||||
}
|
||||
if (Stack->Parameters.QueryInterface.Version >= 4)
|
||||
{
|
||||
InterfaceHub->FlushTransfers = FlushTransfers;
|
||||
}
|
||||
if (Stack->Parameters.QueryInterface.Version >= 5)
|
||||
{
|
||||
InterfaceHub->SetDeviceHandleData = SetDeviceHandleData;
|
||||
}
|
||||
if (Stack->Parameters.QueryInterface.Version >= 6)
|
||||
{
|
||||
DPRINT1("Unknown version!\n");
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
||||
CompareStatus = RtlStringFromGUID(&USB_BUS_INTERFACE_USBDI_GUID, &InterfacMatchString);
|
||||
if (!NT_SUCCESS(CompareStatus))
|
||||
{
|
||||
DPRINT1("Not Supported\n");
|
||||
Status = Irp->IoStatus.Status;
|
||||
Information = Irp->IoStatus.Information;
|
||||
DPRINT1("Failed to create string from GUID!\n");
|
||||
}
|
||||
|
||||
CompareStatus = RtlCompareUnicodeString(&InterfacMatchString, &GuidString, TRUE);
|
||||
|
||||
if (NT_SUCCESS(CompareStatus))
|
||||
{
|
||||
InterfaceDI = (PUSB_BUS_INTERFACE_USBDI_V2) Stack->Parameters.QueryInterface.Interface;
|
||||
InterfaceDI->Version = Stack->Parameters.QueryInterface.Version;
|
||||
if (Stack->Parameters.QueryInterface.Version >= 0)
|
||||
{
|
||||
//InterfaceDI->Size = sizeof(USB_BUS_INTERFACE_USBDI_V2);
|
||||
InterfaceDI->Size = Stack->Parameters.QueryInterface.Size;
|
||||
InterfaceDI->BusContext = PdoDeviceExtension->DeviceObject;
|
||||
InterfaceDI->InterfaceReference = (PINTERFACE_REFERENCE)InterfaceReference;
|
||||
InterfaceDI->InterfaceDereference = (PINTERFACE_DEREFERENCE)InterfaceDereference;
|
||||
InterfaceDI->GetUSBDIVersion = GetUSBDIVersion;
|
||||
InterfaceDI->QueryBusTime = QueryBusTime;
|
||||
InterfaceDI->SubmitIsoOutUrb = SubmitIsoOutUrb;
|
||||
InterfaceDI->QueryBusInformation = QueryBusInformation;
|
||||
}
|
||||
if (Stack->Parameters.QueryInterface.Version >= 1)
|
||||
{
|
||||
InterfaceDI->IsDeviceHighSpeed = IsDeviceHighSpeed;
|
||||
}
|
||||
if (Stack->Parameters.QueryInterface.Version >= 2)
|
||||
{
|
||||
InterfaceDI->EnumLogEntry = EnumLogEntry;
|
||||
}
|
||||
|
||||
if (Stack->Parameters.QueryInterface.Version >= 3)
|
||||
{
|
||||
DPRINT1("Not Supported!\n");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
DPRINT1("Not Supported\n");
|
||||
Status = Irp->IoStatus.Status;
|
||||
Information = Irp->IoStatus.Information;
|
||||
|
||||
break;
|
||||
}
|
||||
case IRP_MN_QUERY_BUS_INFORMATION:
|
||||
|
|
|
@ -58,6 +58,10 @@ CreateUsbDevice(PVOID BusContext,
|
|||
USHORT PortStatus, USHORT PortNumber)
|
||||
{
|
||||
DPRINT1("CreateUsbDevice called\n");
|
||||
DPRINT1("PortStatus %x\n", PortStatus);
|
||||
DPRINT1("PortNumber %x\n", PortNumber);
|
||||
*NewDevice = ExAllocatePoolWithTag(NonPagedPool, sizeof(USB_DEVICE), USB_POOL_TAG);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -100,7 +104,7 @@ USB_BUSIFFN
|
|||
RemoveUsbDevice(PVOID BusContext, PUSB_DEVICE_HANDLE DeviceHandle, ULONG Flags)
|
||||
{
|
||||
DPRINT1("RemoveUsbDevice called\n");
|
||||
return STATUS_SUCCESS;
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
|
@ -108,7 +112,7 @@ USB_BUSIFFN
|
|||
RestoreUsbDevice(PVOID BusContext, PUSB_DEVICE_HANDLE OldDeviceHandle, PUSB_DEVICE_HANDLE NewDeviceHandle)
|
||||
{
|
||||
DPRINT1("RestoreUsbDevice called\n");
|
||||
return STATUS_SUCCESS;
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
|
@ -116,7 +120,7 @@ USB_BUSIFFN
|
|||
GetPortHackFlags(PVOID BusContext, PULONG Flags)
|
||||
{
|
||||
DPRINT1("GetPortHackFlags called\n");
|
||||
return STATUS_SUCCESS;
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
|
@ -172,7 +176,6 @@ QueryDeviceInformation(PVOID BusContext,
|
|||
{
|
||||
RtlCopyMemory(&DeviceInfo->PipeList[i].EndpointDescriptor, &UsbDevice->ActiveInterface->EndPoints[i]->EndPointDescriptor, sizeof(USB_ENDPOINT_DESCRIPTOR));
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -230,7 +233,7 @@ GetExtendedHubInformation(PVOID BusContext,
|
|||
PPDO_DEVICE_EXTENSION PdoDeviceExtension = (PPDO_DEVICE_EXTENSION)((PDEVICE_OBJECT)BusContext)->DeviceExtension;
|
||||
PFDO_DEVICE_EXTENSION FdoDeviceExntension = (PFDO_DEVICE_EXTENSION)PdoDeviceExtension->ControllerFdo->DeviceExtension;
|
||||
LONG i;
|
||||
|
||||
DPRINT1("GetExtendedHubInformation\n");
|
||||
/* Set the default return value */
|
||||
*LengthReturned = 0;
|
||||
/* Caller must have set InformationLevel to 0 */
|
||||
|
@ -266,7 +269,7 @@ GetRootHubSymbolicName(PVOID BusContext,
|
|||
|
||||
if (HubSymNameBufferLength < 20)
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
//RtlStringCbCopy(HubSymNameBuffer, HubSymNameBufferLength, L"ROOT_HUB20");
|
||||
RtlCopyMemory(HubSymNameBuffer, L"ROOT_HUB20", HubSymNameBufferLength);
|
||||
*HubSymNameActualLength = 20;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
|
@ -284,7 +287,12 @@ NTSTATUS
|
|||
USB_BUSIFFN
|
||||
Initialize20Hub(PVOID BusContext, PUSB_DEVICE_HANDLE HubDeviceHandle, ULONG TtCount)
|
||||
{
|
||||
DPRINT1("Initialize20Hub called\n");
|
||||
DPRINT1("Initialize20Hub called, HubDeviceHandle: %x\n", HubDeviceHandle);
|
||||
|
||||
/* FIXME: */
|
||||
/* Create the Irp Queue for SCE */
|
||||
/* Should queue be created for each device or each enpoint??? */
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -331,7 +339,7 @@ USB_BUSIFFN
|
|||
QueryBusTime(PVOID BusContext, PULONG CurrentFrame)
|
||||
{
|
||||
DPRINT1("QueryBusTime called\n");
|
||||
return STATUS_SUCCESS;
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
|
@ -339,7 +347,7 @@ USB_BUSIFFN
|
|||
SubmitIsoOutUrb(PVOID BusContext, PURB Urb)
|
||||
{
|
||||
DPRINT1("SubmitIsoOutUrb called\n");
|
||||
return STATUS_SUCCESS;
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
|
@ -351,7 +359,7 @@ QueryBusInformation(PVOID BusContext,
|
|||
PULONG BusInformationActualLength)
|
||||
{
|
||||
DPRINT1("QueryBusInformation called\n");
|
||||
return STATUS_SUCCESS;
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
|
@ -367,6 +375,6 @@ USB_BUSIFFN
|
|||
EnumLogEntry(PVOID BusContext, ULONG DriverTag, ULONG EnumTag, ULONG P1, ULONG P2)
|
||||
{
|
||||
DPRINT1("EnumLogEntry called\n");
|
||||
return STATUS_SUCCESS;
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue