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.

223 lines
4.8 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. ideintrf.c
  5. Abstract:
  6. This module implements the "Pci Native Ide" interfaces supported
  7. by the PCI driver.
  8. Author:
  9. Andrew Thornton (andrewth) 1-26-2001
  10. Revision History:
  11. --*/
  12. #include "pcip.h"
  13. VOID
  14. nativeIde_RefDereference(
  15. IN PVOID Context
  16. );
  17. NTSTATUS
  18. nativeIde_Constructor(
  19. IN PVOID DeviceExtension,
  20. IN PVOID PciInterface,
  21. IN PVOID InterfaceSpecificData,
  22. IN USHORT Version,
  23. IN USHORT Size,
  24. OUT PINTERFACE InterfaceReturn
  25. );
  26. NTSTATUS
  27. nativeIde_Initializer(
  28. IN PPCI_ARBITER_INSTANCE Instance
  29. );
  30. VOID
  31. nativeIde_InterruptControl(
  32. IN PVOID Context,
  33. IN BOOLEAN Enable
  34. );
  35. //
  36. // Define the Pci Routing interface "Interface" structure.
  37. //
  38. PCI_INTERFACE PciNativeIdeInterface = {
  39. &GUID_PCI_NATIVE_IDE_INTERFACE, // InterfaceType
  40. sizeof(PCI_NATIVE_IDE_INTERFACE), // MinSize
  41. PCI_NATIVE_IDE_INTERFACE_VERSION, // MinVersion
  42. PCI_NATIVE_IDE_INTERFACE_VERSION, // MaxVersion
  43. PCIIF_PDO, // Flags
  44. 0, // ReferenceCount
  45. PciInterface_NativeIde, // Signature
  46. nativeIde_Constructor, // Constructor
  47. nativeIde_Initializer // Instance Initializer
  48. };
  49. VOID
  50. nativeIde_RefDereference(
  51. IN PVOID Context
  52. )
  53. {
  54. return;
  55. }
  56. NTSTATUS
  57. nativeIde_Constructor(
  58. PVOID DeviceExtension,
  59. PVOID PciInterface,
  60. PVOID InterfaceSpecificData,
  61. USHORT Version,
  62. USHORT Size,
  63. PINTERFACE InterfaceReturn
  64. )
  65. /*++
  66. Routine Description:
  67. Initialize the PCI_NATIVE_IDE_INTERFACE fields.
  68. Arguments:
  69. DeviceExtension - Extension of the device
  70. PciInterface Pointer to the PciInterface record for this
  71. interface type.
  72. InterfaceSpecificData - from the QUERY_INTERFACE irp
  73. Version - Version of the interface requested
  74. Size - Size of the buffer
  75. InterfaceReturn - Buffer to return the interface in
  76. Return Value:
  77. Status
  78. --*/
  79. {
  80. PPCI_NATIVE_IDE_INTERFACE interface = (PPCI_NATIVE_IDE_INTERFACE)InterfaceReturn;
  81. PPCI_PDO_EXTENSION pdo = DeviceExtension;
  82. ASSERT_PCI_PDO_EXTENSION(pdo);
  83. if (!PCI_IS_NATIVE_CAPABLE_IDE_CONTROLLER(pdo)) {
  84. return STATUS_INVALID_DEVICE_REQUEST;
  85. }
  86. interface->Size = sizeof(PCI_NATIVE_IDE_INTERFACE);
  87. interface->Context = DeviceExtension;
  88. interface->Version = PCI_NATIVE_IDE_INTERFACE_VERSION;
  89. interface->InterfaceReference = nativeIde_RefDereference;
  90. interface->InterfaceDereference = nativeIde_RefDereference;
  91. interface->InterruptControl = nativeIde_InterruptControl;
  92. return STATUS_SUCCESS;
  93. }
  94. NTSTATUS
  95. nativeIde_Initializer(
  96. IN PPCI_ARBITER_INSTANCE Instance
  97. )
  98. /*++
  99. Routine Description:
  100. For bus interface, does nothing, shouldn't actually be called.
  101. Arguments:
  102. Instance Pointer to the PDO extension.
  103. Return Value:
  104. Returns the status of this operation.
  105. --*/
  106. {
  107. PCI_ASSERTMSG("PCI nativeide_Initializer, unexpected call.", 0);
  108. return STATUS_UNSUCCESSFUL;
  109. }
  110. VOID
  111. nativeIde_InterruptControl(
  112. IN PVOID Context,
  113. IN BOOLEAN Enable
  114. )
  115. /*++
  116. Routine Description:
  117. Controls the enabling and disabling of native mode PCI IDE controllers
  118. IoSpaceEnable bits which on some controllers (currently Intel ICH3)
  119. will mask off interrupt generation and this prevent the system from
  120. crashing...
  121. Arguments:
  122. Context - Context from the PCI_NATIVE_IDE_INTERFACE
  123. Enable - If TRUE then set the IoSpaceEnable bit in the command register,
  124. otherwise disable it.
  125. Return Value:
  126. None - if this operation fails we have aleady bugchecked in the PCI driver
  127. N.B. This function is called from with an ISR and this must be callable at
  128. DEVICE_LEVEL
  129. --*/
  130. {
  131. PPCI_PDO_EXTENSION pdo = Context;
  132. USHORT command;
  133. //
  134. // Remember we gave the IDE driver control of this
  135. //
  136. pdo->IoSpaceUnderNativeIdeControl = TRUE;
  137. PciReadDeviceConfig(pdo,
  138. &command,
  139. FIELD_OFFSET(PCI_COMMON_CONFIG, Command),
  140. sizeof(command)
  141. );
  142. if (Enable) {
  143. command |= PCI_ENABLE_IO_SPACE;
  144. pdo->CommandEnables |= PCI_ENABLE_IO_SPACE;
  145. } else {
  146. command &= ~PCI_ENABLE_IO_SPACE;
  147. pdo->CommandEnables &= ~PCI_ENABLE_IO_SPACE;
  148. }
  149. PciWriteDeviceConfig(pdo,
  150. &command,
  151. FIELD_OFFSET(PCI_COMMON_CONFIG, Command),
  152. sizeof(command)
  153. );
  154. }