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.

306 lines
7.6 KiB

  1. /*****************************************************************************
  2. @doc INT EXT
  3. ******************************************************************************
  4. * $ProjectName: $
  5. * $ProjectRevision: $
  6. *-----------------------------------------------------------------------------
  7. * $Source: z:/pr/cmbp0/sw/cmbp0.ms/rcs/cmbp0wdm.h $
  8. * $Revision: 1.3 $
  9. *-----------------------------------------------------------------------------
  10. * $Author: WFrischauf $
  11. *-----------------------------------------------------------------------------
  12. * History: see EOF
  13. *-----------------------------------------------------------------------------
  14. *
  15. * Copyright 2000 OMNIKEY AG
  16. ******************************************************************************/
  17. #if !defined ( __CMMOB_WDM_DRV_H__ )
  18. #define __CMMOB_WDM_DRV_H__
  19. #include "WDM.H"
  20. #include "SMCLIB.H"
  21. #include "PCSC_CM.H"
  22. //
  23. // Constants -----------------------------------------------------------------
  24. //
  25. #undef DRIVER_NAME
  26. #define DRIVER_NAME "CMMOB"
  27. #define SMARTCARD_POOL_TAG 'MOCS'
  28. #define CMMOB_MAX_DEVICE 0x02
  29. #define CARDMAN_MOBILE_DEVICE_NAME L"\\Device\\CM_4000_0"
  30. #define CMMOB_VENDOR_NAME "OMNIKEY"
  31. #define CMMOB_PRODUCT_NAME "CardMan 4000"
  32. #define CMMOB_MAJOR_VERSION 3
  33. #define CMMOB_MINOR_VERSION 2
  34. #define CMMOB_BUILD_NUMBER 1
  35. // reader states
  36. #define UNKNOWN 0xFFFFFFFF
  37. #define REMOVED 0x00000001
  38. #define INSERTED 0x00000002
  39. #define POWERED 0x00000004
  40. #define CMMOB_MAXBUFFER 262
  41. #define CMMOB_MAX_CIS_SIZE 256
  42. // for protocol T=0
  43. #define T0_HEADER_LEN 0x05
  44. #define T0_STATE_LEN 0x02
  45. typedef struct _DEVICE_EXTENSION
  46. {
  47. // Dos device name
  48. UNICODE_STRING LinkDeviceName;
  49. // Our PnP device name
  50. UNICODE_STRING PnPDeviceName;
  51. //memory has been mapped, and must be unmapped during cleanup (remove device)
  52. BOOLEAN fUnMapMem;
  53. //device is opened by application (ScardSrv, CT-API)
  54. LONG lOpenCount;
  55. // Used to signal that the reader is able to process reqeusts
  56. KEVENT ReaderStarted;
  57. // Used to signal that update thread can run
  58. KEVENT CanRunUpdateThread;
  59. // Used to signal that all IO is complete
  60. KEVENT OkToStop;
  61. // Used to signal that all pending IO should be cancelled
  62. KEVENT CancelPendingIO;
  63. // incremented when any IO request is received
  64. // decremented when any IO request is completed or passed on
  65. LONG lIoCount;
  66. // Used to access IoCount;
  67. KSPIN_LOCK SpinLockIoCount;
  68. //Bus drivers set the appropriate values in this structure in response
  69. //to an IRP_MN_QUERY_CAPABILITIES IRP. Function and filter drivers might
  70. //alter the capabilities set by the bus driver.
  71. DEVICE_CAPABILITIES DeviceCapabilities;
  72. //attached DO
  73. PDEVICE_OBJECT AttachedDeviceObject;
  74. //smartcard extension
  75. SMARTCARD_EXTENSION SmartcardExtension;
  76. } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
  77. typedef struct _CARD_PARAMETERS
  78. {
  79. //
  80. // flag if card is synchronous card
  81. //
  82. BOOLEAN fSynchronousCard;
  83. //
  84. // parameters for asynchronous cards
  85. //
  86. UCHAR bBaudRateHigh;
  87. UCHAR bBaudRateLow;
  88. UCHAR bStopBits;
  89. UCHAR bClockFrequency;
  90. //
  91. // flag if card uses invers revers convention
  92. //
  93. BOOLEAN fInversRevers;
  94. //
  95. // flag if card reader is switched to T0 mode
  96. //
  97. BOOLEAN fT0Mode;
  98. BOOLEAN fT0Write;
  99. } CARD_PARAMETERS, *PCARD_PARAMETERS;
  100. typedef enum _READER_POWER_STATE
  101. {
  102. PowerReaderUnspecified = 0,
  103. PowerReaderWorking,
  104. PowerReaderOff
  105. } READER_POWER_STATE, *PREADER_POWER_STATE;
  106. typedef struct _READER_EXTENSION
  107. {
  108. //
  109. // Mem address where the reader is configured.
  110. //
  111. PVOID pIoBase;
  112. ULONG ulIoWindow;
  113. PUCHAR pbRegsBase;
  114. //
  115. // Software revision ID of the firmware.
  116. //
  117. ULONG ulFWVersion;
  118. //
  119. // for communication with UpdateCurrentStateThread
  120. //
  121. BOOLEAN fTerminateUpdateThread;
  122. BOOLEAN fUpdateThreadRunning;
  123. //
  124. // state of the reader
  125. //
  126. ULONG ulOldCardState;
  127. ULONG ulNewCardState;
  128. // only used for hibernation
  129. BOOLEAN fCardPresent;
  130. //
  131. // parameters of inserted card
  132. //
  133. CARD_PARAMETERS CardParameters;
  134. //
  135. // previous value of Flags1 register
  136. //
  137. UCHAR bPreviousFlags1;
  138. // bit 9 of data buffer address
  139. UCHAR bAddressHigh;
  140. // flag Tactive (access to RAM)
  141. BOOLEAN fTActive;
  142. // flag ReadCIS (access to CIS)
  143. BOOLEAN fReadCIS;
  144. //
  145. // mutex for access to CardMan
  146. //
  147. KMUTEX CardManIOMutex;
  148. //
  149. // Handle of the update current state thread
  150. //
  151. PVOID ThreadObjectPointer;
  152. //
  153. // Current reader power state.
  154. //
  155. READER_POWER_STATE ReaderPowerState;
  156. } READER_EXTENSION, *PREADER_EXTENSION;
  157. //
  158. // Extern declarations -----------------------------------------------------------------
  159. //
  160. extern BOOLEAN DeviceSlot[];
  161. //
  162. // Functions -----------------------------------------------------------------
  163. //
  164. void SysDelay( ULONG Timeout );
  165. NTSTATUS DriverEntry(
  166. PDRIVER_OBJECT DriverObject,
  167. PUNICODE_STRING RegistryPath
  168. );
  169. NTSTATUS CMMOB_CreateDevice(
  170. IN PDRIVER_OBJECT DriverObject,
  171. IN PDEVICE_OBJECT PhysicalDeviceObject,
  172. OUT PDEVICE_OBJECT *DeviceObject
  173. );
  174. VOID CMMOB_SetVendorAndIfdName(
  175. IN PDEVICE_OBJECT PhysicalDeviceObject,
  176. IN PSMARTCARD_EXTENSION SmartcardExtension
  177. );
  178. NTSTATUS CMMOB_StartDevice(
  179. PDEVICE_OBJECT DeviceObject,
  180. PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
  181. );
  182. VOID CMMOB_StopDevice(
  183. PDEVICE_OBJECT DeviceObject
  184. );
  185. VOID CMMOB_UnloadDevice(
  186. PDEVICE_OBJECT DeviceObject
  187. );
  188. VOID CMMOB_UnloadDriver(
  189. PDRIVER_OBJECT DriverObject
  190. );
  191. NTSTATUS CMMOB_Cleanup(
  192. PDEVICE_OBJECT DeviceObject,
  193. PIRP Irp
  194. );
  195. NTSTATUS CMMOB_CreateClose(
  196. PDEVICE_OBJECT DeviceObject,
  197. PIRP Irp
  198. );
  199. NTSTATUS CMMOB_DeviceIoControl(
  200. PDEVICE_OBJECT DeviceObject,
  201. PIRP Irp
  202. );
  203. NTSTATUS CMMOB_SystemControl(
  204. PDEVICE_OBJECT DeviceObject,
  205. PIRP Irp
  206. );
  207. NTSTATUS IncIoCount(
  208. PDEVICE_EXTENSION DevExt
  209. );
  210. NTSTATUS DecIoCount(
  211. PDEVICE_EXTENSION DevExt
  212. );
  213. NTSTATUS DecIoCountAndWait(
  214. PDEVICE_EXTENSION DevExt
  215. );
  216. #endif // __CMMOB_WDM_DRV_H__
  217. /*****************************************************************************
  218. * History:
  219. * $Log: cmbp0wdm.h $
  220. * Revision 1.3 2000/07/27 13:53:07 WFrischauf
  221. * No comment given
  222. *
  223. *
  224. ******************************************************************************/