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, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28 /* All Rights Reserved */ 29 30 /* 31 * University Copyright- Copyright (c) 1982, 1986, 1988 32 * The Regents of the University of California 33 * All Rights Reserved 34 * 35 * University Acknowledgment- Portions of this document are derived from 36 * software developed by the University of California, Berkeley, and its 37 * contributors. 38 */ 39 40 #ifndef _VM_SEG_DEV_H 41 #define _VM_SEG_DEV_H 42 43 #pragma ident "%Z%%M% %I% %E% SMI" 44 45 #include <sys/project.h> 46 47 #ifdef __cplusplus 48 extern "C" { 49 #endif 50 51 /* 52 * Structure whose pointer is passed to the segdev_create routine 53 */ 54 struct segdev_crargs { 55 offset_t offset; /* starting offset */ 56 int (*mapfunc)(dev_t dev, off_t off, int prot); /* map function */ 57 dev_t dev; /* device number */ 58 uchar_t type; /* type of sharing done */ 59 uchar_t prot; /* protection */ 60 uchar_t maxprot; /* maximum protection */ 61 uint_t hat_attr; /* hat attr */ 62 uint_t hat_flags; /* currently, hat_flags is used ONLY for */ 63 /* HAT_LOAD_NOCONSIST; in future, it can be */ 64 /* expanded to include any flags that are */ 65 /* not already part of hat_attr */ 66 void *devmap_data; /* devmap_handle private data */ 67 }; 68 69 /* 70 * (Semi) private data maintained by the seg_dev driver per segment mapping 71 * 72 * The segment lock is necessary to protect fields that are modified 73 * when the "read" version of the address space lock is held. This lock 74 * is not needed when the segment operation has the "write" version of 75 * the address space lock (it would be redundant). 76 * 77 * The following fields in segdev_data are read-only when the address 78 * space is "read" locked, and don't require the segment lock: 79 * 80 * vp 81 * offset 82 * mapfunc 83 * maxprot 84 */ 85 struct segdev_data { 86 offset_t offset; /* device offset for start of mapping */ 87 kmutex_t lock; /* protects segdev_data */ 88 int (*mapfunc)(dev_t dev, off_t off, int prot); 89 struct vnode *vp; /* vnode associated with device */ 90 uchar_t pageprot; /* true if per page protections present */ 91 uchar_t prot; /* current segment prot if pageprot == 0 */ 92 uchar_t maxprot; /* maximum segment protections */ 93 uchar_t type; /* type of sharing done */ 94 struct vpage *vpage; /* per-page information, if needed */ 95 uint_t hat_attr; /* hat attr - pass to attr in hat_devload */ 96 uint_t hat_flags; /* set HAT_LOAD_NOCONSIST flag in hat_devload */ 97 /* see comments above in segdev_crargs */ 98 size_t softlockcnt; /* # of SOFTLOCKED in seg */ 99 void *devmap_data; /* devmap_handle private data */ 100 }; 101 102 /* Direct physical-userland mapping, without occupying kernel address space */ 103 #define DEVMAP_PMEM_COOKIE ((ddi_umem_cookie_t)0x2) 104 105 /* 106 * pmem_cookie: 107 * Records physical memory pages to be exported to userland. 108 */ 109 struct devmap_pmem_cookie { 110 pgcnt_t dp_npages; /* number of allocated mem pages */ 111 page_t **dp_pparray; /* pages allocated for this cookie */ 112 vnode_t *dp_vnp; /* vnode associated with this cookie */ 113 kproject_t *dp_projp; /* project ptr for resource ctl */ 114 }; 115 116 #ifdef _KERNEL 117 118 extern void segdev_init(void); 119 120 extern int segdev_create(struct seg *, void *); 121 122 extern int segdev_copyto(struct seg *, caddr_t, const void *, void *, size_t); 123 extern int segdev_copyfrom(struct seg *, caddr_t, const void *, void *, size_t); 124 125 #endif /* _KERNEL */ 126 127 #ifdef __cplusplus 128 } 129 #endif 130 131 #endif /* _VM_SEG_DEV_H */ 132