Windows NT 4.0 source code leak
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.

128 lines
2.5 KiB

5 years ago
  1. /*++
  2. Copyright (c) 1993 Microsoft Corporationn, Digital Equipment Corporation
  3. Module Name:
  4. pcibus.c
  5. Abstract:
  6. Platform-specific PCI bus routines
  7. Author:
  8. Environment:
  9. Kernel mode
  10. Revision History:
  11. --*/
  12. #include "halp.h"
  13. #include "pci.h"
  14. #include "pcip.h"
  15. #include "machdep.h"
  16. extern ULONG PCIMaxBus;
  17. //
  18. // Local function prototypes
  19. //
  20. PCI_CONFIGURATION_TYPES
  21. HalpPCIConfigCycleType (
  22. IN ULONG BusNumber
  23. );
  24. VOID
  25. HalpPCIConfigAddr (
  26. IN ULONG BusNumber,
  27. IN PCI_SLOT_NUMBER Slot,
  28. PPCI_CFG_CYCLE_BITS pPciAddr
  29. );
  30. #ifdef AXP_FIRMWARE
  31. //
  32. // Put these functions in the discardable text section.
  33. //
  34. #pragma alloc_text(DISTEXT, HalpPCIConfigCycleType )
  35. #pragma alloc_text(DISTEXT, HalpPCIConfigAddr )
  36. #endif //AXP_FIRMWARE
  37. PCI_CONFIGURATION_TYPES
  38. HalpPCIConfigCycleType (
  39. IN PBUS_HANDLER BusHandler
  40. )
  41. {
  42. if (BusHandler->BusNumber == 0) {
  43. return PciConfigType0;
  44. } else {
  45. return PciConfigType1;
  46. }
  47. }
  48. VOID
  49. HalpPCIConfigAddr (
  50. IN PBUS_HANDLER BusHandler,
  51. IN PCI_SLOT_NUMBER Slot,
  52. PPCI_CFG_CYCLE_BITS pPciAddr
  53. )
  54. {
  55. PCI_CONFIGURATION_TYPES ConfigType;
  56. ConfigType = HalpPCIConfigCycleType(BusHandler);
  57. if (ConfigType == PciConfigType0)
  58. {
  59. //
  60. // Initialize PciAddr for a type 0 configuration cycle
  61. //
  62. // Device number is mapped to address bits 11:24, which are wired to IDSEL pins.
  63. // Note that HalpValidPCISlot has already done bounds checking on DeviceNumber.
  64. //
  65. // PciAddr can be intialized for different bus numbers
  66. // with distinct configuration spaces here.
  67. //
  68. pPciAddr->u.AsULONG = (ULONG) LCA4_PCI_CONFIG_BASE_QVA;
  69. pPciAddr->u.AsULONG += ( 1 << (Slot.u.bits.DeviceNumber + 11) );
  70. pPciAddr->u.bits0.FunctionNumber = Slot.u.bits.FunctionNumber;
  71. pPciAddr->u.bits0.Reserved1 = PciConfigType0;
  72. #if DBG
  73. DbgPrint("Type 0 PCI Config Access @ %x\n", pPciAddr->u.AsULONG);
  74. #endif // DBG
  75. }
  76. else
  77. {
  78. //
  79. // Initialize PciAddr for a type 1 configuration cycle
  80. //
  81. //
  82. pPciAddr->u.AsULONG = (ULONG) LCA4_PCI_CONFIG_BASE_QVA;
  83. pPciAddr->u.bits1.BusNumber = BusHandler->BusNumber;
  84. pPciAddr->u.bits1.FunctionNumber = Slot.u.bits.FunctionNumber;
  85. pPciAddr->u.bits1.DeviceNumber = Slot.u.bits.DeviceNumber;
  86. pPciAddr->u.bits1.Reserved1 = PciConfigType1;
  87. #if DBG
  88. DbgPrint("Type 1 PCI Config Access @ %x\n", pPciAddr->u.AsULONG);
  89. #endif // DBG
  90. }
  91. return;
  92. }