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.

813 lines
26 KiB

  1. /*****************************************************************************
  2. @doc INT EXT
  3. ******************************************************************************
  4. * $ProjectName: $
  5. * $ProjectRevision: $
  6. *-----------------------------------------------------------------------------
  7. * $Source: z:/pr/cmeu0/sw/sccmusbm.ms/rcs/sccmusbm.h $
  8. * $Revision: 1.5 $
  9. *-----------------------------------------------------------------------------
  10. * $Author: WFrischauf $
  11. *-----------------------------------------------------------------------------
  12. * History: see EOF
  13. *-----------------------------------------------------------------------------
  14. *
  15. * Copyright 2000 OMNIKEY AG
  16. ******************************************************************************/
  17. #ifndef CMUSB_INC
  18. #define CMUSB_INC
  19. /*****************************************************************************
  20. * Defines
  21. ******************************************************************************/
  22. #define DRIVER_NAME "CMUSB"
  23. #define SMARTCARD_POOL_TAG 'CUCS'
  24. #include "smclib.h"
  25. #include "pcsc_cm.h"
  26. #define CARDMAN_USB_DEVICE_NAME L"\\Device\\CM_2020_"
  27. #define MAXIMUM_USB_READERS 10
  28. #define MAXIMUM_OEM_NAMES 4
  29. #define VERSIONMAJOR_CARDMAN_USB 3
  30. #define VERSIONMINOR_CARDMAN_USB 2
  31. #define BUILDNUMBER_CARDMAN_USB 1
  32. #define CM2020_VENDOR_NAME "OMNIKEY"
  33. #define CM2020_PRODUCT_NAME "CardMan 2020"
  34. #define ATTR_MAX_IFSD_CARDMAN_USB 35
  35. #define ATTR_MAX_IFSD_SYNCHRON_USB 48
  36. #define UNKNOWN 0xFFFFFFFF
  37. #define REMOVED 0x00000001
  38. #define INSERTED 0x00000002
  39. #define POWERED 0x00000004
  40. #define CMUSB_BUFFER_SIZE 300
  41. #define CMUSB_SYNCH_BUFFER_SIZE 64
  42. // defines for CMUSB_SetCardParameters
  43. #define CMUSB_SMARTCARD_SYNCHRONOUS 0x80
  44. #define CMUSB_SMARTCARD_ASYNCHRONOUS 0x00
  45. #define CMUSB_BAUDRATE_9600 0x01
  46. #define CMUSB_BAUDRATE_19200 0x02
  47. //#define CMUSB_BAUDRATE_28800 0x03
  48. #define CMUSB_BAUDRATE_38400 0x04
  49. //#define CMUSB_BAUDRATE_57600 0x06
  50. #define CMUSB_BAUDRATE_76800 0x08
  51. #define CMUSB_BAUDRATE_115200 0x0C
  52. #define CMUSB_FREQUENCY_3_72MHZ 0x00
  53. #define CMUSB_FREQUENCY_5_12MHZ 0x10
  54. #define CMUSB_ODD_PARITY 0x80
  55. #define CMUSB_EVEN_PARITY 0x00
  56. #define SMARTCARD_COLD_RESET 0x00
  57. #define SMARTCARD_WARM_RESET 0x01
  58. #define DEFAULT_TIMEOUT_P1 1000
  59. // own IOCTLs
  60. //#define CMUSB_IOCTL_CR80S_SAMOS_SET_HIGH_SPEED SCARD_CTL_CODE (3000)
  61. //#define CMUSB_IOCTL_GET_FW_VERSION SCARD_CTL_CODE (3001)
  62. // #define CMUSB_IOCTL_SPE_SECURE_PIN_ENTRY SCARD_CTL_CODE (0x3102)
  63. //#define CMUSB_IOCTL_IS_SPE_SUPPORTED SCARD_CTL_CODE (3003)
  64. //#define CMUSB_IOCTL_READ_DEVICE_DESCRIPTION SCARD_CTL_CODE (3004)
  65. //#define CMUSB_IOCTL_SET_SYNC_PARAMETERS SCARD_CTL_CODE (3010)
  66. //#define CMUSB_IOCTL_2WBP_RESET_CARD SCARD_CTL_CODE (3011)
  67. //#define CMUSB_IOCTL_2WBP_TRANSFER SCARD_CTL_CODE (3012)
  68. //#define CMUSB_IOCTL_3WBP_TRANSFER SCARD_CTL_CODE (3013)
  69. //#define CMUSB_IOCTL_SYNC_CARD_POWERON SCARD_CTL_CODE (3014)
  70. #define SLE4442_WRITE 0x38 /* write without protect bit */
  71. #define SLE4442_WRITE_PROT_MEM 0x3C /* write protection memory */
  72. #define SLE4442_READ 0x30 /* read without protect bit */
  73. #define SLE4442_READ_PROT_MEM 0x34 /* read protection memory */
  74. #define SLE4442_READ_SEC_MEM 0x31 /* read security memory */
  75. #define SLE4442_COMPARE_PIN 0x33 /* compare one PIN byte */
  76. #define SLE4442_UPDATE_SEC_MEM 0x39 /* update security memory */
  77. #define SLE4428_WRITE 0x33 /* write without protect bit */
  78. #define SLE4428_WRITE_PROT 0x31 /* write with protect bit */
  79. #define SLE4428_READ 0x0E /* read without protect bit */
  80. #define SLE4428_READ_PROT 0x0C /* read with protect bit */
  81. #define SLE4428_COMPARE 0x30 /* compare and write prot. bit */
  82. #define SLE4428_SET_COUNTER 0xF2 /* write error counter */
  83. #define SLE4428_COMPARE_PIN 0xCD /* compare one PIN byte */
  84. #if DBG
  85. static const PCHAR szIrpMajFuncDesc[] =
  86. { // note this depends on corresponding values to the indexes in wdm.h
  87. "IRP_MJ_CREATE",
  88. "IRP_MJ_CREATE_NAMED_PIPE",
  89. "IRP_MJ_CLOSE",
  90. "IRP_MJ_READ",
  91. "IRP_MJ_WRITE",
  92. "IRP_MJ_QUERY_INFORMATION",
  93. "IRP_MJ_SET_INFORMATION",
  94. "IRP_MJ_QUERY_EA",
  95. "IRP_MJ_SET_EA",
  96. "IRP_MJ_FLUSH_BUFFERS",
  97. "IRP_MJ_QUERY_VOLUME_INFORMATION",
  98. "IRP_MJ_SET_VOLUME_INFORMATION",
  99. "IRP_MJ_DIRECTORY_CONTROL",
  100. "IRP_MJ_FILE_SYSTEM_CONTROL",
  101. "IRP_MJ_DEVICE_CONTROL",
  102. "IRP_MJ_INTERNAL_DEVICE_CONTROL",
  103. "IRP_MJ_SHUTDOWN",
  104. "IRP_MJ_LOCK_CONTROL",
  105. "IRP_MJ_CLEANUP",
  106. "IRP_MJ_CREATE_MAILSLOT",
  107. "IRP_MJ_QUERY_SECURITY",
  108. "IRP_MJ_SET_SECURITY",
  109. "IRP_MJ_POWER",
  110. "IRP_MJ_SYSTEM_CONTROL",
  111. "IRP_MJ_DEVICE_CHANGE",
  112. "IRP_MJ_QUERY_QUOTA",
  113. "IRP_MJ_SET_QUOTA",
  114. "IRP_MJ_PNP"
  115. };
  116. //IRP_MJ_MAXIMUM_FUNCTION defined in wdm.h
  117. static const PCHAR szPnpMnFuncDesc[] =
  118. { // note this depends on corresponding values to the indexes in wdm.h
  119. "IRP_MN_START_DEVICE",
  120. "IRP_MN_QUERY_REMOVE_DEVICE",
  121. "IRP_MN_REMOVE_DEVICE",
  122. "IRP_MN_CANCEL_REMOVE_DEVICE",
  123. "IRP_MN_STOP_DEVICE",
  124. "IRP_MN_QUERY_STOP_DEVICE",
  125. "IRP_MN_CANCEL_STOP_DEVICE",
  126. "IRP_MN_QUERY_DEVICE_RELATIONS",
  127. "IRP_MN_QUERY_INTERFACE",
  128. "IRP_MN_QUERY_CAPABILITIES",
  129. "IRP_MN_QUERY_RESOURCES",
  130. "IRP_MN_QUERY_RESOURCE_REQUIREMENTS",
  131. "IRP_MN_QUERY_DEVICE_TEXT",
  132. "IRP_MN_FILTER_RESOURCE_REQUIREMENTS",
  133. "IRP_MN_READ_CONFIG",
  134. "IRP_MN_WRITE_CONFIG",
  135. "IRP_MN_EJECT",
  136. "IRP_MN_SET_LOCK",
  137. "IRP_MN_QUERY_ID",
  138. "IRP_MN_QUERY_PNP_DEVICE_STATE",
  139. "IRP_MN_QUERY_BUS_INFORMATION",
  140. "IRP_MN_PAGING_NOTIFICATION"
  141. };
  142. #define IRP_PNP_MN_FUNCMAX IRP_MN_PAGING_NOTIFICATION
  143. static const PCHAR szSystemPowerState[] =
  144. {
  145. "PowerSystemUnspecified",
  146. "PowerSystemWorking",
  147. "PowerSystemSleeping1",
  148. "PowerSystemSleeping2",
  149. "PowerSystemSleeping3",
  150. "PowerSystemHibernate",
  151. "PowerSystemShutdown",
  152. "PowerSystemMaximum"
  153. };
  154. static const PCHAR szDevicePowerState[] =
  155. {
  156. "PowerDeviceUnspecified",
  157. "PowerDeviceD0",
  158. "PowerDeviceD1",
  159. "PowerDeviceD2",
  160. "PowerDeviceD3",
  161. "PowerDeviceMaximum"
  162. };
  163. #define CMUSB_ASSERT( cond ) ASSERT( cond )
  164. #define CMUSB_StringForDevState( devState ) szDevicePowerState[ devState ]
  165. #define CMUSB_StringForSysState( sysState ) szSystemPowerState[ sysState ]
  166. #define CMUSB_StringForPnpMnFunc( mnfunc ) szPnpMnFuncDesc[ mnfunc ]
  167. #define CMUSB_StringForIrpMjFunc( mjfunc ) szIrpMajFuncDesc[ mjfunc ]
  168. #else // if not DBG
  169. // dummy definitions that go away in the retail build
  170. #define CMUSB_ASSERT( cond )
  171. #define CMUSB_StringForDevState( devState )
  172. #define CMUSB_StringForSysState( sysState )
  173. #define CMUSB_StringForPnpMnFunc( mnfunc )
  174. #define CMUSB_StringForIrpMjFunc( mjfunc )
  175. #endif //DBG
  176. /*****************************************************************************
  177. * Types, Structures
  178. ******************************************************************************/
  179. // used to track driver-generated io irps for staged read/write processing
  180. typedef struct _CMUSB_RW_CONTEXT
  181. {
  182. PURB Urb;
  183. PDEVICE_OBJECT DeviceObject;
  184. PIRP Irp;
  185. } CMUSB_RW_CONTEXT, *PCMUSB_RW_CONTEXT;
  186. typedef struct _CARD_PARAMETERS
  187. {
  188. UCHAR bCardType;
  189. UCHAR bBaudRate;
  190. UCHAR bStopBits;
  191. } CARD_PARAMETERS, *PCARD_PARAMETERS;
  192. //
  193. // A structure representing the instance information associated with
  194. // this particular device.
  195. //
  196. typedef struct _DEVICE_EXTENSION
  197. {
  198. //
  199. // The dos device name of our smart card reader
  200. //
  201. UNICODE_STRING DosDeviceName;
  202. // The pnp device name of our smart card reader
  203. UNICODE_STRING PnPDeviceName;
  204. // Our smart card extension
  205. SMARTCARD_EXTENSION SmartcardExtension;
  206. // The current number of io-requests
  207. LONG IoCount;
  208. ULONG DeviceInstance;
  209. KSPIN_LOCK SpinLock;
  210. // Device object we call when submitting Urbs
  211. PDEVICE_OBJECT TopOfStackDeviceObject;
  212. // The bus driver object
  213. PDEVICE_OBJECT PhysicalDeviceObject;
  214. DEVICE_POWER_STATE CurrentDevicePowerState;
  215. // USB configuration handle and ptr for the configuration the
  216. // device is currently in
  217. USBD_CONFIGURATION_HANDLE UsbConfigurationHandle;
  218. PUSB_CONFIGURATION_DESCRIPTOR UsbConfigurationDescriptor;
  219. // ptr to the USB device descriptor
  220. // for this device
  221. PUSB_DEVICE_DESCRIPTOR UsbDeviceDescriptor;
  222. // we support one interface
  223. // this is a copy of the info structure
  224. // returned from select_configuration or
  225. // select_interface
  226. PUSBD_INTERFACE_INFORMATION UsbInterface;
  227. //Bus drivers set the appropriate values in this structure in response
  228. //to an IRP_MN_QUERY_CAPABILITIES IRP. Function and filter drivers might
  229. //alter the capabilities set by the bus driver.
  230. DEVICE_CAPABILITIES DeviceCapabilities;
  231. // used to save the currently-being-handled system-requested power irp request
  232. PIRP PowerIrp;
  233. // Used to signal that update thread can run
  234. KEVENT CanRunUpdateThread;
  235. // Blocks IOCtls during hibernate mode
  236. KEVENT ReaderEnabled;
  237. // set when PendingIoCount goes to 0; flags device can be removed
  238. KEVENT RemoveEvent;
  239. // set when PendingIoCount goes to 1 ( 1st increment was on add device )
  240. // this indicates no IO requests outstanding, either user, system, or self-staged
  241. KEVENT NoPendingIoEvent;
  242. // set to signal driver-generated power request is finished
  243. KEVENT SelfRequestedPowerIrpEvent;
  244. KEVENT ReadP1Completed;
  245. // incremented when device is added and any IO request is received;
  246. // decremented when any io request is completed or passed on, and when device is removed
  247. ULONG PendingIoCount;
  248. // Name buffer for our named Functional device object link
  249. // The name is generated based on the driver's class GUID
  250. WCHAR DeviceLinkNameBuffer[ MAXIMUM_FILENAME_LENGTH ]; // MAXIMUM_FILENAME_LENGTH defined in wdm.h
  251. //device is opened by application (ScardSrv, CT-API)
  252. LONG lOpenCount;
  253. // flag set when processing IRP_MN_REMOVE_DEVICE
  254. BOOLEAN DeviceRemoved;
  255. // flag set when processing IRP_MN_SURPRISE_REMOVAL
  256. BOOLEAN DeviceSurpriseRemoval;
  257. // flag set when driver has answered success to IRP_MN_QUERY_REMOVE_DEVICE
  258. BOOLEAN RemoveDeviceRequested;
  259. // flag set when driver has answered success to IRP_MN_QUERY_STOP_DEVICE
  260. BOOLEAN StopDeviceRequested;
  261. // flag set when device has been successfully started
  262. BOOLEAN DeviceStarted;
  263. // flag set when IRP_MN_WAIT_WAKE is received and we're in a power state
  264. // where we can signal a wait
  265. BOOLEAN EnabledForWakeup;
  266. // used to flag that we're currently handling a self-generated power request
  267. BOOLEAN SelfPowerIrp;
  268. BOOLEAN fPnPResourceManager;
  269. // default power state to power down to on self-suspend
  270. ULONG PowerDownLevel;
  271. } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
  272. //
  273. // Define the reader specific portion of the smart card extension
  274. //
  275. typedef struct _READER_EXTENSION
  276. {
  277. KTIMER WaitTimer;
  278. KTIMER P1Timer;
  279. // at least one info byte must be received within this timeout
  280. ULONG ulTimeoutP1;
  281. ULONG ulDeviceInstance;
  282. ULONG ulOemNameIndex;
  283. ULONG ulOemDeviceInstance;
  284. UCHAR T0ReadBuffer [520];
  285. LONG T0ReadBuffer_OffsetLastByte;
  286. LONG T0ReadBuffer_OffsetLastByteRead;
  287. // Flag that indicates that the caller requests a power-down or a reset
  288. BOOLEAN PowerRequest;
  289. // Saved card state for hibernation/sleeping modes.
  290. BOOLEAN CardPresent;
  291. // Current reader power state.
  292. //READER_POWER_STATE ReaderPowerState;
  293. CARD_PARAMETERS CardParameters;
  294. BOOLEAN TimeToTerminateThread;
  295. BOOLEAN fThreadTerminated;
  296. KMUTEX CardManIOMutex;
  297. // Handle of the UpdateCurrentState thread
  298. PVOID ThreadObjectPointer;
  299. ULONG ulOldCardState;
  300. ULONG ulNewCardState;
  301. BOOLEAN fRawModeNecessary;
  302. ULONG ulFWVersion;
  303. BOOLEAN fSPESupported;
  304. BOOLEAN fInverseAtr;
  305. UCHAR abDeviceDescription[42];
  306. BOOLEAN fP1Stalled;
  307. } READER_EXTENSION, *PREADER_EXTENSION;
  308. /*****************************************************************************
  309. * Function Prototypes
  310. ******************************************************************************/
  311. NTSTATUS CMUSB_ResetT0ReadBuffer (
  312. IN PSMARTCARD_EXTENSION smartcardExtension
  313. );
  314. NTSTATUS CMUSB_AbortPipes (
  315. IN PDEVICE_OBJECT DeviceObject
  316. );
  317. NTSTATUS CMUSB_AsyncReadWrite_Complete (
  318. IN PDEVICE_OBJECT DeviceObject,
  319. IN PIRP Irp,
  320. IN PVOID Context
  321. );
  322. PURB CMUSB_BuildAsyncRequest (
  323. IN PDEVICE_OBJECT DeviceObject,
  324. IN PIRP Irp,
  325. IN PUSBD_PIPE_INFORMATION pipeInformation
  326. );
  327. NTSTATUS CMUSB_CallUSBD (
  328. IN PDEVICE_OBJECT DeviceObject,
  329. IN PURB Urb
  330. );
  331. BOOLEAN CMUSB_CanAcceptIoRequests (
  332. IN PDEVICE_OBJECT DeviceObject
  333. );
  334. NTSTATUS CMUSB_CancelCardTracking (
  335. IN PDEVICE_OBJECT DeviceObject,
  336. IN PIRP Irp
  337. );
  338. NTSTATUS CMUSB_CardPower (
  339. IN PSMARTCARD_EXTENSION pSmartcardExtension
  340. );
  341. NTSTATUS CMUSB_CardTracking (
  342. PSMARTCARD_EXTENSION SmartcardExtension
  343. );
  344. NTSTATUS CMUSB_Cleanup (
  345. IN PDEVICE_OBJECT DeviceObject,
  346. IN PIRP Irp
  347. );
  348. VOID CMUSB_CompleteCardTracking (
  349. IN PSMARTCARD_EXTENSION SmartcardExtension
  350. );
  351. NTSTATUS CMUSB_ConfigureDevice (
  352. IN PDEVICE_OBJECT DeviceObject
  353. );
  354. NTSTATUS CMUSB_CreateClose (
  355. IN PDEVICE_OBJECT DeviceObject,
  356. IN PIRP Irp
  357. );
  358. NTSTATUS CMUSB_CreateDeviceObject(
  359. IN PDRIVER_OBJECT DriverObject,
  360. IN PDEVICE_OBJECT PhysicalDeviceObject,
  361. IN PDEVICE_OBJECT *DeviceObject
  362. );
  363. VOID CMUSB_DecrementIoCount (
  364. IN PDEVICE_OBJECT DeviceObject
  365. );
  366. NTSTATUS CMUSB_GetFWVersion (
  367. IN PSMARTCARD_EXTENSION smartcardExtension
  368. );
  369. VOID CMUSB_IncrementIoCount (
  370. IN PDEVICE_OBJECT DeviceObject
  371. );
  372. VOID CMUSB_InitializeSmartcardExtension (
  373. IN PSMARTCARD_EXTENSION pSmartcardExtension
  374. ) ;
  375. VOID CMUSB_InverseBuffer (
  376. IN PUCHAR pbBuffer,
  377. IN ULONG ulBufferSize
  378. ) ;
  379. NTSTATUS CMUSB_IoCtlVendor (
  380. PSMARTCARD_EXTENSION SmartcardExtension
  381. );
  382. NTSTATUS CMUSB_IrpCompletionRoutine (
  383. IN PDEVICE_OBJECT DeviceObject,
  384. IN PIRP Irp,
  385. IN PVOID Context
  386. );
  387. NTSTATUS CMUSB_IsSPESupported (
  388. IN PSMARTCARD_EXTENSION smartcardExtension
  389. );
  390. NTSTATUS CMUSB_PnPAddDevice (
  391. IN PDRIVER_OBJECT DriverObject,
  392. IN PDEVICE_OBJECT PhysicalDeviceObject
  393. );
  394. NTSTATUS CMUSB_PoSelfRequestCompletion (
  395. IN PDEVICE_OBJECT DeviceObject,
  396. IN UCHAR MinorFunction,
  397. IN POWER_STATE PowerState,
  398. IN PVOID Context,
  399. IN PIO_STATUS_BLOCK IoStatus
  400. );
  401. NTSTATUS CMUSB_PoRequestCompletion(
  402. IN PDEVICE_OBJECT DeviceObject,
  403. IN UCHAR MinorFunction,
  404. IN POWER_STATE PowerState,
  405. IN PVOID Context,
  406. IN PIO_STATUS_BLOCK IoStatus
  407. );
  408. NTSTATUS CMUSB_PowerIrp_Complete (
  409. IN PDEVICE_OBJECT NullDeviceObject,
  410. IN PIRP Irp,
  411. IN PVOID Context
  412. );
  413. NTSTATUS CMUSB_PowerOffCard (
  414. IN PSMARTCARD_EXTENSION smartcardExtension
  415. );
  416. NTSTATUS CMUSB_PowerOnCard (
  417. IN PSMARTCARD_EXTENSION smartcardExtension,
  418. IN PUCHAR pbATR,
  419. OUT PULONG pulATRLength
  420. );
  421. NTSTATUS CMUSB_ProcessIOCTL (
  422. IN PDEVICE_OBJECT DeviceObject,
  423. IN PIRP Irp
  424. );
  425. NTSTATUS CMUSB_ProcessPowerIrp (
  426. IN PDEVICE_OBJECT DeviceObject,
  427. IN PIRP Irp
  428. );
  429. NTSTATUS CMUSB_ProcessPnPIrp (
  430. IN PDEVICE_OBJECT DeviceObject,
  431. IN PIRP Irp
  432. );
  433. NTSTATUS CMUSB_ProcessSysControlIrp (
  434. IN PDEVICE_OBJECT DeviceObject,
  435. IN PIRP Irp
  436. );
  437. NTSTATUS CMUSB_ReadT0 (
  438. IN PSMARTCARD_EXTENSION smartcardExtension
  439. );
  440. NTSTATUS CMUSB_ReadP1 (
  441. IN PDEVICE_OBJECT DeviceObject
  442. );
  443. NTSTATUS CMUSB_ReadP1_T0 (
  444. IN PDEVICE_OBJECT DeviceObject
  445. );
  446. NTSTATUS CMUSB_ReadP0 (
  447. IN PDEVICE_OBJECT DeviceObject
  448. );
  449. NTSTATUS CMUSB_ReadStateAfterP1Stalled(
  450. IN PDEVICE_OBJECT DeviceObject
  451. );
  452. NTSTATUS CMUSB_ResetPipe(
  453. IN PDEVICE_OBJECT DeviceObject,
  454. IN PUSBD_PIPE_INFORMATION PipeInfo
  455. );
  456. NTSTATUS CMUSB_QueryCapabilities (
  457. IN PDEVICE_OBJECT DeviceObject,
  458. IN PDEVICE_CAPABILITIES DeviceCapabilities
  459. );
  460. NTSTATUS CMUSB_ReadDeviceDescription (
  461. IN PSMARTCARD_EXTENSION smartcardExtension
  462. );
  463. NTSTATUS CMUSB_RemoveDevice (
  464. IN PDEVICE_OBJECT DeviceObject
  465. );
  466. NTSTATUS CMUSB_SelfSuspendOrActivate (
  467. IN PDEVICE_OBJECT DeviceObject,
  468. IN BOOLEAN fSuspend
  469. );
  470. NTSTATUS CMUSB_SelectInterface (
  471. IN PDEVICE_OBJECT DeviceObject,
  472. IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor
  473. );
  474. NTSTATUS CMUSB_SelfRequestPowerIrp (
  475. IN PDEVICE_OBJECT DeviceObject,
  476. IN POWER_STATE PowerState
  477. );
  478. BOOLEAN CMUSB_SetDevicePowerState (
  479. IN PDEVICE_OBJECT DeviceObject,
  480. IN DEVICE_POWER_STATE DeviceState
  481. );
  482. NTSTATUS CMUSB_SetCardParameters (
  483. IN PDEVICE_OBJECT DeviceObject,
  484. IN UCHAR bCardType,
  485. IN UCHAR bBaudRate,
  486. IN UCHAR bStopBits
  487. );
  488. NTSTATUS CMUSB_SetHighSpeed_CR80S_SAMOS (
  489. IN PSMARTCARD_EXTENSION smartcardExtension
  490. );
  491. NTSTATUS CMUSB_SetProtocol (
  492. PSMARTCARD_EXTENSION pSmartcardExtension
  493. );
  494. NTSTATUS CMUSB_SetReader_9600Baud (
  495. IN PSMARTCARD_EXTENSION SmartcardExtension
  496. );
  497. NTSTATUS CMUSB_SetReader_38400Baud (
  498. IN PSMARTCARD_EXTENSION SmartcardExtension
  499. );
  500. NTSTATUS CMUSB_SetVendorAndIfdName(
  501. IN PDEVICE_OBJECT PhysicalDeviceObject,
  502. IN PSMARTCARD_EXTENSION SmartcardExtension
  503. );
  504. NTSTATUS CMUSB_StartCardTracking (
  505. IN PDEVICE_OBJECT deviceObject
  506. );
  507. NTSTATUS CMUSB_StartDevice (
  508. IN PDEVICE_OBJECT DeviceObject
  509. );
  510. VOID CMUSB_StopCardTracking (
  511. IN PDEVICE_OBJECT deviceObject
  512. );
  513. NTSTATUS CMUSB_StopDevice (
  514. IN PDEVICE_OBJECT DeviceObject
  515. );
  516. NTSTATUS CMUSB_Transmit (
  517. IN PSMARTCARD_EXTENSION smartcardExtension
  518. );
  519. NTSTATUS CMUSB_TransmitT0 (
  520. IN PSMARTCARD_EXTENSION smartcardExtension
  521. );
  522. NTSTATUS CMUSB_TransmitT1 (
  523. IN PSMARTCARD_EXTENSION smartcardExtension
  524. );
  525. VOID CMUSB_Unload (
  526. IN PDRIVER_OBJECT DriverObject
  527. );
  528. VOID CMUSB_UpdateCurrentStateThread (
  529. IN PVOID Context
  530. );
  531. NTSTATUS CMUSB_UpdateCurrentState(
  532. IN PDEVICE_OBJECT DeviceObject
  533. );
  534. NTSTATUS CMUSB_Wait (
  535. IN ULONG ulMilliseconds
  536. );
  537. NTSTATUS CMUSB_WriteP0 (
  538. IN PDEVICE_OBJECT DeviceObject,
  539. IN UCHAR bRequest,
  540. IN UCHAR bValueLo,
  541. IN UCHAR bValueHi,
  542. IN UCHAR bIndexLo,
  543. IN UCHAR bIndexHi
  544. );
  545. VOID CMUSB_CheckAtrModified (
  546. IN OUT PUCHAR pbBuffer,
  547. IN ULONG ulBufferSize
  548. );
  549. // ----------------------------------------------------------------
  550. // SYNCHRONOUS SMART CARDS
  551. // ----------------------------------------------------------------
  552. NTSTATUS
  553. CMUSB_PowerOnSynchronousCard (
  554. IN PSMARTCARD_EXTENSION smartcardExtension,
  555. IN PUCHAR pbATR,
  556. OUT PULONG pulATRLength
  557. );
  558. NTSTATUS
  559. CMUSB_Transmit2WBP (
  560. IN PSMARTCARD_EXTENSION smartcardExtension
  561. );
  562. NTSTATUS
  563. CMUSB_Transmit3WBP (
  564. IN PSMARTCARD_EXTENSION smartcardExtension
  565. );
  566. NTSTATUS
  567. CMUSB_SendCommand2WBP (
  568. IN PSMARTCARD_EXTENSION smartcardExtension,
  569. IN PUCHAR pbCommandData
  570. );
  571. NTSTATUS
  572. CMUSB_SendCommand3WBP (
  573. IN PSMARTCARD_EXTENSION smartcardExtension,
  574. IN PUCHAR pbCommandData
  575. );
  576. __inline UCHAR
  577. CMUSB_CalcSynchControl (
  578. IN UCHAR bStateReset1, //0 -> low
  579. IN UCHAR bStateClock1, //0 -> low
  580. IN UCHAR bStateDirection1, //0 -> from card to pc
  581. IN UCHAR bStateIO1, //0 -> low
  582. IN UCHAR bStateReset2, //0 -> low
  583. IN UCHAR bStateClock2, //0 -> low
  584. IN UCHAR bStateDirection2, //0 -> from card to pc
  585. IN UCHAR bStateIO2 //0 -> low
  586. )
  587. {
  588. return((UCHAR)( ((bStateReset1==0)?0:128) + ((bStateClock1==0)?0:64) +
  589. ((bStateDirection1==0)?0:32) + ((bStateIO1==0)?0:16) +
  590. ((bStateReset2==0)?0:8) + ((bStateClock2==0)?0:4) +
  591. ((bStateDirection2==0)?0:2) + ((bStateIO2==0)?0:1) ));
  592. };
  593. #endif // CMUSBM_INC
  594. /*****************************************************************************
  595. * History:
  596. * $Log: sccmusbm.h $
  597. * Revision 1.5 2000/09/25 13:38:21 WFrischauf
  598. * No comment given
  599. *
  600. * Revision 1.4 2000/08/16 14:35:02 WFrischauf
  601. * No comment given
  602. *
  603. * Revision 1.3 2000/07/24 11:34:57 WFrischauf
  604. * No comment given
  605. *
  606. * Revision 1.1 2000/07/20 11:50:13 WFrischauf
  607. * No comment given
  608. *
  609. *
  610. ******************************************************************************/