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.

199 lines
4.0 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) SCM Microsystems, 1998 - 1999
  6. //
  7. // File: stc.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #if !defined( __STC_H__ )
  11. #define __STC_H__
  12. #define NAD_IDX 0x00
  13. #define PCB_IDX 0x01
  14. #define LEN_IDX 0x02
  15. #define DATA_IDX 0x03
  16. #define PROLOGUE_LEN 0x03
  17. #define EPILOGUE_LEN 0x01
  18. #define PACKET_OVERHEAD 4
  19. #define OSC 16000
  20. #define FREQ 3580
  21. #define CYC_TO_MS( cyc ) ((ULONG)( cyc / FREQ ))
  22. #define SW_SUCCESS 0x0090
  23. #define SW_OE 0x0020
  24. #define SW_FE 0x0040
  25. #define SW_INSERTED 0xA064
  26. #define SW_REMOVED 0xA164
  27. // register addresses
  28. #define ADR_ETULENGTH15 0x00
  29. #define ADR_ETULENGTH7 0x01
  30. #define ADR_CGT8 0x02
  31. #define ADR_CGT7 0x03
  32. #define ADR_CWT31 0x04
  33. #define ADR_CWT23 0x05
  34. #define ADR_CWT15 0x06
  35. #define ADR_CWT7 0x07
  36. #define ADR_BGT8 0x08
  37. #define ADR_BGT7 0x09
  38. #define ADR_BWT31 0x0A
  39. #define ADR_BWT23 0x0B
  40. #define ADR_BWT15 0x0C
  41. #define ADR_BWT7 0x0D
  42. #define ADR_TCON 0x0E
  43. #define ADR_UART_CONTROL 0x0F
  44. #define ADR_FIFO_CONFIG 0x10
  45. #define ADR_INT_CONTROL 0x11
  46. #define ADR_INT_STATUS 0x12
  47. #define ADR_DATA 0x13
  48. #define ADR_IO_CONFIG 0x14
  49. #define ADR_SC_CONTROL 0x15
  50. #define ADR_CLOCK_CONTROL 0x16
  51. // clock control register
  52. #define M_CKE 0x01
  53. #define M_OEN 0x02
  54. // ETU length register
  55. #define M_ETU_RST 0x80
  56. #define M_DIV 0x30
  57. #define M_DIV1 0x20
  58. #define M_DIV0 0x10
  59. #define M_ETUH 0x0F
  60. #define M_ETUL 0xFF
  61. // CGT length register
  62. #define M_CGTH 0x01
  63. #define M_CGTL 0XFF
  64. // BGT length register
  65. #define M_BGTH 0x01
  66. #define M_BGTL 0xFF
  67. // CWT register
  68. #define M_CWT4 0xFF
  69. #define M_CWT3 0xFF
  70. #define M_CWT2 0xFF
  71. #define M_CWT1 0xFF
  72. // TCON register
  73. #define M_MGT 0x80
  74. #define M_MWT 0x40
  75. #define M_WTR 0x04
  76. #define M_GT 0x02
  77. #define M_WT 0x01
  78. // UART control register
  79. #define M_UEN 0x40
  80. #define M_UART_RST 0x20
  81. #define M_CONV 0x10
  82. #define M_TS 0x08
  83. #define M_PE 0x04
  84. #define M_R 0x03
  85. // FIFO config register
  86. #define M_RFP 0x80
  87. #define M_LD 0x0F
  88. // INT control register
  89. #define M_SSL 0x20
  90. #define M_DRM 0x10
  91. #define M_DSM 0x08
  92. #define M_WTE 0x04
  93. #define M_SIM 0x02
  94. #define M_MEM 0x01
  95. #define M_DRM_MEM 0x11
  96. // INT status register
  97. #define M_FNE 0x80
  98. #define M_FE 0x40
  99. #define M_OE 0x20
  100. #define M_DR 0x10
  101. #define M_TRE 0x08
  102. #define M_WTOVF 0x04
  103. #define M_SENSE 0x02
  104. #define M_MOV 0x01
  105. // SMART card interface
  106. #define M_ALT1 0x20
  107. #define M_ALT2 0x10
  108. #define M_ALT0 0x08
  109. #define M_SDE 0x04
  110. #define M_SL 0x02
  111. #define M_SD 0x01
  112. // SMART card control register
  113. #define M_IO 0x80
  114. #define M_VCE 0x40
  115. #define M_SC_RST 0x20
  116. #define M_SCE 0x10
  117. #define M_SCK 0x08
  118. #define M_C8 0x04
  119. #define M_C4 0x02
  120. #define M_VPE 0x01
  121. // Nad
  122. #define HOST_TO_STC1 0x12
  123. #define HOST_TO_STC2 0x52
  124. #define HOST_TO_ICC1 0x02
  125. #define HOST_TO_ICC2 0x42
  126. #define STC1_TO_HOST 0x21
  127. #define STC2_TO_HOST 0x25
  128. #define ICC1_TO_HOST 0x20
  129. #define ICC2_TO_HOST 0x24
  130. // PCB
  131. #define PCB 0x00
  132. #define CLA_READ_REGISTER 0x00
  133. #define INS_READ_REGISTER 0xB0
  134. #define CLA_WRITE_REGISTER 0x00
  135. #define INS_WRITE_REGISTER 0xD0
  136. #define CLA_READ_FIRMWARE_REVISION 0x00
  137. #define INS_READ_FIRMWARE_REVISION 0xB1
  138. #define PCB_DEFAULT 0x00
  139. #define TLV_BUFFER_SIZE 0x20
  140. #define ATR_SIZE 0x40 // TS + 32 + SW + PROLOGUE + EPILOGUE...
  141. #define MAX_T1_BLOCK_SIZE 270
  142. // ATR interface byte coding in TS
  143. #define TAx 0x01
  144. #define TBx 0x02
  145. #define TCx 0x04
  146. #define TDx 0x08
  147. #define FREQ_DIV 1 // 3,58 MHz XTAL -> SC Clock = 3.58MHz
  148. //#define FREQ_DIV 0x08 /* 30MHz XTAL -> SC Clock = 3.75MHz */
  149. #define PROTOCOL_TO 0
  150. #define PROTOCOL_T1 1
  151. #define PROTOCOL_T14 14
  152. #define PROTOCOL_T15 15
  153. //
  154. // DATA TYPES
  155. //
  156. typedef struct _STC_REGISTER
  157. {
  158. UCHAR Register;
  159. UCHAR Size;
  160. ULONG Value;
  161. } STC_REGISTER, *PSTC_REGISTER;
  162. #endif // ! __STC_H__