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.

338 lines
11 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1999
  6. //
  7. // File: intel.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #if !defined (___intel_h___)
  11. #define ___intel_h___
  12. #include "stddef.h"
  13. #include "ntddk.h"
  14. #include "ntdddisk.h"
  15. #include "ide.h"
  16. #define INTEL_PCI_VENDOR_ID ((USHORT)0x8086)
  17. #define PIIX_DEVICE_ID ((USHORT)0x1230)
  18. #define PIIX3_DEVICE_ID ((USHORT)0x7010)
  19. #define PIIX4_DEVICE_ID ((USHORT)0x7111)
  20. #define ICH_DEVICE_ID ((USHORT)0x2411)
  21. #define ICH0_DEVICE_ID ((USHORT)0x2421)
  22. #define ICH2_LOWEND_DEVICE_ID ((USHORT)0x2441)
  23. #define ICH2_MOBILE_DEVICE_ID ((USHORT)0x244A)
  24. #define ICH2_HIGHEND_DEVICE_ID ((USHORT)0x244B)
  25. #define ICH3_DEVICE_ID_1 ((USHORT)0x248A)
  26. #define ICH3_DEVICE_ID_2 ((USHORT)0x248B)
  27. #define ICH4_DEVICE_ID_1 ((USHORT)0x24C1)
  28. #define ICH4_DEVICE_ID_2 ((USHORT)0x24CA)
  29. #define ICH4_DEVICE_ID_3 ((USHORT)0x24CB)
  30. #define ICH5_DEVICE_ID_1 ((USHORT)0x24D1)
  31. #define ICH5_DEVICE_ID_2 ((USHORT)0x24DB)
  32. #define SINGLE_CHANNEL_IDE_DEVICE_ID ((USHORT)0x7199)
  33. #define IA64_IDE_CONTROLLER_DEVICE_ID ((USHORT)0x7601)
  34. #define IS_INTEL(vendorId) (vendorId == INTEL_PCI_VENDOR_ID)
  35. #define IS_PIIX(deviceId) (deviceId == PIIX_DEVICE_ID)
  36. #define IS_PIIX3(deviceId) (deviceId == PIIX3_DEVICE_ID)
  37. #define IS_PIIX4(deviceId) (deviceId == PIIX4_DEVICE_ID)
  38. #define IS_ICH_(deviceId) (deviceId == ICH_DEVICE_ID)
  39. #define IS_ICH0(deviceId) (deviceId == ICH0_DEVICE_ID || deviceId == IA64_IDE_CONTROLLER_DEVICE_ID)
  40. #define IS_ICH2_LOW(deviceId) (deviceId == ICH2_LOWEND_DEVICE_ID)
  41. #define IS_ICH2_MOBILE(deviceId) (deviceId == ICH2_MOBILE_DEVICE_ID)
  42. #define IS_ICH2_HIGH(deviceId) (deviceId == ICH2_HIGHEND_DEVICE_ID)
  43. #define IS_ICH2(deviceId) (IS_ICH2_LOW(deviceId) || IS_ICH2_MOBILE(deviceId) || IS_ICH2_HIGH(deviceId))
  44. #define IS_ICH3(deviceId) ((deviceId == ICH3_DEVICE_ID_1) || (deviceId == ICH3_DEVICE_ID_2))
  45. #define IS_ICH4(deviceId) ((deviceId == ICH4_DEVICE_ID_1) || (deviceId == ICH4_DEVICE_ID_2) || (deviceId == ICH4_DEVICE_ID_3))
  46. #define IS_ICH5(deviceId) ((deviceId == ICH5_DEVICE_ID_1) || (deviceId == ICH5_DEVICE_ID_2))
  47. #define IS_SINGLE_IDE(deviceId) (deviceId == SINGLE_CHANNEL_IDE_DEVICE_ID)
  48. #define IS_UDMA33_CONTROLLER(deviceId) (IS_PIIX4(deviceId) || IS_ICH0(deviceId) || IS_ICH_(deviceId) || IS_SINGLE_IDE(deviceId) || IS_ICH2(deviceId) || IS_ICH3(deviceId) || IS_ICH4(deviceId) || IS_ICH5(deviceId))
  49. #define IS_UDMA66_CONTROLLER(deviceId) (IS_ICH_(deviceId) || IS_ICH2(deviceId) || IS_ICH3(deviceId) || IS_ICH4(deviceId) || IS_ICH5(deviceId))
  50. #define IS_UDMA100_CONTROLLER(deviceId) (IS_ICH2_MOBILE(deviceId) || IS_ICH2_HIGH(deviceId) || IS_ICH3(deviceId) || IS_ICH4(deviceId) || IS_ICH5(deviceId))
  51. #define IS_UDMA_CONTROLLER(deviceId) (IS_UDMA33_CONTROLLER(deviceId) || IS_UDMA66_CONTROLLER(deviceId) || IS_UDMA100_CONTROLLER(deviceId))
  52. #pragma pack(1)
  53. typedef struct _PIIX_SPECIAL_TIMING_REGISTER {
  54. union {
  55. UCHAR AsUChar;
  56. struct {
  57. UCHAR FastTimingBankDriveSelect:1;
  58. UCHAR IoReadySamplePointEnableDriveSelect:1;
  59. UCHAR PrefetchAndPostingEnable:1;
  60. UCHAR DmaTimingEnable:1;
  61. } b;
  62. };
  63. } PIIX_SPECIAL_TIMING_REGISTER, *PPIIX_SPECIAL_TIMING_REGISTER;
  64. typedef struct _PIIX_TIMING_REGISTER {
  65. union {
  66. struct {
  67. union {
  68. struct {
  69. UCHAR Device0SpecialTiming:4;
  70. UCHAR Device1SpecialTiming:4;
  71. } n;
  72. struct {
  73. UCHAR FastTimingBankDriveSelect0:1;
  74. UCHAR IoReadySamplePointEnableDriveSelect0:1;
  75. UCHAR PrefetchAndPostingEnable0:1;
  76. UCHAR DmaTimingEnable0:1;
  77. UCHAR FastTimingBankDriveSelect1:1;
  78. UCHAR IoReadySamplePointEnableDriveSelect1:1;
  79. UCHAR PrefetchAndPostingEnable1:1;
  80. UCHAR DmaTimingEnable1:1;
  81. } b;
  82. };
  83. UCHAR RecoveryTime:2;
  84. UCHAR Reserved:2;
  85. UCHAR IoReadySamplePoint:2;
  86. UCHAR SlaveTimingEnable:1;
  87. UCHAR ChannelEnable:1;
  88. }b;
  89. USHORT AsUShort;
  90. };
  91. } PIIX_TIMING_REGISTER, *PPIIX_TIMING_REGISTER;
  92. typedef struct _PIIX3_SLAVE_TIMING_REGISTER {
  93. union {
  94. struct {
  95. UCHAR Channel0RecoveryTime:2;
  96. UCHAR Channel0IoReadySamplePoint:2;
  97. UCHAR Channel1RecoveryTime:2;
  98. UCHAR Channel1IoReadySamplePoint:2;
  99. } b;
  100. UCHAR AsUChar;
  101. };
  102. } PIIX3_SLAVE_TIMING_REGISTER, *PPIIX3_SLAVE_TIMING_REGISTER;
  103. typedef struct _PIIX4_UDMA_CONTROL_REGISTER {
  104. union {
  105. struct {
  106. UCHAR Channel0Drive0UdmaEnable:1;
  107. UCHAR Channel0Drive1UdmaEnable:1;
  108. UCHAR Channel1Drive0UdmaEnable:1;
  109. UCHAR Channel1Drive1UdmaEnable:1;
  110. UCHAR Reserved:4;
  111. } b;
  112. UCHAR AsUChar;
  113. };
  114. }PIIX4_UDMA_CONTROL_REGISTER, *PPIIX4_UDMA_CONTROL_REGISTER;
  115. typedef struct _PIIX4_UDMA_TIMING_REGISTER {
  116. union {
  117. struct {
  118. UCHAR Drive0CycleTime:2;
  119. UCHAR Reserved0:2;
  120. UCHAR Drive1CycleTime:2;
  121. UCHAR Reserved1:2;
  122. } b;
  123. UCHAR AsUChar;
  124. };
  125. }PIIX4_UDMA_TIMING_REGISTER, *PPIIX4_UDMA_TIMING_REGISTER;
  126. typedef struct _ICH_IO_CONFIG_REGISTER {
  127. union {
  128. USHORT AsUShort;
  129. struct {
  130. USHORT PrimaryMasterBaseClock:1;
  131. USHORT PrimarySlaveBaseClock:1;
  132. USHORT SecondaryMasterBaseClock:1;
  133. USHORT SecondarySlaveBaseClock:1;
  134. USHORT PrimaryMasterCableReady:1;
  135. USHORT PrimarySlaveCableReady:1;
  136. USHORT SecondaryMasterCableReady:1;
  137. USHORT SecondarySlaveCableReady:1;
  138. USHORT Reserved1:2;
  139. USHORT WriteBufferPingPongEnable:1;
  140. USHORT Reserved2:1;
  141. USHORT FastPrimaryMasterBaseClock:1;
  142. USHORT FastPrimarySlaveBaseClock:1;
  143. USHORT FastSecondaryMasterBaseClock:1;
  144. USHORT FastSecondarySlaveBaseClock:1;
  145. /***
  146. union {
  147. USHORT Reserved3:4;
  148. struct {
  149. USHORT FastPrimaryMasterBaseClock:1;
  150. USHORT FastPrimarySlaveBaseClock:1;
  151. USHORT FastSecondaryMasterBaseClock:1;
  152. USHORT FastSecondarySlaveBaseClock:1;
  153. }f;
  154. };
  155. ***/
  156. } b;
  157. }; // offset 54
  158. }ICH_IO_CONFIG_REGISTER, *PICH_IO_CONFIG_REGISTER;
  159. #define PIIX4_UDMA_MODE2_TIMING 2
  160. #define PIIX4_UDMA_MODE1_TIMING 1
  161. #define PIIX4_UDMA_MODE0_TIMING 0
  162. typedef struct _PIIX4_PCI_CONFIG_DATA {
  163. PCIIDE_CONFIG_HEADER h;
  164. PIIX_TIMING_REGISTER Timing[MAX_IDE_CHANNEL]; // offset 40, 41, 42, 43
  165. PIIX3_SLAVE_TIMING_REGISTER SlaveTiming; // offset 44
  166. UCHAR Reserved0[3]; // offset 45, 46, 47
  167. PIIX4_UDMA_CONTROL_REGISTER UdmaControl; // offset 48
  168. UCHAR Reserved1[1]; // offset 49
  169. PIIX4_UDMA_TIMING_REGISTER UdmaTiming[MAX_IDE_CHANNEL]; // offset 4a, 4b
  170. } PIIX4_PCI_CONFIG_DATA, *PPIIX4_PCI_CONFIG_DATA;
  171. #define ICH2_UDMA_MODE5_TIMING 1
  172. #define ICH_UDMA_MODE4_TIMING 2
  173. #define ICH_UDMA_MODE3_TIMING 1
  174. typedef enum {
  175. NoUdma=0,
  176. Udma33,
  177. Udma66,
  178. Udma100
  179. }CONTROLLER_MODE;
  180. typedef struct _ICH_PCI_CONFIG_DATA {
  181. PIIX4_PCI_CONFIG_DATA Piix4PciConfigData;
  182. UCHAR Reserved2[8]; // offset 4c-53
  183. ICH_IO_CONFIG_REGISTER IoConfig; // offset 54
  184. } ICH_PCI_CONFIG_DATA, *PICH_PCI_CONFIG_DATA;
  185. #pragma pack()
  186. typedef struct _DEVICE_EXTENSION {
  187. USHORT DeviceId;
  188. ULONG TransferModeSupported[MAX_IDE_CHANNEL][MAX_IDE_DEVICE];
  189. BOOLEAN CableReady[MAX_IDE_CHANNEL][MAX_IDE_DEVICE];
  190. CONTROLLER_MODE UdmaController;
  191. IDENTIFY_DATA IdentifyData[MAX_IDE_DEVICE];
  192. } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
  193. #define PIIX_TIMING_CHANNEL_ENABLE 0x8000
  194. #define PIIX_TIMING_SLAVE_TIMING_ENABLE 0x4000
  195. #define PIIX_TIMING_DMA_TIMING_ENABLE(x) (x ? 0x0008 : 0)
  196. #define PIIX_TIMING_PREFETCH_AND_POSTING_ENABLE(x) (x ? 0x0004 : 0)
  197. #define PIIX_TIMING_IOREADY_SAMPLE_POINT_ENABLE(x) (x ? 0x0002 : 0)
  198. #define PIIX_TIMING_FAST_TIMING_BANK_ENABLE(x) (x ? 0x0001 : 0)
  199. #define UDMA_MASK(controller, cable, enableUdma66, mask) {\
  200. switch (controller) { \
  201. case Udma100: mask &= 0xffffffff;enableUdma66=1;break; \
  202. case Udma66: mask &= 0x0000ffff;break; \
  203. case Udma33: mask &= 0x00003fff;break; \
  204. default: mask &= 0x000007ff;break; \
  205. } \
  206. if (!(cable && enableUdma66)) { \
  207. mask &= 0x00003fff; \
  208. } \
  209. }
  210. typedef enum {
  211. PiixMode_NotPresent = 0,
  212. PiixMode_Mode0,
  213. PiixMode_Mode2,
  214. PiixMode_Mode3,
  215. PiixMode_Mode4,
  216. PiixMode_MaxMode
  217. } PIIX_TIMING_MODE;
  218. NTSTATUS
  219. DriverEntry(
  220. IN PDRIVER_OBJECT DriverObject,
  221. IN PUNICODE_STRING RegistryPath
  222. );
  223. NTSTATUS
  224. PiixIdeGetControllerProperties (
  225. IN PVOID DeviceExtension,
  226. IN PIDE_CONTROLLER_PROPERTIES ControllerProperties
  227. );
  228. IDE_CHANNEL_STATE
  229. PiixIdeChannelEnabled (
  230. IN PVOID DeviceHandle,
  231. IN ULONG Channel
  232. );
  233. BOOLEAN
  234. PiixIdeSyncAccessRequired (
  235. IN PVOID DeviceHandle
  236. );
  237. NTSTATUS
  238. PiixIdeTransferModeSelect (
  239. IN PDEVICE_EXTENSION DeviceExtension,
  240. IN OUT PPCIIDE_TRANSFER_MODE_SELECT TransferModeSelect
  241. );
  242. NTSTATUS
  243. PiixIdeUdmaModesSupported (
  244. IN IDENTIFY_DATA IdentifyData,
  245. IN OUT PULONG BestXferMode,
  246. IN OUT PULONG CurrentMode
  247. );
  248. #include "timing.h"
  249. #endif // ___intel_h___