Mail Archives: djgpp/1997/04/28/14:57:42
"Tom Demmer" <DEMMER AT brain1 DOT lstm DOT ruhr-uni-bochum DOT de> wrote:
> I have (partially) ported the GPIB library from the Linux Lab Project
> to DJGPP. It is a lib to program IO-Cards that communicate with
> Voltmeters, Oscilloscopes and such things. These cards can be run in
> two modes, PIO or DMA. The PIO part is working, but I think DMA could
> be faster. So I have a few questions:
>
> - Can the DMA buffer be above 1 MB, or _must_ I transfer from/to
> DOS memory?
8 bits DMA is limited to first Mb of memory. 16 bits DMA to the first 16 Mb.
(ISA boards).
> - If I have to go over DOS mem, how can I ensure the buffer does not
> cross a 128kB boundary?
Are you using 16 bits DMA? because the page size in 8 bits DMA is 64 Kb.
> Or is the information, DMA buffers must not
> cross such a boundary, outdated?
I don't fully understand your question, the thing is as follows:
The 8237 chip can see only 65536 positions in memory (16 bits DMA uses words so
can handle 128Kb) there are some registers that complete the 4 bits needed to
address 1 Mb these bits aren't in the 8237 so the chip can't change this value.
Under this suitation your buffer must feet in one page of 64Kb/128Kb, if not
you can:
1) waste part of the buffer and allocate a bigger one.
2) make the transfer in 2 steps.
> 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_:
>
> /* program dma controller */
> /* rwop->io_cnt is the # of bytes to xfer */
> /* rwop->io_pbuf is a pointer to the buffer
> ** to read/write from/to
> */
> cli();
You must disable the IRQs because of the thing explained in the next sentences.
> disable_dma( ibdma ); /* ibdma is the DMA channel */
> clear_dma_ff ( ibdma ); /* ???? */
Clear DMA Flip/Flop: The 8237 have only one port to set data so if you need to
transfer a word you must transfer it in 2 steps. Now how the 8237 knows if you
are sending the low byte or the high byte? think about that: suppose that one
program sent the low order byte only and not the high byte and the stoped, now
you'll try to send the low byte but the 8237 still waiting for the high byte!.
Clearing the F/F you are sure about in what state is the 8237.
> /* These ones are self-explaining, but how to do it? */
> set_dma_count( ibdma, rwop->io_cnt );
> set_dma_addr ( ibdma, rwop->io_pbuf);
These are words.
> if (rwop->io_flags & IO_READ) {
> set_dma_mode( ibdma, DMA_MODE_READ );
> }
> else {
> set_dma_mode( ibdma, DMA_MODE_WRITE );
> }
Selects the mode.
> enable_dma( ibdma );/* enable Host side DMA transfers */
> sti();
You are out of the dangerous area so now the IRQs can be enabled
> /*
> ** 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?
> */
Code specific for the card you are using and totally hided by the functions.
> disable_dma( ibdma );
Just in case because they explicitly stoped the board, stoping one end is
enough but not 100% correct.
> return resid;
>
>
> Any help appreciated, TIA.
I hope it will help you.
Gruesse, SET
------------------------------------ 0 --------------------------------
Visit my home page: http://www.geocities.com/SiliconValley/Vista/6552/
Salvador Eduardo Tropea (SET). (Electronics Engineer)
Address: Curapaligue 2124, Caseros, 3 de Febrero
Buenos Aires, (1678), ARGENTINA
TE: +(541) 759 0013
- Raw text -