1 // Cut this out as emm.c
\r
4 * Module: All Modules
\r
5 * Author(s): Chris Somers
\r
6 * Date: December 1, 1992
\r
9 minor mods by Alex Russell to simplify
\r
11 Must use memory model with FAR code
\r
13 Open Watcom patch by sparky4~
\r
22 #include "src/lib/exmm/memory.h"
\r
23 #include "src/lib/types.h"
\r
25 #define PEMMDATAPAGENUM 4
\r
27 void TransformData(char *pEmmData, unsigned int len)
\r
38 int main(int argc, char *argv[])
\r
44 char huge *p =(char huge *)(GetEMMSeg0()*0x10000);
\r
46 if(OpenEMM() != SUCCESS)
\r
47 { // make sure we got EMM
\r
48 printf("EMM unavailable.\n");
\r
53 printf("Emm %x available\n", EMVer());
\r
54 printf("EMS pages available are %lu\n", EMMCoreLeft());
\r
55 //printf("EMM Hardware Information %lu\n", EMInfo());
\r
58 printf("b4 EMS pEmmData=%p\n", pEmmData);
\r
59 //printf("b4 EMS *pEmmData=%s\n", *pEmmData);
\r
60 advi=EMMCoreLeft()*EMMPAGESIZE;
\r
61 printf("advi=%lu\n", advi);
\r
63 pEmmData = (byte *)EMMalloc(&hEData, EMMCoreLeft()); // get 6 * 16K bytes - 96K
\r
64 if(pEmmData == NULL/* || pEmmData0 == NULL*/)
\r
66 printf("Not enough EMM or out of handles.\n");
\r
70 printf("EMM allocate OK\n");
\r
72 printf("EMS pages available are %lu\n", EMMCoreLeft());
\r
76 printf("Map 1st 4 pages\n");
\r
77 MapEMM(hEData, 0, PEMMDATAPAGENUM); // load 1st 4 pages into page frame: 0-3
\r
78 //memset(pEmmData, 0x0e, 64000u);
\r
79 //0000 printf("(advi*EMMPAGESIZE)=%lu\n", advi);
\r
80 memset(pEmmData, atoi(argv[1]), 0xffff);//sizeof(atoi(argv[1])));//((EMMCoreLeft())*EMMPAGESIZE));
\r
81 //qqqq memset(pEmmData+0x10000, atoi(argv[1]), 0xffff);//sizeof(atoi(argv[1])));//((EMMCoreLeft())*EMMPAGESIZE));
\r
82 //---- UnmapEMM(hEData, 0, 4); // not absolutely necessary
\r
83 printf("%p= %c %c %c %c %c %c %c %c\n", pEmmData,
\r
84 *pEmmData, *(pEmmData+1), *(pEmmData+2), *(pEmmData+3), *(pEmmData+4), *(pEmmData+5), *(pEmmData+6), *(pEmmData+7));
\r
86 /*printf("Map next 2 pages\n");
\r
87 MapEMM(hEData, 4, 2); // map last 2 pages: 4-5
\r
88 memset(pEmmData, 0x04, 32768u);
\r
89 // memset(pEmmData, atoi(argv[0]), 32768u);
\r
90 printf("*pEmmData=%c\n", *pEmmData);
\r
91 printf(" pEmmData=%p\n", pEmmData);*/
\r
93 /*MapEMM(hEData, 0, 4);
\r
94 // do some stuff with the first 64K of file data.
\r
95 printf("Transform data\n");
\r
96 TransformData(pEmmData, 64000UL);
\r
97 printf("*pEmmData=%lu\n", *pEmmData);
\r
98 MapEMM(hEData, 4, 2); // only unmaps 1st two pages of prior 64k mapping
\r
99 // do stuff with remaining 32K of data
\r
100 TransformData(pEmmData, 32768UL);
\r
101 printf("*pEmmData=%lu\n", *pEmmData);*/
\r
104 while(p<(char huge *)((GetEMMSeg0()*0x10000)+0xffff) && !kbhit())
\r
106 if((i%16)==0) printf("%p= %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c\n", p,
\r
107 *p, *(p+1), *(p+2), *(p+3), *(p+4), *(p+5), *(p+6), *(p+7),
\r
108 *(p+8), *(p+9), *(p+10), *(p+11), *(p+12), *(p+13), *(p+14), *(p+15));
\r
114 /*if(atoi(argv[3]))
\r
115 p =(char huge *)(GetEMMSeg0()*0x20000);
\r
116 while(p<(char huge *)((GetEMMSeg0()*0x20000)+0xffff) && !kbhit())
\r
118 if((i%16)==0) printf("%p= %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c\n", p,
\r
119 *p, *(p+1), *(p+2), *(p+3), *(p+4), *(p+5), *(p+6), *(p+7),
\r
120 *(p+8), *(p+9), *(p+10), *(p+11), *(p+12), *(p+13), *(p+14), *(p+15));
\r
129 UnmapEMM(hEData, 0, PEMMDATAPAGENUM); // should unmap before freeing
\r
130 //printf("after EMS *pEmmData=%c\n", *pEmmData);
\r
131 printf("Close emm\n");
\r
132 EMMFree(hEData); // finished with the file data
\r
135 printf("after EMS pEmmData=%p\n", pEmmData);
\r
136 printf("EMS pages available are %lu\n", EMMCoreLeft());
\r
137 printf("GetEMMSeg0=%p\n", GetEMMSeg0()*0x10000);
\r
138 //printf("EMMPAGESIZE=%d\n", EMMPAGESIZE);
\r