1ddi_model_convert_from(9F)Kernel Functions for Driversddi_model_convert_from(9F)
2
3
4

NAME

6       ddi_model_convert_from - determine data model type mismatch
7

SYNOPSIS

9       #include <sys/ddi.h>
10       #include <sys/sunddi.h>
11
12        uint_tddi_model_convert_from(uint_t model);
13
14

INTERFACE LEVEL

16       Solaris DDI specific (Solaris DDI).
17

PARAMETERS

19       model     The data model type of the current thread.
20
21

DESCRIPTION

23       ddi_model_convert_from()  is  used  to  determine if the current thread
24       uses a different C Language Type Model  than  the  device  driver.  The
25       64-bit  version of Solaris will require a 64-bit kernel to support both
26       64-bit and 32-bit user mode programs. The difference between  a  32-bit
27       program  and a 64-bit program is in its C Language Type Model: a 32-bit
28       program is ILP32 (integer, longs, and pointers are 32-bit) and a 64-bit
29       program  is LP64 (longs and pointers are 64-bit). There are a number of
30       driver entry points such as ioctl(9E) and mmap(9E) where it  is  necesā€
31       sary  to identify the C Language Type Model of the user-mode originator
32       of an kernel event. For example any data which flows  between  programs
33       and  the  device driver or vice versa need to be identical in format. A
34       64-bit device driver may need to modify the format of the  data  before
35       sending it to a 32-bit application. ddi_model_convert_from() is used to
36       determine if data that is passed between  the  device  driver  and  the
37       application requires reformatting to any non-native data model.
38

RETURN VALUES

40       DDI_MODEL_ILP32     A conversion to/from ILP32 is necessary.
41
42
43       DDI_MODEL_NONE      No  conversion  is  necessary.  Current  thread and
44                           driver use the same data model.
45
46

CONTEXT

48       ddi_model_convert_from() can be called from any context.
49

EXAMPLES

51       Example 1 : Using ddi_model_convert_from() in the ioctl()  entry  point
52       to support both 32-bit and 64-bit applications.
53
54
55       The  following is an example how to use ddi_model_convert_from() in the
56       ioctl() entry point to support both 32-bit and 64-bit applications.
57
58
59         struct passargs32 {
60                 int len;
61                 caddr32_t addr;
62         };
63
64         struct passargs {
65                 int len;
66                 caddr_t addr;
67         };
68         xxioctl(dev_t dev, int cmd, intptr_t arg, int mode,
69             cred_t *credp, int *rvalp) {
70                 struct passargs pa;
71
72                 switch (ddi_model_convert_from(mode & FMODELS)) {
73                     case DDI_MODEL_ILP32:
74                     {
75                         struct passargs32 pa32;
76
77                         ddi_copyin(arg, &pa32, sizeof (struct passargs32), mode);
78                         pa.len = pa32.len;
79                         pa.address = pa32.address;
80                         break;
81                     }
82                     case DDI_MODEL_NONE:
83                         ddi_copyin(arg, &pa, sizeof (struct passargs), mode);
84                         break;
85                 }
86
87                 do_ioctl(&pa);
88                 ....
89         }
90
91

SEE ALSO

93       ioctl(9E), mmap(9E), ddi_mmap_get_model(9F)
94
95
96       Writing Device Drivers
97
98
99
100SunOS 5.11                        8 Feb 2001        ddi_model_convert_from(9F)
Impressum