delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/11/02/08:37:42

Date: Tue, 2 Nov 1999 09:56:18 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Rob Kramer <robk AT cyberway DOT com DOT sg>
cc: djgpp AT delorie DOT com
Subject: Re: DMA despair.
In-Reply-To: <199911011050.SAA01756@eastgate.cyberway.com.sg>
Message-ID: <Pine.SUN.3.91.991102095601.19809E-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Mon, 1 Nov 1999, Rob Kramer wrote:

> ulong dma::allocateBuffer (ulong size)
> {
>     ulong               pages       = (size / 0x1000) + 2;
>     ulong               paragraphs  = pages * (0x1000 / 0x10);
>     ulong               paddress;
>     _go32_dpmi_seginfo  seginfo;
> 
>     /* Size must be page aligned */
>     if (size & 0xfff)
>         return 0;
> 
>     if (allocated)
>         freeBuffer();
> 
>     seginfo.size = paragraphs;
> 
>     if (_go32_dpmi_allocate_dos_memory (&seginfo) != -1) {
>         paddress = seginfo.rm_segment << 4;
> 
>         return paddress;
>     }
> 
>     return 0;
> }
> 
> 
> After that, I use the buffer with dosmemput(), and give 'paddress' to
> the MPEG DMA controller.  I take it I can completely ignore the
> selector returned in seginfo.pm_selector?

Yes, the selector is unused if you use dosmemput.

> Can anyone see something wrong with this? My hardware totally ignores
> whatever I copy into the buffer.

Details, please!  What do you pass as SIZE to the above functions? did
it return an error indication? how did you check that the hardware
ignores the data? does the on-board DMA controller need any
programming beyond the buffer address?  It is very hard to help you
without these details (and everything else that might be relevant).

One gotcha is that _go32_dpmi_allocate_dos_memory is not documented to
return -1 on failure: the docs says "non-zero", and it says so for a
reason.  Perhaps the function fails, but your code doesn't know that?

> Physical address equals linear address
> in this case, right?

Yes.

- Raw text -


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