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.

225 lines
6.1 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. Pic1 EQU 20h
  76. Pic2 EQU 0a0h
  77. sBegin Data
  78. staticD dOldVector,0
  79. sEnd
  80. sBegin CodeFix
  81. assumes cs,CodeFix
  82. assumes ds,Data
  83. ;****************************************************************************
  84. ; FUNCTION: InstallInterruptHandler()
  85. ;
  86. ; PURPOSE:
  87. ; This routine saves the interrupt vector "MultiMediaVector" in
  88. ; the global variable "dOldVector". Then, it installs a small
  89. ; ISR at that vector which calls the routine "DoInt()" when
  90. ; the interrupt occurs.
  91. ;
  92. ;
  93. ;****************************************************************************
  94. cProc InstallInterruptHandler, <FAR,PUBLIC>, <si,di>
  95. cBegin InstallInterruptHandler
  96. push bx ;Save previous vector
  97. push es
  98. mov ax,DOS_GetVector + MULTIMEDIA_INTERRUPT
  99. int 21h
  100. mov WORD PTR dOldVector,bx
  101. mov WORD PTR dOldVector+2,es
  102. pop es
  103. pop bx
  104. push ds ;Install handler
  105. push dx ;
  106. push cs
  107. pop ds
  108. mov dx,OFFSET MULTI_MEDIA_ISR286
  109. test cs:[CodeFixWinFlags],WF_WIN286
  110. jnz @F
  111. mov dx,OFFSET MULTI_MEDIA_ISR386
  112. @@:
  113. mov ax,DOS_SetVector + MULTIMEDIA_INTERRUPT
  114. int 21h
  115. pop dx
  116. pop ds
  117. jmp set_exit
  118. ; **** Entry point of ISR ****
  119. MULTI_MEDIA_ISR286: ;Our Multi-Media ISR (286)
  120. pusha
  121. push ds
  122. push es
  123. cCall DoInterrupt ;Do Interrupt Handling
  124. mov al,20h
  125. out Pic2,al ;EOI on Pic2
  126. out Pic1,al ;EOI on Pic1
  127. pop es
  128. pop ds
  129. popa
  130. ; FSTI
  131. ; iret ;exit MULTI_MEDIA_ISR
  132. FIRET
  133. MULTI_MEDIA_ISR386: ;Our Multi-Media ISR (286)
  134. .386
  135. pushad
  136. push ds
  137. push es
  138. push fs
  139. push gs
  140. cCall DoInterrupt ;Do Interrupt Handling
  141. mov al,20h
  142. out Pic2,al ;EOI on Pic2
  143. out Pic1,al ;EOI on Pic1
  144. pop gs
  145. pop fs
  146. pop es
  147. pop ds
  148. popad
  149. ; FSTI
  150. ; iret ;exit MULTI_MEDIA_ISR
  151. FIRET
  152. .286
  153. set_exit: ;exit InstallHandler
  154. ; DOUT <Interupt installed>
  155. mov ax,1 ;return TRUE
  156. cEnd InstallInteruptHandler
  157. ;****************************************************************************
  158. ; FUNCTION: DeInstallInterruptHandler()
  159. ;
  160. ; PURPOSE:
  161. ; Restores the interrupt vector "MultiMediaVector" with the address
  162. ; at "dOldVector".
  163. ;
  164. ;****************************************************************************
  165. cProc DeInstallInterruptHandler, <FAR,PUBLIC>, <si,di>
  166. cBegin DeInstallInterruptHandler
  167. push ds ;
  168. push dx ;
  169. mov dx,WORD PTR dOldVector
  170. mov ax,WORD PTR dOldVector+2
  171. cmp dx,0 ;were we installed?
  172. jnz dih_go
  173. cmp ax,0
  174. jz dih_skip
  175. dih_go:
  176. mov ds,ax
  177. mov ax,DOS_SetVector + MULTIMEDIA_INTERRUPT
  178. int 21h
  179. dih_skip:
  180. pop dx ;
  181. pop ds ;
  182. cEnd DeInstallHandler
  183. sEnd
  184. end