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.7 KiB

  1. page ,132
  2. ;-----------------------------Module-Header-----------------------------;
  3. ; Module Name: TASKA.ASM - Some task functions
  4. ;
  5. ; Copyright (c) 1984-1991 Microsoft Corporation
  6. ;
  7. ;-----------------------------------------------------------------------;
  8. ?PLM = 1
  9. ?WIN = 0
  10. PMODE = 1
  11. .xlist
  12. include cmacros.inc
  13. include windows.inc
  14. include mmsystem.inc
  15. .list
  16. externFP Yield
  17. externFP GetCurrentTask
  18. externFP PostAppMessage
  19. externFP PostMessage
  20. externFP PeekMessage
  21. externFP GetMessage
  22. externFP DispatchMessage
  23. externFP TranslateMessage
  24. ifndef SEGNAME
  25. SEGNAME equ <_TEXT>
  26. endif
  27. ;-----------------------------------------------------------------------;
  28. createSeg %SEGNAME, CodeSeg, word, public, CODE
  29. sBegin CodeSeg
  30. assumes cs,CodeSeg
  31. assumes ds,nothing
  32. assumes es,nothing
  33. ;-----------------------------------------------------------------------;
  34. ;
  35. ; @doc DDK MMSYSTEM TASK
  36. ;
  37. ; @api void | mmTaskYield | This function causes the current task
  38. ; to yield.
  39. ;
  40. ; @comm For predictable results and future compatibility, use this
  41. ; function rather than <f Yield> or the undocumented Kernel yield
  42. ; function to yield within a task created with <f mmTaskCreate>.
  43. ;
  44. ;-----------------------------------------------------------------------;
  45. cProc mmTaskYield, <FAR, PUBLIC, PASCAL>, <>
  46. LocalV msg, %(SIZE MSGSTRUCT)
  47. cBegin
  48. ;
  49. ; we need to call PeekMessage() so ScanSysQue gets called
  50. ; and USER gets the mouse/keyboard input right
  51. ;
  52. ; PeekMessage() may not Yield if there is a message in the
  53. ; Queue so we yield if it did not.
  54. ;
  55. lea ax, msg
  56. cCall PeekMessage, <ss, ax, NULL, 0, 0, PM_NOREMOVE>
  57. or ax,ax
  58. jz mmTaskYieldExit
  59. cCall Yield ; PeekMessage() did not yield, so yield
  60. mmTaskYieldExit:
  61. cEnd
  62. ;-----------------------------------------------------------------------;
  63. ;
  64. ; @doc DDK MMSYSTEM TASK
  65. ;
  66. ; @api HTASK | mmGetCurrentTask | This function returns the
  67. ; handle of the currently executing task created with
  68. ; <f mmTaskCreate>.
  69. ;
  70. ; @rdesc Returns a task handle. For predictable results and future
  71. ; compatibility, use this function rather than <f GetCurrentTask>
  72. ; to get the task handle of a task created with <f mmTaskCreate>.
  73. ;
  74. ; @xref mmTaskCreate
  75. ;
  76. ;-----------------------------------------------------------------------;
  77. cProc mmGetCurrentTask, <FAR, PUBLIC, PASCAL>, <>
  78. cBegin <nogen>
  79. jmp FAR PTR GetCurrentTask ; Jump directly to avoid returning to here
  80. cEnd <nogen>
  81. ;-----------------------------------------------------------------------;
  82. ;
  83. ; @doc DDK MMSYSTEM TASK
  84. ;
  85. ; @api UINT | mmTaskBlock | This function blocks the current
  86. ; task context if its event count is 0.
  87. ;
  88. ; @parm HTASK | hTask | Task handle of the current task. For predictable
  89. ; results, get the task handle from <f mmGetCurrentTask>.
  90. ;
  91. ; @xref mmTaskSignal mmTaskCreate
  92. ;
  93. ; @comm WARNING : For predictable results, must only be called from a
  94. ; task created with <f mmTaskCreate>.
  95. ;
  96. ;-----------------------------------------------------------------------;
  97. cProc mmTaskBlock, <FAR, PUBLIC, PASCAL, NODATA>, <>
  98. ParmW hTask
  99. LocalV msg, %(SIZE MSGSTRUCT)
  100. cBegin
  101. mmTaskBlock_GetMessage:
  102. lea ax, msg
  103. cCall GetMessage, <ss, ax, NULL, 0, 0>; Retrieve any message for task
  104. cmp msg.msHWND, 0 ; Message sent to a window?
  105. je mmTaskBlock_CheckMessage ; If so, dispatch it
  106. lea ax, msg
  107. cCall TranslateMessage, <ss, ax> ; Probably a TaskMan message
  108. lea ax, msg
  109. cCall DispatchMessage, <ss, ax>
  110. jmp mmTaskBlock_GetMessage
  111. ;
  112. ; we got a message, wake up on any message >= WM_MM_RESERVED_FIRST
  113. ;
  114. mmTaskBlock_CheckMessage:
  115. mov ax,msg.msMESSAGE
  116. cmp ax,WM_MM_RESERVED_FIRST
  117. jb mmTaskBlock_GetMessage
  118. cEnd
  119. sEnd
  120. ;-----------------------------------------------------------------------;
  121. createSeg FIX, FixSeg, word, public, CODE
  122. sBegin FixSeg
  123. assumes cs,FixSeg
  124. assumes ds,nothing
  125. assumes es,nothing
  126. ;-----------------------------------------------------------------------;
  127. ;
  128. ; @doc DDK MMSYSTEM TASK
  129. ;
  130. ; @api BOOL | mmTaskSignal | This function signals the specified
  131. ; task, incrementing its event count and unblocking
  132. ; it.
  133. ;
  134. ; @parm HTASK | hTask | Task handle. For predictable results, get the
  135. ; task handle from <f mmGetCurrentTask>.
  136. ;
  137. ; @rdesc Returns TRUE if the signal was sent, else FALSE if the message
  138. ; queue was full.
  139. ;
  140. ; @xref mmTaskBlock mmTaskCreate
  141. ;
  142. ; @comm Must be callable at interrupt time! WARNING : For
  143. ; predictable results, must only be called from a task
  144. ; created with <f mmTaskCreate>.
  145. ;
  146. ;-----------------------------------------------------------------------;
  147. cProc mmTaskSignal, <FAR, PUBLIC, PASCAL>, <>
  148. ; ParmW hTask
  149. cBegin <nogen>
  150. pop bx ; Fetch the return address
  151. pop dx
  152. push WM_USER ; Message
  153. xor ax, ax
  154. push ax ; wParam
  155. push ax ; lParam
  156. push ax
  157. push dx ; Put return address back
  158. push bx
  159. jmp FAR PTR PostAppMessage ; Jump directly to avoid returning to here
  160. cEnd <nogen>
  161. ;-----------------------------------------------------------------------;
  162. ;
  163. ; @doc DDK MCI
  164. ; @api BOOL | mciDriverNotify | Used by a driver to send
  165. ; a notification message
  166. ;
  167. ; @parm HWND | hwndCallback | The window to notify
  168. ;
  169. ; @parm UINT | wDeviceID | The device ID which triggered the callback
  170. ;
  171. ; @parm UINT | wStatus | The status of the callback. May be one of
  172. ; MCI_NOTIFY_SUCCESSFUL or MCI_NOTIFY_SUPERSEDED or MCI_NOTIFY_ABORTED
  173. ; or MCI_NOTIFY_FAILURE
  174. ;
  175. ; @rdesc Returns TRUE if notify was successfully sent, FALSE if the
  176. ; application's message queue was full.
  177. ;
  178. ; @comm This function is callable at interrupt time.
  179. ;
  180. ;-----------------------------------------------------------------------;
  181. cProc mciDriverNotify, <FAR, PUBLIC, PASCAL>, <>
  182. ; ParmW hwndCallback
  183. ; ParmW wDeviceID
  184. ; ParmW wStatus
  185. cBegin <nogen>
  186. pop bx ; Fetch the return address
  187. pop dx
  188. pop ax ; Fetch wStatus
  189. pop cx ; Fetch wDeviceID
  190. push MM_MCINOTIFY ; Message
  191. push ax ; wParam == wStatus
  192. push 0 ; HIWORD of lParam
  193. push cx ; LOWORD of lParam == wDeviceID
  194. push dx ; Put return address back
  195. push bx
  196. jmp FAR PTR PostMessage ; Jump directly to avoid returning to here
  197. cEnd <nogen>
  198. sEnd
  199. ;-----------------------------------------------------------------------;
  200. END