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.

194 lines
4.4 KiB

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