www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/16/01:24:15

From: Shawn Hargreaves <Shawn AT talula DOT demon DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: DMA buffer in protected mode
Date: Mon, 13 Jan 1997 19:35:13 +0000
Organization: None
Lines: 23
Distribution: world
Message-ID: <hmHreSAx5o2yEwmK@talula.demon.co.uk>
References: <5b7dac$djl AT nr1 DOT ottawa DOT istar DOT net>
NNTP-Posting-Host: talula.demon.co.uk
MIME-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

>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 -


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