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.

120 lines
2.8 KiB

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