10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*2768Ssl108498 * Common Development and Distribution License (the "License"). 6*2768Ssl108498 * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*2768Ssl108498 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 270Sstevel@tonic-gate /* All Rights Reserved */ 280Sstevel@tonic-gate 290Sstevel@tonic-gate /* 300Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988 310Sstevel@tonic-gate * The Regents of the University of California 320Sstevel@tonic-gate * All Rights Reserved 330Sstevel@tonic-gate * 340Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from 350Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its 360Sstevel@tonic-gate * contributors. 370Sstevel@tonic-gate */ 380Sstevel@tonic-gate 390Sstevel@tonic-gate #ifndef _VM_SEG_DEV_H 400Sstevel@tonic-gate #define _VM_SEG_DEV_H 410Sstevel@tonic-gate 420Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 430Sstevel@tonic-gate 440Sstevel@tonic-gate #ifdef __cplusplus 450Sstevel@tonic-gate extern "C" { 460Sstevel@tonic-gate #endif 470Sstevel@tonic-gate 48*2768Ssl108498 struct proc; 49*2768Ssl108498 500Sstevel@tonic-gate /* 510Sstevel@tonic-gate * Structure whose pointer is passed to the segdev_create routine 520Sstevel@tonic-gate */ 530Sstevel@tonic-gate struct segdev_crargs { 540Sstevel@tonic-gate offset_t offset; /* starting offset */ 550Sstevel@tonic-gate int (*mapfunc)(dev_t dev, off_t off, int prot); /* map function */ 560Sstevel@tonic-gate dev_t dev; /* device number */ 570Sstevel@tonic-gate uchar_t type; /* type of sharing done */ 580Sstevel@tonic-gate uchar_t prot; /* protection */ 590Sstevel@tonic-gate uchar_t maxprot; /* maximum protection */ 600Sstevel@tonic-gate uint_t hat_attr; /* hat attr */ 610Sstevel@tonic-gate uint_t hat_flags; /* currently, hat_flags is used ONLY for */ 620Sstevel@tonic-gate /* HAT_LOAD_NOCONSIST; in future, it can be */ 630Sstevel@tonic-gate /* expanded to include any flags that are */ 640Sstevel@tonic-gate /* not already part of hat_attr */ 650Sstevel@tonic-gate void *devmap_data; /* devmap_handle private data */ 660Sstevel@tonic-gate }; 670Sstevel@tonic-gate 680Sstevel@tonic-gate /* 690Sstevel@tonic-gate * (Semi) private data maintained by the seg_dev driver per segment mapping 700Sstevel@tonic-gate * 710Sstevel@tonic-gate * The segment lock is necessary to protect fields that are modified 720Sstevel@tonic-gate * when the "read" version of the address space lock is held. This lock 730Sstevel@tonic-gate * is not needed when the segment operation has the "write" version of 740Sstevel@tonic-gate * the address space lock (it would be redundant). 750Sstevel@tonic-gate * 760Sstevel@tonic-gate * The following fields in segdev_data are read-only when the address 770Sstevel@tonic-gate * space is "read" locked, and don't require the segment lock: 780Sstevel@tonic-gate * 790Sstevel@tonic-gate * vp 800Sstevel@tonic-gate * offset 810Sstevel@tonic-gate * mapfunc 820Sstevel@tonic-gate * maxprot 830Sstevel@tonic-gate */ 840Sstevel@tonic-gate struct segdev_data { 850Sstevel@tonic-gate offset_t offset; /* device offset for start of mapping */ 860Sstevel@tonic-gate kmutex_t lock; /* protects segdev_data */ 870Sstevel@tonic-gate int (*mapfunc)(dev_t dev, off_t off, int prot); 880Sstevel@tonic-gate struct vnode *vp; /* vnode associated with device */ 890Sstevel@tonic-gate uchar_t pageprot; /* true if per page protections present */ 900Sstevel@tonic-gate uchar_t prot; /* current segment prot if pageprot == 0 */ 910Sstevel@tonic-gate uchar_t maxprot; /* maximum segment protections */ 920Sstevel@tonic-gate uchar_t type; /* type of sharing done */ 930Sstevel@tonic-gate struct vpage *vpage; /* per-page information, if needed */ 940Sstevel@tonic-gate uint_t hat_attr; /* hat attr - pass to attr in hat_devload */ 950Sstevel@tonic-gate uint_t hat_flags; /* set HAT_LOAD_NOCONSIST flag in hat_devload */ 960Sstevel@tonic-gate /* see comments above in segdev_crargs */ 970Sstevel@tonic-gate size_t softlockcnt; /* # of SOFTLOCKED in seg */ 980Sstevel@tonic-gate void *devmap_data; /* devmap_handle private data */ 990Sstevel@tonic-gate }; 1000Sstevel@tonic-gate 1010Sstevel@tonic-gate /* Direct physical-userland mapping, without occupying kernel address space */ 1020Sstevel@tonic-gate #define DEVMAP_PMEM_COOKIE ((ddi_umem_cookie_t)0x2) 1030Sstevel@tonic-gate 1040Sstevel@tonic-gate /* 1050Sstevel@tonic-gate * pmem_cookie: 1060Sstevel@tonic-gate * Records physical memory pages to be exported to userland. 1070Sstevel@tonic-gate */ 1080Sstevel@tonic-gate struct devmap_pmem_cookie { 1090Sstevel@tonic-gate pgcnt_t dp_npages; /* number of allocated mem pages */ 1100Sstevel@tonic-gate page_t **dp_pparray; /* pages allocated for this cookie */ 1110Sstevel@tonic-gate vnode_t *dp_vnp; /* vnode associated with this cookie */ 112*2768Ssl108498 proc_t *dp_proc; /* proc ptr for resource control */ 1130Sstevel@tonic-gate }; 1140Sstevel@tonic-gate 1150Sstevel@tonic-gate #ifdef _KERNEL 1160Sstevel@tonic-gate 1170Sstevel@tonic-gate extern void segdev_init(void); 1180Sstevel@tonic-gate 1190Sstevel@tonic-gate extern int segdev_create(struct seg *, void *); 1200Sstevel@tonic-gate 1210Sstevel@tonic-gate extern int segdev_copyto(struct seg *, caddr_t, const void *, void *, size_t); 1220Sstevel@tonic-gate extern int segdev_copyfrom(struct seg *, caddr_t, const void *, void *, size_t); 1230Sstevel@tonic-gate 1240Sstevel@tonic-gate #endif /* _KERNEL */ 1250Sstevel@tonic-gate 1260Sstevel@tonic-gate #ifdef __cplusplus 1270Sstevel@tonic-gate } 1280Sstevel@tonic-gate #endif 1290Sstevel@tonic-gate 1300Sstevel@tonic-gate #endif /* _VM_SEG_DEV_H */ 131