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.

230 lines
5.9 KiB

  1. TITLE ISR.ASM -- Windows DLL HARDWARE ISR
  2. ;****************************************************************************
  3. ;
  4. ; PROGRAM: isr.asm
  5. ;
  6. ; PURPOSE:
  7. ; Installs an interrupt handler under Windows 3.x
  8. ; This ISR (Interrupt service routine) will then service a requested
  9. ; multi-media callback routine.
  10. ;
  11. ; FUNCTIONS:
  12. ; DoInterrupt: Performs interrupt processing
  13. ; InstallInterruptHandler: Installs the interrupt handler
  14. ; DeInstallInterruptHandler: Removes the interrupt handler
  15. ;
  16. ;****************************************************************************
  17. .286
  18. memS EQU 1 ;Small memory model
  19. .xlist
  20. include cmacros.inc
  21. include windows.inc
  22. include wowmmcb.inc
  23. include vint.inc
  24. .list
  25. ;-------------------------------------------------------------------------;
  26. ;
  27. ; debug support
  28. ;
  29. ;-------------------------------------------------------------------------;
  30. externFP OutputDebugString
  31. externFP DoInterrupt
  32. ;-------------------------------------------------------------------------;
  33. ;
  34. ; callback support
  35. ;
  36. ;-------------------------------------------------------------------------;
  37. externW CodeFixWinFlags
  38. ;--------------------------Private-Macro----------------------------------;
  39. ; DOUT String - send a debug message to the debugger
  40. ;
  41. ; Entry:
  42. ; String String to send to the COM port, does not need a CR,LF
  43. ;
  44. ; Registers Destroyed:
  45. ; none
  46. ;
  47. ; NOTE no code is generated unless the DEBUG symbol is defined
  48. ;
  49. ; History:
  50. ; Sun 31-Jul-1989 -by- ToddLa
  51. ; Wrote it.
  52. ;-------------------------------------------------------------------------;
  53. DOUT macro text
  54. local string_buffer
  55. ifdef MYDEBUG
  56. push cs
  57. push offset string_buffer
  58. call OutputDebugString
  59. jmp @F
  60. string_buffer label byte
  61. db "MMSYSTEM: "
  62. db "&text&",13,10,0
  63. @@:
  64. endif
  65. endm
  66. ;****************************************************************************
  67. ;
  68. ; Create a fixed code segment
  69. ;
  70. ;****************************************************************************
  71. createSeg FIX, CodeFix, word, public, CODE
  72. createSeg INTDS, DataFix, byte, public, DATA
  73. DOS_SetVector EQU 2500h
  74. DOS_GetVector EQU 3500h
  75. ifdef NEC_98
  76. Pic1 EQU 00h
  77. Pic2 EQU 08h
  78. else ; NEC_98
  79. Pic1 EQU 20h
  80. Pic2 EQU 0a0h
  81. endif ; NEC_98
  82. sBegin Data
  83. staticD dOldVector,0
  84. sEnd
  85. sBegin CodeFix
  86. assumes cs,CodeFix
  87. assumes ds,Data
  88. ;****************************************************************************
  89. ; FUNCTION: InstallInterruptHandler()
  90. ;
  91. ; PURPOSE:
  92. ; This routine saves the interrupt vector "MultiMediaVector" in
  93. ; the global variable "dOldVector". Then, it installs a small
  94. ; ISR at that vector which calls the routine "DoInt()" when
  95. ; the interrupt occurs.
  96. ;
  97. ;
  98. ;****************************************************************************
  99. cProc InstallInterruptHandler, <FAR,PUBLIC>, <si,di>
  100. cBegin InstallInterruptHandler
  101. push bx ;Save previous vector
  102. push es
  103. mov ax,DOS_GetVector + MULTIMEDIA_INTERRUPT
  104. int 21h
  105. mov WORD PTR dOldVector,bx
  106. mov WORD PTR dOldVector+2,es
  107. pop es
  108. pop bx
  109. push ds ;Install handler
  110. push dx ;
  111. push cs
  112. pop ds
  113. mov dx,OFFSET MULTI_MEDIA_ISR286
  114. test cs:[CodeFixWinFlags],WF_WIN286
  115. jnz @F
  116. mov dx,OFFSET MULTI_MEDIA_ISR386
  117. @@:
  118. mov ax,DOS_SetVector + MULTIMEDIA_INTERRUPT
  119. int 21h
  120. pop dx
  121. pop ds
  122. jmp set_exit
  123. ; **** Entry point of ISR ****
  124. MULTI_MEDIA_ISR286: ;Our Multi-Media ISR (286)
  125. pusha
  126. push ds
  127. push es
  128. cCall DoInterrupt ;Do Interrupt Handling
  129. mov al,20h
  130. out Pic2,al ;EOI on Pic2
  131. out Pic1,al ;EOI on Pic1
  132. pop es
  133. pop ds
  134. popa
  135. ; FSTI
  136. ; iret ;exit MULTI_MEDIA_ISR
  137. FIRET
  138. MULTI_MEDIA_ISR386: ;Our Multi-Media ISR (286)
  139. .386
  140. pushad
  141. push ds
  142. push es
  143. push fs
  144. push gs
  145. cCall DoInterrupt ;Do Interrupt Handling
  146. mov al,20h
  147. out Pic2,al ;EOI on Pic2
  148. out Pic1,al ;EOI on Pic1
  149. pop gs
  150. pop fs
  151. pop es
  152. pop ds
  153. popad
  154. ; FSTI
  155. ; iret ;exit MULTI_MEDIA_ISR
  156. FIRET
  157. .286
  158. set_exit: ;exit InstallHandler
  159. ; DOUT <Interupt installed>
  160. mov ax,1 ;return TRUE
  161. cEnd InstallInteruptHandler
  162. ;****************************************************************************
  163. ; FUNCTION: DeInstallInterruptHandler()
  164. ;
  165. ; PURPOSE:
  166. ; Restores the interrupt vector "MultiMediaVector" with the address
  167. ; at "dOldVector".
  168. ;
  169. ;****************************************************************************
  170. cProc DeInstallInterruptHandler, <FAR,PUBLIC>, <si,di>
  171. cBegin DeInstallInterruptHandler
  172. push ds ;
  173. push dx ;
  174. mov dx,WORD PTR dOldVector
  175. mov ax,WORD PTR dOldVector+2
  176. cmp dx,0 ;were we installed?
  177. jnz dih_go
  178. cmp ax,0
  179. jz dih_skip
  180. dih_go:
  181. mov ds,ax
  182. mov ax,DOS_SetVector + MULTIMEDIA_INTERRUPT
  183. int 21h
  184. dih_skip:
  185. pop dx ;
  186. pop ds ;
  187. cEnd DeInstallHandler
  188. sEnd
  189. end