From: kroe AT sbcs DOT sunysb DOT edu (KiYun Roe) Date: Fri, 31 Jan 92 19:07:11 EST To: djgpp AT sun DOT soe DOT clarkson DOT edu Subject: Patches for VPCI/XMS allocation Status: O I left for a couple of days and when I returned I found 26 messages from the mailing list or its participants! It's active enough for me now. :-) Below are my patches for valloc.c in go32 which allow it to allocate from both XMS/extended memory and VCPI. I think the changes are relatively straightforward. The new version of valloc.c allocates a large block from DOS memory and another large block from XMS/extended memory. After these blocks have run out it allocates from VCPI (EMS) memory. The most fundamental assumption is that VCPI pages come from outside of the two initial blocks, so it is possible to track the VCPI allocations in map[]. I haven't tested the changes extensively in the sense of hammering on them, but I've used the modified go32/debug32 to run gcc, etc., without any problems. Somebody asked what VCPI is. It stands for Virtual Control Program Interface, and it's just a scheme for allowing a 386/486 EMS emulator to co-exist with other protected mode programs. 386/486 EMS emulators work by putting the processor into V86 mode and using the memory mapping hardware to do the trick of putting extended memory pages into the EMS page frames of a V86 "box". Without a scheme like VCPI, other programs couldn't access protected mode. VCPI also allows protected mode programs to allocate memory from the extended memory pool reserved by the EMS emulator. Finally, on an entirely separate note, I reviewed the DPMI information in my copy of "Extending DOS" by Duncan et al., and as DJ has explained DPMI 0.9 won't cut it for djgpp. There's no way to ask it to do something like "please put XXX bytes of memory at YYY address (because my program expects memory to be there)". That capability is in DPMI 1.0. -- KiYun KiYun Roe kroe AT sbcs DOT sunysb DOT edu Department of Computer Science SUNY at Stony Brook Stony Brook, NY 11794-4400 (516) 632-7675 ----- Here are the context diffs for valloc.c. I confess that I normally use MKS patch instead of the djgpp patch, but I don't think there should be any problem using either patch program to apply the diffs. ----- CUT HERE ----- *** old\valloc.c Sun Aug 25 17:26:38 1991 --- valloc.c Mon Jan 27 17:26:48 1992 *************** *** 13,18 **** --- 13,19 ---- */ /* Modified for VCPI Implement by Y.Shibata Aug 5th 1991 */ + /* Modified for joint VCPI/extended memory allocation by KiYun Roe 27-Jan-92 */ /* History:126,1 */ #include *************** *** 138,151 **** unsigned los, i, lol; struct REGPACK r; ! if (vcpi_installed) ! { ! pn_hi_first = 32767; ! pn_hi_last = DOS_PAGE; ! } ! else if(use_xms) { ! xms_alloc_init(); /* Try XMS allocation */ ! } else { /* ** int 15/vdisk memory allocation --- 139,147 ---- unsigned los, i, lol; struct REGPACK r; ! if (use_xms) { ! xms_alloc_init(); /* Try XMS allocation */ ! } else { /* ** int 15/vdisk memory allocation *************** *** 181,205 **** r.r_ax = 0x4900; /* because Turbo Debugger won't if we don't */ intr(0x21, &r); ! mem_avail = 0; ! for ( i=0; i pn_hi_last) ! pn_hi_last = pn; ! vset(pn,VA_USED); return pn; - } } - else - { - for (pn=pn_hi_first; pn<=pn_hi_last; pn++) - if (vtest(pn) == VA_FREE) - { - left_hi -= 4; - vset(pn, VA_USED); - return pn; - } - } for (pn=pn_lo_first; pn<=pn_lo_last; pn++) if (vtest(pn) == VA_FREE) { --- 223,243 ---- case VA_1M: more_1m: if (vcpi_installed) + if (pn = vcpi_alloc()) { left_hi -= 4; ! vset(pn, VA_USED); return pn; } + for (pn=pn_hi_first; pn<=pn_hi_last; pn++) + if (vtest(pn) == VA_FREE) + { + left_hi -= 4; + vset(pn, VA_USED); + return pn; + } + for (pn=pn_lo_first; pn<=pn_lo_last; pn++) if (vtest(pn) == VA_FREE) { *************** *** 271,278 **** void vfree(unsigned pn) { ! if ((vcpi_installed)&&(pn >= DOS_PAGE)) ! vcpi_free(pn); vset(pn, VA_FREE); } --- 253,261 ---- void vfree(unsigned pn) { ! if (vcpi_installed && pn > pn_lo_last) ! if (pn < pn_hi_first || pn > pn_hi_last) ! vcpi_free(pn); vset(pn, VA_FREE); } *************** *** 282,288 **** if (!vcpi_flush_ok) return; /* Not Initaialized Map[] */ ! for(pn = pn_hi_first; pn <= pn_hi_last; pn++) if (vtest(pn)) vcpi_free(pn); --- 265,274 ---- if (!vcpi_flush_ok) return; /* Not Initaialized Map[] */ ! for (pn = pn_lo_last + 1; pn < pn_hi_first; pn++) ! if (vtest(pn)) ! vcpi_free(pn); ! for (pn = pn_hi_last + 1; pn <= 32767; pn++) if (vtest(pn)) vcpi_free(pn);