d_alloc_dmamem Kernel Service

Purpose

Allocates an area of "dma-able" memory.

Syntax

void *  d_alloc_dmamem(d_handle_t  device_handle, size_t size,int align)

Description

Exported, documented kernel service supported on PCI-based systems only. The d_alloc_dmamem kernel service allocates an area of "dma-able" memory which satisfies the constraints associated with a DMA handle, specified via the device_handle parameter. The constraints (such as need for contiguous physical pages or need for 32-bit physical address) are intended to guarantee that a given adapter will be able to access the physical pages associated with the allocated memory. A driver associates such constraints with a dma handle via the flags parameter on its d_map_init call.

The area to be allocated is the number of bytes in length specified by the size parameter, and is aligned on the byte boundary specified by the align parameter. The align parameter is actually the log base 2 of the desired address boundary. For example, an align value of 12 requests that the allocated area be aligned on a 4096 byte boundary.

d_alloc_dmamem is appropriate to be used for long-term mappings. Depending on the system configuration and the constraints encoded in the device_handle, the underlying storage will come from either the real_heap (rmalloc service) or pinned_heap (xmalloc service).

Note:
  1. The d_free_dmamem service should be called to free allocation from a previous d_alloc_dmamem call.
  2. The d_alloc_dmamem kernel service can be called from the process environment only.

Parameters

Item Description
device_handle Indicates the dma handle.
align Specifies alignment characteristics.
size_t size Specifies number of bytes to allocate.

Return Values

Item Description
Address of allocated area Indicates that d_alloc_dmamem was successful.
NULL Requested memory could not be allocated.