--- /dos/c/98ddk/src/usb/bulkusb/sys/blk82930.h Mon Jun 15 02:49:24 1998 +++ /dos/c/98ddk/src/usb/tiglusb/sys/blk82930.h Sat May 25 18:22:08 2002 @@ -34,9 +34,12 @@ #include "BusbDbg.h" // the size of the transfer buffer on your test board or device -#define BULKUSB_TEST_BOARD_TRANSFER_BUFFER_SIZE (64 *1024 ) +#define BULKUSB_TEST_BOARD_TRANSFER_BUFFER_SIZE ( 32 ) //roms: max packet size modified +#define BULKUSB_MAX_TRANSFER_SIZE 32 //roms: max packet size modified -#define BULKUSB_MAX_TRANSFER_SIZE 256 +//roms: install a timeout handler for read/write operations +#undef DEADMAN_TIMER //#define DEADMAN_TIMER // comment it for disabling timeout routine +#define DEADMAN_TIMEOUT 1500 // timeout in ms (default value) // used to track driver-generated io irps for staged read/write processing typedef struct _BULKUSB_RW_CONTEXT { @@ -149,6 +152,11 @@ // default maximum transfer per staged irp size ULONG MaximumTransferSize; + + //roms: timeout for read/write operations + LONG TimeoutValue; + KDPC TimeoutDpc; + KTIMER TimeoutTimer; } DEVICE_EXTENSION, *PDEVICE_EXTENSION; --- /dos/c/98ddk/src/usb/bulkusb/sys/bulkusb.h Wed Jun 3 09:28:06 1998 +++ /dos/c/98ddk/src/usb/tiglusb/sys/bulkusb.h Sat May 25 15:30:46 2002 @@ -49,6 +49,26 @@ METHOD_BUFFERED, \ FILE_ANY_ACCESS) +//roms: new IOCTL codes +#define IOCTL_BULKUSB_ABORT_PIPES CTL_CODE(FILE_DEVICE_UNKNOWN, \ + BULKUSB_IOCTL_INDEX+3,\ + METHOD_BUFFERED, \ + FILE_ANY_ACCESS) + +#define IOCTL_BULKUSB_CANCEL_PENDING_IO CTL_CODE(FILE_DEVICE_UNKNOWN, \ + BULKUSB_IOCTL_INDEX+4,\ + METHOD_BUFFERED, \ + FILE_ANY_ACCESS) + +#define IOCTL_BULKUSB_SET_TIMEOUT CTL_CODE(FILE_DEVICE_UNKNOWN, \ + BULKUSB_IOCTL_INDEX+5,\ + METHOD_BUFFERED, \ + FILE_ANY_ACCESS) + +#define IOCTL_BULKUSB_GET_TIMEOUT CTL_CODE(FILE_DEVICE_UNKNOWN, \ + BULKUSB_IOCTL_INDEX+6,\ + METHOD_BUFFERED, \ + FILE_ANY_ACCESS) #endif // end, #ifndef BULKUSBH_INC --- /dos/c/98ddk/src/usb/bulkusb/sys/busbdbg.h Mon Jun 15 02:49:42 1998 +++ /dos/c/98ddk/src/usb/tiglusb/sys/busbdbg.h Sat May 25 14:30:30 2002 @@ -57,8 +57,9 @@ // registry path used for parameters global to all instances of the driver +//roms: modified for TIGLUSB #define BULKUSB_REGISTRY_PARAMETERS_PATH \ - L"\\REGISTRY\\Machine\\System\\CurrentControlSet\\SERVICES\\BULKUSB\\Parameters" + L"\\REGISTRY\\Machine\\System\\CurrentControlSet\\SERVICES\\TIGLUSB\\Parameters" --- /dos/c/98ddk/src/usb/bulkusb/sys/bulkpnp.c Sat Sep 5 01:07:08 1998 +++ /dos/c/98ddk/src/usb/tiglusb/sys/bulkpnp.c Sat May 25 14:30:22 2002 @@ -549,7 +549,7 @@ // ( CurrentControlSet\Services\BulkUsb\Parameters ) // Setting to 0 or 1 in registry disables auto power-down BulkUsb_GetRegistryDword( BULKUSB_REGISTRY_PARAMETERS_PATH, - L"PowerDownLevel", + L"PowerDownLevel", // REG_DWORD ValueName &(deviceExtension->PowerDownLevel) ); --- /dos/c/98ddk/src/usb/bulkusb/sys/bulkusb.c Tue Jul 14 06:31:20 1998 +++ /dos/c/98ddk/src/usb/tiglusb/sys/bulkusb.c Sat May 25 18:34:46 2002 @@ -289,7 +289,6 @@ } - NTSTATUS BulkUsb_CreateDeviceObject( IN PDRIVER_OBJECT DriverObject, @@ -366,6 +365,11 @@ //default maximum transfer size per staged io request deviceExtension->MaximumTransferSize = BULKUSB_MAX_TRANSFER_SIZE ; + //roms: default timeout value (1.5s) +#ifdef DEADMAN_TIMER + deviceExtension->TimeoutValue = DEADMAN_TIMEOUT; // in ms +#endif + #if DBG // may be overridden in registry BulkUsb_GetRegistryDword( BULKUSB_REGISTRY_PARAMETERS_PATH, @@ -403,7 +407,6 @@ return ntStatus; } - NTSTATUS BulkUsb_CallUSBD( IN PDEVICE_OBJECT DeviceObject, @@ -555,7 +558,10 @@ // information or the data is truncated without error. // Therefore the 'siz' set below is just a 'good guess', and we may have to retry - siz = sizeof(USB_CONFIGURATION_DESCRIPTOR) + 512; + //roms: force driver to load the entire descriptor (32 bytes) rather than the + //first part (9 bytes) + //siz = sizeof(USB_CONFIGURATION_DESCRIPTOR) + 512; + siz = sizeof(USB_CONFIGURATION_DESCRIPTOR); // We will break out of this 'retry loop' when UsbBuildGetDescriptorRequest() // has a big enough deviceExtension->UsbConfigurationDescriptor buffer not to truncate --- /dos/c/98ddk/src/usb/bulkusb/sys/ioctlblk.c Mon Jun 15 02:52:58 1998 +++ /dos/c/98ddk/src/usb/tiglusb/sys/ioctlblk.c Sat May 25 18:00:00 2002 @@ -90,7 +90,6 @@ // deviceExtension = DeviceObject->DeviceExtension; - // Can't accept a new io request if: // 1) device is removed, @@ -98,6 +97,7 @@ // 3) is stopped, // 4) has a remove request pending, // 5) has a stop device pending + if ( !BulkUsb_CanAcceptIoRequests( DeviceObject ) ) { ntStatus = STATUS_DELETE_PENDING; Irp->IoStatus.Status = ntStatus; @@ -128,29 +128,43 @@ switch (ioControlCode) { case IOCTL_BULKUSB_RESET_PIPE: + + // + // This api tries to reset IN and OUT pipes + // + + // + // inputs - none + // outputs - none + // + { - PUSBD_PIPE_INFORMATION pipe; + //PUSBD_PIPE_INFORMATION pipe; + PUSBD_PIPE_INFORMATION pipeIn, pipeOut; PFILE_OBJECT fileObject; - - // get our context and see if it is a pipe + + // get our context and see if it is a pipe fileObject = irpStack->FileObject; - pipe = (PUSBD_PIPE_INFORMATION) fileObject->FsContext; + //roms: modified (original code does not work) + //pipe = (PUSBD_PIPE_INFORMATION) fileObject->FsContext; + pipeIn = &deviceExtension->UsbInterface->Pipes[0]; + pipeOut = &deviceExtension->UsbInterface->Pipes[1]; - if(pipe == NULL) { + if(pipeIn == NULL || pipeOut == NULL) { // error, this is not a pipe ntStatus = Irp->IoStatus.Status = STATUS_INVALID_PARAMETER; } else { - BulkUsb_ResetPipe(DeviceObject, pipe ); + BulkUsb_ResetPipe(DeviceObject, pipeIn ); + BulkUsb_ResetPipe(DeviceObject, pipeOut); ntStatus = Irp->IoStatus.Status = STATUS_SUCCESS; } } break; - - case IOCTL_BULKUSB_GET_CONFIG_DESCRIPTOR: + case IOCTL_BULKUSB_GET_CONFIG_DESCRIPTOR: // // This api returns a copy of the configuration descriptor @@ -189,12 +203,101 @@ break; + case IOCTL_BULKUSB_RESET_DEVICE: + // + // This api reset the device. Dangerous... + // - case IOCTL_BULKUSB_RESET_DEVICE: + // + // inputs - none + // outputs - none + // ntStatus = BulkUsb_ResetDevice( DeviceObject ); break; + + //roms: added some IOCTL codes + case IOCTL_BULKUSB_ABORT_PIPES: + + // + // This api abort transfer on both pipes + // + + // + // inputs - none + // outputs - none + // + + ntStatus = BulkUsb_AbortPipes( DeviceObject ); + break; + + case IOCTL_BULKUSB_CANCEL_PENDING_IO: + + // + // This api cancels any pending I/O + // + + // + // inputs - none + // outputs - none + // + + ntStatus = BulkUsb_CancelPendingIo(DeviceObject); + break; + + case IOCTL_BULKUSB_SET_TIMEOUT: // set internal timeout (in 0.1s) for I/O operations + + // + // This api set the internal timeout value for I/O operations. + // The timeout value is given in tenth of seconds (0.1s unit). + // + + // + // inputs - a LONG value + // outputs - none + // + + if(inputBufferLength == sizeof(LONG)) + { + PLONG p = (PLONG)ioBuffer; + + if(*p < 10) + { + ntStatus = Irp->IoStatus.Status = STATUS_INVALID_PARAMETER; + } + else + { + deviceExtension->TimeoutValue = 100 * (*p); + ntStatus = Irp->IoStatus.Status = STATUS_SUCCESS; + } + } + else + { + ntStatus = Irp->IoStatus.Status = STATUS_INVALID_PARAMETER; + } + break; + + case IOCTL_BULKUSB_GET_TIMEOUT: // get internal timeout (in 0.1s) for I/O operations + + // + // This api returns the internal timeout value used for I/O operations. + // The timeout value is given in tenth of seconds (0.1s unit). + // + + // + // inputs - none + // outputs - a LONG value + // + + { + PLONG p = (PLONG) ioBuffer; + + outputBufferLength = sizeof(LONG); + *p = deviceExtension->TimeoutValue; + ntStatus = Irp->IoStatus.Status = STATUS_SUCCESS; + break; + } default: --- /dos/c/98ddk/src/usb/bulkusb/sys/ocrwblk.c Sat May 25 18:28:54 2002 +++ /dos/c/98ddk/src/usb/tiglusb/sys/ocrwblk.c Sat May 25 18:38:02 2002 @@ -43,6 +43,62 @@ #include "Blk82930.h" +//roms: install a Timeout mechanism +#ifdef DEADMAN_TIMER +VOID +TiglUsb_StagedReadWriteTimeoutDPC( + IN PKDPC Dpc, + IN PVOID DeferredContext, + IN PVOID SystemArgument1, + IN PVOID SystemArgument2 + ) +/*++ + +Routine Description: + + This routine runs at DISPATCH_LEVEL IRQL. + + This routine cancels any pending I/O irp if the I/O completion + routine has not been called before timeout expires. + + +Arguments: + + Dpc - Pointer to the DPC object. + + DeferredContext - + + SystemArgument1 - not used. + + SystemArgument2 - not used. + +Return Value: + + None. + +--*/ +{ + PDEVICE_OBJECT DeviceObject; +#if DBG + BOOLEAN status; +#endif + + BULKUSB_KdPrint( DBGLVL_MEDIUM,("!!! TIMEOUT !!! All Irp cancelled !\n")); + DeviceObject = DeferredContext; + + +#if DBG + status = +#endif + BulkUsb_CancelPendingIo(DeviceObject); + +#if DBG + ASSERT(status == TRUE); +#endif +} + +#endif /* DEADMAN_TIMER */ + NTSTATUS BulkUsb_StagedReadWrite( @@ -94,7 +150,7 @@ ULONG ChunkSize = deviceExtension->MaximumTransferSize; ULONG arraySize; PBULKUSB_RW_CONTEXT context = NULL; - + LARGE_INTEGER dueTime; //roms: used for timeout BULKUSB_KdPrint ( DBGLVL_DEFAULT, ("enter BulkUsb_StagedReadWrite()\n")); @@ -288,6 +344,18 @@ ntStatus = IoCallDriver(deviceExtension->TopOfStackDeviceObject, (( PBULKUSB_RW_CONTEXT) pCon)->Irp); +#ifdef DEADMAN_TIMER //roms: initialize timer + KeInitializeTimer(&deviceExtension->TimeoutTimer); + KeInitializeDpc(&deviceExtension->TimeoutDpc, + TiglUsb_StagedReadWriteTimeoutDPC, + DeviceObject); + + dueTime.QuadPart = -10000 * deviceExtension->TimeoutValue; //DEADMAN_TIMEOUT; + + KeSetTimer(&deviceExtension->TimeoutTimer, + dueTime, + &deviceExtension->TimeoutDpc); +#endif /* DEADMAN_TIMER */ } else { ntStatus = STATUS_INSUFFICIENT_RESOURCES; @@ -346,9 +414,26 @@ // BULKUSB_KdPrint ( DBGLVL_HIGH, ("BulkUsb_StagedReadWrite(),marking base IRP 0x%x pending!\n", Irp)); BULKUSB_ASSERT( Irp == deviceExtension->BaseIrp ); - ntStatus = STATUS_PENDING; - Irp->IoStatus.Status = ntStatus; - IoMarkIrpPending(Irp); + + if( Irp != deviceExtension->BaseIrp ) // if different -> pb ! + { + BULKUSB_KdPrint ( DBGLVL_MEDIUM, ("Warning !!! Irp asserted !\n")); +#ifdef DEADMAN_TIMER //roms: clear timer + // + // remove our timeoutDPC from the queue + // + KeCancelTimer(&deviceExtension->TimeoutTimer); +#endif /* DEADMAN_TIMER */ + //IoCancelIrp(Irp); + BulkUsb_CancelPendingIo(DeviceObject); + ntStatus = STATUS_INSUFFICIENT_RESOURCES; + } + else + { + ntStatus = STATUS_PENDING; + Irp->IoStatus.Status = ntStatus; + IoMarkIrpPending(Irp); + } } else { // It is possible for BulkUsb_AsyncReadWrite_Complete() to have completed the // original irp before we even get here! @@ -484,6 +569,13 @@ deviceObject = context->DeviceObject; deviceExtension = deviceObject->DeviceExtension; +#ifdef DEADMAN_TIMER //roms: clear timer + // + // remove our timeoutDPC from the queue + // + KeCancelTimer(&deviceExtension->TimeoutTimer); +#endif /* DEADMAN_TIMER */ + // If the lower driver returned PENDING, mark our stack location as pending also. if ( Irp->PendingReturned ) { IoMarkIrpPending(Irp); @@ -506,7 +598,7 @@ deviceExtension->StagedPendingIrpCount--; // decrement the driver's overall pending irp count - BulkUsb_DecrementIoCount(deviceObject); + BulkUsb_DecrementIoCount(deviceObject); // // IoCallDriver has been called on this Irp; @@ -585,7 +677,10 @@ --*/ { - NTSTATUS ntStatus = BulkUsb_StagedReadWrite(DeviceObject, + NTSTATUS ntStatus; + + BULKUSB_KdPrint ( DBGLVL_HIGH, ("READ\n")); + ntStatus = BulkUsb_StagedReadWrite(DeviceObject, Irp, TRUE); // false to write, true to read @@ -618,7 +713,10 @@ --*/ { - NTSTATUS ntStatus = BulkUsb_StagedReadWrite(DeviceObject, + NTSTATUS ntStatus; + + BULKUSB_KdPrint ( DBGLVL_HIGH, ("WRITE\n")); + ntStatus = BulkUsb_StagedReadWrite(DeviceObject, Irp, FALSE); // false to write, true to read @@ -671,6 +769,8 @@ if (fileObject->FsContext) { // closing pipe handle pipeHandle = fileObject->FsContext; + // roms: reset USB pipes (for flushing them) + BulkUsb_ResetPipe(DeviceObject, pipeHandle ); if ( pipeHandle->PipeFlags ) { // set if opneed // may have been abortedDownload Driver Pack
After your driver has been downloaded, follow these simple steps to install it.
Expand the archive file (if the download file is in zip or rar format).
If the expanded file has an .exe extension, double click it and follow the installation instructions.
Otherwise, open Device Manager by right-clicking the Start menu and selecting Device Manager.
Find the device and model you want to update in the device list.
Double-click on it to open the Properties dialog box.
From the Properties dialog box, select the Driver tab.
Click the Update Driver button, then follow the instructions.
Very important: You must reboot your system to ensure that any driver updates have taken effect.
For more help, visit our Driver Support section for step-by-step videos on how to install drivers for every file type.