FreeBSD Handbook : FreeBSD Internals : DMA: What it Is and How it Works
Previous: PC Memory Utilization
Next: A Sample DMA transfer

24.3. DMA: What it Is and How it Works

Copyright © 1995,1997 Frank Durda IV <uhclem@FreeBSD.ORG>, All Rights Reserved.
10 December 1996. Last Update 8 October 1997.

Direct Memory Access (DMA) is a method of allowing data to be moved from one location to another in a computer without intervention from the central processor (CPU).

The way that the DMA function is implemented varies between computer architectures, so this discussion will limit itself to the implementation and workings of the DMA subsystem on the IBM Personal Computer (PC), the IBM PC/AT and all of its successors and clones.

The PC DMA subsystem is based on the Intel 8237 DMA controller. The 8237 contains four DMA channels that can be programmed independently and any one of the channels may be active at any moment. These channels are numbered 0, 1, 2 and 3. Starting with the PC/AT, IBM added a second 8237 chip, and numbered those channels 4, 5, 6 and 7.

The original DMA controller (0, 1, 2 and 3) moves one byte in each transfer. The second DMA controller (4, 5, 6, and 7) moves 16-bits from two adjacent memory locations in each transfer, with the first byte always coming from an even-numbered address. The two controllers are identical components and the difference in transfer size is caused by the way the second controller is wired into the system.

The 8237 has two electrical signals for each channel, named DRQ and -DACK. There are additional signals with the names HRQ (Hold Request), HLDA (Hold Acknowledge), -EOP (End of Process), and the bus control signals -MEMR (Memory Read), -MEMW (Memory Write), -IOR (I/O Read), and -IOW (I/O Write).

The 8237 DMA is known as a ``fly-by'' DMA controller. This means that the data being moved from one location to another does not pass through the DMA chip and is not stored in the DMA chip. Subsequently, the DMA can only transfer data between an I/O port and a memory address, but not between two I/O ports or two memory locations.

Note: The 8237 does allow two channels to be connected together to allow memory-to-memory DMA operations in a non-``fly-by'' mode, but nobody in the PC industry uses this scarce resource this way since it is faster to move data between memory locations using the CPU.

In the PC architecture, each DMA channel is normally activated only when the hardware that uses a given DMA channel requests a transfer by asserting the DRQ line for that channel.

24.3.1. A Sample DMA transfer

24.3.2. DMA Page Registers and 16Meg address space limitations

24.3.3. DMA Operational Modes and Settings

24.3.4. Programming the DMA

24.3.5. DMA Port Map

24.3.5.1. 0x00 - 0x1f DMA Controller #1 (Channels 0, 1, 2 and 3)
24.3.5.2. 0xc0 - 0xdf DMA Controller #2 (Channels 4, 5, 6 and 7)
24.3.5.3. 0x80 - 0x9f DMA Page Registers
24.3.5.4. 0x400 - 0x4ff 82374 Enhanced DMA Registers

FreeBSD Handbook : FreeBSD Internals : DMA: What it Is and How it Works
Previous: PC Memory Utilization
Next: A Sample DMA transfer