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.

156 lines
3.3 KiB

  1. /*
  2. *
  3. * Copyright (c) Microsoft Corporation. All rights reserved.
  4. *
  5. * CPQOSB.C - COMPAQ OSB PCI chipset routines.
  6. *
  7. * Notes:
  8. * Algorithms from COMPAQ OSB Data Sheet
  9. *
  10. */
  11. #include "local.h"
  12. #ifdef ALLOC_PRAGMA
  13. #pragma alloc_text(INIT, CPQOSBValidateTable)
  14. #endif //ALLOC_PRAGMA
  15. /****************************************************************************
  16. *
  17. * CPQOSBSetIRQ - Set a CPQOSB 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. CPQOSBSetIRQ(UCHAR bIRQNumber, UCHAR bLink)
  30. {
  31. UCHAR bOldValue, bOldIndex;
  32. //
  33. // Validate link number.
  34. //
  35. if (bLink > 4) {
  36. return(PCIMP_INVALID_LINK);
  37. }
  38. //
  39. // Convert link to index.
  40. //
  41. bLink+=3;
  42. //
  43. // Save the old index value.
  44. //
  45. bOldIndex=READ_PORT_UCHAR((PUCHAR)0xC00);
  46. //
  47. // Setup to process the desired link.
  48. //
  49. WRITE_PORT_UCHAR((PUCHAR)0xC00, bLink);
  50. //
  51. // Read the old IRQ value.
  52. //
  53. bOldValue=(UCHAR)(READ_PORT_UCHAR((PUCHAR)0xC01) & 0xf0);
  54. bOldValue|=bIRQNumber;
  55. //
  56. // Set the OSB IRQ register.
  57. //
  58. WRITE_PORT_UCHAR((PUCHAR)0xC01, bOldValue);
  59. //
  60. // Restore the old index value.
  61. //
  62. WRITE_PORT_UCHAR((PUCHAR)0xC00, bOldIndex);
  63. return(PCIMP_SUCCESS);
  64. }
  65. /****************************************************************************
  66. *
  67. * CPQOSBGetIRQ - Get the IRQ of a CPQOSB PCI link
  68. *
  69. * Exported.
  70. *
  71. * ENTRY: pbIRQNumber is the buffer to fill.
  72. *
  73. * bLink is the Link to be read.
  74. *
  75. * EXIT: Standard PCIMP return value.
  76. *
  77. ***************************************************************************/
  78. PCIMPRET CDECL
  79. CPQOSBGetIRQ(PUCHAR pbIRQNumber, UCHAR bLink)
  80. {
  81. UCHAR bOldValue, bOldIndex;
  82. //
  83. // Validate link number.
  84. //
  85. if (bLink > 4) {
  86. return(PCIMP_INVALID_LINK);
  87. }
  88. //
  89. // Convert link to index.
  90. //
  91. bLink+=3;
  92. //
  93. // Save the old index value.
  94. //
  95. bOldIndex=READ_PORT_UCHAR((PUCHAR)0xC00);
  96. //
  97. // Setup to read the correct link.
  98. //
  99. WRITE_PORT_UCHAR((PUCHAR)0xC00, bLink);
  100. bOldValue=READ_PORT_UCHAR((PUCHAR)0xC01);
  101. *pbIRQNumber=bOldValue&0x0f;
  102. //
  103. // Restore the old index value.
  104. //
  105. WRITE_PORT_UCHAR((PUCHAR)0xC00, bOldIndex);
  106. return(PCIMP_SUCCESS);
  107. }
  108. /****************************************************************************
  109. *
  110. * CPQOSBValidateTable - Validate an IRQ table
  111. *
  112. * Exported.
  113. *
  114. * ENTRY: piihIRQInfoHeader points to an IRQInfoHeader followed
  115. * by an IRQ Routing Table.
  116. *
  117. * ulFlags are PCIMP_VALIDATE flags.
  118. *
  119. * EXIT: Standard PCIMP return value.
  120. *
  121. ***************************************************************************/
  122. PCIMPRET CDECL
  123. CPQOSBValidateTable(PIRQINFOHEADER piihIRQInfoHeader, ULONG ulFlags)
  124. {
  125. PAGED_CODE();
  126. //
  127. // If any link is above 4, it is an error.
  128. //
  129. if (GetMaxLink(piihIRQInfoHeader)>4)
  130. return(PCIMP_FAILURE);
  131. return(PCIMP_SUCCESS);
  132. }