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.

153 lines
3.2 KiB

  1. /*
  2. * CPQOSB.C - COMPAQ OSB PCI chipset routines.
  3. *
  4. * Notes:
  5. * Algorithms from COMPAQ OSB Data Sheet
  6. *
  7. */
  8. #include "local.h"
  9. /****************************************************************************
  10. *
  11. * CPQOSBSetIRQ - Set a CPQOSB 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. CPQOSBSetIRQ(UCHAR bIRQNumber, UCHAR bLink)
  24. {
  25. UCHAR bOldValue, bOldIndex;
  26. //
  27. // Validate link number.
  28. //
  29. if (bLink > 4) {
  30. return(PCIMP_INVALID_LINK);
  31. }
  32. //
  33. // Convert link to index.
  34. //
  35. bLink+=3;
  36. //
  37. // Save the old index value.
  38. //
  39. bOldIndex=READ_PORT_UCHAR((PUCHAR)0xC00);
  40. //
  41. // Setup to process the desired link.
  42. //
  43. WRITE_PORT_UCHAR((PUCHAR)0xC00, bLink);
  44. //
  45. // Read the old IRQ value.
  46. //
  47. bOldValue=(UCHAR)(READ_PORT_UCHAR((PUCHAR)0xC01) & 0xf0);
  48. bOldValue|=bIRQNumber;
  49. //
  50. // Set the OSB IRQ register.
  51. //
  52. WRITE_PORT_UCHAR((PUCHAR)0xC01, bOldValue);
  53. //
  54. // Restore the old index value.
  55. //
  56. WRITE_PORT_UCHAR((PUCHAR)0xC00, bOldIndex);
  57. return(PCIMP_SUCCESS);
  58. }
  59. /****************************************************************************
  60. *
  61. * CPQOSBGetIRQ - Get the IRQ of a CPQOSB 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. CPQOSBGetIRQ(PUCHAR pbIRQNumber, UCHAR bLink)
  74. {
  75. UCHAR bOldValue, bOldIndex;
  76. //
  77. // Validate link number.
  78. //
  79. if (bLink > 4) {
  80. return(PCIMP_INVALID_LINK);
  81. }
  82. //
  83. // Convert link to index.
  84. //
  85. bLink+=3;
  86. //
  87. // Save the old index value.
  88. //
  89. bOldIndex=READ_PORT_UCHAR((PUCHAR)0xC00);
  90. //
  91. // Setup to read the correct link.
  92. //
  93. WRITE_PORT_UCHAR((PUCHAR)0xC00, bLink);
  94. bOldValue=READ_PORT_UCHAR((PUCHAR)0xC01);
  95. *pbIRQNumber=bOldValue&0x0f;
  96. //
  97. // Restore the old index value.
  98. //
  99. WRITE_PORT_UCHAR((PUCHAR)0xC00, bOldIndex);
  100. return(PCIMP_SUCCESS);
  101. }
  102. /****************************************************************************
  103. *
  104. * CPQOSBValidateTable - 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. CPQOSBValidateTable(PIRQINFOHEADER piihIRQInfoHeader, ULONG ulFlags);
  119. #pragma alloc_text(PAGE, CPQOSBValidateTable)
  120. #endif //ALLOC_PRAGMA
  121. PCIMPRET CDECL
  122. CPQOSBValidateTable(PIRQINFOHEADER piihIRQInfoHeader, ULONG ulFlags)
  123. {
  124. PAGED_CODE();
  125. //
  126. // If any link is above 4, it is an error.
  127. //
  128. if (GetMaxLink(piihIRQInfoHeader)>4)
  129. return(PCIMP_FAILURE);
  130. return(PCIMP_SUCCESS);
  131. }