91 * open to prevent it from disappearing.
92 */
93 uint64_t physmem_vnodecnt;
94 kmutex_t physmem_mutex; /* protects phsymem_vnodecnt */
95
96 static int physmem_getpage(struct vnode *vp, offset_t off, size_t len,
97 uint_t *protp, page_t *pl[], size_t plsz, struct seg *seg, caddr_t addr,
98 enum seg_rw rw, struct cred *cr, caller_context_t *ct);
99
100 static int physmem_addmap(struct vnode *vp, offset_t off, struct as *as,
101 caddr_t addr, size_t len, uchar_t prot, uchar_t maxprot, uint_t flags,
102 struct cred *cred, caller_context_t *ct);
103
104 static int physmem_delmap(struct vnode *vp, offset_t off, struct as *as,
105 caddr_t addr, size_t len, uint_t prot, uint_t maxprot, uint_t flags,
106 struct cred *cred, caller_context_t *ct);
107
108 static void physmem_inactive(vnode_t *vp, cred_t *crp, caller_context_t *ct);
109
110 const fs_operation_def_t physmem_vnodeops_template[] = {
111 VOPNAME_GETPAGE, { .vop_getpage = physmem_getpage },
112 VOPNAME_ADDMAP, { .vop_addmap = physmem_addmap },
113 VOPNAME_DELMAP, { .vop_delmap = physmem_delmap },
114 VOPNAME_INACTIVE, { .vop_inactive = physmem_inactive },
115 NULL, NULL
116 };
117
118 vnodeops_t *physmem_vnodeops = NULL;
119
120 /*
121 * Removes the current process from the hash if the process has no more
122 * physmem segments active.
123 */
124 void
125 physmem_remove_hash_proc()
126 {
127 int index;
128 struct physmem_proc_hash **walker;
129 struct physmem_proc_hash *victim = NULL;
130
131 index = PHYSMEM_HASH(curproc);
132 rw_enter(&pph_rwlock, RW_WRITER);
133 walker = &pph[index];
134 while (*walker != NULL) {
135 if ((*walker)->pph_proc == curproc &&
943 physmem_getinfo,
944 nulldev,
945 nulldev,
946 physmem_attach,
947 physmem_detach,
948 nodev,
949 &physmem_cb_ops,
950 NULL,
951 NULL,
952 ddi_quiesce_not_needed, /* quiesce */
953 };
954
955 static struct modldrv modldrv = {
956 &mod_driverops,
957 "physmem driver",
958 &physmem_ops
959 };
960
961 static struct modlinkage modlinkage = {
962 MODREV_1,
963 &modldrv,
964 NULL
965 };
966
967 int
968 _init(void)
969 {
970 return (mod_install(&modlinkage));
971 }
972
973 int
974 _info(struct modinfo *modinfop)
975 {
976 return (mod_info(&modlinkage, modinfop));
977 }
978
979 int
980 _fini(void)
981 {
982 return (mod_remove(&modlinkage));
983 }
|
91 * open to prevent it from disappearing.
92 */
93 uint64_t physmem_vnodecnt;
94 kmutex_t physmem_mutex; /* protects phsymem_vnodecnt */
95
96 static int physmem_getpage(struct vnode *vp, offset_t off, size_t len,
97 uint_t *protp, page_t *pl[], size_t plsz, struct seg *seg, caddr_t addr,
98 enum seg_rw rw, struct cred *cr, caller_context_t *ct);
99
100 static int physmem_addmap(struct vnode *vp, offset_t off, struct as *as,
101 caddr_t addr, size_t len, uchar_t prot, uchar_t maxprot, uint_t flags,
102 struct cred *cred, caller_context_t *ct);
103
104 static int physmem_delmap(struct vnode *vp, offset_t off, struct as *as,
105 caddr_t addr, size_t len, uint_t prot, uint_t maxprot, uint_t flags,
106 struct cred *cred, caller_context_t *ct);
107
108 static void physmem_inactive(vnode_t *vp, cred_t *crp, caller_context_t *ct);
109
110 const fs_operation_def_t physmem_vnodeops_template[] = {
111 { VOPNAME_GETPAGE, { .vop_getpage = physmem_getpage } },
112 { VOPNAME_ADDMAP, { .vop_addmap = physmem_addmap } },
113 { VOPNAME_DELMAP, { .vop_delmap = physmem_delmap } },
114 { VOPNAME_INACTIVE, { .vop_inactive = physmem_inactive } },
115 { NULL, { NULL } }
116 };
117
118 vnodeops_t *physmem_vnodeops = NULL;
119
120 /*
121 * Removes the current process from the hash if the process has no more
122 * physmem segments active.
123 */
124 void
125 physmem_remove_hash_proc()
126 {
127 int index;
128 struct physmem_proc_hash **walker;
129 struct physmem_proc_hash *victim = NULL;
130
131 index = PHYSMEM_HASH(curproc);
132 rw_enter(&pph_rwlock, RW_WRITER);
133 walker = &pph[index];
134 while (*walker != NULL) {
135 if ((*walker)->pph_proc == curproc &&
943 physmem_getinfo,
944 nulldev,
945 nulldev,
946 physmem_attach,
947 physmem_detach,
948 nodev,
949 &physmem_cb_ops,
950 NULL,
951 NULL,
952 ddi_quiesce_not_needed, /* quiesce */
953 };
954
955 static struct modldrv modldrv = {
956 &mod_driverops,
957 "physmem driver",
958 &physmem_ops
959 };
960
961 static struct modlinkage modlinkage = {
962 MODREV_1,
963 { &modldrv, NULL }
964 };
965
966 int
967 _init(void)
968 {
969 return (mod_install(&modlinkage));
970 }
971
972 int
973 _info(struct modinfo *modinfop)
974 {
975 return (mod_info(&modlinkage, modinfop));
976 }
977
978 int
979 _fini(void)
980 {
981 return (mod_remove(&modlinkage));
982 }
|