Direct Memory Access (DMA)
at Saturday, November 15, 2008
Direct Memory Access (DMA) is a way by which hardwares directly access host memory for reading or writing independent of CPU. The alternative approach is called the Programmed I/O where all read/write transactions will be through CPU and hence the CPU will be unavailable to other tasks during I/O. Due to the unavailability of CPU during I/O, programmed I/O approach is not preferred where there is a need for higher data transfers between hardwares and memory.
For example, a network device uses DMA approach to read/write buffers in host memory. In this way, CPU can be utilized in an efficient manner to process received frames than processing I/O.
For a DMA transfer, CPU initiates it by issuing a command. The DMA transfer command is executed by a DMA controller on the board. In case of PCI and other technologies, bus mastering technique is mostly used for DMA transfer. In bus mastering technique, the device takes control of the bus and performs DMA transfers on its own
Types of DMA
Devices perform one of the three ways of DMA
1. Bus-Master DMA
2. First-Party DMA, and
3. Third-Party DMA
Bus-Master DMA
The device takes control of the bus and performs DMA transfers on its own. In this type, device driver has to program the device's DMA interface (registers) according to its specification.
First-Party DMA
Under first-party DMA, the device uses a channel from the system's DMA engine to drive that device's DMA bus cycles. The device driver has to configure the channel in a cascade mode to avoid DMA engine from interfering with transfers.
Third-Party DMA
Third-party DMA uses a system DMA engine resident on the main system board, which has several DMA channels that are available for use by devices. The device relies on the system's DMA engine to perform the data transfers between the device and memory. The driver uses DMA engine routines to initialize and program the DMA engine. For each DMA data transfer, the driver programs the DMA engine and then gives the device a command to initiate the transfer in cooperation with that engine.
References:
1. Writing Device Drivers
2. Direct Memory Access
Read More...
For example, a network device uses DMA approach to read/write buffers in host memory. In this way, CPU can be utilized in an efficient manner to process received frames than processing I/O.
For a DMA transfer, CPU initiates it by issuing a command. The DMA transfer command is executed by a DMA controller on the board. In case of PCI and other technologies, bus mastering technique is mostly used for DMA transfer. In bus mastering technique, the device takes control of the bus and performs DMA transfers on its own
Types of DMA
Devices perform one of the three ways of DMA
1. Bus-Master DMA
2. First-Party DMA, and
3. Third-Party DMA
Bus-Master DMA
The device takes control of the bus and performs DMA transfers on its own. In this type, device driver has to program the device's DMA interface (registers) according to its specification.
First-Party DMA
Under first-party DMA, the device uses a channel from the system's DMA engine to drive that device's DMA bus cycles. The device driver has to configure the channel in a cascade mode to avoid DMA engine from interfering with transfers.
Third-Party DMA
Third-party DMA uses a system DMA engine resident on the main system board, which has several DMA channels that are available for use by devices. The device relies on the system's DMA engine to perform the data transfers between the device and memory. The driver uses DMA engine routines to initialize and program the DMA engine. For each DMA data transfer, the driver programs the DMA engine and then gives the device a command to initiate the transfer in cooperation with that engine.
References:
1. Writing Device Drivers
2. Direct Memory Access
Read More...


