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.

192 lines
4.2 KiB

  1. /*
  2. * NS87560.C - NS NS87560 PCI chipset routines.
  3. *
  4. * Notes:
  5. * Algorithms from National Semiconductor NS87560 Data Sheet
  6. *
  7. */
  8. #include "local.h"
  9. /****************************************************************************
  10. *
  11. * NS87560SetIRQ - Set a NS87560 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. NS87560SetIRQ(UCHAR bIRQNumber, UCHAR bLink)
  24. {
  25. UCHAR bOffset, bOldValue;
  26. //
  27. // Validate link number.
  28. //
  29. if (bLink > 4) {
  30. return(PCIMP_INVALID_LINK);
  31. }
  32. //
  33. // Zero based.
  34. //
  35. bLink--;
  36. //
  37. // Set various values.
  38. //
  39. bOffset=(bLink/2)+0x6C;
  40. //
  41. // Read the old NS87560 IRQ register.
  42. //
  43. bOldValue=ReadConfigUchar(bBusPIC, bDevFuncPIC, bOffset);
  44. if (bLink&1) {
  45. bOldValue&=0x0f;
  46. bOldValue|=(bIRQNumber<<4);
  47. }
  48. else {
  49. bOldValue&=0xf0;
  50. bOldValue|=bIRQNumber;
  51. }
  52. //
  53. // Set the NS87560 IRQ register.
  54. //
  55. WriteConfigUchar(bBusPIC, bDevFuncPIC, bOffset, bOldValue);
  56. return(PCIMP_SUCCESS);
  57. }
  58. /****************************************************************************
  59. *
  60. * NS87560GetIRQ - Get the IRQ of a NS87560 PCI link
  61. *
  62. * Exported.
  63. *
  64. * ENTRY: pbIRQNumber is the buffer to fill.
  65. *
  66. * bLink is the Link to be read.
  67. *
  68. * EXIT: Standard PCIMP return value.
  69. *
  70. ***************************************************************************/
  71. PCIMPRET CDECL
  72. NS87560GetIRQ(PUCHAR pbIRQNumber, UCHAR bLink)
  73. {
  74. UCHAR bOffset, bOldValue;
  75. //
  76. // Validate link number.
  77. //
  78. if (bLink > 4) {
  79. return(PCIMP_INVALID_LINK);
  80. }
  81. //
  82. // Zero based.
  83. //
  84. bLink--;
  85. //
  86. // Set various values.
  87. //
  88. bOffset=(bLink/2)+0x6C;
  89. //
  90. // Read the old NS87560 IRQ register.
  91. //
  92. bOldValue=ReadConfigUchar(bBusPIC, bDevFuncPIC, bOffset);
  93. if (bLink&1)
  94. bOldValue>>=4;
  95. *pbIRQNumber=bOldValue&0x0f;
  96. return(PCIMP_SUCCESS);
  97. }
  98. /****************************************************************************
  99. *
  100. * NS87560SetTrigger - Set the IRQ triggering values for the NS87560
  101. *
  102. * Exported.
  103. *
  104. * ENTRY: ulTrigger has bits set for Level triggered IRQs.
  105. *
  106. * EXIT: Standard PCIMP return value.
  107. *
  108. ***************************************************************************/
  109. PCIMPRET CDECL
  110. NS87560SetTrigger(ULONG ulTrigger)
  111. {
  112. WriteConfigUchar(bBusPIC, bDevFuncPIC, 0x67, (UCHAR)ulTrigger);
  113. WriteConfigUchar(bBusPIC, bDevFuncPIC, 0x68, (UCHAR)(ulTrigger >> 8));
  114. return (PCIMP_SUCCESS);
  115. }
  116. /****************************************************************************
  117. *
  118. * NS87560GetTrigger - Get the IRQ triggering values for the NS87560
  119. *
  120. * Exported.
  121. *
  122. * ENTRY: pulTrigger will have bits set for Level triggered IRQs.
  123. *
  124. * EXIT: Standard PCIMP return value.
  125. *
  126. ***************************************************************************/
  127. PCIMPRET CDECL
  128. NS87560GetTrigger(PULONG pulTrigger)
  129. {
  130. //
  131. // Assume all edge.
  132. //
  133. *pulTrigger = 0;
  134. *pulTrigger |= ReadConfigUchar(bBusPIC, bDevFuncPIC, 0x67);
  135. *pulTrigger |= (ReadConfigUchar(bBusPIC, bDevFuncPIC, 0x68) << 8);
  136. return (PCIMP_SUCCESS);
  137. }
  138. /****************************************************************************
  139. *
  140. * NS87560ValidateTable - Validate an IRQ table
  141. *
  142. * Exported.
  143. *
  144. * ENTRY: piihIRQInfoHeader points to an IRQInfoHeader followed
  145. * by an IRQ Routing Table.
  146. *
  147. * ulFlags are PCIMP_VALIDATE flags.
  148. *
  149. * EXIT: Standard PCIMP return value.
  150. *
  151. ***************************************************************************/
  152. #ifdef ALLOC_PRAGMA
  153. PCIMPRET CDECL
  154. NS87560ValidateTable(PIRQINFOHEADER piihIRQInfoHeader, ULONG ulFlags);
  155. #pragma alloc_text(PAGE, NS87560ValidateTable)
  156. #endif //ALLOC_PRAGMA
  157. PCIMPRET CDECL
  158. NS87560ValidateTable(PIRQINFOHEADER piihIRQInfoHeader, ULONG ulFlags)
  159. {
  160. PAGED_CODE();
  161. //
  162. // If any link is above 4, it is an error.
  163. //
  164. if (GetMaxLink(piihIRQInfoHeader)>4)
  165. return(PCIMP_FAILURE);
  166. return(PCIMP_SUCCESS);
  167. }