home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 14 / CDACTUAL.iso / cdactual / demobin / share / program / c / XMS11.ZIP / XMS.H < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-31  |  3.7 KB  |  98 lines

  1. // Microsoft eXtended Memory Specification
  2. // C++ Interface Library Header File
  3. // by Richard Vuduc 
  4. // Copyright 1990, Richard Vuduc
  5.  
  6. #ifndef _XMSMGR
  7. #define _XMSMGR 1
  8.  
  9. // Types and constants
  10. enum boolean { False, True };    // analogous to Pascal's boolean
  11. const HMASeg = 0xFFFF;        // Last physical segment in real-mode
  12. const HMAOff = 0xA;        // 16 bytes + HMASeg = The 1 MB boundary
  13.  
  14. #ifndef NULL
  15. #define NULL 0
  16. #endif
  17.  
  18. class XMSDriver;            // Incomplete declaration
  19. #include "xmshndl.h"
  20.  
  21. // Extended Memory Block Move structure
  22. struct XMSMoveBlock
  23. {
  24.     unsigned long Length;        // Length of move block, in bytes
  25.     unsigned int  SrcHandle;        // Source Handle #; 0 = conventional Mem
  26.     unsigned long SrcOffset;        // Offset of source handle or off,seg
  27.     unsigned int  DestHandle;    // Destination handle
  28.     unsigned long DestOffset;    // Destination offset
  29. };
  30.  
  31. // XMSDriver class
  32. // Handles allocation and deallocation of XMS blocks
  33. class XMSDriver
  34. {
  35.     static long Avail;        // Extended Memory available to application
  36.     static long Total;        // Total extended memory installed
  37.     static boolean Installed;    // XMM installed?
  38.     boolean InstHMA;        // XMM HMA available
  39.     char far *HMAPtr;        // Pointer into High Memory Area
  40.     XMSHandle *CurrHandle,   // Linked list - Current handle
  41.             *First,        // First handle in linked list
  42.             *Last;        // Last handle in linked list
  43. public:
  44.     XMSDriver( void );        // constructor
  45.     ~XMSDriver( void );        // destructor
  46.  
  47.     // ***************** High Memory Area management functions (1024K-1088K)
  48.     boolean   ReqHMA( void );    // Allocate HMA
  49.     void      RelHMA( void );    // Deallocate HMA
  50.     void far *GetHMAPtr( void );    // Get a pointer to HMA
  51.     boolean   A20Enable( void );    // Globally enable A20 line
  52.     void      A20Disable( void );    // Globally disable A20 line
  53.     boolean   A20LEnable( void );    // Locally enable the A20 line
  54.     void      A20LDisable( void );    // Locally disable the A20 line
  55.     boolean   A20Query( void );    // Query state of A20 line
  56.     void far *HMAWrite( unsigned ItemSize, unsigned Index, unsigned Length,
  57.                     void far *Data );    // Write a block to high memory
  58.         // Read from HMA
  59.     void far *HMARead( unsigned ItemSize, unsigned Index, unsigned Length, 
  60.                     void far *Data );
  61.  
  62.     // **************** Extended Memory Block Functions... (1088K+)
  63.     unsigned EMBAlloc( unsigned size );        // Allocate EMB
  64.     void     EMBFree( unsigned handle );        // Free EMB
  65.     long     EMBLock( unsigned handle );        // Lock EMB
  66.     boolean  EMBUnlock( unsigned handle );        // Unlock EMB
  67.     boolean  EMBMoveToExt( unsigned dhandle, unsigned doff, 
  68.                        void far *p, long size );
  69.     boolean  EMBMoveToCon( void far *p, unsigned shandle, unsigned soff,
  70.                        long size );
  71.     boolean  EMBExtToExt( unsigned dhandle, unsigned doff,
  72.                       unsigned shandle, unsigned soff, long size );
  73.     boolean  EMBRealloc( unsigned handle, unsigned size );    // Realloc block
  74.  
  75.     // **************** Upper Memory Block management routines (640K - 1024K)
  76.  
  77.     // **************** Miscellaneous Management routines
  78.     long    GetAvail( void );    // Get available Extended Memory
  79.     boolean Inst( void ) { return Installed; }    // XMS Installed?
  80.     boolean HMAInst( void ) { return InstHMA; }    // HMA Installed?
  81.     long    GetTotal( void ) { return Total; }
  82.  
  83.     // **************** XMS Hi-Level Memory Managment Routines
  84.     XMSHandle *HndReqPtr( unsigned handle );
  85.     void       HndRelPtr( unsigned handle );
  86.     
  87.     // Internal functions - private only
  88. private:
  89.     void CopyBlock( char far *dest, char far *src, unsigned len );
  90.     void XMSChainHandle( unsigned int handle, unsigned int size );
  91.     XMSHandle *XMSFindLastHandle( void ) { return (CurrHandle=Last); }
  92.     XMSHandle *XMSFindFirstHandle( void ) { return (CurrHandle=First); }
  93.     XMSHandle *XMSFindHandle( unsigned handle );
  94. };
  95.  
  96. #endif
  97. // End XMS.H
  98.