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.

304 lines
6.1 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. VOID
  142. TLP3RemoveDevice(
  143. PDEVICE_OBJECT DeviceObject
  144. );
  145. VOID
  146. TLP3DriverUnload(
  147. IN PDRIVER_OBJECT DriverObject
  148. );
  149. NTSTATUS
  150. TLP3ConfigureSerialPort(
  151. PSMARTCARD_EXTENSION SmartcardExtension
  152. );
  153. NTSTATUS
  154. TLP3SerialIo(
  155. PSMARTCARD_EXTENSION SmartcardExtension
  156. );
  157. NTSTATUS
  158. TLP3StartSerialEventTracking(
  159. PSMARTCARD_EXTENSION SmartcardExtension
  160. );
  161. NTSTATUS
  162. TLP3SerialEvent(
  163. IN PDEVICE_OBJECT DeviceObject,
  164. IN PIRP Irp,
  165. IN PSMARTCARD_EXTENSION SmartcardExtension
  166. );
  167. NTSTATUS
  168. TLP3Cleanup(
  169. IN PDEVICE_OBJECT DeviceObject,
  170. IN PIRP Irp
  171. );
  172. NTSTATUS
  173. TLP3ReaderPower(
  174. PSMARTCARD_EXTENSION SmartcardExtension
  175. );
  176. NTSTATUS
  177. TLP3SetProtocol(
  178. PSMARTCARD_EXTENSION SmartcardExtension
  179. );
  180. NTSTATUS
  181. TLP3Transmit(
  182. PSMARTCARD_EXTENSION SmartcardExtension
  183. );
  184. NTSTATUS
  185. TLP3CardTracking(
  186. PSMARTCARD_EXTENSION SmartcardExtension
  187. );
  188. NTSTATUS
  189. TLP3VendorIoctl(
  190. PSMARTCARD_EXTENSION SmartcardExtension
  191. );
  192. NTSTATUS
  193. TLP3Cancel(
  194. IN PDEVICE_OBJECT DeviceObject,
  195. IN PIRP Irp
  196. );
  197. NTSTATUS
  198. TLP3CallSerialDriver(
  199. IN PDEVICE_OBJECT DeviceObject,
  200. IN PIRP Irp
  201. );
  202. NTSTATUS
  203. TLP3TransmitT0(
  204. PSMARTCARD_EXTENSION SmartcardExtension
  205. );
  206. NTSTATUS
  207. TLP3Power (
  208. IN PDEVICE_OBJECT DeviceObject,
  209. IN PIRP Irp
  210. );
  211. VOID
  212. TLP3CompleteCardTracking(
  213. IN PSMARTCARD_EXTENSION SmartcardExtension
  214. );
  215. VOID
  216. TLP3CloseSerialPort(
  217. IN PDEVICE_OBJECT DeviceObject,
  218. IN PVOID Context
  219. );
  220. VOID
  221. TLP3StopDevice(
  222. IN PDEVICE_OBJECT DeviceObject
  223. );
  224. #endif