home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l350 / 3.ddi / INCLUDE / DOSX.AH next >
Encoding:
Text File  |  1993-01-06  |  13.4 KB  |  386 lines

  1. comment #**********************************************************************
  2. /* $Id: dosx.ah 1.14 93/01/06 15:11:54 rwm Exp $ */
  3.  
  4. DOSX.AH - 386|DOS-Extender Interface Definitions
  5.  
  6. /************************************************************************/
  7. /*    Copyright (C) 1986-1988 Phar Lap Software, Inc.            */
  8. /*    Unpublished - rights reserved under the Copyright Laws of the    */
  9. /*    United States.  Use, duplication, or disclosure by the         */
  10. /*    Government is subject to restrictions as set forth in         */
  11. /*    subparagraph (c)(1)(ii) of the Rights in Technical Data and     */
  12. /*    Computer Software clause at 252.227-7013.            */
  13. /*    Phar Lap Software, Inc., 60 Aberdeen Ave., Cambridge, MA 02138    */
  14. /************************************************************************/
  15.  
  16. REVISION LOG
  17.  
  18. Rev. 1.00, JMB, 05-May-88    File creation date.
  19.  
  20.     FILE DESCRIPTION
  21.  
  22. This file contains the assembly language definitions for the interface
  23. between 386|DOS-Extender and an application program.
  24.  
  25. #******************************************************************************
  26. ;
  27. ; 386|DOS-Extender system call numbers
  28. ;
  29. DX_RESET_DATA    equ    2501h    ;/* Reset DOS-Extender data structures */
  30. DX_PMIV_GET    equ    2502h    ;/* Get protected mode interrupt */
  31. DX_RMIV_GET    equ    2503h    ;/* Get real mode interrupt */
  32. DX_PMIV_SET    equ    2504h    ;/* Set protected mode interrupt */
  33. DX_RMIV_SET    equ    2505h    ;/* Set real mode interrupt */
  34. DX_APMIV_SET    equ    2506h    ;/* Set both vecs to get control in prot mode 
  35. DX_RPMIV_SET    equ    2507h    ;/* Get both interrupts separately */
  36. DX_TOLINEAR    equ    2508h    ;/* Get linear base address */
  37. DX_TOPHYS    equ    2509h    ;/* Convert a linear address to physical */
  38. DX_MAP_PHYS    equ    250Ah    ;/* Map physical memory to the end of seg
  39. DX_HWIV_GET    equ    250Ch    ;/* Get hardware interrupt vector base */
  40. DX_RMLINK_GET    equ    250Dh    ;/* Get real mode link information */
  41. DX_REAL_CALL    equ    250Eh    ;/* Call a real mode procedure */
  42. DX_TOREAL    equ    250Fh    ;/* Convert prot mode address to real addr
  43. DX_REAL_REGCALL equ    2510h    ;/* Call a real mode proc with register args
  44. DX_REAL_INT    equ    2511h    ;/* Issue a real mode int with register args
  45. DX_DBG_LOAD    equ    2512h    ;/* Load a program for debugging */
  46. DX_SEG_ALIAS    equ    2513h    ;/* Alias a segment */
  47. DX_SEGATTR_SET    equ    2514h    ;/* Set segment attributes */
  48. DX_SEGATTR_GET    equ    2515h    ;/* Get segment attributes */
  49. DX_LDTMEM_FREE    equ    2516h    ;/* Free all memory owned by LDT */
  50. DX_DBUFF_GET    equ    2517h    ;/* Get info on DOS data buffer */
  51. DX_SEGMOV_HAND    equ    2518h    ;/* Specify handler for moved segments */
  52. DX_MEMERR_GET    equ    2519h    ;/* Get additional memory error info */
  53. DX_LOCK_PAGE    equ    251Ah    ;/* Lock pages in memory */
  54. DX_UNLOCK_PAGE    equ    251Bh    ;/* Unlock pages in memory */
  55. DX_PAGE_FREE    equ    251Ch    ;/* Free physical memory pages */
  56. DX_PTE_READ    equ    251Dh    ;/* Read page table entry */
  57. DX_PTE_WRITE    equ    251Eh    ;/* Write page table entry */
  58. DX_PTE_XCHG    equ    251Fh    ;/* Exchange page table entries */
  59. DX_VM_STATS    equ    2520h    ;/* Get memory statistics */
  60. DX_XMEM_LIMIT    equ    2521h    ;/* Limit program's extended memory usage */
  61. DX_PGFLT_HAND    equ    2522h    ;/* Specify alternate page fault handler */
  62. DX_OSWSP_HAND    equ    2523h    ;/* Specify out-of-swap-space handler */
  63. DX_PGREPL_HAND    equ    2524h    ;/* Specify page replacement handlers */
  64. DX_CMEM_LIMIT    equ    2525h    ;/* Limit program's conventional memory usage 
  65. DX_CONFIG_INF    equ    2526h    ;/* Get Configuration Information */
  66. DX_DBG_FLAGS    equ    2527h    ;/* Set debug flags */
  67. DX_CC_RDREGS    equ    2528h    ;/* Read registers after Ctrl/C interrupt*/
  68. DX_LOAD_EXP    equ    2529h    ;/* Load Flat Model EXP file **/
  69. DX_DBG_NEWLD    equ    252Ah    ;/* New load pgm for debug 
  70. DX_MEM_MGT    equ    252Bh    ;/* Memory region page management */
  71. DX_ADD_UNMAP    equ    252Ch    ;/* Add unmapped pages at end of segment */
  72. DX_CLOSE_VMH    equ    252Dh    ;/* Close VMM file handle */
  73. DX_VMM_PARAMS    equ    252Eh    ;/* Get/Set VMM parameters */
  74. DX_WR_PAGELOG    equ    252Fh    ;/* Write record to VMM page log file */
  75. DX_SET_DOSBUF    equ    2530h    ;/* Set size of data buffer used for DOS calls
  76. DX_RW_LDTDESC    equ    2531h    ;/* Read/Write LDT descriptor */
  77. DX_PMEXC_GET    equ    2532h    ;/* Get prot mode processor exception vector */
  78. DX_PMEXC_SET    equ    2533h    ;/* Set prot mode processor exception vector */
  79. DX_IF_GET    equ    2534h    ;/* Get interrupt flag */
  80. DX_SR_RW    equ    2535h    ;/* Read/Write System Registers */
  81. DX_MEM_USAGE    equ    2536h    ;/* Min/Max Ext/Conv Memory Usage */
  82. DX_REAL_ADDB    equ    2537h    ;/* Allocate DOS memory above DOS Data Buffer
  83. DX_SWI_RDREGS equ    2538h  ;/* Read PM regs after a SW interrupt */
  84. DX_GET_HDROFF equ    2539h    ;/* Get Offset of EXP file header */
  85. DX_MSEG_FAILH equ    253Ah    ;/* Install Mod. Segment Failure Handler */
  86. DX_TOREAL_JMP equ    253Bh  ;/* Jump to real mode code, no context saved */
  87. DX_SHRINK_SWAP    equ    253Ch    ; shrink size of 386|VMM swap file
  88. DX_RW_IDTDESC    equ    253Dh    ; read/write IDT descriptor
  89. DX_PROC_MFREE    equ    253Eh    ;/* Free process LDT resources */
  90. DX_REAL_ALLOC    equ    25C0h    ;/* Allocate real mode memory */
  91. DX_REAL_FREE    equ    25C1h    ;/* Release real mode memory */
  92. DX_REAL_RESIZE    equ    25C2h    ;/* Change size of a real mode memory block
  93. DX_EXEC_SPEC    equ    25C3h    ;/* Special program execute call */
  94.  
  95. ;
  96. ; 386|DOS-Extender error codes
  97. ;
  98. _DXE_LDT_SIZE    equ    128    ; LDT buf too small in load for debug call */
  99. _DXE_BAD_PARAM    equ    129    ; Bad parameter passed in to system call */
  100. _DXE_NOT_DPMI    equ    130    ; Operation not supported under this */
  101.                 ; DPMI implementation */
  102. _DXE_DBG_NOSAV    equ    131    ; Register saving for debuggers not enabled */
  103. _DXE_DBG_NOREG    equ    132    ; Register buffer for debuggers is empty */
  104. _DXE_NO_PAGELOG    equ    133    ; Attempt to write to VMM page log file */
  105.                 ; when no file exists */
  106. _DXE_MAX_VMH    equ    134    ; Maximum number of 386|VMM file handles */
  107.                 ; are already allocated */
  108.  
  109. ;
  110. ; Parameter block used for Call through from real to protected mode
  111. ; system service.  (Documented in Get Real Mode Link Information system
  112. ; call 250Dh)
  113. ;
  114. PMC_BLK    struc
  115.     PMC_DS    dw    ?    ; value to load into DS
  116.     PMC_ES    dw    ?    ; value to load into ES
  117.     PMC_FS    dw    ?    ; value to load into FS
  118.     PMC_GS    dw    ?    ; value to load into GS
  119. PMC_BLK    ends
  120.  
  121. ;
  122. ; Parameter block passed to Call Real Mode Procedure system call (2510h)
  123. ;
  124. RMC_BLK    struc
  125.     RMC_DS    dw    ?    ; real mode DS value
  126.     RMC_ES    dw    ?    ; real mode ES value
  127.     RMC_FS    dw    ?    ; real mode FS value
  128.     RMC_GS    dw    ?    ; real mode GS value
  129.     RMC_EAX    dd    ?    ; real mode EAX value
  130.     RMC_EBX    dd    ?    ; real mode EBX value
  131.     RMC_ECX    dd    ?    ; real mode ECX value
  132.     RMC_EDX    dd    ?    ; real mode EDX value
  133. RMC_BLK    ends
  134.  
  135. ;
  136. ; Parameter block passed to Issue Real Mode Interrupt system call (2511h)
  137. ;
  138. RMI_BLK    struc
  139.     RMI_INUM dw    ?    ; interrupt to issue
  140.     RMI_DS    dw    ?    ; real mode DS value
  141.     RMI_ES    dw    ?    ; real mode ES value
  142.     RMI_FS    dw    ?    ; real mode FS value
  143.     RMI_GS    dw    ?    ; real mode GS value
  144.     RMI_EAX    dd    ?    ; real mode EAX value
  145.     RMI_EDX    dd    ?    ; real mode EDX value
  146. RMI_BLK    ends
  147.  
  148. ;
  149. ; Parameter block passed to Exec system calls (AH=4B or AX=25C3)
  150. ;
  151. EXEC_BLK struc
  152.     EX_EOFF dd ?        ; Pointer to environment string
  153.     EX_ESEG dw ?            ;
  154.     EX_COFF dd ?        ; Pointer to command tail string
  155.     EX_CSEG dw ?            ;
  156. EXEC_BLK ends
  157.  
  158. ;
  159. ; Parameter block passed to Load Pgm for Debug system call (2512)
  160. ;
  161. LDDBG_BLK struc
  162.     db (size EXEC_BLK) dup (?) ; same as EXEC parameter block
  163.     EX_LOFF    dd    ?    ; Pointer to LDT buffer to fill in
  164.     EX_LSEG    dw    ?        ;
  165. ;
  166. ; Outputs: Child program's important values.
  167. ;
  168.     LD_REAL_PSP dw    ?    ; program's real mode PSP segment address
  169.     LD_PROTF dw    ?    ; 1 ==> prot mode pgm, 0 => real mode pgm
  170.     LD_EIP    dd    ?    ; initial register values
  171.     LD_CS    dw    ?        ;
  172.     LD_ESP    dd    ?        ;
  173.     LD_SS    dw    ?        ;
  174.     LD_DS    dw    ?        ;
  175.     LD_ES    dw    ?        ;
  176.     LD_FS    dw    ?        ;
  177.     LD_GS    dw    ?        ;
  178. LDDBG_BLK ends
  179.  
  180. ;
  181. ; Data structure for load EXP file system call (2529h)
  182. ;
  183. LDEXP_BLK struc
  184.     LX_EIP    dd    ?    ; initial EIP
  185.     LX_CS    dw    ?    ; initial CS
  186.     LX_ESP    dd    ?    ; initial ESP
  187.     LX_SS    dw    ?    ; initial SS
  188.     LX_DS    dw    ?    ; initial DS
  189.     LX_ES    dw    ?    ; initial ES
  190.     LX_FS    dw    ?    ; initial FS
  191.     LX_GS    dw    ?    ; initial GS
  192.     LX_MINSIZE dd    ?    ; min size of pgm segment
  193.     LX_EXTRAMEM dd    ?    ; amt of extra mem allocated 
  194.     ; from here to LDEXP_SIZE zeroed
  195. LDEXP_BLK ends
  196. LDEXP_SIZE equ    64    ; size of load EXP param block, in bytes
  197.  
  198. ;
  199. ; Data struct for info returned by Read Regs From Int (2528h, 2538h).
  200. ;
  201. SWI_REGS struc
  202.         dw    ?    ; unused, not modified
  203.         dd    ?    ; unused, not modified
  204.         dw    ?    ; unused, not modified
  205.     SWI_EAX    dd    ?
  206.     SWI_EBX    dd    ?
  207.     SWI_ECX    dd    ?
  208.     SWI_EDX    dd    ?
  209.     SWI_ESI    dd    ?
  210.     SWI_EDI    dd    ?
  211.     SWI_EBP    dd    ?
  212.     SWI_ESP    dd    ?
  213.     SWI_CS    dw    ?
  214.     SWI_DS    dw    ?
  215.     SWI_SS    dw    ?
  216.     SWI_ES    dw    ?
  217.     SWI_FS    dw    ?
  218.     SWI_GS    dw    ?
  219.     SWI_EIP    dd    ?
  220.     SWI_EFLAGS dd    ?
  221. SWI_REGS ends
  222.  
  223. ;
  224. ; Data structure pointed to by DS:ESI on Map Data File at Offset call
  225. ; (system call 252Bh, subfunction 11)
  226. ;
  227. MAP_FILE struc
  228.     MF_STARTOFFS dd    ?    ; starting BYTE offset to map in file */
  229.     MF_ACCESS dd    ?    ; file access and sharing mode for file open*/
  230. MAP_FILE ends
  231.  
  232. ;
  233. ; Data struct for read/write system regs (2535h).
  234. ;
  235. SYS_REGS struc
  236.     SR_CR0    dd    ?
  237.     SR_DR0    dd    ?
  238.     SR_DR1    dd    ?
  239.     SR_DR2    dd    ?
  240.     SR_DR3    dd    ?
  241.         dd    ?
  242.         dd    ?
  243.     SR_DR6    dd    ?
  244.     SR_DR7    dd    ?
  245.         dd    ?
  246.         dd    ?
  247.         dd    ?
  248. SYS_REGS ends
  249.  
  250. ;**************************************************************
  251. ; Interrupt stack frame
  252. ;**************************************************************
  253. INT_CR2 equ    (dword ptr 56[esp])    ; CR2 at time of interrupt
  254. INT_INUM equ    (dword ptr 52[esp])    ; interrupt number
  255. INT_FL equ    (dword ptr 48[esp])    ; flag bits
  256.     IFL_RMODE equ    00000001h        ; int occurred in real mode
  257.     IFL_LDSREGS equ    00000002h        ; load seg regs on return
  258. INT_GS equ    (dword ptr 44[esp])    ; GS at time of interrupt
  259. INT_FS equ    (dword ptr 40[esp])    ; FS at time of interrupt
  260. INT_DS equ    (dword ptr 36[esp])    ; DS at time of interrupt
  261. INT_ES equ    (dword ptr 32[esp])    ; ES at time of interrupt
  262. INT_SS equ    (dword ptr 28[esp])    ; SS:ESP at time of interrupt
  263. INT_ESP equ    (dword ptr 24[esp])        ;
  264. INT_EFLAGS equ    (dword ptr 20[esp])    ; EFLAGS at time of interrupt
  265. INT_CS equ    (dword ptr 16[esp])    ; CS:EIP at time of interrupt
  266. INT_EIP equ    (dword ptr 12[esp])        ;
  267. INT_DOSX_EFL equ (dword ptr 8[esp])    ; return stack frame in
  268. INT_DOSX_CS equ    (dword ptr 4[esp])        ; 386|DOS-Extender handler
  269. INT_DOSX_EIP equ (dword ptr [esp])        ; DO NOT MODIFY
  270. ; for exceptions 8 and 10-14, there is also an error code 
  271.  
  272. ;**************************************************************
  273. ; segment selectors in DOS-Extender descriptor tables
  274. ;**************************************************************
  275. ;
  276. ; Bit which indicates LDT vs. GDT selector
  277. ;
  278. SEL_LDT    equ 0004h        ; table indicator; 0 ==> GDT, 1 ==> LDT
  279.  
  280. ;
  281. ; GDT selectors
  282. ;
  283. SS_NULL        equ    0000h    ; system null segment selector
  284. SS_LDT        equ     0028h    ; LDT system segment
  285. SS_DLDT        equ    0030h    ; data segment mapping the LDT
  286. SS_DGDT        equ    0038h    ; data segment mapping the GDT
  287. SS_DIDT        equ    0050h    ; data segment mapping the IDT
  288. SS_TSS        equ    0080h    ; DOS-X TSS system segment
  289. SS_DTSS        equ    0088h    ; data segment mapping the DOS-X TSS
  290. SS_PGTAB    equ    00D0h    ; page table segment
  291. SS_PTINF    equ    00D8h    ; page table info
  292.  
  293. ;
  294. ; LDT segment selectors
  295. ;
  296. SS_CODE        equ    0008h or SEL_LDT ; User code segment
  297. SS_DATA        equ    0010h or SEL_LDT ; User data segment
  298. SS_SCREEN    equ    0018h or SEL_LDT ; User text screen segment
  299. SS_PSP        equ    0020h or SEL_LDT ; User PSP
  300. SS_ENV        equ    0028h or SEL_LDT ; User DOS environment strings
  301. SS_DOSMEM    equ    0030h or SEL_LDT ; Writeable data segment for lower
  302.                         ; 1 megabyte of memory
  303. SS_1167        equ    0038h or SEL_LDT ; Weitek 1167, 3167, 4167 coprocessor
  304. SS_WEITEK    equ    0038h or SEL_LDT ; Weitek 1167, 3167, 4167 coprocessor
  305. SS_GRAPHICS    equ    0040h or SEL_LDT ; User graphics screen segment
  306. SS_CYRIX    equ    004Ch or SEL_LDT ; Cyrix EMC87 coprocessor
  307.  
  308. ;****************************************************************
  309. ; Page Tables
  310. ;****************************************************************
  311. ;
  312. ; Software-defined page table entry bit definitions for pages marked present.
  313. ;
  314. PE_ALLOC equ    00000200h    ; page was actually allocated, as opposed to
  315.                 ; just mapped in with system call 250Ah
  316. PE_LOCKED equ    00000800h    ; page is locked in memory
  317.  
  318. ;
  319. ; Bit definitions for a page table entry for a swapped page
  320. ;
  321. SPE_SWAPPED equ    00000002h    ; page is swapped to disk
  322. SPE_ZERO equ    00000004h    ; zero page and mark it dirty when it is
  323.                 ; ref'd, instead of reading it in from disk
  324. SPE_REPLCD equ    00000008h    ; page was replaced (kicked out of memory) -
  325.                 ; used only for statistics keeping
  326.  
  327. ;
  328. ; Bit definitions for DWORD entry kept in page table info segment for each
  329. ; page table entry, if VM is present
  330. ;
  331. PTI_LFUCNT equ    0F0000000h    ; LFU count field
  332. PTI_ONDISK equ    00800000h    ; page is on disk
  333. PTI_INEXP equ    00400000h    ; page is in EXP file, not swap file
  334.  
  335. ;
  336. ; Boolean Values
  337. ;
  338. TRUE    equ    1            ; Boolean 'true' value
  339. FALSE    equ    0            ; Boolean 'false' value
  340.  
  341. ;
  342. ; FASTMOVS -- macro to copy memory efficiently
  343. ;
  344. ;    Input:    DS:ESI = source buffer
  345. ;        ES:EDI = destination buffer
  346. ;        ECX = byte count
  347. ;        DF = 0
  348. ;
  349. ;    Output: ESI,EDI    advanced to one byte past copied data
  350. ;        ECX    0
  351. ;        EAX    destroyed
  352. ;
  353. FASTMOVS macro
  354.     mov    eax,ecx            ;; save low 2 bits of ECX
  355.     shr    ecx,2            ;; move all doublewords
  356.     rep movsd
  357.     mov    ecx,eax            ;; get back low 2 bits
  358.     and    ecx,3
  359.     rep movsb            ;; move remaining bytes
  360.     endm
  361.  
  362. ;
  363. ; FASTSTOS -- macro to store memory efficiently
  364. ;
  365. ;    Input:    ES:EDI = destination buffer
  366. ;        ECX = byte count
  367. ;        AL = byte to store
  368. ;        DF = 0
  369. ;
  370. ;    Output: EDI    advanced to one byte past stored data
  371. ;        ECX    0
  372. ;        EAX,EDX    destroyed
  373. ;
  374. FASTSTOS macro
  375.     mov    ah,al            ;; replicate AL throughout EAX
  376.     push    ax
  377.     shl    eax,16
  378.     pop    ax
  379.     mov    edx,ecx            ;; save low 2 bits of ECX
  380.     shr    ecx,2            ;; store all doublewords
  381.     rep stosd
  382.     mov    ecx,edx            ;; get back low 2 bits
  383.     and    ecx,3
  384.     rep stosd            ;; store remaining bytes
  385.     endm
  386.