Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
8.  Direct Memory Access (DMA) DMA Software Components: Handles, Windows, and Cookies  Previous   Contents   Next 
   
 

DMA Operations

The steps involved in a DMA transfer are similar among the types of DMA. The sections below present methods for performing DMA transfers.


Note - You do not have to ensure the DMA object is locked in memory in block drivers for buffers coming from the file system, as the file system has already locked the data in memory.


Performing Bus-Master DMA Transfers

In general, the driver should perform the following steps for bus-master DMA.

  1. Describe the DMA attributes. This enables the routines to ensure that the device will be able to access the buffer.

  2. Allocate a DMA handle.

  3. Ensure that the DMA object is locked in memory (see physio(9F) or ddi_umem_lock(9F)).

  4. Allocate DMA resources for the object.

  5. Program the DMA engine on the device and start it (this is device specific). When the transfer is complete, continue the bus master operation.

  6. Perform any required object synchronizations.

  7. Release the DMA resources.

  8. Free the DMA handle.

Performing First-Party DMA Transfers

In general, the driver should perform the following steps for first-party DMA.

  1. Allocate a DMA channel.

  2. Configure the channel with ddi_dmae_1stparty(9F).

  3. Ensure that the DMA object is locked in memory (see physio(9F) or ddi_umem_lock(9F)).

  4. Allocate DMA resources for the object.

  5. Program the DMA engine on the device and start it (this is device specific). When the transfer is complete, continue the bus-master operation.

  6. Perform any required object synchronizations.

  7. Release the DMA resources.

  8. Deallocate the DMA channel.

Performing Third-Party DMA Transfers

In general, the driver should perform these steps for third-party DMA.

  1. Allocate a DMA channel.

  2. Retrieve the system's DMA engine attributes with ddi_dmae_getattr(9F).

  3. Lock the DMA object in memory (see physio(9F) or ddi_umem_lock(9F)).

  4. Allocate DMA resources for the object.

  5. Program the system DMA engine to perform the transfer with ddi_dmae_prog(9F).

  6. Perform any required object synchronizations.

  7. Stop the DMA engine with ddi_dmae_stop(9F).

  8. Release the DMA resources.

  9. Deallocate the DMA channel.

Certain hardware platforms restrict DMA capabilities in a bus-specific way. Drivers should use ddi_slaveonly(9F) to determine if the device is in a slot in which DMA is possible.

DMA Attributes

DMA attributes describe the built-in attributes and limits of a DMA engine, including:

  • Limits on addresses the device can access

  • Maximum transfer count

  • Address alignment restrictions

To ensure that DMA resources allocated by the system can be accessed by the device's DMA engine, device drivers must inform the system of their DMA engine limitations using a ddi_dma_attr(9S) structure. The system might impose additional restrictions on the device attributes, but it never removes any of the driver-supplied restrictions.

 
 
 
  Previous   Contents   Next