home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v2.zip / DDKX86 / DBCSDD / INC / V8086.INC < prev    next >
Text File  |  1995-04-14  |  10KB  |  356 lines

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