Mail Archives: djgpp/1998/12/03/01:35:39
On Wed, 2 Dec 1998 jjed AT hotmail DOT com wrote:
> Is it possible to call the XMS handler from protected mode and allocate some
> memory? Or is the memory already eaten by the DPMI host?
It depends on the DPMI host and the environment you are running.
The only configuration where I'm *sure* all the XMS is taken is when
you use CWSDPMI with no memory manager, or HIMEM alone, or put NOVCPI
and NOEMS parameters on the memory manager command line. This is
documented in the FAQ (sections 3.9 and 15.8).
I believe in all other cases, XMS is available for allocation.
> mov ax, 4310h
> int 2Fh ; get handler address
> mov word ptr [XMSControl], bx
> mov word ptr [XMSControl+2], es
>
> mov ah, 00h
> call [XMSControl] ; Get XMS version number
>
> Now, how do I do this in protected mode?
As usual, like you do with any other real-mode service (see sections
18.2, 18.3 and 18.4 of the FAQ). The following example is NOT TESTED,
and I only converted the snippet above, with no other details (like
declaration of XMSControl and the info that needs to be put there)
which would need to be filled in before it actually works:
#include <dpmi.h>
#include <go32.h>
#include <sys/types.h>
#include <sys/movedata.h>
#include <sys/farptr.h>
...
__dpmi_regs r;
dosmemput (XMSControl, XMSControl_size, __tb);
r.x.ax = 0x4310;
r.x.bx = __tb & 15;
r.x.es = __tb >> 4;
__dpmi_int (0x2f, &r);
r.h.ah = 0;
r.x.ip = _farpeekw (_dos_ds, __tb);
r.x.cs = _farpeekw (_dos_ds, __tb + 2);
r.x.ss = r.x.sp = r.x.flags = 0;
__dpmi_simulate_real_mode_procedure_retf (&r);
- Raw text -