[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How does DMA work?



In article <5h7c7l$iv3@nnrp1.news.primenet.com>,
Joe Walters <jlwalter@primenet.com> wrote:
>> Here is a fairly dumb question, which I couldn't resolve from the
>> manual - with an AE TWGS (with gal 2B) and the AE GS-Ram Plus Rev
>> D, what is it that enables me to know if DMA is taking place?

>I think that this is a two part question. The first part answers Jim's
>question and the second answers my expansion on this subject. All feel
>free to jump in with your answers, etc.

>1. How does turning on DMA change the way my Apple and the associated
>   card work? (I know that the disk read somehow goes directly to the
>   destination memory. How is this effected? Said info needs to be
>   if a FAQ of some sort. Or I need to be pointed to an existing FAQ.)

   This is a rather *in*frequently asked question, as I think it's
been over a year since I saw a similar question asked here in csa2. :)
I'll archive what gets said in this thread and drop it in my
miscellaneous A2 FAQ pages, and will report URL when done.

   Someone who gets their hands dirty with the solder (I'm mostly a
software type) may give a better explanation, but this is what I've
got in my head... DMA is the bypassing of the microprocessor to access
memory. Instead of having the main processor doing a tight loop
copying memory out of a buffer (or one byte at a time from a magic
location) and storing it in the destination memory, the DMA setup
arranges to get *safe* access to memory and do its magic.

   The safety issue is one of the major issues as to why certain
combos of accelerators, memory cards, etc are not happy when DMA is
done. For example, what if the accelerator's cache 'knows' what's in a
byte in memory, and you DMA into that? If the cache is stupid, it
won't know of the update, and provide the outdated value next time the
program asks for it. Not sure what went wrong on the first generation
of 'unsafe' AE RAM boards, but it's probably something stupid like
ignoring a signal from the motherboard or the like.

   Also, on the GS, the way the memory card is accessed varies
depending on whether it's in the first 4 blocks (either 256K or 1MB,
depending on RAM card type) of expansion slot RAM or after that. DMA
is supposed to be safe into the first 4 blocks, but apparently, with
certain special access patterns (I seem to remember it being the bank
address on certain lines in the first half of an access cycle, thus
requiring fast decode logic to grab and hold it), you can do DMA above
this limit. Both the DMA initiator (usually SCSI board) and RAM board
have to support this, also, I believe.

>2. How does turning off DMA change the way my Apple and the associated
>   card work? (The oppoosite of question #1.)

   See above.

>3. And the question in the post, "What enables me to know that DMA is
>   taking place?" (I suspect nothing external is available. Only the
>   DIP/Soft switches for your SCSI card, "give it all away.)

   Yes, looking at the dip switches is probably the best method. DMA
may do its work on the Apple II via 'cycle stealing' (processor gets
put on hold for a cycle or two while the DMA devices get safe access
to the bus), and if so, you may be able to detect the use of it via a
tightly coded loop, but that'd be pretty hard to do in the first place.
[You'd have to do so in an interrupt, and since the RamFAST puts
interrupts on hold while transferring stuff, good luck.

Nathan Mates
--
<*> Nathan Mates http://www.visi.com/~nathan/      <*>
# What are the facts? Again and again and again-- what are the _facts_?
# Shun wishful thinking, avoid opinion, care not what the neighbors
# think-- what are the facts, and to how many decimal places?  -R.A. Heinlein