Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

150 lines
5.7 KiB

  1. /***************************************************************************
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. Dot4Usb.sys - Lower Filter Driver for Dot4.sys for USB connected
  5. IEEE 1284.4 devices.
  6. File Name:
  7. DevExt.h
  8. Abstract:
  9. Defines, Globals, Structures, Enums, and Device Extension
  10. Environment:
  11. Kernel mode only
  12. Notes:
  13. THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  14. KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  15. IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  16. PURPOSE.
  17. Copyright (c) 2000 Microsoft Corporation. All Rights Reserved.
  18. Revision History:
  19. 01/18/2000 : created
  20. Author(s):
  21. Doug Fritz (DFritz)
  22. Joby Lafky (JobyL)
  23. ****************************************************************************/
  24. #ifndef _DEVEXT_H_
  25. #define _DEVEXT_H_
  26. //
  27. // Defines
  28. //
  29. #define arraysize(p) (sizeof(p)/sizeof((p)[0])) // number of elements in an array
  30. #define FAILURE_TIMEOUT -(30 * 10 * 1000 * 1000)// 5 seconds (in 100ns units) - used for KeWaitForSingleObject timeout
  31. #define DOT4USBTAG (ULONG)' u4d' // Used as PoolTag and Device Extension Signature
  32. #define SCRATCH_BUFFER_SIZE 512 // buffer size for reading from Interrupt pipe
  33. #ifdef ExAllocatePool // use pool tagging
  34. #undef ExAllocatePool
  35. #define ExAllocatePool(type, size) ExAllocatePoolWithTag((type), (size), DOT4USBTAG)
  36. #endif
  37. //
  38. // Globals
  39. //
  40. extern UNICODE_STRING gRegistryPath; // copy of RegistryPath passed to DriverEntry - Buffer is UNICODE_NULL terminated for flexibilty
  41. extern ULONG gTrace; // events to trace - see debug.h
  42. extern ULONG gBreak; // events that we should break on - see debug.h
  43. //
  44. // Structs (other than Device Extension)
  45. //
  46. typedef struct _USB_RW_CONTEXT { // Used to pass context to IRP Completion Routine
  47. PURB Urb;
  48. BOOLEAN IsWrite;
  49. PDEVICE_OBJECT DevObj;
  50. } USB_RW_CONTEXT, *PUSB_RW_CONTEXT;
  51. //
  52. // Enums
  53. //
  54. typedef enum _USB_REQUEST_TYPE { // Flag used to distinguish Reads from Writes in UsbReadWrite()
  55. UsbReadRequest = 1,
  56. UsbWriteRequest = 2
  57. } USB_REQUEST_TYPE;
  58. typedef enum _PNP_STATE { // PnP Device States
  59. STATE_INITIALIZED,
  60. STATE_STARTING,
  61. STATE_STARTED,
  62. STATE_START_FAILED,
  63. STATE_STOPPED, // implies device was previously started successfully
  64. STATE_SUSPENDED,
  65. STATE_REMOVING,
  66. STATE_REMOVED
  67. } PNP_STATE;
  68. //
  69. // Device Extension
  70. //
  71. typedef struct _DEVICE_EXTENSION {
  72. ULONG Signature1; // extra check that devExt looks like ours - DOT4USBTAG
  73. PDEVICE_OBJECT DevObj; // back pointer to our DeviceObject
  74. PDEVICE_OBJECT Pdo; // our PDO
  75. PDEVICE_OBJECT LowerDevObj; // Device Object returned by IoAttachDeviceToDeviceStack that we send IRPs to
  76. PNP_STATE PnpState; // PnP device state
  77. BOOLEAN IsDLConnected; // is our datalink connected? i.e., between PARDOT3_ CONNECT and DISCONNECT?
  78. UCHAR Spare1[3]; // pad to DWORD boundary
  79. PKEVENT Dot4Event; // datalink event - given to us by dot4.sys to signal when device data avail
  80. USBD_CONFIGURATION_HANDLE ConfigHandle; // handle for the configuration the device is currently in
  81. PUSB_DEVICE_DESCRIPTOR DeviceDescriptor; // ptr to the USB device descriptor for this device
  82. PUSBD_INTERFACE_INFORMATION Interface; // copy of the info structure returned from select_configuration or select_interface
  83. PUSBD_PIPE_INFORMATION WritePipe; // pipe for bulk writes
  84. PUSBD_PIPE_INFORMATION ReadPipe; // pipe for bulk reads
  85. PUSBD_PIPE_INFORMATION InterruptPipe; // pipe for interrupt reads
  86. KSPIN_LOCK SpinLock; // SpinLock to protect extension data
  87. PIRP PollIrp; // irp used for polling device interrupt pipe for device data avail
  88. KSPIN_LOCK PollIrpSpinLock; // SpinLock used to protect changes to Polling Irp for Interrupt Pipe
  89. KEVENT PollIrpEvent; // used by completion routine to signal that cancel of pollIrp has been detected/handled
  90. UCHAR Spare2[3]; // pad to DWORD boundary
  91. DEVICE_CAPABILITIES DeviceCapabilities; // includes a table mapping system power states to device power states.
  92. IO_REMOVE_LOCK RemoveLock; // Synch mechanism to keep us from being removed while we have IRPs active
  93. LONG ResetWorkItemPending;// flag to specify if a "reset pipe" work item is pending
  94. ULONG Signature2; // extra check that devExt looks like ours - DOT4USBTAG
  95. PUSB_RW_CONTEXT InterruptContext; // context for read on interrupt pipe
  96. SYSTEM_POWER_STATE SystemPowerState;
  97. DEVICE_POWER_STATE DevicePowerState;
  98. PIRP CurrentPowerIrp;
  99. } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
  100. typedef struct _DOT4USB_WORKITEM_CONTEXT
  101. {
  102. PIO_WORKITEM ioWorkItem;
  103. PDEVICE_OBJECT deviceObject;
  104. PUSBD_PIPE_INFORMATION pPipeInfo;
  105. PIRP irp;
  106. } DOT4USB_WORKITEM_CONTEXT,*PDOT4USB_WORKITEM_CONTEXT;
  107. #endif // _DEVEXT_H_