1ddi_dma_req(9S) Data Structures for Drivers ddi_dma_req(9S)
2
3
4
6 ddi_dma_req - DMA Request structure
7
9 #include <sys/ddidmareq.h>
10
11
13 Solaris DDI specific (Solaris DDI). This interface is obsolete.
14
16 A ddi_dma_req structure describes a request for DMA resources. A driver
17 can use it to describe forms of allocations and ways to allocate DMA
18 resources for a DMA request.
19
21 ddi_dma_lim_t *dmar_limits; /* Caller's dma engine
22 constraints */
23 uint_t dmar_flags; /* Contains info for
24 mapping routines */
25 int (*dmar_fp)(caddr_t);/* Callback function */
26 caddr_t dmar_arg; /* Callback function's argument */
27 ddi_dma_obj_t dmar_object; /* Descrip. of object
28 to be mapped */
29
30
31
32 For the definition of the DMA limits structure, which dmar_limits
33 points to, see ddi_dma_lim_sparc(9S) or ddi_dma_lim_x86(9S).
34
35
36 Valid values for dmar_flags are:
37
38 DDI_DMA_WRITE /* Direction memory --> IO */
39 DDI_DMA_READ /* Direction IO --> memory */
40 DDI_DMA_RDWR /* Both read and write */
41 DDI_DMA_REDZONE /* Establish MMU redzone at end of mapping */
42 DDI_DMA_PARTIAL /* Partial mapping is allowed */
43 DDI_DMA_CONSISTENT /* Byte consistent access wanted */
44 DDI_DMA_SBUS_64BIT /* Use 64 bit capability on SBus */
45
46
47
48 DDI_DMA_WRITE, DDI_DMA_READ, and DDI_DMA_RDWR describe the intended
49 direction of the DMA transfer. Some implementations might explicitly
50 disallow DDI_DMA_RDWR.
51
52
53 DDI_DMA_REDZONE asks the system to establish a protected red zone
54 after the object. The DMA resource allocation functions do not guaran‐
55 tee the success of this request, as some implementations might not have
56 the hardware ability to support it.
57
58
59 DDI_DMA_PARTIAL lets the system know that the caller can accept partial
60 mapping. That is, if the size of the object exceeds the resources
61 available, the system allocates only a portion of the object and
62 returns status indicating this partial allocation. At a later point,
63 the caller can use ddi_dma_curwin(9F) and ddi_dma_movwin(9F) to change
64 the valid portion of the object that has resources allocated.
65
66
67 DDI_DMA_CONSISTENT gives a hint to the system that the object should be
68 mapped for byte consistent access. Normal data transfers usually use a
69 streaming mode of operation. They start at a specific point, transfer a
70 fairly large amount of data sequentially, and then stop, usually on an
71 aligned boundary. Control mode data transfers for memory-resident
72 device control blocks (for example, Ethernet message descriptors) do
73 not access memory in such a sequential fashion. Instead, they tend to
74 modify a few words or bytes, move around and maybe modify a few more.
75
76
77 Many machine implementations make this non-sequential memory access
78 difficult to control in a generic and seamless fashion. Therefore,
79 explicit synchronization steps using ddi_dma_sync(9F) or
80 ddi_dma_free(9F) are required to make the view of a memory object
81 shared between a CPU and a DMA device consistent. However, proper use
82 of the DDI_DMA_CONSISTENT flag can create a condition in which a system
83 will pick resources in a way that makes these synchronization steps are
84 as efficient as possible.
85
86
87 DDI_DMA_SBUS_64BIT tells the system that the device can perform 64-bit
88 transfers on a 64-bit SBus. If the SBus does not support 64-bit data
89 transfers, data will be transferred in 32-bit mode.
90
91
92 The callback function specified by the member dmar_fp indicates how a
93 caller to one of the DMA resource allocation functions wants to deal
94 with the possibility of resources not being available. (See
95 ddi_dma_setup(9F).) If dmar_fp is set to DDI_DMA_DONTWAIT, then the
96 caller does not care if the allocation fails, and can deal with an
97 allocation failure appropriately. Setting dmar_fp to DDI_DMA_SLEEP
98 indicates the caller wants to have the allocation routines wait for
99 resources to become available. If any other value is set, and a DMA
100 resource allocation fails, this value is assumed to be a function to
101 call later, when resources become available. When the specified func‐
102 tion is called, it is passed the value set in the structure member
103 dmar_arg. The specified callback function must return either:
104
105 0 Indicating that it attempted to allocate a DMA resource but failed
106 to do so, again, in which case the callback function will be put
107 back on a list to be called again later.
108
109
110 1 Indicating either success at allocating DMA resources or that it
111 no longer wants to retry.
112
113
114
115 The callback function is called in interrupt context. Therefore, only
116 system functions and contexts that are accessible from interrupt con‐
117 text are available. The callback function must take whatever steps nec‐
118 essary to protect its critical resources, data structures, and queues.
119
120
121 It is possible that a call to ddi_dma_free(9F), which frees DMA
122 resources, might cause a callback function to be called and, unless
123 some care is taken, an undesired recursion can occur. This can cause an
124 undesired recursive mutex_enter(9F), which makes the system panic.
125
126 dmar_object Structure
127 The dmar_object member of the ddi_dma_req structure is itself a complex
128 and extensible structure:
129
130 uint_t dmao_size; /* size, in bytes, of the object */
131 ddi_dma_atyp_t dmao_type; /* type of object */
132 ddi_dma_aobj_t dmao_obj; /* the object described */
133
134
135
136 The dmao_size element is the size, in bytes, of the object resources
137 allocated for DMA.
138
139
140 The dmao_type element selects the kind of object described by dmao_obj.
141 It can be set to DMA_OTYP_VADDR, indicating virtual addresses.
142
143
144 The last element, dmao_obj, consists of the virtual address type:
145
146 struct v_address virt_obj;
147
148
149
150 It is specified as:
151
152 struct v_address {
153 caddr_t v_addr; /* base virtual address */
154 struct as *v_as; /* pointer to address space */
155 void *v_priv; /* priv data for shadow I/O */
156 };
157
158
160 See attributes(5) for descriptions of the following attributes:
161
162
163
164
165 ┌─────────────────────────────┬─────────────────────────────┐
166 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
167 ├─────────────────────────────┼─────────────────────────────┤
168 │Interface Stability │Obsolete │
169 └─────────────────────────────┴─────────────────────────────┘
170
172 ddi_dma_addr_setup(9F), ddi_dma_buf_setup(9F), ddi_dma_curwin(9F),
173 ddi_dma_free(9F), ddi_dma_movwin(9F), ddi_dma_setup(9F),
174 ddi_dma_sync(9F), mutex(9F)
175
176
177 Writing Device Drivers
178
179
180
181SunOS 5.11 12 Oct 2005 ddi_dma_req(9S)