2 .\" Copyright (c) 2000, Sun Microsystems, Inc. All Rights Reserved
3 .\" 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.
4 .\" 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.
5 .\" 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]
6 .TH DEVMAP_DO_CTXMGT 9F "Jan 22, 1997"
8 devmap_do_ctxmgt \- perform device context switching on a mapping
13 #include <sys/sunddi.h>
17 \fBint\fR \fBdevmap_do_ctxmgt\fR(\fBdevmap_cookie_t\fR \fIdhp\fR, \fBvoid\fR \fI*pvtp\fR, \fBoffset_t\fR \fIoff\fR,
18 \fBsize_t\fR \fIlen\fR, \fBuint_t\fR \fItype\fR,
19 \fBuint_t\fR \fIrw\fR, \fBint (*\fR\fIdevmap_contextmgt\fR)devmap_cookie_t,
20 void *, offset_t, size_t, uint_t, uint_t);
26 Solaris DDI specific (Solaris DDI).
34 An opaque mapping handle that the system uses to describe the mapping.
43 Driver private mapping data.
52 User offset within the logical device memory at which the access begins.
61 Length (in bytes) of the memory being accessed.
67 \fB\fIdevmap_contextmgt\fR \fR
70 The address of driver function that the system will call to perform context
71 switching on a mapping. See \fBdevmap_contextmgt\fR(9E) for details.
80 Type of access operation. Provided by \fBdevmap_access\fR(9E). Should not be
90 Direction of access. Provided by \fBdevmap_access\fR(9E). Should not be
97 Device drivers call \fBdevmap_do_ctxmgt()\fR in the \fBdevmap_access\fR(9E)
98 entry point to perform device context switching on a mapping.
99 \fBdevmap_do_ctxmgt()\fR passes a pointer to a driver supplied callback
100 function, \fBdevmap_contextmgt\fR(9E), to the system that will perform the
101 actual device context switching. If \fBdevmap_contextmgt\fR(9E) is not a valid
102 driver callback function, the system will fail the memory access operation
103 which will result in a \fBSIGSEGV\fR or \fBSIGBUS\fR signal being delivered to
107 \fBdevmap_do_ctxmgt()\fR performs context switching on the mapping object
108 identified by \fIdhp\fR and \fIpvtp\fR in the range specified by \fIoff\fR and
109 \fIlen\fR. The arguments \fIdhp\fR, \fIpvtp\fR, \fItype\fR, and \fIrw\fR are
110 provided by the \fBdevmap_access\fR(9E) entry point and must not be modified.
111 The range from \fIoff\fR to \fIoff+len\fR must support context switching.
114 The system will pass through \fIdhp\fR,\fI pvtp\fR,\fI off\fR, \fI len\fR,\fI
115 type\fR, and \fIrw\fR to \fBdevmap_contextmgt\fR(9E) in order to perform the
116 actual device context switching. The return value from
117 \fBdevmap_contextmgt\fR(9E) will be returned directly to
118 \fBdevmap_do_ctxmgt()\fR.
126 Successful completion.
141 \fBdevmap_do_ctxmgt()\fR must be called from the driver's
142 \fBdevmap_access\fR(9E) entry point.
145 \fBExample 1 \fRUsing devmap_do_ctxmgt in the devmap_access entry point.
148 The following shows an example of using \fBdevmap_do_ctxmgt()\fR in the
149 \fBdevmap_access\fR(9E) entry point.
155 #define OFF_DO_CTXMGT 0x40000000
156 #define OFF_NORMAL 0x40100000
157 #define CTXMGT_SIZE 0x100000
158 #define NORMAL_SIZE 0x100000
161 * Driver devmap_contextmgt(9E) callback function.
164 xx_context_mgt(devmap_cookie_t dhp, void *pvtp, offset_t offset,
165 size_t length, uint_t type, uint_t rw)
169 * see devmap_contextmgt(9E) for an example
174 * Driver devmap_access(9E) entry point
177 xxdevmap_access(devmap_cookie_t dhp, void *pvtp, offset_t off,
178 size_t len, uint_t type, uint_t rw)
184 * check if off is within the range that supports
185 * context management.
187 if ((diff = off - OFF_DO_CTXMG) >= 0 && diff < CTXMGT_SIZE) {
189 * calculates the length for context switching
191 if ((len + off) > (OFF_DO_CTXMGT + CTXMGT_SIZE))
194 * perform context switching
196 err = devmap_do_ctxmgt(dhp, pvtp, off, len, type,
199 * check if off is within the range that does normal
202 } else if ((diff = off - OFF_NORMAL) >= 0 && diff < NORMAL_SIZE) {
203 if ((len + off) > (OFF_NORMAL + NORMAL_SIZE))
205 err = devmap_default_access(dhp, pvtp, off, len, type, rw);
217 \fBdevmap_access\fR(9E), \fBdevmap_contextmgt\fR(9E),
218 \fBdevmap_default_access\fR(9F)
221 \fIWriting Device Drivers\fR