home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / warptlk3.zip / TOOLKIT / INC / V8086.INC < prev    next >
Text File  |  1995-08-24  |  11KB  |  332 lines

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