home *** CD-ROM | disk | FTP | other *** search
- // ------------- xms.cpp
- // Extended Memory Specification (XMS) Driver Functions
-
- #include "xms.h"
-
- static void far (*xmscall)();
-
- // ------- test for XMS installed in system
- int xms_present()
- {
- _AX = 0x4300;
- geninterrupt(0x2f);
- if (_AL != 0x80)
- return 0;
- _AX = 0x4310;
- geninterrupt(0x2f);
- xmscall = (void far(*)()) (MK_FP(_ES, _BX));
- return 1;
- }
-
- // ------- return size in KB of largest XMS block available
- unsigned xms_available()
- {
- _AH = 8;
- (*xmscall)();
- return _AX;
- }
-
- // ------- allocate block in KB of XMS to an application
- int xms_allocate(unsigned blksize)
- {
- _DX = blksize;
- _AH = 9;
- (*xmscall)();
- return _DX;
- }
-
- static struct xms_copyparams {
- long length;
- int src_handle;
- long src_offset;
- int dest_handle;
- long dest_offset;
- } xcp;
-
- void xms_free(int handle)
- {
- _DX = handle;
- _AH = 0x0a;
- (*xmscall)();
- }
-
- void copy_xmstoconv(int handle, char far *memblk, long offset, long length)
- {
- xcp.src_handle = handle;
- xcp.src_offset = offset;
- xcp.dest_handle = 0;
- xcp.dest_offset = (long) memblk;
- xcp.length = length;
- _SI = (unsigned) &xcp;
- _AH = 0x0b;
- (*xmscall)();
- }
-
- void copy_convtoxms(int handle, char far *memblk, long offset, long length)
- {
- xcp.src_handle = 0;
- xcp.src_offset = (long) memblk;
- xcp.dest_handle = handle;
- xcp.dest_offset = offset;
- xcp.length = length;
- _SI = (unsigned) &xcp;
- _AH = 0x0b;
- (*xmscall)();
- }
-
-
-