Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ddi_dma_setup(9F)

ddi_dma_sync(9F)

ddi_iopb_alloc(9F)

ddi_dma_lim(9S)

ddi_dma_req(9S)

ddi_mem_alloc(9F)

NAME

ddi_mem_alloc, ddi_mem_free − allocate and free memory for streaming mode access

SYNOPSIS

#include <sys/ddi.h>
#include <sys/sunddi.h>

int ddi_mem_alloc(dev_info_t ∗dip, ddi_dma_lim_t ∗limits, u_int length, u_int flags,

caddr_t ∗kaddrp, u_int ∗real_length);

void ddi_mem_free(caddr_t kaddr);

ARGUMENTS

ddi_mem_alloc()

dip A pointer to the device’s dev_info structure. 

limits A pointer to a DMA limits structure for this device (see ddi_dma_lim(9S)).  If this pointer is NULL, a default set of DMA limits is assumed. 

length The length in bytes of the desired allocation. 

flags The possible flags 1 and 0 are taken to mean, respectively, wait until memory is available, or do not wait. 

kaddrp On a successful return, ∗kaddrp points to the allocated memory. 

real_length The length in bytes that was allocated. Alignment and padding requirements may cause ddi_mem_alloc() to allocate more memory than requested in length.

ddi_mem_free()

kaddr The memory returned from a successful call to ddi_mem_alloc(). 

INTERFACE LEVEL

SPARC architecture specific (SPARC DDI). 

DESCRIPTION

ddi_mem_alloc() allocates memory addressable by the caller’s device (as described by both the dip and limits arguments) in a way that can be used for streaming mode access (see ddi_dma_req(9S)).  The allocation will obey the alignment and padding constraints as specified in the limits argument and other limits imposed by the system.  The limits argument may be NULL, in which case the system picks a reasonable limits. 

Note that you must still use DMA resource allocation functions (see ddi_dma_setup(9F)) to establish DMA resources for the memory allocated using ddi_mem_alloc(). 

In order to make the view of a memory object shared between a CPU and a DMA device consistent, explicit synchronization steps using ddi_dma_sync(9F) or ddi_dma_free(9F) are required. 

ddi_mem_free() frees up memory allocated by ddi_mem_alloc(). 

RETURN VALUES

ddi_mem_alloc() returns:

DDI_SUCCESS
Memory successfully allocated.

DDI_FAILURE
Allocation failed.

CONTEXT

ddi_mem_alloc() can be called from user or interrupt context, except when flags is set to 1, in which case it can be called from user context only. 

SEE ALSO

ddi_dma_setup(9F), ddi_dma_sync(9F), ddi_iopb_alloc(9F), ddi_dma_lim(9S), ddi_dma_req(9S)

SunOS 5.3 Writing Device Drivers

Sun Microsystems  —  Last change: 28 Sep 1992

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026