Index: drivers/hid/hidclass/fdo.c =================================================================== --- drivers/hid/hidclass/fdo.c (revision 70555) +++ drivers/hid/hidclass/fdo.c (working copy) @@ -10,7 +10,7 @@ #include "precomp.h" -#define NDEBUG +//#define NDEBUG #include NTSTATUS @@ -636,48 +636,101 @@ PHIDCLASS_FDO_EXTENSION FDODeviceExtension; NTSTATUS Status; - // - // get device extension - // - FDODeviceExtension = DeviceObject->DeviceExtension; + FDODeviceExtension = DeviceObject->DeviceExtension; // get device extension ASSERT(FDODeviceExtension->Common.IsFDO); - // - // get current irp stack location - // - IoStack = IoGetCurrentIrpStackLocation(Irp); + IoStack = IoGetCurrentIrpStackLocation(Irp); // get current irp stack location + switch (IoStack->MinorFunction) { - case IRP_MN_START_DEVICE: - { - return HidClassFDO_StartDevice(DeviceObject, Irp); - } - case IRP_MN_REMOVE_DEVICE: - { - return HidClassFDO_RemoveDevice(DeviceObject, Irp); - } - case IRP_MN_QUERY_DEVICE_RELATIONS: - { - return HidClassFDO_DeviceRelations(DeviceObject, Irp); - } - case IRP_MN_QUERY_REMOVE_DEVICE: - case IRP_MN_QUERY_STOP_DEVICE: - case IRP_MN_CANCEL_REMOVE_DEVICE: - case IRP_MN_CANCEL_STOP_DEVICE: - { - // - // set status to success and fall through - // + case IRP_MN_START_DEVICE: //0x00 + DPRINT("[FDO_PnP] IRP_MN_START_DEVICE\n"); + return HidClassFDO_StartDevice(DeviceObject, Irp); + + case IRP_MN_REMOVE_DEVICE: //0x02 + DPRINT("[FDO_PnP] IRP_MN_REMOVE_DEVICE\n"); + return HidClassFDO_RemoveDevice(DeviceObject, Irp); + + case IRP_MN_QUERY_DEVICE_RELATIONS: //0x07 + DPRINT("[FDO_PnP] IRP_MN_QUERY_DEVICE_RELATIONS\n"); + return HidClassFDO_DeviceRelations(DeviceObject, Irp); + + case IRP_MN_QUERY_REMOVE_DEVICE: //0x01 + DPRINT("[FDO_PnP] IRP_MN_QUERY_REMOVE_DEVICE\n"); Irp->IoStatus.Status = STATUS_SUCCESS; - } + break; + + case IRP_MN_QUERY_STOP_DEVICE: //0x05 + DPRINT("[FDO_PnP] IRP_MN_QUERY_STOP_DEVICE\n"); + Irp->IoStatus.Status = STATUS_SUCCESS; + break; + + case IRP_MN_CANCEL_REMOVE_DEVICE: //0x03 + DPRINT("[FDO_PnP] IRP_MN_CANCEL_REMOVE_DEVICE\n"); + Irp->IoStatus.Status = STATUS_SUCCESS; + break; + + case IRP_MN_CANCEL_STOP_DEVICE: //0x06 + DPRINT("[FDO_PnP] IRP_MN_CANCEL_STOP_DEVICE\n"); + Irp->IoStatus.Status = STATUS_SUCCESS; + break; + + case IRP_MN_STOP_DEVICE: //0x04 + DPRINT("[FDO_PnP] IRP_MN_STOP_DEVICE\n"); + break; + case IRP_MN_QUERY_INTERFACE: //0x08 + DPRINT("[FDO_PnP] IRP_MN_QUERY_INTERFACE\n"); + break; + case IRP_MN_QUERY_CAPABILITIES: //0x09 + DPRINT("[FDO_PnP] IRP_MN_QUERY_CAPABILITIES\n"); + break; + case IRP_MN_QUERY_RESOURCES: //0x0A //10 + DPRINT("[FDO_PnP] IRP_MN_QUERY_RESOURCES\n"); + break; + case IRP_MN_QUERY_RESOURCE_REQUIREMENTS: //0x0B //11 + DPRINT("[FDO_PnP] IRP_MN_QUERY_RESOURCE_REQUIREMENTS\n"); + break; + case IRP_MN_QUERY_DEVICE_TEXT: //0x0C //12 + DPRINT("[FDO_PnP] IRP_MN_QUERY_DEVICE_TEXT\n"); + break; + case IRP_MN_FILTER_RESOURCE_REQUIREMENTS: //0x0D //13 + DPRINT("[FDO_PnP] IRP_MN_FILTER_RESOURCE_REQUIREMENTS\n"); + break; + case IRP_MN_READ_CONFIG: //0x0F //15 + DPRINT("[FDO_PnP] IRP_MN_READ_CONFIG\n"); + break; + case IRP_MN_WRITE_CONFIG: //0x10 //16 + DPRINT("[FDO_PnP] IRP_MN_WRITE_CONFIG\n"); + break; + case IRP_MN_EJECT: //0x11 //17 + DPRINT("[FDO_PnP] IRP_MN_EJECT\n"); + break; + case IRP_MN_SET_LOCK: //0x12 //18 + DPRINT("[FDO_PnP] IRP_MN_SET_LOCK\n"); + break; + case IRP_MN_QUERY_ID: //0x13 //19 + DPRINT("[FDO_PnP] IRP_MN_QUERY_ID\n"); + break; + case IRP_MN_QUERY_PNP_DEVICE_STATE: //0x14 //20 + DPRINT("[FDO_PnP] IRP_MN_QUERY_PNP_DEVICE_STATE\n"); + break; + case IRP_MN_QUERY_BUS_INFORMATION: //0x15 //21 + DPRINT("[FDO_PnP] IRP_MN_QUERY_BUS_INFORMATION\n"); + break; + case IRP_MN_DEVICE_USAGE_NOTIFICATION: //0x16 //22 + DPRINT("[FDO_PnP] IRP_MN_DEVICE_USAGE_NOTIFICATION\n"); + break; + case IRP_MN_SURPRISE_REMOVAL: //0x17 //23 + DPRINT("[FDO_PnP] IRP_MN_SURPRISE_REMOVAL\n"); + break; + default: - { - // - // dispatch to mini driver - // - IoCopyCurrentIrpStackLocationToNext(Irp); - Status = HidClassFDO_DispatchRequest(DeviceObject, Irp); - return Status; - } + DPRINT("[FDO_PnP] IRP_MN_xxx %x\n", IoStack->MinorFunction); + break; } + + IoCopyCurrentIrpStackLocationToNext(Irp); + Status = HidClassFDO_DispatchRequest(DeviceObject, Irp); // dispatch to mini driver + + return Status; } Index: drivers/hid/hidclass/hidclass.c =================================================================== --- drivers/hid/hidclass/hidclass.c (revision 70555) +++ drivers/hid/hidclass/hidclass.c (working copy) @@ -10,7 +10,7 @@ #include "precomp.h" -#define NDEBUG +//#define NDEBUG #include static LPWSTR ClientIdentificationAddress = L"HIDCLASS"; @@ -1053,7 +1053,7 @@ // get current stack location // IoStack = IoGetCurrentIrpStackLocation(Irp); - DPRINT("[HIDCLASS] Dispatch Major %x Minor %x\n", IoStack->MajorFunction, IoStack->MinorFunction); + DPRINT("[HIDCLASS] DeviceObject %x Dispatch Major %x Minor %x\n", DeviceObject, IoStack->MajorFunction, IoStack->MinorFunction); // // dispatch request based on major function Index: drivers/hid/hidclass/pdo.c =================================================================== --- drivers/hid/hidclass/pdo.c (revision 70555) +++ drivers/hid/hidclass/pdo.c (working copy) @@ -12,7 +12,7 @@ #include -#define NDEBUG +//#define NDEBUG #include PHIDP_COLLECTION_DESC @@ -22,6 +22,8 @@ { ULONG Index; + DPRINT("HidClassPDO_GetCollectionDescription DeviceDescription %x CollectionNumber %x\n", DeviceDescription, CollectionNumber); + for(Index = 0; Index < DeviceDescription->CollectionDescLength; Index++) { if (DeviceDescription->CollectionDesc[Index].CollectionNumber == CollectionNumber) @@ -177,6 +179,8 @@ return Status; } + DPRINT("HidClassPDO_HandleQueryHardwareId CollectionDescLength %x\n", PDODeviceExtension->Common.DeviceDescription.CollectionDescLength); + if (PDODeviceExtension->Common.DeviceDescription.CollectionDescLength > 1) { // @@ -379,6 +383,8 @@ { case IRP_MN_QUERY_ID: { + DPRINT("[PDO_PnP]: IRP_MN_QUERY_ID IdType %x\n", IoStack->Parameters.QueryId.IdType); + if (IoStack->Parameters.QueryId.IdType == BusQueryDeviceID) { // @@ -419,6 +425,8 @@ } case IRP_MN_QUERY_CAPABILITIES: { + DPRINT("[PDO_PnP]: IRP_MN_QUERY_CAPABILITIES\n"); + if (IoStack->Parameters.DeviceCapabilities.Capabilities == NULL) { // @@ -439,6 +447,8 @@ } case IRP_MN_QUERY_BUS_INFORMATION: { + DPRINT("[PDO_PnP]: IRP_MN_QUERY_BUS_INFORMATION\n"); + // // // @@ -460,6 +470,8 @@ } case IRP_MN_QUERY_PNP_DEVICE_STATE: { + DPRINT("[PDO_PnP]: IRP_MN_QUERY_PNP_DEVICE_STATE\n"); + // // FIXME set flags when driver fails / disabled // @@ -468,6 +480,8 @@ } case IRP_MN_QUERY_DEVICE_RELATIONS: { + DPRINT("[PDO_PnP]: IRP_MN_QUERY_DEVICE_RELATIONS\n"); + // // only target relations are supported // @@ -509,6 +523,8 @@ } case IRP_MN_START_DEVICE: { + DPRINT("[PDO_PnP]: IRP_MN_START_DEVICE\n"); + // // FIXME: support polled devices // @@ -539,6 +555,8 @@ } case IRP_MN_REMOVE_DEVICE: { + DPRINT("[PDO_PnP]: IRP_MN_REMOVE_DEVICE\n"); + /* Disable the device interface */ if (PDODeviceExtension->DeviceInterface.Length != 0) IoSetDeviceInterfaceState(&PDODeviceExtension->DeviceInterface, FALSE); @@ -582,11 +600,28 @@ Status = Irp->IoStatus.Status; break; } - case IRP_MN_QUERY_REMOVE_DEVICE: - case IRP_MN_CANCEL_STOP_DEVICE: - case IRP_MN_QUERY_STOP_DEVICE: - case IRP_MN_CANCEL_REMOVE_DEVICE: + case IRP_MN_QUERY_REMOVE_DEVICE: //0x01 + DPRINT("[PDO_PnP] IRP_MN_QUERY_REMOVE_DEVICE\n"); + DPRINT1("Denying removal of HID device due to IRP cancellation bugs\n"); + Status = STATUS_UNSUCCESSFUL; + break; + + case IRP_MN_CANCEL_STOP_DEVICE: //0x06 + DPRINT("[PDO_PnP] IRP_MN_CANCEL_STOP_DEVICE\n"); + DPRINT1("Denying removal of HID device due to IRP cancellation bugs\n"); + Status = STATUS_UNSUCCESSFUL; + break; + + case IRP_MN_QUERY_STOP_DEVICE: //0x05 + DPRINT("[PDO_PnP] IRP_MN_QUERY_STOP_DEVICE\n"); + DPRINT1("Denying removal of HID device due to IRP cancellation bugs\n"); + Status = STATUS_UNSUCCESSFUL; + break; + + case IRP_MN_CANCEL_REMOVE_DEVICE: //0x03 { + DPRINT("[PDO_PnP] IRP_MN_CANCEL_REMOVE_DEVICE\n"); + // // no/op // @@ -598,8 +633,44 @@ #endif break; } + case IRP_MN_STOP_DEVICE: //0x04 + DPRINT("[PDO_PnP] IRP_MN_STOP_DEVICE\n"); + break; + case IRP_MN_QUERY_RESOURCES: //0x0A //10 + DPRINT("[PDO_PnP] IRP_MN_QUERY_RESOURCES\n"); + break; + case IRP_MN_QUERY_RESOURCE_REQUIREMENTS: //0x0B //11 + DPRINT("[PDO_PnP] IRP_MN_QUERY_RESOURCE_REQUIREMENTS\n"); + break; + case IRP_MN_QUERY_DEVICE_TEXT: //0x0C //12 + DPRINT("[PDO_PnP] IRP_MN_QUERY_DEVICE_TEXT\n"); + break; + case IRP_MN_FILTER_RESOURCE_REQUIREMENTS: //0x0D //13 + DPRINT("[PDO_PnP] IRP_MN_FILTER_RESOURCE_REQUIREMENTS\n"); + break; + case IRP_MN_READ_CONFIG: //0x0F //15 + DPRINT("[PDO_PnP] IRP_MN_READ_CONFIG\n"); + break; + case IRP_MN_WRITE_CONFIG: //0x10 //16 + DPRINT("[PDO_PnP] IRP_MN_WRITE_CONFIG\n"); + break; + case IRP_MN_EJECT: //0x11 //17 + DPRINT("[PDO_PnP] IRP_MN_EJECT\n"); + break; + case IRP_MN_SET_LOCK: //0x12 //18 + DPRINT("[PDO_PnP] IRP_MN_SET_LOCK\n"); + break; + case IRP_MN_DEVICE_USAGE_NOTIFICATION: //0x16 //22 + DPRINT("[PDO_PnP] IRP_MN_DEVICE_USAGE_NOTIFICATION\n"); + break; + case IRP_MN_SURPRISE_REMOVAL: //0x17 //23 + DPRINT("[PDO_PnP] IRP_MN_SURPRISE_REMOVAL\n"); + break; + default: { + DPRINT("[HIDCLASS] PDO IRP_MN_xxx %x\n", IoStack->MinorFunction); + // // do nothing // @@ -671,6 +742,8 @@ // let's create a PDO for top level collection // Index = 0; + DPRINT("HidClassPDO_CreatePDO: FDODeviceExtension->Common.DeviceDescription.CollectionDescLength %x\n", FDODeviceExtension->Common.DeviceDescription.CollectionDescLength); + while (Index < FDODeviceExtension->Common.DeviceDescription.CollectionDescLength) { // Index: drivers/hid/hidparse/hidparse.c =================================================================== --- drivers/hid/hidparse/hidparse.c (revision 70555) +++ drivers/hid/hidparse/hidparse.c (working copy) @@ -10,7 +10,7 @@ #include "hidparse.h" -#define NDEBUG +//#define NDEBUG #include PVOID Index: drivers/hid/hidusb/hidusb.c =================================================================== --- drivers/hid/hidusb/hidusb.c (revision 70555) +++ drivers/hid/hidusb/hidusb.c (working copy) @@ -386,7 +386,9 @@ // // invalidate device state // + DPRINT("USBHUB: IoInvalidateDeviceState\n"); IoInvalidateDeviceState(DeviceExtension->PhysicalDeviceObject); + DPRINT("USBHUB: IoInvalidateDeviceState end \n"); } // @@ -662,6 +664,9 @@ HidDeviceExtension->HidDescriptor->DescriptorList[0].bReportType, 0, HidDeviceExtension->InterfaceInfo->InterfaceNumber); + + DPRINT("[HIDUSB] get report descriptor (URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE) with %x\n", Status); + if (!NT_SUCCESS(Status)) { // @@ -677,6 +682,9 @@ HidDeviceExtension->HidDescriptor->DescriptorList[0].bReportType, 0, 0 /* FIXME*/); + + DPRINT("[HIDUSB] get report descriptor (URB_FUNCTION_GET_DESCRIPTOR_FROM_ENDPOINT) with %x\n", Status); + if (!NT_SUCCESS(Status)) { DPRINT("[HIDUSB] failed to get report descriptor with %x\n", Status); @@ -1434,6 +1442,8 @@ HidDeviceExtension = DeviceExtension->MiniDeviceExtension; ASSERT(HidDeviceExtension->InterfaceInfo); + DPRINT("Hid_GetProtocol: HidDeviceExtension->InterfaceInfo->SubClass - %x\n", HidDeviceExtension->InterfaceInfo->SubClass); + if (HidDeviceExtension->InterfaceInfo->SubClass != 0x1) { // Index: drivers/hid/hidusb/hidusb.h =================================================================== --- drivers/hid/hidusb/hidusb.h (revision 70555) +++ drivers/hid/hidusb/hidusb.h (working copy) @@ -2,7 +2,7 @@ #define _HIDPI_ #define _HIDPI_NO_FUNCTION_MACROS_ -#define NDEBUG +//#define NDEBUG #include #include #include Index: drivers/hid/mouhid/mouhid.h =================================================================== --- drivers/hid/mouhid/mouhid.h (revision 70555) +++ drivers/hid/mouhid/mouhid.h (working copy) @@ -5,7 +5,7 @@ #include #include #include -#define NDEBUG +//#define NDEBUG #include #include #include Index: drivers/usb/usbd/usbd.c =================================================================== --- drivers/usb/usbd/usbd.c (revision 70555) +++ drivers/usb/usbd/usbd.c (working copy) @@ -33,7 +33,7 @@ */ #define _USBD_ -#define NDEBUG +//#define NDEBUG #include #include #include Index: drivers/usb/usbhub/fdo.c =================================================================== --- drivers/usb/usbhub/fdo.c (revision 70555) +++ drivers/usb/usbhub/fdo.c (working copy) @@ -12,7 +12,7 @@ #include -#define NDEBUG +//#define NDEBUG #include NTSTATUS @@ -1116,7 +1116,9 @@ HubDeviceExtension->ChildDeviceObject[Index] = NULL; /* Invalidate device relations for the root hub */ + DPRINT("USBHUB: IoInvalidateDeviceRelations\n"); IoInvalidateDeviceRelations(HubDeviceExtension->RootHubPhysicalDeviceObject, BusRelations); + DPRINT("USBHUB: IoInvalidateDeviceRelations end \n"); /* The rest of the removal process takes place in IRP_MN_REMOVE_DEVICE handling for the PDO */ return STATUS_SUCCESS; @@ -1325,7 +1327,7 @@ &DeviceInfoSize); - //DumpFullConfigurationDescriptor(UsbChildExtension->FullConfigDesc); + DumpFullConfigurationDescriptor(UsbChildExtension->FullConfigDesc); // // Construct all the strings that will describe the device to PNP @@ -1337,10 +1339,14 @@ goto Cleanup; } + DPRINT("USBHUB: CreateDeviceIds return status %x\n", Status); + HubDeviceExtension->ChildDeviceObject[ChildDeviceCount] = NewChildDeviceObject; HubDeviceExtension->InstanceCount++; + DPRINT("USBHUB: HubDeviceExtension->InstanceCount %x\n", HubDeviceExtension->InstanceCount); IoInvalidateDeviceRelations(RootHubDeviceObject, BusRelations); + DPRINT("USBHUB: IoInvalidateDeviceRelations end \n"); return STATUS_SUCCESS; Cleanup: Index: drivers/usb/usbhub/pdo.c =================================================================== --- drivers/usb/usbhub/pdo.c (revision 70555) +++ drivers/usb/usbhub/pdo.c (working copy) @@ -13,7 +13,7 @@ #include -#define NDEBUG +//#define NDEBUG #include #define IO_METHOD_FROM_CTL_CODE(ctlCode) (ctlCode&0x00000003) @@ -291,8 +291,17 @@ case URB_FUNCTION_VENDOR_DEVICE: DPRINT("URB_FUNCTION_VENDOR_DEVICE\n"); break; + case URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL: + DPRINT("URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL\n"); + break; + case URB_FUNCTION_GET_DESCRIPTOR_FROM_ENDPOINT: //0x24 + DPRINT("URB_FUNCTION_GET_DESCRIPTOR_FROM_ENDPOINT\n"); + break; + case URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE: //0x28 + DPRINT("URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE\n"); + break; default: - DPRINT1("IOCTL_INTERNAL_USB_SUBMIT_URB Function %x NOT IMPLEMENTED\n", Urb->UrbHeader.Function); + DPRINT1("IOCTL_INTERNAL_USB_SUBMIT_URB Unknown Function %x\n", Urb->UrbHeader.Function); break; } Urb->UrbHeader.UsbdDeviceHandle = ChildDeviceExtension->UsbDeviceHandle; @@ -687,7 +696,9 @@ if (bFound) { /* invalidate device relations */ + DPRINT("USBHUB: IoInvalidateDeviceRelations\n"); IoInvalidateDeviceRelations(ParentDevice, BusRelations); + DPRINT("USBHUB: IoInvalidateDeviceRelations end \n"); } return STATUS_SUCCESS; Index: drivers/usb/usbohci/hardware.cpp =================================================================== --- drivers/usb/usbohci/hardware.cpp (revision 70555) +++ drivers/usb/usbohci/hardware.cpp (working copy) @@ -10,7 +10,7 @@ #include "usbohci.h" -#define NDEBUG +//#define NDEBUG #include typedef VOID __stdcall HD_INIT_CALLBACK(IN PVOID CallBackContext); @@ -470,37 +470,63 @@ ULONG NewControl, WaitInMs; LARGE_INTEGER Timeout; BOOLEAN Again = FALSE; + ULONG OldFrameInterval = 0; + ULONG NewFrameInterval = 0; - // + // check context - // Control = READ_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_CONTROL_OFFSET)); + DPRINT("Controller First State %x\n", Control); //Save this NewControl = Control & OHCI_REMOTE_WAKEUP_CONNECTED; + //Save FrameInterval + OldFrameInterval = READ_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_FRAME_INTERVAL_OFFSET)); + DPRINT("Old FrameInterval %x\n", OldFrameInterval); + + //Check if BIOS ownership if ((Control & OHCI_INTERRUPT_ROUTING)) { // // change ownership // + + if ( READ_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_INTERRUPT_ENABLE_OFFSET)) == 0) + { + //HcInterruptEnable.MIE == 0 + WRITE_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_CONTROL_OFFSET), 0); + DPRINT("BIOS ownership and (HcInterruptEnable.MIE == 0) !\n"); + goto Label1; + } + + //HcInterruptEnable.MIE (MasterInterruptEnable) set + WRITE_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_INTERRUPT_ENABLE_OFFSET), OHCI_MASTER_INTERRUPT_ENABLE); + + //HcCommandStatus.OwnershipChangeRequest set WRITE_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_COMMAND_STATUS_OFFSET), OHCI_OWNERSHIP_CHANGE_REQUEST); - for(Index = 0; Index < 100; Index++) + + //HcInterruptDisable.RHSC - Disable interrupt generation due to Root Hub Status Change. + WRITE_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_INTERRUPT_DISABLE_OFFSET), OHCI_ROOT_HUB_STATUS_CHANGE); + + // wait time is 5 sec + for (Index = 0; Index < 500000; Index++) { - // - // wait a bit - // - KeStallExecutionProcessor(100); + // wait a 10 microseconds + KeStallExecutionProcessor(10); - // // check control - // Control = READ_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_CONTROL_OFFSET)); - if (!(Control & OHCI_INTERRUPT_ROUTING)) + if ( !(Control & OHCI_INTERRUPT_ROUTING) ) { - // - // acquired ownership - // + DPRINT("Controller acquired ownership\n"); + + //HcInterruptStatus clear + WRITE_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_INTERRUPT_STATUS_OFFSET), 0xFFFFFFFF); + + //HcInterruptDisable.MIE - Disable interrupt generation. + WRITE_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_INTERRUPT_DISABLE_OFFSET), OHCI_MASTER_INTERRUPT_ENABLE); + break; } } @@ -518,10 +544,9 @@ } } - // +Label1: + // read contents of control register - // - Control = (READ_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_CONTROL_OFFSET)) & OHCI_HC_FUNCTIONAL_STATE_MASK); DPRINT("Controller State %x\n", Control); @@ -532,15 +557,15 @@ WaitInMs = 50; break; + case OHCI_HC_FUNCTIONAL_STATE_OPERATIONAL: + WaitInMs = 0; + break; + case OHCI_HC_FUNCTIONAL_STATE_SUSPEND: case OHCI_HC_FUNCTIONAL_STATE_RESUME: NewControl |= OHCI_HC_FUNCTIONAL_STATE_RESUME; WaitInMs = 10; break; - - default: - WaitInMs = 0; - break; } retry: @@ -569,66 +594,99 @@ } } - // - // now reset controller - // - WRITE_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_COMMAND_STATUS_OFFSET), OHCI_HOST_CONTROLLER_RESET); - - // - // reset time is 10ms - // - for(Index = 0; Index < 100; Index++) + // if state not operational then reset controller + if (Control != OHCI_HC_FUNCTIONAL_STATE_OPERATIONAL) { - // - // wait a bit - // - KeStallExecutionProcessor(10); + WRITE_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_COMMAND_STATUS_OFFSET), OHCI_HOST_CONTROLLER_RESET); - // - // read command status - // - Reset = READ_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_COMMAND_STATUS_OFFSET)); + // reset time is 10ms + for (Index = 0; Index < 100; Index++) + { + // + // wait a bit + // + KeStallExecutionProcessor(10); - // - // was reset bit cleared - // - if ((Reset & OHCI_HOST_CONTROLLER_RESET) == 0) + // + // read command status + // + Reset = READ_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_COMMAND_STATUS_OFFSET)); + + // + // was reset bit cleared + // + if ((Reset & OHCI_HOST_CONTROLLER_RESET) == 0) + { + // + // controller completed reset + // + break; + } + } + + if ((Reset & OHCI_HOST_CONTROLLER_RESET)) { // - // controller completed reset + // failed to reset controller // - break; + return STATUS_UNSUCCESSFUL; } } - if ((Reset & OHCI_HOST_CONTROLLER_RESET)) + if (OldFrameInterval) { - // - // failed to reset controller - // - return STATUS_UNSUCCESSFUL; + //restore FrameInterval + FrameInterval = OldFrameInterval; } + else + { + // get frame interval + FrameInterval = READ_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_FRAME_INTERVAL_OFFSET)); + } - // - // get frame interval - // - FrameInterval = READ_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_FRAME_INTERVAL_OFFSET)); m_IntervalValue = OHCI_GET_INTERVAL_VALUE(FrameInterval); + DPRINT("FrameInterval %x IntervalValue %x\n", FrameInterval, m_IntervalValue); FrameInterval = ((FrameInterval & OHCI_FRAME_INTERVAL_TOGGLE) ^ OHCI_FRAME_INTERVAL_TOGGLE); - - DPRINT("FrameInterval %x IntervalValue %x\n", FrameInterval, m_IntervalValue); FrameInterval |= OHCI_FSMPS(m_IntervalValue) | m_IntervalValue; DPRINT("Computed FrameInterval %x\n", FrameInterval); - // - // write frame interval - // + // write FrameInterval WRITE_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_FRAME_INTERVAL_OFFSET), FrameInterval); - FrameInterval = READ_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_FRAME_INTERVAL_OFFSET)); - DPRINT("Read FrameInterval %x\n", FrameInterval); + // wait time is 5 sec + for (Index = 0; Index < 500000; Index++) + { + // wait a 10 microseconds + KeStallExecutionProcessor(10); + // read FrameInterval + NewFrameInterval = READ_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_FRAME_INTERVAL_OFFSET)); + + if (NewFrameInterval == FrameInterval) + break; + } + + DPRINT("NewFrameInterval %x, FrameInterval %x\n", NewFrameInterval, FrameInterval); + + if (NewFrameInterval != FrameInterval) + { + // failed to write frame interval + if (Again) return STATUS_UNSUCCESSFUL; + + if (!Again) + { + DPRINT1("Failed to write FrameInterval\n"); + Again = TRUE; + goto retry; + } + else + { + DPRINT1("Second reset and failed to write FrameInterval\n"); + return STATUS_UNSUCCESSFUL; + } + } + // // 90 % periodic // Index: lib/drivers/libusb/hcd_controller.cpp =================================================================== --- lib/drivers/libusb/hcd_controller.cpp (revision 70555) +++ lib/drivers/libusb/hcd_controller.cpp (working copy) @@ -10,7 +10,7 @@ #include "libusb.h" -#define NDEBUG +//#define NDEBUG #include class CHCDController : public IHCDController, @@ -415,12 +415,19 @@ // start the hardware // Status = m_Hardware->PnpStart(RawResourceList, TranslatedResourceList); + + if (NT_SUCCESS(Status)) + { + // + // enable symbolic link + // + Status = SetSymbolicLink(TRUE); + } } - - // - // enable symbolic link - // - Status = SetSymbolicLink(TRUE); + else + { + Status = STATUS_UNSUCCESSFUL; + } } DPRINT("[%s] HandlePnp IRP_MN_START FDO: Status %x\n", m_USBType ,Status); Index: lib/drivers/libusb/hub_controller.cpp =================================================================== --- lib/drivers/libusb/hub_controller.cpp (revision 70555) +++ lib/drivers/libusb/hub_controller.cpp (working copy) @@ -10,7 +10,7 @@ #include "libusb.h" -#define NDEBUG +//#define NDEBUG #include VOID NTAPI StatusChangeEndpointCallBack( @@ -1489,6 +1489,8 @@ CtrlSetup.wLength = (USHORT)Urb->UrbControlDescriptorRequest.TransferBufferLength; CtrlSetup.bmRequestType.B = 0x81; + DPRINT("[%s] HandleGetDescriptorFromInterface device handle %p\n", m_USBType, Urb->UrbHeader.UsbdDeviceHandle); + // // submit setup packet // Index: lib/drivers/libusb/usb_device.cpp =================================================================== --- lib/drivers/libusb/usb_device.cpp (revision 70555) +++ lib/drivers/libusb/usb_device.cpp (working copy) @@ -10,7 +10,7 @@ #include "libusb.h" -#define NDEBUG +//#define NDEBUG #include class CUSBDevice : public IUSBDevice Index: ntoskrnl/io/pnpmgr/pnpmgr.c =================================================================== --- ntoskrnl/io/pnpmgr/pnpmgr.c (revision 70555) +++ ntoskrnl/io/pnpmgr/pnpmgr.c (working copy) @@ -10,7 +10,7 @@ /* INCLUDES ******************************************************************/ #include -#define NDEBUG +//#define NDEBUG #include /* GLOBALS *******************************************************************/ @@ -904,6 +904,8 @@ PINVALIDATE_DEVICE_RELATION_DATA Data; KIRQL OldIrql; + DPRINT("IopDeviceRelationsWorker: Context - %x \n", Context); + KeAcquireSpinLock(&IopDeviceRelationsSpinLock, &OldIrql); while (!IsListEmpty(&IopDeviceRelationsRequestList)) { @@ -922,6 +924,8 @@ } IopDeviceRelationsRequestInProgress = FALSE; KeReleaseSpinLock(&IopDeviceRelationsSpinLock, OldIrql); + + DPRINT("IopDeviceRelationsWorker end\n"); } NTSTATUS @@ -4696,6 +4700,8 @@ PINVALIDATE_DEVICE_RELATION_DATA Data; KIRQL OldIrql; + DPRINT("IoInvalidateDeviceRelations: DeviceObject - %x \n", DeviceObject); + Data = ExAllocatePool(NonPagedPool, sizeof(INVALIDATE_DEVICE_RELATION_DATA)); if (!Data) return; @@ -4730,13 +4736,20 @@ IN PDEVICE_OBJECT DeviceObject, IN DEVICE_RELATION_TYPE Type) { + NTSTATUS Status=0; + PAGED_CODE(); + DPRINT("IoSynchronousInvalidateDeviceRelations: DeviceObject - %x, Type - %x \n", DeviceObject, Type); + switch (Type) { case BusRelations: /* Enumerate the device */ + Status = IopEnumerateDevice(DeviceObject); + DPRINT("IoSynchronousInvalidateDeviceRelations: IopEnumerateDevice return Status - %x \n", Status); return IopEnumerateDevice(DeviceObject); + case PowerRelations: /* Not handled yet */ return STATUS_NOT_IMPLEMENTED; Index: ntoskrnl/io/pnpmgr/pnproot.c =================================================================== --- ntoskrnl/io/pnpmgr/pnproot.c (revision 70555) +++ ntoskrnl/io/pnpmgr/pnproot.c (working copy) @@ -10,7 +10,7 @@ /* INCLUDES ******************************************************************/ #include -#define NDEBUG +//#define NDEBUG #include /* GLOBALS *******************************************************************/