<sect>DMA Code

<sect1>Current DOSEmu DMA code
<p>
Unfortunately I haven't documented this yet. However, the current code has been
completely rewritten from this.

<sect1>Original DOSEMU DMA code
<p>
<tscreen><verb>
    DOSEMU DMA code
    Copyright (C) 1995  Joel N. Weber II

    This dma code is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
</verb></tscreen>

This is intended to be a reasonably complete implementation of dma.  However,
the following has been omitted:
<itemize>

<item> There is no command register.  Half the bits control hardware details,
     two bits are related to memory to memory transfer, and two bits have
     misc. functions that might be useful execpt that they are global, so
     probably only the bios messes with them.  And dosemu's psuedo-bios
     certainly doesn't need them.

<item> 16 bit DMA isn't supported, because I'm not quite sure how it's supposed
     to work.  DMA channels 4-7 are treated the same way as 0-3 execpt that
     they have different address.  Also, my currnet goal is a sb pro emulator,
     and the sb pro doesn't use 16 bit DMA.  So it's really a combination of
     lack of information and lack of need.

<item> Verify is not supported.  It doesn't actually move any data, so how
     can it possibly be simulated?

<item> The mode selection that determines whether to transfer one byte at a
     time or several is ignored because we want to feed the data to the kernel
     efficiently and let it control the speed.

<item> Cascade mode really isn't supported; however all the channels are
     available so I don't consider it nessisary.

<item> Autoinitialization may be broken.  From the docs I have, the current and
     reload registers might be written at the same time???  I can't tell.

<item> The docs I have refer to a "temporary register".  I can't figure out
     what it is, so guess what: It ain't implemented.  (It's only a read 
     register).
</itemize>

The following is known to be broken.  It should be fixed.  Any volunteers? :-)

<itemize>
<item>     dma_ff1 is not used yet

<item>     Address decrement is not supported.  As far as I know, there's no
     simple, effecient flag to pass to the kernel.

<item>     I should have used much more bitwise logic and conditional
expressions.
</itemize>

     This is my second real C program, and I had a lot of experience in Pascal
     before that.

<sect2>Adding DMA devices to DOSEMU
<p>
Read include/dma.h.  In the dma_ch[] struct, you'll find some fields that
don't exist on the real DMA controller itself.  Those are for you to fill in.
I trust that they are self-explainatory.
<p>
One trick that you should know: if you know you're writing to a device which
will fill up and you want the transfer to occur in the background, open the
file with O_NONBLOCK.
<p>
References:
<p>
PC Game Programers Encyclopedia
<htmlurl url="ftp://teeri.oulu.fi/pub/msdos/programming/gpe/" name="ftp://teeri.oulu.fi/pub/msdos/programming/gpe/">
<p>
The Intel Microprocessors: 8086/8088, 80186, 80286, 80386, 80486,
Barry B. Brey,ISBN 0-02-314250-2,1994,Macmillan
<p>
(The only reason I use this book so extensively is it's the only one like it
that I can find in the Hawaii State Library System :-)

