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.

155 lines
3.3 KiB

  1. /*
  2. * CPQ1000.C - COMPAQ 1000 PCI chipset routines.
  3. *
  4. * Notes:
  5. * Algorithms from COMPAQ 1000 Data Sheet
  6. *
  7. */
  8. #include "local.h"
  9. const UCHAR LinkToIndex[]={0, 1, 6, 7, 4, 5};
  10. /****************************************************************************
  11. *
  12. * CPQ1000SetIRQ - Set a CPQ1000 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. CPQ1000SetIRQ(UCHAR bIRQNumber, UCHAR bLink)
  25. {
  26. UCHAR bOldValue, bOldIndex, bIndex;
  27. //
  28. // Validate link number.
  29. //
  30. if (bLink > 6) {
  31. return(PCIMP_INVALID_LINK);
  32. }
  33. //
  34. // Get the index from the link.
  35. //
  36. bIndex=LinkToIndex[bLink-1];
  37. //
  38. // Save the old index value.
  39. //
  40. bOldIndex=READ_PORT_UCHAR((PUCHAR)0xC00);
  41. //
  42. // Setup to process the desired link.
  43. //
  44. WRITE_PORT_UCHAR((PUCHAR)0xC00, bIndex);
  45. //
  46. // Read the old IRQ value.
  47. //
  48. bOldValue=(UCHAR)(READ_PORT_UCHAR((PUCHAR)0xC01) & 0x0f);
  49. bOldValue|=(bIRQNumber<<4);
  50. //
  51. // Set the VESUVIUS IRQ register.
  52. //
  53. WRITE_PORT_UCHAR((PUCHAR)0xC01, bOldValue);
  54. //
  55. // Restore the old index value.
  56. //
  57. WRITE_PORT_UCHAR((PUCHAR)0xC00, bOldIndex);
  58. return(PCIMP_SUCCESS);
  59. }
  60. /****************************************************************************
  61. *
  62. * CPQ1000GetIRQ - Get the IRQ of a CPQ1000 PCI link
  63. *
  64. * Exported.
  65. *
  66. * ENTRY: pbIRQNumber is the buffer to fill.
  67. *
  68. * bLink is the Link to be read.
  69. *
  70. * EXIT: Standard PCIMP return value.
  71. *
  72. ***************************************************************************/
  73. PCIMPRET CDECL
  74. CPQ1000GetIRQ(PUCHAR pbIRQNumber, UCHAR bLink)
  75. {
  76. UCHAR bOldValue, bOldIndex, bIndex;
  77. //
  78. // Validate link number.
  79. //
  80. if (bLink > 6) {
  81. return(PCIMP_INVALID_LINK);
  82. }
  83. //
  84. // Get the index from the link.
  85. //
  86. bIndex=LinkToIndex[bLink-1];
  87. //
  88. // Save the old index value.
  89. //
  90. bOldIndex=READ_PORT_UCHAR((PUCHAR)0xC00);
  91. //
  92. // Setup to read the correct link.
  93. //
  94. WRITE_PORT_UCHAR((PUCHAR)0xC00, bIndex);
  95. bOldValue=READ_PORT_UCHAR((PUCHAR)0xC01);
  96. *pbIRQNumber=(bOldValue>>4);
  97. //
  98. // Restore the old index value.
  99. //
  100. WRITE_PORT_UCHAR((PUCHAR)0xC00, bOldIndex);
  101. return(PCIMP_SUCCESS);
  102. }
  103. /****************************************************************************
  104. *
  105. * CPQ1000ValidateTable - Validate an IRQ table
  106. *
  107. * Exported.
  108. *
  109. * ENTRY: piihIRQInfoHeader points to an IRQInfoHeader followed
  110. * by an IRQ Routing Table.
  111. *
  112. * ulFlags are PCIMP_VALIDATE flags.
  113. *
  114. * EXIT: Standard PCIMP return value.
  115. *
  116. ***************************************************************************/
  117. #ifdef ALLOC_PRAGMA
  118. PCIMPRET CDECL
  119. CPQ1000ValidateTable(PIRQINFOHEADER piihIRQInfoHeader, ULONG ulFlags);
  120. #pragma alloc_text(PAGE, CPQ1000ValidateTable)
  121. #endif //ALLOC_PRAGMA
  122. PCIMPRET CDECL
  123. CPQ1000ValidateTable(PIRQINFOHEADER piihIRQInfoHeader, ULONG ulFlags)
  124. {
  125. PAGED_CODE();
  126. //
  127. // If any link is above 6, it is an error.
  128. //
  129. if (GetMaxLink(piihIRQInfoHeader)>6)
  130. return(PCIMP_FAILURE);
  131. return(PCIMP_SUCCESS);
  132. }