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.

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