//////////////////////////////////////////////////////////////////////
//
// File: ezusbsys.c
// $Archive: /USB/Drivers/ezusbdrv/ezusbsys.c $
//
// Purpose:
// General purpose USB device driver
//
// Environment:
// kernel mode
//
// $Author: Mdn $
//
// $History: ezusbsys.c $
//
// ***************** Version 6 *****************
// User: Mdn Date: 9/17/01 Time: 10:54a
// Updated in $/USB/Drivers/ezusbdrv
// Fixed memory leak bug in ISO streaming code. Was setting the
// PendingTransfers variable to the wrong value and not properly freeing
// after stopping the ISO stream.
//
// ***************** Version 5 *****************
// User: Mdn Date: 10/06/00 Time: 10:08a
// Updated in $/USB/Drivers/ezusbdrv
// Added IOCTL_EZUSB_SET_FEATURE
//
// ***************** Version 4 *****************
// User: Mdn Date: 8/17/00 Time: 9:46a
// Updated in $/USB/Drivers/ezusbdrv
// added a generic get descriptor function.
//
// ***************** Version 3 *****************
// User: Mdn Date: 8/04/00 Time: 11:41a
// Updated in $/USB/Drivers/ezmon
// added support for monitor download to FX2
//
// ***************** Version 2 *****************
// User: Mdn Date: 7/21/00 Time: 4:27p
// Updated in $/USB/Drivers/ezusbdrv
// Added a Started flag to the device extension. This flag gets set after
// the device has successfully Started. It is used to prevent a potential
// race condition where an application could get a handle (with
// CreateFile()) before the device is completely enumerated.
//
// ***************** Version 1 *****************
// User: Tpm Date: 6/09/00 Time: 6:32p
// Created in $/USB/Drivers/ezusbdrv
//
// ***************** Version 42 *****************
// User: Mdn Date: 5/05/00 Time: 10:24a
// Updated in $/EzUsb/Drivers/ezusbdrv
// comments
//
// ***************** Version 41 *****************
// User: Mdn Date: 4/18/00 Time: 2:45p
// Updated in $/EzUsb/Drivers/ezusbdrv
// fixed memory leak where I wasn't freeing an URB allocated for
// vendor/class requests.
//
// ***************** Version 40 *****************
// User: Mdn Date: 1/21/00 Time: 10:03a
// Updated in $/EzUsb/Drivers/ezusbdrv
// modified device removal code to send an abort message to all pipes
// before proceding with device removal. This solves the deadlock problem
// that can occur when a transfer is pending and the device receives a
// remove message. Before this change, the driver would block the removal
// indefinitely waiting for all pending transfers to complete.
//
// ***************** Version 39 *****************
// User: Markm Date: 12/17/99 Time: 11:17a
// Updated in $/EzUsb/Drivers/ezusbdrv
// Removed interface select workaround for an obscure OSR2.1 bug since the
// driver no longer supports Win95. Changed interface select so that it
// selects the first interface/alternate setting in the config descriptor.
// Before, it was hardcoded to select interface 0, AS 0. This should
// allow the driver to handle composite devices more easily, although I
// haven't tested it.
//
// ***************** Version 38 *****************
// User: Markm Date: 10/06/99 Time: 1:18p
// Updated in $/EzUsb/Drivers/ezusbdrv
// Made changes to Power IRP handling to fix the blue screen on shutdown
// that was occuring under Win2K. Specifically, started using PoXXX()
// calls for handling power IRPs. See code comments in
// Ezusb_DispatchPower(). The PoXXX() calls are not supported by Win95, so
// as of this revision, the driver will no longer work with Windows 95.
//
// ***************** Version 37 *****************
// User: Markm Date: 5/18/99 Time: 3:37p
// Updated in $/EzUsb/Drivers/ezusbdrv
//
// ***************** Version 36 *****************
// User: Markm Date: 4/29/99 Time: 9:48a
// Updated in $/EzUsb/Drivers/ezusbdrv
// Fixed IOCTL_EZUSB_VENDOR_OR_CLASS_REQUEST so that it correctly returns
// the number of bytes transferred.
//
// ***************** Version 35 *****************
// User: Markm Date: 4/16/99 Time: 3:39p
// Updated in $/EzUsb/Drivers/ezusbdrv
// more minor changes to get rid of compiler warnings.
//
// ***************** Version 34 *****************
// User: Markm Date: 4/12/99 Time: 10:26a
// Updated in $/EzUsb/Drivers/ezusbdrv
// minor changes to get rid of compiler warnings.
//
// ***************** Version 33 *****************
// User: Markm Date: 3/25/99 Time: 4:16p
// Updated in $/EzUsb/Drivers/ezusbdrv
// Fixed a bug in the surprise removal code I just added. I was returning
// from the PnP dispatch function without unlocking the device object.
//
// ***************** Version 32 *****************
// User: Markm Date: 3/25/99 Time: 2:03p
// Updated in $/EzUsb/Drivers/ezusbdrv
// Added code to allow unplugs (surprise removal) under NT5 without
// notifying the user.
//
// ***************** Version 31 *****************
// User: Markm Date: 2/23/99 Time: 9:50a
// Updated in $/EzUsb/Drivers/ezusbdrv
// Driver now supports ISO IN streaming with a path to user mode.
//
// ***************** Version 30 *****************
// User: Markm Date: 2/10/99 Time: 3:31p
// Updated in $/EzUsb/Drivers/ezusbdrv
// removed lots of unused code. Added ring buffer support functions.
//
// ***************** Version 29 *****************
// User: Markm Date: 2/01/99 Time: 11:57a
// Updated in $/EzUsb/Drivers/ezusbdrv
// Added preliminary support for ISO streaming.
//
// ***************** Version 28 *****************
// User: Markm Date: 6/12/98 Time: 4:23p
// Updated in $/EzUsb/Drivers/ezusbdrv
// modified pipe reset and abort code so that the driver will work
// correctly under Windows 95 OSR2.1. For Win98, MS changed the size of
// the URB_PIPE_REQUEST structure. They added an extra ulong to it. So,
// a driver compiled with the 98 DDk and run under 95 will send the wrong
// URB size. The solution is to check the USBDI version whenever I do a
// pipe reset or abort. If the USBDI version is pre-win98, I subtract 4
// from the size of the urb.
//
// ***************** Version 27 *****************
// User: Markm Date: 4/10/98 Time: 2:52p
// Updated in $/EZUSB/ezmon
// Modified Intel Hex download code to stop the 8051 before downloading to
// internal RAM.
//
// ***************** Version 26 *****************
// User: Markm Date: 4/09/98 Time: 4:39p
// Updated in $/EZUSB/ezusb driver
// Was not returning status information for ISO transfers. Now it does!
//
// ***************** Version 25 *****************
// User: Markm Date: 4/09/98 Time: 4:39p
// Updated in $/EZUSB/ezmon
// changes for monitor version of driver
//
// ***************** Version 24 *****************
// User: Markm Date: 4/09/98 Time: 3:09p
// Updated in $/EZUSB/ezusb driver
// nothing much
//
// ***************** Version 23 *****************
// User: Markm Date: 4/09/98 Time: 3:00p
// Updated in $/EZUSB/ezusb driver
// Added function to download Intel Hex File records to EZ-USB. For now,
// this function is only used by the conditional build of the driver that
// automatically downloads the Keil monitor.
//
// ***************** Version 22 *****************
// User: Markm Date: 4/07/98 Time: 1:52p
// Updated in $/EZUSB/ezusb driver
// Added IOCTL_EZUSB_GET_DRIVER_VERSION
//
// ***************** Version 21 *****************
// User: Markm Date: 4/06/98 Time: 4:26p
// Updated in $/EZUSB/ezusb driver
//