home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l352 / 1.img / INC / PHAPI.H
Encoding:
C/C++ Source or Header  |  1992-05-27  |  9.1 KB  |  375 lines

  1. /* PHAPI.H - 286|DOS-Extender Phar Lap API definition file */
  2.  
  3. /************************************************************************/
  4. /*    Copyright (C) 1986-1990 Phar Lap Software, Inc.            */
  5. /*    Unpublished - rights reserved under the Copyright Laws of the    */
  6. /*    United States.  Use, duplication, or disclosure by the         */
  7. /*    Government is subject to restrictions as set forth in         */
  8. /*    subparagraph (c)(1)(ii) of the Rights in Technical Data and     */
  9. /*    Computer Software clause at 252.227-7013.            */
  10. /*    Phar Lap Software, Inc., 60 Aberdeen Ave., Cambridge, MA 02138    */
  11. /************************************************************************/
  12.  
  13. /* $Id: phapi.h 1.6 91/10/08 15:32:05 rob Exp $ */
  14.  
  15.  
  16. /*
  17.  
  18. This file provides C data structure declarations and function
  19. prototypes that define the Phar Lap Application Program Interface
  20. (PHAPI) for use in 286|DOS-Extender programs. The functions declared
  21. in this file provide the following services:
  22.  
  23.     o  manipulating protected mode selectors
  24.     o  manipulating pages on the 80386
  25.     o  allocated conventional (DOS) memory
  26.     o  interrupt and exception handling
  27.     o  communicating with real mode code
  28.     o  dynamic linking
  29.     o  miscellaneous services
  30.      
  31. The code for PHAPI is located in PHAPI.DLL, a dynamic link
  32. library that is part of 286|DOS-Extender. In addition to #including
  33. PHAPI.H, programs that use the PHAPI should also link in the import
  34. library, PHAPI.LIB. 
  35.  
  36. All PHAPI functions must be invoked with a FAR call. With the
  37. exception of three functions that allow a variable number of
  38. arguments, all PHAPI routines use the Pascal calling convention. In
  39. the following function prototypes, APIENTRY designates a FAR PASCAL
  40. function. 
  41.  
  42. 286|DOS-Extender provides character-mode OS/2 API calls for
  43. use by protected mode MS-DOS programs. The OS/2 API data structures
  44. and function prototypes are declared in the file OS2.H, provided with
  45. Microsoft C and compatible compilers (you DO NOT need the OS/2 SDK!).
  46.  
  47. The functions declared in this file, PHAPI.H, are those PHAPI
  48. functions which are not already declared in OS2.H or in its helper
  49. include files such as OS2DEF.H, BSEDOS.H, or BSESUB.H. This file,
  50. PHAPI.H, automatically includes (and requires) the Microsoft C
  51. OS2DEF.H include file. Most programs that #include <PHAPI.H> will
  52. probably also need to #include <OS2.H>.
  53.  
  54. */
  55. #ifndef PHAPI_H_INCLUDED
  56. #define PHAPI_H_INCLUDED
  57.  
  58.  
  59. /*
  60.  
  61. If the OS/2 .H files haven't been included, then define the
  62. following base types.
  63.  
  64. */
  65.  
  66. #ifndef OS2DEF_INCLUDED
  67. #define OS2DEF_INCLUDED
  68.  
  69. #ifdef __cplusplus
  70. extern "C" {
  71. #endif    
  72.  
  73. #ifndef CHAR
  74. typedef char CHAR;
  75. #endif
  76. #ifndef INT
  77. typedef int INT;
  78. #endif
  79. typedef short SHORT;
  80. typedef long LONG;
  81. typedef int BOOL;
  82. typedef unsigned char BYTE;
  83.  
  84. typedef unsigned char UCHAR;
  85. typedef unsigned int UINT;
  86. typedef unsigned short USHORT;
  87. typedef unsigned long ULONG;
  88.  
  89. typedef char _far *PCHAR;
  90. typedef int _far *PINT;
  91. typedef short _far *PSHORT;
  92. typedef long _far *PLONG;
  93.  
  94. typedef unsigned char _far *PUCHAR;
  95. typedef unsigned int _far *PUINT;
  96. typedef unsigned short _far *PUSHORT;
  97. typedef unsigned long _far *PULONG;
  98.  
  99. typedef unsigned short SEL;
  100. typedef unsigned short _far *PSEL;
  101. typedef unsigned short HMODULE;
  102. typedef unsigned short _far *PHMODULE;
  103. typedef void _far *PVOID;
  104. typedef unsigned char _far *PSZ;
  105. typedef void (pascal _far *PFN)();
  106. typedef PFN _far *PPFN;
  107.  
  108. #define VOID void
  109. #define APIENTRY pascal _far
  110.  
  111.  
  112. /* 
  113.  
  114. Utility macros
  115.  
  116. */
  117.  
  118. #define MAKEP(sel, off) ((PVOID)((((ULONG)(sel)) << 16) + (off)))
  119.  
  120. #define SELECTOROF(fp) ((SEL)(((ULONG)(fp)) >> 16))
  121.  
  122. #define OFFSETOF(fp) ((UINT)(ULONG)(fp))           
  123.     
  124. #define MAKETYPE(var, type) (*((type _far *)&var))
  125.  
  126. #define FIELDOFFSET(type, field) ((UINT)&(((type *)0)->field))
  127.  
  128. #define MAKELONG(lo, hi) ((((LONG)(hi)) << 16) + (USHORT)(lo))
  129.  
  130. #define MAKEULONG(lo, hi) ((((ULONG)(hi)) << 16) + (USHORT)(lo))
  131.  
  132. #define MAKESHORT(lo, hi) ((((USHORT)(hi)) << 8) + (UCHAR)(lo))
  133.  
  134. #define MAKEUSHORT(lo, hi) ((((USHORT)(hi)) << 8) + (UCHAR)(lo)) 
  135.  
  136. #define LOBYTE(val) ((UCHAR)(val))  
  137.  
  138. #define HIBYTE(val) ((UCHAR)(((USHORT)(val)) >> 8))
  139.  
  140. #define LOUCHAR(val) ((UCHAR)(val))  
  141.  
  142. #define HIUCHAR(val) ((UCHAR)(((USHORT)(val)) >> 8))
  143.  
  144. #define LOWORD(val) ((USHORT)(val))
  145.  
  146. #define HIWORD(val) ((USHORT)(((ULONG)(val)) >> 16))
  147.  
  148. #define LOUSHORT(val) ((USHORT)(val))
  149.  
  150. #define HIUSHORT(val) ((USHORT)(((ULONG)(val)) >> 16))
  151.  
  152. #endif
  153.  
  154.  
  155. /*
  156.  
  157. Force PHAPI.LIB to be linked into the resulting .EXE
  158.  
  159. */
  160.  
  161. #pragma comment(lib, "PHAPI")
  162.  
  163.  
  164. /*
  165.  
  166. Types 
  167.  
  168. */
  169.  
  170. typedef unsigned long REALPTR;
  171.  
  172.  
  173. /*
  174.  
  175. Idealized segment descriptor
  176.  
  177. */
  178.  
  179. typedef struct
  180. {
  181.     ULONG base;        /* Segment linear base address */
  182.     ULONG size;        /* Size in bytes of segment */
  183.     USHORT attrib;        /* Attribute byte */
  184. } DESC;
  185.  
  186. typedef DESC _far *PDESC;
  187.  
  188.  
  189. /*
  190.  
  191. Segment types
  192.  
  193. */
  194.  
  195. #define CODE16        1        /* Code segment */
  196. #define DATA16        2        /* Data segment */
  197. #define CODE16_NOREAD    3        /* Execute only code segment */
  198. #define DATA16_NOWRITE    4        /* Read only data segment */
  199.  
  200.  
  201. /*
  202.  
  203. Mask values returned by "DosVerifyAccess"
  204.  
  205. */
  206.  
  207. #define IS_SEL        0x0001        /* Is a valid selector */    
  208. #define IS_READABLE    0x0002            /* Is readable */
  209. #define IS_WRITEABLE    0x0004               /* Is writeable */
  210. #define IS_CODE        0x0008        /* Is executable */
  211.  
  212.  
  213. /*
  214.  
  215. Function prototypes
  216.  
  217. */
  218.  
  219. USHORT APIENTRY DosCreateDSAlias(SEL sel, PSEL aselp);
  220.  
  221. USHORT APIENTRY DosMapLinSeg(ULONG lin_addr, ULONG size, PSEL selp);
  222.  
  223. USHORT APIENTRY DosMapRealSeg(USHORT rm_para, ULONG size, PSEL selp);
  224.  
  225. USHORT APIENTRY DosMapPhysSeg(ULONG phys_addr, ULONG size, PSEL selp);
  226.  
  227. USHORT APIENTRY DosGetBIOSSeg(PSEL selp);
  228.  
  229. USHORT APIENTRY DosGetSegDesc(SEL sel, PDESC descp);
  230.  
  231. USHORT APIENTRY DosSetSegAttrib(SEL sel, USHORT attrib);
  232.  
  233. USHORT APIENTRY DosVerifyAccess(SEL sel, PUSHORT flagp);
  234.  
  235. USHORT APIENTRY DosLockSegPages(SEL sel);
  236.  
  237. USHORT APIENTRY DosUnlockSegPages(SEL sel);
  238.  
  239. USHORT APIENTRY DosGetPhysAddr(PVOID addr, PULONG phys_addrp, PULONG countp);
  240.  
  241. USHORT APIENTRY DosEnumMod(PSZ name_buff, USHORT name_len, PHMODULE handp);
  242.  
  243. USHORT APIENTRY DosEnumProc(USHORT mod_handle, PSZ name_buff,
  244.                 PUSHORT ordinalp);
  245.  
  246. USHORT APIENTRY DosIsPharLap(void);
  247.  
  248. REALPTR APIENTRY DosProtToReal(PVOID ptr);
  249.  
  250. PVOID APIENTRY DosRealToProt(REALPTR ptr);
  251.  
  252. USHORT APIENTRY DosSetProcAddr(HMODULE mhand, PSZ pnamep,
  253.                    PFN paddr);
  254.  
  255.  
  256. /*
  257.  
  258. Low level memory management functions
  259.  
  260. */
  261.  
  262. USHORT APIENTRY DosRemapLinSeg(ULONG lin_addr, ULONG size, SEL sel);
  263.  
  264. USHORT APIENTRY DosRemapRealSeg(USHORT rm_para, ULONG size, SEL sel);
  265.  
  266. USHORT APIENTRY DosRemapPhysSeg(ULONG phys_addr, ULONG size, SEL sel);
  267.  
  268. USHORT APIENTRY DosAllocLinMem(ULONG size, PULONG lin_addp);
  269.  
  270. USHORT APIENTRY DosFreeLinMem(ULONG lin_add);
  271.  
  272. USHORT APIENTRY DosReallocLinMem(ULONG old_lin_add, ULONG new_size, 
  273.                              PULONG new_lin_addp);
  274.  
  275. USHORT APIENTRY DosMapLinMemToSelector(USHORT sel, ULONG lin_addr, 
  276.                        ULONG size);
  277.  
  278. USHORT APIENTRY DosAllocSpecificSelectors(SEL sel, USHORT count);
  279.  
  280. USHORT APIENTRY DosFreeSelectors(SEL sel, USHORT count);
  281.  
  282.  
  283. /*
  284.  
  285. OS/2 compatible API's
  286.  
  287. */
  288.  
  289. #ifndef INCL_DOSPROCESS_INCLUDED
  290. #define INCL_DOSPROCESS_INCLUDED
  291.  
  292. typedef struct _RESULTCODES
  293.     USHORT codeTerminate;
  294.     USHORT codeResult;
  295. } RESULTCODES;
  296.  
  297. typedef RESULTCODES _far *PRESULTCODES;
  298.  
  299. typedef void (pascal _far *PFNEXITLIST)(USHORT);
  300.  
  301. #define EXLST_ADD    1
  302. #define EXLST_REMOVE 2
  303. #define EXLST_EXIT   3
  304.  
  305. #define MODE_REAL      0
  306. #define MODE_PROTECTED 1
  307.  
  308. #define TC_EXIT        0
  309. #define TC_HARDERROR   1
  310. #define TC_TRAP        2
  311. #define TC_KILLPROCESS 3
  312.  
  313. #define EXEC_SYNC        0
  314. #define EXEC_ASYNC       1
  315. #define EXEC_ASYNCRESULT 2
  316. #define EXEC_TRACE       3
  317. #define EXEC_BACKGROUND  4
  318.  
  319. USHORT APIENTRY DosExecPgm(PCHAR failp, SHORT failc,
  320.                USHORT flags, PSZ argsp, PSZ envp,
  321.                PRESULTCODES resultp, PSZ namep);
  322.  
  323. VOID APIENTRY DosExit(USHORT flag, USHORT rc);
  324.  
  325. USHORT APIENTRY DosExitList(USHORT code, PFNEXITLIST funcp);
  326.  
  327. USHORT APIENTRY DosGetMachineMode(PUCHAR modep);
  328.  
  329. #endif
  330.  
  331. #ifndef INCL_DOSMEMMGR_INCLUDED
  332. #define INCL_DOSMEMMGR_INCLUDED
  333.  
  334. USHORT APIENTRY DosAllocHuge(USHORT nseg, USHORT lcount, PSEL selp,
  335.                  USHORT maxsel, USHORT flags);
  336.  
  337. USHORT APIENTRY DosAllocSeg(USHORT size, PSEL selp, USHORT flags);
  338.  
  339. USHORT APIENTRY DosCreateCSAlias(SEL dsel, PSEL cselp);
  340.  
  341. USHORT APIENTRY DosGetHugeShift(PUSHORT countp);
  342.  
  343. USHORT APIENTRY DosFreeSeg(SEL sel);
  344.  
  345. USHORT APIENTRY DosMemAvail(PULONG availp);
  346.  
  347. USHORT APIENTRY DosReallocHuge(USHORT nseg, USHORT lcount, SEL sel);
  348.  
  349. USHORT APIENTRY DosReallocSeg(USHORT nsize, SEL sel);
  350.  
  351. #endif
  352.  
  353. #ifndef INCL_DOSMODULEMGR_INCLUDED
  354. #define INCL_DOSMODULEMGR_INCLUDED
  355.  
  356. USHORT APIENTRY DosFreeModule(HMODULE mhand);
  357.  
  358. USHORT APIENTRY DosGetModHandle(PSZ namep, PHMODULE mhandp);
  359.  
  360. USHORT APIENTRY DosGetModName(HMODULE mhand, USHORT buffc, PCHAR buffp);
  361.  
  362. USHORT APIENTRY DosGetProcAddr(HMODULE mhand, PSZ pnamep,
  363.                    PPFN paddrp);
  364.  
  365. USHORT APIENTRY DosLoadModule(PSZ failp, USHORT failc,
  366.                               PSZ modnamep, PHMODULE mhandp);
  367.  
  368. #ifdef __cplusplus
  369. }
  370. #endif    
  371.  
  372. #endif
  373. #endif
  374.