home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-386-Vol-2of3.iso / b / bc3.zip / DPMI.H < prev    next >
C/C++ Source or Header  |  1992-02-17  |  51KB  |  1,635 lines

  1. //
  2. // (c) Copyright 1992, Qualitas, Inc. All Rights Reserved
  3. //
  4. // dpmi.h - header file for Qualitas DPMI Library
  5. //
  6.  
  7.  
  8. #ifndef __BORLANDC__
  9. #define MK_FP(s,o) ((void far *)(((unsigned long)s << 16)|(unsigned short)o))
  10. #endif
  11.  
  12. #ifndef __DPMI__
  13. #define __DPMI__ 1
  14.  
  15. #define theCodeSel getCS()
  16. #define theDataSel getDS()
  17.  
  18. // basic typedefs
  19.  
  20. typedef unsigned char    uChar;
  21. typedef unsigned int    uShort;
  22. typedef unsigned long    uLong;
  23. typedef    unsigned short    selector_t;
  24. typedef enum {TRUE=1, FALSE=0} boolean;
  25.  
  26. // structure for LDT descriptor management
  27.  
  28. struct descriptor_t 
  29. {
  30.     uShort descLimit;    // descriptor limit
  31.     uShort descBaseLo;    // low word of linear base
  32.     uChar  descBaseMid;    // middle byte of linear base
  33.     uChar  descArb;        // access rights/type byte
  34.     uChar  descArb386;    // extended attributes byte (386+)
  35.     uChar  descBaseHi;    // high byte of linear base
  36. };
  37.  
  38.  
  39. union reg            // single long register
  40. {    uLong l;
  41.     uShort s;
  42. };
  43.  
  44.  
  45. struct dpmiRegs_t        // DPMI register passing structure
  46. {
  47.     union reg drEDI;
  48.     union reg drESI;
  49.     union reg drEBP;
  50.     union reg drRESV;
  51.     union reg drEBX;
  52.     union reg drEDX;
  53.     union reg drECX;
  54.     union reg drEAX;
  55.     uShort drFlags;
  56.     uShort drES;
  57.     uShort drDS;
  58.     uShort drFS;
  59.     uShort drGS;
  60.     uShort drIP;
  61.     uShort drCS;
  62.     uShort drSP;        // NOTE: When SS:SP is input as 0:0,
  63.     uShort drSS;        // the DPMI host attempts to provide a 
  64. };                // small stack for the call.
  65.  
  66.  
  67. // structure to receive data from DPMI memory query call
  68.  
  69. struct freeMem_t
  70. {
  71.     uLong largestFree;
  72.     uLong maxUnlocked;
  73.     uLong maxLocked;
  74.     uLong linearSize;
  75.     uLong nUnlockedPages;
  76.     uLong nFreePages;
  77.     uLong nPhysicalPages;
  78.     uLong freeLinearSpace;
  79.     uLong pageFileSize;
  80.     uLong reserved[3];
  81. };
  82.  
  83.  
  84. // structure to define stack frame for processor exception handlers
  85.  
  86. struct excFrame
  87. {
  88.     uShort excError;    // Error code
  89.     uShort excIP;        // IP of fault address
  90.     uShort excCS;        // CS of fault address
  91.     uShort excFlags;    // flags at exception point
  92.     uShort excSP;        // SP at exception point
  93.     uShort excSS;        // SS at exception point
  94. };
  95.         
  96.  
  97. // structure to pass state of registers for raw mode switch
  98.  
  99. struct rawModeRegs_t
  100. {
  101.     uShort rawDS;
  102.     uShort rawES;
  103.     uShort rawSS;
  104.     uShort rawCS;
  105. };
  106.     
  107. // types required for DPMI debug watchpoint interface
  108.  
  109.  
  110. enum watchSize            // size of watchpoint
  111. {
  112.     wByte = 1,
  113.     wWord = 2,
  114.     wLong = 4
  115. };
  116.  
  117. enum watchType            // type of watchpoint
  118. {
  119.     wExecute = 0,
  120.     wWrite = 1,
  121.     wReadWrite =2
  122. };
  123.  
  124.  
  125. struct DPMImemory_t        // used for DPMImalloc, DPMIresize, DPMIfree
  126. {
  127.     uLong handle;
  128.     selector_t sel;
  129. };
  130.  
  131.  
  132.  
  133. #ifdef __cplusplus
  134. extern "C" {
  135. #endif
  136.  
  137. //////////////////////////////////////////////////////////////////////
  138. ///////////////// DPMI Library Function Prototypes ///////////////////
  139. //////////////////////////////////////////////////////////////////////
  140.  
  141.  
  142. // Note on return values:
  143. //
  144. //    Unless indicated otherwise, the functions in the DPMI library 
  145. //    return zero to indicate success, and non-zero to indicate failure.
  146. //    This is consistent with the DPMI 0.9 specification, which did not
  147. //    specify a detailed set of error return values.  The DPMI 1.0 
  148. //    specification, however, includes specific error return values 
  149. //    for each function.  Some version 0.9 hosts have adopted the 
  150. //    version 1.0 error returns, and they are as indicated below.  
  151. //    However, when running on a version 0.9 host, it is not safe to 
  152. //    assume that specific error return values will be available.
  153.  
  154. //======================================================================
  155. // Function: Release Time Slice
  156. //
  157. // Synopsis:
  158. //
  159.     void DPMIReleaseTimeSlice(void);
  160. //
  161. // Description:
  162. //
  163. //    DPMI clients call this function to indicate an idle state to the
  164. //    DPMI host.  This enables multitasking DPMI hosts to schedule other
  165. //    clients. Installing this call inside idle loops can result in 
  166. //    significant improvement of system throughput.
  167. //
  168. // DPMI reference: INT 2Fh AX=1680h
  169.  
  170.  
  171. //======================================================================
  172. // Function: Get CPU Mode
  173. //
  174. // Synopsis:
  175.  
  176.     int DPMIGetCPUMode(void);
  177. //
  178. // Description:
  179. //
  180. //    This function may be used by mode sensitive applications to determine
  181. //    the current processor operating mode. Clients must verify the 
  182. //    presence of a DPMI host prior to making this call. The function
  183. //    returns zero if executing in protected mode, and returns non-zero
  184. //    if running in real or virtual 86 mode.
  185. //    
  186. // DPMI reference: INT 2Fh AX=1686h
  187.  
  188.  
  189. //======================================================================
  190. // Function: Obtain Mode Switch Entry Point
  191. //
  192. // Synopsis:
  193.  
  194.     int DPMIObtainSwitchEntryPoint(
  195.         uShort *flags,            // 32-bitness flag
  196.         uChar *processor,        // processor type
  197.         uChar *majorVersion,        // major version #
  198.         uChar *minorVersion,        // minor version #
  199.         uShort *nPrivateDataParas,    // size of host data
  200.         void (far* *entryAddress)());    // switch entry point
  201.         
  202. // Description:
  203. //
  204. //    This call determines if a DPMI host is present, and if so, returns
  205. //    necessary information on how to invoke it.  The function returns
  206. //    zero if a DPMI host was found; otherwise it returns non-zero.
  207. //
  208. //    All arguments are pointers to locations to store return values.
  209. //    The flags argument is non-zero if the DPMI host supports 32-bit
  210. //    applications.  The processor argument is written as 2 (80286),
  211. //    3 (80386), 4 (80486), or 5 (future). The version arguments indicate
  212. //    the version numbers of the DPMI host (For DPMI 0.9, major version is
  213. //    zero, and minor version is 90).  The nPrivateDataParas argument
  214. //    receives the number of paragraphs of memory that the host requires
  215. //    for each client.  If this is non-zero, the client must provide
  216. //    this much memory prior to calling the mode switch entry point, and
  217. //    the memory must be paragraph aligned.
  218. //
  219. //    The value written at the entryAddress argument is the far address 
  220. //    to call to make the initial switch into protected mode. See also,
  221. //    DPMIEnterProtectedMode.
  222. //
  223. // DPMI reference: INT 2Fh AX=1687h
  224.  
  225. //======================================================================
  226. // Function: Enter Protected Mode
  227. //
  228. // Synopsis:
  229. //
  230.     int DPMIEnterProtectedMode(
  231.         void (far *switchEntryPoint)(),    // mode switch entry point
  232.         uShort bitness,            // 16 or 32
  233.         uShort nPrivateDataParas);    // number of paras required
  234.             
  235.  
  236. // Description:
  237. //
  238. //    This function is used to make the initial switch into protected
  239. //    mode.  The switchEntryPoint argument is the value returned in the
  240. //    entryAddress argument of ObtainSwitchEntryPoint.  The bitness argument
  241. //    is zero to indicate that the calling client is 16-bit, and is one to 
  242. //    indicate that the calling client is 32-bit.  The nPrivateDataParas 
  243. //    argument is obtained from the function DPMIObtainSwitchEntryPoint.
  244. //
  245. //    If the call returns zero, the client is then running in protected
  246. //    mode.  The segment registers CS, DS, and SS contain selectors that
  247. //    address the same linear memory as they did in real mode at the 
  248. //    time of the call.  The selector in ES addresses the programs PSP,
  249. //    and the corresponding descriptor has a limit of 0xFF.  If running
  250. //    on a 32-bit processor, FS and GS are zero.
  251. //
  252. // DPMI reference: calling the mode switch entry point
  253. //
  254. // Version 1.0 Error returns:
  255. //
  256. //    8011h    descriptor unavailable
  257. //    8021h    32-bit clients not supported
  258.  
  259. //======================================================================
  260. // Function: Allocate Descriptors 
  261. //
  262. // Synopsis:
  263.  
  264.     int DPMIAllocateDescriptors(
  265.         uShort howMany,        // how many descriptors to allocate
  266.         selector_t *baseSel);    // receives selector of first desc
  267.             
  268. // Description:
  269. //
  270. //    This function allocates one or more LDT descriptors. The howMany
  271. //    argument is the number of descriptors to allocate, and the 
  272. //    selector of the first allocated descriptor is written to the
  273. //    address pointed to by the baseSel argument.  When more than one
  274. //    descriptor  is allocated, they are consecutive, i.e., the 
  275. //    difference between them is obtained by calling DPMIGetSelectorDelta.
  276. //
  277. //    At the time of allocation, each descriptor is of type DATA with
  278. //    a base and limit of zero.  It is the client's responsibility to
  279. //    set up the descriptors with meaningful values.
  280.  
  281. // DPMI reference: INT 31h AX=0000h
  282. //
  283. // Version 1.0 Error returns:
  284. //
  285. //    8011h    descriptor unavailable.
  286.  
  287.  
  288. //======================================================================
  289. // Function: Free Descriptor
  290. //
  291. // Synopsis:
  292.  
  293.     int DPMIFreeDescriptor(
  294.         selector_t sel);    // Selector of descriptor to free
  295.  
  296. // Description:
  297. //
  298. //    This function returns the specified descriptor to the DPMI host.
  299. //    
  300. // DPMI reference: INT 31h AX=0001h
  301. //
  302. // Version 1.0 Error returns:
  303. //
  304. //    8022h    invalid selector
  305.  
  306. //======================================================================
  307. // Function: Create Descriptor to Address Real Segment
  308. //
  309. // Synopsis
  310.  
  311.     int DPMIParaToSelector(
  312.         uShort para,        // paragraph to map
  313.         selector_t *sel);    // selector to address paragraph
  314.     
  315. // Description:
  316. //
  317. //    This function creates a data descriptor whose base corresponds
  318. //    to the real mode paragraph specified by the para argument.  The
  319. //    function writes the selector of the created descriptor at the
  320. //    address pointed to by the sel argument.  The descriptor limit 
  321. //    is 64 KB.
  322. //
  323. //    The function is intended to be used only for commonly accessed
  324. //    regions of the low megabyte, for example, paragraphs 40h, A000h,
  325. //    and B800h. Descriptors allocated by this function should not be
  326. //    modified or freed.  Multiple calls to this function with the same
  327. //    input return the same selector.
  328. //
  329. // DPMI reference: INT 31h AX=0002h
  330. //
  331. // Version 1.0 Error returns: 
  332. //
  333. //    8011h    descriptor unavailable
  334.  
  335.  
  336. //======================================================================
  337. // Function: Get Selector Delta
  338. //
  339. // Synopsis:
  340.  
  341.     uShort DPMIGetSelectorDelta(void);
  342.     
  343. // Description:
  344. //
  345. //    The return value of this function is the difference between
  346. //    consecutive selectors.
  347. //
  348. // DPMI reference: INT 31h AX=0003h
  349.  
  350.  
  351. //======================================================================
  352. // Function: Get Segment Base
  353. //
  354. // Synopsis:
  355.  
  356.     int DPMIGetSegmentBase(
  357.         selector_t sel,        // selector of segment to get base of
  358.         uLong *base);        // location to receive base of segment
  359.  
  360. // Description:
  361. //
  362. //    This function retrieves the base of the segment specified by the
  363. //    sel argument.  The linear base of the segment is written at the
  364. //    address pointed to by the base argument.
  365. //
  366. // DPMI reference: INT 31h AX=0006h
  367. //
  368. // Version 1.0 Error returns:
  369. //
  370. //    8022h    invalid selector
  371.  
  372. //======================================================================
  373. // Function: Set Segment Base
  374. //
  375. // Synopsis:
  376.  
  377.     int DPMISetSegmentBase(
  378.         selector_t sel,        // selector of segment to set base of
  379.         uLong base);        // new value for base
  380.  
  381. // Description:
  382. //
  383. //    This function sets the base of the segment specified by the sel
  384. //    argument to the value of the base argument.
  385. //
  386. // DPMI reference: INT 31h AX=0007h
  387. //
  388. // Version 1.0 Error returns:
  389. //
  390. //    8022h    invalid selector
  391. //    8025h    invalid linear address
  392.  
  393. //======================================================================
  394. // Function: Get Segment Limit
  395. //
  396. // Synopsis:
  397.  
  398.     int DPMIGetSegmentLimit(
  399.         selector_t sel,        // selector of segment to get limit of
  400.         uLong *limit);        // location to receive limit
  401.  
  402. // Description:
  403. //
  404. //    This function retrieves retrieves the limit of the segment 
  405. //    specified by the sel argument, and writes it at the address
  406. //    pointed to by the limit argument.  The function is implemented
  407. //    not by a DPMI call, but with the LSL instruction.
  408. //
  409. //
  410. // DPMI reference: Not a true DPMI function, but included for completeness.
  411. //
  412.  
  413. //======================================================================
  414. // Function: Set Segment Limit
  415. //
  416. // Synopsis:
  417.  
  418.     int DPMISetSegmentLimit(
  419.         selector_t sel,        // selector of segment to set limit of
  420.         uLong limit);        // desired segment limit
  421.  
  422.  
  423. // Description:
  424. //
  425. //    This function sets the limit of the segment specified by the
  426. //    sel argument to the value given by the limit argument.
  427. //
  428. // DPMI reference: INT 31h AX=0008h
  429. //
  430. // Version 1.0 Error returns:
  431. //
  432. //    8021h    invalid value
  433. //    8022h    invalid selecotr
  434. //    8023h    invalid linear address
  435.  
  436. //======================================================================
  437. // Function: Get Segment Attributes
  438. //
  439. // Synopsis:
  440.  
  441.     int DPMIGetSegmentAttributes(
  442.         selector_t sel,        // selector of segment to get attribs
  443.         uChar *arb,        // receives access rights/type byte
  444.         uChar *arb386);        // receives extended access byte(386+)
  445.  
  446.  
  447. // Description:
  448. //
  449. //    This function gets the attributes of the segment specified by the
  450. //    sel argument. The location pointed to by the arb argument receives
  451. //    the 6th byte of the descriptor, and the location pointed to by
  452. //    the arb386 argument returns the 8th byte of the descriptor.  This
  453. //    function is implemented with the LAR instruction.
  454. //
  455. // DPMI reference: Not a true DPMI function, but included for completeness.
  456. //
  457.  
  458. //======================================================================
  459. // Function: Set Segment Attributes
  460. //
  461. // Synopsis:
  462.  
  463.     int DPMISetSegmentAttributes(
  464.         selector_t sel,        // selector of segment to set attribs
  465.         uChar arb,        // access rights/type byte
  466.         uChar arb386);        // extended access byte (386+)
  467.  
  468.  
  469. // Description:
  470. //
  471. //    This function sets the attributes of the segment specified by
  472. //    the sel argument.  The arb argument is the 6th byte of the 
  473. //    descriptor, and the arb386 argument is the 8th byte of the 
  474. //    descriptor.  Attempts to set privilege levels more privileged
  475. //    than the client level will fail.
  476. //
  477. // DPMI reference: INT 31h AX=0009h
  478. //
  479. // Version 1.0 Error returns:
  480. //
  481. //    8021h    invalid value
  482. //    8022h    invalid selector
  483. //    8025h    invalid linear address
  484.  
  485. //======================================================================
  486. // Function: Create Alias Descriptor
  487. //
  488. // Synopsis:
  489.  
  490.     int DPMICreateAlias(
  491.         selector_t sel,        // selector to create alias for
  492.         selector_t *alias);    // receives selector of alias segment
  493.  
  494.  
  495. // Description:
  496. //
  497. //    This function creates a descriptor with the same base and limit
  498. //    as the descriptor specified by the sel argument.  It writes the
  499. //    selector of the alias descriptor at the address pointed to by
  500. //    the alias argument.  The descriptor that this function creates is
  501. //    of type data.  The DPMI host does not maintain an association
  502. //    between the aliased descriptors.
  503. //
  504. // DPMI reference: INT 31h AX=000Ah
  505. //
  506. // Version 1.0 Error returns:
  507. //
  508. //    8011h    descriptor unavailable
  509. //    8022h    invalid selector
  510.  
  511. //======================================================================
  512. // Function: Get Raw LDT Descriptor
  513. //
  514. // Synopsis:
  515.  
  516.     int DPMIGetDescriptor(
  517.         selector_t sel,                // descriptor to get
  518.         struct descriptor_t *descriptor);    // struct to receive
  519.  
  520.  
  521. // Description:
  522. //    This function copies the contents of the LDT descriptor specified
  523. //    by the sel argument to the structure pointed to by the descriptor
  524. //    argument.
  525. //
  526. // DPMI reference: INT 31h AX=000Bh
  527. //
  528. // Version 1.0 Error returns:
  529. //
  530. //    8022h    invalid selector
  531.  
  532. //======================================================================
  533. // Function: Set Raw LDT Descriptor
  534. //
  535. // Synopsis:
  536.  
  537.     int DPMISetDescriptor(
  538.         selector_t sel,                // descriptor to set
  539.         struct descriptor_t *descriptor);    // descriptor contents
  540.  
  541.  
  542. // Description:
  543. //
  544. //    This function copies the contents of the structure pointed to
  545. //    by the descriptor argument to the LDT entry specified by the
  546. //    sel argument.  If the present bit is set, the 
  547. //
  548. // DPMI reference: INT 31h AX=000Ch
  549. //
  550. // Version 1.0 Error returns:
  551. //
  552. //    8021h    invalid value
  553. //    8022h    invalid selector
  554. //    8025h    invalid linear address
  555.  
  556. //======================================================================
  557. // Function: Allocate Specific LDT Descriptor
  558. //
  559. // Synopsis:
  560.  
  561.     int DPMIAllocateSpecificDescriptor(
  562.         selector_t sel);    // selector of descriptor to allocate
  563.  
  564.  
  565. // Description:
  566. //    This function allocates a specific LDT descriptor in the range
  567. //    04h to 7Ch. It is intended for use only with DOS extended applications
  568. //    that require compatibility with pre-DPMI environments.
  569. //
  570. // DPMI reference: INT 31h AX=000Dh
  571. //
  572. // Version 1.0 Error returns:
  573. //
  574. //    8011h    descriptor unavailable
  575. //    8022h    invalid selector
  576.  
  577. //======================================================================
  578. // Function: Allocate DOS Memory Block
  579. //
  580. // Synopsis:
  581.  
  582.     int DPMIAllocateDOSMemory(
  583.         uShort nParas,        // number of paragraphs to allocate
  584.         uShort *para,        // receives para of alloc'ed block
  585.         selector_t *sel,    // receives selector of alloc'ed block
  586.         uShort *maxParas);    // receives max avail in fail case
  587.  
  588.  
  589. // Description:
  590. //
  591. //    This function allocates a block of memory from DOS.  The block so
  592. //    allocated is guaranteed to reside below 1 MB, and thus be addressable
  593. //    by real mode code.  The desired size of the block is specified by 
  594. //    the nParas argument, which should be set to the number of paragraphs
  595. //    (16 bytes each) for the block.  The DPMI host provides both a 
  596. //    paragraph address (which is written at the address pointed to by the
  597. //    para argument),and a selector (which is written at the address 
  598. //    pointed to by the sel argument.
  599. //
  600. //    If the requested size of the block is greater than 64 KB (4096 paras),
  601. //    the DPMI host creates a set of descriptors sufficient to span the
  602. //    allocated region, with consecutive selectors and bases that differ
  603. //    by 64 KB.
  604. //
  605. //    In the case where there is insufficient memory to satisfy the request,
  606. //    the DPMI host writes the maximum number of paragraphs available to
  607. //    the address pointed to by the maxParas argument.
  608. //
  609. //
  610. // DPMI reference: INT 31h AX=0100h
  611. //
  612. // Error returns (valid for version 0.9)
  613. //
  614. //    0007h    memory control blocks damaged
  615. //    0008h    insufficient memory
  616.  
  617.  
  618. //======================================================================
  619. // Function: Free DOS Memory Block
  620. //
  621. // Synopsis:
  622.  
  623.     int DPMIFreeDOSMemory(
  624.         selector_t sel);    // selector of block to free
  625.  
  626. // Description:
  627. //
  628. //    This function frees a DOS memory block allocated by the function
  629. //    DPMIAllocateDOSMemory.  The argument is the selector of the 
  630. //    block to be freed. If the DOS block is larger than 64 KB, all of
  631. //    the descriptors that were allocated for the block are freed.d
  632. //
  633. // DPMI reference: INT 31h AX=0101h
  634. //
  635. // Error returns (valid for version 0.9):
  636. //
  637. //    0007h    memory control blocks damaged
  638. //    0009h    incorrect memory segment specified
  639.  
  640. //======================================================================
  641. // Function: Resize DOS Memory Block
  642. //
  643. // Synopsis:
  644.  
  645.     int DPMIResizeDOSMemory(
  646.         selector_t sel,        // selector of block to resize
  647.         uShort nParas,        // desired size of block in paras
  648.         uShort *maxParas);    // receives max paras available
  649.  
  650.  
  651. // Description:
  652. //
  653. //    This function changes the size of a block that was allocated with
  654. //    the function DPMIAllocateDOSMemory.  The nParas argument specifies
  655. //    the desired new size of the block, in paragraphs.  The sel argument
  656. //    is the selector of the block to be resized.
  657. //
  658. //    In the case where there is insufficient memory to satisfy the request,
  659. //    the DPMI host writes the maximum number of paragraphs available to
  660. //    the address pointed to by the maxParas argument.
  661. //
  662. // DPMI reference: INT 31h AX=102h
  663. //
  664. // Error returns (valid for version 0.9):
  665. //
  666. //    0007h    memory control blocks damaged
  667. //    0008h    insufficient memory
  668. //    0009h    incorrect memory segment
  669.  
  670. //======================================================================
  671. // Function: Get Real Mode Interrupt Vector
  672. //
  673. // Synopsis:
  674.  
  675.     void DPMIGetRealInterruptVector(
  676.         uChar vector,            // vector number to get
  677.         void (far* *realIsr)());    // receives real vector
  678.  
  679.  
  680. // Description:
  681. //
  682. //    This function retrieves the real mode paragraph:offset address of
  683. //    the real mode interrupt handler specified by the vector argument.
  684. //    The handler address is written to the address pointed to by the
  685. //    realIsr argument.
  686. //
  687. //
  688. // DPMI reference: INT 31h AX=0200h
  689. //
  690.  
  691. //======================================================================
  692. // Function: Set Real Mode Interrupt Vector
  693. //
  694. // Synopsis:
  695.  
  696.     void DPMISetRealInterruptVector(
  697.         uChar vector,            // vector number to set
  698.         void (far *realIsr)());        // new real vector
  699.  
  700.  
  701. // Description:
  702. //
  703. //    This function sets the real mode interrupt vector specified by the
  704. //    vector argument to the value in the realIsr argument.  The handler
  705. //    address in realIsr must be a real mode paragraph:offset address.
  706. //
  707. //    Note: Do not declare the handler as _interrupt. Doing so forces the
  708. //    DS register to be loaded upon entry to the handler, but the result
  709. //    will be the protected mode selector, not the real mode paragraph.
  710. //    Thus, references to the default data segment from the real mode
  711. //    handler will fail unless other measures are taken to load DS
  712. //    correctly.
  713. //
  714. // DPMI reference: INT 31h AX=0201h
  715. //
  716.  
  717. //======================================================================
  718. // Function: Get Processor Exception Vector
  719. //
  720. // Synopsis:
  721.  
  722.     int DPMIGetExceptionVector(
  723.         uChar exception,        // exception number to get
  724.         void (far* *excHandler)());    // receives handler address
  725.  
  726.  
  727. // Description:
  728. //
  729. //    This function retrieves the address of the exception handler
  730. //    specified by the exception argument (range 0-1Fh).  The handler
  731. //    address is written to the address pointed to by the 
  732. //    excHandler argument.
  733. //    
  734. // DPMI reference: INT 31h AX=0202h
  735. //
  736. // Version 1.0 Error returns:
  737. //
  738. //    8021h    invalid value
  739.  
  740. //======================================================================
  741. // Function: Set Processor Exception Vector
  742. //
  743. // Synopsis:
  744.  
  745.     int DPMISetExceptionVector(
  746.         uChar exception,        // exception number to set
  747.         void (far *excHandler)());    // new handler address
  748.  
  749.  
  750. // Description:
  751. //
  752. //    This function sets the exception vector specified by the
  753. //    exception argument to the value in the excHandler argument.  
  754. //
  755. //    The exception handler is defined as follows:
  756. //
  757. //        void _saveregs _far excHandler(struct excFrame);
  758. //
  759. //    The exception handler may modify the fields of the excFrame structure.
  760. //    When the handler returns, the DPMI host uses the new values from
  761. //    the structure to restart the faulting client.
  762.  
  763.  
  764. // DPMI reference: INT 31h AX=0203h
  765. //
  766. // Version 1.0 Error returns:
  767. //
  768. //    8021h    invalid value
  769. //    8022h    invalid selector
  770.  
  771. //======================================================================
  772. // Function: Get Protected Mode Interrupt Vector
  773. //
  774. // Synopsis:
  775.  
  776.     void DPMIGetProtInterruptVector(
  777.         uChar vector,            // interrupt vector to get
  778.         void (_interrupt **protIsr)());    // receives interrupt vector
  779.  
  780.  
  781. // Description:
  782. //
  783. //    This function retrieves the protected mode interrupt vector
  784. //    specified by the vector argument.  The selector:offset address of
  785. //    the current interrupt handler is written to the address pointed to
  786. //    by the protIsr argument.
  787. //
  788. // DPMI reference: INT 31h AX=0204h
  789. //
  790.  
  791. //======================================================================
  792. // Function: Set Protected Mode Interrupt Vector
  793. //
  794. // Synopsis:
  795.  
  796.     int DPMISetProtInterruptVector(
  797.         uChar vector,            // interrupt vector to set
  798.         void (_interrupt *protIsr)());    // new handler address
  799.  
  800.  
  801. // Description:
  802. //
  803. //    This function sets the address of the protected mode interrupt
  804. //    handler for the vector specified by the vector arugment.  The
  805. //    protIsr argument is the selector:offset of the desired new
  806. //    handler.
  807. //
  808. //    Note that for hardware interrupts, the handler is invoked on the
  809. //    DPMI host's stack, and DS != SS.  This makes usage of near pointers
  810. //    unreliable and is not recommended.
  811. //
  812. // DPMI reference: INT 31h AX=0205h
  813. //
  814. // Version 1.0 Error returns:
  815. //
  816. //    8022h    invalid selector
  817.  
  818. //======================================================================
  819. // Function: Issue Real Mode Interrupt
  820. //
  821. // Synopsis:
  822.  
  823.     int DPMIIssueRealInterrupt(
  824.         uChar vector,            // interrupt to issue
  825.         uShort nArgBytes,        // number of bytes of args
  826.         struct dpmiRegs_t *regs);    // real mode register state
  827.  
  828.  
  829. // Description:
  830. //
  831. //    This function switches to real mode and issues the interrupt 
  832. //    specified by the vector argument.  Prior to issuing the interrupt,
  833. //    the DPMI host loads the processor registers with the contents of
  834. //    the structure pointed to by the regs argument.  When the interrupt
  835. //    handler returns, the DPMI host updates the register structure to
  836. //    reflect changes caused by the interrupt handler.
  837. //
  838. //    The CS:IP field of the real call structure is ignored, because the
  839. //    execution address is determined by the real mode interrupt vector.
  840. //
  841. // DPMI reference: INT 31h AX=0300h
  842. //
  843. // Version 1.0 Error returns:
  844. //
  845. //    8012h    linear memory unavailable
  846. //    8013h    physical memory unavailable
  847. //    8014h    backing store unavailable
  848. //    8021h    invalid value
  849.  
  850. //======================================================================
  851. // Function: Call Real Mode Procedure with Far Return
  852. //
  853. // Synopsis:
  854.  
  855.     int DPMICallRealProcedure(
  856.         uShort nArgBytes,        // number of bytes of args
  857.         struct dpmiRegs_t *regs,    // real mode register state
  858.         ...);                // function arguments
  859.  
  860. // Description:
  861. //
  862. //    This function causes the DPMI host to switch to real mode, push
  863. //    zero or more argument bytes on the stack, and call the far function
  864. //    indicated by the CS:IP fields of the real call structure pointed
  865. //    to by the regs argument.  The number of argument bytes to push is
  866. //    given by the nArgBytes argument, and the function arguments should
  867. //    follow the pointer to the real call structure in the arugment list.
  868. //    The real function must return on the same stack on which it was
  869. //    called.
  870. //
  871. //    The DPMI host reloads the register structure with the register 
  872. //    current register state when the far function returns.  
  873. //
  874. // DPMI reference: INT 31h AX=0301h
  875. //
  876. // Version 1.0 Error returns:
  877. //
  878. //    8012h    linear memory unavailable
  879. //    8013h    physical memory unavailable
  880. //    8014h    backing store unavailable
  881. //    8021h    invalid value
  882.  
  883. //======================================================================
  884. // Function: Call Real Mode Procedure with IRET
  885. //
  886. // Synopsis:
  887.  
  888.     int DPMICallRealInterruptProcedure(
  889.         uShort nArgBytes,        // number of bytes of args
  890.         struct dpmiRegs_t *regs,    // real mode register state
  891.         ...);                // function arguments.
  892.     
  893.  
  894. // Description:
  895. //
  896. //    This function is identical to DPMICallRealProcedure, except that
  897. //    it is used to call a real function that returns with an IRET
  898. //    instead of a RETF.
  899. //
  900. // DPMI reference: INT 31h AX=0302h
  901. //
  902. // Version 1.0 Error returns:
  903. //
  904. //    8012h    linear memory unavailable
  905. //    8013h    physical memory unavailable
  906. //    8014h    backing store unavailable
  907. //    8021h    invalid value
  908.  
  909. //======================================================================
  910. // Function: Allocate Real Mode Callback
  911. //
  912. // Synopsis:
  913.  
  914.     int DPMIAllocateRealCallBack(
  915.         struct dpmiRegs_t *regs,    // address of static reg state
  916.         void (far *handler)(),        // prot mode callback handler
  917.         void (far* *cbAddr)());        // receives real callback addr
  918.  
  919. // Description:
  920. //
  921. //    This function allocates a real mode callback from the DPMI host.
  922. //    A real mode callback is a real mode address (paragraph:offset) that
  923. //    a real mode caller uses to invoke a protected mode callback
  924. //    handler.  This provides a mechanism for calling protected mode
  925. //    from real mode.  
  926. //
  927. //    The cbAddr argument points to the location to receive the real mode
  928. //    callback address.  When called, the DPMI host passes control to
  929. //    the protected mode address specified by the handler argument. 
  930. //
  931. //    The protected mode handler  is passed (in ES:DI) a pointer to the 
  932. //    real mode call structure whose address is passed  to this function
  933. //    in the regs argument.  Therefore, this structure should be statically
  934. //    allocated.  The DPMI host is responsible for loading the structure
  935. //    with the register state at the time of the callback prior to passing
  936. //    it to the protected mode callback handler. The handler is also 
  937. //    passed (in DS:SI) the protected mode address of the real mode stack.
  938. //
  939. //    The DPMI host uses the register state in the call structure
  940. //    to restart the real mode caller.  It is the responsibility of the
  941. //    protected mode handler to locate the real mode return address on
  942. //    the real mode stack, and store it in the CS:IP fields of the call
  943. //    structure in order to effect a return from the callback.
  944. //
  945. // DPMI reference: INT 31h AX=0303h
  946. //
  947. // Version 1.0 Error returns:
  948. //
  949. //    8015h    callback unavailable
  950.  
  951. //======================================================================
  952. // Function: Free Real Mode Callback
  953. //
  954. // Synopsis:
  955.  
  956.     int DPMIFreeRealCallBack(
  957.         void (far *cbAddr)());        // callback to free
  958.  
  959.  
  960. // Description:
  961. //
  962. //    This function frees a real mode callback allocated by 
  963. //    DPMIAllocateRealCallBack.  The cbAddr is the callback
  964. //    address to be freed.
  965. //
  966. // DPMI reference: INT 31h AX=0303h
  967. //
  968. // Version 1.0 Error returns:
  969. //
  970. //    8024h    invalid callback address
  971.  
  972. //======================================================================
  973. // Function: Get State Save/Restore Procedure Addresses
  974. //
  975. // Synopsis:
  976.  
  977.     void DPMIGetStateSaveRestoreProcs(
  978.         uShort *stateSize,        // size of state info
  979.         void (far* *realProc)(),    // receives real save/rst proc
  980.         void (far* *protProc)());    // receives prot save/rst proc
  981.  
  982. // Description:
  983. //
  984. //    This function retrieves information from the DPMI host that
  985. //    is required for saving and restoring the client state when
  986. //    using the raw mode switch function.
  987. //
  988. //    The DPMI specification requires that clients save their state
  989. //    prior to making a raw mode switch, and subsequently restore it.
  990. //    This function provides the size of the state information, and
  991. //    the both the protected mode and real mode addresses of functions
  992. //    to call to save and restore the client state.
  993. //
  994. //    The size of the state information, in bytes, is stored at the
  995. //    address pointed to by the stateSize argument.  The address of the
  996. //    far procedure to call from real mode to save or restore the client
  997. //    state is stored at the address pointed to by the realProc argument.
  998. //    The address of the far procedure to call from protected mode to
  999. //    save and restore the client state is stored at the address pointed
  1000. //    to by the protProc argument.
  1001. //
  1002. //    The state save/restore procedures are called with AL=0 to save the
  1003. //    state, and AL=1 to restore the state.  In both cases, ES:DI points
  1004. //    to the state information buffer.
  1005. //
  1006. //
  1007. // DPMI reference: INT 31h AX=0305h
  1008.  
  1009. //======================================================================
  1010. // Function: Save Or Restore Client State for Raw Switch
  1011. //
  1012. // Synopsis:
  1013.  
  1014.     void DPMISaveOrRestoreState(
  1015.         int saveRestore,        // 0=save 1=restore
  1016.         uChar *stateBuffer,        // pointer to state buffer
  1017.         void (far *procAddr)());    // procedure to call
  1018.             
  1019. // Description:            
  1020. //
  1021. //    This function invokes the save/restore procedure whose address
  1022. //    is specified by the procAddr argument.  The stateBuffer argument
  1023. //    points to the buffer to supply or receive the client state. Its
  1024. //    size is determined by calling DPMIGetStateSaveRestoreProcs. The
  1025. //    saveRestore argument is zero to perform state save, or one to
  1026. //    perform a state restore.
  1027.  
  1028.  
  1029. //======================================================================
  1030. // Function: Get Raw Switch Procedure Addresses
  1031. //
  1032. // Synopsis:
  1033.  
  1034.     void DPMIGetRawSwitchProc(
  1035.         void (far* *realToProt)(),    // real to prot switch addr
  1036.         void (far* *protToReal)());    // prot to real switch addr
  1037.             
  1038. // Description:
  1039. //
  1040. //    This function retrieves information from the DPMI host that
  1041. //    is required for raw mode switching.  The address (paragraph:offset)
  1042. //    of the real to protected mode service is stored at the address
  1043. //    pointed to by the realToProt argument.  The address (selector:offset)
  1044. //    of the protected to real mode service is stored at the address
  1045. //    pointed to by the protToReal argument.
  1046. //
  1047. // DPMI reference: INT 31h AX=0306h
  1048. //
  1049.  
  1050. //======================================================================
  1051. // Function: Do Raw Mode Switch
  1052. //
  1053. // Synopsis:
  1054.  
  1055.     void DPMIDoRawSwitch(
  1056.         void (far *switchAddr)(),    // switch service address
  1057.         struct rawModeRegs_t *rawRegs);    // new register values
  1058.  
  1059. // Description:
  1060. //
  1061. //    This function invokes the raw switch service.  The switchAddr
  1062. //    argument is obtained from DPMIGetRawSwitchProc, and specifies
  1063. //    the address of the switch service to invoke.  When the function
  1064. //    returns, the processor will be in the alternate mode.  
  1065. //
  1066. //    The rawRegs argument points to the structure containing the register 
  1067. //    contents to be put in effect after the mode switch is effected.
  1068. //    The values in the structure MUST be aliases for the currently active
  1069. //    segment registers.  In other words, when switching from protected
  1070. //    to real mode, each segment register value in the structure must
  1071. //    be the paragraph equivalent of the current protected mode descriptor
  1072. //    value.  Likewise, when switching from real to protected mode, each
  1073. //    segment register value in the structure must be the selector that
  1074. //    maps the current paragraph in each segment register. These
  1075. //    requirements imply that this routine must execute only in the low
  1076. //    1 MB of the address space, and that the stack must also be in the
  1077. //    low 1 MB.
  1078. //
  1079. // DPMI reference: invoking the raw mode switch services
  1080.  
  1081.  
  1082. //======================================================================
  1083. // Function: Get DPMI Host Version Information
  1084. //
  1085. // Synopsis:
  1086. //
  1087.     void DPMIGetVersion(
  1088.         uChar *major,        // receives major version number
  1089.         uChar *minor,        // receives minor version number
  1090.         uChar *processor,    // receives processor code
  1091.         uShort *flags,        // receives flags
  1092.         uChar *masterPIC,    // receives virtual master PIC base
  1093.         uChar *slavePIC);    // receives virtual slave PIC base
  1094.  
  1095. // Description:
  1096. //
  1097. //    This function retrieves version information from the DPMI host.
  1098. //    For version 0.9, the major version is zero and the minor version
  1099. //    is 90 (5Ah).  The processor codes are as follows:
  1100. //
  1101. //        2 => 80286, 3 => 80386, 4 => 80486 5-FFh => future
  1102. //
  1103. //    The bits of the flags word have the following meanings:
  1104. //
  1105. //        Bit    Meaning
  1106. //         0    0 = 16-bit host, 
  1107. //            1 = 32-bit host
  1108. //         1    0 = DOS runs in virtual 86 mode, 
  1109. //            1 = DOS runs in real
  1110. //         2    0 = no virtual memory support
  1111. //            1 = virtual memory supported
  1112. //    
  1113. // DPMI reference: INT 31h AX=0400h
  1114.  
  1115. //======================================================================
  1116. // Function: Get Free Memory Information
  1117. //
  1118. // Synopsis:
  1119.  
  1120.     void DPMIGetFreeMemory(
  1121.         struct freeMem_t *freeMem); // receives free mem info
  1122.  
  1123.  
  1124. // Description:
  1125. //
  1126. //    This function retrieves free memory information from the DPMI
  1127. //    host.  The freeMem argument is a pointer to the structure to
  1128. //    receive the free memory information. Only the first field
  1129. //    (largestFree) of the free memory structure is guaranteed to be
  1130. //    supported.  The other values are set to 0xffffffff if the 
  1131. //    item is unavailable.
  1132. //
  1133. // DPMI reference: INT 31h AX=0500h
  1134.  
  1135. //======================================================================
  1136. // Function: Allocate Memory Block
  1137. //
  1138. // Synopsis:
  1139.  
  1140.     int DPMIAllocateMemory(
  1141.         uLong nBytes,        // size of block to allocate
  1142.         uLong *base,        // receives linear base of block
  1143.         uLong *handle);        // receives block handle
  1144.  
  1145. // Description:
  1146. //
  1147. //    This function allocates a memory block.  The nBytes argument
  1148. //    specifies the desired size of the block to allocate, in bytes.
  1149. //    The linear base address of the block that is allocated is 
  1150. //    written to the address pointed to by the base argument.  The
  1151. //    block handle is written to the address pointed to by the handle
  1152. //    argument.  The handle is used to free or resize the block.
  1153. //
  1154. // DPMI reference: INT 31h AX=0501h
  1155. //
  1156. // Version 1.0 Error returns:
  1157. //
  1158. //    8012h    linear memory unavailable
  1159. //    8013h    physicl memory unavailable
  1160. //    8014h    backing store unavailable
  1161. //    8016h    handle unavailable
  1162. //    8021h    invalid value
  1163.  
  1164. //======================================================================
  1165. // Function: Free Memory Block
  1166. //
  1167. // Synopsis:
  1168.  
  1169.     int DPMIFreeMemory(
  1170.         uLong handle);        // handle of block to free
  1171.  
  1172.  
  1173. // Description:
  1174. //
  1175. //    This function frees a memory block allocated by DPMIAllocateMemory.
  1176. //
  1177. // DPMI reference: INT 31h AX=0502h
  1178. //
  1179. // Version 1.0 Error returns:
  1180. //
  1181. //    8023h    invalid handle
  1182.  
  1183. //======================================================================
  1184. // Function: Resize Memory Block
  1185. //
  1186. // Synopsis:
  1187.  
  1188.     int DPMIResizeMemory(
  1189.         uLong *handle,        //address of handle of block to resize
  1190.         uLong nBytes,        // new desired size in bytes
  1191.         uLong *base);        // receives new linear base of block
  1192.  
  1193. // Description:
  1194. //
  1195. //    This function resizes a memory block allocated by DPMIAllocateMemory.
  1196. //    The handle argument points to the handle of the block to resize.
  1197. //    The nBytes argument is the desired new size of the block, in bytes.
  1198. //    The base argument points to the address to receive the new address
  1199. //    of the block.  Note that both the block handle and the linear base
  1200. //    of the block may be changed by this call.
  1201. //
  1202. // DPMI reference: INT 31h AX=0503h
  1203. //
  1204. // Version 1.0 Error returns:
  1205. //
  1206. //    8012h    linear memory unavailable
  1207. //    8013h    physical memory unavailable
  1208. //    8014h    backing store unavailable
  1209. //    8016h    handle unavailable
  1210. //    8021h    invalid value
  1211.  
  1212. //======================================================================
  1213. // Function: Lock Linear Region of Memory
  1214. //
  1215. // Synopsis:
  1216.  
  1217.     int DPMILockRegion(
  1218.         uLong base,        // linear address of region to lock
  1219.         uLong nBytes);        // size of region to lock
  1220.  
  1221. // Description:
  1222. //
  1223. //    This function is used to prevent pages from being swapped to disk
  1224. //    by a DPMI host that supports virtual memory.  The base argument is
  1225. //    the linear address of the start of the region to be locked, and the
  1226. //    nBytes argument is the size of the region to lock.  The host maintains
  1227. //    a lock count for each page.  If the DPMI host does not support 
  1228. //    virtual memory, the function has no effect.
  1229. //
  1230. // DPMI reference: INT 31h AX=0600h
  1231. //
  1232. // Version 1.0 Error returns:
  1233. //
  1234. //    8013h    physical memory unavailable
  1235. //    8017h    lock count exceeded
  1236. //    8025h    invalid linear address
  1237.  
  1238. //======================================================================
  1239. // Function: Unlock Linear Region of Memory
  1240. //
  1241. // Synopsis:
  1242.  
  1243.     int DPMIUnlockRegion(
  1244.         uLong base,        // linear address of region to unlock
  1245.         uLong nBytes);        // size of region to unlock
  1246.  
  1247. // Description:
  1248. //
  1249. //    This function decrements the lock count for pages in the specified
  1250. //    region.  The base argument is the linear address of the start of the
  1251. //    region, and the nBytes argument is the size of the region in bytes.
  1252. //    Pages are not unlocked until the lock count is zero.
  1253. //
  1254. // DPMI reference: INT 31h AX=0601h
  1255. //
  1256. // Version 1.0 Error returns:
  1257. //
  1258. //    8002h    invalid state
  1259. //    8025h    invalid linear address
  1260.  
  1261. //======================================================================
  1262. // Function: Mark Real Mode Region as Pageable
  1263. //
  1264. // Synopsis:
  1265.  
  1266.     int DPMIMarkRealRegionPageable(
  1267.         uLong base,        // linear address of region to mark
  1268.         uLong nBytes);        // size in bytes of region to mark
  1269.  
  1270. // Description:
  1271. //
  1272. //    This function allows memory in the low megabyte of the linear
  1273. //    address space to be swapped to disk by a DPMI host that supports
  1274. //    virtual memory.  The base argument is the linear address of the
  1275. //    start of the region to be made pageable, and the nBytes argument
  1276. //    is the size of the region in bytes. 
  1277. //
  1278. // DPMI reference: INT 31h AX=0602h
  1279. //
  1280. // Version 1.0 Error returns:
  1281. //
  1282. //    8002h    invalid state
  1283. //    8025h    invalid linear address
  1284.  
  1285. //======================================================================
  1286. // Function: Relock Real Mode Region
  1287. //
  1288. // Synopsis:
  1289.  
  1290.     int DPMIRelockRealRegion(
  1291.         uLong base,        // linear address of region to relock
  1292.         uLong nBytes);        // size in bytes of region to relock
  1293.  
  1294. // Description:
  1295. //
  1296. //    This function relocks a memory region in the low 1 MB that was marked
  1297. //    as pageable by DPMIMarkRealRegionPageable.  The base argument is the
  1298. //    linear address of the start of the region to be relocked, and the
  1299. //    nBytes argument is the size of the region in bytes. 
  1300. //
  1301. // DPMI reference: INT 31h AX=0603h
  1302. //
  1303. // Version 1.0 Error returns:
  1304. //
  1305. //    8002h    invalid state
  1306. //    8013h    physical meomory unavailable
  1307. //    8025h    invalid linear address
  1308.  
  1309. //======================================================================
  1310. // Function: Get Size of Processor Page
  1311. //
  1312. // Synopsis:
  1313.  
  1314.     int DPMIGetPageSize(
  1315.         uLong *pageSize);
  1316.  
  1317.  
  1318. // Description:
  1319. //
  1320. //    This function is used to determine the processor's page size.
  1321. //    The pageSize argument points to the location to receive the
  1322. //    page size, in bytes.  16-bit hosts will fail this call.
  1323. //
  1324. // DPMI reference: INT 31h AX=0604h
  1325. //
  1326. // Version 1.0 Error returns:
  1327. //
  1328. //    8001h    unsupported function
  1329.  
  1330. //======================================================================
  1331. // Function: Nominate Pages as Demand Paging Candidates
  1332. //
  1333. // Synopsis:
  1334.  
  1335.     int DPMINominatePages(
  1336.         uLong base,        // base of region to nominate
  1337.         uLong nBytes);        // size in bytes of region
  1338.  
  1339. // Description:
  1340. //
  1341. //    This function is used to indicate to the DPMI host that a range
  1342. //    of memory should be the most likely to be swapped to disk.  The
  1343. //    base argument is the linear address of the start of the region
  1344. //    to be nominated, and the nBytes argument is the size of the region,
  1345. //    in bytes.  The call is advisory only.
  1346. //
  1347. // DPMI reference: INT 31h AX=0702h
  1348. //
  1349. // Version 1.0 Error returns:
  1350. //
  1351. //    8025h    invalid linear address range
  1352.  
  1353. //======================================================================
  1354. // Function: Discard Contents of Pages
  1355. //
  1356. // Synopsis:
  1357.  
  1358.     int DPMIDiscardPageContents(
  1359.         uLong base,        // base of region to discard
  1360.         uLong nBytes);        // size of region in bytes
  1361.  
  1362. // Description:
  1363. //
  1364. //    This function advises the DPMI host to discard the contents of
  1365. //    the specified region to avoid unnecessarily saving them on disk.  The
  1366. //    base argument is the linear address of the start of the region
  1367. //    to be discarded, and the nBytes argument is the size of the region,
  1368. //    in bytes.  The call is advisory only.
  1369. //
  1370. // DPMI reference: INT 31h AX=0703h
  1371. //
  1372. // Version 1.0 Error returns:
  1373. //
  1374. //    8025h    invalid linear address
  1375.  
  1376. //======================================================================
  1377. // Function: Get Linear Address for Physical Region 
  1378. //
  1379. // Synopsis:
  1380.  
  1381.     int DPMIMapPhysicalRegion(
  1382.         uLong physAddr,        // physical address to map
  1383.         uLong nBytes,        // size of region to map
  1384.         uLong *linear);        // receives linear address of region
  1385.  
  1386. // Description:
  1387. //
  1388. //    This function allows a DPMI client to obtain a linear address that
  1389. //    maps to any physical address above 1 MB.  The physAddr argument
  1390. //    specifies the physical address of the region to map. The nBytes
  1391. //    argument is the size of the region to map, in bytes. The linear
  1392. //    argument points to the address to receive the linear address that
  1393. //    the DPMI sets up to map the physical region.
  1394. //
  1395. // DPMI reference: INT 31h AX=0800h
  1396. //
  1397. // Version 1.0 Error returns:
  1398. //
  1399. //    8003h    system integrity
  1400. //    8021h    invalid value
  1401.  
  1402. //======================================================================
  1403. // Function: Test Virtual Interrupt State and Disable
  1404. //
  1405. // Synopsis:
  1406.  
  1407.     int DPMITestDisableInts(void);
  1408.  
  1409.  
  1410. // Description:
  1411. //
  1412. //    This function returns the current virtual interrupt enable state,
  1413. //    and disables virtual interrupts.  The return value is zero if 
  1414. //    interrupts were previously disabled, and one if they were enabled.
  1415. //
  1416. // DPMI reference: INT 31h AX=0900h
  1417.  
  1418. //======================================================================
  1419. // Function: Test Virtual Interrupt State and Enable
  1420. //
  1421. // Synopsis:
  1422.  
  1423.     int DPMITestEnableInts(void);
  1424.  
  1425. // Description:
  1426. //
  1427. //    This function returns the current virtual interrupt enable state,
  1428. //    and enables virtual interrupts.  The return value is zero if 
  1429. //    interrupts were previously disabled, and one if they were enabled.
  1430. //
  1431. // DPMI reference: INT 31h AX=0901h
  1432.  
  1433.  
  1434. //======================================================================
  1435. // Function: Test Virtual Interrupt State 
  1436. //
  1437. // Synopsis:
  1438.  
  1439.     int DPMITestInts(void);
  1440.  
  1441. // Description:
  1442. //
  1443. //    This function returns the current virtual interrupt enable state.
  1444. //    The return value is zero if interrupts are disabled, and one if 
  1445. //    they are enabled.
  1446. //
  1447. //
  1448. // DPMI reference: INT 31h AX=0902h
  1449.  
  1450. //======================================================================
  1451. // Function: Get Vendor Extensions Entry Point
  1452. //
  1453. // Synopsis:
  1454.  
  1455.     int DPMIGetVendorEntryPoint(
  1456.         char *extensionID,
  1457.         void (far* *extAPIEntry)());
  1458.  
  1459. // Description:
  1460. //    
  1461. //    This function retrieves an address that can be used to access
  1462. //    vendor specific DPMI extensions.  The extensionID argument points
  1463. //    to a null terminated string that identifies the desired set of
  1464. //    extensions.  The extAPIEntry argument points to the address where
  1465. //    a far pointer to the vendor entry point is to be stored.  The function
  1466. //    returns non-zero if the requested vendor extensions are not found.
  1467. //
  1468. // DPMI reference: INT 31h AX=0A00h and INT 2Fh AX=168Ah
  1469. //
  1470. // Version 1.0 Error returns:
  1471. //
  1472. //    8001h    unsupported function
  1473.  
  1474. //======================================================================
  1475. // Function: Set Debug Watchpoint
  1476. //
  1477. // Synopsis:
  1478.  
  1479.     int DPMISetWatchpoint(
  1480.         uLong linear,        // linear address of watchpoint
  1481.         enum watchSize size,    // watchpoint size
  1482.         enum watchType type,    // watchpoint type
  1483.         uShort *watchHandle);    // receives watchpoint handle
  1484.  
  1485. // Description:
  1486. //
  1487. //    This function sets a debug watchpoint using the processor's debug
  1488. //    registers.  The linear argument specifies the linear address of the
  1489. //    watchpoint.  Arguments watchSize and watchType specify the size
  1490. //    and type of the watchpoint.  The watchHandle argument points to the
  1491. //    location to receive the watchpoint handle allocated by the DPMI
  1492. //    host.  Tripping a watchpoint invokes the exception 1 handler.
  1493. //
  1494. // DPMI reference: INT 31h AX=0B00h
  1495. //
  1496. // Version 1.0 Error returns:
  1497. //
  1498. //    8016h    too many breakpoints
  1499. //    8021h    invalid value
  1500. //    8025h    invalid linear address
  1501.  
  1502. //======================================================================
  1503. // Function: Clear Debug Watchpoint
  1504. //
  1505. // Synopsis:
  1506.  
  1507.     int DPMIClearWatchpoint(
  1508.         uShort watchHandle);    // handle of watchpoint to free
  1509.  
  1510. // Description:
  1511. //
  1512. //    This function releases the watchpoint handle allocated by
  1513. //    DPMISetWatchpoint, and clears the associated debug register.
  1514. //    The watchHandle argument is the handle of the watchpoint to free.
  1515. //
  1516. // DPMI reference: INT 31h AX=0B01h
  1517. //
  1518. // Version 1.0 Error returns:
  1519. //
  1520. //    8023h    invalid handle
  1521.  
  1522. //======================================================================
  1523. // Function: Get Debug Watchpoint State
  1524. //
  1525. // Synopsis:
  1526.  
  1527.     int DPMIGetWatchpointState(
  1528.         uShort watchHandle,    //handle of watchpoint to get state of
  1529.         uChar *tripped);    // receives state
  1530.  
  1531. // Description:
  1532. //
  1533. //    This function retrieves the state of a watchpoint set by 
  1534. //    DPMISetWatchpoint.  The watchHandle argument is the handle of
  1535. //    watchpoint whose state is to be retrieved.  The tripped argument
  1536. //    receives a zero if the watchpoint has not been encountered,
  1537. //    and receives a one if the watchpoint has been encountered.
  1538. //
  1539. // DPMI reference: INT 31h AX=0B02h
  1540. //
  1541. // Version 1.0 Error returns:
  1542. //
  1543. //    8023h    invalid handle
  1544.  
  1545. //======================================================================
  1546. // Function: Reset Debug Watchpoint
  1547. //
  1548. // Synopsis:
  1549.  
  1550.     int DPMIResetWatchpoint(
  1551.         uShort watchHandle);    // handle of watchpoint to reset
  1552.  
  1553. // Description:
  1554. //
  1555. //    This function resets the state of a watchpoint allocated by
  1556. //    DPMISetWatchpoint.  This sets the watchpoint state to 
  1557. //    "not encountered".  The watchHandle argument specifies the watchpoint
  1558. //    in question.
  1559. //
  1560. // DPMI reference: INT 31h AX=0B03h
  1561. //
  1562. // Version 1.0 Error returns:
  1563. //
  1564. //    8023h    invalid handle
  1565.  
  1566.  
  1567.  
  1568.  
  1569. //======================================================================
  1570. // Function: Allocate memory and selector
  1571. //
  1572. // Synopsis:
  1573.  
  1574.     void far *DPMImalloc(uShort size, struct DPMImemory_t *mem);
  1575.  
  1576. // Description:
  1577. //
  1578. //    This is a higher level call that allocates a block of memory
  1579. //    whose size is given by the size argument (size == 0 is taken
  1580. //    to mean 64 KB), and allocates a descriptor to map it.  The 
  1581. //    caller provides a pointer to a DPMImemory_t struct that records
  1582. //    the memory handle and selector.  The function returns a far
  1583. //    pointer to offset zero of the allocated block.
  1584.  
  1585.  
  1586. //======================================================================
  1587. // Function: Free memory and selector
  1588. //
  1589. // Synopsis:
  1590.  
  1591.     void DPMIfree(struct DPMImemory_t *mem);
  1592.  
  1593. // Description:
  1594. //
  1595. //    This function frees the memory block and selector allocated 
  1596. //    by DPMImalloc.
  1597.  
  1598. //======================================================================
  1599. // Function: Resize memory and selector
  1600. //
  1601. // Synopsis:
  1602.  
  1603.     boolean DPMIresize(uShort newSize, struct DPMImemory_t *mem);
  1604.  
  1605. // Description:
  1606. //
  1607. //    This function attempts to resize the memory block whose handle
  1608. //    is found in the structure pointed to by the mem argument to
  1609. //    the size indicated by the newSize argument. (As with DPMImalloc,
  1610. //    newSize==0 is taken to mean 64 KB.) If successful, the limit
  1611. //    of the corresponding descriptor is set accordingly.
  1612. //
  1613. //    The function returns TRUE if the resize operation is successful,
  1614. //    otherwise false.
  1615. //
  1616. //    Warning: callers of this function must not propagate copies of 
  1617. //    the DPMImemory_t structure, as the resize operation may modify
  1618. //    the block handle.
  1619.  
  1620. //======================================================================
  1621. // Function: getCS - return current code selector
  1622. //
  1623.     uShort getCS(void);
  1624.  
  1625. //======================================================================
  1626. // Function: getDS - return current data selector
  1627. //
  1628.     uShort getDS(void);
  1629.  
  1630. #ifdef __cplusplus
  1631. }
  1632. #endif
  1633.  
  1634. #endif
  1635.