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 DDI_SEGMAP 9F "Nov 17, 2003"
8 ddi_segmap, ddi_segmap_setup \- set up a user mapping using seg_dev
14 #include <sys/sunddi.h>
18 \fBint\fR \fBddi_segmap\fR(\fBdev_t\fR \fIdev\fR, \fBoff_t\fR \fIoffset\fR, \fBstruct as *\fR\fIasp\fR,
19 \fBcaddr_t *\fR\fIaddrp\fR, \fBoff_t\fR \fIlen\fR, \fBuint_t\fR \fIprot\fR,
20 \fBuint_t\fR \fImaxprot\fR, \fBuint_t\fR \fIflags\fR, \fBcred_t\fR \fI*credp\fR);
25 \fBint\fR \fBddi_segmap_setup\fR(\fBdev_t\fR \fIdev\fR, \fBoff_t\fR \fIoffset\fR, \fBstruct as *\fR\fIasp\fR,
26 \fBcaddr_t *\fR\fIaddrp\fR, \fBoff_t\fR \fIlen\fR, \fBuint_t\fR \fIprot\fR,
27 \fBuint_t\fR \fImaxprot\fR, \fBuint_t\fR \fIflags\fR, \fBcred_t\fR \fI*credp\fR,
28 \fBddi_device_acc_attr_t\fR \fI*accattrp\fR, \fBuint_t\fR \fIrnumber\fR);
34 These interfaces are obsolete. See \fBdevmap\fR(9E) for an alternative to
35 \fBddi_segmap()\fR. Use \fBdevmap_setup\fR(9F) instead of
36 \fBddi_segmap_setup()\fR.
44 The device whose memory is to be mapped.
53 The offset within device memory at which the mapping begins.
62 An opaque pointer to the user address space into which the device memory should
72 Pointer to the starting address within the user address space to which the
73 device memory should be mapped.
82 Length (in bytes) of the memory to be mapped.
91 A bit field that specifies the protections. Some combinations of possible
96 \fB\fBPROT_READ\fR \fR
99 Read access is desired.
105 \fB\fBPROT_WRITE\fR \fR
108 Write access is desired.
114 \fB\fBPROT_EXEC\fR \fR
117 Execute access is desired.
123 \fB\fBPROT_USER\fR \fR
126 User-level access is desired (the mapping is being done as a result of a
127 \fBmmap\fR(2) system call).
133 \fB\fBPROT_ALL\fR \fR
136 All access is desired.
147 Maximum protection flag possible for attempted mapping (the \fBPROT_WRITE\fR
148 bit may be masked out if the user opened the special file read-only). If
149 \fB(maxprot & prot) != prot\fR then there is an access violation.
158 Flags indicating type of mapping. Possible values are (other bits may be set):
162 \fB\fBMAP_PRIVATE\fR \fR
171 \fB\fBMAP_SHARED\fR \fR
174 Changes should be shared.
180 \fB\fBMAP_FIXED\fR \fR
183 The user specified an address in \fI*addrp\fR rather than letting the system
195 Pointer to user credential structure.
198 .SS "ddi_segmap_setup(\|)"
202 \fB\fIdev_acc_attr\fR \fR
205 Pointer to a \fBddi_device_acc_attr\fR(9S) structure which contains the device
206 access attributes to apply to this mapping.
215 Index number to the register address space set.
221 Future releases of Solaris will provide this function for binary and source
222 compatibility. However, for increased functionality, use
223 \fBddi_devmap_segmap\fR(9F) instead. See \fBddi_devmap_segmap\fR(9F) for
227 \fBddi_segmap\fR(\|) and \fBddi_segmap_setup()\fR set up user mappings to
228 device space. When setting up the mapping, the \fBddi_segmap\fR(\|) and
229 \fBddi_segmap_setup()\fR routines call the \fBmmap\fR(9E) entry point to
230 validate the range to be mapped. When a user process accesses the mapping, the
231 drivers \fBmmap\fR(9E) entry point is again called to retrieve the page frame
232 number that needs to be loaded. The mapping translations for that page are
233 then loaded on behalf of the driver by the DDI framework.
236 \fBddi_segmap()\fR is typically used as the \fBsegmap\fR(9E) entry in the
237 \fBcb_ops\fR(9S) structure for those devices that do not choose to provide
238 their own \fBsegmap\fR(9E) entry point. However, some drivers may have their
239 own \fBsegmap\fR(9E) entry point to do some initial processing on the
240 parameters and then call \fBddi_segmap()\fR to establish the default memory
244 \fBddi_segmap_setup()\fR is used in the drivers \fBsegmap\fR(9E) entry point to
245 set up the mapping and assign device access attributes to that mapping.
246 \fIrnumber\fR specifies the register set representing the range of device
247 memory being mapped. See \fBddi_device_acc_attr\fR(9S) for details regarding
248 what device access attributes are available.
251 \fBddi_segmap_setup()\fR cannot be used directly in the \fBcb_ops\fR(9S)
252 structure and requires a driver to have a \fBsegmap\fR(9E) entry point.
256 \fBddi_segmap()\fR and \fBddi_segmap_setup()\fR return the following values:
263 Successful completion.
272 An error occurred. In particular, they return \fBENXIO\fR if the range to be
279 \fBddi_segmap()\fR and \fBddi_segmap_setup()\fR can be called from user or
284 See \fBattributes\fR(5) for a description of the following attributes:
292 ATTRIBUTE TYPE ATTRIBUTE VALUE
294 Stability Level Obsolete
300 \fBmmap\fR(2), \fBattributes\fR(5), \fBdevmap\fR(9E), \fBmmap\fR(9E),
301 \fBsegmap\fR(9E), \fBdevmap_setup\fR(9F), \fBcb_ops\fR(9S),
302 \fBddi_device_acc_attr\fR(9S)
305 \fIWriting Device Drivers\fR