5907 xdrmblk_getpos() is unreliable
[illumos-gate.git] / usr / src / uts / common / vm / seg_dev.h
blobd7fbbfe6a31bcf87363a9891e4c04328cac1d72a
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
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.
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]
19 * CDDL HEADER END
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
27 /* All Rights Reserved */
30 * University Copyright- Copyright (c) 1982, 1986, 1988
31 * The Regents of the University of California
32 * All Rights Reserved
34 * University Acknowledgment- Portions of this document are derived from
35 * software developed by the University of California, Berkeley, and its
36 * contributors.
39 #ifndef _VM_SEG_DEV_H
40 #define _VM_SEG_DEV_H
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
46 struct proc;
49 * Structure whose pointer is passed to the segdev_create routine
51 struct segdev_crargs {
52 offset_t offset; /* starting offset */
53 int (*mapfunc)(dev_t dev, off_t off, int prot); /* map function */
54 dev_t dev; /* device number */
55 uchar_t type; /* type of sharing done */
56 uchar_t prot; /* protection */
57 uchar_t maxprot; /* maximum protection */
58 uint_t hat_attr; /* hat attr */
59 uint_t hat_flags; /* currently, hat_flags is used ONLY for */
60 /* HAT_LOAD_NOCONSIST; in future, it can be */
61 /* expanded to include any flags that are */
62 /* not already part of hat_attr */
63 void *devmap_data; /* devmap_handle private data */
67 * (Semi) private data maintained by the seg_dev driver per segment mapping
69 * The segment lock is necessary to protect fields that are modified
70 * when the "read" version of the address space lock is held. This lock
71 * is not needed when the segment operation has the "write" version of
72 * the address space lock (it would be redundant).
74 * The following fields in segdev_data are read-only when the address
75 * space is "read" locked, and don't require the segment lock:
77 * vp
78 * offset
79 * mapfunc
80 * maxprot
82 struct segdev_data {
83 offset_t offset; /* device offset for start of mapping */
84 krwlock_t lock; /* protects segdev_data */
85 int (*mapfunc)(dev_t dev, off_t off, int prot);
86 struct vnode *vp; /* vnode associated with device */
87 uchar_t pageprot; /* true if per page protections present */
88 uchar_t prot; /* current segment prot if pageprot == 0 */
89 uchar_t maxprot; /* maximum segment protections */
90 uchar_t type; /* type of sharing done */
91 struct vpage *vpage; /* per-page information, if needed */
92 uint_t hat_attr; /* hat attr - pass to attr in hat_devload */
93 uint_t hat_flags; /* set HAT_LOAD_NOCONSIST flag in hat_devload */
94 /* see comments above in segdev_crargs */
95 size_t softlockcnt; /* # of SOFTLOCKED in seg */
96 void *devmap_data; /* devmap_handle private data */
99 /* Direct physical-userland mapping, without occupying kernel address space */
100 #define DEVMAP_PMEM_COOKIE ((ddi_umem_cookie_t)0x2)
103 * pmem_cookie:
104 * Records physical memory pages to be exported to userland.
106 struct devmap_pmem_cookie {
107 pgcnt_t dp_npages; /* number of allocated mem pages */
108 page_t **dp_pparray; /* pages allocated for this cookie */
109 vnode_t *dp_vnp; /* vnode associated with this cookie */
110 proc_t *dp_proc; /* proc ptr for resource control */
113 #ifdef _KERNEL
116 * Mappings of /dev/null come from segdev and have no mapping type.
119 #define SEG_IS_DEVNULL_MAPPING(seg) \
120 ((seg)->s_ops == &segdev_ops && \
121 ((SEGOP_GETTYPE(seg, (seg)->s_base) & (MAP_SHARED | MAP_PRIVATE)) == 0))
123 extern void segdev_init(void);
125 extern int segdev_create(struct seg *, void *);
127 extern int segdev_copyto(struct seg *, caddr_t, const void *, void *, size_t);
128 extern int segdev_copyfrom(struct seg *, caddr_t, const void *, void *, size_t);
129 extern struct seg_ops segdev_ops;
131 #endif /* _KERNEL */
133 #ifdef __cplusplus
135 #endif
137 #endif /* _VM_SEG_DEV_H */