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.

286 lines
6.0 KiB

  1. /*++
  2. Copyright (c) 1997 - 1999 SCM Microsystems, Inc.
  3. Module Name:
  4. PscrNT.h
  5. Abstract:
  6. Driver header - NT Version
  7. Author:
  8. Andreas Straub (SCM Microsystems, Inc.)
  9. Klaus Schuetz (Microsoft Corp.)
  10. Revision History:
  11. Andreas Straub 1.00 8/18/1997 Initial Version
  12. Klaus Schuetz 1.01 9/20/1997 Timing changed
  13. Andreas Straub 1.02 9/24/1997 Low Level error handling,
  14. minor bugfixes, clanup
  15. Andreas Straub 1.03 10/8/1997 Timing changed, generic SCM
  16. interface changed
  17. Andreas Straub 1.04 10/18/1997 Interrupt handling changed
  18. Andreas Straub 1.05 10/19/1997 Generic IOCTL's added
  19. Andreas Straub 1.06 10/25/1997 Timeout limit for FW update variable
  20. Andreas Straub 1.07 11/7/1997 Version information added
  21. Andreas Straub 1.08 11/10/1997 Generic IOCTL GET_CONFIGURATION
  22. Klaus Schuetz 1998 PnP and Power Management added
  23. --*/
  24. #if !defined ( __PSCR_NT_DRV_H__ )
  25. #define __PSCR_NT_DRV_H__
  26. #define SMARTCARD_POOL_TAG '4SCS'
  27. #include <wdm.h>
  28. #include <DEVIOCTL.H>
  29. #include "SMCLIB.h"
  30. #include "WINSMCRD.h"
  31. #include "PscrRdWr.h"
  32. #if !defined( STATUS_DEVICE_REMOVED )
  33. #define STATUS_DEVICE_REMOVED STATUS_UNSUCCESSFUL
  34. #endif
  35. #define SysCompareMemory( p1, p2, Len ) ( RtlCompareMemory( p1,p2, Len ) != Len )
  36. #define SysCopyMemory( pDest, pSrc, Len ) RtlCopyMemory( pDest, pSrc, Len )
  37. #define SysFillMemory( pDest, Value, Len ) RtlFillMemory( pDest, Len, Value )
  38. #define DELAY_WRITE_PSCR_REG 1
  39. #define DELAY_PSCR_WAIT 5
  40. #define LOBYTE( any ) ((UCHAR)( any & 0xFF ) )
  41. #define HIBYTE( any ) ((UCHAR)( ( any >> 8) & 0xFF ))
  42. typedef struct _DEVICE_EXTENSION
  43. {
  44. SMARTCARD_EXTENSION SmartcardExtension;
  45. // The PDO that we are attached to
  46. PDEVICE_OBJECT AttachedPDO;
  47. // The DPC object for post interrupt processing
  48. KDPC DpcObject;
  49. // Out interrupt resource
  50. PKINTERRUPT InterruptObject;
  51. // Flag that indicates if we need to unmap the port upon stop
  52. BOOLEAN UnMapPort;
  53. // Our PnP device name
  54. UNICODE_STRING DeviceName;
  55. // Current number of io-requests
  56. LONG IoCount;
  57. // Used to access IoCount;
  58. KSPIN_LOCK SpinLock;
  59. // Used to signal that the device has been removed
  60. KEVENT ReaderRemoved;
  61. // Used to signal that the reader is able to process reqeusts
  62. KEVENT ReaderStarted;
  63. // Used to signal the the reader has been closed
  64. LONG ReaderOpen;
  65. // Used to keep track of the current power state the reader is in
  66. LONG PowerState;
  67. // Number of pending card tracking interrupts
  68. ULONG PendingInterrupts;
  69. } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
  70. #define PSCR_MAX_DEVICE 2
  71. #define IOCTL_PSCR_COMMAND SCARD_CTL_CODE( 0x8000 )
  72. #define IOCTL_GET_VERSIONS SCARD_CTL_CODE( 0x8001 )
  73. #define IOCTL_SET_TIMEOUT SCARD_CTL_CODE( 0x8002 )
  74. #define IOCTL_GET_CONFIGURATION SCARD_CTL_CODE( 0x8003 )
  75. typedef struct _VERSION_CONTROL
  76. {
  77. ULONG SmclibVersion;
  78. UCHAR DriverMajor,
  79. DriverMinor,
  80. FirmwareMajor,
  81. FirmwareMinor,
  82. UpdateKey;
  83. } VERSION_CONTROL, *PVERSION_CONTROL;
  84. #define SIZEOF_VERSION_CONTROL sizeof( VERSION_CONTROL )
  85. typedef struct _PSCR_CONFIGURATION
  86. {
  87. PPSCR_REGISTERS IOBase;
  88. ULONG IRQ;
  89. } PSCR_CONFIGURATION, *PPSCR_CONFIGURATION;
  90. #define SIZEOF_PSCR_CONFIGURATION sizeof( PSCR_CONFIGURATION )
  91. void SysDelay( ULONG Timeout );
  92. BOOLEAN
  93. PscrMapIOPort(
  94. INTERFACE_TYPE InterfaceType,
  95. ULONG BusNumber,
  96. PHYSICAL_ADDRESS BusAddress,
  97. ULONG Length,
  98. PULONG pIOPort
  99. );
  100. NTSTATUS
  101. DriverEntry(
  102. PDRIVER_OBJECT DriverObject,
  103. PUNICODE_STRING RegistryPath
  104. );
  105. NTSTATUS
  106. PscrPnP(
  107. IN PDEVICE_OBJECT DeviceObject,
  108. IN PIRP Irp
  109. );
  110. NTSTATUS
  111. PscrPower(
  112. IN PDEVICE_OBJECT DeviceObject,
  113. IN PIRP Irp
  114. );
  115. NTSTATUS
  116. PscrCreateAndStartDevice(
  117. PDRIVER_OBJECT DriverObject
  118. );
  119. NTSTATUS
  120. PscrCreateDevice(
  121. IN PDRIVER_OBJECT DriverObject,
  122. OUT PDEVICE_OBJECT *DeviceObject
  123. );
  124. NTSTATUS
  125. PscrStartDevice(
  126. PDEVICE_OBJECT DeviceObject,
  127. PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
  128. );
  129. NTSTATUS
  130. PscrPcmciaCallComplete(
  131. IN PDEVICE_OBJECT DeviceObject,
  132. IN PIRP Irp,
  133. IN PKEVENT Event
  134. );
  135. VOID
  136. PscrStopDevice(
  137. PDEVICE_OBJECT DeviceObject
  138. );
  139. NTSTATUS
  140. PscrReportResources(
  141. PDRIVER_OBJECT DriverObject,
  142. PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDesciptor
  143. );
  144. NTSTATUS
  145. PscrAddDevice(
  146. IN PDRIVER_OBJECT DriverObject,
  147. IN PDEVICE_OBJECT PhysicalDeviceObject
  148. );
  149. VOID
  150. PscrUnloadDevice(
  151. PDEVICE_OBJECT DeviceObject
  152. );
  153. VOID
  154. PscrUnloadDriver(
  155. PDRIVER_OBJECT DriverObject
  156. );
  157. BOOLEAN
  158. IsPnPDriver(
  159. void
  160. );
  161. VOID
  162. PscrFinishPendingRequest(
  163. PDEVICE_OBJECT DeviceObject,
  164. NTSTATUS NTStatus
  165. );
  166. NTSTATUS
  167. PscrCancel(
  168. PDEVICE_OBJECT DeviceObject,
  169. PIRP Irp
  170. );
  171. NTSTATUS
  172. PscrCleanup(
  173. PDEVICE_OBJECT DeviceObject,
  174. PIRP Irp
  175. );
  176. BOOLEAN
  177. PscrIrqServiceRoutine(
  178. PKINTERRUPT Interrupt,
  179. PDEVICE_EXTENSION DeviceExtension
  180. );
  181. VOID
  182. PscrDpcRoutine(
  183. PKDPC Dpc,
  184. PDEVICE_OBJECT DeviceObject,
  185. PDEVICE_EXTENSION DeviceExtension,
  186. PSMARTCARD_EXTENSION SmartcardExtension
  187. );
  188. NTSTATUS
  189. PscrGenericIOCTL(
  190. PSMARTCARD_EXTENSION SmartcardExtension
  191. );
  192. NTSTATUS
  193. PscrCreateClose(
  194. PDEVICE_OBJECT DeviceObject,
  195. PIRP Irp
  196. );
  197. NTSTATUS
  198. PscrSystemControl(
  199. PDEVICE_OBJECT DeviceObject,
  200. PIRP Irp
  201. );
  202. NTSTATUS
  203. PscrDeviceIoControl(
  204. PDEVICE_OBJECT DeviceObject,
  205. PIRP Irp
  206. );
  207. VOID
  208. PscrInterruptEvent(
  209. IN PDEVICE_OBJECT DeviceObject
  210. );
  211. VOID
  212. PscrFreeze(
  213. PSMARTCARD_EXTENSION SmartcardExtension
  214. );
  215. NTSTATUS
  216. PscrCallPcmciaDriver(
  217. IN PDEVICE_OBJECT AttachedPDO,
  218. IN PIRP Irp
  219. );
  220. #endif // __PSCR_NT_DRV_H__