Windows NT 4.0 source code leak
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.

298 lines
7.0 KiB

4 years ago
  1. // ----------------------------------------------------------------------------
  2. // Copyright (c) 1992 Olivetti
  3. //
  4. // File: eisaintr.c
  5. //
  6. // Description: EISA code interrupt related routines
  7. // ----------------------------------------------------------------------------
  8. //
  9. #include "fwp.h"
  10. #include "oli2msft.h"
  11. #include "arceisa.h"
  12. #include "inc.h"
  13. #include "string.h"
  14. #include "debug.h"
  15. extern EISA_BUS_INFO EisaBusInfo[];
  16. // ----------------------------------------------------------------------------
  17. // Declare Function Prototypes
  18. // ----------------------------------------------------------------------------
  19. VOID
  20. EisaBeginCriticalSection
  21. (
  22. IN VOID
  23. );
  24. VOID
  25. EisaEndCriticalSection
  26. (
  27. IN VOID
  28. );
  29. ARC_STATUS
  30. EisaProcessEndOfInterrupt
  31. (
  32. IN ULONG BusNumber,
  33. IN USHORT Irq
  34. );
  35. BOOLEAN_ULONG
  36. EisaTestEisaInterrupt
  37. (
  38. IN ULONG BusNumber,
  39. IN USHORT Irq
  40. );
  41. // ----------------------------------------------------------------------------
  42. // General Function Prototypes
  43. // ----------------------------------------------------------------------------
  44. ULONG
  45. StatusReg
  46. (
  47. IN ULONG,
  48. IN ULONG
  49. );
  50. // ----------------------------------------------------------------------------
  51. // General : Begin/End Critical Setction functions
  52. // ----------------------------------------------------------------------------
  53. ULONG NestedCounter = 0 ; // nested conter;
  54. ULONG StatusRegBuff = 0 ; // used to store the old ints status
  55. // bits 31-16 Reserved (0)
  56. // bits 15- 8 Specific interrupt mask
  57. // bits 7- 1 Reserved (0)
  58. // bit 0 General Interrupt mask
  59. // ----------------------------------------------------------------------------
  60. // PROCEDURE: EisaBeginCriticalSection:
  61. //
  62. // DESCRIPTION: This function disables all the hardware interrupts
  63. // except for the EISA NMI interrupt. The old interrupt
  64. // status is saved for "EisaEndCriticalSection" routine.
  65. //
  66. // ARGUMENTS: none
  67. //
  68. // RETURN: none
  69. //
  70. // ASSUMPTIONS:
  71. //
  72. // CALLS:
  73. //
  74. // GLOBALS:
  75. //
  76. // NOTES:
  77. // ----------------------------------------------------------------------------
  78. //
  79. VOID
  80. EisaBeginCriticalSection
  81. (
  82. IN VOID
  83. )
  84. {
  85. // Disable interrupts (except for the EISA NMI) and save the old interrupt
  86. // status only if no previous calls to this routine were made.
  87. // The first argument is "&" and the second is "|" with the status
  88. // register.
  89. if ( !NestedCounter++ )
  90. {
  91. StatusRegBuff = StatusReg(~STATUS_INT_MASK, STATUS_EISA_NMI+STATUS_IE);
  92. }
  93. // all done
  94. return;
  95. }
  96. // ----------------------------------------------------------------------------
  97. // PROCEDURE: EisaEndCriticalSection:
  98. //
  99. // DESCRIPTION: This function restores the hardware interrupt status
  100. // at the CPU level as it was before calling the
  101. // "EisaBeginCriticalSection" function.
  102. //
  103. // ARGUMENTS: none
  104. //
  105. // RETURN: none
  106. //
  107. // ASSUMPTIONS:
  108. //
  109. // CALLS:
  110. //
  111. // GLOBALS:
  112. //
  113. // NOTES:
  114. // ----------------------------------------------------------------------------
  115. //
  116. VOID
  117. EisaEndCriticalSection
  118. (
  119. IN VOID
  120. )
  121. {
  122. // Restore the interrupts status only if NestedCounter equals zero.
  123. // The first argument is "&" and the second is "|" with the status
  124. // register.
  125. if ( !--NestedCounter )
  126. {
  127. StatusReg(~STATUS_INT_MASK, StatusRegBuff & STATUS_INT_MASK);
  128. }
  129. // all done
  130. return;
  131. }
  132. // ----------------------------------------------------------------------------
  133. // PROCEDURE: EisaProcessEndOfInterrupt:
  134. //
  135. // DESCRIPTION: Because the EISA interrupts are masked at PIC
  136. // (8259A) level, this routine function doesn't need
  137. // to do anything.
  138. // It doesn't matter if the interrupt channel is level
  139. // or edge triggered, when the interrupt sources goes
  140. // away, the corrisponding bit within the interrupt
  141. // request register (IRR) is cleared.
  142. //
  143. // ARGUMENTS: BusNumber EISA bus number
  144. // Irq IRQ to process
  145. //
  146. // RETURN: ESUCCESS All done
  147. //
  148. // ASSUMPTIONS: none
  149. //
  150. // CALLS: none
  151. //
  152. // GLOBALS: none
  153. //
  154. // NOTES: none
  155. // ----------------------------------------------------------------------------
  156. //
  157. ARC_STATUS
  158. EisaProcessEndOfInterrupt
  159. (
  160. IN ULONG BusNumber,
  161. IN USHORT Irq
  162. )
  163. {
  164. // Return all done.
  165. return ESUCCESS;
  166. }
  167. // ----------------------------------------------------------------------------
  168. // PROCEDURE: EisaTestEisaInterrupt:
  169. //
  170. // DESCRIPTION: This function checks if there is an interrupt pending
  171. // on the specified IRQ.
  172. //
  173. // ARGUMENTS: BusNumber EISA bus number
  174. // Irq IRQ to process
  175. //
  176. // RETURN: TRUE Interrupt is pending
  177. // FALSE Interrupt is not pending
  178. //
  179. // ASSUMPTIONS: none
  180. //
  181. // CALLS: none
  182. //
  183. // GLOBALS: none
  184. //
  185. // NOTES: none
  186. // ----------------------------------------------------------------------------
  187. //
  188. BOOLEAN_ULONG
  189. EisaTestEisaInterrupt
  190. (
  191. IN ULONG BusNumber,
  192. IN USHORT Irq
  193. )
  194. {
  195. // define local variables
  196. BOOLEAN_ULONG IntPending = FALSE; // assume no interrupt is pending
  197. PUCHAR PicPort; // PIC virtual address
  198. UCHAR PicMask; // to check the requested IRQ
  199. // check the IRQ only if the input parameters are valid
  200. // if ( EisaCheckBusNumber( BusNumber ) == ESUCCESS && Irq <= IRQ15 )
  201. if ( Irq <= IRQ15 )
  202. {
  203. // load the virtual address of the specified EISA I/O bus and
  204. // build the mask for checking the specified IRQ.
  205. PicPort = EisaBusInfo[ BusNumber ].IoBusInfo->VirAddr;
  206. if ( Irq < IRQ8 )
  207. {
  208. PicPort += PIC1; // the IRQ is on the 1st PIC
  209. PicMask = 1 << Irq; // set the mask
  210. }
  211. else
  212. {
  213. PicPort += PIC2; // the IRQ is on the 2nd PIC
  214. PicMask = 1 << (Irq - IRQ8); // set the mask
  215. }
  216. // to check the spcified IRQ we need to send first an OCW3 command
  217. // to the PIC to request the interrupt request register (IRR).
  218. WRITE_REGISTER_UCHAR( PicPort, OCW3_IRR );
  219. EISA_IO_DELAY;
  220. if ( READ_REGISTER_UCHAR(PicPort) & PicMask )
  221. {
  222. IntPending = TRUE; // interrupt is pending
  223. }
  224. }
  225. // return the specified IRQ status
  226. return IntPending;
  227. }