home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c100 / 2.ddi / XMSCPP.ZIP / XMS.H < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-19  |  4.2 KB  |  113 lines

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