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.

595 lines
22 KiB

  1. ;++
  2. ;
  3. ;Copyright (c) 1991 Microsoft Corporation
  4. ;
  5. ;Module Name:
  6. ;
  7. ; ixsysint.asm
  8. ;
  9. ;Abstract:
  10. ;
  11. ; This module implements the HAL routines to enable/disable system
  12. ; interrupts.
  13. ;
  14. ;Author:
  15. ;
  16. ; John Vert (jvert) 22-Jul-1991
  17. ;
  18. ;Environment:
  19. ;
  20. ; Kernel Mode
  21. ;
  22. ;Revision History:
  23. ;
  24. ;--
  25. .386p
  26. .xlist
  27. include hal386.inc
  28. include i386\ix8259.inc
  29. include i386\kimacro.inc
  30. include mac386.inc
  31. include callconv.inc
  32. include xxacpi.h
  33. .list
  34. extrn KiI8259MaskTable:DWORD
  35. EXTRNP _KeBugCheck,1,IMPORT
  36. ;
  37. ; Constants used to initialize CMOS/Real Time Clock
  38. ;
  39. CMOS_CONTROL_PORT EQU 70h ; command port for cmos
  40. CMOS_DATA_PORT EQU 71h ; cmos data port
  41. ;
  42. ; Macros to Read/Write/Reset CMOS to initialize RTC
  43. ;
  44. ; CMOS_READ
  45. ;
  46. ; Description: This macro read a byte from the CMOS register specified
  47. ; in (AL).
  48. ;
  49. ; Parameter: (AL) = address/register to read
  50. ; Return: (AL) = data
  51. ;
  52. CMOS_READ MACRO
  53. OUT CMOS_CONTROL_PORT,al ; ADDRESS LOCATION AND DISABLE NMI
  54. IODelay ; I/O DELAY
  55. IN AL,CMOS_DATA_PORT ; READ IN REQUESTED CMOS DATA
  56. IODelay ; I/O DELAY
  57. ENDM
  58. _TEXT SEGMENT DWORD PUBLIC 'DATA'
  59. align dword
  60. ;
  61. ; HalDismissSystemInterrupt does an indirect jump through this table so it
  62. ; can quickly execute specific code for different interrupts.
  63. ;
  64. public HalpSpecialDismissTable
  65. HalpSpecialDismissTable label dword
  66. dd offset FLAT:HalpDismissNormal ; irq 0
  67. dd offset FLAT:HalpDismissNormal ; irq 1
  68. dd offset FLAT:HalpDismissNormal ; irq 2
  69. dd offset FLAT:HalpDismissNormal ; irq 3
  70. dd offset FLAT:HalpDismissNormal ; irq 4
  71. dd offset FLAT:HalpDismissNormal ; irq 5
  72. dd offset FLAT:HalpDismissNormal ; irq 6
  73. dd offset FLAT:HalpDismissIrq07 ; irq 7
  74. dd offset FLAT:HalpDismissNormal ; irq 8
  75. dd offset FLAT:HalpDismissNormal ; irq 9
  76. dd offset FLAT:HalpDismissNormal ; irq A
  77. dd offset FLAT:HalpDismissNormal ; irq B
  78. dd offset FLAT:HalpDismissNormal ; irq C
  79. dd offset FLAT:HalpDismissNormal ; irq D
  80. dd offset FLAT:HalpDismissNormal ; irq E
  81. dd offset FLAT:HalpDismissIrq0f ; irq F
  82. dd offset FLAT:HalpDismissNormal ; irq 10
  83. dd offset FLAT:HalpDismissNormal ; irq 11
  84. dd offset FLAT:HalpDismissNormal ; irq 12
  85. dd offset FLAT:HalpDismissNormal ; irq 13
  86. dd offset FLAT:HalpDismissNormal ; irq 14
  87. dd offset FLAT:HalpDismissNormal ; irq 15
  88. dd offset FLAT:HalpDismissNormal ; irq 16
  89. dd offset FLAT:HalpDismissNormal ; irq 17
  90. dd offset FLAT:HalpDismissNormal ; irq 18
  91. dd offset FLAT:HalpDismissNormal ; irq 19
  92. dd offset FLAT:HalpDismissNormal ; irq 1A
  93. dd offset FLAT:HalpDismissNormal ; irq 1B
  94. dd offset FLAT:HalpDismissNormal ; irq 1C
  95. dd offset FLAT:HalpDismissNormal ; irq 1D
  96. dd offset FLAT:HalpDismissNormal ; irq 1E
  97. dd offset FLAT:HalpDismissNormal ; irq 1F
  98. dd offset FLAT:HalpDismissNormal ; irq 20
  99. dd offset FLAT:HalpDismissNormal ; irq 21
  100. dd offset FLAT:HalpDismissNormal ; irq 22
  101. dd offset FLAT:HalpDismissNormal ; irq 23
  102. dd offset FLAT:HalpDismissInvalidVector ;24
  103. dd offset FLAT:HalpDismissInvalidVector ;25
  104. dd offset FLAT:HalpDismissInvalidVector ;26
  105. dd offset FLAT:HalpDismissInvalidVector ;27
  106. dd offset FLAT:HalpDismissInvalidVector ;28
  107. dd offset FLAT:HalpDismissInvalidVector ;29
  108. dd offset FLAT:HalpDismissInvalidVector ;2a
  109. dd offset FLAT:HalpDismissInvalidVector ;2b
  110. dd offset FLAT:HalpDismissInvalidVector ;2c
  111. dd offset FLAT:HalpDismissInvalidVector ;2d
  112. dd offset FLAT:HalpDismissInvalidVector ;2e
  113. dd offset FLAT:HalpDismissInvalidVector ;2f
  114. dd offset FLAT:HalpDismissInvalidVector ;30
  115. dd offset FLAT:HalpDismissInvalidVector ;31
  116. dd offset FLAT:HalpDismissInvalidVector ;32
  117. dd offset FLAT:HalpDismissInvalidVector ;33
  118. dd offset FLAT:HalpDismissInvalidVector ;34
  119. dd offset FLAT:HalpDismissInvalidVector ;35
  120. dd offset FLAT:HalpDismissInvalidVector ;36
  121. dd offset FLAT:HalpDismissInvalidVector ;37
  122. dd offset FLAT:HalpDismissInvalidVector ;38
  123. dd offset FLAT:HalpDismissInvalidVector ;39
  124. dd offset FLAT:HalpDismissInvalidVector ;3a
  125. dd offset FLAT:HalpDismissInvalidVector ;3b
  126. dd offset FLAT:HalpDismissInvalidVector ;3c
  127. dd offset FLAT:HalpDismissInvalidVector ;3d
  128. dd offset FLAT:HalpDismissInvalidVector ;3e
  129. dd offset FLAT:HalpDismissInvalidVector ;3f
  130. dd offset FLAT:HalpDismissInvalidVector ;40
  131. dd offset FLAT:HalpDismissInvalidVector ;41
  132. dd offset FLAT:HalpDismissInvalidVector ;42
  133. dd offset FLAT:HalpDismissInvalidVector ;43
  134. dd offset FLAT:HalpDismissInvalidVector ;44
  135. dd offset FLAT:HalpDismissInvalidVector ;45
  136. dd offset FLAT:HalpDismissInvalidVector ;46
  137. dd offset FLAT:HalpDismissInvalidVector ;47
  138. dd offset FLAT:HalpDismissInvalidVector ;48
  139. dd offset FLAT:HalpDismissInvalidVector ;49
  140. dd offset FLAT:HalpDismissInvalidVector ;4a
  141. dd offset FLAT:HalpDismissInvalidVector ;4b
  142. dd offset FLAT:HalpDismissInvalidVector ;4c
  143. dd offset FLAT:HalpDismissInvalidVector ;4d
  144. dd offset FLAT:HalpDismissInvalidVector ;4e
  145. dd offset FLAT:HalpDismissInvalidVector ;4f
  146. dd offset FLAT:HalpDismissInvalidVector ;50
  147. dd offset FLAT:HalpDismissInvalidVector ;51
  148. dd offset FLAT:HalpDismissInvalidVector ;52
  149. dd offset FLAT:HalpDismissInvalidVector ;53
  150. dd offset FLAT:HalpDismissInvalidVector ;54
  151. dd offset FLAT:HalpDismissInvalidVector ;55
  152. dd offset FLAT:HalpDismissInvalidVector ;56
  153. dd offset FLAT:HalpDismissInvalidVector ;57
  154. dd offset FLAT:HalpDismissInvalidVector ;58
  155. dd offset FLAT:HalpDismissInvalidVector ;59
  156. dd offset FLAT:HalpDismissInvalidVector ;5a
  157. dd offset FLAT:HalpDismissInvalidVector ;5b
  158. dd offset FLAT:HalpDismissInvalidVector ;5c
  159. dd offset FLAT:HalpDismissInvalidVector ;5d
  160. dd offset FLAT:HalpDismissInvalidVector ;5e
  161. dd offset FLAT:HalpDismissInvalidVector ;5f
  162. dd offset FLAT:HalpDismissInvalidVector ;60
  163. dd offset FLAT:HalpDismissInvalidVector ;61
  164. dd offset FLAT:HalpDismissInvalidVector ;62
  165. dd offset FLAT:HalpDismissInvalidVector ;63
  166. dd offset FLAT:HalpDismissInvalidVector ;64
  167. dd offset FLAT:HalpDismissInvalidVector ;65
  168. dd offset FLAT:HalpDismissInvalidVector ;66
  169. dd offset FLAT:HalpDismissInvalidVector ;67
  170. dd offset FLAT:HalpDismissInvalidVector ;68
  171. dd offset FLAT:HalpDismissInvalidVector ;69
  172. dd offset FLAT:HalpDismissInvalidVector ;6a
  173. dd offset FLAT:HalpDismissInvalidVector ;6b
  174. dd offset FLAT:HalpDismissInvalidVector ;6c
  175. dd offset FLAT:HalpDismissInvalidVector ;6d
  176. dd offset FLAT:HalpDismissInvalidVector ;6e
  177. dd offset FLAT:HalpDismissInvalidVector ;6f
  178. dd offset FLAT:HalpDismissInvalidVector ;70
  179. dd offset FLAT:HalpDismissInvalidVector ;71
  180. dd offset FLAT:HalpDismissInvalidVector ;72
  181. dd offset FLAT:HalpDismissInvalidVector ;73
  182. dd offset FLAT:HalpDismissInvalidVector ;74
  183. dd offset FLAT:HalpDismissInvalidVector ;75
  184. dd offset FLAT:HalpDismissInvalidVector ;76
  185. dd offset FLAT:HalpDismissInvalidVector ;77
  186. dd offset FLAT:HalpDismissInvalidVector ;78
  187. dd offset FLAT:HalpDismissInvalidVector ;79
  188. dd offset FLAT:HalpDismissInvalidVector ;7a
  189. dd offset FLAT:HalpDismissInvalidVector ;7b
  190. dd offset FLAT:HalpDismissInvalidVector ;7c
  191. dd offset FLAT:HalpDismissInvalidVector ;7d
  192. dd offset FLAT:HalpDismissInvalidVector ;7e
  193. dd offset FLAT:HalpDismissInvalidVector ;7f
  194. dd offset FLAT:HalpDismissInvalidVector ;80
  195. dd offset FLAT:HalpDismissInvalidVector ;81
  196. dd offset FLAT:HalpDismissInvalidVector ;82
  197. dd offset FLAT:HalpDismissInvalidVector ;83
  198. dd offset FLAT:HalpDismissInvalidVector ;84
  199. dd offset FLAT:HalpDismissInvalidVector ;85
  200. dd offset FLAT:HalpDismissInvalidVector ;86
  201. dd offset FLAT:HalpDismissInvalidVector ;87
  202. dd offset FLAT:HalpDismissInvalidVector ;88
  203. dd offset FLAT:HalpDismissInvalidVector ;89
  204. dd offset FLAT:HalpDismissInvalidVector ;8a
  205. dd offset FLAT:HalpDismissInvalidVector ;8b
  206. dd offset FLAT:HalpDismissInvalidVector ;8c
  207. dd offset FLAT:HalpDismissInvalidVector ;8d
  208. dd offset FLAT:HalpDismissInvalidVector ;8e
  209. dd offset FLAT:HalpDismissInvalidVector ;8f
  210. dd offset FLAT:HalpDismissInvalidVector ;90
  211. dd offset FLAT:HalpDismissInvalidVector ;91
  212. dd offset FLAT:HalpDismissInvalidVector ;92
  213. dd offset FLAT:HalpDismissInvalidVector ;93
  214. dd offset FLAT:HalpDismissInvalidVector ;94
  215. dd offset FLAT:HalpDismissInvalidVector ;95
  216. dd offset FLAT:HalpDismissInvalidVector ;96
  217. dd offset FLAT:HalpDismissInvalidVector ;97
  218. dd offset FLAT:HalpDismissInvalidVector ;98
  219. dd offset FLAT:HalpDismissInvalidVector ;99
  220. dd offset FLAT:HalpDismissInvalidVector ;9a
  221. dd offset FLAT:HalpDismissInvalidVector ;9b
  222. dd offset FLAT:HalpDismissInvalidVector ;9c
  223. dd offset FLAT:HalpDismissInvalidVector ;9d
  224. dd offset FLAT:HalpDismissInvalidVector ;9e
  225. dd offset FLAT:HalpDismissInvalidVector ;9f
  226. dd offset FLAT:HalpDismissInvalidVector ;a0
  227. dd offset FLAT:HalpDismissInvalidVector ;a1
  228. dd offset FLAT:HalpDismissInvalidVector ;a2
  229. dd offset FLAT:HalpDismissInvalidVector ;a3
  230. dd offset FLAT:HalpDismissInvalidVector ;a4
  231. dd offset FLAT:HalpDismissInvalidVector ;a5
  232. dd offset FLAT:HalpDismissInvalidVector ;a6
  233. dd offset FLAT:HalpDismissInvalidVector ;a7
  234. dd offset FLAT:HalpDismissInvalidVector ;a8
  235. dd offset FLAT:HalpDismissInvalidVector ;a9
  236. dd offset FLAT:HalpDismissInvalidVector ;aa
  237. dd offset FLAT:HalpDismissInvalidVector ;ab
  238. dd offset FLAT:HalpDismissInvalidVector ;ac
  239. dd offset FLAT:HalpDismissInvalidVector ;ad
  240. dd offset FLAT:HalpDismissInvalidVector ;ae
  241. dd offset FLAT:HalpDismissInvalidVector ;af
  242. dd offset FLAT:HalpDismissInvalidVector ;b0
  243. dd offset FLAT:HalpDismissInvalidVector ;b1
  244. dd offset FLAT:HalpDismissInvalidVector ;b2
  245. dd offset FLAT:HalpDismissInvalidVector ;b3
  246. dd offset FLAT:HalpDismissInvalidVector ;b4
  247. dd offset FLAT:HalpDismissInvalidVector ;b5
  248. dd offset FLAT:HalpDismissInvalidVector ;b6
  249. dd offset FLAT:HalpDismissInvalidVector ;b7
  250. dd offset FLAT:HalpDismissInvalidVector ;b8
  251. dd offset FLAT:HalpDismissInvalidVector ;b9
  252. dd offset FLAT:HalpDismissInvalidVector ;ba
  253. dd offset FLAT:HalpDismissInvalidVector ;bb
  254. dd offset FLAT:HalpDismissInvalidVector ;bc
  255. dd offset FLAT:HalpDismissInvalidVector ;bd
  256. dd offset FLAT:HalpDismissInvalidVector ;be
  257. dd offset FLAT:HalpDismissInvalidVector ;bf
  258. dd offset FLAT:HalpDismissInvalidVector ;c0
  259. dd offset FLAT:HalpDismissInvalidVector ;c1
  260. dd offset FLAT:HalpDismissInvalidVector ;c2
  261. dd offset FLAT:HalpDismissInvalidVector ;c3
  262. dd offset FLAT:HalpDismissInvalidVector ;c4
  263. dd offset FLAT:HalpDismissInvalidVector ;c5
  264. dd offset FLAT:HalpDismissInvalidVector ;c6
  265. dd offset FLAT:HalpDismissInvalidVector ;c7
  266. dd offset FLAT:HalpDismissInvalidVector ;c8
  267. dd offset FLAT:HalpDismissInvalidVector ;c9
  268. dd offset FLAT:HalpDismissInvalidVector ;ca
  269. dd offset FLAT:HalpDismissInvalidVector ;cb
  270. dd offset FLAT:HalpDismissInvalidVector ;cc
  271. dd offset FLAT:HalpDismissInvalidVector ;cd
  272. dd offset FLAT:HalpDismissInvalidVector ;ce
  273. dd offset FLAT:HalpDismissInvalidVector ;cf
  274. _TEXT ENDS
  275. _TEXT$01 SEGMENT DWORD PUBLIC 'CODE'
  276. ASSUME DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING
  277. ;++
  278. ;BOOLEAN
  279. ;HalBeginSystemInterrupt(
  280. ; IN KIRQL Irql
  281. ; IN ULONG Vector,
  282. ; OUT PKIRQL OldIrql
  283. ; )
  284. ;
  285. ;
  286. ;
  287. ;Routine Description:
  288. ;
  289. ; This routine is used to dismiss the specified vector number. It is called
  290. ; before any interrupt service routine code is executed.
  291. ;
  292. ; N.B. This routine does NOT preserve EAX or EBX
  293. ;
  294. ; On a UP machine the interrupt dismissed at BeginSystemInterrupt time.
  295. ; This is fine since the irql is being raise to mask it off.
  296. ; HalEndSystemInterrupt is simply a LowerIrql request.
  297. ;
  298. ;
  299. ;Arguments:
  300. ;
  301. ; Irql - Supplies the IRQL to raise to
  302. ;
  303. ; Vector - Supplies the vector of the interrupt to be processed
  304. ;
  305. ; OldIrql- Location to return OldIrql
  306. ;
  307. ;
  308. ;Return Value:
  309. ;
  310. ; FALSE - Interrupt is spurious and should be ignored
  311. ;
  312. ; TRUE - Interrupt successfully dismissed and Irql raised.
  313. ;
  314. ;--
  315. align dword
  316. HbsiIrql equ byte ptr [esp+4]
  317. HbsiVector equ byte ptr [esp+8]
  318. HbsiOldIrql equ dword ptr [esp+12]
  319. cPublicProc _HalBeginSystemInterrupt ,3
  320. cPublicFpo 3, 0
  321. movzx ebx,HbsiVector ; (ebx) = IDTEntry
  322. sub ebx, PRIMARY_VECTOR_BASE ; (ebx) = 8259 IRQ #
  323. if DBG
  324. cmp ebx, 23h
  325. jbe hbsi00
  326. int 3
  327. hbsi00:
  328. endif
  329. jmp HalpSpecialDismissTable[ebx*4] ; jmp to proper dismiss code
  330. HalpDismissIrq0f:
  331. ;
  332. ; Check to see if this is a spurious interrupt
  333. ;
  334. mov al, OCW3_READ_ISR ; tell 8259 we want to read ISR
  335. out PIC2_PORT0, al
  336. IODelay ; delay
  337. in al, PIC2_PORT0 ; (al) = content of PIC 1 ISR
  338. test al, 10000000B ; Is In-Service register set?
  339. jnz short HalpDismissNormal ; No, this is NOT a spurious int,
  340. ; go do the normal interrupt stuff
  341. ;
  342. ; This is a spurious interrupt.
  343. ; Because the slave PIC is cascaded to irq2 of master PIC, we need to
  344. ; dismiss the interupt on master PIC's irq2.
  345. ;
  346. mov al, PIC2_EOI ; Specific eoi to master for pic2 eoi
  347. out PIC1_PORT0, al ; send irq2 specific eoi to master
  348. mov eax,0 ; return FALSE
  349. ; sti
  350. stdRET _HalBeginSystemInterrupt
  351. HalpDismissIrq07:
  352. ;
  353. ; Check to see if this is a spurious interrupt
  354. ;
  355. mov al, OCW3_READ_ISR ; tell 8259 we want to read ISR
  356. out PIC1_PORT0, al
  357. IODelay ; delay
  358. in al, PIC1_PORT0 ; (al) = content of PIC 1 ISR
  359. test al, 10000000B ; Is In-Service register set?
  360. jnz short HalpDismissNormal ; No, so this is NOT a spurious int
  361. mov eax, 0 ; return FALSE
  362. ; sti
  363. stdRET _HalBeginSystemInterrupt
  364. HalpDismissNormal:
  365. ;
  366. ; Store OldIrql
  367. ;
  368. mov eax, HbsiOldIrql
  369. mov ecx, dword ptr PCR[PcIrql]
  370. mov byte ptr [eax], cl
  371. ;
  372. ; Raise IRQL to requested level
  373. ;
  374. movzx eax, HbsiIrql ; (eax) = irql
  375. ; (ebx) = IRQ #
  376. mov PCR[PcIrql], eax ; set new Irql
  377. mov eax, KiI8259MaskTable[eax*4] ; get 8259's masks
  378. or eax, PCR[PcIDR] ; mask disabled irqs
  379. SET_8259_MASK ; send mask to 8259s
  380. ;
  381. ; Dismiss interrupt. Current interrupt is already masked off.
  382. ;
  383. mov eax, ebx ; (eax) = IRQ #
  384. cmp eax, 8 ; EOI to master or slave?
  385. jae short Hbsi100 ; EIO to both master and slave
  386. or al, PIC1_EOI_MASK ; create specific eoi mask for master
  387. out PIC1_PORT0, al ; dismiss the interrupt
  388. jmp short Hbsi200 ; IO delay - This is not enough for 486
  389. Hbsi100:
  390. mov al, OCW2_NON_SPECIFIC_EOI ; send non specific eoi to slave
  391. out PIC2_PORT0, al
  392. mov al, PIC2_EOI ; specific eoi to master for pic2 eoi
  393. out PIC1_PORT0, al ; send irq2 specific eoi to master
  394. Hbsi200:
  395. PIC1DELAY ; *MUST* wait for 8259 before sti
  396. sti
  397. mov eax, 1 ; return TRUE, interrupt dismissed
  398. stdRET _HalBeginSystemInterrupt
  399. align 4
  400. HalpDismissInvalidVector:
  401. mov eax,0 ; return FALSE
  402. stdRET _HalBeginSystemInterrupt
  403. stdENDP _HalBeginSystemInterrupt
  404. ;++
  405. ;VOID
  406. ;HalDisableSystemInterrupt(
  407. ; IN CCHAR Vector,
  408. ; IN KIRQL Irql
  409. ; )
  410. ;
  411. ;
  412. ;
  413. ;Routine Description:
  414. ;
  415. ; Disables a system interrupt.
  416. ;
  417. ;Arguments:
  418. ;
  419. ; Vector - Supplies the vector of the interrupt to be disabled
  420. ;
  421. ; Irql - Supplies the interrupt level of the interrupt to be disabled
  422. ;
  423. ;Return Value:
  424. ;
  425. ; None.
  426. ;
  427. ;--
  428. cPublicProc _HalDisableSystemInterrupt ,2
  429. cPublicFpo 2, 0
  430. ;
  431. movzx ecx, byte ptr [esp+4] ; (ecx) = IDTEntry
  432. sub ecx, PRIMARY_VECTOR_BASE ; (ecx) = 8259 irq #
  433. mov edx, 1
  434. shl edx, cl ; (ebx) = bit in IMR to disable
  435. cli
  436. or PCR[PcIDR], edx
  437. xor eax, eax
  438. ;
  439. ; Get the current interrupt mask register from the 8259
  440. ;
  441. in al, PIC2_PORT1
  442. shl eax, 8
  443. in al, PIC1_PORT1
  444. ;
  445. ; Mask off the interrupt to be disabled
  446. ;
  447. or eax, edx
  448. ;
  449. ; Write the new interrupt mask register back to the 8259
  450. ;
  451. out PIC1_PORT1, al
  452. shr eax, 8
  453. out PIC2_PORT1, al
  454. PIC2DELAY
  455. sti
  456. stdRET _HalDisableSystemInterrupt
  457. stdENDP _HalDisableSystemInterrupt
  458. ;++
  459. ;
  460. ;BOOLEAN
  461. ;HalEnableSystemInterrupt(
  462. ; IN ULONG Vector,
  463. ; IN KIRQL Irql,
  464. ; IN KINTERRUPT_MODE InterruptMode
  465. ; )
  466. ;
  467. ;
  468. ;Routine Description:
  469. ;
  470. ; Enables a system interrupt
  471. ;
  472. ;Arguments:
  473. ;
  474. ; Vector - Supplies the vector of the interrupt to be enabled
  475. ;
  476. ; Irql - Supplies the interrupt level of the interrupt to be enabled.
  477. ;
  478. ;Return Value:
  479. ;
  480. ; None.
  481. ;
  482. ;--
  483. Vector EQU [esp+4]
  484. Irql EQU [esp+8]
  485. InterruptMode EQU [esp+12]
  486. cPublicProc _HalEnableSystemInterrupt ,3
  487. cPublicFpo 3, 0
  488. movzx ecx, byte ptr Vector ; (ecx) = IDTEntry
  489. sub ecx, PRIMARY_VECTOR_BASE
  490. jc hes_error
  491. cmp ecx, CLOCK2_LEVEL
  492. jnc hes_error
  493. ;
  494. ; Set Edge/Level bit in the interrupt controller
  495. ;
  496. ; read the edge/level control bits into ax
  497. mov edx, EISA_EDGE_LEVEL1
  498. in al, dx
  499. shl ax, 8
  500. mov edx, EISA_EDGE_LEVEL0
  501. in al, dx
  502. mov dx, 1
  503. shl dx, cl ; set the bit corresponding to this Vector
  504. .IF InterruptMode == 0 ; if level,
  505. or ax, dx ; set the bit
  506. .ELSE ; else (edge)
  507. not dx
  508. and ax, dx ; clear the bit
  509. .ENDIF
  510. ; write it back
  511. mov edx, EISA_EDGE_LEVEL0
  512. out dx, al
  513. shr ax, 8
  514. mov edx, EISA_EDGE_LEVEL1
  515. out dx, al
  516. mov eax, 1
  517. shl eax, cl ; (ebx) = bit in IMR to enable
  518. not eax
  519. cli
  520. and PCR[PcIDR], eax
  521. ;
  522. ; Get the PIC masks for the current Irql
  523. ;
  524. mov eax, dword ptr PCR[PcIrql]
  525. mov eax, KiI8259MaskTable[eax*4]
  526. or eax, PCR[PcIDR]
  527. ;
  528. ; Write the new interrupt mask register back to the 8259
  529. ;
  530. SET_8259_MASK
  531. sti
  532. mov eax, 1 ; return TRUE
  533. stdRET _HalEnableSystemInterrupt
  534. hes_error:
  535. if DBG
  536. int 3
  537. endif
  538. xor eax, eax ; FALSE
  539. stdRET _HalEnableSystemInterrupt
  540. stdENDP _HalEnableSystemInterrupt
  541. _TEXT$01 ENDS
  542. END