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

NAME

6       ddi_segmap, ddi_segmap_setup - set up a user mapping using seg_dev
7

SYNOPSIS

9       #include <sys/conf.h>
10       #include <sys/ddi.h>
11       #include <sys/sunddi.h>
12
13
14
15       int ddi_segmap(dev_t dev, off_t offset, struct as *asp,
16            caddr_t *addrp, off_t len, uint_t prot,
17            uint_t maxprot, uint_t flags, cred_t *credp);
18
19
20       int ddi_segmap_setup(dev_t dev, off_t offset, struct as *asp,
21            caddr_t *addrp, off_t len, uint_t prot,
22            uint_t maxprot, uint_t flags, cred_t *credp,
23            ddi_device_acc_attr_t *accattrp, uint_t rnumber);
24
25

INTERFACE LEVEL

27       These  interfaces  are  obsolete.  See devmap(9E) for an alternative to
28       ddi_segmap(). Use devmap_setup(9F) instead of ddi_segmap_setup().
29

PARAMETERS

31       dev         The device whose memory is to be mapped.
32
33
34       offset      The offset  within  device  memory  at  which  the  mapping
35                   begins.
36
37
38       asp         An  opaque pointer to the user address space into which the
39                   device memory should be mapped.
40
41
42       addrp       Pointer to the starting address  within  the  user  address
43                   space to which the device memory should be mapped.
44
45
46       len         Length (in bytes) of the memory to be mapped.
47
48
49       prot        A  bit  field that specifies the protections. Some combina‐
50                   tions of possible settings are:
51
52                   PROT_READ      Read access is desired.
53
54
55                   PROT_WRITE     Write access is desired.
56
57
58                   PROT_EXEC      Execute access is desired.
59
60
61                   PROT_USER      User-level access is desired (the mapping is
62                                  being  done  as a result of a mmap(2) system
63                                  call).
64
65
66                   PROT_ALL       All access is desired.
67
68
69
70       maxprot     Maximum protection flag possible for attempted mapping (the
71                   PROT_WRITE  bit  may  be  masked out if the user opened the
72                   special file read-only). If (maxprot & prot) !=  prot  then
73                   there is an access violation.
74
75
76       flags       Flags  indicating  type  of  mapping.  Possible  values are
77                   (other bits may be set):
78
79                   MAP_PRIVATE     Changes are private.
80
81
82                   MAP_SHARED      Changes should be shared.
83
84
85                   MAP_FIXED       The user specified an  address  in   *addrp
86                                   rather  than  letting  the  system pick and
87                                   address.
88
89
90
91       credp       Pointer to user credential structure.
92
93
94   ddi_segmap_setup()
95       dev_acc_attr     Pointer to a ddi_device_acc_attr(9S)  structure  which
96                        contains the device access attributes to apply to this
97                        mapping.
98
99
100       rnumber          Index number to the register address space set.
101
102

DESCRIPTION

104       Future releases of Solaris will provide this function for  binary   and
105       source   compatibility.   However,  for  increased  functionality,  use
106       ddi_devmap_segmap(9F) instead.  See  ddi_devmap_segmap(9F) for details.
107
108
109       ddi_segmap() and ddi_segmap_setup() set  up  user  mappings  to  device
110       space.   When   setting   up   the   mapping,   the   ddi_segmap()  and
111       ddi_segmap_setup() routines call the mmap(9E) entry point  to  validate
112       the  range to be mapped.  When a user process accesses the mapping, the
113       drivers mmap(9E) entry point is again called to retrieve the page frame
114       number that needs to be loaded.  The mapping translations for that page
115       are then loaded on behalf of the driver by the DDI framework.
116
117
118       ddi_segmap()  is  typically  used  as  the  segmap(9E)  entry  in   the
119       cb_ops(9S)  structure  for  those devices that do not choose to provide
120       their own  segmap(9E) entry point. However, some drivers may have their
121       own segmap(9E) entry point to do some initial processing on the parame‐
122       ters and then call ddi_segmap() to establish the  default  memory  map‐
123       ping.
124
125
126       ddi_segmap_setup() is used in the drivers segmap(9E) entry point to set
127       up the mapping and assign device access  attributes  to  that  mapping.
128       rnumber  specifies  the  register  set representing the range of device
129       memory being mapped. See  ddi_device_acc_attr(9S) for details regarding
130       what device access attributes are available.
131
132
133       ddi_segmap_setup()  cannot be used directly in the cb_ops(9S) structure
134       and requires a driver to have a segmap(9E) entry point.
135

RETURN VALUES

137       ddi_segmap() and ddi_segmap_setup() return the following values:
138
139       0           Successful completion.
140
141
142       Non-zero    An error occurred. In particular, they return ENXIO if  the
143                   range to be mapped is invalid.
144
145

CONTEXT

147       ddi_segmap()  and  ddi_segmap_setup() can be called from user or kernel
148       context only.
149

ATTRIBUTES

151       See attributes(5) for a description of the following attributes:
152
153
154
155
156       ┌─────────────────────────────┬─────────────────────────────┐
157ATTRIBUTE TYPE         ATTRIBUTE VALUE        
158       ├─────────────────────────────┼─────────────────────────────┤
159       │Stability Level              │Obsolete                     │
160       └─────────────────────────────┴─────────────────────────────┘
161

SEE ALSO

163       mmap(2), attributes(5), devmap(9E), mmap(9E),  segmap(9E),  devmap_set‐
164       up(9F), cb_ops(9S), ddi_device_acc_attr(9S)
165
166
167       Writing Device Drivers
168
169
170
171SunOS 5.11                        17 Nov 2003                   ddi_segmap(9F)
Impressum