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.

203 lines
5.2 KiB

  1. /*++
  2. Copyright (c) 1997-2000 Microsoft Corporation
  3. Module Name:
  4. tr_irq.c
  5. Abstract:
  6. This module implements the PCI Interrupt translator. It should eventually
  7. go away when all the HALs provide translators.
  8. Author:
  9. Andrew Thornton (andrewth) 21-May-1997
  10. Revision History:
  11. --*/
  12. #include "pcip.h"
  13. #define TRANIRQ_VERSION 0
  14. //
  15. // Irq translator
  16. //
  17. NTSTATUS
  18. tranirq_Initializer(
  19. IN PPCI_ARBITER_INSTANCE Instance
  20. );
  21. NTSTATUS
  22. tranirq_Constructor(
  23. PVOID DeviceExtension,
  24. PVOID PciInterface,
  25. PVOID InterfaceSpecificData,
  26. USHORT Version,
  27. USHORT Size,
  28. PINTERFACE InterfaceReturn
  29. );
  30. NTSTATUS
  31. tranirq_TranslateResource(
  32. IN PVOID Context,
  33. IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source,
  34. IN RESOURCE_TRANSLATION_DIRECTION Direction,
  35. IN ULONG AlternativesCount, OPTIONAL
  36. IN IO_RESOURCE_DESCRIPTOR Alternatives[], OPTIONAL
  37. IN PDEVICE_OBJECT PhysicalDeviceObject,
  38. OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target
  39. );
  40. NTSTATUS
  41. tranirq_TranslateResourceRequirement(
  42. IN PVOID Context,
  43. IN PIO_RESOURCE_DESCRIPTOR Source,
  44. IN PDEVICE_OBJECT PhysicalDeviceObject,
  45. OUT PULONG TargetCount,
  46. OUT PIO_RESOURCE_DESCRIPTOR *Target
  47. );
  48. NTSTATUS
  49. tranirq_TranslateInterrupt(
  50. IN PDEVICE_OBJECT Pdo,
  51. IN PPCI_TRANSLATOR_INSTANCE Translator,
  52. IN ULONG Vector,
  53. OUT PULONG TranslatedVector,
  54. OUT PULONG TranslatedLevel,
  55. OUT PULONG TranslatedAffinity,
  56. OUT PULONG UntranslatedVector
  57. );
  58. #define TR_IRQ_INVALID_VECTOR 0xffffffff
  59. #ifdef ALLOC_PRAGMA
  60. #pragma alloc_text(PAGE, tranirq_Initializer)
  61. #pragma alloc_text(PAGE, tranirq_Constructor)
  62. #endif
  63. PCI_INTERFACE TranslatorInterfaceInterrupt = {
  64. &GUID_TRANSLATOR_INTERFACE_STANDARD, // InterfaceType
  65. sizeof(TRANSLATOR_INTERFACE), // MinSize
  66. TRANIRQ_VERSION, // MinVersion
  67. TRANIRQ_VERSION, // MaxVersion
  68. PCIIF_FDO, // Flags
  69. 0, // ReferenceCount
  70. PciTrans_Interrupt, // Signature
  71. tranirq_Constructor, // Constructor
  72. tranirq_Initializer // Instance Initializer
  73. };
  74. NTSTATUS
  75. tranirq_Initializer(
  76. IN PPCI_ARBITER_INSTANCE Instance
  77. )
  78. {
  79. return STATUS_SUCCESS;
  80. }
  81. NTSTATUS
  82. tranirq_Constructor(
  83. IN PVOID DeviceExtension,
  84. IN PVOID PciInterface,
  85. IN PVOID InterfaceSpecificData,
  86. IN USHORT Version,
  87. IN USHORT Size,
  88. IN PINTERFACE InterfaceReturn
  89. )
  90. /*++
  91. Routine Description:
  92. Check the InterfaceSpecificData to see if this is the correct
  93. translator (we already know the required interface is a translator
  94. from the GUID) and if so, allocate (and reference) a context
  95. for this interface.
  96. Arguments:
  97. PciInterface Pointer to the PciInterface record for this
  98. interface type.
  99. InterfaceSpecificData
  100. A ULONG containing the resource type for which
  101. arbitration is required.
  102. InterfaceReturn
  103. Return Value:
  104. TRUE is this device is not known to cause problems, FALSE
  105. if the device should be skipped altogether.
  106. --*/
  107. {
  108. ULONG secondaryBusNumber, parentBusNumber;
  109. INTERFACE_TYPE parentInterface;
  110. PPCI_FDO_EXTENSION fdoExt = (PPCI_FDO_EXTENSION)DeviceExtension;
  111. PPCI_PDO_EXTENSION pdoExt;
  112. //
  113. // This translator handles interrupts, is that what they want?
  114. //
  115. if ((CM_RESOURCE_TYPE)(ULONG_PTR)InterfaceSpecificData != CmResourceTypeInterrupt) {
  116. PciDebugPrint(
  117. PciDbgVerbose,
  118. "PCI - IRQ trans constructor doesn't like %x in InterfaceSpecificData\n",
  119. InterfaceSpecificData);
  120. //
  121. // No, it's not us then.
  122. //
  123. return STATUS_INVALID_PARAMETER_3;
  124. }
  125. PCI_ASSERT(fdoExt->ExtensionType == PciFdoExtensionType);
  126. //
  127. // Give the HAL a shot at providing this translator.
  128. //
  129. if (PCI_IS_ROOT_FDO(fdoExt)) {
  130. parentInterface = Internal;
  131. secondaryBusNumber = fdoExt->BaseBus;
  132. parentBusNumber = 0;
  133. PciDebugPrint(PciDbgObnoxious, " Is root FDO\n");
  134. } else {
  135. parentInterface = PCIBus;
  136. secondaryBusNumber = fdoExt->BaseBus;
  137. pdoExt = (PPCI_PDO_EXTENSION)fdoExt->PhysicalDeviceObject->DeviceExtension;
  138. parentBusNumber = PCI_PARENT_FDOX(pdoExt)->BaseBus;
  139. PciDebugPrint(PciDbgObnoxious,
  140. " Is bridge FDO, parent bus %x, secondary bus %x\n",
  141. parentBusNumber,
  142. secondaryBusNumber);
  143. }
  144. return HalGetInterruptTranslator(parentInterface,
  145. parentBusNumber,
  146. PCIBus,
  147. sizeof(TRANSLATOR_INTERFACE),
  148. TRANIRQ_VERSION,
  149. (PTRANSLATOR_INTERFACE)InterfaceReturn,
  150. &secondaryBusNumber);
  151. }