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.

148 lines
3.3 KiB

  1. /*
  2. * SIS5503.C - SiS5503 PCI System I/O chipset routines
  3. *
  4. * Notes:
  5. * Algorithms from SiS Pentium/P54C PCI/ISA Chipset databook.
  6. *
  7. */
  8. #include "local.h"
  9. /****************************************************************************
  10. *
  11. * SiS5503SetIRQ - Set an SiS 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. SiS5503SetIRQ(UCHAR bIRQNumber, UCHAR bLink)
  24. {
  25. UCHAR bRegValue;
  26. //
  27. // Validate link number.
  28. //
  29. if (bLink < 0x40) {
  30. return(PCIMP_INVALID_LINK);
  31. }
  32. //
  33. // Use 0x80 to disable.
  34. //
  35. if (!bIRQNumber)
  36. bIRQNumber=0x80;
  37. //
  38. // Preserve other bits.
  39. //
  40. bRegValue= (ReadConfigUchar(bBusPIC, bDevFuncPIC, bLink)&(~0x8F))|(bIRQNumber&0x0F);
  41. //
  42. // Set the SiS IRQ register.
  43. //
  44. WriteConfigUchar(bBusPIC, bDevFuncPIC, bLink, bRegValue);
  45. return(PCIMP_SUCCESS);
  46. }
  47. /****************************************************************************
  48. *
  49. * SiS5503GetIRQ - Get the IRQ of an SiS5503 PCI link
  50. *
  51. * Exported.
  52. *
  53. * ENTRY: pbIRQNumber is the buffer to fill.
  54. *
  55. * bLink is the Link to be read.
  56. *
  57. * EXIT: Standard PCIMP return value.
  58. *
  59. ***************************************************************************/
  60. PCIMPRET CDECL
  61. SiS5503GetIRQ(PUCHAR pbIRQNumber, UCHAR bLink)
  62. {
  63. //
  64. // Validate link number.
  65. //
  66. if (bLink < 0x40) {
  67. return(PCIMP_INVALID_LINK);
  68. }
  69. //
  70. // Store the IRQ value.
  71. //
  72. *pbIRQNumber=(ReadConfigUchar(bBusPIC, bDevFuncPIC, bLink)&0x8F);
  73. //
  74. // Return 0 if disabled.
  75. //
  76. if (*pbIRQNumber & 0x80)
  77. *pbIRQNumber=0;
  78. return(PCIMP_SUCCESS);
  79. }
  80. /****************************************************************************
  81. *
  82. * Sis5503ValidateTable - Validate an IRQ table
  83. *
  84. * Exported.
  85. *
  86. * ENTRY: piihIRQInfoHeader points to an IRQInfoHeader followed
  87. * by an IRQ Routing Table.
  88. *
  89. * ulFlags are PCIMP_VALIDATE flags.
  90. *
  91. * EXIT: Standard PCIMP return value.
  92. *
  93. ***************************************************************************/
  94. #ifdef ALLOC_PRAGMA
  95. PCIMPRET CDECL
  96. SiS5503ValidateTable(PIRQINFOHEADER piihIRQInfoHeader, ULONG ulFlags);
  97. #pragma alloc_text(PAGE, SiS5503ValidateTable)
  98. #endif //ALLOC_PRAGMA
  99. PCIMPRET CDECL
  100. SiS5503ValidateTable(PIRQINFOHEADER piihIRQInfoHeader, ULONG ulFlags)
  101. {
  102. PAGED_CODE();
  103. if ((ulFlags & PCIMP_VALIDATE_SOURCE_BITS)==PCIMP_VALIDATE_SOURCE_PCIBIOS) {
  104. //
  105. // If all links are above 40, we they are config space.
  106. //
  107. if (GetMinLink(piihIRQInfoHeader)>=0x40)
  108. return(PCIMP_SUCCESS);
  109. //
  110. // If there are links above 4, we are clueless.
  111. //
  112. if (GetMaxLink(piihIRQInfoHeader)>0x04)
  113. return(PCIMP_FAILURE);
  114. //
  115. // Assume 1,2,3,4 are the 41,42,43,44 links.
  116. //
  117. NormalizeLinks(piihIRQInfoHeader, 0x40);
  118. } else {
  119. //
  120. // Validate that all config space addresses are above 40.
  121. //
  122. if (GetMinLink(piihIRQInfoHeader)<0x40)
  123. return(PCIMP_FAILURE);
  124. }
  125. return(PCIMP_SUCCESS);
  126. }