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_UNMAP 9E "Jan 21, 1997"
8 devmap_unmap \- device mapping unmap entry point
13 #include <sys/sunddi.h>
17 \fBvoid prefix\fR\fBdevmap_unmap\fR(\fBdevmap_cookie_t\fR \fIdhp\fR, \fBvoid *\fR\fIpvtp\fR,
18 \fBoffset_t\fR \fIoff\fR, \fBsize_t\fR\fIlen\fR, \fBdevmap_cookie_t\fR \fInew_dhp1\fR,
19 \fBvoid **\fR\fInew_pvtp1\fR, \fBdevmap_cookie_t\fR\fInew_dhp2\fR, \fBvoid **\fR\fInew_pvtp2\fR);
25 Solaris DDI specific (Solaris DDI).
33 An opaque mapping handle that the system uses to describe the mapping.
42 Driver private mapping data.
51 User offset within the logical device memory at which the unmapping begins.
60 Length (in bytes) of the memory being unmapped.
69 The opaque mapping handle that the system uses to describe the new region that
70 ends at (\fIoff\fR - 1) . \fInew_dhp1\fR may be \fINULL\fR.
76 \fB\fInew_pvtp1\fR \fR
79 A pointer to be filled in by the driver with the driver private mapping data
80 for the new region that ends at (\fIoff\fR - 1); ignored if \fInew_dhp1\fR is
90 The opaque mapping handle that the system uses to describe the new region that
91 begins at (\fIoff \fR + \fIlen\fR); \fInew_dhp2\fR may be \fINULL\fR.
97 \fB\fInew_pvtp2\fR \fR
100 A pointer to be filled in by the driver with the driver private mapping data
101 for the new region that begins at (\fIoff\fR + \fIlen\fR); ignored if
102 \fInew_dhp2\fR is \fINULL\fR.
108 \fBdevmap_unmap()\fR is called when the system removes the mapping in the range
109 [ \fIoff\fR, \fIoff\fR + \fIlen\fR ], such as in the \fBmunmap\fR(2) or
110 \fBexit\fR(2) system calls. Device drivers use \fBdevmap_unmap()\fR to free up
111 the resources allocated in \fBdevmap_map\fR(9E).
114 \fIdhp\fR is the mapping handle that uniquely identifies the mapping. The
115 driver stores the mapping attributes in the driver's private data, \fIpvtp\fR,
116 when the mapping is created. See \fBdevmap_map\fR(9E) for details.
119 \fIoff\fR and \fIlen\fR define the range to be affected by
120 \fBdevmap_unmap()\fR. This range is within the boundary of the mapping
121 described by \fIdhp\fR.
124 If the range [ \fIoff\fR, \fIoff\fR + \fIlen\fR ] covers the entire mapping,
125 the system passes \fINULL\fR to \fInew_dhp1\fR, \fInew_pvtp1\fR,
126 \fInew_dhp2\fR, and \fInew_pvtp2\fR. The system expects device drivers to free
127 all resources allocated for this mapping.
130 If \fIoff\fR is at the beginning of the mapping and \fIlen\fR does not cover
131 the entire mapping, the system sets \fINULL\fR to \fInew_dhp1\fR and to
132 \fInew_pvtp1\fR. The system expects the drivers to allocate new driver private
133 data for the region that starts at \fIoff\fR + \fIlen\fR and to set
134 \fI*new_pvtp2\fR to point to it. \fInew_dhp2\fR is the mapping handle of the
138 If \fIoff\fR is not at the beginning of the mapping, but \fIoff\fR + \fIlen\fR
139 is at the end of the mapping the system passes \fINULL\fR to \fInew_dhp2\fR
140 and \fInew_pvtp2\fR. The system then expects the drivers to allocate new driver
141 private data for the region that begins at the beginning of the mapping (for
142 example, stored in \fIpvtp\fR) and to set \fI*new_pvtp1\fR to point to it.
143 \fInew_dhp1\fR is the mapping handle of the newly mapped object.
146 The drivers should free up the driver private data, \fIpvtp\fR, previously
147 allocated in \fBdevmap_map\fR(9E) before returning to the system.
150 \fBExample 1 \fR\fBdevmap_unmap()\fR implementation
155 xxdevmap_unmap(devmap_cookie_t dhp, void *pvtp, offset_t off,
156 size_t len, devmap_cookie_t new_dhp1, void **new_pvtp1,
157 devmap_cookie_t new_dhp2, void **new_pvtp2)
159 struct xxpvtdata *ptmp;
160 struct xxpvtdata *p = (struct xxpvtdata *)pvtp;
161 struct xx_softc *softc = p->softc;
162 mutex_enter(&softc->mutex);
164 * If new_dhp1 is not NULL, create a new driver private data
165 * for the region from the beginning of old mapping to off.
167 if (new_dhp1 != NULL) {
168 ptmp = kmem_zalloc(sizeof (struct xxpvtdata), KM_SLEEP);
169 ptmp->dhp = new_dhp1;
170 ptmp->off = pvtp->off;
171 ptmp->len = off - pvtp->off;
176 * If new_dhp2 is not NULL, create a new driver private data
177 * for the region from off+len to the end of the old mapping.
179 if (new_dhp2 != NULL) {
180 ptmp = kmem_zalloc(sizeof (struct xxpvtdata), KM_SLEEP);
181 ptmp->off = off + len;
182 ptmp->len = pvpt->len - (off + len - pvtp->off);
183 ptmp->dhp = new_dhp2;
187 /* Destroy the driver private data - Device dependent */
189 kmem_free(pvtp, sizeof (struct xxpvtdata));
190 mutex_exit(&softc->mutex);
198 \fBexit\fR(2), \fBmunmap\fR(2), \fBdevmap_map\fR(9E),
199 \fBdevmap_callback_ctl\fR(9S)
202 \fIWriting Device Drivers\fR