1ddi_mem_alloc(9F)        Kernel Functions for Drivers        ddi_mem_alloc(9F)
2
3
4

NAME

6       ddi_mem_alloc,  ddi_mem_free  - allocate and free sequentially accessed
7       memory
8

SYNOPSIS

10       #include <sys/ddi.h>
11       #include <sys/sunddi.h>
12
13       int ddi_mem_alloc(dev_info_t *dip, ddi_dma_lim_t *limits,
14            uint_t length, uint_t flags, caddr_t *kaddrp,
15            uint_t *real_length);
16
17
18       void ddi_mem_free(caddr_t kaddr);
19
20

INTERFACE LEVEL

22       These    interfaces    are    obsolete.    ddi_dma_mem_alloc(9F)    and
23       ddi_dma_mem_free(9F) should be used instead.
24

PARAMETERS

26   ddi_mem_alloc()
27       dip            A pointer to the device's dev_info structure.
28
29
30       limits         A pointer to a DMA limits structure for this device (see
31                      ddi_dma_lim_sparc(9S) or ddi_dma_lim_x86(9S)).  If  this
32                      pointer is NULL, a default set of DMA limits is assumed.
33
34
35       length         The length in bytes of the desired allocation.
36
37
38       flags          The  possible  flags  1 and 0 are taken to mean, respec‐
39                      tively, wait until memory is available, or do not wait.
40
41
42       kaddrp         On a successful return, *kaddrp points to the  allocated
43                      memory.
44
45
46       real_length    The  length  in  bytes that was allocated. Alignment and
47                      padding requirements may cause ddi_mem_alloc() to  allo‐
48                      cate more memory than requested in length.
49
50
51   ddi_mem_free()
52       kaddr    The memory returned from a successful call to ddi_mem_alloc().
53
54

DESCRIPTION

56       The  ddi_mem_alloc()  function  allocates  memory for DMA transfers and
57       should be used if the device is performing sequential,  unidirectional,
58       block-sized and block-aligned transfers to or from memory. This type of
59       access is commonly known as streaming access. The allocation will  obey
60       the  alignment and padding constraints as specified by the limits argu‐
61       ment and other limits imposed by the system.
62
63
64       Note that you must still use DMA  resource  allocation  functions  (see
65       ddi_dma_setup(9F))  to establish DMA resources for the memory allocated
66       using ddi_mem_alloc(). ddi_mem_alloc() returns the actual size  of  the
67       allocated  memory  object.   Because  of padding and alignment require‐
68       ments, the actual  size  might  be  larger  than  the  requested  size.
69       ddi_dma_setup(9F) requires the actual length.
70
71
72       In order to make the view of a memory object shared between a CPU and a
73       DMA   device   consistent,   explicit   synchronization   steps   using
74       ddi_dma_sync(9F) or ddi_dma_free(9F) are required.
75
76
77       The    ddi_mem_free()   function   frees   up   memory   allocated   by
78       ddi_mem_alloc().
79

RETURN VALUES

81       The ddi_mem_alloc() function returns:
82
83       DDI_SUCCESS    Memory successfully allocated.
84
85
86       DDI_FAILURE    Allocation failed.
87
88

CONTEXT

90       The ddi_mem_alloc() function can be called  from  user,  interrupt,  or
91       kernel  context, except when flags is set to 1, in which case it cannot
92       be called from interrupt context.
93

ATTRIBUTES

95       See attributes(5) for a description of the following attributes:
96
97
98
99
100       ┌─────────────────────────────┬─────────────────────────────┐
101       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
102       ├─────────────────────────────┼─────────────────────────────┤
103       │Stability Level              │Obsolete                     │
104       └─────────────────────────────┴─────────────────────────────┘
105

SEE ALSO

107       attributes(5),         ddi_dma_free(9F),         ddi_dma_mem_alloc(9F),
108       ddi_dma_mem_free(9F),        ddi_dma_setup(9F),       ddi_dma_sync(9F),
109       ddi_iopb_alloc(9F),     ddi_dma_lim_sparc(9S),     ddi_dma_lim_x86(9S),
110       ddi_dma_req(9S)
111
112
113       Writing Device Drivers
114
115
116
117SunOS 5.11                        04 Apr 2006                ddi_mem_alloc(9F)
Impressum