1 /* 2 * CDDL HEADER START 3 * 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. 7 * 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 2006 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 27 /* All Rights Reserved */ 28 29 /* 30 * University Copyright- Copyright (c) 1982, 1986, 1988 31 * The Regents of the University of California 32 * All Rights Reserved 33 * 34 * University Acknowledgment- Portions of this document are derived from 35 * software developed by the University of California, Berkeley, and its 36 * contributors. 37 */ 38 39 #ifndef _VM_SEG_DEV_H 40 #define _VM_SEG_DEV_H 41 42 #pragma ident "%Z%%M% %I% %E% SMI" 43 44 #ifdef __cplusplus 45 extern "C" { 46 #endif 47 48 struct proc; 49 50 /* 51 * Structure whose pointer is passed to the segdev_create routine 52 */ 53 struct segdev_crargs { 54 offset_t offset; /* starting offset */ 55 int (*mapfunc)(dev_t dev, off_t off, int prot); /* map function */ 56 dev_t dev; /* device number */ 57 uchar_t type; /* type of sharing done */ 58 uchar_t prot; /* protection */ 59 uchar_t maxprot; /* maximum protection */ 60 uint_t hat_attr; /* hat attr */ 61 uint_t hat_flags; /* currently, hat_flags is used ONLY for */ 62 /* HAT_LOAD_NOCONSIST; in future, it can be */ 63 /* expanded to include any flags that are */ 64 /* not already part of hat_attr */ 65 void *devmap_data; /* devmap_handle private data */ 66 }; 67 68 /* 69 * (Semi) private data maintained by the seg_dev driver per segment mapping 70 * 71 * The segment lock is necessary to protect fields that are modified 72 * when the "read" version of the address space lock is held. This lock 73 * is not needed when the segment operation has the "write" version of 74 * the address space lock (it would be redundant). 75 * 76 * The following fields in segdev_data are read-only when the address 77 * space is "read" locked, and don't require the segment lock: 78 * 79 * vp 80 * offset 81 * mapfunc 82 * maxprot 83 */ 84 struct segdev_data { 85 offset_t offset; /* device offset for start of mapping */ 86 kmutex_t lock; /* protects segdev_data */ 87 int (*mapfunc)(dev_t dev, off_t off, int prot); 88 struct vnode *vp; /* vnode associated with device */ 89 uchar_t pageprot; /* true if per page protections present */ 90 uchar_t prot; /* current segment prot if pageprot == 0 */ 91 uchar_t maxprot; /* maximum segment protections */ 92 uchar_t type; /* type of sharing done */ 93 struct vpage *vpage; /* per-page information, if needed */ 94 uint_t hat_attr; /* hat attr - pass to attr in hat_devload */ 95 uint_t hat_flags; /* set HAT_LOAD_NOCONSIST flag in hat_devload */ 96 /* see comments above in segdev_crargs */ 97 size_t softlockcnt; /* # of SOFTLOCKED in seg */ 98 void *devmap_data; /* devmap_handle private data */ 99 }; 100 101 /* Direct physical-userland mapping, without occupying kernel address space */ 102 #define DEVMAP_PMEM_COOKIE ((ddi_umem_cookie_t)0x2) 103 104 /* 105 * pmem_cookie: 106 * Records physical memory pages to be exported to userland. 107 */ 108 struct devmap_pmem_cookie { 109 pgcnt_t dp_npages; /* number of allocated mem pages */ 110 page_t **dp_pparray; /* pages allocated for this cookie */ 111 vnode_t *dp_vnp; /* vnode associated with this cookie */ 112 proc_t *dp_proc; /* proc ptr for resource control */ 113 }; 114 115 #ifdef _KERNEL 116 117 extern void segdev_init(void); 118 119 extern int segdev_create(struct seg *, void *); 120 121 extern int segdev_copyto(struct seg *, caddr_t, const void *, void *, size_t); 122 extern int segdev_copyfrom(struct seg *, caddr_t, const void *, void *, size_t); 123 124 #endif /* _KERNEL */ 125 126 #ifdef __cplusplus 127 } 128 #endif 129 130 #endif /* _VM_SEG_DEV_H */ 131