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.

173 lines
3.8 KiB

  1. /*
  2. *
  3. * Copyright (c) Microsoft Corporation. All rights reserved.
  4. *
  5. * M1533.C - ALI M1533 PCI chipset routines.
  6. *
  7. * Notes:
  8. * Algorithms from ALI M1533 Data Sheet
  9. *
  10. */
  11. #include "local.h"
  12. #ifdef ALLOC_DATA_PRAGMA
  13. #pragma data_seg()
  14. #pragma const_seg()
  15. #endif
  16. LOCAL_DATA const UCHAR IrqToMaskTable[]={ 0x00,0x00,0x00,0x02,
  17. 0x04,0x05,0x07,0x06,
  18. 0x00,0x01,0x03,0x09,
  19. 0x0b,0x00,0x0d, 0x0f};
  20. LOCAL_DATA const UCHAR MaskToIRQTable[]={ 0x00,0x09,0x03,0x0a,
  21. 0x04,0x05,0x07,0x06,
  22. 0x00,0x0b,0x00,0x0c,
  23. 0x00, 0x0e,0x00,0x0f};
  24. #ifdef ALLOC_PRAGMA
  25. #pragma alloc_text(INIT, M1533ValidateTable)
  26. #endif //ALLOC_PRAGMA
  27. /****************************************************************************
  28. *
  29. * M1533SetIRQ - Set a M1533 PCI link to a specific IRQ
  30. *
  31. * Exported.
  32. *
  33. * ENTRY: bIRQNumber is the new IRQ to be used.
  34. *
  35. * bLink is the Link to be set.
  36. *
  37. * EXIT: Standard PCIMP return value.
  38. *
  39. ***************************************************************************/
  40. PCIMPRET CDECL
  41. M1533SetIRQ(UCHAR bIRQNumber, UCHAR bLink)
  42. {
  43. UCHAR bOffset, bOldValue;
  44. //
  45. // Validate link number.
  46. //
  47. if (bLink > 8 && bLink != 0x59) {
  48. return(PCIMP_INVALID_LINK);
  49. }
  50. //
  51. // Get the IRQ number from the look-up table.
  52. //
  53. bIRQNumber=IrqToMaskTable[bIRQNumber&0x0f];
  54. //
  55. // Zero based.
  56. //
  57. bLink--;
  58. //
  59. // Set various values.
  60. //
  61. bOffset=(bLink/2)+0x48;
  62. //
  63. // Read the old M1533 IRQ register.
  64. //
  65. bOldValue=ReadConfigUchar(bBusPIC, bDevFuncPIC, bOffset);
  66. if (bLink&1) {
  67. bOldValue&=0x0f;
  68. bOldValue|=(bIRQNumber<<4);
  69. }
  70. else {
  71. bOldValue&=0xf0;
  72. bOldValue|=bIRQNumber;
  73. }
  74. //
  75. // Set the M1533 IRQ register.
  76. //
  77. WriteConfigUchar(bBusPIC, bDevFuncPIC, bOffset, bOldValue);
  78. return(PCIMP_SUCCESS);
  79. }
  80. /****************************************************************************
  81. *
  82. * M1533GetIRQ - Get the IRQ of a M1533 PCI link
  83. *
  84. * Exported.
  85. *
  86. * ENTRY: pbIRQNumber is the buffer to fill.
  87. *
  88. * bLink is the Link to be read.
  89. *
  90. * EXIT: Standard PCIMP return value.
  91. *
  92. ***************************************************************************/
  93. PCIMPRET CDECL
  94. M1533GetIRQ(PUCHAR pbIRQNumber, UCHAR bLink)
  95. {
  96. UCHAR bOffset, bOldValue;
  97. //
  98. // Validate link number.
  99. //
  100. if (bLink > 8 && bLink != 0x59) {
  101. return(PCIMP_INVALID_LINK);
  102. }
  103. //
  104. // Zero based.
  105. //
  106. bLink--;
  107. //
  108. // Set various values.
  109. //
  110. bOffset=(bLink/2)+0x48;
  111. //
  112. // Read the old M1533 IRQ register.
  113. //
  114. bOldValue=ReadConfigUchar(bBusPIC, bDevFuncPIC, bOffset);
  115. if (bLink&1)
  116. bOldValue>>=4;
  117. *pbIRQNumber=MaskToIRQTable[bOldValue&0x0f];
  118. return(PCIMP_SUCCESS);
  119. }
  120. /****************************************************************************
  121. *
  122. * M1533ValidateTable - Validate an IRQ table
  123. *
  124. * Exported.
  125. *
  126. * ENTRY: piihIRQInfoHeader points to an IRQInfoHeader followed
  127. * by an IRQ Routing Table.
  128. *
  129. * ulFlags are PCIMP_VALIDATE flags.
  130. *
  131. * EXIT: Standard PCIMP return value.
  132. *
  133. ***************************************************************************/
  134. PCIMPRET CDECL
  135. M1533ValidateTable(PIRQINFOHEADER piihIRQInfoHeader, ULONG ulFlags)
  136. {
  137. UCHAR bMaxLink = GetMaxLink(piihIRQInfoHeader);
  138. PAGED_CODE();
  139. if (bMaxLink <= 0x08)
  140. return PCIMP_SUCCESS;
  141. if (bMaxLink == 0x59)
  142. return PCIMP_SUCCESS;
  143. return PCIMP_FAILURE;
  144. }