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.

360 lines
10 KiB

  1. page ,132
  2. ;-----------------------------Module-Header-----------------------------;
  3. ; Module Name: TIMEA.ASM - Some time 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. include mmddk.inc
  16. .list
  17. externFP DefTimerProc ; in TIME.C
  18. externFP StackInit ; in INIT.C
  19. externFP CheckThunkInit ; in stack.asm
  20. externFP MMCALLPROC32 ; in Stack.asm
  21. ;-----------------------------------------------------------------------;
  22. createSeg FIX, CodeFix, word, public, CODE
  23. createSeg INTDS, DataFix, byte, public, DATA
  24. sBegin DataFix
  25. public lpTimeMsgProc
  26. public hTimeDrv
  27. lpTimeMsgProc dd DefTimerProc ; timer driver entry point
  28. hTimeDrv dw 0 ; driver handle for timer
  29. externW gwStackSize ; in STACK.ASM
  30. externD tid32Message ; in Stack.asm
  31. sEnd
  32. sBegin CodeFix
  33. assumes cs,CodeFix
  34. assumes ds,nothing
  35. assumes es,nothing
  36. externW CodeFixDS ; in STACK.ASM
  37. externW CodeFixWinFlags
  38. ;-----------------------------------------------------------------------;
  39. ;
  40. ; @doc EXTERNAL
  41. ;
  42. ; @api WORD | timeBeginPeriod | This function sets the minimum (lowest
  43. ; number of milliseconds) timer resolution that an application or
  44. ; driver is going to use. Call this function immediately before starting
  45. ; to use timer-event services, and call <f timeEndPeriod> immediately
  46. ; after finishing with the timer-event services.
  47. ;
  48. ; @parm WORD | wPeriod | Specifies the minimum timer-event resolution
  49. ; that the application or driver will use.
  50. ;
  51. ; @rdesc Returns zero if successful. Returns TIMERR_NOCANDO if the specified
  52. ; <p wPeriod> resolution value is out of range.
  53. ;
  54. ; @xref timeEndPeriod timeSetEvent
  55. ;
  56. ; @comm For each call to <f timeBeginPeriod>, you must call
  57. ; <f timeEndPeriod> with a matching <p wPeriod> value.
  58. ; An application or driver can make multiple calls to <f timeBeginPeriod>,
  59. ; as long as each <f timeBeginPeriod> call is matched with a
  60. ; <f timeEndPeriod> call.
  61. ;
  62. ;-----------------------------------------------------------------------;
  63. assumes ds,nothing
  64. assumes es,nothing
  65. cProc timeBeginPeriod, <FAR, PUBLIC, PASCAL>, <>
  66. ; ParmW wPeriod
  67. cBegin <nogen>
  68. ;
  69. ; Below is a hack to knobble the minimum period that we support
  70. ; on WOW. 6 ms is about all that a 486dx can cope with.
  71. ;
  72. push bp
  73. mov bp,sp
  74. mov ax,word ptr [bp+6]
  75. cmp ax,5
  76. ja @f
  77. mov word ptr [bp+6],6
  78. @@:
  79. pop bp
  80. ;
  81. ; start of original code.
  82. ;
  83. mov bx, TDD_BEGINMINPERIOD
  84. jmp short timeMessageWord
  85. cEnd <nogen>
  86. ;-----------------------------------------------------------------------;
  87. ;
  88. ; @doc EXTERNAL
  89. ;
  90. ; @api WORD | timeEndPeriod | This function clears a previously set
  91. ; minimum (lowest number of milliseconds) timer resolution that an
  92. ; application or driver is going to use. Call this function
  93. ; immediately after using timer event services.
  94. ;
  95. ; @parm WORD | wPeriod | Specifies the minimum timer-event resolution
  96. ; value specified in the previous call to <f timeBeginPeriod>.
  97. ;
  98. ; @rdesc Returns zero if successful. Returns TIMERR_NOCANDO if the specified
  99. ; <p wPeriod> resolution value is out of range.
  100. ;
  101. ; @xref timeBeginPeriod timeSetEvent
  102. ;
  103. ; @comm For each call to <f timeBeginPeriod>, you must call
  104. ; <f timeEndPeriod> with a matching <p wPeriod> value.
  105. ; An application or driver can make multiple calls to <f timeBeginPeriod>,
  106. ; as long as each <f timeBeginPeriod> call is matched with a
  107. ; <f timeEndPeriod> call.
  108. ;
  109. ;-----------------------------------------------------------------------;
  110. assumes ds,nothing
  111. assumes es,nothing
  112. cProc timeEndPeriod, <FAR, PUBLIC, PASCAL>, <>
  113. ; ParmW wPeriod
  114. cBegin <nogen>
  115. ;
  116. ; Below is a hack to knobble the minimum period that we support
  117. ; on WOW. 6 ms is about all that a 486dx can cope with.
  118. ;
  119. push bp
  120. mov bp,sp
  121. mov ax,word ptr [bp+6]
  122. cmp ax,5
  123. ja @f
  124. mov word ptr [bp+6],6
  125. @@:
  126. pop bp
  127. ;
  128. ; start of original code.
  129. ;
  130. mov bx, TDD_ENDMINPERIOD
  131. jmp short timeMessageWord
  132. cEnd <nogen>
  133. ;-----------------------------------------------------------------------;
  134. ;
  135. ; @doc EXTERNAL
  136. ;
  137. ; @api WORD | timeKillEvent | This functions destroys a specified timer
  138. ; callback event.
  139. ;
  140. ; @parm WORD | wID | Identifies the event to be destroyed.
  141. ;
  142. ; @rdesc Returns zero if successful. Returns TIMERR_NOCANDO if the
  143. ; specified timer event does not exist.
  144. ;
  145. ; @comm The timer event ID specified by <p wID> must be an ID
  146. ; returned by <f timeSetEvent>.
  147. ;
  148. ; @xref timeSetEvent
  149. ;
  150. ;-----------------------------------------------------------------------;
  151. assumes ds,nothing
  152. assumes es,nothing
  153. cProc timeKillEvent, <FAR, PUBLIC, PASCAL>, <>
  154. ; ParmW wId
  155. cBegin <nogen>
  156. mov bx, TDD_KILLTIMEREVENT
  157. errn$ timeMessageWord
  158. cEnd <nogen>
  159. ;-----------------------------------------------------------------------;
  160. ;
  161. ; @doc INTERNAL
  162. ;
  163. ; @api DWORD | timeMessageWord | send a message to the timer driver
  164. ;
  165. ; @reg bx | message to send to driver
  166. ;
  167. ; @parm WORD | w | WORD to send to driver
  168. ;
  169. ; @rdesc Returns zero if successful, error code otherwise
  170. ;
  171. ;-----------------------------------------------------------------------;
  172. assumes ds,nothing
  173. assumes es,nothing
  174. cProc timeMessageWord, <FAR, PUBLIC, PASCAL>, <>
  175. ; ParmW w
  176. cBegin <nogen>
  177. pop ax ; DX:AX = return addr.
  178. pop dx
  179. pop cx ; CX = LOWORD(dw1)
  180. mov es, [CodeFixDS]
  181. assumes es, DataFix
  182. push 0 ; 0
  183. push 0 ; 0
  184. push es:[hTimeDrv]
  185. push bx ; Message
  186. xor bx,bx
  187. push bx ; 0
  188. push cx ; wParam
  189. push bx ; 0
  190. push bx ; 0
  191. push dx ; Return address
  192. push ax
  193. jmp DWORD PTR es:[lpTimeMsgProc]
  194. cEnd <nogen>
  195. ;-----------------------------------------------------------------------;
  196. ;
  197. ; @doc EXTERNAL
  198. ;
  199. ; @api DWORD | timeGetTime | This function retrieves the system time
  200. ; in milliseconds. The system time is the time elapsed since
  201. ; Windows was started.
  202. ;
  203. ; @rdesc The return value is the system time in milliseconds.
  204. ;
  205. ; @comm The only difference between this function and
  206. ; the <f timeGetSystemTime> function is <f timeGetSystemTime>
  207. ; uses the standard multimedia time structure <t MMTIME> to return
  208. ; the system time. The <f timeGetTime> function has less overhead than
  209. ; <f timeGetSystemTime>.
  210. ;
  211. ; @xref timeGetSystemTime
  212. ;
  213. ;-----------------------------------------------------------------------;
  214. assumes ds,nothing
  215. assumes es,nothing
  216. cProc timeGetTime, <FAR, PUBLIC, PASCAL>, <>
  217. cBegin
  218. call CheckThunkInit ; changes es to point to fixed data seg
  219. or ax,ax
  220. jnz @F
  221. sub dx,dx
  222. push dx ; api encoded number
  223. push 0Ah ; see THUNK_TIMEGETTIME in thunks.h
  224. push dx ; Dummy dw1
  225. push dx ;
  226. push dx ; Dummy dw2
  227. push dx ;
  228. push dx ; Dummy dw3
  229. push dx ;
  230. push dx ; Dummy dw4
  231. push dx ;
  232. push es:tid32Message.sel ; Address of function to be called
  233. push es:tid32Message.off ;
  234. push dx
  235. push dx ; no directory change
  236. call FAR PTR MMCALLPROC32 ; call the 32 bit code
  237. @@:
  238. cEnd
  239. ;-----------------------------------------------------------------------;
  240. ;
  241. ; @doc INTERNAL
  242. ;
  243. ; @api void | timeStackInit | in 286p mode init the stacks when
  244. ; timeSetEvent() is called for the first time.
  245. ;
  246. ; @xref timeSetEvent
  247. ;
  248. ; @rdesc none
  249. ;
  250. ;-----------------------------------------------------------------------;
  251. assumes ds,nothing
  252. assumes es,nothing
  253. cProc timeStackInit, <NEAR, PUBLIC, PASCAL>, <>
  254. cBegin
  255. test cs:[CodeFixWinFlags], WF_WIN386
  256. jnz timeStackInitExit
  257. mov es,[CodeFixDS]
  258. assumes es,DataFix
  259. mov ax,es:[gwStackSize]
  260. or ax,ax
  261. jnz timeStackInitExit
  262. push ds ; set DS = DGROUP
  263. mov ax,DGROUP
  264. mov ds,ax
  265. cCall StackInit
  266. pop ds
  267. timeStackInitExit:
  268. cEnd
  269. ;-----------------------------------------------------------------------;
  270. ;
  271. ; @doc INTERNAL
  272. ;
  273. ; @api DWORD | timeMessage | send a message to the timer driver
  274. ;
  275. ; @parm WORD | msg | message to send
  276. ;
  277. ; @parm DWORD | dw1 | first DWORD
  278. ;
  279. ; @parm DWORD | dw2 | first DWORD
  280. ;
  281. ; @rdesc Returns zero if successful, error code otherwise
  282. ;
  283. ;-----------------------------------------------------------------------;
  284. assumes ds,nothing
  285. assumes es,nothing
  286. cProc timeMessage, <FAR, PUBLIC, PASCAL>, <>
  287. ParmW msg
  288. ParmD dw1
  289. ParmD dw2
  290. cBegin
  291. mov es,[CodeFixDS]
  292. assumes es,DataFix
  293. xor ax,ax
  294. push ax ; dwDriverId
  295. push ax
  296. push es:[hTimeDrv]
  297. push msg ; Message passed
  298. push dw1.hi
  299. push dw1.lo
  300. push dw2.hi
  301. push dw2.lo
  302. call DWORD PTR es:[lpTimeMsgProc]
  303. timeMessageExit:
  304. cEnd
  305. ;-----------------------------------------------------------------------;
  306. sEnd CodeFix
  307. ;-----------------------------------------------------------------------;
  308. END