![]() |
DM&P DOS XMS Library Reference |
2002/04/18 Version 0.10 |
DOS XMS library is a DOS real mode and large memory model C library. Because DOS is ran under real mode, programmer only can access RAM under 1MB. The memory user can use are 640 KB, Other 384 KB are reserved for ROM BIOS and other cards. XMS library provides M6117D programmer a easy way to access RAM above 1 MB under DOS via XMS driver. For X-DOS, add "DOS=HIGH" to you CONFIG.SYS will force X-DOS to active XMS driver.
Notice: The memory size should be even when you call XMS functions. The string "szStr" in DEMO.C contains 15 characters which length is 16(15+one '\0'). You can modified it that the length of "szStr" to be odd and will get mistake.
If you have any problem, mail to soc@dmp.com.tw please.
Description: | Initialize XMS driver and get control function address. | ||
Arguments: |
|
||
Example: |
/* Initialize XMS driver */ if(XMS_Init() == 0) { printf("Unable to find XMS driver.\n"); return; } |
Description: | Get XMS driver version. | ||
Arguments: |
|
||
Example: |
/* Show XMS version */ printf("XMS Version: %x\n", XMS_GetVer()); |
Description: | Query free memory and maximum available space | ||||
Arguments: |
|
||||
Example: |
unsigned int nMax, nTotal; XMS_GetFree(&nMax, &nTotal); printf("Free memory: max=%u KB, total=%u KB.\n", nMax, nTotal); |
Description: | Allocate XMS memory. | ||||||
Arguments: |
|
||||||
Example: |
unsigned int Handle; if(XMS_Allocate(1, &Handle) == 0) { printf("failed!\n"); return; } |
Description: | Free allocated XMS memory. | ||||
Arguments: |
|
||||
Example: |
/* Free XMS we allocated */ XMS_Free(Handle); |
Description: | Get handle information. | ||||||||||
Arguments: |
|
||||||||||
Example: |
/* Show handle information */ XMS_GetInfo(Handle, &cLockCounter, &cAvailHandle, &nSize); printf("Block info: "); printf("lock counter=%u, ", cLockCounter); printf("available handle=%u, ", cAvailHandle); printf("size=%u KB.\n", nSize); |
Description: | Copy memory. | ||||
Arguments: |
The XMMS structure: struct XMMS { unsigned long lLen; /* length */ unsigned int SrcHandle; /* source handle */ unsigned long lSrcOffset; /* source offset */ unsigned int DstHandle; /* destination handle */ unsigned long lDstOffset; /* destination offset */ }; |
||||
Example: |
XMMS XMMS; XMMS.lLen = lLen; XMMS.SrcHandle = SrcHandle; XMMS.lSrcOffset = lSrcOffset; XMMS.DstHandle = 0; ((unsigned int *)(&XMMS.lDstOffset))[0] = FP_OFF(pDst); ((unsigned int *)(&XMMS.lDstOffset))[1] = FP_SEG(pDst); XMS_Copy(&XMMS); |
Description: | Copy memory buffer to XMS. | ||||||||||
Arguments: |
|
||||||||||
Example: |
XMS_CopyToXMS(Handle, 0, pcBuf, BUF_SIZE); |
Description: | Copy XMS to memory buffer. | ||||||||||
Arguments: |
|
||||||||||
Example: |
XMS_CopyFromXMS(pcBuf, Handle, 0, BUF_SIZE); |
DMP Electronics Inc. All rights reserved. | Email us: info@dmp.com.tw |