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.

175 lines
3.4 KiB

  1. /*++
  2. Copyright (c) 1998 Gemplus Development
  3. Name:
  4. Gprelcmd.h
  5. Description:
  6. Fonctions enable to access and to deal with GPR. PC/SC version
  7. Header file.
  8. Environment:
  9. Kernel Mode
  10. Revision History:
  11. 06/05/98: V1.00.003 (P. Plouidy)
  12. - Power management for NT5
  13. 10/02/98: V1.00.002 (P. Plouidy)
  14. - Plug and Play for NT5
  15. 03/07/97: V1.00.001 (P. Plouidy)
  16. - Start of development.
  17. --*/
  18. #include "gprnt.h"
  19. //
  20. // Name definition:
  21. // _GPRELCMD_ is used to avoid multiple inclusion.
  22. //
  23. #ifndef _GPRELCMD_
  24. #define _GPRELCMD_
  25. //
  26. // Constants section:
  27. // - REGISTER_HANDSHAKE, REGISTER_PRG, REGISTER_T, REGISTER_L and REGISTER_V are
  28. // the offset address in the GPR.
  29. // - HANDSHAKE_INTR defines the mask for INTR bit in the handshake register.
  30. // - HANDSHAKE_IREQ defines the mask for IREQ bit in the handshake register.
  31. // - MAX_V_LEN defines the maximum length data for a TLV command.
  32. //
  33. #define REGISTER_HANDSHAKE 0x00
  34. #define REGISTER_PRG 0x01
  35. #define REGISTER_T 0x02
  36. #define REGISTER_L 0x03
  37. #define REGISTER_V 0x04
  38. #define HANDSHAKE_INTR 0x02
  39. #define HANDSHAKE_IREQ 0x04
  40. #define MAX_V_LEN 28
  41. //
  42. // GPR400 commands definitions:
  43. //
  44. #define DEFINE_TYPE_CMD 0x50
  45. #define OPEN_SESSION_CMD 0x20
  46. #define CLOSE_SESSION_CMD 0x10
  47. #define APDU_EXCHANGE_CMD 0x30
  48. #define VALIDATE_DRIVER_CMD 0x70
  49. #define POWER_DOWN_GPR_CMD 0x40
  50. #define LOAD_MEMORY_CMD 0x60
  51. #define READ_MEMORY_CMD 0x80
  52. #define EXEC_MEMORY_CMD 0x90
  53. #define CHECK_AND_STATUS_CMD 0xA0
  54. #define INIT_ENCRYPTION_CMD 0xB0
  55. #define UPDATE_CMD 0xF0
  56. //
  57. // Debug prototypes
  58. //
  59. #if DBG
  60. void GPR_Debug_Buffer
  61. (
  62. PUCHAR pBuffer,
  63. DWORD Lenght
  64. );
  65. #endif
  66. //
  67. // Prototype section
  68. //
  69. NTSTATUS GDDK_Translate
  70. (
  71. const BYTE IFDStatus,
  72. const UCHAR Tag
  73. );
  74. BOOLEAN G_ReadByte
  75. (
  76. const USHORT BIOAddr,
  77. UCHAR *Value
  78. );
  79. BOOLEAN G_WriteByte
  80. (
  81. const USHORT BIOAddr,
  82. UCHAR *Value
  83. );
  84. BOOLEAN G_ReadBuf
  85. (
  86. const USHORT BIOAddr,
  87. const USHORT Len,
  88. UCHAR *Buffer
  89. );
  90. BOOLEAN G_WriteBuf
  91. (
  92. const USHORT BIOAddr,
  93. const USHORT Len,
  94. UCHAR *Buffer
  95. );
  96. UCHAR GprllReadRegister
  97. (
  98. const PREADER_EXTENSION pReaderExt,
  99. const SHORT GPRRegister
  100. );
  101. void GprllMaskHandshakeRegister
  102. (
  103. const PREADER_EXTENSION pReaderExt,
  104. const UCHAR Mask,
  105. const UCHAR BitState
  106. );
  107. NTSTATUS GprllTLVExchange
  108. (
  109. const PREADER_EXTENSION pReaderExt,
  110. const UCHAR Ti,
  111. const USHORT Li,
  112. const UCHAR *Vi,
  113. UCHAR *To,
  114. USHORT *Lo,
  115. UCHAR *Vo
  116. );
  117. void GprllSendCmd
  118. (
  119. const PREADER_EXTENSION pReaderExt,
  120. const UCHAR Ti,
  121. const USHORT Li,
  122. const UCHAR *Vi
  123. );
  124. void GprllReadResp
  125. (
  126. const PREADER_EXTENSION pReaderExt
  127. );
  128. NTSTATUS GprllSendChainUp
  129. (
  130. const PREADER_EXTENSION pReaderExt,
  131. const UCHAR Ti,
  132. const USHORT Li,
  133. const UCHAR *Vi
  134. );
  135. NTSTATUS GprllReadChainUp
  136. (
  137. const PREADER_EXTENSION pReaderExt,
  138. UCHAR *To,
  139. USHORT *Lo,
  140. UCHAR *Vo
  141. );
  142. // GprllWait
  143. //
  144. void GprllWait
  145. (
  146. const LONG lWaitingTime
  147. );
  148. #endif