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.

300 lines
5.2 KiB

  1. /*++
  2. Copyright (c) 1997 Rainbow Technologies Inc.
  3. Module Name:
  4. RNBO3531.h
  5. Abstract:
  6. Author:
  7. Mehdi Sotoodeh mehdi@rainbow.com
  8. Environment:
  9. Kernel mode
  10. Revision History :
  11. Jan 98 - Started from the DDK sources from Klaus Schutz
  12. Mar 98 - PnP support added
  13. Apr 98 - Changes on card timings and PnP
  14. - Added power management
  15. May 98 - RemoveLock changes
  16. --*/
  17. #ifndef _RNBO3531_
  18. #define _RNBO3531_
  19. #define VENDOR_NAME "Rainbow Technologies"
  20. #define DRIVER_NAME "RNBO3531"
  21. #define READER_NAME "CardTerm"
  22. #define SMARTCARD_POOL_TAG 'brCS'
  23. #include <ntddk.h>
  24. #include <ntddser.h>
  25. #if _WIN32_WINNT >= 0x0500
  26. #define NT5
  27. #endif
  28. #include "smclib.h"
  29. #include "RbSclog.h"
  30. #include "Ifddefs.h"
  31. #ifndef NT5
  32. #define MAXIMUM_SERIAL_READERS 4
  33. #endif
  34. #define SMARTCARD_READ SCARD_CTL_CODE(1000)
  35. #define SMARTCARD_WRITE SCARD_CTL_CODE(1001)
  36. #ifdef NT5
  37. typedef enum _READER_POWER_STATE {
  38. PowerReaderUnspecified = 0,
  39. PowerReaderWorking,
  40. PowerReaderOff
  41. } READER_POWER_STATE, *PREADER_POWER_STATE;
  42. #endif
  43. //
  44. // Define the reader specific portion of the smart card extension
  45. //
  46. typedef struct _READER_EXTENSION
  47. {
  48. //
  49. // DeviceObject pointer to serial port
  50. //
  51. PDEVICE_OBJECT AttachedSerialPort;
  52. //
  53. // Synchronization objects
  54. //
  55. KEVENT ReaderStarted;
  56. //KEVENT ReaderClosed;
  57. KEVENT SerialCloseDone;
  58. // Used to keep track of open close calls
  59. LONG ReaderOpen;
  60. #ifdef NT5
  61. UNICODE_STRING PnPDeviceName;
  62. ULONG DataRatesSupported[9];
  63. #else
  64. //
  65. // The dos device name of our smart card reader
  66. //
  67. UNICODE_STRING DosDeviceName;
  68. //
  69. // This FileObject is needed to close the connection to the serial port.
  70. //
  71. PFILE_OBJECT SerialFileObject;
  72. #endif
  73. //
  74. // This struct is used for CardTracking
  75. //
  76. PIRP SerialStatusIrp;
  77. // The current number of io-requests and its spinlock
  78. LONG IoCount;
  79. KSPIN_LOCK SpinLock;
  80. // Flag that indicates we're getting the ModemStatus
  81. BOOLEAN GetModemStatus;
  82. // Saved card state for hibernation/sleeping modes.
  83. BOOLEAN CardPresent;
  84. // Flag that indicates that the caller requests a power-down or a reset
  85. BOOLEAN PowerRequest;
  86. // Variable used to receive the modem status
  87. ULONG ModemStatus;
  88. // Event serial reader uses to signal insert/removal
  89. ULONG WaitMask;
  90. //
  91. // Stop bits, parity configuration
  92. //
  93. SERIAL_LINE_CONTROL LineControl;
  94. SERIAL_TIMEOUTS SerialTimeouts;
  95. #ifdef NT5
  96. // Used to keep track of the current power state the reader is in
  97. READER_POWER_STATE ReaderPowerState;
  98. #endif
  99. // A worker thread that closes the serial driver
  100. PIO_WORKITEM CloseSerial;
  101. SMARTCARD_EXTENSION SmartcardExtension;
  102. } READER_EXTENSION, *PREADER_EXTENSION;
  103. //
  104. // Prototypes
  105. //
  106. NTSTATUS
  107. DriverEntry(
  108. PDRIVER_OBJECT DriverObject,
  109. PUNICODE_STRING RegistryPath
  110. );
  111. VOID
  112. RBSCUnloadDriver(
  113. PDRIVER_OBJECT DriverObject
  114. );
  115. NTSTATUS
  116. RBSCCreateClose(
  117. PDEVICE_OBJECT DeviceObject,
  118. PIRP Irp
  119. );
  120. NTSTATUS
  121. RBSCAddDevice(
  122. PDRIVER_OBJECT DriverObject,
  123. PDEVICE_OBJECT PhysicalDeviceObject
  124. );
  125. VOID
  126. RBSCRemoveDevice(
  127. PDEVICE_OBJECT DeviceObject
  128. );
  129. NTSTATUS
  130. RBSCDeviceControl(
  131. PDEVICE_OBJECT DeviceObject,
  132. PIRP Irp
  133. );
  134. NTSTATUS
  135. RBSCConfigureSerialPort(
  136. PREADER_EXTENSION ReaderExtension
  137. );
  138. NTSTATUS
  139. RBSCSerialIo(
  140. PSMARTCARD_EXTENSION SmartcardExtension,
  141. ULONG SerialIoControlCode,
  142. PUCHAR TxBuffer,
  143. ULONG TxSize,
  144. ULONG RxSize
  145. );
  146. NTSTATUS
  147. RBSCSetCommParams(
  148. PSMARTCARD_EXTENSION SmartcardExtension,
  149. ULONG DataRate
  150. );
  151. NTSTATUS
  152. RBSCPacketExchange(
  153. PSMARTCARD_EXTENSION SmartcardExtension,
  154. PUCHAR Command,
  155. ULONG Length,
  156. ULONG WaitTime,
  157. BOOLEAN IfdResponse
  158. );
  159. NTSTATUS
  160. RBSCReadFromCard(
  161. PSMARTCARD_EXTENSION SmartcardExtension,
  162. ULONG Length
  163. );
  164. NTSTATUS
  165. RBSCWriteToCard(
  166. PSMARTCARD_EXTENSION SmartcardExtension,
  167. PUCHAR Buffer,
  168. ULONG Length
  169. );
  170. NTSTATUS
  171. RBSCSerialEvents(
  172. PDEVICE_OBJECT DeviceObject,
  173. PIRP Irp,
  174. PREADER_EXTENSION ReaderExtension
  175. );
  176. NTSTATUS
  177. RBSCCleanup(
  178. PDEVICE_OBJECT DeviceObject,
  179. PIRP Irp
  180. );
  181. NTSTATUS
  182. RBSCReaderPower(
  183. PSMARTCARD_EXTENSION SmartcardExtension
  184. );
  185. NTSTATUS
  186. RBSCSetProtocol(
  187. PSMARTCARD_EXTENSION SmartcardExtension
  188. );
  189. NTSTATUS
  190. RBSCTransmit(
  191. PSMARTCARD_EXTENSION SmartcardExtension
  192. );
  193. NTSTATUS
  194. RBSCT0Transmit(
  195. PSMARTCARD_EXTENSION SmartcardExtension
  196. );
  197. NTSTATUS
  198. RBSCT1Transmit(
  199. PSMARTCARD_EXTENSION SmartcardExtension
  200. );
  201. NTSTATUS
  202. RBSCCardTracking(
  203. PSMARTCARD_EXTENSION SmartcardExtension
  204. );
  205. VOID
  206. RBSCCompleteCardTracking(
  207. PSMARTCARD_EXTENSION SmartcardExtension
  208. );
  209. NTSTATUS
  210. RBSCStartDevice(
  211. PDEVICE_OBJECT DeviceObject
  212. );
  213. #ifdef NT5
  214. NTSTATUS
  215. RBSCPnPDeviceControl(
  216. PDEVICE_OBJECT DeviceObject,
  217. PIRP Irp
  218. );
  219. VOID
  220. RBSCCloseSerialPort(
  221. PDEVICE_OBJECT DeviceObject,
  222. PVOID Context
  223. );
  224. NTSTATUS
  225. RBSCCallSerialDriver(
  226. PDEVICE_OBJECT AttachedSerialPort,
  227. PIRP Irp
  228. );
  229. NTSTATUS
  230. RBSCPower (
  231. IN PDEVICE_OBJECT DeviceObject,
  232. IN PIRP Irp
  233. );
  234. #endif
  235. VOID
  236. RBSCStopDevice(
  237. PREADER_EXTENSION ReaderExtension
  238. );
  239. #endif