1ddi_mmap_get_model(9F)   Kernel Functions for Drivers   ddi_mmap_get_model(9F)
2
3
4

NAME

6       ddi_mmap_get_model - return data model type of current thread
7

SYNOPSIS

9       #include <sys/ddi.h>
10       #include <sys/sunddi.h>
11
12
13
14       uint_t ddi_mmap_get_model(void);
15
16

INTERFACE LEVEL

18       Solaris DDI specific (Solaris DDI).
19

DESCRIPTION

21       ddi_mmap_get_model()  returns  the C Language Type Model which the cur‐
22       rent thread expects. ddi_mmap_get_model() is used in  combination  with
23       ddi_model_convert_from(9F) in the mmap(9E) driver entry point to deter‐
24       mine whether there is a data model mismatch between the current  thread
25       and the device driver. The device driver might have to adjust the shape
26       of data structures before exporting them to a user  thread  which  sup‐
27       ports a different data model.
28

RETURN VALUES

30       DDI_MODEL_ILP32     Current thread expects 32-bit (ILP32) semantics.
31
32
33       DDI_MODEL_LP64      Current thread expects 64-bit (LP64) semantics.
34
35
36       DDI_FAILURE         The  ddi_mmap_get_model()  function  was not called
37                           from the mmap(9E) entry point.
38
39

CONTEXT

41       The ddi_mmap_get_model() function can only be called from the  mmap(9E)
42       driver entry point.
43

EXAMPLES

45       Example 1 : Using ddi_mmap_get_model()
46
47
48       The following is an example of the mmap(9E) entry point and how to sup‐
49       port 32-bit and 64-bit applications with the same device driver.
50
51
52         struct data32 {
53                 int len;
54                 caddr32_t addr;
55         };
56
57         struct data {
58                 int len;
59                 caddr_t addr;
60         };
61         xxmmap(dev_t dev, off_t off, int prot) {
62                 struct data dtc; /* a local copy for clash resolution */
63                 struct data *dp = (struct data *)shared_area;
64
65                 switch (ddi_model_convert_from(ddi_mmap_get_model())) {
66                 case DDI_MODEL_ILP32:
67                 {
68                         struct data32 *da32p;
69
70                         da32p = (struct data32 *)shared_area;
71                         dp = &dtc;
72                         dp->len = da32p->len;
73                         dp->address = da32->address;
74                         break;
75                 }
76                 case DDI_MODEL_NONE:
77                         break;
78                 }
79                 /* continues along using dp */
80                ...
81         }
82
83

SEE ALSO

85       mmap(9E), ddi_model_convert_from(9F)
86
87
88       Writing Device Drivers
89
90
91
92SunOS 5.11                        8 Feb 2001            ddi_mmap_get_model(9F)
Impressum