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.

271 lines
5.8 KiB

  1. /*++
  2. Copyright (c) 1998 Gemplus Development
  3. Name:
  4. gprcmd.h
  5. Description:
  6. This module holds the prototypes of the functions
  7. from gprcmd.c
  8. Environment:
  9. Kernel Mode
  10. Revision History:
  11. 06/04/99: (Y. Nadeau + M. Veillette)
  12. - Code Review
  13. 06/05/98: V1.00.003 (P. Plouidy)
  14. - Power management for NT5
  15. 10/02/98: V1.00.002 (P. Plouidy)
  16. - Plug and Play for NT5
  17. 03/07/97: V1.00.001 (P. Plouidy)
  18. - Start of development.
  19. --*/
  20. // Include
  21. // - smclib.h: smart card library definitions.
  22. #include <smclib.h>
  23. #ifndef _GPRCMD_
  24. #define _GPRCMD_
  25. //
  26. // To give possibility for recognition of driver
  27. //
  28. #define ATTR_MANUFACTURER_NAME "Gemplus"
  29. #define ATTR_ORIGINAL_FILENAME "Gpr400.sys"
  30. #define ATTR_LENGTH 32
  31. //
  32. // - SCARD_ATTR_SPEC_BAUD_RATE is the Tag for the speed in use between the
  33. // system and the reader.
  34. // - SCARD_ATTR_SPEC_CMD_TIMEOUT is the Tag for the value of the Cmd Timeout.
  35. // - SCARD_ATTR_SPEC_POWER_TIMEOUT is the Tag for the value of the Power
  36. // Timeout.
  37. // - SCARD_ATTR_SPEC_APDU_TIMEOUT is the Tag to access at the value of the APDU
  38. // Timeout.
  39. //
  40. #define SCARD_ATTR_SPEC_BAUD_RATE SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_DEFINED,0x0180)
  41. #define SCARD_ATTR_SPEC_CMD_TIMEOUT SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_DEFINED,0x0181)
  42. #define SCARD_ATTR_SPEC_POWER_TIMEOUT SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_DEFINED,0x0182)
  43. #define SCARD_ATTR_SPEC_APDU_TIMEOUT SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_DEFINED,0x0183)
  44. #define SCARD_ATTR_MANUFACTURER_NAME SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_DEFINED,0x0190)
  45. #define SCARD_ATTR_ORIGINAL_FILENAME SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_DEFINED,0x0191)
  46. //
  47. // - IOCTL_SMARTCARD_VENDOR_IFD_EXCHANGE defines a specific IOCTL for the Gemplus
  48. // Reader to exchange data with the reader without control of the driver.
  49. // - IOCTL_SMARTCARD_VENDOR_GET_ATTRIBUTE defines a specific IOCTL for the Gemplus
  50. // Reader to gets vendor attributes.
  51. // - IOCTL_SMARTCARD_VENDOR_SET_ATTRIBUTE defines a specific IOCTL for the Gemplus
  52. // Reader to sets vendor attributes.
  53. //
  54. #define IOCTL_SMARTCARD_VENDOR_IFD_EXCHANGE CTL_CODE(FILE_DEVICE_SMARTCARD,2048,0,0)
  55. #define IOCTL_SMARTCARD_VENDOR_GET_ATTRIBUTE CTL_CODE(FILE_DEVICE_SMARTCARD,2049,0,0)
  56. #define IOCTL_SMARTCARD_VENDOR_SET_ATTRIBUTE CTL_CODE(FILE_DEVICE_SMARTCARD,2050,0,0)
  57. // 2051 is reserved for Gcr420 keyboard reader.
  58. #define IOCTL_SMARTCARD_VENDOR_SWITCH_SPEED CTL_CODE(FILE_DEVICE_SMARTCARD,2052,0,0)
  59. #define LOWORD(l) ((USHORT)(l))
  60. #define HIWORD(l) ((USHORT)(((UINT)(l)) >> 16))
  61. #define LOBYTE(w) ((UCHAR)(w))
  62. #define HIBYTE(w) ((UCHAR)(((USHORT)(w)) >> 8))
  63. USHORT ATRLen
  64. (
  65. UCHAR *ATR,
  66. USHORT MaxChar
  67. );
  68. BOOLEAN NeedToSwitchWithoutPTS
  69. (
  70. BYTE *ATR,
  71. DWORD LengthATR
  72. );
  73. NTSTATUS ValidateDriver
  74. (
  75. PSMARTCARD_EXTENSION pSmartcardExtension
  76. );
  77. NTSTATUS Update
  78. (
  79. PSMARTCARD_EXTENSION pSmartcardExtension,
  80. UCHAR Addr,
  81. UCHAR Value
  82. );
  83. NTSTATUS UpdateORL
  84. (
  85. PSMARTCARD_EXTENSION pSmartcardExtension,
  86. UCHAR Addr,
  87. UCHAR Value
  88. );
  89. NTSTATUS T0toT1
  90. (
  91. PSMARTCARD_EXTENSION pSmartcardExtension
  92. );
  93. NTSTATUS T1toT0
  94. (
  95. PSMARTCARD_EXTENSION pSmartcardExtension
  96. );
  97. //
  98. // Icc Functions
  99. //
  100. // - IccColdReset
  101. // - IccWarmReset
  102. // - IccPowerDown
  103. // - IccIsoOutput
  104. // - IccIsoInput
  105. // - IccIsoT1
  106. //
  107. NTSTATUS IccColdReset
  108. (
  109. PSMARTCARD_EXTENSION SmartcardExtension
  110. );
  111. NTSTATUS IccPowerDown
  112. (
  113. PSMARTCARD_EXTENSION SmartcardExtension
  114. );
  115. NTSTATUS IccIsoOutput
  116. (
  117. PSMARTCARD_EXTENSION SmartcardExtension,
  118. const UCHAR Command[5],
  119. USHORT *RespLen,
  120. UCHAR RespBuff[]
  121. );
  122. NTSTATUS IccIsoInput
  123. (
  124. PSMARTCARD_EXTENSION SmartcardExtension,
  125. const UCHAR Command[5],
  126. const UCHAR Data[],
  127. USHORT *RespLen,
  128. UCHAR RespBuff[]
  129. );
  130. NTSTATUS IccIsoT1
  131. (
  132. PSMARTCARD_EXTENSION SmartcardExtension,
  133. const USHORT CmdLen,
  134. const UCHAR Cmd[],
  135. USHORT *RspLen,
  136. UCHAR Rsp[]
  137. );
  138. //
  139. // Ifd Functions
  140. //
  141. // - IfdReset
  142. // - IfdCheck
  143. // - IfdPowerDown
  144. //
  145. NTSTATUS IfdReset
  146. (
  147. PSMARTCARD_EXTENSION SmartcardExtension
  148. );
  149. NTSTATUS IfdCheck
  150. (
  151. PSMARTCARD_EXTENSION SmartcardExtension
  152. );
  153. NTSTATUS IfdPowerDown
  154. (
  155. PSMARTCARD_EXTENSION SmartcardExtension
  156. );
  157. NTSTATUS IfdConfig
  158. (
  159. PSMARTCARD_EXTENSION pSmartcardExtension,
  160. UCHAR TA1
  161. );
  162. //
  163. // Driver callback Functions
  164. //
  165. // - GprCbReaderPower
  166. // - GprCbTransmit
  167. // - GprCbSetProtocol
  168. // - GprCbSetupCardTracking
  169. // - GprCbVendorIoctl
  170. //
  171. NTSTATUS GprCbReaderPower
  172. (
  173. PSMARTCARD_EXTENSION SmartcardExtension
  174. );
  175. NTSTATUS GprCbTransmit
  176. (
  177. PSMARTCARD_EXTENSION SmartcardExtension
  178. );
  179. NTSTATUS GprCbSetProtocol
  180. (
  181. PSMARTCARD_EXTENSION SmartcardExtension
  182. );
  183. NTSTATUS GprCbSetupCardTracking
  184. (
  185. PSMARTCARD_EXTENSION SmartcardExtension
  186. );
  187. NTSTATUS GprCbVendorIoctl
  188. (
  189. PSMARTCARD_EXTENSION SmartcardExtension
  190. );
  191. // Icc detection utilities
  192. //
  193. // - AskForCardPresence
  194. //
  195. NTSTATUS AskForCardPresence
  196. (
  197. PSMARTCARD_EXTENSION SmartcardExtension
  198. );
  199. //
  200. // Specific
  201. //
  202. // - SpecificTag
  203. // - SwitchSpeed
  204. //
  205. NTSTATUS SpecificTag
  206. (
  207. PSMARTCARD_EXTENSION SmartcardExtension,
  208. DWORD IoControlCode,
  209. DWORD BufferInLen,
  210. BYTE *BufferIn,
  211. DWORD BufferOutLen,
  212. BYTE *BufferOut,
  213. DWORD *LengthOut
  214. );
  215. NTSTATUS SwitchSpeed
  216. (
  217. PSMARTCARD_EXTENSION SmartcardExtension,
  218. ULONG BufferInLen,
  219. PUCHAR BufferIn,
  220. ULONG BufferOutLen,
  221. PUCHAR BufferOut,
  222. PULONG LengthOut
  223. );
  224. #endif