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.

309 lines
5.8 KiB

  1. /*
  2. * Copyright (C) Microsoft Corporation, 1990-1999
  3. * nt_vdd.h
  4. *
  5. * VDD services exports and defines
  6. *
  7. */
  8. #ifndef _NT_VDD
  9. #define _NT_VDD
  10. #if _MSC_VER > 1000
  11. #pragma once
  12. #endif
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. /**
  17. * IO port service prototypes and data structure definitions
  18. **/
  19. /** Basic typedefs of VDD IO hooks **/
  20. typedef VOID (*PFNVDD_INB) (WORD iport,BYTE * data);
  21. typedef VOID (*PFNVDD_INW) (WORD iport,WORD * data);
  22. typedef VOID (*PFNVDD_INSB) (WORD iport,BYTE * data,WORD count);
  23. typedef VOID (*PFNVDD_INSW) (WORD iport,WORD * data,WORD count);
  24. typedef VOID (*PFNVDD_OUTB) (WORD iport,BYTE data);
  25. typedef VOID (*PFNVDD_OUTW) (WORD iport,WORD data);
  26. typedef VOID (*PFNVDD_OUTSB) (WORD iport,BYTE * data,WORD count);
  27. typedef VOID (*PFNVDD_OUTSW) (WORD iport,WORD * data,WORD count);
  28. /** Array of handlers for VDD IO hooks. **/
  29. typedef struct _VDD_IO_HANDLERS {
  30. PFNVDD_INB inb_handler;
  31. PFNVDD_INW inw_handler;
  32. PFNVDD_INSB insb_handler;
  33. PFNVDD_INSW insw_handler;
  34. PFNVDD_OUTB outb_handler;
  35. PFNVDD_OUTW outw_handler;
  36. PFNVDD_OUTSB outsb_handler;
  37. PFNVDD_OUTSW outsw_handler;
  38. } VDD_IO_HANDLERS, *PVDD_IO_HANDLERS;
  39. /** Port Range structure **/
  40. typedef struct _VDD_IO_PORTRANGE {
  41. WORD First;
  42. WORD Last;
  43. } VDD_IO_PORTRANGE, *PVDD_IO_PORTRANGE;
  44. BOOL VDDInstallIOHook (
  45. HANDLE hVDD,
  46. WORD cPortRange,
  47. PVDD_IO_PORTRANGE pPortRange,
  48. PVDD_IO_HANDLERS IOhandler
  49. );
  50. VOID VDDDeInstallIOHook (
  51. HANDLE hVdd,
  52. WORD cPortRange,
  53. PVDD_IO_PORTRANGE pPortRange
  54. );
  55. WORD VDDReserveIrqLine (
  56. HANDLE hVdd,
  57. WORD IrqLine
  58. );
  59. BOOL VDDReleaseIrqLine (
  60. HANDLE hVdd,
  61. WORD IrqLine
  62. );
  63. /**
  64. * DMA service prototypes and data structure definitions
  65. **/
  66. /** Buffer definition for returning DMA information **/
  67. typedef struct _VDD_DMA_INFO {
  68. WORD addr;
  69. WORD count;
  70. WORD page;
  71. BYTE status;
  72. BYTE mode;
  73. BYTE mask;
  74. } VDD_DMA_INFO, *PVDD_DMA_INFO;
  75. /** bits for querying the DMA information **/
  76. #define VDD_DMA_ADDR 0x01
  77. #define VDD_DMA_COUNT 0x02
  78. #define VDD_DMA_PAGE 0x04
  79. #define VDD_DMA_STATUS 0x08
  80. #define VDD_DMA_ALL VDD_DMA_ADDR | VDD_DMA_COUNT | VDD_DMA_PAGE | VDD_DMA_STATUS
  81. DWORD VDDRequestDMA (
  82. HANDLE hVDD,
  83. WORD iChannel,
  84. PVOID Buffer,
  85. DWORD length
  86. );
  87. BOOL VDDSetDMA (
  88. HANDLE hVDD,
  89. WORD iChannel,
  90. WORD fDMA,
  91. PVDD_DMA_INFO Buffer
  92. );
  93. BOOL VDDQueryDMA (
  94. HANDLE hVDD,
  95. WORD iChannel,
  96. PVDD_DMA_INFO pDmaInfo
  97. );
  98. /**
  99. * Memory mapped I/O service prototypes and data structure definitions
  100. **/
  101. typedef VOID (*PVDD_MEMORY_HANDLER) (PVOID FaultAddress, ULONG RWMode);
  102. BOOL VDDInstallMemoryHook (
  103. HANDLE hVDD,
  104. PVOID pStart,
  105. DWORD count,
  106. PVDD_MEMORY_HANDLER MemoryHandler
  107. );
  108. BOOL VDDDeInstallMemoryHook (
  109. HANDLE hVDD,
  110. PVOID pStart,
  111. DWORD count
  112. );
  113. BOOL VDDAllocMem(
  114. HANDLE hVDD,
  115. PVOID Address,
  116. DWORD Size
  117. );
  118. BOOL VDDFreeMem(
  119. HANDLE hVDD,
  120. PVOID Address,
  121. DWORD Size
  122. );
  123. /**
  124. * Misc. service prototypes and data structure definitions
  125. **/
  126. BOOL VDDIncludeMem(
  127. HANDLE hVDD,
  128. PVOID Address,
  129. DWORD Size
  130. );
  131. VOID VDDTerminateVDM();
  132. /** Basic typedefs of VDD User hooks **/
  133. typedef VOID (*PFNVDD_UCREATE) (USHORT DosPDB);
  134. typedef VOID (*PFNVDD_UTERMINATE) (USHORT DosPDB);
  135. typedef VOID (*PFNVDD_UBLOCK) (VOID);
  136. typedef VOID (*PFNVDD_URESUME) (VOID);
  137. /** Array of handlers for VDD User hooks. **/
  138. typedef struct _VDD_USER_HANDLERS {
  139. HANDLE hvdd;
  140. PFNVDD_UCREATE ucr_handler;
  141. PFNVDD_UTERMINATE uterm_handler;
  142. PFNVDD_UBLOCK ublock_handler;
  143. PFNVDD_URESUME uresume_handler;
  144. struct _VDD_USER_HANDLERS *next;
  145. } VDD_USER_HANDLERS, *PVDD_USER_HANDLERS;
  146. /** Function prototypes **/
  147. BOOL VDDInstallUserHook (
  148. HANDLE hVDD,
  149. PFNVDD_UCREATE Ucr_Handler,
  150. PFNVDD_UTERMINATE Uterm_Handler,
  151. PFNVDD_UBLOCK Ublock_handler,
  152. PFNVDD_URESUME Uresume_handler
  153. );
  154. BOOL VDDDeInstallUserHook (
  155. HANDLE hVdd
  156. );
  157. VOID VDDTerminateUserHook(USHORT DosPDB);
  158. VOID VDDCreateUserHook(USHORT DosPDB);
  159. VOID VDDBlockUserHook(VOID);
  160. VOID VDDResumeUserHook(VOID);
  161. VOID VDDSimulate16(VOID);
  162. SHORT VDDAllocateDosHandle(ULONG pPDB, PVOID* ppSFT, PVOID* ppJFT);
  163. VOID VDDAssociateNtHandle(PVOID pSFT, HANDLE h32File, WORD wAccess);
  164. BOOL VDDReleaseDosHandle (ULONG pPDB, SHORT hFile);
  165. HANDLE VDDRetrieveNtHandle (ULONG pPDB, SHORT hFile, PVOID* ppSFT, PVOID* ppJFT);
  166. VOID
  167. VdmTraceEvent(
  168. USHORT Type,
  169. USHORT wData,
  170. ULONG lData
  171. );
  172. #if DBG
  173. #define VDM_TRACE(Type, wData, lData) VdmTraceEvent(Type, wData, lData)
  174. #else
  175. #define VDM_TRACE(Type, wData, lData) TRUE
  176. #endif
  177. typedef enum {
  178. VDM_V86,
  179. VDM_PM
  180. } VDM_MODE;
  181. typedef enum {
  182. VDM_NO_ERROR,
  183. VDM_ERROR_INVALID_BUFFER_SIZE,
  184. VDM_ERROR_INVALID_FUNCTION,
  185. } VDM_ERROR_TYPE;
  186. typedef enum {
  187. VDM_GET_TICK_COUNT,
  188. VDM_GET_TIMER0_INITIAL_COUNT,
  189. VDM_GET_LAST_UPDATED_TIMER0_COUNT,
  190. VDM_LATCH_TIMER0_COUNT,
  191. VDM_SET_NEXT_TIMER0_COUNT,
  192. } VDM_INFO_TYPE;
  193. #ifndef MSW_PE
  194. #define MSW_PE 0x1
  195. #endif
  196. #define getMODE() ((getMSW() & MSW_PE) ? VDM_PM : VDM_V86)
  197. PVOID
  198. VdmMapFlat(
  199. USHORT selector,
  200. ULONG offset,
  201. VDM_MODE mode
  202. );
  203. #ifdef _X86_
  204. #define VdmUnmapFlat(sel, off, buffer, mode) TRUE
  205. #define VdmFlushCache(sel, off, len, mode) TRUE
  206. #else
  207. BOOL
  208. VdmUnmapFlat(
  209. USHORT selector,
  210. ULONG offset,
  211. PVOID buffer,
  212. VDM_MODE mode
  213. );
  214. BOOL
  215. VdmFlushCache(
  216. USHORT selector,
  217. ULONG offset,
  218. ULONG length,
  219. VDM_MODE mode
  220. );
  221. #endif
  222. BOOL
  223. VdmParametersInfo(
  224. VDM_INFO_TYPE infotype,
  225. PVOID pBuffer,
  226. ULONG cbBufferSize
  227. );
  228. VDM_INFO_TYPE
  229. VdmGetParametersInfoError(
  230. VOID
  231. );
  232. #ifdef __cplusplus
  233. }
  234. #endif
  235. #endif // ifndef _NT_VDD