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.

259 lines
4.2 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. scrcp8t.h
  5. Abstract:
  6. smartcard CP8 serial miniport defines and structures
  7. Author:
  8. Klaus U. Schutz
  9. Revision History:
  10. --*/
  11. #ifndef _SCRCP8T_
  12. #define _SCRCP8T_
  13. #define DRIVER_NAME "SCRCP8T"
  14. #define SMARTCARD_POOL_TAG '8bCS'
  15. #include <ntddk.h>
  16. #include <ntddser.h>
  17. #include "smclib.h"
  18. #include "cp8tlog.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. typedef struct _SERIAL_READER_CONFIG {
  27. //
  28. // flow control
  29. //
  30. SERIAL_HANDFLOW HandFlow;
  31. //
  32. // special characters
  33. //
  34. SERIAL_CHARS SerialChars;
  35. //
  36. // read/write timeouts
  37. //
  38. SERIAL_TIMEOUTS Timeouts;
  39. //
  40. // Baudrate for reader
  41. //
  42. SERIAL_BAUD_RATE BaudRate;
  43. //
  44. // Stop bits, parity configuration
  45. //
  46. SERIAL_LINE_CONTROL LineControl;
  47. //
  48. // Event serial reader uses to signal insert/removal
  49. //
  50. ULONG WaitMask;
  51. } SERIAL_READER_CONFIG, *PSERIAL_READER_CONFIG;
  52. //
  53. // Define the reader specific portion of the smart card extension
  54. //
  55. typedef struct _READER_EXTENSION {
  56. //
  57. // DeviceObject pointer to serial port
  58. //
  59. PDEVICE_OBJECT ConnectedSerialPort;
  60. //
  61. // The dos device name of our smart card reader
  62. //
  63. UNICODE_STRING DosDeviceName;
  64. //
  65. // Used to synchronize access to the smartcard-extension
  66. //
  67. KSPIN_LOCK SpinLock;
  68. //
  69. // This FileObject is needed to close the connection to the serial port.
  70. //
  71. PFILE_OBJECT SerialFileObject;
  72. //
  73. // This struct is used for CardTracking
  74. //
  75. struct {
  76. PIRP Irp;
  77. KEVENT Event;
  78. IO_STATUS_BLOCK IoStatus;
  79. KDPC Dpc;
  80. } CardStatus;
  81. //
  82. // IoRequest to be send to serial driver
  83. //
  84. ULONG SerialIoControlCode;
  85. //
  86. // Flag that indicates we're getting the ModemStatus (used in a DPC)
  87. //
  88. BOOLEAN GetModemStatus;
  89. //
  90. // Variable used to receive the modem status
  91. //
  92. ULONG ModemStatus;
  93. //
  94. // Flag that indicates that the caller requests a power-down or a reset
  95. //
  96. BOOLEAN PowerRequest;
  97. SERIAL_READER_CONFIG SerialConfigData;
  98. } READER_EXTENSION, *PREADER_EXTENSION;
  99. typedef struct _DEVICE_EXTENSION {
  100. SMARTCARD_EXTENSION SmartcardExtension;
  101. } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
  102. //
  103. // Prototypes
  104. //
  105. NTSTATUS
  106. DriverEntry(
  107. IN PDRIVER_OBJECT DriverObject,
  108. IN PUNICODE_STRING RegistryPath
  109. );
  110. VOID
  111. CP8Unload(
  112. IN PDRIVER_OBJECT DriverObject
  113. );
  114. NTSTATUS
  115. CP8CreateClose(
  116. IN PDEVICE_OBJECT DeviceObject,
  117. IN PIRP Irp
  118. );
  119. NTSTATUS
  120. CP8AddDevice(
  121. IN PDRIVER_OBJECT DriverObject,
  122. IN PUNICODE_STRING SerialDeviceName
  123. );
  124. VOID
  125. CP8RemoveDevice(
  126. IN PDEVICE_OBJECT DeviceObject
  127. );
  128. NTSTATUS
  129. CP8DeviceControl(
  130. PDEVICE_OBJECT DeviceObject,
  131. PIRP Irp
  132. );
  133. NTSTATUS
  134. CP8CreateDevice(
  135. IN PDRIVER_OBJECT DriverObject,
  136. IN PUNICODE_STRING SmartcardDeviceName,
  137. IN PUNICODE_STRING SerialDeviceName
  138. );
  139. NTSTATUS
  140. CP8Initialize(
  141. IN PSMARTCARD_EXTENSION SmartcardExtension
  142. );
  143. NTSTATUS
  144. CP8ConfigureSerialPort(
  145. PSMARTCARD_EXTENSION SmartcardExtension
  146. );
  147. NTSTATUS
  148. CP8SerialIo(
  149. IN PSMARTCARD_EXTENSION SmartcardExtension
  150. );
  151. NTSTATUS
  152. CP8InitializeCardTracking(
  153. PSMARTCARD_EXTENSION SmartcardExtension
  154. );
  155. NTSTATUS
  156. CP8StartCardTracking(
  157. PSMARTCARD_EXTENSION SmartcardExtension
  158. );
  159. VOID
  160. CP8UpdateCardStatus(
  161. IN PKDPC EventDpc,
  162. IN PDEVICE_OBJECT DeviceObject,
  163. IN PIRP Irp,
  164. IN PSMARTCARD_EXTENSION SmartcardExtension
  165. );
  166. NTSTATUS
  167. CP8SerialCtsChanged(
  168. IN PDEVICE_OBJECT DeviceObject,
  169. IN PIRP Irp,
  170. IN PSMARTCARD_EXTENSION SmartcardExtension
  171. );
  172. NTSTATUS
  173. CP8Cleanup(
  174. IN PDEVICE_OBJECT DeviceObject,
  175. IN PIRP Irp
  176. );
  177. NTSTATUS
  178. CP8ReaderPower(
  179. PSMARTCARD_EXTENSION SmartcardExtension
  180. );
  181. NTSTATUS
  182. CP8SetProtocol(
  183. PSMARTCARD_EXTENSION SmartcardExtension
  184. );
  185. NTSTATUS
  186. CP8Transmit(
  187. PSMARTCARD_EXTENSION SmartcardExtension
  188. );
  189. NTSTATUS
  190. CP8CardTracking(
  191. PSMARTCARD_EXTENSION SmartcardExtension
  192. );
  193. #endif