#include <wdmguid.h>
#include <stdio.h>
#include <debug.h>
+#include <guiddef.h>
/* Lifted from Linux with slight changes */
const UCHAR ROOTHUB2_DEVICE_DESCRIPTOR [] =
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");
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:
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;
}
RemoveUsbDevice(PVOID BusContext, PUSB_DEVICE_HANDLE DeviceHandle, ULONG Flags)
{
DPRINT1("RemoveUsbDevice called\n");
- return STATUS_SUCCESS;
+ return STATUS_NOT_SUPPORTED;
}
NTSTATUS
RestoreUsbDevice(PVOID BusContext, PUSB_DEVICE_HANDLE OldDeviceHandle, PUSB_DEVICE_HANDLE NewDeviceHandle)
{
DPRINT1("RestoreUsbDevice called\n");
- return STATUS_SUCCESS;
+ return STATUS_NOT_SUPPORTED;
}
NTSTATUS
GetPortHackFlags(PVOID BusContext, PULONG Flags)
{
DPRINT1("GetPortHackFlags called\n");
- return STATUS_SUCCESS;
+ return STATUS_NOT_SUPPORTED;
}
NTSTATUS
{
RtlCopyMemory(&DeviceInfo->PipeList[i].EndpointDescriptor, &UsbDevice->ActiveInterface->EndPoints[i]->EndPointDescriptor, sizeof(USB_ENDPOINT_DESCRIPTOR));
}
-
return STATUS_SUCCESS;
}
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 */
if (HubSymNameBufferLength < 20)
return STATUS_UNSUCCESSFUL;
- //RtlStringCbCopy(HubSymNameBuffer, HubSymNameBufferLength, L"ROOT_HUB20");
+ RtlCopyMemory(HubSymNameBuffer, L"ROOT_HUB20", HubSymNameBufferLength);
*HubSymNameActualLength = 20;
return STATUS_SUCCESS;
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;
}
QueryBusTime(PVOID BusContext, PULONG CurrentFrame)
{
DPRINT1("QueryBusTime called\n");
- return STATUS_SUCCESS;
+ return STATUS_NOT_SUPPORTED;
}
NTSTATUS
SubmitIsoOutUrb(PVOID BusContext, PURB Urb)
{
DPRINT1("SubmitIsoOutUrb called\n");
- return STATUS_SUCCESS;
+ return STATUS_NOT_SUPPORTED;
}
NTSTATUS
PULONG BusInformationActualLength)
{
DPRINT1("QueryBusInformation called\n");
- return STATUS_SUCCESS;
+ return STATUS_NOT_SUPPORTED;
}
BOOLEAN
EnumLogEntry(PVOID BusContext, ULONG DriverTag, ULONG EnumTag, ULONG P1, ULONG P2)
{
DPRINT1("EnumLogEntry called\n");
- return STATUS_SUCCESS;
+ return STATUS_NOT_SUPPORTED;
}