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.

315 lines
6.0 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1997 - 1999
  3. Module Name:
  4. scrcp8t.h
  5. Abstract:
  6. smartcard TLP3 serial miniport defines and structures
  7. Author:
  8. Klaus U. Schutz
  9. Revision History:
  10. --*/
  11. #ifndef _BULLTLP3_
  12. #define _BULLTLP3_
  13. #define DRIVER_NAME "BULLTLP3"
  14. #define SMARTCARD_POOL_TAG '3BCS'
  15. #include <ntddk.h>
  16. #include <ntddser.h>
  17. #include "smclib.h"
  18. #include "tlp3log.h"
  19. #define MAXIMUM_SERIAL_READERS 4
  20. #define SMARTCARD_READ SCARD_CTL_CODE(1000)
  21. #define SMARTCARD_WRITE SCARD_CTL_CODE(1001)
  22. #define READ_INTERVAL_TIMEOUT_DEFAULT 1000
  23. #define READ_TOTAL_TIMEOUT_CONSTANT_DEFAULT 3000
  24. #define READ_INTERVAL_TIMEOUT_ATR 0
  25. #define READ_TOTAL_TIMEOUT_CONSTANT_ATR 50
  26. #define READER_CMD_POWER_DOWN 'O'
  27. #define READER_CMD_COLD_RESET 'C'
  28. #define READER_CMD_WARM_RESET 'W'
  29. #define SIM_IO_TIMEOUT 0x00000001
  30. #define SIM_ATR_TRASH 0x00000002
  31. #define SIM_WRONG_STATE 0x00000004
  32. #define SIM_INVALID_STATE 0x00000008
  33. #define SIM_LONG_RESET_TIMEOUT 0x00000010
  34. #define SIM_LONG_IO_TIMEOUT 0x00000020
  35. #define DEBUG_SIMULATION DEBUG_ERROR
  36. typedef enum _READER_POWER_STATE {
  37. PowerReaderUnspecified = 0,
  38. PowerReaderWorking,
  39. PowerReaderOff
  40. } READER_POWER_STATE, *PREADER_POWER_STATE;
  41. typedef struct _SERIAL_READER_CONFIG {
  42. // flow control
  43. SERIAL_HANDFLOW HandFlow;
  44. // special characters
  45. SERIAL_CHARS SerialChars;
  46. // read/write timeouts
  47. SERIAL_TIMEOUTS Timeouts;
  48. // Baudrate for reader
  49. SERIAL_BAUD_RATE BaudRate;
  50. // Stop bits, parity configuration
  51. SERIAL_LINE_CONTROL LineControl;
  52. // Event serial reader uses to signal insert/removal
  53. ULONG SerialWaitMask;
  54. } SERIAL_READER_CONFIG, *PSERIAL_READER_CONFIG;
  55. typedef struct _DEVICE_EXTENSION {
  56. // Our smart card extension
  57. SMARTCARD_EXTENSION SmartcardExtension;
  58. // The current number of io-requests
  59. LONG IoCount;
  60. // Used to signal that the reader is able to process reqeusts
  61. KEVENT ReaderStarted;
  62. // Used to signal the the reader has been closed
  63. LONG ReaderOpen;
  64. // The pnp device name of our smart card reader
  65. UNICODE_STRING PnPDeviceName;
  66. KSPIN_LOCK SpinLock;
  67. // A worker thread that closes the serial driver
  68. PIO_WORKITEM CloseSerial;
  69. } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
  70. //
  71. // Define the reader specific portion of the smart card extension
  72. //
  73. typedef struct _READER_EXTENSION {
  74. // DeviceObject pointer to serial port
  75. PDEVICE_OBJECT AttachedDeviceObject;
  76. // Used to signal that the connection to the serial driver has been closed
  77. KEVENT SerialCloseDone;
  78. // This is used for CardTracking
  79. PIRP SerialStatusIrp;
  80. // IoRequest to be send to serial driver
  81. ULONG SerialIoControlCode;
  82. // Flag that indicates we're getting the ModemStatus (used in a DPC)
  83. BOOLEAN GetModemStatus;
  84. // Variable used to receive the modem status
  85. ULONG ModemStatus;
  86. // Flag that indicates that the caller requests a power-down or a reset
  87. BOOLEAN PowerRequest;
  88. SERIAL_READER_CONFIG SerialConfigData;
  89. // Saved card state for hibernation/sleeping modes.
  90. BOOLEAN CardPresent;
  91. // Current reader power state.
  92. READER_POWER_STATE ReaderPowerState;
  93. #ifdef SIMULATION
  94. ULONG SimulationLevel;
  95. #endif
  96. } READER_EXTENSION, *PREADER_EXTENSION;
  97. #define READER_EXTENSION(member) \
  98. (SmartcardExtension->ReaderExtension->member)
  99. #define READER_EXTENSION_L(member) \
  100. (smartcardExtension->ReaderExtension->member)
  101. #define ATTACHED_DEVICE_OBJECT \
  102. deviceExtension->SmartcardExtension.ReaderExtension->AttachedDeviceObject
  103. //
  104. // Prototypes
  105. //
  106. NTSTATUS
  107. DriverEntry(
  108. IN PDRIVER_OBJECT DriverObject,
  109. IN PUNICODE_STRING RegistryPath
  110. );
  111. NTSTATUS
  112. TLP3PnP(
  113. IN PDEVICE_OBJECT DeviceObject,
  114. IN PIRP Irp
  115. );
  116. NTSTATUS
  117. TLP3AddDevice(
  118. IN PDRIVER_OBJECT DriverObject,
  119. IN PDEVICE_OBJECT PhysicalDeviceObject
  120. );
  121. NTSTATUS
  122. TLP3CreateClose(
  123. IN PDEVICE_OBJECT DeviceObject,
  124. IN PIRP Irp
  125. );
  126. NTSTATUS
  127. TLP3CreateDevice(
  128. IN PDRIVER_OBJECT DriverObject,
  129. OUT PDEVICE_OBJECT *DeviceObject
  130. );
  131. NTSTATUS
  132. TLP3SystemControl(
  133. PDEVICE_OBJECT DeviceObject,
  134. PIRP Irp
  135. );
  136. NTSTATUS
  137. TLP3DeviceControl(
  138. PDEVICE_OBJECT DeviceObject,
  139. PIRP Irp
  140. );
  141. NTSTATUS
  142. TLP3CreateAndStartDevice(
  143. IN PDRIVER_OBJECT DriverObject,
  144. IN PUNICODE_STRING RegistryPath
  145. );
  146. VOID
  147. TLP3RemoveDevice(
  148. PDEVICE_OBJECT DeviceObject
  149. );
  150. VOID
  151. TLP3DriverUnload(
  152. IN PDRIVER_OBJECT DriverObject
  153. );
  154. NTSTATUS
  155. TLP3ConfigureSerialPort(
  156. PSMARTCARD_EXTENSION SmartcardExtension
  157. );
  158. NTSTATUS
  159. TLP3SerialIo(
  160. PSMARTCARD_EXTENSION SmartcardExtension
  161. );
  162. NTSTATUS
  163. TLP3StartSerialEventTracking(
  164. PSMARTCARD_EXTENSION SmartcardExtension
  165. );
  166. NTSTATUS
  167. TLP3SerialEvent(
  168. IN PDEVICE_OBJECT DeviceObject,
  169. IN PIRP Irp,
  170. IN PSMARTCARD_EXTENSION SmartcardExtension
  171. );
  172. NTSTATUS
  173. TLP3Cleanup(
  174. IN PDEVICE_OBJECT DeviceObject,
  175. IN PIRP Irp
  176. );
  177. NTSTATUS
  178. TLP3ReaderPower(
  179. PSMARTCARD_EXTENSION SmartcardExtension
  180. );
  181. NTSTATUS
  182. TLP3SetProtocol(
  183. PSMARTCARD_EXTENSION SmartcardExtension
  184. );
  185. NTSTATUS
  186. TLP3SetParameters(
  187. PSMARTCARD_EXTENSION SmartcardExtension
  188. );
  189. NTSTATUS
  190. TLP3Transmit(
  191. PSMARTCARD_EXTENSION SmartcardExtension
  192. );
  193. NTSTATUS
  194. TLP3CardTracking(
  195. PSMARTCARD_EXTENSION SmartcardExtension
  196. );
  197. NTSTATUS
  198. TLP3VendorIoctl(
  199. PSMARTCARD_EXTENSION SmartcardExtension
  200. );
  201. NTSTATUS
  202. TLP3Cancel(
  203. IN PDEVICE_OBJECT DeviceObject,
  204. IN PIRP Irp
  205. );
  206. NTSTATUS
  207. TLP3CallSerialDriver(
  208. IN PDEVICE_OBJECT DeviceObject,
  209. IN PIRP Irp
  210. );
  211. NTSTATUS
  212. TLP3TransmitT0(
  213. PSMARTCARD_EXTENSION SmartcardExtension
  214. );
  215. NTSTATUS
  216. TLP3Power (
  217. IN PDEVICE_OBJECT DeviceObject,
  218. IN PIRP Irp
  219. );
  220. VOID
  221. TLP3CompleteCardTracking(
  222. IN PSMARTCARD_EXTENSION SmartcardExtension
  223. );
  224. VOID
  225. TLP3CloseSerialPort(
  226. IN PDEVICE_OBJECT DeviceObject,
  227. IN PVOID Context
  228. );
  229. VOID
  230. TLP3StopDevice(
  231. IN PDEVICE_OBJECT DeviceObject
  232. );
  233. #endif