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.

498 lines
13 KiB

  1. .LALL
  2. ;*****************************************************************************
  3. ;
  4. ; (C) Copyright MICROSOFT Corp, 1993
  5. ;
  6. ; Title: DPLAY.ASM
  7. ;
  8. ; Version: 1.00
  9. ;
  10. ; Date: 16-Mar-1993
  11. ;
  12. ; Author: AaronO (mostly stolen from SnowBall vxdinit.asm)
  13. ;
  14. ;-----------------------------------------------------------------------------
  15. ;
  16. ; Change log:
  17. ;
  18. ; Date Rev Description
  19. ; ----------- --- ------------------------------------------------------
  20. ; 16-Mar-1993 AWO Original (splurped from SnowBall vxdinit.asm)
  21. ;
  22. ;=============================================================================
  23. ;
  24. ; Main VxD module for the NWSERVER NCP server:
  25. ;
  26. ; Real mode initialization
  27. ; VxD Initialization, including server VM creation
  28. ; VxD PM API support
  29. ; ServerStarvation checker
  30. ;
  31. ;-----------------------------------------------------------------------------
  32. ; BUGBUG: make sure everything is cleaned up from getting rid of VM here.
  33. ;-----------------------------------------------------------------------------
  34. TITLE $DEBUG
  35. .386P
  36. include vmm.inc
  37. include debug.inc
  38. include shell.inc
  39. include perf.inc ;performance monitor
  40. include msgmacro.inc
  41. include messages.inc
  42. MASM=1
  43. ifdef DEBUG
  44. extrn _Debug_Query : near
  45. extrn _DebugQueryCmdStr : byte
  46. extrn _DebugQueryCmdStrLen : dword
  47. endif
  48. VxD_LOCKED_CODE_SEG
  49. DPLAY_Device_Id equ 444h
  50. Declare_Virtual_Device DPLAY, 1, 0, DPLAY_Control, DPLAY_Device_Id, \
  51. Undefined_Init_Order, 0, 0
  52. ;=============================================================================
  53. ; VxD Control Dispatch table
  54. ;-----------------------------------------------------------------------------
  55. Begin_Control_Dispatch DPLAY
  56. ; Control_Dispatch Set_Device_Focus, SERVER_Set_Device_Focus
  57. ; Control_Dispatch QUERY_DESTROY, NWSERVER_Query_Destroy
  58. ; Control_Dispatch SYS_CRITICAL_INIT, NWSERVER_Critical_Init
  59. Control_Dispatch DEVICE_INIT, DPLAY_Device_Init
  60. ; Control_Dispatch INIT_COMPLETE, NWSERVER_Init_Complete
  61. Control_Dispatch DEBUG_QUERY, DPLAY_Debug_Query
  62. ; Control_Dispatch Create_VM, SERVER_Create_VM
  63. ; Control_Dispatch SYS_VM_TERMINATE, NWSERVER_Exit
  64. ; Control_Dispatch SYS_CRITICAL_EXIT, NWSERVER_Critical_Exit
  65. ; Control_Dispatch VM_NOT_EXECUTEABLE, NWSERVER_VM_Not_Exec
  66. ; Control_Dispatch END_PM_APP, NWSERVER_End_PM_App
  67. ; Control_Dispatch Device_Reboot_Notify, NWSERVER_Reboot
  68. ; Control_Dispatch DESTROY_THREAD, NWSERVER_Destroy_Thread
  69. ; Control_Dispatch BEGIN_PM_APP, NWSERVER_Begin_PM_App
  70. ; Control_Dispatch KERNEL32_INITIALIZED, NWSERVER_Kernel32Initialized
  71. ; Control_Dispatch KERNEL32_SHUTDOWN, NWSERVER_Kernel32Shutdown
  72. ; Control_Dispatch W32_DeviceIoControl, NWSERVER_Win32_API
  73. ;PNP_NEW_DEVNODE EQU 22h
  74. ; Control_Dispatch PNP_NEW_DEVNODE, NWSERVER_PNPNewDevNode
  75. ; Control_Dispatch System_Exit, NWSERVER_System_Exit
  76. Control_Dispatch W32_DEVICEIOCONTROL, DPLAY_W32_DeviceIOControl, sCall, <ecx, ebx, edx, esi>
  77. End_Control_Dispatch DPLAY
  78. ;
  79. ; DbgPrint is defined in DbgPrint.c in this case.
  80. ;
  81. _VMM_Out_Debug_String PROC NEAR PUBLIC
  82. push esi
  83. mov esi, [esp].8
  84. VMMcall Out_Debug_String
  85. pop esi
  86. ret
  87. _VMM_Out_Debug_String ENDP
  88. ; VOID VMM_Out_Debug_Code_Label(PVOID Address)
  89. ;
  90. ; Outputs a flat pointer as a symbolic label
  91. ;
  92. _VMM_Out_Debug_Code_Label PROC NEAR PUBLIC
  93. mov eax, [esp].4
  94. mov dx, cs
  95. Trace_Out "?DX:EAX", nocrlf
  96. ret
  97. _VMM_Out_Debug_Code_Label ENDP
  98. ; VOID VMM_Out_Debug_Data_Label(PVOID Address)
  99. ;
  100. ; Outputs a flat pointer as a symbolic label
  101. ;
  102. _VMM_Out_Debug_Data_Label PROC NEAR PUBLIC
  103. mov eax, [esp].4
  104. mov dx, ds
  105. Trace_Out "?DX:EAX", nocrlf
  106. ret
  107. _VMM_Out_Debug_Data_Label ENDP
  108. _VMM_Get_Sys_VM_Handle proc public
  109. push ebx
  110. VMMcall Get_Sys_VM_Handle
  111. mov eax, ebx
  112. pop ebx
  113. ret
  114. _VMM_Get_Sys_VM_Handle endp
  115. _VMM_Get_Profile_String proc public
  116. push ebp
  117. mov ebp, esp
  118. push esi
  119. push edi
  120. mov esi, [ebp+8] ; Section name
  121. mov edi, [ebp+12] ; Key name
  122. mov edx, [ebp+16] ; default
  123. VMMcall Get_Profile_String
  124. mov eax, edx
  125. pop edi
  126. pop esi
  127. pop ebp
  128. ret
  129. _VMM_Get_Profile_String endp
  130. _VMM_Get_Profile_Hex_Int proc public
  131. push ebp
  132. mov ebp, esp
  133. push esi
  134. push edi
  135. mov esi, [ebp+8] ; Section name
  136. mov edi, [ebp+12] ; Key name
  137. mov eax, [ebp+16] ; default
  138. VMMcall Get_Profile_Hex_Int
  139. pop edi
  140. pop esi
  141. pop ebp
  142. ret
  143. _VMM_Get_Profile_Hex_Int endp
  144. _C_HeapAllocate PROC NEAR PUBLIC
  145. mov eax,ss:[esp+8]
  146. mov edx,ss:[esp+4]
  147. push eax
  148. push edx
  149. VMMCall _HeapAllocate
  150. add esp,8
  151. ret
  152. _C_HeapAllocate ENDP
  153. _C_HeapFree PROC NEAR PUBLIC
  154. mov edx,ss:[esp+4]
  155. push 0
  156. push edx
  157. VMMcall _HeapFree
  158. add esp,8
  159. ret
  160. _C_HeapFree ENDP
  161. _GetThreadHandle PROC NEAR PUBLIC
  162. push edi
  163. VMMcall Get_Cur_Thread_Handle
  164. mov eax,edi
  165. pop edi
  166. ret
  167. _GetThreadHandle ENDP
  168. _VMM_Create_Semaphore proc public
  169. mov ecx, [esp+4] ; First arg = Initial token count
  170. VMMCall Create_Semaphore
  171. jnc vcs_1
  172. xor eax, eax
  173. vcs_1:
  174. ret
  175. _VMM_Create_Semaphore endp
  176. _VMM_Destroy_Semaphore proc public
  177. mov eax, [esp+4] ; First arg = Semaphore handle
  178. VMMJmp Destroy_Semaphore
  179. _VMM_Destroy_Semaphore endp
  180. _VMM_Signal_Semaphore proc public
  181. mov eax, [esp+4] ; First arg = Semaphore handle
  182. VMMJmp Signal_Semaphore
  183. _VMM_Signal_Semaphore endp
  184. ; VMM_Wait_Semaphore_Ints - Waits on a semaphore, allowing ints to be processed in this thread
  185. ;
  186. _VMM_Wait_Semaphore_Ints proc public
  187. mov eax, [esp+4] ; First arg = Semaphore handle
  188. mov ecx, Block_Force_Svc_Ints+Block_Svc_Ints
  189. VMMJmp Wait_Semaphore
  190. _VMM_Wait_Semaphore_Ints endp
  191. ;Get system time in milliseconds
  192. _VMM_Get_System_Time proc public
  193. VMMJmp Get_System_Time
  194. _VMM_Get_System_Time endp
  195. ;**************************************************************************
  196. ;
  197. ; MAP_Client_Ptr - convert a pointer to a 0:32 flat pointer
  198. ;
  199. ; IN eax = client Segment/Selector
  200. ; IN ebx = client Offset
  201. ; IN edi = points o Client Reg Structure
  202. ;
  203. ; OUT edx = flat client ptr
  204. ;**************************************************************************
  205. MAP_Client_Ptr proc near uses ecx
  206. ;borrow the client DS:DX
  207. movzx ecx, [edi].Client_DS
  208. push ecx
  209. movzx ecx, [edi].Client_DX
  210. push ecx
  211. mov [edi].Client_DS, ax
  212. mov [edi].Client_DX, bx
  213. Client_Ptr_Flat edx, DS, DX
  214. ;restore the contents of the client regs
  215. pop ecx
  216. mov [edi].Client_DX, cx
  217. pop ecx
  218. mov [edi].Client_DS, cx
  219. RET
  220. MAP_Client_Ptr ENDP
  221. ;*****************************************************************************
  222. ; DPLAYGetVersion - returns the version number of DPLAY DEBUG module
  223. ;
  224. ; ENTRY:
  225. ;
  226. ; EXIT: Carry is clear, ax=DPLAYVXD version <AH=Major AL = Minor>
  227. ;=============================================================================
  228. BeginProc DPLAYGetVersion Service
  229. mov eax, 001h
  230. clc
  231. ret
  232. EndProc DPLAYGetVersion
  233. ; NOTE: The following assumes (craftily) that the command tail for the debug query
  234. ; dot-command is passed in by VMM in FS:[ESI].
  235. ;
  236. BeginProc DPLAY_Debug_Query
  237. xor ebx, ebx
  238. mov ax, fs
  239. test ax, ax
  240. jz dq1
  241. push esi
  242. push ds
  243. lea edi, _DebugQueryCmdStr
  244. mov ecx, _DebugQueryCmdStrLen
  245. mov ds, ax
  246. cld
  247. rep movsb
  248. xor eax, eax
  249. stosb
  250. pop ds
  251. pop esi
  252. lea ebx, _DebugQueryCmdStr
  253. dq1:
  254. push ebx
  255. call _Debug_Query
  256. add esp, 4
  257. ret
  258. EndProc DPLAY_Debug_Query
  259. VxD_LOCKED_CODE_ENDS
  260. VxD_LOCKED_DATA_SEG
  261. ;====================================================================
  262. ; STATISTICS for performance monitor
  263. ;--------------------------------------------------------------------
  264. public hPerfId
  265. hPerfId dd ?
  266. public _stat_ThrottleRate
  267. _stat_ThrottleRate dd ?
  268. public _stat_BytesSent
  269. _stat_BytesSent dd ?
  270. public _stat_BackLog
  271. _stat_BackLog dd ?
  272. public _stat_BytesLost
  273. _stat_BytesLost dd ?
  274. public _stat_RemBytesReceived
  275. _stat_RemBytesReceived dd ?
  276. public _stat_Latency
  277. _stat_Latency dd ?
  278. public _stat_MinLatency
  279. _stat_MinLatency dd ?
  280. public _stat_AvgLatency
  281. _stat_AvgLatency dd ?
  282. public _stat_AvgDevLatency
  283. _stat_AvgDevLatency dd ?
  284. public _stat_USER1
  285. _stat_USER1 dd ?
  286. public _stat_USER2
  287. _stat_USER2 dd ?
  288. public _stat_USER3
  289. _stat_USER3 dd ?
  290. public _stat_USER4
  291. _stat_USER4 dd ?
  292. public _stat_USER5
  293. _stat_USER5 dd ?
  294. public _stat_USER6
  295. _stat_USER6 dd ?
  296. Vxd_LOCKED_DATA_ENDS
  297. VXD_ICODE_SEG
  298. DPLAY_Device_Init proc near public
  299. LocalVar hStatNULL, DWORD
  300. LocalVar hStat2, DWORD
  301. LocalVar hStat1, DWORD
  302. ; Do STATISTICS VxD stuff
  303. GET_MESSAGE_PTR <PerfName>, ebx
  304. GET_MESSAGE_PTR <PerfNodeName>, ecx
  305. Reg_Perf_Srv 0,0,ebx,ecx,0
  306. or eax, eax ; Q: perf.386 around?
  307. jz ir0 ; N: skip it
  308. mov hPerfId, eax
  309. GET_MESSAGE_PTR <PerfThrottleNam>, ebx
  310. GET_MESSAGE_PTR <PerfThrottleNodeNam>, ecx
  311. GET_MESSAGE_PTR <PerfThrottleDsc>, edx
  312. Reg_Perf_Stat hPerfId,0,0,ebx,ecx,0,edx,_stat_ThrottleRate
  313. GET_MESSAGE_PTR <PerfBWNam>, ebx
  314. GET_MESSAGE_PTR <PerfBWNodeNam>, ecx
  315. GET_MESSAGE_PTR <PerfBWDsc>, edx
  316. Reg_Perf_Stat hPerfId,0,<PSTF_RATE>,ebx,ecx,0,edx,_stat_BytesSent
  317. GET_MESSAGE_PTR <PerfBackLogNam>, ebx
  318. GET_MESSAGE_PTR <PerfBackLogNodeNam>, ecx
  319. GET_MESSAGE_PTR <PerfBackLogDsc>, edx
  320. Reg_Perf_Stat hPerfId,0,0,ebx,ecx,0,edx,_stat_BackLog
  321. GET_MESSAGE_PTR <PerfBytesLostNam>, ebx
  322. GET_MESSAGE_PTR <PerfBytesLostNodeNam>, ecx
  323. GET_MESSAGE_PTR <PerfBytesLostDsc>, edx
  324. Reg_Perf_Stat hPerfId,0,<PSTF_RATE>,ebx,ecx,0,edx,_stat_BytesLost
  325. GET_MESSAGE_PTR <PerfLocThroughputNam>, ebx
  326. GET_MESSAGE_PTR <PerfLocThroughputNodeNam>, ecx
  327. GET_MESSAGE_PTR <PerfThroughputDsc>, edx
  328. Reg_Perf_Stat hPerfId,0,<PSTF_RATE>,ebx,ecx,0,edx,_stat_RemBytesReceived
  329. GET_MESSAGE_PTR <PerfLastLatNam>, ebx
  330. GET_MESSAGE_PTR <PerfLastLatNodeNam>, ecx
  331. GET_MESSAGE_PTR <PerfLastLatDsc>, edx
  332. Reg_Perf_Stat hPerfId,0,0,ebx,ecx,0,edx,_stat_Latency
  333. GET_MESSAGE_PTR <PerfMinLatNam>, ebx
  334. GET_MESSAGE_PTR <PerfMinLatNodeNam>, ecx
  335. GET_MESSAGE_PTR <PerfMinLatDsc>, edx
  336. Reg_Perf_Stat hPerfId,0,0,ebx,ecx,0,edx,_stat_MinLatency
  337. GET_MESSAGE_PTR <PerfAvgLatNam>, ebx
  338. GET_MESSAGE_PTR <PerfAvgLatNodeNam>, ecx
  339. GET_MESSAGE_PTR <PerfAvgLatDsc>, edx
  340. Reg_Perf_Stat hPerfId,0,0,ebx,ecx,0,edx,_stat_AvgLatency
  341. GET_MESSAGE_PTR <PerfAvgDevLatNam>, ebx
  342. GET_MESSAGE_PTR <PerfAvgDevLatNodeNam>, ecx
  343. GET_MESSAGE_PTR <PerfAvgDevLatDsc>, edx
  344. Reg_Perf_Stat hPerfId,0,0,ebx,ecx,0,edx,_stat_AvgDevLatency
  345. GET_MESSAGE_PTR <PerfUSER1Nam>, ebx
  346. GET_MESSAGE_PTR <PerfUSER1NodeNam>, ecx
  347. GET_MESSAGE_PTR <PerfUSER1Dsc>, edx
  348. Reg_Perf_Stat hPerfId,0,0,ebx,ecx,0,edx,_stat_USER1
  349. GET_MESSAGE_PTR <PerfUSER2Nam>, ebx
  350. GET_MESSAGE_PTR <PerfUSER2NodeNam>, ecx
  351. GET_MESSAGE_PTR <PerfUSER2Dsc>, edx
  352. Reg_Perf_Stat hPerfId,0,0,ebx,ecx,0,edx,_stat_USER2
  353. GET_MESSAGE_PTR <PerfUSER3Nam>, ebx
  354. GET_MESSAGE_PTR <PerfUSER3NodeNam>, ecx
  355. GET_MESSAGE_PTR <PerfUSER3Dsc>, edx
  356. Reg_Perf_Stat hPerfId,0,0,ebx,ecx,0,edx,_stat_USER3
  357. GET_MESSAGE_PTR <PerfUSER4Nam>, ebx
  358. GET_MESSAGE_PTR <PerfUSER4NodeNam>, ecx
  359. GET_MESSAGE_PTR <PerfUSER4Dsc>, edx
  360. Reg_Perf_Stat hPerfId,0,0,ebx,ecx,0,edx,_stat_USER4
  361. GET_MESSAGE_PTR <PerfUSER5Nam>, ebx
  362. GET_MESSAGE_PTR <PerfUSER5NodeNam>, ecx
  363. GET_MESSAGE_PTR <PerfUSER5Dsc>, edx
  364. Reg_Perf_Stat hPerfId,0,0,ebx,ecx,0,edx,_stat_USER5
  365. GET_MESSAGE_PTR <PerfUSER6Nam>, ebx
  366. GET_MESSAGE_PTR <PerfUSER6NodeNam>, ecx
  367. GET_MESSAGE_PTR <PerfUSER6Dsc>, edx
  368. Reg_Perf_Stat hPerfId,0,0,ebx,ecx,0,edx,_stat_USER6
  369. ;
  370. ; GET_MESSAGE_PTR <PerfTPSNam>, ebx
  371. ; GET_MESSAGE_PTR <PerfTPSNodeNam>, ecx
  372. ; GET_MESSAGE_PTR <PerfTPSDsc>, edx
  373. ; Reg_Perf_Stat hPerfId,0,<PSTF_RATE>,ebx,ecx,0,edx,_stat_Transactions
  374. ;
  375. ;
  376. ; GET_MESSAGE_PTR <PerfBReadNam>, ebx
  377. ; GET_MESSAGE_PTR <PerfBReadNodeNam>, ecx
  378. ; GET_MESSAGE_PTR <PerfBReadDsc>, edx
  379. ; Reg_Perf_Stat hPerfId,0,<PSTF_RATE>,ebx,ecx,0,edx,_stat_BRead
  380. ; mov [hStat1], eax
  381. ;
  382. ; GET_MESSAGE_PTR <PerfBWriteNam>, ebx
  383. ; GET_MESSAGE_PTR <PerfBWriteNodeNam>, ecx
  384. ; GET_MESSAGE_PTR <PerfBWriteDsc>, edx
  385. ; Reg_Perf_Stat hPerfId,0,<PSTF_RATE>,ebx,ecx,0,edx,_stat_BWrite
  386. ; mov [hStat2], eax
  387. ; mov [hStatNull],0
  388. ;
  389. ; lea eax,hStat1
  390. ; GET_MESSAGE_PTR <PerfThroughputNam>, ebx
  391. ; GET_MESSAGE_PTR <PerfThroughputNodeNam>, ecx
  392. ; GET_MESSAGE_PTR <PerfThroughputDsc>, edx
  393. ; Reg_Perf_Stat hPerfId,0,<PSTF_COMPLEX OR PSTF_RATE>,ebx,ecx,0,edx,eax
  394. ir0:
  395. clc
  396. ir1:
  397. LeaveProc
  398. Return
  399. DPLAY_Device_Init endp
  400. VXD_ICODE_ENDS
  401. END