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.

275 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. PscrStartDevice(
  117. PDEVICE_OBJECT DeviceObject,
  118. PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
  119. );
  120. NTSTATUS
  121. PscrPcmciaCallComplete(
  122. IN PDEVICE_OBJECT DeviceObject,
  123. IN PIRP Irp,
  124. IN PKEVENT Event
  125. );
  126. VOID
  127. PscrStopDevice(
  128. PDEVICE_OBJECT DeviceObject
  129. );
  130. NTSTATUS
  131. PscrReportResources(
  132. PDRIVER_OBJECT DriverObject,
  133. PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDesciptor
  134. );
  135. NTSTATUS
  136. PscrAddDevice(
  137. IN PDRIVER_OBJECT DriverObject,
  138. IN PDEVICE_OBJECT PhysicalDeviceObject
  139. );
  140. VOID
  141. PscrUnloadDevice(
  142. PDEVICE_OBJECT DeviceObject
  143. );
  144. VOID
  145. PscrUnloadDriver(
  146. PDRIVER_OBJECT DriverObject
  147. );
  148. BOOLEAN
  149. IsPnPDriver(
  150. void
  151. );
  152. VOID
  153. PscrFinishPendingRequest(
  154. PDEVICE_OBJECT DeviceObject,
  155. NTSTATUS NTStatus
  156. );
  157. NTSTATUS
  158. PscrCancel(
  159. PDEVICE_OBJECT DeviceObject,
  160. PIRP Irp
  161. );
  162. NTSTATUS
  163. PscrCleanup(
  164. PDEVICE_OBJECT DeviceObject,
  165. PIRP Irp
  166. );
  167. BOOLEAN
  168. PscrIrqServiceRoutine(
  169. PKINTERRUPT Interrupt,
  170. PDEVICE_EXTENSION DeviceExtension
  171. );
  172. VOID
  173. PscrDpcRoutine(
  174. PKDPC Dpc,
  175. PDEVICE_OBJECT DeviceObject,
  176. PDEVICE_EXTENSION DeviceExtension,
  177. PSMARTCARD_EXTENSION SmartcardExtension
  178. );
  179. NTSTATUS
  180. PscrGenericIOCTL(
  181. PSMARTCARD_EXTENSION SmartcardExtension
  182. );
  183. NTSTATUS
  184. PscrCreateClose(
  185. PDEVICE_OBJECT DeviceObject,
  186. PIRP Irp
  187. );
  188. NTSTATUS
  189. PscrSystemControl(
  190. PDEVICE_OBJECT DeviceObject,
  191. PIRP Irp
  192. );
  193. NTSTATUS
  194. PscrDeviceIoControl(
  195. PDEVICE_OBJECT DeviceObject,
  196. PIRP Irp
  197. );
  198. VOID
  199. PscrInterruptEvent(
  200. IN PDEVICE_OBJECT DeviceObject
  201. );
  202. VOID
  203. PscrFreeze(
  204. PSMARTCARD_EXTENSION SmartcardExtension
  205. );
  206. NTSTATUS
  207. PscrCallPcmciaDriver(
  208. IN PDEVICE_OBJECT AttachedPDO,
  209. IN PIRP Irp
  210. );
  211. #endif // __PSCR_NT_DRV_H__