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.

200 lines
4.3 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. pciopregion.c
  5. Abstract:
  6. This module implements PCI_BUS_INTERFACE_STANDARD,
  7. which allows the PCI driver to get utility functions
  8. from its parent.
  9. Author:
  10. Jake Oshins (jakeo) 11-14-97
  11. Environment:
  12. NT Kernel Model Driver only
  13. --*/
  14. #include "pch.h"
  15. VOID
  16. PciInterfacePinToLine(
  17. IN PVOID Context,
  18. IN PPCI_COMMON_CONFIG PciData
  19. );
  20. VOID
  21. PciInterfaceLineToPin(
  22. IN PVOID Context,
  23. IN PPCI_COMMON_CONFIG PciNewData,
  24. IN PPCI_COMMON_CONFIG PciOldData
  25. );
  26. ULONG
  27. PciInterfaceReadConfig(
  28. IN PVOID Context,
  29. IN UCHAR BusOffset,
  30. IN ULONG Slot,
  31. IN PVOID Buffer,
  32. IN ULONG Offset,
  33. IN ULONG Length
  34. );
  35. ULONG
  36. PciInterfaceWriteConfig(
  37. IN PVOID Context,
  38. IN UCHAR BusOffset,
  39. IN ULONG Slot,
  40. IN PVOID Buffer,
  41. IN ULONG Offset,
  42. IN ULONG Length
  43. );
  44. #ifdef ALLOC_PRAGMA
  45. #pragma alloc_text(PAGE, PciInterfacePinToLine)
  46. #pragma alloc_text(PAGE, PciInterfaceLineToPin)
  47. #pragma alloc_text(PAGE, PciBusEjectInterface)
  48. #endif
  49. NTSTATUS
  50. PciBusEjectInterface(
  51. PDEVICE_OBJECT DeviceObject,
  52. PIRP Irp
  53. )
  54. {
  55. PIO_RESOURCE_REQUIREMENTS_LIST ioList = NULL;
  56. PPCI_BUS_INTERFACE_STANDARD pciInterface;
  57. PIO_STACK_LOCATION irpSp;
  58. PDEVICE_EXTENSION devExtension;
  59. NTSTATUS status;
  60. BOOLEAN foundBusNumber = FALSE;
  61. OBJDATA crsData;
  62. ULONG i, busNumber;
  63. PAGED_CODE();
  64. ASSERT(HalPciInterfaceReadConfig);
  65. ASSERT(HalPciInterfaceWriteConfig);
  66. devExtension = ACPIInternalGetDeviceExtension(DeviceObject);
  67. ASSERT(devExtension);
  68. ASSERT(devExtension->AcpiObject);
  69. irpSp = IoGetCurrentIrpStackLocation(Irp);
  70. ASSERT(irpSp->Parameters.QueryInterface.Size >=
  71. sizeof(PCI_BUS_INTERFACE_STANDARD));
  72. pciInterface = (PPCI_BUS_INTERFACE_STANDARD)irpSp->Parameters.QueryInterface.Interface;
  73. ASSERT(pciInterface);
  74. status = ACPIGetDataSync(devExtension, PACKED_CRS, &crsData);
  75. if (NT_SUCCESS(status)) {
  76. ASSERT(crsData.dwDataType == OBJTYPE_BUFFDATA);
  77. //
  78. // Turn it into something meaningful.
  79. //
  80. status = PnpBiosResourcesToNtResources(
  81. crsData.pbDataBuff,
  82. PNP_BIOS_TO_IO_NO_CONSUMED_RESOURCES,
  83. &ioList
  84. );
  85. if (NT_SUCCESS(status) && ioList) {
  86. //
  87. // A _CRS shouldn't have choices.
  88. //
  89. ASSERT(ioList->AlternativeLists == 1);
  90. //
  91. // Look for the Bus Number resource.
  92. //
  93. for (i = 0; i < ioList->List[0].Count; i++) {
  94. if (ioList->List[0].Descriptors[i].Type == CmResourceTypeBusNumber) {
  95. break;
  96. }
  97. }
  98. if (i != ioList->List[0].Count) {
  99. busNumber = (ULONG)ioList->List[0].Descriptors[i].u.BusNumber.MinBusNumber;
  100. foundBusNumber = TRUE;
  101. }
  102. }
  103. AMLIFreeDataBuffs(&crsData, 1);
  104. }
  105. if (!foundBusNumber) {
  106. //
  107. // Punt. Assume this is for PCI bus 0.
  108. //
  109. busNumber = 0;
  110. }
  111. pciInterface->Size = sizeof(PCI_BUS_INTERFACE_STANDARD);
  112. pciInterface->Version = 1;
  113. pciInterface->Context = (PVOID)UlongToPtr(busNumber);
  114. pciInterface->InterfaceReference = AcpiNullReference;
  115. pciInterface->InterfaceDereference = AcpiNullReference;
  116. pciInterface->ReadConfig = HalPciInterfaceReadConfig;
  117. pciInterface->WriteConfig = HalPciInterfaceWriteConfig;
  118. pciInterface->PinToLine = PciInterfacePinToLine;
  119. pciInterface->LineToPin = PciInterfaceLineToPin;
  120. status = STATUS_SUCCESS;
  121. if (ioList) {
  122. ExFreePool(ioList);
  123. }
  124. Irp->IoStatus.Status = status;
  125. return status;
  126. }
  127. VOID
  128. PciInterfacePinToLine(
  129. IN PVOID Context,
  130. IN PPCI_COMMON_CONFIG PciData
  131. )
  132. {
  133. return;
  134. }
  135. VOID
  136. PciInterfaceLineToPin(
  137. IN PVOID Context,
  138. IN PPCI_COMMON_CONFIG PciNewData,
  139. IN PPCI_COMMON_CONFIG PciOldData
  140. )
  141. {
  142. return;
  143. }
  144. VOID
  145. AcpiNullReference(
  146. PVOID Context
  147. )
  148. {
  149. return;
  150. }