delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/11/03:55:23

Xref: news2.mv.net comp.os.msdos.djgpp:3685
From: Shawn Hargreaves <slh100 AT york DOT ac DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: How to program DMA
Date: Fri, 10 May 1996 10:05:58 +0100
Organization: The University of York, UK
Lines: 42
Message-ID: <Pine.SGI.3.91.960510093803.12368A-100000@tower.york.ac.uk>
NNTP-Posting-Host: tower.york.ac.uk
Mime-Version: 1.0
In-Reply-To: <1C660601A1@merlin2.e-technik.uni-erlangen.de>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On Thu, 9 May 1996, Michael Schuster wrote:

> How can I program a Direct Memory Acess (DMA) Transfer from 
> an I/O card to my DJGPP V2 C/C++ programm? The I/O card 
> is in an ISA slot, and has to transfer 24 byte to my programm with a 
> frequency of 36 kHz.

I have yet to find any good documentation on programming the DMA. There 
is some information in the PCGPE (x2ftp.oulu.fi/pub/msdos/programmer/pcgpe),
but it is very sketchy. It's also complicated under djgpp by the fact that 
the DMA buffer usually has to be in the low megabyte of physical memory, 
so you need to use special DPMI calls to allocate DOS memory. There is 
some code that does this in my Allegro library (checkout dma.c and sb.c).

> I know, I could also make this with an interrupt-handler, as the FAQ 
> says:
>
> "  When your program runs under a DPMI host, hardware interrupts are
>    always passed to protected mode first ... However, if the interrupts
>     happen at a high frequency (say, more than 10 KHz), then the
>    overhead of the interrupt reflection from real to protected mode might
>     be too painful, and you might consider installing a real-mode interrupt 
>    handler in addition to the protected-mode one. "
>
> So, if I am in the protected mode with the DPMI host, why is it faster 
> to switch to the realmode and get there the interrupt? Or don't I 

If you are already in protected mode there is no benefit in switching to 
real mode, and it wouldn't happen. But djgpp programs often spend large 
amounts of time in real mode when they make calls to DOS (eg. accessing 
the disk or reading keystrokes) and if the interrupt occurs at one of 
these times, it is faster if it doesn't need to switch. You get the speed 
from having _two_ interrupt handlers, so there is one for whichever mode 
you happen to be in when the interrupt occurs.


/*
 *	Shawn Hargreaves.        Why is 'phonetic' spelt with a ph?
 *	Check out Allegro and FED on http://www.york.ac.uk/~slh100/
 */


- Raw text -


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