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.

386 lines
10 KiB

4 years ago
  1. ;++
  2. ;
  3. ;Copyright (c) 1991 Microsoft Corporation
  4. ;
  5. ;Module Name:
  6. ;
  7. ; olisyint.asm
  8. ;
  9. ;Abstract:
  10. ;
  11. ; This module implements the HAL routines to enable/disable system
  12. ; interrupts, for the MP systempro implementation
  13. ;
  14. ;Author:
  15. ;
  16. ; John Vert (jvert) 22-Jul-1991
  17. ;
  18. ;Environment:
  19. ;
  20. ; Kernel Mode
  21. ;
  22. ;Revision History:
  23. ;
  24. ; Bruno Sartirana (o-obruno) 3-Mar-92
  25. ; Added support for the Olivetti LSX5030.
  26. ;
  27. ;--
  28. .386p
  29. .xlist
  30. include hal386.inc
  31. include callconv.inc
  32. include i386\ix8259.inc
  33. include i386\kimacro.inc
  34. include mac386.inc
  35. ;LSX5030 start
  36. include i386\olimp.inc
  37. ;LSX5030 end
  38. .list
  39. extrn KiI8259MaskTable:DWORD
  40. EXTRNP _KeBugCheck,1,IMPORT
  41. ;
  42. ; Constants used to initialize CMOS/Real Time Clock
  43. ;
  44. CMOS_CONTROL_PORT EQU 70h ; command port for cmos
  45. CMOS_DATA_PORT EQU 71h ; cmos data port
  46. ;
  47. ; Macros to Read/Write/Reset CMOS to initialize RTC
  48. ;
  49. ; CMOS_READ
  50. ;
  51. ; Description: This macro read a byte from the CMOS register specified
  52. ; in (AL).
  53. ;
  54. ; Parameter: (AL) = address/register to read
  55. ; Return: (AL) = data
  56. ;
  57. CMOS_READ MACRO
  58. OUT CMOS_CONTROL_PORT,al ; ADDRESS LOCATION AND DISABLE NMI
  59. IODelay ; I/O DELAY
  60. IN AL,CMOS_DATA_PORT ; READ IN REQUESTED CMOS DATA
  61. IODelay ; I/O DELAY
  62. ENDM
  63. _DATA SEGMENT DWORD PUBLIC 'DATA'
  64. align dword
  65. ;
  66. ; HalDismissSystemInterrupt does an indirect jump through this table so it
  67. ; can quickly execute specific code for different interrupts.
  68. ;
  69. public HalpSpecialDismissTable
  70. HalpSpecialDismissTable label dword
  71. dd offset FLAT:HalpDismissNormal ; irq 0
  72. dd offset FLAT:HalpDismissNormal ; irq 1
  73. dd offset FLAT:HalpDismissNormal ; irq 2
  74. dd offset FLAT:HalpDismissNormal ; irq 3
  75. dd offset FLAT:HalpDismissNormal ; irq 4
  76. dd offset FLAT:HalpDismissNormal ; irq 5
  77. dd offset FLAT:HalpDismissNormal ; irq 6
  78. dd offset FLAT:HalpDismissIrq07 ; irq 7
  79. dd offset FLAT:HalpDismissNormal ; irq 8
  80. dd offset FLAT:HalpDismissNormal ; irq 9
  81. dd offset FLAT:HalpDismissNormal ; irq A
  82. dd offset FLAT:HalpDismissNormal ; irq B
  83. dd offset FLAT:HalpDismissNormal ; irq C
  84. dd offset FLAT:HalpDismissNormal ; irq D
  85. dd offset FLAT:HalpDismissNormal ; irq E
  86. dd offset FLAT:HalpDismissIrq0f ; irq F
  87. dd offset FLAT:HalpDismissNormal ; irq 10
  88. dd offset FLAT:HalpDismissNormal ; irq 11
  89. dd offset FLAT:HalpDismissNormal ; irq 12
  90. dd offset FLAT:HalpDismissNormal ; irq 13
  91. dd offset FLAT:HalpDismissNormal ; irq 14
  92. dd offset FLAT:HalpDismissNormal ; irq 15
  93. dd offset FLAT:HalpDismissNormal ; irq 16
  94. dd offset FLAT:HalpDismissNormal ; irq 17
  95. dd offset FLAT:HalpDismissNormal ; irq 18
  96. dd offset FLAT:HalpDismissNormal ; irq 19
  97. dd offset FLAT:HalpDismissNormal ; irq 1A
  98. dd offset FLAT:HalpDismissNormal ; irq 1B
  99. dd offset FLAT:HalpDismissNormal ; irq 1C
  100. dd offset FLAT:HalpDismissNormal ; irq 1D
  101. dd offset FLAT:HalpDismissNormal ; irq 1E
  102. dd offset FLAT:HalpDismissNormal ; irq 1F
  103. dd offset FLAT:HalpDismissNormal ; irq 20
  104. dd offset FLAT:HalpDismissNormal ; irq 21
  105. dd offset FLAT:HalpDismissNormal ; irq 22
  106. dd offset FLAT:HalpDismissNormal ; irq 23
  107. _DATA ENDS
  108. _TEXT SEGMENT DWORD PUBLIC 'CODE'
  109. ASSUME DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING
  110. ;++
  111. ;BOOLEAN
  112. ;HalBeginSystemInterrupt(
  113. ; IN KIRQL Irql
  114. ; IN CCHAR Vector,
  115. ; OUT PKIRQL OldIrql
  116. ; )
  117. ;
  118. ;
  119. ;
  120. ;Routine Description:
  121. ;
  122. ; This routine is used to dismiss the specified vector number. It is called
  123. ; before any interrupt service routine code is executed.
  124. ;
  125. ; N.B. This routine does NOT preserve EAX or EBX
  126. ;
  127. ;
  128. ;Arguments:
  129. ;
  130. ; Irql - Supplies the IRQL to raise to
  131. ;
  132. ; Vector - Supplies the vector of the interrupt to be dismissed
  133. ;
  134. ; OldIrql- Location to return OldIrql
  135. ;
  136. ;
  137. ;Return Value:
  138. ;
  139. ; FALSE - Interrupt is spurious and should be ignored
  140. ;
  141. ; TRUE - Interrupt successfully dismissed and Irql raised.
  142. ;
  143. ;--
  144. align dword
  145. HbsiIrql equ byte ptr [esp+4]
  146. HbsiVector equ byte ptr [esp+8]
  147. HbsiOldIrql equ dword ptr [esp+12]
  148. cPublicProc _HalBeginSystemInterrupt,3
  149. movzx ebx,HbsiVector ; (ebx) = System Vector
  150. sub ebx, PRIMARY_VECTOR_BASE ; (ebx) = 8259 IRQ #
  151. cmp ebx, 24h ; Interrupt in table?
  152. jnc hbsi00 ; no go handle
  153. jmp HalpSpecialDismissTable[ebx*4]
  154. hbsi00:
  155. ;
  156. ; Interrupt is out of range. There's no EOI here since it wouldn't
  157. ; have been out of range if it occured on either interrupt controller
  158. ; which is known about.
  159. ;
  160. mov eax,0 ; return FALSE
  161. stdRET _HalBeginSystemInterrupt
  162. HalpDismissIrq0f:
  163. ;
  164. ; Check to see if this is a spurious interrupt
  165. ;
  166. mov al, OCW3_READ_ISR ; tell 8259 we want to read ISR
  167. out PIC2_PORT0, al
  168. IODelay ; delay
  169. in al, PIC2_PORT0 ; (al) = content of PIC 1 ISR
  170. test al, 10000000B ; Is In-Service register set?
  171. jnz short HalpDismissNormal ; No, this is NOT a spurious int,
  172. ; go do the normal interrupt stuff
  173. ;
  174. ; This is a spurious interrupt.
  175. ; Because the slave PIC is cascaded to irq2 of master PIC, we need to
  176. ; dismiss the interupt on master PIC's irq2.
  177. ;
  178. mov al, PIC2_EOI ; Specific eoi to master for pic2 eoi
  179. out PIC1_PORT0, al ; send irq2 specific eoi to master
  180. mov eax,0 ; return FALSE
  181. stdRET _HalBeginSystemInterrupt
  182. HalpDismissIrq07:
  183. ;
  184. ; Check to see if this is a spurious interrupt
  185. ;
  186. mov al, OCW3_READ_ISR ; tell 8259 we want to read ISR
  187. out PIC1_PORT0, al
  188. IODelay ; delay
  189. in al, PIC1_PORT0 ; (al) = content of PIC 1 ISR
  190. test al, 10000000B ; Is In-Service register set?
  191. jnz short HalpDismissNormal ; No, so this is NOT a spurious int
  192. mov eax, 0 ; return FALSE
  193. stdRET _HalBeginSystemInterrupt
  194. HalpDismissNormal:
  195. ;
  196. ; Store OldIrql
  197. ;
  198. mov eax, HbsiOldIrql
  199. movzx ecx, byte ptr fs:PcIrql
  200. mov byte ptr [eax], cl
  201. ;
  202. ; Raise IRQL to requested level
  203. ;
  204. movzx eax, HbsiIrql ; (eax) = irql
  205. ; (ebx) = IRQ #
  206. mov fs:PcIrql, al ; set new Irql
  207. mov eax, KiI8259MaskTable[eax*4] ; get 8259's masks
  208. or eax, fs:PcIDR ; mask disabled irqs
  209. SET_8259_MASK ; send mask to 8259s
  210. ;
  211. ; Dismiss interrupt. Current interrupt is already masked off.
  212. ;
  213. mov eax, ebx ; (eax) = IRQ #
  214. cmp eax, 8 ; EOI to master or slave?
  215. jae short Hbsi100 ; EIO to both master and slave
  216. or al, PIC1_EOI_MASK ; create specific eoi mask for master
  217. out PIC1_PORT0, al ; dismiss the interrupt
  218. jmp short Hbsi200 ; IO delay
  219. Hbsi100:
  220. mov al, OCW2_NON_SPECIFIC_EOI ; send non specific eoi to slave
  221. out PIC2_PORT0, al
  222. mov al, PIC2_EOI ; specific eoi to master for pic2 eoi
  223. out PIC1_PORT0, al ; send irq2 specific eoi to master
  224. Hbsi200:
  225. PIC1DELAY
  226. sti
  227. mov eax, 1 ; return TRUE, interrupt dismissed
  228. stdRET _HalBeginSystemInterrupt
  229. stdENDP _HalBeginSystemInterrupt
  230. ;++
  231. ;VOID
  232. ;HalDisableSystemInterrupt(
  233. ; IN CCHAR Vector,
  234. ; IN KIRQL Irql
  235. ; )
  236. ;
  237. ;
  238. ;
  239. ;Routine Description:
  240. ;
  241. ; Disables a system interrupt.
  242. ;
  243. ;Arguments:
  244. ;
  245. ; Vector - Supplies the vector of the interrupt to be disabled
  246. ;
  247. ; Irql - Supplies the interrupt level of the interrupt to be disabled
  248. ;
  249. ;Return Value:
  250. ;
  251. ; None.
  252. ;
  253. ;--
  254. cPublicProc _HalDisableSystemInterrupt,2
  255. ;
  256. movzx ecx, byte ptr [esp+4] ; (ecx) = Vector
  257. sub ecx, PRIMARY_VECTOR_BASE ; (ecx) = 8259 irq #
  258. mov edx, 1
  259. shl edx, cl ; (ebx) = bit in IMR to disable
  260. cli
  261. or fs:PcIDR, edx
  262. xor eax, eax
  263. ;
  264. ; Get the current interrupt mask register from the 8259
  265. ;
  266. in al, PIC2_PORT1
  267. shl eax, 8
  268. in al, PIC1_PORT1
  269. ;
  270. ; Mask off the interrupt to be disabled
  271. ;
  272. or eax, edx
  273. ;
  274. ; Write the new interrupt mask register back to the 8259
  275. ;
  276. out PIC1_PORT1, al
  277. shr eax, 8
  278. out PIC2_PORT1, al
  279. PIC2DELAY
  280. sti
  281. stdRET _HalDisableSystemInterrupt
  282. stdENDP _HalDisableSystemInterrupt
  283. ;++
  284. ;
  285. ;BOOLEAN
  286. ;HalEnableSystemInterrupt(
  287. ; IN ULONG Vector,
  288. ; IN KIRQL Irql,
  289. ; IN KINTERRUPT_MODE InterruptMode
  290. ; )
  291. ;
  292. ;
  293. ;Routine Description:
  294. ;
  295. ; Enables a system interrupt
  296. ;
  297. ;Arguments:
  298. ;
  299. ; Vector - Supplies the vector of the interrupt to be enabled
  300. ;
  301. ; Irql - Supplies the interrupt level of the interrupt to be enabled.
  302. ;
  303. ;Return Value:
  304. ;
  305. ; None.
  306. ;
  307. ;--
  308. cPublicProc _HalEnableSystemInterrupt,3
  309. movzx ecx, byte ptr [esp+4] ; (ecx) = vector
  310. sub ecx, PRIMARY_VECTOR_BASE
  311. jc hes_error
  312. cmp ecx, CLOCK2_LEVEL
  313. jnc hes_error
  314. mov eax, 1
  315. shl eax, cl ; (ebx) = bit in IMR to enable
  316. not eax
  317. cli
  318. and fs:PcIDR, eax
  319. ;
  320. ; Get the PIC masks for the current Irql
  321. ;
  322. movzx eax, byte ptr fs:PcIrql
  323. mov eax, KiI8259MaskTable[eax*4]
  324. or eax, fs:PcIDR
  325. ;
  326. ; Write the new interrupt mask register back to the 8259
  327. ;
  328. SET_8259_MASK
  329. sti
  330. mov eax, 1 ; return TRUE
  331. stdRET _HalEnableSystemInterrupt
  332. hes_error:
  333. if DBG
  334. int 3
  335. endif
  336. xor eax, eax ; FALSE
  337. stdRET _HalEnableSystemInterrupt
  338. stdENDP _HalEnableSystemInterrupt
  339. _TEXT ENDS
  340. END