home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / odtlktv4.zip / ODTLKT / TOOLKIT / INC / V8086.INC < prev    next >
Text File  |  1995-12-04  |  9KB  |  348 lines

  1. ;***    V8086.INC
  2. ;
  3. ;
  4. ;    Title:
  5. ;
  6. ;    8086 Emulation Export Include File
  7. ;
  8. ;    Description:
  9. ;
  10. ;    Contains the exported structures, defines and VDH
  11. ;    function prototypes for 8086 emulation.
  12. ;
  13. ;    MODIFICATION HISTORY
  14. ;    --------------------
  15. ;    05/07/91 RCW  Changed all occurences of the single line comment
  16. ;              notation to the standard notation to allow users to
  17. ;              maintain ANSI compatibility.  This is in response to
  18. ;              PTR B718526.  All future updates to this and all other
  19. ;              header files should use the standard commenting format.
  20. ;  73541 10/20/93 ChangeTeam  Added em86Is32Sel.
  21. ;  93273 12 AUG 1994 ChangeTeam Added VDHGetFlags(PULONG)
  22. ;
  23.  
  24.  
  25.  
  26.  
  27. ;***    Low memory defines - used by VBIOS
  28.  
  29. IVT_START    EQU    0    ;Interrupt vector table start
  30. IVT_LEN        EQU    0400h    ;    "        "        "   length 
  31.  
  32.  
  33. ;***    flVdmStatus flags
  34.  
  35. VDM_STATUS_VPM_32    EQU    000000001h    ;32 bit DPMI app
  36. VDM_STATUS_VPM_32_BIT    EQU    0
  37. VDM_STATUS_VPM_APP    EQU    000000002h    ;DPMI app started
  38. VDM_STATUS_VPM_APP_BIT    EQU    1
  39. VDM_STATUS_VPM_EXEC    EQU    000000004h    ;in VDM protected mode
  40. VDM_STATUS_VPM_EXEC_BIT        EQU    2
  41. VDM_STATUS_VPM_TRAPMODE        EQU    000000008h    ;V86 mode at kernel entry?
  42. VDM_STATUS_VPM_TRAP_BIT        EQU    3
  43. VDM_STATUS_VPM_IF_FLAG    EQU    000000010h    ;Virtual IF flag
  44. VDM_STATUS_VPM_IF_BIT    EQU    4
  45. VDM_STATUS_VPM_08_HOOK    EQU    000000020h    ;protect 08h hooked?
  46. VDM_STATUS_VPM_08_BIT    EQU    5
  47. VDM_STATUS_VPM_1C_HOOK    EQU    000000040h    ;protect 1Ch hooked?
  48. VDM_STATUS_VPM_1C_BIT    EQU    6
  49. VDM_STATUS_VPM_PERM    EQU    000000080h    ;protected mode allowed?
  50. VDM_STATUS_VPM_PERM_BIT        EQU    7
  51. VDM_STATUS_VPM_XDOS    EQU    000000100h    ;DOS API Extension active?
  52. VDM_STATUS_VPM_XDOS_BIT        EQU    8
  53. VDM_STATUS_VPM_TERM    EQU    000000200h    ;VDM terminating?
  54. VDM_STATUS_VPM_TERM_BIT        EQU    9
  55. VDM_STATUS_VPM_EM_FLAG    EQU    000000400h    ;Virtual EM flag
  56. VDM_STATUS_VPM_EM_BIT    EQU    10
  57. VDM_STATUS_VPM_TASK_SW    EQU    000000800h    ;Task switch for HW int
  58. VDM_STATUS_VPM_TASK_BIT        EQU    11
  59. VDM_STATUS_VME    EQU    000001000h    ;Virt Mode Ext present
  60. VDM_STATUS_VME_BIT    EQU    12
  61.  
  62.  
  63. ;***    VDHInstallIntHook options
  64.  
  65. VDH_ASM_HOOK    EQU    000000001h
  66.  
  67.  
  68. ;***    VDHInstallIOHook options
  69.  
  70. VDHIIH_ASM_HOOK        EQU    <VDH_ASM_HOOK>
  71. VDHIIH_ALWAYS_TRAP    EQU    000000002h
  72. VDHIIH_NO_SIMULATE    EQU    000000004h
  73. VDHIIH_IGNORE    EQU    000000010h
  74.  
  75.  
  76. ;***    VDHSetIOHookState options
  77.  
  78. SETIO_TRAP    EQU    <TRUE>
  79. SETIO_NOTRAP    EQU    <FALSE>
  80.  
  81.  
  82. ;***    I/O type flags - VDHInstallIOPort pfnOther handler
  83.  
  84. IO_TYPE_SHIFT    EQU    8
  85. IO_TYPE_MASK    EQU    000000F00h
  86. IO_TYPE_INPUT    EQU    000000100h
  87. IO_TYPE_OUTPUT    EQU    000000000h
  88. IO_TYPE_STRING    EQU    000000200h
  89. IO_TYPE_BYTE    EQU    000000400h
  90. IO_TYPE_WORD    EQU    000000000h
  91. IO_TYPE_DWORD    EQU    000000800h
  92.  
  93. IO_TYPE_ADDR32    EQU    000001000h
  94. IO_TYPE_REP    EQU    000002000h
  95. IO_TYPE_REVERSE        EQU    000008000h
  96.  
  97. IO_SEG_SHIFT    EQU    16
  98. IO_SEG_MASK    EQU    0000f0000h
  99. IO_SEG_ES    EQU    000000000h
  100. IO_SEG_CS    EQU    000010000h
  101. IO_SEG_SS    EQU    000020000h
  102. IO_SEG_DS    EQU    000030000h
  103. IO_SEG_FS    EQU    000040000h
  104. IO_SEG_GS    EQU    000050000h
  105.  
  106.  
  107. ;***    VDHCheckPagePerm and private DPMI options
  108.  
  109. VPMPG_W        EQU    000000002h    ;Writable
  110. VPMPG_U        EQU    000000004h    ;user mode accessible
  111. VPMPG_X        EQU    000000008h    ;eXecutable
  112. VPMPG_R        EQU    000000010h    ;Readable
  113. VPMPG_RESERVED    EQU    000001000h    ;Reserved for system use
  114.  
  115.  
  116.  
  117. ;***    VDHAllocHook options
  118.  
  119. VDH_CONTEXT_HOOK    EQU    0
  120. VDH_STI_HOOK    EQU    1
  121. VDH_RETURN_HOOK        EQU    2
  122. VDH_TIMER_HOOK    EQU    3
  123. VDH_BP_HOOK    EQU    4
  124.  
  125.  
  126. ;***    VDHArmContextHook options
  127.  
  128. GLOBAL_CONTEXT_HOOK    EQU    ( -1)
  129.  
  130.  
  131. ;***    VDHArmReturnHook options
  132.  
  133. VDHARH_NORMAL_RET    EQU    0
  134. VDHARH_NORMAL_IRET    EQU    1
  135. VDHARH_RECURSIVE_RET    EQU    2
  136. VDHARH_RECURSIVE_IRET    EQU    3
  137. VDHARH_CSEIP_HOOK    EQU    4
  138. VDHARH_RECURSIVE_CSEIP_HOOK    EQU    5
  139. VDHARH_ALWAYS_ARM_HOOK    EQU    080000000h
  140.  
  141.  
  142. ;***    VDHArmReturnHook recursive user stack usage
  143. ;
  144. ;    VDHARH_RECURSIVE_CSEIP_HOOK stack usage will vary depend
  145. ;    on the VDM protected mode "bitness".   If 32 bit, there
  146. ;    will be 8 bytes on the stack otherwise, 4 bytes.
  147. ;
  148.  
  149. VDHARH_RECURSIVE_STACK_USAGE    EQU    4
  150.  
  151.  
  152. ;***    VDHPushFarCall user stack usage
  153.  
  154. VDHPFC_STACK_USAGE    EQU    4
  155.  
  156.  
  157. ;***    VDHPushInt user stack usage
  158.  
  159. VDHPI_STACK_USAGE    EQU    6
  160.  
  161.  
  162. ;***    VDHPushRegs/VDHPopRegs flags
  163.  
  164. VDHREG_AX    EQU    000000001h
  165. VDHREG_BX    EQU    000000002h
  166. VDHREG_CX    EQU    000000004h
  167. VDHREG_DX    EQU    000000008h
  168. VDHREG_SI    EQU    000000010h
  169. VDHREG_DI    EQU    000000020h
  170. VDHREG_BP    EQU    000000040h
  171. VDHREG_SP    EQU    000000080h
  172. VDHREG_DS    EQU    000000100h
  173. VDHREG_ES    EQU    000000200h
  174. VDHREG_SS    EQU    000000400h
  175. VDHREG_FLAG    EQU    000000800h
  176. VDHREG_EREGS    EQU    010000000h      ;Push/Pop 32 bit values
  177. VDHREG_ALL    EQU    (VDHREG_AX  OR    VDHREG_BX  OR  \
  178.                  VDHREG_CX  OR    VDHREG_DX  OR  \
  179.                  VDHREG_SI  OR    VDHREG_DI  OR  \
  180.                  VDHREG_BP  OR    VDHREG_SP  OR  \
  181.                  VDHREG_DS  OR    VDHREG_ES  OR  \
  182.                  VDHREG_SS  OR    VDHREG_FLAG)
  183. VDHREG_GENERAL    EQU    (VDHREG_AX  OR    VDHREG_BX  OR  \
  184.                  VDHREG_CX  OR    VDHREG_DX  OR  \
  185.                  VDHREG_SI  OR    VDHREG_DI  OR  \
  186.                  VDHREG_BP  OR    VDHREG_DS  OR  \
  187.                  VDHREG_ES  OR    VDHREG_FLAG)
  188.  
  189.  
  190. ;***    CRF - Client Register Frame
  191. ;
  192. ;    The EBX register points to the CRF structure on entry
  193. ;    to I/O port handlers and VDD interrupt handlers.  VDDs
  194. ;    can retrieve or modify the client's registers with this
  195. ;    interface.
  196. ;
  197.  
  198. DefStruc ,crf_s
  199.     ULONG crf_edi
  200.     ULONG crf_esi
  201.     ULONG crf_ebp
  202.     ULONG crf_padesp
  203.     ULONG crf_ebx
  204.     ULONG crf_edx
  205.     ULONG crf_ecx
  206.     ULONG crf_eax
  207.     ULONG crf_pad2,,2
  208.     ULONG crf_eip
  209.     USHORT crf_cs
  210.     USHORT crf_padcs
  211.     ULONG crf_eflag
  212.     ULONG crf_esp
  213.     USHORT crf_ss
  214.     USHORT crf_padss
  215.     USHORT crf_es
  216.     USHORT crf_pades
  217.     USHORT crf_ds
  218.     USHORT crf_padds
  219.     USHORT crf_fs
  220.     USHORT crf_padfs
  221.     USHORT crf_gs
  222.     USHORT crf_padgs
  223.     ULONG crf_alteip           ;other modes register set
  224.     USHORT crf_altcs
  225.     USHORT crf_altpadcs
  226.     ULONG crf_alteflag
  227.     ULONG crf_altesp
  228.     USHORT crf_altss
  229.     USHORT crf_altpadss
  230.     USHORT crf_altes
  231.     USHORT crf_altpades
  232.     USHORT crf_altds
  233.     USHORT crf_altpadds
  234.     USHORT crf_altfs
  235.     USHORT crf_altpadfs
  236.     USHORT crf_altgs
  237.     USHORT crf_altpadgs
  238. EndStruc CRF
  239.  
  240. DefType PCRF,dd
  241.  
  242.  
  243.  
  244.  
  245. ; VDHReadUBuf and VDHWriteUBuf flags
  246.  
  247. VPM_FAULT_IF_RW_SET    EQU    001h
  248. VPM_FAULT_IF_SU_SET    EQU    002h
  249. VPM_SEL_PRESENT        EQU    004h
  250. VPM_SEL_WRITEABLE    EQU    008h
  251. VPM_FAULT_IF_RO        EQU    010h
  252. VPM_SEL_IS_SS    EQU    020h
  253. VPM_PROT_READ    EQU    040h
  254. VPM_PROT_WRITE    EQU    080h
  255. VPM_XCPTRET_ALT        EQU    0100h
  256. VPM_NO_SIM_EXCPT    EQU    0200h
  257.  
  258. ;***    Hook routine typedefs
  259.  
  260. HOOKENTRY BIH        <ULONG, PCRF>         ;I/O hook routines
  261. HOOKENTRY BOH        <_BYTE, ULONG, PCRF>
  262. HOOKENTRY WIH        <ULONG, PCRF>
  263. HOOKENTRY WOH        <_WORD, ULONG, PCRF>
  264. HOOKENTRY OTH        <ULONG, PULONG, ULONG, ULONG, PCRF>
  265.  
  266. DefType PBIH,dd            ;pointers to I/O hook routines
  267. DefType PBOH,dd
  268. DefType PWIH,dd
  269. DefType PWOH,dd
  270. DefType POTH,dd
  271.  
  272. HOOKENTRY FNHOOK        <PCRF>          ;hook routine
  273. DefType PFNHOOK,dd            ;pointer to hook routine
  274.  
  275. HOOKENTRY FNARM        <>           ;arm hook routine
  276. DefType PFNARM,dd            ;pointer to arm hook routine
  277.  
  278.  
  279. ;***    IOH - I/O Port Hook Entry
  280. ;
  281. ;    This is the structure for the parameter to the VDHInstallIOHook
  282. ;    service.  Only the byte input and output handlers are required.
  283. ;    A null (0) entry indicates that the type of I/O should be
  284. ;    simulated.  The structure passed by VDHInstallIOHook is
  285. ;    copied and saved away after the NULLs are replaced with the
  286. ;    addresses of the simulation routines.
  287. ;
  288.  
  289. DefStruc ,ioh_s
  290.     PBIH ioh_pbihByteInput               ;byte input handler
  291.     PBOH ioh_pbohByteOutput               ;byte output handler
  292.     PWIH ioh_pwihWordInput               ;word input handler
  293.     PWOH ioh_pwohWordOutput               ;word output handler
  294.     POTH ioh_pothOther               ;dword and string I/O handler
  295. EndStruc IOH
  296.  
  297. DefType PIOH,dd            ;pointer to IOH entry
  298.  
  299.  
  300.  
  301. ; 8086 emulation VDH services
  302.  
  303. VDHENTRY VDHInstallIOHook        <HVDM, PORT, ULONG, PIOH, FLAGS>
  304. VDHENTRY VDHRemoveIOHook        <HVDM, PORT, ULONG, PIOH>
  305. VDHENTRY VDHSetIOHookState        <HVDM, PORT, ULONG, PIOH, BOOL>
  306. VDHENTRY VDHInstallIntHook        <HVDM, ULONG, PFNHOOK, FLAGS>
  307. VDHENTRY VDHAllocHook        <ULONG, PFNARM, ULONG>
  308. VDHENTRY VDHQueryHookData        <HHOOK>
  309. VDHENTRY VDHFreeHook        <HHOOK>
  310. VDHENTRY VDHArmContextHook        <HHOOK, HVDM>
  311. VDHENTRY VDHArmSTIHook        <HHOOK, HVDM>
  312. VDHENTRY VDHArmReturnHook        <HHOOK, ULONG>
  313. VDHENTRY VDHArmBPHook        <HHOOK>
  314. VDHENTRY VDHPushInt        <ULONG>
  315. VDHENTRY VDHPopInt        <VOID>
  316. VDHENTRY VDHPushRegs        <FLAGS>
  317. VDHENTRY VDHPopRegs        <FLAGS>
  318. VDHENTRY VDHPushStack        <ULONG,PVOID>
  319. VDHENTRY VDHPopStack        <ULONG,PVOID>
  320. VDHENTRY VDHSetA20        <BOOL>
  321. VDHENTRY VDHQueryA20        <VOID>
  322. VDHENTRY VDHSetFlags        <ULONG>
  323. VDHENTRY VDHGetFlags        <PULONG>
  324. VDHENTRY VDHSwitchToV86        <VOID>
  325. VDHENTRY VDHSwitchToVPM        <VOID>
  326. VDHENTRY VDHCheckVPMIntVector        <ULONG>
  327. VDHENTRY VDHCheckVPMExcept        <ULONG>
  328. VDHENTRY VDHGetVPMIntVector        <ULONG,PFPFN>
  329. VDHENTRY VDHGetSelBase        <SEL,PULONG>
  330. VDHENTRY VDHChangeVPMIF        <BOOL>
  331. VDHENTRY VDHReadUBuf        <PVOID,ULONG,SEL,PULONG,ULONG>
  332. VDHENTRY VDHWriteUBuf        <PVOID,ULONG,SEL,PULONG,ULONG>
  333. VDHENTRY VDHCheckPagePerm        <ULONG,PVOID,ULONG,ULONG>
  334. VDHENTRY VDHRaiseException        <ULONG,ULONG,ULONG>
  335. VDHENTRY VDHStartHWInt        <BOOL>
  336. VDHENTRY VDHGetVPMExcept        <ULONG,PFPFN,PBYTE>
  337. VDHENTRY VDHProbeUBuf        <SEL,ULONG,ULONG,ULONG>
  338. VDHENTRY VDHPrepVPMIret        <HHOOK>
  339. VDHENTRY VDHPopVPMFarRet        <VOID>
  340. VDHENTRY VDHRegisterAPI        <PSZ, PFNHOOK, PFNHOOK>
  341.  
  342. VDHENTRY VDHSetVPMIntVector   <ULONG, ULONG, ULONG>
  343. VDHENTRY VDHSetVPMExcept  <ULONG, ULONG, ULONG, _BYTE>
  344. VDHENTRY VDHPushFarCall        <ULONG, ULONG>
  345. VDHENTRY VDHArmVPMBPHook        <HHOOK>
  346. VDHENTRY VDHEndUseVPMStack        <VOID>
  347. VDHENTRY VDHBeginUseVPMStack        <VOID>
  348.