home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v1.zip / DDKX86 / H / MVDM.H < prev    next >
C/C++ Source or Header  |  1995-04-14  |  9KB  |  342 lines

  1. /*DDK*************************************************************************/
  2. /*                                                                           */
  3. /* COPYRIGHT (C) Microsoft Corporation, 1989                                 */
  4. /* COPYRIGHT    Copyright (C) 1995 IBM Corporation                           */
  5. /*                                                                           */
  6. /*    The following IBM OS/2 WARP source code is provided to you solely for  */
  7. /*    the purpose of assisting you in your development of OS/2 WARP device   */
  8. /*    drivers. You may use this code in accordance with the IBM License      */
  9. /*    Agreement provided in the IBM Device Driver Source Kit for OS/2. This  */
  10. /*    Copyright statement may not be removed.                                */
  11. /*                                                                           */
  12. /*****************************************************************************/
  13. /*static char *SCCSID = "@(#)mvdm.h    6.1 90/11/15";*/
  14. /***    MVDM.H
  15.  *
  16.  *    SCCSID = @(#)mvdm.h   13.28 90/09/24
  17.  *
  18.  *    MVDM constants and types
  19.  *
  20.  *    Include file hierarchy:
  21.  *
  22.  *      mvdm.h
  23.  *        basemac.h
  24.  *        basedef.h
  25.  *        vdmprop.h
  26.  *        vdmm.h
  27.  *        v8086.h
  28.  *        vdos.h
  29.  *        vpic.h
  30.  *        vdmbios.h
  31.  *        vkbd.h
  32.  *        vlpt.h
  33.  *        vdma.h
  34.  *
  35.  *    By default, ALL portions of ALL include files are included (ie,
  36.  *    INCL_ALL is assumed).
  37.  *
  38.  *    To control what is included, use INCL_NONE and then select from
  39.  *    the following:
  40.  *
  41.  *        INCL_DEF
  42.  *        INCL_MI        BUGBUG 22-Feb-89 JeffPar:  NOT included by default
  43.  *        INCL_TYPES
  44.  *        INCL_MVDMTYPES
  45.  *        INCL_SSTODS
  46.  *        INCL_ROMBIOS
  47.  *        INCL_PAGE
  48.  *        INCL_VDH
  49.  *        INCL_VDHVPIC
  50.  *        INCL_VDHALL
  51.  *        INCL_VDDHELPERS
  52.  *        INCL_VDHVKBD
  53.  *        INCL_VDHVLPT
  54.  *        INCL_VDHVDMA
  55.  *
  56.  *
  57.  *    MODIFICATION HISTORY
  58.  *    10/11/88    JTP        Created.
  59.  *    12/02/88    SB        Deleted VDMINFO include.
  60.  *    12/04/88    JTP        Moved MVDM-specific definitions to here.
  61.  */
  62.  
  63.  
  64. #ifndef INCL_NONE
  65. #define INCL_DEF
  66. #define INCL_TYPES
  67. #define INCL_MVDMTYPES
  68. #define INCL_SSTODS
  69. #define INCL_ROMBIOS
  70. #define INCL_PAGE
  71. #define INCL_VDHALL
  72. #define INCL_VDDHELPERS
  73. #define INCL_VDHVKBD
  74. #define INCL_VDHVLPT
  75. #define INCL_VDHVDMA
  76. #endif
  77.  
  78. #ifdef    INCL_VDHALL        // if all VDH services, set defines
  79. #define INCL_VDH
  80. #define INCL_VDHVPIC
  81. #define INCL_VDHVKBD
  82. #define INCL_VDHVLPT
  83. #define INCL_VDHVDMA
  84. #endif
  85.  
  86. #ifdef    INCL_VDH        // VDH services require MVDM types
  87. #define INCL_MVDMTYPES
  88. #endif
  89.  
  90. #ifdef    INCL_VDHVPIC        // VDH services require MVDM types
  91. #define INCL_MVDMTYPES
  92. #endif
  93.  
  94. #ifdef    INCL_VDHVKBD        // VDH services require MVDM types
  95. #define INCL_MVDMTYPES
  96. #endif
  97.  
  98. #ifdef    INCL_VDHVLPT        // VDH services require MVDM types
  99. #define INCL_MVDMTYPES
  100. #endif
  101.  
  102. #ifdef    INCL_VDHVDMA        // VDH services require MVDM types
  103. #define INCL_MVDMTYPES
  104. #endif
  105.  
  106. #ifdef    INCL_MVDMTYPES        // MVDM types depend on basic types
  107. #define INCL_TYPES
  108. #endif
  109.  
  110. #ifdef    INCL_TYPES        // types depend on basemaca.inc macros
  111. #define INCL_DEF
  112. #endif
  113.  
  114.  
  115. /*** Required generic include files
  116.  */
  117.  
  118. //c-begin
  119. #include <basemac.h>        // macros for C
  120. //c-end
  121. //masm-begin
  122. //include basemaca.inc        // macros for MASM
  123. //masm-end
  124.  
  125. #include <basedef.h>        // basic OS/2 data types
  126. //c-begin
  127. #include <string.h>        // for str* and mem* prototypes
  128. //c-end
  129.  
  130.  
  131. /*** MVDM-specific equates (required for function prototypes)
  132.  */
  133.  
  134. #define VDHENTRY PASCAL NEAR    // to declare exported VDH services
  135. #define HOOKENTRY PASCAL NEAR    // to declare "hook" entry points
  136. #define PDDENTRY PASCAL FAR32    // to declare PDD and VDD entry points
  137. #define VDDENTRY PASCAL FAR32 _loadds
  138.  
  139. #define VDDInit main        // kludge to force compiler to ref. __acrtused
  140.  
  141.  
  142. /*** MVDM-specific macros
  143.  */
  144.  
  145. //c-begin
  146. #define BEGIN_GLOBAL_CODE    code_seg()
  147. #define END_GLOBAL_CODE     code_seg()
  148.  
  149. #define BEGIN_GLOBAL_DATA    data_seg()
  150. #define END_GLOBAL_DATA     data_seg()
  151.  
  152. #define BEGIN_INIT_CODE     code_seg("CINIT_TEXT", "CODE")
  153. #define END_INIT_CODE        code_seg()
  154.  
  155. #define BEGIN_INIT_DATA     data_seg("CINIT_DATA", "CINITDATA")
  156. #define END_INIT_DATA        data_seg()
  157.  
  158. #define BEGIN_INSTANCE_DATA    data_seg("MVDMINSTDATA", "MIDATA")
  159. #define END_INSTANCE_DATA    data_seg()
  160.  
  161. #define BEGIN_SWAP_CODE     code_seg("CSWAP_TEXT","CODE")
  162. #define END_SWAP_CODE        code_seg()
  163.  
  164. #define BEGIN_SWAP_DATA     data_seg("CSWAP_DATA","CSWAPDATA")
  165. #define END_SWAP_DATA        data_seg()
  166.  
  167. #define BEGIN_SWAP_INSTANCE    data_seg("SWAPINSTDATA","SIDATA")
  168. #define END_SWAP_INSTANCE    data_seg()
  169. //c-end
  170.  
  171.  
  172. #ifdef    INCL_VDDHELPERS
  173.  
  174. ULONG PRIVENTRY vdhSaveFlags(VOID);    // prototypes for helper externals
  175. VOID  PRIVENTRY vdhRestoreFlags(ULONG);
  176. VOID  PRIVENTRY vdhInt3(VOID);
  177. ULONG PRIVENTRY vdhXCHG(PULONG, ULONG);
  178. ULONG PRIVENTRY vdhBTC(PULONG, ULONG);
  179. ULONG PRIVENTRY vdhBTR(PULONG, ULONG);
  180. ULONG PRIVENTRY vdhBTS(PULONG, ULONG);
  181. ULONG PRIVENTRY vdhBSF(ULONG);
  182. ULONG PRIVENTRY vdhBSR(ULONG);
  183. VOID  PRIVENTRY vdhOutSB(PORT, PBYTE, ULONG, BOOL);
  184. PSZ   PRIVENTRY vdhFindToken(PSZ);
  185. INT   PRIVENTRY vdhCompareStr(PSZ, PSZ, BOOL);
  186. VOID  PRIVENTRY vdhMoveMem(PVOID, PVOID, INT, INT, UINT, BOOL);
  187.  
  188. //c-begin
  189. #ifdef FUNCS                // can't find easy way to allow
  190. #pragma function(inp, inpw, outp, outpw)// both intrinsics and functions -JTP
  191. #endif
  192.  
  193. #define STRTOKEN(p)      vdhFindToken(p)
  194. #define STRCOMPARE(p,q,f) vdhCompareStr(p,q,f)
  195.  
  196. #define DISABLE()    _disable()    // _disable() intrinsic fixed now
  197. #define ENABLE()    _enable()    // _enable() intrinsic fixed now
  198. #define SAVEFLAGS()    vdhSaveFlags()    // preserve flags
  199. #define RESTOREFLAGS(f)    vdhRestoreFlags(f) // restore flags
  200. #define INT3()        vdhInt3()    // execute an INT 3
  201.  
  202. #define INB(p)        ((BYTE)inp(p))
  203. #ifndef IO8BIT
  204. #define INW(p)        inpw(p)
  205. #else
  206. #define INW(p)        ((WORD)(inp(p) + (inp((p)+1)<<8)))
  207. #endif
  208.  
  209. #define OUTB(p,b)    outp(p,b)
  210. #define OUTSB(p,pb,n,f) vdhOutSB(p,pb,n,f)
  211. #ifndef IO8BIT
  212. #define OUTW(p,w)    outpw(p,w)
  213. #else
  214. #define OUTW(p,w)    (outp(p,(BYTE)(w)), outp((p)+1,(BYTE)((w)>>8)))
  215. #endif
  216. //c-end
  217.  
  218. //masm-begin
  219. //DISABLE macro              ;alias for CLI (similar to C)
  220. //      cli
  221. //      endm
  222. //
  223. //ENABLE  macro              ;alias for STI (similar to C)
  224. //      sti
  225. //      endm
  226. //
  227. //PUSHFLAGS macro          ;alias for PUSHF
  228. //      pushf
  229. //      endm
  230. //
  231. //POPFLAGS macro          ;alias for POPF
  232. //      popf
  233. //      endm
  234. //
  235. //INT3      macro           ;alias for INT 3
  236. //      int 3
  237. //      endm
  238. //
  239. //INB      macro      ral,rdx     ;alias for IN AL,DX (also supports IN AH,DX)
  240. //      ifidni  <ral>,<ah>
  241. //        xchg    al,ah
  242. //        in        al,rdx
  243. //        xchg    al,ah
  244. //      else
  245. //        in        ral,rdx
  246. //      endif
  247. //      endm
  248. //
  249. //INW      macro      rax,rdx     ;alias for IN AX,DX (provides support for IO8BIT)
  250. //      IFNDEF IO8BIT
  251. //      in      rax,rdx
  252. //      ELSE
  253. //      in      al,rdx
  254. //      xchg      al,ah
  255. //      inc      rdx
  256. //      jmp      $+2
  257. //      in      al,rdx
  258. //      xchg      al,ah
  259. //      dec      rdx
  260. //      ENDIF
  261. //      endm
  262. //
  263. //OUTB      macro      rdx,ral     ;alias for OUT DX,AL (also supports OUT DX,AH)
  264. //      ifidni  <ral>,<ah>
  265. //        xchg    al,ah
  266. //        out        rdx,al
  267. //        xchg    al,ah
  268. //      else
  269. //        out        rdx,ral
  270. //      endif
  271. //      endm
  272. //
  273. //OUTW      macro      rdx,rax     ;alias for OUT DX,AX (provides support for IO8BIT)
  274. //      IFNDEF IO8BIT
  275. //      out      rdx,rax
  276. //      ELSE
  277. //      out      rdx,al
  278. //      xchg      al,ah
  279. //      inc      rdx
  280. //      jmp      $+2
  281. //      out      rdx,al
  282. //      xchg      al,ah
  283. //      dec      rdx
  284. //      ENDIF
  285. //      endm
  286. //masm-end
  287.  
  288. #endif    // INCL_VDDHELPERS
  289.  
  290.  
  291. /*** MVDM-specific types
  292.  */
  293.  
  294. #ifdef    INCL_MVDMTYPES
  295.  
  296. typedef PVOID PVDM;        // linear pointer into VDM    /* pvdm */
  297.  
  298. typedef PBYTE PBVDM;        // same as PVDM, but often needs less casting
  299.  
  300. typedef BYTE VBREG;        // virtual byte register    /* vb */
  301.  
  302. #endif    // INCL_MVDMTYPES
  303.  
  304.  
  305. /*** MVDM-specific include files
  306.  */
  307.  
  308. #ifdef    INCL_VDH
  309. #include <vdmprop.h>        // DOS property services
  310. #include <vdmm.h>        // VDM Manager services
  311. #include <v8086.h>        // 8086 emulation services
  312. #include <vdos.h>        // DOS emulation services
  313. #endif
  314.  
  315. #ifdef    INCL_VDHVPIC
  316. #include <vpic.h>        // VPIC services
  317. #endif
  318.  
  319. #ifdef    INCL_VDHVKBD
  320. #include <vkbd.h>        // VKBD services
  321. #endif
  322.  
  323. #ifdef    INCL_VDHVLPT
  324. #include <vlpt.h>        // VLPT services
  325. #endif
  326.  
  327. #ifdef    INCL_VDHVDMA
  328. #include <vdma.h>        // VDMA services
  329. #endif
  330.  
  331. #ifdef    INCL_ROMBIOS        // ROM BIOS Data Area definitions
  332. #include <vdmbios.h>
  333. #endif
  334.  
  335. #ifdef    INCL_MI         // machine instructions
  336. typedef UCHAR  uchar_t;     // BUGBUG 22-Feb-89 JeffPar:
  337. typedef USHORT ushort_t;    //  MI.H needs to be fixed!!!
  338. typedef ULONG  ulong_t;
  339.  
  340. #include <mi.h>
  341. #endif
  342.