home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tolkit45.zip / os2tk45 / inc / v8086.inc < prev    next >
Text File  |  1999-04-30  |  9KB  |  351 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. ifdef  SMP
  75. VDHIIH_MPSAFE    EQU    000000020h
  76. endif
  77.  
  78.  
  79. ;***    VDHSetIOHookState options
  80.  
  81. SETIO_TRAP    EQU    <TRUE>
  82. SETIO_NOTRAP    EQU    <FALSE>
  83.  
  84.  
  85. ;***    I/O type flags - VDHInstallIOPort pfnOther handler
  86.  
  87. IO_TYPE_SHIFT    EQU    8
  88. IO_TYPE_MASK    EQU    000000F00h
  89. IO_TYPE_INPUT    EQU    000000100h
  90. IO_TYPE_OUTPUT    EQU    000000000h
  91. IO_TYPE_STRING    EQU    000000200h
  92. IO_TYPE_BYTE    EQU    000000400h
  93. IO_TYPE_WORD    EQU    000000000h
  94. IO_TYPE_DWORD    EQU    000000800h
  95.  
  96. IO_TYPE_ADDR32    EQU    000001000h
  97. IO_TYPE_REP    EQU    000002000h
  98. IO_TYPE_REVERSE        EQU    000008000h
  99.  
  100. IO_SEG_SHIFT    EQU    16
  101. IO_SEG_MASK    EQU    0000f0000h
  102. IO_SEG_ES    EQU    000000000h
  103. IO_SEG_CS    EQU    000010000h
  104. IO_SEG_SS    EQU    000020000h
  105. IO_SEG_DS    EQU    000030000h
  106. IO_SEG_FS    EQU    000040000h
  107. IO_SEG_GS    EQU    000050000h
  108.  
  109.  
  110. ;***    VDHCheckPagePerm and private DPMI options
  111.  
  112. VPMPG_W        EQU    000000002h    ;Writable
  113. VPMPG_U        EQU    000000004h    ;user mode accessible
  114. VPMPG_X        EQU    000000008h    ;eXecutable
  115. VPMPG_R        EQU    000000010h    ;Readable
  116. VPMPG_RESERVED    EQU    000001000h    ;Reserved for system use
  117.  
  118.  
  119.  
  120. ;***    VDHAllocHook options
  121.  
  122. VDH_CONTEXT_HOOK    EQU    0
  123. VDH_STI_HOOK    EQU    1
  124. VDH_RETURN_HOOK        EQU    2
  125. VDH_TIMER_HOOK    EQU    3
  126. VDH_BP_HOOK    EQU    4
  127.  
  128.  
  129. ;***    VDHArmContextHook options
  130.  
  131. GLOBAL_CONTEXT_HOOK    EQU    ( -1)
  132.  
  133.  
  134. ;***    VDHArmReturnHook options
  135.  
  136. VDHARH_NORMAL_RET    EQU    0
  137. VDHARH_NORMAL_IRET    EQU    1
  138. VDHARH_RECURSIVE_RET    EQU    2
  139. VDHARH_RECURSIVE_IRET    EQU    3
  140. VDHARH_CSEIP_HOOK    EQU    4
  141. VDHARH_RECURSIVE_CSEIP_HOOK    EQU    5
  142. VDHARH_ALWAYS_ARM_HOOK    EQU    080000000h
  143.  
  144.  
  145. ;***    VDHArmReturnHook recursive user stack usage
  146. ;
  147. ;    VDHARH_RECURSIVE_CSEIP_HOOK stack usage will vary depend
  148. ;    on the VDM protected mode "bitness".   If 32 bit, there
  149. ;    will be 8 bytes on the stack otherwise, 4 bytes.
  150. ;
  151.  
  152. VDHARH_RECURSIVE_STACK_USAGE    EQU    4
  153.  
  154.  
  155. ;***    VDHPushFarCall user stack usage
  156.  
  157. VDHPFC_STACK_USAGE    EQU    4
  158.  
  159.  
  160. ;***    VDHPushInt user stack usage
  161.  
  162. VDHPI_STACK_USAGE    EQU    6
  163.  
  164.  
  165. ;***    VDHPushRegs/VDHPopRegs flags
  166.  
  167. VDHREG_AX    EQU    000000001h
  168. VDHREG_BX    EQU    000000002h
  169. VDHREG_CX    EQU    000000004h
  170. VDHREG_DX    EQU    000000008h
  171. VDHREG_SI    EQU    000000010h
  172. VDHREG_DI    EQU    000000020h
  173. VDHREG_BP    EQU    000000040h
  174. VDHREG_SP    EQU    000000080h
  175. VDHREG_DS    EQU    000000100h
  176. VDHREG_ES    EQU    000000200h
  177. VDHREG_SS    EQU    000000400h
  178. VDHREG_FLAG    EQU    000000800h
  179. VDHREG_EREGS    EQU    010000000h      ;Push/Pop 32 bit values
  180. VDHREG_ALL    EQU    (VDHREG_AX  OR    VDHREG_BX  OR  \
  181.                  VDHREG_CX  OR    VDHREG_DX  OR  \
  182.                  VDHREG_SI  OR    VDHREG_DI  OR  \
  183.                  VDHREG_BP  OR    VDHREG_SP  OR  \
  184.                  VDHREG_DS  OR    VDHREG_ES  OR  \
  185.                  VDHREG_SS  OR    VDHREG_FLAG)
  186. VDHREG_GENERAL    EQU    (VDHREG_AX  OR    VDHREG_BX  OR  \
  187.                  VDHREG_CX  OR    VDHREG_DX  OR  \
  188.                  VDHREG_SI  OR    VDHREG_DI  OR  \
  189.                  VDHREG_BP  OR    VDHREG_DS  OR  \
  190.                  VDHREG_ES  OR    VDHREG_FLAG)
  191.  
  192.  
  193. ;***    CRF - Client Register Frame
  194. ;
  195. ;    The EBX register points to the CRF structure on entry
  196. ;    to I/O port handlers and VDD interrupt handlers.  VDDs
  197. ;    can retrieve or modify the client's registers with this
  198. ;    interface.
  199. ;
  200.  
  201. DefStruc ,crf_s
  202.     ULONG crf_edi
  203.     ULONG crf_esi
  204.     ULONG crf_ebp
  205.     ULONG crf_padesp
  206.     ULONG crf_ebx
  207.     ULONG crf_edx
  208.     ULONG crf_ecx
  209.     ULONG crf_eax
  210.     ULONG crf_pad2,,2
  211.     ULONG crf_eip
  212.     USHORT crf_cs
  213.     USHORT crf_padcs
  214.     ULONG crf_eflag
  215.     ULONG crf_esp
  216.     USHORT crf_ss
  217.     USHORT crf_padss
  218.     USHORT crf_es
  219.     USHORT crf_pades
  220.     USHORT crf_ds
  221.     USHORT crf_padds
  222.     USHORT crf_fs
  223.     USHORT crf_padfs
  224.     USHORT crf_gs
  225.     USHORT crf_padgs
  226.     ULONG crf_alteip           ;other modes register set
  227.     USHORT crf_altcs
  228.     USHORT crf_altpadcs
  229.     ULONG crf_alteflag
  230.     ULONG crf_altesp
  231.     USHORT crf_altss
  232.     USHORT crf_altpadss
  233.     USHORT crf_altes
  234.     USHORT crf_altpades
  235.     USHORT crf_altds
  236.     USHORT crf_altpadds
  237.     USHORT crf_altfs
  238.     USHORT crf_altpadfs
  239.     USHORT crf_altgs
  240.     USHORT crf_altpadgs
  241. EndStruc CRF
  242.  
  243. DefType PCRF,dd
  244.  
  245.  
  246.  
  247.  
  248. ; VDHReadUBuf and VDHWriteUBuf flags
  249.  
  250. VPM_FAULT_IF_RW_SET    EQU    001h
  251. VPM_FAULT_IF_SU_SET    EQU    002h
  252. VPM_SEL_PRESENT        EQU    004h
  253. VPM_SEL_WRITEABLE    EQU    008h
  254. VPM_FAULT_IF_RO        EQU    010h
  255. VPM_SEL_IS_SS    EQU    020h
  256. VPM_PROT_READ    EQU    040h
  257. VPM_PROT_WRITE    EQU    080h
  258. VPM_XCPTRET_ALT        EQU    0100h
  259. VPM_NO_SIM_EXCPT    EQU    0200h
  260.  
  261. ;***    Hook routine typedefs
  262.  
  263. HOOKENTRY BIH        <ULONG, PCRF>         ;I/O hook routines
  264. HOOKENTRY BOH        <_BYTE, ULONG, PCRF>
  265. HOOKENTRY WIH        <ULONG, PCRF>
  266. HOOKENTRY WOH        <_WORD, ULONG, PCRF>
  267. HOOKENTRY OTH        <ULONG, PULONG, ULONG, ULONG, PCRF>
  268.  
  269. DefType PBIH,dd            ;pointers to I/O hook routines
  270. DefType PBOH,dd
  271. DefType PWIH,dd
  272. DefType PWOH,dd
  273. DefType POTH,dd
  274.  
  275. HOOKENTRY FNHOOK        <PCRF>          ;hook routine
  276. DefType PFNHOOK,dd            ;pointer to hook routine
  277.  
  278. HOOKENTRY FNARM        <>           ;arm hook routine
  279. DefType PFNARM,dd            ;pointer to arm hook routine
  280.  
  281.  
  282. ;***    IOH - I/O Port Hook Entry
  283. ;
  284. ;    This is the structure for the parameter to the VDHInstallIOHook
  285. ;    service.  Only the byte input and output handlers are required.
  286. ;    A null (0) entry indicates that the type of I/O should be
  287. ;    simulated.  The structure passed by VDHInstallIOHook is
  288. ;    copied and saved away after the NULLs are replaced with the
  289. ;    addresses of the simulation routines.
  290. ;
  291.  
  292. DefStruc ,ioh_s
  293.     PBIH ioh_pbihByteInput               ;byte input handler
  294.     PBOH ioh_pbohByteOutput               ;byte output handler
  295.     PWIH ioh_pwihWordInput               ;word input handler
  296.     PWOH ioh_pwohWordOutput               ;word output handler
  297.     POTH ioh_pothOther               ;dword and string I/O handler
  298. EndStruc IOH
  299.  
  300. DefType PIOH,dd            ;pointer to IOH entry
  301.  
  302.  
  303.  
  304. ; 8086 emulation VDH services
  305.  
  306. VDHENTRY VDHInstallIOHook        <HVDM, PORT, ULONG, PIOH, FLAGS>
  307. VDHENTRY VDHRemoveIOHook        <HVDM, PORT, ULONG, PIOH>
  308. VDHENTRY VDHSetIOHookState        <HVDM, PORT, ULONG, PIOH, BOOL>
  309. VDHENTRY VDHInstallIntHook        <HVDM, ULONG, PFNHOOK, FLAGS>
  310. VDHENTRY VDHAllocHook        <ULONG, PFNARM, ULONG>
  311. VDHENTRY VDHQueryHookData        <HHOOK>
  312. VDHENTRY VDHFreeHook        <HHOOK>
  313. VDHENTRY VDHArmContextHook        <HHOOK, HVDM>
  314. VDHENTRY VDHArmSTIHook        <HHOOK, HVDM>
  315. VDHENTRY VDHArmReturnHook        <HHOOK, ULONG>
  316. VDHENTRY VDHArmBPHook        <HHOOK>
  317. VDHENTRY VDHPushInt        <ULONG>
  318. VDHENTRY VDHPopInt        <VOID>
  319. VDHENTRY VDHPushRegs        <FLAGS>
  320. VDHENTRY VDHPopRegs        <FLAGS>
  321. VDHENTRY VDHPushStack        <ULONG,PVOID>
  322. VDHENTRY VDHPopStack        <ULONG,PVOID>
  323. VDHENTRY VDHSetA20        <BOOL>
  324. VDHENTRY VDHQueryA20        <VOID>
  325. VDHENTRY VDHSetFlags        <ULONG>
  326. VDHENTRY VDHGetFlags        <PULONG>
  327. VDHENTRY VDHSwitchToV86        <VOID>
  328. VDHENTRY VDHSwitchToVPM        <VOID>
  329. VDHENTRY VDHCheckVPMIntVector        <ULONG>
  330. VDHENTRY VDHCheckVPMExcept        <ULONG>
  331. VDHENTRY VDHGetVPMIntVector        <ULONG,PFPFN>
  332. VDHENTRY VDHGetSelBase        <SEL,PULONG>
  333. VDHENTRY VDHChangeVPMIF        <BOOL>
  334. VDHENTRY VDHReadUBuf        <PVOID,ULONG,SEL,PULONG,ULONG>
  335. VDHENTRY VDHWriteUBuf        <PVOID,ULONG,SEL,PULONG,ULONG>
  336. VDHENTRY VDHCheckPagePerm        <ULONG,PVOID,ULONG,ULONG>
  337. VDHENTRY VDHRaiseException        <ULONG,ULONG,ULONG>
  338. VDHENTRY VDHStartHWInt        <BOOL>
  339. VDHENTRY VDHGetVPMExcept        <ULONG,PFPFN,PBYTE>
  340. VDHENTRY VDHProbeUBuf        <SEL,ULONG,ULONG,ULONG>
  341. VDHENTRY VDHPrepVPMIret        <HHOOK>
  342. VDHENTRY VDHPopVPMFarRet        <VOID>
  343. VDHENTRY VDHRegisterAPI        <PSZ, PFNHOOK, PFNHOOK>
  344.  
  345. VDHENTRY VDHSetVPMIntVector   <ULONG, ULONG, ULONG>
  346. VDHENTRY VDHSetVPMExcept  <ULONG, ULONG, ULONG, _BYTE>
  347. VDHENTRY VDHPushFarCall        <ULONG, ULONG>
  348. VDHENTRY VDHArmVPMBPHook        <HHOOK>
  349. VDHENTRY VDHEndUseVPMStack        <VOID>
  350. VDHENTRY VDHBeginUseVPMStack        <VOID>
  351.