From: pekangas AT sci DOT fi (Petteri Kangaslampi) Newsgroups: comp.os.msdos.djgpp Subject: Re: Need help on DMA transfer Date: 28 Apr 1997 15:12:16 GMT Organization: Scifi Communications International Oy, http://www.sci.fi/, helpdesk AT sci DOT fi, 03 2899111 Lines: 90 Message-ID: References: <5E6E9801EF3 AT brain1 DOT lstm DOT ruhr-uni-bochum DOT de> Reply-To: pekangas AT sci DOT fi NNTP-Posting-Host: sci.fi To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk On Mon, 28 Apr 1997 12:39:59 GMT, Tom Demmer wrote: > - Can the DMA buffer be above 1 MB, or _must_ I transfer from/to > DOS memory? I could be wrong, but I have a feeling that the DMA controller could access the first 16 megabytes of memory, but not more. I stick to the first megabyte though, it always works. > - If I have to go over DOS mem, how can I ensure the buffer does not > cross a 128kB boundary? Or is the information, DMA buffers must not > cross such a boundary, outdated? No, you certainly cannot cross the boundaries. In addition, the page size is 128k for the 16-bit DMA channels, and 64k for the 8-bit ones. I'd suggest you always stay inside a 64k page. >And the toughest thing ;-) this is from the Linux code: >I know what most of the functions are doing, but I don't have the >slightest idea _how_: [clip] Most of the functions seem to map pretty 1-to-1 to the DMA controller registers. I suggest you grab some reference about the DMA controller (maybe HelpPC has some information), and a good example DMA source code - the Allegro DMA code is probably a good place to start. Some comments on the functions though: > disable_dma( ibdma ); /* ibdma is the DMA channel */ Probably masks out the DMA channel. > clear_dma_ff ( ibdma ); /* ???? */ Clears the DMA controller word flip-flop - now, when writing/reading a 16-bit register, the next write/read will go to the lower byte. > /* These ones are self-explaining, but how to do it? */ > set_dma_count( ibdma, rwop->io_cnt ); > set_dma_addr ( ibdma, rwop->io_pbuf); > if (rwop->io_flags & IO_READ) { > set_dma_mode( ibdma, DMA_MODE_READ ); > } > else { > set_dma_mode( ibdma, DMA_MODE_WRITE ); > } > enable_dma( ibdma );/* enable Host side DMA transfers */ > sti(); > /* > ** Let IO card initiate DMA > */ > bdDMAstart(rwop); > /* > ** Wait until card finished or error > */ > bdDMAwait(rwop, 0); > /* > ** Stop IO card and get amount xfered > */ > resid = bdDMAstop(rwop); > /* > ** Disable DMA channel. How? > */ > disable_dma( ibdma ); > return resid; > > >Any help appreciated, TIA. > >Ciao >Tom > > ****************************************************************** > * Thomas Demmer * Phone : +49 234 700 6434 * > * Universitaetsstr. 150 * Fax : +49 234 709 4162 * > * Lehrstuhl fuer Stroemungsmechanik * * > * D-44780 Bochum * * > ****************************************************************** > * Email: demmer AT LStM DOT Ruhr-Uni-Bochum DOT De * > * WWW: http://www.lstm.ruhr-uni-bochum.de/~demmer * > ****************************************************************** > > Anatomy (n): something everyone has, but which looks > better on a girl. -- Bruce Raeburn. >