d_map_page Kernel Service

Purpose

Performs platform-specific DMA mapping for a single page.

Syntax

#include <sys/dma.h>
#include <sys/xmem.h>

int d_map_page(*handle, flags, baddr, *busaddr, *xmp)
struct d_handle *handle;
int flags;
caddr_t baddr;
uint *busaddr;
struct xmem *xmp;
Note: The following is the interface definition for d_map_page when the DMA_ADDRESS_64 and DMA_ENABLE_64 flags are set on the d_map_init call.
int d_map_page(*handle, flags, baddr, *busaddr, *xmp)
struct d_handle *handle;
int flags;
unsigned long long baddr;
unsigned long long *busaddr;
struct xmem *xmp;

Parameters

Item Description
handle Indicates the unique handle returned by the d_map_init kernel service.
flags Specifies one of the following flags:
DMA_READ
Transfers from a device to memory.
BUS_DMA
Transfers from one device to another device.
DMA_BYPASS
Do not check page access.
DMA_STMAP
Indicates a short-term mapping.
baddr Specifies the buffer address.
busaddr Points to the busaddr field.
xmp Cross-memory descriptor for the buffer.

Description

The d_map_page kernel service is a bus-specific utility routine determined by the d_map_init or d_map_init_ext kernel service that performs platform specific mapping of a single 4KB or less transfer for DMA master devices. The d_map_page kernel service is a fast-path version of the d_map_list service. The entire transfer amount must fit within a single page in order to use this service. This service accepts a virtual address and completes the appropriate bus address for the device to use in the DMA transfer. Unless the DMA_BYPASS flag is set, this service also verifies access permissions to the page. If the mapping is for short term (that is, it is unmapped as soon as the I/O is complete), you must set the DMA_STMAP flag.

If the buffer is a global kernel space buffer, the cross-memory descriptor can be set to point to the exported GLOBAL cross-memory descriptor, xmem_global.

If the transfer is unable to be mapped due to resource restrictions, the d_map_page service returns DMA_NORES. If the transfer is unable to be mapped due to page access violations, this service returns DMA_NOACC.

Note: You can use the D_MAP_PAGE macro provided in the /usr/include/sys/dma.h file to code calls to the d_map_page kernel service.

Return Values

Item Description
DMA_NORES Indicates that resources are unavailable.
Note: d_map_page no mapping is done, device driver must wait until resources are freed and attempt the d_map_page call again.
Item Description
DMA_NOACC Indicates no access permission to the page.
Note: d_map_page no mapping is done, device driver must fail the corresponding I/O request.
Item Description
DMA_SUCC Indicates that the busaddr parameter contains the bus address to use for the device transfer.
Note: d_map_page successful mapping was done, device driver must call d_unmap_page when I/O is complete, or when device driver is finished with the mapped area in the case of a long-term mapping.