Specifications

12-1
12
Chapter 12 Supporting Direct Memory Access (DMA)
12
12
12
This chapter explains how to program devices that support Direct Memory Access (DMA)
using this operating system on the Series 6000 platform. From a hardware perspective,
DMA is an optional hardware feature that is commonly supported by devices that must
transfer large amounts of data between the device and either system or bus memory. Its
chief advantage is that it allows the device to drive its own data transfer in parallel with the
processor. During the data transfers, the processors are free to perform any work that does
not require access to the same memory areas involved in the DMA transfer.
This chapter gives an overview of a typical DMA transfer on the Series 6000 platform. It
also details programming issues that you must consider when programming a DMA trans-
fer. These issues are related to the characteristics of the device as well as the hardware
platform. For each issue, this chapter provides programming advice in terms of kernel rou-
tines, device driver flags, or programming algorithms.
Overview 12
Typically, a driver starts a DMA transfer by sending a command to the DMA controller
that includes the operation to be done (read or write), the physical memory address or list
of addresses of the data, and the size of the transfer. Once started, the DMA device
performs the data transfer on behalf of the processor, which is free to perform other tasks.
The driver may be designed to force the initiating process to sleep until the DMA transfer
completes, or it may allow the process to continue running.
Typically, the device reports completion of the DMA operation by means of an interrupt.
The driver's interrupt routine has the responsibility of handling the completion status and
notifying the initiating process of the completion, either by waking up the process or by
using some other means.
DMA into User Buffers 12
One decision that a driver writer must make is whether to perform DMA operations
directly into the user's buffer or to use kernel memory along with the copyin() and
copyout() routines. Making use of kernel memory may result in simpler driver code,
but the overhead of copying the data to and from the user's buffers may not be acceptable.
In order to perform DMA directly into the user's buffer, the driver must make sure that the
memory is locked down—that is, cannot be swapped out by the system while the DMA is
in progress. Swapping happens when the system requires real memory (RAM) but none is
available. Portions of user memory will be written to disk to free the memory for use by
other processes. When the affected process requires access to the swapped data, the