Mail Archives: djgpp/2001/01/04/04:30:54
[Please keep the news group cc:'ed, don't write to me alone: I think
this discussion is useful for others as well.]
On Wed, 3 Jan 2001 jvasquez AT getntds DOT com wrote:
> Are there any sample code that will show me how to do the steps outlined in
> chapter 18.13? The paragraph discribing XMS operation is kinda cyptic.
DMA programming has ``cryptic'' written all over it. You should get
used to this ;-)
As for code examples, search the archives of this news group for
keywords such as XMS and DMA. I think someone posted some code here
in the past. The archives can be searched at this URL:
http://www.delorie.com/djgpp/mail-archives/
> I use int86x(0x2f,&inregs,&outregs,&sregs) setting inregs.x.ax to 0x4310.
Bad idea: use __dpmi_int instead. I suggest to read sections 18.1,
18.2, and 18.4 at least, before writing such low-level code. If you
can afford it, I suggest to read the entire Chapter 18.
> union REGS inregs,outregs;
> struct SREGS segregs
> inregs.x.ax = 0x4310;
> if (int86x(0x2f,&inregs,&outregs,&segregs) == 0)
This will most probably crash: you pass garbage in sregs. Use
__dpmi_int instead, as I said above.
> Xms.segment = segregs.es; //=0
Why do you think Xms.segment is (or should be) zero? I don't think it
should, in general.
> DpmiRegs.x.sp = 0;
> DpmiRegs.x.ss = 0;
> DpmiRegs.x.flags = 0;
It's much better to use memset to zero out the entire DpmiRegs
variable.
> DpmiRegs.x.es = Xms.segment; //obtain from function 4310h - value = 0
> DpmiRegs.x.di = Xms.offset16;//obtain from function 4310h - some value
>
> DpmiRegs.x.ax = 0x900; //function 9
> DpmiRegs.x.dx = 64; //64 k buffers
> __dpmi_simulate_real_mode_procedure_retf(&DpmiRegs); //system hangs-up I
> must reboot
This seems very wrong: why did you put the entry point returned by
4310h into ES:DI? The XMS spec clearly says that you should simply
_call_ that address. This means you need to put it int CS:IP in the
DpmiRegs structure, not into ES:DI.
As written, your code leaves random garbage in CS:IP, so the CPU jumps
into the blue and gets wedged, as expected.
- Raw text -