what is dma, direct memory access, how dma works
Home About Us Reference Product Service Sitemap

what is dma, direct memory access, how dma works?


What is DMA, Direct Memory Access?

DMA, Direct memory access is a feature of modern computers and microprocessors that allows certain hardware subsystems within the computer to access system memory for reading and/or writing without using the central processing unit, CPU. Many hardware systems use DMA including disk drive controllers, graphics cards, network cards and sound cards. DMA is also used for intra-chip data transfer in multi-core processors, especially in multiprocessor system-on-chips, where its processing element is equipped with a local memory (often called scratchpad memory) and DMA is used for transferring data between the local memory and the main memory. Computers that have DMA channels can transfer data to and from devices with much less CPU overhead than computers without a DMA channel. Similarly a processing element inside a multi-core processor can transfer data to and from its local memory without occupying its processor time and allowing computation and data transfer concurrency.

Without DMA, using programmed input/output (PIO) mode for communication with peripheral devices, or load/store instructions in the case of multicore chips, the CPU is typically fully occupied for the entire duration of the read or write operation, and is thus unavailable to perform other work. With DMA, the CPU would initiate the transfer, do other operations while the transfer is in progress, and receive an interrupt from the DMA controller once the operation has been done. This is especially useful in real-time computing applications where not stalling behind concurrent operations is critical. Another and related application area is various forms of stream processing where it is essential to have data processing and transfer in parallel, in order to achieve sufficient throughput.

How DMA, Direct Memory Access works?

The DMA, Direct Memory Access is another two chips on your motherboard that allow you to offload data transfers between I/O boards. DMA can work from memory to I/O or from I/O to memory, but the memory to memory transfer doesn't work.

What about caches and DMA? L1 and L2 caches work absolutely transparently. When DMA writes to memory, caches autmatically load or least invalidate the data that go into the memory. When DMA reads memory, caches supply the unwritten bytes so not old but new values are tranferred to the peripheral.

There are signals DACK, DRQ, and TC. When a peripheral wants to move a byte or 2 bytes into memory, it issues DRQ. DMA controller chats with CPU and after some time DMA controller issues DACK. Seeing DACK, the peripheral puts it's byte on data bus, DMA controller takes it and puts it in memory. If it was the last byte/word to move, DMA controller sets up also TC during the DACK. When peripheral sees TC, it is possible it will not want any more movements,

In the other direction, everything is the same, but first the byte/word is fetched from the memory and then DACK is generated and the peripheral takes the data.

DMA controller has only 8-bit address counter inside. There is external ALS573 counter for each chip so it makes programmer see it as DMA controller had 16 bits of address counter per channel inside. There are more 8 bits of address per channel of so called page register in LS612 that unfortunately do not increment as those in ALS573. All these 24 bits can address 16777216 of distict addresses.

Recapitulation: for each channel, independently, you see 16 bits of auto-incrementing counter, and 8 bits of page register which doesn't increment.

The difference between 16-bit DMA channels and 8-bit DMA channels is that the address bits for 16-bit channels are wired one bit left to the address bus so every address is 2 times bigger. The lowest bit is 0. The highest bit of page register would fit into bit 24 which is not on ISA so that it is left unconnected. The bus control logic is wired for 16-bit channels in a manner every single DMA transfer, a 16-bit cycle is generated, so ISA device puts 16 bits onto the bus at the time. I don't know what happens if you use 16-bit DMA channel with XT peripheral. I guess it could work but only be slower.

8-bit DMA: increments by 1, cycles inside 65536 bytes, addresses 16MB, moves 8 bits a time.

16-bit DMA: increments by 2, goes only over even addresses, cycles inside 131072 bytes, addresses 16MB, moves 16 bits a time. Uses 16-bit ISA I/O cycle so it takes less ticks to make one move that the 8-bit DMA.

An example of DMA usage would be the Sound Blaster's ability to play samples in the background. The CPU sets up the sound card and the DMA. When the DMA is told to "go", it simply shovels the data from RAM to the card. Since this is done off-CPU, the CPU can do other things while the data is being transferred.

How to enable DMA in Windows XP?

1. Go to the Device Manager (click the Start button and then click Control Panel and double-click System and then select the Hardware tab and then click the Device Manager button).

2. In the Device Manager, expand the IDE ATA/ATAPI controllers entry, either by double-clicking IDE ATA/ATAPI controllers or by clicking on the + next to it.

3. Select the appropriate IDE channel (Primary or Secondary). To get to the IDE Channel Properties window, either double-click the channel, or right-click the channel and then click Properties, or select the channel and click Action -> Properties in the menubar.

4. In the Primary/Secondary IDE Channel Properties window, select the Advanced Settings tab.

5. Choose either the Device 0 frame for the master device on the channel or the Device 1 frame for the slave device on the channel, depending on whether the drive for which you are trying to enable DMA is master or slave. Click the Transfer Mode pull-down menu. Select DMA if available. Then click OK.

6. To verify that DMA was indeed enabled for the drive, again select the appropriate IDE channel (as in step 3), open the IDE Channel Properties window and select the Advanced Settings tab (as in step 4). The Current Transfer Mode box should display Ultra DMA Mode 2 if the drive can handle this, or Multi-Word DMA Mode 2 if the drive does not support UDMA. If DMA was not enabled, it will say PIO Mode.

©1994 - 2010 Edusoftmax Inc. All rights reserved. Questions? Comments?    Visitors: