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.

117 lines
2.7 KiB

  1. /*
  2. * Cx5520.C - Cyrix Cx5520 PCI chipset routines.
  3. *
  4. * Notes:
  5. * Algorithms from Cyrix Cx5520 Data Sheet
  6. *
  7. */
  8. #include "local.h"
  9. /****************************************************************************
  10. *
  11. * Cx5520SetIRQ - Set a Cx5520 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. Cx5520SetIRQ(UCHAR bIRQNumber, UCHAR bLink)
  24. {
  25. UCHAR bOldValue, bNewValue, bOffset;
  26. //
  27. // Validate link number.
  28. //
  29. if (bLink > 4)
  30. return(PCIMP_INVALID_LINK);
  31. bOffset = (UCHAR)(((bLink - 1) / 2) + 0x5C);
  32. bOldValue = ReadConfigUchar(bBusPIC, bDevFuncPIC, bOffset);
  33. if (bLink & 1)
  34. {
  35. bNewValue = (UCHAR)((bOldValue & 0xF0) | (bIRQNumber & 0x0F));
  36. }
  37. else
  38. {
  39. bNewValue = (UCHAR)((bOldValue & 0x0F) | (bIRQNumber << 4));
  40. }
  41. WriteConfigUchar(bBusPIC, bDevFuncPIC, bOffset, bNewValue);
  42. return(PCIMP_SUCCESS);
  43. }
  44. /****************************************************************************
  45. *
  46. * Cx5520GetIRQ - Get the IRQ of a Cx5520 PCI link
  47. *
  48. * Exported.
  49. *
  50. * ENTRY: pbIRQNumber is the buffer to fill.
  51. *
  52. * bLink is the Link to be read.
  53. *
  54. * EXIT: Standard PCIMP return value.
  55. *
  56. ***************************************************************************/
  57. PCIMPRET CDECL
  58. Cx5520GetIRQ(PUCHAR pbIRQNumber, UCHAR bLink)
  59. {
  60. UCHAR bOldValue, bOffset;
  61. //
  62. // Validate link number.
  63. //
  64. if (bLink > 4)
  65. return(PCIMP_INVALID_LINK);
  66. bOffset = (UCHAR)(((bLink - 1) / 2) + 0x5C);
  67. bOldValue = ReadConfigUchar(bBusPIC, bDevFuncPIC, bOffset);
  68. if (!(bLink & 1))
  69. {
  70. bOldValue >>= 4;
  71. }
  72. *pbIRQNumber = (UCHAR)(bOldValue & 0x0F);
  73. return(PCIMP_SUCCESS);
  74. }
  75. /****************************************************************************
  76. *
  77. * Cx5520ValidateTable - Validate an IRQ table
  78. *
  79. * Exported.
  80. *
  81. * ENTRY: piihIRQInfoHeader points to an IRQInfoHeader followed
  82. * by an IRQ Routing Table.
  83. *
  84. * ulFlags are PCIMP_VALIDATE flags.
  85. *
  86. * EXIT: Standard PCIMP return value.
  87. *
  88. ***************************************************************************/
  89. #ifdef ALLOC_PRAGMA
  90. PCIMPRET CDECL
  91. Cx5520ValidateTable(PIRQINFOHEADER piihIRQInfoHeader, ULONG ulFlags);
  92. #pragma alloc_text(PAGE, Cx5520ValidateTable)
  93. #endif //ALLOC_PRAGMA
  94. PCIMPRET CDECL
  95. Cx5520ValidateTable(PIRQINFOHEADER piihIRQInfoHeader, ULONG ulFlags)
  96. {
  97. PAGED_CODE();
  98. return ((GetMaxLink(piihIRQInfoHeader) > 4)? PCIMP_FAILURE : PCIMP_SUCCESS);
  99. }