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.

214 lines
4.7 KiB

  1. /*
  2. * TOSHIBA.C - Toshiba Tecra IRQ routing spec
  3. *
  4. * Notes:
  5. * Algorithms from TECS-1010-1001
  6. *
  7. */
  8. #include "local.h"
  9. GLOBAL_DATA ULONG SMIPort=0xB2;
  10. /****************************************************************************
  11. *
  12. * CallSMI - Get into SMI
  13. *
  14. * Not exported.
  15. *
  16. * ENTRY: rAX is the value for AX as input.
  17. *
  18. * rBX is the value for BX as input.
  19. *
  20. * rCX is the value for CX as input.
  21. *
  22. * prCX is filled with the returned CX, if not NULL.
  23. *
  24. * EXIT: TRUE iff no error.
  25. *
  26. ***************************************************************************/
  27. BOOLEAN CDECL
  28. CallSMI(ULONG rAX, ULONG rBX, ULONG rCX, PULONG prCX)
  29. {
  30. ULONG ulAX, ulCX;
  31. _asm mov eax, rAX
  32. _asm mov ebx, rBX
  33. _asm mov ecx, rCX
  34. _asm mov edx, SMIPort
  35. _asm in al, dx
  36. _asm movzx ecx, cx
  37. _asm mov ulCX, ecx
  38. _asm movzx eax, ah
  39. _asm mov ulAX, eax
  40. if (prCX)
  41. *prCX=ulCX;
  42. return(ulAX==0);
  43. }
  44. /****************************************************************************
  45. *
  46. * ToshibaSetIRQ - Set a Toshiba PCI link to a specific IRQ
  47. *
  48. * Exported.
  49. *
  50. * ENTRY: bIRQNumber is the new IRQ to be used.
  51. *
  52. * bLink is the Link to be set.
  53. *
  54. * EXIT: Standard PCIMP return value.
  55. *
  56. ***************************************************************************/
  57. PCIMPRET CDECL
  58. ToshibaSetIRQ(UCHAR bIRQNumber, UCHAR bLink)
  59. {
  60. //
  61. // Use 0xFF to disable.
  62. //
  63. if (!bIRQNumber)
  64. bIRQNumber=0xFF;
  65. //
  66. // Ask SMI to set the link.
  67. //
  68. return(CallSMI( 0xFF44,
  69. 0x0701,
  70. (bLink<<8)+bIRQNumber,
  71. NULL) ?
  72. PCIMP_SUCCESS :
  73. PCIMP_FAILURE);
  74. }
  75. /****************************************************************************
  76. *
  77. * ToshibaGetIRQ - Get the IRQ of a Toshiba PCI link
  78. *
  79. * Exported.
  80. *
  81. * ENTRY: pbIRQNumber is the buffer to fill.
  82. *
  83. * bLink is the Link to be read.
  84. *
  85. * EXIT: Standard PCIMP return value.
  86. *
  87. ***************************************************************************/
  88. PCIMPRET CDECL
  89. ToshibaGetIRQ(PUCHAR pbIRQNumber, UCHAR bLink)
  90. {
  91. ULONG ulCX;
  92. //
  93. // Ask SMI to get the link.
  94. //
  95. if (!CallSMI( 0xFE44,
  96. 0x0701,
  97. bLink<<8,
  98. &ulCX))
  99. return(PCIMP_FAILURE);
  100. //
  101. // Get the byte only.
  102. //
  103. ulCX&=0xFF;
  104. //
  105. // Use 0xFF to disable.
  106. //
  107. if (ulCX==0xFF)
  108. ulCX=0;
  109. //
  110. // Store the IRQ value.
  111. //
  112. *pbIRQNumber=(UCHAR)ulCX;
  113. return(PCIMP_SUCCESS);
  114. }
  115. /****************************************************************************
  116. *
  117. * ToshibaSetTrigger - Set the IRQ triggering values for the Toshiba
  118. *
  119. * Exported.
  120. *
  121. * ENTRY: ulTrigger has bits set for Level triggered IRQs.
  122. *
  123. * EXIT: Standard PCIMP return value.
  124. *
  125. ***************************************************************************/
  126. PCIMPRET CDECL
  127. ToshibaSetTrigger(ULONG ulTrigger)
  128. {
  129. //
  130. // Ask SMI to set the triggering mechanism.
  131. //
  132. return(CallSMI( 0xFF44,
  133. 0x0702,
  134. ulTrigger,
  135. NULL) ?
  136. PCIMP_SUCCESS :
  137. PCIMP_FAILURE);
  138. }
  139. /****************************************************************************
  140. *
  141. * ToshibaGetTrigger - Get the IRQ triggering values for the Toshiba
  142. *
  143. * Exported.
  144. *
  145. * ENTRY: pulTrigger will have bits set for Level triggered IRQs.
  146. *
  147. * EXIT: Standard PCIMP return value.
  148. *
  149. ***************************************************************************/
  150. PCIMPRET CDECL
  151. ToshibaGetTrigger(PULONG pulTrigger)
  152. {
  153. //
  154. // Assume all edge.
  155. //
  156. *pulTrigger = 0;
  157. //
  158. // Ask SMI to get the triggering mechanism.
  159. //
  160. return(CallSMI( 0xFE44,
  161. 0x0702,
  162. 0,
  163. pulTrigger) ?
  164. PCIMP_SUCCESS :
  165. PCIMP_FAILURE);
  166. }
  167. /****************************************************************************
  168. *
  169. * ToshibaValidateTable - Validate an IRQ table
  170. *
  171. * Exported.
  172. *
  173. * ENTRY: piihIRQInfoHeader points to an IRQInfoHeader followed
  174. * by an IRQ Routing Table.
  175. *
  176. * ulFlags are PCIMP_VALIDATE flags.
  177. *
  178. * EXIT: Standard PCIMP return value.
  179. *
  180. ***************************************************************************/
  181. #ifdef ALLOC_PRAGMA
  182. PCIMPRET CDECL
  183. ToshibaValidateTable(PIRQINFOHEADER piihIRQInfoHeader, ULONG ulFlags);
  184. #pragma alloc_text(PAGE, ToshibaValidateTable)
  185. #endif //ALLOC_PRAGMA
  186. PCIMPRET CDECL
  187. ToshibaValidateTable(PIRQINFOHEADER piihIRQInfoHeader, ULONG ulFlags)
  188. {
  189. PAGED_CODE();
  190. SMIPort=*(((PUSHORT)&(piihIRQInfoHeader->MiniportData))+1);
  191. return(((ulFlags & PCIMP_VALIDATE_SOURCE_BITS)==PCIMP_VALIDATE_SOURCE_PCIBIOS) ?
  192. PCIMP_FAILURE : PCIMP_SUCCESS);
  193. }