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.

182 lines
4.2 KiB

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