Source code of Windows XP (NT5)
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.

145 lines
4.4 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. pcibios.h
  5. Abstract:
  6. This module contains support routines for the Pci Irq Routing.
  7. Author:
  8. Santosh Jodh (santoshj) 15-Sept-1998
  9. Environment:
  10. Kernel mode
  11. --*/
  12. #include "hwdetect.h"
  13. #include "pcibios.h"
  14. #define SUCCESSFUL 0x00
  15. #define BUFFER_TOO_SMALL 0x89
  16. #define PIRT_SIGNATURE 0x52495024 // $PIR little endian
  17. #if DBG
  18. #define DebugPrint(x) \
  19. { \
  20. BlPrint x; \
  21. BlPrint("...\n"); \
  22. }
  23. #else
  24. #define DebugPrint(x)
  25. #endif
  26. typedef struct
  27. {
  28. USHORT BufferSize;
  29. UCHAR far *Buffer;
  30. }IRQ_ROUTING_OPTIONS, far *FPIRQ_ROUTING_OPTIONS;
  31. typedef SLOT_INFO far *FPSLOT_INFO;
  32. FPPCI_IRQ_ROUTING_TABLE
  33. HwGetRealModeIrqRoutingTable(
  34. VOID
  35. )
  36. {
  37. IRQ_ROUTING_OPTIONS routeBuffer;
  38. FPPCI_IRQ_ROUTING_TABLE irqRoutingTable = NULL;
  39. USHORT pciIrqMask;
  40. UCHAR returnCode;
  41. USHORT size;
  42. #if DBG
  43. FPSLOT_INFO slotInfo;
  44. FPSLOT_INFO lastSlot;
  45. #endif
  46. routeBuffer.BufferSize = 0;
  47. routeBuffer.Buffer = NULL;
  48. returnCode = HwGetPciIrqRoutingOptions( &routeBuffer,
  49. &pciIrqMask);
  50. if (returnCode == BUFFER_TOO_SMALL)
  51. {
  52. if (routeBuffer.BufferSize)
  53. {
  54. DebugPrint(("PCI BIOS returned 0x%x as the size of IRQ routing options buffer", routeBuffer.BufferSize));
  55. size = routeBuffer.BufferSize + sizeof(PCI_IRQ_ROUTING_TABLE);
  56. irqRoutingTable = HwAllocateHeap(size, TRUE);
  57. if (irqRoutingTable)
  58. {
  59. routeBuffer.Buffer = (UCHAR far *)irqRoutingTable + sizeof(PCI_IRQ_ROUTING_TABLE);
  60. returnCode = HwGetPciIrqRoutingOptions( &routeBuffer,
  61. &pciIrqMask);
  62. if (returnCode == SUCCESSFUL)
  63. {
  64. irqRoutingTable->Signature = PIRT_SIGNATURE;
  65. irqRoutingTable->TableSize = size;
  66. irqRoutingTable->Version = 0x0100;
  67. }
  68. else
  69. {
  70. HwFreeHeap(size);
  71. irqRoutingTable = NULL;
  72. DebugPrint(("PCI BIOS returned error code 0x%x while getting the PCI IRQ routing table", returnCode));
  73. }
  74. }
  75. else
  76. {
  77. DebugPrint(("Could not allocate %d bytes of memory to read PCI IRQ routing table", size));
  78. }
  79. }
  80. else
  81. {
  82. DebugPrint(("PCI BIOS returned 0 size for PCI IRQ Routint table"));
  83. }
  84. }
  85. else
  86. {
  87. DebugPrint(("PCI BIOS returned error code 0x%x while getting the PCI IRQ routing table size", returnCode));
  88. }
  89. #if DBG
  90. if (irqRoutingTable)
  91. {
  92. BlPrint("*** Real-mode PCI BIOS IRQ Routing Table - BEGIN ***\n\n");
  93. BlPrint("Exclusive PCI IRQ mask = 0x%x\n", pciIrqMask);
  94. BlPrint("----------------------------------------------------------------\n");
  95. BlPrint("Bus Device LnkA Mask LnkB Mask LnkC Mask LnkD Mask Slot\n");
  96. BlPrint("----------------------------------------------------------------\n");
  97. for ( slotInfo = (FPSLOT_INFO)((UCHAR far *)irqRoutingTable + sizeof(PCI_IRQ_ROUTING_TABLE)),
  98. lastSlot = (FPSLOT_INFO)((UCHAR far *)irqRoutingTable + irqRoutingTable->TableSize);
  99. slotInfo < lastSlot;
  100. slotInfo++)
  101. {
  102. BlPrint("0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
  103. slotInfo->BusNumber,
  104. slotInfo->DeviceNumber >> 3,
  105. slotInfo->PinInfo[0].Link, slotInfo->PinInfo[0].InterruptMap,
  106. slotInfo->PinInfo[1].Link, slotInfo->PinInfo[1].InterruptMap,
  107. slotInfo->PinInfo[2].Link, slotInfo->PinInfo[2].InterruptMap,
  108. slotInfo->PinInfo[3].Link, slotInfo->PinInfo[3].InterruptMap,
  109. slotInfo->SlotNumber);
  110. }
  111. BlPrint("\n*** Real-mode PCI BIOS IRQ Routing Table - END ***\n\n");
  112. BlPrint("press any key to continue...\n");
  113. while ( !HwGetKey() ) ; // wait until key pressed to continue
  114. }
  115. #endif
  116. return (irqRoutingTable);
  117. }