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.

179 lines
4.1 KiB

  1. /*
  2. * NEC.C - NEC C98Bus Bridge chipset routines.
  3. *
  4. */
  5. #include "local.h"
  6. /****************************************************************************
  7. *
  8. * NECSetIRQ - Set a Triton PCI link to a specific IRQ
  9. *
  10. * Exported.
  11. *
  12. * ENTRY: bIRQNumber is the new IRQ to be used.
  13. *
  14. * bLink is the Link to be set.
  15. *
  16. * EXIT: Standard PCIMP return value.
  17. *
  18. ***************************************************************************/
  19. PCIMPRET CDECL
  20. NECSetIRQ(UCHAR bIRQNumber, UCHAR bLink)
  21. {
  22. //
  23. // Validate link number.
  24. //
  25. if (bLink < 0x60) {
  26. return(PCIMP_INVALID_LINK);
  27. }
  28. //
  29. // Use 0x80 to disable.
  30. //
  31. if (!bIRQNumber)
  32. bIRQNumber=0x80;
  33. //
  34. // Set the Triton IRQ register.
  35. //
  36. WriteConfigUchar(bBusPIC, bDevFuncPIC, bLink, bIRQNumber);
  37. return(PCIMP_SUCCESS);
  38. }
  39. /****************************************************************************
  40. *
  41. * NECGetIRQ - Get the IRQ of a Triton PCI link
  42. *
  43. * Exported.
  44. *
  45. * ENTRY: pbIRQNumber is the buffer to fill.
  46. *
  47. * bLink is the Link to be read.
  48. *
  49. * EXIT: Standard PCIMP return value.
  50. *
  51. ***************************************************************************/
  52. PCIMPRET CDECL
  53. NECGetIRQ(PUCHAR pbIRQNumber, UCHAR bLink)
  54. {
  55. //
  56. // Validate link number.
  57. //
  58. if (bLink < 0x60) {
  59. return(PCIMP_INVALID_LINK);
  60. }
  61. //
  62. // Store the IRQ value.
  63. //
  64. *pbIRQNumber=ReadConfigUchar(bBusPIC, bDevFuncPIC, bLink);
  65. //
  66. // Return 0 if disabled.
  67. //
  68. if (*pbIRQNumber & 0x80)
  69. *pbIRQNumber=0;
  70. return(PCIMP_SUCCESS);
  71. }
  72. /****************************************************************************
  73. *
  74. * NECSetTrigger - Set the IRQ triggering values for an Intel system.
  75. *
  76. * Exported.
  77. *
  78. * ENTRY: ulTrigger has bits set for Level triggered IRQs.
  79. *
  80. * EXIT: Standard PCIMP return value.
  81. *
  82. ***************************************************************************/
  83. PCIMPRET CDECL
  84. NECSetTrigger(ULONG ulTrigger)
  85. {
  86. // PC-9800 can not handle IRQ trigger.
  87. // we have nothing to do.
  88. return(PCIMP_SUCCESS);
  89. }
  90. /****************************************************************************
  91. *
  92. * NECGetTrigger - Get the IRQ triggering values for an Intel system.
  93. *
  94. * Exported.
  95. *
  96. * ENTRY: pulTrigger will have bits set for Level triggered IRQs.
  97. *
  98. * EXIT: Standard PCIMP return value.
  99. *
  100. ***************************************************************************/
  101. PCIMPRET CDECL
  102. NECGetTrigger(PULONG pulTrigger)
  103. {
  104. // PC-9800 can not handle IRQ trigger.
  105. // We fake IRQ triggering value so that PCI.VXD works fine.
  106. *pulTrigger = 0xffff;
  107. return(PCIMP_SUCCESS);
  108. }
  109. /****************************************************************************
  110. *
  111. * NECValidateTable - Validate an IRQ table
  112. *
  113. * Exported.
  114. *
  115. * ENTRY: piihIRQInfoHeader points to an IRQInfoHeader followed
  116. * by an IRQ Routing Table.
  117. *
  118. * ulFlags are PCIMP_VALIDATE flags.
  119. *
  120. * EXIT: Standard PCIMP return value.
  121. *
  122. ***************************************************************************/
  123. #ifdef ALLOC_PRAGMA
  124. PCIMPRET CDECL
  125. NECValidateTable(PIRQINFOHEADER piihIRQInfoHeader, ULONG ulFlags);
  126. #pragma alloc_text(PAGE, NECValidateTable)
  127. #endif //ALLOC_PRAGMA
  128. PCIMPRET CDECL
  129. NECValidateTable(PIRQINFOHEADER piihIRQInfoHeader, ULONG ulFlags)
  130. {
  131. PAGED_CODE();
  132. if ((ulFlags & PCIMP_VALIDATE_SOURCE_BITS)==PCIMP_VALIDATE_SOURCE_PCIBIOS) {
  133. //
  134. // If all links are above 60, we they are config space.
  135. //
  136. if (GetMinLink(piihIRQInfoHeader)>=0x60)
  137. return(PCIMP_SUCCESS);
  138. //
  139. // If there are links above 4, we are clueless.
  140. //
  141. if (GetMaxLink(piihIRQInfoHeader)>0x04)
  142. return(PCIMP_FAILURE);
  143. //
  144. // Assume 1,2,3,4 are the 60,61,62,63 links.
  145. //
  146. NormalizeLinks(piihIRQInfoHeader, 0x5F);
  147. } else {
  148. //
  149. // Validate that all config space addresses are above 60.
  150. //
  151. if (GetMinLink(piihIRQInfoHeader)<0x60)
  152. return(PCIMP_FAILURE);
  153. }
  154. return(PCIMP_SUCCESS);
  155. }