Source code of Windows XP (NT5)
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.

349 lines
7.9 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. #ifdef NT4
  20. #include <NTDDK.H>
  21. #include <NTDDDISK.H>
  22. #else
  23. #include "WDM.H"
  24. #endif
  25. #include "SMCLIB.H"
  26. #include "PCSC_CM.H"
  27. //#define MEMORYCARD
  28. #define IOCARD
  29. //
  30. // Constants -----------------------------------------------------------------
  31. //
  32. #undef DRIVER_NAME
  33. #define DRIVER_NAME "CMMOB"
  34. #define SMARTCARD_POOL_TAG 'MOCS'
  35. #define CMMOB_MAX_DEVICE 0x02
  36. #define CARDMAN_MOBILE_DEVICE_NAME L"\\Device\\CM_4000_0"
  37. #define CMMOB_VENDOR_NAME "OMNIKEY"
  38. #define CMMOB_PRODUCT_NAME "CardMan 4000"
  39. #define CMMOB_MAJOR_VERSION 3
  40. #define CMMOB_MINOR_VERSION 2
  41. #define CMMOB_BUILD_NUMBER 1
  42. // reader states
  43. #define UNKNOWN 0xFFFFFFFF
  44. #define REMOVED 0x00000001
  45. #define INSERTED 0x00000002
  46. #define POWERED 0x00000004
  47. #define CMMOB_MAXBUFFER 262
  48. #define CMMOB_MAX_CIS_SIZE 256
  49. // for protocol T=0
  50. #define T0_HEADER_LEN 0x05
  51. #define T0_STATE_LEN 0x02
  52. typedef enum _OS_VERSION
  53. {
  54. OS_Unspecified = 0,
  55. OS_Windows95,
  56. OS_Windows98,
  57. OS_Windows98SE,
  58. OS_WindowsME,
  59. OS_Windows2000
  60. } OS_VERSION;
  61. #ifdef DBG
  62. static const PCHAR szOSVersion[] =
  63. {
  64. "Unspecified",
  65. "Windows95",
  66. "Windows98",
  67. "Windows98SE",
  68. "WindowsME",
  69. "Windows2000"
  70. };
  71. #endif
  72. typedef struct _DEVICE_EXTENSION
  73. {
  74. // Dos device name
  75. UNICODE_STRING LinkDeviceName;
  76. #ifndef NT4
  77. // Our PnP device name
  78. UNICODE_STRING PnPDeviceName;
  79. //detected OS version
  80. OS_VERSION OSVersion;
  81. #endif
  82. //memory has been mapped, and must be unmapped during cleanup (remove device)
  83. BOOLEAN fUnMapMem;
  84. //device is opened by application (ScardSrv, CT-API)
  85. LONG lOpenCount;
  86. // Used to signal that the reader is able to process reqeusts
  87. KEVENT ReaderStarted;
  88. //device has been removed
  89. BOOLEAN fDeviceRemoved;
  90. //removing device now
  91. BOOLEAN fRemovePending;
  92. // Used to signal that update thread can run
  93. KEVENT CanRunUpdateThread;
  94. // incremented when any IO request is received
  95. // decremented when any IO request is completed or passed on
  96. LONG lIoCount;
  97. // Used to access IoCount;
  98. KSPIN_LOCK SpinLockIoCount;
  99. #ifndef NT4
  100. //Bus drivers set the appropriate values in this structure in response
  101. //to an IRP_MN_QUERY_CAPABILITIES IRP. Function and filter drivers might
  102. //alter the capabilities set by the bus driver.
  103. DEVICE_CAPABILITIES DeviceCapabilities;
  104. #endif
  105. //attached DO
  106. PDEVICE_OBJECT AttachedDeviceObject;
  107. //smartcard extension
  108. SMARTCARD_EXTENSION SmartcardExtension;
  109. } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
  110. typedef struct _CARD_PARAMETERS
  111. {
  112. //
  113. // flag if card is synchronous card
  114. //
  115. BOOLEAN fSynchronousCard;
  116. //
  117. // parameters for asynchronous cards
  118. //
  119. UCHAR bBaudRateHigh;
  120. UCHAR bBaudRateLow;
  121. UCHAR bStopBits;
  122. UCHAR bClockFrequency;
  123. //
  124. // flag if card uses invers revers convention
  125. //
  126. BOOLEAN fInversRevers;
  127. //
  128. // flag if card reader is switched to T0 mode
  129. //
  130. BOOLEAN fT0Mode;
  131. BOOLEAN fT0Write;
  132. } CARD_PARAMETERS, *PCARD_PARAMETERS;
  133. typedef enum _READER_POWER_STATE
  134. {
  135. PowerReaderUnspecified = 0,
  136. PowerReaderWorking,
  137. PowerReaderOff
  138. } READER_POWER_STATE, *PREADER_POWER_STATE;
  139. typedef struct _READER_EXTENSION
  140. {
  141. #ifdef MEMORYCARD
  142. //
  143. // Mem address where the reader is configured.
  144. //
  145. PVOID pMemBase;
  146. ULONG ulMemWindow;
  147. PUCHAR pbCISBase;
  148. PUCHAR pbRegsBase;
  149. PUCHAR pbDataBase;
  150. #endif
  151. #ifdef IOCARD
  152. //
  153. // Mem address where the reader is configured.
  154. //
  155. PVOID pIoBase;
  156. ULONG ulIoWindow;
  157. PUCHAR pbRegsBase;
  158. #endif
  159. //
  160. // Software revision ID of the firmware.
  161. //
  162. ULONG ulFWVersion;
  163. //
  164. // for communication with UpdateCurrentStateThread
  165. //
  166. BOOLEAN fTerminateUpdateThread;
  167. BOOLEAN fUpdateThreadRunning;
  168. //
  169. // state of the reader
  170. //
  171. ULONG ulOldCardState;
  172. ULONG ulNewCardState;
  173. // only used for hibernation
  174. BOOLEAN fCardPresent;
  175. //
  176. // parameters of inserted card
  177. //
  178. CARD_PARAMETERS CardParameters;
  179. //
  180. // previous value of Flags1 register
  181. //
  182. UCHAR bPreviousFlags1;
  183. #ifdef IOCARD
  184. // bit 9 of data buffer address
  185. UCHAR bAddressHigh;
  186. // flag Tactive (access to RAM)
  187. BOOLEAN fTActive;
  188. // flag ReadCIS (access to CIS)
  189. BOOLEAN fReadCIS;
  190. #endif
  191. //
  192. // mutex for access to CardMan
  193. //
  194. KMUTEX CardManIOMutex;
  195. //
  196. // Handle of the update current state thread
  197. //
  198. PVOID ThreadObjectPointer;
  199. //
  200. // Current reader power state.
  201. //
  202. READER_POWER_STATE ReaderPowerState;
  203. } READER_EXTENSION, *PREADER_EXTENSION;
  204. //
  205. // Extern declarations -----------------------------------------------------------------
  206. //
  207. extern BOOLEAN DeviceSlot[];
  208. //
  209. // Functions -----------------------------------------------------------------
  210. //
  211. void SysDelay( ULONG Timeout );
  212. NTSTATUS DriverEntry(
  213. PDRIVER_OBJECT DriverObject,
  214. PUNICODE_STRING RegistryPath
  215. );
  216. NTSTATUS CMMOB_CreateDevice(
  217. IN PDRIVER_OBJECT DriverObject,
  218. IN PDEVICE_OBJECT PhysicalDeviceObject,
  219. OUT PDEVICE_OBJECT *DeviceObject
  220. );
  221. VOID CMMOB_SetVendorAndIfdName(
  222. IN PDEVICE_OBJECT PhysicalDeviceObject,
  223. IN PSMARTCARD_EXTENSION SmartcardExtension
  224. );
  225. NTSTATUS CMMOB_StartDevice(
  226. PDEVICE_OBJECT DeviceObject,
  227. PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
  228. );
  229. VOID CMMOB_StopDevice(
  230. PDEVICE_OBJECT DeviceObject
  231. );
  232. VOID CMMOB_UnloadDevice(
  233. PDEVICE_OBJECT DeviceObject
  234. );
  235. VOID CMMOB_UnloadDriver(
  236. PDRIVER_OBJECT DriverObject
  237. );
  238. NTSTATUS CMMOB_Cleanup(
  239. PDEVICE_OBJECT DeviceObject,
  240. PIRP Irp
  241. );
  242. NTSTATUS CMMOB_CreateClose(
  243. PDEVICE_OBJECT DeviceObject,
  244. PIRP Irp
  245. );
  246. NTSTATUS CMMOB_DeviceIoControl(
  247. PDEVICE_OBJECT DeviceObject,
  248. PIRP Irp
  249. );
  250. NTSTATUS CMMOB_SystemControl(
  251. PDEVICE_OBJECT DeviceObject,
  252. PIRP Irp
  253. );
  254. #endif // __CMMOB_WDM_DRV_H__
  255. /*****************************************************************************
  256. * History:
  257. * $Log: cmbp0wdm.h $
  258. * Revision 1.3 2000/07/27 13:53:07 WFrischauf
  259. * No comment given
  260. *
  261. *
  262. ******************************************************************************/