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.

157 lines
3.4 KiB

  1. /*
  2. * MERCURY.C - Intel Mercury PCI chipset routines.
  3. *
  4. * Notes:
  5. * Algorithms from Intel 82420/82430 PCISet EISA Bridge doc,
  6. * 82374EB/SB EISA System Component (ESC) spec.
  7. *
  8. */
  9. #include "local.h"
  10. /****************************************************************************
  11. *
  12. * MercurySetIRQ - Set a Mercury PCI link to a specific IRQ
  13. *
  14. * Exported.
  15. *
  16. * ENTRY: bIRQNumber is the new IRQ to be used.
  17. *
  18. * bLink is the Link to be set.
  19. *
  20. * EXIT: Standard PCIMP return value.
  21. *
  22. ***************************************************************************/
  23. PCIMPRET CDECL
  24. MercurySetIRQ(UCHAR bIRQNumber, UCHAR bLink)
  25. {
  26. //
  27. // Make link number 0 based, and validate.
  28. //
  29. bLink--;
  30. if (bLink > 3) {
  31. return(PCIMP_INVALID_LINK);
  32. }
  33. //
  34. // Use 0x80 to disable.
  35. //
  36. if (!bIRQNumber)
  37. bIRQNumber=0x80;
  38. //
  39. // Start talking to interrupt controller.
  40. //
  41. WRITE_PORT_UCHAR((PUCHAR)0x22, 0x02);
  42. WRITE_PORT_UCHAR((PUCHAR)0x23, 0x0f);
  43. //
  44. // Set our link to the new IRQ.
  45. //
  46. WRITE_PORT_UCHAR((PUCHAR)0x22, (UCHAR)(bLink+0x60));
  47. WRITE_PORT_UCHAR((PUCHAR)0x23, bIRQNumber);
  48. //
  49. // Done talking to interrupt controller.
  50. //
  51. WRITE_PORT_UCHAR((PUCHAR)0x22, 0x02);
  52. WRITE_PORT_UCHAR((PUCHAR)0x23, 0x00);
  53. return(PCIMP_SUCCESS);
  54. }
  55. /****************************************************************************
  56. *
  57. * MercuryGetIRQ - Get the IRQ of a Mercury PCI link
  58. *
  59. * Exported.
  60. *
  61. * ENTRY: pbIRQNumber is the buffer to fill.
  62. *
  63. * bLink is the Link to be read.
  64. *
  65. * EXIT: Standard PCIMP return value.
  66. *
  67. ***************************************************************************/
  68. PCIMPRET CDECL
  69. MercuryGetIRQ(PUCHAR pbIRQNumber, UCHAR bLink)
  70. {
  71. //
  72. // Make link number 0 based, and validate.
  73. //
  74. bLink--;
  75. if (bLink > 3) {
  76. return(PCIMP_INVALID_LINK);
  77. }
  78. //
  79. // Start talking to interrupt controller.
  80. //
  81. WRITE_PORT_UCHAR((PUCHAR)0x22, 0x02);
  82. WRITE_PORT_UCHAR((PUCHAR)0x23, 0x0f);
  83. //
  84. // Get our link's IRQ.
  85. //
  86. WRITE_PORT_UCHAR((PUCHAR)0x22, (UCHAR)(bLink+0x60));
  87. *pbIRQNumber=READ_PORT_UCHAR((PUCHAR)0x23);
  88. //
  89. // Done talking to interrupt controller.
  90. //
  91. WRITE_PORT_UCHAR((PUCHAR)0x22, 0x02);
  92. WRITE_PORT_UCHAR((PUCHAR)0x23, 0x00);
  93. //
  94. // Return 0 if disabled.
  95. //
  96. if (*pbIRQNumber & 0x80)
  97. *pbIRQNumber=0;
  98. return(PCIMP_SUCCESS);
  99. }
  100. /****************************************************************************
  101. *
  102. * MercuryValidateTable - Validate an IRQ table
  103. *
  104. * Exported.
  105. *
  106. * ENTRY: piihIRQInfoHeader points to an IRQInfoHeader followed
  107. * by an IRQ Routing Table.
  108. *
  109. * ulFlags are PCIMP_VALIDATE flags.
  110. *
  111. * EXIT: Standard PCIMP return value.
  112. *
  113. ***************************************************************************/
  114. #ifdef ALLOC_PRAGMA
  115. PCIMPRET CDECL
  116. MercuryValidateTable(PIRQINFOHEADER piihIRQInfoHeader, ULONG ulFlags);
  117. #pragma alloc_text(PAGE, MercuryValidateTable)
  118. #endif //ALLOC_PRAGMA
  119. PCIMPRET CDECL
  120. MercuryValidateTable(PIRQINFOHEADER piihIRQInfoHeader, ULONG ulFlags)
  121. {
  122. UCHAR bMin=GetMinLink(piihIRQInfoHeader);
  123. UCHAR bMax=GetMaxLink(piihIRQInfoHeader);
  124. PAGED_CODE();
  125. if (bMax<=0x04) {
  126. return(PCIMP_SUCCESS);
  127. }
  128. if ((bMin<0x60) || (bMax>0x63)) {
  129. return(PCIMP_FAILURE);
  130. }
  131. NormalizeLinks(piihIRQInfoHeader, (UCHAR)(0-0x5F));
  132. return(PCIMP_SUCCESS);
  133. }