summaryrefslogtreecommitdiff
path: root/usr/src/man/man9f/devmap_devmem_setup.9f
blob: 6a914399caca0b26b2c2df45f71900f9bce15817 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
'\" te
.\"  Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH DEVMAP_DEVMEM_SETUP 9F "Jun 05, 2006"
.SH NAME
devmap_devmem_setup, devmap_umem_setup \- set driver memory mapping parameters
.SH SYNOPSIS
.nf
#include <sys/ddi.h>
#include <sys/sunddi.h>



\fBint\fR \fBdevmap_devmem_setup\fR(\fBdevmap_cookie_t\fR \fIdhp\fR, \fBdev_info_t *\fR\fIdip\fR,
     \fBstruct devmap_callback_ctl *\fR\fIcallbackops\fR, \fBuint_t\fR \fIrnumber\fR,
     \fBoffset_t\fR \fIroff\fR,  \fBsize_t\fR \fIlen\fR, \fBuint_t\fR \fImaxprot\fR,
     \fBuint_t\fR \fIflags\fR, \fBddi_device_acc_attr_t *\fR\fIaccattrp\fR);
.fi

.LP
.nf
\fBint\fR \fBdevmap_umem_setup\fR(\fBdevmap_cookie_t\fR \fIdhp\fR, \fBdev_info_t *\fR\fIdip\fR,
     \fBstruct devmap_callback_ctl *\fR\fIcallbackops\fR, \fBddi_umem_cookie_t\fR \fIcookie\fR,
     \fBoffset_t\fR \fIkoff\fR, \fBsize_t\fR \fIlen\fR, \fBuint_t\fR \fImaxprot\fR, \fBuint_t\fR \fIflags\fR,
     \fBddi_device_acc_attr_t *\fR\fIaccattrp\fR);
.fi

.SH INTERFACE LEVEL
illumos DDI specific (illumos DDI).
.SH PARAMETERS
\fBdevmap_devmem_setup()\fR parameters:
.sp
.ne 2
.na
\fB\fIdhp\fR\fR
.ad
.RS 15n
An opaque mapping handle that the system uses to describe the mapping.
.RE

.sp
.ne 2
.na
\fB\fIdip\fR\fR
.ad
.RS 15n
Pointer to the device's \fBdev_info\fR structure.
.RE

.sp
.ne 2
.na
\fB\fIcallbackops\fR\fR
.ad
.RS 15n
Pointer to a \fBdevmap_callback_ctl\fR(9S) structure. The structure contains
pointers to device driver-supplied functions that manage events on the device
mapping. The framework will copy the structure to the system private memory.
.RE

.sp
.ne 2
.na
\fB\fIrnumber\fR\fR
.ad
.RS 15n
Index number to the register address space set.
.RE

.sp
.ne 2
.na
\fB\fIroff\fR\fR
.ad
.RS 15n
Offset into the register address space.
.RE

.sp
.ne 2
.na
\fB\fIlen\fR\fR
.ad
.RS 15n
Length (in bytes) of the mapping to be mapped.
.RE

.sp
.ne 2
.na
\fB\fImaxprot\fR\fR
.ad
.RS 15n
Maximum protection flag possible for attempted mapping. Some combinations of
possible settings are:
.sp
.ne 2
.na
\fB\fBPROT_READ\fR\fR
.ad
.RS 14n
Read access is allowed.
.RE

.sp
.ne 2
.na
\fB\fBPROT_WRITE\fR\fR
.ad
.RS 14n
Write access is allowed.
.RE

.sp
.ne 2
.na
\fB\fBPROT_EXEC\fR\fR
.ad
.RS 14n
Execute access is allowed.
.RE

.sp
.ne 2
.na
\fB\fBPROT_USER\fR\fR
.ad
.RS 14n
User-level access is allowed. The mapping is done as a result of a
\fBmmap\fR(2) system call.
.RE

.sp
.ne 2
.na
\fB\fBPROT_ALL\fR\fR
.ad
.RS 14n
All access is allowed.
.RE

.RE

.sp
.ne 2
.na
\fB\fIflags\fR\fR
.ad
.RS 15n
Used to determine the cache attribute.
.sp
Possible values of the cache attribute are:
.sp
.ne 2
.na
\fB\fBIOMEM_DATA_CACHED\fR\fR
.ad
.RS 28n
The CPU can cache the data it fetches and push it to memory at a later time.
This is the default attribute that is used if no cache attributes are
specified.
.RE

.sp
.ne 2
.na
\fB\fBIOMEM_DATA_UC_WR_COMBINE\fR\fR
.ad
.RS 28n
The CPU never caches the data, but writes can occur out of order or can be
combined. Reordering is implied.
.sp
If \fBIOMEM_DATA_UC_WR_COMBINE\fR is specified but not supported,
\fBIOMEM_DATA_UNCACHED\fR is used instead.
.RE

.sp
.ne 2
.na
\fB\fBIOMEM_DATA_UNCACHED\fR\fR
.ad
.RS 28n
The CPU never caches data, but has uncacheable access to memory. Strict
ordering is implied.
.RE

The cache attributes are mutually exclusive. Any combination of the values
leads to a failure. On the SPARC architecture, only \fBIOMEM_DATA_CACHED\fR is
meaningful. Others lead to a failure.
.RE

.sp
.ne 2
.na
\fB\fIaccattrp\fR\fR
.ad
.RS 15n
Pointer to a \fBddi_device_acc_attr()\fR structure of the device. See
\fBddi_device_acc_attr\fR(9S). The value in \fBdevacc_attr_dataorder\fR is
ignored in the current release. The value in \fBdevacc_attr_endian_flags\fR is
meaningful on the SPARC architecture only.
.RE

.sp
.LP
\fBdevmap_umem_setup()\fR parameters:
.sp
.ne 2
.na
\fB\fIdhp\fR\fR
.ad
.RS 15n
An opaque data structure that the system uses to describe the mapping.
.RE

.sp
.ne 2
.na
\fB\fIdip\fR\fR
.ad
.RS 15n
Pointer to the device's \fBdev_info\fR structure.
.RE

.sp
.ne 2
.na
\fB\fIcallbackops\fR\fR
.ad
.RS 15n
Pointer to a \fBdevmap_callback_ctl\fR(9S) structure. The structure contains
pointers to device driver-supplied functions that manage events on the device
mapping.
.RE

.sp
.ne 2
.na
\fB\fIcookie\fR\fR
.ad
.RS 15n
A kernel memory \fIcookie\fR (see \fBddi_umem_alloc\fR(9F)).
.RE

.sp
.ne 2
.na
\fB\fIkoff\fR\fR
.ad
.RS 15n
Offset into the kernel memory defined by \fIcookie\fR.
.RE

.sp
.ne 2
.na
\fB\fIlen\fR\fR
.ad
.RS 15n
Length (in bytes) of the mapping to be mapped.
.RE

.sp
.ne 2
.na
\fB\fImaxprot\fR\fR
.ad
.RS 15n
Maximum protection flag possible for attempted mapping. Some combinations of
possible settings are:
.sp
.ne 2
.na
\fB\fBPROT_READ\fR\fR
.ad
.RS 14n
Read access is allowed.
.RE

.sp
.ne 2
.na
\fB\fBPROT_WRITE\fR\fR
.ad
.RS 14n
Write access is allowed.
.RE

.sp
.ne 2
.na
\fB\fBPROT_EXEC\fR\fR
.ad
.RS 14n
Execute access is allowed.
.RE

.sp
.ne 2
.na
\fB\fBPROT_USER\fR\fR
.ad
.RS 14n
User-level access is allowed (the mapping is being done as a result of a
\fBmmap\fR(2) system call).
.RE

.sp
.ne 2
.na
\fB\fBPROT_ALL\fR\fR
.ad
.RS 14n
All access is allowed.
.RE

.RE

.sp
.ne 2
.na
\fB\fIflags\fR\fR
.ad
.RS 15n
Must be set to \fB0\fR.
.RE

.sp
.ne 2
.na
\fB\fIaccattrp\fR\fR
.ad
.RS 15n
Pointer to a \fBddi_device_acc_attr\fR(9S) structure. Ignored in the current
release. Reserved for future use.
.RE

.SH DESCRIPTION
The \fBdevmap_devmem_setup()\fR and \fBdevmap_umem_setup()\fR functions are
used in the \fBdevmap\fR(9E) entry point to pass mapping parameters from the
driver to the system.
.sp
.LP
The \fIdhp\fR argument specifies a device mapping handle that the system uses
to store all mapping parameters of a physical contiguous memory. The system
copies the data pointed to by \fIcallbackops\fR to a system private memory.
This allows the driver to free the data after returning from either
\fBdevmap_devmem_setup()\fR or \fBdevmap_umem_setup()\fR. The driver is
notified of user events on the mappings via the entry points defined by
\fBdevmap_callback_ctl\fR(9S). The driver is notified of the following user
events:
.sp
.ne 2
.na
\fBMapping Setup\fR
.ad
.RS 17n
User has called \fBmmap\fR(2) to create a mapping to the device memory.
.RE

.sp
.ne 2
.na
\fBAccess\fR
.ad
.RS 17n
User has accessed an address in the mapping that has no translations.
.RE

.sp
.ne 2
.na
\fBDuplication\fR
.ad
.RS 17n
User has duplicated the mapping. Mappings are duplicated when the process calls
\fBfork\fR(2).
.RE

.sp
.ne 2
.na
\fBUnmapping\fR
.ad
.RS 17n
User has called \fBmunmap\fR(2) on the mapping or is exiting, \fBexit\fR(2).
.RE

.sp
.LP
See \fBdevmap_map\fR(9E), \fBdevmap_access\fR(9E), \fBdevmap_dup\fR(9E), and
\fBdevmap_unmap\fR(9E) for details on these entry points.
.sp
.LP
By specifying a valid \fIcallbackops\fR to the system, device drivers can
manage events on a device mapping. For example, the \fBdevmap_access\fR(9E)
entry point allows the drivers to perform context switching by unloading the
mappings of other processes and to load the mapping of the calling process.
Device drivers may specify \fINULL\fR to \fIcallbackops\fR which means the
drivers do not want to be notified by the system.
.sp
.LP
The maximum protection allowed for the mapping is specified in \fImaxprot\fR.
\fIaccattrp\fR defines the device access attributes. See
\fBddi_device_acc_attr\fR(9S) for more details.
.sp
.LP
\fBdevmap_devmem_setup()\fR is used for device memory to map in the register
set given by \fIrnumber\fR and the offset into the register address space given
by \fIroff\fR. The system uses \fIrnumber\fR and \fIroff\fR to go up the device
tree to get the physical address that corresponds to \fIroff\fR. The range to
be affected is defined by \fIlen\fR and \fIroff\fR. The range from \fIroff\fR
to \fIroff\fR \fI+\fR \fIlen\fR must be a physical contiguous memory and page
aligned.
.sp
.LP
Drivers use \fBdevmap_umem_setup()\fR for kernel memory to map in the kernel
memory described by \fIcookie\fR and the offset into the kernel memory space
given by \fIkoff\fR. \fIcookie\fR is a kernel memory pointer obtained from
\fBddi_umem_alloc\fR(9F). If \fIcookie\fR is \fINULL,\fR
\fBdevmap_umem_setup()\fR returns \fB-1.\fR The range to be affected is defined
by \fIlen\fR and \fIkoff\fR. The range from \fIkoff\fR to \fIkoff\fR \fI+\fR
\fIlen\fR must be within the limits of the kernel memory described by
\fIkoff\fR \fI+\fR \fIlen\fR and must be page aligned.
.sp
.LP
Drivers use \fBdevmap_umem_setup()\fR to export the kernel memory allocated by
\fBddi_umem_alloc\fR(9F) to user space. The system selects a user virtual
address that is aligned with the kernel virtual address being mapped to avoid
cache incoherence if the mapping is not \fBMAP_FIXED.\fR
.SH RETURN VALUES
.ne 2
.na
\fB\fB0\fR\fR
.ad
.RS 6n
Successful completion.
.RE

.sp
.ne 2
.na
\fB\fB-1\fR\fR
.ad
.RS 6n
An error occurred.
.RE

.SH CONTEXT
\fBdevmap_devmem_setup()\fR and \fBdevmap_umem_setup()\fR can be called from
user, kernel, and interrupt context.
.SH SEE ALSO
\fBexit\fR(2), \fBfork\fR(2), \fBmmap\fR(2), \fBmunmap\fR(2), \fBdevmap\fR(9E),
\fBddi_umem_alloc\fR(9F), \fBddi_device_acc_attr\fR(9S),
\fBdevmap_callback_ctl\fR(9S)
.sp
.LP
\fIWriting Device Drivers\fR