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.

288 lines
7.4 KiB

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;
  3. ; API.ASM
  4. ;
  5. ; Copyright (c) Microsoft Corporation 1989, 1990. All rights reserved.
  6. ;
  7. ; Contains the routine tddMessage which communicates to either
  8. ; the 386 timer API's of the 286 timer API's depending on the
  9. ; WinFlags settings WF_WIN286,WF_WIN386.
  10. ;
  11. ;
  12. ; Revision history:
  13. ;
  14. ; 2/12/90 First created by w-glenns
  15. ;
  16. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  17. ?PLM=1 ; pascal call convention
  18. ?WIN=0 ; Windows prolog/epilog code
  19. ?DF=1
  20. PMODE=1
  21. .xlist
  22. include cmacros.inc
  23. include windows.inc
  24. include mmsystem.inc
  25. include mmddk.inc
  26. include timer.inc
  27. .list
  28. .286p
  29. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  30. ;
  31. ; External functions
  32. ;
  33. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  34. externFP Enable
  35. externFP Disable
  36. ifdef DEBUG
  37. externFP tddGetTickCount
  38. endif
  39. externFP tddSetTimerEvent
  40. externFP tddKillTimerEvent
  41. externFP tddGetSystemTime
  42. externFP tddGetDevCaps
  43. externFP tddBeginMinPeriod
  44. externFP tddEndMinPeriod
  45. ;externFP vtdSetTimerEvent
  46. ;externFP vtdKillTimerEvent
  47. ;externFP vtdGetSystemTime
  48. ;externFP vtdGetDevCaps
  49. ;externFP vtdBeginMinPeriod
  50. ;externFP vtdEndMinPeriod
  51. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  52. ;
  53. ; Local data segment
  54. ;
  55. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  56. externA WinFlags
  57. sBegin Data
  58. externW wEnabled
  59. errnz <TDD_KILLTIMEREVENT-DRV_RESERVED>
  60. errnz <TDD_SETTIMEREVENT-4-DRV_RESERVED>
  61. errnz <TDD_GETSYSTEMTIME-8-DRV_RESERVED>
  62. errnz <TDD_GETDEVCAPS-12-DRV_RESERVED>
  63. errnz <TDD_BEGINMINPERIOD-16-DRV_RESERVED>
  64. errnz <TDD_ENDMINPERIOD-20-DRV_RESERVED>
  65. tblCall286 dd tddKillTimerEvent,tddSetTimerEvent,tddGetSystemTime,tddGetDevCaps,tddBeginMinPeriod, tddEndMinPeriod
  66. tblCall386 dd tddKillTimerEvent,tddSetTimerEvent,tddGetSystemTime,tddGetDevCaps,tddBeginMinPeriod, tddEndMinPeriod
  67. ; tblCall386 dd vtdKillTimerEvent,vtdSetTimerEvent,vtdGetSystemTime,vtdGetDevCaps,vtdBeginMinPeriod, vtdEndMinPeriod
  68. tblCallLen equ ($-tblCall286)/2
  69. ifdef DEBUG
  70. externD RModeIntCount
  71. externD PModeIntCount
  72. endif
  73. sEnd Data
  74. sBegin CodeFixed
  75. assumes cs,CodeFixed
  76. assumes ds,Data
  77. assumes es,nothing
  78. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  79. ;
  80. ; @doc INTERNAL
  81. ;
  82. ; @api DWORD | DriverProc | Pass messages to functions that really do work
  83. ;
  84. ; @parm DWORD | nDevice | The id of the device to get the message.
  85. ;
  86. ; @parm WORD | msg | The message.
  87. ;
  88. ; @parm LONG | lParam1 | Parameter 1.
  89. ;
  90. ; @parm LONG | lParam2 | Parameter 2.
  91. ;
  92. ; @rdesc The return value depends on the message being sent.
  93. ;
  94. ; @comm Devices not supporting a message should return 0.
  95. ;
  96. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  97. ;
  98. ; driver message handler table
  99. ;
  100. ; These two tables define which routine handles which driver message.
  101. ;
  102. ; NOTE WARNING: ProcTbl must IMMEDIATELY follow MsgTbl.
  103. ;
  104. MsgTbl dw TDD_GETSYSTEMTIME
  105. dw TDD_BEGINMINPERIOD
  106. dw TDD_ENDMINPERIOD
  107. dw TDD_KILLTIMEREVENT
  108. dw TDD_SETTIMEREVENT
  109. dw TDD_GETDEVCAPS
  110. dw DRV_LOAD
  111. dw DRV_OPEN
  112. dw DRV_CLOSE
  113. dw DRV_ENABLE
  114. dw DRV_DISABLE
  115. dw DRV_QUERYCONFIGURE
  116. dw DRV_INSTALL
  117. ifdef DEBUG
  118. dw TDD_GETTICK
  119. dw TDD_GETRINTCOUNT
  120. dw TDD_GETPINTCOUNT
  121. endif
  122. dw -1
  123. MsgLen equ $-MsgTbl
  124. ProcTbl dw msg_TDD_GETSYSTEMTIME ; TDD_GETSYSTEMTIME
  125. dw msg_TDD_BEGINMINPERIOD ; TDD_BEGINMINPERIOD
  126. dw msg_TDD_ENDMINPERIOD ; TDD_ENDMINPERIOD
  127. dw msg_TDD_KILLTIMEREVENT ; TDD_KILLTIMEREVENT
  128. dw msg_TDD_SETTIMEREVENT ; TDD_SETTIMEREVENT
  129. dw msg_TDD_GETDEVCAPS ; TDD_GETDEVCAPS
  130. ;
  131. dw msg_DRV_LOAD ; DRV_OPEN
  132. dw msg_DRV_OPEN ; DRV_OPEN
  133. dw msg_DRV_CLOSE ; DRV_CLOSE
  134. dw msg_DRV_ENABLE ; DRV_ENABLE
  135. dw msg_DRV_DISABLE ; DRV_DISABLE
  136. dw msg_DRV_QUERYCONFIGURE ; DRV_QUERYCONFIGURE
  137. dw msg_DRV_INSTALL ; DRV_INSTALL
  138. ifdef DEBUG
  139. dw msg_TDD_GETTICK ; TDD_GETTICK
  140. dw msg_TDD_GETRINTCOUNT ; TDD_GETRINTCOUNT
  141. dw msg_TDD_GETPINTCOUNT ; TDD_GETPINTCOUNT
  142. endif
  143. dw msg_fail ; default
  144. ProcLen equ $-ProcTbl
  145. errnz <ProcLen-MsgLen> ; these had better be the same!
  146. errnz <ProcTbl-MsgTbl-MsgLen> ; ProcTbl *must* follow MsgTbl
  147. cProc DriverProc <PUBLIC,FAR,LOADDS> <di>
  148. ParmD id
  149. ParmW hDriver
  150. ParmW msg
  151. ParmD lParam1
  152. ParmD lParam2
  153. cBegin
  154. mov ax,cs ; es == Code
  155. mov es,ax
  156. assumes es,CodeFixed
  157. mov ax,msg ; AX = Message number
  158. cmp ax,DRV_RESERVED ; messages below DRV_RESERVED dont
  159. jl msg_dispatch ; ...need driver to be enabled
  160. cmp wEnabled,0 ; must be enabled for msgs > DRV_RESERVED
  161. jz msg_error
  162. msg_dispatch:
  163. mov di,CodeFixedOFFSET MsgTbl
  164. mov cx,MsgLen/2
  165. cld
  166. repnz scasw
  167. lea bx,[di+MsgLen-2]
  168. jmp cs:[bx]
  169. assumes es,nothing
  170. msg_error:
  171. mov ax, TIMERR_NOCANDO
  172. jmp short msg_makelong
  173. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
  174. ; handle std. installable driver messages.
  175. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
  176. msg_DRV_ENABLE:
  177. cCall Enable, <ax> ; enable driver
  178. jmp short msg_makelong
  179. msg_DRV_DISABLE:
  180. cCall Disable, <ax>
  181. jmp short msg_makelong
  182. msg_DRV_LOAD:
  183. msg_DRV_OPEN:
  184. msg_DRV_CLOSE:
  185. msg_success:
  186. mov ax,1 ; return 1 for all others
  187. jmp short msg_makelong
  188. msg_fail:
  189. msg_DRV_QUERYCONFIGURE:
  190. xor ax, ax ; no - return 0
  191. jmp short msg_makelong
  192. msg_DRV_INSTALL:
  193. mov ax, DRVCNF_RESTART ; restart after install
  194. errn$ msg_makelong
  195. msg_makelong:
  196. cwd ; make sure high word (dx) is set
  197. jmp short msg_done
  198. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
  199. ; handle timer driver specific massages
  200. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
  201. ifdef DEBUG
  202. msg_TDD_GETTICK:
  203. cCall tddGetTickCount
  204. jmp short msg_done
  205. msg_TDD_GETRINTCOUNT:
  206. mov ax,RModeIntCount.lo
  207. mov dx,RModeIntCount.hi
  208. jmp short msg_done
  209. msg_TDD_GETPINTCOUNT:
  210. mov ax,PModeIntCount.lo
  211. mov dx,PModeIntCount.hi
  212. jmp short msg_done
  213. endif
  214. msg_TDD_GETDEVCAPS:
  215. push lParam1.hi
  216. push lParam1.lo
  217. push lParam2.lo
  218. jmp short msg_call
  219. msg_TDD_SETTIMEREVENT:
  220. push lParam1.hi
  221. msg_TDD_BEGINMINPERIOD:
  222. msg_TDD_ENDMINPERIOD:
  223. msg_TDD_KILLTIMEREVENT:
  224. push lParam1.lo
  225. msg_TDD_GETSYSTEMTIME:
  226. errn$ msg_call
  227. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
  228. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
  229. msg_call:
  230. sub ax,DRV_RESERVED ; map msg into table index
  231. mov di,offset DGROUP:tblCall286
  232. add di,ax
  233. mov ax,WinFlags
  234. test ax,WF_WIN386
  235. jz @f ; jump if not win386
  236. add di,tblCallLen
  237. @@: call dword ptr [di] ; index into table
  238. errn$ msg_done
  239. msg_done:
  240. cEnd
  241. sEnd
  242. end