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.

250 lines
6.0 KiB

  1. ;/*
  2. ;++
  3. ;
  4. ; Copyright (c) 1989 Microsoft Corporation
  5. ;
  6. ; Module Name:
  7. ;
  8. ; ix8259.inc
  9. ;
  10. ; Abstract:
  11. ;
  12. ; This module contains the definitions used by HAL to manipulate
  13. ; 8259 interrupt controller and 8259-specific constants.
  14. ;
  15. ; WARNING: This file is included by both ASM and C files.
  16. ;
  17. ; Author:
  18. ;
  19. ; John Vert (jvert) 31-Dec-1991
  20. ;
  21. ; (Moved from ke\i386\kimacro.inc)
  22. ;
  23. ;--
  24. if 0 ; Begin C only code */
  25. //
  26. // 8259 defines for C code
  27. // BE SURE TO CHANGE THESE VALUES IN BOTH TABLES!
  28. //
  29. #define HIGHEST_LEVEL_FOR_8259 27 // Highest level for standard 8259
  30. #define PRIMARY_VECTOR_BASE 0x30 // Vector base for standard 8259
  31. #if defined(NEC_98)
  32. #if defined(NT_UP_98)
  33. #define PROFILE_VECTOR (PRIMARY_VECTOR_BASE + 0) // standard profile
  34. #else
  35. #define PROFILE_VECTOR (PRIMARY_VECTOR_BASE + 15) // standard profile
  36. #endif
  37. #else // defined(NEC_98)
  38. #define PROFILE_VECTOR (PRIMARY_VECTOR_BASE + 8) // standard profile
  39. #endif // defined(NEC_98)
  40. #define CLOCK_VECTOR (PRIMARY_VECTOR_BASE + 0) // standard clock
  41. #define I386_80387_IRQ 0x0d // standard npx
  42. #define I386_80387_IRQL (HIGHEST_LEVEL_FOR_8259 - I386_80387_IRQ)
  43. #define I386_80387_VECTOR (PRIMARY_VECTOR_BASE + I386_80387_IRQ)
  44. #define PIC_VECTORS 16
  45. #define V2I(a) (a-PRIMARY_VECTOR_BASE) // Vector to interrupt macro
  46. #define I386_80387_BUSY_PORT (PUCHAR)0xF0
  47. #ifndef NEC_98
  48. #define PIC_SLAVE_IRQ 2
  49. #define PIC_SLAVE_REDIRECT 9
  50. #else
  51. #define PIC_SLAVE_IRQ 7
  52. #define PIC_SLAVE_REDIRECT 8
  53. #endif
  54. #define EISA_EDGE_LEVEL0 0x4D0
  55. #define EISA_EDGE_LEVEL1 0x4D1
  56. /*
  57. endif
  58. ;
  59. ; Same 8259 defines for assemble code
  60. ; BE SURE TO CHANGE THESE VALUES IN BOTH TABLES!
  61. ;
  62. HIGHEST_LEVEL_FOR_8259 equ 27
  63. PRIMARY_VECTOR_BASE equ 30h
  64. ifdef NEC_98
  65. ifdef NT_UP_98
  66. PROFILE_VECTOR equ (PRIMARY_VECTOR_BASE + 0)
  67. else
  68. PROFILE_VECTOR equ (PRIMARY_VECTOR_BASE + 15)
  69. endif
  70. else ; NEC_98
  71. PROFILE_VECTOR equ (PRIMARY_VECTOR_BASE + 8)
  72. endif ; NEC_98
  73. CLOCK_VECTOR equ (PRIMARY_VECTOR_BASE + 0)
  74. I386_80387_IRQ equ 0dh
  75. I386_80387_IRQL equ (HIGHEST_LEVEL_FOR_8259 - I386_80387_IRQ)
  76. I386_80387_VECTOR equ (PRIMARY_VECTOR_BASE + I386_80387_IRQ)
  77. I386_80387_BUSY_PORT equ 0f0h ; port to dismiss busy error line
  78. ifdef NEC_98
  79. PIC_SLAVE_IRQ equ 7
  80. else
  81. PIC_SLAVE_IRQ equ 2
  82. endif
  83. ;
  84. ; The rest of the file are macros used in assemble only.
  85. ;
  86. ;++
  87. ;
  88. ; SET_8259_MASK
  89. ;
  90. ; Macro Description:
  91. ;
  92. ; This macro sets 8259 interrupt mask register with the mask
  93. ; passed from eax register.
  94. ;
  95. ; Note: Currently, only two 8259s are support. As a result,
  96. ; only ax contains valid mask.
  97. ;
  98. ; Arguments:
  99. ;
  100. ; (eax) = mask for setting 8259 interrupt mask register
  101. ;
  102. ;--
  103. SET_8259_MASK macro
  104. local a ; define local labels
  105. out PIC1_PORT1, al ; set master 8259 mask
  106. shr eax, 8 ; shift slave 8259 mask to al
  107. out PIC2_PORT1, al ; set slave 8259 mask
  108. a:
  109. endm
  110. ;
  111. ; Interrupt controller register addresses
  112. ;
  113. ifdef NEC_98
  114. PIC1_PORT0 equ 00H
  115. PIC1_PORT1 equ 02H
  116. PIC2_PORT0 equ 08H
  117. PIC2_PORT1 equ 0AH
  118. else ; NEC_98
  119. PIC1_PORT0 equ 020H
  120. PIC1_PORT1 equ 021H
  121. PIC2_PORT0 equ 0A0H
  122. PIC2_PORT1 equ 0A1H
  123. endif ; NEC_98
  124. EISA_EDGE_LEVEL0 EQU 4D0h
  125. EISA_EDGE_LEVEL1 EQU 4D1h
  126. ;
  127. ; Commands for Interrupt controller
  128. ;
  129. PIC1_EOI_MASK equ 060H
  130. ifdef NEC_98
  131. PIC2_EOI equ 067H ; special EOI
  132. else ; NEC_98
  133. PIC2_EOI equ 062H
  134. endif ; NEC_98
  135. OCW2_NON_SPECIFIC_EOI equ 020H
  136. OCW2_SPECIFIC_EOI equ 060H
  137. OCW3_READ_ISR equ 0BH
  138. OCW3_READ_IRR equ 0AH
  139. ;++
  140. ;
  141. ; IODELAY
  142. ;
  143. ; Macro Description:
  144. ;
  145. ; This macro simply does a jmp to next instruction to synchronize
  146. ; IO port access.
  147. ;
  148. ; Arguments:
  149. ;
  150. ; None
  151. ;
  152. ;--
  153. IODELAY macro
  154. ifdef NEC_98
  155. out 5fh,al ; same effect with "stdcall IODelay8259"
  156. else ; NEC_98
  157. jmp $+2
  158. endif ; NEC_98
  159. endm
  160. ;++
  161. ;
  162. ; PICDELAY
  163. ;
  164. ; Macro Description:
  165. ;
  166. ; This macro does an inb on interrupt mask register to provide the
  167. ; time for 8259 to get stabled.
  168. ;
  169. ; Why do we need this?
  170. ;
  171. ; This is because:
  172. ; . The 80386 has a delayed write to memory and delayed output to IO
  173. ; capability and
  174. ; . 8259 needs some time to settle
  175. ;
  176. ; It is possible for the actual output cycle to 8259 to occur after
  177. ; the completion of instructions following the out instruction. For
  178. ; example, the STI instruction after SET_MASK and dismiss interrupt
  179. ; macros may complete before 8259 actually drops the interrupt. We don't
  180. ; want this happen in MCA system.
  181. ;
  182. ; You may argue that most OEMS add about 450ns delay to solve the
  183. ; back-to-back IO (delay) problem. But, remember that STI is not an IO
  184. ; instruction.
  185. ;
  186. ; Arguments:
  187. ;
  188. ; None
  189. ;
  190. ; NOTE: * The content of AL will be destroyed on return.
  191. ;
  192. ;--
  193. PIC1DELAY macro
  194. in al, PIC1_PORT1
  195. endm
  196. PIC2DELAY macro
  197. in al, PIC2_PORT1
  198. endm
  199. ;++
  200. ;
  201. ; SOFT_INTERRUPT_EXIT
  202. ;
  203. ; Macro Description:
  204. ;
  205. ; This macro is executed on return from the soft interrupt
  206. ; service routine. Its function is to restore privileged processor
  207. ; state, and continue thread execution.
  208. ;
  209. ; Arguments:
  210. ;
  211. ; (TOS) = previous irql
  212. ; (TOS+4 ...) = machine_state frame
  213. ;
  214. ;--
  215. SOFT_INTERRUPT_EXIT macro
  216. EXTRNP _HalpEndSoftwareInterrupt,1
  217. cli
  218. call _HalpEndSoftwareInterrupt@4 ; restore irql
  219. SPURIOUS_INTERRUPT_EXIT ; exit interrupt without EOI
  220. endm
  221. ;*/