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.

160 lines
3.7 KiB

  1. /*
  2. * Comap3.C - Compaq MISC 3 PCI chipset routines.
  3. *
  4. * Notes:
  5. * Algorithms from Compaq MISC 3 Data Sheet
  6. *
  7. */
  8. #include "local.h"
  9. /****************************************************************************
  10. *
  11. * Compaq3SetIRQ - Set a MISC 3 PCI link to a specific IRQ
  12. *
  13. * Exported.
  14. *
  15. * ENTRY: bIRQNumber is the new IRQ to be used.
  16. *
  17. * bLink is the Link to be set.
  18. *
  19. * EXIT: Standard PCIMP return value.
  20. *
  21. ***************************************************************************/
  22. PCIMPRET CDECL
  23. Compaq3SetIRQ(UCHAR bIRQNumber, UCHAR bLink)
  24. {
  25. UCHAR bBus, bDevFunc;
  26. //
  27. // Validate link number.
  28. //
  29. if (bLink >= 10 && bLink <= 12) {
  30. bLink -= 10;
  31. bBus = (UCHAR)bBusPIC;
  32. bDevFunc = (UCHAR)bDevFuncPIC;
  33. }
  34. else if (bLink >= 20 && bLink <= 25) {
  35. bLink -= 20;
  36. bBus = 0;
  37. bDevFunc = 0x78;
  38. }
  39. else {
  40. return(PCIMP_INVALID_LINK);
  41. }
  42. //
  43. // Write to the Interrupt Index Register (offset AE)
  44. //
  45. WriteConfigUchar(bBus, bDevFunc, (UCHAR)0xAE, bLink);
  46. //
  47. // Are we enabling/disabling IRQ?
  48. //
  49. if (bIRQNumber==0)
  50. bIRQNumber|=1; // Disable IRQ.
  51. else
  52. bIRQNumber<<=4; // Enable the specified IRQ.
  53. //
  54. // Write to the interrupt map register.
  55. //
  56. WriteConfigUchar(bBus, bDevFunc, (UCHAR)0xAF, bIRQNumber);
  57. return(PCIMP_SUCCESS);
  58. }
  59. /****************************************************************************
  60. *
  61. * Compaq3GetIRQ - Get the IRQ of a MISC 3 PCI link
  62. *
  63. * Exported.
  64. *
  65. * ENTRY: pbIRQNumber is the buffer to fill.
  66. *
  67. * bLink is the Link to be read.
  68. *
  69. * EXIT: Standard PCIMP return value.
  70. *
  71. ***************************************************************************/
  72. PCIMPRET CDECL
  73. Compaq3GetIRQ(PUCHAR pbIRQNumber, UCHAR bLink)
  74. {
  75. UCHAR bBus, bDevFunc;
  76. //
  77. // Validate link number.
  78. //
  79. if (bLink >= 10 && bLink <= 12) {
  80. bLink-=10;
  81. bBus = (UCHAR)bBusPIC;
  82. bDevFunc = (UCHAR)bDevFuncPIC;
  83. }
  84. else if (bLink >= 20 && bLink <= 25) {
  85. bLink -= 20;
  86. bBus = 0;
  87. bDevFunc = 0x78;
  88. }
  89. else {
  90. return(PCIMP_INVALID_LINK);
  91. }
  92. //
  93. // Write to the Interrupt Index Register.
  94. //
  95. WriteConfigUchar(bBus, bDevFunc, (UCHAR)0xAE, bLink);
  96. //
  97. // Read the old MISC 3 IRQ register.
  98. //
  99. *pbIRQNumber=(ReadConfigUchar(bBus, bDevFunc, (UCHAR)0xAF)>>4);
  100. return(PCIMP_SUCCESS);
  101. }
  102. /****************************************************************************
  103. *
  104. * Compaq3ValidateTable - Validate an IRQ table
  105. *
  106. * Exported.
  107. *
  108. * ENTRY: piihIRQInfoHeader points to an IRQInfoHeader followed
  109. * by an IRQ Routing Table.
  110. *
  111. * ulFlags are PCIMP_VALIDATE flags.
  112. *
  113. * EXIT: Standard PCIMP return value.
  114. *
  115. ***************************************************************************/
  116. #ifdef ALLOC_PRAGMA
  117. PCIMPRET CDECL
  118. Compaq3ValidateTable(PIRQINFOHEADER piihIRQInfoHeader, ULONG ulFlags);
  119. #pragma alloc_text(PAGE, Compaq3ValidateTable)
  120. #endif //ALLOC_PRAGMA
  121. PCIMPRET CDECL
  122. Compaq3ValidateTable(PIRQINFOHEADER piihIRQInfoHeader, ULONG ulFlags)
  123. {
  124. PIRQINFO pii=(PIRQINFO)(((PUCHAR) piihIRQInfoHeader)+sizeof(IRQINFOHEADER));
  125. ULONG i, j;
  126. ULONG cEntries=(piihIRQInfoHeader->TableSize-sizeof(IRQINFOHEADER))/sizeof(IRQINFO);
  127. PAGED_CODE();
  128. for (i=0; i<cEntries; i++) {
  129. for (j=0; j<4; j++) {
  130. if ( pii->PinInfo[j].Link == 0 ||
  131. (pii->PinInfo[j].Link >= 8 && pii->PinInfo[j].Link <= 12) ||
  132. (pii->PinInfo[j].Link >= 20 && pii->PinInfo[j].Link <= 25))
  133. continue;
  134. return PCIMP_FAILURE;
  135. }
  136. pii++;
  137. }
  138. return(i? PCIMP_SUCCESS : PCIMP_FAILURE);
  139. }