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.

259 lines
6.4 KiB

  1. /*++
  2. Copyright (c) 2002 Microsoft Corporation
  3. Module Name:
  4. sdcard.h
  5. Abstract:
  6. This is the include file that defines all constants and types for
  7. interfacing to the SD bus driver.
  8. // @@BEGIN_DDKSPLIT
  9. Author:
  10. Neil Sandlin
  11. Revision History:
  12. // @@END_DDKSPLIT
  13. --*/
  14. #ifndef _SDCARDH_
  15. #define _SDCARDH_
  16. #define SDCMD_GO_IDLE_STATE 0x00 // 0
  17. #define SDCMD_ALL_SEND_CID 0x02 // 2
  18. #define SDCMD_SEND_RELATIVE_ADDR 0x03 // 3
  19. #define SDCMD_SET_DSR 0x04 // 4
  20. #define SDCMD_IO_SEND_OP_COND 0x05 // 5
  21. #define SDCMD_SELECT_CARD 0x07 // 7
  22. #define SDCMD_SEND_CSD 0x09 // 9
  23. #define SDCMD_SEND_CID 0x0A // 10
  24. #define SDCMD_STOP_TRANSMISSION 0x0C // 12
  25. #define SDCMD_SEND_STATUS 0x0D // 13
  26. #define SDCMD_GO_INACTIVE_STATE 0x0F // 15
  27. #define SDCMD_SET_BLOCKLEN 0x10 // 16
  28. #define SDCMD_READ_BLOCK 0x11 // 17
  29. #define SDCMD_READ_MULTIPLE_BLOCK 0x12 // 18
  30. #define SDCMD_WRITE_BLOCK 0x18 // 24
  31. #define SDCMD_WRITE_MULTIPLE_BLOCK 0x19 // 25
  32. #define SDCMD_PROGRAM_CSD 0x1B // 27
  33. #define SDCMD_SET_WRITE_PROT 0x1C // 28
  34. #define SDCMD_CLR_WRITE_PROT 0x1D // 29
  35. #define SDCMD_SEND_WRITE_PROT 0x1E // 30
  36. #define SDCMD_ERASE_WR_BLK_START 0x20 // 32
  37. #define SDCMD_ERASE_WR_BLK_END 0x21 // 33
  38. #define SDCMD_ERASE 0x26 // 38
  39. #define SDCMD_LOCK_UNLOCK 0x2A // 42
  40. #define SDCMD_IO_RW_DIRECT 0x34 // 52
  41. #define SDCMD_IO_RW_EXTENDED 0x35 // 53
  42. #define SDCMD_APP_CMD 0x37 // 55
  43. #define SDCMD_GEN_CMD 0x38 // 56
  44. #define MAX_SD_CMD 0x38+1
  45. //
  46. // Response values used by the bus driver
  47. //
  48. #define SDCMD_RESP_NONE 0
  49. #define SDCMD_RESP_1 1
  50. #define SDCMD_RESP_1B 0x1B
  51. #define SDCMD_RESP_2 2
  52. #define SDCMD_RESP_3 3
  53. #define SDCMD_RESP_4 4
  54. #define SDCMD_RESP_5 5
  55. #define SDCMD_RESP_5B 0x5B
  56. #define SDCMD_RESP_6 6
  57. //
  58. // Flag values for SD send cmd
  59. //
  60. #define SDCMDF_ACMD 0x0001
  61. #define SDCMDF_DATA 0x0002
  62. #define SDCMDF_READ 0x0004
  63. #define SDCMDF_WRITE 0x0008
  64. #define SDCMDF_MULTIBLOCK 0x0010
  65. //
  66. // Application specific commands for Memory
  67. //
  68. #define SDCMD_SET_BUS_WIDTH 0x06 // 6
  69. #define SDCMD_SD_STATUS 0x0D // 13
  70. #define SDCMD_SEND_NUM_WR_BLOCKS 0x16 // 22
  71. #define SDCMD_SET_WR_BLK_ERASE_COUNT 0x17 // 23
  72. #define SDCMD_SD_APP_OP_COND 0x29 // 41
  73. #define SDCMD_SET_CLR_CARD_DETECT 0x2A // 42
  74. #define SDCMD_SEND_SCR 0x33 // 51
  75. #define MAX_SD_ACMD 0x38+1
  76. //
  77. // SD Card Registers
  78. //
  79. typedef struct _SD_OCR {
  80. union {
  81. struct {
  82. ULONG Reserved1:4;
  83. ULONG VddVoltage:20;
  84. ULONG Reserved2:7;
  85. ULONG PowerUpBusy:1;
  86. } bits;
  87. ULONG AsULONG;
  88. } u;
  89. } SD_OCR, *PSD_OCR;
  90. #pragma pack(1)
  91. typedef struct _SD_CID {
  92. struct {
  93. UCHAR ManufactureMonth:4;
  94. UCHAR ManufactureYearLow:4;
  95. } a;
  96. struct {
  97. UCHAR ManufactureYearHigh:4;
  98. UCHAR reserved:4;
  99. } b;
  100. ULONG SerialNumber;
  101. UCHAR Revision;
  102. UCHAR ProductName[5];
  103. USHORT OemId;
  104. UCHAR ManufacturerId;
  105. } SD_CID, *PSD_CID;
  106. typedef struct _SD_CSD {
  107. struct {
  108. UCHAR reserved:2;
  109. UCHAR FileFormat:2;
  110. UCHAR TempWriteProtect:1;
  111. UCHAR PermWriteProtect:1;
  112. UCHAR CopyFlag:1;
  113. UCHAR FileFormatGroup:1;
  114. } e;
  115. struct {
  116. USHORT reserved:5;
  117. USHORT PartialBlocksWrite:1;
  118. USHORT MaxWriteDataBlockLength:4;
  119. USHORT WriteSpeedFactor:3;
  120. USHORT reserved2:2;
  121. USHORT WriteProtectGroupEnable:1;
  122. } d;
  123. struct {
  124. ULONG WriteProtectGroupSize:7;
  125. ULONG EraseSectorSize:7;
  126. ULONG EraseSingleBlockEnable:1;
  127. ULONG DeviceSizeMultiplier:3;
  128. ULONG WriteCurrentVddMax:3;
  129. ULONG WriteCurrentVddMin:3;
  130. ULONG ReadCurrentVddMax:3;
  131. ULONG ReadCurrentVddMin:3;
  132. ULONG DeviceSizeLow:2;
  133. } c;
  134. struct {
  135. ULONG DeviceSizeHigh:10;
  136. ULONG reserved:2;
  137. ULONG DsrImplemented:1;
  138. ULONG ReadBlockMisalignment:1;
  139. ULONG WriteBlockMisalignment:1;
  140. ULONG PartialBlocksRead:1;
  141. ULONG MaxReadDataBlockLength:4;
  142. ULONG CardCommandClasses:12;
  143. } b;
  144. UCHAR MaxDataTransferRate;
  145. UCHAR DataReadAccessTime2;
  146. UCHAR DataReadAccessTime1;
  147. struct {
  148. UCHAR reserved:6;
  149. UCHAR Version:2;
  150. } a;
  151. } SD_CSD, *PSD_CSD;
  152. typedef struct _SD_RW_DIRECT_ARGUMENT {
  153. union {
  154. struct {
  155. ULONG Data:8;
  156. ULONG Reserved1:1;
  157. ULONG Address:17;
  158. ULONG Reserved2:1;
  159. ULONG ReadAfterWrite:1;
  160. ULONG Function:3;
  161. ULONG WriteToDevice:1;
  162. } bits;
  163. ULONG AsULONG;
  164. } u;
  165. } SD_RW_DIRECT_ARGUMENT, *PSD_RW_DIRECT_ARGUMENT;
  166. typedef struct _SD_RW_EXTENDED_ARGUMENT {
  167. union {
  168. struct {
  169. ULONG Count:9;
  170. ULONG Address:17;
  171. ULONG OpCode:1;
  172. ULONG BlockMode:1;
  173. ULONG Function:3;
  174. ULONG WriteToDevice:1;
  175. } bits;
  176. ULONG AsULONG;
  177. } u;
  178. } SD_RW_EXTENDED_ARGUMENT, *PSD_RW_EXTENDED_ARGUMENT;
  179. #pragma pack()
  180. //
  181. // SDIO definitions
  182. //
  183. //
  184. // SDIO CCCR layout by offset
  185. //
  186. #define SD_CCCR_REVISION 0
  187. #define SD_CCCR_SPEC_REVISION 1
  188. #define SD_CCCR_IO_ENABLE 2
  189. #define SD_CCCR_IO_READY 3
  190. #define SD_CCCR_INT_ENABLE 4
  191. #define SD_CCCR_INT_PENDING 5
  192. #define SD_CCCR_IO_ABORT 6
  193. #define SD_CCCR_BUS_CONTROL 7
  194. #define SD_CCCR_CAPABILITIES 8
  195. #define SD_CCCR_CIS_POINTER 9
  196. #define SD_CCCR_BUS_SUSPEND 0x0C
  197. #define SD_CCCR_FUNC_SELECT 0x0D
  198. #define SD_CCCR_EXEC_FLAGS 0x0E
  199. #define SD_CCCR_READY_FLAGS 0x0F
  200. #define SD_CCCR_FN0_BLOCK_SIZE 0x10
  201. #endif