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.

791 lines
24 KiB

  1. Installable Virtual Device Driver (VDD) Support For NTVDM
  2. ==========================================================
  3. Problem:
  4. --------
  5. There is a class of DOS applications which run on their
  6. own custom hardware. Generally these applications will
  7. have a pluggable card and a 16bit device driver for their
  8. card. As these cards are beyond the scope of normal PC
  9. architecture, NTVDM cannot virtualize them in a secure
  10. manner. So all such applications are not supported under
  11. NTVDM.
  12. Solution:
  13. ---------
  14. If an ISV is writing an NT native device driver for such a
  15. card, it is technically quite simple to provide the support
  16. such that the DOS application runs unmodified and in a secure
  17. fashion. The vendor has to write a Virtual Device Driver (VDD)
  18. which will virtualize the card for the DOS application by calling
  19. the native device driver.
  20. -----------------------
  21. | |
  22. | DOS Application | V86 mode
  23. | |
  24. -----------------------
  25. I/O-map | ^ |Mem-Map | DMA
  26. IO | | |IO |
  27. -------------|-----------------------------
  28. | | | |
  29. V | V V
  30. -----------------------
  31. | | DMA |
  32. | NTVDM -------| NT User mode code
  33. | |
  34. -----------------------
  35. ^ |
  36. | | Dispatches the event to VDD
  37. | V
  38. -----------------------
  39. | |
  40. | VDD | VDD is a DLL attached to NTVDM
  41. | |
  42. -----------------------
  43. ^ |
  44. | | Call the real driver
  45. -------------|-----------------------------
  46. | |
  47. | V
  48. -----------------------
  49. | |
  50. | NT Device Driver | Kernel mode
  51. | |
  52. -----------------------
  53. ^ |
  54. | | Carries out the operation with its card
  55. | V
  56. -----------------------
  57. | |
  58. | Plugged Card |
  59. | |
  60. -----------------------
  61. Following are the main work items to achieve the above solution:
  62. a. Loading the VDD
  63. b. Support for I/O mapped I/O
  64. c. Support for Memory mapped I/O
  65. d. Support for DMA operations
  66. e. Register manipulation services
  67. f. Memory accessing services
  68. g. Interrupt simulation services
  69. h. Miscelleneous services
  70. a. Loading the VDD:
  71. The system administrator will add the command lines in the
  72. \\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\CONTROL\"VirtualDeviceDrivers"
  73. section of the registry for all the VDDs to be loaded in the
  74. VDM process. The command line format is REG_MULT_SZ (i.e. ASCIIZZ).
  75. This key will laways be present and install program just need to
  76. add their VDD name.
  77. [VirtualDeviceDrivers]
  78. VDD = <full-path of the VDD1.DLL>\0<full-path of the VDD2>\0\0
  79. VDD ACTION :
  80. NTVDM will load all these VDDs from the registry at the VDM process
  81. initialization time and call their initialization routine. VDDs should
  82. make sure at this time that their respective NT device driver is
  83. present and make all the resource allocations. The VDD handle passed
  84. in this initialization routine will be the Id of the VDD when calling
  85. the VDD services as described below.
  86. b. Support for I/O mapped I/O:
  87. Following services will be provided for VDDs to deal with IO
  88. ports:
  89. BOOL VDDInstallIOHook (HANDLE, IO_PORT_RANGE, IO_PORT_HANDLERS);
  90. BOOL VDDDeInstallIOHook (HANDLE, IO_PORT_RANGE);
  91. The HANDLE is the one passed to the VDD in its DLLInit routine.
  92. Only one IO hook may be installed for a given port, all subsequent
  93. requests will fail. On DeInstalling, the default IO hook will be
  94. placed, which means no one is hooked on those IO ports. IO_PORT_HANDLERS
  95. should atleast provide a byte read and a byte write handler. In addition,
  96. word and string handlers can also be provided. In the absense of word
  97. or string handlers, these will be emulated using byte handlers.
  98. A port has to be hooked for both read and write. VDDs should not hook
  99. DMA ports as these are virtualized by NTVDM and services are provided
  100. for VDDs to access DMA.
  101. VDD Action: On an IO access (or on a series of IO accesses) the VDD
  102. can check if it needs to start the DMA. If so it can call
  103. the DMA services given in the following section. If it
  104. does'nt require the DMA or if the DMA has transfered the
  105. buffer, then the VDD can call its NT device driver to
  106. complete the desired request. (Its also possible that the
  107. VDD first requests the device driver and than using DMA
  108. services copies the contents to the VDM buffer).
  109. c. Support for Memory mapped I/O:
  110. Following services will be provided for VDDs to deal with their
  111. memory mapped addresses:
  112. BOOL VDDInstallMemoryHooks (HANDLE, ADDR_RANGE, MEMORY_HANDLER);
  113. BOOL VDDDeInstallMemoryHooks (HANDLE, ADDR_RANGE);
  114. The addr_range should be a valid range i.e. above RMSIZE and below system
  115. rom. Only one Memory hook may be installed for a given range, all subsequent
  116. requests will fail. On deinstalling the range, VDD will no longer get page
  117. fault on those ranges. Memory_handler will
  118. tell on which address the fault occured and whether it was a
  119. read or write fault. On its return from the memory handler it will be
  120. assumed that the fault was handled.
  121. A port-range will actually result in a whole page to be reserved. That
  122. means the page will not remain available to EMM for EMM page frames and
  123. UMBs.
  124. VDD Action: It can map the normal memory and let the app write to it.
  125. Later they can use the WIN32 API's or its device driver
  126. as per the case to deal the whole memory range.
  127. d. Support for DMA operations
  128. Following DMA service will be provided for the VDD:
  129. DWORD VDDRequestDMA (HANDLE, DMA_CHANNEL, BUFFER, TRANSFER_BYTES);
  130. BOOL VDDQueryDMA (HANDLE, DMA_CHANNEL, DMA_INFO_BUFFER);
  131. BOOL VDDSetDma (HANDLE, DMA_CHANNEL, INDEX, DMA_INFO_BUFFER);
  132. NTVDM will control all the DMA ports and will maintain all the
  133. information on per channel basis. There are two flavors in which
  134. a VDD can carry-out the DMA operations. It can call VDDRequestDMA
  135. and this service will interpret the DMA registers and do the
  136. DMA transfer. It should be clear at this point that this will
  137. involve two buffer copyings. For example, the VDD will ask the device
  138. driver to trasnfer some data in a buffer (allocated by VDD) then it will
  139. call this service to transfer this buffer to the address DOS application
  140. has asked for (through DMA programming).
  141. On the other hand, a VDD can collect all the DMA registers using
  142. VDDQueryDMA and figure out where the DOS application has asked the
  143. DMA to take place, in what mode and how much to transfer. Then it can
  144. call the NT device driver with same address as asked by DOS app. In this
  145. case there will be only one copying. VDD should use VDDSetDMA after
  146. such an operation to update the DMA state.
  147. e. Register manipulation services:
  148. See the reference section for details. There is a get and a set service
  149. for each V86 registers.
  150. f: Memory Accessing services:
  151. Following services are provided for Manipulating VDM's memory.
  152. PVOID GetVDMPointer(ULONG Address, ULONG Size, BOOL ProtectedMode);
  153. BOOL FreeVDMPointer(ULONG Address, ULONG Size, BOOL ProtectedMode);
  154. BOOL FlushVDMPointer(ULONG Addr,
  155. ULONG Size, PVOID Buffer, BOOL ProtectedMode);
  156. g: Interrupt simulation services
  157. Following services is provided for simulating an interrupt to the VDM.
  158. VOID VDDSimulateInterrupt (BYTE ms, BYTE line, WORD count);
  159. h. Miscellaneous Services
  160. Following services will be provided for memory allocation/deallocation.
  161. VDDAllocMem (HANDLE, ADDRESS, PAGES);
  162. VDDFreeMem (HANDLE, ADDRESS, PAGES);
  163. VDD will use VDDAllocMem when it gets a page fault on a page which
  164. it has hooked using VDDInstallMemoryHook. Later it can free this memory
  165. using VDDFreeMem. We are asking VDDs to use WIN32 API for all their needs
  166. and here also a VDD could have used VirtualAlloc and VirtualFree. The
  167. problem is that on a non-x86 machine this would'nt have worked because
  168. on such a plateform the VDM memory is under the emulator's control and it
  169. has to be told of such memory changes.
  170. Following service will be provided for VDM termination.
  171. VDDTerminateVDM (VOID);
  172. VDD will use this service to terminate the VDM. For instance if a VDD
  173. fails to allocate memory on a memory mapped IO, it may want to terminate
  174. the VDM as its state is inconsistenet.
  175. VDDs should always use these services to achieve plateform independence.
  176. ---------------- REFERENCE SECTION -------------------------
  177. /** Basic typedefs of VDD IO hooks **/
  178. typedef VOID (*PFNVDD_INB) (WORD iport,BYTE * data);
  179. typedef VOID (*PFNVDD_INW) (WORD iport,WORD * data);
  180. typedef VOID (*PFNVDD_INSB) (WORD iport,BYTE * data,WORD count);
  181. typedef VOID (*PFNVDD_INSW) (WORD iport,WORD * data,WORD count);
  182. typedef VOID (*PFNVDD_OUTB) (WORD iport,BYTE data);
  183. typedef VOID (*PFNVDD_OUTW) (WORD iport,WORD data);
  184. typedef VOID (*PFNVDD_OUTSB) (WORD iport,BYTE * data,WORD count);
  185. typedef VOID (*PFNVDD_OUTSW) (WORD iport,WORD * data,WORD count);
  186. /** Array of handlers for VDD IO hooks. **/
  187. typedef struct _VDD_IO_HANDLERS {
  188. PFNVDD_INB inb_handler;
  189. PFNVDD_INW inw_handler;
  190. PFNVDD_INSB insb_handler;
  191. PFNVDD_INSW insw_handler;
  192. PFNVDD_OUTB outb_handler;
  193. PFNVDD_OUTW outw_handler;
  194. PFNVDD_OUTSB outsb_handler;
  195. PFNVDD_OUTSW outsw_handler;
  196. } VDD_IO_HANDLERS, *PVDD_IO_HANDLERS;
  197. /** Port Range structure **/
  198. typedef struct _VDD_IO_PORTRANGE {
  199. WORD First;
  200. WORD Last;
  201. } VDD_IO_PORTRANGE, *PVDD_IO_PORTRANGE;
  202. /** Memory mapped I/O handler. **/
  203. typedef VOID (*PVDD_MEMORY_HANDLER) (PVOID FaultAddress, ULONG RWMode);
  204. /** Buffer for returning DMA information **/
  205. typedef struct _VDD_DMA_INFO {
  206. WORD addr;
  207. WORD count;
  208. WORD page;
  209. BYTE status;
  210. BYTE mode;
  211. BYTE mask;
  212. } VDD_DMA_INFO, *PVDD_DMA_INFO;
  213. /*** VDDInstallIOHook - This service is provided for VDDs to hook the
  214. * IO ports they are responsible for.
  215. *
  216. * INPUT:
  217. * hVDD ; VDD Handle
  218. * cPortRange; Number of VDD_IO_PORTRANGE structures
  219. * pPortRange; Pointer to array of VDD_IO_PORTRANGE
  220. * IOhandler : VDD handler for the ports.
  221. *
  222. * OUTPUT
  223. * SUCCESS : Returns TRUE
  224. * FAILURE : Returns FALSE
  225. * GetLastError has the extended error information.
  226. *
  227. * NOTES:
  228. * 1. The first one to hook a port will get control. Subsequent
  229. * requests will be failed. There is no concept of chaining
  230. * the hooks.
  231. *
  232. * 2. IOHandler must atleast provide a byte read and a byte write
  233. * handler. Others can be NULL.
  234. *
  235. * 3. If word or string handlers are not provided, their effect
  236. * will be emulated using byte handlers.
  237. *
  238. * 4. VDDs should not hook DMA ports. NTVDM manages it for all
  239. * the clients and services are provided to perform DMA
  240. * operations and to access and modify DMA data.
  241. *
  242. * 5. VDDs should not hook video ports as well. Such a hooking
  243. * will succeed but there is no gurantee that the IO handler will
  244. * get called.
  245. *
  246. * 6. Each Vdd is allowed to install only one set of IO hooks
  247. * at a time.
  248. *
  249. * 7. Extended Error codes:
  250. *
  251. * ERROR_ACCESS_DENIED - One of the requested ports is already hooked
  252. * ERROR_ALREADY_EXISTS - Vdd already has active IO port handlers
  253. * ERROR_OUTOFMEMORY - Insufficient resources for additional VDD
  254. * Port handler set.
  255. * ERROR_INVALID_ADDRESS - One of the IO port handlers has an invalid
  256. * address.
  257. */
  258. BOOL VDDInstallIOHook (
  259. HANDLE hVdd,
  260. WORD cPortRange,
  261. PVDD_IO_PORTRANGE pPortRange,
  262. PVDD_IO_HANDLERS pIOFn
  263. );
  264. /*** VDDDeInstallIOHook - This service is provided for VDDs to unhook the
  265. * IO ports they have hooked.
  266. *
  267. * INPUT:
  268. * hVDD : VDD Handle
  269. *
  270. * OUTPUT
  271. * None
  272. *
  273. * NOTES
  274. *
  275. * 1. On Deinstalling a hook, the defult hook is placed back on
  276. * those ports. Default hook returns 0xff on reading
  277. * and ignores the write operations.
  278. *
  279. */
  280. VOID VDDDeInstallIOHook (
  281. HANDLE hVdd,
  282. WORD cPortRange,
  283. PVDD_IO_PORTRANGE pPortRange
  284. );
  285. /*** VDDInstallMemoryHook - This service is provided for VDDs to hook the
  286. * Memory Mapped IO addresses they are resposible
  287. * for.
  288. *
  289. * INPUT:
  290. * hVDD : VDD Handle
  291. * addr : Starting linear address
  292. * count : Number of bytes
  293. * MemoryHandler : VDD handler for the memory addresses
  294. *
  295. *
  296. * OUTPUT
  297. * SUCCESS : Returns TRUE
  298. * FAILURE : Returns FALSE
  299. * GetLastError has the extended error information.
  300. *
  301. * NOTES
  302. * 1. The first one to hook an address will get the control. There
  303. * is no concept of chaining the hooks. VDD should grab the
  304. * memory range in its initialization routine. After all
  305. * the VDDs are loaded, EMM will eat up all the remaining
  306. * memory ranges for UMB support.
  307. *
  308. * 2. Memory handler will be called with the address on which the
  309. * page fault occured and with a falg telling whether it was a
  310. * read or write operation.
  311. *
  312. * 3. On returning from the hook handler it will be assumed that
  313. * the page fault was handled and the return will go back to the
  314. * VDM.
  315. *
  316. * 4. Installing a hook on a memory range will result in the
  317. * consumption of memory based upon page boundaries. The Starting
  318. * address is rounded down, and the count is rounded up to the
  319. * next page boundary. The VDD's memory hook handler will be
  320. * invoked for all addreses within the page(s) hooked. The page(s)
  321. * will be set aside as mapped reserved sections, and will no
  322. * longer be available for use by NTVDM or other VDDs. The VDD is
  323. * permitted to manipulate the memory (commit, free, etc) as needed.
  324. *
  325. * 5. After calling the MemoryHandler, NTVDM will return to the
  326. * faulting cs:ip in the 16bit app. If the VDD does'nt want
  327. * that to happen it should adjust cs:ip appropriatly by using
  328. * setCS and setIP.
  329. *
  330. * 6. Only one VDD will be allowed to have memory hooks in a page.
  331. * In other words a page si owned by a VDD exclusively.
  332. *
  333. * 7. Extended Error codes:
  334. *
  335. * ERROR_ACCESS_DENIED - One of the requested ports is already hooked
  336. * ERROR_OUTOFMEMORY - Insufficient resources.
  337. */
  338. BOOL VDDInstallMemoryHook (
  339. HANDLE hVDD,
  340. PVOID pStart,
  341. DWORD count,
  342. PVDD_MEMORY_HANDLER MemoryHandler
  343. );
  344. /*** VDDDeInstallMemoryHook - This service is provided for VDDs to unhook the
  345. * Memory Mapped IO addresses.
  346. *
  347. * INPUT:
  348. * hVDD : VDD Handle
  349. * addr : Starting linear address
  350. * count : Number of addresses
  351. *
  352. * OUTPUT
  353. * None
  354. *
  355. * NOTES
  356. * 1. On Deinstalling a hook, the memory range becomes invalid.
  357. * VDM's access of this memory range will cause a page fault.
  358. *
  359. * 2. Extended Error codes:
  360. * ERROR_INVALID_PARAMETER - One of the parameter is invalid.
  361. */
  362. BOOL VDDDeInstallMemoryHook (
  363. HANDLE hVDD,
  364. PVOID pStart,
  365. DWORD count
  366. );
  367. /*** VDDRequestDMA - This service is provided for VDDs to request a DMA
  368. * transfer.
  369. *
  370. * INPUT:
  371. * hVDD VDD Handle
  372. * iChannel DMA Channel on which the operation to take place
  373. * Buffer Buffer where to or from transfer to take place
  374. * length Transfer Count (in bytes)
  375. * If Zero, returns the Current VDMA transfer count
  376. * in bytes.
  377. *
  378. * OUTPUT
  379. * DWORD returns bytes transferred
  380. * if Zero and GetLastError is set means operation failed.
  381. * if Zero and GetLastError is clear means VDMA transfer count
  382. * was zero.
  383. *
  384. * NOTES
  385. * 1. This service is intended for those VDDs which do not want to
  386. * carry on the DMA operation on their own. Carrying on a DMA
  387. * operation involves understanding all the DMA registers and
  388. * figuring out what has to be copied, from where and how much.
  389. *
  390. * 2. This service will be slower than using VDDQueryDMA/VDDSetDMA and
  391. * doing the transfer on your own.
  392. *
  393. * 3. Extended Error codes:
  394. *
  395. * ERROR_ALREADY_EXISTS - Vdd already has active IO port handlers
  396. * ERROR_OUTOFMEMORY - Insufficient resources for additional VDD
  397. * Port handler set.
  398. * ERROR_INVALID_ADDRESS - One of the IO port handlers has an invalid
  399. * address.
  400. *
  401. */
  402. DWORD VDDRequestDMA (
  403. HANDLE hVDD,
  404. WORD iChannel,
  405. PVOID Buffer,
  406. DWORD length
  407. );
  408. /*** VDDQueryDMA - This service is provided for VDDs to collect all the DMA
  409. * data.
  410. *
  411. * INPUT:
  412. * hVDD VDD Handle
  413. * iChannel DMA Channel for which to query
  414. * Buffer Buffer where information will be returned
  415. *
  416. * OUTPUT
  417. * SUCCESS : Returns TRUE
  418. * FAILURE : Returns FALSE
  419. * GetLastError has the extended error information.
  420. *
  421. *
  422. * NOTES
  423. * 1. This service is intended for those VDD which are doing
  424. * performance critical work. These VDD can do their own DMA
  425. * transfers and avoid one extra buffer copying which is a
  426. * overhead in using VDDRequestDMA.
  427. *
  428. * 2. VDDs should use VDDSetDMA to properly update the state of
  429. * DMA after carrying on the operation.
  430. *
  431. * 3. Extended Error codes:
  432. *
  433. * ERROR_INVALID_ADDRESS - Invalid channel
  434. *
  435. */
  436. BOOL VDDQueryDMA (
  437. HANDLE hVDD,
  438. WORD iChannel,
  439. PVDD_DMA_INFO pDmaInfo
  440. );
  441. /*** VDDSetDMA - This service is provided for VDDs to set the DMA data.
  442. *
  443. * INPUT:
  444. * hVDD VDD Handle
  445. * iChannel DMA Channel for which to query
  446. * fDMA Bit Mask indicating which DMA data fields are to be set
  447. * VDD_DMA_ADDR
  448. * VDD_DMA_COUNT
  449. * VDD_DMA_PAGE
  450. * VDD_DMA_STATUS
  451. * VDD_DMA_ALL (all Above)
  452. * Buffer Buffer with DMA data
  453. *
  454. * OUTPUT
  455. * SUCCESS : Returns TRUE
  456. * FAILURE : Returns FALSE
  457. * GetLastError has the extended error information.
  458. *
  459. * NOTES
  460. *
  461. * 1. Extended Error codes:
  462. *
  463. * ERROR_INVALID_ADDRESS - Invalid channel
  464. *
  465. */
  466. BOOL VDDSetDMA (
  467. HANDLE hVDD,
  468. WORD iChannel,
  469. WORD fDMA,
  470. PVDD_DMA_INFO pDmaInfo
  471. );
  472. /** VDDAllocMem - Allocates memory at a given virtual address.
  473. *
  474. * INPUT
  475. * hVDD : VDD
  476. * Address: Address where memory is to be allocated (between 640k and 1Mb)
  477. * nBytes : Number of bytes to allocate
  478. *
  479. * OUTPUT
  480. * SUCCESS : Returns TRUE
  481. * FAILURE : Returns FALSE
  482. * GetLastError has the extended error information.
  483. * Notes:
  484. * 1. VDDs have to use this service instead of WIN32 VirtualAlloc
  485. * to be plateform independent. On non-x86 machines VDDAllocMem
  486. * tells the CPU emulator about this memory allocation.
  487. *
  488. * 2. The address will be made page aligned downwards and nBytes will
  489. * be streched upward to be page aligned.
  490. *
  491. * 3. Extended Error codes:
  492. * ERROR_OUTOFMEMORY - Insufficient memory
  493. * ERROR_INVALID_ADDRESS - Invalid address
  494. */
  495. VOID VDDAllocMem (
  496. HANDLE hVDD,
  497. PVOID Address,
  498. ULONG nBytes
  499. );
  500. /** VDDFreeMem - Free memory at a given virtual address.
  501. *
  502. * INPUT
  503. * hVDD : VDD
  504. * Address: Address where memory is to be freed
  505. * nBytes : Number of bytes to free
  506. *
  507. * OUTPUT
  508. * SUCCESS : Returns TRUE
  509. * FAILURE : Returns FALSE
  510. * GetLastError has the extended error information.
  511. *
  512. * Notes:
  513. * 1. Extended Error codes:
  514. * ERROR_INVALID_ADDRESS - Invalid address
  515. *
  516. * 2. The address will be made page aligned downwards and nBytes will
  517. * be streched upward to be page aligned.
  518. *
  519. */
  520. VOID VDDFreeMem (
  521. HANDLE hVDD,
  522. PVOID Address,
  523. ULONG nBytes
  524. );
  525. /** VDDTerminateVDM - Terminate the VDM.
  526. *
  527. * INPUT
  528. * None
  529. *
  530. * OUTPUT
  531. * None
  532. *
  533. * Notes:
  534. * 1. VDD should call this service on encoutering a fatal error,
  535. * such that VDDs state is inconsistent.
  536. *
  537. * 2. VDD can use MessageBox WIN32 API to putup a popup before
  538. * terminating the VDM.
  539. */
  540. VOID VDDTerminateVDM (
  541. VOID
  542. );
  543. /** Register Manipulation services
  544. *
  545. */
  546. ULONG getEAX(VOID);
  547. USHORT getAX(VOID);
  548. UCHAR getAL(VOID);
  549. UCHAR getAH(VOID);
  550. ULONG getEBX(VOID);
  551. USHORT getBX(VOID);
  552. UCHAR getBL(VOID);
  553. UCHAR getBH(VOID);
  554. ULONG getECX(VOID);
  555. USHORT getCX(VOID);
  556. UCHAR getCL(VOID);
  557. UCHAR getCH(VOID);
  558. ULONG getEDX(VOID);
  559. USHORT getDX(VOID);
  560. UCHAR getDL(VOID);
  561. UCHAR getDH(VOID);
  562. ULONG getESP(VOID);
  563. USHORT getSP(VOID);
  564. ULONG getEBP(VOID);
  565. USHORT getBP(VOID);
  566. ULONG getESI(VOID);
  567. USHORT getSI(VOID);
  568. ULONG getEDI(VOID);
  569. USHORT getDI(VOID);
  570. ULONG getEIP(VOID);
  571. USHORT getIP(VOID);
  572. USHORT getCS(VOID);
  573. USHORT getSS(VOID);
  574. USHORT getDS(VOID);
  575. USHORT getES(VOID);
  576. USHORT getFS(VOID);
  577. USHORT getGS(VOID);
  578. ULONG getCF(VOID);
  579. ULONG getPF(VOID);
  580. ULONG getAF(VOID);
  581. ULONG getZF(VOID);
  582. ULONG getSF(VOID);
  583. ULONG getIF(VOID);
  584. ULONG getDF(VOID);
  585. ULONG getOF(VOID);
  586. USHORT getMSW(VOID);
  587. VOID setEAX(ULONG);
  588. VOID setAX(USHORT);
  589. VOID setAH(UCHAR);
  590. VOID setAL(UCHAR);
  591. VOID setEBX(ULONG);
  592. VOID setBX(USHORT);
  593. VOID setBH(UCHAR);
  594. VOID setBL(UCHAR);
  595. VOID setECX(ULONG);
  596. VOID setCX(USHORT);
  597. VOID setCH(UCHAR);
  598. VOID setCL(UCHAR);
  599. VOID setEDX(ULONG);
  600. VOID setDX(USHORT);
  601. VOID setDH(UCHAR);
  602. VOID setDL(UCHAR);
  603. VOID setESP(ULONG);
  604. VOID setSP(USHORT);
  605. VOID setEBP(ULONG);
  606. VOID setBP(USHORT);
  607. VOID setESI(ULONG);
  608. VOID setSI(USHORT);
  609. VOID setEDI(ULONG);
  610. VOID setDI(USHORT);
  611. VOID setEIP(ULONG);
  612. VOID setIP(USHORT);
  613. VOID setCS(USHORT);
  614. VOID setSS(USHORT);
  615. VOID setDS(USHORT);
  616. VOID setES(USHORT);
  617. VOID setFS(USHORT);
  618. VOID setGS(USHORT);
  619. VOID setCF(ULONG);
  620. VOID setPF(ULONG);
  621. VOID setAF(ULONG);
  622. VOID setZF(ULONG);
  623. VOID setSF(ULONG);
  624. VOID setIF(ULONG);
  625. VOID setDF(ULONG);
  626. VOID setOF(ULONG);
  627. VOID setMSW(USHORT);
  628. /** GetVDMPointer - Findout the linear address of a given VDM address
  629. *
  630. * INPUT
  631. * Address - seg/sel:off (hi word has segment or selector and loword
  632. * is offset)
  633. * Size - Range of the pointer
  634. * ProtectMode - If protectmode == TRUE its sel:off
  635. * If protectmode == FALSE its seg:off
  636. *
  637. * OUTPUT
  638. * Returns Linear address.
  639. *
  640. * NOTES:
  641. * 1. VDDs should use this service to convert the address rather
  642. * than shifting the seg by 4 and adding the offset. This makes
  643. * them plateform independent. On non-x86 machine VDM's 0 and
  644. * the process's 0 are different and the actual adddress conversion
  645. * is provided by the CPU emulator.
  646. */
  647. PVOID GetVDMPointer(
  648. ULONG Address,
  649. ULONG Size,
  650. BOOL ProtectedMode
  651. );
  652. /** FlushVDMPointer - Flushes the contents (required because of emulator)
  653. *
  654. * INPUT
  655. * Address - seg/sel:off (hi word has segment or selector and loword
  656. * is offset)
  657. * Size - Range of the pointer
  658. * Buffer - Address returned by GetVDMPointer.
  659. * ProtectMode - If protecmeode == TRUE its sel:off
  660. * If protecmeode == FALSE its seg:off
  661. *
  662. * OUTPUT
  663. * Returns Linear address.
  664. *
  665. * NOTES:
  666. * 1. VDDs should use this service to make sure that on non-x86
  667. * machines, the CPU emulator gets a chance to flush any data
  668. * associated with a memory range.
  669. */
  670. BOOL FlushVDMPointer(
  671. ULONG Addr,
  672. ULONG Size,
  673. PVOID Buffer,
  674. BOOL ProtectedMode
  675. );
  676. /** FreeVDMPointer - Frees a pointer previously returned by GetVDMPointer
  677. *
  678. * INPUT
  679. * Address - seg/sel:off (hi word has segment or selector and loword
  680. * is offset)
  681. * Size - Range of the pointer
  682. * ProtectMode - If protecmeode == TRUE its sel:off
  683. * If protecmeode == FALSE its seg:off
  684. *
  685. * OUTPUT
  686. * None
  687. *
  688. * NOTES:
  689. * 1. FreeVDMPointer does FlushVDMPointer as well.
  690. */
  691. BOOL FreeVDMPointer(
  692. ULONG Address,
  693. ULONG Size,
  694. BOOL ProtectedMode
  695. );
  696. /** VDDSimulateInterrupt - Simulates an interrupt to the VDM.
  697. *
  698. * INPUT
  699. * ms - Is either ICA_MASTER or ICA_SLAVE as appropriate
  700. * line - Interrupt line
  701. * count - allows a batch of interrupts to be delivered but will usually
  702. * be 1.
  703. *
  704. * OUTPUT
  705. * None
  706. */
  707. VOID VDDSimulateInterrupt (
  708. BYTE ms,
  709. BYTE line,
  710. WORD count
  711. );