17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5c6939658Ssl108498 * Common Development and Distribution License (the "License"). 6c6939658Ssl108498 * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*40688216SSudheer A * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 277c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate /* 307c478bd9Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988 317c478bd9Sstevel@tonic-gate * The Regents of the University of California 327c478bd9Sstevel@tonic-gate * All Rights Reserved 337c478bd9Sstevel@tonic-gate * 347c478bd9Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from 357c478bd9Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its 367c478bd9Sstevel@tonic-gate * contributors. 377c478bd9Sstevel@tonic-gate */ 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #ifndef _VM_SEG_DEV_H 407c478bd9Sstevel@tonic-gate #define _VM_SEG_DEV_H 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate #ifdef __cplusplus 437c478bd9Sstevel@tonic-gate extern "C" { 447c478bd9Sstevel@tonic-gate #endif 457c478bd9Sstevel@tonic-gate 46c6939658Ssl108498 struct proc; 47c6939658Ssl108498 487c478bd9Sstevel@tonic-gate /* 497c478bd9Sstevel@tonic-gate * Structure whose pointer is passed to the segdev_create routine 507c478bd9Sstevel@tonic-gate */ 517c478bd9Sstevel@tonic-gate struct segdev_crargs { 527c478bd9Sstevel@tonic-gate offset_t offset; /* starting offset */ 537c478bd9Sstevel@tonic-gate int (*mapfunc)(dev_t dev, off_t off, int prot); /* map function */ 547c478bd9Sstevel@tonic-gate dev_t dev; /* device number */ 557c478bd9Sstevel@tonic-gate uchar_t type; /* type of sharing done */ 567c478bd9Sstevel@tonic-gate uchar_t prot; /* protection */ 577c478bd9Sstevel@tonic-gate uchar_t maxprot; /* maximum protection */ 587c478bd9Sstevel@tonic-gate uint_t hat_attr; /* hat attr */ 597c478bd9Sstevel@tonic-gate uint_t hat_flags; /* currently, hat_flags is used ONLY for */ 607c478bd9Sstevel@tonic-gate /* HAT_LOAD_NOCONSIST; in future, it can be */ 617c478bd9Sstevel@tonic-gate /* expanded to include any flags that are */ 627c478bd9Sstevel@tonic-gate /* not already part of hat_attr */ 637c478bd9Sstevel@tonic-gate void *devmap_data; /* devmap_handle private data */ 647c478bd9Sstevel@tonic-gate }; 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate /* 677c478bd9Sstevel@tonic-gate * (Semi) private data maintained by the seg_dev driver per segment mapping 687c478bd9Sstevel@tonic-gate * 697c478bd9Sstevel@tonic-gate * The segment lock is necessary to protect fields that are modified 707c478bd9Sstevel@tonic-gate * when the "read" version of the address space lock is held. This lock 717c478bd9Sstevel@tonic-gate * is not needed when the segment operation has the "write" version of 727c478bd9Sstevel@tonic-gate * the address space lock (it would be redundant). 737c478bd9Sstevel@tonic-gate * 747c478bd9Sstevel@tonic-gate * The following fields in segdev_data are read-only when the address 757c478bd9Sstevel@tonic-gate * space is "read" locked, and don't require the segment lock: 767c478bd9Sstevel@tonic-gate * 777c478bd9Sstevel@tonic-gate * vp 787c478bd9Sstevel@tonic-gate * offset 797c478bd9Sstevel@tonic-gate * mapfunc 807c478bd9Sstevel@tonic-gate * maxprot 817c478bd9Sstevel@tonic-gate */ 827c478bd9Sstevel@tonic-gate struct segdev_data { 837c478bd9Sstevel@tonic-gate offset_t offset; /* device offset for start of mapping */ 8444374aaeSsvemuri krwlock_t lock; /* protects segdev_data */ 857c478bd9Sstevel@tonic-gate int (*mapfunc)(dev_t dev, off_t off, int prot); 867c478bd9Sstevel@tonic-gate struct vnode *vp; /* vnode associated with device */ 877c478bd9Sstevel@tonic-gate uchar_t pageprot; /* true if per page protections present */ 887c478bd9Sstevel@tonic-gate uchar_t prot; /* current segment prot if pageprot == 0 */ 897c478bd9Sstevel@tonic-gate uchar_t maxprot; /* maximum segment protections */ 907c478bd9Sstevel@tonic-gate uchar_t type; /* type of sharing done */ 917c478bd9Sstevel@tonic-gate struct vpage *vpage; /* per-page information, if needed */ 927c478bd9Sstevel@tonic-gate uint_t hat_attr; /* hat attr - pass to attr in hat_devload */ 937c478bd9Sstevel@tonic-gate uint_t hat_flags; /* set HAT_LOAD_NOCONSIST flag in hat_devload */ 947c478bd9Sstevel@tonic-gate /* see comments above in segdev_crargs */ 957c478bd9Sstevel@tonic-gate size_t softlockcnt; /* # of SOFTLOCKED in seg */ 967c478bd9Sstevel@tonic-gate void *devmap_data; /* devmap_handle private data */ 977c478bd9Sstevel@tonic-gate }; 987c478bd9Sstevel@tonic-gate 997c478bd9Sstevel@tonic-gate /* Direct physical-userland mapping, without occupying kernel address space */ 1007c478bd9Sstevel@tonic-gate #define DEVMAP_PMEM_COOKIE ((ddi_umem_cookie_t)0x2) 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate /* 1037c478bd9Sstevel@tonic-gate * pmem_cookie: 1047c478bd9Sstevel@tonic-gate * Records physical memory pages to be exported to userland. 1057c478bd9Sstevel@tonic-gate */ 1067c478bd9Sstevel@tonic-gate struct devmap_pmem_cookie { 1077c478bd9Sstevel@tonic-gate pgcnt_t dp_npages; /* number of allocated mem pages */ 1087c478bd9Sstevel@tonic-gate page_t **dp_pparray; /* pages allocated for this cookie */ 1097c478bd9Sstevel@tonic-gate vnode_t *dp_vnp; /* vnode associated with this cookie */ 110c6939658Ssl108498 proc_t *dp_proc; /* proc ptr for resource control */ 1117c478bd9Sstevel@tonic-gate }; 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate #ifdef _KERNEL 1147c478bd9Sstevel@tonic-gate 115*40688216SSudheer A /* 116*40688216SSudheer A * Mappings of /dev/null come from segdev and have no mapping type. 117*40688216SSudheer A */ 118*40688216SSudheer A 119*40688216SSudheer A #define SEG_IS_DEVNULL_MAPPING(seg) \ 120*40688216SSudheer A ((seg)->s_ops == &segdev_ops && \ 121*40688216SSudheer A ((SEGOP_GETTYPE(seg, (seg)->s_base) & (MAP_SHARED | MAP_PRIVATE)) == 0)) 122*40688216SSudheer A 1237c478bd9Sstevel@tonic-gate extern void segdev_init(void); 1247c478bd9Sstevel@tonic-gate 1257c478bd9Sstevel@tonic-gate extern int segdev_create(struct seg *, void *); 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate extern int segdev_copyto(struct seg *, caddr_t, const void *, void *, size_t); 1287c478bd9Sstevel@tonic-gate extern int segdev_copyfrom(struct seg *, caddr_t, const void *, void *, size_t); 1290616c1c3SMichael Corcoran extern struct seg_ops segdev_ops; 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1347c478bd9Sstevel@tonic-gate } 1357c478bd9Sstevel@tonic-gate #endif 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate #endif /* _VM_SEG_DEV_H */ 138