www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/31/18:05:26

From: mert0407 AT sable DOT ox DOT ac DOT uk (George Foot)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: buffers in conventional memory used in interrupts
Date: 29 Jul 1997 23:31:00 GMT
Organization: Oxford University, England
Lines: 44
Message-ID: <5rlufk$101@news.ox.ac.uk>
References: <33DDA0CC DOT 7A28 AT indy DOT net>
NNTP-Posting-Host: sable.ox.ac.uk
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Chris Frolik (frolikcc AT indy DOT net) wrote:

: it might make my problem clearer.  The problem is that the buffer
: structure b1 (which is pointed to by ES:SI in the interrupt) contains a
: pointer (pointer_to_more_data) which is used by the interrupt in
: referencing the data buffer which was malloc()ed and moved to
: conventional memory.  The problem here is that the interrupt references
: this memory through pointer_to_more_data, which *should* point to the
: data in the conventional memory rather than the malloc()ed data.  I

You can either write to the DOS memory block directly, using nearptr
perhaps to get a pointer to it and then treating it as a normal buffer,
which will work under some DPMI servers but not all (notably linux's
dosemu and Windows NT's DPMI server don't allow it).

Alternatively, you can write your data to a buffer in your own address
space and copy this buffer to your DOS memory block just before calling
the interrupt. You need to do this every time you call the interrupt,
though; or at least, every time you do so when the buffer's contents have
been changed. Use dosmemput to do this.

To summarise, this is the order I would do things: On initialisation, call
__dpmi_allocate_dos_memory() to get the memory block and barf if it fails.
Then make a function to call the interrupt, which accepts perhaps a
pointer to a memory buffer. This function would copy the given buffer into
the DOS memory block allocated earlier using dosmemput perhaps, and set up
a __dpmi_regs structure, and call the interrupt. If the interrupt is going
to return any information you would also need to dosmemget the block back,
so that the caller can read it. Finally, when your program terminates or
when you have finished with the interrupt for good, free up the dos memory
block allocated earlier.

If you use nearptrs, you would also need to enable them at startup using
__djgpp_nearptr_enable(), checking that it succeeded, and create a pointer
to the DOS block in the usual nearptr fashion. The interrupt caller would
no longer need to accept a pointer, and would not need to copy either to
or from DOS memory.

I hope this is clear; my shell account keeps crashing on me, so this is
the third time I've written this :)

-- 
George Foot <mert0407 AT sable DOT ox DOT ac DOT uk>
Merton College, Oxford

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019