1devmap_default_access(9F)Kernel Functions for Driversdevmap_default_access(9F)
2
3
4
6 devmap_default_access - default driver memory access function
7
9 #include <sys/ddi.h>
10 #include <sys/sunddi.h>
11
12
13 int devmap_default_access(devmap_cookie_t dhp, void *pvtp,
14 offset_t off, size_t len, uint_t type, uint_t rw);
15
16
18 Solaris DDI specific (Solaris DDI).
19
21 dhp An opaque mapping handle that the system uses to describe the
22 mapping.
23
24
25 pvtp Driver private mapping data.
26
27
28 off User offset within the logical device memory at which the
29 access begins.
30
31
32 len Length (in bytes) of the memory being accessed.
33
34
35 type Type of access operation.
36
37
38 rw Type of access.
39
40
42 devmap_default_access() is a function providing the semantics of
43 devmap_access(9E). The drivers call devmap_default_access() to handle
44 the mappings that do not support context switching. The drivers should
45 call devmap_do_ctxmgt(9F) for the mappings that support context manageā
46 ment.
47
48
49 devmap_default_access() can either be called from devmap_access(9E) or
50 be used as the devmap_access(9E) entry point. The arguments dhp, pvtp,
51 off, len, type, and rw are provided by the devmap_access(9E) entry
52 point and must not be modified.
53
55 0 Successful completion.
56
57
58 Non-zero An error occurred.
59
60
62 devmap_default_access() must be called from the driver's
63 devmap_access(9E) entry point.
64
66 Example 1 Using devmap_default_access in devmap_access.
67
68
69 The following shows an example of using devmap_default_access() in the
70 devmap_access(9E) entry point.
71
72
73 ...
74 #define OFF_DO_CTXMGT 0x40000000
75 #define OFF_NORMAL 0x40100000
76 #define CTXMGT_SIZE 0x100000
77 #define NORMAL_SIZE 0x100000
78
79 /*
80 * Driver devmap_contextmgt(9E) callback function.
81 */
82 static int
83 xx_context_mgt(devmap_cookie_t dhp, void *pvtp, offset_t offset,
84 size_t length, uint_t type, uint_t rw)
85 {
86 ......
87 /*
88 * see devmap_contextmgt(9E) for an example
89 */
90 }
91
92 /*
93 * Driver devmap_access(9E) entry point
94 */
95 static int
96 xxdevmap_access(devmap_cookie_t dhp, void *pvtp, offset_t off,
97 size_t len, uint_t type, uint_t rw)
98 {
99 offset_t diff;
100 int err;
101
102 /*
103 * check if off is within the range that supports
104 * context management.
105 */
106 if ((diff = off - OFF_DO_CTXMG) >= 0 && diff < CTXMGT_SIZE) {
107 /*
108 * calculates the length for context switching
109 */
110 if ((len + off) > (OFF_DO_CTXMGT + CTXMGT_SIZE))
111 return (-1);
112 /*
113 * perform context switching
114 */
115 err = devmap_do_ctxmgt(dhp, pvtp, off, len, type,
116 rw, xx_context_mgt);
117 /*
118 * check if off is within the range that does normal
119 * memory mapping.
120 */
121 } else if ((diff = off - OFF_NORMAL) >= 0 && diff < NORMAL_SIZE) {
122 if ((len + off) > (OFF_NORMAL + NORMAL_SIZE))
123 return (-1);
124 err = devmap_default_access(dhp, pvtp, off, len, type, rw);
125 } else
126 return (-1);
127
128 return (err);
129 }
130
131
133 devmap_access(9E), devmap_do_ctxmgt(9F), devmap_callback_ctl(9S)
134
135
136 Writing Device Drivers
137
138
139
140SunOS 5.11 14 Jan 1997 devmap_default_access(9F)