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.

163 lines
3.5 KiB

  1. /*
  2. * M1523.C - ALI M1523 PCI chipset routines.
  3. *
  4. * Notes:
  5. * Algorithms from ALI M1523 Data Sheet
  6. *
  7. */
  8. #include "local.h"
  9. LOCAL_DATA const UCHAR IrqToMaskTable[]={ 0x00,0x00,0x00,0x02,
  10. 0x04,0x05,0x07,0x06,
  11. 0x00,0x01,0x03,0x09,
  12. 0x0b,0x00,0x0d, 0x0f};
  13. LOCAL_DATA const UCHAR MaskToIRQTable[]={ 0x00,0x09,0x03,0x0a,
  14. 0x04,0x05,0x07,0x06,
  15. 0x00,0x0b,0x00,0x0c,
  16. 0x00, 0x0e,0x00,0x0f};
  17. /****************************************************************************
  18. *
  19. * M1523SetIRQ - Set a M1523 PCI link to a specific IRQ
  20. *
  21. * Exported.
  22. *
  23. * ENTRY: bIRQNumber is the new IRQ to be used.
  24. *
  25. * bLink is the Link to be set.
  26. *
  27. * EXIT: Standard PCIMP return value.
  28. *
  29. ***************************************************************************/
  30. PCIMPRET CDECL
  31. M1523SetIRQ(UCHAR bIRQNumber, UCHAR bLink)
  32. {
  33. UCHAR bOffset, bOldValue;
  34. //
  35. // Validate link number.
  36. //
  37. if (bLink > 8) {
  38. return(PCIMP_INVALID_LINK);
  39. }
  40. //
  41. // Get the IRQ number from the look-up table.
  42. //
  43. bIRQNumber=IrqToMaskTable[bIRQNumber&0x0f];
  44. //
  45. // Zero based.
  46. //
  47. bLink--;
  48. //
  49. // Set various values.
  50. //
  51. bOffset=(bLink/2)+0x48;
  52. //
  53. // Read the old M1523 IRQ register.
  54. //
  55. bOldValue=ReadConfigUchar(bBusPIC, bDevFuncPIC, bOffset);
  56. if (bLink&1) {
  57. bOldValue&=0x0f;
  58. bOldValue|=(bIRQNumber<<4);
  59. }
  60. else {
  61. bOldValue&=0xf0;
  62. bOldValue|=bIRQNumber;
  63. }
  64. //
  65. // Set the M1523 IRQ register.
  66. //
  67. WriteConfigUchar(bBusPIC, bDevFuncPIC, bOffset, bOldValue);
  68. return(PCIMP_SUCCESS);
  69. }
  70. /****************************************************************************
  71. *
  72. * M1523GetIRQ - Get the IRQ of a M1523 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. M1523GetIRQ(PUCHAR pbIRQNumber, UCHAR bLink)
  85. {
  86. UCHAR bOffset, bOldValue;
  87. //
  88. // Validate link number.
  89. //
  90. if (bLink > 8) {
  91. return(PCIMP_INVALID_LINK);
  92. }
  93. //
  94. // Zero based.
  95. //
  96. bLink--;
  97. //
  98. // Set various values.
  99. //
  100. bOffset=(bLink/2)+0x48;
  101. //
  102. // Read the old M1523 IRQ register.
  103. //
  104. bOldValue=ReadConfigUchar(bBusPIC, bDevFuncPIC, bOffset);
  105. if (bLink&1)
  106. bOldValue>>=4;
  107. *pbIRQNumber=MaskToIRQTable[bOldValue&0x0f];
  108. return(PCIMP_SUCCESS);
  109. }
  110. /****************************************************************************
  111. *
  112. * M1523ValidateTable - Validate an IRQ table
  113. *
  114. * Exported.
  115. *
  116. * ENTRY: piihIRQInfoHeader points to an IRQInfoHeader followed
  117. * by an IRQ Routing Table.
  118. *
  119. * ulFlags are PCIMP_VALIDATE flags.
  120. *
  121. * EXIT: Standard PCIMP return value.
  122. *
  123. ***************************************************************************/
  124. #ifdef ALLOC_PRAGMA
  125. PCIMPRET CDECL
  126. M1523ValidateTable(PIRQINFOHEADER piihIRQInfoHeader, ULONG ulFlags);
  127. #pragma alloc_text(PAGE, M1523ValidateTable)
  128. #endif //ALLOC_PRAGMA
  129. PCIMPRET CDECL
  130. M1523ValidateTable(PIRQINFOHEADER piihIRQInfoHeader, ULONG ulFlags)
  131. {
  132. PAGED_CODE();
  133. //
  134. // If any link is above 8, it is an error.
  135. //
  136. if (GetMaxLink(piihIRQInfoHeader)>8)
  137. return(PCIMP_FAILURE);
  138. return(PCIMP_SUCCESS);
  139. }