Yesterday i talked a little about "what DMA is". Today i want to talk a little bit about how devices use DMA)
DMA to a Driver
From the driver's point of view there are two aspects to DMA. The first is how you prepare your data for DMA transfers. The second is how you program the device to initiate the transfers & how you notice that a transfer is done. Let's talk about the second part first.
There are an infinite number of models for programming your device to start a DMA. Each introduces its own limitations. I'll go over a few of the common ones i've seen:
All of these models have the same basic characteristics. You tell the controller one or more physical address ranges from/to which to transfer data & you tell it to start transferring data. Some time in the future the transfer finishes and your driver finds out about it somehow. Hopefully this "somehow" is through an interrupt but it might also involve polling. The problem with polling is that you are, once again, wasting a very expensive CPU doing something mundane - in this case spinning and waiting on a bit in a register.
Next time i'll talk some about how you get those physical address ranges in the first place.