Merge commit '9276b3991ba20d5a5660887ba81b0bc7bed25a0c'
[unleashed.git] / share / man / man9f / ddi_model_convert_from.9f
blob752ee456d5afddba2731dad8904f16be0d3524eb
1 '\" te
2 .\"  Copyright (c) 2001 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_MODEL_CONVERT_FROM 9F "Feb 8, 2001"
7 .SH NAME
8 ddi_model_convert_from \- determine data model type mismatch
9 .SH SYNOPSIS
10 .LP
11 .nf
12 #include <sys/ddi.h>
13 #include <sys/sunddi.h>
15 \fB uint_t\fR\fBddi_model_convert_from\fR(\fBuint_t\fR \fImodel\fR);
16 .fi
18 .SH INTERFACE LEVEL
19 .sp
20 .LP
21 Solaris DDI specific (Solaris DDI).
22 .SH PARAMETERS
23 .sp
24 .ne 2
25 .na
26 \fB\fImodel\fR \fR
27 .ad
28 .RS 10n
29 The data model type of the current thread.
30 .RE
32 .SH DESCRIPTION
33 .sp
34 .LP
35 \fBddi_model_convert_from()\fR is used to determine if the current thread uses
36 a different \fBC\fR Language Type Model than the device driver. The 64-bit
37 version of Solaris will require a 64-bit kernel to support both 64-bit and
38 32-bit user mode programs. The difference between a 32-bit program and a 64-bit
39 program is in its \fBC\fR Language Type Model: a 32-bit program is \fBILP32\fR
40 (integer, longs, and pointers are 32-bit) and a 64-bit program is \fBLP64\fR
41 (longs and pointers are 64-bit). There are a number of driver entry points such
42 as \fBioctl\fR(9E) and \fBmmap\fR(9E) where it is necessary to identify the
43 \fBC\fR Language Type Model of the user-mode originator of an kernel event. For
44 example any data which flows between programs and the device driver or vice
45 versa need to be identical in format. A 64-bit device driver may need to modify
46 the format of the data before sending it to a 32-bit application.
47 \fBddi_model_convert_from()\fR is used to determine if data that is passed
48 between the device driver and the application requires reformatting to any
49 non-native data model.
50 .SH RETURN VALUES
51 .sp
52 .ne 2
53 .na
54 \fB\fBDDI_MODEL_ILP32\fR \fR
55 .ad
56 .RS 20n
57 A conversion to/from \fBILP32\fR is necessary.
58 .RE
60 .sp
61 .ne 2
62 .na
63 \fB\fBDDI_MODEL_NONE\fR \fR
64 .ad
65 .RS 20n
66 No conversion is necessary. Current thread and driver use the same data model.
67 .RE
69 .SH CONTEXT
70 .sp
71 .LP
72 \fBddi_model_convert_from()\fR can be called from any context.
73 .SH EXAMPLES
74 .LP
75 \fBExample 1 \fR: Using \fBddi_model_convert_from()\fR in the \fBioctl()\fR
76 entry point to support both 32-bit and 64-bit applications.
77 .sp
78 .LP
79 The following is an example how to use \fBddi_model_convert_from()\fR in the
80 \fBioctl()\fR entry point to support both 32-bit and 64-bit applications.
82 .sp
83 .in +2
84 .nf
85 struct passargs32 {
86         int len;
87         caddr32_t addr;
90 struct passargs {
91         int len;
92         caddr_t addr;
94 xxioctl(dev_t dev, int cmd, intptr_t arg, int mode,
95     cred_t *credp, int *rvalp) {
96         struct passargs pa;
98         switch (ddi_model_convert_from(mode & FMODELS)) {
99             case DDI_MODEL_ILP32:
100             {
101                 struct passargs32 pa32;
103                 ddi_copyin(arg, &pa32, sizeof (struct passargs32), mode);
104                 pa.len = pa32.len;
105                 pa.address = pa32.address;
106                 break;
107             }
108             case DDI_MODEL_NONE:
109                 ddi_copyin(arg, &pa, sizeof (struct passargs), mode);
110                 break;
111         }
113         do_ioctl(&pa);
114         .\|.\|.\|.
117 .in -2
119 .SH SEE ALSO
122 \fBioctl\fR(9E), \fBmmap\fR(9E), \fBddi_mmap_get_model\fR(9F)
125 \fIWriting Device Drivers\fR