Leaked source code of windows server 2003
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.

162 lines
3.5 KiB

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