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.

220 lines
5.6 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1999
  6. //
  7. // File: init.c
  8. //
  9. //--------------------------------------------------------------------------
  10. #include "intel.h"
  11. NTSTATUS
  12. DriverEntry(
  13. IN PDRIVER_OBJECT DriverObject,
  14. IN PUNICODE_STRING RegistryPath
  15. )
  16. {
  17. return PciIdeXInitialize (
  18. DriverObject,
  19. RegistryPath,
  20. PiixIdeGetControllerProperties,
  21. sizeof (DEVICE_EXTENSION)
  22. );
  23. }
  24. //
  25. // Called on every I/O. Returns 1 if DMA is allowed.
  26. // Returns 0 if DMA is not allowed.
  27. //
  28. ULONG
  29. PiixIdeUseDma(
  30. IN PVOID DeviceExtension,
  31. IN PVOID cdbcmd,
  32. IN UCHAR slave)
  33. /**++
  34. * Arguments : DeviceExtension
  35. Cdb
  36. Slave =1, if slave
  37. =0, if master
  38. --**/
  39. {
  40. PDEVICE_EXTENSION deviceExtension = DeviceExtension;
  41. PUCHAR cdb= cdbcmd;
  42. return 1;
  43. }
  44. NTSTATUS
  45. PiixIdeGetControllerProperties (
  46. IN PVOID DeviceExtension,
  47. IN PIDE_CONTROLLER_PROPERTIES ControllerProperties
  48. )
  49. {
  50. PDEVICE_EXTENSION deviceExtension = DeviceExtension;
  51. NTSTATUS status;
  52. ULONG i;
  53. ULONG j;
  54. ULONG mode;
  55. PCIIDE_CONFIG_HEADER pciData;
  56. if (ControllerProperties->Size != sizeof (IDE_CONTROLLER_PROPERTIES)) {
  57. return STATUS_REVISION_MISMATCH;
  58. }
  59. status = PciIdeXGetBusData (
  60. deviceExtension,
  61. &pciData,
  62. 0,
  63. sizeof (pciData)
  64. );
  65. if (!NT_SUCCESS(status)) {
  66. return status;
  67. }
  68. deviceExtension->DeviceId = pciData.DeviceID;
  69. if (!IS_INTEL(pciData.VendorID)) {
  70. return STATUS_UNSUCCESSFUL;
  71. }
  72. mode = PIO_SUPPORT;
  73. deviceExtension->UdmaController = NoUdma;
  74. if (pciData.MasterIde) {
  75. mode |= SWDMA_SUPPORT | MWDMA_SUPPORT;
  76. if (IS_UDMA33_CONTROLLER(pciData.DeviceID)) {
  77. mode |= UDMA33_SUPPORT;
  78. deviceExtension->UdmaController = Udma33;
  79. }
  80. if (IS_UDMA66_CONTROLLER(pciData.DeviceID)) {
  81. ICH_PCI_CONFIG_DATA ichPciData;
  82. status = PciIdeXGetBusData (
  83. deviceExtension,
  84. &ichPciData,
  85. 0,
  86. sizeof (ichPciData)
  87. );
  88. if (NT_SUCCESS(status)) {
  89. deviceExtension->CableReady[0][0] = (BOOLEAN) ichPciData.IoConfig.b.PrimaryMasterCableReady;
  90. deviceExtension->CableReady[0][1] = (BOOLEAN) ichPciData.IoConfig.b.PrimarySlaveCableReady;
  91. deviceExtension->CableReady[1][0] = (BOOLEAN) ichPciData.IoConfig.b.SecondaryMasterCableReady;
  92. deviceExtension->CableReady[1][1] = (BOOLEAN) ichPciData.IoConfig.b.SecondarySlaveCableReady;
  93. mode |= UDMA66_SUPPORT;
  94. }
  95. deviceExtension->UdmaController = Udma66;
  96. }
  97. if (IS_UDMA100_CONTROLLER(pciData.DeviceID)) {
  98. ASSERT(IS_UDMA33_CONTROLLER(pciData.DeviceID));
  99. ASSERT(IS_UDMA66_CONTROLLER(pciData.DeviceID));
  100. if (NT_SUCCESS(status)) {
  101. mode |= UDMA100_SUPPORT;
  102. }
  103. deviceExtension->UdmaController = Udma100;
  104. }
  105. }
  106. for (i=0; i< MAX_IDE_CHANNEL; i++) {
  107. for (j=0; j< MAX_IDE_DEVICE; j++) {
  108. ControllerProperties->SupportedTransferMode[i][j] =
  109. deviceExtension->TransferModeSupported[i][j] =
  110. deviceExtension->TransferModeSupported[i][j] = mode;
  111. }
  112. }
  113. //
  114. // use this when required
  115. // if ((pciData.VendorID == 0x8086) && // Intel
  116. // (pciData.DeviceID == 0x84c4) && // 82450GX/KX Pentium Pro Processor to PCI bridge
  117. // (pciData.RevisionID < 0x4)) { // Stepping less than 4
  118. // NO DMA
  119. ControllerProperties->PciIdeChannelEnabled = PiixIdeChannelEnabled;
  120. ControllerProperties->PciIdeSyncAccessRequired = PiixIdeSyncAccessRequired;
  121. ControllerProperties->PciIdeUseDma = PiixIdeUseDma;
  122. ControllerProperties->PciIdeUdmaModesSupported = PiixIdeUdmaModesSupported;
  123. ControllerProperties->AlignmentRequirement=1;
  124. #ifdef PIIX_TIMING_REGISTER_SUPPORT
  125. ControllerProperties->PciIdeTransferModeSelect = PiixIdeTransferModeSelect;
  126. #else
  127. ControllerProperties->PciIdeTransferModeSelect = NULL;
  128. #endif
  129. return STATUS_SUCCESS;
  130. }
  131. IDE_CHANNEL_STATE
  132. PiixIdeChannelEnabled (
  133. IN PVOID DeviceExtension,
  134. IN ULONG Channel
  135. )
  136. {
  137. PDEVICE_EXTENSION deviceExtension = DeviceExtension;
  138. NTSTATUS status;
  139. PIIX4_PCI_CONFIG_DATA pciData;
  140. ASSERT ((Channel & ~1) == 0);
  141. if (Channel & ~1) {
  142. return FALSE;
  143. }
  144. status = PciIdeXGetBusData (
  145. deviceExtension,
  146. &pciData.Timing,
  147. FIELD_OFFSET(PIIX4_PCI_CONFIG_DATA, Timing),
  148. sizeof (pciData.Timing)
  149. );
  150. if (!NT_SUCCESS(status)) {
  151. //
  152. // can't tell
  153. //
  154. return ChannelStateUnknown;
  155. }
  156. return pciData.Timing[Channel].b.ChannelEnable ? ChannelEnabled : ChannelDisabled;
  157. }
  158. BOOLEAN
  159. PiixIdeSyncAccessRequired (
  160. IN PVOID DeviceHandle
  161. )
  162. {
  163. //
  164. // Never!
  165. //
  166. return FALSE;
  167. }