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.4 KiB

  1. /*
  2. * VT586.C - VIA Technologies PCI chipset routines.
  3. *
  4. * Notes:
  5. * Algorithms from VIATECH 82C586B Data Sheet
  6. * Compaq contact:
  7. *
  8. */
  9. #include "local.h"
  10. /****************************************************************************
  11. *
  12. * VT586SetIRQ - Set a VIATECH 82C586B 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. VT586SetIRQ(UCHAR bIRQNumber, UCHAR bLink)
  25. {
  26. UCHAR bOffset, bOldValue;
  27. switch (bLink)
  28. {
  29. case 1: case 2:
  30. case 3: case 5:
  31. break;
  32. default:
  33. return (PCIMP_INVALID_LINK);
  34. }
  35. //
  36. // Compute the offset in config space.
  37. //
  38. bOffset=(bLink/2)+0x55;
  39. //
  40. // Read the old VT82C586 IRQ register.
  41. //
  42. bOldValue=ReadConfigUchar(bBusPIC, bDevFuncPIC, bOffset);
  43. if (bLink&1) {
  44. bOldValue&=0x0f;
  45. bOldValue|=(bIRQNumber<<4);
  46. }
  47. else {
  48. bOldValue&=0xf0;
  49. bOldValue|=bIRQNumber;
  50. }
  51. //
  52. // Set the VT82C586B IRQ register.
  53. //
  54. WriteConfigUchar(bBusPIC, bDevFuncPIC, bOffset, bOldValue);
  55. return(PCIMP_SUCCESS);
  56. }
  57. /****************************************************************************
  58. *
  59. * VT586GetIRQ - Get the IRQ of a VIATECH 82C586B PCI link
  60. *
  61. * Exported.
  62. *
  63. * ENTRY: pbIRQNumber is the buffer to fill.
  64. *
  65. * bLink is the Link to be read.
  66. *
  67. * EXIT: Standard PCIMP return value.
  68. *
  69. ***************************************************************************/
  70. PCIMPRET CDECL
  71. VT586GetIRQ(PUCHAR pbIRQNumber, UCHAR bLink)
  72. {
  73. UCHAR bOffset, bOldValue;
  74. switch (bLink)
  75. {
  76. case 1: case 2:
  77. case 3: case 5:
  78. break;
  79. default:
  80. return (PCIMP_INVALID_LINK);
  81. }
  82. //
  83. // Set various values.
  84. //
  85. bOffset=(bLink/2)+0x55;
  86. //
  87. // Read the old VT82C586 IRQ register.
  88. //
  89. bOldValue=ReadConfigUchar(bBusPIC, bDevFuncPIC, bOffset);
  90. if (bLink&1)
  91. bOldValue>>=4;
  92. *pbIRQNumber=bOldValue&0x0f;
  93. return(PCIMP_SUCCESS);
  94. }
  95. /****************************************************************************
  96. *
  97. * VT586ValidateTable - Validate an IRQ table
  98. *
  99. * Exported.
  100. *
  101. * ENTRY: piihIRQInfoHeader points to an IRQInfoHeader followed
  102. * by an IRQ Routing Table.
  103. *
  104. * ulFlags are PCIMP_VALIDATE flags.
  105. *
  106. * EXIT: Standard PCIMP return value.
  107. *
  108. ***************************************************************************/
  109. #ifdef ALLOC_PRAGMA
  110. PCIMPRET CDECL
  111. VT586ValidateTable(PIRQINFOHEADER piihIRQInfoHeader, ULONG ulFlags);
  112. #pragma alloc_text(PAGE, VT586ValidateTable)
  113. #endif //ALLOC_PRAGMA
  114. PCIMPRET CDECL
  115. VT586ValidateTable(PIRQINFOHEADER piihIRQInfoHeader, ULONG ulFlags)
  116. {
  117. PIRQINFO pii=(PIRQINFO)(((PUCHAR) piihIRQInfoHeader)+sizeof(IRQINFOHEADER));
  118. ULONG i, j;
  119. ULONG cEntries=(piihIRQInfoHeader->TableSize-sizeof(IRQINFOHEADER))/sizeof(IRQINFO);
  120. PAGED_CODE();
  121. for (i=0; i<cEntries; i++, pii++) {
  122. for (j=0; j<4; j++) {
  123. if (pii->PinInfo[j].Link<=3 || pii->PinInfo[j].Link==5)
  124. continue;
  125. return (PCIMP_FAILURE);
  126. }
  127. }
  128. return(i? PCIMP_SUCCESS : PCIMP_FAILURE);
  129. }