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.

398 lines
8.6 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1999
  6. //
  7. // File: ctlrfdo.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #if !defined (___ctrlfdo_h___)
  11. #define ___ctrlfdo_h___
  12. //
  13. // DeviceControlsFlags
  14. //
  15. // WARNING: all of these flags must be correctly reflected
  16. // in the mshdc.inf and txtsetuo.sif files
  17. //
  18. #define PCIIDEX_DCF_NO_ATAPI_DMA (1 << 0)
  19. //
  20. // determine how often we rescan for new unknown child.
  21. // unknown child is IDE channel which we don't know
  22. // it is enabled or not unless we pnp start the channel
  23. // and poke at it to find out.
  24. #define MIN_BUS_SCAN_PERIOD_IN_SEC 90
  25. #define IsNativeMode(d) ((d)->NativeMode[0] && (d)->NativeMode[1])
  26. struct _CONTROLLER_FDO_EXTENSION;
  27. typedef struct _CONTROLLER_FDO_EXTENSION * PCTRLFDO_EXTENSION;
  28. typedef struct _IDE_BUS_MASTER_REGISTERS * PIDE_BUS_MASTER_REGISTERS;
  29. typedef struct _DRIVER_OBJECT_EXTENSION {
  30. PCONTROLLER_PROPERTIES PciIdeGetControllerProperties;
  31. ULONG ExtensionSize;
  32. } DRIVER_OBJECT_EXTENSION, *PDRIVER_OBJECT_EXTENSION;
  33. typedef struct _FDO_POWER_CONTEXT {
  34. PIRP OriginalPowerIrp;
  35. POWER_STATE_TYPE newPowerType;
  36. POWER_STATE newPowerState;
  37. } FDO_POWER_CONTEXT, *PFDO_POWER_CONTEXT;
  38. typedef struct _PCIIDE_INTERRUPT_CONTEXT {
  39. PVOID DeviceExtension;
  40. ULONG ChannelNumber;
  41. } PCIIDE_INTERRUPT_CONTEXT, *PPCIIDE_INTERRUPT_CONTEXT;
  42. struct _CHANNEL_PDO_EXTENSION;
  43. typedef struct _CHANNEL_PDO_EXTENSION * PCHANPDO_EXTENSION;
  44. typedef struct _CONTROLLER_FDO_EXTENSION {
  45. EXTENSION_COMMON_HEADER;
  46. ULONG ControllerNumber;
  47. PDEVICE_OBJECT PhysicalDeviceObject;
  48. PCHANPDO_EXTENSION ChildDeviceExtension[MAX_IDE_CHANNEL];
  49. ULONG NumberOfChildren;
  50. //
  51. // Interlocked* protected
  52. //
  53. ULONG NumberOfChildrenPowerUp;
  54. //
  55. // native mode channels
  56. //
  57. BOOLEAN NativeMode[MAX_IDE_CHANNEL];
  58. //
  59. // initialized by AnalyzeResourceList()
  60. //
  61. BOOLEAN PdoCmdRegResourceFound[MAX_IDE_CHANNEL];
  62. BOOLEAN PdoCtrlRegResourceFound[MAX_IDE_CHANNEL];
  63. BOOLEAN PdoInterruptResourceFound[MAX_IDE_CHANNEL];
  64. ULONG PdoResourceListSize[MAX_IDE_CHANNEL];
  65. PCM_RESOURCE_LIST PdoResourceList[MAX_IDE_CHANNEL];
  66. ULONG BmResourceListSize;
  67. PCM_RESOURCE_LIST BmResourceList;
  68. //
  69. // Bus Master Register
  70. //
  71. ULONG BusMasterBaseAddressSpace;
  72. PIDE_BUS_MASTER_REGISTERS TranslatedBusMasterBaseAddress;
  73. //
  74. // Vendor Specific Controller Properties
  75. //
  76. IDE_CONTROLLER_PROPERTIES ControllerProperties;
  77. //
  78. // Vendor Specific Device Extension
  79. //
  80. PVOID VendorSpecificDeviceEntension;
  81. //
  82. // Controller Object for serailizing access to broken PCI-IDE controller
  83. //
  84. //
  85. PCONTROLLER_OBJECT ControllerObject;
  86. //
  87. // mutex for setting pci config data
  88. //
  89. KSPIN_LOCK PciConfigDataLock;
  90. //
  91. // Special device specific parameter
  92. //
  93. ULONG DeviceControlsFlags;
  94. //
  95. // Bus Interface
  96. //
  97. BUS_INTERFACE_STANDARD BusInterface;
  98. //
  99. // Last BusScan Time in sec
  100. //
  101. ULONG LastBusScanTime;
  102. //
  103. // Flag to enable udma66
  104. //
  105. ULONG EnableUDMA66;
  106. //
  107. // Timings for the different transfer modes
  108. //
  109. PULONG TransferModeTimingTable;
  110. //
  111. // Length of the table
  112. //
  113. ULONG TransferModeTableLength;
  114. //
  115. // Pre-alloced context structure for power routines
  116. //
  117. FDO_POWER_CONTEXT FdoPowerContext[MAX_IDE_CHANNEL];
  118. #if DBG
  119. ULONG PowerContextLock[MAX_IDE_CHANNEL];
  120. #endif
  121. #ifdef ENABLE_NATIVE_MODE
  122. //
  123. // Interrupt object
  124. //
  125. PKINTERRUPT InterruptObject[MAX_IDE_CHANNEL];
  126. //
  127. // Context structure for the ISR
  128. //
  129. PCIIDE_INTERRUPT_CONTEXT InterruptContext[MAX_IDE_CHANNEL];
  130. //
  131. // IDE resources for native mode controllers
  132. //
  133. IDE_RESOURCE IdeResource;
  134. //
  135. // Base register locations
  136. //
  137. IDE_REGISTERS_1 BaseIoAddress1[MAX_IDE_CHANNEL];
  138. IDE_REGISTERS_2 BaseIoAddress2[MAX_IDE_CHANNEL];
  139. //
  140. //interrupt
  141. //
  142. PCM_PARTIAL_RESOURCE_DESCRIPTOR IrqPartialDescriptors[MAX_IDE_CHANNEL];
  143. //
  144. // Register length.
  145. //
  146. ULONG BaseIoAddress1Length[MAX_IDE_CHANNEL];
  147. ULONG BaseIoAddress2Length[MAX_IDE_CHANNEL];
  148. //
  149. // Max ide device/target-id
  150. //
  151. ULONG MaxIdeDevice[MAX_IDE_CHANNEL];
  152. ULONG MaxIdeTargetId[MAX_IDE_CHANNEL];
  153. //
  154. // Flags to close the interrupt window
  155. //
  156. BOOLEAN ControllerIsrInstalled;
  157. BOOLEAN NativeInterruptEnabled;
  158. BOOLEAN NoBusMaster[MAX_IDE_CHANNEL];
  159. //
  160. // Native Ide Interface obtained from PCI
  161. //
  162. PCI_NATIVE_IDE_INTERFACE NativeIdeInterface;
  163. #endif
  164. } CTRLFDO_EXTENSION, *PCTRLFDO_EXTENSION;
  165. NTSTATUS
  166. ControllerAddDevice(
  167. IN PDRIVER_OBJECT DriverObject,
  168. IN PDEVICE_OBJECT PhysicalDeviceObject
  169. );
  170. NTSTATUS
  171. ControllerStartDevice (
  172. IN PDEVICE_OBJECT DeviceObject,
  173. IN OUT PIRP Irp
  174. );
  175. NTSTATUS
  176. ControllerStartDeviceCompletionRoutine(
  177. IN PDEVICE_OBJECT DeviceObject,
  178. IN OUT PIRP Irp,
  179. IN OUT PVOID Context
  180. );
  181. NTSTATUS
  182. ControllerStopDevice (
  183. IN PDEVICE_OBJECT DeviceObject,
  184. IN OUT PIRP Irp
  185. );
  186. NTSTATUS
  187. ControllerStopController (
  188. IN PCTRLFDO_EXTENSION fdoExtension
  189. );
  190. NTSTATUS
  191. ControllerSurpriseRemoveDevice (
  192. IN PDEVICE_OBJECT DeviceObject,
  193. IN OUT PIRP Irp
  194. );
  195. NTSTATUS
  196. ControllerRemoveDevice (
  197. IN PDEVICE_OBJECT DeviceObject,
  198. IN OUT PIRP Irp
  199. );
  200. NTSTATUS
  201. ControllerRemoveDeviceCompletionRoutine (
  202. IN PDEVICE_OBJECT DeviceObject,
  203. IN PIRP Irp,
  204. IN PVOID Context
  205. );
  206. NTSTATUS
  207. ControllerQueryDeviceRelations (
  208. IN PDEVICE_OBJECT DeviceObject,
  209. IN OUT PIRP Irp
  210. );
  211. NTSTATUS
  212. ControllerQueryResourceRequirements(
  213. IN PDEVICE_OBJECT DeviceObject,
  214. IN PIRP Irp
  215. );
  216. NTSTATUS
  217. LoadControllerParameters (
  218. PCTRLFDO_EXTENSION FdoExtension
  219. );
  220. NTSTATUS
  221. AnalyzeResourceList (
  222. PCTRLFDO_EXTENSION FdoExtension,
  223. PCM_RESOURCE_LIST ResourceList
  224. );
  225. VOID
  226. ControllerOpMode (
  227. IN PCTRLFDO_EXTENSION FdoExtension
  228. );
  229. VOID
  230. EnablePCIBusMastering (
  231. IN PCTRLFDO_EXTENSION FdoExtension
  232. );
  233. IDE_CHANNEL_STATE
  234. PciIdeChannelEnabled (
  235. IN PCTRLFDO_EXTENSION FdoExtension,
  236. IN ULONG Channel
  237. );
  238. VOID
  239. ControllerTranslatorNull (
  240. IN PVOID Context
  241. );
  242. NTSTATUS
  243. ControllerTranslateResource (
  244. IN PVOID Context,
  245. IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source,
  246. IN RESOURCE_TRANSLATION_DIRECTION Direction,
  247. IN ULONG AlternativesCount OPTIONAL,
  248. IN IO_RESOURCE_DESCRIPTOR Alternatives[] OPTIONAL,
  249. IN PDEVICE_OBJECT PhysicalDeviceObject,
  250. OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target
  251. );
  252. NTSTATUS
  253. ControllerTranslateRequirement (
  254. IN PVOID Context,
  255. IN PIO_RESOURCE_DESCRIPTOR Source,
  256. IN PDEVICE_OBJECT PhysicalDeviceObject,
  257. OUT PULONG TargetCount,
  258. OUT PIO_RESOURCE_DESCRIPTOR *Target
  259. );
  260. NTSTATUS
  261. ControllerQueryInterface (
  262. IN PDEVICE_OBJECT DeviceObject,
  263. IN OUT PIRP Irp
  264. );
  265. VOID
  266. PciIdeInitControllerProperties (
  267. IN PCTRLFDO_EXTENSION FdoExtension
  268. );
  269. NTSTATUS
  270. ControllerUsageNotification (
  271. IN PDEVICE_OBJECT DeviceObject,
  272. IN OUT PIRP Irp
  273. );
  274. NTSTATUS
  275. ControllerUsageNotificationCompletionRoutine (
  276. IN PDEVICE_OBJECT DeviceObject,
  277. IN PIRP Irp,
  278. IN PVOID Context
  279. );
  280. NTSTATUS
  281. PciIdeGetBusStandardInterface(
  282. IN PCTRLFDO_EXTENSION FdoExtension
  283. );
  284. NTSTATUS
  285. ControllerQueryPnPDeviceState (
  286. IN PDEVICE_OBJECT DeviceObject,
  287. IN OUT PIRP Irp
  288. );
  289. NTSTATUS
  290. PciIdeCreateTimingTable (
  291. IN PCTRLFDO_EXTENSION FdoExtension
  292. );
  293. #ifdef ENABLE_NATIVE_MODE
  294. NTSTATUS
  295. ControllerInterruptControl (
  296. IN PCTRLFDO_EXTENSION FdoExtension,
  297. IN ULONG Channel,
  298. IN ULONG Disconnect
  299. );
  300. BOOLEAN
  301. ControllerInterrupt(
  302. IN PKINTERRUPT Interrupt,
  303. PVOID Context
  304. );
  305. NTSTATUS
  306. PciIdeGetNativeModeInterface(
  307. IN PCTRLFDO_EXTENSION FdoExtension
  308. );
  309. #define ControllerEnableInterrupt(FdoExtension) \
  310. if (FdoExtension->NativeIdeInterface.InterruptControl) { \
  311. (FdoExtension->NativeIdeInterface).InterruptControl((FdoExtension->NativeIdeInterface).Context,\
  312. TRUE);\
  313. }
  314. #define ControllerDisableInterrupt(FdoExtension) \
  315. if (FdoExtension->NativeIdeInterface.InterruptControl) { \
  316. (FdoExtension->NativeIdeInterface).InterruptControl((FdoExtension->NativeIdeInterface).Context,\
  317. FALSE);\
  318. }
  319. #endif //ENABLE_NATIVE_MODE
  320. #endif // ___ctrlfdo_h___