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.

152 lines
5.1 KiB

  1. //-------------------------------------------------------------------
  2. // This is abstract class for generic device
  3. // Specific devices should use it as a parent device
  4. // Author: Sergey Ivanov
  5. // Log:
  6. // 08/11/99 - implemented
  7. //-------------------------------------------------------------------
  8. #ifndef __GEMCORE__
  9. #define __GEMCORE__
  10. #include "interface.h"
  11. #include "rdrconfig.h"
  12. // Reader max buffer size
  13. #define READER_DATA_BUFFER_SIZE 255
  14. // Tells that power command was used
  15. #define GEMCORE_CARD_POWER 1
  16. //
  17. // DEFAULT_POWER_TIMEOUT defines the default power timout in ms.
  18. //
  19. #define GEMCORE_DEFAULT_POWER_TIMEOUT 750
  20. #define GEMCORE_CARD_POWER_DOWN 0x11
  21. #define GEMCORE_CARD_POWER_UP 0x12
  22. #define GEMCORE_CARD_READ 0x13
  23. #define GEMCORE_CARD_WRITE 0x14
  24. #define GEMCORE_CARD_EXCHANGE 0x15
  25. #define GEMCORE_DEFINE_CARD_TYPE 0x17
  26. #define GEMCORE_GET_CARD_STATUS 0x17// Commands differs only by parameter...
  27. #define GEMCORE_GET_FIRMWARE_VERSION "\x22\x05\x3F\xE0\x10"
  28. #define GEMCORE_READER_SET_MODE 0x01
  29. // Card configuration
  30. #define ISO_CARD 0x02
  31. #define TRANSPARENT_MODE_CARD 0xEF
  32. #define DEFAULT_PRESENCE_DETECTION 0x0D
  33. #define CARD_DEFAULT_VPP 0
  34. #define CARD_VOLTAGE_5V 0
  35. #define CARD_VOLTAGE_3V 1
  36. #define CARD_DEFAULT_VOLTAGE CARD_VOLTAGE_5V
  37. // PTS mode parameters
  38. #define PTS_MODE_DEFAULT 0
  39. #define PTS_MODE_DISABLED 1
  40. #define PTS_MODE_OPTIMAL 2
  41. #define PTS_MODE_MANUALLY 3
  42. #define PTS_NEGOTIATE_PTS1 0x10
  43. #define PTS_NEGOTIATE_PTS2 0x20
  44. #define PTS_NEGOTIATE_PTS3 0x40
  45. #define PTS_NEGOTIATE_T0 0x00
  46. #define PTS_NEGOTIATE_T1 0x01
  47. // - ICC_DEFAULT_POWER_TIMOUT defines the default power timout in ms.
  48. #define ICC_DEFAULT_POWER_TIMOUT 750
  49. #pragma PAGEDCODE
  50. class CIoPacket;
  51. class CGemCore : public CReaderInterface
  52. {
  53. public:
  54. NTSTATUS m_Status;
  55. SAFE_DESTRUCTORS();
  56. private:
  57. ReaderConfig configuration;
  58. protected:
  59. CGemCore(){};
  60. public:
  61. CGemCore(CProtocol* protocol) : CReaderInterface(protocol)
  62. {
  63. TRACE("Gemcore Reader Interface was created with protocol %x \n",protocol);
  64. // These values went from Gemcore portocol
  65. // Lets leave it for now, but eventually we could
  66. // redefine them creating Gemcore independent
  67. // reader configuration
  68. configuration.Type = ISO_CARD;//ISO_CARD (02)
  69. configuration.PresenceDetection = DEFAULT_PRESENCE_DETECTION;//DEFAULT_PRESENCE_DETECTION (0D)
  70. configuration.Voltage = CARD_DEFAULT_VOLTAGE; //CARD_DEFAULT_VOLTAGE;
  71. configuration.PTSMode = PTS_MODE_DISABLED; //PTS_MODE_DISABLED;
  72. configuration.PTS0 = 0;
  73. configuration.PTS1 = 0;
  74. configuration.PTS2 = 0;
  75. configuration.PTS3 = 0;
  76. configuration.Vpp = 0; //CARD_DEFAULT_VPP;
  77. configuration.ActiveProtocol = 0;// Undefined
  78. configuration.PowerTimeOut = GEMCORE_DEFAULT_POWER_TIMEOUT;
  79. m_Status = STATUS_SUCCESS;
  80. };
  81. virtual ~CGemCore()
  82. {
  83. TRACE("GemCore Reader Interface %8.8lX was destroied...\n",this);
  84. };
  85. virtual VOID dispose()
  86. {
  87. self_delete();
  88. };
  89. static CReaderInterface* create(CProtocol* protocol)
  90. {
  91. CReaderInterface* interface = new (NonPagedPool) CGemCore(protocol);
  92. if(!ALLOCATED_OK(interface))
  93. {
  94. DISPOSE_OBJECT(interface);
  95. interface = NULL;
  96. }
  97. return interface;
  98. };
  99. virtual NTSTATUS translateStatus( const BYTE ReaderStatus, const ULONG IoctlType);
  100. virtual ULONG getReaderState();
  101. virtual NTSTATUS getReaderVersion(PUCHAR pVersion, PULONG pLength);
  102. virtual NTSTATUS setReaderMode(ULONG mode);
  103. virtual NTSTATUS initialize();
  104. // Reader interface functions...
  105. virtual ReaderConfig getConfiguration();
  106. virtual NTSTATUS setConfiguration(ReaderConfig configuration);
  107. virtual NTSTATUS setTransparentConfig(PSCARD_CARD_CAPABILITIES cardCapabilities, BYTE NewWtx);
  108. virtual VOID RestoreISOsetting(VOID);
  109. virtual NTSTATUS read(CIoPacket* Irp);
  110. virtual NTSTATUS write(CIoPacket* Irp);
  111. virtual NTSTATUS readAndWait(BYTE * pRequest,ULONG RequestLength,BYTE * pReply,ULONG* pReplyLength);
  112. virtual NTSTATUS writeAndWait(BYTE * pRequest,ULONG RequestLength,BYTE * pReply,ULONG* pReplyLength);
  113. virtual NTSTATUS ioctl(ULONG ControlCode,BYTE* pRequest,ULONG RequestLength,BYTE* pReply,ULONG* pReplyLength);
  114. virtual NTSTATUS SwitchSpeed(ULONG ControlCode,BYTE* pRequest,ULONG RequestLength,BYTE* pReply,ULONG* pReplyLength);
  115. virtual NTSTATUS VendorAttribute(ULONG ControlCode,BYTE* pRequest,ULONG RequestLength,BYTE* pReply,ULONG* pReplyLength);
  116. virtual NTSTATUS power(ULONG ControlCode,BYTE* pReply,ULONG* pReplyLength, BOOLEAN Specific);
  117. virtual NTSTATUS powerUp(BYTE* pReply,ULONG* pReplyLength);
  118. virtual NTSTATUS setProtocol(ULONG ProtocolRequested);
  119. virtual VOID cancel();
  120. // Process smartcard requests according to reader capabilities
  121. virtual NTSTATUS translate_request(BYTE * pRequest,ULONG RequestLength,BYTE * pReply,ULONG* pReplyLength, PSCARD_CARD_CAPABILITIES cardCapabilities, BYTE NewWtx);
  122. virtual NTSTATUS translate_response(BYTE * pRequest,ULONG RequestLength,BYTE * pReply,ULONG* pReplyLength);
  123. };
  124. #endif