home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c220 / 7.ddi / INCLUDES / PHARLAP.H < prev    next >
Encoding:
C/C++ Source or Header  |  1991-01-17  |  46.6 KB  |  1,185 lines

  1. /* PHARLAP.H - Definitions for Phar Lap's 386|DOS-Extender */
  2. /* $Id: pharlap.h 1.30 91/01/17 12:51:52 rwm Exp $ */
  3.  
  4. /************************************************************************/
  5. /*    Copyright (C) 1986-1991 Phar Lap Software, Inc.            */
  6. /*    Unpublished - rights reserved under the Copyright Laws of the    */
  7. /*    United States.  Use, duplication, or disclosure by the         */
  8. /*    Government is subject to restrictions as set forth in         */
  9. /*    subparagraph (c)(1)(ii) of the Rights in Technical Data and     */
  10. /*    Computer Software clause at 252.227-7013.            */
  11. /*    Phar Lap Software, Inc., 60 Aberdeen Ave., Cambridge, MA 02138    */
  12. /************************************************************************/
  13.  
  14. /*    
  15.  
  16.     FILE DESCRIPTION
  17.  
  18. This include file contains definitions used by application programs 
  19. that run under Phar Lap's 386|DOS-Extender.  The file defines the
  20. application program interface (API) to 386|DOS-Extender.  The following
  21. definitions are present in the file:
  22.  
  23.     * Fixed selector numbers
  24.     * Program segment prefix (PSP)
  25.     * Interrupt numbers
  26.     * System call numbers
  27.     * Error numbers
  28.     * Data structures used by system calls
  29.  
  30. */
  31.  
  32. #ifndef PLTYPES
  33. #include <pltypes.h>
  34. #endif
  35.  
  36.  
  37. /*
  38.  
  39. Fixed GDT Segment selectors used by 386|DOS-Extender
  40.  
  41. The following selectors in the GDT are available to 
  42. applications to directly access the LDT, GDT, and IDT
  43. when running under 386|DOS-Extender.
  44.  
  45. THESE SEGMENTS MUST NOT BE USED IF THE PROGRAM RUNS AT PRIVILEGE LEVEL
  46. 3 AND/OR DPMI COMPATIBILITY IS DESIRED
  47.  
  48. */
  49.  
  50. #define    SS_LDT        0x0028        /* LDT system segment */
  51. #define SS_DLDT        0x0030        /* data segment mapping LDT */
  52. #define SS_DGDT        0x0038        /* data segment mapping GDT */
  53. #define SS_DIDT     0x0050        /* data segment mapping IDT */
  54.  
  55.  
  56. /*
  57.  
  58. Fixed LDT Segment selectors used by 386|DOS-Extender
  59.  
  60. The following selectors in the LDT are available to be 
  61. used by an applications to access the various pieces of
  62. a program when running under 386|DOS-Extender. 
  63.  
  64. */
  65.  
  66. #define SS_CODE      0x000C        /* User code */
  67. #define SS_DATA      0x0014        /* User data */
  68. #define SS_SCREEN     0x001C        /* Screen memory */
  69. #define SS_PSP       0x0024        /* PSP */
  70. #define SS_ENV        0x002C        /* DOS environment */
  71. #define SS_DOSMEM     0x0034        /* low 1 megabyte of memory (RO) */
  72. #define SS_1167     0x003C        /* Weitek 1167,3167,4167 coprocessor */
  73. #define SS_WEITEK     0x003C        /* Weitek 1167,3167,4167 coprocessor */
  74. #define SS_GRAPHICS    0x0044        /* Screen graphics memory */
  75. #define SS_CYRIX    0x004C        /* Cyrix EMC387 coprocessor, added */
  76.                     /*in version 3.0 of 386|DOS-Extender*/
  77.  
  78.  
  79. /*
  80.  
  81. The max. length of a DOS file name string 
  82.  
  83. */
  84.  
  85. #define MAX_FNLEN    128
  86.  
  87.  
  88. /*
  89.  
  90. Program segment prefix (PSP)
  91.  
  92. */
  93.  
  94. typedef struct
  95. {
  96.     USHORT    i20;        /* INT 20h instruction */
  97.     USHORT    end_alloc;    /* para addr of end of allocation block */
  98.     UCHAR    pad1;        /* unused byte */
  99.     UCHAR    fcall;        /* -RESERVED- */
  100.     USHORT    cpmoffs;    /* -RESERVED- */
  101.     USHORT    cpmseg;        /* -RESERVED- */
  102.     USHORT    term_ip;    /* -RESERVED- */
  103.     USHORT    term_cs;    /* -RESERVED- */
  104.     USHORT    cc_ip;        /* -RESERVED- */
  105.     USHORT    cc_cs;        /* -RESERVED- */
  106.     USHORT    ce_ip;        /* -RESERVED- */
  107.     USHORT    ce_cs;        /* -RESERVED- */
  108.     USHORT    parseg;        /* segment address of parent */
  109.     UCHAR    oftab[20];    /* open file table */
  110.     USHORT    env_addr;    /* para addr of environment block */
  111.     USHORT    sp_sav;        /* -RESERVED- */
  112.     USHORT    ss_sav;        /* -RESERVED- */
  113.     USHORT    maxfil;        /* max. number of open files */
  114.     USHORT    oftoffs;    /* offset of open file table */
  115.     USHORT    oftseg;        /* segment addr of open file table */
  116.     USHORT    npspoffs;    /* next PSP offset */
  117.     USHORT    npspseg;    /* next PSP segment */
  118.     UCHAR    pad2[20];    /* unused bytes, always 0 */
  119.     USHORT    i21;        /* INT 21h opcode */
  120.     UCHAR    fret;        /* far return opcode */
  121.     UCHAR    pad3[9];    /* unused bytes, always 0 */
  122.     ULONG    data_size;    /* # data bytes read from .EXE file */
  123.     ULONG    dseg_size;    /* size, in bytes, of data segment */
  124.     ULONG    edat_size;    /* # extra data bytes alloc'd (size-amt) */
  125.     UCHAR    pad4[24];    /* unused bytes, always 0 */
  126.     UCHAR    ct_len;        /* length of command tail string */
  127.     UCHAR    ctail[127];    /* buffer for command tail */
  128. } MS_PSP;
  129.  
  130.  
  131. /*
  132.  
  133. DOS interrupt numbers
  134.  
  135. */
  136.  
  137. #define INT_TERM    0x20    /* Terminate */
  138. #define INT_DOS        0x21    /* DOS system call */
  139. #define INT_TADDR    0x22    /* Terminate address */
  140. #define INT_CTRLC    0x23    /* Control/C handler */
  141. #define INT_CRERR    0x24    /* Critical error handler */
  142. #define INT_DREAD    0x25    /* Disk read */
  143. #define INT_DWRITE    0x26    /* Disk write */
  144. #define INT_TSR        0x27    /* Terminate-and-stay resident */
  145. #define INT_PSC        0x2F    /* Print spool control */
  146.  
  147.  
  148. /* 
  149.  
  150. System call numbers 
  151.  
  152. */
  153.  
  154. #define _DOS_CHAR_INE    0x01    /* Character input with echo */
  155. #define _DOS_CHAR_OUT    0x02    /* Character output */
  156. #define _DOS_AUX_IN    0x03    /* Auxiliary input */
  157. #define _DOS_AUX_OUT    0x04    /* Auxiliary output */
  158. #define _DOS_PRT_OUT    0x05    /* Printer output */
  159. #define _DOS_CHAR_IO    0x06    /* Direct console I/O */
  160. #define _DOS_CHAR_INR    0x07    /* Character input (raw) */
  161. #define _DOS_CHAR_INNE    0x08    /* Character input (no echo) */
  162. #define _DOS_STR_OUT    0x09    /* Character string output */
  163. #define _DOS_BUFF_IN    0x0A    /* Buffered input */
  164. #define _DOS_IN_STATS    0x0B    /* Input status */
  165. #define _DOS_RESET_IN    0x0C    /* Reset, then input */
  166. #define _DOS_DISK_RES    0x0D    /* Disk reset */
  167. #define _DOS_DEFD_SET    0x0E    /* Set default disk */
  168. #define _DOS_DEFD_GET    0x19    /* Get default disk */
  169. #define _DOS_DTA_SET    0x1A    /* Set disk transfer address */
  170. #define _DOS_DALLOC_GET    0x1B    /* Get allocation info for default drive */
  171. #define _DOS_SALLOC_GET    0x1C    /* Get allocation info for specific drive */
  172. #define _DOS_DATE_GET    0x2A    /* Get date */
  173. #define _DOS_DATE_SET    0x2B    /* Set date */
  174. #define _DOS_TIME_GET    0x2C    /* Get time */
  175. #define _DOS_TIME_SET    0x2D    /* Set time */
  176. #define _DOS_VERF_SET    0x2E    /* Set verify flag */
  177. #define _DOS_DTA_GET    0x2F    /* Get disk transfer address */
  178. #define _DOS_VERNO_GET    0x30    /* Get DOS and 386|DOS-Extender version #'s */
  179. #define _DOS_TSR    0x31    /* Terminate a stay resident */
  180. #define _DOS_GDBLK    0x32    /* Get disk block */
  181. #define _DOS_BRK_FLAG    0x33    /* Get or set control/break flag */
  182. #define _DOS_FSPACE_GET    0x36    /* Get disk free space */
  183. #define _DOS_CNTRY    0x38    /* Get or set country information */
  184. #define _DOS_MKDIR    0x39    /* Create a subdirectory */
  185. #define _DOS_RMDIR    0x3A    /* Remove a subdirectory */
  186. #define _DOS_CHDIR    0x3B    /* Change current directory */
  187. #define _DOS_CREATE    0x3C    /* Create a file */
  188. #define _DOS_OPEN    0x3D    /* Open a file */
  189. #define _DOS_CLOSE    0x3E    /* Close a file */
  190. #define _DOS_READ    0x3F    /* Read from a file */
  191. #define _DOS_WRITE    0x40    /* Write to a file */
  192. #define _DOS_DELETE    0x41    /* Delete a file */
  193. #define _DOS_SEEK    0x42    /* Seek in a file */
  194. #define _DOS_FATTR    0x43    /* Get or set file attributes */
  195. #define _DOS_IOCTL    0x44    /* Device I/O control */
  196. #define _DOS_DUP    0x45    /* Duplicate a handle */
  197. #define _DOS_DUP2    0x46    /* Duplicate a handle */
  198. #define _DOS_CURDIR    0x47    /* Get current directory name */
  199. #define _DOS_SEG_ALLOC    0x48    /* Allocate a segment */
  200. #define _DOS_SEG_FREE    0x49    /* Free a segment */
  201. #define _DOS_SEG_RESIZE    0x4A    /* Modify segment size */
  202. #define _DOS_EXEC    0x4B    /* Execute a program */
  203. #define _DOS_TERM    0x4C    /* Exit with a return code */
  204. #define _DOS_RC_GET    0x4D    /* Get child return code */
  205. #define _DOS_FIND_FIRST    0x4E    /* Find first */
  206. #define _DOS_FIND_NEXT    0x4F    /* Find next */
  207. #define _DOS_PSP_SET    0x50    /* Set PSP */
  208. #define _DOS_VERF_GET    0x51    /* Get verify flag */
  209. #define _DOS_RENAME    0x56    /* Rename a file */
  210. #define _DOS_FDATE    0x57    /* Get or set file date */
  211. #define _DOS_MEM_STRAT    0x58    /* Get or set conventional memory allocation
  212.                    strategy */
  213. #define _DOS_XERR_GET    0x59    /* Get extended error information */
  214. #define _DOS_TEMPF_CRT    0x5A    /* Create a temporary file */
  215. #define _DOS_CCREATE    0x5B    /* Create file if it does not exist */
  216. #define _DOS_FILE_LOCK    0x5C    /* Lock a file */
  217. #define _DOS_PSP_GET    0x62    /* Get PSP */
  218.  
  219.  
  220. /*
  221.  
  222. 386|DOS-Extender system call numbers
  223.  
  224. */
  225.  
  226. #define _DX_RESET_DATA    0x2501    /* Reset DOS-Extender data structures */
  227. #define _DX_PMIV_GET    0x2502    /* Get protected mode interrupt */
  228. #define _DX_RMIV_GET    0x2503    /* Get real mode interrupt */
  229. #define _DX_PMIV_SET    0x2504    /* Set protected mode interrupt */
  230. #define _DX_RMIV_SET    0x2505    /* Set real mode interrupt */
  231. #define _DX_APMIV_SET    0x2506    /* Set both interrupts to get control
  232.                    in protected mode */
  233. #define _DX_RPMIV_SET    0x2507    /* Get both interrupts separately */
  234. #define _DX_TOLINEAR    0x2508    /* Get linear base address */
  235. #define _DX_TOPHYS    0x2509    /* Convert a linear address to physical */
  236. #define _DX_MAP_PHYS    0x250A    /* Map physical memory to the end of a
  237.                    segment */
  238. #define _DX_HWIV_GET    0x250C    /* Get hardware interrupt vector base */
  239. #define _DX_RMLINK_GET    0x250D    /* Get real mode link information */
  240. #define _DX_REAL_CALL    0x250E    /* Call a real mode procedure */
  241. #define _DX_TOREAL    0x250F    /* Convert protected mode address to
  242.                    real mode address */
  243. #define _DX_REAL_REGCALL 0x2510    /* Call a real mode procedure with
  244.                    register arguments */
  245. #define _DX_REAL_INT    0x2511    /* Issue a real mode interrupt with
  246.                    register arguments */
  247. #define _DX_DBG_LOAD    0x2512    /* Load a program for debugging */
  248. #define _DX_SEG_ALIAS    0x2513    /* Alias a segment */
  249. #define _DX_SEGATTR_SET    0x2514    /* Set segment attributes */
  250. #define _DX_SEGATTR_GET    0x2515    /* Get segment attributes */
  251. #define _DX_LDTMEM_FREE    0x2516    /* Free all memory owned by LDT */
  252. #define _DX_DBUFF_GET    0x2517    /* Get info on DOS data buffer */
  253. #define _DX_SEGMOV_HAND    0x2518    /* Specify handler for moved segments */
  254. #define _DX_MEMERR_GET    0x2519    /* Get additional memory error info */
  255. #define _DX_LOCK_PAGE    0x251A    /* Lock pages in memory */
  256. #define _DX_UNLOCK_PAGE    0x251B    /* Unlock pages in memory */
  257. #define _DX_PAGE_FREE    0x251C    /* Free physical memory pages */
  258. #define _DX_PTE_READ    0x251D    /* Read page table entry */
  259. #define _DX_PTE_WRITE    0x251E    /* Write page table entry */
  260. #define _DX_PTE_XCHG    0x251F    /* Exchange page table entries */
  261. #define _DX_VM_STATS    0x2520    /* Get memory statistics */
  262. #define _DX_XMEM_LIMIT    0x2521    /* Limit program's extended memory usage */
  263. #define _DX_PGFLT_HAND    0x2522    /* Specify alternate page fault handler */
  264. #define _DX_OSWSP_HAND    0x2523    /* Specify out-of-swap-space handler */
  265. #define _DX_PGREPL_HAND    0x2524    /* Specify page replacement handlers */
  266. #define _DX_CMEM_LIMIT    0x2525    /* Limit program's conventional memory usage */
  267. #define _DX_CONFIG_INF    0x2526    /* Get Configuration Information */
  268. #define _DX_DBG_FLAGS    0x2527    /* Set debug flags */
  269. #define _DX_CC_RDREGS    0x2528    /* Read registers after Ctrl/C interrupt*/
  270. #define _DX_LOAD_EXP    0x2529    /* Load Flat Model EXP file **/
  271. #define _DX_DBG_NEWLD    0x252A    /* New load pgm for debug (more error info */
  272.                 /* than _DX_DBG_LOAD call) */
  273. #define _DX_MEM_MGT    0x252B    /* Memory region page management */
  274. #define _DX_ADD_UNMAP    0x252C    /* Add unmapped pages at end of segment */
  275. #define _DX_CLOSE_VMH    0x252D    /* Close VMM file handle */
  276. #define _DX_VMM_PARAMS    0x252E    /* Get/Set VMM parameters */
  277. #define _DX_WR_PAGELOG    0x252F    /* Write record to VMM page log file */
  278. #define _DX_SET_DOSBUF    0x2530    /* Set size of data buffer used for DOS calls*/
  279. #define _DX_RW_LDTDESC    0x2531    /* Read/Write LDT descriptor */
  280. #define _DX_PMEXC_GET    0x2532    /* Get prot mode processor exception vector */
  281. #define _DX_PMEXC_SET    0x2533    /* Set prot mode processor exception vector */
  282. #define _DX_IF_GET    0x2534    /* Get interrupt flag */
  283. #define _DX_SR_RW    0x2535    /* Read/Write System Registers */
  284. #define _DX_MEM_USAGE    0x2536    /* Min/Max Ext/Conv Memory Usage */
  285. #define _DX_REAL_ADDB    0x2537    /* Allocate DOS memory above DOS Data Buffer */
  286. #define _DX_SWI_RDREGS 0x2538  /* Read PM regs after a SW interrupt */
  287. #define _DX_GET_HDROFF 0x2539    /* Get Offset of EXP file header */
  288. #define _DX_MSEG_FAILH 0x253A    /* Install Mod. Segment Failure Handler */
  289. #define _DX_TOREAL_JMP 0x253B  /* Jump to real mode code, no context saved */
  290. #define _DX_SHRINK_SWAP    0x253C    /* shrink size of 386|VMM swap file */
  291. #define _DX_RW_IDTDESC    0x253D    /* Read/Write IDT descriptor */
  292. #define _DX_REAL_ALLOC    0x25C0    /* Allocate real mode memory */
  293. #define _DX_REAL_FREE    0x25C1    /* Release real mode memory */
  294. #define _DX_REAL_RESIZE    0x25C2    /* Change size of a real mode memory
  295.                    block */
  296. #define _DX_EXEC_SPEC    0x25C3    /* Special program execute call */
  297.  
  298.  
  299. /*
  300.  
  301. I/O Control subfunction numbers
  302.  
  303. */
  304.  
  305. #define _IOC_GDINFO    0    /* Get device information */
  306. #define _IOC_SDINFO    1    /* Get device information */
  307. #define _IOC_RCDCC    2    /* Read from char. device control channel */
  308. #define _IOC_WCDCC    3    /* Write from char. device control channel */
  309. #define _IOC_RBDCC    4    /* Read from block device control channel */
  310. #define _IOC_WBDCC    5    /* Write from block device control channel */
  311. #define _IOC_INST    6    /* Get input status */
  312. #define _IOC_OUTST    7    /* Get output status */
  313. #define _IOC_TCHG    8    /* Test if device is changeable */
  314. #define _IOC_TDLOC    9    /* Test location of device */
  315. #define _IOC_THLOC    10    /* Test location of handle */
  316. #define _IOC_SSRC    11    /* Set sharing retry count */
  317.  
  318.  
  319.  
  320. /*
  321.  
  322. DOS error codes 
  323.  
  324. */
  325.  
  326. #define _DOSE_NONE    0    /* No error */
  327. #define _DOSE_BAD_FUNC    1    /* Bad function number */
  328. #define _DOSE_FILE_NOTFND 2    /* File not found */
  329. #define _DOSE_PATH_NOTFND 3    /* Path not found */
  330. #define _DOSE_TOOMANY_OPENS 4    /* Too many files open */
  331. #define _DOSE_ACC_DEN    5    /* Access denied */
  332. #define _DOSE_BAD_HAND    6    /* Bad handle */
  333. #define _DOSE_BAD_MCB    7    /* Bad memory control block */
  334. #define _DOSE_NO_MEM    8    /* Out of memory */
  335. #define _DOSE_BAD_MBA    9    /* Bad memory block address */
  336. #define _DOSE_BAD_ENV    10    /* Bad environment */
  337. #define _DOSE_BAD_FMT    11    /* Bad format */
  338. #define _DOSE_BAD_ACC    12    /* Bad access code */
  339. #define _DOSE_BAD_DATA    13    /* Bad data */
  340. #define _DOSE_BAD_DISK    15    /* Bad disk drive */
  341. #define _DOSE_REM_CD    16    /* Attempt to remove current directory */
  342. #define _DOSE_NOT_SAME    17    /* Not same device */
  343. #define _DOSE_NOMORE_FILES 18    /* No more files */
  344. #define _DOSE_WRITE_PROT 19    /* Disk write-protected */
  345. #define _DOSE_BAD_UNITNO 20    /* Bad disk unit number */
  346. #define _DOSE_NOT_READY    21    /* Drive not ready */
  347. #define _DOSE_BAD_CMD    22    /* Unknown command */
  348. #define _DOSE_BAD_CRC    23    /* Bad CRC */
  349. #define _DOSE_BAD_REQLEN 24    /* Bad request structure length */
  350. #define _DOSE_SEEK    25    /* Seek error */
  351. #define _DOSE_BAD_MEDT    26    /* Bad media type */
  352. #define _DOSE_SECT_NOTFND 27    /* Sector not found */
  353. #define _DOSE_NO_PAPER    28    /* No paper in printer */
  354. #define _DOSE_WRITE_FLT    29    /* Write fault */
  355. #define _DOSE_READ_FLT    30    /* Read fault */
  356. #define _DOSE_GEN_FAIL    31    /* General failure */
  357. #define _DOSE_SHARE_VIOL 32    /* Sharing violation */
  358. #define _DOSE_LOCK_VIOL    33    /* Lock violation */
  359. #define _DOSE_BAD_CHG    34    /* Invalid disk change */
  360. #define _DOSE_NO_FCB    35    /* No FCB's available */
  361. #define _DOSE_SHAR_OVF    36    /* Sharing buffer overflow */
  362. #define _DOSE_REQ_NIMP    50    /* Network request not implemented */
  363. #define _DOSE_RMT_NOLIS    51    /* Remote not listening */
  364. #define _DOSE_DUP_NET    52    /* Duplicate name on network */
  365. #define _DOSE_NET_NOTFND 53    /* Network name not found */
  366. #define _DOSE_NET_BUSY  54    /* Network busy */
  367. #define _DOSE_DEV_GONE  55    /* Network device no longer exists */
  368. #define _DOSE_CMD_LIMIT    56    /* Network BIOS command limit exceeded */
  369. #define _DOSE_NET_ERR    57    /* Network hardware error */
  370. #define _DOSE_BAD_RESP    58    /* Bad response from network */
  371. #define _DOSE_UNEXPECT     59    /* Unexpected error */
  372. #define _DOSE_ADPT_INC    60    /* Incompatible remote adapter */
  373. #define _DOSE_PRTQ_FULL    61    /* Print queue full */
  374. #define _DOSE_PRTQ_NOTFND 62    /* Print queue not found */
  375. #define _DOSE_PRTF_DEL    63    /* Print file deleted */
  376. #define _DOSE_NAME_DEL    64    /* Network name deleted */
  377. #define _DOSE_ACC_DEN2    65    /* Access denied */
  378. #define _DOSE_BAD_NTYEP    66    /* Bad network device type */
  379. #define _DOSE_NET_NOTFND2 67    /* Network name not found */
  380. #define _DOSE_NAME_LIMIT 68    /* Network name limit exceeded */
  381. #define _DOSE_SESS_LIMIT 69    /* Network session limit exceeded */
  382. #define _DOSE_TPAUSE    70    /* Temporary pause */
  383. #define _DOSE_REQ_NACC    71    /* Network request not accepted */
  384. #define _DOSE_RED_PAUSE    72    /* Print or disk redirection pause */
  385. #define _DOSE_FILE_EXISTS 80    /* File already exists */
  386. #define _DOSE_NO_DIRENT    82    /* Cannot make directory entry */
  387. #define _DOSE_INT24_ERR    83    /* Error on INT 24 */
  388. #define _DOSE_RED_TOOMANY 84    /* Too many redirections */
  389. #define _DOSE_RED_DUP    85    /* Duplicate redirection */
  390. #define _DOSE_BAD_PSWD    86    /* Bad password */
  391. #define _DOSE_BAD_PARM    87    /* Bad parameter */
  392. #define _DOSE_DEV_FAIL    88    /* Network device failure */
  393.  
  394.  
  395. /*
  396.  
  397. 386|DOS-Extender error codes
  398.  
  399. */
  400.  
  401. #define _DXE_LDT_SIZE    128    /* LDT buf too small in load for debug call */
  402. #define _DXE_BAD_PARAM    129    /* Bad parameter passed in to system call */
  403. #define _DXE_NOT_DPMI    130    /* Operation not supported under this */
  404.                 /* DPMI implementation */
  405. #define _DXE_DBG_NOSAV    131    /* Register saving for debuggers not enabled */
  406. #define _DXE_DBG_NOREG    132    /* Register buffer for debuggers is empty */
  407. #define _DXE_NO_PAGELOG    133    /* Attempt to write to VMM page log file */
  408.                 /* when no file exists */
  409. #define _DXE_MAX_VMH    134    /* Maximum number of 386|VMM file handles */
  410.                 /* are already allocated */
  411.  
  412. /*
  413.  * Memory error codes, returned by the Get Additional Memory Error Info
  414.  * system call (_DX_MEMERR_GET), and some other system calls such as
  415.  * _DX_LOAD_EXP and _DX_DBG_NEWLD.  It gives more detailed information
  416.  * about why the most recent DOS memory error (error 8, _DOSE_NO_MEM) occurred.
  417.  */
  418. #define MERR_NONE    0    /* no additional info available */
  419. #define MERR_NOMEM    1    /* insufficient physical memory available */
  420. #define MERR_NOSWAP    2    /* insuff. VMM swap space available on disk */
  421. #define MERR_NOLDT    3    /* no free LDT entries and unable to grow LDT*/
  422. #define MERR_NOEXT    4    /* unable to change extended memory */
  423.                 /* allocation mark */
  424. #define MERR_NOVIRT    5    /* insuff. virtual memory space (-MAXPGMMEM */
  425.                 /* switch value exceeded) */
  426. #define MERR_NORBRK    6    /* insuff. conventional memory to satisfy */
  427.                 /* -REALBREAK when loading an EXP file */
  428. #define MERR_NOPSP    7    /* insuff. conventional memory to allocate */
  429.                 /* a PSP and environment when loading an EXP */
  430.                 /* file for debugging */
  431.  
  432. /*
  433.  * Loader error codes, returned by Load EXP file (_DX_LOAD_EXP) and Load
  434.  * Program for Debug (_DX_DBG_NEWLD).
  435.  */
  436. #define LERR_OPEN    1    /* DOS error returned opening file */
  437. #define LERR_SEEK    2    /* DOS error returned seeking in file */
  438. #define LERR_READ    3    /* DOS error returned reading from file */
  439. #define LERR_NOTEXE    4    /* Not a supported EXE or EXP file format */
  440. #define LERR_INVFILE    5    /* Invalid file format (file header was */
  441.                 /* recognized, but information in the file */
  442.                 /* was invalid) */
  443. #define LERR_BADOFFS    6    /* Linker -OFFSET switch value is not a */
  444.                 /* multiple of 4K, or -OFFSET not allowed */
  445.                 /* because -NOPAGE used, or because this */
  446.                 /* DPMI version doesn't support -OFFSET */
  447. #define LERR_BADRBRK    7    /* -REALBREAK not allowed because -NOPAGE */
  448.                 /* used, or because this DPMI version */
  449.                 /* doesn't support -REALBREAK */
  450. #define LERR_DOSLOAD    8    /* DOS error returned loading real mode */
  451.                 /* EXE file */
  452. #define LERR_PRIV    9    /* privilege level of program incompatible */
  453.                 /* with current privilege level (only ret'd */
  454.                 /* by Load for Debug, not by Load EXP File) */
  455.  
  456. /*
  457.  
  458. DOS time structure
  459.  
  460. */
  461.  
  462. typedef struct
  463. {
  464.     UCHAR hour;        /* Hour (0-23) */
  465.     UCHAR minute;        /* Minute (0-59) */
  466.     UCHAR second;        /* Second (0-59) */
  467.     UCHAR hsecond;        /* 1/100 second (0-99) */
  468. } DOS_TIME;
  469.  
  470.  
  471. /*
  472.  
  473. DOS date structure
  474.  
  475. */
  476.  
  477. typedef struct
  478. {
  479.     UCHAR day;        /* Day (1-31) */
  480.     UCHAR month;        /* Month (1-12) */
  481.     USHORT year;        /* Year (1980-...) */
  482.     UCHAR dayofweek;    /* Day of week (0-6) */
  483. } DOS_DATE;
  484.  
  485.  
  486. /*
  487.  
  488. Disk block used in function 32H
  489.  
  490. */
  491.  
  492. typedef struct
  493. {
  494.     UCHAR drive;        /* Number number (A = 0) */
  495.     UCHAR unit_no;        /* Unit number within driver */
  496.     USHORT sec_size;    /* Sector size in bytes */
  497.     UCHAR sec_cls;        /* Number of sectors per cluster - 1*/
  498.     UCHAR cls_shift;    /* Cluster to sector shift */
  499.     USHORT rsrv_cnt;    /* Number of reserved sectors */
  500.     UCHAR fat_cnt;        /* Number of FAT entries */
  501.     USHORT root_cnt;    /* Number of root directory entries */
  502.     USHORT cls2_secno;    /* Sector number of cluster #2 */
  503.     USHORT cls_cnt;        /* Number of clusters + 1 */
  504.     UCHAR fat_scnt;        /* Number of sectors for the FAT */
  505.     USHORT dir_secno;    /* Sector number of the directory */
  506.     REALPTR dev_hdrp;    /* Real mode pointer to device handle */
  507.     UCHAR media_byte;    /* Media descriptor byte */
  508.     UCHAR not_accf;        /* Not accessed flag */
  509.     REALPTR dblk_nextp;    /* Real mode pointer to next block */
  510. } DISK_BLK;
  511.  
  512.  
  513. /*
  514.  
  515. File attributes
  516.  
  517. */
  518.  
  519. #define NORM_FILE    0    /* Normal file */
  520. #define RO_FILE        1    /* Read only file */
  521. #define HIDE_FILE    2    /* Hiddent file */
  522. #define SYS_FILE    4    /* System file */
  523.  
  524.  
  525. /*
  526.  
  527. Find block
  528.  
  529. */
  530.  
  531. typedef struct
  532. {
  533.     UCHAR reserved[21];    /* 21 bytes reserved by DOS */
  534.     UCHAR file_attr;    /* File attribute */
  535.     USHORT file_time;    /* File time */
  536.     USHORT file_date;    /* File data */
  537.     ULONG file_size;    /* Size in bytes of file */
  538.     UCHAR file_name[13];    /* Null terminate file name */
  539. } FIND_BLK;
  540.  
  541.  
  542. /*
  543.  
  544. MS-DOS EXEC system call control block
  545.  
  546. */
  547.  
  548. typedef struct
  549. {
  550.     UCHAR *ex_eoff;        /* Offset of the environment segment */
  551.     USHORT ex_eseg;        /* Segment of the environment segment */
  552.     UCHAR *ex_coff;        /* Offset of the command tail */
  553.     USHORT ex_cseg;        /* Segment of the command tail */
  554. } EXEC_BLK;
  555.  
  556.  
  557. /*
  558.  
  559. Type of disk media
  560.  
  561. */
  562.  
  563. #define DM_FIXED    0xF8    /* Fixed disk */
  564. #define DM_DS15        0xF9    /* Double sided, 15 sectors (1.2 Meg) */
  565. #define DM_SS9        0xFC    /* Single sided, 9 sectors */
  566. #define DM_DS9        0xFD    /* Double sided, 9 sectors */
  567. #define DM_SS8        0xFE    /* Single sided, 8 sectors */
  568. #define DM_DS8        0xFF    /* Doubled sided, 8 sectors */
  569.  
  570.  
  571. /*
  572.  
  573. Seek directions
  574.  
  575. */
  576.  
  577. #define SEEK_ABS    0    /* Absolute seek */
  578. #define SEEK_REL    1    /* Relative to current file ptr. */
  579. #define SEEK_EOF    2    /* Relative to EOF */
  580.  
  581.  
  582.  
  583. /*
  584.  
  585. Country info typedef
  586.  
  587. */
  588.  
  589. typedef struct
  590. {
  591.  
  592.     USHORT date_fmt;    /* Date format */
  593.     UCHAR curr_sym;        /* Currency symbol */
  594.     UCHAR fill1;        /* Filler (zero) */
  595.     UCHAR dec_sep;        /* Decimal separator character */
  596.     UCHAR fill2;        /* Filler (zero) */
  597.     UCHAR date_sep;        /* Date separator character */
  598.     UCHAR fill3;         /* Filler (zero) */
  599.     UCHAR time_sep;        /* Time separator character */
  600.     UCHAR fill4;         /* Filler (zero) */
  601.     UCHAR curr_fmt;        /* Currency format */
  602.     UCHAR curr_ddec;    /* Number of digits after decimal */
  603.     UCHAR time_fmt;        /* Time format */
  604.     REALPTR cm_ptr;        /* Case map function pointer (real mode) */
  605.     UCHAR dlist_sep;    /* Data list separator character */
  606.     UCHAR fill5[11];    /* Filler */
  607. } COUNTRY_INFO;
  608.  
  609. #define DATE_USA        /* American date format */
  610. #define DATE_EUROPE        /* European date format */
  611. #define DATE_JAPAN        /* Japanese date format */
  612.  
  613. #define CURR_SPM    0x02    /* Number of spaces between currency symbol
  614.                    and value (0 or 1) */
  615. #define CURR_LOCM    0x01    /* Location mask */
  616. #define CURR_BEFORE    0x00    /* Currency symbol precedes value */
  617. #define CURR_AFTER    0x01    /* Currency symbol follows value */
  618.  
  619.  
  620. /*
  621.  
  622. Data structure for calling a protected mode procedure from real mode
  623. (using addr obtained from system call 250Dh).
  624.  
  625. */
  626.  
  627. typedef struct
  628. {
  629.     USHORT ds;        /* DS register */
  630.     USHORT es;        /* ES register */
  631.     USHORT fs;        /* FS register */
  632.     USHORT gs;        /* GS register */
  633. } PMC_BLK;
  634.  
  635.  
  636. /*
  637.  
  638. Data structure for call real mode procedure (2510h)
  639.  
  640. */
  641.  
  642. typedef struct
  643. {
  644.     USHORT ds;        /* DS register */
  645.     USHORT es;        /* ES register */
  646.     USHORT fs;        /* FS register */
  647.     USHORT gs;        /* GS register */
  648.     ULONG eax;        /* EAX register */
  649.     ULONG ebx;        /* EBX register */
  650.     ULONG ecx;        /* ECX register */
  651.     ULONG edx;        /* EDX register */
  652. } RMC_BLK;
  653.  
  654.  
  655. /*
  656.  
  657. Data structure for issue real mode interrupt (2511h)
  658.  
  659. */
  660.  
  661. typedef struct
  662. {
  663.     USHORT inum;        /* Interrupt number */
  664.     USHORT ds;        /* DS register */
  665.     USHORT es;        /* ES register */
  666.     USHORT fs;        /* FS register */
  667.     USHORT gs;        /* GS register */
  668.     ULONG eax;        /* EAX register */
  669.     ULONG edx;        /* EDX register */
  670. } RMI_BLK;
  671.  
  672.  
  673. /*
  674.  
  675. Data structure for load for debug system call (2512h and 252Ah)
  676.  
  677. */
  678.  
  679. typedef struct
  680. {
  681.     UCHAR *ex_eoff;        /* Offset of the environment segment */
  682.     USHORT ex_eseg;        /* Segment of the environment segment */
  683.     UCHAR *ex_coff;        /* Offset of the command tail */
  684.     USHORT ex_cseg;        /* Segment of the command tail */
  685.     UCHAR *ex_loff;        /* Offset of the LDT buffer */
  686.     USHORT ex_lseg;        /* Segment of the LDT buffer */
  687.     USHORT real_psp;    /* Real mode PSP address */
  688.     USHORT protf;        /* Protected mode flag */
  689.     ULONG eip;        /* Initial EIP */
  690.     USHORT cs;        /* Initial CS */
  691.     ULONG esp;        /* Initial ESP */
  692.     USHORT ss;        /* Initial SS */
  693.     USHORT ds;        /* Initial DS */
  694.     USHORT es;        /* Initial ES */
  695.     USHORT fs;        /* Initial FS */
  696.     USHORT gs;        /* Initial GS */
  697. } LDDBG_BLK;
  698.  
  699. /*
  700.  * Data structure for load EXP file system call (2529h)
  701.  */
  702. typedef struct
  703. {
  704.     ULONG    eip;        /* initial EIP */
  705.     USHORT    cs;        /* initial CS */
  706.     ULONG    esp;        /* initial ESP */
  707.     USHORT    ss;        /* initial SS */
  708.     USHORT ds;        /* Initial DS */
  709.     USHORT es;        /* Initial ES */
  710.     USHORT fs;        /* Initial FS */
  711.     USHORT gs;        /* Initial GS */
  712.     ULONG    minsize;    /* minimum size of program segment, in bytes */
  713.                 /* (any -OFFSET value, plus size of pgm in */
  714.                 /* EXP file, plus any -MINDATA value.  Same */
  715.                 /* as info at offset 5Ch in PSP for main pgm)*/
  716.     ULONG    extramem;    /* amount of extra memory, in bytes, beyond */
  717.                 /* the size of the pgm in the EXP file, that */
  718.                 /* was allocated (Same as info at offset 64h */
  719.                 /* in PSP for main pgm) */
  720.     ULONG    flags;        /* flags, defined below */
  721.     ULONG    rsrv[8];    /* reserved, always zeroed */
  722. } LDEXP_BLK;
  723. /* Bit definitions for flags word in LDEXP_BLK struct */
  724. #define LD_UNPRIV 0x00000001    /* if set, child was linked with -UNPRIV */
  725.                 /* switch, if cleared, child linked -PRIV */
  726.  
  727. /*
  728.  
  729. VM_STATS - Memory statistics data structure returned by 2520h system call.
  730.  
  731. */
  732.  
  733. typedef struct
  734. {
  735.     ULONG vm_presf;        /* 386|VMM is present flag */
  736.     ULONG vm_nconvpg;    /* Conventional memory physical page count */
  737.     ULONG vm_rsrv1;        /* reserved, always zero */
  738.     ULONG vm_nextpg;    /* Extended memory physical page count (this is
  739.                    an APPROXIMATE number) */
  740.     ULONG vm_extpglim;    /* Extended memory physical page limit */
  741.     ULONG vm_nallocpg;    /* Number of physical pages allocated to
  742.                    application */
  743.     ULONG vm_nlockpg;    /* Number of locked physical pages */
  744.     ULONG vm_nsyspg;    /* Number of physical pages allocated by
  745.                    386|DOS-Extender for system data */
  746.     ULONG vm_rsrv2;        /* reserved, contents undefined */
  747.     ULONG vm_dmin;        /* Linear address of the beginning of
  748.                    the dynamic linear range */
  749.     ULONG vm_dmax;        /* Linear address of 1 byte past the end of
  750.                    the dynamic linear range */
  751.     ULONG vm_eltime;    /* Elapse time in seconds since last
  752.                    VM status reset */
  753.     ULONG vm_pfltcnt;    /* Number of page faults since last
  754.                    VM status reset */
  755.     ULONG vm_wrtcnt;    /* Number of pages written out to disk
  756.                    since the last VM status reset */
  757.     ULONG vm_reclcnt;    /* Number of reclaimed pages since the
  758.                    last VM status reset */
  759.     ULONG vm_nvirtpg;    /* Number of virtual pages allocated to
  760.                    application */
  761.     ULONG vm_nswappg;    /* Size of swap file, in pages */
  762.     ULONG vm_rsrv3;        /* reserved, contents undefined */
  763.     ULONG vm_minconvpg;    /* Minimum number of conventional memory 
  764.                    pages required */
  765.     ULONG vm_maxswpg;    /* Max. size of swap file, in pages */
  766.     ULONG vm_flags;        /* flag bits */
  767.     ULONG vm_nfree;        /* number of free physical pages GUARANTEED 
  768.                    (total number of physical pages currently
  769.                    used by appl and 386|DOS-Extender system
  770.                    data is vm_nfree + vm_syspg + vm_nallocpg */
  771.     ULONG vm_navail;    /* number of free physical pages currently 
  772.                    available (equal to
  773.                    MIN(vm_nextpg, vm_extpglim) - vm_nlockpg - 
  774.                                    vm_syspg */
  775.     ULONG vm_rsrv[2];    /* Reserved, always zero */
  776. } VM_STATS;
  777.  
  778. /*
  779.  * Bit definitions for flags in VM_STATS structure
  780.  */
  781. #define VMFL_PGFLT    0x00000001    /* page fault in progress */
  782.  
  783. /*
  784.  * 386|VMM parameters block (Get/Set 386|VMM Parameters System Call)
  785.  */
  786. typedef struct
  787. {
  788.     ULONG    vp_flags;    /* flag bits */
  789.     ULONG    vp_vscan;    /* scan period, in milliseconds, for */
  790.                 /* updating page ageing information */
  791.     ULONG    vp_vslen;    /* max length, in bytes, of linear address */
  792.                 /* space to process on each page table scan */
  793.     ULONG    vp_rsrvd[13];    /* reserved for future expansion */
  794. } VM_PARAMS;
  795.  
  796. /*
  797.  * Bit definitions for flags in VM_PARAMS struct
  798.  */
  799. #define VMP_PGLOGEN    0x00000001    /* page fault logging enabled */
  800.  
  801. /*
  802.  * Data structure for Get Configuration Information call (2526h)
  803.  */
  804. typedef struct {
  805.     ULONG    c_flags1;    /* flags dword 1 */
  806.     ULONG    c_flags2;    /* flags dword 2 */
  807.     ULONG    c_flags3;    /* flags dword 3 */
  808.     ULONG    c_major;    /* 386|DOS-Extender major version # */
  809.     ULONG    c_minor;    /* 386|DOS-Extender minor version # */
  810.     ULONG    c_letter;    /* first letter, in ASCII, of text following */
  811.                 /* minor version # in version number string */
  812.                 /* 0 if no letter present */
  813.     ULONG    c_betaf;    /* 0 ==> not a beta version, 1 ==> beta */
  814.                 /* more than one letter following minor */
  815.                 /* version number) */
  816.     ULONG    c_processor;    /* 3 ==> 386, 4 ==> 486 */
  817.     ULONG    c_coproc;    /* 4 ==> none, 6 ==> 287, 7 ==> 387 or 486 */
  818.     ULONG    c_weitekf;    /* 0 ==> not present, 1 ==> present (see */
  819.                 /* also c_1167 below) */
  820.     ULONG    c_machine;    /* 0 ==> IBM compat, 1 ==> NEC 9800 series */
  821.     ULONG    c_mclass;    /* IBM:  0==>ISA, 1==>MCA, 2==>XT, 3==>EISA */
  822.                 /* NEC:  0==>normal mode, 1==>high res mode */
  823.     ULONG    c_dosenv;    /* VCPI flag; 0==>no VCPI, 1==>VCPI present */
  824.     ULONG    c_1167;        /* -WEITEK or -1167 switch setting:  */
  825.                 /* 0 ==> AUTO, 1 ==> ON, 2 ==> OFF */
  826.     ULONG    c_minreal;    /* -MINREAL switch setting */
  827.     ULONG    c_maxreal;    /* -MAXREAL switch setting */
  828.     ULONG    c_minibuf;    /* -MINIBUF switch setting */
  829.     ULONG    c_maxibuf;    /* -MAXIBUF switch setting */
  830.     ULONG    c_ibufsize;    /* size of data buf for DOS calls, in bytes */
  831.     ULONG    c_nistack;    /* -NISTACK switch setting */
  832.     ULONG    c_istksize;    /* -ISTKSIZE switch setting */
  833.     ULONG    c_realbreak;    /* -REALBREAK switch setting */
  834.     ULONG    c_callbufs;    /* -CALLBUFS switch setting */
  835.     ULONG    c_hwivec;    /* -HWIVEC switch setting */
  836.     ULONG    c_privec;    /* -PRIVEC switch setting */
  837.     ULONG    c_intmap;    /* -INTMAP switch setting */
  838.     ULONG    c_primap;    /* -PRIMAP switch setting */
  839.     ULONG    c_irq0;        /* hardware interrupt vector for IRQ0 when */
  840.                 /* running under VCPI */
  841.     ULONG    c_irq8;        /* HW interrupt vector for IRQ8 under VCPI, 0*/
  842.                 /* if running on an XT with only IRQ0-7 */
  843.     ULONG    c_prscreen;    /* interrupt vector for BIOS print screen, */
  844.                 /* 0 if c_machine == NEC */
  845.     ULONG    c_extlow;    /* -EXTLOW switch setting */
  846.     ULONG    c_exthigh;    /* -EXTHIGH switch setting */
  847.     ULONG    c_minext;    /* physical addr of lowest extended memory */
  848.                 /* 386|DOS-Extender will ever allocate */
  849.     ULONG    c_maxext;    /* physical addr of 1 byte past highest */
  850.                 /* ext mem 386|DOS-Extender will allocate */
  851.     ULONG    c_smem_base;    /* physical base addr of "special" memory */
  852.                 /* (either auto detected, or specified with */
  853.                 /* the -SPCLMEM switch, 0 if none) */
  854.     ULONG    c_smem_size;    /*size, in bytes, of "special" mem, 0 if none*/
  855.     ULONG    c_maxvcpimem;    /* -MAXVCPIMEM switch setting */
  856.     ULONG    c_vscan;    /* -VSCAN switch setting */
  857.     ULONG    c_swapchk;    /* -SWAPCHK switch setting:  0 ==> OFF, */
  858.                 /* 1 ==> ON, 2 ==> FORCE, 3 ==> MAX */
  859.     ULONG    c_codesize;    /* -CODESIZE switch setting */
  860.     ULONG    c_minswfsize;    /* -MINSWFSIZE switch setting */
  861.     ULONG    c_maxswfsize;    /* -MAXSWFSIZE switch setting */
  862.     ULONG    c_replpolicy;    /* 0 ==> LFU, 1 ==> NUR */
  863.     ULONG    c_ngdtent;    /* -NGDTENT switch setting */
  864.     ULONG    c_nldtent;    /* -NLDTENT switch setting */
  865.     ULONG    c_priv;        /*privilege level program is running at (0-3)*/
  866. /* the following values were added in release 3.0 of 386|DOS-Extender */
  867.     ULONG    c_lockstack;    /* -LOCKSTACK switch setting */
  868.     ULONG    c_maxextmem;    /* -MAXEXTMEM switch setting */
  869.     ULONG    c_maxxmsmem;    /* -MAXXMSMEM switch setting */
  870.     ULONG    c_maxpgmmem;    /* -MAXPGMMEM switch setting */
  871.     ULONG    c_datathresh;    /* -DATATHRESHOLD switch setting */
  872.     ULONG    c_vmmf;        /* 0 ==> 386|VMM not present, 1 ==> present */
  873.     ULONG    c_cyrixf;    /* 0==>Cyrix EMC387 not present, 1==>present*/
  874.     ULONG    c_cyrix;    /* -CYRIX switch setting, 0 ==> AUTO */
  875.                 /* 1 ==> ON, 2 ==> OFF */
  876.     ULONG    c_dpmif;    /* 0 ==> DPMI not present, 1 ==> present */
  877.     ULONG    c_dpmimaj;    /* DPMI major version number */
  878.     ULONG    c_dpmimin;    /* DPMI minor version number */
  879.     ULONG    c_dpmi_capf;    /* DPMI capabilities flags */
  880.     ULONG    c_vcpimaj;    /* VCPI major version number */
  881.     ULONG    c_vcpimin;    /* VCPI minor version number */
  882.     USHORT    c_vcpiirq0;    /* under VCPI, IRQ0 physical base int vector */
  883.     USHORT    c_vcpiirq8;    /* under VCPI, IRQ8 physical base int vector */
  884.     ULONG    c_xmsf;        /* 0 ==> XMS not present, 1 ==> present */
  885.     ULONG    c_xmsmaj;    /* XMS major version number */
  886.     ULONG    c_xmsmin;    /* XMS minor version number */
  887.     USHORT    c_cs_sel;    /* appl's CS selector */
  888.     USHORT    c_ds_sel;    /* appl's DS selector */
  889.     USHORT    c_psp_sel;    /* appl's PSP selector */
  890.     USHORT    c_env_sel;    /* appl's environment selector */
  891.     USHORT    c_dos_sel;    /* selector for segment mapping DOS 1MB */
  892.                 /* address space */
  893.     USHORT    c_vidtxt_sel;    /* selector for segment mapping video text */
  894.                 /* memory */
  895.     USHORT    c_vidgrph_sel;    /* selector for segment that maps video */
  896.                 /* graphics memory on NEC machines;  maps */
  897.                 /* the same memory as the video text segment */
  898.                 /* on IBM-compatible machines */
  899.     USHORT    c_weitek_sel;    /* selector of segment that maps Weitek */
  900.                 /* address space, 0 if no Weitek chip */
  901.     USHORT    c_cyrix_sel;    /* selector of segment that maps Cyrix EMC387*/
  902.                 /* address space, 0 if no Cyrix chip */
  903.     USHORT    c_unused;    /* reserved, always zero */
  904.     ULONG    c_swprot;    /* real mode FAR addr of 386|DOS-X routine */
  905.                 /* to CALL for a jump to protected mode */
  906.                 /* with no saved context */
  907.     ULONG    c_ldtsize;    /* size of LDT, in bytes */
  908.     ULONG    c_rsrv[57];    /* Reserved, always zero */
  909. } CONFIG_INF;
  910. /*
  911.  * Bit definitions for c_flags1.  c_flags2 and c_flags3 are currently unused.
  912.  */
  913. #define    CF1_NOPAGE    0x00000001L    /* -NOPAGE switch used */
  914. #define    CF1_A20        0x00000002L    /* -A20 switch used */
  915. #define    CF1_VDISK    0x00000004L    /* -VDISK switch used */
  916. #define    CF1_XT        0x00000008L    /* -XT switch used */
  917. #define    CF1_AT        0x00000010L    /* -AT switch used */
  918. #define    CF1_MCA        0x00000020L    /* -MCA switch used */
  919. #define    CF1_EISA    0x00000040L    /* -EISA switch used */
  920. #define    CF1_NORMRES    0x00000080L    /* -NORMRES switch (for NEC) used */
  921. #define    CF1_HIGHRES    0x00000100L    /* -HIGHRES switch (for NEC) used */
  922. #define    CF1_SWFGROW    0x00000200L    /* 1 ==> -SWFGROW1ST switch used, */
  923.                     /* 0 ==> -NOSWFGROW1ST */
  924. #define    CF1_NOVM    0x00000400L    /* -NOVM switch used */
  925. #define    CF1_SAVEREGS    0x00000800L    /* -SAVEREGS switch used */
  926. /*    0x00001000L            not used, always zero */
  927. #define    CF1_NOVCPI    0x00002000L    /* -NOVCPI switch used */
  928. #define    CF1_NOMUL    0x00004000L    /* -NOMUL switch used */
  929. #define    CF1_NOBMCHK    0x00008000L    /* -NOBMCHK switch used */
  930. #define    CF1_NOSPCL    0x00010000L    /* -NOSPCLMEM or -NOBIM switch used */
  931. #define    CF1_NOPGEXP    0x00020000L    /* -NOPGEXP switch used */
  932. #define    CF1_SWAPDEFDISK    0x00040000L    /* -SWAPDEFDISK switch used */
  933. /* the following values were added in release 3.0 of 386|DOS-Extender */
  934. #define CF1_SAVEINTS    0x00080000L    /* -SAVEINTS switch used */
  935. #define CF1_NOLOAD    0x00100000L    /* -NOLOAD switch used */
  936. #define CF1_PAGELOG    0x00200000L    /* -PAGELOG switch used */
  937. #define CF1_OPENDENY    0x00400000L    /* -OPENDENY switch used */
  938. #define CF1_ERRATA17    0x00800000L    /* -ERRATA17 switch used */
  939.  
  940. /*
  941.  * Flags bits for DPMI capabilities flags dword 
  942.  */
  943. #define CD_PAGING    0x00000001L    /* paging support capability present */
  944.                     /* (never present in 0.9 DPMI, always*/
  945.                     /* present if 1.0 or later DPMI) */
  946. #define CD_DEVMAP    0x00000002L    /* Physical Device Mapping capability*/
  947.                     /* present */
  948. #define CD_CONVMEM    0x00000004L    /* Conventional Memory Mapping */
  949.                     /* capability present */
  950. #define CD_EXCRSTRT    0x00000008L    /* Exceptions Restartability */
  951.                     /* capability present */
  952.  
  953. /*
  954.  * Data structure for system call 2528h and 2538h (get appl registers)
  955.  */
  956. typedef struct {
  957.     USHORT    u1;        /* unused, never modified */
  958.     ULONG    u2;        /* unused, never modified */
  959.     USHORT    u3;        /* unused, never modified */
  960.     ULONG    eax;        /* register EAX contents */
  961.     ULONG    ebx;        /* register EBX contents */
  962.     ULONG    ecx;        /* register ECX contents */
  963.     ULONG    edx;        /* register EDX contents */
  964.     ULONG    esi;        /* register ESI contents */
  965.     ULONG    edi;        /* register EDI contents */
  966.     ULONG    ebp;        /* register EBP contents */
  967.     ULONG    esp;        /* register ESP contents */
  968.     USHORT    cs;        /* register CS contents */
  969.     USHORT    ds;        /* register DS contents */
  970.     USHORT    ss;        /* register SS contents */
  971.     USHORT    es;        /* register ES contents */
  972.     USHORT    fs;        /* register FS contents */
  973.     USHORT    gs;        /* register GS contents */
  974.     ULONG    eip;        /* register EIP contents */
  975.     ULONG    flags;        /* register EFLAGS contents */
  976. } SWI_REGS;
  977.  
  978. /*
  979.  * Bit definitions for the page type word returned for each page by the
  980.  * Get Page Types call (system call 252Bh, subfunction 4)
  981.  *
  982.  * The flags bits apply only if the page type is allocated.
  983.  */
  984. #define PT_TYPE        0x000F    /* page type code field */
  985.     #define PTYP_UNMAP    0    /* unmapped page */
  986.     #define PTYP_ALLOC    1    /* allocated page */
  987.     #define PTYP_PHYSDEV    2    /* physical device page */
  988. #define PT_LOCKED    0x0010    /* allocated page is locked */
  989. #define PT_SWAPPED    0x0020    /* allocated page is swapped to disk */
  990. #define PT_ROFILE    0x0040    /* alloc'd page mapped to rd only data file */
  991. #define PT_RWFILE    0x0080    /* alloc'd page mapped to rd/wr data file */
  992.  
  993. /*
  994.  * Data structure for Read/Write System Registers system call 2535h 
  995.  */
  996.  
  997. typedef struct{
  998.     ULONG    cr0;        /* Control Register 0 */
  999.     ULONG    dr0;        /* Debug Register 0 */
  1000.     ULONG    dr1;        /* Debug Register 1 */
  1001.     ULONG    dr2;        /* Debug Register 2 */
  1002.     ULONG    dr3;        /* Debug Register 3 */
  1003.     ULONG    rsrv1[2];    /* reserved, always zeroed */
  1004.     ULONG    dr6;        /* Debug Register 6 */
  1005.     ULONG    dr7;        /* Debug Register 7 */
  1006.     ULONG    rsrv2[3];    /* reserved, always zeroed */
  1007. } SYS_REGS;
  1008.  
  1009. /*
  1010.  * Record numbers for page log file created by 386|VMM if the
  1011.  * -PAGELOG switch is used
  1012.  */
  1013. #define PREC_BASE    0    /* segment base changed record */
  1014. #define PREC_LIMIT    1    /* segment limit changed record */
  1015. #define PREC_PGFLT    2    /* page fault record */
  1016. #define PREC_SWAPSIZ    3    /* swap file size increased record */
  1017. #define PREC_APPL    4    /* application-defined record */
  1018.  
  1019. /*
  1020.  * Flag bit definitions for the flags byte in a page fault record 
  1021.  */
  1022. #define PLOG_DSKRD    0x01    /* set if page read from swap file, EXP */
  1023.                 /* file, or mapped data file;  cleared if */
  1024.                 /* page was just zeroed */
  1025. #define PLOG_SWAPRD    0x02    /* set if read from swap file, cleared if */
  1026.                 /* read from EXP file or mapped data file */
  1027. #define PLOG_THRASH    0x04    /* set if this page has been in memory */
  1028.                 /* before, cleared if 1st time in memory */
  1029. #define PLOG_REPLCD    0x08    /* set if another virtual page was replaced */
  1030.                 /* (kicked out of memory), cleared if a free */
  1031.                 /* physical page was available.  If set, */
  1032.                 /* the DWORD at offset 6 in the page fault */
  1033.                 /* record is present, and specifies the */
  1034.                 /* linear addr of the replaced page */
  1035. #define PLOG_SWAPWR    0x10    /* set if replaced page written to swap file */
  1036.                 /* or to a read/write mapped data file, */
  1037.                 /* cleared if replaced page just discarded */
  1038.                 /* because it was unmodified */
  1039.  
  1040. /*    
  1041.  * Function prototypes for C-callable routines in DOSX32.LIB, to make
  1042.  * 386|DOS-Extender system calls from C.
  1043.  *
  1044.  * All functions return an error code, a zero value (_DOSE_NONE) meaning 
  1045.  * no error.
  1046.  */
  1047. extern int _dx_reset_data(void);
  1048. extern int _dx_pmiv_get(UINT int_no, FARPTR *int_handpp);
  1049. extern int _dx_rmiv_get(UINT int_no, REALPTR *int_handpp);
  1050. extern int _dx_pmiv_set(UINT int_no, FARPTR int_handp);
  1051. extern int _dx_rmiv_set(UINT int_no, REALPTR int_handp);
  1052. extern int _dx_apmiv_set(UINT int_no, FARPTR int_handp);
  1053. extern int _dx_rpmiv_set(UINT int_no, FARPTR pm_int_handp,
  1054.                      REALPTR rm_int_handp);
  1055. extern int _dx_tolinear(USHORT selector, ULONG *lin_addrp);
  1056. extern int _dx_tophys(ULONG lin_addr, ULONG *phys_addrp);
  1057. extern int _dx_map_phys(USHORT selector, ULONG phys_addr, ULONG page_cnt,
  1058.                 ULONG *offsetp);
  1059. extern int _dx_hwiv_get(UINT *irq0_7p, UINT *irq8_15p, UINT *prt_scrp);
  1060. extern int _dx_rmlink_get(REALPTR *cback_addrpp, REALPTR *rm_cbuff_addrpp,
  1061.                ULONG *cbuff_sizep, FARPTR *pm_cbuff_addrpp);
  1062. extern int _dx_real_call(REALPTR proc_addr, UINT word_cnt);
  1063. extern int _dx_toreal(FARPTR pm_addrp, ULONG byte_cnt, REALPTR *rm_addrpp);
  1064. extern int _dx_real_regcall(REALPTR proc_addrp, ULONG word_cnt, 
  1065.                     RMC_BLK *parmp);
  1066. extern int _dx_real_int(RMC_BLK *parmp);
  1067. extern int _dx_dbg_load(UCHAR *prog_namep, LDDBG_BLK *parmp, UINT ldt_bytes,
  1068.               UINT *sel_countp);
  1069. extern int _dx_seg_alias(USHORT selector, UINT acc_rights, UINT use_types, 
  1070.                      USHORT *alias_selp);
  1071. extern int _dx_segattr_set(USHORT selector, UINT acc_rights, UINT use_types);
  1072. extern int _dx_segattr_get(USHORT selector, UINT *acc_rightsp, 
  1073.                UINT *use_typesp);
  1074. extern int _dx_ldtmem_free(void);
  1075. extern int _dx_dosbuf_get(FARPTR *pm_buffpp, REALPTR *rm_buffpp,
  1076.                  ULONG *buff_sizep);
  1077. extern int _dx_segmove_hand(FARPTR new_handp, FARPTR *old_handpp);
  1078. extern int _dx_memerr_get(void);
  1079. extern int _dx_page_lock(FARPTR addrp, ULONG npage);
  1080. extern int _dx_page_lockl(ULONG linadr, ULONG npage);
  1081. extern int _dx_page_unlock(FARPTR addrp, ULONG npage);
  1082. extern int _dx_page_unlockl(ULONG linadr, ULONG npage);
  1083. extern int _dx_page_free(FARPTR addrp, ULONG npage, BOOL discardf);
  1084. extern int _dx_page_freel(ULONG linadr, ULONG npage, BOOL discardf);
  1085. extern int _dx_pte_read(FARPTR addrp, ULONG *valp);
  1086. extern int _dx_pte_readl(ULONG linadr, ULONG *valp);
  1087. extern int _dx_pte_write(FARPTR addrp, ULONG val);
  1088. extern int _dx_pte_writel(ULONG linadr, ULONG val);
  1089. extern int _dx_pte_xchg(FARPTR addr1p, FARPTR addr2p);
  1090. extern int _dx_pte_xchgl(ULONG linaddr1, ULONG linadr2);
  1091. extern int _dx_vm_stats(VM_STATS *statp, BOOL resetf);
  1092. extern int _dx_xmem_limit(ULONG npages, ULONG *minp, ULONG *maxp);
  1093. extern int _dx_pgflt_hand(FARPTR new_handp, FARPTR *old_handpp);
  1094. extern int _dx_oswsp_hand(FARPTR new_addrp, FARPTR *old_addrpp);
  1095. extern int _dx_pgrepl_hand(FARPTR new_raddrp, FARPTR *old_raddrpp,
  1096.                FARPTR new_taddrp, FARPTR *old_taddrpp,
  1097.                FARPTR new_paddrp, FARPTR *old_paddrpp);
  1098. extern int _dx_cmem_limit(ULONG npages, ULONG *minp, ULONG *maxp);
  1099. extern int _dx_config_inf(CONFIG_INF *bufp, UCHAR *swf_namep);
  1100. extern int _dx_dbg_regsav(BOOL savf);
  1101. extern int _dx_cc_rdregs(SWI_REGS *buffp);
  1102. extern    int _dx_ld_flat(UCHAR *prog_namep, LDEXP_BLK *parmp, BOOL dmdloadf, 
  1103.             UINT *vmmhp, UINT *errinfop, UINT *doserrp);
  1104. extern int _dx_dbg_ld(UCHAR *prog_namep, LDDBG_BLK *parmp, UINT ldt_bytes,
  1105.                       BOOL dmdloadf, UINT *vmmhp, UINT *ndescp,
  1106.                UINT *errinfop, UINT *doserrp);
  1107. extern    int _dx_umap_pgs(FARPTR addrp, UINT len);
  1108. extern    int _dx_umap_pgsl(ULONG linadr, UINT len);
  1109. extern    int _dx_alloc_pgs(FARPTR addrp, UINT len);
  1110. extern    int _dx_alloc_pgsl(ULONG linadr, UINT len);
  1111. extern    int _dx_map_pgs(FARPTR addrp, UINT len, ULONG baseaddr);
  1112. extern    int _dx_map_pgsl(ULONG linadr, UINT len, ULONG baseaddr);
  1113. extern    int _dx_mfile_pgs(FARPTR addrp, UINT len, UCHAR *fnamep, USHORT facc,
  1114.                       UINT *vmmhp, UINT *flenp, UINT *errinfo, UINT *doserr);
  1115. extern    int _dx_mfile_pgsl(ULONG linadr, UINT len, UCHAR *fnamep, USHORT facc,
  1116.                        UINT *vmmhp, UINT *flenp, UINT *errinfo, UINT *doserr);
  1117. extern    int _dx_gtyp_pgs(FARPTR addrp, UINT len, UCHAR *buffp);
  1118. extern    int _dx_gtyp_pgsl(ULONG linadr, UINT len, UCHAR *buffp);
  1119. extern    int _dx_lock_pgs(FARPTR addrp, UINT len);
  1120. extern    int _dx_lock_pgsl(ULONG linadr, UINT len);
  1121. extern    int _dx_ulock_pgs(FARPTR addrp, UINT len);
  1122. extern    int _dx_ulock_pgsl(ULONG linadr, UINT len);
  1123. extern    int _dx_fphys_pgs(FARPTR addrp, UINT len, BOOL discardf);
  1124. extern    int _dx_fphys_pgsl(ULONG linadr, UINT len, BOOL discardf);
  1125. extern int _dx_add_umapg(USHORT selector, ULONG page_cnt, UINT *segoffp);
  1126. extern int _dx_vmm_close(UINT vmmhndl);
  1127. extern int _dx_vmm_pget(VM_PARAMS *buffp);
  1128. extern int _dx_vmm_pset(VM_PARAMS *buffp);
  1129. extern int _dx_vmm_wlog(UCHAR *datap, USHORT datasiz);
  1130. extern int _dx_dosbuf_set(UINT buffsiz);
  1131. extern int _dx_ldt_rd(USHORT selector, UCHAR *descp);
  1132. extern int _dx_ldt_wr(USHORT selector, UCHAR *descp);
  1133. extern int _dx_excep_get(UCHAR num, FARPTR *evecpp);
  1134. extern int _dx_excep_set(UCHAR num, FARPTR evecp);
  1135. extern int _dx_if_get(BOOL *iflg);
  1136. extern int _dx_sysregs_get(SYS_REGS *buffp);
  1137. extern int _dx_sysregs_set(SYS_REGS *buffp);
  1138. extern int _dx_cmem_usage(ULONG npages, BOOL maximizef, ULONG *minp, 
  1139.                             ULONG *maxp);
  1140. extern int _dx_ext_usage(ULONG npages, BOOL maximizef, ULONG *minp, 
  1141.                             ULONG *maxp);
  1142. extern int _dx_real_above(UINT para_count, USHORT *para_addrp,
  1143.               USHORT *largestp);
  1144. extern int _dx_swi_rdregs(SWI_REGS *buffp, BOOL nextf, ULONG *ihndp,
  1145.                         ULONG *intnump);
  1146. extern int _dx_hdroff_get(ULONG hndl, ULONG *hdroffp, ULONG *fep, 
  1147.                             USHORT *dosep);
  1148. extern int _dx_msegfail_hnd(FARPTR new_hndp, FARPTR *old_hndpp);
  1149. extern int _dx_jmp_toreal(SWI_REGS *buffp);
  1150. extern int _dx_shrink_swap(ULONG *old_nbytep, ULONG *new_nbytep);
  1151. extern int _dx_idt_rd(UINT int_no, UCHAR *descp);
  1152. extern int _dx_idt_wr(UINT int_no, UCHAR *descp);
  1153. extern int _dx_real_alloc(UINT para_count, USHORT *para_addrp, 
  1154.               USHORT *largestp);
  1155. extern int _dx_real_free(USHORT para_addr);
  1156. extern int _dx_real_resize(USHORT para_addr, UINT para_count,
  1157.             USHORT *largestp);
  1158. extern int _dx_exec_spec(UCHAR *pathp, EXEC_BLK *parmp);
  1159.  
  1160. /*    
  1161.  * Function prototypes for C-callable routines in DOS32.LIB, to make
  1162.  * 32-bit DOS system calls from C.
  1163.  *
  1164.  * All functions return an error code, a zero value (_DOSE_NONE) meaning 
  1165.  * no error.
  1166.  */
  1167. extern int _dos_char_ine(UCHAR *chp);
  1168. extern int _dos_char_out(UCHAR ch);
  1169. extern int _dos_str_out(UCHAR *strp);
  1170. extern int _dos_buff_in(UCHAR *bufp);
  1171. extern int _dos_ver(ULONG dxinfo, ULONG *verp, ULONG *dxverp, ULONG *dxenvp);
  1172. extern int _dos_create(UCHAR *fnamep, USHORT attr, USHORT *handlep);
  1173. extern int _dos_open(UCHAR *fnamep, USHORT attr, USHORT *handlep);
  1174. extern int _dos_close(USHORT handle);
  1175. extern int _dos_read(USHORT handle, int nbytes, FARPTR bufp, int *nreadp);
  1176. extern int _dos_write(USHORT handle, int nbytes, FARPTR bufp, int *nwritep);
  1177. extern int _dos_delete(UCHAR *fnamep);
  1178. extern int _dos_seek(USHORT handle, int origin, LONG offset,ULONG *new_filep);
  1179. extern int _dos_force_hnd(USHORT hnd, USHORT newhnd);
  1180. extern int _dos_seg_alloc(ULONG npages, USHORT *selectorp, ULONG *maxpgsp);
  1181. extern int _dos_seg_free(USHORT selector);
  1182. extern int _dos_seg_resize(USHORT selector, ULONG npages, ULONG *maxpgsp);
  1183. extern int _dos_alloc_sset(USHORT strategy);
  1184. extern int _dos_alloc_sget(USHORT *stratp);
  1185.