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.

145 lines
3.0 KiB

  1. /*
  2. *
  3. * Copyright (c) Microsoft Corporation. All rights reserved.
  4. *
  5. * TRITON.C - Intel Triton PCI chipset routines.
  6. *
  7. * Notes:
  8. * Algorithms from Intel Triton 82430FX PCISET Data Sheet
  9. * (Intel Secret) 82371FB PCI ISA IDE Xcelerator spec.
  10. *
  11. */
  12. #include "local.h"
  13. #ifdef ALLOC_PRAGMA
  14. #pragma alloc_text(INIT, TritonValidateTable)
  15. #endif //ALLOC_PRAGMA
  16. /****************************************************************************
  17. *
  18. * TritonSetIRQ - Set a Triton PCI link to a specific IRQ
  19. *
  20. * Exported.
  21. *
  22. * ENTRY: bIRQNumber is the new IRQ to be used.
  23. *
  24. * bLink is the Link to be set.
  25. *
  26. * EXIT: Standard PCIMP return value.
  27. *
  28. ***************************************************************************/
  29. PCIMPRET CDECL
  30. TritonSetIRQ(UCHAR bIRQNumber, UCHAR bLink)
  31. {
  32. //
  33. // Validate link number.
  34. //
  35. if (bLink < 0x40) {
  36. return(PCIMP_INVALID_LINK);
  37. }
  38. //
  39. // Use 0x80 to disable.
  40. //
  41. if (!bIRQNumber)
  42. bIRQNumber=0x80;
  43. //
  44. // Set the Triton IRQ register.
  45. //
  46. WriteConfigUchar(bBusPIC, bDevFuncPIC, bLink, bIRQNumber);
  47. return(PCIMP_SUCCESS);
  48. }
  49. /****************************************************************************
  50. *
  51. * TritonGetIRQ - Get the IRQ of a Triton PCI link
  52. *
  53. * Exported.
  54. *
  55. * ENTRY: pbIRQNumber is the buffer to fill.
  56. *
  57. * bLink is the Link to be read.
  58. *
  59. * EXIT: Standard PCIMP return value.
  60. *
  61. ***************************************************************************/
  62. PCIMPRET CDECL
  63. TritonGetIRQ(PUCHAR pbIRQNumber, UCHAR bLink)
  64. {
  65. //
  66. // Validate link number.
  67. //
  68. if (bLink < 0x40) {
  69. return(PCIMP_INVALID_LINK);
  70. }
  71. //
  72. // Store the IRQ value.
  73. //
  74. *pbIRQNumber=ReadConfigUchar(bBusPIC, bDevFuncPIC, bLink);
  75. //
  76. // Return 0 if disabled.
  77. //
  78. if (*pbIRQNumber & 0x80)
  79. *pbIRQNumber=0;
  80. return(PCIMP_SUCCESS);
  81. }
  82. /****************************************************************************
  83. *
  84. * TritonValidateTable - Validate an IRQ table
  85. *
  86. * Exported.
  87. *
  88. * ENTRY: piihIRQInfoHeader points to an IRQInfoHeader followed
  89. * by an IRQ Routing Table.
  90. *
  91. * ulFlags are PCIMP_VALIDATE flags.
  92. *
  93. * EXIT: Standard PCIMP return value.
  94. *
  95. ***************************************************************************/
  96. PCIMPRET CDECL
  97. TritonValidateTable(PIRQINFOHEADER piihIRQInfoHeader, ULONG ulFlags)
  98. {
  99. PAGED_CODE();
  100. if ((ulFlags & PCIMP_VALIDATE_SOURCE_BITS)==PCIMP_VALIDATE_SOURCE_PCIBIOS) {
  101. //
  102. // If all links are above 40, we they are config space.
  103. //
  104. if (GetMinLink(piihIRQInfoHeader)>=0x40)
  105. return(PCIMP_SUCCESS);
  106. //
  107. // If there are links above 4, we are clueless.
  108. //
  109. if (GetMaxLink(piihIRQInfoHeader)>0x04)
  110. return(PCIMP_FAILURE);
  111. //
  112. // Assume 1,2,3,4 are the 60,61,62,63 links.
  113. //
  114. NormalizeLinks(piihIRQInfoHeader, 0x5F);
  115. } else {
  116. //
  117. // Validate that all config space addresses are above 40.
  118. //
  119. if (GetMinLink(piihIRQInfoHeader)<0x40)
  120. return(PCIMP_FAILURE);
  121. }
  122. return(PCIMP_SUCCESS);
  123. }