Mail Archives: djgpp/1997/01/16/01:24:15
>In protected mode, to make a DMA buffer, one must allocate memory under
>1M, correct? This memory cannot cross page breaks right? So in protected
>mode, where there are no page breaks, does it matter where the DMA
>buffer is as long as it under 1M? If it does matter, how do you find if
>it crosses a page break?
Being in protected mode doesn't make any difference to the page break
restriction - that is imposed by the DMA hardware, not the CPU.
The best strategy I can think of for getting a valid buffer is to use
__dpmi_allocate_dos_memory() to request twice as much memory as you
really need. If the first half of this is all in one page, use that,
otherwise the second half of your block will be ok. This is slightly
wasteful of memory, but DMA buffers are usually only a few K in size, so
that doesn't really matter.
For an example implementation of this technique, have a look at the
function _dma_allocate_mem() in the Allegro file dma.c.
/*
* Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
* Ghoti: 'gh' as in 'enough', 'o' as in 'women', and 'ti' as in 'nation'.
*/
- Raw text -