Date: Sun, 11 Feb 96 12:44:02 GMT From: Neil Jarvis To: ulfg AT groundhog DOT phy DOT nist DOT gov Cc: djgpp AT delorie DOT com Subject: Re: how to allocate DMA pages ? Reply-To: Neil DOT Jarvis AT proteon DOT com >>>>> "Ulf" == Ulf Griesmann writes: Ulf> Hello All, Ulf> The 8237 DMA controllers in a PC can only perform DMA Ulf> transfers to the lower 16MB of physical memory. This makes it Ulf> awkward to allocate buffers for DMA transfers on machines Ulf> with >16MB of memory because a simple 'malloc' is no longer Ulf> guaranteed to allocate DMAable memory. Does anyone out there Ulf> know of a good strategy for allocating DMA buffers which Ulf> works on large memory machines ? (Will take source code...) Ulf, It is actually worse than this - the 8237 DMA controller takes physical addresses, malloc returns virtual addresses. There is currently no mechanism to translate malloc'ed virtual addresses into physical addresses with which to program the DMA controller. Having said that, I came up with a solution that uses XMS to allocate and lock a region of memory above 1Mb - XMS will tell you the physical address of this region, allowing you to program DMA transfers. I then used DPMI to map a region of linear memory to this XMS region. The application can then access the data using the functions. I posted example code to this mailing list a couple of months ago. Check out in the DJGPP mail archives. http://www.delorie.com/djgpp/mail-archives/djgpp/1995/12/13/17:04:41 *NOTE* There are problem with this approach :-( . Windows 95 does not let me lock the XMS memory (I've not yet experimented with not locking the XMS region - it may not be necessary). You also require some DPMI 1.0 functions, CWSDPMI (supplies them, my version of QDPMI.COM does not. I have been using this method in a large application for the last few months with no problems (I never run under Windows 95). Hope this help. -- Neil Jarvis, Proteon International, York R&D (Neil DOT Jarvis AT proteon DOT com)