8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 * Copyright (c) 2016 by Delphix. All rights reserved.
25 */
26
27 /*
28 * Copyright (c) 2015, Joyent, Inc. All rights reserved.
29 * Copyright 2017 James S Blachly, MD <james.blachly@gmail.com>
30 */
31
32 /*
33 * Memory special file
34 */
35
36 #include <sys/types.h>
37 #include <sys/param.h>
38 #include <sys/user.h>
39 #include <sys/buf.h>
40 #include <sys/systm.h>
41 #include <sys/cred.h>
42 #include <sys/vm.h>
43 #include <sys/uio.h>
44 #include <sys/mman.h>
45 #include <sys/kmem.h>
46 #include <vm/seg.h>
47 #include <vm/page.h>
48 #include <sys/stat.h>
242 }
243
244 struct pollhead mm_pollhd;
245
246 /*ARGSUSED*/
247 static int
248 mmchpoll(dev_t dev, short events, int anyyet, short *reventsp,
249 struct pollhead **phpp)
250 {
251 switch (getminor(dev)) {
252 case M_NULL:
253 case M_ZERO:
254 case M_FULL:
255 case M_MEM:
256 case M_KMEM:
257 case M_ALLKMEM:
258 *reventsp = events & (POLLIN | POLLOUT | POLLPRI | POLLRDNORM |
259 POLLWRNORM | POLLRDBAND | POLLWRBAND);
260 /*
261 * A non NULL pollhead pointer should be returned in case
262 * user polls for 0 events.
263 */
264 *phpp = !anyyet && !*reventsp ?
265 &mm_pollhd : (struct pollhead *)NULL;
266 return (0);
267 default:
268 /* no other devices currently support polling */
269 return (ENXIO);
270 }
271 }
272
273 static int
274 mmpropop(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, int flags,
275 char *name, caddr_t valuep, int *lengthp)
276 {
277 /*
278 * implement zero size to reduce overhead (avoid two failing
279 * property lookups per stat).
280 */
281 return (ddi_prop_op_size(dev, dip, prop_op,
282 flags, name, valuep, lengthp, 0));
283 }
284
285 static int
|
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 * Copyright (c) 2016 by Delphix. All rights reserved.
25 */
26
27 /*
28 * Copyright 2017 Joyent, Inc.
29 * Copyright 2017 James S Blachly, MD <james.blachly@gmail.com>
30 */
31
32 /*
33 * Memory special file
34 */
35
36 #include <sys/types.h>
37 #include <sys/param.h>
38 #include <sys/user.h>
39 #include <sys/buf.h>
40 #include <sys/systm.h>
41 #include <sys/cred.h>
42 #include <sys/vm.h>
43 #include <sys/uio.h>
44 #include <sys/mman.h>
45 #include <sys/kmem.h>
46 #include <vm/seg.h>
47 #include <vm/page.h>
48 #include <sys/stat.h>
242 }
243
244 struct pollhead mm_pollhd;
245
246 /*ARGSUSED*/
247 static int
248 mmchpoll(dev_t dev, short events, int anyyet, short *reventsp,
249 struct pollhead **phpp)
250 {
251 switch (getminor(dev)) {
252 case M_NULL:
253 case M_ZERO:
254 case M_FULL:
255 case M_MEM:
256 case M_KMEM:
257 case M_ALLKMEM:
258 *reventsp = events & (POLLIN | POLLOUT | POLLPRI | POLLRDNORM |
259 POLLWRNORM | POLLRDBAND | POLLWRBAND);
260 /*
261 * A non NULL pollhead pointer should be returned in case
262 * user polls for 0 events or is doing an edge-triggerd poll.
263 */
264 if ((!*reventsp && !anyyet) || (events & POLLET)) {
265 *phpp = &mm_pollhd;
266 }
267 return (0);
268 default:
269 /* no other devices currently support polling */
270 return (ENXIO);
271 }
272 }
273
274 static int
275 mmpropop(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, int flags,
276 char *name, caddr_t valuep, int *lengthp)
277 {
278 /*
279 * implement zero size to reduce overhead (avoid two failing
280 * property lookups per stat).
281 */
282 return (ddi_prop_op_size(dev, dip, prop_op,
283 flags, name, valuep, lengthp, 0));
284 }
285
286 static int
|