2 .\" Copyright (c) 1996, 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_ACCESS 9E "Jan 17, 1997"
8 devmap_access \- device mapping access entry point
13 #include <sys/sunddi.h>
17 \fBint prefix\fR\fBdevmap_access\fR(\fBdevmap_cookie_t\fR \fIdhp\fR, \fBvoid *\fR\fIpvtp\fR,
18 \fBoffset_t\fR \fIoff\fR, \fBsize_t\fR \fIlen\fR, \fBuint_t\fR \fItype\fR, \fBuint_t\fR \fIrw\fR);
24 Solaris DDI specific (Solaris DDI).
32 An opaque mapping handle that the system uses to describe the mapping.
41 Driver private mapping data.
50 User offset within the logical device memory at which the access begins.
59 Length (in bytes) of the memory being accessed.
68 Type of access operation. Possible values are:
72 \fB\fBDEVMAP_ACCESS\fR \fR
81 \fB\fBDEVMAP_LOCK\fR \fR
84 Lock the memory being accessed.
90 \fB\fBDEVMAP_UNLOCK\fR \fR
93 Unlock the memory being accessed.
104 Direction of access. Possible values are:
108 \fB\fBDEVMAP_READ\fR \fR
111 Read access attempted.
117 \fB\fBDEVMAP_WRITE\fR \fR
120 Write access attempted.
126 \fB\fBDEVMAP_EXEC\fR \fR
129 Execution access attempted.
137 The \fBdevmap_access()\fR entry point is an optional routine. It notifies
138 drivers whenever an access is made to a mapping described by \fIdhp\fR that
139 has not been validated or does not have sufficient protection for the access.
140 The system expects \fBdevmap_access()\fR to call either
141 \fBdevmap_do_ctxmgt\fR(9F) or \fBdevmap_default_access\fR(9F) to load the
142 memory address translations before it returns. For mappings that support
143 context switching, device drivers should call \fBdevmap_do_ctxmgt\fR(9F). For
144 mappings that do not support context switching, the drivers should call
145 \fBdevmap_default_access\fR(9F).
148 In \fBdevmap_access()\fR, drivers perform memory access related operations
149 such as context switching, checking the availability of the memory object, and
150 locking and unlocking the memory object being accessed. The
151 \fBdevmap_access()\fR entry point is set to \fINULL\fR if no operations need
155 \fIpvtp\fR is a pointer to the driver's private mapping data that was allocated
156 and initialized in the \fBdevmap_map\fR(9E) entry point.
159 \fIoff\fR and \fIlen\fR define the range to be affected by the operations in
160 \fBdevmap_access()\fR. \fItype\fR defines the type of operation that device
161 drivers should perform on the memory object. If \fBtype\fR is either
162 \fBDEVMAP_LOCK\fR or \fBDEVMAP_UNLOCK,\fR the length passed to either
163 \fBdevmap_do_ctxmgt\fR(9F) or \fBdevmap_default_access\fR(9F) must be same as
164 \fIlen\fR. \fIrw\fR specifies the direction of access on the memory object.
167 A non-zero return value from \fBdevmap_access()\fR may result in a
168 \fBSIGSEGV\fR or \fBSIGBUS\fR signal being delivered to the process.
172 \fBdevmap_access()\fR returns the following values:
179 Successful completion.
188 An error occurred. The return value from \fBdevmap_do_ctxmgt\fR(9F) or
189 \fBdevmap_default_access\fR(9F) should be returned.
194 \fBExample 1 \fR\fBdevmap_access()\fR entry point
197 The following is an example of the \fBdevmap_access()\fR entry point. If the
198 mapping supports context switching, \fBdevmap_access()\fR calls
199 \fBdevmap_do_ctxmgt\fR(9F). Otherwise, \fBdevmap_access()\fR calls
200 \fBdevmap_default_access\fR(9F).
206 #define OFF_DO_CTXMGT 0x40000000
207 #define OFF_NORMAL 0x40100000
208 #define CTXMGT_SIZE 0x100000
209 #define NORMAL_SIZE 0x100000
212 * Driver devmap_contextmgt(9E) callback function.
215 xx_context_mgt(devmap_cookie_t dhp, void *pvtp, offset_t offset,
216 size_t length, uint_t type, uint_t rw)
220 * see devmap_contextmgt(9E) for an example
225 * Driver devmap_access(9E) entry point
228 xxdevmap_access(devmap_cookie_t dhp, void *pvtp, offset_t off,
229 size_t len, uint_t type, uint_t rw)
235 * check if \fIoff\fR is within the range that supports
236 * context management.
238 if ((diff = off - OFF_DO_CTXMG) >= 0 && diff < CTXMGT_SIZE) {
240 * calculates the length for context switching
242 if ((len + off) > (OFF_DO_CTXMGT + CTXMGT_SIZE))
245 * perform context switching
247 err = devmap_do_ctxmgt(dhp, pvtp, off, len, type,
250 * check if \fI off \fRis within the range that does normal
253 } else if ((diff = off - OFF_NORMAL) >= 0 && diff < NORMAL_SIZE) {
254 if ((len + off) > (OFF_NORMAL + NORMAL_SIZE))
256 err = devmap_default_access(dhp, pvtp, off, len, type, rw);
268 \fBdevmap_map\fR(9E), \fBdevmap_default_access\fR(9F),
269 \fBdevmap_do_ctxmgt\fR(9F), \fBdevmap_callback_ctl\fR(9S)
272 \fIWriting Device Drivers\fR